diff --git a/dist/api/account.api.d.ts b/dist/api/account.api.d.ts index 387bd84..3a673e5 100644 --- a/dist/api/account.api.d.ts +++ b/dist/api/account.api.d.ts @@ -1,10 +1,11 @@ import { AxiosInstance } from 'axios'; +import { TonProofItemReply } from '@tonconnect/sdk'; type TAccountType = 'email' | 'block_chain'; export type TAccountRole = 'B' | 'C'; export type TDeviceType = 'WEB' | 'TG' | 'PLUG'; export interface ILoginResponse { token: string; - old_token: string; + old_token?: string; user_id: string; new_user: boolean; } @@ -23,12 +24,23 @@ interface ILoginParamsBase { [key: string]: any; }; } +interface IConnectParamsBase { + account_type: string; + connector: 'codatta_email' | 'codatta_wallet' | 'codatta_ton'; + account_enum: TAccountRole; +} interface IEmailLoginParams extends ILoginParamsBase { connector: 'codatta_email'; account_type: 'email'; email: string; email_code: string; } +interface IEmailConnectParams extends IConnectParamsBase { + connector: 'codatta_email'; + account_type: 'email'; + email: string; + email_code: string; +} interface IWalletLoginParams extends ILoginParamsBase { connector: 'codatta_wallet'; account_type: 'block_chain'; @@ -39,13 +51,35 @@ interface IWalletLoginParams extends ILoginParamsBase { signature: string; message: string; } +interface IWalletConnectParams extends IConnectParamsBase { + connector: 'codatta_wallet'; + account_type: 'block_chain'; + address: string; + wallet_name: string; + chain: string; + nonce: string; + signature: string; + message: string; +} interface ITonLoginParams extends ILoginParamsBase { connector: 'codatta_ton'; account_type: 'block_chain'; wallet_name: string; address: string; chain: string; - connect_info: object[]; + connect_info: [{ + [key: string]: string; + }, TonProofItemReply]; +} +interface ITonConnectParams extends IConnectParamsBase { + connector: 'codatta_ton'; + account_type: 'block_chain'; + wallet_name: string; + address: string; + chain: string; + connect_info: [{ + [key: string]: string; + }, TonProofItemReply]; } declare class AccountApi { private request; @@ -58,7 +92,7 @@ declare class AccountApi { getEmailCode(props: { account_type: TAccountType; email: string; - }): Promise; + }, captcha: string): Promise; emailLogin(props: IEmailLoginParams): Promise<{ data: ILoginResponse; }>; @@ -68,6 +102,9 @@ declare class AccountApi { tonLogin(props: ITonLoginParams): Promise<{ data: ILoginResponse; }>; + bindEmail(props: IEmailConnectParams): Promise; + bindTonWallet(props: ITonConnectParams): Promise; + bindEvmWallet(props: IWalletConnectParams): Promise; } declare const _default: AccountApi; export default _default; diff --git a/dist/codatta-connect-context-provider.d.ts b/dist/codatta-connect-context-provider.d.ts index 982ea2b..ea5996f 100644 --- a/dist/codatta-connect-context-provider.d.ts +++ b/dist/codatta-connect-context-provider.d.ts @@ -1,4 +1,5 @@ import { WalletItem } from './types/wallet-item.class'; +import { Chain } from 'viem'; export declare const coinbaseWallet: { getProvider: () => import('@coinbase/wallet-sdk').ProviderInterface; }; @@ -8,11 +9,14 @@ interface CodattaConnectContext { featuredWallets: WalletItem[]; lastUsedWallet: WalletItem | null; saveLastUsedWallet: (wallet: WalletItem) => void; + chains: Chain[]; } export declare function useCodattaConnectContext(): CodattaConnectContext; interface CodattaConnectContextProviderProps { children: React.ReactNode; apiBaseUrl?: string; + singleWalletName?: string; + chains?: Chain[]; } export declare function CodattaConnectContextProvider(props: CodattaConnectContextProviderProps): import("react/jsx-runtime").JSX.Element; export {}; diff --git a/dist/codatta-connect.css b/dist/codatta-connect.css new file mode 100644 index 0000000..fd83dcb --- /dev/null +++ b/dist/codatta-connect.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.xc-pointer-events-none{pointer-events:none}.xc-absolute{position:absolute}.xc-relative{position:relative}.xc-inset-0{inset:0}.xc-left-0{left:0}.xc-right-2{right:.5rem}.xc-top-0{top:0}.xc-z-10{z-index:10}.xc-m-auto{margin:auto}.xc-mx-auto{margin-left:auto;margin-right:auto}.xc-mb-1{margin-bottom:.25rem}.xc-mb-12{margin-bottom:3rem}.xc-mb-2{margin-bottom:.5rem}.xc-mb-3{margin-bottom:.75rem}.xc-mb-4{margin-bottom:1rem}.xc-mb-6{margin-bottom:1.5rem}.xc-mb-8{margin-bottom:2rem}.xc-ml-auto{margin-left:auto}.xc-mt-4{margin-top:1rem}.xc-box-content{box-sizing:content-box}.xc-block{display:block}.xc-inline-block{display:inline-block}.xc-flex{display:flex}.xc-grid{display:grid}.xc-aspect-\[1\/1\]{aspect-ratio:1/1}.xc-h-1{height:.25rem}.xc-h-10{height:2.5rem}.xc-h-12{height:3rem}.xc-h-16{height:4rem}.xc-h-4{height:1rem}.xc-h-5{height:1.25rem}.xc-h-6{height:1.5rem}.xc-h-\[309px\]{height:309px}.xc-h-full{height:100%}.xc-h-screen{height:100vh}.xc-max-h-\[272px\]{max-height:272px}.xc-max-h-\[309px\]{max-height:309px}.xc-w-1{width:.25rem}.xc-w-10{width:2.5rem}.xc-w-12{width:3rem}.xc-w-16{width:4rem}.xc-w-5{width:1.25rem}.xc-w-6{width:1.5rem}.xc-w-full{width:100%}.xc-w-px{width:1px}.xc-min-w-\[160px\]{min-width:160px}.xc-min-w-\[277px\]{min-width:277px}.xc-max-w-\[272px\]{max-width:272px}.xc-max-w-\[400px\]{max-width:400px}.xc-max-w-\[420px\]{max-width:420px}.xc-flex-1{flex:1 1 0%}.xc-shrink-0{flex-shrink:0}@keyframes xc-caret-blink{0%,70%,to{opacity:1}20%,50%{opacity:0}}.xc-animate-caret-blink{animation:xc-caret-blink 1.25s ease-out infinite}@keyframes xc-spin{to{transform:rotate(360deg)}}.xc-animate-spin{animation:xc-spin 1s linear infinite}.xc-cursor-pointer{cursor:pointer}.xc-appearance-none{appearance:none}.xc-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.xc-flex-col{flex-direction:column}.xc-flex-wrap{flex-wrap:wrap}.xc-items-center{align-items:center}.xc-justify-center{justify-content:center}.xc-justify-between{justify-content:space-between}.xc-gap-2{gap:.5rem}.xc-gap-3{gap:.75rem}.xc-gap-4{gap:1rem}.xc-overflow-hidden{overflow:hidden}.xc-overflow-scroll{overflow:scroll}.xc-rounded-2xl{border-radius:1rem}.xc-rounded-full{border-radius:9999px}.xc-rounded-lg{border-radius:.5rem}.xc-rounded-md{border-radius:.375rem}.xc-rounded-xl{border-radius:.75rem}.xc-border{border-width:1px}.xc-border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.xc-border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.xc-border-opacity-15{--tw-border-opacity: .15}.xc-border-opacity-20{--tw-border-opacity: .2}.xc-bg-\[\#009E8C\]{--tw-bg-opacity: 1;background-color:rgb(0 158 140 / var(--tw-bg-opacity, 1))}.xc-bg-\[\#2596FF\]{--tw-bg-opacity: 1;background-color:rgb(37 150 255 / var(--tw-bg-opacity, 1))}.xc-bg-\[rgb\(135\,93\,255\)\]{--tw-bg-opacity: 1;background-color:rgb(135 93 255 / var(--tw-bg-opacity, 1))}.xc-bg-\[rgb\(28\,28\,38\)\]{--tw-bg-opacity: 1;background-color:rgb(28 28 38 / var(--tw-bg-opacity, 1))}.xc-bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.xc-bg-transparent{background-color:transparent}.xc-bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.xc-bg-opacity-10{--tw-bg-opacity: .1}.xc-p-1{padding:.25rem}.xc-p-6{padding:1.5rem}.xc-px-3{padding-left:.75rem;padding-right:.75rem}.xc-px-4{padding-left:1rem;padding-right:1rem}.xc-px-6{padding-left:1.5rem;padding-right:1.5rem}.xc-px-8{padding-left:2rem;padding-right:2rem}.xc-py-1{padding-top:.25rem;padding-bottom:.25rem}.xc-py-2{padding-top:.5rem;padding-bottom:.5rem}.xc-py-3{padding-top:.75rem;padding-bottom:.75rem}.xc-text-center{text-align:center}.xc-text-2xl{font-size:1.5rem;line-height:2rem}.xc-text-lg{font-size:1.125rem;line-height:1.75rem}.xc-text-sm{font-size:.875rem;line-height:1.25rem}.xc-text-xl{font-size:1.25rem;line-height:1.75rem}.xc-text-xs{font-size:.75rem;line-height:1rem}.xc-font-bold{font-weight:700}.xc-text-\[\#ff0000\]{--tw-text-opacity: 1;color:rgb(255 0 0 / var(--tw-text-opacity, 1))}.xc-text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.xc-text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.xc-text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.xc-text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.xc-opacity-0{opacity:0}.xc-opacity-100{opacity:1}.xc-opacity-20{opacity:.2}.xc-opacity-50{opacity:.5}.xc-opacity-80{opacity:.8}.xc-outline-none{outline:2px solid transparent;outline-offset:2px}.xc-ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.xc-ring-\[rgb\(135\,93\,255\)\]{--tw-ring-opacity: 1;--tw-ring-color: rgb(135 93 255 / var(--tw-ring-opacity, 1))}.xc-transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.xc-duration-1000{transition-duration:1s}.no-scrollbar::-webkit-scrollbar{display:none}.\[key\:string\]{key:string}.focus-within\:xc-border-opacity-40:focus-within{--tw-border-opacity: .4}.hover\:xc-shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.disabled\:xc-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:xc-bg-white:disabled{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.disabled\:xc-bg-opacity-10:disabled{--tw-bg-opacity: .1}.disabled\:xc-text-opacity-50:disabled{--tw-text-opacity: .5}.disabled\:xc-opacity-20:disabled{opacity:.2}.xc-group:hover .group-hover\:xc-left-2{left:.5rem}.xc-group:hover .group-hover\:xc-right-0{right:0}.xc-group:hover .group-hover\:xc-opacity-0{opacity:0}.xc-group:hover .group-hover\:xc-opacity-100{opacity:1} diff --git a/dist/codatta-connect.d.ts b/dist/codatta-connect.d.ts index 9b13953..ce33f8c 100644 --- a/dist/codatta-connect.d.ts +++ b/dist/codatta-connect.d.ts @@ -1,6 +1,28 @@ import { WalletItem } from './types/wallet-item.class'; -export default function CodattaConnect(props: { - onSelectMoreWallets: () => void; - onSelectTonConnect?: () => void; - onConnect: (wallet: WalletItem) => Promise; +import { default as TonConnect, Wallet } from '@tonconnect/sdk'; +import { WalletSignInfo } from './components/wallet-connect'; +import { WalletClient } from 'viem'; +export interface EmvWalletConnectInfo { + chain_type: 'eip155'; + client: WalletClient; + connect_info: WalletSignInfo; + wallet: WalletItem; +} +export interface TonWalletConnectInfo { + chain_type: 'ton'; + client: TonConnect; + connect_info: Wallet; + wallet: Wallet; +} +export declare function CodattaConnect(props: { + onEvmWalletConnect?: (connectInfo: EmvWalletConnectInfo) => Promise; + onTonWalletConnect?: (connectInfo: TonWalletConnectInfo) => Promise; + onEmailConnect?: (email: string, code: string) => Promise; + header?: React.ReactNode; + config?: { + showEmailSignIn?: boolean; + showFeaturedWallets?: boolean; + showMoreWallets?: boolean; + showTonConnect?: boolean; + }; }): import("react/jsx-runtime").JSX.Element; diff --git a/dist/components/email-captcha.d.ts b/dist/components/email-captcha.d.ts new file mode 100644 index 0000000..ca698d5 --- /dev/null +++ b/dist/components/email-captcha.d.ts @@ -0,0 +1,4 @@ +export default function EmailCaptcha(props: { + email: string; + onCodeSend: () => void; +}): import("react/jsx-runtime").JSX.Element; diff --git a/dist/components/email-connect-widget.d.ts b/dist/components/email-connect-widget.d.ts new file mode 100644 index 0000000..018ef8b --- /dev/null +++ b/dist/components/email-connect-widget.d.ts @@ -0,0 +1,5 @@ +export default function EmailConnectWidget(props: { + email: string; + onInputCode: (email: string, code: string) => Promise; + onBack: () => void; +}): import("react/jsx-runtime").JSX.Element; diff --git a/dist/components/email-connect.d.ts b/dist/components/email-connect.d.ts new file mode 100644 index 0000000..281027f --- /dev/null +++ b/dist/components/email-connect.d.ts @@ -0,0 +1,5 @@ +export default function EmailConnect(props: { + email: string; + onInputCode: (email: string, code: string) => Promise; + onResendCode: () => void; +}): import("react/jsx-runtime").JSX.Element; diff --git a/dist/components/email-login.d.ts b/dist/components/email-login-widget.d.ts similarity index 78% rename from dist/components/email-login.d.ts rename to dist/components/email-login-widget.d.ts index c1e13a4..0811c8f 100644 --- a/dist/components/email-login.d.ts +++ b/dist/components/email-login-widget.d.ts @@ -1,6 +1,6 @@ import { ILoginResponse } from '../api/account.api'; export default function EmailLoginWidget(props: { email: string; - onLogin: (res: ILoginResponse) => void; + onLogin: (res: ILoginResponse) => Promise; onBack: () => void; }): import("react/jsx-runtime").JSX.Element; diff --git a/dist/components/evm-wallet-login-widget.d.ts b/dist/components/evm-wallet-login-widget.d.ts index 0a590e6..d636a91 100644 --- a/dist/components/evm-wallet-login-widget.d.ts +++ b/dist/components/evm-wallet-login-widget.d.ts @@ -1,6 +1,6 @@ import { WalletItem } from '../types/wallet-item.class'; import { ILoginResponse } from '../api/account.api'; -export default function WalletLogin(props: { +export default function EvmWalletLoginWidget(props: { wallet: WalletItem; onLogin: (res: ILoginResponse) => void; onBack: () => void; diff --git a/dist/components/signin-index.d.ts b/dist/components/signin-index.d.ts index 94b3761..399bb94 100644 --- a/dist/components/signin-index.d.ts +++ b/dist/components/signin-index.d.ts @@ -5,6 +5,7 @@ export default function SingInIndex(props: { onSelectWallet: (walletOption: WalletItem) => void; onSelectMoreWallets: () => void; onSelectTonConnect: () => void; + useSingleWallet: boolean; config: { showEmailSignIn?: boolean; showTonConnect?: boolean; diff --git a/dist/components/single-wallet-option.d.ts b/dist/components/single-wallet-option.d.ts new file mode 100644 index 0000000..b885e7b --- /dev/null +++ b/dist/components/single-wallet-option.d.ts @@ -0,0 +1,5 @@ +import { WalletItem } from '../types/wallet-item.class'; +export default function SingleWalletOption(props: { + wallet: WalletItem; + onClick: (wallet: WalletItem) => void; +}): import("react/jsx-runtime").JSX.Element; diff --git a/dist/components/ton-wallet-connect.d.ts b/dist/components/ton-wallet-connect.d.ts index 2affda6..1c0cfa5 100644 --- a/dist/components/ton-wallet-connect.d.ts +++ b/dist/components/ton-wallet-connect.d.ts @@ -3,5 +3,5 @@ export default function TonWalletConnect(props: { connector: TonConnect; wallet: WalletInfoRemote | WalletInfoInjectable; onBack: () => void; - loading: boolean; + loading?: boolean; }): import("react/jsx-runtime").JSX.Element; diff --git a/dist/components/ton-wallet-select.d.ts b/dist/components/ton-wallet-select.d.ts index 5cbf8c7..49e7950 100644 --- a/dist/components/ton-wallet-select.d.ts +++ b/dist/components/ton-wallet-select.d.ts @@ -1,6 +1,6 @@ -import { default as TonConnect, WalletInfo } from '@tonconnect/sdk'; +import { default as TonConnect, WalletInfoInjectable, WalletInfoRemote } from '@tonconnect/sdk'; export default function TonWalletSelect(props: { connector: TonConnect; - onSelect: (wallet: WalletInfo) => void; + onSelect: (wallet: WalletInfoRemote | WalletInfoInjectable) => void; onBack: () => void; }): import("react/jsx-runtime").JSX.Element; diff --git a/dist/components/wallet-connect-widget.d.ts b/dist/components/wallet-connect-widget.d.ts index e06433d..ccd8159 100644 --- a/dist/components/wallet-connect-widget.d.ts +++ b/dist/components/wallet-connect-widget.d.ts @@ -1,6 +1,7 @@ +import { WalletSignInfo } from './wallet-connect'; import { WalletItem } from '../types/wallet-item.class'; export default function WalletConnectWidget(props: { wallet: WalletItem; - onConnect: (wallet: WalletItem) => void; + onConnect: (wallet: WalletItem, signInfo: WalletSignInfo) => void; onBack: () => void; }): import("react/jsx-runtime").JSX.Element; diff --git a/dist/components/wallet-connect.d.ts b/dist/components/wallet-connect.d.ts index 1507a58..4319fcd 100644 --- a/dist/components/wallet-connect.d.ts +++ b/dist/components/wallet-connect.d.ts @@ -1,12 +1,13 @@ import { WalletItem } from '../types/wallet-item.class'; +export interface WalletSignInfo { + message: string; + nonce: string; + signature: string; + address: string; + wallet_name: string; +} export default function WalletConnect(props: { wallet: WalletItem; - onSignFinish: (wallet: WalletItem, params: { - message: string; - nonce: string; - signature: string; - address: string; - wallet_name: string; - }) => Promise; + onSignFinish: (wallet: WalletItem, params: WalletSignInfo) => Promise; onShowQrCode: () => void; }): import("react/jsx-runtime").JSX.Element; diff --git a/dist/index.es.js b/dist/index.es.js index cfe7710..5c32103 100644 --- a/dist/index.es.js +++ b/dist/index.es.js @@ -1,7 +1,9 @@ -import { C as o, d as e, a as n, u as C } from "./main-7Oj8aJZz.js"; +import { l as o, C as e, k as n, W as C, j as s, u as d } from "./main-CtRNJ0s5.js"; export { - o as CodattaConnectContextProvider, - e as CodattaSignin, - n as coinbaseWallet, - C as useCodattaConnectContext + o as CodattaConnect, + e as CodattaConnectContextProvider, + n as CodattaSignin, + C as WalletItem, + s as coinbaseWallet, + d as useCodattaConnectContext }; diff --git a/dist/index.umd.js b/dist/index.umd.js index 8d8374d..8e81c5a 100644 --- a/dist/index.umd.js +++ b/dist/index.umd.js @@ -1,4 +1,4 @@ -(function(Vn,Pe){typeof exports=="object"&&typeof module<"u"?Pe(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],Pe):(Vn=typeof globalThis<"u"?globalThis:Vn||self,Pe(Vn["xny-connect"]={},Vn.React))})(this,function(Vn,Pe){"use strict";var noe=Object.defineProperty;var ioe=(Vn,Pe,Lc)=>Pe in Vn?noe(Vn,Pe,{enumerable:!0,configurable:!0,writable:!0,value:Lc}):Vn[Pe]=Lc;var so=(Vn,Pe,Lc)=>ioe(Vn,typeof Pe!="symbol"?Pe+"":Pe,Lc);function Lc(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const Yt=Lc(Pe);var nn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ui(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Jp(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var Xp={exports:{}},pf={};/** +(function(Ii,Se){typeof exports=="object"&&typeof module<"u"?Se(exports,require("react"),require("https://o.alicdn.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js")):typeof define=="function"&&define.amd?define(["exports","react","https://o.alicdn.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js"],Se):(Ii=typeof globalThis<"u"?globalThis:Ii||self,Se(Ii["xny-connect"]={},Ii.React))})(this,(function(Ii,Se){"use strict";function MA(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const Yt=MA(Se);var Wn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ny(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function n(){var i=!1;try{i=this instanceof n}catch{}return i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var Rl={exports:{}},du={};/** * @license React * react-jsx-runtime.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Hy;function UA(){if(Hy)return pf;Hy=1;var t=Pe,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(a,u,l){var d,g={},y=null,A=null;l!==void 0&&(y=""+l),u.key!==void 0&&(y=""+u.key),u.ref!==void 0&&(A=u.ref);for(d in u)n.call(u,d)&&!s.hasOwnProperty(d)&&(g[d]=u[d]);if(a&&a.defaultProps)for(d in u=a.defaultProps,u)g[d]===void 0&&(g[d]=u[d]);return{$$typeof:e,type:a,key:y,ref:A,props:g,_owner:i.current}}return pf.Fragment=r,pf.jsx=o,pf.jsxs=o,pf}var gf={};/** + */var iy;function CA(){if(iy)return du;iy=1;var t=Se,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(a,f,u){var h,g={},b=null,x=null;u!==void 0&&(b=""+u),f.key!==void 0&&(b=""+f.key),f.ref!==void 0&&(x=f.ref);for(h in f)n.call(f,h)&&!s.hasOwnProperty(h)&&(g[h]=f[h]);if(a&&a.defaultProps)for(h in f=a.defaultProps,f)g[h]===void 0&&(g[h]=f[h]);return{$$typeof:e,type:a,key:b,ref:x,props:g,_owner:i.current}}return du.Fragment=r,du.jsx=o,du.jsxs=o,du}var pu={};/** * @license React * react-jsx-runtime.development.js * @@ -14,42 +14,42 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Wy;function jA(){return Wy||(Wy=1,process.env.NODE_ENV!=="production"&&function(){var t=Pe,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),l=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),A=Symbol.for("react.offscreen"),P=Symbol.iterator,N="@@iterator";function D(j){if(j===null||typeof j!="object")return null;var oe=P&&j[P]||j[N];return typeof oe=="function"?oe:null}var k=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function $(j){{for(var oe=arguments.length,pe=new Array(oe>1?oe-1:0),xe=1;xe=1&&tt>=0&&je[st]!==gt[tt];)tt--;for(;st>=1&&tt>=0;st--,tt--)if(je[st]!==gt[tt]){if(st!==1||tt!==1)do if(st--,tt--,tt<0||je[st]!==gt[tt]){var At=` -`+je[st].replace(" at new "," at ");return j.displayName&&At.includes("")&&(At=At.replace("",j.displayName)),typeof j=="function"&&R.set(j,At),At}while(st>=1&&tt>=0);break}}}finally{Q=!1,se.current=De,O(),Error.prepareStackTrace=Re}var Rt=j?j.displayName||j.name:"",Mt=Rt?X(Rt):"";return typeof j=="function"&&R.set(j,Mt),Mt}function le(j,oe,pe){return te(j,!1)}function ie(j){var oe=j.prototype;return!!(oe&&oe.isReactComponent)}function fe(j,oe,pe){if(j==null)return"";if(typeof j=="function")return te(j,ie(j));if(typeof j=="string")return X(j);switch(j){case l:return X("Suspense");case d:return X("SuspenseList")}if(typeof j=="object")switch(j.$$typeof){case u:return le(j.render);case g:return fe(j.type,oe,pe);case y:{var xe=j,Re=xe._payload,De=xe._init;try{return fe(De(Re),oe,pe)}catch{}}}return""}var ve=Object.prototype.hasOwnProperty,Me={},Ne=k.ReactDebugCurrentFrame;function Te(j){if(j){var oe=j._owner,pe=fe(j.type,j._source,oe?oe.type:null);Ne.setExtraStackFrame(pe)}else Ne.setExtraStackFrame(null)}function Be(j,oe,pe,xe,Re){{var De=Function.call.bind(ve);for(var it in j)if(De(j,it)){var je=void 0;try{if(typeof j[it]!="function"){var gt=Error((xe||"React class")+": "+pe+" type `"+it+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof j[it]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw gt.name="Invariant Violation",gt}je=j[it](oe,it,xe,pe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(st){je=st}je&&!(je instanceof Error)&&(Te(Re),$("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",xe||"React class",pe,it,typeof je),Te(null)),je instanceof Error&&!(je.message in Me)&&(Me[je.message]=!0,Te(Re),$("Failed %s type: %s",pe,je.message),Te(null))}}}var Ie=Array.isArray;function Le(j){return Ie(j)}function Ve(j){{var oe=typeof Symbol=="function"&&Symbol.toStringTag,pe=oe&&j[Symbol.toStringTag]||j.constructor.name||"Object";return pe}}function ke(j){try{return ze(j),!1}catch{return!0}}function ze(j){return""+j}function He(j){if(ke(j))return $("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ve(j)),ze(j)}var Ee=k.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},ct,$e,et;et={};function rt(j){if(ve.call(j,"ref")){var oe=Object.getOwnPropertyDescriptor(j,"ref").get;if(oe&&oe.isReactWarning)return!1}return j.ref!==void 0}function Je(j){if(ve.call(j,"key")){var oe=Object.getOwnPropertyDescriptor(j,"key").get;if(oe&&oe.isReactWarning)return!1}return j.key!==void 0}function pt(j,oe){if(typeof j.ref=="string"&&Ee.current&&oe&&Ee.current.stateNode!==oe){var pe=m(Ee.current.type);et[pe]||($('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',m(Ee.current.type),j.ref),et[pe]=!0)}}function ht(j,oe){{var pe=function(){ct||(ct=!0,$("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",oe))};pe.isReactWarning=!0,Object.defineProperty(j,"key",{get:pe,configurable:!0})}}function ft(j,oe){{var pe=function(){$e||($e=!0,$("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",oe))};pe.isReactWarning=!0,Object.defineProperty(j,"ref",{get:pe,configurable:!0})}}var Ht=function(j,oe,pe,xe,Re,De,it){var je={$$typeof:e,type:j,key:oe,ref:pe,props:it,_owner:De};return je._store={},Object.defineProperty(je._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(je,"_self",{configurable:!1,enumerable:!1,writable:!1,value:xe}),Object.defineProperty(je,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Re}),Object.freeze&&(Object.freeze(je.props),Object.freeze(je)),je};function Jt(j,oe,pe,xe,Re){{var De,it={},je=null,gt=null;pe!==void 0&&(He(pe),je=""+pe),Je(oe)&&(He(oe.key),je=""+oe.key),rt(oe)&&(gt=oe.ref,pt(oe,Re));for(De in oe)ve.call(oe,De)&&!Qe.hasOwnProperty(De)&&(it[De]=oe[De]);if(j&&j.defaultProps){var st=j.defaultProps;for(De in st)it[De]===void 0&&(it[De]=st[De])}if(je||gt){var tt=typeof j=="function"?j.displayName||j.name||"Unknown":j;je&&ht(it,tt),gt&&ft(it,tt)}return Ht(j,je,gt,Re,xe,Ee.current,it)}}var St=k.ReactCurrentOwner,er=k.ReactDebugCurrentFrame;function Xt(j){if(j){var oe=j._owner,pe=fe(j.type,j._source,oe?oe.type:null);er.setExtraStackFrame(pe)}else er.setExtraStackFrame(null)}var Ot;Ot=!1;function $t(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function Tt(){{if(St.current){var j=m(St.current.type);if(j)return` + */var sy;function RA(){return sy||(sy=1,process.env.NODE_ENV!=="production"&&(function(){var t=Se,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),S=Symbol.iterator,C="@@iterator";function D(j){if(j===null||typeof j!="object")return null;var oe=S&&j[S]||j[C];return typeof oe=="function"?oe:null}var B=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function L(j){{for(var oe=arguments.length,le=new Array(oe>1?oe-1:0),me=1;me=1&&ot>=0&&et[rt]!==Ze[ot];)ot--;for(;rt>=1&&ot>=0;rt--,ot--)if(et[rt]!==Ze[ot]){if(rt!==1||ot!==1)do if(rt--,ot--,ot<0||et[rt]!==Ze[ot]){var yt=` +`+et[rt].replace(" at new "," at ");return j.displayName&&yt.includes("")&&(yt=yt.replace("",j.displayName)),typeof j=="function"&&N.set(j,yt),yt}while(rt>=1&&ot>=0);break}}}finally{te=!1,ie.current=ke,O(),Error.prepareStackTrace=Ee}var Rt=j?j.displayName||j.name:"",Mt=Rt?Z(Rt):"";return typeof j=="function"&&N.set(j,Mt),Mt}function de(j,oe,le){return ne(j,!1)}function ce(j){var oe=j.prototype;return!!(oe&&oe.isReactComponent)}function fe(j,oe,le){if(j==null)return"";if(typeof j=="function")return ne(j,ce(j));if(typeof j=="string")return Z(j);switch(j){case u:return Z("Suspense");case h:return Z("SuspenseList")}if(typeof j=="object")switch(j.$$typeof){case f:return de(j.render);case g:return fe(j.type,oe,le);case b:{var me=j,Ee=me._payload,ke=me._init;try{return fe(ke(Ee),oe,le)}catch{}}}return""}var be=Object.prototype.hasOwnProperty,Pe={},De=B.ReactDebugCurrentFrame;function Te(j){if(j){var oe=j._owner,le=fe(j.type,j._source,oe?oe.type:null);De.setExtraStackFrame(le)}else De.setExtraStackFrame(null)}function Fe(j,oe,le,me,Ee){{var ke=Function.call.bind(be);for(var Ce in j)if(ke(j,Ce)){var et=void 0;try{if(typeof j[Ce]!="function"){var Ze=Error((me||"React class")+": "+le+" type `"+Ce+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof j[Ce]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ze.name="Invariant Violation",Ze}et=j[Ce](oe,Ce,me,le,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(rt){et=rt}et&&!(et instanceof Error)&&(Te(Ee),L("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",me||"React class",le,Ce,typeof et),Te(null)),et instanceof Error&&!(et.message in Pe)&&(Pe[et.message]=!0,Te(Ee),L("Failed %s type: %s",le,et.message),Te(null))}}}var Me=Array.isArray;function Ne(j){return Me(j)}function He(j){{var oe=typeof Symbol=="function"&&Symbol.toStringTag,le=oe&&j[Symbol.toStringTag]||j.constructor.name||"Object";return le}}function Oe(j){try{return $e(j),!1}catch{return!0}}function $e(j){return""+j}function qe(j){if(Oe(j))return L("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",He(j)),$e(j)}var _e=B.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},at,Be;function nt(j){if(be.call(j,"ref")){var oe=Object.getOwnPropertyDescriptor(j,"ref").get;if(oe&&oe.isReactWarning)return!1}return j.ref!==void 0}function it(j){if(be.call(j,"key")){var oe=Object.getOwnPropertyDescriptor(j,"key").get;if(oe&&oe.isReactWarning)return!1}return j.key!==void 0}function Ye(j,oe){typeof j.ref=="string"&&_e.current}function pt(j,oe){{var le=function(){at||(at=!0,L("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",oe))};le.isReactWarning=!0,Object.defineProperty(j,"key",{get:le,configurable:!0})}}function ht(j,oe){{var le=function(){Be||(Be=!0,L("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",oe))};le.isReactWarning=!0,Object.defineProperty(j,"ref",{get:le,configurable:!0})}}var ft=function(j,oe,le,me,Ee,ke,Ce){var et={$$typeof:e,type:j,key:oe,ref:le,props:Ce,_owner:ke};return et._store={},Object.defineProperty(et._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(et,"_self",{configurable:!1,enumerable:!1,writable:!1,value:me}),Object.defineProperty(et,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ee}),Object.freeze&&(Object.freeze(et.props),Object.freeze(et)),et};function Ht(j,oe,le,me,Ee){{var ke,Ce={},et=null,Ze=null;le!==void 0&&(qe(le),et=""+le),it(oe)&&(qe(oe.key),et=""+oe.key),nt(oe)&&(Ze=oe.ref,Ye(oe,Ee));for(ke in oe)be.call(oe,ke)&&!Qe.hasOwnProperty(ke)&&(Ce[ke]=oe[ke]);if(j&&j.defaultProps){var rt=j.defaultProps;for(ke in rt)Ce[ke]===void 0&&(Ce[ke]=rt[ke])}if(et||Ze){var ot=typeof j=="function"?j.displayName||j.name||"Unknown":j;et&&pt(Ce,ot),Ze&&ht(Ce,ot)}return ft(j,et,Ze,Ee,me,_e.current,Ce)}}var Jt=B.ReactCurrentOwner,St=B.ReactDebugCurrentFrame;function Xt(j){if(j){var oe=j._owner,le=fe(j.type,j._source,oe?oe.type:null);St.setExtraStackFrame(le)}else St.setExtraStackFrame(null)}var tr;tr=!1;function Dt(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function Bt(){{if(Jt.current){var j=v(Jt.current.type);if(j)return` -Check the render method of \``+j+"`."}return""}}function vt(j){return""}var Dt={};function Lt(j){{var oe=Tt();if(!oe){var pe=typeof j=="string"?j:j.displayName||j.name;pe&&(oe=` +Check the render method of \``+j+"`."}return""}}function Ct(j){return""}var gt={};function Ot(j){{var oe=Bt();if(!oe){var le=typeof j=="string"?j:j.displayName||j.name;le&&(oe=` -Check the top-level render call using <`+pe+">.")}return oe}}function bt(j,oe){{if(!j._store||j._store.validated||j.key!=null)return;j._store.validated=!0;var pe=Lt(oe);if(Dt[pe])return;Dt[pe]=!0;var xe="";j&&j._owner&&j._owner!==St.current&&(xe=" It was passed a child from "+m(j._owner.type)+"."),Xt(j),$('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',pe,xe),Xt(null)}}function Bt(j,oe){{if(typeof j!="object")return;if(Le(j))for(var pe=0;pe",je=" Did you accidentally export a JSX literal instead of a component?"):st=typeof j,$("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",st,je)}var tt=Jt(j,oe,pe,Re,De);if(tt==null)return tt;if(it){var At=oe.children;if(At!==void 0)if(xe)if(Le(At)){for(var Rt=0;Rt0?"{key: someKey, "+Et.join(": ..., ")+": ...}":"{key: someKey}";if(!Ft[Mt+dt]){var _t=Et.length>0?"{"+Et.join(": ..., ")+": ...}":"{}";$(`A props object containing a "key" prop is being spread into JSX: +Check the top-level render call using <`+le+">.")}return oe}}function Lt(j,oe){{if(!j._store||j._store.validated||j.key!=null)return;j._store.validated=!0;var le=Ot(oe);if(gt[le])return;gt[le]=!0;var me="";j&&j._owner&&j._owner!==Jt.current&&(me=" It was passed a child from "+v(j._owner.type)+"."),Xt(j),L('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',le,me),Xt(null)}}function bt(j,oe){{if(typeof j!="object")return;if(Ne(j))for(var le=0;le",et=" Did you accidentally export a JSX literal instead of a component?"):rt=typeof j,L("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",rt,et)}var ot=Ht(j,oe,le,Ee,ke);if(ot==null)return ot;if(Ce){var yt=oe.children;if(yt!==void 0)if(me)if(Ne(yt)){for(var Rt=0;Rt0?"{key: someKey, "+xt.join(": ..., ")+": ...}":"{key: someKey}";if(!tt[Mt+Tt]){var mt=xt.length>0?"{"+xt.join(": ..., ")+": ...}":"{}";L(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; - <%s key={someKey} {...props} />`,dt,Mt,_t,Mt),Ft[Mt+dt]=!0}}return j===n?nt(tt):Ut(tt),tt}}function H(j,oe,pe){return B(j,oe,pe,!0)}function V(j,oe,pe){return B(j,oe,pe,!1)}var C=V,Y=H;gf.Fragment=n,gf.jsx=C,gf.jsxs=Y}()),gf}process.env.NODE_ENV==="production"?Xp.exports=UA():Xp.exports=jA();var me=Xp.exports;const Ts="https://static.codatta.io/codatta-connect/wallet-icons.svg?v=2",qA=[{featured:!0,name:"MetaMask",rdns:"io.metamask",image:`${Ts}#metamask`,getWallet:{chrome_store_id:"nkbihfbeogaeaoehlefnkodbefgpgknn",brave_store_id:"nkbihfbeogaeaoehlefnkodbefgpgknn",edge_addon_id:"ejbalbakoplchlghecdalmeeeajnimhm",firefox_addon_id:"ether-metamask",play_store_id:"io.metamask",app_store_id:"id1438144202"},deep_link:"metamask://wc",universal_link:"https://metamask.app.link/wc"},{featured:!0,name:"OKX Wallet",rdns:"com.okex.wallet",image:`${Ts}#okx`,getWallet:{chrome_store_id:"mcohilncbfahbmgdjkbpemcciiolgcge",brave_store_id:"mcohilncbfahbmgdjkbpemcciiolgcge",edge_addon_id:"pbpjkcldjiffchgbbndmhojiacbgflha",play_store_id:"com.okinc.okex.gp",app_store_id:"id1327268470"},deep_link:"okex://main/wc",universal_link:"okex://main/wc"},{featured:!0,name:"WalletConnect",image:`${Ts}#walletconnect`},{featured:!1,name:"Coinbase Wallet",image:`${Ts}#coinbase`},{featured:!1,name:"GateWallet",rdns:"io.gate.wallet",image:`${Ts}#6e528abf-7a7d-47bd-d84d-481f169b1200`,getWallet:{chrome_store_id:"cpmkedoipcpimgecpmgpldfpohjplkpp",brave_store_id:"cpmkedoipcpimgecpmgpldfpohjplkpp",play_store_id:"com.gateio.gateio",app_store_id:"id1294998195",mac_app_store_id:"id1609559473"},deep_link:"https://www.gate.io/mobileapp",universal_link:"https://www.gate.io/mobileapp"},{featured:!1,name:"Onekey",rdns:"so.onekey.app.wallet",image:`${Ts}#onekey`,getWallet:{chrome_store_id:"jnmbobjmhlngoefaiojfljckilhhlhcj",brave_store_id:"jnmbobjmhlngoefaiojfljckilhhlhcj",play_store_id:"so.onekey.app.wallet",app_store_id:"id1609559473"},deep_link:"onekey-wallet://",universal_link:"onekey://wc"},{featured:!1,name:"Infinity Wallet",image:`${Ts}#9f259366-0bcd-4817-0af9-f78773e41900`,desktop_link:"infinity://wc"},{name:"Rabby Wallet",rdns:"io.rabby",featured:!1,image:`${Ts}#rabby`,getWallet:{chrome_store_id:"acmacodkjbdgmoleebolmdjonilkdbch",brave_store_id:"acmacodkjbdgmoleebolmdjonilkdbch",play_store_id:"com.debank.rabbymobile",app_store_id:"id6474381673"}},{name:"Binance Web3 Wallet",featured:!1,image:`${Ts}#ebac7b39-688c-41e3-7912-a4fefba74600`,getWallet:{play_store_id:"com.binance.dev",app_store_id:"id1436799971"}},{name:"Rainbow Wallet",rdns:"me.rainbow",featured:!1,image:`${Ts}#rainbow`,getWallet:{chrome_store_id:"opfgelmcmbiajamepnmloijbpoleiama",edge_addon_id:"cpojfbodiccabbabgimdeohkkpjfpbnf",firefox_addon_id:"rainbow-extension",app_store_id:"id1457119021",play_store_id:"me.rainbow"}}];function zA(t,e){const r=t.exec(e);return r==null?void 0:r.groups}const Ky=/^tuple(?(\[(\d*)\])*)$/;function Zp(t){let e=t.type;if(Ky.test(t.type)&&"components"in t){e="(";const r=t.components.length;for(let i=0;ie(t,s)}function kc(t,{includeName:e=!1}={}){if(t.type!=="function"&&t.type!=="event"&&t.type!=="error")throw new rP(t.type);return`${t.name}(${Qp(t.inputs,{includeName:e})})`}function Qp(t,{includeName:e=!1}={}){return t?t.map(r=>WA(r,{includeName:e})).join(e?", ":","):""}function WA(t,{includeName:e}){return t.type.startsWith("tuple")?`(${Qp(t.components,{includeName:e})})${t.type.slice(5)}`:t.type+(e&&t.name?` ${t.name}`:"")}function Yo(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function _n(t){return Yo(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Vy="2.21.45";let vf={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${Vy}`};class yt extends Error{constructor(e,r={}){var a;const n=(()=>{var u;return r.cause instanceof yt?r.cause.details:(u=r.cause)!=null&&u.message?r.cause.message:r.details})(),i=r.cause instanceof yt&&r.cause.docsPath||r.docsPath,s=(a=vf.getDocsUrl)==null?void 0:a.call(vf,{...r,docsPath:i}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...vf.version?[`Version: ${vf.version}`]:[]].join(` -`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=Vy}walk(e){return Gy(this,e)}}function Gy(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Gy(t.cause,e):e?null:t}class KA extends yt{constructor({docsPath:e}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join(` -`),{docsPath:e,name:"AbiConstructorNotFoundError"})}}class Yy extends yt{constructor({docsPath:e}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join(` -`),{docsPath:e,name:"AbiConstructorParamsNotFoundError"})}}class VA extends yt{constructor({data:e,params:r,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join(` -`),{metaMessages:[`Params: (${Qp(r,{includeName:!0})})`,`Data: ${e} (${n} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=r,this.size=n}}class eg extends yt{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class GA extends yt{constructor({expectedLength:e,givenLength:r,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${e}`,`Given length: ${r}`].join(` -`),{name:"AbiEncodingArrayLengthMismatchError"})}}class YA extends yt{constructor({expectedSize:e,value:r}){super(`Size of bytes "${r}" (bytes${_n(r)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class JA extends yt{constructor({expectedLength:e,givenLength:r}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${r}`].join(` -`),{name:"AbiEncodingLengthMismatchError"})}}class Jy extends yt{constructor(e,{docsPath:r}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join(` -`),{docsPath:r,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class Xy extends yt{constructor(e,{docsPath:r}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(` -`),{docsPath:r,name:"AbiFunctionNotFoundError"})}}class XA extends yt{constructor(e,r){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${kc(e.abiItem)}\`, and`,`\`${r.type}\` in \`${kc(r.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class ZA extends yt{constructor({expectedSize:e,givenSize:r}){super(`Expected bytes${e}, got bytes${r}.`,{name:"BytesSizeMismatchError"})}}class QA extends yt{constructor(e,{docsPath:r}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(` -`),{docsPath:r,name:"InvalidAbiEncodingType"})}}class eP extends yt{constructor(e,{docsPath:r}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(` -`),{docsPath:r,name:"InvalidAbiDecodingType"})}}class tP extends yt{constructor(e){super([`Value "${e}" is not a valid array.`].join(` -`),{name:"InvalidArrayError"})}}class rP extends yt{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(` -`),{name:"InvalidDefinitionTypeError"})}}class Zy extends yt{constructor({offset:e,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class Qy extends yt{constructor({size:e,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}class ew extends yt{constructor({size:e,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${r} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function $c(t,{dir:e,size:r=32}={}){return typeof t=="string"?Jo(t,{dir:e,size:r}):nP(t,{dir:e,size:r})}function Jo(t,{dir:e,size:r=32}={}){if(r===null)return t;const n=t.replace("0x","");if(n.length>r*2)throw new Qy({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function nP(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new Qy({size:t.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let i=0;ie)throw new oP({givenSize:_n(t),maxSize:e})}function bf(t,e={}){const{signed:r}=e;e.size&&Rs(t,{size:e.size});const n=BigInt(t);if(!r)return n;const i=(t.length-2)/2,s=(1n<e.toString(16).padStart(2,"0"));function Rh(t,e={}){return typeof t=="number"||typeof t=="bigint"?Pr(t,e):typeof t=="string"?Dh(t,e):typeof t=="boolean"?tw(t,e):li(t,e)}function tw(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(Rs(r,{size:e.size}),$c(r,{size:e.size})):r}function li(t,e={}){let r="";for(let i=0;is||i=oo.zero&&t<=oo.nine)return t-oo.zero;if(t>=oo.A&&t<=oo.F)return t-(oo.A-10);if(t>=oo.a&&t<=oo.f)return t-(oo.a-10)}function ao(t,e={}){let r=t;e.size&&(Rs(r,{size:e.size}),r=$c(r,{dir:"right",size:e.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,s=new Uint8Array(i);for(let o=0,a=0;o0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function dP(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Oh(t.outputLen),Oh(t.blockLen)}function Uc(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function iw(t,e){Fc(t);const r=e.outputLen;if(t.length>sw&Nh)}:{h:Number(t>>sw&Nh)|0,l:Number(t&Nh)|0}}function gP(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;it<>>32-r,vP=(t,e,r)=>e<>>32-r,bP=(t,e,r)=>e<>>64-r,yP=(t,e,r)=>t<>>64-r,jc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const wP=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),ng=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ds=(t,e)=>t<<32-e|t>>>e,ow=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,xP=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;function aw(t){for(let e=0;ee.toString(16).padStart(2,"0"));function EP(t){Fc(t);let e="";for(let r=0;rt().update(yf(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function PP(t){const e=(n,i)=>t(i).update(yf(n)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}function MP(t=32){if(jc&&typeof jc.getRandomValues=="function")return jc.getRandomValues(new Uint8Array(t));if(jc&&typeof jc.randomBytes=="function")return jc.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}const uw=[],fw=[],lw=[],IP=BigInt(0),wf=BigInt(1),CP=BigInt(2),TP=BigInt(7),RP=BigInt(256),DP=BigInt(113);for(let t=0,e=wf,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],uw.push(2*(5*n+r)),fw.push((t+1)*(t+2)/2%64);let i=IP;for(let s=0;s<7;s++)e=(e<>TP)*DP)%RP,e&CP&&(i^=wf<<(wf<r>32?bP(t,e,r):mP(t,e,r),dw=(t,e,r)=>r>32?yP(t,e,r):vP(t,e,r);function pw(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,l=r[u],d=r[u+1],g=hw(l,d,1)^r[a],y=dw(l,d,1)^r[a+1];for(let A=0;A<50;A+=10)t[o+A]^=g,t[o+A+1]^=y}let i=t[2],s=t[3];for(let o=0;o<24;o++){const a=fw[o],u=hw(i,s,a),l=dw(i,s,a),d=uw[o];i=t[d],s=t[d+1],t[d]=u,t[d+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=OP[n],t[1]^=NP[n]}r.fill(0)}class xf extends ig{constructor(e,r,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Oh(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=wP(this.state)}keccak(){ow||aw(this.state32),pw(this.state32,this.rounds),ow||aw(this.state32),this.posOut=0,this.pos=0}update(e){Uc(this);const{blockLen:r,state:n}=this;e=yf(e);const i=e.length;for(let s=0;s=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Oh(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(iw(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new xf(r,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Xo=(t,e,r)=>cw(()=>new xf(e,t,r)),LP=Xo(6,144,224/8),kP=Xo(6,136,256/8),$P=Xo(6,104,384/8),BP=Xo(6,72,512/8),FP=Xo(1,144,224/8),gw=Xo(1,136,256/8),UP=Xo(1,104,384/8),jP=Xo(1,72,512/8),mw=(t,e,r)=>PP((n={})=>new xf(e,t,n.dkLen===void 0?r:n.dkLen,!0)),qP=mw(31,168,128/8),zP=mw(31,136,256/8),HP=Object.freeze(Object.defineProperty({__proto__:null,Keccak:xf,keccakP:pw,keccak_224:FP,keccak_256:gw,keccak_384:UP,keccak_512:jP,sha3_224:LP,sha3_256:kP,sha3_384:$P,sha3_512:BP,shake128:qP,shake256:zP},Symbol.toStringTag,{value:"Module"}));function _f(t,e){const r=e||"hex",n=gw(Yo(t,{strict:!1})?rg(t):t);return r==="bytes"?n:Rh(n)}const WP=t=>_f(rg(t));function KP(t){return WP(t)}function VP(t){let e=!0,r="",n=0,i="",s=!1;for(let o=0;o{const e=typeof t=="string"?t:HA(t);return VP(e)};function vw(t){return KP(GP(t))}const YP=vw;class qc extends yt{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Lh extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const sg=new Lh(8192);function Ef(t,e){if(sg.has(`${t}.${e}`))return sg.get(`${t}.${e}`);const r=t.substring(2).toLowerCase(),n=_f(nw(r),"bytes"),i=r.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(n[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const s=`0x${i.join("")}`;return sg.set(`${t}.${e}`,s),s}function bw(t,e){if(!co(t,{strict:!1}))throw new qc({address:t});return Ef(t,e)}const JP=/^0x[a-fA-F0-9]{40}$/,og=new Lh(8192);function co(t,e){const{strict:r=!0}=e??{},n=`${t}.${r}`;if(og.has(n))return og.get(n);const i=JP.test(t)?t.toLowerCase()===t?!0:r?Ef(t)===t:!0:!1;return og.set(n,i),i}function zc(t){return typeof t[0]=="string"?kh(t):XP(t)}function XP(t){let e=0;for(const i of t)e+=i.length;const r=new Uint8Array(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function kh(t){return`0x${t.reduce((e,r)=>e+r.replace("0x",""),"")}`}function $h(t,e,r,{strict:n}={}){return Yo(t,{strict:!1})?ZP(t,e,r,{strict:n}):xw(t,e,r,{strict:n})}function yw(t,e){if(typeof e=="number"&&e>0&&e>_n(t)-1)throw new Zy({offset:e,position:"start",size:_n(t)})}function ww(t,e,r){if(typeof e=="number"&&typeof r=="number"&&_n(t)!==r-e)throw new Zy({offset:r,position:"end",size:_n(t)})}function xw(t,e,r,{strict:n}={}){yw(t,e);const i=t.slice(e,r);return n&&ww(i,e,r),i}function ZP(t,e,r,{strict:n}={}){yw(t,e);const i=`0x${t.replace("0x","").slice((e??0)*2,(r??t.length)*2)}`;return n&&ww(i,e,r),i}function _w(t,e){if(t.length!==e.length)throw new JA({expectedLength:t.length,givenLength:e.length});const r=QP({params:t,values:e}),n=cg(r);return n.length===0?"0x":n}function QP({params:t,values:e}){const r=[];for(let n=0;n0?zc([a,o]):a}}if(i)return{dynamic:!0,encoded:o}}return{dynamic:!1,encoded:zc(s.map(({encoded:o})=>o))}}function rM(t,{param:e}){const[,r]=e.type.split("bytes"),n=_n(t);if(!r){let i=t;return n%32!==0&&(i=Jo(i,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:zc([Jo(Pr(n,{size:32})),i])}}if(n!==Number.parseInt(r))throw new YA({expectedSize:Number.parseInt(r),value:t});return{dynamic:!1,encoded:Jo(t,{dir:"right"})}}function nM(t){if(typeof t!="boolean")throw new yt(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Jo(tw(t))}}function iM(t,{signed:e}){return{dynamic:!1,encoded:Pr(t,{size:32,signed:e})}}function sM(t){const e=Dh(t),r=Math.ceil(_n(e)/32),n=[];for(let i=0;ii))}}function ug(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}const fg=t=>$h(vw(t),0,4);function Ew(t){const{abi:e,args:r=[],name:n}=t,i=Yo(n,{strict:!1}),s=e.filter(a=>i?a.type==="function"?fg(a)===n:a.type==="event"?YP(a)===n:!1:"name"in a&&a.name===n);if(s.length===0)return;if(s.length===1)return s[0];let o;for(const a of s){if(!("inputs"in a))continue;if(!r||r.length===0){if(!a.inputs||a.inputs.length===0)return a;continue}if(!a.inputs||a.inputs.length===0||a.inputs.length!==r.length)continue;if(r.every((l,d)=>{const g="inputs"in a&&a.inputs[d];return g?lg(l,g):!1})){if(o&&"inputs"in o&&o.inputs){const l=Sw(a.inputs,o.inputs,r);if(l)throw new XA({abiItem:a,type:l[0]},{abiItem:o,type:l[1]})}o=a}}return o||s[0]}function lg(t,e){const r=typeof t,n=e.type;switch(n){case"address":return co(t,{strict:!1});case"bool":return r==="boolean";case"function":return r==="string";case"string":return r==="string";default:return n==="tuple"&&"components"in e?Object.values(e.components).every((i,s)=>lg(Object.values(t)[s],i)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(n)?r==="number"||r==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(n)?r==="string"||t instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(n)?Array.isArray(t)&&t.every(i=>lg(i,{...e,type:n.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Sw(t,e,r){for(const n in t){const i=t[n],s=e[n];if(i.type==="tuple"&&s.type==="tuple"&&"components"in i&&"components"in s)return Sw(i.components,s.components,r[n]);const o=[i.type,s.type];if(o.includes("address")&&o.includes("bytes20")?!0:o.includes("address")&&o.includes("string")?co(r[n],{strict:!1}):o.includes("address")&&o.includes("bytes")?co(r[n],{strict:!1}):!1)return o}}function uo(t){return typeof t=="string"?{address:t,type:"json-rpc"}:t}const Aw="/docs/contract/encodeFunctionData";function aM(t){const{abi:e,args:r,functionName:n}=t;let i=e[0];if(n){const s=Ew({abi:e,args:r,name:n});if(!s)throw new Xy(n,{docsPath:Aw});i=s}if(i.type!=="function")throw new Xy(void 0,{docsPath:Aw});return{abi:[i],functionName:fg(kc(i))}}function cM(t){const{args:e}=t,{abi:r,functionName:n}=(()=>{var a;return t.abi.length===1&&((a=t.functionName)!=null&&a.startsWith("0x"))?t:aM(t)})(),i=r[0],s=n,o="inputs"in i&&i.inputs?_w(i.inputs,e??[]):void 0;return kh([s,o??"0x"])}const uM={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},fM={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},lM={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};class Pw extends yt{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class hM extends yt{constructor({length:e,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class dM extends yt{constructor({count:e,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const pM={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new dM({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new hM({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new Pw({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new Pw({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const r=e??this.position;return this.assertPosition(r+t-1),this.bytes.subarray(r,r+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const r=this.inspectBytes(t);return this.position+=e??t,r},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function hg(t,{recursiveReadLimit:e=8192}={}){const r=Object.create(pM);return r.bytes=t,r.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=e,r}function gM(t,e={}){typeof e.size<"u"&&Rs(t,{size:e.size});const r=li(t,e);return bf(r,e)}function mM(t,e={}){let r=t;if(typeof e.size<"u"&&(Rs(r,{size:e.size}),r=tg(r)),r.length>1||r[0]>1)throw new sP(r);return!!r[0]}function fo(t,e={}){typeof e.size<"u"&&Rs(t,{size:e.size});const r=li(t,e);return Bc(r,e)}function vM(t,e={}){let r=t;return typeof e.size<"u"&&(Rs(r,{size:e.size}),r=tg(r,{dir:"right"})),new TextDecoder().decode(r)}function bM(t,e){const r=typeof e=="string"?ao(e):e,n=hg(r);if(_n(r)===0&&t.length>0)throw new eg;if(_n(e)&&_n(e)<32)throw new VA({data:typeof e=="string"?e:li(e),params:t,size:_n(e)});let i=0;const s=[];for(let o=0;o48?gM(i,{signed:r}):fo(i,{signed:r}),32]}function SM(t,e,{staticPosition:r}){const n=e.components.length===0||e.components.some(({name:o})=>!o),i=n?[]:{};let s=0;if(Sf(e)){const o=fo(t.readBytes(dg)),a=r+o;for(let u=0;uo.type==="error"&&n===fg(kc(o)));if(!s)throw new Jy(n,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:s,args:"inputs"in s&&s.inputs&&s.inputs.length>0?bM(s.inputs,$h(r,4)):void 0,errorName:s.name}}const Wc=(t,e,r)=>JSON.stringify(t,(n,i)=>typeof i=="bigint"?i.toString():i,r);function Iw({abiItem:t,args:e,includeFunctionName:r=!0,includeName:n=!1}){if("name"in t&&"inputs"in t&&t.inputs)return`${r?t.name:""}(${t.inputs.map((i,s)=>`${n&&i.name?`${i.name}: `:""}${typeof e[s]=="object"?Wc(e[s]):e[s]}`).join(", ")})`}const MM={gwei:9,wei:18},IM={ether:-9,wei:9};function Cw(t,e){let r=t.toString();const n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(e,"0");let[i,s]=[r.slice(0,r.length-e),r.slice(r.length-e)];return s=s.replace(/(0+)$/,""),`${n?"-":""}${i||"0"}${s?`.${s}`:""}`}function Tw(t,e="wei"){return Cw(t,MM[e])}function ls(t,e="wei"){return Cw(t,IM[e])}class CM extends yt{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class TM extends yt{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Bh(t){const e=Object.entries(t).map(([n,i])=>i===void 0||i===!1?null:[n,i]).filter(Boolean),r=e.reduce((n,[i])=>Math.max(n,i.length),0);return e.map(([n,i])=>` ${`${n}:`.padEnd(r+1)} ${i}`).join(` -`)}class RM extends yt{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join(` -`),{name:"FeeConflictError"})}}class DM extends yt{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Bh(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class OM extends yt{constructor(e,{account:r,docsPath:n,chain:i,data:s,gas:o,gasPrice:a,maxFeePerGas:u,maxPriorityFeePerGas:l,nonce:d,to:g,value:y}){var P;const A=Bh({chain:i&&`${i==null?void 0:i.name} (id: ${i==null?void 0:i.id})`,from:r==null?void 0:r.address,to:g,value:typeof y<"u"&&`${Tw(y)} ${((P=i==null?void 0:i.nativeCurrency)==null?void 0:P.symbol)||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${ls(a)} gwei`,maxFeePerGas:typeof u<"u"&&`${ls(u)} gwei`,maxPriorityFeePerGas:typeof l<"u"&&`${ls(l)} gwei`,nonce:d});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",A].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}const NM=t=>t,Rw=t=>t;class LM extends yt{constructor(e,{abi:r,args:n,contractAddress:i,docsPath:s,functionName:o,sender:a}){const u=Ew({abi:r,args:n,name:o}),l=u?Iw({abiItem:u,args:n,includeFunctionName:!1,includeName:!1}):void 0,d=u?kc(u,{includeName:!0}):void 0,g=Bh({address:i&&NM(i),function:d,args:l&&l!=="()"&&`${[...Array((o==null?void 0:o.length)??0).keys()].map(()=>" ").join("")}${l}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${o}".`,{cause:e,docsPath:s,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],g&&"Contract Call:",g].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=r,this.args=n,this.cause=e,this.contractAddress=i,this.functionName=o,this.sender=a}}class kM extends yt{constructor({abi:e,data:r,functionName:n,message:i}){let s,o,a,u;if(r&&r!=="0x")try{o=PM({abi:e,data:r});const{abiItem:d,errorName:g,args:y}=o;if(g==="Error")u=y[0];else if(g==="Panic"){const[A]=y;u=uM[A]}else{const A=d?kc(d,{includeName:!0}):void 0,P=d&&y?Iw({abiItem:d,args:y,includeFunctionName:!1,includeName:!1}):void 0;a=[A?`Error: ${A}`:"",P&&P!=="()"?` ${[...Array((g==null?void 0:g.length)??0).keys()].map(()=>" ").join("")}${P}`:""]}}catch(d){s=d}else i&&(u=i);let l;s instanceof Jy&&(l=s.signature,a=[`Unable to decode signature "${l}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${l}.`]),super(u&&u!=="execution reverted"||l?[`The contract function "${n}" reverted with the following ${l?"signature":"reason"}:`,u||l].join(` -`):`The contract function "${n}" reverted.`,{cause:s,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o,this.reason=u,this.signature=l}}class $M extends yt{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class BM extends yt{constructor({data:e,message:r}){super(r||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e}}class Dw extends yt{constructor({body:e,cause:r,details:n,headers:i,status:s,url:o}){super("HTTP request failed.",{cause:r,details:n,metaMessages:[s&&`Status: ${s}`,`URL: ${Rw(o)}`,e&&`Request body: ${Wc(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=i,this.status=s,this.url=o}}class FM extends yt{constructor({body:e,error:r,url:n}){super("RPC Request failed.",{cause:r,details:r.message,metaMessages:[`URL: ${Rw(n)}`,`Request body: ${Wc(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=r.code}}const UM=-1;class hi extends yt{constructor(e,{code:r,docsPath:n,metaMessages:i,name:s,shortMessage:o}){super(o,{cause:e,docsPath:n,metaMessages:i||(e==null?void 0:e.metaMessages),name:s||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=s||e.name,this.code=e instanceof FM?e.code:r??UM}}class Kc extends hi{constructor(e,r){super(e,r),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=r.data}}class Af extends hi{constructor(e){super(e,{code:Af.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(Af,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class Pf extends hi{constructor(e){super(e,{code:Pf.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(Pf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Mf extends hi{constructor(e,{method:r}={}){super(e,{code:Mf.code,name:"MethodNotFoundRpcError",shortMessage:`The method${r?` "${r}"`:""} does not exist / is not available.`})}}Object.defineProperty(Mf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class If extends hi{constructor(e){super(e,{code:If.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(` -`)})}}Object.defineProperty(If,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class ka extends hi{constructor(e){super(e,{code:ka.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(ka,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Cf extends hi{constructor(e){super(e,{code:Cf.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(` -`)})}}Object.defineProperty(Cf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class Tf extends hi{constructor(e){super(e,{code:Tf.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(Tf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class Rf extends hi{constructor(e){super(e,{code:Rf.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(Rf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class Df extends hi{constructor(e){super(e,{code:Df.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(Df,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Of extends hi{constructor(e,{method:r}={}){super(e,{code:Of.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${r?` "${r}"`:""} is not implemented.`})}}Object.defineProperty(Of,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class Vc extends hi{constructor(e){super(e,{code:Vc.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(Vc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Nf extends hi{constructor(e){super(e,{code:Nf.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(Nf,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Gc extends Kc{constructor(e){super(e,{code:Gc.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(Gc,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Lf extends Kc{constructor(e){super(e,{code:Lf.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(Lf,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class kf extends Kc{constructor(e,{method:r}={}){super(e,{code:kf.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${r?` " ${r}"`:""}.`})}}Object.defineProperty(kf,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class $f extends Kc{constructor(e){super(e,{code:$f.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty($f,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Bf extends Kc{constructor(e){super(e,{code:Bf.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(Bf,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Ff extends Kc{constructor(e){super(e,{code:Ff.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Ff,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class jM extends hi{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const qM=3;function zM(t,{abi:e,address:r,args:n,docsPath:i,functionName:s,sender:o}){const{code:a,data:u,message:l,shortMessage:d}=t instanceof BM?t:t instanceof yt?t.walk(y=>"data"in y)||t.walk():{},g=t instanceof eg?new $M({functionName:s}):[qM,ka.code].includes(a)&&(u||l||d)?new kM({abi:e,data:typeof u=="object"?u.data:u,functionName:s,message:d??l}):t;return new LM(g,{abi:e,args:n,contractAddress:r,docsPath:i,functionName:s,sender:o})}function HM(t){const e=_f(`0x${t.substring(4)}`).substring(26);return Ef(`0x${e}`)}async function WM({hash:t,signature:e}){const r=Yo(t)?t:Rh(t),{secp256k1:n}=await Promise.resolve().then(()=>TC);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:l,s:d,v:g,yParity:y}=e,A=Number(y??g),P=Ow(A);return new n.Signature(bf(l),bf(d)).addRecoveryBit(P)}const o=Yo(e)?e:Rh(e),a=Bc(`0x${o.slice(130)}`),u=Ow(a);return n.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(u)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function Ow(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function KM({hash:t,signature:e}){return HM(await WM({hash:t,signature:e}))}function VM(t,e="hex"){const r=Nw(t),n=hg(new Uint8Array(r.length));return r.encode(n),e==="hex"?li(n.bytes):n.bytes}function Nw(t){return Array.isArray(t)?GM(t.map(e=>Nw(e))):YM(t)}function GM(t){const e=t.reduce((i,s)=>i+s.length,0),r=Lw(e);return{length:e<=55?1+e:1+r+e,encode(i){e<=55?i.pushByte(192+e):(i.pushByte(247+r),r===1?i.pushUint8(e):r===2?i.pushUint16(e):r===3?i.pushUint24(e):i.pushUint32(e));for(const{encode:s}of t)s(i)}}}function YM(t){const e=typeof t=="string"?ao(t):t,r=Lw(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+r+e.length,encode(i){e.length===1&&e[0]<128?i.pushBytes(e):e.length<=55?(i.pushByte(128+e.length),i.pushBytes(e)):(i.pushByte(183+r),r===1?i.pushUint8(e.length):r===2?i.pushUint16(e.length):r===3?i.pushUint24(e.length):i.pushUint32(e.length),i.pushBytes(e))}}}function Lw(t){if(t<2**8)return 1;if(t<2**16)return 2;if(t<2**24)return 3;if(t<2**32)return 4;throw new yt("Length is too large.")}function JM(t){const{chainId:e,contractAddress:r,nonce:n,to:i}=t,s=_f(kh(["0x05",VM([e?Pr(e):"0x",r,n?Pr(n):"0x"])]));return i==="bytes"?ao(s):s}async function kw(t){const{authorization:e,signature:r}=t;return KM({hash:JM(e),signature:r??e})}class XM extends yt{constructor(e,{account:r,docsPath:n,chain:i,data:s,gas:o,gasPrice:a,maxFeePerGas:u,maxPriorityFeePerGas:l,nonce:d,to:g,value:y}){var P;const A=Bh({from:r==null?void 0:r.address,to:g,value:typeof y<"u"&&`${Tw(y)} ${((P=i==null?void 0:i.nativeCurrency)==null?void 0:P.symbol)||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${ls(a)} gwei`,maxFeePerGas:typeof u<"u"&&`${ls(u)} gwei`,maxPriorityFeePerGas:typeof l<"u"&&`${ls(l)} gwei`,nonce:d});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",A].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class Yc extends yt{constructor({cause:e,message:r}={}){var i;const n=(i=r==null?void 0:r.replace("execution reverted: ",""))==null?void 0:i.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Yc,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Yc,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Fh extends yt{constructor({cause:e,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${ls(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Fh,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class pg extends yt{constructor({cause:e,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${ls(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(pg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class gg extends yt{constructor({cause:e,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(gg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class mg extends yt{constructor({cause:e,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(` -`),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(mg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class vg extends yt{constructor({cause:e,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(vg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class bg extends yt{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(` -`),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(bg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class yg extends yt{constructor({cause:e,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(yg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class wg extends yt{constructor({cause:e,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(wg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class xg extends yt{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(xg,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Uh extends yt{constructor({cause:e,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${ls(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${ls(n)} gwei`:""}).`].join(` -`),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Uh,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class _g extends yt{constructor({cause:e}){super(`An error occurred while executing: ${e==null?void 0:e.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function $w(t,e){const r=(t.details||"").toLowerCase(),n=t instanceof yt?t.walk(i=>(i==null?void 0:i.code)===Yc.code):t;return n instanceof yt?new Yc({cause:t,message:n.details}):Yc.nodeMessage.test(r)?new Yc({cause:t,message:t.details}):Fh.nodeMessage.test(r)?new Fh({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas}):pg.nodeMessage.test(r)?new pg({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas}):gg.nodeMessage.test(r)?new gg({cause:t,nonce:e==null?void 0:e.nonce}):mg.nodeMessage.test(r)?new mg({cause:t,nonce:e==null?void 0:e.nonce}):vg.nodeMessage.test(r)?new vg({cause:t,nonce:e==null?void 0:e.nonce}):bg.nodeMessage.test(r)?new bg({cause:t}):yg.nodeMessage.test(r)?new yg({cause:t,gas:e==null?void 0:e.gas}):wg.nodeMessage.test(r)?new wg({cause:t,gas:e==null?void 0:e.gas}):xg.nodeMessage.test(r)?new xg({cause:t}):Uh.nodeMessage.test(r)?new Uh({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas,maxPriorityFeePerGas:e==null?void 0:e.maxPriorityFeePerGas}):new _g({cause:t})}function ZM(t,{docsPath:e,...r}){const n=(()=>{const i=$w(t,r);return i instanceof _g?t:i})();return new XM(n,{docsPath:e,...r})}function Bw(t,{format:e}){if(!e)return{};const r={};function n(s){const o=Object.keys(s);for(const a of o)a in t&&(r[a]=t[a]),s[a]&&typeof s[a]=="object"&&!Array.isArray(s[a])&&n(s[a])}const i=e(t||{});return n(i),r}const QM={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Eg(t){const e={};return typeof t.authorizationList<"u"&&(e.authorizationList=eI(t.authorizationList)),typeof t.accessList<"u"&&(e.accessList=t.accessList),typeof t.blobVersionedHashes<"u"&&(e.blobVersionedHashes=t.blobVersionedHashes),typeof t.blobs<"u"&&(typeof t.blobs[0]!="string"?e.blobs=t.blobs.map(r=>li(r)):e.blobs=t.blobs),typeof t.data<"u"&&(e.data=t.data),typeof t.from<"u"&&(e.from=t.from),typeof t.gas<"u"&&(e.gas=Pr(t.gas)),typeof t.gasPrice<"u"&&(e.gasPrice=Pr(t.gasPrice)),typeof t.maxFeePerBlobGas<"u"&&(e.maxFeePerBlobGas=Pr(t.maxFeePerBlobGas)),typeof t.maxFeePerGas<"u"&&(e.maxFeePerGas=Pr(t.maxFeePerGas)),typeof t.maxPriorityFeePerGas<"u"&&(e.maxPriorityFeePerGas=Pr(t.maxPriorityFeePerGas)),typeof t.nonce<"u"&&(e.nonce=Pr(t.nonce)),typeof t.to<"u"&&(e.to=t.to),typeof t.type<"u"&&(e.type=QM[t.type]),typeof t.value<"u"&&(e.value=Pr(t.value)),e}function eI(t){return t.map(e=>({address:e.contractAddress,r:e.r,s:e.s,chainId:Pr(e.chainId),nonce:Pr(e.nonce),...typeof e.yParity<"u"?{yParity:Pr(e.yParity)}:{},...typeof e.v<"u"&&typeof e.yParity>"u"?{v:Pr(e.v)}:{}}))}function Fw(t){if(!(!t||t.length===0))return t.reduce((e,{slot:r,value:n})=>{if(r.length!==66)throw new ew({size:r.length,targetSize:66,type:"hex"});if(n.length!==66)throw new ew({size:n.length,targetSize:66,type:"hex"});return e[r]=n,e},{})}function tI(t){const{balance:e,nonce:r,state:n,stateDiff:i,code:s}=t,o={};if(s!==void 0&&(o.code=s),e!==void 0&&(o.balance=Pr(e)),r!==void 0&&(o.nonce=Pr(r)),n!==void 0&&(o.state=Fw(n)),i!==void 0){if(o.state)throw new TM;o.stateDiff=Fw(i)}return o}function rI(t){if(!t)return;const e={};for(const{address:r,...n}of t){if(!co(r,{strict:!1}))throw new qc({address:r});if(e[r])throw new CM({address:r});e[r]=tI(n)}return e}const nI=2n**256n-1n;function jh(t){const{account:e,gasPrice:r,maxFeePerGas:n,maxPriorityFeePerGas:i,to:s}=t,o=e?uo(e):void 0;if(o&&!co(o.address))throw new qc({address:o.address});if(s&&!co(s))throw new qc({address:s});if(typeof r<"u"&&(typeof n<"u"||typeof i<"u"))throw new RM;if(n&&n>nI)throw new Fh({maxFeePerGas:n});if(i&&n&&i>n)throw new Uh({maxFeePerGas:n,maxPriorityFeePerGas:i})}class iI extends yt{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Sg extends yt{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class sI extends yt{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${ls(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class oI extends yt{constructor({blockHash:e,blockNumber:r}){let n="Block";e&&(n=`Block at hash "${e}"`),r&&(n=`Block at number "${r}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}}const aI={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function cI(t){const e={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,chainId:t.chainId?Bc(t.chainId):void 0,gas:t.gas?BigInt(t.gas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,maxFeePerBlobGas:t.maxFeePerBlobGas?BigInt(t.maxFeePerBlobGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,nonce:t.nonce?Bc(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?aI[t.type]:void 0,typeHex:t.type?t.type:void 0,value:t.value?BigInt(t.value):void 0,v:t.v?BigInt(t.v):void 0};return t.authorizationList&&(e.authorizationList=uI(t.authorizationList)),e.yParity=(()=>{if(t.yParity)return Number(t.yParity);if(typeof e.v=="bigint"){if(e.v===0n||e.v===27n)return 0;if(e.v===1n||e.v===28n)return 1;if(e.v>=35n)return e.v%2n===0n?1:0}})(),e.type==="legacy"&&(delete e.accessList,delete e.maxFeePerBlobGas,delete e.maxFeePerGas,delete e.maxPriorityFeePerGas,delete e.yParity),e.type==="eip2930"&&(delete e.maxFeePerBlobGas,delete e.maxFeePerGas,delete e.maxPriorityFeePerGas),e.type==="eip1559"&&delete e.maxFeePerBlobGas,e}function uI(t){return t.map(e=>({contractAddress:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))}function fI(t){const e=(t.transactions??[]).map(r=>typeof r=="string"?r:cI(r));return{...t,baseFeePerGas:t.baseFeePerGas?BigInt(t.baseFeePerGas):null,blobGasUsed:t.blobGasUsed?BigInt(t.blobGasUsed):void 0,difficulty:t.difficulty?BigInt(t.difficulty):void 0,excessBlobGas:t.excessBlobGas?BigInt(t.excessBlobGas):void 0,gasLimit:t.gasLimit?BigInt(t.gasLimit):void 0,gasUsed:t.gasUsed?BigInt(t.gasUsed):void 0,hash:t.hash?t.hash:null,logsBloom:t.logsBloom?t.logsBloom:null,nonce:t.nonce?t.nonce:null,number:t.number?BigInt(t.number):null,size:t.size?BigInt(t.size):void 0,timestamp:t.timestamp?BigInt(t.timestamp):void 0,transactions:e,totalDifficulty:t.totalDifficulty?BigInt(t.totalDifficulty):null}}async function qh(t,{blockHash:e,blockNumber:r,blockTag:n,includeTransactions:i}={}){var d,g,y;const s=n??"latest",o=i??!1,a=r!==void 0?Pr(r):void 0;let u=null;if(e?u=await t.request({method:"eth_getBlockByHash",params:[e,o]},{dedupe:!0}):u=await t.request({method:"eth_getBlockByNumber",params:[a||s,o]},{dedupe:!!a}),!u)throw new oI({blockHash:e,blockNumber:r});return(((y=(g=(d=t.chain)==null?void 0:d.formatters)==null?void 0:g.block)==null?void 0:y.format)||fI)(u)}async function Uw(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function lI(t,e){var s,o;const{block:r,chain:n=t.chain,request:i}=e||{};try{const a=((s=n==null?void 0:n.fees)==null?void 0:s.maxPriorityFeePerGas)??((o=n==null?void 0:n.fees)==null?void 0:o.defaultPriorityFee);if(typeof a=="function"){const l=r||await fi(t,qh,"getBlock")({}),d=await a({block:l,client:t,request:i});if(d===null)throw new Error;return d}if(typeof a<"u")return a;const u=await t.request({method:"eth_maxPriorityFeePerGas"});return bf(u)}catch{const[a,u]=await Promise.all([r?Promise.resolve(r):fi(t,qh,"getBlock")({}),fi(t,Uw,"getGasPrice")({})]);if(typeof a.baseFeePerGas!="bigint")throw new Sg;const l=u-a.baseFeePerGas;return l<0n?0n:l}}async function jw(t,e){var y,A;const{block:r,chain:n=t.chain,request:i,type:s="eip1559"}=e||{},o=await(async()=>{var P,N;return typeof((P=n==null?void 0:n.fees)==null?void 0:P.baseFeeMultiplier)=="function"?n.fees.baseFeeMultiplier({block:r,client:t,request:i}):((N=n==null?void 0:n.fees)==null?void 0:N.baseFeeMultiplier)??1.2})();if(o<1)throw new iI;const u=10**(((y=o.toString().split(".")[1])==null?void 0:y.length)??0),l=P=>P*BigInt(Math.ceil(o*u))/BigInt(u),d=r||await fi(t,qh,"getBlock")({});if(typeof((A=n==null?void 0:n.fees)==null?void 0:A.estimateFeesPerGas)=="function"){const P=await n.fees.estimateFeesPerGas({block:r,client:t,multiply:l,request:i,type:s});if(P!==null)return P}if(s==="eip1559"){if(typeof d.baseFeePerGas!="bigint")throw new Sg;const P=typeof(i==null?void 0:i.maxPriorityFeePerGas)=="bigint"?i.maxPriorityFeePerGas:await lI(t,{block:d,chain:n,request:i}),N=l(d.baseFeePerGas);return{maxFeePerGas:(i==null?void 0:i.maxFeePerGas)??N+P,maxPriorityFeePerGas:P}}return{gasPrice:(i==null?void 0:i.gasPrice)??l(await fi(t,Uw,"getGasPrice")({}))}}async function hI(t,{address:e,blockTag:r="latest",blockNumber:n}){const i=await t.request({method:"eth_getTransactionCount",params:[e,n?Pr(n):r]},{dedupe:!!n});return Bc(i)}function qw(t){const{kzg:e}=t,r=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),n=typeof t.blobs[0]=="string"?t.blobs.map(s=>ao(s)):t.blobs,i=[];for(const s of n)i.push(Uint8Array.from(e.blobToKzgCommitment(s)));return r==="bytes"?i:i.map(s=>li(s))}function zw(t){const{kzg:e}=t,r=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),n=typeof t.blobs[0]=="string"?t.blobs.map(o=>ao(o)):t.blobs,i=typeof t.commitments[0]=="string"?t.commitments.map(o=>ao(o)):t.commitments,s=[];for(let o=0;oli(o))}function dI(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),u=n?4:0,l=n?0:4;t.setUint32(e+u,o,n),t.setUint32(e+l,a,n)}const pI=(t,e,r)=>t&e^~t&r,gI=(t,e,r)=>t&e^t&r^e&r;class mI extends ig{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=ng(this.buffer)}update(e){Uc(this);const{view:r,buffer:n,blockLen:i}=this;e=yf(e);const s=e.length;for(let o=0;oi-o&&(this.process(n,0),o=0);for(let g=o;gd.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g>>3,N=Ds(A,17)^Ds(A,19)^A>>>10;Qo[g]=N+Qo[g-7]+P+Qo[g-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:u,G:l,H:d}=this;for(let g=0;g<64;g++){const y=Ds(a,6)^Ds(a,11)^Ds(a,25),A=d+y+pI(a,u,l)+vI[g]+Qo[g]|0,N=(Ds(n,2)^Ds(n,13)^Ds(n,22))+gI(n,i,s)|0;d=l,l=u,u=a,a=o+A|0,o=s,s=i,i=n,n=A+N|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(n,i,s,o,a,u,l,d)}roundClean(){Qo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Ag=cw(()=>new bI);function yI(t,e){return Ag(Yo(t,{strict:!1})?rg(t):t)}function wI(t){const{commitment:e,version:r=1}=t,n=t.to??(typeof e=="string"?"hex":"bytes"),i=yI(e);return i.set([r],0),n==="bytes"?i:li(i)}function xI(t){const{commitments:e,version:r}=t,n=t.to??(typeof e[0]=="string"?"hex":"bytes"),i=[];for(const s of e)i.push(wI({commitment:s,to:n,version:r}));return i}const Hw=6,Ww=32,Pg=4096,Kw=Ww*Pg,Vw=Kw*Hw-1-1*Pg*Hw;class _I extends yt{constructor({maxSize:e,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class EI extends yt{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function SI(t){const e=t.to??(typeof t.data=="string"?"hex":"bytes"),r=typeof t.data=="string"?ao(t.data):t.data,n=_n(r);if(!n)throw new EI;if(n>Vw)throw new _I({maxSize:Vw,size:n});const i=[];let s=!0,o=0;for(;s;){const a=hg(new Uint8Array(Kw));let u=0;for(;ua.bytes):i.map(a=>li(a.bytes))}function AI(t){const{data:e,kzg:r,to:n}=t,i=t.blobs??SI({data:e,to:n}),s=t.commitments??qw({blobs:i,kzg:r,to:n}),o=t.proofs??zw({blobs:i,commitments:s,kzg:r,to:n}),a=[];for(let u=0;u"u"&&g)if(u){const k=await D();y.nonce=await u.consume({address:g.address,chainId:k,client:t})}else y.nonce=await fi(t,hI,"getTransactionCount")({address:g.address,blockTag:"pending"});if((l.includes("fees")||l.includes("type"))&&typeof d>"u")try{y.type=PI(y)}catch{const k=await P();y.type=typeof(k==null?void 0:k.baseFeePerGas)=="bigint"?"eip1559":"legacy"}if(l.includes("fees"))if(y.type!=="legacy"&&y.type!=="eip2930"){if(typeof y.maxFeePerGas>"u"||typeof y.maxPriorityFeePerGas>"u"){const k=await P(),{maxFeePerGas:$,maxPriorityFeePerGas:q}=await jw(t,{block:k,chain:i,request:y});if(typeof e.maxPriorityFeePerGas>"u"&&e.maxFeePerGas&&e.maxFeePerGas"u"&&(y.gas=await fi(t,II,"estimateGas")({...y,account:g&&{address:g.address,type:"json-rpc"}})),jh(y),delete y.parameters,y}async function MI(t,{address:e,blockNumber:r,blockTag:n="latest"}){const i=r?Pr(r):void 0,s=await t.request({method:"eth_getBalance",params:[e,i||n]});return BigInt(s)}async function II(t,e){var i,s,o;const{account:r=t.account}=e,n=r?uo(r):void 0;try{let f=function(v){const{block:x,request:_,rpcStateOverride:S}=v;return t.request({method:"eth_estimateGas",params:S?[_,x??"latest",S]:x?[_,x]:[_]})};const{accessList:a,authorizationList:u,blobs:l,blobVersionedHashes:d,blockNumber:g,blockTag:y,data:A,gas:P,gasPrice:N,maxFeePerBlobGas:D,maxFeePerGas:k,maxPriorityFeePerGas:$,nonce:q,value:U,stateOverride:K,...J}=await Mg(t,{...e,parameters:(n==null?void 0:n.type)==="local"?void 0:["blobVersionedHashes"]}),z=(g?Pr(g):void 0)||y,ue=rI(K),_e=await(async()=>{if(J.to)return J.to;if(u&&u.length>0)return await kw({authorization:u[0]}).catch(()=>{throw new yt("`to` is required. Could not infer from `authorizationList`")})})();jh(e);const G=(o=(s=(i=t.chain)==null?void 0:i.formatters)==null?void 0:s.transactionRequest)==null?void 0:o.format,m=(G||Eg)({...Bw(J,{format:G}),from:n==null?void 0:n.address,accessList:a,authorizationList:u,blobs:l,blobVersionedHashes:d,data:A,gas:P,gasPrice:N,maxFeePerBlobGas:D,maxFeePerGas:k,maxPriorityFeePerGas:$,nonce:q,to:_e,value:U});let p=BigInt(await f({block:z,request:m,rpcStateOverride:ue}));if(u){const v=await MI(t,{address:m.from}),x=await Promise.all(u.map(async _=>{const{contractAddress:S}=_,b=await f({block:z,request:{authorizationList:void 0,data:A,from:n==null?void 0:n.address,to:S,value:Pr(v)},rpcStateOverride:ue}).catch(()=>100000n);return 2n*BigInt(b)}));p+=x.reduce((_,S)=>_+S,0n)}return p}catch(a){throw ZM(a,{...e,account:n,chain:t.chain})}}class CI extends yt{constructor({chain:e,currentChainId:r}){super(`The current chain of the wallet (id: ${r}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`,{metaMessages:[`Current Chain ID: ${r}`,`Expected Chain ID: ${e.id} – ${e.name}`],name:"ChainMismatchError"})}}class TI extends yt{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(` -`),{name:"ChainNotFoundError"})}}const Ig="/docs/contract/encodeDeployData";function RI(t){const{abi:e,args:r,bytecode:n}=t;if(!r||r.length===0)return n;const i=e.find(o=>"type"in o&&o.type==="constructor");if(!i)throw new KA({docsPath:Ig});if(!("inputs"in i))throw new Yy({docsPath:Ig});if(!i.inputs||i.inputs.length===0)throw new Yy({docsPath:Ig});const s=_w(i.inputs,r);return kh([n,s])}async function DI(t){return new Promise(e=>setTimeout(e,t))}class Uf extends yt{constructor({docsPath:e}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(` -`),{docsPath:e,docsSlug:"account",name:"AccountNotFoundError"})}}class Cg extends yt{constructor({docsPath:e,metaMessages:r,type:n}){super(`Account type "${n}" is not supported.`,{docsPath:e,metaMessages:r,name:"AccountTypeNotSupportedError"})}}function Yw({chain:t,currentChainId:e}){if(!t)throw new TI;if(e!==t.id)throw new CI({chain:t,currentChainId:e})}function OI(t,{docsPath:e,...r}){const n=(()=>{const i=$w(t,r);return i instanceof _g?t:i})();return new OM(n,{docsPath:e,...r})}async function Jw(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]},{retryCount:0})}const Tg=new Lh(128);async function Rg(t,e){var k,$,q,U;const{account:r=t.account,chain:n=t.chain,accessList:i,authorizationList:s,blobs:o,data:a,gas:u,gasPrice:l,maxFeePerBlobGas:d,maxFeePerGas:g,maxPriorityFeePerGas:y,nonce:A,value:P,...N}=e;if(typeof r>"u")throw new Uf({docsPath:"/docs/actions/wallet/sendTransaction"});const D=r?uo(r):null;try{jh(e);const K=await(async()=>{if(e.to)return e.to;if(s&&s.length>0)return await kw({authorization:s[0]}).catch(()=>{throw new yt("`to` is required. Could not infer from `authorizationList`.")})})();if((D==null?void 0:D.type)==="json-rpc"||D===null){let J;n!==null&&(J=await fi(t,zh,"getChainId")({}),Yw({currentChainId:J,chain:n}));const T=(q=($=(k=t.chain)==null?void 0:k.formatters)==null?void 0:$.transactionRequest)==null?void 0:q.format,ue=(T||Eg)({...Bw(N,{format:T}),accessList:i,authorizationList:s,blobs:o,chainId:J,data:a,from:D==null?void 0:D.address,gas:u,gasPrice:l,maxFeePerBlobGas:d,maxFeePerGas:g,maxPriorityFeePerGas:y,nonce:A,to:K,value:P}),_e=Tg.get(t.uid),G=_e?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:G,params:[ue]},{retryCount:0})}catch(E){if(_e===!1)throw E;const m=E;if(m.name==="InvalidInputRpcError"||m.name==="InvalidParamsRpcError"||m.name==="MethodNotFoundRpcError"||m.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[ue]},{retryCount:0}).then(f=>(Tg.set(t.uid,!0),f)).catch(f=>{const p=f;throw p.name==="MethodNotFoundRpcError"||p.name==="MethodNotSupportedRpcError"?(Tg.set(t.uid,!1),m):p});throw m}}if((D==null?void 0:D.type)==="local"){const J=await fi(t,Mg,"prepareTransactionRequest")({account:D,accessList:i,authorizationList:s,blobs:o,chain:n,data:a,gas:u,gasPrice:l,maxFeePerBlobGas:d,maxFeePerGas:g,maxPriorityFeePerGas:y,nonce:A,nonceManager:D.nonceManager,parameters:[...Gw,"sidecars"],value:P,...N,to:K}),T=(U=n==null?void 0:n.serializers)==null?void 0:U.transaction,z=await D.signTransaction(J,{serializer:T});return await fi(t,Jw,"sendRawTransaction")({serializedTransaction:z})}throw(D==null?void 0:D.type)==="smart"?new Cg({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new Cg({docsPath:"/docs/actions/wallet/sendTransaction",type:D==null?void 0:D.type})}catch(K){throw K instanceof Cg?K:OI(K,{...e,account:D,chain:e.chain||void 0})}}async function NI(t,e){const{abi:r,account:n=t.account,address:i,args:s,dataSuffix:o,functionName:a,...u}=e;if(typeof n>"u")throw new Uf({docsPath:"/docs/contract/writeContract"});const l=n?uo(n):null,d=cM({abi:r,args:s,functionName:a});try{return await fi(t,Rg,"sendTransaction")({data:`${d}${o?o.replace("0x",""):""}`,to:i,account:l,...u})}catch(g){throw zM(g,{abi:r,address:i,args:s,docsPath:"/docs/contract/writeContract",functionName:a,sender:l==null?void 0:l.address})}}async function LI(t,{chain:e}){const{id:r,name:n,nativeCurrency:i,rpcUrls:s,blockExplorers:o}=e;await t.request({method:"wallet_addEthereumChain",params:[{chainId:Pr(r),chainName:n,nativeCurrency:i,rpcUrls:s.default.http,blockExplorerUrls:o?Object.values(o).map(({url:a})=>a):void 0}]},{dedupe:!0,retryCount:0})}const Dg=256;let Hh=Dg,Wh;function Xw(t=11){if(!Wh||Hh+t>Dg*2){Wh="",Hh=0;for(let e=0;e{const $=k(D);for(const U in P)delete $[U];const q={...D,...$};return Object.assign(q,{extend:N(q)})}}return Object.assign(P,{extend:N(P)})}const Kh=new Lh(8192);function $I(t,{enabled:e=!0,id:r}){if(!e||!r)return t();if(Kh.get(r))return Kh.get(r);const n=t().finally(()=>Kh.delete(r));return Kh.set(r,n),n}function BI(t,{delay:e=100,retryCount:r=2,shouldRetry:n=()=>!0}={}){return new Promise((i,s)=>{const o=async({count:a=0}={})=>{const u=async({error:l})=>{const d=typeof e=="function"?e({count:a,error:l}):e;d&&await DI(d),o({count:a+1})};try{const l=await t();i(l)}catch(l){if(a{const{dedupe:i=!1,retryDelay:s=150,retryCount:o=3,uid:a}={...e,...n},u=i?_f(Dh(`${a}.${Wc(r)}`)):void 0;return $I(()=>BI(async()=>{try{return await t(r)}catch(l){const d=l;switch(d.code){case Af.code:throw new Af(d);case Pf.code:throw new Pf(d);case Mf.code:throw new Mf(d,{method:r.method});case If.code:throw new If(d);case ka.code:throw new ka(d);case Cf.code:throw new Cf(d);case Tf.code:throw new Tf(d);case Rf.code:throw new Rf(d);case Df.code:throw new Df(d);case Of.code:throw new Of(d,{method:r.method});case Vc.code:throw new Vc(d);case Nf.code:throw new Nf(d);case Gc.code:throw new Gc(d);case Lf.code:throw new Lf(d);case kf.code:throw new kf(d);case $f.code:throw new $f(d);case Bf.code:throw new Bf(d);case Ff.code:throw new Ff(d);case 5e3:throw new Gc(d);default:throw l instanceof yt?l:new jM(d)}}},{delay:({count:l,error:d})=>{var g;if(d&&d instanceof Dw){const y=(g=d==null?void 0:d.headers)==null?void 0:g.get("Retry-After");if(y!=null&&y.match(/\d/))return Number.parseInt(y)*1e3}return~~(1<UI(l)}),{enabled:i,id:u})}}function UI(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===Vc.code||t.code===ka.code:t instanceof Dw&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function jI({key:t,name:e,request:r,retryCount:n=3,retryDelay:i=150,timeout:s,type:o},a){const u=Xw();return{config:{key:t,name:e,request:r,retryCount:n,retryDelay:i,timeout:s,type:o},request:FI(r,{retryCount:n,retryDelay:i,uid:u}),value:a}}function qI(t,e={}){const{key:r="custom",name:n="Custom Provider",retryDelay:i}=e;return({retryCount:s})=>jI({key:r,name:n,request:t.request.bind(t),retryCount:e.retryCount??s,retryDelay:i,type:"custom"})}const zI=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,HI=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;class WI extends yt{constructor({domain:e}){super(`Invalid domain "${Wc(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class KI extends yt{constructor({primaryType:e,types:r}){super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(r))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class VI extends yt{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function GI(t){const{domain:e,message:r,primaryType:n,types:i}=t,s=(u,l)=>{const d={...l};for(const g of u){const{name:y,type:A}=g;A==="address"&&(d[y]=d[y].toLowerCase())}return d},o=i.EIP712Domain?e?s(i.EIP712Domain,e):{}:{},a=(()=>{if(n!=="EIP712Domain")return s(i[n],r)})();return Wc({domain:o,message:a,primaryType:n,types:i})}function YI(t){const{domain:e,message:r,primaryType:n,types:i}=t,s=(o,a)=>{for(const u of o){const{name:l,type:d}=u,g=a[l],y=d.match(HI);if(y&&(typeof g=="number"||typeof g=="bigint")){const[N,D,k]=y;Pr(g,{signed:D==="int",size:Number.parseInt(k)/8})}if(d==="address"&&typeof g=="string"&&!co(g))throw new qc({address:g});const A=d.match(zI);if(A){const[N,D]=A;if(D&&_n(g)!==Number.parseInt(D))throw new ZA({expectedSize:Number.parseInt(D),givenSize:_n(g)})}const P=i[d];P&&(XI(d),s(P,g))}};if(i.EIP712Domain&&e){if(typeof e!="object")throw new WI({domain:e});s(i.EIP712Domain,e)}if(n!=="EIP712Domain")if(i[n])s(i[n],r);else throw new KI({primaryType:n,types:i})}function JI({domain:t}){return[typeof(t==null?void 0:t.name)=="string"&&{name:"name",type:"string"},(t==null?void 0:t.version)&&{name:"version",type:"string"},typeof(t==null?void 0:t.chainId)=="number"&&{name:"chainId",type:"uint256"},(t==null?void 0:t.verifyingContract)&&{name:"verifyingContract",type:"address"},(t==null?void 0:t.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function XI(t){if(t==="address"||t==="bool"||t==="string"||t.startsWith("bytes")||t.startsWith("uint")||t.startsWith("int"))throw new VI({type:t})}let Zw=class extends ig{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,dP(e);const n=yf(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;onew Zw(t,e).update(r).digest();Qw.create=(t,e)=>new Zw(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Og=BigInt(0),Vh=BigInt(1),ZI=BigInt(2);function $a(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function jf(t){if(!$a(t))throw new Error("Uint8Array expected")}function Jc(t,e){if(typeof e!="boolean")throw new Error(`${t} must be valid boolean, got "${e}".`)}const QI=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Xc(t){jf(t);let e="";for(let r=0;r=lo._0&&t<=lo._9)return t-lo._0;if(t>=lo._A&&t<=lo._F)return t-(lo._A-10);if(t>=lo._a&&t<=lo._f)return t-(lo._a-10)}function Qc(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let i=0,s=0;itypeof t=="bigint"&&Og<=t;function Gh(t,e,r){return $g(t)&&$g(e)&&$g(r)&&e<=t&&tOg;t>>=Vh,e+=1);return e}function nC(t,e){return t>>BigInt(e)&Vh}function iC(t,e,r){return t|(r?Vh:Og)<(ZI<new Uint8Array(t),r2=t=>Uint8Array.from(t);function n2(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Fg(t),i=Fg(t),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=(...g)=>r(i,n,...g),u=(g=Fg())=>{i=a(r2([0]),g),n=a(),g.length!==0&&(i=a(r2([1]),g),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const y=[];for(;g{o(),u(g);let A;for(;!(A=y(l()));)u();return o(),A}}const sC={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||$a(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function zf(t,e,r={}){const n=(i,s,o)=>{const a=sC[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);const u=t[i];if(!(o&&u===void 0)&&!a(u,t))throw new Error(`Invalid param ${String(i)}=${u} (${typeof u}), expected ${s}`)};for(const[i,s]of Object.entries(e))n(i,s,!1);for(const[i,s]of Object.entries(r))n(i,s,!0);return t}const oC=()=>{throw new Error("not implemented")};function Ug(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(i!==void 0)return i;const s=t(r,...n);return e.set(r,s),s}}const aC=Object.freeze(Object.defineProperty({__proto__:null,aInRange:Fa,abool:Jc,abytes:jf,bitGet:nC,bitLen:t2,bitMask:Bg,bitSet:iC,bytesToHex:Xc,bytesToNumberBE:Ba,bytesToNumberLE:Lg,concatBytes:qf,createHmacDrbg:n2,ensureBytes:hs,equalBytes:tC,hexToBytes:Qc,hexToNumber:Ng,inRange:Gh,isBytes:$a,memoized:Ug,notImplemented:oC,numberToBytesBE:eu,numberToBytesLE:kg,numberToHexUnpadded:Zc,numberToVarBytesBE:eC,utf8ToBytes:rC,validateObject:zf},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Mn=BigInt(0),sn=BigInt(1),Ua=BigInt(2),cC=BigInt(3),jg=BigInt(4),i2=BigInt(5),s2=BigInt(8);BigInt(9),BigInt(16);function di(t,e){const r=t%e;return r>=Mn?r:e+r}function uC(t,e,r){if(r<=Mn||e 0");if(r===sn)return Mn;let n=sn;for(;e>Mn;)e&sn&&(n=n*t%r),t=t*t%r,e>>=sn;return n}function ji(t,e,r){let n=t;for(;e-- >Mn;)n*=n,n%=r;return n}function qg(t,e){if(t===Mn||e<=Mn)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=di(t,e),n=e,i=Mn,s=sn;for(;r!==Mn;){const a=n/r,u=n%r,l=i-s*a;n=r,r=u,i=s,s=l}if(n!==sn)throw new Error("invert: does not exist");return di(i,e)}function fC(t){const e=(t-sn)/Ua;let r,n,i;for(r=t-sn,n=0;r%Ua===Mn;r/=Ua,n++);for(i=Ua;i(n[i]="function",n),e);return zf(t,r)}function pC(t,e,r){if(r 0");if(r===Mn)return t.ONE;if(r===sn)return e;let n=t.ONE,i=e;for(;r>Mn;)r&sn&&(n=t.mul(n,i)),i=t.sqr(i),r>>=sn;return n}function gC(t,e){const r=new Array(e.length),n=e.reduce((s,o,a)=>t.is0(o)?s:(r[a]=s,t.mul(s,o)),t.ONE),i=t.inv(n);return e.reduceRight((s,o,a)=>t.is0(o)?s:(r[a]=t.mul(s,r[a]),t.mul(s,o)),i),r}function o2(t,e){const r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function a2(t,e,r=!1,n={}){if(t<=Mn)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:s}=o2(t,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=lC(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:s,MASK:Bg(i),ZERO:Mn,ONE:sn,create:u=>di(u,t),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Mn<=u&&uu===Mn,isOdd:u=>(u&sn)===sn,neg:u=>di(-u,t),eql:(u,l)=>u===l,sqr:u=>di(u*u,t),add:(u,l)=>di(u+l,t),sub:(u,l)=>di(u-l,t),mul:(u,l)=>di(u*l,t),pow:(u,l)=>pC(a,u,l),div:(u,l)=>di(u*qg(l,t),t),sqrN:u=>u*u,addN:(u,l)=>u+l,subN:(u,l)=>u-l,mulN:(u,l)=>u*l,inv:u=>qg(u,t),sqrt:n.sqrt||(u=>o(a,u)),invertBatch:u=>gC(a,u),cmov:(u,l,d)=>d?l:u,toBytes:u=>r?kg(u,s):eu(u,s),fromBytes:u=>{if(u.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${u.length}`);return r?Lg(u):Ba(u)}});return Object.freeze(a)}function c2(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function u2(t){const e=c2(t);return e+Math.ceil(e/2)}function mC(t,e,r=!1){const n=t.length,i=c2(e),s=u2(e);if(n<16||n1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const o=r?Ba(t):Lg(t),a=di(o,e-sn)+sn;return r?kg(a,i):eu(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vC=BigInt(0),zg=BigInt(1),Hg=new WeakMap,f2=new WeakMap;function bC(t,e){const r=(s,o)=>{const a=o.negate();return s?a:o},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>e)throw new Error(`Wrong window size=${s}, should be [1..${e}]`)},i=s=>{n(s);const o=Math.ceil(e/s)+1,a=2**(s-1);return{windows:o,windowSize:a}};return{constTimeNegate:r,unsafeLadder(s,o){let a=t.ZERO,u=s;for(;o>vC;)o&zg&&(a=a.add(u)),u=u.double(),o>>=zg;return a},precomputeWindow(s,o){const{windows:a,windowSize:u}=i(o),l=[];let d=s,g=d;for(let y=0;y>=P,k>l&&(k-=A,a+=zg);const $=D,q=D+Math.abs(k)-1,U=N%2!==0,K=k<0;k===0?g=g.add(r(U,o[$])):d=d.add(r(K,o[q]))}return{p:d,f:g}},wNAFCached(s,o,a){const u=f2.get(s)||1;let l=Hg.get(s);return l||(l=this.precomputeWindow(s,u),u!==1&&Hg.set(s,a(l))),this.wNAF(u,l,o)},setWindowSize(s,o){n(o),f2.set(s,o),Hg.delete(s)}}}function yC(t,e,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((d,g)=>{if(!e.isValid(d))throw new Error(`wrong scalar at index ${g}`)}),r.forEach((d,g)=>{if(!(d instanceof t))throw new Error(`wrong point at index ${g}`)});const i=t2(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,o=(1<=0;d-=s){a.fill(t.ZERO);for(let y=0;y>BigInt(d)&BigInt(o));a[P]=a[P].add(r[y])}let g=t.ZERO;for(let y=a.length-1,A=t.ZERO;y>0;y--)A=A.add(a[y]),g=g.add(A);if(l=l.add(g),d!==0)for(let y=0;y{const{Err:r}=ho;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const n=e.length/2,i=Zc(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const s=n>127?Zc(i.length/2|128):"";return`${Zc(t)}${s}${i}${e}`},decode(t,e){const{Err:r}=ho;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const i=e[n++],s=!!(i&128);let o=0;if(!s)o=i;else{const u=i&127;if(!u)throw new r("tlv.decode(long): indefinite length not supported");if(u>4)throw new r("tlv.decode(long): byte length is too big");const l=e.subarray(n,n+u);if(l.length!==u)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const d of l)o=o<<8|d;if(n+=u,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){const{Err:e}=ho;if(t{const $=D.toAffine();return qf(Uint8Array.from([4]),r.toBytes($.x),r.toBytes($.y))}),s=e.fromBytes||(N=>{const D=N.subarray(1),k=r.fromBytes(D.subarray(0,r.BYTES)),$=r.fromBytes(D.subarray(r.BYTES,2*r.BYTES));return{x:k,y:$}});function o(N){const{a:D,b:k}=e,$=r.sqr(N),q=r.mul($,N);return r.add(r.add(q,r.mul(N,D)),k)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function a(N){return Gh(N,In,e.n)}function u(N){const{allowedPrivateKeyLengths:D,nByteLength:k,wrapPrivateKey:$,n:q}=e;if(D&&typeof N!="bigint"){if($a(N)&&(N=Xc(N)),typeof N!="string"||!D.includes(N.length))throw new Error("Invalid key");N=N.padStart(k*2,"0")}let U;try{U=typeof N=="bigint"?N:Ba(hs("private key",N,k))}catch{throw new Error(`private key must be ${k} bytes, hex or bigint, not ${typeof N}`)}return $&&(U=di(U,q)),Fa("private key",U,In,q),U}function l(N){if(!(N instanceof y))throw new Error("ProjectivePoint expected")}const d=Ug((N,D)=>{const{px:k,py:$,pz:q}=N;if(r.eql(q,r.ONE))return{x:k,y:$};const U=N.is0();D==null&&(D=U?r.ONE:r.inv(q));const K=r.mul(k,D),J=r.mul($,D),T=r.mul(q,D);if(U)return{x:r.ZERO,y:r.ZERO};if(!r.eql(T,r.ONE))throw new Error("invZ was invalid");return{x:K,y:J}}),g=Ug(N=>{if(N.is0()){if(e.allowInfinityPoint&&!r.is0(N.py))return;throw new Error("bad point: ZERO")}const{x:D,y:k}=N.toAffine();if(!r.isValid(D)||!r.isValid(k))throw new Error("bad point: x or y not FE");const $=r.sqr(k),q=o(D);if(!r.eql($,q))throw new Error("bad point: equation left != right");if(!N.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class y{constructor(D,k,$){if(this.px=D,this.py=k,this.pz=$,D==null||!r.isValid(D))throw new Error("x required");if(k==null||!r.isValid(k))throw new Error("y required");if($==null||!r.isValid($))throw new Error("z required");Object.freeze(this)}static fromAffine(D){const{x:k,y:$}=D||{};if(!D||!r.isValid(k)||!r.isValid($))throw new Error("invalid affine point");if(D instanceof y)throw new Error("projective point not allowed");const q=U=>r.eql(U,r.ZERO);return q(k)&&q($)?y.ZERO:new y(k,$,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(D){const k=r.invertBatch(D.map($=>$.pz));return D.map(($,q)=>$.toAffine(k[q])).map(y.fromAffine)}static fromHex(D){const k=y.fromAffine(s(hs("pointHex",D)));return k.assertValidity(),k}static fromPrivateKey(D){return y.BASE.multiply(u(D))}static msm(D,k){return yC(y,n,D,k)}_setWindowSize(D){P.setWindowSize(this,D)}assertValidity(){g(this)}hasEvenY(){const{y:D}=this.toAffine();if(r.isOdd)return!r.isOdd(D);throw new Error("Field doesn't support isOdd")}equals(D){l(D);const{px:k,py:$,pz:q}=this,{px:U,py:K,pz:J}=D,T=r.eql(r.mul(k,J),r.mul(U,q)),z=r.eql(r.mul($,J),r.mul(K,q));return T&&z}negate(){return new y(this.px,r.neg(this.py),this.pz)}double(){const{a:D,b:k}=e,$=r.mul(k,d2),{px:q,py:U,pz:K}=this;let J=r.ZERO,T=r.ZERO,z=r.ZERO,ue=r.mul(q,q),_e=r.mul(U,U),G=r.mul(K,K),E=r.mul(q,U);return E=r.add(E,E),z=r.mul(q,K),z=r.add(z,z),J=r.mul(D,z),T=r.mul($,G),T=r.add(J,T),J=r.sub(_e,T),T=r.add(_e,T),T=r.mul(J,T),J=r.mul(E,J),z=r.mul($,z),G=r.mul(D,G),E=r.sub(ue,G),E=r.mul(D,E),E=r.add(E,z),z=r.add(ue,ue),ue=r.add(z,ue),ue=r.add(ue,G),ue=r.mul(ue,E),T=r.add(T,ue),G=r.mul(U,K),G=r.add(G,G),ue=r.mul(G,E),J=r.sub(J,ue),z=r.mul(G,_e),z=r.add(z,z),z=r.add(z,z),new y(J,T,z)}add(D){l(D);const{px:k,py:$,pz:q}=this,{px:U,py:K,pz:J}=D;let T=r.ZERO,z=r.ZERO,ue=r.ZERO;const _e=e.a,G=r.mul(e.b,d2);let E=r.mul(k,U),m=r.mul($,K),f=r.mul(q,J),p=r.add(k,$),v=r.add(U,K);p=r.mul(p,v),v=r.add(E,m),p=r.sub(p,v),v=r.add(k,q);let x=r.add(U,J);return v=r.mul(v,x),x=r.add(E,f),v=r.sub(v,x),x=r.add($,q),T=r.add(K,J),x=r.mul(x,T),T=r.add(m,f),x=r.sub(x,T),ue=r.mul(_e,v),T=r.mul(G,f),ue=r.add(T,ue),T=r.sub(m,ue),ue=r.add(m,ue),z=r.mul(T,ue),m=r.add(E,E),m=r.add(m,E),f=r.mul(_e,f),v=r.mul(G,v),m=r.add(m,f),f=r.sub(E,f),f=r.mul(_e,f),v=r.add(v,f),E=r.mul(m,v),z=r.add(z,E),E=r.mul(x,v),T=r.mul(p,T),T=r.sub(T,E),E=r.mul(p,m),ue=r.mul(x,ue),ue=r.add(ue,E),new y(T,z,ue)}subtract(D){return this.add(D.negate())}is0(){return this.equals(y.ZERO)}wNAF(D){return P.wNAFCached(this,D,y.normalizeZ)}multiplyUnsafe(D){Fa("scalar",D,po,e.n);const k=y.ZERO;if(D===po)return k;if(D===In)return this;const{endo:$}=e;if(!$)return P.unsafeLadder(this,D);let{k1neg:q,k1:U,k2neg:K,k2:J}=$.splitScalar(D),T=k,z=k,ue=this;for(;U>po||J>po;)U&In&&(T=T.add(ue)),J&In&&(z=z.add(ue)),ue=ue.double(),U>>=In,J>>=In;return q&&(T=T.negate()),K&&(z=z.negate()),z=new y(r.mul(z.px,$.beta),z.py,z.pz),T.add(z)}multiply(D){const{endo:k,n:$}=e;Fa("scalar",D,In,$);let q,U;if(k){const{k1neg:K,k1:J,k2neg:T,k2:z}=k.splitScalar(D);let{p:ue,f:_e}=this.wNAF(J),{p:G,f:E}=this.wNAF(z);ue=P.constTimeNegate(K,ue),G=P.constTimeNegate(T,G),G=new y(r.mul(G.px,k.beta),G.py,G.pz),q=ue.add(G),U=_e.add(E)}else{const{p:K,f:J}=this.wNAF(D);q=K,U=J}return y.normalizeZ([q,U])[0]}multiplyAndAddUnsafe(D,k,$){const q=y.BASE,U=(J,T)=>T===po||T===In||!J.equals(q)?J.multiplyUnsafe(T):J.multiply(T),K=U(this,k).add(U(D,$));return K.is0()?void 0:K}toAffine(D){return d(this,D)}isTorsionFree(){const{h:D,isTorsionFree:k}=e;if(D===In)return!0;if(k)return k(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:D,clearCofactor:k}=e;return D===In?this:k?k(y,this):this.multiplyUnsafe(e.h)}toRawBytes(D=!0){return Jc("isCompressed",D),this.assertValidity(),i(y,this,D)}toHex(D=!0){return Jc("isCompressed",D),Xc(this.toRawBytes(D))}}y.BASE=new y(e.Gx,e.Gy,r.ONE),y.ZERO=new y(r.ZERO,r.ONE,r.ZERO);const A=e.nBitLength,P=bC(y,e.endo?Math.ceil(A/2):A);return{CURVE:e,ProjectivePoint:y,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:a}}function SC(t){const e=l2(t);return zf(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function AC(t){const e=SC(t),{Fp:r,n}=e,i=r.BYTES+1,s=2*r.BYTES+1;function o(f){return di(f,n)}function a(f){return qg(f,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:l,weierstrassEquation:d,isWithinCurveOrder:g}=EC({...e,toBytes(f,p,v){const x=p.toAffine(),_=r.toBytes(x.x),S=qf;return Jc("isCompressed",v),v?S(Uint8Array.from([p.hasEvenY()?2:3]),_):S(Uint8Array.from([4]),_,r.toBytes(x.y))},fromBytes(f){const p=f.length,v=f[0],x=f.subarray(1);if(p===i&&(v===2||v===3)){const _=Ba(x);if(!Gh(_,In,r.ORDER))throw new Error("Point is not on curve");const S=d(_);let b;try{b=r.sqrt(S)}catch(F){const ae=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+ae)}const M=(b&In)===In;return(v&1)===1!==M&&(b=r.neg(b)),{x:_,y:b}}else if(p===s&&v===4){const _=r.fromBytes(x.subarray(0,r.BYTES)),S=r.fromBytes(x.subarray(r.BYTES,2*r.BYTES));return{x:_,y:S}}else throw new Error(`Point of length ${p} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}}),y=f=>Xc(eu(f,e.nByteLength));function A(f){const p=n>>In;return f>p}function P(f){return A(f)?o(-f):f}const N=(f,p,v)=>Ba(f.slice(p,v));class D{constructor(p,v,x){this.r=p,this.s=v,this.recovery=x,this.assertValidity()}static fromCompact(p){const v=e.nByteLength;return p=hs("compactSignature",p,v*2),new D(N(p,0,v),N(p,v,2*v))}static fromDER(p){const{r:v,s:x}=ho.toSig(hs("DER",p));return new D(v,x)}assertValidity(){Fa("r",this.r,In,n),Fa("s",this.s,In,n)}addRecoveryBit(p){return new D(this.r,this.s,p)}recoverPublicKey(p){const{r:v,s:x,recovery:_}=this,S=J(hs("msgHash",p));if(_==null||![0,1,2,3].includes(_))throw new Error("recovery id invalid");const b=_===2||_===3?v+e.n:v;if(b>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const M=_&1?"03":"02",I=u.fromHex(M+y(b)),F=a(b),ae=o(-S*F),O=o(x*F),se=u.BASE.multiplyAndAddUnsafe(I,ae,O);if(!se)throw new Error("point at infinify");return se.assertValidity(),se}hasHighS(){return A(this.s)}normalizeS(){return this.hasHighS()?new D(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Qc(this.toDERHex())}toDERHex(){return ho.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Qc(this.toCompactHex())}toCompactHex(){return y(this.r)+y(this.s)}}const k={isValidPrivateKey(f){try{return l(f),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const f=u2(e.n);return mC(e.randomBytes(f),e.n)},precompute(f=8,p=u.BASE){return p._setWindowSize(f),p.multiply(BigInt(3)),p}};function $(f,p=!0){return u.fromPrivateKey(f).toRawBytes(p)}function q(f){const p=$a(f),v=typeof f=="string",x=(p||v)&&f.length;return p?x===i||x===s:v?x===2*i||x===2*s:f instanceof u}function U(f,p,v=!0){if(q(f))throw new Error("first arg must be private key");if(!q(p))throw new Error("second arg must be public key");return u.fromHex(p).multiply(l(f)).toRawBytes(v)}const K=e.bits2int||function(f){const p=Ba(f),v=f.length*8-e.nBitLength;return v>0?p>>BigInt(v):p},J=e.bits2int_modN||function(f){return o(K(f))},T=Bg(e.nBitLength);function z(f){return Fa(`num < 2^${e.nBitLength}`,f,po,T),eu(f,e.nByteLength)}function ue(f,p,v=_e){if(["recovered","canonical"].some(X=>X in v))throw new Error("sign() legacy options not supported");const{hash:x,randomBytes:_}=e;let{lowS:S,prehash:b,extraEntropy:M}=v;S==null&&(S=!0),f=hs("msgHash",f),h2(v),b&&(f=hs("prehashed msgHash",x(f)));const I=J(f),F=l(p),ae=[z(F),z(I)];if(M!=null&&M!==!1){const X=M===!0?_(r.BYTES):M;ae.push(hs("extraEntropy",X))}const O=qf(...ae),se=I;function ee(X){const Q=K(X);if(!g(Q))return;const R=a(Q),Z=u.BASE.multiply(Q).toAffine(),te=o(Z.x);if(te===po)return;const le=o(R*o(se+te*F));if(le===po)return;let ie=(Z.x===te?0:2)|Number(Z.y&In),fe=le;return S&&A(le)&&(fe=P(le),ie^=1),new D(te,fe,ie)}return{seed:O,k2sig:ee}}const _e={lowS:e.lowS,prehash:!1},G={lowS:e.lowS,prehash:!1};function E(f,p,v=_e){const{seed:x,k2sig:_}=ue(f,p,v),S=e;return n2(S.hash.outputLen,S.nByteLength,S.hmac)(x,_)}u.BASE._setWindowSize(8);function m(f,p,v,x=G){var Z;const _=f;if(p=hs("msgHash",p),v=hs("publicKey",v),"strict"in x)throw new Error("options.strict was renamed to lowS");h2(x);const{lowS:S,prehash:b}=x;let M,I;try{if(typeof _=="string"||$a(_))try{M=D.fromDER(_)}catch(te){if(!(te instanceof ho.Err))throw te;M=D.fromCompact(_)}else if(typeof _=="object"&&typeof _.r=="bigint"&&typeof _.s=="bigint"){const{r:te,s:le}=_;M=new D(te,le)}else throw new Error("PARSE");I=u.fromHex(v)}catch(te){if(te.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(S&&M.hasHighS())return!1;b&&(p=e.hash(p));const{r:F,s:ae}=M,O=J(p),se=a(ae),ee=o(O*se),X=o(F*se),Q=(Z=u.BASE.multiplyAndAddUnsafe(I,ee,X))==null?void 0:Z.toAffine();return Q?o(Q.x)===F:!1}return{CURVE:e,getPublicKey:$,getSharedSecret:U,sign:E,verify:m,ProjectivePoint:u,Signature:D,utils:k}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function PC(t){return{hash:t,hmac:(e,...r)=>Qw(t,e,AP(...r)),randomBytes:MP}}function MC(t,e){const r=n=>AC({...t,...PC(n)});return Object.freeze({...r(e),create:r})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const p2=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),g2=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),IC=BigInt(1),Wg=BigInt(2),m2=(t,e)=>(t+e/Wg)/e;function CC(t){const e=p2,r=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),l=t*t*t%e,d=l*l*t%e,g=ji(d,r,e)*d%e,y=ji(g,r,e)*d%e,A=ji(y,Wg,e)*l%e,P=ji(A,i,e)*A%e,N=ji(P,s,e)*P%e,D=ji(N,a,e)*N%e,k=ji(D,u,e)*D%e,$=ji(k,a,e)*N%e,q=ji($,r,e)*d%e,U=ji(q,o,e)*P%e,K=ji(U,n,e)*l%e,J=ji(K,Wg,e);if(!Kg.eql(Kg.sqr(J),t))throw new Error("Cannot find square root");return J}const Kg=a2(p2,void 0,void 0,{sqrt:CC}),v2=MC({a:BigInt(0),b:BigInt(7),Fp:Kg,n:g2,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=g2,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-IC*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=BigInt("0x100000000000000000000000000000000"),a=m2(s*t,e),u=m2(-n*t,e);let l=di(t-a*r-u*i,e),d=di(-a*n-u*s,e);const g=l>o,y=d>o;if(g&&(l=e-l),y&&(d=e-d),l>o||d>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:g,k1:l,k2neg:y,k2:d}}}},Ag);BigInt(0),v2.ProjectivePoint;const TC=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:v2},Symbol.toStringTag,{value:"Module"}));function RC(t,e){const{abi:r,args:n,bytecode:i,...s}=e,o=RI({abi:r,args:n,bytecode:i});return Rg(t,{...s,data:o})}async function DC(t){var r;return((r=t.account)==null?void 0:r.type)==="local"?[t.account.address]:(await t.request({method:"eth_accounts"},{dedupe:!0})).map(n=>Ef(n))}async function OC(t){return await t.request({method:"wallet_getPermissions"},{dedupe:!0})}async function NC(t){return(await t.request({method:"eth_requestAccounts"},{dedupe:!0,retryCount:0})).map(r=>bw(r))}async function LC(t,e){return t.request({method:"wallet_requestPermissions",params:[e]},{retryCount:0})}async function kC(t,{account:e=t.account,message:r}){if(!e)throw new Uf({docsPath:"/docs/actions/wallet/signMessage"});const n=uo(e);if(n.signMessage)return n.signMessage({message:r});const i=typeof r=="string"?Dh(r):r.raw instanceof Uint8Array?Rh(r.raw):r.raw;return t.request({method:"personal_sign",params:[i,n.address]},{retryCount:0})}async function $C(t,e){var l,d,g,y;const{account:r=t.account,chain:n=t.chain,...i}=e;if(!r)throw new Uf({docsPath:"/docs/actions/wallet/signTransaction"});const s=uo(r);jh({account:s,...e});const o=await fi(t,zh,"getChainId")({});n!==null&&Yw({currentChainId:o,chain:n});const a=(n==null?void 0:n.formatters)||((l=t.chain)==null?void 0:l.formatters),u=((d=a==null?void 0:a.transactionRequest)==null?void 0:d.format)||Eg;return s.signTransaction?s.signTransaction({...i,chainId:o},{serializer:(y=(g=t.chain)==null?void 0:g.serializers)==null?void 0:y.transaction}):await t.request({method:"eth_signTransaction",params:[{...u(i),chainId:Pr(o),from:s.address}]},{retryCount:0})}async function BC(t,e){const{account:r=t.account,domain:n,message:i,primaryType:s}=e;if(!r)throw new Uf({docsPath:"/docs/actions/wallet/signTypedData"});const o=uo(r),a={EIP712Domain:JI({domain:n}),...e.types};if(YI({domain:n,message:i,primaryType:s,types:a}),o.signTypedData)return o.signTypedData({domain:n,message:i,primaryType:s,types:a});const u=GI({domain:n,message:i,primaryType:s,types:a});return t.request({method:"eth_signTypedData_v4",params:[o.address,u]},{retryCount:0})}async function FC(t,{id:e}){await t.request({method:"wallet_switchEthereumChain",params:[{chainId:Pr(e)}]},{retryCount:0})}async function UC(t,e){return await t.request({method:"wallet_watchAsset",params:e},{retryCount:0})}function jC(t){return{addChain:e=>LI(t,e),deployContract:e=>RC(t,e),getAddresses:()=>DC(t),getChainId:()=>zh(t),getPermissions:()=>OC(t),prepareTransactionRequest:e=>Mg(t,e),requestAddresses:()=>NC(t),requestPermissions:e=>LC(t,e),sendRawTransaction:e=>Jw(t,e),sendTransaction:e=>Rg(t,e),signMessage:e=>kC(t,e),signTransaction:e=>$C(t,e),signTypedData:e=>BC(t,e),switchChain:e=>FC(t,e),watchAsset:e=>UC(t,e),writeContract:e=>NI(t,e)}}function qC(t){const{key:e="wallet",name:r="Wallet Client",transport:n}=t;return kI({...t,key:e,name:r,transport:n,type:"walletClient"}).extend(jC)}class Hf{constructor(e){so(this,"_key");so(this,"_config",null);so(this,"_provider",null);so(this,"_connected",!1);so(this,"_address",null);so(this,"_fatured",!1);so(this,"_installed",!1);so(this,"lastUsed",!1);var r;if("name"in e&&"image"in e)this._key=e.name,this._config=e,this._fatured=e.featured;else if("session"in e){if(!e.session)throw new Error("session is null");this._key=(r=e.session)==null?void 0:r.peer.metadata.name,this._provider=e,this._config={name:e.session.peer.metadata.name,image:e.session.peer.metadata.icons[0],featured:!1}}else if("info"in e)console.log(e.info,"installed"),this._key=e.info.name,this._provider=e.provider,this._installed=!0,this._config={name:e.info.name,image:e.info.icon,featured:!1},this.testConnect();else throw new Error("unknown params")}get address(){return this._address}get connected(){return this._connected}get featured(){return this._fatured}get key(){return this._key}get installed(){return this._installed}get client(){return this._provider?qC({transport:qI(this._provider)}):null}get config(){return this._config}static fromWalletConfig(e){return new Hf(e)}EIP6963Detected(e){this._provider=e.provider,this._installed=!0,this._provider.on("disconnect",this.disconnect),this._provider.on("accountsChanged",r=>{this._address=r[0],this._connected=!0}),this.testConnect()}setUniversalProvider(e){this._provider=e,this.testConnect()}async testConnect(){var r;const e=await((r=this.client)==null?void 0:r.getAddresses());e&&e.length>0?(this._address=e[0],this._connected=!0):(this._address=null,this._connected=!1)}async connect(){var r;const e=await((r=this.client)==null?void 0:r.request({method:"eth_requestAccounts",params:void 0}));if(!e)throw new Error("connect failed");return e}async getAddress(){var r;const e=await((r=this.client)==null?void 0:r.getAddresses());if(!e)throw new Error("get address failed");return e[0]}async getChain(){var r;const e=await((r=this.client)==null?void 0:r.getChainId());if(!e)throw new Error("get chain failed");return e}async signMessage(e,r){var i;return await((i=this.client)==null?void 0:i.signMessage({message:e,account:r}))}async disconnect(){this._provider&&"session"in this._provider&&await this._provider.disconnect(),this._connected=!1,this._address=null}}var Vg={exports:{}},tu=typeof Reflect=="object"?Reflect:null,b2=tu&&typeof tu.apply=="function"?tu.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Yh;tu&&typeof tu.ownKeys=="function"?Yh=tu.ownKeys:Object.getOwnPropertySymbols?Yh=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Yh=function(e){return Object.getOwnPropertyNames(e)};function zC(t){console&&console.warn&&console.warn(t)}var y2=Number.isNaN||function(e){return e!==e};function Rr(){Rr.init.call(this)}Vg.exports=Rr,Vg.exports.once=VC,Rr.EventEmitter=Rr,Rr.prototype._events=void 0,Rr.prototype._eventsCount=0,Rr.prototype._maxListeners=void 0;var w2=10;function Jh(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Rr,"defaultMaxListeners",{enumerable:!0,get:function(){return w2},set:function(t){if(typeof t!="number"||t<0||y2(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");w2=t}}),Rr.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},Rr.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||y2(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 x2(t){return t._maxListeners===void 0?Rr.defaultMaxListeners:t._maxListeners}Rr.prototype.getMaxListeners=function(){return x2(this)},Rr.prototype.emit=function(e){for(var r=[],n=1;n0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=s[e];if(u===void 0)return!1;if(typeof u=="function")b2(u,this,r);else for(var l=u.length,d=P2(u,l),n=0;n0&&o.length>i&&!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=t,a.type=e,a.count=o.length,zC(a)}return t}Rr.prototype.addListener=function(e,r){return _2(this,e,r,!1)},Rr.prototype.on=Rr.prototype.addListener,Rr.prototype.prependListener=function(e,r){return _2(this,e,r,!0)};function HC(){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 E2(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=HC.bind(n);return i.listener=r,n.wrapFn=i,i}Rr.prototype.once=function(e,r){return Jh(r),this.on(e,E2(this,e,r)),this},Rr.prototype.prependOnceListener=function(e,r){return Jh(r),this.prependListener(e,E2(this,e,r)),this},Rr.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Jh(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():WC(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this},Rr.prototype.off=Rr.prototype.removeListener,Rr.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i=0;i--)this.removeListener(e,r[i]);return this};function S2(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?KC(i):P2(i,i.length)}Rr.prototype.listeners=function(e){return S2(this,e,!0)},Rr.prototype.rawListeners=function(e){return S2(this,e,!1)},Rr.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):A2.call(t,e)},Rr.prototype.listenerCount=A2;function A2(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Rr.prototype.eventNames=function(){return this._eventsCount>0?Yh(this._events):[]};function P2(t,e){for(var r=new Array(e),n=0;n`,Tt,Mt,mt,Mt),tt[Mt+Tt]=!0}}return j===n?Ut(ot):jt(ot),ot}}function K(j,oe,le){return Ft(j,oe,le,!0)}function G(j,oe,le){return Ft(j,oe,le,!1)}var J=G,T=K;pu.Fragment=n,pu.jsx=J,pu.jsxs=T})()),pu}var oy;function TA(){return oy||(oy=1,process.env.NODE_ENV==="production"?Rl.exports=CA():Rl.exports=RA()),Rl.exports}var he=TA();const bs="https://static.codatta.io/codatta-connect/wallet-icons.svg?v=2",DA=[{featured:!0,name:"MetaMask",rdns:"io.metamask",image:`${bs}#metamask`,getWallet:{chrome_store_id:"nkbihfbeogaeaoehlefnkodbefgpgknn",brave_store_id:"nkbihfbeogaeaoehlefnkodbefgpgknn",edge_addon_id:"ejbalbakoplchlghecdalmeeeajnimhm",firefox_addon_id:"ether-metamask",play_store_id:"io.metamask",app_store_id:"id1438144202"},deep_link:"metamask://wc",universal_link:"https://metamask.app.link/wc"},{name:"Binance Wallet",featured:!0,image:`${bs}#ebac7b39-688c-41e3-7912-a4fefba74600`,getWallet:{chrome_store_id:"cadiboklkpojfamcoggejbbdjcoiljjk",play_store_id:"com.binance.dev",app_store_id:"id1436799971"}},{featured:!0,name:"OKX Wallet",rdns:"com.okex.wallet",image:`${bs}#okx`,getWallet:{chrome_store_id:"mcohilncbfahbmgdjkbpemcciiolgcge",brave_store_id:"mcohilncbfahbmgdjkbpemcciiolgcge",edge_addon_id:"pbpjkcldjiffchgbbndmhojiacbgflha",play_store_id:"com.okinc.okex.gp",app_store_id:"id1327268470"},deep_link:"okex://main/wc",universal_link:"okex://main/wc"},{featured:!0,name:"WalletConnect",image:`${bs}#walletconnect`},{featured:!1,name:"Coinbase Wallet",image:`${bs}#coinbase`},{featured:!1,name:"GateWallet",rdns:"io.gate.wallet",image:`${bs}#6e528abf-7a7d-47bd-d84d-481f169b1200`,getWallet:{chrome_store_id:"cpmkedoipcpimgecpmgpldfpohjplkpp",brave_store_id:"cpmkedoipcpimgecpmgpldfpohjplkpp",play_store_id:"com.gateio.gateio",app_store_id:"id1294998195",mac_app_store_id:"id1609559473"},deep_link:"https://www.gate.io/mobileapp",universal_link:"https://www.gate.io/mobileapp"},{featured:!1,name:"Onekey",rdns:"so.onekey.app.wallet",image:`${bs}#onekey`,getWallet:{chrome_store_id:"jnmbobjmhlngoefaiojfljckilhhlhcj",brave_store_id:"jnmbobjmhlngoefaiojfljckilhhlhcj",play_store_id:"so.onekey.app.wallet",app_store_id:"id1609559473"},deep_link:"onekey-wallet://",universal_link:"onekey://wc"},{featured:!1,name:"Infinity Wallet",image:`${bs}#9f259366-0bcd-4817-0af9-f78773e41900`,desktop_link:"infinity://wc"},{name:"Rabby Wallet",rdns:"io.rabby",featured:!1,image:`${bs}#rabby`,getWallet:{chrome_store_id:"acmacodkjbdgmoleebolmdjonilkdbch",brave_store_id:"acmacodkjbdgmoleebolmdjonilkdbch",play_store_id:"com.debank.rabbymobile",app_store_id:"id6474381673"}},{name:"Rainbow Wallet",rdns:"me.rainbow",featured:!1,image:`${bs}#rainbow`,getWallet:{chrome_store_id:"opfgelmcmbiajamepnmloijbpoleiama",edge_addon_id:"cpojfbodiccabbabgimdeohkkpjfpbnf",firefox_addon_id:"rainbow-extension",app_store_id:"id1457119021",play_store_id:"me.rainbow"}}];function OA(t,e){return t.exec(e)?.groups}const ay=/^tuple(?(\[(\d*)\])*)$/;function V0(t){let e=t.type;if(ay.test(t.type)&&"components"in t){e="(";const r=t.components.length;for(let i=0;ie(t,s)}function nc(t,{includeName:e=!1}={}){if(t.type!=="function"&&t.type!=="event"&&t.type!=="error")throw new KA(t.type);return`${t.name}(${G0(t.inputs,{includeName:e})})`}function G0(t,{includeName:e=!1}={}){return t?t.map(r=>LA(r,{includeName:e})).join(e?", ":","):""}function LA(t,{includeName:e}){return t.type.startsWith("tuple")?`(${G0(t.components,{includeName:e})})${t.type.slice(5)}`:t.type+(e&&t.name?` ${t.name}`:"")}function wo(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function gn(t){return wo(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const cy="2.31.3";let Y0={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:r})=>e?`${t??"https://viem.sh"}${e}${r?`#${r}`:""}`:void 0,version:`viem@${cy}`};class dt extends Error{constructor(e,r={}){const n=r.cause instanceof dt?r.cause.details:r.cause?.message?r.cause.message:r.details,i=r.cause instanceof dt&&r.cause.docsPath||r.docsPath,s=Y0.getDocsUrl?.({...r,docsPath:i}),o=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...n?[`Details: ${n}`]:[],...Y0.version?[`Version: ${Y0.version}`]:[]].join(` +`);super(o,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=e,this.version=cy}walk(e){return uy(this,e)}}function uy(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?uy(t.cause,e):e?null:t}class kA extends dt{constructor({docsPath:e}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join(` +`),{docsPath:e,name:"AbiConstructorNotFoundError"})}}class fy extends dt{constructor({docsPath:e}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join(` +`),{docsPath:e,name:"AbiConstructorParamsNotFoundError"})}}class BA extends dt{constructor({data:e,params:r,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join(` +`),{metaMessages:[`Params: (${G0(r,{includeName:!0})})`,`Data: ${e} (${n} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=r,this.size=n}}class J0 extends dt{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class FA extends dt{constructor({expectedLength:e,givenLength:r,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${e}`,`Given length: ${r}`].join(` +`),{name:"AbiEncodingArrayLengthMismatchError"})}}class jA extends dt{constructor({expectedSize:e,value:r}){super(`Size of bytes "${r}" (bytes${gn(r)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class UA extends dt{constructor({expectedLength:e,givenLength:r}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${r}`].join(` +`),{name:"AbiEncodingLengthMismatchError"})}}class ly extends dt{constructor(e,{docsPath:r}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join(` +`),{docsPath:r,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class hy extends dt{constructor(e,{docsPath:r}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(` +`),{docsPath:r,name:"AbiFunctionNotFoundError"})}}class $A extends dt{constructor(e,r){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${nc(e.abiItem)}\`, and`,`\`${r.type}\` in \`${nc(r.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class qA extends dt{constructor({expectedSize:e,givenSize:r}){super(`Expected bytes${e}, got bytes${r}.`,{name:"BytesSizeMismatchError"})}}class zA extends dt{constructor(e,{docsPath:r}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(` +`),{docsPath:r,name:"InvalidAbiEncodingType"})}}class HA extends dt{constructor(e,{docsPath:r}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(` +`),{docsPath:r,name:"InvalidAbiDecodingType"})}}class WA extends dt{constructor(e){super([`Value "${e}" is not a valid array.`].join(` +`),{name:"InvalidArrayError"})}}class KA extends dt{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(` +`),{name:"InvalidDefinitionTypeError"})}}class dy extends dt{constructor({offset:e,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class py extends dt{constructor({size:e,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}class gy extends dt{constructor({size:e,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${r} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function ic(t,{dir:e,size:r=32}={}){return typeof t=="string"?xo(t,{dir:e,size:r}):VA(t,{dir:e,size:r})}function xo(t,{dir:e,size:r=32}={}){if(r===null)return t;const n=t.replace("0x","");if(n.length>r*2)throw new py({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](r*2,"0")}`}function VA(t,{dir:e,size:r=32}={}){if(r===null)return t;if(t.length>r)throw new py({size:t.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let i=0;ie)throw new YA({givenSize:gn(t),maxSize:e})}function _o(t,e={}){const{signed:r}=e;e.size&&ys(t,{size:e.size});const n=BigInt(t);if(!r)return n;const i=(t.length-2)/2,s=(1n<e.toString(16).padStart(2,"0"));function Dl(t,e={}){return typeof t=="number"||typeof t=="bigint"?pr(t,e):typeof t=="string"?Ol(t,e):typeof t=="boolean"?vy(t,e):ti(t,e)}function vy(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(ys(r,{size:e.size}),ic(r,{size:e.size})):r}function ti(t,e={}){let r="";for(let i=0;is||i=js.zero&&t<=js.nine)return t-js.zero;if(t>=js.A&&t<=js.F)return t-(js.A-10);if(t>=js.a&&t<=js.f)return t-(js.a-10)}function Us(t,e={}){let r=t;e.size&&(ys(r,{size:e.size}),r=ic(r,{dir:"right",size:e.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,s=new Uint8Array(i);for(let o=0,a=0;o>wy&Nl)}:{h:Number(t>>wy&Nl)|0,l:Number(t&Nl)|0}}function rP(t,e=!1){const r=t.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let s=0;st<>>32-r,iP=(t,e,r)=>e<>>32-r,sP=(t,e,r)=>e<>>64-r,oP=(t,e,r)=>t<>>64-r,sc=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Z0(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function mu(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function es(t,...e){if(!Z0(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function aP(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");mu(t.outputLen),mu(t.blockLen)}function oc(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function xy(t,e){es(t);const r=e.outputLen;if(t.length>>e}const uP=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function fP(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function lP(t){for(let e=0;et:lP,Ey=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",hP=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function cc(t){if(es(t),Ey)return t.toHex();let e="";for(let r=0;r=$s._0&&t<=$s._9)return t-$s._0;if(t>=$s.A&&t<=$s.F)return t-($s.A-10);if(t>=$s.a&&t<=$s.f)return t-($s.a-10)}function ep(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Ey)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let i=0,s=0;it().update(Ll(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function pP(t=32){if(sc&&typeof sc.getRandomValues=="function")return sc.getRandomValues(new Uint8Array(t));if(sc&&typeof sc.randomBytes=="function")return Uint8Array.from(sc.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const gP=BigInt(0),vu=BigInt(1),mP=BigInt(2),vP=BigInt(7),bP=BigInt(256),yP=BigInt(113),Py=[],Iy=[],My=[];for(let t=0,e=vu,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],Py.push(2*(5*n+r)),Iy.push((t+1)*(t+2)/2%64);let i=gP;for(let s=0;s<7;s++)e=(e<>vP)*yP)%bP,e&mP&&(i^=vu<<(vu<r>32?sP(t,e,r):nP(t,e,r),Ty=(t,e,r)=>r>32?oP(t,e,r):iP(t,e,r);function _P(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,f=(o+2)%10,u=r[f],h=r[f+1],g=Ry(u,h,1)^r[a],b=Ty(u,h,1)^r[a+1];for(let x=0;x<50;x+=10)t[o+x]^=g,t[o+x+1]^=b}let i=t[2],s=t[3];for(let o=0;o<24;o++){const a=Iy[o],f=Ry(i,s,a),u=Ty(i,s,a),h=Py[o];i=t[h],s=t[h+1],t[h]=f,t[h+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=wP[n],t[1]^=xP[n]}ac(r)}class rp extends tp{constructor(e,r,n,i=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=s,mu(n),!(0=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return mu(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(xy(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ac(this.state)}_cloneInto(e){const{blockLen:r,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new rp(r,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const EP=(t,e,r)=>Ay(()=>new rp(e,t,r)),SP=EP(1,136,256/8);function kl(t,e){const r=e||"hex",n=SP(wo(t,{strict:!1})?X0(t):t);return r==="bytes"?n:Dl(n)}const AP=t=>kl(X0(t));function PP(t){return AP(t)}function IP(t){let e=!0,r="",n=0,i="",s=!1;for(let o=0;o{const e=typeof t=="string"?t:NA(t);return IP(e)};function Dy(t){return PP(MP(t))}const CP=Dy;class So extends dt{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Bl extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const np=new Bl(8192);function bu(t,e){if(np.has(`${t}.${e}`))return np.get(`${t}.${e}`);const r=t.substring(2).toLowerCase(),n=kl(yy(r),"bytes"),i=r.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&i[o]&&(i[o]=i[o].toUpperCase()),(n[o>>1]&15)>=8&&i[o+1]&&(i[o+1]=i[o+1].toUpperCase());const s=`0x${i.join("")}`;return np.set(`${t}.${e}`,s),s}function ip(t,e){if(!ts(t,{strict:!1}))throw new So({address:t});return bu(t,e)}const RP=/^0x[a-fA-F0-9]{40}$/,sp=new Bl(8192);function ts(t,e){const{strict:r=!0}=e??{},n=`${t}.${r}`;if(sp.has(n))return sp.get(n);const i=RP.test(t)?t.toLowerCase()===t?!0:r?bu(t)===t:!0:!1;return sp.set(n,i),i}function Ao(t){return typeof t[0]=="string"?Fl(t):TP(t)}function TP(t){let e=0;for(const i of t)e+=i.length;const r=new Uint8Array(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function Fl(t){return`0x${t.reduce((e,r)=>e+r.replace("0x",""),"")}`}function jl(t,e,r,{strict:n}={}){return wo(t,{strict:!1})?op(t,e,r,{strict:n}):Ly(t,e,r,{strict:n})}function Oy(t,e){if(typeof e=="number"&&e>0&&e>gn(t)-1)throw new dy({offset:e,position:"start",size:gn(t)})}function Ny(t,e,r){if(typeof e=="number"&&typeof r=="number"&&gn(t)!==r-e)throw new dy({offset:r,position:"end",size:gn(t)})}function Ly(t,e,r,{strict:n}={}){Oy(t,e);const i=t.slice(e,r);return n&&Ny(i,e,r),i}function op(t,e,r,{strict:n}={}){Oy(t,e);const i=`0x${t.replace("0x","").slice((e??0)*2,(r??t.length)*2)}`;return n&&Ny(i,e,r),i}const DP=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,ky=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function By(t,e){if(t.length!==e.length)throw new UA({expectedLength:t.length,givenLength:e.length});const r=OP({params:t,values:e}),n=cp(r);return n.length===0?"0x":n}function OP({params:t,values:e}){const r=[];for(let n=0;n0?Ao([a,o]):a}}if(i)return{dynamic:!0,encoded:o}}return{dynamic:!1,encoded:Ao(s.map(({encoded:o})=>o))}}function kP(t,{param:e}){const[,r]=e.type.split("bytes"),n=gn(t);if(!r){let i=t;return n%32!==0&&(i=xo(i,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:Ao([xo(pr(n,{size:32})),i])}}if(n!==Number.parseInt(r))throw new jA({expectedSize:Number.parseInt(r),value:t});return{dynamic:!1,encoded:xo(t,{dir:"right"})}}function BP(t){if(typeof t!="boolean")throw new dt(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:xo(vy(t))}}function FP(t,{signed:e,size:r=256}){if(typeof r=="number"){const n=2n**(BigInt(r)-(e?1n:0n))-1n,i=e?-n-1n:0n;if(t>n||ti))}}function up(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}const fp=t=>jl(Dy(t),0,4);function Fy(t){const{abi:e,args:r=[],name:n}=t,i=wo(n,{strict:!1}),s=e.filter(a=>i?a.type==="function"?fp(a)===n:a.type==="event"?CP(a)===n:!1:"name"in a&&a.name===n);if(s.length===0)return;if(s.length===1)return s[0];let o;for(const a of s){if(!("inputs"in a))continue;if(!r||r.length===0){if(!a.inputs||a.inputs.length===0)return a;continue}if(!a.inputs||a.inputs.length===0||a.inputs.length!==r.length)continue;if(r.every((u,h)=>{const g="inputs"in a&&a.inputs[h];return g?lp(u,g):!1})){if(o&&"inputs"in o&&o.inputs){const u=jy(a.inputs,o.inputs,r);if(u)throw new $A({abiItem:a,type:u[0]},{abiItem:o,type:u[1]})}o=a}}return o||s[0]}function lp(t,e){const r=typeof t,n=e.type;switch(n){case"address":return ts(t,{strict:!1});case"bool":return r==="boolean";case"function":return r==="string";case"string":return r==="string";default:return n==="tuple"&&"components"in e?Object.values(e.components).every((i,s)=>lp(Object.values(t)[s],i)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(n)?r==="number"||r==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(n)?r==="string"||t instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(n)?Array.isArray(t)&&t.every(i=>lp(i,{...e,type:n.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function jy(t,e,r){for(const n in t){const i=t[n],s=e[n];if(i.type==="tuple"&&s.type==="tuple"&&"components"in i&&"components"in s)return jy(i.components,s.components,r[n]);const o=[i.type,s.type];if(o.includes("address")&&o.includes("bytes20")?!0:o.includes("address")&&o.includes("string")?ts(r[n],{strict:!1}):o.includes("address")&&o.includes("bytes")?ts(r[n],{strict:!1}):!1)return o}}function ri(t){return typeof t=="string"?{address:t,type:"json-rpc"}:t}const Uy="/docs/contract/encodeFunctionData";function $P(t){const{abi:e,args:r,functionName:n}=t;let i=e[0];if(n){const s=Fy({abi:e,args:r,name:n});if(!s)throw new hy(n,{docsPath:Uy});i=s}if(i.type!=="function")throw new hy(void 0,{docsPath:Uy});return{abi:[i],functionName:fp(nc(i))}}function $y(t){const{args:e}=t,{abi:r,functionName:n}=t.abi.length===1&&t.functionName?.startsWith("0x")?t:$P(t),i=r[0],s=n,o="inputs"in i&&i.inputs?By(i.inputs,e??[]):void 0;return Fl([s,o??"0x"])}const qP={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},zP={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},HP={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};class qy extends dt{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class WP extends dt{constructor({length:e,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class KP extends dt{constructor({count:e,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const VP={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new KP({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new WP({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new qy({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new qy({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const r=e??this.position;return this.assertPosition(r+t-1),this.bytes.subarray(r,r+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const r=this.inspectBytes(t);return this.position+=e??t,r},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function hp(t,{recursiveReadLimit:e=8192}={}){const r=Object.create(VP);return r.bytes=t,r.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=e,r}function GP(t,e={}){typeof e.size<"u"&&ys(t,{size:e.size});const r=ti(t,e);return _o(r,e)}function YP(t,e={}){let r=t;if(typeof e.size<"u"&&(ys(r,{size:e.size}),r=Tl(r)),r.length>1||r[0]>1)throw new GA(r);return!!r[0]}function qs(t,e={}){typeof e.size<"u"&&ys(t,{size:e.size});const r=ti(t,e);return Eo(r,e)}function JP(t,e={}){let r=t;return typeof e.size<"u"&&(ys(r,{size:e.size}),r=Tl(r,{dir:"right"})),new TextDecoder().decode(r)}function XP(t,e){const r=typeof e=="string"?Us(e):e,n=hp(r);if(gn(r)===0&&t.length>0)throw new J0;if(gn(e)&&gn(e)<32)throw new BA({data:typeof e=="string"?e:ti(e),params:t,size:gn(e)});let i=0;const s=[];for(let o=0;o48?GP(i,{signed:r}):qs(i,{signed:r}),32]}function nI(t,e,{staticPosition:r}){const n=e.components.length===0||e.components.some(({name:o})=>!o),i=n?[]:{};let s=0;if(yu(e)){const o=qs(t.readBytes(dp)),a=r+o;for(let f=0;fo.type==="error"&&n===fp(nc(o)));if(!s)throw new ly(n,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:s,args:"inputs"in s&&s.inputs&&s.inputs.length>0?XP(s.inputs,jl(r,4)):void 0,errorName:s.name}}const sa=(t,e,r)=>JSON.stringify(t,(n,i)=>typeof i=="bigint"?i.toString():i,r);function Hy({abiItem:t,args:e,includeFunctionName:r=!0,includeName:n=!1}){if("name"in t&&"inputs"in t&&t.inputs)return`${r?t.name:""}(${t.inputs.map((i,s)=>`${n&&i.name?`${i.name}: `:""}${typeof e[s]=="object"?sa(e[s]):e[s]}`).join(", ")})`}const oI={gwei:9,wei:18},aI={ether:-9,wei:9};function Wy(t,e){let r=t.toString();const n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(e,"0");let[i,s]=[r.slice(0,r.length-e),r.slice(r.length-e)];return s=s.replace(/(0+)$/,""),`${n?"-":""}${i||"0"}${s?`.${s}`:""}`}function Ky(t,e="wei"){return Wy(t,oI[e])}function rs(t,e="wei"){return Wy(t,aI[e])}class cI extends dt{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class uI extends dt{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Ul(t){const e=Object.entries(t).map(([n,i])=>i===void 0||i===!1?null:[n,i]).filter(Boolean),r=e.reduce((n,[i])=>Math.max(n,i.length),0);return e.map(([n,i])=>` ${`${n}:`.padEnd(r+1)} ${i}`).join(` +`)}class fI extends dt{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join(` +`),{name:"FeeConflictError"})}}class lI extends dt{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Ul(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class hI extends dt{constructor(e,{account:r,docsPath:n,chain:i,data:s,gas:o,gasPrice:a,maxFeePerGas:f,maxPriorityFeePerGas:u,nonce:h,to:g,value:b}){const x=Ul({chain:i&&`${i?.name} (id: ${i?.id})`,from:r?.address,to:g,value:typeof b<"u"&&`${Ky(b)} ${i?.nativeCurrency?.symbol||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${rs(a)} gwei`,maxFeePerGas:typeof f<"u"&&`${rs(f)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${rs(u)} gwei`,nonce:h});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",x].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}const dI=t=>t,Vy=t=>t;class pI extends dt{constructor(e,{abi:r,args:n,contractAddress:i,docsPath:s,functionName:o,sender:a}){const f=Fy({abi:r,args:n,name:o}),u=f?Hy({abiItem:f,args:n,includeFunctionName:!1,includeName:!1}):void 0,h=f?nc(f,{includeName:!0}):void 0,g=Ul({address:i&&dI(i),function:h,args:u&&u!=="()"&&`${[...Array(o?.length??0).keys()].map(()=>" ").join("")}${u}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${o}".`,{cause:e,docsPath:s,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],g&&"Contract Call:",g].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=r,this.args=n,this.cause=e,this.contractAddress=i,this.functionName=o,this.sender=a}}class gI extends dt{constructor({abi:e,data:r,functionName:n,message:i}){let s,o,a,f;if(r&&r!=="0x")try{o=sI({abi:e,data:r});const{abiItem:h,errorName:g,args:b}=o;if(g==="Error")f=b[0];else if(g==="Panic"){const[x]=b;f=qP[x]}else{const x=h?nc(h,{includeName:!0}):void 0,S=h&&b?Hy({abiItem:h,args:b,includeFunctionName:!1,includeName:!1}):void 0;a=[x?`Error: ${x}`:"",S&&S!=="()"?` ${[...Array(g?.length??0).keys()].map(()=>" ").join("")}${S}`:""]}}catch(h){s=h}else i&&(f=i);let u;s instanceof ly&&(u=s.signature,a=[`Unable to decode signature "${u}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${u}.`]),super(f&&f!=="execution reverted"||u?[`The contract function "${n}" reverted with the following ${u?"signature":"reason"}:`,f||u].join(` +`):`The contract function "${n}" reverted.`,{cause:s,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o,this.raw=r,this.reason=f,this.signature=u}}class mI extends dt{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class vI extends dt{constructor({data:e,message:r}){super(r||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e}}class Gy extends dt{constructor({body:e,cause:r,details:n,headers:i,status:s,url:o}){super("HTTP request failed.",{cause:r,details:n,metaMessages:[s&&`Status: ${s}`,`URL: ${Vy(o)}`,e&&`Request body: ${sa(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=i,this.status=s,this.url=o}}class Yy extends dt{constructor({body:e,error:r,url:n}){super("RPC Request failed.",{cause:r,details:r.message,metaMessages:[`URL: ${Vy(n)}`,`Request body: ${sa(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=r.code,this.data=r.data}}const bI=-1;class ni extends dt{constructor(e,{code:r,docsPath:n,metaMessages:i,name:s,shortMessage:o}){super(o,{cause:e,docsPath:n,metaMessages:i||e?.metaMessages,name:s||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=s||e.name,this.code=e instanceof Yy?e.code:r??bI}}class gi extends ni{constructor(e,r){super(e,r),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=r.data}}class wu extends ni{constructor(e){super(e,{code:wu.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(wu,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class xu extends ni{constructor(e){super(e,{code:xu.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(xu,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class _u extends ni{constructor(e,{method:r}={}){super(e,{code:_u.code,name:"MethodNotFoundRpcError",shortMessage:`The method${r?` "${r}"`:""} does not exist / is not available.`})}}Object.defineProperty(_u,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Eu extends ni{constructor(e){super(e,{code:Eu.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(` +`)})}}Object.defineProperty(Eu,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class oa extends ni{constructor(e){super(e,{code:oa.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(oa,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Su extends ni{constructor(e){super(e,{code:Su.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(` +`)})}}Object.defineProperty(Su,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class Au extends ni{constructor(e){super(e,{code:Au.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(Au,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class Pu extends ni{constructor(e){super(e,{code:Pu.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(Pu,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class Iu extends ni{constructor(e){super(e,{code:Iu.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(Iu,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class aa extends ni{constructor(e,{method:r}={}){super(e,{code:aa.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${r?` "${r}"`:""} is not supported.`})}}Object.defineProperty(aa,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class fc extends ni{constructor(e){super(e,{code:fc.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(fc,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Mu extends ni{constructor(e){super(e,{code:Mu.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(Mu,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class lc extends gi{constructor(e){super(e,{code:lc.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(lc,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Cu extends gi{constructor(e){super(e,{code:Cu.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(Cu,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Ru extends gi{constructor(e,{method:r}={}){super(e,{code:Ru.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${r?` " ${r}"`:""}.`})}}Object.defineProperty(Ru,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class Tu extends gi{constructor(e){super(e,{code:Tu.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(Tu,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Du extends gi{constructor(e){super(e,{code:Du.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(Du,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Ou extends gi{constructor(e){super(e,{code:Ou.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Ou,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class hc extends gi{constructor(e){super(e,{code:hc.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(hc,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Nu extends gi{constructor(e){super(e,{code:Nu.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Nu,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class Lu extends gi{constructor(e){super(e,{code:Lu.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(Lu,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class ku extends gi{constructor(e){super(e,{code:ku.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(ku,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Bu extends gi{constructor(e){super(e,{code:Bu.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Bu,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Fu extends gi{constructor(e){super(e,{code:Fu.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Fu,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class dc extends gi{constructor(e){super(e,{code:dc.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(dc,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class yI extends ni{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const wI=3;function xI(t,{abi:e,address:r,args:n,docsPath:i,functionName:s,sender:o}){const a=t instanceof vI?t:t instanceof dt?t.walk(S=>"data"in S)||t.walk():{},{code:f,data:u,details:h,message:g,shortMessage:b}=a,x=t instanceof J0?new mI({functionName:s}):[wI,oa.code].includes(f)&&(u||h||g||b)?new gI({abi:e,data:typeof u=="object"?u.data:u,functionName:s,message:a instanceof Yy?h:b??g}):t;return new pI(x,{abi:e,args:n,contractAddress:r,docsPath:i,functionName:s,sender:o})}function _I(t){const e=kl(`0x${t.substring(4)}`).substring(26);return bu(`0x${e}`)}async function EI({hash:t,signature:e}){const r=wo(t)?t:Dl(t),{secp256k1:n}=await Promise.resolve().then(()=>dC);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:u,s:h,v:g,yParity:b}=e,x=Number(b??g),S=Jy(x);return new n.Signature(_o(u),_o(h)).addRecoveryBit(S)}const o=wo(e)?e:Dl(e);if(gn(o)!==65)throw new Error("invalid signature length");const a=Eo(`0x${o.slice(130)}`),f=Jy(a);return n.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(f)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function Jy(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function SI({hash:t,signature:e}){return _I(await EI({hash:t,signature:e}))}function AI(t,e="hex"){const r=Xy(t),n=hp(new Uint8Array(r.length));return r.encode(n),e==="hex"?ti(n.bytes):n.bytes}function Xy(t){return Array.isArray(t)?PI(t.map(e=>Xy(e))):II(t)}function PI(t){const e=t.reduce((i,s)=>i+s.length,0),r=Zy(e);return{length:e<=55?1+e:1+r+e,encode(i){e<=55?i.pushByte(192+e):(i.pushByte(247+r),r===1?i.pushUint8(e):r===2?i.pushUint16(e):r===3?i.pushUint24(e):i.pushUint32(e));for(const{encode:s}of t)s(i)}}}function II(t){const e=typeof t=="string"?Us(t):t,r=Zy(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+r+e.length,encode(i){e.length===1&&e[0]<128?i.pushBytes(e):e.length<=55?(i.pushByte(128+e.length),i.pushBytes(e)):(i.pushByte(183+r),r===1?i.pushUint8(e.length):r===2?i.pushUint16(e.length):r===3?i.pushUint24(e.length):i.pushUint32(e.length),i.pushBytes(e))}}}function Zy(t){if(t<2**8)return 1;if(t<2**16)return 2;if(t<2**24)return 3;if(t<2**32)return 4;throw new dt("Length is too large.")}function MI(t){const{chainId:e,nonce:r,to:n}=t,i=t.contractAddress??t.address,s=kl(Fl(["0x05",AI([e?pr(e):"0x",i,r?pr(r):"0x"])]));return n==="bytes"?Us(s):s}async function Qy(t){const{authorization:e,signature:r}=t;return SI({hash:MI(e),signature:r??e})}class CI extends dt{constructor(e,{account:r,docsPath:n,chain:i,data:s,gas:o,gasPrice:a,maxFeePerGas:f,maxPriorityFeePerGas:u,nonce:h,to:g,value:b}){const x=Ul({from:r?.address,to:g,value:typeof b<"u"&&`${Ky(b)} ${i?.nativeCurrency?.symbol||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${rs(a)} gwei`,maxFeePerGas:typeof f<"u"&&`${rs(f)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${rs(u)} gwei`,nonce:h});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",x].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class pc extends dt{constructor({cause:e,message:r}={}){const n=r?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(pc,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(pc,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class $l extends dt{constructor({cause:e,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${rs(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty($l,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class pp extends dt{constructor({cause:e,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${rs(r)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(pp,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class gp extends dt{constructor({cause:e,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(gp,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class mp extends dt{constructor({cause:e,nonce:r}={}){super([`Nonce provided for the transaction ${r?`(${r}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(` +`),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(mp,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class vp extends dt{constructor({cause:e,nonce:r}={}){super(`Nonce provided for the transaction ${r?`(${r}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(vp,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class bp extends dt{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(` +`),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(bp,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class yp extends dt{constructor({cause:e,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(yp,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class wp extends dt{constructor({cause:e,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(wp,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class xp extends dt{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(xp,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class ql extends dt{constructor({cause:e,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${rs(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${rs(n)} gwei`:""}).`].join(` +`),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(ql,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class _p extends dt{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function ew(t,e){const r=(t.details||"").toLowerCase(),n=t instanceof dt?t.walk(i=>i?.code===pc.code):t;return n instanceof dt?new pc({cause:t,message:n.details}):pc.nodeMessage.test(r)?new pc({cause:t,message:t.details}):$l.nodeMessage.test(r)?new $l({cause:t,maxFeePerGas:e?.maxFeePerGas}):pp.nodeMessage.test(r)?new pp({cause:t,maxFeePerGas:e?.maxFeePerGas}):gp.nodeMessage.test(r)?new gp({cause:t,nonce:e?.nonce}):mp.nodeMessage.test(r)?new mp({cause:t,nonce:e?.nonce}):vp.nodeMessage.test(r)?new vp({cause:t,nonce:e?.nonce}):bp.nodeMessage.test(r)?new bp({cause:t}):yp.nodeMessage.test(r)?new yp({cause:t,gas:e?.gas}):wp.nodeMessage.test(r)?new wp({cause:t,gas:e?.gas}):xp.nodeMessage.test(r)?new xp({cause:t}):ql.nodeMessage.test(r)?new ql({cause:t,maxFeePerGas:e?.maxFeePerGas,maxPriorityFeePerGas:e?.maxPriorityFeePerGas}):new _p({cause:t})}function RI(t,{docsPath:e,...r}){const n=(()=>{const i=ew(t,r);return i instanceof _p?t:i})();return new CI(n,{docsPath:e,...r})}function tw(t,{format:e}){if(!e)return{};const r={};function n(s){const o=Object.keys(s);for(const a of o)a in t&&(r[a]=t[a]),s[a]&&typeof s[a]=="object"&&!Array.isArray(s[a])&&n(s[a])}const i=e(t||{});return n(i),r}const TI={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Ep(t){const e={};return typeof t.authorizationList<"u"&&(e.authorizationList=DI(t.authorizationList)),typeof t.accessList<"u"&&(e.accessList=t.accessList),typeof t.blobVersionedHashes<"u"&&(e.blobVersionedHashes=t.blobVersionedHashes),typeof t.blobs<"u"&&(typeof t.blobs[0]!="string"?e.blobs=t.blobs.map(r=>ti(r)):e.blobs=t.blobs),typeof t.data<"u"&&(e.data=t.data),typeof t.from<"u"&&(e.from=t.from),typeof t.gas<"u"&&(e.gas=pr(t.gas)),typeof t.gasPrice<"u"&&(e.gasPrice=pr(t.gasPrice)),typeof t.maxFeePerBlobGas<"u"&&(e.maxFeePerBlobGas=pr(t.maxFeePerBlobGas)),typeof t.maxFeePerGas<"u"&&(e.maxFeePerGas=pr(t.maxFeePerGas)),typeof t.maxPriorityFeePerGas<"u"&&(e.maxPriorityFeePerGas=pr(t.maxPriorityFeePerGas)),typeof t.nonce<"u"&&(e.nonce=pr(t.nonce)),typeof t.to<"u"&&(e.to=t.to),typeof t.type<"u"&&(e.type=TI[t.type]),typeof t.value<"u"&&(e.value=pr(t.value)),e}function DI(t){return t.map(e=>({address:e.address,r:e.r?pr(BigInt(e.r)):e.r,s:e.s?pr(BigInt(e.s)):e.s,chainId:pr(e.chainId),nonce:pr(e.nonce),...typeof e.yParity<"u"?{yParity:pr(e.yParity)}:{},...typeof e.v<"u"&&typeof e.yParity>"u"?{v:pr(e.v)}:{}}))}function rw(t){if(!(!t||t.length===0))return t.reduce((e,{slot:r,value:n})=>{if(r.length!==66)throw new gy({size:r.length,targetSize:66,type:"hex"});if(n.length!==66)throw new gy({size:n.length,targetSize:66,type:"hex"});return e[r]=n,e},{})}function OI(t){const{balance:e,nonce:r,state:n,stateDiff:i,code:s}=t,o={};if(s!==void 0&&(o.code=s),e!==void 0&&(o.balance=pr(e)),r!==void 0&&(o.nonce=pr(r)),n!==void 0&&(o.state=rw(n)),i!==void 0){if(o.state)throw new uI;o.stateDiff=rw(i)}return o}function NI(t){if(!t)return;const e={};for(const{address:r,...n}of t){if(!ts(r,{strict:!1}))throw new So({address:r});if(e[r])throw new cI({address:r});e[r]=OI(n)}return e}const LI=2n**256n-1n;function zl(t){const{account:e,gasPrice:r,maxFeePerGas:n,maxPriorityFeePerGas:i,to:s}=t,o=e?ri(e):void 0;if(o&&!ts(o.address))throw new So({address:o.address});if(s&&!ts(s))throw new So({address:s});if(typeof r<"u"&&(typeof n<"u"||typeof i<"u"))throw new fI;if(n&&n>LI)throw new $l({maxFeePerGas:n});if(i&&n&&i>n)throw new ql({maxFeePerGas:n,maxPriorityFeePerGas:i})}class kI extends dt{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Sp extends dt{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class BI extends dt{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${rs(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class FI extends dt{constructor({blockHash:e,blockNumber:r}){let n="Block";e&&(n=`Block at hash "${e}"`),r&&(n=`Block at number "${r}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}}const jI={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function UI(t){const e={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,chainId:t.chainId?Eo(t.chainId):void 0,gas:t.gas?BigInt(t.gas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,maxFeePerBlobGas:t.maxFeePerBlobGas?BigInt(t.maxFeePerBlobGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,nonce:t.nonce?Eo(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?jI[t.type]:void 0,typeHex:t.type?t.type:void 0,value:t.value?BigInt(t.value):void 0,v:t.v?BigInt(t.v):void 0};return t.authorizationList&&(e.authorizationList=$I(t.authorizationList)),e.yParity=(()=>{if(t.yParity)return Number(t.yParity);if(typeof e.v=="bigint"){if(e.v===0n||e.v===27n)return 0;if(e.v===1n||e.v===28n)return 1;if(e.v>=35n)return e.v%2n===0n?1:0}})(),e.type==="legacy"&&(delete e.accessList,delete e.maxFeePerBlobGas,delete e.maxFeePerGas,delete e.maxPriorityFeePerGas,delete e.yParity),e.type==="eip2930"&&(delete e.maxFeePerBlobGas,delete e.maxFeePerGas,delete e.maxPriorityFeePerGas),e.type==="eip1559"&&delete e.maxFeePerBlobGas,e}function $I(t){return t.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))}function qI(t){const e=(t.transactions??[]).map(r=>typeof r=="string"?r:UI(r));return{...t,baseFeePerGas:t.baseFeePerGas?BigInt(t.baseFeePerGas):null,blobGasUsed:t.blobGasUsed?BigInt(t.blobGasUsed):void 0,difficulty:t.difficulty?BigInt(t.difficulty):void 0,excessBlobGas:t.excessBlobGas?BigInt(t.excessBlobGas):void 0,gasLimit:t.gasLimit?BigInt(t.gasLimit):void 0,gasUsed:t.gasUsed?BigInt(t.gasUsed):void 0,hash:t.hash?t.hash:null,logsBloom:t.logsBloom?t.logsBloom:null,nonce:t.nonce?t.nonce:null,number:t.number?BigInt(t.number):null,size:t.size?BigInt(t.size):void 0,timestamp:t.timestamp?BigInt(t.timestamp):void 0,transactions:e,totalDifficulty:t.totalDifficulty?BigInt(t.totalDifficulty):null}}async function Hl(t,{blockHash:e,blockNumber:r,blockTag:n,includeTransactions:i}={}){const s=n??"latest",o=i??!1,a=r!==void 0?pr(r):void 0;let f=null;if(e?f=await t.request({method:"eth_getBlockByHash",params:[e,o]},{dedupe:!0}):f=await t.request({method:"eth_getBlockByNumber",params:[a||s,o]},{dedupe:!!a}),!f)throw new FI({blockHash:e,blockNumber:r});return(t.chain?.formatters?.block?.format||qI)(f)}async function nw(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function zI(t,e){const{block:r,chain:n=t.chain,request:i}=e||{};try{const s=n?.fees?.maxPriorityFeePerGas??n?.fees?.defaultPriorityFee;if(typeof s=="function"){const a=r||await Fn(t,Hl,"getBlock")({}),f=await s({block:a,client:t,request:i});if(f===null)throw new Error;return f}if(typeof s<"u")return s;const o=await t.request({method:"eth_maxPriorityFeePerGas"});return _o(o)}catch{const[s,o]=await Promise.all([r?Promise.resolve(r):Fn(t,Hl,"getBlock")({}),Fn(t,nw,"getGasPrice")({})]);if(typeof s.baseFeePerGas!="bigint")throw new Sp;const a=o-s.baseFeePerGas;return a<0n?0n:a}}async function iw(t,e){const{block:r,chain:n=t.chain,request:i,type:s="eip1559"}=e||{},o=await(async()=>typeof n?.fees?.baseFeeMultiplier=="function"?n.fees.baseFeeMultiplier({block:r,client:t,request:i}):n?.fees?.baseFeeMultiplier??1.2)();if(o<1)throw new kI;const f=10**(o.toString().split(".")[1]?.length??0),u=b=>b*BigInt(Math.ceil(o*f))/BigInt(f),h=r||await Fn(t,Hl,"getBlock")({});if(typeof n?.fees?.estimateFeesPerGas=="function"){const b=await n.fees.estimateFeesPerGas({block:r,client:t,multiply:u,request:i,type:s});if(b!==null)return b}if(s==="eip1559"){if(typeof h.baseFeePerGas!="bigint")throw new Sp;const b=typeof i?.maxPriorityFeePerGas=="bigint"?i.maxPriorityFeePerGas:await zI(t,{block:h,chain:n,request:i}),x=u(h.baseFeePerGas);return{maxFeePerGas:i?.maxFeePerGas??x+b,maxPriorityFeePerGas:b}}return{gasPrice:i?.gasPrice??u(await Fn(t,nw,"getGasPrice")({}))}}async function sw(t,{address:e,blockTag:r="latest",blockNumber:n}){const i=await t.request({method:"eth_getTransactionCount",params:[e,typeof n=="bigint"?pr(n):r]},{dedupe:!!n});return Eo(i)}function ow(t){const{kzg:e}=t,r=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),n=typeof t.blobs[0]=="string"?t.blobs.map(s=>Us(s)):t.blobs,i=[];for(const s of n)i.push(Uint8Array.from(e.blobToKzgCommitment(s)));return r==="bytes"?i:i.map(s=>ti(s))}function aw(t){const{kzg:e}=t,r=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),n=typeof t.blobs[0]=="string"?t.blobs.map(o=>Us(o)):t.blobs,i=typeof t.commitments[0]=="string"?t.commitments.map(o=>Us(o)):t.commitments,s=[];for(let o=0;oti(o))}function HI(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),f=n?4:0,u=n?0:4;t.setUint32(e+f,o,n),t.setUint32(e+u,a,n)}function WI(t,e,r){return t&e^~t&r}function KI(t,e,r){return t&e^t&r^e&r}class VI extends tp{constructor(e,r,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Q0(this.buffer)}update(e){oc(this),e=Ll(e),es(e);const{view:r,buffer:n,blockLen:i}=this,s=e.length;for(let o=0;oi-o&&(this.process(n,0),o=0);for(let g=o;gh.length)throw new Error("_sha2: outputLen bigger than state");for(let g=0;g>>3,C=ws(x,17)^ws(x,19)^x>>>10;Io[g]=C+Io[g-7]+S+Io[g-16]|0}let{A:n,B:i,C:s,D:o,E:a,F:f,G:u,H:h}=this;for(let g=0;g<64;g++){const b=ws(a,6)^ws(a,11)^ws(a,25),x=h+b+WI(a,f,u)+GI[g]+Io[g]|0,C=(ws(n,2)^ws(n,13)^ws(n,22))+KI(n,i,s)|0;h=u,u=f,f=a,a=o+x|0,o=s,s=i,i=n,n=x+C|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,f=f+this.F|0,u=u+this.G|0,h=h+this.H|0,this.set(n,i,s,o,a,f,u,h)}roundClean(){ac(Io)}destroy(){this.set(0,0,0,0,0,0,0,0),ac(this.buffer)}}const cw=Ay(()=>new YI),uw=cw;function JI(t,e){return uw(wo(t,{strict:!1})?X0(t):t)}function XI(t){const{commitment:e,version:r=1}=t,n=t.to??(typeof e=="string"?"hex":"bytes"),i=JI(e);return i.set([r],0),n==="bytes"?i:ti(i)}function ZI(t){const{commitments:e,version:r}=t,n=t.to,i=[];for(const s of e)i.push(XI({commitment:s,to:n,version:r}));return i}const fw=6,lw=32,Ap=4096,hw=lw*Ap,dw=hw*fw-1-1*Ap*fw;class QI extends dt{constructor({maxSize:e,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class eM extends dt{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function tM(t){const e=typeof t.data=="string"?Us(t.data):t.data,r=gn(e);if(!r)throw new eM;if(r>dw)throw new QI({maxSize:dw,size:r});const n=[];let i=!0,s=0;for(;i;){const o=hp(new Uint8Array(hw));let a=0;for(;ati(o.bytes))}function rM(t){const{data:e,kzg:r,to:n}=t,i=t.blobs??tM({data:e}),s=t.commitments??ow({blobs:i,kzg:r,to:n}),o=t.proofs??aw({blobs:i,commitments:s,kzg:r,to:n}),a=[];for(let f=0;f"u"&&g)if(f){const B=await D();b.nonce=await f.consume({address:g.address,chainId:B,client:t})}else b.nonce=await Fn(t,sw,"getTransactionCount")({address:g.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&n&&o){const B=ow({blobs:n,kzg:o});if(u.includes("blobVersionedHashes")){const L=ZI({commitments:B,to:"hex"});b.blobVersionedHashes=L}if(u.includes("sidecars")){const L=aw({blobs:n,commitments:B,kzg:o}),H=rM({blobs:n,commitments:B,proofs:L,to:"hex"});b.sidecars=H}}if(u.includes("chainId")&&(b.chainId=await D()),(u.includes("fees")||u.includes("type"))&&typeof h>"u")try{b.type=nM(b)}catch{let B=gw.get(t.uid);typeof B>"u"&&(B=typeof(await S())?.baseFeePerGas=="bigint",gw.set(t.uid,B)),b.type=B?"eip1559":"legacy"}if(u.includes("fees"))if(b.type!=="legacy"&&b.type!=="eip2930"){if(typeof b.maxFeePerGas>"u"||typeof b.maxPriorityFeePerGas>"u"){const B=await S(),{maxFeePerGas:L,maxPriorityFeePerGas:H}=await iw(t,{block:B,chain:i,request:b});if(typeof e.maxPriorityFeePerGas>"u"&&e.maxFeePerGas&&e.maxFeePerGas"u"){const B=await S(),{gasPrice:L}=await iw(t,{block:B,chain:i,request:b,type:"legacy"});b.gasPrice=L}}return u.includes("gas")&&typeof s>"u"&&(b.gas=await Fn(t,sM,"estimateGas")({...b,account:g&&{address:g.address,type:"json-rpc"}})),zl(b),delete b.parameters,b}async function iM(t,{address:e,blockNumber:r,blockTag:n="latest"}){const i=typeof r=="bigint"?pr(r):void 0,s=await t.request({method:"eth_getBalance",params:[e,i||n]});return BigInt(s)}async function sM(t,e){const{account:r=t.account}=e,n=r?ri(r):void 0;try{let q=function(v){const{block:l,request:p,rpcStateOverride:m}=v;return t.request({method:"eth_estimateGas",params:m?[p,l??"latest",m]:l?[p,l]:[p]})};const{accessList:i,authorizationList:s,blobs:o,blobVersionedHashes:a,blockNumber:f,blockTag:u,data:h,gas:g,gasPrice:b,maxFeePerBlobGas:x,maxFeePerGas:S,maxPriorityFeePerGas:C,nonce:D,value:B,stateOverride:L,...H}=await Pp(t,{...e,parameters:n?.type==="local"?void 0:["blobVersionedHashes"]}),k=(typeof f=="bigint"?pr(f):void 0)||u,$=NI(L),R=await(async()=>{if(H.to)return H.to;if(s&&s.length>0)return await Qy({authorization:s[0]}).catch(()=>{throw new dt("`to` is required. Could not infer from `authorizationList`")})})();zl(e);const W=t.chain?.formatters?.transactionRequest?.format,X=(W||Ep)({...tw(H,{format:W}),from:n?.address,accessList:i,authorizationList:s,blobs:o,blobVersionedHashes:a,data:h,gas:g,gasPrice:b,maxFeePerBlobGas:x,maxFeePerGas:S,maxPriorityFeePerGas:C,nonce:D,to:R,value:B});let _=BigInt(await q({block:k,request:X,rpcStateOverride:$}));if(s){const v=await iM(t,{address:X.from}),l=await Promise.all(s.map(async p=>{const{address:m}=p,y=await q({block:k,request:{authorizationList:void 0,data:h,from:n?.address,to:m,value:pr(v)},rpcStateOverride:$}).catch(()=>100000n);return 2n*BigInt(y)}));_+=l.reduce((p,m)=>p+m,0n)}return _}catch(i){throw RI(i,{...e,account:n,chain:t.chain})}}function oM(t,e){if(!ts(t,{strict:!1}))throw new So({address:t});if(!ts(e,{strict:!1}))throw new So({address:e});return t.toLowerCase()===e.toLowerCase()}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ip=BigInt(0),Mp=BigInt(1);function Wl(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function Kl(t){const e=t.toString(16);return e.length&1?"0"+e:e}function mw(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Ip:BigInt("0x"+t)}function Vl(t){return mw(cc(t))}function vw(t){return es(t),mw(cc(Uint8Array.from(t).reverse()))}function Cp(t,e){return ep(t.toString(16).padStart(e*2,"0"))}function bw(t,e){return Cp(t,e).reverse()}function Ci(t,e,r){let n;if(typeof e=="string")try{n=ep(e)}catch(s){throw new Error(t+" must be hex string or Uint8Array, cause: "+s)}else if(Z0(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=n.length;if(typeof r=="number"&&i!==r)throw new Error(t+" of length "+r+" expected, got "+i);return n}const Rp=t=>typeof t=="bigint"&&Ip<=t;function aM(t,e,r){return Rp(t)&&Rp(e)&&Rp(r)&&e<=t&&tIp;t>>=Mp,e+=1);return e}const Gl=t=>(Mp<new Uint8Array(x),i=x=>Uint8Array.of(x);let s=n(t),o=n(t),a=0;const f=()=>{s.fill(1),o.fill(0),a=0},u=(...x)=>r(o,s,...x),h=(x=n(0))=>{o=u(i(0),x),s=u(),x.length!==0&&(o=u(i(1),x),s=u())},g=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let x=0;const S=[];for(;x{f(),h(x);let C;for(;!(C=S(g()));)h();return f(),C}}function Tp(t,e,r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(i,s,o){const a=t[i];if(o&&a===void 0)return;const f=typeof a;if(f!==s||a===null)throw new Error(`param "${i}" is invalid: expected ${s}, got ${f}`)}Object.entries(e).forEach(([i,s])=>n(i,s,!1)),Object.entries(r).forEach(([i,s])=>n(i,s,!0))}function yw(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(i!==void 0)return i;const s=t(r,...n);return e.set(r,s),s}}class lM extends dt{constructor({chain:e,currentChainId:r}){super(`The current chain of the wallet (id: ${r}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`,{metaMessages:[`Current Chain ID: ${r}`,`Expected Chain ID: ${e.id} – ${e.name}`],name:"ChainMismatchError"})}}class hM extends dt{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(` +`),{name:"ChainNotFoundError"})}}const Dp="/docs/contract/encodeDeployData";function dM(t){const{abi:e,args:r,bytecode:n}=t;if(!r||r.length===0)return n;const i=e.find(o=>"type"in o&&o.type==="constructor");if(!i)throw new kA({docsPath:Dp});if(!("inputs"in i))throw new fy({docsPath:Dp});if(!i.inputs||i.inputs.length===0)throw new fy({docsPath:Dp});const s=By(i.inputs,r);return Fl([n,s])}function pM(){let t=()=>{},e=()=>{};return{promise:new Promise((n,i)=>{t=n,e=i}),resolve:t,reject:e}}const Op=new Map,ww=new Map;let gM=0;function mM(t,e,r){const n=++gM,i=()=>Op.get(t)||[],s=()=>{const h=i();Op.set(t,h.filter(g=>g.id!==n))},o=()=>{const h=i();if(!h.some(b=>b.id===n))return;const g=ww.get(t);if(h.length===1&&g){const b=g();b instanceof Promise&&b.catch(()=>{})}s()},a=i();if(Op.set(t,[...a,{id:n,fns:e}]),a&&a.length>0)return o;const f={};for(const h in e)f[h]=((...g)=>{const b=i();if(b.length!==0)for(const x of b)x.fns[h]?.(...g)});const u=r(f);return typeof u=="function"&&ww.set(t,u),o}async function Np(t){return new Promise(e=>setTimeout(e,t))}function vM(t,{emitOnBegin:e,initialWaitTime:r,interval:n}){let i=!0;const s=()=>i=!1;return(async()=>{let a;a=await t({unpoll:s});const f=await r?.(a)??n;await Np(f);const u=async()=>{i&&(await t({unpoll:s}),await Np(n),u())};u()})(),s}class ca extends dt{constructor({docsPath:e}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(` +`),{docsPath:e,docsSlug:"account",name:"AccountNotFoundError"})}}class Yl extends dt{constructor({docsPath:e,metaMessages:r,type:n}){super(`Account type "${n}" is not supported.`,{docsPath:e,metaMessages:r,name:"AccountTypeNotSupportedError"})}}function xw({chain:t,currentChainId:e}){if(!t)throw new hM;if(e!==t.id)throw new lM({chain:t,currentChainId:e})}function _w(t,{docsPath:e,...r}){const n=(()=>{const i=ew(t,r);return i instanceof _p?t:i})();return new hI(n,{docsPath:e,...r})}async function Ew(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]},{retryCount:0})}const Lp=new Bl(128);async function Jl(t,e){const{account:r=t.account,chain:n=t.chain,accessList:i,authorizationList:s,blobs:o,data:a,gas:f,gasPrice:u,maxFeePerBlobGas:h,maxFeePerGas:g,maxPriorityFeePerGas:b,nonce:x,type:S,value:C,...D}=e;if(typeof r>"u")throw new ca({docsPath:"/docs/actions/wallet/sendTransaction"});const B=r?ri(r):null;try{zl(e);const L=await(async()=>{if(e.to)return e.to;if(e.to!==null&&s&&s.length>0)return await Qy({authorization:s[0]}).catch(()=>{throw new dt("`to` is required. Could not infer from `authorizationList`.")})})();if(B?.type==="json-rpc"||B===null){let H;n!==null&&(H=await Fn(t,ju,"getChainId")({}),xw({currentChainId:H,chain:n}));const F=t.chain?.formatters?.transactionRequest?.format,$=(F||Ep)({...tw(D,{format:F}),accessList:i,authorizationList:s,blobs:o,chainId:H,data:a,from:B?.address,gas:f,gasPrice:u,maxFeePerBlobGas:h,maxFeePerGas:g,maxPriorityFeePerGas:b,nonce:x,to:L,type:S,value:C}),R=Lp.get(t.uid),W=R?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:W,params:[$]},{retryCount:0})}catch(V){if(R===!1)throw V;const X=V;if(X.name==="InvalidInputRpcError"||X.name==="InvalidParamsRpcError"||X.name==="MethodNotFoundRpcError"||X.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[$]},{retryCount:0}).then(q=>(Lp.set(t.uid,!0),q)).catch(q=>{const _=q;throw _.name==="MethodNotFoundRpcError"||_.name==="MethodNotSupportedRpcError"?(Lp.set(t.uid,!1),X):_});throw X}}if(B?.type==="local"){const H=await Fn(t,Pp,"prepareTransactionRequest")({account:B,accessList:i,authorizationList:s,blobs:o,chain:n,data:a,gas:f,gasPrice:u,maxFeePerBlobGas:h,maxFeePerGas:g,maxPriorityFeePerGas:b,nonce:x,nonceManager:B.nonceManager,parameters:[...pw,"sidecars"],type:S,value:C,...D,to:L}),F=n?.serializers?.transaction,k=await B.signTransaction(H,{serializer:F});return await Fn(t,Ew,"sendRawTransaction")({serializedTransaction:k})}throw B?.type==="smart"?new Yl({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new Yl({docsPath:"/docs/actions/wallet/sendTransaction",type:B?.type})}catch(L){throw L instanceof Yl?L:_w(L,{...e,account:B,chain:e.chain||void 0})}}async function bM(t,e){const{abi:r,account:n=t.account,address:i,args:s,dataSuffix:o,functionName:a,...f}=e;if(typeof n>"u")throw new ca({docsPath:"/docs/contract/writeContract"});const u=n?ri(n):null,h=$y({abi:r,args:s,functionName:a});try{return await Fn(t,Jl,"sendTransaction")({data:`${h}${o?o.replace("0x",""):""}`,to:i,account:u,...f})}catch(g){throw xI(g,{abi:r,address:i,args:s,docsPath:"/docs/contract/writeContract",functionName:a,sender:u?.address})}}const yM={"0x0":"reverted","0x1":"success"},Sw="0x5792579257925792579257925792579257925792579257925792579257925792",Aw=pr(0,{size:32});async function wM(t,e){const{account:r=t.account,capabilities:n,chain:i=t.chain,experimental_fallback:s,experimental_fallbackDelay:o=32,forceAtomic:a=!1,id:f,version:u="2.0.0"}=e,h=r?ri(r):null,g=e.calls.map(b=>{const x=b,S=x.abi?$y({abi:x.abi,functionName:x.functionName,args:x.args}):x.data;return{data:x.dataSuffix&&S?Ao([S,x.dataSuffix]):S,to:x.to,value:x.value?pr(x.value):void 0}});try{const b=await t.request({method:"wallet_sendCalls",params:[{atomicRequired:a,calls:g,capabilities:n,chainId:pr(i.id),from:h?.address,id:f,version:u}]},{retryCount:0});return typeof b=="string"?{id:b}:b}catch(b){const x=b;if(s&&(x.name==="MethodNotFoundRpcError"||x.name==="MethodNotSupportedRpcError"||x.name==="UnknownRpcError"||x.details.toLowerCase().includes("does not exist / is not available")||x.details.toLowerCase().includes("missing or invalid. request()")||x.details.toLowerCase().includes("did not match any variant of untagged enum")||x.details.toLowerCase().includes("account upgraded to unsupported contract")||x.details.toLowerCase().includes("eip-7702 not supported")||x.details.toLowerCase().includes("unsupported wc_ method"))){if(n&&Object.values(n).some(L=>!L.optional)){const L="non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";throw new hc(new dt(L,{details:L}))}if(a&&g.length>1){const B="`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";throw new dc(new dt(B,{details:B}))}const S=[];for(const B of g){const L=Jl(t,{account:h,chain:i,data:B.data,to:B.to,value:B.value?_o(B.value):void 0});S.push(L),o>0&&await new Promise(H=>setTimeout(H,o))}const C=await Promise.allSettled(S);if(C.every(B=>B.status==="rejected"))throw C[0].reason;const D=C.map(B=>B.status==="fulfilled"?B.value:Aw);return{id:Ao([...D,pr(i.id,{size:32}),Sw])}}throw _w(b,{...e,account:h,chain:e.chain})}}async function Pw(t,e){async function r(h){if(h.endsWith(Sw.slice(2))){const b=Tl(op(h,-64,-32)),x=op(h,0,-64).slice(2).match(/.{1,64}/g),S=await Promise.all(x.map(D=>Aw.slice(2)!==D?t.request({method:"eth_getTransactionReceipt",params:[`0x${D}`]},{dedupe:!0}):void 0)),C=S.some(D=>D===null)?100:S.every(D=>D?.status==="0x1")?200:S.every(D=>D?.status==="0x0")?500:600;return{atomic:!1,chainId:Eo(b),receipts:S.filter(Boolean),status:C,version:"2.0.0"}}return t.request({method:"wallet_getCallsStatus",params:[h]})}const{atomic:n=!1,chainId:i,receipts:s,version:o="2.0.0",...a}=await r(e.id),[f,u]=(()=>{const h=a.status;return h>=100&&h<200?["pending",h]:h>=200&&h<300?["success",h]:h>=300&&h<700?["failure",h]:h==="CONFIRMED"?["success",200]:h==="PENDING"?["pending",100]:[void 0,h]})();return{...a,atomic:n,chainId:i?Eo(i):void 0,receipts:s?.map(h=>({...h,blockNumber:_o(h.blockNumber),gasUsed:_o(h.gasUsed),status:yM[h.status]}))??[],statusCode:u,status:f,version:o}}async function xM(t,e){const{id:r,pollingInterval:n=t.pollingInterval,status:i=({statusCode:b})=>b>=200,timeout:s=6e4}=e,o=sa(["waitForCallsStatus",t.uid,r]),{promise:a,resolve:f,reject:u}=pM();let h;const g=mM(o,{resolve:f,reject:u},b=>{const x=vM(async()=>{const S=C=>{clearTimeout(h),x(),C(),g()};try{const C=await Pw(t,{id:r});if(!i(C))return;S(()=>b.resolve(C))}catch(C){S(()=>b.reject(C))}},{interval:n,emitOnBegin:!0});return x});return h=s?setTimeout(()=>{g(),clearTimeout(h),u(new _M({id:r}))},s):void 0,await a}class _M extends dt{constructor({id:e}){super(`Timed out while waiting for call bundle with id "${e}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}const kp=256;let Xl=kp,Zl;function Iw(t=11){if(!Zl||Xl+t>kp*2){Zl="",Xl=0;for(let e=0;e{const F=H(L);for(const $ in D)delete F[$];const k={...L,...F};return Object.assign(k,{extend:B(k)})}}return Object.assign(D,{extend:B(D)})}const Ql=new Bl(8192);function SM(t,{enabled:e=!0,id:r}){if(!e||!r)return t();if(Ql.get(r))return Ql.get(r);const n=t().finally(()=>Ql.delete(r));return Ql.set(r,n),n}function AM(t,{delay:e=100,retryCount:r=2,shouldRetry:n=()=>!0}={}){return new Promise((i,s)=>{const o=async({count:a=0}={})=>{const f=async({error:u})=>{const h=typeof e=="function"?e({count:a,error:u}):e;h&&await Np(h),o({count:a+1})};try{const u=await t();i(u)}catch(u){if(a{const{dedupe:i=!1,methods:s,retryDelay:o=150,retryCount:a=3,uid:f}={...e,...n},{method:u}=r;if(s?.exclude?.includes(u))throw new aa(new Error("method not supported"),{method:u});if(s?.include&&!s.include.includes(u))throw new aa(new Error("method not supported"),{method:u});const h=i?Ol(`${f}.${sa(r)}`):void 0;return SM(()=>AM(async()=>{try{return await t(r)}catch(g){const b=g;switch(b.code){case wu.code:throw new wu(b);case xu.code:throw new xu(b);case _u.code:throw new _u(b,{method:r.method});case Eu.code:throw new Eu(b);case oa.code:throw new oa(b);case Su.code:throw new Su(b);case Au.code:throw new Au(b);case Pu.code:throw new Pu(b);case Iu.code:throw new Iu(b);case aa.code:throw new aa(b,{method:r.method});case fc.code:throw new fc(b);case Mu.code:throw new Mu(b);case lc.code:throw new lc(b);case Cu.code:throw new Cu(b);case Ru.code:throw new Ru(b);case Tu.code:throw new Tu(b);case Du.code:throw new Du(b);case Ou.code:throw new Ou(b);case hc.code:throw new hc(b);case Nu.code:throw new Nu(b);case Lu.code:throw new Lu(b);case ku.code:throw new ku(b);case Bu.code:throw new Bu(b);case Fu.code:throw new Fu(b);case dc.code:throw new dc(b);case 5e3:throw new lc(b);default:throw g instanceof dt?g:new yI(b)}}},{delay:({count:g,error:b})=>{if(b&&b instanceof Gy){const x=b?.headers?.get("Retry-After");if(x?.match(/\d/))return Number.parseInt(x)*1e3}return~~(1<IM(g)}),{enabled:i,id:h})}}function IM(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===fc.code||t.code===oa.code:t instanceof Gy&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function MM({key:t,methods:e,name:r,request:n,retryCount:i=3,retryDelay:s=150,timeout:o,type:a},f){const u=Iw();return{config:{key:t,methods:e,name:r,request:n,retryCount:i,retryDelay:s,timeout:o,type:a},request:PM(n,{methods:e,retryCount:i,retryDelay:s,uid:u}),value:f}}function eh(t,e={}){const{key:r="custom",methods:n,name:i="Custom Provider",retryDelay:s}=e;return({retryCount:o})=>MM({key:r,methods:n,name:i,request:t.request.bind(t),retryCount:e.retryCount??o,retryDelay:s,type:"custom"})}function CM(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}class RM extends dt{constructor({domain:e}){super(`Invalid domain "${sa(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class TM extends dt{constructor({primaryType:e,types:r}){super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(r))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class DM extends dt{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function OM(t){const{domain:e,message:r,primaryType:n,types:i}=t,s=(f,u)=>{const h={...u};for(const g of f){const{name:b,type:x}=g;x==="address"&&(h[b]=h[b].toLowerCase())}return h},o=i.EIP712Domain?e?s(i.EIP712Domain,e):{}:{},a=(()=>{if(n!=="EIP712Domain")return s(i[n],r)})();return sa({domain:o,message:a,primaryType:n,types:i})}function NM(t){const{domain:e,message:r,primaryType:n,types:i}=t,s=(o,a)=>{for(const f of o){const{name:u,type:h}=f,g=a[u],b=h.match(ky);if(b&&(typeof g=="number"||typeof g=="bigint")){const[C,D,B]=b;pr(g,{signed:D==="int",size:Number.parseInt(B)/8})}if(h==="address"&&typeof g=="string"&&!ts(g))throw new So({address:g});const x=h.match(DP);if(x){const[C,D]=x;if(D&&gn(g)!==Number.parseInt(D))throw new qA({expectedSize:Number.parseInt(D),givenSize:gn(g)})}const S=i[h];S&&(kM(h),s(S,g))}};if(i.EIP712Domain&&e){if(typeof e!="object")throw new RM({domain:e});s(i.EIP712Domain,e)}if(n!=="EIP712Domain")if(i[n])s(i[n],r);else throw new TM({primaryType:n,types:i})}function LM({domain:t}){return[typeof t?.name=="string"&&{name:"name",type:"string"},t?.version&&{name:"version",type:"string"},(typeof t?.chainId=="number"||typeof t?.chainId=="bigint")&&{name:"chainId",type:"uint256"},t?.verifyingContract&&{name:"verifyingContract",type:"address"},t?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function kM(t){if(t==="address"||t==="bool"||t==="string"||t.startsWith("bytes")||t.startsWith("uint")||t.startsWith("int"))throw new DM({type:t})}class Mw extends tp{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,aP(e);const n=Ll(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let o=0;onew Mw(t,e).update(r).digest();Cw.create=(t,e)=>new Mw(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ii=BigInt(0),Kn=BigInt(1),ua=BigInt(2),BM=BigInt(3),Rw=BigInt(4),Tw=BigInt(5),Dw=BigInt(8);function Ri(t,e){const r=t%e;return r>=ii?r:e+r}function Ti(t,e,r){let n=t;for(;e-- >ii;)n*=n,n%=r;return n}function Ow(t,e){if(t===ii)throw new Error("invert: expected non-zero number");if(e<=ii)throw new Error("invert: expected positive modulus, got "+e);let r=Ri(t,e),n=e,i=ii,s=Kn;for(;r!==ii;){const a=n/r,f=n%r,u=i-s*a;n=r,r=f,i=s,s=u}if(n!==Kn)throw new Error("invert: does not exist");return Ri(i,e)}function Nw(t,e){const r=(t.ORDER+Kn)/Rw,n=t.pow(e,r);if(!t.eql(t.sqr(n),e))throw new Error("Cannot find square root");return n}function FM(t,e){const r=(t.ORDER-Tw)/Dw,n=t.mul(e,ua),i=t.pow(n,r),s=t.mul(e,i),o=t.mul(t.mul(s,ua),i),a=t.mul(s,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),e))throw new Error("Cannot find square root");return a}function jM(t){if(t1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Nw;let s=i.pow(n,e);const o=(e+Kn)/ua;return function(f,u){if(f.is0(u))return u;if(kw(f,u)!==1)throw new Error("Cannot find square root");let h=r,g=f.mul(f.ONE,s),b=f.pow(u,e),x=f.pow(u,o);for(;!f.eql(b,f.ONE);){if(f.is0(b))return f.ZERO;let S=1,C=f.sqr(b);for(;!f.eql(C,f.ONE);)if(S++,C=f.sqr(C),S===h)throw new Error("Cannot find square root");const D=Kn<(n[i]="function",n),e);return Tp(t,r),t}function zM(t,e,r){if(rii;)r&Kn&&(n=t.mul(n,i)),i=t.sqr(i),r>>=Kn;return n}function Lw(t,e,r=!1){const n=new Array(e.length).fill(r?t.ZERO:void 0),i=e.reduce((o,a,f)=>t.is0(a)?o:(n[f]=o,t.mul(o,a)),t.ONE),s=t.inv(i);return e.reduceRight((o,a,f)=>t.is0(a)?o:(n[f]=t.mul(o,n[f]),t.mul(o,a)),s),n}function kw(t,e){const r=(t.ORDER-Kn)/ua,n=t.pow(e,r),i=t.eql(n,t.ONE),s=t.eql(n,t.ZERO),o=t.eql(n,t.neg(t.ONE));if(!i&&!s&&!o)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function HM(t,e){e!==void 0&&mu(e);const r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function th(t,e,r=!1,n={}){if(t<=ii)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,s;if(typeof e=="object"&&e!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");const h=e;h.BITS&&(i=h.BITS),h.sqrt&&(s=h.sqrt),typeof h.isLE=="boolean"&&(r=h.isLE)}else typeof e=="number"&&(i=e),n.sqrt&&(s=n.sqrt);const{nBitLength:o,nByteLength:a}=HM(t,i);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const u=Object.freeze({ORDER:t,isLE:r,BITS:o,BYTES:a,MASK:Gl(o),ZERO:ii,ONE:Kn,create:h=>Ri(h,t),isValid:h=>{if(typeof h!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof h);return ii<=h&&hh===ii,isValidNot0:h=>!u.is0(h)&&u.isValid(h),isOdd:h=>(h&Kn)===Kn,neg:h=>Ri(-h,t),eql:(h,g)=>h===g,sqr:h=>Ri(h*h,t),add:(h,g)=>Ri(h+g,t),sub:(h,g)=>Ri(h-g,t),mul:(h,g)=>Ri(h*g,t),pow:(h,g)=>zM(u,h,g),div:(h,g)=>Ri(h*Ow(g,t),t),sqrN:h=>h*h,addN:(h,g)=>h+g,subN:(h,g)=>h-g,mulN:(h,g)=>h*g,inv:h=>Ow(h,t),sqrt:s||(h=>(f||(f=UM(t)),f(u,h))),toBytes:h=>r?bw(h,a):Cp(h,a),fromBytes:h=>{if(h.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+h.length);return r?vw(h):Vl(h)},invertBatch:h=>Lw(u,h),cmov:(h,g,b)=>b?g:h});return Object.freeze(u)}function Bw(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Fw(t){const e=Bw(t);return e+Math.ceil(e/2)}function WM(t,e,r=!1){const n=t.length,i=Bw(e),s=Fw(e);if(n<16||n1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);const o=r?vw(t):Vl(t),a=Ri(o,e-Kn)+Kn;return r?bw(a,i):Cp(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const gc=BigInt(0),fa=BigInt(1);function Uu(t,e){const r=e.negate();return t?r:e}function KM(t,e,r){const n=o=>o.pz,i=Lw(t.Fp,r.map(n));return r.map((o,a)=>o.toAffine(i[a])).map(t.fromAffine)}function jw(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Bp(t,e){jw(t,e);const r=Math.ceil(e/t)+1,n=2**(t-1),i=2**t,s=Gl(t),o=BigInt(t);return{windows:r,windowSize:n,mask:s,maxNumber:i,shiftBy:o}}function Uw(t,e,r){const{windowSize:n,mask:i,maxNumber:s,shiftBy:o}=r;let a=Number(t&i),f=t>>o;a>n&&(a-=s,f+=fa);const u=e*n,h=u+Math.abs(a)-1,g=a===0,b=a<0,x=e%2!==0;return{nextN:f,offset:h,isZero:g,isNeg:b,isNegF:x,offsetF:u}}function VM(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function GM(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,n)=>{if(!e.isValid(r))throw new Error("invalid scalar at index "+n)})}const Fp=new WeakMap,$w=new WeakMap;function jp(t){return $w.get(t)||1}function qw(t){if(t!==gc)throw new Error("invalid wNAF")}function YM(t,e){return{constTimeNegate:Uu,hasPrecomputes(r){return jp(r)!==1},unsafeLadder(r,n,i=t.ZERO){let s=r;for(;n>gc;)n&fa&&(i=i.add(s)),s=s.double(),n>>=fa;return i},precomputeWindow(r,n){const{windows:i,windowSize:s}=Bp(n,e),o=[];let a=r,f=a;for(let u=0;ugc||n>gc;)r&fa&&(s=s.add(i)),n&fa&&(o=o.add(i)),i=i.double(),r>>=fa,n>>=fa;return{p1:s,p2:o}}function XM(t,e,r,n){VM(r,t),GM(n,e);const i=r.length,s=n.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=uM(BigInt(i));let f=1;a>12?f=a-3:a>4?f=a-2:a>0&&(f=2);const u=Gl(f),h=new Array(Number(u)+1).fill(o),g=Math.floor((e.BITS-1)/f)*f;let b=o;for(let x=g;x>=0;x-=f){h.fill(o);for(let C=0;C>BigInt(x)&u);h[B]=h[B].add(r[C])}let S=o;for(let C=h.length-1,D=o;C>0;C--)D=D.add(h[C]),S=S.add(D);if(b=b.add(S),x!==0)for(let C=0;Cgc))throw new Error(`CURVE.${a} must be positive bigint`)}const n=zw(e.p,r.Fp),i=zw(e.n,r.Fn),o=["Gx","Gy","a","b"];for(const a of o)if(!n.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Hw(t){t.lowS!==void 0&&Wl("lowS",t.lowS),t.prehash!==void 0&&Wl("prehash",t.prehash)}class QM extends Error{constructor(e=""){super(e)}}const zs={Err:QM,_tlv:{encode:(t,e)=>{const{Err:r}=zs;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length&1)throw new r("tlv.encode: unpadded data");const n=e.length/2,i=Kl(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const s=n>127?Kl(i.length/2|128):"";return Kl(t)+s+i+e},decode(t,e){const{Err:r}=zs;let n=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");const i=e[n++],s=!!(i&128);let o=0;if(!s)o=i;else{const f=i&127;if(!f)throw new r("tlv.decode(long): indefinite length not supported");if(f>4)throw new r("tlv.decode(long): byte length is too big");const u=e.subarray(n,n+f);if(u.length!==f)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const h of u)o=o<<8|h;if(n+=f,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=e.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){const{Err:e}=zs;if(t<$u)throw new e("integer: negative integers are not allowed");let r=Kl(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){const{Err:e}=zs;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Vl(t)}},toSig(t){const{Err:e,_int:r,_tlv:n}=zs,i=Ci("signature",t),{v:s,l:o}=n.decode(48,i);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:f}=n.decode(2,s),{v:u,l:h}=n.decode(2,f);if(h.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(t){const{_tlv:e,_int:r}=zs,n=e.encode(2,r.encode(t.r)),i=e.encode(2,r.encode(t.s)),s=n+i;return e.encode(48,s)}},$u=BigInt(0),qu=BigInt(1),eC=BigInt(2),rh=BigInt(3),tC=BigInt(4);function rC(t,e,r){function n(i){const s=t.sqr(i),o=t.mul(s,i);return t.add(t.add(o,t.mul(i,e)),r)}return n}function Ww(t,e,r){const{BYTES:n}=t;function i(s){let o;if(typeof s=="bigint")o=s;else{let a=Ci("private key",s);if(e){if(!e.includes(a.length*2))throw new Error("invalid private key");const f=new Uint8Array(n);f.set(a,f.length-a.length),a=f}try{o=t.fromBytes(a)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof s}`)}}if(r&&(o=t.create(o)),!t.isValidNot0(o))throw new Error("invalid private key: out of range [1..N-1]");return o}return i}function nC(t,e={}){const{Fp:r,Fn:n}=ZM("weierstrass",t,e),{h:i,n:s}=t;Tp(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:o}=e;if(o&&(!r.is0(t.a)||typeof o.beta!="bigint"||typeof o.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function a(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(W,V,X){const{x:q,y:_}=V.toAffine(),v=r.toBytes(q);if(Wl("isCompressed",X),X){a();const l=!r.isOdd(_);return ia(Kw(l),v)}else return ia(Uint8Array.of(4),v,r.toBytes(_))}function u(W){es(W);const V=r.BYTES,X=V+1,q=2*V+1,_=W.length,v=W[0],l=W.subarray(1);if(_===X&&(v===2||v===3)){const p=r.fromBytes(l);if(!r.isValid(p))throw new Error("bad point: is not on curve, wrong x");const m=b(p);let y;try{y=r.sqrt(m)}catch(w){const I=w instanceof Error?": "+w.message:"";throw new Error("bad point: is not on curve, sqrt error"+I)}a();const A=r.isOdd(y);return(v&1)===1!==A&&(y=r.neg(y)),{x:p,y}}else if(_===q&&v===4){const p=r.fromBytes(l.subarray(V*0,V*1)),m=r.fromBytes(l.subarray(V*1,V*2));if(!x(p,m))throw new Error("bad point: is not on curve");return{x:p,y:m}}else throw new Error(`bad point: got length ${_}, expected compressed=${X} or uncompressed=${q}`)}const h=e.toBytes||f,g=e.fromBytes||u,b=rC(r,t.a,t.b);function x(W,V){const X=r.sqr(V),q=b(W);return r.eql(X,q)}if(!x(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const S=r.mul(r.pow(t.a,rh),tC),C=r.mul(r.sqr(t.b),BigInt(27));if(r.is0(r.add(S,C)))throw new Error("bad curve params: a or b");function D(W,V,X=!1){if(!r.isValid(V)||X&&r.is0(V))throw new Error(`bad point coordinate ${W}`);return V}function B(W){if(!(W instanceof k))throw new Error("ProjectivePoint expected")}const L=yw((W,V)=>{const{px:X,py:q,pz:_}=W;if(r.eql(_,r.ONE))return{x:X,y:q};const v=W.is0();V==null&&(V=v?r.ONE:r.inv(_));const l=r.mul(X,V),p=r.mul(q,V),m=r.mul(_,V);if(v)return{x:r.ZERO,y:r.ZERO};if(!r.eql(m,r.ONE))throw new Error("invZ was invalid");return{x:l,y:p}}),H=yw(W=>{if(W.is0()){if(e.allowInfinityPoint&&!r.is0(W.py))return;throw new Error("bad point: ZERO")}const{x:V,y:X}=W.toAffine();if(!r.isValid(V)||!r.isValid(X))throw new Error("bad point: x or y not field elements");if(!x(V,X))throw new Error("bad point: equation left != right");if(!W.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function F(W,V,X,q,_){return X=new k(r.mul(X.px,W),X.py,X.pz),V=Uu(q,V),X=Uu(_,X),V.add(X)}class k{constructor(V,X,q){this.px=D("x",V),this.py=D("y",X,!0),this.pz=D("z",q),Object.freeze(this)}static fromAffine(V){const{x:X,y:q}=V||{};if(!V||!r.isValid(X)||!r.isValid(q))throw new Error("invalid affine point");if(V instanceof k)throw new Error("projective point not allowed");return r.is0(X)&&r.is0(q)?k.ZERO:new k(X,q,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(V){return KM(k,"pz",V)}static fromBytes(V){return es(V),k.fromHex(V)}static fromHex(V){const X=k.fromAffine(g(Ci("pointHex",V)));return X.assertValidity(),X}static fromPrivateKey(V){const X=Ww(n,e.allowedPrivateKeyLengths,e.wrapPrivateKey);return k.BASE.multiply(X(V))}static msm(V,X){return XM(k,n,V,X)}precompute(V=8,X=!0){return R.setWindowSize(this,V),X||this.multiply(rh),this}_setWindowSize(V){this.precompute(V)}assertValidity(){H(this)}hasEvenY(){const{y:V}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(V)}equals(V){B(V);const{px:X,py:q,pz:_}=this,{px:v,py:l,pz:p}=V,m=r.eql(r.mul(X,p),r.mul(v,_)),y=r.eql(r.mul(q,p),r.mul(l,_));return m&&y}negate(){return new k(this.px,r.neg(this.py),this.pz)}double(){const{a:V,b:X}=t,q=r.mul(X,rh),{px:_,py:v,pz:l}=this;let p=r.ZERO,m=r.ZERO,y=r.ZERO,A=r.mul(_,_),E=r.mul(v,v),w=r.mul(l,l),I=r.mul(_,v);return I=r.add(I,I),y=r.mul(_,l),y=r.add(y,y),p=r.mul(V,y),m=r.mul(q,w),m=r.add(p,m),p=r.sub(E,m),m=r.add(E,m),m=r.mul(p,m),p=r.mul(I,p),y=r.mul(q,y),w=r.mul(V,w),I=r.sub(A,w),I=r.mul(V,I),I=r.add(I,y),y=r.add(A,A),A=r.add(y,A),A=r.add(A,w),A=r.mul(A,I),m=r.add(m,A),w=r.mul(v,l),w=r.add(w,w),A=r.mul(w,I),p=r.sub(p,A),y=r.mul(w,E),y=r.add(y,y),y=r.add(y,y),new k(p,m,y)}add(V){B(V);const{px:X,py:q,pz:_}=this,{px:v,py:l,pz:p}=V;let m=r.ZERO,y=r.ZERO,A=r.ZERO;const E=t.a,w=r.mul(t.b,rh);let I=r.mul(X,v),M=r.mul(q,l),z=r.mul(_,p),se=r.add(X,q),O=r.add(v,l);se=r.mul(se,O),O=r.add(I,M),se=r.sub(se,O),O=r.add(X,_);let ie=r.add(v,p);return O=r.mul(O,ie),ie=r.add(I,z),O=r.sub(O,ie),ie=r.add(q,_),m=r.add(l,p),ie=r.mul(ie,m),m=r.add(M,z),ie=r.sub(ie,m),A=r.mul(E,O),m=r.mul(w,z),A=r.add(m,A),m=r.sub(M,A),A=r.add(M,A),y=r.mul(m,A),M=r.add(I,I),M=r.add(M,I),z=r.mul(E,z),O=r.mul(w,O),M=r.add(M,z),z=r.sub(I,z),z=r.mul(E,z),O=r.add(O,z),I=r.mul(M,O),y=r.add(y,I),I=r.mul(ie,O),m=r.mul(se,m),m=r.sub(m,I),I=r.mul(se,M),A=r.mul(ie,A),A=r.add(A,I),new k(m,y,A)}subtract(V){return this.add(V.negate())}is0(){return this.equals(k.ZERO)}multiply(V){const{endo:X}=e;if(!n.isValidNot0(V))throw new Error("invalid scalar: out of range");let q,_;const v=l=>R.wNAFCached(this,l,k.normalizeZ);if(X){const{k1neg:l,k1:p,k2neg:m,k2:y}=X.splitScalar(V),{p:A,f:E}=v(p),{p:w,f:I}=v(y);_=E.add(I),q=F(X.beta,A,w,l,m)}else{const{p:l,f:p}=v(V);q=l,_=p}return k.normalizeZ([q,_])[0]}multiplyUnsafe(V){const{endo:X}=e,q=this;if(!n.isValid(V))throw new Error("invalid scalar: out of range");if(V===$u||q.is0())return k.ZERO;if(V===qu)return q;if(R.hasPrecomputes(this))return this.multiply(V);if(X){const{k1neg:_,k1:v,k2neg:l,k2:p}=X.splitScalar(V),{p1:m,p2:y}=JM(k,q,v,p);return F(X.beta,m,y,_,l)}else return R.wNAFCachedUnsafe(q,V)}multiplyAndAddUnsafe(V,X,q){const _=this.multiplyUnsafe(X).add(V.multiplyUnsafe(q));return _.is0()?void 0:_}toAffine(V){return L(this,V)}isTorsionFree(){const{isTorsionFree:V}=e;return i===qu?!0:V?V(k,this):R.wNAFCachedUnsafe(this,s).is0()}clearCofactor(){const{clearCofactor:V}=e;return i===qu?this:V?V(k,this):this.multiplyUnsafe(i)}toBytes(V=!0){return Wl("isCompressed",V),this.assertValidity(),h(k,this,V)}toRawBytes(V=!0){return this.toBytes(V)}toHex(V=!0){return cc(this.toBytes(V))}toString(){return``}}k.BASE=new k(t.Gx,t.Gy,r.ONE),k.ZERO=new k(r.ZERO,r.ONE,r.ZERO),k.Fp=r,k.Fn=n;const $=n.BITS,R=YM(k,e.endo?Math.ceil($/2):$);return k}function Kw(t){return Uint8Array.of(t?2:3)}function iC(t,e,r={}){Tp(e,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=e.randomBytes||pP,i=e.hmac||((q,..._)=>Cw(e.hash,q,ia(..._))),{Fp:s,Fn:o}=t,{ORDER:a,BITS:f}=o;function u(q){const _=a>>qu;return q>_}function h(q){return u(q)?o.neg(q):q}function g(q,_){if(!o.isValidNot0(_))throw new Error(`invalid signature ${q}: out of range 1..CURVE.n`)}class b{constructor(_,v,l){g("r",_),g("s",v),this.r=_,this.s=v,l!=null&&(this.recovery=l),Object.freeze(this)}static fromCompact(_){const v=o.BYTES,l=Ci("compactSignature",_,v*2);return new b(o.fromBytes(l.subarray(0,v)),o.fromBytes(l.subarray(v,v*2)))}static fromDER(_){const{r:v,s:l}=zs.toSig(Ci("DER",_));return new b(v,l)}assertValidity(){}addRecoveryBit(_){return new b(this.r,this.s,_)}recoverPublicKey(_){const v=s.ORDER,{r:l,s:p,recovery:m}=this;if(m==null||![0,1,2,3].includes(m))throw new Error("recovery id invalid");if(a*eC1)throw new Error("recovery id is ambiguous for h>1 curve");const A=m===2||m===3?l+a:l;if(!s.isValid(A))throw new Error("recovery id 2 or 3 invalid");const E=s.toBytes(A),w=t.fromHex(ia(Kw((m&1)===0),E)),I=o.inv(A),M=H(Ci("msgHash",_)),z=o.create(-M*I),se=o.create(p*I),O=t.BASE.multiplyUnsafe(z).add(w.multiplyUnsafe(se));if(O.is0())throw new Error("point at infinify");return O.assertValidity(),O}hasHighS(){return u(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,o.neg(this.s),this.recovery):this}toBytes(_){if(_==="compact")return ia(o.toBytes(this.r),o.toBytes(this.s));if(_==="der")return ep(zs.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return cc(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return cc(this.toBytes("compact"))}}const x=Ww(o,r.allowedPrivateKeyLengths,r.wrapPrivateKey),S={isValidPrivateKey(q){try{return x(q),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{const q=a;return WM(n(Fw(q)),q)},precompute(q=8,_=t.BASE){return _.precompute(q,!1)}};function C(q,_=!0){return t.fromPrivateKey(q).toBytes(_)}function D(q){if(typeof q=="bigint")return!1;if(q instanceof t)return!0;const v=Ci("key",q).length,l=s.BYTES,p=l+1,m=2*l+1;if(!(r.allowedPrivateKeyLengths||o.BYTES===p))return v===p||v===m}function B(q,_,v=!0){if(D(q)===!0)throw new Error("first arg must be private key");if(D(_)===!1)throw new Error("second arg must be public key");return t.fromHex(_).multiply(x(q)).toBytes(v)}const L=e.bits2int||function(q){if(q.length>8192)throw new Error("input is too large");const _=Vl(q),v=q.length*8-f;return v>0?_>>BigInt(v):_},H=e.bits2int_modN||function(q){return o.create(L(q))},F=Gl(f);function k(q){return cM("num < 2^"+f,q,$u,F),o.toBytes(q)}function $(q,_,v=R){if(["recovered","canonical"].some(se=>se in v))throw new Error("sign() legacy options not supported");const{hash:l}=e;let{lowS:p,prehash:m,extraEntropy:y}=v;p==null&&(p=!0),q=Ci("msgHash",q),Hw(v),m&&(q=Ci("prehashed msgHash",l(q)));const A=H(q),E=x(_),w=[k(E),k(A)];if(y!=null&&y!==!1){const se=y===!0?n(s.BYTES):y;w.push(Ci("extraEntropy",se))}const I=ia(...w),M=A;function z(se){const O=L(se);if(!o.isValidNot0(O))return;const ie=o.inv(O),ee=t.BASE.multiply(O).toAffine(),Z=o.create(ee.x);if(Z===$u)return;const te=o.create(ie*o.create(M+Z*E));if(te===$u)return;let N=(ee.x===Z?0:2)|Number(ee.y&qu),Q=te;return p&&u(te)&&(Q=h(te),N^=1),new b(Z,Q,N)}return{seed:I,k2sig:z}}const R={lowS:e.lowS,prehash:!1},W={lowS:e.lowS,prehash:!1};function V(q,_,v=R){const{seed:l,k2sig:p}=$(q,_,v);return fM(e.hash.outputLen,o.BYTES,i)(l,p)}t.BASE.precompute(8);function X(q,_,v,l=W){const p=q;_=Ci("msgHash",_),v=Ci("publicKey",v),Hw(l);const{lowS:m,prehash:y,format:A}=l;if("strict"in l)throw new Error("options.strict was renamed to lowS");if(A!==void 0&&!["compact","der","js"].includes(A))throw new Error('format must be "compact", "der" or "js"');const E=typeof p=="string"||Z0(p),w=!E&&!A&&typeof p=="object"&&p!==null&&typeof p.r=="bigint"&&typeof p.s=="bigint";if(!E&&!w)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let I,M;try{if(w)if(A===void 0||A==="js")I=new b(p.r,p.s);else throw new Error("invalid format");if(E){try{A!=="compact"&&(I=b.fromDER(p))}catch(Q){if(!(Q instanceof zs.Err))throw Q}!I&&A!=="der"&&(I=b.fromCompact(p))}M=t.fromHex(v)}catch{return!1}if(!I||m&&I.hasHighS())return!1;y&&(_=e.hash(_));const{r:z,s:se}=I,O=H(_),ie=o.inv(se),ee=o.create(O*ie),Z=o.create(z*ie),te=t.BASE.multiplyUnsafe(ee).add(M.multiplyUnsafe(Z));return te.is0()?!1:o.create(te.x)===z}return Object.freeze({getPublicKey:C,getSharedSecret:B,sign:V,verify:X,utils:S,Point:t,Signature:b})}function sC(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},r=t.Fp,n=th(e.n,t.nBitLength),i={Fp:r,Fn:n,allowedPrivateKeyLengths:t.allowedPrivateKeyLengths,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,wrapPrivateKey:t.wrapPrivateKey,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:i}}function oC(t){const{CURVE:e,curveOpts:r}=sC(t),n={hash:t.hash,hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:r,ecdsaOpts:n}}function aC(t,e){return Object.assign({},e,{ProjectivePoint:e.Point,CURVE:t})}function cC(t){const{CURVE:e,curveOpts:r,ecdsaOpts:n}=oC(t),i=nC(e,r),s=iC(i,n,r);return aC(t,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function uC(t,e){const r=n=>cC({...t,hash:n});return{...r(e),create:r}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const nh={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")};BigInt(0);const fC=BigInt(1),Up=BigInt(2),Vw=(t,e)=>(t+e/Up)/e;function lC(t){const e=nh.p,r=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),f=BigInt(88),u=t*t*t%e,h=u*u*t%e,g=Ti(h,r,e)*h%e,b=Ti(g,r,e)*h%e,x=Ti(b,Up,e)*u%e,S=Ti(x,i,e)*x%e,C=Ti(S,s,e)*S%e,D=Ti(C,a,e)*C%e,B=Ti(D,f,e)*D%e,L=Ti(B,a,e)*C%e,H=Ti(L,r,e)*h%e,F=Ti(H,o,e)*S%e,k=Ti(F,n,e)*u%e,$=Ti(k,Up,e);if(!$p.eql($p.sqr($),t))throw new Error("Cannot find square root");return $}const $p=th(nh.p,void 0,void 0,{sqrt:lC}),hC=uC({...nh,Fp:$p,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=nh.n,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-fC*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=BigInt("0x100000000000000000000000000000000"),a=Vw(s*t,e),f=Vw(-n*t,e);let u=Ri(t-a*r-f*i,e),h=Ri(-a*n-f*s,e);const g=u>o,b=h>o;if(g&&(u=e-u),b&&(h=e-h),u>o||h>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:g,k1:u,k2neg:b,k2:h}}}},cw),dC=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:hC},Symbol.toStringTag,{value:"Module"}));async function pC(t,{chain:e}){const{id:r,name:n,nativeCurrency:i,rpcUrls:s,blockExplorers:o}=e;await t.request({method:"wallet_addEthereumChain",params:[{chainId:pr(r),chainName:n,nativeCurrency:i,rpcUrls:s.default.http,blockExplorerUrls:o?Object.values(o).map(({url:a})=>a):void 0}]},{dedupe:!0,retryCount:0})}function gC(t,e){const{abi:r,args:n,bytecode:i,...s}=e,o=dM({abi:r,args:n,bytecode:i});return Jl(t,{...s,...s.authorizationList?{to:null}:{},data:o})}async function mC(t){return t.account?.type==="local"?[t.account.address]:(await t.request({method:"eth_accounts"},{dedupe:!0})).map(r=>bu(r))}async function vC(t,e={}){const{account:r=t.account,chainId:n}=e,i=r?ri(r):void 0,s=n?[i?.address,[pr(n)]]:[i?.address],o=await t.request({method:"wallet_getCapabilities",params:s}),a={};for(const[f,u]of Object.entries(o)){a[Number(f)]={};for(let[h,g]of Object.entries(u))h==="addSubAccount"&&(h="unstable_addSubAccount"),a[Number(f)][h]=g}return typeof n=="number"?a[n]:a}async function bC(t){return await t.request({method:"wallet_getPermissions"},{dedupe:!0})}async function Gw(t,e){const{account:r=t.account,chainId:n,nonce:i}=e;if(!r)throw new ca({docsPath:"/docs/eip7702/prepareAuthorization"});const s=ri(r),o=(()=>{if(e.executor)return e.executor==="self"?e.executor:ri(e.executor)})(),a={address:e.contractAddress??e.address,chainId:n,nonce:i};return typeof a.chainId>"u"&&(a.chainId=t.chain?.id??await Fn(t,ju,"getChainId")({})),typeof a.nonce>"u"&&(a.nonce=await Fn(t,sw,"getTransactionCount")({address:s.address,blockTag:"pending"}),(o==="self"||o?.address&&oM(o.address,s.address))&&(a.nonce+=1)),a}async function yC(t){return(await t.request({method:"eth_requestAccounts"},{dedupe:!0,retryCount:0})).map(r=>ip(r))}async function wC(t,e){return t.request({method:"wallet_requestPermissions",params:[e]},{retryCount:0})}async function xC(t,e){const{id:r}=e;await t.request({method:"wallet_showCallsStatus",params:[r]})}async function _C(t,e){const{account:r=t.account}=e;if(!r)throw new ca({docsPath:"/docs/eip7702/signAuthorization"});const n=ri(r);if(!n.signAuthorization)throw new Yl({docsPath:"/docs/eip7702/signAuthorization",metaMessages:["The `signAuthorization` Action does not support JSON-RPC Accounts."],type:n.type});const i=await Gw(t,e);return n.signAuthorization(i)}async function EC(t,{account:e=t.account,message:r}){if(!e)throw new ca({docsPath:"/docs/actions/wallet/signMessage"});const n=ri(e);if(n.signMessage)return n.signMessage({message:r});const i=typeof r=="string"?Ol(r):r.raw instanceof Uint8Array?Dl(r.raw):r.raw;return t.request({method:"personal_sign",params:[i,n.address]},{retryCount:0})}async function SC(t,e){const{account:r=t.account,chain:n=t.chain,...i}=e;if(!r)throw new ca({docsPath:"/docs/actions/wallet/signTransaction"});const s=ri(r);zl({account:s,...e});const o=await Fn(t,ju,"getChainId")({});n!==null&&xw({currentChainId:o,chain:n});const f=(n?.formatters||t.chain?.formatters)?.transactionRequest?.format||Ep;return s.signTransaction?s.signTransaction({...i,chainId:o},{serializer:t.chain?.serializers?.transaction}):await t.request({method:"eth_signTransaction",params:[{...f(i),chainId:pr(o),from:s.address}]},{retryCount:0})}async function AC(t,e){const{account:r=t.account,domain:n,message:i,primaryType:s}=e;if(!r)throw new ca({docsPath:"/docs/actions/wallet/signTypedData"});const o=ri(r),a={EIP712Domain:LM({domain:n}),...e.types};if(NM({domain:n,message:i,primaryType:s,types:a}),o.signTypedData)return o.signTypedData({domain:n,message:i,primaryType:s,types:a});const f=OM({domain:n,message:i,primaryType:s,types:a});return t.request({method:"eth_signTypedData_v4",params:[o.address,f]},{retryCount:0})}async function PC(t,{id:e}){await t.request({method:"wallet_switchEthereumChain",params:[{chainId:pr(e)}]},{retryCount:0})}async function IC(t,e){return await t.request({method:"wallet_watchAsset",params:e},{retryCount:0})}function MC(t){return{addChain:e=>pC(t,e),deployContract:e=>gC(t,e),getAddresses:()=>mC(t),getCallsStatus:e=>Pw(t,e),getCapabilities:e=>vC(t,e),getChainId:()=>ju(t),getPermissions:()=>bC(t),prepareAuthorization:e=>Gw(t,e),prepareTransactionRequest:e=>Pp(t,e),requestAddresses:()=>yC(t),requestPermissions:e=>wC(t,e),sendCalls:e=>wM(t,e),sendRawTransaction:e=>Ew(t,e),sendTransaction:e=>Jl(t,e),showCallsStatus:e=>xC(t,e),signAuthorization:e=>_C(t,e),signMessage:e=>EC(t,e),signTransaction:e=>SC(t,e),signTypedData:e=>AC(t,e),switchChain:e=>PC(t,e),waitForCallsStatus:e=>xM(t,e),watchAsset:e=>IC(t,e),writeContract:e=>bM(t,e)}}function ih(t){const{key:e="wallet",name:r="Wallet Client",transport:n}=t;return EM({...t,key:e,name:r,transport:n,type:"walletClient"}).extend(MC)}class la{_key;_config=null;_provider=null;_connected=!1;_address=null;_fatured=!1;_installed=!1;lastUsed=!1;_client=null;get address(){return this._address}get connected(){return this._connected}get featured(){return this._fatured}get key(){return this._key}get installed(){return this._installed}get provider(){return this._provider}get client(){return this._client?this._client:null}get config(){return this._config}static fromWalletConfig(e){return new la(e)}constructor(e){if("name"in e&&"image"in e)this._key=e.name,this._config=e,this._fatured=e.featured;else if("session"in e){if(!e.session)throw new Error("session is null");this._key=e.session?.peer.metadata.name,this._provider=e,this._client=ih({transport:eh(this._provider)}),this._config={name:e.session.peer.metadata.name,image:e.session.peer.metadata.icons[0],featured:!1},this.testConnect()}else if("info"in e)this._key=e.info.name,this._provider=e.provider,this._installed=!0,this._client=ih({transport:eh(this._provider)}),this._config={name:e.info.name,image:e.info.icon,featured:!1},this.testConnect();else throw new Error("unknown params")}EIP6963Detected(e){this._provider=e.provider,this._client=ih({transport:eh(this._provider)}),this._installed=!0,this._provider.on("disconnect",this.disconnect),this._provider.on("accountsChanged",r=>{this._address=r[0],this._connected=!0}),this.testConnect()}setUniversalProvider(e){this._provider=e,this._client=ih({transport:eh(this._provider)}),this.testConnect()}async switchChain(e){try{return await this.client?.getChainId()===e.id||await this.client?.switchChain(e),!0}catch(r){if(r.code===4902)return await this.client?.addChain({chain:e}),await this.client?.switchChain(e),!0;throw r}}async testConnect(){const e=await this.client?.getAddresses();e&&e.length>0?(this._address=e[0],this._connected=!0):(this._address=null,this._connected=!1)}async connect(){const e=await this.client?.requestAddresses();if(!e)throw new Error("connect failed");return e}async getAddress(){const e=await this.client?.getAddresses();if(!e)throw new Error("get address failed");return e[0]}async getChain(){const e=await this.client?.getChainId();if(!e)throw new Error("get chain failed");return e}async signMessage(e,r){return await this.client?.signMessage({message:e,account:r})}async disconnect(){this._provider&&"session"in this._provider&&await this._provider.disconnect(),this._connected=!1,this._address=null}}var sh={exports:{}},Yw;function CC(){if(Yw)return sh.exports;Yw=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(k,$,R){return Function.prototype.apply.call(k,$,R)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(k){return Object.getOwnPropertyNames(k).concat(Object.getOwnPropertySymbols(k))}:r=function(k){return Object.getOwnPropertyNames(k)};function n(F){console&&console.warn&&console.warn(F)}var i=Number.isNaN||function(k){return k!==k};function s(){s.init.call(this)}sh.exports=s,sh.exports.once=B,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(F){if(typeof F!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof F)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(F){if(typeof F!="number"||F<0||i(F))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+F+".");o=F}}),s.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},s.prototype.setMaxListeners=function(k){if(typeof k!="number"||k<0||i(k))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+k+".");return this._maxListeners=k,this};function f(F){return F._maxListeners===void 0?s.defaultMaxListeners:F._maxListeners}s.prototype.getMaxListeners=function(){return f(this)},s.prototype.emit=function(k){for(var $=[],R=1;R0&&(X=$[0]),X instanceof Error)throw X;var q=new Error("Unhandled error."+(X?" ("+X.message+")":""));throw q.context=X,q}var _=V[k];if(_===void 0)return!1;if(typeof _=="function")e(_,this,$);else for(var v=_.length,l=S(_,v),R=0;R0&&X.length>W&&!X.warned){X.warned=!0;var q=new Error("Possible EventEmitter memory leak detected. "+X.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");q.name="MaxListenersExceededWarning",q.emitter=F,q.type=k,q.count=X.length,n(q)}return F}s.prototype.addListener=function(k,$){return u(this,k,$,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(k,$){return u(this,k,$,!0)};function h(){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 g(F,k,$){var R={fired:!1,wrapFn:void 0,target:F,type:k,listener:$},W=h.bind(R);return W.listener=$,R.wrapFn=W,W}s.prototype.once=function(k,$){return a($),this.on(k,g(this,k,$)),this},s.prototype.prependOnceListener=function(k,$){return a($),this.prependListener(k,g(this,k,$)),this},s.prototype.removeListener=function(k,$){var R,W,V,X,q;if(a($),W=this._events,W===void 0)return this;if(R=W[k],R===void 0)return this;if(R===$||R.listener===$)--this._eventsCount===0?this._events=Object.create(null):(delete W[k],W.removeListener&&this.emit("removeListener",k,R.listener||$));else if(typeof R!="function"){for(V=-1,X=R.length-1;X>=0;X--)if(R[X]===$||R[X].listener===$){q=R[X].listener,V=X;break}if(V<0)return this;V===0?R.shift():C(R,V),R.length===1&&(W[k]=R[0]),W.removeListener!==void 0&&this.emit("removeListener",k,q||$)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(k){var $,R,W;if(R=this._events,R===void 0)return this;if(R.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):R[k]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete R[k]),this;if(arguments.length===0){var V=Object.keys(R),X;for(W=0;W=0;W--)this.removeListener(k,$[W]);return this};function b(F,k,$){var R=F._events;if(R===void 0)return[];var W=R[k];return W===void 0?[]:typeof W=="function"?$?[W.listener||W]:[W]:$?D(W):S(W,W.length)}s.prototype.listeners=function(k){return b(this,k,!0)},s.prototype.rawListeners=function(k){return b(this,k,!1)},s.listenerCount=function(F,k){return typeof F.listenerCount=="function"?F.listenerCount(k):x.call(F,k)},s.prototype.listenerCount=x;function x(F){var k=this._events;if(k!==void 0){var $=k[F];if(typeof $=="function")return 1;if($!==void 0)return $.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function S(F,k){for(var $=new Array(k),R=0;R=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function ZC(t,e){return function(r,n){e(r,n,t)}}function QC(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function eT(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(d){try{l(n.next(d))}catch(g){o(g)}}function u(d){try{l(n.throw(d))}catch(g){o(g)}}function l(d){d.done?s(d.value):i(d.value).then(a,u)}l((n=n.apply(t,e||[])).next())})}function tT(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,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(l){return function(d){return u([l,d])}}function u(l){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function I2(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function iT(){for(var t=[],e=0;e1||a(y,A)})})}function a(y,A){try{u(n[y](A))}catch(P){g(s[0][3],P)}}function u(y){y.value instanceof Wf?Promise.resolve(y.value.v).then(l,d):g(s[0][2],y)}function l(y){a("next",y)}function d(y){a("throw",y)}function g(y,A){y(A),s.shift(),s.length&&a(s[0][0],s[0][1])}}function aT(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:Wf(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function cT(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Xg=="function"?Xg(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,u){o=t[s](o),i(a,u,o.done,o.value)})}}function i(s,o,a,u){Promise.resolve(u).then(function(l){s({value:l,done:a})},o)}}function uT(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function fT(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function lT(t){return t&&t.__esModule?t:{default:t}}function hT(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function dT(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const Kf=Jp(Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Jg},__asyncDelegator:aT,__asyncGenerator:oT,__asyncValues:cT,__await:Wf,__awaiter:eT,__classPrivateFieldGet:hT,__classPrivateFieldSet:dT,__createBinding:rT,__decorate:XC,__exportStar:nT,__extends:YC,__generator:tT,__importDefault:lT,__importStar:fT,__makeTemplateObject:uT,__metadata:QC,__param:ZC,__read:I2,__rest:JC,__spread:iT,__spreadArrays:sT,__values:Xg},Symbol.toStringTag,{value:"Module"})));var Zg={},Vf={},C2;function pT(){if(C2)return Vf;C2=1,Object.defineProperty(Vf,"__esModule",{value:!0}),Vf.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return Vf.delay=t,Vf}var ja={},Qg={},qa={},T2;function gT(){return T2||(T2=1,Object.defineProperty(qa,"__esModule",{value:!0}),qa.ONE_THOUSAND=qa.ONE_HUNDRED=void 0,qa.ONE_HUNDRED=100,qa.ONE_THOUSAND=1e3),qa}var em={},R2;function mT(){return R2||(R2=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365}(em)),em}var D2;function O2(){return D2||(D2=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Kf;e.__exportStar(gT(),t),e.__exportStar(mT(),t)}(Qg)),Qg}var N2;function vT(){if(N2)return ja;N2=1,Object.defineProperty(ja,"__esModule",{value:!0}),ja.fromMiliseconds=ja.toMiliseconds=void 0;const t=O2();function e(n){return n*t.ONE_THOUSAND}ja.toMiliseconds=e;function r(n){return Math.floor(n/t.ONE_THOUSAND)}return ja.fromMiliseconds=r,ja}var L2;function bT(){return L2||(L2=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Kf;e.__exportStar(pT(),t),e.__exportStar(vT(),t)}(Zg)),Zg}var ru={},k2;function yT(){if(k2)return ru;k2=1,Object.defineProperty(ru,"__esModule",{value:!0}),ru.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const n=this.get(r);if(typeof n.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const i=Date.now()-n.started;this.timestamps.set(r,{started:n.started,elapsed:i})}get(r){const n=this.timestamps.get(r);if(typeof n>"u")throw new Error(`No timestamp found for label: ${r}`);return n}elapsed(r){const n=this.get(r);return n.elapsed||Date.now()-n.started}}return ru.Watch=t,ru.default=t,ru}var tm={},Gf={},$2;function wT(){if($2)return Gf;$2=1,Object.defineProperty(Gf,"__esModule",{value:!0}),Gf.IWatch=void 0;class t{}return Gf.IWatch=t,Gf}var B2;function xT(){return B2||(B2=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),Kf.__exportStar(wT(),t)}(tm)),tm}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Kf;e.__exportStar(bT(),t),e.__exportStar(yT(),t),e.__exportStar(xT(),t),e.__exportStar(O2(),t)})(mt);class za{}let _T=class extends za{constructor(e){super()}};const F2=mt.FIVE_SECONDS,nu={pulse:"heartbeat_pulse"};let ET=class $A extends _T{constructor(e){super(e),this.events=new qi.EventEmitter,this.interval=F2,this.interval=(e==null?void 0:e.interval)||F2}static async init(e){const r=new $A(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(),mt.toMiliseconds(this.interval))}pulse(){this.events.emit(nu.pulse)}};const ST=/"(?:_|\\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*:/,AT=/"(?: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*:/,PT=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function MT(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){IT(t);return}return e}function IT(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function Xh(t,e={}){if(typeof t!="string")return t;const r=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const n=r.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;if(n==="undefined")return;if(n==="null")return null;if(n==="nan")return Number.NaN;if(n==="infinity")return Number.POSITIVE_INFINITY;if(n==="-infinity")return Number.NEGATIVE_INFINITY}if(!PT.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(ST.test(t)||AT.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,MT)}return JSON.parse(t)}catch(n){if(e.strict)throw n;return t}}function CT(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function Cn(t,...e){try{return CT(t(...e))}catch(r){return Promise.reject(r)}}function TT(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function RT(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function Zh(t){if(TT(t))return String(t);if(RT(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return Zh(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function U2(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const rm="base64:";function DT(t){if(typeof t=="string")return t;U2();const e=Buffer.from(t).toString("base64");return rm+e}function OT(t){return typeof t!="string"||!t.startsWith(rm)?t:(U2(),Buffer.from(t.slice(rm.length),"base64"))}function pi(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function NT(...t){return pi(t.join(":"))}function Qh(t){return t=pi(t),t?t+":":""}function ooe(t){return t}const LT="memory",kT=()=>{const t=new Map;return{name:LT,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function $T(t={}){const e={mounts:{"":t.driver||kT()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=l=>{for(const d of e.mountpoints)if(l.startsWith(d))return{base:d,relativeKey:l.slice(d.length),driver:e.mounts[d]};return{base:"",relativeKey:l,driver:e.mounts[""]}},n=(l,d)=>e.mountpoints.filter(g=>g.startsWith(l)||d&&l.startsWith(g)).map(g=>({relativeBase:l.length>g.length?l.slice(g.length):void 0,mountpoint:g,driver:e.mounts[g]})),i=(l,d)=>{if(e.watching){d=pi(d);for(const g of e.watchListeners)g(l,d)}},s=async()=>{if(!e.watching){e.watching=!0;for(const l in e.mounts)e.unwatch[l]=await j2(e.mounts[l],i,l)}},o=async()=>{if(e.watching){for(const l in e.unwatch)await e.unwatch[l]();e.unwatch={},e.watching=!1}},a=(l,d,g)=>{const y=new Map,A=P=>{let N=y.get(P.base);return N||(N={driver:P.driver,base:P.base,items:[]},y.set(P.base,N)),N};for(const P of l){const N=typeof P=="string",D=pi(N?P:P.key),k=N?void 0:P.value,$=N||!P.options?d:{...d,...P.options},q=r(D);A(q).items.push({key:D,value:k,relativeKey:q.relativeKey,options:$})}return Promise.all([...y.values()].map(P=>g(P))).then(P=>P.flat())},u={hasItem(l,d={}){l=pi(l);const{relativeKey:g,driver:y}=r(l);return Cn(y.hasItem,g,d)},getItem(l,d={}){l=pi(l);const{relativeKey:g,driver:y}=r(l);return Cn(y.getItem,g,d).then(A=>Xh(A))},getItems(l,d){return a(l,d,g=>g.driver.getItems?Cn(g.driver.getItems,g.items.map(y=>({key:y.relativeKey,options:y.options})),d).then(y=>y.map(A=>({key:NT(g.base,A.key),value:Xh(A.value)}))):Promise.all(g.items.map(y=>Cn(g.driver.getItem,y.relativeKey,y.options).then(A=>({key:y.key,value:Xh(A)})))))},getItemRaw(l,d={}){l=pi(l);const{relativeKey:g,driver:y}=r(l);return y.getItemRaw?Cn(y.getItemRaw,g,d):Cn(y.getItem,g,d).then(A=>OT(A))},async setItem(l,d,g={}){if(d===void 0)return u.removeItem(l);l=pi(l);const{relativeKey:y,driver:A}=r(l);A.setItem&&(await Cn(A.setItem,y,Zh(d),g),A.watch||i("update",l))},async setItems(l,d){await a(l,d,async g=>{if(g.driver.setItems)return Cn(g.driver.setItems,g.items.map(y=>({key:y.relativeKey,value:Zh(y.value),options:y.options})),d);g.driver.setItem&&await Promise.all(g.items.map(y=>Cn(g.driver.setItem,y.relativeKey,Zh(y.value),y.options)))})},async setItemRaw(l,d,g={}){if(d===void 0)return u.removeItem(l,g);l=pi(l);const{relativeKey:y,driver:A}=r(l);if(A.setItemRaw)await Cn(A.setItemRaw,y,d,g);else if(A.setItem)await Cn(A.setItem,y,DT(d),g);else return;A.watch||i("update",l)},async removeItem(l,d={}){typeof d=="boolean"&&(d={removeMeta:d}),l=pi(l);const{relativeKey:g,driver:y}=r(l);y.removeItem&&(await Cn(y.removeItem,g,d),(d.removeMeta||d.removeMata)&&await Cn(y.removeItem,g+"$",d),y.watch||i("remove",l))},async getMeta(l,d={}){typeof d=="boolean"&&(d={nativeOnly:d}),l=pi(l);const{relativeKey:g,driver:y}=r(l),A=Object.create(null);if(y.getMeta&&Object.assign(A,await Cn(y.getMeta,g,d)),!d.nativeOnly){const P=await Cn(y.getItem,g+"$",d).then(N=>Xh(N));P&&typeof P=="object"&&(typeof P.atime=="string"&&(P.atime=new Date(P.atime)),typeof P.mtime=="string"&&(P.mtime=new Date(P.mtime)),Object.assign(A,P))}return A},setMeta(l,d,g={}){return this.setItem(l+"$",d,g)},removeMeta(l,d={}){return this.removeItem(l+"$",d)},async getKeys(l,d={}){l=Qh(l);const g=n(l,!0);let y=[];const A=[];for(const P of g){const N=await Cn(P.driver.getKeys,P.relativeBase,d);for(const D of N){const k=P.mountpoint+pi(D);y.some($=>k.startsWith($))||A.push(k)}y=[P.mountpoint,...y.filter(D=>!D.startsWith(P.mountpoint))]}return l?A.filter(P=>P.startsWith(l)&&P[P.length-1]!=="$"):A.filter(P=>P[P.length-1]!=="$")},async clear(l,d={}){l=Qh(l),await Promise.all(n(l,!1).map(async g=>{if(g.driver.clear)return Cn(g.driver.clear,g.relativeBase,d);if(g.driver.removeItem){const y=await g.driver.getKeys(g.relativeBase||"",d);return Promise.all(y.map(A=>g.driver.removeItem(A,d)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(l=>q2(l)))},async watch(l){return await s(),e.watchListeners.push(l),async()=>{e.watchListeners=e.watchListeners.filter(d=>d!==l),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(l,d){if(l=Qh(l),l&&e.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(e.mountpoints.push(l),e.mountpoints.sort((g,y)=>y.length-g.length)),e.mounts[l]=d,e.watching&&Promise.resolve(j2(d,i,l)).then(g=>{e.unwatch[l]=g}).catch(console.error),u},async unmount(l,d=!0){l=Qh(l),!(!l||!e.mounts[l])&&(e.watching&&l in e.unwatch&&(e.unwatch[l](),delete e.unwatch[l]),d&&await q2(e.mounts[l]),e.mountpoints=e.mountpoints.filter(g=>g!==l),delete e.mounts[l])},getMount(l=""){l=pi(l)+":";const d=r(l);return{driver:d.driver,base:d.base}},getMounts(l="",d={}){return l=pi(l),n(l,d.parents).map(y=>({driver:y.driver,base:y.mountpoint}))},keys:(l,d={})=>u.getKeys(l,d),get:(l,d={})=>u.getItem(l,d),set:(l,d,g={})=>u.setItem(l,d,g),has:(l,d={})=>u.hasItem(l,d),del:(l,d={})=>u.removeItem(l,d),remove:(l,d={})=>u.removeItem(l,d)};return u}function j2(t,e,r){return t.watch?t.watch((n,i)=>e(n,r+i)):()=>{}}async function q2(t){typeof t.dispose=="function"&&await Cn(t.dispose)}function Ha(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function z2(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const n=Ha(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}let nm;function Yf(){return nm||(nm=z2("keyval-store","keyval")),nm}function H2(t,e=Yf()){return e("readonly",r=>Ha(r.get(t)))}function BT(t,e,r=Yf()){return r("readwrite",n=>(n.put(e,t),Ha(n.transaction)))}function FT(t,e=Yf()){return e("readwrite",r=>(r.delete(t),Ha(r.transaction)))}function UT(t=Yf()){return t("readwrite",e=>(e.clear(),Ha(e.transaction)))}function jT(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Ha(t.transaction)}function qT(t=Yf()){return t("readonly",e=>{if(e.getAllKeys)return Ha(e.getAllKeys());const r=[];return jT(e,n=>r.push(n.key)).then(()=>r)})}const zT=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),HT=t=>{const 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=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(n,i)=>typeof i=="string"&&i.match(/^\d+n$/)?BigInt(i.substring(0,i.length-1)):i)};function Wa(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return HT(t)}catch{return t}}function go(t){return typeof t=="string"?t:zT(t)||""}const WT="idb-keyval";var KT=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=i=>e+i;let n;return t.dbName&&t.storeName&&(n=z2(t.dbName,t.storeName)),{name:WT,options:t,async hasItem(i){return!(typeof await H2(r(i),n)>"u")},async getItem(i){return await H2(r(i),n)??null},setItem(i,s){return BT(r(i),s,n)},removeItem(i){return FT(r(i),n)},getKeys(){return qT(n)},clear(){return UT(n)}}};const VT="WALLET_CONNECT_V2_INDEXED_DB",GT="keyvaluestorage";let YT=class{constructor(){this.indexedDb=$T({driver:KT({dbName:VT,storeName:GT})})}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){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,go(r))}async removeItem(e){await this.indexedDb.removeItem(e)}};var im=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ed={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof im<"u"&&im.localStorage?ed.exports=im.localStorage:typeof window<"u"&&window.localStorage?ed.exports=window.localStorage:ed.exports=new e})();function JT(t){var e;return[t[0],Wa((e=t[1])!=null?e:"")]}let XT=class{constructor(){this.localStorage=ed.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(JT)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return Wa(r)}async setItem(e,r){this.localStorage.setItem(e,go(r))}async removeItem(e){this.localStorage.removeItem(e)}};const ZT="wc_storage_version",W2=1,QT=async(t,e,r)=>{const n=ZT,i=await e.getItem(n);if(i&&i>=W2){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const u=a.toLowerCase();if(u.includes("wc@")||u.includes("walletconnect")||u.includes("wc_")||u.includes("wallet_connect")){const l=await t.getItem(a);await e.setItem(a,l),o.push(a)}}await e.setItem(n,W2),r(e),eR(t,o)},eR=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};let tR=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new XT;this.storage=e;try{const r=new YT;QT(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=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}};function rR(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var nR=iR;function iR(t,e,r){var n=r&&r.stringify||rR,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var o=new Array(s);o[0]=n(t);for(var a=1;a-1?g:0,t.charCodeAt(A+1)){case 100:case 102:if(d>=u||e[d]==null)break;g=u||e[d]==null)break;g=u||e[d]===void 0)break;g",g=A+2,A++;break}l+=n(e[d]),g=A+2,A++;break;case 115:if(d>=u)break;g-1&&(s=!1);const o=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");const a=t.level||"info",u=Object.create(r);u.log||(u.log=Xf),Object.defineProperty(u,"levelVal",{get:d}),Object.defineProperty(u,"level",{get:g,set:y});const l={transmit:e,serialize:i,asObject:t.browser.asObject,levels:o,timestamp:lR(t)};u.levels=mo.levels,u.level=a,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=Xf,u.serializers=n,u._serialize=i,u._stdErrSerialize=s,u.child=A,e&&(u._logEvent=sm());function d(){return this.level==="silent"?1/0:this.levels.values[this.level]}function g(){return this._level}function y(P){if(P!=="silent"&&!this.levels.values[P])throw Error("unknown level "+P);this._level=P,su(l,u,"error","log"),su(l,u,"fatal","error"),su(l,u,"warn","error"),su(l,u,"info","log"),su(l,u,"debug","log"),su(l,u,"trace","log")}function A(P,N){if(!P)throw new Error("missing bindings for child Pino");N=N||{},i&&P.serializers&&(N.serializers=P.serializers);const D=N.serializers;if(i&&D){var k=Object.assign({},n,D),$=t.browser.serialize===!0?Object.keys(k):i;delete P.serializers,td([P],$,k,this._stdErrSerialize)}function q(U){this._childLevel=(U._childLevel|0)+1,this.error=ou(U,P,"error"),this.fatal=ou(U,P,"fatal"),this.warn=ou(U,P,"warn"),this.info=ou(U,P,"info"),this.debug=ou(U,P,"debug"),this.trace=ou(U,P,"trace"),k&&(this.serializers=k,this._serialize=$),e&&(this._logEvent=sm([].concat(U._logEvent.bindings,P)))}return q.prototype=this,new q(this)}return u}mo.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"}},mo.stdSerializers=sR,mo.stdTimeFunctions=Object.assign({},{nullTime:V2,epochTime:G2,unixTime:hR,isoTime:dR});function su(t,e,r,n){const i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Xf:i[r]?i[r]:Jf[r]||Jf[n]||Xf,aR(t,e,r)}function aR(t,e,r){!t.transmit&&e[r]===Xf||(e[r]=function(n){return function(){const s=t.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Jf?Jf:this;for(var u=0;u-1&&s in r&&(t[i][s]=r[s](t[i][s]))}function ou(t,e,r){return function(){const n=new Array(1+arguments.length);n[0]=e;for(var i=1;ithis.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;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let 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};const r=e.value;return e=e.next,{done:!1,value:r}}}}},J2=class{constructor(e,r=am){this.level=e??"error",this.levelValue=iu.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new Y2(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===iu.levels.values.error?console.error(e):r===iu.levels.values.warn?console.warn(e):r===iu.levels.values.debug?console.debug(e):r===iu.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(go({timestamp:new Date().toISOString(),log:e}));const 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 Y2(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(go({extraMetadata:e})),new Blob(r,{type:"application/json"})}},vR=class{constructor(e,r=am){this.baseChunkLogger=new J2(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){const r=URL.createObjectURL(this.logsToBlob(e)),n=document.createElement("a");n.href=r,n.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}},bR=class{constructor(e,r=am){this.baseChunkLogger=new J2(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)}};var yR=Object.defineProperty,wR=Object.defineProperties,xR=Object.getOwnPropertyDescriptors,X2=Object.getOwnPropertySymbols,_R=Object.prototype.hasOwnProperty,ER=Object.prototype.propertyIsEnumerable,Z2=(t,e,r)=>e in t?yR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,nd=(t,e)=>{for(var r in e||(e={}))_R.call(e,r)&&Z2(t,r,e[r]);if(X2)for(var r of X2(e))ER.call(e,r)&&Z2(t,r,e[r]);return t},id=(t,e)=>wR(t,xR(e));function sd(t){return id(nd({},t),{level:(t==null?void 0:t.level)||gR.level})}function SR(t,e=Qf){return t[e]||""}function AR(t,e,r=Qf){return t[r]=e,t}function gi(t,e=Qf){let r="";return typeof t.bindings>"u"?r=SR(t,e):r=t.bindings().context||"",r}function PR(t,e,r=Qf){const n=gi(t,r);return n.trim()?`${n}/${e}`:e}function ri(t,e,r=Qf){const n=PR(t,e,r),i=t.child({context:n});return AR(i,n,r)}function MR(t){var e,r;const n=new vR((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Zf(id(nd({},t.opts),{level:"trace",browser:id(nd({},(r=t.opts)==null?void 0:r.browser),{write:i=>n.write(i)})})),chunkLoggerController:n}}function IR(t){var e;const r=new bR((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Zf(id(nd({},t.opts),{level:"trace"}),r),chunkLoggerController:r}}function CR(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?MR(t):IR(t)}let TR=class extends za{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},RR=class extends za{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}},DR=class{constructor(e,r){this.logger=e,this.core=r}},OR=class extends za{constructor(e,r){super(),this.relayer=e,this.logger=r}},NR=class extends za{constructor(e){super()}},LR=class{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}},kR=class extends za{constructor(e,r){super(),this.relayer=e,this.logger=r}},$R=class extends za{constructor(e,r){super(),this.core=e,this.logger=r}},BR=class{constructor(e,r,n){this.core=e,this.logger=r,this.store=n}},FR=class{constructor(e,r){this.projectId=e,this.logger=r}},UR=class{constructor(e,r,n){this.core=e,this.logger=r,this.telemetryEnabled=n}},jR=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},qR=class{constructor(e){this.client=e}};var cm={},ea={},od={},ad={};Object.defineProperty(ad,"__esModule",{value:!0}),ad.BrowserRandomSource=void 0;const Q2=65536;class zR{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const 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.");const r=new Uint8Array(e);for(let n=0;n>>16&65535,d=a&65535,g=u>>>16&65535,y=u&65535;return d*y+(l*y+d*g<<16>>>0)|0}t.mul=Math.imul||e;function r(a,u){return a+u|0}t.add=r;function n(a,u){return a-u|0}t.sub=n;function i(a,u){return a<>>32-u}t.rotl=i;function s(a,u){return a<<32-u|a>>>u}t.rotr=s;function o(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(a){return t.isInteger(a)&&a>=-t.MAX_SAFE_INTEGER&&a<=t.MAX_SAFE_INTEGER}})(tx),Object.defineProperty(or,"__esModule",{value:!0});var rx=tx;function JR(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}or.readInt16BE=JR;function XR(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}or.readUint16BE=XR;function ZR(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}or.readInt16LE=ZR;function QR(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}or.readUint16LE=QR;function nx(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}or.writeUint16BE=nx,or.writeInt16BE=nx;function ix(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}or.writeUint16LE=ix,or.writeInt16LE=ix;function um(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}or.readInt32BE=um;function fm(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}or.readUint32BE=fm;function lm(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}or.readInt32LE=lm;function hm(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}or.readUint32LE=hm;function ud(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}or.writeUint32BE=ud,or.writeInt32BE=ud;function fd(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}or.writeUint32LE=fd,or.writeInt32LE=fd;function eD(t,e){e===void 0&&(e=0);var r=um(t,e),n=um(t,e+4);return r*4294967296+n-(n>>31)*4294967296}or.readInt64BE=eD;function tD(t,e){e===void 0&&(e=0);var r=fm(t,e),n=fm(t,e+4);return r*4294967296+n}or.readUint64BE=tD;function rD(t,e){e===void 0&&(e=0);var r=lm(t,e),n=lm(t,e+4);return n*4294967296+r-(r>>31)*4294967296}or.readInt64LE=rD;function nD(t,e){e===void 0&&(e=0);var r=hm(t,e),n=hm(t,e+4);return n*4294967296+r}or.readUint64LE=nD;function sx(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),ud(t/4294967296>>>0,e,r),ud(t>>>0,e,r+4),e}or.writeUint64BE=sx,or.writeInt64BE=sx;function ox(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),fd(t>>>0,e,r),fd(t/4294967296>>>0,e,r+4),e}or.writeUint64LE=ox,or.writeInt64LE=ox;function iD(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}or.readUintBE=iD;function sD(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s=n;s--)r[s]=e/i&255,i*=256;return r}or.writeUintBE=oD;function aD(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!rx.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s256)throw new Error("randomString charset is too long");let y="";const A=d.length,P=256-256%A;for(;l>0;){const N=i(Math.ceil(l*256/P),g);for(let D=0;D0;D++){const k=N[D];k0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=u[d++],l--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(l>=this.blockSize&&(d=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,u,d,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=u[d++],l--;return this},a.prototype.finish=function(u){if(!this._finished){var l=this._bytesHashed,d=this._bufferLength,g=l/536870912|0,y=l<<3,A=l%128<112?128:256;this._buffer[d]=128;for(var P=d+1;P0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(u){return this._stateHi.set(u.stateHi),this._stateLo.set(u.stateLo),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(u){r.wipe(u.stateHi),r.wipe(u.stateLo),u.buffer&&r.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},a}();t.SHA512=n;var i=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 s(a,u,l,d,g,y,A){for(var P=l[0],N=l[1],D=l[2],k=l[3],$=l[4],q=l[5],U=l[6],K=l[7],J=d[0],T=d[1],z=d[2],ue=d[3],_e=d[4],G=d[5],E=d[6],m=d[7],f,p,v,x,_,S,b,M;A>=128;){for(var I=0;I<16;I++){var F=8*I+y;a[I]=e.readUint32BE(g,F),u[I]=e.readUint32BE(g,F+4)}for(var I=0;I<80;I++){var ae=P,O=N,se=D,ee=k,X=$,Q=q,R=U,Z=K,te=J,le=T,ie=z,fe=ue,ve=_e,Me=G,Ne=E,Te=m;if(f=K,p=m,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=($>>>14|_e<<18)^($>>>18|_e<<14)^(_e>>>9|$<<23),p=(_e>>>14|$<<18)^(_e>>>18|$<<14)^($>>>9|_e<<23),_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,f=$&q^~$&U,p=_e&G^~_e&E,_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,f=i[I*2],p=i[I*2+1],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,f=a[I%16],p=u[I%16],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,v=b&65535|M<<16,x=_&65535|S<<16,f=v,p=x,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=(P>>>28|J<<4)^(J>>>2|P<<30)^(J>>>7|P<<25),p=(J>>>28|P<<4)^(P>>>2|J<<30)^(P>>>7|J<<25),_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,f=P&N^P&D^N&D,p=J&T^J&z^T&z,_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,Z=b&65535|M<<16,Te=_&65535|S<<16,f=ee,p=fe,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=v,p=x,_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,ee=b&65535|M<<16,fe=_&65535|S<<16,N=ae,D=O,k=se,$=ee,q=X,U=Q,K=R,P=Z,T=te,z=le,ue=ie,_e=fe,G=ve,E=Me,m=Ne,J=Te,I%16===15)for(var F=0;F<16;F++)f=a[F],p=u[F],_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=a[(F+9)%16],p=u[(F+9)%16],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,v=a[(F+1)%16],x=u[(F+1)%16],f=(v>>>1|x<<31)^(v>>>8|x<<24)^v>>>7,p=(x>>>1|v<<31)^(x>>>8|v<<24)^(x>>>7|v<<25),_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,v=a[(F+14)%16],x=u[(F+14)%16],f=(v>>>19|x<<13)^(x>>>29|v<<3)^v>>>6,p=(x>>>19|v<<13)^(v>>>29|x<<3)^(x>>>6|v<<26),_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,a[F]=b&65535|M<<16,u[F]=_&65535|S<<16}f=P,p=J,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=l[0],p=d[0],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,l[0]=P=b&65535|M<<16,d[0]=J=_&65535|S<<16,f=N,p=T,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=l[1],p=d[1],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,l[1]=N=b&65535|M<<16,d[1]=T=_&65535|S<<16,f=D,p=z,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=l[2],p=d[2],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,l[2]=D=b&65535|M<<16,d[2]=z=_&65535|S<<16,f=k,p=ue,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=l[3],p=d[3],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,l[3]=k=b&65535|M<<16,d[3]=ue=_&65535|S<<16,f=$,p=_e,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=l[4],p=d[4],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,l[4]=$=b&65535|M<<16,d[4]=_e=_&65535|S<<16,f=q,p=G,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=l[5],p=d[5],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,l[5]=q=b&65535|M<<16,d[5]=G=_&65535|S<<16,f=U,p=E,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=l[6],p=d[6],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,l[6]=U=b&65535|M<<16,d[6]=E=_&65535|S<<16,f=K,p=m,_=p&65535,S=p>>>16,b=f&65535,M=f>>>16,f=l[7],p=d[7],_+=p&65535,S+=p>>>16,b+=f&65535,M+=f>>>16,S+=_>>>16,b+=S>>>16,M+=b>>>16,l[7]=K=b&65535|M<<16,d[7]=m=_&65535|S<<16,y+=128,A-=128}return y}function o(a){var u=new n;u.update(a);var l=u.digest();return u.clean(),l}t.hash=o})(ax),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertSecretKeyToX25519=t.convertPublicKeyToX25519=t.verify=t.sign=t.extractPublicKeyFromSecretKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.SEED_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=t.SIGNATURE_LENGTH=void 0;const e=ea,r=ax,n=Mi;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(ee){const X=new Float64Array(16);if(ee)for(let Q=0;Q>16&1),Q[le-1]&=65535;Q[15]=R[15]-32767-(Q[14]>>16&1);const te=Q[15]>>16&1;Q[14]&=65535,N(R,Q,1-te)}for(let Z=0;Z<16;Z++)ee[2*Z]=R[Z]&255,ee[2*Z+1]=R[Z]>>8}function k(ee,X){let Q=0;for(let R=0;R<32;R++)Q|=ee[R]^X[R];return(1&Q-1>>>8)-1}function $(ee,X){const Q=new Uint8Array(32),R=new Uint8Array(32);return D(Q,ee),D(R,X),k(Q,R)}function q(ee){const X=new Uint8Array(32);return D(X,ee),X[0]&1}function U(ee,X){for(let Q=0;Q<16;Q++)ee[Q]=X[2*Q]+(X[2*Q+1]<<8);ee[15]&=32767}function K(ee,X,Q){for(let R=0;R<16;R++)ee[R]=X[R]+Q[R]}function J(ee,X,Q){for(let R=0;R<16;R++)ee[R]=X[R]-Q[R]}function T(ee,X,Q){let R,Z,te=0,le=0,ie=0,fe=0,ve=0,Me=0,Ne=0,Te=0,Be=0,Ie=0,Le=0,Ve=0,ke=0,ze=0,He=0,Ee=0,Qe=0,ct=0,$e=0,et=0,rt=0,Je=0,pt=0,ht=0,ft=0,Ht=0,Jt=0,St=0,er=0,Xt=0,Ot=0,$t=Q[0],Tt=Q[1],vt=Q[2],Dt=Q[3],Lt=Q[4],bt=Q[5],Bt=Q[6],Ut=Q[7],nt=Q[8],Ft=Q[9],B=Q[10],H=Q[11],V=Q[12],C=Q[13],Y=Q[14],j=Q[15];R=X[0],te+=R*$t,le+=R*Tt,ie+=R*vt,fe+=R*Dt,ve+=R*Lt,Me+=R*bt,Ne+=R*Bt,Te+=R*Ut,Be+=R*nt,Ie+=R*Ft,Le+=R*B,Ve+=R*H,ke+=R*V,ze+=R*C,He+=R*Y,Ee+=R*j,R=X[1],le+=R*$t,ie+=R*Tt,fe+=R*vt,ve+=R*Dt,Me+=R*Lt,Ne+=R*bt,Te+=R*Bt,Be+=R*Ut,Ie+=R*nt,Le+=R*Ft,Ve+=R*B,ke+=R*H,ze+=R*V,He+=R*C,Ee+=R*Y,Qe+=R*j,R=X[2],ie+=R*$t,fe+=R*Tt,ve+=R*vt,Me+=R*Dt,Ne+=R*Lt,Te+=R*bt,Be+=R*Bt,Ie+=R*Ut,Le+=R*nt,Ve+=R*Ft,ke+=R*B,ze+=R*H,He+=R*V,Ee+=R*C,Qe+=R*Y,ct+=R*j,R=X[3],fe+=R*$t,ve+=R*Tt,Me+=R*vt,Ne+=R*Dt,Te+=R*Lt,Be+=R*bt,Ie+=R*Bt,Le+=R*Ut,Ve+=R*nt,ke+=R*Ft,ze+=R*B,He+=R*H,Ee+=R*V,Qe+=R*C,ct+=R*Y,$e+=R*j,R=X[4],ve+=R*$t,Me+=R*Tt,Ne+=R*vt,Te+=R*Dt,Be+=R*Lt,Ie+=R*bt,Le+=R*Bt,Ve+=R*Ut,ke+=R*nt,ze+=R*Ft,He+=R*B,Ee+=R*H,Qe+=R*V,ct+=R*C,$e+=R*Y,et+=R*j,R=X[5],Me+=R*$t,Ne+=R*Tt,Te+=R*vt,Be+=R*Dt,Ie+=R*Lt,Le+=R*bt,Ve+=R*Bt,ke+=R*Ut,ze+=R*nt,He+=R*Ft,Ee+=R*B,Qe+=R*H,ct+=R*V,$e+=R*C,et+=R*Y,rt+=R*j,R=X[6],Ne+=R*$t,Te+=R*Tt,Be+=R*vt,Ie+=R*Dt,Le+=R*Lt,Ve+=R*bt,ke+=R*Bt,ze+=R*Ut,He+=R*nt,Ee+=R*Ft,Qe+=R*B,ct+=R*H,$e+=R*V,et+=R*C,rt+=R*Y,Je+=R*j,R=X[7],Te+=R*$t,Be+=R*Tt,Ie+=R*vt,Le+=R*Dt,Ve+=R*Lt,ke+=R*bt,ze+=R*Bt,He+=R*Ut,Ee+=R*nt,Qe+=R*Ft,ct+=R*B,$e+=R*H,et+=R*V,rt+=R*C,Je+=R*Y,pt+=R*j,R=X[8],Be+=R*$t,Ie+=R*Tt,Le+=R*vt,Ve+=R*Dt,ke+=R*Lt,ze+=R*bt,He+=R*Bt,Ee+=R*Ut,Qe+=R*nt,ct+=R*Ft,$e+=R*B,et+=R*H,rt+=R*V,Je+=R*C,pt+=R*Y,ht+=R*j,R=X[9],Ie+=R*$t,Le+=R*Tt,Ve+=R*vt,ke+=R*Dt,ze+=R*Lt,He+=R*bt,Ee+=R*Bt,Qe+=R*Ut,ct+=R*nt,$e+=R*Ft,et+=R*B,rt+=R*H,Je+=R*V,pt+=R*C,ht+=R*Y,ft+=R*j,R=X[10],Le+=R*$t,Ve+=R*Tt,ke+=R*vt,ze+=R*Dt,He+=R*Lt,Ee+=R*bt,Qe+=R*Bt,ct+=R*Ut,$e+=R*nt,et+=R*Ft,rt+=R*B,Je+=R*H,pt+=R*V,ht+=R*C,ft+=R*Y,Ht+=R*j,R=X[11],Ve+=R*$t,ke+=R*Tt,ze+=R*vt,He+=R*Dt,Ee+=R*Lt,Qe+=R*bt,ct+=R*Bt,$e+=R*Ut,et+=R*nt,rt+=R*Ft,Je+=R*B,pt+=R*H,ht+=R*V,ft+=R*C,Ht+=R*Y,Jt+=R*j,R=X[12],ke+=R*$t,ze+=R*Tt,He+=R*vt,Ee+=R*Dt,Qe+=R*Lt,ct+=R*bt,$e+=R*Bt,et+=R*Ut,rt+=R*nt,Je+=R*Ft,pt+=R*B,ht+=R*H,ft+=R*V,Ht+=R*C,Jt+=R*Y,St+=R*j,R=X[13],ze+=R*$t,He+=R*Tt,Ee+=R*vt,Qe+=R*Dt,ct+=R*Lt,$e+=R*bt,et+=R*Bt,rt+=R*Ut,Je+=R*nt,pt+=R*Ft,ht+=R*B,ft+=R*H,Ht+=R*V,Jt+=R*C,St+=R*Y,er+=R*j,R=X[14],He+=R*$t,Ee+=R*Tt,Qe+=R*vt,ct+=R*Dt,$e+=R*Lt,et+=R*bt,rt+=R*Bt,Je+=R*Ut,pt+=R*nt,ht+=R*Ft,ft+=R*B,Ht+=R*H,Jt+=R*V,St+=R*C,er+=R*Y,Xt+=R*j,R=X[15],Ee+=R*$t,Qe+=R*Tt,ct+=R*vt,$e+=R*Dt,et+=R*Lt,rt+=R*bt,Je+=R*Bt,pt+=R*Ut,ht+=R*nt,ft+=R*Ft,Ht+=R*B,Jt+=R*H,St+=R*V,er+=R*C,Xt+=R*Y,Ot+=R*j,te+=38*Qe,le+=38*ct,ie+=38*$e,fe+=38*et,ve+=38*rt,Me+=38*Je,Ne+=38*pt,Te+=38*ht,Be+=38*ft,Ie+=38*Ht,Le+=38*Jt,Ve+=38*St,ke+=38*er,ze+=38*Xt,He+=38*Ot,Z=1,R=te+Z+65535,Z=Math.floor(R/65536),te=R-Z*65536,R=le+Z+65535,Z=Math.floor(R/65536),le=R-Z*65536,R=ie+Z+65535,Z=Math.floor(R/65536),ie=R-Z*65536,R=fe+Z+65535,Z=Math.floor(R/65536),fe=R-Z*65536,R=ve+Z+65535,Z=Math.floor(R/65536),ve=R-Z*65536,R=Me+Z+65535,Z=Math.floor(R/65536),Me=R-Z*65536,R=Ne+Z+65535,Z=Math.floor(R/65536),Ne=R-Z*65536,R=Te+Z+65535,Z=Math.floor(R/65536),Te=R-Z*65536,R=Be+Z+65535,Z=Math.floor(R/65536),Be=R-Z*65536,R=Ie+Z+65535,Z=Math.floor(R/65536),Ie=R-Z*65536,R=Le+Z+65535,Z=Math.floor(R/65536),Le=R-Z*65536,R=Ve+Z+65535,Z=Math.floor(R/65536),Ve=R-Z*65536,R=ke+Z+65535,Z=Math.floor(R/65536),ke=R-Z*65536,R=ze+Z+65535,Z=Math.floor(R/65536),ze=R-Z*65536,R=He+Z+65535,Z=Math.floor(R/65536),He=R-Z*65536,R=Ee+Z+65535,Z=Math.floor(R/65536),Ee=R-Z*65536,te+=Z-1+37*(Z-1),Z=1,R=te+Z+65535,Z=Math.floor(R/65536),te=R-Z*65536,R=le+Z+65535,Z=Math.floor(R/65536),le=R-Z*65536,R=ie+Z+65535,Z=Math.floor(R/65536),ie=R-Z*65536,R=fe+Z+65535,Z=Math.floor(R/65536),fe=R-Z*65536,R=ve+Z+65535,Z=Math.floor(R/65536),ve=R-Z*65536,R=Me+Z+65535,Z=Math.floor(R/65536),Me=R-Z*65536,R=Ne+Z+65535,Z=Math.floor(R/65536),Ne=R-Z*65536,R=Te+Z+65535,Z=Math.floor(R/65536),Te=R-Z*65536,R=Be+Z+65535,Z=Math.floor(R/65536),Be=R-Z*65536,R=Ie+Z+65535,Z=Math.floor(R/65536),Ie=R-Z*65536,R=Le+Z+65535,Z=Math.floor(R/65536),Le=R-Z*65536,R=Ve+Z+65535,Z=Math.floor(R/65536),Ve=R-Z*65536,R=ke+Z+65535,Z=Math.floor(R/65536),ke=R-Z*65536,R=ze+Z+65535,Z=Math.floor(R/65536),ze=R-Z*65536,R=He+Z+65535,Z=Math.floor(R/65536),He=R-Z*65536,R=Ee+Z+65535,Z=Math.floor(R/65536),Ee=R-Z*65536,te+=Z-1+37*(Z-1),ee[0]=te,ee[1]=le,ee[2]=ie,ee[3]=fe,ee[4]=ve,ee[5]=Me,ee[6]=Ne,ee[7]=Te,ee[8]=Be,ee[9]=Ie,ee[10]=Le,ee[11]=Ve,ee[12]=ke,ee[13]=ze,ee[14]=He,ee[15]=Ee}function z(ee,X){T(ee,X,X)}function ue(ee,X){const Q=i();let R;for(R=0;R<16;R++)Q[R]=X[R];for(R=253;R>=0;R--)z(Q,Q),R!==2&&R!==4&&T(Q,Q,X);for(R=0;R<16;R++)ee[R]=Q[R]}function _e(ee,X){const Q=i();let R;for(R=0;R<16;R++)Q[R]=X[R];for(R=250;R>=0;R--)z(Q,Q),R!==1&&T(Q,Q,X);for(R=0;R<16;R++)ee[R]=Q[R]}function G(ee,X){const Q=i(),R=i(),Z=i(),te=i(),le=i(),ie=i(),fe=i(),ve=i(),Me=i();J(Q,ee[1],ee[0]),J(Me,X[1],X[0]),T(Q,Q,Me),K(R,ee[0],ee[1]),K(Me,X[0],X[1]),T(R,R,Me),T(Z,ee[3],X[3]),T(Z,Z,l),T(te,ee[2],X[2]),K(te,te,te),J(le,R,Q),J(ie,te,Z),K(fe,te,Z),K(ve,R,Q),T(ee[0],le,ie),T(ee[1],ve,fe),T(ee[2],fe,ie),T(ee[3],le,ve)}function E(ee,X,Q){for(let R=0;R<4;R++)N(ee[R],X[R],Q)}function m(ee,X){const Q=i(),R=i(),Z=i();ue(Z,X[2]),T(Q,X[0],Z),T(R,X[1],Z),D(ee,R),ee[31]^=q(Q)<<7}function f(ee,X,Q){A(ee[0],o),A(ee[1],a),A(ee[2],a),A(ee[3],o);for(let R=255;R>=0;--R){const Z=Q[R/8|0]>>(R&7)&1;E(ee,X,Z),G(X,ee),G(ee,ee),E(ee,X,Z)}}function p(ee,X){const Q=[i(),i(),i(),i()];A(Q[0],d),A(Q[1],g),A(Q[2],a),T(Q[3],d,g),f(ee,Q,X)}function v(ee){if(ee.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const X=(0,r.hash)(ee);X[0]&=248,X[31]&=127,X[31]|=64;const Q=new Uint8Array(32),R=[i(),i(),i(),i()];p(R,X),m(Q,R);const Z=new Uint8Array(64);return Z.set(ee),Z.set(Q,32),{publicKey:Q,secretKey:Z}}t.generateKeyPairFromSeed=v;function x(ee){const X=(0,e.randomBytes)(32,ee),Q=v(X);return(0,n.wipe)(X),Q}t.generateKeyPair=x;function _(ee){if(ee.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(ee.subarray(32))}t.extractPublicKeyFromSecretKey=_;const S=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 b(ee,X){let Q,R,Z,te;for(R=63;R>=32;--R){for(Q=0,Z=R-32,te=R-12;Z>4)*S[Z],Q=X[Z]>>8,X[Z]&=255;for(Z=0;Z<32;Z++)X[Z]-=Q*S[Z];for(R=0;R<32;R++)X[R+1]+=X[R]>>8,ee[R]=X[R]&255}function M(ee){const X=new Float64Array(64);for(let Q=0;Q<64;Q++)X[Q]=ee[Q];for(let Q=0;Q<64;Q++)ee[Q]=0;b(ee,X)}function I(ee,X){const Q=new Float64Array(64),R=[i(),i(),i(),i()],Z=(0,r.hash)(ee.subarray(0,32));Z[0]&=248,Z[31]&=127,Z[31]|=64;const te=new Uint8Array(64);te.set(Z.subarray(32),32);const le=new r.SHA512;le.update(te.subarray(32)),le.update(X);const ie=le.digest();le.clean(),M(ie),p(R,ie),m(te,R),le.reset(),le.update(te.subarray(0,32)),le.update(ee.subarray(32)),le.update(X);const fe=le.digest();M(fe);for(let ve=0;ve<32;ve++)Q[ve]=ie[ve];for(let ve=0;ve<32;ve++)for(let Me=0;Me<32;Me++)Q[ve+Me]+=fe[ve]*Z[Me];return b(te.subarray(32),Q),te}t.sign=I;function F(ee,X){const Q=i(),R=i(),Z=i(),te=i(),le=i(),ie=i(),fe=i();return A(ee[2],a),U(ee[1],X),z(Z,ee[1]),T(te,Z,u),J(Z,Z,ee[2]),K(te,ee[2],te),z(le,te),z(ie,le),T(fe,ie,le),T(Q,fe,Z),T(Q,Q,te),_e(Q,Q),T(Q,Q,Z),T(Q,Q,te),T(Q,Q,te),T(ee[0],Q,te),z(R,ee[0]),T(R,R,te),$(R,Z)&&T(ee[0],ee[0],y),z(R,ee[0]),T(R,R,te),$(R,Z)?-1:(q(ee[0])===X[31]>>7&&J(ee[0],o,ee[0]),T(ee[3],ee[0],ee[1]),0)}function ae(ee,X,Q){const R=new Uint8Array(32),Z=[i(),i(),i(),i()],te=[i(),i(),i(),i()];if(Q.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(F(te,ee))return!1;const le=new r.SHA512;le.update(Q.subarray(0,32)),le.update(ee),le.update(X);const ie=le.digest();return M(ie),f(Z,te,ie),p(te,Q.subarray(32)),G(Z,te),m(R,Z),!k(Q,R)}t.verify=ae;function O(ee){let X=[i(),i(),i(),i()];if(F(X,ee))throw new Error("Ed25519: invalid public key");let Q=i(),R=i(),Z=X[1];K(Q,a,Z),J(R,a,Z),ue(R,R),T(Q,Q,R);let te=new Uint8Array(32);return D(te,Q),te}t.convertPublicKeyToX25519=O;function se(ee){const X=(0,r.hash)(ee.subarray(0,32));X[0]&=248,X[31]&=127,X[31]|=64;const Q=new Uint8Array(X.subarray(0,32));return(0,n.wipe)(X),Q}t.convertSecretKeyToX25519=se}(cm);const mD="EdDSA",vD="JWT",ld=".",hd="base64url",cx="utf8",ux="utf8",bD=":",yD="did",wD="key",fx="base58btc",xD="z",_D="K36",ED=32;function lx(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function dd(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=lx(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function SD(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,U=new Uint8Array(q);k!==$;){for(var K=P[k],J=0,T=q-1;(K!==0||J>>0,U[T]=K%a>>>0,K=K/a>>>0;if(K!==0)throw new Error("Non-zero carry");D=J,k++}for(var z=q-D;z!==q&&U[z]===0;)z++;for(var ue=u.repeat(N);z>>0,q=new Uint8Array($);P[N];){var U=r[P.charCodeAt(N)];if(U===255)return;for(var K=0,J=$-1;(U!==0||K>>0,q[J]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");k=K,N++}if(P[N]!==" "){for(var T=$-k;T!==$&&q[T]===0;)T++;for(var z=new Uint8Array(D+($-T)),ue=D;T!==$;)z[ue++]=q[T++];return z}}}function A(P){var N=y(P);if(N)return N;throw new Error(`Non-${e} character`)}return{encode:g,decodeUnsafe:y,decode:A}}var AD=SD,PD=AD;const MD=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},ID=t=>new TextEncoder().encode(t),CD=t=>new TextDecoder().decode(t);class TD{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class RD{constructor(e,r,n){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=n}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 hx(this,e)}}class DD{constructor(e){this.decoders=e}or(e){return hx(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const hx=(t,e)=>new DD({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class OD{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new TD(e,r,n),this.decoder=new RD(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const pd=({name:t,prefix:e,encode:r,decode:n})=>new OD(t,e,r,n),tl=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=PD(r,e);return pd({prefix:t,name:e,encode:n,decode:s=>MD(i(s))})},ND=(t,e,r,n)=>{const i={};for(let d=0;d=8&&(a-=8,o[l++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return o},LD=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<pd({prefix:e,name:t,encode(i){return LD(i,n,r)},decode(i){return ND(i,n,r,t)}}),kD=pd({prefix:"\0",name:"identity",encode:t=>CD(t),decode:t=>ID(t)}),$D=Object.freeze(Object.defineProperty({__proto__:null,identity:kD},Symbol.toStringTag,{value:"Module"})),BD=Fn({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),FD=Object.freeze(Object.defineProperty({__proto__:null,base2:BD},Symbol.toStringTag,{value:"Module"})),UD=Fn({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),jD=Object.freeze(Object.defineProperty({__proto__:null,base8:UD},Symbol.toStringTag,{value:"Module"})),qD=tl({prefix:"9",name:"base10",alphabet:"0123456789"}),zD=Object.freeze(Object.defineProperty({__proto__:null,base10:qD},Symbol.toStringTag,{value:"Module"})),HD=Fn({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),WD=Fn({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),KD=Object.freeze(Object.defineProperty({__proto__:null,base16:HD,base16upper:WD},Symbol.toStringTag,{value:"Module"})),VD=Fn({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),GD=Fn({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),YD=Fn({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),JD=Fn({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),XD=Fn({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ZD=Fn({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),QD=Fn({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),eO=Fn({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),tO=Fn({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),rO=Object.freeze(Object.defineProperty({__proto__:null,base32:VD,base32hex:XD,base32hexpad:QD,base32hexpadupper:eO,base32hexupper:ZD,base32pad:YD,base32padupper:JD,base32upper:GD,base32z:tO},Symbol.toStringTag,{value:"Module"})),nO=tl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),iO=tl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),sO=Object.freeze(Object.defineProperty({__proto__:null,base36:nO,base36upper:iO},Symbol.toStringTag,{value:"Module"})),oO=tl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),aO=tl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),cO=Object.freeze(Object.defineProperty({__proto__:null,base58btc:oO,base58flickr:aO},Symbol.toStringTag,{value:"Module"})),uO=Fn({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),fO=Fn({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),lO=Fn({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),hO=Fn({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),dO=Object.freeze(Object.defineProperty({__proto__:null,base64:uO,base64pad:fO,base64url:lO,base64urlpad:hO},Symbol.toStringTag,{value:"Module"})),dx=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),pO=dx.reduce((t,e,r)=>(t[r]=e,t),[]),gO=dx.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function mO(t){return t.reduce((e,r)=>(e+=pO[r],e),"")}function vO(t){const e=[];for(const r of t){const n=gO[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const bO=pd({prefix:"🚀",name:"base256emoji",encode:mO,decode:vO}),yO=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:bO},Symbol.toStringTag,{value:"Module"}));new TextEncoder,new TextDecoder;const px={...$D,...FD,...jD,...zD,...KD,...rO,...sO,...cO,...dO,...yO};function gx(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const mx=gx("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),dm=gx("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);const e=lx(t.length);for(let r=0;r"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new CO:typeof navigator<"u"?LO(navigator.userAgent):$O()}function NO(t){return t!==""&&DO.reduce(function(e,r){var n=r[0],i=r[1];if(e)return e;var s=i.exec(t);return!!s&&[n,s]},!1)}function LO(t){var e=NO(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new IO;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<_x&&(i=xx(xx([],i,!0),BO(_x-i.length),!0)):i=[];var s=i.join("."),o=kO(t),a=RO.exec(t);return a&&a[1]?new MO(r,s,o,a[1]):new AO(r,s,o)}function kO(t){for(var e=0,r=Ex.length;e-1){const D=P.getAttribute("href");if(D)if(D.toLowerCase().indexOf("https:")===-1&&D.toLowerCase().indexOf("http:")===-1&&D.indexOf("//")!==0){let k=e.protocol+"//"+e.host;if(D.indexOf("/")===0)k+=D;else{const $=e.pathname.split("/");$.pop();const q=$.join("/");k+=q+"/"+D}y.push(k)}else if(D.indexOf("//")===0){const k=e.protocol+D;y.push(k)}else y.push(D)}}return y}function n(...g){const y=t.getElementsByTagName("meta");for(let A=0;AP.getAttribute(D)).filter(D=>D?g.includes(D):!1);if(N.length&&N){const D=P.getAttribute("content");if(D)return D}}return""}function i(){let g=n("name","og:site_name","og:title","twitter:title");return g||(g=t.title),g}function s(){return n("description","og:description","twitter:description","keywords")}const o=i(),a=s(),u=e.origin,l=r();return{description:a,url:u,icons:l,name:o}}Ax=mm.getWindowMetadata=YO;var nl={},JO=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Mx="%[a-f0-9]{2}",Ix=new RegExp("("+Mx+")|([^%]+?)","gi"),Cx=new RegExp("("+Mx+")+","gi");function vm(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],vm(r),vm(n))}function XO(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Ix)||[],r=1;r{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},tN=function(t,e){for(var r={},n=Object.keys(t),i=Array.isArray(e),s=0;s$==null,o=Symbol("encodeFragmentIdentifier");function a($){switch($.arrayFormat){case"index":return q=>(U,K)=>{const J=U.length;return K===void 0||$.skipNull&&K===null||$.skipEmptyString&&K===""?U:K===null?[...U,[d(q,$),"[",J,"]"].join("")]:[...U,[d(q,$),"[",d(J,$),"]=",d(K,$)].join("")]};case"bracket":return q=>(U,K)=>K===void 0||$.skipNull&&K===null||$.skipEmptyString&&K===""?U:K===null?[...U,[d(q,$),"[]"].join("")]:[...U,[d(q,$),"[]=",d(K,$)].join("")];case"colon-list-separator":return q=>(U,K)=>K===void 0||$.skipNull&&K===null||$.skipEmptyString&&K===""?U:K===null?[...U,[d(q,$),":list="].join("")]:[...U,[d(q,$),":list=",d(K,$)].join("")];case"comma":case"separator":case"bracket-separator":{const q=$.arrayFormat==="bracket-separator"?"[]=":"=";return U=>(K,J)=>J===void 0||$.skipNull&&J===null||$.skipEmptyString&&J===""?K:(J=J===null?"":J,K.length===0?[[d(U,$),q,d(J,$)].join("")]:[[K,d(J,$)].join($.arrayFormatSeparator)])}default:return q=>(U,K)=>K===void 0||$.skipNull&&K===null||$.skipEmptyString&&K===""?U:K===null?[...U,d(q,$)]:[...U,[d(q,$),"=",d(K,$)].join("")]}}function u($){let q;switch($.arrayFormat){case"index":return(U,K,J)=>{if(q=/\[(\d*)\]$/.exec(U),U=U.replace(/\[\d*\]$/,""),!q){J[U]=K;return}J[U]===void 0&&(J[U]={}),J[U][q[1]]=K};case"bracket":return(U,K,J)=>{if(q=/(\[\])$/.exec(U),U=U.replace(/\[\]$/,""),!q){J[U]=K;return}if(J[U]===void 0){J[U]=[K];return}J[U]=[].concat(J[U],K)};case"colon-list-separator":return(U,K,J)=>{if(q=/(:list)$/.exec(U),U=U.replace(/:list$/,""),!q){J[U]=K;return}if(J[U]===void 0){J[U]=[K];return}J[U]=[].concat(J[U],K)};case"comma":case"separator":return(U,K,J)=>{const T=typeof K=="string"&&K.includes($.arrayFormatSeparator),z=typeof K=="string"&&!T&&g(K,$).includes($.arrayFormatSeparator);K=z?g(K,$):K;const ue=T||z?K.split($.arrayFormatSeparator).map(_e=>g(_e,$)):K===null?K:g(K,$);J[U]=ue};case"bracket-separator":return(U,K,J)=>{const T=/(\[\])$/.test(U);if(U=U.replace(/\[\]$/,""),!T){J[U]=K&&g(K,$);return}const z=K===null?[]:K.split($.arrayFormatSeparator).map(ue=>g(ue,$));if(J[U]===void 0){J[U]=z;return}J[U]=[].concat(J[U],z)};default:return(U,K,J)=>{if(J[U]===void 0){J[U]=K;return}J[U]=[].concat(J[U],K)}}}function l($){if(typeof $!="string"||$.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function d($,q){return q.encode?q.strict?e($):encodeURIComponent($):$}function g($,q){return q.decode?r($):$}function y($){return Array.isArray($)?$.sort():typeof $=="object"?y(Object.keys($)).sort((q,U)=>Number(q)-Number(U)).map(q=>$[q]):$}function A($){const q=$.indexOf("#");return q!==-1&&($=$.slice(0,q)),$}function P($){let q="";const U=$.indexOf("#");return U!==-1&&(q=$.slice(U)),q}function N($){$=A($);const q=$.indexOf("?");return q===-1?"":$.slice(q+1)}function D($,q){return q.parseNumbers&&!Number.isNaN(Number($))&&typeof $=="string"&&$.trim()!==""?$=Number($):q.parseBooleans&&$!==null&&($.toLowerCase()==="true"||$.toLowerCase()==="false")&&($=$.toLowerCase()==="true"),$}function k($,q){q=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},q),l(q.arrayFormatSeparator);const U=u(q),K=Object.create(null);if(typeof $!="string"||($=$.trim().replace(/^[?#&]/,""),!$))return K;for(const J of $.split("&")){if(J==="")continue;let[T,z]=n(q.decode?J.replace(/\+/g," "):J,"=");z=z===void 0?null:["comma","separator","bracket-separator"].includes(q.arrayFormat)?z:g(z,q),U(g(T,q),z,K)}for(const J of Object.keys(K)){const T=K[J];if(typeof T=="object"&&T!==null)for(const z of Object.keys(T))T[z]=D(T[z],q);else K[J]=D(T,q)}return q.sort===!1?K:(q.sort===!0?Object.keys(K).sort():Object.keys(K).sort(q.sort)).reduce((J,T)=>{const z=K[T];return z&&typeof z=="object"&&!Array.isArray(z)?J[T]=y(z):J[T]=z,J},Object.create(null))}t.extract=N,t.parse=k,t.stringify=($,q)=>{if(!$)return"";q=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},q),l(q.arrayFormatSeparator);const U=z=>q.skipNull&&s($[z])||q.skipEmptyString&&$[z]==="",K=a(q),J={};for(const z of Object.keys($))U(z)||(J[z]=$[z]);const T=Object.keys(J);return q.sort!==!1&&T.sort(q.sort),T.map(z=>{const ue=$[z];return ue===void 0?"":ue===null?d(z,q):Array.isArray(ue)?ue.length===0&&q.arrayFormat==="bracket-separator"?d(z,q)+"[]":ue.reduce(K(z),[]).join("&"):d(z,q)+"="+d(ue,q)}).filter(z=>z.length>0).join("&")},t.parseUrl=($,q)=>{q=Object.assign({decode:!0},q);const[U,K]=n($,"#");return Object.assign({url:U.split("?")[0]||"",query:k(N($),q)},q&&q.parseFragmentIdentifier&&K?{fragmentIdentifier:g(K,q)}:{})},t.stringifyUrl=($,q)=>{q=Object.assign({encode:!0,strict:!0,[o]:!0},q);const U=A($.url).split("?")[0]||"",K=t.extract($.url),J=t.parse(K,{sort:!1}),T=Object.assign(J,$.query);let z=t.stringify(T,q);z&&(z=`?${z}`);let ue=P($.url);return $.fragmentIdentifier&&(ue=`#${q[o]?d($.fragmentIdentifier,q):$.fragmentIdentifier}`),`${U}${z}${ue}`},t.pick=($,q,U)=>{U=Object.assign({parseFragmentIdentifier:!0,[o]:!1},U);const{url:K,query:J,fragmentIdentifier:T}=t.parseUrl($,U);return t.stringifyUrl({url:K,query:i(J,q),fragmentIdentifier:T},U)},t.exclude=($,q,U)=>{const K=Array.isArray(q)?J=>!q.includes(J):(J,T)=>!q(J,T);return t.pick($,K,U)}})(nl);var Tx={exports:{}};/** + ***************************************************************************** */var Hp=function(t,e){return Hp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i])},Hp(t,e)};function RC(t,e){Hp(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var Wp=function(){return Wp=Object.assign||function(e){for(var r,n=1,i=arguments.length;n=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function OC(t,e){return function(r,n){e(r,n,t)}}function NC(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function LC(t,e,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function a(h){try{u(n.next(h))}catch(g){o(g)}}function f(h){try{u(n.throw(h))}catch(g){o(g)}}function u(h){h.done?s(h.value):i(h.value).then(a,f)}u((n=n.apply(t,e||[])).next())})}function kC(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,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(h){return f([u,h])}}function f(u){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=u[0]&2?i.return:u[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;switch(i=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,i=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Jw(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function jC(){for(var t=[],e=0;e1||a(b,x)})})}function a(b,x){try{f(n[b](x))}catch(S){g(s[0][3],S)}}function f(b){b.value instanceof zu?Promise.resolve(b.value.v).then(u,h):g(s[0][2],b)}function u(b){a("next",b)}function h(b){a("throw",b)}function g(b,x){b(x),s.shift(),s.length&&a(s[0][0],s[0][1])}}function qC(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(o){return(r=!r)?{value:zu(t[i](o)),done:i==="return"}:s?s(o):o}:s}}function zC(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof Kp=="function"?Kp(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(o){return new Promise(function(a,f){o=t[s](o),i(a,f,o.done,o.value)})}}function i(s,o,a,f){Promise.resolve(f).then(function(u){s({value:u,done:a})},o)}}function HC(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function WC(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function KC(t){return t&&t.__esModule?t:{default:t}}function VC(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function GC(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}const Hu=ny(Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Wp},__asyncDelegator:qC,__asyncGenerator:$C,__asyncValues:zC,__await:zu,__awaiter:LC,__classPrivateFieldGet:VC,__classPrivateFieldSet:GC,__createBinding:BC,__decorate:DC,__exportStar:FC,__extends:RC,__generator:kC,__importDefault:KC,__importStar:WC,__makeTemplateObject:HC,__metadata:NC,__param:OC,__read:Jw,__rest:TC,__spread:jC,__spreadArrays:UC,__values:Kp},Symbol.toStringTag,{value:"Module"})));var Vp={},Wu={},Xw;function YC(){if(Xw)return Wu;Xw=1,Object.defineProperty(Wu,"__esModule",{value:!0}),Wu.delay=void 0;function t(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return Wu.delay=t,Wu}var ha={},Gp={},da={},Zw;function JC(){return Zw||(Zw=1,Object.defineProperty(da,"__esModule",{value:!0}),da.ONE_THOUSAND=da.ONE_HUNDRED=void 0,da.ONE_HUNDRED=100,da.ONE_THOUSAND=1e3),da}var Yp={},Qw;function XC(){return Qw||(Qw=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365})(Yp)),Yp}var e2;function t2(){return e2||(e2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Hu;e.__exportStar(JC(),t),e.__exportStar(XC(),t)})(Gp)),Gp}var r2;function ZC(){if(r2)return ha;r2=1,Object.defineProperty(ha,"__esModule",{value:!0}),ha.fromMiliseconds=ha.toMiliseconds=void 0;const t=t2();function e(n){return n*t.ONE_THOUSAND}ha.toMiliseconds=e;function r(n){return Math.floor(n/t.ONE_THOUSAND)}return ha.fromMiliseconds=r,ha}var n2;function QC(){return n2||(n2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Hu;e.__exportStar(YC(),t),e.__exportStar(ZC(),t)})(Vp)),Vp}var mc={},i2;function eR(){if(i2)return mc;i2=1,Object.defineProperty(mc,"__esModule",{value:!0}),mc.Watch=void 0;class t{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const n=this.get(r);if(typeof n.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const i=Date.now()-n.started;this.timestamps.set(r,{started:n.started,elapsed:i})}get(r){const n=this.timestamps.get(r);if(typeof n>"u")throw new Error(`No timestamp found for label: ${r}`);return n}elapsed(r){const n=this.get(r);return n.elapsed||Date.now()-n.started}}return mc.Watch=t,mc.default=t,mc}var Jp={},Ku={},s2;function tR(){if(s2)return Ku;s2=1,Object.defineProperty(Ku,"__esModule",{value:!0}),Ku.IWatch=void 0;class t{}return Ku.IWatch=t,Ku}var o2;function rR(){return o2||(o2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),Hu.__exportStar(tR(),t)})(Jp)),Jp}var a2;function nR(){return a2||(a2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Hu;e.__exportStar(QC(),t),e.__exportStar(eR(),t),e.__exportStar(rR(),t),e.__exportStar(t2(),t)})(zp)),zp}var vt=nR();class pa{}let iR=class extends pa{constructor(e){super()}};const c2=vt.FIVE_SECONDS,vc={pulse:"heartbeat_pulse"};let sR=class AA extends iR{constructor(e){super(e),this.events=new Di.EventEmitter,this.interval=c2,this.interval=e?.interval||c2}static async init(e){const r=new AA(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(),vt.toMiliseconds(this.interval))}pulse(){this.events.emit(vc.pulse)}};const oR=/"(?:_|\\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*:/,aR=/"(?: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*:/,cR=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function uR(t,e){if(t==="__proto__"||t==="constructor"&&e&&typeof e=="object"&&"prototype"in e){fR(t);return}return e}function fR(t){console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`)}function oh(t,e={}){if(typeof t!="string")return t;const r=t.trim();if(t[0]==='"'&&t.endsWith('"')&&!t.includes("\\"))return r.slice(1,-1);if(r.length<=9){const n=r.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;if(n==="undefined")return;if(n==="null")return null;if(n==="nan")return Number.NaN;if(n==="infinity")return Number.POSITIVE_INFINITY;if(n==="-infinity")return Number.NEGATIVE_INFINITY}if(!cR.test(t)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return t}try{if(oR.test(t)||aR.test(t)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(t,uR)}return JSON.parse(t)}catch(n){if(e.strict)throw n;return t}}function lR(t){return!t||typeof t.then!="function"?Promise.resolve(t):t}function Sn(t,...e){try{return lR(t(...e))}catch(r){return Promise.reject(r)}}function hR(t){const e=typeof t;return t===null||e!=="object"&&e!=="function"}function dR(t){const e=Object.getPrototypeOf(t);return!e||e.isPrototypeOf(Object)}function ah(t){if(hR(t))return String(t);if(dR(t)||Array.isArray(t))return JSON.stringify(t);if(typeof t.toJSON=="function")return ah(t.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function u2(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}const Xp="base64:";function pR(t){if(typeof t=="string")return t;u2();const e=Buffer.from(t).toString("base64");return Xp+e}function gR(t){return typeof t!="string"||!t.startsWith(Xp)?t:(u2(),Buffer.from(t.slice(Xp.length),"base64"))}function si(t){return t?t.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function mR(...t){return si(t.join(":"))}function ch(t){return t=si(t),t?t+":":""}function yne(t){return t}const vR="memory",bR=()=>{const t=new Map;return{name:vR,getInstance:()=>t,hasItem(e){return t.has(e)},getItem(e){return t.get(e)??null},getItemRaw(e){return t.get(e)??null},setItem(e,r){t.set(e,r)},setItemRaw(e,r){t.set(e,r)},removeItem(e){t.delete(e)},getKeys(){return[...t.keys()]},clear(){t.clear()},dispose(){t.clear()}}};function yR(t={}){const e={mounts:{"":t.driver||bR()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=u=>{for(const h of e.mountpoints)if(u.startsWith(h))return{base:h,relativeKey:u.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:u,driver:e.mounts[""]}},n=(u,h)=>e.mountpoints.filter(g=>g.startsWith(u)||h&&u.startsWith(g)).map(g=>({relativeBase:u.length>g.length?u.slice(g.length):void 0,mountpoint:g,driver:e.mounts[g]})),i=(u,h)=>{if(e.watching){h=si(h);for(const g of e.watchListeners)g(u,h)}},s=async()=>{if(!e.watching){e.watching=!0;for(const u in e.mounts)e.unwatch[u]=await f2(e.mounts[u],i,u)}},o=async()=>{if(e.watching){for(const u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},a=(u,h,g)=>{const b=new Map,x=S=>{let C=b.get(S.base);return C||(C={driver:S.driver,base:S.base,items:[]},b.set(S.base,C)),C};for(const S of u){const C=typeof S=="string",D=si(C?S:S.key),B=C?void 0:S.value,L=C||!S.options?h:{...h,...S.options},H=r(D);x(H).items.push({key:D,value:B,relativeKey:H.relativeKey,options:L})}return Promise.all([...b.values()].map(S=>g(S))).then(S=>S.flat())},f={hasItem(u,h={}){u=si(u);const{relativeKey:g,driver:b}=r(u);return Sn(b.hasItem,g,h)},getItem(u,h={}){u=si(u);const{relativeKey:g,driver:b}=r(u);return Sn(b.getItem,g,h).then(x=>oh(x))},getItems(u,h){return a(u,h,g=>g.driver.getItems?Sn(g.driver.getItems,g.items.map(b=>({key:b.relativeKey,options:b.options})),h).then(b=>b.map(x=>({key:mR(g.base,x.key),value:oh(x.value)}))):Promise.all(g.items.map(b=>Sn(g.driver.getItem,b.relativeKey,b.options).then(x=>({key:b.key,value:oh(x)})))))},getItemRaw(u,h={}){u=si(u);const{relativeKey:g,driver:b}=r(u);return b.getItemRaw?Sn(b.getItemRaw,g,h):Sn(b.getItem,g,h).then(x=>gR(x))},async setItem(u,h,g={}){if(h===void 0)return f.removeItem(u);u=si(u);const{relativeKey:b,driver:x}=r(u);x.setItem&&(await Sn(x.setItem,b,ah(h),g),x.watch||i("update",u))},async setItems(u,h){await a(u,h,async g=>{if(g.driver.setItems)return Sn(g.driver.setItems,g.items.map(b=>({key:b.relativeKey,value:ah(b.value),options:b.options})),h);g.driver.setItem&&await Promise.all(g.items.map(b=>Sn(g.driver.setItem,b.relativeKey,ah(b.value),b.options)))})},async setItemRaw(u,h,g={}){if(h===void 0)return f.removeItem(u,g);u=si(u);const{relativeKey:b,driver:x}=r(u);if(x.setItemRaw)await Sn(x.setItemRaw,b,h,g);else if(x.setItem)await Sn(x.setItem,b,pR(h),g);else return;x.watch||i("update",u)},async removeItem(u,h={}){typeof h=="boolean"&&(h={removeMeta:h}),u=si(u);const{relativeKey:g,driver:b}=r(u);b.removeItem&&(await Sn(b.removeItem,g,h),(h.removeMeta||h.removeMata)&&await Sn(b.removeItem,g+"$",h),b.watch||i("remove",u))},async getMeta(u,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),u=si(u);const{relativeKey:g,driver:b}=r(u),x=Object.create(null);if(b.getMeta&&Object.assign(x,await Sn(b.getMeta,g,h)),!h.nativeOnly){const S=await Sn(b.getItem,g+"$",h).then(C=>oh(C));S&&typeof S=="object"&&(typeof S.atime=="string"&&(S.atime=new Date(S.atime)),typeof S.mtime=="string"&&(S.mtime=new Date(S.mtime)),Object.assign(x,S))}return x},setMeta(u,h,g={}){return this.setItem(u+"$",h,g)},removeMeta(u,h={}){return this.removeItem(u+"$",h)},async getKeys(u,h={}){u=ch(u);const g=n(u,!0);let b=[];const x=[];for(const S of g){const C=await Sn(S.driver.getKeys,S.relativeBase,h);for(const D of C){const B=S.mountpoint+si(D);b.some(L=>B.startsWith(L))||x.push(B)}b=[S.mountpoint,...b.filter(D=>!D.startsWith(S.mountpoint))]}return u?x.filter(S=>S.startsWith(u)&&S[S.length-1]!=="$"):x.filter(S=>S[S.length-1]!=="$")},async clear(u,h={}){u=ch(u),await Promise.all(n(u,!1).map(async g=>{if(g.driver.clear)return Sn(g.driver.clear,g.relativeBase,h);if(g.driver.removeItem){const b=await g.driver.getKeys(g.relativeBase||"",h);return Promise.all(b.map(x=>g.driver.removeItem(x,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>l2(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,h){if(u=ch(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((g,b)=>b.length-g.length)),e.mounts[u]=h,e.watching&&Promise.resolve(f2(h,i,u)).then(g=>{e.unwatch[u]=g}).catch(console.error),f},async unmount(u,h=!0){u=ch(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u](),delete e.unwatch[u]),h&&await l2(e.mounts[u]),e.mountpoints=e.mountpoints.filter(g=>g!==u),delete e.mounts[u])},getMount(u=""){u=si(u)+":";const h=r(u);return{driver:h.driver,base:h.base}},getMounts(u="",h={}){return u=si(u),n(u,h.parents).map(b=>({driver:b.driver,base:b.mountpoint}))},keys:(u,h={})=>f.getKeys(u,h),get:(u,h={})=>f.getItem(u,h),set:(u,h,g={})=>f.setItem(u,h,g),has:(u,h={})=>f.hasItem(u,h),del:(u,h={})=>f.removeItem(u,h),remove:(u,h={})=>f.removeItem(u,h)};return f}function f2(t,e,r){return t.watch?t.watch((n,i)=>e(n,r+i)):()=>{}}async function l2(t){typeof t.dispose=="function"&&await Sn(t.dispose)}function ga(t){return new Promise((e,r)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>r(t.error)})}function h2(t,e){const r=indexedDB.open(t);r.onupgradeneeded=()=>r.result.createObjectStore(e);const n=ga(r);return(i,s)=>n.then(o=>s(o.transaction(e,i).objectStore(e)))}let Zp;function Vu(){return Zp||(Zp=h2("keyval-store","keyval")),Zp}function d2(t,e=Vu()){return e("readonly",r=>ga(r.get(t)))}function wR(t,e,r=Vu()){return r("readwrite",n=>(n.put(e,t),ga(n.transaction)))}function xR(t,e=Vu()){return e("readwrite",r=>(r.delete(t),ga(r.transaction)))}function _R(t=Vu()){return t("readwrite",e=>(e.clear(),ga(e.transaction)))}function ER(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},ga(t.transaction)}function SR(t=Vu()){return t("readonly",e=>{if(e.getAllKeys)return ga(e.getAllKeys());const r=[];return ER(e,n=>r.push(n.key)).then(()=>r)})}const AR=t=>JSON.stringify(t,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),PR=t=>{const 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=t.replace(e,'$1"$2n"$3');return JSON.parse(r,(n,i)=>typeof i=="string"&&i.match(/^\d+n$/)?BigInt(i.substring(0,i.length-1)):i)};function ma(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return PR(t)}catch{return t}}function Hs(t){return typeof t=="string"?t:AR(t)||""}const IR="idb-keyval";var MR=(t={})=>{const e=t.base&&t.base.length>0?`${t.base}:`:"",r=i=>e+i;let n;return t.dbName&&t.storeName&&(n=h2(t.dbName,t.storeName)),{name:IR,options:t,async hasItem(i){return!(typeof await d2(r(i),n)>"u")},async getItem(i){return await d2(r(i),n)??null},setItem(i,s){return wR(r(i),s,n)},removeItem(i){return xR(r(i),n)},getKeys(){return SR(n)},clear(){return _R(n)}}};const CR="WALLET_CONNECT_V2_INDEXED_DB",RR="keyvaluestorage";let TR=class{constructor(){this.indexedDb=yR({driver:MR({dbName:CR,storeName:RR})})}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){const r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,Hs(r))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Qp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},uh={exports:{}};(function(){let t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Qp<"u"&&Qp.localStorage?uh.exports=Qp.localStorage:typeof window<"u"&&window.localStorage?uh.exports=window.localStorage:uh.exports=new e})();function DR(t){var e;return[t[0],ma((e=t[1])!=null?e:"")]}let OR=class{constructor(){this.localStorage=uh.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(DR)}async getItem(e){const r=this.localStorage.getItem(e);if(r!==null)return ma(r)}async setItem(e,r){this.localStorage.setItem(e,Hs(r))}async removeItem(e){this.localStorage.removeItem(e)}};const NR="wc_storage_version",p2=1,LR=async(t,e,r)=>{const n=NR,i=await e.getItem(n);if(i&&i>=p2){r(e);return}const s=await t.getKeys();if(!s.length){r(e);return}const o=[];for(;s.length;){const a=s.shift();if(!a)continue;const f=a.toLowerCase();if(f.includes("wc@")||f.includes("walletconnect")||f.includes("wc_")||f.includes("wallet_connect")){const u=await t.getItem(a);await e.setItem(a,u),o.push(a)}}await e.setItem(n,p2),r(e),kR(t,o)},kR=async(t,e)=>{e.length&&e.forEach(async r=>{await t.removeItem(r)})};let BR=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const e=new OR;this.storage=e;try{const r=new TR;LR(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=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}};var eg,g2;function FR(){if(g2)return eg;g2=1;function t(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}eg=e;function e(r,n,i){var s=i&&i.stringify||t,o=1;if(typeof r=="object"&&r!==null){var a=n.length+o;if(a===1)return r;var f=new Array(a);f[0]=s(r);for(var u=1;u-1?x:0,r.charCodeAt(C+1)){case 100:case 102:if(b>=h||n[b]==null)break;x=h||n[b]==null)break;x=h||n[b]===void 0)break;x",x=C+2,C++;break}g+=s(n[b]),x=C+2,C++;break;case 115:if(b>=h)break;x-1&&(q=!1);const _=["error","fatal","warn","info","debug","trace"];typeof W=="function"&&(W.error=W.fatal=W.warn=W.info=W.debug=W.trace=W),$.enabled===!1&&($.level="silent");const v=$.level||"info",l=Object.create(W);l.log||(l.log=D),Object.defineProperty(l,"levelVal",{get:m}),Object.defineProperty(l,"level",{get:y,set:A});const p={transmit:R,serialize:X,asObject:$.browser.asObject,levels:_,timestamp:x($)};l.levels=i.levels,l.level=v,l.setMaxListeners=l.getMaxListeners=l.emit=l.addListener=l.on=l.prependListener=l.once=l.prependOnceListener=l.removeListener=l.removeAllListeners=l.listeners=l.listenerCount=l.eventNames=l.write=l.flush=D,l.serializers=V,l._serialize=X,l._stdErrSerialize=q,l.child=E,R&&(l._logEvent=g());function m(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function A(w){if(w!=="silent"&&!this.levels.values[w])throw Error("unknown level "+w);this._level=w,s(p,l,"error","log"),s(p,l,"fatal","error"),s(p,l,"warn","error"),s(p,l,"info","log"),s(p,l,"debug","log"),s(p,l,"trace","log")}function E(w,I){if(!w)throw new Error("missing bindings for child Pino");I=I||{},X&&w.serializers&&(I.serializers=w.serializers);const M=I.serializers;if(X&&M){var z=Object.assign({},V,M),se=$.browser.serialize===!0?Object.keys(z):X;delete w.serializers,f([w],se,z,this._stdErrSerialize)}function O(ie){this._childLevel=(ie._childLevel|0)+1,this.error=u(ie,w,"error"),this.fatal=u(ie,w,"fatal"),this.warn=u(ie,w,"warn"),this.info=u(ie,w,"info"),this.debug=u(ie,w,"debug"),this.trace=u(ie,w,"trace"),z&&(this.serializers=z,this._serialize=se),R&&(this._logEvent=g([].concat(ie._logEvent.bindings,w)))}return O.prototype=this,new O(this)}return l}i.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"}},i.stdSerializers=r,i.stdTimeFunctions=Object.assign({},{nullTime:B,epochTime:L,unixTime:H,isoTime:F});function s($,R,W,V){const X=Object.getPrototypeOf(R);R[W]=R.levelVal>R.levels.values[W]?D:X[W]?X[W]:e[W]||e[V]||D,o($,R,W)}function o($,R,W){!$.transmit&&R[W]===D||(R[W]=(function(V){return function(){const q=$.timestamp(),_=new Array(arguments.length),v=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var l=0;l<_.length;l++)_[l]=arguments[l];if($.serialize&&!$.asObject&&f(_,this._serialize,this.serializers,this._stdErrSerialize),$.asObject?V.call(v,a(this,W,_,q)):V.apply(v,_),$.transmit){const p=$.transmit.level||R.level,m=i.levels.values[p],y=i.levels.values[W];if(y-1&&q in W&&($[X][q]=W[q]($[X][q]))}function u($,R,W){return function(){const V=new Array(1+arguments.length);V[0]=R;for(var X=1;Xthis.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;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let 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};const r=e.value;return e=e.next,{done:!1,value:r}}}}},b2=class{constructor(e,r=rg){this.level=e??"error",this.levelValue=bc.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new v2(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===bc.levels.values.error?console.error(e):r===bc.levels.values.warn?console.warn(e):r===bc.levels.values.debug?console.debug(e):r===bc.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Hs({timestamp:new Date().toISOString(),log:e}));const 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 v2(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const r=this.getLogArray();return r.push(Hs({extraMetadata:e})),new Blob(r,{type:"application/json"})}},qR=class{constructor(e,r=rg){this.baseChunkLogger=new b2(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){const r=URL.createObjectURL(this.logsToBlob(e)),n=document.createElement("a");n.href=r,n.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}},zR=class{constructor(e,r=rg){this.baseChunkLogger=new b2(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)}};var HR=Object.defineProperty,WR=Object.defineProperties,KR=Object.getOwnPropertyDescriptors,y2=Object.getOwnPropertySymbols,VR=Object.prototype.hasOwnProperty,GR=Object.prototype.propertyIsEnumerable,w2=(t,e,r)=>e in t?HR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fh=(t,e)=>{for(var r in e||(e={}))VR.call(e,r)&&w2(t,r,e[r]);if(y2)for(var r of y2(e))GR.call(e,r)&&w2(t,r,e[r]);return t},lh=(t,e)=>WR(t,KR(e));function hh(t){return lh(fh({},t),{level:t?.level||UR.level})}function YR(t,e=Yu){return t[e]||""}function JR(t,e,r=Yu){return t[r]=e,t}function oi(t,e=Yu){let r="";return typeof t.bindings>"u"?r=YR(t,e):r=t.bindings().context||"",r}function XR(t,e,r=Yu){const n=oi(t,r);return n.trim()?`${n}/${e}`:e}function Vn(t,e,r=Yu){const n=XR(t,e,r),i=t.child({context:n});return JR(i,n,r)}function ZR(t){var e,r;const n=new qR((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Gu(lh(fh({},t.opts),{level:"trace",browser:lh(fh({},(r=t.opts)==null?void 0:r.browser),{write:i=>n.write(i)})})),chunkLoggerController:n}}function QR(t){var e;const r=new zR((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Gu(lh(fh({},t.opts),{level:"trace"}),r),chunkLoggerController:r}}function eT(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?ZR(t):QR(t)}let tT=class extends pa{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},rT=class extends pa{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}},nT=class{constructor(e,r){this.logger=e,this.core=r}},iT=class extends pa{constructor(e,r){super(),this.relayer=e,this.logger=r}},sT=class extends pa{constructor(e){super()}},oT=class{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}},aT=class extends pa{constructor(e,r){super(),this.relayer=e,this.logger=r}},cT=class extends pa{constructor(e,r){super(),this.core=e,this.logger=r}},uT=class{constructor(e,r,n){this.core=e,this.logger=r,this.store=n}},fT=class{constructor(e,r){this.projectId=e,this.logger=r}},lT=class{constructor(e,r,n){this.core=e,this.logger=r,this.telemetryEnabled=n}},hT=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},dT=class{constructor(e){this.client=e}};var ng={},ig={},Ju={},Xu={},x2;function pT(){if(x2)return Xu;x2=1,Object.defineProperty(Xu,"__esModule",{value:!0}),Xu.BrowserRandomSource=void 0;const t=65536;class e{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const n=typeof self<"u"?self.crypto||self.msCrypto:null;n&&n.getRandomValues!==void 0&&(this._crypto=n,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(n){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const i=new Uint8Array(n);for(let s=0;s>>16&65535,h=a&65535,g=f>>>16&65535,b=f&65535;return h*b+(u*b+h*g<<16>>>0)|0}t.mul=Math.imul||e;function r(a,f){return a+f|0}t.add=r;function n(a,f){return a-f|0}t.sub=n;function i(a,f){return a<>>32-f}t.rotl=i;function s(a,f){return a<<32-f|a>>>f}t.rotr=s;function o(a){return typeof a=="number"&&isFinite(a)&&Math.floor(a)===a}t.isInteger=Number.isInteger||o,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(a){return t.isInteger(a)&&a>=-t.MAX_SAFE_INTEGER&&a<=t.MAX_SAFE_INTEGER}})(sg)),sg}var I2;function ef(){if(I2)return lr;I2=1,Object.defineProperty(lr,"__esModule",{value:!0});var t=vT();function e(p,m){return m===void 0&&(m=0),(p[m+0]<<8|p[m+1])<<16>>16}lr.readInt16BE=e;function r(p,m){return m===void 0&&(m=0),(p[m+0]<<8|p[m+1])>>>0}lr.readUint16BE=r;function n(p,m){return m===void 0&&(m=0),(p[m+1]<<8|p[m])<<16>>16}lr.readInt16LE=n;function i(p,m){return m===void 0&&(m=0),(p[m+1]<<8|p[m])>>>0}lr.readUint16LE=i;function s(p,m,y){return m===void 0&&(m=new Uint8Array(2)),y===void 0&&(y=0),m[y+0]=p>>>8,m[y+1]=p>>>0,m}lr.writeUint16BE=s,lr.writeInt16BE=s;function o(p,m,y){return m===void 0&&(m=new Uint8Array(2)),y===void 0&&(y=0),m[y+0]=p>>>0,m[y+1]=p>>>8,m}lr.writeUint16LE=o,lr.writeInt16LE=o;function a(p,m){return m===void 0&&(m=0),p[m]<<24|p[m+1]<<16|p[m+2]<<8|p[m+3]}lr.readInt32BE=a;function f(p,m){return m===void 0&&(m=0),(p[m]<<24|p[m+1]<<16|p[m+2]<<8|p[m+3])>>>0}lr.readUint32BE=f;function u(p,m){return m===void 0&&(m=0),p[m+3]<<24|p[m+2]<<16|p[m+1]<<8|p[m]}lr.readInt32LE=u;function h(p,m){return m===void 0&&(m=0),(p[m+3]<<24|p[m+2]<<16|p[m+1]<<8|p[m])>>>0}lr.readUint32LE=h;function g(p,m,y){return m===void 0&&(m=new Uint8Array(4)),y===void 0&&(y=0),m[y+0]=p>>>24,m[y+1]=p>>>16,m[y+2]=p>>>8,m[y+3]=p>>>0,m}lr.writeUint32BE=g,lr.writeInt32BE=g;function b(p,m,y){return m===void 0&&(m=new Uint8Array(4)),y===void 0&&(y=0),m[y+0]=p>>>0,m[y+1]=p>>>8,m[y+2]=p>>>16,m[y+3]=p>>>24,m}lr.writeUint32LE=b,lr.writeInt32LE=b;function x(p,m){m===void 0&&(m=0);var y=a(p,m),A=a(p,m+4);return y*4294967296+A-(A>>31)*4294967296}lr.readInt64BE=x;function S(p,m){m===void 0&&(m=0);var y=f(p,m),A=f(p,m+4);return y*4294967296+A}lr.readUint64BE=S;function C(p,m){m===void 0&&(m=0);var y=u(p,m),A=u(p,m+4);return A*4294967296+y-(y>>31)*4294967296}lr.readInt64LE=C;function D(p,m){m===void 0&&(m=0);var y=h(p,m),A=h(p,m+4);return A*4294967296+y}lr.readUint64LE=D;function B(p,m,y){return m===void 0&&(m=new Uint8Array(8)),y===void 0&&(y=0),g(p/4294967296>>>0,m,y),g(p>>>0,m,y+4),m}lr.writeUint64BE=B,lr.writeInt64BE=B;function L(p,m,y){return m===void 0&&(m=new Uint8Array(8)),y===void 0&&(y=0),b(p>>>0,m,y),b(p/4294967296>>>0,m,y+4),m}lr.writeUint64LE=L,lr.writeInt64LE=L;function H(p,m,y){if(y===void 0&&(y=0),p%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(p/8>m.length-y)throw new Error("readUintBE: array is too short for the given bitLength");for(var A=0,E=1,w=p/8+y-1;w>=y;w--)A+=m[w]*E,E*=256;return A}lr.readUintBE=H;function F(p,m,y){if(y===void 0&&(y=0),p%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(p/8>m.length-y)throw new Error("readUintLE: array is too short for the given bitLength");for(var A=0,E=1,w=y;w=A;w--)y[w]=m/E&255,E*=256;return y}lr.writeUintBE=k;function $(p,m,y,A){if(y===void 0&&(y=new Uint8Array(p/8)),A===void 0&&(A=0),p%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!t.isSafeInteger(m))throw new Error("writeUintLE value must be an integer");for(var E=1,w=A;w256)throw new Error("randomString charset is too long");let b="";const x=h.length,S=256-256%x;for(;u>0;){const C=i(Math.ceil(u*256/S),g);for(let D=0;D0;D++){const B=C[D];B0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=f[h++],u--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(u>=this.blockSize&&(h=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,f,h,u),u%=this.blockSize);u>0;)this._buffer[this._bufferLength++]=f[h++],u--;return this},a.prototype.finish=function(f){if(!this._finished){var u=this._bytesHashed,h=this._bufferLength,g=u/536870912|0,b=u<<3,x=u%128<112?128:256;this._buffer[h]=128;for(var S=h+1;S0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(f){return this._stateHi.set(f.stateHi),this._stateLo.set(f.stateLo),this._bufferLength=f.bufferLength,f.buffer&&this._buffer.set(f.buffer),this._bytesHashed=f.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(f){r.wipe(f.stateHi),r.wipe(f.stateLo),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},a})();t.SHA512=n;var i=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 s(a,f,u,h,g,b,x){for(var S=u[0],C=u[1],D=u[2],B=u[3],L=u[4],H=u[5],F=u[6],k=u[7],$=h[0],R=h[1],W=h[2],V=h[3],X=h[4],q=h[5],_=h[6],v=h[7],l,p,m,y,A,E,w,I;x>=128;){for(var M=0;M<16;M++){var z=8*M+b;a[M]=e.readUint32BE(g,z),f[M]=e.readUint32BE(g,z+4)}for(var M=0;M<80;M++){var se=S,O=C,ie=D,ee=B,Z=L,te=H,N=F,Q=k,ne=$,de=R,ce=W,fe=V,be=X,Pe=q,De=_,Te=v;if(l=k,p=v,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=(L>>>14|X<<18)^(L>>>18|X<<14)^(X>>>9|L<<23),p=(X>>>14|L<<18)^(X>>>18|L<<14)^(L>>>9|X<<23),A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,l=L&H^~L&F,p=X&q^~X&_,A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,l=i[M*2],p=i[M*2+1],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,l=a[M%16],p=f[M%16],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,m=w&65535|I<<16,y=A&65535|E<<16,l=m,p=y,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=(S>>>28|$<<4)^($>>>2|S<<30)^($>>>7|S<<25),p=($>>>28|S<<4)^(S>>>2|$<<30)^(S>>>7|$<<25),A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,l=S&C^S&D^C&D,p=$&R^$&W^R&W,A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,Q=w&65535|I<<16,Te=A&65535|E<<16,l=ee,p=fe,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=m,p=y,A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,ee=w&65535|I<<16,fe=A&65535|E<<16,C=se,D=O,B=ie,L=ee,H=Z,F=te,k=N,S=Q,R=ne,W=de,V=ce,X=fe,q=be,_=Pe,v=De,$=Te,M%16===15)for(var z=0;z<16;z++)l=a[z],p=f[z],A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=a[(z+9)%16],p=f[(z+9)%16],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,m=a[(z+1)%16],y=f[(z+1)%16],l=(m>>>1|y<<31)^(m>>>8|y<<24)^m>>>7,p=(y>>>1|m<<31)^(y>>>8|m<<24)^(y>>>7|m<<25),A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,m=a[(z+14)%16],y=f[(z+14)%16],l=(m>>>19|y<<13)^(y>>>29|m<<3)^m>>>6,p=(y>>>19|m<<13)^(m>>>29|y<<3)^(y>>>6|m<<26),A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,a[z]=w&65535|I<<16,f[z]=A&65535|E<<16}l=S,p=$,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=u[0],p=h[0],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,u[0]=S=w&65535|I<<16,h[0]=$=A&65535|E<<16,l=C,p=R,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=u[1],p=h[1],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,u[1]=C=w&65535|I<<16,h[1]=R=A&65535|E<<16,l=D,p=W,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=u[2],p=h[2],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,u[2]=D=w&65535|I<<16,h[2]=W=A&65535|E<<16,l=B,p=V,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=u[3],p=h[3],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,u[3]=B=w&65535|I<<16,h[3]=V=A&65535|E<<16,l=L,p=X,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=u[4],p=h[4],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,u[4]=L=w&65535|I<<16,h[4]=X=A&65535|E<<16,l=H,p=q,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=u[5],p=h[5],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,u[5]=H=w&65535|I<<16,h[5]=q=A&65535|E<<16,l=F,p=_,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=u[6],p=h[6],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,u[6]=F=w&65535|I<<16,h[6]=_=A&65535|E<<16,l=k,p=v,A=p&65535,E=p>>>16,w=l&65535,I=l>>>16,l=u[7],p=h[7],A+=p&65535,E+=p>>>16,w+=l&65535,I+=l>>>16,E+=A>>>16,w+=E>>>16,I+=w>>>16,u[7]=k=w&65535|I<<16,h[7]=v=A&65535|E<<16,b+=128,x-=128}return b}function o(a){var f=new n;f.update(a);var u=f.digest();return f.clean(),u}t.hash=o})(ag)),ag}var R2;function yT(){return R2||(R2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertSecretKeyToX25519=t.convertPublicKeyToX25519=t.verify=t.sign=t.extractPublicKeyFromSecretKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.SEED_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=t.SIGNATURE_LENGTH=void 0;const e=og(),r=bT(),n=ns();t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(ee){const Z=new Float64Array(16);if(ee)for(let te=0;te>16&1),te[de-1]&=65535;te[15]=N[15]-32767-(te[14]>>16&1);const ne=te[15]>>16&1;te[14]&=65535,C(N,te,1-ne)}for(let Q=0;Q<16;Q++)ee[2*Q]=N[Q]&255,ee[2*Q+1]=N[Q]>>8}function B(ee,Z){let te=0;for(let N=0;N<32;N++)te|=ee[N]^Z[N];return(1&te-1>>>8)-1}function L(ee,Z){const te=new Uint8Array(32),N=new Uint8Array(32);return D(te,ee),D(N,Z),B(te,N)}function H(ee){const Z=new Uint8Array(32);return D(Z,ee),Z[0]&1}function F(ee,Z){for(let te=0;te<16;te++)ee[te]=Z[2*te]+(Z[2*te+1]<<8);ee[15]&=32767}function k(ee,Z,te){for(let N=0;N<16;N++)ee[N]=Z[N]+te[N]}function $(ee,Z,te){for(let N=0;N<16;N++)ee[N]=Z[N]-te[N]}function R(ee,Z,te){let N,Q,ne=0,de=0,ce=0,fe=0,be=0,Pe=0,De=0,Te=0,Fe=0,Me=0,Ne=0,He=0,Oe=0,$e=0,qe=0,_e=0,Qe=0,at=0,Be=0,nt=0,it=0,Ye=0,pt=0,ht=0,ft=0,Ht=0,Jt=0,St=0,Xt=0,tr=0,Dt=0,Bt=te[0],Ct=te[1],gt=te[2],Ot=te[3],Lt=te[4],bt=te[5],jt=te[6],Ut=te[7],tt=te[8],Ft=te[9],K=te[10],G=te[11],J=te[12],T=te[13],j=te[14],oe=te[15];N=Z[0],ne+=N*Bt,de+=N*Ct,ce+=N*gt,fe+=N*Ot,be+=N*Lt,Pe+=N*bt,De+=N*jt,Te+=N*Ut,Fe+=N*tt,Me+=N*Ft,Ne+=N*K,He+=N*G,Oe+=N*J,$e+=N*T,qe+=N*j,_e+=N*oe,N=Z[1],de+=N*Bt,ce+=N*Ct,fe+=N*gt,be+=N*Ot,Pe+=N*Lt,De+=N*bt,Te+=N*jt,Fe+=N*Ut,Me+=N*tt,Ne+=N*Ft,He+=N*K,Oe+=N*G,$e+=N*J,qe+=N*T,_e+=N*j,Qe+=N*oe,N=Z[2],ce+=N*Bt,fe+=N*Ct,be+=N*gt,Pe+=N*Ot,De+=N*Lt,Te+=N*bt,Fe+=N*jt,Me+=N*Ut,Ne+=N*tt,He+=N*Ft,Oe+=N*K,$e+=N*G,qe+=N*J,_e+=N*T,Qe+=N*j,at+=N*oe,N=Z[3],fe+=N*Bt,be+=N*Ct,Pe+=N*gt,De+=N*Ot,Te+=N*Lt,Fe+=N*bt,Me+=N*jt,Ne+=N*Ut,He+=N*tt,Oe+=N*Ft,$e+=N*K,qe+=N*G,_e+=N*J,Qe+=N*T,at+=N*j,Be+=N*oe,N=Z[4],be+=N*Bt,Pe+=N*Ct,De+=N*gt,Te+=N*Ot,Fe+=N*Lt,Me+=N*bt,Ne+=N*jt,He+=N*Ut,Oe+=N*tt,$e+=N*Ft,qe+=N*K,_e+=N*G,Qe+=N*J,at+=N*T,Be+=N*j,nt+=N*oe,N=Z[5],Pe+=N*Bt,De+=N*Ct,Te+=N*gt,Fe+=N*Ot,Me+=N*Lt,Ne+=N*bt,He+=N*jt,Oe+=N*Ut,$e+=N*tt,qe+=N*Ft,_e+=N*K,Qe+=N*G,at+=N*J,Be+=N*T,nt+=N*j,it+=N*oe,N=Z[6],De+=N*Bt,Te+=N*Ct,Fe+=N*gt,Me+=N*Ot,Ne+=N*Lt,He+=N*bt,Oe+=N*jt,$e+=N*Ut,qe+=N*tt,_e+=N*Ft,Qe+=N*K,at+=N*G,Be+=N*J,nt+=N*T,it+=N*j,Ye+=N*oe,N=Z[7],Te+=N*Bt,Fe+=N*Ct,Me+=N*gt,Ne+=N*Ot,He+=N*Lt,Oe+=N*bt,$e+=N*jt,qe+=N*Ut,_e+=N*tt,Qe+=N*Ft,at+=N*K,Be+=N*G,nt+=N*J,it+=N*T,Ye+=N*j,pt+=N*oe,N=Z[8],Fe+=N*Bt,Me+=N*Ct,Ne+=N*gt,He+=N*Ot,Oe+=N*Lt,$e+=N*bt,qe+=N*jt,_e+=N*Ut,Qe+=N*tt,at+=N*Ft,Be+=N*K,nt+=N*G,it+=N*J,Ye+=N*T,pt+=N*j,ht+=N*oe,N=Z[9],Me+=N*Bt,Ne+=N*Ct,He+=N*gt,Oe+=N*Ot,$e+=N*Lt,qe+=N*bt,_e+=N*jt,Qe+=N*Ut,at+=N*tt,Be+=N*Ft,nt+=N*K,it+=N*G,Ye+=N*J,pt+=N*T,ht+=N*j,ft+=N*oe,N=Z[10],Ne+=N*Bt,He+=N*Ct,Oe+=N*gt,$e+=N*Ot,qe+=N*Lt,_e+=N*bt,Qe+=N*jt,at+=N*Ut,Be+=N*tt,nt+=N*Ft,it+=N*K,Ye+=N*G,pt+=N*J,ht+=N*T,ft+=N*j,Ht+=N*oe,N=Z[11],He+=N*Bt,Oe+=N*Ct,$e+=N*gt,qe+=N*Ot,_e+=N*Lt,Qe+=N*bt,at+=N*jt,Be+=N*Ut,nt+=N*tt,it+=N*Ft,Ye+=N*K,pt+=N*G,ht+=N*J,ft+=N*T,Ht+=N*j,Jt+=N*oe,N=Z[12],Oe+=N*Bt,$e+=N*Ct,qe+=N*gt,_e+=N*Ot,Qe+=N*Lt,at+=N*bt,Be+=N*jt,nt+=N*Ut,it+=N*tt,Ye+=N*Ft,pt+=N*K,ht+=N*G,ft+=N*J,Ht+=N*T,Jt+=N*j,St+=N*oe,N=Z[13],$e+=N*Bt,qe+=N*Ct,_e+=N*gt,Qe+=N*Ot,at+=N*Lt,Be+=N*bt,nt+=N*jt,it+=N*Ut,Ye+=N*tt,pt+=N*Ft,ht+=N*K,ft+=N*G,Ht+=N*J,Jt+=N*T,St+=N*j,Xt+=N*oe,N=Z[14],qe+=N*Bt,_e+=N*Ct,Qe+=N*gt,at+=N*Ot,Be+=N*Lt,nt+=N*bt,it+=N*jt,Ye+=N*Ut,pt+=N*tt,ht+=N*Ft,ft+=N*K,Ht+=N*G,Jt+=N*J,St+=N*T,Xt+=N*j,tr+=N*oe,N=Z[15],_e+=N*Bt,Qe+=N*Ct,at+=N*gt,Be+=N*Ot,nt+=N*Lt,it+=N*bt,Ye+=N*jt,pt+=N*Ut,ht+=N*tt,ft+=N*Ft,Ht+=N*K,Jt+=N*G,St+=N*J,Xt+=N*T,tr+=N*j,Dt+=N*oe,ne+=38*Qe,de+=38*at,ce+=38*Be,fe+=38*nt,be+=38*it,Pe+=38*Ye,De+=38*pt,Te+=38*ht,Fe+=38*ft,Me+=38*Ht,Ne+=38*Jt,He+=38*St,Oe+=38*Xt,$e+=38*tr,qe+=38*Dt,Q=1,N=ne+Q+65535,Q=Math.floor(N/65536),ne=N-Q*65536,N=de+Q+65535,Q=Math.floor(N/65536),de=N-Q*65536,N=ce+Q+65535,Q=Math.floor(N/65536),ce=N-Q*65536,N=fe+Q+65535,Q=Math.floor(N/65536),fe=N-Q*65536,N=be+Q+65535,Q=Math.floor(N/65536),be=N-Q*65536,N=Pe+Q+65535,Q=Math.floor(N/65536),Pe=N-Q*65536,N=De+Q+65535,Q=Math.floor(N/65536),De=N-Q*65536,N=Te+Q+65535,Q=Math.floor(N/65536),Te=N-Q*65536,N=Fe+Q+65535,Q=Math.floor(N/65536),Fe=N-Q*65536,N=Me+Q+65535,Q=Math.floor(N/65536),Me=N-Q*65536,N=Ne+Q+65535,Q=Math.floor(N/65536),Ne=N-Q*65536,N=He+Q+65535,Q=Math.floor(N/65536),He=N-Q*65536,N=Oe+Q+65535,Q=Math.floor(N/65536),Oe=N-Q*65536,N=$e+Q+65535,Q=Math.floor(N/65536),$e=N-Q*65536,N=qe+Q+65535,Q=Math.floor(N/65536),qe=N-Q*65536,N=_e+Q+65535,Q=Math.floor(N/65536),_e=N-Q*65536,ne+=Q-1+37*(Q-1),Q=1,N=ne+Q+65535,Q=Math.floor(N/65536),ne=N-Q*65536,N=de+Q+65535,Q=Math.floor(N/65536),de=N-Q*65536,N=ce+Q+65535,Q=Math.floor(N/65536),ce=N-Q*65536,N=fe+Q+65535,Q=Math.floor(N/65536),fe=N-Q*65536,N=be+Q+65535,Q=Math.floor(N/65536),be=N-Q*65536,N=Pe+Q+65535,Q=Math.floor(N/65536),Pe=N-Q*65536,N=De+Q+65535,Q=Math.floor(N/65536),De=N-Q*65536,N=Te+Q+65535,Q=Math.floor(N/65536),Te=N-Q*65536,N=Fe+Q+65535,Q=Math.floor(N/65536),Fe=N-Q*65536,N=Me+Q+65535,Q=Math.floor(N/65536),Me=N-Q*65536,N=Ne+Q+65535,Q=Math.floor(N/65536),Ne=N-Q*65536,N=He+Q+65535,Q=Math.floor(N/65536),He=N-Q*65536,N=Oe+Q+65535,Q=Math.floor(N/65536),Oe=N-Q*65536,N=$e+Q+65535,Q=Math.floor(N/65536),$e=N-Q*65536,N=qe+Q+65535,Q=Math.floor(N/65536),qe=N-Q*65536,N=_e+Q+65535,Q=Math.floor(N/65536),_e=N-Q*65536,ne+=Q-1+37*(Q-1),ee[0]=ne,ee[1]=de,ee[2]=ce,ee[3]=fe,ee[4]=be,ee[5]=Pe,ee[6]=De,ee[7]=Te,ee[8]=Fe,ee[9]=Me,ee[10]=Ne,ee[11]=He,ee[12]=Oe,ee[13]=$e,ee[14]=qe,ee[15]=_e}function W(ee,Z){R(ee,Z,Z)}function V(ee,Z){const te=i();let N;for(N=0;N<16;N++)te[N]=Z[N];for(N=253;N>=0;N--)W(te,te),N!==2&&N!==4&&R(te,te,Z);for(N=0;N<16;N++)ee[N]=te[N]}function X(ee,Z){const te=i();let N;for(N=0;N<16;N++)te[N]=Z[N];for(N=250;N>=0;N--)W(te,te),N!==1&&R(te,te,Z);for(N=0;N<16;N++)ee[N]=te[N]}function q(ee,Z){const te=i(),N=i(),Q=i(),ne=i(),de=i(),ce=i(),fe=i(),be=i(),Pe=i();$(te,ee[1],ee[0]),$(Pe,Z[1],Z[0]),R(te,te,Pe),k(N,ee[0],ee[1]),k(Pe,Z[0],Z[1]),R(N,N,Pe),R(Q,ee[3],Z[3]),R(Q,Q,u),R(ne,ee[2],Z[2]),k(ne,ne,ne),$(de,N,te),$(ce,ne,Q),k(fe,ne,Q),k(be,N,te),R(ee[0],de,ce),R(ee[1],be,fe),R(ee[2],fe,ce),R(ee[3],de,be)}function _(ee,Z,te){for(let N=0;N<4;N++)C(ee[N],Z[N],te)}function v(ee,Z){const te=i(),N=i(),Q=i();V(Q,Z[2]),R(te,Z[0],Q),R(N,Z[1],Q),D(ee,N),ee[31]^=H(te)<<7}function l(ee,Z,te){x(ee[0],o),x(ee[1],a),x(ee[2],a),x(ee[3],o);for(let N=255;N>=0;--N){const Q=te[N/8|0]>>(N&7)&1;_(ee,Z,Q),q(Z,ee),q(ee,ee),_(ee,Z,Q)}}function p(ee,Z){const te=[i(),i(),i(),i()];x(te[0],h),x(te[1],g),x(te[2],a),R(te[3],h,g),l(ee,te,Z)}function m(ee){if(ee.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const Z=(0,r.hash)(ee);Z[0]&=248,Z[31]&=127,Z[31]|=64;const te=new Uint8Array(32),N=[i(),i(),i(),i()];p(N,Z),v(te,N);const Q=new Uint8Array(64);return Q.set(ee),Q.set(te,32),{publicKey:te,secretKey:Q}}t.generateKeyPairFromSeed=m;function y(ee){const Z=(0,e.randomBytes)(32,ee),te=m(Z);return(0,n.wipe)(Z),te}t.generateKeyPair=y;function A(ee){if(ee.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(ee.subarray(32))}t.extractPublicKeyFromSecretKey=A;const E=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 w(ee,Z){let te,N,Q,ne;for(N=63;N>=32;--N){for(te=0,Q=N-32,ne=N-12;Q>4)*E[Q],te=Z[Q]>>8,Z[Q]&=255;for(Q=0;Q<32;Q++)Z[Q]-=te*E[Q];for(N=0;N<32;N++)Z[N+1]+=Z[N]>>8,ee[N]=Z[N]&255}function I(ee){const Z=new Float64Array(64);for(let te=0;te<64;te++)Z[te]=ee[te];for(let te=0;te<64;te++)ee[te]=0;w(ee,Z)}function M(ee,Z){const te=new Float64Array(64),N=[i(),i(),i(),i()],Q=(0,r.hash)(ee.subarray(0,32));Q[0]&=248,Q[31]&=127,Q[31]|=64;const ne=new Uint8Array(64);ne.set(Q.subarray(32),32);const de=new r.SHA512;de.update(ne.subarray(32)),de.update(Z);const ce=de.digest();de.clean(),I(ce),p(N,ce),v(ne,N),de.reset(),de.update(ne.subarray(0,32)),de.update(ee.subarray(32)),de.update(Z);const fe=de.digest();I(fe);for(let be=0;be<32;be++)te[be]=ce[be];for(let be=0;be<32;be++)for(let Pe=0;Pe<32;Pe++)te[be+Pe]+=fe[be]*Q[Pe];return w(ne.subarray(32),te),ne}t.sign=M;function z(ee,Z){const te=i(),N=i(),Q=i(),ne=i(),de=i(),ce=i(),fe=i();return x(ee[2],a),F(ee[1],Z),W(Q,ee[1]),R(ne,Q,f),$(Q,Q,ee[2]),k(ne,ee[2],ne),W(de,ne),W(ce,de),R(fe,ce,de),R(te,fe,Q),R(te,te,ne),X(te,te),R(te,te,Q),R(te,te,ne),R(te,te,ne),R(ee[0],te,ne),W(N,ee[0]),R(N,N,ne),L(N,Q)&&R(ee[0],ee[0],b),W(N,ee[0]),R(N,N,ne),L(N,Q)?-1:(H(ee[0])===Z[31]>>7&&$(ee[0],o,ee[0]),R(ee[3],ee[0],ee[1]),0)}function se(ee,Z,te){const N=new Uint8Array(32),Q=[i(),i(),i(),i()],ne=[i(),i(),i(),i()];if(te.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(z(ne,ee))return!1;const de=new r.SHA512;de.update(te.subarray(0,32)),de.update(ee),de.update(Z);const ce=de.digest();return I(ce),l(Q,ne,ce),p(ne,te.subarray(32)),q(Q,ne),v(N,Q),!B(te,N)}t.verify=se;function O(ee){let Z=[i(),i(),i(),i()];if(z(Z,ee))throw new Error("Ed25519: invalid public key");let te=i(),N=i(),Q=Z[1];k(te,a,Q),$(N,a,Q),V(N,N),R(te,te,N);let ne=new Uint8Array(32);return D(ne,te),ne}t.convertPublicKeyToX25519=O;function ie(ee){const Z=(0,r.hash)(ee.subarray(0,32));Z[0]&=248,Z[31]&=127,Z[31]|=64;const te=new Uint8Array(Z.subarray(0,32));return(0,n.wipe)(Z),te}t.convertSecretKeyToX25519=ie})(ng)),ng}var T2=yT(),tf=og();const wT="EdDSA",xT="JWT",ph=".",gh="base64url",D2="utf8",O2="utf8",_T=":",ET="did",ST="key",N2="base58btc",AT="z",PT="K36",IT=32;function L2(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function mh(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=L2(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function MT(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,F=new Uint8Array(H);B!==L;){for(var k=S[B],$=0,R=H-1;(k!==0||$>>0,F[R]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");D=$,B++}for(var W=H-D;W!==H&&F[W]===0;)W++;for(var V=f.repeat(C);W>>0,H=new Uint8Array(L);S[C];){var F=r[S.charCodeAt(C)];if(F===255)return;for(var k=0,$=L-1;(F!==0||k>>0,H[$]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");B=k,C++}if(S[C]!==" "){for(var R=L-B;R!==L&&H[R]===0;)R++;for(var W=new Uint8Array(D+(L-R)),V=D;R!==L;)W[V++]=H[R++];return W}}}function x(S){var C=b(S);if(C)return C;throw new Error(`Non-${e} character`)}return{encode:g,decodeUnsafe:b,decode:x}}var CT=MT,RT=CT;const TT=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},DT=t=>new TextEncoder().encode(t),OT=t=>new TextDecoder().decode(t);class NT{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class LT{constructor(e,r,n){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=n}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 k2(this,e)}}class kT{constructor(e){this.decoders=e}or(e){return k2(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const k2=(t,e)=>new kT({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class BT{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new NT(e,r,n),this.decoder=new LT(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const vh=({name:t,prefix:e,encode:r,decode:n})=>new BT(t,e,r,n),rf=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=RT(r,e);return vh({prefix:t,name:e,encode:n,decode:s=>TT(i(s))})},FT=(t,e,r,n)=>{const i={};for(let h=0;h=8&&(a-=8,o[u++]=255&f>>a)}if(a>=r||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},jT=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<vh({prefix:e,name:t,encode(i){return jT(i,n,r)},decode(i){return FT(i,n,r,t)}}),UT=vh({prefix:"\0",name:"identity",encode:t=>OT(t),decode:t=>DT(t)}),$T=Object.freeze(Object.defineProperty({__proto__:null,identity:UT},Symbol.toStringTag,{value:"Module"})),qT=Tn({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),zT=Object.freeze(Object.defineProperty({__proto__:null,base2:qT},Symbol.toStringTag,{value:"Module"})),HT=Tn({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),WT=Object.freeze(Object.defineProperty({__proto__:null,base8:HT},Symbol.toStringTag,{value:"Module"})),KT=rf({prefix:"9",name:"base10",alphabet:"0123456789"}),VT=Object.freeze(Object.defineProperty({__proto__:null,base10:KT},Symbol.toStringTag,{value:"Module"})),GT=Tn({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),YT=Tn({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),JT=Object.freeze(Object.defineProperty({__proto__:null,base16:GT,base16upper:YT},Symbol.toStringTag,{value:"Module"})),XT=Tn({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ZT=Tn({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),QT=Tn({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),eD=Tn({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tD=Tn({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rD=Tn({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),nD=Tn({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),iD=Tn({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),sD=Tn({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),oD=Object.freeze(Object.defineProperty({__proto__:null,base32:XT,base32hex:tD,base32hexpad:nD,base32hexpadupper:iD,base32hexupper:rD,base32pad:QT,base32padupper:eD,base32upper:ZT,base32z:sD},Symbol.toStringTag,{value:"Module"})),aD=rf({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),cD=rf({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),uD=Object.freeze(Object.defineProperty({__proto__:null,base36:aD,base36upper:cD},Symbol.toStringTag,{value:"Module"})),fD=rf({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lD=rf({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),hD=Object.freeze(Object.defineProperty({__proto__:null,base58btc:fD,base58flickr:lD},Symbol.toStringTag,{value:"Module"})),dD=Tn({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),pD=Tn({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gD=Tn({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mD=Tn({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),vD=Object.freeze(Object.defineProperty({__proto__:null,base64:dD,base64pad:pD,base64url:gD,base64urlpad:mD},Symbol.toStringTag,{value:"Module"})),B2=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),bD=B2.reduce((t,e,r)=>(t[r]=e,t),[]),yD=B2.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function wD(t){return t.reduce((e,r)=>(e+=bD[r],e),"")}function xD(t){const e=[];for(const r of t){const n=yD[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const _D=vh({prefix:"🚀",name:"base256emoji",encode:wD,decode:xD}),ED=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:_D},Symbol.toStringTag,{value:"Module"}));new TextEncoder,new TextDecoder;const F2={...$T,...zT,...WT,...VT,...JT,...oD,...uD,...hD,...vD,...ED};function j2(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const U2=j2("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),cg=j2("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);const e=L2(t.length);for(let r=0;r"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new OD:typeof navigator<"u"?jD(navigator.userAgent):$D()}function FD(t){return t!==""&&kD.reduce(function(e,r){var n=r[0],i=r[1];if(e)return e;var s=i.exec(t);return!!s&&[n,s]},!1)}function jD(t){var e=FD(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new DD;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length-1){const L=D.getAttribute("href");if(L)if(L.toLowerCase().indexOf("https:")===-1&&L.toLowerCase().indexOf("http:")===-1&&L.indexOf("//")!==0){let H=n.protocol+"//"+n.host;if(L.indexOf("/")===0)H+=L;else{const F=n.pathname.split("/");F.pop();const k=F.join("/");H+=k+"/"+L}S.push(H)}else if(L.indexOf("//")===0){const H=n.protocol+L;S.push(H)}else S.push(L)}}return S}function s(...x){const S=r.getElementsByTagName("meta");for(let C=0;CD.getAttribute(L)).filter(L=>L?x.includes(L):!1);if(B.length&&B){const L=D.getAttribute("content");if(L)return L}}return""}function o(){let x=s("name","og:site_name","og:title","twitter:title");return x||(x=r.title),x}function a(){return s("description","og:description","twitter:description","keywords")}const f=o(),u=a(),h=n.origin,g=i();return{description:u,url:h,icons:g,name:f}}return nf.getWindowMetadata=e,nf}var HD=zD(),fg={},lg,X2;function WD(){return X2||(X2=1,lg=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)),lg}var hg,Z2;function KD(){if(Z2)return hg;Z2=1;var t="%[a-f0-9]{2}",e=new RegExp("("+t+")|([^%]+?)","gi"),r=new RegExp("("+t+")+","gi");function n(o,a){try{return[decodeURIComponent(o.join(""))]}catch{}if(o.length===1)return o;a=a||1;var f=o.slice(0,a),u=o.slice(a);return Array.prototype.concat.call([],n(f),n(u))}function i(o){try{return decodeURIComponent(o)}catch{for(var a=o.match(e)||[],f=1;f{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]}),dg}var pg,ex;function GD(){return ex||(ex=1,pg=function(t,e){for(var r={},n=Object.keys(t),i=Array.isArray(e),s=0;sL==null,o=Symbol("encodeFragmentIdentifier");function a(L){switch(L.arrayFormat){case"index":return H=>(F,k)=>{const $=F.length;return k===void 0||L.skipNull&&k===null||L.skipEmptyString&&k===""?F:k===null?[...F,[h(H,L),"[",$,"]"].join("")]:[...F,[h(H,L),"[",h($,L),"]=",h(k,L)].join("")]};case"bracket":return H=>(F,k)=>k===void 0||L.skipNull&&k===null||L.skipEmptyString&&k===""?F:k===null?[...F,[h(H,L),"[]"].join("")]:[...F,[h(H,L),"[]=",h(k,L)].join("")];case"colon-list-separator":return H=>(F,k)=>k===void 0||L.skipNull&&k===null||L.skipEmptyString&&k===""?F:k===null?[...F,[h(H,L),":list="].join("")]:[...F,[h(H,L),":list=",h(k,L)].join("")];case"comma":case"separator":case"bracket-separator":{const H=L.arrayFormat==="bracket-separator"?"[]=":"=";return F=>(k,$)=>$===void 0||L.skipNull&&$===null||L.skipEmptyString&&$===""?k:($=$===null?"":$,k.length===0?[[h(F,L),H,h($,L)].join("")]:[[k,h($,L)].join(L.arrayFormatSeparator)])}default:return H=>(F,k)=>k===void 0||L.skipNull&&k===null||L.skipEmptyString&&k===""?F:k===null?[...F,h(H,L)]:[...F,[h(H,L),"=",h(k,L)].join("")]}}function f(L){let H;switch(L.arrayFormat){case"index":return(F,k,$)=>{if(H=/\[(\d*)\]$/.exec(F),F=F.replace(/\[\d*\]$/,""),!H){$[F]=k;return}$[F]===void 0&&($[F]={}),$[F][H[1]]=k};case"bracket":return(F,k,$)=>{if(H=/(\[\])$/.exec(F),F=F.replace(/\[\]$/,""),!H){$[F]=k;return}if($[F]===void 0){$[F]=[k];return}$[F]=[].concat($[F],k)};case"colon-list-separator":return(F,k,$)=>{if(H=/(:list)$/.exec(F),F=F.replace(/:list$/,""),!H){$[F]=k;return}if($[F]===void 0){$[F]=[k];return}$[F]=[].concat($[F],k)};case"comma":case"separator":return(F,k,$)=>{const R=typeof k=="string"&&k.includes(L.arrayFormatSeparator),W=typeof k=="string"&&!R&&g(k,L).includes(L.arrayFormatSeparator);k=W?g(k,L):k;const V=R||W?k.split(L.arrayFormatSeparator).map(X=>g(X,L)):k===null?k:g(k,L);$[F]=V};case"bracket-separator":return(F,k,$)=>{const R=/(\[\])$/.test(F);if(F=F.replace(/\[\]$/,""),!R){$[F]=k&&g(k,L);return}const W=k===null?[]:k.split(L.arrayFormatSeparator).map(V=>g(V,L));if($[F]===void 0){$[F]=W;return}$[F]=[].concat($[F],W)};default:return(F,k,$)=>{if($[F]===void 0){$[F]=k;return}$[F]=[].concat($[F],k)}}}function u(L){if(typeof L!="string"||L.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function h(L,H){return H.encode?H.strict?e(L):encodeURIComponent(L):L}function g(L,H){return H.decode?r(L):L}function b(L){return Array.isArray(L)?L.sort():typeof L=="object"?b(Object.keys(L)).sort((H,F)=>Number(H)-Number(F)).map(H=>L[H]):L}function x(L){const H=L.indexOf("#");return H!==-1&&(L=L.slice(0,H)),L}function S(L){let H="";const F=L.indexOf("#");return F!==-1&&(H=L.slice(F)),H}function C(L){L=x(L);const H=L.indexOf("?");return H===-1?"":L.slice(H+1)}function D(L,H){return H.parseNumbers&&!Number.isNaN(Number(L))&&typeof L=="string"&&L.trim()!==""?L=Number(L):H.parseBooleans&&L!==null&&(L.toLowerCase()==="true"||L.toLowerCase()==="false")&&(L=L.toLowerCase()==="true"),L}function B(L,H){H=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},H),u(H.arrayFormatSeparator);const F=f(H),k=Object.create(null);if(typeof L!="string"||(L=L.trim().replace(/^[?#&]/,""),!L))return k;for(const $ of L.split("&")){if($==="")continue;let[R,W]=n(H.decode?$.replace(/\+/g," "):$,"=");W=W===void 0?null:["comma","separator","bracket-separator"].includes(H.arrayFormat)?W:g(W,H),F(g(R,H),W,k)}for(const $ of Object.keys(k)){const R=k[$];if(typeof R=="object"&&R!==null)for(const W of Object.keys(R))R[W]=D(R[W],H);else k[$]=D(R,H)}return H.sort===!1?k:(H.sort===!0?Object.keys(k).sort():Object.keys(k).sort(H.sort)).reduce(($,R)=>{const W=k[R];return W&&typeof W=="object"&&!Array.isArray(W)?$[R]=b(W):$[R]=W,$},Object.create(null))}t.extract=C,t.parse=B,t.stringify=(L,H)=>{if(!L)return"";H=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},H),u(H.arrayFormatSeparator);const F=W=>H.skipNull&&s(L[W])||H.skipEmptyString&&L[W]==="",k=a(H),$={};for(const W of Object.keys(L))F(W)||($[W]=L[W]);const R=Object.keys($);return H.sort!==!1&&R.sort(H.sort),R.map(W=>{const V=L[W];return V===void 0?"":V===null?h(W,H):Array.isArray(V)?V.length===0&&H.arrayFormat==="bracket-separator"?h(W,H)+"[]":V.reduce(k(W),[]).join("&"):h(W,H)+"="+h(V,H)}).filter(W=>W.length>0).join("&")},t.parseUrl=(L,H)=>{H=Object.assign({decode:!0},H);const[F,k]=n(L,"#");return Object.assign({url:F.split("?")[0]||"",query:B(C(L),H)},H&&H.parseFragmentIdentifier&&k?{fragmentIdentifier:g(k,H)}:{})},t.stringifyUrl=(L,H)=>{H=Object.assign({encode:!0,strict:!0,[o]:!0},H);const F=x(L.url).split("?")[0]||"",k=t.extract(L.url),$=t.parse(k,{sort:!1}),R=Object.assign($,L.query);let W=t.stringify(R,H);W&&(W=`?${W}`);let V=S(L.url);return L.fragmentIdentifier&&(V=`#${H[o]?h(L.fragmentIdentifier,H):L.fragmentIdentifier}`),`${F}${W}${V}`},t.pick=(L,H,F)=>{F=Object.assign({parseFragmentIdentifier:!0,[o]:!1},F);const{url:k,query:$,fragmentIdentifier:R}=t.parseUrl(L,F);return t.stringifyUrl({url:k,query:i($,H),fragmentIdentifier:R},F)},t.exclude=(L,H,F)=>{const k=Array.isArray(H)?$=>!H.includes($):($,R)=>!H($,R);return t.pick(L,k,F)}})(fg)),fg}var yh=YD(),gg={exports:{}};/** * [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 - */(function(t){(function(){var e="input is invalid type",r="finalize already called",n=typeof window=="object",i=n?window:{};i.JS_SHA3_NO_WINDOW&&(n=!1);var s=!n&&typeof self=="object",o=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?i=nn:s&&(i=self);var a=!i.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,u=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",l="0123456789abcdef".split(""),d=[31,7936,2031616,520093696],g=[4,1024,262144,67108864],y=[1,256,65536,16777216],A=[6,1536,393216,100663296],P=[0,8,16,24],N=[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],D=[224,256,384,512],k=[128,256],$=["hex","buffer","arrayBuffer","array","digest"],q={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(O){return Object.prototype.toString.call(O)==="[object Array]"}),u&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(O){return typeof O=="object"&&O.buffer&&O.buffer.constructor===ArrayBuffer});for(var U=function(O,se,ee){return function(X){return new I(O,se,O).update(X)[ee]()}},K=function(O,se,ee){return function(X,Q){return new I(O,se,Q).update(X)[ee]()}},J=function(O,se,ee){return function(X,Q,R,Z){return f["cshake"+O].update(X,Q,R,Z)[ee]()}},T=function(O,se,ee){return function(X,Q,R,Z){return f["kmac"+O].update(X,Q,R,Z)[ee]()}},z=function(O,se,ee,X){for(var Q=0;Q<$.length;++Q){var R=$[Q];O[R]=se(ee,X,R)}return O},ue=function(O,se){var ee=U(O,se,"hex");return ee.create=function(){return new I(O,se,O)},ee.update=function(X){return ee.create().update(X)},z(ee,U,O,se)},_e=function(O,se){var ee=K(O,se,"hex");return ee.create=function(X){return new I(O,se,X)},ee.update=function(X,Q){return ee.create(Q).update(X)},z(ee,K,O,se)},G=function(O,se){var ee=q[O],X=J(O,se,"hex");return X.create=function(Q,R,Z){return!R&&!Z?f["shake"+O].create(Q):new I(O,se,Q).bytepad([R,Z],ee)},X.update=function(Q,R,Z,te){return X.create(R,Z,te).update(Q)},z(X,J,O,se)},E=function(O,se){var ee=q[O],X=T(O,se,"hex");return X.create=function(Q,R,Z){return new F(O,se,R).bytepad(["KMAC",Z],ee).bytepad([Q],ee)},X.update=function(Q,R,Z,te){return X.create(Q,Z,te).update(R)},z(X,T,O,se)},m=[{name:"keccak",padding:y,bits:D,createMethod:ue},{name:"sha3",padding:A,bits:D,createMethod:ue},{name:"shake",padding:d,bits:k,createMethod:_e},{name:"cshake",padding:g,bits:k,createMethod:G},{name:"kmac",padding:g,bits:k,createMethod:E}],f={},p=[],v=0;v>5,this.byteCount=this.blockCount<<2,this.outputBlocks=ee>>5,this.extraBytes=(ee&31)>>3;for(var X=0;X<50;++X)this.s[X]=0}I.prototype.update=function(O){if(this.finalized)throw new Error(r);var se,ee=typeof O;if(ee!=="string"){if(ee==="object"){if(O===null)throw new Error(e);if(u&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!Array.isArray(O)&&(!u||!ArrayBuffer.isView(O)))throw new Error(e)}else throw new Error(e);se=!0}for(var X=this.blocks,Q=this.byteCount,R=O.length,Z=this.blockCount,te=0,le=this.s,ie,fe;te>2]|=O[te]<>2]|=fe<>2]|=(192|fe>>6)<>2]|=(128|fe&63)<=57344?(X[ie>>2]|=(224|fe>>12)<>2]|=(128|fe>>6&63)<>2]|=(128|fe&63)<>2]|=(240|fe>>18)<>2]|=(128|fe>>12&63)<>2]|=(128|fe>>6&63)<>2]|=(128|fe&63)<=Q){for(this.start=ie-Q,this.block=X[Z],ie=0;ie>8,ee=O&255;ee>0;)Q.unshift(ee),O=O>>8,ee=O&255,++X;return se?Q.push(X):Q.unshift(X),this.update(Q),Q.length},I.prototype.encodeString=function(O){var se,ee=typeof O;if(ee!=="string"){if(ee==="object"){if(O===null)throw new Error(e);if(u&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!Array.isArray(O)&&(!u||!ArrayBuffer.isView(O)))throw new Error(e)}else throw new Error(e);se=!0}var X=0,Q=O.length;if(se)X=Q;else for(var R=0;R=57344?X+=3:(Z=65536+((Z&1023)<<10|O.charCodeAt(++R)&1023),X+=4)}return X+=this.encode(X*8),this.update(O),X},I.prototype.bytepad=function(O,se){for(var ee=this.encode(se),X=0;X>2]|=this.padding[se&3],this.lastByteIndex===this.byteCount)for(O[0]=O[ee],se=1;se>4&15]+l[te&15]+l[te>>12&15]+l[te>>8&15]+l[te>>20&15]+l[te>>16&15]+l[te>>28&15]+l[te>>24&15];R%O===0&&(ae(se),Q=0)}return X&&(te=se[Q],Z+=l[te>>4&15]+l[te&15],X>1&&(Z+=l[te>>12&15]+l[te>>8&15]),X>2&&(Z+=l[te>>20&15]+l[te>>16&15])),Z},I.prototype.arrayBuffer=function(){this.finalize();var O=this.blockCount,se=this.s,ee=this.outputBlocks,X=this.extraBytes,Q=0,R=0,Z=this.outputBits>>3,te;X?te=new ArrayBuffer(ee+1<<2):te=new ArrayBuffer(Z);for(var le=new Uint32Array(te);R>8&255,Z[te+2]=le>>16&255,Z[te+3]=le>>24&255;R%O===0&&ae(se)}return X&&(te=R<<2,le=se[Q],Z[te]=le&255,X>1&&(Z[te+1]=le>>8&255),X>2&&(Z[te+2]=le>>16&255)),Z};function F(O,se,ee){I.call(this,O,se,ee)}F.prototype=new I,F.prototype.finalize=function(){return this.encode(this.outputBits,!0),I.prototype.finalize.call(this)};var ae=function(O){var se,ee,X,Q,R,Z,te,le,ie,fe,ve,Me,Ne,Te,Be,Ie,Le,Ve,ke,ze,He,Ee,Qe,ct,$e,et,rt,Je,pt,ht,ft,Ht,Jt,St,er,Xt,Ot,$t,Tt,vt,Dt,Lt,bt,Bt,Ut,nt,Ft,B,H,V,C,Y,j,oe,pe,xe,Re,De,it,je,gt,st,tt;for(X=0;X<48;X+=2)Q=O[0]^O[10]^O[20]^O[30]^O[40],R=O[1]^O[11]^O[21]^O[31]^O[41],Z=O[2]^O[12]^O[22]^O[32]^O[42],te=O[3]^O[13]^O[23]^O[33]^O[43],le=O[4]^O[14]^O[24]^O[34]^O[44],ie=O[5]^O[15]^O[25]^O[35]^O[45],fe=O[6]^O[16]^O[26]^O[36]^O[46],ve=O[7]^O[17]^O[27]^O[37]^O[47],Me=O[8]^O[18]^O[28]^O[38]^O[48],Ne=O[9]^O[19]^O[29]^O[39]^O[49],se=Me^(Z<<1|te>>>31),ee=Ne^(te<<1|Z>>>31),O[0]^=se,O[1]^=ee,O[10]^=se,O[11]^=ee,O[20]^=se,O[21]^=ee,O[30]^=se,O[31]^=ee,O[40]^=se,O[41]^=ee,se=Q^(le<<1|ie>>>31),ee=R^(ie<<1|le>>>31),O[2]^=se,O[3]^=ee,O[12]^=se,O[13]^=ee,O[22]^=se,O[23]^=ee,O[32]^=se,O[33]^=ee,O[42]^=se,O[43]^=ee,se=Z^(fe<<1|ve>>>31),ee=te^(ve<<1|fe>>>31),O[4]^=se,O[5]^=ee,O[14]^=se,O[15]^=ee,O[24]^=se,O[25]^=ee,O[34]^=se,O[35]^=ee,O[44]^=se,O[45]^=ee,se=le^(Me<<1|Ne>>>31),ee=ie^(Ne<<1|Me>>>31),O[6]^=se,O[7]^=ee,O[16]^=se,O[17]^=ee,O[26]^=se,O[27]^=ee,O[36]^=se,O[37]^=ee,O[46]^=se,O[47]^=ee,se=fe^(Q<<1|R>>>31),ee=ve^(R<<1|Q>>>31),O[8]^=se,O[9]^=ee,O[18]^=se,O[19]^=ee,O[28]^=se,O[29]^=ee,O[38]^=se,O[39]^=ee,O[48]^=se,O[49]^=ee,Te=O[0],Be=O[1],nt=O[11]<<4|O[10]>>>28,Ft=O[10]<<4|O[11]>>>28,Je=O[20]<<3|O[21]>>>29,pt=O[21]<<3|O[20]>>>29,je=O[31]<<9|O[30]>>>23,gt=O[30]<<9|O[31]>>>23,Lt=O[40]<<18|O[41]>>>14,bt=O[41]<<18|O[40]>>>14,St=O[2]<<1|O[3]>>>31,er=O[3]<<1|O[2]>>>31,Ie=O[13]<<12|O[12]>>>20,Le=O[12]<<12|O[13]>>>20,B=O[22]<<10|O[23]>>>22,H=O[23]<<10|O[22]>>>22,ht=O[33]<<13|O[32]>>>19,ft=O[32]<<13|O[33]>>>19,st=O[42]<<2|O[43]>>>30,tt=O[43]<<2|O[42]>>>30,oe=O[5]<<30|O[4]>>>2,pe=O[4]<<30|O[5]>>>2,Xt=O[14]<<6|O[15]>>>26,Ot=O[15]<<6|O[14]>>>26,Ve=O[25]<<11|O[24]>>>21,ke=O[24]<<11|O[25]>>>21,V=O[34]<<15|O[35]>>>17,C=O[35]<<15|O[34]>>>17,Ht=O[45]<<29|O[44]>>>3,Jt=O[44]<<29|O[45]>>>3,ct=O[6]<<28|O[7]>>>4,$e=O[7]<<28|O[6]>>>4,xe=O[17]<<23|O[16]>>>9,Re=O[16]<<23|O[17]>>>9,$t=O[26]<<25|O[27]>>>7,Tt=O[27]<<25|O[26]>>>7,ze=O[36]<<21|O[37]>>>11,He=O[37]<<21|O[36]>>>11,Y=O[47]<<24|O[46]>>>8,j=O[46]<<24|O[47]>>>8,Bt=O[8]<<27|O[9]>>>5,Ut=O[9]<<27|O[8]>>>5,et=O[18]<<20|O[19]>>>12,rt=O[19]<<20|O[18]>>>12,De=O[29]<<7|O[28]>>>25,it=O[28]<<7|O[29]>>>25,vt=O[38]<<8|O[39]>>>24,Dt=O[39]<<8|O[38]>>>24,Ee=O[48]<<14|O[49]>>>18,Qe=O[49]<<14|O[48]>>>18,O[0]=Te^~Ie&Ve,O[1]=Be^~Le&ke,O[10]=ct^~et&Je,O[11]=$e^~rt&pt,O[20]=St^~Xt&$t,O[21]=er^~Ot&Tt,O[30]=Bt^~nt&B,O[31]=Ut^~Ft&H,O[40]=oe^~xe&De,O[41]=pe^~Re&it,O[2]=Ie^~Ve&ze,O[3]=Le^~ke&He,O[12]=et^~Je&ht,O[13]=rt^~pt&ft,O[22]=Xt^~$t&vt,O[23]=Ot^~Tt&Dt,O[32]=nt^~B&V,O[33]=Ft^~H&C,O[42]=xe^~De&je,O[43]=Re^~it>,O[4]=Ve^~ze&Ee,O[5]=ke^~He&Qe,O[14]=Je^~ht&Ht,O[15]=pt^~ft&Jt,O[24]=$t^~vt&Lt,O[25]=Tt^~Dt&bt,O[34]=B^~V&Y,O[35]=H^~C&j,O[44]=De^~je&st,O[45]=it^~gt&tt,O[6]=ze^~Ee&Te,O[7]=He^~Qe&Be,O[16]=ht^~Ht&ct,O[17]=ft^~Jt&$e,O[26]=vt^~Lt&St,O[27]=Dt^~bt&er,O[36]=V^~Y&Bt,O[37]=C^~j&Ut,O[46]=je^~st&oe,O[47]=gt^~tt&pe,O[8]=Ee^~Te&Ie,O[9]=Qe^~Be&Le,O[18]=Ht^~ct&et,O[19]=Jt^~$e&rt,O[28]=Lt^~St&Xt,O[29]=bt^~er&Ot,O[38]=Y^~Bt&nt,O[39]=j^~Ut&Ft,O[48]=st^~oe&xe,O[49]=tt^~pe&Re,O[0]^=N[X],O[1]^=N[X+1]};if(a)t.exports=f;else for(v=0;v{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(t){return t.message}return null}const Nx=sN();var ym;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(ym||(ym={}));var ds;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"})(ds||(ds={}));const Lx="0123456789abcdef";class Kr{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){const n=e.toLowerCase();md[n]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(Ox>md[n])&&console.log.apply(console,r)}debug(...e){this._log(Kr.levels.DEBUG,e)}info(...e){this._log(Kr.levels.INFO,e)}warn(...e){this._log(Kr.levels.WARNING,e)}makeError(e,r,n){if(Dx)return this.makeError("censored error",r,{});r||(r=Kr.errors.UNKNOWN_ERROR),n||(n={});const i=[];Object.keys(n).forEach(u=>{const l=n[u];try{if(l instanceof Uint8Array){let d="";for(let g=0;g>4],d+=Lx[l[g]&15];i.push(u+"=Uint8Array(0x"+d+")")}else i.push(u+"="+JSON.stringify(l))}catch{i.push(u+"="+JSON.stringify(n[u].toString()))}}),i.push(`code=${r}`),i.push(`version=${this.version}`);const s=e;let o="";switch(r){case ds.NUMERIC_FAULT:{o="NUMERIC_FAULT";const 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 ds.CALL_EXCEPTION:case ds.INSUFFICIENT_FUNDS:case ds.MISSING_NEW:case ds.NONCE_EXPIRED:case ds.REPLACEMENT_UNDERPRICED:case ds.TRANSACTION_REPLACED:case ds.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(e+=" ("+i.join(", ")+")");const a=new Error(e);return a.reason=s,a.code=r,Object.keys(n).forEach(function(u){a[u]=n[u]}),a}throwError(e,r,n){throw this.makeError(e,r,n)}throwArgumentError(e,r,n){return this.throwError(e,Kr.errors.INVALID_ARGUMENT,{argument:r,value:n})}assert(e,r,n,i){e||this.throwError(r,n,i)}assertArgument(e,r,n,i){e||this.throwArgumentError(r,n,i)}checkNormalize(e){Nx&&this.throwError("platform missing String.prototype.normalize",Kr.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Nx})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,Kr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,Kr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,r,n){n?n=": "+n:n="",er&&this.throwError("too many arguments"+n,Kr.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",Kr.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",Kr.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Kr.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return bm||(bm=new Kr(iN)),bm}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",Kr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Rx){if(!e)return;this.globalLogger().throwError("error censorship permanent",Kr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Dx=!!e,Rx=!!r}static setLogLevel(e){const r=md[e.toLowerCase()];if(r==null){Kr.globalLogger().warn("invalid log level - "+e);return}Ox=r}static from(e){return new Kr(e)}}Kr.errors=ds,Kr.levels=ym;const oN="bytes/5.7.0",on=new Kr(oN);function kx(t){return!!t.toHexString}function cu(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return cu(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function aN(t){return Os(t)&&!(t.length%2)||wm(t)}function $x(t){return typeof t=="number"&&t==t&&t%1===0}function wm(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!$x(t.length)||t.length<0)return!1;for(let e=0;e=256)return!1}return!0}function bn(t,e){if(e||(e={}),typeof t=="number"){on.checkSafeUint53(t,"invalid arrayify value");const r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),cu(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),kx(t)&&(t=t.toHexString()),Os(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":on.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let i=0;ibn(i)),r=e.reduce((i,s)=>i+s.length,0),n=new Uint8Array(r);return e.reduce((i,s)=>(n.set(s,i),i+s.length),0),cu(n)}function uN(t,e){t=bn(t),t.length>e&&on.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),cu(r)}function Os(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const xm="0123456789abcdef";function Ii(t,e){if(e||(e={}),typeof t=="number"){on.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=xm[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),kx(t))return t.toHexString();if(Os(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":on.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(wm(t)){let r="0x";for(let n=0;n>4]+xm[i&15]}return r}return on.throwArgumentError("invalid hexlify value","value",t)}function fN(t){if(typeof t!="string")t=Ii(t);else if(!Os(t)||t.length%2)return null;return(t.length-2)/2}function Bx(t,e,r){return typeof t!="string"?t=Ii(t):(!Os(t)||t.length%2)&&on.throwArgumentError("invalid hexData","value",t),e=2+2*e,"0x"+t.substring(e)}function uu(t,e){for(typeof t!="string"?t=Ii(t):Os(t)||on.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&on.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function Fx(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(aN(t)){let r=bn(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=Ii(r.slice(0,32)),e.s=Ii(r.slice(32,64))):r.length===65?(e.r=Ii(r.slice(0,32)),e.s=Ii(r.slice(32,64)),e.v=r[64]):on.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:on.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Ii(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){const i=uN(bn(e._vs),32);e._vs=Ii(i);const s=i[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&on.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),i[0]&=127;const o=Ii(i);e.s==null?e.s=o:e.s!==o&&on.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?on.throwArgumentError("signature missing v and recoveryParam","signature",t):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{const i=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==i&&on.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!Os(e.r)?on.throwArgumentError("signature missing or invalid r","signature",t):e.r=uu(e.r,32),e.s==null||!Os(e.s)?on.throwArgumentError("signature missing or invalid s","signature",t):e.s=uu(e.s,32);const r=bn(e.s);r[0]>=128&&on.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=Ii(r);e._vs&&(Os(e._vs)||on.throwArgumentError("signature invalid _vs","signature",t),e._vs=uu(e._vs,32)),e._vs==null?e._vs=n:e._vs!==n&&on.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function _m(t){return"0x"+nN.keccak_256(bn(t))}var Em={exports:{}};Em.exports,function(t){(function(e,r){function n(m,f){if(!m)throw new Error(f||"Assertion failed")}function i(m,f){m.super_=f;var p=function(){};p.prototype=f.prototype,m.prototype=new p,m.prototype.constructor=m}function s(m,f,p){if(s.isBN(m))return m;this.negative=0,this.words=null,this.length=0,this.red=null,m!==null&&((f==="le"||f==="be")&&(p=f,f=10),this._init(m||0,f||10,p||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=el.Buffer}catch{}s.isBN=function(f){return f instanceof s?!0:f!==null&&typeof f=="object"&&f.constructor.wordSize===s.wordSize&&Array.isArray(f.words)},s.max=function(f,p){return f.cmp(p)>0?f:p},s.min=function(f,p){return f.cmp(p)<0?f:p},s.prototype._init=function(f,p,v){if(typeof f=="number")return this._initNumber(f,p,v);if(typeof f=="object")return this._initArray(f,p,v);p==="hex"&&(p=16),n(p===(p|0)&&p>=2&&p<=36),f=f.toString().replace(/\s+/g,"");var x=0;f[0]==="-"&&(x++,this.negative=1),x=0;x-=3)S=f[x]|f[x-1]<<8|f[x-2]<<16,this.words[_]|=S<>>26-b&67108863,b+=24,b>=26&&(b-=26,_++);else if(v==="le")for(x=0,_=0;x>>26-b&67108863,b+=24,b>=26&&(b-=26,_++);return this._strip()};function a(m,f){var p=m.charCodeAt(f);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;n(!1,"Invalid character in "+m)}function u(m,f,p){var v=a(m,p);return p-1>=f&&(v|=a(m,p-1)<<4),v}s.prototype._parseHex=function(f,p,v){this.length=Math.ceil((f.length-p)/6),this.words=new Array(this.length);for(var x=0;x=p;x-=2)b=u(f,p,x)<<_,this.words[S]|=b&67108863,_>=18?(_-=18,S+=1,this.words[S]|=b>>>26):_+=8;else{var M=f.length-p;for(x=M%2===0?p+1:p;x=18?(_-=18,S+=1,this.words[S]|=b>>>26):_+=8}this._strip()};function l(m,f,p,v){for(var x=0,_=0,S=Math.min(m.length,p),b=f;b=49?_=M-49+10:M>=17?_=M-17+10:_=M,n(M>=0&&_1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=g}catch{s.prototype.inspect=g}else s.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"],A=[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],P=[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];s.prototype.toString=function(f,p){f=f||10,p=p|0||1;var v;if(f===16||f==="hex"){v="";for(var x=0,_=0,S=0;S>>24-x&16777215,x+=2,x>=26&&(x-=26,S--),_!==0||S!==this.length-1?v=y[6-M.length]+M+v:v=M+v}for(_!==0&&(v=_.toString(16)+v);v.length%p!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(f===(f|0)&&f>=2&&f<=36){var I=A[f],F=P[f];v="";var ae=this.clone();for(ae.negative=0;!ae.isZero();){var O=ae.modrn(F).toString(f);ae=ae.idivn(F),ae.isZero()?v=O+v:v=y[I-O.length]+O+v}for(this.isZero()&&(v="0"+v);v.length%p!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var f=this.words[0];return this.length===2?f+=this.words[1]*67108864:this.length===3&&this.words[2]===1?f+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-f:f},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(f,p){return this.toArrayLike(o,f,p)}),s.prototype.toArray=function(f,p){return this.toArrayLike(Array,f,p)};var N=function(f,p){return f.allocUnsafe?f.allocUnsafe(p):new f(p)};s.prototype.toArrayLike=function(f,p,v){this._strip();var x=this.byteLength(),_=v||Math.max(1,x);n(x<=_,"byte array longer than desired length"),n(_>0,"Requested array length <= 0");var S=N(f,_),b=p==="le"?"LE":"BE";return this["_toArrayLike"+b](S,x),S},s.prototype._toArrayLikeLE=function(f,p){for(var v=0,x=0,_=0,S=0;_>8&255),v>16&255),S===6?(v>24&255),x=0,S=0):(x=b>>>24,S+=2)}if(v=0&&(f[v--]=b>>8&255),v>=0&&(f[v--]=b>>16&255),S===6?(v>=0&&(f[v--]=b>>24&255),x=0,S=0):(x=b>>>24,S+=2)}if(v>=0)for(f[v--]=x;v>=0;)f[v--]=0},Math.clz32?s.prototype._countBits=function(f){return 32-Math.clz32(f)}:s.prototype._countBits=function(f){var p=f,v=0;return p>=4096&&(v+=13,p>>>=13),p>=64&&(v+=7,p>>>=7),p>=8&&(v+=4,p>>>=4),p>=2&&(v+=2,p>>>=2),v+p},s.prototype._zeroBits=function(f){if(f===0)return 26;var p=f,v=0;return p&8191||(v+=13,p>>>=13),p&127||(v+=7,p>>>=7),p&15||(v+=4,p>>>=4),p&3||(v+=2,p>>>=2),p&1||v++,v},s.prototype.bitLength=function(){var f=this.words[this.length-1],p=this._countBits(f);return(this.length-1)*26+p};function D(m){for(var f=new Array(m.bitLength()),p=0;p>>x&1}return f}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var f=0,p=0;pf.length?this.clone().ior(f):f.clone().ior(this)},s.prototype.uor=function(f){return this.length>f.length?this.clone().iuor(f):f.clone().iuor(this)},s.prototype.iuand=function(f){var p;this.length>f.length?p=f:p=this;for(var v=0;vf.length?this.clone().iand(f):f.clone().iand(this)},s.prototype.uand=function(f){return this.length>f.length?this.clone().iuand(f):f.clone().iuand(this)},s.prototype.iuxor=function(f){var p,v;this.length>f.length?(p=this,v=f):(p=f,v=this);for(var x=0;xf.length?this.clone().ixor(f):f.clone().ixor(this)},s.prototype.uxor=function(f){return this.length>f.length?this.clone().iuxor(f):f.clone().iuxor(this)},s.prototype.inotn=function(f){n(typeof f=="number"&&f>=0);var p=Math.ceil(f/26)|0,v=f%26;this._expand(p),v>0&&p--;for(var x=0;x0&&(this.words[x]=~this.words[x]&67108863>>26-v),this._strip()},s.prototype.notn=function(f){return this.clone().inotn(f)},s.prototype.setn=function(f,p){n(typeof f=="number"&&f>=0);var v=f/26|0,x=f%26;return this._expand(v+1),p?this.words[v]=this.words[v]|1<f.length?(v=this,x=f):(v=f,x=this);for(var _=0,S=0;S>>26;for(;_!==0&&S>>26;if(this.length=v.length,_!==0)this.words[this.length]=_,this.length++;else if(v!==this)for(;Sf.length?this.clone().iadd(f):f.clone().iadd(this)},s.prototype.isub=function(f){if(f.negative!==0){f.negative=0;var p=this.iadd(f);return f.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(f),this.negative=1,this._normSign();var v=this.cmp(f);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var x,_;v>0?(x=this,_=f):(x=f,_=this);for(var S=0,b=0;b<_.length;b++)p=(x.words[b]|0)-(_.words[b]|0)+S,S=p>>26,this.words[b]=p&67108863;for(;S!==0&&b>26,this.words[b]=p&67108863;if(S===0&&b>>26,ae=M&67108863,O=Math.min(I,f.length-1),se=Math.max(0,I-m.length+1);se<=O;se++){var ee=I-se|0;x=m.words[ee]|0,_=f.words[se]|0,S=x*_+ae,F+=S/67108864|0,ae=S&67108863}p.words[I]=ae|0,M=F|0}return M!==0?p.words[I]=M|0:p.length--,p._strip()}var $=function(f,p,v){var x=f.words,_=p.words,S=v.words,b=0,M,I,F,ae=x[0]|0,O=ae&8191,se=ae>>>13,ee=x[1]|0,X=ee&8191,Q=ee>>>13,R=x[2]|0,Z=R&8191,te=R>>>13,le=x[3]|0,ie=le&8191,fe=le>>>13,ve=x[4]|0,Me=ve&8191,Ne=ve>>>13,Te=x[5]|0,Be=Te&8191,Ie=Te>>>13,Le=x[6]|0,Ve=Le&8191,ke=Le>>>13,ze=x[7]|0,He=ze&8191,Ee=ze>>>13,Qe=x[8]|0,ct=Qe&8191,$e=Qe>>>13,et=x[9]|0,rt=et&8191,Je=et>>>13,pt=_[0]|0,ht=pt&8191,ft=pt>>>13,Ht=_[1]|0,Jt=Ht&8191,St=Ht>>>13,er=_[2]|0,Xt=er&8191,Ot=er>>>13,$t=_[3]|0,Tt=$t&8191,vt=$t>>>13,Dt=_[4]|0,Lt=Dt&8191,bt=Dt>>>13,Bt=_[5]|0,Ut=Bt&8191,nt=Bt>>>13,Ft=_[6]|0,B=Ft&8191,H=Ft>>>13,V=_[7]|0,C=V&8191,Y=V>>>13,j=_[8]|0,oe=j&8191,pe=j>>>13,xe=_[9]|0,Re=xe&8191,De=xe>>>13;v.negative=f.negative^p.negative,v.length=19,M=Math.imul(O,ht),I=Math.imul(O,ft),I=I+Math.imul(se,ht)|0,F=Math.imul(se,ft);var it=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(it>>>26)|0,it&=67108863,M=Math.imul(X,ht),I=Math.imul(X,ft),I=I+Math.imul(Q,ht)|0,F=Math.imul(Q,ft),M=M+Math.imul(O,Jt)|0,I=I+Math.imul(O,St)|0,I=I+Math.imul(se,Jt)|0,F=F+Math.imul(se,St)|0;var je=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(je>>>26)|0,je&=67108863,M=Math.imul(Z,ht),I=Math.imul(Z,ft),I=I+Math.imul(te,ht)|0,F=Math.imul(te,ft),M=M+Math.imul(X,Jt)|0,I=I+Math.imul(X,St)|0,I=I+Math.imul(Q,Jt)|0,F=F+Math.imul(Q,St)|0,M=M+Math.imul(O,Xt)|0,I=I+Math.imul(O,Ot)|0,I=I+Math.imul(se,Xt)|0,F=F+Math.imul(se,Ot)|0;var gt=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(gt>>>26)|0,gt&=67108863,M=Math.imul(ie,ht),I=Math.imul(ie,ft),I=I+Math.imul(fe,ht)|0,F=Math.imul(fe,ft),M=M+Math.imul(Z,Jt)|0,I=I+Math.imul(Z,St)|0,I=I+Math.imul(te,Jt)|0,F=F+Math.imul(te,St)|0,M=M+Math.imul(X,Xt)|0,I=I+Math.imul(X,Ot)|0,I=I+Math.imul(Q,Xt)|0,F=F+Math.imul(Q,Ot)|0,M=M+Math.imul(O,Tt)|0,I=I+Math.imul(O,vt)|0,I=I+Math.imul(se,Tt)|0,F=F+Math.imul(se,vt)|0;var st=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(st>>>26)|0,st&=67108863,M=Math.imul(Me,ht),I=Math.imul(Me,ft),I=I+Math.imul(Ne,ht)|0,F=Math.imul(Ne,ft),M=M+Math.imul(ie,Jt)|0,I=I+Math.imul(ie,St)|0,I=I+Math.imul(fe,Jt)|0,F=F+Math.imul(fe,St)|0,M=M+Math.imul(Z,Xt)|0,I=I+Math.imul(Z,Ot)|0,I=I+Math.imul(te,Xt)|0,F=F+Math.imul(te,Ot)|0,M=M+Math.imul(X,Tt)|0,I=I+Math.imul(X,vt)|0,I=I+Math.imul(Q,Tt)|0,F=F+Math.imul(Q,vt)|0,M=M+Math.imul(O,Lt)|0,I=I+Math.imul(O,bt)|0,I=I+Math.imul(se,Lt)|0,F=F+Math.imul(se,bt)|0;var tt=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(tt>>>26)|0,tt&=67108863,M=Math.imul(Be,ht),I=Math.imul(Be,ft),I=I+Math.imul(Ie,ht)|0,F=Math.imul(Ie,ft),M=M+Math.imul(Me,Jt)|0,I=I+Math.imul(Me,St)|0,I=I+Math.imul(Ne,Jt)|0,F=F+Math.imul(Ne,St)|0,M=M+Math.imul(ie,Xt)|0,I=I+Math.imul(ie,Ot)|0,I=I+Math.imul(fe,Xt)|0,F=F+Math.imul(fe,Ot)|0,M=M+Math.imul(Z,Tt)|0,I=I+Math.imul(Z,vt)|0,I=I+Math.imul(te,Tt)|0,F=F+Math.imul(te,vt)|0,M=M+Math.imul(X,Lt)|0,I=I+Math.imul(X,bt)|0,I=I+Math.imul(Q,Lt)|0,F=F+Math.imul(Q,bt)|0,M=M+Math.imul(O,Ut)|0,I=I+Math.imul(O,nt)|0,I=I+Math.imul(se,Ut)|0,F=F+Math.imul(se,nt)|0;var At=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(At>>>26)|0,At&=67108863,M=Math.imul(Ve,ht),I=Math.imul(Ve,ft),I=I+Math.imul(ke,ht)|0,F=Math.imul(ke,ft),M=M+Math.imul(Be,Jt)|0,I=I+Math.imul(Be,St)|0,I=I+Math.imul(Ie,Jt)|0,F=F+Math.imul(Ie,St)|0,M=M+Math.imul(Me,Xt)|0,I=I+Math.imul(Me,Ot)|0,I=I+Math.imul(Ne,Xt)|0,F=F+Math.imul(Ne,Ot)|0,M=M+Math.imul(ie,Tt)|0,I=I+Math.imul(ie,vt)|0,I=I+Math.imul(fe,Tt)|0,F=F+Math.imul(fe,vt)|0,M=M+Math.imul(Z,Lt)|0,I=I+Math.imul(Z,bt)|0,I=I+Math.imul(te,Lt)|0,F=F+Math.imul(te,bt)|0,M=M+Math.imul(X,Ut)|0,I=I+Math.imul(X,nt)|0,I=I+Math.imul(Q,Ut)|0,F=F+Math.imul(Q,nt)|0,M=M+Math.imul(O,B)|0,I=I+Math.imul(O,H)|0,I=I+Math.imul(se,B)|0,F=F+Math.imul(se,H)|0;var Rt=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,M=Math.imul(He,ht),I=Math.imul(He,ft),I=I+Math.imul(Ee,ht)|0,F=Math.imul(Ee,ft),M=M+Math.imul(Ve,Jt)|0,I=I+Math.imul(Ve,St)|0,I=I+Math.imul(ke,Jt)|0,F=F+Math.imul(ke,St)|0,M=M+Math.imul(Be,Xt)|0,I=I+Math.imul(Be,Ot)|0,I=I+Math.imul(Ie,Xt)|0,F=F+Math.imul(Ie,Ot)|0,M=M+Math.imul(Me,Tt)|0,I=I+Math.imul(Me,vt)|0,I=I+Math.imul(Ne,Tt)|0,F=F+Math.imul(Ne,vt)|0,M=M+Math.imul(ie,Lt)|0,I=I+Math.imul(ie,bt)|0,I=I+Math.imul(fe,Lt)|0,F=F+Math.imul(fe,bt)|0,M=M+Math.imul(Z,Ut)|0,I=I+Math.imul(Z,nt)|0,I=I+Math.imul(te,Ut)|0,F=F+Math.imul(te,nt)|0,M=M+Math.imul(X,B)|0,I=I+Math.imul(X,H)|0,I=I+Math.imul(Q,B)|0,F=F+Math.imul(Q,H)|0,M=M+Math.imul(O,C)|0,I=I+Math.imul(O,Y)|0,I=I+Math.imul(se,C)|0,F=F+Math.imul(se,Y)|0;var Mt=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,M=Math.imul(ct,ht),I=Math.imul(ct,ft),I=I+Math.imul($e,ht)|0,F=Math.imul($e,ft),M=M+Math.imul(He,Jt)|0,I=I+Math.imul(He,St)|0,I=I+Math.imul(Ee,Jt)|0,F=F+Math.imul(Ee,St)|0,M=M+Math.imul(Ve,Xt)|0,I=I+Math.imul(Ve,Ot)|0,I=I+Math.imul(ke,Xt)|0,F=F+Math.imul(ke,Ot)|0,M=M+Math.imul(Be,Tt)|0,I=I+Math.imul(Be,vt)|0,I=I+Math.imul(Ie,Tt)|0,F=F+Math.imul(Ie,vt)|0,M=M+Math.imul(Me,Lt)|0,I=I+Math.imul(Me,bt)|0,I=I+Math.imul(Ne,Lt)|0,F=F+Math.imul(Ne,bt)|0,M=M+Math.imul(ie,Ut)|0,I=I+Math.imul(ie,nt)|0,I=I+Math.imul(fe,Ut)|0,F=F+Math.imul(fe,nt)|0,M=M+Math.imul(Z,B)|0,I=I+Math.imul(Z,H)|0,I=I+Math.imul(te,B)|0,F=F+Math.imul(te,H)|0,M=M+Math.imul(X,C)|0,I=I+Math.imul(X,Y)|0,I=I+Math.imul(Q,C)|0,F=F+Math.imul(Q,Y)|0,M=M+Math.imul(O,oe)|0,I=I+Math.imul(O,pe)|0,I=I+Math.imul(se,oe)|0,F=F+Math.imul(se,pe)|0;var Et=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(Et>>>26)|0,Et&=67108863,M=Math.imul(rt,ht),I=Math.imul(rt,ft),I=I+Math.imul(Je,ht)|0,F=Math.imul(Je,ft),M=M+Math.imul(ct,Jt)|0,I=I+Math.imul(ct,St)|0,I=I+Math.imul($e,Jt)|0,F=F+Math.imul($e,St)|0,M=M+Math.imul(He,Xt)|0,I=I+Math.imul(He,Ot)|0,I=I+Math.imul(Ee,Xt)|0,F=F+Math.imul(Ee,Ot)|0,M=M+Math.imul(Ve,Tt)|0,I=I+Math.imul(Ve,vt)|0,I=I+Math.imul(ke,Tt)|0,F=F+Math.imul(ke,vt)|0,M=M+Math.imul(Be,Lt)|0,I=I+Math.imul(Be,bt)|0,I=I+Math.imul(Ie,Lt)|0,F=F+Math.imul(Ie,bt)|0,M=M+Math.imul(Me,Ut)|0,I=I+Math.imul(Me,nt)|0,I=I+Math.imul(Ne,Ut)|0,F=F+Math.imul(Ne,nt)|0,M=M+Math.imul(ie,B)|0,I=I+Math.imul(ie,H)|0,I=I+Math.imul(fe,B)|0,F=F+Math.imul(fe,H)|0,M=M+Math.imul(Z,C)|0,I=I+Math.imul(Z,Y)|0,I=I+Math.imul(te,C)|0,F=F+Math.imul(te,Y)|0,M=M+Math.imul(X,oe)|0,I=I+Math.imul(X,pe)|0,I=I+Math.imul(Q,oe)|0,F=F+Math.imul(Q,pe)|0,M=M+Math.imul(O,Re)|0,I=I+Math.imul(O,De)|0,I=I+Math.imul(se,Re)|0,F=F+Math.imul(se,De)|0;var dt=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(dt>>>26)|0,dt&=67108863,M=Math.imul(rt,Jt),I=Math.imul(rt,St),I=I+Math.imul(Je,Jt)|0,F=Math.imul(Je,St),M=M+Math.imul(ct,Xt)|0,I=I+Math.imul(ct,Ot)|0,I=I+Math.imul($e,Xt)|0,F=F+Math.imul($e,Ot)|0,M=M+Math.imul(He,Tt)|0,I=I+Math.imul(He,vt)|0,I=I+Math.imul(Ee,Tt)|0,F=F+Math.imul(Ee,vt)|0,M=M+Math.imul(Ve,Lt)|0,I=I+Math.imul(Ve,bt)|0,I=I+Math.imul(ke,Lt)|0,F=F+Math.imul(ke,bt)|0,M=M+Math.imul(Be,Ut)|0,I=I+Math.imul(Be,nt)|0,I=I+Math.imul(Ie,Ut)|0,F=F+Math.imul(Ie,nt)|0,M=M+Math.imul(Me,B)|0,I=I+Math.imul(Me,H)|0,I=I+Math.imul(Ne,B)|0,F=F+Math.imul(Ne,H)|0,M=M+Math.imul(ie,C)|0,I=I+Math.imul(ie,Y)|0,I=I+Math.imul(fe,C)|0,F=F+Math.imul(fe,Y)|0,M=M+Math.imul(Z,oe)|0,I=I+Math.imul(Z,pe)|0,I=I+Math.imul(te,oe)|0,F=F+Math.imul(te,pe)|0,M=M+Math.imul(X,Re)|0,I=I+Math.imul(X,De)|0,I=I+Math.imul(Q,Re)|0,F=F+Math.imul(Q,De)|0;var _t=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(_t>>>26)|0,_t&=67108863,M=Math.imul(rt,Xt),I=Math.imul(rt,Ot),I=I+Math.imul(Je,Xt)|0,F=Math.imul(Je,Ot),M=M+Math.imul(ct,Tt)|0,I=I+Math.imul(ct,vt)|0,I=I+Math.imul($e,Tt)|0,F=F+Math.imul($e,vt)|0,M=M+Math.imul(He,Lt)|0,I=I+Math.imul(He,bt)|0,I=I+Math.imul(Ee,Lt)|0,F=F+Math.imul(Ee,bt)|0,M=M+Math.imul(Ve,Ut)|0,I=I+Math.imul(Ve,nt)|0,I=I+Math.imul(ke,Ut)|0,F=F+Math.imul(ke,nt)|0,M=M+Math.imul(Be,B)|0,I=I+Math.imul(Be,H)|0,I=I+Math.imul(Ie,B)|0,F=F+Math.imul(Ie,H)|0,M=M+Math.imul(Me,C)|0,I=I+Math.imul(Me,Y)|0,I=I+Math.imul(Ne,C)|0,F=F+Math.imul(Ne,Y)|0,M=M+Math.imul(ie,oe)|0,I=I+Math.imul(ie,pe)|0,I=I+Math.imul(fe,oe)|0,F=F+Math.imul(fe,pe)|0,M=M+Math.imul(Z,Re)|0,I=I+Math.imul(Z,De)|0,I=I+Math.imul(te,Re)|0,F=F+Math.imul(te,De)|0;var ot=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(ot>>>26)|0,ot&=67108863,M=Math.imul(rt,Tt),I=Math.imul(rt,vt),I=I+Math.imul(Je,Tt)|0,F=Math.imul(Je,vt),M=M+Math.imul(ct,Lt)|0,I=I+Math.imul(ct,bt)|0,I=I+Math.imul($e,Lt)|0,F=F+Math.imul($e,bt)|0,M=M+Math.imul(He,Ut)|0,I=I+Math.imul(He,nt)|0,I=I+Math.imul(Ee,Ut)|0,F=F+Math.imul(Ee,nt)|0,M=M+Math.imul(Ve,B)|0,I=I+Math.imul(Ve,H)|0,I=I+Math.imul(ke,B)|0,F=F+Math.imul(ke,H)|0,M=M+Math.imul(Be,C)|0,I=I+Math.imul(Be,Y)|0,I=I+Math.imul(Ie,C)|0,F=F+Math.imul(Ie,Y)|0,M=M+Math.imul(Me,oe)|0,I=I+Math.imul(Me,pe)|0,I=I+Math.imul(Ne,oe)|0,F=F+Math.imul(Ne,pe)|0,M=M+Math.imul(ie,Re)|0,I=I+Math.imul(ie,De)|0,I=I+Math.imul(fe,Re)|0,F=F+Math.imul(fe,De)|0;var wt=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(wt>>>26)|0,wt&=67108863,M=Math.imul(rt,Lt),I=Math.imul(rt,bt),I=I+Math.imul(Je,Lt)|0,F=Math.imul(Je,bt),M=M+Math.imul(ct,Ut)|0,I=I+Math.imul(ct,nt)|0,I=I+Math.imul($e,Ut)|0,F=F+Math.imul($e,nt)|0,M=M+Math.imul(He,B)|0,I=I+Math.imul(He,H)|0,I=I+Math.imul(Ee,B)|0,F=F+Math.imul(Ee,H)|0,M=M+Math.imul(Ve,C)|0,I=I+Math.imul(Ve,Y)|0,I=I+Math.imul(ke,C)|0,F=F+Math.imul(ke,Y)|0,M=M+Math.imul(Be,oe)|0,I=I+Math.imul(Be,pe)|0,I=I+Math.imul(Ie,oe)|0,F=F+Math.imul(Ie,pe)|0,M=M+Math.imul(Me,Re)|0,I=I+Math.imul(Me,De)|0,I=I+Math.imul(Ne,Re)|0,F=F+Math.imul(Ne,De)|0;var lt=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(lt>>>26)|0,lt&=67108863,M=Math.imul(rt,Ut),I=Math.imul(rt,nt),I=I+Math.imul(Je,Ut)|0,F=Math.imul(Je,nt),M=M+Math.imul(ct,B)|0,I=I+Math.imul(ct,H)|0,I=I+Math.imul($e,B)|0,F=F+Math.imul($e,H)|0,M=M+Math.imul(He,C)|0,I=I+Math.imul(He,Y)|0,I=I+Math.imul(Ee,C)|0,F=F+Math.imul(Ee,Y)|0,M=M+Math.imul(Ve,oe)|0,I=I+Math.imul(Ve,pe)|0,I=I+Math.imul(ke,oe)|0,F=F+Math.imul(ke,pe)|0,M=M+Math.imul(Be,Re)|0,I=I+Math.imul(Be,De)|0,I=I+Math.imul(Ie,Re)|0,F=F+Math.imul(Ie,De)|0;var at=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(at>>>26)|0,at&=67108863,M=Math.imul(rt,B),I=Math.imul(rt,H),I=I+Math.imul(Je,B)|0,F=Math.imul(Je,H),M=M+Math.imul(ct,C)|0,I=I+Math.imul(ct,Y)|0,I=I+Math.imul($e,C)|0,F=F+Math.imul($e,Y)|0,M=M+Math.imul(He,oe)|0,I=I+Math.imul(He,pe)|0,I=I+Math.imul(Ee,oe)|0,F=F+Math.imul(Ee,pe)|0,M=M+Math.imul(Ve,Re)|0,I=I+Math.imul(Ve,De)|0,I=I+Math.imul(ke,Re)|0,F=F+Math.imul(ke,De)|0;var Se=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(Se>>>26)|0,Se&=67108863,M=Math.imul(rt,C),I=Math.imul(rt,Y),I=I+Math.imul(Je,C)|0,F=Math.imul(Je,Y),M=M+Math.imul(ct,oe)|0,I=I+Math.imul(ct,pe)|0,I=I+Math.imul($e,oe)|0,F=F+Math.imul($e,pe)|0,M=M+Math.imul(He,Re)|0,I=I+Math.imul(He,De)|0,I=I+Math.imul(Ee,Re)|0,F=F+Math.imul(Ee,De)|0;var Ae=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,M=Math.imul(rt,oe),I=Math.imul(rt,pe),I=I+Math.imul(Je,oe)|0,F=Math.imul(Je,pe),M=M+Math.imul(ct,Re)|0,I=I+Math.imul(ct,De)|0,I=I+Math.imul($e,Re)|0,F=F+Math.imul($e,De)|0;var Ge=(b+M|0)+((I&8191)<<13)|0;b=(F+(I>>>13)|0)+(Ge>>>26)|0,Ge&=67108863,M=Math.imul(rt,Re),I=Math.imul(rt,De),I=I+Math.imul(Je,Re)|0,F=Math.imul(Je,De);var Ue=(b+M|0)+((I&8191)<<13)|0;return b=(F+(I>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,S[0]=it,S[1]=je,S[2]=gt,S[3]=st,S[4]=tt,S[5]=At,S[6]=Rt,S[7]=Mt,S[8]=Et,S[9]=dt,S[10]=_t,S[11]=ot,S[12]=wt,S[13]=lt,S[14]=at,S[15]=Se,S[16]=Ae,S[17]=Ge,S[18]=Ue,b!==0&&(S[19]=b,v.length++),v};Math.imul||($=k);function q(m,f,p){p.negative=f.negative^m.negative,p.length=m.length+f.length;for(var v=0,x=0,_=0;_>>26)|0,x+=S>>>26,S&=67108863}p.words[_]=b,v=S,S=x}return v!==0?p.words[_]=v:p.length--,p._strip()}function U(m,f,p){return q(m,f,p)}s.prototype.mulTo=function(f,p){var v,x=this.length+f.length;return this.length===10&&f.length===10?v=$(this,f,p):x<63?v=k(this,f,p):x<1024?v=q(this,f,p):v=U(this,f,p),v},s.prototype.mul=function(f){var p=new s(null);return p.words=new Array(this.length+f.length),this.mulTo(f,p)},s.prototype.mulf=function(f){var p=new s(null);return p.words=new Array(this.length+f.length),U(this,f,p)},s.prototype.imul=function(f){return this.clone().mulTo(f,this)},s.prototype.imuln=function(f){var p=f<0;p&&(f=-f),n(typeof f=="number"),n(f<67108864);for(var v=0,x=0;x>=26,v+=_/67108864|0,v+=S>>>26,this.words[x]=S&67108863}return v!==0&&(this.words[x]=v,this.length++),p?this.ineg():this},s.prototype.muln=function(f){return this.clone().imuln(f)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(f){var p=D(f);if(p.length===0)return new s(1);for(var v=this,x=0;x=0);var p=f%26,v=(f-p)/26,x=67108863>>>26-p<<26-p,_;if(p!==0){var S=0;for(_=0;_>>26-p}S&&(this.words[_]=S,this.length++)}if(v!==0){for(_=this.length-1;_>=0;_--)this.words[_+v]=this.words[_];for(_=0;_=0);var x;p?x=(p-p%26)/26:x=0;var _=f%26,S=Math.min((f-_)/26,this.length),b=67108863^67108863>>>_<<_,M=v;if(x-=S,x=Math.max(0,x),M){for(var I=0;IS)for(this.length-=S,I=0;I=0&&(F!==0||I>=x);I--){var ae=this.words[I]|0;this.words[I]=F<<26-_|ae>>>_,F=ae&b}return M&&F!==0&&(M.words[M.length++]=F),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(f,p,v){return n(this.negative===0),this.iushrn(f,p,v)},s.prototype.shln=function(f){return this.clone().ishln(f)},s.prototype.ushln=function(f){return this.clone().iushln(f)},s.prototype.shrn=function(f){return this.clone().ishrn(f)},s.prototype.ushrn=function(f){return this.clone().iushrn(f)},s.prototype.testn=function(f){n(typeof f=="number"&&f>=0);var p=f%26,v=(f-p)/26,x=1<=0);var p=f%26,v=(f-p)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(p!==0&&v++,this.length=Math.min(v,this.length),p!==0){var x=67108863^67108863>>>p<=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},s.prototype.isubn=function(f){if(n(typeof f=="number"),n(f<67108864),f<0)return this.iaddn(-f);if(this.negative!==0)return this.negative=0,this.iaddn(f),this.negative=1,this;if(this.words[0]-=f,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p>26)-(M/67108864|0),this.words[_+v]=S&67108863}for(;_>26,this.words[_+v]=S&67108863;if(b===0)return this._strip();for(n(b===-1),b=0,_=0;_>26,this.words[_]=S&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(f,p){var v=this.length-f.length,x=this.clone(),_=f,S=_.words[_.length-1]|0,b=this._countBits(S);v=26-b,v!==0&&(_=_.ushln(v),x.iushln(v),S=_.words[_.length-1]|0);var M=x.length-_.length,I;if(p!=="mod"){I=new s(null),I.length=M+1,I.words=new Array(I.length);for(var F=0;F=0;O--){var se=(x.words[_.length+O]|0)*67108864+(x.words[_.length+O-1]|0);for(se=Math.min(se/S|0,67108863),x._ishlnsubmul(_,se,O);x.negative!==0;)se--,x.negative=0,x._ishlnsubmul(_,1,O),x.isZero()||(x.negative^=1);I&&(I.words[O]=se)}return I&&I._strip(),x._strip(),p!=="div"&&v!==0&&x.iushrn(v),{div:I||null,mod:x}},s.prototype.divmod=function(f,p,v){if(n(!f.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var x,_,S;return this.negative!==0&&f.negative===0?(S=this.neg().divmod(f,p),p!=="mod"&&(x=S.div.neg()),p!=="div"&&(_=S.mod.neg(),v&&_.negative!==0&&_.iadd(f)),{div:x,mod:_}):this.negative===0&&f.negative!==0?(S=this.divmod(f.neg(),p),p!=="mod"&&(x=S.div.neg()),{div:x,mod:S.mod}):this.negative&f.negative?(S=this.neg().divmod(f.neg(),p),p!=="div"&&(_=S.mod.neg(),v&&_.negative!==0&&_.isub(f)),{div:S.div,mod:_}):f.length>this.length||this.cmp(f)<0?{div:new s(0),mod:this}:f.length===1?p==="div"?{div:this.divn(f.words[0]),mod:null}:p==="mod"?{div:null,mod:new s(this.modrn(f.words[0]))}:{div:this.divn(f.words[0]),mod:new s(this.modrn(f.words[0]))}:this._wordDiv(f,p)},s.prototype.div=function(f){return this.divmod(f,"div",!1).div},s.prototype.mod=function(f){return this.divmod(f,"mod",!1).mod},s.prototype.umod=function(f){return this.divmod(f,"mod",!0).mod},s.prototype.divRound=function(f){var p=this.divmod(f);if(p.mod.isZero())return p.div;var v=p.div.negative!==0?p.mod.isub(f):p.mod,x=f.ushrn(1),_=f.andln(1),S=v.cmp(x);return S<0||_===1&&S===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},s.prototype.modrn=function(f){var p=f<0;p&&(f=-f),n(f<=67108863);for(var v=(1<<26)%f,x=0,_=this.length-1;_>=0;_--)x=(v*x+(this.words[_]|0))%f;return p?-x:x},s.prototype.modn=function(f){return this.modrn(f)},s.prototype.idivn=function(f){var p=f<0;p&&(f=-f),n(f<=67108863);for(var v=0,x=this.length-1;x>=0;x--){var _=(this.words[x]|0)+v*67108864;this.words[x]=_/f|0,v=_%f}return this._strip(),p?this.ineg():this},s.prototype.divn=function(f){return this.clone().idivn(f)},s.prototype.egcd=function(f){n(f.negative===0),n(!f.isZero());var p=this,v=f.clone();p.negative!==0?p=p.umod(f):p=p.clone();for(var x=new s(1),_=new s(0),S=new s(0),b=new s(1),M=0;p.isEven()&&v.isEven();)p.iushrn(1),v.iushrn(1),++M;for(var I=v.clone(),F=p.clone();!p.isZero();){for(var ae=0,O=1;!(p.words[0]&O)&&ae<26;++ae,O<<=1);if(ae>0)for(p.iushrn(ae);ae-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(I),_.isub(F)),x.iushrn(1),_.iushrn(1);for(var se=0,ee=1;!(v.words[0]&ee)&&se<26;++se,ee<<=1);if(se>0)for(v.iushrn(se);se-- >0;)(S.isOdd()||b.isOdd())&&(S.iadd(I),b.isub(F)),S.iushrn(1),b.iushrn(1);p.cmp(v)>=0?(p.isub(v),x.isub(S),_.isub(b)):(v.isub(p),S.isub(x),b.isub(_))}return{a:S,b,gcd:v.iushln(M)}},s.prototype._invmp=function(f){n(f.negative===0),n(!f.isZero());var p=this,v=f.clone();p.negative!==0?p=p.umod(f):p=p.clone();for(var x=new s(1),_=new s(0),S=v.clone();p.cmpn(1)>0&&v.cmpn(1)>0;){for(var b=0,M=1;!(p.words[0]&M)&&b<26;++b,M<<=1);if(b>0)for(p.iushrn(b);b-- >0;)x.isOdd()&&x.iadd(S),x.iushrn(1);for(var I=0,F=1;!(v.words[0]&F)&&I<26;++I,F<<=1);if(I>0)for(v.iushrn(I);I-- >0;)_.isOdd()&&_.iadd(S),_.iushrn(1);p.cmp(v)>=0?(p.isub(v),x.isub(_)):(v.isub(p),_.isub(x))}var ae;return p.cmpn(1)===0?ae=x:ae=_,ae.cmpn(0)<0&&ae.iadd(f),ae},s.prototype.gcd=function(f){if(this.isZero())return f.abs();if(f.isZero())return this.abs();var p=this.clone(),v=f.clone();p.negative=0,v.negative=0;for(var x=0;p.isEven()&&v.isEven();x++)p.iushrn(1),v.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;v.isEven();)v.iushrn(1);var _=p.cmp(v);if(_<0){var S=p;p=v,v=S}else if(_===0||v.cmpn(1)===0)break;p.isub(v)}while(!0);return v.iushln(x)},s.prototype.invm=function(f){return this.egcd(f).a.umod(f)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(f){return this.words[0]&f},s.prototype.bincn=function(f){n(typeof f=="number");var p=f%26,v=(f-p)/26,x=1<>>26,b&=67108863,this.words[S]=b}return _!==0&&(this.words[S]=_,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(f){var p=f<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var v;if(this.length>1)v=1;else{p&&(f=-f),n(f<=67108863,"Number is too big");var x=this.words[0]|0;v=x===f?0:xf.length)return 1;if(this.length=0;v--){var x=this.words[v]|0,_=f.words[v]|0;if(x!==_){x<_?p=-1:x>_&&(p=1);break}}return p},s.prototype.gtn=function(f){return this.cmpn(f)===1},s.prototype.gt=function(f){return this.cmp(f)===1},s.prototype.gten=function(f){return this.cmpn(f)>=0},s.prototype.gte=function(f){return this.cmp(f)>=0},s.prototype.ltn=function(f){return this.cmpn(f)===-1},s.prototype.lt=function(f){return this.cmp(f)===-1},s.prototype.lten=function(f){return this.cmpn(f)<=0},s.prototype.lte=function(f){return this.cmp(f)<=0},s.prototype.eqn=function(f){return this.cmpn(f)===0},s.prototype.eq=function(f){return this.cmp(f)===0},s.red=function(f){return new G(f)},s.prototype.toRed=function(f){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),f.convertTo(this)._forceRed(f)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(f){return this.red=f,this},s.prototype.forceRed=function(f){return n(!this.red,"Already a number in reduction context"),this._forceRed(f)},s.prototype.redAdd=function(f){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,f)},s.prototype.redIAdd=function(f){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,f)},s.prototype.redSub=function(f){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,f)},s.prototype.redISub=function(f){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,f)},s.prototype.redShl=function(f){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,f)},s.prototype.redMul=function(f){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.mul(this,f)},s.prototype.redIMul=function(f){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,f),this.red.imul(this,f)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(f){return n(this.red&&!f.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,f)};var K={k256:null,p224:null,p192:null,p25519:null};function J(m,f){this.name=m,this.p=new s(f,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}J.prototype._tmp=function(){var f=new s(null);return f.words=new Array(Math.ceil(this.n/13)),f},J.prototype.ireduce=function(f){var p=f,v;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),v=p.bitLength();while(v>this.n);var x=v0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},J.prototype.split=function(f,p){f.iushrn(this.n,0,p)},J.prototype.imulK=function(f){return f.imul(this.k)};function T(){J.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(T,J),T.prototype.split=function(f,p){for(var v=4194303,x=Math.min(f.length,9),_=0;_>>22,S=b}S>>>=22,f.words[_-10]=S,S===0&&f.length>10?f.length-=10:f.length-=9},T.prototype.imulK=function(f){f.words[f.length]=0,f.words[f.length+1]=0,f.length+=2;for(var p=0,v=0;v>>=26,f.words[v]=_,p=x}return p!==0&&(f.words[f.length++]=p),f},s._prime=function(f){if(K[f])return K[f];var p;if(f==="k256")p=new T;else if(f==="p224")p=new z;else if(f==="p192")p=new ue;else if(f==="p25519")p=new _e;else throw new Error("Unknown prime "+f);return K[f]=p,p};function G(m){if(typeof m=="string"){var f=s._prime(m);this.m=f.p,this.prime=f}else n(m.gtn(1),"modulus must be greater than 1"),this.m=m,this.prime=null}G.prototype._verify1=function(f){n(f.negative===0,"red works only with positives"),n(f.red,"red works only with red numbers")},G.prototype._verify2=function(f,p){n((f.negative|p.negative)===0,"red works only with positives"),n(f.red&&f.red===p.red,"red works only with red numbers")},G.prototype.imod=function(f){return this.prime?this.prime.ireduce(f)._forceRed(this):(d(f,f.umod(this.m)._forceRed(this)),f)},G.prototype.neg=function(f){return f.isZero()?f.clone():this.m.sub(f)._forceRed(this)},G.prototype.add=function(f,p){this._verify2(f,p);var v=f.add(p);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},G.prototype.iadd=function(f,p){this._verify2(f,p);var v=f.iadd(p);return v.cmp(this.m)>=0&&v.isub(this.m),v},G.prototype.sub=function(f,p){this._verify2(f,p);var v=f.sub(p);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},G.prototype.isub=function(f,p){this._verify2(f,p);var v=f.isub(p);return v.cmpn(0)<0&&v.iadd(this.m),v},G.prototype.shl=function(f,p){return this._verify1(f),this.imod(f.ushln(p))},G.prototype.imul=function(f,p){return this._verify2(f,p),this.imod(f.imul(p))},G.prototype.mul=function(f,p){return this._verify2(f,p),this.imod(f.mul(p))},G.prototype.isqr=function(f){return this.imul(f,f.clone())},G.prototype.sqr=function(f){return this.mul(f,f)},G.prototype.sqrt=function(f){if(f.isZero())return f.clone();var p=this.m.andln(3);if(n(p%2===1),p===3){var v=this.m.add(new s(1)).iushrn(2);return this.pow(f,v)}for(var x=this.m.subn(1),_=0;!x.isZero()&&x.andln(1)===0;)_++,x.iushrn(1);n(!x.isZero());var S=new s(1).toRed(this),b=S.redNeg(),M=this.m.subn(1).iushrn(1),I=this.m.bitLength();for(I=new s(2*I*I).toRed(this);this.pow(I,M).cmp(b)!==0;)I.redIAdd(b);for(var F=this.pow(I,x),ae=this.pow(f,x.addn(1).iushrn(1)),O=this.pow(f,x),se=_;O.cmp(S)!==0;){for(var ee=O,X=0;ee.cmp(S)!==0;X++)ee=ee.redSqr();n(X=0;_--){for(var F=p.words[_],ae=I-1;ae>=0;ae--){var O=F>>ae&1;if(S!==x[0]&&(S=this.sqr(S)),O===0&&b===0){M=0;continue}b<<=1,b|=O,M++,!(M!==v&&(_!==0||ae!==0))&&(S=this.mul(S,x[b]),M=0,b=0)}I=26}return S},G.prototype.convertTo=function(f){var p=f.umod(this.m);return p===f?p.clone():p},G.prototype.convertFrom=function(f){var p=f.clone();return p.red=null,p},s.mont=function(f){return new E(f)};function E(m){G.call(this,m),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(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(E,G),E.prototype.convertTo=function(f){return this.imod(f.ushln(this.shift))},E.prototype.convertFrom=function(f){var p=this.imod(f.mul(this.rinv));return p.red=null,p},E.prototype.imul=function(f,p){if(f.isZero()||p.isZero())return f.words[0]=0,f.length=1,f;var v=f.imul(p),x=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=v.isub(x).iushrn(this.shift),S=_;return _.cmp(this.m)>=0?S=_.isub(this.m):_.cmpn(0)<0&&(S=_.iadd(this.m)),S._forceRed(this)},E.prototype.mul=function(f,p){if(f.isZero()||p.isZero())return new s(0)._forceRed(this);var v=f.mul(p),x=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),_=v.isub(x).iushrn(this.shift),S=_;return _.cmp(this.m)>=0?S=_.isub(this.m):_.cmpn(0)<0&&(S=_.iadd(this.m)),S._forceRed(this)},E.prototype.invm=function(f){var p=this.imod(f._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,nn)}(Em);var lN=Em.exports;const rr=Ui(lN);var hN=rr.BN;function dN(t){return new hN(t,36).toString(16)}const pN="strings/5.7.0",gN=new Kr(pN);var vd;(function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"})(vd||(vd={}));var Ux;(function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"})(Ux||(Ux={}));function Sm(t,e=vd.current){e!=vd.current&&(gN.checkNormalize(),t=t.normalize(e));let r=[];for(let n=0;n>6|192),r.push(i&63|128);else if((i&64512)==55296){n++;const s=t.charCodeAt(n);if(n>=t.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((i&1023)<<10)+(s&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(i>>12|224),r.push(i>>6&63|128),r.push(i&63|128)}return bn(r)}const mN=`Ethereum Signed Message: -`;function jx(t){return typeof t=="string"&&(t=Sm(t)),_m(cN([Sm(mN),Sm(String(t.length)),t]))}const vN="address/5.7.0",il=new Kr(vN);function qx(t){Os(t,20)||il.throwArgumentError("invalid address","address",t),t=t.toLowerCase();const e=t.substring(2).split(""),r=new Uint8Array(40);for(let i=0;i<40;i++)r[i]=e[i].charCodeAt(0);const n=bn(_m(r));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(n[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const bN=9007199254740991;function yN(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}const Am={};for(let t=0;t<10;t++)Am[String(t)]=String(t);for(let t=0;t<26;t++)Am[String.fromCharCode(65+t)]=String(10+t);const zx=Math.floor(yN(bN));function wN(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(n=>Am[n]).join("");for(;e.length>=zx;){let n=e.substring(0,zx);e=parseInt(n,10)%97+e.substring(n.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function xN(t){let e=null;if(typeof t!="string"&&il.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=qx(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&il.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==wN(t)&&il.throwArgumentError("bad icap checksum","address",t),e=dN(t.substring(4));e.length<40;)e="0"+e;e=qx("0x"+e)}else il.throwArgumentError("invalid address","address",t);return e}function sl(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}var ol={},yr={},Va=Hx;function Hx(t,e){if(!t)throw new Error(e||"Assertion failed")}Hx.equal=function(e,r,n){if(e!=r)throw new Error(n||"Assertion failed: "+e+" != "+r)};var Pm={exports:{}};typeof Object.create=="function"?Pm.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Pm.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}};var bd=Pm.exports,_N=Va,EN=bd;yr.inherits=EN;function SN(t,e){return(t.charCodeAt(e)&64512)!==55296||e<0||e+1>=t.length?!1:(t.charCodeAt(e+1)&64512)===56320}function AN(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if(typeof t=="string")if(e){if(e==="hex")for(t=t.replace(/[^a-z0-9]+/ig,""),t.length%2!==0&&(t="0"+t),i=0;i>6|192,r[n++]=s&63|128):SN(t,i)?(s=65536+((s&1023)<<10)+(t.charCodeAt(++i)&1023),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=s&63|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=s&63|128)}else for(i=0;i>>24|t>>>8&65280|t<<8&16711680|(t&255)<<24;return e>>>0}yr.htonl=Wx;function MN(t,e){for(var r="",n=0;n>>0}return s}yr.join32=IN;function CN(t,e){for(var r=new Array(t.length*4),n=0,i=0;n>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=s&255):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=s&255)}return r}yr.split32=CN;function TN(t,e){return t>>>e|t<<32-e}yr.rotr32=TN;function RN(t,e){return t<>>32-e}yr.rotl32=RN;function DN(t,e){return t+e>>>0}yr.sum32=DN;function ON(t,e,r){return t+e+r>>>0}yr.sum32_3=ON;function NN(t,e,r,n){return t+e+r+n>>>0}yr.sum32_4=NN;function LN(t,e,r,n,i){return t+e+r+n+i>>>0}yr.sum32_5=LN;function kN(t,e,r,n){var i=t[e],s=t[e+1],o=n+s>>>0,a=(o>>0,t[e+1]=o}yr.sum64=kN;function $N(t,e,r,n){var i=e+n>>>0,s=(i>>0}yr.sum64_hi=$N;function BN(t,e,r,n){var i=e+n;return i>>>0}yr.sum64_lo=BN;function FN(t,e,r,n,i,s,o,a){var u=0,l=e;l=l+n>>>0,u+=l>>0,u+=l>>0,u+=l>>0}yr.sum64_4_hi=FN;function UN(t,e,r,n,i,s,o,a){var u=e+n+s+a;return u>>>0}yr.sum64_4_lo=UN;function jN(t,e,r,n,i,s,o,a,u,l){var d=0,g=e;g=g+n>>>0,d+=g>>0,d+=g>>0,d+=g>>0,d+=g>>0}yr.sum64_5_hi=jN;function qN(t,e,r,n,i,s,o,a,u,l){var d=e+n+s+a+l;return d>>>0}yr.sum64_5_lo=qN;function zN(t,e,r){var n=e<<32-r|t>>>r;return n>>>0}yr.rotr64_hi=zN;function HN(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}yr.rotr64_lo=HN;function WN(t,e,r){return t>>>r}yr.shr64_hi=WN;function KN(t,e,r){var n=t<<32-r|e>>>r;return n>>>0}yr.shr64_lo=KN;var fu={},Gx=yr,VN=Va;function yd(){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}fu.BlockHash=yd,yd.prototype.update=function(e,r){if(e=Gx.toArray(e,r),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var n=e.length%this._delta8;this.pending=e.slice(e.length-n,e.length),this.pending.length===0&&(this.pending=null),e=Gx.join32(e,0,e.length-n,this.endian);for(var i=0;i>>24&255,i[s++]=e>>>16&255,i[s++]=e>>>8&255,i[s++]=e&255}else for(i[s++]=e&255,i[s++]=e>>>8&255,i[s++]=e>>>16&255,i[s++]=e>>>24&255,i[s++]=0,i[s++]=0,i[s++]=0,i[s++]=0,o=8;o>>3}Ns.g0_256=ZN;function QN(t){return Ls(t,17)^Ls(t,19)^t>>>10}Ns.g1_256=QN;var hu=yr,eL=fu,tL=Ns,Mm=hu.rotl32,al=hu.sum32,rL=hu.sum32_5,nL=tL.ft_1,Zx=eL.BlockHash,iL=[1518500249,1859775393,2400959708,3395469782];function ks(){if(!(this instanceof ks))return new ks;Zx.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}hu.inherits(ks,Zx);var sL=ks;ks.blockSize=512,ks.outSize=160,ks.hmacStrength=80,ks.padLength=64,ks.prototype._update=function(e,r){for(var n=this.W,i=0;i<16;i++)n[i]=e[r+i];for(;ithis.blockSize&&(e=new this.Hash().update(e).digest()),KL(e.length<=this.blockSize);for(var r=e.length;r>8,y=d&255;g?u.push(g,y):u.push(y)}return u}r.toArray=n;function i(o){return o.length===1?"0"+o:o}r.zero2=i;function s(o){for(var a="",u=0;u(y>>1)-1?N=(y>>1)-D:N=D,A.isubn(N)):N=0,g[P]=N,A.iushrn(1)}return g}r.getNAF=n;function i(u,l){var d=[[],[]];u=u.clone(),l=l.clone();for(var g=0,y=0,A;u.cmpn(-g)>0||l.cmpn(-y)>0;){var P=u.andln(3)+g&3,N=l.andln(3)+y&3;P===3&&(P=-1),N===3&&(N=-1);var D;P&1?(A=u.andln(7)+g&7,(A===3||A===5)&&N===2?D=-P:D=P):D=0,d[0].push(D);var k;N&1?(A=l.andln(7)+y&7,(A===3||A===5)&&P===2?k=-N:k=N):k=0,d[1].push(k),2*g===D+1&&(g=1-g),2*y===k+1&&(y=1-y),u.iushrn(1),l.iushrn(1)}return d}r.getJSF=i;function s(u,l,d){var g="_"+l;u.prototype[l]=function(){return this[g]!==void 0?this[g]:this[g]=d.call(this)}}r.cachedProperty=s;function o(u){return typeof u=="string"?r.toArray(u,"hex"):u}r.parseBytes=o;function a(u){return new rr(u,"hex","le")}r.intFromLE=a}),xd=Ci.getNAF,YL=Ci.getJSF,_d=Ci.assert;function ra(t,e){this.type=t,this.p=new rr(e.p,16),this.red=e.prime?rr.red(e.prime):rr.mont(this.p),this.zero=new rr(0).toRed(this.red),this.one=new rr(1).toRed(this.red),this.two=new rr(2).toRed(this.red),this.n=e.n&&new rr(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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Ya=ra;ra.prototype.point=function(){throw new Error("Not implemented")},ra.prototype.validate=function(){throw new Error("Not implemented")},ra.prototype._fixedNafMul=function(e,r){_d(e.precomputed);var n=e._getDoubles(),i=xd(r,1,this._bitLength),s=(1<=a;l--)u=(u<<1)+i[l];o.push(u)}for(var d=this.jpoint(null,null,null),g=this.jpoint(null,null,null),y=s;y>0;y--){for(a=0;a=0;u--){for(var l=0;u>=0&&o[u]===0;u--)l++;if(u>=0&&l++,a=a.dblp(l),u<0)break;var d=o[u];_d(d!==0),e.type==="affine"?d>0?a=a.mixedAdd(s[d-1>>1]):a=a.mixedAdd(s[-d-1>>1].neg()):d>0?a=a.add(s[d-1>>1]):a=a.add(s[-d-1>>1].neg())}return e.type==="affine"?a.toP():a},ra.prototype._wnafMulAdd=function(e,r,n,i,s){var o=this._wnafT1,a=this._wnafT2,u=this._wnafT3,l=0,d,g,y;for(d=0;d=1;d-=2){var P=d-1,N=d;if(o[P]!==1||o[N]!==1){u[P]=xd(n[P],o[P],this._bitLength),u[N]=xd(n[N],o[N],this._bitLength),l=Math.max(u[P].length,l),l=Math.max(u[N].length,l);continue}var D=[r[P],null,null,r[N]];r[P].y.cmp(r[N].y)===0?(D[1]=r[P].add(r[N]),D[2]=r[P].toJ().mixedAdd(r[N].neg())):r[P].y.cmp(r[N].y.redNeg())===0?(D[1]=r[P].toJ().mixedAdd(r[N]),D[2]=r[P].add(r[N].neg())):(D[1]=r[P].toJ().mixedAdd(r[N]),D[2]=r[P].toJ().mixedAdd(r[N].neg()));var k=[-3,-1,-5,-7,0,7,5,1,3],$=YL(n[P],n[N]);for(l=Math.max($[0].length,l),u[P]=new Array(l),u[N]=new Array(l),g=0;g=0;d--){for(var T=0;d>=0;){var z=!0;for(g=0;g=0&&T++,K=K.dblp(T),d<0)break;for(g=0;g0?y=a[g][ue-1>>1]:ue<0&&(y=a[g][-ue-1>>1].neg()),y.type==="affine"?K=K.mixedAdd(y):K=K.add(y))}}for(d=0;d=Math.ceil((e.bitLength()+1)/r.step):!1},zi.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,s=0;s=0&&(A=l,P=d),g.negative&&(g=g.neg(),y=y.neg()),A.negative&&(A=A.neg(),P=P.neg()),[{a:g,b:y},{a:A,b:P}]},Hi.prototype._endoSplit=function(e){var r=this.endo.basis,n=r[0],i=r[1],s=i.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),a=s.mul(n.a),u=o.mul(i.a),l=s.mul(n.b),d=o.mul(i.b),g=e.sub(a).sub(u),y=l.add(d).neg();return{k1:g,k2:y}},Hi.prototype.pointFromX=function(e,r){e=new rr(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(r&&!s||!r&&s)&&(i=i.redNeg()),this.point(e,i)},Hi.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,n=e.y,i=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(s).cmpn(0)===0},Hi.prototype._endoWnafMulAdd=function(e,r,n){for(var i=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""},Dn.prototype.isInfinity=function(){return this.inf},Dn.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 r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var n=r.redSqr().redISub(this.x).redISub(e.x),i=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)},Dn.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 r=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),s=n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i),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)},Dn.prototype.getX=function(){return this.x.fromRed()},Dn.prototype.getY=function(){return this.y.fromRed()},Dn.prototype.mul=function(e){return e=new rr(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)},Dn.prototype.mulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)},Dn.prototype.jmulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)},Dn.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)},Dn.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=function(s){return s.neg()};r.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return r},Dn.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 Un(t,e,r,n){Ya.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new rr(0)):(this.x=new rr(e,16),this.y=new rr(r,16),this.z=new rr(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.zOne=this.z===this.curve.one}Om(Un,Ya.BasePoint),Hi.prototype.jpoint=function(e,r,n){return new Un(this,e,r,n)},Un.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),n=this.x.redMul(r),i=this.y.redMul(r).redMul(e);return this.curve.point(n,i)},Un.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Un.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(r),s=e.x.redMul(n),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),u=i.redSub(s),l=o.redSub(a);if(u.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=u.redSqr(),g=d.redMul(u),y=i.redMul(d),A=l.redSqr().redIAdd(g).redISub(y).redISub(y),P=l.redMul(y.redISub(A)).redISub(o.redMul(g)),N=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(A,P,N)},Un.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),n=this.x,i=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=n.redSub(i),u=s.redSub(o);if(a.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),d=l.redMul(a),g=n.redMul(l),y=u.redSqr().redIAdd(d).redISub(g).redISub(g),A=u.redMul(g.redISub(y)).redISub(s.redMul(d)),P=this.z.redMul(a);return this.curve.jpoint(y,A,P)},Un.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var n=this;for(r=0;r=0)return!1;if(n.redIAdd(s),this.x.cmp(n)===0)return!0}},Un.prototype.inspect=function(){return this.isInfinity()?"":""},Un.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Ed=mu(function(t,e){var r=e;r.base=Ya,r.short=XL,r.mont=null,r.edwards=null}),Sd=mu(function(t,e){var r=e,n=Ci.assert;function i(a){a.type==="short"?this.curve=new Ed.short(a):a.type==="edwards"?this.curve=new Ed.edwards(a):this.curve=new Ed.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=i;function s(a,u){Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get:function(){var l=new i(u);return Object.defineProperty(r,a,{configurable:!0,enumerable:!0,value:l}),l}})}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:yo.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:yo.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:yo.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:yo.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:yo.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:yo.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:yo.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:yo.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function na(t){if(!(this instanceof na))return new na(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ms.toArray(t.entropy,t.entropyEnc||"hex"),r=ms.toArray(t.nonce,t.nonceEnc||"hex"),n=ms.toArray(t.pers,t.persEnc||"hex");Dm(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var d3=na;na.prototype._init=function(e,r,n){var i=e.concat(r).concat(n);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(n||[])),this._reseed=1},na.prototype.generate=function(e,r,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(i=n,n=r,r=null),n&&(n=ms.toArray(n,i||"hex"),this._update(n));for(var s=[];s.length"};var ZL=Ci.assert;function Ad(t,e){if(t instanceof Ad)return t;this._importDER(t,e)||(ZL(t.r&&t.s,"Signature without r or s"),this.r=new rr(t.r,16),this.s=new rr(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Pd=Ad;function QL(){this.place=0}function km(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4)return!1;for(var i=0,s=0,o=e.place;s>>=0;return i<=127?!1:(e.place=o,i)}function p3(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Ad.prototype.toDER=function(e){var r=this.r.toArray(),n=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),n[0]&128&&(n=[0].concat(n)),r=p3(r),n=p3(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];$m(i,r.length),i=i.concat(r),i.push(2),$m(i,n.length);var s=i.concat(n),o=[48];return $m(o,s.length),o=o.concat(s),Ci.encode(o,e)};var ek=function(){throw new Error("unsupported")},g3=Ci.assert;function Wi(t){if(!(this instanceof Wi))return new Wi(t);typeof t=="string"&&(g3(Object.prototype.hasOwnProperty.call(Sd,t),"Unknown curve "+t),t=Sd[t]),t instanceof Sd.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var tk=Wi;Wi.prototype.keyPair=function(e){return new Lm(this,e)},Wi.prototype.keyFromPrivate=function(e,r){return Lm.fromPrivate(this,e,r)},Wi.prototype.keyFromPublic=function(e,r){return Lm.fromPublic(this,e,r)},Wi.prototype.genKeyPair=function(e){e||(e={});for(var r=new d3({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||ek(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new rr(2));;){var s=new rr(r.generate(n));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Wi.prototype._truncateToN=function(e,r){var n=e.byteLength()*8-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},Wi.prototype.sign=function(e,r,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),r=this.keyFromPrivate(r,n),e=this._truncateToN(new rr(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),a=e.toArray("be",s),u=new d3({hash:this.hash,entropy:o,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),l=this.n.sub(new rr(1)),d=0;;d++){var g=i.k?i.k(d):new rr(u.generate(this.n.byteLength()));if(g=this._truncateToN(g,!0),!(g.cmpn(1)<=0||g.cmp(l)>=0)){var y=this.g.mul(g);if(!y.isInfinity()){var A=y.getX(),P=A.umod(this.n);if(P.cmpn(0)!==0){var N=g.invm(this.n).mul(P.mul(r.getPrivate()).iadd(e));if(N=N.umod(this.n),N.cmpn(0)!==0){var D=(y.getY().isOdd()?1:0)|(A.cmp(P)!==0?2:0);return i.canonical&&N.cmp(this.nh)>0&&(N=this.n.sub(N),D^=1),new Pd({r:P,s:N,recoveryParam:D})}}}}}},Wi.prototype.verify=function(e,r,n,i){e=this._truncateToN(new rr(e,16)),n=this.keyFromPublic(n,i),r=new Pd(r,"hex");var s=r.r,o=r.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),u=a.mul(e).umod(this.n),l=a.mul(s).umod(this.n),d;return this.curve._maxwellTrick?(d=this.g.jmulAdd(u,n.getPublic(),l),d.isInfinity()?!1:d.eqXToP(s)):(d=this.g.mulAdd(u,n.getPublic(),l),d.isInfinity()?!1:d.getX().umod(this.n).cmp(s)===0)},Wi.prototype.recoverPubKey=function(t,e,r,n){g3((3&r)===r,"The recovery param is more than two bits"),e=new Pd(e,n);var i=this.n,s=new rr(t),o=e.r,a=e.s,u=r&1,l=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");l?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var d=e.r.invm(i),g=i.sub(s).mul(d).umod(i),y=a.mul(d).umod(i);return this.g.mulAdd(g,o,y)},Wi.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new Pd(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch{continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var rk=mu(function(t,e){var r=e;r.version="6.5.4",r.utils=Ci,r.rand=function(){throw new Error("unsupported")},r.curve=Ed,r.curves=Sd,r.ec=tk,r.eddsa=null}),nk=rk.ec;const ik="signing-key/5.7.0",Bm=new Kr(ik);let Fm=null;function ia(){return Fm||(Fm=new nk("secp256k1")),Fm}class sk{constructor(e){sl(this,"curve","secp256k1"),sl(this,"privateKey",Ii(e)),fN(this.privateKey)!==32&&Bm.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=ia().keyFromPrivate(bn(this.privateKey));sl(this,"publicKey","0x"+r.getPublic(!1,"hex")),sl(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),sl(this,"_isSigningKey",!0)}_addPoint(e){const r=ia().keyFromPublic(bn(this.publicKey)),n=ia().keyFromPublic(bn(e));return"0x"+r.pub.add(n.pub).encodeCompressed("hex")}signDigest(e){const r=ia().keyFromPrivate(bn(this.privateKey)),n=bn(e);n.length!==32&&Bm.throwArgumentError("bad digest length","digest",e);const i=r.sign(n,{canonical:!0});return Fx({recoveryParam:i.recoveryParam,r:uu("0x"+i.r.toString(16),32),s:uu("0x"+i.s.toString(16),32)})}computeSharedSecret(e){const r=ia().keyFromPrivate(bn(this.privateKey)),n=ia().keyFromPublic(bn(m3(e)));return uu("0x"+r.derive(n.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function ok(t,e){const r=Fx(e),n={r:bn(r.r),s:bn(r.s)};return"0x"+ia().recoverPubKey(bn(t),n,r.recoveryParam).encode("hex",!1)}function m3(t,e){const r=bn(t);return r.length===32?new sk(r).publicKey:r.length===33?"0x"+ia().keyFromPublic(r).getPublic(!1,"hex"):r.length===65?Ii(r):Bm.throwArgumentError("invalid public or private key","key","[REDACTED]")}var v3;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(v3||(v3={}));function ak(t){const e=m3(t);return xN(Bx(_m(Bx(e,1)),12))}function ck(t,e){return ak(ok(bn(t),e))}var Um={},Md={};Object.defineProperty(Md,"__esModule",{value:!0});var Yn=or,jm=Mi,uk=20;function fk(t,e,r){for(var n=1634760805,i=857760878,s=2036477234,o=1797285236,a=r[3]<<24|r[2]<<16|r[1]<<8|r[0],u=r[7]<<24|r[6]<<16|r[5]<<8|r[4],l=r[11]<<24|r[10]<<16|r[9]<<8|r[8],d=r[15]<<24|r[14]<<16|r[13]<<8|r[12],g=r[19]<<24|r[18]<<16|r[17]<<8|r[16],y=r[23]<<24|r[22]<<16|r[21]<<8|r[20],A=r[27]<<24|r[26]<<16|r[25]<<8|r[24],P=r[31]<<24|r[30]<<16|r[29]<<8|r[28],N=e[3]<<24|e[2]<<16|e[1]<<8|e[0],D=e[7]<<24|e[6]<<16|e[5]<<8|e[4],k=e[11]<<24|e[10]<<16|e[9]<<8|e[8],$=e[15]<<24|e[14]<<16|e[13]<<8|e[12],q=n,U=i,K=s,J=o,T=a,z=u,ue=l,_e=d,G=g,E=y,m=A,f=P,p=N,v=D,x=k,_=$,S=0;S>>16|p<<16,G=G+p|0,T^=G,T=T>>>20|T<<12,U=U+z|0,v^=U,v=v>>>16|v<<16,E=E+v|0,z^=E,z=z>>>20|z<<12,K=K+ue|0,x^=K,x=x>>>16|x<<16,m=m+x|0,ue^=m,ue=ue>>>20|ue<<12,J=J+_e|0,_^=J,_=_>>>16|_<<16,f=f+_|0,_e^=f,_e=_e>>>20|_e<<12,K=K+ue|0,x^=K,x=x>>>24|x<<8,m=m+x|0,ue^=m,ue=ue>>>25|ue<<7,J=J+_e|0,_^=J,_=_>>>24|_<<8,f=f+_|0,_e^=f,_e=_e>>>25|_e<<7,U=U+z|0,v^=U,v=v>>>24|v<<8,E=E+v|0,z^=E,z=z>>>25|z<<7,q=q+T|0,p^=q,p=p>>>24|p<<8,G=G+p|0,T^=G,T=T>>>25|T<<7,q=q+z|0,_^=q,_=_>>>16|_<<16,m=m+_|0,z^=m,z=z>>>20|z<<12,U=U+ue|0,p^=U,p=p>>>16|p<<16,f=f+p|0,ue^=f,ue=ue>>>20|ue<<12,K=K+_e|0,v^=K,v=v>>>16|v<<16,G=G+v|0,_e^=G,_e=_e>>>20|_e<<12,J=J+T|0,x^=J,x=x>>>16|x<<16,E=E+x|0,T^=E,T=T>>>20|T<<12,K=K+_e|0,v^=K,v=v>>>24|v<<8,G=G+v|0,_e^=G,_e=_e>>>25|_e<<7,J=J+T|0,x^=J,x=x>>>24|x<<8,E=E+x|0,T^=E,T=T>>>25|T<<7,U=U+ue|0,p^=U,p=p>>>24|p<<8,f=f+p|0,ue^=f,ue=ue>>>25|ue<<7,q=q+z|0,_^=q,_=_>>>24|_<<8,m=m+_|0,z^=m,z=z>>>25|z<<7;Yn.writeUint32LE(q+n|0,t,0),Yn.writeUint32LE(U+i|0,t,4),Yn.writeUint32LE(K+s|0,t,8),Yn.writeUint32LE(J+o|0,t,12),Yn.writeUint32LE(T+a|0,t,16),Yn.writeUint32LE(z+u|0,t,20),Yn.writeUint32LE(ue+l|0,t,24),Yn.writeUint32LE(_e+d|0,t,28),Yn.writeUint32LE(G+g|0,t,32),Yn.writeUint32LE(E+y|0,t,36),Yn.writeUint32LE(m+A|0,t,40),Yn.writeUint32LE(f+P|0,t,44),Yn.writeUint32LE(p+N|0,t,48),Yn.writeUint32LE(v+D|0,t,52),Yn.writeUint32LE(x+k|0,t,56),Yn.writeUint32LE(_+$|0,t,60)}function b3(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var y3={},sa={};Object.defineProperty(sa,"__esModule",{value:!0});function dk(t,e,r){return~(t-1)&e|t-1&r}sa.select=dk;function pk(t,e){return(t|0)-(e|0)-1>>>31&1}sa.lessOrEqual=pk;function w3(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n>>8}sa.compare=w3;function gk(t,e){return t.length===0||e.length===0?!1:w3(t,e)!==0}sa.equal=gk,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=sa,r=Mi;t.DIGEST_LENGTH=16;var n=function(){function o(a){this.digestLength=t.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 u=a[0]|a[1]<<8;this._r[0]=u&8191;var l=a[2]|a[3]<<8;this._r[1]=(u>>>13|l<<3)&8191;var d=a[4]|a[5]<<8;this._r[2]=(l>>>10|d<<6)&7939;var g=a[6]|a[7]<<8;this._r[3]=(d>>>7|g<<9)&8191;var y=a[8]|a[9]<<8;this._r[4]=(g>>>4|y<<12)&255,this._r[5]=y>>>1&8190;var A=a[10]|a[11]<<8;this._r[6]=(y>>>14|A<<2)&8191;var P=a[12]|a[13]<<8;this._r[7]=(A>>>11|P<<5)&8065;var N=a[14]|a[15]<<8;this._r[8]=(P>>>8|N<<8)&8191,this._r[9]=N>>>5&127,this._pad[0]=a[16]|a[17]<<8,this._pad[1]=a[18]|a[19]<<8,this._pad[2]=a[20]|a[21]<<8,this._pad[3]=a[22]|a[23]<<8,this._pad[4]=a[24]|a[25]<<8,this._pad[5]=a[26]|a[27]<<8,this._pad[6]=a[28]|a[29]<<8,this._pad[7]=a[30]|a[31]<<8}return o.prototype._blocks=function(a,u,l){for(var d=this._fin?0:2048,g=this._h[0],y=this._h[1],A=this._h[2],P=this._h[3],N=this._h[4],D=this._h[5],k=this._h[6],$=this._h[7],q=this._h[8],U=this._h[9],K=this._r[0],J=this._r[1],T=this._r[2],z=this._r[3],ue=this._r[4],_e=this._r[5],G=this._r[6],E=this._r[7],m=this._r[8],f=this._r[9];l>=16;){var p=a[u+0]|a[u+1]<<8;g+=p&8191;var v=a[u+2]|a[u+3]<<8;y+=(p>>>13|v<<3)&8191;var x=a[u+4]|a[u+5]<<8;A+=(v>>>10|x<<6)&8191;var _=a[u+6]|a[u+7]<<8;P+=(x>>>7|_<<9)&8191;var S=a[u+8]|a[u+9]<<8;N+=(_>>>4|S<<12)&8191,D+=S>>>1&8191;var b=a[u+10]|a[u+11]<<8;k+=(S>>>14|b<<2)&8191;var M=a[u+12]|a[u+13]<<8;$+=(b>>>11|M<<5)&8191;var I=a[u+14]|a[u+15]<<8;q+=(M>>>8|I<<8)&8191,U+=I>>>5|d;var F=0,ae=F;ae+=g*K,ae+=y*(5*f),ae+=A*(5*m),ae+=P*(5*E),ae+=N*(5*G),F=ae>>>13,ae&=8191,ae+=D*(5*_e),ae+=k*(5*ue),ae+=$*(5*z),ae+=q*(5*T),ae+=U*(5*J),F+=ae>>>13,ae&=8191;var O=F;O+=g*J,O+=y*K,O+=A*(5*f),O+=P*(5*m),O+=N*(5*E),F=O>>>13,O&=8191,O+=D*(5*G),O+=k*(5*_e),O+=$*(5*ue),O+=q*(5*z),O+=U*(5*T),F+=O>>>13,O&=8191;var se=F;se+=g*T,se+=y*J,se+=A*K,se+=P*(5*f),se+=N*(5*m),F=se>>>13,se&=8191,se+=D*(5*E),se+=k*(5*G),se+=$*(5*_e),se+=q*(5*ue),se+=U*(5*z),F+=se>>>13,se&=8191;var ee=F;ee+=g*z,ee+=y*T,ee+=A*J,ee+=P*K,ee+=N*(5*f),F=ee>>>13,ee&=8191,ee+=D*(5*m),ee+=k*(5*E),ee+=$*(5*G),ee+=q*(5*_e),ee+=U*(5*ue),F+=ee>>>13,ee&=8191;var X=F;X+=g*ue,X+=y*z,X+=A*T,X+=P*J,X+=N*K,F=X>>>13,X&=8191,X+=D*(5*f),X+=k*(5*m),X+=$*(5*E),X+=q*(5*G),X+=U*(5*_e),F+=X>>>13,X&=8191;var Q=F;Q+=g*_e,Q+=y*ue,Q+=A*z,Q+=P*T,Q+=N*J,F=Q>>>13,Q&=8191,Q+=D*K,Q+=k*(5*f),Q+=$*(5*m),Q+=q*(5*E),Q+=U*(5*G),F+=Q>>>13,Q&=8191;var R=F;R+=g*G,R+=y*_e,R+=A*ue,R+=P*z,R+=N*T,F=R>>>13,R&=8191,R+=D*J,R+=k*K,R+=$*(5*f),R+=q*(5*m),R+=U*(5*E),F+=R>>>13,R&=8191;var Z=F;Z+=g*E,Z+=y*G,Z+=A*_e,Z+=P*ue,Z+=N*z,F=Z>>>13,Z&=8191,Z+=D*T,Z+=k*J,Z+=$*K,Z+=q*(5*f),Z+=U*(5*m),F+=Z>>>13,Z&=8191;var te=F;te+=g*m,te+=y*E,te+=A*G,te+=P*_e,te+=N*ue,F=te>>>13,te&=8191,te+=D*z,te+=k*T,te+=$*J,te+=q*K,te+=U*(5*f),F+=te>>>13,te&=8191;var le=F;le+=g*f,le+=y*m,le+=A*E,le+=P*G,le+=N*_e,F=le>>>13,le&=8191,le+=D*ue,le+=k*z,le+=$*T,le+=q*J,le+=U*K,F+=le>>>13,le&=8191,F=(F<<2)+F|0,F=F+ae|0,ae=F&8191,F=F>>>13,O+=F,g=ae,y=O,A=se,P=ee,N=X,D=Q,k=R,$=Z,q=te,U=le,u+=16,l-=16}this._h[0]=g,this._h[1]=y,this._h[2]=A,this._h[3]=P,this._h[4]=N,this._h[5]=D,this._h[6]=k,this._h[7]=$,this._h[8]=q,this._h[9]=U},o.prototype.finish=function(a,u){u===void 0&&(u=0);var l=new Uint16Array(10),d,g,y,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(d=this._h[1]>>>13,this._h[1]&=8191,A=2;A<10;A++)this._h[A]+=d,d=this._h[A]>>>13,this._h[A]&=8191;for(this._h[0]+=d*5,d=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=d,d=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=d,l[0]=this._h[0]+5,d=l[0]>>>13,l[0]&=8191,A=1;A<10;A++)l[A]=this._h[A]+d,d=l[A]>>>13,l[A]&=8191;for(l[9]-=8192,g=(d^1)-1,A=0;A<10;A++)l[A]&=g;for(g=~g,A=0;A<10;A++)this._h[A]=this._h[A]&g|l[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,y=this._h[0]+this._pad[0],this._h[0]=y&65535,A=1;A<8;A++)y=(this._h[A]+this._pad[A]|0)+(y>>>16)|0,this._h[A]=y&65535;return a[u+0]=this._h[0]>>>0,a[u+1]=this._h[0]>>>8,a[u+2]=this._h[1]>>>0,a[u+3]=this._h[1]>>>8,a[u+4]=this._h[2]>>>0,a[u+5]=this._h[2]>>>8,a[u+6]=this._h[3]>>>0,a[u+7]=this._h[3]>>>8,a[u+8]=this._h[4]>>>0,a[u+9]=this._h[4]>>>8,a[u+10]=this._h[5]>>>0,a[u+11]=this._h[5]>>>8,a[u+12]=this._h[6]>>>0,a[u+13]=this._h[6]>>>8,a[u+14]=this._h[7]>>>0,a[u+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(a){var u=0,l=a.length,d;if(this._leftover){d=16-this._leftover,d>l&&(d=l);for(var g=0;g=16&&(d=l-l%16,this._blocks(a,u,d),u+=d,l-=d),l){for(var g=0;g16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var A=new Uint8Array(16);A.set(l,A.length-l.length);var P=new Uint8Array(32);e.stream(this._key,A,P,4);var N=d.length+this.tagLength,D;if(y){if(y.length!==N)throw new Error("ChaCha20Poly1305: incorrect destination length");D=y}else D=new Uint8Array(N);return e.streamXOR(this._key,A,d,D,4),this._authenticate(D.subarray(D.length-this.tagLength,D.length),P,D.subarray(0,D.length-this.tagLength),g),n.wipe(A),D},u.prototype.open=function(l,d,g,y){if(l.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(d.length0&&A.update(o.subarray(y.length%16))),A.update(g),g.length%16>0&&A.update(o.subarray(g.length%16));var P=new Uint8Array(8);y&&i.writeUint64LE(y.length,P),A.update(P),i.writeUint64LE(g.length,P),A.update(P);for(var N=A.digest(),D=0;Dthis.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i1&&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},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=u[d++],l--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(l>=this.blockSize&&(d=s(this._temp,this._state,u,d,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=u[d++],l--;return this},a.prototype.finish=function(u){if(!this._finished){var l=this._bytesHashed,d=this._bufferLength,g=l/536870912|0,y=l<<3,A=l%64<56?64:128;this._buffer[d]=128;for(var P=d+1;P0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(u){return this._state.set(u.state),this._bufferLength=u.bufferLength,u.buffer&&this._buffer.set(u.buffer),this._bytesHashed=u.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(u){r.wipe(u.state),u.buffer&&r.wipe(u.buffer),u.bufferLength=0,u.bytesHashed=0},a}();t.SHA256=n;var i=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 s(a,u,l,d,g){for(;g>=64;){for(var y=u[0],A=u[1],P=u[2],N=u[3],D=u[4],k=u[5],$=u[6],q=u[7],U=0;U<16;U++){var K=d+U*4;a[U]=e.readUint32BE(l,K)}for(var U=16;U<64;U++){var J=a[U-2],T=(J>>>17|J<<15)^(J>>>19|J<<13)^J>>>10;J=a[U-15];var z=(J>>>7|J<<25)^(J>>>18|J<<14)^J>>>3;a[U]=(T+a[U-7]|0)+(z+a[U-16]|0)}for(var U=0;U<64;U++){var T=(((D>>>6|D<<26)^(D>>>11|D<<21)^(D>>>25|D<<7))+(D&k^~D&$)|0)+(q+(i[U]+a[U]|0)|0)|0,z=((y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10))+(y&A^y&P^A&P)|0;q=$,$=k,k=D,D=N+T|0,N=P,P=A,A=y,y=T+z|0}u[0]+=y,u[1]+=A,u[2]+=P,u[3]+=N,u[4]+=D,u[5]+=k,u[6]+=$,u[7]+=q,d+=64,g-=64}return d}function o(a){var u=new n;u.update(a);var l=u.digest();return u.clean(),l}t.hash=o})(fl);var zm={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=ea,r=Mi;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(U){const K=new Float64Array(16);if(U)for(let J=0;J>16&1),J[_e-1]&=65535;J[15]=T[15]-32767-(J[14]>>16&1);const ue=J[15]>>16&1;J[14]&=65535,a(T,J,1-ue)}for(let z=0;z<16;z++)U[2*z]=T[z]&255,U[2*z+1]=T[z]>>8}function l(U,K){for(let J=0;J<16;J++)U[J]=K[2*J]+(K[2*J+1]<<8);U[15]&=32767}function d(U,K,J){for(let T=0;T<16;T++)U[T]=K[T]+J[T]}function g(U,K,J){for(let T=0;T<16;T++)U[T]=K[T]-J[T]}function y(U,K,J){let T,z,ue=0,_e=0,G=0,E=0,m=0,f=0,p=0,v=0,x=0,_=0,S=0,b=0,M=0,I=0,F=0,ae=0,O=0,se=0,ee=0,X=0,Q=0,R=0,Z=0,te=0,le=0,ie=0,fe=0,ve=0,Me=0,Ne=0,Te=0,Be=J[0],Ie=J[1],Le=J[2],Ve=J[3],ke=J[4],ze=J[5],He=J[6],Ee=J[7],Qe=J[8],ct=J[9],$e=J[10],et=J[11],rt=J[12],Je=J[13],pt=J[14],ht=J[15];T=K[0],ue+=T*Be,_e+=T*Ie,G+=T*Le,E+=T*Ve,m+=T*ke,f+=T*ze,p+=T*He,v+=T*Ee,x+=T*Qe,_+=T*ct,S+=T*$e,b+=T*et,M+=T*rt,I+=T*Je,F+=T*pt,ae+=T*ht,T=K[1],_e+=T*Be,G+=T*Ie,E+=T*Le,m+=T*Ve,f+=T*ke,p+=T*ze,v+=T*He,x+=T*Ee,_+=T*Qe,S+=T*ct,b+=T*$e,M+=T*et,I+=T*rt,F+=T*Je,ae+=T*pt,O+=T*ht,T=K[2],G+=T*Be,E+=T*Ie,m+=T*Le,f+=T*Ve,p+=T*ke,v+=T*ze,x+=T*He,_+=T*Ee,S+=T*Qe,b+=T*ct,M+=T*$e,I+=T*et,F+=T*rt,ae+=T*Je,O+=T*pt,se+=T*ht,T=K[3],E+=T*Be,m+=T*Ie,f+=T*Le,p+=T*Ve,v+=T*ke,x+=T*ze,_+=T*He,S+=T*Ee,b+=T*Qe,M+=T*ct,I+=T*$e,F+=T*et,ae+=T*rt,O+=T*Je,se+=T*pt,ee+=T*ht,T=K[4],m+=T*Be,f+=T*Ie,p+=T*Le,v+=T*Ve,x+=T*ke,_+=T*ze,S+=T*He,b+=T*Ee,M+=T*Qe,I+=T*ct,F+=T*$e,ae+=T*et,O+=T*rt,se+=T*Je,ee+=T*pt,X+=T*ht,T=K[5],f+=T*Be,p+=T*Ie,v+=T*Le,x+=T*Ve,_+=T*ke,S+=T*ze,b+=T*He,M+=T*Ee,I+=T*Qe,F+=T*ct,ae+=T*$e,O+=T*et,se+=T*rt,ee+=T*Je,X+=T*pt,Q+=T*ht,T=K[6],p+=T*Be,v+=T*Ie,x+=T*Le,_+=T*Ve,S+=T*ke,b+=T*ze,M+=T*He,I+=T*Ee,F+=T*Qe,ae+=T*ct,O+=T*$e,se+=T*et,ee+=T*rt,X+=T*Je,Q+=T*pt,R+=T*ht,T=K[7],v+=T*Be,x+=T*Ie,_+=T*Le,S+=T*Ve,b+=T*ke,M+=T*ze,I+=T*He,F+=T*Ee,ae+=T*Qe,O+=T*ct,se+=T*$e,ee+=T*et,X+=T*rt,Q+=T*Je,R+=T*pt,Z+=T*ht,T=K[8],x+=T*Be,_+=T*Ie,S+=T*Le,b+=T*Ve,M+=T*ke,I+=T*ze,F+=T*He,ae+=T*Ee,O+=T*Qe,se+=T*ct,ee+=T*$e,X+=T*et,Q+=T*rt,R+=T*Je,Z+=T*pt,te+=T*ht,T=K[9],_+=T*Be,S+=T*Ie,b+=T*Le,M+=T*Ve,I+=T*ke,F+=T*ze,ae+=T*He,O+=T*Ee,se+=T*Qe,ee+=T*ct,X+=T*$e,Q+=T*et,R+=T*rt,Z+=T*Je,te+=T*pt,le+=T*ht,T=K[10],S+=T*Be,b+=T*Ie,M+=T*Le,I+=T*Ve,F+=T*ke,ae+=T*ze,O+=T*He,se+=T*Ee,ee+=T*Qe,X+=T*ct,Q+=T*$e,R+=T*et,Z+=T*rt,te+=T*Je,le+=T*pt,ie+=T*ht,T=K[11],b+=T*Be,M+=T*Ie,I+=T*Le,F+=T*Ve,ae+=T*ke,O+=T*ze,se+=T*He,ee+=T*Ee,X+=T*Qe,Q+=T*ct,R+=T*$e,Z+=T*et,te+=T*rt,le+=T*Je,ie+=T*pt,fe+=T*ht,T=K[12],M+=T*Be,I+=T*Ie,F+=T*Le,ae+=T*Ve,O+=T*ke,se+=T*ze,ee+=T*He,X+=T*Ee,Q+=T*Qe,R+=T*ct,Z+=T*$e,te+=T*et,le+=T*rt,ie+=T*Je,fe+=T*pt,ve+=T*ht,T=K[13],I+=T*Be,F+=T*Ie,ae+=T*Le,O+=T*Ve,se+=T*ke,ee+=T*ze,X+=T*He,Q+=T*Ee,R+=T*Qe,Z+=T*ct,te+=T*$e,le+=T*et,ie+=T*rt,fe+=T*Je,ve+=T*pt,Me+=T*ht,T=K[14],F+=T*Be,ae+=T*Ie,O+=T*Le,se+=T*Ve,ee+=T*ke,X+=T*ze,Q+=T*He,R+=T*Ee,Z+=T*Qe,te+=T*ct,le+=T*$e,ie+=T*et,fe+=T*rt,ve+=T*Je,Me+=T*pt,Ne+=T*ht,T=K[15],ae+=T*Be,O+=T*Ie,se+=T*Le,ee+=T*Ve,X+=T*ke,Q+=T*ze,R+=T*He,Z+=T*Ee,te+=T*Qe,le+=T*ct,ie+=T*$e,fe+=T*et,ve+=T*rt,Me+=T*Je,Ne+=T*pt,Te+=T*ht,ue+=38*O,_e+=38*se,G+=38*ee,E+=38*X,m+=38*Q,f+=38*R,p+=38*Z,v+=38*te,x+=38*le,_+=38*ie,S+=38*fe,b+=38*ve,M+=38*Me,I+=38*Ne,F+=38*Te,z=1,T=ue+z+65535,z=Math.floor(T/65536),ue=T-z*65536,T=_e+z+65535,z=Math.floor(T/65536),_e=T-z*65536,T=G+z+65535,z=Math.floor(T/65536),G=T-z*65536,T=E+z+65535,z=Math.floor(T/65536),E=T-z*65536,T=m+z+65535,z=Math.floor(T/65536),m=T-z*65536,T=f+z+65535,z=Math.floor(T/65536),f=T-z*65536,T=p+z+65535,z=Math.floor(T/65536),p=T-z*65536,T=v+z+65535,z=Math.floor(T/65536),v=T-z*65536,T=x+z+65535,z=Math.floor(T/65536),x=T-z*65536,T=_+z+65535,z=Math.floor(T/65536),_=T-z*65536,T=S+z+65535,z=Math.floor(T/65536),S=T-z*65536,T=b+z+65535,z=Math.floor(T/65536),b=T-z*65536,T=M+z+65535,z=Math.floor(T/65536),M=T-z*65536,T=I+z+65535,z=Math.floor(T/65536),I=T-z*65536,T=F+z+65535,z=Math.floor(T/65536),F=T-z*65536,T=ae+z+65535,z=Math.floor(T/65536),ae=T-z*65536,ue+=z-1+37*(z-1),z=1,T=ue+z+65535,z=Math.floor(T/65536),ue=T-z*65536,T=_e+z+65535,z=Math.floor(T/65536),_e=T-z*65536,T=G+z+65535,z=Math.floor(T/65536),G=T-z*65536,T=E+z+65535,z=Math.floor(T/65536),E=T-z*65536,T=m+z+65535,z=Math.floor(T/65536),m=T-z*65536,T=f+z+65535,z=Math.floor(T/65536),f=T-z*65536,T=p+z+65535,z=Math.floor(T/65536),p=T-z*65536,T=v+z+65535,z=Math.floor(T/65536),v=T-z*65536,T=x+z+65535,z=Math.floor(T/65536),x=T-z*65536,T=_+z+65535,z=Math.floor(T/65536),_=T-z*65536,T=S+z+65535,z=Math.floor(T/65536),S=T-z*65536,T=b+z+65535,z=Math.floor(T/65536),b=T-z*65536,T=M+z+65535,z=Math.floor(T/65536),M=T-z*65536,T=I+z+65535,z=Math.floor(T/65536),I=T-z*65536,T=F+z+65535,z=Math.floor(T/65536),F=T-z*65536,T=ae+z+65535,z=Math.floor(T/65536),ae=T-z*65536,ue+=z-1+37*(z-1),U[0]=ue,U[1]=_e,U[2]=G,U[3]=E,U[4]=m,U[5]=f,U[6]=p,U[7]=v,U[8]=x,U[9]=_,U[10]=S,U[11]=b,U[12]=M,U[13]=I,U[14]=F,U[15]=ae}function A(U,K){y(U,K,K)}function P(U,K){const J=n();for(let T=0;T<16;T++)J[T]=K[T];for(let T=253;T>=0;T--)A(J,J),T!==2&&T!==4&&y(J,J,K);for(let T=0;T<16;T++)U[T]=J[T]}function N(U,K){const J=new Uint8Array(32),T=new Float64Array(80),z=n(),ue=n(),_e=n(),G=n(),E=n(),m=n();for(let x=0;x<31;x++)J[x]=U[x];J[31]=U[31]&127|64,J[0]&=248,l(T,K);for(let x=0;x<16;x++)ue[x]=T[x];z[0]=G[0]=1;for(let x=254;x>=0;--x){const _=J[x>>>3]>>>(x&7)&1;a(z,ue,_),a(_e,G,_),d(E,z,_e),g(z,z,_e),d(_e,ue,G),g(ue,ue,G),A(G,E),A(m,z),y(z,_e,z),y(_e,ue,E),d(E,z,_e),g(z,z,_e),A(ue,z),g(_e,G,m),y(z,_e,s),d(z,z,G),y(_e,_e,z),y(z,G,m),y(G,ue,T),A(ue,E),a(z,ue,_),a(_e,G,_)}for(let x=0;x<16;x++)T[x+16]=z[x],T[x+32]=_e[x],T[x+48]=ue[x],T[x+64]=G[x];const f=T.subarray(32),p=T.subarray(16);P(f,f),y(p,p,f);const v=new Uint8Array(32);return u(v,p),v}t.scalarMult=N;function D(U){return N(U,i)}t.scalarMultBase=D;function k(U){if(U.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const K=new Uint8Array(U);return{publicKey:D(K),secretKey:K}}t.generateKeyPairFromSeed=k;function $(U){const K=(0,e.randomBytes)(32,U),J=k(K);return(0,r.wipe)(K),J}t.generateKeyPair=$;function q(U,K,J=!1){if(U.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(K.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const T=N(U,K);if(J){let z=0;for(let ue=0;ue",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 Ti={},Hm={exports:{}};Hm.exports,function(t){(function(e,r){function n(G,E){if(!G)throw new Error(E||"Assertion failed")}function i(G,E){G.super_=E;var m=function(){};m.prototype=E.prototype,G.prototype=new m,G.prototype.constructor=G}function s(G,E,m){if(s.isBN(G))return G;this.negative=0,this.words=null,this.length=0,this.red=null,G!==null&&((E==="le"||E==="be")&&(m=E,E=10),this._init(G||0,E||10,m||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=el.Buffer}catch{}s.isBN=function(E){return E instanceof s?!0:E!==null&&typeof E=="object"&&E.constructor.wordSize===s.wordSize&&Array.isArray(E.words)},s.max=function(E,m){return E.cmp(m)>0?E:m},s.min=function(E,m){return E.cmp(m)<0?E:m},s.prototype._init=function(E,m,f){if(typeof E=="number")return this._initNumber(E,m,f);if(typeof E=="object")return this._initArray(E,m,f);m==="hex"&&(m=16),n(m===(m|0)&&m>=2&&m<=36),E=E.toString().replace(/\s+/g,"");var p=0;E[0]==="-"&&(p++,this.negative=1),p=0;p-=3)x=E[p]|E[p-1]<<8|E[p-2]<<16,this.words[v]|=x<<_&67108863,this.words[v+1]=x>>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);else if(f==="le")for(p=0,v=0;p>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);return this.strip()};function a(G,E){var m=G.charCodeAt(E);return m>=65&&m<=70?m-55:m>=97&&m<=102?m-87:m-48&15}function u(G,E,m){var f=a(G,m);return m-1>=E&&(f|=a(G,m-1)<<4),f}s.prototype._parseHex=function(E,m,f){this.length=Math.ceil((E.length-m)/6),this.words=new Array(this.length);for(var p=0;p=m;p-=2)_=u(E,m,p)<=18?(v-=18,x+=1,this.words[x]|=_>>>26):v+=8;else{var S=E.length-m;for(p=S%2===0?m+1:m;p=18?(v-=18,x+=1,this.words[x]|=_>>>26):v+=8}this.strip()};function l(G,E,m,f){for(var p=0,v=Math.min(G.length,m),x=E;x=49?p+=_-49+10:_>=17?p+=_-17+10:p+=_}return p}s.prototype._parseBase=function(E,m,f){this.words=[0],this.length=1;for(var p=0,v=1;v<=67108863;v*=m)p++;p--,v=v/m|0;for(var x=E.length-f,_=x%p,S=Math.min(x,x-_)+f,b=0,M=f;M1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var d=["","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];s.prototype.toString=function(E,m){E=E||10,m=m|0||1;var f;if(E===16||E==="hex"){f="";for(var p=0,v=0,x=0;x>>24-p&16777215,p+=2,p>=26&&(p-=26,x--),v!==0||x!==this.length-1?f=d[6-S.length]+S+f:f=S+f}for(v!==0&&(f=v.toString(16)+f);f.length%m!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}if(E===(E|0)&&E>=2&&E<=36){var b=g[E],M=y[E];f="";var I=this.clone();for(I.negative=0;!I.isZero();){var F=I.modn(M).toString(E);I=I.idivn(M),I.isZero()?f=F+f:f=d[b-F.length]+F+f}for(this.isZero()&&(f="0"+f);f.length%m!==0;)f="0"+f;return this.negative!==0&&(f="-"+f),f}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var E=this.words[0];return this.length===2?E+=this.words[1]*67108864:this.length===3&&this.words[2]===1?E+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-E:E},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(E,m){return n(typeof o<"u"),this.toArrayLike(o,E,m)},s.prototype.toArray=function(E,m){return this.toArrayLike(Array,E,m)},s.prototype.toArrayLike=function(E,m,f){var p=this.byteLength(),v=f||Math.max(1,p);n(p<=v,"byte array longer than desired length"),n(v>0,"Requested array length <= 0"),this.strip();var x=m==="le",_=new E(v),S,b,M=this.clone();if(x){for(b=0;!M.isZero();b++)S=M.andln(255),M.iushrn(8),_[b]=S;for(;b=4096&&(f+=13,m>>>=13),m>=64&&(f+=7,m>>>=7),m>=8&&(f+=4,m>>>=4),m>=2&&(f+=2,m>>>=2),f+m},s.prototype._zeroBits=function(E){if(E===0)return 26;var m=E,f=0;return m&8191||(f+=13,m>>>=13),m&127||(f+=7,m>>>=7),m&15||(f+=4,m>>>=4),m&3||(f+=2,m>>>=2),m&1||f++,f},s.prototype.bitLength=function(){var E=this.words[this.length-1],m=this._countBits(E);return(this.length-1)*26+m};function A(G){for(var E=new Array(G.bitLength()),m=0;m>>p}return E}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var E=0,m=0;mE.length?this.clone().ior(E):E.clone().ior(this)},s.prototype.uor=function(E){return this.length>E.length?this.clone().iuor(E):E.clone().iuor(this)},s.prototype.iuand=function(E){var m;this.length>E.length?m=E:m=this;for(var f=0;fE.length?this.clone().iand(E):E.clone().iand(this)},s.prototype.uand=function(E){return this.length>E.length?this.clone().iuand(E):E.clone().iuand(this)},s.prototype.iuxor=function(E){var m,f;this.length>E.length?(m=this,f=E):(m=E,f=this);for(var p=0;pE.length?this.clone().ixor(E):E.clone().ixor(this)},s.prototype.uxor=function(E){return this.length>E.length?this.clone().iuxor(E):E.clone().iuxor(this)},s.prototype.inotn=function(E){n(typeof E=="number"&&E>=0);var m=Math.ceil(E/26)|0,f=E%26;this._expand(m),f>0&&m--;for(var p=0;p0&&(this.words[p]=~this.words[p]&67108863>>26-f),this.strip()},s.prototype.notn=function(E){return this.clone().inotn(E)},s.prototype.setn=function(E,m){n(typeof E=="number"&&E>=0);var f=E/26|0,p=E%26;return this._expand(f+1),m?this.words[f]=this.words[f]|1<E.length?(f=this,p=E):(f=E,p=this);for(var v=0,x=0;x>>26;for(;v!==0&&x>>26;if(this.length=f.length,v!==0)this.words[this.length]=v,this.length++;else if(f!==this)for(;xE.length?this.clone().iadd(E):E.clone().iadd(this)},s.prototype.isub=function(E){if(E.negative!==0){E.negative=0;var m=this.iadd(E);return E.negative=1,m._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(E),this.negative=1,this._normSign();var f=this.cmp(E);if(f===0)return this.negative=0,this.length=1,this.words[0]=0,this;var p,v;f>0?(p=this,v=E):(p=E,v=this);for(var x=0,_=0;_>26,this.words[_]=m&67108863;for(;x!==0&&_>26,this.words[_]=m&67108863;if(x===0&&_>>26,I=S&67108863,F=Math.min(b,E.length-1),ae=Math.max(0,b-G.length+1);ae<=F;ae++){var O=b-ae|0;p=G.words[O]|0,v=E.words[ae]|0,x=p*v+I,M+=x/67108864|0,I=x&67108863}m.words[b]=I|0,S=M|0}return S!==0?m.words[b]=S|0:m.length--,m.strip()}var N=function(E,m,f){var p=E.words,v=m.words,x=f.words,_=0,S,b,M,I=p[0]|0,F=I&8191,ae=I>>>13,O=p[1]|0,se=O&8191,ee=O>>>13,X=p[2]|0,Q=X&8191,R=X>>>13,Z=p[3]|0,te=Z&8191,le=Z>>>13,ie=p[4]|0,fe=ie&8191,ve=ie>>>13,Me=p[5]|0,Ne=Me&8191,Te=Me>>>13,Be=p[6]|0,Ie=Be&8191,Le=Be>>>13,Ve=p[7]|0,ke=Ve&8191,ze=Ve>>>13,He=p[8]|0,Ee=He&8191,Qe=He>>>13,ct=p[9]|0,$e=ct&8191,et=ct>>>13,rt=v[0]|0,Je=rt&8191,pt=rt>>>13,ht=v[1]|0,ft=ht&8191,Ht=ht>>>13,Jt=v[2]|0,St=Jt&8191,er=Jt>>>13,Xt=v[3]|0,Ot=Xt&8191,$t=Xt>>>13,Tt=v[4]|0,vt=Tt&8191,Dt=Tt>>>13,Lt=v[5]|0,bt=Lt&8191,Bt=Lt>>>13,Ut=v[6]|0,nt=Ut&8191,Ft=Ut>>>13,B=v[7]|0,H=B&8191,V=B>>>13,C=v[8]|0,Y=C&8191,j=C>>>13,oe=v[9]|0,pe=oe&8191,xe=oe>>>13;f.negative=E.negative^m.negative,f.length=19,S=Math.imul(F,Je),b=Math.imul(F,pt),b=b+Math.imul(ae,Je)|0,M=Math.imul(ae,pt);var Re=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(Re>>>26)|0,Re&=67108863,S=Math.imul(se,Je),b=Math.imul(se,pt),b=b+Math.imul(ee,Je)|0,M=Math.imul(ee,pt),S=S+Math.imul(F,ft)|0,b=b+Math.imul(F,Ht)|0,b=b+Math.imul(ae,ft)|0,M=M+Math.imul(ae,Ht)|0;var De=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(De>>>26)|0,De&=67108863,S=Math.imul(Q,Je),b=Math.imul(Q,pt),b=b+Math.imul(R,Je)|0,M=Math.imul(R,pt),S=S+Math.imul(se,ft)|0,b=b+Math.imul(se,Ht)|0,b=b+Math.imul(ee,ft)|0,M=M+Math.imul(ee,Ht)|0,S=S+Math.imul(F,St)|0,b=b+Math.imul(F,er)|0,b=b+Math.imul(ae,St)|0,M=M+Math.imul(ae,er)|0;var it=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(it>>>26)|0,it&=67108863,S=Math.imul(te,Je),b=Math.imul(te,pt),b=b+Math.imul(le,Je)|0,M=Math.imul(le,pt),S=S+Math.imul(Q,ft)|0,b=b+Math.imul(Q,Ht)|0,b=b+Math.imul(R,ft)|0,M=M+Math.imul(R,Ht)|0,S=S+Math.imul(se,St)|0,b=b+Math.imul(se,er)|0,b=b+Math.imul(ee,St)|0,M=M+Math.imul(ee,er)|0,S=S+Math.imul(F,Ot)|0,b=b+Math.imul(F,$t)|0,b=b+Math.imul(ae,Ot)|0,M=M+Math.imul(ae,$t)|0;var je=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(je>>>26)|0,je&=67108863,S=Math.imul(fe,Je),b=Math.imul(fe,pt),b=b+Math.imul(ve,Je)|0,M=Math.imul(ve,pt),S=S+Math.imul(te,ft)|0,b=b+Math.imul(te,Ht)|0,b=b+Math.imul(le,ft)|0,M=M+Math.imul(le,Ht)|0,S=S+Math.imul(Q,St)|0,b=b+Math.imul(Q,er)|0,b=b+Math.imul(R,St)|0,M=M+Math.imul(R,er)|0,S=S+Math.imul(se,Ot)|0,b=b+Math.imul(se,$t)|0,b=b+Math.imul(ee,Ot)|0,M=M+Math.imul(ee,$t)|0,S=S+Math.imul(F,vt)|0,b=b+Math.imul(F,Dt)|0,b=b+Math.imul(ae,vt)|0,M=M+Math.imul(ae,Dt)|0;var gt=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(gt>>>26)|0,gt&=67108863,S=Math.imul(Ne,Je),b=Math.imul(Ne,pt),b=b+Math.imul(Te,Je)|0,M=Math.imul(Te,pt),S=S+Math.imul(fe,ft)|0,b=b+Math.imul(fe,Ht)|0,b=b+Math.imul(ve,ft)|0,M=M+Math.imul(ve,Ht)|0,S=S+Math.imul(te,St)|0,b=b+Math.imul(te,er)|0,b=b+Math.imul(le,St)|0,M=M+Math.imul(le,er)|0,S=S+Math.imul(Q,Ot)|0,b=b+Math.imul(Q,$t)|0,b=b+Math.imul(R,Ot)|0,M=M+Math.imul(R,$t)|0,S=S+Math.imul(se,vt)|0,b=b+Math.imul(se,Dt)|0,b=b+Math.imul(ee,vt)|0,M=M+Math.imul(ee,Dt)|0,S=S+Math.imul(F,bt)|0,b=b+Math.imul(F,Bt)|0,b=b+Math.imul(ae,bt)|0,M=M+Math.imul(ae,Bt)|0;var st=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(st>>>26)|0,st&=67108863,S=Math.imul(Ie,Je),b=Math.imul(Ie,pt),b=b+Math.imul(Le,Je)|0,M=Math.imul(Le,pt),S=S+Math.imul(Ne,ft)|0,b=b+Math.imul(Ne,Ht)|0,b=b+Math.imul(Te,ft)|0,M=M+Math.imul(Te,Ht)|0,S=S+Math.imul(fe,St)|0,b=b+Math.imul(fe,er)|0,b=b+Math.imul(ve,St)|0,M=M+Math.imul(ve,er)|0,S=S+Math.imul(te,Ot)|0,b=b+Math.imul(te,$t)|0,b=b+Math.imul(le,Ot)|0,M=M+Math.imul(le,$t)|0,S=S+Math.imul(Q,vt)|0,b=b+Math.imul(Q,Dt)|0,b=b+Math.imul(R,vt)|0,M=M+Math.imul(R,Dt)|0,S=S+Math.imul(se,bt)|0,b=b+Math.imul(se,Bt)|0,b=b+Math.imul(ee,bt)|0,M=M+Math.imul(ee,Bt)|0,S=S+Math.imul(F,nt)|0,b=b+Math.imul(F,Ft)|0,b=b+Math.imul(ae,nt)|0,M=M+Math.imul(ae,Ft)|0;var tt=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(tt>>>26)|0,tt&=67108863,S=Math.imul(ke,Je),b=Math.imul(ke,pt),b=b+Math.imul(ze,Je)|0,M=Math.imul(ze,pt),S=S+Math.imul(Ie,ft)|0,b=b+Math.imul(Ie,Ht)|0,b=b+Math.imul(Le,ft)|0,M=M+Math.imul(Le,Ht)|0,S=S+Math.imul(Ne,St)|0,b=b+Math.imul(Ne,er)|0,b=b+Math.imul(Te,St)|0,M=M+Math.imul(Te,er)|0,S=S+Math.imul(fe,Ot)|0,b=b+Math.imul(fe,$t)|0,b=b+Math.imul(ve,Ot)|0,M=M+Math.imul(ve,$t)|0,S=S+Math.imul(te,vt)|0,b=b+Math.imul(te,Dt)|0,b=b+Math.imul(le,vt)|0,M=M+Math.imul(le,Dt)|0,S=S+Math.imul(Q,bt)|0,b=b+Math.imul(Q,Bt)|0,b=b+Math.imul(R,bt)|0,M=M+Math.imul(R,Bt)|0,S=S+Math.imul(se,nt)|0,b=b+Math.imul(se,Ft)|0,b=b+Math.imul(ee,nt)|0,M=M+Math.imul(ee,Ft)|0,S=S+Math.imul(F,H)|0,b=b+Math.imul(F,V)|0,b=b+Math.imul(ae,H)|0,M=M+Math.imul(ae,V)|0;var At=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(At>>>26)|0,At&=67108863,S=Math.imul(Ee,Je),b=Math.imul(Ee,pt),b=b+Math.imul(Qe,Je)|0,M=Math.imul(Qe,pt),S=S+Math.imul(ke,ft)|0,b=b+Math.imul(ke,Ht)|0,b=b+Math.imul(ze,ft)|0,M=M+Math.imul(ze,Ht)|0,S=S+Math.imul(Ie,St)|0,b=b+Math.imul(Ie,er)|0,b=b+Math.imul(Le,St)|0,M=M+Math.imul(Le,er)|0,S=S+Math.imul(Ne,Ot)|0,b=b+Math.imul(Ne,$t)|0,b=b+Math.imul(Te,Ot)|0,M=M+Math.imul(Te,$t)|0,S=S+Math.imul(fe,vt)|0,b=b+Math.imul(fe,Dt)|0,b=b+Math.imul(ve,vt)|0,M=M+Math.imul(ve,Dt)|0,S=S+Math.imul(te,bt)|0,b=b+Math.imul(te,Bt)|0,b=b+Math.imul(le,bt)|0,M=M+Math.imul(le,Bt)|0,S=S+Math.imul(Q,nt)|0,b=b+Math.imul(Q,Ft)|0,b=b+Math.imul(R,nt)|0,M=M+Math.imul(R,Ft)|0,S=S+Math.imul(se,H)|0,b=b+Math.imul(se,V)|0,b=b+Math.imul(ee,H)|0,M=M+Math.imul(ee,V)|0,S=S+Math.imul(F,Y)|0,b=b+Math.imul(F,j)|0,b=b+Math.imul(ae,Y)|0,M=M+Math.imul(ae,j)|0;var Rt=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,S=Math.imul($e,Je),b=Math.imul($e,pt),b=b+Math.imul(et,Je)|0,M=Math.imul(et,pt),S=S+Math.imul(Ee,ft)|0,b=b+Math.imul(Ee,Ht)|0,b=b+Math.imul(Qe,ft)|0,M=M+Math.imul(Qe,Ht)|0,S=S+Math.imul(ke,St)|0,b=b+Math.imul(ke,er)|0,b=b+Math.imul(ze,St)|0,M=M+Math.imul(ze,er)|0,S=S+Math.imul(Ie,Ot)|0,b=b+Math.imul(Ie,$t)|0,b=b+Math.imul(Le,Ot)|0,M=M+Math.imul(Le,$t)|0,S=S+Math.imul(Ne,vt)|0,b=b+Math.imul(Ne,Dt)|0,b=b+Math.imul(Te,vt)|0,M=M+Math.imul(Te,Dt)|0,S=S+Math.imul(fe,bt)|0,b=b+Math.imul(fe,Bt)|0,b=b+Math.imul(ve,bt)|0,M=M+Math.imul(ve,Bt)|0,S=S+Math.imul(te,nt)|0,b=b+Math.imul(te,Ft)|0,b=b+Math.imul(le,nt)|0,M=M+Math.imul(le,Ft)|0,S=S+Math.imul(Q,H)|0,b=b+Math.imul(Q,V)|0,b=b+Math.imul(R,H)|0,M=M+Math.imul(R,V)|0,S=S+Math.imul(se,Y)|0,b=b+Math.imul(se,j)|0,b=b+Math.imul(ee,Y)|0,M=M+Math.imul(ee,j)|0,S=S+Math.imul(F,pe)|0,b=b+Math.imul(F,xe)|0,b=b+Math.imul(ae,pe)|0,M=M+Math.imul(ae,xe)|0;var Mt=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,S=Math.imul($e,ft),b=Math.imul($e,Ht),b=b+Math.imul(et,ft)|0,M=Math.imul(et,Ht),S=S+Math.imul(Ee,St)|0,b=b+Math.imul(Ee,er)|0,b=b+Math.imul(Qe,St)|0,M=M+Math.imul(Qe,er)|0,S=S+Math.imul(ke,Ot)|0,b=b+Math.imul(ke,$t)|0,b=b+Math.imul(ze,Ot)|0,M=M+Math.imul(ze,$t)|0,S=S+Math.imul(Ie,vt)|0,b=b+Math.imul(Ie,Dt)|0,b=b+Math.imul(Le,vt)|0,M=M+Math.imul(Le,Dt)|0,S=S+Math.imul(Ne,bt)|0,b=b+Math.imul(Ne,Bt)|0,b=b+Math.imul(Te,bt)|0,M=M+Math.imul(Te,Bt)|0,S=S+Math.imul(fe,nt)|0,b=b+Math.imul(fe,Ft)|0,b=b+Math.imul(ve,nt)|0,M=M+Math.imul(ve,Ft)|0,S=S+Math.imul(te,H)|0,b=b+Math.imul(te,V)|0,b=b+Math.imul(le,H)|0,M=M+Math.imul(le,V)|0,S=S+Math.imul(Q,Y)|0,b=b+Math.imul(Q,j)|0,b=b+Math.imul(R,Y)|0,M=M+Math.imul(R,j)|0,S=S+Math.imul(se,pe)|0,b=b+Math.imul(se,xe)|0,b=b+Math.imul(ee,pe)|0,M=M+Math.imul(ee,xe)|0;var Et=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(Et>>>26)|0,Et&=67108863,S=Math.imul($e,St),b=Math.imul($e,er),b=b+Math.imul(et,St)|0,M=Math.imul(et,er),S=S+Math.imul(Ee,Ot)|0,b=b+Math.imul(Ee,$t)|0,b=b+Math.imul(Qe,Ot)|0,M=M+Math.imul(Qe,$t)|0,S=S+Math.imul(ke,vt)|0,b=b+Math.imul(ke,Dt)|0,b=b+Math.imul(ze,vt)|0,M=M+Math.imul(ze,Dt)|0,S=S+Math.imul(Ie,bt)|0,b=b+Math.imul(Ie,Bt)|0,b=b+Math.imul(Le,bt)|0,M=M+Math.imul(Le,Bt)|0,S=S+Math.imul(Ne,nt)|0,b=b+Math.imul(Ne,Ft)|0,b=b+Math.imul(Te,nt)|0,M=M+Math.imul(Te,Ft)|0,S=S+Math.imul(fe,H)|0,b=b+Math.imul(fe,V)|0,b=b+Math.imul(ve,H)|0,M=M+Math.imul(ve,V)|0,S=S+Math.imul(te,Y)|0,b=b+Math.imul(te,j)|0,b=b+Math.imul(le,Y)|0,M=M+Math.imul(le,j)|0,S=S+Math.imul(Q,pe)|0,b=b+Math.imul(Q,xe)|0,b=b+Math.imul(R,pe)|0,M=M+Math.imul(R,xe)|0;var dt=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(dt>>>26)|0,dt&=67108863,S=Math.imul($e,Ot),b=Math.imul($e,$t),b=b+Math.imul(et,Ot)|0,M=Math.imul(et,$t),S=S+Math.imul(Ee,vt)|0,b=b+Math.imul(Ee,Dt)|0,b=b+Math.imul(Qe,vt)|0,M=M+Math.imul(Qe,Dt)|0,S=S+Math.imul(ke,bt)|0,b=b+Math.imul(ke,Bt)|0,b=b+Math.imul(ze,bt)|0,M=M+Math.imul(ze,Bt)|0,S=S+Math.imul(Ie,nt)|0,b=b+Math.imul(Ie,Ft)|0,b=b+Math.imul(Le,nt)|0,M=M+Math.imul(Le,Ft)|0,S=S+Math.imul(Ne,H)|0,b=b+Math.imul(Ne,V)|0,b=b+Math.imul(Te,H)|0,M=M+Math.imul(Te,V)|0,S=S+Math.imul(fe,Y)|0,b=b+Math.imul(fe,j)|0,b=b+Math.imul(ve,Y)|0,M=M+Math.imul(ve,j)|0,S=S+Math.imul(te,pe)|0,b=b+Math.imul(te,xe)|0,b=b+Math.imul(le,pe)|0,M=M+Math.imul(le,xe)|0;var _t=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(_t>>>26)|0,_t&=67108863,S=Math.imul($e,vt),b=Math.imul($e,Dt),b=b+Math.imul(et,vt)|0,M=Math.imul(et,Dt),S=S+Math.imul(Ee,bt)|0,b=b+Math.imul(Ee,Bt)|0,b=b+Math.imul(Qe,bt)|0,M=M+Math.imul(Qe,Bt)|0,S=S+Math.imul(ke,nt)|0,b=b+Math.imul(ke,Ft)|0,b=b+Math.imul(ze,nt)|0,M=M+Math.imul(ze,Ft)|0,S=S+Math.imul(Ie,H)|0,b=b+Math.imul(Ie,V)|0,b=b+Math.imul(Le,H)|0,M=M+Math.imul(Le,V)|0,S=S+Math.imul(Ne,Y)|0,b=b+Math.imul(Ne,j)|0,b=b+Math.imul(Te,Y)|0,M=M+Math.imul(Te,j)|0,S=S+Math.imul(fe,pe)|0,b=b+Math.imul(fe,xe)|0,b=b+Math.imul(ve,pe)|0,M=M+Math.imul(ve,xe)|0;var ot=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(ot>>>26)|0,ot&=67108863,S=Math.imul($e,bt),b=Math.imul($e,Bt),b=b+Math.imul(et,bt)|0,M=Math.imul(et,Bt),S=S+Math.imul(Ee,nt)|0,b=b+Math.imul(Ee,Ft)|0,b=b+Math.imul(Qe,nt)|0,M=M+Math.imul(Qe,Ft)|0,S=S+Math.imul(ke,H)|0,b=b+Math.imul(ke,V)|0,b=b+Math.imul(ze,H)|0,M=M+Math.imul(ze,V)|0,S=S+Math.imul(Ie,Y)|0,b=b+Math.imul(Ie,j)|0,b=b+Math.imul(Le,Y)|0,M=M+Math.imul(Le,j)|0,S=S+Math.imul(Ne,pe)|0,b=b+Math.imul(Ne,xe)|0,b=b+Math.imul(Te,pe)|0,M=M+Math.imul(Te,xe)|0;var wt=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(wt>>>26)|0,wt&=67108863,S=Math.imul($e,nt),b=Math.imul($e,Ft),b=b+Math.imul(et,nt)|0,M=Math.imul(et,Ft),S=S+Math.imul(Ee,H)|0,b=b+Math.imul(Ee,V)|0,b=b+Math.imul(Qe,H)|0,M=M+Math.imul(Qe,V)|0,S=S+Math.imul(ke,Y)|0,b=b+Math.imul(ke,j)|0,b=b+Math.imul(ze,Y)|0,M=M+Math.imul(ze,j)|0,S=S+Math.imul(Ie,pe)|0,b=b+Math.imul(Ie,xe)|0,b=b+Math.imul(Le,pe)|0,M=M+Math.imul(Le,xe)|0;var lt=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(lt>>>26)|0,lt&=67108863,S=Math.imul($e,H),b=Math.imul($e,V),b=b+Math.imul(et,H)|0,M=Math.imul(et,V),S=S+Math.imul(Ee,Y)|0,b=b+Math.imul(Ee,j)|0,b=b+Math.imul(Qe,Y)|0,M=M+Math.imul(Qe,j)|0,S=S+Math.imul(ke,pe)|0,b=b+Math.imul(ke,xe)|0,b=b+Math.imul(ze,pe)|0,M=M+Math.imul(ze,xe)|0;var at=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(at>>>26)|0,at&=67108863,S=Math.imul($e,Y),b=Math.imul($e,j),b=b+Math.imul(et,Y)|0,M=Math.imul(et,j),S=S+Math.imul(Ee,pe)|0,b=b+Math.imul(Ee,xe)|0,b=b+Math.imul(Qe,pe)|0,M=M+Math.imul(Qe,xe)|0;var Se=(_+S|0)+((b&8191)<<13)|0;_=(M+(b>>>13)|0)+(Se>>>26)|0,Se&=67108863,S=Math.imul($e,pe),b=Math.imul($e,xe),b=b+Math.imul(et,pe)|0,M=Math.imul(et,xe);var Ae=(_+S|0)+((b&8191)<<13)|0;return _=(M+(b>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,x[0]=Re,x[1]=De,x[2]=it,x[3]=je,x[4]=gt,x[5]=st,x[6]=tt,x[7]=At,x[8]=Rt,x[9]=Mt,x[10]=Et,x[11]=dt,x[12]=_t,x[13]=ot,x[14]=wt,x[15]=lt,x[16]=at,x[17]=Se,x[18]=Ae,_!==0&&(x[19]=_,f.length++),f};Math.imul||(N=P);function D(G,E,m){m.negative=E.negative^G.negative,m.length=G.length+E.length;for(var f=0,p=0,v=0;v>>26)|0,p+=x>>>26,x&=67108863}m.words[v]=_,f=x,x=p}return f!==0?m.words[v]=f:m.length--,m.strip()}function k(G,E,m){var f=new $;return f.mulp(G,E,m)}s.prototype.mulTo=function(E,m){var f,p=this.length+E.length;return this.length===10&&E.length===10?f=N(this,E,m):p<63?f=P(this,E,m):p<1024?f=D(this,E,m):f=k(this,E,m),f};function $(G,E){this.x=G,this.y=E}$.prototype.makeRBT=function(E){for(var m=new Array(E),f=s.prototype._countBits(E)-1,p=0;p>=1;return p},$.prototype.permute=function(E,m,f,p,v,x){for(var _=0;_>>1)v++;return 1<>>13,f[2*x+1]=v&8191,v=v>>>13;for(x=2*m;x>=26,m+=p/67108864|0,m+=v>>>26,this.words[f]=v&67108863}return m!==0&&(this.words[f]=m,this.length++),this},s.prototype.muln=function(E){return this.clone().imuln(E)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(E){var m=A(E);if(m.length===0)return new s(1);for(var f=this,p=0;p=0);var m=E%26,f=(E-m)/26,p=67108863>>>26-m<<26-m,v;if(m!==0){var x=0;for(v=0;v>>26-m}x&&(this.words[v]=x,this.length++)}if(f!==0){for(v=this.length-1;v>=0;v--)this.words[v+f]=this.words[v];for(v=0;v=0);var p;m?p=(m-m%26)/26:p=0;var v=E%26,x=Math.min((E-v)/26,this.length),_=67108863^67108863>>>v<x)for(this.length-=x,b=0;b=0&&(M!==0||b>=p);b--){var I=this.words[b]|0;this.words[b]=M<<26-v|I>>>v,M=I&_}return S&&M!==0&&(S.words[S.length++]=M),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(E,m,f){return n(this.negative===0),this.iushrn(E,m,f)},s.prototype.shln=function(E){return this.clone().ishln(E)},s.prototype.ushln=function(E){return this.clone().iushln(E)},s.prototype.shrn=function(E){return this.clone().ishrn(E)},s.prototype.ushrn=function(E){return this.clone().iushrn(E)},s.prototype.testn=function(E){n(typeof E=="number"&&E>=0);var m=E%26,f=(E-m)/26,p=1<=0);var m=E%26,f=(E-m)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=f)return this;if(m!==0&&f++,this.length=Math.min(f,this.length),m!==0){var p=67108863^67108863>>>m<=67108864;m++)this.words[m]-=67108864,m===this.length-1?this.words[m+1]=1:this.words[m+1]++;return this.length=Math.max(this.length,m+1),this},s.prototype.isubn=function(E){if(n(typeof E=="number"),n(E<67108864),E<0)return this.iaddn(-E);if(this.negative!==0)return this.negative=0,this.iaddn(E),this.negative=1,this;if(this.words[0]-=E,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var m=0;m>26)-(S/67108864|0),this.words[v+f]=x&67108863}for(;v>26,this.words[v+f]=x&67108863;if(_===0)return this.strip();for(n(_===-1),_=0,v=0;v>26,this.words[v]=x&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(E,m){var f=this.length-E.length,p=this.clone(),v=E,x=v.words[v.length-1]|0,_=this._countBits(x);f=26-_,f!==0&&(v=v.ushln(f),p.iushln(f),x=v.words[v.length-1]|0);var S=p.length-v.length,b;if(m!=="mod"){b=new s(null),b.length=S+1,b.words=new Array(b.length);for(var M=0;M=0;F--){var ae=(p.words[v.length+F]|0)*67108864+(p.words[v.length+F-1]|0);for(ae=Math.min(ae/x|0,67108863),p._ishlnsubmul(v,ae,F);p.negative!==0;)ae--,p.negative=0,p._ishlnsubmul(v,1,F),p.isZero()||(p.negative^=1);b&&(b.words[F]=ae)}return b&&b.strip(),p.strip(),m!=="div"&&f!==0&&p.iushrn(f),{div:b||null,mod:p}},s.prototype.divmod=function(E,m,f){if(n(!E.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var p,v,x;return this.negative!==0&&E.negative===0?(x=this.neg().divmod(E,m),m!=="mod"&&(p=x.div.neg()),m!=="div"&&(v=x.mod.neg(),f&&v.negative!==0&&v.iadd(E)),{div:p,mod:v}):this.negative===0&&E.negative!==0?(x=this.divmod(E.neg(),m),m!=="mod"&&(p=x.div.neg()),{div:p,mod:x.mod}):this.negative&E.negative?(x=this.neg().divmod(E.neg(),m),m!=="div"&&(v=x.mod.neg(),f&&v.negative!==0&&v.isub(E)),{div:x.div,mod:v}):E.length>this.length||this.cmp(E)<0?{div:new s(0),mod:this}:E.length===1?m==="div"?{div:this.divn(E.words[0]),mod:null}:m==="mod"?{div:null,mod:new s(this.modn(E.words[0]))}:{div:this.divn(E.words[0]),mod:new s(this.modn(E.words[0]))}:this._wordDiv(E,m)},s.prototype.div=function(E){return this.divmod(E,"div",!1).div},s.prototype.mod=function(E){return this.divmod(E,"mod",!1).mod},s.prototype.umod=function(E){return this.divmod(E,"mod",!0).mod},s.prototype.divRound=function(E){var m=this.divmod(E);if(m.mod.isZero())return m.div;var f=m.div.negative!==0?m.mod.isub(E):m.mod,p=E.ushrn(1),v=E.andln(1),x=f.cmp(p);return x<0||v===1&&x===0?m.div:m.div.negative!==0?m.div.isubn(1):m.div.iaddn(1)},s.prototype.modn=function(E){n(E<=67108863);for(var m=(1<<26)%E,f=0,p=this.length-1;p>=0;p--)f=(m*f+(this.words[p]|0))%E;return f},s.prototype.idivn=function(E){n(E<=67108863);for(var m=0,f=this.length-1;f>=0;f--){var p=(this.words[f]|0)+m*67108864;this.words[f]=p/E|0,m=p%E}return this.strip()},s.prototype.divn=function(E){return this.clone().idivn(E)},s.prototype.egcd=function(E){n(E.negative===0),n(!E.isZero());var m=this,f=E.clone();m.negative!==0?m=m.umod(E):m=m.clone();for(var p=new s(1),v=new s(0),x=new s(0),_=new s(1),S=0;m.isEven()&&f.isEven();)m.iushrn(1),f.iushrn(1),++S;for(var b=f.clone(),M=m.clone();!m.isZero();){for(var I=0,F=1;!(m.words[0]&F)&&I<26;++I,F<<=1);if(I>0)for(m.iushrn(I);I-- >0;)(p.isOdd()||v.isOdd())&&(p.iadd(b),v.isub(M)),p.iushrn(1),v.iushrn(1);for(var ae=0,O=1;!(f.words[0]&O)&&ae<26;++ae,O<<=1);if(ae>0)for(f.iushrn(ae);ae-- >0;)(x.isOdd()||_.isOdd())&&(x.iadd(b),_.isub(M)),x.iushrn(1),_.iushrn(1);m.cmp(f)>=0?(m.isub(f),p.isub(x),v.isub(_)):(f.isub(m),x.isub(p),_.isub(v))}return{a:x,b:_,gcd:f.iushln(S)}},s.prototype._invmp=function(E){n(E.negative===0),n(!E.isZero());var m=this,f=E.clone();m.negative!==0?m=m.umod(E):m=m.clone();for(var p=new s(1),v=new s(0),x=f.clone();m.cmpn(1)>0&&f.cmpn(1)>0;){for(var _=0,S=1;!(m.words[0]&S)&&_<26;++_,S<<=1);if(_>0)for(m.iushrn(_);_-- >0;)p.isOdd()&&p.iadd(x),p.iushrn(1);for(var b=0,M=1;!(f.words[0]&M)&&b<26;++b,M<<=1);if(b>0)for(f.iushrn(b);b-- >0;)v.isOdd()&&v.iadd(x),v.iushrn(1);m.cmp(f)>=0?(m.isub(f),p.isub(v)):(f.isub(m),v.isub(p))}var I;return m.cmpn(1)===0?I=p:I=v,I.cmpn(0)<0&&I.iadd(E),I},s.prototype.gcd=function(E){if(this.isZero())return E.abs();if(E.isZero())return this.abs();var m=this.clone(),f=E.clone();m.negative=0,f.negative=0;for(var p=0;m.isEven()&&f.isEven();p++)m.iushrn(1),f.iushrn(1);do{for(;m.isEven();)m.iushrn(1);for(;f.isEven();)f.iushrn(1);var v=m.cmp(f);if(v<0){var x=m;m=f,f=x}else if(v===0||f.cmpn(1)===0)break;m.isub(f)}while(!0);return f.iushln(p)},s.prototype.invm=function(E){return this.egcd(E).a.umod(E)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(E){return this.words[0]&E},s.prototype.bincn=function(E){n(typeof E=="number");var m=E%26,f=(E-m)/26,p=1<>>26,_&=67108863,this.words[x]=_}return v!==0&&(this.words[x]=v,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(E){var m=E<0;if(this.negative!==0&&!m)return-1;if(this.negative===0&&m)return 1;this.strip();var f;if(this.length>1)f=1;else{m&&(E=-E),n(E<=67108863,"Number is too big");var p=this.words[0]|0;f=p===E?0:pE.length)return 1;if(this.length=0;f--){var p=this.words[f]|0,v=E.words[f]|0;if(p!==v){pv&&(m=1);break}}return m},s.prototype.gtn=function(E){return this.cmpn(E)===1},s.prototype.gt=function(E){return this.cmp(E)===1},s.prototype.gten=function(E){return this.cmpn(E)>=0},s.prototype.gte=function(E){return this.cmp(E)>=0},s.prototype.ltn=function(E){return this.cmpn(E)===-1},s.prototype.lt=function(E){return this.cmp(E)===-1},s.prototype.lten=function(E){return this.cmpn(E)<=0},s.prototype.lte=function(E){return this.cmp(E)<=0},s.prototype.eqn=function(E){return this.cmpn(E)===0},s.prototype.eq=function(E){return this.cmp(E)===0},s.red=function(E){return new ue(E)},s.prototype.toRed=function(E){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),E.convertTo(this)._forceRed(E)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(E){return this.red=E,this},s.prototype.forceRed=function(E){return n(!this.red,"Already a number in reduction context"),this._forceRed(E)},s.prototype.redAdd=function(E){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,E)},s.prototype.redIAdd=function(E){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,E)},s.prototype.redSub=function(E){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,E)},s.prototype.redISub=function(E){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,E)},s.prototype.redShl=function(E){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,E)},s.prototype.redMul=function(E){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,E),this.red.mul(this,E)},s.prototype.redIMul=function(E){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,E),this.red.imul(this,E)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(E){return n(this.red&&!E.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,E)};var q={k256:null,p224:null,p192:null,p25519:null};function U(G,E){this.name=G,this.p=new s(E,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}U.prototype._tmp=function(){var E=new s(null);return E.words=new Array(Math.ceil(this.n/13)),E},U.prototype.ireduce=function(E){var m=E,f;do this.split(m,this.tmp),m=this.imulK(m),m=m.iadd(this.tmp),f=m.bitLength();while(f>this.n);var p=f0?m.isub(this.p):m.strip!==void 0?m.strip():m._strip(),m},U.prototype.split=function(E,m){E.iushrn(this.n,0,m)},U.prototype.imulK=function(E){return E.imul(this.k)};function K(){U.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(K,U),K.prototype.split=function(E,m){for(var f=4194303,p=Math.min(E.length,9),v=0;v>>22,x=_}x>>>=22,E.words[v-10]=x,x===0&&E.length>10?E.length-=10:E.length-=9},K.prototype.imulK=function(E){E.words[E.length]=0,E.words[E.length+1]=0,E.length+=2;for(var m=0,f=0;f>>=26,E.words[f]=v,m=p}return m!==0&&(E.words[E.length++]=m),E},s._prime=function(E){if(q[E])return q[E];var m;if(E==="k256")m=new K;else if(E==="p224")m=new J;else if(E==="p192")m=new T;else if(E==="p25519")m=new z;else throw new Error("Unknown prime "+E);return q[E]=m,m};function ue(G){if(typeof G=="string"){var E=s._prime(G);this.m=E.p,this.prime=E}else n(G.gtn(1),"modulus must be greater than 1"),this.m=G,this.prime=null}ue.prototype._verify1=function(E){n(E.negative===0,"red works only with positives"),n(E.red,"red works only with red numbers")},ue.prototype._verify2=function(E,m){n((E.negative|m.negative)===0,"red works only with positives"),n(E.red&&E.red===m.red,"red works only with red numbers")},ue.prototype.imod=function(E){return this.prime?this.prime.ireduce(E)._forceRed(this):E.umod(this.m)._forceRed(this)},ue.prototype.neg=function(E){return E.isZero()?E.clone():this.m.sub(E)._forceRed(this)},ue.prototype.add=function(E,m){this._verify2(E,m);var f=E.add(m);return f.cmp(this.m)>=0&&f.isub(this.m),f._forceRed(this)},ue.prototype.iadd=function(E,m){this._verify2(E,m);var f=E.iadd(m);return f.cmp(this.m)>=0&&f.isub(this.m),f},ue.prototype.sub=function(E,m){this._verify2(E,m);var f=E.sub(m);return f.cmpn(0)<0&&f.iadd(this.m),f._forceRed(this)},ue.prototype.isub=function(E,m){this._verify2(E,m);var f=E.isub(m);return f.cmpn(0)<0&&f.iadd(this.m),f},ue.prototype.shl=function(E,m){return this._verify1(E),this.imod(E.ushln(m))},ue.prototype.imul=function(E,m){return this._verify2(E,m),this.imod(E.imul(m))},ue.prototype.mul=function(E,m){return this._verify2(E,m),this.imod(E.mul(m))},ue.prototype.isqr=function(E){return this.imul(E,E.clone())},ue.prototype.sqr=function(E){return this.mul(E,E)},ue.prototype.sqrt=function(E){if(E.isZero())return E.clone();var m=this.m.andln(3);if(n(m%2===1),m===3){var f=this.m.add(new s(1)).iushrn(2);return this.pow(E,f)}for(var p=this.m.subn(1),v=0;!p.isZero()&&p.andln(1)===0;)v++,p.iushrn(1);n(!p.isZero());var x=new s(1).toRed(this),_=x.redNeg(),S=this.m.subn(1).iushrn(1),b=this.m.bitLength();for(b=new s(2*b*b).toRed(this);this.pow(b,S).cmp(_)!==0;)b.redIAdd(_);for(var M=this.pow(b,p),I=this.pow(E,p.addn(1).iushrn(1)),F=this.pow(E,p),ae=v;F.cmp(x)!==0;){for(var O=F,se=0;O.cmp(x)!==0;se++)O=O.redSqr();n(se=0;v--){for(var M=m.words[v],I=b-1;I>=0;I--){var F=M>>I&1;if(x!==p[0]&&(x=this.sqr(x)),F===0&&_===0){S=0;continue}_<<=1,_|=F,S++,!(S!==f&&(v!==0||I!==0))&&(x=this.mul(x,p[_]),S=0,_=0)}b=26}return x},ue.prototype.convertTo=function(E){var m=E.umod(this.m);return m===E?m.clone():m},ue.prototype.convertFrom=function(E){var m=E.clone();return m.red=null,m},s.mont=function(E){return new _e(E)};function _e(G){ue.call(this,G),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(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(_e,ue),_e.prototype.convertTo=function(E){return this.imod(E.ushln(this.shift))},_e.prototype.convertFrom=function(E){var m=this.imod(E.mul(this.rinv));return m.red=null,m},_e.prototype.imul=function(E,m){if(E.isZero()||m.isZero())return E.words[0]=0,E.length=1,E;var f=E.imul(m),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=f.isub(p).iushrn(this.shift),x=v;return v.cmp(this.m)>=0?x=v.isub(this.m):v.cmpn(0)<0&&(x=v.iadd(this.m)),x._forceRed(this)},_e.prototype.mul=function(E,m){if(E.isZero()||m.isZero())return new s(0)._forceRed(this);var f=E.mul(m),p=f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=f.isub(p).iushrn(this.shift),x=v;return v.cmp(this.m)>=0?x=v.isub(this.m):v.cmpn(0)<0&&(x=v.iadd(this.m)),x._forceRed(this)},_e.prototype.invm=function(E){var m=this.imod(E._invmp(this.m).mul(this.r2));return m._forceRed(this)}})(t,nn)}(Hm);var wo=Hm.exports,Wm={};(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var a=[];if(typeof s!="string"){for(var u=0;u>8,g=l&255;d?a.push(d,g):a.push(g)}return a}e.toArray=r;function n(s){return s.length===1?"0"+s:s}e.zero2=n;function i(s){for(var o="",a=0;a(N>>1)-1?k=(N>>1)-$:k=$,D.isubn(k)):k=0,A[P]=k,D.iushrn(1)}return A}e.getNAF=s;function o(d,g){var y=[[],[]];d=d.clone(),g=g.clone();for(var A=0,P=0,N;d.cmpn(-A)>0||g.cmpn(-P)>0;){var D=d.andln(3)+A&3,k=g.andln(3)+P&3;D===3&&(D=-1),k===3&&(k=-1);var $;D&1?(N=d.andln(7)+A&7,(N===3||N===5)&&k===2?$=-D:$=D):$=0,y[0].push($);var q;k&1?(N=g.andln(7)+P&7,(N===3||N===5)&&D===2?q=-k:q=k):q=0,y[1].push(q),2*A===$+1&&(A=1-A),2*P===q+1&&(P=1-P),d.iushrn(1),g.iushrn(1)}return y}e.getJSF=o;function a(d,g,y){var A="_"+g;d.prototype[g]=function(){return this[A]!==void 0?this[A]:this[A]=y.call(this)}}e.cachedProperty=a;function u(d){return typeof d=="string"?e.toArray(d,"hex"):d}e.parseBytes=u;function l(d){return new r(d,"hex","le")}e.intFromLE=l}(Ti);var Km={exports:{}},Vm;Km.exports=function(e){return Vm||(Vm=new oa(null)),Vm.generate(e)};function oa(t){this.rand=t}if(Km.exports.Rand=oa,oa.prototype.generate=function(e){return this._rand(e)},oa.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var r=new Uint8Array(e),n=0;n0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Td=aa;aa.prototype.point=function(){throw new Error("Not implemented")},aa.prototype.validate=function(){throw new Error("Not implemented")},aa.prototype._fixedNafMul=function(e,r){Cd(e.precomputed);var n=e._getDoubles(),i=Id(r,1,this._bitLength),s=(1<=a;l--)u=(u<<1)+i[l];o.push(u)}for(var d=this.jpoint(null,null,null),g=this.jpoint(null,null,null),y=s;y>0;y--){for(a=0;a=0;u--){for(var l=0;u>=0&&o[u]===0;u--)l++;if(u>=0&&l++,a=a.dblp(l),u<0)break;var d=o[u];Cd(d!==0),e.type==="affine"?d>0?a=a.mixedAdd(s[d-1>>1]):a=a.mixedAdd(s[-d-1>>1].neg()):d>0?a=a.add(s[d-1>>1]):a=a.add(s[-d-1>>1].neg())}return e.type==="affine"?a.toP():a},aa.prototype._wnafMulAdd=function(e,r,n,i,s){var o=this._wnafT1,a=this._wnafT2,u=this._wnafT3,l=0,d,g,y;for(d=0;d=1;d-=2){var P=d-1,N=d;if(o[P]!==1||o[N]!==1){u[P]=Id(n[P],o[P],this._bitLength),u[N]=Id(n[N],o[N],this._bitLength),l=Math.max(u[P].length,l),l=Math.max(u[N].length,l);continue}var D=[r[P],null,null,r[N]];r[P].y.cmp(r[N].y)===0?(D[1]=r[P].add(r[N]),D[2]=r[P].toJ().mixedAdd(r[N].neg())):r[P].y.cmp(r[N].y.redNeg())===0?(D[1]=r[P].toJ().mixedAdd(r[N]),D[2]=r[P].add(r[N].neg())):(D[1]=r[P].toJ().mixedAdd(r[N]),D[2]=r[P].toJ().mixedAdd(r[N].neg()));var k=[-3,-1,-5,-7,0,7,5,1,3],$=Ek(n[P],n[N]);for(l=Math.max($[0].length,l),u[P]=new Array(l),u[N]=new Array(l),g=0;g=0;d--){for(var T=0;d>=0;){var z=!0;for(g=0;g=0&&T++,K=K.dblp(T),d<0)break;for(g=0;g0?y=a[g][ue-1>>1]:ue<0&&(y=a[g][-ue-1>>1].neg()),y.type==="affine"?K=K.mixedAdd(y):K=K.add(y))}}for(d=0;d=Math.ceil((e.bitLength()+1)/r.step):!1},Ki.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,s=0;s=0&&(A=l,P=d),g.negative&&(g=g.neg(),y=y.neg()),A.negative&&(A=A.neg(),P=P.neg()),[{a:g,b:y},{a:A,b:P}]},Vi.prototype._endoSplit=function(e){var r=this.endo.basis,n=r[0],i=r[1],s=i.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),a=s.mul(n.a),u=o.mul(i.a),l=s.mul(n.b),d=o.mul(i.b),g=e.sub(a).sub(u),y=l.add(d).neg();return{k1:g,k2:y}},Vi.prototype.pointFromX=function(e,r){e=new en(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(r&&!s||!r&&s)&&(i=i.redNeg()),this.point(e,i)},Vi.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,n=e.y,i=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(s).cmpn(0)===0},Vi.prototype._endoWnafMulAdd=function(e,r,n){for(var i=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""},On.prototype.isInfinity=function(){return this.inf},On.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 r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var n=r.redSqr().redISub(this.x).redISub(e.x),i=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)},On.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 r=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),s=n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i),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)},On.prototype.getX=function(){return this.x.fromRed()},On.prototype.getY=function(){return this.y.fromRed()},On.prototype.mul=function(e){return e=new en(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)},On.prototype.mulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)},On.prototype.jmulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)},On.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)},On.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=function(s){return s.neg()};r.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return r},On.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 jn(t,e,r,n){vu.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new en(0)):(this.x=new en(e,16),this.y=new en(r,16),this.z=new en(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.zOne=this.z===this.curve.one}Ym(jn,vu.BasePoint),Vi.prototype.jpoint=function(e,r,n){return new jn(this,e,r,n)},jn.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),n=this.x.redMul(r),i=this.y.redMul(r).redMul(e);return this.curve.point(n,i)},jn.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},jn.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(r),s=e.x.redMul(n),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),u=i.redSub(s),l=o.redSub(a);if(u.cmpn(0)===0)return l.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var d=u.redSqr(),g=d.redMul(u),y=i.redMul(d),A=l.redSqr().redIAdd(g).redISub(y).redISub(y),P=l.redMul(y.redISub(A)).redISub(o.redMul(g)),N=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(A,P,N)},jn.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),n=this.x,i=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=n.redSub(i),u=s.redSub(o);if(a.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),d=l.redMul(a),g=n.redMul(l),y=u.redSqr().redIAdd(d).redISub(g).redISub(g),A=u.redMul(g.redISub(y)).redISub(s.redMul(d)),P=this.z.redMul(a);return this.curve.jpoint(y,A,P)},jn.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var n=this;for(r=0;r=0)return!1;if(n.redIAdd(s),this.x.cmp(n)===0)return!0}},jn.prototype.inspect=function(){return this.isInfinity()?"":""},jn.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var bu=wo,I3=bd,Rd=Td,Mk=Ti;function yu(t){Rd.call(this,"mont",t),this.a=new bu(t.a,16).toRed(this.red),this.b=new bu(t.b,16).toRed(this.red),this.i4=new bu(4).toRed(this.red).redInvm(),this.two=new bu(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}I3(yu,Rd);var Ik=yu;yu.prototype.validate=function(e){var r=e.normalize().x,n=r.redSqr(),i=n.redMul(r).redAdd(n.redMul(this.a)).redAdd(r),s=i.redSqrt();return s.redSqr().cmp(i)===0};function Nn(t,e,r){Rd.BasePoint.call(this,t,"projective"),e===null&&r===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new bu(e,16),this.z=new bu(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}I3(Nn,Rd.BasePoint),yu.prototype.decodePoint=function(e,r){return this.point(Mk.toArray(e,r),1)},yu.prototype.point=function(e,r){return new Nn(this,e,r)},yu.prototype.pointFromJSON=function(e){return Nn.fromJSON(this,e)},Nn.prototype.precompute=function(){},Nn.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Nn.fromJSON=function(e,r){return new Nn(e,r[0],r[1]||e.one)},Nn.prototype.inspect=function(){return this.isInfinity()?"":""},Nn.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Nn.prototype.dbl=function(){var e=this.x.redAdd(this.z),r=e.redSqr(),n=this.x.redSub(this.z),i=n.redSqr(),s=r.redSub(i),o=r.redMul(i),a=s.redMul(i.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)},Nn.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Nn.prototype.diffAdd=function(e,r){var n=this.x.redAdd(this.z),i=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(n),u=s.redMul(i),l=r.z.redMul(a.redAdd(u).redSqr()),d=r.x.redMul(a.redISub(u).redSqr());return this.curve.point(l,d)},Nn.prototype.mul=function(e){for(var r=e.clone(),n=this,i=this.curve.point(null,null),s=this,o=[];r.cmpn(0)!==0;r.iushrn(1))o.push(r.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(n=n.diffAdd(i,s),i=i.dbl()):(i=n.diffAdd(i,s),n=n.dbl());return i},Nn.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Nn.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Nn.prototype.eq=function(e){return this.getX().cmp(e.getX())===0},Nn.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Nn.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var Ck=Ti,xo=wo,C3=bd,Dd=Td,Tk=Ck.assert;function qs(t){this.twisted=(t.a|0)!==1,this.mOneA=this.twisted&&(t.a|0)===-1,this.extended=this.mOneA,Dd.call(this,"edwards",t),this.a=new xo(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new xo(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new xo(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),Tk(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(t.c|0)===1}C3(qs,Dd);var Rk=qs;qs.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},qs.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},qs.prototype.jpoint=function(e,r,n,i){return this.point(e,r,n,i)},qs.prototype.pointFromX=function(e,r){e=new xo(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr(),i=this.c2.redSub(this.a.redMul(n)),s=this.one.redSub(this.c2.redMul(this.d).redMul(n)),o=i.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var u=a.fromRed().isOdd();return(r&&!u||!r&&u)&&(a=a.redNeg()),this.point(e,a)},qs.prototype.pointFromY=function(e,r){e=new xo(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr(),i=n.redSub(this.c2),s=n.redMul(this.d).redMul(this.c2).redSub(this.a),o=i.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(r)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()!==r&&(a=a.redNeg()),this.point(a,e)},qs.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var r=e.x.redSqr(),n=e.y.redSqr(),i=r.redMul(this.a).redAdd(n),s=this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(n)));return i.cmp(s)===0};function Hr(t,e,r,n,i){Dd.BasePoint.call(this,t,"projective"),e===null&&r===null&&n===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 xo(e,16),this.y=new xo(r,16),this.z=n?new xo(n,16):this.curve.one,this.t=i&&new xo(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.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()))))}C3(Hr,Dd.BasePoint),qs.prototype.pointFromJSON=function(e){return Hr.fromJSON(this,e)},qs.prototype.point=function(e,r,n,i){return new Hr(this,e,r,n,i)},Hr.fromJSON=function(e,r){return new Hr(e,r[0],r[1],r[2])},Hr.prototype.inspect=function(){return this.isInfinity()?"":""},Hr.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},Hr.prototype._extDbl=function(){var e=this.x.redSqr(),r=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var i=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(r),o=i.redAdd(r),a=o.redSub(n),u=i.redSub(r),l=s.redMul(a),d=o.redMul(u),g=s.redMul(u),y=a.redMul(o);return this.curve.point(l,d,y,g)},Hr.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),r=this.x.redSqr(),n=this.y.redSqr(),i,s,o,a,u,l;if(this.curve.twisted){a=this.curve._mulA(r);var d=a.redAdd(n);this.zOne?(i=e.redSub(r).redSub(n).redMul(d.redSub(this.curve.two)),s=d.redMul(a.redSub(n)),o=d.redSqr().redSub(d).redSub(d)):(u=this.z.redSqr(),l=d.redSub(u).redISub(u),i=e.redSub(r).redISub(n).redMul(l),s=d.redMul(a.redSub(n)),o=d.redMul(l))}else a=r.redAdd(n),u=this.curve._mulC(this.z).redSqr(),l=a.redSub(u).redSub(u),i=this.curve._mulC(e.redISub(a)).redMul(l),s=this.curve._mulC(a).redMul(r.redISub(n)),o=a.redMul(l);return this.curve.point(i,s,o)},Hr.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Hr.prototype._extAdd=function(e){var r=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=n.redSub(r),a=s.redSub(i),u=s.redAdd(i),l=n.redAdd(r),d=o.redMul(a),g=u.redMul(l),y=o.redMul(l),A=a.redMul(u);return this.curve.point(d,g,A,y)},Hr.prototype._projAdd=function(e){var r=this.z.redMul(e.z),n=r.redSqr(),i=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(i).redMul(s),a=n.redSub(o),u=n.redAdd(o),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(i).redISub(s),d=r.redMul(a).redMul(l),g,y;return this.curve.twisted?(g=r.redMul(u).redMul(s.redSub(this.curve._mulA(i))),y=a.redMul(u)):(g=r.redMul(u).redMul(s.redSub(i)),y=this.curve._mulC(a).redMul(u)),this.curve.point(d,g,y)},Hr.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Hr.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Hr.prototype.mulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!1)},Hr.prototype.jmulAdd=function(e,r,n){return this.curve._wnafMulAdd(1,[this,r],[e,n],2,!0)},Hr.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},Hr.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Hr.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Hr.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Hr.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0},Hr.prototype.eqXToP=function(e){var r=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(r)===0)return!0;for(var n=e.clone(),i=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),this.x.cmp(r)===0)return!0}},Hr.prototype.toP=Hr.prototype.normalize,Hr.prototype.mixedAdd=Hr.prototype.add,function(t){var e=t;e.base=Td,e.short=Pk,e.mont=Ik,e.edwards=Rk}(Gm);var Od={},Jm,T3;function Dk(){return T3||(T3=1,Jm={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"]]}}),Jm}(function(t){var e=t,r=ol,n=Gm,i=Ti,s=i.assert;function o(l){l.type==="short"?this.curve=new n.short(l):l.type==="edwards"?this.curve=new n.edwards(l):this.curve=new n.mont(l),this.g=this.curve.g,this.n=this.curve.n,this.hash=l.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function a(l,d){Object.defineProperty(e,l,{configurable:!0,enumerable:!0,get:function(){var g=new o(d);return Object.defineProperty(e,l,{configurable:!0,enumerable:!0,value:g}),g}})}a("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.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("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.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("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.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("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.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"]}),a("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.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"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["9"]}),a("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.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var u;try{u=Dk()}catch{u=void 0}a("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.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",u]})})(Od);var Ok=ol,Xa=Wm,R3=Va;function ca(t){if(!(this instanceof ca))return new ca(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Xa.toArray(t.entropy,t.entropyEnc||"hex"),r=Xa.toArray(t.nonce,t.nonceEnc||"hex"),n=Xa.toArray(t.pers,t.persEnc||"hex");R3(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Nk=ca;ca.prototype._init=function(e,r,n){var i=e.concat(r).concat(n);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(n||[])),this._reseed=1},ca.prototype.generate=function(e,r,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(i=n,n=r,r=null),n&&(n=Xa.toArray(n,i||"hex"),this._update(n));for(var s=[];s.length"};var Nd=wo,Zm=Ti,Bk=Zm.assert;function Ld(t,e){if(t instanceof Ld)return t;this._importDER(t,e)||(Bk(t.r&&t.s,"Signature without r or s"),this.r=new Nd(t.r,16),this.s=new Nd(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Fk=Ld;function Uk(){this.place=0}function Qm(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4||t[e.place]===0)return!1;for(var i=0,s=0,o=e.place;s>>=0;return i<=127?!1:(e.place=o,i)}function D3(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Ld.prototype.toDER=function(e){var r=this.r.toArray(),n=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),n[0]&128&&(n=[0].concat(n)),r=D3(r),n=D3(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];e1(i,r.length),i=i.concat(r),i.push(2),e1(i,n.length);var s=i.concat(n),o=[48];return e1(o,s.length),o=o.concat(s),Zm.encode(o,e)};var _o=wo,O3=Nk,jk=Ti,t1=Od,qk=M3,N3=jk.assert,r1=$k,kd=Fk;function Gi(t){if(!(this instanceof Gi))return new Gi(t);typeof t=="string"&&(N3(Object.prototype.hasOwnProperty.call(t1,t),"Unknown curve "+t),t=t1[t]),t instanceof t1.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var zk=Gi;Gi.prototype.keyPair=function(e){return new r1(this,e)},Gi.prototype.keyFromPrivate=function(e,r){return r1.fromPrivate(this,e,r)},Gi.prototype.keyFromPublic=function(e,r){return r1.fromPublic(this,e,r)},Gi.prototype.genKeyPair=function(e){e||(e={});for(var r=new O3({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||qk(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new _o(2));;){var s=new _o(r.generate(n));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Gi.prototype._truncateToN=function(e,r,n){var i;if(_o.isBN(e)||typeof e=="number")e=new _o(e,16),i=e.byteLength();else if(typeof e=="object")i=e.length,e=new _o(e,16);else{var s=e.toString();i=s.length+1>>>1,e=new _o(s,16)}typeof n!="number"&&(n=i*8);var o=n-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},Gi.prototype.sign=function(e,r,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),r=this.keyFromPrivate(r,n),e=this._truncateToN(e,!1,i.msgBitLength);for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),a=e.toArray("be",s),u=new O3({hash:this.hash,entropy:o,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),l=this.n.sub(new _o(1)),d=0;;d++){var g=i.k?i.k(d):new _o(u.generate(this.n.byteLength()));if(g=this._truncateToN(g,!0),!(g.cmpn(1)<=0||g.cmp(l)>=0)){var y=this.g.mul(g);if(!y.isInfinity()){var A=y.getX(),P=A.umod(this.n);if(P.cmpn(0)!==0){var N=g.invm(this.n).mul(P.mul(r.getPrivate()).iadd(e));if(N=N.umod(this.n),N.cmpn(0)!==0){var D=(y.getY().isOdd()?1:0)|(A.cmp(P)!==0?2:0);return i.canonical&&N.cmp(this.nh)>0&&(N=this.n.sub(N),D^=1),new kd({r:P,s:N,recoveryParam:D})}}}}}},Gi.prototype.verify=function(e,r,n,i,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),n=this.keyFromPublic(n,i),r=new kd(r,"hex");var o=r.r,a=r.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var u=a.invm(this.n),l=u.mul(e).umod(this.n),d=u.mul(o).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(l,n.getPublic(),d),g.isInfinity()?!1:g.eqXToP(o)):(g=this.g.mulAdd(l,n.getPublic(),d),g.isInfinity()?!1:g.getX().umod(this.n).cmp(o)===0)},Gi.prototype.recoverPubKey=function(t,e,r,n){N3((3&r)===r,"The recovery param is more than two bits"),e=new kd(e,n);var i=this.n,s=new _o(t),o=e.r,a=e.s,u=r&1,l=r>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");l?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var d=e.r.invm(i),g=i.sub(s).mul(d).umod(i),y=a.mul(d).umod(i);return this.g.mulAdd(g,o,y)},Gi.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new kd(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch{continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var hl=Ti,L3=hl.assert,k3=hl.parseBytes,wu=hl.cachedProperty;function Ln(t,e){this.eddsa=t,this._secret=k3(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=k3(e.pub)}Ln.fromPublic=function(e,r){return r instanceof Ln?r:new Ln(e,{pub:r})},Ln.fromSecret=function(e,r){return r instanceof Ln?r:new Ln(e,{secret:r})},Ln.prototype.secret=function(){return this._secret},wu(Ln,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),wu(Ln,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),wu(Ln,"privBytes",function(){var e=this.eddsa,r=this.hash(),n=e.encodingLength-1,i=r.slice(0,e.encodingLength);return i[0]&=248,i[n]&=127,i[n]|=64,i}),wu(Ln,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),wu(Ln,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),wu(Ln,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),Ln.prototype.sign=function(e){return L3(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},Ln.prototype.verify=function(e,r){return this.eddsa.verify(e,r,this)},Ln.prototype.getSecret=function(e){return L3(this._secret,"KeyPair is public only"),hl.encode(this.secret(),e)},Ln.prototype.getPublic=function(e){return hl.encode(this.pubBytes(),e)};var Hk=Ln,Wk=wo,$d=Ti,$3=$d.assert,Bd=$d.cachedProperty,Kk=$d.parseBytes;function Za(t,e){this.eddsa=t,typeof e!="object"&&(e=Kk(e)),Array.isArray(e)&&($3(e.length===t.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),$3(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof Wk&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}Bd(Za,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),Bd(Za,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),Bd(Za,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),Bd(Za,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Za.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Za.prototype.toHex=function(){return $d.encode(this.toBytes(),"hex").toUpperCase()};var Vk=Za,Gk=ol,Yk=Od,xu=Ti,Jk=xu.assert,B3=xu.parseBytes,F3=Hk,U3=Vk;function vi(t){if(Jk(t==="ed25519","only tested with ed25519 so far"),!(this instanceof vi))return new vi(t);t=Yk[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=Gk.sha512}var Xk=vi;vi.prototype.sign=function(e,r){e=B3(e);var n=this.keyFromSecret(r),i=this.hashInt(n.messagePrefix(),e),s=this.g.mul(i),o=this.encodePoint(s),a=this.hashInt(o,n.pubBytes(),e).mul(n.priv()),u=i.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:u,Rencoded:o})},vi.prototype.verify=function(e,r,n){if(e=B3(e),r=this.makeSignature(r),r.S().gte(r.eddsa.curve.n)||r.S().isNeg())return!1;var i=this.keyFromPublic(n),s=this.hashInt(r.Rencoded(),i.pubBytes(),e),o=this.g.mul(r.S()),a=r.R().add(i.pub().mul(s));return a.eq(o)},vi.prototype.hashInt=function(){for(var e=this.hash(),r=0;re in t?e$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,H3=(t,e)=>{for(var r in e||(e={}))t$.call(e,r)&&z3(t,r,e[r]);if(q3)for(var r of q3(e))r$.call(e,r)&&z3(t,r,e[r]);return t};const n$="ReactNative",Ri={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},i$="js";function Fd(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Eu(){return!rl()&&!!gm()&&navigator.product===n$}function dl(){return!Fd()&&!!gm()&&!!rl()}function pl(){return Eu()?Ri.reactNative:Fd()?Ri.node:dl()?Ri.browser:Ri.unknown}function s$(){var t;try{return Eu()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function o$(t,e){let r=nl.parse(t);return r=H3(H3({},r),e),t=nl.stringify(r),t}function W3(){return Ax()||{name:"",description:"",url:"",icons:[""]}}function a$(){if(pl()===Ri.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:n}=global.Platform;return[r,n].join("-")}const t=OO();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function c$(){var t;const e=pl();return e===Ri.browser?[e,((t=Sx())==null?void 0:t.host)||"unknown"].join(":"):e}function K3(t,e,r){const n=a$(),i=c$();return[[t,e].join("-"),[i$,r].join("-"),n,i].join("/")}function u$({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s,useOnCloseEvent:o,bundleId:a}){const u=r.split("?"),l=K3(t,e,n),d={auth:i,ua:l,projectId:s,useOnCloseEvent:o,origin:a||void 0},g=o$(u[1]||"",d);return u[0]+"?"+g}function Qa(t,e){return t.filter(r=>e.includes(r)).length===t.length}function V3(t){return Object.fromEntries(t.entries())}function G3(t){return new Map(Object.entries(t))}function ec(t=mt.FIVE_MINUTES,e){const r=mt.toMiliseconds(t||mt.FIVE_MINUTES);let n,i,s;return{resolve:o=>{s&&n&&(clearTimeout(s),n(o))},reject:o=>{s&&i&&(clearTimeout(s),i(o))},done:()=>new Promise((o,a)=>{s=setTimeout(()=>{a(new Error(e))},r),n=o,i=a})}}function Su(t,e,r){return new Promise(async(n,i)=>{const s=setTimeout(()=>i(new Error(r)),e);try{const o=await t;n(o)}catch(o){i(o)}clearTimeout(s)})}function Y3(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.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: ${t}`)}function f$(t){return Y3("topic",t)}function l$(t){return Y3("id",t)}function J3(t){const[e,r]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")n.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return n}function En(t,e){return mt.fromMiliseconds(Date.now()+mt.toMiliseconds(t))}function ua(t){return Date.now()>=mt.toMiliseconds(t)}function vr(t,e){return`${t}${e?`:${e}`:""}`}function Ud(t=[],e=[]){return[...new Set([...t,...e])]}async function h$({id:t,topic:e,wcDeepLink:r}){var n;try{if(!r)return;const i=typeof r=="string"?JSON.parse(r):r,s=i==null?void 0:i.href;if(typeof s!="string")return;const o=d$(s,t,e),a=pl();if(a===Ri.browser){if(!((n=rl())!=null&&n.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,g$()?"_blank":"_self","noreferrer noopener")}else a===Ri.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(i){console.error(i)}}function d$(t,e,r){const n=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let i=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";i=`${i}${s}${m$(n,!0)}`}else i=`${i}/wc?${n}`;return i}async function p$(t,e){let r="";try{if(dl()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(n){console.error(n)}return r}function X3(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),n=r.indexOf(e);return r[n+2]}function Z3(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function n1(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function g$(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function m$(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function Q3(t){return Buffer.from(t,"base64").toString("utf-8")}const v$="https://rpc.walletconnect.org/v1";async function b$(t,e,r,n,i,s){switch(r.t){case"eip191":return y$(t,e,r.s);case"eip1271":return await w$(t,e,r.s,n,i,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function y$(t,e,r){return ck(jx(e),r).toLowerCase()===t.toLowerCase()}async function w$(t,e,r,n,i,s){const o=_u(n);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${n}`);try{const a="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",l="0000000000000000000000000000000000000000000000000000000000000041",d=r.substring(2),g=jx(e).substring(2),y=a+g+u+l+d,A=await fetch(`${s||v$}/?chainId=${n}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:x$(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:y},"latest"]})}),{result:P}=await A.json();return P?P.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function x$(){return Date.now()+Math.floor(Math.random()*1e3)}var _$=Object.defineProperty,E$=Object.defineProperties,S$=Object.getOwnPropertyDescriptors,e_=Object.getOwnPropertySymbols,A$=Object.prototype.hasOwnProperty,P$=Object.prototype.propertyIsEnumerable,t_=(t,e,r)=>e in t?_$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,M$=(t,e)=>{for(var r in e||(e={}))A$.call(e,r)&&t_(t,r,e[r]);if(e_)for(var r of e_(e))P$.call(e,r)&&t_(t,r,e[r]);return t},I$=(t,e)=>E$(t,S$(e));const C$="did:pkh:",i1=t=>t==null?void 0:t.split(":"),T$=t=>{const e=t&&i1(t);if(e)return t.includes(C$)?e[3]:e[1]},s1=t=>{const e=t&&i1(t);if(e)return e[2]+":"+e[3]},jd=t=>{const e=t&&i1(t);if(e)return e.pop()};async function r_(t){const{cacao:e,projectId:r}=t,{s:n,p:i}=e,s=n_(i,i.iss),o=jd(i.iss);return await b$(o,s,n,s1(i.iss),r)}const n_=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,n=jd(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let i=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${T$(e)}`,u=`Nonce: ${t.nonce}`,l=`Issued At: ${t.iat}`,d=t.exp?`Expiration Time: ${t.exp}`:void 0,g=t.nbf?`Not Before: ${t.nbf}`:void 0,y=t.requestId?`Request ID: ${t.requestId}`:void 0,A=t.resources?`Resources:${t.resources.map(N=>` -- ${N}`).join("")}`:void 0,P=qd(t.resources);if(P){const N=gl(P);i=F$(i,N)}return[r,n,"",i,"",s,o,a,u,l,d,g,y,A].filter(N=>N!=null).join(` -`)};function R$(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function D$(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function tc(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const n=t.att[r];if(Array.isArray(n))throw new Error(`Resource must be an object: ${r}`);if(typeof n!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(n).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(n).forEach(i=>{const s=n[i];if(!Array.isArray(s))throw new Error(`Ability limits ${i} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${i} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${i}) must be an array of objects, found: ${o}`)})})})}function O$(t,e,r,n={}){return r==null||r.sort((i,s)=>i.localeCompare(s)),{att:{[t]:N$(e,r,n)}}}function N$(t,e,r={}){e=e==null?void 0:e.sort((i,s)=>i.localeCompare(s));const n=e.map(i=>({[`${t}/${i}`]:[r]}));return Object.assign({},...n)}function i_(t){return tc(t),`urn:recap:${R$(t).replace(/=/g,"")}`}function gl(t){const e=D$(t.replace("urn:recap:",""));return tc(e),e}function L$(t,e,r){const n=O$(t,e,r);return i_(n)}function k$(t){return t&&t.includes("urn:recap:")}function $$(t,e){const r=gl(t),n=gl(e),i=B$(r,n);return i_(i)}function B$(t,e){tc(t),tc(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((i,s)=>i.localeCompare(s)),n={att:{}};return r.forEach(i=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[i])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[i])||{})).sort((a,u)=>a.localeCompare(u)).forEach(a=>{var u,l;n.att[i]=I$(M$({},n.att[i]),{[a]:((u=t.att[i])==null?void 0:u[a])||((l=e.att[i])==null?void 0:l[a])})})}),n}function F$(t="",e){tc(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const n=[];let i=0;Object.keys(e.att).forEach(a=>{const u=Object.keys(e.att[a]).map(g=>({ability:g.split("/")[0],action:g.split("/")[1]}));u.sort((g,y)=>g.action.localeCompare(y.action));const l={};u.forEach(g=>{l[g.ability]||(l[g.ability]=[]),l[g.ability].push(g.action)});const d=Object.keys(l).map(g=>(i++,`(${i}) '${g}': '${l[g].join("', '")}' for '${a}'.`));n.push(d.join(", ").replace(".,","."))});const s=n.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function s_(t){var e;const r=gl(t);tc(r);const n=(e=r.att)==null?void 0:e.eip155;return n?Object.keys(n).map(i=>i.split("/")[1]):[]}function o_(t){const e=gl(t);tc(e);const r=[];return Object.values(e.att).forEach(n=>{Object.values(n).forEach(i=>{var s;(s=i==null?void 0:i[0])!=null&&s.chains&&r.push(i[0].chains)})}),[...new Set(r.flat())]}function qd(t){if(!t)return;const e=t==null?void 0:t[t.length-1];return k$(e)?e:void 0}const a_="base10",ni="base16",fa="base64pad",ml="base64url",vl="utf8",c_=0,Eo=1,bl=2,U$=0,u_=1,yl=12,o1=32;function j$(){const t=zm.generateKeyPair();return{privateKey:Tn(t.secretKey,ni),publicKey:Tn(t.publicKey,ni)}}function a1(){const t=ea.randomBytes(o1);return Tn(t,ni)}function q$(t,e){const r=zm.sharedKey(Rn(t,ni),Rn(e,ni),!0),n=new xk(fl.SHA256,r).expand(o1);return Tn(n,ni)}function zd(t){const e=fl.hash(Rn(t,ni));return Tn(e,ni)}function So(t){const e=fl.hash(Rn(t,vl));return Tn(e,ni)}function f_(t){return Rn(`${t}`,a_)}function rc(t){return Number(Tn(t,a_))}function z$(t){const e=f_(typeof t.type<"u"?t.type:c_);if(rc(e)===Eo&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?Rn(t.senderPublicKey,ni):void 0,n=typeof t.iv<"u"?Rn(t.iv,ni):ea.randomBytes(yl),i=new Um.ChaCha20Poly1305(Rn(t.symKey,ni)).seal(n,Rn(t.message,vl));return l_({type:e,sealed:i,iv:n,senderPublicKey:r,encoding:t.encoding})}function H$(t,e){const r=f_(bl),n=ea.randomBytes(yl),i=Rn(t,vl);return l_({type:r,sealed:i,iv:n,encoding:e})}function W$(t){const e=new Um.ChaCha20Poly1305(Rn(t.symKey,ni)),{sealed:r,iv:n}=wl({encoded:t.encoded,encoding:t==null?void 0:t.encoding}),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return Tn(i,vl)}function K$(t,e){const{sealed:r}=wl({encoded:t,encoding:e});return Tn(r,vl)}function l_(t){const{encoding:e=fa}=t;if(rc(t.type)===bl)return Tn(dd([t.type,t.sealed]),e);if(rc(t.type)===Eo){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Tn(dd([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return Tn(dd([t.type,t.iv,t.sealed]),e)}function wl(t){const{encoded:e,encoding:r=fa}=t,n=Rn(e,r),i=n.slice(U$,u_),s=u_;if(rc(i)===Eo){const l=s+o1,d=l+yl,g=n.slice(s,l),y=n.slice(l,d),A=n.slice(d);return{type:i,sealed:A,iv:y,senderPublicKey:g}}if(rc(i)===bl){const l=n.slice(s),d=ea.randomBytes(yl);return{type:i,sealed:l,iv:d}}const o=s+yl,a=n.slice(s,o),u=n.slice(o);return{type:i,sealed:u,iv:a}}function V$(t,e){const r=wl({encoded:t,encoding:e==null?void 0:e.encoding});return h_({type:rc(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Tn(r.senderPublicKey,ni):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function h_(t){const e=(t==null?void 0:t.type)||c_;if(e===Eo){if(typeof(t==null?void 0:t.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(t==null?void 0:t.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t==null?void 0:t.senderPublicKey,receiverPublicKey:t==null?void 0:t.receiverPublicKey}}function d_(t){return t.type===Eo&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function p_(t){return t.type===bl}function G$(t){return new A3.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function Y$(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function J$(t){return Buffer.from(Y$(t),"base64")}function X$(t,e){const[r,n,i]=t.split("."),s=J$(i);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),u=`${r}.${n}`,l=new fl.SHA256().update(Buffer.from(u)).digest(),d=G$(e),g=Buffer.from(l).toString("hex");if(!d.verify(g,{r:o,s:a}))throw new Error("Invalid signature");return pm(t).payload}const Z$="irn";function c1(t){return(t==null?void 0:t.relay)||{protocol:Z$}}function xl(t){const e=Zk[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Q$=Object.defineProperty,eB=Object.defineProperties,tB=Object.getOwnPropertyDescriptors,g_=Object.getOwnPropertySymbols,rB=Object.prototype.hasOwnProperty,nB=Object.prototype.propertyIsEnumerable,m_=(t,e,r)=>e in t?Q$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v_=(t,e)=>{for(var r in e||(e={}))rB.call(e,r)&&m_(t,r,e[r]);if(g_)for(var r of g_(e))nB.call(e,r)&&m_(t,r,e[r]);return t},iB=(t,e)=>eB(t,tB(e));function sB(t,e="-"){const r={},n="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),o=t[i];r[s]=o}}),r}function b_(t){if(!t.includes("wc:")){const u=Q3(t);u!=null&&u.includes("wc:")&&(t=u)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),i=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=nl.parse(s),a=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:n,topic:oB(i[0]),version:parseInt(i[1],10),symKey:o.symKey,relay:sB(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function oB(t){return t.startsWith("//")?t.substring(2):t}function aB(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=r+e+i;t[i]&&(n[s]=t[i])}),n}function y_(t){return`${t.protocol}:${t.topic}@${t.version}?`+nl.stringify(v_(iB(v_({symKey:t.symKey},aB(t.relay)),{expiryTimestamp:t.expiryTimestamp}),t.methods?{methods:t.methods.join(",")}:{}))}function Hd(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function Au(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function cB(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Au(r.accounts))}),e}function uB(t,e){const r=[];return Object.values(t).forEach(n=>{Au(n.accounts).includes(e)&&r.push(...n.methods)}),r}function fB(t,e){const r=[];return Object.values(t).forEach(n=>{Au(n.accounts).includes(e)&&r.push(...n.events)}),r}function u1(t){return t.includes(":")}function _l(t){return u1(t)?t.split(":")[0]:t}function lB(t){const e={};return t==null||t.forEach(r=>{const[n,i]=r.split(":");e[n]||(e[n]={accounts:[],chains:[],events:[]}),e[n].accounts.push(r),e[n].chains.push(`${n}:${i}`)}),e}function w_(t,e){e=e.map(n=>n.replace("did:pkh:",""));const r=lB(e);for(const[n,i]of Object.entries(r))i.methods?i.methods=Ud(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return r}const hB={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}},dB={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 ut(t,e){const{message:r,code:n}=dB[t];return{message:e?`${r} ${e}`:r,code:n}}function Dr(t,e){const{message:r,code:n}=hB[t];return{message:e?`${r} ${e}`:r,code:n}}function nc(t,e){return!!Array.isArray(t)}function El(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function bi(t){return typeof t>"u"}function an(t,e){return e&&bi(t)?!0:typeof t=="string"&&!!t.trim().length}function f1(t,e){return typeof t=="number"&&!isNaN(t)}function pB(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return Qa(i,n)?(n.forEach(o=>{const{accounts:a,methods:u,events:l}=t.namespaces[o],d=Au(a),g=r[o];(!Qa(j3(o,g),d)||!Qa(g.methods,u)||!Qa(g.events,l))&&(s=!1)}),s):!1}function Wd(t){return an(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function gB(t){if(an(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&Wd(r)}}return!1}function mB(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(an(t,!1)){if(e(t))return!0;const r=Q3(t);return e(r)}}catch{}return!1}function vB(t){var e;return(e=t==null?void 0:t.proposer)==null?void 0:e.publicKey}function bB(t){return t==null?void 0:t.topic}function yB(t,e){let r=null;return an(t==null?void 0:t.publicKey,!1)||(r=ut("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function x_(t){let e=!0;return nc(t)?t.length&&(e=t.every(r=>an(r,!1))):e=!1,e}function wB(t,e,r){let n=null;return nc(e)&&e.length?e.forEach(i=>{n||Wd(i)||(n=Dr("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):Wd(t)||(n=Dr("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"] }`)),n}function xB(t,e,r){let n=null;return Object.entries(t).forEach(([i,s])=>{if(n)return;const o=wB(i,j3(i,s),`${e} ${r}`);o&&(n=o)}),n}function _B(t,e){let r=null;return nc(t)?t.forEach(n=>{r||gB(n)||(r=Dr("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=Dr("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function EB(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=_B(n==null?void 0:n.accounts,`${e} namespace`);i&&(r=i)}),r}function SB(t,e){let r=null;return x_(t==null?void 0:t.methods)?x_(t==null?void 0:t.events)||(r=Dr("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=Dr("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function __(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=SB(n,`${e}, namespace`);i&&(r=i)}),r}function AB(t,e,r){let n=null;if(t&&El(t)){const i=__(t,e);i&&(n=i);const s=xB(t,e,r);s&&(n=s)}else n=ut("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return n}function l1(t,e){let r=null;if(t&&El(t)){const n=__(t,e);n&&(r=n);const i=EB(t,e);i&&(r=i)}else r=ut("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function E_(t){return an(t.protocol,!0)}function PB(t,e){let r=!1;return t?t&&nc(t)&&t.length&&t.forEach(n=>{r=E_(n)}):r=!0,r}function MB(t){return typeof t=="number"}function yi(t){return typeof t<"u"&&typeof t!==null}function IB(t){return!(!t||typeof t!="object"||!t.code||!f1(t.code)||!t.message||!an(t.message,!1))}function CB(t){return!(bi(t)||!an(t.method,!1))}function TB(t){return!(bi(t)||bi(t.result)&&bi(t.error)||!f1(t.id)||!an(t.jsonrpc,!1))}function RB(t){return!(bi(t)||!an(t.name,!1))}function S_(t,e){return!(!Wd(e)||!cB(t).includes(e))}function DB(t,e,r){return an(r,!1)?uB(t,e).includes(r):!1}function OB(t,e,r){return an(r,!1)?fB(t,e).includes(r):!1}function A_(t,e,r){let n=null;const i=NB(t),s=LB(e),o=Object.keys(i),a=Object.keys(s),u=P_(Object.keys(t)),l=P_(Object.keys(e)),d=u.filter(g=>!l.includes(g));return d.length&&(n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces. - Required: ${d.toString()} - Received: ${Object.keys(e).toString()}`)),Qa(o,a)||(n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces. + */var rx;function JD(){return rx||(rx=1,(function(t){(function(){var e="input is invalid type",r="finalize already called",n=typeof window=="object",i=n?window:{};i.JS_SHA3_NO_WINDOW&&(n=!1);var s=!n&&typeof self=="object",o=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;o?i=Wn:s&&(i=self);var a=!i.JS_SHA3_NO_COMMON_JS&&!0&&t.exports,f=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),h=[31,7936,2031616,520093696],g=[4,1024,262144,67108864],b=[1,256,65536,16777216],x=[6,1536,393216,100663296],S=[0,8,16,24],C=[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],D=[224,256,384,512],B=[128,256],L=["hex","buffer","arrayBuffer","array","digest"],H={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(O){return Object.prototype.toString.call(O)==="[object Array]"}),f&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(O){return typeof O=="object"&&O.buffer&&O.buffer.constructor===ArrayBuffer});for(var F=function(O,ie,ee){return function(Z){return new M(O,ie,O).update(Z)[ee]()}},k=function(O,ie,ee){return function(Z,te){return new M(O,ie,te).update(Z)[ee]()}},$=function(O,ie,ee){return function(Z,te,N,Q){return l["cshake"+O].update(Z,te,N,Q)[ee]()}},R=function(O,ie,ee){return function(Z,te,N,Q){return l["kmac"+O].update(Z,te,N,Q)[ee]()}},W=function(O,ie,ee,Z){for(var te=0;te>5,this.byteCount=this.blockCount<<2,this.outputBlocks=ee>>5,this.extraBytes=(ee&31)>>3;for(var Z=0;Z<50;++Z)this.s[Z]=0}M.prototype.update=function(O){if(this.finalized)throw new Error(r);var ie,ee=typeof O;if(ee!=="string"){if(ee==="object"){if(O===null)throw new Error(e);if(f&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!Array.isArray(O)&&(!f||!ArrayBuffer.isView(O)))throw new Error(e)}else throw new Error(e);ie=!0}for(var Z=this.blocks,te=this.byteCount,N=O.length,Q=this.blockCount,ne=0,de=this.s,ce,fe;ne>2]|=O[ne]<>2]|=fe<>2]|=(192|fe>>6)<>2]|=(128|fe&63)<=57344?(Z[ce>>2]|=(224|fe>>12)<>2]|=(128|fe>>6&63)<>2]|=(128|fe&63)<>2]|=(240|fe>>18)<>2]|=(128|fe>>12&63)<>2]|=(128|fe>>6&63)<>2]|=(128|fe&63)<=te){for(this.start=ce-te,this.block=Z[Q],ce=0;ce>8,ee=O&255;ee>0;)te.unshift(ee),O=O>>8,ee=O&255,++Z;return ie?te.push(Z):te.unshift(Z),this.update(te),te.length},M.prototype.encodeString=function(O){var ie,ee=typeof O;if(ee!=="string"){if(ee==="object"){if(O===null)throw new Error(e);if(f&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!Array.isArray(O)&&(!f||!ArrayBuffer.isView(O)))throw new Error(e)}else throw new Error(e);ie=!0}var Z=0,te=O.length;if(ie)Z=te;else for(var N=0;N=57344?Z+=3:(Q=65536+((Q&1023)<<10|O.charCodeAt(++N)&1023),Z+=4)}return Z+=this.encode(Z*8),this.update(O),Z},M.prototype.bytepad=function(O,ie){for(var ee=this.encode(ie),Z=0;Z>2]|=this.padding[ie&3],this.lastByteIndex===this.byteCount)for(O[0]=O[ee],ie=1;ie>4&15]+u[ne&15]+u[ne>>12&15]+u[ne>>8&15]+u[ne>>20&15]+u[ne>>16&15]+u[ne>>28&15]+u[ne>>24&15];N%O===0&&(se(ie),te=0)}return Z&&(ne=ie[te],Q+=u[ne>>4&15]+u[ne&15],Z>1&&(Q+=u[ne>>12&15]+u[ne>>8&15]),Z>2&&(Q+=u[ne>>20&15]+u[ne>>16&15])),Q},M.prototype.arrayBuffer=function(){this.finalize();var O=this.blockCount,ie=this.s,ee=this.outputBlocks,Z=this.extraBytes,te=0,N=0,Q=this.outputBits>>3,ne;Z?ne=new ArrayBuffer(ee+1<<2):ne=new ArrayBuffer(Q);for(var de=new Uint32Array(ne);N>8&255,Q[ne+2]=de>>16&255,Q[ne+3]=de>>24&255;N%O===0&&se(ie)}return Z&&(ne=N<<2,de=ie[te],Q[ne]=de&255,Z>1&&(Q[ne+1]=de>>8&255),Z>2&&(Q[ne+2]=de>>16&255)),Q};function z(O,ie,ee){M.call(this,O,ie,ee)}z.prototype=new M,z.prototype.finalize=function(){return this.encode(this.outputBits,!0),M.prototype.finalize.call(this)};var se=function(O){var ie,ee,Z,te,N,Q,ne,de,ce,fe,be,Pe,De,Te,Fe,Me,Ne,He,Oe,$e,qe,_e,Qe,at,Be,nt,it,Ye,pt,ht,ft,Ht,Jt,St,Xt,tr,Dt,Bt,Ct,gt,Ot,Lt,bt,jt,Ut,tt,Ft,K,G,J,T,j,oe,le,me,Ee,ke,Ce,et,Ze,rt,ot,yt;for(Z=0;Z<48;Z+=2)te=O[0]^O[10]^O[20]^O[30]^O[40],N=O[1]^O[11]^O[21]^O[31]^O[41],Q=O[2]^O[12]^O[22]^O[32]^O[42],ne=O[3]^O[13]^O[23]^O[33]^O[43],de=O[4]^O[14]^O[24]^O[34]^O[44],ce=O[5]^O[15]^O[25]^O[35]^O[45],fe=O[6]^O[16]^O[26]^O[36]^O[46],be=O[7]^O[17]^O[27]^O[37]^O[47],Pe=O[8]^O[18]^O[28]^O[38]^O[48],De=O[9]^O[19]^O[29]^O[39]^O[49],ie=Pe^(Q<<1|ne>>>31),ee=De^(ne<<1|Q>>>31),O[0]^=ie,O[1]^=ee,O[10]^=ie,O[11]^=ee,O[20]^=ie,O[21]^=ee,O[30]^=ie,O[31]^=ee,O[40]^=ie,O[41]^=ee,ie=te^(de<<1|ce>>>31),ee=N^(ce<<1|de>>>31),O[2]^=ie,O[3]^=ee,O[12]^=ie,O[13]^=ee,O[22]^=ie,O[23]^=ee,O[32]^=ie,O[33]^=ee,O[42]^=ie,O[43]^=ee,ie=Q^(fe<<1|be>>>31),ee=ne^(be<<1|fe>>>31),O[4]^=ie,O[5]^=ee,O[14]^=ie,O[15]^=ee,O[24]^=ie,O[25]^=ee,O[34]^=ie,O[35]^=ee,O[44]^=ie,O[45]^=ee,ie=de^(Pe<<1|De>>>31),ee=ce^(De<<1|Pe>>>31),O[6]^=ie,O[7]^=ee,O[16]^=ie,O[17]^=ee,O[26]^=ie,O[27]^=ee,O[36]^=ie,O[37]^=ee,O[46]^=ie,O[47]^=ee,ie=fe^(te<<1|N>>>31),ee=be^(N<<1|te>>>31),O[8]^=ie,O[9]^=ee,O[18]^=ie,O[19]^=ee,O[28]^=ie,O[29]^=ee,O[38]^=ie,O[39]^=ee,O[48]^=ie,O[49]^=ee,Te=O[0],Fe=O[1],tt=O[11]<<4|O[10]>>>28,Ft=O[10]<<4|O[11]>>>28,Ye=O[20]<<3|O[21]>>>29,pt=O[21]<<3|O[20]>>>29,Ze=O[31]<<9|O[30]>>>23,rt=O[30]<<9|O[31]>>>23,Lt=O[40]<<18|O[41]>>>14,bt=O[41]<<18|O[40]>>>14,St=O[2]<<1|O[3]>>>31,Xt=O[3]<<1|O[2]>>>31,Me=O[13]<<12|O[12]>>>20,Ne=O[12]<<12|O[13]>>>20,K=O[22]<<10|O[23]>>>22,G=O[23]<<10|O[22]>>>22,ht=O[33]<<13|O[32]>>>19,ft=O[32]<<13|O[33]>>>19,ot=O[42]<<2|O[43]>>>30,yt=O[43]<<2|O[42]>>>30,le=O[5]<<30|O[4]>>>2,me=O[4]<<30|O[5]>>>2,tr=O[14]<<6|O[15]>>>26,Dt=O[15]<<6|O[14]>>>26,He=O[25]<<11|O[24]>>>21,Oe=O[24]<<11|O[25]>>>21,J=O[34]<<15|O[35]>>>17,T=O[35]<<15|O[34]>>>17,Ht=O[45]<<29|O[44]>>>3,Jt=O[44]<<29|O[45]>>>3,at=O[6]<<28|O[7]>>>4,Be=O[7]<<28|O[6]>>>4,Ee=O[17]<<23|O[16]>>>9,ke=O[16]<<23|O[17]>>>9,Bt=O[26]<<25|O[27]>>>7,Ct=O[27]<<25|O[26]>>>7,$e=O[36]<<21|O[37]>>>11,qe=O[37]<<21|O[36]>>>11,j=O[47]<<24|O[46]>>>8,oe=O[46]<<24|O[47]>>>8,jt=O[8]<<27|O[9]>>>5,Ut=O[9]<<27|O[8]>>>5,nt=O[18]<<20|O[19]>>>12,it=O[19]<<20|O[18]>>>12,Ce=O[29]<<7|O[28]>>>25,et=O[28]<<7|O[29]>>>25,gt=O[38]<<8|O[39]>>>24,Ot=O[39]<<8|O[38]>>>24,_e=O[48]<<14|O[49]>>>18,Qe=O[49]<<14|O[48]>>>18,O[0]=Te^~Me&He,O[1]=Fe^~Ne&Oe,O[10]=at^~nt&Ye,O[11]=Be^~it&pt,O[20]=St^~tr&Bt,O[21]=Xt^~Dt&Ct,O[30]=jt^~tt&K,O[31]=Ut^~Ft&G,O[40]=le^~Ee&Ce,O[41]=me^~ke&et,O[2]=Me^~He&$e,O[3]=Ne^~Oe&qe,O[12]=nt^~Ye&ht,O[13]=it^~pt&ft,O[22]=tr^~Bt>,O[23]=Dt^~Ct&Ot,O[32]=tt^~K&J,O[33]=Ft^~G&T,O[42]=Ee^~Ce&Ze,O[43]=ke^~et&rt,O[4]=He^~$e&_e,O[5]=Oe^~qe&Qe,O[14]=Ye^~ht&Ht,O[15]=pt^~ft&Jt,O[24]=Bt^~gt&Lt,O[25]=Ct^~Ot&bt,O[34]=K^~J&j,O[35]=G^~T&oe,O[44]=Ce^~Ze&ot,O[45]=et^~rt&yt,O[6]=$e^~_e&Te,O[7]=qe^~Qe&Fe,O[16]=ht^~Ht&at,O[17]=ft^~Jt&Be,O[26]=gt^~Lt&St,O[27]=Ot^~bt&Xt,O[36]=J^~j&jt,O[37]=T^~oe&Ut,O[46]=Ze^~ot&le,O[47]=rt^~yt&me,O[8]=_e^~Te&Me,O[9]=Qe^~Fe&Ne,O[18]=Ht^~at&nt,O[19]=Jt^~Be&it,O[28]=Lt^~St&tr,O[29]=bt^~Xt&Dt,O[38]=j^~jt&tt,O[39]=oe^~Ut&Ft,O[48]=ot^~le&Ee,O[49]=yt^~me&ke,O[0]^=C[Z],O[1]^=C[Z+1]};if(a)t.exports=l;else for(m=0;m{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if("é".normalize("NFD")!=="é")throw new Error("broken implementation")}catch(t){return t.message}return null}const ox=eO();var vg;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"})(vg||(vg={}));var is;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"})(is||(is={}));const ax="0123456789abcdef";class Kr{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){const n=e.toLowerCase();wh[n]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(sx>wh[n])&&console.log.apply(console,r)}debug(...e){this._log(Kr.levels.DEBUG,e)}info(...e){this._log(Kr.levels.INFO,e)}warn(...e){this._log(Kr.levels.WARNING,e)}makeError(e,r,n){if(ix)return this.makeError("censored error",r,{});r||(r=Kr.errors.UNKNOWN_ERROR),n||(n={});const i=[];Object.keys(n).forEach(f=>{const u=n[f];try{if(u instanceof Uint8Array){let h="";for(let g=0;g>4],h+=ax[u[g]&15];i.push(f+"=Uint8Array(0x"+h+")")}else i.push(f+"="+JSON.stringify(u))}catch{i.push(f+"="+JSON.stringify(n[f].toString()))}}),i.push(`code=${r}`),i.push(`version=${this.version}`);const s=e;let o="";switch(r){case is.NUMERIC_FAULT:{o="NUMERIC_FAULT";const 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 is.CALL_EXCEPTION:case is.INSUFFICIENT_FUNDS:case is.MISSING_NEW:case is.NONCE_EXPIRED:case is.REPLACEMENT_UNDERPRICED:case is.TRANSACTION_REPLACED:case is.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),i.length&&(e+=" ("+i.join(", ")+")");const a=new Error(e);return a.reason=s,a.code=r,Object.keys(n).forEach(function(f){a[f]=n[f]}),a}throwError(e,r,n){throw this.makeError(e,r,n)}throwArgumentError(e,r,n){return this.throwError(e,Kr.errors.INVALID_ARGUMENT,{argument:r,value:n})}assert(e,r,n,i){e||this.throwError(r,n,i)}assertArgument(e,r,n,i){e||this.throwArgumentError(r,n,i)}checkNormalize(e){ox&&this.throwError("platform missing String.prototype.normalize",Kr.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ox})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,Kr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,Kr.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,r,n){n?n=": "+n:n="",er&&this.throwError("too many arguments"+n,Kr.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",Kr.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",Kr.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",Kr.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return mg||(mg=new Kr(QD)),mg}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",Kr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),nx){if(!e)return;this.globalLogger().throwError("error censorship permanent",Kr.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}ix=!!e,nx=!!r}static setLogLevel(e){const r=wh[e.toLowerCase()];if(r==null){Kr.globalLogger().warn("invalid log level - "+e);return}sx=r}static from(e){return new Kr(e)}}Kr.errors=is,Kr.levels=vg;const tO="bytes/5.7.0",rn=new Kr(tO);function cx(t){return!!t.toHexString}function yc(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return yc(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function rO(t){return xs(t)&&!(t.length%2)||bg(t)}function ux(t){return typeof t=="number"&&t==t&&t%1===0}function bg(t){if(t==null)return!1;if(t.constructor===Uint8Array)return!0;if(typeof t=="string"||!ux(t.length)||t.length<0)return!1;for(let e=0;e=256)return!1}return!0}function mn(t,e){if(e||(e={}),typeof t=="number"){rn.checkSafeUint53(t,"invalid arrayify value");const r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),yc(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),cx(t)&&(t=t.toHexString()),xs(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":rn.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let i=0;imn(i)),r=e.reduce((i,s)=>i+s.length,0),n=new Uint8Array(r);return e.reduce((i,s)=>(n.set(s,i),i+s.length),0),yc(n)}function iO(t,e){t=mn(t),t.length>e&&rn.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),yc(r)}function xs(t,e){return!(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}const yg="0123456789abcdef";function mi(t,e){if(e||(e={}),typeof t=="number"){rn.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=yg[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),cx(t))return t.toHexString();if(xs(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":rn.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(bg(t)){let r="0x";for(let n=0;n>4]+yg[i&15]}return r}return rn.throwArgumentError("invalid hexlify value","value",t)}function sO(t){if(typeof t!="string")t=mi(t);else if(!xs(t)||t.length%2)return null;return(t.length-2)/2}function fx(t,e,r){return typeof t!="string"?t=mi(t):(!xs(t)||t.length%2)&&rn.throwArgumentError("invalid hexData","value",t),e=2+2*e,"0x"+t.substring(e)}function wc(t,e){for(typeof t!="string"?t=mi(t):xs(t)||rn.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&rn.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function lx(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(rO(t)){let r=mn(t);r.length===64?(e.v=27+(r[32]>>7),r[32]&=127,e.r=mi(r.slice(0,32)),e.s=mi(r.slice(32,64))):r.length===65?(e.r=mi(r.slice(0,32)),e.s=mi(r.slice(32,64)),e.v=r[64]):rn.throwArgumentError("invalid signature string","signature",t),e.v<27&&(e.v===0||e.v===1?e.v+=27:rn.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=mi(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,e._vs!=null){const i=iO(mn(e._vs),32);e._vs=mi(i);const s=i[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&rn.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),i[0]&=127;const o=mi(i);e.s==null?e.s=o:e.s!==o&&rn.throwArgumentError("signature v mismatch _vs","signature",t)}if(e.recoveryParam==null)e.v==null?rn.throwArgumentError("signature missing v and recoveryParam","signature",t):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{const i=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==i&&rn.throwArgumentError("signature recoveryParam mismatch v","signature",t)}e.r==null||!xs(e.r)?rn.throwArgumentError("signature missing or invalid r","signature",t):e.r=wc(e.r,32),e.s==null||!xs(e.s)?rn.throwArgumentError("signature missing or invalid s","signature",t):e.s=wc(e.s,32);const r=mn(e.s);r[0]>=128&&rn.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=mi(r);e._vs&&(xs(e._vs)||rn.throwArgumentError("signature invalid _vs","signature",t),e._vs=wc(e._vs,32)),e._vs==null?e._vs=n:e._vs!==n&&rn.throwArgumentError("signature _vs mismatch v and s","signature",t)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function wg(t){return"0x"+ZD.keccak_256(mn(t))}var xh={exports:{}},oO=xh.exports,hx;function aO(){return hx||(hx=1,(function(t){(function(e,r){function n(v,l){if(!v)throw new Error(l||"Assertion failed")}function i(v,l){v.super_=l;var p=function(){};p.prototype=l.prototype,v.prototype=new p,v.prototype.constructor=v}function s(v,l,p){if(s.isBN(v))return v;this.negative=0,this.words=null,this.length=0,this.red=null,v!==null&&((l==="le"||l==="be")&&(p=l,l=10),this._init(v||0,l||10,p||"be"))}typeof e=="object"?e.exports=s:r.BN=s,s.BN=s,s.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Qu.Buffer}catch{}s.isBN=function(l){return l instanceof s?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===s.wordSize&&Array.isArray(l.words)},s.max=function(l,p){return l.cmp(p)>0?l:p},s.min=function(l,p){return l.cmp(p)<0?l:p},s.prototype._init=function(l,p,m){if(typeof l=="number")return this._initNumber(l,p,m);if(typeof l=="object")return this._initArray(l,p,m);p==="hex"&&(p=16),n(p===(p|0)&&p>=2&&p<=36),l=l.toString().replace(/\s+/g,"");var y=0;l[0]==="-"&&(y++,this.negative=1),y=0;y-=3)E=l[y]|l[y-1]<<8|l[y-2]<<16,this.words[A]|=E<>>26-w&67108863,w+=24,w>=26&&(w-=26,A++);else if(m==="le")for(y=0,A=0;y>>26-w&67108863,w+=24,w>=26&&(w-=26,A++);return this._strip()};function a(v,l){var p=v.charCodeAt(l);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;n(!1,"Invalid character in "+v)}function f(v,l,p){var m=a(v,p);return p-1>=l&&(m|=a(v,p-1)<<4),m}s.prototype._parseHex=function(l,p,m){this.length=Math.ceil((l.length-p)/6),this.words=new Array(this.length);for(var y=0;y=p;y-=2)w=f(l,p,y)<=18?(A-=18,E+=1,this.words[E]|=w>>>26):A+=8;else{var I=l.length-p;for(y=I%2===0?p+1:p;y=18?(A-=18,E+=1,this.words[E]|=w>>>26):A+=8}this._strip()};function u(v,l,p,m){for(var y=0,A=0,E=Math.min(v.length,p),w=l;w=49?A=I-49+10:I>=17?A=I-17+10:A=I,n(I>=0&&A1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=g}catch{s.prototype.inspect=g}else s.prototype.inspect=g;function g(){return(this.red?""}var b=["","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"],x=[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],S=[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];s.prototype.toString=function(l,p){l=l||10,p=p|0||1;var m;if(l===16||l==="hex"){m="";for(var y=0,A=0,E=0;E>>24-y&16777215,y+=2,y>=26&&(y-=26,E--),A!==0||E!==this.length-1?m=b[6-I.length]+I+m:m=I+m}for(A!==0&&(m=A.toString(16)+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(l===(l|0)&&l>=2&&l<=36){var M=x[l],z=S[l];m="";var se=this.clone();for(se.negative=0;!se.isZero();){var O=se.modrn(z).toString(l);se=se.idivn(z),se.isZero()?m=O+m:m=b[M-O.length]+O+m}for(this.isZero()&&(m="0"+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}n(!1,"Base should be between 2 and 36")},s.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&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(l,p){return this.toArrayLike(o,l,p)}),s.prototype.toArray=function(l,p){return this.toArrayLike(Array,l,p)};var C=function(l,p){return l.allocUnsafe?l.allocUnsafe(p):new l(p)};s.prototype.toArrayLike=function(l,p,m){this._strip();var y=this.byteLength(),A=m||Math.max(1,y);n(y<=A,"byte array longer than desired length"),n(A>0,"Requested array length <= 0");var E=C(l,A),w=p==="le"?"LE":"BE";return this["_toArrayLike"+w](E,y),E},s.prototype._toArrayLikeLE=function(l,p){for(var m=0,y=0,A=0,E=0;A>8&255),m>16&255),E===6?(m>24&255),y=0,E=0):(y=w>>>24,E+=2)}if(m=0&&(l[m--]=w>>8&255),m>=0&&(l[m--]=w>>16&255),E===6?(m>=0&&(l[m--]=w>>24&255),y=0,E=0):(y=w>>>24,E+=2)}if(m>=0)for(l[m--]=y;m>=0;)l[m--]=0},Math.clz32?s.prototype._countBits=function(l){return 32-Math.clz32(l)}:s.prototype._countBits=function(l){var p=l,m=0;return p>=4096&&(m+=13,p>>>=13),p>=64&&(m+=7,p>>>=7),p>=8&&(m+=4,p>>>=4),p>=2&&(m+=2,p>>>=2),m+p},s.prototype._zeroBits=function(l){if(l===0)return 26;var p=l,m=0;return(p&8191)===0&&(m+=13,p>>>=13),(p&127)===0&&(m+=7,p>>>=7),(p&15)===0&&(m+=4,p>>>=4),(p&3)===0&&(m+=2,p>>>=2),(p&1)===0&&m++,m},s.prototype.bitLength=function(){var l=this.words[this.length-1],p=this._countBits(l);return(this.length-1)*26+p};function D(v){for(var l=new Array(v.bitLength()),p=0;p>>y&1}return l}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,p=0;pl.length?this.clone().ior(l):l.clone().ior(this)},s.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},s.prototype.iuand=function(l){var p;this.length>l.length?p=l:p=this;for(var m=0;ml.length?this.clone().iand(l):l.clone().iand(this)},s.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},s.prototype.iuxor=function(l){var p,m;this.length>l.length?(p=this,m=l):(p=l,m=this);for(var y=0;yl.length?this.clone().ixor(l):l.clone().ixor(this)},s.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},s.prototype.inotn=function(l){n(typeof l=="number"&&l>=0);var p=Math.ceil(l/26)|0,m=l%26;this._expand(p),m>0&&p--;for(var y=0;y0&&(this.words[y]=~this.words[y]&67108863>>26-m),this._strip()},s.prototype.notn=function(l){return this.clone().inotn(l)},s.prototype.setn=function(l,p){n(typeof l=="number"&&l>=0);var m=l/26|0,y=l%26;return this._expand(m+1),p?this.words[m]=this.words[m]|1<l.length?(m=this,y=l):(m=l,y=this);for(var A=0,E=0;E>>26;for(;A!==0&&E>>26;if(this.length=m.length,A!==0)this.words[this.length]=A,this.length++;else if(m!==this)for(;El.length?this.clone().iadd(l):l.clone().iadd(this)},s.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var p=this.iadd(l);return l.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var m=this.cmp(l);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var y,A;m>0?(y=this,A=l):(y=l,A=this);for(var E=0,w=0;w>26,this.words[w]=p&67108863;for(;E!==0&&w>26,this.words[w]=p&67108863;if(E===0&&w>>26,se=I&67108863,O=Math.min(M,l.length-1),ie=Math.max(0,M-v.length+1);ie<=O;ie++){var ee=M-ie|0;y=v.words[ee]|0,A=l.words[ie]|0,E=y*A+se,z+=E/67108864|0,se=E&67108863}p.words[M]=se|0,I=z|0}return I!==0?p.words[M]=I|0:p.length--,p._strip()}var L=function(l,p,m){var y=l.words,A=p.words,E=m.words,w=0,I,M,z,se=y[0]|0,O=se&8191,ie=se>>>13,ee=y[1]|0,Z=ee&8191,te=ee>>>13,N=y[2]|0,Q=N&8191,ne=N>>>13,de=y[3]|0,ce=de&8191,fe=de>>>13,be=y[4]|0,Pe=be&8191,De=be>>>13,Te=y[5]|0,Fe=Te&8191,Me=Te>>>13,Ne=y[6]|0,He=Ne&8191,Oe=Ne>>>13,$e=y[7]|0,qe=$e&8191,_e=$e>>>13,Qe=y[8]|0,at=Qe&8191,Be=Qe>>>13,nt=y[9]|0,it=nt&8191,Ye=nt>>>13,pt=A[0]|0,ht=pt&8191,ft=pt>>>13,Ht=A[1]|0,Jt=Ht&8191,St=Ht>>>13,Xt=A[2]|0,tr=Xt&8191,Dt=Xt>>>13,Bt=A[3]|0,Ct=Bt&8191,gt=Bt>>>13,Ot=A[4]|0,Lt=Ot&8191,bt=Ot>>>13,jt=A[5]|0,Ut=jt&8191,tt=jt>>>13,Ft=A[6]|0,K=Ft&8191,G=Ft>>>13,J=A[7]|0,T=J&8191,j=J>>>13,oe=A[8]|0,le=oe&8191,me=oe>>>13,Ee=A[9]|0,ke=Ee&8191,Ce=Ee>>>13;m.negative=l.negative^p.negative,m.length=19,I=Math.imul(O,ht),M=Math.imul(O,ft),M=M+Math.imul(ie,ht)|0,z=Math.imul(ie,ft);var et=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(et>>>26)|0,et&=67108863,I=Math.imul(Z,ht),M=Math.imul(Z,ft),M=M+Math.imul(te,ht)|0,z=Math.imul(te,ft),I=I+Math.imul(O,Jt)|0,M=M+Math.imul(O,St)|0,M=M+Math.imul(ie,Jt)|0,z=z+Math.imul(ie,St)|0;var Ze=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(Ze>>>26)|0,Ze&=67108863,I=Math.imul(Q,ht),M=Math.imul(Q,ft),M=M+Math.imul(ne,ht)|0,z=Math.imul(ne,ft),I=I+Math.imul(Z,Jt)|0,M=M+Math.imul(Z,St)|0,M=M+Math.imul(te,Jt)|0,z=z+Math.imul(te,St)|0,I=I+Math.imul(O,tr)|0,M=M+Math.imul(O,Dt)|0,M=M+Math.imul(ie,tr)|0,z=z+Math.imul(ie,Dt)|0;var rt=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(rt>>>26)|0,rt&=67108863,I=Math.imul(ce,ht),M=Math.imul(ce,ft),M=M+Math.imul(fe,ht)|0,z=Math.imul(fe,ft),I=I+Math.imul(Q,Jt)|0,M=M+Math.imul(Q,St)|0,M=M+Math.imul(ne,Jt)|0,z=z+Math.imul(ne,St)|0,I=I+Math.imul(Z,tr)|0,M=M+Math.imul(Z,Dt)|0,M=M+Math.imul(te,tr)|0,z=z+Math.imul(te,Dt)|0,I=I+Math.imul(O,Ct)|0,M=M+Math.imul(O,gt)|0,M=M+Math.imul(ie,Ct)|0,z=z+Math.imul(ie,gt)|0;var ot=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(ot>>>26)|0,ot&=67108863,I=Math.imul(Pe,ht),M=Math.imul(Pe,ft),M=M+Math.imul(De,ht)|0,z=Math.imul(De,ft),I=I+Math.imul(ce,Jt)|0,M=M+Math.imul(ce,St)|0,M=M+Math.imul(fe,Jt)|0,z=z+Math.imul(fe,St)|0,I=I+Math.imul(Q,tr)|0,M=M+Math.imul(Q,Dt)|0,M=M+Math.imul(ne,tr)|0,z=z+Math.imul(ne,Dt)|0,I=I+Math.imul(Z,Ct)|0,M=M+Math.imul(Z,gt)|0,M=M+Math.imul(te,Ct)|0,z=z+Math.imul(te,gt)|0,I=I+Math.imul(O,Lt)|0,M=M+Math.imul(O,bt)|0,M=M+Math.imul(ie,Lt)|0,z=z+Math.imul(ie,bt)|0;var yt=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(yt>>>26)|0,yt&=67108863,I=Math.imul(Fe,ht),M=Math.imul(Fe,ft),M=M+Math.imul(Me,ht)|0,z=Math.imul(Me,ft),I=I+Math.imul(Pe,Jt)|0,M=M+Math.imul(Pe,St)|0,M=M+Math.imul(De,Jt)|0,z=z+Math.imul(De,St)|0,I=I+Math.imul(ce,tr)|0,M=M+Math.imul(ce,Dt)|0,M=M+Math.imul(fe,tr)|0,z=z+Math.imul(fe,Dt)|0,I=I+Math.imul(Q,Ct)|0,M=M+Math.imul(Q,gt)|0,M=M+Math.imul(ne,Ct)|0,z=z+Math.imul(ne,gt)|0,I=I+Math.imul(Z,Lt)|0,M=M+Math.imul(Z,bt)|0,M=M+Math.imul(te,Lt)|0,z=z+Math.imul(te,bt)|0,I=I+Math.imul(O,Ut)|0,M=M+Math.imul(O,tt)|0,M=M+Math.imul(ie,Ut)|0,z=z+Math.imul(ie,tt)|0;var Rt=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,I=Math.imul(He,ht),M=Math.imul(He,ft),M=M+Math.imul(Oe,ht)|0,z=Math.imul(Oe,ft),I=I+Math.imul(Fe,Jt)|0,M=M+Math.imul(Fe,St)|0,M=M+Math.imul(Me,Jt)|0,z=z+Math.imul(Me,St)|0,I=I+Math.imul(Pe,tr)|0,M=M+Math.imul(Pe,Dt)|0,M=M+Math.imul(De,tr)|0,z=z+Math.imul(De,Dt)|0,I=I+Math.imul(ce,Ct)|0,M=M+Math.imul(ce,gt)|0,M=M+Math.imul(fe,Ct)|0,z=z+Math.imul(fe,gt)|0,I=I+Math.imul(Q,Lt)|0,M=M+Math.imul(Q,bt)|0,M=M+Math.imul(ne,Lt)|0,z=z+Math.imul(ne,bt)|0,I=I+Math.imul(Z,Ut)|0,M=M+Math.imul(Z,tt)|0,M=M+Math.imul(te,Ut)|0,z=z+Math.imul(te,tt)|0,I=I+Math.imul(O,K)|0,M=M+Math.imul(O,G)|0,M=M+Math.imul(ie,K)|0,z=z+Math.imul(ie,G)|0;var Mt=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,I=Math.imul(qe,ht),M=Math.imul(qe,ft),M=M+Math.imul(_e,ht)|0,z=Math.imul(_e,ft),I=I+Math.imul(He,Jt)|0,M=M+Math.imul(He,St)|0,M=M+Math.imul(Oe,Jt)|0,z=z+Math.imul(Oe,St)|0,I=I+Math.imul(Fe,tr)|0,M=M+Math.imul(Fe,Dt)|0,M=M+Math.imul(Me,tr)|0,z=z+Math.imul(Me,Dt)|0,I=I+Math.imul(Pe,Ct)|0,M=M+Math.imul(Pe,gt)|0,M=M+Math.imul(De,Ct)|0,z=z+Math.imul(De,gt)|0,I=I+Math.imul(ce,Lt)|0,M=M+Math.imul(ce,bt)|0,M=M+Math.imul(fe,Lt)|0,z=z+Math.imul(fe,bt)|0,I=I+Math.imul(Q,Ut)|0,M=M+Math.imul(Q,tt)|0,M=M+Math.imul(ne,Ut)|0,z=z+Math.imul(ne,tt)|0,I=I+Math.imul(Z,K)|0,M=M+Math.imul(Z,G)|0,M=M+Math.imul(te,K)|0,z=z+Math.imul(te,G)|0,I=I+Math.imul(O,T)|0,M=M+Math.imul(O,j)|0,M=M+Math.imul(ie,T)|0,z=z+Math.imul(ie,j)|0;var xt=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(xt>>>26)|0,xt&=67108863,I=Math.imul(at,ht),M=Math.imul(at,ft),M=M+Math.imul(Be,ht)|0,z=Math.imul(Be,ft),I=I+Math.imul(qe,Jt)|0,M=M+Math.imul(qe,St)|0,M=M+Math.imul(_e,Jt)|0,z=z+Math.imul(_e,St)|0,I=I+Math.imul(He,tr)|0,M=M+Math.imul(He,Dt)|0,M=M+Math.imul(Oe,tr)|0,z=z+Math.imul(Oe,Dt)|0,I=I+Math.imul(Fe,Ct)|0,M=M+Math.imul(Fe,gt)|0,M=M+Math.imul(Me,Ct)|0,z=z+Math.imul(Me,gt)|0,I=I+Math.imul(Pe,Lt)|0,M=M+Math.imul(Pe,bt)|0,M=M+Math.imul(De,Lt)|0,z=z+Math.imul(De,bt)|0,I=I+Math.imul(ce,Ut)|0,M=M+Math.imul(ce,tt)|0,M=M+Math.imul(fe,Ut)|0,z=z+Math.imul(fe,tt)|0,I=I+Math.imul(Q,K)|0,M=M+Math.imul(Q,G)|0,M=M+Math.imul(ne,K)|0,z=z+Math.imul(ne,G)|0,I=I+Math.imul(Z,T)|0,M=M+Math.imul(Z,j)|0,M=M+Math.imul(te,T)|0,z=z+Math.imul(te,j)|0,I=I+Math.imul(O,le)|0,M=M+Math.imul(O,me)|0,M=M+Math.imul(ie,le)|0,z=z+Math.imul(ie,me)|0;var Tt=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,I=Math.imul(it,ht),M=Math.imul(it,ft),M=M+Math.imul(Ye,ht)|0,z=Math.imul(Ye,ft),I=I+Math.imul(at,Jt)|0,M=M+Math.imul(at,St)|0,M=M+Math.imul(Be,Jt)|0,z=z+Math.imul(Be,St)|0,I=I+Math.imul(qe,tr)|0,M=M+Math.imul(qe,Dt)|0,M=M+Math.imul(_e,tr)|0,z=z+Math.imul(_e,Dt)|0,I=I+Math.imul(He,Ct)|0,M=M+Math.imul(He,gt)|0,M=M+Math.imul(Oe,Ct)|0,z=z+Math.imul(Oe,gt)|0,I=I+Math.imul(Fe,Lt)|0,M=M+Math.imul(Fe,bt)|0,M=M+Math.imul(Me,Lt)|0,z=z+Math.imul(Me,bt)|0,I=I+Math.imul(Pe,Ut)|0,M=M+Math.imul(Pe,tt)|0,M=M+Math.imul(De,Ut)|0,z=z+Math.imul(De,tt)|0,I=I+Math.imul(ce,K)|0,M=M+Math.imul(ce,G)|0,M=M+Math.imul(fe,K)|0,z=z+Math.imul(fe,G)|0,I=I+Math.imul(Q,T)|0,M=M+Math.imul(Q,j)|0,M=M+Math.imul(ne,T)|0,z=z+Math.imul(ne,j)|0,I=I+Math.imul(Z,le)|0,M=M+Math.imul(Z,me)|0,M=M+Math.imul(te,le)|0,z=z+Math.imul(te,me)|0,I=I+Math.imul(O,ke)|0,M=M+Math.imul(O,Ce)|0,M=M+Math.imul(ie,ke)|0,z=z+Math.imul(ie,Ce)|0;var mt=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(mt>>>26)|0,mt&=67108863,I=Math.imul(it,Jt),M=Math.imul(it,St),M=M+Math.imul(Ye,Jt)|0,z=Math.imul(Ye,St),I=I+Math.imul(at,tr)|0,M=M+Math.imul(at,Dt)|0,M=M+Math.imul(Be,tr)|0,z=z+Math.imul(Be,Dt)|0,I=I+Math.imul(qe,Ct)|0,M=M+Math.imul(qe,gt)|0,M=M+Math.imul(_e,Ct)|0,z=z+Math.imul(_e,gt)|0,I=I+Math.imul(He,Lt)|0,M=M+Math.imul(He,bt)|0,M=M+Math.imul(Oe,Lt)|0,z=z+Math.imul(Oe,bt)|0,I=I+Math.imul(Fe,Ut)|0,M=M+Math.imul(Fe,tt)|0,M=M+Math.imul(Me,Ut)|0,z=z+Math.imul(Me,tt)|0,I=I+Math.imul(Pe,K)|0,M=M+Math.imul(Pe,G)|0,M=M+Math.imul(De,K)|0,z=z+Math.imul(De,G)|0,I=I+Math.imul(ce,T)|0,M=M+Math.imul(ce,j)|0,M=M+Math.imul(fe,T)|0,z=z+Math.imul(fe,j)|0,I=I+Math.imul(Q,le)|0,M=M+Math.imul(Q,me)|0,M=M+Math.imul(ne,le)|0,z=z+Math.imul(ne,me)|0,I=I+Math.imul(Z,ke)|0,M=M+Math.imul(Z,Ce)|0,M=M+Math.imul(te,ke)|0,z=z+Math.imul(te,Ce)|0;var Et=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(Et>>>26)|0,Et&=67108863,I=Math.imul(it,tr),M=Math.imul(it,Dt),M=M+Math.imul(Ye,tr)|0,z=Math.imul(Ye,Dt),I=I+Math.imul(at,Ct)|0,M=M+Math.imul(at,gt)|0,M=M+Math.imul(Be,Ct)|0,z=z+Math.imul(Be,gt)|0,I=I+Math.imul(qe,Lt)|0,M=M+Math.imul(qe,bt)|0,M=M+Math.imul(_e,Lt)|0,z=z+Math.imul(_e,bt)|0,I=I+Math.imul(He,Ut)|0,M=M+Math.imul(He,tt)|0,M=M+Math.imul(Oe,Ut)|0,z=z+Math.imul(Oe,tt)|0,I=I+Math.imul(Fe,K)|0,M=M+Math.imul(Fe,G)|0,M=M+Math.imul(Me,K)|0,z=z+Math.imul(Me,G)|0,I=I+Math.imul(Pe,T)|0,M=M+Math.imul(Pe,j)|0,M=M+Math.imul(De,T)|0,z=z+Math.imul(De,j)|0,I=I+Math.imul(ce,le)|0,M=M+Math.imul(ce,me)|0,M=M+Math.imul(fe,le)|0,z=z+Math.imul(fe,me)|0,I=I+Math.imul(Q,ke)|0,M=M+Math.imul(Q,Ce)|0,M=M+Math.imul(ne,ke)|0,z=z+Math.imul(ne,Ce)|0;var ct=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(ct>>>26)|0,ct&=67108863,I=Math.imul(it,Ct),M=Math.imul(it,gt),M=M+Math.imul(Ye,Ct)|0,z=Math.imul(Ye,gt),I=I+Math.imul(at,Lt)|0,M=M+Math.imul(at,bt)|0,M=M+Math.imul(Be,Lt)|0,z=z+Math.imul(Be,bt)|0,I=I+Math.imul(qe,Ut)|0,M=M+Math.imul(qe,tt)|0,M=M+Math.imul(_e,Ut)|0,z=z+Math.imul(_e,tt)|0,I=I+Math.imul(He,K)|0,M=M+Math.imul(He,G)|0,M=M+Math.imul(Oe,K)|0,z=z+Math.imul(Oe,G)|0,I=I+Math.imul(Fe,T)|0,M=M+Math.imul(Fe,j)|0,M=M+Math.imul(Me,T)|0,z=z+Math.imul(Me,j)|0,I=I+Math.imul(Pe,le)|0,M=M+Math.imul(Pe,me)|0,M=M+Math.imul(De,le)|0,z=z+Math.imul(De,me)|0,I=I+Math.imul(ce,ke)|0,M=M+Math.imul(ce,Ce)|0,M=M+Math.imul(fe,ke)|0,z=z+Math.imul(fe,Ce)|0;var wt=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(wt>>>26)|0,wt&=67108863,I=Math.imul(it,Lt),M=Math.imul(it,bt),M=M+Math.imul(Ye,Lt)|0,z=Math.imul(Ye,bt),I=I+Math.imul(at,Ut)|0,M=M+Math.imul(at,tt)|0,M=M+Math.imul(Be,Ut)|0,z=z+Math.imul(Be,tt)|0,I=I+Math.imul(qe,K)|0,M=M+Math.imul(qe,G)|0,M=M+Math.imul(_e,K)|0,z=z+Math.imul(_e,G)|0,I=I+Math.imul(He,T)|0,M=M+Math.imul(He,j)|0,M=M+Math.imul(Oe,T)|0,z=z+Math.imul(Oe,j)|0,I=I+Math.imul(Fe,le)|0,M=M+Math.imul(Fe,me)|0,M=M+Math.imul(Me,le)|0,z=z+Math.imul(Me,me)|0,I=I+Math.imul(Pe,ke)|0,M=M+Math.imul(Pe,Ce)|0,M=M+Math.imul(De,ke)|0,z=z+Math.imul(De,Ce)|0;var lt=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(lt>>>26)|0,lt&=67108863,I=Math.imul(it,Ut),M=Math.imul(it,tt),M=M+Math.imul(Ye,Ut)|0,z=Math.imul(Ye,tt),I=I+Math.imul(at,K)|0,M=M+Math.imul(at,G)|0,M=M+Math.imul(Be,K)|0,z=z+Math.imul(Be,G)|0,I=I+Math.imul(qe,T)|0,M=M+Math.imul(qe,j)|0,M=M+Math.imul(_e,T)|0,z=z+Math.imul(_e,j)|0,I=I+Math.imul(He,le)|0,M=M+Math.imul(He,me)|0,M=M+Math.imul(Oe,le)|0,z=z+Math.imul(Oe,me)|0,I=I+Math.imul(Fe,ke)|0,M=M+Math.imul(Fe,Ce)|0,M=M+Math.imul(Me,ke)|0,z=z+Math.imul(Me,Ce)|0;var st=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(st>>>26)|0,st&=67108863,I=Math.imul(it,K),M=Math.imul(it,G),M=M+Math.imul(Ye,K)|0,z=Math.imul(Ye,G),I=I+Math.imul(at,T)|0,M=M+Math.imul(at,j)|0,M=M+Math.imul(Be,T)|0,z=z+Math.imul(Be,j)|0,I=I+Math.imul(qe,le)|0,M=M+Math.imul(qe,me)|0,M=M+Math.imul(_e,le)|0,z=z+Math.imul(_e,me)|0,I=I+Math.imul(He,ke)|0,M=M+Math.imul(He,Ce)|0,M=M+Math.imul(Oe,ke)|0,z=z+Math.imul(Oe,Ce)|0;var Ae=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,I=Math.imul(it,T),M=Math.imul(it,j),M=M+Math.imul(Ye,T)|0,z=Math.imul(Ye,j),I=I+Math.imul(at,le)|0,M=M+Math.imul(at,me)|0,M=M+Math.imul(Be,le)|0,z=z+Math.imul(Be,me)|0,I=I+Math.imul(qe,ke)|0,M=M+Math.imul(qe,Ce)|0,M=M+Math.imul(_e,ke)|0,z=z+Math.imul(_e,Ce)|0;var Ie=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,I=Math.imul(it,le),M=Math.imul(it,me),M=M+Math.imul(Ye,le)|0,z=Math.imul(Ye,me),I=I+Math.imul(at,ke)|0,M=M+Math.imul(at,Ce)|0,M=M+Math.imul(Be,ke)|0,z=z+Math.imul(Be,Ce)|0;var Ve=(w+I|0)+((M&8191)<<13)|0;w=(z+(M>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,I=Math.imul(it,ke),M=Math.imul(it,Ce),M=M+Math.imul(Ye,ke)|0,z=Math.imul(Ye,Ce);var Ue=(w+I|0)+((M&8191)<<13)|0;return w=(z+(M>>>13)|0)+(Ue>>>26)|0,Ue&=67108863,E[0]=et,E[1]=Ze,E[2]=rt,E[3]=ot,E[4]=yt,E[5]=Rt,E[6]=Mt,E[7]=xt,E[8]=Tt,E[9]=mt,E[10]=Et,E[11]=ct,E[12]=wt,E[13]=lt,E[14]=st,E[15]=Ae,E[16]=Ie,E[17]=Ve,E[18]=Ue,w!==0&&(E[19]=w,m.length++),m};Math.imul||(L=B);function H(v,l,p){p.negative=l.negative^v.negative,p.length=v.length+l.length;for(var m=0,y=0,A=0;A>>26)|0,y+=E>>>26,E&=67108863}p.words[A]=w,m=E,E=y}return m!==0?p.words[A]=m:p.length--,p._strip()}function F(v,l,p){return H(v,l,p)}s.prototype.mulTo=function(l,p){var m,y=this.length+l.length;return this.length===10&&l.length===10?m=L(this,l,p):y<63?m=B(this,l,p):y<1024?m=H(this,l,p):m=F(this,l,p),m},s.prototype.mul=function(l){var p=new s(null);return p.words=new Array(this.length+l.length),this.mulTo(l,p)},s.prototype.mulf=function(l){var p=new s(null);return p.words=new Array(this.length+l.length),F(this,l,p)},s.prototype.imul=function(l){return this.clone().mulTo(l,this)},s.prototype.imuln=function(l){var p=l<0;p&&(l=-l),n(typeof l=="number"),n(l<67108864);for(var m=0,y=0;y>=26,m+=A/67108864|0,m+=E>>>26,this.words[y]=E&67108863}return m!==0&&(this.words[y]=m,this.length++),p?this.ineg():this},s.prototype.muln=function(l){return this.clone().imuln(l)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(l){var p=D(l);if(p.length===0)return new s(1);for(var m=this,y=0;y=0);var p=l%26,m=(l-p)/26,y=67108863>>>26-p<<26-p,A;if(p!==0){var E=0;for(A=0;A>>26-p}E&&(this.words[A]=E,this.length++)}if(m!==0){for(A=this.length-1;A>=0;A--)this.words[A+m]=this.words[A];for(A=0;A=0);var y;p?y=(p-p%26)/26:y=0;var A=l%26,E=Math.min((l-A)/26,this.length),w=67108863^67108863>>>A<E)for(this.length-=E,M=0;M=0&&(z!==0||M>=y);M--){var se=this.words[M]|0;this.words[M]=z<<26-A|se>>>A,z=se&w}return I&&z!==0&&(I.words[I.length++]=z),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(l,p,m){return n(this.negative===0),this.iushrn(l,p,m)},s.prototype.shln=function(l){return this.clone().ishln(l)},s.prototype.ushln=function(l){return this.clone().iushln(l)},s.prototype.shrn=function(l){return this.clone().ishrn(l)},s.prototype.ushrn=function(l){return this.clone().iushrn(l)},s.prototype.testn=function(l){n(typeof l=="number"&&l>=0);var p=l%26,m=(l-p)/26,y=1<=0);var p=l%26,m=(l-p)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(p!==0&&m++,this.length=Math.min(m,this.length),p!==0){var y=67108863^67108863>>>p<=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},s.prototype.isubn=function(l){if(n(typeof l=="number"),n(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 p=0;p>26)-(I/67108864|0),this.words[A+m]=E&67108863}for(;A>26,this.words[A+m]=E&67108863;if(w===0)return this._strip();for(n(w===-1),w=0,A=0;A>26,this.words[A]=E&67108863;return this.negative=1,this._strip()},s.prototype._wordDiv=function(l,p){var m=this.length-l.length,y=this.clone(),A=l,E=A.words[A.length-1]|0,w=this._countBits(E);m=26-w,m!==0&&(A=A.ushln(m),y.iushln(m),E=A.words[A.length-1]|0);var I=y.length-A.length,M;if(p!=="mod"){M=new s(null),M.length=I+1,M.words=new Array(M.length);for(var z=0;z=0;O--){var ie=(y.words[A.length+O]|0)*67108864+(y.words[A.length+O-1]|0);for(ie=Math.min(ie/E|0,67108863),y._ishlnsubmul(A,ie,O);y.negative!==0;)ie--,y.negative=0,y._ishlnsubmul(A,1,O),y.isZero()||(y.negative^=1);M&&(M.words[O]=ie)}return M&&M._strip(),y._strip(),p!=="div"&&m!==0&&y.iushrn(m),{div:M||null,mod:y}},s.prototype.divmod=function(l,p,m){if(n(!l.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var y,A,E;return this.negative!==0&&l.negative===0?(E=this.neg().divmod(l,p),p!=="mod"&&(y=E.div.neg()),p!=="div"&&(A=E.mod.neg(),m&&A.negative!==0&&A.iadd(l)),{div:y,mod:A}):this.negative===0&&l.negative!==0?(E=this.divmod(l.neg(),p),p!=="mod"&&(y=E.div.neg()),{div:y,mod:E.mod}):(this.negative&l.negative)!==0?(E=this.neg().divmod(l.neg(),p),p!=="div"&&(A=E.mod.neg(),m&&A.negative!==0&&A.isub(l)),{div:E.div,mod:A}):l.length>this.length||this.cmp(l)<0?{div:new s(0),mod:this}:l.length===1?p==="div"?{div:this.divn(l.words[0]),mod:null}:p==="mod"?{div:null,mod:new s(this.modrn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new s(this.modrn(l.words[0]))}:this._wordDiv(l,p)},s.prototype.div=function(l){return this.divmod(l,"div",!1).div},s.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},s.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},s.prototype.divRound=function(l){var p=this.divmod(l);if(p.mod.isZero())return p.div;var m=p.div.negative!==0?p.mod.isub(l):p.mod,y=l.ushrn(1),A=l.andln(1),E=m.cmp(y);return E<0||A===1&&E===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},s.prototype.modrn=function(l){var p=l<0;p&&(l=-l),n(l<=67108863);for(var m=(1<<26)%l,y=0,A=this.length-1;A>=0;A--)y=(m*y+(this.words[A]|0))%l;return p?-y:y},s.prototype.modn=function(l){return this.modrn(l)},s.prototype.idivn=function(l){var p=l<0;p&&(l=-l),n(l<=67108863);for(var m=0,y=this.length-1;y>=0;y--){var A=(this.words[y]|0)+m*67108864;this.words[y]=A/l|0,m=A%l}return this._strip(),p?this.ineg():this},s.prototype.divn=function(l){return this.clone().idivn(l)},s.prototype.egcd=function(l){n(l.negative===0),n(!l.isZero());var p=this,m=l.clone();p.negative!==0?p=p.umod(l):p=p.clone();for(var y=new s(1),A=new s(0),E=new s(0),w=new s(1),I=0;p.isEven()&&m.isEven();)p.iushrn(1),m.iushrn(1),++I;for(var M=m.clone(),z=p.clone();!p.isZero();){for(var se=0,O=1;(p.words[0]&O)===0&&se<26;++se,O<<=1);if(se>0)for(p.iushrn(se);se-- >0;)(y.isOdd()||A.isOdd())&&(y.iadd(M),A.isub(z)),y.iushrn(1),A.iushrn(1);for(var ie=0,ee=1;(m.words[0]&ee)===0&&ie<26;++ie,ee<<=1);if(ie>0)for(m.iushrn(ie);ie-- >0;)(E.isOdd()||w.isOdd())&&(E.iadd(M),w.isub(z)),E.iushrn(1),w.iushrn(1);p.cmp(m)>=0?(p.isub(m),y.isub(E),A.isub(w)):(m.isub(p),E.isub(y),w.isub(A))}return{a:E,b:w,gcd:m.iushln(I)}},s.prototype._invmp=function(l){n(l.negative===0),n(!l.isZero());var p=this,m=l.clone();p.negative!==0?p=p.umod(l):p=p.clone();for(var y=new s(1),A=new s(0),E=m.clone();p.cmpn(1)>0&&m.cmpn(1)>0;){for(var w=0,I=1;(p.words[0]&I)===0&&w<26;++w,I<<=1);if(w>0)for(p.iushrn(w);w-- >0;)y.isOdd()&&y.iadd(E),y.iushrn(1);for(var M=0,z=1;(m.words[0]&z)===0&&M<26;++M,z<<=1);if(M>0)for(m.iushrn(M);M-- >0;)A.isOdd()&&A.iadd(E),A.iushrn(1);p.cmp(m)>=0?(p.isub(m),y.isub(A)):(m.isub(p),A.isub(y))}var se;return p.cmpn(1)===0?se=y:se=A,se.cmpn(0)<0&&se.iadd(l),se},s.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var p=this.clone(),m=l.clone();p.negative=0,m.negative=0;for(var y=0;p.isEven()&&m.isEven();y++)p.iushrn(1),m.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;m.isEven();)m.iushrn(1);var A=p.cmp(m);if(A<0){var E=p;p=m,m=E}else if(A===0||m.cmpn(1)===0)break;p.isub(m)}while(!0);return m.iushln(y)},s.prototype.invm=function(l){return this.egcd(l).a.umod(l)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(l){return this.words[0]&l},s.prototype.bincn=function(l){n(typeof l=="number");var p=l%26,m=(l-p)/26,y=1<>>26,w&=67108863,this.words[E]=w}return A!==0&&(this.words[E]=A,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(l){var p=l<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var m;if(this.length>1)m=1;else{p&&(l=-l),n(l<=67108863,"Number is too big");var y=this.words[0]|0;m=y===l?0:yl.length)return 1;if(this.length=0;m--){var y=this.words[m]|0,A=l.words[m]|0;if(y!==A){yA&&(p=1);break}}return p},s.prototype.gtn=function(l){return this.cmpn(l)===1},s.prototype.gt=function(l){return this.cmp(l)===1},s.prototype.gten=function(l){return this.cmpn(l)>=0},s.prototype.gte=function(l){return this.cmp(l)>=0},s.prototype.ltn=function(l){return this.cmpn(l)===-1},s.prototype.lt=function(l){return this.cmp(l)===-1},s.prototype.lten=function(l){return this.cmpn(l)<=0},s.prototype.lte=function(l){return this.cmp(l)<=0},s.prototype.eqn=function(l){return this.cmpn(l)===0},s.prototype.eq=function(l){return this.cmp(l)===0},s.red=function(l){return new q(l)},s.prototype.toRed=function(l){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(l){return this.red=l,this},s.prototype.forceRed=function(l){return n(!this.red,"Already a number in reduction context"),this._forceRed(l)},s.prototype.redAdd=function(l){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},s.prototype.redIAdd=function(l){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},s.prototype.redSub=function(l){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},s.prototype.redISub=function(l){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},s.prototype.redShl=function(l){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},s.prototype.redMul=function(l){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},s.prototype.redIMul=function(l){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(l){return n(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var k={k256:null,p224:null,p192:null,p25519:null};function $(v,l){this.name=v,this.p=new s(l,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}$.prototype._tmp=function(){var l=new s(null);return l.words=new Array(Math.ceil(this.n/13)),l},$.prototype.ireduce=function(l){var p=l,m;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),m=p.bitLength();while(m>this.n);var y=m0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},$.prototype.split=function(l,p){l.iushrn(this.n,0,p)},$.prototype.imulK=function(l){return l.imul(this.k)};function R(){$.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(R,$),R.prototype.split=function(l,p){for(var m=4194303,y=Math.min(l.length,9),A=0;A>>22,E=w}E>>>=22,l.words[A-10]=E,E===0&&l.length>10?l.length-=10:l.length-=9},R.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var p=0,m=0;m>>=26,l.words[m]=A,p=y}return p!==0&&(l.words[l.length++]=p),l},s._prime=function(l){if(k[l])return k[l];var p;if(l==="k256")p=new R;else if(l==="p224")p=new W;else if(l==="p192")p=new V;else if(l==="p25519")p=new X;else throw new Error("Unknown prime "+l);return k[l]=p,p};function q(v){if(typeof v=="string"){var l=s._prime(v);this.m=l.p,this.prime=l}else n(v.gtn(1),"modulus must be greater than 1"),this.m=v,this.prime=null}q.prototype._verify1=function(l){n(l.negative===0,"red works only with positives"),n(l.red,"red works only with red numbers")},q.prototype._verify2=function(l,p){n((l.negative|p.negative)===0,"red works only with positives"),n(l.red&&l.red===p.red,"red works only with red numbers")},q.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):(h(l,l.umod(this.m)._forceRed(this)),l)},q.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},q.prototype.add=function(l,p){this._verify2(l,p);var m=l.add(p);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},q.prototype.iadd=function(l,p){this._verify2(l,p);var m=l.iadd(p);return m.cmp(this.m)>=0&&m.isub(this.m),m},q.prototype.sub=function(l,p){this._verify2(l,p);var m=l.sub(p);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},q.prototype.isub=function(l,p){this._verify2(l,p);var m=l.isub(p);return m.cmpn(0)<0&&m.iadd(this.m),m},q.prototype.shl=function(l,p){return this._verify1(l),this.imod(l.ushln(p))},q.prototype.imul=function(l,p){return this._verify2(l,p),this.imod(l.imul(p))},q.prototype.mul=function(l,p){return this._verify2(l,p),this.imod(l.mul(p))},q.prototype.isqr=function(l){return this.imul(l,l.clone())},q.prototype.sqr=function(l){return this.mul(l,l)},q.prototype.sqrt=function(l){if(l.isZero())return l.clone();var p=this.m.andln(3);if(n(p%2===1),p===3){var m=this.m.add(new s(1)).iushrn(2);return this.pow(l,m)}for(var y=this.m.subn(1),A=0;!y.isZero()&&y.andln(1)===0;)A++,y.iushrn(1);n(!y.isZero());var E=new s(1).toRed(this),w=E.redNeg(),I=this.m.subn(1).iushrn(1),M=this.m.bitLength();for(M=new s(2*M*M).toRed(this);this.pow(M,I).cmp(w)!==0;)M.redIAdd(w);for(var z=this.pow(M,y),se=this.pow(l,y.addn(1).iushrn(1)),O=this.pow(l,y),ie=A;O.cmp(E)!==0;){for(var ee=O,Z=0;ee.cmp(E)!==0;Z++)ee=ee.redSqr();n(Z=0;A--){for(var z=p.words[A],se=M-1;se>=0;se--){var O=z>>se&1;if(E!==y[0]&&(E=this.sqr(E)),O===0&&w===0){I=0;continue}w<<=1,w|=O,I++,!(I!==m&&(A!==0||se!==0))&&(E=this.mul(E,y[w]),I=0,w=0)}M=26}return E},q.prototype.convertTo=function(l){var p=l.umod(this.m);return p===l?p.clone():p},q.prototype.convertFrom=function(l){var p=l.clone();return p.red=null,p},s.mont=function(l){return new _(l)};function _(v){q.call(this,v),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(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(_,q),_.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},_.prototype.convertFrom=function(l){var p=this.imod(l.mul(this.rinv));return p.red=null,p},_.prototype.imul=function(l,p){if(l.isZero()||p.isZero())return l.words[0]=0,l.length=1,l;var m=l.imul(p),y=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=m.isub(y).iushrn(this.shift),E=A;return A.cmp(this.m)>=0?E=A.isub(this.m):A.cmpn(0)<0&&(E=A.iadd(this.m)),E._forceRed(this)},_.prototype.mul=function(l,p){if(l.isZero()||p.isZero())return new s(0)._forceRed(this);var m=l.mul(p),y=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),A=m.isub(y).iushrn(this.shift),E=A;return A.cmp(this.m)>=0?E=A.isub(this.m):A.cmpn(0)<0&&(E=A.iadd(this.m)),E._forceRed(this)},_.prototype.invm=function(l){var p=this.imod(l._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,oO)})(xh)),xh.exports}var cO=aO();const nr=Mi(cO);var uO=nr.BN;function fO(t){return new uO(t,36).toString(16)}const lO="strings/5.7.0",hO=new Kr(lO);var _h;(function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"})(_h||(_h={}));var dx;(function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"})(dx||(dx={}));function xg(t,e=_h.current){e!=_h.current&&(hO.checkNormalize(),t=t.normalize(e));let r=[];for(let n=0;n>6|192),r.push(i&63|128);else if((i&64512)==55296){n++;const s=t.charCodeAt(n);if(n>=t.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");const o=65536+((i&1023)<<10)+(s&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(i>>12|224),r.push(i>>6&63|128),r.push(i&63|128)}return mn(r)}const dO=`Ethereum Signed Message: +`;function px(t){return typeof t=="string"&&(t=xg(t)),wg(nO([xg(dO),xg(String(t.length)),t]))}const pO="address/5.7.0",sf=new Kr(pO);function gx(t){xs(t,20)||sf.throwArgumentError("invalid address","address",t),t=t.toLowerCase();const e=t.substring(2).split(""),r=new Uint8Array(40);for(let i=0;i<40;i++)r[i]=e[i].charCodeAt(0);const n=mn(wg(r));for(let i=0;i<40;i+=2)n[i>>1]>>4>=8&&(e[i]=e[i].toUpperCase()),(n[i>>1]&15)>=8&&(e[i+1]=e[i+1].toUpperCase());return"0x"+e.join("")}const gO=9007199254740991;function mO(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}const _g={};for(let t=0;t<10;t++)_g[String(t)]=String(t);for(let t=0;t<26;t++)_g[String.fromCharCode(65+t)]=String(10+t);const mx=Math.floor(mO(gO));function vO(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(n=>_g[n]).join("");for(;e.length>=mx;){let n=e.substring(0,mx);e=parseInt(n,10)%97+e.substring(n.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function bO(t){let e=null;if(typeof t!="string"&&sf.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=gx(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&sf.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==vO(t)&&sf.throwArgumentError("bad icap checksum","address",t),e=fO(t.substring(4));e.length<40;)e="0"+e;e=gx("0x"+e)}else sf.throwArgumentError("invalid address","address",t);return e}function of(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}var Eg={},Tr={},Sg,vx;function ba(){if(vx)return Sg;vx=1,Sg=t;function t(e,r){if(!e)throw new Error(r||"Assertion failed")}return t.equal=function(r,n,i){if(r!=n)throw new Error(i||"Assertion failed: "+r+" != "+n)},Sg}var Eh={exports:{}},bx;function Sh(){return bx||(bx=1,typeof Object.create=="function"?Eh.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Eh.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}),Eh.exports}var yx;function _s(){if(yx)return Tr;yx=1;var t=ba(),e=Sh();Tr.inherits=e;function r(_,v){return(_.charCodeAt(v)&64512)!==55296||v<0||v+1>=_.length?!1:(_.charCodeAt(v+1)&64512)===56320}function n(_,v){if(Array.isArray(_))return _.slice();if(!_)return[];var l=[];if(typeof _=="string")if(v){if(v==="hex")for(_=_.replace(/[^a-z0-9]+/ig,""),_.length%2!==0&&(_="0"+_),m=0;m<_.length;m+=2)l.push(parseInt(_[m]+_[m+1],16))}else for(var p=0,m=0;m<_.length;m++){var y=_.charCodeAt(m);y<128?l[p++]=y:y<2048?(l[p++]=y>>6|192,l[p++]=y&63|128):r(_,m)?(y=65536+((y&1023)<<10)+(_.charCodeAt(++m)&1023),l[p++]=y>>18|240,l[p++]=y>>12&63|128,l[p++]=y>>6&63|128,l[p++]=y&63|128):(l[p++]=y>>12|224,l[p++]=y>>6&63|128,l[p++]=y&63|128)}else for(m=0;m<_.length;m++)l[m]=_[m]|0;return l}Tr.toArray=n;function i(_){for(var v="",l=0;l<_.length;l++)v+=a(_[l].toString(16));return v}Tr.toHex=i;function s(_){var v=_>>>24|_>>>8&65280|_<<8&16711680|(_&255)<<24;return v>>>0}Tr.htonl=s;function o(_,v){for(var l="",p=0;p<_.length;p++){var m=_[p];v==="little"&&(m=s(m)),l+=f(m.toString(16))}return l}Tr.toHex32=o;function a(_){return _.length===1?"0"+_:_}Tr.zero2=a;function f(_){return _.length===7?"0"+_:_.length===6?"00"+_:_.length===5?"000"+_:_.length===4?"0000"+_:_.length===3?"00000"+_:_.length===2?"000000"+_:_.length===1?"0000000"+_:_}Tr.zero8=f;function u(_,v,l,p){var m=l-v;t(m%4===0);for(var y=new Array(m/4),A=0,E=v;A>>0}return y}Tr.join32=u;function h(_,v){for(var l=new Array(_.length*4),p=0,m=0;p<_.length;p++,m+=4){var y=_[p];v==="big"?(l[m]=y>>>24,l[m+1]=y>>>16&255,l[m+2]=y>>>8&255,l[m+3]=y&255):(l[m+3]=y>>>24,l[m+2]=y>>>16&255,l[m+1]=y>>>8&255,l[m]=y&255)}return l}Tr.split32=h;function g(_,v){return _>>>v|_<<32-v}Tr.rotr32=g;function b(_,v){return _<>>32-v}Tr.rotl32=b;function x(_,v){return _+v>>>0}Tr.sum32=x;function S(_,v,l){return _+v+l>>>0}Tr.sum32_3=S;function C(_,v,l,p){return _+v+l+p>>>0}Tr.sum32_4=C;function D(_,v,l,p,m){return _+v+l+p+m>>>0}Tr.sum32_5=D;function B(_,v,l,p){var m=_[v],y=_[v+1],A=p+y>>>0,E=(A>>0,_[v+1]=A}Tr.sum64=B;function L(_,v,l,p){var m=v+p>>>0,y=(m>>0}Tr.sum64_hi=L;function H(_,v,l,p){var m=v+p;return m>>>0}Tr.sum64_lo=H;function F(_,v,l,p,m,y,A,E){var w=0,I=v;I=I+p>>>0,w+=I>>0,w+=I>>0,w+=I>>0}Tr.sum64_4_hi=F;function k(_,v,l,p,m,y,A,E){var w=v+p+y+E;return w>>>0}Tr.sum64_4_lo=k;function $(_,v,l,p,m,y,A,E,w,I){var M=0,z=v;z=z+p>>>0,M+=z>>0,M+=z>>0,M+=z>>0,M+=z>>0}Tr.sum64_5_hi=$;function R(_,v,l,p,m,y,A,E,w,I){var M=v+p+y+E+I;return M>>>0}Tr.sum64_5_lo=R;function W(_,v,l){var p=v<<32-l|_>>>l;return p>>>0}Tr.rotr64_hi=W;function V(_,v,l){var p=_<<32-l|v>>>l;return p>>>0}Tr.rotr64_lo=V;function X(_,v,l){return _>>>l}Tr.shr64_hi=X;function q(_,v,l){var p=_<<32-l|v>>>l;return p>>>0}return Tr.shr64_lo=q,Tr}var Ag={},wx;function af(){if(wx)return Ag;wx=1;var t=_s(),e=ba();function r(){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}return Ag.BlockHash=r,r.prototype.update=function(i,s){if(i=t.toArray(i,s),this.pending?this.pending=this.pending.concat(i):this.pending=i,this.pendingTotal+=i.length,this.pending.length>=this._delta8){i=this.pending;var o=i.length%this._delta8;this.pending=i.slice(i.length-o,i.length),this.pending.length===0&&(this.pending=null),i=t.join32(i,0,i.length-o,this.endian);for(var a=0;a>>24&255,a[f++]=i>>>16&255,a[f++]=i>>>8&255,a[f++]=i&255}else for(a[f++]=i&255,a[f++]=i>>>8&255,a[f++]=i>>>16&255,a[f++]=i>>>24&255,a[f++]=0,a[f++]=0,a[f++]=0,a[f++]=0,u=8;u>>3}Es.g0_256=f;function u(h){return e(h,17)^e(h,19)^h>>>10}return Es.g1_256=u,Es}var Pg,Ex;function yO(){if(Ex)return Pg;Ex=1;var t=_s(),e=af(),r=_x(),n=t.rotl32,i=t.sum32,s=t.sum32_5,o=r.ft_1,a=e.BlockHash,f=[1518500249,1859775393,2400959708,3395469782];function u(){if(!(this instanceof u))return new u;a.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}return t.inherits(u,a),Pg=u,u.blockSize=512,u.outSize=160,u.hmacStrength=80,u.padLength=64,u.prototype._update=function(g,b){for(var x=this.W,S=0;S<16;S++)x[S]=g[b+S];for(;Sthis.blockSize&&(i=new this.Hash().update(i).digest()),e(i.length<=this.blockSize);for(var s=i.length;s>8,b=h&255;g?f.push(g,b):f.push(b)}return f}r.toArray=n;function i(o){return o.length===1?"0"+o:o}r.zero2=i;function s(o){for(var a="",f=0;f(b>>1)-1?C=(b>>1)-D:C=D,x.isubn(C)):C=0,g[S]=C,x.iushrn(1)}return g}r.getNAF=n;function i(f,u){var h=[[],[]];f=f.clone(),u=u.clone();for(var g=0,b=0,x;f.cmpn(-g)>0||u.cmpn(-b)>0;){var S=f.andln(3)+g&3,C=u.andln(3)+b&3;S===3&&(S=-1),C===3&&(C=-1);var D;(S&1)===0?D=0:(x=f.andln(7)+g&7,(x===3||x===5)&&C===2?D=-S:D=S),h[0].push(D);var B;(C&1)===0?B=0:(x=u.andln(7)+b&7,(x===3||x===5)&&S===2?B=-C:B=C),h[1].push(B),2*g===D+1&&(g=1-g),2*b===B+1&&(b=1-b),f.iushrn(1),u.iushrn(1)}return h}r.getJSF=i;function s(f,u,h){var g="_"+u;f.prototype[u]=function(){return this[g]!==void 0?this[g]:this[g]=h.call(this)}}r.cachedProperty=s;function o(f){return typeof f=="string"?r.toArray(f,"hex"):f}r.parseBytes=o;function a(f){return new nr(f,"hex","le")}r.intFromLE=a}),Ph=vi.getNAF,IO=vi.getJSF,Ih=vi.assert;function Mo(t,e){this.type=t,this.p=new nr(e.p,16),this.red=e.prime?nr.red(e.prime):nr.mont(this.p),this.zero=new nr(0).toRed(this.red),this.one=new nr(1).toRed(this.red),this.two=new nr(2).toRed(this.red),this.n=e.n&&new nr(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 r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var wa=Mo;Mo.prototype.point=function(){throw new Error("Not implemented")},Mo.prototype.validate=function(){throw new Error("Not implemented")},Mo.prototype._fixedNafMul=function(e,r){Ih(e.precomputed);var n=e._getDoubles(),i=Ph(r,1,this._bitLength),s=(1<=a;u--)f=(f<<1)+i[u];o.push(f)}for(var h=this.jpoint(null,null,null),g=this.jpoint(null,null,null),b=s;b>0;b--){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 h=o[f];Ih(h!==0),e.type==="affine"?h>0?a=a.mixedAdd(s[h-1>>1]):a=a.mixedAdd(s[-h-1>>1].neg()):h>0?a=a.add(s[h-1>>1]):a=a.add(s[-h-1>>1].neg())}return e.type==="affine"?a.toP():a},Mo.prototype._wnafMulAdd=function(e,r,n,i,s){var o=this._wnafT1,a=this._wnafT2,f=this._wnafT3,u=0,h,g,b;for(h=0;h=1;h-=2){var S=h-1,C=h;if(o[S]!==1||o[C]!==1){f[S]=Ph(n[S],o[S],this._bitLength),f[C]=Ph(n[C],o[C],this._bitLength),u=Math.max(f[S].length,u),u=Math.max(f[C].length,u);continue}var D=[r[S],null,null,r[C]];r[S].y.cmp(r[C].y)===0?(D[1]=r[S].add(r[C]),D[2]=r[S].toJ().mixedAdd(r[C].neg())):r[S].y.cmp(r[C].y.redNeg())===0?(D[1]=r[S].toJ().mixedAdd(r[C]),D[2]=r[S].add(r[C].neg())):(D[1]=r[S].toJ().mixedAdd(r[C]),D[2]=r[S].toJ().mixedAdd(r[C].neg()));var B=[-3,-1,-5,-7,0,7,5,1,3],L=IO(n[S],n[C]);for(u=Math.max(L[0].length,u),f[S]=new Array(u),f[C]=new Array(u),g=0;g=0;h--){for(var R=0;h>=0;){var W=!0;for(g=0;g=0&&R++,k=k.dblp(R),h<0)break;for(g=0;g0?b=a[g][V-1>>1]:V<0&&(b=a[g][-V-1>>1].neg()),b.type==="affine"?k=k.mixedAdd(b):k=k.add(b))}}for(h=0;h=Math.ceil((e.bitLength()+1)/r.step):!1},Oi.prototype._getDoubles=function(e,r){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],i=this,s=0;s=0&&(x=u,S=h),g.negative&&(g=g.neg(),b=b.neg()),x.negative&&(x=x.neg(),S=S.neg()),[{a:g,b},{a:x,b:S}]},Ni.prototype._endoSplit=function(e){var r=this.endo.basis,n=r[0],i=r[1],s=i.b.mul(e).divRound(this.n),o=n.b.neg().mul(e).divRound(this.n),a=s.mul(n.a),f=o.mul(i.a),u=s.mul(n.b),h=o.mul(i.b),g=e.sub(a).sub(f),b=u.add(h).neg();return{k1:g,k2:b}},Ni.prototype.pointFromX=function(e,r){e=new nr(e,16),e.red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=n.redSqrt();if(i.redSqr().redSub(n).cmp(this.zero)!==0)throw new Error("invalid point");var s=i.fromRed().isOdd();return(r&&!s||!r&&s)&&(i=i.redNeg()),this.point(e,i)},Ni.prototype.validate=function(e){if(e.inf)return!0;var r=e.x,n=e.y,i=this.a.redMul(r),s=r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b);return n.redSqr().redISub(s).cmpn(0)===0},Ni.prototype._endoWnafMulAdd=function(e,r,n){for(var i=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""},In.prototype.isInfinity=function(){return this.inf},In.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 r=this.y.redSub(e.y);r.cmpn(0)!==0&&(r=r.redMul(this.x.redSub(e.x).redInvm()));var n=r.redSqr().redISub(this.x).redISub(e.x),i=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,i)},In.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 r=this.curve.a,n=this.x.redSqr(),i=e.redInvm(),s=n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i),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)},In.prototype.getX=function(){return this.x.fromRed()},In.prototype.getY=function(){return this.y.fromRed()},In.prototype.mul=function(e){return e=new nr(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)},In.prototype.mulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s):this.curve._wnafMulAdd(1,i,s,2)},In.prototype.jmulAdd=function(e,r,n){var i=[this,r],s=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(i,s,!0):this.curve._wnafMulAdd(1,i,s,2,!0)},In.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)},In.prototype.neg=function(e){if(this.inf)return this;var r=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,i=function(s){return s.neg()};r.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(i)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(i)}}}return r},In.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 Dn(t,e,r,n){wa.BasePoint.call(this,t,"jacobian"),e===null&&r===null&&n===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new nr(0)):(this.x=new nr(e,16),this.y=new nr(r,16),this.z=new nr(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.zOne=this.z===this.curve.one}Ng(Dn,wa.BasePoint),Ni.prototype.jpoint=function(e,r,n){return new Dn(this,e,r,n)},Dn.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),r=e.redSqr(),n=this.x.redMul(r),i=this.y.redMul(r).redMul(e);return this.curve.point(n,i)},Dn.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Dn.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var r=e.z.redSqr(),n=this.z.redSqr(),i=this.x.redMul(r),s=e.x.redMul(n),o=this.y.redMul(r.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),f=i.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 h=f.redSqr(),g=h.redMul(f),b=i.redMul(h),x=u.redSqr().redIAdd(g).redISub(b).redISub(b),S=u.redMul(b.redISub(x)).redISub(o.redMul(g)),C=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(x,S,C)},Dn.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var r=this.z.redSqr(),n=this.x,i=e.x.redMul(r),s=this.y,o=e.y.redMul(r).redMul(this.z),a=n.redSub(i),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(),h=u.redMul(a),g=n.redMul(u),b=f.redSqr().redIAdd(h).redISub(g).redISub(g),x=f.redMul(g.redISub(b)).redISub(s.redMul(h)),S=this.z.redMul(a);return this.curve.jpoint(b,x,S)},Dn.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var r;if(this.curve.zeroA||this.curve.threeA){var n=this;for(r=0;r=0)return!1;if(n.redIAdd(s),this.x.cmp(n)===0)return!0}},Dn.prototype.inspect=function(){return this.isInfinity()?"":""},Dn.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Mh=xc(function(t,e){var r=e;r.base=wa,r.short=CO,r.mont=null,r.edwards=null}),Ch=xc(function(t,e){var r=e,n=vi.assert;function i(a){a.type==="short"?this.curve=new Mh.short(a):a.type==="edwards"?this.curve=new Mh.edwards(a):this.curve=new Mh.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,n(this.g.validate(),"Invalid curve"),n(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}r.PresetCurve=i;function s(a,f){Object.defineProperty(r,a,{configurable:!0,enumerable:!0,get:function(){var u=new i(f);return Object.defineProperty(r,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:Ws.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:Ws.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:Ws.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:Ws.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:Ws.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:Ws.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:Ws.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:Ws.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Co(t){if(!(this instanceof Co))return new Co(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ss.toArray(t.entropy,t.entropyEnc||"hex"),r=ss.toArray(t.nonce,t.nonceEnc||"hex"),n=ss.toArray(t.pers,t.persEnc||"hex");Og(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Lx=Co;Co.prototype._init=function(e,r,n){var i=e.concat(r).concat(n);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(n||[])),this._reseed=1},Co.prototype.generate=function(e,r,n,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof r!="string"&&(i=n,n=r,r=null),n&&(n=ss.toArray(n,i||"hex"),this._update(n));for(var s=[];s.length"};var RO=vi.assert;function Rh(t,e){if(t instanceof Rh)return t;this._importDER(t,e)||(RO(t.r&&t.s,"Signature without r or s"),this.r=new nr(t.r,16),this.s=new nr(t.s,16),t.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Th=Rh;function TO(){this.place=0}function Bg(t,e){var r=t[e.place++];if(!(r&128))return r;var n=r&15;if(n===0||n>4)return!1;for(var i=0,s=0,o=e.place;s>>=0;return i<=127?!1:(e.place=o,i)}function kx(t){for(var e=0,r=t.length-1;!t[e]&&!(t[e+1]&128)&&e>>3);for(t.push(r|128);--r;)t.push(e>>>(r<<3)&255);t.push(e)}Rh.prototype.toDER=function(e){var r=this.r.toArray(),n=this.s.toArray();for(r[0]&128&&(r=[0].concat(r)),n[0]&128&&(n=[0].concat(n)),r=kx(r),n=kx(n);!n[0]&&!(n[1]&128);)n=n.slice(1);var i=[2];Fg(i,r.length),i=i.concat(r),i.push(2),Fg(i,n.length);var s=i.concat(n),o=[48];return Fg(o,s.length),o=o.concat(s),vi.encode(o,e)};var DO=(function(){throw new Error("unsupported")}),Bx=vi.assert;function Li(t){if(!(this instanceof Li))return new Li(t);typeof t=="string"&&(Bx(Object.prototype.hasOwnProperty.call(Ch,t),"Unknown curve "+t),t=Ch[t]),t instanceof Ch.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var OO=Li;Li.prototype.keyPair=function(e){return new kg(this,e)},Li.prototype.keyFromPrivate=function(e,r){return kg.fromPrivate(this,e,r)},Li.prototype.keyFromPublic=function(e,r){return kg.fromPublic(this,e,r)},Li.prototype.genKeyPair=function(e){e||(e={});for(var r=new Lx({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||DO(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new nr(2));;){var s=new nr(r.generate(n));if(!(s.cmp(i)>0))return s.iaddn(1),this.keyFromPrivate(s)}},Li.prototype._truncateToN=function(e,r){var n=e.byteLength()*8-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!r&&e.cmp(this.n)>=0?e.sub(this.n):e},Li.prototype.sign=function(e,r,n,i){typeof n=="object"&&(i=n,n=null),i||(i={}),r=this.keyFromPrivate(r,n),e=this._truncateToN(new nr(e,16));for(var s=this.n.byteLength(),o=r.getPrivate().toArray("be",s),a=e.toArray("be",s),f=new Lx({hash:this.hash,entropy:o,nonce:a,pers:i.pers,persEnc:i.persEnc||"utf8"}),u=this.n.sub(new nr(1)),h=0;;h++){var g=i.k?i.k(h):new nr(f.generate(this.n.byteLength()));if(g=this._truncateToN(g,!0),!(g.cmpn(1)<=0||g.cmp(u)>=0)){var b=this.g.mul(g);if(!b.isInfinity()){var x=b.getX(),S=x.umod(this.n);if(S.cmpn(0)!==0){var C=g.invm(this.n).mul(S.mul(r.getPrivate()).iadd(e));if(C=C.umod(this.n),C.cmpn(0)!==0){var D=(b.getY().isOdd()?1:0)|(x.cmp(S)!==0?2:0);return i.canonical&&C.cmp(this.nh)>0&&(C=this.n.sub(C),D^=1),new Th({r:S,s:C,recoveryParam:D})}}}}}},Li.prototype.verify=function(e,r,n,i){e=this._truncateToN(new nr(e,16)),n=this.keyFromPublic(n,i),r=new Th(r,"hex");var s=r.r,o=r.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),h;return this.curve._maxwellTrick?(h=this.g.jmulAdd(f,n.getPublic(),u),h.isInfinity()?!1:h.eqXToP(s)):(h=this.g.mulAdd(f,n.getPublic(),u),h.isInfinity()?!1:h.getX().umod(this.n).cmp(s)===0)},Li.prototype.recoverPubKey=function(t,e,r,n){Bx((3&r)===r,"The recovery param is more than two bits"),e=new Th(e,n);var i=this.n,s=new nr(t),o=e.r,a=e.s,f=r&1,u=r>>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 h=e.r.invm(i),g=i.sub(s).mul(h).umod(i),b=a.mul(h).umod(i);return this.g.mulAdd(g,o,b)},Li.prototype.getKeyRecoveryParam=function(t,e,r,n){if(e=new Th(e,n),e.recoveryParam!==null)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch{continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var NO=xc(function(t,e){var r=e;r.version="6.5.4",r.utils=vi,r.rand=(function(){throw new Error("unsupported")}),r.curve=Mh,r.curves=Ch,r.ec=OO,r.eddsa=null}),LO=NO.ec;const kO="signing-key/5.7.0",jg=new Kr(kO);let Ug=null;function Ro(){return Ug||(Ug=new LO("secp256k1")),Ug}class BO{constructor(e){of(this,"curve","secp256k1"),of(this,"privateKey",mi(e)),sO(this.privateKey)!==32&&jg.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");const r=Ro().keyFromPrivate(mn(this.privateKey));of(this,"publicKey","0x"+r.getPublic(!1,"hex")),of(this,"compressedPublicKey","0x"+r.getPublic(!0,"hex")),of(this,"_isSigningKey",!0)}_addPoint(e){const r=Ro().keyFromPublic(mn(this.publicKey)),n=Ro().keyFromPublic(mn(e));return"0x"+r.pub.add(n.pub).encodeCompressed("hex")}signDigest(e){const r=Ro().keyFromPrivate(mn(this.privateKey)),n=mn(e);n.length!==32&&jg.throwArgumentError("bad digest length","digest",e);const i=r.sign(n,{canonical:!0});return lx({recoveryParam:i.recoveryParam,r:wc("0x"+i.r.toString(16),32),s:wc("0x"+i.s.toString(16),32)})}computeSharedSecret(e){const r=Ro().keyFromPrivate(mn(this.privateKey)),n=Ro().keyFromPublic(mn(Fx(e)));return wc("0x"+r.derive(n.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}function FO(t,e){const r=lx(e),n={r:mn(r.r),s:mn(r.s)};return"0x"+Ro().recoverPubKey(mn(t),n,r.recoveryParam).encode("hex",!1)}function Fx(t,e){const r=mn(t);return r.length===32?new BO(r).publicKey:r.length===33?"0x"+Ro().keyFromPublic(r).getPublic(!1,"hex"):r.length===65?mi(r):jg.throwArgumentError("invalid public or private key","key","[REDACTED]")}var jx;(function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"})(jx||(jx={}));function jO(t){const e=Fx(t);return bO(fx(wg(fx(e,1)),12))}function UO(t,e){return jO(FO(mn(t),e))}var $g={},cf={},Ux;function $O(){if(Ux)return cf;Ux=1,Object.defineProperty(cf,"__esModule",{value:!0});var t=ef(),e=ns(),r=20;function n(a,f,u){for(var h=1634760805,g=857760878,b=2036477234,x=1797285236,S=u[3]<<24|u[2]<<16|u[1]<<8|u[0],C=u[7]<<24|u[6]<<16|u[5]<<8|u[4],D=u[11]<<24|u[10]<<16|u[9]<<8|u[8],B=u[15]<<24|u[14]<<16|u[13]<<8|u[12],L=u[19]<<24|u[18]<<16|u[17]<<8|u[16],H=u[23]<<24|u[22]<<16|u[21]<<8|u[20],F=u[27]<<24|u[26]<<16|u[25]<<8|u[24],k=u[31]<<24|u[30]<<16|u[29]<<8|u[28],$=f[3]<<24|f[2]<<16|f[1]<<8|f[0],R=f[7]<<24|f[6]<<16|f[5]<<8|f[4],W=f[11]<<24|f[10]<<16|f[9]<<8|f[8],V=f[15]<<24|f[14]<<16|f[13]<<8|f[12],X=h,q=g,_=b,v=x,l=S,p=C,m=D,y=B,A=L,E=H,w=F,I=k,M=$,z=R,se=W,O=V,ie=0;ie>>16|M<<16,A=A+M|0,l^=A,l=l>>>20|l<<12,q=q+p|0,z^=q,z=z>>>16|z<<16,E=E+z|0,p^=E,p=p>>>20|p<<12,_=_+m|0,se^=_,se=se>>>16|se<<16,w=w+se|0,m^=w,m=m>>>20|m<<12,v=v+y|0,O^=v,O=O>>>16|O<<16,I=I+O|0,y^=I,y=y>>>20|y<<12,_=_+m|0,se^=_,se=se>>>24|se<<8,w=w+se|0,m^=w,m=m>>>25|m<<7,v=v+y|0,O^=v,O=O>>>24|O<<8,I=I+O|0,y^=I,y=y>>>25|y<<7,q=q+p|0,z^=q,z=z>>>24|z<<8,E=E+z|0,p^=E,p=p>>>25|p<<7,X=X+l|0,M^=X,M=M>>>24|M<<8,A=A+M|0,l^=A,l=l>>>25|l<<7,X=X+p|0,O^=X,O=O>>>16|O<<16,w=w+O|0,p^=w,p=p>>>20|p<<12,q=q+m|0,M^=q,M=M>>>16|M<<16,I=I+M|0,m^=I,m=m>>>20|m<<12,_=_+y|0,z^=_,z=z>>>16|z<<16,A=A+z|0,y^=A,y=y>>>20|y<<12,v=v+l|0,se^=v,se=se>>>16|se<<16,E=E+se|0,l^=E,l=l>>>20|l<<12,_=_+y|0,z^=_,z=z>>>24|z<<8,A=A+z|0,y^=A,y=y>>>25|y<<7,v=v+l|0,se^=v,se=se>>>24|se<<8,E=E+se|0,l^=E,l=l>>>25|l<<7,q=q+m|0,M^=q,M=M>>>24|M<<8,I=I+M|0,m^=I,m=m>>>25|m<<7,X=X+p|0,O^=X,O=O>>>24|O<<8,w=w+O|0,p^=w,p=p>>>25|p<<7;t.writeUint32LE(X+h|0,a,0),t.writeUint32LE(q+g|0,a,4),t.writeUint32LE(_+b|0,a,8),t.writeUint32LE(v+x|0,a,12),t.writeUint32LE(l+S|0,a,16),t.writeUint32LE(p+C|0,a,20),t.writeUint32LE(m+D|0,a,24),t.writeUint32LE(y+B|0,a,28),t.writeUint32LE(A+L|0,a,32),t.writeUint32LE(E+H|0,a,36),t.writeUint32LE(w+F|0,a,40),t.writeUint32LE(I+k|0,a,44),t.writeUint32LE(M+$|0,a,48),t.writeUint32LE(z+R|0,a,52),t.writeUint32LE(se+W|0,a,56),t.writeUint32LE(O+V|0,a,60)}function i(a,f,u,h,g){if(g===void 0&&(g=0),a.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(h.length>>=8,f++;if(h>0)throw new Error("ChaCha: counter overflow")}return cf}var qg={},xa={},$x;function zg(){if($x)return xa;$x=1,Object.defineProperty(xa,"__esModule",{value:!0});function t(i,s,o){return~(i-1)&s|i-1&o}xa.select=t;function e(i,s){return(i|0)-(s|0)-1>>>31&1}xa.lessOrEqual=e;function r(i,s){if(i.length!==s.length)return 0;for(var o=0,a=0;a>>8}xa.compare=r;function n(i,s){return i.length===0||s.length===0?!1:r(i,s)!==0}return xa.equal=n,xa}var qx;function qO(){return qx||(qx=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=zg(),r=ns();t.DIGEST_LENGTH=16;var n=(function(){function o(a){this.digestLength=t.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 f=a[0]|a[1]<<8;this._r[0]=f&8191;var u=a[2]|a[3]<<8;this._r[1]=(f>>>13|u<<3)&8191;var h=a[4]|a[5]<<8;this._r[2]=(u>>>10|h<<6)&7939;var g=a[6]|a[7]<<8;this._r[3]=(h>>>7|g<<9)&8191;var b=a[8]|a[9]<<8;this._r[4]=(g>>>4|b<<12)&255,this._r[5]=b>>>1&8190;var x=a[10]|a[11]<<8;this._r[6]=(b>>>14|x<<2)&8191;var S=a[12]|a[13]<<8;this._r[7]=(x>>>11|S<<5)&8065;var C=a[14]|a[15]<<8;this._r[8]=(S>>>8|C<<8)&8191,this._r[9]=C>>>5&127,this._pad[0]=a[16]|a[17]<<8,this._pad[1]=a[18]|a[19]<<8,this._pad[2]=a[20]|a[21]<<8,this._pad[3]=a[22]|a[23]<<8,this._pad[4]=a[24]|a[25]<<8,this._pad[5]=a[26]|a[27]<<8,this._pad[6]=a[28]|a[29]<<8,this._pad[7]=a[30]|a[31]<<8}return o.prototype._blocks=function(a,f,u){for(var h=this._fin?0:2048,g=this._h[0],b=this._h[1],x=this._h[2],S=this._h[3],C=this._h[4],D=this._h[5],B=this._h[6],L=this._h[7],H=this._h[8],F=this._h[9],k=this._r[0],$=this._r[1],R=this._r[2],W=this._r[3],V=this._r[4],X=this._r[5],q=this._r[6],_=this._r[7],v=this._r[8],l=this._r[9];u>=16;){var p=a[f+0]|a[f+1]<<8;g+=p&8191;var m=a[f+2]|a[f+3]<<8;b+=(p>>>13|m<<3)&8191;var y=a[f+4]|a[f+5]<<8;x+=(m>>>10|y<<6)&8191;var A=a[f+6]|a[f+7]<<8;S+=(y>>>7|A<<9)&8191;var E=a[f+8]|a[f+9]<<8;C+=(A>>>4|E<<12)&8191,D+=E>>>1&8191;var w=a[f+10]|a[f+11]<<8;B+=(E>>>14|w<<2)&8191;var I=a[f+12]|a[f+13]<<8;L+=(w>>>11|I<<5)&8191;var M=a[f+14]|a[f+15]<<8;H+=(I>>>8|M<<8)&8191,F+=M>>>5|h;var z=0,se=z;se+=g*k,se+=b*(5*l),se+=x*(5*v),se+=S*(5*_),se+=C*(5*q),z=se>>>13,se&=8191,se+=D*(5*X),se+=B*(5*V),se+=L*(5*W),se+=H*(5*R),se+=F*(5*$),z+=se>>>13,se&=8191;var O=z;O+=g*$,O+=b*k,O+=x*(5*l),O+=S*(5*v),O+=C*(5*_),z=O>>>13,O&=8191,O+=D*(5*q),O+=B*(5*X),O+=L*(5*V),O+=H*(5*W),O+=F*(5*R),z+=O>>>13,O&=8191;var ie=z;ie+=g*R,ie+=b*$,ie+=x*k,ie+=S*(5*l),ie+=C*(5*v),z=ie>>>13,ie&=8191,ie+=D*(5*_),ie+=B*(5*q),ie+=L*(5*X),ie+=H*(5*V),ie+=F*(5*W),z+=ie>>>13,ie&=8191;var ee=z;ee+=g*W,ee+=b*R,ee+=x*$,ee+=S*k,ee+=C*(5*l),z=ee>>>13,ee&=8191,ee+=D*(5*v),ee+=B*(5*_),ee+=L*(5*q),ee+=H*(5*X),ee+=F*(5*V),z+=ee>>>13,ee&=8191;var Z=z;Z+=g*V,Z+=b*W,Z+=x*R,Z+=S*$,Z+=C*k,z=Z>>>13,Z&=8191,Z+=D*(5*l),Z+=B*(5*v),Z+=L*(5*_),Z+=H*(5*q),Z+=F*(5*X),z+=Z>>>13,Z&=8191;var te=z;te+=g*X,te+=b*V,te+=x*W,te+=S*R,te+=C*$,z=te>>>13,te&=8191,te+=D*k,te+=B*(5*l),te+=L*(5*v),te+=H*(5*_),te+=F*(5*q),z+=te>>>13,te&=8191;var N=z;N+=g*q,N+=b*X,N+=x*V,N+=S*W,N+=C*R,z=N>>>13,N&=8191,N+=D*$,N+=B*k,N+=L*(5*l),N+=H*(5*v),N+=F*(5*_),z+=N>>>13,N&=8191;var Q=z;Q+=g*_,Q+=b*q,Q+=x*X,Q+=S*V,Q+=C*W,z=Q>>>13,Q&=8191,Q+=D*R,Q+=B*$,Q+=L*k,Q+=H*(5*l),Q+=F*(5*v),z+=Q>>>13,Q&=8191;var ne=z;ne+=g*v,ne+=b*_,ne+=x*q,ne+=S*X,ne+=C*V,z=ne>>>13,ne&=8191,ne+=D*W,ne+=B*R,ne+=L*$,ne+=H*k,ne+=F*(5*l),z+=ne>>>13,ne&=8191;var de=z;de+=g*l,de+=b*v,de+=x*_,de+=S*q,de+=C*X,z=de>>>13,de&=8191,de+=D*V,de+=B*W,de+=L*R,de+=H*$,de+=F*k,z+=de>>>13,de&=8191,z=(z<<2)+z|0,z=z+se|0,se=z&8191,z=z>>>13,O+=z,g=se,b=O,x=ie,S=ee,C=Z,D=te,B=N,L=Q,H=ne,F=de,f+=16,u-=16}this._h[0]=g,this._h[1]=b,this._h[2]=x,this._h[3]=S,this._h[4]=C,this._h[5]=D,this._h[6]=B,this._h[7]=L,this._h[8]=H,this._h[9]=F},o.prototype.finish=function(a,f){f===void 0&&(f=0);var u=new Uint16Array(10),h,g,b,x;if(this._leftover){for(x=this._leftover,this._buffer[x++]=1;x<16;x++)this._buffer[x]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(h=this._h[1]>>>13,this._h[1]&=8191,x=2;x<10;x++)this._h[x]+=h,h=this._h[x]>>>13,this._h[x]&=8191;for(this._h[0]+=h*5,h=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=h,h=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=h,u[0]=this._h[0]+5,h=u[0]>>>13,u[0]&=8191,x=1;x<10;x++)u[x]=this._h[x]+h,h=u[x]>>>13,u[x]&=8191;for(u[9]-=8192,g=(h^1)-1,x=0;x<10;x++)u[x]&=g;for(g=~g,x=0;x<10;x++)this._h[x]=this._h[x]&g|u[x];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,b=this._h[0]+this._pad[0],this._h[0]=b&65535,x=1;x<8;x++)b=(this._h[x]+this._pad[x]|0)+(b>>>16)|0,this._h[x]=b&65535;return a[f+0]=this._h[0]>>>0,a[f+1]=this._h[0]>>>8,a[f+2]=this._h[1]>>>0,a[f+3]=this._h[1]>>>8,a[f+4]=this._h[2]>>>0,a[f+5]=this._h[2]>>>8,a[f+6]=this._h[3]>>>0,a[f+7]=this._h[3]>>>8,a[f+8]=this._h[4]>>>0,a[f+9]=this._h[4]>>>8,a[f+10]=this._h[5]>>>0,a[f+11]=this._h[5]>>>8,a[f+12]=this._h[6]>>>0,a[f+13]=this._h[6]>>>8,a[f+14]=this._h[7]>>>0,a[f+15]=this._h[7]>>>8,this._finished=!0,this},o.prototype.update=function(a){var f=0,u=a.length,h;if(this._leftover){h=16-this._leftover,h>u&&(h=u);for(var g=0;g=16&&(h=u-u%16,this._blocks(a,f,h),f+=h,u-=h),u){for(var g=0;g16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var x=new Uint8Array(16);x.set(u,x.length-u.length);var S=new Uint8Array(32);e.stream(this._key,x,S,4);var C=h.length+this.tagLength,D;if(b){if(b.length!==C)throw new Error("ChaCha20Poly1305: incorrect destination length");D=b}else D=new Uint8Array(C);return e.streamXOR(this._key,x,h,D,4),this._authenticate(D.subarray(D.length-this.tagLength,D.length),S,D.subarray(0,D.length-this.tagLength),g),n.wipe(x),D},f.prototype.open=function(u,h,g,b){if(u.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(h.length0&&x.update(o.subarray(b.length%16))),x.update(g),g.length%16>0&&x.update(o.subarray(g.length%16));var S=new Uint8Array(8);b&&i.writeUint64LE(b.length,S),x.update(S),i.writeUint64LE(g.length,S),x.update(S);for(var C=x.digest(),D=0;Dthis.blockSize?this._inner.update(a).finish(f).clean():f.set(a);for(var u=0;u1&&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},n.prototype.expand=function(i){for(var s=new Uint8Array(i),o=0;o0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=f[h++],u--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(u>=this.blockSize&&(h=s(this._temp,this._state,f,h,u),u%=this.blockSize);u>0;)this._buffer[this._bufferLength++]=f[h++],u--;return this},a.prototype.finish=function(f){if(!this._finished){var u=this._bytesHashed,h=this._bufferLength,g=u/536870912|0,b=u<<3,x=u%64<56?64:128;this._buffer[h]=128;for(var S=h+1;S0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},a.prototype.restoreState=function(f){return this._state.set(f.state),this._bufferLength=f.bufferLength,f.buffer&&this._buffer.set(f.buffer),this._bytesHashed=f.bytesHashed,this._finished=!1,this},a.prototype.cleanSavedState=function(f){r.wipe(f.state),f.buffer&&r.wipe(f.buffer),f.bufferLength=0,f.bytesHashed=0},a})();t.SHA256=n;var i=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 s(a,f,u,h,g){for(;g>=64;){for(var b=f[0],x=f[1],S=f[2],C=f[3],D=f[4],B=f[5],L=f[6],H=f[7],F=0;F<16;F++){var k=h+F*4;a[F]=e.readUint32BE(u,k)}for(var F=16;F<64;F++){var $=a[F-2],R=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10;$=a[F-15];var W=($>>>7|$<<25)^($>>>18|$<<14)^$>>>3;a[F]=(R+a[F-7]|0)+(W+a[F-16]|0)}for(var F=0;F<64;F++){var R=(((D>>>6|D<<26)^(D>>>11|D<<21)^(D>>>25|D<<7))+(D&B^~D&L)|0)+(H+(i[F]+a[F]|0)|0)|0,W=((b>>>2|b<<30)^(b>>>13|b<<19)^(b>>>22|b<<10))+(b&x^b&S^x&S)|0;H=L,L=B,B=D,D=C+R|0,C=S,S=x,x=b,b=R+W|0}f[0]+=b,f[1]+=x,f[2]+=S,f[3]+=C,f[4]+=D,f[5]+=B,f[6]+=L,f[7]+=H,h+=64,g-=64}return h}function o(a){var f=new n;f.update(a);var u=f.digest();return f.clean(),u}t.hash=o})(Hg)),Hg}var Nh=GO(),Wg={},Yx;function YO(){return Yx||(Yx=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const e=og(),r=ns();t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(F){const k=new Float64Array(16);if(F)for(let $=0;$>16&1),$[X-1]&=65535;$[15]=R[15]-32767-($[14]>>16&1);const V=$[15]>>16&1;$[14]&=65535,a(R,$,1-V)}for(let W=0;W<16;W++)F[2*W]=R[W]&255,F[2*W+1]=R[W]>>8}function u(F,k){for(let $=0;$<16;$++)F[$]=k[2*$]+(k[2*$+1]<<8);F[15]&=32767}function h(F,k,$){for(let R=0;R<16;R++)F[R]=k[R]+$[R]}function g(F,k,$){for(let R=0;R<16;R++)F[R]=k[R]-$[R]}function b(F,k,$){let R,W,V=0,X=0,q=0,_=0,v=0,l=0,p=0,m=0,y=0,A=0,E=0,w=0,I=0,M=0,z=0,se=0,O=0,ie=0,ee=0,Z=0,te=0,N=0,Q=0,ne=0,de=0,ce=0,fe=0,be=0,Pe=0,De=0,Te=0,Fe=$[0],Me=$[1],Ne=$[2],He=$[3],Oe=$[4],$e=$[5],qe=$[6],_e=$[7],Qe=$[8],at=$[9],Be=$[10],nt=$[11],it=$[12],Ye=$[13],pt=$[14],ht=$[15];R=k[0],V+=R*Fe,X+=R*Me,q+=R*Ne,_+=R*He,v+=R*Oe,l+=R*$e,p+=R*qe,m+=R*_e,y+=R*Qe,A+=R*at,E+=R*Be,w+=R*nt,I+=R*it,M+=R*Ye,z+=R*pt,se+=R*ht,R=k[1],X+=R*Fe,q+=R*Me,_+=R*Ne,v+=R*He,l+=R*Oe,p+=R*$e,m+=R*qe,y+=R*_e,A+=R*Qe,E+=R*at,w+=R*Be,I+=R*nt,M+=R*it,z+=R*Ye,se+=R*pt,O+=R*ht,R=k[2],q+=R*Fe,_+=R*Me,v+=R*Ne,l+=R*He,p+=R*Oe,m+=R*$e,y+=R*qe,A+=R*_e,E+=R*Qe,w+=R*at,I+=R*Be,M+=R*nt,z+=R*it,se+=R*Ye,O+=R*pt,ie+=R*ht,R=k[3],_+=R*Fe,v+=R*Me,l+=R*Ne,p+=R*He,m+=R*Oe,y+=R*$e,A+=R*qe,E+=R*_e,w+=R*Qe,I+=R*at,M+=R*Be,z+=R*nt,se+=R*it,O+=R*Ye,ie+=R*pt,ee+=R*ht,R=k[4],v+=R*Fe,l+=R*Me,p+=R*Ne,m+=R*He,y+=R*Oe,A+=R*$e,E+=R*qe,w+=R*_e,I+=R*Qe,M+=R*at,z+=R*Be,se+=R*nt,O+=R*it,ie+=R*Ye,ee+=R*pt,Z+=R*ht,R=k[5],l+=R*Fe,p+=R*Me,m+=R*Ne,y+=R*He,A+=R*Oe,E+=R*$e,w+=R*qe,I+=R*_e,M+=R*Qe,z+=R*at,se+=R*Be,O+=R*nt,ie+=R*it,ee+=R*Ye,Z+=R*pt,te+=R*ht,R=k[6],p+=R*Fe,m+=R*Me,y+=R*Ne,A+=R*He,E+=R*Oe,w+=R*$e,I+=R*qe,M+=R*_e,z+=R*Qe,se+=R*at,O+=R*Be,ie+=R*nt,ee+=R*it,Z+=R*Ye,te+=R*pt,N+=R*ht,R=k[7],m+=R*Fe,y+=R*Me,A+=R*Ne,E+=R*He,w+=R*Oe,I+=R*$e,M+=R*qe,z+=R*_e,se+=R*Qe,O+=R*at,ie+=R*Be,ee+=R*nt,Z+=R*it,te+=R*Ye,N+=R*pt,Q+=R*ht,R=k[8],y+=R*Fe,A+=R*Me,E+=R*Ne,w+=R*He,I+=R*Oe,M+=R*$e,z+=R*qe,se+=R*_e,O+=R*Qe,ie+=R*at,ee+=R*Be,Z+=R*nt,te+=R*it,N+=R*Ye,Q+=R*pt,ne+=R*ht,R=k[9],A+=R*Fe,E+=R*Me,w+=R*Ne,I+=R*He,M+=R*Oe,z+=R*$e,se+=R*qe,O+=R*_e,ie+=R*Qe,ee+=R*at,Z+=R*Be,te+=R*nt,N+=R*it,Q+=R*Ye,ne+=R*pt,de+=R*ht,R=k[10],E+=R*Fe,w+=R*Me,I+=R*Ne,M+=R*He,z+=R*Oe,se+=R*$e,O+=R*qe,ie+=R*_e,ee+=R*Qe,Z+=R*at,te+=R*Be,N+=R*nt,Q+=R*it,ne+=R*Ye,de+=R*pt,ce+=R*ht,R=k[11],w+=R*Fe,I+=R*Me,M+=R*Ne,z+=R*He,se+=R*Oe,O+=R*$e,ie+=R*qe,ee+=R*_e,Z+=R*Qe,te+=R*at,N+=R*Be,Q+=R*nt,ne+=R*it,de+=R*Ye,ce+=R*pt,fe+=R*ht,R=k[12],I+=R*Fe,M+=R*Me,z+=R*Ne,se+=R*He,O+=R*Oe,ie+=R*$e,ee+=R*qe,Z+=R*_e,te+=R*Qe,N+=R*at,Q+=R*Be,ne+=R*nt,de+=R*it,ce+=R*Ye,fe+=R*pt,be+=R*ht,R=k[13],M+=R*Fe,z+=R*Me,se+=R*Ne,O+=R*He,ie+=R*Oe,ee+=R*$e,Z+=R*qe,te+=R*_e,N+=R*Qe,Q+=R*at,ne+=R*Be,de+=R*nt,ce+=R*it,fe+=R*Ye,be+=R*pt,Pe+=R*ht,R=k[14],z+=R*Fe,se+=R*Me,O+=R*Ne,ie+=R*He,ee+=R*Oe,Z+=R*$e,te+=R*qe,N+=R*_e,Q+=R*Qe,ne+=R*at,de+=R*Be,ce+=R*nt,fe+=R*it,be+=R*Ye,Pe+=R*pt,De+=R*ht,R=k[15],se+=R*Fe,O+=R*Me,ie+=R*Ne,ee+=R*He,Z+=R*Oe,te+=R*$e,N+=R*qe,Q+=R*_e,ne+=R*Qe,de+=R*at,ce+=R*Be,fe+=R*nt,be+=R*it,Pe+=R*Ye,De+=R*pt,Te+=R*ht,V+=38*O,X+=38*ie,q+=38*ee,_+=38*Z,v+=38*te,l+=38*N,p+=38*Q,m+=38*ne,y+=38*de,A+=38*ce,E+=38*fe,w+=38*be,I+=38*Pe,M+=38*De,z+=38*Te,W=1,R=V+W+65535,W=Math.floor(R/65536),V=R-W*65536,R=X+W+65535,W=Math.floor(R/65536),X=R-W*65536,R=q+W+65535,W=Math.floor(R/65536),q=R-W*65536,R=_+W+65535,W=Math.floor(R/65536),_=R-W*65536,R=v+W+65535,W=Math.floor(R/65536),v=R-W*65536,R=l+W+65535,W=Math.floor(R/65536),l=R-W*65536,R=p+W+65535,W=Math.floor(R/65536),p=R-W*65536,R=m+W+65535,W=Math.floor(R/65536),m=R-W*65536,R=y+W+65535,W=Math.floor(R/65536),y=R-W*65536,R=A+W+65535,W=Math.floor(R/65536),A=R-W*65536,R=E+W+65535,W=Math.floor(R/65536),E=R-W*65536,R=w+W+65535,W=Math.floor(R/65536),w=R-W*65536,R=I+W+65535,W=Math.floor(R/65536),I=R-W*65536,R=M+W+65535,W=Math.floor(R/65536),M=R-W*65536,R=z+W+65535,W=Math.floor(R/65536),z=R-W*65536,R=se+W+65535,W=Math.floor(R/65536),se=R-W*65536,V+=W-1+37*(W-1),W=1,R=V+W+65535,W=Math.floor(R/65536),V=R-W*65536,R=X+W+65535,W=Math.floor(R/65536),X=R-W*65536,R=q+W+65535,W=Math.floor(R/65536),q=R-W*65536,R=_+W+65535,W=Math.floor(R/65536),_=R-W*65536,R=v+W+65535,W=Math.floor(R/65536),v=R-W*65536,R=l+W+65535,W=Math.floor(R/65536),l=R-W*65536,R=p+W+65535,W=Math.floor(R/65536),p=R-W*65536,R=m+W+65535,W=Math.floor(R/65536),m=R-W*65536,R=y+W+65535,W=Math.floor(R/65536),y=R-W*65536,R=A+W+65535,W=Math.floor(R/65536),A=R-W*65536,R=E+W+65535,W=Math.floor(R/65536),E=R-W*65536,R=w+W+65535,W=Math.floor(R/65536),w=R-W*65536,R=I+W+65535,W=Math.floor(R/65536),I=R-W*65536,R=M+W+65535,W=Math.floor(R/65536),M=R-W*65536,R=z+W+65535,W=Math.floor(R/65536),z=R-W*65536,R=se+W+65535,W=Math.floor(R/65536),se=R-W*65536,V+=W-1+37*(W-1),F[0]=V,F[1]=X,F[2]=q,F[3]=_,F[4]=v,F[5]=l,F[6]=p,F[7]=m,F[8]=y,F[9]=A,F[10]=E,F[11]=w,F[12]=I,F[13]=M,F[14]=z,F[15]=se}function x(F,k){b(F,k,k)}function S(F,k){const $=n();for(let R=0;R<16;R++)$[R]=k[R];for(let R=253;R>=0;R--)x($,$),R!==2&&R!==4&&b($,$,k);for(let R=0;R<16;R++)F[R]=$[R]}function C(F,k){const $=new Uint8Array(32),R=new Float64Array(80),W=n(),V=n(),X=n(),q=n(),_=n(),v=n();for(let y=0;y<31;y++)$[y]=F[y];$[31]=F[31]&127|64,$[0]&=248,u(R,k);for(let y=0;y<16;y++)V[y]=R[y];W[0]=q[0]=1;for(let y=254;y>=0;--y){const A=$[y>>>3]>>>(y&7)&1;a(W,V,A),a(X,q,A),h(_,W,X),g(W,W,X),h(X,V,q),g(V,V,q),x(q,_),x(v,W),b(W,X,W),b(X,V,_),h(_,W,X),g(W,W,X),x(V,W),g(X,q,v),b(W,X,s),h(W,W,q),b(X,X,W),b(W,q,v),b(q,V,R),x(V,_),a(W,V,A),a(X,q,A)}for(let y=0;y<16;y++)R[y+16]=W[y],R[y+32]=X[y],R[y+48]=V[y],R[y+64]=q[y];const l=R.subarray(32),p=R.subarray(16);S(l,l),b(p,p,l);const m=new Uint8Array(32);return f(m,p),m}t.scalarMult=C;function D(F){return C(F,i)}t.scalarMultBase=D;function B(F){if(F.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const k=new Uint8Array(F);return{publicKey:D(k),secretKey:k}}t.generateKeyPairFromSeed=B;function L(F){const k=(0,e.randomBytes)(32,F),$=B(k);return(0,r.wipe)(k),$}t.generateKeyPair=L;function H(F,k,$=!1){if(F.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(k.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const R=C(F,k);if($){let W=0;for(let V=0;V0?_:v},s.min=function(_,v){return _.cmp(v)<0?_:v},s.prototype._init=function(_,v,l){if(typeof _=="number")return this._initNumber(_,v,l);if(typeof _=="object")return this._initArray(_,v,l);v==="hex"&&(v=16),n(v===(v|0)&&v>=2&&v<=36),_=_.toString().replace(/\s+/g,"");var p=0;_[0]==="-"&&(p++,this.negative=1),p<_.length&&(v===16?this._parseHex(_,p,l):(this._parseBase(_,v,p),l==="le"&&this._initArray(this.toArray(),v,l)))},s.prototype._initNumber=function(_,v,l){_<0&&(this.negative=1,_=-_),_<67108864?(this.words=[_&67108863],this.length=1):_<4503599627370496?(this.words=[_&67108863,_/67108864&67108863],this.length=2):(n(_<9007199254740992),this.words=[_&67108863,_/67108864&67108863,1],this.length=3),l==="le"&&this._initArray(this.toArray(),v,l)},s.prototype._initArray=function(_,v,l){if(n(typeof _.length=="number"),_.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(_.length/3),this.words=new Array(this.length);for(var p=0;p=0;p-=3)y=_[p]|_[p-1]<<8|_[p-2]<<16,this.words[m]|=y<>>26-A&67108863,A+=24,A>=26&&(A-=26,m++);else if(l==="le")for(p=0,m=0;p<_.length;p+=3)y=_[p]|_[p+1]<<8|_[p+2]<<16,this.words[m]|=y<>>26-A&67108863,A+=24,A>=26&&(A-=26,m++);return this.strip()};function a(q,_){var v=q.charCodeAt(_);return v>=65&&v<=70?v-55:v>=97&&v<=102?v-87:v-48&15}function f(q,_,v){var l=a(q,v);return v-1>=_&&(l|=a(q,v-1)<<4),l}s.prototype._parseHex=function(_,v,l){this.length=Math.ceil((_.length-v)/6),this.words=new Array(this.length);for(var p=0;p=v;p-=2)A=f(_,v,p)<=18?(m-=18,y+=1,this.words[y]|=A>>>26):m+=8;else{var E=_.length-v;for(p=E%2===0?v+1:v;p<_.length;p+=2)A=f(_,v,p)<=18?(m-=18,y+=1,this.words[y]|=A>>>26):m+=8}this.strip()};function u(q,_,v,l){for(var p=0,m=Math.min(q.length,v),y=_;y=49?p+=A-49+10:A>=17?p+=A-17+10:p+=A}return p}s.prototype._parseBase=function(_,v,l){this.words=[0],this.length=1;for(var p=0,m=1;m<=67108863;m*=v)p++;p--,m=m/v|0;for(var y=_.length-l,A=y%p,E=Math.min(y,y-A)+l,w=0,I=l;I1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},s.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},s.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"],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],b=[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];s.prototype.toString=function(_,v){_=_||10,v=v|0||1;var l;if(_===16||_==="hex"){l="";for(var p=0,m=0,y=0;y>>24-p&16777215,p+=2,p>=26&&(p-=26,y--),m!==0||y!==this.length-1?l=h[6-E.length]+E+l:l=E+l}for(m!==0&&(l=m.toString(16)+l);l.length%v!==0;)l="0"+l;return this.negative!==0&&(l="-"+l),l}if(_===(_|0)&&_>=2&&_<=36){var w=g[_],I=b[_];l="";var M=this.clone();for(M.negative=0;!M.isZero();){var z=M.modn(I).toString(_);M=M.idivn(I),M.isZero()?l=z+l:l=h[w-z.length]+z+l}for(this.isZero()&&(l="0"+l);l.length%v!==0;)l="0"+l;return this.negative!==0&&(l="-"+l),l}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var _=this.words[0];return this.length===2?_+=this.words[1]*67108864:this.length===3&&this.words[2]===1?_+=4503599627370496+this.words[1]*67108864:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-_:_},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(_,v){return n(typeof o<"u"),this.toArrayLike(o,_,v)},s.prototype.toArray=function(_,v){return this.toArrayLike(Array,_,v)},s.prototype.toArrayLike=function(_,v,l){var p=this.byteLength(),m=l||Math.max(1,p);n(p<=m,"byte array longer than desired length"),n(m>0,"Requested array length <= 0"),this.strip();var y=v==="le",A=new _(m),E,w,I=this.clone();if(y){for(w=0;!I.isZero();w++)E=I.andln(255),I.iushrn(8),A[w]=E;for(;w=4096&&(l+=13,v>>>=13),v>=64&&(l+=7,v>>>=7),v>=8&&(l+=4,v>>>=4),v>=2&&(l+=2,v>>>=2),l+v},s.prototype._zeroBits=function(_){if(_===0)return 26;var v=_,l=0;return(v&8191)===0&&(l+=13,v>>>=13),(v&127)===0&&(l+=7,v>>>=7),(v&15)===0&&(l+=4,v>>>=4),(v&3)===0&&(l+=2,v>>>=2),(v&1)===0&&l++,l},s.prototype.bitLength=function(){var _=this.words[this.length-1],v=this._countBits(_);return(this.length-1)*26+v};function x(q){for(var _=new Array(q.bitLength()),v=0;v<_.length;v++){var l=v/26|0,p=v%26;_[v]=(q.words[l]&1<>>p}return _}s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var _=0,v=0;v_.length?this.clone().ior(_):_.clone().ior(this)},s.prototype.uor=function(_){return this.length>_.length?this.clone().iuor(_):_.clone().iuor(this)},s.prototype.iuand=function(_){var v;this.length>_.length?v=_:v=this;for(var l=0;l_.length?this.clone().iand(_):_.clone().iand(this)},s.prototype.uand=function(_){return this.length>_.length?this.clone().iuand(_):_.clone().iuand(this)},s.prototype.iuxor=function(_){var v,l;this.length>_.length?(v=this,l=_):(v=_,l=this);for(var p=0;p_.length?this.clone().ixor(_):_.clone().ixor(this)},s.prototype.uxor=function(_){return this.length>_.length?this.clone().iuxor(_):_.clone().iuxor(this)},s.prototype.inotn=function(_){n(typeof _=="number"&&_>=0);var v=Math.ceil(_/26)|0,l=_%26;this._expand(v),l>0&&v--;for(var p=0;p0&&(this.words[p]=~this.words[p]&67108863>>26-l),this.strip()},s.prototype.notn=function(_){return this.clone().inotn(_)},s.prototype.setn=function(_,v){n(typeof _=="number"&&_>=0);var l=_/26|0,p=_%26;return this._expand(l+1),v?this.words[l]=this.words[l]|1<_.length?(l=this,p=_):(l=_,p=this);for(var m=0,y=0;y>>26;for(;m!==0&&y>>26;if(this.length=l.length,m!==0)this.words[this.length]=m,this.length++;else if(l!==this)for(;y_.length?this.clone().iadd(_):_.clone().iadd(this)},s.prototype.isub=function(_){if(_.negative!==0){_.negative=0;var v=this.iadd(_);return _.negative=1,v._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(_),this.negative=1,this._normSign();var l=this.cmp(_);if(l===0)return this.negative=0,this.length=1,this.words[0]=0,this;var p,m;l>0?(p=this,m=_):(p=_,m=this);for(var y=0,A=0;A>26,this.words[A]=v&67108863;for(;y!==0&&A>26,this.words[A]=v&67108863;if(y===0&&A>>26,M=E&67108863,z=Math.min(w,_.length-1),se=Math.max(0,w-q.length+1);se<=z;se++){var O=w-se|0;p=q.words[O]|0,m=_.words[se]|0,y=p*m+M,I+=y/67108864|0,M=y&67108863}v.words[w]=M|0,E=I|0}return E!==0?v.words[w]=E|0:v.length--,v.strip()}var C=function(_,v,l){var p=_.words,m=v.words,y=l.words,A=0,E,w,I,M=p[0]|0,z=M&8191,se=M>>>13,O=p[1]|0,ie=O&8191,ee=O>>>13,Z=p[2]|0,te=Z&8191,N=Z>>>13,Q=p[3]|0,ne=Q&8191,de=Q>>>13,ce=p[4]|0,fe=ce&8191,be=ce>>>13,Pe=p[5]|0,De=Pe&8191,Te=Pe>>>13,Fe=p[6]|0,Me=Fe&8191,Ne=Fe>>>13,He=p[7]|0,Oe=He&8191,$e=He>>>13,qe=p[8]|0,_e=qe&8191,Qe=qe>>>13,at=p[9]|0,Be=at&8191,nt=at>>>13,it=m[0]|0,Ye=it&8191,pt=it>>>13,ht=m[1]|0,ft=ht&8191,Ht=ht>>>13,Jt=m[2]|0,St=Jt&8191,Xt=Jt>>>13,tr=m[3]|0,Dt=tr&8191,Bt=tr>>>13,Ct=m[4]|0,gt=Ct&8191,Ot=Ct>>>13,Lt=m[5]|0,bt=Lt&8191,jt=Lt>>>13,Ut=m[6]|0,tt=Ut&8191,Ft=Ut>>>13,K=m[7]|0,G=K&8191,J=K>>>13,T=m[8]|0,j=T&8191,oe=T>>>13,le=m[9]|0,me=le&8191,Ee=le>>>13;l.negative=_.negative^v.negative,l.length=19,E=Math.imul(z,Ye),w=Math.imul(z,pt),w=w+Math.imul(se,Ye)|0,I=Math.imul(se,pt);var ke=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(ke>>>26)|0,ke&=67108863,E=Math.imul(ie,Ye),w=Math.imul(ie,pt),w=w+Math.imul(ee,Ye)|0,I=Math.imul(ee,pt),E=E+Math.imul(z,ft)|0,w=w+Math.imul(z,Ht)|0,w=w+Math.imul(se,ft)|0,I=I+Math.imul(se,Ht)|0;var Ce=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,E=Math.imul(te,Ye),w=Math.imul(te,pt),w=w+Math.imul(N,Ye)|0,I=Math.imul(N,pt),E=E+Math.imul(ie,ft)|0,w=w+Math.imul(ie,Ht)|0,w=w+Math.imul(ee,ft)|0,I=I+Math.imul(ee,Ht)|0,E=E+Math.imul(z,St)|0,w=w+Math.imul(z,Xt)|0,w=w+Math.imul(se,St)|0,I=I+Math.imul(se,Xt)|0;var et=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(et>>>26)|0,et&=67108863,E=Math.imul(ne,Ye),w=Math.imul(ne,pt),w=w+Math.imul(de,Ye)|0,I=Math.imul(de,pt),E=E+Math.imul(te,ft)|0,w=w+Math.imul(te,Ht)|0,w=w+Math.imul(N,ft)|0,I=I+Math.imul(N,Ht)|0,E=E+Math.imul(ie,St)|0,w=w+Math.imul(ie,Xt)|0,w=w+Math.imul(ee,St)|0,I=I+Math.imul(ee,Xt)|0,E=E+Math.imul(z,Dt)|0,w=w+Math.imul(z,Bt)|0,w=w+Math.imul(se,Dt)|0,I=I+Math.imul(se,Bt)|0;var Ze=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(Ze>>>26)|0,Ze&=67108863,E=Math.imul(fe,Ye),w=Math.imul(fe,pt),w=w+Math.imul(be,Ye)|0,I=Math.imul(be,pt),E=E+Math.imul(ne,ft)|0,w=w+Math.imul(ne,Ht)|0,w=w+Math.imul(de,ft)|0,I=I+Math.imul(de,Ht)|0,E=E+Math.imul(te,St)|0,w=w+Math.imul(te,Xt)|0,w=w+Math.imul(N,St)|0,I=I+Math.imul(N,Xt)|0,E=E+Math.imul(ie,Dt)|0,w=w+Math.imul(ie,Bt)|0,w=w+Math.imul(ee,Dt)|0,I=I+Math.imul(ee,Bt)|0,E=E+Math.imul(z,gt)|0,w=w+Math.imul(z,Ot)|0,w=w+Math.imul(se,gt)|0,I=I+Math.imul(se,Ot)|0;var rt=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(rt>>>26)|0,rt&=67108863,E=Math.imul(De,Ye),w=Math.imul(De,pt),w=w+Math.imul(Te,Ye)|0,I=Math.imul(Te,pt),E=E+Math.imul(fe,ft)|0,w=w+Math.imul(fe,Ht)|0,w=w+Math.imul(be,ft)|0,I=I+Math.imul(be,Ht)|0,E=E+Math.imul(ne,St)|0,w=w+Math.imul(ne,Xt)|0,w=w+Math.imul(de,St)|0,I=I+Math.imul(de,Xt)|0,E=E+Math.imul(te,Dt)|0,w=w+Math.imul(te,Bt)|0,w=w+Math.imul(N,Dt)|0,I=I+Math.imul(N,Bt)|0,E=E+Math.imul(ie,gt)|0,w=w+Math.imul(ie,Ot)|0,w=w+Math.imul(ee,gt)|0,I=I+Math.imul(ee,Ot)|0,E=E+Math.imul(z,bt)|0,w=w+Math.imul(z,jt)|0,w=w+Math.imul(se,bt)|0,I=I+Math.imul(se,jt)|0;var ot=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(ot>>>26)|0,ot&=67108863,E=Math.imul(Me,Ye),w=Math.imul(Me,pt),w=w+Math.imul(Ne,Ye)|0,I=Math.imul(Ne,pt),E=E+Math.imul(De,ft)|0,w=w+Math.imul(De,Ht)|0,w=w+Math.imul(Te,ft)|0,I=I+Math.imul(Te,Ht)|0,E=E+Math.imul(fe,St)|0,w=w+Math.imul(fe,Xt)|0,w=w+Math.imul(be,St)|0,I=I+Math.imul(be,Xt)|0,E=E+Math.imul(ne,Dt)|0,w=w+Math.imul(ne,Bt)|0,w=w+Math.imul(de,Dt)|0,I=I+Math.imul(de,Bt)|0,E=E+Math.imul(te,gt)|0,w=w+Math.imul(te,Ot)|0,w=w+Math.imul(N,gt)|0,I=I+Math.imul(N,Ot)|0,E=E+Math.imul(ie,bt)|0,w=w+Math.imul(ie,jt)|0,w=w+Math.imul(ee,bt)|0,I=I+Math.imul(ee,jt)|0,E=E+Math.imul(z,tt)|0,w=w+Math.imul(z,Ft)|0,w=w+Math.imul(se,tt)|0,I=I+Math.imul(se,Ft)|0;var yt=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(yt>>>26)|0,yt&=67108863,E=Math.imul(Oe,Ye),w=Math.imul(Oe,pt),w=w+Math.imul($e,Ye)|0,I=Math.imul($e,pt),E=E+Math.imul(Me,ft)|0,w=w+Math.imul(Me,Ht)|0,w=w+Math.imul(Ne,ft)|0,I=I+Math.imul(Ne,Ht)|0,E=E+Math.imul(De,St)|0,w=w+Math.imul(De,Xt)|0,w=w+Math.imul(Te,St)|0,I=I+Math.imul(Te,Xt)|0,E=E+Math.imul(fe,Dt)|0,w=w+Math.imul(fe,Bt)|0,w=w+Math.imul(be,Dt)|0,I=I+Math.imul(be,Bt)|0,E=E+Math.imul(ne,gt)|0,w=w+Math.imul(ne,Ot)|0,w=w+Math.imul(de,gt)|0,I=I+Math.imul(de,Ot)|0,E=E+Math.imul(te,bt)|0,w=w+Math.imul(te,jt)|0,w=w+Math.imul(N,bt)|0,I=I+Math.imul(N,jt)|0,E=E+Math.imul(ie,tt)|0,w=w+Math.imul(ie,Ft)|0,w=w+Math.imul(ee,tt)|0,I=I+Math.imul(ee,Ft)|0,E=E+Math.imul(z,G)|0,w=w+Math.imul(z,J)|0,w=w+Math.imul(se,G)|0,I=I+Math.imul(se,J)|0;var Rt=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,E=Math.imul(_e,Ye),w=Math.imul(_e,pt),w=w+Math.imul(Qe,Ye)|0,I=Math.imul(Qe,pt),E=E+Math.imul(Oe,ft)|0,w=w+Math.imul(Oe,Ht)|0,w=w+Math.imul($e,ft)|0,I=I+Math.imul($e,Ht)|0,E=E+Math.imul(Me,St)|0,w=w+Math.imul(Me,Xt)|0,w=w+Math.imul(Ne,St)|0,I=I+Math.imul(Ne,Xt)|0,E=E+Math.imul(De,Dt)|0,w=w+Math.imul(De,Bt)|0,w=w+Math.imul(Te,Dt)|0,I=I+Math.imul(Te,Bt)|0,E=E+Math.imul(fe,gt)|0,w=w+Math.imul(fe,Ot)|0,w=w+Math.imul(be,gt)|0,I=I+Math.imul(be,Ot)|0,E=E+Math.imul(ne,bt)|0,w=w+Math.imul(ne,jt)|0,w=w+Math.imul(de,bt)|0,I=I+Math.imul(de,jt)|0,E=E+Math.imul(te,tt)|0,w=w+Math.imul(te,Ft)|0,w=w+Math.imul(N,tt)|0,I=I+Math.imul(N,Ft)|0,E=E+Math.imul(ie,G)|0,w=w+Math.imul(ie,J)|0,w=w+Math.imul(ee,G)|0,I=I+Math.imul(ee,J)|0,E=E+Math.imul(z,j)|0,w=w+Math.imul(z,oe)|0,w=w+Math.imul(se,j)|0,I=I+Math.imul(se,oe)|0;var Mt=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,E=Math.imul(Be,Ye),w=Math.imul(Be,pt),w=w+Math.imul(nt,Ye)|0,I=Math.imul(nt,pt),E=E+Math.imul(_e,ft)|0,w=w+Math.imul(_e,Ht)|0,w=w+Math.imul(Qe,ft)|0,I=I+Math.imul(Qe,Ht)|0,E=E+Math.imul(Oe,St)|0,w=w+Math.imul(Oe,Xt)|0,w=w+Math.imul($e,St)|0,I=I+Math.imul($e,Xt)|0,E=E+Math.imul(Me,Dt)|0,w=w+Math.imul(Me,Bt)|0,w=w+Math.imul(Ne,Dt)|0,I=I+Math.imul(Ne,Bt)|0,E=E+Math.imul(De,gt)|0,w=w+Math.imul(De,Ot)|0,w=w+Math.imul(Te,gt)|0,I=I+Math.imul(Te,Ot)|0,E=E+Math.imul(fe,bt)|0,w=w+Math.imul(fe,jt)|0,w=w+Math.imul(be,bt)|0,I=I+Math.imul(be,jt)|0,E=E+Math.imul(ne,tt)|0,w=w+Math.imul(ne,Ft)|0,w=w+Math.imul(de,tt)|0,I=I+Math.imul(de,Ft)|0,E=E+Math.imul(te,G)|0,w=w+Math.imul(te,J)|0,w=w+Math.imul(N,G)|0,I=I+Math.imul(N,J)|0,E=E+Math.imul(ie,j)|0,w=w+Math.imul(ie,oe)|0,w=w+Math.imul(ee,j)|0,I=I+Math.imul(ee,oe)|0,E=E+Math.imul(z,me)|0,w=w+Math.imul(z,Ee)|0,w=w+Math.imul(se,me)|0,I=I+Math.imul(se,Ee)|0;var xt=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(xt>>>26)|0,xt&=67108863,E=Math.imul(Be,ft),w=Math.imul(Be,Ht),w=w+Math.imul(nt,ft)|0,I=Math.imul(nt,Ht),E=E+Math.imul(_e,St)|0,w=w+Math.imul(_e,Xt)|0,w=w+Math.imul(Qe,St)|0,I=I+Math.imul(Qe,Xt)|0,E=E+Math.imul(Oe,Dt)|0,w=w+Math.imul(Oe,Bt)|0,w=w+Math.imul($e,Dt)|0,I=I+Math.imul($e,Bt)|0,E=E+Math.imul(Me,gt)|0,w=w+Math.imul(Me,Ot)|0,w=w+Math.imul(Ne,gt)|0,I=I+Math.imul(Ne,Ot)|0,E=E+Math.imul(De,bt)|0,w=w+Math.imul(De,jt)|0,w=w+Math.imul(Te,bt)|0,I=I+Math.imul(Te,jt)|0,E=E+Math.imul(fe,tt)|0,w=w+Math.imul(fe,Ft)|0,w=w+Math.imul(be,tt)|0,I=I+Math.imul(be,Ft)|0,E=E+Math.imul(ne,G)|0,w=w+Math.imul(ne,J)|0,w=w+Math.imul(de,G)|0,I=I+Math.imul(de,J)|0,E=E+Math.imul(te,j)|0,w=w+Math.imul(te,oe)|0,w=w+Math.imul(N,j)|0,I=I+Math.imul(N,oe)|0,E=E+Math.imul(ie,me)|0,w=w+Math.imul(ie,Ee)|0,w=w+Math.imul(ee,me)|0,I=I+Math.imul(ee,Ee)|0;var Tt=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,E=Math.imul(Be,St),w=Math.imul(Be,Xt),w=w+Math.imul(nt,St)|0,I=Math.imul(nt,Xt),E=E+Math.imul(_e,Dt)|0,w=w+Math.imul(_e,Bt)|0,w=w+Math.imul(Qe,Dt)|0,I=I+Math.imul(Qe,Bt)|0,E=E+Math.imul(Oe,gt)|0,w=w+Math.imul(Oe,Ot)|0,w=w+Math.imul($e,gt)|0,I=I+Math.imul($e,Ot)|0,E=E+Math.imul(Me,bt)|0,w=w+Math.imul(Me,jt)|0,w=w+Math.imul(Ne,bt)|0,I=I+Math.imul(Ne,jt)|0,E=E+Math.imul(De,tt)|0,w=w+Math.imul(De,Ft)|0,w=w+Math.imul(Te,tt)|0,I=I+Math.imul(Te,Ft)|0,E=E+Math.imul(fe,G)|0,w=w+Math.imul(fe,J)|0,w=w+Math.imul(be,G)|0,I=I+Math.imul(be,J)|0,E=E+Math.imul(ne,j)|0,w=w+Math.imul(ne,oe)|0,w=w+Math.imul(de,j)|0,I=I+Math.imul(de,oe)|0,E=E+Math.imul(te,me)|0,w=w+Math.imul(te,Ee)|0,w=w+Math.imul(N,me)|0,I=I+Math.imul(N,Ee)|0;var mt=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(mt>>>26)|0,mt&=67108863,E=Math.imul(Be,Dt),w=Math.imul(Be,Bt),w=w+Math.imul(nt,Dt)|0,I=Math.imul(nt,Bt),E=E+Math.imul(_e,gt)|0,w=w+Math.imul(_e,Ot)|0,w=w+Math.imul(Qe,gt)|0,I=I+Math.imul(Qe,Ot)|0,E=E+Math.imul(Oe,bt)|0,w=w+Math.imul(Oe,jt)|0,w=w+Math.imul($e,bt)|0,I=I+Math.imul($e,jt)|0,E=E+Math.imul(Me,tt)|0,w=w+Math.imul(Me,Ft)|0,w=w+Math.imul(Ne,tt)|0,I=I+Math.imul(Ne,Ft)|0,E=E+Math.imul(De,G)|0,w=w+Math.imul(De,J)|0,w=w+Math.imul(Te,G)|0,I=I+Math.imul(Te,J)|0,E=E+Math.imul(fe,j)|0,w=w+Math.imul(fe,oe)|0,w=w+Math.imul(be,j)|0,I=I+Math.imul(be,oe)|0,E=E+Math.imul(ne,me)|0,w=w+Math.imul(ne,Ee)|0,w=w+Math.imul(de,me)|0,I=I+Math.imul(de,Ee)|0;var Et=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(Et>>>26)|0,Et&=67108863,E=Math.imul(Be,gt),w=Math.imul(Be,Ot),w=w+Math.imul(nt,gt)|0,I=Math.imul(nt,Ot),E=E+Math.imul(_e,bt)|0,w=w+Math.imul(_e,jt)|0,w=w+Math.imul(Qe,bt)|0,I=I+Math.imul(Qe,jt)|0,E=E+Math.imul(Oe,tt)|0,w=w+Math.imul(Oe,Ft)|0,w=w+Math.imul($e,tt)|0,I=I+Math.imul($e,Ft)|0,E=E+Math.imul(Me,G)|0,w=w+Math.imul(Me,J)|0,w=w+Math.imul(Ne,G)|0,I=I+Math.imul(Ne,J)|0,E=E+Math.imul(De,j)|0,w=w+Math.imul(De,oe)|0,w=w+Math.imul(Te,j)|0,I=I+Math.imul(Te,oe)|0,E=E+Math.imul(fe,me)|0,w=w+Math.imul(fe,Ee)|0,w=w+Math.imul(be,me)|0,I=I+Math.imul(be,Ee)|0;var ct=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(ct>>>26)|0,ct&=67108863,E=Math.imul(Be,bt),w=Math.imul(Be,jt),w=w+Math.imul(nt,bt)|0,I=Math.imul(nt,jt),E=E+Math.imul(_e,tt)|0,w=w+Math.imul(_e,Ft)|0,w=w+Math.imul(Qe,tt)|0,I=I+Math.imul(Qe,Ft)|0,E=E+Math.imul(Oe,G)|0,w=w+Math.imul(Oe,J)|0,w=w+Math.imul($e,G)|0,I=I+Math.imul($e,J)|0,E=E+Math.imul(Me,j)|0,w=w+Math.imul(Me,oe)|0,w=w+Math.imul(Ne,j)|0,I=I+Math.imul(Ne,oe)|0,E=E+Math.imul(De,me)|0,w=w+Math.imul(De,Ee)|0,w=w+Math.imul(Te,me)|0,I=I+Math.imul(Te,Ee)|0;var wt=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(wt>>>26)|0,wt&=67108863,E=Math.imul(Be,tt),w=Math.imul(Be,Ft),w=w+Math.imul(nt,tt)|0,I=Math.imul(nt,Ft),E=E+Math.imul(_e,G)|0,w=w+Math.imul(_e,J)|0,w=w+Math.imul(Qe,G)|0,I=I+Math.imul(Qe,J)|0,E=E+Math.imul(Oe,j)|0,w=w+Math.imul(Oe,oe)|0,w=w+Math.imul($e,j)|0,I=I+Math.imul($e,oe)|0,E=E+Math.imul(Me,me)|0,w=w+Math.imul(Me,Ee)|0,w=w+Math.imul(Ne,me)|0,I=I+Math.imul(Ne,Ee)|0;var lt=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(lt>>>26)|0,lt&=67108863,E=Math.imul(Be,G),w=Math.imul(Be,J),w=w+Math.imul(nt,G)|0,I=Math.imul(nt,J),E=E+Math.imul(_e,j)|0,w=w+Math.imul(_e,oe)|0,w=w+Math.imul(Qe,j)|0,I=I+Math.imul(Qe,oe)|0,E=E+Math.imul(Oe,me)|0,w=w+Math.imul(Oe,Ee)|0,w=w+Math.imul($e,me)|0,I=I+Math.imul($e,Ee)|0;var st=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(st>>>26)|0,st&=67108863,E=Math.imul(Be,j),w=Math.imul(Be,oe),w=w+Math.imul(nt,j)|0,I=Math.imul(nt,oe),E=E+Math.imul(_e,me)|0,w=w+Math.imul(_e,Ee)|0,w=w+Math.imul(Qe,me)|0,I=I+Math.imul(Qe,Ee)|0;var Ae=(A+E|0)+((w&8191)<<13)|0;A=(I+(w>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,E=Math.imul(Be,me),w=Math.imul(Be,Ee),w=w+Math.imul(nt,me)|0,I=Math.imul(nt,Ee);var Ie=(A+E|0)+((w&8191)<<13)|0;return A=(I+(w>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,y[0]=ke,y[1]=Ce,y[2]=et,y[3]=Ze,y[4]=rt,y[5]=ot,y[6]=yt,y[7]=Rt,y[8]=Mt,y[9]=xt,y[10]=Tt,y[11]=mt,y[12]=Et,y[13]=ct,y[14]=wt,y[15]=lt,y[16]=st,y[17]=Ae,y[18]=Ie,A!==0&&(y[19]=A,l.length++),l};Math.imul||(C=S);function D(q,_,v){v.negative=_.negative^q.negative,v.length=q.length+_.length;for(var l=0,p=0,m=0;m>>26)|0,p+=y>>>26,y&=67108863}v.words[m]=A,l=y,y=p}return l!==0?v.words[m]=l:v.length--,v.strip()}function B(q,_,v){var l=new L;return l.mulp(q,_,v)}s.prototype.mulTo=function(_,v){var l,p=this.length+_.length;return this.length===10&&_.length===10?l=C(this,_,v):p<63?l=S(this,_,v):p<1024?l=D(this,_,v):l=B(this,_,v),l};function L(q,_){this.x=q,this.y=_}L.prototype.makeRBT=function(_){for(var v=new Array(_),l=s.prototype._countBits(_)-1,p=0;p<_;p++)v[p]=this.revBin(p,l,_);return v},L.prototype.revBin=function(_,v,l){if(_===0||_===l-1)return _;for(var p=0,m=0;m>=1;return p},L.prototype.permute=function(_,v,l,p,m,y){for(var A=0;A>>1)m++;return 1<>>13,l[2*y+1]=m&8191,m=m>>>13;for(y=2*v;y>=26,v+=p/67108864|0,v+=m>>>26,this.words[l]=m&67108863}return v!==0&&(this.words[l]=v,this.length++),this},s.prototype.muln=function(_){return this.clone().imuln(_)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(_){var v=x(_);if(v.length===0)return new s(1);for(var l=this,p=0;p=0);var v=_%26,l=(_-v)/26,p=67108863>>>26-v<<26-v,m;if(v!==0){var y=0;for(m=0;m>>26-v}y&&(this.words[m]=y,this.length++)}if(l!==0){for(m=this.length-1;m>=0;m--)this.words[m+l]=this.words[m];for(m=0;m=0);var p;v?p=(v-v%26)/26:p=0;var m=_%26,y=Math.min((_-m)/26,this.length),A=67108863^67108863>>>m<y)for(this.length-=y,w=0;w=0&&(I!==0||w>=p);w--){var M=this.words[w]|0;this.words[w]=I<<26-m|M>>>m,I=M&A}return E&&I!==0&&(E.words[E.length++]=I),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(_,v,l){return n(this.negative===0),this.iushrn(_,v,l)},s.prototype.shln=function(_){return this.clone().ishln(_)},s.prototype.ushln=function(_){return this.clone().iushln(_)},s.prototype.shrn=function(_){return this.clone().ishrn(_)},s.prototype.ushrn=function(_){return this.clone().iushrn(_)},s.prototype.testn=function(_){n(typeof _=="number"&&_>=0);var v=_%26,l=(_-v)/26,p=1<=0);var v=_%26,l=(_-v)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=l)return this;if(v!==0&&l++,this.length=Math.min(l,this.length),v!==0){var p=67108863^67108863>>>v<=67108864;v++)this.words[v]-=67108864,v===this.length-1?this.words[v+1]=1:this.words[v+1]++;return this.length=Math.max(this.length,v+1),this},s.prototype.isubn=function(_){if(n(typeof _=="number"),n(_<67108864),_<0)return this.iaddn(-_);if(this.negative!==0)return this.negative=0,this.iaddn(_),this.negative=1,this;if(this.words[0]-=_,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var v=0;v>26)-(E/67108864|0),this.words[m+l]=y&67108863}for(;m>26,this.words[m+l]=y&67108863;if(A===0)return this.strip();for(n(A===-1),A=0,m=0;m>26,this.words[m]=y&67108863;return this.negative=1,this.strip()},s.prototype._wordDiv=function(_,v){var l=this.length-_.length,p=this.clone(),m=_,y=m.words[m.length-1]|0,A=this._countBits(y);l=26-A,l!==0&&(m=m.ushln(l),p.iushln(l),y=m.words[m.length-1]|0);var E=p.length-m.length,w;if(v!=="mod"){w=new s(null),w.length=E+1,w.words=new Array(w.length);for(var I=0;I=0;z--){var se=(p.words[m.length+z]|0)*67108864+(p.words[m.length+z-1]|0);for(se=Math.min(se/y|0,67108863),p._ishlnsubmul(m,se,z);p.negative!==0;)se--,p.negative=0,p._ishlnsubmul(m,1,z),p.isZero()||(p.negative^=1);w&&(w.words[z]=se)}return w&&w.strip(),p.strip(),v!=="div"&&l!==0&&p.iushrn(l),{div:w||null,mod:p}},s.prototype.divmod=function(_,v,l){if(n(!_.isZero()),this.isZero())return{div:new s(0),mod:new s(0)};var p,m,y;return this.negative!==0&&_.negative===0?(y=this.neg().divmod(_,v),v!=="mod"&&(p=y.div.neg()),v!=="div"&&(m=y.mod.neg(),l&&m.negative!==0&&m.iadd(_)),{div:p,mod:m}):this.negative===0&&_.negative!==0?(y=this.divmod(_.neg(),v),v!=="mod"&&(p=y.div.neg()),{div:p,mod:y.mod}):(this.negative&_.negative)!==0?(y=this.neg().divmod(_.neg(),v),v!=="div"&&(m=y.mod.neg(),l&&m.negative!==0&&m.isub(_)),{div:y.div,mod:m}):_.length>this.length||this.cmp(_)<0?{div:new s(0),mod:this}:_.length===1?v==="div"?{div:this.divn(_.words[0]),mod:null}:v==="mod"?{div:null,mod:new s(this.modn(_.words[0]))}:{div:this.divn(_.words[0]),mod:new s(this.modn(_.words[0]))}:this._wordDiv(_,v)},s.prototype.div=function(_){return this.divmod(_,"div",!1).div},s.prototype.mod=function(_){return this.divmod(_,"mod",!1).mod},s.prototype.umod=function(_){return this.divmod(_,"mod",!0).mod},s.prototype.divRound=function(_){var v=this.divmod(_);if(v.mod.isZero())return v.div;var l=v.div.negative!==0?v.mod.isub(_):v.mod,p=_.ushrn(1),m=_.andln(1),y=l.cmp(p);return y<0||m===1&&y===0?v.div:v.div.negative!==0?v.div.isubn(1):v.div.iaddn(1)},s.prototype.modn=function(_){n(_<=67108863);for(var v=(1<<26)%_,l=0,p=this.length-1;p>=0;p--)l=(v*l+(this.words[p]|0))%_;return l},s.prototype.idivn=function(_){n(_<=67108863);for(var v=0,l=this.length-1;l>=0;l--){var p=(this.words[l]|0)+v*67108864;this.words[l]=p/_|0,v=p%_}return this.strip()},s.prototype.divn=function(_){return this.clone().idivn(_)},s.prototype.egcd=function(_){n(_.negative===0),n(!_.isZero());var v=this,l=_.clone();v.negative!==0?v=v.umod(_):v=v.clone();for(var p=new s(1),m=new s(0),y=new s(0),A=new s(1),E=0;v.isEven()&&l.isEven();)v.iushrn(1),l.iushrn(1),++E;for(var w=l.clone(),I=v.clone();!v.isZero();){for(var M=0,z=1;(v.words[0]&z)===0&&M<26;++M,z<<=1);if(M>0)for(v.iushrn(M);M-- >0;)(p.isOdd()||m.isOdd())&&(p.iadd(w),m.isub(I)),p.iushrn(1),m.iushrn(1);for(var se=0,O=1;(l.words[0]&O)===0&&se<26;++se,O<<=1);if(se>0)for(l.iushrn(se);se-- >0;)(y.isOdd()||A.isOdd())&&(y.iadd(w),A.isub(I)),y.iushrn(1),A.iushrn(1);v.cmp(l)>=0?(v.isub(l),p.isub(y),m.isub(A)):(l.isub(v),y.isub(p),A.isub(m))}return{a:y,b:A,gcd:l.iushln(E)}},s.prototype._invmp=function(_){n(_.negative===0),n(!_.isZero());var v=this,l=_.clone();v.negative!==0?v=v.umod(_):v=v.clone();for(var p=new s(1),m=new s(0),y=l.clone();v.cmpn(1)>0&&l.cmpn(1)>0;){for(var A=0,E=1;(v.words[0]&E)===0&&A<26;++A,E<<=1);if(A>0)for(v.iushrn(A);A-- >0;)p.isOdd()&&p.iadd(y),p.iushrn(1);for(var w=0,I=1;(l.words[0]&I)===0&&w<26;++w,I<<=1);if(w>0)for(l.iushrn(w);w-- >0;)m.isOdd()&&m.iadd(y),m.iushrn(1);v.cmp(l)>=0?(v.isub(l),p.isub(m)):(l.isub(v),m.isub(p))}var M;return v.cmpn(1)===0?M=p:M=m,M.cmpn(0)<0&&M.iadd(_),M},s.prototype.gcd=function(_){if(this.isZero())return _.abs();if(_.isZero())return this.abs();var v=this.clone(),l=_.clone();v.negative=0,l.negative=0;for(var p=0;v.isEven()&&l.isEven();p++)v.iushrn(1),l.iushrn(1);do{for(;v.isEven();)v.iushrn(1);for(;l.isEven();)l.iushrn(1);var m=v.cmp(l);if(m<0){var y=v;v=l,l=y}else if(m===0||l.cmpn(1)===0)break;v.isub(l)}while(!0);return l.iushln(p)},s.prototype.invm=function(_){return this.egcd(_).a.umod(_)},s.prototype.isEven=function(){return(this.words[0]&1)===0},s.prototype.isOdd=function(){return(this.words[0]&1)===1},s.prototype.andln=function(_){return this.words[0]&_},s.prototype.bincn=function(_){n(typeof _=="number");var v=_%26,l=(_-v)/26,p=1<>>26,A&=67108863,this.words[y]=A}return m!==0&&(this.words[y]=m,this.length++),this},s.prototype.isZero=function(){return this.length===1&&this.words[0]===0},s.prototype.cmpn=function(_){var v=_<0;if(this.negative!==0&&!v)return-1;if(this.negative===0&&v)return 1;this.strip();var l;if(this.length>1)l=1;else{v&&(_=-_),n(_<=67108863,"Number is too big");var p=this.words[0]|0;l=p===_?0:p<_?-1:1}return this.negative!==0?-l|0:l},s.prototype.cmp=function(_){if(this.negative!==0&&_.negative===0)return-1;if(this.negative===0&&_.negative!==0)return 1;var v=this.ucmp(_);return this.negative!==0?-v|0:v},s.prototype.ucmp=function(_){if(this.length>_.length)return 1;if(this.length<_.length)return-1;for(var v=0,l=this.length-1;l>=0;l--){var p=this.words[l]|0,m=_.words[l]|0;if(p!==m){pm&&(v=1);break}}return v},s.prototype.gtn=function(_){return this.cmpn(_)===1},s.prototype.gt=function(_){return this.cmp(_)===1},s.prototype.gten=function(_){return this.cmpn(_)>=0},s.prototype.gte=function(_){return this.cmp(_)>=0},s.prototype.ltn=function(_){return this.cmpn(_)===-1},s.prototype.lt=function(_){return this.cmp(_)===-1},s.prototype.lten=function(_){return this.cmpn(_)<=0},s.prototype.lte=function(_){return this.cmp(_)<=0},s.prototype.eqn=function(_){return this.cmpn(_)===0},s.prototype.eq=function(_){return this.cmp(_)===0},s.red=function(_){return new V(_)},s.prototype.toRed=function(_){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),_.convertTo(this)._forceRed(_)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(_){return this.red=_,this},s.prototype.forceRed=function(_){return n(!this.red,"Already a number in reduction context"),this._forceRed(_)},s.prototype.redAdd=function(_){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,_)},s.prototype.redIAdd=function(_){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,_)},s.prototype.redSub=function(_){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,_)},s.prototype.redISub=function(_){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,_)},s.prototype.redShl=function(_){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,_)},s.prototype.redMul=function(_){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,_),this.red.mul(this,_)},s.prototype.redIMul=function(_){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,_),this.red.imul(this,_)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(_){return n(this.red&&!_.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,_)};var H={k256:null,p224:null,p192:null,p25519:null};function F(q,_){this.name=q,this.p=new s(_,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}F.prototype._tmp=function(){var _=new s(null);return _.words=new Array(Math.ceil(this.n/13)),_},F.prototype.ireduce=function(_){var v=_,l;do this.split(v,this.tmp),v=this.imulK(v),v=v.iadd(this.tmp),l=v.bitLength();while(l>this.n);var p=l0?v.isub(this.p):v.strip!==void 0?v.strip():v._strip(),v},F.prototype.split=function(_,v){_.iushrn(this.n,0,v)},F.prototype.imulK=function(_){return _.imul(this.k)};function k(){F.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(k,F),k.prototype.split=function(_,v){for(var l=4194303,p=Math.min(_.length,9),m=0;m>>22,y=A}y>>>=22,_.words[m-10]=y,y===0&&_.length>10?_.length-=10:_.length-=9},k.prototype.imulK=function(_){_.words[_.length]=0,_.words[_.length+1]=0,_.length+=2;for(var v=0,l=0;l<_.length;l++){var p=_.words[l]|0;v+=p*977,_.words[l]=v&67108863,v=p*64+(v/67108864|0)}return _.words[_.length-1]===0&&(_.length--,_.words[_.length-1]===0&&_.length--),_};function $(){F.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i($,F);function R(){F.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(R,F);function W(){F.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(W,F),W.prototype.imulK=function(_){for(var v=0,l=0;l<_.length;l++){var p=(_.words[l]|0)*19+v,m=p&67108863;p>>>=26,_.words[l]=m,v=p}return v!==0&&(_.words[_.length++]=v),_},s._prime=function(_){if(H[_])return H[_];var v;if(_==="k256")v=new k;else if(_==="p224")v=new $;else if(_==="p192")v=new R;else if(_==="p25519")v=new W;else throw new Error("Unknown prime "+_);return H[_]=v,v};function V(q){if(typeof q=="string"){var _=s._prime(q);this.m=_.p,this.prime=_}else n(q.gtn(1),"modulus must be greater than 1"),this.m=q,this.prime=null}V.prototype._verify1=function(_){n(_.negative===0,"red works only with positives"),n(_.red,"red works only with red numbers")},V.prototype._verify2=function(_,v){n((_.negative|v.negative)===0,"red works only with positives"),n(_.red&&_.red===v.red,"red works only with red numbers")},V.prototype.imod=function(_){return this.prime?this.prime.ireduce(_)._forceRed(this):_.umod(this.m)._forceRed(this)},V.prototype.neg=function(_){return _.isZero()?_.clone():this.m.sub(_)._forceRed(this)},V.prototype.add=function(_,v){this._verify2(_,v);var l=_.add(v);return l.cmp(this.m)>=0&&l.isub(this.m),l._forceRed(this)},V.prototype.iadd=function(_,v){this._verify2(_,v);var l=_.iadd(v);return l.cmp(this.m)>=0&&l.isub(this.m),l},V.prototype.sub=function(_,v){this._verify2(_,v);var l=_.sub(v);return l.cmpn(0)<0&&l.iadd(this.m),l._forceRed(this)},V.prototype.isub=function(_,v){this._verify2(_,v);var l=_.isub(v);return l.cmpn(0)<0&&l.iadd(this.m),l},V.prototype.shl=function(_,v){return this._verify1(_),this.imod(_.ushln(v))},V.prototype.imul=function(_,v){return this._verify2(_,v),this.imod(_.imul(v))},V.prototype.mul=function(_,v){return this._verify2(_,v),this.imod(_.mul(v))},V.prototype.isqr=function(_){return this.imul(_,_.clone())},V.prototype.sqr=function(_){return this.mul(_,_)},V.prototype.sqrt=function(_){if(_.isZero())return _.clone();var v=this.m.andln(3);if(n(v%2===1),v===3){var l=this.m.add(new s(1)).iushrn(2);return this.pow(_,l)}for(var p=this.m.subn(1),m=0;!p.isZero()&&p.andln(1)===0;)m++,p.iushrn(1);n(!p.isZero());var y=new s(1).toRed(this),A=y.redNeg(),E=this.m.subn(1).iushrn(1),w=this.m.bitLength();for(w=new s(2*w*w).toRed(this);this.pow(w,E).cmp(A)!==0;)w.redIAdd(A);for(var I=this.pow(w,p),M=this.pow(_,p.addn(1).iushrn(1)),z=this.pow(_,p),se=m;z.cmp(y)!==0;){for(var O=z,ie=0;O.cmp(y)!==0;ie++)O=O.redSqr();n(ie=0;m--){for(var I=v.words[m],M=w-1;M>=0;M--){var z=I>>M&1;if(y!==p[0]&&(y=this.sqr(y)),z===0&&A===0){E=0;continue}A<<=1,A|=z,E++,!(E!==l&&(m!==0||M!==0))&&(y=this.mul(y,p[A]),E=0,A=0)}w=26}return y},V.prototype.convertTo=function(_){var v=_.umod(this.m);return v===_?v.clone():v},V.prototype.convertFrom=function(_){var v=_.clone();return v.red=null,v},s.mont=function(_){return new X(_)};function X(q){V.call(this,q),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new s(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(X,V),X.prototype.convertTo=function(_){return this.imod(_.ushln(this.shift))},X.prototype.convertFrom=function(_){var v=this.imod(_.mul(this.rinv));return v.red=null,v},X.prototype.imul=function(_,v){if(_.isZero()||v.isZero())return _.words[0]=0,_.length=1,_;var l=_.imul(v),p=l.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=l.isub(p).iushrn(this.shift),y=m;return m.cmp(this.m)>=0?y=m.isub(this.m):m.cmpn(0)<0&&(y=m.iadd(this.m)),y._forceRed(this)},X.prototype.mul=function(_,v){if(_.isZero()||v.isZero())return new s(0)._forceRed(this);var l=_.mul(v),p=l.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=l.isub(p).iushrn(this.shift),y=m;return m.cmp(this.m)>=0?y=m.isub(this.m):m.cmpn(0)<0&&(y=m.iadd(this.m)),y._forceRed(this)},X.prototype.invm=function(_){var v=this.imod(_._invmp(this.m).mul(this.r2));return v._forceRed(this)}})(t,XO)})(Lh)),Lh.exports}var Gg={},Zx;function Qx(){return Zx||(Zx=1,(function(t){var e=t;function r(s,o){if(Array.isArray(s))return s.slice();if(!s)return[];var a=[];if(typeof s!="string"){for(var f=0;f>8,g=u&255;h?a.push(h,g):a.push(g)}return a}e.toArray=r;function n(s){return s.length===1?"0"+s:s}e.zero2=n;function i(s){for(var o="",a=0;a(C>>1)-1?B=(C>>1)-L:B=L,D.isubn(B)):B=0,x[S]=B,D.iushrn(1)}return x}e.getNAF=s;function o(h,g){var b=[[],[]];h=h.clone(),g=g.clone();for(var x=0,S=0,C;h.cmpn(-x)>0||g.cmpn(-S)>0;){var D=h.andln(3)+x&3,B=g.andln(3)+S&3;D===3&&(D=-1),B===3&&(B=-1);var L;(D&1)===0?L=0:(C=h.andln(7)+x&7,(C===3||C===5)&&B===2?L=-D:L=D),b[0].push(L);var H;(B&1)===0?H=0:(C=g.andln(7)+S&7,(C===3||C===5)&&D===2?H=-B:H=B),b[1].push(H),2*x===L+1&&(x=1-x),2*S===H+1&&(S=1-S),h.iushrn(1),g.iushrn(1)}return b}e.getJSF=o;function a(h,g,b){var x="_"+g;h.prototype[g]=function(){return this[x]!==void 0?this[x]:this[x]=b.call(this)}}e.cachedProperty=a;function f(h){return typeof h=="string"?e.toArray(h,"hex"):h}e.parseBytes=f;function u(h){return new r(h,"hex","le")}e.intFromLE=u})(Vg)),Vg}var kh={exports:{}},t3;function r3(){if(t3)return kh.exports;t3=1;var t;kh.exports=function(i){return t||(t=new e(null)),t.generate(i)};function e(n){this.rand=n}if(kh.exports.Rand=e,e.prototype.generate=function(i){return this._rand(i)},e.prototype._rand=function(i){if(this.rand.getBytes)return this.rand.getBytes(i);for(var s=new Uint8Array(i),o=0;o0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Jg=s,s.prototype.point=function(){throw new Error("Not implemented")},s.prototype.validate=function(){throw new Error("Not implemented")},s.prototype._fixedNafMul=function(f,u){i(f.precomputed);var h=f._getDoubles(),g=r(u,1,this._bitLength),b=(1<=S;D--)C=(C<<1)+g[D];x.push(C)}for(var B=this.jpoint(null,null,null),L=this.jpoint(null,null,null),H=b;H>0;H--){for(S=0;S=0;C--){for(var D=0;C>=0&&x[C]===0;C--)D++;if(C>=0&&D++,S=S.dblp(D),C<0)break;var B=x[C];i(B!==0),f.type==="affine"?B>0?S=S.mixedAdd(b[B-1>>1]):S=S.mixedAdd(b[-B-1>>1].neg()):B>0?S=S.add(b[B-1>>1]):S=S.add(b[-B-1>>1].neg())}return f.type==="affine"?S.toP():S},s.prototype._wnafMulAdd=function(f,u,h,g,b){var x=this._wnafT1,S=this._wnafT2,C=this._wnafT3,D=0,B,L,H;for(B=0;B=1;B-=2){var k=B-1,$=B;if(x[k]!==1||x[$]!==1){C[k]=r(h[k],x[k],this._bitLength),C[$]=r(h[$],x[$],this._bitLength),D=Math.max(C[k].length,D),D=Math.max(C[$].length,D);continue}var R=[u[k],null,null,u[$]];u[k].y.cmp(u[$].y)===0?(R[1]=u[k].add(u[$]),R[2]=u[k].toJ().mixedAdd(u[$].neg())):u[k].y.cmp(u[$].y.redNeg())===0?(R[1]=u[k].toJ().mixedAdd(u[$]),R[2]=u[k].add(u[$].neg())):(R[1]=u[k].toJ().mixedAdd(u[$]),R[2]=u[k].toJ().mixedAdd(u[$].neg()));var W=[-3,-1,-5,-7,0,7,5,1,3],V=n(h[k],h[$]);for(D=Math.max(V[0].length,D),C[k]=new Array(D),C[$]=new Array(D),L=0;L=0;B--){for(var l=0;B>=0;){var p=!0;for(L=0;L=0&&l++,_=_.dblp(l),B<0)break;for(L=0;L0?H=S[L][m-1>>1]:m<0&&(H=S[L][-m-1>>1].neg()),H.type==="affine"?_=_.mixedAdd(H):_=_.add(H))}}for(B=0;B=Math.ceil((f.bitLength()+1)/u.step):!1},o.prototype._getDoubles=function(f,u){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var h=[this],g=this,b=0;b=0&&(k=B,$=L),H.negative&&(H=H.neg(),F=F.neg()),k.negative&&(k=k.neg(),$=$.neg()),[{a:H,b:F},{a:k,b:$}]},s.prototype._endoSplit=function(u){var h=this.endo.basis,g=h[0],b=h[1],x=b.b.mul(u).divRound(this.n),S=g.b.neg().mul(u).divRound(this.n),C=x.mul(g.a),D=S.mul(b.a),B=x.mul(g.b),L=S.mul(b.b),H=u.sub(C).sub(D),F=B.add(L).neg();return{k1:H,k2:F}},s.prototype.pointFromX=function(u,h){u=new e(u,16),u.red||(u=u.toRed(this.red));var g=u.redSqr().redMul(u).redIAdd(u.redMul(this.a)).redIAdd(this.b),b=g.redSqrt();if(b.redSqr().redSub(g).cmp(this.zero)!==0)throw new Error("invalid point");var x=b.fromRed().isOdd();return(h&&!x||!h&&x)&&(b=b.redNeg()),this.point(u,b)},s.prototype.validate=function(u){if(u.inf)return!0;var h=u.x,g=u.y,b=this.a.redMul(h),x=h.redSqr().redMul(h).redIAdd(b).redIAdd(this.b);return g.redSqr().redISub(x).cmpn(0)===0},s.prototype._endoWnafMulAdd=function(u,h,g){for(var b=this._endoWnafT1,x=this._endoWnafT2,S=0;S":""},o.prototype.isInfinity=function(){return this.inf},o.prototype.add=function(u){if(this.inf)return u;if(u.inf)return this;if(this.eq(u))return this.dbl();if(this.neg().eq(u))return this.curve.point(null,null);if(this.x.cmp(u.x)===0)return this.curve.point(null,null);var h=this.y.redSub(u.y);h.cmpn(0)!==0&&(h=h.redMul(this.x.redSub(u.x).redInvm()));var g=h.redSqr().redISub(this.x).redISub(u.x),b=h.redMul(this.x.redSub(g)).redISub(this.y);return this.curve.point(g,b)},o.prototype.dbl=function(){if(this.inf)return this;var u=this.y.redAdd(this.y);if(u.cmpn(0)===0)return this.curve.point(null,null);var h=this.curve.a,g=this.x.redSqr(),b=u.redInvm(),x=g.redAdd(g).redIAdd(g).redIAdd(h).redMul(b),S=x.redSqr().redISub(this.x.redAdd(this.x)),C=x.redMul(this.x.redSub(S)).redISub(this.y);return this.curve.point(S,C)},o.prototype.getX=function(){return this.x.fromRed()},o.prototype.getY=function(){return this.y.fromRed()},o.prototype.mul=function(u){return u=new e(u,16),this.isInfinity()?this:this._hasDoubles(u)?this.curve._fixedNafMul(this,u):this.curve.endo?this.curve._endoWnafMulAdd([this],[u]):this.curve._wnafMul(this,u)},o.prototype.mulAdd=function(u,h,g){var b=[this,h],x=[u,g];return this.curve.endo?this.curve._endoWnafMulAdd(b,x):this.curve._wnafMulAdd(1,b,x,2)},o.prototype.jmulAdd=function(u,h,g){var b=[this,h],x=[u,g];return this.curve.endo?this.curve._endoWnafMulAdd(b,x,!0):this.curve._wnafMulAdd(1,b,x,2,!0)},o.prototype.eq=function(u){return this===u||this.inf===u.inf&&(this.inf||this.x.cmp(u.x)===0&&this.y.cmp(u.y)===0)},o.prototype.neg=function(u){if(this.inf)return this;var h=this.curve.point(this.x,this.y.redNeg());if(u&&this.precomputed){var g=this.precomputed,b=function(x){return x.neg()};h.precomputed={naf:g.naf&&{wnd:g.naf.wnd,points:g.naf.points.map(b)},doubles:g.doubles&&{step:g.doubles.step,points:g.doubles.points.map(b)}}}return h},o.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var u=this.curve.jpoint(this.x,this.y,this.curve.one);return u};function a(f,u,h,g){n.BasePoint.call(this,f,"jacobian"),u===null&&h===null&&g===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new e(0)):(this.x=new e(u,16),this.y=new e(h,16),this.z=new e(g,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}return r(a,n.BasePoint),s.prototype.jpoint=function(u,h,g){return new a(this,u,h,g)},a.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var u=this.z.redInvm(),h=u.redSqr(),g=this.x.redMul(h),b=this.y.redMul(h).redMul(u);return this.curve.point(g,b)},a.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},a.prototype.add=function(u){if(this.isInfinity())return u;if(u.isInfinity())return this;var h=u.z.redSqr(),g=this.z.redSqr(),b=this.x.redMul(h),x=u.x.redMul(g),S=this.y.redMul(h.redMul(u.z)),C=u.y.redMul(g.redMul(this.z)),D=b.redSub(x),B=S.redSub(C);if(D.cmpn(0)===0)return B.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var L=D.redSqr(),H=L.redMul(D),F=b.redMul(L),k=B.redSqr().redIAdd(H).redISub(F).redISub(F),$=B.redMul(F.redISub(k)).redISub(S.redMul(H)),R=this.z.redMul(u.z).redMul(D);return this.curve.jpoint(k,$,R)},a.prototype.mixedAdd=function(u){if(this.isInfinity())return u.toJ();if(u.isInfinity())return this;var h=this.z.redSqr(),g=this.x,b=u.x.redMul(h),x=this.y,S=u.y.redMul(h).redMul(this.z),C=g.redSub(b),D=x.redSub(S);if(C.cmpn(0)===0)return D.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var B=C.redSqr(),L=B.redMul(C),H=g.redMul(B),F=D.redSqr().redIAdd(L).redISub(H).redISub(H),k=D.redMul(H.redISub(F)).redISub(x.redMul(L)),$=this.z.redMul(C);return this.curve.jpoint(F,k,$)},a.prototype.dblp=function(u){if(u===0)return this;if(this.isInfinity())return this;if(!u)return this.dbl();var h;if(this.curve.zeroA||this.curve.threeA){var g=this;for(h=0;h=0)return!1;if(g.redIAdd(x),this.x.cmp(g)===0)return!0}},a.prototype.inspect=function(){return this.isInfinity()?"":""},a.prototype.isInfinity=function(){return this.z.cmpn(0)===0},Xg}var Zg,s3;function QO(){if(s3)return Zg;s3=1;var t=Ks(),e=Sh(),r=Bh(),n=ki();function i(o){r.call(this,"mont",o),this.a=new t(o.a,16).toRed(this.red),this.b=new t(o.b,16).toRed(this.red),this.i4=new t(4).toRed(this.red).redInvm(),this.two=new t(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}e(i,r),Zg=i,i.prototype.validate=function(a){var f=a.normalize().x,u=f.redSqr(),h=u.redMul(f).redAdd(u.redMul(this.a)).redAdd(f),g=h.redSqrt();return g.redSqr().cmp(h)===0};function s(o,a,f){r.BasePoint.call(this,o,"projective"),a===null&&f===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new t(a,16),this.z=new t(f,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}return e(s,r.BasePoint),i.prototype.decodePoint=function(a,f){return this.point(n.toArray(a,f),1)},i.prototype.point=function(a,f){return new s(this,a,f)},i.prototype.pointFromJSON=function(a){return s.fromJSON(this,a)},s.prototype.precompute=function(){},s.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},s.fromJSON=function(a,f){return new s(a,f[0],f[1]||a.one)},s.prototype.inspect=function(){return this.isInfinity()?"":""},s.prototype.isInfinity=function(){return this.z.cmpn(0)===0},s.prototype.dbl=function(){var a=this.x.redAdd(this.z),f=a.redSqr(),u=this.x.redSub(this.z),h=u.redSqr(),g=f.redSub(h),b=f.redMul(h),x=g.redMul(h.redAdd(this.curve.a24.redMul(g)));return this.curve.point(b,x)},s.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.diffAdd=function(a,f){var u=this.x.redAdd(this.z),h=this.x.redSub(this.z),g=a.x.redAdd(a.z),b=a.x.redSub(a.z),x=b.redMul(u),S=g.redMul(h),C=f.z.redMul(x.redAdd(S).redSqr()),D=f.x.redMul(x.redISub(S).redSqr());return this.curve.point(C,D)},s.prototype.mul=function(a){for(var f=a.clone(),u=this,h=this.curve.point(null,null),g=this,b=[];f.cmpn(0)!==0;f.iushrn(1))b.push(f.andln(1));for(var x=b.length-1;x>=0;x--)b[x]===0?(u=u.diffAdd(h,g),h=h.dbl()):(h=u.diffAdd(h,g),u=u.dbl());return h},s.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},s.prototype.eq=function(a){return this.getX().cmp(a.getX())===0},s.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},s.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Zg}var Qg,o3;function eN(){if(o3)return Qg;o3=1;var t=ki(),e=Ks(),r=Sh(),n=Bh(),i=t.assert;function s(a){this.twisted=(a.a|0)!==1,this.mOneA=this.twisted&&(a.a|0)===-1,this.extended=this.mOneA,n.call(this,"edwards",a),this.a=new e(a.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new e(a.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new e(a.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),i(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(a.c|0)===1}r(s,n),Qg=s,s.prototype._mulA=function(f){return this.mOneA?f.redNeg():this.a.redMul(f)},s.prototype._mulC=function(f){return this.oneC?f:this.c.redMul(f)},s.prototype.jpoint=function(f,u,h,g){return this.point(f,u,h,g)},s.prototype.pointFromX=function(f,u){f=new e(f,16),f.red||(f=f.toRed(this.red));var h=f.redSqr(),g=this.c2.redSub(this.a.redMul(h)),b=this.one.redSub(this.c2.redMul(this.d).redMul(h)),x=g.redMul(b.redInvm()),S=x.redSqrt();if(S.redSqr().redSub(x).cmp(this.zero)!==0)throw new Error("invalid point");var C=S.fromRed().isOdd();return(u&&!C||!u&&C)&&(S=S.redNeg()),this.point(f,S)},s.prototype.pointFromY=function(f,u){f=new e(f,16),f.red||(f=f.toRed(this.red));var h=f.redSqr(),g=h.redSub(this.c2),b=h.redMul(this.d).redMul(this.c2).redSub(this.a),x=g.redMul(b.redInvm());if(x.cmp(this.zero)===0){if(u)throw new Error("invalid point");return this.point(this.zero,f)}var S=x.redSqrt();if(S.redSqr().redSub(x).cmp(this.zero)!==0)throw new Error("invalid point");return S.fromRed().isOdd()!==u&&(S=S.redNeg()),this.point(S,f)},s.prototype.validate=function(f){if(f.isInfinity())return!0;f.normalize();var u=f.x.redSqr(),h=f.y.redSqr(),g=u.redMul(this.a).redAdd(h),b=this.c2.redMul(this.one.redAdd(this.d.redMul(u).redMul(h)));return g.cmp(b)===0};function o(a,f,u,h,g){n.BasePoint.call(this,a,"projective"),f===null&&u===null&&h===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 e(f,16),this.y=new e(u,16),this.z=h?new e(h,16):this.curve.one,this.t=g&&new e(g,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()))))}return r(o,n.BasePoint),s.prototype.pointFromJSON=function(f){return o.fromJSON(this,f)},s.prototype.point=function(f,u,h,g){return new o(this,f,u,h,g)},o.fromJSON=function(f,u){return new o(f,u[0],u[1],u[2])},o.prototype.inspect=function(){return this.isInfinity()?"":""},o.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)},o.prototype._extDbl=function(){var f=this.x.redSqr(),u=this.y.redSqr(),h=this.z.redSqr();h=h.redIAdd(h);var g=this.curve._mulA(f),b=this.x.redAdd(this.y).redSqr().redISub(f).redISub(u),x=g.redAdd(u),S=x.redSub(h),C=g.redSub(u),D=b.redMul(S),B=x.redMul(C),L=b.redMul(C),H=S.redMul(x);return this.curve.point(D,B,H,L)},o.prototype._projDbl=function(){var f=this.x.redAdd(this.y).redSqr(),u=this.x.redSqr(),h=this.y.redSqr(),g,b,x,S,C,D;if(this.curve.twisted){S=this.curve._mulA(u);var B=S.redAdd(h);this.zOne?(g=f.redSub(u).redSub(h).redMul(B.redSub(this.curve.two)),b=B.redMul(S.redSub(h)),x=B.redSqr().redSub(B).redSub(B)):(C=this.z.redSqr(),D=B.redSub(C).redISub(C),g=f.redSub(u).redISub(h).redMul(D),b=B.redMul(S.redSub(h)),x=B.redMul(D))}else S=u.redAdd(h),C=this.curve._mulC(this.z).redSqr(),D=S.redSub(C).redSub(C),g=this.curve._mulC(f.redISub(S)).redMul(D),b=this.curve._mulC(S).redMul(u.redISub(h)),x=S.redMul(D);return this.curve.point(g,b,x)},o.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},o.prototype._extAdd=function(f){var u=this.y.redSub(this.x).redMul(f.y.redSub(f.x)),h=this.y.redAdd(this.x).redMul(f.y.redAdd(f.x)),g=this.t.redMul(this.curve.dd).redMul(f.t),b=this.z.redMul(f.z.redAdd(f.z)),x=h.redSub(u),S=b.redSub(g),C=b.redAdd(g),D=h.redAdd(u),B=x.redMul(S),L=C.redMul(D),H=x.redMul(D),F=S.redMul(C);return this.curve.point(B,L,F,H)},o.prototype._projAdd=function(f){var u=this.z.redMul(f.z),h=u.redSqr(),g=this.x.redMul(f.x),b=this.y.redMul(f.y),x=this.curve.d.redMul(g).redMul(b),S=h.redSub(x),C=h.redAdd(x),D=this.x.redAdd(this.y).redMul(f.x.redAdd(f.y)).redISub(g).redISub(b),B=u.redMul(S).redMul(D),L,H;return this.curve.twisted?(L=u.redMul(C).redMul(b.redSub(this.curve._mulA(g))),H=S.redMul(C)):(L=u.redMul(C).redMul(b.redSub(g)),H=this.curve._mulC(S).redMul(C)),this.curve.point(B,L,H)},o.prototype.add=function(f){return this.isInfinity()?f:f.isInfinity()?this:this.curve.extended?this._extAdd(f):this._projAdd(f)},o.prototype.mul=function(f){return this._hasDoubles(f)?this.curve._fixedNafMul(this,f):this.curve._wnafMul(this,f)},o.prototype.mulAdd=function(f,u,h){return this.curve._wnafMulAdd(1,[this,u],[f,h],2,!1)},o.prototype.jmulAdd=function(f,u,h){return this.curve._wnafMulAdd(1,[this,u],[f,h],2,!0)},o.prototype.normalize=function(){if(this.zOne)return this;var f=this.z.redInvm();return this.x=this.x.redMul(f),this.y=this.y.redMul(f),this.t&&(this.t=this.t.redMul(f)),this.z=this.curve.one,this.zOne=!0,this},o.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},o.prototype.getX=function(){return this.normalize(),this.x.fromRed()},o.prototype.getY=function(){return this.normalize(),this.y.fromRed()},o.prototype.eq=function(f){return this===f||this.getX().cmp(f.getX())===0&&this.getY().cmp(f.getY())===0},o.prototype.eqXToP=function(f){var u=f.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(u)===0)return!0;for(var h=f.clone(),g=this.curve.redN.redMul(this.z);;){if(h.iadd(this.curve.n),h.cmp(this.curve.p)>=0)return!1;if(u.redIAdd(g),this.x.cmp(u)===0)return!0}},o.prototype.toP=o.prototype.normalize,o.prototype.mixedAdd=o.prototype.add,Qg}var a3;function c3(){return a3||(a3=1,(function(t){var e=t;e.base=Bh(),e.short=ZO(),e.mont=QO(),e.edwards=eN()})(Yg)),Yg}var em={},tm,u3;function tN(){return u3||(u3=1,tm={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"]]}}),tm}var f3;function rm(){return f3||(f3=1,(function(t){var e=t,r=Ah(),n=c3(),i=ki(),s=i.assert;function o(u){u.type==="short"?this.curve=new n.short(u):u.type==="edwards"?this.curve=new n.edwards(u):this.curve=new n.mont(u),this.g=this.curve.g,this.n=this.curve.n,this.hash=u.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}e.PresetCurve=o;function a(u,h){Object.defineProperty(e,u,{configurable:!0,enumerable:!0,get:function(){var g=new o(h);return Object.defineProperty(e,u,{configurable:!0,enumerable:!0,value:g}),g}})}a("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.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("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.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("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.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("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.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"]}),a("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.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"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:r.sha256,gRed:!1,g:["9"]}),a("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.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var f;try{f=tN()}catch{f=void 0}a("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.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",f]})})(em)),em}var nm,l3;function rN(){if(l3)return nm;l3=1;var t=Ah(),e=Qx(),r=ba();function n(i){if(!(this instanceof n))return new n(i);this.hash=i.hash,this.predResist=!!i.predResist,this.outLen=this.hash.outSize,this.minEntropy=i.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var s=e.toArray(i.entropy,i.entropyEnc||"hex"),o=e.toArray(i.nonce,i.nonceEnc||"hex"),a=e.toArray(i.pers,i.persEnc||"hex");r(s.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(s,o,a)}return nm=n,n.prototype._init=function(s,o,a){var f=s.concat(o).concat(a);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var u=0;u=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(s.concat(a||[])),this._reseed=1},n.prototype.generate=function(s,o,a,f){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof o!="string"&&(f=a,a=o,o=null),a&&(a=e.toArray(a,f||"hex"),this._update(a));for(var u=[];u.length"},im}var sm,d3;function iN(){if(d3)return sm;d3=1;var t=Ks(),e=ki(),r=e.assert;function n(f,u){if(f instanceof n)return f;this._importDER(f,u)||(r(f.r&&f.s,"Signature without r or s"),this.r=new t(f.r,16),this.s=new t(f.s,16),f.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=f.recoveryParam)}sm=n;function i(){this.place=0}function s(f,u){var h=f[u.place++];if(!(h&128))return h;var g=h&15;if(g===0||g>4||f[u.place]===0)return!1;for(var b=0,x=0,S=u.place;x>>=0;return b<=127?!1:(u.place=S,b)}function o(f){for(var u=0,h=f.length-1;!f[u]&&!(f[u+1]&128)&&u>>3);for(f.push(h|128);--h;)f.push(u>>>(h<<3)&255);f.push(u)}return n.prototype.toDER=function(u){var h=this.r.toArray(),g=this.s.toArray();for(h[0]&128&&(h=[0].concat(h)),g[0]&128&&(g=[0].concat(g)),h=o(h),g=o(g);!g[0]&&!(g[1]&128);)g=g.slice(1);var b=[2];a(b,h.length),b=b.concat(h),b.push(2),a(b,g.length);var x=b.concat(g),S=[48];return a(S,x.length),S=S.concat(x),e.encode(S,u)},sm}var om,p3;function sN(){if(p3)return om;p3=1;var t=Ks(),e=rN(),r=ki(),n=rm(),i=r3(),s=r.assert,o=nN(),a=iN();function f(u){if(!(this instanceof f))return new f(u);typeof u=="string"&&(s(Object.prototype.hasOwnProperty.call(n,u),"Unknown curve "+u),u=n[u]),u instanceof n.PresetCurve&&(u={curve:u}),this.curve=u.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=u.curve.g,this.g.precompute(u.curve.n.bitLength()+1),this.hash=u.hash||u.curve.hash}return om=f,f.prototype.keyPair=function(h){return new o(this,h)},f.prototype.keyFromPrivate=function(h,g){return o.fromPrivate(this,h,g)},f.prototype.keyFromPublic=function(h,g){return o.fromPublic(this,h,g)},f.prototype.genKeyPair=function(h){h||(h={});for(var g=new e({hash:this.hash,pers:h.pers,persEnc:h.persEnc||"utf8",entropy:h.entropy||i(this.hash.hmacStrength),entropyEnc:h.entropy&&h.entropyEnc||"utf8",nonce:this.n.toArray()}),b=this.n.byteLength(),x=this.n.sub(new t(2));;){var S=new t(g.generate(b));if(!(S.cmp(x)>0))return S.iaddn(1),this.keyFromPrivate(S)}},f.prototype._truncateToN=function(h,g,b){var x;if(t.isBN(h)||typeof h=="number")h=new t(h,16),x=h.byteLength();else if(typeof h=="object")x=h.length,h=new t(h,16);else{var S=h.toString();x=S.length+1>>>1,h=new t(S,16)}typeof b!="number"&&(b=x*8);var C=b-this.n.bitLength();return C>0&&(h=h.ushrn(C)),!g&&h.cmp(this.n)>=0?h.sub(this.n):h},f.prototype.sign=function(h,g,b,x){typeof b=="object"&&(x=b,b=null),x||(x={}),g=this.keyFromPrivate(g,b),h=this._truncateToN(h,!1,x.msgBitLength);for(var S=this.n.byteLength(),C=g.getPrivate().toArray("be",S),D=h.toArray("be",S),B=new e({hash:this.hash,entropy:C,nonce:D,pers:x.pers,persEnc:x.persEnc||"utf8"}),L=this.n.sub(new t(1)),H=0;;H++){var F=x.k?x.k(H):new t(B.generate(this.n.byteLength()));if(F=this._truncateToN(F,!0),!(F.cmpn(1)<=0||F.cmp(L)>=0)){var k=this.g.mul(F);if(!k.isInfinity()){var $=k.getX(),R=$.umod(this.n);if(R.cmpn(0)!==0){var W=F.invm(this.n).mul(R.mul(g.getPrivate()).iadd(h));if(W=W.umod(this.n),W.cmpn(0)!==0){var V=(k.getY().isOdd()?1:0)|($.cmp(R)!==0?2:0);return x.canonical&&W.cmp(this.nh)>0&&(W=this.n.sub(W),V^=1),new a({r:R,s:W,recoveryParam:V})}}}}}},f.prototype.verify=function(h,g,b,x,S){S||(S={}),h=this._truncateToN(h,!1,S.msgBitLength),b=this.keyFromPublic(b,x),g=new a(g,"hex");var C=g.r,D=g.s;if(C.cmpn(1)<0||C.cmp(this.n)>=0||D.cmpn(1)<0||D.cmp(this.n)>=0)return!1;var B=D.invm(this.n),L=B.mul(h).umod(this.n),H=B.mul(C).umod(this.n),F;return this.curve._maxwellTrick?(F=this.g.jmulAdd(L,b.getPublic(),H),F.isInfinity()?!1:F.eqXToP(C)):(F=this.g.mulAdd(L,b.getPublic(),H),F.isInfinity()?!1:F.getX().umod(this.n).cmp(C)===0)},f.prototype.recoverPubKey=function(u,h,g,b){s((3&g)===g,"The recovery param is more than two bits"),h=new a(h,b);var x=this.n,S=new t(u),C=h.r,D=h.s,B=g&1,L=g>>1;if(C.cmp(this.curve.p.umod(this.curve.n))>=0&&L)throw new Error("Unable to find sencond key candinate");L?C=this.curve.pointFromX(C.add(this.curve.n),B):C=this.curve.pointFromX(C,B);var H=h.r.invm(x),F=x.sub(S).mul(H).umod(x),k=D.mul(H).umod(x);return this.g.mulAdd(F,C,k)},f.prototype.getKeyRecoveryParam=function(u,h,g,b){if(h=new a(h,b),h.recoveryParam!==null)return h.recoveryParam;for(var x=0;x<4;x++){var S;try{S=this.recoverPubKey(u,h,x)}catch{continue}if(S.eq(g))return x}throw new Error("Unable to find valid recovery factor")},om}var am,g3;function oN(){if(g3)return am;g3=1;var t=ki(),e=t.assert,r=t.parseBytes,n=t.cachedProperty;function i(s,o){this.eddsa=s,this._secret=r(o.secret),s.isPoint(o.pub)?this._pub=o.pub:this._pubBytes=r(o.pub)}return i.fromPublic=function(o,a){return a instanceof i?a:new i(o,{pub:a})},i.fromSecret=function(o,a){return a instanceof i?a:new i(o,{secret:a})},i.prototype.secret=function(){return this._secret},n(i,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),n(i,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),n(i,"privBytes",function(){var o=this.eddsa,a=this.hash(),f=o.encodingLength-1,u=a.slice(0,o.encodingLength);return u[0]&=248,u[f]&=127,u[f]|=64,u}),n(i,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),n(i,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),n(i,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),i.prototype.sign=function(o){return e(this._secret,"KeyPair can only verify"),this.eddsa.sign(o,this)},i.prototype.verify=function(o,a){return this.eddsa.verify(o,a,this)},i.prototype.getSecret=function(o){return e(this._secret,"KeyPair is public only"),t.encode(this.secret(),o)},i.prototype.getPublic=function(o){return t.encode(this.pubBytes(),o)},am=i,am}var cm,m3;function aN(){if(m3)return cm;m3=1;var t=Ks(),e=ki(),r=e.assert,n=e.cachedProperty,i=e.parseBytes;function s(o,a){this.eddsa=o,typeof a!="object"&&(a=i(a)),Array.isArray(a)&&(r(a.length===o.encodingLength*2,"Signature has invalid size"),a={R:a.slice(0,o.encodingLength),S:a.slice(o.encodingLength)}),r(a.R&&a.S,"Signature without R or S"),o.isPoint(a.R)&&(this._R=a.R),a.S instanceof t&&(this._S=a.S),this._Rencoded=Array.isArray(a.R)?a.R:a.Rencoded,this._Sencoded=Array.isArray(a.S)?a.S:a.Sencoded}return n(s,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),n(s,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),n(s,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),n(s,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),s.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},s.prototype.toHex=function(){return e.encode(this.toBytes(),"hex").toUpperCase()},cm=s,cm}var um,v3;function cN(){if(v3)return um;v3=1;var t=Ah(),e=rm(),r=ki(),n=r.assert,i=r.parseBytes,s=oN(),o=aN();function a(f){if(n(f==="ed25519","only tested with ed25519 so far"),!(this instanceof a))return new a(f);f=e[f].curve,this.curve=f,this.g=f.g,this.g.precompute(f.n.bitLength()+1),this.pointClass=f.point().constructor,this.encodingLength=Math.ceil(f.n.bitLength()/8),this.hash=t.sha512}return um=a,a.prototype.sign=function(u,h){u=i(u);var g=this.keyFromSecret(h),b=this.hashInt(g.messagePrefix(),u),x=this.g.mul(b),S=this.encodePoint(x),C=this.hashInt(S,g.pubBytes(),u).mul(g.priv()),D=b.add(C).umod(this.curve.n);return this.makeSignature({R:x,S:D,Rencoded:S})},a.prototype.verify=function(u,h,g){if(u=i(u),h=this.makeSignature(h),h.S().gte(h.eddsa.curve.n)||h.S().isNeg())return!1;var b=this.keyFromPublic(g),x=this.hashInt(h.Rencoded(),b.pubBytes(),u),S=this.g.mul(h.S()),C=h.R().add(b.pub().mul(x));return C.eq(S)},a.prototype.hashInt=function(){for(var u=this.hash(),h=0;he in t?dN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_3=(t,e)=>{for(var r in e||(e={}))pN.call(e,r)&&x3(t,r,e[r]);if(w3)for(var r of w3(e))gN.call(e,r)&&x3(t,r,e[r]);return t};const mN="ReactNative",bi={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},vN="js";function Fh(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Sc(){return!va.getDocument()&&!!va.getNavigator()&&navigator.product===mN}function uf(){return!Fh()&&!!va.getNavigator()&&!!va.getDocument()}function ff(){return Sc()?bi.reactNative:Fh()?bi.node:uf()?bi.browser:bi.unknown}function bN(){var t;try{return Sc()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function yN(t,e){let r=yh.parse(t);return r=_3(_3({},r),e),t=yh.stringify(r),t}function E3(){return HD.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function wN(){if(ff()===bi.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:r,Version:n}=global.Platform;return[r,n].join("-")}const t=BD();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function xN(){var t;const e=ff();return e===bi.browser?[e,((t=va.getLocation())==null?void 0:t.host)||"unknown"].join(":"):e}function S3(t,e,r){const n=wN(),i=xN();return[[t,e].join("-"),[vN,r].join("-"),n,i].join("/")}function _N({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s,useOnCloseEvent:o,bundleId:a}){const f=r.split("?"),u=S3(t,e,n),h={auth:i,ua:u,projectId:s,useOnCloseEvent:o,origin:a||void 0},g=yN(f[1]||"",h);return f[0]+"?"+g}function _a(t,e){return t.filter(r=>e.includes(r)).length===t.length}function A3(t){return Object.fromEntries(t.entries())}function P3(t){return new Map(Object.entries(t))}function Ea(t=vt.FIVE_MINUTES,e){const r=vt.toMiliseconds(t||vt.FIVE_MINUTES);let n,i,s;return{resolve:o=>{s&&n&&(clearTimeout(s),n(o))},reject:o=>{s&&i&&(clearTimeout(s),i(o))},done:()=>new Promise((o,a)=>{s=setTimeout(()=>{a(new Error(e))},r),n=o,i=a})}}function Ac(t,e,r){return new Promise(async(n,i)=>{const s=setTimeout(()=>i(new Error(r)),e);try{const o=await t;n(o)}catch(o){i(o)}clearTimeout(s)})}function I3(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.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: ${t}`)}function EN(t){return I3("topic",t)}function SN(t){return I3("id",t)}function M3(t){const[e,r]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")n.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return n}function wn(t,e){return vt.fromMiliseconds(Date.now()+vt.toMiliseconds(t))}function To(t){return Date.now()>=vt.toMiliseconds(t)}function yr(t,e){return`${t}${e?`:${e}`:""}`}function jh(t=[],e=[]){return[...new Set([...t,...e])]}async function AN({id:t,topic:e,wcDeepLink:r}){var n;try{if(!r)return;const i=typeof r=="string"?JSON.parse(r):r,s=i?.href;if(typeof s!="string")return;const o=PN(s,t,e),a=ff();if(a===bi.browser){if(!((n=va.getDocument())!=null&&n.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,MN()?"_blank":"_self","noreferrer noopener")}else a===bi.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(i){console.error(i)}}function PN(t,e,r){const n=`requestId=${e}&sessionTopic=${r}`;t.endsWith("/")&&(t=t.slice(0,-1));let i=`${t}`;if(t.startsWith("https://t.me")){const s=t.includes("?")?"&startapp=":"?startapp=";i=`${i}${s}${CN(n,!0)}`}else i=`${i}/wc?${n}`;return i}async function IN(t,e){let r="";try{if(uf()&&(r=localStorage.getItem(e),r))return r;r=await t.getItem(e)}catch(n){console.error(n)}return r}function C3(t,e){if(!t.includes(e))return null;const r=t.split(/([&,?,=])/),n=r.indexOf(e);return r[n+2]}function R3(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function fm(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function MN(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function CN(t,e=!1){const r=Buffer.from(t).toString("base64");return e?r.replace(/[=]/g,""):r}function T3(t){return Buffer.from(t,"base64").toString("utf-8")}const RN="https://rpc.walletconnect.org/v1";async function TN(t,e,r,n,i,s){switch(r.t){case"eip191":return DN(t,e,r.s);case"eip1271":return await ON(t,e,r.s,n,i,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function DN(t,e,r){return UO(px(e),r).toLowerCase()===t.toLowerCase()}async function ON(t,e,r,n,i,s){const o=Ec(n);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${n}`);try{const a="0x1626ba7e",f="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",h=r.substring(2),g=px(e).substring(2),b=a+g+f+u+h,x=await fetch(`${s||RN}/?chainId=${n}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:NN(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:b},"latest"]})}),{result:S}=await x.json();return S?S.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function NN(){return Date.now()+Math.floor(Math.random()*1e3)}var LN=Object.defineProperty,kN=Object.defineProperties,BN=Object.getOwnPropertyDescriptors,D3=Object.getOwnPropertySymbols,FN=Object.prototype.hasOwnProperty,jN=Object.prototype.propertyIsEnumerable,O3=(t,e,r)=>e in t?LN(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,UN=(t,e)=>{for(var r in e||(e={}))FN.call(e,r)&&O3(t,r,e[r]);if(D3)for(var r of D3(e))jN.call(e,r)&&O3(t,r,e[r]);return t},$N=(t,e)=>kN(t,BN(e));const qN="did:pkh:",lm=t=>t?.split(":"),zN=t=>{const e=t&&lm(t);if(e)return t.includes(qN)?e[3]:e[1]},hm=t=>{const e=t&&lm(t);if(e)return e[2]+":"+e[3]},Uh=t=>{const e=t&&lm(t);if(e)return e.pop()};async function N3(t){const{cacao:e,projectId:r}=t,{s:n,p:i}=e,s=L3(i,i.iss),o=Uh(i.iss);return await TN(o,s,n,hm(i.iss),r)}const L3=(t,e)=>{const r=`${t.domain} wants you to sign in with your Ethereum account:`,n=Uh(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let i=t.statement||void 0;const s=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${zN(e)}`,f=`Nonce: ${t.nonce}`,u=`Issued At: ${t.iat}`,h=t.exp?`Expiration Time: ${t.exp}`:void 0,g=t.nbf?`Not Before: ${t.nbf}`:void 0,b=t.requestId?`Request ID: ${t.requestId}`:void 0,x=t.resources?`Resources:${t.resources.map(C=>` +- ${C}`).join("")}`:void 0,S=$h(t.resources);if(S){const C=lf(S);i=ZN(i,C)}return[r,n,"",i,"",s,o,a,f,u,h,g,b,x].filter(C=>C!=null).join(` +`)};function HN(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function WN(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function Sa(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{const n=t.att[r];if(Array.isArray(n))throw new Error(`Resource must be an object: ${r}`);if(typeof n!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(n).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(n).forEach(i=>{const s=n[i];if(!Array.isArray(s))throw new Error(`Ability limits ${i} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${i} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${i}) must be an array of objects, found: ${o}`)})})})}function KN(t,e,r,n={}){return r?.sort((i,s)=>i.localeCompare(s)),{att:{[t]:VN(e,r,n)}}}function VN(t,e,r={}){e=e?.sort((i,s)=>i.localeCompare(s));const n=e.map(i=>({[`${t}/${i}`]:[r]}));return Object.assign({},...n)}function k3(t){return Sa(t),`urn:recap:${HN(t).replace(/=/g,"")}`}function lf(t){const e=WN(t.replace("urn:recap:",""));return Sa(e),e}function GN(t,e,r){const n=KN(t,e,r);return k3(n)}function YN(t){return t&&t.includes("urn:recap:")}function JN(t,e){const r=lf(t),n=lf(e),i=XN(r,n);return k3(i)}function XN(t,e){Sa(t),Sa(e);const r=Object.keys(t.att).concat(Object.keys(e.att)).sort((i,s)=>i.localeCompare(s)),n={att:{}};return r.forEach(i=>{var s,o;Object.keys(((s=t.att)==null?void 0:s[i])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[i])||{})).sort((a,f)=>a.localeCompare(f)).forEach(a=>{var f,u;n.att[i]=$N(UN({},n.att[i]),{[a]:((f=t.att[i])==null?void 0:f[a])||((u=e.att[i])==null?void 0:u[a])})})}),n}function ZN(t="",e){Sa(e);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(r))return t;const n=[];let i=0;Object.keys(e.att).forEach(a=>{const f=Object.keys(e.att[a]).map(g=>({ability:g.split("/")[0],action:g.split("/")[1]}));f.sort((g,b)=>g.action.localeCompare(b.action));const u={};f.forEach(g=>{u[g.ability]||(u[g.ability]=[]),u[g.ability].push(g.action)});const h=Object.keys(u).map(g=>(i++,`(${i}) '${g}': '${u[g].join("', '")}' for '${a}'.`));n.push(h.join(", ").replace(".,","."))});const s=n.join(" "),o=`${r}${s}`;return`${t?t+" ":""}${o}`}function B3(t){var e;const r=lf(t);Sa(r);const n=(e=r.att)==null?void 0:e.eip155;return n?Object.keys(n).map(i=>i.split("/")[1]):[]}function F3(t){const e=lf(t);Sa(e);const r=[];return Object.values(e.att).forEach(n=>{Object.values(n).forEach(i=>{var s;(s=i?.[0])!=null&&s.chains&&r.push(i[0].chains)})}),[...new Set(r.flat())]}function $h(t){if(!t)return;const e=t?.[t.length-1];return YN(e)?e:void 0}const j3="base10",Gn="base16",Do="base64pad",hf="base64url",df="utf8",U3=0,Vs=1,pf=2,QN=0,$3=1,gf=12,dm=32;function eL(){const t=Jx.generateKeyPair();return{privateKey:An(t.secretKey,Gn),publicKey:An(t.publicKey,Gn)}}function pm(){const t=tf.randomBytes(dm);return An(t,Gn)}function tL(t,e){const r=Jx.sharedKey(Pn(t,Gn),Pn(e,Gn),!0),n=new VO.HKDF(Nh.SHA256,r).expand(dm);return An(n,Gn)}function qh(t){const e=Nh.hash(Pn(t,Gn));return An(e,Gn)}function Gs(t){const e=Nh.hash(Pn(t,df));return An(e,Gn)}function q3(t){return Pn(`${t}`,j3)}function Aa(t){return Number(An(t,j3))}function rL(t){const e=q3(typeof t.type<"u"?t.type:U3);if(Aa(e)===Vs&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?Pn(t.senderPublicKey,Gn):void 0,n=typeof t.iv<"u"?Pn(t.iv,Gn):tf.randomBytes(gf),i=new Hx.ChaCha20Poly1305(Pn(t.symKey,Gn)).seal(n,Pn(t.message,df));return z3({type:e,sealed:i,iv:n,senderPublicKey:r,encoding:t.encoding})}function nL(t,e){const r=q3(pf),n=tf.randomBytes(gf),i=Pn(t,df);return z3({type:r,sealed:i,iv:n,encoding:e})}function iL(t){const e=new Hx.ChaCha20Poly1305(Pn(t.symKey,Gn)),{sealed:r,iv:n}=mf({encoded:t.encoded,encoding:t?.encoding}),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return An(i,df)}function sL(t,e){const{sealed:r}=mf({encoded:t,encoding:e});return An(r,df)}function z3(t){const{encoding:e=Do}=t;if(Aa(t.type)===pf)return An(mh([t.type,t.sealed]),e);if(Aa(t.type)===Vs){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return An(mh([t.type,t.senderPublicKey,t.iv,t.sealed]),e)}return An(mh([t.type,t.iv,t.sealed]),e)}function mf(t){const{encoded:e,encoding:r=Do}=t,n=Pn(e,r),i=n.slice(QN,$3),s=$3;if(Aa(i)===Vs){const u=s+dm,h=u+gf,g=n.slice(s,u),b=n.slice(u,h),x=n.slice(h);return{type:i,sealed:x,iv:b,senderPublicKey:g}}if(Aa(i)===pf){const u=n.slice(s),h=tf.randomBytes(gf);return{type:i,sealed:u,iv:h}}const o=s+gf,a=n.slice(s,o),f=n.slice(o);return{type:i,sealed:f,iv:a}}function oL(t,e){const r=mf({encoded:t,encoding:e?.encoding});return H3({type:Aa(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?An(r.senderPublicKey,Gn):void 0,receiverPublicKey:e?.receiverPublicKey})}function H3(t){const e=t?.type||U3;if(e===Vs){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function W3(t){return t.type===Vs&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function K3(t){return t.type===pf}function aL(t){return new fN.ec("p256").keyFromPublic({x:Buffer.from(t.x,"base64").toString("hex"),y:Buffer.from(t.y,"base64").toString("hex")},"hex")}function cL(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");const r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function uL(t){return Buffer.from(cL(t),"base64")}function fL(t,e){const[r,n,i]=t.split("."),s=uL(i);if(s.length!==64)throw new Error("Invalid signature length");const o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),f=`${r}.${n}`,u=new Nh.SHA256().update(Buffer.from(f)).digest(),h=aL(e),g=Buffer.from(u).toString("hex");if(!h.verify(g,{r:o,s:a}))throw new Error("Invalid signature");return ug(t).payload}const lL="irn";function gm(t){return t?.relay||{protocol:lL}}function vf(t){const e=lN[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var hL=Object.defineProperty,dL=Object.defineProperties,pL=Object.getOwnPropertyDescriptors,V3=Object.getOwnPropertySymbols,gL=Object.prototype.hasOwnProperty,mL=Object.prototype.propertyIsEnumerable,G3=(t,e,r)=>e in t?hL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Y3=(t,e)=>{for(var r in e||(e={}))gL.call(e,r)&&G3(t,r,e[r]);if(V3)for(var r of V3(e))mL.call(e,r)&&G3(t,r,e[r]);return t},vL=(t,e)=>dL(t,pL(e));function bL(t,e="-"){const r={},n="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),o=t[i];r[s]=o}}),r}function J3(t){if(!t.includes("wc:")){const f=T3(t);f!=null&&f.includes("wc:")&&(t=f)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),i=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",o=yh.parse(s),a=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:n,topic:yL(i[0]),version:parseInt(i[1],10),symKey:o.symKey,relay:bL(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function yL(t){return t.startsWith("//")?t.substring(2):t}function wL(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=r+e+i;t[i]&&(n[s]=t[i])}),n}function X3(t){return`${t.protocol}:${t.topic}@${t.version}?`+yh.stringify(Y3(vL(Y3({symKey:t.symKey},wL(t.relay)),{expiryTimestamp:t.expiryTimestamp}),t.methods?{methods:t.methods.join(",")}:{}))}function zh(t,e,r){return`${t}?wc_ev=${r}&topic=${e}`}function Pc(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function xL(t){const e=[];return Object.values(t).forEach(r=>{e.push(...Pc(r.accounts))}),e}function _L(t,e){const r=[];return Object.values(t).forEach(n=>{Pc(n.accounts).includes(e)&&r.push(...n.methods)}),r}function EL(t,e){const r=[];return Object.values(t).forEach(n=>{Pc(n.accounts).includes(e)&&r.push(...n.events)}),r}function mm(t){return t.includes(":")}function bf(t){return mm(t)?t.split(":")[0]:t}function SL(t){const e={};return t?.forEach(r=>{const[n,i]=r.split(":");e[n]||(e[n]={accounts:[],chains:[],events:[]}),e[n].accounts.push(r),e[n].chains.push(`${n}:${i}`)}),e}function Z3(t,e){e=e.map(n=>n.replace("did:pkh:",""));const r=SL(e);for(const[n,i]of Object.entries(r))i.methods?i.methods=jh(i.methods,t):i.methods=t,i.events=["chainChanged","accountsChanged"];return r}const AL={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}},PL={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 ut(t,e){const{message:r,code:n}=PL[t];return{message:e?`${r} ${e}`:r,code:n}}function Dr(t,e){const{message:r,code:n}=AL[t];return{message:e?`${r} ${e}`:r,code:n}}function Pa(t,e){return!!Array.isArray(t)}function yf(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Yn(t){return typeof t>"u"}function nn(t,e){return e&&Yn(t)?!0:typeof t=="string"&&!!t.trim().length}function vm(t,e){return e&&Yn(t)?!0:typeof t=="number"&&!isNaN(t)}function IL(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return _a(i,n)?(n.forEach(o=>{const{accounts:a,methods:f,events:u}=t.namespaces[o],h=Pc(a),g=r[o];(!_a(y3(o,g),h)||!_a(g.methods,f)||!_a(g.events,u))&&(s=!1)}),s):!1}function Hh(t){return nn(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function ML(t){if(nn(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&Hh(r)}}return!1}function CL(t){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(nn(t,!1)){if(e(t))return!0;const r=T3(t);return e(r)}}catch{}return!1}function RL(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function TL(t){return t?.topic}function DL(t,e){let r=null;return nn(t?.publicKey,!1)||(r=ut("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Q3(t){let e=!0;return Pa(t)?t.length&&(e=t.every(r=>nn(r,!1))):e=!1,e}function OL(t,e,r){let n=null;return Pa(e)&&e.length?e.forEach(i=>{n||Hh(i)||(n=Dr("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):Hh(t)||(n=Dr("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"] }`)),n}function NL(t,e,r){let n=null;return Object.entries(t).forEach(([i,s])=>{if(n)return;const o=OL(i,y3(i,s),`${e} ${r}`);o&&(n=o)}),n}function LL(t,e){let r=null;return Pa(t)?t.forEach(n=>{r||ML(n)||(r=Dr("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=Dr("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function kL(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=LL(n?.accounts,`${e} namespace`);i&&(r=i)}),r}function BL(t,e){let r=null;return Q3(t?.methods)?Q3(t?.events)||(r=Dr("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=Dr("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function e_(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=BL(n,`${e}, namespace`);i&&(r=i)}),r}function FL(t,e,r){let n=null;if(t&&yf(t)){const i=e_(t,e);i&&(n=i);const s=NL(t,e,r);s&&(n=s)}else n=ut("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return n}function bm(t,e){let r=null;if(t&&yf(t)){const n=e_(t,e);n&&(r=n);const i=kL(t,e);i&&(r=i)}else r=ut("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function t_(t){return nn(t.protocol,!0)}function jL(t,e){let r=!1;return t?t&&Pa(t)&&t.length&&t.forEach(n=>{r=t_(n)}):r=!0,r}function UL(t){return typeof t=="number"}function ai(t){return typeof t<"u"&&typeof t!==null}function $L(t){return!(!t||typeof t!="object"||!t.code||!vm(t.code,!1)||!t.message||!nn(t.message,!1))}function qL(t){return!(Yn(t)||!nn(t.method,!1))}function zL(t){return!(Yn(t)||Yn(t.result)&&Yn(t.error)||!vm(t.id,!1)||!nn(t.jsonrpc,!1))}function HL(t){return!(Yn(t)||!nn(t.name,!1))}function r_(t,e){return!(!Hh(e)||!xL(t).includes(e))}function WL(t,e,r){return nn(r,!1)?_L(t,e).includes(r):!1}function KL(t,e,r){return nn(r,!1)?EL(t,e).includes(r):!1}function n_(t,e,r){let n=null;const i=VL(t),s=GL(e),o=Object.keys(i),a=Object.keys(s),f=i_(Object.keys(t)),u=i_(Object.keys(e)),h=f.filter(g=>!u.includes(g));return h.length&&(n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces. + Required: ${h.toString()} + Received: ${Object.keys(e).toString()}`)),_a(o,a)||(n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces. Required: ${o.toString()} - Approved: ${a.toString()}`)),Object.keys(e).forEach(g=>{if(!g.includes(":")||n)return;const y=Au(e[g].accounts);y.includes(g)||(n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${g} + Approved: ${a.toString()}`)),Object.keys(e).forEach(g=>{if(!g.includes(":")||n)return;const b=Pc(e[g].accounts);b.includes(g)||(n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${g} Required: ${g} - Approved: ${y.toString()}`))}),o.forEach(g=>{n||(Qa(i[g].methods,s[g].methods)?Qa(i[g].events,s[g].events)||(n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${g}`)):n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${g}`))}),n}function NB(t){const e={};return Object.keys(t).forEach(r=>{var n;r.includes(":")?e[r]=t[r]:(n=t[r].chains)==null||n.forEach(i=>{e[i]={methods:t[r].methods,events:t[r].events}})}),e}function P_(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function LB(t){const e={};return Object.keys(t).forEach(r=>{if(r.includes(":"))e[r]=t[r];else{const n=Au(t[r].accounts);n==null||n.forEach(i=>{e[i]={accounts:t[r].accounts.filter(s=>s.includes(`${i}:`)),methods:t[r].methods,events:t[r].events}})}}),e}function kB(t,e){return f1(t)&&t<=e.max&&t>=e.min}function M_(){const t=pl();return new Promise(e=>{switch(t){case Ri.browser:e($B());break;case Ri.reactNative:e(BB());break;case Ri.node:e(FB());break;default:e(!0)}})}function $B(){return dl()&&(navigator==null?void 0:navigator.onLine)}async function BB(){if(Eu()&&typeof global<"u"&&global!=null&&global.NetInfo){const t=await(global==null?void 0:global.NetInfo.fetch());return t==null?void 0:t.isConnected}return!0}function FB(){return!0}function UB(t){switch(pl()){case Ri.browser:jB(t);break;case Ri.reactNative:qB(t);break}}function jB(t){!Eu()&&dl()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function qB(t){Eu()&&typeof global<"u"&&global!=null&&global.NetInfo&&(global==null||global.NetInfo.addEventListener(e=>t(e==null?void 0:e.isConnected)))}const h1={};class Sl{static get(e){return h1[e]}static set(e,r){h1[e]=r}static delete(e){delete h1[e]}}const zB="PARSE_ERROR",HB="INVALID_REQUEST",WB="METHOD_NOT_FOUND",KB="INVALID_PARAMS",I_="INTERNAL_ERROR",d1="SERVER_ERROR",VB=[-32700,-32600,-32601,-32602,-32603],Al={[zB]:{code:-32700,message:"Parse error"},[HB]:{code:-32600,message:"Invalid Request"},[WB]:{code:-32601,message:"Method not found"},[KB]:{code:-32602,message:"Invalid params"},[I_]:{code:-32603,message:"Internal error"},[d1]:{code:-32e3,message:"Server error"}},C_=d1;function GB(t){return VB.includes(t)}function T_(t){return Object.keys(Al).includes(t)?Al[t]:Al[C_]}function YB(t){const e=Object.values(Al).find(r=>r.code===t);return e||Al[C_]}function R_(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var D_={},Ao={},O_;function JB(){if(O_)return Ao;O_=1,Object.defineProperty(Ao,"__esModule",{value:!0}),Ao.isBrowserCryptoAvailable=Ao.getSubtleCrypto=Ao.getBrowerCrypto=void 0;function t(){return(nn==null?void 0:nn.crypto)||(nn==null?void 0:nn.msCrypto)||{}}Ao.getBrowerCrypto=t;function e(){const n=t();return n.subtle||n.webkitSubtle}Ao.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Ao.isBrowserCryptoAvailable=r,Ao}var Po={},N_;function XB(){if(N_)return Po;N_=1,Object.defineProperty(Po,"__esModule",{value:!0}),Po.isBrowser=Po.isNode=Po.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Po.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Po.isNode=e;function r(){return!t()&&!e()}return Po.isBrowser=r,Po}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Kf;e.__exportStar(JB(),t),e.__exportStar(XB(),t)})(D_);function la(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function ic(t=6){return BigInt(la(t))}function ha(t,e,r){return{id:r||la(),jsonrpc:"2.0",method:t,params:e}}function Kd(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Vd(t,e,r){return{id:t,jsonrpc:"2.0",error:ZB(e)}}function ZB(t,e){return typeof t>"u"?T_(I_):(typeof t=="string"&&(t=Object.assign(Object.assign({},T_(d1)),{message:t})),GB(t.code)&&(t=YB(t.code)),t)}let QB=class{},eF=class extends QB{constructor(){super()}},tF=class extends eF{constructor(e){super()}};const rF="^https?:",nF="^wss?:";function iF(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function L_(t,e){const r=iF(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function k_(t){return L_(t,rF)}function $_(t){return L_(t,nF)}function sF(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function B_(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function p1(t){return B_(t)&&"method"in t}function Gd(t){return B_(t)&&(zs(t)||Yi(t))}function zs(t){return"result"in t}function Yi(t){return"error"in t}let Ji=class extends tF{constructor(e){super(e),this.events=new qi.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(ha(e.method,e.params||[],e.id||ic().toString()),r)}async requestStrict(e,r){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(s){i(s)}this.events.on(`${e.id}`,s=>{Yi(s)?i(s.error):n(s.result)});try{await this.connection.send(e,r)}catch(s){i(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Gd(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)}};const oF=()=>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:require("ws"),aF=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",F_=t=>t.split("?")[0],U_=10,cF=oF();let uF=class{constructor(e){if(this.url=e,this.events=new qi.EventEmitter,this.registering=!1,!$_(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=n=>{this.onClose(n),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(go(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!$_(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,n)=>{const i=new URLSearchParams(e).get("origin"),s=D_.isReactNative()?{headers:{origin:i}}:{rejectUnauthorized:!sF(e)},o=new cF(e,[],s);aF()?o.onerror=a=>{const u=a;n(this.emitError(u.error))}:o.on("error",a=>{n(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;const r=typeof e.data=="string"?Wa(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Vd(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return R_(e,F_(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>U_&&this.events.setMaxListeners(U_)}emitError(e){const r=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${F_(this.url)}`));return this.events.emit("register_error",r),r}};var Yd={exports:{}};Yd.exports,function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,o=9007199254740991,a="[object Arguments]",u="[object Array]",l="[object AsyncFunction]",d="[object Boolean]",g="[object Date]",y="[object Error]",A="[object Function]",P="[object GeneratorFunction]",N="[object Map]",D="[object Number]",k="[object Null]",$="[object Object]",q="[object Promise]",U="[object Proxy]",K="[object RegExp]",J="[object Set]",T="[object String]",z="[object Symbol]",ue="[object Undefined]",_e="[object WeakMap]",G="[object ArrayBuffer]",E="[object DataView]",m="[object Float32Array]",f="[object Float64Array]",p="[object Int8Array]",v="[object Int16Array]",x="[object Int32Array]",_="[object Uint8Array]",S="[object Uint8ClampedArray]",b="[object Uint16Array]",M="[object Uint32Array]",I=/[\\^$.*+?()[\]{}|]/g,F=/^\[object .+?Constructor\]$/,ae=/^(?:0|[1-9]\d*)$/,O={};O[m]=O[f]=O[p]=O[v]=O[x]=O[_]=O[S]=O[b]=O[M]=!0,O[a]=O[u]=O[G]=O[d]=O[E]=O[g]=O[y]=O[A]=O[N]=O[D]=O[$]=O[K]=O[J]=O[T]=O[_e]=!1;var se=typeof nn=="object"&&nn&&nn.Object===Object&&nn,ee=typeof self=="object"&&self&&self.Object===Object&&self,X=se||ee||Function("return this")(),Q=e&&!e.nodeType&&e,R=Q&&!0&&t&&!t.nodeType&&t,Z=R&&R.exports===Q,te=Z&&se.process,le=function(){try{return te&&te.binding&&te.binding("util")}catch{}}(),ie=le&&le.isTypedArray;function fe(ce,ye){for(var Ye=-1,It=ce==null?0:ce.length,Ur=0,ir=[];++Ye-1}function st(ce,ye){var Ye=this.__data__,It=Xe(Ye,ce);return It<0?(++this.size,Ye.push([ce,ye])):Ye[It][1]=ye,this}Re.prototype.clear=De,Re.prototype.delete=it,Re.prototype.get=je,Re.prototype.has=gt,Re.prototype.set=st;function tt(ce){var ye=-1,Ye=ce==null?0:ce.length;for(this.clear();++yewn))return!1;var jr=ir.get(ce);if(jr&&ir.get(ye))return jr==ye;var gn=-1,_i=!0,xn=Ye&s?new _t:void 0;for(ir.set(ce,ye),ir.set(ye,ce);++gn-1&&ce%1==0&&ce-1&&ce%1==0&&ce<=o}function up(ce){var ye=typeof ce;return ce!=null&&(ye=="object"||ye=="function")}function Ac(ce){return ce!=null&&typeof ce=="object"}var fp=ie?Te(ie):dr;function Ub(ce){return Bb(ce)?qe(ce):pr(ce)}function Fr(){return[]}function kr(){return!1}t.exports=Fb}(Yd,Yd.exports);var fF=Yd.exports;const lF=Ui(fF),j_="wc",q_=2,z_="core",Hs=`${j_}@2:${z_}:`,hF={logger:"error"},dF={database:":memory:"},pF="crypto",H_="client_ed25519_seed",gF=mt.ONE_DAY,mF="keychain",vF="0.3",bF="messages",yF="0.3",wF=mt.SIX_HOURS,xF="publisher",W_="irn",_F="error",K_="wss://relay.walletconnect.org",EF="relayer",ii={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",publish:"relayer_publish"},SF="_subscription",Xi={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},AF=.1,g1="2.17.2",Wr={link_mode:"link_mode",relay:"relay"},PF="0.3",MF="WALLETCONNECT_CLIENT_ID",V_="WALLETCONNECT_LINK_MODE_APPS",Ws={created:"subscription_created",deleted:"subscription_deleted",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},IF="subscription",CF="0.3",TF=mt.FIVE_SECONDS*1e3,RF="pairing",DF="0.3",Pl={wc_pairingDelete:{req:{ttl:mt.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:mt.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:mt.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:mt.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:mt.ONE_DAY,prompt:!1,tag:0},res:{ttl:mt.ONE_DAY,prompt:!1,tag:0}}},sc={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},vs={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},OF="history",NF="0.3",LF="expirer",Zi={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},kF="0.3",$F="verify-api",BF="https://verify.walletconnect.com",G_="https://verify.walletconnect.org",Ml=G_,FF=`${Ml}/v3`,UF=[BF,G_],jF="echo",qF="https://echo.walletconnect.com",Ks={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"},Mo={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_listener_not_found:"proposal_listener_not_found"},bs={session_approve_started:"session_approve_started",session_namespaces_validation_success:"session_namespaces_validation_success",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"},oc={no_internet_connection:"no_internet_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"},ac={authenticated_session_approve_started:"authenticated_session_approve_started",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"},Il={no_internet_connection:"no_internet_connection",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"},zF=.1,HF="event-client",WF=86400,KF="https://pulse.walletconnect.org/batch";function VF(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,U=new Uint8Array(q);k!==$;){for(var K=P[k],J=0,T=q-1;(K!==0||J>>0,U[T]=K%a>>>0,K=K/a>>>0;if(K!==0)throw new Error("Non-zero carry");D=J,k++}for(var z=q-D;z!==q&&U[z]===0;)z++;for(var ue=u.repeat(N);z>>0,q=new Uint8Array($);P[N];){var U=r[P.charCodeAt(N)];if(U===255)return;for(var K=0,J=$-1;(U!==0||K>>0,q[J]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");k=K,N++}if(P[N]!==" "){for(var T=$-k;T!==$&&q[T]===0;)T++;for(var z=new Uint8Array(D+($-T)),ue=D;T!==$;)z[ue++]=q[T++];return z}}}function A(P){var N=y(P);if(N)return N;throw new Error(`Non-${e} character`)}return{encode:g,decodeUnsafe:y,decode:A}}var GF=VF,YF=GF;const Y_=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},JF=t=>new TextEncoder().encode(t),XF=t=>new TextDecoder().decode(t);class ZF{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class QF{constructor(e,r,n){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=n}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 J_(this,e)}}class eU{constructor(e){this.decoders=e}or(e){return J_(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const J_=(t,e)=>new eU({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class tU{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new ZF(e,r,n),this.decoder=new QF(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Jd=({name:t,prefix:e,encode:r,decode:n})=>new tU(t,e,r,n),Cl=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=YF(r,e);return Jd({prefix:t,name:e,encode:n,decode:s=>Y_(i(s))})},rU=(t,e,r,n)=>{const i={};for(let d=0;d=8&&(a-=8,o[l++]=255&u>>a)}if(a>=r||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return o},nU=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<Jd({prefix:e,name:t,encode(i){return nU(i,n,r)},decode(i){return rU(i,n,r,t)}}),iU=Jd({prefix:"\0",name:"identity",encode:t=>XF(t),decode:t=>JF(t)});var sU=Object.freeze({__proto__:null,identity:iU});const oU=qn({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var aU=Object.freeze({__proto__:null,base2:oU});const cU=qn({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var uU=Object.freeze({__proto__:null,base8:cU});const fU=Cl({prefix:"9",name:"base10",alphabet:"0123456789"});var lU=Object.freeze({__proto__:null,base10:fU});const hU=qn({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dU=qn({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pU=Object.freeze({__proto__:null,base16:hU,base16upper:dU});const gU=qn({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mU=qn({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),vU=qn({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bU=qn({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yU=qn({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wU=qn({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xU=qn({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_U=qn({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),EU=qn({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var SU=Object.freeze({__proto__:null,base32:gU,base32upper:mU,base32pad:vU,base32padupper:bU,base32hex:yU,base32hexupper:wU,base32hexpad:xU,base32hexpadupper:_U,base32z:EU});const AU=Cl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),PU=Cl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var MU=Object.freeze({__proto__:null,base36:AU,base36upper:PU});const IU=Cl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),CU=Cl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var TU=Object.freeze({__proto__:null,base58btc:IU,base58flickr:CU});const RU=qn({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),DU=qn({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),OU=qn({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),NU=qn({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var LU=Object.freeze({__proto__:null,base64:RU,base64pad:DU,base64url:OU,base64urlpad:NU});const X_=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),kU=X_.reduce((t,e,r)=>(t[r]=e,t),[]),$U=X_.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function BU(t){return t.reduce((e,r)=>(e+=kU[r],e),"")}function FU(t){const e=[];for(const r of t){const n=$U[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const UU=Jd({prefix:"🚀",name:"base256emoji",encode:BU,decode:FU});var jU=Object.freeze({__proto__:null,base256emoji:UU}),qU=Q_,Z_=128,zU=127,HU=~zU,WU=Math.pow(2,31);function Q_(t,e,r){e=e||[],r=r||0;for(var n=r;t>=WU;)e[r++]=t&255|Z_,t/=128;for(;t&HU;)e[r++]=t&255|Z_,t>>>=7;return e[r]=t|0,Q_.bytes=r-n+1,e}var KU=m1,VU=128,e6=127;function m1(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw m1.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&e6)<=VU);return m1.bytes=s-n,r}var GU=Math.pow(2,7),YU=Math.pow(2,14),JU=Math.pow(2,21),XU=Math.pow(2,28),ZU=Math.pow(2,35),QU=Math.pow(2,42),ej=Math.pow(2,49),tj=Math.pow(2,56),rj=Math.pow(2,63),nj=function(t){return t(t6.encode(t,e,r),e),n6=t=>t6.encodingLength(t),v1=(t,e)=>{const r=e.byteLength,n=n6(t),i=n+n6(r),s=new Uint8Array(i+r);return r6(t,s,0),r6(r,s,n),s.set(e,i),new sj(t,r,e,s)};class sj{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const i6=({name:t,code:e,encode:r})=>new oj(t,e,r);class oj{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?v1(this.code,r):r.then(n=>v1(this.code,n))}else throw Error("Unknown type, must be binary type")}}const s6=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),aj=i6({name:"sha2-256",code:18,encode:s6("SHA-256")}),cj=i6({name:"sha2-512",code:19,encode:s6("SHA-512")});var uj=Object.freeze({__proto__:null,sha256:aj,sha512:cj});const o6=0,fj="identity",a6=Y_;var lj=Object.freeze({__proto__:null,identity:{code:o6,name:fj,encode:a6,digest:t=>v1(o6,a6(t))}});new TextEncoder,new TextDecoder;const c6={...sU,...aU,...uU,...lU,...pU,...SU,...MU,...TU,...LU,...jU};({...uj,...lj});function hj(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function u6(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const f6=u6("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),b1=u6("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);const e=hj(t.length);for(let r=0;r{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=ut("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=ri(r,this.name)}get context(){return gi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,V3(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?G3(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}},mj=class{constructor(e,r,n){this.core=e,this.logger=r,this.name=pF,this.randomSessionIdentifier=a1(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=wx(i);return yx(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=j$();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),o=wx(s),a=this.randomSessionIdentifier;return await SO(a,i,gF,o)},this.generateSharedKey=(i,s,o)=>{this.isInitialized();const a=this.getPrivateKey(i),u=q$(a,s);return this.setSymKey(u,o)},this.setSymKey=async(i,s)=>{this.isInitialized();const o=s||zd(i);return await this.keychain.set(o,i),o},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,o)=>{this.isInitialized();const a=h_(o),u=go(s);if(p_(a))return H$(u,o==null?void 0:o.encoding);if(d_(a)){const y=a.senderPublicKey,A=a.receiverPublicKey;i=await this.generateSharedKey(y,A)}const l=this.getSymKey(i),{type:d,senderPublicKey:g}=a;return z$({type:d,symKey:l,message:u,senderPublicKey:g,encoding:o==null?void 0:o.encoding})},this.decode=async(i,s,o)=>{this.isInitialized();const a=V$(s,o);if(p_(a)){const u=K$(s,o==null?void 0:o.encoding);return Wa(u)}if(d_(a)){const u=a.receiverPublicKey,l=a.senderPublicKey;i=await this.generateSharedKey(u,l)}try{const u=this.getSymKey(i),l=W$({symKey:u,encoded:s,encoding:o==null?void 0:o.encoding});return Wa(l)}catch(u){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(u)}},this.getPayloadType=(i,s=fa)=>{const o=wl({encoded:i,encoding:s});return rc(o.type)},this.getPayloadSenderPublicKey=(i,s=fa)=>{const o=wl({encoded:i,encoding:s});return o.senderPublicKey?Tn(o.senderPublicKey,ni):void 0},this.core=e,this.logger=ri(r,this.name),this.keychain=n||new gj(this.core,this.logger)}get context(){return gi(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(H_)}catch{e=a1(),await this.keychain.set(H_,e)}return pj(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}};class vj extends DR{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=bF,this.version=yF,this.initialized=!1,this.storagePrefix=Hs,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=So(i);let o=this.messages.get(n);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=i,this.messages.set(n,o),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),o=So(i);return typeof s[o]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=ri(e,this.name),this.core=r}get context(){return gi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,V3(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?G3(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}}class bj extends OR{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new qi.EventEmitter,this.name=xF,this.queue=new Map,this.publishTimeout=mt.toMiliseconds(mt.ONE_MINUTE),this.failedPublishTimeout=mt.toMiliseconds(mt.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(n,i,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});const a=(s==null?void 0:s.ttl)||wF,u=c1(s),l=(s==null?void 0:s.prompt)||!1,d=(s==null?void 0:s.tag)||0,g=(s==null?void 0:s.id)||ic().toString(),y={topic:n,message:i,opts:{ttl:a,relay:u,prompt:l,tag:d,id:g,attestation:s==null?void 0:s.attestation}},A=`Failed to publish payload, please try again. id:${g} tag:${d}`,P=Date.now();let N,D=1;try{for(;N===void 0;){if(Date.now()-P>this.publishTimeout)throw new Error(A);this.logger.trace({id:g,attempts:D},`publisher.publish - attempt ${D}`),N=await await Su(this.rpcPublish(n,i,a,u,l,d,g,s==null?void 0:s.attestation).catch(k=>this.logger.warn(k)),this.publishTimeout,A),D++,N||await new Promise(k=>setTimeout(k,this.failedPublishTimeout))}this.relayer.events.emit(ii.publish,y),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:g,topic:n,message:i,opts:s}})}catch(k){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(k),(o=s==null?void 0:s.internal)!=null&&o.throwOnFailedPublish)throw k;this.queue.set(g,y)}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=ri(r,this.name),this.registerEventListeners()}get context(){return gi(this.logger)}rpcPublish(e,r,n,i,s,o,a,u){var l,d,g,y;const A={method:xl(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:o,attestation:u},id:a};return bi((l=A.params)==null?void 0:l.prompt)&&((d=A.params)==null||delete d.prompt),bi((g=A.params)==null?void 0:g.tag)&&((y=A.params)==null||delete y.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:A}),this.relayer.request(A)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:n,opts:i}=e;await this.publish(r,n,i)})}registerEventListeners(){this.relayer.core.heartbeat.on(nu.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(ii.connection_stalled);return}this.checkQueue()}),this.relayer.on(ii.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class yj{constructor(){this.map=new Map,this.set=(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,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;const n=this.get(e);if(!this.exists(e,r))return;const i=n.filter(s=>s!==r);if(!i.length){this.map.delete(e);return}this.map.set(e,i)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var wj=Object.defineProperty,xj=Object.defineProperties,_j=Object.getOwnPropertyDescriptors,l6=Object.getOwnPropertySymbols,Ej=Object.prototype.hasOwnProperty,Sj=Object.prototype.propertyIsEnumerable,h6=(t,e,r)=>e in t?wj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tl=(t,e)=>{for(var r in e||(e={}))Ej.call(e,r)&&h6(t,r,e[r]);if(l6)for(var r of l6(e))Sj.call(e,r)&&h6(t,r,e[r]);return t},y1=(t,e)=>xj(t,_j(e));class Aj extends kR{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new yj,this.events=new qi.EventEmitter,this.name=IF,this.version=CF,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Hs,this.subscribeTimeout=mt.toMiliseconds(mt.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(n,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const s=c1(i),o={topic:n,relay:s,transportType:i==null?void 0:i.transportType};this.pending.set(n,o);const a=await this.rpcSubscribe(n,s,i);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(n,i)=>{await this.restartToComplete(),this.isInitialized(),typeof(i==null?void 0:i.id)<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>{if(this.topics.includes(n))return!0;const i=`${this.pendingSubscriptionWatchLabel}_${n}`;return await new Promise((s,o)=>{const a=new mt.Watch;a.start(i);const u=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(u),a.stop(i),s(!0)),a.elapsed(i)>=TF&&(clearInterval(u),a.stop(i),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},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=ri(r,this.name),this.clientId=""}get context(){return gi(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 n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const n=this.topicMap.get(e);await Promise.all(n.map(async i=>await this.unsubscribeById(e,i,r)))}async unsubscribeById(e,r,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}});try{const i=c1(n);await this.rpcUnsubscribe(e,r,i);const s=Dr("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,r,n){var i;(n==null?void 0:n.transportType)===Wr.relay&&await this.restartToComplete();const s={method:xl(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(i=n==null?void 0:n.internal)==null?void 0:i.throwOnFailedPublish;try{const a=So(e+this.clientId);if((n==null?void 0:n.transportType)===Wr.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(l=>this.logger.warn(l))},mt.toMiliseconds(mt.ONE_SECOND)),a;const u=await Su(this.relayer.request(s).catch(l=>this.logger.warn(l)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!u&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return u?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(ii.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,n={method:xl(r.protocol).batchSubscribe,params:{topics:e.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return await await Su(this.relayer.request(n).catch(i=>this.logger.warn(i)),this.subscribeTimeout)}catch{this.relayer.events.emit(ii.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,n={method:xl(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=await await Su(this.relayer.request(n).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(ii.connection_stalled)}return i}rpcUnsubscribe(e,r,n){const i={method:xl(n.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,r){this.setSubscription(e,y1(Tl({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,Tl({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,n){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,n),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,Tl({},r)),this.topicMap.set(r.topic,e),this.events.emit(Ws.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:n}=ut("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Ws.deleted,y1(Tl({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ws.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=ut("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;const r=await this.rpcBatchSubscribe(e);nc(r)&&this.onBatchSubscribe(r.map((n,i)=>y1(Tl({},e[i]),{id:n})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const 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;const 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(nu.pulse,async()=>{await this.checkPending()}),this.events.on(Ws.created,async e=>{const r=Ws.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Ws.deleted,async e=>{const r=Ws.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ut("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=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),e())},this.pollingInterval)})}}var Pj=Object.defineProperty,d6=Object.getOwnPropertySymbols,Mj=Object.prototype.hasOwnProperty,Ij=Object.prototype.propertyIsEnumerable,p6=(t,e,r)=>e in t?Pj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,g6=(t,e)=>{for(var r in e||(e={}))Mj.call(e,r)&&p6(t,r,e[r]);if(d6)for(var r of d6(e))Ij.call(e,r)&&p6(t,r,e[r]);return t};class Cj extends NR{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new qi.EventEmitter,this.name=EF,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=mt.toMiliseconds(mt.THIRTY_SECONDS+mt.ONE_SECOND),this.request=async r=>{var n,i;this.logger.debug("Publishing Request Payload");const s=r.id||ic().toString();await this.toEstablishConnection();try{const o=this.provider.request(r);this.requestsInFlight.set(s,{promise:o,request:r}),this.logger.trace({id:s,method:r.method,topic:(n=r.params)==null?void 0:n.topic},"relayer.request - attempt to publish...");const a=await new Promise(async(u,l)=>{const d=()=>{l(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(Xi.disconnect,d);const g=await o;this.provider.off(Xi.disconnect,d),u(g)});return this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.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(Fd())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,n,i;(i=(n=(r=this.provider)==null?void 0:r.connection)==null?void 0:n.socket)==null||i.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(ii.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(ii.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Xi.payload,this.onPayloadHandler),this.provider.on(Xi.connect,this.onConnectHandler),this.provider.on(Xi.disconnect,this.onDisconnectHandler),this.provider.on(Xi.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?ri(e.logger,this.name):Zf(sd({level:e.logger||_F})),this.messages=new vj(this.logger,e.core),this.subscriber=new Aj(this,this.logger),this.publisher=new bj(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||K_,this.projectId=e.projectId,this.bundleId=s$(),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 gi(this.logger)}get connected(){var e,r,n;return((n=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===1}get connecting(){var e,r,n;return((n=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===0}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:Wr.relay})}async subscribe(e,r){var n,i,s;this.isInitialized(),(r==null?void 0:r.transportType)==="relay"&&await this.toEstablishConnection();const o=typeof((n=r==null?void 0:r.internal)==null?void 0:n.throwOnFailedPublish)>"u"?!0:(i=r==null?void 0:r.internal)==null?void 0:i.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",u;const l=d=>{d.topic===e&&(this.subscriber.off(Ws.created,l),u())};return await Promise.all([new Promise(d=>{u=d,this.subscriber.on(Ws.created,l)}),new Promise(async(d,g)=>{a=await this.subscriber.subscribe(e,g6({internal:{throwOnFailedPublish:o}},r)).catch(y=>{o&&g(y)})||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.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Su(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,n)=>{const i=()=>{this.provider.off(Xi.disconnect,i),n(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(Xi.disconnect,i),await Su(this.provider.connect(),mt.toMiliseconds(mt.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{n(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){this.logger.error(r);const n=r;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(n.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 M_())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const r=e.sort((n,i)=>n.publishedAt-i.publishedAt);this.logger.trace(`Batch of ${r.length} message events sorted`);for(const n of r)try{await this.onMessageEvent(n)}catch(i){this.logger.warn(i)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:n}=e;if(!r.sessionExists){const i=En(mt.FIVE_MINUTES),s={topic:n,expiry:i,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(n,s)}this.events.emit(ii.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,r,n,i,s;if(Fd())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(i=(n=this.provider)==null?void 0:n.connection)==null?void 0:i.socket)==null||s.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();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ji(new uF(u$({sdkVersion:g1,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:r,message:n}=e;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;if(!n||n.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const i=this.messages.has(r,n);return i&&this.logger.debug(`Ignoring duplicate message: ${n}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),p1(e)){if(!e.method.endsWith(SF))return;const r=e.params,{topic:n,message:i,publishedAt:s,attestation:o}=r.data,a={topic:n,message:i,publishedAt:s,transportType:Wr.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(g6({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Gd(e)&&this.events.emit(ii.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(ii.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Kd(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Xi.payload,this.onPayloadHandler),this.provider.off(Xi.connect,this.onConnectHandler),this.provider.off(Xi.disconnect,this.onDisconnectHandler),this.provider.off(Xi.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await M_();UB(async r=>{e!==r&&(e=r,r?await this.restartTransport().catch(n=>this.logger.error(n)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(ii.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},mt.toMiliseconds(AF))))}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var Tj=Object.defineProperty,m6=Object.getOwnPropertySymbols,Rj=Object.prototype.hasOwnProperty,Dj=Object.prototype.propertyIsEnumerable,v6=(t,e,r)=>e in t?Tj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,b6=(t,e)=>{for(var r in e||(e={}))Rj.call(e,r)&&v6(t,r,e[r]);if(m6)for(var r of m6(e))Dj.call(e,r)&&v6(t,r,e[r]);return t};class cc extends LR{constructor(e,r,n,i=Hs,s=void 0){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=PF,this.cached=[],this.initialized=!1,this.storagePrefix=Hs,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&&!bi(o)?this.map.set(this.getKey(o),o):vB(o)?this.map.set(o.id,o):bB(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(u=>lF(a[u],o[u]))):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});const u=b6(b6({},this.getData(o)),a);this.map.set(o,u),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=ri(r,this.name),this.storagePrefix=i,this.getKey=s}get context(){return gi(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){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:i}=ut("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}const{message:n}=ut("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=ut("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){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Oj{constructor(e,r){this.core=e,this.logger=r,this.name=RF,this.version=DF,this.events=new Gg,this.initialized=!1,this.storagePrefix=Hs,this.ignoredPayloadTypes=[Eo],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:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async n=>{this.isInitialized();const i=a1(),s=await this.core.crypto.setSymKey(i),o=En(mt.FIVE_MINUTES),a={protocol:W_},u={topic:s,expiry:o,relay:a,active:!1,methods:n==null?void 0:n.methods},l=y_({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:i,relay:a,expiryTimestamp:o,methods:n==null?void 0:n.methods});return this.events.emit(sc.create,u),this.core.expirer.set(s,o),await this.pairings.set(s,u),await this.core.relayer.subscribe(s,{transportType:n==null?void 0:n.transportType}),{topic:s,uri:l}},this.pair=async n=>{this.isInitialized();const i=this.core.eventClient.createEvent({properties:{topic:n==null?void 0:n.uri,trace:[Ks.pairing_started]}});this.isValidPair(n,i);const{topic:s,symKey:o,relay:a,expiryTimestamp:u,methods:l}=b_(n.uri);i.props.properties.topic=s,i.addTrace(Ks.pairing_uri_validation_success),i.addTrace(Ks.pairing_uri_not_expired);let d;if(this.pairings.keys.includes(s)){if(d=this.pairings.get(s),i.addTrace(Ks.existing_pairing),d.active)throw i.setError(Mo.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);i.addTrace(Ks.pairing_not_expired)}const g=u||En(mt.FIVE_MINUTES),y={topic:s,relay:a,expiry:g,active:!1,methods:l};this.core.expirer.set(s,g),await this.pairings.set(s,y),i.addTrace(Ks.store_new_pairing),n.activatePairing&&await this.activate({topic:s}),this.events.emit(sc.create,y),i.addTrace(Ks.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),i.addTrace(Ks.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(Mo.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(A){throw i.setError(Mo.subscribe_pairing_topic_failure),A}return i.addTrace(Ks.subscribe_pairing_topic_success),y},this.activate=async({topic:n})=>{this.isInitialized();const i=En(mt.THIRTY_DAYS);this.core.expirer.set(n,i),await this.pairings.update(n,{active:!0,expiry:i})},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:i}=n;if(this.pairings.keys.includes(i)){const s=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:u}=ec();this.events.once(vr("pairing_ping",s),({error:l})=>{l?u(l):a()}),await o()}},this.updateExpiry=async({topic:n,expiry:i})=>{this.isInitialized(),await this.pairings.update(n,{expiry:i})},this.updateMetadata=async({topic:n,metadata:i})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:i})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:i}=n;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",Dr("USER_DISCONNECTED")),await this.deletePairing(i))},this.formatUriFromPairing=n=>{this.isInitialized();const{topic:i,relay:s,expiry:o,methods:a}=n,u=this.core.crypto.keychain.get(i);return y_({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:u,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(n,i,s)=>{const o=ha(i,s),a=await this.core.crypto.encode(n,o),u=Pl[i].req;return this.core.history.set(n,o),this.core.relayer.publish(n,a,u),o.id},this.sendResult=async(n,i,s)=>{const o=Kd(n,s),a=await this.core.crypto.encode(i,o),u=await this.core.history.get(i,n),l=Pl[u.request.method].res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)},this.sendError=async(n,i,s)=>{const o=Vd(n,s),a=await this.core.crypto.encode(i,o),u=await this.core.history.get(i,n),l=Pl[u.request.method]?Pl[u.request.method].res:Pl.unregistered_method.res;await this.core.relayer.publish(i,a,l),await this.core.history.resolve(o)},this.deletePairing=async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Dr("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(i=>ua(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))},this.onRelayEventRequest=n=>{const{topic:i,payload:s}=n;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(i,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(i,s);default:return this.onUnknownRpcMethodRequest(i,s)}},this.onRelayEventResponse=async n=>{const{topic:i,payload:s}=n,o=(await this.core.history.get(i,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(n,i)=>{const{id:s}=i;try{this.isValidPing({topic:n}),await this.sendResult(s,n,!0),this.events.emit(sc.ping,{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onPairingPingResponse=(n,i)=>{const{id:s}=i;setTimeout(()=>{zs(i)?this.events.emit(vr("pairing_ping",s),{}):Yi(i)&&this.events.emit(vr("pairing_ping",s),{error:i.error})},500)},this.onPairingDeleteRequest=async(n,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit(sc.delete,{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(n,i)=>{const{id:s,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=Dr("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,n,a),this.logger.error(a)}catch(a){await this.sendError(s,n,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(Dr("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=(n,i)=>{var s;if(!yi(n)){const{message:a}=ut("MISSING_OR_INVALID",`pair() params: ${n}`);throw i.setError(Mo.malformed_pairing_uri),new Error(a)}if(!mB(n.uri)){const{message:a}=ut("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw i.setError(Mo.malformed_pairing_uri),new Error(a)}const o=b_(n==null?void 0:n.uri);if(!((s=o==null?void 0:o.relay)!=null&&s.protocol)){const{message:a}=ut("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(Mo.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=ut("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(Mo.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&mt.toMiliseconds(o==null?void 0:o.expiryTimestamp){if(!yi(n)){const{message:s}=ut("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidDisconnect=async n=>{if(!yi(n)){const{message:s}=ut("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidPairingTopic=async n=>{if(!an(n,!1)){const{message:i}=ut("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){const{message:i}=ut("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(ua(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:i}=ut("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}},this.core=e,this.logger=ri(r,this.name),this.pairings=new cc(this.core,this.logger,this.name,this.storagePrefix)}get context(){return gi(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(ii.message,async e=>{const{topic:r,message:n,transportType:i}=e;if(!this.pairings.keys.includes(r)||i===Wr.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const s=await this.core.crypto.decode(r,n);try{p1(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):Gd(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Zi.expired,async e=>{const{topic:r}=J3(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(sc.expire,{topic:r}))})}}class Nj extends RR{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new qi.EventEmitter,this.name=OF,this.version=NF,this.cached=[],this.initialized=!1,this.storagePrefix=Hs,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;const o={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s,expiry:En(mt.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(vs.created,o)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const i=await this.getRecord(n.id);typeof i.response>"u"&&(i.response=Yi(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.persist(),this.events.emit(vs.updated,i))},this.get=async(n,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i}),await this.getRecord(i)),this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(vs.deleted,s)}}),this.persist()},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=ri(r,this.name)}get context(){return gi(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(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const n={topic:r.topic,request:ha(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(n)}),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();const r=this.records.get(e);if(!r){const{message:n}=ut("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(vs.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=ut("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(vs.created,e=>{const r=vs.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(vs.updated,e=>{const r=vs.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(vs.deleted,e=>{const r=vs.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(nu.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{mt.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(vs.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Lj extends $R{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new qi.EventEmitter,this.name=LF,this.version=kF,this.cached=[],this.initialized=!1,this.storagePrefix=Hs,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},this.set=(n,i)=>{this.isInitialized();const s=this.formatTarget(n),o={target:s,expiry:i};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Zi.created,{target:s,expiration:o})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{if(this.isInitialized(),this.has(n)){const i=this.formatTarget(n),s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Zi.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=ri(r,this.name)}get context(){return gi(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 f$(e);if(typeof e=="number")return l$(e);const{message:r}=ut("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(Zi.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=ut("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){const r=this.expirations.get(e);if(!r){const{message:n}=ut("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;mt.toMiliseconds(n)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Zi.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(nu.pulse,()=>this.checkExpirations()),this.events.on(Zi.created,e=>{const r=Zi.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Zi.expired,e=>{const r=Zi.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Zi.deleted,e=>{const r=Zi.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}}class kj extends BR{constructor(e,r,n){super(e,r,n),this.core=e,this.logger=r,this.store=n,this.name=$F,this.verifyUrlV3=FF,this.storagePrefix=Hs,this.version=q_,this.init=async()=>{var i;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&mt.toMiliseconds((i=this.publicKey)==null?void 0:i.expiresAt){if(!dl()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=i,u=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const l=rl(),d=this.startAbortTimer(mt.ONE_SECOND*5),g=await new Promise((y,A)=>{const P=()=>{window.removeEventListener("message",D),l.body.removeChild(N),A("attestation aborted")};this.abortController.signal.addEventListener("abort",P);const N=l.createElement("iframe");N.src=u,N.style.display="none",N.addEventListener("error",P,{signal:this.abortController.signal});const D=k=>{if(k.data&&typeof k.data=="string")try{const $=JSON.parse(k.data);if($.type==="verify_attestation"){if(pm($.attestation).payload.id!==o)return;clearInterval(d),l.body.removeChild(N),this.abortController.signal.removeEventListener("abort",P),window.removeEventListener("message",D),y($.attestation===null?"":$.attestation)}}catch($){this.logger.warn($)}};l.body.appendChild(N),window.addEventListener("message",D,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",g),g}catch(l){this.logger.warn(l)}return""},this.resolve=async i=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=i;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(pm(s).payload.id!==a)return;const l=await this.isValidJwtAttestation(s);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const u=this.getVerifyUrl(i==null?void 0:i.verifyUrl);return this.fetchAttestation(o,u)},this.fetchAttestation=async(i,s)=>{this.logger.debug(`resolving attestation: ${i} from url: ${s}`);const o=this.startAbortTimer(mt.ONE_SECOND*5),a=await fetch(`${s}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=i=>{let s=i||Ml;return UF.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Ml}`),s=Ml),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const i=this.startAbortTimer(mt.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),await s.json()}catch(i){this.logger.warn(i)}},this.persistPublicKey=async i=>{this.logger.debug("persisting public key to local storage",i),await this.store.setItem(this.storeKey,i),this.publicKey=i},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 i=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(i,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,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=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const i=await this.fetchPromise;return this.fetchPromise=void 0,i},this.validateAttestation=(i,s)=>{const o=X$(i,s.publicKey),a={hasExpired:mt.toMiliseconds(o.exp)this.abortController.abort(),mt.toMiliseconds(e))}}class $j extends FR{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.context=jF,this.registerDeviceToken=async n=>{const{clientId:i,token:s,notificationType:o,enableEncrypted:a=!1}=n,u=`${qF}/${this.projectId}/clients`;await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:s,always_raw:a})})},this.logger=ri(r,this.context)}}var Bj=Object.defineProperty,y6=Object.getOwnPropertySymbols,Fj=Object.prototype.hasOwnProperty,Uj=Object.prototype.propertyIsEnumerable,w6=(t,e,r)=>e in t?Bj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rl=(t,e)=>{for(var r in e||(e={}))Fj.call(e,r)&&w6(t,r,e[r]);if(y6)for(var r of y6(e))Uj.call(e,r)&&w6(t,r,e[r]);return t};class jj extends UR{constructor(e,r,n=!0){super(e,r,n),this.core=e,this.logger=r,this.context=HF,this.storagePrefix=Hs,this.storageVersion=zF,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!n1())try{const i={eventId:Z3(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:K3(this.core.relayer.protocol,this.core.relayer.version,g1)}}};await this.sendEvent([i])}catch(i){this.logger.warn(i)}},this.createEvent=i=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:u}}=i,l=Z3(),d=this.core.projectId||"",g=Date.now(),y=Rl({eventId:l,timestamp:g,props:{event:s,type:o,properties:{topic:a,trace:u}},bundleId:d,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,y),this.shouldPersist=!0),y},this.getEvent=i=>{const{eventId:s,topic:o}=i;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(u=>u.props.properties.topic===o);if(a)return Rl(Rl({},a),this.setMethods(a.eventId))},this.deleteEvent=i=>{const{eventId:s}=i;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(nu.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(i=>{mt.fromMiliseconds(Date.now())-mt.fromMiliseconds(i.timestamp)>WF&&(this.events.delete(i.eventId),this.shouldPersist=!0)})})},this.setMethods=i=>({addTrace:s=>this.addTrace(i,s),setError:s=>this.setError(i,s)}),this.addTrace=(i,s)=>{const o=this.events.get(i);o&&(o.props.properties.trace.push(s),this.events.set(i,o),this.shouldPersist=!0)},this.setError=(i,s)=>{const o=this.events.get(i);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(i,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{const i=await this.core.storage.getItem(this.storageKey)||[];if(!i.length)return;i.forEach(s=>{this.events.set(s.eventId,Rl(Rl({},s),this.setMethods(s.eventId)))})}catch(i){this.logger.warn(i)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const i=[];for(const[s,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((await this.sendEvent(i)).ok)for(const s of i)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async i=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${KF}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${g1}${s}`,{method:"POST",body:JSON.stringify(i)})},this.getAppDomain=()=>W3().url,this.logger=ri(r,this.context),this.telemetryEnabled=n,n?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var qj=Object.defineProperty,x6=Object.getOwnPropertySymbols,zj=Object.prototype.hasOwnProperty,Hj=Object.prototype.propertyIsEnumerable,_6=(t,e,r)=>e in t?qj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,E6=(t,e)=>{for(var r in e||(e={}))zj.call(e,r)&&_6(t,r,e[r]);if(x6)for(var r of x6(e))Hj.call(e,r)&&_6(t,r,e[r]);return t};class w1 extends TR{constructor(e){var r;super(e),this.protocol=j_,this.version=q_,this.name=z_,this.events=new qi.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:u})=>{if(!o||!a)return;const l={topic:o,message:a,publishedAt:Date.now(),transportType:Wr.link_mode};this.relayer.onLinkMessageEvent(l,{sessionExists:u})},this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||K_,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const n=sd({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:hF.logger}),{logger:i,chunkLoggerController:s}=CR({opts:n,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=s,(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=ri(i,this.name),this.heartbeat=new ET,this.crypto=new mj(this,this.logger,e==null?void 0:e.keychain),this.history=new Nj(this,this.logger),this.expirer=new Lj(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new tR(E6(E6({},dF),e==null?void 0:e.storageOptions)),this.relayer=new Cj({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Oj(this,this.logger),this.verify=new kj(this,this.logger,this.storage),this.echoClient=new $j(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new jj(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const r=new w1(e);await r.initialize();const n=await r.crypto.getClientId();return await r.storage.setItem(MF,n),r}get context(){return gi(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(V_,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(V_)||[],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}}}const Wj=w1,S6="wc",A6=2,P6="client",x1=`${S6}@${A6}:${P6}:`,_1={name:P6,logger:"error"},M6="WALLETCONNECT_DEEPLINK_CHOICE",Kj="proposal",I6="Proposal expired",Vj="session",Pu=mt.SEVEN_DAYS,Gj="engine",kn={wc_sessionPropose:{req:{ttl:mt.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:mt.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:mt.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:mt.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:mt.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:mt.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:mt.ONE_DAY,prompt:!1,tag:1104},res:{ttl:mt.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:mt.ONE_DAY,prompt:!1,tag:1106},res:{ttl:mt.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:mt.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:mt.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:mt.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:mt.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:mt.ONE_DAY,prompt:!1,tag:1112},res:{ttl:mt.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:mt.ONE_DAY,prompt:!1,tag:1114},res:{ttl:mt.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:mt.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:mt.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:mt.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:mt.FIVE_MINUTES,prompt:!1,tag:1119}}},E1={min:mt.FIVE_MINUTES,max:mt.SEVEN_DAYS},Vs={idle:"IDLE",active:"ACTIVE"},Yj="request",Jj=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],Xj="wc",Zj="auth",Qj="authKeys",eq="pairingTopics",tq="requests",Xd=`${Xj}@${1.5}:${Zj}:`,Zd=`${Xd}:PUB_KEY`;var rq=Object.defineProperty,nq=Object.defineProperties,iq=Object.getOwnPropertyDescriptors,C6=Object.getOwnPropertySymbols,sq=Object.prototype.hasOwnProperty,oq=Object.prototype.propertyIsEnumerable,T6=(t,e,r)=>e in t?rq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,tn=(t,e)=>{for(var r in e||(e={}))sq.call(e,r)&&T6(t,r,e[r]);if(C6)for(var r of C6(e))oq.call(e,r)&&T6(t,r,e[r]);return t},ys=(t,e)=>nq(t,iq(e));class aq extends qR{constructor(e){super(e),this.name=Gj,this.events=new Gg,this.initialized=!1,this.requestQueue={state:Vs.idle,queue:[]},this.sessionRequestQueue={state:Vs.idle,queue:[]},this.requestQueueDelay=mt.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(kn)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},mt.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const n=ys(tn({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(n);const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:u}=n;let l=i,d,g=!1;try{l&&(g=this.client.core.pairing.pairings.get(l).active)}catch(U){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),U}if(!l||!g){const{topic:U,uri:K}=await this.client.core.pairing.create();l=U,d=K}if(!l){const{message:U}=ut("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(U)}const y=await this.client.core.crypto.generateKeyPair(),A=kn.wc_sessionPropose.req.ttl||mt.FIVE_MINUTES,P=En(A),N=tn({requiredNamespaces:s,optionalNamespaces:o,relays:u??[{protocol:W_}],proposer:{publicKey:y,metadata:this.client.metadata},expiryTimestamp:P,pairingTopic:l},a&&{sessionProperties:a}),{reject:D,resolve:k,done:$}=ec(A,I6);this.events.once(vr("session_connect"),async({error:U,session:K})=>{if(U)D(U);else if(K){K.self.publicKey=y;const J=ys(tn({},K),{pairingTopic:N.pairingTopic,requiredNamespaces:N.requiredNamespaces,optionalNamespaces:N.optionalNamespaces,transportType:Wr.relay});await this.client.session.set(K.topic,J),await this.setExpiry(K.topic,K.expiry),l&&await this.client.core.pairing.updateMetadata({topic:l,metadata:K.peer.metadata}),this.cleanupDuplicatePairings(J),k(J)}});const q=await this.sendRequest({topic:l,method:"wc_sessionPropose",params:N,throwOnFailedPublish:!0});return await this.setProposal(q,tn({id:q},N)),{uri:d,approval:$}},this.pair=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(n){throw this.client.logger.error("pair() failed"),n}},this.approve=async r=>{var n,i,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(n=r==null?void 0:r.id)==null?void 0:n.toString(),trace:[bs.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(z){throw o.setError(oc.no_internet_connection),z}try{await this.isValidProposalId(r==null?void 0:r.id)}catch(z){throw this.client.logger.error(`approve() -> proposal.get(${r==null?void 0:r.id}) failed`),o.setError(oc.proposal_not_found),z}try{await this.isValidApprove(r)}catch(z){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(oc.session_approve_namespace_validation_failure),z}const{id:a,relayProtocol:u,namespaces:l,sessionProperties:d,sessionConfig:g}=r,y=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:A,proposer:P,requiredNamespaces:N,optionalNamespaces:D}=y;let k=(i=this.client.core.eventClient)==null?void 0:i.getEvent({topic:A});k||(k=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:bs.session_approve_started,properties:{topic:A,trace:[bs.session_approve_started,bs.session_namespaces_validation_success]}}));const $=await this.client.core.crypto.generateKeyPair(),q=P.publicKey,U=await this.client.core.crypto.generateSharedKey($,q),K=tn(tn({relay:{protocol:u??"irn"},namespaces:l,controller:{publicKey:$,metadata:this.client.metadata},expiry:En(Pu)},d&&{sessionProperties:d}),g&&{sessionConfig:g}),J=Wr.relay;k.addTrace(bs.subscribing_session_topic);try{await this.client.core.relayer.subscribe(U,{transportType:J})}catch(z){throw k.setError(oc.subscribe_session_topic_failure),z}k.addTrace(bs.subscribe_session_topic_success);const T=ys(tn({},K),{topic:U,requiredNamespaces:N,optionalNamespaces:D,pairingTopic:A,acknowledged:!1,self:K.controller,peer:{publicKey:P.publicKey,metadata:P.metadata},controller:$,transportType:Wr.relay});await this.client.session.set(U,T),k.addTrace(bs.store_session);try{k.addTrace(bs.publishing_session_settle),await this.sendRequest({topic:U,method:"wc_sessionSettle",params:K,throwOnFailedPublish:!0}).catch(z=>{throw k==null||k.setError(oc.session_settle_publish_failure),z}),k.addTrace(bs.session_settle_publish_success),k.addTrace(bs.publishing_session_approve),await this.sendResult({id:a,topic:A,result:{relay:{protocol:u??"irn"},responderPublicKey:$},throwOnFailedPublish:!0}).catch(z=>{throw k==null||k.setError(oc.session_approve_publish_failure),z}),k.addTrace(bs.session_approve_publish_success)}catch(z){throw this.client.logger.error(z),this.client.session.delete(U,Dr("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(U),z}return this.client.core.eventClient.deleteEvent({eventId:k.eventId}),await this.client.core.pairing.updateMetadata({topic:A,metadata:P.metadata}),await this.client.proposal.delete(a,Dr("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:A}),await this.setExpiry(U,En(Pu)),{topic:U,acknowledged:()=>Promise.resolve(this.client.session.get(U))}},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}const{id:n,reason:i}=r;let s;try{s=this.client.proposal.get(n).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${n}) failed`),o}s&&(await this.sendError({id:n,topic:s,error:i,rpcOpts:kn.wc_sessionPropose.reject}),await this.client.proposal.delete(n,Dr("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(g){throw this.client.logger.error("update() -> isValidUpdate() failed"),g}const{topic:n,namespaces:i}=r,{done:s,resolve:o,reject:a}=ec(),u=la(),l=ic().toString(),d=this.client.session.get(n).namespaces;return this.events.once(vr("session_update",u),({error:g})=>{g?a(g):o()}),await this.client.session.update(n,{namespaces:i}),await this.sendRequest({topic:n,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:u,relayRpcId:l}).catch(g=>{this.client.logger.error(g),this.client.session.update(n,{namespaces:d}),a(g)}),{acknowledged:s}},this.extend=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(u){throw this.client.logger.error("extend() -> isValidExtend() failed"),u}const{topic:n}=r,i=la(),{done:s,resolve:o,reject:a}=ec();return this.events.once(vr("session_extend",i),({error:u})=>{u?a(u):o()}),await this.setExpiry(n,En(Pu)),this.sendRequest({topic:n,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(u=>{a(u)}),{acknowledged:s}},this.request=async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(P){throw this.client.logger.error("request() -> isValidRequest() failed"),P}const{chainId:n,request:i,topic:s,expiry:o=kn.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);(a==null?void 0:a.transportType)===Wr.relay&&await this.confirmOnlineStateOrThrow();const u=la(),l=ic().toString(),{done:d,resolve:g,reject:y}=ec(o,"Request expired. Please try again.");this.events.once(vr("session_request",u),({error:P,result:N})=>{P?y(P):g(N)});const A=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return A?(await this.sendRequest({clientRpcId:u,relayRpcId:l,topic:s,method:"wc_sessionRequest",params:{request:ys(tn({},i),{expiryTimestamp:En(o)}),chainId:n},expiry:o,throwOnFailedPublish:!0,appLink:A}).catch(P=>y(P)),this.client.events.emit("session_request_sent",{topic:s,request:i,chainId:n,id:u}),await d()):await Promise.all([new Promise(async P=>{await this.sendRequest({clientRpcId:u,relayRpcId:l,topic:s,method:"wc_sessionRequest",params:{request:ys(tn({},i),{expiryTimestamp:En(o)}),chainId:n},expiry:o,throwOnFailedPublish:!0}).catch(N=>y(N)),this.client.events.emit("session_request_sent",{topic:s,request:i,chainId:n,id:u}),P()}),new Promise(async P=>{var N;if(!((N=a.sessionConfig)!=null&&N.disableDeepLink)){const D=await p$(this.client.core.storage,M6);await h$({id:u,topic:s,wcDeepLink:D})}P()}),d()]).then(P=>P[2])},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i,o=this.client.session.get(n);o.transportType===Wr.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);zs(i)?await this.sendResult({id:s,topic:n,result:i.result,throwOnFailedPublish:!0,appLink:a}):Yi(i)&&await this.sendError({id:s,topic:n,error:i.error,appLink:a}),this.cleanupAfterResponse(r)},this.ping=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(i){throw this.client.logger.error("ping() -> isValidPing() failed"),i}const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=la(),s=ic().toString(),{done:o,resolve:a,reject:u}=ec();this.events.once(vr("session_ping",i),({error:l})=>{l?u(l):a()}),await Promise.all([this.sendRequest({topic:n,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:i,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r,o=ic().toString();await this.sendRequest({topic:n,method:"wc_sessionEvent",params:{event:i,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:n}=r;if(this.client.session.keys.includes(n))await this.sendRequest({topic:n,method:"wc_sessionDelete",params:Dr("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:n,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(n))await this.client.core.pairing.disconnect({topic:n});else{const{message:i}=ut("MISMATCHED_TOPIC",`Session or pairing topic not found: ${n}`);throw new Error(i)}},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>pB(n,r))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(r,n)=>{var i;this.isInitialized(),this.isValidAuthenticate(r);const s=n&&this.client.core.linkModeSupportedApps.includes(n)&&((i=this.client.metadata.redirect)==null?void 0:i.linkMode),o=s?Wr.link_mode:Wr.relay;o===Wr.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:u="",uri:l,domain:d,nonce:g,type:y,exp:A,nbf:P,methods:N=[],expiry:D}=r,k=[...r.resources||[]],{topic:$,uri:q}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:$,uri:q}});const U=await this.client.core.crypto.generateKeyPair(),K=zd(U);if(await Promise.all([this.client.auth.authKeys.set(Zd,{responseTopic:K,publicKey:U}),this.client.auth.pairingTopics.set(K,{topic:K,pairingTopic:$})]),await this.client.core.relayer.subscribe(K,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${$}`),N.length>0){const{namespace:_}=_u(a[0]);let S=L$(_,"request",N);qd(k)&&(S=$$(S,k.pop())),k.push(S)}const J=D&&D>kn.wc_sessionAuthenticate.req.ttl?D:kn.wc_sessionAuthenticate.req.ttl,T={authPayload:{type:y??"caip122",chains:a,statement:u,aud:l,domain:d,version:"1",nonce:g,iat:new Date().toISOString(),exp:A,nbf:P,resources:k},requester:{publicKey:U,metadata:this.client.metadata},expiryTimestamp:En(J)},z={eip155:{chains:a,methods:[...new Set(["personal_sign",...N])],events:["chainChanged","accountsChanged"]}},ue={requiredNamespaces:{},optionalNamespaces:z,relays:[{protocol:"irn"}],pairingTopic:$,proposer:{publicKey:U,metadata:this.client.metadata},expiryTimestamp:En(kn.wc_sessionPropose.req.ttl)},{done:_e,resolve:G,reject:E}=ec(J,"Request expired"),m=async({error:_,session:S})=>{if(this.events.off(vr("session_request",p),f),_)E(_);else if(S){S.self.publicKey=U,await this.client.session.set(S.topic,S),await this.setExpiry(S.topic,S.expiry),$&&await this.client.core.pairing.updateMetadata({topic:$,metadata:S.peer.metadata});const b=this.client.session.get(S.topic);await this.deleteProposal(v),G({session:b})}},f=async _=>{var S,b,M;if(await this.deletePendingAuthRequest(p,{message:"fulfilled",code:0}),_.error){const X=Dr("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return _.error.code===X.code?void 0:(this.events.off(vr("session_connect"),m),E(_.error.message))}await this.deleteProposal(v),this.events.off(vr("session_connect"),m);const{cacaos:I,responder:F}=_.result,ae=[],O=[];for(const X of I){await r_({cacao:X,projectId:this.client.core.projectId})||(this.client.logger.error(X,"Signature verification failed"),E(Dr("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Q}=X,R=qd(Q.resources),Z=[s1(Q.iss)],te=jd(Q.iss);if(R){const le=s_(R),ie=o_(R);ae.push(...le),Z.push(...ie)}for(const le of Z)O.push(`${le}:${te}`)}const se=await this.client.core.crypto.generateSharedKey(U,F.publicKey);let ee;ae.length>0&&(ee={topic:se,acknowledged:!0,self:{publicKey:U,metadata:this.client.metadata},peer:F,controller:F.publicKey,expiry:En(Pu),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:$,namespaces:w_([...new Set(ae)],[...new Set(O)]),transportType:o},await this.client.core.relayer.subscribe(se,{transportType:o}),await this.client.session.set(se,ee),$&&await this.client.core.pairing.updateMetadata({topic:$,metadata:F.metadata}),ee=this.client.session.get(se)),(S=this.client.metadata.redirect)!=null&&S.linkMode&&(b=F.metadata.redirect)!=null&&b.linkMode&&(M=F.metadata.redirect)!=null&&M.universal&&n&&(this.client.core.addLinkModeSupportedApp(F.metadata.redirect.universal),this.client.session.update(se,{transportType:Wr.link_mode})),G({auths:I,session:ee})},p=la(),v=la();this.events.once(vr("session_connect"),m),this.events.once(vr("session_request",p),f);let x;try{if(s){const _=ha("wc_sessionAuthenticate",T,p);this.client.core.history.set($,_);const S=await this.client.core.crypto.encode("",_,{type:bl,encoding:ml});x=Hd(n,$,S)}else await Promise.all([this.sendRequest({topic:$,method:"wc_sessionAuthenticate",params:T,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:p}),this.sendRequest({topic:$,method:"wc_sessionPropose",params:ue,expiry:kn.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:v})])}catch(_){throw this.events.off(vr("session_connect"),m),this.events.off(vr("session_request",p),f),_}return await this.setProposal(v,tn({id:v},ue)),await this.setAuthRequest(p,{request:ys(tn({},T),{verifyContext:{}}),pairingTopic:$,transportType:o}),{uri:x??q,response:_e}},this.approveSessionAuthenticate=async r=>{const{id:n,auths:i}=r,s=this.client.core.eventClient.createEvent({properties:{topic:n.toString(),trace:[ac.authenticated_session_approve_started]}});try{this.isInitialized()}catch(D){throw s.setError(Il.no_internet_connection),D}const o=this.getPendingAuthRequest(n);if(!o)throw s.setError(Il.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${n}`);const a=o.transportType||Wr.relay;a===Wr.relay&&await this.confirmOnlineStateOrThrow();const u=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),d=zd(u),g={type:Eo,receiverPublicKey:u,senderPublicKey:l},y=[],A=[];for(const D of i){if(!await r_({cacao:D,projectId:this.client.core.projectId})){s.setError(Il.invalid_cacao);const K=Dr("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:n,topic:d,error:K,encodeOpts:g}),new Error(K.message)}s.addTrace(ac.cacaos_verified);const{p:k}=D,$=qd(k.resources),q=[s1(k.iss)],U=jd(k.iss);if($){const K=s_($),J=o_($);y.push(...K),q.push(...J)}for(const K of q)A.push(`${K}:${U}`)}const P=await this.client.core.crypto.generateSharedKey(l,u);s.addTrace(ac.create_authenticated_session_topic);let N;if((y==null?void 0:y.length)>0){N={topic:P,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:u,metadata:o.requester.metadata},controller:u,expiry:En(Pu),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:w_([...new Set(y)],[...new Set(A)]),transportType:a},s.addTrace(ac.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(P,{transportType:a})}catch(D){throw s.setError(Il.subscribe_authenticated_session_topic_failure),D}s.addTrace(ac.subscribe_authenticated_session_topic_success),await this.client.session.set(P,N),s.addTrace(ac.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(ac.publishing_authenticated_session_approve);try{await this.sendResult({topic:d,id:n,result:{cacaos:i,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:g,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(D){throw s.setError(Il.authenticated_session_approve_publish_failure),D}return await this.client.auth.requests.delete(n,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:N}},this.rejectSessionAuthenticate=async r=>{this.isInitialized();const{id:n,reason:i}=r,s=this.getPendingAuthRequest(n);if(!s)throw new Error(`Could not find pending auth request with id ${n}`);s.transportType===Wr.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),u=zd(o),l={type:Eo,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:n,topic:u,error:i,encodeOpts:l,rpcOpts:kn.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(n,{message:"rejected",code:0}),await this.client.proposal.delete(n,Dr("USER_DISCONNECTED"))},this.formatAuthMessage=r=>{this.isInitialized();const{request:n,iss:i}=r;return n_(n,i)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const 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{const n=this.client.core.pairing.pairings.get(r.pairingTopic),i=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)===r.peer.metadata.url&&s.topic&&s.topic!==n.topic});if(i.length===0)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}},this.deleteSession=async r=>{var n;const{topic:i,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=r,{self:u}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,Dr("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(u.publicKey)&&await this.client.core.crypto.deleteKeyPair(u.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),s||this.client.core.expirer.del(i),this.client.core.storage.removeItem(M6).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===i&&this.deletePendingSessionRequest(l.id,Dr("USER_DISCONNECTED"))}),i===((n=this.sessionRequestQueue.queue[0])==null?void 0:n.topic)&&(this.sessionRequestQueue.state=Vs.idle),o&&this.client.events.emit("session_delete",{id:a,topic:i})},this.deleteProposal=async(r,n)=>{if(n)try{const i=this.client.proposal.get(r),s=this.client.core.eventClient.getEvent({topic:i.pairingTopic});s==null||s.setError(oc.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,Dr("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")},this.deletePendingSessionRequest=async(r,n,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,n),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),i&&(this.sessionRequestQueue.state=Vs.idle,this.client.events.emit("session_request_expire",{id:r}))},this.deletePendingAuthRequest=async(r,n,i=!1)=>{await Promise.all([this.client.auth.requests.delete(r,n),i?Promise.resolve():this.client.core.expirer.del(r)])},this.setExpiry=async(r,n)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,n),await this.client.session.update(r,{expiry:n}))},this.setProposal=async(r,n)=>{this.client.core.expirer.set(r,En(kn.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,n)},this.setAuthRequest=async(r,n)=>{const{request:i,pairingTopic:s,transportType:o=Wr.relay}=n;this.client.core.expirer.set(r,i.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:r,pairingTopic:s,verifyContext:i.verifyContext,transportType:o})},this.setPendingSessionRequest=async r=>{const{id:n,topic:i,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||En(kn.wc_sessionRequest.req.ttl);this.client.core.expirer.set(n,a),await this.client.pendingRequest.set(n,{id:n,topic:i,params:s,verifyContext:o})},this.sendRequest=async r=>{const{topic:n,method:i,params:s,expiry:o,relayRpcId:a,clientRpcId:u,throwOnFailedPublish:l,appLink:d}=r,g=ha(i,s,u);let y;const A=!!d;try{const D=A?ml:fa;y=await this.client.core.crypto.encode(n,g,{encoding:D})}catch(D){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${n} failed`),D}let P;if(Jj.includes(i)){const D=So(JSON.stringify(g)),k=So(y);P=await this.client.core.verify.register({id:k,decryptedId:D})}const N=kn[i].req;if(N.attestation=P,o&&(N.ttl=o),a&&(N.id=a),this.client.core.history.set(n,g),A){const D=Hd(d,n,y);await global.Linking.openURL(D,this.client.name)}else{const D=kn[i].req;o&&(D.ttl=o),a&&(D.id=a),l?(D.internal=ys(tn({},D.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,y,D)):this.client.core.relayer.publish(n,y,D).catch(k=>this.client.logger.error(k))}return g.id},this.sendResult=async r=>{const{id:n,topic:i,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:u}=r,l=Kd(n,s);let d;const g=u&&typeof(global==null?void 0:global.Linking)<"u";try{const A=g?ml:fa;d=await this.client.core.crypto.encode(i,l,ys(tn({},a||{}),{encoding:A}))}catch(A){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),A}let y;try{y=await this.client.core.history.get(i,n)}catch(A){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${n}) failed`),A}if(g){const A=Hd(u,i,d);await global.Linking.openURL(A,this.client.name)}else{const A=kn[y.request.method].res;o?(A.internal=ys(tn({},A.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,d,A)):this.client.core.relayer.publish(i,d,A).catch(P=>this.client.logger.error(P))}await this.client.core.history.resolve(l)},this.sendError=async r=>{const{id:n,topic:i,error:s,encodeOpts:o,rpcOpts:a,appLink:u}=r,l=Vd(n,s);let d;const g=u&&typeof(global==null?void 0:global.Linking)<"u";try{const A=g?ml:fa;d=await this.client.core.crypto.encode(i,l,ys(tn({},o||{}),{encoding:A}))}catch(A){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),A}let y;try{y=await this.client.core.history.get(i,n)}catch(A){throw this.client.logger.error(`sendError() -> history.get(${i}, ${n}) failed`),A}if(g){const A=Hd(u,i,d);await global.Linking.openURL(A,this.client.name)}else{const A=a||kn[y.request.method].res;this.client.core.relayer.publish(i,d,A)}await this.client.core.history.resolve(l)},this.cleanup=async()=>{const r=[],n=[];this.client.session.getAll().forEach(i=>{let s=!1;ua(i.expiry)&&(s=!0),this.client.core.crypto.keychain.has(i.topic)||(s=!0),s&&r.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{ua(i.expiryTimestamp)&&n.push(i.id)}),await Promise.all([...r.map(i=>this.deleteSession({topic:i})),...n.map(i=>this.deleteProposal(i))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Vs.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=Vs.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(n){this.client.logger.warn(n)}}this.requestQueue.state=Vs.idle},this.processRequest=async r=>{const{topic:n,payload:i,attestation:s,transportType:o,encryptedId:a}=r,u=i.method;if(!this.shouldIgnorePairingRequest({topic:n,requestMethod:u}))switch(u){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:n,payload:i,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(n,i);case"wc_sessionPing":return await this.onSessionPingRequest(n,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(n,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:n,payload:i,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(n,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:n,payload:i,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:i,transportType:s}=r,o=(await this.client.core.history.get(n,i.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i,s);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:n}=r,{message:i}=ut("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)},this.shouldIgnorePairingRequest=r=>{const{topic:n,requestMethod:i}=r,s=this.expectedPairingMethodMap.get(n);return!s||s.includes(i)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async r=>{const{topic:n,payload:i,attestation:s,encryptedId:o}=r,{params:a,id:u}=i;try{const l=this.client.core.eventClient.getEvent({topic:n});this.isValidConnect(tn({},i.params));const d=a.expiryTimestamp||En(kn.wc_sessionPropose.req.ttl),g=tn({id:u,pairingTopic:n,expiryTimestamp:d},a);await this.setProposal(u,g);const y=await this.getVerifyContext({attestationId:s,hash:So(JSON.stringify(i)),encryptedId:o,metadata:g.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l==null||l.setError(Mo.proposal_listener_not_found)),l==null||l.addTrace(Ks.emit_session_proposal),this.client.events.emit("session_proposal",{id:u,params:g,verifyContext:y})}catch(l){await this.sendError({id:u,topic:n,error:l,rpcOpts:kn.wc_sessionPropose.autoReject}),this.client.logger.error(l)}},this.onSessionProposeResponse=async(r,n,i)=>{const{id:s}=n;if(zs(n)){const{result:o}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const u=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const d=await this.client.core.crypto.generateSharedKey(u,l);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:d});const g=await this.client.core.relayer.subscribe(d,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:g}),await this.client.core.pairing.activate({topic:r})}else if(Yi(n)){await this.client.proposal.delete(s,Dr("USER_DISCONNECTED"));const o=vr("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(vr("session_connect"),{error:n.error})}},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:u,namespaces:l,sessionProperties:d,sessionConfig:g}=n.params,y=ys(tn(tn({topic:r,relay:o,expiry:u,namespaces:l,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},d&&{sessionProperties:d}),g&&{sessionConfig:g}),{transportType:Wr.relay}),A=vr("session_connect");if(this.events.listenerCount(A)===0)throw new Error(`emitting ${A} without any listeners 997`);this.events.emit(vr("session_connect"),{session:y}),await this.sendResult({id:n.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:i,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;zs(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(vr("session_approve",i),{})):Yi(n)&&(await this.client.session.delete(r,Dr("USER_DISCONNECTED")),this.events.emit(vr("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:i,id:s}=n;try{const o=`${r}_session_update`,a=Sl.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:Dr("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(tn({topic:r},i));try{Sl.set(o,s),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(u){throw Sl.delete(o),u}this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(r,n)=>parseInt(n.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n,s=vr("session_update",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);zs(n)?this.events.emit(vr("session_update",i),{}):Yi(n)&&this.events.emit(vr("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,En(Pu)),await this.sendResult({id:i,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError({id:i,topic:r,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,n)=>{const{id:i}=n,s=vr("session_extend",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);zs(n)?this.events.emit(vr("session_extend",i),{}):Yi(n)&&this.events.emit(vr("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult({id:i,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError({id:i,topic:r,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(r,n)=>{const{id:i}=n,s=vr("session_ping",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{zs(n)?this.events.emit(vr("session_ping",i),{}):Yi(n)&&this.events.emit(vr("session_ping",i),{error:n.error})},500)},this.onSessionDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(ii.publish,async()=>{s(await this.deleteSession({topic:r,id:i}))})}),this.sendResult({id:i,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:Dr("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async r=>{var n,i,s;const{topic:o,payload:a,attestation:u,encryptedId:l,transportType:d}=r,{id:g,params:y}=a;try{await this.isValidRequest(tn({topic:o},y));const A=this.client.session.get(o),P=await this.getVerifyContext({attestationId:u,hash:So(JSON.stringify(ha("wc_sessionRequest",y,g))),encryptedId:l,metadata:A.peer.metadata,transportType:d}),N={id:g,topic:o,params:y,verifyContext:P};await this.setPendingSessionRequest(N),d===Wr.link_mode&&(n=A.peer.metadata.redirect)!=null&&n.universal&&this.client.core.addLinkModeSupportedApp((i=A.peer.metadata.redirect)==null?void 0:i.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(N):(this.addSessionRequestToSessionRequestQueue(N),this.processSessionRequestQueue())}catch(A){await this.sendError({id:g,topic:o,error:A}),this.client.logger.error(A)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n,s=vr("session_request",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);zs(n)?this.events.emit(vr("session_request",i),{result:n.result}):Yi(n)&&this.events.emit(vr("session_request",i),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:i,params:s}=n;try{const o=`${r}_session_event_${s.event.name}`,a=Sl.get(o);if(a&&this.isRequestOutOfSync(a,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit(tn({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s}),Sl.set(o,i)}catch(o){await this.sendError({id:i,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(r,n)=>{const{id:i}=n;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:n}),zs(n)?this.events.emit(vr("session_request",i),{result:n.result}):Yi(n)&&this.events.emit(vr("session_request",i),{error:n.error})},this.onSessionAuthenticateRequest=async r=>{var n;const{topic:i,payload:s,attestation:o,encryptedId:a,transportType:u}=r;try{const{requester:l,authPayload:d,expiryTimestamp:g}=s.params,y=await this.getVerifyContext({attestationId:o,hash:So(JSON.stringify(s)),encryptedId:a,metadata:l.metadata,transportType:u}),A={requester:l,pairingTopic:i,id:s.id,authPayload:d,verifyContext:y,expiryTimestamp:g};await this.setAuthRequest(s.id,{request:A,pairingTopic:i,transportType:u}),u===Wr.link_mode&&(n=l.metadata.redirect)!=null&&n.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:s.params,id:s.id,verifyContext:y})}catch(l){this.client.logger.error(l);const d=s.params.requester.publicKey,g=await this.client.core.crypto.generateKeyPair(),y=this.getAppLinkIfEnabled(s.params.requester.metadata,u),A={type:Eo,receiverPublicKey:d,senderPublicKey:g};await this.sendError({id:s.id,topic:i,error:l,encodeOpts:A,rpcOpts:kn.wc_sessionAuthenticate.autoReject,appLink:y})}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Vs.idle,this.processSessionRequestQueue()},mt.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:r,error:n})=>{const i=this.client.core.history.pending;i.length>0&&i.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=vr("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(vr("session_request",s.request.id),{error:n})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Vs.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Vs.active,this.emitSessionRequest(r)}catch(n){this.client.logger.error(n)}},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;const n=this.client.proposal.getAll().find(i=>i.pairingTopic===r.topic);n&&this.onSessionProposeRequest({topic:r.topic,payload:ha("wc_sessionPropose",{requiredNamespaces:n.requiredNamespaces,optionalNamespaces:n.optionalNamespaces,relays:n.relays,proposer:n.proposer,sessionProperties:n.sessionProperties},n.id)})},this.isValidConnect=async r=>{if(!yi(r)){const{message:u}=ut("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(u)}const{pairingTopic:n,requiredNamespaces:i,optionalNamespaces:s,sessionProperties:o,relays:a}=r;if(bi(n)||await this.isValidPairingTopic(n),!PB(a)){const{message:u}=ut("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(u)}!bi(i)&&El(i)!==0&&this.validateNamespaces(i,"requiredNamespaces"),!bi(s)&&El(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),bi(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(r,n)=>{const i=AB(r,"connect()",n);if(i)throw new Error(i.message)},this.isValidApprove=async r=>{if(!yi(r))throw new Error(ut("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s,sessionProperties:o}=r;this.checkRecentlyDeleted(n),await this.isValidProposalId(n);const a=this.client.proposal.get(n),u=l1(i,"approve()");if(u)throw new Error(u.message);const l=A_(a.requiredNamespaces,i,"approve()");if(l)throw new Error(l.message);if(!an(s,!0)){const{message:d}=ut("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(d)}bi(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async r=>{if(!yi(r)){const{message:s}=ut("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:n,reason:i}=r;if(this.checkRecentlyDeleted(n),await this.isValidProposalId(n),!IB(i)){const{message:s}=ut("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!yi(r)){const{message:l}=ut("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(l)}const{relay:n,controller:i,namespaces:s,expiry:o}=r;if(!E_(n)){const{message:l}=ut("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=yB(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const u=l1(s,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(ua(o)){const{message:l}=ut("EXPIRED","onSessionSettleRequest()");throw new Error(l)}},this.isValidUpdate=async r=>{if(!yi(r)){const{message:u}=ut("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(u)}const{topic:n,namespaces:i}=r;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const s=this.client.session.get(n),o=l1(i,"update()");if(o)throw new Error(o.message);const a=A_(s.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async r=>{if(!yi(r)){const{message:i}=ut("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!yi(r)){const{message:u}=ut("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(u)}const{topic:n,request:i,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const{namespaces:a}=this.client.session.get(n);if(!S_(a,s)){const{message:u}=ut("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!CB(i)){const{message:u}=ut("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(u)}if(!DB(a,s,i.method)){const{message:u}=ut("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(u)}if(o&&!kB(o,E1)){const{message:u}=ut("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${E1.min} and ${E1.max}`);throw new Error(u)}},this.isValidRespond=async r=>{var n;if(!yi(r)){const{message:o}=ut("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:i,response:s}=r;try{await this.isValidSessionTopic(i)}catch(o){throw(n=r==null?void 0:r.response)!=null&&n.id&&this.cleanupAfterResponse(r),o}if(!TB(s)){const{message:o}=ut("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async r=>{if(!yi(r)){const{message:i}=ut("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!yi(r)){const{message:a}=ut("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:o}=this.client.session.get(n);if(!S_(o,s)){const{message:a}=ut("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!RB(i)){const{message:a}=ut("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!OB(o,s,i.name)){const{message:a}=ut("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}},this.isValidDisconnect=async r=>{if(!yi(r)){const{message:i}=ut("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidAuthenticate=r=>{const{chains:n,uri:i,domain:s,nonce:o}=r;if(!Array.isArray(n)||n.length===0)throw new Error("chains is required and must be a non-empty array");if(!an(i,!1))throw new Error("uri is required parameter");if(!an(s,!1))throw new Error("domain is required parameter");if(!an(o,!1))throw new Error("nonce is required parameter");if([...new Set(n.map(u=>_u(u).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=_u(n[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=>{const{attestationId:n,hash:i,encryptedId:s,metadata:o,transportType:a}=r,u={verified:{verifyUrl:o.verifyUrl||Ml,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Wr.link_mode){const d=this.getAppLinkIfEnabled(o,a);return u.verified.validation=d&&new URL(d).origin===new URL(o.url).origin?"VALID":"INVALID",u}const l=await this.client.core.verify.resolve({attestationId:n,hash:i,encryptedId:s,verifyUrl:o.verifyUrl});l&&(u.verified.origin=l.origin,u.verified.isScam=l.isScam,u.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(u)}`),u},this.validateSessionProps=(r,n)=>{Object.values(r).forEach(i=>{if(!an(i,!1)){const{message:s}=ut("MISSING_OR_INVALID",`${n} must be in Record format. Received: ${JSON.stringify(i)}`);throw new Error(s)}})},this.getPendingAuthRequest=r=>{const n=this.client.auth.requests.get(r);return typeof n=="object"?n:void 0},this.addToRecentlyDeleted=(r,n)=>{if(this.recentlyDeletedMap.set(r,n),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let i=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(i++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=r=>{const n=this.recentlyDeletedMap.get(r);if(n){const{message:i}=ut("MISSING_OR_INVALID",`Record was recently deleted - ${n}: ${r}`);throw new Error(i)}},this.isLinkModeEnabled=(r,n)=>{var i,s,o,a,u,l,d,g,y;return!r||n!==Wr.link_mode?!1:((s=(i=this.client.metadata)==null?void 0:i.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((l=(u=this.client.metadata)==null?void 0:u.redirect)==null?void 0:l.universal)!==""&&((d=r==null?void 0:r.redirect)==null?void 0:d.universal)!==void 0&&((g=r==null?void 0:r.redirect)==null?void 0:g.universal)!==""&&((y=r==null?void 0:r.redirect)==null?void 0:y.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(r,n)=>{var i;return this.isLinkModeEnabled(r,n)?(i=r==null?void 0:r.redirect)==null?void 0:i.universal:void 0},this.handleLinkModeMessage=({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const n=X3(r,"topic")||"",i=decodeURIComponent(X3(r,"wc_ev")||""),s=this.client.session.keys.includes(n);s&&this.client.session.update(n,{transportType:Wr.link_mode}),this.client.core.dispatchEnvelope({topic:n,message:i,sessionExists:s})},this.registerLinkModeListeners=async()=>{var r;if(n1()||Eu()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const n=global==null?void 0:global.Linking;if(typeof n<"u"){n.addEventListener("url",this.handleLinkModeMessage,this.client.name);const i=await n.getInitialURL();i&&setTimeout(()=>{this.handleLinkModeMessage({url:i})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(ii.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:r,message:n,attestation:i,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Zd)?this.client.auth.authKeys.get(Zd):{publicKey:void 0},a=await this.client.core.crypto.decode(r,n,{receiverPublicKey:o,encoding:s===Wr.link_mode?ml:fa});try{p1(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:i,transportType:s,encryptedId:So(n)})):Gd(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:s}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s})}catch(u){this.client.logger.error(u)}}registerExpirerEvents(){this.client.core.expirer.on(Zi.expired,async e=>{const{topic:r,id:n}=J3(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,ut("EXPIRED"),!0);if(n&&this.client.auth.requests.keys.includes(n))return await this.deletePendingAuthRequest(n,ut("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}registerPairingEvents(){this.client.core.pairing.events.on(sc.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(sc.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!an(e,!1)){const{message:r}=ut("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=ut("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(ua(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=ut("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!an(e,!1)){const{message:r}=ut("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=ut("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(ua(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=ut("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=ut("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(an(e,!1)){const{message:r}=ut("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=ut("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!MB(e)){const{message:r}=ut("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=ut("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(ua(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=ut("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class cq extends cc{constructor(e,r){super(e,r,Kj,x1),this.core=e,this.logger=r}}let uq=class extends cc{constructor(e,r){super(e,r,Vj,x1),this.core=e,this.logger=r}};class fq extends cc{constructor(e,r){super(e,r,Yj,x1,n=>n.id),this.core=e,this.logger=r}}class lq extends cc{constructor(e,r){super(e,r,Qj,Xd,()=>Zd),this.core=e,this.logger=r}}class hq extends cc{constructor(e,r){super(e,r,eq,Xd),this.core=e,this.logger=r}}class dq extends cc{constructor(e,r){super(e,r,tq,Xd,n=>n.id),this.core=e,this.logger=r}}class pq{constructor(e,r){this.core=e,this.logger=r,this.authKeys=new lq(this.core,this.logger),this.pairingTopics=new hq(this.core,this.logger),this.requests=new dq(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class S1 extends jR{constructor(e){super(e),this.protocol=S6,this.version=A6,this.name=_1.name,this.events=new qi.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.authenticate=async(n,i)=>{try{return await this.engine.authenticate(n,i)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=n=>{try{return this.engine.formatAuthMessage(n)}catch(i){throw this.logger.error(i.message),i}},this.approveSessionAuthenticate=async n=>{try{return await this.engine.approveSessionAuthenticate(n)}catch(i){throw this.logger.error(i.message),i}},this.rejectSessionAuthenticate=async n=>{try{return await this.engine.rejectSessionAuthenticate(n)}catch(i){throw this.logger.error(i.message),i}},this.name=(e==null?void 0:e.name)||_1.name,this.metadata=(e==null?void 0:e.metadata)||W3(),this.signConfig=e==null?void 0:e.signConfig;const r=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Zf(sd({level:(e==null?void 0:e.logger)||_1.logger}));this.core=(e==null?void 0:e.core)||new Wj(e),this.logger=ri(r,this.name),this.session=new uq(this.core,this.logger),this.proposal=new cq(this.core,this.logger),this.pendingRequest=new fq(this.core,this.logger),this.engine=new aq(this),this.auth=new pq(this.core,this.logger)}static async init(e){const r=new S1(e);return await r.initialize(),r}get context(){return gi(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 Qd={exports:{}};/** + Approved: ${b.toString()}`))}),o.forEach(g=>{n||(_a(i[g].methods,s[g].methods)?_a(i[g].events,s[g].events)||(n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${g}`)):n=ut("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${g}`))}),n}function VL(t){const e={};return Object.keys(t).forEach(r=>{var n;r.includes(":")?e[r]=t[r]:(n=t[r].chains)==null||n.forEach(i=>{e[i]={methods:t[r].methods,events:t[r].events}})}),e}function i_(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function GL(t){const e={};return Object.keys(t).forEach(r=>{r.includes(":")?e[r]=t[r]:Pc(t[r].accounts)?.forEach(i=>{e[i]={accounts:t[r].accounts.filter(s=>s.includes(`${i}:`)),methods:t[r].methods,events:t[r].events}})}),e}function YL(t,e){return vm(t,!1)&&t<=e.max&&t>=e.min}function s_(){const t=ff();return new Promise(e=>{switch(t){case bi.browser:e(JL());break;case bi.reactNative:e(XL());break;case bi.node:e(ZL());break;default:e(!0)}})}function JL(){return uf()&&navigator?.onLine}async function XL(){return Sc()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function ZL(){return!0}function QL(t){switch(ff()){case bi.browser:ek(t);break;case bi.reactNative:tk(t);break}}function ek(t){!Sc()&&uf()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function tk(t){Sc()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}const ym={};class wf{static get(e){return ym[e]}static set(e,r){ym[e]=r}static delete(e){delete ym[e]}}const rk="PARSE_ERROR",nk="INVALID_REQUEST",ik="METHOD_NOT_FOUND",sk="INVALID_PARAMS",o_="INTERNAL_ERROR",wm="SERVER_ERROR",ok=[-32700,-32600,-32601,-32602,-32603],xf={[rk]:{code:-32700,message:"Parse error"},[nk]:{code:-32600,message:"Invalid Request"},[ik]:{code:-32601,message:"Method not found"},[sk]:{code:-32602,message:"Invalid params"},[o_]:{code:-32603,message:"Internal error"},[wm]:{code:-32e3,message:"Server error"}},a_=wm;function ak(t){return ok.includes(t)}function c_(t){return Object.keys(xf).includes(t)?xf[t]:xf[a_]}function ck(t){const e=Object.values(xf).find(r=>r.code===t);return e||xf[a_]}function u_(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var xm={},Ys={},f_;function uk(){if(f_)return Ys;f_=1,Object.defineProperty(Ys,"__esModule",{value:!0}),Ys.isBrowserCryptoAvailable=Ys.getSubtleCrypto=Ys.getBrowerCrypto=void 0;function t(){return Wn?.crypto||Wn?.msCrypto||{}}Ys.getBrowerCrypto=t;function e(){const n=t();return n.subtle||n.webkitSubtle}Ys.getSubtleCrypto=e;function r(){return!!t()&&!!e()}return Ys.isBrowserCryptoAvailable=r,Ys}var Js={},l_;function fk(){if(l_)return Js;l_=1,Object.defineProperty(Js,"__esModule",{value:!0}),Js.isBrowser=Js.isNode=Js.isReactNative=void 0;function t(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Js.isReactNative=t;function e(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Js.isNode=e;function r(){return!t()&&!e()}return Js.isBrowser=r,Js}var h_;function lk(){return h_||(h_=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=Hu;e.__exportStar(uk(),t),e.__exportStar(fk(),t)})(xm)),xm}var hk=lk();function Oo(t=3){const e=Date.now()*Math.pow(10,t),r=Math.floor(Math.random()*Math.pow(10,t));return e+r}function Ia(t=6){return BigInt(Oo(t))}function No(t,e,r){return{id:r||Oo(),jsonrpc:"2.0",method:t,params:e}}function Wh(t,e){return{id:t,jsonrpc:"2.0",result:e}}function Kh(t,e,r){return{id:t,jsonrpc:"2.0",error:dk(e)}}function dk(t,e){return typeof t>"u"?c_(o_):(typeof t=="string"&&(t=Object.assign(Object.assign({},c_(wm)),{message:t})),ak(t.code)&&(t=ck(t.code)),t)}let pk=class{},gk=class extends pk{constructor(){super()}},mk=class extends gk{constructor(e){super()}};const vk="^https?:",bk="^wss?:";function yk(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function d_(t,e){const r=yk(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function p_(t){return d_(t,vk)}function g_(t){return d_(t,bk)}function wk(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function m_(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function _m(t){return m_(t)&&"method"in t}function Vh(t){return m_(t)&&(Ss(t)||Bi(t))}function Ss(t){return"result"in t}function Bi(t){return"error"in t}let Fi=class extends mk{constructor(e){super(e),this.events=new Di.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(No(e.method,e.params||[],e.id||Ia().toString()),r)}async requestStrict(e,r){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(s){i(s)}this.events.on(`${e.id}`,s=>{Bi(s)?i(s.error):n(s.result)});try{await this.connection.send(e,r)}catch(s){i(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Vh(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)}};const xk=()=>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:require("ws"),_k=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",v_=t=>t.split("?")[0],b_=10,Ek=xk();let Sk=class{constructor(e){if(this.url=e,this.events=new Di.EventEmitter,this.registering=!1,!g_(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=n=>{this.onClose(n),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Hs(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!g_(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,n)=>{const i=new URLSearchParams(e).get("origin"),s=hk.isReactNative()?{headers:{origin:i}}:{rejectUnauthorized:!wk(e)},o=new Ek(e,[],s);_k()?o.onerror=a=>{const f=a;n(this.emitError(f.error))}:o.on("error",a=>{n(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;const r=typeof e.data=="string"?ma(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Kh(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return u_(e,v_(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>b_&&this.events.setMaxListeners(b_)}emitError(e){const r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${v_(this.url)}`));return this.events.emit("register_error",r),r}};var _f={exports:{}};_f.exports;var y_;function Ak(){return y_||(y_=1,(function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,o=9007199254740991,a="[object Arguments]",f="[object Array]",u="[object AsyncFunction]",h="[object Boolean]",g="[object Date]",b="[object Error]",x="[object Function]",S="[object GeneratorFunction]",C="[object Map]",D="[object Number]",B="[object Null]",L="[object Object]",H="[object Promise]",F="[object Proxy]",k="[object RegExp]",$="[object Set]",R="[object String]",W="[object Symbol]",V="[object Undefined]",X="[object WeakMap]",q="[object ArrayBuffer]",_="[object DataView]",v="[object Float32Array]",l="[object Float64Array]",p="[object Int8Array]",m="[object Int16Array]",y="[object Int32Array]",A="[object Uint8Array]",E="[object Uint8ClampedArray]",w="[object Uint16Array]",I="[object Uint32Array]",M=/[\\^$.*+?()[\]{}|]/g,z=/^\[object .+?Constructor\]$/,se=/^(?:0|[1-9]\d*)$/,O={};O[v]=O[l]=O[p]=O[m]=O[y]=O[A]=O[E]=O[w]=O[I]=!0,O[a]=O[f]=O[q]=O[h]=O[_]=O[g]=O[b]=O[x]=O[C]=O[D]=O[L]=O[k]=O[$]=O[R]=O[X]=!1;var ie=typeof Wn=="object"&&Wn&&Wn.Object===Object&&Wn,ee=typeof self=="object"&&self&&self.Object===Object&&self,Z=ie||ee||Function("return this")(),te=e&&!e.nodeType&&e,N=te&&!0&&t&&!t.nodeType&&t,Q=N&&N.exports===te,ne=Q&&ie.process,de=(function(){try{return ne&&ne.binding&&ne.binding("util")}catch{}})(),ce=de&&de.isTypedArray;function fe(ue,we){for(var Ge=-1,Pt=ue==null?0:ue.length,$r=0,sr=[];++Ge-1}function ot(ue,we){var Ge=this.__data__,Pt=Je(Ge,ue);return Pt<0?(++this.size,Ge.push([ue,we])):Ge[Pt][1]=we,this}ke.prototype.clear=Ce,ke.prototype.delete=et,ke.prototype.get=Ze,ke.prototype.has=rt,ke.prototype.set=ot;function yt(ue){var we=-1,Ge=ue==null?0:ue.length;for(this.clear();++webn))return!1;var qr=sr.get(ue);if(qr&&sr.get(we))return qr==we;var hn=-1,fi=!0,yn=Ge&s?new Et:void 0;for(sr.set(ue,we),sr.set(we,ue);++hn-1&&ue%1==0&&ue-1&&ue%1==0&&ue<=o}function o0(ue){var we=typeof ue;return ue!=null&&(we=="object"||we=="function")}function Va(ue){return ue!=null&&typeof ue=="object"}var a0=ce?Te(ce):gr;function Q1(ue){return X1(ue)?ze(ue):mr(ue)}function Ur(){return[]}function kr(){return!1}t.exports=Z1})(_f,_f.exports)),_f.exports}var Pk=Ak();const Ik=Mi(Pk),w_="wc",x_=2,__="core",As=`${w_}@2:${__}:`,Mk={logger:"error"},Ck={database:":memory:"},Rk="crypto",E_="client_ed25519_seed",Tk=vt.ONE_DAY,Dk="keychain",Ok="0.3",Nk="messages",Lk="0.3",kk=vt.SIX_HOURS,Bk="publisher",S_="irn",Fk="error",A_="wss://relay.walletconnect.org",jk="relayer",Jn={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"},Uk="_subscription",ji={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},$k=.1,Em="2.17.2",Hr={link_mode:"link_mode",relay:"relay"},qk="0.3",zk="WALLETCONNECT_CLIENT_ID",P_="WALLETCONNECT_LINK_MODE_APPS",Ps={created:"subscription_created",deleted:"subscription_deleted",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},Hk="subscription",Wk="0.3",Kk=vt.FIVE_SECONDS*1e3,Vk="pairing",Gk="0.3",Ef={wc_pairingDelete:{req:{ttl:vt.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:vt.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:vt.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:vt.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:vt.ONE_DAY,prompt:!1,tag:0},res:{ttl:vt.ONE_DAY,prompt:!1,tag:0}}},Ma={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},os={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},Yk="history",Jk="0.3",Xk="expirer",Ui={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},Zk="0.3",Qk="verify-api",eB="https://verify.walletconnect.com",I_="https://verify.walletconnect.org",Sf=I_,tB=`${Sf}/v3`,rB=[eB,I_],nB="echo",iB="https://echo.walletconnect.com",Is={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"},Xs={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"},as={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"},Ca={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"},Ra={authenticated_session_approve_started:"authenticated_session_approve_started",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"},Af={no_internet_connection:"no_internet_connection",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"},sB=.1,oB="event-client",aB=86400,cB="https://pulse.walletconnect.org/batch";function uB(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,F=new Uint8Array(H);B!==L;){for(var k=S[B],$=0,R=H-1;(k!==0||$>>0,F[R]=k%a>>>0,k=k/a>>>0;if(k!==0)throw new Error("Non-zero carry");D=$,B++}for(var W=H-D;W!==H&&F[W]===0;)W++;for(var V=f.repeat(C);W>>0,H=new Uint8Array(L);S[C];){var F=r[S.charCodeAt(C)];if(F===255)return;for(var k=0,$=L-1;(F!==0||k>>0,H[$]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");B=k,C++}if(S[C]!==" "){for(var R=L-B;R!==L&&H[R]===0;)R++;for(var W=new Uint8Array(D+(L-R)),V=D;R!==L;)W[V++]=H[R++];return W}}}function x(S){var C=b(S);if(C)return C;throw new Error(`Non-${e} character`)}return{encode:g,decodeUnsafe:b,decode:x}}var fB=uB,lB=fB;const M_=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},hB=t=>new TextEncoder().encode(t),dB=t=>new TextDecoder().decode(t);class pB{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class gB{constructor(e,r,n){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=n}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 C_(this,e)}}class mB{constructor(e){this.decoders=e}or(e){return C_(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const C_=(t,e)=>new mB({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class vB{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new pB(e,r,n),this.decoder=new gB(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Gh=({name:t,prefix:e,encode:r,decode:n})=>new vB(t,e,r,n),Pf=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=lB(r,e);return Gh({prefix:t,name:e,encode:n,decode:s=>M_(i(s))})},bB=(t,e,r,n)=>{const i={};for(let h=0;h=8&&(a-=8,o[u++]=255&f>>a)}if(a>=r||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},yB=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<Gh({prefix:e,name:t,encode(i){return yB(i,n,r)},decode(i){return bB(i,n,r,t)}}),wB=Gh({prefix:"\0",name:"identity",encode:t=>dB(t),decode:t=>hB(t)});var xB=Object.freeze({__proto__:null,identity:wB});const _B=On({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var EB=Object.freeze({__proto__:null,base2:_B});const SB=On({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var AB=Object.freeze({__proto__:null,base8:SB});const PB=Pf({prefix:"9",name:"base10",alphabet:"0123456789"});var IB=Object.freeze({__proto__:null,base10:PB});const MB=On({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),CB=On({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var RB=Object.freeze({__proto__:null,base16:MB,base16upper:CB});const TB=On({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),DB=On({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),OB=On({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),NB=On({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),LB=On({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),kB=On({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),BB=On({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),FB=On({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),jB=On({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var UB=Object.freeze({__proto__:null,base32:TB,base32upper:DB,base32pad:OB,base32padupper:NB,base32hex:LB,base32hexupper:kB,base32hexpad:BB,base32hexpadupper:FB,base32z:jB});const $B=Pf({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qB=Pf({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var zB=Object.freeze({__proto__:null,base36:$B,base36upper:qB});const HB=Pf({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),WB=Pf({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var KB=Object.freeze({__proto__:null,base58btc:HB,base58flickr:WB});const VB=On({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),GB=On({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),YB=On({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),JB=On({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var XB=Object.freeze({__proto__:null,base64:VB,base64pad:GB,base64url:YB,base64urlpad:JB});const R_=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),ZB=R_.reduce((t,e,r)=>(t[r]=e,t),[]),QB=R_.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function eF(t){return t.reduce((e,r)=>(e+=ZB[r],e),"")}function tF(t){const e=[];for(const r of t){const n=QB[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const rF=Gh({prefix:"🚀",name:"base256emoji",encode:eF,decode:tF});var nF=Object.freeze({__proto__:null,base256emoji:rF}),iF=D_,T_=128,sF=-128,oF=Math.pow(2,31);function D_(t,e,r){e=e||[],r=r||0;for(var n=r;t>=oF;)e[r++]=t&255|T_,t/=128;for(;t&sF;)e[r++]=t&255|T_,t>>>=7;return e[r]=t|0,D_.bytes=r-n+1,e}var aF=Sm,cF=128,O_=127;function Sm(t,n){var r=0,n=n||0,i=0,s=n,o,a=t.length;do{if(s>=a)throw Sm.bytes=0,new RangeError("Could not decode varint");o=t[s++],r+=i<28?(o&O_)<=cF);return Sm.bytes=s-n,r}var uF=Math.pow(2,7),fF=Math.pow(2,14),lF=Math.pow(2,21),hF=Math.pow(2,28),dF=Math.pow(2,35),pF=Math.pow(2,42),gF=Math.pow(2,49),mF=Math.pow(2,56),vF=Math.pow(2,63),bF=function(t){return t(N_.encode(t,e,r),e),k_=t=>N_.encodingLength(t),Am=(t,e)=>{const r=e.byteLength,n=k_(t),i=n+k_(r),s=new Uint8Array(i+r);return L_(t,s,0),L_(r,s,n),s.set(e,i),new wF(t,r,e,s)};class wF{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const B_=({name:t,code:e,encode:r})=>new xF(t,e,r);class xF{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Am(this.code,r):r.then(n=>Am(this.code,n))}else throw Error("Unknown type, must be binary type")}}const F_=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),_F=B_({name:"sha2-256",code:18,encode:F_("SHA-256")}),EF=B_({name:"sha2-512",code:19,encode:F_("SHA-512")});var SF=Object.freeze({__proto__:null,sha256:_F,sha512:EF});const j_=0,AF="identity",U_=M_;var PF=Object.freeze({__proto__:null,identity:{code:j_,name:AF,encode:U_,digest:t=>Am(j_,U_(t))}});new TextEncoder,new TextDecoder;const $_={...xB,...EB,...AB,...IB,...RB,...UB,...zB,...KB,...XB,...nF};({...SF,...PF});function IF(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function q_(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const z_=q_("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Pm=q_("ascii","a",t=>{let e="a";for(let r=0;r{t=t.substring(1);const e=IF(t.length);for(let r=0;r{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=ut("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=Vn(r,this.name)}get context(){return oi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,A3(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?P3(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}},TF=class{constructor(e,r,n){this.core=e,this.logger=r,this.name=Rk,this.randomSessionIdentifier=pm(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=H2(i);return z2(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=eL();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),o=H2(s),a=this.randomSessionIdentifier;return await MD(a,i,Tk,o)},this.generateSharedKey=(i,s,o)=>{this.isInitialized();const a=this.getPrivateKey(i),f=tL(a,s);return this.setSymKey(f,o)},this.setSymKey=async(i,s)=>{this.isInitialized();const o=s||qh(i);return await this.keychain.set(o,i),o},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,o)=>{this.isInitialized();const a=H3(o),f=Hs(s);if(K3(a))return nL(f,o?.encoding);if(W3(a)){const b=a.senderPublicKey,x=a.receiverPublicKey;i=await this.generateSharedKey(b,x)}const u=this.getSymKey(i),{type:h,senderPublicKey:g}=a;return rL({type:h,symKey:u,message:f,senderPublicKey:g,encoding:o?.encoding})},this.decode=async(i,s,o)=>{this.isInitialized();const a=oL(s,o);if(K3(a)){const f=sL(s,o?.encoding);return ma(f)}if(W3(a)){const f=a.receiverPublicKey,u=a.senderPublicKey;i=await this.generateSharedKey(f,u)}try{const f=this.getSymKey(i),u=iL({symKey:f,encoded:s,encoding:o?.encoding});return ma(u)}catch(f){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`),this.logger.error(f)}},this.getPayloadType=(i,s=Do)=>{const o=mf({encoded:i,encoding:s});return Aa(o.type)},this.getPayloadSenderPublicKey=(i,s=Do)=>{const o=mf({encoded:i,encoding:s});return o.senderPublicKey?An(o.senderPublicKey,Gn):void 0},this.core=e,this.logger=Vn(r,this.name),this.keychain=n||new RF(this.core,this.logger)}get context(){return oi(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(E_)}catch{e=pm(),await this.keychain.set(E_,e)}return CF(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}};class DF extends nT{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=Nk,this.version=Lk,this.initialized=!1,this.storagePrefix=As,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=Gs(i);let o=this.messages.get(n);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=i,this.messages.set(n,o),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),o=Gs(i);return typeof s[o]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Vn(e,this.name),this.core=r}get context(){return oi(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,A3(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?P3(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}}class OF extends iT{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new Di.EventEmitter,this.name=Bk,this.queue=new Map,this.publishTimeout=vt.toMiliseconds(vt.ONE_MINUTE),this.failedPublishTimeout=vt.toMiliseconds(vt.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(n,i,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});const a=s?.ttl||kk,f=gm(s),u=s?.prompt||!1,h=s?.tag||0,g=s?.id||Ia().toString(),b={topic:n,message:i,opts:{ttl:a,relay:f,prompt:u,tag:h,id:g,attestation:s?.attestation}},x=`Failed to publish payload, please try again. id:${g} tag:${h}`,S=Date.now();let C,D=1;try{for(;C===void 0;){if(Date.now()-S>this.publishTimeout)throw new Error(x);this.logger.trace({id:g,attempts:D},`publisher.publish - attempt ${D}`),C=await await Ac(this.rpcPublish(n,i,a,f,u,h,g,s?.attestation).catch(B=>this.logger.warn(B)),this.publishTimeout,x),D++,C||await new Promise(B=>setTimeout(B,this.failedPublishTimeout))}this.relayer.events.emit(Jn.publish,b),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:g,topic:n,message:i,opts:s}})}catch(B){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(B),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw B;this.queue.set(g,b)}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Vn(r,this.name),this.registerEventListeners()}get context(){return oi(this.logger)}rpcPublish(e,r,n,i,s,o,a,f){var u,h,g,b;const x={method:vf(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:o,attestation:f},id:a};return Yn((u=x.params)==null?void 0:u.prompt)&&((h=x.params)==null||delete h.prompt),Yn((g=x.params)==null?void 0:g.tag)&&((b=x.params)==null||delete b.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:x}),this.relayer.request(x)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:n,opts:i}=e;await this.publish(r,n,i)})}registerEventListeners(){this.relayer.core.heartbeat.on(vc.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Jn.connection_stalled);return}this.checkQueue()}),this.relayer.on(Jn.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class NF{constructor(){this.map=new Map,this.set=(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,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;const n=this.get(e);if(!this.exists(e,r))return;const i=n.filter(s=>s!==r);if(!i.length){this.map.delete(e);return}this.map.set(e,i)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var LF=Object.defineProperty,kF=Object.defineProperties,BF=Object.getOwnPropertyDescriptors,H_=Object.getOwnPropertySymbols,FF=Object.prototype.hasOwnProperty,jF=Object.prototype.propertyIsEnumerable,W_=(t,e,r)=>e in t?LF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,If=(t,e)=>{for(var r in e||(e={}))FF.call(e,r)&&W_(t,r,e[r]);if(H_)for(var r of H_(e))jF.call(e,r)&&W_(t,r,e[r]);return t},Im=(t,e)=>kF(t,BF(e));class UF extends aT{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new NF,this.events=new Di.EventEmitter,this.name=Hk,this.version=Wk,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=As,this.subscribeTimeout=vt.toMiliseconds(vt.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(n,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const s=gm(i),o={topic:n,relay:s,transportType:i?.transportType};this.pending.set(n,o);const a=await this.rpcSubscribe(n,s,i);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(n,i)=>{await this.restartToComplete(),this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>{if(this.topics.includes(n))return!0;const i=`${this.pendingSubscriptionWatchLabel}_${n}`;return await new Promise((s,o)=>{const a=new vt.Watch;a.start(i);const f=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(f),a.stop(i),s(!0)),a.elapsed(i)>=Kk&&(clearInterval(f),a.stop(i),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},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=Vn(r,this.name),this.clientId=""}get context(){return oi(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 n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const n=this.topicMap.get(e);await Promise.all(n.map(async i=>await this.unsubscribeById(e,i,r)))}async unsubscribeById(e,r,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}});try{const i=gm(n);await this.rpcUnsubscribe(e,r,i);const s=Dr("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,r,n){var i;n?.transportType===Hr.relay&&await this.restartToComplete();const s={method:vf(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});const o=(i=n?.internal)==null?void 0:i.throwOnFailedPublish;try{const a=Gs(e+this.clientId);if(n?.transportType===Hr.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},vt.toMiliseconds(vt.ONE_SECOND)),a;const f=await Ac(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(Jn.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,n={method:vf(r.protocol).batchSubscribe,params:{topics:e.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return await await Ac(this.relayer.request(n).catch(i=>this.logger.warn(i)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jn.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const r=e[0].relay,n={method:vf(r.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=await await Ac(this.relayer.request(n).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Jn.connection_stalled)}return i}rpcUnsubscribe(e,r,n){const i={method:vf(n.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,r){this.setSubscription(e,Im(If({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,If({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,n){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,n),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,If({},r)),this.topicMap.set(r.topic,e),this.events.emit(Ps.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:n}=ut("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Ps.deleted,Im(If({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Ps.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=ut("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;const r=await this.rpcBatchSubscribe(e);Pa(r)&&this.onBatchSubscribe(r.map((n,i)=>Im(If({},e[i]),{id:n})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const 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;const 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(vc.pulse,async()=>{await this.checkPending()}),this.events.on(Ps.created,async e=>{const r=Ps.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Ps.deleted,async e=>{const r=Ps.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ut("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=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),e())},this.pollingInterval)})}}var $F=Object.defineProperty,K_=Object.getOwnPropertySymbols,qF=Object.prototype.hasOwnProperty,zF=Object.prototype.propertyIsEnumerable,V_=(t,e,r)=>e in t?$F(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,G_=(t,e)=>{for(var r in e||(e={}))qF.call(e,r)&&V_(t,r,e[r]);if(K_)for(var r of K_(e))zF.call(e,r)&&V_(t,r,e[r]);return t};class HF extends sT{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Di.EventEmitter,this.name=jk,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=vt.toMiliseconds(vt.THIRTY_SECONDS+vt.ONE_SECOND),this.request=async r=>{var n,i;this.logger.debug("Publishing Request Payload");const s=r.id||Ia().toString();await this.toEstablishConnection();try{const o=this.provider.request(r);this.requestsInFlight.set(s,{promise:o,request:r}),this.logger.trace({id:s,method:r.method,topic:(n=r.params)==null?void 0:n.topic},"relayer.request - attempt to publish...");const a=await new Promise(async(f,u)=>{const h=()=>{u(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(ji.disconnect,h);const g=await o;this.provider.off(ji.disconnect,h),f(g)});return this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.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(Fh())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,n,i;(i=(n=(r=this.provider)==null?void 0:r.connection)==null?void 0:n.socket)==null||i.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(Jn.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Jn.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(ji.payload,this.onPayloadHandler),this.provider.on(ji.connect,this.onConnectHandler),this.provider.on(ji.disconnect,this.onDisconnectHandler),this.provider.on(ji.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Vn(e.logger,this.name):Gu(hh({level:e.logger||Fk})),this.messages=new DF(this.logger,e.core),this.subscriber=new UF(this,this.logger),this.publisher=new OF(this,this.logger),this.relayUrl=e?.relayUrl||A_,this.projectId=e.projectId,this.bundleId=bN(),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 oi(this.logger)}get connected(){var e,r,n;return((n=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===1}get connecting(){var e,r,n;return((n=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===0}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:Hr.relay})}async subscribe(e,r){var n,i,s;this.isInitialized(),r?.transportType==="relay"&&await this.toEstablishConnection();const o=typeof((n=r?.internal)==null?void 0:n.throwOnFailedPublish)>"u"?!0:(i=r?.internal)==null?void 0:i.throwOnFailedPublish;let a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",f;const u=h=>{h.topic===e&&(this.subscriber.off(Ps.created,u),f())};return await Promise.all([new Promise(h=>{f=h,this.subscriber.on(Ps.created,u)}),new Promise(async(h,g)=>{a=await this.subscriber.subscribe(e,G_({internal:{throwOnFailedPublish:o}},r)).catch(b=>{o&&g(b)})||a,h()})]),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.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Ac(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,n)=>{const i=()=>{this.provider.off(ji.disconnect,i),n(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(ji.disconnect,i),await Ac(this.provider.connect(),vt.toMiliseconds(vt.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{n(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){this.logger.error(r);const n=r;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(n.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 s_())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}const r=e.sort((n,i)=>n.publishedAt-i.publishedAt);this.logger.trace(`Batch of ${r.length} message events sorted`);for(const n of r)try{await this.onMessageEvent(n)}catch(i){this.logger.warn(i)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){const{topic:n}=e;if(!r.sessionExists){const i=wn(vt.FIVE_MINUTES),s={topic:n,expiry:i,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(n,s)}this.events.emit(Jn.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,r,n,i,s;if(Fh())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((s=(i=(n=this.provider)==null?void 0:n.connection)==null?void 0:i.socket)==null||s.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();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Fi(new Sk(_N({sdkVersion:Em,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:r,message:n}=e;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;if(!n||n.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const i=this.messages.has(r,n);return i&&this.logger.debug(`Ignoring duplicate message: ${n}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),_m(e)){if(!e.method.endsWith(Uk))return;const r=e.params,{topic:n,message:i,publishedAt:s,attestation:o}=r.data,a={topic:n,message:i,publishedAt:s,transportType:Hr.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(G_({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Vh(e)&&this.events.emit(Jn.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Jn.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Wh(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(ji.payload,this.onPayloadHandler),this.provider.off(ji.connect,this.onConnectHandler),this.provider.off(ji.disconnect,this.onDisconnectHandler),this.provider.off(ji.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await s_();QL(async r=>{e!==r&&(e=r,r?await this.restartTransport().catch(n=>this.logger.error(n)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Jn.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},vt.toMiliseconds($k))))}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}}var WF=Object.defineProperty,Y_=Object.getOwnPropertySymbols,KF=Object.prototype.hasOwnProperty,VF=Object.prototype.propertyIsEnumerable,J_=(t,e,r)=>e in t?WF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,X_=(t,e)=>{for(var r in e||(e={}))KF.call(e,r)&&J_(t,r,e[r]);if(Y_)for(var r of Y_(e))VF.call(e,r)&&J_(t,r,e[r]);return t};class Ta extends oT{constructor(e,r,n,i=As,s=void 0){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=qk,this.cached=[],this.initialized=!1,this.storagePrefix=As,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&&!Yn(o)?this.map.set(this.getKey(o),o):RL(o)?this.map.set(o.id,o):TL(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=>Ik(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});const f=X_(X_({},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=Vn(r,this.name),this.storagePrefix=i,this.getKey=s}get context(){return oi(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){const r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){const{message:i}=ut("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}const{message:n}=ut("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=ut("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){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}}class GF{constructor(e,r){this.core=e,this.logger=r,this.name=Vk,this.version=Gk,this.events=new qp,this.initialized=!1,this.storagePrefix=As,this.ignoredPayloadTypes=[Vs],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:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async n=>{this.isInitialized();const i=pm(),s=await this.core.crypto.setSymKey(i),o=wn(vt.FIVE_MINUTES),a={protocol:S_},f={topic:s,expiry:o,relay:a,active:!1,methods:n?.methods},u=X3({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:i,relay:a,expiryTimestamp:o,methods:n?.methods});return this.events.emit(Ma.create,f),this.core.expirer.set(s,o),await this.pairings.set(s,f),await this.core.relayer.subscribe(s,{transportType:n?.transportType}),{topic:s,uri:u}},this.pair=async n=>{this.isInitialized();const i=this.core.eventClient.createEvent({properties:{topic:n?.uri,trace:[Is.pairing_started]}});this.isValidPair(n,i);const{topic:s,symKey:o,relay:a,expiryTimestamp:f,methods:u}=J3(n.uri);i.props.properties.topic=s,i.addTrace(Is.pairing_uri_validation_success),i.addTrace(Is.pairing_uri_not_expired);let h;if(this.pairings.keys.includes(s)){if(h=this.pairings.get(s),i.addTrace(Is.existing_pairing),h.active)throw i.setError(Xs.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);i.addTrace(Is.pairing_not_expired)}const g=f||wn(vt.FIVE_MINUTES),b={topic:s,relay:a,expiry:g,active:!1,methods:u};this.core.expirer.set(s,g),await this.pairings.set(s,b),i.addTrace(Is.store_new_pairing),n.activatePairing&&await this.activate({topic:s}),this.events.emit(Ma.create,b),i.addTrace(Is.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),i.addTrace(Is.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(Xs.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(x){throw i.setError(Xs.subscribe_pairing_topic_failure),x}return i.addTrace(Is.subscribe_pairing_topic_success),b},this.activate=async({topic:n})=>{this.isInitialized();const i=wn(vt.THIRTY_DAYS);this.core.expirer.set(n,i),await this.pairings.update(n,{active:!0,expiry:i})},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:i}=n;if(this.pairings.keys.includes(i)){const s=await this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:f}=Ea();this.events.once(yr("pairing_ping",s),({error:u})=>{u?f(u):a()}),await o()}},this.updateExpiry=async({topic:n,expiry:i})=>{this.isInitialized(),await this.pairings.update(n,{expiry:i})},this.updateMetadata=async({topic:n,metadata:i})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:i})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:i}=n;this.pairings.keys.includes(i)&&(await this.sendRequest(i,"wc_pairingDelete",Dr("USER_DISCONNECTED")),await this.deletePairing(i))},this.formatUriFromPairing=n=>{this.isInitialized();const{topic:i,relay:s,expiry:o,methods:a}=n,f=this.core.crypto.keychain.get(i);return X3({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:f,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(n,i,s)=>{const o=No(i,s),a=await this.core.crypto.encode(n,o),f=Ef[i].req;return this.core.history.set(n,o),this.core.relayer.publish(n,a,f),o.id},this.sendResult=async(n,i,s)=>{const o=Wh(n,s),a=await this.core.crypto.encode(i,o),f=await this.core.history.get(i,n),u=Ef[f.request.method].res;await this.core.relayer.publish(i,a,u),await this.core.history.resolve(o)},this.sendError=async(n,i,s)=>{const o=Kh(n,s),a=await this.core.crypto.encode(i,o),f=await this.core.history.get(i,n),u=Ef[f.request.method]?Ef[f.request.method].res:Ef.unregistered_method.res;await this.core.relayer.publish(i,a,u),await this.core.history.resolve(o)},this.deletePairing=async(n,i)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Dr("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(i=>To(i.expiry));await Promise.all(n.map(i=>this.deletePairing(i.topic)))},this.onRelayEventRequest=n=>{const{topic:i,payload:s}=n;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(i,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(i,s);default:return this.onUnknownRpcMethodRequest(i,s)}},this.onRelayEventResponse=async n=>{const{topic:i,payload:s}=n,o=(await this.core.history.get(i,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(n,i)=>{const{id:s}=i;try{this.isValidPing({topic:n}),await this.sendResult(s,n,!0),this.events.emit(Ma.ping,{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onPairingPingResponse=(n,i)=>{const{id:s}=i;setTimeout(()=>{Ss(i)?this.events.emit(yr("pairing_ping",s),{}):Bi(i)&&this.events.emit(yr("pairing_ping",s),{error:i.error})},500)},this.onPairingDeleteRequest=async(n,i)=>{const{id:s}=i;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit(Ma.delete,{id:s,topic:n})}catch(o){await this.sendError(s,n,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(n,i)=>{const{id:s,method:o}=i;try{if(this.registeredMethods.includes(o))return;const a=Dr("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,n,a),this.logger.error(a)}catch(a){await this.sendError(s,n,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(Dr("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=(n,i)=>{var s;if(!ai(n)){const{message:a}=ut("MISSING_OR_INVALID",`pair() params: ${n}`);throw i.setError(Xs.malformed_pairing_uri),new Error(a)}if(!CL(n.uri)){const{message:a}=ut("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw i.setError(Xs.malformed_pairing_uri),new Error(a)}const o=J3(n?.uri);if(!((s=o?.relay)!=null&&s.protocol)){const{message:a}=ut("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(Xs.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=ut("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(Xs.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&vt.toMiliseconds(o?.expiryTimestamp){if(!ai(n)){const{message:s}=ut("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidDisconnect=async n=>{if(!ai(n)){const{message:s}=ut("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}const{topic:i}=n;await this.isValidPairingTopic(i)},this.isValidPairingTopic=async n=>{if(!nn(n,!1)){const{message:i}=ut("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){const{message:i}=ut("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(To(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:i}=ut("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}},this.core=e,this.logger=Vn(r,this.name),this.pairings=new Ta(this.core,this.logger,this.name,this.storagePrefix)}get context(){return oi(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Jn.message,async e=>{const{topic:r,message:n,transportType:i}=e;if(!this.pairings.keys.includes(r)||i===Hr.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const s=await this.core.crypto.decode(r,n);try{_m(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):Vh(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Ui.expired,async e=>{const{topic:r}=M3(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Ma.expire,{topic:r}))})}}class YF extends rT{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new Di.EventEmitter,this.name=Yk,this.version=Jk,this.cached=[],this.initialized=!1,this.storagePrefix=As,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;const o={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s,expiry:wn(vt.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(os.created,o)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const i=await this.getRecord(n.id);typeof i.response>"u"&&(i.response=Bi(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.persist(),this.events.emit(os.updated,i))},this.get=async(n,i)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i}),await this.getRecord(i)),this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(os.deleted,s)}}),this.persist()},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Vn(r,this.name)}get context(){return oi(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(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const n={topic:r.topic,request:No(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(n)}),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();const r=this.records.get(e);if(!r){const{message:n}=ut("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(os.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=ut("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(os.created,e=>{const r=os.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(os.updated,e=>{const r=os.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(os.deleted,e=>{const r=os.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(vc.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{vt.toMiliseconds(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(os.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}}class JF extends cT{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new Di.EventEmitter,this.name=Xk,this.version=Zk,this.cached=[],this.initialized=!1,this.storagePrefix=As,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},this.set=(n,i)=>{this.isInitialized();const s=this.formatTarget(n),o={target:s,expiry:i};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Ui.created,{target:s,expiration:o})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{if(this.isInitialized(),this.has(n)){const i=this.formatTarget(n),s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Ui.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Vn(r,this.name)}get context(){return oi(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 EN(e);if(typeof e=="number")return SN(e);const{message:r}=ut("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(Ui.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=ut("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){const r=this.expirations.get(e);if(!r){const{message:n}=ut("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;vt.toMiliseconds(n)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Ui.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(vc.pulse,()=>this.checkExpirations()),this.events.on(Ui.created,e=>{const r=Ui.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Ui.expired,e=>{const r=Ui.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Ui.deleted,e=>{const r=Ui.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}}class XF extends uT{constructor(e,r,n){super(e,r,n),this.core=e,this.logger=r,this.store=n,this.name=Qk,this.verifyUrlV3=tB,this.storagePrefix=As,this.version=x_,this.init=async()=>{var i;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&vt.toMiliseconds((i=this.publicKey)==null?void 0:i.expiresAt){if(!uf()||this.isDevEnv)return;const s=window.location.origin,{id:o,decryptedId:a}=i,f=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{const u=va.getDocument(),h=this.startAbortTimer(vt.ONE_SECOND*5),g=await new Promise((b,x)=>{const S=()=>{window.removeEventListener("message",D),u.body.removeChild(C),x("attestation aborted")};this.abortController.signal.addEventListener("abort",S);const C=u.createElement("iframe");C.src=f,C.style.display="none",C.addEventListener("error",S,{signal:this.abortController.signal});const D=B=>{if(B.data&&typeof B.data=="string")try{const L=JSON.parse(B.data);if(L.type==="verify_attestation"){if(ug(L.attestation).payload.id!==o)return;clearInterval(h),u.body.removeChild(C),this.abortController.signal.removeEventListener("abort",S),window.removeEventListener("message",D),b(L.attestation===null?"":L.attestation)}}catch(L){this.logger.warn(L)}};u.body.appendChild(C),window.addEventListener("message",D,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",g),g}catch(u){this.logger.warn(u)}return""},this.resolve=async i=>{if(this.isDevEnv)return"";const{attestationId:s,hash:o,encryptedId:a}=i;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(ug(s).payload.id!==a)return;const 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;const f=this.getVerifyUrl(i?.verifyUrl);return this.fetchAttestation(o,f)},this.fetchAttestation=async(i,s)=>{this.logger.debug(`resolving attestation: ${i} from url: ${s}`);const o=this.startAbortTimer(vt.ONE_SECOND*5),a=await fetch(`${s}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=i=>{let s=i||Sf;return rB.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Sf}`),s=Sf),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const i=this.startAbortTimer(vt.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),await s.json()}catch(i){this.logger.warn(i)}},this.persistPublicKey=async i=>{this.logger.debug("persisting public key to local storage",i),await this.store.setItem(this.storeKey,i),this.publicKey=i},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 i=>{const s=await this.getPublicKey();try{if(s)return this.validateAttestation(i,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,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=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});const i=await this.fetchPromise;return this.fetchPromise=void 0,i},this.validateAttestation=(i,s)=>{const o=fL(i,s.publicKey),a={hasExpired:vt.toMiliseconds(o.exp)this.abortController.abort(),vt.toMiliseconds(e))}}class ZF extends fT{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.context=nB,this.registerDeviceToken=async n=>{const{clientId:i,token:s,notificationType:o,enableEncrypted:a=!1}=n,f=`${iB}/${this.projectId}/clients`;await fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:s,always_raw:a})})},this.logger=Vn(r,this.context)}}var QF=Object.defineProperty,Z_=Object.getOwnPropertySymbols,ej=Object.prototype.hasOwnProperty,tj=Object.prototype.propertyIsEnumerable,Q_=(t,e,r)=>e in t?QF(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Mf=(t,e)=>{for(var r in e||(e={}))ej.call(e,r)&&Q_(t,r,e[r]);if(Z_)for(var r of Z_(e))tj.call(e,r)&&Q_(t,r,e[r]);return t};class rj extends lT{constructor(e,r,n=!0){super(e,r,n),this.core=e,this.logger=r,this.context=oB,this.storagePrefix=As,this.storageVersion=sB,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!fm())try{const i={eventId:R3(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:S3(this.core.relayer.protocol,this.core.relayer.version,Em)}}};await this.sendEvent([i])}catch(i){this.logger.warn(i)}},this.createEvent=i=>{const{event:s="ERROR",type:o="",properties:{topic:a,trace:f}}=i,u=R3(),h=this.core.projectId||"",g=Date.now(),b=Mf({eventId:u,timestamp:g,props:{event:s,type:o,properties:{topic:a,trace:f}},bundleId:h,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,b),this.shouldPersist=!0),b},this.getEvent=i=>{const{eventId:s,topic:o}=i;if(s)return this.events.get(s);const a=Array.from(this.events.values()).find(f=>f.props.properties.topic===o);if(a)return Mf(Mf({},a),this.setMethods(a.eventId))},this.deleteEvent=i=>{const{eventId:s}=i;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(vc.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(i=>{vt.fromMiliseconds(Date.now())-vt.fromMiliseconds(i.timestamp)>aB&&(this.events.delete(i.eventId),this.shouldPersist=!0)})})},this.setMethods=i=>({addTrace:s=>this.addTrace(i,s),setError:s=>this.setError(i,s)}),this.addTrace=(i,s)=>{const o=this.events.get(i);o&&(o.props.properties.trace.push(s),this.events.set(i,o),this.shouldPersist=!0)},this.setError=(i,s)=>{const o=this.events.get(i);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(i,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{const i=await this.core.storage.getItem(this.storageKey)||[];if(!i.length)return;i.forEach(s=>{this.events.set(s.eventId,Mf(Mf({},s),this.setMethods(s.eventId)))})}catch(i){this.logger.warn(i)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const i=[];for(const[s,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((await this.sendEvent(i)).ok)for(const s of i)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async i=>{const s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${cB}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Em}${s}`,{method:"POST",body:JSON.stringify(i)})},this.getAppDomain=()=>E3().url,this.logger=Vn(r,this.context),this.telemetryEnabled=n,n?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var nj=Object.defineProperty,e6=Object.getOwnPropertySymbols,ij=Object.prototype.hasOwnProperty,sj=Object.prototype.propertyIsEnumerable,t6=(t,e,r)=>e in t?nj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,r6=(t,e)=>{for(var r in e||(e={}))ij.call(e,r)&&t6(t,r,e[r]);if(e6)for(var r of e6(e))sj.call(e,r)&&t6(t,r,e[r]);return t};class Mm extends tT{constructor(e){var r;super(e),this.protocol=w_,this.version=x_,this.name=__,this.events=new Di.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;const u={topic:o,message:a,publishedAt:Date.now(),transportType:Hr.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:f})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||A_,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const n=hh({level:typeof e?.logger=="string"&&e.logger?e.logger:Mk.logger}),{logger:i,chunkLoggerController:s}=eT({opts:n,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(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=Vn(i,this.name),this.heartbeat=new sR,this.crypto=new TF(this,this.logger,e?.keychain),this.history=new YF(this,this.logger),this.expirer=new JF(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new BR(r6(r6({},Ck),e?.storageOptions)),this.relayer=new HF({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new GF(this,this.logger),this.verify=new XF(this,this.logger,this.storage),this.echoClient=new ZF(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new rj(this,this.logger,e?.telemetryEnabled)}static async init(e){const r=new Mm(e);await r.initialize();const n=await r.crypto.getClientId();return await r.storage.setItem(zk,n),r}get context(){return oi(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(P_,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(P_)||[],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}}}const oj=Mm,n6="wc",i6=2,s6="client",Cm=`${n6}@${i6}:${s6}:`,Rm={name:s6,logger:"error"},o6="WALLETCONNECT_DEEPLINK_CHOICE",aj="proposal",a6="Proposal expired",cj="session",Ic=vt.SEVEN_DAYS,uj="engine",Mn={wc_sessionPropose:{req:{ttl:vt.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:vt.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:vt.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:vt.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:vt.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:vt.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:vt.ONE_DAY,prompt:!1,tag:1104},res:{ttl:vt.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:vt.ONE_DAY,prompt:!1,tag:1106},res:{ttl:vt.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:vt.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:vt.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:vt.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:vt.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:vt.ONE_DAY,prompt:!1,tag:1112},res:{ttl:vt.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:vt.ONE_DAY,prompt:!1,tag:1114},res:{ttl:vt.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:vt.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:vt.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:vt.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:vt.FIVE_MINUTES,prompt:!1,tag:1119}}},Tm={min:vt.FIVE_MINUTES,max:vt.SEVEN_DAYS},Ms={idle:"IDLE",active:"ACTIVE"},fj="request",lj=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],hj="wc",dj="auth",pj="authKeys",gj="pairingTopics",mj="requests",Yh=`${hj}@${1.5}:${dj}:`,Jh=`${Yh}:PUB_KEY`;var vj=Object.defineProperty,bj=Object.defineProperties,yj=Object.getOwnPropertyDescriptors,c6=Object.getOwnPropertySymbols,wj=Object.prototype.hasOwnProperty,xj=Object.prototype.propertyIsEnumerable,u6=(t,e,r)=>e in t?vj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,en=(t,e)=>{for(var r in e||(e={}))wj.call(e,r)&&u6(t,r,e[r]);if(c6)for(var r of c6(e))xj.call(e,r)&&u6(t,r,e[r]);return t},cs=(t,e)=>bj(t,yj(e));class _j extends dT{constructor(e){super(e),this.name=uj,this.events=new qp,this.initialized=!1,this.requestQueue={state:Ms.idle,queue:[]},this.sessionRequestQueue={state:Ms.idle,queue:[]},this.requestQueueDelay=vt.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(Mn)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},vt.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const n=cs(en({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(n);const{pairingTopic:i,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:f}=n;let u=i,h,g=!1;try{u&&(g=this.client.core.pairing.pairings.get(u).active)}catch(F){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),F}if(!u||!g){const{topic:F,uri:k}=await this.client.core.pairing.create();u=F,h=k}if(!u){const{message:F}=ut("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(F)}const b=await this.client.core.crypto.generateKeyPair(),x=Mn.wc_sessionPropose.req.ttl||vt.FIVE_MINUTES,S=wn(x),C=en({requiredNamespaces:s,optionalNamespaces:o,relays:f??[{protocol:S_}],proposer:{publicKey:b,metadata:this.client.metadata},expiryTimestamp:S,pairingTopic:u},a&&{sessionProperties:a}),{reject:D,resolve:B,done:L}=Ea(x,a6);this.events.once(yr("session_connect"),async({error:F,session:k})=>{if(F)D(F);else if(k){k.self.publicKey=b;const $=cs(en({},k),{pairingTopic:C.pairingTopic,requiredNamespaces:C.requiredNamespaces,optionalNamespaces:C.optionalNamespaces,transportType:Hr.relay});await this.client.session.set(k.topic,$),await this.setExpiry(k.topic,k.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:k.peer.metadata}),this.cleanupDuplicatePairings($),B($)}});const H=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:C,throwOnFailedPublish:!0});return await this.setProposal(H,en({id:H},C)),{uri:h,approval:L}},this.pair=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(n){throw this.client.logger.error("pair() failed"),n}},this.approve=async r=>{var n,i,s;const o=this.client.core.eventClient.createEvent({properties:{topic:(n=r?.id)==null?void 0:n.toString(),trace:[as.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(W){throw o.setError(Ca.no_internet_connection),W}try{await this.isValidProposalId(r?.id)}catch(W){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(Ca.proposal_not_found),W}try{await this.isValidApprove(r)}catch(W){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Ca.session_approve_namespace_validation_failure),W}const{id:a,relayProtocol:f,namespaces:u,sessionProperties:h,sessionConfig:g}=r,b=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:x,proposer:S,requiredNamespaces:C,optionalNamespaces:D}=b;let B=(i=this.client.core.eventClient)==null?void 0:i.getEvent({topic:x});B||(B=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:as.session_approve_started,properties:{topic:x,trace:[as.session_approve_started,as.session_namespaces_validation_success]}}));const L=await this.client.core.crypto.generateKeyPair(),H=S.publicKey,F=await this.client.core.crypto.generateSharedKey(L,H),k=en(en({relay:{protocol:f??"irn"},namespaces:u,controller:{publicKey:L,metadata:this.client.metadata},expiry:wn(Ic)},h&&{sessionProperties:h}),g&&{sessionConfig:g}),$=Hr.relay;B.addTrace(as.subscribing_session_topic);try{await this.client.core.relayer.subscribe(F,{transportType:$})}catch(W){throw B.setError(Ca.subscribe_session_topic_failure),W}B.addTrace(as.subscribe_session_topic_success);const R=cs(en({},k),{topic:F,requiredNamespaces:C,optionalNamespaces:D,pairingTopic:x,acknowledged:!1,self:k.controller,peer:{publicKey:S.publicKey,metadata:S.metadata},controller:L,transportType:Hr.relay});await this.client.session.set(F,R),B.addTrace(as.store_session);try{B.addTrace(as.publishing_session_settle),await this.sendRequest({topic:F,method:"wc_sessionSettle",params:k,throwOnFailedPublish:!0}).catch(W=>{throw B?.setError(Ca.session_settle_publish_failure),W}),B.addTrace(as.session_settle_publish_success),B.addTrace(as.publishing_session_approve),await this.sendResult({id:a,topic:x,result:{relay:{protocol:f??"irn"},responderPublicKey:L},throwOnFailedPublish:!0}).catch(W=>{throw B?.setError(Ca.session_approve_publish_failure),W}),B.addTrace(as.session_approve_publish_success)}catch(W){throw this.client.logger.error(W),this.client.session.delete(F,Dr("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(F),W}return this.client.core.eventClient.deleteEvent({eventId:B.eventId}),await this.client.core.pairing.updateMetadata({topic:x,metadata:S.metadata}),await this.client.proposal.delete(a,Dr("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:x}),await this.setExpiry(F,wn(Ic)),{topic:F,acknowledged:()=>Promise.resolve(this.client.session.get(F))}},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}const{id:n,reason:i}=r;let s;try{s=this.client.proposal.get(n).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${n}) failed`),o}s&&(await this.sendError({id:n,topic:s,error:i,rpcOpts:Mn.wc_sessionPropose.reject}),await this.client.proposal.delete(n,Dr("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(g){throw this.client.logger.error("update() -> isValidUpdate() failed"),g}const{topic:n,namespaces:i}=r,{done:s,resolve:o,reject:a}=Ea(),f=Oo(),u=Ia().toString(),h=this.client.session.get(n).namespaces;return this.events.once(yr("session_update",f),({error:g})=>{g?a(g):o()}),await this.client.session.update(n,{namespaces:i}),await this.sendRequest({topic:n,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:f,relayRpcId:u}).catch(g=>{this.client.logger.error(g),this.client.session.update(n,{namespaces:h}),a(g)}),{acknowledged:s}},this.extend=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(f){throw this.client.logger.error("extend() -> isValidExtend() failed"),f}const{topic:n}=r,i=Oo(),{done:s,resolve:o,reject:a}=Ea();return this.events.once(yr("session_extend",i),({error:f})=>{f?a(f):o()}),await this.setExpiry(n,wn(Ic)),this.sendRequest({topic:n,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(f=>{a(f)}),{acknowledged:s}},this.request=async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(S){throw this.client.logger.error("request() -> isValidRequest() failed"),S}const{chainId:n,request:i,topic:s,expiry:o=Mn.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(s);a?.transportType===Hr.relay&&await this.confirmOnlineStateOrThrow();const f=Oo(),u=Ia().toString(),{done:h,resolve:g,reject:b}=Ea(o,"Request expired. Please try again.");this.events.once(yr("session_request",f),({error:S,result:C})=>{S?b(S):g(C)});const x=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return x?(await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:cs(en({},i),{expiryTimestamp:wn(o)}),chainId:n},expiry:o,throwOnFailedPublish:!0,appLink:x}).catch(S=>b(S)),this.client.events.emit("session_request_sent",{topic:s,request:i,chainId:n,id:f}),await h()):await Promise.all([new Promise(async S=>{await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:cs(en({},i),{expiryTimestamp:wn(o)}),chainId:n},expiry:o,throwOnFailedPublish:!0}).catch(C=>b(C)),this.client.events.emit("session_request_sent",{topic:s,request:i,chainId:n,id:f}),S()}),new Promise(async S=>{var C;if(!((C=a.sessionConfig)!=null&&C.disableDeepLink)){const D=await IN(this.client.core.storage,o6);await AN({id:f,topic:s,wcDeepLink:D})}S()}),h()]).then(S=>S[2])},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i,o=this.client.session.get(n);o.transportType===Hr.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Ss(i)?await this.sendResult({id:s,topic:n,result:i.result,throwOnFailedPublish:!0,appLink:a}):Bi(i)&&await this.sendError({id:s,topic:n,error:i.error,appLink:a}),this.cleanupAfterResponse(r)},this.ping=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(i){throw this.client.logger.error("ping() -> isValidPing() failed"),i}const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=Oo(),s=Ia().toString(),{done:o,resolve:a,reject:f}=Ea();this.events.once(yr("session_ping",i),({error:u})=>{u?f(u):a()}),await Promise.all([this.sendRequest({topic:n,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:i,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r,o=Ia().toString();await this.sendRequest({topic:n,method:"wc_sessionEvent",params:{event:i,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);const{topic:n}=r;if(this.client.session.keys.includes(n))await this.sendRequest({topic:n,method:"wc_sessionDelete",params:Dr("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:n,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(n))await this.client.core.pairing.disconnect({topic:n});else{const{message:i}=ut("MISMATCHED_TOPIC",`Session or pairing topic not found: ${n}`);throw new Error(i)}},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>IL(n,r))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(r,n)=>{var i;this.isInitialized(),this.isValidAuthenticate(r);const s=n&&this.client.core.linkModeSupportedApps.includes(n)&&((i=this.client.metadata.redirect)==null?void 0:i.linkMode),o=s?Hr.link_mode:Hr.relay;o===Hr.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:f="",uri:u,domain:h,nonce:g,type:b,exp:x,nbf:S,methods:C=[],expiry:D}=r,B=[...r.resources||[]],{topic:L,uri:H}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:L,uri:H}});const F=await this.client.core.crypto.generateKeyPair(),k=qh(F);if(await Promise.all([this.client.auth.authKeys.set(Jh,{responseTopic:k,publicKey:F}),this.client.auth.pairingTopics.set(k,{topic:k,pairingTopic:L})]),await this.client.core.relayer.subscribe(k,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${L}`),C.length>0){const{namespace:A}=Ec(a[0]);let E=GN(A,"request",C);$h(B)&&(E=JN(E,B.pop())),B.push(E)}const $=D&&D>Mn.wc_sessionAuthenticate.req.ttl?D:Mn.wc_sessionAuthenticate.req.ttl,R={authPayload:{type:b??"caip122",chains:a,statement:f,aud:u,domain:h,version:"1",nonce:g,iat:new Date().toISOString(),exp:x,nbf:S,resources:B},requester:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:wn($)},W={eip155:{chains:a,methods:[...new Set(["personal_sign",...C])],events:["chainChanged","accountsChanged"]}},V={requiredNamespaces:{},optionalNamespaces:W,relays:[{protocol:"irn"}],pairingTopic:L,proposer:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:wn(Mn.wc_sessionPropose.req.ttl)},{done:X,resolve:q,reject:_}=Ea($,"Request expired"),v=async({error:A,session:E})=>{if(this.events.off(yr("session_request",p),l),A)_(A);else if(E){E.self.publicKey=F,await this.client.session.set(E.topic,E),await this.setExpiry(E.topic,E.expiry),L&&await this.client.core.pairing.updateMetadata({topic:L,metadata:E.peer.metadata});const w=this.client.session.get(E.topic);await this.deleteProposal(m),q({session:w})}},l=async A=>{var E,w,I;if(await this.deletePendingAuthRequest(p,{message:"fulfilled",code:0}),A.error){const Z=Dr("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return A.error.code===Z.code?void 0:(this.events.off(yr("session_connect"),v),_(A.error.message))}await this.deleteProposal(m),this.events.off(yr("session_connect"),v);const{cacaos:M,responder:z}=A.result,se=[],O=[];for(const Z of M){await N3({cacao:Z,projectId:this.client.core.projectId})||(this.client.logger.error(Z,"Signature verification failed"),_(Dr("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:te}=Z,N=$h(te.resources),Q=[hm(te.iss)],ne=Uh(te.iss);if(N){const de=B3(N),ce=F3(N);se.push(...de),Q.push(...ce)}for(const de of Q)O.push(`${de}:${ne}`)}const ie=await this.client.core.crypto.generateSharedKey(F,z.publicKey);let ee;se.length>0&&(ee={topic:ie,acknowledged:!0,self:{publicKey:F,metadata:this.client.metadata},peer:z,controller:z.publicKey,expiry:wn(Ic),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:L,namespaces:Z3([...new Set(se)],[...new Set(O)]),transportType:o},await this.client.core.relayer.subscribe(ie,{transportType:o}),await this.client.session.set(ie,ee),L&&await this.client.core.pairing.updateMetadata({topic:L,metadata:z.metadata}),ee=this.client.session.get(ie)),(E=this.client.metadata.redirect)!=null&&E.linkMode&&(w=z.metadata.redirect)!=null&&w.linkMode&&(I=z.metadata.redirect)!=null&&I.universal&&n&&(this.client.core.addLinkModeSupportedApp(z.metadata.redirect.universal),this.client.session.update(ie,{transportType:Hr.link_mode})),q({auths:M,session:ee})},p=Oo(),m=Oo();this.events.once(yr("session_connect"),v),this.events.once(yr("session_request",p),l);let y;try{if(s){const A=No("wc_sessionAuthenticate",R,p);this.client.core.history.set(L,A);const E=await this.client.core.crypto.encode("",A,{type:pf,encoding:hf});y=zh(n,L,E)}else await Promise.all([this.sendRequest({topic:L,method:"wc_sessionAuthenticate",params:R,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:p}),this.sendRequest({topic:L,method:"wc_sessionPropose",params:V,expiry:Mn.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:m})])}catch(A){throw this.events.off(yr("session_connect"),v),this.events.off(yr("session_request",p),l),A}return await this.setProposal(m,en({id:m},V)),await this.setAuthRequest(p,{request:cs(en({},R),{verifyContext:{}}),pairingTopic:L,transportType:o}),{uri:y??H,response:X}},this.approveSessionAuthenticate=async r=>{const{id:n,auths:i}=r,s=this.client.core.eventClient.createEvent({properties:{topic:n.toString(),trace:[Ra.authenticated_session_approve_started]}});try{this.isInitialized()}catch(D){throw s.setError(Af.no_internet_connection),D}const o=this.getPendingAuthRequest(n);if(!o)throw s.setError(Af.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${n}`);const a=o.transportType||Hr.relay;a===Hr.relay&&await this.confirmOnlineStateOrThrow();const f=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),h=qh(f),g={type:Vs,receiverPublicKey:f,senderPublicKey:u},b=[],x=[];for(const D of i){if(!await N3({cacao:D,projectId:this.client.core.projectId})){s.setError(Af.invalid_cacao);const k=Dr("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:n,topic:h,error:k,encodeOpts:g}),new Error(k.message)}s.addTrace(Ra.cacaos_verified);const{p:B}=D,L=$h(B.resources),H=[hm(B.iss)],F=Uh(B.iss);if(L){const k=B3(L),$=F3(L);b.push(...k),H.push(...$)}for(const k of H)x.push(`${k}:${F}`)}const S=await this.client.core.crypto.generateSharedKey(u,f);s.addTrace(Ra.create_authenticated_session_topic);let C;if(b?.length>0){C={topic:S,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:f,metadata:o.requester.metadata},controller:f,expiry:wn(Ic),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Z3([...new Set(b)],[...new Set(x)]),transportType:a},s.addTrace(Ra.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(S,{transportType:a})}catch(D){throw s.setError(Af.subscribe_authenticated_session_topic_failure),D}s.addTrace(Ra.subscribe_authenticated_session_topic_success),await this.client.session.set(S,C),s.addTrace(Ra.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Ra.publishing_authenticated_session_approve);try{await this.sendResult({topic:h,id:n,result:{cacaos:i,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:g,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(D){throw s.setError(Af.authenticated_session_approve_publish_failure),D}return await this.client.auth.requests.delete(n,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:C}},this.rejectSessionAuthenticate=async r=>{this.isInitialized();const{id:n,reason:i}=r,s=this.getPendingAuthRequest(n);if(!s)throw new Error(`Could not find pending auth request with id ${n}`);s.transportType===Hr.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),f=qh(o),u={type:Vs,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:n,topic:f,error:i,encodeOpts:u,rpcOpts:Mn.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(n,{message:"rejected",code:0}),await this.client.proposal.delete(n,Dr("USER_DISCONNECTED"))},this.formatAuthMessage=r=>{this.isInitialized();const{request:n,iss:i}=r;return L3(n,i)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const 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{const n=this.client.core.pairing.pairings.get(r.pairingTopic),i=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)===r.peer.metadata.url&&s.topic&&s.topic!==n.topic});if(i.length===0)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}},this.deleteSession=async r=>{var n;const{topic:i,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=r,{self:f}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,Dr("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(f.publicKey)&&await this.client.core.crypto.deleteKeyPair(f.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),s||this.client.core.expirer.del(i),this.client.core.storage.removeItem(o6).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===i&&this.deletePendingSessionRequest(u.id,Dr("USER_DISCONNECTED"))}),i===((n=this.sessionRequestQueue.queue[0])==null?void 0:n.topic)&&(this.sessionRequestQueue.state=Ms.idle),o&&this.client.events.emit("session_delete",{id:a,topic:i})},this.deleteProposal=async(r,n)=>{if(n)try{const i=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:i.pairingTopic})?.setError(Ca.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,Dr("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")},this.deletePendingSessionRequest=async(r,n,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,n),i?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==r),i&&(this.sessionRequestQueue.state=Ms.idle,this.client.events.emit("session_request_expire",{id:r}))},this.deletePendingAuthRequest=async(r,n,i=!1)=>{await Promise.all([this.client.auth.requests.delete(r,n),i?Promise.resolve():this.client.core.expirer.del(r)])},this.setExpiry=async(r,n)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,n),await this.client.session.update(r,{expiry:n}))},this.setProposal=async(r,n)=>{this.client.core.expirer.set(r,wn(Mn.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,n)},this.setAuthRequest=async(r,n)=>{const{request:i,pairingTopic:s,transportType:o=Hr.relay}=n;this.client.core.expirer.set(r,i.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:r,pairingTopic:s,verifyContext:i.verifyContext,transportType:o})},this.setPendingSessionRequest=async r=>{const{id:n,topic:i,params:s,verifyContext:o}=r,a=s.request.expiryTimestamp||wn(Mn.wc_sessionRequest.req.ttl);this.client.core.expirer.set(n,a),await this.client.pendingRequest.set(n,{id:n,topic:i,params:s,verifyContext:o})},this.sendRequest=async r=>{const{topic:n,method:i,params:s,expiry:o,relayRpcId:a,clientRpcId:f,throwOnFailedPublish:u,appLink:h}=r,g=No(i,s,f);let b;const x=!!h;try{const D=x?hf:Do;b=await this.client.core.crypto.encode(n,g,{encoding:D})}catch(D){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${n} failed`),D}let S;if(lj.includes(i)){const D=Gs(JSON.stringify(g)),B=Gs(b);S=await this.client.core.verify.register({id:B,decryptedId:D})}const C=Mn[i].req;if(C.attestation=S,o&&(C.ttl=o),a&&(C.id=a),this.client.core.history.set(n,g),x){const D=zh(h,n,b);await global.Linking.openURL(D,this.client.name)}else{const D=Mn[i].req;o&&(D.ttl=o),a&&(D.id=a),u?(D.internal=cs(en({},D.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,b,D)):this.client.core.relayer.publish(n,b,D).catch(B=>this.client.logger.error(B))}return g.id},this.sendResult=async r=>{const{id:n,topic:i,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:f}=r,u=Wh(n,s);let h;const g=f&&typeof(global==null?void 0:global.Linking)<"u";try{const x=g?hf:Do;h=await this.client.core.crypto.encode(i,u,cs(en({},a||{}),{encoding:x}))}catch(x){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),x}let b;try{b=await this.client.core.history.get(i,n)}catch(x){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${n}) failed`),x}if(g){const x=zh(f,i,h);await global.Linking.openURL(x,this.client.name)}else{const x=Mn[b.request.method].res;o?(x.internal=cs(en({},x.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,h,x)):this.client.core.relayer.publish(i,h,x).catch(S=>this.client.logger.error(S))}await this.client.core.history.resolve(u)},this.sendError=async r=>{const{id:n,topic:i,error:s,encodeOpts:o,rpcOpts:a,appLink:f}=r,u=Kh(n,s);let h;const g=f&&typeof(global==null?void 0:global.Linking)<"u";try{const x=g?hf:Do;h=await this.client.core.crypto.encode(i,u,cs(en({},o||{}),{encoding:x}))}catch(x){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),x}let b;try{b=await this.client.core.history.get(i,n)}catch(x){throw this.client.logger.error(`sendError() -> history.get(${i}, ${n}) failed`),x}if(g){const x=zh(f,i,h);await global.Linking.openURL(x,this.client.name)}else{const x=a||Mn[b.request.method].res;this.client.core.relayer.publish(i,h,x)}await this.client.core.history.resolve(u)},this.cleanup=async()=>{const r=[],n=[];this.client.session.getAll().forEach(i=>{let s=!1;To(i.expiry)&&(s=!0),this.client.core.crypto.keychain.has(i.topic)||(s=!0),s&&r.push(i.topic)}),this.client.proposal.getAll().forEach(i=>{To(i.expiryTimestamp)&&n.push(i.id)}),await Promise.all([...r.map(i=>this.deleteSession({topic:i})),...n.map(i=>this.deleteProposal(i))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Ms.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=Ms.active;const r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(n){this.client.logger.warn(n)}}this.requestQueue.state=Ms.idle},this.processRequest=async r=>{const{topic:n,payload:i,attestation:s,transportType:o,encryptedId:a}=r,f=i.method;if(!this.shouldIgnorePairingRequest({topic:n,requestMethod:f}))switch(f){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:n,payload:i,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(n,i);case"wc_sessionPing":return await this.onSessionPingRequest(n,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(n,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:n,payload:i,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(n,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:n,payload:i,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${f}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:i,transportType:s}=r,o=(await this.client.core.history.get(n,i.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i,s);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:n}=r,{message:i}=ut("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)},this.shouldIgnorePairingRequest=r=>{const{topic:n,requestMethod:i}=r,s=this.expectedPairingMethodMap.get(n);return!s||s.includes(i)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async r=>{const{topic:n,payload:i,attestation:s,encryptedId:o}=r,{params:a,id:f}=i;try{const u=this.client.core.eventClient.getEvent({topic:n});this.isValidConnect(en({},i.params));const h=a.expiryTimestamp||wn(Mn.wc_sessionPropose.req.ttl),g=en({id:f,pairingTopic:n,expiryTimestamp:h},a);await this.setProposal(f,g);const b=await this.getVerifyContext({attestationId:s,hash:Gs(JSON.stringify(i)),encryptedId:o,metadata:g.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u?.setError(Xs.proposal_listener_not_found)),u?.addTrace(Is.emit_session_proposal),this.client.events.emit("session_proposal",{id:f,params:g,verifyContext:b})}catch(u){await this.sendError({id:f,topic:n,error:u,rpcOpts:Mn.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(r,n,i)=>{const{id:s}=n;if(Ss(n)){const{result:o}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const f=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:f});const u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});const h=await this.client.core.crypto.generateSharedKey(f,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:h});const g=await this.client.core.relayer.subscribe(h,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:g}),await this.client.core.pairing.activate({topic:r})}else if(Bi(n)){await this.client.proposal.delete(s,Dr("USER_DISCONNECTED"));const o=yr("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(yr("session_connect"),{error:n.error})}},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:o,controller:a,expiry:f,namespaces:u,sessionProperties:h,sessionConfig:g}=n.params,b=cs(en(en({topic:r,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}},h&&{sessionProperties:h}),g&&{sessionConfig:g}),{transportType:Hr.relay}),x=yr("session_connect");if(this.events.listenerCount(x)===0)throw new Error(`emitting ${x} without any listeners 997`);this.events.emit(yr("session_connect"),{session:b}),await this.sendResult({id:n.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:i,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;Ss(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(yr("session_approve",i),{})):Bi(n)&&(await this.client.session.delete(r,Dr("USER_DISCONNECTED")),this.events.emit(yr("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:i,id:s}=n;try{const o=`${r}_session_update`,a=wf.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:r,error:Dr("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(en({topic:r},i));try{wf.set(o,s),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0})}catch(f){throw wf.delete(o),f}this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(r,n)=>parseInt(n.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n,s=yr("session_update",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Ss(n)?this.events.emit(yr("session_update",i),{}):Bi(n)&&this.events.emit(yr("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,wn(Ic)),await this.sendResult({id:i,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError({id:i,topic:r,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,n)=>{const{id:i}=n,s=yr("session_extend",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Ss(n)?this.events.emit(yr("session_extend",i),{}):Bi(n)&&this.events.emit(yr("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult({id:i,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError({id:i,topic:r,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(r,n)=>{const{id:i}=n,s=yr("session_ping",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Ss(n)?this.events.emit(yr("session_ping",i),{}):Bi(n)&&this.events.emit(yr("session_ping",i),{error:n.error})},500)},this.onSessionDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Jn.publish,async()=>{s(await this.deleteSession({topic:r,id:i}))})}),this.sendResult({id:i,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:Dr("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async r=>{var n,i,s;const{topic:o,payload:a,attestation:f,encryptedId:u,transportType:h}=r,{id:g,params:b}=a;try{await this.isValidRequest(en({topic:o},b));const x=this.client.session.get(o),S=await this.getVerifyContext({attestationId:f,hash:Gs(JSON.stringify(No("wc_sessionRequest",b,g))),encryptedId:u,metadata:x.peer.metadata,transportType:h}),C={id:g,topic:o,params:b,verifyContext:S};await this.setPendingSessionRequest(C),h===Hr.link_mode&&(n=x.peer.metadata.redirect)!=null&&n.universal&&this.client.core.addLinkModeSupportedApp((i=x.peer.metadata.redirect)==null?void 0:i.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(C):(this.addSessionRequestToSessionRequestQueue(C),this.processSessionRequestQueue())}catch(x){await this.sendError({id:g,topic:o,error:x}),this.client.logger.error(x)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n,s=yr("session_request",i);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Ss(n)?this.events.emit(yr("session_request",i),{result:n.result}):Bi(n)&&this.events.emit(yr("session_request",i),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:i,params:s}=n;try{const o=`${r}_session_event_${s.event.name}`,a=wf.get(o);if(a&&this.isRequestOutOfSync(a,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit(en({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s}),wf.set(o,i)}catch(o){await this.sendError({id:i,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(r,n)=>{const{id:i}=n;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:n}),Ss(n)?this.events.emit(yr("session_request",i),{result:n.result}):Bi(n)&&this.events.emit(yr("session_request",i),{error:n.error})},this.onSessionAuthenticateRequest=async r=>{var n;const{topic:i,payload:s,attestation:o,encryptedId:a,transportType:f}=r;try{const{requester:u,authPayload:h,expiryTimestamp:g}=s.params,b=await this.getVerifyContext({attestationId:o,hash:Gs(JSON.stringify(s)),encryptedId:a,metadata:u.metadata,transportType:f}),x={requester:u,pairingTopic:i,id:s.id,authPayload:h,verifyContext:b,expiryTimestamp:g};await this.setAuthRequest(s.id,{request:x,pairingTopic:i,transportType:f}),f===Hr.link_mode&&(n=u.metadata.redirect)!=null&&n.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:s.params,id:s.id,verifyContext:b})}catch(u){this.client.logger.error(u);const h=s.params.requester.publicKey,g=await this.client.core.crypto.generateKeyPair(),b=this.getAppLinkIfEnabled(s.params.requester.metadata,f),x={type:Vs,receiverPublicKey:h,senderPublicKey:g};await this.sendError({id:s.id,topic:i,error:u,encodeOpts:x,rpcOpts:Mn.wc_sessionAuthenticate.autoReject,appLink:b})}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Ms.idle,this.processSessionRequestQueue()},vt.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:r,error:n})=>{const i=this.client.core.history.pending;i.length>0&&i.filter(s=>s.topic===r&&s.request.method==="wc_sessionRequest").forEach(s=>{const o=s.request.id,a=yr("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(yr("session_request",s.request.id),{error:n})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Ms.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Ms.active,this.emitSessionRequest(r)}catch(n){this.client.logger.error(n)}},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;const n=this.client.proposal.getAll().find(i=>i.pairingTopic===r.topic);n&&this.onSessionProposeRequest({topic:r.topic,payload:No("wc_sessionPropose",{requiredNamespaces:n.requiredNamespaces,optionalNamespaces:n.optionalNamespaces,relays:n.relays,proposer:n.proposer,sessionProperties:n.sessionProperties},n.id)})},this.isValidConnect=async r=>{if(!ai(r)){const{message:f}=ut("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(f)}const{pairingTopic:n,requiredNamespaces:i,optionalNamespaces:s,sessionProperties:o,relays:a}=r;if(Yn(n)||await this.isValidPairingTopic(n),!jL(a)){const{message:f}=ut("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(f)}!Yn(i)&&yf(i)!==0&&this.validateNamespaces(i,"requiredNamespaces"),!Yn(s)&&yf(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),Yn(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(r,n)=>{const i=FL(r,"connect()",n);if(i)throw new Error(i.message)},this.isValidApprove=async r=>{if(!ai(r))throw new Error(ut("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s,sessionProperties:o}=r;this.checkRecentlyDeleted(n),await this.isValidProposalId(n);const a=this.client.proposal.get(n),f=bm(i,"approve()");if(f)throw new Error(f.message);const u=n_(a.requiredNamespaces,i,"approve()");if(u)throw new Error(u.message);if(!nn(s,!0)){const{message:h}=ut("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(h)}Yn(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async r=>{if(!ai(r)){const{message:s}=ut("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:n,reason:i}=r;if(this.checkRecentlyDeleted(n),await this.isValidProposalId(n),!$L(i)){const{message:s}=ut("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!ai(r)){const{message:u}=ut("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(u)}const{relay:n,controller:i,namespaces:s,expiry:o}=r;if(!t_(n)){const{message:u}=ut("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}const a=DL(i,"onSessionSettleRequest()");if(a)throw new Error(a.message);const f=bm(s,"onSessionSettleRequest()");if(f)throw new Error(f.message);if(To(o)){const{message:u}=ut("EXPIRED","onSessionSettleRequest()");throw new Error(u)}},this.isValidUpdate=async r=>{if(!ai(r)){const{message:f}=ut("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(f)}const{topic:n,namespaces:i}=r;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const s=this.client.session.get(n),o=bm(i,"update()");if(o)throw new Error(o.message);const a=n_(s.requiredNamespaces,i,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async r=>{if(!ai(r)){const{message:i}=ut("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!ai(r)){const{message:f}=ut("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(f)}const{topic:n,request:i,chainId:s,expiry:o}=r;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const{namespaces:a}=this.client.session.get(n);if(!r_(a,s)){const{message:f}=ut("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(f)}if(!qL(i)){const{message:f}=ut("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(f)}if(!WL(a,s,i.method)){const{message:f}=ut("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(f)}if(o&&!YL(o,Tm)){const{message:f}=ut("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Tm.min} and ${Tm.max}`);throw new Error(f)}},this.isValidRespond=async r=>{var n;if(!ai(r)){const{message:o}=ut("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}const{topic:i,response:s}=r;try{await this.isValidSessionTopic(i)}catch(o){throw(n=r?.response)!=null&&n.id&&this.cleanupAfterResponse(r),o}if(!zL(s)){const{message:o}=ut("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async r=>{if(!ai(r)){const{message:i}=ut("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!ai(r)){const{message:a}=ut("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:o}=this.client.session.get(n);if(!r_(o,s)){const{message:a}=ut("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!HL(i)){const{message:a}=ut("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}if(!KL(o,s,i.name)){const{message:a}=ut("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(a)}},this.isValidDisconnect=async r=>{if(!ai(r)){const{message:i}=ut("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidAuthenticate=r=>{const{chains:n,uri:i,domain:s,nonce:o}=r;if(!Array.isArray(n)||n.length===0)throw new Error("chains is required and must be a non-empty array");if(!nn(i,!1))throw new Error("uri is required parameter");if(!nn(s,!1))throw new Error("domain is required parameter");if(!nn(o,!1))throw new Error("nonce is required parameter");if([...new Set(n.map(f=>Ec(f).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Ec(n[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=>{const{attestationId:n,hash:i,encryptedId:s,metadata:o,transportType:a}=r,f={verified:{verifyUrl:o.verifyUrl||Sf,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Hr.link_mode){const h=this.getAppLinkIfEnabled(o,a);return f.verified.validation=h&&new URL(h).origin===new URL(o.url).origin?"VALID":"INVALID",f}const u=await this.client.core.verify.resolve({attestationId:n,hash:i,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=(r,n)=>{Object.values(r).forEach(i=>{if(!nn(i,!1)){const{message:s}=ut("MISSING_OR_INVALID",`${n} must be in Record format. Received: ${JSON.stringify(i)}`);throw new Error(s)}})},this.getPendingAuthRequest=r=>{const n=this.client.auth.requests.get(r);return typeof n=="object"?n:void 0},this.addToRecentlyDeleted=(r,n)=>{if(this.recentlyDeletedMap.set(r,n),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let i=0;const s=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(i++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=r=>{const n=this.recentlyDeletedMap.get(r);if(n){const{message:i}=ut("MISSING_OR_INVALID",`Record was recently deleted - ${n}: ${r}`);throw new Error(i)}},this.isLinkModeEnabled=(r,n)=>{var i,s,o,a,f,u,h,g,b;return!r||n!==Hr.link_mode?!1:((s=(i=this.client.metadata)==null?void 0:i.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)!==""&&((h=r?.redirect)==null?void 0:h.universal)!==void 0&&((g=r?.redirect)==null?void 0:g.universal)!==""&&((b=r?.redirect)==null?void 0:b.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(r,n)=>{var i;return this.isLinkModeEnabled(r,n)?(i=r?.redirect)==null?void 0:i.universal:void 0},this.handleLinkModeMessage=({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;const n=C3(r,"topic")||"",i=decodeURIComponent(C3(r,"wc_ev")||""),s=this.client.session.keys.includes(n);s&&this.client.session.update(n,{transportType:Hr.link_mode}),this.client.core.dispatchEnvelope({topic:n,message:i,sessionExists:s})},this.registerLinkModeListeners=async()=>{var r;if(fm()||Sc()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){const n=global==null?void 0:global.Linking;if(typeof n<"u"){n.addEventListener("url",this.handleLinkModeMessage,this.client.name);const i=await n.getInitialURL();i&&setTimeout(()=>{this.handleLinkModeMessage({url:i})},50)}}}}isInitialized(){if(!this.initialized){const{message:e}=ut("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Jn.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:r,message:n,attestation:i,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Jh)?this.client.auth.authKeys.get(Jh):{publicKey:void 0},a=await this.client.core.crypto.decode(r,n,{receiverPublicKey:o,encoding:s===Hr.link_mode?hf:Do});try{_m(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:i,transportType:s,encryptedId:Gs(n)})):Vh(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:s}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:s})}catch(f){this.client.logger.error(f)}}registerExpirerEvents(){this.client.core.expirer.on(Ui.expired,async e=>{const{topic:r,id:n}=M3(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,ut("EXPIRED"),!0);if(n&&this.client.auth.requests.keys.includes(n))return await this.deletePendingAuthRequest(n,ut("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}registerPairingEvents(){this.client.core.pairing.events.on(Ma.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Ma.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!nn(e,!1)){const{message:r}=ut("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=ut("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(To(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=ut("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!nn(e,!1)){const{message:r}=ut("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:r}=ut("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(To(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:r}=ut("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){const{message:r}=ut("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(nn(e,!1)){const{message:r}=ut("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=ut("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!UL(e)){const{message:r}=ut("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=ut("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(To(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:r}=ut("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class Ej extends Ta{constructor(e,r){super(e,r,aj,Cm),this.core=e,this.logger=r}}let Sj=class extends Ta{constructor(e,r){super(e,r,cj,Cm),this.core=e,this.logger=r}};class Aj extends Ta{constructor(e,r){super(e,r,fj,Cm,n=>n.id),this.core=e,this.logger=r}}class Pj extends Ta{constructor(e,r){super(e,r,pj,Yh,()=>Jh),this.core=e,this.logger=r}}class Ij extends Ta{constructor(e,r){super(e,r,gj,Yh),this.core=e,this.logger=r}}class Mj extends Ta{constructor(e,r){super(e,r,mj,Yh,n=>n.id),this.core=e,this.logger=r}}class Cj{constructor(e,r){this.core=e,this.logger=r,this.authKeys=new Pj(this.core,this.logger),this.pairingTopics=new Ij(this.core,this.logger),this.requests=new Mj(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class Dm extends hT{constructor(e){super(e),this.protocol=n6,this.version=i6,this.name=Rm.name,this.events=new Di.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.authenticate=async(n,i)=>{try{return await this.engine.authenticate(n,i)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=n=>{try{return this.engine.formatAuthMessage(n)}catch(i){throw this.logger.error(i.message),i}},this.approveSessionAuthenticate=async n=>{try{return await this.engine.approveSessionAuthenticate(n)}catch(i){throw this.logger.error(i.message),i}},this.rejectSessionAuthenticate=async n=>{try{return await this.engine.rejectSessionAuthenticate(n)}catch(i){throw this.logger.error(i.message),i}},this.name=e?.name||Rm.name,this.metadata=e?.metadata||E3(),this.signConfig=e?.signConfig;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Gu(hh({level:e?.logger||Rm.logger}));this.core=e?.core||new oj(e),this.logger=Vn(r,this.name),this.session=new Sj(this.core,this.logger),this.proposal=new Ej(this.core,this.logger),this.pendingRequest=new Aj(this.core,this.logger),this.engine=new _j(this),this.auth=new Cj(this.core,this.logger)}static async init(e){const r=new Dm(e);return await r.initialize(),r}get context(){return oi(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 Cf={exports:{}};/** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */Qd.exports,function(t,e){(function(){var r,n="4.17.21",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",o="Expected a function",a="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",l=500,d="__lodash_placeholder__",g=1,y=2,A=4,P=1,N=2,D=1,k=2,$=4,q=8,U=16,K=32,J=64,T=128,z=256,ue=512,_e=30,G="...",E=800,m=16,f=1,p=2,v=3,x=1/0,_=9007199254740991,S=17976931348623157e292,b=NaN,M=4294967295,I=M-1,F=M>>>1,ae=[["ary",T],["bind",D],["bindKey",k],["curry",q],["curryRight",U],["flip",ue],["partial",K],["partialRight",J],["rearg",z]],O="[object Arguments]",se="[object Array]",ee="[object AsyncFunction]",X="[object Boolean]",Q="[object Date]",R="[object DOMException]",Z="[object Error]",te="[object Function]",le="[object GeneratorFunction]",ie="[object Map]",fe="[object Number]",ve="[object Null]",Me="[object Object]",Ne="[object Promise]",Te="[object Proxy]",Be="[object RegExp]",Ie="[object Set]",Le="[object String]",Ve="[object Symbol]",ke="[object Undefined]",ze="[object WeakMap]",He="[object WeakSet]",Ee="[object ArrayBuffer]",Qe="[object DataView]",ct="[object Float32Array]",$e="[object Float64Array]",et="[object Int8Array]",rt="[object Int16Array]",Je="[object Int32Array]",pt="[object Uint8Array]",ht="[object Uint8ClampedArray]",ft="[object Uint16Array]",Ht="[object Uint32Array]",Jt=/\b__p \+= '';/g,St=/\b(__p \+=) '' \+/g,er=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Xt=/&(?:amp|lt|gt|quot|#39);/g,Ot=/[&<>"']/g,$t=RegExp(Xt.source),Tt=RegExp(Ot.source),vt=/<%-([\s\S]+?)%>/g,Dt=/<%([\s\S]+?)%>/g,Lt=/<%=([\s\S]+?)%>/g,bt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Bt=/^\w*$/,Ut=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,nt=/[\\^$.*+?()[\]{}|]/g,Ft=RegExp(nt.source),B=/^\s+/,H=/\s/,V=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,C=/\{\n\/\* \[wrapped with (.+)\] \*/,Y=/,? & /,j=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,oe=/[()=,{}\[\]\/\s]/,pe=/\\(\\)?/g,xe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Re=/\w*$/,De=/^[-+]0x[0-9a-f]+$/i,it=/^0b[01]+$/i,je=/^\[object .+?Constructor\]$/,gt=/^0o[0-7]+$/i,st=/^(?:0|[1-9]\d*)$/,tt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,At=/($^)/,Rt=/['\n\r\u2028\u2029\\]/g,Mt="\\ud800-\\udfff",Et="\\u0300-\\u036f",dt="\\ufe20-\\ufe2f",_t="\\u20d0-\\u20ff",ot=Et+dt+_t,wt="\\u2700-\\u27bf",lt="a-z\\xdf-\\xf6\\xf8-\\xff",at="\\xac\\xb1\\xd7\\xf7",Se="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Ae="\\u2000-\\u206f",Ge=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ue="A-Z\\xc0-\\xd6\\xd8-\\xde",qe="\\ufe0e\\ufe0f",Xe=at+Se+Ae+Ge,kt="['’]",Wt="["+Mt+"]",Zt="["+Xe+"]",Kt="["+ot+"]",de="\\d+",nr="["+wt+"]",dr="["+lt+"]",pr="[^"+Mt+Xe+de+wt+lt+Ue+"]",Qt="\\ud83c[\\udffb-\\udfff]",gr="(?:"+Kt+"|"+Qt+")",lr="[^"+Mt+"]",Lr="(?:\\ud83c[\\udde6-\\uddff]){2}",mr="[\\ud800-\\udbff][\\udc00-\\udfff]",wr="["+Ue+"]",$r="\\u200d",Br="(?:"+dr+"|"+pr+")",Ir="(?:"+wr+"|"+pr+")",hn="(?:"+kt+"(?:d|ll|m|re|s|t|ve))?",dn="(?:"+kt+"(?:D|LL|M|RE|S|T|VE))?",pn=gr+"?",sp="["+qe+"]?",$b="(?:"+$r+"(?:"+[lr,Lr,mr].join("|")+")"+sp+pn+")*",Fo="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",op="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ap=sp+pn+$b,Zu="(?:"+[nr,Lr,mr].join("|")+")"+ap,Bb="(?:"+[lr+Kt+"?",Kt,Lr,mr,Wt].join("|")+")",ph=RegExp(kt,"g"),Fb=RegExp(Kt,"g"),Qu=RegExp(Qt+"(?="+Qt+")|"+Bb+ap,"g"),cp=RegExp([wr+"?"+dr+"+"+hn+"(?="+[Zt,wr,"$"].join("|")+")",Ir+"+"+dn+"(?="+[Zt,wr+Br,"$"].join("|")+")",wr+"?"+Br+"+"+hn,wr+"+"+dn,op,Fo,de,Zu].join("|"),"g"),up=RegExp("["+$r+Mt+ot+qe+"]"),Ac=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fp=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ub=-1,Fr={};Fr[ct]=Fr[$e]=Fr[et]=Fr[rt]=Fr[Je]=Fr[pt]=Fr[ht]=Fr[ft]=Fr[Ht]=!0,Fr[O]=Fr[se]=Fr[Ee]=Fr[X]=Fr[Qe]=Fr[Q]=Fr[Z]=Fr[te]=Fr[ie]=Fr[fe]=Fr[Me]=Fr[Be]=Fr[Ie]=Fr[Le]=Fr[ze]=!1;var kr={};kr[O]=kr[se]=kr[Ee]=kr[Qe]=kr[X]=kr[Q]=kr[ct]=kr[$e]=kr[et]=kr[rt]=kr[Je]=kr[ie]=kr[fe]=kr[Me]=kr[Be]=kr[Ie]=kr[Le]=kr[Ve]=kr[pt]=kr[ht]=kr[ft]=kr[Ht]=!0,kr[Z]=kr[te]=kr[ze]=!1;var ce={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},ye={"&":"&","<":"<",">":">",'"':""","'":"'"},Ye={"&":"&","<":"<",">":">",""":'"',"'":"'"},It={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ur=parseFloat,ir=parseInt,Yr=typeof nn=="object"&&nn&&nn.Object===Object&&nn,wn=typeof self=="object"&&self&&self.Object===Object&&self,_r=Yr||wn||Function("return this")(),jr=e&&!e.nodeType&&e,gn=jr&&!0&&t&&!t.nodeType&&t,_i=gn&&gn.exports===jr,xn=_i&&Yr.process,Jr=function(){try{var be=gn&&gn.require&&gn.require("util").types;return be||xn&&xn.binding&&xn.binding("util")}catch{}}(),oi=Jr&&Jr.isArrayBuffer,As=Jr&&Jr.isDate,ns=Jr&&Jr.isMap,to=Jr&&Jr.isRegExp,gh=Jr&&Jr.isSet,Pc=Jr&&Jr.isTypedArray;function $n(be,Fe,Ce){switch(Ce.length){case 0:return be.call(Fe);case 1:return be.call(Fe,Ce[0]);case 2:return be.call(Fe,Ce[0],Ce[1]);case 3:return be.call(Fe,Ce[0],Ce[1],Ce[2])}return be.apply(Fe,Ce)}function PQ(be,Fe,Ce,Ct){for(var tr=-1,Mr=be==null?0:be.length;++tr-1}function jb(be,Fe,Ce){for(var Ct=-1,tr=be==null?0:be.length;++Ct-1;);return Ce}function W7(be,Fe){for(var Ce=be.length;Ce--&&ef(Fe,be[Ce],0)>-1;);return Ce}function LQ(be,Fe){for(var Ce=be.length,Ct=0;Ce--;)be[Ce]===Fe&&++Ct;return Ct}var kQ=Wb(ce),$Q=Wb(ye);function BQ(be){return"\\"+It[be]}function FQ(be,Fe){return be==null?r:be[Fe]}function tf(be){return up.test(be)}function UQ(be){return Ac.test(be)}function jQ(be){for(var Fe,Ce=[];!(Fe=be.next()).done;)Ce.push(Fe.value);return Ce}function Yb(be){var Fe=-1,Ce=Array(be.size);return be.forEach(function(Ct,tr){Ce[++Fe]=[tr,Ct]}),Ce}function K7(be,Fe){return function(Ce){return be(Fe(Ce))}}function Ca(be,Fe){for(var Ce=-1,Ct=be.length,tr=0,Mr=[];++Ce-1}function Iee(c,h){var w=this.__data__,L=Ip(w,c);return L<0?(++this.size,w.push([c,h])):w[L][1]=h,this}Uo.prototype.clear=See,Uo.prototype.delete=Aee,Uo.prototype.get=Pee,Uo.prototype.has=Mee,Uo.prototype.set=Iee;function jo(c){var h=-1,w=c==null?0:c.length;for(this.clear();++h=h?c:h)),c}function as(c,h,w,L,W,ne){var he,ge=h&g,we=h&y,We=h&A;if(w&&(he=W?w(c,L,W,ne):w(c)),he!==r)return he;if(!Qr(c))return c;var Ke=sr(c);if(Ke){if(he=Dte(c),!ge)return Ei(c,he)}else{var Ze=ti(c),xt=Ze==te||Ze==le;if(La(c))return I9(c,ge);if(Ze==Me||Ze==O||xt&&!W){if(he=we||xt?{}:V9(c),!ge)return we?xte(c,Hee(he,c)):wte(c,i9(he,c))}else{if(!kr[Ze])return W?c:{};he=Ote(c,Ze,ge)}}ne||(ne=new Ms);var Nt=ne.get(c);if(Nt)return Nt;ne.set(c,he),_A(c)?c.forEach(function(Gt){he.add(as(Gt,h,w,Gt,c,ne))}):wA(c)&&c.forEach(function(Gt,br){he.set(br,as(Gt,h,w,br,c,ne))});var Vt=We?we?xy:wy:we?Ai:Bn,fr=Ke?r:Vt(c);return is(fr||c,function(Gt,br){fr&&(br=Gt,Gt=c[br]),_h(he,br,as(Gt,h,w,br,c,ne))}),he}function Wee(c){var h=Bn(c);return function(w){return s9(w,c,h)}}function s9(c,h,w){var L=w.length;if(c==null)return!L;for(c=qr(c);L--;){var W=w[L],ne=h[W],he=c[W];if(he===r&&!(W in c)||!ne(he))return!1}return!0}function o9(c,h,w){if(typeof c!="function")throw new ss(o);return Ch(function(){c.apply(r,w)},h)}function Eh(c,h,w,L){var W=-1,ne=lp,he=!0,ge=c.length,we=[],We=h.length;if(!ge)return we;w&&(h=Xr(h,Li(w))),L?(ne=jb,he=!1):h.length>=i&&(ne=mh,he=!1,h=new Cc(h));e:for(;++WW?0:W+w),L=L===r||L>W?W:ur(L),L<0&&(L+=W),L=w>L?0:SA(L);w0&&w(ge)?h>1?Kn(ge,h-1,w,L,W):Ia(W,ge):L||(W[W.length]=ge)}return W}var ry=N9(),u9=N9(!0);function ro(c,h){return c&&ry(c,h,Bn)}function ny(c,h){return c&&u9(c,h,Bn)}function Tp(c,h){return Ma(h,function(w){return Ko(c[w])})}function Rc(c,h){h=Oa(h,c);for(var w=0,L=h.length;c!=null&&wh}function Gee(c,h){return c!=null&&Tr.call(c,h)}function Yee(c,h){return c!=null&&h in qr(c)}function Jee(c,h,w){return c>=ei(h,w)&&c=120&&Ke.length>=120)?new Cc(he&&Ke):r}Ke=c[0];var Ze=-1,xt=ge[0];e:for(;++Ze-1;)ge!==c&&xp.call(ge,we,1),xp.call(c,we,1);return c}function w9(c,h){for(var w=c?h.length:0,L=w-1;w--;){var W=h[w];if(w==L||W!==ne){var ne=W;Wo(W)?xp.call(c,W,1):dy(c,W)}}return c}function fy(c,h){return c+Sp(e9()*(h-c+1))}function ute(c,h,w,L){for(var W=-1,ne=Pn(Ep((h-c)/(w||1)),0),he=Ce(ne);ne--;)he[L?ne:++W]=c,c+=w;return he}function ly(c,h){var w="";if(!c||h<1||h>_)return w;do h%2&&(w+=c),h=Sp(h/2),h&&(c+=c);while(h);return w}function hr(c,h){return Iy(J9(c,h,Pi),c+"")}function fte(c){return n9(df(c))}function lte(c,h){var w=df(c);return jp(w,Tc(h,0,w.length))}function Ph(c,h,w,L){if(!Qr(c))return c;h=Oa(h,c);for(var W=-1,ne=h.length,he=ne-1,ge=c;ge!=null&&++WW?0:W+h),w=w>W?W:w,w<0&&(w+=W),W=h>w?0:w-h>>>0,h>>>=0;for(var ne=Ce(W);++L>>1,he=c[ne];he!==null&&!$i(he)&&(w?he<=h:he=i){var We=h?null:Ate(c);if(We)return dp(We);he=!1,W=mh,we=new Cc}else we=h?[]:ge;e:for(;++L=L?c:cs(c,h,w)}var M9=ree||function(c){return _r.clearTimeout(c)};function I9(c,h){if(h)return c.slice();var w=c.length,L=Y7?Y7(w):new c.constructor(w);return c.copy(L),L}function vy(c){var h=new c.constructor(c.byteLength);return new yp(h).set(new yp(c)),h}function mte(c,h){var w=h?vy(c.buffer):c.buffer;return new c.constructor(w,c.byteOffset,c.byteLength)}function vte(c){var h=new c.constructor(c.source,Re.exec(c));return h.lastIndex=c.lastIndex,h}function bte(c){return xh?qr(xh.call(c)):{}}function C9(c,h){var w=h?vy(c.buffer):c.buffer;return new c.constructor(w,c.byteOffset,c.length)}function T9(c,h){if(c!==h){var w=c!==r,L=c===null,W=c===c,ne=$i(c),he=h!==r,ge=h===null,we=h===h,We=$i(h);if(!ge&&!We&&!ne&&c>h||ne&&he&&we&&!ge&&!We||L&&he&&we||!w&&we||!W)return 1;if(!L&&!ne&&!We&&c=ge)return we;var We=w[L];return we*(We=="desc"?-1:1)}}return c.index-h.index}function R9(c,h,w,L){for(var W=-1,ne=c.length,he=w.length,ge=-1,we=h.length,We=Pn(ne-he,0),Ke=Ce(we+We),Ze=!L;++ge1?w[W-1]:r,he=W>2?w[2]:r;for(ne=c.length>3&&typeof ne=="function"?(W--,ne):r,he&&ci(w[0],w[1],he)&&(ne=W<3?r:ne,W=1),h=qr(h);++L-1?W[ne?h[he]:he]:r}}function $9(c){return Ho(function(h){var w=h.length,L=w,W=os.prototype.thru;for(c&&h.reverse();L--;){var ne=h[L];if(typeof ne!="function")throw new ss(o);if(W&&!he&&Fp(ne)=="wrapper")var he=new os([],!0)}for(L=he?L:w;++L1&&Er.reverse(),Ke&&wege))return!1;var We=ne.get(c),Ke=ne.get(h);if(We&&Ke)return We==h&&Ke==c;var Ze=-1,xt=!0,Nt=w&N?new Cc:r;for(ne.set(c,h),ne.set(h,c);++Ze1?"& ":"")+h[L],h=h.join(w>2?", ":" "),c.replace(V,`{ -/* [wrapped with `+h+`] */ -`)}function Lte(c){return sr(c)||Nc(c)||!!(Z7&&c&&c[Z7])}function Wo(c,h){var w=typeof c;return h=h??_,!!h&&(w=="number"||w!="symbol"&&st.test(c))&&c>-1&&c%1==0&&c0){if(++h>=E)return arguments[0]}else h=0;return c.apply(r,arguments)}}function jp(c,h){var w=-1,L=c.length,W=L-1;for(h=h===r?L:h;++w1?c[h-1]:r;return w=typeof w=="function"?(c.pop(),w):r,cA(c,w)});function uA(c){var h=re(c);return h.__chain__=!0,h}function Kre(c,h){return h(c),c}function qp(c,h){return h(c)}var Vre=Ho(function(c){var h=c.length,w=h?c[0]:0,L=this.__wrapped__,W=function(ne){return ty(ne,c)};return h>1||this.__actions__.length||!(L instanceof xr)||!Wo(w)?this.thru(W):(L=L.slice(w,+w+(h?1:0)),L.__actions__.push({func:qp,args:[W],thisArg:r}),new os(L,this.__chain__).thru(function(ne){return h&&!ne.length&&ne.push(r),ne}))});function Gre(){return uA(this)}function Yre(){return new os(this.value(),this.__chain__)}function Jre(){this.__values__===r&&(this.__values__=EA(this.value()));var c=this.__index__>=this.__values__.length,h=c?r:this.__values__[this.__index__++];return{done:c,value:h}}function Xre(){return this}function Zre(c){for(var h,w=this;w instanceof Mp;){var L=rA(w);L.__index__=0,L.__values__=r,h?W.__wrapped__=L:h=L;var W=L;w=w.__wrapped__}return W.__wrapped__=c,h}function Qre(){var c=this.__wrapped__;if(c instanceof xr){var h=c;return this.__actions__.length&&(h=new xr(this)),h=h.reverse(),h.__actions__.push({func:qp,args:[Cy],thisArg:r}),new os(h,this.__chain__)}return this.thru(Cy)}function ene(){return A9(this.__wrapped__,this.__actions__)}var tne=Np(function(c,h,w){Tr.call(c,w)?++c[w]:qo(c,w,1)});function rne(c,h,w){var L=sr(c)?B7:Kee;return w&&ci(c,h,w)&&(h=r),L(c,qt(h,3))}function nne(c,h){var w=sr(c)?Ma:c9;return w(c,qt(h,3))}var ine=k9(nA),sne=k9(iA);function one(c,h){return Kn(zp(c,h),1)}function ane(c,h){return Kn(zp(c,h),x)}function cne(c,h,w){return w=w===r?1:ur(w),Kn(zp(c,h),w)}function fA(c,h){var w=sr(c)?is:Ra;return w(c,qt(h,3))}function lA(c,h){var w=sr(c)?MQ:a9;return w(c,qt(h,3))}var une=Np(function(c,h,w){Tr.call(c,w)?c[w].push(h):qo(c,w,[h])});function fne(c,h,w,L){c=Si(c)?c:df(c),w=w&&!L?ur(w):0;var W=c.length;return w<0&&(w=Pn(W+w,0)),Gp(c)?w<=W&&c.indexOf(h,w)>-1:!!W&&ef(c,h,w)>-1}var lne=hr(function(c,h,w){var L=-1,W=typeof h=="function",ne=Si(c)?Ce(c.length):[];return Ra(c,function(he){ne[++L]=W?$n(h,he,w):Sh(he,h,w)}),ne}),hne=Np(function(c,h,w){qo(c,w,h)});function zp(c,h){var w=sr(c)?Xr:p9;return w(c,qt(h,3))}function dne(c,h,w,L){return c==null?[]:(sr(h)||(h=h==null?[]:[h]),w=L?r:w,sr(w)||(w=w==null?[]:[w]),b9(c,h,w))}var pne=Np(function(c,h,w){c[w?0:1].push(h)},function(){return[[],[]]});function gne(c,h,w){var L=sr(c)?qb:q7,W=arguments.length<3;return L(c,qt(h,4),w,W,Ra)}function mne(c,h,w){var L=sr(c)?IQ:q7,W=arguments.length<3;return L(c,qt(h,4),w,W,a9)}function vne(c,h){var w=sr(c)?Ma:c9;return w(c,Kp(qt(h,3)))}function bne(c){var h=sr(c)?n9:fte;return h(c)}function yne(c,h,w){(w?ci(c,h,w):h===r)?h=1:h=ur(h);var L=sr(c)?jee:lte;return L(c,h)}function wne(c){var h=sr(c)?qee:dte;return h(c)}function xne(c){if(c==null)return 0;if(Si(c))return Gp(c)?rf(c):c.length;var h=ti(c);return h==ie||h==Ie?c.size:ay(c).length}function _ne(c,h,w){var L=sr(c)?zb:pte;return w&&ci(c,h,w)&&(h=r),L(c,qt(h,3))}var Ene=hr(function(c,h){if(c==null)return[];var w=h.length;return w>1&&ci(c,h[0],h[1])?h=[]:w>2&&ci(h[0],h[1],h[2])&&(h=[h[0]]),b9(c,Kn(h,1),[])}),Hp=nee||function(){return _r.Date.now()};function Sne(c,h){if(typeof h!="function")throw new ss(o);return c=ur(c),function(){if(--c<1)return h.apply(this,arguments)}}function hA(c,h,w){return h=w?r:h,h=c&&h==null?c.length:h,zo(c,T,r,r,r,r,h)}function dA(c,h){var w;if(typeof h!="function")throw new ss(o);return c=ur(c),function(){return--c>0&&(w=h.apply(this,arguments)),c<=1&&(h=r),w}}var Ry=hr(function(c,h,w){var L=D;if(w.length){var W=Ca(w,lf(Ry));L|=K}return zo(c,L,h,w,W)}),pA=hr(function(c,h,w){var L=D|k;if(w.length){var W=Ca(w,lf(pA));L|=K}return zo(h,L,c,w,W)});function gA(c,h,w){h=w?r:h;var L=zo(c,q,r,r,r,r,r,h);return L.placeholder=gA.placeholder,L}function mA(c,h,w){h=w?r:h;var L=zo(c,U,r,r,r,r,r,h);return L.placeholder=mA.placeholder,L}function vA(c,h,w){var L,W,ne,he,ge,we,We=0,Ke=!1,Ze=!1,xt=!0;if(typeof c!="function")throw new ss(o);h=fs(h)||0,Qr(w)&&(Ke=!!w.leading,Ze="maxWait"in w,ne=Ze?Pn(fs(w.maxWait)||0,h):ne,xt="trailing"in w?!!w.trailing:xt);function Nt(vn){var Cs=L,Go=W;return L=W=r,We=vn,he=c.apply(Go,Cs),he}function Vt(vn){return We=vn,ge=Ch(br,h),Ke?Nt(vn):he}function fr(vn){var Cs=vn-we,Go=vn-We,kA=h-Cs;return Ze?ei(kA,ne-Go):kA}function Gt(vn){var Cs=vn-we,Go=vn-We;return we===r||Cs>=h||Cs<0||Ze&&Go>=ne}function br(){var vn=Hp();if(Gt(vn))return Er(vn);ge=Ch(br,fr(vn))}function Er(vn){return ge=r,xt&&L?Nt(vn):(L=W=r,he)}function Bi(){ge!==r&&M9(ge),We=0,L=we=W=ge=r}function ui(){return ge===r?he:Er(Hp())}function Fi(){var vn=Hp(),Cs=Gt(vn);if(L=arguments,W=this,we=vn,Cs){if(ge===r)return Vt(we);if(Ze)return M9(ge),ge=Ch(br,h),Nt(we)}return ge===r&&(ge=Ch(br,h)),he}return Fi.cancel=Bi,Fi.flush=ui,Fi}var Ane=hr(function(c,h){return o9(c,1,h)}),Pne=hr(function(c,h,w){return o9(c,fs(h)||0,w)});function Mne(c){return zo(c,ue)}function Wp(c,h){if(typeof c!="function"||h!=null&&typeof h!="function")throw new ss(o);var w=function(){var L=arguments,W=h?h.apply(this,L):L[0],ne=w.cache;if(ne.has(W))return ne.get(W);var he=c.apply(this,L);return w.cache=ne.set(W,he)||ne,he};return w.cache=new(Wp.Cache||jo),w}Wp.Cache=jo;function Kp(c){if(typeof c!="function")throw new ss(o);return function(){var h=arguments;switch(h.length){case 0:return!c.call(this);case 1:return!c.call(this,h[0]);case 2:return!c.call(this,h[0],h[1]);case 3:return!c.call(this,h[0],h[1],h[2])}return!c.apply(this,h)}}function Ine(c){return dA(2,c)}var Cne=gte(function(c,h){h=h.length==1&&sr(h[0])?Xr(h[0],Li(qt())):Xr(Kn(h,1),Li(qt()));var w=h.length;return hr(function(L){for(var W=-1,ne=ei(L.length,w);++W=h}),Nc=l9(function(){return arguments}())?l9:function(c){return rn(c)&&Tr.call(c,"callee")&&!X7.call(c,"callee")},sr=Ce.isArray,Hne=oi?Li(oi):Zee;function Si(c){return c!=null&&Vp(c.length)&&!Ko(c)}function mn(c){return rn(c)&&Si(c)}function Wne(c){return c===!0||c===!1||rn(c)&&ai(c)==X}var La=see||zy,Kne=As?Li(As):Qee;function Vne(c){return rn(c)&&c.nodeType===1&&!Th(c)}function Gne(c){if(c==null)return!0;if(Si(c)&&(sr(c)||typeof c=="string"||typeof c.splice=="function"||La(c)||hf(c)||Nc(c)))return!c.length;var h=ti(c);if(h==ie||h==Ie)return!c.size;if(Ih(c))return!ay(c).length;for(var w in c)if(Tr.call(c,w))return!1;return!0}function Yne(c,h){return Ah(c,h)}function Jne(c,h,w){w=typeof w=="function"?w:r;var L=w?w(c,h):r;return L===r?Ah(c,h,r,w):!!L}function Oy(c){if(!rn(c))return!1;var h=ai(c);return h==Z||h==R||typeof c.message=="string"&&typeof c.name=="string"&&!Th(c)}function Xne(c){return typeof c=="number"&&Q7(c)}function Ko(c){if(!Qr(c))return!1;var h=ai(c);return h==te||h==le||h==ee||h==Te}function yA(c){return typeof c=="number"&&c==ur(c)}function Vp(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=_}function Qr(c){var h=typeof c;return c!=null&&(h=="object"||h=="function")}function rn(c){return c!=null&&typeof c=="object"}var wA=ns?Li(ns):tte;function Zne(c,h){return c===h||oy(c,h,Ey(h))}function Qne(c,h,w){return w=typeof w=="function"?w:r,oy(c,h,Ey(h),w)}function eie(c){return xA(c)&&c!=+c}function tie(c){if(Bte(c))throw new tr(s);return h9(c)}function rie(c){return c===null}function nie(c){return c==null}function xA(c){return typeof c=="number"||rn(c)&&ai(c)==fe}function Th(c){if(!rn(c)||ai(c)!=Me)return!1;var h=wp(c);if(h===null)return!0;var w=Tr.call(h,"constructor")&&h.constructor;return typeof w=="function"&&w instanceof w&&mp.call(w)==QQ}var Ny=to?Li(to):rte;function iie(c){return yA(c)&&c>=-_&&c<=_}var _A=gh?Li(gh):nte;function Gp(c){return typeof c=="string"||!sr(c)&&rn(c)&&ai(c)==Le}function $i(c){return typeof c=="symbol"||rn(c)&&ai(c)==Ve}var hf=Pc?Li(Pc):ite;function sie(c){return c===r}function oie(c){return rn(c)&&ti(c)==ze}function aie(c){return rn(c)&&ai(c)==He}var cie=Bp(cy),uie=Bp(function(c,h){return c<=h});function EA(c){if(!c)return[];if(Si(c))return Gp(c)?Ps(c):Ei(c);if(vh&&c[vh])return jQ(c[vh]());var h=ti(c),w=h==ie?Yb:h==Ie?dp:df;return w(c)}function Vo(c){if(!c)return c===0?c:0;if(c=fs(c),c===x||c===-x){var h=c<0?-1:1;return h*S}return c===c?c:0}function ur(c){var h=Vo(c),w=h%1;return h===h?w?h-w:h:0}function SA(c){return c?Tc(ur(c),0,M):0}function fs(c){if(typeof c=="number")return c;if($i(c))return b;if(Qr(c)){var h=typeof c.valueOf=="function"?c.valueOf():c;c=Qr(h)?h+"":h}if(typeof c!="string")return c===0?c:+c;c=z7(c);var w=it.test(c);return w||gt.test(c)?ir(c.slice(2),w?2:8):De.test(c)?b:+c}function AA(c){return no(c,Ai(c))}function fie(c){return c?Tc(ur(c),-_,_):c===0?c:0}function Cr(c){return c==null?"":ki(c)}var lie=uf(function(c,h){if(Ih(h)||Si(h)){no(h,Bn(h),c);return}for(var w in h)Tr.call(h,w)&&_h(c,w,h[w])}),PA=uf(function(c,h){no(h,Ai(h),c)}),Yp=uf(function(c,h,w,L){no(h,Ai(h),c,L)}),hie=uf(function(c,h,w,L){no(h,Bn(h),c,L)}),die=Ho(ty);function pie(c,h){var w=cf(c);return h==null?w:i9(w,h)}var gie=hr(function(c,h){c=qr(c);var w=-1,L=h.length,W=L>2?h[2]:r;for(W&&ci(h[0],h[1],W)&&(L=1);++w1),ne}),no(c,xy(c),w),L&&(w=as(w,g|y|A,Pte));for(var W=h.length;W--;)dy(w,h[W]);return w});function Oie(c,h){return IA(c,Kp(qt(h)))}var Nie=Ho(function(c,h){return c==null?{}:ate(c,h)});function IA(c,h){if(c==null)return{};var w=Xr(xy(c),function(L){return[L]});return h=qt(h),y9(c,w,function(L,W){return h(L,W[0])})}function Lie(c,h,w){h=Oa(h,c);var L=-1,W=h.length;for(W||(W=1,c=r);++Lh){var L=c;c=h,h=L}if(w||c%1||h%1){var W=e9();return ei(c+W*(h-c+Ur("1e-"+((W+"").length-1))),h)}return fy(c,h)}var Kie=ff(function(c,h,w){return h=h.toLowerCase(),c+(w?RA(h):h)});function RA(c){return $y(Cr(c).toLowerCase())}function DA(c){return c=Cr(c),c&&c.replace(tt,kQ).replace(Fb,"")}function Vie(c,h,w){c=Cr(c),h=ki(h);var L=c.length;w=w===r?L:Tc(ur(w),0,L);var W=w;return w-=h.length,w>=0&&c.slice(w,W)==h}function Gie(c){return c=Cr(c),c&&Tt.test(c)?c.replace(Ot,$Q):c}function Yie(c){return c=Cr(c),c&&Ft.test(c)?c.replace(nt,"\\$&"):c}var Jie=ff(function(c,h,w){return c+(w?"-":"")+h.toLowerCase()}),Xie=ff(function(c,h,w){return c+(w?" ":"")+h.toLowerCase()}),Zie=L9("toLowerCase");function Qie(c,h,w){c=Cr(c),h=ur(h);var L=h?rf(c):0;if(!h||L>=h)return c;var W=(h-L)/2;return $p(Sp(W),w)+c+$p(Ep(W),w)}function ese(c,h,w){c=Cr(c),h=ur(h);var L=h?rf(c):0;return h&&L>>0,w?(c=Cr(c),c&&(typeof h=="string"||h!=null&&!Ny(h))&&(h=ki(h),!h&&tf(c))?Na(Ps(c),0,w):c.split(h,w)):[]}var ase=ff(function(c,h,w){return c+(w?" ":"")+$y(h)});function cse(c,h,w){return c=Cr(c),w=w==null?0:Tc(ur(w),0,c.length),h=ki(h),c.slice(w,w+h.length)==h}function use(c,h,w){var L=re.templateSettings;w&&ci(c,h,w)&&(h=r),c=Cr(c),h=Yp({},h,L,q9);var W=Yp({},h.imports,L.imports,q9),ne=Bn(W),he=Gb(W,ne),ge,we,We=0,Ke=h.interpolate||At,Ze="__p += '",xt=Jb((h.escape||At).source+"|"+Ke.source+"|"+(Ke===Lt?xe:At).source+"|"+(h.evaluate||At).source+"|$","g"),Nt="//# sourceURL="+(Tr.call(h,"sourceURL")?(h.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ub+"]")+` -`;c.replace(xt,function(Gt,br,Er,Bi,ui,Fi){return Er||(Er=Bi),Ze+=c.slice(We,Fi).replace(Rt,BQ),br&&(ge=!0,Ze+=`' + -__e(`+br+`) + -'`),ui&&(we=!0,Ze+=`'; -`+ui+`; -__p += '`),Er&&(Ze+=`' + -((__t = (`+Er+`)) == null ? '' : __t) + -'`),We=Fi+Gt.length,Gt}),Ze+=`'; -`;var Vt=Tr.call(h,"variable")&&h.variable;if(!Vt)Ze=`with (obj) { -`+Ze+` + */var Rj=Cf.exports,f6;function Tj(){return f6||(f6=1,(function(t,e){(function(){var r,n="4.17.21",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",o="Expected a function",a="Invalid `variable` option passed into `_.template`",f="__lodash_hash_undefined__",u=500,h="__lodash_placeholder__",g=1,b=2,x=4,S=1,C=2,D=1,B=2,L=4,H=8,F=16,k=32,$=64,R=128,W=256,V=512,X=30,q="...",_=800,v=16,l=1,p=2,m=3,y=1/0,A=9007199254740991,E=17976931348623157e292,w=NaN,I=4294967295,M=I-1,z=I>>>1,se=[["ary",R],["bind",D],["bindKey",B],["curry",H],["curryRight",F],["flip",V],["partial",k],["partialRight",$],["rearg",W]],O="[object Arguments]",ie="[object Array]",ee="[object AsyncFunction]",Z="[object Boolean]",te="[object Date]",N="[object DOMException]",Q="[object Error]",ne="[object Function]",de="[object GeneratorFunction]",ce="[object Map]",fe="[object Number]",be="[object Null]",Pe="[object Object]",De="[object Promise]",Te="[object Proxy]",Fe="[object RegExp]",Me="[object Set]",Ne="[object String]",He="[object Symbol]",Oe="[object Undefined]",$e="[object WeakMap]",qe="[object WeakSet]",_e="[object ArrayBuffer]",Qe="[object DataView]",at="[object Float32Array]",Be="[object Float64Array]",nt="[object Int8Array]",it="[object Int16Array]",Ye="[object Int32Array]",pt="[object Uint8Array]",ht="[object Uint8ClampedArray]",ft="[object Uint16Array]",Ht="[object Uint32Array]",Jt=/\b__p \+= '';/g,St=/\b(__p \+=) '' \+/g,Xt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,tr=/&(?:amp|lt|gt|quot|#39);/g,Dt=/[&<>"']/g,Bt=RegExp(tr.source),Ct=RegExp(Dt.source),gt=/<%-([\s\S]+?)%>/g,Ot=/<%([\s\S]+?)%>/g,Lt=/<%=([\s\S]+?)%>/g,bt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jt=/^\w*$/,Ut=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,tt=/[\\^$.*+?()[\]{}|]/g,Ft=RegExp(tt.source),K=/^\s+/,G=/\s/,J=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,T=/\{\n\/\* \[wrapped with (.+)\] \*/,j=/,? & /,oe=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,le=/[()=,{}\[\]\/\s]/,me=/\\(\\)?/g,Ee=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ke=/\w*$/,Ce=/^[-+]0x[0-9a-f]+$/i,et=/^0b[01]+$/i,Ze=/^\[object .+?Constructor\]$/,rt=/^0o[0-7]+$/i,ot=/^(?:0|[1-9]\d*)$/,yt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Rt=/($^)/,Mt=/['\n\r\u2028\u2029\\]/g,xt="\\ud800-\\udfff",Tt="\\u0300-\\u036f",mt="\\ufe20-\\ufe2f",Et="\\u20d0-\\u20ff",ct=Tt+mt+Et,wt="\\u2700-\\u27bf",lt="a-z\\xdf-\\xf6\\xf8-\\xff",st="\\xac\\xb1\\xd7\\xf7",Ae="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Ie="\\u2000-\\u206f",Ve=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ue="A-Z\\xc0-\\xd6\\xd8-\\xde",ze="\\ufe0e\\ufe0f",Je=st+Ae+Ie+Ve,kt="['’]",Wt="["+xt+"]",Zt="["+Je+"]",Kt="["+ct+"]",ge="\\d+",ir="["+wt+"]",gr="["+lt+"]",mr="[^"+xt+Je+ge+wt+lt+Ue+"]",Qt="\\ud83c[\\udffb-\\udfff]",vr="(?:"+Kt+"|"+Qt+")",hr="[^"+xt+"]",Lr="(?:\\ud83c[\\udde6-\\uddff]){2}",br="[\\ud800-\\udbff][\\udc00-\\udfff]",xr="["+Ue+"]",Fr="\\u200d",jr="(?:"+gr+"|"+mr+")",Mr="(?:"+xr+"|"+mr+")",un="(?:"+kt+"(?:d|ll|m|re|s|t|ve))?",fn="(?:"+kt+"(?:D|LL|M|RE|S|T|VE))?",ln=vr+"?",r0="["+ze+"]?",J1="(?:"+Fr+"(?:"+[hr,Lr,br].join("|")+")"+r0+ln+")*",uo="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",n0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",i0=r0+ln+J1,Zc="(?:"+[ir,Lr,br].join("|")+")"+i0,X1="(?:"+[hr+Kt+"?",Kt,Lr,br,Wt].join("|")+")",dl=RegExp(kt,"g"),Z1=RegExp(Kt,"g"),Qc=RegExp(Qt+"(?="+Qt+")|"+X1+i0,"g"),s0=RegExp([xr+"?"+gr+"+"+un+"(?="+[Zt,xr,"$"].join("|")+")",Mr+"+"+fn+"(?="+[Zt,xr+jr,"$"].join("|")+")",xr+"?"+jr+"+"+un,xr+"+"+fn,n0,uo,ge,Zc].join("|"),"g"),o0=RegExp("["+Fr+xt+ct+ze+"]"),Va=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,a0=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Q1=-1,Ur={};Ur[at]=Ur[Be]=Ur[nt]=Ur[it]=Ur[Ye]=Ur[pt]=Ur[ht]=Ur[ft]=Ur[Ht]=!0,Ur[O]=Ur[ie]=Ur[_e]=Ur[Z]=Ur[Qe]=Ur[te]=Ur[Q]=Ur[ne]=Ur[ce]=Ur[fe]=Ur[Pe]=Ur[Fe]=Ur[Me]=Ur[Ne]=Ur[$e]=!1;var kr={};kr[O]=kr[ie]=kr[_e]=kr[Qe]=kr[Z]=kr[te]=kr[at]=kr[Be]=kr[nt]=kr[it]=kr[Ye]=kr[ce]=kr[fe]=kr[Pe]=kr[Fe]=kr[Me]=kr[Ne]=kr[He]=kr[pt]=kr[ht]=kr[ft]=kr[Ht]=!0,kr[Q]=kr[ne]=kr[$e]=!1;var ue={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},we={"&":"&","<":"<",">":">",'"':""","'":"'"},Ge={"&":"&","<":"<",">":">",""":'"',"'":"'"},Pt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$r=parseFloat,sr=parseInt,Yr=typeof Wn=="object"&&Wn&&Wn.Object===Object&&Wn,bn=typeof self=="object"&&self&&self.Object===Object&&self,Er=Yr||bn||Function("return this")(),qr=e&&!e.nodeType&&e,hn=qr&&!0&&t&&!t.nodeType&&t,fi=hn&&hn.exports===qr,yn=fi&&Yr.process,Jr=(function(){try{var ye=hn&&hn.require&&hn.require("util").types;return ye||yn&&yn.binding&&yn.binding("util")}catch{}})(),Xn=Jr&&Jr.isArrayBuffer,ds=Jr&&Jr.isDate,Ki=Jr&&Jr.isMap,Ls=Jr&&Jr.isRegExp,pl=Jr&&Jr.isSet,Ga=Jr&&Jr.isTypedArray;function Cn(ye,je,Re){switch(Re.length){case 0:return ye.call(je);case 1:return ye.call(je,Re[0]);case 2:return ye.call(je,Re[0],Re[1]);case 3:return ye.call(je,Re[0],Re[1],Re[2])}return ye.apply(je,Re)}function $J(ye,je,Re,It){for(var rr=-1,Ir=ye==null?0:ye.length;++rr-1}function eb(ye,je,Re){for(var It=-1,rr=ye==null?0:ye.length;++It-1;);return Re}function O7(ye,je){for(var Re=ye.length;Re--&&eu(je,ye[Re],0)>-1;);return Re}function JJ(ye,je){for(var Re=ye.length,It=0;Re--;)ye[Re]===je&&++It;return It}var XJ=ib(ue),ZJ=ib(we);function QJ(ye){return"\\"+Pt[ye]}function eX(ye,je){return ye==null?r:ye[je]}function tu(ye){return o0.test(ye)}function tX(ye){return Va.test(ye)}function rX(ye){for(var je,Re=[];!(je=ye.next()).done;)Re.push(je.value);return Re}function cb(ye){var je=-1,Re=Array(ye.size);return ye.forEach(function(It,rr){Re[++je]=[rr,It]}),Re}function N7(ye,je){return function(Re){return ye(je(Re))}}function Xo(ye,je){for(var Re=-1,It=ye.length,rr=0,Ir=[];++Re-1}function zX(c,d){var P=this.__data__,U=A0(P,c);return U<0?(++this.size,P.push([c,d])):P[U][1]=d,this}fo.prototype.clear=jX,fo.prototype.delete=UX,fo.prototype.get=$X,fo.prototype.has=qX,fo.prototype.set=zX;function lo(c){var d=-1,P=c==null?0:c.length;for(this.clear();++d=d?c:d)),c}function Ji(c,d,P,U,Y,ae){var pe,ve=d&g,xe=d&b,We=d&x;if(P&&(pe=Y?P(c,U,Y,ae):P(c)),pe!==r)return pe;if(!Qr(c))return c;var Ke=or(c);if(Ke){if(pe=VZ(c),!ve)return li(c,pe)}else{var Xe=Hn(c),_t=Xe==ne||Xe==de;if(na(c))return m9(c,ve);if(Xe==Pe||Xe==O||_t&&!Y){if(pe=xe||_t?{}:L9(c),!ve)return xe?kZ(c,sZ(pe,c)):LZ(c,K7(pe,c))}else{if(!kr[Xe])return Y?c:{};pe=GZ(c,Xe,ve)}}ae||(ae=new gs);var Nt=ae.get(c);if(Nt)return Nt;ae.set(c,pe),fA(c)?c.forEach(function(Gt){pe.add(Ji(Gt,d,P,Gt,c,ae))}):cA(c)&&c.forEach(function(Gt,wr){pe.set(wr,Ji(Gt,d,P,wr,c,ae))});var Vt=We?xe?Nb:Ob:xe?di:Rn,fr=Ke?r:Vt(c);return Vi(fr||c,function(Gt,wr){fr&&(wr=Gt,Gt=c[wr]),xl(pe,wr,Ji(Gt,d,P,wr,c,ae))}),pe}function oZ(c){var d=Rn(c);return function(P){return V7(P,c,d)}}function V7(c,d,P){var U=P.length;if(c==null)return!U;for(c=zr(c);U--;){var Y=P[U],ae=d[Y],pe=c[Y];if(pe===r&&!(Y in c)||!ae(pe))return!1}return!0}function G7(c,d,P){if(typeof c!="function")throw new Gi(o);return Ml(function(){c.apply(r,P)},d)}function _l(c,d,P,U){var Y=-1,ae=c0,pe=!0,ve=c.length,xe=[],We=d.length;if(!ve)return xe;P&&(d=Xr(d,_i(P))),U?(ae=eb,pe=!1):d.length>=i&&(ae=gl,pe=!1,d=new Xa(d));e:for(;++YY?0:Y+P),U=U===r||U>Y?Y:ur(U),U<0&&(U+=Y),U=P>U?0:hA(U);P0&&P(ve)?d>1?Bn(ve,d-1,P,U,Y):Jo(Y,ve):U||(Y[Y.length]=ve)}return Y}var gb=_9(),X7=_9(!0);function ks(c,d){return c&&gb(c,d,Rn)}function mb(c,d){return c&&X7(c,d,Rn)}function I0(c,d){return Yo(d,function(P){return vo(c[P])})}function Qa(c,d){d=ta(d,c);for(var P=0,U=d.length;c!=null&&Pd}function uZ(c,d){return c!=null&&Rr.call(c,d)}function fZ(c,d){return c!=null&&d in zr(c)}function lZ(c,d,P){return c>=zn(d,P)&&c=120&&Ke.length>=120)?new Xa(pe&&Ke):r}Ke=c[0];var Xe=-1,_t=ve[0];e:for(;++Xe-1;)ve!==c&&b0.call(ve,xe,1),b0.call(c,xe,1);return c}function c9(c,d){for(var P=c?d.length:0,U=P-1;P--;){var Y=d[P];if(P==U||Y!==ae){var ae=Y;mo(Y)?b0.call(c,Y,1):Pb(c,Y)}}return c}function Eb(c,d){return c+x0(q7()*(d-c+1))}function SZ(c,d,P,U){for(var Y=-1,ae=En(w0((d-c)/(P||1)),0),pe=Re(ae);ae--;)pe[U?ae:++Y]=c,c+=P;return pe}function Sb(c,d){var P="";if(!c||d<1||d>A)return P;do d%2&&(P+=c),d=x0(d/2),d&&(c+=c);while(d);return P}function dr(c,d){return $b(F9(c,d,pi),c+"")}function AZ(c){return W7(hu(c))}function PZ(c,d){var P=hu(c);return F0(P,Za(d,0,P.length))}function Al(c,d,P,U){if(!Qr(c))return c;d=ta(d,c);for(var Y=-1,ae=d.length,pe=ae-1,ve=c;ve!=null&&++YY?0:Y+d),P=P>Y?Y:P,P<0&&(P+=Y),Y=d>P?0:P-d>>>0,d>>>=0;for(var ae=Re(Y);++U>>1,pe=c[ae];pe!==null&&!Si(pe)&&(P?pe<=d:pe=i){var We=d?null:UZ(c);if(We)return f0(We);pe=!1,Y=gl,xe=new Xa}else xe=d?[]:ve;e:for(;++U=U?c:Xi(c,d,P)}var g9=vX||function(c){return Er.clearTimeout(c)};function m9(c,d){if(d)return c.slice();var P=c.length,U=B7?B7(P):new c.constructor(P);return c.copy(U),U}function Rb(c){var d=new c.constructor(c.byteLength);return new m0(d).set(new m0(c)),d}function TZ(c,d){var P=d?Rb(c.buffer):c.buffer;return new c.constructor(P,c.byteOffset,c.byteLength)}function DZ(c){var d=new c.constructor(c.source,ke.exec(c));return d.lastIndex=c.lastIndex,d}function OZ(c){return wl?zr(wl.call(c)):{}}function v9(c,d){var P=d?Rb(c.buffer):c.buffer;return new c.constructor(P,c.byteOffset,c.length)}function b9(c,d){if(c!==d){var P=c!==r,U=c===null,Y=c===c,ae=Si(c),pe=d!==r,ve=d===null,xe=d===d,We=Si(d);if(!ve&&!We&&!ae&&c>d||ae&&pe&&xe&&!ve&&!We||U&&pe&&xe||!P&&xe||!Y)return 1;if(!U&&!ae&&!We&&c=ve)return xe;var We=P[U];return xe*(We=="desc"?-1:1)}}return c.index-d.index}function y9(c,d,P,U){for(var Y=-1,ae=c.length,pe=P.length,ve=-1,xe=d.length,We=En(ae-pe,0),Ke=Re(xe+We),Xe=!U;++ve1?P[Y-1]:r,pe=Y>2?P[2]:r;for(ae=c.length>3&&typeof ae=="function"?(Y--,ae):r,pe&&Qn(P[0],P[1],pe)&&(ae=Y<3?r:ae,Y=1),d=zr(d);++U-1?Y[ae?d[pe]:pe]:r}}function A9(c){return go(function(d){var P=d.length,U=P,Y=Yi.prototype.thru;for(c&&d.reverse();U--;){var ae=d[U];if(typeof ae!="function")throw new Gi(o);if(Y&&!pe&&k0(ae)=="wrapper")var pe=new Yi([],!0)}for(U=pe?U:P;++U1&&Sr.reverse(),Ke&&xeve))return!1;var We=ae.get(c),Ke=ae.get(d);if(We&&Ke)return We==d&&Ke==c;var Xe=-1,_t=!0,Nt=P&C?new Xa:r;for(ae.set(c,d),ae.set(d,c);++Xe1?"& ":"")+d[U],d=d.join(P>2?", ":" "),c.replace(J,`{ +/* [wrapped with `+d+`] */ +`)}function JZ(c){return or(c)||rc(c)||!!(U7&&c&&c[U7])}function mo(c,d){var P=typeof c;return d=d??A,!!d&&(P=="number"||P!="symbol"&&ot.test(c))&&c>-1&&c%1==0&&c0){if(++d>=_)return arguments[0]}else d=0;return c.apply(r,arguments)}}function F0(c,d){var P=-1,U=c.length,Y=U-1;for(d=d===r?U:d;++P1?c[d-1]:r;return P=typeof P=="function"?(c.pop(),P):r,J9(c,P)});function X9(c){var d=re(c);return d.__chain__=!0,d}function aee(c,d){return d(c),c}function j0(c,d){return d(c)}var cee=go(function(c){var d=c.length,P=d?c[0]:0,U=this.__wrapped__,Y=function(ae){return pb(ae,c)};return d>1||this.__actions__.length||!(U instanceof _r)||!mo(P)?this.thru(Y):(U=U.slice(P,+P+(d?1:0)),U.__actions__.push({func:j0,args:[Y],thisArg:r}),new Yi(U,this.__chain__).thru(function(ae){return d&&!ae.length&&ae.push(r),ae}))});function uee(){return X9(this)}function fee(){return new Yi(this.value(),this.__chain__)}function lee(){this.__values__===r&&(this.__values__=lA(this.value()));var c=this.__index__>=this.__values__.length,d=c?r:this.__values__[this.__index__++];return{done:c,value:d}}function hee(){return this}function dee(c){for(var d,P=this;P instanceof S0;){var U=H9(P);U.__index__=0,U.__values__=r,d?Y.__wrapped__=U:d=U;var Y=U;P=P.__wrapped__}return Y.__wrapped__=c,d}function pee(){var c=this.__wrapped__;if(c instanceof _r){var d=c;return this.__actions__.length&&(d=new _r(this)),d=d.reverse(),d.__actions__.push({func:j0,args:[qb],thisArg:r}),new Yi(d,this.__chain__)}return this.thru(qb)}function gee(){return d9(this.__wrapped__,this.__actions__)}var mee=T0(function(c,d,P){Rr.call(c,P)?++c[P]:ho(c,P,1)});function vee(c,d,P){var U=or(c)?P7:aZ;return P&&Qn(c,d,P)&&(d=r),U(c,qt(d,3))}function bee(c,d){var P=or(c)?Yo:J7;return P(c,qt(d,3))}var yee=S9(W9),wee=S9(K9);function xee(c,d){return Bn(U0(c,d),1)}function _ee(c,d){return Bn(U0(c,d),y)}function Eee(c,d,P){return P=P===r?1:ur(P),Bn(U0(c,d),P)}function Z9(c,d){var P=or(c)?Vi:Qo;return P(c,qt(d,3))}function Q9(c,d){var P=or(c)?qJ:Y7;return P(c,qt(d,3))}var See=T0(function(c,d,P){Rr.call(c,P)?c[P].push(d):ho(c,P,[d])});function Aee(c,d,P,U){c=hi(c)?c:hu(c),P=P&&!U?ur(P):0;var Y=c.length;return P<0&&(P=En(Y+P,0)),W0(c)?P<=Y&&c.indexOf(d,P)>-1:!!Y&&eu(c,d,P)>-1}var Pee=dr(function(c,d,P){var U=-1,Y=typeof d=="function",ae=hi(c)?Re(c.length):[];return Qo(c,function(pe){ae[++U]=Y?Cn(d,pe,P):El(pe,d,P)}),ae}),Iee=T0(function(c,d,P){ho(c,P,d)});function U0(c,d){var P=or(c)?Xr:r9;return P(c,qt(d,3))}function Mee(c,d,P,U){return c==null?[]:(or(d)||(d=d==null?[]:[d]),P=U?r:P,or(P)||(P=P==null?[]:[P]),o9(c,d,P))}var Cee=T0(function(c,d,P){c[P?0:1].push(d)},function(){return[[],[]]});function Ree(c,d,P){var U=or(c)?tb:R7,Y=arguments.length<3;return U(c,qt(d,4),P,Y,Qo)}function Tee(c,d,P){var U=or(c)?zJ:R7,Y=arguments.length<3;return U(c,qt(d,4),P,Y,Y7)}function Dee(c,d){var P=or(c)?Yo:J7;return P(c,z0(qt(d,3)))}function Oee(c){var d=or(c)?W7:AZ;return d(c)}function Nee(c,d,P){(P?Qn(c,d,P):d===r)?d=1:d=ur(d);var U=or(c)?rZ:PZ;return U(c,d)}function Lee(c){var d=or(c)?nZ:MZ;return d(c)}function kee(c){if(c==null)return 0;if(hi(c))return W0(c)?ru(c):c.length;var d=Hn(c);return d==ce||d==Me?c.size:wb(c).length}function Bee(c,d,P){var U=or(c)?rb:CZ;return P&&Qn(c,d,P)&&(d=r),U(c,qt(d,3))}var Fee=dr(function(c,d){if(c==null)return[];var P=d.length;return P>1&&Qn(c,d[0],d[1])?d=[]:P>2&&Qn(d[0],d[1],d[2])&&(d=[d[0]]),o9(c,Bn(d,1),[])}),$0=bX||function(){return Er.Date.now()};function jee(c,d){if(typeof d!="function")throw new Gi(o);return c=ur(c),function(){if(--c<1)return d.apply(this,arguments)}}function eA(c,d,P){return d=P?r:d,d=c&&d==null?c.length:d,po(c,R,r,r,r,r,d)}function tA(c,d){var P;if(typeof d!="function")throw new Gi(o);return c=ur(c),function(){return--c>0&&(P=d.apply(this,arguments)),c<=1&&(d=r),P}}var Hb=dr(function(c,d,P){var U=D;if(P.length){var Y=Xo(P,fu(Hb));U|=k}return po(c,U,d,P,Y)}),rA=dr(function(c,d,P){var U=D|B;if(P.length){var Y=Xo(P,fu(rA));U|=k}return po(d,U,c,P,Y)});function nA(c,d,P){d=P?r:d;var U=po(c,H,r,r,r,r,r,d);return U.placeholder=nA.placeholder,U}function iA(c,d,P){d=P?r:d;var U=po(c,F,r,r,r,r,r,d);return U.placeholder=iA.placeholder,U}function sA(c,d,P){var U,Y,ae,pe,ve,xe,We=0,Ke=!1,Xe=!1,_t=!0;if(typeof c!="function")throw new Gi(o);d=Qi(d)||0,Qr(P)&&(Ke=!!P.leading,Xe="maxWait"in P,ae=Xe?En(Qi(P.maxWait)||0,d):ae,_t="trailing"in P?!!P.trailing:_t);function Nt(pn){var vs=U,yo=Y;return U=Y=r,We=pn,pe=c.apply(yo,vs),pe}function Vt(pn){return We=pn,ve=Ml(wr,d),Ke?Nt(pn):pe}function fr(pn){var vs=pn-xe,yo=pn-We,SA=d-vs;return Xe?zn(SA,ae-yo):SA}function Gt(pn){var vs=pn-xe,yo=pn-We;return xe===r||vs>=d||vs<0||Xe&&yo>=ae}function wr(){var pn=$0();if(Gt(pn))return Sr(pn);ve=Ml(wr,fr(pn))}function Sr(pn){return ve=r,_t&&U?Nt(pn):(U=Y=r,pe)}function Ai(){ve!==r&&g9(ve),We=0,U=xe=Y=ve=r}function ei(){return ve===r?pe:Sr($0())}function Pi(){var pn=$0(),vs=Gt(pn);if(U=arguments,Y=this,xe=pn,vs){if(ve===r)return Vt(xe);if(Xe)return g9(ve),ve=Ml(wr,d),Nt(xe)}return ve===r&&(ve=Ml(wr,d)),pe}return Pi.cancel=Ai,Pi.flush=ei,Pi}var Uee=dr(function(c,d){return G7(c,1,d)}),$ee=dr(function(c,d,P){return G7(c,Qi(d)||0,P)});function qee(c){return po(c,V)}function q0(c,d){if(typeof c!="function"||d!=null&&typeof d!="function")throw new Gi(o);var P=function(){var U=arguments,Y=d?d.apply(this,U):U[0],ae=P.cache;if(ae.has(Y))return ae.get(Y);var pe=c.apply(this,U);return P.cache=ae.set(Y,pe)||ae,pe};return P.cache=new(q0.Cache||lo),P}q0.Cache=lo;function z0(c){if(typeof c!="function")throw new Gi(o);return function(){var d=arguments;switch(d.length){case 0:return!c.call(this);case 1:return!c.call(this,d[0]);case 2:return!c.call(this,d[0],d[1]);case 3:return!c.call(this,d[0],d[1],d[2])}return!c.apply(this,d)}}function zee(c){return tA(2,c)}var Hee=RZ(function(c,d){d=d.length==1&&or(d[0])?Xr(d[0],_i(qt())):Xr(Bn(d,1),_i(qt()));var P=d.length;return dr(function(U){for(var Y=-1,ae=zn(U.length,P);++Y=d}),rc=Q7((function(){return arguments})())?Q7:function(c){return tn(c)&&Rr.call(c,"callee")&&!j7.call(c,"callee")},or=Re.isArray,ste=Xn?_i(Xn):dZ;function hi(c){return c!=null&&H0(c.length)&&!vo(c)}function dn(c){return tn(c)&&hi(c)}function ote(c){return c===!0||c===!1||tn(c)&&Zn(c)==Z}var na=wX||ry,ate=ds?_i(ds):pZ;function cte(c){return tn(c)&&c.nodeType===1&&!Cl(c)}function ute(c){if(c==null)return!0;if(hi(c)&&(or(c)||typeof c=="string"||typeof c.splice=="function"||na(c)||lu(c)||rc(c)))return!c.length;var d=Hn(c);if(d==ce||d==Me)return!c.size;if(Il(c))return!wb(c).length;for(var P in c)if(Rr.call(c,P))return!1;return!0}function fte(c,d){return Sl(c,d)}function lte(c,d,P){P=typeof P=="function"?P:r;var U=P?P(c,d):r;return U===r?Sl(c,d,r,P):!!U}function Kb(c){if(!tn(c))return!1;var d=Zn(c);return d==Q||d==N||typeof c.message=="string"&&typeof c.name=="string"&&!Cl(c)}function hte(c){return typeof c=="number"&&$7(c)}function vo(c){if(!Qr(c))return!1;var d=Zn(c);return d==ne||d==de||d==ee||d==Te}function aA(c){return typeof c=="number"&&c==ur(c)}function H0(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=A}function Qr(c){var d=typeof c;return c!=null&&(d=="object"||d=="function")}function tn(c){return c!=null&&typeof c=="object"}var cA=Ki?_i(Ki):mZ;function dte(c,d){return c===d||yb(c,d,kb(d))}function pte(c,d,P){return P=typeof P=="function"?P:r,yb(c,d,kb(d),P)}function gte(c){return uA(c)&&c!=+c}function mte(c){if(QZ(c))throw new rr(s);return e9(c)}function vte(c){return c===null}function bte(c){return c==null}function uA(c){return typeof c=="number"||tn(c)&&Zn(c)==fe}function Cl(c){if(!tn(c)||Zn(c)!=Pe)return!1;var d=v0(c);if(d===null)return!0;var P=Rr.call(d,"constructor")&&d.constructor;return typeof P=="function"&&P instanceof P&&d0.call(P)==pX}var Vb=Ls?_i(Ls):vZ;function yte(c){return aA(c)&&c>=-A&&c<=A}var fA=pl?_i(pl):bZ;function W0(c){return typeof c=="string"||!or(c)&&tn(c)&&Zn(c)==Ne}function Si(c){return typeof c=="symbol"||tn(c)&&Zn(c)==He}var lu=Ga?_i(Ga):yZ;function wte(c){return c===r}function xte(c){return tn(c)&&Hn(c)==$e}function _te(c){return tn(c)&&Zn(c)==qe}var Ete=L0(xb),Ste=L0(function(c,d){return c<=d});function lA(c){if(!c)return[];if(hi(c))return W0(c)?ps(c):li(c);if(ml&&c[ml])return rX(c[ml]());var d=Hn(c),P=d==ce?cb:d==Me?f0:hu;return P(c)}function bo(c){if(!c)return c===0?c:0;if(c=Qi(c),c===y||c===-y){var d=c<0?-1:1;return d*E}return c===c?c:0}function ur(c){var d=bo(c),P=d%1;return d===d?P?d-P:d:0}function hA(c){return c?Za(ur(c),0,I):0}function Qi(c){if(typeof c=="number")return c;if(Si(c))return w;if(Qr(c)){var d=typeof c.valueOf=="function"?c.valueOf():c;c=Qr(d)?d+"":d}if(typeof c!="string")return c===0?c:+c;c=T7(c);var P=et.test(c);return P||rt.test(c)?sr(c.slice(2),P?2:8):Ce.test(c)?w:+c}function dA(c){return Bs(c,di(c))}function Ate(c){return c?Za(ur(c),-A,A):c===0?c:0}function Cr(c){return c==null?"":Ei(c)}var Pte=cu(function(c,d){if(Il(d)||hi(d)){Bs(d,Rn(d),c);return}for(var P in d)Rr.call(d,P)&&xl(c,P,d[P])}),pA=cu(function(c,d){Bs(d,di(d),c)}),K0=cu(function(c,d,P,U){Bs(d,di(d),c,U)}),Ite=cu(function(c,d,P,U){Bs(d,Rn(d),c,U)}),Mte=go(pb);function Cte(c,d){var P=au(c);return d==null?P:K7(P,d)}var Rte=dr(function(c,d){c=zr(c);var P=-1,U=d.length,Y=U>2?d[2]:r;for(Y&&Qn(d[0],d[1],Y)&&(U=1);++P1),ae}),Bs(c,Nb(c),P),U&&(P=Ji(P,g|b|x,$Z));for(var Y=d.length;Y--;)Pb(P,d[Y]);return P});function Gte(c,d){return mA(c,z0(qt(d)))}var Yte=go(function(c,d){return c==null?{}:_Z(c,d)});function mA(c,d){if(c==null)return{};var P=Xr(Nb(c),function(U){return[U]});return d=qt(d),a9(c,P,function(U,Y){return d(U,Y[0])})}function Jte(c,d,P){d=ta(d,c);var U=-1,Y=d.length;for(Y||(Y=1,c=r);++Ud){var U=c;c=d,d=U}if(P||c%1||d%1){var Y=q7();return zn(c+Y*(d-c+$r("1e-"+((Y+"").length-1))),d)}return Eb(c,d)}var are=uu(function(c,d,P){return d=d.toLowerCase(),c+(P?yA(d):d)});function yA(c){return Jb(Cr(c).toLowerCase())}function wA(c){return c=Cr(c),c&&c.replace(yt,XJ).replace(Z1,"")}function cre(c,d,P){c=Cr(c),d=Ei(d);var U=c.length;P=P===r?U:Za(ur(P),0,U);var Y=P;return P-=d.length,P>=0&&c.slice(P,Y)==d}function ure(c){return c=Cr(c),c&&Ct.test(c)?c.replace(Dt,ZJ):c}function fre(c){return c=Cr(c),c&&Ft.test(c)?c.replace(tt,"\\$&"):c}var lre=uu(function(c,d,P){return c+(P?"-":"")+d.toLowerCase()}),hre=uu(function(c,d,P){return c+(P?" ":"")+d.toLowerCase()}),dre=E9("toLowerCase");function pre(c,d,P){c=Cr(c),d=ur(d);var U=d?ru(c):0;if(!d||U>=d)return c;var Y=(d-U)/2;return N0(x0(Y),P)+c+N0(w0(Y),P)}function gre(c,d,P){c=Cr(c),d=ur(d);var U=d?ru(c):0;return d&&U>>0,P?(c=Cr(c),c&&(typeof d=="string"||d!=null&&!Vb(d))&&(d=Ei(d),!d&&tu(c))?ra(ps(c),0,P):c.split(d,P)):[]}var _re=uu(function(c,d,P){return c+(P?" ":"")+Jb(d)});function Ere(c,d,P){return c=Cr(c),P=P==null?0:Za(ur(P),0,c.length),d=Ei(d),c.slice(P,P+d.length)==d}function Sre(c,d,P){var U=re.templateSettings;P&&Qn(c,d,P)&&(d=r),c=Cr(c),d=K0({},d,U,R9);var Y=K0({},d.imports,U.imports,R9),ae=Rn(Y),pe=ab(Y,ae),ve,xe,We=0,Ke=d.interpolate||Rt,Xe="__p += '",_t=ub((d.escape||Rt).source+"|"+Ke.source+"|"+(Ke===Lt?Ee:Rt).source+"|"+(d.evaluate||Rt).source+"|$","g"),Nt="//# sourceURL="+(Rr.call(d,"sourceURL")?(d.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Q1+"]")+` +`;c.replace(_t,function(Gt,wr,Sr,Ai,ei,Pi){return Sr||(Sr=Ai),Xe+=c.slice(We,Pi).replace(Mt,QJ),wr&&(ve=!0,Xe+=`' + +__e(`+wr+`) + +'`),ei&&(xe=!0,Xe+=`'; +`+ei+`; +__p += '`),Sr&&(Xe+=`' + +((__t = (`+Sr+`)) == null ? '' : __t) + +'`),We=Pi+Gt.length,Gt}),Xe+=`'; +`;var Vt=Rr.call(d,"variable")&&d.variable;if(!Vt)Xe=`with (obj) { +`+Xe+` } -`;else if(oe.test(Vt))throw new tr(a);Ze=(we?Ze.replace(Jt,""):Ze).replace(St,"$1").replace(er,"$1;"),Ze="function("+(Vt||"obj")+`) { +`;else if(le.test(Vt))throw new rr(a);Xe=(xe?Xe.replace(Jt,""):Xe).replace(St,"$1").replace(Xt,"$1;"),Xe="function("+(Vt||"obj")+`) { `+(Vt?"":`obj || (obj = {}); -`)+"var __t, __p = ''"+(ge?", __e = _.escape":"")+(we?`, __j = Array.prototype.join; +`)+"var __t, __p = ''"+(ve?", __e = _.escape":"")+(xe?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; -`)+Ze+`return __p -}`;var fr=NA(function(){return Mr(ne,Nt+"return "+Ze).apply(r,he)});if(fr.source=Ze,Oy(fr))throw fr;return fr}function fse(c){return Cr(c).toLowerCase()}function lse(c){return Cr(c).toUpperCase()}function hse(c,h,w){if(c=Cr(c),c&&(w||h===r))return z7(c);if(!c||!(h=ki(h)))return c;var L=Ps(c),W=Ps(h),ne=H7(L,W),he=W7(L,W)+1;return Na(L,ne,he).join("")}function dse(c,h,w){if(c=Cr(c),c&&(w||h===r))return c.slice(0,V7(c)+1);if(!c||!(h=ki(h)))return c;var L=Ps(c),W=W7(L,Ps(h))+1;return Na(L,0,W).join("")}function pse(c,h,w){if(c=Cr(c),c&&(w||h===r))return c.replace(B,"");if(!c||!(h=ki(h)))return c;var L=Ps(c),W=H7(L,Ps(h));return Na(L,W).join("")}function gse(c,h){var w=_e,L=G;if(Qr(h)){var W="separator"in h?h.separator:W;w="length"in h?ur(h.length):w,L="omission"in h?ki(h.omission):L}c=Cr(c);var ne=c.length;if(tf(c)){var he=Ps(c);ne=he.length}if(w>=ne)return c;var ge=w-rf(L);if(ge<1)return L;var we=he?Na(he,0,ge).join(""):c.slice(0,ge);if(W===r)return we+L;if(he&&(ge+=we.length-ge),Ny(W)){if(c.slice(ge).search(W)){var We,Ke=we;for(W.global||(W=Jb(W.source,Cr(Re.exec(W))+"g")),W.lastIndex=0;We=W.exec(Ke);)var Ze=We.index;we=we.slice(0,Ze===r?ge:Ze)}}else if(c.indexOf(ki(W),ge)!=ge){var xt=we.lastIndexOf(W);xt>-1&&(we=we.slice(0,xt))}return we+L}function mse(c){return c=Cr(c),c&&$t.test(c)?c.replace(Xt,WQ):c}var vse=ff(function(c,h,w){return c+(w?" ":"")+h.toUpperCase()}),$y=L9("toUpperCase");function OA(c,h,w){return c=Cr(c),h=w?r:h,h===r?UQ(c)?GQ(c):RQ(c):c.match(h)||[]}var NA=hr(function(c,h){try{return $n(c,r,h)}catch(w){return Oy(w)?w:new tr(w)}}),bse=Ho(function(c,h){return is(h,function(w){w=io(w),qo(c,w,Ry(c[w],c))}),c});function yse(c){var h=c==null?0:c.length,w=qt();return c=h?Xr(c,function(L){if(typeof L[1]!="function")throw new ss(o);return[w(L[0]),L[1]]}):[],hr(function(L){for(var W=-1;++W_)return[];var w=M,L=ei(c,M);h=qt(h),c-=M;for(var W=Vb(L,h);++w0||h<0)?new xr(w):(c<0?w=w.takeRight(-c):c&&(w=w.drop(c)),h!==r&&(h=ur(h),w=h<0?w.dropRight(-h):w.take(h-c)),w)},xr.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},xr.prototype.toArray=function(){return this.take(M)},ro(xr.prototype,function(c,h){var w=/^(?:filter|find|map|reject)|While$/.test(h),L=/^(?:head|last)$/.test(h),W=re[L?"take"+(h=="last"?"Right":""):h],ne=L||/^find/.test(h);W&&(re.prototype[h]=function(){var he=this.__wrapped__,ge=L?[1]:arguments,we=he instanceof xr,We=ge[0],Ke=we||sr(he),Ze=function(br){var Er=W.apply(re,Ia([br],ge));return L&&xt?Er[0]:Er};Ke&&w&&typeof We=="function"&&We.length!=1&&(we=Ke=!1);var xt=this.__chain__,Nt=!!this.__actions__.length,Vt=ne&&!xt,fr=we&&!Nt;if(!ne&&Ke){he=fr?he:new xr(this);var Gt=c.apply(he,ge);return Gt.__actions__.push({func:qp,args:[Ze],thisArg:r}),new os(Gt,xt)}return Vt&&fr?c.apply(this,ge):(Gt=this.thru(Ze),Vt?L?Gt.value()[0]:Gt.value():Gt)})}),is(["pop","push","shift","sort","splice","unshift"],function(c){var h=pp[c],w=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",L=/^(?:pop|shift)$/.test(c);re.prototype[c]=function(){var W=arguments;if(L&&!this.__chain__){var ne=this.value();return h.apply(sr(ne)?ne:[],W)}return this[w](function(he){return h.apply(sr(he)?he:[],W)})}}),ro(xr.prototype,function(c,h){var w=re[h];if(w){var L=w.name+"";Tr.call(af,L)||(af[L]=[]),af[L].push({name:h,func:w})}}),af[Lp(r,k).name]=[{name:"wrapper",func:r}],xr.prototype.clone=mee,xr.prototype.reverse=vee,xr.prototype.value=bee,re.prototype.at=Vre,re.prototype.chain=Gre,re.prototype.commit=Yre,re.prototype.next=Jre,re.prototype.plant=Zre,re.prototype.reverse=Qre,re.prototype.toJSON=re.prototype.valueOf=re.prototype.value=ene,re.prototype.first=re.prototype.head,vh&&(re.prototype[vh]=Xre),re},nf=YQ();gn?((gn.exports=nf)._=nf,jr._=nf):_r._=nf}).call(nn)}(Qd,Qd.exports);var gq=Qd.exports,A1={exports:{}};(function(t,e){var r=typeof self<"u"?self:nn,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function u(f){return f&&DataView.prototype.isPrototypeOf(f)}if(a.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],d=ArrayBuffer.isView||function(f){return f&&l.indexOf(Object.prototype.toString.call(f))>-1};function g(f){if(typeof f!="string"&&(f=String(f)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(f))throw new TypeError("Invalid character in header field name");return f.toLowerCase()}function y(f){return typeof f!="string"&&(f=String(f)),f}function A(f){var p={next:function(){var v=f.shift();return{done:v===void 0,value:v}}};return a.iterable&&(p[Symbol.iterator]=function(){return p}),p}function P(f){this.map={},f instanceof P?f.forEach(function(p,v){this.append(v,p)},this):Array.isArray(f)?f.forEach(function(p){this.append(p[0],p[1])},this):f&&Object.getOwnPropertyNames(f).forEach(function(p){this.append(p,f[p])},this)}P.prototype.append=function(f,p){f=g(f),p=y(p);var v=this.map[f];this.map[f]=v?v+", "+p:p},P.prototype.delete=function(f){delete this.map[g(f)]},P.prototype.get=function(f){return f=g(f),this.has(f)?this.map[f]:null},P.prototype.has=function(f){return this.map.hasOwnProperty(g(f))},P.prototype.set=function(f,p){this.map[g(f)]=y(p)},P.prototype.forEach=function(f,p){for(var v in this.map)this.map.hasOwnProperty(v)&&f.call(p,this.map[v],v,this)},P.prototype.keys=function(){var f=[];return this.forEach(function(p,v){f.push(v)}),A(f)},P.prototype.values=function(){var f=[];return this.forEach(function(p){f.push(p)}),A(f)},P.prototype.entries=function(){var f=[];return this.forEach(function(p,v){f.push([v,p])}),A(f)},a.iterable&&(P.prototype[Symbol.iterator]=P.prototype.entries);function N(f){if(f.bodyUsed)return Promise.reject(new TypeError("Already read"));f.bodyUsed=!0}function D(f){return new Promise(function(p,v){f.onload=function(){p(f.result)},f.onerror=function(){v(f.error)}})}function k(f){var p=new FileReader,v=D(p);return p.readAsArrayBuffer(f),v}function $(f){var p=new FileReader,v=D(p);return p.readAsText(f),v}function q(f){for(var p=new Uint8Array(f),v=new Array(p.length),x=0;x-1?p:f}function z(f,p){p=p||{};var v=p.body;if(f instanceof z){if(f.bodyUsed)throw new TypeError("Already read");this.url=f.url,this.credentials=f.credentials,p.headers||(this.headers=new P(f.headers)),this.method=f.method,this.mode=f.mode,this.signal=f.signal,!v&&f._bodyInit!=null&&(v=f._bodyInit,f.bodyUsed=!0)}else this.url=String(f);if(this.credentials=p.credentials||this.credentials||"same-origin",(p.headers||!this.headers)&&(this.headers=new P(p.headers)),this.method=T(p.method||this.method||"GET"),this.mode=p.mode||this.mode||null,this.signal=p.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&v)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(v)}z.prototype.clone=function(){return new z(this,{body:this._bodyInit})};function ue(f){var p=new FormData;return f.trim().split("&").forEach(function(v){if(v){var x=v.split("="),_=x.shift().replace(/\+/g," "),S=x.join("=").replace(/\+/g," ");p.append(decodeURIComponent(_),decodeURIComponent(S))}}),p}function _e(f){var p=new P,v=f.replace(/\r?\n[\t ]+/g," ");return v.split(/\r?\n/).forEach(function(x){var _=x.split(":"),S=_.shift().trim();if(S){var b=_.join(":").trim();p.append(S,b)}}),p}K.call(z.prototype);function G(f,p){p||(p={}),this.type="default",this.status=p.status===void 0?200:p.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in p?p.statusText:"OK",this.headers=new P(p.headers),this.url=p.url||"",this._initBody(f)}K.call(G.prototype),G.prototype.clone=function(){return new G(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new P(this.headers),url:this.url})},G.error=function(){var f=new G(null,{status:0,statusText:""});return f.type="error",f};var E=[301,302,303,307,308];G.redirect=function(f,p){if(E.indexOf(p)===-1)throw new RangeError("Invalid status code");return new G(null,{status:p,headers:{location:f}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(p,v){this.message=p,this.name=v;var x=Error(p);this.stack=x.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function m(f,p){return new Promise(function(v,x){var _=new z(f,p);if(_.signal&&_.signal.aborted)return x(new o.DOMException("Aborted","AbortError"));var S=new XMLHttpRequest;function b(){S.abort()}S.onload=function(){var M={status:S.status,statusText:S.statusText,headers:_e(S.getAllResponseHeaders()||"")};M.url="responseURL"in S?S.responseURL:M.headers.get("X-Request-URL");var I="response"in S?S.response:S.responseText;v(new G(I,M))},S.onerror=function(){x(new TypeError("Network request failed"))},S.ontimeout=function(){x(new TypeError("Network request failed"))},S.onabort=function(){x(new o.DOMException("Aborted","AbortError"))},S.open(_.method,_.url,!0),_.credentials==="include"?S.withCredentials=!0:_.credentials==="omit"&&(S.withCredentials=!1),"responseType"in S&&a.blob&&(S.responseType="blob"),_.headers.forEach(function(M,I){S.setRequestHeader(I,M)}),_.signal&&(_.signal.addEventListener("abort",b),S.onreadystatechange=function(){S.readyState===4&&_.signal.removeEventListener("abort",b)}),S.send(typeof _._bodyInit>"u"?null:_._bodyInit)})}return m.polyfill=!0,s.fetch||(s.fetch=m,s.Headers=P,s.Request=z,s.Response=G),o.Headers=P,o.Request=z,o.Response=G,o.fetch=m,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(A1,A1.exports);var mq=A1.exports;const R6=Ui(mq);var vq=Object.defineProperty,bq=Object.defineProperties,yq=Object.getOwnPropertyDescriptors,D6=Object.getOwnPropertySymbols,wq=Object.prototype.hasOwnProperty,xq=Object.prototype.propertyIsEnumerable,O6=(t,e,r)=>e in t?vq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,N6=(t,e)=>{for(var r in e||(e={}))wq.call(e,r)&&O6(t,r,e[r]);if(D6)for(var r of D6(e))xq.call(e,r)&&O6(t,r,e[r]);return t},L6=(t,e)=>bq(t,yq(e));const _q={Accept:"application/json","Content-Type":"application/json"},Eq="POST",k6={headers:_q,method:Eq},$6=10;let ws=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new qi.EventEmitter,this.isAvailable=!1,this.registering=!1,!k_(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}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(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const r=go(e),n=await(await R6(this.url,L6(N6({},k6),{body:r}))).json();this.onPayload({data:n})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!k_(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=go({id:1,jsonrpc:"2.0",method:"test",params:[]});await R6(e,L6(N6({},k6),{body:r}))}this.onOpen()}catch(r){const n=this.parseError(r);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?Wa(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Vd(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return R_(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>$6&&this.events.setMaxListeners($6)}};const B6="error",Sq="wss://relay.walletconnect.org",Aq="wc",Pq="universal_provider",F6=`${Aq}@2:${Pq}:`,U6="https://rpc.walletconnect.org/v1/",Mu="generic",Mq=`${U6}bundler`,Qi={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Iq=Object.defineProperty,Cq=Object.defineProperties,Tq=Object.getOwnPropertyDescriptors,j6=Object.getOwnPropertySymbols,Rq=Object.prototype.hasOwnProperty,Dq=Object.prototype.propertyIsEnumerable,q6=(t,e,r)=>e in t?Iq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,e0=(t,e)=>{for(var r in e||(e={}))Rq.call(e,r)&&q6(t,r,e[r]);if(j6)for(var r of j6(e))Dq.call(e,r)&&q6(t,r,e[r]);return t},Oq=(t,e)=>Cq(t,Tq(e));function Di(t,e,r){var n;const i=_u(t);return((n=e.rpcMap)==null?void 0:n[i.reference])||`${U6}?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function uc(t){return t.includes(":")?t.split(":")[1]:t}function z6(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function Nq(t,e){const r=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!r.length)return[];const n=[];return r.forEach(i=>{const s=e.namespaces[i].accounts;n.push(...s)}),n}function P1(t={},e={}){const r=H6(t),n=H6(e);return gq.merge(r,n)}function H6(t){var e,r,n,i;const s={};if(!El(t))return s;for(const[o,a]of Object.entries(t)){const u=u1(o)?[o]:a.chains,l=a.methods||[],d=a.events||[],g=a.rpcMap||{},y=_l(o);s[y]=Oq(e0(e0({},s[y]),a),{chains:Ud(u,(e=s[y])==null?void 0:e.chains),methods:Ud(l,(r=s[y])==null?void 0:r.methods),events:Ud(d,(n=s[y])==null?void 0:n.events),rpcMap:e0(e0({},g),(i=s[y])==null?void 0:i.rpcMap)})}return s}function Lq(t){return t.includes(":")?t.split(":")[2]:t}function W6(t){const e={};for(const[r,n]of Object.entries(t)){const i=n.methods||[],s=n.events||[],o=n.accounts||[],a=u1(r)?[r]:n.chains?n.chains:z6(n.accounts);e[r]={chains:a,methods:i,events:s,accounts:o}}return e}function M1(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const K6={},Ar=t=>K6[t],I1=(t,e)=>{K6[t]=e};class kq{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=uc(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||Di(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ji(new ws(n,Ar("disableProviderPing")))}}var $q=Object.defineProperty,Bq=Object.defineProperties,Fq=Object.getOwnPropertyDescriptors,V6=Object.getOwnPropertySymbols,Uq=Object.prototype.hasOwnProperty,jq=Object.prototype.propertyIsEnumerable,G6=(t,e,r)=>e in t?$q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Y6=(t,e)=>{for(var r in e||(e={}))Uq.call(e,r)&&G6(t,r,e[r]);if(V6)for(var r of V6(e))jq.call(e,r)&&G6(t,r,e[r]);return t},J6=(t,e)=>Bq(t,Fq(e));class qq{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const n=r||Di(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ji(new ws(n,Ar("disableProviderPing")))}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=parseInt(uc(r));e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,n;let i=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var r,n,i;const s=(n=(r=e.request)==null?void 0:r.params)==null?void 0:n[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((i=o==null?void 0:o.sessionProperties)==null?void 0:i.capabilities)||{};if(a!=null&&a[s])return a==null?void 0:a[s];const u=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:J6(Y6({},o.sessionProperties||{}),{capabilities:J6(Y6({},a||{}),{[s]:u})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return u}async getCallStatus(e){var r,n;const i=this.client.session.get(e.topic),s=(r=i.sessionProperties)==null?void 0:r.bundler_name;if(s){const a=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(a,e)}catch(u){console.warn("Failed to fetch call status from bundler",u,a)}}const o=(n=i.sessionProperties)==null?void 0:n.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,r){var n;const i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ha("eth_getUserOperationReceipt",[(n=r.request.params)==null?void 0:n[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${Mq}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}class zq{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=uc(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||Di(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ji(new ws(n,Ar("disableProviderPing")))}}let Hq=class{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=uc(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||Di(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ji(new ws(n,Ar("disableProviderPing")))}},Wq=class{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(!this.httpProviders[e]){const n=r||Di(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.chainId=e,this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||Di(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Ji(new ws(n,Ar("disableProviderPing")))}},Kq=class{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const n=this.getCardanoRPCUrl(r),i=uc(r);e[i]=this.createHttpProvider(i,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ji(new ws(n,Ar("disableProviderPing")))}},Vq=class{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=uc(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||Di(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ji(new ws(n,Ar("disableProviderPing")))}};class Gq{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=uc(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||Di(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ji(new ws(n,Ar("disableProviderPing")))}}let Yq=class{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||Di(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||Di(e,this.namespace);return typeof n>"u"?void 0:new Ji(new ws(n,Ar("disableProviderPing")))}};class Jq{constructor(e){this.name="tezos",this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||Di(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||Di(e,this.namespace);return typeof n>"u"?void 0:new Ji(new ws(n))}}class Xq{constructor(e){this.name=Mu,this.namespace=e.namespace,this.events=Ar("events"),this.client=Ar("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Qi.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const n={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(i=>{const s=_u(i);n[`${s.namespace}:${s.reference}`]=this.createHttpProvider(i)}),n}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||Di(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ji(new ws(n,Ar("disableProviderPing")))}}var Zq=Object.defineProperty,Qq=Object.defineProperties,ez=Object.getOwnPropertyDescriptors,X6=Object.getOwnPropertySymbols,tz=Object.prototype.hasOwnProperty,rz=Object.prototype.propertyIsEnumerable,Z6=(t,e,r)=>e in t?Zq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,t0=(t,e)=>{for(var r in e||(e={}))tz.call(e,r)&&Z6(t,r,e[r]);if(X6)for(var r of X6(e))rz.call(e,r)&&Z6(t,r,e[r]);return t},C1=(t,e)=>Qq(t,ez(e));let Q6=class BA{constructor(e){this.events=new Gg,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Zf(sd({level:(e==null?void 0:e.logger)||B6})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const r=new BA(e);return await r.initialize(),r}async request(e,r,n){const[i,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:t0({},e),chainId:`${i}:${s}`,topic:this.session.topic,expiry:n})}sendAsync(e,r,n,i){const s=new Date().getTime();this.request(e,n,i).then(o=>r(null,Kd(s,o))).catch(o=>r(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Dr("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:i}=await this.client.authenticate(e,r);n&&(this.uri=n,this.events.emit("display_uri",n));const s=await i();if(this.session=s.session,this.session){const o=W6(this.session.namespaces);this.namespaces=P1(this.namespaces,o),this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await i().then(s=>{this.session=s;const o=W6(s.namespaces);this.namespaces=P1(this.namespaces,o),this.persist("namespaces",this.namespaces)}).catch(s=>{if(s.message!==I6)throw s;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[n,i]=this.validateChain(e),s=this.getProvider(n);s.name===Mu?s.setDefaultChain(`${n}:${i}`,r):s.setDefaultChain(i,r)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(nc(r)){for(const n of r)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await S1.init({core:this.providerOpts.core,logger:this.providerOpts.logger||B6,relayUrl:this.providerOpts.relayUrl||Sq,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>_l(r)))];I1("client",this.client),I1("events",this.events),I1("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const n=Nq(r,this.session),i=z6(n),s=P1(this.namespaces,this.optionalNamespaces),o=C1(t0({},s[r]),{accounts:n,chains:i});switch(r){case"eip155":this.rpcProviders[r]=new qq({namespace:o});break;case"algorand":this.rpcProviders[r]=new Wq({namespace:o});break;case"solana":this.rpcProviders[r]=new zq({namespace:o});break;case"cosmos":this.rpcProviders[r]=new Hq({namespace:o});break;case"polkadot":this.rpcProviders[r]=new kq({namespace:o});break;case"cip34":this.rpcProviders[r]=new Kq({namespace:o});break;case"elrond":this.rpcProviders[r]=new Vq({namespace:o});break;case"multiversx":this.rpcProviders[r]=new Gq({namespace:o});break;case"near":this.rpcProviders[r]=new Yq({namespace:o});break;case"tezos":this.rpcProviders[r]=new Jq({namespace:o});break;default:this.rpcProviders[Mu]?this.rpcProviders[Mu].updateNamespace(o):this.rpcProviders[Mu]=new Xq({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:r}=e,{event:n}=r;if(n.name==="accountsChanged"){const i=n.data;i&&nc(i)&&this.events.emit("accountsChanged",i.map(Lq))}else if(n.name==="chainChanged"){const i=r.chainId,s=r.event.data,o=_l(i),a=M1(i)!==M1(s)?`${o}:${M1(s)}`:i;this.onChainChanged(a)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var n;const{namespaces:i}=r,s=(n=this.client)==null?void 0:n.session.get(e);this.session=C1(t0({},s),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",C1(t0({},Dr("USER_DISCONNECTED")),{data:e.topic}))}),this.on(Qi.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Mu]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:n,sessionProperties:i}=e;r&&Object.keys(r).length&&(this.namespaces=r),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.persist("namespaces",r),this.persist("optionalNamespaces",n)}validateChain(e){const[r,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,n];if(r&&!Object.keys(this.namespaces||{}).map(o=>_l(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&n)return[r,n];const i=_l(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){if(!this.namespaces)return;const[n,i]=this.validateChain(e);i&&(r||this.getProvider(n).setDefaultChain(i),this.namespaces[n]?this.namespaces[n].defaultChain=i:this.namespaces[`${n}:${i}`]?this.namespaces[`${n}:${i}`].defaultChain=i:this.namespaces[`${n}:${i}`]={defaultChain:i},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,r){this.client.core.storage.setItem(`${F6}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${F6}/${e}`)}};const nz=Q6;function iz(){return new Promise(t=>{const e=[];let r;window.addEventListener("eip6963:announceProvider",n=>{const{detail:i}=n;r&&clearTimeout(r),e.push(i),r=setTimeout(()=>t(e),200)}),r=setTimeout(()=>t(e),200),window.dispatchEvent(new Event("eip6963:requestProvider"))})}class Gs{constructor(e,r){this.scope=e,this.module=r}storeObject(e,r){this.setItem(e,JSON.stringify(r))}loadObject(e){const r=this.getItem(e);return r?JSON.parse(r):void 0}setItem(e,r){localStorage.setItem(this.scopedKey(e),r)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),r=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new Gs("CBWSDK").clear(),new Gs("walletlink").clear()}}const cn={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}},T1={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},e5="Unspecified error message.",sz="Unspecified server error.";function R1(t,e=e5){if(t&&Number.isInteger(t)){const r=t.toString();if(D1(T1,r))return T1[r].message;if(t5(t))return sz}return e}function oz(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!(T1[e]||t5(t))}function az(t,{shouldIncludeStack:e=!1}={}){const r={};if(t&&typeof t=="object"&&!Array.isArray(t)&&D1(t,"code")&&oz(t.code)){const n=t;r.code=n.code,n.message&&typeof n.message=="string"?(r.message=n.message,D1(n,"data")&&(r.data=n.data)):(r.message=R1(r.code),r.data={originalError:r5(t)})}else r.code=cn.rpc.internal,r.message=n5(t,"message")?t.message:e5,r.data={originalError:r5(t)};return e&&(r.stack=n5(t,"stack")?t.stack:void 0),r}function t5(t){return t>=-32099&&t<=-32e3}function r5(t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.assign({},t):t}function D1(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function n5(t,e){return typeof t=="object"&&t!==null&&e in t&&typeof t[e]=="string"}const Sr={rpc:{parse:t=>es(cn.rpc.parse,t),invalidRequest:t=>es(cn.rpc.invalidRequest,t),invalidParams:t=>es(cn.rpc.invalidParams,t),methodNotFound:t=>es(cn.rpc.methodNotFound,t),internal:t=>es(cn.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return es(e,t)},invalidInput:t=>es(cn.rpc.invalidInput,t),resourceNotFound:t=>es(cn.rpc.resourceNotFound,t),resourceUnavailable:t=>es(cn.rpc.resourceUnavailable,t),transactionRejected:t=>es(cn.rpc.transactionRejected,t),methodNotSupported:t=>es(cn.rpc.methodNotSupported,t),limitExceeded:t=>es(cn.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>Iu(cn.provider.userRejectedRequest,t),unauthorized:t=>Iu(cn.provider.unauthorized,t),unsupportedMethod:t=>Iu(cn.provider.unsupportedMethod,t),disconnected:t=>Iu(cn.provider.disconnected,t),chainDisconnected:t=>Iu(cn.provider.chainDisconnected,t),unsupportedChain:t=>Iu(cn.provider.unsupportedChain,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:r,data:n}=t;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new o5(e,r,n)}}};function es(t,e){const[r,n]=i5(e);return new s5(t,r||R1(t),n)}function Iu(t,e){const[r,n]=i5(e);return new o5(t,r||R1(t),n)}function i5(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,r]}}return[]}class s5 extends Error{constructor(e,r,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string.');super(r),this.code=e,n!==void 0&&(this.data=n)}}class o5 extends s5{constructor(e,r,n){if(!cz(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,r,n)}}function cz(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}function O1(){return t=>t}const Dl=O1(),uz=O1(),fz=O1();function Io(t){return Math.floor(t)}const a5=/^[0-9]*$/,c5=/^[a-f0-9]*$/;function fc(t){return N1(crypto.getRandomValues(new Uint8Array(t)))}function N1(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function r0(t){return new Uint8Array(t.match(/.{1,2}/g).map(e=>Number.parseInt(e,16)))}function Ol(t,e=!1){const r=t.toString("hex");return Dl(e?`0x${r}`:r)}function L1(t){return Ol(B1(t),!0)}function Ys(t){return fz(t.toString(10))}function da(t){return Dl(`0x${BigInt(t).toString(16)}`)}function u5(t){return t.startsWith("0x")||t.startsWith("0X")}function k1(t){return u5(t)?t.slice(2):t}function f5(t){return u5(t)?`0x${t.slice(2)}`:`0x${t}`}function n0(t){if(typeof t!="string")return!1;const e=k1(t).toLowerCase();return c5.test(e)}function lz(t,e=!1){if(typeof t=="string"){const r=k1(t).toLowerCase();if(c5.test(r))return Dl(e?`0x${r}`:r)}throw Sr.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}function $1(t,e=!1){let r=lz(t,!1);return r.length%2===1&&(r=Dl(`0${r}`)),e?Dl(`0x${r}`):r}function pa(t){if(typeof t=="string"){const e=k1(t).toLowerCase();if(n0(e)&&e.length===40)return uz(f5(e))}throw Sr.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`)}function B1(t){if(Buffer.isBuffer(t))return t;if(typeof t=="string"){if(n0(t)){const e=$1(t,!1);return Buffer.from(e,"hex")}return Buffer.from(t,"utf8")}throw Sr.rpc.invalidParams(`Not binary data: ${String(t)}`)}function Nl(t){if(typeof t=="number"&&Number.isInteger(t))return Io(t);if(typeof t=="string"){if(a5.test(t))return Io(Number(t));if(n0(t))return Io(Number(BigInt($1(t,!0))))}throw Sr.rpc.invalidParams(`Not an integer: ${String(t)}`)}function Ll(t){if(t!==null&&(typeof t=="bigint"||dz(t)))return BigInt(t.toString(10));if(typeof t=="number")return BigInt(Nl(t));if(typeof t=="string"){if(a5.test(t))return BigInt(t);if(n0(t))return BigInt($1(t,!0))}throw Sr.rpc.invalidParams(`Not an integer: ${String(t)}`)}function hz(t){if(typeof t=="string")return JSON.parse(t);if(typeof t=="object")return t;throw Sr.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`)}function dz(t){if(t==null||typeof t.constructor!="function")return!1;const{constructor:e}=t;return typeof e.config=="function"&&typeof e.EUCLID=="number"}async function pz(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function gz(t,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function mz(t,e){const r=crypto.getRandomValues(new Uint8Array(12)),n=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},t,new TextEncoder().encode(e));return{iv:r,cipherText:n}}async function vz(t,{iv:e,cipherText:r}){const n=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},t,r);return new TextDecoder().decode(n)}function l5(t){switch(t){case"public":return"spki";case"private":return"pkcs8"}}async function h5(t,e){const r=l5(t),n=await crypto.subtle.exportKey(r,e);return N1(new Uint8Array(n))}async function d5(t,e){const r=l5(t),n=r0(e).buffer;return await crypto.subtle.importKey(r,new Uint8Array(n),{name:"ECDH",namedCurve:"P-256"},!0,t==="private"?["deriveKey"]:[])}async function bz(t,e){const r=JSON.stringify(t,(n,i)=>{if(!(i instanceof Error))return i;const s=i;return Object.assign(Object.assign({},s.code?{code:s.code}:{}),{message:s.message})});return mz(e,r)}async function yz(t,e){return JSON.parse(await vz(e,t))}const F1={storageKey:"ownPrivateKey",keyType:"private"},U1={storageKey:"ownPublicKey",keyType:"public"},j1={storageKey:"peerPublicKey",keyType:"public"};class wz{constructor(){this.storage=new Gs("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(e){this.sharedSecret=null,this.peerPublicKey=e,await this.storeKey(j1,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(U1.storageKey),this.storage.removeItem(F1.storageKey),this.storage.removeItem(j1.storageKey)}async generateKeyPair(){const e=await pz();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(F1,e.privateKey),await this.storeKey(U1,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(F1)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(U1)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(j1)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await gz(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const r=this.storage.getItem(e.storageKey);return r?d5(e.keyType,r):null}async storeKey(e,r){const n=await h5(e.keyType,r);this.storage.setItem(e.storageKey,n)}}const kl="4.2.4",p5="@coinbase/wallet-sdk";async function g5(t,e){const r=Object.assign(Object.assign({},t),{jsonrpc:"2.0",id:crypto.randomUUID()}),n=await window.fetch(e,{method:"POST",body:JSON.stringify(r),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":kl,"X-Cbw-Sdk-Platform":p5}}),{result:i,error:s}=await n.json();if(s)throw s;return i}function xz(){return globalThis.coinbaseWalletExtension}function _z(){var t,e;try{const r=globalThis;return(t=r.ethereum)!==null&&t!==void 0?t:(e=r.top)===null||e===void 0?void 0:e.ethereum}catch{return}}function Ez({metadata:t,preference:e}){var r,n;const{appName:i,appLogoUrl:s,appChainIds:o}=t;if(e.options!=="smartWalletOnly"){const u=xz();if(u)return(r=u.setAppInfo)===null||r===void 0||r.call(u,i,s,o,e),u}const a=_z();if(a!=null&&a.isCoinbaseBrowser)return(n=a.setAppInfo)===null||n===void 0||n.call(a,i,s,o,e),a}function Sz(t){if(!t||typeof t!="object"||Array.isArray(t))throw Sr.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:t});const{method:e,params:r}=t;if(typeof e!="string"||e.length===0)throw Sr.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:t});if(r!==void 0&&!Array.isArray(r)&&(typeof r!="object"||r===null))throw Sr.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:t});switch(e){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw Sr.provider.unsupportedMethod()}}const m5="accounts",v5="activeChain",b5="availableChains",y5="walletCapabilities";class Az{constructor(e){var r,n,i;this.metadata=e.metadata,this.communicator=e.communicator,this.callback=e.callback,this.keyManager=new wz,this.storage=new Gs("CBWSDK","SCWStateManager"),this.accounts=(r=this.storage.loadObject(m5))!==null&&r!==void 0?r:[],this.chain=this.storage.loadObject(v5)||{id:(i=(n=e.metadata.appChainIds)===null||n===void 0?void 0:n[0])!==null&&i!==void 0?i:1},this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(e){var r,n;const i=await this.createRequestMessage({handshake:{method:e.method,params:Object.assign({},this.metadata,(r=e.params)!==null&&r!==void 0?r:{})}}),s=await this.communicator.postRequestAndWaitForResponse(i);if("failure"in s.content)throw s.content.failure;const o=await d5("public",s.sender);await this.keyManager.setPeerPublicKey(o);const u=(await this.decryptResponseMessage(s)).result;if("error"in u)throw u.error;const l=u.value;this.accounts=l,this.storage.storeObject(m5,l),(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",l)}async request(e){var r;if(this.accounts.length===0)throw Sr.provider.unauthorized();switch(e.method){case"eth_requestAccounts":return(r=this.callback)===null||r===void 0||r.call(this,"connect",{chainId:da(this.chain.id)}),this.accounts;case"eth_accounts":return this.accounts;case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return da(this.chain.id);case"wallet_getCapabilities":return this.storage.loadObject(y5);case"wallet_switchEthereumChain":return this.handleSwitchChainRequest(e);case"eth_ecRecover":case"personal_sign":case"personal_ecRecover":case"eth_signTransaction":case"eth_sendTransaction":case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":case"wallet_addEthereumChain":case"wallet_watchAsset":case"wallet_sendCalls":case"wallet_showCallsStatus":case"wallet_grantPermissions":return this.sendRequestToPopup(e);default:if(!this.chain.rpcUrl)throw Sr.rpc.internal("No RPC URL set for chain");return g5(e,this.chain.rpcUrl)}}async sendRequestToPopup(e){var r,n;await((n=(r=this.communicator).waitForPopupLoaded)===null||n===void 0?void 0:n.call(r));const i=await this.sendEncryptedRequest(e),o=(await this.decryptResponseMessage(i)).result;if("error"in o)throw o.error;return o.value}async cleanup(){var e,r;this.storage.clear(),await this.keyManager.clear(),this.accounts=[],this.chain={id:(r=(e=this.metadata.appChainIds)===null||e===void 0?void 0:e[0])!==null&&r!==void 0?r:1}}async handleSwitchChainRequest(e){var r;const n=e.params;if(!n||!(!((r=n[0])===null||r===void 0)&&r.chainId))throw Sr.rpc.invalidParams();const i=Nl(n[0].chainId);if(this.updateChain(i))return null;const o=await this.sendRequestToPopup(e);return o===null&&this.updateChain(i),o}async sendEncryptedRequest(e){const r=await this.keyManager.getSharedSecret();if(!r)throw Sr.provider.unauthorized("No valid session found, try requestAccounts before other methods");const n=await bz({action:e,chainId:this.chain.id},r),i=await this.createRequestMessage({encrypted:n});return this.communicator.postRequestAndWaitForResponse(i)}async createRequestMessage(e){const r=await h5("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:r,content:e,timestamp:new Date}}async decryptResponseMessage(e){var r,n;const i=e.content;if("failure"in i)throw i.failure;const s=await this.keyManager.getSharedSecret();if(!s)throw Sr.provider.unauthorized("Invalid session");const o=await yz(i.encrypted,s),a=(r=o.data)===null||r===void 0?void 0:r.chains;if(a){const l=Object.entries(a).map(([d,g])=>({id:Number(d),rpcUrl:g}));this.storage.storeObject(b5,l),this.updateChain(this.chain.id,l)}const u=(n=o.data)===null||n===void 0?void 0:n.capabilities;return u&&this.storage.storeObject(y5,u),o}updateChain(e,r){var n;const i=r??this.storage.loadObject(b5),s=i==null?void 0:i.find(o=>o.id===e);return s?(s!==this.chain&&(this.chain=s,this.storage.storeObject(v5,s),(n=this.callback)===null||n===void 0||n.call(this,"chainChanged",da(s.id))),!0):!1}}const Pz=Jp(HP),{keccak_256:Mz}=Pz;function w5(t){return Buffer.allocUnsafe(t).fill(0)}function Iz(t){return t.toString(2).length}function x5(t,e){let r=t.toString(16);r.length%2!==0&&(r="0"+r);const n=r.match(/.{1,2}/g).map(i=>parseInt(i,16));for(;n.length"u")throw new Error("Not an array?");if(r=I5(t),r!=="dynamic"&&r!==0&&e.length>r)throw new Error("Elements exceed array size: "+r);i=[],t=t.slice(0,t.lastIndexOf("[")),typeof e=="string"&&(e=JSON.parse(e));for(s in e)i.push(Js(t,e[s]));if(r==="dynamic"){var o=Js("uint256",e.length);i.unshift(o)}return Buffer.concat(i)}else{if(t==="bytes")return e=new Buffer(e),i=Buffer.concat([Js("uint256",e.length),e]),e.length%32!==0&&(i=Buffer.concat([i,si.zeros(32-e.length%32)])),i;if(t.startsWith("bytes")){if(r=Cu(t),r<1||r>32)throw new Error("Invalid bytes width: "+r);return si.setLengthRight(e,32)}else if(t.startsWith("uint")){if(r=Cu(t),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);n=lc(e);const a=si.bitLengthFromBigInt(n);if(a>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+a);if(n<0)throw new Error("Supplied uint is negative");return si.bufferBEFromBigInt(n,32)}else if(t.startsWith("int")){if(r=Cu(t),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);n=lc(e);const a=si.bitLengthFromBigInt(n);if(a>r)throw new Error("Supplied int exceeds width: "+r+" vs "+a);const u=si.twosFromBigInt(n,256);return si.bufferBEFromBigInt(u,32)}else if(t.startsWith("ufixed")){if(r=M5(t),n=lc(e),n<0)throw new Error("Supplied ufixed is negative");return Js("uint256",n*BigInt(2)**BigInt(r[1]))}else if(t.startsWith("fixed"))return r=M5(t),Js("int256",lc(e)*BigInt(2)**BigInt(r[1]))}throw new Error("Unsupported or invalid type: "+t)}function Nz(t){return t==="string"||t==="bytes"||I5(t)==="dynamic"}function Lz(t){return t.lastIndexOf("]")===t.length-1}function kz(t,e){var r=[],n=[],i=32*t.length;for(var s in t){var o=P5(t[s]),a=e[s],u=Js(o,a);Nz(o)?(r.push(Js("uint256",i)),n.push(u),i+=u.length):r.push(u)}return Buffer.concat(r.concat(n))}function C5(t,e){if(t.length!==e.length)throw new Error("Number of types are not matching the values");for(var r,n,i=[],s=0;s32)throw new Error("Invalid bytes width: "+r);i.push(si.setLengthRight(a,r))}else if(o.startsWith("uint")){if(r=Cu(o),r%8||r<8||r>256)throw new Error("Invalid uint width: "+r);n=lc(a);const u=si.bitLengthFromBigInt(n);if(u>r)throw new Error("Supplied uint exceeds width: "+r+" vs "+u);i.push(si.bufferBEFromBigInt(n,r/8))}else if(o.startsWith("int")){if(r=Cu(o),r%8||r<8||r>256)throw new Error("Invalid int width: "+r);n=lc(a);const u=si.bitLengthFromBigInt(n);if(u>r)throw new Error("Supplied int exceeds width: "+r+" vs "+u);const l=si.twosFromBigInt(n,r);i.push(si.bufferBEFromBigInt(l,r/8))}else throw new Error("Unsupported or invalid type: "+o)}return Buffer.concat(i)}function $z(t,e){return si.keccak(C5(t,e))}var Bz={rawEncode:kz,solidityPack:C5,soliditySHA3:$z};const xs=A5,$l=Bz,T5={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},q1={encodeData(t,e,r,n=!0){const i=["bytes32"],s=[this.hashType(t,r)];if(n){const o=(a,u,l)=>{if(r[u]!==void 0)return["bytes32",l==null?"0x0000000000000000000000000000000000000000000000000000000000000000":xs.keccak(this.encodeData(u,l,r,n))];if(l===void 0)throw new Error(`missing value for field ${a} of type ${u}`);if(u==="bytes")return["bytes32",xs.keccak(l)];if(u==="string")return typeof l=="string"&&(l=Buffer.from(l,"utf8")),["bytes32",xs.keccak(l)];if(u.lastIndexOf("]")===u.length-1){const d=u.slice(0,u.lastIndexOf("[")),g=l.map(y=>o(a,d,y));return["bytes32",xs.keccak($l.rawEncode(g.map(([y])=>y),g.map(([,y])=>y)))]}return[u,l]};for(const a of r[t]){const[u,l]=o(a.name,a.type,e[a.name]);i.push(u),s.push(l)}}else for(const o of r[t]){let a=e[o.name];if(a!==void 0)if(o.type==="bytes")i.push("bytes32"),a=xs.keccak(a),s.push(a);else if(o.type==="string")i.push("bytes32"),typeof a=="string"&&(a=Buffer.from(a,"utf8")),a=xs.keccak(a),s.push(a);else if(r[o.type]!==void 0)i.push("bytes32"),a=xs.keccak(this.encodeData(o.type,a,r,n)),s.push(a);else{if(o.type.lastIndexOf("]")===o.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");i.push(o.type),s.push(a)}}return $l.rawEncode(i,s)},encodeType(t,e){let r="",n=this.findTypeDependencies(t,e).filter(i=>i!==t);n=[t].concat(n.sort());for(const i of n){if(!e[i])throw new Error("No type definition specified: "+i);r+=i+"("+e[i].map(({name:o,type:a})=>a+" "+o).join(",")+")"}return r},findTypeDependencies(t,e,r=[]){if(t=t.match(/^\w*/)[0],r.includes(t)||e[t]===void 0)return r;r.push(t);for(const n of e[t])for(const i of this.findTypeDependencies(n.type,e,r))!r.includes(i)&&r.push(i);return r},hashStruct(t,e,r,n=!0){return xs.keccak(this.encodeData(t,e,r,n))},hashType(t,e){return xs.keccak(this.encodeType(t,e))},sanitizeData(t){const e={};for(const r in T5.properties)t[r]&&(e[r]=t[r]);return e.types&&(e.types=Object.assign({EIP712Domain:[]},e.types)),e},hash(t,e=!0){const r=this.sanitizeData(t),n=[Buffer.from("1901","hex")];return n.push(this.hashStruct("EIP712Domain",r.domain,r.types,e)),r.primaryType!=="EIP712Domain"&&n.push(this.hashStruct(r.primaryType,r.message,r.types,e)),xs.keccak(Buffer.concat(n))}};var Fz={TYPED_MESSAGE_SCHEMA:T5,TypedDataUtils:q1,hashForSignTypedDataLegacy:function(t){return Uz(t.data)},hashForSignTypedData_v3:function(t){return q1.hash(t.data,!1)},hashForSignTypedData_v4:function(t){return q1.hash(t.data)}};function Uz(t){const e=new Error("Expect argument to be non-empty array");if(typeof t!="object"||!t.length)throw e;const r=t.map(function(s){return s.type==="bytes"?xs.toBuffer(s.value):s.value}),n=t.map(function(s){return s.type}),i=t.map(function(s){if(!s.name)throw e;return s.type+" "+s.name});return $l.soliditySHA3(["bytes32","bytes32"],[$l.soliditySHA3(new Array(t.length).fill("string"),i),$l.soliditySHA3(n,r)])}const s0=Ui(Fz),jz="walletUsername",z1="Addresses",qz="AppVersion";function zn(t){return t.errorMessage!==void 0}class zz{constructor(e){this.secret=e}async encrypt(e){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",r0(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=new TextEncoder,o=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,s.encode(e)),a=16,u=o.slice(o.byteLength-a),l=o.slice(0,o.byteLength-a),d=new Uint8Array(u),g=new Uint8Array(l),y=new Uint8Array([...n,...d,...g]);return N1(y)}async decrypt(e){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");return new Promise((n,i)=>{(async function(){const s=await crypto.subtle.importKey("raw",r0(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),o=r0(e),a=o.slice(0,12),u=o.slice(12,28),l=o.slice(28),d=new Uint8Array([...l,...u]),g={name:"AES-GCM",iv:new Uint8Array(a)};try{const y=await window.crypto.subtle.decrypt(g,s,d),A=new TextDecoder;n(A.decode(y))}catch(y){i(y)}})()})}}class Hz{constructor(e,r,n){this.linkAPIUrl=e,this.sessionId=r;const i=`${r}:${n}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(r=>fetch(`${this.linkAPIUrl}/events/${r.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(r=>console.error("Unabled to mark event as failed:",r))}async fetchUnseenEvents(){var e;const r=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(r.ok){const{events:n,error:i}=await r.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const s=(e=n==null?void 0:n.filter(o=>o.event==="Web3Response").map(o=>({type:"Event",sessionId:this.sessionId,eventId:o.id,event:o.event,data:o.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(s),s}throw new Error(`Check unseen events failed: ${r.status}`)}}var Co;(function(t){t[t.DISCONNECTED=0]="DISCONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED"})(Co||(Co={}));class Wz{setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,r=WebSocket){this.WebSocketClass=r,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,r)=>{var n;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(s){r(s);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,Co.CONNECTING),i.onclose=s=>{var o;this.clearWebSocket(),r(new Error(`websocket error ${s.code}: ${s.reason}`)),(o=this.connectionStateListener)===null||o===void 0||o.call(this,Co.DISCONNECTED)},i.onopen=s=>{var o;e(),(o=this.connectionStateListener)===null||o===void 0||o.call(this,Co.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(u=>this.sendData(u)),this.pendingData=[])},i.onmessage=s=>{var o,a;if(s.data==="h")(o=this.incomingDataListener)===null||o===void 0||o.call(this,{type:"Heartbeat"});else try{const u=JSON.parse(s.data);(a=this.incomingDataListener)===null||a===void 0||a.call(this,u)}catch{}}})}disconnect(){var e;const{webSocket:r}=this;if(r){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,Co.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{r.close()}catch{}}}sendData(e){const{webSocket:r}=this;if(!r){this.pendingData.push(e),this.connect();return}r.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}const R5=1e4,Kz=6e4;class Vz{constructor({session:e,linkAPIUrl:r,listener:n}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=Io(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=s=>{if(!s)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",a=>s.JsonRpcUrl&&this.handleChainUpdated(a,s.JsonRpcUrl)]]).forEach((a,u)=>{const l=s[u];l!==void 0&&a(l)})},this.handleDestroyed=s=>{var o;s==="1"&&((o=this.listener)===null||o===void 0||o.resetAndReload())},this.handleAccountUpdated=async s=>{var o;const a=await this.cipher.decrypt(s);(o=this.listener)===null||o===void 0||o.accountUpdated(a)},this.handleMetadataUpdated=async(s,o)=>{var a;const u=await this.cipher.decrypt(o);(a=this.listener)===null||a===void 0||a.metadataUpdated(s,u)},this.handleWalletUsernameUpdated=async s=>{this.handleMetadataUpdated(jz,s)},this.handleAppVersionUpdated=async s=>{this.handleMetadataUpdated(qz,s)},this.handleChainUpdated=async(s,o)=>{var a;const u=await this.cipher.decrypt(s),l=await this.cipher.decrypt(o);(a=this.listener)===null||a===void 0||a.chainUpdated(u,l)},this.session=e,this.cipher=new zz(e.secret),this.listener=n;const i=new Wz(`${r}/rpc`,WebSocket);i.setConnectionStateListener(async s=>{let o=!1;switch(s){case Co.DISCONNECTED:if(!this.destroyed){const a=async()=>{await new Promise(u=>setTimeout(u,5e3)),this.destroyed||i.connect().catch(()=>{a()})};a()}break;case Co.CONNECTED:o=await this.handleConnected(),this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},R5),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case Co.CONNECTING:break}this.connected!==o&&(this.connected=o)}),i.setIncomingDataListener(s=>{var o;switch(s.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const a=s.type==="IsLinkedOK"?s.linked:void 0;this.linked=a||s.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(s.metadata);break}case"Event":{this.handleIncomingEvent(s);break}}s.id!==void 0&&((o=this.requestResolutions.get(s.id))===null||o===void 0||o(s))}),this.ws=i,this.http=new Hz(r,e.id,e.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:Io(this.nextReqId++),sessionId:this.session.id,metadata:{__destroyed:"1"}},{timeout:1e3}),this.destroyed=!0,this.ws.disconnect(),this.listener=void 0)}get connected(){return this._connected}set connected(e){this._connected=e}get linked(){return this._linked}set linked(e){var r,n;this._linked=e,e&&((r=this.onceLinked)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(e)}setOnceLinked(e){return new Promise(r=>{this.linked?e().then(r):this.onceLinked=()=>{e().then(r),this.onceLinked=void 0}})}async handleIncomingEvent(e){var r;if(e.type!=="Event"||e.event!=="Web3Response")return;const n=await this.cipher.decrypt(e.data),i=JSON.parse(n);if(i.type!=="WEB3_RESPONSE")return;const{id:s,response:o}=i;(r=this.listener)===null||r===void 0||r.handleWeb3ResponseMessage(s,o)}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(r=>this.handleIncomingEvent(r))}async publishEvent(e,r,n=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},r),{origin:location.origin,location:location.href,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),s={type:"PublishEvent",id:Io(this.nextReqId++),sessionId:this.session.id,event:e,data:i,callWebhook:n};return this.setOnceLinked(async()=>{const o=await this.makeRequest(s);if(o.type==="Fail")throw new Error(o.error||"failed to publish event");return o.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>R5*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,r={timeout:Kz}){const n=e.id;this.sendData(e);let i;return Promise.race([new Promise((s,o)=>{i=window.setTimeout(()=>{o(new Error(`request ${n} timed out`))},r.timeout)}),new Promise(s=>{this.requestResolutions.set(n,o=>{clearTimeout(i),s(o),this.requestResolutions.delete(n)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:Io(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:Io(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:Io(this.nextReqId++),sessionId:this.session.id}),!0)}}class Gz{constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,r=f5(e.toString(16));return this.callbacks.get(r)&&this.callbacks.delete(r),e}}const D5="session:id",O5="session:secret",N5="session:linked";class Tu{constructor(e,r,n,i=!1){this.storage=e,this.id=r,this.secret=n,this.key=EP(Ag(`${r}, ${n} WalletLink`)),this._linked=!!i}static create(e){const r=fc(16),n=fc(32);return new Tu(e,r,n).save()}static load(e){const r=e.getItem(D5),n=e.getItem(N5),i=e.getItem(O5);return r&&i?new Tu(e,r,i,n==="1"):null}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this.storage.setItem(D5,this.id),this.storage.setItem(O5,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(N5,this._linked?"1":"0")}}function Yz(){try{return window.frameElement!==null}catch{return!1}}function Jz(){try{return Yz()&&window.top?window.top.location:window.location}catch{return window.location}}function Xz(){var t;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t=window==null?void 0:window.navigator)===null||t===void 0?void 0:t.userAgent)}function L5(){var t,e;return(e=(t=window==null?void 0:window.matchMedia)===null||t===void 0?void 0:t.call(window,"(prefers-color-scheme: dark)").matches)!==null&&e!==void 0?e:!1}const Zz='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';function k5(){const t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode(Zz)),document.documentElement.appendChild(t)}function $5(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t))for(e=0;e2&&(o.children=arguments.length>3?o0.call(arguments,2):r),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)o[s]===void 0&&(o[s]=t.defaultProps[s]);return a0(t,o,n,i,null)}function a0(t,e,r,n,i){var s={type:t,props:e,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++B5,__i:-1,__u:0};return i==null&&Vr.vnode!=null&&Vr.vnode(s),s}function Ul(t){return t.children}function c0(t,e){this.props=t,this.context=e}function Ru(t,e){if(e==null)return t.__?Ru(t.__,t.__i+1):null;for(var r;ee&&hc.sort(H1));u0.__r=0}function W5(t,e,r,n,i,s,o,a,u,l,d){var g,y,A,P,N,D,k=n&&n.__k||q5,$=e.length;for(u=eH(r,e,k,u),g=0;g<$;g++)(A=r.__k[g])!=null&&(y=A.__i===-1?Fl:k[A.__i]||Fl,A.__i=g,D=J1(t,A,y,i,s,o,a,u,l,d),P=A.__e,A.ref&&y.ref!=A.ref&&(y.ref&&X1(y.ref,null,A),d.push(A.ref,A.__c||P,A)),N==null&&P!=null&&(N=P),4&A.__u||y.__k===A.__k?u=K5(A,u,t):typeof A.type=="function"&&D!==void 0?u=D:P&&(u=P.nextSibling),A.__u&=-7);return r.__e=N,u}function eH(t,e,r,n){var i,s,o,a,u,l=e.length,d=r.length,g=d,y=0;for(t.__k=[],i=0;i0?a0(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=t,s.__b=t.__b+1,o=null,(u=s.__i=tH(s,r,a,g))!==-1&&(g--,(o=r[u])&&(o.__u|=2)),o==null||o.__v===null?(u==-1&&y--,typeof s.type!="function"&&(s.__u|=4)):u!==a&&(u==a-1?y--:u==a+1?y++:(u>a?y--:y++,s.__u|=4))):s=t.__k[i]=null;if(g)for(i=0;i(u!=null&&!(2&u.__u)?1:0))for(;o>=0||a=0){if((u=e[o])&&!(2&u.__u)&&i==u.key&&s===u.type)return o;o--}if(a=r.__.length&&r.__.push({}),r.__[t]}function o4(t){return ev=1,iH(c4,t)}function iH(t,e,r){var n=s4(l0++,2);if(n.t=t,!n.__c&&(n.__=[c4(void 0,e),function(a){var u=n.__N?n.__N[0]:n.__[0],l=n.t(u,a);u!==l&&(n.__N=[l,n.__[1]],n.__c.setState({}))}],n.__c=un,!un.u)){var i=function(a,u,l){if(!n.__c.__H)return!0;var d=n.__c.__H.__.filter(function(y){return!!y.__c});if(d.every(function(y){return!y.__N}))return!s||s.call(this,a,u,l);var g=n.__c.props!==a;return d.forEach(function(y){if(y.__N){var A=y.__[0];y.__=y.__N,y.__N=void 0,A!==y.__[0]&&(g=!0)}}),s&&s.call(this,a,u,l)||g};un.u=!0;var s=un.shouldComponentUpdate,o=un.componentWillUpdate;un.componentWillUpdate=function(a,u,l){if(this.__e){var d=s;s=void 0,i(a,u,l),s=d}o&&o.call(this,a,u,l)},un.shouldComponentUpdate=i}return n.__N||n.__}function sH(t,e){var r=s4(l0++,3);!yn.__s&&cH(r.__H,e)&&(r.__=t,r.i=e,un.__H.__h.push(r))}function oH(){for(var t;t=Z5.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(h0),t.__H.__h.forEach(tv),t.__H.__h=[]}catch(e){t.__H.__h=[],yn.__e(e,t.__v)}}yn.__b=function(t){un=null,Q5&&Q5(t)},yn.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),i4&&i4(t,e)},yn.__r=function(t){e4&&e4(t),l0=0;var e=(un=t.__c).__H;e&&(Q1===un?(e.__h=[],un.__h=[],e.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(e.__h.forEach(h0),e.__h.forEach(tv),e.__h=[],l0=0)),Q1=un},yn.diffed=function(t){t4&&t4(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Z5.push(e)!==1&&X5===yn.requestAnimationFrame||((X5=yn.requestAnimationFrame)||aH)(oH)),e.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),Q1=un=null},yn.__c=function(t,e){e.some(function(r){try{r.__h.forEach(h0),r.__h=r.__h.filter(function(n){return!n.__||tv(n)})}catch(n){e.some(function(i){i.__h&&(i.__h=[])}),e=[],yn.__e(n,r.__v)}}),r4&&r4(t,e)},yn.unmount=function(t){n4&&n4(t);var e,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{h0(n)}catch(i){e=i}}),r.__H=void 0,e&&yn.__e(e,r.__v))};var a4=typeof requestAnimationFrame=="function";function aH(t){var e,r=function(){clearTimeout(n),a4&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(r,100);a4&&(e=requestAnimationFrame(r))}function h0(t){var e=un,r=t.__c;typeof r=="function"&&(t.__c=void 0,r()),un=e}function tv(t){var e=un;t.__c=t.__(),un=e}function cH(t,e){return!t||t.length!==e.length||e.some(function(r,n){return r!==t[n]})}function c4(t,e){return typeof e=="function"?e(t):e}const uH=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}",fH="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",lH="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class hH{constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=L5()}attach(e){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",e.appendChild(this.root),this.render()}presentItem(e){const r=this.nextItemKey++;return this.items.set(r,e),this.render(),()=>{this.items.delete(r),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&Z1(Or("div",null,Or(u4,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([e,r])=>Or(dH,Object.assign({},r,{key:e}))))),this.root)}}const u4=t=>Or("div",{class:Bl("-cbwsdk-snackbar-container")},Or("style",null,uH),Or("div",{class:"-cbwsdk-snackbar"},t.children)),dH=({autoExpand:t,message:e,menuItems:r})=>{const[n,i]=o4(!0),[s,o]=o4(t??!1);sH(()=>{const u=[window.setTimeout(()=>{i(!1)},1),window.setTimeout(()=>{o(!0)},1e4)];return()=>{u.forEach(window.clearTimeout)}});const a=()=>{o(!s)};return Or("div",{class:Bl("-cbwsdk-snackbar-instance",n&&"-cbwsdk-snackbar-instance-hidden",s&&"-cbwsdk-snackbar-instance-expanded")},Or("div",{class:"-cbwsdk-snackbar-instance-header",onClick:a},Or("img",{src:fH,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",Or("div",{class:"-cbwsdk-snackbar-instance-header-message"},e),Or("div",{class:"-gear-container"},!s&&Or("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Or("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),Or("img",{src:lH,class:"-gear-icon",title:"Expand"}))),r&&r.length>0&&Or("div",{class:"-cbwsdk-snackbar-instance-menu"},r.map((u,l)=>Or("div",{class:Bl("-cbwsdk-snackbar-instance-menu-item",u.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:u.onClick,key:l},Or("svg",{width:u.svgWidth,height:u.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Or("path",{"fill-rule":u.defaultFillRule,"clip-rule":u.defaultClipRule,d:u.path,fill:"#AAAAAA"})),Or("span",{class:Bl("-cbwsdk-snackbar-instance-menu-item-info",u.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},u.info)))))};class pH{constructor(){this.attached=!1,this.snackbar=new hH}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,r=document.createElement("div");r.className="-cbwsdk-css-reset",e.appendChild(r),this.snackbar.attach(r),this.attached=!0,k5()}showConnecting(e){let r;return e.isUnlinkedErrorState?r={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:r={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(r)}}const gH=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";class mH{constructor(){this.root=null,this.darkMode=L5()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),k5()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&(Z1(null,this.root),e&&Z1(Or(vH,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const vH=({title:t,buttonText:e,darkMode:r,onButtonClick:n,onDismiss:i})=>{const s=r?"dark":"light";return Or(u4,{darkMode:r},Or("div",{class:"-cbwsdk-redirect-dialog"},Or("style",null,gH),Or("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),Or("div",{class:Bl("-cbwsdk-redirect-dialog-box",s)},Or("p",null,t),Or("button",{onClick:n},e))))},bH="https://keys.coinbase.com/connect",f4="https://www.walletlink.org",yH="https://go.cb-w.com/walletlink";class l4{constructor(){this.attached=!1,this.redirectDialog=new mH}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(e){const r=new URL(yH);r.searchParams.append("redirect_url",Jz().href),e&&r.searchParams.append("wl_url",e);const n=document.createElement("a");n.target="cbw-opener",n.href=r.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}class To{constructor(e){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=Xz(),this.linkedUpdated=s=>{this.isLinked=s;const o=this.storage.getItem(z1);if(s&&(this._session.linked=s),this.isUnlinkedErrorState=!1,o){const a=o.split(" "),u=this.storage.getItem("IsStandaloneSigning")==="true";a[0]!==""&&!s&&this._session.linked&&!u&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(s,o)=>{this.storage.setItem(s,o)},this.chainUpdated=(s,o)=>{this.chainCallbackParams.chainId===s&&this.chainCallbackParams.jsonRpcUrl===o||(this.chainCallbackParams={chainId:s,jsonRpcUrl:o},this.chainCallback&&this.chainCallback(o,Number.parseInt(s,10)))},this.accountUpdated=s=>{this.accountsCallback&&this.accountsCallback([s]),To.accountRequestCallbackIds.size>0&&(Array.from(To.accountRequestCallbackIds.values()).forEach(o=>{this.invokeCallback(o,{method:"requestEthereumAccounts",result:[s]})}),To.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage,this.metadata=e.metadata,this.accountsCallback=e.accountsCallback,this.chainCallback=e.chainCallback;const{session:r,ui:n,connection:i}=this.subscribe();this._session=r,this.connection=i,this.relayEventManager=new Gz,this.ui=n,this.ui.attach()}subscribe(){const e=Tu.load(this.storage)||Tu.create(this.storage),{linkAPIUrl:r}=this,n=new Vz({session:e,linkAPIUrl:r,listener:this}),i=this.isMobileWeb?new l4:new pH;return n.connect(),{session:e,ui:i,connection:n}}resetAndReload(){this.connection.destroy().then(()=>{const e=Tu.load(this.storage);(e==null?void 0:e.id)===this._session.id&&Gs.clearAll(),document.location.reload()}).catch(e=>{})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:Ys(e.weiValue),data:Ol(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?Ys(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?Ys(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?Ys(e.gasPriceInWei):null,gasLimit:e.gasLimit?Ys(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:Ys(e.weiValue),data:Ol(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?Ys(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?Ys(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?Ys(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?Ys(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,r){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:Ol(e,!0),chainId:r}})}getWalletLinkSession(){return this._session}sendRequest(e){let r=null;const n=fc(8),i=s=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,e.method,s),r==null||r()};return new Promise((s,o)=>{r=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(n,a=>{if(r==null||r(),zn(a))return o(new Error(a.errorMessage));s(a)}),this.publishWeb3RequestEvent(n,e)})}publishWeb3RequestEvent(e,r){const n={type:"WEB3_REQUEST",id:e,request:r};this.publishEvent("Web3Request",n,!0).then(i=>{}).catch(i=>{this.handleWeb3ResponseMessage(n.id,{method:r.method,errorMessage:i.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(r.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof l4)switch(e){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(e){const r={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",r,!1).then()}publishEvent(e,r,n){return this.connection.publishEvent(e,r,n)}handleWeb3ResponseMessage(e,r){if(r.method==="requestEthereumAccounts"){To.accountRequestCallbackIds.forEach(n=>this.invokeCallback(n,r)),To.accountRequestCallbackIds.clear();return}this.invokeCallback(e,r)}handleErrorResponse(e,r,n){var i;const s=(i=n==null?void 0:n.message)!==null&&i!==void 0?i:"Unspecified error message.";this.handleWeb3ResponseMessage(e,{method:r,errorMessage:s})}invokeCallback(e,r){const n=this.relayEventManager.callbacks.get(e);n&&(n(r),this.relayEventManager.callbacks.delete(e))}requestEthereumAccounts(){const{appName:e,appLogoUrl:r}=this.metadata,n={method:"requestEthereumAccounts",params:{appName:e,appLogoUrl:r}},i=fc(8);return new Promise((s,o)=>{this.relayEventManager.callbacks.set(i,a=>{if(zn(a))return o(new Error(a.errorMessage));s(a)}),To.accountRequestCallbackIds.add(i),this.publishWeb3RequestEvent(i,n)})}watchAsset(e,r,n,i,s,o){const a={method:"watchAsset",params:{type:e,options:{address:r,symbol:n,decimals:i,image:s},chainId:o}};let u=null;const l=fc(8),d=g=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,a.method,g),u==null||u()};return u=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:d,onResetConnection:this.resetAndReload}),new Promise((g,y)=>{this.relayEventManager.callbacks.set(l,A=>{if(u==null||u(),zn(A))return y(new Error(A.errorMessage));g(A)}),this.publishWeb3RequestEvent(l,a)})}addEthereumChain(e,r,n,i,s,o){const a={method:"addEthereumChain",params:{chainId:e,rpcUrls:r,blockExplorerUrls:i,chainName:s,iconUrls:n,nativeCurrency:o}};let u=null;const l=fc(8),d=g=>{this.publishWeb3RequestCanceledEvent(l),this.handleErrorResponse(l,a.method,g),u==null||u()};return u=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:d,onResetConnection:this.resetAndReload}),new Promise((g,y)=>{this.relayEventManager.callbacks.set(l,A=>{if(u==null||u(),zn(A))return y(new Error(A.errorMessage));g(A)}),this.publishWeb3RequestEvent(l,a)})}switchEthereumChain(e,r){const n={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:r})};let i=null;const s=fc(8),o=a=>{this.publishWeb3RequestCanceledEvent(s),this.handleErrorResponse(s,n.method,a),i==null||i()};return i=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:o,onResetConnection:this.resetAndReload}),new Promise((a,u)=>{this.relayEventManager.callbacks.set(s,l=>{if(i==null||i(),zn(l)&&l.errorCode)return u(Sr.provider.custom({code:l.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(zn(l))return u(new Error(l.errorMessage));a(l)}),this.publishWeb3RequestEvent(s,n)})}}To.accountRequestCallbackIds=new Set;const h4="DefaultChainId",d4="DefaultJsonRpcUrl";class p4{constructor(e){this._relay=null,this._addresses=[],this.metadata=e.metadata,this._storage=new Gs("walletlink",f4),this.callback=e.callback||null;const r=this._storage.getItem(z1);if(r){const n=r.split(" ");n[0]!==""&&(this._addresses=n.map(i=>pa(i)))}this.initializeRelay()}getSession(){const e=this.initializeRelay(),{id:r,secret:n}=e.getWalletLinkSession();return{id:r,secret:n}}async handshake(){await this._eth_requestAccounts()}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(d4))!==null&&e!==void 0?e:void 0}set jsonRpcUrl(e){this._storage.setItem(d4,e)}updateProviderInfo(e,r){var n;this.jsonRpcUrl=e;const i=this.getChainId();this._storage.setItem(h4,r.toString(10)),Nl(r)!==i&&((n=this.callback)===null||n===void 0||n.call(this,"chainChanged",da(r)))}async watchAsset(e){const r=Array.isArray(e)?e[0]:e;if(!r.type)throw Sr.rpc.invalidParams("Type is required");if((r==null?void 0:r.type)!=="ERC20")throw Sr.rpc.invalidParams(`Asset of type '${r.type}' is not supported`);if(!(r!=null&&r.options))throw Sr.rpc.invalidParams("Options are required");if(!(r!=null&&r.options.address))throw Sr.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:i,symbol:s,image:o,decimals:a}=r.options,l=await this.initializeRelay().watchAsset(r.type,i,s,a,o,n==null?void 0:n.toString());return zn(l)?!1:!!l.result}async addEthereumChain(e){var r,n;const i=e[0];if(((r=i.rpcUrls)===null||r===void 0?void 0:r.length)===0)throw Sr.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!i.chainName||i.chainName.trim()==="")throw Sr.rpc.invalidParams("chainName is a required field");if(!i.nativeCurrency)throw Sr.rpc.invalidParams("nativeCurrency is a required field");const s=Number.parseInt(i.chainId,16);if(s===this.getChainId())return!1;const o=this.initializeRelay(),{rpcUrls:a=[],blockExplorerUrls:u=[],chainName:l,iconUrls:d=[],nativeCurrency:g}=i,y=await o.addEthereumChain(s.toString(),a,d,u,l,g);if(zn(y))return!1;if(((n=y.result)===null||n===void 0?void 0:n.isApproved)===!0)return this.updateProviderInfo(a[0],s),null;throw Sr.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(e){const r=e[0],n=Number.parseInt(r.chainId,16),s=await this.initializeRelay().switchEthereumChain(n.toString(10),this.selectedAddress||void 0);if(zn(s))throw s;const o=s.result;return o.isApproved&&o.rpcUrl.length>0&&this.updateProviderInfo(o.rpcUrl,n),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(e,r){var n;if(!Array.isArray(e))throw new Error("addresses is not an array");const i=e.map(s=>pa(s));JSON.stringify(i)!==JSON.stringify(this._addresses)&&(this._addresses=i,(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",i),this._storage.setItem(z1,i.join(" ")))}async request(e){const r=e.params||[];switch(e.method){case"eth_accounts":return[...this._addresses];case"eth_coinbase":return this.selectedAddress||null;case"net_version":return this.getChainId().toString(10);case"eth_chainId":return da(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(e);case"personal_sign":return this.personalSign(e);case"eth_signTransaction":return this._eth_signTransaction(r);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(r);case"eth_sendTransaction":return this._eth_sendTransaction(r);case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":return this.signTypedData(e);case"wallet_addEthereumChain":return this.addEthereumChain(r);case"wallet_switchEthereumChain":return this.switchEthereumChain(r);case"wallet_watchAsset":return this.watchAsset(r);default:if(!this.jsonRpcUrl)throw Sr.rpc.internal("No RPC URL set for chain");return g5(e,this.jsonRpcUrl)}}_ensureKnownAddress(e){const r=pa(e);if(!this._addresses.map(i=>pa(i)).includes(r))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const r=e.from?pa(e.from):this.selectedAddress;if(!r)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(r);const n=e.to?pa(e.to):null,i=e.value!=null?Ll(e.value):BigInt(0),s=e.data?B1(e.data):Buffer.alloc(0),o=e.nonce!=null?Nl(e.nonce):null,a=e.gasPrice!=null?Ll(e.gasPrice):null,u=e.maxFeePerGas!=null?Ll(e.maxFeePerGas):null,l=e.maxPriorityFeePerGas!=null?Ll(e.maxPriorityFeePerGas):null,d=e.gas!=null?Ll(e.gas):null,g=e.chainId?Nl(e.chainId):this.getChainId();return{fromAddress:r,toAddress:n,weiValue:i,data:s,nonce:o,gasPriceInWei:a,maxFeePerGas:u,maxPriorityFeePerGas:l,gasLimit:d,chainId:g}}async ecRecover(e){const{method:r,params:n}=e;if(!Array.isArray(n))throw Sr.rpc.invalidParams();const s=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:L1(n[0]),signature:L1(n[1]),addPrefix:r==="personal_ecRecover"}});if(zn(s))throw s;return s.result}getChainId(){var e;return Number.parseInt((e=this._storage.getItem(h4))!==null&&e!==void 0?e:"1",10)}async _eth_requestAccounts(){var e,r;if(this._addresses.length>0)return(e=this.callback)===null||e===void 0||e.call(this,"connect",{chainId:da(this.getChainId())}),this._addresses;const i=await this.initializeRelay().requestEthereumAccounts();if(zn(i))throw i;if(!i.result)throw new Error("accounts received is empty");return this._setAddresses(i.result),(r=this.callback)===null||r===void 0||r.call(this,"connect",{chainId:da(this.getChainId())}),this._addresses}async personalSign({params:e}){if(!Array.isArray(e))throw Sr.rpc.invalidParams();const r=e[1],n=e[0];this._ensureKnownAddress(r);const s=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:pa(r),message:L1(n),addPrefix:!0,typedDataJson:null}});if(zn(s))throw s;return s.result}async _eth_signTransaction(e){const r=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signEthereumTransaction(r);if(zn(i))throw i;return i.result}async _eth_sendRawTransaction(e){const r=B1(e[0]),i=await this.initializeRelay().submitEthereumTransaction(r,this.getChainId());if(zn(i))throw i;return i.result}async _eth_sendTransaction(e){const r=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signAndSubmitEthereumTransaction(r);if(zn(i))throw i;return i.result}async signTypedData(e){const{method:r,params:n}=e;if(!Array.isArray(n))throw Sr.rpc.invalidParams();const i=l=>{const d={eth_signTypedData_v1:s0.hashForSignTypedDataLegacy,eth_signTypedData_v3:s0.hashForSignTypedData_v3,eth_signTypedData_v4:s0.hashForSignTypedData_v4,eth_signTypedData:s0.hashForSignTypedData_v4};return Ol(d[r]({data:hz(l)}),!0)},s=n[r==="eth_signTypedData_v1"?1:0],o=n[r==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(s);const u=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:pa(s),message:i(o),typedDataJson:JSON.stringify(o,null,2),addPrefix:!1}});if(zn(u))throw u;return u.result}initializeRelay(){return this._relay||(this._relay=new To({linkAPIUrl:f4,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const g4="SignerType",m4=new Gs("CBWSDK","SignerConfigurator");function wH(){return m4.getItem(g4)}function xH(t){m4.setItem(g4,t)}async function _H(t){const{communicator:e,metadata:r,handshakeRequest:n,callback:i}=t;SH(e,r,i).catch(()=>{});const s={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},t.preference),{handshakeRequest:n})},{data:o}=await e.postRequestAndWaitForResponse(s);return o}function EH(t){const{signerType:e,metadata:r,communicator:n,callback:i}=t;switch(e){case"scw":return new Az({metadata:r,callback:i,communicator:n});case"walletlink":return new p4({metadata:r,callback:i})}}async function SH(t,e,r){await t.onMessage(({event:i})=>i==="WalletLinkSessionRequest");const n=new p4({metadata:e,callback:r});t.postMessage({event:"WalletLinkUpdate",data:{session:n.getSession()}}),await n.handshake(),t.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}const AH=`Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app. +`)+Xe+`return __p +}`;var fr=_A(function(){return Ir(ae,Nt+"return "+Xe).apply(r,pe)});if(fr.source=Xe,Kb(fr))throw fr;return fr}function Are(c){return Cr(c).toLowerCase()}function Pre(c){return Cr(c).toUpperCase()}function Ire(c,d,P){if(c=Cr(c),c&&(P||d===r))return T7(c);if(!c||!(d=Ei(d)))return c;var U=ps(c),Y=ps(d),ae=D7(U,Y),pe=O7(U,Y)+1;return ra(U,ae,pe).join("")}function Mre(c,d,P){if(c=Cr(c),c&&(P||d===r))return c.slice(0,L7(c)+1);if(!c||!(d=Ei(d)))return c;var U=ps(c),Y=O7(U,ps(d))+1;return ra(U,0,Y).join("")}function Cre(c,d,P){if(c=Cr(c),c&&(P||d===r))return c.replace(K,"");if(!c||!(d=Ei(d)))return c;var U=ps(c),Y=D7(U,ps(d));return ra(U,Y).join("")}function Rre(c,d){var P=X,U=q;if(Qr(d)){var Y="separator"in d?d.separator:Y;P="length"in d?ur(d.length):P,U="omission"in d?Ei(d.omission):U}c=Cr(c);var ae=c.length;if(tu(c)){var pe=ps(c);ae=pe.length}if(P>=ae)return c;var ve=P-ru(U);if(ve<1)return U;var xe=pe?ra(pe,0,ve).join(""):c.slice(0,ve);if(Y===r)return xe+U;if(pe&&(ve+=xe.length-ve),Vb(Y)){if(c.slice(ve).search(Y)){var We,Ke=xe;for(Y.global||(Y=ub(Y.source,Cr(ke.exec(Y))+"g")),Y.lastIndex=0;We=Y.exec(Ke);)var Xe=We.index;xe=xe.slice(0,Xe===r?ve:Xe)}}else if(c.indexOf(Ei(Y),ve)!=ve){var _t=xe.lastIndexOf(Y);_t>-1&&(xe=xe.slice(0,_t))}return xe+U}function Tre(c){return c=Cr(c),c&&Bt.test(c)?c.replace(tr,oX):c}var Dre=uu(function(c,d,P){return c+(P?" ":"")+d.toUpperCase()}),Jb=E9("toUpperCase");function xA(c,d,P){return c=Cr(c),d=P?r:d,d===r?tX(c)?uX(c):KJ(c):c.match(d)||[]}var _A=dr(function(c,d){try{return Cn(c,r,d)}catch(P){return Kb(P)?P:new rr(P)}}),Ore=go(function(c,d){return Vi(d,function(P){P=Fs(P),ho(c,P,Hb(c[P],c))}),c});function Nre(c){var d=c==null?0:c.length,P=qt();return c=d?Xr(c,function(U){if(typeof U[1]!="function")throw new Gi(o);return[P(U[0]),U[1]]}):[],dr(function(U){for(var Y=-1;++YA)return[];var P=I,U=zn(c,I);d=qt(d),c-=I;for(var Y=ob(U,d);++P0||d<0)?new _r(P):(c<0?P=P.takeRight(-c):c&&(P=P.drop(c)),d!==r&&(d=ur(d),P=d<0?P.dropRight(-d):P.take(d-c)),P)},_r.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},_r.prototype.toArray=function(){return this.take(I)},ks(_r.prototype,function(c,d){var P=/^(?:filter|find|map|reject)|While$/.test(d),U=/^(?:head|last)$/.test(d),Y=re[U?"take"+(d=="last"?"Right":""):d],ae=U||/^find/.test(d);Y&&(re.prototype[d]=function(){var pe=this.__wrapped__,ve=U?[1]:arguments,xe=pe instanceof _r,We=ve[0],Ke=xe||or(pe),Xe=function(wr){var Sr=Y.apply(re,Jo([wr],ve));return U&&_t?Sr[0]:Sr};Ke&&P&&typeof We=="function"&&We.length!=1&&(xe=Ke=!1);var _t=this.__chain__,Nt=!!this.__actions__.length,Vt=ae&&!_t,fr=xe&&!Nt;if(!ae&&Ke){pe=fr?pe:new _r(this);var Gt=c.apply(pe,ve);return Gt.__actions__.push({func:j0,args:[Xe],thisArg:r}),new Yi(Gt,_t)}return Vt&&fr?c.apply(this,ve):(Gt=this.thru(Xe),Vt?U?Gt.value()[0]:Gt.value():Gt)})}),Vi(["pop","push","shift","sort","splice","unshift"],function(c){var d=l0[c],P=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",U=/^(?:pop|shift)$/.test(c);re.prototype[c]=function(){var Y=arguments;if(U&&!this.__chain__){var ae=this.value();return d.apply(or(ae)?ae:[],Y)}return this[P](function(pe){return d.apply(or(pe)?pe:[],Y)})}}),ks(_r.prototype,function(c,d){var P=re[d];if(P){var U=P.name+"";Rr.call(ou,U)||(ou[U]=[]),ou[U].push({name:d,func:P})}}),ou[D0(r,B).name]=[{name:"wrapper",func:r}],_r.prototype.clone=TX,_r.prototype.reverse=DX,_r.prototype.value=OX,re.prototype.at=cee,re.prototype.chain=uee,re.prototype.commit=fee,re.prototype.next=lee,re.prototype.plant=dee,re.prototype.reverse=pee,re.prototype.toJSON=re.prototype.valueOf=re.prototype.value=gee,re.prototype.first=re.prototype.head,ml&&(re.prototype[ml]=hee),re}),nu=fX();hn?((hn.exports=nu)._=nu,qr._=nu):Er._=nu}).call(Rj)})(Cf,Cf.exports)),Cf.exports}var Dj=Tj(),Rf={exports:{}},Oj=Rf.exports,l6;function Nj(){return l6||(l6=1,(function(t,e){var r=typeof self<"u"?self:Oj,n=(function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s})();(function(s){(function(o){var a={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function f(l){return l&&DataView.prototype.isPrototypeOf(l)}if(a.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(l){return l&&u.indexOf(Object.prototype.toString.call(l))>-1};function g(l){if(typeof l!="string"&&(l=String(l)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(l))throw new TypeError("Invalid character in header field name");return l.toLowerCase()}function b(l){return typeof l!="string"&&(l=String(l)),l}function x(l){var p={next:function(){var m=l.shift();return{done:m===void 0,value:m}}};return a.iterable&&(p[Symbol.iterator]=function(){return p}),p}function S(l){this.map={},l instanceof S?l.forEach(function(p,m){this.append(m,p)},this):Array.isArray(l)?l.forEach(function(p){this.append(p[0],p[1])},this):l&&Object.getOwnPropertyNames(l).forEach(function(p){this.append(p,l[p])},this)}S.prototype.append=function(l,p){l=g(l),p=b(p);var m=this.map[l];this.map[l]=m?m+", "+p:p},S.prototype.delete=function(l){delete this.map[g(l)]},S.prototype.get=function(l){return l=g(l),this.has(l)?this.map[l]:null},S.prototype.has=function(l){return this.map.hasOwnProperty(g(l))},S.prototype.set=function(l,p){this.map[g(l)]=b(p)},S.prototype.forEach=function(l,p){for(var m in this.map)this.map.hasOwnProperty(m)&&l.call(p,this.map[m],m,this)},S.prototype.keys=function(){var l=[];return this.forEach(function(p,m){l.push(m)}),x(l)},S.prototype.values=function(){var l=[];return this.forEach(function(p){l.push(p)}),x(l)},S.prototype.entries=function(){var l=[];return this.forEach(function(p,m){l.push([m,p])}),x(l)},a.iterable&&(S.prototype[Symbol.iterator]=S.prototype.entries);function C(l){if(l.bodyUsed)return Promise.reject(new TypeError("Already read"));l.bodyUsed=!0}function D(l){return new Promise(function(p,m){l.onload=function(){p(l.result)},l.onerror=function(){m(l.error)}})}function B(l){var p=new FileReader,m=D(p);return p.readAsArrayBuffer(l),m}function L(l){var p=new FileReader,m=D(p);return p.readAsText(l),m}function H(l){for(var p=new Uint8Array(l),m=new Array(p.length),y=0;y-1?p:l}function W(l,p){p=p||{};var m=p.body;if(l instanceof W){if(l.bodyUsed)throw new TypeError("Already read");this.url=l.url,this.credentials=l.credentials,p.headers||(this.headers=new S(l.headers)),this.method=l.method,this.mode=l.mode,this.signal=l.signal,!m&&l._bodyInit!=null&&(m=l._bodyInit,l.bodyUsed=!0)}else this.url=String(l);if(this.credentials=p.credentials||this.credentials||"same-origin",(p.headers||!this.headers)&&(this.headers=new S(p.headers)),this.method=R(p.method||this.method||"GET"),this.mode=p.mode||this.mode||null,this.signal=p.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&m)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(m)}W.prototype.clone=function(){return new W(this,{body:this._bodyInit})};function V(l){var p=new FormData;return l.trim().split("&").forEach(function(m){if(m){var y=m.split("="),A=y.shift().replace(/\+/g," "),E=y.join("=").replace(/\+/g," ");p.append(decodeURIComponent(A),decodeURIComponent(E))}}),p}function X(l){var p=new S,m=l.replace(/\r?\n[\t ]+/g," ");return m.split(/\r?\n/).forEach(function(y){var A=y.split(":"),E=A.shift().trim();if(E){var w=A.join(":").trim();p.append(E,w)}}),p}k.call(W.prototype);function q(l,p){p||(p={}),this.type="default",this.status=p.status===void 0?200:p.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in p?p.statusText:"OK",this.headers=new S(p.headers),this.url=p.url||"",this._initBody(l)}k.call(q.prototype),q.prototype.clone=function(){return new q(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new S(this.headers),url:this.url})},q.error=function(){var l=new q(null,{status:0,statusText:""});return l.type="error",l};var _=[301,302,303,307,308];q.redirect=function(l,p){if(_.indexOf(p)===-1)throw new RangeError("Invalid status code");return new q(null,{status:p,headers:{location:l}})},o.DOMException=s.DOMException;try{new o.DOMException}catch{o.DOMException=function(p,m){this.message=p,this.name=m;var y=Error(p);this.stack=y.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function v(l,p){return new Promise(function(m,y){var A=new W(l,p);if(A.signal&&A.signal.aborted)return y(new o.DOMException("Aborted","AbortError"));var E=new XMLHttpRequest;function w(){E.abort()}E.onload=function(){var I={status:E.status,statusText:E.statusText,headers:X(E.getAllResponseHeaders()||"")};I.url="responseURL"in E?E.responseURL:I.headers.get("X-Request-URL");var M="response"in E?E.response:E.responseText;m(new q(M,I))},E.onerror=function(){y(new TypeError("Network request failed"))},E.ontimeout=function(){y(new TypeError("Network request failed"))},E.onabort=function(){y(new o.DOMException("Aborted","AbortError"))},E.open(A.method,A.url,!0),A.credentials==="include"?E.withCredentials=!0:A.credentials==="omit"&&(E.withCredentials=!1),"responseType"in E&&a.blob&&(E.responseType="blob"),A.headers.forEach(function(I,M){E.setRequestHeader(M,I)}),A.signal&&(A.signal.addEventListener("abort",w),E.onreadystatechange=function(){E.readyState===4&&A.signal.removeEventListener("abort",w)}),E.send(typeof A._bodyInit>"u"?null:A._bodyInit)})}return v.polyfill=!0,s.fetch||(s.fetch=v,s.Headers=S,s.Request=W,s.Response=q),o.Headers=S,o.Request=W,o.Response=q,o.fetch=v,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(Rf,Rf.exports)),Rf.exports}var Lj=Nj();const h6=Mi(Lj);var kj=Object.defineProperty,Bj=Object.defineProperties,Fj=Object.getOwnPropertyDescriptors,d6=Object.getOwnPropertySymbols,jj=Object.prototype.hasOwnProperty,Uj=Object.prototype.propertyIsEnumerable,p6=(t,e,r)=>e in t?kj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,g6=(t,e)=>{for(var r in e||(e={}))jj.call(e,r)&&p6(t,r,e[r]);if(d6)for(var r of d6(e))Uj.call(e,r)&&p6(t,r,e[r]);return t},m6=(t,e)=>Bj(t,Fj(e));const $j={Accept:"application/json","Content-Type":"application/json"},qj="POST",v6={headers:$j,method:qj},b6=10;let us=class{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new Di.EventEmitter,this.isAvailable=!1,this.registering=!1,!p_(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}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(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const r=Hs(e),n=await(await h6(this.url,m6(g6({},v6),{body:r}))).json();this.onPayload({data:n})}catch(r){this.onError(e.id,r)}}async register(e=this.url){if(!p_(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=Hs({id:1,jsonrpc:"2.0",method:"test",params:[]});await h6(e,m6(g6({},v6),{body:r}))}this.onOpen()}catch(r){const n=this.parseError(r);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?ma(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=Kh(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return u_(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>b6&&this.events.setMaxListeners(b6)}};const y6="error",zj="wss://relay.walletconnect.org",Hj="wc",Wj="universal_provider",w6=`${Hj}@2:${Wj}:`,x6="https://rpc.walletconnect.org/v1/",Mc="generic",Kj=`${x6}bundler`,$i={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Vj=Object.defineProperty,Gj=Object.defineProperties,Yj=Object.getOwnPropertyDescriptors,_6=Object.getOwnPropertySymbols,Jj=Object.prototype.hasOwnProperty,Xj=Object.prototype.propertyIsEnumerable,E6=(t,e,r)=>e in t?Vj(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xh=(t,e)=>{for(var r in e||(e={}))Jj.call(e,r)&&E6(t,r,e[r]);if(_6)for(var r of _6(e))Xj.call(e,r)&&E6(t,r,e[r]);return t},Zj=(t,e)=>Gj(t,Yj(e));function yi(t,e,r){var n;const i=Ec(t);return((n=e.rpcMap)==null?void 0:n[i.reference])||`${x6}?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function Da(t){return t.includes(":")?t.split(":")[1]:t}function S6(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function Qj(t,e){const r=Object.keys(e.namespaces).filter(i=>i.includes(t));if(!r.length)return[];const n=[];return r.forEach(i=>{const s=e.namespaces[i].accounts;n.push(...s)}),n}function Om(t={},e={}){const r=A6(t),n=A6(e);return Dj.merge(r,n)}function A6(t){var e,r,n,i;const s={};if(!yf(t))return s;for(const[o,a]of Object.entries(t)){const f=mm(o)?[o]:a.chains,u=a.methods||[],h=a.events||[],g=a.rpcMap||{},b=bf(o);s[b]=Zj(Xh(Xh({},s[b]),a),{chains:jh(f,(e=s[b])==null?void 0:e.chains),methods:jh(u,(r=s[b])==null?void 0:r.methods),events:jh(h,(n=s[b])==null?void 0:n.events),rpcMap:Xh(Xh({},g),(i=s[b])==null?void 0:i.rpcMap)})}return s}function eU(t){return t.includes(":")?t.split(":")[2]:t}function P6(t){const e={};for(const[r,n]of Object.entries(t)){const i=n.methods||[],s=n.events||[],o=n.accounts||[],a=mm(r)?[r]:n.chains?n.chains:S6(n.accounts);e[r]={chains:a,methods:i,events:s,accounts:o}}return e}function Nm(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}const I6={},Pr=t=>I6[t],Lm=(t,e)=>{I6[t]=e};class tU{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Da(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||yi(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Fi(new us(n,Pr("disableProviderPing")))}}var rU=Object.defineProperty,nU=Object.defineProperties,iU=Object.getOwnPropertyDescriptors,M6=Object.getOwnPropertySymbols,sU=Object.prototype.hasOwnProperty,oU=Object.prototype.propertyIsEnumerable,C6=(t,e,r)=>e in t?rU(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,R6=(t,e)=>{for(var r in e||(e={}))sU.call(e,r)&&C6(t,r,e[r]);if(M6)for(var r of M6(e))oU.call(e,r)&&C6(t,r,e[r]);return t},T6=(t,e)=>nU(t,iU(e));class aU{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const n=r||yi(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Fi(new us(n,Pr("disableProviderPing")))}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=parseInt(Da(r));e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,n;let i=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${s}`);else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var r,n,i;const s=(n=(r=e.request)==null?void 0:r.params)==null?void 0:n[0];if(!s)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((i=o?.sessionProperties)==null?void 0:i.capabilities)||{};if(a!=null&&a[s])return a?.[s];const f=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:T6(R6({},o.sessionProperties||{}),{capabilities:T6(R6({},a||{}),{[s]:f})})})}catch(u){console.warn("Failed to update session with capabilities",u)}return f}async getCallStatus(e){var r,n;const i=this.client.session.get(e.topic),s=(r=i.sessionProperties)==null?void 0:r.bundler_name;if(s){const a=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(a,e)}catch(f){console.warn("Failed to fetch call status from bundler",f,a)}}const o=(n=i.sessionProperties)==null?void 0:n.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,r){var n;const i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(No("eth_getUserOperationReceipt",[(n=r.request.params)==null?void 0:n[0]]))});if(!s.ok)throw new Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,r){return`${Kj}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`}}class cU{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Da(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||yi(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Fi(new us(n,Pr("disableProviderPing")))}}let uU=class{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Da(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||yi(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Fi(new us(n,Pr("disableProviderPing")))}},fU=class{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(!this.httpProviders[e]){const n=r||yi(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.chainId=e,this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||yi(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new Fi(new us(n,Pr("disableProviderPing")))}},lU=class{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const n=this.getCardanoRPCUrl(r),i=Da(r);e[i]=this.createHttpProvider(i,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Fi(new us(n,Pr("disableProviderPing")))}},hU=class{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Da(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||yi(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Fi(new us(n,Pr("disableProviderPing")))}};class dU{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;const i=Da(r);e[i]=this.createHttpProvider(i,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||yi(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Fi(new us(n,Pr("disableProviderPing")))}}let pU=class{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||yi(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var n;e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||yi(e,this.namespace);return typeof n>"u"?void 0:new Fi(new us(n,Pr("disableProviderPing")))}};class gU{constructor(e){this.name="tezos",this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const n=r||yi(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{e[r]=this.createHttpProvider(r)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||yi(e,this.namespace);return typeof n>"u"?void 0:new Fi(new us(n))}}class mU{constructor(e){this.name=Mc,this.namespace=e.namespace,this.events=Pr("events"),this.client=Pr("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit($i.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){var e,r;const n={};return(r=(e=this.namespace)==null?void 0:e.accounts)==null||r.forEach(i=>{const s=Ec(i);n[`${s.namespace}:${s.reference}`]=this.createHttpProvider(i)}),n}getHttpProvider(e){const r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const n=this.createHttpProvider(e,r);n&&(this.httpProviders[e]=n)}createHttpProvider(e,r){const n=r||yi(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Fi(new us(n,Pr("disableProviderPing")))}}var vU=Object.defineProperty,bU=Object.defineProperties,yU=Object.getOwnPropertyDescriptors,D6=Object.getOwnPropertySymbols,wU=Object.prototype.hasOwnProperty,xU=Object.prototype.propertyIsEnumerable,O6=(t,e,r)=>e in t?vU(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zh=(t,e)=>{for(var r in e||(e={}))wU.call(e,r)&&O6(t,r,e[r]);if(D6)for(var r of D6(e))xU.call(e,r)&&O6(t,r,e[r]);return t},km=(t,e)=>bU(t,yU(e));let Bm=class PA{constructor(e){this.events=new qp,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Gu(hh({level:e?.logger||y6})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const r=new PA(e);return await r.initialize(),r}async request(e,r,n){const[i,s]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Zh({},e),chainId:`${i}:${s}`,topic:this.session.topic,expiry:n})}sendAsync(e,r,n,i){const s=new Date().getTime();this.request(e,n,i).then(o=>r(null,Wh(s,o))).catch(o=>r(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Dr("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,r){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:i}=await this.client.authenticate(e,r);n&&(this.uri=n,this.events.emit("display_uri",n));const s=await i();if(this.session=s.session,this.session){const o=P6(this.session.namespaces);this.namespaces=Om(this.namespaces,o),this.persist("namespaces",this.namespaces),this.onConnect()}return s}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await i().then(s=>{this.session=s;const o=P6(s.namespaces);this.namespaces=Om(this.namespaces,o),this.persist("namespaces",this.namespaces)}).catch(s=>{if(s.message!==a6)throw s;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[n,i]=this.validateChain(e),s=this.getProvider(n);s.name===Mc?s.setDefaultChain(`${n}:${i}`,r):s.setDefaultChain(i,r)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(Pa(r)){for(const n of r)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Dm.init({core:this.providerOpts.core,logger:this.providerOpts.logger||y6,relayUrl:this.providerOpts.relayUrl||zj,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(r=>bf(r)))];Lm("client",this.client),Lm("events",this.events),Lm("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const n=Qj(r,this.session),i=S6(n),s=Om(this.namespaces,this.optionalNamespaces),o=km(Zh({},s[r]),{accounts:n,chains:i});switch(r){case"eip155":this.rpcProviders[r]=new aU({namespace:o});break;case"algorand":this.rpcProviders[r]=new fU({namespace:o});break;case"solana":this.rpcProviders[r]=new cU({namespace:o});break;case"cosmos":this.rpcProviders[r]=new uU({namespace:o});break;case"polkadot":this.rpcProviders[r]=new tU({namespace:o});break;case"cip34":this.rpcProviders[r]=new lU({namespace:o});break;case"elrond":this.rpcProviders[r]=new hU({namespace:o});break;case"multiversx":this.rpcProviders[r]=new dU({namespace:o});break;case"near":this.rpcProviders[r]=new pU({namespace:o});break;case"tezos":this.rpcProviders[r]=new gU({namespace:o});break;default:this.rpcProviders[Mc]?this.rpcProviders[Mc].updateNamespace(o):this.rpcProviders[Mc]=new mU({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:r}=e,{event:n}=r;if(n.name==="accountsChanged"){const i=n.data;i&&Pa(i)&&this.events.emit("accountsChanged",i.map(eU))}else if(n.name==="chainChanged"){const i=r.chainId,s=r.event.data,o=bf(i),a=Nm(i)!==Nm(s)?`${o}:${Nm(s)}`:i;this.onChainChanged(a)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var n;const{namespaces:i}=r,s=(n=this.client)==null?void 0:n.session.get(e);this.session=km(Zh({},s),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",km(Zh({},Dr("USER_DISCONNECTED")),{data:e.topic}))}),this.on($i.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Mc]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:n,sessionProperties:i}=e;r&&Object.keys(r).length&&(this.namespaces=r),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=i,this.persist("namespaces",r),this.persist("optionalNamespaces",n)}validateChain(e){const[r,n]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,n];if(r&&!Object.keys(this.namespaces||{}).map(o=>bf(o)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&n)return[r,n];const i=bf(Object.keys(this.namespaces)[0]),s=this.rpcProviders[i].getDefaultChain();return[i,s]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){if(!this.namespaces)return;const[n,i]=this.validateChain(e);i&&(r||this.getProvider(n).setDefaultChain(i),this.namespaces[n]?this.namespaces[n].defaultChain=i:this.namespaces[`${n}:${i}`]?this.namespaces[`${n}:${i}`].defaultChain=i:this.namespaces[`${n}:${i}`]={defaultChain:i},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,r){this.client.core.storage.setItem(`${w6}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${w6}/${e}`)}};const _U=Bm;function EU(){return new Promise(t=>{const e=[];let r;window.addEventListener("eip6963:announceProvider",n=>{const{detail:i}=n;r&&clearTimeout(r),e.push(i),r=setTimeout(()=>t(e),200)}),r=setTimeout(()=>t(e),200),window.dispatchEvent(new Event("eip6963:requestProvider"))})}class Cs{constructor(e,r){this.scope=e,this.module=r}storeObject(e,r){this.setItem(e,JSON.stringify(r))}loadObject(e){const r=this.getItem(e);return r?JSON.parse(r):void 0}setItem(e,r){localStorage.setItem(this.scopedKey(e),r)}getItem(e){return localStorage.getItem(this.scopedKey(e))}removeItem(e){localStorage.removeItem(this.scopedKey(e))}clear(){const e=this.scopedKey(""),r=[];for(let n=0;nlocalStorage.removeItem(n))}scopedKey(e){return`-${this.scope}${this.module?`:${this.module}`:""}:${e}`}static clearAll(){new Cs("CBWSDK").clear(),new Cs("walletlink").clear()}}const sn={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902}},Fm={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},N6="Unspecified error message.",SU="Unspecified server error.";function jm(t,e=N6){if(t&&Number.isInteger(t)){const r=t.toString();if(Um(Fm,r))return Fm[r].message;if(L6(t))return SU}return e}function AU(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!(Fm[e]||L6(t))}function PU(t,{shouldIncludeStack:e=!1}={}){const r={};if(t&&typeof t=="object"&&!Array.isArray(t)&&Um(t,"code")&&AU(t.code)){const n=t;r.code=n.code,n.message&&typeof n.message=="string"?(r.message=n.message,Um(n,"data")&&(r.data=n.data)):(r.message=jm(r.code),r.data={originalError:k6(t)})}else r.code=sn.rpc.internal,r.message=B6(t,"message")?t.message:N6,r.data={originalError:k6(t)};return e&&(r.stack=B6(t,"stack")?t.stack:void 0),r}function L6(t){return t>=-32099&&t<=-32e3}function k6(t){return t&&typeof t=="object"&&!Array.isArray(t)?Object.assign({},t):t}function Um(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function B6(t,e){return typeof t=="object"&&t!==null&&e in t&&typeof t[e]=="string"}const Ar={rpc:{parse:t=>qi(sn.rpc.parse,t),invalidRequest:t=>qi(sn.rpc.invalidRequest,t),invalidParams:t=>qi(sn.rpc.invalidParams,t),methodNotFound:t=>qi(sn.rpc.methodNotFound,t),internal:t=>qi(sn.rpc.internal,t),server:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return qi(e,t)},invalidInput:t=>qi(sn.rpc.invalidInput,t),resourceNotFound:t=>qi(sn.rpc.resourceNotFound,t),resourceUnavailable:t=>qi(sn.rpc.resourceUnavailable,t),transactionRejected:t=>qi(sn.rpc.transactionRejected,t),methodNotSupported:t=>qi(sn.rpc.methodNotSupported,t),limitExceeded:t=>qi(sn.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>Cc(sn.provider.userRejectedRequest,t),unauthorized:t=>Cc(sn.provider.unauthorized,t),unsupportedMethod:t=>Cc(sn.provider.unsupportedMethod,t),disconnected:t=>Cc(sn.provider.disconnected,t),chainDisconnected:t=>Cc(sn.provider.chainDisconnected,t),unsupportedChain:t=>Cc(sn.provider.unsupportedChain,t),custom:t=>{if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:r,data:n}=t;if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string');return new U6(e,r,n)}}};function qi(t,e){const[r,n]=F6(e);return new j6(t,r||jm(t),n)}function Cc(t,e){const[r,n]=F6(e);return new U6(t,r||jm(t),n)}function F6(t){if(t){if(typeof t=="string")return[t];if(typeof t=="object"&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&typeof e!="string")throw new Error("Must specify string message.");return[e||void 0,r]}}return[]}class j6 extends Error{constructor(e,r,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!r||typeof r!="string")throw new Error('"message" must be a nonempty string.');super(r),this.code=e,n!==void 0&&(this.data=n)}}class U6 extends j6{constructor(e,r,n){if(!IU(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,r,n)}}function IU(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}function $m(){return t=>t}const Tf=$m(),MU=$m(),CU=$m();function Zs(t){return Math.floor(t)}const $6=/^[0-9]*$/,q6=/^[a-f0-9]*$/;function Oa(t){return qm(crypto.getRandomValues(new Uint8Array(t)))}function qm(t){return[...t].map(e=>e.toString(16).padStart(2,"0")).join("")}function Qh(t){return new Uint8Array(t.match(/.{1,2}/g).map(e=>Number.parseInt(e,16)))}function Df(t,e=!1){const r=t.toString("hex");return Tf(e?`0x${r}`:r)}function zm(t){return Df(Km(t),!0)}function Rs(t){return CU(t.toString(10))}function Lo(t){return Tf(`0x${BigInt(t).toString(16)}`)}function z6(t){return t.startsWith("0x")||t.startsWith("0X")}function Hm(t){return z6(t)?t.slice(2):t}function H6(t){return z6(t)?`0x${t.slice(2)}`:`0x${t}`}function ed(t){if(typeof t!="string")return!1;const e=Hm(t).toLowerCase();return q6.test(e)}function RU(t,e=!1){if(typeof t=="string"){const r=Hm(t).toLowerCase();if(q6.test(r))return Tf(e?`0x${r}`:r)}throw Ar.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`)}function Wm(t,e=!1){let r=RU(t,!1);return r.length%2===1&&(r=Tf(`0${r}`)),e?Tf(`0x${r}`):r}function ko(t){if(typeof t=="string"){const e=Hm(t).toLowerCase();if(ed(e)&&e.length===40)return MU(H6(e))}throw Ar.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`)}function Km(t){if(Buffer.isBuffer(t))return t;if(typeof t=="string"){if(ed(t)){const e=Wm(t,!1);return Buffer.from(e,"hex")}return Buffer.from(t,"utf8")}throw Ar.rpc.invalidParams(`Not binary data: ${String(t)}`)}function Of(t){if(typeof t=="number"&&Number.isInteger(t))return Zs(t);if(typeof t=="string"){if($6.test(t))return Zs(Number(t));if(ed(t))return Zs(Number(BigInt(Wm(t,!0))))}throw Ar.rpc.invalidParams(`Not an integer: ${String(t)}`)}function Nf(t){if(t!==null&&(typeof t=="bigint"||DU(t)))return BigInt(t.toString(10));if(typeof t=="number")return BigInt(Of(t));if(typeof t=="string"){if($6.test(t))return BigInt(t);if(ed(t))return BigInt(Wm(t,!0))}throw Ar.rpc.invalidParams(`Not an integer: ${String(t)}`)}function TU(t){if(typeof t=="string")return JSON.parse(t);if(typeof t=="object")return t;throw Ar.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`)}function DU(t){if(t==null||typeof t.constructor!="function")return!1;const{constructor:e}=t;return typeof e.config=="function"&&typeof e.EUCLID=="number"}async function OU(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveKey"])}async function NU(t,e){return crypto.subtle.deriveKey({name:"ECDH",public:e},t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function LU(t,e){const r=crypto.getRandomValues(new Uint8Array(12)),n=await crypto.subtle.encrypt({name:"AES-GCM",iv:r},t,new TextEncoder().encode(e));return{iv:r,cipherText:n}}async function kU(t,{iv:e,cipherText:r}){const n=await crypto.subtle.decrypt({name:"AES-GCM",iv:e},t,r);return new TextDecoder().decode(n)}function W6(t){switch(t){case"public":return"spki";case"private":return"pkcs8"}}async function K6(t,e){const r=W6(t),n=await crypto.subtle.exportKey(r,e);return qm(new Uint8Array(n))}async function V6(t,e){const r=W6(t),n=Qh(e).buffer;return await crypto.subtle.importKey(r,new Uint8Array(n),{name:"ECDH",namedCurve:"P-256"},!0,t==="private"?["deriveKey"]:[])}async function BU(t,e){const r=JSON.stringify(t,(n,i)=>{if(!(i instanceof Error))return i;const s=i;return Object.assign(Object.assign({},s.code?{code:s.code}:{}),{message:s.message})});return LU(e,r)}async function FU(t,e){return JSON.parse(await kU(e,t))}const Vm={storageKey:"ownPrivateKey",keyType:"private"},Gm={storageKey:"ownPublicKey",keyType:"public"},Ym={storageKey:"peerPublicKey",keyType:"public"};class jU{constructor(){this.storage=new Cs("CBWSDK","SCWKeyManager"),this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null}async getOwnPublicKey(){return await this.loadKeysIfNeeded(),this.ownPublicKey}async getSharedSecret(){return await this.loadKeysIfNeeded(),this.sharedSecret}async setPeerPublicKey(e){this.sharedSecret=null,this.peerPublicKey=e,await this.storeKey(Ym,e),await this.loadKeysIfNeeded()}async clear(){this.ownPrivateKey=null,this.ownPublicKey=null,this.peerPublicKey=null,this.sharedSecret=null,this.storage.removeItem(Gm.storageKey),this.storage.removeItem(Vm.storageKey),this.storage.removeItem(Ym.storageKey)}async generateKeyPair(){const e=await OU();this.ownPrivateKey=e.privateKey,this.ownPublicKey=e.publicKey,await this.storeKey(Vm,e.privateKey),await this.storeKey(Gm,e.publicKey)}async loadKeysIfNeeded(){if(this.ownPrivateKey===null&&(this.ownPrivateKey=await this.loadKey(Vm)),this.ownPublicKey===null&&(this.ownPublicKey=await this.loadKey(Gm)),(this.ownPrivateKey===null||this.ownPublicKey===null)&&await this.generateKeyPair(),this.peerPublicKey===null&&(this.peerPublicKey=await this.loadKey(Ym)),this.sharedSecret===null){if(this.ownPrivateKey===null||this.peerPublicKey===null)return;this.sharedSecret=await NU(this.ownPrivateKey,this.peerPublicKey)}}async loadKey(e){const r=this.storage.getItem(e.storageKey);return r?V6(e.keyType,r):null}async storeKey(e,r){const n=await K6(e.keyType,r);this.storage.setItem(e.storageKey,n)}}const Lf="4.2.4",G6="@coinbase/wallet-sdk";async function Y6(t,e){const r=Object.assign(Object.assign({},t),{jsonrpc:"2.0",id:crypto.randomUUID()}),n=await window.fetch(e,{method:"POST",body:JSON.stringify(r),mode:"cors",headers:{"Content-Type":"application/json","X-Cbw-Sdk-Version":Lf,"X-Cbw-Sdk-Platform":G6}}),{result:i,error:s}=await n.json();if(s)throw s;return i}function UU(){return globalThis.coinbaseWalletExtension}function $U(){var t,e;try{const r=globalThis;return(t=r.ethereum)!==null&&t!==void 0?t:(e=r.top)===null||e===void 0?void 0:e.ethereum}catch{return}}function qU({metadata:t,preference:e}){var r,n;const{appName:i,appLogoUrl:s,appChainIds:o}=t;if(e.options!=="smartWalletOnly"){const f=UU();if(f)return(r=f.setAppInfo)===null||r===void 0||r.call(f,i,s,o,e),f}const a=$U();if(a?.isCoinbaseBrowser)return(n=a.setAppInfo)===null||n===void 0||n.call(a,i,s,o,e),a}function zU(t){if(!t||typeof t!="object"||Array.isArray(t))throw Ar.rpc.invalidParams({message:"Expected a single, non-array, object argument.",data:t});const{method:e,params:r}=t;if(typeof e!="string"||e.length===0)throw Ar.rpc.invalidParams({message:"'args.method' must be a non-empty string.",data:t});if(r!==void 0&&!Array.isArray(r)&&(typeof r!="object"||r===null))throw Ar.rpc.invalidParams({message:"'args.params' must be an object or array if provided.",data:t});switch(e){case"eth_sign":case"eth_signTypedData_v2":case"eth_subscribe":case"eth_unsubscribe":throw Ar.provider.unsupportedMethod()}}const J6="accounts",X6="activeChain",Z6="availableChains",Q6="walletCapabilities";class HU{constructor(e){var r,n,i;this.metadata=e.metadata,this.communicator=e.communicator,this.callback=e.callback,this.keyManager=new jU,this.storage=new Cs("CBWSDK","SCWStateManager"),this.accounts=(r=this.storage.loadObject(J6))!==null&&r!==void 0?r:[],this.chain=this.storage.loadObject(X6)||{id:(i=(n=e.metadata.appChainIds)===null||n===void 0?void 0:n[0])!==null&&i!==void 0?i:1},this.handshake=this.handshake.bind(this),this.request=this.request.bind(this),this.createRequestMessage=this.createRequestMessage.bind(this),this.decryptResponseMessage=this.decryptResponseMessage.bind(this)}async handshake(e){var r,n;const i=await this.createRequestMessage({handshake:{method:e.method,params:Object.assign({},this.metadata,(r=e.params)!==null&&r!==void 0?r:{})}}),s=await this.communicator.postRequestAndWaitForResponse(i);if("failure"in s.content)throw s.content.failure;const o=await V6("public",s.sender);await this.keyManager.setPeerPublicKey(o);const f=(await this.decryptResponseMessage(s)).result;if("error"in f)throw f.error;const u=f.value;this.accounts=u,this.storage.storeObject(J6,u),(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",u)}async request(e){var r;if(this.accounts.length===0)throw Ar.provider.unauthorized();switch(e.method){case"eth_requestAccounts":return(r=this.callback)===null||r===void 0||r.call(this,"connect",{chainId:Lo(this.chain.id)}),this.accounts;case"eth_accounts":return this.accounts;case"eth_coinbase":return this.accounts[0];case"net_version":return this.chain.id;case"eth_chainId":return Lo(this.chain.id);case"wallet_getCapabilities":return this.storage.loadObject(Q6);case"wallet_switchEthereumChain":return this.handleSwitchChainRequest(e);case"eth_ecRecover":case"personal_sign":case"personal_ecRecover":case"eth_signTransaction":case"eth_sendTransaction":case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":case"wallet_addEthereumChain":case"wallet_watchAsset":case"wallet_sendCalls":case"wallet_showCallsStatus":case"wallet_grantPermissions":return this.sendRequestToPopup(e);default:if(!this.chain.rpcUrl)throw Ar.rpc.internal("No RPC URL set for chain");return Y6(e,this.chain.rpcUrl)}}async sendRequestToPopup(e){var r,n;await((n=(r=this.communicator).waitForPopupLoaded)===null||n===void 0?void 0:n.call(r));const i=await this.sendEncryptedRequest(e),o=(await this.decryptResponseMessage(i)).result;if("error"in o)throw o.error;return o.value}async cleanup(){var e,r;this.storage.clear(),await this.keyManager.clear(),this.accounts=[],this.chain={id:(r=(e=this.metadata.appChainIds)===null||e===void 0?void 0:e[0])!==null&&r!==void 0?r:1}}async handleSwitchChainRequest(e){var r;const n=e.params;if(!n||!(!((r=n[0])===null||r===void 0)&&r.chainId))throw Ar.rpc.invalidParams();const i=Of(n[0].chainId);if(this.updateChain(i))return null;const o=await this.sendRequestToPopup(e);return o===null&&this.updateChain(i),o}async sendEncryptedRequest(e){const r=await this.keyManager.getSharedSecret();if(!r)throw Ar.provider.unauthorized("No valid session found, try requestAccounts before other methods");const n=await BU({action:e,chainId:this.chain.id},r),i=await this.createRequestMessage({encrypted:n});return this.communicator.postRequestAndWaitForResponse(i)}async createRequestMessage(e){const r=await K6("public",await this.keyManager.getOwnPublicKey());return{id:crypto.randomUUID(),sender:r,content:e,timestamp:new Date}}async decryptResponseMessage(e){var r,n;const i=e.content;if("failure"in i)throw i.failure;const s=await this.keyManager.getSharedSecret();if(!s)throw Ar.provider.unauthorized("Invalid session");const o=await FU(i.encrypted,s),a=(r=o.data)===null||r===void 0?void 0:r.chains;if(a){const u=Object.entries(a).map(([h,g])=>({id:Number(h),rpcUrl:g}));this.storage.storeObject(Z6,u),this.updateChain(this.chain.id,u)}const f=(n=o.data)===null||n===void 0?void 0:n.capabilities;return f&&this.storage.storeObject(Q6,f),o}updateChain(e,r){var n;const i=r??this.storage.loadObject(Z6),s=i?.find(o=>o.id===e);return s?(s!==this.chain&&(this.chain=s,this.storage.storeObject(X6,s),(n=this.callback)===null||n===void 0||n.call(this,"chainChanged",Lo(s.id))),!0):!1}}var Wr={},er={},e5;function WU(){if(e5)return er;e5=1,Object.defineProperty(er,"__esModule",{value:!0}),er.toBig=er.shrSL=er.shrSH=er.rotrSL=er.rotrSH=er.rotrBL=er.rotrBH=er.rotr32L=er.rotr32H=er.rotlSL=er.rotlSH=er.rotlBL=er.rotlBH=er.add5L=er.add5H=er.add4L=er.add4H=er.add3L=er.add3H=void 0,er.add=B,er.fromBig=r,er.split=n;const t=BigInt(2**32-1),e=BigInt(32);function r(V,X=!1){return X?{h:Number(V&t),l:Number(V>>e&t)}:{h:Number(V>>e&t)|0,l:Number(V&t)|0}}function n(V,X=!1){const q=V.length;let _=new Uint32Array(q),v=new Uint32Array(q);for(let l=0;lBigInt(V>>>0)<>>0);er.toBig=i;const s=(V,X,q)=>V>>>q;er.shrSH=s;const o=(V,X,q)=>V<<32-q|X>>>q;er.shrSL=o;const a=(V,X,q)=>V>>>q|X<<32-q;er.rotrSH=a;const f=(V,X,q)=>V<<32-q|X>>>q;er.rotrSL=f;const u=(V,X,q)=>V<<64-q|X>>>q-32;er.rotrBH=u;const h=(V,X,q)=>V>>>q-32|X<<64-q;er.rotrBL=h;const g=(V,X)=>X;er.rotr32H=g;const b=(V,X)=>V;er.rotr32L=b;const x=(V,X,q)=>V<>>32-q;er.rotlSH=x;const S=(V,X,q)=>X<>>32-q;er.rotlSL=S;const C=(V,X,q)=>X<>>64-q;er.rotlBH=C;const D=(V,X,q)=>V<>>64-q;er.rotlBL=D;function B(V,X,q,_){const v=(X>>>0)+(_>>>0);return{h:V+q+(v/2**32|0)|0,l:v|0}}const L=(V,X,q)=>(V>>>0)+(X>>>0)+(q>>>0);er.add3L=L;const H=(V,X,q,_)=>X+q+_+(V/2**32|0)|0;er.add3H=H;const F=(V,X,q,_)=>(V>>>0)+(X>>>0)+(q>>>0)+(_>>>0);er.add4L=F;const k=(V,X,q,_,v)=>X+q+_+v+(V/2**32|0)|0;er.add4H=k;const $=(V,X,q,_,v)=>(V>>>0)+(X>>>0)+(q>>>0)+(_>>>0)+(v>>>0);er.add5L=$;const R=(V,X,q,_,v,l)=>X+q+_+v+l+(V/2**32|0)|0;er.add5H=R;const W={fromBig:r,split:n,toBig:i,shrSH:s,shrSL:o,rotrSH:a,rotrSL:f,rotrBH:u,rotrBL:h,rotr32H:g,rotr32L:b,rotlSH:x,rotlSL:S,rotlBH:C,rotlBL:D,add:B,add3L:L,add3H:H,add4L:F,add4H:k,add5H:R,add5L:$};return er.default=W,er}var Jm={},kf={},t5;function KU(){return t5||(t5=1,Object.defineProperty(kf,"__esModule",{value:!0}),kf.crypto=void 0,kf.crypto=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0),kf}var r5;function VU(){return r5||(r5=1,(function(t){/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(t,"__esModule",{value:!0}),t.wrapXOFConstructorWithOpts=t.wrapConstructorWithOpts=t.wrapConstructor=t.Hash=t.nextTick=t.swap32IfBE=t.byteSwapIfBE=t.swap8IfBE=t.isLE=void 0,t.isBytes=r,t.anumber=n,t.abytes=i,t.ahash=s,t.aexists=o,t.aoutput=a,t.u8=f,t.u32=u,t.clean=h,t.createView=g,t.rotr=b,t.rotl=x,t.byteSwap=S,t.byteSwap32=C,t.bytesToHex=L,t.hexToBytes=k,t.asyncLoop=R,t.utf8ToBytes=W,t.bytesToUtf8=V,t.toBytes=X,t.kdfInputToBytes=q,t.concatBytes=_,t.checkOpts=v,t.createHasher=p,t.createOptHasher=m,t.createXOFer=y,t.randomBytes=A;const e=KU();function r(E){return E instanceof Uint8Array||ArrayBuffer.isView(E)&&E.constructor.name==="Uint8Array"}function n(E){if(!Number.isSafeInteger(E)||E<0)throw new Error("positive integer expected, got "+E)}function i(E,...w){if(!r(E))throw new Error("Uint8Array expected");if(w.length>0&&!w.includes(E.length))throw new Error("Uint8Array expected of length "+w+", got length="+E.length)}function s(E){if(typeof E!="function"||typeof E.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");n(E.outputLen),n(E.blockLen)}function o(E,w=!0){if(E.destroyed)throw new Error("Hash instance has been destroyed");if(w&&E.finished)throw new Error("Hash#digest() has already been called")}function a(E,w){i(E);const I=w.outputLen;if(E.length>>w}function x(E,w){return E<>>32-w>>>0}t.isLE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function S(E){return E<<24&4278190080|E<<8&16711680|E>>>8&65280|E>>>24&255}t.swap8IfBE=t.isLE?E=>E:E=>S(E),t.byteSwapIfBE=t.swap8IfBE;function C(E){for(let w=0;wE:C;const D=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",B=Array.from({length:256},(E,w)=>w.toString(16).padStart(2,"0"));function L(E){if(i(E),D)return E.toHex();let w="";for(let I=0;I=H._0&&E<=H._9)return E-H._0;if(E>=H.A&&E<=H.F)return E-(H.A-10);if(E>=H.a&&E<=H.f)return E-(H.a-10)}function k(E){if(typeof E!="string")throw new Error("hex string expected, got "+typeof E);if(D)return Uint8Array.fromHex(E);const w=E.length,I=w/2;if(w%2)throw new Error("hex string expected, got unpadded hex of length "+w);const M=new Uint8Array(I);for(let z=0,se=0;z{};t.nextTick=$;async function R(E,w,I){let M=Date.now();for(let z=0;z=0&&seE().update(X(M)).digest(),I=E();return w.outputLen=I.outputLen,w.blockLen=I.blockLen,w.create=()=>E(),w}function m(E){const w=(M,z)=>E(z).update(X(M)).digest(),I=E({});return w.outputLen=I.outputLen,w.blockLen=I.blockLen,w.create=M=>E(M),w}function y(E){const w=(M,z)=>E(z).update(X(M)).digest(),I=E({});return w.outputLen=I.outputLen,w.blockLen=I.blockLen,w.create=M=>E(M),w}t.wrapConstructor=p,t.wrapConstructorWithOpts=m,t.wrapXOFConstructorWithOpts=y;function A(E=32){if(e.crypto&&typeof e.crypto.getRandomValues=="function")return e.crypto.getRandomValues(new Uint8Array(E));if(e.crypto&&typeof e.crypto.randomBytes=="function")return Uint8Array.from(e.crypto.randomBytes(E));throw new Error("crypto.getRandomValues must be defined")}})(Jm)),Jm}var n5;function GU(){if(n5)return Wr;n5=1,Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.shake256=Wr.shake128=Wr.keccak_512=Wr.keccak_384=Wr.keccak_256=Wr.keccak_224=Wr.sha3_512=Wr.sha3_384=Wr.sha3_256=Wr.sha3_224=Wr.Keccak=void 0,Wr.keccakP=D;const t=WU(),e=VU(),r=BigInt(0),n=BigInt(1),i=BigInt(2),s=BigInt(7),o=BigInt(256),a=BigInt(113),f=[],u=[],h=[];for(let F=0,k=n,$=1,R=0;F<24;F++){[$,R]=[R,(2*$+3*R)%5],f.push(2*(5*R+$)),u.push((F+1)*(F+2)/2%64);let W=r;for(let V=0;V<7;V++)k=(k<>s)*a)%o,k&i&&(W^=n<<(n<$>32?(0,t.rotlBH)(F,k,$):(0,t.rotlSH)(F,k,$),C=(F,k,$)=>$>32?(0,t.rotlBL)(F,k,$):(0,t.rotlSL)(F,k,$);function D(F,k=24){const $=new Uint32Array(10);for(let R=24-k;R<24;R++){for(let X=0;X<10;X++)$[X]=F[X]^F[X+10]^F[X+20]^F[X+30]^F[X+40];for(let X=0;X<10;X+=2){const q=(X+8)%10,_=(X+2)%10,v=$[_],l=$[_+1],p=S(v,l,1)^$[q],m=C(v,l,1)^$[q+1];for(let y=0;y<50;y+=10)F[X+y]^=p,F[X+y+1]^=m}let W=F[2],V=F[3];for(let X=0;X<24;X++){const q=u[X],_=S(W,V,q),v=C(W,V,q),l=f[X];W=F[l],V=F[l+1],F[l]=_,F[l+1]=v}for(let X=0;X<50;X+=10){for(let q=0;q<10;q++)$[q]=F[X+q];for(let q=0;q<10;q++)F[X+q]^=~$[(q+2)%10]&$[(q+4)%10]}F[0]^=b[R],F[1]^=x[R]}(0,e.clean)($)}class B extends e.Hash{constructor(k,$,R,W=!1,V=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=k,this.suffix=$,this.outputLen=R,this.enableXOF=W,this.rounds=V,(0,e.anumber)(R),!(0=R&&this.keccak();const X=Math.min(R-this.posOut,V-W);k.set($.subarray(this.posOut,this.posOut+X),W),this.posOut+=X,W+=X}return k}xofInto(k){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(k)}xof(k){return(0,e.anumber)(k),this.xofInto(new Uint8Array(k))}digestInto(k){if((0,e.aoutput)(k,this),this.finished)throw new Error("digest() was already called");return this.writeInto(k),this.destroy(),k}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,(0,e.clean)(this.state)}_cloneInto(k){const{blockLen:$,suffix:R,outputLen:W,rounds:V,enableXOF:X}=this;return k||(k=new B($,R,W,X,V)),k.state32.set(this.state32),k.pos=this.pos,k.posOut=this.posOut,k.finished=this.finished,k.rounds=V,k.suffix=R,k.outputLen=W,k.enableXOF=X,k.destroyed=this.destroyed,k}}Wr.Keccak=B;const L=(F,k,$)=>(0,e.createHasher)(()=>new B(k,F,$));Wr.sha3_224=L(6,144,224/8),Wr.sha3_256=L(6,136,256/8),Wr.sha3_384=L(6,104,384/8),Wr.sha3_512=L(6,72,512/8),Wr.keccak_224=L(1,144,224/8),Wr.keccak_256=L(1,136,256/8),Wr.keccak_384=L(1,104,384/8),Wr.keccak_512=L(1,72,512/8);const H=(F,k,$)=>(0,e.createXOFer)((R={})=>new B(k,F,R.dkLen===void 0?$:R.dkLen,!0));return Wr.shake128=H(31,168,128/8),Wr.shake256=H(31,136,256/8),Wr}var Xm,i5;function s5(){if(i5)return Xm;i5=1;const{keccak_256:t}=GU();function e(x){return Buffer.allocUnsafe(x).fill(0)}function r(x){return x.toString(2).length}function n(x,S){let C=x.toString(16);C.length%2!==0&&(C="0"+C);const D=C.match(/.{1,2}/g).map(B=>parseInt(B,16));for(;D.length"u")throw new Error("Not an array?");if(S=i(b),S!=="dynamic"&&S!==0&&x.length>S)throw new Error("Elements exceed array size: "+S);D=[],b=b.slice(0,b.lastIndexOf("[")),typeof x=="string"&&(x=JSON.parse(x));for(B in x)D.push(o(b,x[B]));if(S==="dynamic"){var L=o("uint256",x.length);D.unshift(L)}return Buffer.concat(D)}else{if(b==="bytes")return x=new Buffer(x),D=Buffer.concat([o("uint256",x.length),x]),x.length%32!==0&&(D=Buffer.concat([D,t.zeros(32-x.length%32)])),D;if(b.startsWith("bytes")){if(S=r(b),S<1||S>32)throw new Error("Invalid bytes width: "+S);return t.setLengthRight(x,32)}else if(b.startsWith("uint")){if(S=r(b),S%8||S<8||S>256)throw new Error("Invalid uint width: "+S);C=s(x);const H=t.bitLengthFromBigInt(C);if(H>S)throw new Error("Supplied uint exceeds width: "+S+" vs "+H);if(C<0)throw new Error("Supplied uint is negative");return t.bufferBEFromBigInt(C,32)}else if(b.startsWith("int")){if(S=r(b),S%8||S<8||S>256)throw new Error("Invalid int width: "+S);C=s(x);const H=t.bitLengthFromBigInt(C);if(H>S)throw new Error("Supplied int exceeds width: "+S+" vs "+H);const F=t.twosFromBigInt(C,256);return t.bufferBEFromBigInt(F,32)}else if(b.startsWith("ufixed")){if(S=n(b),C=s(x),C<0)throw new Error("Supplied ufixed is negative");return o("uint256",C*BigInt(2)**BigInt(S[1]))}else if(b.startsWith("fixed"))return S=n(b),o("int256",s(x)*BigInt(2)**BigInt(S[1]))}throw new Error("Unsupported or invalid type: "+b)}function a(b){return b==="string"||b==="bytes"||i(b)==="dynamic"}function f(b){return b.lastIndexOf("]")===b.length-1}function u(b,x){var S=[],C=[],D=32*b.length;for(var B in b){var L=e(b[B]),H=x[B],F=o(L,H);a(L)?(S.push(o("uint256",D)),C.push(F),D+=F.length):S.push(F)}return Buffer.concat(S.concat(C))}function h(b,x){if(b.length!==x.length)throw new Error("Number of types are not matching the values");for(var S,C,D=[],B=0;B32)throw new Error("Invalid bytes width: "+S);D.push(t.setLengthRight(H,S))}else if(L.startsWith("uint")){if(S=r(L),S%8||S<8||S>256)throw new Error("Invalid uint width: "+S);C=s(H);const F=t.bitLengthFromBigInt(C);if(F>S)throw new Error("Supplied uint exceeds width: "+S+" vs "+F);D.push(t.bufferBEFromBigInt(C,S/8))}else if(L.startsWith("int")){if(S=r(L),S%8||S<8||S>256)throw new Error("Invalid int width: "+S);C=s(H);const F=t.bitLengthFromBigInt(C);if(F>S)throw new Error("Supplied int exceeds width: "+S+" vs "+F);const k=t.twosFromBigInt(C,S);D.push(t.bufferBEFromBigInt(k,S/8))}else throw new Error("Unsupported or invalid type: "+L)}return Buffer.concat(D)}function g(b,x){return t.keccak(h(b,x))}return Zm={rawEncode:u,solidityPack:h,soliditySHA3:g},Zm}var Qm,a5;function JU(){if(a5)return Qm;a5=1;const t=s5(),e=YU(),r={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},n={encodeData(s,o,a,f=!0){const u=["bytes32"],h=[this.hashType(s,a)];if(f){const g=(b,x,S)=>{if(a[x]!==void 0)return["bytes32",S==null?"0x0000000000000000000000000000000000000000000000000000000000000000":t.keccak(this.encodeData(x,S,a,f))];if(S===void 0)throw new Error(`missing value for field ${b} of type ${x}`);if(x==="bytes")return["bytes32",t.keccak(S)];if(x==="string")return typeof S=="string"&&(S=Buffer.from(S,"utf8")),["bytes32",t.keccak(S)];if(x.lastIndexOf("]")===x.length-1){const C=x.slice(0,x.lastIndexOf("[")),D=S.map(B=>g(b,C,B));return["bytes32",t.keccak(e.rawEncode(D.map(([B])=>B),D.map(([,B])=>B)))]}return[x,S]};for(const b of a[s]){const[x,S]=g(b.name,b.type,o[b.name]);u.push(x),h.push(S)}}else for(const g of a[s]){let b=o[g.name];if(b!==void 0)if(g.type==="bytes")u.push("bytes32"),b=t.keccak(b),h.push(b);else if(g.type==="string")u.push("bytes32"),typeof b=="string"&&(b=Buffer.from(b,"utf8")),b=t.keccak(b),h.push(b);else if(a[g.type]!==void 0)u.push("bytes32"),b=t.keccak(this.encodeData(g.type,b,a,f)),h.push(b);else{if(g.type.lastIndexOf("]")===g.type.length-1)throw new Error("Arrays currently unimplemented in encodeData");u.push(g.type),h.push(b)}}return e.rawEncode(u,h)},encodeType(s,o){let a="",f=this.findTypeDependencies(s,o).filter(u=>u!==s);f=[s].concat(f.sort());for(const u of f){if(!o[u])throw new Error("No type definition specified: "+u);a+=u+"("+o[u].map(({name:g,type:b})=>b+" "+g).join(",")+")"}return a},findTypeDependencies(s,o,a=[]){if(s=s.match(/^\w*/)[0],a.includes(s)||o[s]===void 0)return a;a.push(s);for(const f of o[s])for(const u of this.findTypeDependencies(f.type,o,a))!a.includes(u)&&a.push(u);return a},hashStruct(s,o,a,f=!0){return t.keccak(this.encodeData(s,o,a,f))},hashType(s,o){return t.keccak(this.encodeType(s,o))},sanitizeData(s){const o={};for(const a in r.properties)s[a]&&(o[a]=s[a]);return o.types&&(o.types=Object.assign({EIP712Domain:[]},o.types)),o},hash(s,o=!0){const a=this.sanitizeData(s),f=[Buffer.from("1901","hex")];return f.push(this.hashStruct("EIP712Domain",a.domain,a.types,o)),a.primaryType!=="EIP712Domain"&&f.push(this.hashStruct(a.primaryType,a.message,a.types,o)),t.keccak(Buffer.concat(f))}};Qm={TYPED_MESSAGE_SCHEMA:r,TypedDataUtils:n,hashForSignTypedDataLegacy:function(s){return i(s.data)},hashForSignTypedData_v3:function(s){return n.hash(s.data,!1)},hashForSignTypedData_v4:function(s){return n.hash(s.data)}};function i(s){const o=new Error("Expect argument to be non-empty array");if(typeof s!="object"||!s.length)throw o;const a=s.map(function(h){return h.type==="bytes"?t.toBuffer(h.value):h.value}),f=s.map(function(h){return h.type}),u=s.map(function(h){if(!h.name)throw o;return h.type+" "+h.name});return e.soliditySHA3(["bytes32","bytes32"],[e.soliditySHA3(new Array(s.length).fill("string"),u),e.soliditySHA3(f,a)])}return Qm}var XU=JU();const td=Mi(XU),ZU="walletUsername",ev="Addresses",QU="AppVersion";function Nn(t){return t.errorMessage!==void 0}class e${constructor(e){this.secret=e}async encrypt(e){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");const n=crypto.getRandomValues(new Uint8Array(12)),i=await crypto.subtle.importKey("raw",Qh(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),s=new TextEncoder,o=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},i,s.encode(e)),a=16,f=o.slice(o.byteLength-a),u=o.slice(0,o.byteLength-a),h=new Uint8Array(f),g=new Uint8Array(u),b=new Uint8Array([...n,...h,...g]);return qm(b)}async decrypt(e){const r=this.secret;if(r.length!==64)throw Error("secret must be 256 bits");return new Promise((n,i)=>{(async function(){const s=await crypto.subtle.importKey("raw",Qh(r),{name:"aes-gcm"},!1,["encrypt","decrypt"]),o=Qh(e),a=o.slice(0,12),f=o.slice(12,28),u=o.slice(28),h=new Uint8Array([...u,...f]),g={name:"AES-GCM",iv:new Uint8Array(a)};try{const b=await window.crypto.subtle.decrypt(g,s,h),x=new TextDecoder;n(x.decode(b))}catch(b){i(b)}})()})}}class t${constructor(e,r,n){this.linkAPIUrl=e,this.sessionId=r;const i=`${r}:${n}`;this.auth=`Basic ${btoa(i)}`}async markUnseenEventsAsSeen(e){return Promise.all(e.map(r=>fetch(`${this.linkAPIUrl}/events/${r.eventId}/seen`,{method:"POST",headers:{Authorization:this.auth}}))).catch(r=>console.error("Unabled to mark event as failed:",r))}async fetchUnseenEvents(){var e;const r=await fetch(`${this.linkAPIUrl}/events?unseen=true`,{headers:{Authorization:this.auth}});if(r.ok){const{events:n,error:i}=await r.json();if(i)throw new Error(`Check unseen events failed: ${i}`);const s=(e=n?.filter(o=>o.event==="Web3Response").map(o=>({type:"Event",sessionId:this.sessionId,eventId:o.id,event:o.event,data:o.data})))!==null&&e!==void 0?e:[];return this.markUnseenEventsAsSeen(s),s}throw new Error(`Check unseen events failed: ${r.status}`)}}var Qs;(function(t){t[t.DISCONNECTED=0]="DISCONNECTED",t[t.CONNECTING=1]="CONNECTING",t[t.CONNECTED=2]="CONNECTED"})(Qs||(Qs={}));class r${setConnectionStateListener(e){this.connectionStateListener=e}setIncomingDataListener(e){this.incomingDataListener=e}constructor(e,r=WebSocket){this.WebSocketClass=r,this.webSocket=null,this.pendingData=[],this.url=e.replace(/^http/,"ws")}async connect(){if(this.webSocket)throw new Error("webSocket object is not null");return new Promise((e,r)=>{var n;let i;try{this.webSocket=i=new this.WebSocketClass(this.url)}catch(s){r(s);return}(n=this.connectionStateListener)===null||n===void 0||n.call(this,Qs.CONNECTING),i.onclose=s=>{var o;this.clearWebSocket(),r(new Error(`websocket error ${s.code}: ${s.reason}`)),(o=this.connectionStateListener)===null||o===void 0||o.call(this,Qs.DISCONNECTED)},i.onopen=s=>{var o;e(),(o=this.connectionStateListener)===null||o===void 0||o.call(this,Qs.CONNECTED),this.pendingData.length>0&&([...this.pendingData].forEach(f=>this.sendData(f)),this.pendingData=[])},i.onmessage=s=>{var o,a;if(s.data==="h")(o=this.incomingDataListener)===null||o===void 0||o.call(this,{type:"Heartbeat"});else try{const f=JSON.parse(s.data);(a=this.incomingDataListener)===null||a===void 0||a.call(this,f)}catch{}}})}disconnect(){var e;const{webSocket:r}=this;if(r){this.clearWebSocket(),(e=this.connectionStateListener)===null||e===void 0||e.call(this,Qs.DISCONNECTED),this.connectionStateListener=void 0,this.incomingDataListener=void 0;try{r.close()}catch{}}}sendData(e){const{webSocket:r}=this;if(!r){this.pendingData.push(e),this.connect();return}r.send(e)}clearWebSocket(){const{webSocket:e}=this;e&&(this.webSocket=null,e.onclose=null,e.onerror=null,e.onmessage=null,e.onopen=null)}}const c5=1e4,n$=6e4;class i${constructor({session:e,linkAPIUrl:r,listener:n}){this.destroyed=!1,this.lastHeartbeatResponse=0,this.nextReqId=Zs(1),this._connected=!1,this._linked=!1,this.shouldFetchUnseenEventsOnConnect=!1,this.requestResolutions=new Map,this.handleSessionMetadataUpdated=s=>{if(!s)return;new Map([["__destroyed",this.handleDestroyed],["EthereumAddress",this.handleAccountUpdated],["WalletUsername",this.handleWalletUsernameUpdated],["AppVersion",this.handleAppVersionUpdated],["ChainId",a=>s.JsonRpcUrl&&this.handleChainUpdated(a,s.JsonRpcUrl)]]).forEach((a,f)=>{const u=s[f];u!==void 0&&a(u)})},this.handleDestroyed=s=>{var o;s==="1"&&((o=this.listener)===null||o===void 0||o.resetAndReload())},this.handleAccountUpdated=async s=>{var o;const a=await this.cipher.decrypt(s);(o=this.listener)===null||o===void 0||o.accountUpdated(a)},this.handleMetadataUpdated=async(s,o)=>{var a;const f=await this.cipher.decrypt(o);(a=this.listener)===null||a===void 0||a.metadataUpdated(s,f)},this.handleWalletUsernameUpdated=async s=>{this.handleMetadataUpdated(ZU,s)},this.handleAppVersionUpdated=async s=>{this.handleMetadataUpdated(QU,s)},this.handleChainUpdated=async(s,o)=>{var a;const f=await this.cipher.decrypt(s),u=await this.cipher.decrypt(o);(a=this.listener)===null||a===void 0||a.chainUpdated(f,u)},this.session=e,this.cipher=new e$(e.secret),this.listener=n;const i=new r$(`${r}/rpc`,WebSocket);i.setConnectionStateListener(async s=>{let o=!1;switch(s){case Qs.DISCONNECTED:if(!this.destroyed){const a=async()=>{await new Promise(f=>setTimeout(f,5e3)),this.destroyed||i.connect().catch(()=>{a()})};a()}break;case Qs.CONNECTED:o=await this.handleConnected(),this.updateLastHeartbeat(),setInterval(()=>{this.heartbeat()},c5),this.shouldFetchUnseenEventsOnConnect&&this.fetchUnseenEventsAPI();break;case Qs.CONNECTING:break}this.connected!==o&&(this.connected=o)}),i.setIncomingDataListener(s=>{var o;switch(s.type){case"Heartbeat":this.updateLastHeartbeat();return;case"IsLinkedOK":case"Linked":{const a=s.type==="IsLinkedOK"?s.linked:void 0;this.linked=a||s.onlineGuests>0;break}case"GetSessionConfigOK":case"SessionConfigUpdated":{this.handleSessionMetadataUpdated(s.metadata);break}case"Event":{this.handleIncomingEvent(s);break}}s.id!==void 0&&((o=this.requestResolutions.get(s.id))===null||o===void 0||o(s))}),this.ws=i,this.http=new t$(r,e.id,e.key)}connect(){if(this.destroyed)throw new Error("instance is destroyed");this.ws.connect()}async destroy(){this.destroyed||(await this.makeRequest({type:"SetSessionConfig",id:Zs(this.nextReqId++),sessionId:this.session.id,metadata:{__destroyed:"1"}},{timeout:1e3}),this.destroyed=!0,this.ws.disconnect(),this.listener=void 0)}get connected(){return this._connected}set connected(e){this._connected=e}get linked(){return this._linked}set linked(e){var r,n;this._linked=e,e&&((r=this.onceLinked)===null||r===void 0||r.call(this)),(n=this.listener)===null||n===void 0||n.linkedUpdated(e)}setOnceLinked(e){return new Promise(r=>{this.linked?e().then(r):this.onceLinked=()=>{e().then(r),this.onceLinked=void 0}})}async handleIncomingEvent(e){var r;if(e.type!=="Event"||e.event!=="Web3Response")return;const n=await this.cipher.decrypt(e.data),i=JSON.parse(n);if(i.type!=="WEB3_RESPONSE")return;const{id:s,response:o}=i;(r=this.listener)===null||r===void 0||r.handleWeb3ResponseMessage(s,o)}async checkUnseenEvents(){if(!this.connected){this.shouldFetchUnseenEventsOnConnect=!0;return}await new Promise(e=>setTimeout(e,250));try{await this.fetchUnseenEventsAPI()}catch(e){console.error("Unable to check for unseen events",e)}}async fetchUnseenEventsAPI(){this.shouldFetchUnseenEventsOnConnect=!1,(await this.http.fetchUnseenEvents()).forEach(r=>this.handleIncomingEvent(r))}async publishEvent(e,r,n=!1){const i=await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({},r),{origin:location.origin,location:location.href,relaySource:"coinbaseWalletExtension"in window&&window.coinbaseWalletExtension?"injected_sdk":"sdk"}))),s={type:"PublishEvent",id:Zs(this.nextReqId++),sessionId:this.session.id,event:e,data:i,callWebhook:n};return this.setOnceLinked(async()=>{const o=await this.makeRequest(s);if(o.type==="Fail")throw new Error(o.error||"failed to publish event");return o.eventId})}sendData(e){this.ws.sendData(JSON.stringify(e))}updateLastHeartbeat(){this.lastHeartbeatResponse=Date.now()}heartbeat(){if(Date.now()-this.lastHeartbeatResponse>c5*2){this.ws.disconnect();return}try{this.ws.sendData("h")}catch{}}async makeRequest(e,r={timeout:n$}){const n=e.id;this.sendData(e);let i;return Promise.race([new Promise((s,o)=>{i=window.setTimeout(()=>{o(new Error(`request ${n} timed out`))},r.timeout)}),new Promise(s=>{this.requestResolutions.set(n,o=>{clearTimeout(i),s(o),this.requestResolutions.delete(n)})})])}async handleConnected(){return(await this.makeRequest({type:"HostSession",id:Zs(this.nextReqId++),sessionId:this.session.id,sessionKey:this.session.key})).type==="Fail"?!1:(this.sendData({type:"IsLinked",id:Zs(this.nextReqId++),sessionId:this.session.id}),this.sendData({type:"GetSessionConfig",id:Zs(this.nextReqId++),sessionId:this.session.id}),!0)}}class s${constructor(){this._nextRequestId=0,this.callbacks=new Map}makeRequestId(){this._nextRequestId=(this._nextRequestId+1)%2147483647;const e=this._nextRequestId,r=H6(e.toString(16));return this.callbacks.get(r)&&this.callbacks.delete(r),e}}const u5="session:id",f5="session:secret",l5="session:linked";class Rc{constructor(e,r,n,i=!1){this.storage=e,this.id=r,this.secret=n,this.key=cc(uw(`${r}, ${n} WalletLink`)),this._linked=!!i}static create(e){const r=Oa(16),n=Oa(32);return new Rc(e,r,n).save()}static load(e){const r=e.getItem(u5),n=e.getItem(l5),i=e.getItem(f5);return r&&i?new Rc(e,r,i,n==="1"):null}get linked(){return this._linked}set linked(e){this._linked=e,this.persistLinked()}save(){return this.storage.setItem(u5,this.id),this.storage.setItem(f5,this.secret),this.persistLinked(),this}persistLinked(){this.storage.setItem(l5,this._linked?"1":"0")}}function o$(){try{return window.frameElement!==null}catch{return!1}}function a$(){try{return o$()&&window.top?window.top.location:window.location}catch{return window.location}}function c$(){var t;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t=window?.navigator)===null||t===void 0?void 0:t.userAgent)}function h5(){var t,e;return(e=(t=window?.matchMedia)===null||t===void 0?void 0:t.call(window,"(prefers-color-scheme: dark)").matches)!==null&&e!==void 0?e:!1}const u$='@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}';function d5(){const t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode(u$)),document.documentElement.appendChild(t)}function p5(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t))for(e=0;e2&&(o.children=arguments.length>3?rd.call(arguments,2):r),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)o[s]===void 0&&(o[s]=t.defaultProps[s]);return nd(t,o,n,i,null)}function nd(t,e,r,n,i){var s={type:t,props:e,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++g5,__i:-1,__u:0};return i==null&&Vr.vnode!=null&&Vr.vnode(s),s}function jf(t){return t.children}function id(t,e){this.props=t,this.context=e}function Tc(t,e){if(e==null)return t.__?Tc(t.__,t.__i+1):null;for(var r;ee&&Na.sort(tv));sd.__r=0}function _5(t,e,r,n,i,s,o,a,f,u,h){var g,b,x,S,C,D,B=n&&n.__k||y5,L=e.length;for(f=l$(r,e,B,f),g=0;g0?nd(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=t,s.__b=t.__b+1,o=null,(f=s.__i=h$(s,r,a,g))!==-1&&(g--,(o=r[f])&&(o.__u|=2)),o==null||o.__v===null?(f==-1&&b--,typeof s.type!="function"&&(s.__u|=4)):f!==a&&(f==a-1?b--:f==a+1?b++:(f>a?b--:b++,s.__u|=4))):s=t.__k[i]=null;if(g)for(i=0;i(f!=null&&(2&f.__u)==0?1:0))for(;o>=0||a=0){if((f=e[o])&&(2&f.__u)==0&&i==f.key&&s===f.type)return o;o--}if(a=r.__.length&&r.__.push({}),r.__[t]}function B5(t){return lv=1,g$(j5,t)}function g$(t,e,r){var n=k5(ad++,2);if(n.t=t,!n.__c&&(n.__=[j5(void 0,e),function(a){var f=n.__N?n.__N[0]:n.__[0],u=n.t(f,a);f!==u&&(n.__N=[u,n.__[1]],n.__c.setState({}))}],n.__c=on,!on.u)){var i=function(a,f,u){if(!n.__c.__H)return!0;var h=n.__c.__H.__.filter(function(b){return!!b.__c});if(h.every(function(b){return!b.__N}))return!s||s.call(this,a,f,u);var g=n.__c.props!==a;return h.forEach(function(b){if(b.__N){var x=b.__[0];b.__=b.__N,b.__N=void 0,x!==b.__[0]&&(g=!0)}}),s&&s.call(this,a,f,u)||g};on.u=!0;var s=on.shouldComponentUpdate,o=on.componentWillUpdate;on.componentWillUpdate=function(a,f,u){if(this.__e){var h=s;s=void 0,i(a,f,u),s=h}o&&o.call(this,a,f,u)},on.shouldComponentUpdate=i}return n.__N||n.__}function m$(t,e){var r=k5(ad++,3);!vn.__s&&y$(r.__H,e)&&(r.__=t,r.i=e,on.__H.__h.push(r))}function v$(){for(var t;t=C5.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(cd),t.__H.__h.forEach(hv),t.__H.__h=[]}catch(e){t.__H.__h=[],vn.__e(e,t.__v)}}vn.__b=function(t){on=null,R5&&R5(t)},vn.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),L5&&L5(t,e)},vn.__r=function(t){T5&&T5(t),ad=0;var e=(on=t.__c).__H;e&&(fv===on?(e.__h=[],on.__h=[],e.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(e.__h.forEach(cd),e.__h.forEach(hv),e.__h=[],ad=0)),fv=on},vn.diffed=function(t){D5&&D5(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(C5.push(e)!==1&&M5===vn.requestAnimationFrame||((M5=vn.requestAnimationFrame)||b$)(v$)),e.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),fv=on=null},vn.__c=function(t,e){e.some(function(r){try{r.__h.forEach(cd),r.__h=r.__h.filter(function(n){return!n.__||hv(n)})}catch(n){e.some(function(i){i.__h&&(i.__h=[])}),e=[],vn.__e(n,r.__v)}}),O5&&O5(t,e)},vn.unmount=function(t){N5&&N5(t);var e,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{cd(n)}catch(i){e=i}}),r.__H=void 0,e&&vn.__e(e,r.__v))};var F5=typeof requestAnimationFrame=="function";function b$(t){var e,r=function(){clearTimeout(n),F5&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(r,100);F5&&(e=requestAnimationFrame(r))}function cd(t){var e=on,r=t.__c;typeof r=="function"&&(t.__c=void 0,r()),on=e}function hv(t){var e=on;t.__c=t.__(),on=e}function y$(t,e){return!t||t.length!==e.length||e.some(function(r,n){return r!==t[n]})}function j5(t,e){return typeof e=="function"?e(t):e}const w$=".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}",x$="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+",_$="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4=";class E${constructor(){this.items=new Map,this.nextItemKey=0,this.root=null,this.darkMode=h5()}attach(e){this.root=document.createElement("div"),this.root.className="-cbwsdk-snackbar-root",e.appendChild(this.root),this.render()}presentItem(e){const r=this.nextItemKey++;return this.items.set(r,e),this.render(),()=>{this.items.delete(r),this.render()}}clear(){this.items.clear(),this.render()}render(){this.root&&uv(Or("div",null,Or(U5,{darkMode:this.darkMode},Array.from(this.items.entries()).map(([e,r])=>Or(S$,Object.assign({},r,{key:e}))))),this.root)}}const U5=t=>Or("div",{class:Bf("-cbwsdk-snackbar-container")},Or("style",null,w$),Or("div",{class:"-cbwsdk-snackbar"},t.children)),S$=({autoExpand:t,message:e,menuItems:r})=>{const[n,i]=B5(!0),[s,o]=B5(t??!1);m$(()=>{const f=[window.setTimeout(()=>{i(!1)},1),window.setTimeout(()=>{o(!0)},1e4)];return()=>{f.forEach(window.clearTimeout)}});const a=()=>{o(!s)};return Or("div",{class:Bf("-cbwsdk-snackbar-instance",n&&"-cbwsdk-snackbar-instance-hidden",s&&"-cbwsdk-snackbar-instance-expanded")},Or("div",{class:"-cbwsdk-snackbar-instance-header",onClick:a},Or("img",{src:x$,class:"-cbwsdk-snackbar-instance-header-cblogo"})," ",Or("div",{class:"-cbwsdk-snackbar-instance-header-message"},e),Or("div",{class:"-gear-container"},!s&&Or("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Or("circle",{cx:"12",cy:"12",r:"12",fill:"#F5F7F8"})),Or("img",{src:_$,class:"-gear-icon",title:"Expand"}))),r&&r.length>0&&Or("div",{class:"-cbwsdk-snackbar-instance-menu"},r.map((f,u)=>Or("div",{class:Bf("-cbwsdk-snackbar-instance-menu-item",f.isRed&&"-cbwsdk-snackbar-instance-menu-item-is-red"),onClick:f.onClick,key:u},Or("svg",{width:f.svgWidth,height:f.svgHeight,viewBox:"0 0 10 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Or("path",{"fill-rule":f.defaultFillRule,"clip-rule":f.defaultClipRule,d:f.path,fill:"#AAAAAA"})),Or("span",{class:Bf("-cbwsdk-snackbar-instance-menu-item-info",f.isRed&&"-cbwsdk-snackbar-instance-menu-item-info-is-red")},f.info)))))};class A${constructor(){this.attached=!1,this.snackbar=new E$}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");const e=document.documentElement,r=document.createElement("div");r.className="-cbwsdk-css-reset",e.appendChild(r),this.snackbar.attach(r),this.attached=!0,d5()}showConnecting(e){let r;return e.isUnlinkedErrorState?r={autoExpand:!0,message:"Connection lost",menuItems:[{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]}:r={message:"Confirm on phone",menuItems:[{isRed:!0,info:"Cancel transaction",svgWidth:"11",svgHeight:"11",path:"M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z",defaultFillRule:"inherit",defaultClipRule:"inherit",onClick:e.onCancel},{isRed:!1,info:"Reset connection",svgWidth:"10",svgHeight:"11",path:"M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z",defaultFillRule:"evenodd",defaultClipRule:"evenodd",onClick:e.onResetConnection}]},this.snackbar.presentItem(r)}}const P$=".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}";class I${constructor(){this.root=null,this.darkMode=h5()}attach(){const e=document.documentElement;this.root=document.createElement("div"),this.root.className="-cbwsdk-css-reset",e.appendChild(this.root),d5()}present(e){this.render(e)}clear(){this.render(null)}render(e){this.root&&(uv(null,this.root),e&&uv(Or(M$,Object.assign({},e,{onDismiss:()=>{this.clear()},darkMode:this.darkMode})),this.root))}}const M$=({title:t,buttonText:e,darkMode:r,onButtonClick:n,onDismiss:i})=>{const s=r?"dark":"light";return Or(U5,{darkMode:r},Or("div",{class:"-cbwsdk-redirect-dialog"},Or("style",null,P$),Or("div",{class:"-cbwsdk-redirect-dialog-backdrop",onClick:i}),Or("div",{class:Bf("-cbwsdk-redirect-dialog-box",s)},Or("p",null,t),Or("button",{onClick:n},e))))},C$="https://keys.coinbase.com/connect",$5="https://www.walletlink.org",R$="https://go.cb-w.com/walletlink";class q5{constructor(){this.attached=!1,this.redirectDialog=new I$}attach(){if(this.attached)throw new Error("Coinbase Wallet SDK UI is already attached");this.redirectDialog.attach(),this.attached=!0}redirectToCoinbaseWallet(e){const r=new URL(R$);r.searchParams.append("redirect_url",a$().href),e&&r.searchParams.append("wl_url",e);const n=document.createElement("a");n.target="cbw-opener",n.href=r.href,n.rel="noreferrer noopener",n.click()}openCoinbaseWalletDeeplink(e){this.redirectDialog.present({title:"Redirecting to Coinbase Wallet...",buttonText:"Open",onButtonClick:()=>{this.redirectToCoinbaseWallet(e)}}),setTimeout(()=>{this.redirectToCoinbaseWallet(e)},99)}showConnecting(e){return()=>{this.redirectDialog.clear()}}}class eo{constructor(e){this.chainCallbackParams={chainId:"",jsonRpcUrl:""},this.isMobileWeb=c$(),this.linkedUpdated=s=>{this.isLinked=s;const o=this.storage.getItem(ev);if(s&&(this._session.linked=s),this.isUnlinkedErrorState=!1,o){const a=o.split(" "),f=this.storage.getItem("IsStandaloneSigning")==="true";a[0]!==""&&!s&&this._session.linked&&!f&&(this.isUnlinkedErrorState=!0)}},this.metadataUpdated=(s,o)=>{this.storage.setItem(s,o)},this.chainUpdated=(s,o)=>{this.chainCallbackParams.chainId===s&&this.chainCallbackParams.jsonRpcUrl===o||(this.chainCallbackParams={chainId:s,jsonRpcUrl:o},this.chainCallback&&this.chainCallback(o,Number.parseInt(s,10)))},this.accountUpdated=s=>{this.accountsCallback&&this.accountsCallback([s]),eo.accountRequestCallbackIds.size>0&&(Array.from(eo.accountRequestCallbackIds.values()).forEach(o=>{this.invokeCallback(o,{method:"requestEthereumAccounts",result:[s]})}),eo.accountRequestCallbackIds.clear())},this.resetAndReload=this.resetAndReload.bind(this),this.linkAPIUrl=e.linkAPIUrl,this.storage=e.storage,this.metadata=e.metadata,this.accountsCallback=e.accountsCallback,this.chainCallback=e.chainCallback;const{session:r,ui:n,connection:i}=this.subscribe();this._session=r,this.connection=i,this.relayEventManager=new s$,this.ui=n,this.ui.attach()}subscribe(){const e=Rc.load(this.storage)||Rc.create(this.storage),{linkAPIUrl:r}=this,n=new i$({session:e,linkAPIUrl:r,listener:this}),i=this.isMobileWeb?new q5:new A$;return n.connect(),{session:e,ui:i,connection:n}}resetAndReload(){this.connection.destroy().then(()=>{const e=Rc.load(this.storage);e?.id===this._session.id&&Cs.clearAll(),document.location.reload()}).catch(e=>{})}signEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:Rs(e.weiValue),data:Df(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?Rs(e.gasPriceInWei):null,maxFeePerGas:e.gasPriceInWei?Rs(e.gasPriceInWei):null,maxPriorityFeePerGas:e.gasPriceInWei?Rs(e.gasPriceInWei):null,gasLimit:e.gasLimit?Rs(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!1}})}signAndSubmitEthereumTransaction(e){return this.sendRequest({method:"signEthereumTransaction",params:{fromAddress:e.fromAddress,toAddress:e.toAddress,weiValue:Rs(e.weiValue),data:Df(e.data,!0),nonce:e.nonce,gasPriceInWei:e.gasPriceInWei?Rs(e.gasPriceInWei):null,maxFeePerGas:e.maxFeePerGas?Rs(e.maxFeePerGas):null,maxPriorityFeePerGas:e.maxPriorityFeePerGas?Rs(e.maxPriorityFeePerGas):null,gasLimit:e.gasLimit?Rs(e.gasLimit):null,chainId:e.chainId,shouldSubmit:!0}})}submitEthereumTransaction(e,r){return this.sendRequest({method:"submitEthereumTransaction",params:{signedTransaction:Df(e,!0),chainId:r}})}getWalletLinkSession(){return this._session}sendRequest(e){let r=null;const n=Oa(8),i=s=>{this.publishWeb3RequestCanceledEvent(n),this.handleErrorResponse(n,e.method,s),r?.()};return new Promise((s,o)=>{r=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:i,onResetConnection:this.resetAndReload}),this.relayEventManager.callbacks.set(n,a=>{if(r?.(),Nn(a))return o(new Error(a.errorMessage));s(a)}),this.publishWeb3RequestEvent(n,e)})}publishWeb3RequestEvent(e,r){const n={type:"WEB3_REQUEST",id:e,request:r};this.publishEvent("Web3Request",n,!0).then(i=>{}).catch(i=>{this.handleWeb3ResponseMessage(n.id,{method:r.method,errorMessage:i.message})}),this.isMobileWeb&&this.openCoinbaseWalletDeeplink(r.method)}openCoinbaseWalletDeeplink(e){if(this.ui instanceof q5)switch(e){case"requestEthereumAccounts":case"switchEthereumChain":return;default:window.addEventListener("blur",()=>{window.addEventListener("focus",()=>{this.connection.checkUnseenEvents()},{once:!0})},{once:!0}),this.ui.openCoinbaseWalletDeeplink();break}}publishWeb3RequestCanceledEvent(e){const r={type:"WEB3_REQUEST_CANCELED",id:e};this.publishEvent("Web3RequestCanceled",r,!1).then()}publishEvent(e,r,n){return this.connection.publishEvent(e,r,n)}handleWeb3ResponseMessage(e,r){if(r.method==="requestEthereumAccounts"){eo.accountRequestCallbackIds.forEach(n=>this.invokeCallback(n,r)),eo.accountRequestCallbackIds.clear();return}this.invokeCallback(e,r)}handleErrorResponse(e,r,n){var i;const s=(i=n?.message)!==null&&i!==void 0?i:"Unspecified error message.";this.handleWeb3ResponseMessage(e,{method:r,errorMessage:s})}invokeCallback(e,r){const n=this.relayEventManager.callbacks.get(e);n&&(n(r),this.relayEventManager.callbacks.delete(e))}requestEthereumAccounts(){const{appName:e,appLogoUrl:r}=this.metadata,n={method:"requestEthereumAccounts",params:{appName:e,appLogoUrl:r}},i=Oa(8);return new Promise((s,o)=>{this.relayEventManager.callbacks.set(i,a=>{if(Nn(a))return o(new Error(a.errorMessage));s(a)}),eo.accountRequestCallbackIds.add(i),this.publishWeb3RequestEvent(i,n)})}watchAsset(e,r,n,i,s,o){const a={method:"watchAsset",params:{type:e,options:{address:r,symbol:n,decimals:i,image:s},chainId:o}};let f=null;const u=Oa(8),h=g=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,a.method,g),f?.()};return f=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((g,b)=>{this.relayEventManager.callbacks.set(u,x=>{if(f?.(),Nn(x))return b(new Error(x.errorMessage));g(x)}),this.publishWeb3RequestEvent(u,a)})}addEthereumChain(e,r,n,i,s,o){const a={method:"addEthereumChain",params:{chainId:e,rpcUrls:r,blockExplorerUrls:i,chainName:s,iconUrls:n,nativeCurrency:o}};let f=null;const u=Oa(8),h=g=>{this.publishWeb3RequestCanceledEvent(u),this.handleErrorResponse(u,a.method,g),f?.()};return f=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:h,onResetConnection:this.resetAndReload}),new Promise((g,b)=>{this.relayEventManager.callbacks.set(u,x=>{if(f?.(),Nn(x))return b(new Error(x.errorMessage));g(x)}),this.publishWeb3RequestEvent(u,a)})}switchEthereumChain(e,r){const n={method:"switchEthereumChain",params:Object.assign({chainId:e},{address:r})};let i=null;const s=Oa(8),o=a=>{this.publishWeb3RequestCanceledEvent(s),this.handleErrorResponse(s,n.method,a),i?.()};return i=this.ui.showConnecting({isUnlinkedErrorState:this.isUnlinkedErrorState,onCancel:o,onResetConnection:this.resetAndReload}),new Promise((a,f)=>{this.relayEventManager.callbacks.set(s,u=>{if(i?.(),Nn(u)&&u.errorCode)return f(Ar.provider.custom({code:u.errorCode,message:"Unrecognized chain ID. Try adding the chain using addEthereumChain first."}));if(Nn(u))return f(new Error(u.errorMessage));a(u)}),this.publishWeb3RequestEvent(s,n)})}}eo.accountRequestCallbackIds=new Set;const z5="DefaultChainId",H5="DefaultJsonRpcUrl";class W5{constructor(e){this._relay=null,this._addresses=[],this.metadata=e.metadata,this._storage=new Cs("walletlink",$5),this.callback=e.callback||null;const r=this._storage.getItem(ev);if(r){const n=r.split(" ");n[0]!==""&&(this._addresses=n.map(i=>ko(i)))}this.initializeRelay()}getSession(){const e=this.initializeRelay(),{id:r,secret:n}=e.getWalletLinkSession();return{id:r,secret:n}}async handshake(){await this._eth_requestAccounts()}get selectedAddress(){return this._addresses[0]||void 0}get jsonRpcUrl(){var e;return(e=this._storage.getItem(H5))!==null&&e!==void 0?e:void 0}set jsonRpcUrl(e){this._storage.setItem(H5,e)}updateProviderInfo(e,r){var n;this.jsonRpcUrl=e;const i=this.getChainId();this._storage.setItem(z5,r.toString(10)),Of(r)!==i&&((n=this.callback)===null||n===void 0||n.call(this,"chainChanged",Lo(r)))}async watchAsset(e){const r=Array.isArray(e)?e[0]:e;if(!r.type)throw Ar.rpc.invalidParams("Type is required");if(r?.type!=="ERC20")throw Ar.rpc.invalidParams(`Asset of type '${r.type}' is not supported`);if(!r?.options)throw Ar.rpc.invalidParams("Options are required");if(!r?.options.address)throw Ar.rpc.invalidParams("Address is required");const n=this.getChainId(),{address:i,symbol:s,image:o,decimals:a}=r.options,u=await this.initializeRelay().watchAsset(r.type,i,s,a,o,n?.toString());return Nn(u)?!1:!!u.result}async addEthereumChain(e){var r,n;const i=e[0];if(((r=i.rpcUrls)===null||r===void 0?void 0:r.length)===0)throw Ar.rpc.invalidParams("please pass in at least 1 rpcUrl");if(!i.chainName||i.chainName.trim()==="")throw Ar.rpc.invalidParams("chainName is a required field");if(!i.nativeCurrency)throw Ar.rpc.invalidParams("nativeCurrency is a required field");const s=Number.parseInt(i.chainId,16);if(s===this.getChainId())return!1;const o=this.initializeRelay(),{rpcUrls:a=[],blockExplorerUrls:f=[],chainName:u,iconUrls:h=[],nativeCurrency:g}=i,b=await o.addEthereumChain(s.toString(),a,h,f,u,g);if(Nn(b))return!1;if(((n=b.result)===null||n===void 0?void 0:n.isApproved)===!0)return this.updateProviderInfo(a[0],s),null;throw Ar.rpc.internal("unable to add ethereum chain")}async switchEthereumChain(e){const r=e[0],n=Number.parseInt(r.chainId,16),s=await this.initializeRelay().switchEthereumChain(n.toString(10),this.selectedAddress||void 0);if(Nn(s))throw s;const o=s.result;return o.isApproved&&o.rpcUrl.length>0&&this.updateProviderInfo(o.rpcUrl,n),null}async cleanup(){this.callback=null,this._relay&&this._relay.resetAndReload(),this._storage.clear()}_setAddresses(e,r){var n;if(!Array.isArray(e))throw new Error("addresses is not an array");const i=e.map(s=>ko(s));JSON.stringify(i)!==JSON.stringify(this._addresses)&&(this._addresses=i,(n=this.callback)===null||n===void 0||n.call(this,"accountsChanged",i),this._storage.setItem(ev,i.join(" ")))}async request(e){const r=e.params||[];switch(e.method){case"eth_accounts":return[...this._addresses];case"eth_coinbase":return this.selectedAddress||null;case"net_version":return this.getChainId().toString(10);case"eth_chainId":return Lo(this.getChainId());case"eth_requestAccounts":return this._eth_requestAccounts();case"eth_ecRecover":case"personal_ecRecover":return this.ecRecover(e);case"personal_sign":return this.personalSign(e);case"eth_signTransaction":return this._eth_signTransaction(r);case"eth_sendRawTransaction":return this._eth_sendRawTransaction(r);case"eth_sendTransaction":return this._eth_sendTransaction(r);case"eth_signTypedData_v1":case"eth_signTypedData_v3":case"eth_signTypedData_v4":case"eth_signTypedData":return this.signTypedData(e);case"wallet_addEthereumChain":return this.addEthereumChain(r);case"wallet_switchEthereumChain":return this.switchEthereumChain(r);case"wallet_watchAsset":return this.watchAsset(r);default:if(!this.jsonRpcUrl)throw Ar.rpc.internal("No RPC URL set for chain");return Y6(e,this.jsonRpcUrl)}}_ensureKnownAddress(e){const r=ko(e);if(!this._addresses.map(i=>ko(i)).includes(r))throw new Error("Unknown Ethereum address")}_prepareTransactionParams(e){const r=e.from?ko(e.from):this.selectedAddress;if(!r)throw new Error("Ethereum address is unavailable");this._ensureKnownAddress(r);const n=e.to?ko(e.to):null,i=e.value!=null?Nf(e.value):BigInt(0),s=e.data?Km(e.data):Buffer.alloc(0),o=e.nonce!=null?Of(e.nonce):null,a=e.gasPrice!=null?Nf(e.gasPrice):null,f=e.maxFeePerGas!=null?Nf(e.maxFeePerGas):null,u=e.maxPriorityFeePerGas!=null?Nf(e.maxPriorityFeePerGas):null,h=e.gas!=null?Nf(e.gas):null,g=e.chainId?Of(e.chainId):this.getChainId();return{fromAddress:r,toAddress:n,weiValue:i,data:s,nonce:o,gasPriceInWei:a,maxFeePerGas:f,maxPriorityFeePerGas:u,gasLimit:h,chainId:g}}async ecRecover(e){const{method:r,params:n}=e;if(!Array.isArray(n))throw Ar.rpc.invalidParams();const s=await this.initializeRelay().sendRequest({method:"ethereumAddressFromSignedMessage",params:{message:zm(n[0]),signature:zm(n[1]),addPrefix:r==="personal_ecRecover"}});if(Nn(s))throw s;return s.result}getChainId(){var e;return Number.parseInt((e=this._storage.getItem(z5))!==null&&e!==void 0?e:"1",10)}async _eth_requestAccounts(){var e,r;if(this._addresses.length>0)return(e=this.callback)===null||e===void 0||e.call(this,"connect",{chainId:Lo(this.getChainId())}),this._addresses;const i=await this.initializeRelay().requestEthereumAccounts();if(Nn(i))throw i;if(!i.result)throw new Error("accounts received is empty");return this._setAddresses(i.result),(r=this.callback)===null||r===void 0||r.call(this,"connect",{chainId:Lo(this.getChainId())}),this._addresses}async personalSign({params:e}){if(!Array.isArray(e))throw Ar.rpc.invalidParams();const r=e[1],n=e[0];this._ensureKnownAddress(r);const s=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:ko(r),message:zm(n),addPrefix:!0,typedDataJson:null}});if(Nn(s))throw s;return s.result}async _eth_signTransaction(e){const r=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signEthereumTransaction(r);if(Nn(i))throw i;return i.result}async _eth_sendRawTransaction(e){const r=Km(e[0]),i=await this.initializeRelay().submitEthereumTransaction(r,this.getChainId());if(Nn(i))throw i;return i.result}async _eth_sendTransaction(e){const r=this._prepareTransactionParams(e[0]||{}),i=await this.initializeRelay().signAndSubmitEthereumTransaction(r);if(Nn(i))throw i;return i.result}async signTypedData(e){const{method:r,params:n}=e;if(!Array.isArray(n))throw Ar.rpc.invalidParams();const i=u=>{const h={eth_signTypedData_v1:td.hashForSignTypedDataLegacy,eth_signTypedData_v3:td.hashForSignTypedData_v3,eth_signTypedData_v4:td.hashForSignTypedData_v4,eth_signTypedData:td.hashForSignTypedData_v4};return Df(h[r]({data:TU(u)}),!0)},s=n[r==="eth_signTypedData_v1"?1:0],o=n[r==="eth_signTypedData_v1"?0:1];this._ensureKnownAddress(s);const f=await this.initializeRelay().sendRequest({method:"signEthereumMessage",params:{address:ko(s),message:i(o),typedDataJson:JSON.stringify(o,null,2),addPrefix:!1}});if(Nn(f))throw f;return f.result}initializeRelay(){return this._relay||(this._relay=new eo({linkAPIUrl:$5,storage:this._storage,metadata:this.metadata,accountsCallback:this._setAddresses.bind(this),chainCallback:this.updateProviderInfo.bind(this)})),this._relay}}const K5="SignerType",V5=new Cs("CBWSDK","SignerConfigurator");function T$(){return V5.getItem(K5)}function D$(t){V5.setItem(K5,t)}async function O$(t){const{communicator:e,metadata:r,handshakeRequest:n,callback:i}=t;L$(e,r,i).catch(()=>{});const s={id:crypto.randomUUID(),event:"selectSignerType",data:Object.assign(Object.assign({},t.preference),{handshakeRequest:n})},{data:o}=await e.postRequestAndWaitForResponse(s);return o}function N$(t){const{signerType:e,metadata:r,communicator:n,callback:i}=t;switch(e){case"scw":return new HU({metadata:r,callback:i,communicator:n});case"walletlink":return new W5({metadata:r,callback:i})}}async function L$(t,e,r){await t.onMessage(({event:i})=>i==="WalletLinkSessionRequest");const n=new W5({metadata:e,callback:r});t.postMessage({event:"WalletLinkUpdate",data:{session:n.getSession()}}),await n.handshake(),t.postMessage({event:"WalletLinkUpdate",data:{connected:!0}})}const k$=`Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app. -Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`,PH=()=>{let t;return{getCrossOriginOpenerPolicy:()=>t===void 0?"undefined":t,checkCrossOriginOpenerPolicy:async()=>{if(typeof window>"u"){t="non-browser-env";return}try{const e=`${window.location.origin}${window.location.pathname}`,r=await fetch(e,{method:"HEAD"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);const n=r.headers.get("Cross-Origin-Opener-Policy");t=n??"null",t==="same-origin"&&console.error(AH)}catch(e){console.error("Error checking Cross-Origin-Opener-Policy:",e.message),t="error"}}}},{checkCrossOriginOpenerPolicy:MH,getCrossOriginOpenerPolicy:IH}=PH(),v4=420,b4=540;function CH(t){const e=(window.innerWidth-v4)/2+window.screenX,r=(window.innerHeight-b4)/2+window.screenY;RH(t);const n=window.open(t,"Smart Wallet",`width=${v4}, height=${b4}, left=${e}, top=${r}`);if(n==null||n.focus(),!n)throw Sr.rpc.internal("Pop up window failed to open");return n}function TH(t){t&&!t.closed&&t.close()}function RH(t){const e={sdkName:p5,sdkVersion:kl,origin:window.location.origin,coop:IH()};for(const[r,n]of Object.entries(e))t.searchParams.append(r,n.toString())}class DH{constructor({url:e=bH,metadata:r,preference:n}){this.popup=null,this.listeners=new Map,this.postMessage=async i=>{(await this.waitForPopupLoaded()).postMessage(i,this.url.origin)},this.postRequestAndWaitForResponse=async i=>{const s=this.onMessage(({requestId:o})=>o===i.id);return this.postMessage(i),await s},this.onMessage=async i=>new Promise((s,o)=>{const a=u=>{if(u.origin!==this.url.origin)return;const l=u.data;i(l)&&(s(l),window.removeEventListener("message",a),this.listeners.delete(a))};window.addEventListener("message",a),this.listeners.set(a,{reject:o})}),this.disconnect=()=>{TH(this.popup),this.popup=null,this.listeners.forEach(({reject:i},s)=>{i(Sr.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",s)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=CH(this.url),this.onMessage(({event:i})=>i==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:i})=>i==="PopupLoaded").then(i=>{this.postMessage({requestId:i.id,data:{version:kl,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw Sr.rpc.internal();return this.popup})),this.url=new URL(e),this.metadata=r,this.preference=n}}function OH(t){const e=az(NH(t),{shouldIncludeStack:!0}),r=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return r.searchParams.set("version",kl),r.searchParams.set("code",e.code.toString()),r.searchParams.set("message",e.message),Object.assign(Object.assign({},e),{docUrl:r.href})}function NH(t){var e;if(typeof t=="string")return{message:t,code:cn.rpc.internal};if(zn(t)){const r=t.errorMessage,n=(e=t.errorCode)!==null&&e!==void 0?e:r.match(/(denied|rejected)/i)?cn.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},t),{message:r,code:n,data:{method:t.method}})}return t}var y4={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function i(u,l,d){this.fn=u,this.context=l,this.once=d||!1}function s(u,l,d,g,y){if(typeof d!="function")throw new TypeError("The listener must be a function");var A=new i(d,g||u,y),P=r?r+l:l;return u._events[P]?u._events[P].fn?u._events[P]=[u._events[P],A]:u._events[P].push(A):(u._events[P]=A,u._eventsCount++),u}function o(u,l){--u._eventsCount===0?u._events=new n:delete u._events[l]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],d,g;if(this._eventsCount===0)return l;for(g in d=this._events)e.call(d,g)&&l.push(r?g.slice(1):g);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(d)):l},a.prototype.listeners=function(l){var d=r?r+l:l,g=this._events[d];if(!g)return[];if(g.fn)return[g.fn];for(var y=0,A=g.length,P=new Array(A);y(i||(i=jH(n)),i)}}function w4(t,e){return function(){return t.apply(e,arguments)}}const{toString:HH}=Object.prototype,{getPrototypeOf:rv}=Object,d0=(t=>e=>{const r=HH.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),_s=t=>(t=t.toLowerCase(),e=>d0(e)===t),p0=t=>e=>typeof e===t,{isArray:Du}=Array,jl=p0("undefined");function WH(t){return t!==null&&!jl(t)&&t.constructor!==null&&!jl(t.constructor)&&Oi(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const x4=_s("ArrayBuffer");function KH(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&x4(t.buffer),e}const VH=p0("string"),Oi=p0("function"),_4=p0("number"),g0=t=>t!==null&&typeof t=="object",GH=t=>t===!0||t===!1,m0=t=>{if(d0(t)!=="object")return!1;const e=rv(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},YH=_s("Date"),JH=_s("File"),XH=_s("Blob"),ZH=_s("FileList"),QH=t=>g0(t)&&Oi(t.pipe),eW=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||Oi(t.append)&&((e=d0(t))==="formdata"||e==="object"&&Oi(t.toString)&&t.toString()==="[object FormData]"))},tW=_s("URLSearchParams"),[rW,nW,iW,sW]=["ReadableStream","Request","Response","Headers"].map(_s),oW=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ql(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),Du(t))for(n=0,i=t.length;n0;)if(i=r[n],e===i.toLowerCase())return i;return null}const dc=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,S4=t=>!jl(t)&&t!==dc;function nv(){const{caseless:t}=S4(this)&&this||{},e={},r=(n,i)=>{const s=t&&E4(e,i)||i;m0(e[s])&&m0(n)?e[s]=nv(e[s],n):m0(n)?e[s]=nv({},n):Du(n)?e[s]=n.slice():e[s]=n};for(let n=0,i=arguments.length;n(ql(e,(i,s)=>{r&&Oi(i)?t[s]=w4(i,r):t[s]=i},{allOwnKeys:n}),t),cW=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),uW=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},fW=(t,e,r,n)=>{let i,s,o;const a={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),s=i.length;s-- >0;)o=i[s],(!n||n(o,t,e))&&!a[o]&&(e[o]=t[o],a[o]=!0);t=r!==!1&&rv(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},lW=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},hW=t=>{if(!t)return null;if(Du(t))return t;let e=t.length;if(!_4(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},dW=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&rv(Uint8Array)),pW=(t,e)=>{const n=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(t,s[0],s[1])}},gW=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},mW=_s("HTMLFormElement"),vW=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),A4=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),bW=_s("RegExp"),P4=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};ql(r,(i,s)=>{let o;(o=e(i,s,t))!==!1&&(n[s]=o||i)}),Object.defineProperties(t,n)},yW=t=>{P4(t,(e,r)=>{if(Oi(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(Oi(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},wW=(t,e)=>{const r={},n=i=>{i.forEach(s=>{r[s]=!0})};return Du(t)?n(t):n(String(t).split(e)),r},xW=()=>{},_W=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,iv="abcdefghijklmnopqrstuvwxyz",M4="0123456789",I4={DIGIT:M4,ALPHA:iv,ALPHA_DIGIT:iv+iv.toUpperCase()+M4},EW=(t=16,e=I4.ALPHA_DIGIT)=>{let r="";const{length:n}=e;for(;t--;)r+=e[Math.random()*n|0];return r};function SW(t){return!!(t&&Oi(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const AW=t=>{const e=new Array(10),r=(n,i)=>{if(g0(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[i]=n;const s=Du(n)?[]:{};return ql(n,(o,a)=>{const u=r(o,i+1);!jl(u)&&(s[a]=u)}),e[i]=void 0,s}}return n};return r(t,0)},PW=_s("AsyncFunction"),MW=t=>t&&(g0(t)||Oi(t))&&Oi(t.then)&&Oi(t.catch),C4=((t,e)=>t?setImmediate:e?((r,n)=>(dc.addEventListener("message",({source:i,data:s})=>{i===dc&&s===r&&n.length&&n.shift()()},!1),i=>{n.push(i),dc.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Oi(dc.postMessage)),IW=typeof queueMicrotask<"u"?queueMicrotask.bind(dc):typeof process<"u"&&process.nextTick||C4,Oe={isArray:Du,isArrayBuffer:x4,isBuffer:WH,isFormData:eW,isArrayBufferView:KH,isString:VH,isNumber:_4,isBoolean:GH,isObject:g0,isPlainObject:m0,isReadableStream:rW,isRequest:nW,isResponse:iW,isHeaders:sW,isUndefined:jl,isDate:YH,isFile:JH,isBlob:XH,isRegExp:bW,isFunction:Oi,isStream:QH,isURLSearchParams:tW,isTypedArray:dW,isFileList:ZH,forEach:ql,merge:nv,extend:aW,trim:oW,stripBOM:cW,inherits:uW,toFlatObject:fW,kindOf:d0,kindOfTest:_s,endsWith:lW,toArray:hW,forEachEntry:pW,matchAll:gW,isHTMLForm:mW,hasOwnProperty:A4,hasOwnProp:A4,reduceDescriptors:P4,freezeMethods:yW,toObjectSet:wW,toCamelCase:vW,noop:xW,toFiniteNumber:_W,findKey:E4,global:dc,isContextDefined:S4,ALPHABET:I4,generateString:EW,isSpecCompliantForm:SW,toJSONObject:AW,isAsyncFn:PW,isThenable:MW,setImmediate:C4,asap:IW};function ar(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Oe.inherits(ar,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Oe.toJSONObject(this.config),code:this.code,status:this.status}}});const T4=ar.prototype,R4={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{R4[t]={value:t}}),Object.defineProperties(ar,R4),Object.defineProperty(T4,"isAxiosError",{value:!0}),ar.from=(t,e,r,n,i,s)=>{const o=Object.create(T4);return Oe.toFlatObject(t,o,function(u){return u!==Error.prototype},a=>a!=="isAxiosError"),ar.call(o,t.message,e,r,n,i),o.cause=t,o.name=t.name,s&&Object.assign(o,s),o};const CW=null;function sv(t){return Oe.isPlainObject(t)||Oe.isArray(t)}function D4(t){return Oe.endsWith(t,"[]")?t.slice(0,-2):t}function O4(t,e,r){return t?t.concat(e).map(function(i,s){return i=D4(i),!r&&s?"["+i+"]":i}).join(r?".":""):e}function TW(t){return Oe.isArray(t)&&!t.some(sv)}const RW=Oe.toFlatObject(Oe,{},null,function(e){return/^is[A-Z]/.test(e)});function v0(t,e,r){if(!Oe.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=Oe.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(N,D){return!Oe.isUndefined(D[N])});const n=r.metaTokens,i=r.visitor||d,s=r.dots,o=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&Oe.isSpecCompliantForm(e);if(!Oe.isFunction(i))throw new TypeError("visitor must be a function");function l(P){if(P===null)return"";if(Oe.isDate(P))return P.toISOString();if(!u&&Oe.isBlob(P))throw new ar("Blob is not supported. Use a Buffer instead.");return Oe.isArrayBuffer(P)||Oe.isTypedArray(P)?u&&typeof Blob=="function"?new Blob([P]):Buffer.from(P):P}function d(P,N,D){let k=P;if(P&&!D&&typeof P=="object"){if(Oe.endsWith(N,"{}"))N=n?N:N.slice(0,-2),P=JSON.stringify(P);else if(Oe.isArray(P)&&TW(P)||(Oe.isFileList(P)||Oe.endsWith(N,"[]"))&&(k=Oe.toArray(P)))return N=D4(N),k.forEach(function(q,U){!(Oe.isUndefined(q)||q===null)&&e.append(o===!0?O4([N],U,s):o===null?N:N+"[]",l(q))}),!1}return sv(P)?!0:(e.append(O4(D,N,s),l(P)),!1)}const g=[],y=Object.assign(RW,{defaultVisitor:d,convertValue:l,isVisitable:sv});function A(P,N){if(!Oe.isUndefined(P)){if(g.indexOf(P)!==-1)throw Error("Circular reference detected in "+N.join("."));g.push(P),Oe.forEach(P,function(k,$){(!(Oe.isUndefined(k)||k===null)&&i.call(e,k,Oe.isString($)?$.trim():$,N,y))===!0&&A(k,N?N.concat($):[$])}),g.pop()}}if(!Oe.isObject(t))throw new TypeError("data must be an object");return A(t),e}function N4(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function ov(t,e){this._pairs=[],t&&v0(t,this,e)}const L4=ov.prototype;L4.append=function(e,r){this._pairs.push([e,r])},L4.toString=function(e){const r=e?function(n){return e.call(this,n,N4)}:N4;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function DW(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function k4(t,e,r){if(!e)return t;const n=r&&r.encode||DW;Oe.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let s;if(i?s=i(e,r):s=Oe.isURLSearchParams(e)?e.toString():new ov(e,r).toString(n),s){const o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}class $4{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Oe.forEach(this.handlers,function(n){n!==null&&e(n)})}}const B4={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},OW={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ov,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},av=typeof window<"u"&&typeof document<"u",cv=typeof navigator=="object"&&navigator||void 0,NW=av&&(!cv||["ReactNative","NativeScript","NS"].indexOf(cv.product)<0),LW=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",kW=av&&window.location.href||"http://localhost",Xn={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:av,hasStandardBrowserEnv:NW,hasStandardBrowserWebWorkerEnv:LW,navigator:cv,origin:kW},Symbol.toStringTag,{value:"Module"})),...OW};function $W(t,e){return v0(t,new Xn.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,s){return Xn.isNode&&Oe.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},e))}function BW(t){return Oe.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function FW(t){const e={},r=Object.keys(t);let n;const i=r.length;let s;for(n=0;n=r.length;return o=!o&&Oe.isArray(i)?i.length:o,u?(Oe.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!a):((!i[o]||!Oe.isObject(i[o]))&&(i[o]=[]),e(r,n,i[o],s)&&Oe.isArray(i[o])&&(i[o]=FW(i[o])),!a)}if(Oe.isFormData(t)&&Oe.isFunction(t.entries)){const r={};return Oe.forEachEntry(t,(n,i)=>{e(BW(n),i,r,0)}),r}return null}function UW(t,e,r){if(Oe.isString(t))try{return(e||JSON.parse)(t),Oe.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const zl={transitional:B4,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const n=r.getContentType()||"",i=n.indexOf("application/json")>-1,s=Oe.isObject(e);if(s&&Oe.isHTMLForm(e)&&(e=new FormData(e)),Oe.isFormData(e))return i?JSON.stringify(F4(e)):e;if(Oe.isArrayBuffer(e)||Oe.isBuffer(e)||Oe.isStream(e)||Oe.isFile(e)||Oe.isBlob(e)||Oe.isReadableStream(e))return e;if(Oe.isArrayBufferView(e))return e.buffer;if(Oe.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return $W(e,this.formSerializer).toString();if((a=Oe.isFileList(e))||n.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return v0(a?{"files[]":e}:e,u&&new u,this.formSerializer)}}return s||i?(r.setContentType("application/json",!1),UW(e)):e}],transformResponse:[function(e){const r=this.transitional||zl.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Oe.isResponse(e)||Oe.isReadableStream(e))return e;if(e&&Oe.isString(e)&&(n&&!this.responseType||i)){const o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?ar.from(a,ar.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Xn.classes.FormData,Blob:Xn.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Oe.forEach(["delete","get","head","post","put","patch"],t=>{zl.headers[t]={}});const jW=Oe.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),qW=t=>{const e={};let r,n,i;return t&&t.split(` -`).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||e[r]&&jW[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e},U4=Symbol("internals");function Hl(t){return t&&String(t).trim().toLowerCase()}function b0(t){return t===!1||t==null?t:Oe.isArray(t)?t.map(b0):String(t)}function zW(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}const HW=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function uv(t,e,r,n,i){if(Oe.isFunction(n))return n.call(this,e,r);if(i&&(e=r),!!Oe.isString(e)){if(Oe.isString(n))return e.indexOf(n)!==-1;if(Oe.isRegExp(n))return n.test(e)}}function WW(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,n)=>r.toUpperCase()+n)}function KW(t,e){const r=Oe.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(i,s,o){return this[n].call(this,e,i,s,o)},configurable:!0})})}let wi=class{constructor(e){e&&this.set(e)}set(e,r,n){const i=this;function s(a,u,l){const d=Hl(u);if(!d)throw new Error("header name must be a non-empty string");const g=Oe.findKey(i,d);(!g||i[g]===void 0||l===!0||l===void 0&&i[g]!==!1)&&(i[g||u]=b0(a))}const o=(a,u)=>Oe.forEach(a,(l,d)=>s(l,d,u));if(Oe.isPlainObject(e)||e instanceof this.constructor)o(e,r);else if(Oe.isString(e)&&(e=e.trim())&&!HW(e))o(qW(e),r);else if(Oe.isHeaders(e))for(const[a,u]of e.entries())s(u,a,n);else e!=null&&s(r,e,n);return this}get(e,r){if(e=Hl(e),e){const n=Oe.findKey(this,e);if(n){const i=this[n];if(!r)return i;if(r===!0)return zW(i);if(Oe.isFunction(r))return r.call(this,i,n);if(Oe.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=Hl(e),e){const n=Oe.findKey(this,e);return!!(n&&this[n]!==void 0&&(!r||uv(this,this[n],n,r)))}return!1}delete(e,r){const n=this;let i=!1;function s(o){if(o=Hl(o),o){const a=Oe.findKey(n,o);a&&(!r||uv(n,n[a],a,r))&&(delete n[a],i=!0)}}return Oe.isArray(e)?e.forEach(s):s(e),i}clear(e){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const s=r[n];(!e||uv(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const r=this,n={};return Oe.forEach(this,(i,s)=>{const o=Oe.findKey(n,s);if(o){r[o]=b0(i),delete r[s];return}const a=e?WW(s):String(s).trim();a!==s&&delete r[s],r[a]=b0(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const r=Object.create(null);return Oe.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=e&&Oe.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(` -`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const n=new this(e);return r.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[U4]=this[U4]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=Hl(o);n[a]||(KW(i,o),n[a]=!0)}return Oe.isArray(e)?e.forEach(s):s(e),this}};wi.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Oe.reduceDescriptors(wi.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}}),Oe.freezeMethods(wi);function fv(t,e){const r=this||zl,n=e||r,i=wi.from(n.headers);let s=n.data;return Oe.forEach(t,function(a){s=a.call(r,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function j4(t){return!!(t&&t.__CANCEL__)}function Ou(t,e,r){ar.call(this,t??"canceled",ar.ERR_CANCELED,e,r),this.name="CanceledError"}Oe.inherits(Ou,ar,{__CANCEL__:!0});function q4(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new ar("Request failed with status code "+r.status,[ar.ERR_BAD_REQUEST,ar.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function VW(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function GW(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(u){const l=Date.now(),d=n[s];o||(o=l),r[i]=u,n[i]=l;let g=s,y=0;for(;g!==i;)y+=r[g++],g=g%t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),l-o{r=d,i=null,s&&(clearTimeout(s),s=null),t.apply(null,l)};return[(...l)=>{const d=Date.now(),g=d-r;g>=n?o(l,d):(i=l,s||(s=setTimeout(()=>{s=null,o(i)},n-g)))},()=>i&&o(i)]}const y0=(t,e,r=3)=>{let n=0;const i=GW(50,250);return YW(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,u=o-n,l=i(u),d=o<=a;n=o;const g={loaded:o,total:a,progress:a?o/a:void 0,bytes:u,rate:l||void 0,estimated:l&&a&&d?(a-o)/l:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(g)},r)},z4=(t,e)=>{const r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},H4=t=>(...e)=>Oe.asap(()=>t(...e)),JW=Xn.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,Xn.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(Xn.origin),Xn.navigator&&/(msie|trident)/i.test(Xn.navigator.userAgent)):()=>!0,XW=Xn.hasStandardBrowserEnv?{write(t,e,r,n,i,s){const o=[t+"="+encodeURIComponent(e)];Oe.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Oe.isString(n)&&o.push("path="+n),Oe.isString(i)&&o.push("domain="+i),s===!0&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function ZW(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function QW(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function W4(t,e){return t&&!ZW(e)?QW(t,e):e}const K4=t=>t instanceof wi?{...t}:t;function pc(t,e){e=e||{};const r={};function n(l,d,g,y){return Oe.isPlainObject(l)&&Oe.isPlainObject(d)?Oe.merge.call({caseless:y},l,d):Oe.isPlainObject(d)?Oe.merge({},d):Oe.isArray(d)?d.slice():d}function i(l,d,g,y){if(Oe.isUndefined(d)){if(!Oe.isUndefined(l))return n(void 0,l,g,y)}else return n(l,d,g,y)}function s(l,d){if(!Oe.isUndefined(d))return n(void 0,d)}function o(l,d){if(Oe.isUndefined(d)){if(!Oe.isUndefined(l))return n(void 0,l)}else return n(void 0,d)}function a(l,d,g){if(g in e)return n(l,d);if(g in t)return n(void 0,l)}const u={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(l,d,g)=>i(K4(l),K4(d),g,!0)};return Oe.forEach(Object.keys(Object.assign({},t,e)),function(d){const g=u[d]||i,y=g(t[d],e[d],d);Oe.isUndefined(y)&&g!==a||(r[d]=y)}),r}const V4=t=>{const e=pc({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=e;e.headers=o=wi.from(o),e.url=k4(W4(e.baseURL,e.url),t.params,t.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(Oe.isFormData(r)){if(Xn.hasStandardBrowserEnv||Xn.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((u=o.getContentType())!==!1){const[l,...d]=u?u.split(";").map(g=>g.trim()).filter(Boolean):[];o.setContentType([l||"multipart/form-data",...d].join("; "))}}if(Xn.hasStandardBrowserEnv&&(n&&Oe.isFunction(n)&&(n=n(e)),n||n!==!1&&JW(e.url))){const l=i&&s&&XW.read(s);l&&o.set(i,l)}return e},eK=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){const i=V4(t);let s=i.data;const o=wi.from(i.headers).normalize();let{responseType:a,onUploadProgress:u,onDownloadProgress:l}=i,d,g,y,A,P;function N(){A&&A(),P&&P(),i.cancelToken&&i.cancelToken.unsubscribe(d),i.signal&&i.signal.removeEventListener("abort",d)}let D=new XMLHttpRequest;D.open(i.method.toUpperCase(),i.url,!0),D.timeout=i.timeout;function k(){if(!D)return;const q=wi.from("getAllResponseHeaders"in D&&D.getAllResponseHeaders()),K={data:!a||a==="text"||a==="json"?D.responseText:D.response,status:D.status,statusText:D.statusText,headers:q,config:t,request:D};q4(function(T){r(T),N()},function(T){n(T),N()},K),D=null}"onloadend"in D?D.onloadend=k:D.onreadystatechange=function(){!D||D.readyState!==4||D.status===0&&!(D.responseURL&&D.responseURL.indexOf("file:")===0)||setTimeout(k)},D.onabort=function(){D&&(n(new ar("Request aborted",ar.ECONNABORTED,t,D)),D=null)},D.onerror=function(){n(new ar("Network Error",ar.ERR_NETWORK,t,D)),D=null},D.ontimeout=function(){let U=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const K=i.transitional||B4;i.timeoutErrorMessage&&(U=i.timeoutErrorMessage),n(new ar(U,K.clarifyTimeoutError?ar.ETIMEDOUT:ar.ECONNABORTED,t,D)),D=null},s===void 0&&o.setContentType(null),"setRequestHeader"in D&&Oe.forEach(o.toJSON(),function(U,K){D.setRequestHeader(K,U)}),Oe.isUndefined(i.withCredentials)||(D.withCredentials=!!i.withCredentials),a&&a!=="json"&&(D.responseType=i.responseType),l&&([y,P]=y0(l,!0),D.addEventListener("progress",y)),u&&D.upload&&([g,A]=y0(u),D.upload.addEventListener("progress",g),D.upload.addEventListener("loadend",A)),(i.cancelToken||i.signal)&&(d=q=>{D&&(n(!q||q.type?new Ou(null,t,D):q),D.abort(),D=null)},i.cancelToken&&i.cancelToken.subscribe(d),i.signal&&(i.signal.aborted?d():i.signal.addEventListener("abort",d)));const $=VW(i.url);if($&&Xn.protocols.indexOf($)===-1){n(new ar("Unsupported protocol "+$+":",ar.ERR_BAD_REQUEST,t));return}D.send(s||null)})},tK=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,i;const s=function(l){if(!i){i=!0,a();const d=l instanceof Error?l:this.reason;n.abort(d instanceof ar?d:new Ou(d instanceof Error?d.message:d))}};let o=e&&setTimeout(()=>{o=null,s(new ar(`timeout ${e} of ms exceeded`,ar.ETIMEDOUT))},e);const a=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(l=>{l.unsubscribe?l.unsubscribe(s):l.removeEventListener("abort",s)}),t=null)};t.forEach(l=>l.addEventListener("abort",s));const{signal:u}=n;return u.unsubscribe=()=>Oe.asap(a),u}},rK=function*(t,e){let r=t.byteLength;if(r{const i=nK(t,e);let s=0,o,a=u=>{o||(o=!0,n&&n(u))};return new ReadableStream({async pull(u){try{const{done:l,value:d}=await i.next();if(l){a(),u.close();return}let g=d.byteLength;if(r){let y=s+=g;r(y)}u.enqueue(new Uint8Array(d))}catch(l){throw a(l),l}},cancel(u){return a(u),i.return()}},{highWaterMark:2})},w0=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Y4=w0&&typeof ReadableStream=="function",sK=w0&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),J4=(t,...e)=>{try{return!!t(...e)}catch{return!1}},oK=Y4&&J4(()=>{let t=!1;const e=new Request(Xn.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),X4=64*1024,lv=Y4&&J4(()=>Oe.isReadableStream(new Response("").body)),x0={stream:lv&&(t=>t.body)};w0&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!x0[e]&&(x0[e]=Oe.isFunction(t[e])?r=>r[e]():(r,n)=>{throw new ar(`Response type '${e}' is not supported`,ar.ERR_NOT_SUPPORT,n)})})})(new Response);const aK=async t=>{if(t==null)return 0;if(Oe.isBlob(t))return t.size;if(Oe.isSpecCompliantForm(t))return(await new Request(Xn.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(Oe.isArrayBufferView(t)||Oe.isArrayBuffer(t))return t.byteLength;if(Oe.isURLSearchParams(t)&&(t=t+""),Oe.isString(t))return(await sK(t)).byteLength},cK=async(t,e)=>{const r=Oe.toFiniteNumber(t.getContentLength());return r??aK(e)},hv={http:CW,xhr:eK,fetch:w0&&(async t=>{let{url:e,method:r,data:n,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:u,responseType:l,headers:d,withCredentials:g="same-origin",fetchOptions:y}=V4(t);l=l?(l+"").toLowerCase():"text";let A=tK([i,s&&s.toAbortSignal()],o),P;const N=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let D;try{if(u&&oK&&r!=="get"&&r!=="head"&&(D=await cK(d,n))!==0){let K=new Request(e,{method:"POST",body:n,duplex:"half"}),J;if(Oe.isFormData(n)&&(J=K.headers.get("content-type"))&&d.setContentType(J),K.body){const[T,z]=z4(D,y0(H4(u)));n=G4(K.body,X4,T,z)}}Oe.isString(g)||(g=g?"include":"omit");const k="credentials"in Request.prototype;P=new Request(e,{...y,signal:A,method:r.toUpperCase(),headers:d.normalize().toJSON(),body:n,duplex:"half",credentials:k?g:void 0});let $=await fetch(P);const q=lv&&(l==="stream"||l==="response");if(lv&&(a||q&&N)){const K={};["status","statusText","headers"].forEach(ue=>{K[ue]=$[ue]});const J=Oe.toFiniteNumber($.headers.get("content-length")),[T,z]=a&&z4(J,y0(H4(a),!0))||[];$=new Response(G4($.body,X4,T,()=>{z&&z(),N&&N()}),K)}l=l||"text";let U=await x0[Oe.findKey(x0,l)||"text"]($,t);return!q&&N&&N(),await new Promise((K,J)=>{q4(K,J,{data:U,headers:wi.from($.headers),status:$.status,statusText:$.statusText,config:t,request:P})})}catch(k){throw N&&N(),k&&k.name==="TypeError"&&/fetch/i.test(k.message)?Object.assign(new ar("Network Error",ar.ERR_NETWORK,t,P),{cause:k.cause||k}):ar.from(k,k&&k.code,t,P)}})};Oe.forEach(hv,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Z4=t=>`- ${t}`,uK=t=>Oe.isFunction(t)||t===null||t===!1,Q4={getAdapter:t=>{t=Oe.isArray(t)?t:[t];const{length:e}=t;let r,n;const i={};for(let s=0;s`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=e?s.length>1?`since : -`+s.map(Z4).join(` -`):" "+Z4(s[0]):"as no adapter specified";throw new ar("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n},adapters:hv};function dv(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ou(null,t)}function e8(t){return dv(t),t.headers=wi.from(t.headers),t.data=fv.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Q4.getAdapter(t.adapter||zl.adapter)(t).then(function(n){return dv(t),n.data=fv.call(t,t.transformResponse,n),n.headers=wi.from(n.headers),n},function(n){return j4(n)||(dv(t),n&&n.response&&(n.response.data=fv.call(t,t.transformResponse,n.response),n.response.headers=wi.from(n.response.headers))),Promise.reject(n)})}const t8="1.7.8",_0={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{_0[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const r8={};_0.transitional=function(e,r,n){function i(s,o){return"[Axios v"+t8+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return(s,o,a)=>{if(e===!1)throw new ar(i(o," has been removed"+(r?" in "+r:"")),ar.ERR_DEPRECATED);return r&&!r8[o]&&(r8[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,o,a):!0}},_0.spelling=function(e){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function fK(t,e,r){if(typeof t!="object")throw new ar("options must be an object",ar.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const s=n[i],o=e[s];if(o){const a=t[s],u=a===void 0||o(a,s,t);if(u!==!0)throw new ar("option "+s+" must be "+u,ar.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new ar("Unknown option "+s,ar.ERR_BAD_OPTION)}}const E0={assertOptions:fK,validators:_0},Xs=E0.validators;let gc=class{constructor(e){this.defaults=e,this.interceptors={request:new $4,response:new $4}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=` -`+s):n.stack=s}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=pc(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:s}=r;n!==void 0&&E0.assertOptions(n,{silentJSONParsing:Xs.transitional(Xs.boolean),forcedJSONParsing:Xs.transitional(Xs.boolean),clarifyTimeoutError:Xs.transitional(Xs.boolean)},!1),i!=null&&(Oe.isFunction(i)?r.paramsSerializer={serialize:i}:E0.assertOptions(i,{encode:Xs.function,serialize:Xs.function},!0)),E0.assertOptions(r,{baseUrl:Xs.spelling("baseURL"),withXsrfToken:Xs.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=s&&Oe.merge(s.common,s[r.method]);s&&Oe.forEach(["delete","get","head","post","put","patch","common"],P=>{delete s[P]}),r.headers=wi.concat(o,s);const a=[];let u=!0;this.interceptors.request.forEach(function(N){typeof N.runWhen=="function"&&N.runWhen(r)===!1||(u=u&&N.synchronous,a.unshift(N.fulfilled,N.rejected))});const l=[];this.interceptors.response.forEach(function(N){l.push(N.fulfilled,N.rejected)});let d,g=0,y;if(!u){const P=[e8.bind(this),void 0];for(P.unshift.apply(P,a),P.push.apply(P,l),y=P.length,d=Promise.resolve(r);g{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},e(function(s,o,a){n.reason||(n.reason=new Ou(s,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new FA(function(i){e=i}),cancel:e}}};function hK(t){return function(r){return t.apply(null,r)}}function dK(t){return Oe.isObject(t)&&t.isAxiosError===!0}const pv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(pv).forEach(([t,e])=>{pv[e]=t});function n8(t){const e=new gc(t),r=w4(gc.prototype.request,e);return Oe.extend(r,gc.prototype,e,{allOwnKeys:!0}),Oe.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return n8(pc(t,i))},r}const fn=n8(zl);fn.Axios=gc,fn.CanceledError=Ou,fn.CancelToken=lK,fn.isCancel=j4,fn.VERSION=t8,fn.toFormData=v0,fn.AxiosError=ar,fn.Cancel=fn.CanceledError,fn.all=function(e){return Promise.all(e)},fn.spread=hK,fn.isAxiosError=dK,fn.mergeConfig=pc,fn.AxiosHeaders=wi,fn.formToJSON=t=>F4(Oe.isHTMLForm(t)?new FormData(t):t),fn.getAdapter=Q4.getAdapter,fn.HttpStatusCode=pv,fn.default=fn;const{Axios:Roe,AxiosError:pK,CanceledError:Doe,isCancel:Ooe,CancelToken:Noe,VERSION:Loe,all:koe,Cancel:$oe,isAxiosError:Boe,spread:Foe,toFormData:Uoe,AxiosHeaders:joe,HttpStatusCode:qoe,formToJSON:zoe,getAdapter:Hoe,mergeConfig:Woe}=fn,i8=fn.create({timeout:6e4,headers:{"Content-Type":"application/json"}});function gK(t){var e,r,n;if(((e=t.data)==null?void 0:e.success)!==!0){const i=new pK((r=t.data)==null?void 0:r.errorMessage,(n=t.data)==null?void 0:n.errorCode,t.config,t.request,t);return Promise.reject(i)}else return t}i8.interceptors.response.use(gK);class mK{constructor(e){so(this,"_apiBase","");this.request=e}setApiBase(e){this._apiBase=e||""}async getNonce(e){const{data:r}=await this.request.post(`${this._apiBase}/api/v2/user/nonce`,e);return r.data}async getEmailCode(e){const{data:r}=await this.request.post(`${this._apiBase}/api/v2/user/get_code`,e);return r.data}async emailLogin(e){return(await this.request.post(`${this._apiBase}/api/v2/user/login`,e)).data}async walletLogin(e){return(await this.request.post(`${this._apiBase}/api/v2/user/login`,e)).data}async tonLogin(e){return(await this.request.post(`${this._apiBase}/api/v2/user/login`,e)).data}}const ma=new mK(i8),vK={projectId:"7a4434fefbcc9af474fb5c995e47d286",metadata:{name:"codatta",description:"codatta",url:"https://codatta.io/",icons:["https://avatars.githubusercontent.com/u/171659315"]}},s8=zH({appName:"codatta",appLogoUrl:"https://avatars.githubusercontent.com/u/171659315"}),o8=Pe.createContext({saveLastUsedWallet:()=>{},lastUsedWallet:null,wallets:[],initialized:!1,featuredWallets:[]});function Wl(){return Pe.useContext(o8)}function bK(t){const{apiBaseUrl:e}=t,[r,n]=Pe.useState([]),[i,s]=Pe.useState([]),[o,a]=Pe.useState(null),[u,l]=Pe.useState(!1),d=A=>{console.log("saveLastUsedWallet",A)};function g(A){const P=A.filter(k=>k.featured||k.installed),N=A.filter(k=>!k.featured&&!k.installed),D=[...P,...N];n(D),s(P)}async function y(){const A=[],P=new Map;qA.forEach(D=>{const k=new Hf(D);D.name==="Coinbase Wallet"&&k.EIP6963Detected({info:{name:"Coinbase Wallet",uuid:"coinbase",icon:D.image,rdns:"coinbase"},provider:s8.getProvider()}),P.set(k.key,k),A.push(k)}),(await iz()).forEach(D=>{const k=P.get(D.info.name);if(k)k.EIP6963Detected(D);else{const $=new Hf(D);P.set($.key,$),A.push($)}});try{const D=JSON.parse(localStorage.getItem("xn-last-used-info")||"{}"),k=P.get(D.key);if(k){if(k.lastUsed=!0,D.provider==="UniversalProvider"){const $=await Q6.init(vK);$.session&&k.setUniversalProvider($)}a(k)}}catch(D){console.log(D)}g(A),l(!0)}return Pe.useEffect(()=>{y(),ma.setApiBase(e)},[]),me.jsx(o8.Provider,{value:{saveLastUsedWallet:d,wallets:r,initialized:u,lastUsedWallet:o,featuredWallets:i},children:t.children})}/** +Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`,B$=()=>{let t;return{getCrossOriginOpenerPolicy:()=>t===void 0?"undefined":t,checkCrossOriginOpenerPolicy:async()=>{if(typeof window>"u"){t="non-browser-env";return}try{const e=`${window.location.origin}${window.location.pathname}`,r=await fetch(e,{method:"HEAD"});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);const n=r.headers.get("Cross-Origin-Opener-Policy");t=n??"null",t==="same-origin"&&console.error(k$)}catch(e){console.error("Error checking Cross-Origin-Opener-Policy:",e.message),t="error"}}}},{checkCrossOriginOpenerPolicy:F$,getCrossOriginOpenerPolicy:j$}=B$(),G5=420,Y5=540;function U$(t){const e=(window.innerWidth-G5)/2+window.screenX,r=(window.innerHeight-Y5)/2+window.screenY;q$(t);const n=window.open(t,"Smart Wallet",`width=${G5}, height=${Y5}, left=${e}, top=${r}`);if(n?.focus(),!n)throw Ar.rpc.internal("Pop up window failed to open");return n}function $$(t){t&&!t.closed&&t.close()}function q$(t){const e={sdkName:G6,sdkVersion:Lf,origin:window.location.origin,coop:j$()};for(const[r,n]of Object.entries(e))t.searchParams.append(r,n.toString())}class z${constructor({url:e=C$,metadata:r,preference:n}){this.popup=null,this.listeners=new Map,this.postMessage=async i=>{(await this.waitForPopupLoaded()).postMessage(i,this.url.origin)},this.postRequestAndWaitForResponse=async i=>{const s=this.onMessage(({requestId:o})=>o===i.id);return this.postMessage(i),await s},this.onMessage=async i=>new Promise((s,o)=>{const a=f=>{if(f.origin!==this.url.origin)return;const u=f.data;i(u)&&(s(u),window.removeEventListener("message",a),this.listeners.delete(a))};window.addEventListener("message",a),this.listeners.set(a,{reject:o})}),this.disconnect=()=>{$$(this.popup),this.popup=null,this.listeners.forEach(({reject:i},s)=>{i(Ar.provider.userRejectedRequest("Request rejected")),window.removeEventListener("message",s)}),this.listeners.clear()},this.waitForPopupLoaded=async()=>this.popup&&!this.popup.closed?(this.popup.focus(),this.popup):(this.popup=U$(this.url),this.onMessage(({event:i})=>i==="PopupUnload").then(this.disconnect).catch(()=>{}),this.onMessage(({event:i})=>i==="PopupLoaded").then(i=>{this.postMessage({requestId:i.id,data:{version:Lf,metadata:this.metadata,preference:this.preference,location:window.location.toString()}})}).then(()=>{if(!this.popup)throw Ar.rpc.internal();return this.popup})),this.url=new URL(e),this.metadata=r,this.preference=n}}function H$(t){const e=PU(W$(t),{shouldIncludeStack:!0}),r=new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors");return r.searchParams.set("version",Lf),r.searchParams.set("code",e.code.toString()),r.searchParams.set("message",e.message),Object.assign(Object.assign({},e),{docUrl:r.href})}function W$(t){var e;if(typeof t=="string")return{message:t,code:sn.rpc.internal};if(Nn(t)){const r=t.errorMessage,n=(e=t.errorCode)!==null&&e!==void 0?e:r.match(/(denied|rejected)/i)?sn.provider.userRejectedRequest:void 0;return Object.assign(Object.assign({},t),{message:r,code:n,data:{method:t.method}})}return t}var dv={exports:{}},J5;function K$(){return J5||(J5=1,(function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function i(f,u,h){this.fn=f,this.context=u,this.once=h||!1}function s(f,u,h,g,b){if(typeof h!="function")throw new TypeError("The listener must be a function");var x=new i(h,g||f,b),S=r?r+u:u;return f._events[S]?f._events[S].fn?f._events[S]=[f._events[S],x]:f._events[S].push(x):(f._events[S]=x,f._eventsCount++),f}function o(f,u){--f._eventsCount===0?f._events=new n:delete f._events[u]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var u=[],h,g;if(this._eventsCount===0)return u;for(g in h=this._events)e.call(h,g)&&u.push(r?g.slice(1):g);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(h)):u},a.prototype.listeners=function(u){var h=r?r+u:u,g=this._events[h];if(!g)return[];if(g.fn)return[g.fn];for(var b=0,x=g.length,S=new Array(x);b(i||(i=Q$(n)),i)}}function X5(t,e){return function(){return t.apply(e,arguments)}}const{toString:rq}=Object.prototype,{getPrototypeOf:pv}=Object,ud=(t=>e=>{const r=rq.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),fs=t=>(t=t.toLowerCase(),e=>ud(e)===t),fd=t=>e=>typeof e===t,{isArray:Dc}=Array,Uf=fd("undefined");function nq(t){return t!==null&&!Uf(t)&&t.constructor!==null&&!Uf(t.constructor)&&wi(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Z5=fs("ArrayBuffer");function iq(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Z5(t.buffer),e}const sq=fd("string"),wi=fd("function"),Q5=fd("number"),ld=t=>t!==null&&typeof t=="object",oq=t=>t===!0||t===!1,hd=t=>{if(ud(t)!=="object")return!1;const e=pv(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},aq=fs("Date"),cq=fs("File"),uq=fs("Blob"),fq=fs("FileList"),lq=t=>ld(t)&&wi(t.pipe),hq=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||wi(t.append)&&((e=ud(t))==="formdata"||e==="object"&&wi(t.toString)&&t.toString()==="[object FormData]"))},dq=fs("URLSearchParams"),[pq,gq,mq,vq]=["ReadableStream","Request","Response","Headers"].map(fs),bq=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function $f(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),Dc(t))for(n=0,i=t.length;n0;)if(i=r[n],e===i.toLowerCase())return i;return null}const La=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,t4=t=>!Uf(t)&&t!==La;function gv(){const{caseless:t}=t4(this)&&this||{},e={},r=(n,i)=>{const s=t&&e4(e,i)||i;hd(e[s])&&hd(n)?e[s]=gv(e[s],n):hd(n)?e[s]=gv({},n):Dc(n)?e[s]=n.slice():e[s]=n};for(let n=0,i=arguments.length;n($f(e,(i,s)=>{r&&wi(i)?t[s]=X5(i,r):t[s]=i},{allOwnKeys:n}),t),wq=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),xq=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},_q=(t,e,r,n)=>{let i,s,o;const a={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),s=i.length;s-- >0;)o=i[s],(!n||n(o,t,e))&&!a[o]&&(e[o]=t[o],a[o]=!0);t=r!==!1&&pv(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},Eq=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},Sq=t=>{if(!t)return null;if(Dc(t))return t;let e=t.length;if(!Q5(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},Aq=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&pv(Uint8Array)),Pq=(t,e)=>{const n=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(t,s[0],s[1])}},Iq=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},Mq=fs("HTMLFormElement"),Cq=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),r4=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),Rq=fs("RegExp"),n4=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};$f(r,(i,s)=>{let o;(o=e(i,s,t))!==!1&&(n[s]=o||i)}),Object.defineProperties(t,n)},Tq=t=>{n4(t,(e,r)=>{if(wi(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(wi(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Dq=(t,e)=>{const r={},n=i=>{i.forEach(s=>{r[s]=!0})};return Dc(t)?n(t):n(String(t).split(e)),r},Oq=()=>{},Nq=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e,mv="abcdefghijklmnopqrstuvwxyz",i4="0123456789",s4={DIGIT:i4,ALPHA:mv,ALPHA_DIGIT:mv+mv.toUpperCase()+i4},Lq=(t=16,e=s4.ALPHA_DIGIT)=>{let r="";const{length:n}=e;for(;t--;)r+=e[Math.random()*n|0];return r};function kq(t){return!!(t&&wi(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator])}const Bq=t=>{const e=new Array(10),r=(n,i)=>{if(ld(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[i]=n;const s=Dc(n)?[]:{};return $f(n,(o,a)=>{const f=r(o,i+1);!Uf(f)&&(s[a]=f)}),e[i]=void 0,s}}return n};return r(t,0)},Fq=fs("AsyncFunction"),jq=t=>t&&(ld(t)||wi(t))&&wi(t.then)&&wi(t.catch),o4=((t,e)=>t?setImmediate:e?((r,n)=>(La.addEventListener("message",({source:i,data:s})=>{i===La&&s===r&&n.length&&n.shift()()},!1),i=>{n.push(i),La.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",wi(La.postMessage)),Uq=typeof queueMicrotask<"u"?queueMicrotask.bind(La):typeof process<"u"&&process.nextTick||o4,Le={isArray:Dc,isArrayBuffer:Z5,isBuffer:nq,isFormData:hq,isArrayBufferView:iq,isString:sq,isNumber:Q5,isBoolean:oq,isObject:ld,isPlainObject:hd,isReadableStream:pq,isRequest:gq,isResponse:mq,isHeaders:vq,isUndefined:Uf,isDate:aq,isFile:cq,isBlob:uq,isRegExp:Rq,isFunction:wi,isStream:lq,isURLSearchParams:dq,isTypedArray:Aq,isFileList:fq,forEach:$f,merge:gv,extend:yq,trim:bq,stripBOM:wq,inherits:xq,toFlatObject:_q,kindOf:ud,kindOfTest:fs,endsWith:Eq,toArray:Sq,forEachEntry:Pq,matchAll:Iq,isHTMLForm:Mq,hasOwnProperty:r4,hasOwnProp:r4,reduceDescriptors:n4,freezeMethods:Tq,toObjectSet:Dq,toCamelCase:Cq,noop:Oq,toFiniteNumber:Nq,findKey:e4,global:La,isContextDefined:t4,ALPHABET:s4,generateString:Lq,isSpecCompliantForm:kq,toJSONObject:Bq,isAsyncFn:Fq,isThenable:jq,setImmediate:o4,asap:Uq};function ar(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}Le.inherits(ar,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Le.toJSONObject(this.config),code:this.code,status:this.status}}});const a4=ar.prototype,c4={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{c4[t]={value:t}}),Object.defineProperties(ar,c4),Object.defineProperty(a4,"isAxiosError",{value:!0}),ar.from=(t,e,r,n,i,s)=>{const o=Object.create(a4);return Le.toFlatObject(t,o,function(f){return f!==Error.prototype},a=>a!=="isAxiosError"),ar.call(o,t.message,e,r,n,i),o.cause=t,o.name=t.name,s&&Object.assign(o,s),o};const $q=null;function vv(t){return Le.isPlainObject(t)||Le.isArray(t)}function u4(t){return Le.endsWith(t,"[]")?t.slice(0,-2):t}function f4(t,e,r){return t?t.concat(e).map(function(i,s){return i=u4(i),!r&&s?"["+i+"]":i}).join(r?".":""):e}function qq(t){return Le.isArray(t)&&!t.some(vv)}const zq=Le.toFlatObject(Le,{},null,function(e){return/^is[A-Z]/.test(e)});function dd(t,e,r){if(!Le.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,r=Le.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(C,D){return!Le.isUndefined(D[C])});const n=r.metaTokens,i=r.visitor||h,s=r.dots,o=r.indexes,f=(r.Blob||typeof Blob<"u"&&Blob)&&Le.isSpecCompliantForm(e);if(!Le.isFunction(i))throw new TypeError("visitor must be a function");function u(S){if(S===null)return"";if(Le.isDate(S))return S.toISOString();if(!f&&Le.isBlob(S))throw new ar("Blob is not supported. Use a Buffer instead.");return Le.isArrayBuffer(S)||Le.isTypedArray(S)?f&&typeof Blob=="function"?new Blob([S]):Buffer.from(S):S}function h(S,C,D){let B=S;if(S&&!D&&typeof S=="object"){if(Le.endsWith(C,"{}"))C=n?C:C.slice(0,-2),S=JSON.stringify(S);else if(Le.isArray(S)&&qq(S)||(Le.isFileList(S)||Le.endsWith(C,"[]"))&&(B=Le.toArray(S)))return C=u4(C),B.forEach(function(H,F){!(Le.isUndefined(H)||H===null)&&e.append(o===!0?f4([C],F,s):o===null?C:C+"[]",u(H))}),!1}return vv(S)?!0:(e.append(f4(D,C,s),u(S)),!1)}const g=[],b=Object.assign(zq,{defaultVisitor:h,convertValue:u,isVisitable:vv});function x(S,C){if(!Le.isUndefined(S)){if(g.indexOf(S)!==-1)throw Error("Circular reference detected in "+C.join("."));g.push(S),Le.forEach(S,function(B,L){(!(Le.isUndefined(B)||B===null)&&i.call(e,B,Le.isString(L)?L.trim():L,C,b))===!0&&x(B,C?C.concat(L):[L])}),g.pop()}}if(!Le.isObject(t))throw new TypeError("data must be an object");return x(t),e}function l4(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function bv(t,e){this._pairs=[],t&&dd(t,this,e)}const h4=bv.prototype;h4.append=function(e,r){this._pairs.push([e,r])},h4.toString=function(e){const r=e?function(n){return e.call(this,n,l4)}:l4;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function Hq(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function d4(t,e,r){if(!e)return t;const n=r&&r.encode||Hq;Le.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let s;if(i?s=i(e,r):s=Le.isURLSearchParams(e)?e.toString():new bv(e,r).toString(n),s){const o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}class p4{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Le.forEach(this.handlers,function(n){n!==null&&e(n)})}}const g4={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Wq={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:bv,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},yv=typeof window<"u"&&typeof document<"u",wv=typeof navigator=="object"&&navigator||void 0,Kq=yv&&(!wv||["ReactNative","NativeScript","NS"].indexOf(wv.product)<0),Vq=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Gq=yv&&window.location.href||"http://localhost",Un={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:yv,hasStandardBrowserEnv:Kq,hasStandardBrowserWebWorkerEnv:Vq,navigator:wv,origin:Gq},Symbol.toStringTag,{value:"Module"})),...Wq};function Yq(t,e){return dd(t,new Un.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,s){return Un.isNode&&Le.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},e))}function Jq(t){return Le.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Xq(t){const e={},r=Object.keys(t);let n;const i=r.length;let s;for(n=0;n=r.length;return o=!o&&Le.isArray(i)?i.length:o,f?(Le.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!a):((!i[o]||!Le.isObject(i[o]))&&(i[o]=[]),e(r,n,i[o],s)&&Le.isArray(i[o])&&(i[o]=Xq(i[o])),!a)}if(Le.isFormData(t)&&Le.isFunction(t.entries)){const r={};return Le.forEachEntry(t,(n,i)=>{e(Jq(n),i,r,0)}),r}return null}function Zq(t,e,r){if(Le.isString(t))try{return(e||JSON.parse)(t),Le.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const qf={transitional:g4,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){const n=r.getContentType()||"",i=n.indexOf("application/json")>-1,s=Le.isObject(e);if(s&&Le.isHTMLForm(e)&&(e=new FormData(e)),Le.isFormData(e))return i?JSON.stringify(m4(e)):e;if(Le.isArrayBuffer(e)||Le.isBuffer(e)||Le.isStream(e)||Le.isFile(e)||Le.isBlob(e)||Le.isReadableStream(e))return e;if(Le.isArrayBufferView(e))return e.buffer;if(Le.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Yq(e,this.formSerializer).toString();if((a=Le.isFileList(e))||n.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return dd(a?{"files[]":e}:e,f&&new f,this.formSerializer)}}return s||i?(r.setContentType("application/json",!1),Zq(e)):e}],transformResponse:[function(e){const r=this.transitional||qf.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(Le.isResponse(e)||Le.isReadableStream(e))return e;if(e&&Le.isString(e)&&(n&&!this.responseType||i)){const o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?ar.from(a,ar.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Un.classes.FormData,Blob:Un.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Le.forEach(["delete","get","head","post","put","patch"],t=>{qf.headers[t]={}});const Qq=Le.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ez=t=>{const e={};let r,n,i;return t&&t.split(` +`).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||e[r]&&Qq[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e},v4=Symbol("internals");function zf(t){return t&&String(t).trim().toLowerCase()}function pd(t){return t===!1||t==null?t:Le.isArray(t)?t.map(pd):String(t)}function tz(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}const rz=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function xv(t,e,r,n,i){if(Le.isFunction(n))return n.call(this,e,r);if(i&&(e=r),!!Le.isString(e)){if(Le.isString(n))return e.indexOf(n)!==-1;if(Le.isRegExp(n))return n.test(e)}}function nz(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,n)=>r.toUpperCase()+n)}function iz(t,e){const r=Le.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(i,s,o){return this[n].call(this,e,i,s,o)},configurable:!0})})}let ci=class{constructor(e){e&&this.set(e)}set(e,r,n){const i=this;function s(a,f,u){const h=zf(f);if(!h)throw new Error("header name must be a non-empty string");const g=Le.findKey(i,h);(!g||i[g]===void 0||u===!0||u===void 0&&i[g]!==!1)&&(i[g||f]=pd(a))}const o=(a,f)=>Le.forEach(a,(u,h)=>s(u,h,f));if(Le.isPlainObject(e)||e instanceof this.constructor)o(e,r);else if(Le.isString(e)&&(e=e.trim())&&!rz(e))o(ez(e),r);else if(Le.isHeaders(e))for(const[a,f]of e.entries())s(f,a,n);else e!=null&&s(r,e,n);return this}get(e,r){if(e=zf(e),e){const n=Le.findKey(this,e);if(n){const i=this[n];if(!r)return i;if(r===!0)return tz(i);if(Le.isFunction(r))return r.call(this,i,n);if(Le.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=zf(e),e){const n=Le.findKey(this,e);return!!(n&&this[n]!==void 0&&(!r||xv(this,this[n],n,r)))}return!1}delete(e,r){const n=this;let i=!1;function s(o){if(o=zf(o),o){const a=Le.findKey(n,o);a&&(!r||xv(n,n[a],a,r))&&(delete n[a],i=!0)}}return Le.isArray(e)?e.forEach(s):s(e),i}clear(e){const r=Object.keys(this);let n=r.length,i=!1;for(;n--;){const s=r[n];(!e||xv(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const r=this,n={};return Le.forEach(this,(i,s)=>{const o=Le.findKey(n,s);if(o){r[o]=pd(i),delete r[s];return}const a=e?nz(s):String(s).trim();a!==s&&delete r[s],r[a]=pd(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const r=Object.create(null);return Le.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=e&&Le.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(` +`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const n=new this(e);return r.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[v4]=this[v4]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=zf(o);n[a]||(iz(i,o),n[a]=!0)}return Le.isArray(e)?e.forEach(s):s(e),this}};ci.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Le.reduceDescriptors(ci.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}}),Le.freezeMethods(ci);function _v(t,e){const r=this||qf,n=e||r,i=ci.from(n.headers);let s=n.data;return Le.forEach(t,function(a){s=a.call(r,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function b4(t){return!!(t&&t.__CANCEL__)}function Oc(t,e,r){ar.call(this,t??"canceled",ar.ERR_CANCELED,e,r),this.name="CanceledError"}Le.inherits(Oc,ar,{__CANCEL__:!0});function y4(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new ar("Request failed with status code "+r.status,[ar.ERR_BAD_REQUEST,ar.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function sz(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function oz(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(f){const u=Date.now(),h=n[s];o||(o=u),r[i]=f,n[i]=u;let g=s,b=0;for(;g!==i;)b+=r[g++],g=g%t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),u-o{r=h,i=null,s&&(clearTimeout(s),s=null),t.apply(null,u)};return[(...u)=>{const h=Date.now(),g=h-r;g>=n?o(u,h):(i=u,s||(s=setTimeout(()=>{s=null,o(i)},n-g)))},()=>i&&o(i)]}const gd=(t,e,r=3)=>{let n=0;const i=oz(50,250);return az(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,f=o-n,u=i(f),h=o<=a;n=o;const g={loaded:o,total:a,progress:a?o/a:void 0,bytes:f,rate:u||void 0,estimated:u&&a&&h?(a-o)/u:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(g)},r)},w4=(t,e)=>{const r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},x4=t=>(...e)=>Le.asap(()=>t(...e)),cz=Un.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,Un.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(Un.origin),Un.navigator&&/(msie|trident)/i.test(Un.navigator.userAgent)):()=>!0,uz=Un.hasStandardBrowserEnv?{write(t,e,r,n,i,s){const o=[t+"="+encodeURIComponent(e)];Le.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),Le.isString(n)&&o.push("path="+n),Le.isString(i)&&o.push("domain="+i),s===!0&&o.push("secure"),document.cookie=o.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function fz(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function lz(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function _4(t,e){return t&&!fz(e)?lz(t,e):e}const E4=t=>t instanceof ci?{...t}:t;function ka(t,e){e=e||{};const r={};function n(u,h,g,b){return Le.isPlainObject(u)&&Le.isPlainObject(h)?Le.merge.call({caseless:b},u,h):Le.isPlainObject(h)?Le.merge({},h):Le.isArray(h)?h.slice():h}function i(u,h,g,b){if(Le.isUndefined(h)){if(!Le.isUndefined(u))return n(void 0,u,g,b)}else return n(u,h,g,b)}function s(u,h){if(!Le.isUndefined(h))return n(void 0,h)}function o(u,h){if(Le.isUndefined(h)){if(!Le.isUndefined(u))return n(void 0,u)}else return n(void 0,h)}function a(u,h,g){if(g in e)return n(u,h);if(g in t)return n(void 0,u)}const f={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(u,h,g)=>i(E4(u),E4(h),g,!0)};return Le.forEach(Object.keys(Object.assign({},t,e)),function(h){const g=f[h]||i,b=g(t[h],e[h],h);Le.isUndefined(b)&&g!==a||(r[h]=b)}),r}const S4=t=>{const e=ka({},t);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=e;e.headers=o=ci.from(o),e.url=d4(_4(e.baseURL,e.url),t.params,t.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let f;if(Le.isFormData(r)){if(Un.hasStandardBrowserEnv||Un.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if((f=o.getContentType())!==!1){const[u,...h]=f?f.split(";").map(g=>g.trim()).filter(Boolean):[];o.setContentType([u||"multipart/form-data",...h].join("; "))}}if(Un.hasStandardBrowserEnv&&(n&&Le.isFunction(n)&&(n=n(e)),n||n!==!1&&cz(e.url))){const u=i&&s&&uz.read(s);u&&o.set(i,u)}return e},hz=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){const i=S4(t);let s=i.data;const o=ci.from(i.headers).normalize();let{responseType:a,onUploadProgress:f,onDownloadProgress:u}=i,h,g,b,x,S;function C(){x&&x(),S&&S(),i.cancelToken&&i.cancelToken.unsubscribe(h),i.signal&&i.signal.removeEventListener("abort",h)}let D=new XMLHttpRequest;D.open(i.method.toUpperCase(),i.url,!0),D.timeout=i.timeout;function B(){if(!D)return;const H=ci.from("getAllResponseHeaders"in D&&D.getAllResponseHeaders()),k={data:!a||a==="text"||a==="json"?D.responseText:D.response,status:D.status,statusText:D.statusText,headers:H,config:t,request:D};y4(function(R){r(R),C()},function(R){n(R),C()},k),D=null}"onloadend"in D?D.onloadend=B:D.onreadystatechange=function(){!D||D.readyState!==4||D.status===0&&!(D.responseURL&&D.responseURL.indexOf("file:")===0)||setTimeout(B)},D.onabort=function(){D&&(n(new ar("Request aborted",ar.ECONNABORTED,t,D)),D=null)},D.onerror=function(){n(new ar("Network Error",ar.ERR_NETWORK,t,D)),D=null},D.ontimeout=function(){let F=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const k=i.transitional||g4;i.timeoutErrorMessage&&(F=i.timeoutErrorMessage),n(new ar(F,k.clarifyTimeoutError?ar.ETIMEDOUT:ar.ECONNABORTED,t,D)),D=null},s===void 0&&o.setContentType(null),"setRequestHeader"in D&&Le.forEach(o.toJSON(),function(F,k){D.setRequestHeader(k,F)}),Le.isUndefined(i.withCredentials)||(D.withCredentials=!!i.withCredentials),a&&a!=="json"&&(D.responseType=i.responseType),u&&([b,S]=gd(u,!0),D.addEventListener("progress",b)),f&&D.upload&&([g,x]=gd(f),D.upload.addEventListener("progress",g),D.upload.addEventListener("loadend",x)),(i.cancelToken||i.signal)&&(h=H=>{D&&(n(!H||H.type?new Oc(null,t,D):H),D.abort(),D=null)},i.cancelToken&&i.cancelToken.subscribe(h),i.signal&&(i.signal.aborted?h():i.signal.addEventListener("abort",h)));const L=sz(i.url);if(L&&Un.protocols.indexOf(L)===-1){n(new ar("Unsupported protocol "+L+":",ar.ERR_BAD_REQUEST,t));return}D.send(s||null)})},dz=(t,e)=>{const{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,i;const s=function(u){if(!i){i=!0,a();const h=u instanceof Error?u:this.reason;n.abort(h instanceof ar?h:new Oc(h instanceof Error?h.message:h))}};let o=e&&setTimeout(()=>{o=null,s(new ar(`timeout ${e} of ms exceeded`,ar.ETIMEDOUT))},e);const a=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(s):u.removeEventListener("abort",s)}),t=null)};t.forEach(u=>u.addEventListener("abort",s));const{signal:f}=n;return f.unsubscribe=()=>Le.asap(a),f}},pz=function*(t,e){let r=t.byteLength;if(r{const i=gz(t,e);let s=0,o,a=f=>{o||(o=!0,n&&n(f))};return new ReadableStream({async pull(f){try{const{done:u,value:h}=await i.next();if(u){a(),f.close();return}let g=h.byteLength;if(r){let b=s+=g;r(b)}f.enqueue(new Uint8Array(h))}catch(u){throw a(u),u}},cancel(f){return a(f),i.return()}},{highWaterMark:2})},md=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",P4=md&&typeof ReadableStream=="function",vz=md&&(typeof TextEncoder=="function"?(t=>e=>t.encode(e))(new TextEncoder):async t=>new Uint8Array(await new Response(t).arrayBuffer())),I4=(t,...e)=>{try{return!!t(...e)}catch{return!1}},bz=P4&&I4(()=>{let t=!1;const e=new Request(Un.origin,{body:new ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type");return t&&!e}),M4=64*1024,Ev=P4&&I4(()=>Le.isReadableStream(new Response("").body)),vd={stream:Ev&&(t=>t.body)};md&&(t=>{["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!vd[e]&&(vd[e]=Le.isFunction(t[e])?r=>r[e]():(r,n)=>{throw new ar(`Response type '${e}' is not supported`,ar.ERR_NOT_SUPPORT,n)})})})(new Response);const yz=async t=>{if(t==null)return 0;if(Le.isBlob(t))return t.size;if(Le.isSpecCompliantForm(t))return(await new Request(Un.origin,{method:"POST",body:t}).arrayBuffer()).byteLength;if(Le.isArrayBufferView(t)||Le.isArrayBuffer(t))return t.byteLength;if(Le.isURLSearchParams(t)&&(t=t+""),Le.isString(t))return(await vz(t)).byteLength},wz=async(t,e)=>{const r=Le.toFiniteNumber(t.getContentLength());return r??yz(e)},Sv={http:$q,xhr:hz,fetch:md&&(async t=>{let{url:e,method:r,data:n,signal:i,cancelToken:s,timeout:o,onDownloadProgress:a,onUploadProgress:f,responseType:u,headers:h,withCredentials:g="same-origin",fetchOptions:b}=S4(t);u=u?(u+"").toLowerCase():"text";let x=dz([i,s&&s.toAbortSignal()],o),S;const C=x&&x.unsubscribe&&(()=>{x.unsubscribe()});let D;try{if(f&&bz&&r!=="get"&&r!=="head"&&(D=await wz(h,n))!==0){let k=new Request(e,{method:"POST",body:n,duplex:"half"}),$;if(Le.isFormData(n)&&($=k.headers.get("content-type"))&&h.setContentType($),k.body){const[R,W]=w4(D,gd(x4(f)));n=A4(k.body,M4,R,W)}}Le.isString(g)||(g=g?"include":"omit");const B="credentials"in Request.prototype;S=new Request(e,{...b,signal:x,method:r.toUpperCase(),headers:h.normalize().toJSON(),body:n,duplex:"half",credentials:B?g:void 0});let L=await fetch(S);const H=Ev&&(u==="stream"||u==="response");if(Ev&&(a||H&&C)){const k={};["status","statusText","headers"].forEach(V=>{k[V]=L[V]});const $=Le.toFiniteNumber(L.headers.get("content-length")),[R,W]=a&&w4($,gd(x4(a),!0))||[];L=new Response(A4(L.body,M4,R,()=>{W&&W(),C&&C()}),k)}u=u||"text";let F=await vd[Le.findKey(vd,u)||"text"](L,t);return!H&&C&&C(),await new Promise((k,$)=>{y4(k,$,{data:F,headers:ci.from(L.headers),status:L.status,statusText:L.statusText,config:t,request:S})})}catch(B){throw C&&C(),B&&B.name==="TypeError"&&/fetch/i.test(B.message)?Object.assign(new ar("Network Error",ar.ERR_NETWORK,t,S),{cause:B.cause||B}):ar.from(B,B&&B.code,t,S)}})};Le.forEach(Sv,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const C4=t=>`- ${t}`,xz=t=>Le.isFunction(t)||t===null||t===!1,R4={getAdapter:t=>{t=Le.isArray(t)?t:[t];const{length:e}=t;let r,n;const i={};for(let s=0;s`adapter ${a} `+(f===!1?"is not supported by the environment":"is not available in the build"));let o=e?s.length>1?`since : +`+s.map(C4).join(` +`):" "+C4(s[0]):"as no adapter specified";throw new ar("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return n},adapters:Sv};function Av(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Oc(null,t)}function T4(t){return Av(t),t.headers=ci.from(t.headers),t.data=_v.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),R4.getAdapter(t.adapter||qf.adapter)(t).then(function(n){return Av(t),n.data=_v.call(t,t.transformResponse,n),n.headers=ci.from(n.headers),n},function(n){return b4(n)||(Av(t),n&&n.response&&(n.response.data=_v.call(t,t.transformResponse,n.response),n.response.headers=ci.from(n.response.headers))),Promise.reject(n)})}const D4="1.7.8",bd={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{bd[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const O4={};bd.transitional=function(e,r,n){function i(s,o){return"[Axios v"+D4+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return(s,o,a)=>{if(e===!1)throw new ar(i(o," has been removed"+(r?" in "+r:"")),ar.ERR_DEPRECATED);return r&&!O4[o]&&(O4[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,o,a):!0}},bd.spelling=function(e){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function _z(t,e,r){if(typeof t!="object")throw new ar("options must be an object",ar.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const s=n[i],o=e[s];if(o){const a=t[s],f=a===void 0||o(a,s,t);if(f!==!0)throw new ar("option "+s+" must be "+f,ar.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new ar("Unknown option "+s,ar.ERR_BAD_OPTION)}}const yd={assertOptions:_z,validators:bd},Ts=yd.validators;let Ba=class{constructor(e){this.defaults=e,this.interceptors={request:new p4,response:new p4}}async request(e,r){try{return await this._request(e,r)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=` +`+s):n.stack=s}catch{}}throw n}}_request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=ka(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:s}=r;n!==void 0&&yd.assertOptions(n,{silentJSONParsing:Ts.transitional(Ts.boolean),forcedJSONParsing:Ts.transitional(Ts.boolean),clarifyTimeoutError:Ts.transitional(Ts.boolean)},!1),i!=null&&(Le.isFunction(i)?r.paramsSerializer={serialize:i}:yd.assertOptions(i,{encode:Ts.function,serialize:Ts.function},!0)),yd.assertOptions(r,{baseUrl:Ts.spelling("baseURL"),withXsrfToken:Ts.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=s&&Le.merge(s.common,s[r.method]);s&&Le.forEach(["delete","get","head","post","put","patch","common"],S=>{delete s[S]}),r.headers=ci.concat(o,s);const a=[];let f=!0;this.interceptors.request.forEach(function(C){typeof C.runWhen=="function"&&C.runWhen(r)===!1||(f=f&&C.synchronous,a.unshift(C.fulfilled,C.rejected))});const u=[];this.interceptors.response.forEach(function(C){u.push(C.fulfilled,C.rejected)});let h,g=0,b;if(!f){const S=[T4.bind(this),void 0];for(S.unshift.apply(S,a),S.push.apply(S,u),b=S.length,h=Promise.resolve(r);g{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},e(function(s,o,a){n.reason||(n.reason=new Oc(s,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const e=new AbortController,r=n=>{e.abort(n)};return this.subscribe(r),e.signal.unsubscribe=()=>this.unsubscribe(r),e.signal}static source(){let e;return{token:new IA(function(i){e=i}),cancel:e}}};function Sz(t){return function(r){return t.apply(null,r)}}function Az(t){return Le.isObject(t)&&t.isAxiosError===!0}const Pv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Pv).forEach(([t,e])=>{Pv[e]=t});function N4(t){const e=new Ba(t),r=X5(Ba.prototype.request,e);return Le.extend(r,Ba.prototype,e,{allOwnKeys:!0}),Le.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return N4(ka(t,i))},r}const an=N4(qf);an.Axios=Ba,an.CanceledError=Oc,an.CancelToken=Ez,an.isCancel=b4,an.VERSION=D4,an.toFormData=dd,an.AxiosError=ar,an.Cancel=an.CanceledError,an.all=function(e){return Promise.all(e)},an.spread=Sz,an.isAxiosError=Az,an.mergeConfig=ka,an.AxiosHeaders=ci,an.formToJSON=t=>m4(Le.isHTMLForm(t)?new FormData(t):t),an.getAdapter=R4.getAdapter,an.HttpStatusCode=Pv,an.default=an;const{Axios:Tne,AxiosError:L4,CanceledError:Dne,isCancel:One,CancelToken:Nne,VERSION:Lne,all:kne,Cancel:Bne,isAxiosError:Fne,spread:jne,toFormData:Une,AxiosHeaders:$ne,HttpStatusCode:qne,formToJSON:zne,getAdapter:Hne,mergeConfig:Wne}=an,k4=an.create({timeout:6e4,headers:{"Content-Type":"application/json",token:localStorage.getItem("auth")}});function Pz(t){if(t.data?.success!==!0){const e=new L4(t.data?.errorMessage,t.data?.errorCode,t.config,t.request,t);return Promise.reject(e)}else return t}function Iz(t){console.log(t);const e=t.response?.data;if(e){console.log(e,"responseData");const r=new L4(e.errorMessage,t.code,t.config,t.request,t.response);return Promise.reject(r)}else return Promise.reject(t)}k4.interceptors.response.use(Pz,Iz);class Mz{constructor(e){this.request=e}_apiBase="";setApiBase(e){this._apiBase=e||""}async getNonce(e){const{data:r}=await this.request.post(`${this._apiBase}/api/v2/user/nonce`,e);return r.data}async getEmailCode(e,r){const{data:n}=await this.request.post(`${this._apiBase}/api/v2/user/get_code`,e,{headers:{"Captcha-Param":r}});return n.data}async emailLogin(e){return(await this.request.post(`${this._apiBase}/api/v2/user/login`,e)).data}async walletLogin(e){return e.account_enum==="C"?(await this.request.post(`${this._apiBase}/api/v2/user/login`,e)).data:(await this.request.post(`${this._apiBase}/api/v2/business/login`,e)).data}async tonLogin(e){return(await this.request.post(`${this._apiBase}/api/v2/user/login`,e)).data}async bindEmail(e){return(await this.request.post("/api/v2/user/account/bind",e)).data}async bindTonWallet(e){return(await this.request.post("/api/v2/user/account/bind",e)).data}async bindEvmWallet(e){return(await this.request.post("/api/v2/user/account/bind",e)).data}}const Fo=new Mz(k4),Cz={projectId:"7a4434fefbcc9af474fb5c995e47d286",metadata:{name:"codatta",description:"codatta",url:"https://codatta.io/",icons:["https://avatars.githubusercontent.com/u/171659315"]}},B4=tq({appName:"codatta",appLogoUrl:"https://avatars.githubusercontent.com/u/171659315"}),F4=Se.createContext({saveLastUsedWallet:()=>{},lastUsedWallet:null,wallets:[],initialized:!1,featuredWallets:[],chains:[]});function Hf(){return Se.useContext(F4)}function Rz(t){const{apiBaseUrl:e}=t,[r,n]=Se.useState([]),[i,s]=Se.useState([]),[o,a]=Se.useState(null),[f,u]=Se.useState(!1),[h,g]=Se.useState([]),b=C=>{a(C);const B={provider:C.provider instanceof Bm?"UniversalProvider":"EIP1193Provider",key:C.key,timestamp:Date.now()};localStorage.setItem("xn-last-used-info",JSON.stringify(B))};function x(C){const D=C.find(B=>B.config?.name===t.singleWalletName);if(D)s([D]);else{const B=C.filter(F=>F.featured||F.installed),L=C.filter(F=>!F.featured&&!F.installed),H=[...B,...L];n(H),s(B)}}async function S(){const C=[],D=new Map;DA.forEach(L=>{const H=new la(L);L.name==="Coinbase Wallet"&&H.EIP6963Detected({info:{name:"Coinbase Wallet",uuid:"coinbase",icon:L.image,rdns:"coinbase"},provider:B4.getProvider()}),D.set(H.key,H),C.push(H)}),(await EU()).forEach(L=>{const H=D.get(L.info.name);if(H)H.EIP6963Detected(L);else{const F=new la(L);D.set(F.key,F),C.push(F)}});try{const L=JSON.parse(localStorage.getItem("xn-last-used-info")||"{}"),H=D.get(L.key);if(H&&L.provider==="EIP1193Provider"&&H.installed)a(H);else if(L.provider==="UniversalProvider"){const F=await Bm.init(Cz);if(F.session){const k=new la(F);a(k),console.log("Restored UniversalProvider for wallet:",k.key)}}}catch(L){console.log(L)}t.chains&&g(t.chains),x(C),u(!0)}return Se.useEffect(()=>{S(),Fo.setApiBase(e)},[]),he.jsx(F4.Provider,{value:{saveLastUsedWallet:b,wallets:r,initialized:f,lastUsedWallet:o,featuredWallets:i,chains:h},children:t.children})}/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const yK=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),a8=(...t)=>t.filter((e,r,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===r).join(" ").trim();/** + */const Tz=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),j4=(...t)=>t.filter((e,r,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===r).join(" ").trim();/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */var wK={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + */var Dz={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const xK=Pe.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:i="",children:s,iconNode:o,...a},u)=>Pe.createElement("svg",{ref:u,...wK,width:e,height:e,stroke:t,strokeWidth:n?Number(r)*24/Number(e):r,className:a8("lucide",i),...a},[...o.map(([l,d])=>Pe.createElement(l,d)),...Array.isArray(s)?s:[s]]));/** + */const Oz=Se.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:i="",children:s,iconNode:o,...a},f)=>Se.createElement("svg",{ref:f,...Dz,width:e,height:e,stroke:t,strokeWidth:n?Number(r)*24/Number(e):r,className:j4("lucide",i),...a},[...o.map(([u,h])=>Se.createElement(u,h)),...Array.isArray(s)?s:[s]]));/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Es=(t,e)=>{const r=Pe.forwardRef(({className:n,...i},s)=>Pe.createElement(xK,{ref:s,iconNode:e,className:a8(`lucide-${yK(t)}`,n),...i}));return r.displayName=`${t}`,r};/** + */const zi=(t,e)=>{const r=Se.forwardRef(({className:n,...i},s)=>Se.createElement(Oz,{ref:s,iconNode:e,className:j4(`lucide-${Tz(t)}`,n),...i}));return r.displayName=`${t}`,r};/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const _K=Es("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** + */const Nz=zi("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const c8=Es("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + */const U4=zi("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const EK=Es("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + */const Lz=zi("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const SK=Es("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + */const kz=zi("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const AK=Es("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + */const Bz=zi("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const PK=Es("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + */const Fz=zi("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const u8=Es("Laptop",[["path",{d:"M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16",key:"tarvll"}]]);/** + */const $4=zi("Laptop",[["path",{d:"M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16",key:"tarvll"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const MK=Es("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** + */const jz=zi("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const mc=Es("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + */const Fa=zi("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const IK=Es("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** + */const Uz=zi("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const f8=Es("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),l8=new Set;function S0(t,e,r){t||l8.has(e)||(console.warn(e),l8.add(e))}function CK(t){if(typeof Proxy>"u")return t;const e=new Map,r=(...n)=>(process.env.NODE_ENV!=="production"&&S0(!1,"motion() is deprecated. Use motion.create() instead."),t(...n));return new Proxy(r,{get:(n,i)=>i==="create"?t:(e.has(i)||e.set(i,t(i)),e.get(i))})}function A0(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}const gv=t=>Array.isArray(t);function h8(t,e){if(!Array.isArray(e))return!1;const r=e.length;if(r!==t.length)return!1;for(let n=0;n{e[0][n]=r.get(),e[1][n]=r.getVelocity()}),e}function mv(t,e,r,n){if(typeof e=="function"){const[i,s]=d8(n);e=e(r!==void 0?r:t.custom,i,s)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,s]=d8(n);e=e(r!==void 0?r:t.custom,i,s)}return e}function P0(t,e,r){const n=t.getProps();return mv(n,e,r!==void 0?r:n.custom,t)}const vv=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],bv=["initial",...vv],Vl=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],vc=new Set(Vl),Zs=t=>t*1e3,Ro=t=>t/1e3,TK={type:"spring",stiffness:500,damping:25,restSpeed:10},RK=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),DK={type:"keyframes",duration:.8},OK={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},NK=(t,{keyframes:e})=>e.length>2?DK:vc.has(t)?t.startsWith("scale")?RK(e[1]):TK:OK;function yv(t,e){return t?t[e]||t.default||t:void 0}const LK={useManualTiming:!1},kK=t=>t!==null;function M0(t,{repeat:e,repeatType:r="loop"},n){const i=t.filter(kK),s=e&&r!=="loop"&&e%2===1?0:i.length-1;return!s||n===void 0?i[s]:n}const Hn=t=>t;function $K(t){let e=new Set,r=new Set,n=!1,i=!1;const s=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function a(l){s.has(l)&&(u.schedule(l),t()),l(o)}const u={schedule:(l,d=!1,g=!1)=>{const A=g&&n?e:r;return d&&s.add(l),A.has(l)||A.add(l),l},cancel:l=>{r.delete(l),s.delete(l)},process:l=>{if(o=l,n){i=!0;return}n=!0,[e,r]=[r,e],r.clear(),e.forEach(a),n=!1,i&&(i=!1,u.process(l))}};return u}const I0=["read","resolveKeyframes","update","preRender","render","postRender"],BK=40;function p8(t,e){let r=!1,n=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>r=!0,o=I0.reduce((k,$)=>(k[$]=$K(s),k),{}),{read:a,resolveKeyframes:u,update:l,preRender:d,render:g,postRender:y}=o,A=()=>{const k=performance.now();r=!1,i.delta=n?1e3/60:Math.max(Math.min(k-i.timestamp,BK),1),i.timestamp=k,i.isProcessing=!0,a.process(i),u.process(i),l.process(i),d.process(i),g.process(i),y.process(i),i.isProcessing=!1,r&&e&&(n=!1,t(A))},P=()=>{r=!0,n=!0,i.isProcessing||t(A)};return{schedule:I0.reduce((k,$)=>{const q=o[$];return k[$]=(U,K=!1,J=!1)=>(r||P(),q.schedule(U,K,J)),k},{}),cancel:k=>{for(let $=0;$(((1-3*r+3*e)*t+(3*r-6*e))*t+3*e)*t,FK=1e-7,UK=12;function jK(t,e,r,n,i){let s,o,a=0;do o=e+(r-e)/2,s=g8(o,n,i)-t,s>0?r=o:e=o;while(Math.abs(s)>FK&&++ajK(s,0,1,t,r);return s=>s===0||s===1?s:g8(i(s),e,n)}const m8=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,v8=t=>e=>1-t(1-e),b8=Gl(.33,1.53,.69,.99),xv=v8(b8),y8=m8(xv),w8=t=>(t*=2)<1?.5*xv(t):.5*(2-Math.pow(2,-10*(t-1))),_v=t=>1-Math.sin(Math.acos(t)),x8=v8(_v),_8=m8(_v),E8=t=>/^0[^.\s]+$/u.test(t);function qK(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||E8(t):!0}let Nu=Hn,Do=Hn;process.env.NODE_ENV!=="production"&&(Nu=(t,e)=>{!t&&typeof console<"u"&&console.warn(e)},Do=(t,e)=>{if(!t)throw new Error(e)});const S8=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),A8=t=>e=>typeof e=="string"&&e.startsWith(t),P8=A8("--"),zK=A8("var(--"),Ev=t=>zK(t)?HK.test(t.split("/*")[0].trim()):!1,HK=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,WK=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function KK(t){const e=WK.exec(t);if(!e)return[,];const[,r,n,i]=e;return[`--${r??n}`,i]}const VK=4;function M8(t,e,r=1){Do(r<=VK,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`);const[n,i]=KK(t);if(!n)return;const s=window.getComputedStyle(e).getPropertyValue(n);if(s){const o=s.trim();return S8(o)?parseFloat(o):o}return Ev(i)?M8(i,e,r+1):i}const ba=(t,e,r)=>r>e?e:rtypeof t=="number",parse:parseFloat,transform:t=>t},Yl={...Lu,transform:t=>ba(0,1,t)},C0={...Lu,default:1},Jl=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),ya=Jl("deg"),Qs=Jl("%"),zt=Jl("px"),GK=Jl("vh"),YK=Jl("vw"),I8={...Qs,parse:t=>Qs.parse(t)/100,transform:t=>Qs.transform(t*100)},JK=new Set(["width","height","top","left","right","bottom","x","y","translateX","translateY"]),C8=t=>t===Lu||t===zt,T8=(t,e)=>parseFloat(t.split(", ")[e]),R8=(t,e)=>(r,{transform:n})=>{if(n==="none"||!n)return 0;const i=n.match(/^matrix3d\((.+)\)$/u);if(i)return T8(i[1],e);{const s=n.match(/^matrix\((.+)\)$/u);return s?T8(s[1],t):0}},XK=new Set(["x","y","z"]),ZK=Vl.filter(t=>!XK.has(t));function QK(t){const e=[];return ZK.forEach(r=>{const n=t.getValue(r);n!==void 0&&(e.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),e}const ku={width:({x:t},{paddingLeft:e="0",paddingRight:r="0"})=>t.max-t.min-parseFloat(e)-parseFloat(r),height:({y:t},{paddingTop:e="0",paddingBottom:r="0"})=>t.max-t.min-parseFloat(e)-parseFloat(r),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:R8(4,13),y:R8(5,14)};ku.translateX=ku.x,ku.translateY=ku.y;const D8=t=>e=>e.test(t),O8=[Lu,zt,Qs,ya,YK,GK,{test:t=>t==="auto",parse:t=>t}],N8=t=>O8.find(D8(t)),bc=new Set;let Sv=!1,Av=!1;function L8(){if(Av){const t=Array.from(bc).filter(n=>n.needsMeasurement),e=new Set(t.map(n=>n.element)),r=new Map;e.forEach(n=>{const i=QK(n);i.length&&(r.set(n,i),n.render())}),t.forEach(n=>n.measureInitialState()),e.forEach(n=>{n.render();const i=r.get(n);i&&i.forEach(([s,o])=>{var a;(a=n.getValue(s))===null||a===void 0||a.set(o)})}),t.forEach(n=>n.measureEndState()),t.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}Av=!1,Sv=!1,bc.forEach(t=>t.complete()),bc.clear()}function k8(){bc.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Av=!0)})}function eV(){k8(),L8()}class Pv{constructor(e,r,n,i,s,o=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...e],this.onComplete=r,this.name=n,this.motionValue=i,this.element=s,this.isAsync=o}scheduleResolve(){this.isScheduled=!0,this.isAsync?(bc.add(this),Sv||(Sv=!0,Nr.read(k8),Nr.resolveKeyframes(L8))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:r,element:n,motionValue:i}=this;for(let s=0;sMath.round(t*1e5)/1e5,Mv=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function tV(t){return t==null}const rV=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Iv=(t,e)=>r=>!!(typeof r=="string"&&rV.test(r)&&r.startsWith(t)||e&&!tV(r)&&Object.prototype.hasOwnProperty.call(r,e)),$8=(t,e,r)=>n=>{if(typeof n!="string")return n;const[i,s,o,a]=n.match(Mv);return{[t]:parseFloat(i),[e]:parseFloat(s),[r]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},nV=t=>ba(0,255,t),Cv={...Lu,transform:t=>Math.round(nV(t))},yc={test:Iv("rgb","red"),parse:$8("red","green","blue"),transform:({red:t,green:e,blue:r,alpha:n=1})=>"rgba("+Cv.transform(t)+", "+Cv.transform(e)+", "+Cv.transform(r)+", "+Xl(Yl.transform(n))+")"};function iV(t){let e="",r="",n="",i="";return t.length>5?(e=t.substring(1,3),r=t.substring(3,5),n=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),r=t.substring(2,3),n=t.substring(3,4),i=t.substring(4,5),e+=e,r+=r,n+=n,i+=i),{red:parseInt(e,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:i?parseInt(i,16)/255:1}}const Tv={test:Iv("#"),parse:iV,transform:yc.transform},$u={test:Iv("hsl","hue"),parse:$8("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+Qs.transform(Xl(e))+", "+Qs.transform(Xl(r))+", "+Xl(Yl.transform(n))+")"},Zn={test:t=>yc.test(t)||Tv.test(t)||$u.test(t),parse:t=>yc.test(t)?yc.parse(t):$u.test(t)?$u.parse(t):Tv.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?yc.transform(t):$u.transform(t)},sV=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function oV(t){var e,r;return isNaN(t)&&typeof t=="string"&&(((e=t.match(Mv))===null||e===void 0?void 0:e.length)||0)+(((r=t.match(sV))===null||r===void 0?void 0:r.length)||0)>0}const B8="number",F8="color",aV="var",cV="var(",U8="${}",uV=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Zl(t){const e=t.toString(),r=[],n={color:[],number:[],var:[]},i=[];let s=0;const a=e.replace(uV,u=>(Zn.test(u)?(n.color.push(s),i.push(F8),r.push(Zn.parse(u))):u.startsWith(cV)?(n.var.push(s),i.push(aV),r.push(u)):(n.number.push(s),i.push(B8),r.push(parseFloat(u))),++s,U8)).split(U8);return{values:r,split:a,indexes:n,types:i}}function j8(t){return Zl(t).values}function q8(t){const{split:e,types:r}=Zl(t),n=e.length;return i=>{let s="";for(let o=0;otypeof t=="number"?0:t;function lV(t){const e=j8(t);return q8(t)(e.map(fV))}const wa={test:oV,parse:j8,createTransformer:q8,getAnimatableNone:lV},hV=new Set(["brightness","contrast","saturate","opacity"]);function dV(t){const[e,r]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[n]=r.match(Mv)||[];if(!n)return t;const i=r.replace(n,"");let s=hV.has(e)?1:0;return n!==r&&(s*=100),e+"("+s+i+")"}const pV=/\b([a-z-]*)\(.*?\)/gu,Rv={...wa,getAnimatableNone:t=>{const e=t.match(pV);return e?e.map(dV).join(" "):t}},gV={borderWidth:zt,borderTopWidth:zt,borderRightWidth:zt,borderBottomWidth:zt,borderLeftWidth:zt,borderRadius:zt,radius:zt,borderTopLeftRadius:zt,borderTopRightRadius:zt,borderBottomRightRadius:zt,borderBottomLeftRadius:zt,width:zt,maxWidth:zt,height:zt,maxHeight:zt,top:zt,right:zt,bottom:zt,left:zt,padding:zt,paddingTop:zt,paddingRight:zt,paddingBottom:zt,paddingLeft:zt,margin:zt,marginTop:zt,marginRight:zt,marginBottom:zt,marginLeft:zt,backgroundPositionX:zt,backgroundPositionY:zt},mV={rotate:ya,rotateX:ya,rotateY:ya,rotateZ:ya,scale:C0,scaleX:C0,scaleY:C0,scaleZ:C0,skew:ya,skewX:ya,skewY:ya,distance:zt,translateX:zt,translateY:zt,translateZ:zt,x:zt,y:zt,z:zt,perspective:zt,transformPerspective:zt,opacity:Yl,originX:I8,originY:I8,originZ:zt},z8={...Lu,transform:Math.round},Dv={...gV,...mV,zIndex:z8,size:zt,fillOpacity:Yl,strokeOpacity:Yl,numOctaves:z8},vV={...Dv,color:Zn,backgroundColor:Zn,outlineColor:Zn,fill:Zn,stroke:Zn,borderColor:Zn,borderTopColor:Zn,borderRightColor:Zn,borderBottomColor:Zn,borderLeftColor:Zn,filter:Rv,WebkitFilter:Rv},Ov=t=>vV[t];function H8(t,e){let r=Ov(t);return r!==Rv&&(r=wa),r.getAnimatableNone?r.getAnimatableNone(e):void 0}const bV=new Set(["auto","none","0"]);function yV(t,e,r){let n=0,i;for(;n{r.getValue(u).set(l)}),this.resolveNoneKeyframes()}}function Nv(t){return typeof t=="function"}let T0;function wV(){T0=void 0}const eo={now:()=>(T0===void 0&&eo.set(Wn.isProcessing||LK.useManualTiming?Wn.timestamp:performance.now()),T0),set:t=>{T0=t,queueMicrotask(wV)}},K8=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(wa.test(t)||t==="0")&&!t.startsWith("url("));function xV(t){const e=t[0];if(t.length===1)return!0;for(let r=0;rEV?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&eV(),this._resolved}onKeyframesResolved(e,r){this.resolvedAt=eo.now(),this.hasAttemptedResolve=!0;const{name:n,type:i,velocity:s,delay:o,onComplete:a,onUpdate:u,isGenerator:l}=this.options;if(!l&&!_V(e,n,i,s))if(o)this.options.duration=0;else{u==null||u(M0(e,this.options,r)),a==null||a(),this.resolveFinishedPromise();return}const d=this.initPlayback(e,r);d!==!1&&(this._resolved={keyframes:e,finalKeyframe:r,...d},this.onPostResolved())}onPostResolved(){}then(e,r){return this.currentFinishedPromise.then(e,r)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(e=>{this.resolveFinishedPromise=e})}}function G8(t,e){return e?t*(1e3/e):0}const SV=5;function Y8(t,e,r){const n=Math.max(e-SV,0);return G8(r-t(n),e-n)}const Lv=.001,AV=.01,J8=10,PV=.05,MV=1;function IV({duration:t=800,bounce:e=.25,velocity:r=0,mass:n=1}){let i,s;Nu(t<=Zs(J8),"Spring duration must be 10 seconds or less");let o=1-e;o=ba(PV,MV,o),t=ba(AV,J8,Ro(t)),o<1?(i=l=>{const d=l*o,g=d*t,y=d-r,A=kv(l,o),P=Math.exp(-g);return Lv-y/A*P},s=l=>{const g=l*o*t,y=g*r+r,A=Math.pow(o,2)*Math.pow(l,2)*t,P=Math.exp(-g),N=kv(Math.pow(l,2),o);return(-i(l)+Lv>0?-1:1)*((y-A)*P)/N}):(i=l=>{const d=Math.exp(-l*t),g=(l-r)*t+1;return-Lv+d*g},s=l=>{const d=Math.exp(-l*t),g=(r-l)*(t*t);return d*g});const a=5/t,u=TV(i,s,a);if(t=Zs(t),isNaN(u))return{stiffness:100,damping:10,duration:t};{const l=Math.pow(u,2)*n;return{stiffness:l,damping:o*2*Math.sqrt(n*l),duration:t}}}const CV=12;function TV(t,e,r){let n=r;for(let i=1;it[r]!==void 0)}function OV(t){let e={velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1,...t};if(!X8(t,DV)&&X8(t,RV)){const r=IV(t);e={...e,...r,mass:1},e.isResolvedFromDuration=!0}return e}function Z8({keyframes:t,restDelta:e,restSpeed:r,...n}){const i=t[0],s=t[t.length-1],o={done:!1,value:i},{stiffness:a,damping:u,mass:l,duration:d,velocity:g,isResolvedFromDuration:y}=OV({...n,velocity:-Ro(n.velocity||0)}),A=g||0,P=u/(2*Math.sqrt(a*l)),N=s-i,D=Ro(Math.sqrt(a/l)),k=Math.abs(N)<5;r||(r=k?.01:2),e||(e=k?.005:.5);let $;if(P<1){const q=kv(D,P);$=U=>{const K=Math.exp(-P*D*U);return s-K*((A+P*D*N)/q*Math.sin(q*U)+N*Math.cos(q*U))}}else if(P===1)$=q=>s-Math.exp(-D*q)*(N+(A+D*N)*q);else{const q=D*Math.sqrt(P*P-1);$=U=>{const K=Math.exp(-P*D*U),J=Math.min(q*U,300);return s-K*((A+P*D*N)*Math.sinh(J)+q*N*Math.cosh(J))/q}}return{calculatedDuration:y&&d||null,next:q=>{const U=$(q);if(y)o.done=q>=d;else{let K=0;P<1&&(K=q===0?Zs(A):Y8($,q,U));const J=Math.abs(K)<=r,T=Math.abs(s-U)<=e;o.done=J&&T}return o.value=o.done?s:U,o}}}function Q8({keyframes:t,velocity:e=0,power:r=.8,timeConstant:n=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:o,min:a,max:u,restDelta:l=.5,restSpeed:d}){const g=t[0],y={done:!1,value:g},A=z=>a!==void 0&&zu,P=z=>a===void 0?u:u===void 0||Math.abs(a-z)-N*Math.exp(-z/n),q=z=>k+$(z),U=z=>{const ue=$(z),_e=q(z);y.done=Math.abs(ue)<=l,y.value=y.done?k:_e};let K,J;const T=z=>{A(y.value)&&(K=z,J=Z8({keyframes:[y.value,P(y.value)],velocity:Y8(q,z,y.value),damping:i,stiffness:s,restDelta:l,restSpeed:d}))};return T(0),{calculatedDuration:null,next:z=>{let ue=!1;return!J&&K===void 0&&(ue=!0,U(z),T(z)),K!==void 0&&z>=K?J.next(z-K):(!ue&&U(z),y)}}}const NV=Gl(.42,0,1,1),LV=Gl(0,0,.58,1),eE=Gl(.42,0,.58,1),kV=t=>Array.isArray(t)&&typeof t[0]!="number",$v=t=>Array.isArray(t)&&typeof t[0]=="number",tE={linear:Hn,easeIn:NV,easeInOut:eE,easeOut:LV,circIn:_v,circInOut:_8,circOut:x8,backIn:xv,backInOut:y8,backOut:b8,anticipate:w8},rE=t=>{if($v(t)){Do(t.length===4,"Cubic bezier arrays must contain four numerical values.");const[e,r,n,i]=t;return Gl(e,r,n,i)}else if(typeof t=="string")return Do(tE[t]!==void 0,`Invalid easing type '${t}'`),tE[t];return t},$V=(t,e)=>r=>e(t(r)),Oo=(...t)=>t.reduce($V),Bu=(t,e,r)=>{const n=e-t;return n===0?1:(r-t)/n},Zr=(t,e,r)=>t+(e-t)*r;function Bv(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function BV({hue:t,saturation:e,lightness:r,alpha:n}){t/=360,e/=100,r/=100;let i=0,s=0,o=0;if(!e)i=s=o=r;else{const a=r<.5?r*(1+e):r+e-r*e,u=2*r-a;i=Bv(u,a,t+1/3),s=Bv(u,a,t),o=Bv(u,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:n}}function R0(t,e){return r=>r>0?e:t}const Fv=(t,e,r)=>{const n=t*t,i=r*(e*e-n)+n;return i<0?0:Math.sqrt(i)},FV=[Tv,yc,$u],UV=t=>FV.find(e=>e.test(t));function nE(t){const e=UV(t);if(Nu(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`),!e)return!1;let r=e.parse(t);return e===$u&&(r=BV(r)),r}const iE=(t,e)=>{const r=nE(t),n=nE(e);if(!r||!n)return R0(t,e);const i={...r};return s=>(i.red=Fv(r.red,n.red,s),i.green=Fv(r.green,n.green,s),i.blue=Fv(r.blue,n.blue,s),i.alpha=Zr(r.alpha,n.alpha,s),yc.transform(i))},Uv=new Set(["none","hidden"]);function jV(t,e){return Uv.has(t)?r=>r<=0?t:e:r=>r>=1?e:t}function qV(t,e){return r=>Zr(t,e,r)}function jv(t){return typeof t=="number"?qV:typeof t=="string"?Ev(t)?R0:Zn.test(t)?iE:WV:Array.isArray(t)?sE:typeof t=="object"?Zn.test(t)?iE:zV:R0}function sE(t,e){const r=[...t],n=r.length,i=t.map((s,o)=>jv(s)(s,e[o]));return s=>{for(let o=0;o{for(const s in n)r[s]=n[s](i);return r}}function HV(t,e){var r;const n=[],i={color:0,var:0,number:0};for(let s=0;s{const r=wa.createTransformer(e),n=Zl(t),i=Zl(e);return n.indexes.var.length===i.indexes.var.length&&n.indexes.color.length===i.indexes.color.length&&n.indexes.number.length>=i.indexes.number.length?Uv.has(t)&&!i.values.length||Uv.has(e)&&!n.values.length?jV(t,e):Oo(sE(HV(n,i),i.values),r):(Nu(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),R0(t,e))};function oE(t,e,r){return typeof t=="number"&&typeof e=="number"&&typeof r=="number"?Zr(t,e,r):jv(t)(t,e)}function KV(t,e,r){const n=[],i=r||oE,s=t.length-1;for(let o=0;oe[0];if(s===2&&t[0]===t[1])return()=>e[1];t[0]>t[s-1]&&(t=[...t].reverse(),e=[...e].reverse());const o=KV(e,n,i),a=o.length,u=l=>{let d=0;if(a>1)for(;du(ba(t[0],t[s-1],l)):u}function GV(t,e){const r=t[t.length-1];for(let n=1;n<=e;n++){const i=Bu(0,e,n);t.push(Zr(r,1,i))}}function YV(t){const e=[0];return GV(e,t.length-1),e}function JV(t,e){return t.map(r=>r*e)}function XV(t,e){return t.map(()=>e||eE).splice(0,t.length-1)}function D0({duration:t=300,keyframes:e,times:r,ease:n="easeInOut"}){const i=kV(n)?n.map(rE):rE(n),s={done:!1,value:e[0]},o=JV(r&&r.length===e.length?r:YV(e),t),a=VV(o,e,{ease:Array.isArray(i)?i:XV(e,i)});return{calculatedDuration:t,next:u=>(s.value=a(u),s.done=u>=t,s)}}const aE=2e4;function ZV(t){let e=0;const r=50;let n=t.next(e);for(;!n.done&&e=aE?1/0:e}const QV=t=>{const e=({timestamp:r})=>t(r);return{start:()=>Nr.update(e,!0),stop:()=>va(e),now:()=>Wn.isProcessing?Wn.timestamp:eo.now()}},eG={decay:Q8,inertia:Q8,tween:D0,keyframes:D0,spring:Z8},tG=t=>t/100;class qv extends V8{constructor(e){super(e),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:u}=this.options;u&&u()};const{name:r,motionValue:n,element:i,keyframes:s}=this.options,o=(i==null?void 0:i.KeyframeResolver)||Pv,a=(u,l)=>this.onKeyframesResolved(u,l);this.resolver=new o(s,a,r,n,i),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(e){const{type:r="keyframes",repeat:n=0,repeatDelay:i=0,repeatType:s,velocity:o=0}=this.options,a=Nv(r)?r:eG[r]||D0;let u,l;a!==D0&&typeof e[0]!="number"&&(process.env.NODE_ENV!=="production"&&Do(e.length===2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${e}`),u=Oo(tG,oE(e[0],e[1])),e=[0,100]);const d=a({...this.options,keyframes:e});s==="mirror"&&(l=a({...this.options,keyframes:[...e].reverse(),velocity:-o})),d.calculatedDuration===null&&(d.calculatedDuration=ZV(d));const{calculatedDuration:g}=d,y=g+i,A=y*(n+1)-i;return{generator:d,mirroredGenerator:l,mapPercentToKeyframes:u,calculatedDuration:g,resolvedDuration:y,totalDuration:A}}onPostResolved(){const{autoplay:e=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!e?this.pause():this.state=this.pendingPlayState}tick(e,r=!1){const{resolved:n}=this;if(!n){const{keyframes:z}=this.options;return{done:!0,value:z[z.length-1]}}const{finalKeyframe:i,generator:s,mirroredGenerator:o,mapPercentToKeyframes:a,keyframes:u,calculatedDuration:l,totalDuration:d,resolvedDuration:g}=n;if(this.startTime===null)return s.next(0);const{delay:y,repeat:A,repeatType:P,repeatDelay:N,onUpdate:D}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-d/this.speed,this.startTime)),r?this.currentTime=e:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(e-this.startTime)*this.speed;const k=this.currentTime-y*(this.speed>=0?1:-1),$=this.speed>=0?k<0:k>d;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=d);let q=this.currentTime,U=s;if(A){const z=Math.min(this.currentTime,d)/g;let ue=Math.floor(z),_e=z%1;!_e&&z>=1&&(_e=1),_e===1&&ue--,ue=Math.min(ue,A+1),!!(ue%2)&&(P==="reverse"?(_e=1-_e,N&&(_e-=N/g)):P==="mirror"&&(U=o)),q=ba(0,1,_e)*g}const K=$?{done:!1,value:u[0]}:U.next(q);a&&(K.value=a(K.value));let{done:J}=K;!$&&l!==null&&(J=this.speed>=0?this.currentTime>=d:this.currentTime<=0);const T=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&J);return T&&i!==void 0&&(K.value=M0(u,this.options,i)),D&&D(K.value),T&&this.finish(),K}get duration(){const{resolved:e}=this;return e?Ro(e.calculatedDuration):0}get time(){return Ro(this.currentTime)}set time(e){e=Zs(e),this.currentTime=e,this.holdTime!==null||this.speed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.speed)}get speed(){return this.playbackSpeed}set speed(e){const r=this.playbackSpeed!==e;this.playbackSpeed=e,r&&(this.time=Ro(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:e=QV,onPlay:r,startTime:n}=this.options;this.driver||(this.driver=e(s=>this.tick(s))),r&&r();const i=this.driver.now();this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=i):this.startTime=n??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var e;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(e=this.currentTime)!==null&&e!==void 0?e:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:e}=this.options;e&&e()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}}const rG=new Set(["opacity","clipPath","filter","transform"]),nG=10,iG=(t,e)=>{let r="";const n=Math.max(Math.round(e/nG),2);for(let i=0;i(e===void 0&&(e=t()),e)}const sG={linearEasing:void 0};function oG(t,e){const r=zv(t);return()=>{var n;return(n=sG[e])!==null&&n!==void 0?n:r()}}const O0=oG(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing");function cE(t){return!!(typeof t=="function"&&O0()||!t||typeof t=="string"&&(t in Hv||O0())||$v(t)||Array.isArray(t)&&t.every(cE))}const Ql=([t,e,r,n])=>`cubic-bezier(${t}, ${e}, ${r}, ${n})`,Hv={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Ql([0,.65,.55,1]),circOut:Ql([.55,0,1,.45]),backIn:Ql([.31,.01,.66,-.59]),backOut:Ql([.33,1.53,.69,.99])};function uE(t,e){if(t)return typeof t=="function"&&O0()?iG(t,e):$v(t)?Ql(t):Array.isArray(t)?t.map(r=>uE(r,e)||Hv.easeOut):Hv[t]}function aG(t,e,r,{delay:n=0,duration:i=300,repeat:s=0,repeatType:o="loop",ease:a="easeInOut",times:u}={}){const l={[e]:r};u&&(l.offset=u);const d=uE(a,i);return Array.isArray(d)&&(l.easing=d),t.animate(l,{delay:n,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"})}function fE(t,e){t.timeline=e,t.onfinish=null}const cG=zv(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),N0=10,uG=2e4;function fG(t){return Nv(t.type)||t.type==="spring"||!cE(t.ease)}function lG(t,e){const r=new qv({...e,keyframes:t,repeat:0,delay:0,isGenerator:!0});let n={done:!1,value:t[0]};const i=[];let s=0;for(;!n.done&&sthis.onKeyframesResolved(o,a),r,n,i),this.resolver.scheduleResolve()}initPlayback(e,r){var n;let{duration:i=300,times:s,ease:o,type:a,motionValue:u,name:l,startTime:d}=this.options;if(!(!((n=u.owner)===null||n===void 0)&&n.current))return!1;if(typeof o=="string"&&O0()&&hG(o)&&(o=lE[o]),fG(this.options)){const{onComplete:y,onUpdate:A,motionValue:P,element:N,...D}=this.options,k=lG(e,D);e=k.keyframes,e.length===1&&(e[1]=e[0]),i=k.duration,s=k.times,o=k.ease,a="keyframes"}const g=aG(u.owner.current,l,e,{...this.options,duration:i,times:s,ease:o});return g.startTime=d??this.calcStartTime(),this.pendingTimeline?(fE(g,this.pendingTimeline),this.pendingTimeline=void 0):g.onfinish=()=>{const{onComplete:y}=this.options;u.set(M0(e,this.options,r)),y&&y(),this.cancel(),this.resolveFinishedPromise()},{animation:g,duration:i,times:s,type:a,ease:o,keyframes:e}}get duration(){const{resolved:e}=this;if(!e)return 0;const{duration:r}=e;return Ro(r)}get time(){const{resolved:e}=this;if(!e)return 0;const{animation:r}=e;return Ro(r.currentTime||0)}set time(e){const{resolved:r}=this;if(!r)return;const{animation:n}=r;n.currentTime=Zs(e)}get speed(){const{resolved:e}=this;if(!e)return 1;const{animation:r}=e;return r.playbackRate}set speed(e){const{resolved:r}=this;if(!r)return;const{animation:n}=r;n.playbackRate=e}get state(){const{resolved:e}=this;if(!e)return"idle";const{animation:r}=e;return r.playState}get startTime(){const{resolved:e}=this;if(!e)return null;const{animation:r}=e;return r.startTime}attachTimeline(e){if(!this._resolved)this.pendingTimeline=e;else{const{resolved:r}=this;if(!r)return Hn;const{animation:n}=r;fE(n,e)}return Hn}play(){if(this.isStopped)return;const{resolved:e}=this;if(!e)return;const{animation:r}=e;r.playState==="finished"&&this.updateFinishedPromise(),r.play()}pause(){const{resolved:e}=this;if(!e)return;const{animation:r}=e;r.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:e}=this;if(!e)return;const{animation:r,keyframes:n,duration:i,type:s,ease:o,times:a}=e;if(r.playState==="idle"||r.playState==="finished")return;if(this.time){const{motionValue:l,onUpdate:d,onComplete:g,element:y,...A}=this.options,P=new qv({...A,keyframes:n,duration:i,type:s,ease:o,times:a,isGenerator:!0}),N=Zs(this.time);l.setWithVelocity(P.sample(N-N0).value,P.sample(N).value,N0)}const{onStop:u}=this.options;u&&u(),this.cancel()}complete(){const{resolved:e}=this;e&&e.animation.finish()}cancel(){const{resolved:e}=this;e&&e.animation.cancel()}static supports(e){const{motionValue:r,name:n,repeatDelay:i,repeatType:s,damping:o,type:a}=e;return cG()&&n&&rG.has(n)&&r&&r.owner&&r.owner.current instanceof HTMLElement&&!r.owner.getProps().onUpdate&&!i&&s!=="mirror"&&o!==0&&a!=="inertia"}}const dG=zv(()=>window.ScrollTimeline!==void 0);class pG{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}then(e,r){return Promise.all(this.animations).then(e).catch(r)}getAll(e){return this.animations[0][e]}setAll(e,r){for(let n=0;ndG()&&i.attachTimeline?i.attachTimeline(e):r(i));return()=>{n.forEach((i,s)=>{i&&i(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get startTime(){return this.getAll("startTime")}get duration(){let e=0;for(let r=0;rr[e]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function gG({when:t,delay:e,delayChildren:r,staggerChildren:n,staggerDirection:i,repeat:s,repeatType:o,repeatDelay:a,from:u,elapsed:l,...d}){return!!Object.keys(d).length}const Wv=(t,e,r,n={},i,s)=>o=>{const a=yv(n,t)||{},u=a.delay||n.delay||0;let{elapsed:l=0}=n;l=l-Zs(u);let d={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-l,onUpdate:y=>{e.set(y),a.onUpdate&&a.onUpdate(y)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:s?void 0:i};gG(a)||(d={...d,...NK(t,d)}),d.duration&&(d.duration=Zs(d.duration)),d.repeatDelay&&(d.repeatDelay=Zs(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let g=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(d.duration=0,d.delay===0&&(g=!0)),g&&!s&&e.get()!==void 0){const y=M0(d.keyframes,a);if(y!==void 0)return Nr.update(()=>{d.onUpdate(y),d.onComplete()}),new pG([])}return!s&&hE.supports(d)?new hE(d):new qv(d)},mG=t=>!!(t&&typeof t=="object"&&t.mix&&t.toValue),vG=t=>gv(t)?t[t.length-1]||0:t;function Kv(t,e){t.indexOf(e)===-1&&t.push(e)}function Vv(t,e){const r=t.indexOf(e);r>-1&&t.splice(r,1)}class Gv{constructor(){this.subscriptions=[]}add(e){return Kv(this.subscriptions,e),()=>Vv(this.subscriptions,e)}notify(e,r,n){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,r,n);else for(let s=0;s!isNaN(parseFloat(t));class yG{constructor(e,r={}){this.version="11.11.17",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(n,i=!0)=>{const s=eo.now();this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),i&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=r.owner}setCurrent(e){this.current=e,this.updatedAt=eo.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=bG(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&S0(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,r){this.events[e]||(this.events[e]=new Gv);const n=this.events[e].add(r);return e==="change"?()=>{n(),Nr.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,r){this.passiveEffect=e,this.stopPassiveEffect=r}set(e,r=!0){!r||!this.passiveEffect?this.updateAndNotify(e,r):this.passiveEffect(e,this.updateAndNotify)}setWithVelocity(e,r,n){this.set(r),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,r=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=eo.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>dE)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,dE);return G8(parseFloat(this.current)-parseFloat(this.prevFrameValue),r)}start(e){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=e(r),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function eh(t,e){return new yG(t,e)}function wG(t,e,r){t.hasValue(e)?t.getValue(e).set(r):t.addValue(e,eh(r))}function xG(t,e){const r=P0(t,e);let{transitionEnd:n={},transition:i={},...s}=r||{};s={...s,...n};for(const o in s){const a=vG(s[o]);wG(t,o,a)}}const Yv=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),pE="data-"+Yv("framerAppearId");function gE(t){return t.props[pE]}const Qn=t=>!!(t&&t.getVelocity);function _G(t){return!!(Qn(t)&&t.add)}function Jv(t,e){const r=t.getValue("willChange");if(_G(r))return r.add(e)}function EG({protectedKeys:t,needsAnimating:e},r){const n=t.hasOwnProperty(r)&&e[r]!==!0;return e[r]=!1,n}function mE(t,e,{delay:r=0,transitionOverride:n,type:i}={}){var s;let{transition:o=t.getDefaultTransition(),transitionEnd:a,...u}=e;n&&(o=n);const l=[],d=i&&t.animationState&&t.animationState.getState()[i];for(const g in u){const y=t.getValue(g,(s=t.latestValues[g])!==null&&s!==void 0?s:null),A=u[g];if(A===void 0||d&&EG(d,g))continue;const P={delay:r,...yv(o||{},g)};let N=!1;if(window.MotionHandoffAnimation){const k=gE(t);if(k){const $=window.MotionHandoffAnimation(k,g,Nr);$!==null&&(P.startTime=$,N=!0)}}Jv(t,g),y.start(Wv(g,y,A,t.shouldReduceMotion&&vc.has(g)?{type:!1}:P,t,N));const D=y.animation;D&&l.push(D)}return a&&Promise.all(l).then(()=>{Nr.update(()=>{a&&xG(t,a)})}),l}function Xv(t,e,r={}){var n;const i=P0(t,e,r.type==="exit"?(n=t.presenceContext)===null||n===void 0?void 0:n.custom:void 0);let{transition:s=t.getDefaultTransition()||{}}=i||{};r.transitionOverride&&(s=r.transitionOverride);const o=i?()=>Promise.all(mE(t,i,r)):()=>Promise.resolve(),a=t.variantChildren&&t.variantChildren.size?(l=0)=>{const{delayChildren:d=0,staggerChildren:g,staggerDirection:y}=s;return SG(t,e,d+l,g,y,r)}:()=>Promise.resolve(),{when:u}=s;if(u){const[l,d]=u==="beforeChildren"?[o,a]:[a,o];return l().then(()=>d())}else return Promise.all([o(),a(r.delay)])}function SG(t,e,r=0,n=0,i=1,s){const o=[],a=(t.variantChildren.size-1)*n,u=i===1?(l=0)=>l*n:(l=0)=>a-l*n;return Array.from(t.variantChildren).sort(AG).forEach((l,d)=>{l.notify("AnimationStart",e),o.push(Xv(l,e,{...s,delay:r+u(d)}).then(()=>l.notify("AnimationComplete",e)))}),Promise.all(o)}function AG(t,e){return t.sortNodePosition(e)}function PG(t,e,r={}){t.notify("AnimationStart",e);let n;if(Array.isArray(e)){const i=e.map(s=>Xv(t,s,r));n=Promise.all(i)}else if(typeof e=="string")n=Xv(t,e,r);else{const i=typeof e=="function"?P0(t,e,r.custom):e;n=Promise.all(mE(t,i,r))}return n.then(()=>{t.notify("AnimationComplete",e)})}const MG=bv.length;function vE(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?vE(t.parent)||{}:{};return t.props.initial!==void 0&&(r.initial=t.props.initial),r}const e={};for(let r=0;rPromise.all(e.map(({animation:r,options:n})=>PG(t,r,n)))}function RG(t){let e=TG(t),r=bE(),n=!0;const i=u=>(l,d)=>{var g;const y=P0(t,d,u==="exit"?(g=t.presenceContext)===null||g===void 0?void 0:g.custom:void 0);if(y){const{transition:A,transitionEnd:P,...N}=y;l={...l,...N,...P}}return l};function s(u){e=u(t)}function o(u){const{props:l}=t,d=vE(t.parent)||{},g=[],y=new Set;let A={},P=1/0;for(let D=0;DP&&U,ue=!1;const _e=Array.isArray(q)?q:[q];let G=_e.reduce(i(k),{});K===!1&&(G={});const{prevResolvedValues:E={}}=$,m={...E,...G},f=x=>{z=!0,y.has(x)&&(ue=!0,y.delete(x)),$.needsAnimating[x]=!0;const _=t.getValue(x);_&&(_.liveStyle=!1)};for(const x in m){const _=G[x],S=E[x];if(A.hasOwnProperty(x))continue;let b=!1;gv(_)&&gv(S)?b=!h8(_,S):b=_!==S,b?_!=null?f(x):y.add(x):_!==void 0&&y.has(x)?f(x):$.protectedKeys[x]=!0}$.prevProp=q,$.prevResolvedValues=G,$.isActive&&(A={...A,...G}),n&&t.blockInitialAnimation&&(z=!1),z&&(!(J&&T)||ue)&&g.push(..._e.map(x=>({animation:x,options:{type:k}})))}if(y.size){const D={};y.forEach(k=>{const $=t.getBaseTarget(k),q=t.getValue(k);q&&(q.liveStyle=!0),D[k]=$??null}),g.push({animation:D})}let N=!!g.length;return n&&(l.initial===!1||l.initial===l.animate)&&!t.manuallyAnimateOnMount&&(N=!1),n=!1,N?e(g):Promise.resolve()}function a(u,l){var d;if(r[u].isActive===l)return Promise.resolve();(d=t.variantChildren)===null||d===void 0||d.forEach(y=>{var A;return(A=y.animationState)===null||A===void 0?void 0:A.setActive(u,l)}),r[u].isActive=l;const g=o(u);for(const y in r)r[y].protectedKeys={};return g}return{animateChanges:o,setActive:a,setAnimateFunction:s,getState:()=>r,reset:()=>{r=bE(),n=!0}}}function DG(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!h8(e,t):!1}function wc(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function bE(){return{animate:wc(!0),whileInView:wc(),whileHover:wc(),whileTap:wc(),whileDrag:wc(),whileFocus:wc(),exit:wc()}}class xa{constructor(e){this.isMounted=!1,this.node=e}update(){}}class OG extends xa{constructor(e){super(e),e.animationState||(e.animationState=RG(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();A0(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:r}=this.node.prevProps||{};e!==r&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)===null||e===void 0||e.call(this)}}let NG=0;class LG extends xa{constructor(){super(...arguments),this.id=NG++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;const i=this.node.animationState.setActive("exit",!e);r&&!e&&i.then(()=>r(this.id))}mount(){const{register:e}=this.node.presenceContext||{};e&&(this.unmount=e(this.id))}unmount(){}}const kG={animation:{Feature:OG},exit:{Feature:LG}},yE=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1;function L0(t,e="page"){return{point:{x:t[`${e}X`],y:t[`${e}Y`]}}}const $G=t=>e=>yE(e)&&t(e,L0(e));function No(t,e,r,n={passive:!0}){return t.addEventListener(e,r,n),()=>t.removeEventListener(e,r)}function Lo(t,e,r,n){return No(t,e,$G(r),n)}const wE=(t,e)=>Math.abs(t-e);function BG(t,e){const r=wE(t.x,e.x),n=wE(t.y,e.y);return Math.sqrt(r**2+n**2)}class xE{constructor(e,r,{transformPagePoint:n,contextWindow:i,dragSnapToOrigin:s=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const g=Qv(this.lastMoveEventInfo,this.history),y=this.startEvent!==null,A=BG(g.offset,{x:0,y:0})>=3;if(!y&&!A)return;const{point:P}=g,{timestamp:N}=Wn;this.history.push({...P,timestamp:N});const{onStart:D,onMove:k}=this.handlers;y||(D&&D(this.lastMoveEvent,g),this.startEvent=this.lastMoveEvent),k&&k(this.lastMoveEvent,g)},this.handlePointerMove=(g,y)=>{this.lastMoveEvent=g,this.lastMoveEventInfo=Zv(y,this.transformPagePoint),Nr.update(this.updatePoint,!0)},this.handlePointerUp=(g,y)=>{this.end();const{onEnd:A,onSessionEnd:P,resumeAnimation:N}=this.handlers;if(this.dragSnapToOrigin&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const D=Qv(g.type==="pointercancel"?this.lastMoveEventInfo:Zv(y,this.transformPagePoint),this.history);this.startEvent&&A&&A(g,D),P&&P(g,D)},!yE(e))return;this.dragSnapToOrigin=s,this.handlers=r,this.transformPagePoint=n,this.contextWindow=i||window;const o=L0(e),a=Zv(o,this.transformPagePoint),{point:u}=a,{timestamp:l}=Wn;this.history=[{...u,timestamp:l}];const{onSessionStart:d}=r;d&&d(e,Qv(a,this.history)),this.removeListeners=Oo(Lo(this.contextWindow,"pointermove",this.handlePointerMove),Lo(this.contextWindow,"pointerup",this.handlePointerUp),Lo(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),va(this.updatePoint)}}function Zv(t,e){return e?{point:e(t.point)}:t}function _E(t,e){return{x:t.x-e.x,y:t.y-e.y}}function Qv({point:t},e){return{point:t,delta:_E(t,EE(e)),offset:_E(t,FG(e)),velocity:UG(e,.1)}}function FG(t){return t[0]}function EE(t){return t[t.length-1]}function UG(t,e){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const i=EE(t);for(;r>=0&&(n=t[r],!(i.timestamp-n.timestamp>Zs(e)));)r--;if(!n)return{x:0,y:0};const s=Ro(i.timestamp-n.timestamp);if(s===0)return{x:0,y:0};const o={x:(i.x-n.x)/s,y:(i.y-n.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function SE(t){let e=null;return()=>{const r=()=>{e=null};return e===null?(e=t,r):!1}}const AE=SE("dragHorizontal"),PE=SE("dragVertical");function ME(t){let e=!1;if(t==="y")e=PE();else if(t==="x")e=AE();else{const r=AE(),n=PE();r&&n?e=()=>{r(),n()}:(r&&r(),n&&n())}return e}function IE(){const t=ME(!0);return t?(t(),!1):!0}function Fu(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}const CE=1e-4,jG=1-CE,qG=1+CE,TE=.01,zG=0-TE,HG=0+TE;function Ni(t){return t.max-t.min}function WG(t,e,r){return Math.abs(t-e)<=r}function RE(t,e,r,n=.5){t.origin=n,t.originPoint=Zr(e.min,e.max,t.origin),t.scale=Ni(r)/Ni(e),t.translate=Zr(r.min,r.max,t.origin)-t.originPoint,(t.scale>=jG&&t.scale<=qG||isNaN(t.scale))&&(t.scale=1),(t.translate>=zG&&t.translate<=HG||isNaN(t.translate))&&(t.translate=0)}function th(t,e,r,n){RE(t.x,e.x,r.x,n?n.originX:void 0),RE(t.y,e.y,r.y,n?n.originY:void 0)}function DE(t,e,r){t.min=r.min+e.min,t.max=t.min+Ni(e)}function KG(t,e,r){DE(t.x,e.x,r.x),DE(t.y,e.y,r.y)}function OE(t,e,r){t.min=e.min-r.min,t.max=t.min+Ni(e)}function rh(t,e,r){OE(t.x,e.x,r.x),OE(t.y,e.y,r.y)}function VG(t,{min:e,max:r},n){return e!==void 0&&tr&&(t=n?Zr(r,t,n.max):Math.min(t,r)),t}function NE(t,e,r){return{min:e!==void 0?t.min+e:void 0,max:r!==void 0?t.max+r-(t.max-t.min):void 0}}function GG(t,{top:e,left:r,bottom:n,right:i}){return{x:NE(t.x,r,i),y:NE(t.y,e,n)}}function LE(t,e){let r=e.min-t.min,n=e.max-t.max;return e.max-e.minn?r=Bu(e.min,e.max-n,t.min):n>i&&(r=Bu(t.min,t.max-i,e.min)),ba(0,1,r)}function XG(t,e){const r={};return e.min!==void 0&&(r.min=e.min-t.min),e.max!==void 0&&(r.max=e.max-t.min),r}const eb=.35;function ZG(t=eb){return t===!1?t=0:t===!0&&(t=eb),{x:kE(t,"left","right"),y:kE(t,"top","bottom")}}function kE(t,e,r){return{min:$E(t,e),max:$E(t,r)}}function $E(t,e){return typeof t=="number"?t:t[e]||0}const BE=()=>({translate:0,scale:1,origin:0,originPoint:0}),Uu=()=>({x:BE(),y:BE()}),FE=()=>({min:0,max:0}),ln=()=>({x:FE(),y:FE()});function ts(t){return[t("x"),t("y")]}function UE({top:t,left:e,right:r,bottom:n}){return{x:{min:e,max:r},y:{min:t,max:n}}}function QG({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function eY(t,e){if(!e)return t;const r=e({x:t.left,y:t.top}),n=e({x:t.right,y:t.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}function tb(t){return t===void 0||t===1}function rb({scale:t,scaleX:e,scaleY:r}){return!tb(t)||!tb(e)||!tb(r)}function xc(t){return rb(t)||jE(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function jE(t){return qE(t.x)||qE(t.y)}function qE(t){return t&&t!=="0%"}function k0(t,e,r){const n=t-r,i=e*n;return r+i}function zE(t,e,r,n,i){return i!==void 0&&(t=k0(t,i,n)),k0(t,r,n)+e}function nb(t,e=0,r=1,n,i){t.min=zE(t.min,e,r,n,i),t.max=zE(t.max,e,r,n,i)}function HE(t,{x:e,y:r}){nb(t.x,e.translate,e.scale,e.originPoint),nb(t.y,r.translate,r.scale,r.originPoint)}const WE=.999999999999,KE=1.0000000000001;function tY(t,e,r,n=!1){const i=r.length;if(!i)return;e.x=e.y=1;let s,o;for(let a=0;aWE&&(e.x=1),e.yWE&&(e.y=1)}function ju(t,e){t.min=t.min+e,t.max=t.max+e}function VE(t,e,r,n,i=.5){const s=Zr(t.min,t.max,i);nb(t,e,r,s,n)}function qu(t,e){VE(t.x,e.x,e.scaleX,e.scale,e.originX),VE(t.y,e.y,e.scaleY,e.scale,e.originY)}function GE(t,e){return UE(eY(t.getBoundingClientRect(),e))}function rY(t,e,r){const n=GE(t,r),{scroll:i}=e;return i&&(ju(n.x,i.offset.x),ju(n.y,i.offset.y)),n}const YE=({current:t})=>t?t.ownerDocument.defaultView:null,nY=new WeakMap;class iY{constructor(e){this.openGlobalLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ln(),this.visualElement=e}start(e,{snapToCursor:r=!1}={}){const{presenceContext:n}=this.visualElement;if(n&&n.isPresent===!1)return;const i=d=>{const{dragSnapToOrigin:g}=this.getProps();g?this.pauseAnimation():this.stopAnimation(),r&&this.snapToCursor(L0(d,"page").point)},s=(d,g)=>{const{drag:y,dragPropagation:A,onDragStart:P}=this.getProps();if(y&&!A&&(this.openGlobalLock&&this.openGlobalLock(),this.openGlobalLock=ME(y),!this.openGlobalLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),ts(D=>{let k=this.getAxisMotionValue(D).get()||0;if(Qs.test(k)){const{projection:$}=this.visualElement;if($&&$.layout){const q=$.layout.layoutBox[D];q&&(k=Ni(q)*(parseFloat(k)/100))}}this.originPoint[D]=k}),P&&Nr.postRender(()=>P(d,g)),Jv(this.visualElement,"transform");const{animationState:N}=this.visualElement;N&&N.setActive("whileDrag",!0)},o=(d,g)=>{const{dragPropagation:y,dragDirectionLock:A,onDirectionLock:P,onDrag:N}=this.getProps();if(!y&&!this.openGlobalLock)return;const{offset:D}=g;if(A&&this.currentDirection===null){this.currentDirection=sY(D),this.currentDirection!==null&&P&&P(this.currentDirection);return}this.updateAxis("x",g.point,D),this.updateAxis("y",g.point,D),this.visualElement.render(),N&&N(d,g)},a=(d,g)=>this.stop(d,g),u=()=>ts(d=>{var g;return this.getAnimationState(d)==="paused"&&((g=this.getAxisMotionValue(d).animation)===null||g===void 0?void 0:g.play())}),{dragSnapToOrigin:l}=this.getProps();this.panSession=new xE(e,{onSessionStart:i,onStart:s,onMove:o,onSessionEnd:a,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,contextWindow:YE(this.visualElement)})}stop(e,r){const n=this.isDragging;if(this.cancel(),!n)return;const{velocity:i}=r;this.startAnimation(i);const{onDragEnd:s}=this.getProps();s&&Nr.postRender(()=>s(e,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:r}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:n}=this.getProps();!n&&this.openGlobalLock&&(this.openGlobalLock(),this.openGlobalLock=null),r&&r.setActive("whileDrag",!1)}updateAxis(e,r,n){const{drag:i}=this.getProps();if(!n||!$0(e,i,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(o=VG(o,this.constraints[e],this.elastic[e])),s.set(o)}resolveConstraints(){var e;const{dragConstraints:r,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(e=this.visualElement.projection)===null||e===void 0?void 0:e.layout,s=this.constraints;r&&Fu(r)?this.constraints||(this.constraints=this.resolveRefConstraints()):r&&i?this.constraints=GG(i.layoutBox,r):this.constraints=!1,this.elastic=ZG(n),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&ts(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=XG(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:r}=this.getProps();if(!e||!Fu(e))return!1;const n=e.current;Do(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const s=rY(n,i.root,this.visualElement.getTransformPagePoint());let o=YG(i.layout.layoutBox,s);if(r){const a=r(QG(o));this.hasMutatedConstraints=!!a,a&&(o=UE(a))}return o}startAnimation(e){const{drag:r,dragMomentum:n,dragElastic:i,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),u=this.constraints||{},l=ts(d=>{if(!$0(d,r,this.currentDirection))return;let g=u&&u[d]||{};o&&(g={min:0,max:0});const y=i?200:1e6,A=i?40:1e7,P={type:"inertia",velocity:n?e[d]:0,bounceStiffness:y,bounceDamping:A,timeConstant:750,restDelta:1,restSpeed:10,...s,...g};return this.startAxisValueAnimation(d,P)});return Promise.all(l).then(a)}startAxisValueAnimation(e,r){const n=this.getAxisMotionValue(e);return Jv(this.visualElement,e),n.start(Wv(e,n,0,r,this.visualElement,!1))}stopAnimation(){ts(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){ts(e=>{var r;return(r=this.getAxisMotionValue(e).animation)===null||r===void 0?void 0:r.pause()})}getAnimationState(e){var r;return(r=this.getAxisMotionValue(e).animation)===null||r===void 0?void 0:r.state}getAxisMotionValue(e){const r=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps(),i=n[r];return i||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){ts(r=>{const{drag:n}=this.getProps();if(!$0(r,n,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(r);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[r];s.set(e[r]-Zr(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!Fu(r)||!n||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};ts(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const u=a.get();i[o]=JG({min:u,max:u},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),ts(o=>{if(!$0(o,e,null))return;const a=this.getAxisMotionValue(o),{min:u,max:l}=this.constraints[o];a.set(Zr(u,l,i[o]))})}addListeners(){if(!this.visualElement.current)return;nY.set(this.visualElement,this);const e=this.visualElement.current,r=Lo(e,"pointerdown",u=>{const{drag:l,dragListener:d=!0}=this.getProps();l&&d&&this.start(u)}),n=()=>{const{dragConstraints:u}=this.getProps();Fu(u)&&u.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,s=i.addEventListener("measure",n);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Nr.read(n);const o=No(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:u,hasLayoutChanged:l})=>{this.isDragging&&l&&(ts(d=>{const g=this.getAxisMotionValue(d);g&&(this.originPoint[d]+=u[d].translate,g.set(g.get()+u[d].translate))}),this.visualElement.render())});return()=>{o(),r(),s(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:o=eb,dragMomentum:a=!0}=e;return{...e,drag:r,dragDirectionLock:n,dragPropagation:i,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function $0(t,e,r){return(e===!0||e===t)&&(r===null||r===t)}function sY(t,e=10){let r=null;return Math.abs(t.y)>e?r="y":Math.abs(t.x)>e&&(r="x"),r}class oY extends xa{constructor(e){super(e),this.removeGroupControls=Hn,this.removeListeners=Hn,this.controls=new iY(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Hn}unmount(){this.removeGroupControls(),this.removeListeners()}}const JE=t=>(e,r)=>{t&&Nr.postRender(()=>t(e,r))};class aY extends xa{constructor(){super(...arguments),this.removePointerDownListener=Hn}onPointerDown(e){this.session=new xE(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:YE(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:r,onPan:n,onPanEnd:i}=this.node.getProps();return{onSessionStart:JE(e),onStart:JE(r),onMove:n,onEnd:(s,o)=>{delete this.session,i&&Nr.postRender(()=>i(s,o))}}}mount(){this.removePointerDownListener=Lo(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const B0=Pe.createContext(null);function cY(){const t=Pe.useContext(B0);if(t===null)return[!0,null];const{isPresent:e,onExitComplete:r,register:n}=t,i=Pe.useId();Pe.useEffect(()=>n(i),[]);const s=Pe.useCallback(()=>r&&r(i),[i,r]);return!e&&r?[!1,s]:[!0]}const ib=Pe.createContext({}),XE=Pe.createContext({}),F0={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function ZE(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const nh={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(zt.test(t))t=parseFloat(t);else return t;const r=ZE(t,e.target.x),n=ZE(t,e.target.y);return`${r}% ${n}%`}},uY={correct:(t,{treeScale:e,projectionDelta:r})=>{const n=t,i=wa.parse(t);if(i.length>5)return n;const s=wa.createTransformer(t),o=typeof i[0]!="number"?1:0,a=r.x.scale*e.x,u=r.y.scale*e.y;i[0+o]/=a,i[1+o]/=u;const l=Zr(a,u,.5);return typeof i[2+o]=="number"&&(i[2+o]/=l),typeof i[3+o]=="number"&&(i[3+o]/=l),s(i)}},U0={};function fY(t){Object.assign(U0,t)}const{schedule:sb}=p8(queueMicrotask,!1);class lY extends Pe.Component{componentDidMount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n,layoutId:i}=this.props,{projection:s}=e;fY(hY),s&&(r.group&&r.group.add(s),n&&n.register&&i&&n.register(s),s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),F0.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:r,visualElement:n,drag:i,isPresent:s}=this.props,o=n.projection;return o&&(o.isPresent=s,i||e.layoutDependency!==r||r===void 0?o.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?o.promote():o.relegate()||Nr.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),sb.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:i}=e;i&&(i.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(i),n&&n.deregister&&n.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function QE(t){const[e,r]=cY(),n=Pe.useContext(ib);return me.jsx(lY,{...t,layoutGroup:n,switchLayoutGroup:Pe.useContext(XE),isPresent:e,safeToRemove:r})}const hY={borderRadius:{...nh,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:nh,borderTopRightRadius:nh,borderBottomLeftRadius:nh,borderBottomRightRadius:nh,boxShadow:uY},eS=["TopLeft","TopRight","BottomLeft","BottomRight"],dY=eS.length,tS=t=>typeof t=="string"?parseFloat(t):t,rS=t=>typeof t=="number"||zt.test(t);function pY(t,e,r,n,i,s){i?(t.opacity=Zr(0,r.opacity!==void 0?r.opacity:1,gY(n)),t.opacityExit=Zr(e.opacity!==void 0?e.opacity:1,0,mY(n))):s&&(t.opacity=Zr(e.opacity!==void 0?e.opacity:1,r.opacity!==void 0?r.opacity:1,n));for(let o=0;one?1:r(Bu(t,e,n))}function sS(t,e){t.min=e.min,t.max=e.max}function rs(t,e){sS(t.x,e.x),sS(t.y,e.y)}function oS(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function aS(t,e,r,n,i){return t-=e,t=k0(t,1/r,n),i!==void 0&&(t=k0(t,1/i,n)),t}function vY(t,e=0,r=1,n=.5,i,s=t,o=t){if(Qs.test(e)&&(e=parseFloat(e),e=Zr(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=Zr(s.min,s.max,n);t===s&&(a-=e),t.min=aS(t.min,e,r,a,i),t.max=aS(t.max,e,r,a,i)}function cS(t,e,[r,n,i],s,o){vY(t,e[r],e[n],e[i],e.scale,s,o)}const bY=["x","scaleX","originX"],yY=["y","scaleY","originY"];function uS(t,e,r,n){cS(t.x,e,bY,r?r.x:void 0,n?n.x:void 0),cS(t.y,e,yY,r?r.y:void 0,n?n.y:void 0)}function fS(t){return t.translate===0&&t.scale===1}function lS(t){return fS(t.x)&&fS(t.y)}function hS(t,e){return t.min===e.min&&t.max===e.max}function wY(t,e){return hS(t.x,e.x)&&hS(t.y,e.y)}function dS(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function pS(t,e){return dS(t.x,e.x)&&dS(t.y,e.y)}function gS(t){return Ni(t.x)/Ni(t.y)}function mS(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class xY{constructor(){this.members=[]}add(e){Kv(this.members,e),e.scheduleRender()}remove(e){if(Vv(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const r=this.members[this.members.length-1];r&&this.promote(r)}}relegate(e){const r=this.members.findIndex(i=>e===i);if(r===0)return!1;let n;for(let i=r;i>=0;i--){const s=this.members[i];if(s.isPresent!==!1){n=s;break}}return n?(this.promote(n),!0):!1}promote(e,r){const n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender(),e.resumeFrom=n,r&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:r,resumingFrom:n}=e;r.onExitComplete&&r.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function _Y(t,e,r){let n="";const i=t.x.translate/e.x,s=t.y.translate/e.y,o=(r==null?void 0:r.z)||0;if((i||s||o)&&(n=`translate3d(${i}px, ${s}px, ${o}px) `),(e.x!==1||e.y!==1)&&(n+=`scale(${1/e.x}, ${1/e.y}) `),r){const{transformPerspective:l,rotate:d,rotateX:g,rotateY:y,skewX:A,skewY:P}=r;l&&(n=`perspective(${l}px) ${n}`),d&&(n+=`rotate(${d}deg) `),g&&(n+=`rotateX(${g}deg) `),y&&(n+=`rotateY(${y}deg) `),A&&(n+=`skewX(${A}deg) `),P&&(n+=`skewY(${P}deg) `)}const a=t.x.scale*e.x,u=t.y.scale*e.y;return(a!==1||u!==1)&&(n+=`scale(${a}, ${u})`),n||"none"}const EY=(t,e)=>t.depth-e.depth;class SY{constructor(){this.children=[],this.isDirty=!1}add(e){Kv(this.children,e),this.isDirty=!0}remove(e){Vv(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(EY),this.isDirty=!1,this.children.forEach(e)}}function j0(t){const e=Qn(t)?t.get():t;return mG(e)?e.toValue():e}function AY(t,e){const r=eo.now(),n=({timestamp:i})=>{const s=i-r;s>=e&&(va(n),t(s-e))};return Nr.read(n,!0),()=>va(n)}function PY(t){return t instanceof SVGElement&&t.tagName!=="svg"}function MY(t,e,r){const n=Qn(t)?t:eh(t);return n.start(Wv("",n,e,r)),n.animation}const _c={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},ih=typeof window<"u"&&window.MotionDebug!==void 0,ob=["","X","Y","Z"],IY={visibility:"hidden"},vS=1e3;let CY=0;function ab(t,e,r,n){const{latestValues:i}=e;i[t]&&(r[t]=i[t],e.setStaticValue(t,0),n&&(n[t]=0))}function bS(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const r=gE(e);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:i,layoutId:s}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Nr,!(i||s))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&bS(n)}function yS({attachResizeListener:t,defaultParent:e,measureScroll:r,checkIsScrollRoot:n,resetTransform:i}){return class{constructor(o={},a=e==null?void 0:e()){this.id=CY++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,ih&&(_c.totalNodes=_c.resolvedTargetDeltas=_c.recalculatedProjection=0),this.nodes.forEach(DY),this.nodes.forEach($Y),this.nodes.forEach(BY),this.nodes.forEach(OY),ih&&window.MotionDebug.record(_c)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let u=0;uthis.root.updateBlockedByResize=!1;t(o,()=>{this.root.updateBlockedByResize=!0,g&&g(),g=AY(y,250),F0.hasAnimatedSinceResize&&(F0.hasAnimatedSinceResize=!1,this.nodes.forEach(xS))})}u&&this.root.registerSharedNode(u,this),this.options.animate!==!1&&d&&(u||l)&&this.addEventListener("didUpdate",({delta:g,hasLayoutChanged:y,hasRelativeTargetChanged:A,layout:P})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const N=this.options.transition||d.getDefaultTransition()||zY,{onLayoutAnimationStart:D,onLayoutAnimationComplete:k}=d.getProps(),$=!this.targetLayout||!pS(this.targetLayout,P)||A,q=!y&&A;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||q||y&&($||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(g,q);const U={...yv(N,"layout"),onPlay:D,onComplete:k};(d.shouldReduceMotion||this.options.layoutRoot)&&(U.delay=0,U.type=!1),this.startAnimation(U)}else y||xS(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=P})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,va(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(FY),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&bS(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let u=0;u{const K=U/1e3;_S(g.x,o.x,K),_S(g.y,o.y,K),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(rh(y,this.layout.layoutBox,this.relativeParent.layout.layoutBox),jY(this.relativeTarget,this.relativeTargetOrigin,y,K),q&&wY(this.relativeTarget,q)&&(this.isProjectionDirty=!1),q||(q=ln()),rs(q,this.relativeTarget)),N&&(this.animationValues=d,pY(d,l,this.latestValues,K,$,k)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=K},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(va(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Nr.update(()=>{F0.hasAnimatedSinceResize=!0,this.currentAnimation=MY(0,vS,{...o,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(vS),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:u,layout:l,latestValues:d}=o;if(!(!a||!u||!l)){if(this!==o&&this.layout&&l&&MS(this.options.animationType,this.layout.layoutBox,l.layoutBox)){u=this.target||ln();const g=Ni(this.layout.layoutBox.x);u.x.min=o.target.x.min,u.x.max=u.x.min+g;const y=Ni(this.layout.layoutBox.y);u.y.min=o.target.y.min,u.y.max=u.y.min+y}rs(a,u),qu(a,d),th(this.projectionDeltaWithTransform,this.layoutCorrected,a,d)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new xY),this.sharedNodes.get(o).add(a);const l=a.options.initialPromotionConfig;a.promote({transition:l?l.transition:void 0,preserveFollowOpacity:l&&l.shouldPreserveFollowOpacity?l.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:a}=this.options;return a?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:a}=this.options;return a?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:u}={}){const l=this.getStack();l&&l.promote(this,u),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:u}=o;if((u.z||u.rotate||u.rotateX||u.rotateY||u.rotateZ||u.skewX||u.skewY)&&(a=!0),!a)return;const l={};u.z&&ab("z",o,l,this.animationValues);for(let d=0;d{var a;return(a=o.currentAnimation)===null||a===void 0?void 0:a.stop()}),this.root.nodes.forEach(wS),this.root.sharedNodes.clear()}}}function TY(t){t.updateLayout()}function RY(t){var e;const r=((e=t.resumeFrom)===null||e===void 0?void 0:e.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&r&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:i}=t.layout,{animationType:s}=t.options,o=r.source!==t.layout.source;s==="size"?ts(g=>{const y=o?r.measuredBox[g]:r.layoutBox[g],A=Ni(y);y.min=n[g].min,y.max=y.min+A}):MS(s,r.layoutBox,n)&&ts(g=>{const y=o?r.measuredBox[g]:r.layoutBox[g],A=Ni(n[g]);y.max=y.min+A,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[g].max=t.relativeTarget[g].min+A)});const a=Uu();th(a,n,r.layoutBox);const u=Uu();o?th(u,t.applyTransform(i,!0),r.measuredBox):th(u,n,r.layoutBox);const l=!lS(a);let d=!1;if(!t.resumeFrom){const g=t.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:y,layout:A}=g;if(y&&A){const P=ln();rh(P,r.layoutBox,y.layoutBox);const N=ln();rh(N,n,A.layoutBox),pS(P,N)||(d=!0),g.options.layoutRoot&&(t.relativeTarget=N,t.relativeTargetOrigin=P,t.relativeParent=g)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:r,delta:u,layoutDelta:a,hasLayoutChanged:l,hasRelativeTargetChanged:d})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function DY(t){ih&&_c.totalNodes++,t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function OY(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function NY(t){t.clearSnapshot()}function wS(t){t.clearMeasurements()}function LY(t){t.isLayoutDirty=!1}function kY(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function xS(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function $Y(t){t.resolveTargetDelta()}function BY(t){t.calcProjection()}function FY(t){t.resetSkewAndRotation()}function UY(t){t.removeLeadSnapshot()}function _S(t,e,r){t.translate=Zr(e.translate,0,r),t.scale=Zr(e.scale,1,r),t.origin=e.origin,t.originPoint=e.originPoint}function ES(t,e,r,n){t.min=Zr(e.min,r.min,n),t.max=Zr(e.max,r.max,n)}function jY(t,e,r,n){ES(t.x,e.x,r.x,n),ES(t.y,e.y,r.y,n)}function qY(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const zY={duration:.45,ease:[.4,0,.1,1]},SS=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),AS=SS("applewebkit/")&&!SS("chrome/")?Math.round:Hn;function PS(t){t.min=AS(t.min),t.max=AS(t.max)}function HY(t){PS(t.x),PS(t.y)}function MS(t,e,r){return t==="position"||t==="preserve-aspect"&&!WG(gS(e),gS(r),.2)}function WY(t){var e;return t!==t.root&&((e=t.scroll)===null||e===void 0?void 0:e.wasRoot)}const KY=yS({attachResizeListener:(t,e)=>No(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),cb={current:void 0},IS=yS({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!cb.current){const t=new KY({});t.mount(window),t.setOptions({layoutScroll:!0}),cb.current=t}return cb.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),VY={pan:{Feature:aY},drag:{Feature:oY,ProjectionNode:IS,MeasureLayout:QE}};function CS(t,e){const r=e?"pointerenter":"pointerleave",n=e?"onHoverStart":"onHoverEnd",i=(s,o)=>{if(s.pointerType==="touch"||IE())return;const a=t.getProps();t.animationState&&a.whileHover&&t.animationState.setActive("whileHover",e);const u=a[n];u&&Nr.postRender(()=>u(s,o))};return Lo(t.current,r,i,{passive:!t.getProps()[n]})}class GY extends xa{mount(){this.unmount=Oo(CS(this.node,!0),CS(this.node,!1))}unmount(){}}class YY extends xa{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Oo(No(this.node.current,"focus",()=>this.onFocus()),No(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const TS=(t,e)=>e?t===e?!0:TS(t,e.parentElement):!1;function ub(t,e){if(!e)return;const r=new PointerEvent("pointer"+t);e(r,L0(r))}class JY extends xa{constructor(){super(...arguments),this.removeStartListeners=Hn,this.removeEndListeners=Hn,this.removeAccessibleListeners=Hn,this.startPointerPress=(e,r)=>{if(this.isPressing)return;this.removeEndListeners();const n=this.node.getProps(),s=Lo(window,"pointerup",(a,u)=>{if(!this.checkPressEnd())return;const{onTap:l,onTapCancel:d,globalTapTarget:g}=this.node.getProps(),y=!g&&!TS(this.node.current,a.target)?d:l;y&&Nr.update(()=>y(a,u))},{passive:!(n.onTap||n.onPointerUp)}),o=Lo(window,"pointercancel",(a,u)=>this.cancelPress(a,u),{passive:!(n.onTapCancel||n.onPointerCancel)});this.removeEndListeners=Oo(s,o),this.startPress(e,r)},this.startAccessiblePress=()=>{const e=s=>{if(s.key!=="Enter"||this.isPressing)return;const o=a=>{a.key!=="Enter"||!this.checkPressEnd()||ub("up",(u,l)=>{const{onTap:d}=this.node.getProps();d&&Nr.postRender(()=>d(u,l))})};this.removeEndListeners(),this.removeEndListeners=No(this.node.current,"keyup",o),ub("down",(a,u)=>{this.startPress(a,u)})},r=No(this.node.current,"keydown",e),n=()=>{this.isPressing&&ub("cancel",(s,o)=>this.cancelPress(s,o))},i=No(this.node.current,"blur",n);this.removeAccessibleListeners=Oo(r,i)}}startPress(e,r){this.isPressing=!0;const{onTapStart:n,whileTap:i}=this.node.getProps();i&&this.node.animationState&&this.node.animationState.setActive("whileTap",!0),n&&Nr.postRender(()=>n(e,r))}checkPressEnd(){return this.removeEndListeners(),this.isPressing=!1,this.node.getProps().whileTap&&this.node.animationState&&this.node.animationState.setActive("whileTap",!1),!IE()}cancelPress(e,r){if(!this.checkPressEnd())return;const{onTapCancel:n}=this.node.getProps();n&&Nr.postRender(()=>n(e,r))}mount(){const e=this.node.getProps(),r=Lo(e.globalTapTarget?window:this.node.current,"pointerdown",this.startPointerPress,{passive:!(e.onTapStart||e.onPointerStart)}),n=No(this.node.current,"focus",this.startAccessiblePress);this.removeStartListeners=Oo(r,n)}unmount(){this.removeStartListeners(),this.removeEndListeners(),this.removeAccessibleListeners()}}const fb=new WeakMap,lb=new WeakMap,XY=t=>{const e=fb.get(t.target);e&&e(t)},ZY=t=>{t.forEach(XY)};function QY({root:t,...e}){const r=t||document;lb.has(r)||lb.set(r,{});const n=lb.get(r),i=JSON.stringify(e);return n[i]||(n[i]=new IntersectionObserver(ZY,{root:t,...e})),n[i]}function eJ(t,e,r){const n=QY(e);return fb.set(t,r),n.observe(t),()=>{fb.delete(t),n.unobserve(t)}}const tJ={some:0,all:1};class rJ extends xa{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:r,margin:n,amount:i="some",once:s}=e,o={root:r?r.current:void 0,rootMargin:n,threshold:typeof i=="number"?i:tJ[i]},a=u=>{const{isIntersecting:l}=u;if(this.isInView===l||(this.isInView=l,s&&!l&&this.hasEnteredView))return;l&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",l);const{onViewportEnter:d,onViewportLeave:g}=this.node.getProps(),y=l?d:g;y&&y(u)};return eJ(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:r}=this.node;["amount","margin","root"].some(nJ(e,r))&&this.startObserver()}unmount(){}}function nJ({viewport:t={}},{viewport:e={}}={}){return r=>t[r]!==e[r]}const iJ={inView:{Feature:rJ},tap:{Feature:JY},focus:{Feature:YY},hover:{Feature:GY}},sJ={layout:{ProjectionNode:IS,MeasureLayout:QE}},hb=Pe.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"}),q0=Pe.createContext({}),db=typeof window<"u",RS=db?Pe.useLayoutEffect:Pe.useEffect,DS=Pe.createContext({strict:!1});function oJ(t,e,r,n,i){var s,o;const{visualElement:a}=Pe.useContext(q0),u=Pe.useContext(DS),l=Pe.useContext(B0),d=Pe.useContext(hb).reducedMotion,g=Pe.useRef();n=n||u.renderer,!g.current&&n&&(g.current=n(t,{visualState:e,parent:a,props:r,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:d}));const y=g.current,A=Pe.useContext(XE);y&&!y.projection&&i&&(y.type==="html"||y.type==="svg")&&aJ(g.current,r,i,A);const P=Pe.useRef(!1);Pe.useInsertionEffect(()=>{y&&P.current&&y.update(r,l)});const N=r[pE],D=Pe.useRef(!!N&&!(!((s=window.MotionHandoffIsComplete)===null||s===void 0)&&s.call(window,N))&&((o=window.MotionHasOptimisedAnimation)===null||o===void 0?void 0:o.call(window,N)));return RS(()=>{y&&(P.current=!0,window.MotionIsMounted=!0,y.updateFeatures(),sb.render(y.render),D.current&&y.animationState&&y.animationState.animateChanges())}),Pe.useEffect(()=>{y&&(!D.current&&y.animationState&&y.animationState.animateChanges(),D.current&&(queueMicrotask(()=>{var k;(k=window.MotionHandoffMarkAsComplete)===null||k===void 0||k.call(window,N)}),D.current=!1))}),y}function aJ(t,e,r,n){const{layoutId:i,layout:s,drag:o,dragConstraints:a,layoutScroll:u,layoutRoot:l}=e;t.projection=new r(t.latestValues,e["data-framer-portal-id"]?void 0:OS(t.parent)),t.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&Fu(a),visualElement:t,animationType:typeof s=="string"?s:"both",initialPromotionConfig:n,layoutScroll:u,layoutRoot:l})}function OS(t){if(t)return t.options.allowProjection!==!1?t.projection:OS(t.parent)}function cJ(t,e,r){return Pe.useCallback(n=>{n&&t.mount&&t.mount(n),e&&(n?e.mount(n):e.unmount()),r&&(typeof r=="function"?r(n):Fu(r)&&(r.current=n))},[e])}function z0(t){return A0(t.animate)||bv.some(e=>Kl(t[e]))}function NS(t){return!!(z0(t)||t.variants)}function uJ(t,e){if(z0(t)){const{initial:r,animate:n}=t;return{initial:r===!1||Kl(r)?r:void 0,animate:Kl(n)?n:void 0}}return t.inherit!==!1?e:{}}function fJ(t){const{initial:e,animate:r}=uJ(t,Pe.useContext(q0));return Pe.useMemo(()=>({initial:e,animate:r}),[LS(e),LS(r)])}function LS(t){return Array.isArray(t)?t.join(" "):t}const kS={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},zu={};for(const t in kS)zu[t]={isEnabled:e=>kS[t].some(r=>!!e[r])};function lJ(t){for(const e in t)zu[e]={...zu[e],...t[e]}}const hJ=Symbol.for("motionComponentSymbol");function dJ({preloadedFeatures:t,createVisualElement:e,useRender:r,useVisualState:n,Component:i}){t&&lJ(t);function s(a,u){let l;const d={...Pe.useContext(hb),...a,layoutId:pJ(a)},{isStatic:g}=d,y=fJ(a),A=n(a,g);if(!g&&db){gJ(d,t);const P=mJ(d);l=P.MeasureLayout,y.visualElement=oJ(i,A,d,e,P.ProjectionNode)}return me.jsxs(q0.Provider,{value:y,children:[l&&y.visualElement?me.jsx(l,{visualElement:y.visualElement,...d}):null,r(i,a,cJ(A,y.visualElement,u),A,g,y.visualElement)]})}const o=Pe.forwardRef(s);return o[hJ]=i,o}function pJ({layoutId:t}){const e=Pe.useContext(ib).id;return e&&t!==void 0?e+"-"+t:t}function gJ(t,e){const r=Pe.useContext(DS).strict;if(process.env.NODE_ENV!=="production"&&e&&r){const n="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?Nu(!1,n):Do(!1,n)}}function mJ(t){const{drag:e,layout:r}=zu;if(!e&&!r)return{};const n={...e,...r};return{MeasureLayout:e!=null&&e.isEnabled(t)||r!=null&&r.isEnabled(t)?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}const vJ=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function pb(t){return typeof t!="string"||t.includes("-")?!1:!!(vJ.indexOf(t)>-1||/[A-Z]/u.test(t))}function $S(t,{style:e,vars:r},n,i){Object.assign(t.style,e,i&&i.getProjectionStyles(n));for(const s in r)t.style.setProperty(s,r[s])}const BS=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function FS(t,e,r,n){$S(t,e,void 0,n);for(const i in e.attrs)t.setAttribute(BS.has(i)?i:Yv(i),e.attrs[i])}function US(t,{layout:e,layoutId:r}){return vc.has(t)||t.startsWith("origin")||(e||r!==void 0)&&(!!U0[t]||t==="opacity")}function gb(t,e,r){var n;const{style:i}=t,s={};for(const o in i)(Qn(i[o])||e.style&&Qn(e.style[o])||US(o,t)||((n=r==null?void 0:r.getValue(o))===null||n===void 0?void 0:n.liveStyle)!==void 0)&&(s[o]=i[o]);return s}function jS(t,e,r){const n=gb(t,e,r);for(const i in t)if(Qn(t[i])||Qn(e[i])){const s=Vl.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;n[s]=t[i]}return n}function mb(t){const e=Pe.useRef(null);return e.current===null&&(e.current=t()),e.current}function bJ({scrapeMotionValuesFromProps:t,createRenderState:e,onMount:r},n,i,s){const o={latestValues:yJ(n,i,s,t),renderState:e()};return r&&(o.mount=a=>r(n,a,o)),o}const qS=t=>(e,r)=>{const n=Pe.useContext(q0),i=Pe.useContext(B0),s=()=>bJ(t,e,n,i);return r?s():mb(s)};function yJ(t,e,r,n){const i={},s=n(t,{});for(const y in s)i[y]=j0(s[y]);let{initial:o,animate:a}=t;const u=z0(t),l=NS(t);e&&l&&!u&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let d=r?r.initial===!1:!1;d=d||o===!1;const g=d?a:o;if(g&&typeof g!="boolean"&&!A0(g)){const y=Array.isArray(g)?g:[g];for(let A=0;A({style:{},transform:{},transformOrigin:{},vars:{}}),zS=()=>({...vb(),attrs:{}}),HS=(t,e)=>e&&typeof t=="number"?e.transform(t):t,wJ={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},xJ=Vl.length;function _J(t,e,r){let n="",i=!0;for(let s=0;stypeof t=="string"&&t.toLowerCase()==="svg",MJ={useVisualState:qS({scrapeMotionValuesFromProps:jS,createRenderState:zS,onMount:(t,e,{renderState:r,latestValues:n})=>{Nr.read(()=>{try{r.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{r.dimensions={x:0,y:0,width:0,height:0}}}),Nr.render(()=>{yb(r,n,wb(e.tagName),t.transformTemplate),FS(e,r)})}})},IJ={useVisualState:qS({scrapeMotionValuesFromProps:gb,createRenderState:vb})};function KS(t,e,r){for(const n in e)!Qn(e[n])&&!US(n,r)&&(t[n]=e[n])}function CJ({transformTemplate:t},e){return Pe.useMemo(()=>{const r=vb();return bb(r,e,t),Object.assign({},r.vars,r.style)},[e])}function TJ(t,e){const r=t.style||{},n={};return KS(n,r,t),Object.assign(n,CJ(t,e)),n}function RJ(t,e){const r={},n=TJ(t,e);return t.drag&&t.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(r.tabIndex=0),r.style=n,r}const DJ=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function H0(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||DJ.has(t)}let VS=t=>!H0(t);function OJ(t){t&&(VS=e=>e.startsWith("on")?!H0(e):t(e))}try{OJ(require("@emotion/is-prop-valid").default)}catch{}function NJ(t,e,r){const n={};for(const i in t)i==="values"&&typeof t.values=="object"||(VS(i)||r===!0&&H0(i)||!e&&!H0(i)||t.draggable&&i.startsWith("onDrag"))&&(n[i]=t[i]);return n}function LJ(t,e,r,n){const i=Pe.useMemo(()=>{const s=zS();return yb(s,e,wb(n),t.transformTemplate),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};KS(s,t.style,t),i.style={...s,...i.style}}return i}function kJ(t=!1){return(r,n,i,{latestValues:s},o)=>{const u=(pb(r)?LJ:RJ)(n,s,o,r),l=NJ(n,typeof r=="string",t),d=r!==Pe.Fragment?{...l,...u,ref:i}:{},{children:g}=n,y=Pe.useMemo(()=>Qn(g)?g.get():g,[g]);return Pe.createElement(r,{...d,children:y})}}function $J(t,e){return function(n,{forwardMotionProps:i}={forwardMotionProps:!1}){const o={...pb(n)?MJ:IJ,preloadedFeatures:t,useRender:kJ(i),createVisualElement:e,Component:n};return dJ(o)}}const xb={current:null},GS={current:!1};function BJ(){if(GS.current=!0,!!db)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>xb.current=t.matches;t.addListener(e),e()}else xb.current=!1}function FJ(t,e,r){for(const n in e){const i=e[n],s=r[n];if(Qn(i))t.addValue(n,i),process.env.NODE_ENV==="development"&&S0(i.version==="11.11.17",`Attempting to mix Motion versions ${i.version} with 11.11.17 may not work as expected.`);else if(Qn(s))t.addValue(n,eh(i,{owner:t}));else if(s!==i)if(t.hasValue(n)){const o=t.getValue(n);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(n);t.addValue(n,eh(o!==void 0?o:i,{owner:t}))}}for(const n in r)e[n]===void 0&&t.removeValue(n);return e}const YS=new WeakMap,UJ=[...O8,Zn,wa],jJ=t=>UJ.find(D8(t)),JS=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class qJ{scrapeMotionValuesFromProps(e,r,n){return{}}constructor({parent:e,props:r,presenceContext:n,reducedMotionConfig:i,blockInitialAnimation:s,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Pv,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const y=eo.now();this.renderScheduledAtthis.bindToMotionValue(n,r)),GS.current||BJ(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:xb.current,process.env.NODE_ENV!=="production"&&S0(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected."),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){YS.delete(this.current),this.projection&&this.projection.unmount(),va(this.notifyUpdate),va(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const r=this.features[e];r&&(r.unmount(),r.isMounted=!1)}this.current=null}bindToMotionValue(e,r){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const n=vc.has(e),i=r.on("change",a=>{this.latestValues[e]=a,this.props.onUpdate&&Nr.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)}),s=r.on("renderRequest",this.scheduleRender);let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,r)),this.valueSubscriptions.set(e,()=>{i(),s(),o&&o(),r.owner&&r.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in zu){const r=zu[e];if(!r)continue;const{isEnabled:n,Feature:i}=r;if(!this.features[e]&&i&&n(this.props)&&(this.features[e]=new i(this)),this.features[e]){const s=this.features[e];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):ln()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,r){this.latestValues[e]=r}update(e,r){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let n=0;nr.variantChildren.delete(e)}addValue(e,r){const n=this.values.get(e);r!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,r),this.values.set(e,r),this.latestValues[e]=r.get())}removeValue(e){this.values.delete(e);const r=this.valueSubscriptions.get(e);r&&(r(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,r){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&r!==void 0&&(n=eh(r===null?void 0:r,{owner:this}),this.addValue(e,n)),n}readValue(e,r){var n;let i=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:(n=this.getBaseTargetFromProps(this.props,e))!==null&&n!==void 0?n:this.readValueFromInstance(this.current,e,this.options);return i!=null&&(typeof i=="string"&&(S8(i)||E8(i))?i=parseFloat(i):!jJ(i)&&wa.test(r)&&(i=H8(e,r)),this.setBaseTarget(e,Qn(i)?i.get():i)),Qn(i)?i.get():i}setBaseTarget(e,r){this.baseTarget[e]=r}getBaseTarget(e){var r;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const o=mv(this.props,n,(r=this.presenceContext)===null||r===void 0?void 0:r.custom);o&&(i=o[e])}if(n&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,e);return s!==void 0&&!Qn(s)?s:this.initialValues[e]!==void 0&&i===void 0?void 0:this.baseTarget[e]}on(e,r){return this.events[e]||(this.events[e]=new Gv),this.events[e].add(r)}notify(e,...r){this.events[e]&&this.events[e].notify(...r)}}class XS extends qJ{constructor(){super(...arguments),this.KeyframeResolver=W8}sortInstanceNodePosition(e,r){return e.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(e,r){return e.style?e.style[r]:void 0}removeValueFromRenderState(e,{vars:r,style:n}){delete r[e],delete n[e]}}function zJ(t){return window.getComputedStyle(t)}class HJ extends XS{constructor(){super(...arguments),this.type="html",this.renderInstance=$S}readValueFromInstance(e,r){if(vc.has(r)){const n=Ov(r);return n&&n.default||0}else{const n=zJ(e),i=(P8(r)?n.getPropertyValue(r):n[r])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:r}){return GE(e,r)}build(e,r,n){bb(e,r,n.transformTemplate)}scrapeMotionValuesFromProps(e,r,n){return gb(e,r,n)}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Qn(e)&&(this.childSubscription=e.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class WJ extends XS{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=ln}getBaseTargetFromProps(e,r){return e[r]}readValueFromInstance(e,r){if(vc.has(r)){const n=Ov(r);return n&&n.default||0}return r=BS.has(r)?r:Yv(r),e.getAttribute(r)}scrapeMotionValuesFromProps(e,r,n){return jS(e,r,n)}build(e,r,n){yb(e,r,this.isSVGTag,n.transformTemplate)}renderInstance(e,r,n,i){FS(e,r,n,i)}mount(e){this.isSVGTag=wb(e.tagName),super.mount(e)}}const KJ=(t,e)=>pb(t)?new WJ(e):new HJ(e,{allowProjection:t!==Pe.Fragment}),VJ=$J({...kG,...iJ,...VY,...sJ},KJ),GJ=CK(VJ);class YJ extends Yt.Component{getSnapshotBeforeUpdate(e){const r=this.props.childRef.current;if(r&&e.isPresent&&!this.props.isPresent){const n=this.props.sizeRef.current;n.height=r.offsetHeight||0,n.width=r.offsetWidth||0,n.top=r.offsetTop,n.left=r.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function JJ({children:t,isPresent:e}){const r=Pe.useId(),n=Pe.useRef(null),i=Pe.useRef({width:0,height:0,top:0,left:0}),{nonce:s}=Pe.useContext(hb);return Pe.useInsertionEffect(()=>{const{width:o,height:a,top:u,left:l}=i.current;if(e||!n.current||!o||!a)return;n.current.dataset.motionPopId=r;const d=document.createElement("style");return s&&(d.nonce=s),document.head.appendChild(d),d.sheet&&d.sheet.insertRule(` + */const q4=zi("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $z=zi("UserRoundCheck",[["path",{d:"M2 21a8 8 0 0 1 13.292-6",key:"bjp14o"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]),z4=new Set;function wd(t,e,r){t||z4.has(e)||(console.warn(e),z4.add(e))}function qz(t){if(typeof Proxy>"u")return t;const e=new Map,r=(...n)=>(process.env.NODE_ENV!=="production"&&wd(!1,"motion() is deprecated. Use motion.create() instead."),t(...n));return new Proxy(r,{get:(n,i)=>i==="create"?t:(e.has(i)||e.set(i,t(i)),e.get(i))})}function xd(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}const Iv=t=>Array.isArray(t);function H4(t,e){if(!Array.isArray(e))return!1;const r=e.length;if(r!==t.length)return!1;for(let n=0;n{e[0][n]=r.get(),e[1][n]=r.getVelocity()}),e}function Mv(t,e,r,n){if(typeof e=="function"){const[i,s]=W4(n);e=e(r!==void 0?r:t.custom,i,s)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[i,s]=W4(n);e=e(r!==void 0?r:t.custom,i,s)}return e}function _d(t,e,r){const n=t.getProps();return Mv(n,e,r!==void 0?r:n.custom,t)}const Cv=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Rv=["initial",...Cv],Kf=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ja=new Set(Kf),Ds=t=>t*1e3,to=t=>t/1e3,zz={type:"spring",stiffness:500,damping:25,restSpeed:10},Hz=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Wz={type:"keyframes",duration:.8},Kz={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},Vz=(t,{keyframes:e})=>e.length>2?Wz:ja.has(t)?t.startsWith("scale")?Hz(e[1]):zz:Kz;function Tv(t,e){return t?t[e]||t.default||t:void 0}const Gz={useManualTiming:!1},Yz=t=>t!==null;function Ed(t,{repeat:e,repeatType:r="loop"},n){const i=t.filter(Yz),s=e&&r!=="loop"&&e%2===1?0:i.length-1;return!s||n===void 0?i[s]:n}const Ln=t=>t;function Jz(t){let e=new Set,r=new Set,n=!1,i=!1;const s=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function a(u){s.has(u)&&(f.schedule(u),t()),u(o)}const f={schedule:(u,h=!1,g=!1)=>{const x=g&&n?e:r;return h&&s.add(u),x.has(u)||x.add(u),u},cancel:u=>{r.delete(u),s.delete(u)},process:u=>{if(o=u,n){i=!0;return}n=!0,[e,r]=[r,e],r.clear(),e.forEach(a),n=!1,i&&(i=!1,f.process(u))}};return f}const Sd=["read","resolveKeyframes","update","preRender","render","postRender"],Xz=40;function K4(t,e){let r=!1,n=!0;const i={delta:0,timestamp:0,isProcessing:!1},s=()=>r=!0,o=Sd.reduce((B,L)=>(B[L]=Jz(s),B),{}),{read:a,resolveKeyframes:f,update:u,preRender:h,render:g,postRender:b}=o,x=()=>{const B=performance.now();r=!1,i.delta=n?1e3/60:Math.max(Math.min(B-i.timestamp,Xz),1),i.timestamp=B,i.isProcessing=!0,a.process(i),f.process(i),u.process(i),h.process(i),g.process(i),b.process(i),i.isProcessing=!1,r&&e&&(n=!1,t(x))},S=()=>{r=!0,n=!0,i.isProcessing||t(x)};return{schedule:Sd.reduce((B,L)=>{const H=o[L];return B[L]=(F,k=!1,$=!1)=>(r||S(),H.schedule(F,k,$)),B},{}),cancel:B=>{for(let L=0;L(((1-3*r+3*e)*t+(3*r-6*e))*t+3*e)*t,Zz=1e-7,Qz=12;function eH(t,e,r,n,i){let s,o,a=0;do o=e+(r-e)/2,s=V4(o,n,i)-t,s>0?r=o:e=o;while(Math.abs(s)>Zz&&++aeH(s,0,1,t,r);return s=>s===0||s===1?s:V4(i(s),e,n)}const G4=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Y4=t=>e=>1-t(1-e),J4=Vf(.33,1.53,.69,.99),Ov=Y4(J4),X4=G4(Ov),Z4=t=>(t*=2)<1?.5*Ov(t):.5*(2-Math.pow(2,-10*(t-1))),Nv=t=>1-Math.sin(Math.acos(t)),Q4=Y4(Nv),e8=G4(Nv),t8=t=>/^0[^.\s]+$/u.test(t);function tH(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||t8(t):!0}let Nc=Ln,ro=Ln;process.env.NODE_ENV!=="production"&&(Nc=(t,e)=>{!t&&typeof console<"u"&&console.warn(e)},ro=(t,e)=>{if(!t)throw new Error(e)});const r8=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),n8=t=>e=>typeof e=="string"&&e.startsWith(t),i8=n8("--"),rH=n8("var(--"),Lv=t=>rH(t)?nH.test(t.split("/*")[0].trim()):!1,nH=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,iH=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function sH(t){const e=iH.exec(t);if(!e)return[,];const[,r,n,i]=e;return[`--${r??n}`,i]}const oH=4;function s8(t,e,r=1){ro(r<=oH,`Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`);const[n,i]=sH(t);if(!n)return;const s=window.getComputedStyle(e).getPropertyValue(n);if(s){const o=s.trim();return r8(o)?parseFloat(o):o}return Lv(i)?s8(i,e,r+1):i}const Uo=(t,e,r)=>r>e?e:rtypeof t=="number",parse:parseFloat,transform:t=>t},Gf={...Lc,transform:t=>Uo(0,1,t)},Ad={...Lc,default:1},Yf=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),$o=Yf("deg"),Os=Yf("%"),zt=Yf("px"),aH=Yf("vh"),cH=Yf("vw"),o8={...Os,parse:t=>Os.parse(t)/100,transform:t=>Os.transform(t*100)},uH=new Set(["width","height","top","left","right","bottom","x","y","translateX","translateY"]),a8=t=>t===Lc||t===zt,c8=(t,e)=>parseFloat(t.split(", ")[e]),u8=(t,e)=>(r,{transform:n})=>{if(n==="none"||!n)return 0;const i=n.match(/^matrix3d\((.+)\)$/u);if(i)return c8(i[1],e);{const s=n.match(/^matrix\((.+)\)$/u);return s?c8(s[1],t):0}},fH=new Set(["x","y","z"]),lH=Kf.filter(t=>!fH.has(t));function hH(t){const e=[];return lH.forEach(r=>{const n=t.getValue(r);n!==void 0&&(e.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),e}const kc={width:({x:t},{paddingLeft:e="0",paddingRight:r="0"})=>t.max-t.min-parseFloat(e)-parseFloat(r),height:({y:t},{paddingTop:e="0",paddingBottom:r="0"})=>t.max-t.min-parseFloat(e)-parseFloat(r),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:u8(4,13),y:u8(5,14)};kc.translateX=kc.x,kc.translateY=kc.y;const f8=t=>e=>e.test(t),l8=[Lc,zt,Os,$o,cH,aH,{test:t=>t==="auto",parse:t=>t}],h8=t=>l8.find(f8(t)),Ua=new Set;let kv=!1,Bv=!1;function d8(){if(Bv){const t=Array.from(Ua).filter(n=>n.needsMeasurement),e=new Set(t.map(n=>n.element)),r=new Map;e.forEach(n=>{const i=hH(n);i.length&&(r.set(n,i),n.render())}),t.forEach(n=>n.measureInitialState()),e.forEach(n=>{n.render();const i=r.get(n);i&&i.forEach(([s,o])=>{var a;(a=n.getValue(s))===null||a===void 0||a.set(o)})}),t.forEach(n=>n.measureEndState()),t.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}Bv=!1,kv=!1,Ua.forEach(t=>t.complete()),Ua.clear()}function p8(){Ua.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Bv=!0)})}function dH(){p8(),d8()}class Fv{constructor(e,r,n,i,s,o=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...e],this.onComplete=r,this.name=n,this.motionValue=i,this.element=s,this.isAsync=o}scheduleResolve(){this.isScheduled=!0,this.isAsync?(Ua.add(this),kv||(kv=!0,Nr.read(p8),Nr.resolveKeyframes(d8))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:r,element:n,motionValue:i}=this;for(let s=0;sMath.round(t*1e5)/1e5,jv=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function pH(t){return t==null}const gH=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Uv=(t,e)=>r=>!!(typeof r=="string"&&gH.test(r)&&r.startsWith(t)||e&&!pH(r)&&Object.prototype.hasOwnProperty.call(r,e)),g8=(t,e,r)=>n=>{if(typeof n!="string")return n;const[i,s,o,a]=n.match(jv);return{[t]:parseFloat(i),[e]:parseFloat(s),[r]:parseFloat(o),alpha:a!==void 0?parseFloat(a):1}},mH=t=>Uo(0,255,t),$v={...Lc,transform:t=>Math.round(mH(t))},$a={test:Uv("rgb","red"),parse:g8("red","green","blue"),transform:({red:t,green:e,blue:r,alpha:n=1})=>"rgba("+$v.transform(t)+", "+$v.transform(e)+", "+$v.transform(r)+", "+Jf(Gf.transform(n))+")"};function vH(t){let e="",r="",n="",i="";return t.length>5?(e=t.substring(1,3),r=t.substring(3,5),n=t.substring(5,7),i=t.substring(7,9)):(e=t.substring(1,2),r=t.substring(2,3),n=t.substring(3,4),i=t.substring(4,5),e+=e,r+=r,n+=n,i+=i),{red:parseInt(e,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:i?parseInt(i,16)/255:1}}const qv={test:Uv("#"),parse:vH,transform:$a.transform},Bc={test:Uv("hsl","hue"),parse:g8("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+Os.transform(Jf(e))+", "+Os.transform(Jf(r))+", "+Jf(Gf.transform(n))+")"},$n={test:t=>$a.test(t)||qv.test(t)||Bc.test(t),parse:t=>$a.test(t)?$a.parse(t):Bc.test(t)?Bc.parse(t):qv.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?$a.transform(t):Bc.transform(t)},bH=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function yH(t){var e,r;return isNaN(t)&&typeof t=="string"&&(((e=t.match(jv))===null||e===void 0?void 0:e.length)||0)+(((r=t.match(bH))===null||r===void 0?void 0:r.length)||0)>0}const m8="number",v8="color",wH="var",xH="var(",b8="${}",_H=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Xf(t){const e=t.toString(),r=[],n={color:[],number:[],var:[]},i=[];let s=0;const a=e.replace(_H,f=>($n.test(f)?(n.color.push(s),i.push(v8),r.push($n.parse(f))):f.startsWith(xH)?(n.var.push(s),i.push(wH),r.push(f)):(n.number.push(s),i.push(m8),r.push(parseFloat(f))),++s,b8)).split(b8);return{values:r,split:a,indexes:n,types:i}}function y8(t){return Xf(t).values}function w8(t){const{split:e,types:r}=Xf(t),n=e.length;return i=>{let s="";for(let o=0;otypeof t=="number"?0:t;function SH(t){const e=y8(t);return w8(t)(e.map(EH))}const qo={test:yH,parse:y8,createTransformer:w8,getAnimatableNone:SH},AH=new Set(["brightness","contrast","saturate","opacity"]);function PH(t){const[e,r]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[n]=r.match(jv)||[];if(!n)return t;const i=r.replace(n,"");let s=AH.has(e)?1:0;return n!==r&&(s*=100),e+"("+s+i+")"}const IH=/\b([a-z-]*)\(.*?\)/gu,zv={...qo,getAnimatableNone:t=>{const e=t.match(IH);return e?e.map(PH).join(" "):t}},MH={borderWidth:zt,borderTopWidth:zt,borderRightWidth:zt,borderBottomWidth:zt,borderLeftWidth:zt,borderRadius:zt,radius:zt,borderTopLeftRadius:zt,borderTopRightRadius:zt,borderBottomRightRadius:zt,borderBottomLeftRadius:zt,width:zt,maxWidth:zt,height:zt,maxHeight:zt,top:zt,right:zt,bottom:zt,left:zt,padding:zt,paddingTop:zt,paddingRight:zt,paddingBottom:zt,paddingLeft:zt,margin:zt,marginTop:zt,marginRight:zt,marginBottom:zt,marginLeft:zt,backgroundPositionX:zt,backgroundPositionY:zt},CH={rotate:$o,rotateX:$o,rotateY:$o,rotateZ:$o,scale:Ad,scaleX:Ad,scaleY:Ad,scaleZ:Ad,skew:$o,skewX:$o,skewY:$o,distance:zt,translateX:zt,translateY:zt,translateZ:zt,x:zt,y:zt,z:zt,perspective:zt,transformPerspective:zt,opacity:Gf,originX:o8,originY:o8,originZ:zt},x8={...Lc,transform:Math.round},Hv={...MH,...CH,zIndex:x8,size:zt,fillOpacity:Gf,strokeOpacity:Gf,numOctaves:x8},RH={...Hv,color:$n,backgroundColor:$n,outlineColor:$n,fill:$n,stroke:$n,borderColor:$n,borderTopColor:$n,borderRightColor:$n,borderBottomColor:$n,borderLeftColor:$n,filter:zv,WebkitFilter:zv},Wv=t=>RH[t];function _8(t,e){let r=Wv(t);return r!==zv&&(r=qo),r.getAnimatableNone?r.getAnimatableNone(e):void 0}const TH=new Set(["auto","none","0"]);function DH(t,e,r){let n=0,i;for(;n{r.getValue(f).set(u)}),this.resolveNoneKeyframes()}}function Kv(t){return typeof t=="function"}let Pd;function OH(){Pd=void 0}const Ns={now:()=>(Pd===void 0&&Ns.set(kn.isProcessing||Gz.useManualTiming?kn.timestamp:performance.now()),Pd),set:t=>{Pd=t,queueMicrotask(OH)}},S8=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(qo.test(t)||t==="0")&&!t.startsWith("url("));function NH(t){const e=t[0];if(t.length===1)return!0;for(let r=0;rkH?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&dH(),this._resolved}onKeyframesResolved(e,r){this.resolvedAt=Ns.now(),this.hasAttemptedResolve=!0;const{name:n,type:i,velocity:s,delay:o,onComplete:a,onUpdate:f,isGenerator:u}=this.options;if(!u&&!LH(e,n,i,s))if(o)this.options.duration=0;else{f?.(Ed(e,this.options,r)),a?.(),this.resolveFinishedPromise();return}const h=this.initPlayback(e,r);h!==!1&&(this._resolved={keyframes:e,finalKeyframe:r,...h},this.onPostResolved())}onPostResolved(){}then(e,r){return this.currentFinishedPromise.then(e,r)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(e=>{this.resolveFinishedPromise=e})}}function P8(t,e){return e?t*(1e3/e):0}const BH=5;function I8(t,e,r){const n=Math.max(e-BH,0);return P8(r-t(n),e-n)}const Vv=.001,FH=.01,M8=10,jH=.05,UH=1;function $H({duration:t=800,bounce:e=.25,velocity:r=0,mass:n=1}){let i,s;Nc(t<=Ds(M8),"Spring duration must be 10 seconds or less");let o=1-e;o=Uo(jH,UH,o),t=Uo(FH,M8,to(t)),o<1?(i=u=>{const h=u*o,g=h*t,b=h-r,x=Gv(u,o),S=Math.exp(-g);return Vv-b/x*S},s=u=>{const g=u*o*t,b=g*r+r,x=Math.pow(o,2)*Math.pow(u,2)*t,S=Math.exp(-g),C=Gv(Math.pow(u,2),o);return(-i(u)+Vv>0?-1:1)*((b-x)*S)/C}):(i=u=>{const h=Math.exp(-u*t),g=(u-r)*t+1;return-Vv+h*g},s=u=>{const h=Math.exp(-u*t),g=(r-u)*(t*t);return h*g});const a=5/t,f=zH(i,s,a);if(t=Ds(t),isNaN(f))return{stiffness:100,damping:10,duration:t};{const u=Math.pow(f,2)*n;return{stiffness:u,damping:o*2*Math.sqrt(n*u),duration:t}}}const qH=12;function zH(t,e,r){let n=r;for(let i=1;it[r]!==void 0)}function KH(t){let e={velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1,...t};if(!C8(t,WH)&&C8(t,HH)){const r=$H(t);e={...e,...r,mass:1},e.isResolvedFromDuration=!0}return e}function R8({keyframes:t,restDelta:e,restSpeed:r,...n}){const i=t[0],s=t[t.length-1],o={done:!1,value:i},{stiffness:a,damping:f,mass:u,duration:h,velocity:g,isResolvedFromDuration:b}=KH({...n,velocity:-to(n.velocity||0)}),x=g||0,S=f/(2*Math.sqrt(a*u)),C=s-i,D=to(Math.sqrt(a/u)),B=Math.abs(C)<5;r||(r=B?.01:2),e||(e=B?.005:.5);let L;if(S<1){const H=Gv(D,S);L=F=>{const k=Math.exp(-S*D*F);return s-k*((x+S*D*C)/H*Math.sin(H*F)+C*Math.cos(H*F))}}else if(S===1)L=H=>s-Math.exp(-D*H)*(C+(x+D*C)*H);else{const H=D*Math.sqrt(S*S-1);L=F=>{const k=Math.exp(-S*D*F),$=Math.min(H*F,300);return s-k*((x+S*D*C)*Math.sinh($)+H*C*Math.cosh($))/H}}return{calculatedDuration:b&&h||null,next:H=>{const F=L(H);if(b)o.done=H>=h;else{let k=0;S<1&&(k=H===0?Ds(x):I8(L,H,F));const $=Math.abs(k)<=r,R=Math.abs(s-F)<=e;o.done=$&&R}return o.value=o.done?s:F,o}}}function T8({keyframes:t,velocity:e=0,power:r=.8,timeConstant:n=325,bounceDamping:i=10,bounceStiffness:s=500,modifyTarget:o,min:a,max:f,restDelta:u=.5,restSpeed:h}){const g=t[0],b={done:!1,value:g},x=W=>a!==void 0&&Wf,S=W=>a===void 0?f:f===void 0||Math.abs(a-W)-C*Math.exp(-W/n),H=W=>B+L(W),F=W=>{const V=L(W),X=H(W);b.done=Math.abs(V)<=u,b.value=b.done?B:X};let k,$;const R=W=>{x(b.value)&&(k=W,$=R8({keyframes:[b.value,S(b.value)],velocity:I8(H,W,b.value),damping:i,stiffness:s,restDelta:u,restSpeed:h}))};return R(0),{calculatedDuration:null,next:W=>{let V=!1;return!$&&k===void 0&&(V=!0,F(W),R(W)),k!==void 0&&W>=k?$.next(W-k):(!V&&F(W),b)}}}const VH=Vf(.42,0,1,1),GH=Vf(0,0,.58,1),D8=Vf(.42,0,.58,1),YH=t=>Array.isArray(t)&&typeof t[0]!="number",Yv=t=>Array.isArray(t)&&typeof t[0]=="number",O8={linear:Ln,easeIn:VH,easeInOut:D8,easeOut:GH,circIn:Nv,circInOut:e8,circOut:Q4,backIn:Ov,backInOut:X4,backOut:J4,anticipate:Z4},N8=t=>{if(Yv(t)){ro(t.length===4,"Cubic bezier arrays must contain four numerical values.");const[e,r,n,i]=t;return Vf(e,r,n,i)}else if(typeof t=="string")return ro(O8[t]!==void 0,`Invalid easing type '${t}'`),O8[t];return t},JH=(t,e)=>r=>e(t(r)),no=(...t)=>t.reduce(JH),Fc=(t,e,r)=>{const n=e-t;return n===0?1:(r-t)/n},Zr=(t,e,r)=>t+(e-t)*r;function Jv(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function XH({hue:t,saturation:e,lightness:r,alpha:n}){t/=360,e/=100,r/=100;let i=0,s=0,o=0;if(!e)i=s=o=r;else{const a=r<.5?r*(1+e):r+e-r*e,f=2*r-a;i=Jv(f,a,t+1/3),s=Jv(f,a,t),o=Jv(f,a,t-1/3)}return{red:Math.round(i*255),green:Math.round(s*255),blue:Math.round(o*255),alpha:n}}function Id(t,e){return r=>r>0?e:t}const Xv=(t,e,r)=>{const n=t*t,i=r*(e*e-n)+n;return i<0?0:Math.sqrt(i)},ZH=[qv,$a,Bc],QH=t=>ZH.find(e=>e.test(t));function L8(t){const e=QH(t);if(Nc(!!e,`'${t}' is not an animatable color. Use the equivalent color code instead.`),!e)return!1;let r=e.parse(t);return e===Bc&&(r=XH(r)),r}const k8=(t,e)=>{const r=L8(t),n=L8(e);if(!r||!n)return Id(t,e);const i={...r};return s=>(i.red=Xv(r.red,n.red,s),i.green=Xv(r.green,n.green,s),i.blue=Xv(r.blue,n.blue,s),i.alpha=Zr(r.alpha,n.alpha,s),$a.transform(i))},Zv=new Set(["none","hidden"]);function eW(t,e){return Zv.has(t)?r=>r<=0?t:e:r=>r>=1?e:t}function tW(t,e){return r=>Zr(t,e,r)}function Qv(t){return typeof t=="number"?tW:typeof t=="string"?Lv(t)?Id:$n.test(t)?k8:iW:Array.isArray(t)?B8:typeof t=="object"?$n.test(t)?k8:rW:Id}function B8(t,e){const r=[...t],n=r.length,i=t.map((s,o)=>Qv(s)(s,e[o]));return s=>{for(let o=0;o{for(const s in n)r[s]=n[s](i);return r}}function nW(t,e){var r;const n=[],i={color:0,var:0,number:0};for(let s=0;s{const r=qo.createTransformer(e),n=Xf(t),i=Xf(e);return n.indexes.var.length===i.indexes.var.length&&n.indexes.color.length===i.indexes.color.length&&n.indexes.number.length>=i.indexes.number.length?Zv.has(t)&&!i.values.length||Zv.has(e)&&!n.values.length?eW(t,e):no(B8(nW(n,i),i.values),r):(Nc(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),Id(t,e))};function F8(t,e,r){return typeof t=="number"&&typeof e=="number"&&typeof r=="number"?Zr(t,e,r):Qv(t)(t,e)}function sW(t,e,r){const n=[],i=r||F8,s=t.length-1;for(let o=0;oe[0];if(s===2&&t[0]===t[1])return()=>e[1];t[0]>t[s-1]&&(t=[...t].reverse(),e=[...e].reverse());const o=sW(e,n,i),a=o.length,f=u=>{let h=0;if(a>1)for(;hf(Uo(t[0],t[s-1],u)):f}function aW(t,e){const r=t[t.length-1];for(let n=1;n<=e;n++){const i=Fc(0,e,n);t.push(Zr(r,1,i))}}function cW(t){const e=[0];return aW(e,t.length-1),e}function uW(t,e){return t.map(r=>r*e)}function fW(t,e){return t.map(()=>e||D8).splice(0,t.length-1)}function Md({duration:t=300,keyframes:e,times:r,ease:n="easeInOut"}){const i=YH(n)?n.map(N8):N8(n),s={done:!1,value:e[0]},o=uW(r&&r.length===e.length?r:cW(e),t),a=oW(o,e,{ease:Array.isArray(i)?i:fW(e,i)});return{calculatedDuration:t,next:f=>(s.value=a(f),s.done=f>=t,s)}}const j8=2e4;function lW(t){let e=0;const r=50;let n=t.next(e);for(;!n.done&&e=j8?1/0:e}const hW=t=>{const e=({timestamp:r})=>t(r);return{start:()=>Nr.update(e,!0),stop:()=>jo(e),now:()=>kn.isProcessing?kn.timestamp:Ns.now()}},dW={decay:T8,inertia:T8,tween:Md,keyframes:Md,spring:R8},pW=t=>t/100;class e1 extends A8{constructor(e){super(e),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:f}=this.options;f&&f()};const{name:r,motionValue:n,element:i,keyframes:s}=this.options,o=i?.KeyframeResolver||Fv,a=(f,u)=>this.onKeyframesResolved(f,u);this.resolver=new o(s,a,r,n,i),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(e){const{type:r="keyframes",repeat:n=0,repeatDelay:i=0,repeatType:s,velocity:o=0}=this.options,a=Kv(r)?r:dW[r]||Md;let f,u;a!==Md&&typeof e[0]!="number"&&(process.env.NODE_ENV!=="production"&&ro(e.length===2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${e}`),f=no(pW,F8(e[0],e[1])),e=[0,100]);const h=a({...this.options,keyframes:e});s==="mirror"&&(u=a({...this.options,keyframes:[...e].reverse(),velocity:-o})),h.calculatedDuration===null&&(h.calculatedDuration=lW(h));const{calculatedDuration:g}=h,b=g+i,x=b*(n+1)-i;return{generator:h,mirroredGenerator:u,mapPercentToKeyframes:f,calculatedDuration:g,resolvedDuration:b,totalDuration:x}}onPostResolved(){const{autoplay:e=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!e?this.pause():this.state=this.pendingPlayState}tick(e,r=!1){const{resolved:n}=this;if(!n){const{keyframes:W}=this.options;return{done:!0,value:W[W.length-1]}}const{finalKeyframe:i,generator:s,mirroredGenerator:o,mapPercentToKeyframes:a,keyframes:f,calculatedDuration:u,totalDuration:h,resolvedDuration:g}=n;if(this.startTime===null)return s.next(0);const{delay:b,repeat:x,repeatType:S,repeatDelay:C,onUpdate:D}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-h/this.speed,this.startTime)),r?this.currentTime=e:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(e-this.startTime)*this.speed;const B=this.currentTime-b*(this.speed>=0?1:-1),L=this.speed>=0?B<0:B>h;this.currentTime=Math.max(B,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=h);let H=this.currentTime,F=s;if(x){const W=Math.min(this.currentTime,h)/g;let V=Math.floor(W),X=W%1;!X&&W>=1&&(X=1),X===1&&V--,V=Math.min(V,x+1),!!(V%2)&&(S==="reverse"?(X=1-X,C&&(X-=C/g)):S==="mirror"&&(F=o)),H=Uo(0,1,X)*g}const k=L?{done:!1,value:f[0]}:F.next(H);a&&(k.value=a(k.value));let{done:$}=k;!L&&u!==null&&($=this.speed>=0?this.currentTime>=h:this.currentTime<=0);const R=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&$);return R&&i!==void 0&&(k.value=Ed(f,this.options,i)),D&&D(k.value),R&&this.finish(),k}get duration(){const{resolved:e}=this;return e?to(e.calculatedDuration):0}get time(){return to(this.currentTime)}set time(e){e=Ds(e),this.currentTime=e,this.holdTime!==null||this.speed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.speed)}get speed(){return this.playbackSpeed}set speed(e){const r=this.playbackSpeed!==e;this.playbackSpeed=e,r&&(this.time=to(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:e=hW,onPlay:r,startTime:n}=this.options;this.driver||(this.driver=e(s=>this.tick(s))),r&&r();const i=this.driver.now();this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=i):this.startTime=n??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var e;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(e=this.currentTime)!==null&&e!==void 0?e:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:e}=this.options;e&&e()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}}const gW=new Set(["opacity","clipPath","filter","transform"]),mW=10,vW=(t,e)=>{let r="";const n=Math.max(Math.round(e/mW),2);for(let i=0;i(e===void 0&&(e=t()),e)}const bW={linearEasing:void 0};function yW(t,e){const r=t1(t);return()=>{var n;return(n=bW[e])!==null&&n!==void 0?n:r()}}const Cd=yW(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing");function U8(t){return!!(typeof t=="function"&&Cd()||!t||typeof t=="string"&&(t in r1||Cd())||Yv(t)||Array.isArray(t)&&t.every(U8))}const Zf=([t,e,r,n])=>`cubic-bezier(${t}, ${e}, ${r}, ${n})`,r1={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Zf([0,.65,.55,1]),circOut:Zf([.55,0,1,.45]),backIn:Zf([.31,.01,.66,-.59]),backOut:Zf([.33,1.53,.69,.99])};function $8(t,e){if(t)return typeof t=="function"&&Cd()?vW(t,e):Yv(t)?Zf(t):Array.isArray(t)?t.map(r=>$8(r,e)||r1.easeOut):r1[t]}function wW(t,e,r,{delay:n=0,duration:i=300,repeat:s=0,repeatType:o="loop",ease:a="easeInOut",times:f}={}){const u={[e]:r};f&&(u.offset=f);const h=$8(a,i);return Array.isArray(h)&&(u.easing=h),t.animate(u,{delay:n,duration:i,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:s+1,direction:o==="reverse"?"alternate":"normal"})}function q8(t,e){t.timeline=e,t.onfinish=null}const xW=t1(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),Rd=10,_W=2e4;function EW(t){return Kv(t.type)||t.type==="spring"||!U8(t.ease)}function SW(t,e){const r=new e1({...e,keyframes:t,repeat:0,delay:0,isGenerator:!0});let n={done:!1,value:t[0]};const i=[];let s=0;for(;!n.done&&s<_W;)n=r.sample(s),i.push(n.value),s+=Rd;return{times:void 0,keyframes:i,duration:s-Rd,ease:"linear"}}const z8={anticipate:Z4,backInOut:X4,circInOut:e8};function AW(t){return t in z8}class H8 extends A8{constructor(e){super(e);const{name:r,motionValue:n,element:i,keyframes:s}=this.options;this.resolver=new E8(s,(o,a)=>this.onKeyframesResolved(o,a),r,n,i),this.resolver.scheduleResolve()}initPlayback(e,r){var n;let{duration:i=300,times:s,ease:o,type:a,motionValue:f,name:u,startTime:h}=this.options;if(!(!((n=f.owner)===null||n===void 0)&&n.current))return!1;if(typeof o=="string"&&Cd()&&AW(o)&&(o=z8[o]),EW(this.options)){const{onComplete:b,onUpdate:x,motionValue:S,element:C,...D}=this.options,B=SW(e,D);e=B.keyframes,e.length===1&&(e[1]=e[0]),i=B.duration,s=B.times,o=B.ease,a="keyframes"}const g=wW(f.owner.current,u,e,{...this.options,duration:i,times:s,ease:o});return g.startTime=h??this.calcStartTime(),this.pendingTimeline?(q8(g,this.pendingTimeline),this.pendingTimeline=void 0):g.onfinish=()=>{const{onComplete:b}=this.options;f.set(Ed(e,this.options,r)),b&&b(),this.cancel(),this.resolveFinishedPromise()},{animation:g,duration:i,times:s,type:a,ease:o,keyframes:e}}get duration(){const{resolved:e}=this;if(!e)return 0;const{duration:r}=e;return to(r)}get time(){const{resolved:e}=this;if(!e)return 0;const{animation:r}=e;return to(r.currentTime||0)}set time(e){const{resolved:r}=this;if(!r)return;const{animation:n}=r;n.currentTime=Ds(e)}get speed(){const{resolved:e}=this;if(!e)return 1;const{animation:r}=e;return r.playbackRate}set speed(e){const{resolved:r}=this;if(!r)return;const{animation:n}=r;n.playbackRate=e}get state(){const{resolved:e}=this;if(!e)return"idle";const{animation:r}=e;return r.playState}get startTime(){const{resolved:e}=this;if(!e)return null;const{animation:r}=e;return r.startTime}attachTimeline(e){if(!this._resolved)this.pendingTimeline=e;else{const{resolved:r}=this;if(!r)return Ln;const{animation:n}=r;q8(n,e)}return Ln}play(){if(this.isStopped)return;const{resolved:e}=this;if(!e)return;const{animation:r}=e;r.playState==="finished"&&this.updateFinishedPromise(),r.play()}pause(){const{resolved:e}=this;if(!e)return;const{animation:r}=e;r.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:e}=this;if(!e)return;const{animation:r,keyframes:n,duration:i,type:s,ease:o,times:a}=e;if(r.playState==="idle"||r.playState==="finished")return;if(this.time){const{motionValue:u,onUpdate:h,onComplete:g,element:b,...x}=this.options,S=new e1({...x,keyframes:n,duration:i,type:s,ease:o,times:a,isGenerator:!0}),C=Ds(this.time);u.setWithVelocity(S.sample(C-Rd).value,S.sample(C).value,Rd)}const{onStop:f}=this.options;f&&f(),this.cancel()}complete(){const{resolved:e}=this;e&&e.animation.finish()}cancel(){const{resolved:e}=this;e&&e.animation.cancel()}static supports(e){const{motionValue:r,name:n,repeatDelay:i,repeatType:s,damping:o,type:a}=e;return xW()&&n&&gW.has(n)&&r&&r.owner&&r.owner.current instanceof HTMLElement&&!r.owner.getProps().onUpdate&&!i&&s!=="mirror"&&o!==0&&a!=="inertia"}}const PW=t1(()=>window.ScrollTimeline!==void 0);class IW{constructor(e){this.stop=()=>this.runAll("stop"),this.animations=e.filter(Boolean)}then(e,r){return Promise.all(this.animations).then(e).catch(r)}getAll(e){return this.animations[0][e]}setAll(e,r){for(let n=0;nPW()&&i.attachTimeline?i.attachTimeline(e):r(i));return()=>{n.forEach((i,s)=>{i&&i(),this.animations[s].stop()})}}get time(){return this.getAll("time")}set time(e){this.setAll("time",e)}get speed(){return this.getAll("speed")}set speed(e){this.setAll("speed",e)}get startTime(){return this.getAll("startTime")}get duration(){let e=0;for(let r=0;rr[e]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}function MW({when:t,delay:e,delayChildren:r,staggerChildren:n,staggerDirection:i,repeat:s,repeatType:o,repeatDelay:a,from:f,elapsed:u,...h}){return!!Object.keys(h).length}const n1=(t,e,r,n={},i,s)=>o=>{const a=Tv(n,t)||{},f=a.delay||n.delay||0;let{elapsed:u=0}=n;u=u-Ds(f);let h={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:e.getVelocity(),...a,delay:-u,onUpdate:b=>{e.set(b),a.onUpdate&&a.onUpdate(b)},onComplete:()=>{o(),a.onComplete&&a.onComplete()},name:t,motionValue:e,element:s?void 0:i};MW(a)||(h={...h,...Vz(t,h)}),h.duration&&(h.duration=Ds(h.duration)),h.repeatDelay&&(h.repeatDelay=Ds(h.repeatDelay)),h.from!==void 0&&(h.keyframes[0]=h.from);let g=!1;if((h.type===!1||h.duration===0&&!h.repeatDelay)&&(h.duration=0,h.delay===0&&(g=!0)),g&&!s&&e.get()!==void 0){const b=Ed(h.keyframes,a);if(b!==void 0)return Nr.update(()=>{h.onUpdate(b),h.onComplete()}),new IW([])}return!s&&H8.supports(h)?new H8(h):new e1(h)},CW=t=>!!(t&&typeof t=="object"&&t.mix&&t.toValue),RW=t=>Iv(t)?t[t.length-1]||0:t;function i1(t,e){t.indexOf(e)===-1&&t.push(e)}function s1(t,e){const r=t.indexOf(e);r>-1&&t.splice(r,1)}class o1{constructor(){this.subscriptions=[]}add(e){return i1(this.subscriptions,e),()=>s1(this.subscriptions,e)}notify(e,r,n){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](e,r,n);else for(let s=0;s!isNaN(parseFloat(t));class DW{constructor(e,r={}){this.version="11.11.17",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(n,i=!0)=>{const s=Ns.now();this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),i&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(e),this.owner=r.owner}setCurrent(e){this.current=e,this.updatedAt=Ns.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=TW(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!=="production"&&wd(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,r){this.events[e]||(this.events[e]=new o1);const n=this.events[e].add(r);return e==="change"?()=>{n(),Nr.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,r){this.passiveEffect=e,this.stopPassiveEffect=r}set(e,r=!0){!r||!this.passiveEffect?this.updateAndNotify(e,r):this.passiveEffect(e,this.updateAndNotify)}setWithVelocity(e,r,n){this.set(r),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,r=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Ns.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>W8)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,W8);return P8(parseFloat(this.current)-parseFloat(this.prevFrameValue),r)}start(e){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=e(r),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Qf(t,e){return new DW(t,e)}function OW(t,e,r){t.hasValue(e)?t.getValue(e).set(r):t.addValue(e,Qf(r))}function NW(t,e){const r=_d(t,e);let{transitionEnd:n={},transition:i={},...s}=r||{};s={...s,...n};for(const o in s){const a=RW(s[o]);OW(t,o,a)}}const a1=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),K8="data-"+a1("framerAppearId");function V8(t){return t.props[K8]}const qn=t=>!!(t&&t.getVelocity);function LW(t){return!!(qn(t)&&t.add)}function c1(t,e){const r=t.getValue("willChange");if(LW(r))return r.add(e)}function kW({protectedKeys:t,needsAnimating:e},r){const n=t.hasOwnProperty(r)&&e[r]!==!0;return e[r]=!1,n}function G8(t,e,{delay:r=0,transitionOverride:n,type:i}={}){var s;let{transition:o=t.getDefaultTransition(),transitionEnd:a,...f}=e;n&&(o=n);const u=[],h=i&&t.animationState&&t.animationState.getState()[i];for(const g in f){const b=t.getValue(g,(s=t.latestValues[g])!==null&&s!==void 0?s:null),x=f[g];if(x===void 0||h&&kW(h,g))continue;const S={delay:r,...Tv(o||{},g)};let C=!1;if(window.MotionHandoffAnimation){const B=V8(t);if(B){const L=window.MotionHandoffAnimation(B,g,Nr);L!==null&&(S.startTime=L,C=!0)}}c1(t,g),b.start(n1(g,b,x,t.shouldReduceMotion&&ja.has(g)?{type:!1}:S,t,C));const D=b.animation;D&&u.push(D)}return a&&Promise.all(u).then(()=>{Nr.update(()=>{a&&NW(t,a)})}),u}function u1(t,e,r={}){var n;const i=_d(t,e,r.type==="exit"?(n=t.presenceContext)===null||n===void 0?void 0:n.custom:void 0);let{transition:s=t.getDefaultTransition()||{}}=i||{};r.transitionOverride&&(s=r.transitionOverride);const o=i?()=>Promise.all(G8(t,i,r)):()=>Promise.resolve(),a=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:h=0,staggerChildren:g,staggerDirection:b}=s;return BW(t,e,h+u,g,b,r)}:()=>Promise.resolve(),{when:f}=s;if(f){const[u,h]=f==="beforeChildren"?[o,a]:[a,o];return u().then(()=>h())}else return Promise.all([o(),a(r.delay)])}function BW(t,e,r=0,n=0,i=1,s){const o=[],a=(t.variantChildren.size-1)*n,f=i===1?(u=0)=>u*n:(u=0)=>a-u*n;return Array.from(t.variantChildren).sort(FW).forEach((u,h)=>{u.notify("AnimationStart",e),o.push(u1(u,e,{...s,delay:r+f(h)}).then(()=>u.notify("AnimationComplete",e)))}),Promise.all(o)}function FW(t,e){return t.sortNodePosition(e)}function jW(t,e,r={}){t.notify("AnimationStart",e);let n;if(Array.isArray(e)){const i=e.map(s=>u1(t,s,r));n=Promise.all(i)}else if(typeof e=="string")n=u1(t,e,r);else{const i=typeof e=="function"?_d(t,e,r.custom):e;n=Promise.all(G8(t,i,r))}return n.then(()=>{t.notify("AnimationComplete",e)})}const UW=Rv.length;function Y8(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?Y8(t.parent)||{}:{};return t.props.initial!==void 0&&(r.initial=t.props.initial),r}const e={};for(let r=0;rPromise.all(e.map(({animation:r,options:n})=>jW(t,r,n)))}function HW(t){let e=zW(t),r=J8(),n=!0;const i=f=>(u,h)=>{var g;const b=_d(t,h,f==="exit"?(g=t.presenceContext)===null||g===void 0?void 0:g.custom:void 0);if(b){const{transition:x,transitionEnd:S,...C}=b;u={...u,...C,...S}}return u};function s(f){e=f(t)}function o(f){const{props:u}=t,h=Y8(t.parent)||{},g=[],b=new Set;let x={},S=1/0;for(let D=0;DS&&F,V=!1;const X=Array.isArray(H)?H:[H];let q=X.reduce(i(B),{});k===!1&&(q={});const{prevResolvedValues:_={}}=L,v={..._,...q},l=y=>{W=!0,b.has(y)&&(V=!0,b.delete(y)),L.needsAnimating[y]=!0;const A=t.getValue(y);A&&(A.liveStyle=!1)};for(const y in v){const A=q[y],E=_[y];if(x.hasOwnProperty(y))continue;let w=!1;Iv(A)&&Iv(E)?w=!H4(A,E):w=A!==E,w?A!=null?l(y):b.add(y):A!==void 0&&b.has(y)?l(y):L.protectedKeys[y]=!0}L.prevProp=H,L.prevResolvedValues=q,L.isActive&&(x={...x,...q}),n&&t.blockInitialAnimation&&(W=!1),W&&(!($&&R)||V)&&g.push(...X.map(y=>({animation:y,options:{type:B}})))}if(b.size){const D={};b.forEach(B=>{const L=t.getBaseTarget(B),H=t.getValue(B);H&&(H.liveStyle=!0),D[B]=L??null}),g.push({animation:D})}let C=!!g.length;return n&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(C=!1),n=!1,C?e(g):Promise.resolve()}function a(f,u){var h;if(r[f].isActive===u)return Promise.resolve();(h=t.variantChildren)===null||h===void 0||h.forEach(b=>{var x;return(x=b.animationState)===null||x===void 0?void 0:x.setActive(f,u)}),r[f].isActive=u;const g=o(f);for(const b in r)r[b].protectedKeys={};return g}return{animateChanges:o,setActive:a,setAnimateFunction:s,getState:()=>r,reset:()=>{r=J8(),n=!0}}}function WW(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!H4(e,t):!1}function qa(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function J8(){return{animate:qa(!0),whileInView:qa(),whileHover:qa(),whileTap:qa(),whileDrag:qa(),whileFocus:qa(),exit:qa()}}class zo{constructor(e){this.isMounted=!1,this.node=e}update(){}}class KW extends zo{constructor(e){super(e),e.animationState||(e.animationState=HW(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();xd(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:r}=this.node.prevProps||{};e!==r&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)===null||e===void 0||e.call(this)}}let VW=0;class GW extends zo{constructor(){super(...arguments),this.id=VW++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;const i=this.node.animationState.setActive("exit",!e);r&&!e&&i.then(()=>r(this.id))}mount(){const{register:e}=this.node.presenceContext||{};e&&(this.unmount=e(this.id))}unmount(){}}const YW={animation:{Feature:KW},exit:{Feature:GW}},X8=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1;function Td(t,e="page"){return{point:{x:t[`${e}X`],y:t[`${e}Y`]}}}const JW=t=>e=>X8(e)&&t(e,Td(e));function io(t,e,r,n={passive:!0}){return t.addEventListener(e,r,n),()=>t.removeEventListener(e,r)}function so(t,e,r,n){return io(t,e,JW(r),n)}const Z8=(t,e)=>Math.abs(t-e);function XW(t,e){const r=Z8(t.x,e.x),n=Z8(t.y,e.y);return Math.sqrt(r**2+n**2)}class Q8{constructor(e,r,{transformPagePoint:n,contextWindow:i,dragSnapToOrigin:s=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const g=l1(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,x=XW(g.offset,{x:0,y:0})>=3;if(!b&&!x)return;const{point:S}=g,{timestamp:C}=kn;this.history.push({...S,timestamp:C});const{onStart:D,onMove:B}=this.handlers;b||(D&&D(this.lastMoveEvent,g),this.startEvent=this.lastMoveEvent),B&&B(this.lastMoveEvent,g)},this.handlePointerMove=(g,b)=>{this.lastMoveEvent=g,this.lastMoveEventInfo=f1(b,this.transformPagePoint),Nr.update(this.updatePoint,!0)},this.handlePointerUp=(g,b)=>{this.end();const{onEnd:x,onSessionEnd:S,resumeAnimation:C}=this.handlers;if(this.dragSnapToOrigin&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const D=l1(g.type==="pointercancel"?this.lastMoveEventInfo:f1(b,this.transformPagePoint),this.history);this.startEvent&&x&&x(g,D),S&&S(g,D)},!X8(e))return;this.dragSnapToOrigin=s,this.handlers=r,this.transformPagePoint=n,this.contextWindow=i||window;const o=Td(e),a=f1(o,this.transformPagePoint),{point:f}=a,{timestamp:u}=kn;this.history=[{...f,timestamp:u}];const{onSessionStart:h}=r;h&&h(e,l1(a,this.history)),this.removeListeners=no(so(this.contextWindow,"pointermove",this.handlePointerMove),so(this.contextWindow,"pointerup",this.handlePointerUp),so(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),jo(this.updatePoint)}}function f1(t,e){return e?{point:e(t.point)}:t}function eE(t,e){return{x:t.x-e.x,y:t.y-e.y}}function l1({point:t},e){return{point:t,delta:eE(t,tE(e)),offset:eE(t,ZW(e)),velocity:QW(e,.1)}}function ZW(t){return t[0]}function tE(t){return t[t.length-1]}function QW(t,e){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const i=tE(t);for(;r>=0&&(n=t[r],!(i.timestamp-n.timestamp>Ds(e)));)r--;if(!n)return{x:0,y:0};const s=to(i.timestamp-n.timestamp);if(s===0)return{x:0,y:0};const o={x:(i.x-n.x)/s,y:(i.y-n.y)/s};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function rE(t){let e=null;return()=>{const r=()=>{e=null};return e===null?(e=t,r):!1}}const nE=rE("dragHorizontal"),iE=rE("dragVertical");function sE(t){let e=!1;if(t==="y")e=iE();else if(t==="x")e=nE();else{const r=nE(),n=iE();r&&n?e=()=>{r(),n()}:(r&&r(),n&&n())}return e}function oE(){const t=sE(!0);return t?(t(),!1):!0}function jc(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}const aE=1e-4,eK=1-aE,tK=1+aE,cE=.01,rK=0-cE,nK=0+cE;function xi(t){return t.max-t.min}function iK(t,e,r){return Math.abs(t-e)<=r}function uE(t,e,r,n=.5){t.origin=n,t.originPoint=Zr(e.min,e.max,t.origin),t.scale=xi(r)/xi(e),t.translate=Zr(r.min,r.max,t.origin)-t.originPoint,(t.scale>=eK&&t.scale<=tK||isNaN(t.scale))&&(t.scale=1),(t.translate>=rK&&t.translate<=nK||isNaN(t.translate))&&(t.translate=0)}function el(t,e,r,n){uE(t.x,e.x,r.x,n?n.originX:void 0),uE(t.y,e.y,r.y,n?n.originY:void 0)}function fE(t,e,r){t.min=r.min+e.min,t.max=t.min+xi(e)}function sK(t,e,r){fE(t.x,e.x,r.x),fE(t.y,e.y,r.y)}function lE(t,e,r){t.min=e.min-r.min,t.max=t.min+xi(e)}function tl(t,e,r){lE(t.x,e.x,r.x),lE(t.y,e.y,r.y)}function oK(t,{min:e,max:r},n){return e!==void 0&&tr&&(t=n?Zr(r,t,n.max):Math.min(t,r)),t}function hE(t,e,r){return{min:e!==void 0?t.min+e:void 0,max:r!==void 0?t.max+r-(t.max-t.min):void 0}}function aK(t,{top:e,left:r,bottom:n,right:i}){return{x:hE(t.x,r,i),y:hE(t.y,e,n)}}function dE(t,e){let r=e.min-t.min,n=e.max-t.max;return e.max-e.minn?r=Fc(e.min,e.max-n,t.min):n>i&&(r=Fc(t.min,t.max-i,e.min)),Uo(0,1,r)}function fK(t,e){const r={};return e.min!==void 0&&(r.min=e.min-t.min),e.max!==void 0&&(r.max=e.max-t.min),r}const h1=.35;function lK(t=h1){return t===!1?t=0:t===!0&&(t=h1),{x:pE(t,"left","right"),y:pE(t,"top","bottom")}}function pE(t,e,r){return{min:gE(t,e),max:gE(t,r)}}function gE(t,e){return typeof t=="number"?t:t[e]||0}const mE=()=>({translate:0,scale:1,origin:0,originPoint:0}),Uc=()=>({x:mE(),y:mE()}),vE=()=>({min:0,max:0}),cn=()=>({x:vE(),y:vE()});function Hi(t){return[t("x"),t("y")]}function bE({top:t,left:e,right:r,bottom:n}){return{x:{min:e,max:r},y:{min:t,max:n}}}function hK({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function dK(t,e){if(!e)return t;const r=e({x:t.left,y:t.top}),n=e({x:t.right,y:t.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}function d1(t){return t===void 0||t===1}function p1({scale:t,scaleX:e,scaleY:r}){return!d1(t)||!d1(e)||!d1(r)}function za(t){return p1(t)||yE(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function yE(t){return wE(t.x)||wE(t.y)}function wE(t){return t&&t!=="0%"}function Dd(t,e,r){const n=t-r,i=e*n;return r+i}function xE(t,e,r,n,i){return i!==void 0&&(t=Dd(t,i,n)),Dd(t,r,n)+e}function g1(t,e=0,r=1,n,i){t.min=xE(t.min,e,r,n,i),t.max=xE(t.max,e,r,n,i)}function _E(t,{x:e,y:r}){g1(t.x,e.translate,e.scale,e.originPoint),g1(t.y,r.translate,r.scale,r.originPoint)}const EE=.999999999999,SE=1.0000000000001;function pK(t,e,r,n=!1){const i=r.length;if(!i)return;e.x=e.y=1;let s,o;for(let a=0;aEE&&(e.x=1),e.yEE&&(e.y=1)}function $c(t,e){t.min=t.min+e,t.max=t.max+e}function AE(t,e,r,n,i=.5){const s=Zr(t.min,t.max,i);g1(t,e,r,s,n)}function qc(t,e){AE(t.x,e.x,e.scaleX,e.scale,e.originX),AE(t.y,e.y,e.scaleY,e.scale,e.originY)}function PE(t,e){return bE(dK(t.getBoundingClientRect(),e))}function gK(t,e,r){const n=PE(t,r),{scroll:i}=e;return i&&($c(n.x,i.offset.x),$c(n.y,i.offset.y)),n}const IE=({current:t})=>t?t.ownerDocument.defaultView:null,mK=new WeakMap;class vK{constructor(e){this.openGlobalLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=cn(),this.visualElement=e}start(e,{snapToCursor:r=!1}={}){const{presenceContext:n}=this.visualElement;if(n&&n.isPresent===!1)return;const i=h=>{const{dragSnapToOrigin:g}=this.getProps();g?this.pauseAnimation():this.stopAnimation(),r&&this.snapToCursor(Td(h,"page").point)},s=(h,g)=>{const{drag:b,dragPropagation:x,onDragStart:S}=this.getProps();if(b&&!x&&(this.openGlobalLock&&this.openGlobalLock(),this.openGlobalLock=sE(b),!this.openGlobalLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Hi(D=>{let B=this.getAxisMotionValue(D).get()||0;if(Os.test(B)){const{projection:L}=this.visualElement;if(L&&L.layout){const H=L.layout.layoutBox[D];H&&(B=xi(H)*(parseFloat(B)/100))}}this.originPoint[D]=B}),S&&Nr.postRender(()=>S(h,g)),c1(this.visualElement,"transform");const{animationState:C}=this.visualElement;C&&C.setActive("whileDrag",!0)},o=(h,g)=>{const{dragPropagation:b,dragDirectionLock:x,onDirectionLock:S,onDrag:C}=this.getProps();if(!b&&!this.openGlobalLock)return;const{offset:D}=g;if(x&&this.currentDirection===null){this.currentDirection=bK(D),this.currentDirection!==null&&S&&S(this.currentDirection);return}this.updateAxis("x",g.point,D),this.updateAxis("y",g.point,D),this.visualElement.render(),C&&C(h,g)},a=(h,g)=>this.stop(h,g),f=()=>Hi(h=>{var g;return this.getAnimationState(h)==="paused"&&((g=this.getAxisMotionValue(h).animation)===null||g===void 0?void 0:g.play())}),{dragSnapToOrigin:u}=this.getProps();this.panSession=new Q8(e,{onSessionStart:i,onStart:s,onMove:o,onSessionEnd:a,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,contextWindow:IE(this.visualElement)})}stop(e,r){const n=this.isDragging;if(this.cancel(),!n)return;const{velocity:i}=r;this.startAnimation(i);const{onDragEnd:s}=this.getProps();s&&Nr.postRender(()=>s(e,r))}cancel(){this.isDragging=!1;const{projection:e,animationState:r}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:n}=this.getProps();!n&&this.openGlobalLock&&(this.openGlobalLock(),this.openGlobalLock=null),r&&r.setActive("whileDrag",!1)}updateAxis(e,r,n){const{drag:i}=this.getProps();if(!n||!Od(e,i,this.currentDirection))return;const s=this.getAxisMotionValue(e);let o=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(o=oK(o,this.constraints[e],this.elastic[e])),s.set(o)}resolveConstraints(){var e;const{dragConstraints:r,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(e=this.visualElement.projection)===null||e===void 0?void 0:e.layout,s=this.constraints;r&&jc(r)?this.constraints||(this.constraints=this.resolveRefConstraints()):r&&i?this.constraints=aK(i.layoutBox,r):this.constraints=!1,this.elastic=lK(n),s!==this.constraints&&i&&this.constraints&&!this.hasMutatedConstraints&&Hi(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=fK(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:r}=this.getProps();if(!e||!jc(e))return!1;const n=e.current;ro(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const s=gK(n,i.root,this.visualElement.getTransformPagePoint());let o=cK(i.layout.layoutBox,s);if(r){const a=r(hK(o));this.hasMutatedConstraints=!!a,a&&(o=bE(a))}return o}startAnimation(e){const{drag:r,dragMomentum:n,dragElastic:i,dragTransition:s,dragSnapToOrigin:o,onDragTransitionEnd:a}=this.getProps(),f=this.constraints||{},u=Hi(h=>{if(!Od(h,r,this.currentDirection))return;let g=f&&f[h]||{};o&&(g={min:0,max:0});const b=i?200:1e6,x=i?40:1e7,S={type:"inertia",velocity:n?e[h]:0,bounceStiffness:b,bounceDamping:x,timeConstant:750,restDelta:1,restSpeed:10,...s,...g};return this.startAxisValueAnimation(h,S)});return Promise.all(u).then(a)}startAxisValueAnimation(e,r){const n=this.getAxisMotionValue(e);return c1(this.visualElement,e),n.start(n1(e,n,0,r,this.visualElement,!1))}stopAnimation(){Hi(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Hi(e=>{var r;return(r=this.getAxisMotionValue(e).animation)===null||r===void 0?void 0:r.pause()})}getAnimationState(e){var r;return(r=this.getAxisMotionValue(e).animation)===null||r===void 0?void 0:r.state}getAxisMotionValue(e){const r=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps(),i=n[r];return i||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){Hi(r=>{const{drag:n}=this.getProps();if(!Od(r,n,this.currentDirection))return;const{projection:i}=this.visualElement,s=this.getAxisMotionValue(r);if(i&&i.layout){const{min:o,max:a}=i.layout.layoutBox[r];s.set(e[r]-Zr(o,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!jc(r)||!n||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Hi(o=>{const a=this.getAxisMotionValue(o);if(a&&this.constraints!==!1){const f=a.get();i[o]=uK({min:f,max:f},this.constraints[o])}});const{transformTemplate:s}=this.visualElement.getProps();this.visualElement.current.style.transform=s?s({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),Hi(o=>{if(!Od(o,e,null))return;const a=this.getAxisMotionValue(o),{min:f,max:u}=this.constraints[o];a.set(Zr(f,u,i[o]))})}addListeners(){if(!this.visualElement.current)return;mK.set(this.visualElement,this);const e=this.visualElement.current,r=so(e,"pointerdown",f=>{const{drag:u,dragListener:h=!0}=this.getProps();u&&h&&this.start(f)}),n=()=>{const{dragConstraints:f}=this.getProps();jc(f)&&f.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,s=i.addEventListener("measure",n);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Nr.read(n);const o=io(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:u})=>{this.isDragging&&u&&(Hi(h=>{const g=this.getAxisMotionValue(h);g&&(this.originPoint[h]+=f[h].translate,g.set(g.get()+f[h].translate))}),this.visualElement.render())}));return()=>{o(),r(),s(),a&&a()}}getProps(){const e=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:i=!1,dragConstraints:s=!1,dragElastic:o=h1,dragMomentum:a=!0}=e;return{...e,drag:r,dragDirectionLock:n,dragPropagation:i,dragConstraints:s,dragElastic:o,dragMomentum:a}}}function Od(t,e,r){return(e===!0||e===t)&&(r===null||r===t)}function bK(t,e=10){let r=null;return Math.abs(t.y)>e?r="y":Math.abs(t.x)>e&&(r="x"),r}class yK extends zo{constructor(e){super(e),this.removeGroupControls=Ln,this.removeListeners=Ln,this.controls=new vK(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ln}unmount(){this.removeGroupControls(),this.removeListeners()}}const ME=t=>(e,r)=>{t&&Nr.postRender(()=>t(e,r))};class wK extends zo{constructor(){super(...arguments),this.removePointerDownListener=Ln}onPointerDown(e){this.session=new Q8(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:IE(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:r,onPan:n,onPanEnd:i}=this.node.getProps();return{onSessionStart:ME(e),onStart:ME(r),onMove:n,onEnd:(s,o)=>{delete this.session,i&&Nr.postRender(()=>i(s,o))}}}mount(){this.removePointerDownListener=so(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Nd=Se.createContext(null);function xK(){const t=Se.useContext(Nd);if(t===null)return[!0,null];const{isPresent:e,onExitComplete:r,register:n}=t,i=Se.useId();Se.useEffect(()=>n(i),[]);const s=Se.useCallback(()=>r&&r(i),[i,r]);return!e&&r?[!1,s]:[!0]}const m1=Se.createContext({}),CE=Se.createContext({}),Ld={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function RE(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const rl={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(zt.test(t))t=parseFloat(t);else return t;const r=RE(t,e.target.x),n=RE(t,e.target.y);return`${r}% ${n}%`}},_K={correct:(t,{treeScale:e,projectionDelta:r})=>{const n=t,i=qo.parse(t);if(i.length>5)return n;const s=qo.createTransformer(t),o=typeof i[0]!="number"?1:0,a=r.x.scale*e.x,f=r.y.scale*e.y;i[0+o]/=a,i[1+o]/=f;const u=Zr(a,f,.5);return typeof i[2+o]=="number"&&(i[2+o]/=u),typeof i[3+o]=="number"&&(i[3+o]/=u),s(i)}},kd={};function EK(t){Object.assign(kd,t)}const{schedule:v1}=K4(queueMicrotask,!1);class SK extends Se.Component{componentDidMount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n,layoutId:i}=this.props,{projection:s}=e;EK(AK),s&&(r.group&&r.group.add(s),n&&n.register&&i&&n.register(s),s.root.didUpdate(),s.addEventListener("animationComplete",()=>{this.safeToRemove()}),s.setOptions({...s.options,onExitComplete:()=>this.safeToRemove()})),Ld.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:r,visualElement:n,drag:i,isPresent:s}=this.props,o=n.projection;return o&&(o.isPresent=s,i||e.layoutDependency!==r||r===void 0?o.willUpdate():this.safeToRemove(),e.isPresent!==s&&(s?o.promote():o.relegate()||Nr.postRender(()=>{const a=o.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),v1.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:i}=e;i&&(i.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(i),n&&n.deregister&&n.deregister(i))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function TE(t){const[e,r]=xK(),n=Se.useContext(m1);return he.jsx(SK,{...t,layoutGroup:n,switchLayoutGroup:Se.useContext(CE),isPresent:e,safeToRemove:r})}const AK={borderRadius:{...rl,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:rl,borderTopRightRadius:rl,borderBottomLeftRadius:rl,borderBottomRightRadius:rl,boxShadow:_K},DE=["TopLeft","TopRight","BottomLeft","BottomRight"],PK=DE.length,OE=t=>typeof t=="string"?parseFloat(t):t,NE=t=>typeof t=="number"||zt.test(t);function IK(t,e,r,n,i,s){i?(t.opacity=Zr(0,r.opacity!==void 0?r.opacity:1,MK(n)),t.opacityExit=Zr(e.opacity!==void 0?e.opacity:1,0,CK(n))):s&&(t.opacity=Zr(e.opacity!==void 0?e.opacity:1,r.opacity!==void 0?r.opacity:1,n));for(let o=0;one?1:r(Fc(t,e,n))}function BE(t,e){t.min=e.min,t.max=e.max}function Wi(t,e){BE(t.x,e.x),BE(t.y,e.y)}function FE(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function jE(t,e,r,n,i){return t-=e,t=Dd(t,1/r,n),i!==void 0&&(t=Dd(t,1/i,n)),t}function RK(t,e=0,r=1,n=.5,i,s=t,o=t){if(Os.test(e)&&(e=parseFloat(e),e=Zr(o.min,o.max,e/100)-o.min),typeof e!="number")return;let a=Zr(s.min,s.max,n);t===s&&(a-=e),t.min=jE(t.min,e,r,a,i),t.max=jE(t.max,e,r,a,i)}function UE(t,e,[r,n,i],s,o){RK(t,e[r],e[n],e[i],e.scale,s,o)}const TK=["x","scaleX","originX"],DK=["y","scaleY","originY"];function $E(t,e,r,n){UE(t.x,e,TK,r?r.x:void 0,n?n.x:void 0),UE(t.y,e,DK,r?r.y:void 0,n?n.y:void 0)}function qE(t){return t.translate===0&&t.scale===1}function zE(t){return qE(t.x)&&qE(t.y)}function HE(t,e){return t.min===e.min&&t.max===e.max}function OK(t,e){return HE(t.x,e.x)&&HE(t.y,e.y)}function WE(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function KE(t,e){return WE(t.x,e.x)&&WE(t.y,e.y)}function VE(t){return xi(t.x)/xi(t.y)}function GE(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class NK{constructor(){this.members=[]}add(e){i1(this.members,e),e.scheduleRender()}remove(e){if(s1(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const r=this.members[this.members.length-1];r&&this.promote(r)}}relegate(e){const r=this.members.findIndex(i=>e===i);if(r===0)return!1;let n;for(let i=r;i>=0;i--){const s=this.members[i];if(s.isPresent!==!1){n=s;break}}return n?(this.promote(n),!0):!1}promote(e,r){const n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender(),e.resumeFrom=n,r&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:i}=e.options;i===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:r,resumingFrom:n}=e;r.onExitComplete&&r.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function LK(t,e,r){let n="";const i=t.x.translate/e.x,s=t.y.translate/e.y,o=r?.z||0;if((i||s||o)&&(n=`translate3d(${i}px, ${s}px, ${o}px) `),(e.x!==1||e.y!==1)&&(n+=`scale(${1/e.x}, ${1/e.y}) `),r){const{transformPerspective:u,rotate:h,rotateX:g,rotateY:b,skewX:x,skewY:S}=r;u&&(n=`perspective(${u}px) ${n}`),h&&(n+=`rotate(${h}deg) `),g&&(n+=`rotateX(${g}deg) `),b&&(n+=`rotateY(${b}deg) `),x&&(n+=`skewX(${x}deg) `),S&&(n+=`skewY(${S}deg) `)}const a=t.x.scale*e.x,f=t.y.scale*e.y;return(a!==1||f!==1)&&(n+=`scale(${a}, ${f})`),n||"none"}const kK=(t,e)=>t.depth-e.depth;class BK{constructor(){this.children=[],this.isDirty=!1}add(e){i1(this.children,e),this.isDirty=!0}remove(e){s1(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(kK),this.isDirty=!1,this.children.forEach(e)}}function Bd(t){const e=qn(t)?t.get():t;return CW(e)?e.toValue():e}function FK(t,e){const r=Ns.now(),n=({timestamp:i})=>{const s=i-r;s>=e&&(jo(n),t(s-e))};return Nr.read(n,!0),()=>jo(n)}function jK(t){return t instanceof SVGElement&&t.tagName!=="svg"}function UK(t,e,r){const n=qn(t)?t:Qf(t);return n.start(n1("",n,e,r)),n.animation}const Ha={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},nl=typeof window<"u"&&window.MotionDebug!==void 0,b1=["","X","Y","Z"],$K={visibility:"hidden"},YE=1e3;let qK=0;function y1(t,e,r,n){const{latestValues:i}=e;i[t]&&(r[t]=i[t],e.setStaticValue(t,0),n&&(n[t]=0))}function JE(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const r=V8(e);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:i,layoutId:s}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Nr,!(i||s))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&JE(n)}function XE({attachResizeListener:t,defaultParent:e,measureScroll:r,checkIsScrollRoot:n,resetTransform:i}){return class{constructor(o={},a=e?.()){this.id=qK++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,nl&&(Ha.totalNodes=Ha.resolvedTargetDeltas=Ha.recalculatedProjection=0),this.nodes.forEach(WK),this.nodes.forEach(JK),this.nodes.forEach(XK),this.nodes.forEach(KK),nl&&window.MotionDebug.record(Ha)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let f=0;fthis.root.updateBlockedByResize=!1;t(o,()=>{this.root.updateBlockedByResize=!0,g&&g(),g=FK(b,250),Ld.hasAnimatedSinceResize&&(Ld.hasAnimatedSinceResize=!1,this.nodes.forEach(QE))})}f&&this.root.registerSharedNode(f,this),this.options.animate!==!1&&h&&(f||u)&&this.addEventListener("didUpdate",({delta:g,hasLayoutChanged:b,hasRelativeTargetChanged:x,layout:S})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const C=this.options.transition||h.getDefaultTransition()||rV,{onLayoutAnimationStart:D,onLayoutAnimationComplete:B}=h.getProps(),L=!this.targetLayout||!KE(this.targetLayout,S)||x,H=!b&&x;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||H||b&&(L||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(g,H);const F={...Tv(C,"layout"),onPlay:D,onComplete:B};(h.shouldReduceMotion||this.options.layoutRoot)&&(F.delay=0,F.type=!1),this.startAnimation(F)}else b||QE(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=S})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,jo(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(ZK),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&JE(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let h=0;h{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let f=0;f{const k=F/1e3;eS(g.x,o.x,k),eS(g.y,o.y,k),this.setTargetDelta(g),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(tl(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox),eV(this.relativeTarget,this.relativeTargetOrigin,b,k),H&&OK(this.relativeTarget,H)&&(this.isProjectionDirty=!1),H||(H=cn()),Wi(H,this.relativeTarget)),C&&(this.animationValues=h,IK(h,u,this.latestValues,k,L,B)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=k},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(jo(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Nr.update(()=>{Ld.hasAnimatedSinceResize=!0,this.currentAnimation=UK(0,YE,{...o,onUpdate:a=>{this.mixTargetDelta(a),o.onUpdate&&o.onUpdate(a)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(YE),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:a,target:f,layout:u,latestValues:h}=o;if(!(!a||!f||!u)){if(this!==o&&this.layout&&u&&sS(this.options.animationType,this.layout.layoutBox,u.layoutBox)){f=this.target||cn();const g=xi(this.layout.layoutBox.x);f.x.min=o.target.x.min,f.x.max=f.x.min+g;const b=xi(this.layout.layoutBox.y);f.y.min=o.target.y.min,f.y.max=f.y.min+b}Wi(a,f),qc(a,h),el(this.projectionDeltaWithTransform,this.layoutCorrected,a,h)}}registerSharedNode(o,a){this.sharedNodes.has(o)||this.sharedNodes.set(o,new NK),this.sharedNodes.get(o).add(a);const u=a.options.initialPromotionConfig;a.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(a):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:a}=this.options;return a?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:a}=this.options;return a?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:a,preserveFollowOpacity:f}={}){const u=this.getStack();u&&u.promote(this,f),o&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let a=!1;const{latestValues:f}=o;if((f.z||f.rotate||f.rotateX||f.rotateY||f.rotateZ||f.skewX||f.skewY)&&(a=!0),!a)return;const u={};f.z&&y1("z",o,u,this.animationValues);for(let h=0;h{var a;return(a=o.currentAnimation)===null||a===void 0?void 0:a.stop()}),this.root.nodes.forEach(ZE),this.root.sharedNodes.clear()}}}function zK(t){t.updateLayout()}function HK(t){var e;const r=((e=t.resumeFrom)===null||e===void 0?void 0:e.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&r&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:i}=t.layout,{animationType:s}=t.options,o=r.source!==t.layout.source;s==="size"?Hi(g=>{const b=o?r.measuredBox[g]:r.layoutBox[g],x=xi(b);b.min=n[g].min,b.max=b.min+x}):sS(s,r.layoutBox,n)&&Hi(g=>{const b=o?r.measuredBox[g]:r.layoutBox[g],x=xi(n[g]);b.max=b.min+x,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[g].max=t.relativeTarget[g].min+x)});const a=Uc();el(a,n,r.layoutBox);const f=Uc();o?el(f,t.applyTransform(i,!0),r.measuredBox):el(f,n,r.layoutBox);const u=!zE(a);let h=!1;if(!t.resumeFrom){const g=t.getClosestProjectingParent();if(g&&!g.resumeFrom){const{snapshot:b,layout:x}=g;if(b&&x){const S=cn();tl(S,r.layoutBox,b.layoutBox);const C=cn();tl(C,n,x.layoutBox),KE(S,C)||(h=!0),g.options.layoutRoot&&(t.relativeTarget=C,t.relativeTargetOrigin=S,t.relativeParent=g)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:r,delta:f,layoutDelta:a,hasLayoutChanged:u,hasRelativeTargetChanged:h})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function WK(t){nl&&Ha.totalNodes++,t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function KK(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function VK(t){t.clearSnapshot()}function ZE(t){t.clearMeasurements()}function GK(t){t.isLayoutDirty=!1}function YK(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function QE(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function JK(t){t.resolveTargetDelta()}function XK(t){t.calcProjection()}function ZK(t){t.resetSkewAndRotation()}function QK(t){t.removeLeadSnapshot()}function eS(t,e,r){t.translate=Zr(e.translate,0,r),t.scale=Zr(e.scale,1,r),t.origin=e.origin,t.originPoint=e.originPoint}function tS(t,e,r,n){t.min=Zr(e.min,r.min,n),t.max=Zr(e.max,r.max,n)}function eV(t,e,r,n){tS(t.x,e.x,r.x,n),tS(t.y,e.y,r.y,n)}function tV(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const rV={duration:.45,ease:[.4,0,.1,1]},rS=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),nS=rS("applewebkit/")&&!rS("chrome/")?Math.round:Ln;function iS(t){t.min=nS(t.min),t.max=nS(t.max)}function nV(t){iS(t.x),iS(t.y)}function sS(t,e,r){return t==="position"||t==="preserve-aspect"&&!iK(VE(e),VE(r),.2)}function iV(t){var e;return t!==t.root&&((e=t.scroll)===null||e===void 0?void 0:e.wasRoot)}const sV=XE({attachResizeListener:(t,e)=>io(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),w1={current:void 0},oS=XE({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!w1.current){const t=new sV({});t.mount(window),t.setOptions({layoutScroll:!0}),w1.current=t}return w1.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),oV={pan:{Feature:wK},drag:{Feature:yK,ProjectionNode:oS,MeasureLayout:TE}};function aS(t,e){const r=e?"pointerenter":"pointerleave",n=e?"onHoverStart":"onHoverEnd",i=(s,o)=>{if(s.pointerType==="touch"||oE())return;const a=t.getProps();t.animationState&&a.whileHover&&t.animationState.setActive("whileHover",e);const f=a[n];f&&Nr.postRender(()=>f(s,o))};return so(t.current,r,i,{passive:!t.getProps()[n]})}class aV extends zo{mount(){this.unmount=no(aS(this.node,!0),aS(this.node,!1))}unmount(){}}class cV extends zo{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=no(io(this.node.current,"focus",()=>this.onFocus()),io(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const cS=(t,e)=>e?t===e?!0:cS(t,e.parentElement):!1;function x1(t,e){if(!e)return;const r=new PointerEvent("pointer"+t);e(r,Td(r))}class uV extends zo{constructor(){super(...arguments),this.removeStartListeners=Ln,this.removeEndListeners=Ln,this.removeAccessibleListeners=Ln,this.startPointerPress=(e,r)=>{if(this.isPressing)return;this.removeEndListeners();const n=this.node.getProps(),s=so(window,"pointerup",(a,f)=>{if(!this.checkPressEnd())return;const{onTap:u,onTapCancel:h,globalTapTarget:g}=this.node.getProps(),b=!g&&!cS(this.node.current,a.target)?h:u;b&&Nr.update(()=>b(a,f))},{passive:!(n.onTap||n.onPointerUp)}),o=so(window,"pointercancel",(a,f)=>this.cancelPress(a,f),{passive:!(n.onTapCancel||n.onPointerCancel)});this.removeEndListeners=no(s,o),this.startPress(e,r)},this.startAccessiblePress=()=>{const e=s=>{if(s.key!=="Enter"||this.isPressing)return;const o=a=>{a.key!=="Enter"||!this.checkPressEnd()||x1("up",(f,u)=>{const{onTap:h}=this.node.getProps();h&&Nr.postRender(()=>h(f,u))})};this.removeEndListeners(),this.removeEndListeners=io(this.node.current,"keyup",o),x1("down",(a,f)=>{this.startPress(a,f)})},r=io(this.node.current,"keydown",e),n=()=>{this.isPressing&&x1("cancel",(s,o)=>this.cancelPress(s,o))},i=io(this.node.current,"blur",n);this.removeAccessibleListeners=no(r,i)}}startPress(e,r){this.isPressing=!0;const{onTapStart:n,whileTap:i}=this.node.getProps();i&&this.node.animationState&&this.node.animationState.setActive("whileTap",!0),n&&Nr.postRender(()=>n(e,r))}checkPressEnd(){return this.removeEndListeners(),this.isPressing=!1,this.node.getProps().whileTap&&this.node.animationState&&this.node.animationState.setActive("whileTap",!1),!oE()}cancelPress(e,r){if(!this.checkPressEnd())return;const{onTapCancel:n}=this.node.getProps();n&&Nr.postRender(()=>n(e,r))}mount(){const e=this.node.getProps(),r=so(e.globalTapTarget?window:this.node.current,"pointerdown",this.startPointerPress,{passive:!(e.onTapStart||e.onPointerStart)}),n=io(this.node.current,"focus",this.startAccessiblePress);this.removeStartListeners=no(r,n)}unmount(){this.removeStartListeners(),this.removeEndListeners(),this.removeAccessibleListeners()}}const _1=new WeakMap,E1=new WeakMap,fV=t=>{const e=_1.get(t.target);e&&e(t)},lV=t=>{t.forEach(fV)};function hV({root:t,...e}){const r=t||document;E1.has(r)||E1.set(r,{});const n=E1.get(r),i=JSON.stringify(e);return n[i]||(n[i]=new IntersectionObserver(lV,{root:t,...e})),n[i]}function dV(t,e,r){const n=hV(e);return _1.set(t,r),n.observe(t),()=>{_1.delete(t),n.unobserve(t)}}const pV={some:0,all:1};class gV extends zo{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:r,margin:n,amount:i="some",once:s}=e,o={root:r?r.current:void 0,rootMargin:n,threshold:typeof i=="number"?i:pV[i]},a=f=>{const{isIntersecting:u}=f;if(this.isInView===u||(this.isInView=u,s&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:h,onViewportLeave:g}=this.node.getProps(),b=u?h:g;b&&b(f)};return dV(this.node.current,o,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:r}=this.node;["amount","margin","root"].some(mV(e,r))&&this.startObserver()}unmount(){}}function mV({viewport:t={}},{viewport:e={}}={}){return r=>t[r]!==e[r]}const vV={inView:{Feature:gV},tap:{Feature:uV},focus:{Feature:cV},hover:{Feature:aV}},bV={layout:{ProjectionNode:oS,MeasureLayout:TE}},S1=Se.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"}),Fd=Se.createContext({}),A1=typeof window<"u",uS=A1?Se.useLayoutEffect:Se.useEffect,fS=Se.createContext({strict:!1});function yV(t,e,r,n,i){var s,o;const{visualElement:a}=Se.useContext(Fd),f=Se.useContext(fS),u=Se.useContext(Nd),h=Se.useContext(S1).reducedMotion,g=Se.useRef();n=n||f.renderer,!g.current&&n&&(g.current=n(t,{visualState:e,parent:a,props:r,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:h}));const b=g.current,x=Se.useContext(CE);b&&!b.projection&&i&&(b.type==="html"||b.type==="svg")&&wV(g.current,r,i,x);const S=Se.useRef(!1);Se.useInsertionEffect(()=>{b&&S.current&&b.update(r,u)});const C=r[K8],D=Se.useRef(!!C&&!(!((s=window.MotionHandoffIsComplete)===null||s===void 0)&&s.call(window,C))&&((o=window.MotionHasOptimisedAnimation)===null||o===void 0?void 0:o.call(window,C)));return uS(()=>{b&&(S.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),v1.render(b.render),D.current&&b.animationState&&b.animationState.animateChanges())}),Se.useEffect(()=>{b&&(!D.current&&b.animationState&&b.animationState.animateChanges(),D.current&&(queueMicrotask(()=>{var B;(B=window.MotionHandoffMarkAsComplete)===null||B===void 0||B.call(window,C)}),D.current=!1))}),b}function wV(t,e,r,n){const{layoutId:i,layout:s,drag:o,dragConstraints:a,layoutScroll:f,layoutRoot:u}=e;t.projection=new r(t.latestValues,e["data-framer-portal-id"]?void 0:lS(t.parent)),t.projection.setOptions({layoutId:i,layout:s,alwaysMeasureLayout:!!o||a&&jc(a),visualElement:t,animationType:typeof s=="string"?s:"both",initialPromotionConfig:n,layoutScroll:f,layoutRoot:u})}function lS(t){if(t)return t.options.allowProjection!==!1?t.projection:lS(t.parent)}function xV(t,e,r){return Se.useCallback(n=>{n&&t.mount&&t.mount(n),e&&(n?e.mount(n):e.unmount()),r&&(typeof r=="function"?r(n):jc(r)&&(r.current=n))},[e])}function jd(t){return xd(t.animate)||Rv.some(e=>Wf(t[e]))}function hS(t){return!!(jd(t)||t.variants)}function _V(t,e){if(jd(t)){const{initial:r,animate:n}=t;return{initial:r===!1||Wf(r)?r:void 0,animate:Wf(n)?n:void 0}}return t.inherit!==!1?e:{}}function EV(t){const{initial:e,animate:r}=_V(t,Se.useContext(Fd));return Se.useMemo(()=>({initial:e,animate:r}),[dS(e),dS(r)])}function dS(t){return Array.isArray(t)?t.join(" "):t}const pS={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},zc={};for(const t in pS)zc[t]={isEnabled:e=>pS[t].some(r=>!!e[r])};function SV(t){for(const e in t)zc[e]={...zc[e],...t[e]}}const AV=Symbol.for("motionComponentSymbol");function PV({preloadedFeatures:t,createVisualElement:e,useRender:r,useVisualState:n,Component:i}){t&&SV(t);function s(a,f){let u;const h={...Se.useContext(S1),...a,layoutId:IV(a)},{isStatic:g}=h,b=EV(a),x=n(a,g);if(!g&&A1){MV(h,t);const S=CV(h);u=S.MeasureLayout,b.visualElement=yV(i,x,h,e,S.ProjectionNode)}return he.jsxs(Fd.Provider,{value:b,children:[u&&b.visualElement?he.jsx(u,{visualElement:b.visualElement,...h}):null,r(i,a,xV(x,b.visualElement,f),x,g,b.visualElement)]})}const o=Se.forwardRef(s);return o[AV]=i,o}function IV({layoutId:t}){const e=Se.useContext(m1).id;return e&&t!==void 0?e+"-"+t:t}function MV(t,e){const r=Se.useContext(fS).strict;if(process.env.NODE_ENV!=="production"&&e&&r){const n="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";t.ignoreStrict?Nc(!1,n):ro(!1,n)}}function CV(t){const{drag:e,layout:r}=zc;if(!e&&!r)return{};const n={...e,...r};return{MeasureLayout:e?.isEnabled(t)||r?.isEnabled(t)?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}const RV=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function P1(t){return typeof t!="string"||t.includes("-")?!1:!!(RV.indexOf(t)>-1||/[A-Z]/u.test(t))}function gS(t,{style:e,vars:r},n,i){Object.assign(t.style,e,i&&i.getProjectionStyles(n));for(const s in r)t.style.setProperty(s,r[s])}const mS=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function vS(t,e,r,n){gS(t,e,void 0,n);for(const i in e.attrs)t.setAttribute(mS.has(i)?i:a1(i),e.attrs[i])}function bS(t,{layout:e,layoutId:r}){return ja.has(t)||t.startsWith("origin")||(e||r!==void 0)&&(!!kd[t]||t==="opacity")}function I1(t,e,r){var n;const{style:i}=t,s={};for(const o in i)(qn(i[o])||e.style&&qn(e.style[o])||bS(o,t)||((n=r?.getValue(o))===null||n===void 0?void 0:n.liveStyle)!==void 0)&&(s[o]=i[o]);return s}function yS(t,e,r){const n=I1(t,e,r);for(const i in t)if(qn(t[i])||qn(e[i])){const s=Kf.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;n[s]=t[i]}return n}function M1(t){const e=Se.useRef(null);return e.current===null&&(e.current=t()),e.current}function TV({scrapeMotionValuesFromProps:t,createRenderState:e,onMount:r},n,i,s){const o={latestValues:DV(n,i,s,t),renderState:e()};return r&&(o.mount=a=>r(n,a,o)),o}const wS=t=>(e,r)=>{const n=Se.useContext(Fd),i=Se.useContext(Nd),s=()=>TV(t,e,n,i);return r?s():M1(s)};function DV(t,e,r,n){const i={},s=n(t,{});for(const b in s)i[b]=Bd(s[b]);let{initial:o,animate:a}=t;const f=jd(t),u=hS(t);e&&u&&!f&&t.inherit!==!1&&(o===void 0&&(o=e.initial),a===void 0&&(a=e.animate));let h=r?r.initial===!1:!1;h=h||o===!1;const g=h?a:o;if(g&&typeof g!="boolean"&&!xd(g)){const b=Array.isArray(g)?g:[g];for(let x=0;x({style:{},transform:{},transformOrigin:{},vars:{}}),xS=()=>({...C1(),attrs:{}}),_S=(t,e)=>e&&typeof t=="number"?e.transform(t):t,OV={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},NV=Kf.length;function LV(t,e,r){let n="",i=!0;for(let s=0;stypeof t=="string"&&t.toLowerCase()==="svg",UV={useVisualState:wS({scrapeMotionValuesFromProps:yS,createRenderState:xS,onMount:(t,e,{renderState:r,latestValues:n})=>{Nr.read(()=>{try{r.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{r.dimensions={x:0,y:0,width:0,height:0}}}),Nr.render(()=>{T1(r,n,D1(e.tagName),t.transformTemplate),vS(e,r)})}})},$V={useVisualState:wS({scrapeMotionValuesFromProps:I1,createRenderState:C1})};function SS(t,e,r){for(const n in e)!qn(e[n])&&!bS(n,r)&&(t[n]=e[n])}function qV({transformTemplate:t},e){return Se.useMemo(()=>{const r=C1();return R1(r,e,t),Object.assign({},r.vars,r.style)},[e])}function zV(t,e){const r=t.style||{},n={};return SS(n,r,t),Object.assign(n,qV(t,e)),n}function HV(t,e){const r={},n=zV(t,e);return t.drag&&t.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(r.tabIndex=0),r.style=n,r}const WV=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Ud(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||WV.has(t)}let AS=t=>!Ud(t);function KV(t){t&&(AS=e=>e.startsWith("on")?!Ud(e):t(e))}try{KV(require("@emotion/is-prop-valid").default)}catch{}function VV(t,e,r){const n={};for(const i in t)i==="values"&&typeof t.values=="object"||(AS(i)||r===!0&&Ud(i)||!e&&!Ud(i)||t.draggable&&i.startsWith("onDrag"))&&(n[i]=t[i]);return n}function GV(t,e,r,n){const i=Se.useMemo(()=>{const s=xS();return T1(s,e,D1(n),t.transformTemplate),{...s.attrs,style:{...s.style}}},[e]);if(t.style){const s={};SS(s,t.style,t),i.style={...s,...i.style}}return i}function YV(t=!1){return(r,n,i,{latestValues:s},o)=>{const f=(P1(r)?GV:HV)(n,s,o,r),u=VV(n,typeof r=="string",t),h=r!==Se.Fragment?{...u,...f,ref:i}:{},{children:g}=n,b=Se.useMemo(()=>qn(g)?g.get():g,[g]);return Se.createElement(r,{...h,children:b})}}function JV(t,e){return function(n,{forwardMotionProps:i}={forwardMotionProps:!1}){const o={...P1(n)?UV:$V,preloadedFeatures:t,useRender:YV(i),createVisualElement:e,Component:n};return PV(o)}}const O1={current:null},PS={current:!1};function XV(){if(PS.current=!0,!!A1)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>O1.current=t.matches;t.addListener(e),e()}else O1.current=!1}function ZV(t,e,r){for(const n in e){const i=e[n],s=r[n];if(qn(i))t.addValue(n,i),process.env.NODE_ENV==="development"&&wd(i.version==="11.11.17",`Attempting to mix Motion versions ${i.version} with 11.11.17 may not work as expected.`);else if(qn(s))t.addValue(n,Qf(i,{owner:t}));else if(s!==i)if(t.hasValue(n)){const o=t.getValue(n);o.liveStyle===!0?o.jump(i):o.hasAnimated||o.set(i)}else{const o=t.getStaticValue(n);t.addValue(n,Qf(o!==void 0?o:i,{owner:t}))}}for(const n in r)e[n]===void 0&&t.removeValue(n);return e}const IS=new WeakMap,QV=[...l8,$n,qo],eG=t=>QV.find(f8(t)),MS=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class tG{scrapeMotionValuesFromProps(e,r,n){return{}}constructor({parent:e,props:r,presenceContext:n,reducedMotionConfig:i,blockInitialAnimation:s,visualState:o},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Fv,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const b=Ns.now();this.renderScheduledAtthis.bindToMotionValue(n,r)),PS.current||XV(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:O1.current,process.env.NODE_ENV!=="production"&&wd(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected."),this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){IS.delete(this.current),this.projection&&this.projection.unmount(),jo(this.notifyUpdate),jo(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const e in this.events)this.events[e].clear();for(const e in this.features){const r=this.features[e];r&&(r.unmount(),r.isMounted=!1)}this.current=null}bindToMotionValue(e,r){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const n=ja.has(e),i=r.on("change",a=>{this.latestValues[e]=a,this.props.onUpdate&&Nr.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0)}),s=r.on("renderRequest",this.scheduleRender);let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,e,r)),this.valueSubscriptions.set(e,()=>{i(),s(),o&&o(),r.owner&&r.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in zc){const r=zc[e];if(!r)continue;const{isEnabled:n,Feature:i}=r;if(!this.features[e]&&i&&n(this.props)&&(this.features[e]=new i(this)),this.features[e]){const s=this.features[e];s.isMounted?s.update():(s.mount(),s.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):cn()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,r){this.latestValues[e]=r}update(e,r){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let n=0;nr.variantChildren.delete(e)}addValue(e,r){const n=this.values.get(e);r!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,r),this.values.set(e,r),this.latestValues[e]=r.get())}removeValue(e){this.values.delete(e);const r=this.valueSubscriptions.get(e);r&&(r(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,r){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&r!==void 0&&(n=Qf(r===null?void 0:r,{owner:this}),this.addValue(e,n)),n}readValue(e,r){var n;let i=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:(n=this.getBaseTargetFromProps(this.props,e))!==null&&n!==void 0?n:this.readValueFromInstance(this.current,e,this.options);return i!=null&&(typeof i=="string"&&(r8(i)||t8(i))?i=parseFloat(i):!eG(i)&&qo.test(r)&&(i=_8(e,r)),this.setBaseTarget(e,qn(i)?i.get():i)),qn(i)?i.get():i}setBaseTarget(e,r){this.baseTarget[e]=r}getBaseTarget(e){var r;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const o=Mv(this.props,n,(r=this.presenceContext)===null||r===void 0?void 0:r.custom);o&&(i=o[e])}if(n&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,e);return s!==void 0&&!qn(s)?s:this.initialValues[e]!==void 0&&i===void 0?void 0:this.baseTarget[e]}on(e,r){return this.events[e]||(this.events[e]=new o1),this.events[e].add(r)}notify(e,...r){this.events[e]&&this.events[e].notify(...r)}}class CS extends tG{constructor(){super(...arguments),this.KeyframeResolver=E8}sortInstanceNodePosition(e,r){return e.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(e,r){return e.style?e.style[r]:void 0}removeValueFromRenderState(e,{vars:r,style:n}){delete r[e],delete n[e]}}function rG(t){return window.getComputedStyle(t)}class nG extends CS{constructor(){super(...arguments),this.type="html",this.renderInstance=gS}readValueFromInstance(e,r){if(ja.has(r)){const n=Wv(r);return n&&n.default||0}else{const n=rG(e),i=(i8(r)?n.getPropertyValue(r):n[r])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:r}){return PE(e,r)}build(e,r,n){R1(e,r,n.transformTemplate)}scrapeMotionValuesFromProps(e,r,n){return I1(e,r,n)}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;qn(e)&&(this.childSubscription=e.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class iG extends CS{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=cn}getBaseTargetFromProps(e,r){return e[r]}readValueFromInstance(e,r){if(ja.has(r)){const n=Wv(r);return n&&n.default||0}return r=mS.has(r)?r:a1(r),e.getAttribute(r)}scrapeMotionValuesFromProps(e,r,n){return yS(e,r,n)}build(e,r,n){T1(e,r,this.isSVGTag,n.transformTemplate)}renderInstance(e,r,n,i){vS(e,r,n,i)}mount(e){this.isSVGTag=D1(e.tagName),super.mount(e)}}const sG=(t,e)=>P1(t)?new iG(e):new nG(e,{allowProjection:t!==Se.Fragment}),oG=JV({...YW,...vV,...oV,...bV},sG),aG=qz(oG);class cG extends Yt.Component{getSnapshotBeforeUpdate(e){const r=this.props.childRef.current;if(r&&e.isPresent&&!this.props.isPresent){const n=this.props.sizeRef.current;n.height=r.offsetHeight||0,n.width=r.offsetWidth||0,n.top=r.offsetTop,n.left=r.offsetLeft}return null}componentDidUpdate(){}render(){return this.props.children}}function uG({children:t,isPresent:e}){const r=Se.useId(),n=Se.useRef(null),i=Se.useRef({width:0,height:0,top:0,left:0}),{nonce:s}=Se.useContext(S1);return Se.useInsertionEffect(()=>{const{width:o,height:a,top:f,left:u}=i.current;if(e||!n.current||!o||!a)return;n.current.dataset.motionPopId=r;const h=document.createElement("style");return s&&(h.nonce=s),document.head.appendChild(h),h.sheet&&h.sheet.insertRule(` [data-motion-pop-id="${r}"] { position: absolute !important; width: ${o}px !important; height: ${a}px !important; - top: ${u}px !important; - left: ${l}px !important; + top: ${f}px !important; + left: ${u}px !important; } - `),()=>{document.head.removeChild(d)}},[e]),me.jsx(YJ,{isPresent:e,childRef:n,sizeRef:i,children:Yt.cloneElement(t,{ref:n})})}const XJ=({children:t,initial:e,isPresent:r,onExitComplete:n,custom:i,presenceAffectsLayout:s,mode:o})=>{const a=mb(ZJ),u=Pe.useId(),l=Pe.useCallback(g=>{a.set(g,!0);for(const y of a.values())if(!y)return;n&&n()},[a,n]),d=Pe.useMemo(()=>({id:u,initial:e,isPresent:r,custom:i,onExitComplete:l,register:g=>(a.set(g,!1),()=>a.delete(g))}),s?[Math.random(),l]:[r,l]);return Pe.useMemo(()=>{a.forEach((g,y)=>a.set(y,!1))},[r]),Yt.useEffect(()=>{!r&&!a.size&&n&&n()},[r]),o==="popLayout"&&(t=me.jsx(JJ,{isPresent:r,children:t})),me.jsx(B0.Provider,{value:d,children:t})};function ZJ(){return new Map}const W0=t=>t.key||"";function ZS(t){const e=[];return Pe.Children.forEach(t,r=>{Pe.isValidElement(r)&&e.push(r)}),e}const QJ=({children:t,exitBeforeEnter:e,custom:r,initial:n=!0,onExitComplete:i,presenceAffectsLayout:s=!0,mode:o="sync"})=>{Do(!e,"Replace exitBeforeEnter with mode='wait'");const a=Pe.useMemo(()=>ZS(t),[t]),u=a.map(W0),l=Pe.useRef(!0),d=Pe.useRef(a),g=mb(()=>new Map),[y,A]=Pe.useState(a),[P,N]=Pe.useState(a);RS(()=>{l.current=!1,d.current=a;for(let $=0;$1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:k}=Pe.useContext(ib);return me.jsx(me.Fragment,{children:P.map($=>{const q=W0($),U=a===P||u.includes(q),K=()=>{if(g.has(q))g.set(q,!0);else return;let J=!0;g.forEach(T=>{T||(J=!1)}),J&&(k==null||k(),N(d.current),i&&i())};return me.jsx(XJ,{isPresent:U,initial:!l.current||n?void 0:!1,custom:U?void 0:r,presenceAffectsLayout:s,mode:o,onExitComplete:U?void 0:K,children:$},q)})})},Ec=t=>me.jsx(QJ,{children:me.jsx(GJ.div,{initial:{x:0,opacity:0},animate:{x:0,opacity:1},exit:{x:30,opacity:0},transition:{duration:.3},className:t.className,children:t.children})});function _b(t){const{icon:e,title:r,extra:n,onClick:i}=t;function s(){i&&i()}return me.jsxs("div",{className:"xc-rounded-lg xc-group xc-flex xc-cursor-pointer xc-items-center xc-gap-2 xc-border xc-border-white xc-border-opacity-15 xc-px-4 xc-py-2 xc-transition-all hover:xc-shadow-lg",onClick:s,children:[e,r,me.jsxs("div",{className:"xc-relative xc-ml-auto xc-h-6",children:[me.jsx("div",{className:"xc-relative xc-left-0 xc-opacity-100 xc-transition-all group-hover:xc-left-2 group-hover:xc-opacity-0",children:n}),me.jsx("div",{className:"xc-absolute xc-right-2 xc-top-0 xc-text-gray-400 xc-opacity-0 xc-transition-all group-hover:xc-right-0 group-hover:xc-opacity-100",children:me.jsx(EK,{})})]})]})}function eX(t){return t.lastUsed?me.jsxs("div",{className:"xc-flex xc-items-center xc-gap-2 xc-rounded-full xc-py-1 xc-text-xs xc-text-gray-500",children:[me.jsx("div",{className:"xc-h-1 xc-w-1 xc-rounded-full xc-bg-[#009E8C]"}),"Last Used"]}):t.installed?me.jsxs("div",{className:"xc-flex xc-items-center xc-gap-2 xc-rounded-full xc-py-1 xc-text-xs xc-text-gray-500",children:[me.jsx("div",{className:"xc-h-1 xc-w-1 xc-rounded-full xc-bg-[#2596FF]"}),"Installed"]}):null}function QS(t){var o,a;const{wallet:e,onClick:r}=t,n=me.jsx("img",{className:"xc-rounded-md xc-h-5 xc-w-5",src:(o=e.config)==null?void 0:o.image}),i=((a=e.config)==null?void 0:a.name)||"",s=Pe.useMemo(()=>eX(e),[e]);return me.jsx(_b,{icon:n,title:i,extra:s,onClick:()=>r(e)})}function e7(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e{const e=sX(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:o=>{const a=o.split(Eb);return a[0]===""&&a.length!==1&&a.shift(),t7(a,e)||iX(o)},getConflictingClassGroupIds:(o,a)=>{const u=r[o]||[];return a&&n[o]?[...u,...n[o]]:u}}},t7=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const r=t[0],n=e.nextPart.get(r),i=n?t7(t.slice(1),n):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(Eb);return(o=e.validators.find(({validator:a})=>a(s)))==null?void 0:o.classGroupId},r7=/^\[(.+)\]$/,iX=t=>{if(r7.test(t)){const e=r7.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},sX=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return aX(Object.entries(t.classGroups),r).forEach(([s,o])=>{Sb(o,n,s,e)}),n},Sb=(t,e,r,n)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:n7(e,i);s.classGroupId=r;return}if(typeof i=="function"){if(oX(i)){Sb(i(n),e,r,n);return}e.validators.push({validator:i,classGroupId:r});return}Object.entries(i).forEach(([s,o])=>{Sb(o,n7(e,s),r,n)})})},n7=(t,e)=>{let r=t;return e.split(Eb).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},oX=t=>t.isThemeGetter,aX=(t,e)=>e?t.map(([r,n])=>{const i=n.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[e+o,a])):s);return[r,i]}):t,cX=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const i=(s,o)=>{r.set(s,o),e++,e>t&&(e=0,n=r,r=new Map)};return{get(s){let o=r.get(s);if(o!==void 0)return o;if((o=n.get(s))!==void 0)return i(s,o),o},set(s,o){r.has(s)?r.set(s,o):i(s,o)}}},i7="!",uX=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,i=e[0],s=e.length,o=a=>{const u=[];let l=0,d=0,g;for(let D=0;Dd?g-d:void 0;return{modifiers:u,hasImportantModifier:A,baseClassName:P,maybePostfixModifierPosition:N}};return r?a=>r({className:a,parseClassName:o}):o},fX=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},lX=t=>({cache:cX(t.cacheSize),parseClassName:uX(t),...nX(t)}),hX=/\s+/,dX=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(hX);let a="";for(let u=o.length-1;u>=0;u-=1){const l=o[u],{modifiers:d,hasImportantModifier:g,baseClassName:y,maybePostfixModifierPosition:A}=r(l);let P=!!A,N=n(P?y.substring(0,A):y);if(!N){if(!P){a=l+(a.length>0?" "+a:a);continue}if(N=n(y),!N){a=l+(a.length>0?" "+a:a);continue}P=!1}const D=fX(d).join(":"),k=g?D+i7:D,$=k+N;if(s.includes($))continue;s.push($);const q=i(N,P);for(let U=0;U0?" "+a:a)}return a};function pX(){let t=0,e,r,n="";for(;t{if(typeof t=="string")return t;let e,r="";for(let n=0;ng(d),t());return r=lX(l),n=r.cache.get,i=r.cache.set,s=a,a(u)}function a(u){const l=n(u);if(l)return l;const d=dX(u,r);return i(u,d),d}return function(){return s(pX.apply(null,arguments))}}const Gr=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},o7=/^\[(?:([a-z-]+):)?(.+)\]$/i,mX=/^\d+\/\d+$/,vX=new Set(["px","full","screen"]),bX=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,yX=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,wX=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,xX=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,_X=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ko=t=>Hu(t)||vX.has(t)||mX.test(t),_a=t=>Wu(t,"length",TX),Hu=t=>!!t&&!Number.isNaN(Number(t)),Ab=t=>Wu(t,"number",Hu),sh=t=>!!t&&Number.isInteger(Number(t)),EX=t=>t.endsWith("%")&&Hu(t.slice(0,-1)),cr=t=>o7.test(t),Ea=t=>bX.test(t),SX=new Set(["length","size","percentage"]),AX=t=>Wu(t,SX,a7),PX=t=>Wu(t,"position",a7),MX=new Set(["image","url"]),IX=t=>Wu(t,MX,DX),CX=t=>Wu(t,"",RX),oh=()=>!0,Wu=(t,e,r)=>{const n=o7.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},TX=t=>yX.test(t)&&!wX.test(t),a7=()=>!1,RX=t=>xX.test(t),DX=t=>_X.test(t),OX=gX(()=>{const t=Gr("colors"),e=Gr("spacing"),r=Gr("blur"),n=Gr("brightness"),i=Gr("borderColor"),s=Gr("borderRadius"),o=Gr("borderSpacing"),a=Gr("borderWidth"),u=Gr("contrast"),l=Gr("grayscale"),d=Gr("hueRotate"),g=Gr("invert"),y=Gr("gap"),A=Gr("gradientColorStops"),P=Gr("gradientColorStopPositions"),N=Gr("inset"),D=Gr("margin"),k=Gr("opacity"),$=Gr("padding"),q=Gr("saturate"),U=Gr("scale"),K=Gr("sepia"),J=Gr("skew"),T=Gr("space"),z=Gr("translate"),ue=()=>["auto","contain","none"],_e=()=>["auto","hidden","clip","visible","scroll"],G=()=>["auto",cr,e],E=()=>[cr,e],m=()=>["",ko,_a],f=()=>["auto",Hu,cr],p=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],v=()=>["solid","dashed","dotted","double","none"],x=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],_=()=>["start","end","center","between","around","evenly","stretch"],S=()=>["","0",cr],b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],M=()=>[Hu,cr];return{cacheSize:500,separator:":",theme:{colors:[oh],spacing:[ko,_a],blur:["none","",Ea,cr],brightness:M(),borderColor:[t],borderRadius:["none","","full",Ea,cr],borderSpacing:E(),borderWidth:m(),contrast:M(),grayscale:S(),hueRotate:M(),invert:S(),gap:E(),gradientColorStops:[t],gradientColorStopPositions:[EX,_a],inset:G(),margin:G(),opacity:M(),padding:E(),saturate:M(),scale:M(),sepia:S(),skew:M(),space:E(),translate:E()},classGroups:{aspect:[{aspect:["auto","square","video",cr]}],container:["container"],columns:[{columns:[Ea]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...p(),cr]}],overflow:[{overflow:_e()}],"overflow-x":[{"overflow-x":_e()}],"overflow-y":[{"overflow-y":_e()}],overscroll:[{overscroll:ue()}],"overscroll-x":[{"overscroll-x":ue()}],"overscroll-y":[{"overscroll-y":ue()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[N]}],"inset-x":[{"inset-x":[N]}],"inset-y":[{"inset-y":[N]}],start:[{start:[N]}],end:[{end:[N]}],top:[{top:[N]}],right:[{right:[N]}],bottom:[{bottom:[N]}],left:[{left:[N]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",sh,cr]}],basis:[{basis:G()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",cr]}],grow:[{grow:S()}],shrink:[{shrink:S()}],order:[{order:["first","last","none",sh,cr]}],"grid-cols":[{"grid-cols":[oh]}],"col-start-end":[{col:["auto",{span:["full",sh,cr]},cr]}],"col-start":[{"col-start":f()}],"col-end":[{"col-end":f()}],"grid-rows":[{"grid-rows":[oh]}],"row-start-end":[{row:["auto",{span:[sh,cr]},cr]}],"row-start":[{"row-start":f()}],"row-end":[{"row-end":f()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",cr]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",cr]}],gap:[{gap:[y]}],"gap-x":[{"gap-x":[y]}],"gap-y":[{"gap-y":[y]}],"justify-content":[{justify:["normal",..._()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",..._(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[..._(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[$]}],px:[{px:[$]}],py:[{py:[$]}],ps:[{ps:[$]}],pe:[{pe:[$]}],pt:[{pt:[$]}],pr:[{pr:[$]}],pb:[{pb:[$]}],pl:[{pl:[$]}],m:[{m:[D]}],mx:[{mx:[D]}],my:[{my:[D]}],ms:[{ms:[D]}],me:[{me:[D]}],mt:[{mt:[D]}],mr:[{mr:[D]}],mb:[{mb:[D]}],ml:[{ml:[D]}],"space-x":[{"space-x":[T]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[T]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",cr,e]}],"min-w":[{"min-w":[cr,e,"min","max","fit"]}],"max-w":[{"max-w":[cr,e,"none","full","min","max","fit","prose",{screen:[Ea]},Ea]}],h:[{h:[cr,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[cr,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[cr,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[cr,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Ea,_a]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ab]}],"font-family":[{font:[oh]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",cr]}],"line-clamp":[{"line-clamp":["none",Hu,Ab]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ko,cr]}],"list-image":[{"list-image":["none",cr]}],"list-style-type":[{list:["none","disc","decimal",cr]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...v(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ko,_a]}],"underline-offset":[{"underline-offset":["auto",ko,cr]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:E()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",cr]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",cr]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...p(),PX]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",AX]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},IX]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[P]}],"gradient-via-pos":[{via:[P]}],"gradient-to-pos":[{to:[P]}],"gradient-from":[{from:[A]}],"gradient-via":[{via:[A]}],"gradient-to":[{to:[A]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[k]}],"border-style":[{border:[...v(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[k]}],"divide-style":[{divide:v()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...v()]}],"outline-offset":[{"outline-offset":[ko,cr]}],"outline-w":[{outline:[ko,_a]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:m()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[ko,_a]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ea,CX]}],"shadow-color":[{shadow:[oh]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...x(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":x()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Ea,cr]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[g]}],saturate:[{saturate:[q]}],sepia:[{sepia:[K]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[q]}],"backdrop-sepia":[{"backdrop-sepia":[K]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",cr]}],duration:[{duration:M()}],ease:[{ease:["linear","in","out","in-out",cr]}],delay:[{delay:M()}],animate:[{animate:["none","spin","ping","pulse","bounce",cr]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[U]}],"scale-x":[{"scale-x":[U]}],"scale-y":[{"scale-y":[U]}],rotate:[{rotate:[sh,cr]}],"translate-x":[{"translate-x":[z]}],"translate-y":[{"translate-y":[z]}],"skew-x":[{"skew-x":[J]}],"skew-y":[{"skew-y":[J]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",cr]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",cr]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",cr]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[ko,_a,Ab]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function $o(...t){return OX(rX(t))}function c7(t){const{className:e}=t;return me.jsxs("div",{className:$o("xc-flex xc-items-center xc-gap-2"),children:[me.jsx("hr",{className:$o("xc-flex-1 xc-border-gray-200",e)}),me.jsx("div",{className:"xc-shrink-0",children:t.children}),me.jsx("hr",{className:$o("xc-flex-1 xc-border-gray-200",e)})]})}const NX="https://static.codatta.io/codatta-connect/wallet-icons.svg?v=2#ton";function LX(t){const{onClick:e}=t;function r(){e&&e()}return me.jsx(c7,{className:"xc-opacity-20",children:me.jsxs("div",{className:"xc-flex xc-items-center xc-gap-2 xc-cursor-pointer",onClick:r,children:[me.jsx("span",{className:"xc-text-sm",children:"View more wallets"}),me.jsx(c8,{size:16})]})})}function kX(t){const[e,r]=Pe.useState(""),{featuredWallets:n,initialized:i}=Wl(),{onEmailConfirm:s,onSelectWallet:o,onSelectMoreWallets:a,onSelectTonConnect:u,config:l}=t,d=Pe.useMemo(()=>{const N=/[\u4e00-\u9fff]|[\u3400-\u4dbf]|[\u{20000}-\u{2a6df}]|[\u{2a700}-\u{2b73f}]|[\u{2b740}-\u{2b81f}]|[\u{2b820}-\u{2ceaf}]|[\uf900-\ufaff]|[\u3300-\u33ff]|[\ufe30-\ufe4f]/gu,D=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return!N.test(e)&&D.test(e)},[e]);function g(N){o(N)}function y(N){r(N.target.value)}async function A(){s(e)}function P(N){N.key==="Enter"&&d&&A()}return me.jsx(Ec,{children:i&&me.jsxs(me.Fragment,{children:[t.header||me.jsx("div",{className:"xc-mb-6 xc-text-xl xc-font-bold",children:"Log in or sign up"}),l.showEmailSignIn&&me.jsxs("div",{className:"xc-mb-4",children:[me.jsx("input",{className:"xc-w-full xc-bg-transparent xc-border-white xc-border xc-border-opacity-15 xc-h-10 xc-rounded-lg xc-px-3 xc-mb-3",placeholder:"Enter your email",type:"email",onChange:y,onKeyDown:P}),me.jsx("button",{disabled:!d,className:"xc-bg-[rgb(135,93,255)] xc-text-white xc-w-full xc-rounded-lg xc-py-2 disabled:xc-bg-opacity-10 disabled:xc-text-opacity-50 disabled:xc-bg-white xc-transition-all",onClick:A,children:"Continue"})]}),l.showEmailSignIn&&(l.showFeaturedWallets||l.showTonConnect)&&me.jsx("div",{className:"xc-mb-4",children:me.jsxs(c7,{className:"xc-opacity-20",children:[" ",me.jsx("span",{className:"xc-text-sm xc-opacity-20",children:"OR"})]})}),me.jsxs("div",{children:[me.jsxs("div",{className:"xc-mb-4 xc-flex xc-max-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar",children:[l.showFeaturedWallets&&n&&n.map(N=>me.jsx(QS,{wallet:N,onClick:g},`feature-${N.key}`)),l.showTonConnect&&me.jsx(_b,{icon:me.jsx("img",{className:"xc-h-5 xc-w-5",src:NX}),title:"TON Connect",onClick:u})]}),l.showMoreWallets&&me.jsx(LX,{onClick:a})]})]})})}function ah(t){const{title:e}=t;return me.jsxs("div",{className:"xc-flex xc-items-center xc-gap-2",children:[me.jsx(_K,{onClick:t.onBack,size:20,className:"xc-cursor-pointer"}),me.jsx("span",{children:e})]})}var $X=Object.defineProperty,BX=Object.defineProperties,FX=Object.getOwnPropertyDescriptors,K0=Object.getOwnPropertySymbols,u7=Object.prototype.hasOwnProperty,f7=Object.prototype.propertyIsEnumerable,l7=(t,e,r)=>e in t?$X(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,UX=(t,e)=>{for(var r in e||(e={}))u7.call(e,r)&&l7(t,r,e[r]);if(K0)for(var r of K0(e))f7.call(e,r)&&l7(t,r,e[r]);return t},jX=(t,e)=>BX(t,FX(e)),qX=(t,e)=>{var r={};for(var n in t)u7.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&K0)for(var n of K0(t))e.indexOf(n)<0&&f7.call(t,n)&&(r[n]=t[n]);return r};function zX(t){let e=setTimeout(t,0),r=setTimeout(t,10),n=setTimeout(t,50);return[e,r,n]}function HX(t){let e=Yt.useRef();return Yt.useEffect(()=>{e.current=t}),e.current}var WX=18,h7=40,KX=`${h7}px`,VX=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function GX({containerRef:t,inputRef:e,pushPasswordManagerStrategy:r,isFocused:n}){let[i,s]=Yt.useState(!1),[o,a]=Yt.useState(!1),[u,l]=Yt.useState(!1),d=Yt.useMemo(()=>r==="none"?!1:(r==="increase-width"||r==="experimental-no-flickering")&&i&&o,[i,o,r]),g=Yt.useCallback(()=>{let y=t.current,A=e.current;if(!y||!A||u||r==="none")return;let P=y,N=P.getBoundingClientRect().left+P.offsetWidth,D=P.getBoundingClientRect().top+P.offsetHeight/2,k=N-WX,$=D;document.querySelectorAll(VX).length===0&&document.elementFromPoint(k,$)===y||(s(!0),l(!0))},[t,e,u,r]);return Yt.useEffect(()=>{let y=t.current;if(!y||r==="none")return;function A(){let N=window.innerWidth-y.getBoundingClientRect().right;a(N>=h7)}A();let P=setInterval(A,1e3);return()=>{clearInterval(P)}},[t,r]),Yt.useEffect(()=>{let y=n||document.activeElement===e.current;if(r==="none"||!y)return;let A=setTimeout(g,0),P=setTimeout(g,2e3),N=setTimeout(g,5e3),D=setTimeout(()=>{l(!0)},6e3);return()=>{clearTimeout(A),clearTimeout(P),clearTimeout(N),clearTimeout(D)}},[e,n,r,g]),{hasPWMBadge:i,willPushPWMBadge:d,PWM_BADGE_SPACE_WIDTH:KX}}var d7=Yt.createContext({}),p7=Yt.forwardRef((t,e)=>{var r=t,{value:n,onChange:i,maxLength:s,textAlign:o="left",pattern:a,placeholder:u,inputMode:l="numeric",onComplete:d,pushPasswordManagerStrategy:g="increase-width",pasteTransformer:y,containerClassName:A,noScriptCSSFallback:P=YX,render:N,children:D}=r,k=qX(r,["value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","render","children"]),$,q,U,K,J;let[T,z]=Yt.useState(typeof k.defaultValue=="string"?k.defaultValue:""),ue=n??T,_e=HX(ue),G=Yt.useCallback(ie=>{i==null||i(ie),z(ie)},[i]),E=Yt.useMemo(()=>a?typeof a=="string"?new RegExp(a):a:null,[a]),m=Yt.useRef(null),f=Yt.useRef(null),p=Yt.useRef({value:ue,onChange:G,isIOS:typeof window<"u"&&((q=($=window==null?void 0:window.CSS)==null?void 0:$.supports)==null?void 0:q.call($,"-webkit-touch-callout","none"))}),v=Yt.useRef({prev:[(U=m.current)==null?void 0:U.selectionStart,(K=m.current)==null?void 0:K.selectionEnd,(J=m.current)==null?void 0:J.selectionDirection]});Yt.useImperativeHandle(e,()=>m.current,[]),Yt.useEffect(()=>{let ie=m.current,fe=f.current;if(!ie||!fe)return;p.current.value!==ie.value&&p.current.onChange(ie.value),v.current.prev=[ie.selectionStart,ie.selectionEnd,ie.selectionDirection];function ve(){if(document.activeElement!==ie){I(null),ae(null);return}let Te=ie.selectionStart,Be=ie.selectionEnd,Ie=ie.selectionDirection,Le=ie.maxLength,Ve=ie.value,ke=v.current.prev,ze=-1,He=-1,Ee;if(Ve.length!==0&&Te!==null&&Be!==null){let et=Te===Be,rt=Te===Ve.length&&Ve.length1&&Ve.length>1){let pt=0;if(ke[0]!==null&&ke[1]!==null){Ee=Je{fe&&fe.style.setProperty("--root-height",`${ie.clientHeight}px`)};Me();let Ne=new ResizeObserver(Me);return Ne.observe(ie),()=>{document.removeEventListener("selectionchange",ve,{capture:!0}),Ne.disconnect()}},[]);let[x,_]=Yt.useState(!1),[S,b]=Yt.useState(!1),[M,I]=Yt.useState(null),[F,ae]=Yt.useState(null);Yt.useEffect(()=>{zX(()=>{var ie,fe,ve,Me;(ie=m.current)==null||ie.dispatchEvent(new Event("input"));let Ne=(fe=m.current)==null?void 0:fe.selectionStart,Te=(ve=m.current)==null?void 0:ve.selectionEnd,Be=(Me=m.current)==null?void 0:Me.selectionDirection;Ne!==null&&Te!==null&&(I(Ne),ae(Te),v.current.prev=[Ne,Te,Be])})},[ue,S]),Yt.useEffect(()=>{_e!==void 0&&ue!==_e&&_e.length{let fe=ie.currentTarget.value.slice(0,s);if(fe.length>0&&E&&!E.test(fe)){ie.preventDefault();return}typeof _e=="string"&&fe.length<_e.length&&document.dispatchEvent(new Event("selectionchange")),G(fe)},[s,G,_e,E]),ee=Yt.useCallback(()=>{var ie;if(m.current){let fe=Math.min(m.current.value.length,s-1),ve=m.current.value.length;(ie=m.current)==null||ie.setSelectionRange(fe,ve),I(fe),ae(ve)}b(!0)},[s]),X=Yt.useCallback(ie=>{var fe,ve;let Me=m.current;if(!y&&(!p.current.isIOS||!ie.clipboardData||!Me))return;let Ne=ie.clipboardData.getData("text/plain"),Te=y?y(Ne):Ne;console.log({_content:Ne,content:Te}),ie.preventDefault();let Be=(fe=m.current)==null?void 0:fe.selectionStart,Ie=(ve=m.current)==null?void 0:ve.selectionEnd,Le=(Be!==Ie?ue.slice(0,Be)+Te+ue.slice(Ie):ue.slice(0,Be)+Te+ue.slice(Be)).slice(0,s);if(Le.length>0&&E&&!E.test(Le))return;Me.value=Le,G(Le);let Ve=Math.min(Le.length,s-1),ke=Le.length;Me.setSelectionRange(Ve,ke),I(Ve),ae(ke)},[s,G,E,ue]),Q=Yt.useMemo(()=>({position:"relative",cursor:k.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[k.disabled]),R=Yt.useMemo(()=>({position:"absolute",inset:0,width:O.willPushPWMBadge?`calc(100% + ${O.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:O.willPushPWMBadge?`inset(0 ${O.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:o,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[O.PWM_BADGE_SPACE_WIDTH,O.willPushPWMBadge,o]),Z=Yt.useMemo(()=>Yt.createElement("input",jX(UX({autoComplete:k.autoComplete||"one-time-code"},k),{"data-input-otp":!0,"data-input-otp-placeholder-shown":ue.length===0||void 0,"data-input-otp-mss":M,"data-input-otp-mse":F,inputMode:l,pattern:E==null?void 0:E.source,"aria-placeholder":u,style:R,maxLength:s,value:ue,ref:m,onPaste:ie=>{var fe;X(ie),(fe=k.onPaste)==null||fe.call(k,ie)},onChange:se,onMouseOver:ie=>{var fe;_(!0),(fe=k.onMouseOver)==null||fe.call(k,ie)},onMouseLeave:ie=>{var fe;_(!1),(fe=k.onMouseLeave)==null||fe.call(k,ie)},onFocus:ie=>{var fe;ee(),(fe=k.onFocus)==null||fe.call(k,ie)},onBlur:ie=>{var fe;b(!1),(fe=k.onBlur)==null||fe.call(k,ie)}})),[se,ee,X,l,R,s,F,M,k,E==null?void 0:E.source,ue]),te=Yt.useMemo(()=>({slots:Array.from({length:s}).map((ie,fe)=>{var ve;let Me=S&&M!==null&&F!==null&&(M===F&&fe===M||fe>=M&&feN?N(te):Yt.createElement(d7.Provider,{value:te},D),[D,te,N]);return Yt.createElement(Yt.Fragment,null,P!==null&&Yt.createElement("noscript",null,Yt.createElement("style",null,P)),Yt.createElement("div",{ref:f,"data-input-otp-container":!0,style:Q,className:A},le,Yt.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},Z)))});p7.displayName="Input";function ch(t,e){try{t.insertRule(e)}catch{console.error("input-otp could not insert CSS rule:",e)}}var YX=` + `),()=>{document.head.removeChild(h)}},[e]),he.jsx(cG,{isPresent:e,childRef:n,sizeRef:i,children:Yt.cloneElement(t,{ref:n})})}const fG=({children:t,initial:e,isPresent:r,onExitComplete:n,custom:i,presenceAffectsLayout:s,mode:o})=>{const a=M1(lG),f=Se.useId(),u=Se.useCallback(g=>{a.set(g,!0);for(const b of a.values())if(!b)return;n&&n()},[a,n]),h=Se.useMemo(()=>({id:f,initial:e,isPresent:r,custom:i,onExitComplete:u,register:g=>(a.set(g,!1),()=>a.delete(g))}),s?[Math.random(),u]:[r,u]);return Se.useMemo(()=>{a.forEach((g,b)=>a.set(b,!1))},[r]),Yt.useEffect(()=>{!r&&!a.size&&n&&n()},[r]),o==="popLayout"&&(t=he.jsx(uG,{isPresent:r,children:t})),he.jsx(Nd.Provider,{value:h,children:t})};function lG(){return new Map}const $d=t=>t.key||"";function RS(t){const e=[];return Se.Children.forEach(t,r=>{Se.isValidElement(r)&&e.push(r)}),e}const hG=({children:t,exitBeforeEnter:e,custom:r,initial:n=!0,onExitComplete:i,presenceAffectsLayout:s=!0,mode:o="sync"})=>{ro(!e,"Replace exitBeforeEnter with mode='wait'");const a=Se.useMemo(()=>RS(t),[t]),f=a.map($d),u=Se.useRef(!0),h=Se.useRef(a),g=M1(()=>new Map),[b,x]=Se.useState(a),[S,C]=Se.useState(a);uS(()=>{u.current=!1,h.current=a;for(let L=0;L1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:B}=Se.useContext(m1);return he.jsx(he.Fragment,{children:S.map(L=>{const H=$d(L),F=a===S||f.includes(H),k=()=>{if(g.has(H))g.set(H,!0);else return;let $=!0;g.forEach(R=>{R||($=!1)}),$&&(B?.(),C(h.current),i&&i())};return he.jsx(fG,{isPresent:F,initial:!u.current||n?void 0:!1,custom:F?void 0:r,presenceAffectsLayout:s,mode:o,onExitComplete:F?void 0:k,children:L},H)})})},ls=t=>he.jsx(hG,{children:he.jsx(aG.div,{initial:{x:0,opacity:0},animate:{x:0,opacity:1},exit:{x:30,opacity:0},transition:{duration:.3},className:t.className,children:t.children})});function N1(t){const{icon:e,title:r,extra:n,onClick:i}=t;function s(){i&&i()}return he.jsxs("div",{className:"xc-rounded-lg xc-group xc-flex xc-cursor-pointer xc-items-center xc-gap-2 xc-border xc-border-white xc-border-opacity-15 xc-px-4 xc-py-2 xc-transition-all hover:xc-shadow-lg",onClick:s,children:[e,r,he.jsxs("div",{className:"xc-relative xc-ml-auto xc-h-6",children:[he.jsx("div",{className:"xc-relative xc-left-0 xc-opacity-100 xc-transition-all group-hover:xc-left-2 group-hover:xc-opacity-0",children:n}),he.jsx("div",{className:"xc-absolute xc-right-2 xc-top-0 xc-text-gray-400 xc-opacity-0 xc-transition-all group-hover:xc-right-0 group-hover:xc-opacity-100",children:he.jsx(Lz,{})})]})]})}function dG(t){return t.lastUsed?he.jsxs("div",{className:"xc-flex xc-items-center xc-gap-2 xc-rounded-full xc-py-1 xc-text-xs xc-text-gray-500",children:[he.jsx("div",{className:"xc-h-1 xc-w-1 xc-rounded-full xc-bg-[#009E8C]"}),"Last Used"]}):t.installed?he.jsxs("div",{className:"xc-flex xc-items-center xc-gap-2 xc-rounded-full xc-py-1 xc-text-xs xc-text-gray-500",children:[he.jsx("div",{className:"xc-h-1 xc-w-1 xc-rounded-full xc-bg-[#2596FF]"}),"Installed"]}):null}function TS(t){const{wallet:e,onClick:r}=t,n=he.jsx("img",{className:"xc-rounded-md xc-h-5 xc-w-5",src:e.config?.image}),i=e.config?.name||"",s=Se.useMemo(()=>dG(e),[e]);return he.jsx(N1,{icon:n,title:i,extra:s,onClick:()=>r(e)})}function DS(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e{const e=bG(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:o=>{const a=o.split(L1);return a[0]===""&&a.length!==1&&a.shift(),OS(a,e)||vG(o)},getConflictingClassGroupIds:(o,a)=>{const f=r[o]||[];return a&&n[o]?[...f,...n[o]]:f}}},OS=(t,e)=>{if(t.length===0)return e.classGroupId;const r=t[0],n=e.nextPart.get(r),i=n?OS(t.slice(1),n):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(L1);return e.validators.find(({validator:o})=>o(s))?.classGroupId},NS=/^\[(.+)\]$/,vG=t=>{if(NS.test(t)){const e=NS.exec(t)[1],r=e?.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},bG=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return wG(Object.entries(t.classGroups),r).forEach(([s,o])=>{k1(o,n,s,e)}),n},k1=(t,e,r,n)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:LS(e,i);s.classGroupId=r;return}if(typeof i=="function"){if(yG(i)){k1(i(n),e,r,n);return}e.validators.push({validator:i,classGroupId:r});return}Object.entries(i).forEach(([s,o])=>{k1(o,LS(e,s),r,n)})})},LS=(t,e)=>{let r=t;return e.split(L1).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},yG=t=>t.isThemeGetter,wG=(t,e)=>e?t.map(([r,n])=>{const i=n.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,a])=>[e+o,a])):s);return[r,i]}):t,xG=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const i=(s,o)=>{r.set(s,o),e++,e>t&&(e=0,n=r,r=new Map)};return{get(s){let o=r.get(s);if(o!==void 0)return o;if((o=n.get(s))!==void 0)return i(s,o),o},set(s,o){r.has(s)?r.set(s,o):i(s,o)}}},kS="!",_G=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,i=e[0],s=e.length,o=a=>{const f=[];let u=0,h=0,g;for(let D=0;Dh?g-h:void 0;return{modifiers:f,hasImportantModifier:x,baseClassName:S,maybePostfixModifierPosition:C}};return r?a=>r({className:a,parseClassName:o}):o},EG=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},SG=t=>({cache:xG(t.cacheSize),parseClassName:_G(t),...mG(t)}),AG=/\s+/,PG=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(AG);let a="";for(let f=o.length-1;f>=0;f-=1){const u=o[f],{modifiers:h,hasImportantModifier:g,baseClassName:b,maybePostfixModifierPosition:x}=r(u);let S=!!x,C=n(S?b.substring(0,x):b);if(!C){if(!S){a=u+(a.length>0?" "+a:a);continue}if(C=n(b),!C){a=u+(a.length>0?" "+a:a);continue}S=!1}const D=EG(h).join(":"),B=g?D+kS:D,L=B+C;if(s.includes(L))continue;s.push(L);const H=i(C,S);for(let F=0;F0?" "+a:a)}return a};function IG(){let t=0,e,r,n="";for(;t{if(typeof t=="string")return t;let e,r="";for(let n=0;ng(h),t());return r=SG(u),n=r.cache.get,i=r.cache.set,s=a,a(f)}function a(f){const u=n(f);if(u)return u;const h=PG(f,r);return i(f,h),h}return function(){return s(IG.apply(null,arguments))}}const Gr=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},FS=/^\[(?:([a-z-]+):)?(.+)\]$/i,CG=/^\d+\/\d+$/,RG=new Set(["px","full","screen"]),TG=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,DG=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,OG=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,NG=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,LG=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,oo=t=>Hc(t)||RG.has(t)||CG.test(t),Ho=t=>Wc(t,"length",zG),Hc=t=>!!t&&!Number.isNaN(Number(t)),B1=t=>Wc(t,"number",Hc),il=t=>!!t&&Number.isInteger(Number(t)),kG=t=>t.endsWith("%")&&Hc(t.slice(0,-1)),cr=t=>FS.test(t),Wo=t=>TG.test(t),BG=new Set(["length","size","percentage"]),FG=t=>Wc(t,BG,jS),jG=t=>Wc(t,"position",jS),UG=new Set(["image","url"]),$G=t=>Wc(t,UG,WG),qG=t=>Wc(t,"",HG),sl=()=>!0,Wc=(t,e,r)=>{const n=FS.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},zG=t=>DG.test(t)&&!OG.test(t),jS=()=>!1,HG=t=>NG.test(t),WG=t=>LG.test(t),KG=MG(()=>{const t=Gr("colors"),e=Gr("spacing"),r=Gr("blur"),n=Gr("brightness"),i=Gr("borderColor"),s=Gr("borderRadius"),o=Gr("borderSpacing"),a=Gr("borderWidth"),f=Gr("contrast"),u=Gr("grayscale"),h=Gr("hueRotate"),g=Gr("invert"),b=Gr("gap"),x=Gr("gradientColorStops"),S=Gr("gradientColorStopPositions"),C=Gr("inset"),D=Gr("margin"),B=Gr("opacity"),L=Gr("padding"),H=Gr("saturate"),F=Gr("scale"),k=Gr("sepia"),$=Gr("skew"),R=Gr("space"),W=Gr("translate"),V=()=>["auto","contain","none"],X=()=>["auto","hidden","clip","visible","scroll"],q=()=>["auto",cr,e],_=()=>[cr,e],v=()=>["",oo,Ho],l=()=>["auto",Hc,cr],p=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],m=()=>["solid","dashed","dotted","double","none"],y=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],A=()=>["start","end","center","between","around","evenly","stretch"],E=()=>["","0",cr],w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],I=()=>[Hc,cr];return{cacheSize:500,separator:":",theme:{colors:[sl],spacing:[oo,Ho],blur:["none","",Wo,cr],brightness:I(),borderColor:[t],borderRadius:["none","","full",Wo,cr],borderSpacing:_(),borderWidth:v(),contrast:I(),grayscale:E(),hueRotate:I(),invert:E(),gap:_(),gradientColorStops:[t],gradientColorStopPositions:[kG,Ho],inset:q(),margin:q(),opacity:I(),padding:_(),saturate:I(),scale:I(),sepia:E(),skew:I(),space:_(),translate:_()},classGroups:{aspect:[{aspect:["auto","square","video",cr]}],container:["container"],columns:[{columns:[Wo]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...p(),cr]}],overflow:[{overflow:X()}],"overflow-x":[{"overflow-x":X()}],"overflow-y":[{"overflow-y":X()}],overscroll:[{overscroll:V()}],"overscroll-x":[{"overscroll-x":V()}],"overscroll-y":[{"overscroll-y":V()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[C]}],"inset-x":[{"inset-x":[C]}],"inset-y":[{"inset-y":[C]}],start:[{start:[C]}],end:[{end:[C]}],top:[{top:[C]}],right:[{right:[C]}],bottom:[{bottom:[C]}],left:[{left:[C]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",il,cr]}],basis:[{basis:q()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",cr]}],grow:[{grow:E()}],shrink:[{shrink:E()}],order:[{order:["first","last","none",il,cr]}],"grid-cols":[{"grid-cols":[sl]}],"col-start-end":[{col:["auto",{span:["full",il,cr]},cr]}],"col-start":[{"col-start":l()}],"col-end":[{"col-end":l()}],"grid-rows":[{"grid-rows":[sl]}],"row-start-end":[{row:["auto",{span:[il,cr]},cr]}],"row-start":[{"row-start":l()}],"row-end":[{"row-end":l()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",cr]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",cr]}],gap:[{gap:[b]}],"gap-x":[{"gap-x":[b]}],"gap-y":[{"gap-y":[b]}],"justify-content":[{justify:["normal",...A()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...A(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...A(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[L]}],px:[{px:[L]}],py:[{py:[L]}],ps:[{ps:[L]}],pe:[{pe:[L]}],pt:[{pt:[L]}],pr:[{pr:[L]}],pb:[{pb:[L]}],pl:[{pl:[L]}],m:[{m:[D]}],mx:[{mx:[D]}],my:[{my:[D]}],ms:[{ms:[D]}],me:[{me:[D]}],mt:[{mt:[D]}],mr:[{mr:[D]}],mb:[{mb:[D]}],ml:[{ml:[D]}],"space-x":[{"space-x":[R]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[R]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",cr,e]}],"min-w":[{"min-w":[cr,e,"min","max","fit"]}],"max-w":[{"max-w":[cr,e,"none","full","min","max","fit","prose",{screen:[Wo]},Wo]}],h:[{h:[cr,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[cr,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[cr,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[cr,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Wo,Ho]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",B1]}],"font-family":[{font:[sl]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",cr]}],"line-clamp":[{"line-clamp":["none",Hc,B1]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",oo,cr]}],"list-image":[{"list-image":["none",cr]}],"list-style-type":[{list:["none","disc","decimal",cr]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[B]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[B]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...m(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",oo,Ho]}],"underline-offset":[{"underline-offset":["auto",oo,cr]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:_()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",cr]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",cr]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[B]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...p(),jG]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",FG]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},$G]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[S]}],"gradient-via-pos":[{via:[S]}],"gradient-to-pos":[{to:[S]}],"gradient-from":[{from:[x]}],"gradient-via":[{via:[x]}],"gradient-to":[{to:[x]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[B]}],"border-style":[{border:[...m(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[B]}],"divide-style":[{divide:m()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...m()]}],"outline-offset":[{"outline-offset":[oo,cr]}],"outline-w":[{outline:[oo,Ho]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:v()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[B]}],"ring-offset-w":[{"ring-offset":[oo,Ho]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Wo,qG]}],"shadow-color":[{shadow:[sl]}],opacity:[{opacity:[B]}],"mix-blend":[{"mix-blend":[...y(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":y()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[f]}],"drop-shadow":[{"drop-shadow":["","none",Wo,cr]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[h]}],invert:[{invert:[g]}],saturate:[{saturate:[H]}],sepia:[{sepia:[k]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[f]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[h]}],"backdrop-invert":[{"backdrop-invert":[g]}],"backdrop-opacity":[{"backdrop-opacity":[B]}],"backdrop-saturate":[{"backdrop-saturate":[H]}],"backdrop-sepia":[{"backdrop-sepia":[k]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",cr]}],duration:[{duration:I()}],ease:[{ease:["linear","in","out","in-out",cr]}],delay:[{delay:I()}],animate:[{animate:["none","spin","ping","pulse","bounce",cr]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[F]}],"scale-x":[{"scale-x":[F]}],"scale-y":[{"scale-y":[F]}],rotate:[{rotate:[il,cr]}],"translate-x":[{"translate-x":[W]}],"translate-y":[{"translate-y":[W]}],"skew-x":[{"skew-x":[$]}],"skew-y":[{"skew-y":[$]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",cr]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",cr]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":_()}],"scroll-mx":[{"scroll-mx":_()}],"scroll-my":[{"scroll-my":_()}],"scroll-ms":[{"scroll-ms":_()}],"scroll-me":[{"scroll-me":_()}],"scroll-mt":[{"scroll-mt":_()}],"scroll-mr":[{"scroll-mr":_()}],"scroll-mb":[{"scroll-mb":_()}],"scroll-ml":[{"scroll-ml":_()}],"scroll-p":[{"scroll-p":_()}],"scroll-px":[{"scroll-px":_()}],"scroll-py":[{"scroll-py":_()}],"scroll-ps":[{"scroll-ps":_()}],"scroll-pe":[{"scroll-pe":_()}],"scroll-pt":[{"scroll-pt":_()}],"scroll-pr":[{"scroll-pr":_()}],"scroll-pb":[{"scroll-pb":_()}],"scroll-pl":[{"scroll-pl":_()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",cr]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[oo,Ho,B1]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function ao(...t){return KG(gG(t))}function US(t){const{className:e}=t;return he.jsxs("div",{className:ao("xc-flex xc-items-center xc-gap-2"),children:[he.jsx("hr",{className:ao("xc-flex-1 xc-border-gray-200",e)}),he.jsx("div",{className:"xc-shrink-0",children:t.children}),he.jsx("hr",{className:ao("xc-flex-1 xc-border-gray-200",e)})]})}function VG(t){const{wallet:e,onClick:r}=t;return he.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center xc-justify-center xc-gap-4",children:[he.jsx("img",{className:"xc-rounded-md xc-h-16 xc-w-16",src:e.config?.image,alt:""}),he.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center",children:[he.jsxs("p",{className:"xc-text-danger xc-mb-2 xc-text-center",children:["Connect to ",e.config?.name]}),he.jsx("div",{className:"xc-flex xc-gap-2",children:he.jsx("button",{className:"xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1",onClick:()=>r(e),children:"Connect"})})]})]})}const GG="https://static.codatta.io/codatta-connect/wallet-icons.svg?v=2#ton";function YG(t){const{onClick:e}=t;function r(){e&&e()}return he.jsx(US,{className:"xc-opacity-20",children:he.jsxs("div",{className:"xc-flex xc-items-center xc-gap-2 xc-cursor-pointer",onClick:r,children:[he.jsx("span",{className:"xc-text-sm",children:"View more wallets"}),he.jsx(U4,{size:16})]})})}function $S(t){const[e,r]=Se.useState(""),{featuredWallets:n,initialized:i}=Hf(),{onEmailConfirm:s,onSelectWallet:o,onSelectMoreWallets:a,onSelectTonConnect:f,config:u,useSingleWallet:h}=t,g=Se.useMemo(()=>{const D=/[\u4e00-\u9fff]|[\u3400-\u4dbf]|[\u{20000}-\u{2a6df}]|[\u{2a700}-\u{2b73f}]|[\u{2b740}-\u{2b81f}]|[\u{2b820}-\u{2ceaf}]|[\uf900-\ufaff]|[\u3300-\u33ff]|[\ufe30-\ufe4f]/gu,B=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return!D.test(e)&&B.test(e)},[e]);function b(D){o(D)}function x(D){r(D.target.value)}async function S(){s(e)}function C(D){D.key==="Enter"&&g&&S()}return he.jsx(ls,{children:i&&he.jsxs(he.Fragment,{children:[t.header||he.jsx("div",{className:"xc-mb-6 xc-text-xl xc-font-bold",children:"Log in or sign up"}),n.length===1&&h?he.jsx("div",{className:"xc-mb-4 xc-flex xc-max-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar",children:n.map(D=>he.jsx(VG,{wallet:D,onClick:b},`feature-${D.key}`))}):he.jsxs(he.Fragment,{children:[he.jsxs("div",{children:[he.jsxs("div",{className:"xc-mb-4 xc-flex xc-max-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar",children:[u.showFeaturedWallets&&n&&n.map(D=>he.jsx(TS,{wallet:D,onClick:b},`feature-${D.key}`)),u.showTonConnect&&he.jsx(N1,{icon:he.jsx("img",{className:"xc-h-5 xc-w-5",src:GG}),title:"TON Connect",onClick:f})]}),u.showMoreWallets&&he.jsx(YG,{onClick:a})]}),u.showEmailSignIn&&(u.showFeaturedWallets||u.showTonConnect)&&he.jsx("div",{className:"xc-mb-4 xc-mt-4",children:he.jsxs(US,{className:"xc-opacity-20",children:[" ",he.jsx("span",{className:"xc-text-sm xc-opacity-20",children:"OR"})]})}),u.showEmailSignIn&&he.jsxs("div",{className:"xc-mb-4",children:[he.jsx("input",{className:"xc-w-full xc-bg-transparent xc-border-white xc-border xc-border-opacity-15 xc-h-10 xc-rounded-lg xc-px-3 xc-mb-3",placeholder:"Enter your email",type:"email",onChange:x,onKeyDown:C}),he.jsx("button",{disabled:!g,className:"xc-bg-[rgb(135,93,255)] xc-text-white xc-w-full xc-rounded-lg xc-py-2 disabled:xc-bg-opacity-10 disabled:xc-text-opacity-50 disabled:xc-bg-white xc-transition-all",onClick:S,children:"Continue"})]})]})]})})}function Wa(t){const{title:e}=t;return he.jsxs("div",{className:"xc-flex xc-items-center xc-gap-2",children:[he.jsx(Nz,{onClick:t.onBack,size:20,className:"xc-cursor-pointer"}),he.jsx("span",{children:e})]})}const qS=Se.createContext({channel:"",device:"WEB",app:"",inviterCode:"",role:"C"});function F1(){return Se.useContext(qS)}function JG(t){const{config:e}=t,[r,n]=Se.useState(e.channel),[i,s]=Se.useState(e.device),[o,a]=Se.useState(e.app),[f,u]=Se.useState(e.role||"C"),[h,g]=Se.useState(e.inviterCode);return Se.useEffect(()=>{n(e.channel),s(e.device),a(e.app),g(e.inviterCode),u(e.role||"C")},[e]),he.jsx(qS.Provider,{value:{channel:r,device:i,app:o,inviterCode:h,role:f},children:t.children})}var XG=Object.defineProperty,ZG=Object.defineProperties,QG=Object.getOwnPropertyDescriptors,qd=Object.getOwnPropertySymbols,zS=Object.prototype.hasOwnProperty,HS=Object.prototype.propertyIsEnumerable,WS=(t,e,r)=>e in t?XG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,eY=(t,e)=>{for(var r in e||(e={}))zS.call(e,r)&&WS(t,r,e[r]);if(qd)for(var r of qd(e))HS.call(e,r)&&WS(t,r,e[r]);return t},tY=(t,e)=>ZG(t,QG(e)),rY=(t,e)=>{var r={};for(var n in t)zS.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&qd)for(var n of qd(t))e.indexOf(n)<0&&HS.call(t,n)&&(r[n]=t[n]);return r};function nY(t){let e=setTimeout(t,0),r=setTimeout(t,10),n=setTimeout(t,50);return[e,r,n]}function iY(t){let e=Yt.useRef();return Yt.useEffect(()=>{e.current=t}),e.current}var sY=18,KS=40,oY=`${KS}px`,aY=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function cY({containerRef:t,inputRef:e,pushPasswordManagerStrategy:r,isFocused:n}){let[i,s]=Yt.useState(!1),[o,a]=Yt.useState(!1),[f,u]=Yt.useState(!1),h=Yt.useMemo(()=>r==="none"?!1:(r==="increase-width"||r==="experimental-no-flickering")&&i&&o,[i,o,r]),g=Yt.useCallback(()=>{let b=t.current,x=e.current;if(!b||!x||f||r==="none")return;let S=b,C=S.getBoundingClientRect().left+S.offsetWidth,D=S.getBoundingClientRect().top+S.offsetHeight/2,B=C-sY,L=D;document.querySelectorAll(aY).length===0&&document.elementFromPoint(B,L)===b||(s(!0),u(!0))},[t,e,f,r]);return Yt.useEffect(()=>{let b=t.current;if(!b||r==="none")return;function x(){let C=window.innerWidth-b.getBoundingClientRect().right;a(C>=KS)}x();let S=setInterval(x,1e3);return()=>{clearInterval(S)}},[t,r]),Yt.useEffect(()=>{let b=n||document.activeElement===e.current;if(r==="none"||!b)return;let x=setTimeout(g,0),S=setTimeout(g,2e3),C=setTimeout(g,5e3),D=setTimeout(()=>{u(!0)},6e3);return()=>{clearTimeout(x),clearTimeout(S),clearTimeout(C),clearTimeout(D)}},[e,n,r,g]),{hasPWMBadge:i,willPushPWMBadge:h,PWM_BADGE_SPACE_WIDTH:oY}}var VS=Yt.createContext({}),GS=Yt.forwardRef((t,e)=>{var r=t,{value:n,onChange:i,maxLength:s,textAlign:o="left",pattern:a,placeholder:f,inputMode:u="numeric",onComplete:h,pushPasswordManagerStrategy:g="increase-width",pasteTransformer:b,containerClassName:x,noScriptCSSFallback:S=uY,render:C,children:D}=r,B=rY(r,["value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","render","children"]),L,H,F,k,$;let[R,W]=Yt.useState(typeof B.defaultValue=="string"?B.defaultValue:""),V=n??R,X=iY(V),q=Yt.useCallback(ce=>{i?.(ce),W(ce)},[i]),_=Yt.useMemo(()=>a?typeof a=="string"?new RegExp(a):a:null,[a]),v=Yt.useRef(null),l=Yt.useRef(null),p=Yt.useRef({value:V,onChange:q,isIOS:typeof window<"u"&&((H=(L=window?.CSS)==null?void 0:L.supports)==null?void 0:H.call(L,"-webkit-touch-callout","none"))}),m=Yt.useRef({prev:[(F=v.current)==null?void 0:F.selectionStart,(k=v.current)==null?void 0:k.selectionEnd,($=v.current)==null?void 0:$.selectionDirection]});Yt.useImperativeHandle(e,()=>v.current,[]),Yt.useEffect(()=>{let ce=v.current,fe=l.current;if(!ce||!fe)return;p.current.value!==ce.value&&p.current.onChange(ce.value),m.current.prev=[ce.selectionStart,ce.selectionEnd,ce.selectionDirection];function be(){if(document.activeElement!==ce){M(null),se(null);return}let Te=ce.selectionStart,Fe=ce.selectionEnd,Me=ce.selectionDirection,Ne=ce.maxLength,He=ce.value,Oe=m.current.prev,$e=-1,qe=-1,_e;if(He.length!==0&&Te!==null&&Fe!==null){let nt=Te===Fe,it=Te===He.length&&He.length1&&He.length>1){let pt=0;if(Oe[0]!==null&&Oe[1]!==null){_e=Ye{fe&&fe.style.setProperty("--root-height",`${ce.clientHeight}px`)};Pe();let De=new ResizeObserver(Pe);return De.observe(ce),()=>{document.removeEventListener("selectionchange",be,{capture:!0}),De.disconnect()}},[]);let[y,A]=Yt.useState(!1),[E,w]=Yt.useState(!1),[I,M]=Yt.useState(null),[z,se]=Yt.useState(null);Yt.useEffect(()=>{nY(()=>{var ce,fe,be,Pe;(ce=v.current)==null||ce.dispatchEvent(new Event("input"));let De=(fe=v.current)==null?void 0:fe.selectionStart,Te=(be=v.current)==null?void 0:be.selectionEnd,Fe=(Pe=v.current)==null?void 0:Pe.selectionDirection;De!==null&&Te!==null&&(M(De),se(Te),m.current.prev=[De,Te,Fe])})},[V,E]),Yt.useEffect(()=>{X!==void 0&&V!==X&&X.length{let fe=ce.currentTarget.value.slice(0,s);if(fe.length>0&&_&&!_.test(fe)){ce.preventDefault();return}typeof X=="string"&&fe.length{var ce;if(v.current){let fe=Math.min(v.current.value.length,s-1),be=v.current.value.length;(ce=v.current)==null||ce.setSelectionRange(fe,be),M(fe),se(be)}w(!0)},[s]),Z=Yt.useCallback(ce=>{var fe,be;let Pe=v.current;if(!b&&(!p.current.isIOS||!ce.clipboardData||!Pe))return;let De=ce.clipboardData.getData("text/plain"),Te=b?b(De):De;console.log({_content:De,content:Te}),ce.preventDefault();let Fe=(fe=v.current)==null?void 0:fe.selectionStart,Me=(be=v.current)==null?void 0:be.selectionEnd,Ne=(Fe!==Me?V.slice(0,Fe)+Te+V.slice(Me):V.slice(0,Fe)+Te+V.slice(Fe)).slice(0,s);if(Ne.length>0&&_&&!_.test(Ne))return;Pe.value=Ne,q(Ne);let He=Math.min(Ne.length,s-1),Oe=Ne.length;Pe.setSelectionRange(He,Oe),M(He),se(Oe)},[s,q,_,V]),te=Yt.useMemo(()=>({position:"relative",cursor:B.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[B.disabled]),N=Yt.useMemo(()=>({position:"absolute",inset:0,width:O.willPushPWMBadge?`calc(100% + ${O.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:O.willPushPWMBadge?`inset(0 ${O.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:o,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[O.PWM_BADGE_SPACE_WIDTH,O.willPushPWMBadge,o]),Q=Yt.useMemo(()=>Yt.createElement("input",tY(eY({autoComplete:B.autoComplete||"one-time-code"},B),{"data-input-otp":!0,"data-input-otp-placeholder-shown":V.length===0||void 0,"data-input-otp-mss":I,"data-input-otp-mse":z,inputMode:u,pattern:_?.source,"aria-placeholder":f,style:N,maxLength:s,value:V,ref:v,onPaste:ce=>{var fe;Z(ce),(fe=B.onPaste)==null||fe.call(B,ce)},onChange:ie,onMouseOver:ce=>{var fe;A(!0),(fe=B.onMouseOver)==null||fe.call(B,ce)},onMouseLeave:ce=>{var fe;A(!1),(fe=B.onMouseLeave)==null||fe.call(B,ce)},onFocus:ce=>{var fe;ee(),(fe=B.onFocus)==null||fe.call(B,ce)},onBlur:ce=>{var fe;w(!1),(fe=B.onBlur)==null||fe.call(B,ce)}})),[ie,ee,Z,u,N,s,z,I,B,_?.source,V]),ne=Yt.useMemo(()=>({slots:Array.from({length:s}).map((ce,fe)=>{var be;let Pe=E&&I!==null&&z!==null&&(I===z&&fe===I||fe>=I&&feC?C(ne):Yt.createElement(VS.Provider,{value:ne},D),[D,ne,C]);return Yt.createElement(Yt.Fragment,null,S!==null&&Yt.createElement("noscript",null,Yt.createElement("style",null,S)),Yt.createElement("div",{ref:l,"data-input-otp-container":!0,style:te,className:x},de,Yt.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},Q)))});GS.displayName="Input";function ol(t,e){try{t.insertRule(e)}catch{console.error("input-otp could not insert CSS rule:",e)}}var uY=` [data-input-otp] { --nojs-bg: white !important; --nojs-fg: black !important; @@ -213,30 +218,30 @@ Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opene --nojs-bg: black !important; --nojs-fg: white !important; } -}`;const g7=Yt.forwardRef(({className:t,containerClassName:e,...r},n)=>me.jsx(p7,{ref:n,containerClassName:$o("xc-flex xc-items-center xc-gap-2 xc-has-[:disabled]:opacity-50",e),className:$o("disabled:xc-cursor-not-allowed",t),...r}));g7.displayName="InputOTP";const m7=Yt.forwardRef(({className:t,...e},r)=>me.jsx("div",{ref:r,className:$o("xc-flex xc-items-center",t),...e}));m7.displayName="InputOTPGroup";const Sc=Yt.forwardRef(({index:t,className:e,...r},n)=>{const i=Yt.useContext(d7),{char:s,hasFakeCaret:o,isActive:a}=i.slots[t];return me.jsxs("div",{ref:n,className:$o("xc-relative xc-rounded-xl xc-text-2xl xc-flex xc-h-12 xc-w-12 xc-items-center xc-justify-center xc-border xc-border-white xc-border-opacity-20 xc-transition-all",a&&"xc-z-10 xc-ring-2 xc-ring-ring xc-ring-[rgb(135,93,255)] xc-ring-offset-background",e),...r,children:[s,o&&me.jsx("div",{className:"xc-pointer-events-none xc-absolute xc-inset-0 xc-flex xc-items-center xc-justify-center",children:me.jsx("div",{className:"xc-h-4 xc-w-px xc-animate-caret-blink xc-bg-foreground xc-duration-1000"})})]})});Sc.displayName="InputOTPSlot";function JX(t){const{spinning:e,children:r,className:n}=t;return me.jsxs("div",{className:"xc-inline-block xc-relative",children:[r,e&&me.jsx("div",{className:$o("xc-absolute xc-top-0 xc-left-0 xc-w-full xc-h-full xc-bg-black xc-bg-opacity-10 xc-flex xc-items-center xc-justify-center",n),children:me.jsx(mc,{className:"xc-animate-spin"})})]})}const v7=Pe.createContext({channel:"",device:"WEB",app:"",inviterCode:""});function Pb(){return Pe.useContext(v7)}function XX(t){const{config:e}=t,[r,n]=Pe.useState(e.channel),[i,s]=Pe.useState(e.device),[o,a]=Pe.useState(e.app),[u,l]=Pe.useState(e.inviterCode);return Pe.useEffect(()=>{n(e.channel),s(e.device),a(e.app),l(e.inviterCode)},[e]),me.jsx(v7.Provider,{value:{channel:r,device:i,app:o,inviterCode:u},children:t.children})}function ZX(t){const{email:e}=t,[r,n]=Pe.useState(0),[i,s]=Pe.useState(!1),[o,a]=Pe.useState(!1),[u,l]=Pe.useState(""),[d,g]=Pe.useState(""),y=Pb();async function A(){n(60);const D=setInterval(()=>{n(k=>k===0?(clearInterval(D),0):k-1)},1e3)}async function P(D){a(!0);try{l(""),await ma.getEmailCode({account_type:"email",email:D}),A()}catch(k){l(k.message)}a(!1)}Pe.useEffect(()=>{e&&P(e)},[e]);async function N(D){if(g(""),!(D.length<6)){s(!0);try{const k=await ma.emailLogin({account_type:"email",connector:"codatta_email",account_enum:"C",email_code:D,email:e,inviter_code:y.inviterCode,source:{device:y.device,channel:y.channel,app:y.app}});t.onLogin(k.data)}catch(k){g(k.message)}s(!1)}}return me.jsxs(Ec,{children:[me.jsx("div",{className:"xc-mb-12",children:me.jsx(ah,{title:"Sign in with email",onBack:t.onBack})}),me.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-12",children:[me.jsx(IK,{className:"xc-mb-4",size:60}),me.jsx("div",{className:"xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-8 xc-h-16",children:u?me.jsx("div",{className:"xc-text-[#ff0000] xc-text-center",children:me.jsx("p",{className:"xc-px-8",children:u})}):o?me.jsx(mc,{className:"xc-animate-spin"}):me.jsxs(me.Fragment,{children:[me.jsx("p",{className:"xc-text-lg xc-mb-1",children:"We’ve sent a verification code to"}),me.jsx("p",{className:"xc-font-bold xc-text-center",children:e})]})}),me.jsx("div",{className:"xc-mb-2 xc-h-12",children:me.jsx(JX,{spinning:i,className:"xc-rounded-xl",children:me.jsx(g7,{maxLength:6,onChange:N,disabled:i,className:"disabled:xc-opacity-20",children:me.jsx(m7,{children:me.jsxs("div",{className:$o("xc-flex xc-gap-2",i?"xc-opacity-20":""),children:[me.jsx(Sc,{index:0}),me.jsx(Sc,{index:1}),me.jsx(Sc,{index:2}),me.jsx(Sc,{index:3}),me.jsx(Sc,{index:4}),me.jsx(Sc,{index:5})]})})})})}),d&&me.jsx("div",{className:"xc-text-[#ff0000] xc-text-center",children:me.jsx("p",{children:d})})]}),me.jsxs("div",{className:"xc-text-center xc-text-sm xc-text-gray-400",children:["Not get it? ",r?`Recend in ${r}s`:me.jsx("button",{onClick:()=>P(e),children:"Send again"})]})]})}var b7={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(nn,()=>(()=>{var r={873:(o,a)=>{var u,l,d=function(){var g=function(f,p){var v=f,x=k[p],_=null,S=0,b=null,M=[],I={},F=function(te,le){_=function(ie){for(var fe=new Array(ie),ve=0;ve=7&&ee(te),b==null&&(b=R(v,x,M)),Q(b,le)},ae=function(te,le){for(var ie=-1;ie<=7;ie+=1)if(!(te+ie<=-1||S<=te+ie))for(var fe=-1;fe<=7;fe+=1)le+fe<=-1||S<=le+fe||(_[te+ie][le+fe]=0<=ie&&ie<=6&&(fe==0||fe==6)||0<=fe&&fe<=6&&(ie==0||ie==6)||2<=ie&&ie<=4&&2<=fe&&fe<=4)},O=function(){for(var te=8;te>ie&1)==1;_[Math.floor(ie/3)][ie%3+S-8-3]=fe}for(ie=0;ie<18;ie+=1)fe=!te&&(le>>ie&1)==1,_[ie%3+S-8-3][Math.floor(ie/3)]=fe},X=function(te,le){for(var ie=x<<3|le,fe=$.getBCHTypeInfo(ie),ve=0;ve<15;ve+=1){var Me=!te&&(fe>>ve&1)==1;ve<6?_[ve][8]=Me:ve<8?_[ve+1][8]=Me:_[S-15+ve][8]=Me}for(ve=0;ve<15;ve+=1)Me=!te&&(fe>>ve&1)==1,ve<8?_[8][S-ve-1]=Me:ve<9?_[8][15-ve-1+1]=Me:_[8][15-ve-1]=Me;_[S-8][8]=!te},Q=function(te,le){for(var ie=-1,fe=S-1,ve=7,Me=0,Ne=$.getMaskFunction(le),Te=S-1;Te>0;Te-=2)for(Te==6&&(Te-=1);;){for(var Be=0;Be<2;Be+=1)if(_[fe][Te-Be]==null){var Ie=!1;Me>>ve&1)==1),Ne(fe,Te-Be)&&(Ie=!Ie),_[fe][Te-Be]=Ie,(ve-=1)==-1&&(Me+=1,ve=7)}if((fe+=ie)<0||S<=fe){fe-=ie,ie=-ie;break}}},R=function(te,le,ie){for(var fe=K.getRSBlocks(te,le),ve=J(),Me=0;Me8*Te)throw"code length overflow. ("+ve.getLengthInBits()+">"+8*Te+")";for(ve.getLengthInBits()+4<=8*Te&&ve.put(0,4);ve.getLengthInBits()%8!=0;)ve.putBit(!1);for(;!(ve.getLengthInBits()>=8*Te||(ve.put(236,8),ve.getLengthInBits()>=8*Te));)ve.put(17,8);return function(Be,Ie){for(var Le=0,Ve=0,ke=0,ze=new Array(Ie.length),He=new Array(Ie.length),Ee=0;Ee=0?rt.getAt(Je):0}}var pt=0;for($e=0;$eIe)&&(Ne=Ie,Te=Be)}return Te}())},I.createTableTag=function(te,le){te=te||2;var ie="";ie+='";for(var ve=0;ve';ie+=""}return(ie+="")+"
"},I.createSvgTag=function(te,le,ie,fe){var ve={};typeof arguments[0]=="object"&&(te=(ve=arguments[0]).cellSize,le=ve.margin,ie=ve.alt,fe=ve.title),te=te||2,le=le===void 0?4*te:le,(ie=typeof ie=="string"?{text:ie}:ie||{}).text=ie.text||null,ie.id=ie.text?ie.id||"qrcode-description":null,(fe=typeof fe=="string"?{text:fe}:fe||{}).text=fe.text||null,fe.id=fe.text?fe.id||"qrcode-title":null;var Me,Ne,Te,Be,Ie=I.getModuleCount()*te+2*le,Le="";for(Be="l"+te+",0 0,"+te+" -"+te+",0 0,-"+te+"z ",Le+=''+Z(fe.text)+"":"",Le+=ie.text?''+Z(ie.text)+"":"",Le+='',Le+='"},I.createDataURL=function(te,le){te=te||2,le=le===void 0?4*te:le;var ie=I.getModuleCount()*te+2*le,fe=le,ve=ie-le;return m(ie,ie,function(Me,Ne){if(fe<=Me&&Me"};var Z=function(te){for(var le="",ie=0;ie":le+=">";break;case"&":le+="&";break;case'"':le+=""";break;default:le+=fe}}return le};return I.createASCII=function(te,le){if((te=te||1)<2)return function(ze){ze=ze===void 0?2:ze;var He,Ee,Qe,ct,$e,et=1*I.getModuleCount()+2*ze,rt=ze,Je=et-ze,pt={"██":"█","█ ":"▀"," █":"▄"," ":" "},ht={"██":"▀","█ ":"▀"," █":" "," ":" "},ft="";for(He=0;He=Je?ht[$e]:pt[$e];ft+=` -`}return et%2&&ze>0?ft.substring(0,ft.length-et-1)+Array(et+1).join("▀"):ft.substring(0,ft.length-1)}(le);te-=1,le=le===void 0?2*te:le;var ie,fe,ve,Me,Ne=I.getModuleCount()*te+2*le,Te=le,Be=Ne-le,Ie=Array(te+1).join("██"),Le=Array(te+1).join(" "),Ve="",ke="";for(ie=0;ie>>8),S.push(255&I)):S.push(x)}}return S}};var y,A,P,N,D,k={L:1,M:0,Q:3,H:2},$=(y=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],A=1335,P=7973,D=function(f){for(var p=0;f!=0;)p+=1,f>>>=1;return p},(N={}).getBCHTypeInfo=function(f){for(var p=f<<10;D(p)-D(A)>=0;)p^=A<=0;)p^=P<5&&(v+=3+S-5)}for(x=0;x=256;)x-=255;return f[x]}}}();function U(f,p){if(f.length===void 0)throw f.length+"/"+p;var v=function(){for(var _=0;_>>7-x%8&1)==1},put:function(x,_){for(var S=0;S<_;S+=1)v.putBit((x>>>_-S-1&1)==1)},getLengthInBits:function(){return p},putBit:function(x){var _=Math.floor(p/8);f.length<=_&&f.push(0),x&&(f[_]|=128>>>p%8),p+=1}};return v},T=function(f){var p=f,v={getMode:function(){return 1},getLength:function(S){return p.length},write:function(S){for(var b=p,M=0;M+2>>8&255)+(255&M),_.put(M,13),b+=2}if(b>>8)},writeBytes:function(v,x,_){x=x||0,_=_||v.length;for(var S=0;S<_;S+=1)p.writeByte(v[S+x])},writeString:function(v){for(var x=0;x0&&(v+=","),v+=f[x];return v+"]"}};return p},E=function(f){var p=f,v=0,x=0,_=0,S={read:function(){for(;_<8;){if(v>=p.length){if(_==0)return-1;throw"unexpected end of file./"+_}var M=p.charAt(v);if(v+=1,M=="=")return _=0,-1;M.match(/^\s$/)||(x=x<<6|b(M.charCodeAt(0)),_+=6)}var I=x>>>_-8&255;return _-=8,I}},b=function(M){if(65<=M&&M<=90)return M-65;if(97<=M&&M<=122)return M-97+26;if(48<=M&&M<=57)return M-48+52;if(M==43)return 62;if(M==47)return 63;throw"c:"+M};return S},m=function(f,p,v){for(var x=function(ae,O){var se=ae,ee=O,X=new Array(ae*O),Q={setPixel:function(te,le,ie){X[le*se+te]=ie},write:function(te){te.writeString("GIF87a"),te.writeShort(se),te.writeShort(ee),te.writeByte(128),te.writeByte(0),te.writeByte(0),te.writeByte(0),te.writeByte(0),te.writeByte(0),te.writeByte(255),te.writeByte(255),te.writeByte(255),te.writeString(","),te.writeShort(0),te.writeShort(0),te.writeShort(se),te.writeShort(ee),te.writeByte(0);var le=R(2);te.writeByte(2);for(var ie=0;le.length-ie>255;)te.writeByte(255),te.writeBytes(le,ie,255),ie+=255;te.writeByte(le.length-ie),te.writeBytes(le,ie,le.length-ie),te.writeByte(0),te.writeString(";")}},R=function(te){for(var le=1<>>Ee)throw"length over";for(;Te+Ee>=8;)Ne.writeByte(255&(He<>>=8-Te,Be=0,Te=0;Be|=He<0&&Ne.writeByte(Be)}});Le.write(le,fe);var Ve=0,ke=String.fromCharCode(X[Ve]);for(Ve+=1;Ve=6;)Q(ae>>>O-6),O-=6},X.flush=function(){if(O>0&&(Q(ae<<6-O),ae=0,O=0),se%3!=0)for(var Z=3-se%3,te=0;te>6,128|63&N):N<55296||N>=57344?A.push(224|N>>12,128|N>>6&63,128|63&N):(P++,N=65536+((1023&N)<<10|1023&y.charCodeAt(P)),A.push(240|N>>18,128|N>>12&63,128|N>>6&63,128|63&N))}return A}(g)},(l=typeof(u=function(){return d})=="function"?u.apply(a,[]):u)===void 0||(o.exports=l)}},n={};function i(o){var a=n[o];if(a!==void 0)return a.exports;var u=n[o]={exports:{}};return r[o](u,u.exports,i),u.exports}i.n=o=>{var a=o&&o.__esModule?()=>o.default:()=>o;return i.d(a,{a}),a},i.d=(o,a)=>{for(var u in a)i.o(a,u)&&!i.o(o,u)&&Object.defineProperty(o,u,{enumerable:!0,get:a[u]})},i.o=(o,a)=>Object.prototype.hasOwnProperty.call(o,a);var s={};return(()=>{i.d(s,{default:()=>G});const o=E=>!!E&&typeof E=="object"&&!Array.isArray(E);function a(E,...m){if(!m.length)return E;const f=m.shift();return f!==void 0&&o(E)&&o(f)?(E=Object.assign({},E),Object.keys(f).forEach(p=>{const v=E[p],x=f[p];Array.isArray(v)&&Array.isArray(x)?E[p]=x:o(v)&&o(x)?E[p]=a(Object.assign({},v),x):E[p]=x}),a(E,...m)):E}function u(E,m){const f=document.createElement("a");f.download=m,f.href=E,document.body.appendChild(f),f.click(),document.body.removeChild(f)}const l={L:.07,M:.15,Q:.25,H:.3};class d{constructor({svg:m,type:f,window:p}){this._svg=m,this._type=f,this._window=p}draw(m,f,p,v){let x;switch(this._type){case"dots":x=this._drawDot;break;case"classy":x=this._drawClassy;break;case"classy-rounded":x=this._drawClassyRounded;break;case"rounded":x=this._drawRounded;break;case"extra-rounded":x=this._drawExtraRounded;break;default:x=this._drawSquare}x.call(this,{x:m,y:f,size:p,getNeighbor:v})}_rotateFigure({x:m,y:f,size:p,rotation:v=0,draw:x}){var _;const S=m+p/2,b=f+p/2;x(),(_=this._element)===null||_===void 0||_.setAttribute("transform",`rotate(${180*v/Math.PI},${S},${b})`)}_basicDot(m){const{size:f,x:p,y:v}=m;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",String(p+f/2)),this._element.setAttribute("cy",String(v+f/2)),this._element.setAttribute("r",String(f/2))}}))}_basicSquare(m){const{size:f,x:p,y:v}=m;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",String(p)),this._element.setAttribute("y",String(v)),this._element.setAttribute("width",String(f)),this._element.setAttribute("height",String(f))}}))}_basicSideRounded(m){const{size:f,x:p,y:v}=m;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${p} ${v}v ${f}h `+f/2+`a ${f/2} ${f/2}, 0, 0, 0, 0 ${-f}`)}}))}_basicCornerRounded(m){const{size:f,x:p,y:v}=m;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${p} ${v}v ${f}h ${f}v `+-f/2+`a ${f/2} ${f/2}, 0, 0, 0, ${-f/2} ${-f/2}`)}}))}_basicCornerExtraRounded(m){const{size:f,x:p,y:v}=m;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${p} ${v}v ${f}h ${f}a ${f} ${f}, 0, 0, 0, ${-f} ${-f}`)}}))}_basicCornersRounded(m){const{size:f,x:p,y:v}=m;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${p} ${v}v `+f/2+`a ${f/2} ${f/2}, 0, 0, 0, ${f/2} ${f/2}h `+f/2+"v "+-f/2+`a ${f/2} ${f/2}, 0, 0, 0, ${-f/2} ${-f/2}`)}}))}_drawDot({x:m,y:f,size:p}){this._basicDot({x:m,y:f,size:p,rotation:0})}_drawSquare({x:m,y:f,size:p}){this._basicSquare({x:m,y:f,size:p,rotation:0})}_drawRounded({x:m,y:f,size:p,getNeighbor:v}){const x=v?+v(-1,0):0,_=v?+v(1,0):0,S=v?+v(0,-1):0,b=v?+v(0,1):0,M=x+_+S+b;if(M!==0)if(M>2||x&&_||S&&b)this._basicSquare({x:m,y:f,size:p,rotation:0});else{if(M===2){let I=0;return x&&S?I=Math.PI/2:S&&_?I=Math.PI:_&&b&&(I=-Math.PI/2),void this._basicCornerRounded({x:m,y:f,size:p,rotation:I})}if(M===1){let I=0;return S?I=Math.PI/2:_?I=Math.PI:b&&(I=-Math.PI/2),void this._basicSideRounded({x:m,y:f,size:p,rotation:I})}}else this._basicDot({x:m,y:f,size:p,rotation:0})}_drawExtraRounded({x:m,y:f,size:p,getNeighbor:v}){const x=v?+v(-1,0):0,_=v?+v(1,0):0,S=v?+v(0,-1):0,b=v?+v(0,1):0,M=x+_+S+b;if(M!==0)if(M>2||x&&_||S&&b)this._basicSquare({x:m,y:f,size:p,rotation:0});else{if(M===2){let I=0;return x&&S?I=Math.PI/2:S&&_?I=Math.PI:_&&b&&(I=-Math.PI/2),void this._basicCornerExtraRounded({x:m,y:f,size:p,rotation:I})}if(M===1){let I=0;return S?I=Math.PI/2:_?I=Math.PI:b&&(I=-Math.PI/2),void this._basicSideRounded({x:m,y:f,size:p,rotation:I})}}else this._basicDot({x:m,y:f,size:p,rotation:0})}_drawClassy({x:m,y:f,size:p,getNeighbor:v}){const x=v?+v(-1,0):0,_=v?+v(1,0):0,S=v?+v(0,-1):0,b=v?+v(0,1):0;x+_+S+b!==0?x||S?_||b?this._basicSquare({x:m,y:f,size:p,rotation:0}):this._basicCornerRounded({x:m,y:f,size:p,rotation:Math.PI/2}):this._basicCornerRounded({x:m,y:f,size:p,rotation:-Math.PI/2}):this._basicCornersRounded({x:m,y:f,size:p,rotation:Math.PI/2})}_drawClassyRounded({x:m,y:f,size:p,getNeighbor:v}){const x=v?+v(-1,0):0,_=v?+v(1,0):0,S=v?+v(0,-1):0,b=v?+v(0,1):0;x+_+S+b!==0?x||S?_||b?this._basicSquare({x:m,y:f,size:p,rotation:0}):this._basicCornerExtraRounded({x:m,y:f,size:p,rotation:Math.PI/2}):this._basicCornerExtraRounded({x:m,y:f,size:p,rotation:-Math.PI/2}):this._basicCornersRounded({x:m,y:f,size:p,rotation:Math.PI/2})}}class g{constructor({svg:m,type:f,window:p}){this._svg=m,this._type=f,this._window=p}draw(m,f,p,v){let x;switch(this._type){case"square":x=this._drawSquare;break;case"extra-rounded":x=this._drawExtraRounded;break;default:x=this._drawDot}x.call(this,{x:m,y:f,size:p,rotation:v})}_rotateFigure({x:m,y:f,size:p,rotation:v=0,draw:x}){var _;const S=m+p/2,b=f+p/2;x(),(_=this._element)===null||_===void 0||_.setAttribute("transform",`rotate(${180*v/Math.PI},${S},${b})`)}_basicDot(m){const{size:f,x:p,y:v}=m,x=f/7;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${p+f/2} ${v}a ${f/2} ${f/2} 0 1 0 0.1 0zm 0 ${x}a ${f/2-x} ${f/2-x} 0 1 1 -0.1 0Z`)}}))}_basicSquare(m){const{size:f,x:p,y:v}=m,x=f/7;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${p} ${v}v ${f}h ${f}v `+-f+`zM ${p+x} ${v+x}h `+(f-2*x)+"v "+(f-2*x)+"h "+(2*x-f)+"z")}}))}_basicExtraRounded(m){const{size:f,x:p,y:v}=m,x=f/7;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${p} ${v+2.5*x}v `+2*x+`a ${2.5*x} ${2.5*x}, 0, 0, 0, ${2.5*x} ${2.5*x}h `+2*x+`a ${2.5*x} ${2.5*x}, 0, 0, 0, ${2.5*x} ${2.5*-x}v `+-2*x+`a ${2.5*x} ${2.5*x}, 0, 0, 0, ${2.5*-x} ${2.5*-x}h `+-2*x+`a ${2.5*x} ${2.5*x}, 0, 0, 0, ${2.5*-x} ${2.5*x}M ${p+2.5*x} ${v+x}h `+2*x+`a ${1.5*x} ${1.5*x}, 0, 0, 1, ${1.5*x} ${1.5*x}v `+2*x+`a ${1.5*x} ${1.5*x}, 0, 0, 1, ${1.5*-x} ${1.5*x}h `+-2*x+`a ${1.5*x} ${1.5*x}, 0, 0, 1, ${1.5*-x} ${1.5*-x}v `+-2*x+`a ${1.5*x} ${1.5*x}, 0, 0, 1, ${1.5*x} ${1.5*-x}`)}}))}_drawDot({x:m,y:f,size:p,rotation:v}){this._basicDot({x:m,y:f,size:p,rotation:v})}_drawSquare({x:m,y:f,size:p,rotation:v}){this._basicSquare({x:m,y:f,size:p,rotation:v})}_drawExtraRounded({x:m,y:f,size:p,rotation:v}){this._basicExtraRounded({x:m,y:f,size:p,rotation:v})}}class y{constructor({svg:m,type:f,window:p}){this._svg=m,this._type=f,this._window=p}draw(m,f,p,v){let x;x=this._type==="square"?this._drawSquare:this._drawDot,x.call(this,{x:m,y:f,size:p,rotation:v})}_rotateFigure({x:m,y:f,size:p,rotation:v=0,draw:x}){var _;const S=m+p/2,b=f+p/2;x(),(_=this._element)===null||_===void 0||_.setAttribute("transform",`rotate(${180*v/Math.PI},${S},${b})`)}_basicDot(m){const{size:f,x:p,y:v}=m;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",String(p+f/2)),this._element.setAttribute("cy",String(v+f/2)),this._element.setAttribute("r",String(f/2))}}))}_basicSquare(m){const{size:f,x:p,y:v}=m;this._rotateFigure(Object.assign(Object.assign({},m),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",String(p)),this._element.setAttribute("y",String(v)),this._element.setAttribute("width",String(f)),this._element.setAttribute("height",String(f))}}))}_drawDot({x:m,y:f,size:p,rotation:v}){this._basicDot({x:m,y:f,size:p,rotation:v})}_drawSquare({x:m,y:f,size:p,rotation:v}){this._basicSquare({x:m,y:f,size:p,rotation:v})}}const A="circle",P=[[1,1,1,1,1,1,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,1,1,1,1,1,1]],N=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]];class D{constructor(m,f){this._roundSize=p=>this._options.dotsOptions.roundSize?Math.floor(p):p,this._window=f,this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","svg"),this._element.setAttribute("width",String(m.width)),this._element.setAttribute("height",String(m.height)),this._element.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),m.dotsOptions.roundSize||this._element.setAttribute("shape-rendering","crispEdges"),this._element.setAttribute("viewBox",`0 0 ${m.width} ${m.height}`),this._defs=this._window.document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this._defs),this._imageUri=m.image,this._instanceId=D.instanceCount++,this._options=m}get width(){return this._options.width}get height(){return this._options.height}getElement(){return this._element}async drawQR(m){const f=m.getModuleCount(),p=Math.min(this._options.width,this._options.height)-2*this._options.margin,v=this._options.shape===A?p/Math.sqrt(2):p,x=this._roundSize(v/f);let _={hideXDots:0,hideYDots:0,width:0,height:0};if(this._qr=m,this._options.image){if(await this.loadImage(),!this._image)return;const{imageOptions:S,qrOptions:b}=this._options,M=S.imageSize*l[b.errorCorrectionLevel],I=Math.floor(M*f*f);_=function({originalHeight:F,originalWidth:ae,maxHiddenDots:O,maxHiddenAxisDots:se,dotSize:ee}){const X={x:0,y:0},Q={x:0,y:0};if(F<=0||ae<=0||O<=0||ee<=0)return{height:0,width:0,hideYDots:0,hideXDots:0};const R=F/ae;return X.x=Math.floor(Math.sqrt(O/R)),X.x<=0&&(X.x=1),se&&seO||se&&se{var M,I,F,ae,O,se;return!(this._options.imageOptions.hideBackgroundDots&&S>=(f-_.hideYDots)/2&&S<(f+_.hideYDots)/2&&b>=(f-_.hideXDots)/2&&b<(f+_.hideXDots)/2||!((M=P[S])===null||M===void 0)&&M[b]||!((I=P[S-f+7])===null||I===void 0)&&I[b]||!((F=P[S])===null||F===void 0)&&F[b-f+7]||!((ae=N[S])===null||ae===void 0)&&ae[b]||!((O=N[S-f+7])===null||O===void 0)&&O[b]||!((se=N[S])===null||se===void 0)&&se[b-f+7])}),this.drawCorners(),this._options.image&&await this.drawImage({width:_.width,height:_.height,count:f,dotSize:x})}drawBackground(){var m,f,p;const v=this._element,x=this._options;if(v){const _=(m=x.backgroundOptions)===null||m===void 0?void 0:m.gradient,S=(f=x.backgroundOptions)===null||f===void 0?void 0:f.color;let b=x.height,M=x.width;if(_||S){const I=this._window.document.createElementNS("http://www.w3.org/2000/svg","rect");this._backgroundClipPath=this._window.document.createElementNS("http://www.w3.org/2000/svg","clipPath"),this._backgroundClipPath.setAttribute("id",`clip-path-background-color-${this._instanceId}`),this._defs.appendChild(this._backgroundClipPath),!((p=x.backgroundOptions)===null||p===void 0)&&p.round&&(b=M=Math.min(x.width,x.height),I.setAttribute("rx",String(b/2*x.backgroundOptions.round))),I.setAttribute("x",String(this._roundSize((x.width-M)/2))),I.setAttribute("y",String(this._roundSize((x.height-b)/2))),I.setAttribute("width",String(M)),I.setAttribute("height",String(b)),this._backgroundClipPath.appendChild(I),this._createColor({options:_,color:S,additionalRotation:0,x:0,y:0,height:x.height,width:x.width,name:`background-color-${this._instanceId}`})}}}drawDots(m){var f,p;if(!this._qr)throw"QR code is not defined";const v=this._options,x=this._qr.getModuleCount();if(x>v.width||x>v.height)throw"The canvas is too small.";const _=Math.min(v.width,v.height)-2*v.margin,S=v.shape===A?_/Math.sqrt(2):_,b=this._roundSize(S/x),M=this._roundSize((v.width-x*b)/2),I=this._roundSize((v.height-x*b)/2),F=new d({svg:this._element,type:v.dotsOptions.type,window:this._window});this._dotsClipPath=this._window.document.createElementNS("http://www.w3.org/2000/svg","clipPath"),this._dotsClipPath.setAttribute("id",`clip-path-dot-color-${this._instanceId}`),this._defs.appendChild(this._dotsClipPath),this._createColor({options:(f=v.dotsOptions)===null||f===void 0?void 0:f.gradient,color:v.dotsOptions.color,additionalRotation:0,x:0,y:0,height:v.height,width:v.width,name:`dot-color-${this._instanceId}`});for(let ae=0;ae!(O+se<0||ae+ee<0||O+se>=x||ae+ee>=x)&&!(m&&!m(ae+ee,O+se))&&!!this._qr&&this._qr.isDark(ae+ee,O+se)),F._element&&this._dotsClipPath&&this._dotsClipPath.appendChild(F._element));if(v.shape===A){const ae=this._roundSize((_/b-x)/2),O=x+2*ae,se=M-ae*b,ee=I-ae*b,X=[],Q=this._roundSize(O/2);for(let R=0;R=ae-1&&R<=O-ae&&Z>=ae-1&&Z<=O-ae||Math.sqrt((R-Q)*(R-Q)+(Z-Q)*(Z-Q))>Q?X[R][Z]=0:X[R][Z]=this._qr.isDark(Z-2*ae<0?Z:Z>=x?Z-2*ae:Z-ae,R-2*ae<0?R:R>=x?R-2*ae:R-ae)?1:0}for(let R=0;R{var ie;return!!(!((ie=X[R+le])===null||ie===void 0)&&ie[Z+te])}),F._element&&this._dotsClipPath&&this._dotsClipPath.appendChild(F._element))}}drawCorners(){if(!this._qr)throw"QR code is not defined";const m=this._element,f=this._options;if(!m)throw"Element code is not defined";const p=this._qr.getModuleCount(),v=Math.min(f.width,f.height)-2*f.margin,x=f.shape===A?v/Math.sqrt(2):v,_=this._roundSize(x/p),S=7*_,b=3*_,M=this._roundSize((f.width-p*_)/2),I=this._roundSize((f.height-p*_)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach(([F,ae,O])=>{var se,ee,X,Q,R,Z,te,le,ie,fe,ve,Me;const Ne=M+F*_*(p-7),Te=I+ae*_*(p-7);let Be=this._dotsClipPath,Ie=this._dotsClipPath;if((!((se=f.cornersSquareOptions)===null||se===void 0)&&se.gradient||!((ee=f.cornersSquareOptions)===null||ee===void 0)&&ee.color)&&(Be=this._window.document.createElementNS("http://www.w3.org/2000/svg","clipPath"),Be.setAttribute("id",`clip-path-corners-square-color-${F}-${ae}-${this._instanceId}`),this._defs.appendChild(Be),this._cornersSquareClipPath=this._cornersDotClipPath=Ie=Be,this._createColor({options:(X=f.cornersSquareOptions)===null||X===void 0?void 0:X.gradient,color:(Q=f.cornersSquareOptions)===null||Q===void 0?void 0:Q.color,additionalRotation:O,x:Ne,y:Te,height:S,width:S,name:`corners-square-color-${F}-${ae}-${this._instanceId}`})),(R=f.cornersSquareOptions)===null||R===void 0?void 0:R.type){const Le=new g({svg:this._element,type:f.cornersSquareOptions.type,window:this._window});Le.draw(Ne,Te,S,O),Le._element&&Be&&Be.appendChild(Le._element)}else{const Le=new d({svg:this._element,type:f.dotsOptions.type,window:this._window});for(let Ve=0;Ve{var Ee;return!!(!((Ee=P[Ve+He])===null||Ee===void 0)&&Ee[ke+ze])}),Le._element&&Be&&Be.appendChild(Le._element))}if((!((te=f.cornersDotOptions)===null||te===void 0)&&te.gradient||!((le=f.cornersDotOptions)===null||le===void 0)&&le.color)&&(Ie=this._window.document.createElementNS("http://www.w3.org/2000/svg","clipPath"),Ie.setAttribute("id",`clip-path-corners-dot-color-${F}-${ae}-${this._instanceId}`),this._defs.appendChild(Ie),this._cornersDotClipPath=Ie,this._createColor({options:(ie=f.cornersDotOptions)===null||ie===void 0?void 0:ie.gradient,color:(fe=f.cornersDotOptions)===null||fe===void 0?void 0:fe.color,additionalRotation:O,x:Ne+2*_,y:Te+2*_,height:b,width:b,name:`corners-dot-color-${F}-${ae}-${this._instanceId}`})),(ve=f.cornersDotOptions)===null||ve===void 0?void 0:ve.type){const Le=new y({svg:this._element,type:f.cornersDotOptions.type,window:this._window});Le.draw(Ne+2*_,Te+2*_,b,O),Le._element&&Ie&&Ie.appendChild(Le._element)}else{const Le=new d({svg:this._element,type:f.dotsOptions.type,window:this._window});for(let Ve=0;Ve{var Ee;return!!(!((Ee=N[Ve+He])===null||Ee===void 0)&&Ee[ke+ze])}),Le._element&&Ie&&Ie.appendChild(Le._element))}})}loadImage(){return new Promise((m,f)=>{var p;const v=this._options;if(!v.image)return f("Image is not defined");if(!((p=v.nodeCanvas)===null||p===void 0)&&p.loadImage)v.nodeCanvas.loadImage(v.image).then(x=>{var _,S;if(this._image=x,this._options.imageOptions.saveAsBlob){const b=(_=v.nodeCanvas)===null||_===void 0?void 0:_.createCanvas(this._image.width,this._image.height);(S=b==null?void 0:b.getContext("2d"))===null||S===void 0||S.drawImage(x,0,0),this._imageUri=b==null?void 0:b.toDataURL()}m()}).catch(f);else{const x=new this._window.Image;typeof v.imageOptions.crossOrigin=="string"&&(x.crossOrigin=v.imageOptions.crossOrigin),this._image=x,x.onload=async()=>{this._options.imageOptions.saveAsBlob&&(this._imageUri=await async function(_,S){return new Promise(b=>{const M=new S.XMLHttpRequest;M.onload=function(){const I=new S.FileReader;I.onloadend=function(){b(I.result)},I.readAsDataURL(M.response)},M.open("GET",_),M.responseType="blob",M.send()})}(v.image||"",this._window)),m()},x.src=v.image}})}async drawImage({width:m,height:f,count:p,dotSize:v}){const x=this._options,_=this._roundSize((x.width-p*v)/2),S=this._roundSize((x.height-p*v)/2),b=_+this._roundSize(x.imageOptions.margin+(p*v-m)/2),M=S+this._roundSize(x.imageOptions.margin+(p*v-f)/2),I=m-2*x.imageOptions.margin,F=f-2*x.imageOptions.margin,ae=this._window.document.createElementNS("http://www.w3.org/2000/svg","image");ae.setAttribute("href",this._imageUri||""),ae.setAttribute("x",String(b)),ae.setAttribute("y",String(M)),ae.setAttribute("width",`${I}px`),ae.setAttribute("height",`${F}px`),this._element.appendChild(ae)}_createColor({options:m,color:f,additionalRotation:p,x:v,y:x,height:_,width:S,name:b}){const M=S>_?S:_,I=this._window.document.createElementNS("http://www.w3.org/2000/svg","rect");if(I.setAttribute("x",String(v)),I.setAttribute("y",String(x)),I.setAttribute("height",String(_)),I.setAttribute("width",String(S)),I.setAttribute("clip-path",`url('#clip-path-${b}')`),m){let F;if(m.type==="radial")F=this._window.document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),F.setAttribute("id",b),F.setAttribute("gradientUnits","userSpaceOnUse"),F.setAttribute("fx",String(v+S/2)),F.setAttribute("fy",String(x+_/2)),F.setAttribute("cx",String(v+S/2)),F.setAttribute("cy",String(x+_/2)),F.setAttribute("r",String(M/2));else{const ae=((m.rotation||0)+p)%(2*Math.PI),O=(ae+2*Math.PI)%(2*Math.PI);let se=v+S/2,ee=x+_/2,X=v+S/2,Q=x+_/2;O>=0&&O<=.25*Math.PI||O>1.75*Math.PI&&O<=2*Math.PI?(se-=S/2,ee-=_/2*Math.tan(ae),X+=S/2,Q+=_/2*Math.tan(ae)):O>.25*Math.PI&&O<=.75*Math.PI?(ee-=_/2,se-=S/2/Math.tan(ae),Q+=_/2,X+=S/2/Math.tan(ae)):O>.75*Math.PI&&O<=1.25*Math.PI?(se+=S/2,ee+=_/2*Math.tan(ae),X-=S/2,Q-=_/2*Math.tan(ae)):O>1.25*Math.PI&&O<=1.75*Math.PI&&(ee+=_/2,se+=S/2/Math.tan(ae),Q-=_/2,X-=S/2/Math.tan(ae)),F=this._window.document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),F.setAttribute("id",b),F.setAttribute("gradientUnits","userSpaceOnUse"),F.setAttribute("x1",String(Math.round(se))),F.setAttribute("y1",String(Math.round(ee))),F.setAttribute("x2",String(Math.round(X))),F.setAttribute("y2",String(Math.round(Q)))}m.colorStops.forEach(({offset:ae,color:O})=>{const se=this._window.document.createElementNS("http://www.w3.org/2000/svg","stop");se.setAttribute("offset",100*ae+"%"),se.setAttribute("stop-color",O),F.appendChild(se)}),I.setAttribute("fill",`url('#${b}')`),this._defs.appendChild(F)}else f&&I.setAttribute("fill",f);this._element.appendChild(I)}}D.instanceCount=0;const k=D,$="canvas",q={};for(let E=0;E<=40;E++)q[E]=E;const U={type:$,shape:"square",width:300,height:300,data:"",margin:0,qrOptions:{typeNumber:q[0],mode:void 0,errorCorrectionLevel:"Q"},imageOptions:{saveAsBlob:!0,hideBackgroundDots:!0,imageSize:.4,crossOrigin:void 0,margin:0},dotsOptions:{type:"square",color:"#000",roundSize:!0},backgroundOptions:{round:0,color:"#fff"}};function K(E){const m=Object.assign({},E);if(!m.colorStops||!m.colorStops.length)throw"Field 'colorStops' is required in gradient";return m.rotation?m.rotation=Number(m.rotation):m.rotation=0,m.colorStops=m.colorStops.map(f=>Object.assign(Object.assign({},f),{offset:Number(f.offset)})),m}function J(E){const m=Object.assign({},E);return m.width=Number(m.width),m.height=Number(m.height),m.margin=Number(m.margin),m.imageOptions=Object.assign(Object.assign({},m.imageOptions),{hideBackgroundDots:!!m.imageOptions.hideBackgroundDots,imageSize:Number(m.imageOptions.imageSize),margin:Number(m.imageOptions.margin)}),m.margin>Math.min(m.width,m.height)&&(m.margin=Math.min(m.width,m.height)),m.dotsOptions=Object.assign({},m.dotsOptions),m.dotsOptions.gradient&&(m.dotsOptions.gradient=K(m.dotsOptions.gradient)),m.cornersSquareOptions&&(m.cornersSquareOptions=Object.assign({},m.cornersSquareOptions),m.cornersSquareOptions.gradient&&(m.cornersSquareOptions.gradient=K(m.cornersSquareOptions.gradient))),m.cornersDotOptions&&(m.cornersDotOptions=Object.assign({},m.cornersDotOptions),m.cornersDotOptions.gradient&&(m.cornersDotOptions.gradient=K(m.cornersDotOptions.gradient))),m.backgroundOptions&&(m.backgroundOptions=Object.assign({},m.backgroundOptions),m.backgroundOptions.gradient&&(m.backgroundOptions.gradient=K(m.backgroundOptions.gradient))),m}var T=i(873),z=i.n(T);function ue(E){if(!E)throw new Error("Extension must be defined");E[0]==="."&&(E=E.substring(1));const m={bmp:"image/bmp",gif:"image/gif",ico:"image/vnd.microsoft.icon",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml",tif:"image/tiff",tiff:"image/tiff",webp:"image/webp",pdf:"application/pdf"}[E.toLowerCase()];if(!m)throw new Error(`Extension "${E}" is not supported`);return m}class _e{constructor(m){m!=null&&m.jsdom?this._window=new m.jsdom("",{resources:"usable"}).window:this._window=window,this._options=m?J(a(U,m)):U,this.update()}static _clearContainer(m){m&&(m.innerHTML="")}_setupSvg(){if(!this._qr)return;const m=new k(this._options,this._window);this._svg=m.getElement(),this._svgDrawingPromise=m.drawQR(this._qr).then(()=>{var f;this._svg&&((f=this._extension)===null||f===void 0||f.call(this,m.getElement(),this._options))})}_setupCanvas(){var m,f;this._qr&&(!((m=this._options.nodeCanvas)===null||m===void 0)&&m.createCanvas?(this._nodeCanvas=this._options.nodeCanvas.createCanvas(this._options.width,this._options.height),this._nodeCanvas.width=this._options.width,this._nodeCanvas.height=this._options.height):(this._domCanvas=document.createElement("canvas"),this._domCanvas.width=this._options.width,this._domCanvas.height=this._options.height),this._setupSvg(),this._canvasDrawingPromise=(f=this._svgDrawingPromise)===null||f===void 0?void 0:f.then(()=>{var p;if(!this._svg)return;const v=this._svg,x=new this._window.XMLSerializer().serializeToString(v),_=btoa(x),S=`data:${ue("svg")};base64,${_}`;if(!((p=this._options.nodeCanvas)===null||p===void 0)&&p.loadImage)return this._options.nodeCanvas.loadImage(S).then(b=>{var M,I;b.width=this._options.width,b.height=this._options.height,(I=(M=this._nodeCanvas)===null||M===void 0?void 0:M.getContext("2d"))===null||I===void 0||I.drawImage(b,0,0)});{const b=new this._window.Image;return new Promise(M=>{b.onload=()=>{var I,F;(F=(I=this._domCanvas)===null||I===void 0?void 0:I.getContext("2d"))===null||F===void 0||F.drawImage(b,0,0),M()},b.src=S})}}))}async _getElement(m="png"){if(!this._qr)throw"QR code is empty";return m.toLowerCase()==="svg"?(this._svg&&this._svgDrawingPromise||this._setupSvg(),await this._svgDrawingPromise,this._svg):((this._domCanvas||this._nodeCanvas)&&this._canvasDrawingPromise||this._setupCanvas(),await this._canvasDrawingPromise,this._domCanvas||this._nodeCanvas)}update(m){_e._clearContainer(this._container),this._options=m?J(a(this._options,m)):this._options,this._options.data&&(this._qr=z()(this._options.qrOptions.typeNumber,this._options.qrOptions.errorCorrectionLevel),this._qr.addData(this._options.data,this._options.qrOptions.mode||function(f){switch(!0){case/^[0-9]*$/.test(f):return"Numeric";case/^[0-9A-Z $%*+\-./:]*$/.test(f):return"Alphanumeric";default:return"Byte"}}(this._options.data)),this._qr.make(),this._options.type===$?this._setupCanvas():this._setupSvg(),this.append(this._container))}append(m){if(m){if(typeof m.appendChild!="function")throw"Container should be a single DOM node";this._options.type===$?this._domCanvas&&m.appendChild(this._domCanvas):this._svg&&m.appendChild(this._svg),this._container=m}}applyExtension(m){if(!m)throw"Extension function should be defined.";this._extension=m,this.update()}deleteExtension(){this._extension=void 0,this.update()}async getRawData(m="png"){if(!this._qr)throw"QR code is empty";const f=await this._getElement(m),p=ue(m);if(!f)return null;if(m.toLowerCase()==="svg"){const v=`\r -${new this._window.XMLSerializer().serializeToString(f)}`;return typeof Blob>"u"||this._options.jsdom?Buffer.from(v):new Blob([v],{type:p})}return new Promise(v=>{const x=f;if("toBuffer"in x)if(p==="image/png")v(x.toBuffer(p));else if(p==="image/jpeg")v(x.toBuffer(p));else{if(p!=="application/pdf")throw Error("Unsupported extension");v(x.toBuffer(p))}else"toBlob"in x&&x.toBlob(v,p,1)})}async download(m){if(!this._qr)throw"QR code is empty";if(typeof Blob>"u")throw"Cannot download in Node.js, call getRawData instead.";let f="png",p="qr";typeof m=="string"?(f=m,console.warn("Extension is deprecated as argument for 'download' method, please pass object { name: '...', extension: '...' } as argument")):typeof m=="object"&&m!==null&&(m.name&&(p=m.name),m.extension&&(f=m.extension));const v=await this._getElement(f);if(v)if(f.toLowerCase()==="svg"){let x=new XMLSerializer().serializeToString(v);x=`\r -`+x,u(`data:${ue(f)};charset=utf-8,${encodeURIComponent(x)}`,`${p}.svg`)}else u(v.toDataURL(ue(f)),`${p}.${f}`)}}const G=_e})(),s.default})())})(b7);var QX=b7.exports;const y7=Ui(QX);class Sa extends yt{constructor(e){const{docsPath:r,field:n,metaMessages:i}=e;super(`Invalid Sign-In with Ethereum message field "${n}".`,{docsPath:r,metaMessages:i,name:"SiweInvalidMessageFieldError"})}}function w7(t){if(/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(t)||/%[^0-9a-f]/i.test(t)||/%[0-9a-f](:?[^0-9a-f]|$)/i.test(t))return!1;const e=eZ(t),r=e[1],n=e[2],i=e[3],s=e[4],o=e[5];if(!(r!=null&&r.length&&i.length>=0))return!1;if(n!=null&&n.length){if(!(i.length===0||/^\//.test(i)))return!1}else if(/^\/\//.test(i))return!1;if(!/^[a-z][a-z0-9\+\-\.]*$/.test(r.toLowerCase()))return!1;let a="";return a+=`${r}:`,n!=null&&n.length&&(a+=`//${n}`),a+=i,s!=null&&s.length&&(a+=`?${s}`),o!=null&&o.length&&(a+=`#${o}`),a}function eZ(t){return t.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}function x7(t){const{chainId:e,domain:r,expirationTime:n,issuedAt:i=new Date,nonce:s,notBefore:o,requestId:a,resources:u,scheme:l,uri:d,version:g}=t;{if(e!==Math.floor(e))throw new Sa({field:"chainId",metaMessages:["- Chain ID must be a EIP-155 chain ID.","- See https://eips.ethereum.org/EIPS/eip-155","",`Provided value: ${e}`]});if(!(tZ.test(r)||rZ.test(r)||nZ.test(r)))throw new Sa({field:"domain",metaMessages:["- Domain must be an RFC 3986 authority.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${r}`]});if(!iZ.test(s))throw new Sa({field:"nonce",metaMessages:["- Nonce must be at least 8 characters.","- Nonce must be alphanumeric.","",`Provided value: ${s}`]});if(!w7(d))throw new Sa({field:"uri",metaMessages:["- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${d}`]});if(g!=="1")throw new Sa({field:"version",metaMessages:["- Version must be '1'.","",`Provided value: ${g}`]});if(l&&!sZ.test(l))throw new Sa({field:"scheme",metaMessages:["- Scheme must be an RFC 3986 URI scheme.","- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1","",`Provided value: ${l}`]});const k=t.statement;if(k!=null&&k.includes(` -`))throw new Sa({field:"statement",metaMessages:["- Statement must not include '\\n'.","",`Provided value: ${k}`]})}const y=bw(t.address),A=l?`${l}://${r}`:r,P=t.statement?`${t.statement} -`:"",N=`${A} wants you to sign in with your Ethereum account: -${y} +}`;const YS=Yt.forwardRef(({className:t,containerClassName:e,...r},n)=>he.jsx(GS,{ref:n,containerClassName:ao("xc-flex xc-items-center xc-gap-2 xc-has-[:disabled]:opacity-50",e),className:ao("disabled:xc-cursor-not-allowed",t),...r}));YS.displayName="InputOTP";const JS=Yt.forwardRef(({className:t,...e},r)=>he.jsx("div",{ref:r,className:ao("xc-flex xc-items-center",t),...e}));JS.displayName="InputOTPGroup";const Ka=Yt.forwardRef(({index:t,className:e,...r},n)=>{const i=Yt.useContext(VS),{char:s,hasFakeCaret:o,isActive:a}=i.slots[t];return he.jsxs("div",{ref:n,className:ao("xc-relative xc-rounded-xl xc-text-2xl xc-flex xc-h-12 xc-w-12 xc-items-center xc-justify-center xc-border xc-border-white xc-border-opacity-20 xc-transition-all",a&&"xc-z-10 xc-ring-2 xc-ring-ring xc-ring-[rgb(135,93,255)] xc-ring-offset-background",e),...r,children:[s,o&&he.jsx("div",{className:"xc-pointer-events-none xc-absolute xc-inset-0 xc-flex xc-items-center xc-justify-center",children:he.jsx("div",{className:"xc-h-4 xc-w-px xc-animate-caret-blink xc-bg-foreground xc-duration-1000"})})]})});Ka.displayName="InputOTPSlot";function fY(t){const{spinning:e,children:r,className:n}=t;return he.jsxs("div",{className:"xc-inline-block xc-relative",children:[r,e&&he.jsx("div",{className:ao("xc-absolute xc-top-0 xc-left-0 xc-w-full xc-h-full xc-bg-black xc-bg-opacity-10 xc-flex xc-items-center xc-justify-center",n),children:he.jsx(Fa,{className:"xc-animate-spin"})})]})}function XS(t){const{email:e}=t,[r,n]=Se.useState(0),[i,s]=Se.useState(!1),[o,a]=Se.useState("");async function f(){n(60);const h=setInterval(()=>{n(g=>g===0?(clearInterval(h),0):g-1)},1e3)}async function u(h){if(a(""),!(h.length<6)){s(!0);try{await t.onInputCode(e,h)}catch(g){a(g.message)}s(!1)}}return Se.useEffect(()=>{f()},[]),he.jsxs(ls,{children:[he.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-12",children:[he.jsx(Uz,{className:"xc-mb-4",size:60}),he.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-8 xc-h-16",children:[he.jsx("p",{className:"xc-text-lg xc-mb-1",children:"We’ve sent a verification code to"}),he.jsx("p",{className:"xc-font-bold xc-text-center",children:e})]}),he.jsx("div",{className:"xc-mb-2 xc-h-12",children:he.jsx(fY,{spinning:i,className:"xc-rounded-xl",children:he.jsx(YS,{maxLength:6,onChange:u,disabled:i,className:"disabled:xc-opacity-20",children:he.jsx(JS,{children:he.jsxs("div",{className:ao("xc-flex xc-gap-2",i?"xc-opacity-20":""),children:[he.jsx(Ka,{index:0}),he.jsx(Ka,{index:1}),he.jsx(Ka,{index:2}),he.jsx(Ka,{index:3}),he.jsx(Ka,{index:4}),he.jsx(Ka,{index:5})]})})})})}),o&&he.jsx("div",{className:"xc-text-[#ff0000] xc-text-center",children:he.jsx("p",{children:o})})]}),he.jsxs("div",{className:"xc-text-center xc-text-sm xc-text-gray-400",children:["Not get it? ",r?`Resend in ${r}s`:he.jsx("button",{id:"sendCodeButton",onClick:t.onResendCode,children:"Send again"})]}),he.jsx("div",{id:"captcha-element"})]})}function ZS(t){const{email:e}=t,[r,n]=Se.useState(!1),[i,s]=Se.useState(""),o=Se.useMemo(()=>`xn-btn-${new Date().getTime()}`,[e]);async function a(b,x){n(!0),s(""),await Fo.getEmailCode({account_type:"email",email:b},x),n(!1)}async function f(b){try{return await a(e,JSON.stringify(b)),{captchaResult:!0,bizResult:!0}}catch(x){return s(x.message),{captchaResult:!1,bizResult:!1}}}async function u(b){b&&t.onCodeSend()}const h=Se.useRef();function g(b){h.current=b}return Se.useEffect(()=>{if(e)return window.initAliyunCaptcha({SceneId:"tqyu8129d",prefix:"1mfsn5f",mode:"popup",element:"#captcha-element",button:`#${o}`,captchaVerifyCallback:f,onBizResultCallback:u,getInstance:g,slideStyle:{width:360,height:40},language:"en",region:"cn"}),()=>{document.getElementById("aliyunCaptcha-mask")?.remove(),document.getElementById("aliyunCaptcha-window-popup")?.remove()}},[e]),he.jsxs(ls,{children:[he.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-12",children:[he.jsx($z,{className:"xc-mb-4",size:60}),he.jsx("button",{className:"xc-border xc-rounded-full xc-bg-white xc-text-black xc-px-8 xc-py-2",id:o,children:r?he.jsx(Fa,{className:"xc-animate-spin"}):"I'm not a robot"})]}),i&&he.jsx("div",{className:"xc-text-[#ff0000] xc-text-center",children:he.jsx("p",{children:i})})]})}function lY(t){const{email:e}=t,r=F1(),[n,i]=Se.useState("captcha");async function s(o,a){const f=await Fo.emailLogin({account_type:"email",connector:"codatta_email",account_enum:"C",email_code:a,email:o,inviter_code:r.inviterCode,source:{device:r.device,channel:r.channel,app:r.app}});t.onLogin(f.data)}return he.jsxs(ls,{children:[he.jsx("div",{className:"xc-mb-12",children:he.jsx(Wa,{title:"Sign in with email",onBack:t.onBack})}),n==="captcha"&&he.jsx(ZS,{email:e,onCodeSend:()=>i("verify-email")}),n==="verify-email"&&he.jsx(XS,{email:e,onInputCode:s,onResendCode:()=>i("captcha")})]})}var zd={exports:{}},hY=zd.exports,QS;function dY(){return QS||(QS=1,(function(t,e){(function(r,n){t.exports=n()})(hY,(()=>(()=>{var r={873:(o,a)=>{var f,u,h=(function(){var g=function(l,p){var m=l,y=B[p],A=null,E=0,w=null,I=[],M={},z=function(ne,de){A=(function(ce){for(var fe=new Array(ce),be=0;be=7&&ee(ne),w==null&&(w=N(m,y,I)),te(w,de)},se=function(ne,de){for(var ce=-1;ce<=7;ce+=1)if(!(ne+ce<=-1||E<=ne+ce))for(var fe=-1;fe<=7;fe+=1)de+fe<=-1||E<=de+fe||(A[ne+ce][de+fe]=0<=ce&&ce<=6&&(fe==0||fe==6)||0<=fe&&fe<=6&&(ce==0||ce==6)||2<=ce&&ce<=4&&2<=fe&&fe<=4)},O=function(){for(var ne=8;ne>ce&1)==1;A[Math.floor(ce/3)][ce%3+E-8-3]=fe}for(ce=0;ce<18;ce+=1)fe=!ne&&(de>>ce&1)==1,A[ce%3+E-8-3][Math.floor(ce/3)]=fe},Z=function(ne,de){for(var ce=y<<3|de,fe=L.getBCHTypeInfo(ce),be=0;be<15;be+=1){var Pe=!ne&&(fe>>be&1)==1;be<6?A[be][8]=Pe:be<8?A[be+1][8]=Pe:A[E-15+be][8]=Pe}for(be=0;be<15;be+=1)Pe=!ne&&(fe>>be&1)==1,be<8?A[8][E-be-1]=Pe:be<9?A[8][15-be-1+1]=Pe:A[8][15-be-1]=Pe;A[E-8][8]=!ne},te=function(ne,de){for(var ce=-1,fe=E-1,be=7,Pe=0,De=L.getMaskFunction(de),Te=E-1;Te>0;Te-=2)for(Te==6&&(Te-=1);;){for(var Fe=0;Fe<2;Fe+=1)if(A[fe][Te-Fe]==null){var Me=!1;Pe>>be&1)==1),De(fe,Te-Fe)&&(Me=!Me),A[fe][Te-Fe]=Me,(be-=1)==-1&&(Pe+=1,be=7)}if((fe+=ce)<0||E<=fe){fe-=ce,ce=-ce;break}}},N=function(ne,de,ce){for(var fe=k.getRSBlocks(ne,de),be=$(),Pe=0;Pe8*Te)throw"code length overflow. ("+be.getLengthInBits()+">"+8*Te+")";for(be.getLengthInBits()+4<=8*Te&&be.put(0,4);be.getLengthInBits()%8!=0;)be.putBit(!1);for(;!(be.getLengthInBits()>=8*Te||(be.put(236,8),be.getLengthInBits()>=8*Te));)be.put(17,8);return(function(Fe,Me){for(var Ne=0,He=0,Oe=0,$e=new Array(Me.length),qe=new Array(Me.length),_e=0;_e=0?it.getAt(Ye):0}}var pt=0;for(Be=0;BeMe)&&(De=Me,Te=Fe)}return Te})())},M.createTableTag=function(ne,de){ne=ne||2;var ce="";ce+='";for(var be=0;be';ce+=""}return(ce+="")+"
"},M.createSvgTag=function(ne,de,ce,fe){var be={};typeof arguments[0]=="object"&&(ne=(be=arguments[0]).cellSize,de=be.margin,ce=be.alt,fe=be.title),ne=ne||2,de=de===void 0?4*ne:de,(ce=typeof ce=="string"?{text:ce}:ce||{}).text=ce.text||null,ce.id=ce.text?ce.id||"qrcode-description":null,(fe=typeof fe=="string"?{text:fe}:fe||{}).text=fe.text||null,fe.id=fe.text?fe.id||"qrcode-title":null;var Pe,De,Te,Fe,Me=M.getModuleCount()*ne+2*de,Ne="";for(Fe="l"+ne+",0 0,"+ne+" -"+ne+",0 0,-"+ne+"z ",Ne+=''+Q(fe.text)+"":"",Ne+=ce.text?''+Q(ce.text)+"":"",Ne+='',Ne+='"},M.createDataURL=function(ne,de){ne=ne||2,de=de===void 0?4*ne:de;var ce=M.getModuleCount()*ne+2*de,fe=de,be=ce-de;return v(ce,ce,(function(Pe,De){if(fe<=Pe&&Pe"};var Q=function(ne){for(var de="",ce=0;ce":de+=">";break;case"&":de+="&";break;case'"':de+=""";break;default:de+=fe}}return de};return M.createASCII=function(ne,de){if((ne=ne||1)<2)return(function($e){$e=$e===void 0?2:$e;var qe,_e,Qe,at,Be,nt=1*M.getModuleCount()+2*$e,it=$e,Ye=nt-$e,pt={"██":"█","█ ":"▀"," █":"▄"," ":" "},ht={"██":"▀","█ ":"▀"," █":" "," ":" "},ft="";for(qe=0;qe=Ye?ht[Be]:pt[Be];ft+=` +`}return nt%2&&$e>0?ft.substring(0,ft.length-nt-1)+Array(nt+1).join("▀"):ft.substring(0,ft.length-1)})(de);ne-=1,de=de===void 0?2*ne:de;var ce,fe,be,Pe,De=M.getModuleCount()*ne+2*de,Te=de,Fe=De-de,Me=Array(ne+1).join("██"),Ne=Array(ne+1).join(" "),He="",Oe="";for(ce=0;ce>>8),E.push(255&M)):E.push(y)}}return E}};var b,x,S,C,D,B={L:1,M:0,Q:3,H:2},L=(b=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],x=1335,S=7973,D=function(l){for(var p=0;l!=0;)p+=1,l>>>=1;return p},(C={}).getBCHTypeInfo=function(l){for(var p=l<<10;D(p)-D(x)>=0;)p^=x<=0;)p^=S<5&&(m+=3+E-5)}for(y=0;y=256;)y-=255;return l[y]}}})();function F(l,p){if(l.length===void 0)throw l.length+"/"+p;var m=(function(){for(var A=0;A>>7-y%8&1)==1},put:function(y,A){for(var E=0;E>>A-E-1&1)==1)},getLengthInBits:function(){return p},putBit:function(y){var A=Math.floor(p/8);l.length<=A&&l.push(0),y&&(l[A]|=128>>>p%8),p+=1}};return m},R=function(l){var p=l,m={getMode:function(){return 1},getLength:function(E){return p.length},write:function(E){for(var w=p,I=0;I+2>>8&255)+(255&I),A.put(I,13),w+=2}if(w>>8)},writeBytes:function(m,y,A){y=y||0,A=A||m.length;for(var E=0;E0&&(m+=","),m+=l[y];return m+"]"}};return p},_=function(l){var p=l,m=0,y=0,A=0,E={read:function(){for(;A<8;){if(m>=p.length){if(A==0)return-1;throw"unexpected end of file./"+A}var I=p.charAt(m);if(m+=1,I=="=")return A=0,-1;I.match(/^\s$/)||(y=y<<6|w(I.charCodeAt(0)),A+=6)}var M=y>>>A-8&255;return A-=8,M}},w=function(I){if(65<=I&&I<=90)return I-65;if(97<=I&&I<=122)return I-97+26;if(48<=I&&I<=57)return I-48+52;if(I==43)return 62;if(I==47)return 63;throw"c:"+I};return E},v=function(l,p,m){for(var y=(function(se,O){var ie=se,ee=O,Z=new Array(se*O),te={setPixel:function(ne,de,ce){Z[de*ie+ne]=ce},write:function(ne){ne.writeString("GIF87a"),ne.writeShort(ie),ne.writeShort(ee),ne.writeByte(128),ne.writeByte(0),ne.writeByte(0),ne.writeByte(0),ne.writeByte(0),ne.writeByte(0),ne.writeByte(255),ne.writeByte(255),ne.writeByte(255),ne.writeString(","),ne.writeShort(0),ne.writeShort(0),ne.writeShort(ie),ne.writeShort(ee),ne.writeByte(0);var de=N(2);ne.writeByte(2);for(var ce=0;de.length-ce>255;)ne.writeByte(255),ne.writeBytes(de,ce,255),ce+=255;ne.writeByte(de.length-ce),ne.writeBytes(de,ce,de.length-ce),ne.writeByte(0),ne.writeString(";")}},N=function(ne){for(var de=1<>>_e)throw"length over";for(;Te+_e>=8;)De.writeByte(255&(qe<>>=8-Te,Fe=0,Te=0;Fe|=qe<0&&De.writeByte(Fe)}});Ne.write(de,fe);var He=0,Oe=String.fromCharCode(Z[He]);for(He+=1;He=6;)te(se>>>O-6),O-=6},Z.flush=function(){if(O>0&&(te(se<<6-O),se=0,O=0),ie%3!=0)for(var Q=3-ie%3,ne=0;ne>6,128|63&C):C<55296||C>=57344?x.push(224|C>>12,128|C>>6&63,128|63&C):(S++,C=65536+((1023&C)<<10|1023&b.charCodeAt(S)),x.push(240|C>>18,128|C>>12&63,128|C>>6&63,128|63&C))}return x})(g)},(u=typeof(f=function(){return h})=="function"?f.apply(a,[]):f)===void 0||(o.exports=u)}},n={};function i(o){var a=n[o];if(a!==void 0)return a.exports;var f=n[o]={exports:{}};return r[o](f,f.exports,i),f.exports}i.n=o=>{var a=o&&o.__esModule?()=>o.default:()=>o;return i.d(a,{a}),a},i.d=(o,a)=>{for(var f in a)i.o(a,f)&&!i.o(o,f)&&Object.defineProperty(o,f,{enumerable:!0,get:a[f]})},i.o=(o,a)=>Object.prototype.hasOwnProperty.call(o,a);var s={};return(()=>{i.d(s,{default:()=>q});const o=_=>!!_&&typeof _=="object"&&!Array.isArray(_);function a(_,...v){if(!v.length)return _;const l=v.shift();return l!==void 0&&o(_)&&o(l)?(_=Object.assign({},_),Object.keys(l).forEach((p=>{const m=_[p],y=l[p];Array.isArray(m)&&Array.isArray(y)?_[p]=y:o(m)&&o(y)?_[p]=a(Object.assign({},m),y):_[p]=y})),a(_,...v)):_}function f(_,v){const l=document.createElement("a");l.download=v,l.href=_,document.body.appendChild(l),l.click(),document.body.removeChild(l)}const u={L:.07,M:.15,Q:.25,H:.3};class h{constructor({svg:v,type:l,window:p}){this._svg=v,this._type=l,this._window=p}draw(v,l,p,m){let y;switch(this._type){case"dots":y=this._drawDot;break;case"classy":y=this._drawClassy;break;case"classy-rounded":y=this._drawClassyRounded;break;case"rounded":y=this._drawRounded;break;case"extra-rounded":y=this._drawExtraRounded;break;default:y=this._drawSquare}y.call(this,{x:v,y:l,size:p,getNeighbor:m})}_rotateFigure({x:v,y:l,size:p,rotation:m=0,draw:y}){var A;const E=v+p/2,w=l+p/2;y(),(A=this._element)===null||A===void 0||A.setAttribute("transform",`rotate(${180*m/Math.PI},${E},${w})`)}_basicDot(v){const{size:l,x:p,y:m}=v;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",String(p+l/2)),this._element.setAttribute("cy",String(m+l/2)),this._element.setAttribute("r",String(l/2))}}))}_basicSquare(v){const{size:l,x:p,y:m}=v;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",String(p)),this._element.setAttribute("y",String(m)),this._element.setAttribute("width",String(l)),this._element.setAttribute("height",String(l))}}))}_basicSideRounded(v){const{size:l,x:p,y:m}=v;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${p} ${m}v ${l}h `+l/2+`a ${l/2} ${l/2}, 0, 0, 0, 0 ${-l}`)}}))}_basicCornerRounded(v){const{size:l,x:p,y:m}=v;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${p} ${m}v ${l}h ${l}v `+-l/2+`a ${l/2} ${l/2}, 0, 0, 0, ${-l/2} ${-l/2}`)}}))}_basicCornerExtraRounded(v){const{size:l,x:p,y:m}=v;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${p} ${m}v ${l}h ${l}a ${l} ${l}, 0, 0, 0, ${-l} ${-l}`)}}))}_basicCornersRounded(v){const{size:l,x:p,y:m}=v;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${p} ${m}v `+l/2+`a ${l/2} ${l/2}, 0, 0, 0, ${l/2} ${l/2}h `+l/2+"v "+-l/2+`a ${l/2} ${l/2}, 0, 0, 0, ${-l/2} ${-l/2}`)}}))}_drawDot({x:v,y:l,size:p}){this._basicDot({x:v,y:l,size:p,rotation:0})}_drawSquare({x:v,y:l,size:p}){this._basicSquare({x:v,y:l,size:p,rotation:0})}_drawRounded({x:v,y:l,size:p,getNeighbor:m}){const y=m?+m(-1,0):0,A=m?+m(1,0):0,E=m?+m(0,-1):0,w=m?+m(0,1):0,I=y+A+E+w;if(I!==0)if(I>2||y&&A||E&&w)this._basicSquare({x:v,y:l,size:p,rotation:0});else{if(I===2){let M=0;return y&&E?M=Math.PI/2:E&&A?M=Math.PI:A&&w&&(M=-Math.PI/2),void this._basicCornerRounded({x:v,y:l,size:p,rotation:M})}if(I===1){let M=0;return E?M=Math.PI/2:A?M=Math.PI:w&&(M=-Math.PI/2),void this._basicSideRounded({x:v,y:l,size:p,rotation:M})}}else this._basicDot({x:v,y:l,size:p,rotation:0})}_drawExtraRounded({x:v,y:l,size:p,getNeighbor:m}){const y=m?+m(-1,0):0,A=m?+m(1,0):0,E=m?+m(0,-1):0,w=m?+m(0,1):0,I=y+A+E+w;if(I!==0)if(I>2||y&&A||E&&w)this._basicSquare({x:v,y:l,size:p,rotation:0});else{if(I===2){let M=0;return y&&E?M=Math.PI/2:E&&A?M=Math.PI:A&&w&&(M=-Math.PI/2),void this._basicCornerExtraRounded({x:v,y:l,size:p,rotation:M})}if(I===1){let M=0;return E?M=Math.PI/2:A?M=Math.PI:w&&(M=-Math.PI/2),void this._basicSideRounded({x:v,y:l,size:p,rotation:M})}}else this._basicDot({x:v,y:l,size:p,rotation:0})}_drawClassy({x:v,y:l,size:p,getNeighbor:m}){const y=m?+m(-1,0):0,A=m?+m(1,0):0,E=m?+m(0,-1):0,w=m?+m(0,1):0;y+A+E+w!==0?y||E?A||w?this._basicSquare({x:v,y:l,size:p,rotation:0}):this._basicCornerRounded({x:v,y:l,size:p,rotation:Math.PI/2}):this._basicCornerRounded({x:v,y:l,size:p,rotation:-Math.PI/2}):this._basicCornersRounded({x:v,y:l,size:p,rotation:Math.PI/2})}_drawClassyRounded({x:v,y:l,size:p,getNeighbor:m}){const y=m?+m(-1,0):0,A=m?+m(1,0):0,E=m?+m(0,-1):0,w=m?+m(0,1):0;y+A+E+w!==0?y||E?A||w?this._basicSquare({x:v,y:l,size:p,rotation:0}):this._basicCornerExtraRounded({x:v,y:l,size:p,rotation:Math.PI/2}):this._basicCornerExtraRounded({x:v,y:l,size:p,rotation:-Math.PI/2}):this._basicCornersRounded({x:v,y:l,size:p,rotation:Math.PI/2})}}class g{constructor({svg:v,type:l,window:p}){this._svg=v,this._type=l,this._window=p}draw(v,l,p,m){let y;switch(this._type){case"square":y=this._drawSquare;break;case"extra-rounded":y=this._drawExtraRounded;break;default:y=this._drawDot}y.call(this,{x:v,y:l,size:p,rotation:m})}_rotateFigure({x:v,y:l,size:p,rotation:m=0,draw:y}){var A;const E=v+p/2,w=l+p/2;y(),(A=this._element)===null||A===void 0||A.setAttribute("transform",`rotate(${180*m/Math.PI},${E},${w})`)}_basicDot(v){const{size:l,x:p,y:m}=v,y=l/7;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${p+l/2} ${m}a ${l/2} ${l/2} 0 1 0 0.1 0zm 0 ${y}a ${l/2-y} ${l/2-y} 0 1 1 -0.1 0Z`)}}))}_basicSquare(v){const{size:l,x:p,y:m}=v,y=l/7;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${p} ${m}v ${l}h ${l}v `+-l+`zM ${p+y} ${m+y}h `+(l-2*y)+"v "+(l-2*y)+"h "+(2*y-l)+"z")}}))}_basicExtraRounded(v){const{size:l,x:p,y:m}=v,y=l/7;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${p} ${m+2.5*y}v `+2*y+`a ${2.5*y} ${2.5*y}, 0, 0, 0, ${2.5*y} ${2.5*y}h `+2*y+`a ${2.5*y} ${2.5*y}, 0, 0, 0, ${2.5*y} ${2.5*-y}v `+-2*y+`a ${2.5*y} ${2.5*y}, 0, 0, 0, ${2.5*-y} ${2.5*-y}h `+-2*y+`a ${2.5*y} ${2.5*y}, 0, 0, 0, ${2.5*-y} ${2.5*y}M ${p+2.5*y} ${m+y}h `+2*y+`a ${1.5*y} ${1.5*y}, 0, 0, 1, ${1.5*y} ${1.5*y}v `+2*y+`a ${1.5*y} ${1.5*y}, 0, 0, 1, ${1.5*-y} ${1.5*y}h `+-2*y+`a ${1.5*y} ${1.5*y}, 0, 0, 1, ${1.5*-y} ${1.5*-y}v `+-2*y+`a ${1.5*y} ${1.5*y}, 0, 0, 1, ${1.5*y} ${1.5*-y}`)}}))}_drawDot({x:v,y:l,size:p,rotation:m}){this._basicDot({x:v,y:l,size:p,rotation:m})}_drawSquare({x:v,y:l,size:p,rotation:m}){this._basicSquare({x:v,y:l,size:p,rotation:m})}_drawExtraRounded({x:v,y:l,size:p,rotation:m}){this._basicExtraRounded({x:v,y:l,size:p,rotation:m})}}class b{constructor({svg:v,type:l,window:p}){this._svg=v,this._type=l,this._window=p}draw(v,l,p,m){let y;y=this._type==="square"?this._drawSquare:this._drawDot,y.call(this,{x:v,y:l,size:p,rotation:m})}_rotateFigure({x:v,y:l,size:p,rotation:m=0,draw:y}){var A;const E=v+p/2,w=l+p/2;y(),(A=this._element)===null||A===void 0||A.setAttribute("transform",`rotate(${180*m/Math.PI},${E},${w})`)}_basicDot(v){const{size:l,x:p,y:m}=v;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",String(p+l/2)),this._element.setAttribute("cy",String(m+l/2)),this._element.setAttribute("r",String(l/2))}}))}_basicSquare(v){const{size:l,x:p,y:m}=v;this._rotateFigure(Object.assign(Object.assign({},v),{draw:()=>{this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",String(p)),this._element.setAttribute("y",String(m)),this._element.setAttribute("width",String(l)),this._element.setAttribute("height",String(l))}}))}_drawDot({x:v,y:l,size:p,rotation:m}){this._basicDot({x:v,y:l,size:p,rotation:m})}_drawSquare({x:v,y:l,size:p,rotation:m}){this._basicSquare({x:v,y:l,size:p,rotation:m})}}const x="circle",S=[[1,1,1,1,1,1,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,1,1,1,1,1,1]],C=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]];class D{constructor(v,l){this._roundSize=p=>this._options.dotsOptions.roundSize?Math.floor(p):p,this._window=l,this._element=this._window.document.createElementNS("http://www.w3.org/2000/svg","svg"),this._element.setAttribute("width",String(v.width)),this._element.setAttribute("height",String(v.height)),this._element.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),v.dotsOptions.roundSize||this._element.setAttribute("shape-rendering","crispEdges"),this._element.setAttribute("viewBox",`0 0 ${v.width} ${v.height}`),this._defs=this._window.document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this._defs),this._imageUri=v.image,this._instanceId=D.instanceCount++,this._options=v}get width(){return this._options.width}get height(){return this._options.height}getElement(){return this._element}async drawQR(v){const l=v.getModuleCount(),p=Math.min(this._options.width,this._options.height)-2*this._options.margin,m=this._options.shape===x?p/Math.sqrt(2):p,y=this._roundSize(m/l);let A={hideXDots:0,hideYDots:0,width:0,height:0};if(this._qr=v,this._options.image){if(await this.loadImage(),!this._image)return;const{imageOptions:E,qrOptions:w}=this._options,I=E.imageSize*u[w.errorCorrectionLevel],M=Math.floor(I*l*l);A=(function({originalHeight:z,originalWidth:se,maxHiddenDots:O,maxHiddenAxisDots:ie,dotSize:ee}){const Z={x:0,y:0},te={x:0,y:0};if(z<=0||se<=0||O<=0||ee<=0)return{height:0,width:0,hideYDots:0,hideXDots:0};const N=z/se;return Z.x=Math.floor(Math.sqrt(O/N)),Z.x<=0&&(Z.x=1),ie&&ieO||ie&&ie{var I,M,z,se,O,ie;return!(this._options.imageOptions.hideBackgroundDots&&E>=(l-A.hideYDots)/2&&E<(l+A.hideYDots)/2&&w>=(l-A.hideXDots)/2&&w<(l+A.hideXDots)/2||!((I=S[E])===null||I===void 0)&&I[w]||!((M=S[E-l+7])===null||M===void 0)&&M[w]||!((z=S[E])===null||z===void 0)&&z[w-l+7]||!((se=C[E])===null||se===void 0)&&se[w]||!((O=C[E-l+7])===null||O===void 0)&&O[w]||!((ie=C[E])===null||ie===void 0)&&ie[w-l+7])})),this.drawCorners(),this._options.image&&await this.drawImage({width:A.width,height:A.height,count:l,dotSize:y})}drawBackground(){var v,l,p;const m=this._element,y=this._options;if(m){const A=(v=y.backgroundOptions)===null||v===void 0?void 0:v.gradient,E=(l=y.backgroundOptions)===null||l===void 0?void 0:l.color;let w=y.height,I=y.width;if(A||E){const M=this._window.document.createElementNS("http://www.w3.org/2000/svg","rect");this._backgroundClipPath=this._window.document.createElementNS("http://www.w3.org/2000/svg","clipPath"),this._backgroundClipPath.setAttribute("id",`clip-path-background-color-${this._instanceId}`),this._defs.appendChild(this._backgroundClipPath),!((p=y.backgroundOptions)===null||p===void 0)&&p.round&&(w=I=Math.min(y.width,y.height),M.setAttribute("rx",String(w/2*y.backgroundOptions.round))),M.setAttribute("x",String(this._roundSize((y.width-I)/2))),M.setAttribute("y",String(this._roundSize((y.height-w)/2))),M.setAttribute("width",String(I)),M.setAttribute("height",String(w)),this._backgroundClipPath.appendChild(M),this._createColor({options:A,color:E,additionalRotation:0,x:0,y:0,height:y.height,width:y.width,name:`background-color-${this._instanceId}`})}}}drawDots(v){var l,p;if(!this._qr)throw"QR code is not defined";const m=this._options,y=this._qr.getModuleCount();if(y>m.width||y>m.height)throw"The canvas is too small.";const A=Math.min(m.width,m.height)-2*m.margin,E=m.shape===x?A/Math.sqrt(2):A,w=this._roundSize(E/y),I=this._roundSize((m.width-y*w)/2),M=this._roundSize((m.height-y*w)/2),z=new h({svg:this._element,type:m.dotsOptions.type,window:this._window});this._dotsClipPath=this._window.document.createElementNS("http://www.w3.org/2000/svg","clipPath"),this._dotsClipPath.setAttribute("id",`clip-path-dot-color-${this._instanceId}`),this._defs.appendChild(this._dotsClipPath),this._createColor({options:(l=m.dotsOptions)===null||l===void 0?void 0:l.gradient,color:m.dotsOptions.color,additionalRotation:0,x:0,y:0,height:m.height,width:m.width,name:`dot-color-${this._instanceId}`});for(let se=0;se!(O+ie<0||se+ee<0||O+ie>=y||se+ee>=y)&&!(v&&!v(se+ee,O+ie))&&!!this._qr&&this._qr.isDark(se+ee,O+ie))),z._element&&this._dotsClipPath&&this._dotsClipPath.appendChild(z._element));if(m.shape===x){const se=this._roundSize((A/w-y)/2),O=y+2*se,ie=I-se*w,ee=M-se*w,Z=[],te=this._roundSize(O/2);for(let N=0;N=se-1&&N<=O-se&&Q>=se-1&&Q<=O-se||Math.sqrt((N-te)*(N-te)+(Q-te)*(Q-te))>te?Z[N][Q]=0:Z[N][Q]=this._qr.isDark(Q-2*se<0?Q:Q>=y?Q-2*se:Q-se,N-2*se<0?N:N>=y?N-2*se:N-se)?1:0}for(let N=0;N{var ce;return!!(!((ce=Z[N+de])===null||ce===void 0)&&ce[Q+ne])})),z._element&&this._dotsClipPath&&this._dotsClipPath.appendChild(z._element))}}drawCorners(){if(!this._qr)throw"QR code is not defined";const v=this._element,l=this._options;if(!v)throw"Element code is not defined";const p=this._qr.getModuleCount(),m=Math.min(l.width,l.height)-2*l.margin,y=l.shape===x?m/Math.sqrt(2):m,A=this._roundSize(y/p),E=7*A,w=3*A,I=this._roundSize((l.width-p*A)/2),M=this._roundSize((l.height-p*A)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach((([z,se,O])=>{var ie,ee,Z,te,N,Q,ne,de,ce,fe,be,Pe;const De=I+z*A*(p-7),Te=M+se*A*(p-7);let Fe=this._dotsClipPath,Me=this._dotsClipPath;if((!((ie=l.cornersSquareOptions)===null||ie===void 0)&&ie.gradient||!((ee=l.cornersSquareOptions)===null||ee===void 0)&&ee.color)&&(Fe=this._window.document.createElementNS("http://www.w3.org/2000/svg","clipPath"),Fe.setAttribute("id",`clip-path-corners-square-color-${z}-${se}-${this._instanceId}`),this._defs.appendChild(Fe),this._cornersSquareClipPath=this._cornersDotClipPath=Me=Fe,this._createColor({options:(Z=l.cornersSquareOptions)===null||Z===void 0?void 0:Z.gradient,color:(te=l.cornersSquareOptions)===null||te===void 0?void 0:te.color,additionalRotation:O,x:De,y:Te,height:E,width:E,name:`corners-square-color-${z}-${se}-${this._instanceId}`})),(N=l.cornersSquareOptions)===null||N===void 0?void 0:N.type){const Ne=new g({svg:this._element,type:l.cornersSquareOptions.type,window:this._window});Ne.draw(De,Te,E,O),Ne._element&&Fe&&Fe.appendChild(Ne._element)}else{const Ne=new h({svg:this._element,type:l.dotsOptions.type,window:this._window});for(let He=0;He{var _e;return!!(!((_e=S[He+qe])===null||_e===void 0)&&_e[Oe+$e])})),Ne._element&&Fe&&Fe.appendChild(Ne._element))}if((!((ne=l.cornersDotOptions)===null||ne===void 0)&&ne.gradient||!((de=l.cornersDotOptions)===null||de===void 0)&&de.color)&&(Me=this._window.document.createElementNS("http://www.w3.org/2000/svg","clipPath"),Me.setAttribute("id",`clip-path-corners-dot-color-${z}-${se}-${this._instanceId}`),this._defs.appendChild(Me),this._cornersDotClipPath=Me,this._createColor({options:(ce=l.cornersDotOptions)===null||ce===void 0?void 0:ce.gradient,color:(fe=l.cornersDotOptions)===null||fe===void 0?void 0:fe.color,additionalRotation:O,x:De+2*A,y:Te+2*A,height:w,width:w,name:`corners-dot-color-${z}-${se}-${this._instanceId}`})),(be=l.cornersDotOptions)===null||be===void 0?void 0:be.type){const Ne=new b({svg:this._element,type:l.cornersDotOptions.type,window:this._window});Ne.draw(De+2*A,Te+2*A,w,O),Ne._element&&Me&&Me.appendChild(Ne._element)}else{const Ne=new h({svg:this._element,type:l.dotsOptions.type,window:this._window});for(let He=0;He{var _e;return!!(!((_e=C[He+qe])===null||_e===void 0)&&_e[Oe+$e])})),Ne._element&&Me&&Me.appendChild(Ne._element))}}))}loadImage(){return new Promise(((v,l)=>{var p;const m=this._options;if(!m.image)return l("Image is not defined");if(!((p=m.nodeCanvas)===null||p===void 0)&&p.loadImage)m.nodeCanvas.loadImage(m.image).then((y=>{var A,E;if(this._image=y,this._options.imageOptions.saveAsBlob){const w=(A=m.nodeCanvas)===null||A===void 0?void 0:A.createCanvas(this._image.width,this._image.height);(E=w?.getContext("2d"))===null||E===void 0||E.drawImage(y,0,0),this._imageUri=w?.toDataURL()}v()})).catch(l);else{const y=new this._window.Image;typeof m.imageOptions.crossOrigin=="string"&&(y.crossOrigin=m.imageOptions.crossOrigin),this._image=y,y.onload=async()=>{this._options.imageOptions.saveAsBlob&&(this._imageUri=await(async function(A,E){return new Promise((w=>{const I=new E.XMLHttpRequest;I.onload=function(){const M=new E.FileReader;M.onloadend=function(){w(M.result)},M.readAsDataURL(I.response)},I.open("GET",A),I.responseType="blob",I.send()}))})(m.image||"",this._window)),v()},y.src=m.image}}))}async drawImage({width:v,height:l,count:p,dotSize:m}){const y=this._options,A=this._roundSize((y.width-p*m)/2),E=this._roundSize((y.height-p*m)/2),w=A+this._roundSize(y.imageOptions.margin+(p*m-v)/2),I=E+this._roundSize(y.imageOptions.margin+(p*m-l)/2),M=v-2*y.imageOptions.margin,z=l-2*y.imageOptions.margin,se=this._window.document.createElementNS("http://www.w3.org/2000/svg","image");se.setAttribute("href",this._imageUri||""),se.setAttribute("x",String(w)),se.setAttribute("y",String(I)),se.setAttribute("width",`${M}px`),se.setAttribute("height",`${z}px`),this._element.appendChild(se)}_createColor({options:v,color:l,additionalRotation:p,x:m,y,height:A,width:E,name:w}){const I=E>A?E:A,M=this._window.document.createElementNS("http://www.w3.org/2000/svg","rect");if(M.setAttribute("x",String(m)),M.setAttribute("y",String(y)),M.setAttribute("height",String(A)),M.setAttribute("width",String(E)),M.setAttribute("clip-path",`url('#clip-path-${w}')`),v){let z;if(v.type==="radial")z=this._window.document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),z.setAttribute("id",w),z.setAttribute("gradientUnits","userSpaceOnUse"),z.setAttribute("fx",String(m+E/2)),z.setAttribute("fy",String(y+A/2)),z.setAttribute("cx",String(m+E/2)),z.setAttribute("cy",String(y+A/2)),z.setAttribute("r",String(I/2));else{const se=((v.rotation||0)+p)%(2*Math.PI),O=(se+2*Math.PI)%(2*Math.PI);let ie=m+E/2,ee=y+A/2,Z=m+E/2,te=y+A/2;O>=0&&O<=.25*Math.PI||O>1.75*Math.PI&&O<=2*Math.PI?(ie-=E/2,ee-=A/2*Math.tan(se),Z+=E/2,te+=A/2*Math.tan(se)):O>.25*Math.PI&&O<=.75*Math.PI?(ee-=A/2,ie-=E/2/Math.tan(se),te+=A/2,Z+=E/2/Math.tan(se)):O>.75*Math.PI&&O<=1.25*Math.PI?(ie+=E/2,ee+=A/2*Math.tan(se),Z-=E/2,te-=A/2*Math.tan(se)):O>1.25*Math.PI&&O<=1.75*Math.PI&&(ee+=A/2,ie+=E/2/Math.tan(se),te-=A/2,Z-=E/2/Math.tan(se)),z=this._window.document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),z.setAttribute("id",w),z.setAttribute("gradientUnits","userSpaceOnUse"),z.setAttribute("x1",String(Math.round(ie))),z.setAttribute("y1",String(Math.round(ee))),z.setAttribute("x2",String(Math.round(Z))),z.setAttribute("y2",String(Math.round(te)))}v.colorStops.forEach((({offset:se,color:O})=>{const ie=this._window.document.createElementNS("http://www.w3.org/2000/svg","stop");ie.setAttribute("offset",100*se+"%"),ie.setAttribute("stop-color",O),z.appendChild(ie)})),M.setAttribute("fill",`url('#${w}')`),this._defs.appendChild(z)}else l&&M.setAttribute("fill",l);this._element.appendChild(M)}}D.instanceCount=0;const B=D,L="canvas",H={};for(let _=0;_<=40;_++)H[_]=_;const F={type:L,shape:"square",width:300,height:300,data:"",margin:0,qrOptions:{typeNumber:H[0],mode:void 0,errorCorrectionLevel:"Q"},imageOptions:{saveAsBlob:!0,hideBackgroundDots:!0,imageSize:.4,crossOrigin:void 0,margin:0},dotsOptions:{type:"square",color:"#000",roundSize:!0},backgroundOptions:{round:0,color:"#fff"}};function k(_){const v=Object.assign({},_);if(!v.colorStops||!v.colorStops.length)throw"Field 'colorStops' is required in gradient";return v.rotation?v.rotation=Number(v.rotation):v.rotation=0,v.colorStops=v.colorStops.map((l=>Object.assign(Object.assign({},l),{offset:Number(l.offset)}))),v}function $(_){const v=Object.assign({},_);return v.width=Number(v.width),v.height=Number(v.height),v.margin=Number(v.margin),v.imageOptions=Object.assign(Object.assign({},v.imageOptions),{hideBackgroundDots:!!v.imageOptions.hideBackgroundDots,imageSize:Number(v.imageOptions.imageSize),margin:Number(v.imageOptions.margin)}),v.margin>Math.min(v.width,v.height)&&(v.margin=Math.min(v.width,v.height)),v.dotsOptions=Object.assign({},v.dotsOptions),v.dotsOptions.gradient&&(v.dotsOptions.gradient=k(v.dotsOptions.gradient)),v.cornersSquareOptions&&(v.cornersSquareOptions=Object.assign({},v.cornersSquareOptions),v.cornersSquareOptions.gradient&&(v.cornersSquareOptions.gradient=k(v.cornersSquareOptions.gradient))),v.cornersDotOptions&&(v.cornersDotOptions=Object.assign({},v.cornersDotOptions),v.cornersDotOptions.gradient&&(v.cornersDotOptions.gradient=k(v.cornersDotOptions.gradient))),v.backgroundOptions&&(v.backgroundOptions=Object.assign({},v.backgroundOptions),v.backgroundOptions.gradient&&(v.backgroundOptions.gradient=k(v.backgroundOptions.gradient))),v}var R=i(873),W=i.n(R);function V(_){if(!_)throw new Error("Extension must be defined");_[0]==="."&&(_=_.substring(1));const v={bmp:"image/bmp",gif:"image/gif",ico:"image/vnd.microsoft.icon",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml",tif:"image/tiff",tiff:"image/tiff",webp:"image/webp",pdf:"application/pdf"}[_.toLowerCase()];if(!v)throw new Error(`Extension "${_}" is not supported`);return v}class X{constructor(v){v?.jsdom?this._window=new v.jsdom("",{resources:"usable"}).window:this._window=window,this._options=v?$(a(F,v)):F,this.update()}static _clearContainer(v){v&&(v.innerHTML="")}_setupSvg(){if(!this._qr)return;const v=new B(this._options,this._window);this._svg=v.getElement(),this._svgDrawingPromise=v.drawQR(this._qr).then((()=>{var l;this._svg&&((l=this._extension)===null||l===void 0||l.call(this,v.getElement(),this._options))}))}_setupCanvas(){var v,l;this._qr&&(!((v=this._options.nodeCanvas)===null||v===void 0)&&v.createCanvas?(this._nodeCanvas=this._options.nodeCanvas.createCanvas(this._options.width,this._options.height),this._nodeCanvas.width=this._options.width,this._nodeCanvas.height=this._options.height):(this._domCanvas=document.createElement("canvas"),this._domCanvas.width=this._options.width,this._domCanvas.height=this._options.height),this._setupSvg(),this._canvasDrawingPromise=(l=this._svgDrawingPromise)===null||l===void 0?void 0:l.then((()=>{var p;if(!this._svg)return;const m=this._svg,y=new this._window.XMLSerializer().serializeToString(m),A=btoa(y),E=`data:${V("svg")};base64,${A}`;if(!((p=this._options.nodeCanvas)===null||p===void 0)&&p.loadImage)return this._options.nodeCanvas.loadImage(E).then((w=>{var I,M;w.width=this._options.width,w.height=this._options.height,(M=(I=this._nodeCanvas)===null||I===void 0?void 0:I.getContext("2d"))===null||M===void 0||M.drawImage(w,0,0)}));{const w=new this._window.Image;return new Promise((I=>{w.onload=()=>{var M,z;(z=(M=this._domCanvas)===null||M===void 0?void 0:M.getContext("2d"))===null||z===void 0||z.drawImage(w,0,0),I()},w.src=E}))}})))}async _getElement(v="png"){if(!this._qr)throw"QR code is empty";return v.toLowerCase()==="svg"?(this._svg&&this._svgDrawingPromise||this._setupSvg(),await this._svgDrawingPromise,this._svg):((this._domCanvas||this._nodeCanvas)&&this._canvasDrawingPromise||this._setupCanvas(),await this._canvasDrawingPromise,this._domCanvas||this._nodeCanvas)}update(v){X._clearContainer(this._container),this._options=v?$(a(this._options,v)):this._options,this._options.data&&(this._qr=W()(this._options.qrOptions.typeNumber,this._options.qrOptions.errorCorrectionLevel),this._qr.addData(this._options.data,this._options.qrOptions.mode||(function(l){switch(!0){case/^[0-9]*$/.test(l):return"Numeric";case/^[0-9A-Z $%*+\-./:]*$/.test(l):return"Alphanumeric";default:return"Byte"}})(this._options.data)),this._qr.make(),this._options.type===L?this._setupCanvas():this._setupSvg(),this.append(this._container))}append(v){if(v){if(typeof v.appendChild!="function")throw"Container should be a single DOM node";this._options.type===L?this._domCanvas&&v.appendChild(this._domCanvas):this._svg&&v.appendChild(this._svg),this._container=v}}applyExtension(v){if(!v)throw"Extension function should be defined.";this._extension=v,this.update()}deleteExtension(){this._extension=void 0,this.update()}async getRawData(v="png"){if(!this._qr)throw"QR code is empty";const l=await this._getElement(v),p=V(v);if(!l)return null;if(v.toLowerCase()==="svg"){const m=`\r +${new this._window.XMLSerializer().serializeToString(l)}`;return typeof Blob>"u"||this._options.jsdom?Buffer.from(m):new Blob([m],{type:p})}return new Promise((m=>{const y=l;if("toBuffer"in y)if(p==="image/png")m(y.toBuffer(p));else if(p==="image/jpeg")m(y.toBuffer(p));else{if(p!=="application/pdf")throw Error("Unsupported extension");m(y.toBuffer(p))}else"toBlob"in y&&y.toBlob(m,p,1)}))}async download(v){if(!this._qr)throw"QR code is empty";if(typeof Blob>"u")throw"Cannot download in Node.js, call getRawData instead.";let l="png",p="qr";typeof v=="string"?(l=v,console.warn("Extension is deprecated as argument for 'download' method, please pass object { name: '...', extension: '...' } as argument")):typeof v=="object"&&v!==null&&(v.name&&(p=v.name),v.extension&&(l=v.extension));const m=await this._getElement(l);if(m)if(l.toLowerCase()==="svg"){let y=new XMLSerializer().serializeToString(m);y=`\r +`+y,f(`data:${V(l)};charset=utf-8,${encodeURIComponent(y)}`,`${p}.svg`)}else f(m.toDataURL(V(l)),`${p}.${l}`)}}const q=X})(),s.default})()))})(zd)),zd.exports}var pY=dY();const e7=Mi(pY);class Ko extends dt{constructor(e){const{docsPath:r,field:n,metaMessages:i}=e;super(`Invalid Sign-In with Ethereum message field "${n}".`,{docsPath:r,metaMessages:i,name:"SiweInvalidMessageFieldError"})}}function t7(t){if(/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(t)||/%[^0-9a-f]/i.test(t)||/%[0-9a-f](:?[^0-9a-f]|$)/i.test(t))return!1;const e=gY(t),r=e[1],n=e[2],i=e[3],s=e[4],o=e[5];if(!(r?.length&&i.length>=0))return!1;if(n?.length){if(!(i.length===0||/^\//.test(i)))return!1}else if(/^\/\//.test(i))return!1;if(!/^[a-z][a-z0-9\+\-\.]*$/.test(r.toLowerCase()))return!1;let a="";return a+=`${r}:`,n?.length&&(a+=`//${n}`),a+=i,s?.length&&(a+=`?${s}`),o?.length&&(a+=`#${o}`),a}function gY(t){return t.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}function r7(t){const{chainId:e,domain:r,expirationTime:n,issuedAt:i=new Date,nonce:s,notBefore:o,requestId:a,resources:f,scheme:u,uri:h,version:g}=t;{if(e!==Math.floor(e))throw new Ko({field:"chainId",metaMessages:["- Chain ID must be a EIP-155 chain ID.","- See https://eips.ethereum.org/EIPS/eip-155","",`Provided value: ${e}`]});if(!(mY.test(r)||vY.test(r)||bY.test(r)))throw new Ko({field:"domain",metaMessages:["- Domain must be an RFC 3986 authority.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${r}`]});if(!yY.test(s))throw new Ko({field:"nonce",metaMessages:["- Nonce must be at least 8 characters.","- Nonce must be alphanumeric.","",`Provided value: ${s}`]});if(!t7(h))throw new Ko({field:"uri",metaMessages:["- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${h}`]});if(g!=="1")throw new Ko({field:"version",metaMessages:["- Version must be '1'.","",`Provided value: ${g}`]});if(u&&!wY.test(u))throw new Ko({field:"scheme",metaMessages:["- Scheme must be an RFC 3986 URI scheme.","- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1","",`Provided value: ${u}`]});const B=t.statement;if(B?.includes(` +`))throw new Ko({field:"statement",metaMessages:["- Statement must not include '\\n'.","",`Provided value: ${B}`]})}const b=ip(t.address),x=u?`${u}://${r}`:r,S=t.statement?`${t.statement} +`:"",C=`${x} wants you to sign in with your Ethereum account: +${b} -${P}`;let D=`URI: ${d} +${S}`;let D=`URI: ${h} Version: ${g} Chain ID: ${e} Nonce: ${s} Issued At: ${i.toISOString()}`;if(n&&(D+=` Expiration Time: ${n.toISOString()}`),o&&(D+=` Not Before: ${o.toISOString()}`),a&&(D+=` -Request ID: ${a}`),u){let k=` -Resources:`;for(const $ of u){if(!w7($))throw new Sa({field:"resources",metaMessages:["- Every resource must be a RFC 3986 URI.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${$}`]});k+=` -- ${$}`}D+=k}return`${N} -${D}`}const tZ=/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/,rZ=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/,nZ=/^localhost(:[0-9]{1,5})?$/,iZ=/^[a-zA-Z0-9]{8,}$/,sZ=/^([a-zA-Z][a-zA-Z0-9+-.]*)$/,_7="7a4434fefbcc9af474fb5c995e47d286",oZ={projectId:_7,metadata:{name:"codatta",description:"codatta",url:"https://codatta.io/",icons:["https://avatars.githubusercontent.com/u/171659315"]}},aZ={namespaces:{eip155:{methods:["eth_sendTransaction","eth_signTransaction","eth_sign","personal_sign","eth_signTypedData"],chains:["eip155:1"],events:["chainChanged","accountsChanged","disconnect"],rpcMap:{1:`https://rpc.walletconnect.com?chainId=eip155:1&projectId=${_7}`}}},skipPairing:!1};function cZ(t,e){const r=window.location.host,n=window.location.href;return x7({address:t,chainId:1,domain:r,nonce:e,uri:n,version:"1"})}function uZ(t){var ue,_e,G;const e=Pe.useRef(null),{wallet:r,onGetExtension:n,onSignFinish:i}=t,[s,o]=Pe.useState(""),[a,u]=Pe.useState(!1),[l,d]=Pe.useState(""),[g,y]=Pe.useState("scan"),A=Pe.useRef(),[P,N]=Pe.useState((ue=r.config)==null?void 0:ue.image),[D,k]=Pe.useState(!1),{saveLastUsedWallet:$}=Wl();async function q(E){var f,p,v,x;u(!0);const m=await nz.init(oZ);m.session&&await m.disconnect();try{if(y("scan"),m.on("display_uri",ae=>{console.log("display_uri",ae),o(ae),u(!1),y("scan")}),m.on("error",ae=>{console.log(ae)}),m.on("session_update",ae=>{console.log("session_update",ae)}),!await m.connect(aZ))throw new Error("Walletconnect init failed");const S=new Hf(m);N(((f=S.config)==null?void 0:f.image)||((p=E.config)==null?void 0:p.image));const b=await S.getAddress(),M=await ma.getNonce({account_type:"block_chain"});console.log("get nonce",M);const I=cZ(b,M);y("sign");const F=await S.signMessage(I,b);y("waiting"),await i(S,{message:I,nonce:M,signature:F,address:b,wallet_name:((v=S.config)==null?void 0:v.name)||((x=E.config)==null?void 0:x.name)||""}),$(S)}catch(_){console.log("err",_),d(_.details||_.message)}}function U(){A.current=new y7({width:264,height:264,margin:0,type:"svg",qrOptions:{errorCorrectionLevel:"M"},dotsOptions:{color:"black",type:"rounded"},backgroundOptions:{color:"transparent"}}),A.current.append(e.current)}function K(E){var m;console.log(A.current),(m=A.current)==null||m.update({data:E})}Pe.useEffect(()=>{s&&K(s)},[s]),Pe.useEffect(()=>{q(r)},[r]),Pe.useEffect(()=>{U()},[]);function J(){d(""),K(""),q(r)}function T(){k(!0),navigator.clipboard.writeText(s),setTimeout(()=>{k(!1)},2500)}function z(){var f;const E=(f=r.config)==null?void 0:f.desktop_link;if(!E)return;const m=`${E}?uri=${encodeURIComponent(s)}`;window.open(m,"_blank")}return me.jsxs("div",{children:[me.jsx("div",{className:"xc-text-center",children:me.jsxs("div",{className:"xc-relative xc-mx-auto xc-mb-6 xc-block xc-max-h-[272px] xc-max-w-[272px] xc-rounded-xl xc-bg-white xc-p-1",children:[me.jsx("div",{className:"xc-aspect-[1/1] xc-flex xc-h-full xc-w-full xc-justify-center",ref:e}),me.jsx("div",{className:"xc-absolute xc-left-0 xc-top-0 xc-flex xc-h-full xc-w-full xc-items-center xc-justify-center",children:a?me.jsx(mc,{className:"xc-h-6 xc-w-6 xc-animate-spin xc-text-black",size:20}):me.jsx("img",{className:"xc-h-10 xc-w-10",src:P})})]})}),me.jsxs("div",{className:"xc-m-auto xc-mb-6 xc-flex xc-max-w-[400px] xc-flex-wrap xc-items-center xc-justify-between xc-gap-3",children:[me.jsx("button",{disabled:!s,onClick:T,className:"xc-disabled:hover-text-white xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black xc-disabled:cursor-not-allowed xc-disabled:opacity-40 xc-disabled:hover:bg-transparent",children:D?me.jsxs(me.Fragment,{children:[" ",me.jsx(SK,{})," Copied!"]}):me.jsxs(me.Fragment,{children:[me.jsx(MK,{}),"Copy QR URL"]})}),((_e=r.config)==null?void 0:_e.getWallet)&&me.jsxs("button",{className:"xc-rounded-2 xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black",onClick:n,children:[me.jsx(AK,{}),"Get Extension"]}),((G=r.config)==null?void 0:G.desktop_link)&&me.jsxs("button",{disabled:!s,className:"xc-rounded-2 xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black",onClick:z,children:[me.jsx(u8,{}),"Desktop"]})]}),me.jsx("div",{className:"xc-text-center",children:l?me.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center",children:[me.jsx("p",{className:"xc-text-danger xc-mb-2 xc-text-center",children:l}),me.jsx("button",{className:"xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1",onClick:J,children:"Retry"})]}):me.jsxs(me.Fragment,{children:[g==="scan"&&me.jsx("p",{children:"Scan this QR code from your mobile wallet or phone's camera to connect."}),g==="connect"&&me.jsx("p",{children:"Click connect in your wallet app"}),g==="sign"&&me.jsx("p",{children:"Click sign-in in your wallet to confirm you own this wallet."}),g==="waiting"&&me.jsx("div",{className:"xc-text-center",children:me.jsx(mc,{className:"xc-inline-block xc-animate-spin"})})]})})]})}const fZ="Accept connection request in the wallet",lZ="Accept sign-in request in your wallet";function hZ(t,e){const r=window.location.host,n=window.location.href;return x7({address:t,chainId:1,domain:r,nonce:e,uri:n,version:"1"})}function dZ(t){var g;const[e,r]=Pe.useState(),{wallet:n,onSignFinish:i}=t,s=Pe.useRef(),[o,a]=Pe.useState("connect"),{saveLastUsedWallet:u}=Wl();async function l(y){var A;try{a("connect");const P=await n.connect();if(!P||P.length===0)throw new Error("Wallet connect error");const N=hZ(P[0],y);a("sign");const D=await n.signMessage(N,P[0]);if(!D||D.length===0)throw new Error("user sign error");a("waiting"),await i(n,{address:P[0],signature:D,message:N,nonce:y,wallet_name:((A=n.config)==null?void 0:A.name)||""}),u(n)}catch(P){console.log(P.details),r(P.details||P.message)}}async function d(){try{r("");const y=await ma.getNonce({account_type:"block_chain"});s.current=y,l(s.current)}catch(y){console.log(y.details),r(y.message)}}return Pe.useEffect(()=>{d()},[]),me.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center xc-justify-center xc-gap-4",children:[me.jsx("img",{className:"xc-rounded-md xc-h-16 xc-w-16",src:(g=n.config)==null?void 0:g.image,alt:""}),e&&me.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center",children:[me.jsx("p",{className:"xc-text-danger xc-mb-2 xc-text-center",children:e}),me.jsx("div",{className:"xc-flex xc-gap-2",children:me.jsx("button",{className:"xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1",onClick:d,children:"Retry"})})]}),!e&&me.jsxs(me.Fragment,{children:[o==="connect"&&me.jsx("span",{className:"xc-text-center",children:fZ}),o==="sign"&&me.jsx("span",{className:"xc-text-center",children:lZ}),o==="waiting"&&me.jsx("span",{className:"xc-text-center",children:me.jsx(mc,{className:"xc-animate-spin"})})]})]})}const Ku="https://static.codatta.io/codatta-connect/wallet-icons.svg",pZ="https://itunes.apple.com/app/",gZ="https://play.google.com/store/apps/details?id=",mZ="https://chromewebstore.google.com/detail/",vZ="https://chromewebstore.google.com/detail/",bZ="https://addons.mozilla.org/en-US/firefox/addon/",yZ="https://microsoftedge.microsoft.com/addons/detail/";function Vu(t){const{icon:e,title:r,link:n}=t;return me.jsxs("a",{href:n,target:"_blank",className:"xc-flex xc-w-full xc-cursor-pointer xc-items-center xc-gap-2 xc-rounded-full xc-border xc-border-white xc-border-opacity-15 xc-px-6 xc-py-3 xc-transition-all xc-hover:bg-white xc-hover:bg-opacity-5",children:[me.jsx("img",{className:"xc-rounded-1 xc-h-6 xc-w-6",src:e,alt:""}),r,me.jsx(c8,{className:"xc-ml-auto xc-text-gray-400"})]})}function wZ(t){const e={appStoreLink:"",playStoreLink:"",chromeStoreLink:"",braveStoreLink:"",firefoxStoreLink:"",edgeStoreLink:""};return t!=null&&t.app_store_id&&(e.appStoreLink=`${pZ}${t.app_store_id}`),t!=null&&t.play_store_id&&(e.playStoreLink=`${gZ}${t.play_store_id}`),t!=null&&t.chrome_store_id&&(e.chromeStoreLink=`${mZ}${t.chrome_store_id}`),t!=null&&t.brave_store_id&&(e.braveStoreLink=`${vZ}${t.brave_store_id}`),t!=null&&t.firefox_addon_id&&(e.firefoxStoreLink=`${bZ}${t.firefox_addon_id}`),t!=null&&t.edge_addon_id&&(e.edgeStoreLink=`${yZ}${t.edge_addon_id}`),e}function xZ(t){var i,s,o;const{wallet:e}=t,r=(i=e.config)==null?void 0:i.getWallet,n=wZ(r);return me.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center",children:[me.jsx("img",{className:"xc-rounded-md xc-mb-2 xc-h-12 xc-w-12",src:(s=e.config)==null?void 0:s.image,alt:""}),me.jsxs("p",{className:"xc-text-lg xc-font-bold",children:["Install ",(o=e.config)==null?void 0:o.name," to connect"]}),me.jsx("p",{className:"xc-mb-6 xc-text-sm xc-text-gray-500",children:"Select from your preferred options below:"}),me.jsxs("div",{className:"xc-grid xc-w-full xc-grid-cols-1 xc-gap-3",children:[(r==null?void 0:r.chrome_store_id)&&me.jsx(Vu,{link:n.chromeStoreLink,icon:`${Ku}#chrome`,title:"Google Play Store"}),(r==null?void 0:r.app_store_id)&&me.jsx(Vu,{link:n.appStoreLink,icon:`${Ku}#apple-dark`,title:"Apple App Store"}),(r==null?void 0:r.play_store_id)&&me.jsx(Vu,{link:n.playStoreLink,icon:`${Ku}#android`,title:"Google Play Store"}),(r==null?void 0:r.edge_addon_id)&&me.jsx(Vu,{link:n.edgeStoreLink,icon:`${Ku}#edge`,title:"Microsoft Edge"}),(r==null?void 0:r.brave_store_id)&&me.jsx(Vu,{link:n.braveStoreLink,icon:`${Ku}#brave`,title:"Brave extension"}),(r==null?void 0:r.firefox_addon_id)&&me.jsx(Vu,{link:n.firefoxStoreLink,icon:`${Ku}#firefox`,title:"Mozilla Firefox"})]})]})}function _Z(t){const{wallet:e}=t,[r,n]=Pe.useState(e.installed?"connect":"qr"),i=Pb();async function s(o,a){var l;const u=await ma.walletLogin({account_type:"block_chain",account_enum:"C",connector:"codatta_wallet",inviter_code:i.inviterCode,wallet_name:((l=o.config)==null?void 0:l.name)||o.key,address:await o.getAddress(),chain:(await o.getChain()).toString(),nonce:a.nonce,signature:a.signature,message:a.message,source:{device:i.device,channel:i.channel,app:i.app}});await t.onLogin(u.data)}return me.jsxs(Ec,{children:[me.jsx("div",{className:"xc-mb-6",children:me.jsx(ah,{title:"Connect wallet",onBack:t.onBack})}),r==="qr"&&me.jsx(uZ,{wallet:e,onGetExtension:()=>n("get-extension"),onSignFinish:s}),r==="connect"&&me.jsx(dZ,{onShowQrCode:()=>n("qr"),wallet:e,onSignFinish:s}),r==="get-extension"&&me.jsx(xZ,{wallet:e})]})}function EZ(t){const{wallet:e,onClick:r}=t,n=me.jsx("img",{className:"xc-rounded-md xc-h-5 xc-w-5",src:e.imageUrl}),i=e.name||"";return me.jsx(_b,{icon:n,title:i,onClick:()=>r(e)})}function SZ(t){const{connector:e}=t,[r,n]=Pe.useState(),[i,s]=Pe.useState([]),o=Pe.useMemo(()=>r?i.filter(d=>d.name.toLowerCase().includes(r.toLowerCase())):i,[r,i]);function a(d){n(d.target.value)}async function u(){const d=await e.getWallets();s(d),console.log(d)}Pe.useEffect(()=>{u()},[]);function l(d){t.onSelect(d)}return me.jsxs(Ec,{children:[me.jsx("div",{className:"xc-mb-6",children:me.jsx(ah,{title:"Select wallet",onBack:t.onBack})}),me.jsxs("div",{className:"xc-mb-6 xc-flex xc-gap-3 xc-px-4 xc-py-2 xc-border xc-rounded-xl xc-w-full xc-overflow-hidden xc-items-center xc-border-opacity-15 xc-border-white focus-within:xc-border-opacity-40",children:[me.jsx(f8,{className:"xc-shrink-0 xc-opacity-50"}),me.jsx("input",{type:"text",className:"xc-flex-1 xc-bg-transparent xc-appearance-none xc-outline-none",placeholder:"Search wallet",onInput:a})]}),me.jsx("div",{className:"xc-mb-4 xc-flex xc-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar",children:o==null?void 0:o.map(d=>me.jsx(EZ,{wallet:d,onClick:l},d.name))})]})}var E7={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():(e.nacl||(e.nacl={}),e.nacl.util=r())})(nn,function(){var e={};function r(n){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(n))throw new TypeError("invalid encoding")}return e.decodeUTF8=function(n){if(typeof n!="string")throw new TypeError("expected string");var i,s=unescape(encodeURIComponent(n)),o=new Uint8Array(s.length);for(i=0;i"u"?typeof Buffer.from<"u"?(e.encodeBase64=function(n){return Buffer.from(n).toString("base64")},e.decodeBase64=function(n){return r(n),new Uint8Array(Array.prototype.slice.call(Buffer.from(n,"base64"),0))}):(e.encodeBase64=function(n){return new Buffer(n).toString("base64")},e.decodeBase64=function(n){return r(n),new Uint8Array(Array.prototype.slice.call(new Buffer(n,"base64"),0))}):(e.encodeBase64=function(n){var i,s=[],o=n.length;for(i=0;i>24&255,B[H+1]=V>>16&255,B[H+2]=V>>8&255,B[H+3]=V&255,B[H+4]=C>>24&255,B[H+5]=C>>16&255,B[H+6]=C>>8&255,B[H+7]=C&255}function N(B,H,V,C,Y){var j,oe=0;for(j=0;j>>8)-1}function D(B,H,V,C){return N(B,H,V,C,16)}function k(B,H,V,C){return N(B,H,V,C,32)}function $(B,H,V,C){for(var Y=C[0]&255|(C[1]&255)<<8|(C[2]&255)<<16|(C[3]&255)<<24,j=V[0]&255|(V[1]&255)<<8|(V[2]&255)<<16|(V[3]&255)<<24,oe=V[4]&255|(V[5]&255)<<8|(V[6]&255)<<16|(V[7]&255)<<24,pe=V[8]&255|(V[9]&255)<<8|(V[10]&255)<<16|(V[11]&255)<<24,xe=V[12]&255|(V[13]&255)<<8|(V[14]&255)<<16|(V[15]&255)<<24,Re=C[4]&255|(C[5]&255)<<8|(C[6]&255)<<16|(C[7]&255)<<24,De=H[0]&255|(H[1]&255)<<8|(H[2]&255)<<16|(H[3]&255)<<24,it=H[4]&255|(H[5]&255)<<8|(H[6]&255)<<16|(H[7]&255)<<24,je=H[8]&255|(H[9]&255)<<8|(H[10]&255)<<16|(H[11]&255)<<24,gt=H[12]&255|(H[13]&255)<<8|(H[14]&255)<<16|(H[15]&255)<<24,st=C[8]&255|(C[9]&255)<<8|(C[10]&255)<<16|(C[11]&255)<<24,tt=V[16]&255|(V[17]&255)<<8|(V[18]&255)<<16|(V[19]&255)<<24,At=V[20]&255|(V[21]&255)<<8|(V[22]&255)<<16|(V[23]&255)<<24,Rt=V[24]&255|(V[25]&255)<<8|(V[26]&255)<<16|(V[27]&255)<<24,Mt=V[28]&255|(V[29]&255)<<8|(V[30]&255)<<16|(V[31]&255)<<24,Et=C[12]&255|(C[13]&255)<<8|(C[14]&255)<<16|(C[15]&255)<<24,dt=Y,_t=j,ot=oe,wt=pe,lt=xe,at=Re,Se=De,Ae=it,Ge=je,Ue=gt,qe=st,Xe=tt,kt=At,Wt=Rt,Zt=Mt,Kt=Et,de,nr=0;nr<20;nr+=2)de=dt+kt|0,lt^=de<<7|de>>>25,de=lt+dt|0,Ge^=de<<9|de>>>23,de=Ge+lt|0,kt^=de<<13|de>>>19,de=kt+Ge|0,dt^=de<<18|de>>>14,de=at+_t|0,Ue^=de<<7|de>>>25,de=Ue+at|0,Wt^=de<<9|de>>>23,de=Wt+Ue|0,_t^=de<<13|de>>>19,de=_t+Wt|0,at^=de<<18|de>>>14,de=qe+Se|0,Zt^=de<<7|de>>>25,de=Zt+qe|0,ot^=de<<9|de>>>23,de=ot+Zt|0,Se^=de<<13|de>>>19,de=Se+ot|0,qe^=de<<18|de>>>14,de=Kt+Xe|0,wt^=de<<7|de>>>25,de=wt+Kt|0,Ae^=de<<9|de>>>23,de=Ae+wt|0,Xe^=de<<13|de>>>19,de=Xe+Ae|0,Kt^=de<<18|de>>>14,de=dt+wt|0,_t^=de<<7|de>>>25,de=_t+dt|0,ot^=de<<9|de>>>23,de=ot+_t|0,wt^=de<<13|de>>>19,de=wt+ot|0,dt^=de<<18|de>>>14,de=at+lt|0,Se^=de<<7|de>>>25,de=Se+at|0,Ae^=de<<9|de>>>23,de=Ae+Se|0,lt^=de<<13|de>>>19,de=lt+Ae|0,at^=de<<18|de>>>14,de=qe+Ue|0,Xe^=de<<7|de>>>25,de=Xe+qe|0,Ge^=de<<9|de>>>23,de=Ge+Xe|0,Ue^=de<<13|de>>>19,de=Ue+Ge|0,qe^=de<<18|de>>>14,de=Kt+Zt|0,kt^=de<<7|de>>>25,de=kt+Kt|0,Wt^=de<<9|de>>>23,de=Wt+kt|0,Zt^=de<<13|de>>>19,de=Zt+Wt|0,Kt^=de<<18|de>>>14;dt=dt+Y|0,_t=_t+j|0,ot=ot+oe|0,wt=wt+pe|0,lt=lt+xe|0,at=at+Re|0,Se=Se+De|0,Ae=Ae+it|0,Ge=Ge+je|0,Ue=Ue+gt|0,qe=qe+st|0,Xe=Xe+tt|0,kt=kt+At|0,Wt=Wt+Rt|0,Zt=Zt+Mt|0,Kt=Kt+Et|0,B[0]=dt>>>0&255,B[1]=dt>>>8&255,B[2]=dt>>>16&255,B[3]=dt>>>24&255,B[4]=_t>>>0&255,B[5]=_t>>>8&255,B[6]=_t>>>16&255,B[7]=_t>>>24&255,B[8]=ot>>>0&255,B[9]=ot>>>8&255,B[10]=ot>>>16&255,B[11]=ot>>>24&255,B[12]=wt>>>0&255,B[13]=wt>>>8&255,B[14]=wt>>>16&255,B[15]=wt>>>24&255,B[16]=lt>>>0&255,B[17]=lt>>>8&255,B[18]=lt>>>16&255,B[19]=lt>>>24&255,B[20]=at>>>0&255,B[21]=at>>>8&255,B[22]=at>>>16&255,B[23]=at>>>24&255,B[24]=Se>>>0&255,B[25]=Se>>>8&255,B[26]=Se>>>16&255,B[27]=Se>>>24&255,B[28]=Ae>>>0&255,B[29]=Ae>>>8&255,B[30]=Ae>>>16&255,B[31]=Ae>>>24&255,B[32]=Ge>>>0&255,B[33]=Ge>>>8&255,B[34]=Ge>>>16&255,B[35]=Ge>>>24&255,B[36]=Ue>>>0&255,B[37]=Ue>>>8&255,B[38]=Ue>>>16&255,B[39]=Ue>>>24&255,B[40]=qe>>>0&255,B[41]=qe>>>8&255,B[42]=qe>>>16&255,B[43]=qe>>>24&255,B[44]=Xe>>>0&255,B[45]=Xe>>>8&255,B[46]=Xe>>>16&255,B[47]=Xe>>>24&255,B[48]=kt>>>0&255,B[49]=kt>>>8&255,B[50]=kt>>>16&255,B[51]=kt>>>24&255,B[52]=Wt>>>0&255,B[53]=Wt>>>8&255,B[54]=Wt>>>16&255,B[55]=Wt>>>24&255,B[56]=Zt>>>0&255,B[57]=Zt>>>8&255,B[58]=Zt>>>16&255,B[59]=Zt>>>24&255,B[60]=Kt>>>0&255,B[61]=Kt>>>8&255,B[62]=Kt>>>16&255,B[63]=Kt>>>24&255}function q(B,H,V,C){for(var Y=C[0]&255|(C[1]&255)<<8|(C[2]&255)<<16|(C[3]&255)<<24,j=V[0]&255|(V[1]&255)<<8|(V[2]&255)<<16|(V[3]&255)<<24,oe=V[4]&255|(V[5]&255)<<8|(V[6]&255)<<16|(V[7]&255)<<24,pe=V[8]&255|(V[9]&255)<<8|(V[10]&255)<<16|(V[11]&255)<<24,xe=V[12]&255|(V[13]&255)<<8|(V[14]&255)<<16|(V[15]&255)<<24,Re=C[4]&255|(C[5]&255)<<8|(C[6]&255)<<16|(C[7]&255)<<24,De=H[0]&255|(H[1]&255)<<8|(H[2]&255)<<16|(H[3]&255)<<24,it=H[4]&255|(H[5]&255)<<8|(H[6]&255)<<16|(H[7]&255)<<24,je=H[8]&255|(H[9]&255)<<8|(H[10]&255)<<16|(H[11]&255)<<24,gt=H[12]&255|(H[13]&255)<<8|(H[14]&255)<<16|(H[15]&255)<<24,st=C[8]&255|(C[9]&255)<<8|(C[10]&255)<<16|(C[11]&255)<<24,tt=V[16]&255|(V[17]&255)<<8|(V[18]&255)<<16|(V[19]&255)<<24,At=V[20]&255|(V[21]&255)<<8|(V[22]&255)<<16|(V[23]&255)<<24,Rt=V[24]&255|(V[25]&255)<<8|(V[26]&255)<<16|(V[27]&255)<<24,Mt=V[28]&255|(V[29]&255)<<8|(V[30]&255)<<16|(V[31]&255)<<24,Et=C[12]&255|(C[13]&255)<<8|(C[14]&255)<<16|(C[15]&255)<<24,dt=Y,_t=j,ot=oe,wt=pe,lt=xe,at=Re,Se=De,Ae=it,Ge=je,Ue=gt,qe=st,Xe=tt,kt=At,Wt=Rt,Zt=Mt,Kt=Et,de,nr=0;nr<20;nr+=2)de=dt+kt|0,lt^=de<<7|de>>>25,de=lt+dt|0,Ge^=de<<9|de>>>23,de=Ge+lt|0,kt^=de<<13|de>>>19,de=kt+Ge|0,dt^=de<<18|de>>>14,de=at+_t|0,Ue^=de<<7|de>>>25,de=Ue+at|0,Wt^=de<<9|de>>>23,de=Wt+Ue|0,_t^=de<<13|de>>>19,de=_t+Wt|0,at^=de<<18|de>>>14,de=qe+Se|0,Zt^=de<<7|de>>>25,de=Zt+qe|0,ot^=de<<9|de>>>23,de=ot+Zt|0,Se^=de<<13|de>>>19,de=Se+ot|0,qe^=de<<18|de>>>14,de=Kt+Xe|0,wt^=de<<7|de>>>25,de=wt+Kt|0,Ae^=de<<9|de>>>23,de=Ae+wt|0,Xe^=de<<13|de>>>19,de=Xe+Ae|0,Kt^=de<<18|de>>>14,de=dt+wt|0,_t^=de<<7|de>>>25,de=_t+dt|0,ot^=de<<9|de>>>23,de=ot+_t|0,wt^=de<<13|de>>>19,de=wt+ot|0,dt^=de<<18|de>>>14,de=at+lt|0,Se^=de<<7|de>>>25,de=Se+at|0,Ae^=de<<9|de>>>23,de=Ae+Se|0,lt^=de<<13|de>>>19,de=lt+Ae|0,at^=de<<18|de>>>14,de=qe+Ue|0,Xe^=de<<7|de>>>25,de=Xe+qe|0,Ge^=de<<9|de>>>23,de=Ge+Xe|0,Ue^=de<<13|de>>>19,de=Ue+Ge|0,qe^=de<<18|de>>>14,de=Kt+Zt|0,kt^=de<<7|de>>>25,de=kt+Kt|0,Wt^=de<<9|de>>>23,de=Wt+kt|0,Zt^=de<<13|de>>>19,de=Zt+Wt|0,Kt^=de<<18|de>>>14;B[0]=dt>>>0&255,B[1]=dt>>>8&255,B[2]=dt>>>16&255,B[3]=dt>>>24&255,B[4]=at>>>0&255,B[5]=at>>>8&255,B[6]=at>>>16&255,B[7]=at>>>24&255,B[8]=qe>>>0&255,B[9]=qe>>>8&255,B[10]=qe>>>16&255,B[11]=qe>>>24&255,B[12]=Kt>>>0&255,B[13]=Kt>>>8&255,B[14]=Kt>>>16&255,B[15]=Kt>>>24&255,B[16]=Se>>>0&255,B[17]=Se>>>8&255,B[18]=Se>>>16&255,B[19]=Se>>>24&255,B[20]=Ae>>>0&255,B[21]=Ae>>>8&255,B[22]=Ae>>>16&255,B[23]=Ae>>>24&255,B[24]=Ge>>>0&255,B[25]=Ge>>>8&255,B[26]=Ge>>>16&255,B[27]=Ge>>>24&255,B[28]=Ue>>>0&255,B[29]=Ue>>>8&255,B[30]=Ue>>>16&255,B[31]=Ue>>>24&255}function U(B,H,V,C){$(B,H,V,C)}function K(B,H,V,C){q(B,H,V,C)}var J=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function T(B,H,V,C,Y,j,oe){var pe=new Uint8Array(16),xe=new Uint8Array(64),Re,De;for(De=0;De<16;De++)pe[De]=0;for(De=0;De<8;De++)pe[De]=j[De];for(;Y>=64;){for(U(xe,pe,oe,J),De=0;De<64;De++)B[H+De]=V[C+De]^xe[De];for(Re=1,De=8;De<16;De++)Re=Re+(pe[De]&255)|0,pe[De]=Re&255,Re>>>=8;Y-=64,H+=64,C+=64}if(Y>0)for(U(xe,pe,oe,J),De=0;De=64;){for(U(oe,j,Y,J),xe=0;xe<64;xe++)B[H+xe]=oe[xe];for(pe=1,xe=8;xe<16;xe++)pe=pe+(j[xe]&255)|0,j[xe]=pe&255,pe>>>=8;V-=64,H+=64}if(V>0)for(U(oe,j,Y,J),xe=0;xe>>13|V<<3)&8191,C=B[4]&255|(B[5]&255)<<8,this.r[2]=(V>>>10|C<<6)&7939,Y=B[6]&255|(B[7]&255)<<8,this.r[3]=(C>>>7|Y<<9)&8191,j=B[8]&255|(B[9]&255)<<8,this.r[4]=(Y>>>4|j<<12)&255,this.r[5]=j>>>1&8190,oe=B[10]&255|(B[11]&255)<<8,this.r[6]=(j>>>14|oe<<2)&8191,pe=B[12]&255|(B[13]&255)<<8,this.r[7]=(oe>>>11|pe<<5)&8065,xe=B[14]&255|(B[15]&255)<<8,this.r[8]=(pe>>>8|xe<<8)&8191,this.r[9]=xe>>>5&127,this.pad[0]=B[16]&255|(B[17]&255)<<8,this.pad[1]=B[18]&255|(B[19]&255)<<8,this.pad[2]=B[20]&255|(B[21]&255)<<8,this.pad[3]=B[22]&255|(B[23]&255)<<8,this.pad[4]=B[24]&255|(B[25]&255)<<8,this.pad[5]=B[26]&255|(B[27]&255)<<8,this.pad[6]=B[28]&255|(B[29]&255)<<8,this.pad[7]=B[30]&255|(B[31]&255)<<8};G.prototype.blocks=function(B,H,V){for(var C=this.fin?0:2048,Y,j,oe,pe,xe,Re,De,it,je,gt,st,tt,At,Rt,Mt,Et,dt,_t,ot,wt=this.h[0],lt=this.h[1],at=this.h[2],Se=this.h[3],Ae=this.h[4],Ge=this.h[5],Ue=this.h[6],qe=this.h[7],Xe=this.h[8],kt=this.h[9],Wt=this.r[0],Zt=this.r[1],Kt=this.r[2],de=this.r[3],nr=this.r[4],dr=this.r[5],pr=this.r[6],Qt=this.r[7],gr=this.r[8],lr=this.r[9];V>=16;)Y=B[H+0]&255|(B[H+1]&255)<<8,wt+=Y&8191,j=B[H+2]&255|(B[H+3]&255)<<8,lt+=(Y>>>13|j<<3)&8191,oe=B[H+4]&255|(B[H+5]&255)<<8,at+=(j>>>10|oe<<6)&8191,pe=B[H+6]&255|(B[H+7]&255)<<8,Se+=(oe>>>7|pe<<9)&8191,xe=B[H+8]&255|(B[H+9]&255)<<8,Ae+=(pe>>>4|xe<<12)&8191,Ge+=xe>>>1&8191,Re=B[H+10]&255|(B[H+11]&255)<<8,Ue+=(xe>>>14|Re<<2)&8191,De=B[H+12]&255|(B[H+13]&255)<<8,qe+=(Re>>>11|De<<5)&8191,it=B[H+14]&255|(B[H+15]&255)<<8,Xe+=(De>>>8|it<<8)&8191,kt+=it>>>5|C,je=0,gt=je,gt+=wt*Wt,gt+=lt*(5*lr),gt+=at*(5*gr),gt+=Se*(5*Qt),gt+=Ae*(5*pr),je=gt>>>13,gt&=8191,gt+=Ge*(5*dr),gt+=Ue*(5*nr),gt+=qe*(5*de),gt+=Xe*(5*Kt),gt+=kt*(5*Zt),je+=gt>>>13,gt&=8191,st=je,st+=wt*Zt,st+=lt*Wt,st+=at*(5*lr),st+=Se*(5*gr),st+=Ae*(5*Qt),je=st>>>13,st&=8191,st+=Ge*(5*pr),st+=Ue*(5*dr),st+=qe*(5*nr),st+=Xe*(5*de),st+=kt*(5*Kt),je+=st>>>13,st&=8191,tt=je,tt+=wt*Kt,tt+=lt*Zt,tt+=at*Wt,tt+=Se*(5*lr),tt+=Ae*(5*gr),je=tt>>>13,tt&=8191,tt+=Ge*(5*Qt),tt+=Ue*(5*pr),tt+=qe*(5*dr),tt+=Xe*(5*nr),tt+=kt*(5*de),je+=tt>>>13,tt&=8191,At=je,At+=wt*de,At+=lt*Kt,At+=at*Zt,At+=Se*Wt,At+=Ae*(5*lr),je=At>>>13,At&=8191,At+=Ge*(5*gr),At+=Ue*(5*Qt),At+=qe*(5*pr),At+=Xe*(5*dr),At+=kt*(5*nr),je+=At>>>13,At&=8191,Rt=je,Rt+=wt*nr,Rt+=lt*de,Rt+=at*Kt,Rt+=Se*Zt,Rt+=Ae*Wt,je=Rt>>>13,Rt&=8191,Rt+=Ge*(5*lr),Rt+=Ue*(5*gr),Rt+=qe*(5*Qt),Rt+=Xe*(5*pr),Rt+=kt*(5*dr),je+=Rt>>>13,Rt&=8191,Mt=je,Mt+=wt*dr,Mt+=lt*nr,Mt+=at*de,Mt+=Se*Kt,Mt+=Ae*Zt,je=Mt>>>13,Mt&=8191,Mt+=Ge*Wt,Mt+=Ue*(5*lr),Mt+=qe*(5*gr),Mt+=Xe*(5*Qt),Mt+=kt*(5*pr),je+=Mt>>>13,Mt&=8191,Et=je,Et+=wt*pr,Et+=lt*dr,Et+=at*nr,Et+=Se*de,Et+=Ae*Kt,je=Et>>>13,Et&=8191,Et+=Ge*Zt,Et+=Ue*Wt,Et+=qe*(5*lr),Et+=Xe*(5*gr),Et+=kt*(5*Qt),je+=Et>>>13,Et&=8191,dt=je,dt+=wt*Qt,dt+=lt*pr,dt+=at*dr,dt+=Se*nr,dt+=Ae*de,je=dt>>>13,dt&=8191,dt+=Ge*Kt,dt+=Ue*Zt,dt+=qe*Wt,dt+=Xe*(5*lr),dt+=kt*(5*gr),je+=dt>>>13,dt&=8191,_t=je,_t+=wt*gr,_t+=lt*Qt,_t+=at*pr,_t+=Se*dr,_t+=Ae*nr,je=_t>>>13,_t&=8191,_t+=Ge*de,_t+=Ue*Kt,_t+=qe*Zt,_t+=Xe*Wt,_t+=kt*(5*lr),je+=_t>>>13,_t&=8191,ot=je,ot+=wt*lr,ot+=lt*gr,ot+=at*Qt,ot+=Se*pr,ot+=Ae*dr,je=ot>>>13,ot&=8191,ot+=Ge*nr,ot+=Ue*de,ot+=qe*Kt,ot+=Xe*Zt,ot+=kt*Wt,je+=ot>>>13,ot&=8191,je=(je<<2)+je|0,je=je+gt|0,gt=je&8191,je=je>>>13,st+=je,wt=gt,lt=st,at=tt,Se=At,Ae=Rt,Ge=Mt,Ue=Et,qe=dt,Xe=_t,kt=ot,H+=16,V-=16;this.h[0]=wt,this.h[1]=lt,this.h[2]=at,this.h[3]=Se,this.h[4]=Ae,this.h[5]=Ge,this.h[6]=Ue,this.h[7]=qe,this.h[8]=Xe,this.h[9]=kt},G.prototype.finish=function(B,H){var V=new Uint16Array(10),C,Y,j,oe;if(this.leftover){for(oe=this.leftover,this.buffer[oe++]=1;oe<16;oe++)this.buffer[oe]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(C=this.h[1]>>>13,this.h[1]&=8191,oe=2;oe<10;oe++)this.h[oe]+=C,C=this.h[oe]>>>13,this.h[oe]&=8191;for(this.h[0]+=C*5,C=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=C,C=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=C,V[0]=this.h[0]+5,C=V[0]>>>13,V[0]&=8191,oe=1;oe<10;oe++)V[oe]=this.h[oe]+C,C=V[oe]>>>13,V[oe]&=8191;for(V[9]-=8192,Y=(C^1)-1,oe=0;oe<10;oe++)V[oe]&=Y;for(Y=~Y,oe=0;oe<10;oe++)this.h[oe]=this.h[oe]&Y|V[oe];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,j=this.h[0]+this.pad[0],this.h[0]=j&65535,oe=1;oe<8;oe++)j=(this.h[oe]+this.pad[oe]|0)+(j>>>16)|0,this.h[oe]=j&65535;B[H+0]=this.h[0]>>>0&255,B[H+1]=this.h[0]>>>8&255,B[H+2]=this.h[1]>>>0&255,B[H+3]=this.h[1]>>>8&255,B[H+4]=this.h[2]>>>0&255,B[H+5]=this.h[2]>>>8&255,B[H+6]=this.h[3]>>>0&255,B[H+7]=this.h[3]>>>8&255,B[H+8]=this.h[4]>>>0&255,B[H+9]=this.h[4]>>>8&255,B[H+10]=this.h[5]>>>0&255,B[H+11]=this.h[5]>>>8&255,B[H+12]=this.h[6]>>>0&255,B[H+13]=this.h[6]>>>8&255,B[H+14]=this.h[7]>>>0&255,B[H+15]=this.h[7]>>>8&255},G.prototype.update=function(B,H,V){var C,Y;if(this.leftover){for(Y=16-this.leftover,Y>V&&(Y=V),C=0;C=16&&(Y=V-V%16,this.blocks(B,H,Y),H+=Y,V-=Y),V){for(C=0;C>16&1),j[V-1]&=65535;j[15]=oe[15]-32767-(j[14]>>16&1),Y=j[15]>>16&1,j[14]&=65535,_(oe,j,1-Y)}for(V=0;V<16;V++)B[2*V]=oe[V]&255,B[2*V+1]=oe[V]>>8}function b(B,H){var V=new Uint8Array(32),C=new Uint8Array(32);return S(V,B),S(C,H),k(V,0,C,0)}function M(B){var H=new Uint8Array(32);return S(H,B),H[0]&1}function I(B,H){var V;for(V=0;V<16;V++)B[V]=H[2*V]+(H[2*V+1]<<8);B[15]&=32767}function F(B,H,V){for(var C=0;C<16;C++)B[C]=H[C]+V[C]}function ae(B,H,V){for(var C=0;C<16;C++)B[C]=H[C]-V[C]}function O(B,H,V){var C,Y,j=0,oe=0,pe=0,xe=0,Re=0,De=0,it=0,je=0,gt=0,st=0,tt=0,At=0,Rt=0,Mt=0,Et=0,dt=0,_t=0,ot=0,wt=0,lt=0,at=0,Se=0,Ae=0,Ge=0,Ue=0,qe=0,Xe=0,kt=0,Wt=0,Zt=0,Kt=0,de=V[0],nr=V[1],dr=V[2],pr=V[3],Qt=V[4],gr=V[5],lr=V[6],Lr=V[7],mr=V[8],wr=V[9],$r=V[10],Br=V[11],Ir=V[12],hn=V[13],dn=V[14],pn=V[15];C=H[0],j+=C*de,oe+=C*nr,pe+=C*dr,xe+=C*pr,Re+=C*Qt,De+=C*gr,it+=C*lr,je+=C*Lr,gt+=C*mr,st+=C*wr,tt+=C*$r,At+=C*Br,Rt+=C*Ir,Mt+=C*hn,Et+=C*dn,dt+=C*pn,C=H[1],oe+=C*de,pe+=C*nr,xe+=C*dr,Re+=C*pr,De+=C*Qt,it+=C*gr,je+=C*lr,gt+=C*Lr,st+=C*mr,tt+=C*wr,At+=C*$r,Rt+=C*Br,Mt+=C*Ir,Et+=C*hn,dt+=C*dn,_t+=C*pn,C=H[2],pe+=C*de,xe+=C*nr,Re+=C*dr,De+=C*pr,it+=C*Qt,je+=C*gr,gt+=C*lr,st+=C*Lr,tt+=C*mr,At+=C*wr,Rt+=C*$r,Mt+=C*Br,Et+=C*Ir,dt+=C*hn,_t+=C*dn,ot+=C*pn,C=H[3],xe+=C*de,Re+=C*nr,De+=C*dr,it+=C*pr,je+=C*Qt,gt+=C*gr,st+=C*lr,tt+=C*Lr,At+=C*mr,Rt+=C*wr,Mt+=C*$r,Et+=C*Br,dt+=C*Ir,_t+=C*hn,ot+=C*dn,wt+=C*pn,C=H[4],Re+=C*de,De+=C*nr,it+=C*dr,je+=C*pr,gt+=C*Qt,st+=C*gr,tt+=C*lr,At+=C*Lr,Rt+=C*mr,Mt+=C*wr,Et+=C*$r,dt+=C*Br,_t+=C*Ir,ot+=C*hn,wt+=C*dn,lt+=C*pn,C=H[5],De+=C*de,it+=C*nr,je+=C*dr,gt+=C*pr,st+=C*Qt,tt+=C*gr,At+=C*lr,Rt+=C*Lr,Mt+=C*mr,Et+=C*wr,dt+=C*$r,_t+=C*Br,ot+=C*Ir,wt+=C*hn,lt+=C*dn,at+=C*pn,C=H[6],it+=C*de,je+=C*nr,gt+=C*dr,st+=C*pr,tt+=C*Qt,At+=C*gr,Rt+=C*lr,Mt+=C*Lr,Et+=C*mr,dt+=C*wr,_t+=C*$r,ot+=C*Br,wt+=C*Ir,lt+=C*hn,at+=C*dn,Se+=C*pn,C=H[7],je+=C*de,gt+=C*nr,st+=C*dr,tt+=C*pr,At+=C*Qt,Rt+=C*gr,Mt+=C*lr,Et+=C*Lr,dt+=C*mr,_t+=C*wr,ot+=C*$r,wt+=C*Br,lt+=C*Ir,at+=C*hn,Se+=C*dn,Ae+=C*pn,C=H[8],gt+=C*de,st+=C*nr,tt+=C*dr,At+=C*pr,Rt+=C*Qt,Mt+=C*gr,Et+=C*lr,dt+=C*Lr,_t+=C*mr,ot+=C*wr,wt+=C*$r,lt+=C*Br,at+=C*Ir,Se+=C*hn,Ae+=C*dn,Ge+=C*pn,C=H[9],st+=C*de,tt+=C*nr,At+=C*dr,Rt+=C*pr,Mt+=C*Qt,Et+=C*gr,dt+=C*lr,_t+=C*Lr,ot+=C*mr,wt+=C*wr,lt+=C*$r,at+=C*Br,Se+=C*Ir,Ae+=C*hn,Ge+=C*dn,Ue+=C*pn,C=H[10],tt+=C*de,At+=C*nr,Rt+=C*dr,Mt+=C*pr,Et+=C*Qt,dt+=C*gr,_t+=C*lr,ot+=C*Lr,wt+=C*mr,lt+=C*wr,at+=C*$r,Se+=C*Br,Ae+=C*Ir,Ge+=C*hn,Ue+=C*dn,qe+=C*pn,C=H[11],At+=C*de,Rt+=C*nr,Mt+=C*dr,Et+=C*pr,dt+=C*Qt,_t+=C*gr,ot+=C*lr,wt+=C*Lr,lt+=C*mr,at+=C*wr,Se+=C*$r,Ae+=C*Br,Ge+=C*Ir,Ue+=C*hn,qe+=C*dn,Xe+=C*pn,C=H[12],Rt+=C*de,Mt+=C*nr,Et+=C*dr,dt+=C*pr,_t+=C*Qt,ot+=C*gr,wt+=C*lr,lt+=C*Lr,at+=C*mr,Se+=C*wr,Ae+=C*$r,Ge+=C*Br,Ue+=C*Ir,qe+=C*hn,Xe+=C*dn,kt+=C*pn,C=H[13],Mt+=C*de,Et+=C*nr,dt+=C*dr,_t+=C*pr,ot+=C*Qt,wt+=C*gr,lt+=C*lr,at+=C*Lr,Se+=C*mr,Ae+=C*wr,Ge+=C*$r,Ue+=C*Br,qe+=C*Ir,Xe+=C*hn,kt+=C*dn,Wt+=C*pn,C=H[14],Et+=C*de,dt+=C*nr,_t+=C*dr,ot+=C*pr,wt+=C*Qt,lt+=C*gr,at+=C*lr,Se+=C*Lr,Ae+=C*mr,Ge+=C*wr,Ue+=C*$r,qe+=C*Br,Xe+=C*Ir,kt+=C*hn,Wt+=C*dn,Zt+=C*pn,C=H[15],dt+=C*de,_t+=C*nr,ot+=C*dr,wt+=C*pr,lt+=C*Qt,at+=C*gr,Se+=C*lr,Ae+=C*Lr,Ge+=C*mr,Ue+=C*wr,qe+=C*$r,Xe+=C*Br,kt+=C*Ir,Wt+=C*hn,Zt+=C*dn,Kt+=C*pn,j+=38*_t,oe+=38*ot,pe+=38*wt,xe+=38*lt,Re+=38*at,De+=38*Se,it+=38*Ae,je+=38*Ge,gt+=38*Ue,st+=38*qe,tt+=38*Xe,At+=38*kt,Rt+=38*Wt,Mt+=38*Zt,Et+=38*Kt,Y=1,C=j+Y+65535,Y=Math.floor(C/65536),j=C-Y*65536,C=oe+Y+65535,Y=Math.floor(C/65536),oe=C-Y*65536,C=pe+Y+65535,Y=Math.floor(C/65536),pe=C-Y*65536,C=xe+Y+65535,Y=Math.floor(C/65536),xe=C-Y*65536,C=Re+Y+65535,Y=Math.floor(C/65536),Re=C-Y*65536,C=De+Y+65535,Y=Math.floor(C/65536),De=C-Y*65536,C=it+Y+65535,Y=Math.floor(C/65536),it=C-Y*65536,C=je+Y+65535,Y=Math.floor(C/65536),je=C-Y*65536,C=gt+Y+65535,Y=Math.floor(C/65536),gt=C-Y*65536,C=st+Y+65535,Y=Math.floor(C/65536),st=C-Y*65536,C=tt+Y+65535,Y=Math.floor(C/65536),tt=C-Y*65536,C=At+Y+65535,Y=Math.floor(C/65536),At=C-Y*65536,C=Rt+Y+65535,Y=Math.floor(C/65536),Rt=C-Y*65536,C=Mt+Y+65535,Y=Math.floor(C/65536),Mt=C-Y*65536,C=Et+Y+65535,Y=Math.floor(C/65536),Et=C-Y*65536,C=dt+Y+65535,Y=Math.floor(C/65536),dt=C-Y*65536,j+=Y-1+37*(Y-1),Y=1,C=j+Y+65535,Y=Math.floor(C/65536),j=C-Y*65536,C=oe+Y+65535,Y=Math.floor(C/65536),oe=C-Y*65536,C=pe+Y+65535,Y=Math.floor(C/65536),pe=C-Y*65536,C=xe+Y+65535,Y=Math.floor(C/65536),xe=C-Y*65536,C=Re+Y+65535,Y=Math.floor(C/65536),Re=C-Y*65536,C=De+Y+65535,Y=Math.floor(C/65536),De=C-Y*65536,C=it+Y+65535,Y=Math.floor(C/65536),it=C-Y*65536,C=je+Y+65535,Y=Math.floor(C/65536),je=C-Y*65536,C=gt+Y+65535,Y=Math.floor(C/65536),gt=C-Y*65536,C=st+Y+65535,Y=Math.floor(C/65536),st=C-Y*65536,C=tt+Y+65535,Y=Math.floor(C/65536),tt=C-Y*65536,C=At+Y+65535,Y=Math.floor(C/65536),At=C-Y*65536,C=Rt+Y+65535,Y=Math.floor(C/65536),Rt=C-Y*65536,C=Mt+Y+65535,Y=Math.floor(C/65536),Mt=C-Y*65536,C=Et+Y+65535,Y=Math.floor(C/65536),Et=C-Y*65536,C=dt+Y+65535,Y=Math.floor(C/65536),dt=C-Y*65536,j+=Y-1+37*(Y-1),B[0]=j,B[1]=oe,B[2]=pe,B[3]=xe,B[4]=Re,B[5]=De,B[6]=it,B[7]=je,B[8]=gt,B[9]=st,B[10]=tt,B[11]=At,B[12]=Rt,B[13]=Mt,B[14]=Et,B[15]=dt}function se(B,H){O(B,H,H)}function ee(B,H){var V=r(),C;for(C=0;C<16;C++)V[C]=H[C];for(C=253;C>=0;C--)se(V,V),C!==2&&C!==4&&O(V,V,H);for(C=0;C<16;C++)B[C]=V[C]}function X(B,H){var V=r(),C;for(C=0;C<16;C++)V[C]=H[C];for(C=250;C>=0;C--)se(V,V),C!==1&&O(V,V,H);for(C=0;C<16;C++)B[C]=V[C]}function Q(B,H,V){var C=new Uint8Array(32),Y=new Float64Array(80),j,oe,pe=r(),xe=r(),Re=r(),De=r(),it=r(),je=r();for(oe=0;oe<31;oe++)C[oe]=H[oe];for(C[31]=H[31]&127|64,C[0]&=248,I(Y,V),oe=0;oe<16;oe++)xe[oe]=Y[oe],De[oe]=pe[oe]=Re[oe]=0;for(pe[0]=De[0]=1,oe=254;oe>=0;--oe)j=C[oe>>>3]>>>(oe&7)&1,_(pe,xe,j),_(Re,De,j),F(it,pe,Re),ae(pe,pe,Re),F(Re,xe,De),ae(xe,xe,De),se(De,it),se(je,pe),O(pe,Re,pe),O(Re,xe,it),F(it,pe,Re),ae(pe,pe,Re),se(xe,pe),ae(Re,De,je),O(pe,Re,u),F(pe,pe,De),O(Re,Re,pe),O(pe,De,je),O(De,xe,Y),se(xe,it),_(pe,xe,j),_(Re,De,j);for(oe=0;oe<16;oe++)Y[oe+16]=pe[oe],Y[oe+32]=Re[oe],Y[oe+48]=xe[oe],Y[oe+64]=De[oe];var gt=Y.subarray(32),st=Y.subarray(16);return ee(gt,gt),O(st,st,gt),S(B,st),0}function R(B,H){return Q(B,H,s)}function Z(B,H){return n(H,32),R(B,H)}function te(B,H,V){var C=new Uint8Array(32);return Q(C,V,H),K(B,i,C,J)}var le=f,ie=p;function fe(B,H,V,C,Y,j){var oe=new Uint8Array(32);return te(oe,Y,j),le(B,H,V,C,oe)}function ve(B,H,V,C,Y,j){var oe=new Uint8Array(32);return te(oe,Y,j),ie(B,H,V,C,oe)}var Me=[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 Ne(B,H,V,C){for(var Y=new Int32Array(16),j=new Int32Array(16),oe,pe,xe,Re,De,it,je,gt,st,tt,At,Rt,Mt,Et,dt,_t,ot,wt,lt,at,Se,Ae,Ge,Ue,qe,Xe,kt=B[0],Wt=B[1],Zt=B[2],Kt=B[3],de=B[4],nr=B[5],dr=B[6],pr=B[7],Qt=H[0],gr=H[1],lr=H[2],Lr=H[3],mr=H[4],wr=H[5],$r=H[6],Br=H[7],Ir=0;C>=128;){for(lt=0;lt<16;lt++)at=8*lt+Ir,Y[lt]=V[at+0]<<24|V[at+1]<<16|V[at+2]<<8|V[at+3],j[lt]=V[at+4]<<24|V[at+5]<<16|V[at+6]<<8|V[at+7];for(lt=0;lt<80;lt++)if(oe=kt,pe=Wt,xe=Zt,Re=Kt,De=de,it=nr,je=dr,gt=pr,st=Qt,tt=gr,At=lr,Rt=Lr,Mt=mr,Et=wr,dt=$r,_t=Br,Se=pr,Ae=Br,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=(de>>>14|mr<<18)^(de>>>18|mr<<14)^(mr>>>9|de<<23),Ae=(mr>>>14|de<<18)^(mr>>>18|de<<14)^(de>>>9|mr<<23),Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Se=de&nr^~de&dr,Ae=mr&wr^~mr&$r,Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Se=Me[lt*2],Ae=Me[lt*2+1],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Se=Y[lt%16],Ae=j[lt%16],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,ot=qe&65535|Xe<<16,wt=Ge&65535|Ue<<16,Se=ot,Ae=wt,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=(kt>>>28|Qt<<4)^(Qt>>>2|kt<<30)^(Qt>>>7|kt<<25),Ae=(Qt>>>28|kt<<4)^(kt>>>2|Qt<<30)^(kt>>>7|Qt<<25),Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Se=kt&Wt^kt&Zt^Wt&Zt,Ae=Qt&gr^Qt&lr^gr&lr,Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,gt=qe&65535|Xe<<16,_t=Ge&65535|Ue<<16,Se=Re,Ae=Rt,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=ot,Ae=wt,Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,Re=qe&65535|Xe<<16,Rt=Ge&65535|Ue<<16,Wt=oe,Zt=pe,Kt=xe,de=Re,nr=De,dr=it,pr=je,kt=gt,gr=st,lr=tt,Lr=At,mr=Rt,wr=Mt,$r=Et,Br=dt,Qt=_t,lt%16===15)for(at=0;at<16;at++)Se=Y[at],Ae=j[at],Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=Y[(at+9)%16],Ae=j[(at+9)%16],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,ot=Y[(at+1)%16],wt=j[(at+1)%16],Se=(ot>>>1|wt<<31)^(ot>>>8|wt<<24)^ot>>>7,Ae=(wt>>>1|ot<<31)^(wt>>>8|ot<<24)^(wt>>>7|ot<<25),Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,ot=Y[(at+14)%16],wt=j[(at+14)%16],Se=(ot>>>19|wt<<13)^(wt>>>29|ot<<3)^ot>>>6,Ae=(wt>>>19|ot<<13)^(ot>>>29|wt<<3)^(wt>>>6|ot<<26),Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,Y[at]=qe&65535|Xe<<16,j[at]=Ge&65535|Ue<<16;Se=kt,Ae=Qt,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=B[0],Ae=H[0],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,B[0]=kt=qe&65535|Xe<<16,H[0]=Qt=Ge&65535|Ue<<16,Se=Wt,Ae=gr,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=B[1],Ae=H[1],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,B[1]=Wt=qe&65535|Xe<<16,H[1]=gr=Ge&65535|Ue<<16,Se=Zt,Ae=lr,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=B[2],Ae=H[2],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,B[2]=Zt=qe&65535|Xe<<16,H[2]=lr=Ge&65535|Ue<<16,Se=Kt,Ae=Lr,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=B[3],Ae=H[3],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,B[3]=Kt=qe&65535|Xe<<16,H[3]=Lr=Ge&65535|Ue<<16,Se=de,Ae=mr,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=B[4],Ae=H[4],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,B[4]=de=qe&65535|Xe<<16,H[4]=mr=Ge&65535|Ue<<16,Se=nr,Ae=wr,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=B[5],Ae=H[5],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,B[5]=nr=qe&65535|Xe<<16,H[5]=wr=Ge&65535|Ue<<16,Se=dr,Ae=$r,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=B[6],Ae=H[6],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,B[6]=dr=qe&65535|Xe<<16,H[6]=$r=Ge&65535|Ue<<16,Se=pr,Ae=Br,Ge=Ae&65535,Ue=Ae>>>16,qe=Se&65535,Xe=Se>>>16,Se=B[7],Ae=H[7],Ge+=Ae&65535,Ue+=Ae>>>16,qe+=Se&65535,Xe+=Se>>>16,Ue+=Ge>>>16,qe+=Ue>>>16,Xe+=qe>>>16,B[7]=pr=qe&65535|Xe<<16,H[7]=Br=Ge&65535|Ue<<16,Ir+=128,C-=128}return C}function Te(B,H,V){var C=new Int32Array(8),Y=new Int32Array(8),j=new Uint8Array(256),oe,pe=V;for(C[0]=1779033703,C[1]=3144134277,C[2]=1013904242,C[3]=2773480762,C[4]=1359893119,C[5]=2600822924,C[6]=528734635,C[7]=1541459225,Y[0]=4089235720,Y[1]=2227873595,Y[2]=4271175723,Y[3]=1595750129,Y[4]=2917565137,Y[5]=725511199,Y[6]=4215389547,Y[7]=327033209,Ne(C,Y,H,V),V%=128,oe=0;oe=0;--Y)C=V[Y/8|0]>>(Y&7)&1,Ie(B,H,C),Be(H,B),Be(B,B),Ie(B,H,C)}function ke(B,H){var V=[r(),r(),r(),r()];v(V[0],g),v(V[1],y),v(V[2],a),O(V[3],g,y),Ve(B,V,H)}function ze(B,H,V){var C=new Uint8Array(64),Y=[r(),r(),r(),r()],j;for(V||n(H,32),Te(C,H,32),C[0]&=248,C[31]&=127,C[31]|=64,ke(Y,C),Le(B,Y),j=0;j<32;j++)H[j+32]=B[j];return 0}var He=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 Ee(B,H){var V,C,Y,j;for(C=63;C>=32;--C){for(V=0,Y=C-32,j=C-12;Y>4)*He[Y],V=H[Y]>>8,H[Y]&=255;for(Y=0;Y<32;Y++)H[Y]-=V*He[Y];for(C=0;C<32;C++)H[C+1]+=H[C]>>8,B[C]=H[C]&255}function Qe(B){var H=new Float64Array(64),V;for(V=0;V<64;V++)H[V]=B[V];for(V=0;V<64;V++)B[V]=0;Ee(B,H)}function ct(B,H,V,C){var Y=new Uint8Array(64),j=new Uint8Array(64),oe=new Uint8Array(64),pe,xe,Re=new Float64Array(64),De=[r(),r(),r(),r()];Te(Y,C,32),Y[0]&=248,Y[31]&=127,Y[31]|=64;var it=V+64;for(pe=0;pe>7&&ae(B[0],o,B[0]),O(B[3],B[0],B[1]),0)}function et(B,H,V,C){var Y,j=new Uint8Array(32),oe=new Uint8Array(64),pe=[r(),r(),r(),r()],xe=[r(),r(),r(),r()];if(V<64||$e(xe,C))return-1;for(Y=0;Y=0},e.sign.keyPair=function(){var B=new Uint8Array(vt),H=new Uint8Array(Dt);return ze(B,H),{publicKey:B,secretKey:H}},e.sign.keyPair.fromSecretKey=function(B){if(nt(B),B.length!==Dt)throw new Error("bad secret key size");for(var H=new Uint8Array(vt),V=0;V=t.length)throw new Error("Index is out of buffer");const r=t.slice(0,e),n=t.slice(e);return[r,n]}function Mb(t){let e="";return t.forEach(r=>{e+=("0"+(r&255).toString(16)).slice(-2)}),e}function G0(t){if(t.length%2!==0)throw new Error(`Cannot convert ${t} to bytesArray`);const e=new Uint8Array(t.length/2);for(let r=0;r{o(y),f(!1),b("scan")}),X.on("error",y=>{console.log(y)}),X.on("session_update",y=>{console.log("session_update",y)}),!await X.connect(_Y))throw new Error("Walletconnect init failed");const _=new la(X);C(_.config?.image||V.config?.image);const v=await _.getAddress(),l=await Fo.getNonce({account_type:"block_chain"});console.log("get nonce",l);const p=EY(v,l);b("sign");const m=await _.signMessage(p,v);b("waiting"),await i(_,{message:p,nonce:l,signature:m,address:v,wallet_name:_.config?.name||V.config?.name||""}),console.log("save wallet connect wallet!"),L(_)}catch(q){console.log("err",q),h(q.details||q.message)}}function F(){x.current=new e7({width:264,height:264,margin:0,type:"svg",qrOptions:{errorCorrectionLevel:"M"},dotsOptions:{color:"black",type:"rounded"},backgroundOptions:{color:"transparent"}}),x.current.append(e.current)}function k(V){console.log(x.current),x.current?.update({data:V})}Se.useEffect(()=>{s&&k(s)},[s]),Se.useEffect(()=>{H(r)},[r]),Se.useEffect(()=>{F()},[]);function $(){h(""),k(""),H(r)}function R(){B(!0),navigator.clipboard.writeText(s),setTimeout(()=>{B(!1)},2500)}function W(){const V=r.config?.desktop_link;if(!V)return;const X=`${V}?uri=${encodeURIComponent(s)}`;window.open(X,"_blank")}return he.jsxs("div",{children:[he.jsx("div",{className:"xc-text-center",children:he.jsxs("div",{className:"xc-relative xc-mx-auto xc-mb-6 xc-block xc-max-h-[272px] xc-max-w-[272px] xc-rounded-xl xc-bg-white xc-p-1",children:[he.jsx("div",{className:"xc-aspect-[1/1] xc-flex xc-h-full xc-w-full xc-justify-center",ref:e}),he.jsx("div",{className:"xc-absolute xc-left-0 xc-top-0 xc-flex xc-h-full xc-w-full xc-items-center xc-justify-center",children:a?he.jsx(Fa,{className:"xc-h-6 xc-w-6 xc-animate-spin xc-text-black",size:20}):he.jsx("img",{className:"xc-h-10 xc-w-10",src:S})})]})}),he.jsxs("div",{className:"xc-m-auto xc-mb-6 xc-flex xc-max-w-[400px] xc-flex-wrap xc-items-center xc-justify-between xc-gap-3",children:[he.jsx("button",{disabled:!s,onClick:R,className:"xc-disabled:hover-text-white xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black xc-disabled:cursor-not-allowed xc-disabled:opacity-40 xc-disabled:hover:bg-transparent",children:D?he.jsxs(he.Fragment,{children:[" ",he.jsx(kz,{})," Copied!"]}):he.jsxs(he.Fragment,{children:[he.jsx(jz,{}),"Copy QR URL"]})}),r.config?.getWallet&&he.jsxs("button",{className:"xc-rounded-2 xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black",onClick:n,children:[he.jsx(Bz,{}),"Get Extension"]}),r.config?.desktop_link&&he.jsxs("button",{disabled:!s,className:"xc-rounded-2 xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black",onClick:W,children:[he.jsx($4,{}),"Desktop"]})]}),he.jsx("div",{className:"xc-text-center",children:u?he.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center",children:[he.jsx("p",{className:"xc-text-danger xc-mb-2 xc-text-center",children:u}),he.jsx("button",{className:"xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1",onClick:$,children:"Retry"})]}):he.jsxs(he.Fragment,{children:[g==="scan"&&he.jsx("p",{children:"Scan this QR code from your mobile wallet or phone's camera to connect."}),g==="connect"&&he.jsx("p",{children:"Click connect in your wallet app"}),g==="sign"&&he.jsx("p",{children:"Click sign-in in your wallet to confirm you own this wallet."}),g==="waiting"&&he.jsx("div",{className:"xc-text-center",children:he.jsx(Fa,{className:"xc-inline-block xc-animate-spin"})})]})})]})}const SY=CM({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),AY="Accept connection request in the wallet",PY="Accept sign-in request in your wallet";function IY(t,e,r){const n=window.location.host,i=window.location.href;return r7({address:t,chainId:r,domain:n,nonce:e,uri:i,version:"1"})}function s7(t){const[e,r]=Se.useState(),{wallet:n,onSignFinish:i}=t,s=Se.useRef(),[o,a]=Se.useState("connect"),{saveLastUsedWallet:f,chains:u}=Hf();async function h(b){try{a("connect");const x=await n.connect();if(!x||x.length===0)throw new Error("Wallet connect error");const S=await n.getChain(),C=u.find(F=>F.id===S),D=C||u[0]||SY;!C&&u.length>0&&(a("switch-chain"),await n.switchChain(D));const B=ip(x[0]),L=IY(B,b,D.id);a("sign");const H=await n.signMessage(L,B);if(!H||H.length===0)throw new Error("user sign error");a("waiting"),await i(n,{address:B,signature:H,message:L,nonce:b,wallet_name:n.config?.name||""}),f(n)}catch(x){console.log("walletSignin error",x.stack),console.log(x.details||x.message),r(x.details||x.message)}}async function g(){try{r("");const b=await Fo.getNonce({account_type:"block_chain"});s.current=b,h(s.current)}catch(b){console.log(b.details),r(b.message)}}return Se.useEffect(()=>{g()},[]),he.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center xc-justify-center xc-gap-4",children:[he.jsx("img",{className:"xc-rounded-md xc-h-16 xc-w-16",src:n.config?.image,alt:""}),e&&he.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center",children:[he.jsx("p",{className:"xc-text-danger xc-mb-2 xc-text-center",children:e}),he.jsx("div",{className:"xc-flex xc-gap-2",children:he.jsx("button",{className:"xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1",onClick:g,children:"Retry"})})]}),!e&&he.jsxs(he.Fragment,{children:[o==="connect"&&he.jsx("span",{className:"xc-text-center",children:AY}),o==="sign"&&he.jsx("span",{className:"xc-text-center",children:PY}),o==="waiting"&&he.jsx("span",{className:"xc-text-center",children:he.jsx(Fa,{className:"xc-animate-spin"})}),o==="switch-chain"&&he.jsxs("span",{className:"xc-text-center",children:["Switch to ",u[0].name]})]})]})}const Kc="https://static.codatta.io/codatta-connect/wallet-icons.svg",MY="https://itunes.apple.com/app/",CY="https://play.google.com/store/apps/details?id=",RY="https://chromewebstore.google.com/detail/",TY="https://chromewebstore.google.com/detail/",DY="https://addons.mozilla.org/en-US/firefox/addon/",OY="https://microsoftedge.microsoft.com/addons/detail/";function Vc(t){const{icon:e,title:r,link:n}=t;return he.jsxs("a",{href:n,target:"_blank",className:"xc-flex xc-w-full xc-cursor-pointer xc-items-center xc-gap-2 xc-rounded-full xc-border xc-border-white xc-border-opacity-15 xc-px-6 xc-py-3 xc-transition-all xc-hover:bg-white xc-hover:bg-opacity-5",children:[he.jsx("img",{className:"xc-rounded-1 xc-h-6 xc-w-6",src:e,alt:""}),r,he.jsx(U4,{className:"xc-ml-auto xc-text-gray-400"})]})}function NY(t){const e={appStoreLink:"",playStoreLink:"",chromeStoreLink:"",braveStoreLink:"",firefoxStoreLink:"",edgeStoreLink:""};return t?.app_store_id&&(e.appStoreLink=`${MY}${t.app_store_id}`),t?.play_store_id&&(e.playStoreLink=`${CY}${t.play_store_id}`),t?.chrome_store_id&&(e.chromeStoreLink=`${RY}${t.chrome_store_id}`),t?.brave_store_id&&(e.braveStoreLink=`${TY}${t.brave_store_id}`),t?.firefox_addon_id&&(e.firefoxStoreLink=`${DY}${t.firefox_addon_id}`),t?.edge_addon_id&&(e.edgeStoreLink=`${OY}${t.edge_addon_id}`),e}function o7(t){const{wallet:e}=t,r=e.config?.getWallet,n=NY(r);return he.jsxs("div",{className:"xc-flex xc-flex-col xc-items-center",children:[he.jsx("img",{className:"xc-rounded-md xc-mb-2 xc-h-12 xc-w-12",src:e.config?.image,alt:""}),he.jsxs("p",{className:"xc-text-lg xc-font-bold",children:["Install ",e.config?.name," to connect"]}),he.jsx("p",{className:"xc-mb-6 xc-text-sm xc-text-gray-500",children:"Select from your preferred options below:"}),he.jsxs("div",{className:"xc-grid xc-w-full xc-grid-cols-1 xc-gap-3",children:[r?.chrome_store_id&&he.jsx(Vc,{link:n.chromeStoreLink,icon:`${Kc}#chrome`,title:"Chrome Web Store"}),r?.app_store_id&&he.jsx(Vc,{link:n.appStoreLink,icon:`${Kc}#apple-dark`,title:"Apple App Store"}),r?.play_store_id&&he.jsx(Vc,{link:n.playStoreLink,icon:`${Kc}#android`,title:"Google Play Store"}),r?.edge_addon_id&&he.jsx(Vc,{link:n.edgeStoreLink,icon:`${Kc}#edge`,title:"Microsoft Edge"}),r?.brave_store_id&&he.jsx(Vc,{link:n.braveStoreLink,icon:`${Kc}#brave`,title:"Brave extension"}),r?.firefox_addon_id&&he.jsx(Vc,{link:n.firefoxStoreLink,icon:`${Kc}#firefox`,title:"Mozilla Firefox"})]})]})}function LY(t){const{wallet:e}=t,[r,n]=Se.useState(e.installed?"connect":"qr"),i=F1();async function s(o,a){const f=await Fo.walletLogin({account_type:"block_chain",account_enum:i.role,connector:"codatta_wallet",inviter_code:i.inviterCode,wallet_name:o.config?.name||o.key,address:await o.getAddress(),chain:(await o.getChain()).toString(),nonce:a.nonce,signature:a.signature,message:a.message,source:{device:i.device,channel:i.channel,app:i.app}});await t.onLogin(f.data)}return he.jsxs(ls,{children:[he.jsx("div",{className:"xc-mb-6",children:he.jsx(Wa,{title:"Connect wallet",onBack:t.onBack})}),r==="qr"&&he.jsx(i7,{wallet:e,onGetExtension:()=>n("get-extension"),onSignFinish:s}),r==="connect"&&he.jsx(s7,{onShowQrCode:()=>n("qr"),wallet:e,onSignFinish:s}),r==="get-extension"&&he.jsx(o7,{wallet:e})]})}function kY(t){const{wallet:e,onClick:r}=t,n=he.jsx("img",{className:"xc-rounded-md xc-h-5 xc-w-5",src:e.imageUrl}),i=e.name||"";return he.jsx(N1,{icon:n,title:i,onClick:()=>r(e)})}function a7(t){const{connector:e}=t,[r,n]=Se.useState(),[i,s]=Se.useState([]),o=Se.useMemo(()=>r?i.filter(h=>h.name.toLowerCase().includes(r.toLowerCase())):i,[r,i]);function a(h){n(h.target.value)}async function f(){const h=await e.getWallets();s(h)}Se.useEffect(()=>{f()},[]);function u(h){t.onSelect(h)}return he.jsxs(ls,{children:[he.jsx("div",{className:"xc-mb-6",children:he.jsx(Wa,{title:"Select wallet",onBack:t.onBack})}),he.jsxs("div",{className:"xc-mb-6 xc-flex xc-gap-3 xc-px-4 xc-py-2 xc-border xc-rounded-xl xc-w-full xc-overflow-hidden xc-items-center xc-border-opacity-15 xc-border-white focus-within:xc-border-opacity-40",children:[he.jsx(q4,{className:"xc-shrink-0 xc-opacity-50"}),he.jsx("input",{type:"text",className:"xc-flex-1 xc-bg-transparent xc-appearance-none xc-outline-none",placeholder:"Search wallet",onInput:a})]}),he.jsx("div",{className:"xc-mb-4 xc-flex xc-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar",children:o?.map(h=>he.jsx(kY,{wallet:h,onClick:u},h.name))})]})}var Hd={exports:{}},BY=Hd.exports,c7;function FY(){return c7||(c7=1,(function(t){(function(e,r){t.exports?t.exports=r():(e.nacl||(e.nacl={}),e.nacl.util=r())})(BY,function(){var e={};function r(n){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(n))throw new TypeError("invalid encoding")}return e.decodeUTF8=function(n){if(typeof n!="string")throw new TypeError("expected string");var i,s=unescape(encodeURIComponent(n)),o=new Uint8Array(s.length);for(i=0;i"u"?typeof Buffer.from<"u"?(e.encodeBase64=function(n){return Buffer.from(n).toString("base64")},e.decodeBase64=function(n){return r(n),new Uint8Array(Array.prototype.slice.call(Buffer.from(n,"base64"),0))}):(e.encodeBase64=function(n){return new Buffer(n).toString("base64")},e.decodeBase64=function(n){return r(n),new Uint8Array(Array.prototype.slice.call(new Buffer(n,"base64"),0))}):(e.encodeBase64=function(n){var i,s=[],o=n.length;for(i=0;i>24&255,K[G+1]=J>>16&255,K[G+2]=J>>8&255,K[G+3]=J&255,K[G+4]=T>>24&255,K[G+5]=T>>16&255,K[G+6]=T>>8&255,K[G+7]=T&255}function C(K,G,J,T,j){var oe,le=0;for(oe=0;oe>>8)-1}function D(K,G,J,T){return C(K,G,J,T,16)}function B(K,G,J,T){return C(K,G,J,T,32)}function L(K,G,J,T){for(var j=T[0]&255|(T[1]&255)<<8|(T[2]&255)<<16|(T[3]&255)<<24,oe=J[0]&255|(J[1]&255)<<8|(J[2]&255)<<16|(J[3]&255)<<24,le=J[4]&255|(J[5]&255)<<8|(J[6]&255)<<16|(J[7]&255)<<24,me=J[8]&255|(J[9]&255)<<8|(J[10]&255)<<16|(J[11]&255)<<24,Ee=J[12]&255|(J[13]&255)<<8|(J[14]&255)<<16|(J[15]&255)<<24,ke=T[4]&255|(T[5]&255)<<8|(T[6]&255)<<16|(T[7]&255)<<24,Ce=G[0]&255|(G[1]&255)<<8|(G[2]&255)<<16|(G[3]&255)<<24,et=G[4]&255|(G[5]&255)<<8|(G[6]&255)<<16|(G[7]&255)<<24,Ze=G[8]&255|(G[9]&255)<<8|(G[10]&255)<<16|(G[11]&255)<<24,rt=G[12]&255|(G[13]&255)<<8|(G[14]&255)<<16|(G[15]&255)<<24,ot=T[8]&255|(T[9]&255)<<8|(T[10]&255)<<16|(T[11]&255)<<24,yt=J[16]&255|(J[17]&255)<<8|(J[18]&255)<<16|(J[19]&255)<<24,Rt=J[20]&255|(J[21]&255)<<8|(J[22]&255)<<16|(J[23]&255)<<24,Mt=J[24]&255|(J[25]&255)<<8|(J[26]&255)<<16|(J[27]&255)<<24,xt=J[28]&255|(J[29]&255)<<8|(J[30]&255)<<16|(J[31]&255)<<24,Tt=T[12]&255|(T[13]&255)<<8|(T[14]&255)<<16|(T[15]&255)<<24,mt=j,Et=oe,ct=le,wt=me,lt=Ee,st=ke,Ae=Ce,Ie=et,Ve=Ze,Ue=rt,ze=ot,Je=yt,kt=Rt,Wt=Mt,Zt=xt,Kt=Tt,ge,ir=0;ir<20;ir+=2)ge=mt+kt|0,lt^=ge<<7|ge>>>25,ge=lt+mt|0,Ve^=ge<<9|ge>>>23,ge=Ve+lt|0,kt^=ge<<13|ge>>>19,ge=kt+Ve|0,mt^=ge<<18|ge>>>14,ge=st+Et|0,Ue^=ge<<7|ge>>>25,ge=Ue+st|0,Wt^=ge<<9|ge>>>23,ge=Wt+Ue|0,Et^=ge<<13|ge>>>19,ge=Et+Wt|0,st^=ge<<18|ge>>>14,ge=ze+Ae|0,Zt^=ge<<7|ge>>>25,ge=Zt+ze|0,ct^=ge<<9|ge>>>23,ge=ct+Zt|0,Ae^=ge<<13|ge>>>19,ge=Ae+ct|0,ze^=ge<<18|ge>>>14,ge=Kt+Je|0,wt^=ge<<7|ge>>>25,ge=wt+Kt|0,Ie^=ge<<9|ge>>>23,ge=Ie+wt|0,Je^=ge<<13|ge>>>19,ge=Je+Ie|0,Kt^=ge<<18|ge>>>14,ge=mt+wt|0,Et^=ge<<7|ge>>>25,ge=Et+mt|0,ct^=ge<<9|ge>>>23,ge=ct+Et|0,wt^=ge<<13|ge>>>19,ge=wt+ct|0,mt^=ge<<18|ge>>>14,ge=st+lt|0,Ae^=ge<<7|ge>>>25,ge=Ae+st|0,Ie^=ge<<9|ge>>>23,ge=Ie+Ae|0,lt^=ge<<13|ge>>>19,ge=lt+Ie|0,st^=ge<<18|ge>>>14,ge=ze+Ue|0,Je^=ge<<7|ge>>>25,ge=Je+ze|0,Ve^=ge<<9|ge>>>23,ge=Ve+Je|0,Ue^=ge<<13|ge>>>19,ge=Ue+Ve|0,ze^=ge<<18|ge>>>14,ge=Kt+Zt|0,kt^=ge<<7|ge>>>25,ge=kt+Kt|0,Wt^=ge<<9|ge>>>23,ge=Wt+kt|0,Zt^=ge<<13|ge>>>19,ge=Zt+Wt|0,Kt^=ge<<18|ge>>>14;mt=mt+j|0,Et=Et+oe|0,ct=ct+le|0,wt=wt+me|0,lt=lt+Ee|0,st=st+ke|0,Ae=Ae+Ce|0,Ie=Ie+et|0,Ve=Ve+Ze|0,Ue=Ue+rt|0,ze=ze+ot|0,Je=Je+yt|0,kt=kt+Rt|0,Wt=Wt+Mt|0,Zt=Zt+xt|0,Kt=Kt+Tt|0,K[0]=mt>>>0&255,K[1]=mt>>>8&255,K[2]=mt>>>16&255,K[3]=mt>>>24&255,K[4]=Et>>>0&255,K[5]=Et>>>8&255,K[6]=Et>>>16&255,K[7]=Et>>>24&255,K[8]=ct>>>0&255,K[9]=ct>>>8&255,K[10]=ct>>>16&255,K[11]=ct>>>24&255,K[12]=wt>>>0&255,K[13]=wt>>>8&255,K[14]=wt>>>16&255,K[15]=wt>>>24&255,K[16]=lt>>>0&255,K[17]=lt>>>8&255,K[18]=lt>>>16&255,K[19]=lt>>>24&255,K[20]=st>>>0&255,K[21]=st>>>8&255,K[22]=st>>>16&255,K[23]=st>>>24&255,K[24]=Ae>>>0&255,K[25]=Ae>>>8&255,K[26]=Ae>>>16&255,K[27]=Ae>>>24&255,K[28]=Ie>>>0&255,K[29]=Ie>>>8&255,K[30]=Ie>>>16&255,K[31]=Ie>>>24&255,K[32]=Ve>>>0&255,K[33]=Ve>>>8&255,K[34]=Ve>>>16&255,K[35]=Ve>>>24&255,K[36]=Ue>>>0&255,K[37]=Ue>>>8&255,K[38]=Ue>>>16&255,K[39]=Ue>>>24&255,K[40]=ze>>>0&255,K[41]=ze>>>8&255,K[42]=ze>>>16&255,K[43]=ze>>>24&255,K[44]=Je>>>0&255,K[45]=Je>>>8&255,K[46]=Je>>>16&255,K[47]=Je>>>24&255,K[48]=kt>>>0&255,K[49]=kt>>>8&255,K[50]=kt>>>16&255,K[51]=kt>>>24&255,K[52]=Wt>>>0&255,K[53]=Wt>>>8&255,K[54]=Wt>>>16&255,K[55]=Wt>>>24&255,K[56]=Zt>>>0&255,K[57]=Zt>>>8&255,K[58]=Zt>>>16&255,K[59]=Zt>>>24&255,K[60]=Kt>>>0&255,K[61]=Kt>>>8&255,K[62]=Kt>>>16&255,K[63]=Kt>>>24&255}function H(K,G,J,T){for(var j=T[0]&255|(T[1]&255)<<8|(T[2]&255)<<16|(T[3]&255)<<24,oe=J[0]&255|(J[1]&255)<<8|(J[2]&255)<<16|(J[3]&255)<<24,le=J[4]&255|(J[5]&255)<<8|(J[6]&255)<<16|(J[7]&255)<<24,me=J[8]&255|(J[9]&255)<<8|(J[10]&255)<<16|(J[11]&255)<<24,Ee=J[12]&255|(J[13]&255)<<8|(J[14]&255)<<16|(J[15]&255)<<24,ke=T[4]&255|(T[5]&255)<<8|(T[6]&255)<<16|(T[7]&255)<<24,Ce=G[0]&255|(G[1]&255)<<8|(G[2]&255)<<16|(G[3]&255)<<24,et=G[4]&255|(G[5]&255)<<8|(G[6]&255)<<16|(G[7]&255)<<24,Ze=G[8]&255|(G[9]&255)<<8|(G[10]&255)<<16|(G[11]&255)<<24,rt=G[12]&255|(G[13]&255)<<8|(G[14]&255)<<16|(G[15]&255)<<24,ot=T[8]&255|(T[9]&255)<<8|(T[10]&255)<<16|(T[11]&255)<<24,yt=J[16]&255|(J[17]&255)<<8|(J[18]&255)<<16|(J[19]&255)<<24,Rt=J[20]&255|(J[21]&255)<<8|(J[22]&255)<<16|(J[23]&255)<<24,Mt=J[24]&255|(J[25]&255)<<8|(J[26]&255)<<16|(J[27]&255)<<24,xt=J[28]&255|(J[29]&255)<<8|(J[30]&255)<<16|(J[31]&255)<<24,Tt=T[12]&255|(T[13]&255)<<8|(T[14]&255)<<16|(T[15]&255)<<24,mt=j,Et=oe,ct=le,wt=me,lt=Ee,st=ke,Ae=Ce,Ie=et,Ve=Ze,Ue=rt,ze=ot,Je=yt,kt=Rt,Wt=Mt,Zt=xt,Kt=Tt,ge,ir=0;ir<20;ir+=2)ge=mt+kt|0,lt^=ge<<7|ge>>>25,ge=lt+mt|0,Ve^=ge<<9|ge>>>23,ge=Ve+lt|0,kt^=ge<<13|ge>>>19,ge=kt+Ve|0,mt^=ge<<18|ge>>>14,ge=st+Et|0,Ue^=ge<<7|ge>>>25,ge=Ue+st|0,Wt^=ge<<9|ge>>>23,ge=Wt+Ue|0,Et^=ge<<13|ge>>>19,ge=Et+Wt|0,st^=ge<<18|ge>>>14,ge=ze+Ae|0,Zt^=ge<<7|ge>>>25,ge=Zt+ze|0,ct^=ge<<9|ge>>>23,ge=ct+Zt|0,Ae^=ge<<13|ge>>>19,ge=Ae+ct|0,ze^=ge<<18|ge>>>14,ge=Kt+Je|0,wt^=ge<<7|ge>>>25,ge=wt+Kt|0,Ie^=ge<<9|ge>>>23,ge=Ie+wt|0,Je^=ge<<13|ge>>>19,ge=Je+Ie|0,Kt^=ge<<18|ge>>>14,ge=mt+wt|0,Et^=ge<<7|ge>>>25,ge=Et+mt|0,ct^=ge<<9|ge>>>23,ge=ct+Et|0,wt^=ge<<13|ge>>>19,ge=wt+ct|0,mt^=ge<<18|ge>>>14,ge=st+lt|0,Ae^=ge<<7|ge>>>25,ge=Ae+st|0,Ie^=ge<<9|ge>>>23,ge=Ie+Ae|0,lt^=ge<<13|ge>>>19,ge=lt+Ie|0,st^=ge<<18|ge>>>14,ge=ze+Ue|0,Je^=ge<<7|ge>>>25,ge=Je+ze|0,Ve^=ge<<9|ge>>>23,ge=Ve+Je|0,Ue^=ge<<13|ge>>>19,ge=Ue+Ve|0,ze^=ge<<18|ge>>>14,ge=Kt+Zt|0,kt^=ge<<7|ge>>>25,ge=kt+Kt|0,Wt^=ge<<9|ge>>>23,ge=Wt+kt|0,Zt^=ge<<13|ge>>>19,ge=Zt+Wt|0,Kt^=ge<<18|ge>>>14;K[0]=mt>>>0&255,K[1]=mt>>>8&255,K[2]=mt>>>16&255,K[3]=mt>>>24&255,K[4]=st>>>0&255,K[5]=st>>>8&255,K[6]=st>>>16&255,K[7]=st>>>24&255,K[8]=ze>>>0&255,K[9]=ze>>>8&255,K[10]=ze>>>16&255,K[11]=ze>>>24&255,K[12]=Kt>>>0&255,K[13]=Kt>>>8&255,K[14]=Kt>>>16&255,K[15]=Kt>>>24&255,K[16]=Ae>>>0&255,K[17]=Ae>>>8&255,K[18]=Ae>>>16&255,K[19]=Ae>>>24&255,K[20]=Ie>>>0&255,K[21]=Ie>>>8&255,K[22]=Ie>>>16&255,K[23]=Ie>>>24&255,K[24]=Ve>>>0&255,K[25]=Ve>>>8&255,K[26]=Ve>>>16&255,K[27]=Ve>>>24&255,K[28]=Ue>>>0&255,K[29]=Ue>>>8&255,K[30]=Ue>>>16&255,K[31]=Ue>>>24&255}function F(K,G,J,T){L(K,G,J,T)}function k(K,G,J,T){H(K,G,J,T)}var $=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function R(K,G,J,T,j,oe,le){var me=new Uint8Array(16),Ee=new Uint8Array(64),ke,Ce;for(Ce=0;Ce<16;Ce++)me[Ce]=0;for(Ce=0;Ce<8;Ce++)me[Ce]=oe[Ce];for(;j>=64;){for(F(Ee,me,le,$),Ce=0;Ce<64;Ce++)K[G+Ce]=J[T+Ce]^Ee[Ce];for(ke=1,Ce=8;Ce<16;Ce++)ke=ke+(me[Ce]&255)|0,me[Ce]=ke&255,ke>>>=8;j-=64,G+=64,T+=64}if(j>0)for(F(Ee,me,le,$),Ce=0;Ce=64;){for(F(le,oe,j,$),Ee=0;Ee<64;Ee++)K[G+Ee]=le[Ee];for(me=1,Ee=8;Ee<16;Ee++)me=me+(oe[Ee]&255)|0,oe[Ee]=me&255,me>>>=8;J-=64,G+=64}if(J>0)for(F(le,oe,j,$),Ee=0;Ee>>13|J<<3)&8191,T=K[4]&255|(K[5]&255)<<8,this.r[2]=(J>>>10|T<<6)&7939,j=K[6]&255|(K[7]&255)<<8,this.r[3]=(T>>>7|j<<9)&8191,oe=K[8]&255|(K[9]&255)<<8,this.r[4]=(j>>>4|oe<<12)&255,this.r[5]=oe>>>1&8190,le=K[10]&255|(K[11]&255)<<8,this.r[6]=(oe>>>14|le<<2)&8191,me=K[12]&255|(K[13]&255)<<8,this.r[7]=(le>>>11|me<<5)&8065,Ee=K[14]&255|(K[15]&255)<<8,this.r[8]=(me>>>8|Ee<<8)&8191,this.r[9]=Ee>>>5&127,this.pad[0]=K[16]&255|(K[17]&255)<<8,this.pad[1]=K[18]&255|(K[19]&255)<<8,this.pad[2]=K[20]&255|(K[21]&255)<<8,this.pad[3]=K[22]&255|(K[23]&255)<<8,this.pad[4]=K[24]&255|(K[25]&255)<<8,this.pad[5]=K[26]&255|(K[27]&255)<<8,this.pad[6]=K[28]&255|(K[29]&255)<<8,this.pad[7]=K[30]&255|(K[31]&255)<<8};q.prototype.blocks=function(K,G,J){for(var T=this.fin?0:2048,j,oe,le,me,Ee,ke,Ce,et,Ze,rt,ot,yt,Rt,Mt,xt,Tt,mt,Et,ct,wt=this.h[0],lt=this.h[1],st=this.h[2],Ae=this.h[3],Ie=this.h[4],Ve=this.h[5],Ue=this.h[6],ze=this.h[7],Je=this.h[8],kt=this.h[9],Wt=this.r[0],Zt=this.r[1],Kt=this.r[2],ge=this.r[3],ir=this.r[4],gr=this.r[5],mr=this.r[6],Qt=this.r[7],vr=this.r[8],hr=this.r[9];J>=16;)j=K[G+0]&255|(K[G+1]&255)<<8,wt+=j&8191,oe=K[G+2]&255|(K[G+3]&255)<<8,lt+=(j>>>13|oe<<3)&8191,le=K[G+4]&255|(K[G+5]&255)<<8,st+=(oe>>>10|le<<6)&8191,me=K[G+6]&255|(K[G+7]&255)<<8,Ae+=(le>>>7|me<<9)&8191,Ee=K[G+8]&255|(K[G+9]&255)<<8,Ie+=(me>>>4|Ee<<12)&8191,Ve+=Ee>>>1&8191,ke=K[G+10]&255|(K[G+11]&255)<<8,Ue+=(Ee>>>14|ke<<2)&8191,Ce=K[G+12]&255|(K[G+13]&255)<<8,ze+=(ke>>>11|Ce<<5)&8191,et=K[G+14]&255|(K[G+15]&255)<<8,Je+=(Ce>>>8|et<<8)&8191,kt+=et>>>5|T,Ze=0,rt=Ze,rt+=wt*Wt,rt+=lt*(5*hr),rt+=st*(5*vr),rt+=Ae*(5*Qt),rt+=Ie*(5*mr),Ze=rt>>>13,rt&=8191,rt+=Ve*(5*gr),rt+=Ue*(5*ir),rt+=ze*(5*ge),rt+=Je*(5*Kt),rt+=kt*(5*Zt),Ze+=rt>>>13,rt&=8191,ot=Ze,ot+=wt*Zt,ot+=lt*Wt,ot+=st*(5*hr),ot+=Ae*(5*vr),ot+=Ie*(5*Qt),Ze=ot>>>13,ot&=8191,ot+=Ve*(5*mr),ot+=Ue*(5*gr),ot+=ze*(5*ir),ot+=Je*(5*ge),ot+=kt*(5*Kt),Ze+=ot>>>13,ot&=8191,yt=Ze,yt+=wt*Kt,yt+=lt*Zt,yt+=st*Wt,yt+=Ae*(5*hr),yt+=Ie*(5*vr),Ze=yt>>>13,yt&=8191,yt+=Ve*(5*Qt),yt+=Ue*(5*mr),yt+=ze*(5*gr),yt+=Je*(5*ir),yt+=kt*(5*ge),Ze+=yt>>>13,yt&=8191,Rt=Ze,Rt+=wt*ge,Rt+=lt*Kt,Rt+=st*Zt,Rt+=Ae*Wt,Rt+=Ie*(5*hr),Ze=Rt>>>13,Rt&=8191,Rt+=Ve*(5*vr),Rt+=Ue*(5*Qt),Rt+=ze*(5*mr),Rt+=Je*(5*gr),Rt+=kt*(5*ir),Ze+=Rt>>>13,Rt&=8191,Mt=Ze,Mt+=wt*ir,Mt+=lt*ge,Mt+=st*Kt,Mt+=Ae*Zt,Mt+=Ie*Wt,Ze=Mt>>>13,Mt&=8191,Mt+=Ve*(5*hr),Mt+=Ue*(5*vr),Mt+=ze*(5*Qt),Mt+=Je*(5*mr),Mt+=kt*(5*gr),Ze+=Mt>>>13,Mt&=8191,xt=Ze,xt+=wt*gr,xt+=lt*ir,xt+=st*ge,xt+=Ae*Kt,xt+=Ie*Zt,Ze=xt>>>13,xt&=8191,xt+=Ve*Wt,xt+=Ue*(5*hr),xt+=ze*(5*vr),xt+=Je*(5*Qt),xt+=kt*(5*mr),Ze+=xt>>>13,xt&=8191,Tt=Ze,Tt+=wt*mr,Tt+=lt*gr,Tt+=st*ir,Tt+=Ae*ge,Tt+=Ie*Kt,Ze=Tt>>>13,Tt&=8191,Tt+=Ve*Zt,Tt+=Ue*Wt,Tt+=ze*(5*hr),Tt+=Je*(5*vr),Tt+=kt*(5*Qt),Ze+=Tt>>>13,Tt&=8191,mt=Ze,mt+=wt*Qt,mt+=lt*mr,mt+=st*gr,mt+=Ae*ir,mt+=Ie*ge,Ze=mt>>>13,mt&=8191,mt+=Ve*Kt,mt+=Ue*Zt,mt+=ze*Wt,mt+=Je*(5*hr),mt+=kt*(5*vr),Ze+=mt>>>13,mt&=8191,Et=Ze,Et+=wt*vr,Et+=lt*Qt,Et+=st*mr,Et+=Ae*gr,Et+=Ie*ir,Ze=Et>>>13,Et&=8191,Et+=Ve*ge,Et+=Ue*Kt,Et+=ze*Zt,Et+=Je*Wt,Et+=kt*(5*hr),Ze+=Et>>>13,Et&=8191,ct=Ze,ct+=wt*hr,ct+=lt*vr,ct+=st*Qt,ct+=Ae*mr,ct+=Ie*gr,Ze=ct>>>13,ct&=8191,ct+=Ve*ir,ct+=Ue*ge,ct+=ze*Kt,ct+=Je*Zt,ct+=kt*Wt,Ze+=ct>>>13,ct&=8191,Ze=(Ze<<2)+Ze|0,Ze=Ze+rt|0,rt=Ze&8191,Ze=Ze>>>13,ot+=Ze,wt=rt,lt=ot,st=yt,Ae=Rt,Ie=Mt,Ve=xt,Ue=Tt,ze=mt,Je=Et,kt=ct,G+=16,J-=16;this.h[0]=wt,this.h[1]=lt,this.h[2]=st,this.h[3]=Ae,this.h[4]=Ie,this.h[5]=Ve,this.h[6]=Ue,this.h[7]=ze,this.h[8]=Je,this.h[9]=kt},q.prototype.finish=function(K,G){var J=new Uint16Array(10),T,j,oe,le;if(this.leftover){for(le=this.leftover,this.buffer[le++]=1;le<16;le++)this.buffer[le]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(T=this.h[1]>>>13,this.h[1]&=8191,le=2;le<10;le++)this.h[le]+=T,T=this.h[le]>>>13,this.h[le]&=8191;for(this.h[0]+=T*5,T=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=T,T=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=T,J[0]=this.h[0]+5,T=J[0]>>>13,J[0]&=8191,le=1;le<10;le++)J[le]=this.h[le]+T,T=J[le]>>>13,J[le]&=8191;for(J[9]-=8192,j=(T^1)-1,le=0;le<10;le++)J[le]&=j;for(j=~j,le=0;le<10;le++)this.h[le]=this.h[le]&j|J[le];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,oe=this.h[0]+this.pad[0],this.h[0]=oe&65535,le=1;le<8;le++)oe=(this.h[le]+this.pad[le]|0)+(oe>>>16)|0,this.h[le]=oe&65535;K[G+0]=this.h[0]>>>0&255,K[G+1]=this.h[0]>>>8&255,K[G+2]=this.h[1]>>>0&255,K[G+3]=this.h[1]>>>8&255,K[G+4]=this.h[2]>>>0&255,K[G+5]=this.h[2]>>>8&255,K[G+6]=this.h[3]>>>0&255,K[G+7]=this.h[3]>>>8&255,K[G+8]=this.h[4]>>>0&255,K[G+9]=this.h[4]>>>8&255,K[G+10]=this.h[5]>>>0&255,K[G+11]=this.h[5]>>>8&255,K[G+12]=this.h[6]>>>0&255,K[G+13]=this.h[6]>>>8&255,K[G+14]=this.h[7]>>>0&255,K[G+15]=this.h[7]>>>8&255},q.prototype.update=function(K,G,J){var T,j;if(this.leftover){for(j=16-this.leftover,j>J&&(j=J),T=0;T=16&&(j=J-J%16,this.blocks(K,G,j),G+=j,J-=j),J){for(T=0;T>16&1),oe[J-1]&=65535;oe[15]=le[15]-32767-(oe[14]>>16&1),j=oe[15]>>16&1,oe[14]&=65535,A(le,oe,1-j)}for(J=0;J<16;J++)K[2*J]=le[J]&255,K[2*J+1]=le[J]>>8}function w(K,G){var J=new Uint8Array(32),T=new Uint8Array(32);return E(J,K),E(T,G),B(J,0,T,0)}function I(K){var G=new Uint8Array(32);return E(G,K),G[0]&1}function M(K,G){var J;for(J=0;J<16;J++)K[J]=G[2*J]+(G[2*J+1]<<8);K[15]&=32767}function z(K,G,J){for(var T=0;T<16;T++)K[T]=G[T]+J[T]}function se(K,G,J){for(var T=0;T<16;T++)K[T]=G[T]-J[T]}function O(K,G,J){var T,j,oe=0,le=0,me=0,Ee=0,ke=0,Ce=0,et=0,Ze=0,rt=0,ot=0,yt=0,Rt=0,Mt=0,xt=0,Tt=0,mt=0,Et=0,ct=0,wt=0,lt=0,st=0,Ae=0,Ie=0,Ve=0,Ue=0,ze=0,Je=0,kt=0,Wt=0,Zt=0,Kt=0,ge=J[0],ir=J[1],gr=J[2],mr=J[3],Qt=J[4],vr=J[5],hr=J[6],Lr=J[7],br=J[8],xr=J[9],Fr=J[10],jr=J[11],Mr=J[12],un=J[13],fn=J[14],ln=J[15];T=G[0],oe+=T*ge,le+=T*ir,me+=T*gr,Ee+=T*mr,ke+=T*Qt,Ce+=T*vr,et+=T*hr,Ze+=T*Lr,rt+=T*br,ot+=T*xr,yt+=T*Fr,Rt+=T*jr,Mt+=T*Mr,xt+=T*un,Tt+=T*fn,mt+=T*ln,T=G[1],le+=T*ge,me+=T*ir,Ee+=T*gr,ke+=T*mr,Ce+=T*Qt,et+=T*vr,Ze+=T*hr,rt+=T*Lr,ot+=T*br,yt+=T*xr,Rt+=T*Fr,Mt+=T*jr,xt+=T*Mr,Tt+=T*un,mt+=T*fn,Et+=T*ln,T=G[2],me+=T*ge,Ee+=T*ir,ke+=T*gr,Ce+=T*mr,et+=T*Qt,Ze+=T*vr,rt+=T*hr,ot+=T*Lr,yt+=T*br,Rt+=T*xr,Mt+=T*Fr,xt+=T*jr,Tt+=T*Mr,mt+=T*un,Et+=T*fn,ct+=T*ln,T=G[3],Ee+=T*ge,ke+=T*ir,Ce+=T*gr,et+=T*mr,Ze+=T*Qt,rt+=T*vr,ot+=T*hr,yt+=T*Lr,Rt+=T*br,Mt+=T*xr,xt+=T*Fr,Tt+=T*jr,mt+=T*Mr,Et+=T*un,ct+=T*fn,wt+=T*ln,T=G[4],ke+=T*ge,Ce+=T*ir,et+=T*gr,Ze+=T*mr,rt+=T*Qt,ot+=T*vr,yt+=T*hr,Rt+=T*Lr,Mt+=T*br,xt+=T*xr,Tt+=T*Fr,mt+=T*jr,Et+=T*Mr,ct+=T*un,wt+=T*fn,lt+=T*ln,T=G[5],Ce+=T*ge,et+=T*ir,Ze+=T*gr,rt+=T*mr,ot+=T*Qt,yt+=T*vr,Rt+=T*hr,Mt+=T*Lr,xt+=T*br,Tt+=T*xr,mt+=T*Fr,Et+=T*jr,ct+=T*Mr,wt+=T*un,lt+=T*fn,st+=T*ln,T=G[6],et+=T*ge,Ze+=T*ir,rt+=T*gr,ot+=T*mr,yt+=T*Qt,Rt+=T*vr,Mt+=T*hr,xt+=T*Lr,Tt+=T*br,mt+=T*xr,Et+=T*Fr,ct+=T*jr,wt+=T*Mr,lt+=T*un,st+=T*fn,Ae+=T*ln,T=G[7],Ze+=T*ge,rt+=T*ir,ot+=T*gr,yt+=T*mr,Rt+=T*Qt,Mt+=T*vr,xt+=T*hr,Tt+=T*Lr,mt+=T*br,Et+=T*xr,ct+=T*Fr,wt+=T*jr,lt+=T*Mr,st+=T*un,Ae+=T*fn,Ie+=T*ln,T=G[8],rt+=T*ge,ot+=T*ir,yt+=T*gr,Rt+=T*mr,Mt+=T*Qt,xt+=T*vr,Tt+=T*hr,mt+=T*Lr,Et+=T*br,ct+=T*xr,wt+=T*Fr,lt+=T*jr,st+=T*Mr,Ae+=T*un,Ie+=T*fn,Ve+=T*ln,T=G[9],ot+=T*ge,yt+=T*ir,Rt+=T*gr,Mt+=T*mr,xt+=T*Qt,Tt+=T*vr,mt+=T*hr,Et+=T*Lr,ct+=T*br,wt+=T*xr,lt+=T*Fr,st+=T*jr,Ae+=T*Mr,Ie+=T*un,Ve+=T*fn,Ue+=T*ln,T=G[10],yt+=T*ge,Rt+=T*ir,Mt+=T*gr,xt+=T*mr,Tt+=T*Qt,mt+=T*vr,Et+=T*hr,ct+=T*Lr,wt+=T*br,lt+=T*xr,st+=T*Fr,Ae+=T*jr,Ie+=T*Mr,Ve+=T*un,Ue+=T*fn,ze+=T*ln,T=G[11],Rt+=T*ge,Mt+=T*ir,xt+=T*gr,Tt+=T*mr,mt+=T*Qt,Et+=T*vr,ct+=T*hr,wt+=T*Lr,lt+=T*br,st+=T*xr,Ae+=T*Fr,Ie+=T*jr,Ve+=T*Mr,Ue+=T*un,ze+=T*fn,Je+=T*ln,T=G[12],Mt+=T*ge,xt+=T*ir,Tt+=T*gr,mt+=T*mr,Et+=T*Qt,ct+=T*vr,wt+=T*hr,lt+=T*Lr,st+=T*br,Ae+=T*xr,Ie+=T*Fr,Ve+=T*jr,Ue+=T*Mr,ze+=T*un,Je+=T*fn,kt+=T*ln,T=G[13],xt+=T*ge,Tt+=T*ir,mt+=T*gr,Et+=T*mr,ct+=T*Qt,wt+=T*vr,lt+=T*hr,st+=T*Lr,Ae+=T*br,Ie+=T*xr,Ve+=T*Fr,Ue+=T*jr,ze+=T*Mr,Je+=T*un,kt+=T*fn,Wt+=T*ln,T=G[14],Tt+=T*ge,mt+=T*ir,Et+=T*gr,ct+=T*mr,wt+=T*Qt,lt+=T*vr,st+=T*hr,Ae+=T*Lr,Ie+=T*br,Ve+=T*xr,Ue+=T*Fr,ze+=T*jr,Je+=T*Mr,kt+=T*un,Wt+=T*fn,Zt+=T*ln,T=G[15],mt+=T*ge,Et+=T*ir,ct+=T*gr,wt+=T*mr,lt+=T*Qt,st+=T*vr,Ae+=T*hr,Ie+=T*Lr,Ve+=T*br,Ue+=T*xr,ze+=T*Fr,Je+=T*jr,kt+=T*Mr,Wt+=T*un,Zt+=T*fn,Kt+=T*ln,oe+=38*Et,le+=38*ct,me+=38*wt,Ee+=38*lt,ke+=38*st,Ce+=38*Ae,et+=38*Ie,Ze+=38*Ve,rt+=38*Ue,ot+=38*ze,yt+=38*Je,Rt+=38*kt,Mt+=38*Wt,xt+=38*Zt,Tt+=38*Kt,j=1,T=oe+j+65535,j=Math.floor(T/65536),oe=T-j*65536,T=le+j+65535,j=Math.floor(T/65536),le=T-j*65536,T=me+j+65535,j=Math.floor(T/65536),me=T-j*65536,T=Ee+j+65535,j=Math.floor(T/65536),Ee=T-j*65536,T=ke+j+65535,j=Math.floor(T/65536),ke=T-j*65536,T=Ce+j+65535,j=Math.floor(T/65536),Ce=T-j*65536,T=et+j+65535,j=Math.floor(T/65536),et=T-j*65536,T=Ze+j+65535,j=Math.floor(T/65536),Ze=T-j*65536,T=rt+j+65535,j=Math.floor(T/65536),rt=T-j*65536,T=ot+j+65535,j=Math.floor(T/65536),ot=T-j*65536,T=yt+j+65535,j=Math.floor(T/65536),yt=T-j*65536,T=Rt+j+65535,j=Math.floor(T/65536),Rt=T-j*65536,T=Mt+j+65535,j=Math.floor(T/65536),Mt=T-j*65536,T=xt+j+65535,j=Math.floor(T/65536),xt=T-j*65536,T=Tt+j+65535,j=Math.floor(T/65536),Tt=T-j*65536,T=mt+j+65535,j=Math.floor(T/65536),mt=T-j*65536,oe+=j-1+37*(j-1),j=1,T=oe+j+65535,j=Math.floor(T/65536),oe=T-j*65536,T=le+j+65535,j=Math.floor(T/65536),le=T-j*65536,T=me+j+65535,j=Math.floor(T/65536),me=T-j*65536,T=Ee+j+65535,j=Math.floor(T/65536),Ee=T-j*65536,T=ke+j+65535,j=Math.floor(T/65536),ke=T-j*65536,T=Ce+j+65535,j=Math.floor(T/65536),Ce=T-j*65536,T=et+j+65535,j=Math.floor(T/65536),et=T-j*65536,T=Ze+j+65535,j=Math.floor(T/65536),Ze=T-j*65536,T=rt+j+65535,j=Math.floor(T/65536),rt=T-j*65536,T=ot+j+65535,j=Math.floor(T/65536),ot=T-j*65536,T=yt+j+65535,j=Math.floor(T/65536),yt=T-j*65536,T=Rt+j+65535,j=Math.floor(T/65536),Rt=T-j*65536,T=Mt+j+65535,j=Math.floor(T/65536),Mt=T-j*65536,T=xt+j+65535,j=Math.floor(T/65536),xt=T-j*65536,T=Tt+j+65535,j=Math.floor(T/65536),Tt=T-j*65536,T=mt+j+65535,j=Math.floor(T/65536),mt=T-j*65536,oe+=j-1+37*(j-1),K[0]=oe,K[1]=le,K[2]=me,K[3]=Ee,K[4]=ke,K[5]=Ce,K[6]=et,K[7]=Ze,K[8]=rt,K[9]=ot,K[10]=yt,K[11]=Rt,K[12]=Mt,K[13]=xt,K[14]=Tt,K[15]=mt}function ie(K,G){O(K,G,G)}function ee(K,G){var J=r(),T;for(T=0;T<16;T++)J[T]=G[T];for(T=253;T>=0;T--)ie(J,J),T!==2&&T!==4&&O(J,J,G);for(T=0;T<16;T++)K[T]=J[T]}function Z(K,G){var J=r(),T;for(T=0;T<16;T++)J[T]=G[T];for(T=250;T>=0;T--)ie(J,J),T!==1&&O(J,J,G);for(T=0;T<16;T++)K[T]=J[T]}function te(K,G,J){var T=new Uint8Array(32),j=new Float64Array(80),oe,le,me=r(),Ee=r(),ke=r(),Ce=r(),et=r(),Ze=r();for(le=0;le<31;le++)T[le]=G[le];for(T[31]=G[31]&127|64,T[0]&=248,M(j,J),le=0;le<16;le++)Ee[le]=j[le],Ce[le]=me[le]=ke[le]=0;for(me[0]=Ce[0]=1,le=254;le>=0;--le)oe=T[le>>>3]>>>(le&7)&1,A(me,Ee,oe),A(ke,Ce,oe),z(et,me,ke),se(me,me,ke),z(ke,Ee,Ce),se(Ee,Ee,Ce),ie(Ce,et),ie(Ze,me),O(me,ke,me),O(ke,Ee,et),z(et,me,ke),se(me,me,ke),ie(Ee,me),se(ke,Ce,Ze),O(me,ke,f),z(me,me,Ce),O(ke,ke,me),O(me,Ce,Ze),O(Ce,Ee,j),ie(Ee,et),A(me,Ee,oe),A(ke,Ce,oe);for(le=0;le<16;le++)j[le+16]=me[le],j[le+32]=ke[le],j[le+48]=Ee[le],j[le+64]=Ce[le];var rt=j.subarray(32),ot=j.subarray(16);return ee(rt,rt),O(ot,ot,rt),E(K,ot),0}function N(K,G){return te(K,G,s)}function Q(K,G){return n(G,32),N(K,G)}function ne(K,G,J){var T=new Uint8Array(32);return te(T,J,G),k(K,i,T,$)}var de=l,ce=p;function fe(K,G,J,T,j,oe){var le=new Uint8Array(32);return ne(le,j,oe),de(K,G,J,T,le)}function be(K,G,J,T,j,oe){var le=new Uint8Array(32);return ne(le,j,oe),ce(K,G,J,T,le)}var Pe=[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 De(K,G,J,T){for(var j=new Int32Array(16),oe=new Int32Array(16),le,me,Ee,ke,Ce,et,Ze,rt,ot,yt,Rt,Mt,xt,Tt,mt,Et,ct,wt,lt,st,Ae,Ie,Ve,Ue,ze,Je,kt=K[0],Wt=K[1],Zt=K[2],Kt=K[3],ge=K[4],ir=K[5],gr=K[6],mr=K[7],Qt=G[0],vr=G[1],hr=G[2],Lr=G[3],br=G[4],xr=G[5],Fr=G[6],jr=G[7],Mr=0;T>=128;){for(lt=0;lt<16;lt++)st=8*lt+Mr,j[lt]=J[st+0]<<24|J[st+1]<<16|J[st+2]<<8|J[st+3],oe[lt]=J[st+4]<<24|J[st+5]<<16|J[st+6]<<8|J[st+7];for(lt=0;lt<80;lt++)if(le=kt,me=Wt,Ee=Zt,ke=Kt,Ce=ge,et=ir,Ze=gr,rt=mr,ot=Qt,yt=vr,Rt=hr,Mt=Lr,xt=br,Tt=xr,mt=Fr,Et=jr,Ae=mr,Ie=jr,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=(ge>>>14|br<<18)^(ge>>>18|br<<14)^(br>>>9|ge<<23),Ie=(br>>>14|ge<<18)^(br>>>18|ge<<14)^(ge>>>9|br<<23),Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ae=ge&ir^~ge&gr,Ie=br&xr^~br&Fr,Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ae=Pe[lt*2],Ie=Pe[lt*2+1],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ae=j[lt%16],Ie=oe[lt%16],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,ct=ze&65535|Je<<16,wt=Ve&65535|Ue<<16,Ae=ct,Ie=wt,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=(kt>>>28|Qt<<4)^(Qt>>>2|kt<<30)^(Qt>>>7|kt<<25),Ie=(Qt>>>28|kt<<4)^(kt>>>2|Qt<<30)^(kt>>>7|Qt<<25),Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ae=kt&Wt^kt&Zt^Wt&Zt,Ie=Qt&vr^Qt&hr^vr&hr,Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,rt=ze&65535|Je<<16,Et=Ve&65535|Ue<<16,Ae=ke,Ie=Mt,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=ct,Ie=wt,Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,ke=ze&65535|Je<<16,Mt=Ve&65535|Ue<<16,Wt=le,Zt=me,Kt=Ee,ge=ke,ir=Ce,gr=et,mr=Ze,kt=rt,vr=ot,hr=yt,Lr=Rt,br=Mt,xr=xt,Fr=Tt,jr=mt,Qt=Et,lt%16===15)for(st=0;st<16;st++)Ae=j[st],Ie=oe[st],Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=j[(st+9)%16],Ie=oe[(st+9)%16],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,ct=j[(st+1)%16],wt=oe[(st+1)%16],Ae=(ct>>>1|wt<<31)^(ct>>>8|wt<<24)^ct>>>7,Ie=(wt>>>1|ct<<31)^(wt>>>8|ct<<24)^(wt>>>7|ct<<25),Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,ct=j[(st+14)%16],wt=oe[(st+14)%16],Ae=(ct>>>19|wt<<13)^(wt>>>29|ct<<3)^ct>>>6,Ie=(wt>>>19|ct<<13)^(ct>>>29|wt<<3)^(wt>>>6|ct<<26),Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,j[st]=ze&65535|Je<<16,oe[st]=Ve&65535|Ue<<16;Ae=kt,Ie=Qt,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=K[0],Ie=G[0],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,K[0]=kt=ze&65535|Je<<16,G[0]=Qt=Ve&65535|Ue<<16,Ae=Wt,Ie=vr,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=K[1],Ie=G[1],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,K[1]=Wt=ze&65535|Je<<16,G[1]=vr=Ve&65535|Ue<<16,Ae=Zt,Ie=hr,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=K[2],Ie=G[2],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,K[2]=Zt=ze&65535|Je<<16,G[2]=hr=Ve&65535|Ue<<16,Ae=Kt,Ie=Lr,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=K[3],Ie=G[3],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,K[3]=Kt=ze&65535|Je<<16,G[3]=Lr=Ve&65535|Ue<<16,Ae=ge,Ie=br,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=K[4],Ie=G[4],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,K[4]=ge=ze&65535|Je<<16,G[4]=br=Ve&65535|Ue<<16,Ae=ir,Ie=xr,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=K[5],Ie=G[5],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,K[5]=ir=ze&65535|Je<<16,G[5]=xr=Ve&65535|Ue<<16,Ae=gr,Ie=Fr,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=K[6],Ie=G[6],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,K[6]=gr=ze&65535|Je<<16,G[6]=Fr=Ve&65535|Ue<<16,Ae=mr,Ie=jr,Ve=Ie&65535,Ue=Ie>>>16,ze=Ae&65535,Je=Ae>>>16,Ae=K[7],Ie=G[7],Ve+=Ie&65535,Ue+=Ie>>>16,ze+=Ae&65535,Je+=Ae>>>16,Ue+=Ve>>>16,ze+=Ue>>>16,Je+=ze>>>16,K[7]=mr=ze&65535|Je<<16,G[7]=jr=Ve&65535|Ue<<16,Mr+=128,T-=128}return T}function Te(K,G,J){var T=new Int32Array(8),j=new Int32Array(8),oe=new Uint8Array(256),le,me=J;for(T[0]=1779033703,T[1]=3144134277,T[2]=1013904242,T[3]=2773480762,T[4]=1359893119,T[5]=2600822924,T[6]=528734635,T[7]=1541459225,j[0]=4089235720,j[1]=2227873595,j[2]=4271175723,j[3]=1595750129,j[4]=2917565137,j[5]=725511199,j[6]=4215389547,j[7]=327033209,De(T,j,G,J),J%=128,le=0;le=0;--j)T=J[j/8|0]>>(j&7)&1,Me(K,G,T),Fe(G,K),Fe(K,K),Me(K,G,T)}function Oe(K,G){var J=[r(),r(),r(),r()];m(J[0],g),m(J[1],b),m(J[2],a),O(J[3],g,b),He(K,J,G)}function $e(K,G,J){var T=new Uint8Array(64),j=[r(),r(),r(),r()],oe;for(J||n(G,32),Te(T,G,32),T[0]&=248,T[31]&=127,T[31]|=64,Oe(j,T),Ne(K,j),oe=0;oe<32;oe++)G[oe+32]=K[oe];return 0}var qe=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 _e(K,G){var J,T,j,oe;for(T=63;T>=32;--T){for(J=0,j=T-32,oe=T-12;j>4)*qe[j],J=G[j]>>8,G[j]&=255;for(j=0;j<32;j++)G[j]-=J*qe[j];for(T=0;T<32;T++)G[T+1]+=G[T]>>8,K[T]=G[T]&255}function Qe(K){var G=new Float64Array(64),J;for(J=0;J<64;J++)G[J]=K[J];for(J=0;J<64;J++)K[J]=0;_e(K,G)}function at(K,G,J,T){var j=new Uint8Array(64),oe=new Uint8Array(64),le=new Uint8Array(64),me,Ee,ke=new Float64Array(64),Ce=[r(),r(),r(),r()];Te(j,T,32),j[0]&=248,j[31]&=127,j[31]|=64;var et=J+64;for(me=0;me>7&&se(K[0],o,K[0]),O(K[3],K[0],K[1]),0)}function nt(K,G,J,T){var j,oe=new Uint8Array(32),le=new Uint8Array(64),me=[r(),r(),r(),r()],Ee=[r(),r(),r(),r()];if(J<64||Be(Ee,T))return-1;for(j=0;j=0},e.sign.keyPair=function(){var K=new Uint8Array(gt),G=new Uint8Array(Ot);return $e(K,G),{publicKey:K,secretKey:G}},e.sign.keyPair.fromSecretKey=function(K){if(tt(K),K.length!==Ot)throw new Error("bad secret key size");for(var G=new Uint8Array(gt),J=0;J=t.length)throw new Error("Index is out of buffer");const r=t.slice(0,e),n=t.slice(e);return[r,n]}function U1(t){let e="";return t.forEach(r=>{e+=("0"+(r&255).toString(16)).slice(-2)}),e}function Kd(t){if(t.length%2!==0)throw new Error(`Cannot convert ${t} to bytesArray`);const e=new Uint8Array(t.length/2);for(let r=0;r{var i,s;if(!((i=void 0)===null||i===void 0)&&i.aborted){n(new jt("Delay aborted"));return}const o=setTimeout(()=>r(),t);(s=void 0)===null||s===void 0||s.addEventListener("abort",()=>{clearTimeout(o),n(new jt("Delay aborted"))})})})}function Ss(t){const e=new AbortController;return t!=null&&t.aborted?e.abort():t==null||t.addEventListener("abort",()=>e.abort(),{once:!0}),e}function fh(t,e){var r,n;return Pt(this,void 0,void 0,function*(){const i=(r=e==null?void 0:e.attempts)!==null&&r!==void 0?r:10,s=(n=e==null?void 0:e.delayMs)!==null&&n!==void 0?n:200,o=Ss(e==null?void 0:e.signal);if(typeof t!="function")throw new jt(`Expected a function, got ${typeof t}`);let a=0,u;for(;aPt(this,void 0,void 0,function*(){if(s=g??null,o==null||o.abort(),o=Ss(g),o.signal.aborted)throw new jt("Resource creation was aborted");n=y??null;const A=t(o.signal,...y);i=A;const P=yield A;if(i!==A&&P!==r)throw yield e(P),new jt("Resource creation was aborted by a new resource creation");return r=P,r});return{create:a,current:()=>r??null,dispose:()=>Pt(this,void 0,void 0,function*(){try{const g=r;r=null;const y=i;i=null;try{o==null||o.abort()}catch{}yield Promise.allSettled([g?e(g):Promise.resolve(),y?e(yield y):Promise.resolve()])}catch{}}),recreate:g=>Pt(this,void 0,void 0,function*(){const y=r,A=i,P=n,N=s;if(yield O7(g),y===r&&A===i&&P===n&&N===s)return yield a(s,...P??[]);throw new jt("Resource recreation was aborted by a new resource creation")})}}function WZ(t,e){const r=e==null?void 0:e.timeout,n=e==null?void 0:e.signal,i=Ss(n);return new Promise((s,o)=>Pt(this,void 0,void 0,function*(){if(i.signal.aborted){o(new jt("Operation aborted"));return}let a;typeof r<"u"&&(a=setTimeout(()=>{i.abort(),o(new jt(`Timeout after ${r}ms`))},r)),i.signal.addEventListener("abort",()=>{clearTimeout(a),o(new jt("Operation aborted"))},{once:!0});const u={timeout:r,abort:i.signal};yield t((...l)=>{clearTimeout(a),s(...l)},()=>{clearTimeout(a),o()},u)}))}class Ob{constructor(e,r,n,i,s){this.bridgeUrl=r,this.sessionId=n,this.listener=i,this.errorsListener=s,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=HZ((o,a)=>Pt(this,void 0,void 0,function*(){const u={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:o,openingDeadlineMS:a};return yield KZ(u)}),o=>Pt(this,void 0,void 0,function*(){o.close()})),this.bridgeGatewayStorage=new FZ(e,r)}get isReady(){const e=this.eventSource.current();return(e==null?void 0:e.readyState)===EventSource.OPEN}get isClosed(){const e=this.eventSource.current();return(e==null?void 0:e.readyState)!==EventSource.OPEN}get isConnecting(){const e=this.eventSource.current();return(e==null?void 0:e.readyState)===EventSource.CONNECTING}registerSession(e){return Pt(this,void 0,void 0,function*(){yield this.eventSource.create(e==null?void 0:e.signal,e==null?void 0:e.openingDeadlineMS)})}send(e,r,n,i){var s;return Pt(this,void 0,void 0,function*(){const o={};typeof i=="number"?o.ttl=i:(o.ttl=i==null?void 0:i.ttl,o.signal=i==null?void 0:i.signal,o.attempts=i==null?void 0:i.attempts);const a=new URL(D7(this.bridgeUrl,this.postPath));a.searchParams.append("client_id",this.sessionId),a.searchParams.append("to",r),a.searchParams.append("ttl",((o==null?void 0:o.ttl)||this.defaultTtl).toString()),a.searchParams.append("topic",n);const u=C7.encode(e);yield fh(l=>Pt(this,void 0,void 0,function*(){const d=yield this.post(a,u,l.signal);if(!d.ok)throw new jt(`Bridge send failed, status ${d.status}`)}),{attempts:(s=o==null?void 0:o.attempts)!==null&&s!==void 0?s:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:o==null?void 0:o.signal})})}pause(){this.eventSource.dispose().catch(e=>Bo(`Bridge pause failed, ${e}`))}unPause(){return Pt(this,void 0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return Pt(this,void 0,void 0,function*(){yield this.eventSource.dispose().catch(e=>Bo(`Bridge close failed, ${e}`))})}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}post(e,r,n){return Pt(this,void 0,void 0,function*(){const i=yield fetch(e,{method:"post",body:r,signal:n});if(!i.ok)throw new jt(`Bridge send failed, status ${i.status}`);return i})}errorsHandler(e,r){return Pt(this,void 0,void 0,function*(){if(this.isConnecting)throw e.close(),new jt("Bridge error, failed to connect");if(this.isReady){try{this.errorsListener(r)}catch{}return}if(this.isClosed)return e.close(),Sn(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new jt("Bridge error, unknown state")})}messagesHandler(e){return Pt(this,void 0,void 0,function*(){if(e.data===this.heartbeatMessage||(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),this.isClosed))return;let r;try{r=JSON.parse(e.data)}catch(n){throw new jt(`Bridge message parse failed, message ${n.data}`)}this.listener(r)})}}function KZ(t){return Pt(this,void 0,void 0,function*(){return yield WZ((e,r,n)=>Pt(this,void 0,void 0,function*(){var i;const o=Ss(n.signal).signal;if(o.aborted){r(new jt("Bridge connection aborted"));return}const a=new URL(D7(t.bridgeUrl,t.ssePath));a.searchParams.append("client_id",t.sessionId);const u=yield t.bridgeGatewayStorage.getLastEventId();if(u&&a.searchParams.append("last_event_id",u),o.aborted){r(new jt("Bridge connection aborted"));return}const l=new EventSource(a.toString());l.onerror=d=>Pt(this,void 0,void 0,function*(){if(o.aborted){l.close(),r(new jt("Bridge connection aborted"));return}try{const g=yield t.errorHandler(l,d);g!==l&&l.close(),g&&g!==l&&e(g)}catch(g){l.close(),r(g)}}),l.onopen=()=>{if(o.aborted){l.close(),r(new jt("Bridge connection aborted"));return}e(l)},l.onmessage=d=>{if(o.aborted){l.close(),r(new jt("Bridge connection aborted"));return}t.messageHandler(d)},(i=t.signal)===null||i===void 0||i.addEventListener("abort",()=>{l.close(),r(new jt("Bridge connection aborted"))})}),{timeout:t.openingDeadlineMS,signal:t.signal})})}function lh(t){return!("connectEvent"in t)}class hh{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return Pt(this,void 0,void 0,function*(){if(e.type==="injected")return this.storage.setItem(this.storeKey,JSON.stringify(e));if(!lh(e)){const n={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},i={type:"http",connectEvent:e.connectEvent,session:n,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(i))}const r={type:"http",connectionSource:e.connectionSource,sessionCrypto:e.sessionCrypto.stringifyKeypair()};return this.storage.setItem(this.storeKey,JSON.stringify(r))})}removeConnection(){return Pt(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return Pt(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const r=JSON.parse(e);if(r.type==="injected")return r;if("connectEvent"in r){const n=new Ib(r.session.sessionKeyPair);return{type:"http",connectEvent:r.connectEvent,lastWalletEventId:r.lastWalletEventId,nextRpcRequestId:r.nextRpcRequestId,session:{sessionCrypto:n,bridgeUrl:r.session.bridgeUrl,walletPublicKey:r.session.walletPublicKey}}}return{type:"http",sessionCrypto:new Ib(r.sessionCrypto),connectionSource:r.connectionSource}})}getHttpConnection(){return Pt(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new jt("Trying to read HTTP connection source while nothing is stored");if(e.type==="injected")throw new jt("Trying to read HTTP connection source while injected connection is stored");return e})}getHttpPendingConnection(){return Pt(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new jt("Trying to read HTTP connection source while nothing is stored");if(e.type==="injected")throw new jt("Trying to read HTTP connection source while injected connection is stored");if(!lh(e))throw new jt("Trying to read HTTP-pending connection while http connection is stored");return e})}getInjectedConnection(){return Pt(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new jt("Trying to read Injected bridge connection source while nothing is stored");if((e==null?void 0:e.type)==="http")throw new jt("Trying to read Injected bridge connection source while HTTP connection is stored");return e})}storedConnectionType(){return Pt(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);return e?JSON.parse(e).type:null})}storeLastWalletEventId(e){return Pt(this,void 0,void 0,function*(){const r=yield this.getConnection();if(r&&r.type==="http"&&!lh(r))return r.lastWalletEventId=e,this.storeConnection(r)})}getLastWalletEventId(){return Pt(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId})}increaseNextRpcRequestId(){return Pt(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"nextRpcRequestId"in e){const r=e.nextRpcRequestId||0;return e.nextRpcRequestId=r+1,this.storeConnection(e)}})}getNextRpcRequestId(){return Pt(this,void 0,void 0,function*(){const e=yield this.getConnection();return e&&"nextRpcRequestId"in e&&e.nextRpcRequestId||0})}}const N7=2;class dh{constructor(e,r){this.storage=e,this.walletConnectionSource=r,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.connectionStorage=new hh(e)}static fromStorage(e){return Pt(this,void 0,void 0,function*(){const n=yield new hh(e).getHttpConnection();return lh(n)?new dh(e,n.connectionSource):new dh(e,{bridgeUrl:n.session.bridgeUrl})})}connect(e,r){var n;const i=Ss(r==null?void 0:r.signal);(n=this.abortController)===null||n===void 0||n.abort(),this.abortController=i,this.closeGateways();const s=new Ib;this.session={sessionCrypto:s,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:s}).then(()=>Pt(this,void 0,void 0,function*(){i.signal.aborted||(yield fh(a=>{var u;return this.openGateways(s,{openingDeadlineMS:(u=r==null?void 0:r.openingDeadlineMS)!==null&&u!==void 0?u:this.defaultOpeningDeadlineMS,signal:a==null?void 0:a.signal})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:i.signal}))}));const o="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(o,e)}restoreConnection(e){var r,n;return Pt(this,void 0,void 0,function*(){const i=Ss(e==null?void 0:e.signal);if((r=this.abortController)===null||r===void 0||r.abort(),this.abortController=i,i.signal.aborted)return;this.closeGateways();const s=yield this.connectionStorage.getHttpConnection();if(!s||i.signal.aborted)return;const o=(n=e==null?void 0:e.openingDeadlineMS)!==null&&n!==void 0?n:this.defaultOpeningDeadlineMS;if(lh(s))return this.session={sessionCrypto:s.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(s.sessionCrypto,{openingDeadlineMS:o,signal:i==null?void 0:i.signal});if(Array.isArray(this.walletConnectionSource))throw new jt("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=s.session,this.gateway&&(Sn("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new Ob(this.storage,this.walletConnectionSource.bridgeUrl,s.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),!i.signal.aborted){this.listeners.forEach(a=>a(s.connectEvent));try{yield fh(a=>this.gateway.registerSession({openingDeadlineMS:o,signal:a.signal}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:i.signal})}catch{yield this.disconnect({signal:i.signal});return}}})}sendRequest(e,r){const n={};return typeof r=="function"?n.onRequestSent=r:(n.onRequestSent=r==null?void 0:r.onRequestSent,n.signal=r==null?void 0:r.signal,n.attempts=r==null?void 0:r.attempts),new Promise((i,s)=>Pt(this,void 0,void 0,function*(){var o;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new jt("Trying to send bridge request without session");const a=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),Sn("Send http-bridge request:",Object.assign(Object.assign({},e),{id:a}));const u=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:a})),G0(this.session.walletPublicKey));try{yield this.gateway.send(u,this.session.walletPublicKey,e.method,{attempts:n==null?void 0:n.attempts,signal:n==null?void 0:n.signal}),(o=n==null?void 0:n.onRequestSent)===null||o===void 0||o.call(n),this.pendingRequests.set(a.toString(),i)}catch(l){s(l)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return Pt(this,void 0,void 0,function*(){return new Promise(r=>Pt(this,void 0,void 0,function*(){let n=!1,i=null;const s=()=>{n||(n=!0,this.removeBridgeAndSession().then(r))};try{this.closeGateways();const o=Ss(e==null?void 0:e.signal);i=setTimeout(()=>{o.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:s,signal:o.signal,attempts:1})}catch(o){Sn("Disconnect error:",o),n||this.removeBridgeAndSession().then(r)}finally{i&&clearTimeout(i),s()}}))})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(r=>r!==e)}pause(){var e;(e=this.gateway)===null||e===void 0||e.pause(),this.pendingGateways.forEach(r=>r.pause())}unPause(){return Pt(this,void 0,void 0,function*(){const e=this.pendingGateways.map(r=>r.unPause());this.gateway&&e.push(this.gateway.unPause()),yield Promise.all(e)})}pendingGatewaysListener(e,r,n){return Pt(this,void 0,void 0,function*(){if(!this.pendingGateways.includes(e)){yield e.close();return}return this.closeGateways({except:e}),this.gateway&&(Sn("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=r,this.gateway=e,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(n)})}gatewayListener(e){return Pt(this,void 0,void 0,function*(){const r=JSON.parse(this.session.sessionCrypto.decrypt(C7.decode(e.message).toUint8Array(),G0(e.from)));if(Sn("Wallet message received:",r),!("event"in r)){const i=r.id.toString(),s=this.pendingRequests.get(i);if(!s){Sn(`Response id ${i} doesn't match any request's id`);return}s(r),this.pendingRequests.delete(i);return}if(r.id!==void 0){const i=yield this.connectionStorage.getLastWalletEventId();if(i!==void 0&&r.id<=i){Bo(`Received event id (=${r.id}) must be greater than stored last wallet event id (=${i}) `);return}r.event!=="connect"&&(yield this.connectionStorage.storeLastWalletEventId(r.id))}const n=this.listeners;r.event==="connect"&&(yield this.updateSession(r,e.from)),r.event==="disconnect"&&(Sn("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),n.forEach(i=>i(r))})}gatewayErrorsListener(e){return Pt(this,void 0,void 0,function*(){throw new jt(`Bridge error ${JSON.stringify(e)}`)})}updateSession(e,r){return Pt(this,void 0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:r});const n=e.payload.items.find(s=>s.name==="ton_addr"),i=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:i,nextRpcRequestId:0})})}removeBridgeAndSession(){return Pt(this,void 0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(e,r){return jZ(e)?this.generateTGUniversalLink(e,r):this.generateRegularUniversalLink(e,r)}generateRegularUniversalLink(e,r){const n=new URL(e);return n.searchParams.append("v",N7.toString()),n.searchParams.append("id",this.session.sessionCrypto.sessionId),n.searchParams.append("r",JSON.stringify(r)),n.toString()}generateTGUniversalLink(e,r){const i=this.generateRegularUniversalLink("about:blank",r).split("?")[1],s="tonconnect-"+qZ(i),o=this.convertToDirectLink(e),a=new URL(o);return a.searchParams.append("startapp",s),a.toString()}convertToDirectLink(e){const r=new URL(e);return r.searchParams.has("attach")&&(r.searchParams.delete("attach"),r.pathname+="/start"),r.toString()}openGateways(e,r){return Pt(this,void 0,void 0,function*(){if(Array.isArray(this.walletConnectionSource)){this.pendingGateways.map(n=>n.close().catch()),this.pendingGateways=this.walletConnectionSource.map(n=>{const i=new Ob(this.storage,n.bridgeUrl,e.sessionId,()=>{},()=>{});return i.setListener(s=>this.pendingGatewaysListener(i,n.bridgeUrl,s)),i}),yield Promise.allSettled(this.pendingGateways.map(n=>fh(i=>{var s;return this.pendingGateways.some(o=>o===n)?n.registerSession({openingDeadlineMS:(s=r==null?void 0:r.openingDeadlineMS)!==null&&s!==void 0?s:this.defaultOpeningDeadlineMS,signal:i.signal}):n.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:r==null?void 0:r.signal})));return}else return this.gateway&&(Sn("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new Ob(this.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.gateway.registerSession({openingDeadlineMS:r==null?void 0:r.openingDeadlineMS,signal:r==null?void 0:r.signal})})}closeGateways(e){var r;(r=this.gateway)===null||r===void 0||r.close(),this.pendingGateways.filter(n=>n!==(e==null?void 0:e.except)).forEach(n=>n.close()),this.pendingGateways=[]}}function L7(t,e){return k7(t,[e])}function k7(t,e){return!t||typeof t!="object"?!1:e.every(r=>r in t)}function VZ(t){try{return!L7(t,"tonconnect")||!L7(t.tonconnect,"walletInfo")?!1:k7(t.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch{return!1}}class Yu{constructor(){this.storage={}}static getInstance(){return Yu.instance||(Yu.instance=new Yu),Yu.instance}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(e){var r;return(r=this.storage[e])!==null&&r!==void 0?r:null}key(e){var r;const n=Object.keys(this.storage);return e<0||e>=n.length?null:(r=n[e])!==null&&r!==void 0?r:null}removeItem(e){delete this.storage[e]}setItem(e,r){this.storage[e]=r}}function rp(){if(!(typeof window>"u"))return window}function GZ(){const t=rp();if(!t)return[];try{return Object.keys(t)}catch{return[]}}function YZ(){if(!(typeof document>"u"))return document}function JZ(){var t;const e=(t=rp())===null||t===void 0?void 0:t.location.origin;return e?e+"/tonconnect-manifest.json":""}function XZ(){if(ZZ())return localStorage;if(QZ())throw new jt("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return Yu.getInstance()}function ZZ(){try{return typeof localStorage<"u"}catch{return!1}}function QZ(){return typeof process<"u"&&process.versions!=null&&process.versions.node!=null}class xi{constructor(e,r){this.injectedWalletKey=r,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=xi.window;if(!xi.isWindowContainsWallet(n,r))throw new Rb;this.connectionStorage=new hh(e),this.injectedWallet=n[r].tonconnect}static fromStorage(e){return Pt(this,void 0,void 0,function*(){const n=yield new hh(e).getInjectedConnection();return new xi(e,n.jsBridgeKey)})}static isWalletInjected(e){return xi.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return xi.isWindowContainsWallet(this.window,e)?this.window[e].tonconnect.isWalletBrowser:!1}static getCurrentlyInjectedWallets(){return this.window?GZ().filter(([n,i])=>VZ(i)).map(([n,i])=>({name:i.tonconnect.walletInfo.name,appName:i.tonconnect.walletInfo.app_name,aboutUrl:i.tonconnect.walletInfo.about_url,imageUrl:i.tonconnect.walletInfo.image,tondns:i.tonconnect.walletInfo.tondns,jsBridgeKey:n,injected:!0,embedded:i.tonconnect.isWalletBrowser,platforms:i.tonconnect.walletInfo.platforms})):[]}static isWindowContainsWallet(e,r){return!!e&&r in e&&typeof e[r]=="object"&&"tonconnect"in e[r]}connect(e){this._connect(N7,e)}restoreConnection(){return Pt(this,void 0,void 0,function*(){try{Sn("Injected Provider restoring connection...");const e=yield this.injectedWallet.restoreConnection();Sn("Injected Provider restoring connection response",e),e.event==="connect"?(this.makeSubscriptions(),this.listeners.forEach(r=>r(e))):yield this.connectionStorage.removeConnection()}catch(e){yield this.connectionStorage.removeConnection(),console.error(e)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return Pt(this,void 0,void 0,function*(){return new Promise(e=>{const r=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),r()}catch(n){Sn(n),this.sendRequest({method:"disconnect",params:[]},r)}})})}closeAllListeners(){var e;this.listenSubscriptions=!1,this.listeners=[],(e=this.unsubscribeCallback)===null||e===void 0||e.call(this)}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(r=>r!==e)}sendRequest(e,r){var n;return Pt(this,void 0,void 0,function*(){const i={};typeof r=="function"?i.onRequestSent=r:(i.onRequestSent=r==null?void 0:r.onRequestSent,i.signal=r==null?void 0:r.signal);const s=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),Sn("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:s}));const o=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:s}));return o.then(a=>Sn("Wallet message received:",a)),(n=i==null?void 0:i.onRequestSent)===null||n===void 0||n.call(i),o})}_connect(e,r){return Pt(this,void 0,void 0,function*(){try{Sn(`Injected Provider connect request: protocolVersion: ${e}, message:`,r);const n=yield this.injectedWallet.connect(e,r);Sn("Injected Provider connect response:",n),n.event==="connect"&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach(i=>i(n))}catch(n){Sn("Injected Provider connect error:",n);const i={event:"connect_error",payload:{code:0,message:n==null?void 0:n.toString()}};this.listeners.forEach(s=>s(i))}})}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen(e=>{Sn("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach(r=>r(e)),e.event==="disconnect"&&this.disconnect()})}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}xi.window=rp();class eQ{constructor(){this.localStorage=XZ()}getItem(e){return Pt(this,void 0,void 0,function*(){return this.localStorage.getItem(e)})}removeItem(e){return Pt(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}setItem(e,r){return Pt(this,void 0,void 0,function*(){this.localStorage.setItem(e,r)})}}function $7(t){return rQ(t)&&t.injected}function tQ(t){return $7(t)&&t.embedded}function rQ(t){return"jsBridgeKey"in t}const nQ=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.ton.space/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"]},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.delab.team/bridge"}],platforms:["ios","android"]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitkeepwallet/download/main/logo/png/bitget_wallet_logo_0_gas_fee.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://bridge.tonapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect"},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]},{app_name:"okxTonWalletTr",name:"OKX TR Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/587A8296F0BB640F.png",about_url:"https://tr.okx.com/web3",universal_url:"https://tr.okx.com/download?appendQuery=true&deeplink=okxtr://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]}];class Nb{constructor(e){this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null,this.walletsListSource="https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",e!=null&&e.walletsListSource&&(this.walletsListSource=e.walletsListSource),e!=null&&e.cacheTTLMs&&(this.cacheTTLMs=e.cacheTTLMs)}getWallets(){return Pt(this,void 0,void 0,function*(){return this.cacheTTLMs&&this.walletsListCacheCreationTimestamp&&Date.now()>this.walletsListCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListCache=null),this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.then(()=>{this.walletsListCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null})),this.walletsListCache})}getEmbeddedWallet(){return Pt(this,void 0,void 0,function*(){const r=(yield this.getWallets()).filter(tQ);return r.length!==1?null:r[0]})}fetchWalletsList(){return Pt(this,void 0,void 0,function*(){let e=[];try{if(e=yield(yield fetch(this.walletsListSource)).json(),!Array.isArray(e))throw new Db("Wrong wallets list format, wallets list must be an array.");const i=e.filter(s=>!this.isCorrectWalletConfigDTO(s));i.length&&(Bo(`Wallet(s) ${i.map(s=>s.name).join(", ")} config format is wrong. They were removed from the wallets list.`),e=e.filter(s=>this.isCorrectWalletConfigDTO(s)))}catch(n){Bo(n),e=nQ}let r=[];try{r=xi.getCurrentlyInjectedWallets()}catch(n){Bo(n)}return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),r)})}walletConfigDTOListToWalletConfigList(e){return e.map(r=>{const i={name:r.name,appName:r.app_name,imageUrl:r.image,aboutUrl:r.about_url,tondns:r.tondns,platforms:r.platforms};return r.bridge.forEach(s=>{if(s.type==="sse"&&(i.bridgeUrl=s.url,i.universalLink=r.universal_url,i.deepLink=r.deepLink),s.type==="js"){const o=s.key;i.jsBridgeKey=o,i.injected=xi.isWalletInjected(o),i.embedded=xi.isInsideWalletBrowser(o)}}),i})}mergeWalletsLists(e,r){return[...new Set(e.concat(r).map(i=>i.name)).values()].map(i=>{const s=e.find(a=>a.name===i),o=r.find(a=>a.name===i);return Object.assign(Object.assign({},s&&Object.assign({},s)),o&&Object.assign({},o))})}isCorrectWalletConfigDTO(e){if(!e||typeof e!="object")return!1;const r="name"in e,n="app_name"in e,i="image"in e,s="about_url"in e,o="platforms"in e;if(!r||!i||!s||!o||!n||!e.platforms||!Array.isArray(e.platforms)||!e.platforms.length||!("bridge"in e)||!Array.isArray(e.bridge)||!e.bridge.length)return!1;const a=e.bridge;if(a.some(d=>!d||typeof d!="object"||!("type"in d)))return!1;const u=a.find(d=>d.type==="sse");if(u&&(!("url"in u)||!u.url||!e.universal_url))return!1;const l=a.find(d=>d.type==="js");return!(l&&(!("key"in l)||!l.key))}}class np extends jt{get info(){return"Wallet doesn't support requested feature method."}constructor(...e){super(...e),Object.setPrototypeOf(this,np.prototype)}}function iQ(t,e){const r=t.includes("SendTransaction"),n=t.find(i=>i&&typeof i=="object"&&i.name==="SendTransaction");if(!r&&!n)throw new np("Wallet doesn't support SendTransaction feature.");if(n&&n.maxMessages!==void 0){if(n.maxMessages{var a,u;return{address:(a=o.address)!==null&&a!==void 0?a:null,amount:(u=o.amount)!==null&&u!==void 0?u:null}})}}function dQ(t,e,r){return Object.assign(Object.assign({type:"transaction-sent-for-signature"},Xu(t,e)),Lb(e,r))}function pQ(t,e,r,n){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:n.boc},Xu(t,e)),Lb(e,r))}function gQ(t,e,r,n,i){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:n,error_code:i??null},Xu(t,e)),Lb(e,r))}function mQ(t,e,r){return Object.assign({type:"disconnection",scope:r},Xu(t,e))}class vQ{constructor(){this.window=rp()}dispatchEvent(e,r){var n;return Pt(this,void 0,void 0,function*(){const i=new CustomEvent(e,{detail:r});(n=this.window)===null||n===void 0||n.dispatchEvent(i)})}addEventListener(e,r,n){var i;return Pt(this,void 0,void 0,function*(){return(i=this.window)===null||i===void 0||i.addEventListener(e,r,n),()=>{var s;return(s=this.window)===null||s===void 0?void 0:s.removeEventListener(e,r)}})}}class bQ{constructor(e){var r;this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=(r=e==null?void 0:e.eventDispatcher)!==null&&r!==void 0?r:new vQ,this.tonConnectSdkVersion=e.tonConnectSdkVersion,this.init().catch()}get version(){return Ju({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return Pt(this,void 0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch{}})}setRequestVersionHandler(){return Pt(this,void 0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>Pt(this,void 0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",oQ(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return Pt(this,void 0,void 0,function*(){return new Promise((e,r)=>Pt(this,void 0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",n=>{e(n.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",sQ())}catch(n){r(n)}}))})}dispatchUserActionEvent(e){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch{}}trackConnectionStarted(...e){try{const r=aQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionCompleted(...e){try{const r=cQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionError(...e){try{const r=uQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionRestoringStarted(...e){try{const r=fQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionRestoringCompleted(...e){try{const r=lQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionRestoringError(...e){try{const r=hQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackDisconnection(...e){try{const r=mQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackTransactionSentForSignature(...e){try{const r=dQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackTransactionSigned(...e){try{const r=pQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackTransactionSigningFailed(...e){try{const r=gQ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}}const yQ="3.0.5";class ip{constructor(e){if(this.walletsList=new Nb,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(e==null?void 0:e.manifestUrl)||JZ(),storage:(e==null?void 0:e.storage)||new eQ},this.walletsList=new Nb({walletsListSource:e==null?void 0:e.walletsListSource,cacheTTLMs:e==null?void 0:e.walletsListCacheTTLMs}),this.tracker=new bQ({eventDispatcher:e==null?void 0:e.eventDispatcher,tonConnectSdkVersion:yQ}),!this.dappSettings.manifestUrl)throw new Cb("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest");this.bridgeConnectionStorage=new hh(this.dappSettings.storage),e!=null&&e.disableAutoPauseConnection||this.addWindowFocusAndBlurSubscriptions()}static getWallets(){return this.walletsList.getWallets()}get connected(){return this._wallet!==null}get account(){var e;return((e=this._wallet)===null||e===void 0?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach(r=>r(this._wallet))}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,r){return this.statusChangeSubscriptions.push(e),r&&this.statusChangeErrorSubscriptions.push(r),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(n=>n!==e),r&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(n=>n!==r))}}connect(e,r){var n,i;const s={};if(typeof r=="object"&&"tonProof"in r&&(s.request=r),typeof r=="object"&&("openingDeadlineMS"in r||"signal"in r||"request"in r)&&(s.request=r==null?void 0:r.request,s.openingDeadlineMS=r==null?void 0:r.openingDeadlineMS,s.signal=r==null?void 0:r.signal),this.connected)throw new Tb;const o=Ss(s==null?void 0:s.signal);if((n=this.abortController)===null||n===void 0||n.abort(),this.abortController=o,o.signal.aborted)throw new jt("Connection was aborted");return(i=this.provider)===null||i===void 0||i.closeConnection(),this.provider=this.createProvider(e),o.signal.addEventListener("abort",()=>{var a;(a=this.provider)===null||a===void 0||a.closeConnection(),this.provider=null}),this.tracker.trackConnectionStarted(),this.provider.connect(this.createConnectRequest(s==null?void 0:s.request),{openingDeadlineMS:s==null?void 0:s.openingDeadlineMS,signal:o.signal})}restoreConnection(e){var r,n;return Pt(this,void 0,void 0,function*(){this.tracker.trackConnectionRestoringStarted();const i=Ss(e==null?void 0:e.signal);if((r=this.abortController)===null||r===void 0||r.abort(),this.abortController=i,i.signal.aborted){this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}const[s,o]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(i.signal.aborted){this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}let a=null;try{switch(s){case"http":a=yield dh.fromStorage(this.dappSettings.storage);break;case"injected":a=yield xi.fromStorage(this.dappSettings.storage);break;default:if(o)a=this.createProvider(o);else return}}catch{this.tracker.trackConnectionRestoringError("Provider is not restored"),yield this.bridgeConnectionStorage.removeConnection(),a==null||a.closeConnection(),a=null;return}if(i.signal.aborted){a==null||a.closeConnection(),this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}if(!a){Bo("Provider is not restored"),this.tracker.trackConnectionRestoringError("Provider is not restored");return}(n=this.provider)===null||n===void 0||n.closeConnection(),this.provider=a,a.listen(this.walletEventsListener.bind(this));const u=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted"),a==null||a.closeConnection(),a=null};i.signal.addEventListener("abort",u);const l=fh(g=>Pt(this,void 0,void 0,function*(){yield a==null?void 0:a.restoreConnection({openingDeadlineMS:e==null?void 0:e.openingDeadlineMS,signal:g.signal}),i.signal.removeEventListener("abort",u),this.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):this.tracker.trackConnectionRestoringError("Connection restoring failed")}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:e==null?void 0:e.signal}),d=new Promise(g=>setTimeout(()=>g(),12e3));return Promise.race([l,d])})}sendTransaction(e,r){return Pt(this,void 0,void 0,function*(){const n={};typeof r=="function"?n.onRequestSent=r:(n.onRequestSent=r==null?void 0:r.onRequestSent,n.signal=r==null?void 0:r.signal);const i=Ss(n==null?void 0:n.signal);if(i.signal.aborted)throw new jt("Transaction sending was aborted");this.checkConnection(),iQ(this.wallet.device.features,{requiredMessagesNumber:e.messages.length}),this.tracker.trackTransactionSentForSignature(this.wallet,e);const{validUntil:s}=e,o=OZ(e,["validUntil"]),a=e.from||this.account.address,u=e.network||this.account.chain,l=yield this.provider.sendRequest(tp.convertToRpcRequest(Object.assign(Object.assign({},o),{valid_until:s,from:a,network:u})),{onRequestSent:n.onRequestSent,signal:i.signal});if(tp.isError(l))return this.tracker.trackTransactionSigningFailed(this.wallet,e,l.error.message,l.error.code),tp.parseAndThrowError(l);const d=tp.convertFromRpcResponse(l);return this.tracker.trackTransactionSigned(this.wallet,e,d),d})}disconnect(e){var r;return Pt(this,void 0,void 0,function*(){if(!this.connected)throw new X0;const n=Ss(e==null?void 0:e.signal),i=this.abortController;if(this.abortController=n,n.signal.aborted)throw new jt("Disconnect was aborted");this.onWalletDisconnected("dapp"),yield(r=this.provider)===null||r===void 0?void 0:r.disconnect({signal:n.signal}),i==null||i.abort()})}pauseConnection(){var e;((e=this.provider)===null||e===void 0?void 0:e.type)==="http"&&this.provider.pause()}unPauseConnection(){var e;return((e=this.provider)===null||e===void 0?void 0:e.type)!=="http"?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const e=YZ();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?this.pauseConnection():this.unPauseConnection().catch()})}catch(r){Bo("Cannot subscribe to the document.visibilitychange: ",r)}}createProvider(e){let r;return!Array.isArray(e)&&NZ(e)?r=new xi(this.dappSettings.storage,e.jsBridgeKey):r=new dh(this.dappSettings.storage,e),r.listen(this.walletEventsListener.bind(this)),r}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload);break;case"connect_error":this.onWalletConnectError(e.payload);break;case"disconnect":this.onWalletDisconnected("wallet")}}onWalletConnected(e){const r=e.items.find(s=>s.name==="ton_addr"),n=e.items.find(s=>s.name==="ton_proof");if(!r)throw new jt("ton_addr connection item was not found");const i={device:e.device,provider:this.provider.type,account:{address:r.address,chain:r.network,walletStateInit:r.walletStateInit,publicKey:r.publicKey}};n&&(i.connectItems={tonProof:n}),this.wallet=i,this.tracker.trackConnectionCompleted(i)}onWalletConnectError(e){const r=kZ.parseError(e);if(this.statusChangeErrorSubscriptions.forEach(n=>n(r)),Sn(r),this.tracker.trackConnectionError(e.message,e.code),r instanceof J0||r instanceof Y0)throw Bo(r),r}onWalletDisconnected(e){this.tracker.trackDisconnection(this.wallet,e),this.wallet=null}checkConnection(){if(!this.connected)throw new X0}createConnectRequest(e){const r=[{name:"ton_addr"}];return e!=null&&e.tonProof&&r.push({name:"ton_proof",payload:e.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:r}}}ip.walletsList=new Nb,ip.isWalletInjected=t=>xi.isWalletInjected(t),ip.isInsideWalletBrowser=t=>xi.isInsideWalletBrowser(t);for(let t=0;t<=255;t++){let e=t.toString(16);e.length<2&&(e="0"+e)}function kb(t){const{children:e,onClick:r}=t;return me.jsx("button",{onClick:r,className:"xc-border xc-px-4 xc-py-2 xc-rounded-full xc-text-sm xc-flex xc-gap-2 xc-items-center",children:e})}function wQ(t){const{wallet:e,connector:r,loading:n}=t,i=Pe.useRef(null),s=Pe.useRef(),[o,a]=Pe.useState(),[u,l]=Pe.useState(),[d,g]=Pe.useState("connect"),[y,A]=Pe.useState(!1),[P,N]=Pe.useState();function D(z){var ue;(ue=s.current)==null||ue.update({data:z})}async function k(){A(!0);try{a("");const z=await ma.getNonce({account_type:"block_chain"});if("universalLink"in e&&e.universalLink){const ue=r.connect({universalLink:e.universalLink,bridgeUrl:e.bridgeUrl},{request:{tonProof:z}});if(!ue)return;N(ue),D(ue),l(z)}}catch(z){a(z.message)}A(!1)}function $(){s.current=new y7({width:264,height:264,margin:0,type:"svg",qrOptions:{errorCorrectionLevel:"M"},dotsOptions:{color:"black",type:"rounded"},backgroundOptions:{color:"transparent"}}),s.current.append(i.current)}function q(){r.connect(e,{request:{tonProof:u}})}function U(){if("deepLink"in e){if(!e.deepLink||!P)return;const z=new URL(P),ue=`${e.deepLink}${z.search}`;window.open(ue)}}function K(){"universalLink"in e&&e.universalLink&&/t.me/.test(e.universalLink)&&window.open(P)}const J=Pe.useMemo(()=>!!("deepLink"in e&&e.deepLink),[e]),T=Pe.useMemo(()=>!!("universalLink"in e&&e.universalLink&&/t.me/.test(e.universalLink)),[e]);return Pe.useEffect(()=>{$(),k()},[]),me.jsxs(Ec,{children:[me.jsx("div",{className:"xc-mb-6",children:me.jsx(ah,{title:"Connect wallet",onBack:t.onBack})}),me.jsxs("div",{className:"xc-text-center xc-mb-6",children:[me.jsxs("div",{className:"xc-relative xc-mx-auto xc-mb-6 xc-block xc-max-h-[272px] xc-max-w-[272px] xc-rounded-xl xc-bg-white xc-p-1",children:[me.jsx("div",{className:"xc-aspect-[1/1] xc-flex xc-h-full xc-w-full xc-justify-center",ref:i}),me.jsx("div",{className:"xc-absolute xc-left-0 xc-top-0 xc-flex xc-h-full xc-w-full xc-items-center xc-justify-center",children:y?me.jsx(mc,{className:"xc-h-6 xc-w-6 xc-animate-spin xc-text-black",size:20}):me.jsx("img",{className:"xc-h-10 xc-w-10 xc-rounded-md",src:e.imageUrl})})]}),me.jsx("p",{className:"xc-text-center",children:"Scan the QR code below with your phone's camera. "})]}),me.jsxs("div",{className:"xc-flex xc-justify-center xc-gap-2",children:[n&&me.jsx(mc,{className:"xc-animate-spin"}),!y&&!n&&me.jsxs(me.Fragment,{children:[$7(e)&&me.jsxs(kb,{onClick:q,children:[me.jsx(PK,{className:"xc-opacity-80"}),"Extension"]}),J&&me.jsxs(kb,{onClick:U,children:[me.jsx(u8,{className:"xc-opacity-80"}),"Desktop"]}),T&&me.jsx(kb,{onClick:K,children:"Telegram Mini App"})]})]})]})}function xQ(t){const[e,r]=Pe.useState(""),[n,i]=Pe.useState(),[s,o]=Pe.useState(),a=Pb(),[u,l]=Pe.useState(!1);async function d(y){var P,N;if(!y||!((P=y.connectItems)!=null&&P.tonProof))return;l(!0);const A=await ma.tonLogin({account_type:"block_chain",connector:"codatta_ton",account_enum:"C",wallet_name:y==null?void 0:y.device.appName,inviter_code:a.inviterCode,address:y.account.address,chain:y.account.chain,connect_info:[{name:"ton_addr",network:y.account.chain,...y.account},(N=y.connectItems)==null?void 0:N.tonProof],source:{device:a.device,channel:a.channel,app:a.app}});await t.onLogin(A.data),l(!1)}Pe.useEffect(()=>{const y=new ip({manifestUrl:"https://static.codatta.io/static/tonconnect-manifest.json?v=2"}),A=y.onStatusChange(d);return o(y),r("select"),A},[]);function g(y){r("connect"),i(y)}return me.jsxs(Ec,{children:[e==="select"&&me.jsx(SZ,{connector:s,onSelect:g,onBack:t.onBack}),e==="connect"&&me.jsx(wQ,{connector:s,wallet:n,onBack:t.onBack,loading:u})]})}function _Q(t){const{children:e,className:r}=t,n=Pe.useRef(null),[i,s]=Pe.useState(0);function o(){var a;try{const u=((a=n.current)==null?void 0:a.children)||[];let l=0;for(let d=0;d{const a=new MutationObserver(o);return a.observe(n.current,{childList:!0,subtree:!0}),()=>a.disconnect()},[]),Pe.useEffect(()=>{console.log("maxHeight",i)},[i]),me.jsx("div",{ref:n,className:r,style:{transition:"all 0.2s ease-in-out",overflow:"hidden",height:i},children:e})}function EQ(){return me.jsxs("svg",{width:"121",height:"120",viewBox:"0 0 121 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[me.jsx("rect",{x:"0.5",width:"120",height:"120",rx:"60",fill:"#404049"}),me.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M52.8709 61.106C52.8208 61.4482 52.7948 61.7979 52.7948 62.1535C52.7948 66.2529 56.2445 69.5761 60.5 69.5761C64.7554 69.5761 68.2052 66.2529 68.2052 62.1535C68.2052 61.7979 68.1792 61.4482 68.129 61.106H86.826V77.6174C86.826 78.6422 85.9636 79.473 84.8997 79.473H36.1002C35.0364 79.473 34.174 78.6422 34.174 77.6174V61.106H52.8709Z",fill:"#252532"}),me.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M69.061 60.9416C69.061 65.6697 65.2281 69.5026 60.5 69.5026C55.7719 69.5026 51.939 65.6697 51.939 60.9416C51.939 60.7884 51.943 60.6362 51.951 60.485H33.5L39.7959 41.8696C40.0673 41.0671 40.8202 40.527 41.6674 40.527H79.3326C80.1798 40.527 80.9327 41.0671 81.2041 41.8696L87.5 60.485H69.049C69.057 60.6362 69.061 60.7884 69.061 60.9416Z",fill:"#252532"}),me.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M67.8081 61.5708C67.8081 65.2243 64.5361 68.8446 60.4999 68.8446C56.4637 68.8446 53.1918 65.2243 53.1918 61.5708C53.1918 61.4524 53.1952 60.6762 53.202 60.5594H39.4268L44.8013 47.4919C45.033 46.8717 45.6757 46.4543 46.3989 46.4543H74.601C75.3242 46.4543 75.9669 46.8717 76.1986 47.4919L81.5731 60.5594H67.7979C67.8046 60.6762 67.8081 61.4524 67.8081 61.5708Z",fill:"#404049"}),me.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M34.3232 60.6199V78.063C34.3232 78.6995 34.8392 79.2155 35.4757 79.2155H85.5245C86.1609 79.2155 86.6769 78.6995 86.6769 78.063V60.6199L80.4244 42.1328C80.2661 41.6647 79.8269 41.3496 79.3327 41.3496H41.6674C41.1733 41.3496 40.7341 41.6647 40.5758 42.1328L34.3232 60.6199Z",stroke:"#77777D","stroke-width":"2"}),me.jsx("path",{d:"M34.817 60.2823C37.4094 60.2823 48.1095 60.2823 51.1124 60.2823C52.348 60.2823 52.348 61.1507 52.348 61.5994C52.348 65.9638 55.9675 69.5019 60.4323 69.5019C64.8971 69.5019 68.5165 65.9638 68.5165 61.5994C68.5165 61.1507 68.5165 60.2823 69.7521 60.2823H86.1829",stroke:"#77777D","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]})}function SQ(t){const{wallets:e}=Wl(),[r,n]=Pe.useState(),i=Pe.useMemo(()=>r?e.filter(a=>a.key.toLowerCase().includes(r.toLowerCase())):e,[r]);function s(a){t.onSelectWallet(a)}function o(a){n(a.target.value)}return me.jsxs(Ec,{children:[me.jsx("div",{className:"xc-mb-6",children:me.jsx(ah,{title:"Select wallet",onBack:t.onBack})}),me.jsxs("div",{className:"xc-mb-6 xc-flex xc-gap-3 xc-px-4 xc-py-2 xc-border xc-rounded-xl xc-w-full xc-overflow-hidden xc-items-center xc-border-opacity-15 xc-border-white focus-within:xc-border-opacity-40",children:[me.jsx(f8,{className:"xc-shrink-0 xc-opacity-50"}),me.jsx("input",{type:"text",className:"xc-flex-1 xc-bg-transparent xc-appearance-none xc-outline-none",placeholder:"Search wallet",onInput:o})]}),me.jsx("div",{className:"xc-mb-4 xc-flex xc-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar",children:i.length?i.map(a=>me.jsx(QS,{wallet:a,onClick:s},`feature-${a.key}`)):me.jsx(EQ,{})})]})}function AQ(t){const{onLogin:e,header:r,showEmailSignIn:n=!0,showMoreWallets:i=!0,showTonConnect:s=!0,showFeaturedWallets:o=!0}=t,[a,u]=Pe.useState(""),[l,d]=Pe.useState(null),[g,y]=Pe.useState("");function A(k){d(k),u("evm-wallet")}function P(k){u("email"),y(k)}async function N(k){await e(k)}function D(){u("ton-wallet")}return Pe.useEffect(()=>{u("index")},[]),me.jsx(XX,{config:t.config,children:me.jsxs(_Q,{className:"xc-rounded-2xl xc-transition-height xc-box-content xc-w-full xc-min-w-[277px] xc-max-w-[420px] xc-p-6 xc-bg-[rgb(28,28,38)] xc-text-white",children:[a==="evm-wallet"&&me.jsx(_Z,{onBack:()=>u("index"),onLogin:N,wallet:l}),a==="ton-wallet"&&me.jsx(xQ,{onBack:()=>u("index"),onLogin:N}),a==="email"&&me.jsx(ZX,{email:g,onBack:()=>u("index"),onLogin:N}),a==="index"&&me.jsx(kX,{header:r,onEmailConfirm:P,onSelectWallet:A,onSelectMoreWallets:()=>{u("all-wallet")},onSelectTonConnect:D,config:{showEmailSignIn:n,showFeaturedWallets:o,showMoreWallets:i,showTonConnect:s}}),a==="all-wallet"&&me.jsx(SQ,{onBack:()=>u("index"),onSelectWallet:A})]})})}Vn.CodattaConnectContextProvider=bK,Vn.CodattaSignin=AQ,Vn.coinbaseWallet=s8,Vn.useCodattaConnectContext=Wl,Object.defineProperty(Vn,Symbol.toStringTag,{value:"Module"})}); + ***************************************************************************** */function GY(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i{var i,s;if(!((i=void 0)===null||i===void 0)&&i.aborted){n(new $t("Delay aborted"));return}const o=setTimeout(()=>r(),t);(s=void 0)===null||s===void 0||s.addEventListener("abort",()=>{clearTimeout(o),n(new $t("Delay aborted"))})})})}function hs(t){const e=new AbortController;return t?.aborted?e.abort():t?.addEventListener("abort",()=>e.abort(),{once:!0}),e}function cl(t,e){var r,n;return At(this,void 0,void 0,function*(){const i=(r=e?.attempts)!==null&&r!==void 0?r:10,s=(n=e?.delayMs)!==null&&n!==void 0?n:200,o=hs(e?.signal);if(typeof t!="function")throw new $t(`Expected a function, got ${typeof t}`);let a=0,f;for(;aAt(this,void 0,void 0,function*(){if(s=g??null,o?.abort(),o=hs(g),o.signal.aborted)throw new $t("Resource creation was aborted");n=b??null;const x=t(o.signal,...b);i=x;const S=yield x;if(i!==x&&S!==r)throw yield e(S),new $t("Resource creation was aborted by a new resource creation");return r=S,r});return{create:a,current:()=>r??null,dispose:()=>At(this,void 0,void 0,function*(){try{const g=r;r=null;const b=i;i=null;try{o?.abort()}catch{}yield Promise.allSettled([g?e(g):Promise.resolve(),b?e(yield b):Promise.resolve()])}catch{}}),recreate:g=>At(this,void 0,void 0,function*(){const b=r,x=i,S=n,C=s;if(yield b7(g),b===r&&x===i&&S===n&&C===s)return yield a(s,...S??[]);throw new $t("Resource recreation was aborted by a new resource creation")})}}function oJ(t,e){const r=e?.timeout,n=e?.signal,i=hs(n);return new Promise((s,o)=>At(this,void 0,void 0,function*(){if(i.signal.aborted){o(new $t("Operation aborted"));return}let a;typeof r<"u"&&(a=setTimeout(()=>{i.abort(),o(new $t(`Timeout after ${r}ms`))},r)),i.signal.addEventListener("abort",()=>{clearTimeout(a),o(new $t("Operation aborted"))},{once:!0});const f={timeout:r,abort:i.signal};yield t((...u)=>{clearTimeout(a),s(...u)},()=>{clearTimeout(a),o()},f)}))}class K1{constructor(e,r,n,i,s){this.bridgeUrl=r,this.sessionId=n,this.listener=i,this.errorsListener=s,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=sJ((o,a)=>At(this,void 0,void 0,function*(){const f={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:o,openingDeadlineMS:a};return yield aJ(f)}),o=>At(this,void 0,void 0,function*(){o.close()})),this.bridgeGatewayStorage=new eJ(e,r)}get isReady(){const e=this.eventSource.current();return e?.readyState===EventSource.OPEN}get isClosed(){const e=this.eventSource.current();return e?.readyState!==EventSource.OPEN}get isConnecting(){const e=this.eventSource.current();return e?.readyState===EventSource.CONNECTING}registerSession(e){return At(this,void 0,void 0,function*(){yield this.eventSource.create(e?.signal,e?.openingDeadlineMS)})}send(e,r,n,i){var s;return At(this,void 0,void 0,function*(){const o={};typeof i=="number"?o.ttl=i:(o.ttl=i?.ttl,o.signal=i?.signal,o.attempts=i?.attempts);const a=new URL(v7(this.bridgeUrl,this.postPath));a.searchParams.append("client_id",this.sessionId),a.searchParams.append("to",r),a.searchParams.append("ttl",(o?.ttl||this.defaultTtl).toString()),a.searchParams.append("topic",n);const f=p7.encode(e);yield cl(u=>At(this,void 0,void 0,function*(){const h=yield this.post(a,f,u.signal);if(!h.ok)throw new $t(`Bridge send failed, status ${h.status}`)}),{attempts:(s=o?.attempts)!==null&&s!==void 0?s:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:o?.signal})})}pause(){this.eventSource.dispose().catch(e=>co(`Bridge pause failed, ${e}`))}unPause(){return At(this,void 0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return At(this,void 0,void 0,function*(){yield this.eventSource.dispose().catch(e=>co(`Bridge close failed, ${e}`))})}setListener(e){this.listener=e}setErrorsListener(e){this.errorsListener=e}post(e,r,n){return At(this,void 0,void 0,function*(){const i=yield fetch(e,{method:"post",body:r,signal:n});if(!i.ok)throw new $t(`Bridge send failed, status ${i.status}`);return i})}errorsHandler(e,r){return At(this,void 0,void 0,function*(){if(this.isConnecting)throw e.close(),new $t("Bridge error, failed to connect");if(this.isReady){try{this.errorsListener(r)}catch{}return}if(this.isClosed)return e.close(),xn(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new $t("Bridge error, unknown state")})}messagesHandler(e){return At(this,void 0,void 0,function*(){if(e.data===this.heartbeatMessage||(yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId),this.isClosed))return;let r;try{r=JSON.parse(e.data)}catch(n){throw new $t(`Bridge message parse failed, message ${n.data}`)}this.listener(r)})}}function aJ(t){return At(this,void 0,void 0,function*(){return yield oJ((e,r,n)=>At(this,void 0,void 0,function*(){var i;const o=hs(n.signal).signal;if(o.aborted){r(new $t("Bridge connection aborted"));return}const a=new URL(v7(t.bridgeUrl,t.ssePath));a.searchParams.append("client_id",t.sessionId);const f=yield t.bridgeGatewayStorage.getLastEventId();if(f&&a.searchParams.append("last_event_id",f),o.aborted){r(new $t("Bridge connection aborted"));return}const u=new EventSource(a.toString());u.onerror=h=>At(this,void 0,void 0,function*(){if(o.aborted){u.close(),r(new $t("Bridge connection aborted"));return}try{const g=yield t.errorHandler(u,h);g!==u&&u.close(),g&&g!==u&&e(g)}catch(g){u.close(),r(g)}}),u.onopen=()=>{if(o.aborted){u.close(),r(new $t("Bridge connection aborted"));return}e(u)},u.onmessage=h=>{if(o.aborted){u.close(),r(new $t("Bridge connection aborted"));return}t.messageHandler(h)},(i=t.signal)===null||i===void 0||i.addEventListener("abort",()=>{u.close(),r(new $t("Bridge connection aborted"))})}),{timeout:t.openingDeadlineMS,signal:t.signal})})}function ul(t){return!("connectEvent"in t)}class fl{constructor(e){this.storage=e,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(e){return At(this,void 0,void 0,function*(){if(e.type==="injected")return this.storage.setItem(this.storeKey,JSON.stringify(e));if(!ul(e)){const n={sessionKeyPair:e.session.sessionCrypto.stringifyKeypair(),walletPublicKey:e.session.walletPublicKey,bridgeUrl:e.session.bridgeUrl},i={type:"http",connectEvent:e.connectEvent,session:n,lastWalletEventId:e.lastWalletEventId,nextRpcRequestId:e.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(i))}const r={type:"http",connectionSource:e.connectionSource,sessionCrypto:e.sessionCrypto.stringifyKeypair()};return this.storage.setItem(this.storeKey,JSON.stringify(r))})}removeConnection(){return At(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return At(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);if(!e)return null;const r=JSON.parse(e);if(r.type==="injected")return r;if("connectEvent"in r){const n=new $1(r.session.sessionKeyPair);return{type:"http",connectEvent:r.connectEvent,lastWalletEventId:r.lastWalletEventId,nextRpcRequestId:r.nextRpcRequestId,session:{sessionCrypto:n,bridgeUrl:r.session.bridgeUrl,walletPublicKey:r.session.walletPublicKey}}}return{type:"http",sessionCrypto:new $1(r.sessionCrypto),connectionSource:r.connectionSource}})}getHttpConnection(){return At(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new $t("Trying to read HTTP connection source while nothing is stored");if(e.type==="injected")throw new $t("Trying to read HTTP connection source while injected connection is stored");return e})}getHttpPendingConnection(){return At(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new $t("Trying to read HTTP connection source while nothing is stored");if(e.type==="injected")throw new $t("Trying to read HTTP connection source while injected connection is stored");if(!ul(e))throw new $t("Trying to read HTTP-pending connection while http connection is stored");return e})}getInjectedConnection(){return At(this,void 0,void 0,function*(){const e=yield this.getConnection();if(!e)throw new $t("Trying to read Injected bridge connection source while nothing is stored");if(e?.type==="http")throw new $t("Trying to read Injected bridge connection source while HTTP connection is stored");return e})}storedConnectionType(){return At(this,void 0,void 0,function*(){const e=yield this.storage.getItem(this.storeKey);return e?JSON.parse(e).type:null})}storeLastWalletEventId(e){return At(this,void 0,void 0,function*(){const r=yield this.getConnection();if(r&&r.type==="http"&&!ul(r))return r.lastWalletEventId=e,this.storeConnection(r)})}getLastWalletEventId(){return At(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"lastWalletEventId"in e)return e.lastWalletEventId})}increaseNextRpcRequestId(){return At(this,void 0,void 0,function*(){const e=yield this.getConnection();if(e&&"nextRpcRequestId"in e){const r=e.nextRpcRequestId||0;return e.nextRpcRequestId=r+1,this.storeConnection(e)}})}getNextRpcRequestId(){return At(this,void 0,void 0,function*(){const e=yield this.getConnection();return e&&"nextRpcRequestId"in e&&e.nextRpcRequestId||0})}}const y7=2;class ll{constructor(e,r){this.storage=e,this.walletConnectionSource=r,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.connectionStorage=new fl(e)}static fromStorage(e){return At(this,void 0,void 0,function*(){const n=yield new fl(e).getHttpConnection();return ul(n)?new ll(e,n.connectionSource):new ll(e,{bridgeUrl:n.session.bridgeUrl})})}connect(e,r){var n;const i=hs(r?.signal);(n=this.abortController)===null||n===void 0||n.abort(),this.abortController=i,this.closeGateways();const s=new $1;this.session={sessionCrypto:s,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:s}).then(()=>At(this,void 0,void 0,function*(){i.signal.aborted||(yield cl(a=>{var f;return this.openGateways(s,{openingDeadlineMS:(f=r?.openingDeadlineMS)!==null&&f!==void 0?f:this.defaultOpeningDeadlineMS,signal:a?.signal})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:i.signal}))}));const o="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(o,e)}restoreConnection(e){var r,n;return At(this,void 0,void 0,function*(){const i=hs(e?.signal);if((r=this.abortController)===null||r===void 0||r.abort(),this.abortController=i,i.signal.aborted)return;this.closeGateways();const s=yield this.connectionStorage.getHttpConnection();if(!s||i.signal.aborted)return;const o=(n=e?.openingDeadlineMS)!==null&&n!==void 0?n:this.defaultOpeningDeadlineMS;if(ul(s))return this.session={sessionCrypto:s.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways(s.sessionCrypto,{openingDeadlineMS:o,signal:i?.signal});if(Array.isArray(this.walletConnectionSource))throw new $t("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=s.session,this.gateway&&(xn("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new K1(this.storage,this.walletConnectionSource.bridgeUrl,s.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),!i.signal.aborted){this.listeners.forEach(a=>a(s.connectEvent));try{yield cl(a=>this.gateway.registerSession({openingDeadlineMS:o,signal:a.signal}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:i.signal})}catch{yield this.disconnect({signal:i.signal});return}}})}sendRequest(e,r){const n={};return typeof r=="function"?n.onRequestSent=r:(n.onRequestSent=r?.onRequestSent,n.signal=r?.signal,n.attempts=r?.attempts),new Promise((i,s)=>At(this,void 0,void 0,function*(){var o;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new $t("Trying to send bridge request without session");const a=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),xn("Send http-bridge request:",Object.assign(Object.assign({},e),{id:a}));const f=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},e),{id:a})),Kd(this.session.walletPublicKey));try{yield this.gateway.send(f,this.session.walletPublicKey,e.method,{attempts:n?.attempts,signal:n?.signal}),(o=n?.onRequestSent)===null||o===void 0||o.call(n),this.pendingRequests.set(a.toString(),i)}catch(u){s(u)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(e){return At(this,void 0,void 0,function*(){return new Promise(r=>At(this,void 0,void 0,function*(){let n=!1,i=null;const s=()=>{n||(n=!0,this.removeBridgeAndSession().then(r))};try{this.closeGateways();const o=hs(e?.signal);i=setTimeout(()=>{o.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:s,signal:o.signal,attempts:1})}catch(o){xn("Disconnect error:",o),n||this.removeBridgeAndSession().then(r)}finally{i&&clearTimeout(i),s()}}))})}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(r=>r!==e)}pause(){var e;(e=this.gateway)===null||e===void 0||e.pause(),this.pendingGateways.forEach(r=>r.pause())}unPause(){return At(this,void 0,void 0,function*(){const e=this.pendingGateways.map(r=>r.unPause());this.gateway&&e.push(this.gateway.unPause()),yield Promise.all(e)})}pendingGatewaysListener(e,r,n){return At(this,void 0,void 0,function*(){if(!this.pendingGateways.includes(e)){yield e.close();return}return this.closeGateways({except:e}),this.gateway&&(xn("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=r,this.gateway=e,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(n)})}gatewayListener(e){return At(this,void 0,void 0,function*(){const r=JSON.parse(this.session.sessionCrypto.decrypt(p7.decode(e.message).toUint8Array(),Kd(e.from)));if(xn("Wallet message received:",r),!("event"in r)){const i=r.id.toString(),s=this.pendingRequests.get(i);if(!s){xn(`Response id ${i} doesn't match any request's id`);return}s(r),this.pendingRequests.delete(i);return}if(r.id!==void 0){const i=yield this.connectionStorage.getLastWalletEventId();if(i!==void 0&&r.id<=i){co(`Received event id (=${r.id}) must be greater than stored last wallet event id (=${i}) `);return}r.event!=="connect"&&(yield this.connectionStorage.storeLastWalletEventId(r.id))}const n=this.listeners;r.event==="connect"&&(yield this.updateSession(r,e.from)),r.event==="disconnect"&&(xn("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),n.forEach(i=>i(r))})}gatewayErrorsListener(e){return At(this,void 0,void 0,function*(){throw new $t(`Bridge error ${JSON.stringify(e)}`)})}updateSession(e,r){return At(this,void 0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:r});const n=e.payload.items.find(s=>s.name==="ton_addr"),i=Object.assign(Object.assign({},e),{payload:Object.assign(Object.assign({},e.payload),{items:[n]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:e.id,connectEvent:i,nextRpcRequestId:0})})}removeBridgeAndSession(){return At(this,void 0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(e,r){return rJ(e)?this.generateTGUniversalLink(e,r):this.generateRegularUniversalLink(e,r)}generateRegularUniversalLink(e,r){const n=new URL(e);return n.searchParams.append("v",y7.toString()),n.searchParams.append("id",this.session.sessionCrypto.sessionId),n.searchParams.append("r",JSON.stringify(r)),n.toString()}generateTGUniversalLink(e,r){const i=this.generateRegularUniversalLink("about:blank",r).split("?")[1],s="tonconnect-"+nJ(i),o=this.convertToDirectLink(e),a=new URL(o);return a.searchParams.append("startapp",s),a.toString()}convertToDirectLink(e){const r=new URL(e);return r.searchParams.has("attach")&&(r.searchParams.delete("attach"),r.pathname+="/start"),r.toString()}openGateways(e,r){return At(this,void 0,void 0,function*(){if(Array.isArray(this.walletConnectionSource)){this.pendingGateways.map(n=>n.close().catch()),this.pendingGateways=this.walletConnectionSource.map(n=>{const i=new K1(this.storage,n.bridgeUrl,e.sessionId,()=>{},()=>{});return i.setListener(s=>this.pendingGatewaysListener(i,n.bridgeUrl,s)),i}),yield Promise.allSettled(this.pendingGateways.map(n=>cl(i=>{var s;return this.pendingGateways.some(o=>o===n)?n.registerSession({openingDeadlineMS:(s=r?.openingDeadlineMS)!==null&&s!==void 0?s:this.defaultOpeningDeadlineMS,signal:i.signal}):n.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:r?.signal})));return}else return this.gateway&&(xn("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new K1(this.storage,this.walletConnectionSource.bridgeUrl,e.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.gateway.registerSession({openingDeadlineMS:r?.openingDeadlineMS,signal:r?.signal})})}closeGateways(e){var r;(r=this.gateway)===null||r===void 0||r.close(),this.pendingGateways.filter(n=>n!==e?.except).forEach(n=>n.close()),this.pendingGateways=[]}}function w7(t,e){return x7(t,[e])}function x7(t,e){return!t||typeof t!="object"?!1:e.every(r=>r in t)}function cJ(t){try{return!w7(t,"tonconnect")||!w7(t.tonconnect,"walletInfo")?!1:x7(t.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch{return!1}}class Yc{constructor(){this.storage={}}static getInstance(){return Yc.instance||(Yc.instance=new Yc),Yc.instance}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(e){var r;return(r=this.storage[e])!==null&&r!==void 0?r:null}key(e){var r;const n=Object.keys(this.storage);return e<0||e>=n.length?null:(r=n[e])!==null&&r!==void 0?r:null}removeItem(e){delete this.storage[e]}setItem(e,r){this.storage[e]=r}}function e0(){if(!(typeof window>"u"))return window}function uJ(){const t=e0();if(!t)return[];try{return Object.keys(t)}catch{return[]}}function fJ(){if(!(typeof document>"u"))return document}function lJ(){var t;const e=(t=e0())===null||t===void 0?void 0:t.location.origin;return e?e+"/tonconnect-manifest.json":""}function hJ(){if(dJ())return localStorage;if(pJ())throw new $t("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return Yc.getInstance()}function dJ(){try{return typeof localStorage<"u"}catch{return!1}}function pJ(){return typeof process<"u"&&process.versions!=null&&process.versions.node!=null}class ui{constructor(e,r){this.injectedWalletKey=r,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const n=ui.window;if(!ui.isWindowContainsWallet(n,r))throw new H1;this.connectionStorage=new fl(e),this.injectedWallet=n[r].tonconnect}static fromStorage(e){return At(this,void 0,void 0,function*(){const n=yield new fl(e).getInjectedConnection();return new ui(e,n.jsBridgeKey)})}static isWalletInjected(e){return ui.isWindowContainsWallet(this.window,e)}static isInsideWalletBrowser(e){return ui.isWindowContainsWallet(this.window,e)?this.window[e].tonconnect.isWalletBrowser:!1}static getCurrentlyInjectedWallets(){return this.window?uJ().filter(([n,i])=>cJ(i)).map(([n,i])=>({name:i.tonconnect.walletInfo.name,appName:i.tonconnect.walletInfo.app_name,aboutUrl:i.tonconnect.walletInfo.about_url,imageUrl:i.tonconnect.walletInfo.image,tondns:i.tonconnect.walletInfo.tondns,jsBridgeKey:n,injected:!0,embedded:i.tonconnect.isWalletBrowser,platforms:i.tonconnect.walletInfo.platforms})):[]}static isWindowContainsWallet(e,r){return!!e&&r in e&&typeof e[r]=="object"&&"tonconnect"in e[r]}connect(e){this._connect(y7,e)}restoreConnection(){return At(this,void 0,void 0,function*(){try{xn("Injected Provider restoring connection...");const e=yield this.injectedWallet.restoreConnection();xn("Injected Provider restoring connection response",e),e.event==="connect"?(this.makeSubscriptions(),this.listeners.forEach(r=>r(e))):yield this.connectionStorage.removeConnection()}catch(e){yield this.connectionStorage.removeConnection(),console.error(e)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return At(this,void 0,void 0,function*(){return new Promise(e=>{const r=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(e)};try{this.injectedWallet.disconnect(),r()}catch(n){xn(n),this.sendRequest({method:"disconnect",params:[]},r)}})})}closeAllListeners(){var e;this.listenSubscriptions=!1,this.listeners=[],(e=this.unsubscribeCallback)===null||e===void 0||e.call(this)}listen(e){return this.listeners.push(e),()=>this.listeners=this.listeners.filter(r=>r!==e)}sendRequest(e,r){var n;return At(this,void 0,void 0,function*(){const i={};typeof r=="function"?i.onRequestSent=r:(i.onRequestSent=r?.onRequestSent,i.signal=r?.signal);const s=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),xn("Send injected-bridge request:",Object.assign(Object.assign({},e),{id:s}));const o=this.injectedWallet.send(Object.assign(Object.assign({},e),{id:s}));return o.then(a=>xn("Wallet message received:",a)),(n=i?.onRequestSent)===null||n===void 0||n.call(i),o})}_connect(e,r){return At(this,void 0,void 0,function*(){try{xn(`Injected Provider connect request: protocolVersion: ${e}, message:`,r);const n=yield this.injectedWallet.connect(e,r);xn("Injected Provider connect response:",n),n.event==="connect"&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach(i=>i(n))}catch(n){xn("Injected Provider connect error:",n);const i={event:"connect_error",payload:{code:0,message:n?.toString()}};this.listeners.forEach(s=>s(i))}})}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen(e=>{xn("Wallet message received:",e),this.listenSubscriptions&&this.listeners.forEach(r=>r(e)),e.event==="disconnect"&&this.disconnect()})}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}ui.window=e0();class gJ{constructor(){this.localStorage=hJ()}getItem(e){return At(this,void 0,void 0,function*(){return this.localStorage.getItem(e)})}removeItem(e){return At(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}setItem(e,r){return At(this,void 0,void 0,function*(){this.localStorage.setItem(e,r)})}}function _7(t){return vJ(t)&&t.injected}function mJ(t){return _7(t)&&t.embedded}function vJ(t){return"jsBridgeKey"in t}const bJ=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.ton.space/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"]},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.delab.team/bridge"}],platforms:["ios","android"]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitkeepwallet/download/main/logo/png/bitget_wallet_logo_0_gas_fee.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://bridge.tonapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect"},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]},{app_name:"okxTonWalletTr",name:"OKX TR Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/587A8296F0BB640F.png",about_url:"https://tr.okx.com/web3",universal_url:"https://tr.okx.com/download?appendQuery=true&deeplink=okxtr://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]}];class V1{constructor(e){this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null,this.walletsListSource="https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",e?.walletsListSource&&(this.walletsListSource=e.walletsListSource),e?.cacheTTLMs&&(this.cacheTTLMs=e.cacheTTLMs)}getWallets(){return At(this,void 0,void 0,function*(){return this.cacheTTLMs&&this.walletsListCacheCreationTimestamp&&Date.now()>this.walletsListCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListCache=null),this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.then(()=>{this.walletsListCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null})),this.walletsListCache})}getEmbeddedWallet(){return At(this,void 0,void 0,function*(){const r=(yield this.getWallets()).filter(mJ);return r.length!==1?null:r[0]})}fetchWalletsList(){return At(this,void 0,void 0,function*(){let e=[];try{if(e=yield(yield fetch(this.walletsListSource)).json(),!Array.isArray(e))throw new W1("Wrong wallets list format, wallets list must be an array.");const i=e.filter(s=>!this.isCorrectWalletConfigDTO(s));i.length&&(co(`Wallet(s) ${i.map(s=>s.name).join(", ")} config format is wrong. They were removed from the wallets list.`),e=e.filter(s=>this.isCorrectWalletConfigDTO(s)))}catch(n){co(n),e=bJ}let r=[];try{r=ui.getCurrentlyInjectedWallets()}catch(n){co(n)}return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e),r)})}walletConfigDTOListToWalletConfigList(e){return e.map(r=>{const i={name:r.name,appName:r.app_name,imageUrl:r.image,aboutUrl:r.about_url,tondns:r.tondns,platforms:r.platforms};return r.bridge.forEach(s=>{if(s.type==="sse"&&(i.bridgeUrl=s.url,i.universalLink=r.universal_url,i.deepLink=r.deepLink),s.type==="js"){const o=s.key;i.jsBridgeKey=o,i.injected=ui.isWalletInjected(o),i.embedded=ui.isInsideWalletBrowser(o)}}),i})}mergeWalletsLists(e,r){return[...new Set(e.concat(r).map(i=>i.name)).values()].map(i=>{const s=e.find(a=>a.name===i),o=r.find(a=>a.name===i);return Object.assign(Object.assign({},s&&Object.assign({},s)),o&&Object.assign({},o))})}isCorrectWalletConfigDTO(e){if(!e||typeof e!="object")return!1;const r="name"in e,n="app_name"in e,i="image"in e,s="about_url"in e,o="platforms"in e;if(!r||!i||!s||!o||!n||!e.platforms||!Array.isArray(e.platforms)||!e.platforms.length||!("bridge"in e)||!Array.isArray(e.bridge)||!e.bridge.length)return!1;const a=e.bridge;if(a.some(h=>!h||typeof h!="object"||!("type"in h)))return!1;const f=a.find(h=>h.type==="sse");if(f&&(!("url"in f)||!f.url||!e.universal_url))return!1;const u=a.find(h=>h.type==="js");return!(u&&(!("key"in u)||!u.key))}}class t0 extends $t{get info(){return"Wallet doesn't support requested feature method."}constructor(...e){super(...e),Object.setPrototypeOf(this,t0.prototype)}}function yJ(t,e){const r=t.includes("SendTransaction"),n=t.find(i=>i&&typeof i=="object"&&i.name==="SendTransaction");if(!r&&!n)throw new t0("Wallet doesn't support SendTransaction feature.");if(n&&n.maxMessages!==void 0){if(n.maxMessages{var a,f;return{address:(a=o.address)!==null&&a!==void 0?a:null,amount:(f=o.amount)!==null&&f!==void 0?f:null}})}}function MJ(t,e,r){return Object.assign(Object.assign({type:"transaction-sent-for-signature"},Xc(t,e)),G1(e,r))}function CJ(t,e,r,n){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:n.boc},Xc(t,e)),G1(e,r))}function RJ(t,e,r,n,i){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:n,error_code:i??null},Xc(t,e)),G1(e,r))}function TJ(t,e,r){return Object.assign({type:"disconnection",scope:r},Xc(t,e))}class DJ{constructor(){this.window=e0()}dispatchEvent(e,r){var n;return At(this,void 0,void 0,function*(){const i=new CustomEvent(e,{detail:r});(n=this.window)===null||n===void 0||n.dispatchEvent(i)})}addEventListener(e,r,n){var i;return At(this,void 0,void 0,function*(){return(i=this.window)===null||i===void 0||i.addEventListener(e,r,n),()=>{var s;return(s=this.window)===null||s===void 0?void 0:s.removeEventListener(e,r)}})}}class OJ{constructor(e){var r;this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=(r=e?.eventDispatcher)!==null&&r!==void 0?r:new DJ,this.tonConnectSdkVersion=e.tonConnectSdkVersion,this.init().catch()}get version(){return Jc({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return At(this,void 0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch{}})}setRequestVersionHandler(){return At(this,void 0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>At(this,void 0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",xJ(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return At(this,void 0,void 0,function*(){return new Promise((e,r)=>At(this,void 0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",n=>{e(n.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",wJ())}catch(n){r(n)}}))})}dispatchUserActionEvent(e){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`,e).catch()}catch{}}trackConnectionStarted(...e){try{const r=_J(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionCompleted(...e){try{const r=EJ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionError(...e){try{const r=SJ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionRestoringStarted(...e){try{const r=AJ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionRestoringCompleted(...e){try{const r=PJ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackConnectionRestoringError(...e){try{const r=IJ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackDisconnection(...e){try{const r=TJ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackTransactionSentForSignature(...e){try{const r=MJ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackTransactionSigned(...e){try{const r=CJ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}trackTransactionSigningFailed(...e){try{const r=RJ(this.version,...e);this.dispatchUserActionEvent(r)}catch{}}}const NJ="3.0.5";class hl{constructor(e){if(this.walletsList=new V1,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:e?.manifestUrl||lJ(),storage:e?.storage||new gJ},this.walletsList=new V1({walletsListSource:e?.walletsListSource,cacheTTLMs:e?.walletsListCacheTTLMs}),this.tracker=new OJ({eventDispatcher:e?.eventDispatcher,tonConnectSdkVersion:NJ}),!this.dappSettings.manifestUrl)throw new q1("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest");this.bridgeConnectionStorage=new fl(this.dappSettings.storage),e?.disableAutoPauseConnection||this.addWindowFocusAndBlurSubscriptions()}static getWallets(){return this.walletsList.getWallets()}get connected(){return this._wallet!==null}get account(){var e;return((e=this._wallet)===null||e===void 0?void 0:e.account)||null}get wallet(){return this._wallet}set wallet(e){this._wallet=e,this.statusChangeSubscriptions.forEach(r=>r(this._wallet))}getWallets(){return this.walletsList.getWallets()}onStatusChange(e,r){return this.statusChangeSubscriptions.push(e),r&&this.statusChangeErrorSubscriptions.push(r),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(n=>n!==e),r&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(n=>n!==r))}}connect(e,r){var n,i;const s={};if(typeof r=="object"&&"tonProof"in r&&(s.request=r),typeof r=="object"&&("openingDeadlineMS"in r||"signal"in r||"request"in r)&&(s.request=r?.request,s.openingDeadlineMS=r?.openingDeadlineMS,s.signal=r?.signal),this.connected)throw new z1;const o=hs(s?.signal);if((n=this.abortController)===null||n===void 0||n.abort(),this.abortController=o,o.signal.aborted)throw new $t("Connection was aborted");return(i=this.provider)===null||i===void 0||i.closeConnection(),this.provider=this.createProvider(e),o.signal.addEventListener("abort",()=>{var a;(a=this.provider)===null||a===void 0||a.closeConnection(),this.provider=null}),this.tracker.trackConnectionStarted(),this.provider.connect(this.createConnectRequest(s?.request),{openingDeadlineMS:s?.openingDeadlineMS,signal:o.signal})}restoreConnection(e){var r,n;return At(this,void 0,void 0,function*(){this.tracker.trackConnectionRestoringStarted();const i=hs(e?.signal);if((r=this.abortController)===null||r===void 0||r.abort(),this.abortController=i,i.signal.aborted){this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}const[s,o]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(i.signal.aborted){this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}let a=null;try{switch(s){case"http":a=yield ll.fromStorage(this.dappSettings.storage);break;case"injected":a=yield ui.fromStorage(this.dappSettings.storage);break;default:if(o)a=this.createProvider(o);else return}}catch{this.tracker.trackConnectionRestoringError("Provider is not restored"),yield this.bridgeConnectionStorage.removeConnection(),a?.closeConnection(),a=null;return}if(i.signal.aborted){a?.closeConnection(),this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}if(!a){co("Provider is not restored"),this.tracker.trackConnectionRestoringError("Provider is not restored");return}(n=this.provider)===null||n===void 0||n.closeConnection(),this.provider=a,a.listen(this.walletEventsListener.bind(this));const f=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted"),a?.closeConnection(),a=null};i.signal.addEventListener("abort",f);const u=cl(g=>At(this,void 0,void 0,function*(){yield a?.restoreConnection({openingDeadlineMS:e?.openingDeadlineMS,signal:g.signal}),i.signal.removeEventListener("abort",f),this.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):this.tracker.trackConnectionRestoringError("Connection restoring failed")}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:e?.signal}),h=new Promise(g=>setTimeout(()=>g(),12e3));return Promise.race([u,h])})}sendTransaction(e,r){return At(this,void 0,void 0,function*(){const n={};typeof r=="function"?n.onRequestSent=r:(n.onRequestSent=r?.onRequestSent,n.signal=r?.signal);const i=hs(n?.signal);if(i.signal.aborted)throw new $t("Transaction sending was aborted");this.checkConnection(),yJ(this.wallet.device.features,{requiredMessagesNumber:e.messages.length}),this.tracker.trackTransactionSentForSignature(this.wallet,e);const{validUntil:s}=e,o=GY(e,["validUntil"]),a=e.from||this.account.address,f=e.network||this.account.chain,u=yield this.provider.sendRequest(Qd.convertToRpcRequest(Object.assign(Object.assign({},o),{valid_until:s,from:a,network:f})),{onRequestSent:n.onRequestSent,signal:i.signal});if(Qd.isError(u))return this.tracker.trackTransactionSigningFailed(this.wallet,e,u.error.message,u.error.code),Qd.parseAndThrowError(u);const h=Qd.convertFromRpcResponse(u);return this.tracker.trackTransactionSigned(this.wallet,e,h),h})}disconnect(e){var r;return At(this,void 0,void 0,function*(){if(!this.connected)throw new Yd;const n=hs(e?.signal),i=this.abortController;if(this.abortController=n,n.signal.aborted)throw new $t("Disconnect was aborted");this.onWalletDisconnected("dapp"),yield(r=this.provider)===null||r===void 0?void 0:r.disconnect({signal:n.signal}),i?.abort()})}pauseConnection(){var e;((e=this.provider)===null||e===void 0?void 0:e.type)==="http"&&this.provider.pause()}unPauseConnection(){var e;return((e=this.provider)===null||e===void 0?void 0:e.type)!=="http"?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const e=fJ();if(e)try{e.addEventListener("visibilitychange",()=>{e.hidden?this.pauseConnection():this.unPauseConnection().catch()})}catch(r){co("Cannot subscribe to the document.visibilitychange: ",r)}}createProvider(e){let r;return!Array.isArray(e)&&YY(e)?r=new ui(this.dappSettings.storage,e.jsBridgeKey):r=new ll(this.dappSettings.storage,e),r.listen(this.walletEventsListener.bind(this)),r}walletEventsListener(e){switch(e.event){case"connect":this.onWalletConnected(e.payload);break;case"connect_error":this.onWalletConnectError(e.payload);break;case"disconnect":this.onWalletDisconnected("wallet")}}onWalletConnected(e){const r=e.items.find(s=>s.name==="ton_addr"),n=e.items.find(s=>s.name==="ton_proof");if(!r)throw new $t("ton_addr connection item was not found");const i={device:e.device,provider:this.provider.type,account:{address:r.address,chain:r.network,walletStateInit:r.walletStateInit,publicKey:r.publicKey}};n&&(i.connectItems={tonProof:n}),this.wallet=i,this.tracker.trackConnectionCompleted(i)}onWalletConnectError(e){const r=XY.parseError(e);if(this.statusChangeErrorSubscriptions.forEach(n=>n(r)),xn(r),this.tracker.trackConnectionError(e.message,e.code),r instanceof Gd||r instanceof Vd)throw co(r),r}onWalletDisconnected(e){this.tracker.trackDisconnection(this.wallet,e),this.wallet=null}checkConnection(){if(!this.connected)throw new Yd}createConnectRequest(e){const r=[{name:"ton_addr"}];return e?.tonProof&&r.push({name:"ton_proof",payload:e.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:r}}}hl.walletsList=new V1,hl.isWalletInjected=t=>ui.isWalletInjected(t),hl.isInsideWalletBrowser=t=>ui.isInsideWalletBrowser(t);for(let t=0;t<=255;t++){let e=t.toString(16);e.length<2&&(e="0"+e)}function Y1(t){const{children:e,onClick:r}=t;return he.jsx("button",{onClick:r,className:"xc-border xc-px-4 xc-py-2 xc-rounded-full xc-text-sm xc-flex xc-gap-2 xc-items-center",children:e})}function E7(t){const{wallet:e,connector:r,loading:n}=t,i=Se.useRef(null),s=Se.useRef(),[o,a]=Se.useState(),[f,u]=Se.useState(),[h,g]=Se.useState("connect"),[b,x]=Se.useState(!1),[S,C]=Se.useState();function D(W){s.current?.update({data:W})}async function B(){x(!0);try{a("");const W=await Fo.getNonce({account_type:"block_chain"});if("universalLink"in e&&e.universalLink){const V=r.connect({universalLink:e.universalLink,bridgeUrl:e.bridgeUrl},{request:{tonProof:W}});if(!V)return;C(V),D(V),u(W)}}catch(W){a(W.message)}x(!1)}function L(){s.current=new e7({width:264,height:264,margin:0,type:"svg",qrOptions:{errorCorrectionLevel:"M"},dotsOptions:{color:"black",type:"rounded"},backgroundOptions:{color:"transparent"}}),s.current.append(i.current)}function H(){r.connect(e,{request:{tonProof:f}})}function F(){if("deepLink"in e){if(!e.deepLink||!S)return;const W=new URL(S),V=`${e.deepLink}${W.search}`;window.open(V)}}function k(){"universalLink"in e&&e.universalLink&&/t.me/.test(e.universalLink)&&window.open(S)}const $=Se.useMemo(()=>!!("deepLink"in e&&e.deepLink),[e]),R=Se.useMemo(()=>!!("universalLink"in e&&e.universalLink&&/t.me/.test(e.universalLink)),[e]);return Se.useEffect(()=>{L(),B()},[]),he.jsxs(ls,{children:[he.jsx("div",{className:"xc-mb-6",children:he.jsx(Wa,{title:"Connect wallet",onBack:t.onBack})}),he.jsxs("div",{className:"xc-text-center xc-mb-6",children:[he.jsxs("div",{className:"xc-relative xc-mx-auto xc-mb-6 xc-block xc-max-h-[272px] xc-max-w-[272px] xc-rounded-xl xc-bg-white xc-p-1",children:[he.jsx("div",{className:"xc-aspect-[1/1] xc-flex xc-h-full xc-w-full xc-justify-center",ref:i}),he.jsx("div",{className:"xc-absolute xc-left-0 xc-top-0 xc-flex xc-h-full xc-w-full xc-items-center xc-justify-center",children:b?he.jsx(Fa,{className:"xc-h-6 xc-w-6 xc-animate-spin xc-text-black",size:20}):he.jsx("img",{className:"xc-h-10 xc-w-10 xc-rounded-md",src:e.imageUrl})})]}),he.jsx("p",{className:"xc-text-center",children:"Scan the QR code below with your phone's camera. "})]}),he.jsxs("div",{className:"xc-flex xc-justify-center xc-gap-2",children:[n&&he.jsx(Fa,{className:"xc-animate-spin"}),!b&&!n&&he.jsxs(he.Fragment,{children:[_7(e)&&he.jsxs(Y1,{onClick:H,children:[he.jsx(Fz,{className:"xc-opacity-80"}),"Extension"]}),$&&he.jsxs(Y1,{onClick:F,children:[he.jsx($4,{className:"xc-opacity-80"}),"Desktop"]}),R&&he.jsx(Y1,{onClick:k,children:"Telegram Mini App"})]})]})]})}function LJ(t){const[e,r]=Se.useState(""),[n,i]=Se.useState(),[s,o]=Se.useState(),a=F1(),[f,u]=Se.useState(!1);async function h(b){if(!b||!b.connectItems?.tonProof)return;u(!0);const x=await Fo.tonLogin({account_type:"block_chain",connector:"codatta_ton",account_enum:"C",wallet_name:b?.device.appName,inviter_code:a.inviterCode,address:b.account.address,chain:b.account.chain,connect_info:[{name:"ton_addr",network:b.account.chain,...b.account},b.connectItems?.tonProof],source:{device:a.device,channel:a.channel,app:a.app}});await t.onLogin(x.data),u(!1)}Se.useEffect(()=>{const b=new hl({manifestUrl:"https://static.codatta.io/static/tonconnect-manifest.json?v=2"}),x=b.onStatusChange(h);return o(b),r("select"),x},[]);function g(b){r("connect"),i(b)}return he.jsxs(ls,{children:[e==="select"&&he.jsx(a7,{connector:s,onSelect:g,onBack:t.onBack}),e==="connect"&&he.jsx(E7,{connector:s,wallet:n,onBack:t.onBack,loading:f})]})}function S7(t){const{children:e,className:r}=t,n=Se.useRef(null),[i,s]=Se.useState(0);function o(){try{const a=n.current?.children||[];let f=0;for(let u=0;u{const a=new MutationObserver(o);return a.observe(n.current,{childList:!0,subtree:!0}),()=>a.disconnect()},[]),Se.useEffect(()=>{console.log("maxHeight",i)},[i]),he.jsx("div",{ref:n,className:r,style:{transition:"all 0.2s ease-in-out",overflow:"hidden",height:i},children:e})}function kJ(){return he.jsxs("svg",{width:"121",height:"120",viewBox:"0 0 121 120",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[he.jsx("rect",{x:"0.5",width:"120",height:"120",rx:"60",fill:"#404049"}),he.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M52.8709 61.106C52.8208 61.4482 52.7948 61.7979 52.7948 62.1535C52.7948 66.2529 56.2445 69.5761 60.5 69.5761C64.7554 69.5761 68.2052 66.2529 68.2052 62.1535C68.2052 61.7979 68.1792 61.4482 68.129 61.106H86.826V77.6174C86.826 78.6422 85.9636 79.473 84.8997 79.473H36.1002C35.0364 79.473 34.174 78.6422 34.174 77.6174V61.106H52.8709Z",fill:"#252532"}),he.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M69.061 60.9416C69.061 65.6697 65.2281 69.5026 60.5 69.5026C55.7719 69.5026 51.939 65.6697 51.939 60.9416C51.939 60.7884 51.943 60.6362 51.951 60.485H33.5L39.7959 41.8696C40.0673 41.0671 40.8202 40.527 41.6674 40.527H79.3326C80.1798 40.527 80.9327 41.0671 81.2041 41.8696L87.5 60.485H69.049C69.057 60.6362 69.061 60.7884 69.061 60.9416Z",fill:"#252532"}),he.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M67.8081 61.5708C67.8081 65.2243 64.5361 68.8446 60.4999 68.8446C56.4637 68.8446 53.1918 65.2243 53.1918 61.5708C53.1918 61.4524 53.1952 60.6762 53.202 60.5594H39.4268L44.8013 47.4919C45.033 46.8717 45.6757 46.4543 46.3989 46.4543H74.601C75.3242 46.4543 75.9669 46.8717 76.1986 47.4919L81.5731 60.5594H67.7979C67.8046 60.6762 67.8081 61.4524 67.8081 61.5708Z",fill:"#404049"}),he.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M34.3232 60.6199V78.063C34.3232 78.6995 34.8392 79.2155 35.4757 79.2155H85.5245C86.1609 79.2155 86.6769 78.6995 86.6769 78.063V60.6199L80.4244 42.1328C80.2661 41.6647 79.8269 41.3496 79.3327 41.3496H41.6674C41.1733 41.3496 40.7341 41.6647 40.5758 42.1328L34.3232 60.6199Z",stroke:"#77777D","stroke-width":"2"}),he.jsx("path",{d:"M34.817 60.2823C37.4094 60.2823 48.1095 60.2823 51.1124 60.2823C52.348 60.2823 52.348 61.1507 52.348 61.5994C52.348 65.9638 55.9675 69.5019 60.4323 69.5019C64.8971 69.5019 68.5165 65.9638 68.5165 61.5994C68.5165 61.1507 68.5165 60.2823 69.7521 60.2823H86.1829",stroke:"#77777D","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]})}function A7(t){const{wallets:e}=Hf(),[r,n]=Se.useState(),i=Se.useMemo(()=>r?e.filter(a=>a.key.toLowerCase().includes(r.toLowerCase())):e,[r]);function s(a){t.onSelectWallet(a)}function o(a){n(a.target.value)}return he.jsxs(ls,{children:[he.jsx("div",{className:"xc-mb-6",children:he.jsx(Wa,{title:"Select wallet",onBack:t.onBack})}),he.jsxs("div",{className:"xc-mb-6 xc-flex xc-gap-3 xc-px-4 xc-py-2 xc-border xc-rounded-xl xc-w-full xc-overflow-hidden xc-items-center xc-border-opacity-15 xc-border-white focus-within:xc-border-opacity-40",children:[he.jsx(q4,{className:"xc-shrink-0 xc-opacity-50"}),he.jsx("input",{type:"text",className:"xc-flex-1 xc-bg-transparent xc-appearance-none xc-outline-none",placeholder:"Search wallet",onInput:o})]}),he.jsx("div",{className:"xc-mb-4 xc-flex xc-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar",children:i.length?i.map(a=>he.jsx(TS,{wallet:a,onClick:s},`feature-${a.key}`)):he.jsx(kJ,{})})]})}function BJ(t){const{onLogin:e,header:r,showEmailSignIn:n=!0,showMoreWallets:i=!0,showTonConnect:s=!0,showFeaturedWallets:o=!0}=t,[a,f]=Se.useState(""),[u,h]=Se.useState(null),[g,b]=Se.useState("");function x(B){h(B),f("evm-wallet")}function S(B){f("email"),b(B)}async function C(B){await e(B)}function D(){f("ton-wallet")}return Se.useEffect(()=>{f("index")},[]),he.jsx(JG,{config:t.config,children:he.jsxs(S7,{className:"xc-rounded-2xl xc-transition-height xc-box-content xc-w-full xc-min-w-[277px] xc-max-w-[420px] xc-p-6 xc-bg-[rgb(28,28,38)] xc-text-white",children:[a==="evm-wallet"&&he.jsx(LY,{onBack:()=>f("index"),onLogin:C,wallet:u}),a==="ton-wallet"&&he.jsx(LJ,{onBack:()=>f("index"),onLogin:C}),a==="email"&&he.jsx(lY,{email:g,onBack:()=>f("index"),onLogin:C}),a==="index"&&he.jsx($S,{header:r,useSingleWallet:!0,onEmailConfirm:S,onSelectWallet:x,onSelectMoreWallets:()=>{f("all-wallet")},onSelectTonConnect:D,config:{showEmailSignIn:n,showFeaturedWallets:o,showMoreWallets:i,showTonConnect:s}}),a==="all-wallet"&&he.jsx(A7,{onBack:()=>f("index"),onSelectWallet:x})]})})}function FJ(t){const{wallet:e,onConnect:r}=t,[n,i]=Se.useState(e.installed?"connect":"qr");async function s(o,a){await r(o,a)}return he.jsxs(ls,{children:[he.jsx("div",{className:"xc-mb-6",children:he.jsx(Wa,{title:"Connect wallet",onBack:t.onBack})}),n==="qr"&&he.jsx(i7,{wallet:e,onGetExtension:()=>i("get-extension"),onSignFinish:s}),n==="connect"&&he.jsx(s7,{onShowQrCode:()=>i("qr"),wallet:e,onSignFinish:s}),n==="get-extension"&&he.jsx(o7,{wallet:e})]})}function jJ(t){const{email:e}=t,[r,n]=Se.useState("captcha");return he.jsxs(ls,{children:[he.jsx("div",{className:"xc-mb-12",children:he.jsx(Wa,{title:"Connect with email",onBack:t.onBack})}),r==="captcha"&&he.jsx(ZS,{email:e,onCodeSend:()=>n("verify-email")}),r==="verify-email"&&he.jsx(XS,{email:e,onInputCode:t.onInputCode,onResendCode:()=>n("captcha")})]})}function UJ(t){const{onEvmWalletConnect:e,onTonWalletConnect:r,onEmailConnect:n,header:i,config:s={showEmailSignIn:!1,showFeaturedWallets:!0,showMoreWallets:!0,showTonConnect:!0}}=t,[o,a]=Se.useState(""),[f,u]=Se.useState(),[h,g]=Se.useState(),b=Se.useRef(),[x,S]=Se.useState("");function C(k){u(k),a("evm-wallet-connect")}function D(k){S(k),a("email-connect")}async function B(k,$){await e?.({chain_type:"eip155",client:k.client,connect_info:$,wallet:k}),a("index")}async function L(k,$){await n?.(k,$)}function H(k){g(k),a("ton-wallet-connect")}async function F(k){k&&await r?.({chain_type:"ton",client:b.current,connect_info:k,wallet:k})}return Se.useEffect(()=>{b.current=new hl({manifestUrl:"https://static.codatta.io/static/tonconnect-manifest.json?v=2"});const k=b.current.onStatusChange(F);return a("index"),k},[]),he.jsxs(S7,{className:"xc-rounded-2xl xc-transition-height xc-box-content xc-w-full xc-min-w-[277px] xc-max-w-[420px] xc-p-6 xc-bg-[rgb(28,28,38)] xc-text-white",children:[o==="evm-wallet-select"&&he.jsx(A7,{onBack:()=>a("index"),onSelectWallet:C}),o==="evm-wallet-connect"&&he.jsx(FJ,{onBack:()=>a("index"),onConnect:B,wallet:f}),o==="ton-wallet-select"&&he.jsx(a7,{connector:b.current,onSelect:H,onBack:()=>a("index")}),o==="ton-wallet-connect"&&he.jsx(E7,{connector:b.current,wallet:h,onBack:()=>a("index")}),o==="email-connect"&&he.jsx(jJ,{email:x,onBack:()=>a("index"),onInputCode:L}),o==="index"&&he.jsx($S,{header:i,useSingleWallet:!1,onEmailConfirm:D,onSelectWallet:C,onSelectMoreWallets:()=>a("evm-wallet-select"),onSelectTonConnect:()=>a("ton-wallet-select"),config:s})]})}Ii.CodattaConnect=UJ,Ii.CodattaConnectContextProvider=Rz,Ii.CodattaSignin=BJ,Ii.WalletItem=la,Ii.coinbaseWallet=B4,Ii.useCodattaConnectContext=Hf,Object.defineProperty(Ii,Symbol.toStringTag,{value:"Module"})})); diff --git a/dist/main-7Oj8aJZz.js b/dist/main-7Oj8aJZz.js deleted file mode 100644 index cb18d9f..0000000 --- a/dist/main-7Oj8aJZz.js +++ /dev/null @@ -1,43212 +0,0 @@ -var ER = Object.defineProperty; -var SR = (t, e, r) => e in t ? ER(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; -var Rs = (t, e, r) => SR(t, typeof e != "symbol" ? e + "" : e, r); -import * as Gt from "react"; -import pv, { createContext as Sa, useContext as Tn, useState as fr, useEffect as Xn, forwardRef as gv, createElement as jd, useId as mv, useCallback as vv, Component as AR, useLayoutEffect as PR, useRef as bi, useInsertionEffect as v5, useMemo as Oi, Fragment as b5, Children as MR, isValidElement as IR } from "react"; -var gn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; -function ts(t) { - return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; -} -function bv(t) { - if (t.__esModule) return t; - var e = t.default; - if (typeof e == "function") { - var r = function n() { - return this instanceof n ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments); - }; - r.prototype = e.prototype; - } else r = {}; - return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(t).forEach(function(n) { - var i = Object.getOwnPropertyDescriptor(t, n); - Object.defineProperty(r, n, i.get ? i : { - enumerable: !0, - get: function() { - return t[n]; - } - }); - }), r; -} -var Ym = { exports: {} }, pf = {}; -/** - * @license React - * react-jsx-runtime.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -var h2; -function CR() { - if (h2) return pf; - h2 = 1; - var t = pv, e = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 }; - function o(a, u, l) { - var d, g = {}, w = null, A = null; - l !== void 0 && (w = "" + l), u.key !== void 0 && (w = "" + u.key), u.ref !== void 0 && (A = u.ref); - for (d in u) n.call(u, d) && !s.hasOwnProperty(d) && (g[d] = u[d]); - if (a && a.defaultProps) for (d in u = a.defaultProps, u) g[d] === void 0 && (g[d] = u[d]); - return { $$typeof: e, type: a, key: w, ref: A, props: g, _owner: i.current }; - } - return pf.Fragment = r, pf.jsx = o, pf.jsxs = o, pf; -} -var gf = {}; -/** - * @license React - * react-jsx-runtime.development.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -var d2; -function TR() { - return d2 || (d2 = 1, process.env.NODE_ENV !== "production" && function() { - var t = pv, e = Symbol.for("react.element"), r = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), o = Symbol.for("react.provider"), a = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), d = Symbol.for("react.suspense_list"), g = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), A = Symbol.for("react.offscreen"), M = Symbol.iterator, N = "@@iterator"; - function L(U) { - if (U === null || typeof U != "object") - return null; - var se = M && U[M] || U[N]; - return typeof se == "function" ? se : null; - } - var F = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; - function $(U) { - { - for (var se = arguments.length, he = new Array(se > 1 ? se - 1 : 0), xe = 1; xe < se; xe++) - he[xe - 1] = arguments[xe]; - K("error", U, he); - } - } - function K(U, se, he) { - { - var xe = F.ReactDebugCurrentFrame, Te = xe.getStackAddendum(); - Te !== "" && (se += "%s", he = he.concat([Te])); - var Re = he.map(function(nt) { - return String(nt); - }); - Re.unshift("Warning: " + se), Function.prototype.apply.call(console[U], console, Re); - } - } - var H = !1, V = !1, te = !1, R = !1, W = !1, pe; - pe = Symbol.for("react.module.reference"); - function Ee(U) { - return !!(typeof U == "string" || typeof U == "function" || U === n || U === s || W || U === i || U === l || U === d || R || U === A || H || V || te || typeof U == "object" && U !== null && (U.$$typeof === w || U.$$typeof === g || U.$$typeof === o || U.$$typeof === a || U.$$typeof === u || // This needs to include all possible module reference object - // types supported by any Flight configuration anywhere since - // we don't know which Flight build this will end up being used - // with. - U.$$typeof === pe || U.getModuleId !== void 0)); - } - function Y(U, se, he) { - var xe = U.displayName; - if (xe) - return xe; - var Te = se.displayName || se.name || ""; - return Te !== "" ? he + "(" + Te + ")" : he; - } - function S(U) { - return U.displayName || "Context"; - } - function m(U) { - if (U == null) - return null; - if (typeof U.tag == "number" && $("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof U == "function") - return U.displayName || U.name || null; - if (typeof U == "string") - return U; - switch (U) { - case n: - return "Fragment"; - case r: - return "Portal"; - case s: - return "Profiler"; - case i: - return "StrictMode"; - case l: - return "Suspense"; - case d: - return "SuspenseList"; - } - if (typeof U == "object") - switch (U.$$typeof) { - case a: - var se = U; - return S(se) + ".Consumer"; - case o: - var he = U; - return S(he._context) + ".Provider"; - case u: - return Y(U, U.render, "ForwardRef"); - case g: - var xe = U.displayName || null; - return xe !== null ? xe : m(U.type) || "Memo"; - case w: { - var Te = U, Re = Te._payload, nt = Te._init; - try { - return m(nt(Re)); - } catch { - return null; - } - } - } - return null; - } - var f = Object.assign, p = 0, b, x, _, E, v, P, I; - function B() { - } - B.__reactDisabledLog = !0; - function ce() { - { - if (p === 0) { - b = console.log, x = console.info, _ = console.warn, E = console.error, v = console.group, P = console.groupCollapsed, I = console.groupEnd; - var U = { - configurable: !0, - enumerable: !0, - value: B, - writable: !0 - }; - Object.defineProperties(console, { - info: U, - log: U, - warn: U, - error: U, - group: U, - groupCollapsed: U, - groupEnd: U - }); - } - p++; - } - } - function D() { - { - if (p--, p === 0) { - var U = { - configurable: !0, - enumerable: !0, - writable: !0 - }; - Object.defineProperties(console, { - log: f({}, U, { - value: b - }), - info: f({}, U, { - value: x - }), - warn: f({}, U, { - value: _ - }), - error: f({}, U, { - value: E - }), - group: f({}, U, { - value: v - }), - groupCollapsed: f({}, U, { - value: P - }), - groupEnd: f({}, U, { - value: I - }) - }); - } - p < 0 && $("disabledDepth fell below zero. This is a bug in React. Please file an issue."); - } - } - var oe = F.ReactCurrentDispatcher, Z; - function J(U, se, he) { - { - if (Z === void 0) - try { - throw Error(); - } catch (Te) { - var xe = Te.stack.trim().match(/\n( *(at )?)/); - Z = xe && xe[1] || ""; - } - return ` -` + Z + U; - } - } - var Q = !1, T; - { - var X = typeof WeakMap == "function" ? WeakMap : Map; - T = new X(); - } - function re(U, se) { - if (!U || Q) - return ""; - { - var he = T.get(U); - if (he !== void 0) - return he; - } - var xe; - Q = !0; - var Te = Error.prepareStackTrace; - Error.prepareStackTrace = void 0; - var Re; - Re = oe.current, oe.current = null, ce(); - try { - if (se) { - var nt = function() { - throw Error(); - }; - if (Object.defineProperty(nt.prototype, "props", { - set: function() { - throw Error(); - } - }), typeof Reflect == "object" && Reflect.construct) { - try { - Reflect.construct(nt, []); - } catch (_t) { - xe = _t; - } - Reflect.construct(U, [], nt); - } else { - try { - nt.call(); - } catch (_t) { - xe = _t; - } - U.call(nt.prototype); - } - } else { - try { - throw Error(); - } catch (_t) { - xe = _t; - } - U(); - } - } catch (_t) { - if (_t && xe && typeof _t.stack == "string") { - for (var Ue = _t.stack.split(` -`), pt = xe.stack.split(` -`), it = Ue.length - 1, et = pt.length - 1; it >= 1 && et >= 0 && Ue[it] !== pt[et]; ) - et--; - for (; it >= 1 && et >= 0; it--, et--) - if (Ue[it] !== pt[et]) { - if (it !== 1 || et !== 1) - do - if (it--, et--, et < 0 || Ue[it] !== pt[et]) { - var St = ` -` + Ue[it].replace(" at new ", " at "); - return U.displayName && St.includes("") && (St = St.replace("", U.displayName)), typeof U == "function" && T.set(U, St), St; - } - while (it >= 1 && et >= 0); - break; - } - } - } finally { - Q = !1, oe.current = Re, D(), Error.prepareStackTrace = Te; - } - var Tt = U ? U.displayName || U.name : "", At = Tt ? J(Tt) : ""; - return typeof U == "function" && T.set(U, At), At; - } - function de(U, se, he) { - return re(U, !1); - } - function ie(U) { - var se = U.prototype; - return !!(se && se.isReactComponent); - } - function ue(U, se, he) { - if (U == null) - return ""; - if (typeof U == "function") - return re(U, ie(U)); - if (typeof U == "string") - return J(U); - switch (U) { - case l: - return J("Suspense"); - case d: - return J("SuspenseList"); - } - if (typeof U == "object") - switch (U.$$typeof) { - case u: - return de(U.render); - case g: - return ue(U.type, se, he); - case w: { - var xe = U, Te = xe._payload, Re = xe._init; - try { - return ue(Re(Te), se, he); - } catch { - } - } - } - return ""; - } - var ve = Object.prototype.hasOwnProperty, Pe = {}, De = F.ReactDebugCurrentFrame; - function Ce(U) { - if (U) { - var se = U._owner, he = ue(U.type, U._source, se ? se.type : null); - De.setExtraStackFrame(he); - } else - De.setExtraStackFrame(null); - } - function $e(U, se, he, xe, Te) { - { - var Re = Function.call.bind(ve); - for (var nt in U) - if (Re(U, nt)) { - var Ue = void 0; - try { - if (typeof U[nt] != "function") { - var pt = Error((xe || "React class") + ": " + he + " type `" + nt + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof U[nt] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); - throw pt.name = "Invariant Violation", pt; - } - Ue = U[nt](se, nt, xe, he, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); - } catch (it) { - Ue = it; - } - Ue && !(Ue instanceof Error) && (Ce(Te), $("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", xe || "React class", he, nt, typeof Ue), Ce(null)), Ue instanceof Error && !(Ue.message in Pe) && (Pe[Ue.message] = !0, Ce(Te), $("Failed %s type: %s", he, Ue.message), Ce(null)); - } - } - } - var Me = Array.isArray; - function Ne(U) { - return Me(U); - } - function Ke(U) { - { - var se = typeof Symbol == "function" && Symbol.toStringTag, he = se && U[Symbol.toStringTag] || U.constructor.name || "Object"; - return he; - } - } - function Le(U) { - try { - return qe(U), !1; - } catch { - return !0; - } - } - function qe(U) { - return "" + U; - } - function ze(U) { - if (Le(U)) - return $("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ke(U)), qe(U); - } - var _e = F.ReactCurrentOwner, Ze = { - key: !0, - ref: !0, - __self: !0, - __source: !0 - }, at, ke, Qe; - Qe = {}; - function tt(U) { - if (ve.call(U, "ref")) { - var se = Object.getOwnPropertyDescriptor(U, "ref").get; - if (se && se.isReactWarning) - return !1; - } - return U.ref !== void 0; - } - function Ye(U) { - if (ve.call(U, "key")) { - var se = Object.getOwnPropertyDescriptor(U, "key").get; - if (se && se.isReactWarning) - return !1; - } - return U.key !== void 0; - } - function dt(U, se) { - if (typeof U.ref == "string" && _e.current && se && _e.current.stateNode !== se) { - var he = m(_e.current.type); - Qe[he] || ($('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', m(_e.current.type), U.ref), Qe[he] = !0); - } - } - function lt(U, se) { - { - var he = function() { - at || (at = !0, $("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", se)); - }; - he.isReactWarning = !0, Object.defineProperty(U, "key", { - get: he, - configurable: !0 - }); - } - } - function ct(U, se) { - { - var he = function() { - ke || (ke = !0, $("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", se)); - }; - he.isReactWarning = !0, Object.defineProperty(U, "ref", { - get: he, - configurable: !0 - }); - } - } - var qt = function(U, se, he, xe, Te, Re, nt) { - var Ue = { - // This tag allows us to uniquely identify this as a React Element - $$typeof: e, - // Built-in properties that belong on the element - type: U, - key: se, - ref: he, - props: nt, - // Record the component responsible for creating this element. - _owner: Re - }; - return Ue._store = {}, Object.defineProperty(Ue._store, "validated", { - configurable: !1, - enumerable: !1, - writable: !0, - value: !1 - }), Object.defineProperty(Ue, "_self", { - configurable: !1, - enumerable: !1, - writable: !1, - value: xe - }), Object.defineProperty(Ue, "_source", { - configurable: !1, - enumerable: !1, - writable: !1, - value: Te - }), Object.freeze && (Object.freeze(Ue.props), Object.freeze(Ue)), Ue; - }; - function Yt(U, se, he, xe, Te) { - { - var Re, nt = {}, Ue = null, pt = null; - he !== void 0 && (ze(he), Ue = "" + he), Ye(se) && (ze(se.key), Ue = "" + se.key), tt(se) && (pt = se.ref, dt(se, Te)); - for (Re in se) - ve.call(se, Re) && !Ze.hasOwnProperty(Re) && (nt[Re] = se[Re]); - if (U && U.defaultProps) { - var it = U.defaultProps; - for (Re in it) - nt[Re] === void 0 && (nt[Re] = it[Re]); - } - if (Ue || pt) { - var et = typeof U == "function" ? U.displayName || U.name || "Unknown" : U; - Ue && lt(nt, et), pt && ct(nt, et); - } - return qt(U, Ue, pt, Te, xe, _e.current, nt); - } - } - var Et = F.ReactCurrentOwner, Qt = F.ReactDebugCurrentFrame; - function Jt(U) { - if (U) { - var se = U._owner, he = ue(U.type, U._source, se ? se.type : null); - Qt.setExtraStackFrame(he); - } else - Qt.setExtraStackFrame(null); - } - var Dt; - Dt = !1; - function kt(U) { - return typeof U == "object" && U !== null && U.$$typeof === e; - } - function Ct() { - { - if (Et.current) { - var U = m(Et.current.type); - if (U) - return ` - -Check the render method of \`` + U + "`."; - } - return ""; - } - } - function gt(U) { - return ""; - } - var Rt = {}; - function Nt(U) { - { - var se = Ct(); - if (!se) { - var he = typeof U == "string" ? U : U.displayName || U.name; - he && (se = ` - -Check the top-level render call using <` + he + ">."); - } - return se; - } - } - function vt(U, se) { - { - if (!U._store || U._store.validated || U.key != null) - return; - U._store.validated = !0; - var he = Nt(se); - if (Rt[he]) - return; - Rt[he] = !0; - var xe = ""; - U && U._owner && U._owner !== Et.current && (xe = " It was passed a child from " + m(U._owner.type) + "."), Jt(U), $('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', he, xe), Jt(null); - } - } - function $t(U, se) { - { - if (typeof U != "object") - return; - if (Ne(U)) - for (var he = 0; he < U.length; he++) { - var xe = U[he]; - kt(xe) && vt(xe, se); - } - else if (kt(U)) - U._store && (U._store.validated = !0); - else if (U) { - var Te = L(U); - if (typeof Te == "function" && Te !== U.entries) - for (var Re = Te.call(U), nt; !(nt = Re.next()).done; ) - kt(nt.value) && vt(nt.value, se); - } - } - } - function Bt(U) { - { - var se = U.type; - if (se == null || typeof se == "string") - return; - var he; - if (typeof se == "function") - he = se.propTypes; - else if (typeof se == "object" && (se.$$typeof === u || // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - se.$$typeof === g)) - he = se.propTypes; - else - return; - if (he) { - var xe = m(se); - $e(he, U.props, "prop", xe, U); - } else if (se.PropTypes !== void 0 && !Dt) { - Dt = !0; - var Te = m(se); - $("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", Te || "Unknown"); - } - typeof se.getDefaultProps == "function" && !se.getDefaultProps.isReactClassApproved && $("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); - } - } - function rt(U) { - { - for (var se = Object.keys(U.props), he = 0; he < se.length; he++) { - var xe = se[he]; - if (xe !== "children" && xe !== "key") { - Jt(U), $("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", xe), Jt(null); - break; - } - } - U.ref !== null && (Jt(U), $("Invalid attribute `ref` supplied to `React.Fragment`."), Jt(null)); - } - } - var Ft = {}; - function k(U, se, he, xe, Te, Re) { - { - var nt = Ee(U); - if (!nt) { - var Ue = ""; - (U === void 0 || typeof U == "object" && U !== null && Object.keys(U).length === 0) && (Ue += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); - var pt = gt(); - pt ? Ue += pt : Ue += Ct(); - var it; - U === null ? it = "null" : Ne(U) ? it = "array" : U !== void 0 && U.$$typeof === e ? (it = "<" + (m(U.type) || "Unknown") + " />", Ue = " Did you accidentally export a JSX literal instead of a component?") : it = typeof U, $("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", it, Ue); - } - var et = Yt(U, se, he, Te, Re); - if (et == null) - return et; - if (nt) { - var St = se.children; - if (St !== void 0) - if (xe) - if (Ne(St)) { - for (var Tt = 0; Tt < St.length; Tt++) - $t(St[Tt], U); - Object.freeze && Object.freeze(St); - } else - $("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); - else - $t(St, U); - } - if (ve.call(se, "key")) { - var At = m(U), _t = Object.keys(se).filter(function(st) { - return st !== "key"; - }), ht = _t.length > 0 ? "{key: someKey, " + _t.join(": ..., ") + ": ...}" : "{key: someKey}"; - if (!Ft[At + ht]) { - var xt = _t.length > 0 ? "{" + _t.join(": ..., ") + ": ...}" : "{}"; - $(`A props object containing a "key" prop is being spread into JSX: - let props = %s; - <%s {...props} /> -React keys must be passed directly to JSX without using spread: - let props = %s; - <%s key={someKey} {...props} />`, ht, At, xt, At), Ft[At + ht] = !0; - } - } - return U === n ? rt(et) : Bt(et), et; - } - } - function j(U, se, he) { - return k(U, se, he, !0); - } - function z(U, se, he) { - return k(U, se, he, !1); - } - var C = z, G = j; - gf.Fragment = n, gf.jsx = C, gf.jsxs = G; - }()), gf; -} -process.env.NODE_ENV === "production" ? Ym.exports = CR() : Ym.exports = TR(); -var me = Ym.exports; -const Ds = "https://static.codatta.io/codatta-connect/wallet-icons.svg?v=2", RR = [ - { - featured: !0, - name: "MetaMask", - rdns: "io.metamask", - image: `${Ds}#metamask`, - getWallet: { - chrome_store_id: "nkbihfbeogaeaoehlefnkodbefgpgknn", - brave_store_id: "nkbihfbeogaeaoehlefnkodbefgpgknn", - edge_addon_id: "ejbalbakoplchlghecdalmeeeajnimhm", - firefox_addon_id: "ether-metamask", - play_store_id: "io.metamask", - app_store_id: "id1438144202" - }, - deep_link: "metamask://wc", - universal_link: "https://metamask.app.link/wc" - }, - { - featured: !0, - name: "OKX Wallet", - rdns: "com.okex.wallet", - image: `${Ds}#okx`, - getWallet: { - chrome_store_id: "mcohilncbfahbmgdjkbpemcciiolgcge", - brave_store_id: "mcohilncbfahbmgdjkbpemcciiolgcge", - edge_addon_id: "pbpjkcldjiffchgbbndmhojiacbgflha", - play_store_id: "com.okinc.okex.gp", - app_store_id: "id1327268470" - }, - deep_link: "okex://main/wc", - universal_link: "okex://main/wc" - }, - { - featured: !0, - name: "WalletConnect", - image: `${Ds}#walletconnect` - }, - { - featured: !1, - name: "Coinbase Wallet", - image: `${Ds}#coinbase` - }, - { - featured: !1, - name: "GateWallet", - rdns: "io.gate.wallet", - image: `${Ds}#6e528abf-7a7d-47bd-d84d-481f169b1200`, - getWallet: { - chrome_store_id: "cpmkedoipcpimgecpmgpldfpohjplkpp", - brave_store_id: "cpmkedoipcpimgecpmgpldfpohjplkpp", - play_store_id: "com.gateio.gateio", - app_store_id: "id1294998195", - mac_app_store_id: "id1609559473" - }, - deep_link: "https://www.gate.io/mobileapp", - universal_link: "https://www.gate.io/mobileapp" - }, - { - featured: !1, - name: "Onekey", - rdns: "so.onekey.app.wallet", - image: `${Ds}#onekey`, - getWallet: { - chrome_store_id: "jnmbobjmhlngoefaiojfljckilhhlhcj", - brave_store_id: "jnmbobjmhlngoefaiojfljckilhhlhcj", - play_store_id: "so.onekey.app.wallet", - app_store_id: "id1609559473" - }, - deep_link: "onekey-wallet://", - universal_link: "onekey://wc" - }, - { - featured: !1, - name: "Infinity Wallet", - image: `${Ds}#9f259366-0bcd-4817-0af9-f78773e41900`, - desktop_link: "infinity://wc" - }, - { - name: "Rabby Wallet", - rdns: "io.rabby", - featured: !1, - image: `${Ds}#rabby`, - getWallet: { - chrome_store_id: "acmacodkjbdgmoleebolmdjonilkdbch", - brave_store_id: "acmacodkjbdgmoleebolmdjonilkdbch", - play_store_id: "com.debank.rabbymobile", - app_store_id: "id6474381673" - } - }, - { - name: "Binance Web3 Wallet", - featured: !1, - image: `${Ds}#ebac7b39-688c-41e3-7912-a4fefba74600`, - getWallet: { - play_store_id: "com.binance.dev", - app_store_id: "id1436799971" - } - }, - { - name: "Rainbow Wallet", - rdns: "me.rainbow", - featured: !1, - image: `${Ds}#rainbow`, - getWallet: { - chrome_store_id: "opfgelmcmbiajamepnmloijbpoleiama", - edge_addon_id: "cpojfbodiccabbabgimdeohkkpjfpbnf", - firefox_addon_id: "rainbow-extension", - app_store_id: "id1457119021", - play_store_id: "me.rainbow" - } - } -]; -function DR(t, e) { - const r = t.exec(e); - return r == null ? void 0 : r.groups; -} -const p2 = /^tuple(?(\[(\d*)\])*)$/; -function Jm(t) { - let e = t.type; - if (p2.test(t.type) && "components" in t) { - e = "("; - const r = t.components.length; - for (let i = 0; i < r; i++) { - const s = t.components[i]; - e += Jm(s), i < r - 1 && (e += ", "); - } - const n = DR(p2, t.type); - return e += `)${(n == null ? void 0 : n.array) ?? ""}`, Jm({ - ...t, - type: e - }); - } - return "indexed" in t && t.indexed && (e = `${e} indexed`), t.name ? `${e} ${t.name}` : e; -} -function mf(t) { - let e = ""; - const r = t.length; - for (let n = 0; n < r; n++) { - const i = t[n]; - e += Jm(i), n !== r - 1 && (e += ", "); - } - return e; -} -function OR(t) { - return t.type === "function" ? `function ${t.name}(${mf(t.inputs)})${t.stateMutability && t.stateMutability !== "nonpayable" ? ` ${t.stateMutability}` : ""}${t.outputs.length ? ` returns (${mf(t.outputs)})` : ""}` : t.type === "event" ? `event ${t.name}(${mf(t.inputs)})` : t.type === "error" ? `error ${t.name}(${mf(t.inputs)})` : t.type === "constructor" ? `constructor(${mf(t.inputs)})${t.stateMutability === "payable" ? " payable" : ""}` : t.type === "fallback" ? "fallback()" : "receive() external payable"; -} -function vi(t, e, r) { - const n = t[e.name]; - if (typeof n == "function") - return n; - const i = t[r]; - return typeof i == "function" ? i : (s) => e(t, s); -} -function mu(t, { includeName: e = !1 } = {}) { - if (t.type !== "function" && t.type !== "event" && t.type !== "error") - throw new WR(t.type); - return `${t.name}(${yv(t.inputs, { includeName: e })})`; -} -function yv(t, { includeName: e = !1 } = {}) { - return t ? t.map((r) => NR(r, { includeName: e })).join(e ? ", " : ",") : ""; -} -function NR(t, { includeName: e }) { - return t.type.startsWith("tuple") ? `(${yv(t.components, { includeName: e })})${t.type.slice(5)}` : t.type + (e && t.name ? ` ${t.name}` : ""); -} -function ma(t, { strict: e = !0 } = {}) { - return !t || typeof t != "string" ? !1 : e ? /^0x[0-9a-fA-F]*$/.test(t) : t.startsWith("0x"); -} -function An(t) { - return ma(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length; -} -const y5 = "2.21.45"; -let vf = { - getDocsUrl: ({ docsBaseUrl: t, docsPath: e = "", docsSlug: r }) => e ? `${t ?? "https://viem.sh"}${e}${r ? `#${r}` : ""}` : void 0, - version: `viem@${y5}` -}; -class yt extends Error { - constructor(e, r = {}) { - var a; - const n = (() => { - var u; - return r.cause instanceof yt ? r.cause.details : (u = r.cause) != null && u.message ? r.cause.message : r.details; - })(), i = r.cause instanceof yt && r.cause.docsPath || r.docsPath, s = (a = vf.getDocsUrl) == null ? void 0 : a.call(vf, { ...r, docsPath: i }), o = [ - e || "An error occurred.", - "", - ...r.metaMessages ? [...r.metaMessages, ""] : [], - ...s ? [`Docs: ${s}`] : [], - ...n ? [`Details: ${n}`] : [], - ...vf.version ? [`Version: ${vf.version}`] : [] - ].join(` -`); - super(o, r.cause ? { cause: r.cause } : void 0), Object.defineProperty(this, "details", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "docsPath", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "metaMessages", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "shortMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "version", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "name", { - enumerable: !0, - configurable: !0, - writable: !0, - value: "BaseError" - }), this.details = n, this.docsPath = i, this.metaMessages = r.metaMessages, this.name = r.name ?? this.name, this.shortMessage = e, this.version = y5; - } - walk(e) { - return w5(this, e); - } -} -function w5(t, e) { - return e != null && e(t) ? t : t && typeof t == "object" && "cause" in t && t.cause !== void 0 ? w5(t.cause, e) : e ? null : t; -} -class LR extends yt { - constructor({ docsPath: e }) { - super([ - "A constructor was not found on the ABI.", - "Make sure you are using the correct ABI and that the constructor exists on it." - ].join(` -`), { - docsPath: e, - name: "AbiConstructorNotFoundError" - }); - } -} -class g2 extends yt { - constructor({ docsPath: e }) { - super([ - "Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.", - "Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists." - ].join(` -`), { - docsPath: e, - name: "AbiConstructorParamsNotFoundError" - }); - } -} -class kR extends yt { - constructor({ data: e, params: r, size: n }) { - super([`Data size of ${n} bytes is too small for given parameters.`].join(` -`), { - metaMessages: [ - `Params: (${yv(r, { includeName: !0 })})`, - `Data: ${e} (${n} bytes)` - ], - name: "AbiDecodingDataSizeTooSmallError" - }), Object.defineProperty(this, "data", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "params", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "size", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.data = e, this.params = r, this.size = n; - } -} -class wv extends yt { - constructor() { - super('Cannot decode zero data ("0x") with ABI parameters.', { - name: "AbiDecodingZeroDataError" - }); - } -} -class $R extends yt { - constructor({ expectedLength: e, givenLength: r, type: n }) { - super([ - `ABI encoding array length mismatch for type ${n}.`, - `Expected length: ${e}`, - `Given length: ${r}` - ].join(` -`), { name: "AbiEncodingArrayLengthMismatchError" }); - } -} -class FR extends yt { - constructor({ expectedSize: e, value: r }) { - super(`Size of bytes "${r}" (bytes${An(r)}) does not match expected size (bytes${e}).`, { name: "AbiEncodingBytesSizeMismatchError" }); - } -} -class BR extends yt { - constructor({ expectedLength: e, givenLength: r }) { - super([ - "ABI encoding params/values length mismatch.", - `Expected length (params): ${e}`, - `Given length (values): ${r}` - ].join(` -`), { name: "AbiEncodingLengthMismatchError" }); - } -} -class x5 extends yt { - constructor(e, { docsPath: r }) { - super([ - `Encoded error signature "${e}" not found on ABI.`, - "Make sure you are using the correct ABI and that the error exists on it.", - `You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.` - ].join(` -`), { - docsPath: r, - name: "AbiErrorSignatureNotFoundError" - }), Object.defineProperty(this, "signature", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.signature = e; - } -} -class m2 extends yt { - constructor(e, { docsPath: r } = {}) { - super([ - `Function ${e ? `"${e}" ` : ""}not found on ABI.`, - "Make sure you are using the correct ABI and that the function exists on it." - ].join(` -`), { - docsPath: r, - name: "AbiFunctionNotFoundError" - }); - } -} -class UR extends yt { - constructor(e, r) { - super("Found ambiguous types in overloaded ABI items.", { - metaMessages: [ - `\`${e.type}\` in \`${mu(e.abiItem)}\`, and`, - `\`${r.type}\` in \`${mu(r.abiItem)}\``, - "", - "These types encode differently and cannot be distinguished at runtime.", - "Remove one of the ambiguous items in the ABI." - ], - name: "AbiItemAmbiguityError" - }); - } -} -class jR extends yt { - constructor({ expectedSize: e, givenSize: r }) { - super(`Expected bytes${e}, got bytes${r}.`, { - name: "BytesSizeMismatchError" - }); - } -} -class qR extends yt { - constructor(e, { docsPath: r }) { - super([ - `Type "${e}" is not a valid encoding type.`, - "Please provide a valid ABI type." - ].join(` -`), { docsPath: r, name: "InvalidAbiEncodingType" }); - } -} -class zR extends yt { - constructor(e, { docsPath: r }) { - super([ - `Type "${e}" is not a valid decoding type.`, - "Please provide a valid ABI type." - ].join(` -`), { docsPath: r, name: "InvalidAbiDecodingType" }); - } -} -class HR extends yt { - constructor(e) { - super([`Value "${e}" is not a valid array.`].join(` -`), { - name: "InvalidArrayError" - }); - } -} -class WR extends yt { - constructor(e) { - super([ - `"${e}" is not a valid definition type.`, - 'Valid types: "function", "event", "error"' - ].join(` -`), { name: "InvalidDefinitionTypeError" }); - } -} -class _5 extends yt { - constructor({ offset: e, position: r, size: n }) { - super(`Slice ${r === "start" ? "starting" : "ending"} at offset "${e}" is out-of-bounds (size: ${n}).`, { name: "SliceOffsetOutOfBoundsError" }); - } -} -class E5 extends yt { - constructor({ size: e, targetSize: r, type: n }) { - super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`, { name: "SizeExceedsPaddingSizeError" }); - } -} -class v2 extends yt { - constructor({ size: e, targetSize: r, type: n }) { - super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${r} ${n} long, but is ${e} ${n} long.`, { name: "InvalidBytesLengthError" }); - } -} -function Cu(t, { dir: e, size: r = 32 } = {}) { - return typeof t == "string" ? ga(t, { dir: e, size: r }) : KR(t, { dir: e, size: r }); -} -function ga(t, { dir: e, size: r = 32 } = {}) { - if (r === null) - return t; - const n = t.replace("0x", ""); - if (n.length > r * 2) - throw new E5({ - size: Math.ceil(n.length / 2), - targetSize: r, - type: "hex" - }); - return `0x${n[e === "right" ? "padEnd" : "padStart"](r * 2, "0")}`; -} -function KR(t, { dir: e, size: r = 32 } = {}) { - if (r === null) - return t; - if (t.length > r) - throw new E5({ - size: t.length, - targetSize: r, - type: "bytes" - }); - const n = new Uint8Array(r); - for (let i = 0; i < r; i++) { - const s = e === "right"; - n[s ? i : r - i - 1] = t[s ? i : t.length - i - 1]; - } - return n; -} -class VR extends yt { - constructor({ max: e, min: r, signed: n, size: i, value: s }) { - super(`Number "${s}" is not in safe ${i ? `${i * 8}-bit ${n ? "signed" : "unsigned"} ` : ""}integer range ${e ? `(${r} to ${e})` : `(above ${r})`}`, { name: "IntegerOutOfRangeError" }); - } -} -class GR extends yt { - constructor(e) { - super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, { - name: "InvalidBytesBooleanError" - }); - } -} -class YR extends yt { - constructor({ givenSize: e, maxSize: r }) { - super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`, { name: "SizeOverflowError" }); - } -} -function xv(t, { dir: e = "left" } = {}) { - let r = typeof t == "string" ? t.replace("0x", "") : t, n = 0; - for (let i = 0; i < r.length - 1 && r[e === "left" ? i : r.length - i - 1].toString() === "0"; i++) - n++; - return r = e === "left" ? r.slice(n) : r.slice(0, r.length - n), typeof t == "string" ? (r.length === 1 && e === "right" && (r = `${r}0`), `0x${r.length % 2 === 1 ? `0${r}` : r}`) : r; -} -function eo(t, { size: e }) { - if (An(t) > e) - throw new YR({ - givenSize: An(t), - maxSize: e - }); -} -function Qf(t, e = {}) { - const { signed: r } = e; - e.size && eo(t, { size: e.size }); - const n = BigInt(t); - if (!r) - return n; - const i = (t.length - 2) / 2, s = (1n << BigInt(i) * 8n - 1n) - 1n; - return n <= s ? n : n - BigInt(`0x${"f".padStart(i * 2, "f")}`) - 1n; -} -function vu(t, e = {}) { - return Number(Qf(t, e)); -} -const JR = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0")); -function qd(t, e = {}) { - return typeof t == "number" || typeof t == "bigint" ? Mr(t, e) : typeof t == "string" ? M0(t, e) : typeof t == "boolean" ? S5(t, e) : wi(t, e); -} -function S5(t, e = {}) { - const r = `0x${Number(t)}`; - return typeof e.size == "number" ? (eo(r, { size: e.size }), Cu(r, { size: e.size })) : r; -} -function wi(t, e = {}) { - let r = ""; - for (let i = 0; i < t.length; i++) - r += JR[t[i]]; - const n = `0x${r}`; - return typeof e.size == "number" ? (eo(n, { size: e.size }), Cu(n, { dir: "right", size: e.size })) : n; -} -function Mr(t, e = {}) { - const { signed: r, size: n } = e, i = BigInt(t); - let s; - n ? r ? s = (1n << BigInt(n) * 8n - 1n) - 1n : s = 2n ** (BigInt(n) * 8n) - 1n : typeof t == "number" && (s = BigInt(Number.MAX_SAFE_INTEGER)); - const o = typeof s == "bigint" && r ? -s - 1n : 0; - if (s && i > s || i < o) { - const u = typeof t == "bigint" ? "n" : ""; - throw new VR({ - max: s ? `${s}${u}` : void 0, - min: `${o}${u}`, - signed: r, - size: n, - value: `${t}${u}` - }); - } - const a = `0x${(r && i < 0 ? (1n << BigInt(n * 8)) + BigInt(i) : i).toString(16)}`; - return n ? Cu(a, { size: n }) : a; -} -const XR = /* @__PURE__ */ new TextEncoder(); -function M0(t, e = {}) { - const r = XR.encode(t); - return wi(r, e); -} -const ZR = /* @__PURE__ */ new TextEncoder(); -function _v(t, e = {}) { - return typeof t == "number" || typeof t == "bigint" ? eD(t, e) : typeof t == "boolean" ? QR(t, e) : ma(t) ? No(t, e) : A5(t, e); -} -function QR(t, e = {}) { - const r = new Uint8Array(1); - return r[0] = Number(t), typeof e.size == "number" ? (eo(r, { size: e.size }), Cu(r, { size: e.size })) : r; -} -const po = { - zero: 48, - nine: 57, - A: 65, - F: 70, - a: 97, - f: 102 -}; -function b2(t) { - if (t >= po.zero && t <= po.nine) - return t - po.zero; - if (t >= po.A && t <= po.F) - return t - (po.A - 10); - if (t >= po.a && t <= po.f) - return t - (po.a - 10); -} -function No(t, e = {}) { - let r = t; - e.size && (eo(r, { size: e.size }), r = Cu(r, { dir: "right", size: e.size })); - let n = r.slice(2); - n.length % 2 && (n = `0${n}`); - const i = n.length / 2, s = new Uint8Array(i); - for (let o = 0, a = 0; o < i; o++) { - const u = b2(n.charCodeAt(a++)), l = b2(n.charCodeAt(a++)); - if (u === void 0 || l === void 0) - throw new yt(`Invalid byte sequence ("${n[a - 2]}${n[a - 1]}" in "${n}").`); - s[o] = u * 16 + l; - } - return s; -} -function eD(t, e) { - const r = Mr(t, e); - return No(r); -} -function A5(t, e = {}) { - const r = ZR.encode(t); - return typeof e.size == "number" ? (eo(r, { size: e.size }), Cu(r, { dir: "right", size: e.size })) : r; -} -function zd(t) { - if (!Number.isSafeInteger(t) || t < 0) - throw new Error(`positive integer expected, not ${t}`); -} -function tD(t) { - return t instanceof Uint8Array || t != null && typeof t == "object" && t.constructor.name === "Uint8Array"; -} -function Nl(t, ...e) { - if (!tD(t)) - throw new Error("Uint8Array expected"); - if (e.length > 0 && !e.includes(t.length)) - throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`); -} -function cse(t) { - if (typeof t != "function" || typeof t.create != "function") - throw new Error("Hash should be wrapped by utils.wrapConstructor"); - zd(t.outputLen), zd(t.blockLen); -} -function Hd(t, e = !0) { - if (t.destroyed) - throw new Error("Hash instance has been destroyed"); - if (e && t.finished) - throw new Error("Hash#digest() has already been called"); -} -function P5(t, e) { - Nl(t); - const r = e.outputLen; - if (t.length < r) - throw new Error(`digestInto() expects output buffer of length at least ${r}`); -} -const td = /* @__PURE__ */ BigInt(2 ** 32 - 1), y2 = /* @__PURE__ */ BigInt(32); -function rD(t, e = !1) { - return e ? { h: Number(t & td), l: Number(t >> y2 & td) } : { h: Number(t >> y2 & td) | 0, l: Number(t & td) | 0 }; -} -function nD(t, e = !1) { - let r = new Uint32Array(t.length), n = new Uint32Array(t.length); - for (let i = 0; i < t.length; i++) { - const { h: s, l: o } = rD(t[i], e); - [r[i], n[i]] = [s, o]; - } - return [r, n]; -} -const iD = (t, e, r) => t << r | e >>> 32 - r, sD = (t, e, r) => e << r | t >>> 32 - r, oD = (t, e, r) => e << r - 32 | t >>> 64 - r, aD = (t, e, r) => t << r - 32 | e >>> 64 - r, jc = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0; -/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const cD = (t) => new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4)), Fg = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength), Os = (t, e) => t << 32 - e | t >>> e, w2 = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68, uD = (t) => t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255; -function x2(t) { - for (let e = 0; e < t.length; e++) - t[e] = uD(t[e]); -} -const fD = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0")); -function lD(t) { - Nl(t); - let e = ""; - for (let r = 0; r < t.length; r++) - e += fD[t[r]]; - return e; -} -function hD(t) { - if (typeof t != "string") - throw new Error(`utf8ToBytes expected string, got ${typeof t}`); - return new Uint8Array(new TextEncoder().encode(t)); -} -function I0(t) { - return typeof t == "string" && (t = hD(t)), Nl(t), t; -} -function use(...t) { - let e = 0; - for (let n = 0; n < t.length; n++) { - const i = t[n]; - Nl(i), e += i.length; - } - const r = new Uint8Array(e); - for (let n = 0, i = 0; n < t.length; n++) { - const s = t[n]; - r.set(s, i), i += s.length; - } - return r; -} -class M5 { - // Safe version that clones internal state - clone() { - return this._cloneInto(); - } -} -function I5(t) { - const e = (n) => t().update(I0(n)).digest(), r = t(); - return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.create = () => t(), e; -} -function dD(t) { - const e = (n, i) => t(i).update(I0(n)).digest(), r = t({}); - return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.create = (n) => t(n), e; -} -function fse(t = 32) { - if (jc && typeof jc.getRandomValues == "function") - return jc.getRandomValues(new Uint8Array(t)); - if (jc && typeof jc.randomBytes == "function") - return jc.randomBytes(t); - throw new Error("crypto.getRandomValues must be defined"); -} -const C5 = [], T5 = [], R5 = [], pD = /* @__PURE__ */ BigInt(0), bf = /* @__PURE__ */ BigInt(1), gD = /* @__PURE__ */ BigInt(2), mD = /* @__PURE__ */ BigInt(7), vD = /* @__PURE__ */ BigInt(256), bD = /* @__PURE__ */ BigInt(113); -for (let t = 0, e = bf, r = 1, n = 0; t < 24; t++) { - [r, n] = [n, (2 * r + 3 * n) % 5], C5.push(2 * (5 * n + r)), T5.push((t + 1) * (t + 2) / 2 % 64); - let i = pD; - for (let s = 0; s < 7; s++) - e = (e << bf ^ (e >> mD) * bD) % vD, e & gD && (i ^= bf << (bf << /* @__PURE__ */ BigInt(s)) - bf); - R5.push(i); -} -const [yD, wD] = /* @__PURE__ */ nD(R5, !0), _2 = (t, e, r) => r > 32 ? oD(t, e, r) : iD(t, e, r), E2 = (t, e, r) => r > 32 ? aD(t, e, r) : sD(t, e, r); -function D5(t, e = 24) { - const r = new Uint32Array(10); - for (let n = 24 - e; n < 24; n++) { - for (let o = 0; o < 10; o++) - r[o] = t[o] ^ t[o + 10] ^ t[o + 20] ^ t[o + 30] ^ t[o + 40]; - for (let o = 0; o < 10; o += 2) { - const a = (o + 8) % 10, u = (o + 2) % 10, l = r[u], d = r[u + 1], g = _2(l, d, 1) ^ r[a], w = E2(l, d, 1) ^ r[a + 1]; - for (let A = 0; A < 50; A += 10) - t[o + A] ^= g, t[o + A + 1] ^= w; - } - let i = t[2], s = t[3]; - for (let o = 0; o < 24; o++) { - const a = T5[o], u = _2(i, s, a), l = E2(i, s, a), d = C5[o]; - i = t[d], s = t[d + 1], t[d] = u, t[d + 1] = l; - } - for (let o = 0; o < 50; o += 10) { - for (let a = 0; a < 10; a++) - r[a] = t[o + a]; - for (let a = 0; a < 10; a++) - t[o + a] ^= ~r[(a + 2) % 10] & r[(a + 4) % 10]; - } - t[0] ^= yD[n], t[1] ^= wD[n]; - } - r.fill(0); -} -class Ll extends M5 { - // NOTE: we accept arguments in bytes instead of bits here. - constructor(e, r, n, i = !1, s = 24) { - if (super(), this.blockLen = e, this.suffix = r, this.outputLen = n, this.enableXOF = i, this.rounds = s, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, zd(n), 0 >= this.blockLen || this.blockLen >= 200) - throw new Error("Sha3 supports only keccak-f1600 function"); - this.state = new Uint8Array(200), this.state32 = cD(this.state); - } - keccak() { - w2 || x2(this.state32), D5(this.state32, this.rounds), w2 || x2(this.state32), this.posOut = 0, this.pos = 0; - } - update(e) { - Hd(this); - const { blockLen: r, state: n } = this; - e = I0(e); - const i = e.length; - for (let s = 0; s < i; ) { - const o = Math.min(r - this.pos, i - s); - for (let a = 0; a < o; a++) - n[this.pos++] ^= e[s++]; - this.pos === r && this.keccak(); - } - return this; - } - finish() { - if (this.finished) - return; - this.finished = !0; - const { state: e, suffix: r, pos: n, blockLen: i } = this; - e[n] ^= r, r & 128 && n === i - 1 && this.keccak(), e[i - 1] ^= 128, this.keccak(); - } - writeInto(e) { - Hd(this, !1), Nl(e), this.finish(); - const r = this.state, { blockLen: n } = this; - for (let i = 0, s = e.length; i < s; ) { - this.posOut >= n && this.keccak(); - const o = Math.min(n - this.posOut, s - i); - e.set(r.subarray(this.posOut, this.posOut + o), i), this.posOut += o, i += o; - } - return e; - } - xofInto(e) { - if (!this.enableXOF) - throw new Error("XOF is not possible for this instance"); - return this.writeInto(e); - } - xof(e) { - return zd(e), this.xofInto(new Uint8Array(e)); - } - digestInto(e) { - if (P5(e, this), this.finished) - throw new Error("digest() was already called"); - return this.writeInto(e), this.destroy(), e; - } - digest() { - return this.digestInto(new Uint8Array(this.outputLen)); - } - destroy() { - this.destroyed = !0, this.state.fill(0); - } - _cloneInto(e) { - const { blockLen: r, suffix: n, outputLen: i, rounds: s, enableXOF: o } = this; - return e || (e = new Ll(r, n, i, o, s)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = s, e.suffix = n, e.outputLen = i, e.enableXOF = o, e.destroyed = this.destroyed, e; - } -} -const Aa = (t, e, r) => I5(() => new Ll(e, t, r)), xD = /* @__PURE__ */ Aa(6, 144, 224 / 8), _D = /* @__PURE__ */ Aa(6, 136, 256 / 8), ED = /* @__PURE__ */ Aa(6, 104, 384 / 8), SD = /* @__PURE__ */ Aa(6, 72, 512 / 8), AD = /* @__PURE__ */ Aa(1, 144, 224 / 8), O5 = /* @__PURE__ */ Aa(1, 136, 256 / 8), PD = /* @__PURE__ */ Aa(1, 104, 384 / 8), MD = /* @__PURE__ */ Aa(1, 72, 512 / 8), N5 = (t, e, r) => dD((n = {}) => new Ll(e, t, n.dkLen === void 0 ? r : n.dkLen, !0)), ID = /* @__PURE__ */ N5(31, 168, 128 / 8), CD = /* @__PURE__ */ N5(31, 136, 256 / 8), TD = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - Keccak: Ll, - keccakP: D5, - keccak_224: AD, - keccak_256: O5, - keccak_384: PD, - keccak_512: MD, - sha3_224: xD, - sha3_256: _D, - sha3_384: ED, - sha3_512: SD, - shake128: ID, - shake256: CD -}, Symbol.toStringTag, { value: "Module" })); -function kl(t, e) { - const r = e || "hex", n = O5(ma(t, { strict: !1 }) ? _v(t) : t); - return r === "bytes" ? n : qd(n); -} -const RD = (t) => kl(_v(t)); -function DD(t) { - return RD(t); -} -function OD(t) { - let e = !0, r = "", n = 0, i = "", s = !1; - for (let o = 0; o < t.length; o++) { - const a = t[o]; - if (["(", ")", ","].includes(a) && (e = !0), a === "(" && n++, a === ")" && n--, !!e) { - if (n === 0) { - if (a === " " && ["event", "function", ""].includes(i)) - i = ""; - else if (i += a, a === ")") { - s = !0; - break; - } - continue; - } - if (a === " ") { - t[o - 1] !== "," && r !== "," && r !== ",(" && (r = "", e = !1); - continue; - } - i += a, r += a; - } - } - if (!s) - throw new yt("Unable to normalize signature."); - return i; -} -const ND = (t) => { - const e = typeof t == "string" ? t : OR(t); - return OD(e); -}; -function L5(t) { - return DD(ND(t)); -} -const LD = L5; -class bu extends yt { - constructor({ address: e }) { - super(`Address "${e}" is invalid.`, { - metaMessages: [ - "- Address must be a hex value of 20 bytes (40 hex characters).", - "- Address must match its checksum counterpart." - ], - name: "InvalidAddressError" - }); - } -} -class C0 extends Map { - constructor(e) { - super(), Object.defineProperty(this, "maxSize", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.maxSize = e; - } - get(e) { - const r = super.get(e); - return super.has(e) && r !== void 0 && (this.delete(e), super.set(e, r)), r; - } - set(e, r) { - if (super.set(e, r), this.maxSize && this.size > this.maxSize) { - const n = this.keys().next().value; - n && this.delete(n); - } - return this; - } -} -const Bg = /* @__PURE__ */ new C0(8192); -function $l(t, e) { - if (Bg.has(`${t}.${e}`)) - return Bg.get(`${t}.${e}`); - const r = t.substring(2).toLowerCase(), n = kl(A5(r), "bytes"), i = r.split(""); - for (let o = 0; o < 40; o += 2) - n[o >> 1] >> 4 >= 8 && i[o] && (i[o] = i[o].toUpperCase()), (n[o >> 1] & 15) >= 8 && i[o + 1] && (i[o + 1] = i[o + 1].toUpperCase()); - const s = `0x${i.join("")}`; - return Bg.set(`${t}.${e}`, s), s; -} -function k5(t, e) { - if (!Lo(t, { strict: !1 })) - throw new bu({ address: t }); - return $l(t, e); -} -const kD = /^0x[a-fA-F0-9]{40}$/, Ug = /* @__PURE__ */ new C0(8192); -function Lo(t, e) { - const { strict: r = !0 } = e ?? {}, n = `${t}.${r}`; - if (Ug.has(n)) - return Ug.get(n); - const i = kD.test(t) ? t.toLowerCase() === t ? !0 : r ? $l(t) === t : !0 : !1; - return Ug.set(n, i), i; -} -function yu(t) { - return typeof t[0] == "string" ? T0(t) : $D(t); -} -function $D(t) { - let e = 0; - for (const i of t) - e += i.length; - const r = new Uint8Array(e); - let n = 0; - for (const i of t) - r.set(i, n), n += i.length; - return r; -} -function T0(t) { - return `0x${t.reduce((e, r) => e + r.replace("0x", ""), "")}`; -} -function Wd(t, e, r, { strict: n } = {}) { - return ma(t, { strict: !1 }) ? FD(t, e, r, { - strict: n - }) : B5(t, e, r, { - strict: n - }); -} -function $5(t, e) { - if (typeof e == "number" && e > 0 && e > An(t) - 1) - throw new _5({ - offset: e, - position: "start", - size: An(t) - }); -} -function F5(t, e, r) { - if (typeof e == "number" && typeof r == "number" && An(t) !== r - e) - throw new _5({ - offset: r, - position: "end", - size: An(t) - }); -} -function B5(t, e, r, { strict: n } = {}) { - $5(t, e); - const i = t.slice(e, r); - return n && F5(i, e, r), i; -} -function FD(t, e, r, { strict: n } = {}) { - $5(t, e); - const i = `0x${t.replace("0x", "").slice((e ?? 0) * 2, (r ?? t.length) * 2)}`; - return n && F5(i, e, r), i; -} -function U5(t, e) { - if (t.length !== e.length) - throw new BR({ - expectedLength: t.length, - givenLength: e.length - }); - const r = BD({ - params: t, - values: e - }), n = Sv(r); - return n.length === 0 ? "0x" : n; -} -function BD({ params: t, values: e }) { - const r = []; - for (let n = 0; n < t.length; n++) - r.push(Ev({ param: t[n], value: e[n] })); - return r; -} -function Ev({ param: t, value: e }) { - const r = Av(t.type); - if (r) { - const [n, i] = r; - return jD(e, { length: n, param: { ...t, type: i } }); - } - if (t.type === "tuple") - return KD(e, { - param: t - }); - if (t.type === "address") - return UD(e); - if (t.type === "bool") - return zD(e); - if (t.type.startsWith("uint") || t.type.startsWith("int")) { - const n = t.type.startsWith("int"); - return HD(e, { signed: n }); - } - if (t.type.startsWith("bytes")) - return qD(e, { param: t }); - if (t.type === "string") - return WD(e); - throw new qR(t.type, { - docsPath: "/docs/contract/encodeAbiParameters" - }); -} -function Sv(t) { - let e = 0; - for (let s = 0; s < t.length; s++) { - const { dynamic: o, encoded: a } = t[s]; - o ? e += 32 : e += An(a); - } - const r = [], n = []; - let i = 0; - for (let s = 0; s < t.length; s++) { - const { dynamic: o, encoded: a } = t[s]; - o ? (r.push(Mr(e + i, { size: 32 })), n.push(a), i += An(a)) : r.push(a); - } - return yu([...r, ...n]); -} -function UD(t) { - if (!Lo(t)) - throw new bu({ address: t }); - return { dynamic: !1, encoded: ga(t.toLowerCase()) }; -} -function jD(t, { length: e, param: r }) { - const n = e === null; - if (!Array.isArray(t)) - throw new HR(t); - if (!n && t.length !== e) - throw new $R({ - expectedLength: e, - givenLength: t.length, - type: `${r.type}[${e}]` - }); - let i = !1; - const s = []; - for (let o = 0; o < t.length; o++) { - const a = Ev({ param: r, value: t[o] }); - a.dynamic && (i = !0), s.push(a); - } - if (n || i) { - const o = Sv(s); - if (n) { - const a = Mr(s.length, { size: 32 }); - return { - dynamic: !0, - encoded: s.length > 0 ? yu([a, o]) : a - }; - } - if (i) - return { dynamic: !0, encoded: o }; - } - return { - dynamic: !1, - encoded: yu(s.map(({ encoded: o }) => o)) - }; -} -function qD(t, { param: e }) { - const [, r] = e.type.split("bytes"), n = An(t); - if (!r) { - let i = t; - return n % 32 !== 0 && (i = ga(i, { - dir: "right", - size: Math.ceil((t.length - 2) / 2 / 32) * 32 - })), { - dynamic: !0, - encoded: yu([ga(Mr(n, { size: 32 })), i]) - }; - } - if (n !== Number.parseInt(r)) - throw new FR({ - expectedSize: Number.parseInt(r), - value: t - }); - return { dynamic: !1, encoded: ga(t, { dir: "right" }) }; -} -function zD(t) { - if (typeof t != "boolean") - throw new yt(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`); - return { dynamic: !1, encoded: ga(S5(t)) }; -} -function HD(t, { signed: e }) { - return { - dynamic: !1, - encoded: Mr(t, { - size: 32, - signed: e - }) - }; -} -function WD(t) { - const e = M0(t), r = Math.ceil(An(e) / 32), n = []; - for (let i = 0; i < r; i++) - n.push(ga(Wd(e, i * 32, (i + 1) * 32), { - dir: "right" - })); - return { - dynamic: !0, - encoded: yu([ - ga(Mr(An(e), { size: 32 })), - ...n - ]) - }; -} -function KD(t, { param: e }) { - let r = !1; - const n = []; - for (let i = 0; i < e.components.length; i++) { - const s = e.components[i], o = Array.isArray(t) ? i : s.name, a = Ev({ - param: s, - value: t[o] - }); - n.push(a), a.dynamic && (r = !0); - } - return { - dynamic: r, - encoded: r ? Sv(n) : yu(n.map(({ encoded: i }) => i)) - }; -} -function Av(t) { - const e = t.match(/^(.*)\[(\d+)?\]$/); - return e ? ( - // Return `null` if the array is dynamic. - [e[2] ? Number(e[2]) : null, e[1]] - ) : void 0; -} -const Pv = (t) => Wd(L5(t), 0, 4); -function j5(t) { - const { abi: e, args: r = [], name: n } = t, i = ma(n, { strict: !1 }), s = e.filter((a) => i ? a.type === "function" ? Pv(a) === n : a.type === "event" ? LD(a) === n : !1 : "name" in a && a.name === n); - if (s.length === 0) - return; - if (s.length === 1) - return s[0]; - let o; - for (const a of s) { - if (!("inputs" in a)) - continue; - if (!r || r.length === 0) { - if (!a.inputs || a.inputs.length === 0) - return a; - continue; - } - if (!a.inputs || a.inputs.length === 0 || a.inputs.length !== r.length) - continue; - if (r.every((l, d) => { - const g = "inputs" in a && a.inputs[d]; - return g ? Xm(l, g) : !1; - })) { - if (o && "inputs" in o && o.inputs) { - const l = q5(a.inputs, o.inputs, r); - if (l) - throw new UR({ - abiItem: a, - type: l[0] - }, { - abiItem: o, - type: l[1] - }); - } - o = a; - } - } - return o || s[0]; -} -function Xm(t, e) { - const r = typeof t, n = e.type; - switch (n) { - case "address": - return Lo(t, { strict: !1 }); - case "bool": - return r === "boolean"; - case "function": - return r === "string"; - case "string": - return r === "string"; - default: - return n === "tuple" && "components" in e ? Object.values(e.components).every((i, s) => Xm(Object.values(t)[s], i)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(n) ? r === "number" || r === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(n) ? r === "string" || t instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(n) ? Array.isArray(t) && t.every((i) => Xm(i, { - ...e, - // Pop off `[]` or `[M]` from end of type - type: n.replace(/(\[[0-9]{0,}\])$/, "") - })) : !1; - } -} -function q5(t, e, r) { - for (const n in t) { - const i = t[n], s = e[n]; - if (i.type === "tuple" && s.type === "tuple" && "components" in i && "components" in s) - return q5(i.components, s.components, r[n]); - const o = [i.type, s.type]; - if (o.includes("address") && o.includes("bytes20") ? !0 : o.includes("address") && o.includes("string") ? Lo(r[n], { strict: !1 }) : o.includes("address") && o.includes("bytes") ? Lo(r[n], { strict: !1 }) : !1) - return o; - } -} -function jo(t) { - return typeof t == "string" ? { address: t, type: "json-rpc" } : t; -} -const S2 = "/docs/contract/encodeFunctionData"; -function VD(t) { - const { abi: e, args: r, functionName: n } = t; - let i = e[0]; - if (n) { - const s = j5({ - abi: e, - args: r, - name: n - }); - if (!s) - throw new m2(n, { docsPath: S2 }); - i = s; - } - if (i.type !== "function") - throw new m2(void 0, { docsPath: S2 }); - return { - abi: [i], - functionName: Pv(mu(i)) - }; -} -function GD(t) { - const { args: e } = t, { abi: r, functionName: n } = (() => { - var a; - return t.abi.length === 1 && ((a = t.functionName) != null && a.startsWith("0x")) ? t : VD(t); - })(), i = r[0], s = n, o = "inputs" in i && i.inputs ? U5(i.inputs, e ?? []) : void 0; - return T0([s, o ?? "0x"]); -} -const YD = { - 1: "An `assert` condition failed.", - 17: "Arithmetic operation resulted in underflow or overflow.", - 18: "Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).", - 33: "Attempted to convert to an invalid type.", - 34: "Attempted to access a storage byte array that is incorrectly encoded.", - 49: "Performed `.pop()` on an empty array", - 50: "Array index is out of bounds.", - 65: "Allocated too much memory or created an array which is too large.", - 81: "Attempted to call a zero-initialized variable of internal function type." -}, JD = { - inputs: [ - { - name: "message", - type: "string" - } - ], - name: "Error", - type: "error" -}, XD = { - inputs: [ - { - name: "reason", - type: "uint256" - } - ], - name: "Panic", - type: "error" -}; -class A2 extends yt { - constructor({ offset: e }) { - super(`Offset \`${e}\` cannot be negative.`, { - name: "NegativeOffsetError" - }); - } -} -class ZD extends yt { - constructor({ length: e, position: r }) { - super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`, { name: "PositionOutOfBoundsError" }); - } -} -class QD extends yt { - constructor({ count: e, limit: r }) { - super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`, { name: "RecursiveReadLimitExceededError" }); - } -} -const eO = { - bytes: new Uint8Array(), - dataView: new DataView(new ArrayBuffer(0)), - position: 0, - positionReadCount: /* @__PURE__ */ new Map(), - recursiveReadCount: 0, - recursiveReadLimit: Number.POSITIVE_INFINITY, - assertReadLimit() { - if (this.recursiveReadCount >= this.recursiveReadLimit) - throw new QD({ - count: this.recursiveReadCount + 1, - limit: this.recursiveReadLimit - }); - }, - assertPosition(t) { - if (t < 0 || t > this.bytes.length - 1) - throw new ZD({ - length: this.bytes.length, - position: t - }); - }, - decrementPosition(t) { - if (t < 0) - throw new A2({ offset: t }); - const e = this.position - t; - this.assertPosition(e), this.position = e; - }, - getReadCount(t) { - return this.positionReadCount.get(t || this.position) || 0; - }, - incrementPosition(t) { - if (t < 0) - throw new A2({ offset: t }); - const e = this.position + t; - this.assertPosition(e), this.position = e; - }, - inspectByte(t) { - const e = t ?? this.position; - return this.assertPosition(e), this.bytes[e]; - }, - inspectBytes(t, e) { - const r = e ?? this.position; - return this.assertPosition(r + t - 1), this.bytes.subarray(r, r + t); - }, - inspectUint8(t) { - const e = t ?? this.position; - return this.assertPosition(e), this.bytes[e]; - }, - inspectUint16(t) { - const e = t ?? this.position; - return this.assertPosition(e + 1), this.dataView.getUint16(e); - }, - inspectUint24(t) { - const e = t ?? this.position; - return this.assertPosition(e + 2), (this.dataView.getUint16(e) << 8) + this.dataView.getUint8(e + 2); - }, - inspectUint32(t) { - const e = t ?? this.position; - return this.assertPosition(e + 3), this.dataView.getUint32(e); - }, - pushByte(t) { - this.assertPosition(this.position), this.bytes[this.position] = t, this.position++; - }, - pushBytes(t) { - this.assertPosition(this.position + t.length - 1), this.bytes.set(t, this.position), this.position += t.length; - }, - pushUint8(t) { - this.assertPosition(this.position), this.bytes[this.position] = t, this.position++; - }, - pushUint16(t) { - this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, t), this.position += 2; - }, - pushUint24(t) { - this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, t >> 8), this.dataView.setUint8(this.position + 2, t & 255), this.position += 3; - }, - pushUint32(t) { - this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, t), this.position += 4; - }, - readByte() { - this.assertReadLimit(), this._touch(); - const t = this.inspectByte(); - return this.position++, t; - }, - readBytes(t, e) { - this.assertReadLimit(), this._touch(); - const r = this.inspectBytes(t); - return this.position += e ?? t, r; - }, - readUint8() { - this.assertReadLimit(), this._touch(); - const t = this.inspectUint8(); - return this.position += 1, t; - }, - readUint16() { - this.assertReadLimit(), this._touch(); - const t = this.inspectUint16(); - return this.position += 2, t; - }, - readUint24() { - this.assertReadLimit(), this._touch(); - const t = this.inspectUint24(); - return this.position += 3, t; - }, - readUint32() { - this.assertReadLimit(), this._touch(); - const t = this.inspectUint32(); - return this.position += 4, t; - }, - get remaining() { - return this.bytes.length - this.position; - }, - setPosition(t) { - const e = this.position; - return this.assertPosition(t), this.position = t, () => this.position = e; - }, - _touch() { - if (this.recursiveReadLimit === Number.POSITIVE_INFINITY) - return; - const t = this.getReadCount(); - this.positionReadCount.set(this.position, t + 1), t > 0 && this.recursiveReadCount++; - } -}; -function Mv(t, { recursiveReadLimit: e = 8192 } = {}) { - const r = Object.create(eO); - return r.bytes = t, r.dataView = new DataView(t.buffer, t.byteOffset, t.byteLength), r.positionReadCount = /* @__PURE__ */ new Map(), r.recursiveReadLimit = e, r; -} -function tO(t, e = {}) { - typeof e.size < "u" && eo(t, { size: e.size }); - const r = wi(t, e); - return Qf(r, e); -} -function rO(t, e = {}) { - let r = t; - if (typeof e.size < "u" && (eo(r, { size: e.size }), r = xv(r)), r.length > 1 || r[0] > 1) - throw new GR(r); - return !!r[0]; -} -function Mo(t, e = {}) { - typeof e.size < "u" && eo(t, { size: e.size }); - const r = wi(t, e); - return vu(r, e); -} -function nO(t, e = {}) { - let r = t; - return typeof e.size < "u" && (eo(r, { size: e.size }), r = xv(r, { dir: "right" })), new TextDecoder().decode(r); -} -function iO(t, e) { - const r = typeof e == "string" ? No(e) : e, n = Mv(r); - if (An(r) === 0 && t.length > 0) - throw new wv(); - if (An(e) && An(e) < 32) - throw new kR({ - data: typeof e == "string" ? e : wi(e), - params: t, - size: An(e) - }); - let i = 0; - const s = []; - for (let o = 0; o < t.length; ++o) { - const a = t[o]; - n.setPosition(i); - const [u, l] = ou(n, a, { - staticPosition: 0 - }); - i += l, s.push(u); - } - return s; -} -function ou(t, e, { staticPosition: r }) { - const n = Av(e.type); - if (n) { - const [i, s] = n; - return oO(t, { ...e, type: s }, { length: i, staticPosition: r }); - } - if (e.type === "tuple") - return fO(t, e, { staticPosition: r }); - if (e.type === "address") - return sO(t); - if (e.type === "bool") - return aO(t); - if (e.type.startsWith("bytes")) - return cO(t, e, { staticPosition: r }); - if (e.type.startsWith("uint") || e.type.startsWith("int")) - return uO(t, e); - if (e.type === "string") - return lO(t, { staticPosition: r }); - throw new zR(e.type, { - docsPath: "/docs/contract/decodeAbiParameters" - }); -} -const P2 = 32, Zm = 32; -function sO(t) { - const e = t.readBytes(32); - return [$l(wi(B5(e, -20))), 32]; -} -function oO(t, e, { length: r, staticPosition: n }) { - if (!r) { - const o = Mo(t.readBytes(Zm)), a = n + o, u = a + P2; - t.setPosition(a); - const l = Mo(t.readBytes(P2)), d = el(e); - let g = 0; - const w = []; - for (let A = 0; A < l; ++A) { - t.setPosition(u + (d ? A * 32 : g)); - const [M, N] = ou(t, e, { - staticPosition: u - }); - g += N, w.push(M); - } - return t.setPosition(n + 32), [w, 32]; - } - if (el(e)) { - const o = Mo(t.readBytes(Zm)), a = n + o, u = []; - for (let l = 0; l < r; ++l) { - t.setPosition(a + l * 32); - const [d] = ou(t, e, { - staticPosition: a - }); - u.push(d); - } - return t.setPosition(n + 32), [u, 32]; - } - let i = 0; - const s = []; - for (let o = 0; o < r; ++o) { - const [a, u] = ou(t, e, { - staticPosition: n + i - }); - i += u, s.push(a); - } - return [s, i]; -} -function aO(t) { - return [rO(t.readBytes(32), { size: 32 }), 32]; -} -function cO(t, e, { staticPosition: r }) { - const [n, i] = e.type.split("bytes"); - if (!i) { - const o = Mo(t.readBytes(32)); - t.setPosition(r + o); - const a = Mo(t.readBytes(32)); - if (a === 0) - return t.setPosition(r + 32), ["0x", 32]; - const u = t.readBytes(a); - return t.setPosition(r + 32), [wi(u), 32]; - } - return [wi(t.readBytes(Number.parseInt(i), 32)), 32]; -} -function uO(t, e) { - const r = e.type.startsWith("int"), n = Number.parseInt(e.type.split("int")[1] || "256"), i = t.readBytes(32); - return [ - n > 48 ? tO(i, { signed: r }) : Mo(i, { signed: r }), - 32 - ]; -} -function fO(t, e, { staticPosition: r }) { - const n = e.components.length === 0 || e.components.some(({ name: o }) => !o), i = n ? [] : {}; - let s = 0; - if (el(e)) { - const o = Mo(t.readBytes(Zm)), a = r + o; - for (let u = 0; u < e.components.length; ++u) { - const l = e.components[u]; - t.setPosition(a + s); - const [d, g] = ou(t, l, { - staticPosition: a - }); - s += g, i[n ? u : l == null ? void 0 : l.name] = d; - } - return t.setPosition(r + 32), [i, 32]; - } - for (let o = 0; o < e.components.length; ++o) { - const a = e.components[o], [u, l] = ou(t, a, { - staticPosition: r - }); - i[n ? o : a == null ? void 0 : a.name] = u, s += l; - } - return [i, s]; -} -function lO(t, { staticPosition: e }) { - const r = Mo(t.readBytes(32)), n = e + r; - t.setPosition(n); - const i = Mo(t.readBytes(32)); - if (i === 0) - return t.setPosition(e + 32), ["", 32]; - const s = t.readBytes(i, 32), o = nO(xv(s)); - return t.setPosition(e + 32), [o, 32]; -} -function el(t) { - var n; - const { type: e } = t; - if (e === "string" || e === "bytes" || e.endsWith("[]")) - return !0; - if (e === "tuple") - return (n = t.components) == null ? void 0 : n.some(el); - const r = Av(t.type); - return !!(r && el({ ...t, type: r[1] })); -} -function hO(t) { - const { abi: e, data: r } = t, n = Wd(r, 0, 4); - if (n === "0x") - throw new wv(); - const s = [...e || [], JD, XD].find((o) => o.type === "error" && n === Pv(mu(o))); - if (!s) - throw new x5(n, { - docsPath: "/docs/contract/decodeErrorResult" - }); - return { - abiItem: s, - args: "inputs" in s && s.inputs && s.inputs.length > 0 ? iO(s.inputs, Wd(r, 4)) : void 0, - errorName: s.name - }; -} -const Tu = (t, e, r) => JSON.stringify(t, (n, i) => typeof i == "bigint" ? i.toString() : i, r); -function z5({ abiItem: t, args: e, includeFunctionName: r = !0, includeName: n = !1 }) { - if ("name" in t && "inputs" in t && t.inputs) - return `${r ? t.name : ""}(${t.inputs.map((i, s) => `${n && i.name ? `${i.name}: ` : ""}${typeof e[s] == "object" ? Tu(e[s]) : e[s]}`).join(", ")})`; -} -const dO = { - gwei: 9, - wei: 18 -}, pO = { - ether: -9, - wei: 9 -}; -function H5(t, e) { - let r = t.toString(); - const n = r.startsWith("-"); - n && (r = r.slice(1)), r = r.padStart(e, "0"); - let [i, s] = [ - r.slice(0, r.length - e), - r.slice(r.length - e) - ]; - return s = s.replace(/(0+)$/, ""), `${n ? "-" : ""}${i || "0"}${s ? `.${s}` : ""}`; -} -function W5(t, e = "wei") { - return H5(t, dO[e]); -} -function _s(t, e = "wei") { - return H5(t, pO[e]); -} -class gO extends yt { - constructor({ address: e }) { - super(`State for account "${e}" is set multiple times.`, { - name: "AccountStateConflictError" - }); - } -} -class mO extends yt { - constructor() { - super("state and stateDiff are set on the same account.", { - name: "StateAssignmentConflictError" - }); - } -} -function R0(t) { - const e = Object.entries(t).map(([n, i]) => i === void 0 || i === !1 ? null : [n, i]).filter(Boolean), r = e.reduce((n, [i]) => Math.max(n, i.length), 0); - return e.map(([n, i]) => ` ${`${n}:`.padEnd(r + 1)} ${i}`).join(` -`); -} -class vO extends yt { - constructor() { - super([ - "Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.", - "Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others." - ].join(` -`), { name: "FeeConflictError" }); - } -} -class bO extends yt { - constructor({ transaction: e }) { - super("Cannot infer a transaction type from provided transaction.", { - metaMessages: [ - "Provided Transaction:", - "{", - R0(e), - "}", - "", - "To infer the type, either provide:", - "- a `type` to the Transaction, or", - "- an EIP-1559 Transaction with `maxFeePerGas`, or", - "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or", - "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or", - "- an EIP-7702 Transaction with `authorizationList`, or", - "- a Legacy Transaction with `gasPrice`" - ], - name: "InvalidSerializableTransactionError" - }); - } -} -class yO extends yt { - constructor(e, { account: r, docsPath: n, chain: i, data: s, gas: o, gasPrice: a, maxFeePerGas: u, maxPriorityFeePerGas: l, nonce: d, to: g, value: w }) { - var M; - const A = R0({ - chain: i && `${i == null ? void 0 : i.name} (id: ${i == null ? void 0 : i.id})`, - from: r == null ? void 0 : r.address, - to: g, - value: typeof w < "u" && `${W5(w)} ${((M = i == null ? void 0 : i.nativeCurrency) == null ? void 0 : M.symbol) || "ETH"}`, - data: s, - gas: o, - gasPrice: typeof a < "u" && `${_s(a)} gwei`, - maxFeePerGas: typeof u < "u" && `${_s(u)} gwei`, - maxPriorityFeePerGas: typeof l < "u" && `${_s(l)} gwei`, - nonce: d - }); - super(e.shortMessage, { - cause: e, - docsPath: n, - metaMessages: [ - ...e.metaMessages ? [...e.metaMessages, " "] : [], - "Request Arguments:", - A - ].filter(Boolean), - name: "TransactionExecutionError" - }), Object.defineProperty(this, "cause", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.cause = e; - } -} -const wO = (t) => t, K5 = (t) => t; -class xO extends yt { - constructor(e, { abi: r, args: n, contractAddress: i, docsPath: s, functionName: o, sender: a }) { - const u = j5({ abi: r, args: n, name: o }), l = u ? z5({ - abiItem: u, - args: n, - includeFunctionName: !1, - includeName: !1 - }) : void 0, d = u ? mu(u, { includeName: !0 }) : void 0, g = R0({ - address: i && wO(i), - function: d, - args: l && l !== "()" && `${[...Array((o == null ? void 0 : o.length) ?? 0).keys()].map(() => " ").join("")}${l}`, - sender: a - }); - super(e.shortMessage || `An unknown error occurred while executing the contract function "${o}".`, { - cause: e, - docsPath: s, - metaMessages: [ - ...e.metaMessages ? [...e.metaMessages, " "] : [], - g && "Contract Call:", - g - ].filter(Boolean), - name: "ContractFunctionExecutionError" - }), Object.defineProperty(this, "abi", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "args", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "cause", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "contractAddress", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "formattedArgs", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "functionName", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "sender", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.abi = r, this.args = n, this.cause = e, this.contractAddress = i, this.functionName = o, this.sender = a; - } -} -class _O extends yt { - constructor({ abi: e, data: r, functionName: n, message: i }) { - let s, o, a, u; - if (r && r !== "0x") - try { - o = hO({ abi: e, data: r }); - const { abiItem: d, errorName: g, args: w } = o; - if (g === "Error") - u = w[0]; - else if (g === "Panic") { - const [A] = w; - u = YD[A]; - } else { - const A = d ? mu(d, { includeName: !0 }) : void 0, M = d && w ? z5({ - abiItem: d, - args: w, - includeFunctionName: !1, - includeName: !1 - }) : void 0; - a = [ - A ? `Error: ${A}` : "", - M && M !== "()" ? ` ${[...Array((g == null ? void 0 : g.length) ?? 0).keys()].map(() => " ").join("")}${M}` : "" - ]; - } - } catch (d) { - s = d; - } - else i && (u = i); - let l; - s instanceof x5 && (l = s.signature, a = [ - `Unable to decode signature "${l}" as it was not found on the provided ABI.`, - "Make sure you are using the correct ABI and that the error exists on it.", - `You can look up the decoded signature here: https://openchain.xyz/signatures?query=${l}.` - ]), super(u && u !== "execution reverted" || l ? [ - `The contract function "${n}" reverted with the following ${l ? "signature" : "reason"}:`, - u || l - ].join(` -`) : `The contract function "${n}" reverted.`, { - cause: s, - metaMessages: a, - name: "ContractFunctionRevertedError" - }), Object.defineProperty(this, "data", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "reason", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "signature", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.data = o, this.reason = u, this.signature = l; - } -} -class EO extends yt { - constructor({ functionName: e }) { - super(`The contract function "${e}" returned no data ("0x").`, { - metaMessages: [ - "This could be due to any of the following:", - ` - The contract does not have the function "${e}",`, - " - The parameters passed to the contract function may be invalid, or", - " - The address is not a contract." - ], - name: "ContractFunctionZeroDataError" - }); - } -} -class SO extends yt { - constructor({ data: e, message: r }) { - super(r || "", { name: "RawContractError" }), Object.defineProperty(this, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: 3 - }), Object.defineProperty(this, "data", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.data = e; - } -} -class V5 extends yt { - constructor({ body: e, cause: r, details: n, headers: i, status: s, url: o }) { - super("HTTP request failed.", { - cause: r, - details: n, - metaMessages: [ - s && `Status: ${s}`, - `URL: ${K5(o)}`, - e && `Request body: ${Tu(e)}` - ].filter(Boolean), - name: "HttpRequestError" - }), Object.defineProperty(this, "body", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "headers", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "status", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), Object.defineProperty(this, "url", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.body = e, this.headers = i, this.status = s, this.url = o; - } -} -class AO extends yt { - constructor({ body: e, error: r, url: n }) { - super("RPC Request failed.", { - cause: r, - details: r.message, - metaMessages: [`URL: ${K5(n)}`, `Request body: ${Tu(e)}`], - name: "RpcRequestError" - }), Object.defineProperty(this, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.code = r.code; - } -} -const PO = -1; -class Ei extends yt { - constructor(e, { code: r, docsPath: n, metaMessages: i, name: s, shortMessage: o }) { - super(o, { - cause: e, - docsPath: n, - metaMessages: i || (e == null ? void 0 : e.metaMessages), - name: s || "RpcError" - }), Object.defineProperty(this, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.name = s || e.name, this.code = e instanceof AO ? e.code : r ?? PO; - } -} -class Ru extends Ei { - constructor(e, r) { - super(e, r), Object.defineProperty(this, "data", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.data = r.data; - } -} -class tl extends Ei { - constructor(e) { - super(e, { - code: tl.code, - name: "ParseRpcError", - shortMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text." - }); - } -} -Object.defineProperty(tl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32700 -}); -class rl extends Ei { - constructor(e) { - super(e, { - code: rl.code, - name: "InvalidRequestRpcError", - shortMessage: "JSON is not a valid request object." - }); - } -} -Object.defineProperty(rl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32600 -}); -class nl extends Ei { - constructor(e, { method: r } = {}) { - super(e, { - code: nl.code, - name: "MethodNotFoundRpcError", - shortMessage: `The method${r ? ` "${r}"` : ""} does not exist / is not available.` - }); - } -} -Object.defineProperty(nl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32601 -}); -class il extends Ei { - constructor(e) { - super(e, { - code: il.code, - name: "InvalidParamsRpcError", - shortMessage: [ - "Invalid parameters were provided to the RPC method.", - "Double check you have provided the correct parameters." - ].join(` -`) - }); - } -} -Object.defineProperty(il, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32602 -}); -class cc extends Ei { - constructor(e) { - super(e, { - code: cc.code, - name: "InternalRpcError", - shortMessage: "An internal error was received." - }); - } -} -Object.defineProperty(cc, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32603 -}); -class sl extends Ei { - constructor(e) { - super(e, { - code: sl.code, - name: "InvalidInputRpcError", - shortMessage: [ - "Missing or invalid parameters.", - "Double check you have provided the correct parameters." - ].join(` -`) - }); - } -} -Object.defineProperty(sl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32e3 -}); -class ol extends Ei { - constructor(e) { - super(e, { - code: ol.code, - name: "ResourceNotFoundRpcError", - shortMessage: "Requested resource not found." - }), Object.defineProperty(this, "name", { - enumerable: !0, - configurable: !0, - writable: !0, - value: "ResourceNotFoundRpcError" - }); - } -} -Object.defineProperty(ol, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32001 -}); -class al extends Ei { - constructor(e) { - super(e, { - code: al.code, - name: "ResourceUnavailableRpcError", - shortMessage: "Requested resource not available." - }); - } -} -Object.defineProperty(al, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32002 -}); -class cl extends Ei { - constructor(e) { - super(e, { - code: cl.code, - name: "TransactionRejectedRpcError", - shortMessage: "Transaction creation failed." - }); - } -} -Object.defineProperty(cl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32003 -}); -class ul extends Ei { - constructor(e, { method: r } = {}) { - super(e, { - code: ul.code, - name: "MethodNotSupportedRpcError", - shortMessage: `Method${r ? ` "${r}"` : ""} is not implemented.` - }); - } -} -Object.defineProperty(ul, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32004 -}); -class wu extends Ei { - constructor(e) { - super(e, { - code: wu.code, - name: "LimitExceededRpcError", - shortMessage: "Request exceeds defined limit." - }); - } -} -Object.defineProperty(wu, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32005 -}); -class fl extends Ei { - constructor(e) { - super(e, { - code: fl.code, - name: "JsonRpcVersionUnsupportedError", - shortMessage: "Version of JSON-RPC protocol is not supported." - }); - } -} -Object.defineProperty(fl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: -32006 -}); -class au extends Ru { - constructor(e) { - super(e, { - code: au.code, - name: "UserRejectedRequestError", - shortMessage: "User rejected the request." - }); - } -} -Object.defineProperty(au, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: 4001 -}); -class ll extends Ru { - constructor(e) { - super(e, { - code: ll.code, - name: "UnauthorizedProviderError", - shortMessage: "The requested method and/or account has not been authorized by the user." - }); - } -} -Object.defineProperty(ll, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: 4100 -}); -class hl extends Ru { - constructor(e, { method: r } = {}) { - super(e, { - code: hl.code, - name: "UnsupportedProviderMethodError", - shortMessage: `The Provider does not support the requested method${r ? ` " ${r}"` : ""}.` - }); - } -} -Object.defineProperty(hl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: 4200 -}); -class dl extends Ru { - constructor(e) { - super(e, { - code: dl.code, - name: "ProviderDisconnectedError", - shortMessage: "The Provider is disconnected from all chains." - }); - } -} -Object.defineProperty(dl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: 4900 -}); -class pl extends Ru { - constructor(e) { - super(e, { - code: pl.code, - name: "ChainDisconnectedError", - shortMessage: "The Provider is not connected to the requested chain." - }); - } -} -Object.defineProperty(pl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: 4901 -}); -class gl extends Ru { - constructor(e) { - super(e, { - code: gl.code, - name: "SwitchChainError", - shortMessage: "An error occurred when attempting to switch chain." - }); - } -} -Object.defineProperty(gl, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: 4902 -}); -class MO extends Ei { - constructor(e) { - super(e, { - name: "UnknownRpcError", - shortMessage: "An unknown RPC error occurred." - }); - } -} -const IO = 3; -function CO(t, { abi: e, address: r, args: n, docsPath: i, functionName: s, sender: o }) { - const { code: a, data: u, message: l, shortMessage: d } = t instanceof SO ? t : t instanceof yt ? t.walk((w) => "data" in w) || t.walk() : {}, g = t instanceof wv ? new EO({ functionName: s }) : [IO, cc.code].includes(a) && (u || l || d) ? new _O({ - abi: e, - data: typeof u == "object" ? u.data : u, - functionName: s, - message: d ?? l - }) : t; - return new xO(g, { - abi: e, - args: n, - contractAddress: r, - docsPath: i, - functionName: s, - sender: o - }); -} -function TO(t) { - const e = kl(`0x${t.substring(4)}`).substring(26); - return $l(`0x${e}`); -} -async function RO({ hash: t, signature: e }) { - const r = ma(t) ? t : qd(t), { secp256k1: n } = await import("./secp256k1-BZeczIQv.js"); - return `0x${(() => { - if (typeof e == "object" && "r" in e && "s" in e) { - const { r: l, s: d, v: g, yParity: w } = e, A = Number(w ?? g), M = M2(A); - return new n.Signature(Qf(l), Qf(d)).addRecoveryBit(M); - } - const o = ma(e) ? e : qd(e), a = vu(`0x${o.slice(130)}`), u = M2(a); - return n.Signature.fromCompact(o.substring(2, 130)).addRecoveryBit(u); - })().recoverPublicKey(r.substring(2)).toHex(!1)}`; -} -function M2(t) { - if (t === 0 || t === 1) - return t; - if (t === 27) - return 0; - if (t === 28) - return 1; - throw new Error("Invalid yParityOrV value"); -} -async function DO({ hash: t, signature: e }) { - return TO(await RO({ hash: t, signature: e })); -} -function OO(t, e = "hex") { - const r = G5(t), n = Mv(new Uint8Array(r.length)); - return r.encode(n), e === "hex" ? wi(n.bytes) : n.bytes; -} -function G5(t) { - return Array.isArray(t) ? NO(t.map((e) => G5(e))) : LO(t); -} -function NO(t) { - const e = t.reduce((i, s) => i + s.length, 0), r = Y5(e); - return { - length: e <= 55 ? 1 + e : 1 + r + e, - encode(i) { - e <= 55 ? i.pushByte(192 + e) : (i.pushByte(247 + r), r === 1 ? i.pushUint8(e) : r === 2 ? i.pushUint16(e) : r === 3 ? i.pushUint24(e) : i.pushUint32(e)); - for (const { encode: s } of t) - s(i); - } - }; -} -function LO(t) { - const e = typeof t == "string" ? No(t) : t, r = Y5(e.length); - return { - length: e.length === 1 && e[0] < 128 ? 1 : e.length <= 55 ? 1 + e.length : 1 + r + e.length, - encode(i) { - e.length === 1 && e[0] < 128 ? i.pushBytes(e) : e.length <= 55 ? (i.pushByte(128 + e.length), i.pushBytes(e)) : (i.pushByte(183 + r), r === 1 ? i.pushUint8(e.length) : r === 2 ? i.pushUint16(e.length) : r === 3 ? i.pushUint24(e.length) : i.pushUint32(e.length), i.pushBytes(e)); - } - }; -} -function Y5(t) { - if (t < 2 ** 8) - return 1; - if (t < 2 ** 16) - return 2; - if (t < 2 ** 24) - return 3; - if (t < 2 ** 32) - return 4; - throw new yt("Length is too large."); -} -function kO(t) { - const { chainId: e, contractAddress: r, nonce: n, to: i } = t, s = kl(T0([ - "0x05", - OO([ - e ? Mr(e) : "0x", - r, - n ? Mr(n) : "0x" - ]) - ])); - return i === "bytes" ? No(s) : s; -} -async function J5(t) { - const { authorization: e, signature: r } = t; - return DO({ - hash: kO(e), - signature: r ?? e - }); -} -class $O extends yt { - constructor(e, { account: r, docsPath: n, chain: i, data: s, gas: o, gasPrice: a, maxFeePerGas: u, maxPriorityFeePerGas: l, nonce: d, to: g, value: w }) { - var M; - const A = R0({ - from: r == null ? void 0 : r.address, - to: g, - value: typeof w < "u" && `${W5(w)} ${((M = i == null ? void 0 : i.nativeCurrency) == null ? void 0 : M.symbol) || "ETH"}`, - data: s, - gas: o, - gasPrice: typeof a < "u" && `${_s(a)} gwei`, - maxFeePerGas: typeof u < "u" && `${_s(u)} gwei`, - maxPriorityFeePerGas: typeof l < "u" && `${_s(l)} gwei`, - nonce: d - }); - super(e.shortMessage, { - cause: e, - docsPath: n, - metaMessages: [ - ...e.metaMessages ? [...e.metaMessages, " "] : [], - "Estimate Gas Arguments:", - A - ].filter(Boolean), - name: "EstimateGasExecutionError" - }), Object.defineProperty(this, "cause", { - enumerable: !0, - configurable: !0, - writable: !0, - value: void 0 - }), this.cause = e; - } -} -class Xc extends yt { - constructor({ cause: e, message: r } = {}) { - var i; - const n = (i = r == null ? void 0 : r.replace("execution reverted: ", "")) == null ? void 0 : i.replace("execution reverted", ""); - super(`Execution reverted ${n ? `with reason: ${n}` : "for an unknown reason"}.`, { - cause: e, - name: "ExecutionRevertedError" - }); - } -} -Object.defineProperty(Xc, "code", { - enumerable: !0, - configurable: !0, - writable: !0, - value: 3 -}); -Object.defineProperty(Xc, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /execution reverted/ -}); -class Kd extends yt { - constructor({ cause: e, maxFeePerGas: r } = {}) { - super(`The fee cap (\`maxFeePerGas\`${r ? ` = ${_s(r)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, { - cause: e, - name: "FeeCapTooHighError" - }); - } -} -Object.defineProperty(Kd, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/ -}); -class Qm extends yt { - constructor({ cause: e, maxFeePerGas: r } = {}) { - super(`The fee cap (\`maxFeePerGas\`${r ? ` = ${_s(r)}` : ""} gwei) cannot be lower than the block base fee.`, { - cause: e, - name: "FeeCapTooLowError" - }); - } -} -Object.defineProperty(Qm, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/ -}); -class e1 extends yt { - constructor({ cause: e, nonce: r } = {}) { - super(`Nonce provided for the transaction ${r ? `(${r}) ` : ""}is higher than the next one expected.`, { cause: e, name: "NonceTooHighError" }); - } -} -Object.defineProperty(e1, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /nonce too high/ -}); -class t1 extends yt { - constructor({ cause: e, nonce: r } = {}) { - super([ - `Nonce provided for the transaction ${r ? `(${r}) ` : ""}is lower than the current nonce of the account.`, - "Try increasing the nonce or find the latest nonce with `getTransactionCount`." - ].join(` -`), { cause: e, name: "NonceTooLowError" }); - } -} -Object.defineProperty(t1, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /nonce too low|transaction already imported|already known/ -}); -class r1 extends yt { - constructor({ cause: e, nonce: r } = {}) { - super(`Nonce provided for the transaction ${r ? `(${r}) ` : ""}exceeds the maximum allowed nonce.`, { cause: e, name: "NonceMaxValueError" }); - } -} -Object.defineProperty(r1, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /nonce has max value/ -}); -class n1 extends yt { - constructor({ cause: e } = {}) { - super([ - "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account." - ].join(` -`), { - cause: e, - metaMessages: [ - "This error could arise when the account does not have enough funds to:", - " - pay for the total gas fee,", - " - pay for the value to send.", - " ", - "The cost of the transaction is calculated as `gas * gas fee + value`, where:", - " - `gas` is the amount of gas needed for transaction to execute,", - " - `gas fee` is the gas fee,", - " - `value` is the amount of ether to send to the recipient." - ], - name: "InsufficientFundsError" - }); - } -} -Object.defineProperty(n1, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /insufficient funds|exceeds transaction sender account balance/ -}); -class i1 extends yt { - constructor({ cause: e, gas: r } = {}) { - super(`The amount of gas ${r ? `(${r}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, { - cause: e, - name: "IntrinsicGasTooHighError" - }); - } -} -Object.defineProperty(i1, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /intrinsic gas too high|gas limit reached/ -}); -class s1 extends yt { - constructor({ cause: e, gas: r } = {}) { - super(`The amount of gas ${r ? `(${r}) ` : ""}provided for the transaction is too low.`, { - cause: e, - name: "IntrinsicGasTooLowError" - }); - } -} -Object.defineProperty(s1, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /intrinsic gas too low/ -}); -class o1 extends yt { - constructor({ cause: e }) { - super("The transaction type is not supported for this chain.", { - cause: e, - name: "TransactionTypeNotSupportedError" - }); - } -} -Object.defineProperty(o1, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /transaction type not valid/ -}); -class Vd extends yt { - constructor({ cause: e, maxPriorityFeePerGas: r, maxFeePerGas: n } = {}) { - super([ - `The provided tip (\`maxPriorityFeePerGas\`${r ? ` = ${_s(r)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n ? ` = ${_s(n)} gwei` : ""}).` - ].join(` -`), { - cause: e, - name: "TipAboveFeeCapError" - }); - } -} -Object.defineProperty(Vd, "nodeMessage", { - enumerable: !0, - configurable: !0, - writable: !0, - value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/ -}); -class Iv extends yt { - constructor({ cause: e }) { - super(`An error occurred while executing: ${e == null ? void 0 : e.shortMessage}`, { - cause: e, - name: "UnknownNodeError" - }); - } -} -function X5(t, e) { - const r = (t.details || "").toLowerCase(), n = t instanceof yt ? t.walk((i) => (i == null ? void 0 : i.code) === Xc.code) : t; - return n instanceof yt ? new Xc({ - cause: t, - message: n.details - }) : Xc.nodeMessage.test(r) ? new Xc({ - cause: t, - message: t.details - }) : Kd.nodeMessage.test(r) ? new Kd({ - cause: t, - maxFeePerGas: e == null ? void 0 : e.maxFeePerGas - }) : Qm.nodeMessage.test(r) ? new Qm({ - cause: t, - maxFeePerGas: e == null ? void 0 : e.maxFeePerGas - }) : e1.nodeMessage.test(r) ? new e1({ cause: t, nonce: e == null ? void 0 : e.nonce }) : t1.nodeMessage.test(r) ? new t1({ cause: t, nonce: e == null ? void 0 : e.nonce }) : r1.nodeMessage.test(r) ? new r1({ cause: t, nonce: e == null ? void 0 : e.nonce }) : n1.nodeMessage.test(r) ? new n1({ cause: t }) : i1.nodeMessage.test(r) ? new i1({ cause: t, gas: e == null ? void 0 : e.gas }) : s1.nodeMessage.test(r) ? new s1({ cause: t, gas: e == null ? void 0 : e.gas }) : o1.nodeMessage.test(r) ? new o1({ cause: t }) : Vd.nodeMessage.test(r) ? new Vd({ - cause: t, - maxFeePerGas: e == null ? void 0 : e.maxFeePerGas, - maxPriorityFeePerGas: e == null ? void 0 : e.maxPriorityFeePerGas - }) : new Iv({ - cause: t - }); -} -function FO(t, { docsPath: e, ...r }) { - const n = (() => { - const i = X5(t, r); - return i instanceof Iv ? t : i; - })(); - return new $O(n, { - docsPath: e, - ...r - }); -} -function Z5(t, { format: e }) { - if (!e) - return {}; - const r = {}; - function n(s) { - const o = Object.keys(s); - for (const a of o) - a in t && (r[a] = t[a]), s[a] && typeof s[a] == "object" && !Array.isArray(s[a]) && n(s[a]); - } - const i = e(t || {}); - return n(i), r; -} -const BO = { - legacy: "0x0", - eip2930: "0x1", - eip1559: "0x2", - eip4844: "0x3", - eip7702: "0x4" -}; -function Cv(t) { - const e = {}; - return typeof t.authorizationList < "u" && (e.authorizationList = UO(t.authorizationList)), typeof t.accessList < "u" && (e.accessList = t.accessList), typeof t.blobVersionedHashes < "u" && (e.blobVersionedHashes = t.blobVersionedHashes), typeof t.blobs < "u" && (typeof t.blobs[0] != "string" ? e.blobs = t.blobs.map((r) => wi(r)) : e.blobs = t.blobs), typeof t.data < "u" && (e.data = t.data), typeof t.from < "u" && (e.from = t.from), typeof t.gas < "u" && (e.gas = Mr(t.gas)), typeof t.gasPrice < "u" && (e.gasPrice = Mr(t.gasPrice)), typeof t.maxFeePerBlobGas < "u" && (e.maxFeePerBlobGas = Mr(t.maxFeePerBlobGas)), typeof t.maxFeePerGas < "u" && (e.maxFeePerGas = Mr(t.maxFeePerGas)), typeof t.maxPriorityFeePerGas < "u" && (e.maxPriorityFeePerGas = Mr(t.maxPriorityFeePerGas)), typeof t.nonce < "u" && (e.nonce = Mr(t.nonce)), typeof t.to < "u" && (e.to = t.to), typeof t.type < "u" && (e.type = BO[t.type]), typeof t.value < "u" && (e.value = Mr(t.value)), e; -} -function UO(t) { - return t.map((e) => ({ - address: e.contractAddress, - r: e.r, - s: e.s, - chainId: Mr(e.chainId), - nonce: Mr(e.nonce), - ...typeof e.yParity < "u" ? { yParity: Mr(e.yParity) } : {}, - ...typeof e.v < "u" && typeof e.yParity > "u" ? { v: Mr(e.v) } : {} - })); -} -function I2(t) { - if (!(!t || t.length === 0)) - return t.reduce((e, { slot: r, value: n }) => { - if (r.length !== 66) - throw new v2({ - size: r.length, - targetSize: 66, - type: "hex" - }); - if (n.length !== 66) - throw new v2({ - size: n.length, - targetSize: 66, - type: "hex" - }); - return e[r] = n, e; - }, {}); -} -function jO(t) { - const { balance: e, nonce: r, state: n, stateDiff: i, code: s } = t, o = {}; - if (s !== void 0 && (o.code = s), e !== void 0 && (o.balance = Mr(e)), r !== void 0 && (o.nonce = Mr(r)), n !== void 0 && (o.state = I2(n)), i !== void 0) { - if (o.state) - throw new mO(); - o.stateDiff = I2(i); - } - return o; -} -function qO(t) { - if (!t) - return; - const e = {}; - for (const { address: r, ...n } of t) { - if (!Lo(r, { strict: !1 })) - throw new bu({ address: r }); - if (e[r]) - throw new gO({ address: r }); - e[r] = jO(n); - } - return e; -} -const zO = 2n ** 256n - 1n; -function D0(t) { - const { account: e, gasPrice: r, maxFeePerGas: n, maxPriorityFeePerGas: i, to: s } = t, o = e ? jo(e) : void 0; - if (o && !Lo(o.address)) - throw new bu({ address: o.address }); - if (s && !Lo(s)) - throw new bu({ address: s }); - if (typeof r < "u" && (typeof n < "u" || typeof i < "u")) - throw new vO(); - if (n && n > zO) - throw new Kd({ maxFeePerGas: n }); - if (i && n && i > n) - throw new Vd({ maxFeePerGas: n, maxPriorityFeePerGas: i }); -} -class HO extends yt { - constructor() { - super("`baseFeeMultiplier` must be greater than 1.", { - name: "BaseFeeScalarError" - }); - } -} -class Tv extends yt { - constructor() { - super("Chain does not support EIP-1559 fees.", { - name: "Eip1559FeesNotSupportedError" - }); - } -} -class WO extends yt { - constructor({ maxPriorityFeePerGas: e }) { - super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${_s(e)} gwei).`, { name: "MaxFeePerGasTooLowError" }); - } -} -class KO extends yt { - constructor({ blockHash: e, blockNumber: r }) { - let n = "Block"; - e && (n = `Block at hash "${e}"`), r && (n = `Block at number "${r}"`), super(`${n} could not be found.`, { name: "BlockNotFoundError" }); - } -} -const VO = { - "0x0": "legacy", - "0x1": "eip2930", - "0x2": "eip1559", - "0x3": "eip4844", - "0x4": "eip7702" -}; -function GO(t) { - const e = { - ...t, - blockHash: t.blockHash ? t.blockHash : null, - blockNumber: t.blockNumber ? BigInt(t.blockNumber) : null, - chainId: t.chainId ? vu(t.chainId) : void 0, - gas: t.gas ? BigInt(t.gas) : void 0, - gasPrice: t.gasPrice ? BigInt(t.gasPrice) : void 0, - maxFeePerBlobGas: t.maxFeePerBlobGas ? BigInt(t.maxFeePerBlobGas) : void 0, - maxFeePerGas: t.maxFeePerGas ? BigInt(t.maxFeePerGas) : void 0, - maxPriorityFeePerGas: t.maxPriorityFeePerGas ? BigInt(t.maxPriorityFeePerGas) : void 0, - nonce: t.nonce ? vu(t.nonce) : void 0, - to: t.to ? t.to : null, - transactionIndex: t.transactionIndex ? Number(t.transactionIndex) : null, - type: t.type ? VO[t.type] : void 0, - typeHex: t.type ? t.type : void 0, - value: t.value ? BigInt(t.value) : void 0, - v: t.v ? BigInt(t.v) : void 0 - }; - return t.authorizationList && (e.authorizationList = YO(t.authorizationList)), e.yParity = (() => { - if (t.yParity) - return Number(t.yParity); - if (typeof e.v == "bigint") { - if (e.v === 0n || e.v === 27n) - return 0; - if (e.v === 1n || e.v === 28n) - return 1; - if (e.v >= 35n) - return e.v % 2n === 0n ? 1 : 0; - } - })(), e.type === "legacy" && (delete e.accessList, delete e.maxFeePerBlobGas, delete e.maxFeePerGas, delete e.maxPriorityFeePerGas, delete e.yParity), e.type === "eip2930" && (delete e.maxFeePerBlobGas, delete e.maxFeePerGas, delete e.maxPriorityFeePerGas), e.type === "eip1559" && delete e.maxFeePerBlobGas, e; -} -function YO(t) { - return t.map((e) => ({ - contractAddress: e.address, - chainId: Number(e.chainId), - nonce: Number(e.nonce), - r: e.r, - s: e.s, - yParity: Number(e.yParity) - })); -} -function JO(t) { - const e = (t.transactions ?? []).map((r) => typeof r == "string" ? r : GO(r)); - return { - ...t, - baseFeePerGas: t.baseFeePerGas ? BigInt(t.baseFeePerGas) : null, - blobGasUsed: t.blobGasUsed ? BigInt(t.blobGasUsed) : void 0, - difficulty: t.difficulty ? BigInt(t.difficulty) : void 0, - excessBlobGas: t.excessBlobGas ? BigInt(t.excessBlobGas) : void 0, - gasLimit: t.gasLimit ? BigInt(t.gasLimit) : void 0, - gasUsed: t.gasUsed ? BigInt(t.gasUsed) : void 0, - hash: t.hash ? t.hash : null, - logsBloom: t.logsBloom ? t.logsBloom : null, - nonce: t.nonce ? t.nonce : null, - number: t.number ? BigInt(t.number) : null, - size: t.size ? BigInt(t.size) : void 0, - timestamp: t.timestamp ? BigInt(t.timestamp) : void 0, - transactions: e, - totalDifficulty: t.totalDifficulty ? BigInt(t.totalDifficulty) : null - }; -} -async function Gd(t, { blockHash: e, blockNumber: r, blockTag: n, includeTransactions: i } = {}) { - var d, g, w; - const s = n ?? "latest", o = i ?? !1, a = r !== void 0 ? Mr(r) : void 0; - let u = null; - if (e ? u = await t.request({ - method: "eth_getBlockByHash", - params: [e, o] - }, { dedupe: !0 }) : u = await t.request({ - method: "eth_getBlockByNumber", - params: [a || s, o] - }, { dedupe: !!a }), !u) - throw new KO({ blockHash: e, blockNumber: r }); - return (((w = (g = (d = t.chain) == null ? void 0 : d.formatters) == null ? void 0 : g.block) == null ? void 0 : w.format) || JO)(u); -} -async function Q5(t) { - const e = await t.request({ - method: "eth_gasPrice" - }); - return BigInt(e); -} -async function XO(t, e) { - var s, o; - const { block: r, chain: n = t.chain, request: i } = e || {}; - try { - const a = ((s = n == null ? void 0 : n.fees) == null ? void 0 : s.maxPriorityFeePerGas) ?? ((o = n == null ? void 0 : n.fees) == null ? void 0 : o.defaultPriorityFee); - if (typeof a == "function") { - const l = r || await vi(t, Gd, "getBlock")({}), d = await a({ - block: l, - client: t, - request: i - }); - if (d === null) - throw new Error(); - return d; - } - if (typeof a < "u") - return a; - const u = await t.request({ - method: "eth_maxPriorityFeePerGas" - }); - return Qf(u); - } catch { - const [a, u] = await Promise.all([ - r ? Promise.resolve(r) : vi(t, Gd, "getBlock")({}), - vi(t, Q5, "getGasPrice")({}) - ]); - if (typeof a.baseFeePerGas != "bigint") - throw new Tv(); - const l = u - a.baseFeePerGas; - return l < 0n ? 0n : l; - } -} -async function C2(t, e) { - var w, A; - const { block: r, chain: n = t.chain, request: i, type: s = "eip1559" } = e || {}, o = await (async () => { - var M, N; - return typeof ((M = n == null ? void 0 : n.fees) == null ? void 0 : M.baseFeeMultiplier) == "function" ? n.fees.baseFeeMultiplier({ - block: r, - client: t, - request: i - }) : ((N = n == null ? void 0 : n.fees) == null ? void 0 : N.baseFeeMultiplier) ?? 1.2; - })(); - if (o < 1) - throw new HO(); - const u = 10 ** (((w = o.toString().split(".")[1]) == null ? void 0 : w.length) ?? 0), l = (M) => M * BigInt(Math.ceil(o * u)) / BigInt(u), d = r || await vi(t, Gd, "getBlock")({}); - if (typeof ((A = n == null ? void 0 : n.fees) == null ? void 0 : A.estimateFeesPerGas) == "function") { - const M = await n.fees.estimateFeesPerGas({ - block: r, - client: t, - multiply: l, - request: i, - type: s - }); - if (M !== null) - return M; - } - if (s === "eip1559") { - if (typeof d.baseFeePerGas != "bigint") - throw new Tv(); - const M = typeof (i == null ? void 0 : i.maxPriorityFeePerGas) == "bigint" ? i.maxPriorityFeePerGas : await XO(t, { - block: d, - chain: n, - request: i - }), N = l(d.baseFeePerGas); - return { - maxFeePerGas: (i == null ? void 0 : i.maxFeePerGas) ?? N + M, - maxPriorityFeePerGas: M - }; - } - return { - gasPrice: (i == null ? void 0 : i.gasPrice) ?? l(await vi(t, Q5, "getGasPrice")({})) - }; -} -async function ZO(t, { address: e, blockTag: r = "latest", blockNumber: n }) { - const i = await t.request({ - method: "eth_getTransactionCount", - params: [e, n ? Mr(n) : r] - }, { dedupe: !!n }); - return vu(i); -} -function e4(t) { - const { kzg: e } = t, r = t.to ?? (typeof t.blobs[0] == "string" ? "hex" : "bytes"), n = typeof t.blobs[0] == "string" ? t.blobs.map((s) => No(s)) : t.blobs, i = []; - for (const s of n) - i.push(Uint8Array.from(e.blobToKzgCommitment(s))); - return r === "bytes" ? i : i.map((s) => wi(s)); -} -function t4(t) { - const { kzg: e } = t, r = t.to ?? (typeof t.blobs[0] == "string" ? "hex" : "bytes"), n = typeof t.blobs[0] == "string" ? t.blobs.map((o) => No(o)) : t.blobs, i = typeof t.commitments[0] == "string" ? t.commitments.map((o) => No(o)) : t.commitments, s = []; - for (let o = 0; o < n.length; o++) { - const a = n[o], u = i[o]; - s.push(Uint8Array.from(e.computeBlobKzgProof(a, u))); - } - return r === "bytes" ? s : s.map((o) => wi(o)); -} -function QO(t, e, r, n) { - if (typeof t.setBigUint64 == "function") - return t.setBigUint64(e, r, n); - const i = BigInt(32), s = BigInt(4294967295), o = Number(r >> i & s), a = Number(r & s), u = n ? 4 : 0, l = n ? 0 : 4; - t.setUint32(e + u, o, n), t.setUint32(e + l, a, n); -} -const eN = (t, e, r) => t & e ^ ~t & r, tN = (t, e, r) => t & e ^ t & r ^ e & r; -class rN extends M5 { - constructor(e, r, n, i) { - super(), this.blockLen = e, this.outputLen = r, this.padOffset = n, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(e), this.view = Fg(this.buffer); - } - update(e) { - Hd(this); - const { view: r, buffer: n, blockLen: i } = this; - e = I0(e); - const s = e.length; - for (let o = 0; o < s; ) { - const a = Math.min(i - this.pos, s - o); - if (a === i) { - const u = Fg(e); - for (; i <= s - o; o += i) - this.process(u, o); - continue; - } - n.set(e.subarray(o, o + a), this.pos), this.pos += a, o += a, this.pos === i && (this.process(r, 0), this.pos = 0); - } - return this.length += e.length, this.roundClean(), this; - } - digestInto(e) { - Hd(this), P5(e, this), this.finished = !0; - const { buffer: r, view: n, blockLen: i, isLE: s } = this; - let { pos: o } = this; - r[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > i - o && (this.process(n, 0), o = 0); - for (let g = o; g < i; g++) - r[g] = 0; - QO(n, i - 8, BigInt(this.length * 8), s), this.process(n, 0); - const a = Fg(e), u = this.outputLen; - if (u % 4) - throw new Error("_sha2: outputLen should be aligned to 32bit"); - const l = u / 4, d = this.get(); - if (l > d.length) - throw new Error("_sha2: outputLen bigger than state"); - for (let g = 0; g < l; g++) - a.setUint32(4 * g, d[g], s); - } - digest() { - const { buffer: e, outputLen: r } = this; - this.digestInto(e); - const n = e.slice(0, r); - return this.destroy(), n; - } - _cloneInto(e) { - e || (e = new this.constructor()), e.set(...this.get()); - const { blockLen: r, buffer: n, length: i, finished: s, destroyed: o, pos: a } = this; - return e.length = i, e.pos = a, e.finished = s, e.destroyed = o, i % r && e.buffer.set(n), e; - } -} -const nN = /* @__PURE__ */ new Uint32Array([ - 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 -]), Zo = /* @__PURE__ */ new Uint32Array([ - 1779033703, - 3144134277, - 1013904242, - 2773480762, - 1359893119, - 2600822924, - 528734635, - 1541459225 -]), Qo = /* @__PURE__ */ new Uint32Array(64); -let iN = class extends rN { - constructor() { - super(64, 32, 8, !1), this.A = Zo[0] | 0, this.B = Zo[1] | 0, this.C = Zo[2] | 0, this.D = Zo[3] | 0, this.E = Zo[4] | 0, this.F = Zo[5] | 0, this.G = Zo[6] | 0, this.H = Zo[7] | 0; - } - get() { - const { A: e, B: r, C: n, D: i, E: s, F: o, G: a, H: u } = this; - return [e, r, n, i, s, o, a, u]; - } - // prettier-ignore - set(e, r, n, i, s, o, a, u) { - this.A = e | 0, this.B = r | 0, this.C = n | 0, this.D = i | 0, this.E = s | 0, this.F = o | 0, this.G = a | 0, this.H = u | 0; - } - process(e, r) { - for (let g = 0; g < 16; g++, r += 4) - Qo[g] = e.getUint32(r, !1); - for (let g = 16; g < 64; g++) { - const w = Qo[g - 15], A = Qo[g - 2], M = Os(w, 7) ^ Os(w, 18) ^ w >>> 3, N = Os(A, 17) ^ Os(A, 19) ^ A >>> 10; - Qo[g] = N + Qo[g - 7] + M + Qo[g - 16] | 0; - } - let { A: n, B: i, C: s, D: o, E: a, F: u, G: l, H: d } = this; - for (let g = 0; g < 64; g++) { - const w = Os(a, 6) ^ Os(a, 11) ^ Os(a, 25), A = d + w + eN(a, u, l) + nN[g] + Qo[g] | 0, N = (Os(n, 2) ^ Os(n, 13) ^ Os(n, 22)) + tN(n, i, s) | 0; - d = l, l = u, u = a, a = o + A | 0, o = s, s = i, i = n, n = A + N | 0; - } - n = n + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, u = u + this.F | 0, l = l + this.G | 0, d = d + this.H | 0, this.set(n, i, s, o, a, u, l, d); - } - roundClean() { - Qo.fill(0); - } - destroy() { - this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0); - } -}; -const r4 = /* @__PURE__ */ I5(() => new iN()); -function sN(t, e) { - return r4(ma(t, { strict: !1 }) ? _v(t) : t); -} -function oN(t) { - const { commitment: e, version: r = 1 } = t, n = t.to ?? (typeof e == "string" ? "hex" : "bytes"), i = sN(e); - return i.set([r], 0), n === "bytes" ? i : wi(i); -} -function aN(t) { - const { commitments: e, version: r } = t, n = t.to ?? (typeof e[0] == "string" ? "hex" : "bytes"), i = []; - for (const s of e) - i.push(oN({ - commitment: s, - to: n, - version: r - })); - return i; -} -const T2 = 6, n4 = 32, Rv = 4096, i4 = n4 * Rv, R2 = i4 * T2 - // terminator byte (0x80). -1 - // zero byte (0x00) appended to each field element. -1 * Rv * T2; -class cN extends yt { - constructor({ maxSize: e, size: r }) { - super("Blob size is too large.", { - metaMessages: [`Max: ${e} bytes`, `Given: ${r} bytes`], - name: "BlobSizeTooLargeError" - }); - } -} -class uN extends yt { - constructor() { - super("Blob data must not be empty.", { name: "EmptyBlobError" }); - } -} -function fN(t) { - const e = t.to ?? (typeof t.data == "string" ? "hex" : "bytes"), r = typeof t.data == "string" ? No(t.data) : t.data, n = An(r); - if (!n) - throw new uN(); - if (n > R2) - throw new cN({ - maxSize: R2, - size: n - }); - const i = []; - let s = !0, o = 0; - for (; s; ) { - const a = Mv(new Uint8Array(i4)); - let u = 0; - for (; u < Rv; ) { - const l = r.slice(o, o + (n4 - 1)); - if (a.pushByte(0), a.pushBytes(l), l.length < 31) { - a.pushByte(128), s = !1; - break; - } - u++, o += 31; - } - i.push(a); - } - return e === "bytes" ? i.map((a) => a.bytes) : i.map((a) => wi(a.bytes)); -} -function lN(t) { - const { data: e, kzg: r, to: n } = t, i = t.blobs ?? fN({ data: e, to: n }), s = t.commitments ?? e4({ blobs: i, kzg: r, to: n }), o = t.proofs ?? t4({ blobs: i, commitments: s, kzg: r, to: n }), a = []; - for (let u = 0; u < i.length; u++) - a.push({ - blob: i[u], - commitment: s[u], - proof: o[u] - }); - return a; -} -function hN(t) { - if (t.type) - return t.type; - if (typeof t.authorizationList < "u") - return "eip7702"; - if (typeof t.blobs < "u" || typeof t.blobVersionedHashes < "u" || typeof t.maxFeePerBlobGas < "u" || typeof t.sidecars < "u") - return "eip4844"; - if (typeof t.maxFeePerGas < "u" || typeof t.maxPriorityFeePerGas < "u") - return "eip1559"; - if (typeof t.gasPrice < "u") - return typeof t.accessList < "u" ? "eip2930" : "legacy"; - throw new bO({ transaction: t }); -} -async function O0(t) { - const e = await t.request({ - method: "eth_chainId" - }, { dedupe: !0 }); - return vu(e); -} -const s4 = [ - "blobVersionedHashes", - "chainId", - "fees", - "gas", - "nonce", - "type" -]; -async function Dv(t, e) { - const { account: r = t.account, blobs: n, chain: i, gas: s, kzg: o, nonce: a, nonceManager: u, parameters: l = s4, type: d } = e, g = r && jo(r), w = { ...e, ...g ? { from: g == null ? void 0 : g.address } : {} }; - let A; - async function M() { - return A || (A = await vi(t, Gd, "getBlock")({ blockTag: "latest" }), A); - } - let N; - async function L() { - return N || (i ? i.id : typeof e.chainId < "u" ? e.chainId : (N = await vi(t, O0, "getChainId")({}), N)); - } - if ((l.includes("blobVersionedHashes") || l.includes("sidecars")) && n && o) { - const F = e4({ blobs: n, kzg: o }); - if (l.includes("blobVersionedHashes")) { - const $ = aN({ - commitments: F, - to: "hex" - }); - w.blobVersionedHashes = $; - } - if (l.includes("sidecars")) { - const $ = t4({ blobs: n, commitments: F, kzg: o }), K = lN({ - blobs: n, - commitments: F, - proofs: $, - to: "hex" - }); - w.sidecars = K; - } - } - if (l.includes("chainId") && (w.chainId = await L()), l.includes("nonce") && typeof a > "u" && g) - if (u) { - const F = await L(); - w.nonce = await u.consume({ - address: g.address, - chainId: F, - client: t - }); - } else - w.nonce = await vi(t, ZO, "getTransactionCount")({ - address: g.address, - blockTag: "pending" - }); - if ((l.includes("fees") || l.includes("type")) && typeof d > "u") - try { - w.type = hN(w); - } catch { - const F = await M(); - w.type = typeof (F == null ? void 0 : F.baseFeePerGas) == "bigint" ? "eip1559" : "legacy"; - } - if (l.includes("fees")) - if (w.type !== "legacy" && w.type !== "eip2930") { - if (typeof w.maxFeePerGas > "u" || typeof w.maxPriorityFeePerGas > "u") { - const F = await M(), { maxFeePerGas: $, maxPriorityFeePerGas: K } = await C2(t, { - block: F, - chain: i, - request: w - }); - if (typeof e.maxPriorityFeePerGas > "u" && e.maxFeePerGas && e.maxFeePerGas < K) - throw new WO({ - maxPriorityFeePerGas: K - }); - w.maxPriorityFeePerGas = K, w.maxFeePerGas = $; - } - } else { - if (typeof e.maxFeePerGas < "u" || typeof e.maxPriorityFeePerGas < "u") - throw new Tv(); - const F = await M(), { gasPrice: $ } = await C2(t, { - block: F, - chain: i, - request: w, - type: "legacy" - }); - w.gasPrice = $; - } - return l.includes("gas") && typeof s > "u" && (w.gas = await vi(t, pN, "estimateGas")({ - ...w, - account: g && { address: g.address, type: "json-rpc" } - })), D0(w), delete w.parameters, w; -} -async function dN(t, { address: e, blockNumber: r, blockTag: n = "latest" }) { - const i = r ? Mr(r) : void 0, s = await t.request({ - method: "eth_getBalance", - params: [e, i || n] - }); - return BigInt(s); -} -async function pN(t, e) { - var i, s, o; - const { account: r = t.account } = e, n = r ? jo(r) : void 0; - try { - let f = function(b) { - const { block: x, request: _, rpcStateOverride: E } = b; - return t.request({ - method: "eth_estimateGas", - params: E ? [_, x ?? "latest", E] : x ? [_, x] : [_] - }); - }; - const { accessList: a, authorizationList: u, blobs: l, blobVersionedHashes: d, blockNumber: g, blockTag: w, data: A, gas: M, gasPrice: N, maxFeePerBlobGas: L, maxFeePerGas: F, maxPriorityFeePerGas: $, nonce: K, value: H, stateOverride: V, ...te } = await Dv(t, { - ...e, - parameters: ( - // Some RPC Providers do not compute versioned hashes from blobs. We will need - // to compute them. - (n == null ? void 0 : n.type) === "local" ? void 0 : ["blobVersionedHashes"] - ) - }), W = (g ? Mr(g) : void 0) || w, pe = qO(V), Ee = await (async () => { - if (te.to) - return te.to; - if (u && u.length > 0) - return await J5({ - authorization: u[0] - }).catch(() => { - throw new yt("`to` is required. Could not infer from `authorizationList`"); - }); - })(); - D0(e); - const Y = (o = (s = (i = t.chain) == null ? void 0 : i.formatters) == null ? void 0 : s.transactionRequest) == null ? void 0 : o.format, m = (Y || Cv)({ - // Pick out extra data that might exist on the chain's transaction request type. - ...Z5(te, { format: Y }), - from: n == null ? void 0 : n.address, - accessList: a, - authorizationList: u, - blobs: l, - blobVersionedHashes: d, - data: A, - gas: M, - gasPrice: N, - maxFeePerBlobGas: L, - maxFeePerGas: F, - maxPriorityFeePerGas: $, - nonce: K, - to: Ee, - value: H - }); - let p = BigInt(await f({ block: W, request: m, rpcStateOverride: pe })); - if (u) { - const b = await dN(t, { address: m.from }), x = await Promise.all(u.map(async (_) => { - const { contractAddress: E } = _, v = await f({ - block: W, - request: { - authorizationList: void 0, - data: A, - from: n == null ? void 0 : n.address, - to: E, - value: Mr(b) - }, - rpcStateOverride: pe - }).catch(() => 100000n); - return 2n * BigInt(v); - })); - p += x.reduce((_, E) => _ + E, 0n); - } - return p; - } catch (a) { - throw FO(a, { - ...e, - account: n, - chain: t.chain - }); - } -} -class gN extends yt { - constructor({ chain: e, currentChainId: r }) { - super(`The current chain of the wallet (id: ${r}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`, { - metaMessages: [ - `Current Chain ID: ${r}`, - `Expected Chain ID: ${e.id} – ${e.name}` - ], - name: "ChainMismatchError" - }); - } -} -class mN extends yt { - constructor() { - super([ - "No chain was provided to the request.", - "Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient." - ].join(` -`), { - name: "ChainNotFoundError" - }); - } -} -const jg = "/docs/contract/encodeDeployData"; -function vN(t) { - const { abi: e, args: r, bytecode: n } = t; - if (!r || r.length === 0) - return n; - const i = e.find((o) => "type" in o && o.type === "constructor"); - if (!i) - throw new LR({ docsPath: jg }); - if (!("inputs" in i)) - throw new g2({ docsPath: jg }); - if (!i.inputs || i.inputs.length === 0) - throw new g2({ docsPath: jg }); - const s = U5(i.inputs, r); - return T0([n, s]); -} -async function bN(t) { - return new Promise((e) => setTimeout(e, t)); -} -class Fl extends yt { - constructor({ docsPath: e } = {}) { - super([ - "Could not find an Account to execute with this Action.", - "Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client." - ].join(` -`), { - docsPath: e, - docsSlug: "account", - name: "AccountNotFoundError" - }); - } -} -class qg extends yt { - constructor({ docsPath: e, metaMessages: r, type: n }) { - super(`Account type "${n}" is not supported.`, { - docsPath: e, - metaMessages: r, - name: "AccountTypeNotSupportedError" - }); - } -} -function o4({ chain: t, currentChainId: e }) { - if (!t) - throw new mN(); - if (e !== t.id) - throw new gN({ chain: t, currentChainId: e }); -} -function yN(t, { docsPath: e, ...r }) { - const n = (() => { - const i = X5(t, r); - return i instanceof Iv ? t : i; - })(); - return new yO(n, { - docsPath: e, - ...r - }); -} -async function a4(t, { serializedTransaction: e }) { - return t.request({ - method: "eth_sendRawTransaction", - params: [e] - }, { retryCount: 0 }); -} -const zg = new C0(128); -async function Ov(t, e) { - var F, $, K, H; - const { account: r = t.account, chain: n = t.chain, accessList: i, authorizationList: s, blobs: o, data: a, gas: u, gasPrice: l, maxFeePerBlobGas: d, maxFeePerGas: g, maxPriorityFeePerGas: w, nonce: A, value: M, ...N } = e; - if (typeof r > "u") - throw new Fl({ - docsPath: "/docs/actions/wallet/sendTransaction" - }); - const L = r ? jo(r) : null; - try { - D0(e); - const V = await (async () => { - if (e.to) - return e.to; - if (s && s.length > 0) - return await J5({ - authorization: s[0] - }).catch(() => { - throw new yt("`to` is required. Could not infer from `authorizationList`."); - }); - })(); - if ((L == null ? void 0 : L.type) === "json-rpc" || L === null) { - let te; - n !== null && (te = await vi(t, O0, "getChainId")({}), o4({ - currentChainId: te, - chain: n - })); - const R = (K = ($ = (F = t.chain) == null ? void 0 : F.formatters) == null ? void 0 : $.transactionRequest) == null ? void 0 : K.format, pe = (R || Cv)({ - // Pick out extra data that might exist on the chain's transaction request type. - ...Z5(N, { format: R }), - accessList: i, - authorizationList: s, - blobs: o, - chainId: te, - data: a, - from: L == null ? void 0 : L.address, - gas: u, - gasPrice: l, - maxFeePerBlobGas: d, - maxFeePerGas: g, - maxPriorityFeePerGas: w, - nonce: A, - to: V, - value: M - }), Ee = zg.get(t.uid), Y = Ee ? "wallet_sendTransaction" : "eth_sendTransaction"; - try { - return await t.request({ - method: Y, - params: [pe] - }, { retryCount: 0 }); - } catch (S) { - if (Ee === !1) - throw S; - const m = S; - if (m.name === "InvalidInputRpcError" || m.name === "InvalidParamsRpcError" || m.name === "MethodNotFoundRpcError" || m.name === "MethodNotSupportedRpcError") - return await t.request({ - method: "wallet_sendTransaction", - params: [pe] - }, { retryCount: 0 }).then((f) => (zg.set(t.uid, !0), f)).catch((f) => { - const p = f; - throw p.name === "MethodNotFoundRpcError" || p.name === "MethodNotSupportedRpcError" ? (zg.set(t.uid, !1), m) : p; - }); - throw m; - } - } - if ((L == null ? void 0 : L.type) === "local") { - const te = await vi(t, Dv, "prepareTransactionRequest")({ - account: L, - accessList: i, - authorizationList: s, - blobs: o, - chain: n, - data: a, - gas: u, - gasPrice: l, - maxFeePerBlobGas: d, - maxFeePerGas: g, - maxPriorityFeePerGas: w, - nonce: A, - nonceManager: L.nonceManager, - parameters: [...s4, "sidecars"], - value: M, - ...N, - to: V - }), R = (H = n == null ? void 0 : n.serializers) == null ? void 0 : H.transaction, W = await L.signTransaction(te, { - serializer: R - }); - return await vi(t, a4, "sendRawTransaction")({ - serializedTransaction: W - }); - } - throw (L == null ? void 0 : L.type) === "smart" ? new qg({ - metaMessages: [ - "Consider using the `sendUserOperation` Action instead." - ], - docsPath: "/docs/actions/bundler/sendUserOperation", - type: "smart" - }) : new qg({ - docsPath: "/docs/actions/wallet/sendTransaction", - type: L == null ? void 0 : L.type - }); - } catch (V) { - throw V instanceof qg ? V : yN(V, { - ...e, - account: L, - chain: e.chain || void 0 - }); - } -} -async function wN(t, e) { - const { abi: r, account: n = t.account, address: i, args: s, dataSuffix: o, functionName: a, ...u } = e; - if (typeof n > "u") - throw new Fl({ - docsPath: "/docs/contract/writeContract" - }); - const l = n ? jo(n) : null, d = GD({ - abi: r, - args: s, - functionName: a - }); - try { - return await vi(t, Ov, "sendTransaction")({ - data: `${d}${o ? o.replace("0x", "") : ""}`, - to: i, - account: l, - ...u - }); - } catch (g) { - throw CO(g, { - abi: r, - address: i, - args: s, - docsPath: "/docs/contract/writeContract", - functionName: a, - sender: l == null ? void 0 : l.address - }); - } -} -async function xN(t, { chain: e }) { - const { id: r, name: n, nativeCurrency: i, rpcUrls: s, blockExplorers: o } = e; - await t.request({ - method: "wallet_addEthereumChain", - params: [ - { - chainId: Mr(r), - chainName: n, - nativeCurrency: i, - rpcUrls: s.default.http, - blockExplorerUrls: o ? Object.values(o).map(({ url: a }) => a) : void 0 - } - ] - }, { dedupe: !0, retryCount: 0 }); -} -const a1 = 256; -let rd = a1, nd; -function c4(t = 11) { - if (!nd || rd + t > a1 * 2) { - nd = "", rd = 0; - for (let e = 0; e < a1; e++) - nd += (256 + Math.random() * 256 | 0).toString(16).substring(1); - } - return nd.substring(rd, rd++ + t); -} -function _N(t) { - const { batch: e, cacheTime: r = t.pollingInterval ?? 4e3, ccipRead: n, key: i = "base", name: s = "Base Client", pollingInterval: o = 4e3, type: a = "base" } = t, u = t.chain, l = t.account ? jo(t.account) : void 0, { config: d, request: g, value: w } = t.transport({ - chain: u, - pollingInterval: o - }), A = { ...d, ...w }, M = { - account: l, - batch: e, - cacheTime: r, - ccipRead: n, - chain: u, - key: i, - name: s, - pollingInterval: o, - request: g, - transport: A, - type: a, - uid: c4() - }; - function N(L) { - return (F) => { - const $ = F(L); - for (const H in M) - delete $[H]; - const K = { ...L, ...$ }; - return Object.assign(K, { extend: N(K) }); - }; - } - return Object.assign(M, { extend: N(M) }); -} -const id = /* @__PURE__ */ new C0(8192); -function EN(t, { enabled: e = !0, id: r }) { - if (!e || !r) - return t(); - if (id.get(r)) - return id.get(r); - const n = t().finally(() => id.delete(r)); - return id.set(r, n), n; -} -function SN(t, { delay: e = 100, retryCount: r = 2, shouldRetry: n = () => !0 } = {}) { - return new Promise((i, s) => { - const o = async ({ count: a = 0 } = {}) => { - const u = async ({ error: l }) => { - const d = typeof e == "function" ? e({ count: a, error: l }) : e; - d && await bN(d), o({ count: a + 1 }); - }; - try { - const l = await t(); - i(l); - } catch (l) { - if (a < r && await n({ count: a, error: l })) - return u({ error: l }); - s(l); - } - }; - o(); - }); -} -function AN(t, e = {}) { - return async (r, n = {}) => { - const { dedupe: i = !1, retryDelay: s = 150, retryCount: o = 3, uid: a } = { - ...e, - ...n - }, u = i ? kl(M0(`${a}.${Tu(r)}`)) : void 0; - return EN(() => SN(async () => { - try { - return await t(r); - } catch (l) { - const d = l; - switch (d.code) { - case tl.code: - throw new tl(d); - case rl.code: - throw new rl(d); - case nl.code: - throw new nl(d, { method: r.method }); - case il.code: - throw new il(d); - case cc.code: - throw new cc(d); - case sl.code: - throw new sl(d); - case ol.code: - throw new ol(d); - case al.code: - throw new al(d); - case cl.code: - throw new cl(d); - case ul.code: - throw new ul(d, { - method: r.method - }); - case wu.code: - throw new wu(d); - case fl.code: - throw new fl(d); - case au.code: - throw new au(d); - case ll.code: - throw new ll(d); - case hl.code: - throw new hl(d); - case dl.code: - throw new dl(d); - case pl.code: - throw new pl(d); - case gl.code: - throw new gl(d); - case 5e3: - throw new au(d); - default: - throw l instanceof yt ? l : new MO(d); - } - } - }, { - delay: ({ count: l, error: d }) => { - var g; - if (d && d instanceof V5) { - const w = (g = d == null ? void 0 : d.headers) == null ? void 0 : g.get("Retry-After"); - if (w != null && w.match(/\d/)) - return Number.parseInt(w) * 1e3; - } - return ~~(1 << l) * s; - }, - retryCount: o, - shouldRetry: ({ error: l }) => PN(l) - }), { enabled: i, id: u }); - }; -} -function PN(t) { - return "code" in t && typeof t.code == "number" ? t.code === -1 || t.code === wu.code || t.code === cc.code : t instanceof V5 && t.status ? t.status === 403 || t.status === 408 || t.status === 413 || t.status === 429 || t.status === 500 || t.status === 502 || t.status === 503 || t.status === 504 : !0; -} -function MN({ key: t, name: e, request: r, retryCount: n = 3, retryDelay: i = 150, timeout: s, type: o }, a) { - const u = c4(); - return { - config: { - key: t, - name: e, - request: r, - retryCount: n, - retryDelay: i, - timeout: s, - type: o - }, - request: AN(r, { retryCount: n, retryDelay: i, uid: u }), - value: a - }; -} -function IN(t, e = {}) { - const { key: r = "custom", name: n = "Custom Provider", retryDelay: i } = e; - return ({ retryCount: s }) => MN({ - key: r, - name: n, - request: t.request.bind(t), - retryCount: e.retryCount ?? s, - retryDelay: i, - type: "custom" - }); -} -const CN = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, TN = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/; -class RN extends yt { - constructor({ domain: e }) { - super(`Invalid domain "${Tu(e)}".`, { - metaMessages: ["Must be a valid EIP-712 domain."] - }); - } -} -class DN extends yt { - constructor({ primaryType: e, types: r }) { - super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(r))}\`.`, { - docsPath: "/api/glossary/Errors#typeddatainvalidprimarytypeerror", - metaMessages: ["Check that the primary type is a key in `types`."] - }); - } -} -class ON extends yt { - constructor({ type: e }) { - super(`Struct type "${e}" is invalid.`, { - metaMessages: ["Struct type must not be a Solidity type."], - name: "InvalidStructTypeError" - }); - } -} -function NN(t) { - const { domain: e, message: r, primaryType: n, types: i } = t, s = (u, l) => { - const d = { ...l }; - for (const g of u) { - const { name: w, type: A } = g; - A === "address" && (d[w] = d[w].toLowerCase()); - } - return d; - }, o = i.EIP712Domain ? e ? s(i.EIP712Domain, e) : {} : {}, a = (() => { - if (n !== "EIP712Domain") - return s(i[n], r); - })(); - return Tu({ domain: o, message: a, primaryType: n, types: i }); -} -function LN(t) { - const { domain: e, message: r, primaryType: n, types: i } = t, s = (o, a) => { - for (const u of o) { - const { name: l, type: d } = u, g = a[l], w = d.match(TN); - if (w && (typeof g == "number" || typeof g == "bigint")) { - const [N, L, F] = w; - Mr(g, { - signed: L === "int", - size: Number.parseInt(F) / 8 - }); - } - if (d === "address" && typeof g == "string" && !Lo(g)) - throw new bu({ address: g }); - const A = d.match(CN); - if (A) { - const [N, L] = A; - if (L && An(g) !== Number.parseInt(L)) - throw new jR({ - expectedSize: Number.parseInt(L), - givenSize: An(g) - }); - } - const M = i[d]; - M && ($N(d), s(M, g)); - } - }; - if (i.EIP712Domain && e) { - if (typeof e != "object") - throw new RN({ domain: e }); - s(i.EIP712Domain, e); - } - if (n !== "EIP712Domain") - if (i[n]) - s(i[n], r); - else - throw new DN({ primaryType: n, types: i }); -} -function kN({ domain: t }) { - return [ - typeof (t == null ? void 0 : t.name) == "string" && { name: "name", type: "string" }, - (t == null ? void 0 : t.version) && { name: "version", type: "string" }, - typeof (t == null ? void 0 : t.chainId) == "number" && { - name: "chainId", - type: "uint256" - }, - (t == null ? void 0 : t.verifyingContract) && { - name: "verifyingContract", - type: "address" - }, - (t == null ? void 0 : t.salt) && { name: "salt", type: "bytes32" } - ].filter(Boolean); -} -function $N(t) { - if (t === "address" || t === "bool" || t === "string" || t.startsWith("bytes") || t.startsWith("uint") || t.startsWith("int")) - throw new ON({ type: t }); -} -function FN(t, e) { - const { abi: r, args: n, bytecode: i, ...s } = e, o = vN({ abi: r, args: n, bytecode: i }); - return Ov(t, { - ...s, - data: o - }); -} -async function BN(t) { - var r; - return ((r = t.account) == null ? void 0 : r.type) === "local" ? [t.account.address] : (await t.request({ method: "eth_accounts" }, { dedupe: !0 })).map((n) => $l(n)); -} -async function UN(t) { - return await t.request({ method: "wallet_getPermissions" }, { dedupe: !0 }); -} -async function jN(t) { - return (await t.request({ method: "eth_requestAccounts" }, { dedupe: !0, retryCount: 0 })).map((r) => k5(r)); -} -async function qN(t, e) { - return t.request({ - method: "wallet_requestPermissions", - params: [e] - }, { retryCount: 0 }); -} -async function zN(t, { account: e = t.account, message: r }) { - if (!e) - throw new Fl({ - docsPath: "/docs/actions/wallet/signMessage" - }); - const n = jo(e); - if (n.signMessage) - return n.signMessage({ message: r }); - const i = typeof r == "string" ? M0(r) : r.raw instanceof Uint8Array ? qd(r.raw) : r.raw; - return t.request({ - method: "personal_sign", - params: [i, n.address] - }, { retryCount: 0 }); -} -async function HN(t, e) { - var l, d, g, w; - const { account: r = t.account, chain: n = t.chain, ...i } = e; - if (!r) - throw new Fl({ - docsPath: "/docs/actions/wallet/signTransaction" - }); - const s = jo(r); - D0({ - account: s, - ...e - }); - const o = await vi(t, O0, "getChainId")({}); - n !== null && o4({ - currentChainId: o, - chain: n - }); - const a = (n == null ? void 0 : n.formatters) || ((l = t.chain) == null ? void 0 : l.formatters), u = ((d = a == null ? void 0 : a.transactionRequest) == null ? void 0 : d.format) || Cv; - return s.signTransaction ? s.signTransaction({ - ...i, - chainId: o - }, { serializer: (w = (g = t.chain) == null ? void 0 : g.serializers) == null ? void 0 : w.transaction }) : await t.request({ - method: "eth_signTransaction", - params: [ - { - ...u(i), - chainId: Mr(o), - from: s.address - } - ] - }, { retryCount: 0 }); -} -async function WN(t, e) { - const { account: r = t.account, domain: n, message: i, primaryType: s } = e; - if (!r) - throw new Fl({ - docsPath: "/docs/actions/wallet/signTypedData" - }); - const o = jo(r), a = { - EIP712Domain: kN({ domain: n }), - ...e.types - }; - if (LN({ domain: n, message: i, primaryType: s, types: a }), o.signTypedData) - return o.signTypedData({ domain: n, message: i, primaryType: s, types: a }); - const u = NN({ domain: n, message: i, primaryType: s, types: a }); - return t.request({ - method: "eth_signTypedData_v4", - params: [o.address, u] - }, { retryCount: 0 }); -} -async function KN(t, { id: e }) { - await t.request({ - method: "wallet_switchEthereumChain", - params: [ - { - chainId: Mr(e) - } - ] - }, { retryCount: 0 }); -} -async function VN(t, e) { - return await t.request({ - method: "wallet_watchAsset", - params: e - }, { retryCount: 0 }); -} -function GN(t) { - return { - addChain: (e) => xN(t, e), - deployContract: (e) => FN(t, e), - getAddresses: () => BN(t), - getChainId: () => O0(t), - getPermissions: () => UN(t), - prepareTransactionRequest: (e) => Dv(t, e), - requestAddresses: () => jN(t), - requestPermissions: (e) => qN(t, e), - sendRawTransaction: (e) => a4(t, e), - sendTransaction: (e) => Ov(t, e), - signMessage: (e) => zN(t, e), - signTransaction: (e) => HN(t, e), - signTypedData: (e) => WN(t, e), - switchChain: (e) => KN(t, e), - watchAsset: (e) => VN(t, e), - writeContract: (e) => wN(t, e) - }; -} -function YN(t) { - const { key: e = "wallet", name: r = "Wallet Client", transport: n } = t; - return _N({ - ...t, - key: e, - name: r, - transport: n, - type: "walletClient" - }).extend(GN); -} -class ml { - constructor(e) { - Rs(this, "_key"); - Rs(this, "_config", null); - Rs(this, "_provider", null); - Rs(this, "_connected", !1); - Rs(this, "_address", null); - Rs(this, "_fatured", !1); - Rs(this, "_installed", !1); - Rs(this, "lastUsed", !1); - var r; - if ("name" in e && "image" in e) - this._key = e.name, this._config = e, this._fatured = e.featured; - else if ("session" in e) { - if (!e.session) throw new Error("session is null"); - this._key = (r = e.session) == null ? void 0 : r.peer.metadata.name, this._provider = e, this._config = { - name: e.session.peer.metadata.name, - image: e.session.peer.metadata.icons[0], - featured: !1 - }; - } else if ("info" in e) - console.log(e.info, "installed"), this._key = e.info.name, this._provider = e.provider, this._installed = !0, this._config = { - name: e.info.name, - image: e.info.icon, - featured: !1 - }, this.testConnect(); - else - throw new Error("unknown params"); - } - get address() { - return this._address; - } - get connected() { - return this._connected; - } - get featured() { - return this._fatured; - } - get key() { - return this._key; - } - get installed() { - return this._installed; - } - get client() { - return this._provider ? YN({ transport: IN(this._provider) }) : null; - } - get config() { - return this._config; - } - static fromWalletConfig(e) { - return new ml(e); - } - EIP6963Detected(e) { - this._provider = e.provider, this._installed = !0, this._provider.on("disconnect", this.disconnect), this._provider.on("accountsChanged", (r) => { - this._address = r[0], this._connected = !0; - }), this.testConnect(); - } - setUniversalProvider(e) { - this._provider = e, this.testConnect(); - } - async testConnect() { - var r; - const e = await ((r = this.client) == null ? void 0 : r.getAddresses()); - e && e.length > 0 ? (this._address = e[0], this._connected = !0) : (this._address = null, this._connected = !1); - } - async connect() { - var r; - const e = await ((r = this.client) == null ? void 0 : r.request({ method: "eth_requestAccounts", params: void 0 })); - if (!e) throw new Error("connect failed"); - return e; - } - async getAddress() { - var r; - const e = await ((r = this.client) == null ? void 0 : r.getAddresses()); - if (!e) throw new Error("get address failed"); - return e[0]; - } - async getChain() { - var r; - const e = await ((r = this.client) == null ? void 0 : r.getChainId()); - if (!e) throw new Error("get chain failed"); - return e; - } - async signMessage(e, r) { - var i; - return await ((i = this.client) == null ? void 0 : i.signMessage({ message: e, account: r })); - } - async disconnect() { - this._provider && "session" in this._provider && await this._provider.disconnect(), this._connected = !1, this._address = null; - } -} -var Nv = { exports: {} }, cu = typeof Reflect == "object" ? Reflect : null, D2 = cu && typeof cu.apply == "function" ? cu.apply : function(e, r, n) { - return Function.prototype.apply.call(e, r, n); -}, wd; -cu && typeof cu.ownKeys == "function" ? wd = cu.ownKeys : Object.getOwnPropertySymbols ? wd = function(e) { - return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e)); -} : wd = function(e) { - return Object.getOwnPropertyNames(e); -}; -function JN(t) { - console && console.warn && console.warn(t); -} -var u4 = Number.isNaN || function(e) { - return e !== e; -}; -function kr() { - kr.init.call(this); -} -Nv.exports = kr; -Nv.exports.once = eL; -kr.EventEmitter = kr; -kr.prototype._events = void 0; -kr.prototype._eventsCount = 0; -kr.prototype._maxListeners = void 0; -var O2 = 10; -function N0(t) { - if (typeof t != "function") - throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof t); -} -Object.defineProperty(kr, "defaultMaxListeners", { - enumerable: !0, - get: function() { - return O2; - }, - set: function(t) { - if (typeof t != "number" || t < 0 || u4(t)) - throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + t + "."); - O2 = t; - } -}); -kr.init = function() { - (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0; -}; -kr.prototype.setMaxListeners = function(e) { - if (typeof e != "number" || e < 0 || u4(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 f4(t) { - return t._maxListeners === void 0 ? kr.defaultMaxListeners : t._maxListeners; -} -kr.prototype.getMaxListeners = function() { - return f4(this); -}; -kr.prototype.emit = function(e) { - for (var r = [], n = 1; n < arguments.length; n++) r.push(arguments[n]); - var i = e === "error", s = this._events; - if (s !== void 0) - i = i && s.error === void 0; - else if (!i) - return !1; - if (i) { - var o; - if (r.length > 0 && (o = r[0]), o instanceof Error) - throw o; - var a = new Error("Unhandled error." + (o ? " (" + o.message + ")" : "")); - throw a.context = o, a; - } - var u = s[e]; - if (u === void 0) - return !1; - if (typeof u == "function") - D2(u, this, r); - else - for (var l = u.length, d = g4(u, l), n = 0; n < l; ++n) - D2(d[n], this, r); - return !0; -}; -function l4(t, e, r, n) { - var i, s, o; - if (N0(r), s = t._events, s === void 0 ? (s = t._events = /* @__PURE__ */ Object.create(null), t._eventsCount = 0) : (s.newListener !== void 0 && (t.emit( - "newListener", - e, - r.listener ? r.listener : r - ), s = t._events), o = s[e]), o === void 0) - o = s[e] = r, ++t._eventsCount; - else if (typeof o == "function" ? o = s[e] = n ? [r, o] : [o, r] : n ? o.unshift(r) : o.push(r), i = f4(t), i > 0 && o.length > i && !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 = t, a.type = e, a.count = o.length, JN(a); - } - return t; -} -kr.prototype.addListener = function(e, r) { - return l4(this, e, r, !1); -}; -kr.prototype.on = kr.prototype.addListener; -kr.prototype.prependListener = function(e, r) { - return l4(this, e, r, !0); -}; -function XN() { - 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 h4(t, e, r) { - var n = { fired: !1, wrapFn: void 0, target: t, type: e, listener: r }, i = XN.bind(n); - return i.listener = r, n.wrapFn = i, i; -} -kr.prototype.once = function(e, r) { - return N0(r), this.on(e, h4(this, e, r)), this; -}; -kr.prototype.prependOnceListener = function(e, r) { - return N0(r), this.prependListener(e, h4(this, e, r)), this; -}; -kr.prototype.removeListener = function(e, r) { - var n, i, s, o, a; - if (N0(r), i = this._events, i === void 0) - return this; - if (n = i[e], n === void 0) - return this; - if (n === r || n.listener === r) - --this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete i[e], i.removeListener && this.emit("removeListener", e, n.listener || r)); - else if (typeof n != "function") { - for (s = -1, o = n.length - 1; o >= 0; o--) - if (n[o] === r || n[o].listener === r) { - a = n[o].listener, s = o; - break; - } - if (s < 0) - return this; - s === 0 ? n.shift() : ZN(n, s), n.length === 1 && (i[e] = n[0]), i.removeListener !== void 0 && this.emit("removeListener", e, a || r); - } - return this; -}; -kr.prototype.off = kr.prototype.removeListener; -kr.prototype.removeAllListeners = function(e) { - var r, n, i; - if (n = this._events, n === void 0) - return this; - if (n.removeListener === void 0) - return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : n[e] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete n[e]), this; - if (arguments.length === 0) { - var s = Object.keys(n), o; - for (i = 0; i < s.length; ++i) - o = s[i], o !== "removeListener" && this.removeAllListeners(o); - return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this; - } - if (r = n[e], typeof r == "function") - this.removeListener(e, r); - else if (r !== void 0) - for (i = r.length - 1; i >= 0; i--) - this.removeListener(e, r[i]); - return this; -}; -function d4(t, e, r) { - var n = t._events; - if (n === void 0) - return []; - var i = n[e]; - return i === void 0 ? [] : typeof i == "function" ? r ? [i.listener || i] : [i] : r ? QN(i) : g4(i, i.length); -} -kr.prototype.listeners = function(e) { - return d4(this, e, !0); -}; -kr.prototype.rawListeners = function(e) { - return d4(this, e, !1); -}; -kr.listenerCount = function(t, e) { - return typeof t.listenerCount == "function" ? t.listenerCount(e) : p4.call(t, e); -}; -kr.prototype.listenerCount = p4; -function p4(t) { - var e = this._events; - if (e !== void 0) { - var r = e[t]; - if (typeof r == "function") - return 1; - if (r !== void 0) - return r.length; - } - return 0; -} -kr.prototype.eventNames = function() { - return this._eventsCount > 0 ? wd(this._events) : []; -}; -function g4(t, e) { - for (var r = new Array(e), n = 0; n < e; ++n) - r[n] = t[n]; - return r; -} -function ZN(t, e) { - for (; e + 1 < t.length; e++) - t[e] = t[e + 1]; - t.pop(); -} -function QN(t) { - for (var e = new Array(t.length), r = 0; r < e.length; ++r) - e[r] = t[r].listener || t[r]; - return e; -} -function eL(t, e) { - return new Promise(function(r, n) { - function i(o) { - t.removeListener(e, s), n(o); - } - function s() { - typeof t.removeListener == "function" && t.removeListener("error", i), r([].slice.call(arguments)); - } - m4(t, e, s, { once: !0 }), e !== "error" && tL(t, i, { once: !0 }); - }); -} -function tL(t, e, r) { - typeof t.on == "function" && m4(t, "error", e, r); -} -function m4(t, e, r, n) { - if (typeof t.on == "function") - n.once ? t.once(e, r) : t.on(e, r); - else if (typeof t.addEventListener == "function") - t.addEventListener(e, function i(s) { - n.once && t.removeEventListener(e, i), r(s); - }); - else - throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof t); -} -var rs = Nv.exports; -const Lv = /* @__PURE__ */ ts(rs); -var mt = {}; -/*! ***************************************************************************** -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. -***************************************************************************** */ -var c1 = function(t, e) { - return c1 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) { - r.__proto__ = n; - } || function(r, n) { - for (var i in n) n.hasOwnProperty(i) && (r[i] = n[i]); - }, c1(t, e); -}; -function rL(t, e) { - c1(t, e); - function r() { - this.constructor = t; - } - t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r()); -} -var u1 = function() { - return u1 = Object.assign || function(e) { - for (var r, n = 1, i = arguments.length; n < i; n++) { - r = arguments[n]; - for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]); - } - return e; - }, u1.apply(this, arguments); -}; -function nL(t, e) { - var r = {}; - for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); - if (t != null && typeof Object.getOwnPropertySymbols == "function") - for (var i = 0, n = Object.getOwnPropertySymbols(t); i < n.length; i++) - e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[i]) && (r[n[i]] = t[n[i]]); - return r; -} -function iL(t, e, r, n) { - var i = arguments.length, s = i < 3 ? e : n === null ? n = Object.getOwnPropertyDescriptor(e, r) : n, o; - if (typeof Reflect == "object" && typeof Reflect.decorate == "function") s = Reflect.decorate(t, e, r, n); - else for (var a = t.length - 1; a >= 0; a--) (o = t[a]) && (s = (i < 3 ? o(s) : i > 3 ? o(e, r, s) : o(e, r)) || s); - return i > 3 && s && Object.defineProperty(e, r, s), s; -} -function sL(t, e) { - return function(r, n) { - e(r, n, t); - }; -} -function oL(t, e) { - if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(t, e); -} -function aL(t, e, r, n) { - function i(s) { - return s instanceof r ? s : new r(function(o) { - o(s); - }); - } - return new (r || (r = Promise))(function(s, o) { - function a(d) { - try { - l(n.next(d)); - } catch (g) { - o(g); - } - } - function u(d) { - try { - l(n.throw(d)); - } catch (g) { - o(g); - } - } - function l(d) { - d.done ? s(d.value) : i(d.value).then(a, u); - } - l((n = n.apply(t, e || [])).next()); - }); -} -function cL(t, e) { - var r = { label: 0, sent: function() { - if (s[0] & 1) throw s[1]; - return s[1]; - }, trys: [], ops: [] }, n, i, 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(l) { - return function(d) { - return u([l, d]); - }; - } - function u(l) { - if (n) throw new TypeError("Generator is already executing."); - for (; r; ) try { - if (n = 1, i && (s = l[0] & 2 ? i.return : l[0] ? i.throw || ((s = i.return) && s.call(i), 0) : i.next) && !(s = s.call(i, l[1])).done) return s; - switch (i = 0, s && (l = [l[0] & 2, s.value]), l[0]) { - case 0: - case 1: - s = l; - break; - case 4: - return r.label++, { value: l[1], done: !1 }; - case 5: - r.label++, i = l[1], l = [0]; - continue; - case 7: - l = r.ops.pop(), r.trys.pop(); - continue; - default: - if (s = r.trys, !(s = s.length > 0 && s[s.length - 1]) && (l[0] === 6 || l[0] === 2)) { - r = 0; - continue; - } - if (l[0] === 3 && (!s || l[1] > s[0] && l[1] < s[3])) { - r.label = l[1]; - break; - } - if (l[0] === 6 && r.label < s[1]) { - r.label = s[1], s = l; - break; - } - if (s && r.label < s[2]) { - r.label = s[2], r.ops.push(l); - break; - } - s[2] && r.ops.pop(), r.trys.pop(); - continue; - } - l = e.call(t, r); - } catch (d) { - l = [6, d], i = 0; - } finally { - n = s = 0; - } - if (l[0] & 5) throw l[1]; - return { value: l[0] ? l[1] : void 0, done: !0 }; - } -} -function uL(t, e, r, n) { - n === void 0 && (n = r), t[n] = e[r]; -} -function fL(t, e) { - for (var r in t) r !== "default" && !e.hasOwnProperty(r) && (e[r] = t[r]); -} -function f1(t) { - var e = typeof Symbol == "function" && Symbol.iterator, r = e && t[e], n = 0; - if (r) return r.call(t); - if (t && typeof t.length == "number") return { - next: function() { - return t && n >= t.length && (t = void 0), { value: t && t[n++], done: !t }; - } - }; - throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined."); -} -function v4(t, e) { - var r = typeof Symbol == "function" && t[Symbol.iterator]; - if (!r) return t; - var n = r.call(t), i, s = [], o; - try { - for (; (e === void 0 || e-- > 0) && !(i = n.next()).done; ) s.push(i.value); - } catch (a) { - o = { error: a }; - } finally { - try { - i && !i.done && (r = n.return) && r.call(n); - } finally { - if (o) throw o.error; - } - } - return s; -} -function lL() { - for (var t = [], e = 0; e < arguments.length; e++) - t = t.concat(v4(arguments[e])); - return t; -} -function hL() { - for (var t = 0, e = 0, r = arguments.length; e < r; e++) t += arguments[e].length; - for (var n = Array(t), i = 0, e = 0; e < r; e++) - for (var s = arguments[e], o = 0, a = s.length; o < a; o++, i++) - n[i] = s[o]; - return n; -} -function vl(t) { - return this instanceof vl ? (this.v = t, this) : new vl(t); -} -function dL(t, e, r) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var n = r.apply(t, e || []), i, s = []; - return i = {}, o("next"), o("throw"), o("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i; - function o(w) { - n[w] && (i[w] = function(A) { - return new Promise(function(M, N) { - s.push([w, A, M, N]) > 1 || a(w, A); - }); - }); - } - function a(w, A) { - try { - u(n[w](A)); - } catch (M) { - g(s[0][3], M); - } - } - function u(w) { - w.value instanceof vl ? Promise.resolve(w.value.v).then(l, d) : g(s[0][2], w); - } - function l(w) { - a("next", w); - } - function d(w) { - a("throw", w); - } - function g(w, A) { - w(A), s.shift(), s.length && a(s[0][0], s[0][1]); - } -} -function pL(t) { - var e, r; - return e = {}, n("next"), n("throw", function(i) { - throw i; - }), n("return"), e[Symbol.iterator] = function() { - return this; - }, e; - function n(i, s) { - e[i] = t[i] ? function(o) { - return (r = !r) ? { value: vl(t[i](o)), done: i === "return" } : s ? s(o) : o; - } : s; - } -} -function gL(t) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var e = t[Symbol.asyncIterator], r; - return e ? e.call(t) : (t = typeof f1 == "function" ? f1(t) : t[Symbol.iterator](), r = {}, n("next"), n("throw"), n("return"), r[Symbol.asyncIterator] = function() { - return this; - }, r); - function n(s) { - r[s] = t[s] && function(o) { - return new Promise(function(a, u) { - o = t[s](o), i(a, u, o.done, o.value); - }); - }; - } - function i(s, o, a, u) { - Promise.resolve(u).then(function(l) { - s({ value: l, done: a }); - }, o); - } -} -function mL(t, e) { - return Object.defineProperty ? Object.defineProperty(t, "raw", { value: e }) : t.raw = e, t; -} -function vL(t) { - if (t && t.__esModule) return t; - var e = {}; - if (t != null) for (var r in t) Object.hasOwnProperty.call(t, r) && (e[r] = t[r]); - return e.default = t, e; -} -function bL(t) { - return t && t.__esModule ? t : { default: t }; -} -function yL(t, e) { - if (!e.has(t)) - throw new TypeError("attempted to get private field on non-instance"); - return e.get(t); -} -function wL(t, e, r) { - if (!e.has(t)) - throw new TypeError("attempted to set private field on non-instance"); - return e.set(t, r), r; -} -const xL = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - get __assign() { - return u1; - }, - __asyncDelegator: pL, - __asyncGenerator: dL, - __asyncValues: gL, - __await: vl, - __awaiter: aL, - __classPrivateFieldGet: yL, - __classPrivateFieldSet: wL, - __createBinding: uL, - __decorate: iL, - __exportStar: fL, - __extends: rL, - __generator: cL, - __importDefault: bL, - __importStar: vL, - __makeTemplateObject: mL, - __metadata: oL, - __param: sL, - __read: v4, - __rest: nL, - __spread: lL, - __spreadArrays: hL, - __values: f1 -}, Symbol.toStringTag, { value: "Module" })), Bl = /* @__PURE__ */ bv(xL); -var Hg = {}, yf = {}, N2; -function _L() { - if (N2) return yf; - N2 = 1, Object.defineProperty(yf, "__esModule", { value: !0 }), yf.delay = void 0; - function t(e) { - return new Promise((r) => { - setTimeout(() => { - r(!0); - }, e); - }); - } - return yf.delay = t, yf; -} -var ja = {}, Wg = {}, qa = {}, L2; -function EL() { - return L2 || (L2 = 1, Object.defineProperty(qa, "__esModule", { value: !0 }), qa.ONE_THOUSAND = qa.ONE_HUNDRED = void 0, qa.ONE_HUNDRED = 100, qa.ONE_THOUSAND = 1e3), qa; -} -var Kg = {}, k2; -function SL() { - return k2 || (k2 = 1, function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }), t.ONE_YEAR = t.FOUR_WEEKS = t.THREE_WEEKS = t.TWO_WEEKS = t.ONE_WEEK = t.THIRTY_DAYS = t.SEVEN_DAYS = t.FIVE_DAYS = t.THREE_DAYS = t.ONE_DAY = t.TWENTY_FOUR_HOURS = t.TWELVE_HOURS = t.SIX_HOURS = t.THREE_HOURS = t.ONE_HOUR = t.SIXTY_MINUTES = t.THIRTY_MINUTES = t.TEN_MINUTES = t.FIVE_MINUTES = t.ONE_MINUTE = t.SIXTY_SECONDS = t.THIRTY_SECONDS = t.TEN_SECONDS = t.FIVE_SECONDS = t.ONE_SECOND = void 0, t.ONE_SECOND = 1, t.FIVE_SECONDS = 5, t.TEN_SECONDS = 10, t.THIRTY_SECONDS = 30, t.SIXTY_SECONDS = 60, t.ONE_MINUTE = t.SIXTY_SECONDS, t.FIVE_MINUTES = t.ONE_MINUTE * 5, t.TEN_MINUTES = t.ONE_MINUTE * 10, t.THIRTY_MINUTES = t.ONE_MINUTE * 30, t.SIXTY_MINUTES = t.ONE_MINUTE * 60, t.ONE_HOUR = t.SIXTY_MINUTES, t.THREE_HOURS = t.ONE_HOUR * 3, t.SIX_HOURS = t.ONE_HOUR * 6, t.TWELVE_HOURS = t.ONE_HOUR * 12, t.TWENTY_FOUR_HOURS = t.ONE_HOUR * 24, t.ONE_DAY = t.TWENTY_FOUR_HOURS, t.THREE_DAYS = t.ONE_DAY * 3, t.FIVE_DAYS = t.ONE_DAY * 5, t.SEVEN_DAYS = t.ONE_DAY * 7, t.THIRTY_DAYS = t.ONE_DAY * 30, t.ONE_WEEK = t.SEVEN_DAYS, t.TWO_WEEKS = t.ONE_WEEK * 2, t.THREE_WEEKS = t.ONE_WEEK * 3, t.FOUR_WEEKS = t.ONE_WEEK * 4, t.ONE_YEAR = t.ONE_DAY * 365; - }(Kg)), Kg; -} -var $2; -function b4() { - return $2 || ($2 = 1, function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }); - const e = Bl; - e.__exportStar(EL(), t), e.__exportStar(SL(), t); - }(Wg)), Wg; -} -var F2; -function AL() { - if (F2) return ja; - F2 = 1, Object.defineProperty(ja, "__esModule", { value: !0 }), ja.fromMiliseconds = ja.toMiliseconds = void 0; - const t = b4(); - function e(n) { - return n * t.ONE_THOUSAND; - } - ja.toMiliseconds = e; - function r(n) { - return Math.floor(n / t.ONE_THOUSAND); - } - return ja.fromMiliseconds = r, ja; -} -var B2; -function PL() { - return B2 || (B2 = 1, function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }); - const e = Bl; - e.__exportStar(_L(), t), e.__exportStar(AL(), t); - }(Hg)), Hg; -} -var qc = {}, U2; -function ML() { - if (U2) return qc; - U2 = 1, Object.defineProperty(qc, "__esModule", { value: !0 }), qc.Watch = void 0; - class t { - constructor() { - this.timestamps = /* @__PURE__ */ new Map(); - } - start(r) { - if (this.timestamps.has(r)) - throw new Error(`Watch already started for label: ${r}`); - this.timestamps.set(r, { started: Date.now() }); - } - stop(r) { - const n = this.get(r); - if (typeof n.elapsed < "u") - throw new Error(`Watch already stopped for label: ${r}`); - const i = Date.now() - n.started; - this.timestamps.set(r, { started: n.started, elapsed: i }); - } - get(r) { - const n = this.timestamps.get(r); - if (typeof n > "u") - throw new Error(`No timestamp found for label: ${r}`); - return n; - } - elapsed(r) { - const n = this.get(r); - return n.elapsed || Date.now() - n.started; - } - } - return qc.Watch = t, qc.default = t, qc; -} -var Vg = {}, wf = {}, j2; -function IL() { - if (j2) return wf; - j2 = 1, Object.defineProperty(wf, "__esModule", { value: !0 }), wf.IWatch = void 0; - class t { - } - return wf.IWatch = t, wf; -} -var q2; -function CL() { - return q2 || (q2 = 1, function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }), Bl.__exportStar(IL(), t); - }(Vg)), Vg; -} -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }); - const e = Bl; - e.__exportStar(PL(), t), e.__exportStar(ML(), t), e.__exportStar(CL(), t), e.__exportStar(b4(), t); -})(mt); -class mc { -} -let TL = class extends mc { - constructor(e) { - super(); - } -}; -const z2 = mt.FIVE_SECONDS, Du = { pulse: "heartbeat_pulse" }; -let RL = class y4 extends TL { - constructor(e) { - super(e), this.events = new rs.EventEmitter(), this.interval = z2, this.interval = (e == null ? void 0 : e.interval) || z2; - } - static async init(e) { - const r = new y4(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(), mt.toMiliseconds(this.interval)); - } - pulse() { - this.events.emit(Du.pulse); - } -}; -const DL = /"(?:_|\\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*:/, OL = /"(?: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*:/, NL = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/; -function LL(t, e) { - if (t === "__proto__" || t === "constructor" && e && typeof e == "object" && "prototype" in e) { - kL(t); - return; - } - return e; -} -function kL(t) { - console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`); -} -function sd(t, e = {}) { - if (typeof t != "string") - return t; - const r = t.trim(); - if ( - // eslint-disable-next-line unicorn/prefer-at - t[0] === '"' && t.endsWith('"') && !t.includes("\\") - ) - return r.slice(1, -1); - if (r.length <= 9) { - const n = r.toLowerCase(); - if (n === "true") - return !0; - if (n === "false") - return !1; - if (n === "undefined") - return; - if (n === "null") - return null; - if (n === "nan") - return Number.NaN; - if (n === "infinity") - return Number.POSITIVE_INFINITY; - if (n === "-infinity") - return Number.NEGATIVE_INFINITY; - } - if (!NL.test(t)) { - if (e.strict) - throw new SyntaxError("[destr] Invalid JSON"); - return t; - } - try { - if (DL.test(t) || OL.test(t)) { - if (e.strict) - throw new Error("[destr] Possible prototype pollution"); - return JSON.parse(t, LL); - } - return JSON.parse(t); - } catch (n) { - if (e.strict) - throw n; - return t; - } -} -function $L(t) { - return !t || typeof t.then != "function" ? Promise.resolve(t) : t; -} -function Cn(t, ...e) { - try { - return $L(t(...e)); - } catch (r) { - return Promise.reject(r); - } -} -function FL(t) { - const e = typeof t; - return t === null || e !== "object" && e !== "function"; -} -function BL(t) { - const e = Object.getPrototypeOf(t); - return !e || e.isPrototypeOf(Object); -} -function xd(t) { - if (FL(t)) - return String(t); - if (BL(t) || Array.isArray(t)) - return JSON.stringify(t); - if (typeof t.toJSON == "function") - return xd(t.toJSON()); - throw new Error("[unstorage] Cannot stringify value!"); -} -function w4() { - if (typeof Buffer > "u") - throw new TypeError("[unstorage] Buffer is not supported!"); -} -const l1 = "base64:"; -function UL(t) { - if (typeof t == "string") - return t; - w4(); - const e = Buffer.from(t).toString("base64"); - return l1 + e; -} -function jL(t) { - return typeof t != "string" || !t.startsWith(l1) ? t : (w4(), Buffer.from(t.slice(l1.length), "base64")); -} -function di(t) { - return t ? t.split("?")[0].replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") : ""; -} -function qL(...t) { - return di(t.join(":")); -} -function od(t) { - return t = di(t), t ? t + ":" : ""; -} -const zL = "memory", HL = () => { - const t = /* @__PURE__ */ new Map(); - return { - name: zL, - getInstance: () => t, - hasItem(e) { - return t.has(e); - }, - getItem(e) { - return t.get(e) ?? null; - }, - getItemRaw(e) { - return t.get(e) ?? null; - }, - setItem(e, r) { - t.set(e, r); - }, - setItemRaw(e, r) { - t.set(e, r); - }, - removeItem(e) { - t.delete(e); - }, - getKeys() { - return [...t.keys()]; - }, - clear() { - t.clear(); - }, - dispose() { - t.clear(); - } - }; -}; -function WL(t = {}) { - const e = { - mounts: { "": t.driver || HL() }, - mountpoints: [""], - watching: !1, - watchListeners: [], - unwatch: {} - }, r = (l) => { - for (const d of e.mountpoints) - if (l.startsWith(d)) - return { - base: d, - relativeKey: l.slice(d.length), - driver: e.mounts[d] - }; - return { - base: "", - relativeKey: l, - driver: e.mounts[""] - }; - }, n = (l, d) => e.mountpoints.filter( - (g) => g.startsWith(l) || d && l.startsWith(g) - ).map((g) => ({ - relativeBase: l.length > g.length ? l.slice(g.length) : void 0, - mountpoint: g, - driver: e.mounts[g] - })), i = (l, d) => { - if (e.watching) { - d = di(d); - for (const g of e.watchListeners) - g(l, d); - } - }, s = async () => { - if (!e.watching) { - e.watching = !0; - for (const l in e.mounts) - e.unwatch[l] = await H2( - e.mounts[l], - i, - l - ); - } - }, o = async () => { - if (e.watching) { - for (const l in e.unwatch) - await e.unwatch[l](); - e.unwatch = {}, e.watching = !1; - } - }, a = (l, d, g) => { - const w = /* @__PURE__ */ new Map(), A = (M) => { - let N = w.get(M.base); - return N || (N = { - driver: M.driver, - base: M.base, - items: [] - }, w.set(M.base, N)), N; - }; - for (const M of l) { - const N = typeof M == "string", L = di(N ? M : M.key), F = N ? void 0 : M.value, $ = N || !M.options ? d : { ...d, ...M.options }, K = r(L); - A(K).items.push({ - key: L, - value: F, - relativeKey: K.relativeKey, - options: $ - }); - } - return Promise.all([...w.values()].map((M) => g(M))).then( - (M) => M.flat() - ); - }, u = { - // Item - hasItem(l, d = {}) { - l = di(l); - const { relativeKey: g, driver: w } = r(l); - return Cn(w.hasItem, g, d); - }, - getItem(l, d = {}) { - l = di(l); - const { relativeKey: g, driver: w } = r(l); - return Cn(w.getItem, g, d).then( - (A) => sd(A) - ); - }, - getItems(l, d) { - return a(l, d, (g) => g.driver.getItems ? Cn( - g.driver.getItems, - g.items.map((w) => ({ - key: w.relativeKey, - options: w.options - })), - d - ).then( - (w) => w.map((A) => ({ - key: qL(g.base, A.key), - value: sd(A.value) - })) - ) : Promise.all( - g.items.map((w) => Cn( - g.driver.getItem, - w.relativeKey, - w.options - ).then((A) => ({ - key: w.key, - value: sd(A) - }))) - )); - }, - getItemRaw(l, d = {}) { - l = di(l); - const { relativeKey: g, driver: w } = r(l); - return w.getItemRaw ? Cn(w.getItemRaw, g, d) : Cn(w.getItem, g, d).then( - (A) => jL(A) - ); - }, - async setItem(l, d, g = {}) { - if (d === void 0) - return u.removeItem(l); - l = di(l); - const { relativeKey: w, driver: A } = r(l); - A.setItem && (await Cn(A.setItem, w, xd(d), g), A.watch || i("update", l)); - }, - async setItems(l, d) { - await a(l, d, async (g) => { - if (g.driver.setItems) - return Cn( - g.driver.setItems, - g.items.map((w) => ({ - key: w.relativeKey, - value: xd(w.value), - options: w.options - })), - d - ); - g.driver.setItem && await Promise.all( - g.items.map((w) => Cn( - g.driver.setItem, - w.relativeKey, - xd(w.value), - w.options - )) - ); - }); - }, - async setItemRaw(l, d, g = {}) { - if (d === void 0) - return u.removeItem(l, g); - l = di(l); - const { relativeKey: w, driver: A } = r(l); - if (A.setItemRaw) - await Cn(A.setItemRaw, w, d, g); - else if (A.setItem) - await Cn(A.setItem, w, UL(d), g); - else - return; - A.watch || i("update", l); - }, - async removeItem(l, d = {}) { - typeof d == "boolean" && (d = { removeMeta: d }), l = di(l); - const { relativeKey: g, driver: w } = r(l); - w.removeItem && (await Cn(w.removeItem, g, d), (d.removeMeta || d.removeMata) && await Cn(w.removeItem, g + "$", d), w.watch || i("remove", l)); - }, - // Meta - async getMeta(l, d = {}) { - typeof d == "boolean" && (d = { nativeOnly: d }), l = di(l); - const { relativeKey: g, driver: w } = r(l), A = /* @__PURE__ */ Object.create(null); - if (w.getMeta && Object.assign(A, await Cn(w.getMeta, g, d)), !d.nativeOnly) { - const M = await Cn( - w.getItem, - g + "$", - d - ).then((N) => sd(N)); - 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(A, M)); - } - return A; - }, - setMeta(l, d, g = {}) { - return this.setItem(l + "$", d, g); - }, - removeMeta(l, d = {}) { - return this.removeItem(l + "$", d); - }, - // Keys - async getKeys(l, d = {}) { - l = od(l); - const g = n(l, !0); - let w = []; - const A = []; - for (const M of g) { - const N = await Cn( - M.driver.getKeys, - M.relativeBase, - d - ); - for (const L of N) { - const F = M.mountpoint + di(L); - w.some(($) => F.startsWith($)) || A.push(F); - } - w = [ - M.mountpoint, - ...w.filter((L) => !L.startsWith(M.mountpoint)) - ]; - } - return l ? A.filter( - (M) => M.startsWith(l) && M[M.length - 1] !== "$" - ) : A.filter((M) => M[M.length - 1] !== "$"); - }, - // Utils - async clear(l, d = {}) { - l = od(l), await Promise.all( - n(l, !1).map(async (g) => { - if (g.driver.clear) - return Cn(g.driver.clear, g.relativeBase, d); - if (g.driver.removeItem) { - const w = await g.driver.getKeys(g.relativeBase || "", d); - return Promise.all( - w.map((A) => g.driver.removeItem(A, d)) - ); - } - }) - ); - }, - async dispose() { - await Promise.all( - Object.values(e.mounts).map((l) => W2(l)) - ); - }, - async watch(l) { - return await s(), e.watchListeners.push(l), async () => { - e.watchListeners = e.watchListeners.filter( - (d) => d !== l - ), e.watchListeners.length === 0 && await o(); - }; - }, - async unwatch() { - e.watchListeners = [], await o(); - }, - // Mount - mount(l, d) { - if (l = od(l), l && e.mounts[l]) - throw new Error(`already mounted at ${l}`); - return l && (e.mountpoints.push(l), e.mountpoints.sort((g, w) => w.length - g.length)), e.mounts[l] = d, e.watching && Promise.resolve(H2(d, i, l)).then((g) => { - e.unwatch[l] = g; - }).catch(console.error), u; - }, - async unmount(l, d = !0) { - l = od(l), !(!l || !e.mounts[l]) && (e.watching && l in e.unwatch && (e.unwatch[l](), delete e.unwatch[l]), d && await W2(e.mounts[l]), e.mountpoints = e.mountpoints.filter((g) => g !== l), delete e.mounts[l]); - }, - getMount(l = "") { - l = di(l) + ":"; - const d = r(l); - return { - driver: d.driver, - base: d.base - }; - }, - getMounts(l = "", d = {}) { - return l = di(l), n(l, d.parents).map((w) => ({ - driver: w.driver, - base: w.mountpoint - })); - }, - // Aliases - keys: (l, d = {}) => u.getKeys(l, d), - get: (l, d = {}) => u.getItem(l, d), - set: (l, d, g = {}) => u.setItem(l, d, g), - has: (l, d = {}) => u.hasItem(l, d), - del: (l, d = {}) => u.removeItem(l, d), - remove: (l, d = {}) => u.removeItem(l, d) - }; - return u; -} -function H2(t, e, r) { - return t.watch ? t.watch((n, i) => e(n, r + i)) : () => { - }; -} -async function W2(t) { - typeof t.dispose == "function" && await Cn(t.dispose); -} -function vc(t) { - return new Promise((e, r) => { - t.oncomplete = t.onsuccess = () => e(t.result), t.onabort = t.onerror = () => r(t.error); - }); -} -function x4(t, e) { - const r = indexedDB.open(t); - r.onupgradeneeded = () => r.result.createObjectStore(e); - const n = vc(r); - return (i, s) => n.then((o) => s(o.transaction(e, i).objectStore(e))); -} -let Gg; -function Ul() { - return Gg || (Gg = x4("keyval-store", "keyval")), Gg; -} -function K2(t, e = Ul()) { - return e("readonly", (r) => vc(r.get(t))); -} -function KL(t, e, r = Ul()) { - return r("readwrite", (n) => (n.put(e, t), vc(n.transaction))); -} -function VL(t, e = Ul()) { - return e("readwrite", (r) => (r.delete(t), vc(r.transaction))); -} -function GL(t = Ul()) { - return t("readwrite", (e) => (e.clear(), vc(e.transaction))); -} -function YL(t, e) { - return t.openCursor().onsuccess = function() { - this.result && (e(this.result), this.result.continue()); - }, vc(t.transaction); -} -function JL(t = Ul()) { - return t("readonly", (e) => { - if (e.getAllKeys) - return vc(e.getAllKeys()); - const r = []; - return YL(e, (n) => r.push(n.key)).then(() => r); - }); -} -const XL = (t) => JSON.stringify(t, (e, r) => typeof r == "bigint" ? r.toString() + "n" : r), ZL = (t) => { - const 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 = t.replace(e, '$1"$2n"$3'); - return JSON.parse(r, (n, i) => typeof i == "string" && i.match(/^\d+n$/) ? BigInt(i.substring(0, i.length - 1)) : i); -}; -function uc(t) { - if (typeof t != "string") - throw new Error(`Cannot safe json parse value of type ${typeof t}`); - try { - return ZL(t); - } catch { - return t; - } -} -function ko(t) { - return typeof t == "string" ? t : XL(t) || ""; -} -const QL = "idb-keyval"; -var ek = (t = {}) => { - const e = t.base && t.base.length > 0 ? `${t.base}:` : "", r = (i) => e + i; - let n; - return t.dbName && t.storeName && (n = x4(t.dbName, t.storeName)), { name: QL, options: t, async hasItem(i) { - return !(typeof await K2(r(i), n) > "u"); - }, async getItem(i) { - return await K2(r(i), n) ?? null; - }, setItem(i, s) { - return KL(r(i), s, n); - }, removeItem(i) { - return VL(r(i), n); - }, getKeys() { - return JL(n); - }, clear() { - return GL(n); - } }; -}; -const tk = "WALLET_CONNECT_V2_INDEXED_DB", rk = "keyvaluestorage"; -let nk = class { - constructor() { - this.indexedDb = WL({ driver: ek({ dbName: tk, storeName: rk }) }); - } - 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) { - const r = await this.indexedDb.getItem(e); - if (r !== null) return r; - } - async setItem(e, r) { - await this.indexedDb.setItem(e, ko(r)); - } - async removeItem(e) { - await this.indexedDb.removeItem(e); - } -}; -var Yg = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, _d = { exports: {} }; -(function() { - let t; - function e() { - } - t = e, t.prototype.getItem = function(r) { - return this.hasOwnProperty(r) ? String(this[r]) : null; - }, t.prototype.setItem = function(r, n) { - this[r] = String(n); - }, t.prototype.removeItem = function(r) { - delete this[r]; - }, t.prototype.clear = function() { - const r = this; - Object.keys(r).forEach(function(n) { - r[n] = void 0, delete r[n]; - }); - }, t.prototype.key = function(r) { - return r = r || 0, Object.keys(this)[r]; - }, t.prototype.__defineGetter__("length", function() { - return Object.keys(this).length; - }), typeof Yg < "u" && Yg.localStorage ? _d.exports = Yg.localStorage : typeof window < "u" && window.localStorage ? _d.exports = window.localStorage : _d.exports = new e(); -})(); -function ik(t) { - var e; - return [t[0], uc((e = t[1]) != null ? e : "")]; -} -let sk = class { - constructor() { - this.localStorage = _d.exports; - } - async getKeys() { - return Object.keys(this.localStorage); - } - async getEntries() { - return Object.entries(this.localStorage).map(ik); - } - async getItem(e) { - const r = this.localStorage.getItem(e); - if (r !== null) return uc(r); - } - async setItem(e, r) { - this.localStorage.setItem(e, ko(r)); - } - async removeItem(e) { - this.localStorage.removeItem(e); - } -}; -const ok = "wc_storage_version", V2 = 1, ak = async (t, e, r) => { - const n = ok, i = await e.getItem(n); - if (i && i >= V2) { - r(e); - return; - } - const s = await t.getKeys(); - if (!s.length) { - r(e); - return; - } - const o = []; - for (; s.length; ) { - const a = s.shift(); - if (!a) continue; - const u = a.toLowerCase(); - if (u.includes("wc@") || u.includes("walletconnect") || u.includes("wc_") || u.includes("wallet_connect")) { - const l = await t.getItem(a); - await e.setItem(a, l), o.push(a); - } - } - await e.setItem(n, V2), r(e), ck(t, o); -}, ck = async (t, e) => { - e.length && e.forEach(async (r) => { - await t.removeItem(r); - }); -}; -let uk = class { - constructor() { - this.initialized = !1, this.setInitialized = (r) => { - this.storage = r, this.initialized = !0; - }; - const e = new sk(); - this.storage = e; - try { - const r = new nk(); - ak(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) => { - const r = setInterval(() => { - this.initialized && (clearInterval(r), e()); - }, 20); - }); - } -}; -function fk(t) { - try { - return JSON.stringify(t); - } catch { - return '"[Circular]"'; - } -} -var lk = hk; -function hk(t, e, r) { - var n = r && r.stringify || fk, i = 1; - if (typeof t == "object" && t !== null) { - var s = e.length + i; - if (s === 1) return t; - var o = new Array(s); - o[0] = n(t); - for (var a = 1; a < s; a++) - o[a] = n(e[a]); - return o.join(" "); - } - if (typeof t != "string") - return t; - var u = e.length; - if (u === 0) return t; - for (var l = "", d = 1 - i, g = -1, w = t && t.length || 0, A = 0; A < w; ) { - if (t.charCodeAt(A) === 37 && A + 1 < w) { - switch (g = g > -1 ? g : 0, t.charCodeAt(A + 1)) { - case 100: - case 102: - if (d >= u || e[d] == null) break; - g < A && (l += t.slice(g, A)), l += Number(e[d]), g = A + 2, A++; - break; - case 105: - if (d >= u || e[d] == null) break; - g < A && (l += t.slice(g, A)), l += Math.floor(Number(e[d])), g = A + 2, A++; - break; - case 79: - case 111: - case 106: - if (d >= u || e[d] === void 0) break; - g < A && (l += t.slice(g, A)); - var M = typeof e[d]; - if (M === "string") { - l += "'" + e[d] + "'", g = A + 2, A++; - break; - } - if (M === "function") { - l += e[d].name || "", g = A + 2, A++; - break; - } - l += n(e[d]), g = A + 2, A++; - break; - case 115: - if (d >= u) - break; - g < A && (l += t.slice(g, A)), l += String(e[d]), g = A + 2, A++; - break; - case 37: - g < A && (l += t.slice(g, A)), l += "%", g = A + 2, A++, d--; - break; - } - ++d; - } - ++A; - } - return g === -1 ? t : (g < w && (l += t.slice(g)), l); -} -const G2 = lk; -var Yc = $o; -const bl = _k().console || {}, dk = { - mapHttpRequest: ad, - mapHttpResponse: ad, - wrapRequestSerializer: Jg, - wrapResponseSerializer: Jg, - wrapErrorSerializer: Jg, - req: ad, - res: ad, - err: bk -}; -function pk(t, e) { - return Array.isArray(t) ? t.filter(function(n) { - return n !== "!stdSerializers.err"; - }) : t === !0 ? Object.keys(e) : !1; -} -function $o(t) { - t = t || {}, t.browser = t.browser || {}; - const e = t.browser.transmit; - if (e && typeof e.send != "function") - throw Error("pino: transmit option must have a send function"); - const r = t.browser.write || bl; - t.browser.write && (t.browser.asObject = !0); - const n = t.serializers || {}, i = pk(t.browser.serialize, n); - let s = t.browser.serialize; - Array.isArray(t.browser.serialize) && t.browser.serialize.indexOf("!stdSerializers.err") > -1 && (s = !1); - const o = ["error", "fatal", "warn", "info", "debug", "trace"]; - typeof r == "function" && (r.error = r.fatal = r.warn = r.info = r.debug = r.trace = r), t.enabled === !1 && (t.level = "silent"); - const a = t.level || "info", u = Object.create(r); - u.log || (u.log = yl), Object.defineProperty(u, "levelVal", { - get: d - }), Object.defineProperty(u, "level", { - get: g, - set: w - }); - const l = { - transmit: e, - serialize: i, - asObject: t.browser.asObject, - levels: o, - timestamp: yk(t) - }; - u.levels = $o.levels, u.level = a, 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 = yl, u.serializers = n, u._serialize = i, u._stdErrSerialize = s, u.child = A, e && (u._logEvent = h1()); - function d() { - return this.level === "silent" ? 1 / 0 : this.levels.values[this.level]; - } - function g() { - return this._level; - } - function w(M) { - if (M !== "silent" && !this.levels.values[M]) - throw Error("unknown level " + M); - this._level = M, zc(l, u, "error", "log"), zc(l, u, "fatal", "error"), zc(l, u, "warn", "error"), zc(l, u, "info", "log"), zc(l, u, "debug", "log"), zc(l, u, "trace", "log"); - } - function A(M, N) { - if (!M) - throw new Error("missing bindings for child Pino"); - N = N || {}, i && M.serializers && (N.serializers = M.serializers); - const L = N.serializers; - if (i && L) { - var F = Object.assign({}, n, L), $ = t.browser.serialize === !0 ? Object.keys(F) : i; - delete M.serializers, L0([M], $, F, this._stdErrSerialize); - } - function K(H) { - this._childLevel = (H._childLevel | 0) + 1, this.error = Hc(H, M, "error"), this.fatal = Hc(H, M, "fatal"), this.warn = Hc(H, M, "warn"), this.info = Hc(H, M, "info"), this.debug = Hc(H, M, "debug"), this.trace = Hc(H, M, "trace"), F && (this.serializers = F, this._serialize = $), e && (this._logEvent = h1( - [].concat(H._logEvent.bindings, M) - )); - } - return K.prototype = this, new K(this); - } - return u; -} -$o.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" - } -}; -$o.stdSerializers = dk; -$o.stdTimeFunctions = Object.assign({}, { nullTime: _4, epochTime: E4, unixTime: wk, isoTime: xk }); -function zc(t, e, r, n) { - const i = Object.getPrototypeOf(e); - e[r] = e.levelVal > e.levels.values[r] ? yl : i[r] ? i[r] : bl[r] || bl[n] || yl, gk(t, e, r); -} -function gk(t, e, r) { - !t.transmit && e[r] === yl || (e[r] = /* @__PURE__ */ function(n) { - return function() { - const s = t.timestamp(), o = new Array(arguments.length), a = Object.getPrototypeOf && Object.getPrototypeOf(this) === bl ? bl : this; - for (var u = 0; u < o.length; u++) o[u] = arguments[u]; - if (t.serialize && !t.asObject && L0(o, this._serialize, this.serializers, this._stdErrSerialize), t.asObject ? n.call(a, mk(this, r, o, s)) : n.apply(a, o), t.transmit) { - const l = t.transmit.level || e.level, d = $o.levels.values[l], g = $o.levels.values[r]; - if (g < d) return; - vk(this, { - ts: s, - methodLevel: r, - methodValue: g, - send: t.transmit.send, - val: e.levelVal - }, o); - } - }; - }(e[r])); -} -function mk(t, e, r, n) { - t._serialize && L0(r, t._serialize, t.serializers, t._stdErrSerialize); - const i = r.slice(); - let s = i[0]; - const o = {}; - n && (o.time = n), o.level = $o.levels.values[e]; - let a = (t._childLevel | 0) + 1; - if (a < 1 && (a = 1), s !== null && typeof s == "object") { - for (; a-- && typeof i[0] == "object"; ) - Object.assign(o, i.shift()); - s = i.length ? G2(i.shift(), i) : void 0; - } else typeof s == "string" && (s = G2(i.shift(), i)); - return s !== void 0 && (o.msg = s), o; -} -function L0(t, e, r, n) { - for (const i in t) - if (n && t[i] instanceof Error) - t[i] = $o.stdSerializers.err(t[i]); - else if (typeof t[i] == "object" && !Array.isArray(t[i])) - for (const s in t[i]) - e && e.indexOf(s) > -1 && s in r && (t[i][s] = r[s](t[i][s])); -} -function Hc(t, e, r) { - return function() { - const n = new Array(1 + arguments.length); - n[0] = e; - for (var i = 1; i < n.length; i++) - n[i] = arguments[i - 1]; - return t[r].apply(this, n); - }; -} -function vk(t, e, r) { - const n = e.send, i = e.ts, s = e.methodLevel, o = e.methodValue, a = e.val, u = t._logEvent.bindings; - L0( - r, - t._serialize || Object.keys(t.serializers), - t.serializers, - t._stdErrSerialize === void 0 ? !0 : t._stdErrSerialize - ), t._logEvent.ts = i, t._logEvent.messages = r.filter(function(l) { - return u.indexOf(l) === -1; - }), t._logEvent.level.label = s, t._logEvent.level.value = o, n(s, t._logEvent, a), t._logEvent = h1(u); -} -function h1(t) { - return { - ts: 0, - messages: [], - bindings: t || [], - level: { label: "", value: 0 } - }; -} -function bk(t) { - const e = { - type: t.constructor.name, - msg: t.message, - stack: t.stack - }; - for (const r in t) - e[r] === void 0 && (e[r] = t[r]); - return e; -} -function yk(t) { - return typeof t.timestamp == "function" ? t.timestamp : t.timestamp === !1 ? _4 : E4; -} -function ad() { - return {}; -} -function Jg(t) { - return t; -} -function yl() { -} -function _4() { - return !1; -} -function E4() { - return Date.now(); -} -function wk() { - return Math.round(Date.now() / 1e3); -} -function xk() { - return new Date(Date.now()).toISOString(); -} -function _k() { - function t(e) { - return typeof e < "u" && e; - } - try { - return typeof globalThis < "u" || Object.defineProperty(Object.prototype, "globalThis", { - get: function() { - return delete Object.prototype.globalThis, this.globalThis = this; - }, - configurable: !0 - }), globalThis; - } catch { - return t(self) || t(window) || t(this) || {}; - } -} -const jl = /* @__PURE__ */ ts(Yc), Ek = { level: "info" }, ql = "custom_context", kv = 1e3 * 1024; -let Sk = 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; - } -}, Y2 = class { - constructor(e) { - this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = e, this.sizeInBytes = 0; - } - append(e) { - const r = new Sk(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; - const e = this.head; - this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= e.size; - } - toArray() { - const e = []; - let 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 }; - const r = e.value; - return e = e.next, { done: !1, value: r }; - } }; - } -}, S4 = class { - constructor(e, r = kv) { - this.level = e ?? "error", this.levelValue = Yc.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = r, this.logs = new Y2(this.MAX_LOG_SIZE_IN_BYTES); - } - forwardToConsole(e, r) { - r === Yc.levels.values.error ? console.error(e) : r === Yc.levels.values.warn ? console.warn(e) : r === Yc.levels.values.debug ? console.debug(e) : r === Yc.levels.values.trace ? console.trace(e) : console.log(e); - } - appendToLogs(e) { - this.logs.append(ko({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: e })); - const 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 Y2(this.MAX_LOG_SIZE_IN_BYTES); - } - getLogArray() { - return Array.from(this.logs); - } - logsToBlob(e) { - const r = this.getLogArray(); - return r.push(ko({ extraMetadata: e })), new Blob(r, { type: "application/json" }); - } -}, Ak = class { - constructor(e, r = kv) { - this.baseChunkLogger = new S4(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) { - const r = URL.createObjectURL(this.logsToBlob(e)), n = document.createElement("a"); - n.href = r, n.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(r); - } -}, Pk = class { - constructor(e, r = kv) { - this.baseChunkLogger = new S4(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); - } -}; -var Mk = Object.defineProperty, Ik = Object.defineProperties, Ck = Object.getOwnPropertyDescriptors, J2 = Object.getOwnPropertySymbols, Tk = Object.prototype.hasOwnProperty, Rk = Object.prototype.propertyIsEnumerable, X2 = (t, e, r) => e in t ? Mk(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Yd = (t, e) => { - for (var r in e || (e = {})) Tk.call(e, r) && X2(t, r, e[r]); - if (J2) for (var r of J2(e)) Rk.call(e, r) && X2(t, r, e[r]); - return t; -}, Jd = (t, e) => Ik(t, Ck(e)); -function k0(t) { - return Jd(Yd({}, t), { level: (t == null ? void 0 : t.level) || Ek.level }); -} -function Dk(t, e = ql) { - return t[e] || ""; -} -function Ok(t, e, r = ql) { - return t[r] = e, t; -} -function Si(t, e = ql) { - let r = ""; - return typeof t.bindings > "u" ? r = Dk(t, e) : r = t.bindings().context || "", r; -} -function Nk(t, e, r = ql) { - const n = Si(t, r); - return n.trim() ? `${n}/${e}` : e; -} -function ai(t, e, r = ql) { - const n = Nk(t, e, r), i = t.child({ context: n }); - return Ok(i, n, r); -} -function Lk(t) { - var e, r; - const n = new Ak((e = t.opts) == null ? void 0 : e.level, t.maxSizeInBytes); - return { logger: jl(Jd(Yd({}, t.opts), { level: "trace", browser: Jd(Yd({}, (r = t.opts) == null ? void 0 : r.browser), { write: (i) => n.write(i) }) })), chunkLoggerController: n }; -} -function kk(t) { - var e; - const r = new Pk((e = t.opts) == null ? void 0 : e.level, t.maxSizeInBytes); - return { logger: jl(Jd(Yd({}, t.opts), { level: "trace" }), r), chunkLoggerController: r }; -} -function $k(t) { - return typeof t.loggerOverride < "u" && typeof t.loggerOverride != "string" ? { logger: t.loggerOverride, chunkLoggerController: null } : typeof window < "u" ? Lk(t) : kk(t); -} -let Fk = class extends mc { - constructor(e) { - super(), this.opts = e, this.protocol = "wc", this.version = 2; - } -}, Bk = class extends mc { - constructor(e, r) { - super(), this.core = e, this.logger = r, this.records = /* @__PURE__ */ new Map(); - } -}, Uk = class { - constructor(e, r) { - this.logger = e, this.core = r; - } -}, jk = class extends mc { - constructor(e, r) { - super(), this.relayer = e, this.logger = r; - } -}, qk = class extends mc { - constructor(e) { - super(); - } -}, zk = class { - constructor(e, r, n, i) { - this.core = e, this.logger = r, this.name = n; - } -}, Hk = class extends mc { - constructor(e, r) { - super(), this.relayer = e, this.logger = r; - } -}, Wk = class extends mc { - constructor(e, r) { - super(), this.core = e, this.logger = r; - } -}, Kk = class { - constructor(e, r, n) { - this.core = e, this.logger = r, this.store = n; - } -}, Vk = class { - constructor(e, r) { - this.projectId = e, this.logger = r; - } -}, Gk = class { - constructor(e, r, n) { - this.core = e, this.logger = r, this.telemetryEnabled = n; - } -}, Yk = class { - constructor(e) { - this.opts = e, this.protocol = "wc", this.version = 2; - } -}, Jk = class { - constructor(e) { - this.client = e; - } -}; -var $v = {}, Pa = {}, $0 = {}, F0 = {}; -Object.defineProperty(F0, "__esModule", { value: !0 }); -F0.BrowserRandomSource = void 0; -const Z2 = 65536; -class Xk { - constructor() { - this.isAvailable = !1, this.isInstantiated = !1; - const 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."); - const r = new Uint8Array(e); - for (let n = 0; n < r.length; n += Z2) - this._crypto.getRandomValues(r.subarray(n, n + Math.min(r.length - n, Z2))); - return r; - } -} -F0.BrowserRandomSource = Xk; -function A4(t) { - throw new Error('Could not dynamically require "' + t + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); -} -var B0 = {}, ki = {}; -Object.defineProperty(ki, "__esModule", { value: !0 }); -function Zk(t) { - for (var e = 0; e < t.length; e++) - t[e] = 0; - return t; -} -ki.wipe = Zk; -const Qk = {}, e$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - default: Qk -}, Symbol.toStringTag, { value: "Module" })), zl = /* @__PURE__ */ bv(e$); -Object.defineProperty(B0, "__esModule", { value: !0 }); -B0.NodeRandomSource = void 0; -const t$ = ki; -class r$ { - constructor() { - if (this.isAvailable = !1, this.isInstantiated = !1, typeof A4 < "u") { - const e = zl; - 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"); - const n = new Uint8Array(e); - for (let i = 0; i < n.length; i++) - n[i] = r[i]; - return (0, t$.wipe)(r), n; - } -} -B0.NodeRandomSource = r$; -Object.defineProperty($0, "__esModule", { value: !0 }); -$0.SystemRandomSource = void 0; -const n$ = F0, i$ = B0; -class s$ { - constructor() { - if (this.isAvailable = !1, this.name = "", this._source = new n$.BrowserRandomSource(), this._source.isAvailable) { - this.isAvailable = !0, this.name = "Browser"; - return; - } - if (this._source = new i$.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); - } -} -$0.SystemRandomSource = s$; -var or = {}, P4 = {}; -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }); - function e(a, u) { - var l = a >>> 16 & 65535, d = a & 65535, g = u >>> 16 & 65535, w = u & 65535; - return d * w + (l * w + d * g << 16 >>> 0) | 0; - } - t.mul = Math.imul || e; - function r(a, u) { - return a + u | 0; - } - t.add = r; - function n(a, u) { - return a - u | 0; - } - t.sub = n; - function i(a, u) { - return a << u | a >>> 32 - u; - } - t.rotl = i; - function s(a, u) { - return a << 32 - u | a >>> u; - } - t.rotr = s; - function o(a) { - return typeof a == "number" && isFinite(a) && Math.floor(a) === a; - } - t.isInteger = Number.isInteger || o, t.MAX_SAFE_INTEGER = 9007199254740991, t.isSafeInteger = function(a) { - return t.isInteger(a) && a >= -t.MAX_SAFE_INTEGER && a <= t.MAX_SAFE_INTEGER; - }; -})(P4); -Object.defineProperty(or, "__esModule", { value: !0 }); -var M4 = P4; -function o$(t, e) { - return e === void 0 && (e = 0), (t[e + 0] << 8 | t[e + 1]) << 16 >> 16; -} -or.readInt16BE = o$; -function a$(t, e) { - return e === void 0 && (e = 0), (t[e + 0] << 8 | t[e + 1]) >>> 0; -} -or.readUint16BE = a$; -function c$(t, e) { - return e === void 0 && (e = 0), (t[e + 1] << 8 | t[e]) << 16 >> 16; -} -or.readInt16LE = c$; -function u$(t, e) { - return e === void 0 && (e = 0), (t[e + 1] << 8 | t[e]) >>> 0; -} -or.readUint16LE = u$; -function I4(t, e, r) { - return e === void 0 && (e = new Uint8Array(2)), r === void 0 && (r = 0), e[r + 0] = t >>> 8, e[r + 1] = t >>> 0, e; -} -or.writeUint16BE = I4; -or.writeInt16BE = I4; -function C4(t, e, r) { - return e === void 0 && (e = new Uint8Array(2)), r === void 0 && (r = 0), e[r + 0] = t >>> 0, e[r + 1] = t >>> 8, e; -} -or.writeUint16LE = C4; -or.writeInt16LE = C4; -function d1(t, e) { - return e === void 0 && (e = 0), t[e] << 24 | t[e + 1] << 16 | t[e + 2] << 8 | t[e + 3]; -} -or.readInt32BE = d1; -function p1(t, e) { - return e === void 0 && (e = 0), (t[e] << 24 | t[e + 1] << 16 | t[e + 2] << 8 | t[e + 3]) >>> 0; -} -or.readUint32BE = p1; -function g1(t, e) { - return e === void 0 && (e = 0), t[e + 3] << 24 | t[e + 2] << 16 | t[e + 1] << 8 | t[e]; -} -or.readInt32LE = g1; -function m1(t, e) { - return e === void 0 && (e = 0), (t[e + 3] << 24 | t[e + 2] << 16 | t[e + 1] << 8 | t[e]) >>> 0; -} -or.readUint32LE = m1; -function Xd(t, e, r) { - return e === void 0 && (e = new Uint8Array(4)), r === void 0 && (r = 0), e[r + 0] = t >>> 24, e[r + 1] = t >>> 16, e[r + 2] = t >>> 8, e[r + 3] = t >>> 0, e; -} -or.writeUint32BE = Xd; -or.writeInt32BE = Xd; -function Zd(t, e, r) { - return e === void 0 && (e = new Uint8Array(4)), r === void 0 && (r = 0), e[r + 0] = t >>> 0, e[r + 1] = t >>> 8, e[r + 2] = t >>> 16, e[r + 3] = t >>> 24, e; -} -or.writeUint32LE = Zd; -or.writeInt32LE = Zd; -function f$(t, e) { - e === void 0 && (e = 0); - var r = d1(t, e), n = d1(t, e + 4); - return r * 4294967296 + n - (n >> 31) * 4294967296; -} -or.readInt64BE = f$; -function l$(t, e) { - e === void 0 && (e = 0); - var r = p1(t, e), n = p1(t, e + 4); - return r * 4294967296 + n; -} -or.readUint64BE = l$; -function h$(t, e) { - e === void 0 && (e = 0); - var r = g1(t, e), n = g1(t, e + 4); - return n * 4294967296 + r - (r >> 31) * 4294967296; -} -or.readInt64LE = h$; -function d$(t, e) { - e === void 0 && (e = 0); - var r = m1(t, e), n = m1(t, e + 4); - return n * 4294967296 + r; -} -or.readUint64LE = d$; -function T4(t, e, r) { - return e === void 0 && (e = new Uint8Array(8)), r === void 0 && (r = 0), Xd(t / 4294967296 >>> 0, e, r), Xd(t >>> 0, e, r + 4), e; -} -or.writeUint64BE = T4; -or.writeInt64BE = T4; -function R4(t, e, r) { - return e === void 0 && (e = new Uint8Array(8)), r === void 0 && (r = 0), Zd(t >>> 0, e, r), Zd(t / 4294967296 >>> 0, e, r + 4), e; -} -or.writeUint64LE = R4; -or.writeInt64LE = R4; -function p$(t, e, r) { - if (r === void 0 && (r = 0), t % 8 !== 0) - throw new Error("readUintBE supports only bitLengths divisible by 8"); - if (t / 8 > e.length - r) - throw new Error("readUintBE: array is too short for the given bitLength"); - for (var n = 0, i = 1, s = t / 8 + r - 1; s >= r; s--) - n += e[s] * i, i *= 256; - return n; -} -or.readUintBE = p$; -function g$(t, e, r) { - if (r === void 0 && (r = 0), t % 8 !== 0) - throw new Error("readUintLE supports only bitLengths divisible by 8"); - if (t / 8 > e.length - r) - throw new Error("readUintLE: array is too short for the given bitLength"); - for (var n = 0, i = 1, s = r; s < r + t / 8; s++) - n += e[s] * i, i *= 256; - return n; -} -or.readUintLE = g$; -function m$(t, e, r, n) { - if (r === void 0 && (r = new Uint8Array(t / 8)), n === void 0 && (n = 0), t % 8 !== 0) - throw new Error("writeUintBE supports only bitLengths divisible by 8"); - if (!M4.isSafeInteger(e)) - throw new Error("writeUintBE value must be an integer"); - for (var i = 1, s = t / 8 + n - 1; s >= n; s--) - r[s] = e / i & 255, i *= 256; - return r; -} -or.writeUintBE = m$; -function v$(t, e, r, n) { - if (r === void 0 && (r = new Uint8Array(t / 8)), n === void 0 && (n = 0), t % 8 !== 0) - throw new Error("writeUintLE supports only bitLengths divisible by 8"); - if (!M4.isSafeInteger(e)) - throw new Error("writeUintLE value must be an integer"); - for (var i = 1, s = n; s < n + t / 8; s++) - r[s] = e / i & 255, i *= 256; - return r; -} -or.writeUintLE = v$; -function b$(t, e) { - e === void 0 && (e = 0); - var r = new DataView(t.buffer, t.byteOffset, t.byteLength); - return r.getFloat32(e); -} -or.readFloat32BE = b$; -function y$(t, e) { - e === void 0 && (e = 0); - var r = new DataView(t.buffer, t.byteOffset, t.byteLength); - return r.getFloat32(e, !0); -} -or.readFloat32LE = y$; -function w$(t, e) { - e === void 0 && (e = 0); - var r = new DataView(t.buffer, t.byteOffset, t.byteLength); - return r.getFloat64(e); -} -or.readFloat64BE = w$; -function x$(t, e) { - e === void 0 && (e = 0); - var r = new DataView(t.buffer, t.byteOffset, t.byteLength); - return r.getFloat64(e, !0); -} -or.readFloat64LE = x$; -function _$(t, e, r) { - e === void 0 && (e = new Uint8Array(4)), r === void 0 && (r = 0); - var n = new DataView(e.buffer, e.byteOffset, e.byteLength); - return n.setFloat32(r, t), e; -} -or.writeFloat32BE = _$; -function E$(t, e, r) { - e === void 0 && (e = new Uint8Array(4)), r === void 0 && (r = 0); - var n = new DataView(e.buffer, e.byteOffset, e.byteLength); - return n.setFloat32(r, t, !0), e; -} -or.writeFloat32LE = E$; -function S$(t, e, r) { - e === void 0 && (e = new Uint8Array(8)), r === void 0 && (r = 0); - var n = new DataView(e.buffer, e.byteOffset, e.byteLength); - return n.setFloat64(r, t), e; -} -or.writeFloat64BE = S$; -function A$(t, e, r) { - e === void 0 && (e = new Uint8Array(8)), r === void 0 && (r = 0); - var n = new DataView(e.buffer, e.byteOffset, e.byteLength); - return n.setFloat64(r, t, !0), e; -} -or.writeFloat64LE = A$; -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }), t.randomStringForEntropy = t.randomString = t.randomUint32 = t.randomBytes = t.defaultRandomSource = void 0; - const e = $0, r = or, n = ki; - t.defaultRandomSource = new e.SystemRandomSource(); - function i(l, d = t.defaultRandomSource) { - return d.randomBytes(l); - } - t.randomBytes = i; - function s(l = t.defaultRandomSource) { - const d = i(4, l), g = (0, r.readUint32LE)(d); - return (0, n.wipe)(d), g; - } - t.randomUint32 = s; - const o = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - function a(l, d = o, g = t.defaultRandomSource) { - if (d.length < 2) - throw new Error("randomString charset is too short"); - if (d.length > 256) - throw new Error("randomString charset is too long"); - let w = ""; - const A = d.length, M = 256 - 256 % A; - for (; l > 0; ) { - const N = i(Math.ceil(l * 256 / M), g); - for (let L = 0; L < N.length && l > 0; L++) { - const F = N[L]; - F < M && (w += d.charAt(F % A), l--); - } - (0, n.wipe)(N); - } - return w; - } - t.randomString = a; - function u(l, d = o, g = t.defaultRandomSource) { - const w = Math.ceil(l / (Math.log(d.length) / Math.LN2)); - return a(w, d, g); - } - t.randomStringForEntropy = u; -})(Pa); -var D4 = {}; -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }); - var e = or, r = ki; - t.DIGEST_LENGTH = 64, t.BLOCK_SIZE = 128; - var n = ( - /** @class */ - function() { - function a() { - 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 a.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; - }, a.prototype.reset = function() { - return this._initState(), this._bufferLength = 0, this._bytesHashed = 0, this._finished = !1, this; - }, a.prototype.clean = function() { - r.wipe(this._buffer), r.wipe(this._tempHi), r.wipe(this._tempLo), this.reset(); - }, a.prototype.update = function(u, l) { - if (l === void 0 && (l = u.length), this._finished) - throw new Error("SHA512: can't update because hash was finished."); - var d = 0; - if (this._bytesHashed += l, this._bufferLength > 0) { - for (; this._bufferLength < t.BLOCK_SIZE && l > 0; ) - this._buffer[this._bufferLength++] = u[d++], l--; - this._bufferLength === this.blockSize && (s(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, this.blockSize), this._bufferLength = 0); - } - for (l >= this.blockSize && (d = s(this._tempHi, this._tempLo, this._stateHi, this._stateLo, u, d, l), l %= this.blockSize); l > 0; ) - this._buffer[this._bufferLength++] = u[d++], l--; - return this; - }, a.prototype.finish = function(u) { - if (!this._finished) { - var l = this._bytesHashed, d = this._bufferLength, g = l / 536870912 | 0, w = l << 3, A = l % 128 < 112 ? 128 : 256; - this._buffer[d] = 128; - for (var M = d + 1; M < A - 8; M++) - this._buffer[M] = 0; - e.writeUint32BE(g, this._buffer, A - 8), e.writeUint32BE(w, this._buffer, A - 4), s(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, A), this._finished = !0; - } - for (var M = 0; M < this.digestLength / 8; M++) - e.writeUint32BE(this._stateHi[M], u, M * 8), e.writeUint32BE(this._stateLo[M], u, M * 8 + 4); - return this; - }, a.prototype.digest = function() { - var u = new Uint8Array(this.digestLength); - return this.finish(u), u; - }, a.prototype.saveState = function() { - if (this._finished) - throw new Error("SHA256: cannot save finished state"); - return { - stateHi: new Int32Array(this._stateHi), - stateLo: new Int32Array(this._stateLo), - buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, - bufferLength: this._bufferLength, - bytesHashed: this._bytesHashed - }; - }, a.prototype.restoreState = function(u) { - return this._stateHi.set(u.stateHi), this._stateLo.set(u.stateLo), this._bufferLength = u.bufferLength, u.buffer && this._buffer.set(u.buffer), this._bytesHashed = u.bytesHashed, this._finished = !1, this; - }, a.prototype.cleanSavedState = function(u) { - r.wipe(u.stateHi), r.wipe(u.stateLo), u.buffer && r.wipe(u.buffer), u.bufferLength = 0, u.bytesHashed = 0; - }, a; - }() - ); - t.SHA512 = n; - var i = 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 s(a, u, l, d, g, w, A) { - for (var M = l[0], N = l[1], L = l[2], F = l[3], $ = l[4], K = l[5], H = l[6], V = l[7], te = d[0], R = d[1], W = d[2], pe = d[3], Ee = d[4], Y = d[5], S = d[6], m = d[7], f, p, b, x, _, E, v, P; A >= 128; ) { - for (var I = 0; I < 16; I++) { - var B = 8 * I + w; - a[I] = e.readUint32BE(g, B), u[I] = e.readUint32BE(g, B + 4); - } - for (var I = 0; I < 80; I++) { - var ce = M, D = N, oe = L, Z = F, J = $, Q = K, T = H, X = V, re = te, de = R, ie = W, ue = pe, ve = Ee, Pe = Y, De = S, Ce = m; - if (f = V, p = m, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = ($ >>> 14 | Ee << 18) ^ ($ >>> 18 | Ee << 14) ^ (Ee >>> 9 | $ << 23), p = (Ee >>> 14 | $ << 18) ^ (Ee >>> 18 | $ << 14) ^ ($ >>> 9 | Ee << 23), _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, f = $ & K ^ ~$ & H, p = Ee & Y ^ ~Ee & S, _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, f = i[I * 2], p = i[I * 2 + 1], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, f = a[I % 16], p = u[I % 16], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, b = v & 65535 | P << 16, x = _ & 65535 | E << 16, f = b, p = x, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = (M >>> 28 | te << 4) ^ (te >>> 2 | M << 30) ^ (te >>> 7 | M << 25), p = (te >>> 28 | M << 4) ^ (M >>> 2 | te << 30) ^ (M >>> 7 | te << 25), _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, f = M & N ^ M & L ^ N & L, p = te & R ^ te & W ^ R & W, _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, X = v & 65535 | P << 16, Ce = _ & 65535 | E << 16, f = Z, p = ue, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = b, p = x, _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, Z = v & 65535 | P << 16, ue = _ & 65535 | E << 16, N = ce, L = D, F = oe, $ = Z, K = J, H = Q, V = T, M = X, R = re, W = de, pe = ie, Ee = ue, Y = ve, S = Pe, m = De, te = Ce, I % 16 === 15) - for (var B = 0; B < 16; B++) - f = a[B], p = u[B], _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = a[(B + 9) % 16], p = u[(B + 9) % 16], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, b = a[(B + 1) % 16], x = u[(B + 1) % 16], f = (b >>> 1 | x << 31) ^ (b >>> 8 | x << 24) ^ b >>> 7, p = (x >>> 1 | b << 31) ^ (x >>> 8 | b << 24) ^ (x >>> 7 | b << 25), _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, b = a[(B + 14) % 16], x = u[(B + 14) % 16], f = (b >>> 19 | x << 13) ^ (x >>> 29 | b << 3) ^ b >>> 6, p = (x >>> 19 | b << 13) ^ (b >>> 29 | x << 3) ^ (x >>> 6 | b << 26), _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, a[B] = v & 65535 | P << 16, u[B] = _ & 65535 | E << 16; - } - f = M, p = te, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = l[0], p = d[0], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, l[0] = M = v & 65535 | P << 16, d[0] = te = _ & 65535 | E << 16, f = N, p = R, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = l[1], p = d[1], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, l[1] = N = v & 65535 | P << 16, d[1] = R = _ & 65535 | E << 16, f = L, p = W, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = l[2], p = d[2], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, l[2] = L = v & 65535 | P << 16, d[2] = W = _ & 65535 | E << 16, f = F, p = pe, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = l[3], p = d[3], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, l[3] = F = v & 65535 | P << 16, d[3] = pe = _ & 65535 | E << 16, f = $, p = Ee, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = l[4], p = d[4], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, l[4] = $ = v & 65535 | P << 16, d[4] = Ee = _ & 65535 | E << 16, f = K, p = Y, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = l[5], p = d[5], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, l[5] = K = v & 65535 | P << 16, d[5] = Y = _ & 65535 | E << 16, f = H, p = S, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = l[6], p = d[6], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, l[6] = H = v & 65535 | P << 16, d[6] = S = _ & 65535 | E << 16, f = V, p = m, _ = p & 65535, E = p >>> 16, v = f & 65535, P = f >>> 16, f = l[7], p = d[7], _ += p & 65535, E += p >>> 16, v += f & 65535, P += f >>> 16, E += _ >>> 16, v += E >>> 16, P += v >>> 16, l[7] = V = v & 65535 | P << 16, d[7] = m = _ & 65535 | E << 16, w += 128, A -= 128; - } - return w; - } - function o(a) { - var u = new n(); - u.update(a); - var l = u.digest(); - return u.clean(), l; - } - t.hash = o; -})(D4); -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }), t.convertSecretKeyToX25519 = t.convertPublicKeyToX25519 = t.verify = t.sign = t.extractPublicKeyFromSecretKey = t.generateKeyPair = t.generateKeyPairFromSeed = t.SEED_LENGTH = t.SECRET_KEY_LENGTH = t.PUBLIC_KEY_LENGTH = t.SIGNATURE_LENGTH = void 0; - const e = Pa, r = D4, n = ki; - t.SIGNATURE_LENGTH = 64, t.PUBLIC_KEY_LENGTH = 32, t.SECRET_KEY_LENGTH = 64, t.SEED_LENGTH = 32; - function i(Z) { - const J = new Float64Array(16); - if (Z) - for (let Q = 0; Q < Z.length; Q++) - J[Q] = Z[Q]; - return J; - } - const s = new Uint8Array(32); - s[0] = 9; - const o = i(), a = i([1]), u = i([ - 30883, - 4953, - 19914, - 30187, - 55467, - 16705, - 2637, - 112, - 59544, - 30585, - 16505, - 36039, - 65139, - 11119, - 27886, - 20995 - ]), l = i([ - 61785, - 9906, - 39828, - 60374, - 45398, - 33411, - 5274, - 224, - 53552, - 61171, - 33010, - 6542, - 64743, - 22239, - 55772, - 9222 - ]), d = i([ - 54554, - 36645, - 11616, - 51542, - 42930, - 38181, - 51040, - 26924, - 56412, - 64982, - 57905, - 49316, - 21502, - 52590, - 14035, - 8553 - ]), g = i([ - 26200, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214, - 26214 - ]), w = i([ - 41136, - 18958, - 6951, - 50414, - 58488, - 44335, - 6150, - 12099, - 55207, - 15867, - 153, - 11085, - 57099, - 20417, - 9344, - 11139 - ]); - function A(Z, J) { - for (let Q = 0; Q < 16; Q++) - Z[Q] = J[Q] | 0; - } - function M(Z) { - let J = 1; - for (let Q = 0; Q < 16; Q++) { - let T = Z[Q] + J + 65535; - J = Math.floor(T / 65536), Z[Q] = T - J * 65536; - } - Z[0] += J - 1 + 37 * (J - 1); - } - function N(Z, J, Q) { - const T = ~(Q - 1); - for (let X = 0; X < 16; X++) { - const re = T & (Z[X] ^ J[X]); - Z[X] ^= re, J[X] ^= re; - } - } - function L(Z, J) { - const Q = i(), T = i(); - for (let X = 0; X < 16; X++) - T[X] = J[X]; - M(T), M(T), M(T); - for (let X = 0; X < 2; X++) { - Q[0] = T[0] - 65517; - for (let de = 1; de < 15; de++) - Q[de] = T[de] - 65535 - (Q[de - 1] >> 16 & 1), Q[de - 1] &= 65535; - Q[15] = T[15] - 32767 - (Q[14] >> 16 & 1); - const re = Q[15] >> 16 & 1; - Q[14] &= 65535, N(T, Q, 1 - re); - } - for (let X = 0; X < 16; X++) - Z[2 * X] = T[X] & 255, Z[2 * X + 1] = T[X] >> 8; - } - function F(Z, J) { - let Q = 0; - for (let T = 0; T < 32; T++) - Q |= Z[T] ^ J[T]; - return (1 & Q - 1 >>> 8) - 1; - } - function $(Z, J) { - const Q = new Uint8Array(32), T = new Uint8Array(32); - return L(Q, Z), L(T, J), F(Q, T); - } - function K(Z) { - const J = new Uint8Array(32); - return L(J, Z), J[0] & 1; - } - function H(Z, J) { - for (let Q = 0; Q < 16; Q++) - Z[Q] = J[2 * Q] + (J[2 * Q + 1] << 8); - Z[15] &= 32767; - } - function V(Z, J, Q) { - for (let T = 0; T < 16; T++) - Z[T] = J[T] + Q[T]; - } - function te(Z, J, Q) { - for (let T = 0; T < 16; T++) - Z[T] = J[T] - Q[T]; - } - function R(Z, J, Q) { - let T, X, re = 0, de = 0, ie = 0, ue = 0, ve = 0, Pe = 0, De = 0, Ce = 0, $e = 0, Me = 0, Ne = 0, Ke = 0, Le = 0, qe = 0, ze = 0, _e = 0, Ze = 0, at = 0, ke = 0, Qe = 0, tt = 0, Ye = 0, dt = 0, lt = 0, ct = 0, qt = 0, Yt = 0, Et = 0, Qt = 0, Jt = 0, Dt = 0, kt = Q[0], Ct = Q[1], gt = Q[2], Rt = Q[3], Nt = Q[4], vt = Q[5], $t = Q[6], Bt = Q[7], rt = Q[8], Ft = Q[9], k = Q[10], j = Q[11], z = Q[12], C = Q[13], G = Q[14], U = Q[15]; - T = J[0], re += T * kt, de += T * Ct, ie += T * gt, ue += T * Rt, ve += T * Nt, Pe += T * vt, De += T * $t, Ce += T * Bt, $e += T * rt, Me += T * Ft, Ne += T * k, Ke += T * j, Le += T * z, qe += T * C, ze += T * G, _e += T * U, T = J[1], de += T * kt, ie += T * Ct, ue += T * gt, ve += T * Rt, Pe += T * Nt, De += T * vt, Ce += T * $t, $e += T * Bt, Me += T * rt, Ne += T * Ft, Ke += T * k, Le += T * j, qe += T * z, ze += T * C, _e += T * G, Ze += T * U, T = J[2], ie += T * kt, ue += T * Ct, ve += T * gt, Pe += T * Rt, De += T * Nt, Ce += T * vt, $e += T * $t, Me += T * Bt, Ne += T * rt, Ke += T * Ft, Le += T * k, qe += T * j, ze += T * z, _e += T * C, Ze += T * G, at += T * U, T = J[3], ue += T * kt, ve += T * Ct, Pe += T * gt, De += T * Rt, Ce += T * Nt, $e += T * vt, Me += T * $t, Ne += T * Bt, Ke += T * rt, Le += T * Ft, qe += T * k, ze += T * j, _e += T * z, Ze += T * C, at += T * G, ke += T * U, T = J[4], ve += T * kt, Pe += T * Ct, De += T * gt, Ce += T * Rt, $e += T * Nt, Me += T * vt, Ne += T * $t, Ke += T * Bt, Le += T * rt, qe += T * Ft, ze += T * k, _e += T * j, Ze += T * z, at += T * C, ke += T * G, Qe += T * U, T = J[5], Pe += T * kt, De += T * Ct, Ce += T * gt, $e += T * Rt, Me += T * Nt, Ne += T * vt, Ke += T * $t, Le += T * Bt, qe += T * rt, ze += T * Ft, _e += T * k, Ze += T * j, at += T * z, ke += T * C, Qe += T * G, tt += T * U, T = J[6], De += T * kt, Ce += T * Ct, $e += T * gt, Me += T * Rt, Ne += T * Nt, Ke += T * vt, Le += T * $t, qe += T * Bt, ze += T * rt, _e += T * Ft, Ze += T * k, at += T * j, ke += T * z, Qe += T * C, tt += T * G, Ye += T * U, T = J[7], Ce += T * kt, $e += T * Ct, Me += T * gt, Ne += T * Rt, Ke += T * Nt, Le += T * vt, qe += T * $t, ze += T * Bt, _e += T * rt, Ze += T * Ft, at += T * k, ke += T * j, Qe += T * z, tt += T * C, Ye += T * G, dt += T * U, T = J[8], $e += T * kt, Me += T * Ct, Ne += T * gt, Ke += T * Rt, Le += T * Nt, qe += T * vt, ze += T * $t, _e += T * Bt, Ze += T * rt, at += T * Ft, ke += T * k, Qe += T * j, tt += T * z, Ye += T * C, dt += T * G, lt += T * U, T = J[9], Me += T * kt, Ne += T * Ct, Ke += T * gt, Le += T * Rt, qe += T * Nt, ze += T * vt, _e += T * $t, Ze += T * Bt, at += T * rt, ke += T * Ft, Qe += T * k, tt += T * j, Ye += T * z, dt += T * C, lt += T * G, ct += T * U, T = J[10], Ne += T * kt, Ke += T * Ct, Le += T * gt, qe += T * Rt, ze += T * Nt, _e += T * vt, Ze += T * $t, at += T * Bt, ke += T * rt, Qe += T * Ft, tt += T * k, Ye += T * j, dt += T * z, lt += T * C, ct += T * G, qt += T * U, T = J[11], Ke += T * kt, Le += T * Ct, qe += T * gt, ze += T * Rt, _e += T * Nt, Ze += T * vt, at += T * $t, ke += T * Bt, Qe += T * rt, tt += T * Ft, Ye += T * k, dt += T * j, lt += T * z, ct += T * C, qt += T * G, Yt += T * U, T = J[12], Le += T * kt, qe += T * Ct, ze += T * gt, _e += T * Rt, Ze += T * Nt, at += T * vt, ke += T * $t, Qe += T * Bt, tt += T * rt, Ye += T * Ft, dt += T * k, lt += T * j, ct += T * z, qt += T * C, Yt += T * G, Et += T * U, T = J[13], qe += T * kt, ze += T * Ct, _e += T * gt, Ze += T * Rt, at += T * Nt, ke += T * vt, Qe += T * $t, tt += T * Bt, Ye += T * rt, dt += T * Ft, lt += T * k, ct += T * j, qt += T * z, Yt += T * C, Et += T * G, Qt += T * U, T = J[14], ze += T * kt, _e += T * Ct, Ze += T * gt, at += T * Rt, ke += T * Nt, Qe += T * vt, tt += T * $t, Ye += T * Bt, dt += T * rt, lt += T * Ft, ct += T * k, qt += T * j, Yt += T * z, Et += T * C, Qt += T * G, Jt += T * U, T = J[15], _e += T * kt, Ze += T * Ct, at += T * gt, ke += T * Rt, Qe += T * Nt, tt += T * vt, Ye += T * $t, dt += T * Bt, lt += T * rt, ct += T * Ft, qt += T * k, Yt += T * j, Et += T * z, Qt += T * C, Jt += T * G, Dt += T * U, re += 38 * Ze, de += 38 * at, ie += 38 * ke, ue += 38 * Qe, ve += 38 * tt, Pe += 38 * Ye, De += 38 * dt, Ce += 38 * lt, $e += 38 * ct, Me += 38 * qt, Ne += 38 * Yt, Ke += 38 * Et, Le += 38 * Qt, qe += 38 * Jt, ze += 38 * Dt, X = 1, T = re + X + 65535, X = Math.floor(T / 65536), re = T - X * 65536, T = de + X + 65535, X = Math.floor(T / 65536), de = T - X * 65536, T = ie + X + 65535, X = Math.floor(T / 65536), ie = T - X * 65536, T = ue + X + 65535, X = Math.floor(T / 65536), ue = T - X * 65536, T = ve + X + 65535, X = Math.floor(T / 65536), ve = T - X * 65536, T = Pe + X + 65535, X = Math.floor(T / 65536), Pe = T - X * 65536, T = De + X + 65535, X = Math.floor(T / 65536), De = T - X * 65536, T = Ce + X + 65535, X = Math.floor(T / 65536), Ce = T - X * 65536, T = $e + X + 65535, X = Math.floor(T / 65536), $e = T - X * 65536, T = Me + X + 65535, X = Math.floor(T / 65536), Me = T - X * 65536, T = Ne + X + 65535, X = Math.floor(T / 65536), Ne = T - X * 65536, T = Ke + X + 65535, X = Math.floor(T / 65536), Ke = T - X * 65536, T = Le + X + 65535, X = Math.floor(T / 65536), Le = T - X * 65536, T = qe + X + 65535, X = Math.floor(T / 65536), qe = T - X * 65536, T = ze + X + 65535, X = Math.floor(T / 65536), ze = T - X * 65536, T = _e + X + 65535, X = Math.floor(T / 65536), _e = T - X * 65536, re += X - 1 + 37 * (X - 1), X = 1, T = re + X + 65535, X = Math.floor(T / 65536), re = T - X * 65536, T = de + X + 65535, X = Math.floor(T / 65536), de = T - X * 65536, T = ie + X + 65535, X = Math.floor(T / 65536), ie = T - X * 65536, T = ue + X + 65535, X = Math.floor(T / 65536), ue = T - X * 65536, T = ve + X + 65535, X = Math.floor(T / 65536), ve = T - X * 65536, T = Pe + X + 65535, X = Math.floor(T / 65536), Pe = T - X * 65536, T = De + X + 65535, X = Math.floor(T / 65536), De = T - X * 65536, T = Ce + X + 65535, X = Math.floor(T / 65536), Ce = T - X * 65536, T = $e + X + 65535, X = Math.floor(T / 65536), $e = T - X * 65536, T = Me + X + 65535, X = Math.floor(T / 65536), Me = T - X * 65536, T = Ne + X + 65535, X = Math.floor(T / 65536), Ne = T - X * 65536, T = Ke + X + 65535, X = Math.floor(T / 65536), Ke = T - X * 65536, T = Le + X + 65535, X = Math.floor(T / 65536), Le = T - X * 65536, T = qe + X + 65535, X = Math.floor(T / 65536), qe = T - X * 65536, T = ze + X + 65535, X = Math.floor(T / 65536), ze = T - X * 65536, T = _e + X + 65535, X = Math.floor(T / 65536), _e = T - X * 65536, re += X - 1 + 37 * (X - 1), Z[0] = re, Z[1] = de, Z[2] = ie, Z[3] = ue, Z[4] = ve, Z[5] = Pe, Z[6] = De, Z[7] = Ce, Z[8] = $e, Z[9] = Me, Z[10] = Ne, Z[11] = Ke, Z[12] = Le, Z[13] = qe, Z[14] = ze, Z[15] = _e; - } - function W(Z, J) { - R(Z, J, J); - } - function pe(Z, J) { - const Q = i(); - let T; - for (T = 0; T < 16; T++) - Q[T] = J[T]; - for (T = 253; T >= 0; T--) - W(Q, Q), T !== 2 && T !== 4 && R(Q, Q, J); - for (T = 0; T < 16; T++) - Z[T] = Q[T]; - } - function Ee(Z, J) { - const Q = i(); - let T; - for (T = 0; T < 16; T++) - Q[T] = J[T]; - for (T = 250; T >= 0; T--) - W(Q, Q), T !== 1 && R(Q, Q, J); - for (T = 0; T < 16; T++) - Z[T] = Q[T]; - } - function Y(Z, J) { - const Q = i(), T = i(), X = i(), re = i(), de = i(), ie = i(), ue = i(), ve = i(), Pe = i(); - te(Q, Z[1], Z[0]), te(Pe, J[1], J[0]), R(Q, Q, Pe), V(T, Z[0], Z[1]), V(Pe, J[0], J[1]), R(T, T, Pe), R(X, Z[3], J[3]), R(X, X, l), R(re, Z[2], J[2]), V(re, re, re), te(de, T, Q), te(ie, re, X), V(ue, re, X), V(ve, T, Q), R(Z[0], de, ie), R(Z[1], ve, ue), R(Z[2], ue, ie), R(Z[3], de, ve); - } - function S(Z, J, Q) { - for (let T = 0; T < 4; T++) - N(Z[T], J[T], Q); - } - function m(Z, J) { - const Q = i(), T = i(), X = i(); - pe(X, J[2]), R(Q, J[0], X), R(T, J[1], X), L(Z, T), Z[31] ^= K(Q) << 7; - } - function f(Z, J, Q) { - A(Z[0], o), A(Z[1], a), A(Z[2], a), A(Z[3], o); - for (let T = 255; T >= 0; --T) { - const X = Q[T / 8 | 0] >> (T & 7) & 1; - S(Z, J, X), Y(J, Z), Y(Z, Z), S(Z, J, X); - } - } - function p(Z, J) { - const Q = [i(), i(), i(), i()]; - A(Q[0], d), A(Q[1], g), A(Q[2], a), R(Q[3], d, g), f(Z, Q, J); - } - function b(Z) { - if (Z.length !== t.SEED_LENGTH) - throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`); - const J = (0, r.hash)(Z); - J[0] &= 248, J[31] &= 127, J[31] |= 64; - const Q = new Uint8Array(32), T = [i(), i(), i(), i()]; - p(T, J), m(Q, T); - const X = new Uint8Array(64); - return X.set(Z), X.set(Q, 32), { - publicKey: Q, - secretKey: X - }; - } - t.generateKeyPairFromSeed = b; - function x(Z) { - const J = (0, e.randomBytes)(32, Z), Q = b(J); - return (0, n.wipe)(J), Q; - } - t.generateKeyPair = x; - function _(Z) { - if (Z.length !== t.SECRET_KEY_LENGTH) - throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`); - return new Uint8Array(Z.subarray(32)); - } - t.extractPublicKeyFromSecretKey = _; - const E = 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 v(Z, J) { - let Q, T, X, re; - for (T = 63; T >= 32; --T) { - for (Q = 0, X = T - 32, re = T - 12; X < re; ++X) - J[X] += Q - 16 * J[T] * E[X - (T - 32)], Q = Math.floor((J[X] + 128) / 256), J[X] -= Q * 256; - J[X] += Q, J[T] = 0; - } - for (Q = 0, X = 0; X < 32; X++) - J[X] += Q - (J[31] >> 4) * E[X], Q = J[X] >> 8, J[X] &= 255; - for (X = 0; X < 32; X++) - J[X] -= Q * E[X]; - for (T = 0; T < 32; T++) - J[T + 1] += J[T] >> 8, Z[T] = J[T] & 255; - } - function P(Z) { - const J = new Float64Array(64); - for (let Q = 0; Q < 64; Q++) - J[Q] = Z[Q]; - for (let Q = 0; Q < 64; Q++) - Z[Q] = 0; - v(Z, J); - } - function I(Z, J) { - const Q = new Float64Array(64), T = [i(), i(), i(), i()], X = (0, r.hash)(Z.subarray(0, 32)); - X[0] &= 248, X[31] &= 127, X[31] |= 64; - const re = new Uint8Array(64); - re.set(X.subarray(32), 32); - const de = new r.SHA512(); - de.update(re.subarray(32)), de.update(J); - const ie = de.digest(); - de.clean(), P(ie), p(T, ie), m(re, T), de.reset(), de.update(re.subarray(0, 32)), de.update(Z.subarray(32)), de.update(J); - const ue = de.digest(); - P(ue); - for (let ve = 0; ve < 32; ve++) - Q[ve] = ie[ve]; - for (let ve = 0; ve < 32; ve++) - for (let Pe = 0; Pe < 32; Pe++) - Q[ve + Pe] += ue[ve] * X[Pe]; - return v(re.subarray(32), Q), re; - } - t.sign = I; - function B(Z, J) { - const Q = i(), T = i(), X = i(), re = i(), de = i(), ie = i(), ue = i(); - return A(Z[2], a), H(Z[1], J), W(X, Z[1]), R(re, X, u), te(X, X, Z[2]), V(re, Z[2], re), W(de, re), W(ie, de), R(ue, ie, de), R(Q, ue, X), R(Q, Q, re), Ee(Q, Q), R(Q, Q, X), R(Q, Q, re), R(Q, Q, re), R(Z[0], Q, re), W(T, Z[0]), R(T, T, re), $(T, X) && R(Z[0], Z[0], w), W(T, Z[0]), R(T, T, re), $(T, X) ? -1 : (K(Z[0]) === J[31] >> 7 && te(Z[0], o, Z[0]), R(Z[3], Z[0], Z[1]), 0); - } - function ce(Z, J, Q) { - const T = new Uint8Array(32), X = [i(), i(), i(), i()], re = [i(), i(), i(), i()]; - if (Q.length !== t.SIGNATURE_LENGTH) - throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`); - if (B(re, Z)) - return !1; - const de = new r.SHA512(); - de.update(Q.subarray(0, 32)), de.update(Z), de.update(J); - const ie = de.digest(); - return P(ie), f(X, re, ie), p(re, Q.subarray(32)), Y(X, re), m(T, X), !F(Q, T); - } - t.verify = ce; - function D(Z) { - let J = [i(), i(), i(), i()]; - if (B(J, Z)) - throw new Error("Ed25519: invalid public key"); - let Q = i(), T = i(), X = J[1]; - V(Q, a, X), te(T, a, X), pe(T, T), R(Q, Q, T); - let re = new Uint8Array(32); - return L(re, Q), re; - } - t.convertPublicKeyToX25519 = D; - function oe(Z) { - const J = (0, r.hash)(Z.subarray(0, 32)); - J[0] &= 248, J[31] &= 127, J[31] |= 64; - const Q = new Uint8Array(J.subarray(0, 32)); - return (0, n.wipe)(J), Q; - } - t.convertSecretKeyToX25519 = oe; -})($v); -const P$ = "EdDSA", M$ = "JWT", Qd = ".", U0 = "base64url", O4 = "utf8", N4 = "utf8", I$ = ":", C$ = "did", T$ = "key", Q2 = "base58btc", R$ = "z", D$ = "K36", O$ = 32; -function L4(t = 0) { - return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? globalThis.Buffer.allocUnsafe(t) : new Uint8Array(t); -} -function Ed(t, e) { - e || (e = t.reduce((i, s) => i + s.length, 0)); - const r = L4(e); - let n = 0; - for (const i of t) - r.set(i, n), n += i.length; - return r; -} -function N$(t, e) { - if (t.length >= 255) - throw new TypeError("Alphabet too long"); - for (var r = new Uint8Array(256), n = 0; n < r.length; n++) - r[n] = 255; - for (var i = 0; i < t.length; i++) { - var s = t.charAt(i), o = s.charCodeAt(0); - if (r[o] !== 255) - throw new TypeError(s + " is ambiguous"); - r[o] = i; - } - var a = t.length, u = t.charAt(0), l = Math.log(a) / Math.log(256), d = Math.log(256) / Math.log(a); - function g(M) { - if (M instanceof Uint8Array || (ArrayBuffer.isView(M) ? M = new Uint8Array(M.buffer, M.byteOffset, M.byteLength) : Array.isArray(M) && (M = Uint8Array.from(M))), !(M instanceof Uint8Array)) - throw new TypeError("Expected Uint8Array"); - if (M.length === 0) - return ""; - for (var N = 0, L = 0, F = 0, $ = M.length; F !== $ && M[F] === 0; ) - F++, N++; - for (var K = ($ - F) * d + 1 >>> 0, H = new Uint8Array(K); F !== $; ) { - for (var V = M[F], te = 0, R = K - 1; (V !== 0 || te < L) && R !== -1; R--, te++) - V += 256 * H[R] >>> 0, H[R] = V % a >>> 0, V = V / a >>> 0; - if (V !== 0) - throw new Error("Non-zero carry"); - L = te, F++; - } - for (var W = K - L; W !== K && H[W] === 0; ) - W++; - for (var pe = u.repeat(N); W < K; ++W) - pe += t.charAt(H[W]); - return pe; - } - function w(M) { - if (typeof M != "string") - throw new TypeError("Expected String"); - if (M.length === 0) - return new Uint8Array(); - var N = 0; - if (M[N] !== " ") { - for (var L = 0, F = 0; M[N] === u; ) - L++, N++; - for (var $ = (M.length - N) * l + 1 >>> 0, K = new Uint8Array($); M[N]; ) { - var H = r[M.charCodeAt(N)]; - if (H === 255) - return; - for (var V = 0, te = $ - 1; (H !== 0 || V < F) && te !== -1; te--, V++) - H += a * K[te] >>> 0, K[te] = H % 256 >>> 0, H = H / 256 >>> 0; - if (H !== 0) - throw new Error("Non-zero carry"); - F = V, N++; - } - if (M[N] !== " ") { - for (var R = $ - F; R !== $ && K[R] === 0; ) - R++; - for (var W = new Uint8Array(L + ($ - R)), pe = L; R !== $; ) - W[pe++] = K[R++]; - return W; - } - } - } - function A(M) { - var N = w(M); - if (N) - return N; - throw new Error(`Non-${e} character`); - } - return { - encode: g, - decodeUnsafe: w, - decode: A - }; -} -var L$ = N$, k$ = L$; -const $$ = (t) => { - if (t instanceof Uint8Array && t.constructor.name === "Uint8Array") - return t; - if (t instanceof ArrayBuffer) - return new Uint8Array(t); - if (ArrayBuffer.isView(t)) - return new Uint8Array(t.buffer, t.byteOffset, t.byteLength); - throw new Error("Unknown type, must be binary type"); -}, F$ = (t) => new TextEncoder().encode(t), B$ = (t) => new TextDecoder().decode(t); -class U$ { - constructor(e, r, n) { - this.name = e, this.prefix = r, this.baseEncode = n; - } - encode(e) { - if (e instanceof Uint8Array) - return `${this.prefix}${this.baseEncode(e)}`; - throw Error("Unknown type, must be binary type"); - } -} -class j$ { - constructor(e, r, n) { - 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 = n; - } - 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 k4(this, e); - } -} -class q$ { - constructor(e) { - this.decoders = e; - } - or(e) { - return k4(this, e); - } - decode(e) { - const r = e[0], n = this.decoders[r]; - if (n) - return n.decode(e); - throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); - } -} -const k4 = (t, e) => new q$({ - ...t.decoders || { [t.prefix]: t }, - ...e.decoders || { [e.prefix]: e } -}); -class z$ { - constructor(e, r, n, i) { - this.name = e, this.prefix = r, this.baseEncode = n, this.baseDecode = i, this.encoder = new U$(e, r, n), this.decoder = new j$(e, r, i); - } - encode(e) { - return this.encoder.encode(e); - } - decode(e) { - return this.decoder.decode(e); - } -} -const j0 = ({ name: t, prefix: e, encode: r, decode: n }) => new z$(t, e, r, n), Hl = ({ prefix: t, name: e, alphabet: r }) => { - const { encode: n, decode: i } = k$(r, e); - return j0({ - prefix: t, - name: e, - encode: n, - decode: (s) => $$(i(s)) - }); -}, H$ = (t, e, r, n) => { - const i = {}; - for (let d = 0; d < e.length; ++d) - i[e[d]] = d; - let s = t.length; - for (; t[s - 1] === "="; ) - --s; - const o = new Uint8Array(s * r / 8 | 0); - let a = 0, u = 0, l = 0; - for (let d = 0; d < s; ++d) { - const g = i[t[d]]; - if (g === void 0) - throw new SyntaxError(`Non-${n} character`); - u = u << r | g, a += r, a >= 8 && (a -= 8, o[l++] = 255 & u >> a); - } - if (a >= r || 255 & u << 8 - a) - throw new SyntaxError("Unexpected end of data"); - return o; -}, W$ = (t, e, r) => { - const n = e[e.length - 1] === "=", i = (1 << r) - 1; - let s = "", o = 0, a = 0; - for (let u = 0; u < t.length; ++u) - for (a = a << 8 | t[u], o += 8; o > r; ) - o -= r, s += e[i & a >> o]; - if (o && (s += e[i & a << r - o]), n) - for (; s.length * r & 7; ) - s += "="; - return s; -}, jn = ({ name: t, prefix: e, bitsPerChar: r, alphabet: n }) => j0({ - prefix: e, - name: t, - encode(i) { - return W$(i, n, r); - }, - decode(i) { - return H$(i, n, r, t); - } -}), K$ = j0({ - prefix: "\0", - name: "identity", - encode: (t) => B$(t), - decode: (t) => F$(t) -}), V$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - identity: K$ -}, Symbol.toStringTag, { value: "Module" })), G$ = jn({ - prefix: "0", - name: "base2", - alphabet: "01", - bitsPerChar: 1 -}), Y$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base2: G$ -}, Symbol.toStringTag, { value: "Module" })), J$ = jn({ - prefix: "7", - name: "base8", - alphabet: "01234567", - bitsPerChar: 3 -}), X$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base8: J$ -}, Symbol.toStringTag, { value: "Module" })), Z$ = Hl({ - prefix: "9", - name: "base10", - alphabet: "0123456789" -}), Q$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base10: Z$ -}, Symbol.toStringTag, { value: "Module" })), eF = jn({ - prefix: "f", - name: "base16", - alphabet: "0123456789abcdef", - bitsPerChar: 4 -}), tF = jn({ - prefix: "F", - name: "base16upper", - alphabet: "0123456789ABCDEF", - bitsPerChar: 4 -}), rF = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base16: eF, - base16upper: tF -}, Symbol.toStringTag, { value: "Module" })), nF = jn({ - prefix: "b", - name: "base32", - alphabet: "abcdefghijklmnopqrstuvwxyz234567", - bitsPerChar: 5 -}), iF = jn({ - prefix: "B", - name: "base32upper", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", - bitsPerChar: 5 -}), sF = jn({ - prefix: "c", - name: "base32pad", - alphabet: "abcdefghijklmnopqrstuvwxyz234567=", - bitsPerChar: 5 -}), oF = jn({ - prefix: "C", - name: "base32padupper", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", - bitsPerChar: 5 -}), aF = jn({ - prefix: "v", - name: "base32hex", - alphabet: "0123456789abcdefghijklmnopqrstuv", - bitsPerChar: 5 -}), cF = jn({ - prefix: "V", - name: "base32hexupper", - alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", - bitsPerChar: 5 -}), uF = jn({ - prefix: "t", - name: "base32hexpad", - alphabet: "0123456789abcdefghijklmnopqrstuv=", - bitsPerChar: 5 -}), fF = jn({ - prefix: "T", - name: "base32hexpadupper", - alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", - bitsPerChar: 5 -}), lF = jn({ - prefix: "h", - name: "base32z", - alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", - bitsPerChar: 5 -}), hF = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base32: nF, - base32hex: aF, - base32hexpad: uF, - base32hexpadupper: fF, - base32hexupper: cF, - base32pad: sF, - base32padupper: oF, - base32upper: iF, - base32z: lF -}, Symbol.toStringTag, { value: "Module" })), dF = Hl({ - prefix: "k", - name: "base36", - alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" -}), pF = Hl({ - prefix: "K", - name: "base36upper", - alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" -}), gF = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base36: dF, - base36upper: pF -}, Symbol.toStringTag, { value: "Module" })), mF = Hl({ - name: "base58btc", - prefix: "z", - alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" -}), vF = Hl({ - name: "base58flickr", - prefix: "Z", - alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" -}), bF = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base58btc: mF, - base58flickr: vF -}, Symbol.toStringTag, { value: "Module" })), yF = jn({ - prefix: "m", - name: "base64", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", - bitsPerChar: 6 -}), wF = jn({ - prefix: "M", - name: "base64pad", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - bitsPerChar: 6 -}), xF = jn({ - prefix: "u", - name: "base64url", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", - bitsPerChar: 6 -}), _F = jn({ - prefix: "U", - name: "base64urlpad", - alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", - bitsPerChar: 6 -}), EF = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base64: yF, - base64pad: wF, - base64url: xF, - base64urlpad: _F -}, Symbol.toStringTag, { value: "Module" })), $4 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), SF = $4.reduce((t, e, r) => (t[r] = e, t), []), AF = $4.reduce((t, e, r) => (t[e.codePointAt(0)] = r, t), []); -function PF(t) { - return t.reduce((e, r) => (e += SF[r], e), ""); -} -function MF(t) { - const e = []; - for (const r of t) { - const n = AF[r.codePointAt(0)]; - if (n === void 0) - throw new Error(`Non-base256emoji character: ${r}`); - e.push(n); - } - return new Uint8Array(e); -} -const IF = j0({ - prefix: "🚀", - name: "base256emoji", - encode: PF, - decode: MF -}), CF = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - base256emoji: IF -}, Symbol.toStringTag, { value: "Module" })); -new TextEncoder(); -new TextDecoder(); -const ex = { - ...V$, - ...Y$, - ...X$, - ...Q$, - ...rF, - ...hF, - ...gF, - ...bF, - ...EF, - ...CF -}; -function F4(t, e, r, n) { - return { - name: t, - prefix: e, - encoder: { - name: t, - prefix: e, - encode: r - }, - decoder: { decode: n } - }; -} -const tx = F4("utf8", "u", (t) => "u" + new TextDecoder("utf8").decode(t), (t) => new TextEncoder().encode(t.substring(1))), Xg = F4("ascii", "a", (t) => { - let e = "a"; - for (let r = 0; r < t.length; r++) - e += String.fromCharCode(t[r]); - return e; -}, (t) => { - t = t.substring(1); - const e = L4(t.length); - for (let r = 0; r < t.length; r++) - e[r] = t.charCodeAt(r); - return e; -}), B4 = { - utf8: tx, - "utf-8": tx, - hex: ex.base16, - latin1: Xg, - ascii: Xg, - binary: Xg, - ...ex -}; -function Dn(t, e = "utf8") { - const r = B4[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(t.buffer, t.byteOffset, t.byteLength).toString("utf8") : r.encoder.encode(t).substring(1); -} -function Rn(t, e = "utf8") { - const r = B4[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(t, "utf8") : r.decoder.decode(`${r.prefix}${t}`); -} -function rx(t) { - return uc(Dn(Rn(t, U0), O4)); -} -function e0(t) { - return Dn(Rn(ko(t), O4), U0); -} -function U4(t) { - const e = Rn(D$, Q2), r = R$ + Dn(Ed([e, t]), Q2); - return [C$, T$, r].join(I$); -} -function TF(t) { - return Dn(t, U0); -} -function RF(t) { - return Rn(t, U0); -} -function DF(t) { - return Rn([e0(t.header), e0(t.payload)].join(Qd), N4); -} -function OF(t) { - return [ - e0(t.header), - e0(t.payload), - TF(t.signature) - ].join(Qd); -} -function v1(t) { - const e = t.split(Qd), r = rx(e[0]), n = rx(e[1]), i = RF(e[2]), s = Rn(e.slice(0, 2).join(Qd), N4); - return { header: r, payload: n, signature: i, data: s }; -} -function nx(t = Pa.randomBytes(O$)) { - return $v.generateKeyPairFromSeed(t); -} -async function NF(t, e, r, n, i = mt.fromMiliseconds(Date.now())) { - const s = { alg: P$, typ: M$ }, o = U4(n.publicKey), a = i + r, u = { iss: o, sub: t, aud: e, iat: i, exp: a }, l = DF({ header: s, payload: u }), d = $v.sign(n.secretKey, l); - return OF({ header: s, payload: u, signature: d }); -} -var ix = function(t, e, r) { - if (r || arguments.length === 2) for (var n = 0, i = e.length, s; n < i; n++) - (s || !(n in e)) && (s || (s = Array.prototype.slice.call(e, 0, n)), s[n] = e[n]); - return t.concat(s || Array.prototype.slice.call(e)); -}, LF = ( - /** @class */ - /* @__PURE__ */ function() { - function t(e, r, n) { - this.name = e, this.version = r, this.os = n, this.type = "browser"; - } - return t; - }() -), kF = ( - /** @class */ - /* @__PURE__ */ function() { - function t(e) { - this.version = e, this.type = "node", this.name = "node", this.os = process.platform; - } - return t; - }() -), $F = ( - /** @class */ - /* @__PURE__ */ function() { - function t(e, r, n, i) { - this.name = e, this.version = r, this.os = n, this.bot = i, this.type = "bot-device"; - } - return t; - }() -), FF = ( - /** @class */ - /* @__PURE__ */ function() { - function t() { - this.type = "bot", this.bot = !0, this.name = "bot", this.version = null, this.os = null; - } - return t; - }() -), BF = ( - /** @class */ - /* @__PURE__ */ function() { - function t() { - this.type = "react-native", this.name = "react-native", this.version = null, this.os = null; - } - return t; - }() -), UF = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/, jF = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/, sx = 3, qF = [ - ["aol", /AOLShield\/([0-9\._]+)/], - ["edge", /Edge\/([0-9\._]+)/], - ["edge-ios", /EdgiOS\/([0-9\._]+)/], - ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], - ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], - ["samsung", /SamsungBrowser\/([0-9\.]+)/], - ["silk", /\bSilk\/([0-9._-]+)\b/], - ["miui", /MiuiBrowser\/([0-9\.]+)$/], - ["beaker", /BeakerBrowser\/([0-9\.]+)/], - ["edge-chromium", /EdgA?\/([0-9\.]+)/], - [ - "chromium-webview", - /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ - ], - ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], - ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], - ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], - ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], - ["fxios", /FxiOS\/([0-9\.]+)/], - ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], - ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], - ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], - ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], - ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], - ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], - ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], - ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], - ["ie", /MSIE\s(7\.0)/], - ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], - ["android", /Android\s([0-9\.]+)/], - ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], - ["safari", /Version\/([0-9\._]+).*Safari/], - ["facebook", /FB[AS]V\/([0-9\.]+)/], - ["instagram", /Instagram\s([0-9\.]+)/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], - ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], - ["curl", /^curl\/([0-9\.]+)$/], - ["searchbot", UF] -], ox = [ - ["iOS", /iP(hone|od|ad)/], - ["Android OS", /Android/], - ["BlackBerry OS", /BlackBerry|BB10/], - ["Windows Mobile", /IEMobile/], - ["Amazon OS", /Kindle/], - ["Windows 3.11", /Win16/], - ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], - ["Windows 98", /(Windows 98)|(Win98)/], - ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], - ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], - ["Windows Server 2003", /(Windows NT 5.2)/], - ["Windows Vista", /(Windows NT 6.0)/], - ["Windows 7", /(Windows NT 6.1)/], - ["Windows 8", /(Windows NT 6.2)/], - ["Windows 8.1", /(Windows NT 6.3)/], - ["Windows 10", /(Windows NT 10.0)/], - ["Windows ME", /Windows ME/], - ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], - ["Open BSD", /OpenBSD/], - ["Sun OS", /SunOS/], - ["Chrome OS", /CrOS/], - ["Linux", /(Linux)|(X11)/], - ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], - ["QNX", /QNX/], - ["BeOS", /BeOS/], - ["OS/2", /OS\/2/] -]; -function zF(t) { - return typeof document > "u" && typeof navigator < "u" && navigator.product === "ReactNative" ? new BF() : typeof navigator < "u" ? WF(navigator.userAgent) : VF(); -} -function HF(t) { - return t !== "" && qF.reduce(function(e, r) { - var n = r[0], i = r[1]; - if (e) - return e; - var s = i.exec(t); - return !!s && [n, s]; - }, !1); -} -function WF(t) { - var e = HF(t); - if (!e) - return null; - var r = e[0], n = e[1]; - if (r === "searchbot") - return new FF(); - var i = n[1] && n[1].split(".").join("_").split("_").slice(0, 3); - i ? i.length < sx && (i = ix(ix([], i, !0), GF(sx - i.length), !0)) : i = []; - var s = i.join("."), o = KF(t), a = jF.exec(t); - return a && a[1] ? new $F(r, s, o, a[1]) : new LF(r, s, o); -} -function KF(t) { - for (var e = 0, r = ox.length; e < r; e++) { - var n = ox[e], i = n[0], s = n[1], o = s.exec(t); - if (o) - return i; - } - return null; -} -function VF() { - var t = typeof process < "u" && process.version; - return t ? new kF(process.version.slice(1)) : null; -} -function GF(t) { - for (var e = [], r = 0; r < t; r++) - e.push("0"); - return e; -} -var Hr = {}; -Object.defineProperty(Hr, "__esModule", { value: !0 }); -Hr.getLocalStorage = Hr.getLocalStorageOrThrow = Hr.getCrypto = Hr.getCryptoOrThrow = j4 = Hr.getLocation = Hr.getLocationOrThrow = Fv = Hr.getNavigator = Hr.getNavigatorOrThrow = Wl = Hr.getDocument = Hr.getDocumentOrThrow = Hr.getFromWindowOrThrow = Hr.getFromWindow = void 0; -function bc(t) { - let e; - return typeof window < "u" && typeof window[t] < "u" && (e = window[t]), e; -} -Hr.getFromWindow = bc; -function Ou(t) { - const e = bc(t); - if (!e) - throw new Error(`${t} is not defined in Window`); - return e; -} -Hr.getFromWindowOrThrow = Ou; -function YF() { - return Ou("document"); -} -Hr.getDocumentOrThrow = YF; -function JF() { - return bc("document"); -} -var Wl = Hr.getDocument = JF; -function XF() { - return Ou("navigator"); -} -Hr.getNavigatorOrThrow = XF; -function ZF() { - return bc("navigator"); -} -var Fv = Hr.getNavigator = ZF; -function QF() { - return Ou("location"); -} -Hr.getLocationOrThrow = QF; -function eB() { - return bc("location"); -} -var j4 = Hr.getLocation = eB; -function tB() { - return Ou("crypto"); -} -Hr.getCryptoOrThrow = tB; -function rB() { - return bc("crypto"); -} -Hr.getCrypto = rB; -function nB() { - return Ou("localStorage"); -} -Hr.getLocalStorageOrThrow = nB; -function iB() { - return bc("localStorage"); -} -Hr.getLocalStorage = iB; -var Bv = {}; -Object.defineProperty(Bv, "__esModule", { value: !0 }); -var q4 = Bv.getWindowMetadata = void 0; -const ax = Hr; -function sB() { - let t, e; - try { - t = ax.getDocumentOrThrow(), e = ax.getLocationOrThrow(); - } catch { - return null; - } - function r() { - const g = t.getElementsByTagName("link"), w = []; - for (let A = 0; A < g.length; A++) { - const M = g[A], N = M.getAttribute("rel"); - if (N && N.toLowerCase().indexOf("icon") > -1) { - const L = M.getAttribute("href"); - if (L) - if (L.toLowerCase().indexOf("https:") === -1 && L.toLowerCase().indexOf("http:") === -1 && L.indexOf("//") !== 0) { - let F = e.protocol + "//" + e.host; - if (L.indexOf("/") === 0) - F += L; - else { - const $ = e.pathname.split("/"); - $.pop(); - const K = $.join("/"); - F += K + "/" + L; - } - w.push(F); - } else if (L.indexOf("//") === 0) { - const F = e.protocol + L; - w.push(F); - } else - w.push(L); - } - } - return w; - } - function n(...g) { - const w = t.getElementsByTagName("meta"); - for (let A = 0; A < w.length; A++) { - const M = w[A], N = ["itemprop", "property", "name"].map((L) => M.getAttribute(L)).filter((L) => L ? g.includes(L) : !1); - if (N.length && N) { - const L = M.getAttribute("content"); - if (L) - return L; - } - } - return ""; - } - function i() { - let g = n("name", "og:site_name", "og:title", "twitter:title"); - return g || (g = t.title), g; - } - function s() { - return n("description", "og:description", "twitter:description", "keywords"); - } - const o = i(), a = s(), u = e.origin, l = r(); - return { - description: a, - url: u, - icons: l, - name: o - }; -} -q4 = Bv.getWindowMetadata = sB; -var wl = {}, oB = (t) => encodeURIComponent(t).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`), z4 = "%[a-f0-9]{2}", cx = new RegExp("(" + z4 + ")|([^%]+?)", "gi"), ux = new RegExp("(" + z4 + ")+", "gi"); -function b1(t, e) { - try { - return [decodeURIComponent(t.join(""))]; - } catch { - } - if (t.length === 1) - return t; - e = e || 1; - var r = t.slice(0, e), n = t.slice(e); - return Array.prototype.concat.call([], b1(r), b1(n)); -} -function aB(t) { - try { - return decodeURIComponent(t); - } catch { - for (var e = t.match(cx) || [], r = 1; r < e.length; r++) - t = b1(e, r).join(""), e = t.match(cx) || []; - return t; - } -} -function cB(t) { - for (var e = { - "%FE%FF": "��", - "%FF%FE": "��" - }, r = ux.exec(t); r; ) { - try { - e[r[0]] = decodeURIComponent(r[0]); - } catch { - var n = aB(r[0]); - n !== r[0] && (e[r[0]] = n); - } - r = ux.exec(t); - } - e["%C2"] = "�"; - for (var i = Object.keys(e), s = 0; s < i.length; s++) { - var o = i[s]; - t = t.replace(new RegExp(o, "g"), e[o]); - } - return t; -} -var uB = function(t) { - if (typeof t != "string") - throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof t + "`"); - try { - return t = t.replace(/\+/g, " "), decodeURIComponent(t); - } catch { - return cB(t); - } -}, fB = (t, e) => { - if (!(typeof t == "string" && typeof e == "string")) - throw new TypeError("Expected the arguments to be of type `string`"); - if (e === "") - return [t]; - const r = t.indexOf(e); - return r === -1 ? [t] : [ - t.slice(0, r), - t.slice(r + e.length) - ]; -}, lB = function(t, e) { - for (var r = {}, n = Object.keys(t), i = Array.isArray(e), s = 0; s < n.length; s++) { - var o = n[s], a = t[o]; - (i ? e.indexOf(o) !== -1 : e(o, a, t)) && (r[o] = a); - } - return r; -}; -(function(t) { - const e = oB, r = uB, n = fB, i = lB, s = ($) => $ == null, o = Symbol("encodeFragmentIdentifier"); - function a($) { - switch ($.arrayFormat) { - case "index": - return (K) => (H, V) => { - const te = H.length; - return V === void 0 || $.skipNull && V === null || $.skipEmptyString && V === "" ? H : V === null ? [...H, [d(K, $), "[", te, "]"].join("")] : [ - ...H, - [d(K, $), "[", d(te, $), "]=", d(V, $)].join("") - ]; - }; - case "bracket": - return (K) => (H, V) => V === void 0 || $.skipNull && V === null || $.skipEmptyString && V === "" ? H : V === null ? [...H, [d(K, $), "[]"].join("")] : [...H, [d(K, $), "[]=", d(V, $)].join("")]; - case "colon-list-separator": - return (K) => (H, V) => V === void 0 || $.skipNull && V === null || $.skipEmptyString && V === "" ? H : V === null ? [...H, [d(K, $), ":list="].join("")] : [...H, [d(K, $), ":list=", d(V, $)].join("")]; - case "comma": - case "separator": - case "bracket-separator": { - const K = $.arrayFormat === "bracket-separator" ? "[]=" : "="; - return (H) => (V, te) => te === void 0 || $.skipNull && te === null || $.skipEmptyString && te === "" ? V : (te = te === null ? "" : te, V.length === 0 ? [[d(H, $), K, d(te, $)].join("")] : [[V, d(te, $)].join($.arrayFormatSeparator)]); - } - default: - return (K) => (H, V) => V === void 0 || $.skipNull && V === null || $.skipEmptyString && V === "" ? H : V === null ? [...H, d(K, $)] : [...H, [d(K, $), "=", d(V, $)].join("")]; - } - } - function u($) { - let K; - switch ($.arrayFormat) { - case "index": - return (H, V, te) => { - if (K = /\[(\d*)\]$/.exec(H), H = H.replace(/\[\d*\]$/, ""), !K) { - te[H] = V; - return; - } - te[H] === void 0 && (te[H] = {}), te[H][K[1]] = V; - }; - case "bracket": - return (H, V, te) => { - if (K = /(\[\])$/.exec(H), H = H.replace(/\[\]$/, ""), !K) { - te[H] = V; - return; - } - if (te[H] === void 0) { - te[H] = [V]; - return; - } - te[H] = [].concat(te[H], V); - }; - case "colon-list-separator": - return (H, V, te) => { - if (K = /(:list)$/.exec(H), H = H.replace(/:list$/, ""), !K) { - te[H] = V; - return; - } - if (te[H] === void 0) { - te[H] = [V]; - return; - } - te[H] = [].concat(te[H], V); - }; - case "comma": - case "separator": - return (H, V, te) => { - const R = typeof V == "string" && V.includes($.arrayFormatSeparator), W = typeof V == "string" && !R && g(V, $).includes($.arrayFormatSeparator); - V = W ? g(V, $) : V; - const pe = R || W ? V.split($.arrayFormatSeparator).map((Ee) => g(Ee, $)) : V === null ? V : g(V, $); - te[H] = pe; - }; - case "bracket-separator": - return (H, V, te) => { - const R = /(\[\])$/.test(H); - if (H = H.replace(/\[\]$/, ""), !R) { - te[H] = V && g(V, $); - return; - } - const W = V === null ? [] : V.split($.arrayFormatSeparator).map((pe) => g(pe, $)); - if (te[H] === void 0) { - te[H] = W; - return; - } - te[H] = [].concat(te[H], W); - }; - default: - return (H, V, te) => { - if (te[H] === void 0) { - te[H] = V; - return; - } - te[H] = [].concat(te[H], V); - }; - } - } - function l($) { - if (typeof $ != "string" || $.length !== 1) - throw new TypeError("arrayFormatSeparator must be single character string"); - } - function d($, K) { - return K.encode ? K.strict ? e($) : encodeURIComponent($) : $; - } - function g($, K) { - return K.decode ? r($) : $; - } - function w($) { - return Array.isArray($) ? $.sort() : typeof $ == "object" ? w(Object.keys($)).sort((K, H) => Number(K) - Number(H)).map((K) => $[K]) : $; - } - function A($) { - const K = $.indexOf("#"); - return K !== -1 && ($ = $.slice(0, K)), $; - } - function M($) { - let K = ""; - const H = $.indexOf("#"); - return H !== -1 && (K = $.slice(H)), K; - } - function N($) { - $ = A($); - const K = $.indexOf("?"); - return K === -1 ? "" : $.slice(K + 1); - } - function L($, K) { - return K.parseNumbers && !Number.isNaN(Number($)) && typeof $ == "string" && $.trim() !== "" ? $ = Number($) : K.parseBooleans && $ !== null && ($.toLowerCase() === "true" || $.toLowerCase() === "false") && ($ = $.toLowerCase() === "true"), $; - } - function F($, K) { - K = Object.assign({ - decode: !0, - sort: !0, - arrayFormat: "none", - arrayFormatSeparator: ",", - parseNumbers: !1, - parseBooleans: !1 - }, K), l(K.arrayFormatSeparator); - const H = u(K), V = /* @__PURE__ */ Object.create(null); - if (typeof $ != "string" || ($ = $.trim().replace(/^[?#&]/, ""), !$)) - return V; - for (const te of $.split("&")) { - if (te === "") - continue; - let [R, W] = n(K.decode ? te.replace(/\+/g, " ") : te, "="); - W = W === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(K.arrayFormat) ? W : g(W, K), H(g(R, K), W, V); - } - for (const te of Object.keys(V)) { - const R = V[te]; - if (typeof R == "object" && R !== null) - for (const W of Object.keys(R)) - R[W] = L(R[W], K); - else - V[te] = L(R, K); - } - return K.sort === !1 ? V : (K.sort === !0 ? Object.keys(V).sort() : Object.keys(V).sort(K.sort)).reduce((te, R) => { - const W = V[R]; - return W && typeof W == "object" && !Array.isArray(W) ? te[R] = w(W) : te[R] = W, te; - }, /* @__PURE__ */ Object.create(null)); - } - t.extract = N, t.parse = F, t.stringify = ($, K) => { - if (!$) - return ""; - K = Object.assign({ - encode: !0, - strict: !0, - arrayFormat: "none", - arrayFormatSeparator: "," - }, K), l(K.arrayFormatSeparator); - const H = (W) => K.skipNull && s($[W]) || K.skipEmptyString && $[W] === "", V = a(K), te = {}; - for (const W of Object.keys($)) - H(W) || (te[W] = $[W]); - const R = Object.keys(te); - return K.sort !== !1 && R.sort(K.sort), R.map((W) => { - const pe = $[W]; - return pe === void 0 ? "" : pe === null ? d(W, K) : Array.isArray(pe) ? pe.length === 0 && K.arrayFormat === "bracket-separator" ? d(W, K) + "[]" : pe.reduce(V(W), []).join("&") : d(W, K) + "=" + d(pe, K); - }).filter((W) => W.length > 0).join("&"); - }, t.parseUrl = ($, K) => { - K = Object.assign({ - decode: !0 - }, K); - const [H, V] = n($, "#"); - return Object.assign( - { - url: H.split("?")[0] || "", - query: F(N($), K) - }, - K && K.parseFragmentIdentifier && V ? { fragmentIdentifier: g(V, K) } : {} - ); - }, t.stringifyUrl = ($, K) => { - K = Object.assign({ - encode: !0, - strict: !0, - [o]: !0 - }, K); - const H = A($.url).split("?")[0] || "", V = t.extract($.url), te = t.parse(V, { sort: !1 }), R = Object.assign(te, $.query); - let W = t.stringify(R, K); - W && (W = `?${W}`); - let pe = M($.url); - return $.fragmentIdentifier && (pe = `#${K[o] ? d($.fragmentIdentifier, K) : $.fragmentIdentifier}`), `${H}${W}${pe}`; - }, t.pick = ($, K, H) => { - H = Object.assign({ - parseFragmentIdentifier: !0, - [o]: !1 - }, H); - const { url: V, query: te, fragmentIdentifier: R } = t.parseUrl($, H); - return t.stringifyUrl({ - url: V, - query: i(te, K), - fragmentIdentifier: R - }, H); - }, t.exclude = ($, K, H) => { - const V = Array.isArray(K) ? (te) => !K.includes(te) : (te, R) => !K(te, R); - return t.pick($, V, H); - }; -})(wl); -var H4 = { exports: {} }; -/** - * [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 - */ -(function(t) { - (function() { - var e = "input is invalid type", r = "finalize already called", n = typeof window == "object", i = n ? window : {}; - i.JS_SHA3_NO_WINDOW && (n = !1); - var s = !n && typeof self == "object", o = !i.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; - o ? i = gn : s && (i = self); - var a = !i.JS_SHA3_NO_COMMON_JS && !0 && t.exports, u = !i.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", l = "0123456789abcdef".split(""), d = [31, 7936, 2031616, 520093696], g = [4, 1024, 262144, 67108864], w = [1, 256, 65536, 16777216], A = [6, 1536, 393216, 100663296], M = [0, 8, 16, 24], N = [ - 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 - ], L = [224, 256, 384, 512], F = [128, 256], $ = ["hex", "buffer", "arrayBuffer", "array", "digest"], K = { - 128: 168, - 256: 136 - }; - (i.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(D) { - return Object.prototype.toString.call(D) === "[object Array]"; - }), u && (i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(D) { - return typeof D == "object" && D.buffer && D.buffer.constructor === ArrayBuffer; - }); - for (var H = function(D, oe, Z) { - return function(J) { - return new I(D, oe, D).update(J)[Z](); - }; - }, V = function(D, oe, Z) { - return function(J, Q) { - return new I(D, oe, Q).update(J)[Z](); - }; - }, te = function(D, oe, Z) { - return function(J, Q, T, X) { - return f["cshake" + D].update(J, Q, T, X)[Z](); - }; - }, R = function(D, oe, Z) { - return function(J, Q, T, X) { - return f["kmac" + D].update(J, Q, T, X)[Z](); - }; - }, W = function(D, oe, Z, J) { - for (var Q = 0; Q < $.length; ++Q) { - var T = $[Q]; - D[T] = oe(Z, J, T); - } - return D; - }, pe = function(D, oe) { - var Z = H(D, oe, "hex"); - return Z.create = function() { - return new I(D, oe, D); - }, Z.update = function(J) { - return Z.create().update(J); - }, W(Z, H, D, oe); - }, Ee = function(D, oe) { - var Z = V(D, oe, "hex"); - return Z.create = function(J) { - return new I(D, oe, J); - }, Z.update = function(J, Q) { - return Z.create(Q).update(J); - }, W(Z, V, D, oe); - }, Y = function(D, oe) { - var Z = K[D], J = te(D, oe, "hex"); - return J.create = function(Q, T, X) { - return !T && !X ? f["shake" + D].create(Q) : new I(D, oe, Q).bytepad([T, X], Z); - }, J.update = function(Q, T, X, re) { - return J.create(T, X, re).update(Q); - }, W(J, te, D, oe); - }, S = function(D, oe) { - var Z = K[D], J = R(D, oe, "hex"); - return J.create = function(Q, T, X) { - return new B(D, oe, T).bytepad(["KMAC", X], Z).bytepad([Q], Z); - }, J.update = function(Q, T, X, re) { - return J.create(Q, X, re).update(T); - }, W(J, R, D, oe); - }, m = [ - { name: "keccak", padding: w, bits: L, createMethod: pe }, - { name: "sha3", padding: A, bits: L, createMethod: pe }, - { name: "shake", padding: d, bits: F, createMethod: Ee }, - { name: "cshake", padding: g, bits: F, createMethod: Y }, - { name: "kmac", padding: g, bits: F, createMethod: S } - ], f = {}, p = [], b = 0; b < m.length; ++b) - for (var x = m[b], _ = x.bits, E = 0; E < _.length; ++E) { - var v = x.name + "_" + _[E]; - if (p.push(v), f[v] = x.createMethod(_[E], x.padding), x.name !== "sha3") { - var P = x.name + _[E]; - p.push(P), f[P] = f[v]; - } - } - function I(D, oe, Z) { - this.blocks = [], this.s = [], this.padding = oe, this.outputBits = Z, this.reset = !0, this.finalized = !1, this.block = 0, this.start = 0, this.blockCount = 1600 - (D << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = Z >> 5, this.extraBytes = (Z & 31) >> 3; - for (var J = 0; J < 50; ++J) - this.s[J] = 0; - } - I.prototype.update = function(D) { - if (this.finalized) - throw new Error(r); - var oe, Z = typeof D; - if (Z !== "string") { - if (Z === "object") { - if (D === null) - throw new Error(e); - if (u && D.constructor === ArrayBuffer) - D = new Uint8Array(D); - else if (!Array.isArray(D) && (!u || !ArrayBuffer.isView(D))) - throw new Error(e); - } else - throw new Error(e); - oe = !0; - } - for (var J = this.blocks, Q = this.byteCount, T = D.length, X = this.blockCount, re = 0, de = this.s, ie, ue; re < T; ) { - if (this.reset) - for (this.reset = !1, J[0] = this.block, ie = 1; ie < X + 1; ++ie) - J[ie] = 0; - if (oe) - for (ie = this.start; re < T && ie < Q; ++re) - J[ie >> 2] |= D[re] << M[ie++ & 3]; - else - for (ie = this.start; re < T && ie < Q; ++re) - ue = D.charCodeAt(re), ue < 128 ? J[ie >> 2] |= ue << M[ie++ & 3] : ue < 2048 ? (J[ie >> 2] |= (192 | ue >> 6) << M[ie++ & 3], J[ie >> 2] |= (128 | ue & 63) << M[ie++ & 3]) : ue < 55296 || ue >= 57344 ? (J[ie >> 2] |= (224 | ue >> 12) << M[ie++ & 3], J[ie >> 2] |= (128 | ue >> 6 & 63) << M[ie++ & 3], J[ie >> 2] |= (128 | ue & 63) << M[ie++ & 3]) : (ue = 65536 + ((ue & 1023) << 10 | D.charCodeAt(++re) & 1023), J[ie >> 2] |= (240 | ue >> 18) << M[ie++ & 3], J[ie >> 2] |= (128 | ue >> 12 & 63) << M[ie++ & 3], J[ie >> 2] |= (128 | ue >> 6 & 63) << M[ie++ & 3], J[ie >> 2] |= (128 | ue & 63) << M[ie++ & 3]); - if (this.lastByteIndex = ie, ie >= Q) { - for (this.start = ie - Q, this.block = J[X], ie = 0; ie < X; ++ie) - de[ie] ^= J[ie]; - ce(de), this.reset = !0; - } else - this.start = ie; - } - return this; - }, I.prototype.encode = function(D, oe) { - var Z = D & 255, J = 1, Q = [Z]; - for (D = D >> 8, Z = D & 255; Z > 0; ) - Q.unshift(Z), D = D >> 8, Z = D & 255, ++J; - return oe ? Q.push(J) : Q.unshift(J), this.update(Q), Q.length; - }, I.prototype.encodeString = function(D) { - var oe, Z = typeof D; - if (Z !== "string") { - if (Z === "object") { - if (D === null) - throw new Error(e); - if (u && D.constructor === ArrayBuffer) - D = new Uint8Array(D); - else if (!Array.isArray(D) && (!u || !ArrayBuffer.isView(D))) - throw new Error(e); - } else - throw new Error(e); - oe = !0; - } - var J = 0, Q = D.length; - if (oe) - J = Q; - else - for (var T = 0; T < D.length; ++T) { - var X = D.charCodeAt(T); - X < 128 ? J += 1 : X < 2048 ? J += 2 : X < 55296 || X >= 57344 ? J += 3 : (X = 65536 + ((X & 1023) << 10 | D.charCodeAt(++T) & 1023), J += 4); - } - return J += this.encode(J * 8), this.update(D), J; - }, I.prototype.bytepad = function(D, oe) { - for (var Z = this.encode(oe), J = 0; J < D.length; ++J) - Z += this.encodeString(D[J]); - var Q = oe - Z % oe, T = []; - return T.length = Q, this.update(T), this; - }, I.prototype.finalize = function() { - if (!this.finalized) { - this.finalized = !0; - var D = this.blocks, oe = this.lastByteIndex, Z = this.blockCount, J = this.s; - if (D[oe >> 2] |= this.padding[oe & 3], this.lastByteIndex === this.byteCount) - for (D[0] = D[Z], oe = 1; oe < Z + 1; ++oe) - D[oe] = 0; - for (D[Z - 1] |= 2147483648, oe = 0; oe < Z; ++oe) - J[oe] ^= D[oe]; - ce(J); - } - }, I.prototype.toString = I.prototype.hex = function() { - this.finalize(); - for (var D = this.blockCount, oe = this.s, Z = this.outputBlocks, J = this.extraBytes, Q = 0, T = 0, X = "", re; T < Z; ) { - for (Q = 0; Q < D && T < Z; ++Q, ++T) - re = oe[Q], X += l[re >> 4 & 15] + l[re & 15] + l[re >> 12 & 15] + l[re >> 8 & 15] + l[re >> 20 & 15] + l[re >> 16 & 15] + l[re >> 28 & 15] + l[re >> 24 & 15]; - T % D === 0 && (ce(oe), Q = 0); - } - return J && (re = oe[Q], X += l[re >> 4 & 15] + l[re & 15], J > 1 && (X += l[re >> 12 & 15] + l[re >> 8 & 15]), J > 2 && (X += l[re >> 20 & 15] + l[re >> 16 & 15])), X; - }, I.prototype.arrayBuffer = function() { - this.finalize(); - var D = this.blockCount, oe = this.s, Z = this.outputBlocks, J = this.extraBytes, Q = 0, T = 0, X = this.outputBits >> 3, re; - J ? re = new ArrayBuffer(Z + 1 << 2) : re = new ArrayBuffer(X); - for (var de = new Uint32Array(re); T < Z; ) { - for (Q = 0; Q < D && T < Z; ++Q, ++T) - de[T] = oe[Q]; - T % D === 0 && ce(oe); - } - return J && (de[Q] = oe[Q], re = re.slice(0, X)), re; - }, I.prototype.buffer = I.prototype.arrayBuffer, I.prototype.digest = I.prototype.array = function() { - this.finalize(); - for (var D = this.blockCount, oe = this.s, Z = this.outputBlocks, J = this.extraBytes, Q = 0, T = 0, X = [], re, de; T < Z; ) { - for (Q = 0; Q < D && T < Z; ++Q, ++T) - re = T << 2, de = oe[Q], X[re] = de & 255, X[re + 1] = de >> 8 & 255, X[re + 2] = de >> 16 & 255, X[re + 3] = de >> 24 & 255; - T % D === 0 && ce(oe); - } - return J && (re = T << 2, de = oe[Q], X[re] = de & 255, J > 1 && (X[re + 1] = de >> 8 & 255), J > 2 && (X[re + 2] = de >> 16 & 255)), X; - }; - function B(D, oe, Z) { - I.call(this, D, oe, Z); - } - B.prototype = new I(), B.prototype.finalize = function() { - return this.encode(this.outputBits, !0), I.prototype.finalize.call(this); - }; - var ce = function(D) { - var oe, Z, J, Q, T, X, re, de, ie, ue, ve, Pe, De, Ce, $e, Me, Ne, Ke, Le, qe, ze, _e, Ze, at, ke, Qe, tt, Ye, dt, lt, ct, qt, Yt, Et, Qt, Jt, Dt, kt, Ct, gt, Rt, Nt, vt, $t, Bt, rt, Ft, k, j, z, C, G, U, se, he, xe, Te, Re, nt, Ue, pt, it, et; - for (J = 0; J < 48; J += 2) - Q = D[0] ^ D[10] ^ D[20] ^ D[30] ^ D[40], T = D[1] ^ D[11] ^ D[21] ^ D[31] ^ D[41], X = D[2] ^ D[12] ^ D[22] ^ D[32] ^ D[42], re = D[3] ^ D[13] ^ D[23] ^ D[33] ^ D[43], de = D[4] ^ D[14] ^ D[24] ^ D[34] ^ D[44], ie = D[5] ^ D[15] ^ D[25] ^ D[35] ^ D[45], ue = D[6] ^ D[16] ^ D[26] ^ D[36] ^ D[46], ve = D[7] ^ D[17] ^ D[27] ^ D[37] ^ D[47], Pe = D[8] ^ D[18] ^ D[28] ^ D[38] ^ D[48], De = D[9] ^ D[19] ^ D[29] ^ D[39] ^ D[49], oe = Pe ^ (X << 1 | re >>> 31), Z = De ^ (re << 1 | X >>> 31), D[0] ^= oe, D[1] ^= Z, D[10] ^= oe, D[11] ^= Z, D[20] ^= oe, D[21] ^= Z, D[30] ^= oe, D[31] ^= Z, D[40] ^= oe, D[41] ^= Z, oe = Q ^ (de << 1 | ie >>> 31), Z = T ^ (ie << 1 | de >>> 31), D[2] ^= oe, D[3] ^= Z, D[12] ^= oe, D[13] ^= Z, D[22] ^= oe, D[23] ^= Z, D[32] ^= oe, D[33] ^= Z, D[42] ^= oe, D[43] ^= Z, oe = X ^ (ue << 1 | ve >>> 31), Z = re ^ (ve << 1 | ue >>> 31), D[4] ^= oe, D[5] ^= Z, D[14] ^= oe, D[15] ^= Z, D[24] ^= oe, D[25] ^= Z, D[34] ^= oe, D[35] ^= Z, D[44] ^= oe, D[45] ^= Z, oe = de ^ (Pe << 1 | De >>> 31), Z = ie ^ (De << 1 | Pe >>> 31), D[6] ^= oe, D[7] ^= Z, D[16] ^= oe, D[17] ^= Z, D[26] ^= oe, D[27] ^= Z, D[36] ^= oe, D[37] ^= Z, D[46] ^= oe, D[47] ^= Z, oe = ue ^ (Q << 1 | T >>> 31), Z = ve ^ (T << 1 | Q >>> 31), D[8] ^= oe, D[9] ^= Z, D[18] ^= oe, D[19] ^= Z, D[28] ^= oe, D[29] ^= Z, D[38] ^= oe, D[39] ^= Z, D[48] ^= oe, D[49] ^= Z, Ce = D[0], $e = D[1], rt = D[11] << 4 | D[10] >>> 28, Ft = D[10] << 4 | D[11] >>> 28, Ye = D[20] << 3 | D[21] >>> 29, dt = D[21] << 3 | D[20] >>> 29, Ue = D[31] << 9 | D[30] >>> 23, pt = D[30] << 9 | D[31] >>> 23, Nt = D[40] << 18 | D[41] >>> 14, vt = D[41] << 18 | D[40] >>> 14, Et = D[2] << 1 | D[3] >>> 31, Qt = D[3] << 1 | D[2] >>> 31, Me = D[13] << 12 | D[12] >>> 20, Ne = D[12] << 12 | D[13] >>> 20, k = D[22] << 10 | D[23] >>> 22, j = D[23] << 10 | D[22] >>> 22, lt = D[33] << 13 | D[32] >>> 19, ct = D[32] << 13 | D[33] >>> 19, it = D[42] << 2 | D[43] >>> 30, et = D[43] << 2 | D[42] >>> 30, se = D[5] << 30 | D[4] >>> 2, he = D[4] << 30 | D[5] >>> 2, Jt = D[14] << 6 | D[15] >>> 26, Dt = D[15] << 6 | D[14] >>> 26, Ke = D[25] << 11 | D[24] >>> 21, Le = D[24] << 11 | D[25] >>> 21, z = D[34] << 15 | D[35] >>> 17, C = D[35] << 15 | D[34] >>> 17, qt = D[45] << 29 | D[44] >>> 3, Yt = D[44] << 29 | D[45] >>> 3, at = D[6] << 28 | D[7] >>> 4, ke = D[7] << 28 | D[6] >>> 4, xe = D[17] << 23 | D[16] >>> 9, Te = D[16] << 23 | D[17] >>> 9, kt = D[26] << 25 | D[27] >>> 7, Ct = D[27] << 25 | D[26] >>> 7, qe = D[36] << 21 | D[37] >>> 11, ze = D[37] << 21 | D[36] >>> 11, G = D[47] << 24 | D[46] >>> 8, U = D[46] << 24 | D[47] >>> 8, $t = D[8] << 27 | D[9] >>> 5, Bt = D[9] << 27 | D[8] >>> 5, Qe = D[18] << 20 | D[19] >>> 12, tt = D[19] << 20 | D[18] >>> 12, Re = D[29] << 7 | D[28] >>> 25, nt = D[28] << 7 | D[29] >>> 25, gt = D[38] << 8 | D[39] >>> 24, Rt = D[39] << 8 | D[38] >>> 24, _e = D[48] << 14 | D[49] >>> 18, Ze = D[49] << 14 | D[48] >>> 18, D[0] = Ce ^ ~Me & Ke, D[1] = $e ^ ~Ne & Le, D[10] = at ^ ~Qe & Ye, D[11] = ke ^ ~tt & dt, D[20] = Et ^ ~Jt & kt, D[21] = Qt ^ ~Dt & Ct, D[30] = $t ^ ~rt & k, D[31] = Bt ^ ~Ft & j, D[40] = se ^ ~xe & Re, D[41] = he ^ ~Te & nt, D[2] = Me ^ ~Ke & qe, D[3] = Ne ^ ~Le & ze, D[12] = Qe ^ ~Ye & lt, D[13] = tt ^ ~dt & ct, D[22] = Jt ^ ~kt & gt, D[23] = Dt ^ ~Ct & Rt, D[32] = rt ^ ~k & z, D[33] = Ft ^ ~j & C, D[42] = xe ^ ~Re & Ue, D[43] = Te ^ ~nt & pt, D[4] = Ke ^ ~qe & _e, D[5] = Le ^ ~ze & Ze, D[14] = Ye ^ ~lt & qt, D[15] = dt ^ ~ct & Yt, D[24] = kt ^ ~gt & Nt, D[25] = Ct ^ ~Rt & vt, D[34] = k ^ ~z & G, D[35] = j ^ ~C & U, D[44] = Re ^ ~Ue & it, D[45] = nt ^ ~pt & et, D[6] = qe ^ ~_e & Ce, D[7] = ze ^ ~Ze & $e, D[16] = lt ^ ~qt & at, D[17] = ct ^ ~Yt & ke, D[26] = gt ^ ~Nt & Et, D[27] = Rt ^ ~vt & Qt, D[36] = z ^ ~G & $t, D[37] = C ^ ~U & Bt, D[46] = Ue ^ ~it & se, D[47] = pt ^ ~et & he, D[8] = _e ^ ~Ce & Me, D[9] = Ze ^ ~$e & Ne, D[18] = qt ^ ~at & Qe, D[19] = Yt ^ ~ke & tt, D[28] = Nt ^ ~Et & Jt, D[29] = vt ^ ~Qt & Dt, D[38] = G ^ ~$t & rt, D[39] = U ^ ~Bt & Ft, D[48] = it ^ ~se & xe, D[49] = et ^ ~he & Te, D[0] ^= N[J], D[1] ^= N[J + 1]; - }; - if (a) - t.exports = f; - else - for (b = 0; b < p.length; ++b) - i[p[b]] = f[p[b]]; - })(); -})(H4); -var hB = H4.exports; -const dB = /* @__PURE__ */ ts(hB), pB = "logger/5.7.0"; -let fx = !1, lx = !1; -const Sd = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; -let hx = Sd.default, Zg = null; -function gB() { - try { - const t = []; - if (["NFD", "NFC", "NFKD", "NFKC"].forEach((e) => { - try { - if ("test".normalize(e) !== "test") - throw new Error("bad normalize"); - } catch { - t.push(e); - } - }), t.length) - throw new Error("missing " + t.join(", ")); - if ("é".normalize("NFD") !== "é") - throw new Error("broken implementation"); - } catch (t) { - return t.message; - } - return null; -} -const dx = gB(); -var y1; -(function(t) { - t.DEBUG = "DEBUG", t.INFO = "INFO", t.WARNING = "WARNING", t.ERROR = "ERROR", t.OFF = "OFF"; -})(y1 || (y1 = {})); -var ys; -(function(t) { - t.UNKNOWN_ERROR = "UNKNOWN_ERROR", t.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", t.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", t.NETWORK_ERROR = "NETWORK_ERROR", t.SERVER_ERROR = "SERVER_ERROR", t.TIMEOUT = "TIMEOUT", t.BUFFER_OVERRUN = "BUFFER_OVERRUN", t.NUMERIC_FAULT = "NUMERIC_FAULT", t.MISSING_NEW = "MISSING_NEW", t.INVALID_ARGUMENT = "INVALID_ARGUMENT", t.MISSING_ARGUMENT = "MISSING_ARGUMENT", t.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", t.CALL_EXCEPTION = "CALL_EXCEPTION", t.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", t.NONCE_EXPIRED = "NONCE_EXPIRED", t.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", t.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", t.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", t.ACTION_REJECTED = "ACTION_REJECTED"; -})(ys || (ys = {})); -const px = "0123456789abcdef"; -class Yr { - constructor(e) { - Object.defineProperty(this, "version", { - enumerable: !0, - value: e, - writable: !1 - }); - } - _log(e, r) { - const n = e.toLowerCase(); - Sd[n] == null && this.throwArgumentError("invalid log level name", "logLevel", e), !(hx > Sd[n]) && console.log.apply(console, r); - } - debug(...e) { - this._log(Yr.levels.DEBUG, e); - } - info(...e) { - this._log(Yr.levels.INFO, e); - } - warn(...e) { - this._log(Yr.levels.WARNING, e); - } - makeError(e, r, n) { - if (lx) - return this.makeError("censored error", r, {}); - r || (r = Yr.errors.UNKNOWN_ERROR), n || (n = {}); - const i = []; - Object.keys(n).forEach((u) => { - const l = n[u]; - try { - if (l instanceof Uint8Array) { - let d = ""; - for (let g = 0; g < l.length; g++) - d += px[l[g] >> 4], d += px[l[g] & 15]; - i.push(u + "=Uint8Array(0x" + d + ")"); - } else - i.push(u + "=" + JSON.stringify(l)); - } catch { - i.push(u + "=" + JSON.stringify(n[u].toString())); - } - }), i.push(`code=${r}`), i.push(`version=${this.version}`); - const s = e; - let o = ""; - switch (r) { - case ys.NUMERIC_FAULT: { - o = "NUMERIC_FAULT"; - const 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 ys.CALL_EXCEPTION: - case ys.INSUFFICIENT_FUNDS: - case ys.MISSING_NEW: - case ys.NONCE_EXPIRED: - case ys.REPLACEMENT_UNDERPRICED: - case ys.TRANSACTION_REPLACED: - case ys.UNPREDICTABLE_GAS_LIMIT: - o = r; - break; - } - o && (e += " [ See: https://links.ethers.org/v5-errors-" + o + " ]"), i.length && (e += " (" + i.join(", ") + ")"); - const a = new Error(e); - return a.reason = s, a.code = r, Object.keys(n).forEach(function(u) { - a[u] = n[u]; - }), a; - } - throwError(e, r, n) { - throw this.makeError(e, r, n); - } - throwArgumentError(e, r, n) { - return this.throwError(e, Yr.errors.INVALID_ARGUMENT, { - argument: r, - value: n - }); - } - assert(e, r, n, i) { - e || this.throwError(r, n, i); - } - assertArgument(e, r, n, i) { - e || this.throwArgumentError(r, n, i); - } - checkNormalize(e) { - dx && this.throwError("platform missing String.prototype.normalize", Yr.errors.UNSUPPORTED_OPERATION, { - operation: "String.prototype.normalize", - form: dx - }); - } - checkSafeUint53(e, r) { - typeof e == "number" && (r == null && (r = "value not safe"), (e < 0 || e >= 9007199254740991) && this.throwError(r, Yr.errors.NUMERIC_FAULT, { - operation: "checkSafeInteger", - fault: "out-of-safe-range", - value: e - }), e % 1 && this.throwError(r, Yr.errors.NUMERIC_FAULT, { - operation: "checkSafeInteger", - fault: "non-integer", - value: e - })); - } - checkArgumentCount(e, r, n) { - n ? n = ": " + n : n = "", e < r && this.throwError("missing argument" + n, Yr.errors.MISSING_ARGUMENT, { - count: e, - expectedCount: r - }), e > r && this.throwError("too many arguments" + n, Yr.errors.UNEXPECTED_ARGUMENT, { - count: e, - expectedCount: r - }); - } - checkNew(e, r) { - (e === Object || e == null) && this.throwError("missing new", Yr.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", Yr.errors.UNSUPPORTED_OPERATION, { name: e.name, operation: "new" }) : (e === Object || e == null) && this.throwError("missing new", Yr.errors.MISSING_NEW, { name: r.name }); - } - static globalLogger() { - return Zg || (Zg = new Yr(pB)), Zg; - } - static setCensorship(e, r) { - if (!e && r && this.globalLogger().throwError("cannot permanently disable censorship", Yr.errors.UNSUPPORTED_OPERATION, { - operation: "setCensorship" - }), fx) { - if (!e) - return; - this.globalLogger().throwError("error censorship permanent", Yr.errors.UNSUPPORTED_OPERATION, { - operation: "setCensorship" - }); - } - lx = !!e, fx = !!r; - } - static setLogLevel(e) { - const r = Sd[e.toLowerCase()]; - if (r == null) { - Yr.globalLogger().warn("invalid log level - " + e); - return; - } - hx = r; - } - static from(e) { - return new Yr(e); - } -} -Yr.errors = ys; -Yr.levels = y1; -const mB = "bytes/5.7.0", hn = new Yr(mB); -function W4(t) { - return !!t.toHexString; -} -function uu(t) { - return t.slice || (t.slice = function() { - const e = Array.prototype.slice.call(arguments); - return uu(new Uint8Array(Array.prototype.slice.apply(t, e))); - }), t; -} -function vB(t) { - return qs(t) && !(t.length % 2) || Uv(t); -} -function gx(t) { - return typeof t == "number" && t == t && t % 1 === 0; -} -function Uv(t) { - if (t == null) - return !1; - if (t.constructor === Uint8Array) - return !0; - if (typeof t == "string" || !gx(t.length) || t.length < 0) - return !1; - for (let e = 0; e < t.length; e++) { - const r = t[e]; - if (!gx(r) || r < 0 || r >= 256) - return !1; - } - return !0; -} -function wn(t, e) { - if (e || (e = {}), typeof t == "number") { - hn.checkSafeUint53(t, "invalid arrayify value"); - const r = []; - for (; t; ) - r.unshift(t & 255), t = parseInt(String(t / 256)); - return r.length === 0 && r.push(0), uu(new Uint8Array(r)); - } - if (e.allowMissingPrefix && typeof t == "string" && t.substring(0, 2) !== "0x" && (t = "0x" + t), W4(t) && (t = t.toHexString()), qs(t)) { - let r = t.substring(2); - r.length % 2 && (e.hexPad === "left" ? r = "0" + r : e.hexPad === "right" ? r += "0" : hn.throwArgumentError("hex data is odd-length", "value", t)); - const n = []; - for (let i = 0; i < r.length; i += 2) - n.push(parseInt(r.substring(i, i + 2), 16)); - return uu(new Uint8Array(n)); - } - return Uv(t) ? uu(new Uint8Array(t)) : hn.throwArgumentError("invalid arrayify value", "value", t); -} -function bB(t) { - const e = t.map((i) => wn(i)), r = e.reduce((i, s) => i + s.length, 0), n = new Uint8Array(r); - return e.reduce((i, s) => (n.set(s, i), i + s.length), 0), uu(n); -} -function yB(t, e) { - t = wn(t), t.length > e && hn.throwArgumentError("value out of range", "value", arguments[0]); - const r = new Uint8Array(e); - return r.set(t, e - t.length), uu(r); -} -function qs(t, e) { - return !(typeof t != "string" || !t.match(/^0x[0-9A-Fa-f]*$/) || e && t.length !== 2 + 2 * e); -} -const Qg = "0123456789abcdef"; -function Ti(t, e) { - if (e || (e = {}), typeof t == "number") { - hn.checkSafeUint53(t, "invalid hexlify value"); - let r = ""; - for (; t; ) - r = Qg[t & 15] + r, t = Math.floor(t / 16); - return r.length ? (r.length % 2 && (r = "0" + r), "0x" + r) : "0x00"; - } - if (typeof t == "bigint") - return t = t.toString(16), t.length % 2 ? "0x0" + t : "0x" + t; - if (e.allowMissingPrefix && typeof t == "string" && t.substring(0, 2) !== "0x" && (t = "0x" + t), W4(t)) - return t.toHexString(); - if (qs(t)) - return t.length % 2 && (e.hexPad === "left" ? t = "0x0" + t.substring(2) : e.hexPad === "right" ? t += "0" : hn.throwArgumentError("hex data is odd-length", "value", t)), t.toLowerCase(); - if (Uv(t)) { - let r = "0x"; - for (let n = 0; n < t.length; n++) { - let i = t[n]; - r += Qg[(i & 240) >> 4] + Qg[i & 15]; - } - return r; - } - return hn.throwArgumentError("invalid hexlify value", "value", t); -} -function wB(t) { - if (typeof t != "string") - t = Ti(t); - else if (!qs(t) || t.length % 2) - return null; - return (t.length - 2) / 2; -} -function mx(t, e, r) { - return typeof t != "string" ? t = Ti(t) : (!qs(t) || t.length % 2) && hn.throwArgumentError("invalid hexData", "value", t), e = 2 + 2 * e, "0x" + t.substring(e); -} -function fu(t, e) { - for (typeof t != "string" ? t = Ti(t) : qs(t) || hn.throwArgumentError("invalid hex string", "value", t), t.length > 2 * e + 2 && hn.throwArgumentError("value out of range", "value", arguments[1]); t.length < 2 * e + 2; ) - t = "0x0" + t.substring(2); - return t; -} -function K4(t) { - const e = { - r: "0x", - s: "0x", - _vs: "0x", - recoveryParam: 0, - v: 0, - yParityAndS: "0x", - compact: "0x" - }; - if (vB(t)) { - let r = wn(t); - r.length === 64 ? (e.v = 27 + (r[32] >> 7), r[32] &= 127, e.r = Ti(r.slice(0, 32)), e.s = Ti(r.slice(32, 64))) : r.length === 65 ? (e.r = Ti(r.slice(0, 32)), e.s = Ti(r.slice(32, 64)), e.v = r[64]) : hn.throwArgumentError("invalid signature string", "signature", t), e.v < 27 && (e.v === 0 || e.v === 1 ? e.v += 27 : hn.throwArgumentError("signature invalid v byte", "signature", t)), e.recoveryParam = 1 - e.v % 2, e.recoveryParam && (r[32] |= 128), e._vs = Ti(r.slice(32, 64)); - } else { - if (e.r = t.r, e.s = t.s, e.v = t.v, e.recoveryParam = t.recoveryParam, e._vs = t._vs, e._vs != null) { - const i = yB(wn(e._vs), 32); - e._vs = Ti(i); - const s = i[0] >= 128 ? 1 : 0; - e.recoveryParam == null ? e.recoveryParam = s : e.recoveryParam !== s && hn.throwArgumentError("signature recoveryParam mismatch _vs", "signature", t), i[0] &= 127; - const o = Ti(i); - e.s == null ? e.s = o : e.s !== o && hn.throwArgumentError("signature v mismatch _vs", "signature", t); - } - if (e.recoveryParam == null) - e.v == null ? hn.throwArgumentError("signature missing v and recoveryParam", "signature", t) : 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 { - const i = e.v === 0 || e.v === 1 ? e.v : 1 - e.v % 2; - e.recoveryParam !== i && hn.throwArgumentError("signature recoveryParam mismatch v", "signature", t); - } - e.r == null || !qs(e.r) ? hn.throwArgumentError("signature missing or invalid r", "signature", t) : e.r = fu(e.r, 32), e.s == null || !qs(e.s) ? hn.throwArgumentError("signature missing or invalid s", "signature", t) : e.s = fu(e.s, 32); - const r = wn(e.s); - r[0] >= 128 && hn.throwArgumentError("signature s out of range", "signature", t), e.recoveryParam && (r[0] |= 128); - const n = Ti(r); - e._vs && (qs(e._vs) || hn.throwArgumentError("signature invalid _vs", "signature", t), e._vs = fu(e._vs, 32)), e._vs == null ? e._vs = n : e._vs !== n && hn.throwArgumentError("signature _vs mismatch v and s", "signature", t); - } - return e.yParityAndS = e._vs, e.compact = e.r + e.yParityAndS.substring(2), e; -} -function jv(t) { - return "0x" + dB.keccak_256(wn(t)); -} -var qv = { exports: {} }; -qv.exports; -(function(t) { - (function(e, r) { - function n(m, f) { - if (!m) throw new Error(f || "Assertion failed"); - } - function i(m, f) { - m.super_ = f; - var p = function() { - }; - p.prototype = f.prototype, m.prototype = new p(), m.prototype.constructor = m; - } - function s(m, f, p) { - if (s.isBN(m)) - return m; - this.negative = 0, this.words = null, this.length = 0, this.red = null, m !== null && ((f === "le" || f === "be") && (p = f, f = 10), this._init(m || 0, f || 10, p || "be")); - } - typeof e == "object" ? e.exports = s : r.BN = s, s.BN = s, s.wordSize = 26; - var o; - try { - typeof window < "u" && typeof window.Buffer < "u" ? o = window.Buffer : o = zl.Buffer; - } catch { - } - s.isBN = function(f) { - return f instanceof s ? !0 : f !== null && typeof f == "object" && f.constructor.wordSize === s.wordSize && Array.isArray(f.words); - }, s.max = function(f, p) { - return f.cmp(p) > 0 ? f : p; - }, s.min = function(f, p) { - return f.cmp(p) < 0 ? f : p; - }, s.prototype._init = function(f, p, b) { - if (typeof f == "number") - return this._initNumber(f, p, b); - if (typeof f == "object") - return this._initArray(f, p, b); - p === "hex" && (p = 16), n(p === (p | 0) && p >= 2 && p <= 36), f = f.toString().replace(/\s+/g, ""); - var x = 0; - f[0] === "-" && (x++, this.negative = 1), x < f.length && (p === 16 ? this._parseHex(f, x, b) : (this._parseBase(f, p, x), b === "le" && this._initArray(this.toArray(), p, b))); - }, s.prototype._initNumber = function(f, p, b) { - f < 0 && (this.negative = 1, f = -f), f < 67108864 ? (this.words = [f & 67108863], this.length = 1) : f < 4503599627370496 ? (this.words = [ - f & 67108863, - f / 67108864 & 67108863 - ], this.length = 2) : (n(f < 9007199254740992), this.words = [ - f & 67108863, - f / 67108864 & 67108863, - 1 - ], this.length = 3), b === "le" && this._initArray(this.toArray(), p, b); - }, s.prototype._initArray = function(f, p, b) { - if (n(typeof f.length == "number"), f.length <= 0) - return this.words = [0], this.length = 1, this; - this.length = Math.ceil(f.length / 3), this.words = new Array(this.length); - for (var x = 0; x < this.length; x++) - this.words[x] = 0; - var _, E, v = 0; - if (b === "be") - for (x = f.length - 1, _ = 0; x >= 0; x -= 3) - E = f[x] | f[x - 1] << 8 | f[x - 2] << 16, this.words[_] |= E << v & 67108863, this.words[_ + 1] = E >>> 26 - v & 67108863, v += 24, v >= 26 && (v -= 26, _++); - else if (b === "le") - for (x = 0, _ = 0; x < f.length; x += 3) - E = f[x] | f[x + 1] << 8 | f[x + 2] << 16, this.words[_] |= E << v & 67108863, this.words[_ + 1] = E >>> 26 - v & 67108863, v += 24, v >= 26 && (v -= 26, _++); - return this._strip(); - }; - function a(m, f) { - var p = m.charCodeAt(f); - if (p >= 48 && p <= 57) - return p - 48; - if (p >= 65 && p <= 70) - return p - 55; - if (p >= 97 && p <= 102) - return p - 87; - n(!1, "Invalid character in " + m); - } - function u(m, f, p) { - var b = a(m, p); - return p - 1 >= f && (b |= a(m, p - 1) << 4), b; - } - s.prototype._parseHex = function(f, p, b) { - this.length = Math.ceil((f.length - p) / 6), this.words = new Array(this.length); - for (var x = 0; x < this.length; x++) - this.words[x] = 0; - var _ = 0, E = 0, v; - if (b === "be") - for (x = f.length - 1; x >= p; x -= 2) - v = u(f, p, x) << _, this.words[E] |= v & 67108863, _ >= 18 ? (_ -= 18, E += 1, this.words[E] |= v >>> 26) : _ += 8; - else { - var P = f.length - p; - for (x = P % 2 === 0 ? p + 1 : p; x < f.length; x += 2) - v = u(f, p, x) << _, this.words[E] |= v & 67108863, _ >= 18 ? (_ -= 18, E += 1, this.words[E] |= v >>> 26) : _ += 8; - } - this._strip(); - }; - function l(m, f, p, b) { - for (var x = 0, _ = 0, E = Math.min(m.length, p), v = f; v < E; v++) { - var P = m.charCodeAt(v) - 48; - x *= b, P >= 49 ? _ = P - 49 + 10 : P >= 17 ? _ = P - 17 + 10 : _ = P, n(P >= 0 && _ < b, "Invalid character"), x += _; - } - return x; - } - s.prototype._parseBase = function(f, p, b) { - this.words = [0], this.length = 1; - for (var x = 0, _ = 1; _ <= 67108863; _ *= p) - x++; - x--, _ = _ / p | 0; - for (var E = f.length - b, v = E % x, P = Math.min(E, E - v) + b, I = 0, B = b; B < P; B += x) - I = l(f, B, B + x, p), this.imuln(_), this.words[0] + I < 67108864 ? this.words[0] += I : this._iaddn(I); - if (v !== 0) { - var ce = 1; - for (I = l(f, B, f.length, p), B = 0; B < v; B++) - ce *= p; - this.imuln(ce), this.words[0] + I < 67108864 ? this.words[0] += I : this._iaddn(I); - } - this._strip(); - }, s.prototype.copy = function(f) { - f.words = new Array(this.length); - for (var p = 0; p < this.length; p++) - f.words[p] = this.words[p]; - f.length = this.length, f.negative = this.negative, f.red = this.red; - }; - function d(m, f) { - m.words = f.words, m.length = f.length, m.negative = f.negative, m.red = f.red; - } - if (s.prototype._move = function(f) { - d(f, this); - }, s.prototype.clone = function() { - var f = new s(null); - return this.copy(f), f; - }, s.prototype._expand = function(f) { - for (; this.length < f; ) - this.words[this.length++] = 0; - return this; - }, s.prototype._strip = function() { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) - this.length--; - return this._normSign(); - }, s.prototype._normSign = function() { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }, typeof Symbol < "u" && typeof Symbol.for == "function") - try { - s.prototype[Symbol.for("nodejs.util.inspect.custom")] = g; - } catch { - s.prototype.inspect = g; - } - else - s.prototype.inspect = g; - function g() { - return (this.red ? ""; - } - var w = [ - "", - "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" - ], A = [ - 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 - ], M = [ - 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 - ]; - s.prototype.toString = function(f, p) { - f = f || 10, p = p | 0 || 1; - var b; - if (f === 16 || f === "hex") { - b = ""; - for (var x = 0, _ = 0, E = 0; E < this.length; E++) { - var v = this.words[E], P = ((v << x | _) & 16777215).toString(16); - _ = v >>> 24 - x & 16777215, x += 2, x >= 26 && (x -= 26, E--), _ !== 0 || E !== this.length - 1 ? b = w[6 - P.length] + P + b : b = P + b; - } - for (_ !== 0 && (b = _.toString(16) + b); b.length % p !== 0; ) - b = "0" + b; - return this.negative !== 0 && (b = "-" + b), b; - } - if (f === (f | 0) && f >= 2 && f <= 36) { - var I = A[f], B = M[f]; - b = ""; - var ce = this.clone(); - for (ce.negative = 0; !ce.isZero(); ) { - var D = ce.modrn(B).toString(f); - ce = ce.idivn(B), ce.isZero() ? b = D + b : b = w[I - D.length] + D + b; - } - for (this.isZero() && (b = "0" + b); b.length % p !== 0; ) - b = "0" + b; - return this.negative !== 0 && (b = "-" + b), b; - } - n(!1, "Base should be between 2 and 36"); - }, s.prototype.toNumber = function() { - var f = this.words[0]; - return this.length === 2 ? f += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? f += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && n(!1, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -f : f; - }, s.prototype.toJSON = function() { - return this.toString(16, 2); - }, o && (s.prototype.toBuffer = function(f, p) { - return this.toArrayLike(o, f, p); - }), s.prototype.toArray = function(f, p) { - return this.toArrayLike(Array, f, p); - }; - var N = function(f, p) { - return f.allocUnsafe ? f.allocUnsafe(p) : new f(p); - }; - s.prototype.toArrayLike = function(f, p, b) { - this._strip(); - var x = this.byteLength(), _ = b || Math.max(1, x); - n(x <= _, "byte array longer than desired length"), n(_ > 0, "Requested array length <= 0"); - var E = N(f, _), v = p === "le" ? "LE" : "BE"; - return this["_toArrayLike" + v](E, x), E; - }, s.prototype._toArrayLikeLE = function(f, p) { - for (var b = 0, x = 0, _ = 0, E = 0; _ < this.length; _++) { - var v = this.words[_] << E | x; - f[b++] = v & 255, b < f.length && (f[b++] = v >> 8 & 255), b < f.length && (f[b++] = v >> 16 & 255), E === 6 ? (b < f.length && (f[b++] = v >> 24 & 255), x = 0, E = 0) : (x = v >>> 24, E += 2); - } - if (b < f.length) - for (f[b++] = x; b < f.length; ) - f[b++] = 0; - }, s.prototype._toArrayLikeBE = function(f, p) { - for (var b = f.length - 1, x = 0, _ = 0, E = 0; _ < this.length; _++) { - var v = this.words[_] << E | x; - f[b--] = v & 255, b >= 0 && (f[b--] = v >> 8 & 255), b >= 0 && (f[b--] = v >> 16 & 255), E === 6 ? (b >= 0 && (f[b--] = v >> 24 & 255), x = 0, E = 0) : (x = v >>> 24, E += 2); - } - if (b >= 0) - for (f[b--] = x; b >= 0; ) - f[b--] = 0; - }, Math.clz32 ? s.prototype._countBits = function(f) { - return 32 - Math.clz32(f); - } : s.prototype._countBits = function(f) { - var p = f, b = 0; - return p >= 4096 && (b += 13, p >>>= 13), p >= 64 && (b += 7, p >>>= 7), p >= 8 && (b += 4, p >>>= 4), p >= 2 && (b += 2, p >>>= 2), b + p; - }, s.prototype._zeroBits = function(f) { - if (f === 0) return 26; - var p = f, b = 0; - return p & 8191 || (b += 13, p >>>= 13), p & 127 || (b += 7, p >>>= 7), p & 15 || (b += 4, p >>>= 4), p & 3 || (b += 2, p >>>= 2), p & 1 || b++, b; - }, s.prototype.bitLength = function() { - var f = this.words[this.length - 1], p = this._countBits(f); - return (this.length - 1) * 26 + p; - }; - function L(m) { - for (var f = new Array(m.bitLength()), p = 0; p < f.length; p++) { - var b = p / 26 | 0, x = p % 26; - f[p] = m.words[b] >>> x & 1; - } - return f; - } - s.prototype.zeroBits = function() { - if (this.isZero()) return 0; - for (var f = 0, p = 0; p < this.length; p++) { - var b = this._zeroBits(this.words[p]); - if (f += b, b !== 26) break; - } - return f; - }, s.prototype.byteLength = function() { - return Math.ceil(this.bitLength() / 8); - }, s.prototype.toTwos = function(f) { - return this.negative !== 0 ? this.abs().inotn(f).iaddn(1) : this.clone(); - }, s.prototype.fromTwos = function(f) { - return this.testn(f - 1) ? this.notn(f).iaddn(1).ineg() : this.clone(); - }, s.prototype.isNeg = function() { - return this.negative !== 0; - }, s.prototype.neg = function() { - return this.clone().ineg(); - }, s.prototype.ineg = function() { - return this.isZero() || (this.negative ^= 1), this; - }, s.prototype.iuor = function(f) { - for (; this.length < f.length; ) - this.words[this.length++] = 0; - for (var p = 0; p < f.length; p++) - this.words[p] = this.words[p] | f.words[p]; - return this._strip(); - }, s.prototype.ior = function(f) { - return n((this.negative | f.negative) === 0), this.iuor(f); - }, s.prototype.or = function(f) { - return this.length > f.length ? this.clone().ior(f) : f.clone().ior(this); - }, s.prototype.uor = function(f) { - return this.length > f.length ? this.clone().iuor(f) : f.clone().iuor(this); - }, s.prototype.iuand = function(f) { - var p; - this.length > f.length ? p = f : p = this; - for (var b = 0; b < p.length; b++) - this.words[b] = this.words[b] & f.words[b]; - return this.length = p.length, this._strip(); - }, s.prototype.iand = function(f) { - return n((this.negative | f.negative) === 0), this.iuand(f); - }, s.prototype.and = function(f) { - return this.length > f.length ? this.clone().iand(f) : f.clone().iand(this); - }, s.prototype.uand = function(f) { - return this.length > f.length ? this.clone().iuand(f) : f.clone().iuand(this); - }, s.prototype.iuxor = function(f) { - var p, b; - this.length > f.length ? (p = this, b = f) : (p = f, b = this); - for (var x = 0; x < b.length; x++) - this.words[x] = p.words[x] ^ b.words[x]; - if (this !== p) - for (; x < p.length; x++) - this.words[x] = p.words[x]; - return this.length = p.length, this._strip(); - }, s.prototype.ixor = function(f) { - return n((this.negative | f.negative) === 0), this.iuxor(f); - }, s.prototype.xor = function(f) { - return this.length > f.length ? this.clone().ixor(f) : f.clone().ixor(this); - }, s.prototype.uxor = function(f) { - return this.length > f.length ? this.clone().iuxor(f) : f.clone().iuxor(this); - }, s.prototype.inotn = function(f) { - n(typeof f == "number" && f >= 0); - var p = Math.ceil(f / 26) | 0, b = f % 26; - this._expand(p), b > 0 && p--; - for (var x = 0; x < p; x++) - this.words[x] = ~this.words[x] & 67108863; - return b > 0 && (this.words[x] = ~this.words[x] & 67108863 >> 26 - b), this._strip(); - }, s.prototype.notn = function(f) { - return this.clone().inotn(f); - }, s.prototype.setn = function(f, p) { - n(typeof f == "number" && f >= 0); - var b = f / 26 | 0, x = f % 26; - return this._expand(b + 1), p ? this.words[b] = this.words[b] | 1 << x : this.words[b] = this.words[b] & ~(1 << x), this._strip(); - }, s.prototype.iadd = function(f) { - var p; - if (this.negative !== 0 && f.negative === 0) - return this.negative = 0, p = this.isub(f), this.negative ^= 1, this._normSign(); - if (this.negative === 0 && f.negative !== 0) - return f.negative = 0, p = this.isub(f), f.negative = 1, p._normSign(); - var b, x; - this.length > f.length ? (b = this, x = f) : (b = f, x = this); - for (var _ = 0, E = 0; E < x.length; E++) - p = (b.words[E] | 0) + (x.words[E] | 0) + _, this.words[E] = p & 67108863, _ = p >>> 26; - for (; _ !== 0 && E < b.length; E++) - p = (b.words[E] | 0) + _, this.words[E] = p & 67108863, _ = p >>> 26; - if (this.length = b.length, _ !== 0) - this.words[this.length] = _, this.length++; - else if (b !== this) - for (; E < b.length; E++) - this.words[E] = b.words[E]; - return this; - }, s.prototype.add = function(f) { - var p; - return f.negative !== 0 && this.negative === 0 ? (f.negative = 0, p = this.sub(f), f.negative ^= 1, p) : f.negative === 0 && this.negative !== 0 ? (this.negative = 0, p = f.sub(this), this.negative = 1, p) : this.length > f.length ? this.clone().iadd(f) : f.clone().iadd(this); - }, s.prototype.isub = function(f) { - if (f.negative !== 0) { - f.negative = 0; - var p = this.iadd(f); - return f.negative = 1, p._normSign(); - } else if (this.negative !== 0) - return this.negative = 0, this.iadd(f), this.negative = 1, this._normSign(); - var b = this.cmp(f); - if (b === 0) - return this.negative = 0, this.length = 1, this.words[0] = 0, this; - var x, _; - b > 0 ? (x = this, _ = f) : (x = f, _ = this); - for (var E = 0, v = 0; v < _.length; v++) - p = (x.words[v] | 0) - (_.words[v] | 0) + E, E = p >> 26, this.words[v] = p & 67108863; - for (; E !== 0 && v < x.length; v++) - p = (x.words[v] | 0) + E, E = p >> 26, this.words[v] = p & 67108863; - if (E === 0 && v < x.length && x !== this) - for (; v < x.length; v++) - this.words[v] = x.words[v]; - return this.length = Math.max(this.length, v), x !== this && (this.negative = 1), this._strip(); - }, s.prototype.sub = function(f) { - return this.clone().isub(f); - }; - function F(m, f, p) { - p.negative = f.negative ^ m.negative; - var b = m.length + f.length | 0; - p.length = b, b = b - 1 | 0; - var x = m.words[0] | 0, _ = f.words[0] | 0, E = x * _, v = E & 67108863, P = E / 67108864 | 0; - p.words[0] = v; - for (var I = 1; I < b; I++) { - for (var B = P >>> 26, ce = P & 67108863, D = Math.min(I, f.length - 1), oe = Math.max(0, I - m.length + 1); oe <= D; oe++) { - var Z = I - oe | 0; - x = m.words[Z] | 0, _ = f.words[oe] | 0, E = x * _ + ce, B += E / 67108864 | 0, ce = E & 67108863; - } - p.words[I] = ce | 0, P = B | 0; - } - return P !== 0 ? p.words[I] = P | 0 : p.length--, p._strip(); - } - var $ = function(f, p, b) { - var x = f.words, _ = p.words, E = b.words, v = 0, P, I, B, ce = x[0] | 0, D = ce & 8191, oe = ce >>> 13, Z = x[1] | 0, J = Z & 8191, Q = Z >>> 13, T = x[2] | 0, X = T & 8191, re = T >>> 13, de = x[3] | 0, ie = de & 8191, ue = de >>> 13, ve = x[4] | 0, Pe = ve & 8191, De = ve >>> 13, Ce = x[5] | 0, $e = Ce & 8191, Me = Ce >>> 13, Ne = x[6] | 0, Ke = Ne & 8191, Le = Ne >>> 13, qe = x[7] | 0, ze = qe & 8191, _e = qe >>> 13, Ze = x[8] | 0, at = Ze & 8191, ke = Ze >>> 13, Qe = x[9] | 0, tt = Qe & 8191, Ye = Qe >>> 13, dt = _[0] | 0, lt = dt & 8191, ct = dt >>> 13, qt = _[1] | 0, Yt = qt & 8191, Et = qt >>> 13, Qt = _[2] | 0, Jt = Qt & 8191, Dt = Qt >>> 13, kt = _[3] | 0, Ct = kt & 8191, gt = kt >>> 13, Rt = _[4] | 0, Nt = Rt & 8191, vt = Rt >>> 13, $t = _[5] | 0, Bt = $t & 8191, rt = $t >>> 13, Ft = _[6] | 0, k = Ft & 8191, j = Ft >>> 13, z = _[7] | 0, C = z & 8191, G = z >>> 13, U = _[8] | 0, se = U & 8191, he = U >>> 13, xe = _[9] | 0, Te = xe & 8191, Re = xe >>> 13; - b.negative = f.negative ^ p.negative, b.length = 19, P = Math.imul(D, lt), I = Math.imul(D, ct), I = I + Math.imul(oe, lt) | 0, B = Math.imul(oe, ct); - var nt = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (nt >>> 26) | 0, nt &= 67108863, P = Math.imul(J, lt), I = Math.imul(J, ct), I = I + Math.imul(Q, lt) | 0, B = Math.imul(Q, ct), P = P + Math.imul(D, Yt) | 0, I = I + Math.imul(D, Et) | 0, I = I + Math.imul(oe, Yt) | 0, B = B + Math.imul(oe, Et) | 0; - var Ue = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (Ue >>> 26) | 0, Ue &= 67108863, P = Math.imul(X, lt), I = Math.imul(X, ct), I = I + Math.imul(re, lt) | 0, B = Math.imul(re, ct), P = P + Math.imul(J, Yt) | 0, I = I + Math.imul(J, Et) | 0, I = I + Math.imul(Q, Yt) | 0, B = B + Math.imul(Q, Et) | 0, P = P + Math.imul(D, Jt) | 0, I = I + Math.imul(D, Dt) | 0, I = I + Math.imul(oe, Jt) | 0, B = B + Math.imul(oe, Dt) | 0; - var pt = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (pt >>> 26) | 0, pt &= 67108863, P = Math.imul(ie, lt), I = Math.imul(ie, ct), I = I + Math.imul(ue, lt) | 0, B = Math.imul(ue, ct), P = P + Math.imul(X, Yt) | 0, I = I + Math.imul(X, Et) | 0, I = I + Math.imul(re, Yt) | 0, B = B + Math.imul(re, Et) | 0, P = P + Math.imul(J, Jt) | 0, I = I + Math.imul(J, Dt) | 0, I = I + Math.imul(Q, Jt) | 0, B = B + Math.imul(Q, Dt) | 0, P = P + Math.imul(D, Ct) | 0, I = I + Math.imul(D, gt) | 0, I = I + Math.imul(oe, Ct) | 0, B = B + Math.imul(oe, gt) | 0; - var it = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (it >>> 26) | 0, it &= 67108863, P = Math.imul(Pe, lt), I = Math.imul(Pe, ct), I = I + Math.imul(De, lt) | 0, B = Math.imul(De, ct), P = P + Math.imul(ie, Yt) | 0, I = I + Math.imul(ie, Et) | 0, I = I + Math.imul(ue, Yt) | 0, B = B + Math.imul(ue, Et) | 0, P = P + Math.imul(X, Jt) | 0, I = I + Math.imul(X, Dt) | 0, I = I + Math.imul(re, Jt) | 0, B = B + Math.imul(re, Dt) | 0, P = P + Math.imul(J, Ct) | 0, I = I + Math.imul(J, gt) | 0, I = I + Math.imul(Q, Ct) | 0, B = B + Math.imul(Q, gt) | 0, P = P + Math.imul(D, Nt) | 0, I = I + Math.imul(D, vt) | 0, I = I + Math.imul(oe, Nt) | 0, B = B + Math.imul(oe, vt) | 0; - var et = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (et >>> 26) | 0, et &= 67108863, P = Math.imul($e, lt), I = Math.imul($e, ct), I = I + Math.imul(Me, lt) | 0, B = Math.imul(Me, ct), P = P + Math.imul(Pe, Yt) | 0, I = I + Math.imul(Pe, Et) | 0, I = I + Math.imul(De, Yt) | 0, B = B + Math.imul(De, Et) | 0, P = P + Math.imul(ie, Jt) | 0, I = I + Math.imul(ie, Dt) | 0, I = I + Math.imul(ue, Jt) | 0, B = B + Math.imul(ue, Dt) | 0, P = P + Math.imul(X, Ct) | 0, I = I + Math.imul(X, gt) | 0, I = I + Math.imul(re, Ct) | 0, B = B + Math.imul(re, gt) | 0, P = P + Math.imul(J, Nt) | 0, I = I + Math.imul(J, vt) | 0, I = I + Math.imul(Q, Nt) | 0, B = B + Math.imul(Q, vt) | 0, P = P + Math.imul(D, Bt) | 0, I = I + Math.imul(D, rt) | 0, I = I + Math.imul(oe, Bt) | 0, B = B + Math.imul(oe, rt) | 0; - var St = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (St >>> 26) | 0, St &= 67108863, P = Math.imul(Ke, lt), I = Math.imul(Ke, ct), I = I + Math.imul(Le, lt) | 0, B = Math.imul(Le, ct), P = P + Math.imul($e, Yt) | 0, I = I + Math.imul($e, Et) | 0, I = I + Math.imul(Me, Yt) | 0, B = B + Math.imul(Me, Et) | 0, P = P + Math.imul(Pe, Jt) | 0, I = I + Math.imul(Pe, Dt) | 0, I = I + Math.imul(De, Jt) | 0, B = B + Math.imul(De, Dt) | 0, P = P + Math.imul(ie, Ct) | 0, I = I + Math.imul(ie, gt) | 0, I = I + Math.imul(ue, Ct) | 0, B = B + Math.imul(ue, gt) | 0, P = P + Math.imul(X, Nt) | 0, I = I + Math.imul(X, vt) | 0, I = I + Math.imul(re, Nt) | 0, B = B + Math.imul(re, vt) | 0, P = P + Math.imul(J, Bt) | 0, I = I + Math.imul(J, rt) | 0, I = I + Math.imul(Q, Bt) | 0, B = B + Math.imul(Q, rt) | 0, P = P + Math.imul(D, k) | 0, I = I + Math.imul(D, j) | 0, I = I + Math.imul(oe, k) | 0, B = B + Math.imul(oe, j) | 0; - var Tt = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (Tt >>> 26) | 0, Tt &= 67108863, P = Math.imul(ze, lt), I = Math.imul(ze, ct), I = I + Math.imul(_e, lt) | 0, B = Math.imul(_e, ct), P = P + Math.imul(Ke, Yt) | 0, I = I + Math.imul(Ke, Et) | 0, I = I + Math.imul(Le, Yt) | 0, B = B + Math.imul(Le, Et) | 0, P = P + Math.imul($e, Jt) | 0, I = I + Math.imul($e, Dt) | 0, I = I + Math.imul(Me, Jt) | 0, B = B + Math.imul(Me, Dt) | 0, P = P + Math.imul(Pe, Ct) | 0, I = I + Math.imul(Pe, gt) | 0, I = I + Math.imul(De, Ct) | 0, B = B + Math.imul(De, gt) | 0, P = P + Math.imul(ie, Nt) | 0, I = I + Math.imul(ie, vt) | 0, I = I + Math.imul(ue, Nt) | 0, B = B + Math.imul(ue, vt) | 0, P = P + Math.imul(X, Bt) | 0, I = I + Math.imul(X, rt) | 0, I = I + Math.imul(re, Bt) | 0, B = B + Math.imul(re, rt) | 0, P = P + Math.imul(J, k) | 0, I = I + Math.imul(J, j) | 0, I = I + Math.imul(Q, k) | 0, B = B + Math.imul(Q, j) | 0, P = P + Math.imul(D, C) | 0, I = I + Math.imul(D, G) | 0, I = I + Math.imul(oe, C) | 0, B = B + Math.imul(oe, G) | 0; - var At = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (At >>> 26) | 0, At &= 67108863, P = Math.imul(at, lt), I = Math.imul(at, ct), I = I + Math.imul(ke, lt) | 0, B = Math.imul(ke, ct), P = P + Math.imul(ze, Yt) | 0, I = I + Math.imul(ze, Et) | 0, I = I + Math.imul(_e, Yt) | 0, B = B + Math.imul(_e, Et) | 0, P = P + Math.imul(Ke, Jt) | 0, I = I + Math.imul(Ke, Dt) | 0, I = I + Math.imul(Le, Jt) | 0, B = B + Math.imul(Le, Dt) | 0, P = P + Math.imul($e, Ct) | 0, I = I + Math.imul($e, gt) | 0, I = I + Math.imul(Me, Ct) | 0, B = B + Math.imul(Me, gt) | 0, P = P + Math.imul(Pe, Nt) | 0, I = I + Math.imul(Pe, vt) | 0, I = I + Math.imul(De, Nt) | 0, B = B + Math.imul(De, vt) | 0, P = P + Math.imul(ie, Bt) | 0, I = I + Math.imul(ie, rt) | 0, I = I + Math.imul(ue, Bt) | 0, B = B + Math.imul(ue, rt) | 0, P = P + Math.imul(X, k) | 0, I = I + Math.imul(X, j) | 0, I = I + Math.imul(re, k) | 0, B = B + Math.imul(re, j) | 0, P = P + Math.imul(J, C) | 0, I = I + Math.imul(J, G) | 0, I = I + Math.imul(Q, C) | 0, B = B + Math.imul(Q, G) | 0, P = P + Math.imul(D, se) | 0, I = I + Math.imul(D, he) | 0, I = I + Math.imul(oe, se) | 0, B = B + Math.imul(oe, he) | 0; - var _t = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, P = Math.imul(tt, lt), I = Math.imul(tt, ct), I = I + Math.imul(Ye, lt) | 0, B = Math.imul(Ye, ct), P = P + Math.imul(at, Yt) | 0, I = I + Math.imul(at, Et) | 0, I = I + Math.imul(ke, Yt) | 0, B = B + Math.imul(ke, Et) | 0, P = P + Math.imul(ze, Jt) | 0, I = I + Math.imul(ze, Dt) | 0, I = I + Math.imul(_e, Jt) | 0, B = B + Math.imul(_e, Dt) | 0, P = P + Math.imul(Ke, Ct) | 0, I = I + Math.imul(Ke, gt) | 0, I = I + Math.imul(Le, Ct) | 0, B = B + Math.imul(Le, gt) | 0, P = P + Math.imul($e, Nt) | 0, I = I + Math.imul($e, vt) | 0, I = I + Math.imul(Me, Nt) | 0, B = B + Math.imul(Me, vt) | 0, P = P + Math.imul(Pe, Bt) | 0, I = I + Math.imul(Pe, rt) | 0, I = I + Math.imul(De, Bt) | 0, B = B + Math.imul(De, rt) | 0, P = P + Math.imul(ie, k) | 0, I = I + Math.imul(ie, j) | 0, I = I + Math.imul(ue, k) | 0, B = B + Math.imul(ue, j) | 0, P = P + Math.imul(X, C) | 0, I = I + Math.imul(X, G) | 0, I = I + Math.imul(re, C) | 0, B = B + Math.imul(re, G) | 0, P = P + Math.imul(J, se) | 0, I = I + Math.imul(J, he) | 0, I = I + Math.imul(Q, se) | 0, B = B + Math.imul(Q, he) | 0, P = P + Math.imul(D, Te) | 0, I = I + Math.imul(D, Re) | 0, I = I + Math.imul(oe, Te) | 0, B = B + Math.imul(oe, Re) | 0; - var ht = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (ht >>> 26) | 0, ht &= 67108863, P = Math.imul(tt, Yt), I = Math.imul(tt, Et), I = I + Math.imul(Ye, Yt) | 0, B = Math.imul(Ye, Et), P = P + Math.imul(at, Jt) | 0, I = I + Math.imul(at, Dt) | 0, I = I + Math.imul(ke, Jt) | 0, B = B + Math.imul(ke, Dt) | 0, P = P + Math.imul(ze, Ct) | 0, I = I + Math.imul(ze, gt) | 0, I = I + Math.imul(_e, Ct) | 0, B = B + Math.imul(_e, gt) | 0, P = P + Math.imul(Ke, Nt) | 0, I = I + Math.imul(Ke, vt) | 0, I = I + Math.imul(Le, Nt) | 0, B = B + Math.imul(Le, vt) | 0, P = P + Math.imul($e, Bt) | 0, I = I + Math.imul($e, rt) | 0, I = I + Math.imul(Me, Bt) | 0, B = B + Math.imul(Me, rt) | 0, P = P + Math.imul(Pe, k) | 0, I = I + Math.imul(Pe, j) | 0, I = I + Math.imul(De, k) | 0, B = B + Math.imul(De, j) | 0, P = P + Math.imul(ie, C) | 0, I = I + Math.imul(ie, G) | 0, I = I + Math.imul(ue, C) | 0, B = B + Math.imul(ue, G) | 0, P = P + Math.imul(X, se) | 0, I = I + Math.imul(X, he) | 0, I = I + Math.imul(re, se) | 0, B = B + Math.imul(re, he) | 0, P = P + Math.imul(J, Te) | 0, I = I + Math.imul(J, Re) | 0, I = I + Math.imul(Q, Te) | 0, B = B + Math.imul(Q, Re) | 0; - var xt = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (xt >>> 26) | 0, xt &= 67108863, P = Math.imul(tt, Jt), I = Math.imul(tt, Dt), I = I + Math.imul(Ye, Jt) | 0, B = Math.imul(Ye, Dt), P = P + Math.imul(at, Ct) | 0, I = I + Math.imul(at, gt) | 0, I = I + Math.imul(ke, Ct) | 0, B = B + Math.imul(ke, gt) | 0, P = P + Math.imul(ze, Nt) | 0, I = I + Math.imul(ze, vt) | 0, I = I + Math.imul(_e, Nt) | 0, B = B + Math.imul(_e, vt) | 0, P = P + Math.imul(Ke, Bt) | 0, I = I + Math.imul(Ke, rt) | 0, I = I + Math.imul(Le, Bt) | 0, B = B + Math.imul(Le, rt) | 0, P = P + Math.imul($e, k) | 0, I = I + Math.imul($e, j) | 0, I = I + Math.imul(Me, k) | 0, B = B + Math.imul(Me, j) | 0, P = P + Math.imul(Pe, C) | 0, I = I + Math.imul(Pe, G) | 0, I = I + Math.imul(De, C) | 0, B = B + Math.imul(De, G) | 0, P = P + Math.imul(ie, se) | 0, I = I + Math.imul(ie, he) | 0, I = I + Math.imul(ue, se) | 0, B = B + Math.imul(ue, he) | 0, P = P + Math.imul(X, Te) | 0, I = I + Math.imul(X, Re) | 0, I = I + Math.imul(re, Te) | 0, B = B + Math.imul(re, Re) | 0; - var st = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (st >>> 26) | 0, st &= 67108863, P = Math.imul(tt, Ct), I = Math.imul(tt, gt), I = I + Math.imul(Ye, Ct) | 0, B = Math.imul(Ye, gt), P = P + Math.imul(at, Nt) | 0, I = I + Math.imul(at, vt) | 0, I = I + Math.imul(ke, Nt) | 0, B = B + Math.imul(ke, vt) | 0, P = P + Math.imul(ze, Bt) | 0, I = I + Math.imul(ze, rt) | 0, I = I + Math.imul(_e, Bt) | 0, B = B + Math.imul(_e, rt) | 0, P = P + Math.imul(Ke, k) | 0, I = I + Math.imul(Ke, j) | 0, I = I + Math.imul(Le, k) | 0, B = B + Math.imul(Le, j) | 0, P = P + Math.imul($e, C) | 0, I = I + Math.imul($e, G) | 0, I = I + Math.imul(Me, C) | 0, B = B + Math.imul(Me, G) | 0, P = P + Math.imul(Pe, se) | 0, I = I + Math.imul(Pe, he) | 0, I = I + Math.imul(De, se) | 0, B = B + Math.imul(De, he) | 0, P = P + Math.imul(ie, Te) | 0, I = I + Math.imul(ie, Re) | 0, I = I + Math.imul(ue, Te) | 0, B = B + Math.imul(ue, Re) | 0; - var bt = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (bt >>> 26) | 0, bt &= 67108863, P = Math.imul(tt, Nt), I = Math.imul(tt, vt), I = I + Math.imul(Ye, Nt) | 0, B = Math.imul(Ye, vt), P = P + Math.imul(at, Bt) | 0, I = I + Math.imul(at, rt) | 0, I = I + Math.imul(ke, Bt) | 0, B = B + Math.imul(ke, rt) | 0, P = P + Math.imul(ze, k) | 0, I = I + Math.imul(ze, j) | 0, I = I + Math.imul(_e, k) | 0, B = B + Math.imul(_e, j) | 0, P = P + Math.imul(Ke, C) | 0, I = I + Math.imul(Ke, G) | 0, I = I + Math.imul(Le, C) | 0, B = B + Math.imul(Le, G) | 0, P = P + Math.imul($e, se) | 0, I = I + Math.imul($e, he) | 0, I = I + Math.imul(Me, se) | 0, B = B + Math.imul(Me, he) | 0, P = P + Math.imul(Pe, Te) | 0, I = I + Math.imul(Pe, Re) | 0, I = I + Math.imul(De, Te) | 0, B = B + Math.imul(De, Re) | 0; - var ut = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (ut >>> 26) | 0, ut &= 67108863, P = Math.imul(tt, Bt), I = Math.imul(tt, rt), I = I + Math.imul(Ye, Bt) | 0, B = Math.imul(Ye, rt), P = P + Math.imul(at, k) | 0, I = I + Math.imul(at, j) | 0, I = I + Math.imul(ke, k) | 0, B = B + Math.imul(ke, j) | 0, P = P + Math.imul(ze, C) | 0, I = I + Math.imul(ze, G) | 0, I = I + Math.imul(_e, C) | 0, B = B + Math.imul(_e, G) | 0, P = P + Math.imul(Ke, se) | 0, I = I + Math.imul(Ke, he) | 0, I = I + Math.imul(Le, se) | 0, B = B + Math.imul(Le, he) | 0, P = P + Math.imul($e, Te) | 0, I = I + Math.imul($e, Re) | 0, I = I + Math.imul(Me, Te) | 0, B = B + Math.imul(Me, Re) | 0; - var ot = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (ot >>> 26) | 0, ot &= 67108863, P = Math.imul(tt, k), I = Math.imul(tt, j), I = I + Math.imul(Ye, k) | 0, B = Math.imul(Ye, j), P = P + Math.imul(at, C) | 0, I = I + Math.imul(at, G) | 0, I = I + Math.imul(ke, C) | 0, B = B + Math.imul(ke, G) | 0, P = P + Math.imul(ze, se) | 0, I = I + Math.imul(ze, he) | 0, I = I + Math.imul(_e, se) | 0, B = B + Math.imul(_e, he) | 0, P = P + Math.imul(Ke, Te) | 0, I = I + Math.imul(Ke, Re) | 0, I = I + Math.imul(Le, Te) | 0, B = B + Math.imul(Le, Re) | 0; - var Se = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (Se >>> 26) | 0, Se &= 67108863, P = Math.imul(tt, C), I = Math.imul(tt, G), I = I + Math.imul(Ye, C) | 0, B = Math.imul(Ye, G), P = P + Math.imul(at, se) | 0, I = I + Math.imul(at, he) | 0, I = I + Math.imul(ke, se) | 0, B = B + Math.imul(ke, he) | 0, P = P + Math.imul(ze, Te) | 0, I = I + Math.imul(ze, Re) | 0, I = I + Math.imul(_e, Te) | 0, B = B + Math.imul(_e, Re) | 0; - var Ae = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (Ae >>> 26) | 0, Ae &= 67108863, P = Math.imul(tt, se), I = Math.imul(tt, he), I = I + Math.imul(Ye, se) | 0, B = Math.imul(Ye, he), P = P + Math.imul(at, Te) | 0, I = I + Math.imul(at, Re) | 0, I = I + Math.imul(ke, Te) | 0, B = B + Math.imul(ke, Re) | 0; - var Ve = (v + P | 0) + ((I & 8191) << 13) | 0; - v = (B + (I >>> 13) | 0) + (Ve >>> 26) | 0, Ve &= 67108863, P = Math.imul(tt, Te), I = Math.imul(tt, Re), I = I + Math.imul(Ye, Te) | 0, B = Math.imul(Ye, Re); - var Be = (v + P | 0) + ((I & 8191) << 13) | 0; - return v = (B + (I >>> 13) | 0) + (Be >>> 26) | 0, Be &= 67108863, E[0] = nt, E[1] = Ue, E[2] = pt, E[3] = it, E[4] = et, E[5] = St, E[6] = Tt, E[7] = At, E[8] = _t, E[9] = ht, E[10] = xt, E[11] = st, E[12] = bt, E[13] = ut, E[14] = ot, E[15] = Se, E[16] = Ae, E[17] = Ve, E[18] = Be, v !== 0 && (E[19] = v, b.length++), b; - }; - Math.imul || ($ = F); - function K(m, f, p) { - p.negative = f.negative ^ m.negative, p.length = m.length + f.length; - for (var b = 0, x = 0, _ = 0; _ < p.length - 1; _++) { - var E = x; - x = 0; - for (var v = b & 67108863, P = Math.min(_, f.length - 1), I = Math.max(0, _ - m.length + 1); I <= P; I++) { - var B = _ - I, ce = m.words[B] | 0, D = f.words[I] | 0, oe = ce * D, Z = oe & 67108863; - E = E + (oe / 67108864 | 0) | 0, Z = Z + v | 0, v = Z & 67108863, E = E + (Z >>> 26) | 0, x += E >>> 26, E &= 67108863; - } - p.words[_] = v, b = E, E = x; - } - return b !== 0 ? p.words[_] = b : p.length--, p._strip(); - } - function H(m, f, p) { - return K(m, f, p); - } - s.prototype.mulTo = function(f, p) { - var b, x = this.length + f.length; - return this.length === 10 && f.length === 10 ? b = $(this, f, p) : x < 63 ? b = F(this, f, p) : x < 1024 ? b = K(this, f, p) : b = H(this, f, p), b; - }, s.prototype.mul = function(f) { - var p = new s(null); - return p.words = new Array(this.length + f.length), this.mulTo(f, p); - }, s.prototype.mulf = function(f) { - var p = new s(null); - return p.words = new Array(this.length + f.length), H(this, f, p); - }, s.prototype.imul = function(f) { - return this.clone().mulTo(f, this); - }, s.prototype.imuln = function(f) { - var p = f < 0; - p && (f = -f), n(typeof f == "number"), n(f < 67108864); - for (var b = 0, x = 0; x < this.length; x++) { - var _ = (this.words[x] | 0) * f, E = (_ & 67108863) + (b & 67108863); - b >>= 26, b += _ / 67108864 | 0, b += E >>> 26, this.words[x] = E & 67108863; - } - return b !== 0 && (this.words[x] = b, this.length++), p ? this.ineg() : this; - }, s.prototype.muln = function(f) { - return this.clone().imuln(f); - }, s.prototype.sqr = function() { - return this.mul(this); - }, s.prototype.isqr = function() { - return this.imul(this.clone()); - }, s.prototype.pow = function(f) { - var p = L(f); - if (p.length === 0) return new s(1); - for (var b = this, x = 0; x < p.length && p[x] === 0; x++, b = b.sqr()) - ; - if (++x < p.length) - for (var _ = b.sqr(); x < p.length; x++, _ = _.sqr()) - p[x] !== 0 && (b = b.mul(_)); - return b; - }, s.prototype.iushln = function(f) { - n(typeof f == "number" && f >= 0); - var p = f % 26, b = (f - p) / 26, x = 67108863 >>> 26 - p << 26 - p, _; - if (p !== 0) { - var E = 0; - for (_ = 0; _ < this.length; _++) { - var v = this.words[_] & x, P = (this.words[_] | 0) - v << p; - this.words[_] = P | E, E = v >>> 26 - p; - } - E && (this.words[_] = E, this.length++); - } - if (b !== 0) { - for (_ = this.length - 1; _ >= 0; _--) - this.words[_ + b] = this.words[_]; - for (_ = 0; _ < b; _++) - this.words[_] = 0; - this.length += b; - } - return this._strip(); - }, s.prototype.ishln = function(f) { - return n(this.negative === 0), this.iushln(f); - }, s.prototype.iushrn = function(f, p, b) { - n(typeof f == "number" && f >= 0); - var x; - p ? x = (p - p % 26) / 26 : x = 0; - var _ = f % 26, E = Math.min((f - _) / 26, this.length), v = 67108863 ^ 67108863 >>> _ << _, P = b; - if (x -= E, x = Math.max(0, x), P) { - for (var I = 0; I < E; I++) - P.words[I] = this.words[I]; - P.length = E; - } - if (E !== 0) if (this.length > E) - for (this.length -= E, I = 0; I < this.length; I++) - this.words[I] = this.words[I + E]; - else - this.words[0] = 0, this.length = 1; - var B = 0; - for (I = this.length - 1; I >= 0 && (B !== 0 || I >= x); I--) { - var ce = this.words[I] | 0; - this.words[I] = B << 26 - _ | ce >>> _, B = ce & v; - } - return P && B !== 0 && (P.words[P.length++] = B), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); - }, s.prototype.ishrn = function(f, p, b) { - return n(this.negative === 0), this.iushrn(f, p, b); - }, s.prototype.shln = function(f) { - return this.clone().ishln(f); - }, s.prototype.ushln = function(f) { - return this.clone().iushln(f); - }, s.prototype.shrn = function(f) { - return this.clone().ishrn(f); - }, s.prototype.ushrn = function(f) { - return this.clone().iushrn(f); - }, s.prototype.testn = function(f) { - n(typeof f == "number" && f >= 0); - var p = f % 26, b = (f - p) / 26, x = 1 << p; - if (this.length <= b) return !1; - var _ = this.words[b]; - return !!(_ & x); - }, s.prototype.imaskn = function(f) { - n(typeof f == "number" && f >= 0); - var p = f % 26, b = (f - p) / 26; - if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= b) - return this; - if (p !== 0 && b++, this.length = Math.min(b, this.length), p !== 0) { - var x = 67108863 ^ 67108863 >>> p << p; - this.words[this.length - 1] &= x; - } - return this._strip(); - }, s.prototype.maskn = function(f) { - return this.clone().imaskn(f); - }, s.prototype.iaddn = function(f) { - return n(typeof f == "number"), n(f < 67108864), f < 0 ? this.isubn(-f) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= f ? (this.words[0] = f - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(f), this.negative = 1, this) : this._iaddn(f); - }, s.prototype._iaddn = function(f) { - this.words[0] += f; - for (var p = 0; p < this.length && this.words[p] >= 67108864; p++) - this.words[p] -= 67108864, p === this.length - 1 ? this.words[p + 1] = 1 : this.words[p + 1]++; - return this.length = Math.max(this.length, p + 1), this; - }, s.prototype.isubn = function(f) { - if (n(typeof f == "number"), n(f < 67108864), f < 0) return this.iaddn(-f); - if (this.negative !== 0) - return this.negative = 0, this.iaddn(f), this.negative = 1, this; - if (this.words[0] -= f, this.length === 1 && this.words[0] < 0) - this.words[0] = -this.words[0], this.negative = 1; - else - for (var p = 0; p < this.length && this.words[p] < 0; p++) - this.words[p] += 67108864, this.words[p + 1] -= 1; - return this._strip(); - }, s.prototype.addn = function(f) { - return this.clone().iaddn(f); - }, s.prototype.subn = function(f) { - return this.clone().isubn(f); - }, s.prototype.iabs = function() { - return this.negative = 0, this; - }, s.prototype.abs = function() { - return this.clone().iabs(); - }, s.prototype._ishlnsubmul = function(f, p, b) { - var x = f.length + b, _; - this._expand(x); - var E, v = 0; - for (_ = 0; _ < f.length; _++) { - E = (this.words[_ + b] | 0) + v; - var P = (f.words[_] | 0) * p; - E -= P & 67108863, v = (E >> 26) - (P / 67108864 | 0), this.words[_ + b] = E & 67108863; - } - for (; _ < this.length - b; _++) - E = (this.words[_ + b] | 0) + v, v = E >> 26, this.words[_ + b] = E & 67108863; - if (v === 0) return this._strip(); - for (n(v === -1), v = 0, _ = 0; _ < this.length; _++) - E = -(this.words[_] | 0) + v, v = E >> 26, this.words[_] = E & 67108863; - return this.negative = 1, this._strip(); - }, s.prototype._wordDiv = function(f, p) { - var b = this.length - f.length, x = this.clone(), _ = f, E = _.words[_.length - 1] | 0, v = this._countBits(E); - b = 26 - v, b !== 0 && (_ = _.ushln(b), x.iushln(b), E = _.words[_.length - 1] | 0); - var P = x.length - _.length, I; - if (p !== "mod") { - I = new s(null), I.length = P + 1, I.words = new Array(I.length); - for (var B = 0; B < I.length; B++) - I.words[B] = 0; - } - var ce = x.clone()._ishlnsubmul(_, 1, P); - ce.negative === 0 && (x = ce, I && (I.words[P] = 1)); - for (var D = P - 1; D >= 0; D--) { - var oe = (x.words[_.length + D] | 0) * 67108864 + (x.words[_.length + D - 1] | 0); - for (oe = Math.min(oe / E | 0, 67108863), x._ishlnsubmul(_, oe, D); x.negative !== 0; ) - oe--, x.negative = 0, x._ishlnsubmul(_, 1, D), x.isZero() || (x.negative ^= 1); - I && (I.words[D] = oe); - } - return I && I._strip(), x._strip(), p !== "div" && b !== 0 && x.iushrn(b), { - div: I || null, - mod: x - }; - }, s.prototype.divmod = function(f, p, b) { - if (n(!f.isZero()), this.isZero()) - return { - div: new s(0), - mod: new s(0) - }; - var x, _, E; - return this.negative !== 0 && f.negative === 0 ? (E = this.neg().divmod(f, p), p !== "mod" && (x = E.div.neg()), p !== "div" && (_ = E.mod.neg(), b && _.negative !== 0 && _.iadd(f)), { - div: x, - mod: _ - }) : this.negative === 0 && f.negative !== 0 ? (E = this.divmod(f.neg(), p), p !== "mod" && (x = E.div.neg()), { - div: x, - mod: E.mod - }) : this.negative & f.negative ? (E = this.neg().divmod(f.neg(), p), p !== "div" && (_ = E.mod.neg(), b && _.negative !== 0 && _.isub(f)), { - div: E.div, - mod: _ - }) : f.length > this.length || this.cmp(f) < 0 ? { - div: new s(0), - mod: this - } : f.length === 1 ? p === "div" ? { - div: this.divn(f.words[0]), - mod: null - } : p === "mod" ? { - div: null, - mod: new s(this.modrn(f.words[0])) - } : { - div: this.divn(f.words[0]), - mod: new s(this.modrn(f.words[0])) - } : this._wordDiv(f, p); - }, s.prototype.div = function(f) { - return this.divmod(f, "div", !1).div; - }, s.prototype.mod = function(f) { - return this.divmod(f, "mod", !1).mod; - }, s.prototype.umod = function(f) { - return this.divmod(f, "mod", !0).mod; - }, s.prototype.divRound = function(f) { - var p = this.divmod(f); - if (p.mod.isZero()) return p.div; - var b = p.div.negative !== 0 ? p.mod.isub(f) : p.mod, x = f.ushrn(1), _ = f.andln(1), E = b.cmp(x); - return E < 0 || _ === 1 && E === 0 ? p.div : p.div.negative !== 0 ? p.div.isubn(1) : p.div.iaddn(1); - }, s.prototype.modrn = function(f) { - var p = f < 0; - p && (f = -f), n(f <= 67108863); - for (var b = (1 << 26) % f, x = 0, _ = this.length - 1; _ >= 0; _--) - x = (b * x + (this.words[_] | 0)) % f; - return p ? -x : x; - }, s.prototype.modn = function(f) { - return this.modrn(f); - }, s.prototype.idivn = function(f) { - var p = f < 0; - p && (f = -f), n(f <= 67108863); - for (var b = 0, x = this.length - 1; x >= 0; x--) { - var _ = (this.words[x] | 0) + b * 67108864; - this.words[x] = _ / f | 0, b = _ % f; - } - return this._strip(), p ? this.ineg() : this; - }, s.prototype.divn = function(f) { - return this.clone().idivn(f); - }, s.prototype.egcd = function(f) { - n(f.negative === 0), n(!f.isZero()); - var p = this, b = f.clone(); - p.negative !== 0 ? p = p.umod(f) : p = p.clone(); - for (var x = new s(1), _ = new s(0), E = new s(0), v = new s(1), P = 0; p.isEven() && b.isEven(); ) - p.iushrn(1), b.iushrn(1), ++P; - for (var I = b.clone(), B = p.clone(); !p.isZero(); ) { - for (var ce = 0, D = 1; !(p.words[0] & D) && ce < 26; ++ce, D <<= 1) ; - if (ce > 0) - for (p.iushrn(ce); ce-- > 0; ) - (x.isOdd() || _.isOdd()) && (x.iadd(I), _.isub(B)), x.iushrn(1), _.iushrn(1); - for (var oe = 0, Z = 1; !(b.words[0] & Z) && oe < 26; ++oe, Z <<= 1) ; - if (oe > 0) - for (b.iushrn(oe); oe-- > 0; ) - (E.isOdd() || v.isOdd()) && (E.iadd(I), v.isub(B)), E.iushrn(1), v.iushrn(1); - p.cmp(b) >= 0 ? (p.isub(b), x.isub(E), _.isub(v)) : (b.isub(p), E.isub(x), v.isub(_)); - } - return { - a: E, - b: v, - gcd: b.iushln(P) - }; - }, s.prototype._invmp = function(f) { - n(f.negative === 0), n(!f.isZero()); - var p = this, b = f.clone(); - p.negative !== 0 ? p = p.umod(f) : p = p.clone(); - for (var x = new s(1), _ = new s(0), E = b.clone(); p.cmpn(1) > 0 && b.cmpn(1) > 0; ) { - for (var v = 0, P = 1; !(p.words[0] & P) && v < 26; ++v, P <<= 1) ; - if (v > 0) - for (p.iushrn(v); v-- > 0; ) - x.isOdd() && x.iadd(E), x.iushrn(1); - for (var I = 0, B = 1; !(b.words[0] & B) && I < 26; ++I, B <<= 1) ; - if (I > 0) - for (b.iushrn(I); I-- > 0; ) - _.isOdd() && _.iadd(E), _.iushrn(1); - p.cmp(b) >= 0 ? (p.isub(b), x.isub(_)) : (b.isub(p), _.isub(x)); - } - var ce; - return p.cmpn(1) === 0 ? ce = x : ce = _, ce.cmpn(0) < 0 && ce.iadd(f), ce; - }, s.prototype.gcd = function(f) { - if (this.isZero()) return f.abs(); - if (f.isZero()) return this.abs(); - var p = this.clone(), b = f.clone(); - p.negative = 0, b.negative = 0; - for (var x = 0; p.isEven() && b.isEven(); x++) - p.iushrn(1), b.iushrn(1); - do { - for (; p.isEven(); ) - p.iushrn(1); - for (; b.isEven(); ) - b.iushrn(1); - var _ = p.cmp(b); - if (_ < 0) { - var E = p; - p = b, b = E; - } else if (_ === 0 || b.cmpn(1) === 0) - break; - p.isub(b); - } while (!0); - return b.iushln(x); - }, s.prototype.invm = function(f) { - return this.egcd(f).a.umod(f); - }, s.prototype.isEven = function() { - return (this.words[0] & 1) === 0; - }, s.prototype.isOdd = function() { - return (this.words[0] & 1) === 1; - }, s.prototype.andln = function(f) { - return this.words[0] & f; - }, s.prototype.bincn = function(f) { - n(typeof f == "number"); - var p = f % 26, b = (f - p) / 26, x = 1 << p; - if (this.length <= b) - return this._expand(b + 1), this.words[b] |= x, this; - for (var _ = x, E = b; _ !== 0 && E < this.length; E++) { - var v = this.words[E] | 0; - v += _, _ = v >>> 26, v &= 67108863, this.words[E] = v; - } - return _ !== 0 && (this.words[E] = _, this.length++), this; - }, s.prototype.isZero = function() { - return this.length === 1 && this.words[0] === 0; - }, s.prototype.cmpn = function(f) { - var p = f < 0; - if (this.negative !== 0 && !p) return -1; - if (this.negative === 0 && p) return 1; - this._strip(); - var b; - if (this.length > 1) - b = 1; - else { - p && (f = -f), n(f <= 67108863, "Number is too big"); - var x = this.words[0] | 0; - b = x === f ? 0 : x < f ? -1 : 1; - } - return this.negative !== 0 ? -b | 0 : b; - }, s.prototype.cmp = function(f) { - if (this.negative !== 0 && f.negative === 0) return -1; - if (this.negative === 0 && f.negative !== 0) return 1; - var p = this.ucmp(f); - return this.negative !== 0 ? -p | 0 : p; - }, s.prototype.ucmp = function(f) { - if (this.length > f.length) return 1; - if (this.length < f.length) return -1; - for (var p = 0, b = this.length - 1; b >= 0; b--) { - var x = this.words[b] | 0, _ = f.words[b] | 0; - if (x !== _) { - x < _ ? p = -1 : x > _ && (p = 1); - break; - } - } - return p; - }, s.prototype.gtn = function(f) { - return this.cmpn(f) === 1; - }, s.prototype.gt = function(f) { - return this.cmp(f) === 1; - }, s.prototype.gten = function(f) { - return this.cmpn(f) >= 0; - }, s.prototype.gte = function(f) { - return this.cmp(f) >= 0; - }, s.prototype.ltn = function(f) { - return this.cmpn(f) === -1; - }, s.prototype.lt = function(f) { - return this.cmp(f) === -1; - }, s.prototype.lten = function(f) { - return this.cmpn(f) <= 0; - }, s.prototype.lte = function(f) { - return this.cmp(f) <= 0; - }, s.prototype.eqn = function(f) { - return this.cmpn(f) === 0; - }, s.prototype.eq = function(f) { - return this.cmp(f) === 0; - }, s.red = function(f) { - return new Y(f); - }, s.prototype.toRed = function(f) { - return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), f.convertTo(this)._forceRed(f); - }, s.prototype.fromRed = function() { - return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }, s.prototype._forceRed = function(f) { - return this.red = f, this; - }, s.prototype.forceRed = function(f) { - return n(!this.red, "Already a number in reduction context"), this._forceRed(f); - }, s.prototype.redAdd = function(f) { - return n(this.red, "redAdd works only with red numbers"), this.red.add(this, f); - }, s.prototype.redIAdd = function(f) { - return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, f); - }, s.prototype.redSub = function(f) { - return n(this.red, "redSub works only with red numbers"), this.red.sub(this, f); - }, s.prototype.redISub = function(f) { - return n(this.red, "redISub works only with red numbers"), this.red.isub(this, f); - }, s.prototype.redShl = function(f) { - return n(this.red, "redShl works only with red numbers"), this.red.shl(this, f); - }, s.prototype.redMul = function(f) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, f), this.red.mul(this, f); - }, s.prototype.redIMul = function(f) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, f), this.red.imul(this, f); - }, s.prototype.redSqr = function() { - return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }, s.prototype.redISqr = function() { - return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }, s.prototype.redSqrt = function() { - return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }, s.prototype.redInvm = function() { - return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }, s.prototype.redNeg = function() { - return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }, s.prototype.redPow = function(f) { - return n(this.red && !f.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, f); - }; - var V = { - k256: null, - p224: null, - p192: null, - p25519: null - }; - function te(m, f) { - this.name = m, this.p = new s(f, 16), this.n = this.p.bitLength(), this.k = new s(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); - } - te.prototype._tmp = function() { - var f = new s(null); - return f.words = new Array(Math.ceil(this.n / 13)), f; - }, te.prototype.ireduce = function(f) { - var p = f, b; - do - this.split(p, this.tmp), p = this.imulK(p), p = p.iadd(this.tmp), b = p.bitLength(); - while (b > this.n); - var x = b < this.n ? -1 : p.ucmp(this.p); - return x === 0 ? (p.words[0] = 0, p.length = 1) : x > 0 ? p.isub(this.p) : p.strip !== void 0 ? p.strip() : p._strip(), p; - }, te.prototype.split = function(f, p) { - f.iushrn(this.n, 0, p); - }, te.prototype.imulK = function(f) { - return f.imul(this.k); - }; - function R() { - te.call( - this, - "k256", - "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f" - ); - } - i(R, te), R.prototype.split = function(f, p) { - for (var b = 4194303, x = Math.min(f.length, 9), _ = 0; _ < x; _++) - p.words[_] = f.words[_]; - if (p.length = x, f.length <= 9) { - f.words[0] = 0, f.length = 1; - return; - } - var E = f.words[9]; - for (p.words[p.length++] = E & b, _ = 10; _ < f.length; _++) { - var v = f.words[_] | 0; - f.words[_ - 10] = (v & b) << 4 | E >>> 22, E = v; - } - E >>>= 22, f.words[_ - 10] = E, E === 0 && f.length > 10 ? f.length -= 10 : f.length -= 9; - }, R.prototype.imulK = function(f) { - f.words[f.length] = 0, f.words[f.length + 1] = 0, f.length += 2; - for (var p = 0, b = 0; b < f.length; b++) { - var x = f.words[b] | 0; - p += x * 977, f.words[b] = p & 67108863, p = x * 64 + (p / 67108864 | 0); - } - return f.words[f.length - 1] === 0 && (f.length--, f.words[f.length - 1] === 0 && f.length--), f; - }; - function W() { - te.call( - this, - "p224", - "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001" - ); - } - i(W, te); - function pe() { - te.call( - this, - "p192", - "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff" - ); - } - i(pe, te); - function Ee() { - te.call( - this, - "25519", - "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed" - ); - } - i(Ee, te), Ee.prototype.imulK = function(f) { - for (var p = 0, b = 0; b < f.length; b++) { - var x = (f.words[b] | 0) * 19 + p, _ = x & 67108863; - x >>>= 26, f.words[b] = _, p = x; - } - return p !== 0 && (f.words[f.length++] = p), f; - }, s._prime = function(f) { - if (V[f]) return V[f]; - var p; - if (f === "k256") - p = new R(); - else if (f === "p224") - p = new W(); - else if (f === "p192") - p = new pe(); - else if (f === "p25519") - p = new Ee(); - else - throw new Error("Unknown prime " + f); - return V[f] = p, p; - }; - function Y(m) { - if (typeof m == "string") { - var f = s._prime(m); - this.m = f.p, this.prime = f; - } else - n(m.gtn(1), "modulus must be greater than 1"), this.m = m, this.prime = null; - } - Y.prototype._verify1 = function(f) { - n(f.negative === 0, "red works only with positives"), n(f.red, "red works only with red numbers"); - }, Y.prototype._verify2 = function(f, p) { - n((f.negative | p.negative) === 0, "red works only with positives"), n( - f.red && f.red === p.red, - "red works only with red numbers" - ); - }, Y.prototype.imod = function(f) { - return this.prime ? this.prime.ireduce(f)._forceRed(this) : (d(f, f.umod(this.m)._forceRed(this)), f); - }, Y.prototype.neg = function(f) { - return f.isZero() ? f.clone() : this.m.sub(f)._forceRed(this); - }, Y.prototype.add = function(f, p) { - this._verify2(f, p); - var b = f.add(p); - return b.cmp(this.m) >= 0 && b.isub(this.m), b._forceRed(this); - }, Y.prototype.iadd = function(f, p) { - this._verify2(f, p); - var b = f.iadd(p); - return b.cmp(this.m) >= 0 && b.isub(this.m), b; - }, Y.prototype.sub = function(f, p) { - this._verify2(f, p); - var b = f.sub(p); - return b.cmpn(0) < 0 && b.iadd(this.m), b._forceRed(this); - }, Y.prototype.isub = function(f, p) { - this._verify2(f, p); - var b = f.isub(p); - return b.cmpn(0) < 0 && b.iadd(this.m), b; - }, Y.prototype.shl = function(f, p) { - return this._verify1(f), this.imod(f.ushln(p)); - }, Y.prototype.imul = function(f, p) { - return this._verify2(f, p), this.imod(f.imul(p)); - }, Y.prototype.mul = function(f, p) { - return this._verify2(f, p), this.imod(f.mul(p)); - }, Y.prototype.isqr = function(f) { - return this.imul(f, f.clone()); - }, Y.prototype.sqr = function(f) { - return this.mul(f, f); - }, Y.prototype.sqrt = function(f) { - if (f.isZero()) return f.clone(); - var p = this.m.andln(3); - if (n(p % 2 === 1), p === 3) { - var b = this.m.add(new s(1)).iushrn(2); - return this.pow(f, b); - } - for (var x = this.m.subn(1), _ = 0; !x.isZero() && x.andln(1) === 0; ) - _++, x.iushrn(1); - n(!x.isZero()); - var E = new s(1).toRed(this), v = E.redNeg(), P = this.m.subn(1).iushrn(1), I = this.m.bitLength(); - for (I = new s(2 * I * I).toRed(this); this.pow(I, P).cmp(v) !== 0; ) - I.redIAdd(v); - for (var B = this.pow(I, x), ce = this.pow(f, x.addn(1).iushrn(1)), D = this.pow(f, x), oe = _; D.cmp(E) !== 0; ) { - for (var Z = D, J = 0; Z.cmp(E) !== 0; J++) - Z = Z.redSqr(); - n(J < oe); - var Q = this.pow(B, new s(1).iushln(oe - J - 1)); - ce = ce.redMul(Q), B = Q.redSqr(), D = D.redMul(B), oe = J; - } - return ce; - }, Y.prototype.invm = function(f) { - var p = f._invmp(this.m); - return p.negative !== 0 ? (p.negative = 0, this.imod(p).redNeg()) : this.imod(p); - }, Y.prototype.pow = function(f, p) { - if (p.isZero()) return new s(1).toRed(this); - if (p.cmpn(1) === 0) return f.clone(); - var b = 4, x = new Array(1 << b); - x[0] = new s(1).toRed(this), x[1] = f; - for (var _ = 2; _ < x.length; _++) - x[_] = this.mul(x[_ - 1], f); - var E = x[0], v = 0, P = 0, I = p.bitLength() % 26; - for (I === 0 && (I = 26), _ = p.length - 1; _ >= 0; _--) { - for (var B = p.words[_], ce = I - 1; ce >= 0; ce--) { - var D = B >> ce & 1; - if (E !== x[0] && (E = this.sqr(E)), D === 0 && v === 0) { - P = 0; - continue; - } - v <<= 1, v |= D, P++, !(P !== b && (_ !== 0 || ce !== 0)) && (E = this.mul(E, x[v]), P = 0, v = 0); - } - I = 26; - } - return E; - }, Y.prototype.convertTo = function(f) { - var p = f.umod(this.m); - return p === f ? p.clone() : p; - }, Y.prototype.convertFrom = function(f) { - var p = f.clone(); - return p.red = null, p; - }, s.mont = function(f) { - return new S(f); - }; - function S(m) { - Y.call(this, m), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new s(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(S, Y), S.prototype.convertTo = function(f) { - return this.imod(f.ushln(this.shift)); - }, S.prototype.convertFrom = function(f) { - var p = this.imod(f.mul(this.rinv)); - return p.red = null, p; - }, S.prototype.imul = function(f, p) { - if (f.isZero() || p.isZero()) - return f.words[0] = 0, f.length = 1, f; - var b = f.imul(p), x = b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), _ = b.isub(x).iushrn(this.shift), E = _; - return _.cmp(this.m) >= 0 ? E = _.isub(this.m) : _.cmpn(0) < 0 && (E = _.iadd(this.m)), E._forceRed(this); - }, S.prototype.mul = function(f, p) { - if (f.isZero() || p.isZero()) return new s(0)._forceRed(this); - var b = f.mul(p), x = b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), _ = b.isub(x).iushrn(this.shift), E = _; - return _.cmp(this.m) >= 0 ? E = _.isub(this.m) : _.cmpn(0) < 0 && (E = _.iadd(this.m)), E._forceRed(this); - }, S.prototype.invm = function(f) { - var p = this.imod(f._invmp(this.m).mul(this.r2)); - return p._forceRed(this); - }; - })(t, gn); -})(qv); -var xB = qv.exports; -const ir = /* @__PURE__ */ ts(xB); -var _B = ir.BN; -function EB(t) { - return new _B(t, 36).toString(16); -} -const SB = "strings/5.7.0", AB = new Yr(SB); -var t0; -(function(t) { - t.current = "", t.NFC = "NFC", t.NFD = "NFD", t.NFKC = "NFKC", t.NFKD = "NFKD"; -})(t0 || (t0 = {})); -var vx; -(function(t) { - t.UNEXPECTED_CONTINUE = "unexpected continuation byte", t.BAD_PREFIX = "bad codepoint prefix", t.OVERRUN = "string overrun", t.MISSING_CONTINUE = "missing continuation byte", t.OUT_OF_RANGE = "out of UTF-8 range", t.UTF16_SURROGATE = "UTF-16 surrogate", t.OVERLONG = "overlong representation"; -})(vx || (vx = {})); -function em(t, e = t0.current) { - e != t0.current && (AB.checkNormalize(), t = t.normalize(e)); - let r = []; - for (let n = 0; n < t.length; n++) { - const i = t.charCodeAt(n); - if (i < 128) - r.push(i); - else if (i < 2048) - r.push(i >> 6 | 192), r.push(i & 63 | 128); - else if ((i & 64512) == 55296) { - n++; - const s = t.charCodeAt(n); - if (n >= t.length || (s & 64512) !== 56320) - throw new Error("invalid utf-8 string"); - const o = 65536 + ((i & 1023) << 10) + (s & 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(i >> 12 | 224), r.push(i >> 6 & 63 | 128), r.push(i & 63 | 128); - } - return wn(r); -} -const PB = `Ethereum Signed Message: -`; -function V4(t) { - return typeof t == "string" && (t = em(t)), jv(bB([ - em(PB), - em(String(t.length)), - t - ])); -} -const MB = "address/5.7.0", kf = new Yr(MB); -function bx(t) { - qs(t, 20) || kf.throwArgumentError("invalid address", "address", t), t = t.toLowerCase(); - const e = t.substring(2).split(""), r = new Uint8Array(40); - for (let i = 0; i < 40; i++) - r[i] = e[i].charCodeAt(0); - const n = wn(jv(r)); - for (let i = 0; i < 40; i += 2) - n[i >> 1] >> 4 >= 8 && (e[i] = e[i].toUpperCase()), (n[i >> 1] & 15) >= 8 && (e[i + 1] = e[i + 1].toUpperCase()); - return "0x" + e.join(""); -} -const IB = 9007199254740991; -function CB(t) { - return Math.log10 ? Math.log10(t) : Math.log(t) / Math.LN10; -} -const zv = {}; -for (let t = 0; t < 10; t++) - zv[String(t)] = String(t); -for (let t = 0; t < 26; t++) - zv[String.fromCharCode(65 + t)] = String(10 + t); -const yx = Math.floor(CB(IB)); -function TB(t) { - t = t.toUpperCase(), t = t.substring(4) + t.substring(0, 2) + "00"; - let e = t.split("").map((n) => zv[n]).join(""); - for (; e.length >= yx; ) { - let n = e.substring(0, yx); - e = parseInt(n, 10) % 97 + e.substring(n.length); - } - let r = String(98 - parseInt(e, 10) % 97); - for (; r.length < 2; ) - r = "0" + r; - return r; -} -function RB(t) { - let e = null; - if (typeof t != "string" && kf.throwArgumentError("invalid address", "address", t), t.match(/^(0x)?[0-9a-fA-F]{40}$/)) - t.substring(0, 2) !== "0x" && (t = "0x" + t), e = bx(t), t.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && e !== t && kf.throwArgumentError("bad address checksum", "address", t); - else if (t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { - for (t.substring(2, 4) !== TB(t) && kf.throwArgumentError("bad icap checksum", "address", t), e = EB(t.substring(4)); e.length < 40; ) - e = "0" + e; - e = bx("0x" + e); - } else - kf.throwArgumentError("invalid address", "address", t); - return e; -} -function xf(t, e, r) { - Object.defineProperty(t, e, { - enumerable: !0, - value: r, - writable: !1 - }); -} -var Kl = {}, xr = {}, yc = G4; -function G4(t, e) { - if (!t) - throw new Error(e || "Assertion failed"); -} -G4.equal = function(e, r, n) { - if (e != r) - throw new Error(n || "Assertion failed: " + e + " != " + r); -}; -var w1 = { exports: {} }; -typeof Object.create == "function" ? w1.exports = function(e, r) { - r && (e.super_ = r, e.prototype = Object.create(r.prototype, { - constructor: { - value: e, - enumerable: !1, - writable: !0, - configurable: !0 - } - })); -} : w1.exports = function(e, r) { - if (r) { - e.super_ = r; - var n = function() { - }; - n.prototype = r.prototype, e.prototype = new n(), e.prototype.constructor = e; - } -}; -var q0 = w1.exports, DB = yc, OB = q0; -xr.inherits = OB; -function NB(t, e) { - return (t.charCodeAt(e) & 64512) !== 55296 || e < 0 || e + 1 >= t.length ? !1 : (t.charCodeAt(e + 1) & 64512) === 56320; -} -function LB(t, e) { - if (Array.isArray(t)) - return t.slice(); - if (!t) - return []; - var r = []; - if (typeof t == "string") - if (e) { - if (e === "hex") - for (t = t.replace(/[^a-z0-9]+/ig, ""), t.length % 2 !== 0 && (t = "0" + t), i = 0; i < t.length; i += 2) - r.push(parseInt(t[i] + t[i + 1], 16)); - } else for (var n = 0, i = 0; i < t.length; i++) { - var s = t.charCodeAt(i); - s < 128 ? r[n++] = s : s < 2048 ? (r[n++] = s >> 6 | 192, r[n++] = s & 63 | 128) : NB(t, i) ? (s = 65536 + ((s & 1023) << 10) + (t.charCodeAt(++i) & 1023), r[n++] = s >> 18 | 240, r[n++] = s >> 12 & 63 | 128, r[n++] = s >> 6 & 63 | 128, r[n++] = s & 63 | 128) : (r[n++] = s >> 12 | 224, r[n++] = s >> 6 & 63 | 128, r[n++] = s & 63 | 128); - } - else - for (i = 0; i < t.length; i++) - r[i] = t[i] | 0; - return r; -} -xr.toArray = LB; -function kB(t) { - for (var e = "", r = 0; r < t.length; r++) - e += J4(t[r].toString(16)); - return e; -} -xr.toHex = kB; -function Y4(t) { - var e = t >>> 24 | t >>> 8 & 65280 | t << 8 & 16711680 | (t & 255) << 24; - return e >>> 0; -} -xr.htonl = Y4; -function $B(t, e) { - for (var r = "", n = 0; n < t.length; n++) { - var i = t[n]; - e === "little" && (i = Y4(i)), r += X4(i.toString(16)); - } - return r; -} -xr.toHex32 = $B; -function J4(t) { - return t.length === 1 ? "0" + t : t; -} -xr.zero2 = J4; -function X4(t) { - return t.length === 7 ? "0" + t : t.length === 6 ? "00" + t : t.length === 5 ? "000" + t : t.length === 4 ? "0000" + t : t.length === 3 ? "00000" + t : t.length === 2 ? "000000" + t : t.length === 1 ? "0000000" + t : t; -} -xr.zero8 = X4; -function FB(t, e, r, n) { - var i = r - e; - DB(i % 4 === 0); - for (var s = new Array(i / 4), o = 0, a = e; o < s.length; o++, a += 4) { - var u; - n === "big" ? u = t[a] << 24 | t[a + 1] << 16 | t[a + 2] << 8 | t[a + 3] : u = t[a + 3] << 24 | t[a + 2] << 16 | t[a + 1] << 8 | t[a], s[o] = u >>> 0; - } - return s; -} -xr.join32 = FB; -function BB(t, e) { - for (var r = new Array(t.length * 4), n = 0, i = 0; n < t.length; n++, i += 4) { - var s = t[n]; - e === "big" ? (r[i] = s >>> 24, r[i + 1] = s >>> 16 & 255, r[i + 2] = s >>> 8 & 255, r[i + 3] = s & 255) : (r[i + 3] = s >>> 24, r[i + 2] = s >>> 16 & 255, r[i + 1] = s >>> 8 & 255, r[i] = s & 255); - } - return r; -} -xr.split32 = BB; -function UB(t, e) { - return t >>> e | t << 32 - e; -} -xr.rotr32 = UB; -function jB(t, e) { - return t << e | t >>> 32 - e; -} -xr.rotl32 = jB; -function qB(t, e) { - return t + e >>> 0; -} -xr.sum32 = qB; -function zB(t, e, r) { - return t + e + r >>> 0; -} -xr.sum32_3 = zB; -function HB(t, e, r, n) { - return t + e + r + n >>> 0; -} -xr.sum32_4 = HB; -function WB(t, e, r, n, i) { - return t + e + r + n + i >>> 0; -} -xr.sum32_5 = WB; -function KB(t, e, r, n) { - var i = t[e], s = t[e + 1], o = n + s >>> 0, a = (o < n ? 1 : 0) + r + i; - t[e] = a >>> 0, t[e + 1] = o; -} -xr.sum64 = KB; -function VB(t, e, r, n) { - var i = e + n >>> 0, s = (i < e ? 1 : 0) + t + r; - return s >>> 0; -} -xr.sum64_hi = VB; -function GB(t, e, r, n) { - var i = e + n; - return i >>> 0; -} -xr.sum64_lo = GB; -function YB(t, e, r, n, i, s, o, a) { - var u = 0, l = e; - l = l + n >>> 0, u += l < e ? 1 : 0, l = l + s >>> 0, u += l < s ? 1 : 0, l = l + a >>> 0, u += l < a ? 1 : 0; - var d = t + r + i + o + u; - return d >>> 0; -} -xr.sum64_4_hi = YB; -function JB(t, e, r, n, i, s, o, a) { - var u = e + n + s + a; - return u >>> 0; -} -xr.sum64_4_lo = JB; -function XB(t, e, r, n, i, s, o, a, u, l) { - var d = 0, g = e; - g = g + n >>> 0, d += g < e ? 1 : 0, g = g + s >>> 0, d += g < s ? 1 : 0, g = g + a >>> 0, d += g < a ? 1 : 0, g = g + l >>> 0, d += g < l ? 1 : 0; - var w = t + r + i + o + u + d; - return w >>> 0; -} -xr.sum64_5_hi = XB; -function ZB(t, e, r, n, i, s, o, a, u, l) { - var d = e + n + s + a + l; - return d >>> 0; -} -xr.sum64_5_lo = ZB; -function QB(t, e, r) { - var n = e << 32 - r | t >>> r; - return n >>> 0; -} -xr.rotr64_hi = QB; -function eU(t, e, r) { - var n = t << 32 - r | e >>> r; - return n >>> 0; -} -xr.rotr64_lo = eU; -function tU(t, e, r) { - return t >>> r; -} -xr.shr64_hi = tU; -function rU(t, e, r) { - var n = t << 32 - r | e >>> r; - return n >>> 0; -} -xr.shr64_lo = rU; -var Nu = {}, wx = xr, nU = yc; -function z0() { - 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; -} -Nu.BlockHash = z0; -z0.prototype.update = function(e, r) { - if (e = wx.toArray(e, r), this.pending ? this.pending = this.pending.concat(e) : this.pending = e, this.pendingTotal += e.length, this.pending.length >= this._delta8) { - e = this.pending; - var n = e.length % this._delta8; - this.pending = e.slice(e.length - n, e.length), this.pending.length === 0 && (this.pending = null), e = wx.join32(e, 0, e.length - n, this.endian); - for (var i = 0; i < e.length; i += this._delta32) - this._update(e, i, i + this._delta32); - } - return this; -}; -z0.prototype.digest = function(e) { - return this.update(this._pad()), nU(this.pending === null), this._digest(e); -}; -z0.prototype._pad = function() { - var e = this.pendingTotal, r = this._delta8, n = r - (e + this.padLength) % r, i = new Array(n + this.padLength); - i[0] = 128; - for (var s = 1; s < n; s++) - i[s] = 0; - if (e <<= 3, this.endian === "big") { - for (var o = 8; o < this.padLength; o++) - i[s++] = 0; - i[s++] = 0, i[s++] = 0, i[s++] = 0, i[s++] = 0, i[s++] = e >>> 24 & 255, i[s++] = e >>> 16 & 255, i[s++] = e >>> 8 & 255, i[s++] = e & 255; - } else - for (i[s++] = e & 255, i[s++] = e >>> 8 & 255, i[s++] = e >>> 16 & 255, i[s++] = e >>> 24 & 255, i[s++] = 0, i[s++] = 0, i[s++] = 0, i[s++] = 0, o = 8; o < this.padLength; o++) - i[s++] = 0; - return i; -}; -var Lu = {}, to = {}, iU = xr, zs = iU.rotr32; -function sU(t, e, r, n) { - if (t === 0) - return Z4(e, r, n); - if (t === 1 || t === 3) - return e8(e, r, n); - if (t === 2) - return Q4(e, r, n); -} -to.ft_1 = sU; -function Z4(t, e, r) { - return t & e ^ ~t & r; -} -to.ch32 = Z4; -function Q4(t, e, r) { - return t & e ^ t & r ^ e & r; -} -to.maj32 = Q4; -function e8(t, e, r) { - return t ^ e ^ r; -} -to.p32 = e8; -function oU(t) { - return zs(t, 2) ^ zs(t, 13) ^ zs(t, 22); -} -to.s0_256 = oU; -function aU(t) { - return zs(t, 6) ^ zs(t, 11) ^ zs(t, 25); -} -to.s1_256 = aU; -function cU(t) { - return zs(t, 7) ^ zs(t, 18) ^ t >>> 3; -} -to.g0_256 = cU; -function uU(t) { - return zs(t, 17) ^ zs(t, 19) ^ t >>> 10; -} -to.g1_256 = uU; -var xu = xr, fU = Nu, lU = to, tm = xu.rotl32, _f = xu.sum32, hU = xu.sum32_5, dU = lU.ft_1, t8 = fU.BlockHash, pU = [ - 1518500249, - 1859775393, - 2400959708, - 3395469782 -]; -function Ys() { - if (!(this instanceof Ys)) - return new Ys(); - t8.call(this), this.h = [ - 1732584193, - 4023233417, - 2562383102, - 271733878, - 3285377520 - ], this.W = new Array(80); -} -xu.inherits(Ys, t8); -var gU = Ys; -Ys.blockSize = 512; -Ys.outSize = 160; -Ys.hmacStrength = 80; -Ys.padLength = 64; -Ys.prototype._update = function(e, r) { - for (var n = this.W, i = 0; i < 16; i++) - n[i] = e[r + i]; - for (; i < n.length; i++) - n[i] = tm(n[i - 3] ^ n[i - 8] ^ n[i - 14] ^ n[i - 16], 1); - var s = this.h[0], o = this.h[1], a = this.h[2], u = this.h[3], l = this.h[4]; - for (i = 0; i < n.length; i++) { - var d = ~~(i / 20), g = hU(tm(s, 5), dU(d, o, a, u), l, n[i], pU[d]); - l = u, u = a, a = tm(o, 30), o = s, s = g; - } - this.h[0] = _f(this.h[0], s), this.h[1] = _f(this.h[1], o), this.h[2] = _f(this.h[2], a), this.h[3] = _f(this.h[3], u), this.h[4] = _f(this.h[4], l); -}; -Ys.prototype._digest = function(e) { - return e === "hex" ? xu.toHex32(this.h, "big") : xu.split32(this.h, "big"); -}; -var _u = xr, mU = Nu, ku = to, vU = yc, ps = _u.sum32, bU = _u.sum32_4, yU = _u.sum32_5, wU = ku.ch32, xU = ku.maj32, _U = ku.s0_256, EU = ku.s1_256, SU = ku.g0_256, AU = ku.g1_256, r8 = mU.BlockHash, PU = [ - 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 Js() { - if (!(this instanceof Js)) - return new Js(); - r8.call(this), this.h = [ - 1779033703, - 3144134277, - 1013904242, - 2773480762, - 1359893119, - 2600822924, - 528734635, - 1541459225 - ], this.k = PU, this.W = new Array(64); -} -_u.inherits(Js, r8); -var n8 = Js; -Js.blockSize = 512; -Js.outSize = 256; -Js.hmacStrength = 192; -Js.padLength = 64; -Js.prototype._update = function(e, r) { - for (var n = this.W, i = 0; i < 16; i++) - n[i] = e[r + i]; - for (; i < n.length; i++) - n[i] = bU(AU(n[i - 2]), n[i - 7], SU(n[i - 15]), n[i - 16]); - var s = this.h[0], o = this.h[1], a = this.h[2], u = this.h[3], l = this.h[4], d = this.h[5], g = this.h[6], w = this.h[7]; - for (vU(this.k.length === n.length), i = 0; i < n.length; i++) { - var A = yU(w, EU(l), wU(l, d, g), this.k[i], n[i]), M = ps(_U(s), xU(s, o, a)); - w = g, g = d, d = l, l = ps(u, A), u = a, a = o, o = s, s = ps(A, M); - } - this.h[0] = ps(this.h[0], s), this.h[1] = ps(this.h[1], o), this.h[2] = ps(this.h[2], a), this.h[3] = ps(this.h[3], u), this.h[4] = ps(this.h[4], l), this.h[5] = ps(this.h[5], d), this.h[6] = ps(this.h[6], g), this.h[7] = ps(this.h[7], w); -}; -Js.prototype._digest = function(e) { - return e === "hex" ? _u.toHex32(this.h, "big") : _u.split32(this.h, "big"); -}; -var x1 = xr, i8 = n8; -function Fo() { - if (!(this instanceof Fo)) - return new Fo(); - i8.call(this), this.h = [ - 3238371032, - 914150663, - 812702999, - 4144912697, - 4290775857, - 1750603025, - 1694076839, - 3204075428 - ]; -} -x1.inherits(Fo, i8); -var MU = Fo; -Fo.blockSize = 512; -Fo.outSize = 224; -Fo.hmacStrength = 192; -Fo.padLength = 64; -Fo.prototype._digest = function(e) { - return e === "hex" ? x1.toHex32(this.h.slice(0, 7), "big") : x1.split32(this.h.slice(0, 7), "big"); -}; -var xi = xr, IU = Nu, CU = yc, Hs = xi.rotr64_hi, Ws = xi.rotr64_lo, s8 = xi.shr64_hi, o8 = xi.shr64_lo, ea = xi.sum64, rm = xi.sum64_hi, nm = xi.sum64_lo, TU = xi.sum64_4_hi, RU = xi.sum64_4_lo, DU = xi.sum64_5_hi, OU = xi.sum64_5_lo, a8 = IU.BlockHash, NU = [ - 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 Es() { - if (!(this instanceof Es)) - return new Es(); - a8.call(this), this.h = [ - 1779033703, - 4089235720, - 3144134277, - 2227873595, - 1013904242, - 4271175723, - 2773480762, - 1595750129, - 1359893119, - 2917565137, - 2600822924, - 725511199, - 528734635, - 4215389547, - 1541459225, - 327033209 - ], this.k = NU, this.W = new Array(160); -} -xi.inherits(Es, a8); -var c8 = Es; -Es.blockSize = 1024; -Es.outSize = 512; -Es.hmacStrength = 192; -Es.padLength = 128; -Es.prototype._prepareBlock = function(e, r) { - for (var n = this.W, i = 0; i < 32; i++) - n[i] = e[r + i]; - for (; i < n.length; i += 2) { - var s = WU(n[i - 4], n[i - 3]), o = KU(n[i - 4], n[i - 3]), a = n[i - 14], u = n[i - 13], l = zU(n[i - 30], n[i - 29]), d = HU(n[i - 30], n[i - 29]), g = n[i - 32], w = n[i - 31]; - n[i] = TU( - s, - o, - a, - u, - l, - d, - g, - w - ), n[i + 1] = RU( - s, - o, - a, - u, - l, - d, - g, - w - ); - } -}; -Es.prototype._update = function(e, r) { - this._prepareBlock(e, r); - var n = this.W, i = this.h[0], s = this.h[1], o = this.h[2], a = this.h[3], u = this.h[4], l = this.h[5], d = this.h[6], g = this.h[7], w = this.h[8], A = this.h[9], M = this.h[10], N = this.h[11], L = this.h[12], F = this.h[13], $ = this.h[14], K = this.h[15]; - CU(this.k.length === n.length); - for (var H = 0; H < n.length; H += 2) { - var V = $, te = K, R = jU(w, A), W = qU(w, A), pe = LU(w, A, M, N, L), Ee = kU(w, A, M, N, L, F), Y = this.k[H], S = this.k[H + 1], m = n[H], f = n[H + 1], p = DU( - V, - te, - R, - W, - pe, - Ee, - Y, - S, - m, - f - ), b = OU( - V, - te, - R, - W, - pe, - Ee, - Y, - S, - m, - f - ); - V = BU(i, s), te = UU(i, s), R = $U(i, s, o, a, u), W = FU(i, s, o, a, u, l); - var x = rm(V, te, R, W), _ = nm(V, te, R, W); - $ = L, K = F, L = M, F = N, M = w, N = A, w = rm(d, g, p, b), A = nm(g, g, p, b), d = u, g = l, u = o, l = a, o = i, a = s, i = rm(p, b, x, _), s = nm(p, b, x, _); - } - ea(this.h, 0, i, s), ea(this.h, 2, o, a), ea(this.h, 4, u, l), ea(this.h, 6, d, g), ea(this.h, 8, w, A), ea(this.h, 10, M, N), ea(this.h, 12, L, F), ea(this.h, 14, $, K); -}; -Es.prototype._digest = function(e) { - return e === "hex" ? xi.toHex32(this.h, "big") : xi.split32(this.h, "big"); -}; -function LU(t, e, r, n, i) { - var s = t & r ^ ~t & i; - return s < 0 && (s += 4294967296), s; -} -function kU(t, e, r, n, i, s) { - var o = e & n ^ ~e & s; - return o < 0 && (o += 4294967296), o; -} -function $U(t, e, r, n, i) { - var s = t & r ^ t & i ^ r & i; - return s < 0 && (s += 4294967296), s; -} -function FU(t, e, r, n, i, s) { - var o = e & n ^ e & s ^ n & s; - return o < 0 && (o += 4294967296), o; -} -function BU(t, e) { - var r = Hs(t, e, 28), n = Hs(e, t, 2), i = Hs(e, t, 7), s = r ^ n ^ i; - return s < 0 && (s += 4294967296), s; -} -function UU(t, e) { - var r = Ws(t, e, 28), n = Ws(e, t, 2), i = Ws(e, t, 7), s = r ^ n ^ i; - return s < 0 && (s += 4294967296), s; -} -function jU(t, e) { - var r = Hs(t, e, 14), n = Hs(t, e, 18), i = Hs(e, t, 9), s = r ^ n ^ i; - return s < 0 && (s += 4294967296), s; -} -function qU(t, e) { - var r = Ws(t, e, 14), n = Ws(t, e, 18), i = Ws(e, t, 9), s = r ^ n ^ i; - return s < 0 && (s += 4294967296), s; -} -function zU(t, e) { - var r = Hs(t, e, 1), n = Hs(t, e, 8), i = s8(t, e, 7), s = r ^ n ^ i; - return s < 0 && (s += 4294967296), s; -} -function HU(t, e) { - var r = Ws(t, e, 1), n = Ws(t, e, 8), i = o8(t, e, 7), s = r ^ n ^ i; - return s < 0 && (s += 4294967296), s; -} -function WU(t, e) { - var r = Hs(t, e, 19), n = Hs(e, t, 29), i = s8(t, e, 6), s = r ^ n ^ i; - return s < 0 && (s += 4294967296), s; -} -function KU(t, e) { - var r = Ws(t, e, 19), n = Ws(e, t, 29), i = o8(t, e, 6), s = r ^ n ^ i; - return s < 0 && (s += 4294967296), s; -} -var _1 = xr, u8 = c8; -function Bo() { - if (!(this instanceof Bo)) - return new Bo(); - u8.call(this), this.h = [ - 3418070365, - 3238371032, - 1654270250, - 914150663, - 2438529370, - 812702999, - 355462360, - 4144912697, - 1731405415, - 4290775857, - 2394180231, - 1750603025, - 3675008525, - 1694076839, - 1203062813, - 3204075428 - ]; -} -_1.inherits(Bo, u8); -var VU = Bo; -Bo.blockSize = 1024; -Bo.outSize = 384; -Bo.hmacStrength = 192; -Bo.padLength = 128; -Bo.prototype._digest = function(e) { - return e === "hex" ? _1.toHex32(this.h.slice(0, 12), "big") : _1.split32(this.h.slice(0, 12), "big"); -}; -Lu.sha1 = gU; -Lu.sha224 = MU; -Lu.sha256 = n8; -Lu.sha384 = VU; -Lu.sha512 = c8; -var f8 = {}, fc = xr, GU = Nu, cd = fc.rotl32, xx = fc.sum32, Ef = fc.sum32_3, _x = fc.sum32_4, l8 = GU.BlockHash; -function Xs() { - if (!(this instanceof Xs)) - return new Xs(); - l8.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; -} -fc.inherits(Xs, l8); -f8.ripemd160 = Xs; -Xs.blockSize = 512; -Xs.outSize = 160; -Xs.hmacStrength = 192; -Xs.padLength = 64; -Xs.prototype._update = function(e, r) { - for (var n = this.h[0], i = this.h[1], s = this.h[2], o = this.h[3], a = this.h[4], u = n, l = i, d = s, g = o, w = a, A = 0; A < 80; A++) { - var M = xx( - cd( - _x(n, Ex(A, i, s, o), e[XU[A] + r], YU(A)), - QU[A] - ), - a - ); - n = a, a = o, o = cd(s, 10), s = i, i = M, M = xx( - cd( - _x(u, Ex(79 - A, l, d, g), e[ZU[A] + r], JU(A)), - ej[A] - ), - w - ), u = w, w = g, g = cd(d, 10), d = l, l = M; - } - M = Ef(this.h[1], s, g), this.h[1] = Ef(this.h[2], o, w), this.h[2] = Ef(this.h[3], a, u), this.h[3] = Ef(this.h[4], n, l), this.h[4] = Ef(this.h[0], i, d), this.h[0] = M; -}; -Xs.prototype._digest = function(e) { - return e === "hex" ? fc.toHex32(this.h, "little") : fc.split32(this.h, "little"); -}; -function Ex(t, e, r, n) { - return t <= 15 ? e ^ r ^ n : t <= 31 ? e & r | ~e & n : t <= 47 ? (e | ~r) ^ n : t <= 63 ? e & n | r & ~n : e ^ (r | ~n); -} -function YU(t) { - return t <= 15 ? 0 : t <= 31 ? 1518500249 : t <= 47 ? 1859775393 : t <= 63 ? 2400959708 : 2840853838; -} -function JU(t) { - return t <= 15 ? 1352829926 : t <= 31 ? 1548603684 : t <= 47 ? 1836072691 : t <= 63 ? 2053994217 : 0; -} -var XU = [ - 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 -], ZU = [ - 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 -], QU = [ - 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 -], ej = [ - 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 -], tj = xr, rj = yc; -function Eu(t, e, r) { - if (!(this instanceof Eu)) - return new Eu(t, e, r); - this.Hash = t, this.blockSize = t.blockSize / 8, this.outSize = t.outSize / 8, this.inner = null, this.outer = null, this._init(tj.toArray(e, r)); -} -var nj = Eu; -Eu.prototype._init = function(e) { - e.length > this.blockSize && (e = new this.Hash().update(e).digest()), rj(e.length <= this.blockSize); - for (var r = e.length; r < this.blockSize; r++) - e.push(0); - for (r = 0; r < e.length; r++) - e[r] ^= 54; - for (this.inner = new this.Hash().update(e), r = 0; r < e.length; r++) - e[r] ^= 106; - this.outer = new this.Hash().update(e); -}; -Eu.prototype.update = function(e, r) { - return this.inner.update(e, r), this; -}; -Eu.prototype.digest = function(e) { - return this.outer.update(this.inner.digest()), this.outer.digest(e); -}; -(function(t) { - var e = t; - e.utils = xr, e.common = Nu, e.sha = Lu, e.ripemd = f8, e.hmac = nj, e.sha1 = e.sha.sha1, e.sha256 = e.sha.sha256, e.sha224 = e.sha.sha224, e.sha384 = e.sha.sha384, e.sha512 = e.sha.sha512, e.ripemd160 = e.ripemd.ripemd160; -})(Kl); -const bo = /* @__PURE__ */ ts(Kl); -function $u(t, e, r) { - return r = { - path: e, - exports: {}, - require: function(n, i) { - return ij(n, i ?? r.path); - } - }, t(r, r.exports), r.exports; -} -function ij() { - throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); -} -var Hv = h8; -function h8(t, e) { - if (!t) - throw new Error(e || "Assertion failed"); -} -h8.equal = function(e, r, n) { - if (e != r) - throw new Error(n || "Assertion failed: " + e + " != " + r); -}; -var ws = $u(function(t, e) { - var r = e; - function n(o, a) { - if (Array.isArray(o)) - return o.slice(); - if (!o) - return []; - var u = []; - if (typeof o != "string") { - for (var l = 0; l < o.length; l++) - u[l] = o[l] | 0; - return u; - } - if (a === "hex") { - o = o.replace(/[^a-z0-9]+/ig, ""), o.length % 2 !== 0 && (o = "0" + o); - for (var l = 0; l < o.length; l += 2) - u.push(parseInt(o[l] + o[l + 1], 16)); - } else - for (var l = 0; l < o.length; l++) { - var d = o.charCodeAt(l), g = d >> 8, w = d & 255; - g ? u.push(g, w) : u.push(w); - } - return u; - } - r.toArray = n; - function i(o) { - return o.length === 1 ? "0" + o : o; - } - r.zero2 = i; - function s(o) { - for (var a = "", u = 0; u < o.length; u++) - a += i(o[u].toString(16)); - return a; - } - r.toHex = s, r.encode = function(a, u) { - return u === "hex" ? s(a) : a; - }; -}), $i = $u(function(t, e) { - var r = e; - r.assert = Hv, r.toArray = ws.toArray, r.zero2 = ws.zero2, r.toHex = ws.toHex, r.encode = ws.encode; - function n(u, l, d) { - var g = new Array(Math.max(u.bitLength(), d) + 1); - g.fill(0); - for (var w = 1 << l + 1, A = u.clone(), M = 0; M < g.length; M++) { - var N, L = A.andln(w - 1); - A.isOdd() ? (L > (w >> 1) - 1 ? N = (w >> 1) - L : N = L, A.isubn(N)) : N = 0, g[M] = N, A.iushrn(1); - } - return g; - } - r.getNAF = n; - function i(u, l) { - var d = [ - [], - [] - ]; - u = u.clone(), l = l.clone(); - for (var g = 0, w = 0, A; u.cmpn(-g) > 0 || l.cmpn(-w) > 0; ) { - var M = u.andln(3) + g & 3, N = l.andln(3) + w & 3; - M === 3 && (M = -1), N === 3 && (N = -1); - var L; - M & 1 ? (A = u.andln(7) + g & 7, (A === 3 || A === 5) && N === 2 ? L = -M : L = M) : L = 0, d[0].push(L); - var F; - N & 1 ? (A = l.andln(7) + w & 7, (A === 3 || A === 5) && M === 2 ? F = -N : F = N) : F = 0, d[1].push(F), 2 * g === L + 1 && (g = 1 - g), 2 * w === F + 1 && (w = 1 - w), u.iushrn(1), l.iushrn(1); - } - return d; - } - r.getJSF = i; - function s(u, l, d) { - var g = "_" + l; - u.prototype[l] = function() { - return this[g] !== void 0 ? this[g] : this[g] = d.call(this); - }; - } - r.cachedProperty = s; - function o(u) { - return typeof u == "string" ? r.toArray(u, "hex") : u; - } - r.parseBytes = o; - function a(u) { - return new ir(u, "hex", "le"); - } - r.intFromLE = a; -}), r0 = $i.getNAF, sj = $i.getJSF, n0 = $i.assert; -function Ma(t, e) { - this.type = t, this.p = new ir(e.p, 16), this.red = e.prime ? ir.red(e.prime) : ir.mont(this.p), this.zero = new ir(0).toRed(this.red), this.one = new ir(1).toRed(this.red), this.two = new ir(2).toRed(this.red), this.n = e.n && new ir(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 r = this.n && this.p.div(this.n); - !r || r.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = !0, this.redN = this.n.toRed(this.red)); -} -var wc = Ma; -Ma.prototype.point = function() { - throw new Error("Not implemented"); -}; -Ma.prototype.validate = function() { - throw new Error("Not implemented"); -}; -Ma.prototype._fixedNafMul = function(e, r) { - n0(e.precomputed); - var n = e._getDoubles(), i = r0(r, 1, this._bitLength), s = (1 << n.step + 1) - (n.step % 2 === 0 ? 2 : 1); - s /= 3; - var o = [], a, u; - for (a = 0; a < i.length; a += n.step) { - u = 0; - for (var l = a + n.step - 1; l >= a; l--) - u = (u << 1) + i[l]; - o.push(u); - } - for (var d = this.jpoint(null, null, null), g = this.jpoint(null, null, null), w = s; w > 0; w--) { - for (a = 0; a < o.length; a++) - u = o[a], u === w ? g = g.mixedAdd(n.points[a]) : u === -w && (g = g.mixedAdd(n.points[a].neg())); - d = d.add(g); - } - return d.toP(); -}; -Ma.prototype._wnafMul = function(e, r) { - var n = 4, i = e._getNAFPoints(n); - n = i.wnd; - for (var s = i.points, o = r0(r, n, this._bitLength), a = this.jpoint(null, null, null), u = o.length - 1; u >= 0; u--) { - for (var l = 0; u >= 0 && o[u] === 0; u--) - l++; - if (u >= 0 && l++, a = a.dblp(l), u < 0) - break; - var d = o[u]; - n0(d !== 0), e.type === "affine" ? d > 0 ? a = a.mixedAdd(s[d - 1 >> 1]) : a = a.mixedAdd(s[-d - 1 >> 1].neg()) : d > 0 ? a = a.add(s[d - 1 >> 1]) : a = a.add(s[-d - 1 >> 1].neg()); - } - return e.type === "affine" ? a.toP() : a; -}; -Ma.prototype._wnafMulAdd = function(e, r, n, i, s) { - var o = this._wnafT1, a = this._wnafT2, u = this._wnafT3, l = 0, d, g, w; - for (d = 0; d < i; d++) { - w = r[d]; - var A = w._getNAFPoints(e); - o[d] = A.wnd, a[d] = A.points; - } - for (d = i - 1; d >= 1; d -= 2) { - var M = d - 1, N = d; - if (o[M] !== 1 || o[N] !== 1) { - u[M] = r0(n[M], o[M], this._bitLength), u[N] = r0(n[N], o[N], this._bitLength), l = Math.max(u[M].length, l), l = Math.max(u[N].length, l); - continue; - } - var L = [ - r[M], - /* 1 */ - null, - /* 3 */ - null, - /* 5 */ - r[N] - /* 7 */ - ]; - r[M].y.cmp(r[N].y) === 0 ? (L[1] = r[M].add(r[N]), L[2] = r[M].toJ().mixedAdd(r[N].neg())) : r[M].y.cmp(r[N].y.redNeg()) === 0 ? (L[1] = r[M].toJ().mixedAdd(r[N]), L[2] = r[M].add(r[N].neg())) : (L[1] = r[M].toJ().mixedAdd(r[N]), L[2] = r[M].toJ().mixedAdd(r[N].neg())); - var F = [ - -3, - /* -1 -1 */ - -1, - /* -1 0 */ - -5, - /* -1 1 */ - -7, - /* 0 -1 */ - 0, - /* 0 0 */ - 7, - /* 0 1 */ - 5, - /* 1 -1 */ - 1, - /* 1 0 */ - 3 - /* 1 1 */ - ], $ = sj(n[M], n[N]); - for (l = Math.max($[0].length, l), u[M] = new Array(l), u[N] = new Array(l), g = 0; g < l; g++) { - var K = $[0][g] | 0, H = $[1][g] | 0; - u[M][g] = F[(K + 1) * 3 + (H + 1)], u[N][g] = 0, a[M] = L; - } - } - var V = this.jpoint(null, null, null), te = this._wnafT4; - for (d = l; d >= 0; d--) { - for (var R = 0; d >= 0; ) { - var W = !0; - for (g = 0; g < i; g++) - te[g] = u[g][d] | 0, te[g] !== 0 && (W = !1); - if (!W) - break; - R++, d--; - } - if (d >= 0 && R++, V = V.dblp(R), d < 0) - break; - for (g = 0; g < i; g++) { - var pe = te[g]; - pe !== 0 && (pe > 0 ? w = a[g][pe - 1 >> 1] : pe < 0 && (w = a[g][-pe - 1 >> 1].neg()), w.type === "affine" ? V = V.mixedAdd(w) : V = V.add(w)); - } - } - for (d = 0; d < i; d++) - a[d] = null; - return s ? V : V.toP(); -}; -function ns(t, e) { - this.curve = t, this.type = e, this.precomputed = null; -} -Ma.BasePoint = ns; -ns.prototype.eq = function() { - throw new Error("Not implemented"); -}; -ns.prototype.validate = function() { - return this.curve.validate(this); -}; -Ma.prototype.decodePoint = function(e, r) { - e = $i.toArray(e, r); - var n = this.p.byteLength(); - if ((e[0] === 4 || e[0] === 6 || e[0] === 7) && e.length - 1 === 2 * n) { - e[0] === 6 ? n0(e[e.length - 1] % 2 === 0) : e[0] === 7 && n0(e[e.length - 1] % 2 === 1); - var i = this.point( - e.slice(1, 1 + n), - e.slice(1 + n, 1 + 2 * n) - ); - return i; - } else if ((e[0] === 2 || e[0] === 3) && e.length - 1 === n) - return this.pointFromX(e.slice(1, 1 + n), e[0] === 3); - throw new Error("Unknown point format"); -}; -ns.prototype.encodeCompressed = function(e) { - return this.encode(e, !0); -}; -ns.prototype._encode = function(e) { - var r = this.curve.p.byteLength(), n = this.getX().toArray("be", r); - return e ? [this.getY().isEven() ? 2 : 3].concat(n) : [4].concat(n, this.getY().toArray("be", r)); -}; -ns.prototype.encode = function(e, r) { - return $i.encode(this._encode(r), e); -}; -ns.prototype.precompute = function(e) { - if (this.precomputed) - return this; - var r = { - doubles: null, - naf: null, - beta: null - }; - return r.naf = this._getNAFPoints(8), r.doubles = this._getDoubles(4, e), r.beta = this._getBeta(), this.precomputed = r, this; -}; -ns.prototype._hasDoubles = function(e) { - if (!this.precomputed) - return !1; - var r = this.precomputed.doubles; - return r ? r.points.length >= Math.ceil((e.bitLength() + 1) / r.step) : !1; -}; -ns.prototype._getDoubles = function(e, r) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; - for (var n = [this], i = this, s = 0; s < r; s += e) { - for (var o = 0; o < e; o++) - i = i.dbl(); - n.push(i); - } - return { - step: e, - points: n - }; -}; -ns.prototype._getNAFPoints = function(e) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; - for (var r = [this], n = (1 << e) - 1, i = n === 1 ? null : this.dbl(), s = 1; s < n; s++) - r[s] = r[s - 1].add(i); - return { - wnd: e, - points: r - }; -}; -ns.prototype._getBeta = function() { - return null; -}; -ns.prototype.dblp = function(e) { - for (var r = this, n = 0; n < e; n++) - r = r.dbl(); - return r; -}; -var Wv = $u(function(t) { - typeof Object.create == "function" ? t.exports = function(r, n) { - n && (r.super_ = n, r.prototype = Object.create(n.prototype, { - constructor: { - value: r, - enumerable: !1, - writable: !0, - configurable: !0 - } - })); - } : t.exports = function(r, n) { - if (n) { - r.super_ = n; - var i = function() { - }; - i.prototype = n.prototype, r.prototype = new i(), r.prototype.constructor = r; - } - }; -}), oj = $i.assert; -function is(t) { - wc.call(this, "short", t), this.a = new ir(t.a, 16).toRed(this.red), this.b = new ir(t.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(t), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); -} -Wv(is, wc); -var aj = is; -is.prototype._getEndomorphism = function(e) { - if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { - var r, n; - if (e.beta) - r = new ir(e.beta, 16).toRed(this.red); - else { - var i = this._getEndoRoots(this.p); - r = i[0].cmp(i[1]) < 0 ? i[0] : i[1], r = r.toRed(this.red); - } - if (e.lambda) - n = new ir(e.lambda, 16); - else { - var s = this._getEndoRoots(this.n); - this.g.mul(s[0]).x.cmp(this.g.x.redMul(r)) === 0 ? n = s[0] : (n = s[1], oj(this.g.mul(n).x.cmp(this.g.x.redMul(r)) === 0)); - } - var o; - return e.basis ? o = e.basis.map(function(a) { - return { - a: new ir(a.a, 16), - b: new ir(a.b, 16) - }; - }) : o = this._getEndoBasis(n), { - beta: r, - lambda: n, - basis: o - }; - } -}; -is.prototype._getEndoRoots = function(e) { - var r = e === this.p ? this.red : ir.mont(e), n = new ir(2).toRed(r).redInvm(), i = n.redNeg(), s = new ir(3).toRed(r).redNeg().redSqrt().redMul(n), o = i.redAdd(s).fromRed(), a = i.redSub(s).fromRed(); - return [o, a]; -}; -is.prototype._getEndoBasis = function(e) { - for (var r = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), n = e, i = this.n.clone(), s = new ir(1), o = new ir(0), a = new ir(0), u = new ir(1), l, d, g, w, A, M, N, L = 0, F, $; n.cmpn(0) !== 0; ) { - var K = i.div(n); - F = i.sub(K.mul(n)), $ = a.sub(K.mul(s)); - var H = u.sub(K.mul(o)); - if (!g && F.cmp(r) < 0) - l = N.neg(), d = s, g = F.neg(), w = $; - else if (g && ++L === 2) - break; - N = F, i = n, n = F, a = s, s = $, u = o, o = H; - } - A = F.neg(), M = $; - var V = g.sqr().add(w.sqr()), te = A.sqr().add(M.sqr()); - return te.cmp(V) >= 0 && (A = l, M = d), g.negative && (g = g.neg(), w = w.neg()), A.negative && (A = A.neg(), M = M.neg()), [ - { a: g, b: w }, - { a: A, b: M } - ]; -}; -is.prototype._endoSplit = function(e) { - var r = this.endo.basis, n = r[0], i = r[1], s = i.b.mul(e).divRound(this.n), o = n.b.neg().mul(e).divRound(this.n), a = s.mul(n.a), u = o.mul(i.a), l = s.mul(n.b), d = o.mul(i.b), g = e.sub(a).sub(u), w = l.add(d).neg(); - return { k1: g, k2: w }; -}; -is.prototype.pointFromX = function(e, r) { - e = new ir(e, 16), e.red || (e = e.toRed(this.red)); - var n = e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b), i = n.redSqrt(); - if (i.redSqr().redSub(n).cmp(this.zero) !== 0) - throw new Error("invalid point"); - var s = i.fromRed().isOdd(); - return (r && !s || !r && s) && (i = i.redNeg()), this.point(e, i); -}; -is.prototype.validate = function(e) { - if (e.inf) - return !0; - var r = e.x, n = e.y, i = this.a.redMul(r), s = r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b); - return n.redSqr().redISub(s).cmpn(0) === 0; -}; -is.prototype._endoWnafMulAdd = function(e, r, n) { - for (var i = this._endoWnafT1, s = this._endoWnafT2, o = 0; o < e.length; o++) { - var a = this._endoSplit(r[o]), u = e[o], l = u._getBeta(); - a.k1.negative && (a.k1.ineg(), u = u.neg(!0)), a.k2.negative && (a.k2.ineg(), l = l.neg(!0)), i[o * 2] = u, i[o * 2 + 1] = l, s[o * 2] = a.k1, s[o * 2 + 1] = a.k2; - } - for (var d = this._wnafMulAdd(1, i, s, o * 2, n), g = 0; g < o * 2; g++) - i[g] = null, s[g] = null; - return d; -}; -function Ln(t, e, r, n) { - wc.BasePoint.call(this, t, "affine"), e === null && r === null ? (this.x = null, this.y = null, this.inf = !0) : (this.x = new ir(e, 16), this.y = new ir(r, 16), n && (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); -} -Wv(Ln, wc.BasePoint); -is.prototype.point = function(e, r, n) { - return new Ln(this, e, r, n); -}; -is.prototype.pointFromJSON = function(e, r) { - return Ln.fromJSON(this, e, r); -}; -Ln.prototype._getBeta = function() { - if (this.curve.endo) { - var e = this.precomputed; - if (e && e.beta) - return e.beta; - var r = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); - if (e) { - var n = this.curve, i = function(s) { - return n.point(s.x.redMul(n.endo.beta), s.y); - }; - e.beta = r, r.precomputed = { - beta: null, - naf: e.naf && { - wnd: e.naf.wnd, - points: e.naf.points.map(i) - }, - doubles: e.doubles && { - step: e.doubles.step, - points: e.doubles.points.map(i) - } - }; - } - return r; - } -}; -Ln.prototype.toJSON = function() { - return this.precomputed ? [this.x, this.y, this.precomputed && { - doubles: this.precomputed.doubles && { - step: this.precomputed.doubles.step, - points: this.precomputed.doubles.points.slice(1) - }, - naf: this.precomputed.naf && { - wnd: this.precomputed.naf.wnd, - points: this.precomputed.naf.points.slice(1) - } - }] : [this.x, this.y]; -}; -Ln.fromJSON = function(e, r, n) { - typeof r == "string" && (r = JSON.parse(r)); - var i = e.point(r[0], r[1], n); - if (!r[2]) - return i; - function s(a) { - return e.point(a[0], a[1], n); - } - var o = r[2]; - return i.precomputed = { - beta: null, - doubles: o.doubles && { - step: o.doubles.step, - points: [i].concat(o.doubles.points.map(s)) - }, - naf: o.naf && { - wnd: o.naf.wnd, - points: [i].concat(o.naf.points.map(s)) - } - }, i; -}; -Ln.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; -}; -Ln.prototype.isInfinity = function() { - return this.inf; -}; -Ln.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 r = this.y.redSub(e.y); - r.cmpn(0) !== 0 && (r = r.redMul(this.x.redSub(e.x).redInvm())); - var n = r.redSqr().redISub(this.x).redISub(e.x), i = r.redMul(this.x.redSub(n)).redISub(this.y); - return this.curve.point(n, i); -}; -Ln.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 r = this.curve.a, n = this.x.redSqr(), i = e.redInvm(), s = n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i), 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); -}; -Ln.prototype.getX = function() { - return this.x.fromRed(); -}; -Ln.prototype.getY = function() { - return this.y.fromRed(); -}; -Ln.prototype.mul = function(e) { - return e = new ir(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); -}; -Ln.prototype.mulAdd = function(e, r, n) { - var i = [this, r], s = [e, n]; - return this.curve.endo ? this.curve._endoWnafMulAdd(i, s) : this.curve._wnafMulAdd(1, i, s, 2); -}; -Ln.prototype.jmulAdd = function(e, r, n) { - var i = [this, r], s = [e, n]; - return this.curve.endo ? this.curve._endoWnafMulAdd(i, s, !0) : this.curve._wnafMulAdd(1, i, s, 2, !0); -}; -Ln.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); -}; -Ln.prototype.neg = function(e) { - if (this.inf) - return this; - var r = this.curve.point(this.x, this.y.redNeg()); - if (e && this.precomputed) { - var n = this.precomputed, i = function(s) { - return s.neg(); - }; - r.precomputed = { - naf: n.naf && { - wnd: n.naf.wnd, - points: n.naf.points.map(i) - }, - doubles: n.doubles && { - step: n.doubles.step, - points: n.doubles.points.map(i) - } - }; - } - return r; -}; -Ln.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 qn(t, e, r, n) { - wc.BasePoint.call(this, t, "jacobian"), e === null && r === null && n === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new ir(0)) : (this.x = new ir(e, 16), this.y = new ir(r, 16), this.z = new ir(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.zOne = this.z === this.curve.one; -} -Wv(qn, wc.BasePoint); -is.prototype.jpoint = function(e, r, n) { - return new qn(this, e, r, n); -}; -qn.prototype.toP = function() { - if (this.isInfinity()) - return this.curve.point(null, null); - var e = this.z.redInvm(), r = e.redSqr(), n = this.x.redMul(r), i = this.y.redMul(r).redMul(e); - return this.curve.point(n, i); -}; -qn.prototype.neg = function() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); -}; -qn.prototype.add = function(e) { - if (this.isInfinity()) - return e; - if (e.isInfinity()) - return this; - var r = e.z.redSqr(), n = this.z.redSqr(), i = this.x.redMul(r), s = e.x.redMul(n), o = this.y.redMul(r.redMul(e.z)), a = e.y.redMul(n.redMul(this.z)), u = i.redSub(s), l = o.redSub(a); - if (u.cmpn(0) === 0) - return l.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); - var d = u.redSqr(), g = d.redMul(u), w = i.redMul(d), A = l.redSqr().redIAdd(g).redISub(w).redISub(w), M = l.redMul(w.redISub(A)).redISub(o.redMul(g)), N = this.z.redMul(e.z).redMul(u); - return this.curve.jpoint(A, M, N); -}; -qn.prototype.mixedAdd = function(e) { - if (this.isInfinity()) - return e.toJ(); - if (e.isInfinity()) - return this; - var r = this.z.redSqr(), n = this.x, i = e.x.redMul(r), s = this.y, o = e.y.redMul(r).redMul(this.z), a = n.redSub(i), u = s.redSub(o); - if (a.cmpn(0) === 0) - return u.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); - var l = a.redSqr(), d = l.redMul(a), g = n.redMul(l), w = u.redSqr().redIAdd(d).redISub(g).redISub(g), A = u.redMul(g.redISub(w)).redISub(s.redMul(d)), M = this.z.redMul(a); - return this.curve.jpoint(w, A, M); -}; -qn.prototype.dblp = function(e) { - if (e === 0) - return this; - if (this.isInfinity()) - return this; - if (!e) - return this.dbl(); - var r; - if (this.curve.zeroA || this.curve.threeA) { - var n = this; - for (r = 0; r < e; r++) - n = n.dbl(); - return n; - } - var i = this.curve.a, s = this.curve.tinv, o = this.x, a = this.y, u = this.z, l = u.redSqr().redSqr(), d = a.redAdd(a); - for (r = 0; r < e; r++) { - var g = o.redSqr(), w = d.redSqr(), A = w.redSqr(), M = g.redAdd(g).redIAdd(g).redIAdd(i.redMul(l)), N = o.redMul(w), L = M.redSqr().redISub(N.redAdd(N)), F = N.redISub(L), $ = M.redMul(F); - $ = $.redIAdd($).redISub(A); - var K = d.redMul(u); - r + 1 < e && (l = l.redMul(A)), o = L, u = K, d = $; - } - return this.curve.jpoint(o, d.redMul(s), u); -}; -qn.prototype.dbl = function() { - return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); -}; -qn.prototype._zeroDbl = function() { - var e, r, n; - if (this.zOne) { - var i = this.x.redSqr(), s = this.y.redSqr(), o = s.redSqr(), a = this.x.redAdd(s).redSqr().redISub(i).redISub(o); - a = a.redIAdd(a); - var u = i.redAdd(i).redIAdd(i), l = u.redSqr().redISub(a).redISub(a), d = o.redIAdd(o); - d = d.redIAdd(d), d = d.redIAdd(d), e = l, r = u.redMul(a.redISub(l)).redISub(d), n = this.y.redAdd(this.y); - } else { - var g = this.x.redSqr(), w = this.y.redSqr(), A = w.redSqr(), M = this.x.redAdd(w).redSqr().redISub(g).redISub(A); - M = M.redIAdd(M); - var N = g.redAdd(g).redIAdd(g), L = N.redSqr(), F = A.redIAdd(A); - F = F.redIAdd(F), F = F.redIAdd(F), e = L.redISub(M).redISub(M), r = N.redMul(M.redISub(e)).redISub(F), n = this.y.redMul(this.z), n = n.redIAdd(n); - } - return this.curve.jpoint(e, r, n); -}; -qn.prototype._threeDbl = function() { - var e, r, n; - if (this.zOne) { - var i = this.x.redSqr(), s = this.y.redSqr(), o = s.redSqr(), a = this.x.redAdd(s).redSqr().redISub(i).redISub(o); - a = a.redIAdd(a); - var u = i.redAdd(i).redIAdd(i).redIAdd(this.curve.a), l = u.redSqr().redISub(a).redISub(a); - e = l; - var d = o.redIAdd(o); - d = d.redIAdd(d), d = d.redIAdd(d), r = u.redMul(a.redISub(l)).redISub(d), n = this.y.redAdd(this.y); - } else { - var g = this.z.redSqr(), w = this.y.redSqr(), A = this.x.redMul(w), M = this.x.redSub(g).redMul(this.x.redAdd(g)); - M = M.redAdd(M).redIAdd(M); - var N = A.redIAdd(A); - N = N.redIAdd(N); - var L = N.redAdd(N); - e = M.redSqr().redISub(L), n = this.y.redAdd(this.z).redSqr().redISub(w).redISub(g); - var F = w.redSqr(); - F = F.redIAdd(F), F = F.redIAdd(F), F = F.redIAdd(F), r = M.redMul(N.redISub(e)).redISub(F); - } - return this.curve.jpoint(e, r, n); -}; -qn.prototype._dbl = function() { - var e = this.curve.a, r = this.x, n = this.y, i = this.z, s = i.redSqr().redSqr(), o = r.redSqr(), a = n.redSqr(), u = o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)), l = r.redAdd(r); - l = l.redIAdd(l); - var d = l.redMul(a), g = u.redSqr().redISub(d.redAdd(d)), w = d.redISub(g), A = a.redSqr(); - A = A.redIAdd(A), A = A.redIAdd(A), A = A.redIAdd(A); - var M = u.redMul(w).redISub(A), N = n.redAdd(n).redMul(i); - return this.curve.jpoint(g, M, N); -}; -qn.prototype.trpl = function() { - if (!this.curve.zeroA) - return this.dbl().add(this); - var e = this.x.redSqr(), r = this.y.redSqr(), n = this.z.redSqr(), i = r.redSqr(), s = e.redAdd(e).redIAdd(e), o = s.redSqr(), a = this.x.redAdd(r).redSqr().redISub(e).redISub(i); - a = a.redIAdd(a), a = a.redAdd(a).redIAdd(a), a = a.redISub(o); - var u = a.redSqr(), l = i.redIAdd(i); - l = l.redIAdd(l), l = l.redIAdd(l), l = l.redIAdd(l); - var d = s.redIAdd(a).redSqr().redISub(o).redISub(u).redISub(l), g = r.redMul(d); - g = g.redIAdd(g), g = g.redIAdd(g); - var w = this.x.redMul(u).redISub(g); - w = w.redIAdd(w), w = w.redIAdd(w); - var A = this.y.redMul(d.redMul(l.redISub(d)).redISub(a.redMul(u))); - A = A.redIAdd(A), A = A.redIAdd(A), A = A.redIAdd(A); - var M = this.z.redAdd(a).redSqr().redISub(n).redISub(u); - return this.curve.jpoint(w, A, M); -}; -qn.prototype.mul = function(e, r) { - return e = new ir(e, r), this.curve._wnafMul(this, e); -}; -qn.prototype.eq = function(e) { - if (e.type === "affine") - return this.eq(e.toJ()); - if (this === e) - return !0; - var r = this.z.redSqr(), n = e.z.redSqr(); - if (this.x.redMul(n).redISub(e.x.redMul(r)).cmpn(0) !== 0) - return !1; - var i = r.redMul(this.z), s = n.redMul(e.z); - return this.y.redMul(s).redISub(e.y.redMul(i)).cmpn(0) === 0; -}; -qn.prototype.eqXToP = function(e) { - var r = this.z.redSqr(), n = e.toRed(this.curve.red).redMul(r); - if (this.x.cmp(n) === 0) - return !0; - for (var i = e.clone(), s = this.curve.redN.redMul(r); ; ) { - if (i.iadd(this.curve.n), i.cmp(this.curve.p) >= 0) - return !1; - if (n.redIAdd(s), this.x.cmp(n) === 0) - return !0; - } -}; -qn.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; -}; -qn.prototype.isInfinity = function() { - return this.z.cmpn(0) === 0; -}; -var Ad = $u(function(t, e) { - var r = e; - r.base = wc, r.short = aj, r.mont = /*RicMoo:ethers:require(./mont)*/ - null, r.edwards = /*RicMoo:ethers:require(./edwards)*/ - null; -}), Pd = $u(function(t, e) { - var r = e, n = $i.assert; - function i(a) { - a.type === "short" ? this.curve = new Ad.short(a) : a.type === "edwards" ? this.curve = new Ad.edwards(a) : this.curve = new Ad.mont(a), this.g = this.curve.g, this.n = this.curve.n, this.hash = a.hash, n(this.g.validate(), "Invalid curve"), n(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); - } - r.PresetCurve = i; - function s(a, u) { - Object.defineProperty(r, a, { - configurable: !0, - enumerable: !0, - get: function() { - var l = new i(u); - return Object.defineProperty(r, a, { - configurable: !0, - enumerable: !0, - value: l - }), l; - } - }); - } - 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: bo.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: bo.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: bo.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: bo.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: bo.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: bo.sha256, - gRed: !1, - g: [ - "9" - ] - }), s("ed25519", { - type: "edwards", - prime: "p25519", - p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", - a: "-1", - c: "1", - // -121665 * (121666^(-1)) (mod P) - d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", - n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", - hash: bo.sha256, - gRed: !1, - g: [ - "216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", - // 4/5 - "6666666666666666666666666666666666666666666666666666666666666658" - ] - }); - var o; - try { - o = /*RicMoo:ethers:require(./precomputed/secp256k1)*/ - 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: bo.sha256, - // Precomputed endomorphism - beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", - lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", - basis: [ - { - a: "3086d221a7d46bcde86c90e49284eb15", - b: "-e4437ed6010e88286f547fa90abfe4c3" - }, - { - a: "114ca50f7a8e2f3f657c1108d9d44cfd8", - b: "3086d221a7d46bcde86c90e49284eb15" - } - ], - gRed: !1, - g: [ - "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", - "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", - o - ] - }); -}); -function va(t) { - if (!(this instanceof va)) - return new va(t); - this.hash = t.hash, this.predResist = !!t.predResist, this.outLen = this.hash.outSize, this.minEntropy = t.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; - var e = ws.toArray(t.entropy, t.entropyEnc || "hex"), r = ws.toArray(t.nonce, t.nonceEnc || "hex"), n = ws.toArray(t.pers, t.persEnc || "hex"); - Hv( - e.length >= this.minEntropy / 8, - "Not enough entropy. Minimum is: " + this.minEntropy + " bits" - ), this._init(e, r, n); -} -var d8 = va; -va.prototype._init = function(e, r, n) { - var i = e.concat(r).concat(n); - this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); - for (var s = 0; s < this.V.length; s++) - this.K[s] = 0, this.V[s] = 1; - this._update(i), this._reseed = 1, this.reseedInterval = 281474976710656; -}; -va.prototype._hmac = function() { - return new bo.hmac(this.hash, this.K); -}; -va.prototype._update = function(e) { - var r = this._hmac().update(this.V).update([0]); - e && (r = r.update(e)), this.K = r.digest(), this.V = this._hmac().update(this.V).digest(), e && (this.K = this._hmac().update(this.V).update([1]).update(e).digest(), this.V = this._hmac().update(this.V).digest()); -}; -va.prototype.reseed = function(e, r, n, i) { - typeof r != "string" && (i = n, n = r, r = null), e = ws.toArray(e, r), n = ws.toArray(n, i), Hv( - e.length >= this.minEntropy / 8, - "Not enough entropy. Minimum is: " + this.minEntropy + " bits" - ), this._update(e.concat(n || [])), this._reseed = 1; -}; -va.prototype.generate = function(e, r, n, i) { - if (this._reseed > this.reseedInterval) - throw new Error("Reseed is required"); - typeof r != "string" && (i = n, n = r, r = null), n && (n = ws.toArray(n, i || "hex"), this._update(n)); - for (var s = []; s.length < e; ) - this.V = this._hmac().update(this.V).digest(), s = s.concat(this.V); - var o = s.slice(0, e); - return this._update(n), this._reseed++, ws.encode(o, r); -}; -var E1 = $i.assert; -function Zn(t, e) { - this.ec = t, this.priv = null, this.pub = null, e.priv && this._importPrivate(e.priv, e.privEnc), e.pub && this._importPublic(e.pub, e.pubEnc); -} -var Kv = Zn; -Zn.fromPublic = function(e, r, n) { - return r instanceof Zn ? r : new Zn(e, { - pub: r, - pubEnc: n - }); -}; -Zn.fromPrivate = function(e, r, n) { - return r instanceof Zn ? r : new Zn(e, { - priv: r, - privEnc: n - }); -}; -Zn.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" }; -}; -Zn.prototype.getPublic = function(e, r) { - return typeof e == "string" && (r = e, e = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r ? this.pub.encode(r, e) : this.pub; -}; -Zn.prototype.getPrivate = function(e) { - return e === "hex" ? this.priv.toString(16, 2) : this.priv; -}; -Zn.prototype._importPrivate = function(e, r) { - this.priv = new ir(e, r || 16), this.priv = this.priv.umod(this.ec.curve.n); -}; -Zn.prototype._importPublic = function(e, r) { - if (e.x || e.y) { - this.ec.curve.type === "mont" ? E1(e.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && E1(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, r); -}; -Zn.prototype.derive = function(e) { - return e.validate() || E1(e.validate(), "public point not validated"), e.mul(this.priv).getX(); -}; -Zn.prototype.sign = function(e, r, n) { - return this.ec.sign(e, this, r, n); -}; -Zn.prototype.verify = function(e, r) { - return this.ec.verify(e, r, this); -}; -Zn.prototype.inspect = function() { - return ""; -}; -var cj = $i.assert; -function H0(t, e) { - if (t instanceof H0) - return t; - this._importDER(t, e) || (cj(t.r && t.s, "Signature without r or s"), this.r = new ir(t.r, 16), this.s = new ir(t.s, 16), t.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = t.recoveryParam); -} -var W0 = H0; -function uj() { - this.place = 0; -} -function im(t, e) { - var r = t[e.place++]; - if (!(r & 128)) - return r; - var n = r & 15; - if (n === 0 || n > 4) - return !1; - for (var i = 0, s = 0, o = e.place; s < n; s++, o++) - i <<= 8, i |= t[o], i >>>= 0; - return i <= 127 ? !1 : (e.place = o, i); -} -function Sx(t) { - for (var e = 0, r = t.length - 1; !t[e] && !(t[e + 1] & 128) && e < r; ) - e++; - return e === 0 ? t : t.slice(e); -} -H0.prototype._importDER = function(e, r) { - e = $i.toArray(e, r); - var n = new uj(); - if (e[n.place++] !== 48) - return !1; - var i = im(e, n); - if (i === !1 || i + n.place !== e.length || e[n.place++] !== 2) - return !1; - var s = im(e, n); - if (s === !1) - return !1; - var o = e.slice(n.place, s + n.place); - if (n.place += s, e[n.place++] !== 2) - return !1; - var a = im(e, n); - if (a === !1 || e.length !== a + n.place) - return !1; - var u = e.slice(n.place, a + n.place); - if (o[0] === 0) - if (o[1] & 128) - o = o.slice(1); - else - return !1; - if (u[0] === 0) - if (u[1] & 128) - u = u.slice(1); - else - return !1; - return this.r = new ir(o), this.s = new ir(u), this.recoveryParam = null, !0; -}; -function sm(t, e) { - if (e < 128) { - t.push(e); - return; - } - var r = 1 + (Math.log(e) / Math.LN2 >>> 3); - for (t.push(r | 128); --r; ) - t.push(e >>> (r << 3) & 255); - t.push(e); -} -H0.prototype.toDER = function(e) { - var r = this.r.toArray(), n = this.s.toArray(); - for (r[0] & 128 && (r = [0].concat(r)), n[0] & 128 && (n = [0].concat(n)), r = Sx(r), n = Sx(n); !n[0] && !(n[1] & 128); ) - n = n.slice(1); - var i = [2]; - sm(i, r.length), i = i.concat(r), i.push(2), sm(i, n.length); - var s = i.concat(n), o = [48]; - return sm(o, s.length), o = o.concat(s), $i.encode(o, e); -}; -var fj = ( - /*RicMoo:ethers:require(brorand)*/ - function() { - throw new Error("unsupported"); - } -), p8 = $i.assert; -function Qi(t) { - if (!(this instanceof Qi)) - return new Qi(t); - typeof t == "string" && (p8( - Object.prototype.hasOwnProperty.call(Pd, t), - "Unknown curve " + t - ), t = Pd[t]), t instanceof Pd.PresetCurve && (t = { curve: t }), this.curve = t.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = t.curve.g, this.g.precompute(t.curve.n.bitLength() + 1), this.hash = t.hash || t.curve.hash; -} -var lj = Qi; -Qi.prototype.keyPair = function(e) { - return new Kv(this, e); -}; -Qi.prototype.keyFromPrivate = function(e, r) { - return Kv.fromPrivate(this, e, r); -}; -Qi.prototype.keyFromPublic = function(e, r) { - return Kv.fromPublic(this, e, r); -}; -Qi.prototype.genKeyPair = function(e) { - e || (e = {}); - for (var r = new d8({ - hash: this.hash, - pers: e.pers, - persEnc: e.persEnc || "utf8", - entropy: e.entropy || fj(this.hash.hmacStrength), - entropyEnc: e.entropy && e.entropyEnc || "utf8", - nonce: this.n.toArray() - }), n = this.n.byteLength(), i = this.n.sub(new ir(2)); ; ) { - var s = new ir(r.generate(n)); - if (!(s.cmp(i) > 0)) - return s.iaddn(1), this.keyFromPrivate(s); - } -}; -Qi.prototype._truncateToN = function(e, r) { - var n = e.byteLength() * 8 - this.n.bitLength(); - return n > 0 && (e = e.ushrn(n)), !r && e.cmp(this.n) >= 0 ? e.sub(this.n) : e; -}; -Qi.prototype.sign = function(e, r, n, i) { - typeof n == "object" && (i = n, n = null), i || (i = {}), r = this.keyFromPrivate(r, n), e = this._truncateToN(new ir(e, 16)); - for (var s = this.n.byteLength(), o = r.getPrivate().toArray("be", s), a = e.toArray("be", s), u = new d8({ - hash: this.hash, - entropy: o, - nonce: a, - pers: i.pers, - persEnc: i.persEnc || "utf8" - }), l = this.n.sub(new ir(1)), d = 0; ; d++) { - var g = i.k ? i.k(d) : new ir(u.generate(this.n.byteLength())); - if (g = this._truncateToN(g, !0), !(g.cmpn(1) <= 0 || g.cmp(l) >= 0)) { - var w = this.g.mul(g); - if (!w.isInfinity()) { - var A = w.getX(), M = A.umod(this.n); - if (M.cmpn(0) !== 0) { - var N = g.invm(this.n).mul(M.mul(r.getPrivate()).iadd(e)); - if (N = N.umod(this.n), N.cmpn(0) !== 0) { - var L = (w.getY().isOdd() ? 1 : 0) | (A.cmp(M) !== 0 ? 2 : 0); - return i.canonical && N.cmp(this.nh) > 0 && (N = this.n.sub(N), L ^= 1), new W0({ r: M, s: N, recoveryParam: L }); - } - } - } - } - } -}; -Qi.prototype.verify = function(e, r, n, i) { - e = this._truncateToN(new ir(e, 16)), n = this.keyFromPublic(n, i), r = new W0(r, "hex"); - var s = r.r, o = r.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), u = a.mul(e).umod(this.n), l = a.mul(s).umod(this.n), d; - return this.curve._maxwellTrick ? (d = this.g.jmulAdd(u, n.getPublic(), l), d.isInfinity() ? !1 : d.eqXToP(s)) : (d = this.g.mulAdd(u, n.getPublic(), l), d.isInfinity() ? !1 : d.getX().umod(this.n).cmp(s) === 0); -}; -Qi.prototype.recoverPubKey = function(t, e, r, n) { - p8((3 & r) === r, "The recovery param is more than two bits"), e = new W0(e, n); - var i = this.n, s = new ir(t), o = e.r, a = e.s, u = r & 1, l = r >> 1; - if (o.cmp(this.curve.p.umod(this.curve.n)) >= 0 && l) - throw new Error("Unable to find sencond key candinate"); - l ? o = this.curve.pointFromX(o.add(this.curve.n), u) : o = this.curve.pointFromX(o, u); - var d = e.r.invm(i), g = i.sub(s).mul(d).umod(i), w = a.mul(d).umod(i); - return this.g.mulAdd(g, o, w); -}; -Qi.prototype.getKeyRecoveryParam = function(t, e, r, n) { - if (e = new W0(e, n), e.recoveryParam !== null) - return e.recoveryParam; - for (var i = 0; i < 4; i++) { - var s; - try { - s = this.recoverPubKey(t, e, i); - } catch { - continue; - } - if (s.eq(r)) - return i; - } - throw new Error("Unable to find valid recovery factor"); -}; -var hj = $u(function(t, e) { - var r = e; - r.version = "6.5.4", r.utils = $i, r.rand = /*RicMoo:ethers:require(brorand)*/ - function() { - throw new Error("unsupported"); - }, r.curve = Ad, r.curves = Pd, r.ec = lj, r.eddsa = /*RicMoo:ethers:require(./elliptic/eddsa)*/ - null; -}), dj = hj.ec; -const pj = "signing-key/5.7.0", S1 = new Yr(pj); -let om = null; -function oa() { - return om || (om = new dj("secp256k1")), om; -} -class gj { - constructor(e) { - xf(this, "curve", "secp256k1"), xf(this, "privateKey", Ti(e)), wB(this.privateKey) !== 32 && S1.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]"); - const r = oa().keyFromPrivate(wn(this.privateKey)); - xf(this, "publicKey", "0x" + r.getPublic(!1, "hex")), xf(this, "compressedPublicKey", "0x" + r.getPublic(!0, "hex")), xf(this, "_isSigningKey", !0); - } - _addPoint(e) { - const r = oa().keyFromPublic(wn(this.publicKey)), n = oa().keyFromPublic(wn(e)); - return "0x" + r.pub.add(n.pub).encodeCompressed("hex"); - } - signDigest(e) { - const r = oa().keyFromPrivate(wn(this.privateKey)), n = wn(e); - n.length !== 32 && S1.throwArgumentError("bad digest length", "digest", e); - const i = r.sign(n, { canonical: !0 }); - return K4({ - recoveryParam: i.recoveryParam, - r: fu("0x" + i.r.toString(16), 32), - s: fu("0x" + i.s.toString(16), 32) - }); - } - computeSharedSecret(e) { - const r = oa().keyFromPrivate(wn(this.privateKey)), n = oa().keyFromPublic(wn(g8(e))); - return fu("0x" + r.derive(n.getPublic()).toString(16), 32); - } - static isSigningKey(e) { - return !!(e && e._isSigningKey); - } -} -function mj(t, e) { - const r = K4(e), n = { r: wn(r.r), s: wn(r.s) }; - return "0x" + oa().recoverPubKey(wn(t), n, r.recoveryParam).encode("hex", !1); -} -function g8(t, e) { - const r = wn(t); - return r.length === 32 ? new gj(r).publicKey : r.length === 33 ? "0x" + oa().keyFromPublic(r).getPublic(!1, "hex") : r.length === 65 ? Ti(r) : S1.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); -} -var Ax; -(function(t) { - t[t.legacy = 0] = "legacy", t[t.eip2930 = 1] = "eip2930", t[t.eip1559 = 2] = "eip1559"; -})(Ax || (Ax = {})); -function vj(t) { - const e = g8(t); - return RB(mx(jv(mx(e, 1)), 12)); -} -function bj(t, e) { - return vj(mj(wn(t), e)); -} -var Vv = {}, K0 = {}; -Object.defineProperty(K0, "__esModule", { value: !0 }); -var Vn = or, A1 = ki, yj = 20; -function wj(t, e, r) { - for (var n = 1634760805, i = 857760878, s = 2036477234, o = 1797285236, a = r[3] << 24 | r[2] << 16 | r[1] << 8 | r[0], u = r[7] << 24 | r[6] << 16 | r[5] << 8 | r[4], l = r[11] << 24 | r[10] << 16 | r[9] << 8 | r[8], d = r[15] << 24 | r[14] << 16 | r[13] << 8 | r[12], g = r[19] << 24 | r[18] << 16 | r[17] << 8 | r[16], w = r[23] << 24 | r[22] << 16 | r[21] << 8 | r[20], A = r[27] << 24 | r[26] << 16 | r[25] << 8 | r[24], M = r[31] << 24 | r[30] << 16 | r[29] << 8 | r[28], N = e[3] << 24 | e[2] << 16 | e[1] << 8 | e[0], L = e[7] << 24 | e[6] << 16 | e[5] << 8 | e[4], F = e[11] << 24 | e[10] << 16 | e[9] << 8 | e[8], $ = e[15] << 24 | e[14] << 16 | e[13] << 8 | e[12], K = n, H = i, V = s, te = o, R = a, W = u, pe = l, Ee = d, Y = g, S = w, m = A, f = M, p = N, b = L, x = F, _ = $, E = 0; E < yj; E += 2) - K = K + R | 0, p ^= K, p = p >>> 16 | p << 16, Y = Y + p | 0, R ^= Y, R = R >>> 20 | R << 12, H = H + W | 0, b ^= H, b = b >>> 16 | b << 16, S = S + b | 0, W ^= S, W = W >>> 20 | W << 12, V = V + pe | 0, x ^= V, x = x >>> 16 | x << 16, m = m + x | 0, pe ^= m, pe = pe >>> 20 | pe << 12, te = te + Ee | 0, _ ^= te, _ = _ >>> 16 | _ << 16, f = f + _ | 0, Ee ^= f, Ee = Ee >>> 20 | Ee << 12, V = V + pe | 0, x ^= V, x = x >>> 24 | x << 8, m = m + x | 0, pe ^= m, pe = pe >>> 25 | pe << 7, te = te + Ee | 0, _ ^= te, _ = _ >>> 24 | _ << 8, f = f + _ | 0, Ee ^= f, Ee = Ee >>> 25 | Ee << 7, H = H + W | 0, b ^= H, b = b >>> 24 | b << 8, S = S + b | 0, W ^= S, W = W >>> 25 | W << 7, K = K + R | 0, p ^= K, p = p >>> 24 | p << 8, Y = Y + p | 0, R ^= Y, R = R >>> 25 | R << 7, K = K + W | 0, _ ^= K, _ = _ >>> 16 | _ << 16, m = m + _ | 0, W ^= m, W = W >>> 20 | W << 12, H = H + pe | 0, p ^= H, p = p >>> 16 | p << 16, f = f + p | 0, pe ^= f, pe = pe >>> 20 | pe << 12, V = V + Ee | 0, b ^= V, b = b >>> 16 | b << 16, Y = Y + b | 0, Ee ^= Y, Ee = Ee >>> 20 | Ee << 12, te = te + R | 0, x ^= te, x = x >>> 16 | x << 16, S = S + x | 0, R ^= S, R = R >>> 20 | R << 12, V = V + Ee | 0, b ^= V, b = b >>> 24 | b << 8, Y = Y + b | 0, Ee ^= Y, Ee = Ee >>> 25 | Ee << 7, te = te + R | 0, x ^= te, x = x >>> 24 | x << 8, S = S + x | 0, R ^= S, R = R >>> 25 | R << 7, H = H + pe | 0, p ^= H, p = p >>> 24 | p << 8, f = f + p | 0, pe ^= f, pe = pe >>> 25 | pe << 7, K = K + W | 0, _ ^= K, _ = _ >>> 24 | _ << 8, m = m + _ | 0, W ^= m, W = W >>> 25 | W << 7; - Vn.writeUint32LE(K + n | 0, t, 0), Vn.writeUint32LE(H + i | 0, t, 4), Vn.writeUint32LE(V + s | 0, t, 8), Vn.writeUint32LE(te + o | 0, t, 12), Vn.writeUint32LE(R + a | 0, t, 16), Vn.writeUint32LE(W + u | 0, t, 20), Vn.writeUint32LE(pe + l | 0, t, 24), Vn.writeUint32LE(Ee + d | 0, t, 28), Vn.writeUint32LE(Y + g | 0, t, 32), Vn.writeUint32LE(S + w | 0, t, 36), Vn.writeUint32LE(m + A | 0, t, 40), Vn.writeUint32LE(f + M | 0, t, 44), Vn.writeUint32LE(p + N | 0, t, 48), Vn.writeUint32LE(b + L | 0, t, 52), Vn.writeUint32LE(x + F | 0, t, 56), Vn.writeUint32LE(_ + $ | 0, t, 60); -} -function m8(t, e, r, n, i) { - if (i === void 0 && (i = 0), t.length !== 32) - throw new Error("ChaCha: key size must be 32 bytes"); - if (n.length < r.length) - throw new Error("ChaCha: destination is shorter than source"); - var s, o; - if (i === 0) { - if (e.length !== 8 && e.length !== 12) - throw new Error("ChaCha nonce must be 8 or 12 bytes"); - s = new Uint8Array(16), o = s.length - e.length, s.set(e, o); - } else { - if (e.length !== 16) - throw new Error("ChaCha nonce with counter must be 16 bytes"); - s = e, o = i; - } - for (var a = new Uint8Array(64), u = 0; u < r.length; u += 64) { - wj(a, s, t); - for (var l = u; l < u + 64 && l < r.length; l++) - n[l] = r[l] ^ a[l - u]; - _j(s, 0, o); - } - return A1.wipe(a), i === 0 && A1.wipe(s), n; -} -K0.streamXOR = m8; -function xj(t, e, r, n) { - return n === void 0 && (n = 0), A1.wipe(r), m8(t, e, r, r, n); -} -K0.stream = xj; -function _j(t, e, r) { - for (var n = 1; r--; ) - n = n + (t[e] & 255) | 0, t[e] = n & 255, n >>>= 8, e++; - if (n > 0) - throw new Error("ChaCha: counter overflow"); -} -var v8 = {}, Ia = {}; -Object.defineProperty(Ia, "__esModule", { value: !0 }); -function Ej(t, e, r) { - return ~(t - 1) & e | t - 1 & r; -} -Ia.select = Ej; -function Sj(t, e) { - return (t | 0) - (e | 0) - 1 >>> 31 & 1; -} -Ia.lessOrEqual = Sj; -function b8(t, e) { - if (t.length !== e.length) - return 0; - for (var r = 0, n = 0; n < t.length; n++) - r |= t[n] ^ e[n]; - return 1 & r - 1 >>> 8; -} -Ia.compare = b8; -function Aj(t, e) { - return t.length === 0 || e.length === 0 ? !1 : b8(t, e) !== 0; -} -Ia.equal = Aj; -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }); - var e = Ia, r = ki; - t.DIGEST_LENGTH = 16; - var n = ( - /** @class */ - function() { - function o(a) { - this.digestLength = t.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 u = a[0] | a[1] << 8; - this._r[0] = u & 8191; - var l = a[2] | a[3] << 8; - this._r[1] = (u >>> 13 | l << 3) & 8191; - var d = a[4] | a[5] << 8; - this._r[2] = (l >>> 10 | d << 6) & 7939; - var g = a[6] | a[7] << 8; - this._r[3] = (d >>> 7 | g << 9) & 8191; - var w = a[8] | a[9] << 8; - this._r[4] = (g >>> 4 | w << 12) & 255, this._r[5] = w >>> 1 & 8190; - var A = a[10] | a[11] << 8; - this._r[6] = (w >>> 14 | A << 2) & 8191; - var M = a[12] | a[13] << 8; - this._r[7] = (A >>> 11 | M << 5) & 8065; - var N = a[14] | a[15] << 8; - this._r[8] = (M >>> 8 | N << 8) & 8191, this._r[9] = N >>> 5 & 127, this._pad[0] = a[16] | a[17] << 8, this._pad[1] = a[18] | a[19] << 8, this._pad[2] = a[20] | a[21] << 8, this._pad[3] = a[22] | a[23] << 8, this._pad[4] = a[24] | a[25] << 8, this._pad[5] = a[26] | a[27] << 8, this._pad[6] = a[28] | a[29] << 8, this._pad[7] = a[30] | a[31] << 8; - } - return o.prototype._blocks = function(a, u, l) { - for (var d = this._fin ? 0 : 2048, g = this._h[0], w = this._h[1], A = this._h[2], M = this._h[3], N = this._h[4], L = this._h[5], F = this._h[6], $ = this._h[7], K = this._h[8], H = this._h[9], V = this._r[0], te = this._r[1], R = this._r[2], W = this._r[3], pe = this._r[4], Ee = this._r[5], Y = this._r[6], S = this._r[7], m = this._r[8], f = this._r[9]; l >= 16; ) { - var p = a[u + 0] | a[u + 1] << 8; - g += p & 8191; - var b = a[u + 2] | a[u + 3] << 8; - w += (p >>> 13 | b << 3) & 8191; - var x = a[u + 4] | a[u + 5] << 8; - A += (b >>> 10 | x << 6) & 8191; - var _ = a[u + 6] | a[u + 7] << 8; - M += (x >>> 7 | _ << 9) & 8191; - var E = a[u + 8] | a[u + 9] << 8; - N += (_ >>> 4 | E << 12) & 8191, L += E >>> 1 & 8191; - var v = a[u + 10] | a[u + 11] << 8; - F += (E >>> 14 | v << 2) & 8191; - var P = a[u + 12] | a[u + 13] << 8; - $ += (v >>> 11 | P << 5) & 8191; - var I = a[u + 14] | a[u + 15] << 8; - K += (P >>> 8 | I << 8) & 8191, H += I >>> 5 | d; - var B = 0, ce = B; - ce += g * V, ce += w * (5 * f), ce += A * (5 * m), ce += M * (5 * S), ce += N * (5 * Y), B = ce >>> 13, ce &= 8191, ce += L * (5 * Ee), ce += F * (5 * pe), ce += $ * (5 * W), ce += K * (5 * R), ce += H * (5 * te), B += ce >>> 13, ce &= 8191; - var D = B; - D += g * te, D += w * V, D += A * (5 * f), D += M * (5 * m), D += N * (5 * S), B = D >>> 13, D &= 8191, D += L * (5 * Y), D += F * (5 * Ee), D += $ * (5 * pe), D += K * (5 * W), D += H * (5 * R), B += D >>> 13, D &= 8191; - var oe = B; - oe += g * R, oe += w * te, oe += A * V, oe += M * (5 * f), oe += N * (5 * m), B = oe >>> 13, oe &= 8191, oe += L * (5 * S), oe += F * (5 * Y), oe += $ * (5 * Ee), oe += K * (5 * pe), oe += H * (5 * W), B += oe >>> 13, oe &= 8191; - var Z = B; - Z += g * W, Z += w * R, Z += A * te, Z += M * V, Z += N * (5 * f), B = Z >>> 13, Z &= 8191, Z += L * (5 * m), Z += F * (5 * S), Z += $ * (5 * Y), Z += K * (5 * Ee), Z += H * (5 * pe), B += Z >>> 13, Z &= 8191; - var J = B; - J += g * pe, J += w * W, J += A * R, J += M * te, J += N * V, B = J >>> 13, J &= 8191, J += L * (5 * f), J += F * (5 * m), J += $ * (5 * S), J += K * (5 * Y), J += H * (5 * Ee), B += J >>> 13, J &= 8191; - var Q = B; - Q += g * Ee, Q += w * pe, Q += A * W, Q += M * R, Q += N * te, B = Q >>> 13, Q &= 8191, Q += L * V, Q += F * (5 * f), Q += $ * (5 * m), Q += K * (5 * S), Q += H * (5 * Y), B += Q >>> 13, Q &= 8191; - var T = B; - T += g * Y, T += w * Ee, T += A * pe, T += M * W, T += N * R, B = T >>> 13, T &= 8191, T += L * te, T += F * V, T += $ * (5 * f), T += K * (5 * m), T += H * (5 * S), B += T >>> 13, T &= 8191; - var X = B; - X += g * S, X += w * Y, X += A * Ee, X += M * pe, X += N * W, B = X >>> 13, X &= 8191, X += L * R, X += F * te, X += $ * V, X += K * (5 * f), X += H * (5 * m), B += X >>> 13, X &= 8191; - var re = B; - re += g * m, re += w * S, re += A * Y, re += M * Ee, re += N * pe, B = re >>> 13, re &= 8191, re += L * W, re += F * R, re += $ * te, re += K * V, re += H * (5 * f), B += re >>> 13, re &= 8191; - var de = B; - de += g * f, de += w * m, de += A * S, de += M * Y, de += N * Ee, B = de >>> 13, de &= 8191, de += L * pe, de += F * W, de += $ * R, de += K * te, de += H * V, B += de >>> 13, de &= 8191, B = (B << 2) + B | 0, B = B + ce | 0, ce = B & 8191, B = B >>> 13, D += B, g = ce, w = D, A = oe, M = Z, N = J, L = Q, F = T, $ = X, K = re, H = de, u += 16, l -= 16; - } - this._h[0] = g, this._h[1] = w, this._h[2] = A, this._h[3] = M, this._h[4] = N, this._h[5] = L, this._h[6] = F, this._h[7] = $, this._h[8] = K, this._h[9] = H; - }, o.prototype.finish = function(a, u) { - u === void 0 && (u = 0); - var l = new Uint16Array(10), d, g, w, 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 (d = this._h[1] >>> 13, this._h[1] &= 8191, A = 2; A < 10; A++) - this._h[A] += d, d = this._h[A] >>> 13, this._h[A] &= 8191; - for (this._h[0] += d * 5, d = this._h[0] >>> 13, this._h[0] &= 8191, this._h[1] += d, d = this._h[1] >>> 13, this._h[1] &= 8191, this._h[2] += d, l[0] = this._h[0] + 5, d = l[0] >>> 13, l[0] &= 8191, A = 1; A < 10; A++) - l[A] = this._h[A] + d, d = l[A] >>> 13, l[A] &= 8191; - for (l[9] -= 8192, g = (d ^ 1) - 1, A = 0; A < 10; A++) - l[A] &= g; - for (g = ~g, A = 0; A < 10; A++) - this._h[A] = this._h[A] & g | l[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, w = this._h[0] + this._pad[0], this._h[0] = w & 65535, A = 1; A < 8; A++) - w = (this._h[A] + this._pad[A] | 0) + (w >>> 16) | 0, this._h[A] = w & 65535; - return a[u + 0] = this._h[0] >>> 0, a[u + 1] = this._h[0] >>> 8, a[u + 2] = this._h[1] >>> 0, a[u + 3] = this._h[1] >>> 8, a[u + 4] = this._h[2] >>> 0, a[u + 5] = this._h[2] >>> 8, a[u + 6] = this._h[3] >>> 0, a[u + 7] = this._h[3] >>> 8, a[u + 8] = this._h[4] >>> 0, a[u + 9] = this._h[4] >>> 8, a[u + 10] = this._h[5] >>> 0, a[u + 11] = this._h[5] >>> 8, a[u + 12] = this._h[6] >>> 0, a[u + 13] = this._h[6] >>> 8, a[u + 14] = this._h[7] >>> 0, a[u + 15] = this._h[7] >>> 8, this._finished = !0, this; - }, o.prototype.update = function(a) { - var u = 0, l = a.length, d; - if (this._leftover) { - d = 16 - this._leftover, d > l && (d = l); - for (var g = 0; g < d; g++) - this._buffer[this._leftover + g] = a[u + g]; - if (l -= d, u += d, this._leftover += d, this._leftover < 16) - return this; - this._blocks(this._buffer, 0, 16), this._leftover = 0; - } - if (l >= 16 && (d = l - l % 16, this._blocks(a, u, d), u += d, l -= d), l) { - for (var g = 0; g < l; g++) - this._buffer[this._leftover + g] = a[u + g]; - this._leftover += l; - } - return this; - }, o.prototype.digest = function() { - if (this._finished) - throw new Error("Poly1305 was finished"); - var a = new Uint8Array(16); - return this.finish(a), a; - }, o.prototype.clean = function() { - return r.wipe(this._buffer), r.wipe(this._r), r.wipe(this._h), r.wipe(this._pad), this._leftover = 0, this._fin = 0, this._finished = !0, this; - }, o; - }() - ); - t.Poly1305 = n; - function i(o, a) { - var u = new n(o); - u.update(a); - var l = u.digest(); - return u.clean(), l; - } - t.oneTimeAuth = i; - function s(o, a) { - return o.length !== t.DIGEST_LENGTH || a.length !== t.DIGEST_LENGTH ? !1 : e.equal(o, a); - } - t.equal = s; -})(v8); -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }); - var e = K0, r = v8, n = ki, i = or, s = Ia; - t.KEY_LENGTH = 32, t.NONCE_LENGTH = 12, t.TAG_LENGTH = 16; - var o = new Uint8Array(16), a = ( - /** @class */ - function() { - function u(l) { - if (this.nonceLength = t.NONCE_LENGTH, this.tagLength = t.TAG_LENGTH, l.length !== t.KEY_LENGTH) - throw new Error("ChaCha20Poly1305 needs 32-byte key"); - this._key = new Uint8Array(l); - } - return u.prototype.seal = function(l, d, g, w) { - if (l.length > 16) - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - var A = new Uint8Array(16); - A.set(l, A.length - l.length); - var M = new Uint8Array(32); - e.stream(this._key, A, M, 4); - var N = d.length + this.tagLength, L; - if (w) { - if (w.length !== N) - throw new Error("ChaCha20Poly1305: incorrect destination length"); - L = w; - } else - L = new Uint8Array(N); - return e.streamXOR(this._key, A, d, L, 4), this._authenticate(L.subarray(L.length - this.tagLength, L.length), M, L.subarray(0, L.length - this.tagLength), g), n.wipe(A), L; - }, u.prototype.open = function(l, d, g, w) { - if (l.length > 16) - throw new Error("ChaCha20Poly1305: incorrect nonce length"); - if (d.length < this.tagLength) - return null; - var A = new Uint8Array(16); - A.set(l, A.length - l.length); - var M = new Uint8Array(32); - e.stream(this._key, A, M, 4); - var N = new Uint8Array(this.tagLength); - if (this._authenticate(N, M, d.subarray(0, d.length - this.tagLength), g), !s.equal(N, d.subarray(d.length - this.tagLength, d.length))) - return null; - var L = d.length - this.tagLength, F; - if (w) { - if (w.length !== L) - throw new Error("ChaCha20Poly1305: incorrect destination length"); - F = w; - } else - F = new Uint8Array(L); - return e.streamXOR(this._key, A, d.subarray(0, d.length - this.tagLength), F, 4), n.wipe(A), F; - }, u.prototype.clean = function() { - return n.wipe(this._key), this; - }, u.prototype._authenticate = function(l, d, g, w) { - var A = new r.Poly1305(d); - w && (A.update(w), w.length % 16 > 0 && A.update(o.subarray(w.length % 16))), A.update(g), g.length % 16 > 0 && A.update(o.subarray(g.length % 16)); - var M = new Uint8Array(8); - w && i.writeUint64LE(w.length, M), A.update(M), i.writeUint64LE(g.length, M), A.update(M); - for (var N = A.digest(), L = 0; L < N.length; L++) - l[L] = N[L]; - A.clean(), n.wipe(N), n.wipe(M); - }, u; - }() - ); - t.ChaCha20Poly1305 = a; -})(Vv); -var y8 = {}, Vl = {}, Gv = {}; -Object.defineProperty(Gv, "__esModule", { value: !0 }); -function Pj(t) { - return typeof t.saveState < "u" && typeof t.restoreState < "u" && typeof t.cleanSavedState < "u"; -} -Gv.isSerializableHash = Pj; -Object.defineProperty(Vl, "__esModule", { value: !0 }); -var Ns = Gv, Mj = Ia, Ij = ki, w8 = ( - /** @class */ - function() { - function t(e, r) { - this._finished = !1, this._inner = new e(), this._outer = new e(), this.blockSize = this._outer.blockSize, this.digestLength = this._outer.digestLength; - var n = new Uint8Array(this.blockSize); - r.length > this.blockSize ? this._inner.update(r).finish(n).clean() : n.set(r); - for (var i = 0; i < n.length; i++) - n[i] ^= 54; - this._inner.update(n); - for (var i = 0; i < n.length; i++) - n[i] ^= 106; - this._outer.update(n), Ns.isSerializableHash(this._inner) && Ns.isSerializableHash(this._outer) && (this._innerKeyedState = this._inner.saveState(), this._outerKeyedState = this._outer.saveState()), Ij.wipe(n); - } - return t.prototype.reset = function() { - if (!Ns.isSerializableHash(this._inner) || !Ns.isSerializableHash(this._outer)) - throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); - return this._inner.restoreState(this._innerKeyedState), this._outer.restoreState(this._outerKeyedState), this._finished = !1, this; - }, t.prototype.clean = function() { - Ns.isSerializableHash(this._inner) && this._inner.cleanSavedState(this._innerKeyedState), Ns.isSerializableHash(this._outer) && this._outer.cleanSavedState(this._outerKeyedState), this._inner.clean(), this._outer.clean(); - }, t.prototype.update = function(e) { - return this._inner.update(e), this; - }, t.prototype.finish = function(e) { - return this._finished ? (this._outer.finish(e), this) : (this._inner.finish(e), this._outer.update(e.subarray(0, this.digestLength)).finish(e), this._finished = !0, this); - }, t.prototype.digest = function() { - var e = new Uint8Array(this.digestLength); - return this.finish(e), e; - }, t.prototype.saveState = function() { - if (!Ns.isSerializableHash(this._inner)) - throw new Error("hmac: can't saveState() because hash doesn't implement it"); - return this._inner.saveState(); - }, t.prototype.restoreState = function(e) { - if (!Ns.isSerializableHash(this._inner) || !Ns.isSerializableHash(this._outer)) - throw new Error("hmac: can't restoreState() because hash doesn't implement it"); - return this._inner.restoreState(e), this._outer.restoreState(this._outerKeyedState), this._finished = !1, this; - }, t.prototype.cleanSavedState = function(e) { - if (!Ns.isSerializableHash(this._inner)) - throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); - this._inner.cleanSavedState(e); - }, t; - }() -); -Vl.HMAC = w8; -function Cj(t, e, r) { - var n = new w8(t, e); - n.update(r); - var i = n.digest(); - return n.clean(), i; -} -Vl.hmac = Cj; -Vl.equal = Mj.equal; -Object.defineProperty(y8, "__esModule", { value: !0 }); -var Px = Vl, Mx = ki, Tj = ( - /** @class */ - function() { - function t(e, r, n, i) { - n === void 0 && (n = new Uint8Array(0)), this._counter = new Uint8Array(1), this._hash = e, this._info = i; - var s = Px.hmac(this._hash, n, r); - this._hmac = new Px.HMAC(e, s), this._buffer = new Uint8Array(this._hmac.digestLength), this._bufpos = this._buffer.length; - } - return t.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; - }, t.prototype.expand = function(e) { - for (var r = new Uint8Array(e), n = 0; n < r.length; n++) - this._bufpos === this._buffer.length && this._fillBuffer(), r[n] = this._buffer[this._bufpos++]; - return r; - }, t.prototype.clean = function() { - this._hmac.clean(), Mx.wipe(this._buffer), Mx.wipe(this._counter), this._bufpos = 0; - }, t; - }() -), Rj = y8.HKDF = Tj, Gl = {}; -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }); - var e = or, r = ki; - t.DIGEST_LENGTH = 32, t.BLOCK_SIZE = 64; - var n = ( - /** @class */ - function() { - function a() { - this.digestLength = t.DIGEST_LENGTH, this.blockSize = t.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 a.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; - }, a.prototype.reset = function() { - return this._initState(), this._bufferLength = 0, this._bytesHashed = 0, this._finished = !1, this; - }, a.prototype.clean = function() { - r.wipe(this._buffer), r.wipe(this._temp), this.reset(); - }, a.prototype.update = function(u, l) { - if (l === void 0 && (l = u.length), this._finished) - throw new Error("SHA256: can't update because hash was finished."); - var d = 0; - if (this._bytesHashed += l, this._bufferLength > 0) { - for (; this._bufferLength < this.blockSize && l > 0; ) - this._buffer[this._bufferLength++] = u[d++], l--; - this._bufferLength === this.blockSize && (s(this._temp, this._state, this._buffer, 0, this.blockSize), this._bufferLength = 0); - } - for (l >= this.blockSize && (d = s(this._temp, this._state, u, d, l), l %= this.blockSize); l > 0; ) - this._buffer[this._bufferLength++] = u[d++], l--; - return this; - }, a.prototype.finish = function(u) { - if (!this._finished) { - var l = this._bytesHashed, d = this._bufferLength, g = l / 536870912 | 0, w = l << 3, A = l % 64 < 56 ? 64 : 128; - this._buffer[d] = 128; - for (var M = d + 1; M < A - 8; M++) - this._buffer[M] = 0; - e.writeUint32BE(g, this._buffer, A - 8), e.writeUint32BE(w, this._buffer, A - 4), s(this._temp, this._state, this._buffer, 0, A), this._finished = !0; - } - for (var M = 0; M < this.digestLength / 4; M++) - e.writeUint32BE(this._state[M], u, M * 4); - return this; - }, a.prototype.digest = function() { - var u = new Uint8Array(this.digestLength); - return this.finish(u), u; - }, a.prototype.saveState = function() { - if (this._finished) - throw new Error("SHA256: cannot save finished state"); - return { - state: new Int32Array(this._state), - buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, - bufferLength: this._bufferLength, - bytesHashed: this._bytesHashed - }; - }, a.prototype.restoreState = function(u) { - return this._state.set(u.state), this._bufferLength = u.bufferLength, u.buffer && this._buffer.set(u.buffer), this._bytesHashed = u.bytesHashed, this._finished = !1, this; - }, a.prototype.cleanSavedState = function(u) { - r.wipe(u.state), u.buffer && r.wipe(u.buffer), u.bufferLength = 0, u.bytesHashed = 0; - }, a; - }() - ); - t.SHA256 = n; - var i = 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 s(a, u, l, d, g) { - for (; g >= 64; ) { - for (var w = u[0], A = u[1], M = u[2], N = u[3], L = u[4], F = u[5], $ = u[6], K = u[7], H = 0; H < 16; H++) { - var V = d + H * 4; - a[H] = e.readUint32BE(l, V); - } - for (var H = 16; H < 64; H++) { - var te = a[H - 2], R = (te >>> 17 | te << 15) ^ (te >>> 19 | te << 13) ^ te >>> 10; - te = a[H - 15]; - var W = (te >>> 7 | te << 25) ^ (te >>> 18 | te << 14) ^ te >>> 3; - a[H] = (R + a[H - 7] | 0) + (W + a[H - 16] | 0); - } - for (var H = 0; H < 64; H++) { - var R = (((L >>> 6 | L << 26) ^ (L >>> 11 | L << 21) ^ (L >>> 25 | L << 7)) + (L & F ^ ~L & $) | 0) + (K + (i[H] + a[H] | 0) | 0) | 0, W = ((w >>> 2 | w << 30) ^ (w >>> 13 | w << 19) ^ (w >>> 22 | w << 10)) + (w & A ^ w & M ^ A & M) | 0; - K = $, $ = F, F = L, L = N + R | 0, N = M, M = A, A = w, w = R + W | 0; - } - u[0] += w, u[1] += A, u[2] += M, u[3] += N, u[4] += L, u[5] += F, u[6] += $, u[7] += K, d += 64, g -= 64; - } - return d; - } - function o(a) { - var u = new n(); - u.update(a); - var l = u.digest(); - return u.clean(), l; - } - t.hash = o; -})(Gl); -var Yv = {}; -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }), t.sharedKey = t.generateKeyPair = t.generateKeyPairFromSeed = t.scalarMultBase = t.scalarMult = t.SHARED_KEY_LENGTH = t.SECRET_KEY_LENGTH = t.PUBLIC_KEY_LENGTH = void 0; - const e = Pa, r = ki; - t.PUBLIC_KEY_LENGTH = 32, t.SECRET_KEY_LENGTH = 32, t.SHARED_KEY_LENGTH = 32; - function n(H) { - const V = new Float64Array(16); - if (H) - for (let te = 0; te < H.length; te++) - V[te] = H[te]; - return V; - } - const i = new Uint8Array(32); - i[0] = 9; - const s = n([56129, 1]); - function o(H) { - let V = 1; - for (let te = 0; te < 16; te++) { - let R = H[te] + V + 65535; - V = Math.floor(R / 65536), H[te] = R - V * 65536; - } - H[0] += V - 1 + 37 * (V - 1); - } - function a(H, V, te) { - const R = ~(te - 1); - for (let W = 0; W < 16; W++) { - const pe = R & (H[W] ^ V[W]); - H[W] ^= pe, V[W] ^= pe; - } - } - function u(H, V) { - const te = n(), R = n(); - for (let W = 0; W < 16; W++) - R[W] = V[W]; - o(R), o(R), o(R); - for (let W = 0; W < 2; W++) { - te[0] = R[0] - 65517; - for (let Ee = 1; Ee < 15; Ee++) - te[Ee] = R[Ee] - 65535 - (te[Ee - 1] >> 16 & 1), te[Ee - 1] &= 65535; - te[15] = R[15] - 32767 - (te[14] >> 16 & 1); - const pe = te[15] >> 16 & 1; - te[14] &= 65535, a(R, te, 1 - pe); - } - for (let W = 0; W < 16; W++) - H[2 * W] = R[W] & 255, H[2 * W + 1] = R[W] >> 8; - } - function l(H, V) { - for (let te = 0; te < 16; te++) - H[te] = V[2 * te] + (V[2 * te + 1] << 8); - H[15] &= 32767; - } - function d(H, V, te) { - for (let R = 0; R < 16; R++) - H[R] = V[R] + te[R]; - } - function g(H, V, te) { - for (let R = 0; R < 16; R++) - H[R] = V[R] - te[R]; - } - function w(H, V, te) { - let R, W, pe = 0, Ee = 0, Y = 0, S = 0, m = 0, f = 0, p = 0, b = 0, x = 0, _ = 0, E = 0, v = 0, P = 0, I = 0, B = 0, ce = 0, D = 0, oe = 0, Z = 0, J = 0, Q = 0, T = 0, X = 0, re = 0, de = 0, ie = 0, ue = 0, ve = 0, Pe = 0, De = 0, Ce = 0, $e = te[0], Me = te[1], Ne = te[2], Ke = te[3], Le = te[4], qe = te[5], ze = te[6], _e = te[7], Ze = te[8], at = te[9], ke = te[10], Qe = te[11], tt = te[12], Ye = te[13], dt = te[14], lt = te[15]; - R = V[0], pe += R * $e, Ee += R * Me, Y += R * Ne, S += R * Ke, m += R * Le, f += R * qe, p += R * ze, b += R * _e, x += R * Ze, _ += R * at, E += R * ke, v += R * Qe, P += R * tt, I += R * Ye, B += R * dt, ce += R * lt, R = V[1], Ee += R * $e, Y += R * Me, S += R * Ne, m += R * Ke, f += R * Le, p += R * qe, b += R * ze, x += R * _e, _ += R * Ze, E += R * at, v += R * ke, P += R * Qe, I += R * tt, B += R * Ye, ce += R * dt, D += R * lt, R = V[2], Y += R * $e, S += R * Me, m += R * Ne, f += R * Ke, p += R * Le, b += R * qe, x += R * ze, _ += R * _e, E += R * Ze, v += R * at, P += R * ke, I += R * Qe, B += R * tt, ce += R * Ye, D += R * dt, oe += R * lt, R = V[3], S += R * $e, m += R * Me, f += R * Ne, p += R * Ke, b += R * Le, x += R * qe, _ += R * ze, E += R * _e, v += R * Ze, P += R * at, I += R * ke, B += R * Qe, ce += R * tt, D += R * Ye, oe += R * dt, Z += R * lt, R = V[4], m += R * $e, f += R * Me, p += R * Ne, b += R * Ke, x += R * Le, _ += R * qe, E += R * ze, v += R * _e, P += R * Ze, I += R * at, B += R * ke, ce += R * Qe, D += R * tt, oe += R * Ye, Z += R * dt, J += R * lt, R = V[5], f += R * $e, p += R * Me, b += R * Ne, x += R * Ke, _ += R * Le, E += R * qe, v += R * ze, P += R * _e, I += R * Ze, B += R * at, ce += R * ke, D += R * Qe, oe += R * tt, Z += R * Ye, J += R * dt, Q += R * lt, R = V[6], p += R * $e, b += R * Me, x += R * Ne, _ += R * Ke, E += R * Le, v += R * qe, P += R * ze, I += R * _e, B += R * Ze, ce += R * at, D += R * ke, oe += R * Qe, Z += R * tt, J += R * Ye, Q += R * dt, T += R * lt, R = V[7], b += R * $e, x += R * Me, _ += R * Ne, E += R * Ke, v += R * Le, P += R * qe, I += R * ze, B += R * _e, ce += R * Ze, D += R * at, oe += R * ke, Z += R * Qe, J += R * tt, Q += R * Ye, T += R * dt, X += R * lt, R = V[8], x += R * $e, _ += R * Me, E += R * Ne, v += R * Ke, P += R * Le, I += R * qe, B += R * ze, ce += R * _e, D += R * Ze, oe += R * at, Z += R * ke, J += R * Qe, Q += R * tt, T += R * Ye, X += R * dt, re += R * lt, R = V[9], _ += R * $e, E += R * Me, v += R * Ne, P += R * Ke, I += R * Le, B += R * qe, ce += R * ze, D += R * _e, oe += R * Ze, Z += R * at, J += R * ke, Q += R * Qe, T += R * tt, X += R * Ye, re += R * dt, de += R * lt, R = V[10], E += R * $e, v += R * Me, P += R * Ne, I += R * Ke, B += R * Le, ce += R * qe, D += R * ze, oe += R * _e, Z += R * Ze, J += R * at, Q += R * ke, T += R * Qe, X += R * tt, re += R * Ye, de += R * dt, ie += R * lt, R = V[11], v += R * $e, P += R * Me, I += R * Ne, B += R * Ke, ce += R * Le, D += R * qe, oe += R * ze, Z += R * _e, J += R * Ze, Q += R * at, T += R * ke, X += R * Qe, re += R * tt, de += R * Ye, ie += R * dt, ue += R * lt, R = V[12], P += R * $e, I += R * Me, B += R * Ne, ce += R * Ke, D += R * Le, oe += R * qe, Z += R * ze, J += R * _e, Q += R * Ze, T += R * at, X += R * ke, re += R * Qe, de += R * tt, ie += R * Ye, ue += R * dt, ve += R * lt, R = V[13], I += R * $e, B += R * Me, ce += R * Ne, D += R * Ke, oe += R * Le, Z += R * qe, J += R * ze, Q += R * _e, T += R * Ze, X += R * at, re += R * ke, de += R * Qe, ie += R * tt, ue += R * Ye, ve += R * dt, Pe += R * lt, R = V[14], B += R * $e, ce += R * Me, D += R * Ne, oe += R * Ke, Z += R * Le, J += R * qe, Q += R * ze, T += R * _e, X += R * Ze, re += R * at, de += R * ke, ie += R * Qe, ue += R * tt, ve += R * Ye, Pe += R * dt, De += R * lt, R = V[15], ce += R * $e, D += R * Me, oe += R * Ne, Z += R * Ke, J += R * Le, Q += R * qe, T += R * ze, X += R * _e, re += R * Ze, de += R * at, ie += R * ke, ue += R * Qe, ve += R * tt, Pe += R * Ye, De += R * dt, Ce += R * lt, pe += 38 * D, Ee += 38 * oe, Y += 38 * Z, S += 38 * J, m += 38 * Q, f += 38 * T, p += 38 * X, b += 38 * re, x += 38 * de, _ += 38 * ie, E += 38 * ue, v += 38 * ve, P += 38 * Pe, I += 38 * De, B += 38 * Ce, W = 1, R = pe + W + 65535, W = Math.floor(R / 65536), pe = R - W * 65536, R = Ee + W + 65535, W = Math.floor(R / 65536), Ee = R - W * 65536, R = Y + W + 65535, W = Math.floor(R / 65536), Y = R - W * 65536, R = S + W + 65535, W = Math.floor(R / 65536), S = R - W * 65536, R = m + W + 65535, W = Math.floor(R / 65536), m = R - W * 65536, R = f + W + 65535, W = Math.floor(R / 65536), f = R - W * 65536, R = p + W + 65535, W = Math.floor(R / 65536), p = R - W * 65536, R = b + W + 65535, W = Math.floor(R / 65536), b = R - W * 65536, R = x + W + 65535, W = Math.floor(R / 65536), x = R - W * 65536, R = _ + W + 65535, W = Math.floor(R / 65536), _ = R - W * 65536, R = E + W + 65535, W = Math.floor(R / 65536), E = R - W * 65536, R = v + W + 65535, W = Math.floor(R / 65536), v = R - W * 65536, R = P + W + 65535, W = Math.floor(R / 65536), P = R - W * 65536, R = I + W + 65535, W = Math.floor(R / 65536), I = R - W * 65536, R = B + W + 65535, W = Math.floor(R / 65536), B = R - W * 65536, R = ce + W + 65535, W = Math.floor(R / 65536), ce = R - W * 65536, pe += W - 1 + 37 * (W - 1), W = 1, R = pe + W + 65535, W = Math.floor(R / 65536), pe = R - W * 65536, R = Ee + W + 65535, W = Math.floor(R / 65536), Ee = R - W * 65536, R = Y + W + 65535, W = Math.floor(R / 65536), Y = R - W * 65536, R = S + W + 65535, W = Math.floor(R / 65536), S = R - W * 65536, R = m + W + 65535, W = Math.floor(R / 65536), m = R - W * 65536, R = f + W + 65535, W = Math.floor(R / 65536), f = R - W * 65536, R = p + W + 65535, W = Math.floor(R / 65536), p = R - W * 65536, R = b + W + 65535, W = Math.floor(R / 65536), b = R - W * 65536, R = x + W + 65535, W = Math.floor(R / 65536), x = R - W * 65536, R = _ + W + 65535, W = Math.floor(R / 65536), _ = R - W * 65536, R = E + W + 65535, W = Math.floor(R / 65536), E = R - W * 65536, R = v + W + 65535, W = Math.floor(R / 65536), v = R - W * 65536, R = P + W + 65535, W = Math.floor(R / 65536), P = R - W * 65536, R = I + W + 65535, W = Math.floor(R / 65536), I = R - W * 65536, R = B + W + 65535, W = Math.floor(R / 65536), B = R - W * 65536, R = ce + W + 65535, W = Math.floor(R / 65536), ce = R - W * 65536, pe += W - 1 + 37 * (W - 1), H[0] = pe, H[1] = Ee, H[2] = Y, H[3] = S, H[4] = m, H[5] = f, H[6] = p, H[7] = b, H[8] = x, H[9] = _, H[10] = E, H[11] = v, H[12] = P, H[13] = I, H[14] = B, H[15] = ce; - } - function A(H, V) { - w(H, V, V); - } - function M(H, V) { - const te = n(); - for (let R = 0; R < 16; R++) - te[R] = V[R]; - for (let R = 253; R >= 0; R--) - A(te, te), R !== 2 && R !== 4 && w(te, te, V); - for (let R = 0; R < 16; R++) - H[R] = te[R]; - } - function N(H, V) { - const te = new Uint8Array(32), R = new Float64Array(80), W = n(), pe = n(), Ee = n(), Y = n(), S = n(), m = n(); - for (let x = 0; x < 31; x++) - te[x] = H[x]; - te[31] = H[31] & 127 | 64, te[0] &= 248, l(R, V); - for (let x = 0; x < 16; x++) - pe[x] = R[x]; - W[0] = Y[0] = 1; - for (let x = 254; x >= 0; --x) { - const _ = te[x >>> 3] >>> (x & 7) & 1; - a(W, pe, _), a(Ee, Y, _), d(S, W, Ee), g(W, W, Ee), d(Ee, pe, Y), g(pe, pe, Y), A(Y, S), A(m, W), w(W, Ee, W), w(Ee, pe, S), d(S, W, Ee), g(W, W, Ee), A(pe, W), g(Ee, Y, m), w(W, Ee, s), d(W, W, Y), w(Ee, Ee, W), w(W, Y, m), w(Y, pe, R), A(pe, S), a(W, pe, _), a(Ee, Y, _); - } - for (let x = 0; x < 16; x++) - R[x + 16] = W[x], R[x + 32] = Ee[x], R[x + 48] = pe[x], R[x + 64] = Y[x]; - const f = R.subarray(32), p = R.subarray(16); - M(f, f), w(p, p, f); - const b = new Uint8Array(32); - return u(b, p), b; - } - t.scalarMult = N; - function L(H) { - return N(H, i); - } - t.scalarMultBase = L; - function F(H) { - if (H.length !== t.SECRET_KEY_LENGTH) - throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`); - const V = new Uint8Array(H); - return { - publicKey: L(V), - secretKey: V - }; - } - t.generateKeyPairFromSeed = F; - function $(H) { - const V = (0, e.randomBytes)(32, H), te = F(V); - return (0, r.wipe)(V), te; - } - t.generateKeyPair = $; - function K(H, V, te = !1) { - if (H.length !== t.PUBLIC_KEY_LENGTH) - throw new Error("X25519: incorrect secret key length"); - if (V.length !== t.PUBLIC_KEY_LENGTH) - throw new Error("X25519: incorrect public key length"); - const R = N(H, V); - if (te) { - let W = 0; - for (let pe = 0; pe < R.length; pe++) - W |= R[pe]; - if (W === 0) - throw new Error("X25519: invalid shared key"); - } - return R; - } - t.sharedKey = K; -})(Yv); -var x8 = {}; -const Dj = "elliptic", Oj = "6.6.0", Nj = "EC cryptography", Lj = "lib/elliptic.js", kj = [ - "lib" -], $j = { - 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/" -}, Fj = { - type: "git", - url: "git@github.com:indutny/elliptic" -}, Bj = [ - "EC", - "Elliptic", - "curve", - "Cryptography" -], Uj = "Fedor Indutny ", jj = "MIT", qj = { - url: "https://github.com/indutny/elliptic/issues" -}, zj = "https://github.com/indutny/elliptic", Hj = { - 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" -}, Wj = { - "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" -}, Kj = { - name: Dj, - version: Oj, - description: Nj, - main: Lj, - files: kj, - scripts: $j, - repository: Fj, - keywords: Bj, - author: Uj, - license: jj, - bugs: qj, - homepage: zj, - devDependencies: Hj, - dependencies: Wj -}; -var Fi = {}, Jv = { exports: {} }; -Jv.exports; -(function(t) { - (function(e, r) { - function n(Y, S) { - if (!Y) throw new Error(S || "Assertion failed"); - } - function i(Y, S) { - Y.super_ = S; - var m = function() { - }; - m.prototype = S.prototype, Y.prototype = new m(), Y.prototype.constructor = Y; - } - function s(Y, S, m) { - if (s.isBN(Y)) - return Y; - this.negative = 0, this.words = null, this.length = 0, this.red = null, Y !== null && ((S === "le" || S === "be") && (m = S, S = 10), this._init(Y || 0, S || 10, m || "be")); - } - typeof e == "object" ? e.exports = s : r.BN = s, s.BN = s, s.wordSize = 26; - var o; - try { - typeof window < "u" && typeof window.Buffer < "u" ? o = window.Buffer : o = zl.Buffer; - } catch { - } - s.isBN = function(S) { - return S instanceof s ? !0 : S !== null && typeof S == "object" && S.constructor.wordSize === s.wordSize && Array.isArray(S.words); - }, s.max = function(S, m) { - return S.cmp(m) > 0 ? S : m; - }, s.min = function(S, m) { - return S.cmp(m) < 0 ? S : m; - }, s.prototype._init = function(S, m, f) { - if (typeof S == "number") - return this._initNumber(S, m, f); - if (typeof S == "object") - return this._initArray(S, m, f); - m === "hex" && (m = 16), n(m === (m | 0) && m >= 2 && m <= 36), S = S.toString().replace(/\s+/g, ""); - var p = 0; - S[0] === "-" && (p++, this.negative = 1), p < S.length && (m === 16 ? this._parseHex(S, p, f) : (this._parseBase(S, m, p), f === "le" && this._initArray(this.toArray(), m, f))); - }, s.prototype._initNumber = function(S, m, f) { - S < 0 && (this.negative = 1, S = -S), S < 67108864 ? (this.words = [S & 67108863], this.length = 1) : S < 4503599627370496 ? (this.words = [ - S & 67108863, - S / 67108864 & 67108863 - ], this.length = 2) : (n(S < 9007199254740992), this.words = [ - S & 67108863, - S / 67108864 & 67108863, - 1 - ], this.length = 3), f === "le" && this._initArray(this.toArray(), m, f); - }, s.prototype._initArray = function(S, m, f) { - if (n(typeof S.length == "number"), S.length <= 0) - return this.words = [0], this.length = 1, this; - this.length = Math.ceil(S.length / 3), this.words = new Array(this.length); - for (var p = 0; p < this.length; p++) - this.words[p] = 0; - var b, x, _ = 0; - if (f === "be") - for (p = S.length - 1, b = 0; p >= 0; p -= 3) - x = S[p] | S[p - 1] << 8 | S[p - 2] << 16, this.words[b] |= x << _ & 67108863, this.words[b + 1] = x >>> 26 - _ & 67108863, _ += 24, _ >= 26 && (_ -= 26, b++); - else if (f === "le") - for (p = 0, b = 0; p < S.length; p += 3) - x = S[p] | S[p + 1] << 8 | S[p + 2] << 16, this.words[b] |= x << _ & 67108863, this.words[b + 1] = x >>> 26 - _ & 67108863, _ += 24, _ >= 26 && (_ -= 26, b++); - return this.strip(); - }; - function a(Y, S) { - var m = Y.charCodeAt(S); - return m >= 65 && m <= 70 ? m - 55 : m >= 97 && m <= 102 ? m - 87 : m - 48 & 15; - } - function u(Y, S, m) { - var f = a(Y, m); - return m - 1 >= S && (f |= a(Y, m - 1) << 4), f; - } - s.prototype._parseHex = function(S, m, f) { - this.length = Math.ceil((S.length - m) / 6), this.words = new Array(this.length); - for (var p = 0; p < this.length; p++) - this.words[p] = 0; - var b = 0, x = 0, _; - if (f === "be") - for (p = S.length - 1; p >= m; p -= 2) - _ = u(S, m, p) << b, this.words[x] |= _ & 67108863, b >= 18 ? (b -= 18, x += 1, this.words[x] |= _ >>> 26) : b += 8; - else { - var E = S.length - m; - for (p = E % 2 === 0 ? m + 1 : m; p < S.length; p += 2) - _ = u(S, m, p) << b, this.words[x] |= _ & 67108863, b >= 18 ? (b -= 18, x += 1, this.words[x] |= _ >>> 26) : b += 8; - } - this.strip(); - }; - function l(Y, S, m, f) { - for (var p = 0, b = Math.min(Y.length, m), x = S; x < b; x++) { - var _ = Y.charCodeAt(x) - 48; - p *= f, _ >= 49 ? p += _ - 49 + 10 : _ >= 17 ? p += _ - 17 + 10 : p += _; - } - return p; - } - s.prototype._parseBase = function(S, m, f) { - this.words = [0], this.length = 1; - for (var p = 0, b = 1; b <= 67108863; b *= m) - p++; - p--, b = b / m | 0; - for (var x = S.length - f, _ = x % p, E = Math.min(x, x - _) + f, v = 0, P = f; P < E; P += p) - v = l(S, P, P + p, m), this.imuln(b), this.words[0] + v < 67108864 ? this.words[0] += v : this._iaddn(v); - if (_ !== 0) { - var I = 1; - for (v = l(S, P, S.length, m), P = 0; P < _; P++) - I *= m; - this.imuln(I), this.words[0] + v < 67108864 ? this.words[0] += v : this._iaddn(v); - } - this.strip(); - }, s.prototype.copy = function(S) { - S.words = new Array(this.length); - for (var m = 0; m < this.length; m++) - S.words[m] = this.words[m]; - S.length = this.length, S.negative = this.negative, S.red = this.red; - }, s.prototype.clone = function() { - var S = new s(null); - return this.copy(S), S; - }, s.prototype._expand = function(S) { - for (; this.length < S; ) - this.words[this.length++] = 0; - return this; - }, s.prototype.strip = function() { - for (; this.length > 1 && this.words[this.length - 1] === 0; ) - this.length--; - return this._normSign(); - }, s.prototype._normSign = function() { - return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; - }, s.prototype.inspect = function() { - return (this.red ? ""; - }; - var d = [ - "", - "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 - ], w = [ - 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 - ]; - s.prototype.toString = function(S, m) { - S = S || 10, m = m | 0 || 1; - var f; - if (S === 16 || S === "hex") { - f = ""; - for (var p = 0, b = 0, x = 0; x < this.length; x++) { - var _ = this.words[x], E = ((_ << p | b) & 16777215).toString(16); - b = _ >>> 24 - p & 16777215, p += 2, p >= 26 && (p -= 26, x--), b !== 0 || x !== this.length - 1 ? f = d[6 - E.length] + E + f : f = E + f; - } - for (b !== 0 && (f = b.toString(16) + f); f.length % m !== 0; ) - f = "0" + f; - return this.negative !== 0 && (f = "-" + f), f; - } - if (S === (S | 0) && S >= 2 && S <= 36) { - var v = g[S], P = w[S]; - f = ""; - var I = this.clone(); - for (I.negative = 0; !I.isZero(); ) { - var B = I.modn(P).toString(S); - I = I.idivn(P), I.isZero() ? f = B + f : f = d[v - B.length] + B + f; - } - for (this.isZero() && (f = "0" + f); f.length % m !== 0; ) - f = "0" + f; - return this.negative !== 0 && (f = "-" + f), f; - } - n(!1, "Base should be between 2 and 36"); - }, s.prototype.toNumber = function() { - var S = this.words[0]; - return this.length === 2 ? S += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? S += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && n(!1, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -S : S; - }, s.prototype.toJSON = function() { - return this.toString(16); - }, s.prototype.toBuffer = function(S, m) { - return n(typeof o < "u"), this.toArrayLike(o, S, m); - }, s.prototype.toArray = function(S, m) { - return this.toArrayLike(Array, S, m); - }, s.prototype.toArrayLike = function(S, m, f) { - var p = this.byteLength(), b = f || Math.max(1, p); - n(p <= b, "byte array longer than desired length"), n(b > 0, "Requested array length <= 0"), this.strip(); - var x = m === "le", _ = new S(b), E, v, P = this.clone(); - if (x) { - for (v = 0; !P.isZero(); v++) - E = P.andln(255), P.iushrn(8), _[v] = E; - for (; v < b; v++) - _[v] = 0; - } else { - for (v = 0; v < b - p; v++) - _[v] = 0; - for (v = 0; !P.isZero(); v++) - E = P.andln(255), P.iushrn(8), _[b - v - 1] = E; - } - return _; - }, Math.clz32 ? s.prototype._countBits = function(S) { - return 32 - Math.clz32(S); - } : s.prototype._countBits = function(S) { - var m = S, f = 0; - return m >= 4096 && (f += 13, m >>>= 13), m >= 64 && (f += 7, m >>>= 7), m >= 8 && (f += 4, m >>>= 4), m >= 2 && (f += 2, m >>>= 2), f + m; - }, s.prototype._zeroBits = function(S) { - if (S === 0) return 26; - var m = S, f = 0; - return m & 8191 || (f += 13, m >>>= 13), m & 127 || (f += 7, m >>>= 7), m & 15 || (f += 4, m >>>= 4), m & 3 || (f += 2, m >>>= 2), m & 1 || f++, f; - }, s.prototype.bitLength = function() { - var S = this.words[this.length - 1], m = this._countBits(S); - return (this.length - 1) * 26 + m; - }; - function A(Y) { - for (var S = new Array(Y.bitLength()), m = 0; m < S.length; m++) { - var f = m / 26 | 0, p = m % 26; - S[m] = (Y.words[f] & 1 << p) >>> p; - } - return S; - } - s.prototype.zeroBits = function() { - if (this.isZero()) return 0; - for (var S = 0, m = 0; m < this.length; m++) { - var f = this._zeroBits(this.words[m]); - if (S += f, f !== 26) break; - } - return S; - }, s.prototype.byteLength = function() { - return Math.ceil(this.bitLength() / 8); - }, s.prototype.toTwos = function(S) { - return this.negative !== 0 ? this.abs().inotn(S).iaddn(1) : this.clone(); - }, s.prototype.fromTwos = function(S) { - return this.testn(S - 1) ? this.notn(S).iaddn(1).ineg() : this.clone(); - }, s.prototype.isNeg = function() { - return this.negative !== 0; - }, s.prototype.neg = function() { - return this.clone().ineg(); - }, s.prototype.ineg = function() { - return this.isZero() || (this.negative ^= 1), this; - }, s.prototype.iuor = function(S) { - for (; this.length < S.length; ) - this.words[this.length++] = 0; - for (var m = 0; m < S.length; m++) - this.words[m] = this.words[m] | S.words[m]; - return this.strip(); - }, s.prototype.ior = function(S) { - return n((this.negative | S.negative) === 0), this.iuor(S); - }, s.prototype.or = function(S) { - return this.length > S.length ? this.clone().ior(S) : S.clone().ior(this); - }, s.prototype.uor = function(S) { - return this.length > S.length ? this.clone().iuor(S) : S.clone().iuor(this); - }, s.prototype.iuand = function(S) { - var m; - this.length > S.length ? m = S : m = this; - for (var f = 0; f < m.length; f++) - this.words[f] = this.words[f] & S.words[f]; - return this.length = m.length, this.strip(); - }, s.prototype.iand = function(S) { - return n((this.negative | S.negative) === 0), this.iuand(S); - }, s.prototype.and = function(S) { - return this.length > S.length ? this.clone().iand(S) : S.clone().iand(this); - }, s.prototype.uand = function(S) { - return this.length > S.length ? this.clone().iuand(S) : S.clone().iuand(this); - }, s.prototype.iuxor = function(S) { - var m, f; - this.length > S.length ? (m = this, f = S) : (m = S, f = this); - for (var p = 0; p < f.length; p++) - this.words[p] = m.words[p] ^ f.words[p]; - if (this !== m) - for (; p < m.length; p++) - this.words[p] = m.words[p]; - return this.length = m.length, this.strip(); - }, s.prototype.ixor = function(S) { - return n((this.negative | S.negative) === 0), this.iuxor(S); - }, s.prototype.xor = function(S) { - return this.length > S.length ? this.clone().ixor(S) : S.clone().ixor(this); - }, s.prototype.uxor = function(S) { - return this.length > S.length ? this.clone().iuxor(S) : S.clone().iuxor(this); - }, s.prototype.inotn = function(S) { - n(typeof S == "number" && S >= 0); - var m = Math.ceil(S / 26) | 0, f = S % 26; - this._expand(m), f > 0 && m--; - for (var p = 0; p < m; p++) - this.words[p] = ~this.words[p] & 67108863; - return f > 0 && (this.words[p] = ~this.words[p] & 67108863 >> 26 - f), this.strip(); - }, s.prototype.notn = function(S) { - return this.clone().inotn(S); - }, s.prototype.setn = function(S, m) { - n(typeof S == "number" && S >= 0); - var f = S / 26 | 0, p = S % 26; - return this._expand(f + 1), m ? this.words[f] = this.words[f] | 1 << p : this.words[f] = this.words[f] & ~(1 << p), this.strip(); - }, s.prototype.iadd = function(S) { - var m; - if (this.negative !== 0 && S.negative === 0) - return this.negative = 0, m = this.isub(S), this.negative ^= 1, this._normSign(); - if (this.negative === 0 && S.negative !== 0) - return S.negative = 0, m = this.isub(S), S.negative = 1, m._normSign(); - var f, p; - this.length > S.length ? (f = this, p = S) : (f = S, p = this); - for (var b = 0, x = 0; x < p.length; x++) - m = (f.words[x] | 0) + (p.words[x] | 0) + b, this.words[x] = m & 67108863, b = m >>> 26; - for (; b !== 0 && x < f.length; x++) - m = (f.words[x] | 0) + b, this.words[x] = m & 67108863, b = m >>> 26; - if (this.length = f.length, b !== 0) - this.words[this.length] = b, this.length++; - else if (f !== this) - for (; x < f.length; x++) - this.words[x] = f.words[x]; - return this; - }, s.prototype.add = function(S) { - var m; - return S.negative !== 0 && this.negative === 0 ? (S.negative = 0, m = this.sub(S), S.negative ^= 1, m) : S.negative === 0 && this.negative !== 0 ? (this.negative = 0, m = S.sub(this), this.negative = 1, m) : this.length > S.length ? this.clone().iadd(S) : S.clone().iadd(this); - }, s.prototype.isub = function(S) { - if (S.negative !== 0) { - S.negative = 0; - var m = this.iadd(S); - return S.negative = 1, m._normSign(); - } else if (this.negative !== 0) - return this.negative = 0, this.iadd(S), this.negative = 1, this._normSign(); - var f = this.cmp(S); - if (f === 0) - return this.negative = 0, this.length = 1, this.words[0] = 0, this; - var p, b; - f > 0 ? (p = this, b = S) : (p = S, b = this); - for (var x = 0, _ = 0; _ < b.length; _++) - m = (p.words[_] | 0) - (b.words[_] | 0) + x, x = m >> 26, this.words[_] = m & 67108863; - for (; x !== 0 && _ < p.length; _++) - m = (p.words[_] | 0) + x, x = m >> 26, this.words[_] = m & 67108863; - if (x === 0 && _ < p.length && p !== this) - for (; _ < p.length; _++) - this.words[_] = p.words[_]; - return this.length = Math.max(this.length, _), p !== this && (this.negative = 1), this.strip(); - }, s.prototype.sub = function(S) { - return this.clone().isub(S); - }; - function M(Y, S, m) { - m.negative = S.negative ^ Y.negative; - var f = Y.length + S.length | 0; - m.length = f, f = f - 1 | 0; - var p = Y.words[0] | 0, b = S.words[0] | 0, x = p * b, _ = x & 67108863, E = x / 67108864 | 0; - m.words[0] = _; - for (var v = 1; v < f; v++) { - for (var P = E >>> 26, I = E & 67108863, B = Math.min(v, S.length - 1), ce = Math.max(0, v - Y.length + 1); ce <= B; ce++) { - var D = v - ce | 0; - p = Y.words[D] | 0, b = S.words[ce] | 0, x = p * b + I, P += x / 67108864 | 0, I = x & 67108863; - } - m.words[v] = I | 0, E = P | 0; - } - return E !== 0 ? m.words[v] = E | 0 : m.length--, m.strip(); - } - var N = function(S, m, f) { - var p = S.words, b = m.words, x = f.words, _ = 0, E, v, P, I = p[0] | 0, B = I & 8191, ce = I >>> 13, D = p[1] | 0, oe = D & 8191, Z = D >>> 13, J = p[2] | 0, Q = J & 8191, T = J >>> 13, X = p[3] | 0, re = X & 8191, de = X >>> 13, ie = p[4] | 0, ue = ie & 8191, ve = ie >>> 13, Pe = p[5] | 0, De = Pe & 8191, Ce = Pe >>> 13, $e = p[6] | 0, Me = $e & 8191, Ne = $e >>> 13, Ke = p[7] | 0, Le = Ke & 8191, qe = Ke >>> 13, ze = p[8] | 0, _e = ze & 8191, Ze = ze >>> 13, at = p[9] | 0, ke = at & 8191, Qe = at >>> 13, tt = b[0] | 0, Ye = tt & 8191, dt = tt >>> 13, lt = b[1] | 0, ct = lt & 8191, qt = lt >>> 13, Yt = b[2] | 0, Et = Yt & 8191, Qt = Yt >>> 13, Jt = b[3] | 0, Dt = Jt & 8191, kt = Jt >>> 13, Ct = b[4] | 0, gt = Ct & 8191, Rt = Ct >>> 13, Nt = b[5] | 0, vt = Nt & 8191, $t = Nt >>> 13, Bt = b[6] | 0, rt = Bt & 8191, Ft = Bt >>> 13, k = b[7] | 0, j = k & 8191, z = k >>> 13, C = b[8] | 0, G = C & 8191, U = C >>> 13, se = b[9] | 0, he = se & 8191, xe = se >>> 13; - f.negative = S.negative ^ m.negative, f.length = 19, E = Math.imul(B, Ye), v = Math.imul(B, dt), v = v + Math.imul(ce, Ye) | 0, P = Math.imul(ce, dt); - var Te = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (Te >>> 26) | 0, Te &= 67108863, E = Math.imul(oe, Ye), v = Math.imul(oe, dt), v = v + Math.imul(Z, Ye) | 0, P = Math.imul(Z, dt), E = E + Math.imul(B, ct) | 0, v = v + Math.imul(B, qt) | 0, v = v + Math.imul(ce, ct) | 0, P = P + Math.imul(ce, qt) | 0; - var Re = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (Re >>> 26) | 0, Re &= 67108863, E = Math.imul(Q, Ye), v = Math.imul(Q, dt), v = v + Math.imul(T, Ye) | 0, P = Math.imul(T, dt), E = E + Math.imul(oe, ct) | 0, v = v + Math.imul(oe, qt) | 0, v = v + Math.imul(Z, ct) | 0, P = P + Math.imul(Z, qt) | 0, E = E + Math.imul(B, Et) | 0, v = v + Math.imul(B, Qt) | 0, v = v + Math.imul(ce, Et) | 0, P = P + Math.imul(ce, Qt) | 0; - var nt = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (nt >>> 26) | 0, nt &= 67108863, E = Math.imul(re, Ye), v = Math.imul(re, dt), v = v + Math.imul(de, Ye) | 0, P = Math.imul(de, dt), E = E + Math.imul(Q, ct) | 0, v = v + Math.imul(Q, qt) | 0, v = v + Math.imul(T, ct) | 0, P = P + Math.imul(T, qt) | 0, E = E + Math.imul(oe, Et) | 0, v = v + Math.imul(oe, Qt) | 0, v = v + Math.imul(Z, Et) | 0, P = P + Math.imul(Z, Qt) | 0, E = E + Math.imul(B, Dt) | 0, v = v + Math.imul(B, kt) | 0, v = v + Math.imul(ce, Dt) | 0, P = P + Math.imul(ce, kt) | 0; - var Ue = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (Ue >>> 26) | 0, Ue &= 67108863, E = Math.imul(ue, Ye), v = Math.imul(ue, dt), v = v + Math.imul(ve, Ye) | 0, P = Math.imul(ve, dt), E = E + Math.imul(re, ct) | 0, v = v + Math.imul(re, qt) | 0, v = v + Math.imul(de, ct) | 0, P = P + Math.imul(de, qt) | 0, E = E + Math.imul(Q, Et) | 0, v = v + Math.imul(Q, Qt) | 0, v = v + Math.imul(T, Et) | 0, P = P + Math.imul(T, Qt) | 0, E = E + Math.imul(oe, Dt) | 0, v = v + Math.imul(oe, kt) | 0, v = v + Math.imul(Z, Dt) | 0, P = P + Math.imul(Z, kt) | 0, E = E + Math.imul(B, gt) | 0, v = v + Math.imul(B, Rt) | 0, v = v + Math.imul(ce, gt) | 0, P = P + Math.imul(ce, Rt) | 0; - var pt = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (pt >>> 26) | 0, pt &= 67108863, E = Math.imul(De, Ye), v = Math.imul(De, dt), v = v + Math.imul(Ce, Ye) | 0, P = Math.imul(Ce, dt), E = E + Math.imul(ue, ct) | 0, v = v + Math.imul(ue, qt) | 0, v = v + Math.imul(ve, ct) | 0, P = P + Math.imul(ve, qt) | 0, E = E + Math.imul(re, Et) | 0, v = v + Math.imul(re, Qt) | 0, v = v + Math.imul(de, Et) | 0, P = P + Math.imul(de, Qt) | 0, E = E + Math.imul(Q, Dt) | 0, v = v + Math.imul(Q, kt) | 0, v = v + Math.imul(T, Dt) | 0, P = P + Math.imul(T, kt) | 0, E = E + Math.imul(oe, gt) | 0, v = v + Math.imul(oe, Rt) | 0, v = v + Math.imul(Z, gt) | 0, P = P + Math.imul(Z, Rt) | 0, E = E + Math.imul(B, vt) | 0, v = v + Math.imul(B, $t) | 0, v = v + Math.imul(ce, vt) | 0, P = P + Math.imul(ce, $t) | 0; - var it = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (it >>> 26) | 0, it &= 67108863, E = Math.imul(Me, Ye), v = Math.imul(Me, dt), v = v + Math.imul(Ne, Ye) | 0, P = Math.imul(Ne, dt), E = E + Math.imul(De, ct) | 0, v = v + Math.imul(De, qt) | 0, v = v + Math.imul(Ce, ct) | 0, P = P + Math.imul(Ce, qt) | 0, E = E + Math.imul(ue, Et) | 0, v = v + Math.imul(ue, Qt) | 0, v = v + Math.imul(ve, Et) | 0, P = P + Math.imul(ve, Qt) | 0, E = E + Math.imul(re, Dt) | 0, v = v + Math.imul(re, kt) | 0, v = v + Math.imul(de, Dt) | 0, P = P + Math.imul(de, kt) | 0, E = E + Math.imul(Q, gt) | 0, v = v + Math.imul(Q, Rt) | 0, v = v + Math.imul(T, gt) | 0, P = P + Math.imul(T, Rt) | 0, E = E + Math.imul(oe, vt) | 0, v = v + Math.imul(oe, $t) | 0, v = v + Math.imul(Z, vt) | 0, P = P + Math.imul(Z, $t) | 0, E = E + Math.imul(B, rt) | 0, v = v + Math.imul(B, Ft) | 0, v = v + Math.imul(ce, rt) | 0, P = P + Math.imul(ce, Ft) | 0; - var et = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (et >>> 26) | 0, et &= 67108863, E = Math.imul(Le, Ye), v = Math.imul(Le, dt), v = v + Math.imul(qe, Ye) | 0, P = Math.imul(qe, dt), E = E + Math.imul(Me, ct) | 0, v = v + Math.imul(Me, qt) | 0, v = v + Math.imul(Ne, ct) | 0, P = P + Math.imul(Ne, qt) | 0, E = E + Math.imul(De, Et) | 0, v = v + Math.imul(De, Qt) | 0, v = v + Math.imul(Ce, Et) | 0, P = P + Math.imul(Ce, Qt) | 0, E = E + Math.imul(ue, Dt) | 0, v = v + Math.imul(ue, kt) | 0, v = v + Math.imul(ve, Dt) | 0, P = P + Math.imul(ve, kt) | 0, E = E + Math.imul(re, gt) | 0, v = v + Math.imul(re, Rt) | 0, v = v + Math.imul(de, gt) | 0, P = P + Math.imul(de, Rt) | 0, E = E + Math.imul(Q, vt) | 0, v = v + Math.imul(Q, $t) | 0, v = v + Math.imul(T, vt) | 0, P = P + Math.imul(T, $t) | 0, E = E + Math.imul(oe, rt) | 0, v = v + Math.imul(oe, Ft) | 0, v = v + Math.imul(Z, rt) | 0, P = P + Math.imul(Z, Ft) | 0, E = E + Math.imul(B, j) | 0, v = v + Math.imul(B, z) | 0, v = v + Math.imul(ce, j) | 0, P = P + Math.imul(ce, z) | 0; - var St = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (St >>> 26) | 0, St &= 67108863, E = Math.imul(_e, Ye), v = Math.imul(_e, dt), v = v + Math.imul(Ze, Ye) | 0, P = Math.imul(Ze, dt), E = E + Math.imul(Le, ct) | 0, v = v + Math.imul(Le, qt) | 0, v = v + Math.imul(qe, ct) | 0, P = P + Math.imul(qe, qt) | 0, E = E + Math.imul(Me, Et) | 0, v = v + Math.imul(Me, Qt) | 0, v = v + Math.imul(Ne, Et) | 0, P = P + Math.imul(Ne, Qt) | 0, E = E + Math.imul(De, Dt) | 0, v = v + Math.imul(De, kt) | 0, v = v + Math.imul(Ce, Dt) | 0, P = P + Math.imul(Ce, kt) | 0, E = E + Math.imul(ue, gt) | 0, v = v + Math.imul(ue, Rt) | 0, v = v + Math.imul(ve, gt) | 0, P = P + Math.imul(ve, Rt) | 0, E = E + Math.imul(re, vt) | 0, v = v + Math.imul(re, $t) | 0, v = v + Math.imul(de, vt) | 0, P = P + Math.imul(de, $t) | 0, E = E + Math.imul(Q, rt) | 0, v = v + Math.imul(Q, Ft) | 0, v = v + Math.imul(T, rt) | 0, P = P + Math.imul(T, Ft) | 0, E = E + Math.imul(oe, j) | 0, v = v + Math.imul(oe, z) | 0, v = v + Math.imul(Z, j) | 0, P = P + Math.imul(Z, z) | 0, E = E + Math.imul(B, G) | 0, v = v + Math.imul(B, U) | 0, v = v + Math.imul(ce, G) | 0, P = P + Math.imul(ce, U) | 0; - var Tt = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (Tt >>> 26) | 0, Tt &= 67108863, E = Math.imul(ke, Ye), v = Math.imul(ke, dt), v = v + Math.imul(Qe, Ye) | 0, P = Math.imul(Qe, dt), E = E + Math.imul(_e, ct) | 0, v = v + Math.imul(_e, qt) | 0, v = v + Math.imul(Ze, ct) | 0, P = P + Math.imul(Ze, qt) | 0, E = E + Math.imul(Le, Et) | 0, v = v + Math.imul(Le, Qt) | 0, v = v + Math.imul(qe, Et) | 0, P = P + Math.imul(qe, Qt) | 0, E = E + Math.imul(Me, Dt) | 0, v = v + Math.imul(Me, kt) | 0, v = v + Math.imul(Ne, Dt) | 0, P = P + Math.imul(Ne, kt) | 0, E = E + Math.imul(De, gt) | 0, v = v + Math.imul(De, Rt) | 0, v = v + Math.imul(Ce, gt) | 0, P = P + Math.imul(Ce, Rt) | 0, E = E + Math.imul(ue, vt) | 0, v = v + Math.imul(ue, $t) | 0, v = v + Math.imul(ve, vt) | 0, P = P + Math.imul(ve, $t) | 0, E = E + Math.imul(re, rt) | 0, v = v + Math.imul(re, Ft) | 0, v = v + Math.imul(de, rt) | 0, P = P + Math.imul(de, Ft) | 0, E = E + Math.imul(Q, j) | 0, v = v + Math.imul(Q, z) | 0, v = v + Math.imul(T, j) | 0, P = P + Math.imul(T, z) | 0, E = E + Math.imul(oe, G) | 0, v = v + Math.imul(oe, U) | 0, v = v + Math.imul(Z, G) | 0, P = P + Math.imul(Z, U) | 0, E = E + Math.imul(B, he) | 0, v = v + Math.imul(B, xe) | 0, v = v + Math.imul(ce, he) | 0, P = P + Math.imul(ce, xe) | 0; - var At = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (At >>> 26) | 0, At &= 67108863, E = Math.imul(ke, ct), v = Math.imul(ke, qt), v = v + Math.imul(Qe, ct) | 0, P = Math.imul(Qe, qt), E = E + Math.imul(_e, Et) | 0, v = v + Math.imul(_e, Qt) | 0, v = v + Math.imul(Ze, Et) | 0, P = P + Math.imul(Ze, Qt) | 0, E = E + Math.imul(Le, Dt) | 0, v = v + Math.imul(Le, kt) | 0, v = v + Math.imul(qe, Dt) | 0, P = P + Math.imul(qe, kt) | 0, E = E + Math.imul(Me, gt) | 0, v = v + Math.imul(Me, Rt) | 0, v = v + Math.imul(Ne, gt) | 0, P = P + Math.imul(Ne, Rt) | 0, E = E + Math.imul(De, vt) | 0, v = v + Math.imul(De, $t) | 0, v = v + Math.imul(Ce, vt) | 0, P = P + Math.imul(Ce, $t) | 0, E = E + Math.imul(ue, rt) | 0, v = v + Math.imul(ue, Ft) | 0, v = v + Math.imul(ve, rt) | 0, P = P + Math.imul(ve, Ft) | 0, E = E + Math.imul(re, j) | 0, v = v + Math.imul(re, z) | 0, v = v + Math.imul(de, j) | 0, P = P + Math.imul(de, z) | 0, E = E + Math.imul(Q, G) | 0, v = v + Math.imul(Q, U) | 0, v = v + Math.imul(T, G) | 0, P = P + Math.imul(T, U) | 0, E = E + Math.imul(oe, he) | 0, v = v + Math.imul(oe, xe) | 0, v = v + Math.imul(Z, he) | 0, P = P + Math.imul(Z, xe) | 0; - var _t = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, E = Math.imul(ke, Et), v = Math.imul(ke, Qt), v = v + Math.imul(Qe, Et) | 0, P = Math.imul(Qe, Qt), E = E + Math.imul(_e, Dt) | 0, v = v + Math.imul(_e, kt) | 0, v = v + Math.imul(Ze, Dt) | 0, P = P + Math.imul(Ze, kt) | 0, E = E + Math.imul(Le, gt) | 0, v = v + Math.imul(Le, Rt) | 0, v = v + Math.imul(qe, gt) | 0, P = P + Math.imul(qe, Rt) | 0, E = E + Math.imul(Me, vt) | 0, v = v + Math.imul(Me, $t) | 0, v = v + Math.imul(Ne, vt) | 0, P = P + Math.imul(Ne, $t) | 0, E = E + Math.imul(De, rt) | 0, v = v + Math.imul(De, Ft) | 0, v = v + Math.imul(Ce, rt) | 0, P = P + Math.imul(Ce, Ft) | 0, E = E + Math.imul(ue, j) | 0, v = v + Math.imul(ue, z) | 0, v = v + Math.imul(ve, j) | 0, P = P + Math.imul(ve, z) | 0, E = E + Math.imul(re, G) | 0, v = v + Math.imul(re, U) | 0, v = v + Math.imul(de, G) | 0, P = P + Math.imul(de, U) | 0, E = E + Math.imul(Q, he) | 0, v = v + Math.imul(Q, xe) | 0, v = v + Math.imul(T, he) | 0, P = P + Math.imul(T, xe) | 0; - var ht = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (ht >>> 26) | 0, ht &= 67108863, E = Math.imul(ke, Dt), v = Math.imul(ke, kt), v = v + Math.imul(Qe, Dt) | 0, P = Math.imul(Qe, kt), E = E + Math.imul(_e, gt) | 0, v = v + Math.imul(_e, Rt) | 0, v = v + Math.imul(Ze, gt) | 0, P = P + Math.imul(Ze, Rt) | 0, E = E + Math.imul(Le, vt) | 0, v = v + Math.imul(Le, $t) | 0, v = v + Math.imul(qe, vt) | 0, P = P + Math.imul(qe, $t) | 0, E = E + Math.imul(Me, rt) | 0, v = v + Math.imul(Me, Ft) | 0, v = v + Math.imul(Ne, rt) | 0, P = P + Math.imul(Ne, Ft) | 0, E = E + Math.imul(De, j) | 0, v = v + Math.imul(De, z) | 0, v = v + Math.imul(Ce, j) | 0, P = P + Math.imul(Ce, z) | 0, E = E + Math.imul(ue, G) | 0, v = v + Math.imul(ue, U) | 0, v = v + Math.imul(ve, G) | 0, P = P + Math.imul(ve, U) | 0, E = E + Math.imul(re, he) | 0, v = v + Math.imul(re, xe) | 0, v = v + Math.imul(de, he) | 0, P = P + Math.imul(de, xe) | 0; - var xt = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (xt >>> 26) | 0, xt &= 67108863, E = Math.imul(ke, gt), v = Math.imul(ke, Rt), v = v + Math.imul(Qe, gt) | 0, P = Math.imul(Qe, Rt), E = E + Math.imul(_e, vt) | 0, v = v + Math.imul(_e, $t) | 0, v = v + Math.imul(Ze, vt) | 0, P = P + Math.imul(Ze, $t) | 0, E = E + Math.imul(Le, rt) | 0, v = v + Math.imul(Le, Ft) | 0, v = v + Math.imul(qe, rt) | 0, P = P + Math.imul(qe, Ft) | 0, E = E + Math.imul(Me, j) | 0, v = v + Math.imul(Me, z) | 0, v = v + Math.imul(Ne, j) | 0, P = P + Math.imul(Ne, z) | 0, E = E + Math.imul(De, G) | 0, v = v + Math.imul(De, U) | 0, v = v + Math.imul(Ce, G) | 0, P = P + Math.imul(Ce, U) | 0, E = E + Math.imul(ue, he) | 0, v = v + Math.imul(ue, xe) | 0, v = v + Math.imul(ve, he) | 0, P = P + Math.imul(ve, xe) | 0; - var st = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (st >>> 26) | 0, st &= 67108863, E = Math.imul(ke, vt), v = Math.imul(ke, $t), v = v + Math.imul(Qe, vt) | 0, P = Math.imul(Qe, $t), E = E + Math.imul(_e, rt) | 0, v = v + Math.imul(_e, Ft) | 0, v = v + Math.imul(Ze, rt) | 0, P = P + Math.imul(Ze, Ft) | 0, E = E + Math.imul(Le, j) | 0, v = v + Math.imul(Le, z) | 0, v = v + Math.imul(qe, j) | 0, P = P + Math.imul(qe, z) | 0, E = E + Math.imul(Me, G) | 0, v = v + Math.imul(Me, U) | 0, v = v + Math.imul(Ne, G) | 0, P = P + Math.imul(Ne, U) | 0, E = E + Math.imul(De, he) | 0, v = v + Math.imul(De, xe) | 0, v = v + Math.imul(Ce, he) | 0, P = P + Math.imul(Ce, xe) | 0; - var bt = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (bt >>> 26) | 0, bt &= 67108863, E = Math.imul(ke, rt), v = Math.imul(ke, Ft), v = v + Math.imul(Qe, rt) | 0, P = Math.imul(Qe, Ft), E = E + Math.imul(_e, j) | 0, v = v + Math.imul(_e, z) | 0, v = v + Math.imul(Ze, j) | 0, P = P + Math.imul(Ze, z) | 0, E = E + Math.imul(Le, G) | 0, v = v + Math.imul(Le, U) | 0, v = v + Math.imul(qe, G) | 0, P = P + Math.imul(qe, U) | 0, E = E + Math.imul(Me, he) | 0, v = v + Math.imul(Me, xe) | 0, v = v + Math.imul(Ne, he) | 0, P = P + Math.imul(Ne, xe) | 0; - var ut = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (ut >>> 26) | 0, ut &= 67108863, E = Math.imul(ke, j), v = Math.imul(ke, z), v = v + Math.imul(Qe, j) | 0, P = Math.imul(Qe, z), E = E + Math.imul(_e, G) | 0, v = v + Math.imul(_e, U) | 0, v = v + Math.imul(Ze, G) | 0, P = P + Math.imul(Ze, U) | 0, E = E + Math.imul(Le, he) | 0, v = v + Math.imul(Le, xe) | 0, v = v + Math.imul(qe, he) | 0, P = P + Math.imul(qe, xe) | 0; - var ot = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (ot >>> 26) | 0, ot &= 67108863, E = Math.imul(ke, G), v = Math.imul(ke, U), v = v + Math.imul(Qe, G) | 0, P = Math.imul(Qe, U), E = E + Math.imul(_e, he) | 0, v = v + Math.imul(_e, xe) | 0, v = v + Math.imul(Ze, he) | 0, P = P + Math.imul(Ze, xe) | 0; - var Se = (_ + E | 0) + ((v & 8191) << 13) | 0; - _ = (P + (v >>> 13) | 0) + (Se >>> 26) | 0, Se &= 67108863, E = Math.imul(ke, he), v = Math.imul(ke, xe), v = v + Math.imul(Qe, he) | 0, P = Math.imul(Qe, xe); - var Ae = (_ + E | 0) + ((v & 8191) << 13) | 0; - return _ = (P + (v >>> 13) | 0) + (Ae >>> 26) | 0, Ae &= 67108863, x[0] = Te, x[1] = Re, x[2] = nt, x[3] = Ue, x[4] = pt, x[5] = it, x[6] = et, x[7] = St, x[8] = Tt, x[9] = At, x[10] = _t, x[11] = ht, x[12] = xt, x[13] = st, x[14] = bt, x[15] = ut, x[16] = ot, x[17] = Se, x[18] = Ae, _ !== 0 && (x[19] = _, f.length++), f; - }; - Math.imul || (N = M); - function L(Y, S, m) { - m.negative = S.negative ^ Y.negative, m.length = Y.length + S.length; - for (var f = 0, p = 0, b = 0; b < m.length - 1; b++) { - var x = p; - p = 0; - for (var _ = f & 67108863, E = Math.min(b, S.length - 1), v = Math.max(0, b - Y.length + 1); v <= E; v++) { - var P = b - v, I = Y.words[P] | 0, B = S.words[v] | 0, ce = I * B, D = ce & 67108863; - x = x + (ce / 67108864 | 0) | 0, D = D + _ | 0, _ = D & 67108863, x = x + (D >>> 26) | 0, p += x >>> 26, x &= 67108863; - } - m.words[b] = _, f = x, x = p; - } - return f !== 0 ? m.words[b] = f : m.length--, m.strip(); - } - function F(Y, S, m) { - var f = new $(); - return f.mulp(Y, S, m); - } - s.prototype.mulTo = function(S, m) { - var f, p = this.length + S.length; - return this.length === 10 && S.length === 10 ? f = N(this, S, m) : p < 63 ? f = M(this, S, m) : p < 1024 ? f = L(this, S, m) : f = F(this, S, m), f; - }; - function $(Y, S) { - this.x = Y, this.y = S; - } - $.prototype.makeRBT = function(S) { - for (var m = new Array(S), f = s.prototype._countBits(S) - 1, p = 0; p < S; p++) - m[p] = this.revBin(p, f, S); - return m; - }, $.prototype.revBin = function(S, m, f) { - if (S === 0 || S === f - 1) return S; - for (var p = 0, b = 0; b < m; b++) - p |= (S & 1) << m - b - 1, S >>= 1; - return p; - }, $.prototype.permute = function(S, m, f, p, b, x) { - for (var _ = 0; _ < x; _++) - p[_] = m[S[_]], b[_] = f[S[_]]; - }, $.prototype.transform = function(S, m, f, p, b, x) { - this.permute(x, S, m, f, p, b); - for (var _ = 1; _ < b; _ <<= 1) - for (var E = _ << 1, v = Math.cos(2 * Math.PI / E), P = Math.sin(2 * Math.PI / E), I = 0; I < b; I += E) - for (var B = v, ce = P, D = 0; D < _; D++) { - var oe = f[I + D], Z = p[I + D], J = f[I + D + _], Q = p[I + D + _], T = B * J - ce * Q; - Q = B * Q + ce * J, J = T, f[I + D] = oe + J, p[I + D] = Z + Q, f[I + D + _] = oe - J, p[I + D + _] = Z - Q, D !== E && (T = v * B - P * ce, ce = v * ce + P * B, B = T); - } - }, $.prototype.guessLen13b = function(S, m) { - var f = Math.max(m, S) | 1, p = f & 1, b = 0; - for (f = f / 2 | 0; f; f = f >>> 1) - b++; - return 1 << b + 1 + p; - }, $.prototype.conjugate = function(S, m, f) { - if (!(f <= 1)) - for (var p = 0; p < f / 2; p++) { - var b = S[p]; - S[p] = S[f - p - 1], S[f - p - 1] = b, b = m[p], m[p] = -m[f - p - 1], m[f - p - 1] = -b; - } - }, $.prototype.normalize13b = function(S, m) { - for (var f = 0, p = 0; p < m / 2; p++) { - var b = Math.round(S[2 * p + 1] / m) * 8192 + Math.round(S[2 * p] / m) + f; - S[p] = b & 67108863, b < 67108864 ? f = 0 : f = b / 67108864 | 0; - } - return S; - }, $.prototype.convert13b = function(S, m, f, p) { - for (var b = 0, x = 0; x < m; x++) - b = b + (S[x] | 0), f[2 * x] = b & 8191, b = b >>> 13, f[2 * x + 1] = b & 8191, b = b >>> 13; - for (x = 2 * m; x < p; ++x) - f[x] = 0; - n(b === 0), n((b & -8192) === 0); - }, $.prototype.stub = function(S) { - for (var m = new Array(S), f = 0; f < S; f++) - m[f] = 0; - return m; - }, $.prototype.mulp = function(S, m, f) { - var p = 2 * this.guessLen13b(S.length, m.length), b = this.makeRBT(p), x = this.stub(p), _ = new Array(p), E = new Array(p), v = new Array(p), P = new Array(p), I = new Array(p), B = new Array(p), ce = f.words; - ce.length = p, this.convert13b(S.words, S.length, _, p), this.convert13b(m.words, m.length, P, p), this.transform(_, x, E, v, p, b), this.transform(P, x, I, B, p, b); - for (var D = 0; D < p; D++) { - var oe = E[D] * I[D] - v[D] * B[D]; - v[D] = E[D] * B[D] + v[D] * I[D], E[D] = oe; - } - return this.conjugate(E, v, p), this.transform(E, v, ce, x, p, b), this.conjugate(ce, x, p), this.normalize13b(ce, p), f.negative = S.negative ^ m.negative, f.length = S.length + m.length, f.strip(); - }, s.prototype.mul = function(S) { - var m = new s(null); - return m.words = new Array(this.length + S.length), this.mulTo(S, m); - }, s.prototype.mulf = function(S) { - var m = new s(null); - return m.words = new Array(this.length + S.length), F(this, S, m); - }, s.prototype.imul = function(S) { - return this.clone().mulTo(S, this); - }, s.prototype.imuln = function(S) { - n(typeof S == "number"), n(S < 67108864); - for (var m = 0, f = 0; f < this.length; f++) { - var p = (this.words[f] | 0) * S, b = (p & 67108863) + (m & 67108863); - m >>= 26, m += p / 67108864 | 0, m += b >>> 26, this.words[f] = b & 67108863; - } - return m !== 0 && (this.words[f] = m, this.length++), this; - }, s.prototype.muln = function(S) { - return this.clone().imuln(S); - }, s.prototype.sqr = function() { - return this.mul(this); - }, s.prototype.isqr = function() { - return this.imul(this.clone()); - }, s.prototype.pow = function(S) { - var m = A(S); - if (m.length === 0) return new s(1); - for (var f = this, p = 0; p < m.length && m[p] === 0; p++, f = f.sqr()) - ; - if (++p < m.length) - for (var b = f.sqr(); p < m.length; p++, b = b.sqr()) - m[p] !== 0 && (f = f.mul(b)); - return f; - }, s.prototype.iushln = function(S) { - n(typeof S == "number" && S >= 0); - var m = S % 26, f = (S - m) / 26, p = 67108863 >>> 26 - m << 26 - m, b; - if (m !== 0) { - var x = 0; - for (b = 0; b < this.length; b++) { - var _ = this.words[b] & p, E = (this.words[b] | 0) - _ << m; - this.words[b] = E | x, x = _ >>> 26 - m; - } - x && (this.words[b] = x, this.length++); - } - if (f !== 0) { - for (b = this.length - 1; b >= 0; b--) - this.words[b + f] = this.words[b]; - for (b = 0; b < f; b++) - this.words[b] = 0; - this.length += f; - } - return this.strip(); - }, s.prototype.ishln = function(S) { - return n(this.negative === 0), this.iushln(S); - }, s.prototype.iushrn = function(S, m, f) { - n(typeof S == "number" && S >= 0); - var p; - m ? p = (m - m % 26) / 26 : p = 0; - var b = S % 26, x = Math.min((S - b) / 26, this.length), _ = 67108863 ^ 67108863 >>> b << b, E = f; - if (p -= x, p = Math.max(0, p), E) { - for (var v = 0; v < x; v++) - E.words[v] = this.words[v]; - E.length = x; - } - if (x !== 0) if (this.length > x) - for (this.length -= x, v = 0; v < this.length; v++) - this.words[v] = this.words[v + x]; - else - this.words[0] = 0, this.length = 1; - var P = 0; - for (v = this.length - 1; v >= 0 && (P !== 0 || v >= p); v--) { - var I = this.words[v] | 0; - this.words[v] = P << 26 - b | I >>> b, P = I & _; - } - return E && P !== 0 && (E.words[E.length++] = P), this.length === 0 && (this.words[0] = 0, this.length = 1), this.strip(); - }, s.prototype.ishrn = function(S, m, f) { - return n(this.negative === 0), this.iushrn(S, m, f); - }, s.prototype.shln = function(S) { - return this.clone().ishln(S); - }, s.prototype.ushln = function(S) { - return this.clone().iushln(S); - }, s.prototype.shrn = function(S) { - return this.clone().ishrn(S); - }, s.prototype.ushrn = function(S) { - return this.clone().iushrn(S); - }, s.prototype.testn = function(S) { - n(typeof S == "number" && S >= 0); - var m = S % 26, f = (S - m) / 26, p = 1 << m; - if (this.length <= f) return !1; - var b = this.words[f]; - return !!(b & p); - }, s.prototype.imaskn = function(S) { - n(typeof S == "number" && S >= 0); - var m = S % 26, f = (S - m) / 26; - if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= f) - return this; - if (m !== 0 && f++, this.length = Math.min(f, this.length), m !== 0) { - var p = 67108863 ^ 67108863 >>> m << m; - this.words[this.length - 1] &= p; - } - return this.strip(); - }, s.prototype.maskn = function(S) { - return this.clone().imaskn(S); - }, s.prototype.iaddn = function(S) { - return n(typeof S == "number"), n(S < 67108864), S < 0 ? this.isubn(-S) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) < S ? (this.words[0] = S - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(S), this.negative = 1, this) : this._iaddn(S); - }, s.prototype._iaddn = function(S) { - this.words[0] += S; - for (var m = 0; m < this.length && this.words[m] >= 67108864; m++) - this.words[m] -= 67108864, m === this.length - 1 ? this.words[m + 1] = 1 : this.words[m + 1]++; - return this.length = Math.max(this.length, m + 1), this; - }, s.prototype.isubn = function(S) { - if (n(typeof S == "number"), n(S < 67108864), S < 0) return this.iaddn(-S); - if (this.negative !== 0) - return this.negative = 0, this.iaddn(S), this.negative = 1, this; - if (this.words[0] -= S, this.length === 1 && this.words[0] < 0) - this.words[0] = -this.words[0], this.negative = 1; - else - for (var m = 0; m < this.length && this.words[m] < 0; m++) - this.words[m] += 67108864, this.words[m + 1] -= 1; - return this.strip(); - }, s.prototype.addn = function(S) { - return this.clone().iaddn(S); - }, s.prototype.subn = function(S) { - return this.clone().isubn(S); - }, s.prototype.iabs = function() { - return this.negative = 0, this; - }, s.prototype.abs = function() { - return this.clone().iabs(); - }, s.prototype._ishlnsubmul = function(S, m, f) { - var p = S.length + f, b; - this._expand(p); - var x, _ = 0; - for (b = 0; b < S.length; b++) { - x = (this.words[b + f] | 0) + _; - var E = (S.words[b] | 0) * m; - x -= E & 67108863, _ = (x >> 26) - (E / 67108864 | 0), this.words[b + f] = x & 67108863; - } - for (; b < this.length - f; b++) - x = (this.words[b + f] | 0) + _, _ = x >> 26, this.words[b + f] = x & 67108863; - if (_ === 0) return this.strip(); - for (n(_ === -1), _ = 0, b = 0; b < this.length; b++) - x = -(this.words[b] | 0) + _, _ = x >> 26, this.words[b] = x & 67108863; - return this.negative = 1, this.strip(); - }, s.prototype._wordDiv = function(S, m) { - var f = this.length - S.length, p = this.clone(), b = S, x = b.words[b.length - 1] | 0, _ = this._countBits(x); - f = 26 - _, f !== 0 && (b = b.ushln(f), p.iushln(f), x = b.words[b.length - 1] | 0); - var E = p.length - b.length, v; - if (m !== "mod") { - v = new s(null), v.length = E + 1, v.words = new Array(v.length); - for (var P = 0; P < v.length; P++) - v.words[P] = 0; - } - var I = p.clone()._ishlnsubmul(b, 1, E); - I.negative === 0 && (p = I, v && (v.words[E] = 1)); - for (var B = E - 1; B >= 0; B--) { - var ce = (p.words[b.length + B] | 0) * 67108864 + (p.words[b.length + B - 1] | 0); - for (ce = Math.min(ce / x | 0, 67108863), p._ishlnsubmul(b, ce, B); p.negative !== 0; ) - ce--, p.negative = 0, p._ishlnsubmul(b, 1, B), p.isZero() || (p.negative ^= 1); - v && (v.words[B] = ce); - } - return v && v.strip(), p.strip(), m !== "div" && f !== 0 && p.iushrn(f), { - div: v || null, - mod: p - }; - }, s.prototype.divmod = function(S, m, f) { - if (n(!S.isZero()), this.isZero()) - return { - div: new s(0), - mod: new s(0) - }; - var p, b, x; - return this.negative !== 0 && S.negative === 0 ? (x = this.neg().divmod(S, m), m !== "mod" && (p = x.div.neg()), m !== "div" && (b = x.mod.neg(), f && b.negative !== 0 && b.iadd(S)), { - div: p, - mod: b - }) : this.negative === 0 && S.negative !== 0 ? (x = this.divmod(S.neg(), m), m !== "mod" && (p = x.div.neg()), { - div: p, - mod: x.mod - }) : this.negative & S.negative ? (x = this.neg().divmod(S.neg(), m), m !== "div" && (b = x.mod.neg(), f && b.negative !== 0 && b.isub(S)), { - div: x.div, - mod: b - }) : S.length > this.length || this.cmp(S) < 0 ? { - div: new s(0), - mod: this - } : S.length === 1 ? m === "div" ? { - div: this.divn(S.words[0]), - mod: null - } : m === "mod" ? { - div: null, - mod: new s(this.modn(S.words[0])) - } : { - div: this.divn(S.words[0]), - mod: new s(this.modn(S.words[0])) - } : this._wordDiv(S, m); - }, s.prototype.div = function(S) { - return this.divmod(S, "div", !1).div; - }, s.prototype.mod = function(S) { - return this.divmod(S, "mod", !1).mod; - }, s.prototype.umod = function(S) { - return this.divmod(S, "mod", !0).mod; - }, s.prototype.divRound = function(S) { - var m = this.divmod(S); - if (m.mod.isZero()) return m.div; - var f = m.div.negative !== 0 ? m.mod.isub(S) : m.mod, p = S.ushrn(1), b = S.andln(1), x = f.cmp(p); - return x < 0 || b === 1 && x === 0 ? m.div : m.div.negative !== 0 ? m.div.isubn(1) : m.div.iaddn(1); - }, s.prototype.modn = function(S) { - n(S <= 67108863); - for (var m = (1 << 26) % S, f = 0, p = this.length - 1; p >= 0; p--) - f = (m * f + (this.words[p] | 0)) % S; - return f; - }, s.prototype.idivn = function(S) { - n(S <= 67108863); - for (var m = 0, f = this.length - 1; f >= 0; f--) { - var p = (this.words[f] | 0) + m * 67108864; - this.words[f] = p / S | 0, m = p % S; - } - return this.strip(); - }, s.prototype.divn = function(S) { - return this.clone().idivn(S); - }, s.prototype.egcd = function(S) { - n(S.negative === 0), n(!S.isZero()); - var m = this, f = S.clone(); - m.negative !== 0 ? m = m.umod(S) : m = m.clone(); - for (var p = new s(1), b = new s(0), x = new s(0), _ = new s(1), E = 0; m.isEven() && f.isEven(); ) - m.iushrn(1), f.iushrn(1), ++E; - for (var v = f.clone(), P = m.clone(); !m.isZero(); ) { - for (var I = 0, B = 1; !(m.words[0] & B) && I < 26; ++I, B <<= 1) ; - if (I > 0) - for (m.iushrn(I); I-- > 0; ) - (p.isOdd() || b.isOdd()) && (p.iadd(v), b.isub(P)), p.iushrn(1), b.iushrn(1); - for (var ce = 0, D = 1; !(f.words[0] & D) && ce < 26; ++ce, D <<= 1) ; - if (ce > 0) - for (f.iushrn(ce); ce-- > 0; ) - (x.isOdd() || _.isOdd()) && (x.iadd(v), _.isub(P)), x.iushrn(1), _.iushrn(1); - m.cmp(f) >= 0 ? (m.isub(f), p.isub(x), b.isub(_)) : (f.isub(m), x.isub(p), _.isub(b)); - } - return { - a: x, - b: _, - gcd: f.iushln(E) - }; - }, s.prototype._invmp = function(S) { - n(S.negative === 0), n(!S.isZero()); - var m = this, f = S.clone(); - m.negative !== 0 ? m = m.umod(S) : m = m.clone(); - for (var p = new s(1), b = new s(0), x = f.clone(); m.cmpn(1) > 0 && f.cmpn(1) > 0; ) { - for (var _ = 0, E = 1; !(m.words[0] & E) && _ < 26; ++_, E <<= 1) ; - if (_ > 0) - for (m.iushrn(_); _-- > 0; ) - p.isOdd() && p.iadd(x), p.iushrn(1); - for (var v = 0, P = 1; !(f.words[0] & P) && v < 26; ++v, P <<= 1) ; - if (v > 0) - for (f.iushrn(v); v-- > 0; ) - b.isOdd() && b.iadd(x), b.iushrn(1); - m.cmp(f) >= 0 ? (m.isub(f), p.isub(b)) : (f.isub(m), b.isub(p)); - } - var I; - return m.cmpn(1) === 0 ? I = p : I = b, I.cmpn(0) < 0 && I.iadd(S), I; - }, s.prototype.gcd = function(S) { - if (this.isZero()) return S.abs(); - if (S.isZero()) return this.abs(); - var m = this.clone(), f = S.clone(); - m.negative = 0, f.negative = 0; - for (var p = 0; m.isEven() && f.isEven(); p++) - m.iushrn(1), f.iushrn(1); - do { - for (; m.isEven(); ) - m.iushrn(1); - for (; f.isEven(); ) - f.iushrn(1); - var b = m.cmp(f); - if (b < 0) { - var x = m; - m = f, f = x; - } else if (b === 0 || f.cmpn(1) === 0) - break; - m.isub(f); - } while (!0); - return f.iushln(p); - }, s.prototype.invm = function(S) { - return this.egcd(S).a.umod(S); - }, s.prototype.isEven = function() { - return (this.words[0] & 1) === 0; - }, s.prototype.isOdd = function() { - return (this.words[0] & 1) === 1; - }, s.prototype.andln = function(S) { - return this.words[0] & S; - }, s.prototype.bincn = function(S) { - n(typeof S == "number"); - var m = S % 26, f = (S - m) / 26, p = 1 << m; - if (this.length <= f) - return this._expand(f + 1), this.words[f] |= p, this; - for (var b = p, x = f; b !== 0 && x < this.length; x++) { - var _ = this.words[x] | 0; - _ += b, b = _ >>> 26, _ &= 67108863, this.words[x] = _; - } - return b !== 0 && (this.words[x] = b, this.length++), this; - }, s.prototype.isZero = function() { - return this.length === 1 && this.words[0] === 0; - }, s.prototype.cmpn = function(S) { - var m = S < 0; - if (this.negative !== 0 && !m) return -1; - if (this.negative === 0 && m) return 1; - this.strip(); - var f; - if (this.length > 1) - f = 1; - else { - m && (S = -S), n(S <= 67108863, "Number is too big"); - var p = this.words[0] | 0; - f = p === S ? 0 : p < S ? -1 : 1; - } - return this.negative !== 0 ? -f | 0 : f; - }, s.prototype.cmp = function(S) { - if (this.negative !== 0 && S.negative === 0) return -1; - if (this.negative === 0 && S.negative !== 0) return 1; - var m = this.ucmp(S); - return this.negative !== 0 ? -m | 0 : m; - }, s.prototype.ucmp = function(S) { - if (this.length > S.length) return 1; - if (this.length < S.length) return -1; - for (var m = 0, f = this.length - 1; f >= 0; f--) { - var p = this.words[f] | 0, b = S.words[f] | 0; - if (p !== b) { - p < b ? m = -1 : p > b && (m = 1); - break; - } - } - return m; - }, s.prototype.gtn = function(S) { - return this.cmpn(S) === 1; - }, s.prototype.gt = function(S) { - return this.cmp(S) === 1; - }, s.prototype.gten = function(S) { - return this.cmpn(S) >= 0; - }, s.prototype.gte = function(S) { - return this.cmp(S) >= 0; - }, s.prototype.ltn = function(S) { - return this.cmpn(S) === -1; - }, s.prototype.lt = function(S) { - return this.cmp(S) === -1; - }, s.prototype.lten = function(S) { - return this.cmpn(S) <= 0; - }, s.prototype.lte = function(S) { - return this.cmp(S) <= 0; - }, s.prototype.eqn = function(S) { - return this.cmpn(S) === 0; - }, s.prototype.eq = function(S) { - return this.cmp(S) === 0; - }, s.red = function(S) { - return new pe(S); - }, s.prototype.toRed = function(S) { - return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), S.convertTo(this)._forceRed(S); - }, s.prototype.fromRed = function() { - return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); - }, s.prototype._forceRed = function(S) { - return this.red = S, this; - }, s.prototype.forceRed = function(S) { - return n(!this.red, "Already a number in reduction context"), this._forceRed(S); - }, s.prototype.redAdd = function(S) { - return n(this.red, "redAdd works only with red numbers"), this.red.add(this, S); - }, s.prototype.redIAdd = function(S) { - return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, S); - }, s.prototype.redSub = function(S) { - return n(this.red, "redSub works only with red numbers"), this.red.sub(this, S); - }, s.prototype.redISub = function(S) { - return n(this.red, "redISub works only with red numbers"), this.red.isub(this, S); - }, s.prototype.redShl = function(S) { - return n(this.red, "redShl works only with red numbers"), this.red.shl(this, S); - }, s.prototype.redMul = function(S) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, S), this.red.mul(this, S); - }, s.prototype.redIMul = function(S) { - return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, S), this.red.imul(this, S); - }, s.prototype.redSqr = function() { - return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); - }, s.prototype.redISqr = function() { - return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); - }, s.prototype.redSqrt = function() { - return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); - }, s.prototype.redInvm = function() { - return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); - }, s.prototype.redNeg = function() { - return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); - }, s.prototype.redPow = function(S) { - return n(this.red && !S.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, S); - }; - var K = { - k256: null, - p224: null, - p192: null, - p25519: null - }; - function H(Y, S) { - this.name = Y, this.p = new s(S, 16), this.n = this.p.bitLength(), this.k = new s(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); - } - H.prototype._tmp = function() { - var S = new s(null); - return S.words = new Array(Math.ceil(this.n / 13)), S; - }, H.prototype.ireduce = function(S) { - var m = S, f; - do - this.split(m, this.tmp), m = this.imulK(m), m = m.iadd(this.tmp), f = m.bitLength(); - while (f > this.n); - var p = f < this.n ? -1 : m.ucmp(this.p); - return p === 0 ? (m.words[0] = 0, m.length = 1) : p > 0 ? m.isub(this.p) : m.strip !== void 0 ? m.strip() : m._strip(), m; - }, H.prototype.split = function(S, m) { - S.iushrn(this.n, 0, m); - }, H.prototype.imulK = function(S) { - return S.imul(this.k); - }; - function V() { - H.call( - this, - "k256", - "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f" - ); - } - i(V, H), V.prototype.split = function(S, m) { - for (var f = 4194303, p = Math.min(S.length, 9), b = 0; b < p; b++) - m.words[b] = S.words[b]; - if (m.length = p, S.length <= 9) { - S.words[0] = 0, S.length = 1; - return; - } - var x = S.words[9]; - for (m.words[m.length++] = x & f, b = 10; b < S.length; b++) { - var _ = S.words[b] | 0; - S.words[b - 10] = (_ & f) << 4 | x >>> 22, x = _; - } - x >>>= 22, S.words[b - 10] = x, x === 0 && S.length > 10 ? S.length -= 10 : S.length -= 9; - }, V.prototype.imulK = function(S) { - S.words[S.length] = 0, S.words[S.length + 1] = 0, S.length += 2; - for (var m = 0, f = 0; f < S.length; f++) { - var p = S.words[f] | 0; - m += p * 977, S.words[f] = m & 67108863, m = p * 64 + (m / 67108864 | 0); - } - return S.words[S.length - 1] === 0 && (S.length--, S.words[S.length - 1] === 0 && S.length--), S; - }; - function te() { - H.call( - this, - "p224", - "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001" - ); - } - i(te, H); - function R() { - H.call( - this, - "p192", - "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff" - ); - } - i(R, H); - function W() { - H.call( - this, - "25519", - "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed" - ); - } - i(W, H), W.prototype.imulK = function(S) { - for (var m = 0, f = 0; f < S.length; f++) { - var p = (S.words[f] | 0) * 19 + m, b = p & 67108863; - p >>>= 26, S.words[f] = b, m = p; - } - return m !== 0 && (S.words[S.length++] = m), S; - }, s._prime = function(S) { - if (K[S]) return K[S]; - var m; - if (S === "k256") - m = new V(); - else if (S === "p224") - m = new te(); - else if (S === "p192") - m = new R(); - else if (S === "p25519") - m = new W(); - else - throw new Error("Unknown prime " + S); - return K[S] = m, m; - }; - function pe(Y) { - if (typeof Y == "string") { - var S = s._prime(Y); - this.m = S.p, this.prime = S; - } else - n(Y.gtn(1), "modulus must be greater than 1"), this.m = Y, this.prime = null; - } - pe.prototype._verify1 = function(S) { - n(S.negative === 0, "red works only with positives"), n(S.red, "red works only with red numbers"); - }, pe.prototype._verify2 = function(S, m) { - n((S.negative | m.negative) === 0, "red works only with positives"), n( - S.red && S.red === m.red, - "red works only with red numbers" - ); - }, pe.prototype.imod = function(S) { - return this.prime ? this.prime.ireduce(S)._forceRed(this) : S.umod(this.m)._forceRed(this); - }, pe.prototype.neg = function(S) { - return S.isZero() ? S.clone() : this.m.sub(S)._forceRed(this); - }, pe.prototype.add = function(S, m) { - this._verify2(S, m); - var f = S.add(m); - return f.cmp(this.m) >= 0 && f.isub(this.m), f._forceRed(this); - }, pe.prototype.iadd = function(S, m) { - this._verify2(S, m); - var f = S.iadd(m); - return f.cmp(this.m) >= 0 && f.isub(this.m), f; - }, pe.prototype.sub = function(S, m) { - this._verify2(S, m); - var f = S.sub(m); - return f.cmpn(0) < 0 && f.iadd(this.m), f._forceRed(this); - }, pe.prototype.isub = function(S, m) { - this._verify2(S, m); - var f = S.isub(m); - return f.cmpn(0) < 0 && f.iadd(this.m), f; - }, pe.prototype.shl = function(S, m) { - return this._verify1(S), this.imod(S.ushln(m)); - }, pe.prototype.imul = function(S, m) { - return this._verify2(S, m), this.imod(S.imul(m)); - }, pe.prototype.mul = function(S, m) { - return this._verify2(S, m), this.imod(S.mul(m)); - }, pe.prototype.isqr = function(S) { - return this.imul(S, S.clone()); - }, pe.prototype.sqr = function(S) { - return this.mul(S, S); - }, pe.prototype.sqrt = function(S) { - if (S.isZero()) return S.clone(); - var m = this.m.andln(3); - if (n(m % 2 === 1), m === 3) { - var f = this.m.add(new s(1)).iushrn(2); - return this.pow(S, f); - } - for (var p = this.m.subn(1), b = 0; !p.isZero() && p.andln(1) === 0; ) - b++, p.iushrn(1); - n(!p.isZero()); - var x = new s(1).toRed(this), _ = x.redNeg(), E = this.m.subn(1).iushrn(1), v = this.m.bitLength(); - for (v = new s(2 * v * v).toRed(this); this.pow(v, E).cmp(_) !== 0; ) - v.redIAdd(_); - for (var P = this.pow(v, p), I = this.pow(S, p.addn(1).iushrn(1)), B = this.pow(S, p), ce = b; B.cmp(x) !== 0; ) { - for (var D = B, oe = 0; D.cmp(x) !== 0; oe++) - D = D.redSqr(); - n(oe < ce); - var Z = this.pow(P, new s(1).iushln(ce - oe - 1)); - I = I.redMul(Z), P = Z.redSqr(), B = B.redMul(P), ce = oe; - } - return I; - }, pe.prototype.invm = function(S) { - var m = S._invmp(this.m); - return m.negative !== 0 ? (m.negative = 0, this.imod(m).redNeg()) : this.imod(m); - }, pe.prototype.pow = function(S, m) { - if (m.isZero()) return new s(1).toRed(this); - if (m.cmpn(1) === 0) return S.clone(); - var f = 4, p = new Array(1 << f); - p[0] = new s(1).toRed(this), p[1] = S; - for (var b = 2; b < p.length; b++) - p[b] = this.mul(p[b - 1], S); - var x = p[0], _ = 0, E = 0, v = m.bitLength() % 26; - for (v === 0 && (v = 26), b = m.length - 1; b >= 0; b--) { - for (var P = m.words[b], I = v - 1; I >= 0; I--) { - var B = P >> I & 1; - if (x !== p[0] && (x = this.sqr(x)), B === 0 && _ === 0) { - E = 0; - continue; - } - _ <<= 1, _ |= B, E++, !(E !== f && (b !== 0 || I !== 0)) && (x = this.mul(x, p[_]), E = 0, _ = 0); - } - v = 26; - } - return x; - }, pe.prototype.convertTo = function(S) { - var m = S.umod(this.m); - return m === S ? m.clone() : m; - }, pe.prototype.convertFrom = function(S) { - var m = S.clone(); - return m.red = null, m; - }, s.mont = function(S) { - return new Ee(S); - }; - function Ee(Y) { - pe.call(this, Y), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new s(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(Ee, pe), Ee.prototype.convertTo = function(S) { - return this.imod(S.ushln(this.shift)); - }, Ee.prototype.convertFrom = function(S) { - var m = this.imod(S.mul(this.rinv)); - return m.red = null, m; - }, Ee.prototype.imul = function(S, m) { - if (S.isZero() || m.isZero()) - return S.words[0] = 0, S.length = 1, S; - var f = S.imul(m), p = f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), b = f.isub(p).iushrn(this.shift), x = b; - return b.cmp(this.m) >= 0 ? x = b.isub(this.m) : b.cmpn(0) < 0 && (x = b.iadd(this.m)), x._forceRed(this); - }, Ee.prototype.mul = function(S, m) { - if (S.isZero() || m.isZero()) return new s(0)._forceRed(this); - var f = S.mul(m), p = f.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), b = f.isub(p).iushrn(this.shift), x = b; - return b.cmp(this.m) >= 0 ? x = b.isub(this.m) : b.cmpn(0) < 0 && (x = b.iadd(this.m)), x._forceRed(this); - }, Ee.prototype.invm = function(S) { - var m = this.imod(S._invmp(this.m).mul(this.r2)); - return m._forceRed(this); - }; - })(t, gn); -})(Jv); -var qo = Jv.exports, Xv = {}; -(function(t) { - var e = t; - function r(s, o) { - if (Array.isArray(s)) - return s.slice(); - if (!s) - return []; - var a = []; - if (typeof s != "string") { - for (var u = 0; u < s.length; u++) - a[u] = s[u] | 0; - return a; - } - if (o === "hex") { - s = s.replace(/[^a-z0-9]+/ig, ""), s.length % 2 !== 0 && (s = "0" + s); - for (var u = 0; u < s.length; u += 2) - a.push(parseInt(s[u] + s[u + 1], 16)); - } else - for (var u = 0; u < s.length; u++) { - var l = s.charCodeAt(u), d = l >> 8, g = l & 255; - d ? a.push(d, g) : a.push(g); - } - return a; - } - e.toArray = r; - function n(s) { - return s.length === 1 ? "0" + s : s; - } - e.zero2 = n; - function i(s) { - for (var o = "", a = 0; a < s.length; a++) - o += n(s[a].toString(16)); - return o; - } - e.toHex = i, e.encode = function(o, a) { - return a === "hex" ? i(o) : o; - }; -})(Xv); -(function(t) { - var e = t, r = qo, n = yc, i = Xv; - e.assert = n, e.toArray = i.toArray, e.zero2 = i.zero2, e.toHex = i.toHex, e.encode = i.encode; - function s(d, g, w) { - var A = new Array(Math.max(d.bitLength(), w) + 1), M; - for (M = 0; M < A.length; M += 1) - A[M] = 0; - var N = 1 << g + 1, L = d.clone(); - for (M = 0; M < A.length; M++) { - var F, $ = L.andln(N - 1); - L.isOdd() ? ($ > (N >> 1) - 1 ? F = (N >> 1) - $ : F = $, L.isubn(F)) : F = 0, A[M] = F, L.iushrn(1); - } - return A; - } - e.getNAF = s; - function o(d, g) { - var w = [ - [], - [] - ]; - d = d.clone(), g = g.clone(); - for (var A = 0, M = 0, N; d.cmpn(-A) > 0 || g.cmpn(-M) > 0; ) { - var L = d.andln(3) + A & 3, F = g.andln(3) + M & 3; - L === 3 && (L = -1), F === 3 && (F = -1); - var $; - L & 1 ? (N = d.andln(7) + A & 7, (N === 3 || N === 5) && F === 2 ? $ = -L : $ = L) : $ = 0, w[0].push($); - var K; - F & 1 ? (N = g.andln(7) + M & 7, (N === 3 || N === 5) && L === 2 ? K = -F : K = F) : K = 0, w[1].push(K), 2 * A === $ + 1 && (A = 1 - A), 2 * M === K + 1 && (M = 1 - M), d.iushrn(1), g.iushrn(1); - } - return w; - } - e.getJSF = o; - function a(d, g, w) { - var A = "_" + g; - d.prototype[g] = function() { - return this[A] !== void 0 ? this[A] : this[A] = w.call(this); - }; - } - e.cachedProperty = a; - function u(d) { - return typeof d == "string" ? e.toArray(d, "hex") : d; - } - e.parseBytes = u; - function l(d) { - return new r(d, "hex", "le"); - } - e.intFromLE = l; -})(Fi); -var Zv = { exports: {} }, am; -Zv.exports = function(e) { - return am || (am = new fa(null)), am.generate(e); -}; -function fa(t) { - this.rand = t; -} -Zv.exports.Rand = fa; -fa.prototype.generate = function(e) { - return this._rand(e); -}; -fa.prototype._rand = function(e) { - if (this.rand.getBytes) - return this.rand.getBytes(e); - for (var r = new Uint8Array(e), n = 0; n < r.length; n++) - r[n] = this.rand.getByte(); - return r; -}; -if (typeof self == "object") - self.crypto && self.crypto.getRandomValues ? fa.prototype._rand = function(e) { - var r = new Uint8Array(e); - return self.crypto.getRandomValues(r), r; - } : self.msCrypto && self.msCrypto.getRandomValues ? fa.prototype._rand = function(e) { - var r = new Uint8Array(e); - return self.msCrypto.getRandomValues(r), r; - } : typeof window == "object" && (fa.prototype._rand = function() { - throw new Error("Not implemented yet"); - }); -else - try { - var Ix = zl; - if (typeof Ix.randomBytes != "function") - throw new Error("Not supported"); - fa.prototype._rand = function(e) { - return Ix.randomBytes(e); - }; - } catch { - } -var _8 = Zv.exports, Qv = {}, za = qo, Yl = Fi, i0 = Yl.getNAF, Vj = Yl.getJSF, s0 = Yl.assert; -function Ca(t, e) { - this.type = t, this.p = new za(e.p, 16), this.red = e.prime ? za.red(e.prime) : za.mont(this.p), this.zero = new za(0).toRed(this.red), this.one = new za(1).toRed(this.red), this.two = new za(2).toRed(this.red), this.n = e.n && new za(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 r = this.n && this.p.div(this.n); - !r || r.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = !0, this.redN = this.n.toRed(this.red)); -} -var V0 = Ca; -Ca.prototype.point = function() { - throw new Error("Not implemented"); -}; -Ca.prototype.validate = function() { - throw new Error("Not implemented"); -}; -Ca.prototype._fixedNafMul = function(e, r) { - s0(e.precomputed); - var n = e._getDoubles(), i = i0(r, 1, this._bitLength), s = (1 << n.step + 1) - (n.step % 2 === 0 ? 2 : 1); - s /= 3; - var o = [], a, u; - for (a = 0; a < i.length; a += n.step) { - u = 0; - for (var l = a + n.step - 1; l >= a; l--) - u = (u << 1) + i[l]; - o.push(u); - } - for (var d = this.jpoint(null, null, null), g = this.jpoint(null, null, null), w = s; w > 0; w--) { - for (a = 0; a < o.length; a++) - u = o[a], u === w ? g = g.mixedAdd(n.points[a]) : u === -w && (g = g.mixedAdd(n.points[a].neg())); - d = d.add(g); - } - return d.toP(); -}; -Ca.prototype._wnafMul = function(e, r) { - var n = 4, i = e._getNAFPoints(n); - n = i.wnd; - for (var s = i.points, o = i0(r, n, this._bitLength), a = this.jpoint(null, null, null), u = o.length - 1; u >= 0; u--) { - for (var l = 0; u >= 0 && o[u] === 0; u--) - l++; - if (u >= 0 && l++, a = a.dblp(l), u < 0) - break; - var d = o[u]; - s0(d !== 0), e.type === "affine" ? d > 0 ? a = a.mixedAdd(s[d - 1 >> 1]) : a = a.mixedAdd(s[-d - 1 >> 1].neg()) : d > 0 ? a = a.add(s[d - 1 >> 1]) : a = a.add(s[-d - 1 >> 1].neg()); - } - return e.type === "affine" ? a.toP() : a; -}; -Ca.prototype._wnafMulAdd = function(e, r, n, i, s) { - var o = this._wnafT1, a = this._wnafT2, u = this._wnafT3, l = 0, d, g, w; - for (d = 0; d < i; d++) { - w = r[d]; - var A = w._getNAFPoints(e); - o[d] = A.wnd, a[d] = A.points; - } - for (d = i - 1; d >= 1; d -= 2) { - var M = d - 1, N = d; - if (o[M] !== 1 || o[N] !== 1) { - u[M] = i0(n[M], o[M], this._bitLength), u[N] = i0(n[N], o[N], this._bitLength), l = Math.max(u[M].length, l), l = Math.max(u[N].length, l); - continue; - } - var L = [ - r[M], - /* 1 */ - null, - /* 3 */ - null, - /* 5 */ - r[N] - /* 7 */ - ]; - r[M].y.cmp(r[N].y) === 0 ? (L[1] = r[M].add(r[N]), L[2] = r[M].toJ().mixedAdd(r[N].neg())) : r[M].y.cmp(r[N].y.redNeg()) === 0 ? (L[1] = r[M].toJ().mixedAdd(r[N]), L[2] = r[M].add(r[N].neg())) : (L[1] = r[M].toJ().mixedAdd(r[N]), L[2] = r[M].toJ().mixedAdd(r[N].neg())); - var F = [ - -3, - /* -1 -1 */ - -1, - /* -1 0 */ - -5, - /* -1 1 */ - -7, - /* 0 -1 */ - 0, - /* 0 0 */ - 7, - /* 0 1 */ - 5, - /* 1 -1 */ - 1, - /* 1 0 */ - 3 - /* 1 1 */ - ], $ = Vj(n[M], n[N]); - for (l = Math.max($[0].length, l), u[M] = new Array(l), u[N] = new Array(l), g = 0; g < l; g++) { - var K = $[0][g] | 0, H = $[1][g] | 0; - u[M][g] = F[(K + 1) * 3 + (H + 1)], u[N][g] = 0, a[M] = L; - } - } - var V = this.jpoint(null, null, null), te = this._wnafT4; - for (d = l; d >= 0; d--) { - for (var R = 0; d >= 0; ) { - var W = !0; - for (g = 0; g < i; g++) - te[g] = u[g][d] | 0, te[g] !== 0 && (W = !1); - if (!W) - break; - R++, d--; - } - if (d >= 0 && R++, V = V.dblp(R), d < 0) - break; - for (g = 0; g < i; g++) { - var pe = te[g]; - pe !== 0 && (pe > 0 ? w = a[g][pe - 1 >> 1] : pe < 0 && (w = a[g][-pe - 1 >> 1].neg()), w.type === "affine" ? V = V.mixedAdd(w) : V = V.add(w)); - } - } - for (d = 0; d < i; d++) - a[d] = null; - return s ? V : V.toP(); -}; -function ss(t, e) { - this.curve = t, this.type = e, this.precomputed = null; -} -Ca.BasePoint = ss; -ss.prototype.eq = function() { - throw new Error("Not implemented"); -}; -ss.prototype.validate = function() { - return this.curve.validate(this); -}; -Ca.prototype.decodePoint = function(e, r) { - e = Yl.toArray(e, r); - var n = this.p.byteLength(); - if ((e[0] === 4 || e[0] === 6 || e[0] === 7) && e.length - 1 === 2 * n) { - e[0] === 6 ? s0(e[e.length - 1] % 2 === 0) : e[0] === 7 && s0(e[e.length - 1] % 2 === 1); - var i = this.point( - e.slice(1, 1 + n), - e.slice(1 + n, 1 + 2 * n) - ); - return i; - } else if ((e[0] === 2 || e[0] === 3) && e.length - 1 === n) - return this.pointFromX(e.slice(1, 1 + n), e[0] === 3); - throw new Error("Unknown point format"); -}; -ss.prototype.encodeCompressed = function(e) { - return this.encode(e, !0); -}; -ss.prototype._encode = function(e) { - var r = this.curve.p.byteLength(), n = this.getX().toArray("be", r); - return e ? [this.getY().isEven() ? 2 : 3].concat(n) : [4].concat(n, this.getY().toArray("be", r)); -}; -ss.prototype.encode = function(e, r) { - return Yl.encode(this._encode(r), e); -}; -ss.prototype.precompute = function(e) { - if (this.precomputed) - return this; - var r = { - doubles: null, - naf: null, - beta: null - }; - return r.naf = this._getNAFPoints(8), r.doubles = this._getDoubles(4, e), r.beta = this._getBeta(), this.precomputed = r, this; -}; -ss.prototype._hasDoubles = function(e) { - if (!this.precomputed) - return !1; - var r = this.precomputed.doubles; - return r ? r.points.length >= Math.ceil((e.bitLength() + 1) / r.step) : !1; -}; -ss.prototype._getDoubles = function(e, r) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; - for (var n = [this], i = this, s = 0; s < r; s += e) { - for (var o = 0; o < e; o++) - i = i.dbl(); - n.push(i); - } - return { - step: e, - points: n - }; -}; -ss.prototype._getNAFPoints = function(e) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; - for (var r = [this], n = (1 << e) - 1, i = n === 1 ? null : this.dbl(), s = 1; s < n; s++) - r[s] = r[s - 1].add(i); - return { - wnd: e, - points: r - }; -}; -ss.prototype._getBeta = function() { - return null; -}; -ss.prototype.dblp = function(e) { - for (var r = this, n = 0; n < e; n++) - r = r.dbl(); - return r; -}; -var Gj = Fi, rn = qo, eb = q0, Fu = V0, Yj = Gj.assert; -function os(t) { - Fu.call(this, "short", t), this.a = new rn(t.a, 16).toRed(this.red), this.b = new rn(t.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(t), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); -} -eb(os, Fu); -var Jj = os; -os.prototype._getEndomorphism = function(e) { - if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { - var r, n; - if (e.beta) - r = new rn(e.beta, 16).toRed(this.red); - else { - var i = this._getEndoRoots(this.p); - r = i[0].cmp(i[1]) < 0 ? i[0] : i[1], r = r.toRed(this.red); - } - if (e.lambda) - n = new rn(e.lambda, 16); - else { - var s = this._getEndoRoots(this.n); - this.g.mul(s[0]).x.cmp(this.g.x.redMul(r)) === 0 ? n = s[0] : (n = s[1], Yj(this.g.mul(n).x.cmp(this.g.x.redMul(r)) === 0)); - } - var o; - return e.basis ? o = e.basis.map(function(a) { - return { - a: new rn(a.a, 16), - b: new rn(a.b, 16) - }; - }) : o = this._getEndoBasis(n), { - beta: r, - lambda: n, - basis: o - }; - } -}; -os.prototype._getEndoRoots = function(e) { - var r = e === this.p ? this.red : rn.mont(e), n = new rn(2).toRed(r).redInvm(), i = n.redNeg(), s = new rn(3).toRed(r).redNeg().redSqrt().redMul(n), o = i.redAdd(s).fromRed(), a = i.redSub(s).fromRed(); - return [o, a]; -}; -os.prototype._getEndoBasis = function(e) { - for (var r = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), n = e, i = this.n.clone(), s = new rn(1), o = new rn(0), a = new rn(0), u = new rn(1), l, d, g, w, A, M, N, L = 0, F, $; n.cmpn(0) !== 0; ) { - var K = i.div(n); - F = i.sub(K.mul(n)), $ = a.sub(K.mul(s)); - var H = u.sub(K.mul(o)); - if (!g && F.cmp(r) < 0) - l = N.neg(), d = s, g = F.neg(), w = $; - else if (g && ++L === 2) - break; - N = F, i = n, n = F, a = s, s = $, u = o, o = H; - } - A = F.neg(), M = $; - var V = g.sqr().add(w.sqr()), te = A.sqr().add(M.sqr()); - return te.cmp(V) >= 0 && (A = l, M = d), g.negative && (g = g.neg(), w = w.neg()), A.negative && (A = A.neg(), M = M.neg()), [ - { a: g, b: w }, - { a: A, b: M } - ]; -}; -os.prototype._endoSplit = function(e) { - var r = this.endo.basis, n = r[0], i = r[1], s = i.b.mul(e).divRound(this.n), o = n.b.neg().mul(e).divRound(this.n), a = s.mul(n.a), u = o.mul(i.a), l = s.mul(n.b), d = o.mul(i.b), g = e.sub(a).sub(u), w = l.add(d).neg(); - return { k1: g, k2: w }; -}; -os.prototype.pointFromX = function(e, r) { - e = new rn(e, 16), e.red || (e = e.toRed(this.red)); - var n = e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b), i = n.redSqrt(); - if (i.redSqr().redSub(n).cmp(this.zero) !== 0) - throw new Error("invalid point"); - var s = i.fromRed().isOdd(); - return (r && !s || !r && s) && (i = i.redNeg()), this.point(e, i); -}; -os.prototype.validate = function(e) { - if (e.inf) - return !0; - var r = e.x, n = e.y, i = this.a.redMul(r), s = r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b); - return n.redSqr().redISub(s).cmpn(0) === 0; -}; -os.prototype._endoWnafMulAdd = function(e, r, n) { - for (var i = this._endoWnafT1, s = this._endoWnafT2, o = 0; o < e.length; o++) { - var a = this._endoSplit(r[o]), u = e[o], l = u._getBeta(); - a.k1.negative && (a.k1.ineg(), u = u.neg(!0)), a.k2.negative && (a.k2.ineg(), l = l.neg(!0)), i[o * 2] = u, i[o * 2 + 1] = l, s[o * 2] = a.k1, s[o * 2 + 1] = a.k2; - } - for (var d = this._wnafMulAdd(1, i, s, o * 2, n), g = 0; g < o * 2; g++) - i[g] = null, s[g] = null; - return d; -}; -function kn(t, e, r, n) { - Fu.BasePoint.call(this, t, "affine"), e === null && r === null ? (this.x = null, this.y = null, this.inf = !0) : (this.x = new rn(e, 16), this.y = new rn(r, 16), n && (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); -} -eb(kn, Fu.BasePoint); -os.prototype.point = function(e, r, n) { - return new kn(this, e, r, n); -}; -os.prototype.pointFromJSON = function(e, r) { - return kn.fromJSON(this, e, r); -}; -kn.prototype._getBeta = function() { - if (this.curve.endo) { - var e = this.precomputed; - if (e && e.beta) - return e.beta; - var r = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); - if (e) { - var n = this.curve, i = function(s) { - return n.point(s.x.redMul(n.endo.beta), s.y); - }; - e.beta = r, r.precomputed = { - beta: null, - naf: e.naf && { - wnd: e.naf.wnd, - points: e.naf.points.map(i) - }, - doubles: e.doubles && { - step: e.doubles.step, - points: e.doubles.points.map(i) - } - }; - } - return r; - } -}; -kn.prototype.toJSON = function() { - return this.precomputed ? [this.x, this.y, this.precomputed && { - doubles: this.precomputed.doubles && { - step: this.precomputed.doubles.step, - points: this.precomputed.doubles.points.slice(1) - }, - naf: this.precomputed.naf && { - wnd: this.precomputed.naf.wnd, - points: this.precomputed.naf.points.slice(1) - } - }] : [this.x, this.y]; -}; -kn.fromJSON = function(e, r, n) { - typeof r == "string" && (r = JSON.parse(r)); - var i = e.point(r[0], r[1], n); - if (!r[2]) - return i; - function s(a) { - return e.point(a[0], a[1], n); - } - var o = r[2]; - return i.precomputed = { - beta: null, - doubles: o.doubles && { - step: o.doubles.step, - points: [i].concat(o.doubles.points.map(s)) - }, - naf: o.naf && { - wnd: o.naf.wnd, - points: [i].concat(o.naf.points.map(s)) - } - }, i; -}; -kn.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; -}; -kn.prototype.isInfinity = function() { - return this.inf; -}; -kn.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 r = this.y.redSub(e.y); - r.cmpn(0) !== 0 && (r = r.redMul(this.x.redSub(e.x).redInvm())); - var n = r.redSqr().redISub(this.x).redISub(e.x), i = r.redMul(this.x.redSub(n)).redISub(this.y); - return this.curve.point(n, i); -}; -kn.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 r = this.curve.a, n = this.x.redSqr(), i = e.redInvm(), s = n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i), 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); -}; -kn.prototype.getX = function() { - return this.x.fromRed(); -}; -kn.prototype.getY = function() { - return this.y.fromRed(); -}; -kn.prototype.mul = function(e) { - return e = new rn(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); -}; -kn.prototype.mulAdd = function(e, r, n) { - var i = [this, r], s = [e, n]; - return this.curve.endo ? this.curve._endoWnafMulAdd(i, s) : this.curve._wnafMulAdd(1, i, s, 2); -}; -kn.prototype.jmulAdd = function(e, r, n) { - var i = [this, r], s = [e, n]; - return this.curve.endo ? this.curve._endoWnafMulAdd(i, s, !0) : this.curve._wnafMulAdd(1, i, s, 2, !0); -}; -kn.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); -}; -kn.prototype.neg = function(e) { - if (this.inf) - return this; - var r = this.curve.point(this.x, this.y.redNeg()); - if (e && this.precomputed) { - var n = this.precomputed, i = function(s) { - return s.neg(); - }; - r.precomputed = { - naf: n.naf && { - wnd: n.naf.wnd, - points: n.naf.points.map(i) - }, - doubles: n.doubles && { - step: n.doubles.step, - points: n.doubles.points.map(i) - } - }; - } - return r; -}; -kn.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 zn(t, e, r, n) { - Fu.BasePoint.call(this, t, "jacobian"), e === null && r === null && n === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new rn(0)) : (this.x = new rn(e, 16), this.y = new rn(r, 16), this.z = new rn(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.zOne = this.z === this.curve.one; -} -eb(zn, Fu.BasePoint); -os.prototype.jpoint = function(e, r, n) { - return new zn(this, e, r, n); -}; -zn.prototype.toP = function() { - if (this.isInfinity()) - return this.curve.point(null, null); - var e = this.z.redInvm(), r = e.redSqr(), n = this.x.redMul(r), i = this.y.redMul(r).redMul(e); - return this.curve.point(n, i); -}; -zn.prototype.neg = function() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); -}; -zn.prototype.add = function(e) { - if (this.isInfinity()) - return e; - if (e.isInfinity()) - return this; - var r = e.z.redSqr(), n = this.z.redSqr(), i = this.x.redMul(r), s = e.x.redMul(n), o = this.y.redMul(r.redMul(e.z)), a = e.y.redMul(n.redMul(this.z)), u = i.redSub(s), l = o.redSub(a); - if (u.cmpn(0) === 0) - return l.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); - var d = u.redSqr(), g = d.redMul(u), w = i.redMul(d), A = l.redSqr().redIAdd(g).redISub(w).redISub(w), M = l.redMul(w.redISub(A)).redISub(o.redMul(g)), N = this.z.redMul(e.z).redMul(u); - return this.curve.jpoint(A, M, N); -}; -zn.prototype.mixedAdd = function(e) { - if (this.isInfinity()) - return e.toJ(); - if (e.isInfinity()) - return this; - var r = this.z.redSqr(), n = this.x, i = e.x.redMul(r), s = this.y, o = e.y.redMul(r).redMul(this.z), a = n.redSub(i), u = s.redSub(o); - if (a.cmpn(0) === 0) - return u.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); - var l = a.redSqr(), d = l.redMul(a), g = n.redMul(l), w = u.redSqr().redIAdd(d).redISub(g).redISub(g), A = u.redMul(g.redISub(w)).redISub(s.redMul(d)), M = this.z.redMul(a); - return this.curve.jpoint(w, A, M); -}; -zn.prototype.dblp = function(e) { - if (e === 0) - return this; - if (this.isInfinity()) - return this; - if (!e) - return this.dbl(); - var r; - if (this.curve.zeroA || this.curve.threeA) { - var n = this; - for (r = 0; r < e; r++) - n = n.dbl(); - return n; - } - var i = this.curve.a, s = this.curve.tinv, o = this.x, a = this.y, u = this.z, l = u.redSqr().redSqr(), d = a.redAdd(a); - for (r = 0; r < e; r++) { - var g = o.redSqr(), w = d.redSqr(), A = w.redSqr(), M = g.redAdd(g).redIAdd(g).redIAdd(i.redMul(l)), N = o.redMul(w), L = M.redSqr().redISub(N.redAdd(N)), F = N.redISub(L), $ = M.redMul(F); - $ = $.redIAdd($).redISub(A); - var K = d.redMul(u); - r + 1 < e && (l = l.redMul(A)), o = L, u = K, d = $; - } - return this.curve.jpoint(o, d.redMul(s), u); -}; -zn.prototype.dbl = function() { - return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); -}; -zn.prototype._zeroDbl = function() { - var e, r, n; - if (this.zOne) { - var i = this.x.redSqr(), s = this.y.redSqr(), o = s.redSqr(), a = this.x.redAdd(s).redSqr().redISub(i).redISub(o); - a = a.redIAdd(a); - var u = i.redAdd(i).redIAdd(i), l = u.redSqr().redISub(a).redISub(a), d = o.redIAdd(o); - d = d.redIAdd(d), d = d.redIAdd(d), e = l, r = u.redMul(a.redISub(l)).redISub(d), n = this.y.redAdd(this.y); - } else { - var g = this.x.redSqr(), w = this.y.redSqr(), A = w.redSqr(), M = this.x.redAdd(w).redSqr().redISub(g).redISub(A); - M = M.redIAdd(M); - var N = g.redAdd(g).redIAdd(g), L = N.redSqr(), F = A.redIAdd(A); - F = F.redIAdd(F), F = F.redIAdd(F), e = L.redISub(M).redISub(M), r = N.redMul(M.redISub(e)).redISub(F), n = this.y.redMul(this.z), n = n.redIAdd(n); - } - return this.curve.jpoint(e, r, n); -}; -zn.prototype._threeDbl = function() { - var e, r, n; - if (this.zOne) { - var i = this.x.redSqr(), s = this.y.redSqr(), o = s.redSqr(), a = this.x.redAdd(s).redSqr().redISub(i).redISub(o); - a = a.redIAdd(a); - var u = i.redAdd(i).redIAdd(i).redIAdd(this.curve.a), l = u.redSqr().redISub(a).redISub(a); - e = l; - var d = o.redIAdd(o); - d = d.redIAdd(d), d = d.redIAdd(d), r = u.redMul(a.redISub(l)).redISub(d), n = this.y.redAdd(this.y); - } else { - var g = this.z.redSqr(), w = this.y.redSqr(), A = this.x.redMul(w), M = this.x.redSub(g).redMul(this.x.redAdd(g)); - M = M.redAdd(M).redIAdd(M); - var N = A.redIAdd(A); - N = N.redIAdd(N); - var L = N.redAdd(N); - e = M.redSqr().redISub(L), n = this.y.redAdd(this.z).redSqr().redISub(w).redISub(g); - var F = w.redSqr(); - F = F.redIAdd(F), F = F.redIAdd(F), F = F.redIAdd(F), r = M.redMul(N.redISub(e)).redISub(F); - } - return this.curve.jpoint(e, r, n); -}; -zn.prototype._dbl = function() { - var e = this.curve.a, r = this.x, n = this.y, i = this.z, s = i.redSqr().redSqr(), o = r.redSqr(), a = n.redSqr(), u = o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)), l = r.redAdd(r); - l = l.redIAdd(l); - var d = l.redMul(a), g = u.redSqr().redISub(d.redAdd(d)), w = d.redISub(g), A = a.redSqr(); - A = A.redIAdd(A), A = A.redIAdd(A), A = A.redIAdd(A); - var M = u.redMul(w).redISub(A), N = n.redAdd(n).redMul(i); - return this.curve.jpoint(g, M, N); -}; -zn.prototype.trpl = function() { - if (!this.curve.zeroA) - return this.dbl().add(this); - var e = this.x.redSqr(), r = this.y.redSqr(), n = this.z.redSqr(), i = r.redSqr(), s = e.redAdd(e).redIAdd(e), o = s.redSqr(), a = this.x.redAdd(r).redSqr().redISub(e).redISub(i); - a = a.redIAdd(a), a = a.redAdd(a).redIAdd(a), a = a.redISub(o); - var u = a.redSqr(), l = i.redIAdd(i); - l = l.redIAdd(l), l = l.redIAdd(l), l = l.redIAdd(l); - var d = s.redIAdd(a).redSqr().redISub(o).redISub(u).redISub(l), g = r.redMul(d); - g = g.redIAdd(g), g = g.redIAdd(g); - var w = this.x.redMul(u).redISub(g); - w = w.redIAdd(w), w = w.redIAdd(w); - var A = this.y.redMul(d.redMul(l.redISub(d)).redISub(a.redMul(u))); - A = A.redIAdd(A), A = A.redIAdd(A), A = A.redIAdd(A); - var M = this.z.redAdd(a).redSqr().redISub(n).redISub(u); - return this.curve.jpoint(w, A, M); -}; -zn.prototype.mul = function(e, r) { - return e = new rn(e, r), this.curve._wnafMul(this, e); -}; -zn.prototype.eq = function(e) { - if (e.type === "affine") - return this.eq(e.toJ()); - if (this === e) - return !0; - var r = this.z.redSqr(), n = e.z.redSqr(); - if (this.x.redMul(n).redISub(e.x.redMul(r)).cmpn(0) !== 0) - return !1; - var i = r.redMul(this.z), s = n.redMul(e.z); - return this.y.redMul(s).redISub(e.y.redMul(i)).cmpn(0) === 0; -}; -zn.prototype.eqXToP = function(e) { - var r = this.z.redSqr(), n = e.toRed(this.curve.red).redMul(r); - if (this.x.cmp(n) === 0) - return !0; - for (var i = e.clone(), s = this.curve.redN.redMul(r); ; ) { - if (i.iadd(this.curve.n), i.cmp(this.curve.p) >= 0) - return !1; - if (n.redIAdd(s), this.x.cmp(n) === 0) - return !0; - } -}; -zn.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; -}; -zn.prototype.isInfinity = function() { - return this.z.cmpn(0) === 0; -}; -var Zc = qo, E8 = q0, G0 = V0, Xj = Fi; -function Bu(t) { - G0.call(this, "mont", t), this.a = new Zc(t.a, 16).toRed(this.red), this.b = new Zc(t.b, 16).toRed(this.red), this.i4 = new Zc(4).toRed(this.red).redInvm(), this.two = new Zc(2).toRed(this.red), this.a24 = this.i4.redMul(this.a.redAdd(this.two)); -} -E8(Bu, G0); -var Zj = Bu; -Bu.prototype.validate = function(e) { - var r = e.normalize().x, n = r.redSqr(), i = n.redMul(r).redAdd(n.redMul(this.a)).redAdd(r), s = i.redSqrt(); - return s.redSqr().cmp(i) === 0; -}; -function Nn(t, e, r) { - G0.BasePoint.call(this, t, "projective"), e === null && r === null ? (this.x = this.curve.one, this.z = this.curve.zero) : (this.x = new Zc(e, 16), this.z = new Zc(r, 16), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red))); -} -E8(Nn, G0.BasePoint); -Bu.prototype.decodePoint = function(e, r) { - return this.point(Xj.toArray(e, r), 1); -}; -Bu.prototype.point = function(e, r) { - return new Nn(this, e, r); -}; -Bu.prototype.pointFromJSON = function(e) { - return Nn.fromJSON(this, e); -}; -Nn.prototype.precompute = function() { -}; -Nn.prototype._encode = function() { - return this.getX().toArray("be", this.curve.p.byteLength()); -}; -Nn.fromJSON = function(e, r) { - return new Nn(e, r[0], r[1] || e.one); -}; -Nn.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; -}; -Nn.prototype.isInfinity = function() { - return this.z.cmpn(0) === 0; -}; -Nn.prototype.dbl = function() { - var e = this.x.redAdd(this.z), r = e.redSqr(), n = this.x.redSub(this.z), i = n.redSqr(), s = r.redSub(i), o = r.redMul(i), a = s.redMul(i.redAdd(this.curve.a24.redMul(s))); - return this.curve.point(o, a); -}; -Nn.prototype.add = function() { - throw new Error("Not supported on Montgomery curve"); -}; -Nn.prototype.diffAdd = function(e, r) { - var n = this.x.redAdd(this.z), i = this.x.redSub(this.z), s = e.x.redAdd(e.z), o = e.x.redSub(e.z), a = o.redMul(n), u = s.redMul(i), l = r.z.redMul(a.redAdd(u).redSqr()), d = r.x.redMul(a.redISub(u).redSqr()); - return this.curve.point(l, d); -}; -Nn.prototype.mul = function(e) { - for (var r = e.clone(), n = this, i = this.curve.point(null, null), s = this, o = []; r.cmpn(0) !== 0; r.iushrn(1)) - o.push(r.andln(1)); - for (var a = o.length - 1; a >= 0; a--) - o[a] === 0 ? (n = n.diffAdd(i, s), i = i.dbl()) : (i = n.diffAdd(i, s), n = n.dbl()); - return i; -}; -Nn.prototype.mulAdd = function() { - throw new Error("Not supported on Montgomery curve"); -}; -Nn.prototype.jumlAdd = function() { - throw new Error("Not supported on Montgomery curve"); -}; -Nn.prototype.eq = function(e) { - return this.getX().cmp(e.getX()) === 0; -}; -Nn.prototype.normalize = function() { - return this.x = this.x.redMul(this.z.redInvm()), this.z = this.curve.one, this; -}; -Nn.prototype.getX = function() { - return this.normalize(), this.x.fromRed(); -}; -var Qj = Fi, Eo = qo, S8 = q0, Y0 = V0, eq = Qj.assert; -function ro(t) { - this.twisted = (t.a | 0) !== 1, this.mOneA = this.twisted && (t.a | 0) === -1, this.extended = this.mOneA, Y0.call(this, "edwards", t), this.a = new Eo(t.a, 16).umod(this.red.m), this.a = this.a.toRed(this.red), this.c = new Eo(t.c, 16).toRed(this.red), this.c2 = this.c.redSqr(), this.d = new Eo(t.d, 16).toRed(this.red), this.dd = this.d.redAdd(this.d), eq(!this.twisted || this.c.fromRed().cmpn(1) === 0), this.oneC = (t.c | 0) === 1; -} -S8(ro, Y0); -var tq = ro; -ro.prototype._mulA = function(e) { - return this.mOneA ? e.redNeg() : this.a.redMul(e); -}; -ro.prototype._mulC = function(e) { - return this.oneC ? e : this.c.redMul(e); -}; -ro.prototype.jpoint = function(e, r, n, i) { - return this.point(e, r, n, i); -}; -ro.prototype.pointFromX = function(e, r) { - e = new Eo(e, 16), e.red || (e = e.toRed(this.red)); - var n = e.redSqr(), i = this.c2.redSub(this.a.redMul(n)), s = this.one.redSub(this.c2.redMul(this.d).redMul(n)), o = i.redMul(s.redInvm()), a = o.redSqrt(); - if (a.redSqr().redSub(o).cmp(this.zero) !== 0) - throw new Error("invalid point"); - var u = a.fromRed().isOdd(); - return (r && !u || !r && u) && (a = a.redNeg()), this.point(e, a); -}; -ro.prototype.pointFromY = function(e, r) { - e = new Eo(e, 16), e.red || (e = e.toRed(this.red)); - var n = e.redSqr(), i = n.redSub(this.c2), s = n.redMul(this.d).redMul(this.c2).redSub(this.a), o = i.redMul(s.redInvm()); - if (o.cmp(this.zero) === 0) { - if (r) - 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() !== r && (a = a.redNeg()), this.point(a, e); -}; -ro.prototype.validate = function(e) { - if (e.isInfinity()) - return !0; - e.normalize(); - var r = e.x.redSqr(), n = e.y.redSqr(), i = r.redMul(this.a).redAdd(n), s = this.c2.redMul(this.one.redAdd(this.d.redMul(r).redMul(n))); - return i.cmp(s) === 0; -}; -function Wr(t, e, r, n, i) { - Y0.BasePoint.call(this, t, "projective"), e === null && r === null && n === 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 Eo(e, 16), this.y = new Eo(r, 16), this.z = n ? new Eo(n, 16) : this.curve.one, this.t = i && new Eo(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.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())))); -} -S8(Wr, Y0.BasePoint); -ro.prototype.pointFromJSON = function(e) { - return Wr.fromJSON(this, e); -}; -ro.prototype.point = function(e, r, n, i) { - return new Wr(this, e, r, n, i); -}; -Wr.fromJSON = function(e, r) { - return new Wr(e, r[0], r[1], r[2]); -}; -Wr.prototype.inspect = function() { - return this.isInfinity() ? "" : ""; -}; -Wr.prototype.isInfinity = function() { - return this.x.cmpn(0) === 0 && (this.y.cmp(this.z) === 0 || this.zOne && this.y.cmp(this.curve.c) === 0); -}; -Wr.prototype._extDbl = function() { - var e = this.x.redSqr(), r = this.y.redSqr(), n = this.z.redSqr(); - n = n.redIAdd(n); - var i = this.curve._mulA(e), s = this.x.redAdd(this.y).redSqr().redISub(e).redISub(r), o = i.redAdd(r), a = o.redSub(n), u = i.redSub(r), l = s.redMul(a), d = o.redMul(u), g = s.redMul(u), w = a.redMul(o); - return this.curve.point(l, d, w, g); -}; -Wr.prototype._projDbl = function() { - var e = this.x.redAdd(this.y).redSqr(), r = this.x.redSqr(), n = this.y.redSqr(), i, s, o, a, u, l; - if (this.curve.twisted) { - a = this.curve._mulA(r); - var d = a.redAdd(n); - this.zOne ? (i = e.redSub(r).redSub(n).redMul(d.redSub(this.curve.two)), s = d.redMul(a.redSub(n)), o = d.redSqr().redSub(d).redSub(d)) : (u = this.z.redSqr(), l = d.redSub(u).redISub(u), i = e.redSub(r).redISub(n).redMul(l), s = d.redMul(a.redSub(n)), o = d.redMul(l)); - } else - a = r.redAdd(n), u = this.curve._mulC(this.z).redSqr(), l = a.redSub(u).redSub(u), i = this.curve._mulC(e.redISub(a)).redMul(l), s = this.curve._mulC(a).redMul(r.redISub(n)), o = a.redMul(l); - return this.curve.point(i, s, o); -}; -Wr.prototype.dbl = function() { - return this.isInfinity() ? this : this.curve.extended ? this._extDbl() : this._projDbl(); -}; -Wr.prototype._extAdd = function(e) { - var r = this.y.redSub(this.x).redMul(e.y.redSub(e.x)), n = this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)), i = this.t.redMul(this.curve.dd).redMul(e.t), s = this.z.redMul(e.z.redAdd(e.z)), o = n.redSub(r), a = s.redSub(i), u = s.redAdd(i), l = n.redAdd(r), d = o.redMul(a), g = u.redMul(l), w = o.redMul(l), A = a.redMul(u); - return this.curve.point(d, g, A, w); -}; -Wr.prototype._projAdd = function(e) { - var r = this.z.redMul(e.z), n = r.redSqr(), i = this.x.redMul(e.x), s = this.y.redMul(e.y), o = this.curve.d.redMul(i).redMul(s), a = n.redSub(o), u = n.redAdd(o), l = this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(i).redISub(s), d = r.redMul(a).redMul(l), g, w; - return this.curve.twisted ? (g = r.redMul(u).redMul(s.redSub(this.curve._mulA(i))), w = a.redMul(u)) : (g = r.redMul(u).redMul(s.redSub(i)), w = this.curve._mulC(a).redMul(u)), this.curve.point(d, g, w); -}; -Wr.prototype.add = function(e) { - return this.isInfinity() ? e : e.isInfinity() ? this : this.curve.extended ? this._extAdd(e) : this._projAdd(e); -}; -Wr.prototype.mul = function(e) { - return this._hasDoubles(e) ? this.curve._fixedNafMul(this, e) : this.curve._wnafMul(this, e); -}; -Wr.prototype.mulAdd = function(e, r, n) { - return this.curve._wnafMulAdd(1, [this, r], [e, n], 2, !1); -}; -Wr.prototype.jmulAdd = function(e, r, n) { - return this.curve._wnafMulAdd(1, [this, r], [e, n], 2, !0); -}; -Wr.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; -}; -Wr.prototype.neg = function() { - return this.curve.point( - this.x.redNeg(), - this.y, - this.z, - this.t && this.t.redNeg() - ); -}; -Wr.prototype.getX = function() { - return this.normalize(), this.x.fromRed(); -}; -Wr.prototype.getY = function() { - return this.normalize(), this.y.fromRed(); -}; -Wr.prototype.eq = function(e) { - return this === e || this.getX().cmp(e.getX()) === 0 && this.getY().cmp(e.getY()) === 0; -}; -Wr.prototype.eqXToP = function(e) { - var r = e.toRed(this.curve.red).redMul(this.z); - if (this.x.cmp(r) === 0) - return !0; - for (var n = e.clone(), i = this.curve.redN.redMul(this.z); ; ) { - if (n.iadd(this.curve.n), n.cmp(this.curve.p) >= 0) - return !1; - if (r.redIAdd(i), this.x.cmp(r) === 0) - return !0; - } -}; -Wr.prototype.toP = Wr.prototype.normalize; -Wr.prototype.mixedAdd = Wr.prototype.add; -(function(t) { - var e = t; - e.base = V0, e.short = Jj, e.mont = Zj, e.edwards = tq; -})(Qv); -var J0 = {}, cm, Cx; -function rq() { - return Cx || (Cx = 1, cm = { - 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" - ] - ] - } - }), cm; -} -(function(t) { - var e = t, r = Kl, n = Qv, i = Fi, s = i.assert; - function o(l) { - l.type === "short" ? this.curve = new n.short(l) : l.type === "edwards" ? this.curve = new n.edwards(l) : this.curve = new n.mont(l), this.g = this.curve.g, this.n = this.curve.n, this.hash = l.hash, s(this.g.validate(), "Invalid curve"), s(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); - } - e.PresetCurve = o; - function a(l, d) { - Object.defineProperty(e, l, { - configurable: !0, - enumerable: !0, - get: function() { - var g = new o(d); - return Object.defineProperty(e, l, { - configurable: !0, - enumerable: !0, - value: g - }), g; - } - }); - } - a("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.sha256, - gRed: !1, - g: [ - "188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", - "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811" - ] - }), a("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.sha256, - gRed: !1, - g: [ - "b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", - "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34" - ] - }), a("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.sha256, - gRed: !1, - g: [ - "6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", - "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5" - ] - }), a("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.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" - ] - }), a("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.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" - ] - }), a("curve25519", { - type: "mont", - prime: "p25519", - p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", - a: "76d06", - b: "1", - n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", - hash: r.sha256, - gRed: !1, - g: [ - "9" - ] - }), a("ed25519", { - type: "edwards", - prime: "p25519", - p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", - a: "-1", - c: "1", - // -121665 * (121666^(-1)) (mod P) - d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", - n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", - hash: r.sha256, - gRed: !1, - g: [ - "216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", - // 4/5 - "6666666666666666666666666666666666666666666666666666666666666658" - ] - }); - var u; - try { - u = rq(); - } catch { - u = void 0; - } - a("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.sha256, - // Precomputed endomorphism - beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", - lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", - basis: [ - { - a: "3086d221a7d46bcde86c90e49284eb15", - b: "-e4437ed6010e88286f547fa90abfe4c3" - }, - { - a: "114ca50f7a8e2f3f657c1108d9d44cfd8", - b: "3086d221a7d46bcde86c90e49284eb15" - } - ], - gRed: !1, - g: [ - "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", - "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", - u - ] - }); -})(J0); -var nq = Kl, sc = Xv, A8 = yc; -function ba(t) { - if (!(this instanceof ba)) - return new ba(t); - this.hash = t.hash, this.predResist = !!t.predResist, this.outLen = this.hash.outSize, this.minEntropy = t.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; - var e = sc.toArray(t.entropy, t.entropyEnc || "hex"), r = sc.toArray(t.nonce, t.nonceEnc || "hex"), n = sc.toArray(t.pers, t.persEnc || "hex"); - A8( - e.length >= this.minEntropy / 8, - "Not enough entropy. Minimum is: " + this.minEntropy + " bits" - ), this._init(e, r, n); -} -var iq = ba; -ba.prototype._init = function(e, r, n) { - var i = e.concat(r).concat(n); - this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); - for (var s = 0; s < this.V.length; s++) - this.K[s] = 0, this.V[s] = 1; - this._update(i), this._reseed = 1, this.reseedInterval = 281474976710656; -}; -ba.prototype._hmac = function() { - return new nq.hmac(this.hash, this.K); -}; -ba.prototype._update = function(e) { - var r = this._hmac().update(this.V).update([0]); - e && (r = r.update(e)), this.K = r.digest(), this.V = this._hmac().update(this.V).digest(), e && (this.K = this._hmac().update(this.V).update([1]).update(e).digest(), this.V = this._hmac().update(this.V).digest()); -}; -ba.prototype.reseed = function(e, r, n, i) { - typeof r != "string" && (i = n, n = r, r = null), e = sc.toArray(e, r), n = sc.toArray(n, i), A8( - e.length >= this.minEntropy / 8, - "Not enough entropy. Minimum is: " + this.minEntropy + " bits" - ), this._update(e.concat(n || [])), this._reseed = 1; -}; -ba.prototype.generate = function(e, r, n, i) { - if (this._reseed > this.reseedInterval) - throw new Error("Reseed is required"); - typeof r != "string" && (i = n, n = r, r = null), n && (n = sc.toArray(n, i || "hex"), this._update(n)); - for (var s = []; s.length < e; ) - this.V = this._hmac().update(this.V).digest(), s = s.concat(this.V); - var o = s.slice(0, e); - return this._update(n), this._reseed++, sc.encode(o, r); -}; -var sq = qo, oq = Fi, P1 = oq.assert; -function Qn(t, e) { - this.ec = t, this.priv = null, this.pub = null, e.priv && this._importPrivate(e.priv, e.privEnc), e.pub && this._importPublic(e.pub, e.pubEnc); -} -var aq = Qn; -Qn.fromPublic = function(e, r, n) { - return r instanceof Qn ? r : new Qn(e, { - pub: r, - pubEnc: n - }); -}; -Qn.fromPrivate = function(e, r, n) { - return r instanceof Qn ? r : new Qn(e, { - priv: r, - privEnc: n - }); -}; -Qn.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" }; -}; -Qn.prototype.getPublic = function(e, r) { - return typeof e == "string" && (r = e, e = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r ? this.pub.encode(r, e) : this.pub; -}; -Qn.prototype.getPrivate = function(e) { - return e === "hex" ? this.priv.toString(16, 2) : this.priv; -}; -Qn.prototype._importPrivate = function(e, r) { - this.priv = new sq(e, r || 16), this.priv = this.priv.umod(this.ec.curve.n); -}; -Qn.prototype._importPublic = function(e, r) { - if (e.x || e.y) { - this.ec.curve.type === "mont" ? P1(e.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && P1(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, r); -}; -Qn.prototype.derive = function(e) { - return e.validate() || P1(e.validate(), "public point not validated"), e.mul(this.priv).getX(); -}; -Qn.prototype.sign = function(e, r, n) { - return this.ec.sign(e, this, r, n); -}; -Qn.prototype.verify = function(e, r, n) { - return this.ec.verify(e, r, this, void 0, n); -}; -Qn.prototype.inspect = function() { - return ""; -}; -var o0 = qo, tb = Fi, cq = tb.assert; -function X0(t, e) { - if (t instanceof X0) - return t; - this._importDER(t, e) || (cq(t.r && t.s, "Signature without r or s"), this.r = new o0(t.r, 16), this.s = new o0(t.s, 16), t.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = t.recoveryParam); -} -var uq = X0; -function fq() { - this.place = 0; -} -function um(t, e) { - var r = t[e.place++]; - if (!(r & 128)) - return r; - var n = r & 15; - if (n === 0 || n > 4 || t[e.place] === 0) - return !1; - for (var i = 0, s = 0, o = e.place; s < n; s++, o++) - i <<= 8, i |= t[o], i >>>= 0; - return i <= 127 ? !1 : (e.place = o, i); -} -function Tx(t) { - for (var e = 0, r = t.length - 1; !t[e] && !(t[e + 1] & 128) && e < r; ) - e++; - return e === 0 ? t : t.slice(e); -} -X0.prototype._importDER = function(e, r) { - e = tb.toArray(e, r); - var n = new fq(); - if (e[n.place++] !== 48) - return !1; - var i = um(e, n); - if (i === !1 || i + n.place !== e.length || e[n.place++] !== 2) - return !1; - var s = um(e, n); - if (s === !1 || e[n.place] & 128) - return !1; - var o = e.slice(n.place, s + n.place); - if (n.place += s, e[n.place++] !== 2) - return !1; - var a = um(e, n); - if (a === !1 || e.length !== a + n.place || e[n.place] & 128) - return !1; - var u = e.slice(n.place, a + n.place); - if (o[0] === 0) - if (o[1] & 128) - o = o.slice(1); - else - return !1; - if (u[0] === 0) - if (u[1] & 128) - u = u.slice(1); - else - return !1; - return this.r = new o0(o), this.s = new o0(u), this.recoveryParam = null, !0; -}; -function fm(t, e) { - if (e < 128) { - t.push(e); - return; - } - var r = 1 + (Math.log(e) / Math.LN2 >>> 3); - for (t.push(r | 128); --r; ) - t.push(e >>> (r << 3) & 255); - t.push(e); -} -X0.prototype.toDER = function(e) { - var r = this.r.toArray(), n = this.s.toArray(); - for (r[0] & 128 && (r = [0].concat(r)), n[0] & 128 && (n = [0].concat(n)), r = Tx(r), n = Tx(n); !n[0] && !(n[1] & 128); ) - n = n.slice(1); - var i = [2]; - fm(i, r.length), i = i.concat(r), i.push(2), fm(i, n.length); - var s = i.concat(n), o = [48]; - return fm(o, s.length), o = o.concat(s), tb.encode(o, e); -}; -var So = qo, P8 = iq, lq = Fi, lm = J0, hq = _8, M8 = lq.assert, rb = aq, Z0 = uq; -function es(t) { - if (!(this instanceof es)) - return new es(t); - typeof t == "string" && (M8( - Object.prototype.hasOwnProperty.call(lm, t), - "Unknown curve " + t - ), t = lm[t]), t instanceof lm.PresetCurve && (t = { curve: t }), this.curve = t.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = t.curve.g, this.g.precompute(t.curve.n.bitLength() + 1), this.hash = t.hash || t.curve.hash; -} -var dq = es; -es.prototype.keyPair = function(e) { - return new rb(this, e); -}; -es.prototype.keyFromPrivate = function(e, r) { - return rb.fromPrivate(this, e, r); -}; -es.prototype.keyFromPublic = function(e, r) { - return rb.fromPublic(this, e, r); -}; -es.prototype.genKeyPair = function(e) { - e || (e = {}); - for (var r = new P8({ - hash: this.hash, - pers: e.pers, - persEnc: e.persEnc || "utf8", - entropy: e.entropy || hq(this.hash.hmacStrength), - entropyEnc: e.entropy && e.entropyEnc || "utf8", - nonce: this.n.toArray() - }), n = this.n.byteLength(), i = this.n.sub(new So(2)); ; ) { - var s = new So(r.generate(n)); - if (!(s.cmp(i) > 0)) - return s.iaddn(1), this.keyFromPrivate(s); - } -}; -es.prototype._truncateToN = function(e, r, n) { - var i; - if (So.isBN(e) || typeof e == "number") - e = new So(e, 16), i = e.byteLength(); - else if (typeof e == "object") - i = e.length, e = new So(e, 16); - else { - var s = e.toString(); - i = s.length + 1 >>> 1, e = new So(s, 16); - } - typeof n != "number" && (n = i * 8); - var o = n - this.n.bitLength(); - return o > 0 && (e = e.ushrn(o)), !r && e.cmp(this.n) >= 0 ? e.sub(this.n) : e; -}; -es.prototype.sign = function(e, r, n, i) { - typeof n == "object" && (i = n, n = null), i || (i = {}), r = this.keyFromPrivate(r, n), e = this._truncateToN(e, !1, i.msgBitLength); - for (var s = this.n.byteLength(), o = r.getPrivate().toArray("be", s), a = e.toArray("be", s), u = new P8({ - hash: this.hash, - entropy: o, - nonce: a, - pers: i.pers, - persEnc: i.persEnc || "utf8" - }), l = this.n.sub(new So(1)), d = 0; ; d++) { - var g = i.k ? i.k(d) : new So(u.generate(this.n.byteLength())); - if (g = this._truncateToN(g, !0), !(g.cmpn(1) <= 0 || g.cmp(l) >= 0)) { - var w = this.g.mul(g); - if (!w.isInfinity()) { - var A = w.getX(), M = A.umod(this.n); - if (M.cmpn(0) !== 0) { - var N = g.invm(this.n).mul(M.mul(r.getPrivate()).iadd(e)); - if (N = N.umod(this.n), N.cmpn(0) !== 0) { - var L = (w.getY().isOdd() ? 1 : 0) | (A.cmp(M) !== 0 ? 2 : 0); - return i.canonical && N.cmp(this.nh) > 0 && (N = this.n.sub(N), L ^= 1), new Z0({ r: M, s: N, recoveryParam: L }); - } - } - } - } - } -}; -es.prototype.verify = function(e, r, n, i, s) { - s || (s = {}), e = this._truncateToN(e, !1, s.msgBitLength), n = this.keyFromPublic(n, i), r = new Z0(r, "hex"); - var o = r.r, a = r.s; - if (o.cmpn(1) < 0 || o.cmp(this.n) >= 0 || a.cmpn(1) < 0 || a.cmp(this.n) >= 0) - return !1; - var u = a.invm(this.n), l = u.mul(e).umod(this.n), d = u.mul(o).umod(this.n), g; - return this.curve._maxwellTrick ? (g = this.g.jmulAdd(l, n.getPublic(), d), g.isInfinity() ? !1 : g.eqXToP(o)) : (g = this.g.mulAdd(l, n.getPublic(), d), g.isInfinity() ? !1 : g.getX().umod(this.n).cmp(o) === 0); -}; -es.prototype.recoverPubKey = function(t, e, r, n) { - M8((3 & r) === r, "The recovery param is more than two bits"), e = new Z0(e, n); - var i = this.n, s = new So(t), o = e.r, a = e.s, u = r & 1, l = r >> 1; - if (o.cmp(this.curve.p.umod(this.curve.n)) >= 0 && l) - throw new Error("Unable to find sencond key candinate"); - l ? o = this.curve.pointFromX(o.add(this.curve.n), u) : o = this.curve.pointFromX(o, u); - var d = e.r.invm(i), g = i.sub(s).mul(d).umod(i), w = a.mul(d).umod(i); - return this.g.mulAdd(g, o, w); -}; -es.prototype.getKeyRecoveryParam = function(t, e, r, n) { - if (e = new Z0(e, n), e.recoveryParam !== null) - return e.recoveryParam; - for (var i = 0; i < 4; i++) { - var s; - try { - s = this.recoverPubKey(t, e, i); - } catch { - continue; - } - if (s.eq(r)) - return i; - } - throw new Error("Unable to find valid recovery factor"); -}; -var Jl = Fi, I8 = Jl.assert, Rx = Jl.parseBytes, Uu = Jl.cachedProperty; -function On(t, e) { - this.eddsa = t, this._secret = Rx(e.secret), t.isPoint(e.pub) ? this._pub = e.pub : this._pubBytes = Rx(e.pub); -} -On.fromPublic = function(e, r) { - return r instanceof On ? r : new On(e, { pub: r }); -}; -On.fromSecret = function(e, r) { - return r instanceof On ? r : new On(e, { secret: r }); -}; -On.prototype.secret = function() { - return this._secret; -}; -Uu(On, "pubBytes", function() { - return this.eddsa.encodePoint(this.pub()); -}); -Uu(On, "pub", function() { - return this._pubBytes ? this.eddsa.decodePoint(this._pubBytes) : this.eddsa.g.mul(this.priv()); -}); -Uu(On, "privBytes", function() { - var e = this.eddsa, r = this.hash(), n = e.encodingLength - 1, i = r.slice(0, e.encodingLength); - return i[0] &= 248, i[n] &= 127, i[n] |= 64, i; -}); -Uu(On, "priv", function() { - return this.eddsa.decodeInt(this.privBytes()); -}); -Uu(On, "hash", function() { - return this.eddsa.hash().update(this.secret()).digest(); -}); -Uu(On, "messagePrefix", function() { - return this.hash().slice(this.eddsa.encodingLength); -}); -On.prototype.sign = function(e) { - return I8(this._secret, "KeyPair can only verify"), this.eddsa.sign(e, this); -}; -On.prototype.verify = function(e, r) { - return this.eddsa.verify(e, r, this); -}; -On.prototype.getSecret = function(e) { - return I8(this._secret, "KeyPair is public only"), Jl.encode(this.secret(), e); -}; -On.prototype.getPublic = function(e) { - return Jl.encode(this.pubBytes(), e); -}; -var pq = On, gq = qo, Q0 = Fi, Dx = Q0.assert, ep = Q0.cachedProperty, mq = Q0.parseBytes; -function xc(t, e) { - this.eddsa = t, typeof e != "object" && (e = mq(e)), Array.isArray(e) && (Dx(e.length === t.encodingLength * 2, "Signature has invalid size"), e = { - R: e.slice(0, t.encodingLength), - S: e.slice(t.encodingLength) - }), Dx(e.R && e.S, "Signature without R or S"), t.isPoint(e.R) && (this._R = e.R), e.S instanceof gq && (this._S = e.S), this._Rencoded = Array.isArray(e.R) ? e.R : e.Rencoded, this._Sencoded = Array.isArray(e.S) ? e.S : e.Sencoded; -} -ep(xc, "S", function() { - return this.eddsa.decodeInt(this.Sencoded()); -}); -ep(xc, "R", function() { - return this.eddsa.decodePoint(this.Rencoded()); -}); -ep(xc, "Rencoded", function() { - return this.eddsa.encodePoint(this.R()); -}); -ep(xc, "Sencoded", function() { - return this.eddsa.encodeInt(this.S()); -}); -xc.prototype.toBytes = function() { - return this.Rencoded().concat(this.Sencoded()); -}; -xc.prototype.toHex = function() { - return Q0.encode(this.toBytes(), "hex").toUpperCase(); -}; -var vq = xc, bq = Kl, yq = J0, Su = Fi, wq = Su.assert, C8 = Su.parseBytes, T8 = pq, Ox = vq; -function _i(t) { - if (wq(t === "ed25519", "only tested with ed25519 so far"), !(this instanceof _i)) - return new _i(t); - t = yq[t].curve, this.curve = t, this.g = t.g, this.g.precompute(t.n.bitLength() + 1), this.pointClass = t.point().constructor, this.encodingLength = Math.ceil(t.n.bitLength() / 8), this.hash = bq.sha512; -} -var xq = _i; -_i.prototype.sign = function(e, r) { - e = C8(e); - var n = this.keyFromSecret(r), i = this.hashInt(n.messagePrefix(), e), s = this.g.mul(i), o = this.encodePoint(s), a = this.hashInt(o, n.pubBytes(), e).mul(n.priv()), u = i.add(a).umod(this.curve.n); - return this.makeSignature({ R: s, S: u, Rencoded: o }); -}; -_i.prototype.verify = function(e, r, n) { - if (e = C8(e), r = this.makeSignature(r), r.S().gte(r.eddsa.curve.n) || r.S().isNeg()) - return !1; - var i = this.keyFromPublic(n), s = this.hashInt(r.Rencoded(), i.pubBytes(), e), o = this.g.mul(r.S()), a = r.R().add(i.pub().mul(s)); - return a.eq(o); -}; -_i.prototype.hashInt = function() { - for (var e = this.hash(), r = 0; r < arguments.length; r++) - e.update(arguments[r]); - return Su.intFromLE(e.digest()).umod(this.curve.n); -}; -_i.prototype.keyFromPublic = function(e) { - return T8.fromPublic(this, e); -}; -_i.prototype.keyFromSecret = function(e) { - return T8.fromSecret(this, e); -}; -_i.prototype.makeSignature = function(e) { - return e instanceof Ox ? e : new Ox(this, e); -}; -_i.prototype.encodePoint = function(e) { - var r = e.getY().toArray("le", this.encodingLength); - return r[this.encodingLength - 1] |= e.getX().isOdd() ? 128 : 0, r; -}; -_i.prototype.decodePoint = function(e) { - e = Su.parseBytes(e); - var r = e.length - 1, n = e.slice(0, r).concat(e[r] & -129), i = (e[r] & 128) !== 0, s = Su.intFromLE(n); - return this.curve.pointFromY(s, i); -}; -_i.prototype.encodeInt = function(e) { - return e.toArray("le", this.encodingLength); -}; -_i.prototype.decodeInt = function(e) { - return Su.intFromLE(e); -}; -_i.prototype.isPoint = function(e) { - return e instanceof this.pointClass; -}; -(function(t) { - var e = t; - e.version = Kj.version, e.utils = Fi, e.rand = _8, e.curve = Qv, e.curves = J0, e.ec = dq, e.eddsa = xq; -})(x8); -const _q = { 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" } }, Eq = ":"; -function lu(t) { - const [e, r] = t.split(Eq); - return { namespace: e, reference: r }; -} -function R8(t, e) { - return t.includes(":") ? [t] : e.chains || []; -} -var Sq = Object.defineProperty, Nx = Object.getOwnPropertySymbols, Aq = Object.prototype.hasOwnProperty, Pq = Object.prototype.propertyIsEnumerable, Lx = (t, e, r) => e in t ? Sq(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, kx = (t, e) => { - for (var r in e || (e = {})) Aq.call(e, r) && Lx(t, r, e[r]); - if (Nx) for (var r of Nx(e)) Pq.call(e, r) && Lx(t, r, e[r]); - return t; -}; -const Mq = "ReactNative", Ri = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, Iq = "js"; -function a0() { - return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; -} -function ju() { - return !Wl() && !!Fv() && navigator.product === Mq; -} -function Xl() { - return !a0() && !!Fv() && !!Wl(); -} -function Zl() { - return ju() ? Ri.reactNative : a0() ? Ri.node : Xl() ? Ri.browser : Ri.unknown; -} -function Cq() { - var t; - try { - return ju() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (t = global.Application) == null ? void 0 : t.applicationId : void 0; - } catch { - return; - } -} -function Tq(t, e) { - let r = wl.parse(t); - return r = kx(kx({}, r), e), t = wl.stringify(r), t; -} -function D8() { - return q4() || { name: "", description: "", url: "", icons: [""] }; -} -function Rq() { - if (Zl() === Ri.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { - const { OS: r, Version: n } = global.Platform; - return [r, n].join("-"); - } - const t = zF(); - if (t === null) return "unknown"; - const e = t.os ? t.os.replace(" ", "").toLowerCase() : "unknown"; - return t.type === "browser" ? [e, t.name, t.version].join("-") : [e, t.version].join("-"); -} -function Dq() { - var t; - const e = Zl(); - return e === Ri.browser ? [e, ((t = j4()) == null ? void 0 : t.host) || "unknown"].join(":") : e; -} -function O8(t, e, r) { - const n = Rq(), i = Dq(); - return [[t, e].join("-"), [Iq, r].join("-"), n, i].join("/"); -} -function Oq({ protocol: t, version: e, relayUrl: r, sdkVersion: n, auth: i, projectId: s, useOnCloseEvent: o, bundleId: a }) { - const u = r.split("?"), l = O8(t, e, n), d = { auth: i, ua: l, projectId: s, useOnCloseEvent: o, origin: a || void 0 }, g = Tq(u[1] || "", d); - return u[0] + "?" + g; -} -function tc(t, e) { - return t.filter((r) => e.includes(r)).length === t.length; -} -function N8(t) { - return Object.fromEntries(t.entries()); -} -function L8(t) { - return new Map(Object.entries(t)); -} -function Va(t = mt.FIVE_MINUTES, e) { - const r = mt.toMiliseconds(t || mt.FIVE_MINUTES); - let n, i, s; - return { resolve: (o) => { - s && n && (clearTimeout(s), n(o)); - }, reject: (o) => { - s && i && (clearTimeout(s), i(o)); - }, done: () => new Promise((o, a) => { - s = setTimeout(() => { - a(new Error(e)); - }, r), n = o, i = a; - }) }; -} -function hu(t, e, r) { - return new Promise(async (n, i) => { - const s = setTimeout(() => i(new Error(r)), e); - try { - const o = await t; - n(o); - } catch (o) { - i(o); - } - clearTimeout(s); - }); -} -function k8(t, e) { - if (typeof e == "string" && e.startsWith(`${t}:`)) return e; - if (t.toLowerCase() === "topic") { - if (typeof e != "string") throw new Error('Value must be "string" for expirer target type: topic'); - return `topic:${e}`; - } else if (t.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: ${t}`); -} -function Nq(t) { - return k8("topic", t); -} -function Lq(t) { - return k8("id", t); -} -function $8(t) { - const [e, r] = t.split(":"), n = { id: void 0, topic: void 0 }; - if (e === "topic" && typeof r == "string") n.topic = r; - else if (e === "id" && Number.isInteger(Number(r))) n.id = Number(r); - else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`); - return n; -} -function En(t, e) { - return mt.fromMiliseconds(Date.now() + mt.toMiliseconds(t)); -} -function aa(t) { - return Date.now() >= mt.toMiliseconds(t); -} -function br(t, e) { - return `${t}${e ? `:${e}` : ""}`; -} -function Md(t = [], e = []) { - return [.../* @__PURE__ */ new Set([...t, ...e])]; -} -async function kq({ id: t, topic: e, wcDeepLink: r }) { - var n; - try { - if (!r) return; - const i = typeof r == "string" ? JSON.parse(r) : r, s = i == null ? void 0 : i.href; - if (typeof s != "string") return; - const o = $q(s, t, e), a = Zl(); - if (a === Ri.browser) { - if (!((n = Wl()) != null && n.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, Bq() ? "_blank" : "_self", "noreferrer noopener"); - } else a === Ri.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(o); - } catch (i) { - console.error(i); - } -} -function $q(t, e, r) { - const n = `requestId=${e}&sessionTopic=${r}`; - t.endsWith("/") && (t = t.slice(0, -1)); - let i = `${t}`; - if (t.startsWith("https://t.me")) { - const s = t.includes("?") ? "&startapp=" : "?startapp="; - i = `${i}${s}${Uq(n, !0)}`; - } else i = `${i}/wc?${n}`; - return i; -} -async function Fq(t, e) { - let r = ""; - try { - if (Xl() && (r = localStorage.getItem(e), r)) return r; - r = await t.getItem(e); - } catch (n) { - console.error(n); - } - return r; -} -function $x(t, e) { - if (!t.includes(e)) return null; - const r = t.split(/([&,?,=])/), n = r.indexOf(e); - return r[n + 2]; -} -function Fx() { - return typeof crypto < "u" && crypto != null && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu, (t) => { - const e = Math.random() * 16 | 0; - return (t === "x" ? e : e & 3 | 8).toString(16); - }); -} -function nb() { - return typeof process < "u" && process.env.IS_VITEST === "true"; -} -function Bq() { - return typeof window < "u" && (!!window.TelegramWebviewProxy || !!window.Telegram || !!window.TelegramWebviewProxyProto); -} -function Uq(t, e = !1) { - const r = Buffer.from(t).toString("base64"); - return e ? r.replace(/[=]/g, "") : r; -} -function F8(t) { - return Buffer.from(t, "base64").toString("utf-8"); -} -const jq = "https://rpc.walletconnect.org/v1"; -async function qq(t, e, r, n, i, s) { - switch (r.t) { - case "eip191": - return zq(t, e, r.s); - case "eip1271": - return await Hq(t, e, r.s, n, i, s); - default: - throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`); - } -} -function zq(t, e, r) { - return bj(V4(e), r).toLowerCase() === t.toLowerCase(); -} -async function Hq(t, e, r, n, i, s) { - const o = lu(n); - if (!o.namespace || !o.reference) throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${n}`); - try { - const a = "0x1626ba7e", u = "0000000000000000000000000000000000000000000000000000000000000040", l = "0000000000000000000000000000000000000000000000000000000000000041", d = r.substring(2), g = V4(e).substring(2), w = a + g + u + l + d, A = await fetch(`${s || jq}/?chainId=${n}&projectId=${i}`, { method: "POST", body: JSON.stringify({ id: Wq(), jsonrpc: "2.0", method: "eth_call", params: [{ to: t, data: w }, "latest"] }) }), { result: M } = await A.json(); - return M ? M.slice(0, a.length).toLowerCase() === a.toLowerCase() : !1; - } catch (a) { - return console.error("isValidEip1271Signature: ", a), !1; - } -} -function Wq() { - return Date.now() + Math.floor(Math.random() * 1e3); -} -var Kq = Object.defineProperty, Vq = Object.defineProperties, Gq = Object.getOwnPropertyDescriptors, Bx = Object.getOwnPropertySymbols, Yq = Object.prototype.hasOwnProperty, Jq = Object.prototype.propertyIsEnumerable, Ux = (t, e, r) => e in t ? Kq(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Xq = (t, e) => { - for (var r in e || (e = {})) Yq.call(e, r) && Ux(t, r, e[r]); - if (Bx) for (var r of Bx(e)) Jq.call(e, r) && Ux(t, r, e[r]); - return t; -}, Zq = (t, e) => Vq(t, Gq(e)); -const Qq = "did:pkh:", ib = (t) => t == null ? void 0 : t.split(":"), ez = (t) => { - const e = t && ib(t); - if (e) return t.includes(Qq) ? e[3] : e[1]; -}, M1 = (t) => { - const e = t && ib(t); - if (e) return e[2] + ":" + e[3]; -}, c0 = (t) => { - const e = t && ib(t); - if (e) return e.pop(); -}; -async function jx(t) { - const { cacao: e, projectId: r } = t, { s: n, p: i } = e, s = B8(i, i.iss), o = c0(i.iss); - return await qq(o, s, n, M1(i.iss), r); -} -const B8 = (t, e) => { - const r = `${t.domain} wants you to sign in with your Ethereum account:`, n = c0(e); - if (!t.aud && !t.uri) throw new Error("Either `aud` or `uri` is required to construct the message"); - let i = t.statement || void 0; - const s = `URI: ${t.aud || t.uri}`, o = `Version: ${t.version}`, a = `Chain ID: ${ez(e)}`, u = `Nonce: ${t.nonce}`, l = `Issued At: ${t.iat}`, d = t.exp ? `Expiration Time: ${t.exp}` : void 0, g = t.nbf ? `Not Before: ${t.nbf}` : void 0, w = t.requestId ? `Request ID: ${t.requestId}` : void 0, A = t.resources ? `Resources:${t.resources.map((N) => ` -- ${N}`).join("")}` : void 0, M = Id(t.resources); - if (M) { - const N = xl(M); - i = uz(i, N); - } - return [r, n, "", i, "", s, o, a, u, l, d, g, w, A].filter((N) => N != null).join(` -`); -}; -function tz(t) { - return Buffer.from(JSON.stringify(t)).toString("base64"); -} -function rz(t) { - return JSON.parse(Buffer.from(t, "base64").toString("utf-8")); -} -function lc(t) { - if (!t) throw new Error("No recap provided, value is undefined"); - if (!t.att) throw new Error("No `att` property found"); - const e = Object.keys(t.att); - if (!(e != null && e.length)) throw new Error("No resources found in `att` property"); - e.forEach((r) => { - const n = t.att[r]; - if (Array.isArray(n)) throw new Error(`Resource must be an object: ${r}`); - if (typeof n != "object") throw new Error(`Resource must be an object: ${r}`); - if (!Object.keys(n).length) throw new Error(`Resource object is empty: ${r}`); - Object.keys(n).forEach((i) => { - const s = n[i]; - if (!Array.isArray(s)) throw new Error(`Ability limits ${i} must be an array of objects, found: ${s}`); - if (!s.length) throw new Error(`Value of ${i} is empty array, must be an array with objects`); - s.forEach((o) => { - if (typeof o != "object") throw new Error(`Ability limits (${i}) must be an array of objects, found: ${o}`); - }); - }); - }); -} -function nz(t, e, r, n = {}) { - return r == null || r.sort((i, s) => i.localeCompare(s)), { att: { [t]: iz(e, r, n) } }; -} -function iz(t, e, r = {}) { - e = e == null ? void 0 : e.sort((i, s) => i.localeCompare(s)); - const n = e.map((i) => ({ [`${t}/${i}`]: [r] })); - return Object.assign({}, ...n); -} -function U8(t) { - return lc(t), `urn:recap:${tz(t).replace(/=/g, "")}`; -} -function xl(t) { - const e = rz(t.replace("urn:recap:", "")); - return lc(e), e; -} -function sz(t, e, r) { - const n = nz(t, e, r); - return U8(n); -} -function oz(t) { - return t && t.includes("urn:recap:"); -} -function az(t, e) { - const r = xl(t), n = xl(e), i = cz(r, n); - return U8(i); -} -function cz(t, e) { - lc(t), lc(e); - const r = Object.keys(t.att).concat(Object.keys(e.att)).sort((i, s) => i.localeCompare(s)), n = { att: {} }; - return r.forEach((i) => { - var s, o; - Object.keys(((s = t.att) == null ? void 0 : s[i]) || {}).concat(Object.keys(((o = e.att) == null ? void 0 : o[i]) || {})).sort((a, u) => a.localeCompare(u)).forEach((a) => { - var u, l; - n.att[i] = Zq(Xq({}, n.att[i]), { [a]: ((u = t.att[i]) == null ? void 0 : u[a]) || ((l = e.att[i]) == null ? void 0 : l[a]) }); - }); - }), n; -} -function uz(t = "", e) { - lc(e); - const r = "I further authorize the stated URI to perform the following actions on my behalf: "; - if (t.includes(r)) return t; - const n = []; - let i = 0; - Object.keys(e.att).forEach((a) => { - const u = Object.keys(e.att[a]).map((g) => ({ ability: g.split("/")[0], action: g.split("/")[1] })); - u.sort((g, w) => g.action.localeCompare(w.action)); - const l = {}; - u.forEach((g) => { - l[g.ability] || (l[g.ability] = []), l[g.ability].push(g.action); - }); - const d = Object.keys(l).map((g) => (i++, `(${i}) '${g}': '${l[g].join("', '")}' for '${a}'.`)); - n.push(d.join(", ").replace(".,", ".")); - }); - const s = n.join(" "), o = `${r}${s}`; - return `${t ? t + " " : ""}${o}`; -} -function qx(t) { - var e; - const r = xl(t); - lc(r); - const n = (e = r.att) == null ? void 0 : e.eip155; - return n ? Object.keys(n).map((i) => i.split("/")[1]) : []; -} -function zx(t) { - const e = xl(t); - lc(e); - const r = []; - return Object.values(e.att).forEach((n) => { - Object.values(n).forEach((i) => { - var s; - (s = i == null ? void 0 : i[0]) != null && s.chains && r.push(i[0].chains); - }); - }), [...new Set(r.flat())]; -} -function Id(t) { - if (!t) return; - const e = t == null ? void 0 : t[t.length - 1]; - return oz(e) ? e : void 0; -} -const j8 = "base10", oi = "base16", la = "base64pad", Sf = "base64url", Ql = "utf8", q8 = 0, Io = 1, eh = 2, fz = 0, Hx = 1, jf = 12, sb = 32; -function lz() { - const t = Yv.generateKeyPair(); - return { privateKey: Dn(t.secretKey, oi), publicKey: Dn(t.publicKey, oi) }; -} -function I1() { - const t = Pa.randomBytes(sb); - return Dn(t, oi); -} -function hz(t, e) { - const r = Yv.sharedKey(Rn(t, oi), Rn(e, oi), !0), n = new Rj(Gl.SHA256, r).expand(sb); - return Dn(n, oi); -} -function Cd(t) { - const e = Gl.hash(Rn(t, oi)); - return Dn(e, oi); -} -function wo(t) { - const e = Gl.hash(Rn(t, Ql)); - return Dn(e, oi); -} -function z8(t) { - return Rn(`${t}`, j8); -} -function hc(t) { - return Number(Dn(t, j8)); -} -function dz(t) { - const e = z8(typeof t.type < "u" ? t.type : q8); - if (hc(e) === Io && typeof t.senderPublicKey > "u") throw new Error("Missing sender public key for type 1 envelope"); - const r = typeof t.senderPublicKey < "u" ? Rn(t.senderPublicKey, oi) : void 0, n = typeof t.iv < "u" ? Rn(t.iv, oi) : Pa.randomBytes(jf), i = new Vv.ChaCha20Poly1305(Rn(t.symKey, oi)).seal(n, Rn(t.message, Ql)); - return H8({ type: e, sealed: i, iv: n, senderPublicKey: r, encoding: t.encoding }); -} -function pz(t, e) { - const r = z8(eh), n = Pa.randomBytes(jf), i = Rn(t, Ql); - return H8({ type: r, sealed: i, iv: n, encoding: e }); -} -function gz(t) { - const e = new Vv.ChaCha20Poly1305(Rn(t.symKey, oi)), { sealed: r, iv: n } = _l({ encoded: t.encoded, encoding: t == null ? void 0 : t.encoding }), i = e.open(n, r); - if (i === null) throw new Error("Failed to decrypt"); - return Dn(i, Ql); -} -function mz(t, e) { - const { sealed: r } = _l({ encoded: t, encoding: e }); - return Dn(r, Ql); -} -function H8(t) { - const { encoding: e = la } = t; - if (hc(t.type) === eh) return Dn(Ed([t.type, t.sealed]), e); - if (hc(t.type) === Io) { - if (typeof t.senderPublicKey > "u") throw new Error("Missing sender public key for type 1 envelope"); - return Dn(Ed([t.type, t.senderPublicKey, t.iv, t.sealed]), e); - } - return Dn(Ed([t.type, t.iv, t.sealed]), e); -} -function _l(t) { - const { encoded: e, encoding: r = la } = t, n = Rn(e, r), i = n.slice(fz, Hx), s = Hx; - if (hc(i) === Io) { - const l = s + sb, d = l + jf, g = n.slice(s, l), w = n.slice(l, d), A = n.slice(d); - return { type: i, sealed: A, iv: w, senderPublicKey: g }; - } - if (hc(i) === eh) { - const l = n.slice(s), d = Pa.randomBytes(jf); - return { type: i, sealed: l, iv: d }; - } - const o = s + jf, a = n.slice(s, o), u = n.slice(o); - return { type: i, sealed: u, iv: a }; -} -function vz(t, e) { - const r = _l({ encoded: t, encoding: e == null ? void 0 : e.encoding }); - return W8({ type: hc(r.type), senderPublicKey: typeof r.senderPublicKey < "u" ? Dn(r.senderPublicKey, oi) : void 0, receiverPublicKey: e == null ? void 0 : e.receiverPublicKey }); -} -function W8(t) { - const e = (t == null ? void 0 : t.type) || q8; - if (e === Io) { - if (typeof (t == null ? void 0 : t.senderPublicKey) > "u") throw new Error("missing sender public key"); - if (typeof (t == null ? void 0 : t.receiverPublicKey) > "u") throw new Error("missing receiver public key"); - } - return { type: e, senderPublicKey: t == null ? void 0 : t.senderPublicKey, receiverPublicKey: t == null ? void 0 : t.receiverPublicKey }; -} -function Wx(t) { - return t.type === Io && typeof t.senderPublicKey == "string" && typeof t.receiverPublicKey == "string"; -} -function Kx(t) { - return t.type === eh; -} -function bz(t) { - return new x8.ec("p256").keyFromPublic({ x: Buffer.from(t.x, "base64").toString("hex"), y: Buffer.from(t.y, "base64").toString("hex") }, "hex"); -} -function yz(t) { - let e = t.replace(/-/g, "+").replace(/_/g, "/"); - const r = e.length % 4; - return r > 0 && (e += "=".repeat(4 - r)), e; -} -function wz(t) { - return Buffer.from(yz(t), "base64"); -} -function xz(t, e) { - const [r, n, i] = t.split("."), s = wz(i); - if (s.length !== 64) throw new Error("Invalid signature length"); - const o = s.slice(0, 32).toString("hex"), a = s.slice(32, 64).toString("hex"), u = `${r}.${n}`, l = new Gl.SHA256().update(Buffer.from(u)).digest(), d = bz(e), g = Buffer.from(l).toString("hex"); - if (!d.verify(g, { r: o, s: a })) throw new Error("Invalid signature"); - return v1(t).payload; -} -const _z = "irn"; -function C1(t) { - return (t == null ? void 0 : t.relay) || { protocol: _z }; -} -function $f(t) { - const e = _q[t]; - if (typeof e > "u") throw new Error(`Relay Protocol not supported: ${t}`); - return e; -} -var Ez = Object.defineProperty, Sz = Object.defineProperties, Az = Object.getOwnPropertyDescriptors, Vx = Object.getOwnPropertySymbols, Pz = Object.prototype.hasOwnProperty, Mz = Object.prototype.propertyIsEnumerable, Gx = (t, e, r) => e in t ? Ez(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Yx = (t, e) => { - for (var r in e || (e = {})) Pz.call(e, r) && Gx(t, r, e[r]); - if (Vx) for (var r of Vx(e)) Mz.call(e, r) && Gx(t, r, e[r]); - return t; -}, Iz = (t, e) => Sz(t, Az(e)); -function Cz(t, e = "-") { - const r = {}, n = "relay" + e; - return Object.keys(t).forEach((i) => { - if (i.startsWith(n)) { - const s = i.replace(n, ""), o = t[i]; - r[s] = o; - } - }), r; -} -function Jx(t) { - if (!t.includes("wc:")) { - const u = F8(t); - u != null && u.includes("wc:") && (t = u); - } - t = t.includes("wc://") ? t.replace("wc://", "") : t, t = t.includes("wc:") ? t.replace("wc:", "") : t; - const e = t.indexOf(":"), r = t.indexOf("?") !== -1 ? t.indexOf("?") : void 0, n = t.substring(0, e), i = t.substring(e + 1, r).split("@"), s = typeof r < "u" ? t.substring(r) : "", o = wl.parse(s), a = typeof o.methods == "string" ? o.methods.split(",") : void 0; - return { protocol: n, topic: Tz(i[0]), version: parseInt(i[1], 10), symKey: o.symKey, relay: Cz(o), methods: a, expiryTimestamp: o.expiryTimestamp ? parseInt(o.expiryTimestamp, 10) : void 0 }; -} -function Tz(t) { - return t.startsWith("//") ? t.substring(2) : t; -} -function Rz(t, e = "-") { - const r = "relay", n = {}; - return Object.keys(t).forEach((i) => { - const s = r + e + i; - t[i] && (n[s] = t[i]); - }), n; -} -function Xx(t) { - return `${t.protocol}:${t.topic}@${t.version}?` + wl.stringify(Yx(Iz(Yx({ symKey: t.symKey }, Rz(t.relay)), { expiryTimestamp: t.expiryTimestamp }), t.methods ? { methods: t.methods.join(",") } : {})); -} -function ud(t, e, r) { - return `${t}?wc_ev=${r}&topic=${e}`; -} -function qu(t) { - const e = []; - return t.forEach((r) => { - const [n, i] = r.split(":"); - e.push(`${n}:${i}`); - }), e; -} -function Dz(t) { - const e = []; - return Object.values(t).forEach((r) => { - e.push(...qu(r.accounts)); - }), e; -} -function Oz(t, e) { - const r = []; - return Object.values(t).forEach((n) => { - qu(n.accounts).includes(e) && r.push(...n.methods); - }), r; -} -function Nz(t, e) { - const r = []; - return Object.values(t).forEach((n) => { - qu(n.accounts).includes(e) && r.push(...n.events); - }), r; -} -function ob(t) { - return t.includes(":"); -} -function Ff(t) { - return ob(t) ? t.split(":")[0] : t; -} -function Lz(t) { - const e = {}; - return t == null || t.forEach((r) => { - const [n, i] = r.split(":"); - e[n] || (e[n] = { accounts: [], chains: [], events: [] }), e[n].accounts.push(r), e[n].chains.push(`${n}:${i}`); - }), e; -} -function Zx(t, e) { - e = e.map((n) => n.replace("did:pkh:", "")); - const r = Lz(e); - for (const [n, i] of Object.entries(r)) i.methods ? i.methods = Md(i.methods, t) : i.methods = t, i.events = ["chainChanged", "accountsChanged"]; - return r; -} -const kz = { 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 } }, $z = { 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 ft(t, e) { - const { message: r, code: n } = $z[t]; - return { message: e ? `${r} ${e}` : r, code: n }; -} -function Or(t, e) { - const { message: r, code: n } = kz[t]; - return { message: e ? `${r} ${e}` : r, code: n }; -} -function dc(t, e) { - return !!Array.isArray(t); -} -function El(t) { - return Object.getPrototypeOf(t) === Object.prototype && Object.keys(t).length; -} -function gi(t) { - return typeof t > "u"; -} -function dn(t, e) { - return e && gi(t) ? !0 : typeof t == "string" && !!t.trim().length; -} -function ab(t, e) { - return typeof t == "number" && !isNaN(t); -} -function Fz(t, e) { - const { requiredNamespaces: r } = e, n = Object.keys(t.namespaces), i = Object.keys(r); - let s = !0; - return tc(i, n) ? (n.forEach((o) => { - const { accounts: a, methods: u, events: l } = t.namespaces[o], d = qu(a), g = r[o]; - (!tc(R8(o, g), d) || !tc(g.methods, u) || !tc(g.events, l)) && (s = !1); - }), s) : !1; -} -function u0(t) { - return dn(t, !1) && t.includes(":") ? t.split(":").length === 2 : !1; -} -function Bz(t) { - if (dn(t, !1) && t.includes(":")) { - const e = t.split(":"); - if (e.length === 3) { - const r = e[0] + ":" + e[1]; - return !!e[2] && u0(r); - } - } - return !1; -} -function Uz(t) { - function e(r) { - try { - return typeof new URL(r) < "u"; - } catch { - return !1; - } - } - try { - if (dn(t, !1)) { - if (e(t)) return !0; - const r = F8(t); - return e(r); - } - } catch { - } - return !1; -} -function jz(t) { - var e; - return (e = t == null ? void 0 : t.proposer) == null ? void 0 : e.publicKey; -} -function qz(t) { - return t == null ? void 0 : t.topic; -} -function zz(t, e) { - let r = null; - return dn(t == null ? void 0 : t.publicKey, !1) || (r = ft("MISSING_OR_INVALID", `${e} controller public key should be a string`)), r; -} -function Qx(t) { - let e = !0; - return dc(t) ? t.length && (e = t.every((r) => dn(r, !1))) : e = !1, e; -} -function Hz(t, e, r) { - let n = null; - return dc(e) && e.length ? e.forEach((i) => { - n || u0(i) || (n = Or("UNSUPPORTED_CHAINS", `${r}, chain ${i} should be a string and conform to "namespace:chainId" format`)); - }) : u0(t) || (n = Or("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"] }`)), n; -} -function Wz(t, e, r) { - let n = null; - return Object.entries(t).forEach(([i, s]) => { - if (n) return; - const o = Hz(i, R8(i, s), `${e} ${r}`); - o && (n = o); - }), n; -} -function Kz(t, e) { - let r = null; - return dc(t) ? t.forEach((n) => { - r || Bz(n) || (r = Or("UNSUPPORTED_ACCOUNTS", `${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`)); - }) : r = Or("UNSUPPORTED_ACCOUNTS", `${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), r; -} -function Vz(t, e) { - let r = null; - return Object.values(t).forEach((n) => { - if (r) return; - const i = Kz(n == null ? void 0 : n.accounts, `${e} namespace`); - i && (r = i); - }), r; -} -function Gz(t, e) { - let r = null; - return Qx(t == null ? void 0 : t.methods) ? Qx(t == null ? void 0 : t.events) || (r = Or("UNSUPPORTED_EVENTS", `${e}, events should be an array of strings or empty array for no events`)) : r = Or("UNSUPPORTED_METHODS", `${e}, methods should be an array of strings or empty array for no methods`), r; -} -function K8(t, e) { - let r = null; - return Object.values(t).forEach((n) => { - if (r) return; - const i = Gz(n, `${e}, namespace`); - i && (r = i); - }), r; -} -function Yz(t, e, r) { - let n = null; - if (t && El(t)) { - const i = K8(t, e); - i && (n = i); - const s = Wz(t, e, r); - s && (n = s); - } else n = ft("MISSING_OR_INVALID", `${e}, ${r} should be an object with data`); - return n; -} -function hm(t, e) { - let r = null; - if (t && El(t)) { - const n = K8(t, e); - n && (r = n); - const i = Vz(t, e); - i && (r = i); - } else r = ft("MISSING_OR_INVALID", `${e}, namespaces should be an object with data`); - return r; -} -function V8(t) { - return dn(t.protocol, !0); -} -function Jz(t, e) { - let r = !1; - return t ? t && dc(t) && t.length && t.forEach((n) => { - r = V8(n); - }) : r = !0, r; -} -function Xz(t) { - return typeof t == "number"; -} -function pi(t) { - return typeof t < "u" && typeof t !== null; -} -function Zz(t) { - return !(!t || typeof t != "object" || !t.code || !ab(t.code) || !t.message || !dn(t.message, !1)); -} -function Qz(t) { - return !(gi(t) || !dn(t.method, !1)); -} -function eH(t) { - return !(gi(t) || gi(t.result) && gi(t.error) || !ab(t.id) || !dn(t.jsonrpc, !1)); -} -function tH(t) { - return !(gi(t) || !dn(t.name, !1)); -} -function e3(t, e) { - return !(!u0(e) || !Dz(t).includes(e)); -} -function rH(t, e, r) { - return dn(r, !1) ? Oz(t, e).includes(r) : !1; -} -function nH(t, e, r) { - return dn(r, !1) ? Nz(t, e).includes(r) : !1; -} -function t3(t, e, r) { - let n = null; - const i = iH(t), s = sH(e), o = Object.keys(i), a = Object.keys(s), u = r3(Object.keys(t)), l = r3(Object.keys(e)), d = u.filter((g) => !l.includes(g)); - return d.length && (n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces keys don't satisfy requiredNamespaces. - Required: ${d.toString()} - Received: ${Object.keys(e).toString()}`)), tc(o, a) || (n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces chains don't satisfy required namespaces. - Required: ${o.toString()} - Approved: ${a.toString()}`)), Object.keys(e).forEach((g) => { - if (!g.includes(":") || n) return; - const w = qu(e[g].accounts); - w.includes(g) || (n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces accounts don't satisfy namespace accounts for ${g} - Required: ${g} - Approved: ${w.toString()}`)); - }), o.forEach((g) => { - n || (tc(i[g].methods, s[g].methods) ? tc(i[g].events, s[g].events) || (n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces events don't satisfy namespace events for ${g}`)) : n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces methods don't satisfy namespace methods for ${g}`)); - }), n; -} -function iH(t) { - const e = {}; - return Object.keys(t).forEach((r) => { - var n; - r.includes(":") ? e[r] = t[r] : (n = t[r].chains) == null || n.forEach((i) => { - e[i] = { methods: t[r].methods, events: t[r].events }; - }); - }), e; -} -function r3(t) { - return [...new Set(t.map((e) => e.includes(":") ? e.split(":")[0] : e))]; -} -function sH(t) { - const e = {}; - return Object.keys(t).forEach((r) => { - if (r.includes(":")) e[r] = t[r]; - else { - const n = qu(t[r].accounts); - n == null || n.forEach((i) => { - e[i] = { accounts: t[r].accounts.filter((s) => s.includes(`${i}:`)), methods: t[r].methods, events: t[r].events }; - }); - } - }), e; -} -function oH(t, e) { - return ab(t) && t <= e.max && t >= e.min; -} -function n3() { - const t = Zl(); - return new Promise((e) => { - switch (t) { - case Ri.browser: - e(aH()); - break; - case Ri.reactNative: - e(cH()); - break; - case Ri.node: - e(uH()); - break; - default: - e(!0); - } - }); -} -function aH() { - return Xl() && (navigator == null ? void 0 : navigator.onLine); -} -async function cH() { - if (ju() && typeof global < "u" && global != null && global.NetInfo) { - const t = await (global == null ? void 0 : global.NetInfo.fetch()); - return t == null ? void 0 : t.isConnected; - } - return !0; -} -function uH() { - return !0; -} -function fH(t) { - switch (Zl()) { - case Ri.browser: - lH(t); - break; - case Ri.reactNative: - hH(t); - break; - } -} -function lH(t) { - !ju() && Xl() && (window.addEventListener("online", () => t(!0)), window.addEventListener("offline", () => t(!1))); -} -function hH(t) { - ju() && typeof global < "u" && global != null && global.NetInfo && (global == null || global.NetInfo.addEventListener((e) => t(e == null ? void 0 : e.isConnected))); -} -const dm = {}; -class Af { - static get(e) { - return dm[e]; - } - static set(e, r) { - dm[e] = r; - } - static delete(e) { - delete dm[e]; - } -} -const dH = "PARSE_ERROR", pH = "INVALID_REQUEST", gH = "METHOD_NOT_FOUND", mH = "INVALID_PARAMS", G8 = "INTERNAL_ERROR", cb = "SERVER_ERROR", vH = [-32700, -32600, -32601, -32602, -32603], qf = { - [dH]: { code: -32700, message: "Parse error" }, - [pH]: { code: -32600, message: "Invalid Request" }, - [gH]: { code: -32601, message: "Method not found" }, - [mH]: { code: -32602, message: "Invalid params" }, - [G8]: { code: -32603, message: "Internal error" }, - [cb]: { code: -32e3, message: "Server error" } -}, Y8 = cb; -function bH(t) { - return vH.includes(t); -} -function i3(t) { - return Object.keys(qf).includes(t) ? qf[t] : qf[Y8]; -} -function yH(t) { - const e = Object.values(qf).find((r) => r.code === t); - return e || qf[Y8]; -} -function J8(t, e, r) { - return t.message.includes("getaddrinfo ENOTFOUND") || t.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${r} RPC url at ${e}`) : t; -} -var X8 = {}, go = {}, s3; -function wH() { - if (s3) return go; - s3 = 1, Object.defineProperty(go, "__esModule", { value: !0 }), go.isBrowserCryptoAvailable = go.getSubtleCrypto = go.getBrowerCrypto = void 0; - function t() { - return (gn == null ? void 0 : gn.crypto) || (gn == null ? void 0 : gn.msCrypto) || {}; - } - go.getBrowerCrypto = t; - function e() { - const n = t(); - return n.subtle || n.webkitSubtle; - } - go.getSubtleCrypto = e; - function r() { - return !!t() && !!e(); - } - return go.isBrowserCryptoAvailable = r, go; -} -var mo = {}, o3; -function xH() { - if (o3) return mo; - o3 = 1, Object.defineProperty(mo, "__esModule", { value: !0 }), mo.isBrowser = mo.isNode = mo.isReactNative = void 0; - function t() { - return typeof document > "u" && typeof navigator < "u" && navigator.product === "ReactNative"; - } - mo.isReactNative = t; - function e() { - return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; - } - mo.isNode = e; - function r() { - return !t() && !e(); - } - return mo.isBrowser = r, mo; -} -(function(t) { - Object.defineProperty(t, "__esModule", { value: !0 }); - const e = Bl; - e.__exportStar(wH(), t), e.__exportStar(xH(), t); -})(X8); -function ca(t = 3) { - const e = Date.now() * Math.pow(10, t), r = Math.floor(Math.random() * Math.pow(10, t)); - return e + r; -} -function rc(t = 6) { - return BigInt(ca(t)); -} -function ha(t, e, r) { - return { - id: r || ca(), - jsonrpc: "2.0", - method: t, - params: e - }; -} -function tp(t, e) { - return { - id: t, - jsonrpc: "2.0", - result: e - }; -} -function rp(t, e, r) { - return { - id: t, - jsonrpc: "2.0", - error: _H(e) - }; -} -function _H(t, e) { - return typeof t > "u" ? i3(G8) : (typeof t == "string" && (t = Object.assign(Object.assign({}, i3(cb)), { message: t })), bH(t.code) && (t = yH(t.code)), t); -} -let EH = class { -}, SH = class extends EH { - constructor() { - super(); - } -}, AH = class extends SH { - constructor(e) { - super(); - } -}; -const PH = "^https?:", MH = "^wss?:"; -function IH(t) { - const e = t.match(new RegExp(/^\w+:/, "gi")); - if (!(!e || !e.length)) - return e[0]; -} -function Z8(t, e) { - const r = IH(t); - return typeof r > "u" ? !1 : new RegExp(e).test(r); -} -function a3(t) { - return Z8(t, PH); -} -function c3(t) { - return Z8(t, MH); -} -function CH(t) { - return new RegExp("wss?://localhost(:d{2,5})?").test(t); -} -function Q8(t) { - return typeof t == "object" && "id" in t && "jsonrpc" in t && t.jsonrpc === "2.0"; -} -function ub(t) { - return Q8(t) && "method" in t; -} -function np(t) { - return Q8(t) && (Bs(t) || Zi(t)); -} -function Bs(t) { - return "result" in t; -} -function Zi(t) { - return "error" in t; -} -let as = class extends AH { - constructor(e) { - super(e), this.events = new rs.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(ha(e.method, e.params || [], e.id || rc().toString()), r); - } - async requestStrict(e, r) { - return new Promise(async (n, i) => { - if (!this.connection.connected) try { - await this.open(); - } catch (s) { - i(s); - } - this.events.on(`${e.id}`, (s) => { - Zi(s) ? i(s.error) : n(s.result); - }); - try { - await this.connection.send(e, r); - } catch (s) { - i(s); - } - }); - } - setConnection(e = this.connection) { - return e; - } - onPayload(e) { - this.events.emit("payload", e), np(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); - } -}; -const TH = () => 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 : require("ws"), RH = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", u3 = (t) => t.split("?")[0], f3 = 10, DH = TH(); -let OH = class { - constructor(e) { - if (this.url = e, this.events = new rs.EventEmitter(), this.registering = !1, !c3(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 = (n) => { - this.onClose(n), e(); - }, this.socket.close(); - }); - } - async send(e) { - typeof this.socket > "u" && (this.socket = await this.register()); - try { - this.socket.send(ko(e)); - } catch (r) { - this.onError(e.id, r); - } - } - register(e = this.url) { - if (!c3(e)) throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`); - if (this.registering) { - const r = this.events.getMaxListeners(); - return (this.events.listenerCount("register_error") >= r || this.events.listenerCount("open") >= r) && this.events.setMaxListeners(r + 1), new Promise((n, i) => { - this.events.once("register_error", (s) => { - this.resetMaxListeners(), i(s); - }), this.events.once("open", () => { - if (this.resetMaxListeners(), typeof this.socket > "u") return i(new Error("WebSocket connection is missing or invalid")); - n(this.socket); - }); - }); - } - return this.url = e, this.registering = !0, new Promise((r, n) => { - const i = new URLSearchParams(e).get("origin"), s = X8.isReactNative() ? { headers: { origin: i } } : { rejectUnauthorized: !CH(e) }, o = new DH(e, [], s); - RH() ? o.onerror = (a) => { - const u = a; - n(this.emitError(u.error)); - } : o.on("error", (a) => { - n(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; - const r = typeof e.data == "string" ? uc(e.data) : e.data; - this.events.emit("payload", r); - } - onError(e, r) { - const n = this.parseError(r), i = n.message || n.toString(), s = rp(e, i); - this.events.emit("payload", s); - } - parseError(e, r = this.url) { - return J8(e, u3(r), "WS"); - } - resetMaxListeners() { - this.events.getMaxListeners() > f3 && this.events.setMaxListeners(f3); - } - emitError(e) { - const r = this.parseError(new Error((e == null ? void 0 : e.message) || `WebSocket connection failed for host: ${u3(this.url)}`)); - return this.events.emit("register_error", r), r; - } -}; -var f0 = { exports: {} }; -f0.exports; -(function(t, e) { - var r = 200, n = "__lodash_hash_undefined__", i = 1, s = 2, o = 9007199254740991, a = "[object Arguments]", u = "[object Array]", l = "[object AsyncFunction]", d = "[object Boolean]", g = "[object Date]", w = "[object Error]", A = "[object Function]", M = "[object GeneratorFunction]", N = "[object Map]", L = "[object Number]", F = "[object Null]", $ = "[object Object]", K = "[object Promise]", H = "[object Proxy]", V = "[object RegExp]", te = "[object Set]", R = "[object String]", W = "[object Symbol]", pe = "[object Undefined]", Ee = "[object WeakMap]", Y = "[object ArrayBuffer]", S = "[object DataView]", m = "[object Float32Array]", f = "[object Float64Array]", p = "[object Int8Array]", b = "[object Int16Array]", x = "[object Int32Array]", _ = "[object Uint8Array]", E = "[object Uint8ClampedArray]", v = "[object Uint16Array]", P = "[object Uint32Array]", I = /[\\^$.*+?()[\]{}|]/g, B = /^\[object .+?Constructor\]$/, ce = /^(?:0|[1-9]\d*)$/, D = {}; - D[m] = D[f] = D[p] = D[b] = D[x] = D[_] = D[E] = D[v] = D[P] = !0, D[a] = D[u] = D[Y] = D[d] = D[S] = D[g] = D[w] = D[A] = D[N] = D[L] = D[$] = D[V] = D[te] = D[R] = D[Ee] = !1; - var oe = typeof gn == "object" && gn && gn.Object === Object && gn, Z = typeof self == "object" && self && self.Object === Object && self, J = oe || Z || Function("return this")(), Q = e && !e.nodeType && e, T = Q && !0 && t && !t.nodeType && t, X = T && T.exports === Q, re = X && oe.process, de = function() { - try { - return re && re.binding && re.binding("util"); - } catch { - } - }(), ie = de && de.isTypedArray; - function ue(ae, ye) { - for (var Ge = -1, Pt = ae == null ? 0 : ae.length, Ur = 0, rr = []; ++Ge < Pt; ) { - var Kr = ae[Ge]; - ye(Kr, Ge, ae) && (rr[Ur++] = Kr); - } - return rr; - } - function ve(ae, ye) { - for (var Ge = -1, Pt = ye.length, Ur = ae.length; ++Ge < Pt; ) - ae[Ur + Ge] = ye[Ge]; - return ae; - } - function Pe(ae, ye) { - for (var Ge = -1, Pt = ae == null ? 0 : ae.length; ++Ge < Pt; ) - if (ye(ae[Ge], Ge, ae)) - return !0; - return !1; - } - function De(ae, ye) { - for (var Ge = -1, Pt = Array(ae); ++Ge < ae; ) - Pt[Ge] = ye(Ge); - return Pt; - } - function Ce(ae) { - return function(ye) { - return ae(ye); - }; - } - function $e(ae, ye) { - return ae.has(ye); - } - function Me(ae, ye) { - return ae == null ? void 0 : ae[ye]; - } - function Ne(ae) { - var ye = -1, Ge = Array(ae.size); - return ae.forEach(function(Pt, Ur) { - Ge[++ye] = [Ur, Pt]; - }), Ge; - } - function Ke(ae, ye) { - return function(Ge) { - return ae(ye(Ge)); - }; - } - function Le(ae) { - var ye = -1, Ge = Array(ae.size); - return ae.forEach(function(Pt) { - Ge[++ye] = Pt; - }), Ge; - } - var qe = Array.prototype, ze = Function.prototype, _e = Object.prototype, Ze = J["__core-js_shared__"], at = ze.toString, ke = _e.hasOwnProperty, Qe = function() { - var ae = /[^.]+$/.exec(Ze && Ze.keys && Ze.keys.IE_PROTO || ""); - return ae ? "Symbol(src)_1." + ae : ""; - }(), tt = _e.toString, Ye = RegExp( - "^" + at.call(ke).replace(I, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" - ), dt = X ? J.Buffer : void 0, lt = J.Symbol, ct = J.Uint8Array, qt = _e.propertyIsEnumerable, Yt = qe.splice, Et = lt ? lt.toStringTag : void 0, Qt = Object.getOwnPropertySymbols, Jt = dt ? dt.isBuffer : void 0, Dt = Ke(Object.keys, Object), kt = yr(J, "DataView"), Ct = yr(J, "Map"), gt = yr(J, "Promise"), Rt = yr(J, "Set"), Nt = yr(J, "WeakMap"), vt = yr(Object, "create"), $t = no(kt), Bt = no(Ct), rt = no(gt), Ft = no(Rt), k = no(Nt), j = lt ? lt.prototype : void 0, z = j ? j.valueOf : void 0; - function C(ae) { - var ye = -1, Ge = ae == null ? 0 : ae.length; - for (this.clear(); ++ye < Ge; ) { - var Pt = ae[ye]; - this.set(Pt[0], Pt[1]); - } - } - function G() { - this.__data__ = vt ? vt(null) : {}, this.size = 0; - } - function U(ae) { - var ye = this.has(ae) && delete this.__data__[ae]; - return this.size -= ye ? 1 : 0, ye; - } - function se(ae) { - var ye = this.__data__; - if (vt) { - var Ge = ye[ae]; - return Ge === n ? void 0 : Ge; - } - return ke.call(ye, ae) ? ye[ae] : void 0; - } - function he(ae) { - var ye = this.__data__; - return vt ? ye[ae] !== void 0 : ke.call(ye, ae); - } - function xe(ae, ye) { - var Ge = this.__data__; - return this.size += this.has(ae) ? 0 : 1, Ge[ae] = vt && ye === void 0 ? n : ye, this; - } - C.prototype.clear = G, C.prototype.delete = U, C.prototype.get = se, C.prototype.has = he, C.prototype.set = xe; - function Te(ae) { - var ye = -1, Ge = ae == null ? 0 : ae.length; - for (this.clear(); ++ye < Ge; ) { - var Pt = ae[ye]; - this.set(Pt[0], Pt[1]); - } - } - function Re() { - this.__data__ = [], this.size = 0; - } - function nt(ae) { - var ye = this.__data__, Ge = Je(ye, ae); - if (Ge < 0) - return !1; - var Pt = ye.length - 1; - return Ge == Pt ? ye.pop() : Yt.call(ye, Ge, 1), --this.size, !0; - } - function Ue(ae) { - var ye = this.__data__, Ge = Je(ye, ae); - return Ge < 0 ? void 0 : ye[Ge][1]; - } - function pt(ae) { - return Je(this.__data__, ae) > -1; - } - function it(ae, ye) { - var Ge = this.__data__, Pt = Je(Ge, ae); - return Pt < 0 ? (++this.size, Ge.push([ae, ye])) : Ge[Pt][1] = ye, this; - } - Te.prototype.clear = Re, Te.prototype.delete = nt, Te.prototype.get = Ue, Te.prototype.has = pt, Te.prototype.set = it; - function et(ae) { - var ye = -1, Ge = ae == null ? 0 : ae.length; - for (this.clear(); ++ye < Ge; ) { - var Pt = ae[ye]; - this.set(Pt[0], Pt[1]); - } - } - function St() { - this.size = 0, this.__data__ = { - hash: new C(), - map: new (Ct || Te)(), - string: new C() - }; - } - function Tt(ae) { - var ye = mr(this, ae).delete(ae); - return this.size -= ye ? 1 : 0, ye; - } - function At(ae) { - return mr(this, ae).get(ae); - } - function _t(ae) { - return mr(this, ae).has(ae); - } - function ht(ae, ye) { - var Ge = mr(this, ae), Pt = Ge.size; - return Ge.set(ae, ye), this.size += Ge.size == Pt ? 0 : 1, this; - } - et.prototype.clear = St, et.prototype.delete = Tt, et.prototype.get = At, et.prototype.has = _t, et.prototype.set = ht; - function xt(ae) { - var ye = -1, Ge = ae == null ? 0 : ae.length; - for (this.__data__ = new et(); ++ye < Ge; ) - this.add(ae[ye]); - } - function st(ae) { - return this.__data__.set(ae, n), this; - } - function bt(ae) { - return this.__data__.has(ae); - } - xt.prototype.add = xt.prototype.push = st, xt.prototype.has = bt; - function ut(ae) { - var ye = this.__data__ = new Te(ae); - this.size = ye.size; - } - function ot() { - this.__data__ = new Te(), this.size = 0; - } - function Se(ae) { - var ye = this.__data__, Ge = ye.delete(ae); - return this.size = ye.size, Ge; - } - function Ae(ae) { - return this.__data__.get(ae); - } - function Ve(ae) { - return this.__data__.has(ae); - } - function Be(ae, ye) { - var Ge = this.__data__; - if (Ge instanceof Te) { - var Pt = Ge.__data__; - if (!Ct || Pt.length < r - 1) - return Pt.push([ae, ye]), this.size = ++Ge.size, this; - Ge = this.__data__ = new et(Pt); - } - return Ge.set(ae, ye), this.size = Ge.size, this; - } - ut.prototype.clear = ot, ut.prototype.delete = Se, ut.prototype.get = Ae, ut.prototype.has = Ve, ut.prototype.set = Be; - function je(ae, ye) { - var Ge = Pc(ae), Pt = !Ge && hh(ae), Ur = !Ge && !Pt && Ju(ae), rr = !Ge && !Pt && !Ur && gh(ae), Kr = Ge || Pt || Ur || rr, vn = Kr ? De(ae.length, String) : [], _r = vn.length; - for (var jr in ae) - ke.call(ae, jr) && !(Kr && // Safari 9 has enumerable `arguments.length` in strict mode. - (jr == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. - Ur && (jr == "offset" || jr == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. - rr && (jr == "buffer" || jr == "byteLength" || jr == "byteOffset") || // Skip index properties. - nn(jr, _r))) && vn.push(jr); - return vn; - } - function Je(ae, ye) { - for (var Ge = ae.length; Ge--; ) - if (lh(ae[Ge][0], ye)) - return Ge; - return -1; - } - function Lt(ae, ye, Ge) { - var Pt = ye(ae); - return Pc(ae) ? Pt : ve(Pt, Ge(ae)); - } - function zt(ae) { - return ae == null ? ae === void 0 ? pe : F : Et && Et in Object(ae) ? $r(ae) : Rp(ae); - } - function Xt(ae) { - return Ra(ae) && zt(ae) == a; - } - function Ht(ae, ye, Ge, Pt, Ur) { - return ae === ye ? !0 : ae == null || ye == null || !Ra(ae) && !Ra(ye) ? ae !== ae && ye !== ye : le(ae, ye, Ge, Pt, Ht, Ur); - } - function le(ae, ye, Ge, Pt, Ur, rr) { - var Kr = Pc(ae), vn = Pc(ye), _r = Kr ? u : Ir(ae), jr = vn ? u : Ir(ye); - _r = _r == a ? $ : _r, jr = jr == a ? $ : jr; - var an = _r == $, ci = jr == $, bn = _r == jr; - if (bn && Ju(ae)) { - if (!Ju(ye)) - return !1; - Kr = !0, an = !1; - } - if (bn && !an) - return rr || (rr = new ut()), Kr || gh(ae) ? Zt(ae, ye, Ge, Pt, Ur, rr) : gr(ae, ye, _r, Ge, Pt, Ur, rr); - if (!(Ge & i)) { - var Vr = an && ke.call(ae, "__wrapped__"), ei = ci && ke.call(ye, "__wrapped__"); - if (Vr || ei) { - var us = Vr ? ae.value() : ae, Bi = ei ? ye.value() : ye; - return rr || (rr = new ut()), Ur(us, Bi, Ge, Pt, rr); - } - } - return bn ? (rr || (rr = new ut()), lr(ae, ye, Ge, Pt, Ur, rr)) : !1; - } - function tr(ae) { - if (!ph(ae) || on(ae)) - return !1; - var ye = Mc(ae) ? Ye : B; - return ye.test(no(ae)); - } - function dr(ae) { - return Ra(ae) && dh(ae.length) && !!D[zt(ae)]; - } - function pr(ae) { - if (!fh(ae)) - return Dt(ae); - var ye = []; - for (var Ge in Object(ae)) - ke.call(ae, Ge) && Ge != "constructor" && ye.push(Ge); - return ye; - } - function Zt(ae, ye, Ge, Pt, Ur, rr) { - var Kr = Ge & i, vn = ae.length, _r = ye.length; - if (vn != _r && !(Kr && _r > vn)) - return !1; - var jr = rr.get(ae); - if (jr && rr.get(ye)) - return jr == ye; - var an = -1, ci = !0, bn = Ge & s ? new xt() : void 0; - for (rr.set(ae, ye), rr.set(ye, ae); ++an < vn; ) { - var Vr = ae[an], ei = ye[an]; - if (Pt) - var us = Kr ? Pt(ei, Vr, an, ye, ae, rr) : Pt(Vr, ei, an, ae, ye, rr); - if (us !== void 0) { - if (us) - continue; - ci = !1; - break; - } - if (bn) { - if (!Pe(ye, function(Bi, Ms) { - if (!$e(bn, Ms) && (Vr === Bi || Ur(Vr, Bi, Ge, Pt, rr))) - return bn.push(Ms); - })) { - ci = !1; - break; - } - } else if (!(Vr === ei || Ur(Vr, ei, Ge, Pt, rr))) { - ci = !1; - break; - } - } - return rr.delete(ae), rr.delete(ye), ci; - } - function gr(ae, ye, Ge, Pt, Ur, rr, Kr) { - switch (Ge) { - case S: - if (ae.byteLength != ye.byteLength || ae.byteOffset != ye.byteOffset) - return !1; - ae = ae.buffer, ye = ye.buffer; - case Y: - return !(ae.byteLength != ye.byteLength || !rr(new ct(ae), new ct(ye))); - case d: - case g: - case L: - return lh(+ae, +ye); - case w: - return ae.name == ye.name && ae.message == ye.message; - case V: - case R: - return ae == ye + ""; - case N: - var vn = Ne; - case te: - var _r = Pt & i; - if (vn || (vn = Le), ae.size != ye.size && !_r) - return !1; - var jr = Kr.get(ae); - if (jr) - return jr == ye; - Pt |= s, Kr.set(ae, ye); - var an = Zt(vn(ae), vn(ye), Pt, Ur, rr, Kr); - return Kr.delete(ae), an; - case W: - if (z) - return z.call(ae) == z.call(ye); - } - return !1; - } - function lr(ae, ye, Ge, Pt, Ur, rr) { - var Kr = Ge & i, vn = Rr(ae), _r = vn.length, jr = Rr(ye), an = jr.length; - if (_r != an && !Kr) - return !1; - for (var ci = _r; ci--; ) { - var bn = vn[ci]; - if (!(Kr ? bn in ye : ke.call(ye, bn))) - return !1; - } - var Vr = rr.get(ae); - if (Vr && rr.get(ye)) - return Vr == ye; - var ei = !0; - rr.set(ae, ye), rr.set(ye, ae); - for (var us = Kr; ++ci < _r; ) { - bn = vn[ci]; - var Bi = ae[bn], Ms = ye[bn]; - if (Pt) - var Xu = Kr ? Pt(Ms, Bi, bn, ye, ae, rr) : Pt(Bi, Ms, bn, ae, ye, rr); - if (!(Xu === void 0 ? Bi === Ms || Ur(Bi, Ms, Ge, Pt, rr) : Xu)) { - ei = !1; - break; - } - us || (us = bn == "constructor"); - } - if (ei && !us) { - var Da = ae.constructor, Pn = ye.constructor; - Da != Pn && "constructor" in ae && "constructor" in ye && !(typeof Da == "function" && Da instanceof Da && typeof Pn == "function" && Pn instanceof Pn) && (ei = !1); - } - return rr.delete(ae), rr.delete(ye), ei; - } - function Rr(ae) { - return Lt(ae, Np, Fr); - } - function mr(ae, ye) { - var Ge = ae.__data__; - return sn(ye) ? Ge[typeof ye == "string" ? "string" : "hash"] : Ge.map; - } - function yr(ae, ye) { - var Ge = Me(ae, ye); - return tr(Ge) ? Ge : void 0; - } - function $r(ae) { - var ye = ke.call(ae, Et), Ge = ae[Et]; - try { - ae[Et] = void 0; - var Pt = !0; - } catch { - } - var Ur = tt.call(ae); - return Pt && (ye ? ae[Et] = Ge : delete ae[Et]), Ur; - } - var Fr = Qt ? function(ae) { - return ae == null ? [] : (ae = Object(ae), ue(Qt(ae), function(ye) { - return qt.call(ae, ye); - })); - } : Br, Ir = zt; - (kt && Ir(new kt(new ArrayBuffer(1))) != S || Ct && Ir(new Ct()) != N || gt && Ir(gt.resolve()) != K || Rt && Ir(new Rt()) != te || Nt && Ir(new Nt()) != Ee) && (Ir = function(ae) { - var ye = zt(ae), Ge = ye == $ ? ae.constructor : void 0, Pt = Ge ? no(Ge) : ""; - if (Pt) - switch (Pt) { - case $t: - return S; - case Bt: - return N; - case rt: - return K; - case Ft: - return te; - case k: - return Ee; - } - return ye; - }); - function nn(ae, ye) { - return ye = ye ?? o, !!ye && (typeof ae == "number" || ce.test(ae)) && ae > -1 && ae % 1 == 0 && ae < ye; - } - function sn(ae) { - var ye = typeof ae; - return ye == "string" || ye == "number" || ye == "symbol" || ye == "boolean" ? ae !== "__proto__" : ae === null; - } - function on(ae) { - return !!Qe && Qe in ae; - } - function fh(ae) { - var ye = ae && ae.constructor, Ge = typeof ye == "function" && ye.prototype || _e; - return ae === Ge; - } - function Rp(ae) { - return tt.call(ae); - } - function no(ae) { - if (ae != null) { - try { - return at.call(ae); - } catch { - } - try { - return ae + ""; - } catch { - } - } - return ""; - } - function lh(ae, ye) { - return ae === ye || ae !== ae && ye !== ye; - } - var hh = Xt(/* @__PURE__ */ function() { - return arguments; - }()) ? Xt : function(ae) { - return Ra(ae) && ke.call(ae, "callee") && !qt.call(ae, "callee"); - }, Pc = Array.isArray; - function Dp(ae) { - return ae != null && dh(ae.length) && !Mc(ae); - } - var Ju = Jt || Dr; - function Op(ae, ye) { - return Ht(ae, ye); - } - function Mc(ae) { - if (!ph(ae)) - return !1; - var ye = zt(ae); - return ye == A || ye == M || ye == l || ye == H; - } - function dh(ae) { - return typeof ae == "number" && ae > -1 && ae % 1 == 0 && ae <= o; - } - function ph(ae) { - var ye = typeof ae; - return ae != null && (ye == "object" || ye == "function"); - } - function Ra(ae) { - return ae != null && typeof ae == "object"; - } - var gh = ie ? Ce(ie) : dr; - function Np(ae) { - return Dp(ae) ? je(ae) : pr(ae); - } - function Br() { - return []; - } - function Dr() { - return !1; - } - t.exports = Op; -})(f0, f0.exports); -var NH = f0.exports; -const LH = /* @__PURE__ */ ts(NH), eE = "wc", tE = 2, rE = "core", Zs = `${eE}@2:${rE}:`, kH = { logger: "error" }, $H = { database: ":memory:" }, FH = "crypto", l3 = "client_ed25519_seed", BH = mt.ONE_DAY, UH = "keychain", jH = "0.3", qH = "messages", zH = "0.3", HH = mt.SIX_HOURS, WH = "publisher", nE = "irn", KH = "error", iE = "wss://relay.walletconnect.org", VH = "relayer", si = { message: "relayer_message", message_ack: "relayer_message_ack", connect: "relayer_connect", disconnect: "relayer_disconnect", error: "relayer_error", connection_stalled: "relayer_connection_stalled", publish: "relayer_publish" }, GH = "_subscription", Vi = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, YH = 0.1, T1 = "2.17.2", zr = { link_mode: "link_mode", relay: "relay" }, JH = "0.3", XH = "WALLETCONNECT_CLIENT_ID", h3 = "WALLETCONNECT_LINK_MODE_APPS", Us = { created: "subscription_created", deleted: "subscription_deleted", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, ZH = "subscription", QH = "0.3", eW = mt.FIVE_SECONDS * 1e3, tW = "pairing", rW = "0.3", Pf = { wc_pairingDelete: { req: { ttl: mt.ONE_DAY, prompt: !1, tag: 1e3 }, res: { ttl: mt.ONE_DAY, prompt: !1, tag: 1001 } }, wc_pairingPing: { req: { ttl: mt.THIRTY_SECONDS, prompt: !1, tag: 1002 }, res: { ttl: mt.THIRTY_SECONDS, prompt: !1, tag: 1003 } }, unregistered_method: { req: { ttl: mt.ONE_DAY, prompt: !1, tag: 0 }, res: { ttl: mt.ONE_DAY, prompt: !1, tag: 0 } } }, Xa = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, gs = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, nW = "history", iW = "0.3", sW = "expirer", Ji = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, oW = "0.3", aW = "verify-api", cW = "https://verify.walletconnect.com", sE = "https://verify.walletconnect.org", zf = sE, uW = `${zf}/v3`, fW = [cW, sE], lW = "echo", hW = "https://echo.walletconnect.com", Fs = { 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" }, yo = { 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_listener_not_found: "proposal_listener_not_found" }, ms = { session_approve_started: "session_approve_started", session_namespaces_validation_success: "session_namespaces_validation_success", 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" }, Ha = { no_internet_connection: "no_internet_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" }, Wa = { authenticated_session_approve_started: "authenticated_session_approve_started", 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" }, Mf = { no_internet_connection: "no_internet_connection", 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" }, dW = 0.1, pW = "event-client", gW = 86400, mW = "https://pulse.walletconnect.org/batch"; -function vW(t, e) { - if (t.length >= 255) throw new TypeError("Alphabet too long"); - for (var r = new Uint8Array(256), n = 0; n < r.length; n++) r[n] = 255; - for (var i = 0; i < t.length; i++) { - var s = t.charAt(i), o = s.charCodeAt(0); - if (r[o] !== 255) throw new TypeError(s + " is ambiguous"); - r[o] = i; - } - var a = t.length, u = t.charAt(0), l = Math.log(a) / Math.log(256), d = Math.log(256) / Math.log(a); - function g(M) { - if (M instanceof Uint8Array || (ArrayBuffer.isView(M) ? M = new Uint8Array(M.buffer, M.byteOffset, M.byteLength) : Array.isArray(M) && (M = Uint8Array.from(M))), !(M instanceof Uint8Array)) throw new TypeError("Expected Uint8Array"); - if (M.length === 0) return ""; - for (var N = 0, L = 0, F = 0, $ = M.length; F !== $ && M[F] === 0; ) F++, N++; - for (var K = ($ - F) * d + 1 >>> 0, H = new Uint8Array(K); F !== $; ) { - for (var V = M[F], te = 0, R = K - 1; (V !== 0 || te < L) && R !== -1; R--, te++) V += 256 * H[R] >>> 0, H[R] = V % a >>> 0, V = V / a >>> 0; - if (V !== 0) throw new Error("Non-zero carry"); - L = te, F++; - } - for (var W = K - L; W !== K && H[W] === 0; ) W++; - for (var pe = u.repeat(N); W < K; ++W) pe += t.charAt(H[W]); - return pe; - } - function w(M) { - if (typeof M != "string") throw new TypeError("Expected String"); - if (M.length === 0) return new Uint8Array(); - var N = 0; - if (M[N] !== " ") { - for (var L = 0, F = 0; M[N] === u; ) L++, N++; - for (var $ = (M.length - N) * l + 1 >>> 0, K = new Uint8Array($); M[N]; ) { - var H = r[M.charCodeAt(N)]; - if (H === 255) return; - for (var V = 0, te = $ - 1; (H !== 0 || V < F) && te !== -1; te--, V++) H += a * K[te] >>> 0, K[te] = H % 256 >>> 0, H = H / 256 >>> 0; - if (H !== 0) throw new Error("Non-zero carry"); - F = V, N++; - } - if (M[N] !== " ") { - for (var R = $ - F; R !== $ && K[R] === 0; ) R++; - for (var W = new Uint8Array(L + ($ - R)), pe = L; R !== $; ) W[pe++] = K[R++]; - return W; - } - } - } - function A(M) { - var N = w(M); - if (N) return N; - throw new Error(`Non-${e} character`); - } - return { encode: g, decodeUnsafe: w, decode: A }; -} -var bW = vW, yW = bW; -const oE = (t) => { - if (t instanceof Uint8Array && t.constructor.name === "Uint8Array") return t; - if (t instanceof ArrayBuffer) return new Uint8Array(t); - if (ArrayBuffer.isView(t)) return new Uint8Array(t.buffer, t.byteOffset, t.byteLength); - throw new Error("Unknown type, must be binary type"); -}, wW = (t) => new TextEncoder().encode(t), xW = (t) => new TextDecoder().decode(t); -class _W { - constructor(e, r, n) { - this.name = e, this.prefix = r, this.baseEncode = n; - } - encode(e) { - if (e instanceof Uint8Array) return `${this.prefix}${this.baseEncode(e)}`; - throw Error("Unknown type, must be binary type"); - } -} -class EW { - constructor(e, r, n) { - 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 = n; - } - 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 aE(this, e); - } -} -class SW { - constructor(e) { - this.decoders = e; - } - or(e) { - return aE(this, e); - } - decode(e) { - const r = e[0], n = this.decoders[r]; - if (n) return n.decode(e); - throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); - } -} -const aE = (t, e) => new SW({ ...t.decoders || { [t.prefix]: t }, ...e.decoders || { [e.prefix]: e } }); -class AW { - constructor(e, r, n, i) { - this.name = e, this.prefix = r, this.baseEncode = n, this.baseDecode = i, this.encoder = new _W(e, r, n), this.decoder = new EW(e, r, i); - } - encode(e) { - return this.encoder.encode(e); - } - decode(e) { - return this.decoder.decode(e); - } -} -const ip = ({ name: t, prefix: e, encode: r, decode: n }) => new AW(t, e, r, n), th = ({ prefix: t, name: e, alphabet: r }) => { - const { encode: n, decode: i } = yW(r, e); - return ip({ prefix: t, name: e, encode: n, decode: (s) => oE(i(s)) }); -}, PW = (t, e, r, n) => { - const i = {}; - for (let d = 0; d < e.length; ++d) i[e[d]] = d; - let s = t.length; - for (; t[s - 1] === "="; ) --s; - const o = new Uint8Array(s * r / 8 | 0); - let a = 0, u = 0, l = 0; - for (let d = 0; d < s; ++d) { - const g = i[t[d]]; - if (g === void 0) throw new SyntaxError(`Non-${n} character`); - u = u << r | g, a += r, a >= 8 && (a -= 8, o[l++] = 255 & u >> a); - } - if (a >= r || 255 & u << 8 - a) throw new SyntaxError("Unexpected end of data"); - return o; -}, MW = (t, e, r) => { - const n = e[e.length - 1] === "=", i = (1 << r) - 1; - let s = "", o = 0, a = 0; - for (let u = 0; u < t.length; ++u) for (a = a << 8 | t[u], o += 8; o > r; ) o -= r, s += e[i & a >> o]; - if (o && (s += e[i & a << r - o]), n) for (; s.length * r & 7; ) s += "="; - return s; -}, Hn = ({ name: t, prefix: e, bitsPerChar: r, alphabet: n }) => ip({ prefix: e, name: t, encode(i) { - return MW(i, n, r); -}, decode(i) { - return PW(i, n, r, t); -} }), IW = ip({ prefix: "\0", name: "identity", encode: (t) => xW(t), decode: (t) => wW(t) }); -var CW = Object.freeze({ __proto__: null, identity: IW }); -const TW = Hn({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); -var RW = Object.freeze({ __proto__: null, base2: TW }); -const DW = Hn({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); -var OW = Object.freeze({ __proto__: null, base8: DW }); -const NW = th({ prefix: "9", name: "base10", alphabet: "0123456789" }); -var LW = Object.freeze({ __proto__: null, base10: NW }); -const kW = Hn({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), $W = Hn({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); -var FW = Object.freeze({ __proto__: null, base16: kW, base16upper: $W }); -const BW = Hn({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), UW = Hn({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), jW = Hn({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), qW = Hn({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), zW = Hn({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), HW = Hn({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), WW = Hn({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), KW = Hn({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), VW = Hn({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); -var GW = Object.freeze({ __proto__: null, base32: BW, base32upper: UW, base32pad: jW, base32padupper: qW, base32hex: zW, base32hexupper: HW, base32hexpad: WW, base32hexpadupper: KW, base32z: VW }); -const YW = th({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), JW = th({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); -var XW = Object.freeze({ __proto__: null, base36: YW, base36upper: JW }); -const ZW = th({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), QW = th({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); -var eK = Object.freeze({ __proto__: null, base58btc: ZW, base58flickr: QW }); -const tK = Hn({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), rK = Hn({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), nK = Hn({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), iK = Hn({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); -var sK = Object.freeze({ __proto__: null, base64: tK, base64pad: rK, base64url: nK, base64urlpad: iK }); -const cE = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), oK = cE.reduce((t, e, r) => (t[r] = e, t), []), aK = cE.reduce((t, e, r) => (t[e.codePointAt(0)] = r, t), []); -function cK(t) { - return t.reduce((e, r) => (e += oK[r], e), ""); -} -function uK(t) { - const e = []; - for (const r of t) { - const n = aK[r.codePointAt(0)]; - if (n === void 0) throw new Error(`Non-base256emoji character: ${r}`); - e.push(n); - } - return new Uint8Array(e); -} -const fK = ip({ prefix: "🚀", name: "base256emoji", encode: cK, decode: uK }); -var lK = Object.freeze({ __proto__: null, base256emoji: fK }), hK = uE, d3 = 128, dK = 127, pK = ~dK, gK = Math.pow(2, 31); -function uE(t, e, r) { - e = e || [], r = r || 0; - for (var n = r; t >= gK; ) e[r++] = t & 255 | d3, t /= 128; - for (; t & pK; ) e[r++] = t & 255 | d3, t >>>= 7; - return e[r] = t | 0, uE.bytes = r - n + 1, e; -} -var mK = R1, vK = 128, p3 = 127; -function R1(t, n) { - var r = 0, n = n || 0, i = 0, s = n, o, a = t.length; - do { - if (s >= a) throw R1.bytes = 0, new RangeError("Could not decode varint"); - o = t[s++], r += i < 28 ? (o & p3) << i : (o & p3) * Math.pow(2, i), i += 7; - } while (o >= vK); - return R1.bytes = s - n, r; -} -var bK = Math.pow(2, 7), yK = Math.pow(2, 14), wK = Math.pow(2, 21), xK = Math.pow(2, 28), _K = Math.pow(2, 35), EK = Math.pow(2, 42), SK = Math.pow(2, 49), AK = Math.pow(2, 56), PK = Math.pow(2, 63), MK = function(t) { - return t < bK ? 1 : t < yK ? 2 : t < wK ? 3 : t < xK ? 4 : t < _K ? 5 : t < EK ? 6 : t < SK ? 7 : t < AK ? 8 : t < PK ? 9 : 10; -}, IK = { encode: hK, decode: mK, encodingLength: MK }, fE = IK; -const g3 = (t, e, r = 0) => (fE.encode(t, e, r), e), m3 = (t) => fE.encodingLength(t), D1 = (t, e) => { - const r = e.byteLength, n = m3(t), i = n + m3(r), s = new Uint8Array(i + r); - return g3(t, s, 0), g3(r, s, n), s.set(e, i), new CK(t, r, e, s); -}; -class CK { - constructor(e, r, n, i) { - this.code = e, this.size = r, this.digest = n, this.bytes = i; - } -} -const lE = ({ name: t, code: e, encode: r }) => new TK(t, e, r); -class TK { - constructor(e, r, n) { - this.name = e, this.code = r, this.encode = n; - } - digest(e) { - if (e instanceof Uint8Array) { - const r = this.encode(e); - return r instanceof Uint8Array ? D1(this.code, r) : r.then((n) => D1(this.code, n)); - } else throw Error("Unknown type, must be binary type"); - } -} -const hE = (t) => async (e) => new Uint8Array(await crypto.subtle.digest(t, e)), RK = lE({ name: "sha2-256", code: 18, encode: hE("SHA-256") }), DK = lE({ name: "sha2-512", code: 19, encode: hE("SHA-512") }); -var OK = Object.freeze({ __proto__: null, sha256: RK, sha512: DK }); -const dE = 0, NK = "identity", pE = oE, LK = (t) => D1(dE, pE(t)), kK = { code: dE, name: NK, encode: pE, digest: LK }; -var $K = Object.freeze({ __proto__: null, identity: kK }); -new TextEncoder(), new TextDecoder(); -const v3 = { ...CW, ...RW, ...OW, ...LW, ...FW, ...GW, ...XW, ...eK, ...sK, ...lK }; -({ ...OK, ...$K }); -function FK(t = 0) { - return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? globalThis.Buffer.allocUnsafe(t) : new Uint8Array(t); -} -function gE(t, e, r, n) { - return { name: t, prefix: e, encoder: { name: t, prefix: e, encode: r }, decoder: { decode: n } }; -} -const b3 = gE("utf8", "u", (t) => "u" + new TextDecoder("utf8").decode(t), (t) => new TextEncoder().encode(t.substring(1))), pm = gE("ascii", "a", (t) => { - let e = "a"; - for (let r = 0; r < t.length; r++) e += String.fromCharCode(t[r]); - return e; -}, (t) => { - t = t.substring(1); - const e = FK(t.length); - for (let r = 0; r < t.length; r++) e[r] = t.charCodeAt(r); - return e; -}), BK = { utf8: b3, "utf-8": b3, hex: v3.base16, latin1: pm, ascii: pm, binary: pm, ...v3 }; -function UK(t, e = "utf8") { - const r = BK[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(t, "utf8") : r.decoder.decode(`${r.prefix}${t}`); -} -let jK = class { - constructor(e, r) { - this.core = e, this.logger = r, this.keychain = /* @__PURE__ */ new Map(), this.name = UH, this.version = jH, this.initialized = !1, this.storagePrefix = Zs, this.init = async () => { - if (!this.initialized) { - const n = await this.getKeyChain(); - typeof n < "u" && (this.keychain = n), this.initialized = !0; - } - }, this.has = (n) => (this.isInitialized(), this.keychain.has(n)), this.set = async (n, i) => { - this.isInitialized(), this.keychain.set(n, i), await this.persist(); - }, this.get = (n) => { - this.isInitialized(); - const i = this.keychain.get(n); - if (typeof i > "u") { - const { message: s } = ft("NO_MATCHING_KEY", `${this.name}: ${n}`); - throw new Error(s); - } - return i; - }, this.del = async (n) => { - this.isInitialized(), this.keychain.delete(n), await this.persist(); - }, this.core = e, this.logger = ai(r, this.name); - } - get context() { - return Si(this.logger); - } - get storageKey() { - return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; - } - async setKeyChain(e) { - await this.core.storage.setItem(this.storageKey, N8(e)); - } - async getKeyChain() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? L8(e) : void 0; - } - async persist() { - await this.setKeyChain(this.keychain); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = ft("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -}, qK = class { - constructor(e, r, n) { - this.core = e, this.logger = r, this.name = FH, this.randomSessionIdentifier = I1(), this.initialized = !1, this.init = async () => { - this.initialized || (await this.keychain.init(), this.initialized = !0); - }, this.hasKeys = (i) => (this.isInitialized(), this.keychain.has(i)), this.getClientId = async () => { - this.isInitialized(); - const i = await this.getClientSeed(), s = nx(i); - return U4(s.publicKey); - }, this.generateKeyPair = () => { - this.isInitialized(); - const i = lz(); - return this.setPrivateKey(i.publicKey, i.privateKey); - }, this.signJWT = async (i) => { - this.isInitialized(); - const s = await this.getClientSeed(), o = nx(s), a = this.randomSessionIdentifier; - return await NF(a, i, BH, o); - }, this.generateSharedKey = (i, s, o) => { - this.isInitialized(); - const a = this.getPrivateKey(i), u = hz(a, s); - return this.setSymKey(u, o); - }, this.setSymKey = async (i, s) => { - this.isInitialized(); - const o = s || Cd(i); - return await this.keychain.set(o, i), o; - }, this.deleteKeyPair = async (i) => { - this.isInitialized(), await this.keychain.del(i); - }, this.deleteSymKey = async (i) => { - this.isInitialized(), await this.keychain.del(i); - }, this.encode = async (i, s, o) => { - this.isInitialized(); - const a = W8(o), u = ko(s); - if (Kx(a)) return pz(u, o == null ? void 0 : o.encoding); - if (Wx(a)) { - const w = a.senderPublicKey, A = a.receiverPublicKey; - i = await this.generateSharedKey(w, A); - } - const l = this.getSymKey(i), { type: d, senderPublicKey: g } = a; - return dz({ type: d, symKey: l, message: u, senderPublicKey: g, encoding: o == null ? void 0 : o.encoding }); - }, this.decode = async (i, s, o) => { - this.isInitialized(); - const a = vz(s, o); - if (Kx(a)) { - const u = mz(s, o == null ? void 0 : o.encoding); - return uc(u); - } - if (Wx(a)) { - const u = a.receiverPublicKey, l = a.senderPublicKey; - i = await this.generateSharedKey(u, l); - } - try { - const u = this.getSymKey(i), l = gz({ symKey: u, encoded: s, encoding: o == null ? void 0 : o.encoding }); - return uc(l); - } catch (u) { - this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`), this.logger.error(u); - } - }, this.getPayloadType = (i, s = la) => { - const o = _l({ encoded: i, encoding: s }); - return hc(o.type); - }, this.getPayloadSenderPublicKey = (i, s = la) => { - const o = _l({ encoded: i, encoding: s }); - return o.senderPublicKey ? Dn(o.senderPublicKey, oi) : void 0; - }, this.core = e, this.logger = ai(r, this.name), this.keychain = n || new jK(this.core, this.logger); - } - get context() { - return Si(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(l3); - } catch { - e = I1(), await this.keychain.set(l3, e); - } - return UK(e, "base16"); - } - getSymKey(e) { - return this.keychain.get(e); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = ft("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -}; -class zK extends Uk { - constructor(e, r) { - super(e, r), this.logger = e, this.core = r, this.messages = /* @__PURE__ */ new Map(), this.name = qH, this.version = zH, this.initialized = !1, this.storagePrefix = Zs, this.init = async () => { - if (!this.initialized) { - this.logger.trace("Initialized"); - try { - const n = await this.getRelayerMessages(); - typeof n < "u" && (this.messages = n), this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", size: this.messages.size }); - } catch (n) { - this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(n); - } finally { - this.initialized = !0; - } - } - }, this.set = async (n, i) => { - this.isInitialized(); - const s = wo(i); - let o = this.messages.get(n); - return typeof o > "u" && (o = {}), typeof o[s] < "u" || (o[s] = i, this.messages.set(n, o), await this.persist()), s; - }, this.get = (n) => { - this.isInitialized(); - let i = this.messages.get(n); - return typeof i > "u" && (i = {}), i; - }, this.has = (n, i) => { - this.isInitialized(); - const s = this.get(n), o = wo(i); - return typeof s[o] < "u"; - }, this.del = async (n) => { - this.isInitialized(), this.messages.delete(n), await this.persist(); - }, this.logger = ai(e, this.name), this.core = r; - } - get context() { - return Si(this.logger); - } - get storageKey() { - return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; - } - async setRelayerMessages(e) { - await this.core.storage.setItem(this.storageKey, N8(e)); - } - async getRelayerMessages() { - const e = await this.core.storage.getItem(this.storageKey); - return typeof e < "u" ? L8(e) : void 0; - } - async persist() { - await this.setRelayerMessages(this.messages); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = ft("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class HK extends jk { - constructor(e, r) { - super(e, r), this.relayer = e, this.logger = r, this.events = new rs.EventEmitter(), this.name = WH, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = mt.toMiliseconds(mt.ONE_MINUTE), this.failedPublishTimeout = mt.toMiliseconds(mt.ONE_SECOND), this.needsTransportRestart = !1, this.publish = async (n, i, s) => { - var o; - this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: n, message: i, opts: s } }); - const a = (s == null ? void 0 : s.ttl) || HH, u = C1(s), l = (s == null ? void 0 : s.prompt) || !1, d = (s == null ? void 0 : s.tag) || 0, g = (s == null ? void 0 : s.id) || rc().toString(), w = { topic: n, message: i, opts: { ttl: a, relay: u, prompt: l, tag: d, id: g, attestation: s == null ? void 0 : s.attestation } }, A = `Failed to publish payload, please try again. id:${g} tag:${d}`, M = Date.now(); - let N, L = 1; - try { - for (; N === void 0; ) { - if (Date.now() - M > this.publishTimeout) throw new Error(A); - this.logger.trace({ id: g, attempts: L }, `publisher.publish - attempt ${L}`), N = await await hu(this.rpcPublish(n, i, a, u, l, d, g, s == null ? void 0 : s.attestation).catch((F) => this.logger.warn(F)), this.publishTimeout, A), L++, N || await new Promise((F) => setTimeout(F, this.failedPublishTimeout)); - } - this.relayer.events.emit(si.publish, w), this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { id: g, topic: n, message: i, opts: s } }); - } catch (F) { - if (this.logger.debug("Failed to Publish Payload"), this.logger.error(F), (o = s == null ? void 0 : s.internal) != null && o.throwOnFailedPublish) throw F; - this.queue.set(g, w); - } - }, this.on = (n, i) => { - this.events.on(n, i); - }, this.once = (n, i) => { - this.events.once(n, i); - }, this.off = (n, i) => { - this.events.off(n, i); - }, this.removeListener = (n, i) => { - this.events.removeListener(n, i); - }, this.relayer = e, this.logger = ai(r, this.name), this.registerEventListeners(); - } - get context() { - return Si(this.logger); - } - rpcPublish(e, r, n, i, s, o, a, u) { - var l, d, g, w; - const A = { method: $f(i.protocol).publish, params: { topic: e, message: r, ttl: n, prompt: s, tag: o, attestation: u }, id: a }; - return gi((l = A.params) == null ? void 0 : l.prompt) && ((d = A.params) == null || delete d.prompt), gi((g = A.params) == null ? void 0 : g.tag) && ((w = A.params) == null || delete w.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: A }), this.relayer.request(A); - } - removeRequestFromQueue(e) { - this.queue.delete(e); - } - checkQueue() { - this.queue.forEach(async (e) => { - const { topic: r, message: n, opts: i } = e; - await this.publish(r, n, i); - }); - } - registerEventListeners() { - this.relayer.core.heartbeat.on(Du.pulse, () => { - if (this.needsTransportRestart) { - this.needsTransportRestart = !1, this.relayer.events.emit(si.connection_stalled); - return; - } - this.checkQueue(); - }), this.relayer.on(si.message_ack, (e) => { - this.removeRequestFromQueue(e.id.toString()); - }); - } -} -class WK { - constructor() { - this.map = /* @__PURE__ */ new Map(), this.set = (e, r) => { - const n = this.get(e); - this.exists(e, r) || this.map.set(e, [...n, 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; - const n = this.get(e); - if (!this.exists(e, r)) return; - const i = n.filter((s) => s !== r); - if (!i.length) { - this.map.delete(e); - return; - } - this.map.set(e, i); - }, this.clear = () => { - this.map.clear(); - }; - } - get topics() { - return Array.from(this.map.keys()); - } -} -var KK = Object.defineProperty, VK = Object.defineProperties, GK = Object.getOwnPropertyDescriptors, y3 = Object.getOwnPropertySymbols, YK = Object.prototype.hasOwnProperty, JK = Object.prototype.propertyIsEnumerable, w3 = (t, e, r) => e in t ? KK(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, If = (t, e) => { - for (var r in e || (e = {})) YK.call(e, r) && w3(t, r, e[r]); - if (y3) for (var r of y3(e)) JK.call(e, r) && w3(t, r, e[r]); - return t; -}, gm = (t, e) => VK(t, GK(e)); -class XK extends Hk { - constructor(e, r) { - super(e, r), this.relayer = e, this.logger = r, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new WK(), this.events = new rs.EventEmitter(), this.name = ZH, this.version = QH, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = !1, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = Zs, this.subscribeTimeout = mt.toMiliseconds(mt.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 (n, i) => { - this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: n, opts: i } }); - try { - const s = C1(i), o = { topic: n, relay: s, transportType: i == null ? void 0 : i.transportType }; - this.pending.set(n, o); - const a = await this.rpcSubscribe(n, s, i); - return typeof a == "string" && (this.onSubscribe(a, o), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: n, opts: i } })), a; - } catch (s) { - throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(s), s; - } - }, this.unsubscribe = async (n, i) => { - await this.restartToComplete(), this.isInitialized(), typeof (i == null ? void 0 : i.id) < "u" ? await this.unsubscribeById(n, i.id, i) : await this.unsubscribeByTopic(n, i); - }, this.isSubscribed = async (n) => { - if (this.topics.includes(n)) return !0; - const i = `${this.pendingSubscriptionWatchLabel}_${n}`; - return await new Promise((s, o) => { - const a = new mt.Watch(); - a.start(i); - const u = setInterval(() => { - !this.pending.has(n) && this.topics.includes(n) && (clearInterval(u), a.stop(i), s(!0)), a.elapsed(i) >= eW && (clearInterval(u), a.stop(i), o(new Error("Subscription resolution timeout"))); - }, this.pollingInterval); - }).catch(() => !1); - }, this.on = (n, i) => { - this.events.on(n, i); - }, this.once = (n, i) => { - this.events.once(n, i); - }, this.off = (n, i) => { - this.events.off(n, i); - }, this.removeListener = (n, i) => { - this.events.removeListener(n, i); - }, 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 = ai(r, this.name), this.clientId = ""; - } - get context() { - return Si(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 n = !1; - try { - n = this.getSubscription(e).topic === r; - } catch { - } - return n; - } - onEnable() { - this.cached = [], this.initialized = !0; - } - onDisable() { - this.cached = this.values, this.subscriptions.clear(), this.topicMap.clear(); - } - async unsubscribeByTopic(e, r) { - const n = this.topicMap.get(e); - await Promise.all(n.map(async (i) => await this.unsubscribeById(e, i, r))); - } - async unsubscribeById(e, r, n) { - this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: r, opts: n } }); - try { - const i = C1(n); - await this.rpcUnsubscribe(e, r, i); - const s = Or("USER_DISCONNECTED", `${this.name}, ${e}`); - await this.onUnsubscribe(e, r, s), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: r, opts: n } }); - } catch (i) { - throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(i), i; - } - } - async rpcSubscribe(e, r, n) { - var i; - (n == null ? void 0 : n.transportType) === zr.relay && await this.restartToComplete(); - const s = { method: $f(r.protocol).subscribe, params: { topic: e } }; - this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s }); - const o = (i = n == null ? void 0 : n.internal) == null ? void 0 : i.throwOnFailedPublish; - try { - const a = wo(e + this.clientId); - if ((n == null ? void 0 : n.transportType) === zr.link_mode) return setTimeout(() => { - (this.relayer.connected || this.relayer.connecting) && this.relayer.request(s).catch((l) => this.logger.warn(l)); - }, mt.toMiliseconds(mt.ONE_SECOND)), a; - const u = await hu(this.relayer.request(s).catch((l) => this.logger.warn(l)), this.subscribeTimeout, `Subscribing to ${e} failed, please try again`); - if (!u && o) throw new Error(`Subscribing to ${e} failed, please try again`); - return u ? a : null; - } catch (a) { - if (this.logger.debug("Outgoing Relay Subscribe Payload stalled"), this.relayer.events.emit(si.connection_stalled), o) throw a; - } - return null; - } - async rpcBatchSubscribe(e) { - if (!e.length) return; - const r = e[0].relay, n = { method: $f(r.protocol).batchSubscribe, params: { topics: e.map((i) => i.topic) } }; - this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: n }); - try { - return await await hu(this.relayer.request(n).catch((i) => this.logger.warn(i)), this.subscribeTimeout); - } catch { - this.relayer.events.emit(si.connection_stalled); - } - } - async rpcBatchFetchMessages(e) { - if (!e.length) return; - const r = e[0].relay, n = { method: $f(r.protocol).batchFetchMessages, params: { topics: e.map((s) => s.topic) } }; - this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: n }); - let i; - try { - i = await await hu(this.relayer.request(n).catch((s) => this.logger.warn(s)), this.subscribeTimeout); - } catch { - this.relayer.events.emit(si.connection_stalled); - } - return i; - } - rpcUnsubscribe(e, r, n) { - const i = { method: $f(n.protocol).unsubscribe, params: { topic: e, id: r } }; - return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i }), this.relayer.request(i); - } - onSubscribe(e, r) { - this.setSubscription(e, gm(If({}, r), { id: e })), this.pending.delete(r.topic); - } - onBatchSubscribe(e) { - e.length && e.forEach((r) => { - this.setSubscription(r.id, If({}, r)), this.pending.delete(r.topic); - }); - } - async onUnsubscribe(e, r, n) { - this.events.removeAllListeners(r), this.hasSubscription(r, e) && this.deleteSubscription(r, n), 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, If({}, r)), this.topicMap.set(r.topic, e), this.events.emit(Us.created, r); - } - getSubscription(e) { - this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e }); - const r = this.subscriptions.get(e); - if (!r) { - const { message: n } = ft("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw new Error(n); - } - return r; - } - deleteSubscription(e, r) { - this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e, reason: r }); - const n = this.getSubscription(e); - this.subscriptions.delete(e), this.topicMap.delete(n.topic, e), this.events.emit(Us.deleted, gm(If({}, n), { reason: r })); - } - async persist() { - await this.setRelayerSubscriptions(this.values), this.events.emit(Us.sync); - } - async reset() { - if (this.cached.length) { - const e = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); - for (let r = 0; r < e; r++) { - const n = this.cached.splice(0, this.batchSubscribeTopicsLimit); - await this.batchFetchMessages(n), await this.batchSubscribe(n); - } - } - this.events.emit(Us.resubscribed); - } - async restore() { - try { - const e = await this.getRelayerSubscriptions(); - if (typeof e > "u" || !e.length) return; - if (this.subscriptions.size) { - const { message: r } = ft("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; - const r = await this.rpcBatchSubscribe(e); - dc(r) && this.onBatchSubscribe(r.map((n, i) => gm(If({}, e[i]), { id: n }))); - } - async batchFetchMessages(e) { - if (!e.length) return; - this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`); - const 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; - const 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(Du.pulse, async () => { - await this.checkPending(); - }), this.events.on(Us.created, async (e) => { - const r = Us.created; - this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), await this.persist(); - }), this.events.on(Us.deleted, async (e) => { - const r = Us.deleted; - this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), await this.persist(); - }); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = ft("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) => { - const r = setInterval(() => { - this.restartInProgress || (clearInterval(r), e()); - }, this.pollingInterval); - }); - } -} -var ZK = Object.defineProperty, x3 = Object.getOwnPropertySymbols, QK = Object.prototype.hasOwnProperty, eV = Object.prototype.propertyIsEnumerable, _3 = (t, e, r) => e in t ? ZK(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, E3 = (t, e) => { - for (var r in e || (e = {})) QK.call(e, r) && _3(t, r, e[r]); - if (x3) for (var r of x3(e)) eV.call(e, r) && _3(t, r, e[r]); - return t; -}; -class tV extends qk { - constructor(e) { - super(e), this.protocol = "wc", this.version = 2, this.events = new rs.EventEmitter(), this.name = VH, this.transportExplicitlyClosed = !1, this.initialized = !1, this.connectionAttemptInProgress = !1, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "stalled", "interrupted"], this.hasExperiencedNetworkDisruption = !1, this.requestsInFlight = /* @__PURE__ */ new Map(), this.heartBeatTimeout = mt.toMiliseconds(mt.THIRTY_SECONDS + mt.ONE_SECOND), this.request = async (r) => { - var n, i; - this.logger.debug("Publishing Request Payload"); - const s = r.id || rc().toString(); - await this.toEstablishConnection(); - try { - const o = this.provider.request(r); - this.requestsInFlight.set(s, { promise: o, request: r }), this.logger.trace({ id: s, method: r.method, topic: (n = r.params) == null ? void 0 : n.topic }, "relayer.request - attempt to publish..."); - const a = await new Promise(async (u, l) => { - const d = () => { - l(new Error(`relayer.request - publish interrupted, id: ${s}`)); - }; - this.provider.on(Vi.disconnect, d); - const g = await o; - this.provider.off(Vi.disconnect, d), u(g); - }); - return this.logger.trace({ id: s, method: r.method, topic: (i = r.params) == null ? void 0 : i.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 (a0()) try { - clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => { - var r, n, i; - (i = (n = (r = this.provider) == null ? void 0 : r.connection) == null ? void 0 : n.socket) == null || i.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(si.connect); - }, this.onDisconnectHandler = () => { - this.logger.trace("relayer disconnected"), this.onProviderDisconnect(); - }, this.onProviderErrorHandler = (r) => { - this.logger.error(r), this.events.emit(si.error, r), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); - }, this.registerProviderListeners = () => { - this.provider.on(Vi.payload, this.onPayloadHandler), this.provider.on(Vi.connect, this.onConnectHandler), this.provider.on(Vi.disconnect, this.onDisconnectHandler), this.provider.on(Vi.error, this.onProviderErrorHandler); - }, this.core = e.core, this.logger = typeof e.logger < "u" && typeof e.logger != "string" ? ai(e.logger, this.name) : jl(k0({ level: e.logger || KH })), this.messages = new zK(this.logger, e.core), this.subscriber = new XK(this, this.logger), this.publisher = new HK(this, this.logger), this.relayUrl = (e == null ? void 0 : e.relayUrl) || iE, this.projectId = e.projectId, this.bundleId = Cq(), 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 Si(this.logger); - } - get connected() { - var e, r, n; - return ((n = (r = (e = this.provider) == null ? void 0 : e.connection) == null ? void 0 : r.socket) == null ? void 0 : n.readyState) === 1; - } - get connecting() { - var e, r, n; - return ((n = (r = (e = this.provider) == null ? void 0 : e.connection) == null ? void 0 : r.socket) == null ? void 0 : n.readyState) === 0; - } - async publish(e, r, n) { - this.isInitialized(), await this.publisher.publish(e, r, n), await this.recordMessageEvent({ topic: e, message: r, publishedAt: Date.now(), transportType: zr.relay }); - } - async subscribe(e, r) { - var n, i, s; - this.isInitialized(), (r == null ? void 0 : r.transportType) === "relay" && await this.toEstablishConnection(); - const o = typeof ((n = r == null ? void 0 : r.internal) == null ? void 0 : n.throwOnFailedPublish) > "u" ? !0 : (i = r == null ? void 0 : r.internal) == null ? void 0 : i.throwOnFailedPublish; - let a = ((s = this.subscriber.topicMap.get(e)) == null ? void 0 : s[0]) || "", u; - const l = (d) => { - d.topic === e && (this.subscriber.off(Us.created, l), u()); - }; - return await Promise.all([new Promise((d) => { - u = d, this.subscriber.on(Us.created, l); - }), new Promise(async (d, g) => { - a = await this.subscriber.subscribe(e, E3({ internal: { throwOnFailedPublish: o } }, r)).catch((w) => { - o && g(w); - }) || 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.provider.disconnect && (this.hasExperiencedNetworkDisruption || this.connected) ? await hu(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, n) => { - const i = () => { - this.provider.off(Vi.disconnect, i), n(new Error("Connection interrupted while trying to subscribe")); - }; - this.provider.on(Vi.disconnect, i), await hu(this.provider.connect(), mt.toMiliseconds(mt.ONE_MINUTE), `Socket stalled when trying to connect to ${this.relayUrl}`).catch((s) => { - n(s); - }).finally(() => { - clearTimeout(this.reconnectTimeout), this.reconnectTimeout = void 0; - }), this.subscriber.start().catch((s) => { - this.logger.error(s), this.onDisconnectHandler(); - }), this.hasExperiencedNetworkDisruption = !1, r(); - }); - } catch (r) { - this.logger.error(r); - const n = r; - if (this.hasExperiencedNetworkDisruption = !0, !this.isConnectionStalled(n.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 n3()) throw new Error("No internet connection detected. Please restart your network and try again."); - } - async handleBatchMessageEvents(e) { - if ((e == null ? void 0 : e.length) === 0) { - this.logger.trace("Batch message events is empty. Ignoring..."); - return; - } - const r = e.sort((n, i) => n.publishedAt - i.publishedAt); - this.logger.trace(`Batch of ${r.length} message events sorted`); - for (const n of r) try { - await this.onMessageEvent(n); - } catch (i) { - this.logger.warn(i); - } - this.logger.trace(`Batch of ${r.length} message events processed`); - } - async onLinkMessageEvent(e, r) { - const { topic: n } = e; - if (!r.sessionExists) { - const i = En(mt.FIVE_MINUTES), s = { topic: n, expiry: i, relay: { protocol: "irn" }, active: !1 }; - await this.core.pairing.pairings.set(n, s); - } - this.events.emit(si.message, e), await this.recordMessageEvent(e); - } - startPingTimeout() { - var e, r, n, i, s; - if (a0()) try { - (r = (e = this.provider) == null ? void 0 : e.connection) != null && r.socket && ((s = (i = (n = this.provider) == null ? void 0 : n.connection) == null ? void 0 : i.socket) == null || s.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(); - const e = await this.core.crypto.signJWT(this.relayUrl); - this.provider = new as(new OH(Oq({ sdkVersion: T1, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e, useOnCloseEvent: !0, bundleId: this.bundleId }))), this.registerProviderListeners(); - } - async recordMessageEvent(e) { - const { topic: r, message: n } = e; - await this.messages.set(r, n); - } - async shouldIgnoreMessageEvent(e) { - const { topic: r, message: n } = e; - if (!n || n.length === 0) return this.logger.debug(`Ignoring invalid/empty message: ${n}`), !0; - if (!await this.subscriber.isSubscribed(r)) return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`), !0; - const i = this.messages.has(r, n); - return i && this.logger.debug(`Ignoring duplicate message: ${n}`), i; - } - async onProviderPayload(e) { - if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e }), ub(e)) { - if (!e.method.endsWith(GH)) return; - const r = e.params, { topic: n, message: i, publishedAt: s, attestation: o } = r.data, a = { topic: n, message: i, publishedAt: s, transportType: zr.relay, attestation: o }; - this.logger.debug("Emitting Relayer Payload"), this.logger.trace(E3({ type: "event", event: r.id }, a)), this.events.emit(r.id, a), await this.acknowledgePayload(e), await this.onMessageEvent(a); - } else np(e) && this.events.emit(si.message_ack, e); - } - async onMessageEvent(e) { - await this.shouldIgnoreMessageEvent(e) || (this.events.emit(si.message, e), await this.recordMessageEvent(e)); - } - async acknowledgePayload(e) { - const r = tp(e.id, !0); - await this.provider.connection.send(r); - } - unregisterProviderListeners() { - this.provider.off(Vi.payload, this.onPayloadHandler), this.provider.off(Vi.connect, this.onConnectHandler), this.provider.off(Vi.disconnect, this.onDisconnectHandler), this.provider.off(Vi.error, this.onProviderErrorHandler), clearTimeout(this.pingTimeout); - } - async registerEventListeners() { - let e = await n3(); - fH(async (r) => { - e !== r && (e = r, r ? await this.restartTransport().catch((n) => this.logger.error(n)) : (this.hasExperiencedNetworkDisruption = !0, await this.transportDisconnect(), this.transportExplicitlyClosed = !1)); - }); - } - async onProviderDisconnect() { - await this.subscriber.stop(), this.requestsInFlight.clear(), clearTimeout(this.pingTimeout), this.events.emit(si.disconnect), this.connectionAttemptInProgress = !1, !this.transportExplicitlyClosed && (this.reconnectTimeout || (this.reconnectTimeout = setTimeout(async () => { - await this.transportOpen().catch((e) => this.logger.error(e)); - }, mt.toMiliseconds(YH)))); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = ft("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } - async toEstablishConnection() { - await this.confirmOnlineStateOrThrow(), !this.connected && (this.connectionAttemptInProgress && await new Promise((e) => { - const r = setInterval(() => { - this.connected && (clearInterval(r), e()); - }, this.connectionStatusPollingInterval); - }), await this.transportOpen()); - } -} -var rV = Object.defineProperty, S3 = Object.getOwnPropertySymbols, nV = Object.prototype.hasOwnProperty, iV = Object.prototype.propertyIsEnumerable, A3 = (t, e, r) => e in t ? rV(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, P3 = (t, e) => { - for (var r in e || (e = {})) nV.call(e, r) && A3(t, r, e[r]); - if (S3) for (var r of S3(e)) iV.call(e, r) && A3(t, r, e[r]); - return t; -}; -class _c extends zk { - constructor(e, r, n, i = Zs, s = void 0) { - super(e, r, n, i), this.core = e, this.logger = r, this.name = n, this.map = /* @__PURE__ */ new Map(), this.version = JH, this.cached = [], this.initialized = !1, this.storagePrefix = Zs, 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 && !gi(o) ? this.map.set(this.getKey(o), o) : jz(o) ? this.map.set(o.id, o) : qz(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((u) => LH(a[u], o[u]))) : 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 }); - const u = P3(P3({}, this.getData(o)), a); - this.map.set(o, u), 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 = ai(r, this.name), this.storagePrefix = i, this.getKey = s; - } - get context() { - return Si(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) { - const r = this.map.get(e); - if (!r) { - if (this.recentlyDeleted.includes(e)) { - const { message: i } = ft("MISSING_OR_INVALID", `Record was recently deleted - ${this.name}: ${e}`); - throw this.logger.error(i), new Error(i); - } - const { message: n } = ft("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw this.logger.error(n), new Error(n); - } - return r; - } - async persist() { - await this.setDataStore(this.values); - } - async restore() { - try { - const e = await this.getDataStore(); - if (typeof e > "u" || !e.length) return; - if (this.map.size) { - const { message: r } = ft("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) { - const { message: e } = ft("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class sV { - constructor(e, r) { - this.core = e, this.logger = r, this.name = tW, this.version = rW, this.events = new Lv(), this.initialized = !1, this.storagePrefix = Zs, this.ignoredPayloadTypes = [Io], 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: n }) => { - this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...n])]; - }, this.create = async (n) => { - this.isInitialized(); - const i = I1(), s = await this.core.crypto.setSymKey(i), o = En(mt.FIVE_MINUTES), a = { protocol: nE }, u = { topic: s, expiry: o, relay: a, active: !1, methods: n == null ? void 0 : n.methods }, l = Xx({ protocol: this.core.protocol, version: this.core.version, topic: s, symKey: i, relay: a, expiryTimestamp: o, methods: n == null ? void 0 : n.methods }); - return this.events.emit(Xa.create, u), this.core.expirer.set(s, o), await this.pairings.set(s, u), await this.core.relayer.subscribe(s, { transportType: n == null ? void 0 : n.transportType }), { topic: s, uri: l }; - }, this.pair = async (n) => { - this.isInitialized(); - const i = this.core.eventClient.createEvent({ properties: { topic: n == null ? void 0 : n.uri, trace: [Fs.pairing_started] } }); - this.isValidPair(n, i); - const { topic: s, symKey: o, relay: a, expiryTimestamp: u, methods: l } = Jx(n.uri); - i.props.properties.topic = s, i.addTrace(Fs.pairing_uri_validation_success), i.addTrace(Fs.pairing_uri_not_expired); - let d; - if (this.pairings.keys.includes(s)) { - if (d = this.pairings.get(s), i.addTrace(Fs.existing_pairing), d.active) throw i.setError(yo.active_pairing_already_exists), new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`); - i.addTrace(Fs.pairing_not_expired); - } - const g = u || En(mt.FIVE_MINUTES), w = { topic: s, relay: a, expiry: g, active: !1, methods: l }; - this.core.expirer.set(s, g), await this.pairings.set(s, w), i.addTrace(Fs.store_new_pairing), n.activatePairing && await this.activate({ topic: s }), this.events.emit(Xa.create, w), i.addTrace(Fs.emit_inactive_pairing), this.core.crypto.keychain.has(s) || await this.core.crypto.setSymKey(o, s), i.addTrace(Fs.subscribing_pairing_topic); - try { - await this.core.relayer.confirmOnlineStateOrThrow(); - } catch { - i.setError(yo.no_internet_connection); - } - try { - await this.core.relayer.subscribe(s, { relay: a }); - } catch (A) { - throw i.setError(yo.subscribe_pairing_topic_failure), A; - } - return i.addTrace(Fs.subscribe_pairing_topic_success), w; - }, this.activate = async ({ topic: n }) => { - this.isInitialized(); - const i = En(mt.THIRTY_DAYS); - this.core.expirer.set(n, i), await this.pairings.update(n, { active: !0, expiry: i }); - }, this.ping = async (n) => { - this.isInitialized(), await this.isValidPing(n); - const { topic: i } = n; - if (this.pairings.keys.includes(i)) { - const s = await this.sendRequest(i, "wc_pairingPing", {}), { done: o, resolve: a, reject: u } = Va(); - this.events.once(br("pairing_ping", s), ({ error: l }) => { - l ? u(l) : a(); - }), await o(); - } - }, this.updateExpiry = async ({ topic: n, expiry: i }) => { - this.isInitialized(), await this.pairings.update(n, { expiry: i }); - }, this.updateMetadata = async ({ topic: n, metadata: i }) => { - this.isInitialized(), await this.pairings.update(n, { peerMetadata: i }); - }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (n) => { - this.isInitialized(), await this.isValidDisconnect(n); - const { topic: i } = n; - this.pairings.keys.includes(i) && (await this.sendRequest(i, "wc_pairingDelete", Or("USER_DISCONNECTED")), await this.deletePairing(i)); - }, this.formatUriFromPairing = (n) => { - this.isInitialized(); - const { topic: i, relay: s, expiry: o, methods: a } = n, u = this.core.crypto.keychain.get(i); - return Xx({ protocol: this.core.protocol, version: this.core.version, topic: i, symKey: u, relay: s, expiryTimestamp: o, methods: a }); - }, this.sendRequest = async (n, i, s) => { - const o = ha(i, s), a = await this.core.crypto.encode(n, o), u = Pf[i].req; - return this.core.history.set(n, o), this.core.relayer.publish(n, a, u), o.id; - }, this.sendResult = async (n, i, s) => { - const o = tp(n, s), a = await this.core.crypto.encode(i, o), u = await this.core.history.get(i, n), l = Pf[u.request.method].res; - await this.core.relayer.publish(i, a, l), await this.core.history.resolve(o); - }, this.sendError = async (n, i, s) => { - const o = rp(n, s), a = await this.core.crypto.encode(i, o), u = await this.core.history.get(i, n), l = Pf[u.request.method] ? Pf[u.request.method].res : Pf.unregistered_method.res; - await this.core.relayer.publish(i, a, l), await this.core.history.resolve(o); - }, this.deletePairing = async (n, i) => { - await this.core.relayer.unsubscribe(n), await Promise.all([this.pairings.delete(n, Or("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(n), i ? Promise.resolve() : this.core.expirer.del(n)]); - }, this.cleanup = async () => { - const n = this.pairings.getAll().filter((i) => aa(i.expiry)); - await Promise.all(n.map((i) => this.deletePairing(i.topic))); - }, this.onRelayEventRequest = (n) => { - const { topic: i, payload: s } = n; - switch (s.method) { - case "wc_pairingPing": - return this.onPairingPingRequest(i, s); - case "wc_pairingDelete": - return this.onPairingDeleteRequest(i, s); - default: - return this.onUnknownRpcMethodRequest(i, s); - } - }, this.onRelayEventResponse = async (n) => { - const { topic: i, payload: s } = n, o = (await this.core.history.get(i, s.id)).request.method; - switch (o) { - case "wc_pairingPing": - return this.onPairingPingResponse(i, s); - default: - return this.onUnknownRpcMethodResponse(o); - } - }, this.onPairingPingRequest = async (n, i) => { - const { id: s } = i; - try { - this.isValidPing({ topic: n }), await this.sendResult(s, n, !0), this.events.emit(Xa.ping, { id: s, topic: n }); - } catch (o) { - await this.sendError(s, n, o), this.logger.error(o); - } - }, this.onPairingPingResponse = (n, i) => { - const { id: s } = i; - setTimeout(() => { - Bs(i) ? this.events.emit(br("pairing_ping", s), {}) : Zi(i) && this.events.emit(br("pairing_ping", s), { error: i.error }); - }, 500); - }, this.onPairingDeleteRequest = async (n, i) => { - const { id: s } = i; - try { - this.isValidDisconnect({ topic: n }), await this.deletePairing(n), this.events.emit(Xa.delete, { id: s, topic: n }); - } catch (o) { - await this.sendError(s, n, o), this.logger.error(o); - } - }, this.onUnknownRpcMethodRequest = async (n, i) => { - const { id: s, method: o } = i; - try { - if (this.registeredMethods.includes(o)) return; - const a = Or("WC_METHOD_UNSUPPORTED", o); - await this.sendError(s, n, a), this.logger.error(a); - } catch (a) { - await this.sendError(s, n, a), this.logger.error(a); - } - }, this.onUnknownRpcMethodResponse = (n) => { - this.registeredMethods.includes(n) || this.logger.error(Or("WC_METHOD_UNSUPPORTED", n)); - }, this.isValidPair = (n, i) => { - var s; - if (!pi(n)) { - const { message: a } = ft("MISSING_OR_INVALID", `pair() params: ${n}`); - throw i.setError(yo.malformed_pairing_uri), new Error(a); - } - if (!Uz(n.uri)) { - const { message: a } = ft("MISSING_OR_INVALID", `pair() uri: ${n.uri}`); - throw i.setError(yo.malformed_pairing_uri), new Error(a); - } - const o = Jx(n == null ? void 0 : n.uri); - if (!((s = o == null ? void 0 : o.relay) != null && s.protocol)) { - const { message: a } = ft("MISSING_OR_INVALID", "pair() uri#relay-protocol"); - throw i.setError(yo.malformed_pairing_uri), new Error(a); - } - if (!(o != null && o.symKey)) { - const { message: a } = ft("MISSING_OR_INVALID", "pair() uri#symKey"); - throw i.setError(yo.malformed_pairing_uri), new Error(a); - } - if (o != null && o.expiryTimestamp && mt.toMiliseconds(o == null ? void 0 : o.expiryTimestamp) < Date.now()) { - i.setError(yo.pairing_expired); - const { message: a } = ft("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); - throw new Error(a); - } - }, this.isValidPing = async (n) => { - if (!pi(n)) { - const { message: s } = ft("MISSING_OR_INVALID", `ping() params: ${n}`); - throw new Error(s); - } - const { topic: i } = n; - await this.isValidPairingTopic(i); - }, this.isValidDisconnect = async (n) => { - if (!pi(n)) { - const { message: s } = ft("MISSING_OR_INVALID", `disconnect() params: ${n}`); - throw new Error(s); - } - const { topic: i } = n; - await this.isValidPairingTopic(i); - }, this.isValidPairingTopic = async (n) => { - if (!dn(n, !1)) { - const { message: i } = ft("MISSING_OR_INVALID", `pairing topic should be a string: ${n}`); - throw new Error(i); - } - if (!this.pairings.keys.includes(n)) { - const { message: i } = ft("NO_MATCHING_KEY", `pairing topic doesn't exist: ${n}`); - throw new Error(i); - } - if (aa(this.pairings.get(n).expiry)) { - await this.deletePairing(n); - const { message: i } = ft("EXPIRED", `pairing topic: ${n}`); - throw new Error(i); - } - }, this.core = e, this.logger = ai(r, this.name), this.pairings = new _c(this.core, this.logger, this.name, this.storagePrefix); - } - get context() { - return Si(this.logger); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = ft("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } - registerRelayerEvents() { - this.core.relayer.on(si.message, async (e) => { - const { topic: r, message: n, transportType: i } = e; - if (!this.pairings.keys.includes(r) || i === zr.link_mode || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n))) return; - const s = await this.core.crypto.decode(r, n); - try { - ub(s) ? (this.core.history.set(r, s), this.onRelayEventRequest({ topic: r, payload: s })) : np(s) && (await this.core.history.resolve(s), await this.onRelayEventResponse({ topic: r, payload: s }), this.core.history.delete(r, s.id)); - } catch (o) { - this.logger.error(o); - } - }); - } - registerExpirerEvents() { - this.core.expirer.on(Ji.expired, async (e) => { - const { topic: r } = $8(e.target); - r && this.pairings.keys.includes(r) && (await this.deletePairing(r, !0), this.events.emit(Xa.expire, { topic: r })); - }); - } -} -class oV extends Bk { - constructor(e, r) { - super(e, r), this.core = e, this.logger = r, this.records = /* @__PURE__ */ new Map(), this.events = new rs.EventEmitter(), this.name = nW, this.version = iW, this.cached = [], this.initialized = !1, this.storagePrefix = Zs, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((n) => this.records.set(n.id, n)), this.cached = [], this.registerEventListeners(), this.initialized = !0); - }, this.set = (n, i, s) => { - if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: n, request: i, chainId: s }), this.records.has(i.id)) return; - const o = { id: i.id, topic: n, request: { method: i.method, params: i.params || null }, chainId: s, expiry: En(mt.THIRTY_DAYS) }; - this.records.set(o.id, o), this.persist(), this.events.emit(gs.created, o); - }, this.resolve = async (n) => { - if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: n }), !this.records.has(n.id)) return; - const i = await this.getRecord(n.id); - typeof i.response > "u" && (i.response = Zi(n) ? { error: n.error } : { result: n.result }, this.records.set(i.id, i), this.persist(), this.events.emit(gs.updated, i)); - }, this.get = async (n, i) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: n, id: i }), await this.getRecord(i)), this.delete = (n, i) => { - this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: i }), this.values.forEach((s) => { - if (s.topic === n) { - if (typeof i < "u" && s.id !== i) return; - this.records.delete(s.id), this.events.emit(gs.deleted, s); - } - }), this.persist(); - }, this.exists = async (n, i) => (this.isInitialized(), this.records.has(i) ? (await this.getRecord(i)).topic === n : !1), this.on = (n, i) => { - this.events.on(n, i); - }, this.once = (n, i) => { - this.events.once(n, i); - }, this.off = (n, i) => { - this.events.off(n, i); - }, this.removeListener = (n, i) => { - this.events.removeListener(n, i); - }, this.logger = ai(r, this.name); - } - get context() { - return Si(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() { - const e = []; - return this.values.forEach((r) => { - if (typeof r.response < "u") return; - const n = { topic: r.topic, request: ha(r.request.method, r.request.params, r.id), chainId: r.chainId }; - return e.push(n); - }), 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(); - const r = this.records.get(e); - if (!r) { - const { message: n } = ft("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw new Error(n); - } - return r; - } - async persist() { - await this.setJsonRpcRecords(this.values), this.events.emit(gs.sync); - } - async restore() { - try { - const e = await this.getJsonRpcRecords(); - if (typeof e > "u" || !e.length) return; - if (this.records.size) { - const { message: r } = ft("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(gs.created, (e) => { - const r = gs.created; - this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, record: e }); - }), this.events.on(gs.updated, (e) => { - const r = gs.updated; - this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, record: e }); - }), this.events.on(gs.deleted, (e) => { - const r = gs.deleted; - this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, record: e }); - }), this.core.heartbeat.on(Du.pulse, () => { - this.cleanup(); - }); - } - cleanup() { - try { - this.isInitialized(); - let e = !1; - this.records.forEach((r) => { - mt.toMiliseconds(r.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${r.id}`), this.records.delete(r.id), this.events.emit(gs.deleted, r, !1), e = !0); - }), e && this.persist(); - } catch (e) { - this.logger.warn(e); - } - } - isInitialized() { - if (!this.initialized) { - const { message: e } = ft("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class aV extends Wk { - constructor(e, r) { - super(e, r), this.core = e, this.logger = r, this.expirations = /* @__PURE__ */ new Map(), this.events = new rs.EventEmitter(), this.name = sW, this.version = oW, this.cached = [], this.initialized = !1, this.storagePrefix = Zs, this.init = async () => { - this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((n) => this.expirations.set(n.target, n)), this.cached = [], this.registerEventListeners(), this.initialized = !0); - }, this.has = (n) => { - try { - const i = this.formatTarget(n); - return typeof this.getExpiration(i) < "u"; - } catch { - return !1; - } - }, this.set = (n, i) => { - this.isInitialized(); - const s = this.formatTarget(n), o = { target: s, expiry: i }; - this.expirations.set(s, o), this.checkExpiry(s, o), this.events.emit(Ji.created, { target: s, expiration: o }); - }, this.get = (n) => { - this.isInitialized(); - const i = this.formatTarget(n); - return this.getExpiration(i); - }, this.del = (n) => { - if (this.isInitialized(), this.has(n)) { - const i = this.formatTarget(n), s = this.getExpiration(i); - this.expirations.delete(i), this.events.emit(Ji.deleted, { target: i, expiration: s }); - } - }, this.on = (n, i) => { - this.events.on(n, i); - }, this.once = (n, i) => { - this.events.once(n, i); - }, this.off = (n, i) => { - this.events.off(n, i); - }, this.removeListener = (n, i) => { - this.events.removeListener(n, i); - }, this.logger = ai(r, this.name); - } - get context() { - return Si(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 Nq(e); - if (typeof e == "number") return Lq(e); - const { message: r } = ft("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(Ji.sync); - } - async restore() { - try { - const e = await this.getExpirations(); - if (typeof e > "u" || !e.length) return; - if (this.expirations.size) { - const { message: r } = ft("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) { - const r = this.expirations.get(e); - if (!r) { - const { message: n } = ft("NO_MATCHING_KEY", `${this.name}: ${e}`); - throw this.logger.warn(n), new Error(n); - } - return r; - } - checkExpiry(e, r) { - const { expiry: n } = r; - mt.toMiliseconds(n) - Date.now() <= 0 && this.expire(e, r); - } - expire(e, r) { - this.expirations.delete(e), this.events.emit(Ji.expired, { target: e, expiration: r }); - } - checkExpirations() { - this.core.relayer.connected && this.expirations.forEach((e, r) => this.checkExpiry(r, e)); - } - registerEventListeners() { - this.core.heartbeat.on(Du.pulse, () => this.checkExpirations()), this.events.on(Ji.created, (e) => { - const r = Ji.created; - this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), this.persist(); - }), this.events.on(Ji.expired, (e) => { - const r = Ji.expired; - this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), this.persist(); - }), this.events.on(Ji.deleted, (e) => { - const r = Ji.deleted; - this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), this.persist(); - }); - } - isInitialized() { - if (!this.initialized) { - const { message: e } = ft("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } -} -class cV extends Kk { - constructor(e, r, n) { - super(e, r, n), this.core = e, this.logger = r, this.store = n, this.name = aW, this.verifyUrlV3 = uW, this.storagePrefix = Zs, this.version = tE, this.init = async () => { - var i; - this.isDevEnv || (this.publicKey = await this.store.getItem(this.storeKey), this.publicKey && mt.toMiliseconds((i = this.publicKey) == null ? void 0 : i.expiresAt) < Date.now() && (this.logger.debug("verify v2 public key expired"), await this.removePublicKey())); - }, this.register = async (i) => { - if (!Xl() || this.isDevEnv) return; - const s = window.location.origin, { id: o, decryptedId: a } = i, u = `${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`; - try { - const l = Wl(), d = this.startAbortTimer(mt.ONE_SECOND * 5), g = await new Promise((w, A) => { - const M = () => { - window.removeEventListener("message", L), l.body.removeChild(N), A("attestation aborted"); - }; - this.abortController.signal.addEventListener("abort", M); - const N = l.createElement("iframe"); - N.src = u, N.style.display = "none", N.addEventListener("error", M, { signal: this.abortController.signal }); - const L = (F) => { - if (F.data && typeof F.data == "string") try { - const $ = JSON.parse(F.data); - if ($.type === "verify_attestation") { - if (v1($.attestation).payload.id !== o) return; - clearInterval(d), l.body.removeChild(N), this.abortController.signal.removeEventListener("abort", M), window.removeEventListener("message", L), w($.attestation === null ? "" : $.attestation); - } - } catch ($) { - this.logger.warn($); - } - }; - l.body.appendChild(N), window.addEventListener("message", L, { signal: this.abortController.signal }); - }); - return this.logger.debug("jwt attestation", g), g; - } catch (l) { - this.logger.warn(l); - } - return ""; - }, this.resolve = async (i) => { - if (this.isDevEnv) return ""; - const { attestationId: s, hash: o, encryptedId: a } = i; - if (s === "") { - this.logger.debug("resolve: attestationId is empty, skipping"); - return; - } - if (s) { - if (v1(s).payload.id !== a) return; - const l = await this.isValidJwtAttestation(s); - if (l) { - if (!l.isVerified) { - this.logger.warn("resolve: jwt attestation: origin url not verified"); - return; - } - return l; - } - } - if (!o) return; - const u = this.getVerifyUrl(i == null ? void 0 : i.verifyUrl); - return this.fetchAttestation(o, u); - }, this.fetchAttestation = async (i, s) => { - this.logger.debug(`resolving attestation: ${i} from url: ${s}`); - const o = this.startAbortTimer(mt.ONE_SECOND * 5), a = await fetch(`${s}/attestation/${i}?v2Supported=true`, { signal: this.abortController.signal }); - return clearTimeout(o), a.status === 200 ? await a.json() : void 0; - }, this.getVerifyUrl = (i) => { - let s = i || zf; - return fW.includes(s) || (this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${zf}`), s = zf), s; - }, this.fetchPublicKey = async () => { - try { - this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`); - const i = this.startAbortTimer(mt.FIVE_SECONDS), s = await fetch(`${this.verifyUrlV3}/public-key`, { signal: this.abortController.signal }); - return clearTimeout(i), await s.json(); - } catch (i) { - this.logger.warn(i); - } - }, this.persistPublicKey = async (i) => { - this.logger.debug("persisting public key to local storage", i), await this.store.setItem(this.storeKey, i), this.publicKey = i; - }, 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 (i) => { - const s = await this.getPublicKey(); - try { - if (s) return this.validateAttestation(i, s); - } catch (a) { - this.logger.error(a), this.logger.warn("error validating attestation"); - } - const o = await this.fetchAndPersistPublicKey(); - try { - if (o) return this.validateAttestation(i, 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) => { - const o = await this.fetchPublicKey(); - o && (await this.persistPublicKey(o), s(o)); - }); - const i = await this.fetchPromise; - return this.fetchPromise = void 0, i; - }, this.validateAttestation = (i, s) => { - const o = xz(i, s.publicKey), a = { hasExpired: mt.toMiliseconds(o.exp) < Date.now(), payload: o }; - if (a.hasExpired) throw this.logger.warn("resolve: jwt attestation expired"), new Error("JWT attestation expired"); - return { origin: a.payload.origin, isScam: a.payload.isScam, isVerified: a.payload.isVerified }; - }, this.logger = ai(r, this.name), this.abortController = new AbortController(), this.isDevEnv = nb(), this.init(); - } - get storeKey() { - return this.storagePrefix + this.version + this.core.customStoragePrefix + "//verify:public:key"; - } - get context() { - return Si(this.logger); - } - startAbortTimer(e) { - return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), mt.toMiliseconds(e)); - } -} -class uV extends Vk { - constructor(e, r) { - super(e, r), this.projectId = e, this.logger = r, this.context = lW, this.registerDeviceToken = async (n) => { - const { clientId: i, token: s, notificationType: o, enableEncrypted: a = !1 } = n, u = `${hW}/${this.projectId}/clients`; - await fetch(u, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: i, type: o, token: s, always_raw: a }) }); - }, this.logger = ai(r, this.context); - } -} -var fV = Object.defineProperty, M3 = Object.getOwnPropertySymbols, lV = Object.prototype.hasOwnProperty, hV = Object.prototype.propertyIsEnumerable, I3 = (t, e, r) => e in t ? fV(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Cf = (t, e) => { - for (var r in e || (e = {})) lV.call(e, r) && I3(t, r, e[r]); - if (M3) for (var r of M3(e)) hV.call(e, r) && I3(t, r, e[r]); - return t; -}; -class dV extends Gk { - constructor(e, r, n = !0) { - super(e, r, n), this.core = e, this.logger = r, this.context = pW, this.storagePrefix = Zs, this.storageVersion = dW, this.events = /* @__PURE__ */ new Map(), this.shouldPersist = !1, this.init = async () => { - if (!nb()) try { - const i = { eventId: Fx(), timestamp: Date.now(), domain: this.getAppDomain(), props: { event: "INIT", type: "", properties: { client_id: await this.core.crypto.getClientId(), user_agent: O8(this.core.relayer.protocol, this.core.relayer.version, T1) } } }; - await this.sendEvent([i]); - } catch (i) { - this.logger.warn(i); - } - }, this.createEvent = (i) => { - const { event: s = "ERROR", type: o = "", properties: { topic: a, trace: u } } = i, l = Fx(), d = this.core.projectId || "", g = Date.now(), w = Cf({ eventId: l, timestamp: g, props: { event: s, type: o, properties: { topic: a, trace: u } }, bundleId: d, domain: this.getAppDomain() }, this.setMethods(l)); - return this.telemetryEnabled && (this.events.set(l, w), this.shouldPersist = !0), w; - }, this.getEvent = (i) => { - const { eventId: s, topic: o } = i; - if (s) return this.events.get(s); - const a = Array.from(this.events.values()).find((u) => u.props.properties.topic === o); - if (a) return Cf(Cf({}, a), this.setMethods(a.eventId)); - }, this.deleteEvent = (i) => { - const { eventId: s } = i; - this.events.delete(s), this.shouldPersist = !0; - }, this.setEventListeners = () => { - this.core.heartbeat.on(Du.pulse, async () => { - this.shouldPersist && await this.persist(), this.events.forEach((i) => { - mt.fromMiliseconds(Date.now()) - mt.fromMiliseconds(i.timestamp) > gW && (this.events.delete(i.eventId), this.shouldPersist = !0); - }); - }); - }, this.setMethods = (i) => ({ addTrace: (s) => this.addTrace(i, s), setError: (s) => this.setError(i, s) }), this.addTrace = (i, s) => { - const o = this.events.get(i); - o && (o.props.properties.trace.push(s), this.events.set(i, o), this.shouldPersist = !0); - }, this.setError = (i, s) => { - const o = this.events.get(i); - o && (o.props.type = s, o.timestamp = Date.now(), this.events.set(i, 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 { - const i = await this.core.storage.getItem(this.storageKey) || []; - if (!i.length) return; - i.forEach((s) => { - this.events.set(s.eventId, Cf(Cf({}, s), this.setMethods(s.eventId))); - }); - } catch (i) { - this.logger.warn(i); - } - }, this.submit = async () => { - if (!this.telemetryEnabled || this.events.size === 0) return; - const i = []; - for (const [s, o] of this.events) o.props.type && i.push(o); - if (i.length !== 0) try { - if ((await this.sendEvent(i)).ok) for (const s of i) this.events.delete(s.eventId), this.shouldPersist = !0; - } catch (s) { - this.logger.warn(s); - } - }, this.sendEvent = async (i) => { - const s = this.getAppDomain() ? "" : "&sp=desktop"; - return await fetch(`${mW}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${T1}${s}`, { method: "POST", body: JSON.stringify(i) }); - }, this.getAppDomain = () => D8().url, this.logger = ai(r, this.context), this.telemetryEnabled = n, n ? this.restore().then(async () => { - await this.submit(), this.setEventListeners(); - }) : this.persist(); - } - get storageKey() { - return this.storagePrefix + this.storageVersion + this.core.customStoragePrefix + "//" + this.context; - } -} -var pV = Object.defineProperty, C3 = Object.getOwnPropertySymbols, gV = Object.prototype.hasOwnProperty, mV = Object.prototype.propertyIsEnumerable, T3 = (t, e, r) => e in t ? pV(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, R3 = (t, e) => { - for (var r in e || (e = {})) gV.call(e, r) && T3(t, r, e[r]); - if (C3) for (var r of C3(e)) mV.call(e, r) && T3(t, r, e[r]); - return t; -}; -class fb extends Fk { - constructor(e) { - var r; - super(e), this.protocol = eE, this.version = tE, this.name = rE, this.events = new rs.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: u }) => { - if (!o || !a) return; - const l = { topic: o, message: a, publishedAt: Date.now(), transportType: zr.link_mode }; - this.relayer.onLinkMessageEvent(l, { sessionExists: u }); - }, this.projectId = e == null ? void 0 : e.projectId, this.relayUrl = (e == null ? void 0 : e.relayUrl) || iE, this.customStoragePrefix = e != null && e.customStoragePrefix ? `:${e.customStoragePrefix}` : ""; - const n = k0({ level: typeof (e == null ? void 0 : e.logger) == "string" && e.logger ? e.logger : kH.logger }), { logger: i, chunkLoggerController: s } = $k({ opts: n, maxSizeInBytes: e == null ? void 0 : e.maxLogBlobSizeInBytes, loggerOverride: e == null ? void 0 : e.logger }); - this.logChunkController = s, (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 = ai(i, this.name), this.heartbeat = new RL(), this.crypto = new qK(this, this.logger, e == null ? void 0 : e.keychain), this.history = new oV(this, this.logger), this.expirer = new aV(this, this.logger), this.storage = e != null && e.storage ? e.storage : new uk(R3(R3({}, $H), e == null ? void 0 : e.storageOptions)), this.relayer = new tV({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new sV(this, this.logger), this.verify = new cV(this, this.logger, this.storage), this.echoClient = new uV(this.projectId || "", this.logger), this.linkModeSupportedApps = [], this.eventClient = new dV(this, this.logger, e == null ? void 0 : e.telemetryEnabled); - } - static async init(e) { - const r = new fb(e); - await r.initialize(); - const n = await r.crypto.getClientId(); - return await r.storage.setItem(XH, n), r; - } - get context() { - return Si(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(h3, 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(h3) || [], 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; - } - } -} -const vV = fb, mE = "wc", vE = 2, bE = "client", lb = `${mE}@${vE}:${bE}:`, mm = { name: bE, logger: "error" }, D3 = "WALLETCONNECT_DEEPLINK_CHOICE", bV = "proposal", yE = "Proposal expired", yV = "session", Wc = mt.SEVEN_DAYS, wV = "engine", In = { wc_sessionPropose: { req: { ttl: mt.FIVE_MINUTES, prompt: !0, tag: 1100 }, res: { ttl: mt.FIVE_MINUTES, prompt: !1, tag: 1101 }, reject: { ttl: mt.FIVE_MINUTES, prompt: !1, tag: 1120 }, autoReject: { ttl: mt.FIVE_MINUTES, prompt: !1, tag: 1121 } }, wc_sessionSettle: { req: { ttl: mt.FIVE_MINUTES, prompt: !1, tag: 1102 }, res: { ttl: mt.FIVE_MINUTES, prompt: !1, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: mt.ONE_DAY, prompt: !1, tag: 1104 }, res: { ttl: mt.ONE_DAY, prompt: !1, tag: 1105 } }, wc_sessionExtend: { req: { ttl: mt.ONE_DAY, prompt: !1, tag: 1106 }, res: { ttl: mt.ONE_DAY, prompt: !1, tag: 1107 } }, wc_sessionRequest: { req: { ttl: mt.FIVE_MINUTES, prompt: !0, tag: 1108 }, res: { ttl: mt.FIVE_MINUTES, prompt: !1, tag: 1109 } }, wc_sessionEvent: { req: { ttl: mt.FIVE_MINUTES, prompt: !0, tag: 1110 }, res: { ttl: mt.FIVE_MINUTES, prompt: !1, tag: 1111 } }, wc_sessionDelete: { req: { ttl: mt.ONE_DAY, prompt: !1, tag: 1112 }, res: { ttl: mt.ONE_DAY, prompt: !1, tag: 1113 } }, wc_sessionPing: { req: { ttl: mt.ONE_DAY, prompt: !1, tag: 1114 }, res: { ttl: mt.ONE_DAY, prompt: !1, tag: 1115 } }, wc_sessionAuthenticate: { req: { ttl: mt.ONE_HOUR, prompt: !0, tag: 1116 }, res: { ttl: mt.ONE_HOUR, prompt: !1, tag: 1117 }, reject: { ttl: mt.FIVE_MINUTES, prompt: !1, tag: 1118 }, autoReject: { ttl: mt.FIVE_MINUTES, prompt: !1, tag: 1119 } } }, vm = { min: mt.FIVE_MINUTES, max: mt.SEVEN_DAYS }, Ls = { idle: "IDLE", active: "ACTIVE" }, xV = "request", _V = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest", "wc_sessionAuthenticate"], EV = "wc", SV = "auth", AV = "authKeys", PV = "pairingTopics", MV = "requests", sp = `${EV}@${1.5}:${SV}:`, Td = `${sp}:PUB_KEY`; -var IV = Object.defineProperty, CV = Object.defineProperties, TV = Object.getOwnPropertyDescriptors, O3 = Object.getOwnPropertySymbols, RV = Object.prototype.hasOwnProperty, DV = Object.prototype.propertyIsEnumerable, N3 = (t, e, r) => e in t ? IV(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, tn = (t, e) => { - for (var r in e || (e = {})) RV.call(e, r) && N3(t, r, e[r]); - if (O3) for (var r of O3(e)) DV.call(e, r) && N3(t, r, e[r]); - return t; -}, vs = (t, e) => CV(t, TV(e)); -class OV extends Jk { - constructor(e) { - super(e), this.name = wV, this.events = new Lv(), this.initialized = !1, this.requestQueue = { state: Ls.idle, queue: [] }, this.sessionRequestQueue = { state: Ls.idle, queue: [] }, this.requestQueueDelay = mt.ONE_SECOND, this.expectedPairingMethodMap = /* @__PURE__ */ new Map(), this.recentlyDeletedMap = /* @__PURE__ */ 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(In) }), this.initialized = !0, setTimeout(() => { - this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); - }, mt.toMiliseconds(this.requestQueueDelay))); - }, this.connect = async (r) => { - this.isInitialized(), await this.confirmOnlineStateOrThrow(); - const n = vs(tn({}, r), { requiredNamespaces: r.requiredNamespaces || {}, optionalNamespaces: r.optionalNamespaces || {} }); - await this.isValidConnect(n); - const { pairingTopic: i, requiredNamespaces: s, optionalNamespaces: o, sessionProperties: a, relays: u } = n; - let l = i, d, g = !1; - try { - l && (g = this.client.core.pairing.pairings.get(l).active); - } catch (H) { - throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`), H; - } - if (!l || !g) { - const { topic: H, uri: V } = await this.client.core.pairing.create(); - l = H, d = V; - } - if (!l) { - const { message: H } = ft("NO_MATCHING_KEY", `connect() pairing topic: ${l}`); - throw new Error(H); - } - const w = await this.client.core.crypto.generateKeyPair(), A = In.wc_sessionPropose.req.ttl || mt.FIVE_MINUTES, M = En(A), N = tn({ requiredNamespaces: s, optionalNamespaces: o, relays: u ?? [{ protocol: nE }], proposer: { publicKey: w, metadata: this.client.metadata }, expiryTimestamp: M, pairingTopic: l }, a && { sessionProperties: a }), { reject: L, resolve: F, done: $ } = Va(A, yE); - this.events.once(br("session_connect"), async ({ error: H, session: V }) => { - if (H) L(H); - else if (V) { - V.self.publicKey = w; - const te = vs(tn({}, V), { pairingTopic: N.pairingTopic, requiredNamespaces: N.requiredNamespaces, optionalNamespaces: N.optionalNamespaces, transportType: zr.relay }); - await this.client.session.set(V.topic, te), await this.setExpiry(V.topic, V.expiry), l && await this.client.core.pairing.updateMetadata({ topic: l, metadata: V.peer.metadata }), this.cleanupDuplicatePairings(te), F(te); - } - }); - const K = await this.sendRequest({ topic: l, method: "wc_sessionPropose", params: N, throwOnFailedPublish: !0 }); - return await this.setProposal(K, tn({ id: K }, N)), { uri: d, approval: $ }; - }, this.pair = async (r) => { - this.isInitialized(), await this.confirmOnlineStateOrThrow(); - try { - return await this.client.core.pairing.pair(r); - } catch (n) { - throw this.client.logger.error("pair() failed"), n; - } - }, this.approve = async (r) => { - var n, i, s; - const o = this.client.core.eventClient.createEvent({ properties: { topic: (n = r == null ? void 0 : r.id) == null ? void 0 : n.toString(), trace: [ms.session_approve_started] } }); - try { - this.isInitialized(), await this.confirmOnlineStateOrThrow(); - } catch (W) { - throw o.setError(Ha.no_internet_connection), W; - } - try { - await this.isValidProposalId(r == null ? void 0 : r.id); - } catch (W) { - throw this.client.logger.error(`approve() -> proposal.get(${r == null ? void 0 : r.id}) failed`), o.setError(Ha.proposal_not_found), W; - } - try { - await this.isValidApprove(r); - } catch (W) { - throw this.client.logger.error("approve() -> isValidApprove() failed"), o.setError(Ha.session_approve_namespace_validation_failure), W; - } - const { id: a, relayProtocol: u, namespaces: l, sessionProperties: d, sessionConfig: g } = r, w = this.client.proposal.get(a); - this.client.core.eventClient.deleteEvent({ eventId: o.eventId }); - const { pairingTopic: A, proposer: M, requiredNamespaces: N, optionalNamespaces: L } = w; - let F = (i = this.client.core.eventClient) == null ? void 0 : i.getEvent({ topic: A }); - F || (F = (s = this.client.core.eventClient) == null ? void 0 : s.createEvent({ type: ms.session_approve_started, properties: { topic: A, trace: [ms.session_approve_started, ms.session_namespaces_validation_success] } })); - const $ = await this.client.core.crypto.generateKeyPair(), K = M.publicKey, H = await this.client.core.crypto.generateSharedKey($, K), V = tn(tn({ relay: { protocol: u ?? "irn" }, namespaces: l, controller: { publicKey: $, metadata: this.client.metadata }, expiry: En(Wc) }, d && { sessionProperties: d }), g && { sessionConfig: g }), te = zr.relay; - F.addTrace(ms.subscribing_session_topic); - try { - await this.client.core.relayer.subscribe(H, { transportType: te }); - } catch (W) { - throw F.setError(Ha.subscribe_session_topic_failure), W; - } - F.addTrace(ms.subscribe_session_topic_success); - const R = vs(tn({}, V), { topic: H, requiredNamespaces: N, optionalNamespaces: L, pairingTopic: A, acknowledged: !1, self: V.controller, peer: { publicKey: M.publicKey, metadata: M.metadata }, controller: $, transportType: zr.relay }); - await this.client.session.set(H, R), F.addTrace(ms.store_session); - try { - F.addTrace(ms.publishing_session_settle), await this.sendRequest({ topic: H, method: "wc_sessionSettle", params: V, throwOnFailedPublish: !0 }).catch((W) => { - throw F == null || F.setError(Ha.session_settle_publish_failure), W; - }), F.addTrace(ms.session_settle_publish_success), F.addTrace(ms.publishing_session_approve), await this.sendResult({ id: a, topic: A, result: { relay: { protocol: u ?? "irn" }, responderPublicKey: $ }, throwOnFailedPublish: !0 }).catch((W) => { - throw F == null || F.setError(Ha.session_approve_publish_failure), W; - }), F.addTrace(ms.session_approve_publish_success); - } catch (W) { - throw this.client.logger.error(W), this.client.session.delete(H, Or("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(H), W; - } - return this.client.core.eventClient.deleteEvent({ eventId: F.eventId }), await this.client.core.pairing.updateMetadata({ topic: A, metadata: M.metadata }), await this.client.proposal.delete(a, Or("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: A }), await this.setExpiry(H, En(Wc)), { topic: H, acknowledged: () => Promise.resolve(this.client.session.get(H)) }; - }, 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; - } - const { id: n, reason: i } = r; - let s; - try { - s = this.client.proposal.get(n).pairingTopic; - } catch (o) { - throw this.client.logger.error(`reject() -> proposal.get(${n}) failed`), o; - } - s && (await this.sendError({ id: n, topic: s, error: i, rpcOpts: In.wc_sessionPropose.reject }), await this.client.proposal.delete(n, Or("USER_DISCONNECTED"))); - }, this.update = async (r) => { - this.isInitialized(), await this.confirmOnlineStateOrThrow(); - try { - await this.isValidUpdate(r); - } catch (g) { - throw this.client.logger.error("update() -> isValidUpdate() failed"), g; - } - const { topic: n, namespaces: i } = r, { done: s, resolve: o, reject: a } = Va(), u = ca(), l = rc().toString(), d = this.client.session.get(n).namespaces; - return this.events.once(br("session_update", u), ({ error: g }) => { - g ? a(g) : o(); - }), await this.client.session.update(n, { namespaces: i }), await this.sendRequest({ topic: n, method: "wc_sessionUpdate", params: { namespaces: i }, throwOnFailedPublish: !0, clientRpcId: u, relayRpcId: l }).catch((g) => { - this.client.logger.error(g), this.client.session.update(n, { namespaces: d }), a(g); - }), { acknowledged: s }; - }, this.extend = async (r) => { - this.isInitialized(), await this.confirmOnlineStateOrThrow(); - try { - await this.isValidExtend(r); - } catch (u) { - throw this.client.logger.error("extend() -> isValidExtend() failed"), u; - } - const { topic: n } = r, i = ca(), { done: s, resolve: o, reject: a } = Va(); - return this.events.once(br("session_extend", i), ({ error: u }) => { - u ? a(u) : o(); - }), await this.setExpiry(n, En(Wc)), this.sendRequest({ topic: n, method: "wc_sessionExtend", params: {}, clientRpcId: i, throwOnFailedPublish: !0 }).catch((u) => { - a(u); - }), { acknowledged: s }; - }, this.request = async (r) => { - this.isInitialized(); - try { - await this.isValidRequest(r); - } catch (M) { - throw this.client.logger.error("request() -> isValidRequest() failed"), M; - } - const { chainId: n, request: i, topic: s, expiry: o = In.wc_sessionRequest.req.ttl } = r, a = this.client.session.get(s); - (a == null ? void 0 : a.transportType) === zr.relay && await this.confirmOnlineStateOrThrow(); - const u = ca(), l = rc().toString(), { done: d, resolve: g, reject: w } = Va(o, "Request expired. Please try again."); - this.events.once(br("session_request", u), ({ error: M, result: N }) => { - M ? w(M) : g(N); - }); - const A = this.getAppLinkIfEnabled(a.peer.metadata, a.transportType); - return A ? (await this.sendRequest({ clientRpcId: u, relayRpcId: l, topic: s, method: "wc_sessionRequest", params: { request: vs(tn({}, i), { expiryTimestamp: En(o) }), chainId: n }, expiry: o, throwOnFailedPublish: !0, appLink: A }).catch((M) => w(M)), this.client.events.emit("session_request_sent", { topic: s, request: i, chainId: n, id: u }), await d()) : await Promise.all([new Promise(async (M) => { - await this.sendRequest({ clientRpcId: u, relayRpcId: l, topic: s, method: "wc_sessionRequest", params: { request: vs(tn({}, i), { expiryTimestamp: En(o) }), chainId: n }, expiry: o, throwOnFailedPublish: !0 }).catch((N) => w(N)), this.client.events.emit("session_request_sent", { topic: s, request: i, chainId: n, id: u }), M(); - }), new Promise(async (M) => { - var N; - if (!((N = a.sessionConfig) != null && N.disableDeepLink)) { - const L = await Fq(this.client.core.storage, D3); - await kq({ id: u, topic: s, wcDeepLink: L }); - } - M(); - }), d()]).then((M) => M[2]); - }, this.respond = async (r) => { - this.isInitialized(), await this.isValidRespond(r); - const { topic: n, response: i } = r, { id: s } = i, o = this.client.session.get(n); - o.transportType === zr.relay && await this.confirmOnlineStateOrThrow(); - const a = this.getAppLinkIfEnabled(o.peer.metadata, o.transportType); - Bs(i) ? await this.sendResult({ id: s, topic: n, result: i.result, throwOnFailedPublish: !0, appLink: a }) : Zi(i) && await this.sendError({ id: s, topic: n, error: i.error, appLink: a }), this.cleanupAfterResponse(r); - }, this.ping = async (r) => { - this.isInitialized(), await this.confirmOnlineStateOrThrow(); - try { - await this.isValidPing(r); - } catch (i) { - throw this.client.logger.error("ping() -> isValidPing() failed"), i; - } - const { topic: n } = r; - if (this.client.session.keys.includes(n)) { - const i = ca(), s = rc().toString(), { done: o, resolve: a, reject: u } = Va(); - this.events.once(br("session_ping", i), ({ error: l }) => { - l ? u(l) : a(); - }), await Promise.all([this.sendRequest({ topic: n, method: "wc_sessionPing", params: {}, throwOnFailedPublish: !0, clientRpcId: i, relayRpcId: s }), o()]); - } else this.client.core.pairing.pairings.keys.includes(n) && await this.client.core.pairing.ping({ topic: n }); - }, this.emit = async (r) => { - this.isInitialized(), await this.confirmOnlineStateOrThrow(), await this.isValidEmit(r); - const { topic: n, event: i, chainId: s } = r, o = rc().toString(); - await this.sendRequest({ topic: n, method: "wc_sessionEvent", params: { event: i, chainId: s }, throwOnFailedPublish: !0, relayRpcId: o }); - }, this.disconnect = async (r) => { - this.isInitialized(), await this.confirmOnlineStateOrThrow(), await this.isValidDisconnect(r); - const { topic: n } = r; - if (this.client.session.keys.includes(n)) await this.sendRequest({ topic: n, method: "wc_sessionDelete", params: Or("USER_DISCONNECTED"), throwOnFailedPublish: !0 }), await this.deleteSession({ topic: n, emitEvent: !1 }); - else if (this.client.core.pairing.pairings.keys.includes(n)) await this.client.core.pairing.disconnect({ topic: n }); - else { - const { message: i } = ft("MISMATCHED_TOPIC", `Session or pairing topic not found: ${n}`); - throw new Error(i); - } - }, this.find = (r) => (this.isInitialized(), this.client.session.getAll().filter((n) => Fz(n, r))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.authenticate = async (r, n) => { - var i; - this.isInitialized(), this.isValidAuthenticate(r); - const s = n && this.client.core.linkModeSupportedApps.includes(n) && ((i = this.client.metadata.redirect) == null ? void 0 : i.linkMode), o = s ? zr.link_mode : zr.relay; - o === zr.relay && await this.confirmOnlineStateOrThrow(); - const { chains: a, statement: u = "", uri: l, domain: d, nonce: g, type: w, exp: A, nbf: M, methods: N = [], expiry: L } = r, F = [...r.resources || []], { topic: $, uri: K } = await this.client.core.pairing.create({ methods: ["wc_sessionAuthenticate"], transportType: o }); - this.client.logger.info({ message: "Generated new pairing", pairing: { topic: $, uri: K } }); - const H = await this.client.core.crypto.generateKeyPair(), V = Cd(H); - if (await Promise.all([this.client.auth.authKeys.set(Td, { responseTopic: V, publicKey: H }), this.client.auth.pairingTopics.set(V, { topic: V, pairingTopic: $ })]), await this.client.core.relayer.subscribe(V, { transportType: o }), this.client.logger.info(`sending request to new pairing topic: ${$}`), N.length > 0) { - const { namespace: _ } = lu(a[0]); - let E = sz(_, "request", N); - Id(F) && (E = az(E, F.pop())), F.push(E); - } - const te = L && L > In.wc_sessionAuthenticate.req.ttl ? L : In.wc_sessionAuthenticate.req.ttl, R = { authPayload: { type: w ?? "caip122", chains: a, statement: u, aud: l, domain: d, version: "1", nonce: g, iat: (/* @__PURE__ */ new Date()).toISOString(), exp: A, nbf: M, resources: F }, requester: { publicKey: H, metadata: this.client.metadata }, expiryTimestamp: En(te) }, W = { eip155: { chains: a, methods: [.../* @__PURE__ */ new Set(["personal_sign", ...N])], events: ["chainChanged", "accountsChanged"] } }, pe = { requiredNamespaces: {}, optionalNamespaces: W, relays: [{ protocol: "irn" }], pairingTopic: $, proposer: { publicKey: H, metadata: this.client.metadata }, expiryTimestamp: En(In.wc_sessionPropose.req.ttl) }, { done: Ee, resolve: Y, reject: S } = Va(te, "Request expired"), m = async ({ error: _, session: E }) => { - if (this.events.off(br("session_request", p), f), _) S(_); - else if (E) { - E.self.publicKey = H, await this.client.session.set(E.topic, E), await this.setExpiry(E.topic, E.expiry), $ && await this.client.core.pairing.updateMetadata({ topic: $, metadata: E.peer.metadata }); - const v = this.client.session.get(E.topic); - await this.deleteProposal(b), Y({ session: v }); - } - }, f = async (_) => { - var E, v, P; - if (await this.deletePendingAuthRequest(p, { message: "fulfilled", code: 0 }), _.error) { - const J = Or("WC_METHOD_UNSUPPORTED", "wc_sessionAuthenticate"); - return _.error.code === J.code ? void 0 : (this.events.off(br("session_connect"), m), S(_.error.message)); - } - await this.deleteProposal(b), this.events.off(br("session_connect"), m); - const { cacaos: I, responder: B } = _.result, ce = [], D = []; - for (const J of I) { - await jx({ cacao: J, projectId: this.client.core.projectId }) || (this.client.logger.error(J, "Signature verification failed"), S(Or("SESSION_SETTLEMENT_FAILED", "Signature verification failed"))); - const { p: Q } = J, T = Id(Q.resources), X = [M1(Q.iss)], re = c0(Q.iss); - if (T) { - const de = qx(T), ie = zx(T); - ce.push(...de), X.push(...ie); - } - for (const de of X) D.push(`${de}:${re}`); - } - const oe = await this.client.core.crypto.generateSharedKey(H, B.publicKey); - let Z; - ce.length > 0 && (Z = { topic: oe, acknowledged: !0, self: { publicKey: H, metadata: this.client.metadata }, peer: B, controller: B.publicKey, expiry: En(Wc), requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: $, namespaces: Zx([...new Set(ce)], [...new Set(D)]), transportType: o }, await this.client.core.relayer.subscribe(oe, { transportType: o }), await this.client.session.set(oe, Z), $ && await this.client.core.pairing.updateMetadata({ topic: $, metadata: B.metadata }), Z = this.client.session.get(oe)), (E = this.client.metadata.redirect) != null && E.linkMode && (v = B.metadata.redirect) != null && v.linkMode && (P = B.metadata.redirect) != null && P.universal && n && (this.client.core.addLinkModeSupportedApp(B.metadata.redirect.universal), this.client.session.update(oe, { transportType: zr.link_mode })), Y({ auths: I, session: Z }); - }, p = ca(), b = ca(); - this.events.once(br("session_connect"), m), this.events.once(br("session_request", p), f); - let x; - try { - if (s) { - const _ = ha("wc_sessionAuthenticate", R, p); - this.client.core.history.set($, _); - const E = await this.client.core.crypto.encode("", _, { type: eh, encoding: Sf }); - x = ud(n, $, E); - } else await Promise.all([this.sendRequest({ topic: $, method: "wc_sessionAuthenticate", params: R, expiry: r.expiry, throwOnFailedPublish: !0, clientRpcId: p }), this.sendRequest({ topic: $, method: "wc_sessionPropose", params: pe, expiry: In.wc_sessionPropose.req.ttl, throwOnFailedPublish: !0, clientRpcId: b })]); - } catch (_) { - throw this.events.off(br("session_connect"), m), this.events.off(br("session_request", p), f), _; - } - return await this.setProposal(b, tn({ id: b }, pe)), await this.setAuthRequest(p, { request: vs(tn({}, R), { verifyContext: {} }), pairingTopic: $, transportType: o }), { uri: x ?? K, response: Ee }; - }, this.approveSessionAuthenticate = async (r) => { - const { id: n, auths: i } = r, s = this.client.core.eventClient.createEvent({ properties: { topic: n.toString(), trace: [Wa.authenticated_session_approve_started] } }); - try { - this.isInitialized(); - } catch (L) { - throw s.setError(Mf.no_internet_connection), L; - } - const o = this.getPendingAuthRequest(n); - if (!o) throw s.setError(Mf.authenticated_session_pending_request_not_found), new Error(`Could not find pending auth request with id ${n}`); - const a = o.transportType || zr.relay; - a === zr.relay && await this.confirmOnlineStateOrThrow(); - const u = o.requester.publicKey, l = await this.client.core.crypto.generateKeyPair(), d = Cd(u), g = { type: Io, receiverPublicKey: u, senderPublicKey: l }, w = [], A = []; - for (const L of i) { - if (!await jx({ cacao: L, projectId: this.client.core.projectId })) { - s.setError(Mf.invalid_cacao); - const V = Or("SESSION_SETTLEMENT_FAILED", "Signature verification failed"); - throw await this.sendError({ id: n, topic: d, error: V, encodeOpts: g }), new Error(V.message); - } - s.addTrace(Wa.cacaos_verified); - const { p: F } = L, $ = Id(F.resources), K = [M1(F.iss)], H = c0(F.iss); - if ($) { - const V = qx($), te = zx($); - w.push(...V), K.push(...te); - } - for (const V of K) A.push(`${V}:${H}`); - } - const M = await this.client.core.crypto.generateSharedKey(l, u); - s.addTrace(Wa.create_authenticated_session_topic); - let N; - if ((w == null ? void 0 : w.length) > 0) { - N = { topic: M, acknowledged: !0, self: { publicKey: l, metadata: this.client.metadata }, peer: { publicKey: u, metadata: o.requester.metadata }, controller: u, expiry: En(Wc), authentication: i, requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: o.pairingTopic, namespaces: Zx([...new Set(w)], [...new Set(A)]), transportType: a }, s.addTrace(Wa.subscribing_authenticated_session_topic); - try { - await this.client.core.relayer.subscribe(M, { transportType: a }); - } catch (L) { - throw s.setError(Mf.subscribe_authenticated_session_topic_failure), L; - } - s.addTrace(Wa.subscribe_authenticated_session_topic_success), await this.client.session.set(M, N), s.addTrace(Wa.store_authenticated_session), await this.client.core.pairing.updateMetadata({ topic: o.pairingTopic, metadata: o.requester.metadata }); - } - s.addTrace(Wa.publishing_authenticated_session_approve); - try { - await this.sendResult({ topic: d, id: n, result: { cacaos: i, responder: { publicKey: l, metadata: this.client.metadata } }, encodeOpts: g, throwOnFailedPublish: !0, appLink: this.getAppLinkIfEnabled(o.requester.metadata, a) }); - } catch (L) { - throw s.setError(Mf.authenticated_session_approve_publish_failure), L; - } - return await this.client.auth.requests.delete(n, { message: "fulfilled", code: 0 }), await this.client.core.pairing.activate({ topic: o.pairingTopic }), this.client.core.eventClient.deleteEvent({ eventId: s.eventId }), { session: N }; - }, this.rejectSessionAuthenticate = async (r) => { - this.isInitialized(); - const { id: n, reason: i } = r, s = this.getPendingAuthRequest(n); - if (!s) throw new Error(`Could not find pending auth request with id ${n}`); - s.transportType === zr.relay && await this.confirmOnlineStateOrThrow(); - const o = s.requester.publicKey, a = await this.client.core.crypto.generateKeyPair(), u = Cd(o), l = { type: Io, receiverPublicKey: o, senderPublicKey: a }; - await this.sendError({ id: n, topic: u, error: i, encodeOpts: l, rpcOpts: In.wc_sessionAuthenticate.reject, appLink: this.getAppLinkIfEnabled(s.requester.metadata, s.transportType) }), await this.client.auth.requests.delete(n, { message: "rejected", code: 0 }), await this.client.proposal.delete(n, Or("USER_DISCONNECTED")); - }, this.formatAuthMessage = (r) => { - this.isInitialized(); - const { request: n, iss: i } = r; - return B8(n, i); - }, this.processRelayMessageCache = () => { - setTimeout(async () => { - if (this.relayMessageCache.length !== 0) for (; this.relayMessageCache.length > 0; ) try { - const 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 { - const n = this.client.core.pairing.pairings.get(r.pairingTopic), i = 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) === r.peer.metadata.url && s.topic && s.topic !== n.topic; - }); - if (i.length === 0) return; - this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`), await Promise.all(i.map((s) => this.client.core.pairing.disconnect({ topic: s.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); - } catch (n) { - this.client.logger.error(n); - } - }, this.deleteSession = async (r) => { - var n; - const { topic: i, expirerHasDeleted: s = !1, emitEvent: o = !0, id: a = 0 } = r, { self: u } = this.client.session.get(i); - await this.client.core.relayer.unsubscribe(i), await this.client.session.delete(i, Or("USER_DISCONNECTED")), this.addToRecentlyDeleted(i, "session"), this.client.core.crypto.keychain.has(u.publicKey) && await this.client.core.crypto.deleteKeyPair(u.publicKey), this.client.core.crypto.keychain.has(i) && await this.client.core.crypto.deleteSymKey(i), s || this.client.core.expirer.del(i), this.client.core.storage.removeItem(D3).catch((l) => this.client.logger.warn(l)), this.getPendingSessionRequests().forEach((l) => { - l.topic === i && this.deletePendingSessionRequest(l.id, Or("USER_DISCONNECTED")); - }), i === ((n = this.sessionRequestQueue.queue[0]) == null ? void 0 : n.topic) && (this.sessionRequestQueue.state = Ls.idle), o && this.client.events.emit("session_delete", { id: a, topic: i }); - }, this.deleteProposal = async (r, n) => { - if (n) try { - const i = this.client.proposal.get(r), s = this.client.core.eventClient.getEvent({ topic: i.pairingTopic }); - s == null || s.setError(Ha.proposal_expired); - } catch { - } - await Promise.all([this.client.proposal.delete(r, Or("USER_DISCONNECTED")), n ? Promise.resolve() : this.client.core.expirer.del(r)]), this.addToRecentlyDeleted(r, "proposal"); - }, this.deletePendingSessionRequest = async (r, n, i = !1) => { - await Promise.all([this.client.pendingRequest.delete(r, n), i ? Promise.resolve() : this.client.core.expirer.del(r)]), this.addToRecentlyDeleted(r, "request"), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((s) => s.id !== r), i && (this.sessionRequestQueue.state = Ls.idle, this.client.events.emit("session_request_expire", { id: r })); - }, this.deletePendingAuthRequest = async (r, n, i = !1) => { - await Promise.all([this.client.auth.requests.delete(r, n), i ? Promise.resolve() : this.client.core.expirer.del(r)]); - }, this.setExpiry = async (r, n) => { - this.client.session.keys.includes(r) && (this.client.core.expirer.set(r, n), await this.client.session.update(r, { expiry: n })); - }, this.setProposal = async (r, n) => { - this.client.core.expirer.set(r, En(In.wc_sessionPropose.req.ttl)), await this.client.proposal.set(r, n); - }, this.setAuthRequest = async (r, n) => { - const { request: i, pairingTopic: s, transportType: o = zr.relay } = n; - this.client.core.expirer.set(r, i.expiryTimestamp), await this.client.auth.requests.set(r, { authPayload: i.authPayload, requester: i.requester, expiryTimestamp: i.expiryTimestamp, id: r, pairingTopic: s, verifyContext: i.verifyContext, transportType: o }); - }, this.setPendingSessionRequest = async (r) => { - const { id: n, topic: i, params: s, verifyContext: o } = r, a = s.request.expiryTimestamp || En(In.wc_sessionRequest.req.ttl); - this.client.core.expirer.set(n, a), await this.client.pendingRequest.set(n, { id: n, topic: i, params: s, verifyContext: o }); - }, this.sendRequest = async (r) => { - const { topic: n, method: i, params: s, expiry: o, relayRpcId: a, clientRpcId: u, throwOnFailedPublish: l, appLink: d } = r, g = ha(i, s, u); - let w; - const A = !!d; - try { - const L = A ? Sf : la; - w = await this.client.core.crypto.encode(n, g, { encoding: L }); - } catch (L) { - throw await this.cleanup(), this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${n} failed`), L; - } - let M; - if (_V.includes(i)) { - const L = wo(JSON.stringify(g)), F = wo(w); - M = await this.client.core.verify.register({ id: F, decryptedId: L }); - } - const N = In[i].req; - if (N.attestation = M, o && (N.ttl = o), a && (N.id = a), this.client.core.history.set(n, g), A) { - const L = ud(d, n, w); - await global.Linking.openURL(L, this.client.name); - } else { - const L = In[i].req; - o && (L.ttl = o), a && (L.id = a), l ? (L.internal = vs(tn({}, L.internal), { throwOnFailedPublish: !0 }), await this.client.core.relayer.publish(n, w, L)) : this.client.core.relayer.publish(n, w, L).catch((F) => this.client.logger.error(F)); - } - return g.id; - }, this.sendResult = async (r) => { - const { id: n, topic: i, result: s, throwOnFailedPublish: o, encodeOpts: a, appLink: u } = r, l = tp(n, s); - let d; - const g = u && typeof (global == null ? void 0 : global.Linking) < "u"; - try { - const A = g ? Sf : la; - d = await this.client.core.crypto.encode(i, l, vs(tn({}, a || {}), { encoding: A })); - } catch (A) { - throw await this.cleanup(), this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`), A; - } - let w; - try { - w = await this.client.core.history.get(i, n); - } catch (A) { - throw this.client.logger.error(`sendResult() -> history.get(${i}, ${n}) failed`), A; - } - if (g) { - const A = ud(u, i, d); - await global.Linking.openURL(A, this.client.name); - } else { - const A = In[w.request.method].res; - o ? (A.internal = vs(tn({}, A.internal), { throwOnFailedPublish: !0 }), await this.client.core.relayer.publish(i, d, A)) : this.client.core.relayer.publish(i, d, A).catch((M) => this.client.logger.error(M)); - } - await this.client.core.history.resolve(l); - }, this.sendError = async (r) => { - const { id: n, topic: i, error: s, encodeOpts: o, rpcOpts: a, appLink: u } = r, l = rp(n, s); - let d; - const g = u && typeof (global == null ? void 0 : global.Linking) < "u"; - try { - const A = g ? Sf : la; - d = await this.client.core.crypto.encode(i, l, vs(tn({}, o || {}), { encoding: A })); - } catch (A) { - throw await this.cleanup(), this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`), A; - } - let w; - try { - w = await this.client.core.history.get(i, n); - } catch (A) { - throw this.client.logger.error(`sendError() -> history.get(${i}, ${n}) failed`), A; - } - if (g) { - const A = ud(u, i, d); - await global.Linking.openURL(A, this.client.name); - } else { - const A = a || In[w.request.method].res; - this.client.core.relayer.publish(i, d, A); - } - await this.client.core.history.resolve(l); - }, this.cleanup = async () => { - const r = [], n = []; - this.client.session.getAll().forEach((i) => { - let s = !1; - aa(i.expiry) && (s = !0), this.client.core.crypto.keychain.has(i.topic) || (s = !0), s && r.push(i.topic); - }), this.client.proposal.getAll().forEach((i) => { - aa(i.expiryTimestamp) && n.push(i.id); - }), await Promise.all([...r.map((i) => this.deleteSession({ topic: i })), ...n.map((i) => this.deleteProposal(i))]); - }, this.onRelayEventRequest = async (r) => { - this.requestQueue.queue.push(r), await this.processRequestsQueue(); - }, this.processRequestsQueue = async () => { - if (this.requestQueue.state === Ls.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 = Ls.active; - const r = this.requestQueue.queue.shift(); - if (r) try { - await this.processRequest(r); - } catch (n) { - this.client.logger.warn(n); - } - } - this.requestQueue.state = Ls.idle; - }, this.processRequest = async (r) => { - const { topic: n, payload: i, attestation: s, transportType: o, encryptedId: a } = r, u = i.method; - if (!this.shouldIgnorePairingRequest({ topic: n, requestMethod: u })) switch (u) { - case "wc_sessionPropose": - return await this.onSessionProposeRequest({ topic: n, payload: i, attestation: s, encryptedId: a }); - case "wc_sessionSettle": - return await this.onSessionSettleRequest(n, i); - case "wc_sessionUpdate": - return await this.onSessionUpdateRequest(n, i); - case "wc_sessionExtend": - return await this.onSessionExtendRequest(n, i); - case "wc_sessionPing": - return await this.onSessionPingRequest(n, i); - case "wc_sessionDelete": - return await this.onSessionDeleteRequest(n, i); - case "wc_sessionRequest": - return await this.onSessionRequest({ topic: n, payload: i, attestation: s, encryptedId: a, transportType: o }); - case "wc_sessionEvent": - return await this.onSessionEventRequest(n, i); - case "wc_sessionAuthenticate": - return await this.onSessionAuthenticateRequest({ topic: n, payload: i, attestation: s, encryptedId: a, transportType: o }); - default: - return this.client.logger.info(`Unsupported request method ${u}`); - } - }, this.onRelayEventResponse = async (r) => { - const { topic: n, payload: i, transportType: s } = r, o = (await this.client.core.history.get(n, i.id)).request.method; - switch (o) { - case "wc_sessionPropose": - return this.onSessionProposeResponse(n, i, s); - case "wc_sessionSettle": - return this.onSessionSettleResponse(n, i); - case "wc_sessionUpdate": - return this.onSessionUpdateResponse(n, i); - case "wc_sessionExtend": - return this.onSessionExtendResponse(n, i); - case "wc_sessionPing": - return this.onSessionPingResponse(n, i); - case "wc_sessionRequest": - return this.onSessionRequestResponse(n, i); - case "wc_sessionAuthenticate": - return this.onSessionAuthenticateResponse(n, i); - default: - return this.client.logger.info(`Unsupported response method ${o}`); - } - }, this.onRelayEventUnknownPayload = (r) => { - const { topic: n } = r, { message: i } = ft("MISSING_OR_INVALID", `Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`); - throw new Error(i); - }, this.shouldIgnorePairingRequest = (r) => { - const { topic: n, requestMethod: i } = r, s = this.expectedPairingMethodMap.get(n); - return !s || s.includes(i) ? !1 : !!(s.includes("wc_sessionAuthenticate") && this.client.events.listenerCount("session_authenticate") > 0); - }, this.onSessionProposeRequest = async (r) => { - const { topic: n, payload: i, attestation: s, encryptedId: o } = r, { params: a, id: u } = i; - try { - const l = this.client.core.eventClient.getEvent({ topic: n }); - this.isValidConnect(tn({}, i.params)); - const d = a.expiryTimestamp || En(In.wc_sessionPropose.req.ttl), g = tn({ id: u, pairingTopic: n, expiryTimestamp: d }, a); - await this.setProposal(u, g); - const w = await this.getVerifyContext({ attestationId: s, hash: wo(JSON.stringify(i)), encryptedId: o, metadata: g.proposer.metadata }); - this.client.events.listenerCount("session_proposal") === 0 && (console.warn("No listener for session_proposal event"), l == null || l.setError(yo.proposal_listener_not_found)), l == null || l.addTrace(Fs.emit_session_proposal), this.client.events.emit("session_proposal", { id: u, params: g, verifyContext: w }); - } catch (l) { - await this.sendError({ id: u, topic: n, error: l, rpcOpts: In.wc_sessionPropose.autoReject }), this.client.logger.error(l); - } - }, this.onSessionProposeResponse = async (r, n, i) => { - const { id: s } = n; - if (Bs(n)) { - const { result: o } = n; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: o }); - const a = this.client.proposal.get(s); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: a }); - const u = a.proposer.publicKey; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: u }); - const l = o.responderPublicKey; - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: l }); - const d = await this.client.core.crypto.generateSharedKey(u, l); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: d }); - const g = await this.client.core.relayer.subscribe(d, { transportType: i }); - this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: g }), await this.client.core.pairing.activate({ topic: r }); - } else if (Zi(n)) { - await this.client.proposal.delete(s, Or("USER_DISCONNECTED")); - const o = br("session_connect"); - if (this.events.listenerCount(o) === 0) throw new Error(`emitting ${o} without any listeners, 954`); - this.events.emit(br("session_connect"), { error: n.error }); - } - }, this.onSessionSettleRequest = async (r, n) => { - const { id: i, params: s } = n; - try { - this.isValidSessionSettleRequest(s); - const { relay: o, controller: a, expiry: u, namespaces: l, sessionProperties: d, sessionConfig: g } = n.params, w = vs(tn(tn({ topic: r, relay: o, expiry: u, namespaces: l, acknowledged: !0, pairingTopic: "", requiredNamespaces: {}, optionalNamespaces: {}, controller: a.publicKey, self: { publicKey: "", metadata: this.client.metadata }, peer: { publicKey: a.publicKey, metadata: a.metadata } }, d && { sessionProperties: d }), g && { sessionConfig: g }), { transportType: zr.relay }), A = br("session_connect"); - if (this.events.listenerCount(A) === 0) throw new Error(`emitting ${A} without any listeners 997`); - this.events.emit(br("session_connect"), { session: w }), await this.sendResult({ id: n.id, topic: r, result: !0, throwOnFailedPublish: !0 }); - } catch (o) { - await this.sendError({ id: i, topic: r, error: o }), this.client.logger.error(o); - } - }, this.onSessionSettleResponse = async (r, n) => { - const { id: i } = n; - Bs(n) ? (await this.client.session.update(r, { acknowledged: !0 }), this.events.emit(br("session_approve", i), {})) : Zi(n) && (await this.client.session.delete(r, Or("USER_DISCONNECTED")), this.events.emit(br("session_approve", i), { error: n.error })); - }, this.onSessionUpdateRequest = async (r, n) => { - const { params: i, id: s } = n; - try { - const o = `${r}_session_update`, a = Af.get(o); - if (a && this.isRequestOutOfSync(a, s)) { - this.client.logger.info(`Discarding out of sync request - ${s}`), this.sendError({ id: s, topic: r, error: Or("INVALID_UPDATE_REQUEST") }); - return; - } - this.isValidUpdate(tn({ topic: r }, i)); - try { - Af.set(o, s), await this.client.session.update(r, { namespaces: i.namespaces }), await this.sendResult({ id: s, topic: r, result: !0, throwOnFailedPublish: !0 }); - } catch (u) { - throw Af.delete(o), u; - } - this.client.events.emit("session_update", { id: s, topic: r, params: i }); - } catch (o) { - await this.sendError({ id: s, topic: r, error: o }), this.client.logger.error(o); - } - }, this.isRequestOutOfSync = (r, n) => parseInt(n.toString().slice(0, -3)) <= parseInt(r.toString().slice(0, -3)), this.onSessionUpdateResponse = (r, n) => { - const { id: i } = n, s = br("session_update", i); - if (this.events.listenerCount(s) === 0) throw new Error(`emitting ${s} without any listeners`); - Bs(n) ? this.events.emit(br("session_update", i), {}) : Zi(n) && this.events.emit(br("session_update", i), { error: n.error }); - }, this.onSessionExtendRequest = async (r, n) => { - const { id: i } = n; - try { - this.isValidExtend({ topic: r }), await this.setExpiry(r, En(Wc)), await this.sendResult({ id: i, topic: r, result: !0, throwOnFailedPublish: !0 }), this.client.events.emit("session_extend", { id: i, topic: r }); - } catch (s) { - await this.sendError({ id: i, topic: r, error: s }), this.client.logger.error(s); - } - }, this.onSessionExtendResponse = (r, n) => { - const { id: i } = n, s = br("session_extend", i); - if (this.events.listenerCount(s) === 0) throw new Error(`emitting ${s} without any listeners`); - Bs(n) ? this.events.emit(br("session_extend", i), {}) : Zi(n) && this.events.emit(br("session_extend", i), { error: n.error }); - }, this.onSessionPingRequest = async (r, n) => { - const { id: i } = n; - try { - this.isValidPing({ topic: r }), await this.sendResult({ id: i, topic: r, result: !0, throwOnFailedPublish: !0 }), this.client.events.emit("session_ping", { id: i, topic: r }); - } catch (s) { - await this.sendError({ id: i, topic: r, error: s }), this.client.logger.error(s); - } - }, this.onSessionPingResponse = (r, n) => { - const { id: i } = n, s = br("session_ping", i); - if (this.events.listenerCount(s) === 0) throw new Error(`emitting ${s} without any listeners`); - setTimeout(() => { - Bs(n) ? this.events.emit(br("session_ping", i), {}) : Zi(n) && this.events.emit(br("session_ping", i), { error: n.error }); - }, 500); - }, this.onSessionDeleteRequest = async (r, n) => { - const { id: i } = n; - try { - this.isValidDisconnect({ topic: r, reason: n.params }), Promise.all([new Promise((s) => { - this.client.core.relayer.once(si.publish, async () => { - s(await this.deleteSession({ topic: r, id: i })); - }); - }), this.sendResult({ id: i, topic: r, result: !0, throwOnFailedPublish: !0 }), this.cleanupPendingSentRequestsForTopic({ topic: r, error: Or("USER_DISCONNECTED") })]).catch((s) => this.client.logger.error(s)); - } catch (s) { - this.client.logger.error(s); - } - }, this.onSessionRequest = async (r) => { - var n, i, s; - const { topic: o, payload: a, attestation: u, encryptedId: l, transportType: d } = r, { id: g, params: w } = a; - try { - await this.isValidRequest(tn({ topic: o }, w)); - const A = this.client.session.get(o), M = await this.getVerifyContext({ attestationId: u, hash: wo(JSON.stringify(ha("wc_sessionRequest", w, g))), encryptedId: l, metadata: A.peer.metadata, transportType: d }), N = { id: g, topic: o, params: w, verifyContext: M }; - await this.setPendingSessionRequest(N), d === zr.link_mode && (n = A.peer.metadata.redirect) != null && n.universal && this.client.core.addLinkModeSupportedApp((i = A.peer.metadata.redirect) == null ? void 0 : i.universal), (s = this.client.signConfig) != null && s.disableRequestQueue ? this.emitSessionRequest(N) : (this.addSessionRequestToSessionRequestQueue(N), this.processSessionRequestQueue()); - } catch (A) { - await this.sendError({ id: g, topic: o, error: A }), this.client.logger.error(A); - } - }, this.onSessionRequestResponse = (r, n) => { - const { id: i } = n, s = br("session_request", i); - if (this.events.listenerCount(s) === 0) throw new Error(`emitting ${s} without any listeners`); - Bs(n) ? this.events.emit(br("session_request", i), { result: n.result }) : Zi(n) && this.events.emit(br("session_request", i), { error: n.error }); - }, this.onSessionEventRequest = async (r, n) => { - const { id: i, params: s } = n; - try { - const o = `${r}_session_event_${s.event.name}`, a = Af.get(o); - if (a && this.isRequestOutOfSync(a, i)) { - this.client.logger.info(`Discarding out of sync request - ${i}`); - return; - } - this.isValidEmit(tn({ topic: r }, s)), this.client.events.emit("session_event", { id: i, topic: r, params: s }), Af.set(o, i); - } catch (o) { - await this.sendError({ id: i, topic: r, error: o }), this.client.logger.error(o); - } - }, this.onSessionAuthenticateResponse = (r, n) => { - const { id: i } = n; - this.client.logger.trace({ type: "method", method: "onSessionAuthenticateResponse", topic: r, payload: n }), Bs(n) ? this.events.emit(br("session_request", i), { result: n.result }) : Zi(n) && this.events.emit(br("session_request", i), { error: n.error }); - }, this.onSessionAuthenticateRequest = async (r) => { - var n; - const { topic: i, payload: s, attestation: o, encryptedId: a, transportType: u } = r; - try { - const { requester: l, authPayload: d, expiryTimestamp: g } = s.params, w = await this.getVerifyContext({ attestationId: o, hash: wo(JSON.stringify(s)), encryptedId: a, metadata: l.metadata, transportType: u }), A = { requester: l, pairingTopic: i, id: s.id, authPayload: d, verifyContext: w, expiryTimestamp: g }; - await this.setAuthRequest(s.id, { request: A, pairingTopic: i, transportType: u }), u === zr.link_mode && (n = l.metadata.redirect) != null && n.universal && this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal), this.client.events.emit("session_authenticate", { topic: i, params: s.params, id: s.id, verifyContext: w }); - } catch (l) { - this.client.logger.error(l); - const d = s.params.requester.publicKey, g = await this.client.core.crypto.generateKeyPair(), w = this.getAppLinkIfEnabled(s.params.requester.metadata, u), A = { type: Io, receiverPublicKey: d, senderPublicKey: g }; - await this.sendError({ id: s.id, topic: i, error: l, encodeOpts: A, rpcOpts: In.wc_sessionAuthenticate.autoReject, appLink: w }); - } - }, this.addSessionRequestToSessionRequestQueue = (r) => { - this.sessionRequestQueue.queue.push(r); - }, this.cleanupAfterResponse = (r) => { - this.deletePendingSessionRequest(r.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { - this.sessionRequestQueue.state = Ls.idle, this.processSessionRequestQueue(); - }, mt.toMiliseconds(this.requestQueueDelay)); - }, this.cleanupPendingSentRequestsForTopic = ({ topic: r, error: n }) => { - const i = this.client.core.history.pending; - i.length > 0 && i.filter((s) => s.topic === r && s.request.method === "wc_sessionRequest").forEach((s) => { - const o = s.request.id, a = br("session_request", o); - if (this.events.listenerCount(a) === 0) throw new Error(`emitting ${a} without any listeners`); - this.events.emit(br("session_request", s.request.id), { error: n }); - }); - }, this.processSessionRequestQueue = () => { - if (this.sessionRequestQueue.state === Ls.active) { - this.client.logger.info("session request queue is already active."); - return; - } - const r = this.sessionRequestQueue.queue[0]; - if (!r) { - this.client.logger.info("session request queue is empty."); - return; - } - try { - this.sessionRequestQueue.state = Ls.active, this.emitSessionRequest(r); - } catch (n) { - this.client.logger.error(n); - } - }, 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; - const n = this.client.proposal.getAll().find((i) => i.pairingTopic === r.topic); - n && this.onSessionProposeRequest({ topic: r.topic, payload: ha("wc_sessionPropose", { requiredNamespaces: n.requiredNamespaces, optionalNamespaces: n.optionalNamespaces, relays: n.relays, proposer: n.proposer, sessionProperties: n.sessionProperties }, n.id) }); - }, this.isValidConnect = async (r) => { - if (!pi(r)) { - const { message: u } = ft("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(r)}`); - throw new Error(u); - } - const { pairingTopic: n, requiredNamespaces: i, optionalNamespaces: s, sessionProperties: o, relays: a } = r; - if (gi(n) || await this.isValidPairingTopic(n), !Jz(a)) { - const { message: u } = ft("MISSING_OR_INVALID", `connect() relays: ${a}`); - throw new Error(u); - } - !gi(i) && El(i) !== 0 && this.validateNamespaces(i, "requiredNamespaces"), !gi(s) && El(s) !== 0 && this.validateNamespaces(s, "optionalNamespaces"), gi(o) || this.validateSessionProps(o, "sessionProperties"); - }, this.validateNamespaces = (r, n) => { - const i = Yz(r, "connect()", n); - if (i) throw new Error(i.message); - }, this.isValidApprove = async (r) => { - if (!pi(r)) throw new Error(ft("MISSING_OR_INVALID", `approve() params: ${r}`).message); - const { id: n, namespaces: i, relayProtocol: s, sessionProperties: o } = r; - this.checkRecentlyDeleted(n), await this.isValidProposalId(n); - const a = this.client.proposal.get(n), u = hm(i, "approve()"); - if (u) throw new Error(u.message); - const l = t3(a.requiredNamespaces, i, "approve()"); - if (l) throw new Error(l.message); - if (!dn(s, !0)) { - const { message: d } = ft("MISSING_OR_INVALID", `approve() relayProtocol: ${s}`); - throw new Error(d); - } - gi(o) || this.validateSessionProps(o, "sessionProperties"); - }, this.isValidReject = async (r) => { - if (!pi(r)) { - const { message: s } = ft("MISSING_OR_INVALID", `reject() params: ${r}`); - throw new Error(s); - } - const { id: n, reason: i } = r; - if (this.checkRecentlyDeleted(n), await this.isValidProposalId(n), !Zz(i)) { - const { message: s } = ft("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(i)}`); - throw new Error(s); - } - }, this.isValidSessionSettleRequest = (r) => { - if (!pi(r)) { - const { message: l } = ft("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${r}`); - throw new Error(l); - } - const { relay: n, controller: i, namespaces: s, expiry: o } = r; - if (!V8(n)) { - const { message: l } = ft("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); - throw new Error(l); - } - const a = zz(i, "onSessionSettleRequest()"); - if (a) throw new Error(a.message); - const u = hm(s, "onSessionSettleRequest()"); - if (u) throw new Error(u.message); - if (aa(o)) { - const { message: l } = ft("EXPIRED", "onSessionSettleRequest()"); - throw new Error(l); - } - }, this.isValidUpdate = async (r) => { - if (!pi(r)) { - const { message: u } = ft("MISSING_OR_INVALID", `update() params: ${r}`); - throw new Error(u); - } - const { topic: n, namespaces: i } = r; - this.checkRecentlyDeleted(n), await this.isValidSessionTopic(n); - const s = this.client.session.get(n), o = hm(i, "update()"); - if (o) throw new Error(o.message); - const a = t3(s.requiredNamespaces, i, "update()"); - if (a) throw new Error(a.message); - }, this.isValidExtend = async (r) => { - if (!pi(r)) { - const { message: i } = ft("MISSING_OR_INVALID", `extend() params: ${r}`); - throw new Error(i); - } - const { topic: n } = r; - this.checkRecentlyDeleted(n), await this.isValidSessionTopic(n); - }, this.isValidRequest = async (r) => { - if (!pi(r)) { - const { message: u } = ft("MISSING_OR_INVALID", `request() params: ${r}`); - throw new Error(u); - } - const { topic: n, request: i, chainId: s, expiry: o } = r; - this.checkRecentlyDeleted(n), await this.isValidSessionTopic(n); - const { namespaces: a } = this.client.session.get(n); - if (!e3(a, s)) { - const { message: u } = ft("MISSING_OR_INVALID", `request() chainId: ${s}`); - throw new Error(u); - } - if (!Qz(i)) { - const { message: u } = ft("MISSING_OR_INVALID", `request() ${JSON.stringify(i)}`); - throw new Error(u); - } - if (!rH(a, s, i.method)) { - const { message: u } = ft("MISSING_OR_INVALID", `request() method: ${i.method}`); - throw new Error(u); - } - if (o && !oH(o, vm)) { - const { message: u } = ft("MISSING_OR_INVALID", `request() expiry: ${o}. Expiry must be a number (in seconds) between ${vm.min} and ${vm.max}`); - throw new Error(u); - } - }, this.isValidRespond = async (r) => { - var n; - if (!pi(r)) { - const { message: o } = ft("MISSING_OR_INVALID", `respond() params: ${r}`); - throw new Error(o); - } - const { topic: i, response: s } = r; - try { - await this.isValidSessionTopic(i); - } catch (o) { - throw (n = r == null ? void 0 : r.response) != null && n.id && this.cleanupAfterResponse(r), o; - } - if (!eH(s)) { - const { message: o } = ft("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(s)}`); - throw new Error(o); - } - }, this.isValidPing = async (r) => { - if (!pi(r)) { - const { message: i } = ft("MISSING_OR_INVALID", `ping() params: ${r}`); - throw new Error(i); - } - const { topic: n } = r; - await this.isValidSessionOrPairingTopic(n); - }, this.isValidEmit = async (r) => { - if (!pi(r)) { - const { message: a } = ft("MISSING_OR_INVALID", `emit() params: ${r}`); - throw new Error(a); - } - const { topic: n, event: i, chainId: s } = r; - await this.isValidSessionTopic(n); - const { namespaces: o } = this.client.session.get(n); - if (!e3(o, s)) { - const { message: a } = ft("MISSING_OR_INVALID", `emit() chainId: ${s}`); - throw new Error(a); - } - if (!tH(i)) { - const { message: a } = ft("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(i)}`); - throw new Error(a); - } - if (!nH(o, s, i.name)) { - const { message: a } = ft("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(i)}`); - throw new Error(a); - } - }, this.isValidDisconnect = async (r) => { - if (!pi(r)) { - const { message: i } = ft("MISSING_OR_INVALID", `disconnect() params: ${r}`); - throw new Error(i); - } - const { topic: n } = r; - await this.isValidSessionOrPairingTopic(n); - }, this.isValidAuthenticate = (r) => { - const { chains: n, uri: i, domain: s, nonce: o } = r; - if (!Array.isArray(n) || n.length === 0) throw new Error("chains is required and must be a non-empty array"); - if (!dn(i, !1)) throw new Error("uri is required parameter"); - if (!dn(s, !1)) throw new Error("domain is required parameter"); - if (!dn(o, !1)) throw new Error("nonce is required parameter"); - if ([...new Set(n.map((u) => lu(u).namespace))].length > 1) throw new Error("Multi-namespace requests are not supported. Please request single namespace only."); - const { namespace: a } = lu(n[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) => { - const { attestationId: n, hash: i, encryptedId: s, metadata: o, transportType: a } = r, u = { verified: { verifyUrl: o.verifyUrl || zf, validation: "UNKNOWN", origin: o.url || "" } }; - try { - if (a === zr.link_mode) { - const d = this.getAppLinkIfEnabled(o, a); - return u.verified.validation = d && new URL(d).origin === new URL(o.url).origin ? "VALID" : "INVALID", u; - } - const l = await this.client.core.verify.resolve({ attestationId: n, hash: i, encryptedId: s, verifyUrl: o.verifyUrl }); - l && (u.verified.origin = l.origin, u.verified.isScam = l.isScam, u.verified.validation = l.origin === new URL(o.url).origin ? "VALID" : "INVALID"); - } catch (l) { - this.client.logger.warn(l); - } - return this.client.logger.debug(`Verify context: ${JSON.stringify(u)}`), u; - }, this.validateSessionProps = (r, n) => { - Object.values(r).forEach((i) => { - if (!dn(i, !1)) { - const { message: s } = ft("MISSING_OR_INVALID", `${n} must be in Record format. Received: ${JSON.stringify(i)}`); - throw new Error(s); - } - }); - }, this.getPendingAuthRequest = (r) => { - const n = this.client.auth.requests.get(r); - return typeof n == "object" ? n : void 0; - }, this.addToRecentlyDeleted = (r, n) => { - if (this.recentlyDeletedMap.set(r, n), this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) { - let i = 0; - const s = this.recentlyDeletedLimit / 2; - for (const o of this.recentlyDeletedMap.keys()) { - if (i++ >= s) break; - this.recentlyDeletedMap.delete(o); - } - } - }, this.checkRecentlyDeleted = (r) => { - const n = this.recentlyDeletedMap.get(r); - if (n) { - const { message: i } = ft("MISSING_OR_INVALID", `Record was recently deleted - ${n}: ${r}`); - throw new Error(i); - } - }, this.isLinkModeEnabled = (r, n) => { - var i, s, o, a, u, l, d, g, w; - return !r || n !== zr.link_mode ? !1 : ((s = (i = this.client.metadata) == null ? void 0 : i.redirect) == null ? void 0 : s.linkMode) === !0 && ((a = (o = this.client.metadata) == null ? void 0 : o.redirect) == null ? void 0 : a.universal) !== void 0 && ((l = (u = this.client.metadata) == null ? void 0 : u.redirect) == null ? void 0 : l.universal) !== "" && ((d = r == null ? void 0 : r.redirect) == null ? void 0 : d.universal) !== void 0 && ((g = r == null ? void 0 : r.redirect) == null ? void 0 : g.universal) !== "" && ((w = r == null ? void 0 : r.redirect) == null ? void 0 : w.linkMode) === !0 && this.client.core.linkModeSupportedApps.includes(r.redirect.universal) && typeof (global == null ? void 0 : global.Linking) < "u"; - }, this.getAppLinkIfEnabled = (r, n) => { - var i; - return this.isLinkModeEnabled(r, n) ? (i = r == null ? void 0 : r.redirect) == null ? void 0 : i.universal : void 0; - }, this.handleLinkModeMessage = ({ url: r }) => { - if (!r || !r.includes("wc_ev") || !r.includes("topic")) return; - const n = $x(r, "topic") || "", i = decodeURIComponent($x(r, "wc_ev") || ""), s = this.client.session.keys.includes(n); - s && this.client.session.update(n, { transportType: zr.link_mode }), this.client.core.dispatchEnvelope({ topic: n, message: i, sessionExists: s }); - }, this.registerLinkModeListeners = async () => { - var r; - if (nb() || ju() && (r = this.client.metadata.redirect) != null && r.linkMode) { - const n = global == null ? void 0 : global.Linking; - if (typeof n < "u") { - n.addEventListener("url", this.handleLinkModeMessage, this.client.name); - const i = await n.getInitialURL(); - i && setTimeout(() => { - this.handleLinkModeMessage({ url: i }); - }, 50); - } - } - }; - } - isInitialized() { - if (!this.initialized) { - const { message: e } = ft("NOT_INITIALIZED", this.name); - throw new Error(e); - } - } - async confirmOnlineStateOrThrow() { - await this.client.core.relayer.confirmOnlineStateOrThrow(); - } - registerRelayerEvents() { - this.client.core.relayer.on(si.message, (e) => { - !this.initialized || this.relayMessageCache.length > 0 ? this.relayMessageCache.push(e) : this.onRelayMessage(e); - }); - } - async onRelayMessage(e) { - const { topic: r, message: n, attestation: i, transportType: s } = e, { publicKey: o } = this.client.auth.authKeys.keys.includes(Td) ? this.client.auth.authKeys.get(Td) : { publicKey: void 0 }, a = await this.client.core.crypto.decode(r, n, { receiverPublicKey: o, encoding: s === zr.link_mode ? Sf : la }); - try { - ub(a) ? (this.client.core.history.set(r, a), this.onRelayEventRequest({ topic: r, payload: a, attestation: i, transportType: s, encryptedId: wo(n) })) : np(a) ? (await this.client.core.history.resolve(a), await this.onRelayEventResponse({ topic: r, payload: a, transportType: s }), this.client.core.history.delete(r, a.id)) : this.onRelayEventUnknownPayload({ topic: r, payload: a, transportType: s }); - } catch (u) { - this.client.logger.error(u); - } - } - registerExpirerEvents() { - this.client.core.expirer.on(Ji.expired, async (e) => { - const { topic: r, id: n } = $8(e.target); - if (n && this.client.pendingRequest.keys.includes(n)) return await this.deletePendingSessionRequest(n, ft("EXPIRED"), !0); - if (n && this.client.auth.requests.keys.includes(n)) return await this.deletePendingAuthRequest(n, ft("EXPIRED"), !0); - r ? this.client.session.keys.includes(r) && (await this.deleteSession({ topic: r, expirerHasDeleted: !0 }), this.client.events.emit("session_expire", { topic: r })) : n && (await this.deleteProposal(n, !0), this.client.events.emit("proposal_expire", { id: n })); - }); - } - registerPairingEvents() { - this.client.core.pairing.events.on(Xa.create, (e) => this.onPairingCreated(e)), this.client.core.pairing.events.on(Xa.delete, (e) => { - this.addToRecentlyDeleted(e.topic, "pairing"); - }); - } - isValidPairingTopic(e) { - if (!dn(e, !1)) { - const { message: r } = ft("MISSING_OR_INVALID", `pairing topic should be a string: ${e}`); - throw new Error(r); - } - if (!this.client.core.pairing.pairings.keys.includes(e)) { - const { message: r } = ft("NO_MATCHING_KEY", `pairing topic doesn't exist: ${e}`); - throw new Error(r); - } - if (aa(this.client.core.pairing.pairings.get(e).expiry)) { - const { message: r } = ft("EXPIRED", `pairing topic: ${e}`); - throw new Error(r); - } - } - async isValidSessionTopic(e) { - if (!dn(e, !1)) { - const { message: r } = ft("MISSING_OR_INVALID", `session topic should be a string: ${e}`); - throw new Error(r); - } - if (this.checkRecentlyDeleted(e), !this.client.session.keys.includes(e)) { - const { message: r } = ft("NO_MATCHING_KEY", `session topic doesn't exist: ${e}`); - throw new Error(r); - } - if (aa(this.client.session.get(e).expiry)) { - await this.deleteSession({ topic: e }); - const { message: r } = ft("EXPIRED", `session topic: ${e}`); - throw new Error(r); - } - if (!this.client.core.crypto.keychain.has(e)) { - const { message: r } = ft("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 (dn(e, !1)) { - const { message: r } = ft("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${e}`); - throw new Error(r); - } else { - const { message: r } = ft("MISSING_OR_INVALID", `session or pairing topic should be a string: ${e}`); - throw new Error(r); - } - } - async isValidProposalId(e) { - if (!Xz(e)) { - const { message: r } = ft("MISSING_OR_INVALID", `proposal id should be a number: ${e}`); - throw new Error(r); - } - if (!this.client.proposal.keys.includes(e)) { - const { message: r } = ft("NO_MATCHING_KEY", `proposal id doesn't exist: ${e}`); - throw new Error(r); - } - if (aa(this.client.proposal.get(e).expiryTimestamp)) { - await this.deleteProposal(e); - const { message: r } = ft("EXPIRED", `proposal id: ${e}`); - throw new Error(r); - } - } -} -class NV extends _c { - constructor(e, r) { - super(e, r, bV, lb), this.core = e, this.logger = r; - } -} -let LV = class extends _c { - constructor(e, r) { - super(e, r, yV, lb), this.core = e, this.logger = r; - } -}; -class kV extends _c { - constructor(e, r) { - super(e, r, xV, lb, (n) => n.id), this.core = e, this.logger = r; - } -} -class $V extends _c { - constructor(e, r) { - super(e, r, AV, sp, () => Td), this.core = e, this.logger = r; - } -} -class FV extends _c { - constructor(e, r) { - super(e, r, PV, sp), this.core = e, this.logger = r; - } -} -class BV extends _c { - constructor(e, r) { - super(e, r, MV, sp, (n) => n.id), this.core = e, this.logger = r; - } -} -class UV { - constructor(e, r) { - this.core = e, this.logger = r, this.authKeys = new $V(this.core, this.logger), this.pairingTopics = new FV(this.core, this.logger), this.requests = new BV(this.core, this.logger); - } - async init() { - await this.authKeys.init(), await this.pairingTopics.init(), await this.requests.init(); - } -} -class hb extends Yk { - constructor(e) { - super(e), this.protocol = mE, this.version = vE, this.name = mm.name, this.events = new rs.EventEmitter(), this.on = (n, i) => this.events.on(n, i), this.once = (n, i) => this.events.once(n, i), this.off = (n, i) => this.events.off(n, i), this.removeListener = (n, i) => this.events.removeListener(n, i), this.removeAllListeners = (n) => this.events.removeAllListeners(n), this.connect = async (n) => { - try { - return await this.engine.connect(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.pair = async (n) => { - try { - return await this.engine.pair(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.approve = async (n) => { - try { - return await this.engine.approve(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.reject = async (n) => { - try { - return await this.engine.reject(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.update = async (n) => { - try { - return await this.engine.update(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.extend = async (n) => { - try { - return await this.engine.extend(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.request = async (n) => { - try { - return await this.engine.request(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.respond = async (n) => { - try { - return await this.engine.respond(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.ping = async (n) => { - try { - return await this.engine.ping(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.emit = async (n) => { - try { - return await this.engine.emit(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.disconnect = async (n) => { - try { - return await this.engine.disconnect(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.find = (n) => { - try { - return this.engine.find(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.getPendingSessionRequests = () => { - try { - return this.engine.getPendingSessionRequests(); - } catch (n) { - throw this.logger.error(n.message), n; - } - }, this.authenticate = async (n, i) => { - try { - return await this.engine.authenticate(n, i); - } catch (s) { - throw this.logger.error(s.message), s; - } - }, this.formatAuthMessage = (n) => { - try { - return this.engine.formatAuthMessage(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.approveSessionAuthenticate = async (n) => { - try { - return await this.engine.approveSessionAuthenticate(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.rejectSessionAuthenticate = async (n) => { - try { - return await this.engine.rejectSessionAuthenticate(n); - } catch (i) { - throw this.logger.error(i.message), i; - } - }, this.name = (e == null ? void 0 : e.name) || mm.name, this.metadata = (e == null ? void 0 : e.metadata) || D8(), this.signConfig = e == null ? void 0 : e.signConfig; - const r = typeof (e == null ? void 0 : e.logger) < "u" && typeof (e == null ? void 0 : e.logger) != "string" ? e.logger : jl(k0({ level: (e == null ? void 0 : e.logger) || mm.logger })); - this.core = (e == null ? void 0 : e.core) || new vV(e), this.logger = ai(r, this.name), this.session = new LV(this.core, this.logger), this.proposal = new NV(this.core, this.logger), this.pendingRequest = new kV(this.core, this.logger), this.engine = new OV(this), this.auth = new UV(this.core, this.logger); - } - static async init(e) { - const r = new hb(e); - return await r.initialize(), r; - } - get context() { - return Si(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 l0 = { exports: {} }; -/** - * @license - * Lodash - * Copyright OpenJS Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ -l0.exports; -(function(t, e) { - (function() { - var r, n = "4.17.21", i = 200, s = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", o = "Expected a function", a = "Invalid `variable` option passed into `_.template`", u = "__lodash_hash_undefined__", l = 500, d = "__lodash_placeholder__", g = 1, w = 2, A = 4, M = 1, N = 2, L = 1, F = 2, $ = 4, K = 8, H = 16, V = 32, te = 64, R = 128, W = 256, pe = 512, Ee = 30, Y = "...", S = 800, m = 16, f = 1, p = 2, b = 3, x = 1 / 0, _ = 9007199254740991, E = 17976931348623157e292, v = NaN, P = 4294967295, I = P - 1, B = P >>> 1, ce = [ - ["ary", R], - ["bind", L], - ["bindKey", F], - ["curry", K], - ["curryRight", H], - ["flip", pe], - ["partial", V], - ["partialRight", te], - ["rearg", W] - ], D = "[object Arguments]", oe = "[object Array]", Z = "[object AsyncFunction]", J = "[object Boolean]", Q = "[object Date]", T = "[object DOMException]", X = "[object Error]", re = "[object Function]", de = "[object GeneratorFunction]", ie = "[object Map]", ue = "[object Number]", ve = "[object Null]", Pe = "[object Object]", De = "[object Promise]", Ce = "[object Proxy]", $e = "[object RegExp]", Me = "[object Set]", Ne = "[object String]", Ke = "[object Symbol]", Le = "[object Undefined]", qe = "[object WeakMap]", ze = "[object WeakSet]", _e = "[object ArrayBuffer]", Ze = "[object DataView]", at = "[object Float32Array]", ke = "[object Float64Array]", Qe = "[object Int8Array]", tt = "[object Int16Array]", Ye = "[object Int32Array]", dt = "[object Uint8Array]", lt = "[object Uint8ClampedArray]", ct = "[object Uint16Array]", qt = "[object Uint32Array]", Yt = /\b__p \+= '';/g, Et = /\b(__p \+=) '' \+/g, Qt = /(__e\(.*?\)|\b__t\)) \+\n'';/g, Jt = /&(?:amp|lt|gt|quot|#39);/g, Dt = /[&<>"']/g, kt = RegExp(Jt.source), Ct = RegExp(Dt.source), gt = /<%-([\s\S]+?)%>/g, Rt = /<%([\s\S]+?)%>/g, Nt = /<%=([\s\S]+?)%>/g, vt = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, $t = /^\w*$/, Bt = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, rt = /[\\^$.*+?()[\]{}|]/g, Ft = RegExp(rt.source), k = /^\s+/, j = /\s/, z = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, C = /\{\n\/\* \[wrapped with (.+)\] \*/, G = /,? & /, U = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, se = /[()=,{}\[\]\/\s]/, he = /\\(\\)?/g, xe = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g, Te = /\w*$/, Re = /^[-+]0x[0-9a-f]+$/i, nt = /^0b[01]+$/i, Ue = /^\[object .+?Constructor\]$/, pt = /^0o[0-7]+$/i, it = /^(?:0|[1-9]\d*)$/, et = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, St = /($^)/, Tt = /['\n\r\u2028\u2029\\]/g, At = "\\ud800-\\udfff", _t = "\\u0300-\\u036f", ht = "\\ufe20-\\ufe2f", xt = "\\u20d0-\\u20ff", st = _t + ht + xt, bt = "\\u2700-\\u27bf", ut = "a-z\\xdf-\\xf6\\xf8-\\xff", ot = "\\xac\\xb1\\xd7\\xf7", Se = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Ae = "\\u2000-\\u206f", Ve = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", Be = "A-Z\\xc0-\\xd6\\xd8-\\xde", je = "\\ufe0e\\ufe0f", Je = ot + Se + Ae + Ve, Lt = "['’]", zt = "[" + At + "]", Xt = "[" + Je + "]", Ht = "[" + st + "]", le = "\\d+", tr = "[" + bt + "]", dr = "[" + ut + "]", pr = "[^" + At + Je + le + bt + ut + Be + "]", Zt = "\\ud83c[\\udffb-\\udfff]", gr = "(?:" + Ht + "|" + Zt + ")", lr = "[^" + At + "]", Rr = "(?:\\ud83c[\\udde6-\\uddff]){2}", mr = "[\\ud800-\\udbff][\\udc00-\\udfff]", yr = "[" + Be + "]", $r = "\\u200d", Fr = "(?:" + dr + "|" + pr + ")", Ir = "(?:" + yr + "|" + pr + ")", nn = "(?:" + Lt + "(?:d|ll|m|re|s|t|ve))?", sn = "(?:" + Lt + "(?:D|LL|M|RE|S|T|VE))?", on = gr + "?", fh = "[" + je + "]?", Rp = "(?:" + $r + "(?:" + [lr, Rr, mr].join("|") + ")" + fh + on + ")*", no = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", lh = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", hh = fh + on + Rp, Pc = "(?:" + [tr, Rr, mr].join("|") + ")" + hh, Dp = "(?:" + [lr + Ht + "?", Ht, Rr, mr, zt].join("|") + ")", Ju = RegExp(Lt, "g"), Op = RegExp(Ht, "g"), Mc = RegExp(Zt + "(?=" + Zt + ")|" + Dp + hh, "g"), dh = RegExp([ - yr + "?" + dr + "+" + nn + "(?=" + [Xt, yr, "$"].join("|") + ")", - Ir + "+" + sn + "(?=" + [Xt, yr + Fr, "$"].join("|") + ")", - yr + "?" + Fr + "+" + nn, - yr + "+" + sn, - lh, - no, - le, - Pc - ].join("|"), "g"), ph = RegExp("[" + $r + At + st + je + "]"), Ra = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/, gh = [ - "Array", - "Buffer", - "DataView", - "Date", - "Error", - "Float32Array", - "Float64Array", - "Function", - "Int8Array", - "Int16Array", - "Int32Array", - "Map", - "Math", - "Object", - "Promise", - "RegExp", - "Set", - "String", - "Symbol", - "TypeError", - "Uint8Array", - "Uint8ClampedArray", - "Uint16Array", - "Uint32Array", - "WeakMap", - "_", - "clearTimeout", - "isFinite", - "parseInt", - "setTimeout" - ], Np = -1, Br = {}; - Br[at] = Br[ke] = Br[Qe] = Br[tt] = Br[Ye] = Br[dt] = Br[lt] = Br[ct] = Br[qt] = !0, Br[D] = Br[oe] = Br[_e] = Br[J] = Br[Ze] = Br[Q] = Br[X] = Br[re] = Br[ie] = Br[ue] = Br[Pe] = Br[$e] = Br[Me] = Br[Ne] = Br[qe] = !1; - var Dr = {}; - Dr[D] = Dr[oe] = Dr[_e] = Dr[Ze] = Dr[J] = Dr[Q] = Dr[at] = Dr[ke] = Dr[Qe] = Dr[tt] = Dr[Ye] = Dr[ie] = Dr[ue] = Dr[Pe] = Dr[$e] = Dr[Me] = Dr[Ne] = Dr[Ke] = Dr[dt] = Dr[lt] = Dr[ct] = Dr[qt] = !0, Dr[X] = Dr[re] = Dr[qe] = !1; - var ae = { - // Latin-1 Supplement block. - À: "A", - Á: "A", - Â: "A", - Ã: "A", - Ä: "A", - Å: "A", - à: "a", - á: "a", - â: "a", - ã: "a", - ä: "a", - å: "a", - Ç: "C", - ç: "c", - Ð: "D", - ð: "d", - È: "E", - É: "E", - Ê: "E", - Ë: "E", - è: "e", - é: "e", - ê: "e", - ë: "e", - Ì: "I", - Í: "I", - Î: "I", - Ï: "I", - ì: "i", - í: "i", - î: "i", - ï: "i", - Ñ: "N", - ñ: "n", - Ò: "O", - Ó: "O", - Ô: "O", - Õ: "O", - Ö: "O", - Ø: "O", - ò: "o", - ó: "o", - ô: "o", - õ: "o", - ö: "o", - ø: "o", - Ù: "U", - Ú: "U", - Û: "U", - Ü: "U", - ù: "u", - ú: "u", - û: "u", - ü: "u", - Ý: "Y", - ý: "y", - ÿ: "y", - Æ: "Ae", - æ: "ae", - Þ: "Th", - þ: "th", - ß: "ss", - // Latin Extended-A block. - Ā: "A", - Ă: "A", - Ą: "A", - ā: "a", - ă: "a", - ą: "a", - Ć: "C", - Ĉ: "C", - Ċ: "C", - Č: "C", - ć: "c", - ĉ: "c", - ċ: "c", - č: "c", - Ď: "D", - Đ: "D", - ď: "d", - đ: "d", - Ē: "E", - Ĕ: "E", - Ė: "E", - Ę: "E", - Ě: "E", - ē: "e", - ĕ: "e", - ė: "e", - ę: "e", - ě: "e", - Ĝ: "G", - Ğ: "G", - Ġ: "G", - Ģ: "G", - ĝ: "g", - ğ: "g", - ġ: "g", - ģ: "g", - Ĥ: "H", - Ħ: "H", - ĥ: "h", - ħ: "h", - Ĩ: "I", - Ī: "I", - Ĭ: "I", - Į: "I", - İ: "I", - ĩ: "i", - ī: "i", - ĭ: "i", - į: "i", - ı: "i", - Ĵ: "J", - ĵ: "j", - Ķ: "K", - ķ: "k", - ĸ: "k", - Ĺ: "L", - Ļ: "L", - Ľ: "L", - Ŀ: "L", - Ł: "L", - ĺ: "l", - ļ: "l", - ľ: "l", - ŀ: "l", - ł: "l", - Ń: "N", - Ņ: "N", - Ň: "N", - Ŋ: "N", - ń: "n", - ņ: "n", - ň: "n", - ŋ: "n", - Ō: "O", - Ŏ: "O", - Ő: "O", - ō: "o", - ŏ: "o", - ő: "o", - Ŕ: "R", - Ŗ: "R", - Ř: "R", - ŕ: "r", - ŗ: "r", - ř: "r", - Ś: "S", - Ŝ: "S", - Ş: "S", - Š: "S", - ś: "s", - ŝ: "s", - ş: "s", - š: "s", - Ţ: "T", - Ť: "T", - Ŧ: "T", - ţ: "t", - ť: "t", - ŧ: "t", - Ũ: "U", - Ū: "U", - Ŭ: "U", - Ů: "U", - Ű: "U", - Ų: "U", - ũ: "u", - ū: "u", - ŭ: "u", - ů: "u", - ű: "u", - ų: "u", - Ŵ: "W", - ŵ: "w", - Ŷ: "Y", - ŷ: "y", - Ÿ: "Y", - Ź: "Z", - Ż: "Z", - Ž: "Z", - ź: "z", - ż: "z", - ž: "z", - IJ: "IJ", - ij: "ij", - Œ: "Oe", - œ: "oe", - ʼn: "'n", - ſ: "s" - }, ye = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'" - }, Ge = { - "&": "&", - "<": "<", - ">": ">", - """: '"', - "'": "'" - }, Pt = { - "\\": "\\", - "'": "'", - "\n": "n", - "\r": "r", - "\u2028": "u2028", - "\u2029": "u2029" - }, Ur = parseFloat, rr = parseInt, Kr = typeof gn == "object" && gn && gn.Object === Object && gn, vn = typeof self == "object" && self && self.Object === Object && self, _r = Kr || vn || Function("return this")(), jr = e && !e.nodeType && e, an = jr && !0 && t && !t.nodeType && t, ci = an && an.exports === jr, bn = ci && Kr.process, Vr = function() { - try { - var be = an && an.require && an.require("util").types; - return be || bn && bn.binding && bn.binding("util"); - } catch { - } - }(), ei = Vr && Vr.isArrayBuffer, us = Vr && Vr.isDate, Bi = Vr && Vr.isMap, Ms = Vr && Vr.isRegExp, Xu = Vr && Vr.isSet, Da = Vr && Vr.isTypedArray; - function Pn(be, Fe, Ie) { - switch (Ie.length) { - case 0: - return be.call(Fe); - case 1: - return be.call(Fe, Ie[0]); - case 2: - return be.call(Fe, Ie[0], Ie[1]); - case 3: - return be.call(Fe, Ie[0], Ie[1], Ie[2]); - } - return be.apply(Fe, Ie); - } - function K9(be, Fe, Ie, It) { - for (var er = -1, Pr = be == null ? 0 : be.length; ++er < Pr; ) { - var xn = be[er]; - Fe(It, xn, Ie(xn), be); - } - return It; - } - function Ui(be, Fe) { - for (var Ie = -1, It = be == null ? 0 : be.length; ++Ie < It && Fe(be[Ie], Ie, be) !== !1; ) - ; - return be; - } - function V9(be, Fe) { - for (var Ie = be == null ? 0 : be.length; Ie-- && Fe(be[Ie], Ie, be) !== !1; ) - ; - return be; - } - function dy(be, Fe) { - for (var Ie = -1, It = be == null ? 0 : be.length; ++Ie < It; ) - if (!Fe(be[Ie], Ie, be)) - return !1; - return !0; - } - function zo(be, Fe) { - for (var Ie = -1, It = be == null ? 0 : be.length, er = 0, Pr = []; ++Ie < It; ) { - var xn = be[Ie]; - Fe(xn, Ie, be) && (Pr[er++] = xn); - } - return Pr; - } - function mh(be, Fe) { - var Ie = be == null ? 0 : be.length; - return !!Ie && Ic(be, Fe, 0) > -1; - } - function Lp(be, Fe, Ie) { - for (var It = -1, er = be == null ? 0 : be.length; ++It < er; ) - if (Ie(Fe, be[It])) - return !0; - return !1; - } - function Xr(be, Fe) { - for (var Ie = -1, It = be == null ? 0 : be.length, er = Array(It); ++Ie < It; ) - er[Ie] = Fe(be[Ie], Ie, be); - return er; - } - function Ho(be, Fe) { - for (var Ie = -1, It = Fe.length, er = be.length; ++Ie < It; ) - be[er + Ie] = Fe[Ie]; - return be; - } - function kp(be, Fe, Ie, It) { - var er = -1, Pr = be == null ? 0 : be.length; - for (It && Pr && (Ie = be[++er]); ++er < Pr; ) - Ie = Fe(Ie, be[er], er, be); - return Ie; - } - function G9(be, Fe, Ie, It) { - var er = be == null ? 0 : be.length; - for (It && er && (Ie = be[--er]); er--; ) - Ie = Fe(Ie, be[er], er, be); - return Ie; - } - function $p(be, Fe) { - for (var Ie = -1, It = be == null ? 0 : be.length; ++Ie < It; ) - if (Fe(be[Ie], Ie, be)) - return !0; - return !1; - } - var Y9 = Fp("length"); - function J9(be) { - return be.split(""); - } - function X9(be) { - return be.match(U) || []; - } - function py(be, Fe, Ie) { - var It; - return Ie(be, function(er, Pr, xn) { - if (Fe(er, Pr, xn)) - return It = Pr, !1; - }), It; - } - function vh(be, Fe, Ie, It) { - for (var er = be.length, Pr = Ie + (It ? 1 : -1); It ? Pr-- : ++Pr < er; ) - if (Fe(be[Pr], Pr, be)) - return Pr; - return -1; - } - function Ic(be, Fe, Ie) { - return Fe === Fe ? uA(be, Fe, Ie) : vh(be, gy, Ie); - } - function Z9(be, Fe, Ie, It) { - for (var er = Ie - 1, Pr = be.length; ++er < Pr; ) - if (It(be[er], Fe)) - return er; - return -1; - } - function gy(be) { - return be !== be; - } - function my(be, Fe) { - var Ie = be == null ? 0 : be.length; - return Ie ? Up(be, Fe) / Ie : v; - } - function Fp(be) { - return function(Fe) { - return Fe == null ? r : Fe[be]; - }; - } - function Bp(be) { - return function(Fe) { - return be == null ? r : be[Fe]; - }; - } - function vy(be, Fe, Ie, It, er) { - return er(be, function(Pr, xn, qr) { - Ie = It ? (It = !1, Pr) : Fe(Ie, Pr, xn, qr); - }), Ie; - } - function Q9(be, Fe) { - var Ie = be.length; - for (be.sort(Fe); Ie--; ) - be[Ie] = be[Ie].value; - return be; - } - function Up(be, Fe) { - for (var Ie, It = -1, er = be.length; ++It < er; ) { - var Pr = Fe(be[It]); - Pr !== r && (Ie = Ie === r ? Pr : Ie + Pr); - } - return Ie; - } - function jp(be, Fe) { - for (var Ie = -1, It = Array(be); ++Ie < be; ) - It[Ie] = Fe(Ie); - return It; - } - function eA(be, Fe) { - return Xr(Fe, function(Ie) { - return [Ie, be[Ie]]; - }); - } - function by(be) { - return be && be.slice(0, _y(be) + 1).replace(k, ""); - } - function Ai(be) { - return function(Fe) { - return be(Fe); - }; - } - function qp(be, Fe) { - return Xr(Fe, function(Ie) { - return be[Ie]; - }); - } - function Zu(be, Fe) { - return be.has(Fe); - } - function yy(be, Fe) { - for (var Ie = -1, It = be.length; ++Ie < It && Ic(Fe, be[Ie], 0) > -1; ) - ; - return Ie; - } - function wy(be, Fe) { - for (var Ie = be.length; Ie-- && Ic(Fe, be[Ie], 0) > -1; ) - ; - return Ie; - } - function tA(be, Fe) { - for (var Ie = be.length, It = 0; Ie--; ) - be[Ie] === Fe && ++It; - return It; - } - var rA = Bp(ae), nA = Bp(ye); - function iA(be) { - return "\\" + Pt[be]; - } - function sA(be, Fe) { - return be == null ? r : be[Fe]; - } - function Cc(be) { - return ph.test(be); - } - function oA(be) { - return Ra.test(be); - } - function aA(be) { - for (var Fe, Ie = []; !(Fe = be.next()).done; ) - Ie.push(Fe.value); - return Ie; - } - function zp(be) { - var Fe = -1, Ie = Array(be.size); - return be.forEach(function(It, er) { - Ie[++Fe] = [er, It]; - }), Ie; - } - function xy(be, Fe) { - return function(Ie) { - return be(Fe(Ie)); - }; - } - function Wo(be, Fe) { - for (var Ie = -1, It = be.length, er = 0, Pr = []; ++Ie < It; ) { - var xn = be[Ie]; - (xn === Fe || xn === d) && (be[Ie] = d, Pr[er++] = Ie); - } - return Pr; - } - function bh(be) { - var Fe = -1, Ie = Array(be.size); - return be.forEach(function(It) { - Ie[++Fe] = It; - }), Ie; - } - function cA(be) { - var Fe = -1, Ie = Array(be.size); - return be.forEach(function(It) { - Ie[++Fe] = [It, It]; - }), Ie; - } - function uA(be, Fe, Ie) { - for (var It = Ie - 1, er = be.length; ++It < er; ) - if (be[It] === Fe) - return It; - return -1; - } - function fA(be, Fe, Ie) { - for (var It = Ie + 1; It--; ) - if (be[It] === Fe) - return It; - return It; - } - function Tc(be) { - return Cc(be) ? hA(be) : Y9(be); - } - function fs(be) { - return Cc(be) ? dA(be) : J9(be); - } - function _y(be) { - for (var Fe = be.length; Fe-- && j.test(be.charAt(Fe)); ) - ; - return Fe; - } - var lA = Bp(Ge); - function hA(be) { - for (var Fe = Mc.lastIndex = 0; Mc.test(be); ) - ++Fe; - return Fe; - } - function dA(be) { - return be.match(Mc) || []; - } - function pA(be) { - return be.match(dh) || []; - } - var gA = function be(Fe) { - Fe = Fe == null ? _r : Rc.defaults(_r.Object(), Fe, Rc.pick(_r, gh)); - var Ie = Fe.Array, It = Fe.Date, er = Fe.Error, Pr = Fe.Function, xn = Fe.Math, qr = Fe.Object, Hp = Fe.RegExp, mA = Fe.String, ji = Fe.TypeError, yh = Ie.prototype, vA = Pr.prototype, Dc = qr.prototype, wh = Fe["__core-js_shared__"], xh = vA.toString, Tr = Dc.hasOwnProperty, bA = 0, Ey = function() { - var c = /[^.]+$/.exec(wh && wh.keys && wh.keys.IE_PROTO || ""); - return c ? "Symbol(src)_1." + c : ""; - }(), _h = Dc.toString, yA = xh.call(qr), wA = _r._, xA = Hp( - "^" + xh.call(Tr).replace(rt, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" - ), Eh = ci ? Fe.Buffer : r, Ko = Fe.Symbol, Sh = Fe.Uint8Array, Sy = Eh ? Eh.allocUnsafe : r, Ah = xy(qr.getPrototypeOf, qr), Ay = qr.create, Py = Dc.propertyIsEnumerable, Ph = yh.splice, My = Ko ? Ko.isConcatSpreadable : r, Qu = Ko ? Ko.iterator : r, Oa = Ko ? Ko.toStringTag : r, Mh = function() { - try { - var c = Fa(qr, "defineProperty"); - return c({}, "", {}), c; - } catch { - } - }(), _A = Fe.clearTimeout !== _r.clearTimeout && Fe.clearTimeout, EA = It && It.now !== _r.Date.now && It.now, SA = Fe.setTimeout !== _r.setTimeout && Fe.setTimeout, Ih = xn.ceil, Ch = xn.floor, Wp = qr.getOwnPropertySymbols, AA = Eh ? Eh.isBuffer : r, Iy = Fe.isFinite, PA = yh.join, MA = xy(qr.keys, qr), _n = xn.max, Wn = xn.min, IA = It.now, CA = Fe.parseInt, Cy = xn.random, TA = yh.reverse, Kp = Fa(Fe, "DataView"), ef = Fa(Fe, "Map"), Vp = Fa(Fe, "Promise"), Oc = Fa(Fe, "Set"), tf = Fa(Fe, "WeakMap"), rf = Fa(qr, "create"), Th = tf && new tf(), Nc = {}, RA = Ba(Kp), DA = Ba(ef), OA = Ba(Vp), NA = Ba(Oc), LA = Ba(tf), Rh = Ko ? Ko.prototype : r, nf = Rh ? Rh.valueOf : r, Ty = Rh ? Rh.toString : r; - function ee(c) { - if (en(c) && !nr(c) && !(c instanceof wr)) { - if (c instanceof qi) - return c; - if (Tr.call(c, "__wrapped__")) - return Rw(c); - } - return new qi(c); - } - var Lc = /* @__PURE__ */ function() { - function c() { - } - return function(h) { - if (!Zr(h)) - return {}; - if (Ay) - return Ay(h); - c.prototype = h; - var y = new c(); - return c.prototype = r, y; - }; - }(); - function Dh() { - } - function qi(c, h) { - this.__wrapped__ = c, this.__actions__ = [], this.__chain__ = !!h, this.__index__ = 0, this.__values__ = r; - } - ee.templateSettings = { - /** - * Used to detect `data` property values to be HTML-escaped. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - escape: gt, - /** - * Used to detect code to be evaluated. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - evaluate: Rt, - /** - * Used to detect `data` property values to inject. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ - interpolate: Nt, - /** - * Used to reference the data object in the template text. - * - * @memberOf _.templateSettings - * @type {string} - */ - variable: "", - /** - * Used to import variables into the compiled template. - * - * @memberOf _.templateSettings - * @type {Object} - */ - imports: { - /** - * A reference to the `lodash` function. - * - * @memberOf _.templateSettings.imports - * @type {Function} - */ - _: ee - } - }, ee.prototype = Dh.prototype, ee.prototype.constructor = ee, qi.prototype = Lc(Dh.prototype), qi.prototype.constructor = qi; - function wr(c) { - this.__wrapped__ = c, this.__actions__ = [], this.__dir__ = 1, this.__filtered__ = !1, this.__iteratees__ = [], this.__takeCount__ = P, this.__views__ = []; - } - function kA() { - var c = new wr(this.__wrapped__); - return c.__actions__ = ui(this.__actions__), c.__dir__ = this.__dir__, c.__filtered__ = this.__filtered__, c.__iteratees__ = ui(this.__iteratees__), c.__takeCount__ = this.__takeCount__, c.__views__ = ui(this.__views__), c; - } - function $A() { - if (this.__filtered__) { - var c = new wr(this); - c.__dir__ = -1, c.__filtered__ = !0; - } else - c = this.clone(), c.__dir__ *= -1; - return c; - } - function FA() { - var c = this.__wrapped__.value(), h = this.__dir__, y = nr(c), O = h < 0, q = y ? c.length : 0, ne = JP(0, q, this.__views__), fe = ne.start, ge = ne.end, we = ge - fe, He = O ? ge : fe - 1, We = this.__iteratees__, Xe = We.length, wt = 0, Ot = Wn(we, this.__takeCount__); - if (!y || !O && q == we && Ot == we) - return ew(c, this.__actions__); - var Wt = []; - e: - for (; we-- && wt < Ot; ) { - He += h; - for (var ur = -1, Kt = c[He]; ++ur < Xe; ) { - var vr = We[ur], Er = vr.iteratee, Ii = vr.type, ni = Er(Kt); - if (Ii == p) - Kt = ni; - else if (!ni) { - if (Ii == f) - continue e; - break e; - } - } - Wt[wt++] = Kt; - } - return Wt; - } - wr.prototype = Lc(Dh.prototype), wr.prototype.constructor = wr; - function Na(c) { - var h = -1, y = c == null ? 0 : c.length; - for (this.clear(); ++h < y; ) { - var O = c[h]; - this.set(O[0], O[1]); - } - } - function BA() { - this.__data__ = rf ? rf(null) : {}, this.size = 0; - } - function UA(c) { - var h = this.has(c) && delete this.__data__[c]; - return this.size -= h ? 1 : 0, h; - } - function jA(c) { - var h = this.__data__; - if (rf) { - var y = h[c]; - return y === u ? r : y; - } - return Tr.call(h, c) ? h[c] : r; - } - function qA(c) { - var h = this.__data__; - return rf ? h[c] !== r : Tr.call(h, c); - } - function zA(c, h) { - var y = this.__data__; - return this.size += this.has(c) ? 0 : 1, y[c] = rf && h === r ? u : h, this; - } - Na.prototype.clear = BA, Na.prototype.delete = UA, Na.prototype.get = jA, Na.prototype.has = qA, Na.prototype.set = zA; - function io(c) { - var h = -1, y = c == null ? 0 : c.length; - for (this.clear(); ++h < y; ) { - var O = c[h]; - this.set(O[0], O[1]); - } - } - function HA() { - this.__data__ = [], this.size = 0; - } - function WA(c) { - var h = this.__data__, y = Oh(h, c); - if (y < 0) - return !1; - var O = h.length - 1; - return y == O ? h.pop() : Ph.call(h, y, 1), --this.size, !0; - } - function KA(c) { - var h = this.__data__, y = Oh(h, c); - return y < 0 ? r : h[y][1]; - } - function VA(c) { - return Oh(this.__data__, c) > -1; - } - function GA(c, h) { - var y = this.__data__, O = Oh(y, c); - return O < 0 ? (++this.size, y.push([c, h])) : y[O][1] = h, this; - } - io.prototype.clear = HA, io.prototype.delete = WA, io.prototype.get = KA, io.prototype.has = VA, io.prototype.set = GA; - function so(c) { - var h = -1, y = c == null ? 0 : c.length; - for (this.clear(); ++h < y; ) { - var O = c[h]; - this.set(O[0], O[1]); - } - } - function YA() { - this.size = 0, this.__data__ = { - hash: new Na(), - map: new (ef || io)(), - string: new Na() - }; - } - function JA(c) { - var h = Wh(this, c).delete(c); - return this.size -= h ? 1 : 0, h; - } - function XA(c) { - return Wh(this, c).get(c); - } - function ZA(c) { - return Wh(this, c).has(c); - } - function QA(c, h) { - var y = Wh(this, c), O = y.size; - return y.set(c, h), this.size += y.size == O ? 0 : 1, this; - } - so.prototype.clear = YA, so.prototype.delete = JA, so.prototype.get = XA, so.prototype.has = ZA, so.prototype.set = QA; - function La(c) { - var h = -1, y = c == null ? 0 : c.length; - for (this.__data__ = new so(); ++h < y; ) - this.add(c[h]); - } - function eP(c) { - return this.__data__.set(c, u), this; - } - function tP(c) { - return this.__data__.has(c); - } - La.prototype.add = La.prototype.push = eP, La.prototype.has = tP; - function ls(c) { - var h = this.__data__ = new io(c); - this.size = h.size; - } - function rP() { - this.__data__ = new io(), this.size = 0; - } - function nP(c) { - var h = this.__data__, y = h.delete(c); - return this.size = h.size, y; - } - function iP(c) { - return this.__data__.get(c); - } - function sP(c) { - return this.__data__.has(c); - } - function oP(c, h) { - var y = this.__data__; - if (y instanceof io) { - var O = y.__data__; - if (!ef || O.length < i - 1) - return O.push([c, h]), this.size = ++y.size, this; - y = this.__data__ = new so(O); - } - return y.set(c, h), this.size = y.size, this; - } - ls.prototype.clear = rP, ls.prototype.delete = nP, ls.prototype.get = iP, ls.prototype.has = sP, ls.prototype.set = oP; - function Ry(c, h) { - var y = nr(c), O = !y && Ua(c), q = !y && !O && Xo(c), ne = !y && !O && !q && Bc(c), fe = y || O || q || ne, ge = fe ? jp(c.length, mA) : [], we = ge.length; - for (var He in c) - (h || Tr.call(c, He)) && !(fe && // Safari 9 has enumerable `arguments.length` in strict mode. - (He == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. - q && (He == "offset" || He == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. - ne && (He == "buffer" || He == "byteLength" || He == "byteOffset") || // Skip index properties. - uo(He, we))) && ge.push(He); - return ge; - } - function Dy(c) { - var h = c.length; - return h ? c[ig(0, h - 1)] : r; - } - function aP(c, h) { - return Kh(ui(c), ka(h, 0, c.length)); - } - function cP(c) { - return Kh(ui(c)); - } - function Gp(c, h, y) { - (y !== r && !hs(c[h], y) || y === r && !(h in c)) && oo(c, h, y); - } - function sf(c, h, y) { - var O = c[h]; - (!(Tr.call(c, h) && hs(O, y)) || y === r && !(h in c)) && oo(c, h, y); - } - function Oh(c, h) { - for (var y = c.length; y--; ) - if (hs(c[y][0], h)) - return y; - return -1; - } - function uP(c, h, y, O) { - return Vo(c, function(q, ne, fe) { - h(O, q, y(q), fe); - }), O; - } - function Oy(c, h) { - return c && Cs(h, Mn(h), c); - } - function fP(c, h) { - return c && Cs(h, li(h), c); - } - function oo(c, h, y) { - h == "__proto__" && Mh ? Mh(c, h, { - configurable: !0, - enumerable: !0, - value: y, - writable: !0 - }) : c[h] = y; - } - function Yp(c, h) { - for (var y = -1, O = h.length, q = Ie(O), ne = c == null; ++y < O; ) - q[y] = ne ? r : Cg(c, h[y]); - return q; - } - function ka(c, h, y) { - return c === c && (y !== r && (c = c <= y ? c : y), h !== r && (c = c >= h ? c : h)), c; - } - function zi(c, h, y, O, q, ne) { - var fe, ge = h & g, we = h & w, He = h & A; - if (y && (fe = q ? y(c, O, q, ne) : y(c)), fe !== r) - return fe; - if (!Zr(c)) - return c; - var We = nr(c); - if (We) { - if (fe = ZP(c), !ge) - return ui(c, fe); - } else { - var Xe = Kn(c), wt = Xe == re || Xe == de; - if (Xo(c)) - return nw(c, ge); - if (Xe == Pe || Xe == D || wt && !q) { - if (fe = we || wt ? {} : _w(c), !ge) - return we ? jP(c, fP(fe, c)) : UP(c, Oy(fe, c)); - } else { - if (!Dr[Xe]) - return q ? c : {}; - fe = QP(c, Xe, ge); - } - } - ne || (ne = new ls()); - var Ot = ne.get(c); - if (Ot) - return Ot; - ne.set(c, fe), Xw(c) ? c.forEach(function(Kt) { - fe.add(zi(Kt, h, y, Kt, c, ne)); - }) : Yw(c) && c.forEach(function(Kt, vr) { - fe.set(vr, zi(Kt, h, y, vr, c, ne)); - }); - var Wt = He ? we ? gg : pg : we ? li : Mn, ur = We ? r : Wt(c); - return Ui(ur || c, function(Kt, vr) { - ur && (vr = Kt, Kt = c[vr]), sf(fe, vr, zi(Kt, h, y, vr, c, ne)); - }), fe; - } - function lP(c) { - var h = Mn(c); - return function(y) { - return Ny(y, c, h); - }; - } - function Ny(c, h, y) { - var O = y.length; - if (c == null) - return !O; - for (c = qr(c); O--; ) { - var q = y[O], ne = h[q], fe = c[q]; - if (fe === r && !(q in c) || !ne(fe)) - return !1; - } - return !0; - } - function Ly(c, h, y) { - if (typeof c != "function") - throw new ji(o); - return hf(function() { - c.apply(r, y); - }, h); - } - function of(c, h, y, O) { - var q = -1, ne = mh, fe = !0, ge = c.length, we = [], He = h.length; - if (!ge) - return we; - y && (h = Xr(h, Ai(y))), O ? (ne = Lp, fe = !1) : h.length >= i && (ne = Zu, fe = !1, h = new La(h)); - e: - for (; ++q < ge; ) { - var We = c[q], Xe = y == null ? We : y(We); - if (We = O || We !== 0 ? We : 0, fe && Xe === Xe) { - for (var wt = He; wt--; ) - if (h[wt] === Xe) - continue e; - we.push(We); - } else ne(h, Xe, O) || we.push(We); - } - return we; - } - var Vo = cw(Is), ky = cw(Xp, !0); - function hP(c, h) { - var y = !0; - return Vo(c, function(O, q, ne) { - return y = !!h(O, q, ne), y; - }), y; - } - function Nh(c, h, y) { - for (var O = -1, q = c.length; ++O < q; ) { - var ne = c[O], fe = h(ne); - if (fe != null && (ge === r ? fe === fe && !Mi(fe) : y(fe, ge))) - var ge = fe, we = ne; - } - return we; - } - function dP(c, h, y, O) { - var q = c.length; - for (y = ar(y), y < 0 && (y = -y > q ? 0 : q + y), O = O === r || O > q ? q : ar(O), O < 0 && (O += q), O = y > O ? 0 : Qw(O); y < O; ) - c[y++] = h; - return c; - } - function $y(c, h) { - var y = []; - return Vo(c, function(O, q, ne) { - h(O, q, ne) && y.push(O); - }), y; - } - function $n(c, h, y, O, q) { - var ne = -1, fe = c.length; - for (y || (y = tM), q || (q = []); ++ne < fe; ) { - var ge = c[ne]; - h > 0 && y(ge) ? h > 1 ? $n(ge, h - 1, y, O, q) : Ho(q, ge) : O || (q[q.length] = ge); - } - return q; - } - var Jp = uw(), Fy = uw(!0); - function Is(c, h) { - return c && Jp(c, h, Mn); - } - function Xp(c, h) { - return c && Fy(c, h, Mn); - } - function Lh(c, h) { - return zo(h, function(y) { - return fo(c[y]); - }); - } - function $a(c, h) { - h = Yo(h, c); - for (var y = 0, O = h.length; c != null && y < O; ) - c = c[Ts(h[y++])]; - return y && y == O ? c : r; - } - function By(c, h, y) { - var O = h(c); - return nr(c) ? O : Ho(O, y(c)); - } - function ti(c) { - return c == null ? c === r ? Le : ve : Oa && Oa in qr(c) ? YP(c) : cM(c); - } - function Zp(c, h) { - return c > h; - } - function pP(c, h) { - return c != null && Tr.call(c, h); - } - function gP(c, h) { - return c != null && h in qr(c); - } - function mP(c, h, y) { - return c >= Wn(h, y) && c < _n(h, y); - } - function Qp(c, h, y) { - for (var O = y ? Lp : mh, q = c[0].length, ne = c.length, fe = ne, ge = Ie(ne), we = 1 / 0, He = []; fe--; ) { - var We = c[fe]; - fe && h && (We = Xr(We, Ai(h))), we = Wn(We.length, we), ge[fe] = !y && (h || q >= 120 && We.length >= 120) ? new La(fe && We) : r; - } - We = c[0]; - var Xe = -1, wt = ge[0]; - e: - for (; ++Xe < q && He.length < we; ) { - var Ot = We[Xe], Wt = h ? h(Ot) : Ot; - if (Ot = y || Ot !== 0 ? Ot : 0, !(wt ? Zu(wt, Wt) : O(He, Wt, y))) { - for (fe = ne; --fe; ) { - var ur = ge[fe]; - if (!(ur ? Zu(ur, Wt) : O(c[fe], Wt, y))) - continue e; - } - wt && wt.push(Wt), He.push(Ot); - } - } - return He; - } - function vP(c, h, y, O) { - return Is(c, function(q, ne, fe) { - h(O, y(q), ne, fe); - }), O; - } - function af(c, h, y) { - h = Yo(h, c), c = Pw(c, h); - var O = c == null ? c : c[Ts(Wi(h))]; - return O == null ? r : Pn(O, c, y); - } - function Uy(c) { - return en(c) && ti(c) == D; - } - function bP(c) { - return en(c) && ti(c) == _e; - } - function yP(c) { - return en(c) && ti(c) == Q; - } - function cf(c, h, y, O, q) { - return c === h ? !0 : c == null || h == null || !en(c) && !en(h) ? c !== c && h !== h : wP(c, h, y, O, cf, q); - } - function wP(c, h, y, O, q, ne) { - var fe = nr(c), ge = nr(h), we = fe ? oe : Kn(c), He = ge ? oe : Kn(h); - we = we == D ? Pe : we, He = He == D ? Pe : He; - var We = we == Pe, Xe = He == Pe, wt = we == He; - if (wt && Xo(c)) { - if (!Xo(h)) - return !1; - fe = !0, We = !1; - } - if (wt && !We) - return ne || (ne = new ls()), fe || Bc(c) ? yw(c, h, y, O, q, ne) : VP(c, h, we, y, O, q, ne); - if (!(y & M)) { - var Ot = We && Tr.call(c, "__wrapped__"), Wt = Xe && Tr.call(h, "__wrapped__"); - if (Ot || Wt) { - var ur = Ot ? c.value() : c, Kt = Wt ? h.value() : h; - return ne || (ne = new ls()), q(ur, Kt, y, O, ne); - } - } - return wt ? (ne || (ne = new ls()), GP(c, h, y, O, q, ne)) : !1; - } - function xP(c) { - return en(c) && Kn(c) == ie; - } - function eg(c, h, y, O) { - var q = y.length, ne = q, fe = !O; - if (c == null) - return !ne; - for (c = qr(c); q--; ) { - var ge = y[q]; - if (fe && ge[2] ? ge[1] !== c[ge[0]] : !(ge[0] in c)) - return !1; - } - for (; ++q < ne; ) { - ge = y[q]; - var we = ge[0], He = c[we], We = ge[1]; - if (fe && ge[2]) { - if (He === r && !(we in c)) - return !1; - } else { - var Xe = new ls(); - if (O) - var wt = O(He, We, we, c, h, Xe); - if (!(wt === r ? cf(We, He, M | N, O, Xe) : wt)) - return !1; - } - } - return !0; - } - function jy(c) { - if (!Zr(c) || nM(c)) - return !1; - var h = fo(c) ? xA : Ue; - return h.test(Ba(c)); - } - function _P(c) { - return en(c) && ti(c) == $e; - } - function EP(c) { - return en(c) && Kn(c) == Me; - } - function SP(c) { - return en(c) && Zh(c.length) && !!Br[ti(c)]; - } - function qy(c) { - return typeof c == "function" ? c : c == null ? hi : typeof c == "object" ? nr(c) ? Wy(c[0], c[1]) : Hy(c) : f2(c); - } - function tg(c) { - if (!lf(c)) - return MA(c); - var h = []; - for (var y in qr(c)) - Tr.call(c, y) && y != "constructor" && h.push(y); - return h; - } - function AP(c) { - if (!Zr(c)) - return aM(c); - var h = lf(c), y = []; - for (var O in c) - O == "constructor" && (h || !Tr.call(c, O)) || y.push(O); - return y; - } - function rg(c, h) { - return c < h; - } - function zy(c, h) { - var y = -1, O = fi(c) ? Ie(c.length) : []; - return Vo(c, function(q, ne, fe) { - O[++y] = h(q, ne, fe); - }), O; - } - function Hy(c) { - var h = vg(c); - return h.length == 1 && h[0][2] ? Sw(h[0][0], h[0][1]) : function(y) { - return y === c || eg(y, c, h); - }; - } - function Wy(c, h) { - return yg(c) && Ew(h) ? Sw(Ts(c), h) : function(y) { - var O = Cg(y, c); - return O === r && O === h ? Tg(y, c) : cf(h, O, M | N); - }; - } - function kh(c, h, y, O, q) { - c !== h && Jp(h, function(ne, fe) { - if (q || (q = new ls()), Zr(ne)) - PP(c, h, fe, y, kh, O, q); - else { - var ge = O ? O(xg(c, fe), ne, fe + "", c, h, q) : r; - ge === r && (ge = ne), Gp(c, fe, ge); - } - }, li); - } - function PP(c, h, y, O, q, ne, fe) { - var ge = xg(c, y), we = xg(h, y), He = fe.get(we); - if (He) { - Gp(c, y, He); - return; - } - var We = ne ? ne(ge, we, y + "", c, h, fe) : r, Xe = We === r; - if (Xe) { - var wt = nr(we), Ot = !wt && Xo(we), Wt = !wt && !Ot && Bc(we); - We = we, wt || Ot || Wt ? nr(ge) ? We = ge : cn(ge) ? We = ui(ge) : Ot ? (Xe = !1, We = nw(we, !0)) : Wt ? (Xe = !1, We = iw(we, !0)) : We = [] : df(we) || Ua(we) ? (We = ge, Ua(ge) ? We = e2(ge) : (!Zr(ge) || fo(ge)) && (We = _w(we))) : Xe = !1; - } - Xe && (fe.set(we, We), q(We, we, O, ne, fe), fe.delete(we)), Gp(c, y, We); - } - function Ky(c, h) { - var y = c.length; - if (y) - return h += h < 0 ? y : 0, uo(h, y) ? c[h] : r; - } - function Vy(c, h, y) { - h.length ? h = Xr(h, function(ne) { - return nr(ne) ? function(fe) { - return $a(fe, ne.length === 1 ? ne[0] : ne); - } : ne; - }) : h = [hi]; - var O = -1; - h = Xr(h, Ai(jt())); - var q = zy(c, function(ne, fe, ge) { - var we = Xr(h, function(He) { - return He(ne); - }); - return { criteria: we, index: ++O, value: ne }; - }); - return Q9(q, function(ne, fe) { - return BP(ne, fe, y); - }); - } - function MP(c, h) { - return Gy(c, h, function(y, O) { - return Tg(c, O); - }); - } - function Gy(c, h, y) { - for (var O = -1, q = h.length, ne = {}; ++O < q; ) { - var fe = h[O], ge = $a(c, fe); - y(ge, fe) && uf(ne, Yo(fe, c), ge); - } - return ne; - } - function IP(c) { - return function(h) { - return $a(h, c); - }; - } - function ng(c, h, y, O) { - var q = O ? Z9 : Ic, ne = -1, fe = h.length, ge = c; - for (c === h && (h = ui(h)), y && (ge = Xr(c, Ai(y))); ++ne < fe; ) - for (var we = 0, He = h[ne], We = y ? y(He) : He; (we = q(ge, We, we, O)) > -1; ) - ge !== c && Ph.call(ge, we, 1), Ph.call(c, we, 1); - return c; - } - function Yy(c, h) { - for (var y = c ? h.length : 0, O = y - 1; y--; ) { - var q = h[y]; - if (y == O || q !== ne) { - var ne = q; - uo(q) ? Ph.call(c, q, 1) : ag(c, q); - } - } - return c; - } - function ig(c, h) { - return c + Ch(Cy() * (h - c + 1)); - } - function CP(c, h, y, O) { - for (var q = -1, ne = _n(Ih((h - c) / (y || 1)), 0), fe = Ie(ne); ne--; ) - fe[O ? ne : ++q] = c, c += y; - return fe; - } - function sg(c, h) { - var y = ""; - if (!c || h < 1 || h > _) - return y; - do - h % 2 && (y += c), h = Ch(h / 2), h && (c += c); - while (h); - return y; - } - function hr(c, h) { - return _g(Aw(c, h, hi), c + ""); - } - function TP(c) { - return Dy(Uc(c)); - } - function RP(c, h) { - var y = Uc(c); - return Kh(y, ka(h, 0, y.length)); - } - function uf(c, h, y, O) { - if (!Zr(c)) - return c; - h = Yo(h, c); - for (var q = -1, ne = h.length, fe = ne - 1, ge = c; ge != null && ++q < ne; ) { - var we = Ts(h[q]), He = y; - if (we === "__proto__" || we === "constructor" || we === "prototype") - return c; - if (q != fe) { - var We = ge[we]; - He = O ? O(We, we, ge) : r, He === r && (He = Zr(We) ? We : uo(h[q + 1]) ? [] : {}); - } - sf(ge, we, He), ge = ge[we]; - } - return c; - } - var Jy = Th ? function(c, h) { - return Th.set(c, h), c; - } : hi, DP = Mh ? function(c, h) { - return Mh(c, "toString", { - configurable: !0, - enumerable: !1, - value: Dg(h), - writable: !0 - }); - } : hi; - function OP(c) { - return Kh(Uc(c)); - } - function Hi(c, h, y) { - var O = -1, q = c.length; - h < 0 && (h = -h > q ? 0 : q + h), y = y > q ? q : y, y < 0 && (y += q), q = h > y ? 0 : y - h >>> 0, h >>>= 0; - for (var ne = Ie(q); ++O < q; ) - ne[O] = c[O + h]; - return ne; - } - function NP(c, h) { - var y; - return Vo(c, function(O, q, ne) { - return y = h(O, q, ne), !y; - }), !!y; - } - function $h(c, h, y) { - var O = 0, q = c == null ? O : c.length; - if (typeof h == "number" && h === h && q <= B) { - for (; O < q; ) { - var ne = O + q >>> 1, fe = c[ne]; - fe !== null && !Mi(fe) && (y ? fe <= h : fe < h) ? O = ne + 1 : q = ne; - } - return q; - } - return og(c, h, hi, y); - } - function og(c, h, y, O) { - var q = 0, ne = c == null ? 0 : c.length; - if (ne === 0) - return 0; - h = y(h); - for (var fe = h !== h, ge = h === null, we = Mi(h), He = h === r; q < ne; ) { - var We = Ch((q + ne) / 2), Xe = y(c[We]), wt = Xe !== r, Ot = Xe === null, Wt = Xe === Xe, ur = Mi(Xe); - if (fe) - var Kt = O || Wt; - else He ? Kt = Wt && (O || wt) : ge ? Kt = Wt && wt && (O || !Ot) : we ? Kt = Wt && wt && !Ot && (O || !ur) : Ot || ur ? Kt = !1 : Kt = O ? Xe <= h : Xe < h; - Kt ? q = We + 1 : ne = We; - } - return Wn(ne, I); - } - function Xy(c, h) { - for (var y = -1, O = c.length, q = 0, ne = []; ++y < O; ) { - var fe = c[y], ge = h ? h(fe) : fe; - if (!y || !hs(ge, we)) { - var we = ge; - ne[q++] = fe === 0 ? 0 : fe; - } - } - return ne; - } - function Zy(c) { - return typeof c == "number" ? c : Mi(c) ? v : +c; - } - function Pi(c) { - if (typeof c == "string") - return c; - if (nr(c)) - return Xr(c, Pi) + ""; - if (Mi(c)) - return Ty ? Ty.call(c) : ""; - var h = c + ""; - return h == "0" && 1 / c == -x ? "-0" : h; - } - function Go(c, h, y) { - var O = -1, q = mh, ne = c.length, fe = !0, ge = [], we = ge; - if (y) - fe = !1, q = Lp; - else if (ne >= i) { - var He = h ? null : WP(c); - if (He) - return bh(He); - fe = !1, q = Zu, we = new La(); - } else - we = h ? [] : ge; - e: - for (; ++O < ne; ) { - var We = c[O], Xe = h ? h(We) : We; - if (We = y || We !== 0 ? We : 0, fe && Xe === Xe) { - for (var wt = we.length; wt--; ) - if (we[wt] === Xe) - continue e; - h && we.push(Xe), ge.push(We); - } else q(we, Xe, y) || (we !== ge && we.push(Xe), ge.push(We)); - } - return ge; - } - function ag(c, h) { - return h = Yo(h, c), c = Pw(c, h), c == null || delete c[Ts(Wi(h))]; - } - function Qy(c, h, y, O) { - return uf(c, h, y($a(c, h)), O); - } - function Fh(c, h, y, O) { - for (var q = c.length, ne = O ? q : -1; (O ? ne-- : ++ne < q) && h(c[ne], ne, c); ) - ; - return y ? Hi(c, O ? 0 : ne, O ? ne + 1 : q) : Hi(c, O ? ne + 1 : 0, O ? q : ne); - } - function ew(c, h) { - var y = c; - return y instanceof wr && (y = y.value()), kp(h, function(O, q) { - return q.func.apply(q.thisArg, Ho([O], q.args)); - }, y); - } - function cg(c, h, y) { - var O = c.length; - if (O < 2) - return O ? Go(c[0]) : []; - for (var q = -1, ne = Ie(O); ++q < O; ) - for (var fe = c[q], ge = -1; ++ge < O; ) - ge != q && (ne[q] = of(ne[q] || fe, c[ge], h, y)); - return Go($n(ne, 1), h, y); - } - function tw(c, h, y) { - for (var O = -1, q = c.length, ne = h.length, fe = {}; ++O < q; ) { - var ge = O < ne ? h[O] : r; - y(fe, c[O], ge); - } - return fe; - } - function ug(c) { - return cn(c) ? c : []; - } - function fg(c) { - return typeof c == "function" ? c : hi; - } - function Yo(c, h) { - return nr(c) ? c : yg(c, h) ? [c] : Tw(Cr(c)); - } - var LP = hr; - function Jo(c, h, y) { - var O = c.length; - return y = y === r ? O : y, !h && y >= O ? c : Hi(c, h, y); - } - var rw = _A || function(c) { - return _r.clearTimeout(c); - }; - function nw(c, h) { - if (h) - return c.slice(); - var y = c.length, O = Sy ? Sy(y) : new c.constructor(y); - return c.copy(O), O; - } - function lg(c) { - var h = new c.constructor(c.byteLength); - return new Sh(h).set(new Sh(c)), h; - } - function kP(c, h) { - var y = h ? lg(c.buffer) : c.buffer; - return new c.constructor(y, c.byteOffset, c.byteLength); - } - function $P(c) { - var h = new c.constructor(c.source, Te.exec(c)); - return h.lastIndex = c.lastIndex, h; - } - function FP(c) { - return nf ? qr(nf.call(c)) : {}; - } - function iw(c, h) { - var y = h ? lg(c.buffer) : c.buffer; - return new c.constructor(y, c.byteOffset, c.length); - } - function sw(c, h) { - if (c !== h) { - var y = c !== r, O = c === null, q = c === c, ne = Mi(c), fe = h !== r, ge = h === null, we = h === h, He = Mi(h); - if (!ge && !He && !ne && c > h || ne && fe && we && !ge && !He || O && fe && we || !y && we || !q) - return 1; - if (!O && !ne && !He && c < h || He && y && q && !O && !ne || ge && y && q || !fe && q || !we) - return -1; - } - return 0; - } - function BP(c, h, y) { - for (var O = -1, q = c.criteria, ne = h.criteria, fe = q.length, ge = y.length; ++O < fe; ) { - var we = sw(q[O], ne[O]); - if (we) { - if (O >= ge) - return we; - var He = y[O]; - return we * (He == "desc" ? -1 : 1); - } - } - return c.index - h.index; - } - function ow(c, h, y, O) { - for (var q = -1, ne = c.length, fe = y.length, ge = -1, we = h.length, He = _n(ne - fe, 0), We = Ie(we + He), Xe = !O; ++ge < we; ) - We[ge] = h[ge]; - for (; ++q < fe; ) - (Xe || q < ne) && (We[y[q]] = c[q]); - for (; He--; ) - We[ge++] = c[q++]; - return We; - } - function aw(c, h, y, O) { - for (var q = -1, ne = c.length, fe = -1, ge = y.length, we = -1, He = h.length, We = _n(ne - ge, 0), Xe = Ie(We + He), wt = !O; ++q < We; ) - Xe[q] = c[q]; - for (var Ot = q; ++we < He; ) - Xe[Ot + we] = h[we]; - for (; ++fe < ge; ) - (wt || q < ne) && (Xe[Ot + y[fe]] = c[q++]); - return Xe; - } - function ui(c, h) { - var y = -1, O = c.length; - for (h || (h = Ie(O)); ++y < O; ) - h[y] = c[y]; - return h; - } - function Cs(c, h, y, O) { - var q = !y; - y || (y = {}); - for (var ne = -1, fe = h.length; ++ne < fe; ) { - var ge = h[ne], we = O ? O(y[ge], c[ge], ge, y, c) : r; - we === r && (we = c[ge]), q ? oo(y, ge, we) : sf(y, ge, we); - } - return y; - } - function UP(c, h) { - return Cs(c, bg(c), h); - } - function jP(c, h) { - return Cs(c, ww(c), h); - } - function Bh(c, h) { - return function(y, O) { - var q = nr(y) ? K9 : uP, ne = h ? h() : {}; - return q(y, c, jt(O, 2), ne); - }; - } - function kc(c) { - return hr(function(h, y) { - var O = -1, q = y.length, ne = q > 1 ? y[q - 1] : r, fe = q > 2 ? y[2] : r; - for (ne = c.length > 3 && typeof ne == "function" ? (q--, ne) : r, fe && ri(y[0], y[1], fe) && (ne = q < 3 ? r : ne, q = 1), h = qr(h); ++O < q; ) { - var ge = y[O]; - ge && c(h, ge, O, ne); - } - return h; - }); - } - function cw(c, h) { - return function(y, O) { - if (y == null) - return y; - if (!fi(y)) - return c(y, O); - for (var q = y.length, ne = h ? q : -1, fe = qr(y); (h ? ne-- : ++ne < q) && O(fe[ne], ne, fe) !== !1; ) - ; - return y; - }; - } - function uw(c) { - return function(h, y, O) { - for (var q = -1, ne = qr(h), fe = O(h), ge = fe.length; ge--; ) { - var we = fe[c ? ge : ++q]; - if (y(ne[we], we, ne) === !1) - break; - } - return h; - }; - } - function qP(c, h, y) { - var O = h & L, q = ff(c); - function ne() { - var fe = this && this !== _r && this instanceof ne ? q : c; - return fe.apply(O ? y : this, arguments); - } - return ne; - } - function fw(c) { - return function(h) { - h = Cr(h); - var y = Cc(h) ? fs(h) : r, O = y ? y[0] : h.charAt(0), q = y ? Jo(y, 1).join("") : h.slice(1); - return O[c]() + q; - }; - } - function $c(c) { - return function(h) { - return kp(c2(a2(h).replace(Ju, "")), c, ""); - }; - } - function ff(c) { - return function() { - var h = arguments; - switch (h.length) { - case 0: - return new c(); - case 1: - return new c(h[0]); - case 2: - return new c(h[0], h[1]); - case 3: - return new c(h[0], h[1], h[2]); - case 4: - return new c(h[0], h[1], h[2], h[3]); - case 5: - return new c(h[0], h[1], h[2], h[3], h[4]); - case 6: - return new c(h[0], h[1], h[2], h[3], h[4], h[5]); - case 7: - return new c(h[0], h[1], h[2], h[3], h[4], h[5], h[6]); - } - var y = Lc(c.prototype), O = c.apply(y, h); - return Zr(O) ? O : y; - }; - } - function zP(c, h, y) { - var O = ff(c); - function q() { - for (var ne = arguments.length, fe = Ie(ne), ge = ne, we = Fc(q); ge--; ) - fe[ge] = arguments[ge]; - var He = ne < 3 && fe[0] !== we && fe[ne - 1] !== we ? [] : Wo(fe, we); - if (ne -= He.length, ne < y) - return gw( - c, - h, - Uh, - q.placeholder, - r, - fe, - He, - r, - r, - y - ne - ); - var We = this && this !== _r && this instanceof q ? O : c; - return Pn(We, this, fe); - } - return q; - } - function lw(c) { - return function(h, y, O) { - var q = qr(h); - if (!fi(h)) { - var ne = jt(y, 3); - h = Mn(h), y = function(ge) { - return ne(q[ge], ge, q); - }; - } - var fe = c(h, y, O); - return fe > -1 ? q[ne ? h[fe] : fe] : r; - }; - } - function hw(c) { - return co(function(h) { - var y = h.length, O = y, q = qi.prototype.thru; - for (c && h.reverse(); O--; ) { - var ne = h[O]; - if (typeof ne != "function") - throw new ji(o); - if (q && !fe && Hh(ne) == "wrapper") - var fe = new qi([], !0); - } - for (O = fe ? O : y; ++O < y; ) { - ne = h[O]; - var ge = Hh(ne), we = ge == "wrapper" ? mg(ne) : r; - we && wg(we[0]) && we[1] == (R | K | V | W) && !we[4].length && we[9] == 1 ? fe = fe[Hh(we[0])].apply(fe, we[3]) : fe = ne.length == 1 && wg(ne) ? fe[ge]() : fe.thru(ne); - } - return function() { - var He = arguments, We = He[0]; - if (fe && He.length == 1 && nr(We)) - return fe.plant(We).value(); - for (var Xe = 0, wt = y ? h[Xe].apply(this, He) : We; ++Xe < y; ) - wt = h[Xe].call(this, wt); - return wt; - }; - }); - } - function Uh(c, h, y, O, q, ne, fe, ge, we, He) { - var We = h & R, Xe = h & L, wt = h & F, Ot = h & (K | H), Wt = h & pe, ur = wt ? r : ff(c); - function Kt() { - for (var vr = arguments.length, Er = Ie(vr), Ii = vr; Ii--; ) - Er[Ii] = arguments[Ii]; - if (Ot) - var ni = Fc(Kt), Ci = tA(Er, ni); - if (O && (Er = ow(Er, O, q, Ot)), ne && (Er = aw(Er, ne, fe, Ot)), vr -= Ci, Ot && vr < He) { - var un = Wo(Er, ni); - return gw( - c, - h, - Uh, - Kt.placeholder, - y, - Er, - un, - ge, - we, - He - vr - ); - } - var ds = Xe ? y : this, ho = wt ? ds[c] : c; - return vr = Er.length, ge ? Er = uM(Er, ge) : Wt && vr > 1 && Er.reverse(), We && we < vr && (Er.length = we), this && this !== _r && this instanceof Kt && (ho = ur || ff(ho)), ho.apply(ds, Er); - } - return Kt; - } - function dw(c, h) { - return function(y, O) { - return vP(y, c, h(O), {}); - }; - } - function jh(c, h) { - return function(y, O) { - var q; - if (y === r && O === r) - return h; - if (y !== r && (q = y), O !== r) { - if (q === r) - return O; - typeof y == "string" || typeof O == "string" ? (y = Pi(y), O = Pi(O)) : (y = Zy(y), O = Zy(O)), q = c(y, O); - } - return q; - }; - } - function hg(c) { - return co(function(h) { - return h = Xr(h, Ai(jt())), hr(function(y) { - var O = this; - return c(h, function(q) { - return Pn(q, O, y); - }); - }); - }); - } - function qh(c, h) { - h = h === r ? " " : Pi(h); - var y = h.length; - if (y < 2) - return y ? sg(h, c) : h; - var O = sg(h, Ih(c / Tc(h))); - return Cc(h) ? Jo(fs(O), 0, c).join("") : O.slice(0, c); - } - function HP(c, h, y, O) { - var q = h & L, ne = ff(c); - function fe() { - for (var ge = -1, we = arguments.length, He = -1, We = O.length, Xe = Ie(We + we), wt = this && this !== _r && this instanceof fe ? ne : c; ++He < We; ) - Xe[He] = O[He]; - for (; we--; ) - Xe[He++] = arguments[++ge]; - return Pn(wt, q ? y : this, Xe); - } - return fe; - } - function pw(c) { - return function(h, y, O) { - return O && typeof O != "number" && ri(h, y, O) && (y = O = r), h = lo(h), y === r ? (y = h, h = 0) : y = lo(y), O = O === r ? h < y ? 1 : -1 : lo(O), CP(h, y, O, c); - }; - } - function zh(c) { - return function(h, y) { - return typeof h == "string" && typeof y == "string" || (h = Ki(h), y = Ki(y)), c(h, y); - }; - } - function gw(c, h, y, O, q, ne, fe, ge, we, He) { - var We = h & K, Xe = We ? fe : r, wt = We ? r : fe, Ot = We ? ne : r, Wt = We ? r : ne; - h |= We ? V : te, h &= ~(We ? te : V), h & $ || (h &= ~(L | F)); - var ur = [ - c, - h, - q, - Ot, - Xe, - Wt, - wt, - ge, - we, - He - ], Kt = y.apply(r, ur); - return wg(c) && Mw(Kt, ur), Kt.placeholder = O, Iw(Kt, c, h); - } - function dg(c) { - var h = xn[c]; - return function(y, O) { - if (y = Ki(y), O = O == null ? 0 : Wn(ar(O), 292), O && Iy(y)) { - var q = (Cr(y) + "e").split("e"), ne = h(q[0] + "e" + (+q[1] + O)); - return q = (Cr(ne) + "e").split("e"), +(q[0] + "e" + (+q[1] - O)); - } - return h(y); - }; - } - var WP = Oc && 1 / bh(new Oc([, -0]))[1] == x ? function(c) { - return new Oc(c); - } : Lg; - function mw(c) { - return function(h) { - var y = Kn(h); - return y == ie ? zp(h) : y == Me ? cA(h) : eA(h, c(h)); - }; - } - function ao(c, h, y, O, q, ne, fe, ge) { - var we = h & F; - if (!we && typeof c != "function") - throw new ji(o); - var He = O ? O.length : 0; - if (He || (h &= ~(V | te), O = q = r), fe = fe === r ? fe : _n(ar(fe), 0), ge = ge === r ? ge : ar(ge), He -= q ? q.length : 0, h & te) { - var We = O, Xe = q; - O = q = r; - } - var wt = we ? r : mg(c), Ot = [ - c, - h, - y, - O, - q, - We, - Xe, - ne, - fe, - ge - ]; - if (wt && oM(Ot, wt), c = Ot[0], h = Ot[1], y = Ot[2], O = Ot[3], q = Ot[4], ge = Ot[9] = Ot[9] === r ? we ? 0 : c.length : _n(Ot[9] - He, 0), !ge && h & (K | H) && (h &= ~(K | H)), !h || h == L) - var Wt = qP(c, h, y); - else h == K || h == H ? Wt = zP(c, h, ge) : (h == V || h == (L | V)) && !q.length ? Wt = HP(c, h, y, O) : Wt = Uh.apply(r, Ot); - var ur = wt ? Jy : Mw; - return Iw(ur(Wt, Ot), c, h); - } - function vw(c, h, y, O) { - return c === r || hs(c, Dc[y]) && !Tr.call(O, y) ? h : c; - } - function bw(c, h, y, O, q, ne) { - return Zr(c) && Zr(h) && (ne.set(h, c), kh(c, h, r, bw, ne), ne.delete(h)), c; - } - function KP(c) { - return df(c) ? r : c; - } - function yw(c, h, y, O, q, ne) { - var fe = y & M, ge = c.length, we = h.length; - if (ge != we && !(fe && we > ge)) - return !1; - var He = ne.get(c), We = ne.get(h); - if (He && We) - return He == h && We == c; - var Xe = -1, wt = !0, Ot = y & N ? new La() : r; - for (ne.set(c, h), ne.set(h, c); ++Xe < ge; ) { - var Wt = c[Xe], ur = h[Xe]; - if (O) - var Kt = fe ? O(ur, Wt, Xe, h, c, ne) : O(Wt, ur, Xe, c, h, ne); - if (Kt !== r) { - if (Kt) - continue; - wt = !1; - break; - } - if (Ot) { - if (!$p(h, function(vr, Er) { - if (!Zu(Ot, Er) && (Wt === vr || q(Wt, vr, y, O, ne))) - return Ot.push(Er); - })) { - wt = !1; - break; - } - } else if (!(Wt === ur || q(Wt, ur, y, O, ne))) { - wt = !1; - break; - } - } - return ne.delete(c), ne.delete(h), wt; - } - function VP(c, h, y, O, q, ne, fe) { - switch (y) { - case Ze: - if (c.byteLength != h.byteLength || c.byteOffset != h.byteOffset) - return !1; - c = c.buffer, h = h.buffer; - case _e: - return !(c.byteLength != h.byteLength || !ne(new Sh(c), new Sh(h))); - case J: - case Q: - case ue: - return hs(+c, +h); - case X: - return c.name == h.name && c.message == h.message; - case $e: - case Ne: - return c == h + ""; - case ie: - var ge = zp; - case Me: - var we = O & M; - if (ge || (ge = bh), c.size != h.size && !we) - return !1; - var He = fe.get(c); - if (He) - return He == h; - O |= N, fe.set(c, h); - var We = yw(ge(c), ge(h), O, q, ne, fe); - return fe.delete(c), We; - case Ke: - if (nf) - return nf.call(c) == nf.call(h); - } - return !1; - } - function GP(c, h, y, O, q, ne) { - var fe = y & M, ge = pg(c), we = ge.length, He = pg(h), We = He.length; - if (we != We && !fe) - return !1; - for (var Xe = we; Xe--; ) { - var wt = ge[Xe]; - if (!(fe ? wt in h : Tr.call(h, wt))) - return !1; - } - var Ot = ne.get(c), Wt = ne.get(h); - if (Ot && Wt) - return Ot == h && Wt == c; - var ur = !0; - ne.set(c, h), ne.set(h, c); - for (var Kt = fe; ++Xe < we; ) { - wt = ge[Xe]; - var vr = c[wt], Er = h[wt]; - if (O) - var Ii = fe ? O(Er, vr, wt, h, c, ne) : O(vr, Er, wt, c, h, ne); - if (!(Ii === r ? vr === Er || q(vr, Er, y, O, ne) : Ii)) { - ur = !1; - break; - } - Kt || (Kt = wt == "constructor"); - } - if (ur && !Kt) { - var ni = c.constructor, Ci = h.constructor; - ni != Ci && "constructor" in c && "constructor" in h && !(typeof ni == "function" && ni instanceof ni && typeof Ci == "function" && Ci instanceof Ci) && (ur = !1); - } - return ne.delete(c), ne.delete(h), ur; - } - function co(c) { - return _g(Aw(c, r, Nw), c + ""); - } - function pg(c) { - return By(c, Mn, bg); - } - function gg(c) { - return By(c, li, ww); - } - var mg = Th ? function(c) { - return Th.get(c); - } : Lg; - function Hh(c) { - for (var h = c.name + "", y = Nc[h], O = Tr.call(Nc, h) ? y.length : 0; O--; ) { - var q = y[O], ne = q.func; - if (ne == null || ne == c) - return q.name; - } - return h; - } - function Fc(c) { - var h = Tr.call(ee, "placeholder") ? ee : c; - return h.placeholder; - } - function jt() { - var c = ee.iteratee || Og; - return c = c === Og ? qy : c, arguments.length ? c(arguments[0], arguments[1]) : c; - } - function Wh(c, h) { - var y = c.__data__; - return rM(h) ? y[typeof h == "string" ? "string" : "hash"] : y.map; - } - function vg(c) { - for (var h = Mn(c), y = h.length; y--; ) { - var O = h[y], q = c[O]; - h[y] = [O, q, Ew(q)]; - } - return h; - } - function Fa(c, h) { - var y = sA(c, h); - return jy(y) ? y : r; - } - function YP(c) { - var h = Tr.call(c, Oa), y = c[Oa]; - try { - c[Oa] = r; - var O = !0; - } catch { - } - var q = _h.call(c); - return O && (h ? c[Oa] = y : delete c[Oa]), q; - } - var bg = Wp ? function(c) { - return c == null ? [] : (c = qr(c), zo(Wp(c), function(h) { - return Py.call(c, h); - })); - } : kg, ww = Wp ? function(c) { - for (var h = []; c; ) - Ho(h, bg(c)), c = Ah(c); - return h; - } : kg, Kn = ti; - (Kp && Kn(new Kp(new ArrayBuffer(1))) != Ze || ef && Kn(new ef()) != ie || Vp && Kn(Vp.resolve()) != De || Oc && Kn(new Oc()) != Me || tf && Kn(new tf()) != qe) && (Kn = function(c) { - var h = ti(c), y = h == Pe ? c.constructor : r, O = y ? Ba(y) : ""; - if (O) - switch (O) { - case RA: - return Ze; - case DA: - return ie; - case OA: - return De; - case NA: - return Me; - case LA: - return qe; - } - return h; - }); - function JP(c, h, y) { - for (var O = -1, q = y.length; ++O < q; ) { - var ne = y[O], fe = ne.size; - switch (ne.type) { - case "drop": - c += fe; - break; - case "dropRight": - h -= fe; - break; - case "take": - h = Wn(h, c + fe); - break; - case "takeRight": - c = _n(c, h - fe); - break; - } - } - return { start: c, end: h }; - } - function XP(c) { - var h = c.match(C); - return h ? h[1].split(G) : []; - } - function xw(c, h, y) { - h = Yo(h, c); - for (var O = -1, q = h.length, ne = !1; ++O < q; ) { - var fe = Ts(h[O]); - if (!(ne = c != null && y(c, fe))) - break; - c = c[fe]; - } - return ne || ++O != q ? ne : (q = c == null ? 0 : c.length, !!q && Zh(q) && uo(fe, q) && (nr(c) || Ua(c))); - } - function ZP(c) { - var h = c.length, y = new c.constructor(h); - return h && typeof c[0] == "string" && Tr.call(c, "index") && (y.index = c.index, y.input = c.input), y; - } - function _w(c) { - return typeof c.constructor == "function" && !lf(c) ? Lc(Ah(c)) : {}; - } - function QP(c, h, y) { - var O = c.constructor; - switch (h) { - case _e: - return lg(c); - case J: - case Q: - return new O(+c); - case Ze: - return kP(c, y); - case at: - case ke: - case Qe: - case tt: - case Ye: - case dt: - case lt: - case ct: - case qt: - return iw(c, y); - case ie: - return new O(); - case ue: - case Ne: - return new O(c); - case $e: - return $P(c); - case Me: - return new O(); - case Ke: - return FP(c); - } - } - function eM(c, h) { - var y = h.length; - if (!y) - return c; - var O = y - 1; - return h[O] = (y > 1 ? "& " : "") + h[O], h = h.join(y > 2 ? ", " : " "), c.replace(z, `{ -/* [wrapped with ` + h + `] */ -`); - } - function tM(c) { - return nr(c) || Ua(c) || !!(My && c && c[My]); - } - function uo(c, h) { - var y = typeof c; - return h = h ?? _, !!h && (y == "number" || y != "symbol" && it.test(c)) && c > -1 && c % 1 == 0 && c < h; - } - function ri(c, h, y) { - if (!Zr(y)) - return !1; - var O = typeof h; - return (O == "number" ? fi(y) && uo(h, y.length) : O == "string" && h in y) ? hs(y[h], c) : !1; - } - function yg(c, h) { - if (nr(c)) - return !1; - var y = typeof c; - return y == "number" || y == "symbol" || y == "boolean" || c == null || Mi(c) ? !0 : $t.test(c) || !vt.test(c) || h != null && c in qr(h); - } - function rM(c) { - var h = typeof c; - return h == "string" || h == "number" || h == "symbol" || h == "boolean" ? c !== "__proto__" : c === null; - } - function wg(c) { - var h = Hh(c), y = ee[h]; - if (typeof y != "function" || !(h in wr.prototype)) - return !1; - if (c === y) - return !0; - var O = mg(y); - return !!O && c === O[0]; - } - function nM(c) { - return !!Ey && Ey in c; - } - var iM = wh ? fo : $g; - function lf(c) { - var h = c && c.constructor, y = typeof h == "function" && h.prototype || Dc; - return c === y; - } - function Ew(c) { - return c === c && !Zr(c); - } - function Sw(c, h) { - return function(y) { - return y == null ? !1 : y[c] === h && (h !== r || c in qr(y)); - }; - } - function sM(c) { - var h = Jh(c, function(O) { - return y.size === l && y.clear(), O; - }), y = h.cache; - return h; - } - function oM(c, h) { - var y = c[1], O = h[1], q = y | O, ne = q < (L | F | R), fe = O == R && y == K || O == R && y == W && c[7].length <= h[8] || O == (R | W) && h[7].length <= h[8] && y == K; - if (!(ne || fe)) - return c; - O & L && (c[2] = h[2], q |= y & L ? 0 : $); - var ge = h[3]; - if (ge) { - var we = c[3]; - c[3] = we ? ow(we, ge, h[4]) : ge, c[4] = we ? Wo(c[3], d) : h[4]; - } - return ge = h[5], ge && (we = c[5], c[5] = we ? aw(we, ge, h[6]) : ge, c[6] = we ? Wo(c[5], d) : h[6]), ge = h[7], ge && (c[7] = ge), O & R && (c[8] = c[8] == null ? h[8] : Wn(c[8], h[8])), c[9] == null && (c[9] = h[9]), c[0] = h[0], c[1] = q, c; - } - function aM(c) { - var h = []; - if (c != null) - for (var y in qr(c)) - h.push(y); - return h; - } - function cM(c) { - return _h.call(c); - } - function Aw(c, h, y) { - return h = _n(h === r ? c.length - 1 : h, 0), function() { - for (var O = arguments, q = -1, ne = _n(O.length - h, 0), fe = Ie(ne); ++q < ne; ) - fe[q] = O[h + q]; - q = -1; - for (var ge = Ie(h + 1); ++q < h; ) - ge[q] = O[q]; - return ge[h] = y(fe), Pn(c, this, ge); - }; - } - function Pw(c, h) { - return h.length < 2 ? c : $a(c, Hi(h, 0, -1)); - } - function uM(c, h) { - for (var y = c.length, O = Wn(h.length, y), q = ui(c); O--; ) { - var ne = h[O]; - c[O] = uo(ne, y) ? q[ne] : r; - } - return c; - } - function xg(c, h) { - if (!(h === "constructor" && typeof c[h] == "function") && h != "__proto__") - return c[h]; - } - var Mw = Cw(Jy), hf = SA || function(c, h) { - return _r.setTimeout(c, h); - }, _g = Cw(DP); - function Iw(c, h, y) { - var O = h + ""; - return _g(c, eM(O, fM(XP(O), y))); - } - function Cw(c) { - var h = 0, y = 0; - return function() { - var O = IA(), q = m - (O - y); - if (y = O, q > 0) { - if (++h >= S) - return arguments[0]; - } else - h = 0; - return c.apply(r, arguments); - }; - } - function Kh(c, h) { - var y = -1, O = c.length, q = O - 1; - for (h = h === r ? O : h; ++y < h; ) { - var ne = ig(y, q), fe = c[ne]; - c[ne] = c[y], c[y] = fe; - } - return c.length = h, c; - } - var Tw = sM(function(c) { - var h = []; - return c.charCodeAt(0) === 46 && h.push(""), c.replace(Bt, function(y, O, q, ne) { - h.push(q ? ne.replace(he, "$1") : O || y); - }), h; - }); - function Ts(c) { - if (typeof c == "string" || Mi(c)) - return c; - var h = c + ""; - return h == "0" && 1 / c == -x ? "-0" : h; - } - function Ba(c) { - if (c != null) { - try { - return xh.call(c); - } catch { - } - try { - return c + ""; - } catch { - } - } - return ""; - } - function fM(c, h) { - return Ui(ce, function(y) { - var O = "_." + y[0]; - h & y[1] && !mh(c, O) && c.push(O); - }), c.sort(); - } - function Rw(c) { - if (c instanceof wr) - return c.clone(); - var h = new qi(c.__wrapped__, c.__chain__); - return h.__actions__ = ui(c.__actions__), h.__index__ = c.__index__, h.__values__ = c.__values__, h; - } - function lM(c, h, y) { - (y ? ri(c, h, y) : h === r) ? h = 1 : h = _n(ar(h), 0); - var O = c == null ? 0 : c.length; - if (!O || h < 1) - return []; - for (var q = 0, ne = 0, fe = Ie(Ih(O / h)); q < O; ) - fe[ne++] = Hi(c, q, q += h); - return fe; - } - function hM(c) { - for (var h = -1, y = c == null ? 0 : c.length, O = 0, q = []; ++h < y; ) { - var ne = c[h]; - ne && (q[O++] = ne); - } - return q; - } - function dM() { - var c = arguments.length; - if (!c) - return []; - for (var h = Ie(c - 1), y = arguments[0], O = c; O--; ) - h[O - 1] = arguments[O]; - return Ho(nr(y) ? ui(y) : [y], $n(h, 1)); - } - var pM = hr(function(c, h) { - return cn(c) ? of(c, $n(h, 1, cn, !0)) : []; - }), gM = hr(function(c, h) { - var y = Wi(h); - return cn(y) && (y = r), cn(c) ? of(c, $n(h, 1, cn, !0), jt(y, 2)) : []; - }), mM = hr(function(c, h) { - var y = Wi(h); - return cn(y) && (y = r), cn(c) ? of(c, $n(h, 1, cn, !0), r, y) : []; - }); - function vM(c, h, y) { - var O = c == null ? 0 : c.length; - return O ? (h = y || h === r ? 1 : ar(h), Hi(c, h < 0 ? 0 : h, O)) : []; - } - function bM(c, h, y) { - var O = c == null ? 0 : c.length; - return O ? (h = y || h === r ? 1 : ar(h), h = O - h, Hi(c, 0, h < 0 ? 0 : h)) : []; - } - function yM(c, h) { - return c && c.length ? Fh(c, jt(h, 3), !0, !0) : []; - } - function wM(c, h) { - return c && c.length ? Fh(c, jt(h, 3), !0) : []; - } - function xM(c, h, y, O) { - var q = c == null ? 0 : c.length; - return q ? (y && typeof y != "number" && ri(c, h, y) && (y = 0, O = q), dP(c, h, y, O)) : []; - } - function Dw(c, h, y) { - var O = c == null ? 0 : c.length; - if (!O) - return -1; - var q = y == null ? 0 : ar(y); - return q < 0 && (q = _n(O + q, 0)), vh(c, jt(h, 3), q); - } - function Ow(c, h, y) { - var O = c == null ? 0 : c.length; - if (!O) - return -1; - var q = O - 1; - return y !== r && (q = ar(y), q = y < 0 ? _n(O + q, 0) : Wn(q, O - 1)), vh(c, jt(h, 3), q, !0); - } - function Nw(c) { - var h = c == null ? 0 : c.length; - return h ? $n(c, 1) : []; - } - function _M(c) { - var h = c == null ? 0 : c.length; - return h ? $n(c, x) : []; - } - function EM(c, h) { - var y = c == null ? 0 : c.length; - return y ? (h = h === r ? 1 : ar(h), $n(c, h)) : []; - } - function SM(c) { - for (var h = -1, y = c == null ? 0 : c.length, O = {}; ++h < y; ) { - var q = c[h]; - O[q[0]] = q[1]; - } - return O; - } - function Lw(c) { - return c && c.length ? c[0] : r; - } - function AM(c, h, y) { - var O = c == null ? 0 : c.length; - if (!O) - return -1; - var q = y == null ? 0 : ar(y); - return q < 0 && (q = _n(O + q, 0)), Ic(c, h, q); - } - function PM(c) { - var h = c == null ? 0 : c.length; - return h ? Hi(c, 0, -1) : []; - } - var MM = hr(function(c) { - var h = Xr(c, ug); - return h.length && h[0] === c[0] ? Qp(h) : []; - }), IM = hr(function(c) { - var h = Wi(c), y = Xr(c, ug); - return h === Wi(y) ? h = r : y.pop(), y.length && y[0] === c[0] ? Qp(y, jt(h, 2)) : []; - }), CM = hr(function(c) { - var h = Wi(c), y = Xr(c, ug); - return h = typeof h == "function" ? h : r, h && y.pop(), y.length && y[0] === c[0] ? Qp(y, r, h) : []; - }); - function TM(c, h) { - return c == null ? "" : PA.call(c, h); - } - function Wi(c) { - var h = c == null ? 0 : c.length; - return h ? c[h - 1] : r; - } - function RM(c, h, y) { - var O = c == null ? 0 : c.length; - if (!O) - return -1; - var q = O; - return y !== r && (q = ar(y), q = q < 0 ? _n(O + q, 0) : Wn(q, O - 1)), h === h ? fA(c, h, q) : vh(c, gy, q, !0); - } - function DM(c, h) { - return c && c.length ? Ky(c, ar(h)) : r; - } - var OM = hr(kw); - function kw(c, h) { - return c && c.length && h && h.length ? ng(c, h) : c; - } - function NM(c, h, y) { - return c && c.length && h && h.length ? ng(c, h, jt(y, 2)) : c; - } - function LM(c, h, y) { - return c && c.length && h && h.length ? ng(c, h, r, y) : c; - } - var kM = co(function(c, h) { - var y = c == null ? 0 : c.length, O = Yp(c, h); - return Yy(c, Xr(h, function(q) { - return uo(q, y) ? +q : q; - }).sort(sw)), O; - }); - function $M(c, h) { - var y = []; - if (!(c && c.length)) - return y; - var O = -1, q = [], ne = c.length; - for (h = jt(h, 3); ++O < ne; ) { - var fe = c[O]; - h(fe, O, c) && (y.push(fe), q.push(O)); - } - return Yy(c, q), y; - } - function Eg(c) { - return c == null ? c : TA.call(c); - } - function FM(c, h, y) { - var O = c == null ? 0 : c.length; - return O ? (y && typeof y != "number" && ri(c, h, y) ? (h = 0, y = O) : (h = h == null ? 0 : ar(h), y = y === r ? O : ar(y)), Hi(c, h, y)) : []; - } - function BM(c, h) { - return $h(c, h); - } - function UM(c, h, y) { - return og(c, h, jt(y, 2)); - } - function jM(c, h) { - var y = c == null ? 0 : c.length; - if (y) { - var O = $h(c, h); - if (O < y && hs(c[O], h)) - return O; - } - return -1; - } - function qM(c, h) { - return $h(c, h, !0); - } - function zM(c, h, y) { - return og(c, h, jt(y, 2), !0); - } - function HM(c, h) { - var y = c == null ? 0 : c.length; - if (y) { - var O = $h(c, h, !0) - 1; - if (hs(c[O], h)) - return O; - } - return -1; - } - function WM(c) { - return c && c.length ? Xy(c) : []; - } - function KM(c, h) { - return c && c.length ? Xy(c, jt(h, 2)) : []; - } - function VM(c) { - var h = c == null ? 0 : c.length; - return h ? Hi(c, 1, h) : []; - } - function GM(c, h, y) { - return c && c.length ? (h = y || h === r ? 1 : ar(h), Hi(c, 0, h < 0 ? 0 : h)) : []; - } - function YM(c, h, y) { - var O = c == null ? 0 : c.length; - return O ? (h = y || h === r ? 1 : ar(h), h = O - h, Hi(c, h < 0 ? 0 : h, O)) : []; - } - function JM(c, h) { - return c && c.length ? Fh(c, jt(h, 3), !1, !0) : []; - } - function XM(c, h) { - return c && c.length ? Fh(c, jt(h, 3)) : []; - } - var ZM = hr(function(c) { - return Go($n(c, 1, cn, !0)); - }), QM = hr(function(c) { - var h = Wi(c); - return cn(h) && (h = r), Go($n(c, 1, cn, !0), jt(h, 2)); - }), eI = hr(function(c) { - var h = Wi(c); - return h = typeof h == "function" ? h : r, Go($n(c, 1, cn, !0), r, h); - }); - function tI(c) { - return c && c.length ? Go(c) : []; - } - function rI(c, h) { - return c && c.length ? Go(c, jt(h, 2)) : []; - } - function nI(c, h) { - return h = typeof h == "function" ? h : r, c && c.length ? Go(c, r, h) : []; - } - function Sg(c) { - if (!(c && c.length)) - return []; - var h = 0; - return c = zo(c, function(y) { - if (cn(y)) - return h = _n(y.length, h), !0; - }), jp(h, function(y) { - return Xr(c, Fp(y)); - }); - } - function $w(c, h) { - if (!(c && c.length)) - return []; - var y = Sg(c); - return h == null ? y : Xr(y, function(O) { - return Pn(h, r, O); - }); - } - var iI = hr(function(c, h) { - return cn(c) ? of(c, h) : []; - }), sI = hr(function(c) { - return cg(zo(c, cn)); - }), oI = hr(function(c) { - var h = Wi(c); - return cn(h) && (h = r), cg(zo(c, cn), jt(h, 2)); - }), aI = hr(function(c) { - var h = Wi(c); - return h = typeof h == "function" ? h : r, cg(zo(c, cn), r, h); - }), cI = hr(Sg); - function uI(c, h) { - return tw(c || [], h || [], sf); - } - function fI(c, h) { - return tw(c || [], h || [], uf); - } - var lI = hr(function(c) { - var h = c.length, y = h > 1 ? c[h - 1] : r; - return y = typeof y == "function" ? (c.pop(), y) : r, $w(c, y); - }); - function Fw(c) { - var h = ee(c); - return h.__chain__ = !0, h; - } - function hI(c, h) { - return h(c), c; - } - function Vh(c, h) { - return h(c); - } - var dI = co(function(c) { - var h = c.length, y = h ? c[0] : 0, O = this.__wrapped__, q = function(ne) { - return Yp(ne, c); - }; - return h > 1 || this.__actions__.length || !(O instanceof wr) || !uo(y) ? this.thru(q) : (O = O.slice(y, +y + (h ? 1 : 0)), O.__actions__.push({ - func: Vh, - args: [q], - thisArg: r - }), new qi(O, this.__chain__).thru(function(ne) { - return h && !ne.length && ne.push(r), ne; - })); - }); - function pI() { - return Fw(this); - } - function gI() { - return new qi(this.value(), this.__chain__); - } - function mI() { - this.__values__ === r && (this.__values__ = Zw(this.value())); - var c = this.__index__ >= this.__values__.length, h = c ? r : this.__values__[this.__index__++]; - return { done: c, value: h }; - } - function vI() { - return this; - } - function bI(c) { - for (var h, y = this; y instanceof Dh; ) { - var O = Rw(y); - O.__index__ = 0, O.__values__ = r, h ? q.__wrapped__ = O : h = O; - var q = O; - y = y.__wrapped__; - } - return q.__wrapped__ = c, h; - } - function yI() { - var c = this.__wrapped__; - if (c instanceof wr) { - var h = c; - return this.__actions__.length && (h = new wr(this)), h = h.reverse(), h.__actions__.push({ - func: Vh, - args: [Eg], - thisArg: r - }), new qi(h, this.__chain__); - } - return this.thru(Eg); - } - function wI() { - return ew(this.__wrapped__, this.__actions__); - } - var xI = Bh(function(c, h, y) { - Tr.call(c, y) ? ++c[y] : oo(c, y, 1); - }); - function _I(c, h, y) { - var O = nr(c) ? dy : hP; - return y && ri(c, h, y) && (h = r), O(c, jt(h, 3)); - } - function EI(c, h) { - var y = nr(c) ? zo : $y; - return y(c, jt(h, 3)); - } - var SI = lw(Dw), AI = lw(Ow); - function PI(c, h) { - return $n(Gh(c, h), 1); - } - function MI(c, h) { - return $n(Gh(c, h), x); - } - function II(c, h, y) { - return y = y === r ? 1 : ar(y), $n(Gh(c, h), y); - } - function Bw(c, h) { - var y = nr(c) ? Ui : Vo; - return y(c, jt(h, 3)); - } - function Uw(c, h) { - var y = nr(c) ? V9 : ky; - return y(c, jt(h, 3)); - } - var CI = Bh(function(c, h, y) { - Tr.call(c, y) ? c[y].push(h) : oo(c, y, [h]); - }); - function TI(c, h, y, O) { - c = fi(c) ? c : Uc(c), y = y && !O ? ar(y) : 0; - var q = c.length; - return y < 0 && (y = _n(q + y, 0)), Qh(c) ? y <= q && c.indexOf(h, y) > -1 : !!q && Ic(c, h, y) > -1; - } - var RI = hr(function(c, h, y) { - var O = -1, q = typeof h == "function", ne = fi(c) ? Ie(c.length) : []; - return Vo(c, function(fe) { - ne[++O] = q ? Pn(h, fe, y) : af(fe, h, y); - }), ne; - }), DI = Bh(function(c, h, y) { - oo(c, y, h); - }); - function Gh(c, h) { - var y = nr(c) ? Xr : zy; - return y(c, jt(h, 3)); - } - function OI(c, h, y, O) { - return c == null ? [] : (nr(h) || (h = h == null ? [] : [h]), y = O ? r : y, nr(y) || (y = y == null ? [] : [y]), Vy(c, h, y)); - } - var NI = Bh(function(c, h, y) { - c[y ? 0 : 1].push(h); - }, function() { - return [[], []]; - }); - function LI(c, h, y) { - var O = nr(c) ? kp : vy, q = arguments.length < 3; - return O(c, jt(h, 4), y, q, Vo); - } - function kI(c, h, y) { - var O = nr(c) ? G9 : vy, q = arguments.length < 3; - return O(c, jt(h, 4), y, q, ky); - } - function $I(c, h) { - var y = nr(c) ? zo : $y; - return y(c, Xh(jt(h, 3))); - } - function FI(c) { - var h = nr(c) ? Dy : TP; - return h(c); - } - function BI(c, h, y) { - (y ? ri(c, h, y) : h === r) ? h = 1 : h = ar(h); - var O = nr(c) ? aP : RP; - return O(c, h); - } - function UI(c) { - var h = nr(c) ? cP : OP; - return h(c); - } - function jI(c) { - if (c == null) - return 0; - if (fi(c)) - return Qh(c) ? Tc(c) : c.length; - var h = Kn(c); - return h == ie || h == Me ? c.size : tg(c).length; - } - function qI(c, h, y) { - var O = nr(c) ? $p : NP; - return y && ri(c, h, y) && (h = r), O(c, jt(h, 3)); - } - var zI = hr(function(c, h) { - if (c == null) - return []; - var y = h.length; - return y > 1 && ri(c, h[0], h[1]) ? h = [] : y > 2 && ri(h[0], h[1], h[2]) && (h = [h[0]]), Vy(c, $n(h, 1), []); - }), Yh = EA || function() { - return _r.Date.now(); - }; - function HI(c, h) { - if (typeof h != "function") - throw new ji(o); - return c = ar(c), function() { - if (--c < 1) - return h.apply(this, arguments); - }; - } - function jw(c, h, y) { - return h = y ? r : h, h = c && h == null ? c.length : h, ao(c, R, r, r, r, r, h); - } - function qw(c, h) { - var y; - if (typeof h != "function") - throw new ji(o); - return c = ar(c), function() { - return --c > 0 && (y = h.apply(this, arguments)), c <= 1 && (h = r), y; - }; - } - var Ag = hr(function(c, h, y) { - var O = L; - if (y.length) { - var q = Wo(y, Fc(Ag)); - O |= V; - } - return ao(c, O, h, y, q); - }), zw = hr(function(c, h, y) { - var O = L | F; - if (y.length) { - var q = Wo(y, Fc(zw)); - O |= V; - } - return ao(h, O, c, y, q); - }); - function Hw(c, h, y) { - h = y ? r : h; - var O = ao(c, K, r, r, r, r, r, h); - return O.placeholder = Hw.placeholder, O; - } - function Ww(c, h, y) { - h = y ? r : h; - var O = ao(c, H, r, r, r, r, r, h); - return O.placeholder = Ww.placeholder, O; - } - function Kw(c, h, y) { - var O, q, ne, fe, ge, we, He = 0, We = !1, Xe = !1, wt = !0; - if (typeof c != "function") - throw new ji(o); - h = Ki(h) || 0, Zr(y) && (We = !!y.leading, Xe = "maxWait" in y, ne = Xe ? _n(Ki(y.maxWait) || 0, h) : ne, wt = "trailing" in y ? !!y.trailing : wt); - function Ot(un) { - var ds = O, ho = q; - return O = q = r, He = un, fe = c.apply(ho, ds), fe; - } - function Wt(un) { - return He = un, ge = hf(vr, h), We ? Ot(un) : fe; - } - function ur(un) { - var ds = un - we, ho = un - He, l2 = h - ds; - return Xe ? Wn(l2, ne - ho) : l2; - } - function Kt(un) { - var ds = un - we, ho = un - He; - return we === r || ds >= h || ds < 0 || Xe && ho >= ne; - } - function vr() { - var un = Yh(); - if (Kt(un)) - return Er(un); - ge = hf(vr, ur(un)); - } - function Er(un) { - return ge = r, wt && O ? Ot(un) : (O = q = r, fe); - } - function Ii() { - ge !== r && rw(ge), He = 0, O = we = q = ge = r; - } - function ni() { - return ge === r ? fe : Er(Yh()); - } - function Ci() { - var un = Yh(), ds = Kt(un); - if (O = arguments, q = this, we = un, ds) { - if (ge === r) - return Wt(we); - if (Xe) - return rw(ge), ge = hf(vr, h), Ot(we); - } - return ge === r && (ge = hf(vr, h)), fe; - } - return Ci.cancel = Ii, Ci.flush = ni, Ci; - } - var WI = hr(function(c, h) { - return Ly(c, 1, h); - }), KI = hr(function(c, h, y) { - return Ly(c, Ki(h) || 0, y); - }); - function VI(c) { - return ao(c, pe); - } - function Jh(c, h) { - if (typeof c != "function" || h != null && typeof h != "function") - throw new ji(o); - var y = function() { - var O = arguments, q = h ? h.apply(this, O) : O[0], ne = y.cache; - if (ne.has(q)) - return ne.get(q); - var fe = c.apply(this, O); - return y.cache = ne.set(q, fe) || ne, fe; - }; - return y.cache = new (Jh.Cache || so)(), y; - } - Jh.Cache = so; - function Xh(c) { - if (typeof c != "function") - throw new ji(o); - return function() { - var h = arguments; - switch (h.length) { - case 0: - return !c.call(this); - case 1: - return !c.call(this, h[0]); - case 2: - return !c.call(this, h[0], h[1]); - case 3: - return !c.call(this, h[0], h[1], h[2]); - } - return !c.apply(this, h); - }; - } - function GI(c) { - return qw(2, c); - } - var YI = LP(function(c, h) { - h = h.length == 1 && nr(h[0]) ? Xr(h[0], Ai(jt())) : Xr($n(h, 1), Ai(jt())); - var y = h.length; - return hr(function(O) { - for (var q = -1, ne = Wn(O.length, y); ++q < ne; ) - O[q] = h[q].call(this, O[q]); - return Pn(c, this, O); - }); - }), Pg = hr(function(c, h) { - var y = Wo(h, Fc(Pg)); - return ao(c, V, r, h, y); - }), Vw = hr(function(c, h) { - var y = Wo(h, Fc(Vw)); - return ao(c, te, r, h, y); - }), JI = co(function(c, h) { - return ao(c, W, r, r, r, h); - }); - function XI(c, h) { - if (typeof c != "function") - throw new ji(o); - return h = h === r ? h : ar(h), hr(c, h); - } - function ZI(c, h) { - if (typeof c != "function") - throw new ji(o); - return h = h == null ? 0 : _n(ar(h), 0), hr(function(y) { - var O = y[h], q = Jo(y, 0, h); - return O && Ho(q, O), Pn(c, this, q); - }); - } - function QI(c, h, y) { - var O = !0, q = !0; - if (typeof c != "function") - throw new ji(o); - return Zr(y) && (O = "leading" in y ? !!y.leading : O, q = "trailing" in y ? !!y.trailing : q), Kw(c, h, { - leading: O, - maxWait: h, - trailing: q - }); - } - function eC(c) { - return jw(c, 1); - } - function tC(c, h) { - return Pg(fg(h), c); - } - function rC() { - if (!arguments.length) - return []; - var c = arguments[0]; - return nr(c) ? c : [c]; - } - function nC(c) { - return zi(c, A); - } - function iC(c, h) { - return h = typeof h == "function" ? h : r, zi(c, A, h); - } - function sC(c) { - return zi(c, g | A); - } - function oC(c, h) { - return h = typeof h == "function" ? h : r, zi(c, g | A, h); - } - function aC(c, h) { - return h == null || Ny(c, h, Mn(h)); - } - function hs(c, h) { - return c === h || c !== c && h !== h; - } - var cC = zh(Zp), uC = zh(function(c, h) { - return c >= h; - }), Ua = Uy(/* @__PURE__ */ function() { - return arguments; - }()) ? Uy : function(c) { - return en(c) && Tr.call(c, "callee") && !Py.call(c, "callee"); - }, nr = Ie.isArray, fC = ei ? Ai(ei) : bP; - function fi(c) { - return c != null && Zh(c.length) && !fo(c); - } - function cn(c) { - return en(c) && fi(c); - } - function lC(c) { - return c === !0 || c === !1 || en(c) && ti(c) == J; - } - var Xo = AA || $g, hC = us ? Ai(us) : yP; - function dC(c) { - return en(c) && c.nodeType === 1 && !df(c); - } - function pC(c) { - if (c == null) - return !0; - if (fi(c) && (nr(c) || typeof c == "string" || typeof c.splice == "function" || Xo(c) || Bc(c) || Ua(c))) - return !c.length; - var h = Kn(c); - if (h == ie || h == Me) - return !c.size; - if (lf(c)) - return !tg(c).length; - for (var y in c) - if (Tr.call(c, y)) - return !1; - return !0; - } - function gC(c, h) { - return cf(c, h); - } - function mC(c, h, y) { - y = typeof y == "function" ? y : r; - var O = y ? y(c, h) : r; - return O === r ? cf(c, h, r, y) : !!O; - } - function Mg(c) { - if (!en(c)) - return !1; - var h = ti(c); - return h == X || h == T || typeof c.message == "string" && typeof c.name == "string" && !df(c); - } - function vC(c) { - return typeof c == "number" && Iy(c); - } - function fo(c) { - if (!Zr(c)) - return !1; - var h = ti(c); - return h == re || h == de || h == Z || h == Ce; - } - function Gw(c) { - return typeof c == "number" && c == ar(c); - } - function Zh(c) { - return typeof c == "number" && c > -1 && c % 1 == 0 && c <= _; - } - function Zr(c) { - var h = typeof c; - return c != null && (h == "object" || h == "function"); - } - function en(c) { - return c != null && typeof c == "object"; - } - var Yw = Bi ? Ai(Bi) : xP; - function bC(c, h) { - return c === h || eg(c, h, vg(h)); - } - function yC(c, h, y) { - return y = typeof y == "function" ? y : r, eg(c, h, vg(h), y); - } - function wC(c) { - return Jw(c) && c != +c; - } - function xC(c) { - if (iM(c)) - throw new er(s); - return jy(c); - } - function _C(c) { - return c === null; - } - function EC(c) { - return c == null; - } - function Jw(c) { - return typeof c == "number" || en(c) && ti(c) == ue; - } - function df(c) { - if (!en(c) || ti(c) != Pe) - return !1; - var h = Ah(c); - if (h === null) - return !0; - var y = Tr.call(h, "constructor") && h.constructor; - return typeof y == "function" && y instanceof y && xh.call(y) == yA; - } - var Ig = Ms ? Ai(Ms) : _P; - function SC(c) { - return Gw(c) && c >= -_ && c <= _; - } - var Xw = Xu ? Ai(Xu) : EP; - function Qh(c) { - return typeof c == "string" || !nr(c) && en(c) && ti(c) == Ne; - } - function Mi(c) { - return typeof c == "symbol" || en(c) && ti(c) == Ke; - } - var Bc = Da ? Ai(Da) : SP; - function AC(c) { - return c === r; - } - function PC(c) { - return en(c) && Kn(c) == qe; - } - function MC(c) { - return en(c) && ti(c) == ze; - } - var IC = zh(rg), CC = zh(function(c, h) { - return c <= h; - }); - function Zw(c) { - if (!c) - return []; - if (fi(c)) - return Qh(c) ? fs(c) : ui(c); - if (Qu && c[Qu]) - return aA(c[Qu]()); - var h = Kn(c), y = h == ie ? zp : h == Me ? bh : Uc; - return y(c); - } - function lo(c) { - if (!c) - return c === 0 ? c : 0; - if (c = Ki(c), c === x || c === -x) { - var h = c < 0 ? -1 : 1; - return h * E; - } - return c === c ? c : 0; - } - function ar(c) { - var h = lo(c), y = h % 1; - return h === h ? y ? h - y : h : 0; - } - function Qw(c) { - return c ? ka(ar(c), 0, P) : 0; - } - function Ki(c) { - if (typeof c == "number") - return c; - if (Mi(c)) - return v; - if (Zr(c)) { - var h = typeof c.valueOf == "function" ? c.valueOf() : c; - c = Zr(h) ? h + "" : h; - } - if (typeof c != "string") - return c === 0 ? c : +c; - c = by(c); - var y = nt.test(c); - return y || pt.test(c) ? rr(c.slice(2), y ? 2 : 8) : Re.test(c) ? v : +c; - } - function e2(c) { - return Cs(c, li(c)); - } - function TC(c) { - return c ? ka(ar(c), -_, _) : c === 0 ? c : 0; - } - function Cr(c) { - return c == null ? "" : Pi(c); - } - var RC = kc(function(c, h) { - if (lf(h) || fi(h)) { - Cs(h, Mn(h), c); - return; - } - for (var y in h) - Tr.call(h, y) && sf(c, y, h[y]); - }), t2 = kc(function(c, h) { - Cs(h, li(h), c); - }), ed = kc(function(c, h, y, O) { - Cs(h, li(h), c, O); - }), DC = kc(function(c, h, y, O) { - Cs(h, Mn(h), c, O); - }), OC = co(Yp); - function NC(c, h) { - var y = Lc(c); - return h == null ? y : Oy(y, h); - } - var LC = hr(function(c, h) { - c = qr(c); - var y = -1, O = h.length, q = O > 2 ? h[2] : r; - for (q && ri(h[0], h[1], q) && (O = 1); ++y < O; ) - for (var ne = h[y], fe = li(ne), ge = -1, we = fe.length; ++ge < we; ) { - var He = fe[ge], We = c[He]; - (We === r || hs(We, Dc[He]) && !Tr.call(c, He)) && (c[He] = ne[He]); - } - return c; - }), kC = hr(function(c) { - return c.push(r, bw), Pn(r2, r, c); - }); - function $C(c, h) { - return py(c, jt(h, 3), Is); - } - function FC(c, h) { - return py(c, jt(h, 3), Xp); - } - function BC(c, h) { - return c == null ? c : Jp(c, jt(h, 3), li); - } - function UC(c, h) { - return c == null ? c : Fy(c, jt(h, 3), li); - } - function jC(c, h) { - return c && Is(c, jt(h, 3)); - } - function qC(c, h) { - return c && Xp(c, jt(h, 3)); - } - function zC(c) { - return c == null ? [] : Lh(c, Mn(c)); - } - function HC(c) { - return c == null ? [] : Lh(c, li(c)); - } - function Cg(c, h, y) { - var O = c == null ? r : $a(c, h); - return O === r ? y : O; - } - function WC(c, h) { - return c != null && xw(c, h, pP); - } - function Tg(c, h) { - return c != null && xw(c, h, gP); - } - var KC = dw(function(c, h, y) { - h != null && typeof h.toString != "function" && (h = _h.call(h)), c[h] = y; - }, Dg(hi)), VC = dw(function(c, h, y) { - h != null && typeof h.toString != "function" && (h = _h.call(h)), Tr.call(c, h) ? c[h].push(y) : c[h] = [y]; - }, jt), GC = hr(af); - function Mn(c) { - return fi(c) ? Ry(c) : tg(c); - } - function li(c) { - return fi(c) ? Ry(c, !0) : AP(c); - } - function YC(c, h) { - var y = {}; - return h = jt(h, 3), Is(c, function(O, q, ne) { - oo(y, h(O, q, ne), O); - }), y; - } - function JC(c, h) { - var y = {}; - return h = jt(h, 3), Is(c, function(O, q, ne) { - oo(y, q, h(O, q, ne)); - }), y; - } - var XC = kc(function(c, h, y) { - kh(c, h, y); - }), r2 = kc(function(c, h, y, O) { - kh(c, h, y, O); - }), ZC = co(function(c, h) { - var y = {}; - if (c == null) - return y; - var O = !1; - h = Xr(h, function(ne) { - return ne = Yo(ne, c), O || (O = ne.length > 1), ne; - }), Cs(c, gg(c), y), O && (y = zi(y, g | w | A, KP)); - for (var q = h.length; q--; ) - ag(y, h[q]); - return y; - }); - function QC(c, h) { - return n2(c, Xh(jt(h))); - } - var eT = co(function(c, h) { - return c == null ? {} : MP(c, h); - }); - function n2(c, h) { - if (c == null) - return {}; - var y = Xr(gg(c), function(O) { - return [O]; - }); - return h = jt(h), Gy(c, y, function(O, q) { - return h(O, q[0]); - }); - } - function tT(c, h, y) { - h = Yo(h, c); - var O = -1, q = h.length; - for (q || (q = 1, c = r); ++O < q; ) { - var ne = c == null ? r : c[Ts(h[O])]; - ne === r && (O = q, ne = y), c = fo(ne) ? ne.call(c) : ne; - } - return c; - } - function rT(c, h, y) { - return c == null ? c : uf(c, h, y); - } - function nT(c, h, y, O) { - return O = typeof O == "function" ? O : r, c == null ? c : uf(c, h, y, O); - } - var i2 = mw(Mn), s2 = mw(li); - function iT(c, h, y) { - var O = nr(c), q = O || Xo(c) || Bc(c); - if (h = jt(h, 4), y == null) { - var ne = c && c.constructor; - q ? y = O ? new ne() : [] : Zr(c) ? y = fo(ne) ? Lc(Ah(c)) : {} : y = {}; - } - return (q ? Ui : Is)(c, function(fe, ge, we) { - return h(y, fe, ge, we); - }), y; - } - function sT(c, h) { - return c == null ? !0 : ag(c, h); - } - function oT(c, h, y) { - return c == null ? c : Qy(c, h, fg(y)); - } - function aT(c, h, y, O) { - return O = typeof O == "function" ? O : r, c == null ? c : Qy(c, h, fg(y), O); - } - function Uc(c) { - return c == null ? [] : qp(c, Mn(c)); - } - function cT(c) { - return c == null ? [] : qp(c, li(c)); - } - function uT(c, h, y) { - return y === r && (y = h, h = r), y !== r && (y = Ki(y), y = y === y ? y : 0), h !== r && (h = Ki(h), h = h === h ? h : 0), ka(Ki(c), h, y); - } - function fT(c, h, y) { - return h = lo(h), y === r ? (y = h, h = 0) : y = lo(y), c = Ki(c), mP(c, h, y); - } - function lT(c, h, y) { - if (y && typeof y != "boolean" && ri(c, h, y) && (h = y = r), y === r && (typeof h == "boolean" ? (y = h, h = r) : typeof c == "boolean" && (y = c, c = r)), c === r && h === r ? (c = 0, h = 1) : (c = lo(c), h === r ? (h = c, c = 0) : h = lo(h)), c > h) { - var O = c; - c = h, h = O; - } - if (y || c % 1 || h % 1) { - var q = Cy(); - return Wn(c + q * (h - c + Ur("1e-" + ((q + "").length - 1))), h); - } - return ig(c, h); - } - var hT = $c(function(c, h, y) { - return h = h.toLowerCase(), c + (y ? o2(h) : h); - }); - function o2(c) { - return Rg(Cr(c).toLowerCase()); - } - function a2(c) { - return c = Cr(c), c && c.replace(et, rA).replace(Op, ""); - } - function dT(c, h, y) { - c = Cr(c), h = Pi(h); - var O = c.length; - y = y === r ? O : ka(ar(y), 0, O); - var q = y; - return y -= h.length, y >= 0 && c.slice(y, q) == h; - } - function pT(c) { - return c = Cr(c), c && Ct.test(c) ? c.replace(Dt, nA) : c; - } - function gT(c) { - return c = Cr(c), c && Ft.test(c) ? c.replace(rt, "\\$&") : c; - } - var mT = $c(function(c, h, y) { - return c + (y ? "-" : "") + h.toLowerCase(); - }), vT = $c(function(c, h, y) { - return c + (y ? " " : "") + h.toLowerCase(); - }), bT = fw("toLowerCase"); - function yT(c, h, y) { - c = Cr(c), h = ar(h); - var O = h ? Tc(c) : 0; - if (!h || O >= h) - return c; - var q = (h - O) / 2; - return qh(Ch(q), y) + c + qh(Ih(q), y); - } - function wT(c, h, y) { - c = Cr(c), h = ar(h); - var O = h ? Tc(c) : 0; - return h && O < h ? c + qh(h - O, y) : c; - } - function xT(c, h, y) { - c = Cr(c), h = ar(h); - var O = h ? Tc(c) : 0; - return h && O < h ? qh(h - O, y) + c : c; - } - function _T(c, h, y) { - return y || h == null ? h = 0 : h && (h = +h), CA(Cr(c).replace(k, ""), h || 0); - } - function ET(c, h, y) { - return (y ? ri(c, h, y) : h === r) ? h = 1 : h = ar(h), sg(Cr(c), h); - } - function ST() { - var c = arguments, h = Cr(c[0]); - return c.length < 3 ? h : h.replace(c[1], c[2]); - } - var AT = $c(function(c, h, y) { - return c + (y ? "_" : "") + h.toLowerCase(); - }); - function PT(c, h, y) { - return y && typeof y != "number" && ri(c, h, y) && (h = y = r), y = y === r ? P : y >>> 0, y ? (c = Cr(c), c && (typeof h == "string" || h != null && !Ig(h)) && (h = Pi(h), !h && Cc(c)) ? Jo(fs(c), 0, y) : c.split(h, y)) : []; - } - var MT = $c(function(c, h, y) { - return c + (y ? " " : "") + Rg(h); - }); - function IT(c, h, y) { - return c = Cr(c), y = y == null ? 0 : ka(ar(y), 0, c.length), h = Pi(h), c.slice(y, y + h.length) == h; - } - function CT(c, h, y) { - var O = ee.templateSettings; - y && ri(c, h, y) && (h = r), c = Cr(c), h = ed({}, h, O, vw); - var q = ed({}, h.imports, O.imports, vw), ne = Mn(q), fe = qp(q, ne), ge, we, He = 0, We = h.interpolate || St, Xe = "__p += '", wt = Hp( - (h.escape || St).source + "|" + We.source + "|" + (We === Nt ? xe : St).source + "|" + (h.evaluate || St).source + "|$", - "g" - ), Ot = "//# sourceURL=" + (Tr.call(h, "sourceURL") ? (h.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++Np + "]") + ` -`; - c.replace(wt, function(Kt, vr, Er, Ii, ni, Ci) { - return Er || (Er = Ii), Xe += c.slice(He, Ci).replace(Tt, iA), vr && (ge = !0, Xe += `' + -__e(` + vr + `) + -'`), ni && (we = !0, Xe += `'; -` + ni + `; -__p += '`), Er && (Xe += `' + -((__t = (` + Er + `)) == null ? '' : __t) + -'`), He = Ci + Kt.length, Kt; - }), Xe += `'; -`; - var Wt = Tr.call(h, "variable") && h.variable; - if (!Wt) - Xe = `with (obj) { -` + Xe + ` -} -`; - else if (se.test(Wt)) - throw new er(a); - Xe = (we ? Xe.replace(Yt, "") : Xe).replace(Et, "$1").replace(Qt, "$1;"), Xe = "function(" + (Wt || "obj") + `) { -` + (Wt ? "" : `obj || (obj = {}); -`) + "var __t, __p = ''" + (ge ? ", __e = _.escape" : "") + (we ? `, __j = Array.prototype.join; -function print() { __p += __j.call(arguments, '') } -` : `; -`) + Xe + `return __p -}`; - var ur = u2(function() { - return Pr(ne, Ot + "return " + Xe).apply(r, fe); - }); - if (ur.source = Xe, Mg(ur)) - throw ur; - return ur; - } - function TT(c) { - return Cr(c).toLowerCase(); - } - function RT(c) { - return Cr(c).toUpperCase(); - } - function DT(c, h, y) { - if (c = Cr(c), c && (y || h === r)) - return by(c); - if (!c || !(h = Pi(h))) - return c; - var O = fs(c), q = fs(h), ne = yy(O, q), fe = wy(O, q) + 1; - return Jo(O, ne, fe).join(""); - } - function OT(c, h, y) { - if (c = Cr(c), c && (y || h === r)) - return c.slice(0, _y(c) + 1); - if (!c || !(h = Pi(h))) - return c; - var O = fs(c), q = wy(O, fs(h)) + 1; - return Jo(O, 0, q).join(""); - } - function NT(c, h, y) { - if (c = Cr(c), c && (y || h === r)) - return c.replace(k, ""); - if (!c || !(h = Pi(h))) - return c; - var O = fs(c), q = yy(O, fs(h)); - return Jo(O, q).join(""); - } - function LT(c, h) { - var y = Ee, O = Y; - if (Zr(h)) { - var q = "separator" in h ? h.separator : q; - y = "length" in h ? ar(h.length) : y, O = "omission" in h ? Pi(h.omission) : O; - } - c = Cr(c); - var ne = c.length; - if (Cc(c)) { - var fe = fs(c); - ne = fe.length; - } - if (y >= ne) - return c; - var ge = y - Tc(O); - if (ge < 1) - return O; - var we = fe ? Jo(fe, 0, ge).join("") : c.slice(0, ge); - if (q === r) - return we + O; - if (fe && (ge += we.length - ge), Ig(q)) { - if (c.slice(ge).search(q)) { - var He, We = we; - for (q.global || (q = Hp(q.source, Cr(Te.exec(q)) + "g")), q.lastIndex = 0; He = q.exec(We); ) - var Xe = He.index; - we = we.slice(0, Xe === r ? ge : Xe); - } - } else if (c.indexOf(Pi(q), ge) != ge) { - var wt = we.lastIndexOf(q); - wt > -1 && (we = we.slice(0, wt)); - } - return we + O; - } - function kT(c) { - return c = Cr(c), c && kt.test(c) ? c.replace(Jt, lA) : c; - } - var $T = $c(function(c, h, y) { - return c + (y ? " " : "") + h.toUpperCase(); - }), Rg = fw("toUpperCase"); - function c2(c, h, y) { - return c = Cr(c), h = y ? r : h, h === r ? oA(c) ? pA(c) : X9(c) : c.match(h) || []; - } - var u2 = hr(function(c, h) { - try { - return Pn(c, r, h); - } catch (y) { - return Mg(y) ? y : new er(y); - } - }), FT = co(function(c, h) { - return Ui(h, function(y) { - y = Ts(y), oo(c, y, Ag(c[y], c)); - }), c; - }); - function BT(c) { - var h = c == null ? 0 : c.length, y = jt(); - return c = h ? Xr(c, function(O) { - if (typeof O[1] != "function") - throw new ji(o); - return [y(O[0]), O[1]]; - }) : [], hr(function(O) { - for (var q = -1; ++q < h; ) { - var ne = c[q]; - if (Pn(ne[0], this, O)) - return Pn(ne[1], this, O); - } - }); - } - function UT(c) { - return lP(zi(c, g)); - } - function Dg(c) { - return function() { - return c; - }; - } - function jT(c, h) { - return c == null || c !== c ? h : c; - } - var qT = hw(), zT = hw(!0); - function hi(c) { - return c; - } - function Og(c) { - return qy(typeof c == "function" ? c : zi(c, g)); - } - function HT(c) { - return Hy(zi(c, g)); - } - function WT(c, h) { - return Wy(c, zi(h, g)); - } - var KT = hr(function(c, h) { - return function(y) { - return af(y, c, h); - }; - }), VT = hr(function(c, h) { - return function(y) { - return af(c, y, h); - }; - }); - function Ng(c, h, y) { - var O = Mn(h), q = Lh(h, O); - y == null && !(Zr(h) && (q.length || !O.length)) && (y = h, h = c, c = this, q = Lh(h, Mn(h))); - var ne = !(Zr(y) && "chain" in y) || !!y.chain, fe = fo(c); - return Ui(q, function(ge) { - var we = h[ge]; - c[ge] = we, fe && (c.prototype[ge] = function() { - var He = this.__chain__; - if (ne || He) { - var We = c(this.__wrapped__), Xe = We.__actions__ = ui(this.__actions__); - return Xe.push({ func: we, args: arguments, thisArg: c }), We.__chain__ = He, We; - } - return we.apply(c, Ho([this.value()], arguments)); - }); - }), c; - } - function GT() { - return _r._ === this && (_r._ = wA), this; - } - function Lg() { - } - function YT(c) { - return c = ar(c), hr(function(h) { - return Ky(h, c); - }); - } - var JT = hg(Xr), XT = hg(dy), ZT = hg($p); - function f2(c) { - return yg(c) ? Fp(Ts(c)) : IP(c); - } - function QT(c) { - return function(h) { - return c == null ? r : $a(c, h); - }; - } - var eR = pw(), tR = pw(!0); - function kg() { - return []; - } - function $g() { - return !1; - } - function rR() { - return {}; - } - function nR() { - return ""; - } - function iR() { - return !0; - } - function sR(c, h) { - if (c = ar(c), c < 1 || c > _) - return []; - var y = P, O = Wn(c, P); - h = jt(h), c -= P; - for (var q = jp(O, h); ++y < c; ) - h(y); - return q; - } - function oR(c) { - return nr(c) ? Xr(c, Ts) : Mi(c) ? [c] : ui(Tw(Cr(c))); - } - function aR(c) { - var h = ++bA; - return Cr(c) + h; - } - var cR = jh(function(c, h) { - return c + h; - }, 0), uR = dg("ceil"), fR = jh(function(c, h) { - return c / h; - }, 1), lR = dg("floor"); - function hR(c) { - return c && c.length ? Nh(c, hi, Zp) : r; - } - function dR(c, h) { - return c && c.length ? Nh(c, jt(h, 2), Zp) : r; - } - function pR(c) { - return my(c, hi); - } - function gR(c, h) { - return my(c, jt(h, 2)); - } - function mR(c) { - return c && c.length ? Nh(c, hi, rg) : r; - } - function vR(c, h) { - return c && c.length ? Nh(c, jt(h, 2), rg) : r; - } - var bR = jh(function(c, h) { - return c * h; - }, 1), yR = dg("round"), wR = jh(function(c, h) { - return c - h; - }, 0); - function xR(c) { - return c && c.length ? Up(c, hi) : 0; - } - function _R(c, h) { - return c && c.length ? Up(c, jt(h, 2)) : 0; - } - return ee.after = HI, ee.ary = jw, ee.assign = RC, ee.assignIn = t2, ee.assignInWith = ed, ee.assignWith = DC, ee.at = OC, ee.before = qw, ee.bind = Ag, ee.bindAll = FT, ee.bindKey = zw, ee.castArray = rC, ee.chain = Fw, ee.chunk = lM, ee.compact = hM, ee.concat = dM, ee.cond = BT, ee.conforms = UT, ee.constant = Dg, ee.countBy = xI, ee.create = NC, ee.curry = Hw, ee.curryRight = Ww, ee.debounce = Kw, ee.defaults = LC, ee.defaultsDeep = kC, ee.defer = WI, ee.delay = KI, ee.difference = pM, ee.differenceBy = gM, ee.differenceWith = mM, ee.drop = vM, ee.dropRight = bM, ee.dropRightWhile = yM, ee.dropWhile = wM, ee.fill = xM, ee.filter = EI, ee.flatMap = PI, ee.flatMapDeep = MI, ee.flatMapDepth = II, ee.flatten = Nw, ee.flattenDeep = _M, ee.flattenDepth = EM, ee.flip = VI, ee.flow = qT, ee.flowRight = zT, ee.fromPairs = SM, ee.functions = zC, ee.functionsIn = HC, ee.groupBy = CI, ee.initial = PM, ee.intersection = MM, ee.intersectionBy = IM, ee.intersectionWith = CM, ee.invert = KC, ee.invertBy = VC, ee.invokeMap = RI, ee.iteratee = Og, ee.keyBy = DI, ee.keys = Mn, ee.keysIn = li, ee.map = Gh, ee.mapKeys = YC, ee.mapValues = JC, ee.matches = HT, ee.matchesProperty = WT, ee.memoize = Jh, ee.merge = XC, ee.mergeWith = r2, ee.method = KT, ee.methodOf = VT, ee.mixin = Ng, ee.negate = Xh, ee.nthArg = YT, ee.omit = ZC, ee.omitBy = QC, ee.once = GI, ee.orderBy = OI, ee.over = JT, ee.overArgs = YI, ee.overEvery = XT, ee.overSome = ZT, ee.partial = Pg, ee.partialRight = Vw, ee.partition = NI, ee.pick = eT, ee.pickBy = n2, ee.property = f2, ee.propertyOf = QT, ee.pull = OM, ee.pullAll = kw, ee.pullAllBy = NM, ee.pullAllWith = LM, ee.pullAt = kM, ee.range = eR, ee.rangeRight = tR, ee.rearg = JI, ee.reject = $I, ee.remove = $M, ee.rest = XI, ee.reverse = Eg, ee.sampleSize = BI, ee.set = rT, ee.setWith = nT, ee.shuffle = UI, ee.slice = FM, ee.sortBy = zI, ee.sortedUniq = WM, ee.sortedUniqBy = KM, ee.split = PT, ee.spread = ZI, ee.tail = VM, ee.take = GM, ee.takeRight = YM, ee.takeRightWhile = JM, ee.takeWhile = XM, ee.tap = hI, ee.throttle = QI, ee.thru = Vh, ee.toArray = Zw, ee.toPairs = i2, ee.toPairsIn = s2, ee.toPath = oR, ee.toPlainObject = e2, ee.transform = iT, ee.unary = eC, ee.union = ZM, ee.unionBy = QM, ee.unionWith = eI, ee.uniq = tI, ee.uniqBy = rI, ee.uniqWith = nI, ee.unset = sT, ee.unzip = Sg, ee.unzipWith = $w, ee.update = oT, ee.updateWith = aT, ee.values = Uc, ee.valuesIn = cT, ee.without = iI, ee.words = c2, ee.wrap = tC, ee.xor = sI, ee.xorBy = oI, ee.xorWith = aI, ee.zip = cI, ee.zipObject = uI, ee.zipObjectDeep = fI, ee.zipWith = lI, ee.entries = i2, ee.entriesIn = s2, ee.extend = t2, ee.extendWith = ed, Ng(ee, ee), ee.add = cR, ee.attempt = u2, ee.camelCase = hT, ee.capitalize = o2, ee.ceil = uR, ee.clamp = uT, ee.clone = nC, ee.cloneDeep = sC, ee.cloneDeepWith = oC, ee.cloneWith = iC, ee.conformsTo = aC, ee.deburr = a2, ee.defaultTo = jT, ee.divide = fR, ee.endsWith = dT, ee.eq = hs, ee.escape = pT, ee.escapeRegExp = gT, ee.every = _I, ee.find = SI, ee.findIndex = Dw, ee.findKey = $C, ee.findLast = AI, ee.findLastIndex = Ow, ee.findLastKey = FC, ee.floor = lR, ee.forEach = Bw, ee.forEachRight = Uw, ee.forIn = BC, ee.forInRight = UC, ee.forOwn = jC, ee.forOwnRight = qC, ee.get = Cg, ee.gt = cC, ee.gte = uC, ee.has = WC, ee.hasIn = Tg, ee.head = Lw, ee.identity = hi, ee.includes = TI, ee.indexOf = AM, ee.inRange = fT, ee.invoke = GC, ee.isArguments = Ua, ee.isArray = nr, ee.isArrayBuffer = fC, ee.isArrayLike = fi, ee.isArrayLikeObject = cn, ee.isBoolean = lC, ee.isBuffer = Xo, ee.isDate = hC, ee.isElement = dC, ee.isEmpty = pC, ee.isEqual = gC, ee.isEqualWith = mC, ee.isError = Mg, ee.isFinite = vC, ee.isFunction = fo, ee.isInteger = Gw, ee.isLength = Zh, ee.isMap = Yw, ee.isMatch = bC, ee.isMatchWith = yC, ee.isNaN = wC, ee.isNative = xC, ee.isNil = EC, ee.isNull = _C, ee.isNumber = Jw, ee.isObject = Zr, ee.isObjectLike = en, ee.isPlainObject = df, ee.isRegExp = Ig, ee.isSafeInteger = SC, ee.isSet = Xw, ee.isString = Qh, ee.isSymbol = Mi, ee.isTypedArray = Bc, ee.isUndefined = AC, ee.isWeakMap = PC, ee.isWeakSet = MC, ee.join = TM, ee.kebabCase = mT, ee.last = Wi, ee.lastIndexOf = RM, ee.lowerCase = vT, ee.lowerFirst = bT, ee.lt = IC, ee.lte = CC, ee.max = hR, ee.maxBy = dR, ee.mean = pR, ee.meanBy = gR, ee.min = mR, ee.minBy = vR, ee.stubArray = kg, ee.stubFalse = $g, ee.stubObject = rR, ee.stubString = nR, ee.stubTrue = iR, ee.multiply = bR, ee.nth = DM, ee.noConflict = GT, ee.noop = Lg, ee.now = Yh, ee.pad = yT, ee.padEnd = wT, ee.padStart = xT, ee.parseInt = _T, ee.random = lT, ee.reduce = LI, ee.reduceRight = kI, ee.repeat = ET, ee.replace = ST, ee.result = tT, ee.round = yR, ee.runInContext = be, ee.sample = FI, ee.size = jI, ee.snakeCase = AT, ee.some = qI, ee.sortedIndex = BM, ee.sortedIndexBy = UM, ee.sortedIndexOf = jM, ee.sortedLastIndex = qM, ee.sortedLastIndexBy = zM, ee.sortedLastIndexOf = HM, ee.startCase = MT, ee.startsWith = IT, ee.subtract = wR, ee.sum = xR, ee.sumBy = _R, ee.template = CT, ee.times = sR, ee.toFinite = lo, ee.toInteger = ar, ee.toLength = Qw, ee.toLower = TT, ee.toNumber = Ki, ee.toSafeInteger = TC, ee.toString = Cr, ee.toUpper = RT, ee.trim = DT, ee.trimEnd = OT, ee.trimStart = NT, ee.truncate = LT, ee.unescape = kT, ee.uniqueId = aR, ee.upperCase = $T, ee.upperFirst = Rg, ee.each = Bw, ee.eachRight = Uw, ee.first = Lw, Ng(ee, function() { - var c = {}; - return Is(ee, function(h, y) { - Tr.call(ee.prototype, y) || (c[y] = h); - }), c; - }(), { chain: !1 }), ee.VERSION = n, Ui(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(c) { - ee[c].placeholder = ee; - }), Ui(["drop", "take"], function(c, h) { - wr.prototype[c] = function(y) { - y = y === r ? 1 : _n(ar(y), 0); - var O = this.__filtered__ && !h ? new wr(this) : this.clone(); - return O.__filtered__ ? O.__takeCount__ = Wn(y, O.__takeCount__) : O.__views__.push({ - size: Wn(y, P), - type: c + (O.__dir__ < 0 ? "Right" : "") - }), O; - }, wr.prototype[c + "Right"] = function(y) { - return this.reverse()[c](y).reverse(); - }; - }), Ui(["filter", "map", "takeWhile"], function(c, h) { - var y = h + 1, O = y == f || y == b; - wr.prototype[c] = function(q) { - var ne = this.clone(); - return ne.__iteratees__.push({ - iteratee: jt(q, 3), - type: y - }), ne.__filtered__ = ne.__filtered__ || O, ne; - }; - }), Ui(["head", "last"], function(c, h) { - var y = "take" + (h ? "Right" : ""); - wr.prototype[c] = function() { - return this[y](1).value()[0]; - }; - }), Ui(["initial", "tail"], function(c, h) { - var y = "drop" + (h ? "" : "Right"); - wr.prototype[c] = function() { - return this.__filtered__ ? new wr(this) : this[y](1); - }; - }), wr.prototype.compact = function() { - return this.filter(hi); - }, wr.prototype.find = function(c) { - return this.filter(c).head(); - }, wr.prototype.findLast = function(c) { - return this.reverse().find(c); - }, wr.prototype.invokeMap = hr(function(c, h) { - return typeof c == "function" ? new wr(this) : this.map(function(y) { - return af(y, c, h); - }); - }), wr.prototype.reject = function(c) { - return this.filter(Xh(jt(c))); - }, wr.prototype.slice = function(c, h) { - c = ar(c); - var y = this; - return y.__filtered__ && (c > 0 || h < 0) ? new wr(y) : (c < 0 ? y = y.takeRight(-c) : c && (y = y.drop(c)), h !== r && (h = ar(h), y = h < 0 ? y.dropRight(-h) : y.take(h - c)), y); - }, wr.prototype.takeRightWhile = function(c) { - return this.reverse().takeWhile(c).reverse(); - }, wr.prototype.toArray = function() { - return this.take(P); - }, Is(wr.prototype, function(c, h) { - var y = /^(?:filter|find|map|reject)|While$/.test(h), O = /^(?:head|last)$/.test(h), q = ee[O ? "take" + (h == "last" ? "Right" : "") : h], ne = O || /^find/.test(h); - q && (ee.prototype[h] = function() { - var fe = this.__wrapped__, ge = O ? [1] : arguments, we = fe instanceof wr, He = ge[0], We = we || nr(fe), Xe = function(vr) { - var Er = q.apply(ee, Ho([vr], ge)); - return O && wt ? Er[0] : Er; - }; - We && y && typeof He == "function" && He.length != 1 && (we = We = !1); - var wt = this.__chain__, Ot = !!this.__actions__.length, Wt = ne && !wt, ur = we && !Ot; - if (!ne && We) { - fe = ur ? fe : new wr(this); - var Kt = c.apply(fe, ge); - return Kt.__actions__.push({ func: Vh, args: [Xe], thisArg: r }), new qi(Kt, wt); - } - return Wt && ur ? c.apply(this, ge) : (Kt = this.thru(Xe), Wt ? O ? Kt.value()[0] : Kt.value() : Kt); - }); - }), Ui(["pop", "push", "shift", "sort", "splice", "unshift"], function(c) { - var h = yh[c], y = /^(?:push|sort|unshift)$/.test(c) ? "tap" : "thru", O = /^(?:pop|shift)$/.test(c); - ee.prototype[c] = function() { - var q = arguments; - if (O && !this.__chain__) { - var ne = this.value(); - return h.apply(nr(ne) ? ne : [], q); - } - return this[y](function(fe) { - return h.apply(nr(fe) ? fe : [], q); - }); - }; - }), Is(wr.prototype, function(c, h) { - var y = ee[h]; - if (y) { - var O = y.name + ""; - Tr.call(Nc, O) || (Nc[O] = []), Nc[O].push({ name: h, func: y }); - } - }), Nc[Uh(r, F).name] = [{ - name: "wrapper", - func: r - }], wr.prototype.clone = kA, wr.prototype.reverse = $A, wr.prototype.value = FA, ee.prototype.at = dI, ee.prototype.chain = pI, ee.prototype.commit = gI, ee.prototype.next = mI, ee.prototype.plant = bI, ee.prototype.reverse = yI, ee.prototype.toJSON = ee.prototype.valueOf = ee.prototype.value = wI, ee.prototype.first = ee.prototype.head, Qu && (ee.prototype[Qu] = vI), ee; - }, Rc = gA(); - an ? ((an.exports = Rc)._ = Rc, jr._ = Rc) : _r._ = Rc; - }).call(gn); -})(l0, l0.exports); -var jV = l0.exports, O1 = { exports: {} }; -(function(t, e) { - var r = typeof self < "u" ? self : gn, n = function() { - function s() { - this.fetch = !1, this.DOMException = r.DOMException; - } - return s.prototype = r, new s(); - }(); - (function(s) { - (function(o) { - var a = { - searchParams: "URLSearchParams" in s, - iterable: "Symbol" in s && "iterator" in Symbol, - blob: "FileReader" in s && "Blob" in s && function() { - try { - return new Blob(), !0; - } catch { - return !1; - } - }(), - formData: "FormData" in s, - arrayBuffer: "ArrayBuffer" in s - }; - function u(f) { - return f && DataView.prototype.isPrototypeOf(f); - } - if (a.arrayBuffer) - var l = [ - "[object Int8Array]", - "[object Uint8Array]", - "[object Uint8ClampedArray]", - "[object Int16Array]", - "[object Uint16Array]", - "[object Int32Array]", - "[object Uint32Array]", - "[object Float32Array]", - "[object Float64Array]" - ], d = ArrayBuffer.isView || function(f) { - return f && l.indexOf(Object.prototype.toString.call(f)) > -1; - }; - function g(f) { - if (typeof f != "string" && (f = String(f)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(f)) - throw new TypeError("Invalid character in header field name"); - return f.toLowerCase(); - } - function w(f) { - return typeof f != "string" && (f = String(f)), f; - } - function A(f) { - var p = { - next: function() { - var b = f.shift(); - return { done: b === void 0, value: b }; - } - }; - return a.iterable && (p[Symbol.iterator] = function() { - return p; - }), p; - } - function M(f) { - this.map = {}, f instanceof M ? f.forEach(function(p, b) { - this.append(b, p); - }, this) : Array.isArray(f) ? f.forEach(function(p) { - this.append(p[0], p[1]); - }, this) : f && Object.getOwnPropertyNames(f).forEach(function(p) { - this.append(p, f[p]); - }, this); - } - M.prototype.append = function(f, p) { - f = g(f), p = w(p); - var b = this.map[f]; - this.map[f] = b ? b + ", " + p : p; - }, M.prototype.delete = function(f) { - delete this.map[g(f)]; - }, M.prototype.get = function(f) { - return f = g(f), this.has(f) ? this.map[f] : null; - }, M.prototype.has = function(f) { - return this.map.hasOwnProperty(g(f)); - }, M.prototype.set = function(f, p) { - this.map[g(f)] = w(p); - }, M.prototype.forEach = function(f, p) { - for (var b in this.map) - this.map.hasOwnProperty(b) && f.call(p, this.map[b], b, this); - }, M.prototype.keys = function() { - var f = []; - return this.forEach(function(p, b) { - f.push(b); - }), A(f); - }, M.prototype.values = function() { - var f = []; - return this.forEach(function(p) { - f.push(p); - }), A(f); - }, M.prototype.entries = function() { - var f = []; - return this.forEach(function(p, b) { - f.push([b, p]); - }), A(f); - }, a.iterable && (M.prototype[Symbol.iterator] = M.prototype.entries); - function N(f) { - if (f.bodyUsed) - return Promise.reject(new TypeError("Already read")); - f.bodyUsed = !0; - } - function L(f) { - return new Promise(function(p, b) { - f.onload = function() { - p(f.result); - }, f.onerror = function() { - b(f.error); - }; - }); - } - function F(f) { - var p = new FileReader(), b = L(p); - return p.readAsArrayBuffer(f), b; - } - function $(f) { - var p = new FileReader(), b = L(p); - return p.readAsText(f), b; - } - function K(f) { - for (var p = new Uint8Array(f), b = new Array(p.length), x = 0; x < p.length; x++) - b[x] = String.fromCharCode(p[x]); - return b.join(""); - } - function H(f) { - if (f.slice) - return f.slice(0); - var p = new Uint8Array(f.byteLength); - return p.set(new Uint8Array(f)), p.buffer; - } - function V() { - return this.bodyUsed = !1, this._initBody = function(f) { - this._bodyInit = f, f ? typeof f == "string" ? this._bodyText = f : a.blob && Blob.prototype.isPrototypeOf(f) ? this._bodyBlob = f : a.formData && FormData.prototype.isPrototypeOf(f) ? this._bodyFormData = f : a.searchParams && URLSearchParams.prototype.isPrototypeOf(f) ? this._bodyText = f.toString() : a.arrayBuffer && a.blob && u(f) ? (this._bodyArrayBuffer = H(f.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(f) || d(f)) ? this._bodyArrayBuffer = H(f) : this._bodyText = f = Object.prototype.toString.call(f) : this._bodyText = "", this.headers.get("content-type") || (typeof f == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : a.searchParams && URLSearchParams.prototype.isPrototypeOf(f) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8")); - }, a.blob && (this.blob = function() { - var f = N(this); - if (f) - return f; - if (this._bodyBlob) - return Promise.resolve(this._bodyBlob); - if (this._bodyArrayBuffer) - return Promise.resolve(new Blob([this._bodyArrayBuffer])); - if (this._bodyFormData) - throw new Error("could not read FormData body as blob"); - return Promise.resolve(new Blob([this._bodyText])); - }, this.arrayBuffer = function() { - return this._bodyArrayBuffer ? N(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(F); - }), this.text = function() { - var f = N(this); - if (f) - return f; - if (this._bodyBlob) - return $(this._bodyBlob); - if (this._bodyArrayBuffer) - return Promise.resolve(K(this._bodyArrayBuffer)); - if (this._bodyFormData) - throw new Error("could not read FormData body as text"); - return Promise.resolve(this._bodyText); - }, a.formData && (this.formData = function() { - return this.text().then(pe); - }), this.json = function() { - return this.text().then(JSON.parse); - }, this; - } - var te = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"]; - function R(f) { - var p = f.toUpperCase(); - return te.indexOf(p) > -1 ? p : f; - } - function W(f, p) { - p = p || {}; - var b = p.body; - if (f instanceof W) { - if (f.bodyUsed) - throw new TypeError("Already read"); - this.url = f.url, this.credentials = f.credentials, p.headers || (this.headers = new M(f.headers)), this.method = f.method, this.mode = f.mode, this.signal = f.signal, !b && f._bodyInit != null && (b = f._bodyInit, f.bodyUsed = !0); - } else - this.url = String(f); - if (this.credentials = p.credentials || this.credentials || "same-origin", (p.headers || !this.headers) && (this.headers = new M(p.headers)), this.method = R(p.method || this.method || "GET"), this.mode = p.mode || this.mode || null, this.signal = p.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && b) - throw new TypeError("Body not allowed for GET or HEAD requests"); - this._initBody(b); - } - W.prototype.clone = function() { - return new W(this, { body: this._bodyInit }); - }; - function pe(f) { - var p = new FormData(); - return f.trim().split("&").forEach(function(b) { - if (b) { - var x = b.split("="), _ = x.shift().replace(/\+/g, " "), E = x.join("=").replace(/\+/g, " "); - p.append(decodeURIComponent(_), decodeURIComponent(E)); - } - }), p; - } - function Ee(f) { - var p = new M(), b = f.replace(/\r?\n[\t ]+/g, " "); - return b.split(/\r?\n/).forEach(function(x) { - var _ = x.split(":"), E = _.shift().trim(); - if (E) { - var v = _.join(":").trim(); - p.append(E, v); - } - }), p; - } - V.call(W.prototype); - function Y(f, p) { - p || (p = {}), this.type = "default", this.status = p.status === void 0 ? 200 : p.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in p ? p.statusText : "OK", this.headers = new M(p.headers), this.url = p.url || "", this._initBody(f); - } - V.call(Y.prototype), Y.prototype.clone = function() { - return new Y(this._bodyInit, { - status: this.status, - statusText: this.statusText, - headers: new M(this.headers), - url: this.url - }); - }, Y.error = function() { - var f = new Y(null, { status: 0, statusText: "" }); - return f.type = "error", f; - }; - var S = [301, 302, 303, 307, 308]; - Y.redirect = function(f, p) { - if (S.indexOf(p) === -1) - throw new RangeError("Invalid status code"); - return new Y(null, { status: p, headers: { location: f } }); - }, o.DOMException = s.DOMException; - try { - new o.DOMException(); - } catch { - o.DOMException = function(p, b) { - this.message = p, this.name = b; - var x = Error(p); - this.stack = x.stack; - }, o.DOMException.prototype = Object.create(Error.prototype), o.DOMException.prototype.constructor = o.DOMException; - } - function m(f, p) { - return new Promise(function(b, x) { - var _ = new W(f, p); - if (_.signal && _.signal.aborted) - return x(new o.DOMException("Aborted", "AbortError")); - var E = new XMLHttpRequest(); - function v() { - E.abort(); - } - E.onload = function() { - var P = { - status: E.status, - statusText: E.statusText, - headers: Ee(E.getAllResponseHeaders() || "") - }; - P.url = "responseURL" in E ? E.responseURL : P.headers.get("X-Request-URL"); - var I = "response" in E ? E.response : E.responseText; - b(new Y(I, P)); - }, E.onerror = function() { - x(new TypeError("Network request failed")); - }, E.ontimeout = function() { - x(new TypeError("Network request failed")); - }, E.onabort = function() { - x(new o.DOMException("Aborted", "AbortError")); - }, E.open(_.method, _.url, !0), _.credentials === "include" ? E.withCredentials = !0 : _.credentials === "omit" && (E.withCredentials = !1), "responseType" in E && a.blob && (E.responseType = "blob"), _.headers.forEach(function(P, I) { - E.setRequestHeader(I, P); - }), _.signal && (_.signal.addEventListener("abort", v), E.onreadystatechange = function() { - E.readyState === 4 && _.signal.removeEventListener("abort", v); - }), E.send(typeof _._bodyInit > "u" ? null : _._bodyInit); - }); - } - return m.polyfill = !0, s.fetch || (s.fetch = m, s.Headers = M, s.Request = W, s.Response = Y), o.Headers = M, o.Request = W, o.Response = Y, o.fetch = m, Object.defineProperty(o, "__esModule", { value: !0 }), o; - })({}); - })(n), n.fetch.ponyfill = !0, delete n.fetch.polyfill; - var i = n; - e = i.fetch, e.default = i.fetch, e.fetch = i.fetch, e.Headers = i.Headers, e.Request = i.Request, e.Response = i.Response, t.exports = e; -})(O1, O1.exports); -var qV = O1.exports; -const L3 = /* @__PURE__ */ ts(qV); -var zV = Object.defineProperty, HV = Object.defineProperties, WV = Object.getOwnPropertyDescriptors, k3 = Object.getOwnPropertySymbols, KV = Object.prototype.hasOwnProperty, VV = Object.prototype.propertyIsEnumerable, $3 = (t, e, r) => e in t ? zV(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, F3 = (t, e) => { - for (var r in e || (e = {})) KV.call(e, r) && $3(t, r, e[r]); - if (k3) for (var r of k3(e)) VV.call(e, r) && $3(t, r, e[r]); - return t; -}, B3 = (t, e) => HV(t, WV(e)); -const GV = { Accept: "application/json", "Content-Type": "application/json" }, YV = "POST", U3 = { headers: GV, method: YV }, j3 = 10; -let Ss = class { - constructor(e, r = !1) { - if (this.url = e, this.disableProviderPing = r, this.events = new rs.EventEmitter(), this.isAvailable = !1, this.registering = !1, !a3(e)) throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`); - this.url = e, this.disableProviderPing = r; - } - get connected() { - return this.isAvailable; - } - 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() { - if (!this.isAvailable) throw new Error("Connection already closed"); - this.onClose(); - } - async send(e) { - this.isAvailable || await this.register(); - try { - const r = ko(e), n = await (await L3(this.url, B3(F3({}, U3), { body: r }))).json(); - this.onPayload({ data: n }); - } catch (r) { - this.onError(e.id, r); - } - } - async register(e = this.url) { - if (!a3(e)) throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`); - if (this.registering) { - const r = this.events.getMaxListeners(); - return (this.events.listenerCount("register_error") >= r || this.events.listenerCount("open") >= r) && this.events.setMaxListeners(r + 1), new Promise((n, i) => { - this.events.once("register_error", (s) => { - this.resetMaxListeners(), i(s); - }), this.events.once("open", () => { - if (this.resetMaxListeners(), typeof this.isAvailable > "u") return i(new Error("HTTP connection is missing or invalid")); - n(); - }); - }); - } - this.url = e, this.registering = !0; - try { - if (!this.disableProviderPing) { - const r = ko({ id: 1, jsonrpc: "2.0", method: "test", params: [] }); - await L3(e, B3(F3({}, U3), { body: r })); - } - this.onOpen(); - } catch (r) { - const n = this.parseError(r); - throw this.events.emit("register_error", n), this.onClose(), n; - } - } - onOpen() { - this.isAvailable = !0, this.registering = !1, this.events.emit("open"); - } - onClose() { - this.isAvailable = !1, this.registering = !1, this.events.emit("close"); - } - onPayload(e) { - if (typeof e.data > "u") return; - const r = typeof e.data == "string" ? uc(e.data) : e.data; - this.events.emit("payload", r); - } - onError(e, r) { - const n = this.parseError(r), i = n.message || n.toString(), s = rp(e, i); - this.events.emit("payload", s); - } - parseError(e, r = this.url) { - return J8(e, r, "HTTP"); - } - resetMaxListeners() { - this.events.getMaxListeners() > j3 && this.events.setMaxListeners(j3); - } -}; -const q3 = "error", JV = "wss://relay.walletconnect.org", XV = "wc", ZV = "universal_provider", z3 = `${XV}@2:${ZV}:`, wE = "https://rpc.walletconnect.org/v1/", Jc = "generic", QV = `${wE}bundler`, cs = { DEFAULT_CHAIN_CHANGED: "default_chain_changed" }; -var eG = Object.defineProperty, tG = Object.defineProperties, rG = Object.getOwnPropertyDescriptors, H3 = Object.getOwnPropertySymbols, nG = Object.prototype.hasOwnProperty, iG = Object.prototype.propertyIsEnumerable, W3 = (t, e, r) => e in t ? eG(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, fd = (t, e) => { - for (var r in e || (e = {})) nG.call(e, r) && W3(t, r, e[r]); - if (H3) for (var r of H3(e)) iG.call(e, r) && W3(t, r, e[r]); - return t; -}, sG = (t, e) => tG(t, rG(e)); -function Ni(t, e, r) { - var n; - const i = lu(t); - return ((n = e.rpcMap) == null ? void 0 : n[i.reference]) || `${wE}?chainId=${i.namespace}:${i.reference}&projectId=${r}`; -} -function Ec(t) { - return t.includes(":") ? t.split(":")[1] : t; -} -function xE(t) { - return t.map((e) => `${e.split(":")[0]}:${e.split(":")[1]}`); -} -function oG(t, e) { - const r = Object.keys(e.namespaces).filter((i) => i.includes(t)); - if (!r.length) return []; - const n = []; - return r.forEach((i) => { - const s = e.namespaces[i].accounts; - n.push(...s); - }), n; -} -function bm(t = {}, e = {}) { - const r = K3(t), n = K3(e); - return jV.merge(r, n); -} -function K3(t) { - var e, r, n, i; - const s = {}; - if (!El(t)) return s; - for (const [o, a] of Object.entries(t)) { - const u = ob(o) ? [o] : a.chains, l = a.methods || [], d = a.events || [], g = a.rpcMap || {}, w = Ff(o); - s[w] = sG(fd(fd({}, s[w]), a), { chains: Md(u, (e = s[w]) == null ? void 0 : e.chains), methods: Md(l, (r = s[w]) == null ? void 0 : r.methods), events: Md(d, (n = s[w]) == null ? void 0 : n.events), rpcMap: fd(fd({}, g), (i = s[w]) == null ? void 0 : i.rpcMap) }); - } - return s; -} -function aG(t) { - return t.includes(":") ? t.split(":")[2] : t; -} -function V3(t) { - const e = {}; - for (const [r, n] of Object.entries(t)) { - const i = n.methods || [], s = n.events || [], o = n.accounts || [], a = ob(r) ? [r] : n.chains ? n.chains : xE(n.accounts); - e[r] = { chains: a, methods: i, events: s, accounts: o }; - } - return e; -} -function ym(t) { - return typeof t == "number" ? t : t.includes("0x") ? parseInt(t, 16) : (t = t.includes(":") ? t.split(":")[1] : t, isNaN(Number(t)) ? t : Number(t)); -} -const _E = {}, Ar = (t) => _E[t], wm = (t, e) => { - _E[t] = e; -}; -class cG { - constructor(e) { - this.name = "polkadot", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - requestAccounts() { - return this.getAccounts(); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); - } - setDefaultChain(e, r) { - this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); - } - getAccounts() { - const e = this.namespace.accounts; - return e ? e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]) || [] : []; - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - var n; - const i = Ec(r); - e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); - }), e; - } - getHttpProvider() { - const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || Ni(e, this.namespace, this.client.core.projectId); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - return new as(new Ss(n, Ar("disableProviderPing"))); - } -} -var uG = Object.defineProperty, fG = Object.defineProperties, lG = Object.getOwnPropertyDescriptors, G3 = Object.getOwnPropertySymbols, hG = Object.prototype.hasOwnProperty, dG = Object.prototype.propertyIsEnumerable, Y3 = (t, e, r) => e in t ? uG(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, J3 = (t, e) => { - for (var r in e || (e = {})) hG.call(e, r) && Y3(t, r, e[r]); - if (G3) for (var r of G3(e)) dG.call(e, r) && Y3(t, r, e[r]); - return t; -}, X3 = (t, e) => fG(t, lG(e)); -class pG { - constructor(e) { - this.name = "eip155", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.httpProviders = this.createHttpProviders(), this.chainId = parseInt(this.getDefaultChain()); - } - async request(e) { - switch (e.request.method) { - case "eth_requestAccounts": - return this.getAccounts(); - case "eth_accounts": - return this.getAccounts(); - case "wallet_switchEthereumChain": - return await this.handleSwitchChain(e); - case "eth_chainId": - return parseInt(this.getDefaultChain()); - case "wallet_getCapabilities": - return await this.getCapabilities(e); - case "wallet_getCallsStatus": - return await this.getCallStatus(e); - } - return this.namespace.methods.includes(e.request.method) ? await this.client.request(e) : this.getHttpProvider().request(e.request); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - setDefaultChain(e, r) { - this.httpProviders[e] || this.setHttpProvider(parseInt(e), r), this.chainId = parseInt(e), this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); - } - requestAccounts() { - return this.getAccounts(); - } - getDefaultChain() { - if (this.chainId) return this.chainId.toString(); - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - createHttpProvider(e, r) { - const n = r || Ni(`${this.name}:${e}`, this.namespace, this.client.core.projectId); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - return new as(new Ss(n, Ar("disableProviderPing"))); - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - var n; - const i = parseInt(Ec(r)); - e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); - }), e; - } - getAccounts() { - const e = this.namespace.accounts; - return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; - } - getHttpProvider() { - const e = this.chainId, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - async handleSwitchChain(e) { - var r, n; - let i = e.request.params ? (r = e.request.params[0]) == null ? void 0 : r.chainId : "0x0"; - i = i.startsWith("0x") ? i : `0x${i}`; - const s = parseInt(i, 16); - if (this.isChainApproved(s)) this.setDefaultChain(`${s}`); - else if (this.namespace.methods.includes("wallet_switchEthereumChain")) await this.client.request({ topic: e.topic, request: { method: e.request.method, params: [{ chainId: i }] }, chainId: (n = this.namespace.chains) == null ? void 0 : n[0] }), this.setDefaultChain(`${s}`); - else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`); - return null; - } - isChainApproved(e) { - return this.namespace.chains.includes(`${this.name}:${e}`); - } - async getCapabilities(e) { - var r, n, i; - const s = (n = (r = e.request) == null ? void 0 : r.params) == null ? void 0 : n[0]; - if (!s) throw new Error("Missing address parameter in `wallet_getCapabilities` request"); - const o = this.client.session.get(e.topic), a = ((i = o == null ? void 0 : o.sessionProperties) == null ? void 0 : i.capabilities) || {}; - if (a != null && a[s]) return a == null ? void 0 : a[s]; - const u = await this.client.request(e); - try { - await this.client.session.update(e.topic, { sessionProperties: X3(J3({}, o.sessionProperties || {}), { capabilities: X3(J3({}, a || {}), { [s]: u }) }) }); - } catch (l) { - console.warn("Failed to update session with capabilities", l); - } - return u; - } - async getCallStatus(e) { - var r, n; - const i = this.client.session.get(e.topic), s = (r = i.sessionProperties) == null ? void 0 : r.bundler_name; - if (s) { - const a = this.getBundlerUrl(e.chainId, s); - try { - return await this.getUserOperationReceipt(a, e); - } catch (u) { - console.warn("Failed to fetch call status from bundler", u, a); - } - } - const o = (n = i.sessionProperties) == null ? void 0 : n.bundler_url; - if (o) try { - return await this.getUserOperationReceipt(o, e); - } catch (a) { - console.warn("Failed to fetch call status from custom bundler", a, o); - } - if (this.namespace.methods.includes(e.request.method)) return await this.client.request(e); - throw new Error("Fetching call status not approved by the wallet."); - } - async getUserOperationReceipt(e, r) { - var n; - const i = new URL(e), s = await fetch(i, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(ha("eth_getUserOperationReceipt", [(n = r.request.params) == null ? void 0 : n[0]])) }); - if (!s.ok) throw new Error(`Failed to fetch user operation receipt - ${s.status}`); - return await s.json(); - } - getBundlerUrl(e, r) { - return `${QV}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`; - } -} -class gG { - constructor(e) { - this.name = "solana", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - requestAccounts() { - return this.getAccounts(); - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); - } - setDefaultChain(e, r) { - this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - getAccounts() { - const e = this.namespace.accounts; - return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - var n; - const i = Ec(r); - e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); - }), e; - } - getHttpProvider() { - const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || Ni(e, this.namespace, this.client.core.projectId); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - return new as(new Ss(n, Ar("disableProviderPing"))); - } -} -let mG = class { - constructor(e) { - this.name = "cosmos", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - requestAccounts() { - return this.getAccounts(); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); - } - setDefaultChain(e, r) { - this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); - } - getAccounts() { - const e = this.namespace.accounts; - return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - var n; - const i = Ec(r); - e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); - }), e; - } - getHttpProvider() { - const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || Ni(e, this.namespace, this.client.core.projectId); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - return new as(new Ss(n, Ar("disableProviderPing"))); - } -}, vG = class { - constructor(e) { - this.name = "algorand", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - requestAccounts() { - return this.getAccounts(); - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); - } - setDefaultChain(e, r) { - if (!this.httpProviders[e]) { - const n = r || Ni(`${this.name}:${e}`, this.namespace, this.client.core.projectId); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - this.setHttpProvider(e, n); - } - this.chainId = e, this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - getAccounts() { - const e = this.namespace.accounts; - return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - var n; - e[r] = this.createHttpProvider(r, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); - }), e; - } - getHttpProvider() { - const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || Ni(e, this.namespace, this.client.core.projectId); - return typeof n > "u" ? void 0 : new as(new Ss(n, Ar("disableProviderPing"))); - } -}, bG = class { - constructor(e) { - this.name = "cip34", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - requestAccounts() { - return this.getAccounts(); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); - } - setDefaultChain(e, r) { - this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); - } - getAccounts() { - const e = this.namespace.accounts; - return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - const n = this.getCardanoRPCUrl(r), i = Ec(r); - e[i] = this.createHttpProvider(i, n); - }), e; - } - getHttpProvider() { - const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - getCardanoRPCUrl(e) { - const r = this.namespace.rpcMap; - if (r) return r[e]; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || this.getCardanoRPCUrl(e); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - return new as(new Ss(n, Ar("disableProviderPing"))); - } -}, yG = class { - constructor(e) { - this.name = "elrond", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - requestAccounts() { - return this.getAccounts(); - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); - } - setDefaultChain(e, r) { - this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - getAccounts() { - const e = this.namespace.accounts; - return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - var n; - const i = Ec(r); - e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); - }), e; - } - getHttpProvider() { - const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || Ni(e, this.namespace, this.client.core.projectId); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - return new as(new Ss(n, Ar("disableProviderPing"))); - } -}; -class wG { - constructor(e) { - this.name = "multiversx", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - requestAccounts() { - return this.getAccounts(); - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); - } - setDefaultChain(e, r) { - this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - getAccounts() { - const e = this.namespace.accounts; - return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - var n; - const i = Ec(r); - e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); - }), e; - } - getHttpProvider() { - const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || Ni(e, this.namespace, this.client.core.projectId); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - return new as(new Ss(n, Ar("disableProviderPing"))); - } -} -let xG = class { - constructor(e) { - this.name = "near", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - requestAccounts() { - return this.getAccounts(); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); - } - setDefaultChain(e, r) { - if (this.chainId = e, !this.httpProviders[e]) { - const n = r || Ni(`${this.name}:${e}`, this.namespace); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - this.setHttpProvider(e, n); - } - this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); - } - getAccounts() { - const e = this.namespace.accounts; - return e ? e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]) || [] : []; - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - var n; - e[r] = this.createHttpProvider(r, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); - }), e; - } - getHttpProvider() { - const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || Ni(e, this.namespace); - return typeof n > "u" ? void 0 : new as(new Ss(n, Ar("disableProviderPing"))); - } -}; -class _G { - constructor(e) { - this.name = "tezos", this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace = Object.assign(this.namespace, e); - } - requestAccounts() { - return this.getAccounts(); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); - } - setDefaultChain(e, r) { - if (this.chainId = e, !this.httpProviders[e]) { - const n = r || Ni(`${this.name}:${e}`, this.namespace); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - this.setHttpProvider(e, n); - } - this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); - } - getAccounts() { - const e = this.namespace.accounts; - return e ? e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]) || [] : []; - } - createHttpProviders() { - const e = {}; - return this.namespace.chains.forEach((r) => { - e[r] = this.createHttpProvider(r); - }), e; - } - getHttpProvider() { - const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || Ni(e, this.namespace); - return typeof n > "u" ? void 0 : new as(new Ss(n)); - } -} -class EG { - constructor(e) { - this.name = Jc, this.namespace = e.namespace, this.events = Ar("events"), this.client = Ar("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); - } - updateNamespace(e) { - this.namespace.chains = [...new Set((this.namespace.chains || []).concat(e.chains || []))], this.namespace.accounts = [...new Set((this.namespace.accounts || []).concat(e.accounts || []))], this.namespace.methods = [...new Set((this.namespace.methods || []).concat(e.methods || []))], this.namespace.events = [...new Set((this.namespace.events || []).concat(e.events || []))], this.httpProviders = this.createHttpProviders(); - } - requestAccounts() { - return this.getAccounts(); - } - request(e) { - return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider(e.chainId).request(e.request); - } - setDefaultChain(e, r) { - this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(cs.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); - } - getDefaultChain() { - if (this.chainId) return this.chainId; - if (this.namespace.defaultChain) return this.namespace.defaultChain; - const e = this.namespace.chains[0]; - if (!e) throw new Error("ChainId not found"); - return e.split(":")[1]; - } - getAccounts() { - const e = this.namespace.accounts; - return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; - } - createHttpProviders() { - var e, r; - const n = {}; - return (r = (e = this.namespace) == null ? void 0 : e.accounts) == null || r.forEach((i) => { - const s = lu(i); - n[`${s.namespace}:${s.reference}`] = this.createHttpProvider(i); - }), n; - } - getHttpProvider(e) { - const r = this.httpProviders[e]; - if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); - return r; - } - setHttpProvider(e, r) { - const n = this.createHttpProvider(e, r); - n && (this.httpProviders[e] = n); - } - createHttpProvider(e, r) { - const n = r || Ni(e, this.namespace, this.client.core.projectId); - if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); - return new as(new Ss(n, Ar("disableProviderPing"))); - } -} -var SG = Object.defineProperty, AG = Object.defineProperties, PG = Object.getOwnPropertyDescriptors, Z3 = Object.getOwnPropertySymbols, MG = Object.prototype.hasOwnProperty, IG = Object.prototype.propertyIsEnumerable, Q3 = (t, e, r) => e in t ? SG(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, ld = (t, e) => { - for (var r in e || (e = {})) MG.call(e, r) && Q3(t, r, e[r]); - if (Z3) for (var r of Z3(e)) IG.call(e, r) && Q3(t, r, e[r]); - return t; -}, xm = (t, e) => AG(t, PG(e)); -let EE = class SE { - constructor(e) { - this.events = new Lv(), this.rpcProviders = {}, this.shouldAbortPairingAttempt = !1, this.maxPairingAttempts = 10, this.disableProviderPing = !1, this.providerOpts = e, this.logger = typeof (e == null ? void 0 : e.logger) < "u" && typeof (e == null ? void 0 : e.logger) != "string" ? e.logger : jl(k0({ level: (e == null ? void 0 : e.logger) || q3 })), this.disableProviderPing = (e == null ? void 0 : e.disableProviderPing) || !1; - } - static async init(e) { - const r = new SE(e); - return await r.initialize(), r; - } - async request(e, r, n) { - const [i, s] = this.validateChain(r); - if (!this.session) throw new Error("Please call connect() before request()"); - return await this.getProvider(i).request({ request: ld({}, e), chainId: `${i}:${s}`, topic: this.session.topic, expiry: n }); - } - sendAsync(e, r, n, i) { - const s = (/* @__PURE__ */ new Date()).getTime(); - this.request(e, n, i).then((o) => r(null, tp(s, o))).catch((o) => r(o, void 0)); - } - async enable() { - if (!this.client) throw new Error("Sign Client not initialized"); - return this.session || await this.connect({ namespaces: this.namespaces, optionalNamespaces: this.optionalNamespaces, sessionProperties: this.sessionProperties }), await this.requestAccounts(); - } - async disconnect() { - var e; - if (!this.session) throw new Error("Please call connect() before enable()"); - await this.client.disconnect({ topic: (e = this.session) == null ? void 0 : e.topic, reason: Or("USER_DISCONNECTED") }), await this.cleanup(); - } - async connect(e) { - if (!this.client) throw new Error("Sign Client not initialized"); - if (this.setNamespaces(e), await this.cleanupPendingPairings(), !e.skipPairing) return await this.pair(e.pairingTopic); - } - async authenticate(e, r) { - if (!this.client) throw new Error("Sign Client not initialized"); - this.setNamespaces(e), await this.cleanupPendingPairings(); - const { uri: n, response: i } = await this.client.authenticate(e, r); - n && (this.uri = n, this.events.emit("display_uri", n)); - const s = await i(); - if (this.session = s.session, this.session) { - const o = V3(this.session.namespaces); - this.namespaces = bm(this.namespaces, o), this.persist("namespaces", this.namespaces), this.onConnect(); - } - return s; - } - on(e, r) { - this.events.on(e, r); - } - once(e, r) { - this.events.once(e, r); - } - removeListener(e, r) { - this.events.removeListener(e, r); - } - off(e, r) { - this.events.off(e, r); - } - get isWalletConnect() { - return !0; - } - async pair(e) { - this.shouldAbortPairingAttempt = !1; - let r = 0; - do { - if (this.shouldAbortPairingAttempt) throw new Error("Pairing aborted"); - if (r >= this.maxPairingAttempts) throw new Error("Max auto pairing attempts reached"); - const { uri: n, approval: i } = await this.client.connect({ pairingTopic: e, requiredNamespaces: this.namespaces, optionalNamespaces: this.optionalNamespaces, sessionProperties: this.sessionProperties }); - n && (this.uri = n, this.events.emit("display_uri", n)), await i().then((s) => { - this.session = s; - const o = V3(s.namespaces); - this.namespaces = bm(this.namespaces, o), this.persist("namespaces", this.namespaces); - }).catch((s) => { - if (s.message !== yE) throw s; - r++; - }); - } while (!this.session); - return this.onConnect(), this.session; - } - setDefaultChain(e, r) { - try { - if (!this.session) return; - const [n, i] = this.validateChain(e), s = this.getProvider(n); - s.name === Jc ? s.setDefaultChain(`${n}:${i}`, r) : s.setDefaultChain(i, r); - } catch (n) { - if (!/Please call connect/.test(n.message)) throw n; - } - } - async cleanupPendingPairings(e = {}) { - this.logger.info("Cleaning up inactive pairings..."); - const r = this.client.pairing.getAll(); - if (dc(r)) { - for (const n of r) e.deletePairings ? this.client.core.expirer.set(n.topic, 0) : await this.client.core.relayer.subscriber.unsubscribe(n.topic); - this.logger.info(`Inactive pairings cleared: ${r.length}`); - } - } - abortPairingAttempt() { - this.shouldAbortPairingAttempt = !0; - } - async checkStorage() { - if (this.namespaces = await this.getFromStore("namespaces"), this.optionalNamespaces = await this.getFromStore("optionalNamespaces") || {}, this.client.session.length) { - const e = this.client.session.keys.length - 1; - this.session = this.client.session.get(this.client.session.keys[e]), this.createProviders(); - } - } - async initialize() { - this.logger.trace("Initialized"), await this.createClient(), await this.checkStorage(), this.registerEventListeners(); - } - async createClient() { - this.client = this.providerOpts.client || await hb.init({ core: this.providerOpts.core, logger: this.providerOpts.logger || q3, relayUrl: this.providerOpts.relayUrl || JV, projectId: this.providerOpts.projectId, metadata: this.providerOpts.metadata, storageOptions: this.providerOpts.storageOptions, storage: this.providerOpts.storage, name: this.providerOpts.name, customStoragePrefix: this.providerOpts.customStoragePrefix, telemetryEnabled: this.providerOpts.telemetryEnabled }), this.logger.trace("SignClient Initialized"); - } - createProviders() { - if (!this.client) throw new Error("Sign Client not initialized"); - if (!this.session) throw new Error("Session not initialized. Please call connect() before enable()"); - const e = [...new Set(Object.keys(this.session.namespaces).map((r) => Ff(r)))]; - wm("client", this.client), wm("events", this.events), wm("disableProviderPing", this.disableProviderPing), e.forEach((r) => { - if (!this.session) return; - const n = oG(r, this.session), i = xE(n), s = bm(this.namespaces, this.optionalNamespaces), o = xm(ld({}, s[r]), { accounts: n, chains: i }); - switch (r) { - case "eip155": - this.rpcProviders[r] = new pG({ namespace: o }); - break; - case "algorand": - this.rpcProviders[r] = new vG({ namespace: o }); - break; - case "solana": - this.rpcProviders[r] = new gG({ namespace: o }); - break; - case "cosmos": - this.rpcProviders[r] = new mG({ namespace: o }); - break; - case "polkadot": - this.rpcProviders[r] = new cG({ namespace: o }); - break; - case "cip34": - this.rpcProviders[r] = new bG({ namespace: o }); - break; - case "elrond": - this.rpcProviders[r] = new yG({ namespace: o }); - break; - case "multiversx": - this.rpcProviders[r] = new wG({ namespace: o }); - break; - case "near": - this.rpcProviders[r] = new xG({ namespace: o }); - break; - case "tezos": - this.rpcProviders[r] = new _G({ namespace: o }); - break; - default: - this.rpcProviders[Jc] ? this.rpcProviders[Jc].updateNamespace(o) : this.rpcProviders[Jc] = new EG({ namespace: o }); - } - }); - } - registerEventListeners() { - if (typeof this.client > "u") throw new Error("Sign Client is not initialized"); - this.client.on("session_ping", (e) => { - this.events.emit("session_ping", e); - }), this.client.on("session_event", (e) => { - const { params: r } = e, { event: n } = r; - if (n.name === "accountsChanged") { - const i = n.data; - i && dc(i) && this.events.emit("accountsChanged", i.map(aG)); - } else if (n.name === "chainChanged") { - const i = r.chainId, s = r.event.data, o = Ff(i), a = ym(i) !== ym(s) ? `${o}:${ym(s)}` : i; - this.onChainChanged(a); - } else this.events.emit(n.name, n.data); - this.events.emit("session_event", e); - }), this.client.on("session_update", ({ topic: e, params: r }) => { - var n; - const { namespaces: i } = r, s = (n = this.client) == null ? void 0 : n.session.get(e); - this.session = xm(ld({}, s), { namespaces: i }), this.onSessionUpdate(), this.events.emit("session_update", { topic: e, params: r }); - }), this.client.on("session_delete", async (e) => { - await this.cleanup(), this.events.emit("session_delete", e), this.events.emit("disconnect", xm(ld({}, Or("USER_DISCONNECTED")), { data: e.topic })); - }), this.on(cs.DEFAULT_CHAIN_CHANGED, (e) => { - this.onChainChanged(e, !0); - }); - } - getProvider(e) { - return this.rpcProviders[e] || this.rpcProviders[Jc]; - } - onSessionUpdate() { - Object.keys(this.rpcProviders).forEach((e) => { - var r; - this.getProvider(e).updateNamespace((r = this.session) == null ? void 0 : r.namespaces[e]); - }); - } - setNamespaces(e) { - const { namespaces: r, optionalNamespaces: n, sessionProperties: i } = e; - r && Object.keys(r).length && (this.namespaces = r), n && Object.keys(n).length && (this.optionalNamespaces = n), this.sessionProperties = i, this.persist("namespaces", r), this.persist("optionalNamespaces", n); - } - validateChain(e) { - const [r, n] = (e == null ? void 0 : e.split(":")) || ["", ""]; - if (!this.namespaces || !Object.keys(this.namespaces).length) return [r, n]; - if (r && !Object.keys(this.namespaces || {}).map((o) => Ff(o)).includes(r)) throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`); - if (r && n) return [r, n]; - const i = Ff(Object.keys(this.namespaces)[0]), s = this.rpcProviders[i].getDefaultChain(); - return [i, s]; - } - async requestAccounts() { - const [e] = this.validateChain(); - return await this.getProvider(e).requestAccounts(); - } - onChainChanged(e, r = !1) { - if (!this.namespaces) return; - const [n, i] = this.validateChain(e); - i && (r || this.getProvider(n).setDefaultChain(i), this.namespaces[n] ? this.namespaces[n].defaultChain = i : this.namespaces[`${n}:${i}`] ? this.namespaces[`${n}:${i}`].defaultChain = i : this.namespaces[`${n}:${i}`] = { defaultChain: i }, this.persist("namespaces", this.namespaces), this.events.emit("chainChanged", i)); - } - onConnect() { - this.createProviders(), this.events.emit("connect", { session: this.session }); - } - async cleanup() { - this.session = void 0, this.namespaces = void 0, this.optionalNamespaces = void 0, this.sessionProperties = void 0, this.persist("namespaces", void 0), this.persist("optionalNamespaces", void 0), this.persist("sessionProperties", void 0), await this.cleanupPendingPairings({ deletePairings: !0 }); - } - persist(e, r) { - this.client.core.storage.setItem(`${z3}/${e}`, r); - } - async getFromStore(e) { - return await this.client.core.storage.getItem(`${z3}/${e}`); - } -}; -const CG = EE; -function TG() { - return new Promise((t) => { - const e = []; - let r; - window.addEventListener("eip6963:announceProvider", (n) => { - const { detail: i } = n; - r && clearTimeout(r), e.push(i), r = setTimeout(() => t(e), 200); - }), r = setTimeout(() => t(e), 200), window.dispatchEvent(new Event("eip6963:requestProvider")); - }); -} -class Qs { - constructor(e, r) { - this.scope = e, this.module = r; - } - storeObject(e, r) { - this.setItem(e, JSON.stringify(r)); - } - loadObject(e) { - const r = this.getItem(e); - return r ? JSON.parse(r) : void 0; - } - setItem(e, r) { - localStorage.setItem(this.scopedKey(e), r); - } - getItem(e) { - return localStorage.getItem(this.scopedKey(e)); - } - removeItem(e) { - localStorage.removeItem(this.scopedKey(e)); - } - clear() { - const e = this.scopedKey(""), r = []; - for (let n = 0; n < localStorage.length; n++) { - const i = localStorage.key(n); - typeof i == "string" && i.startsWith(e) && r.push(i); - } - r.forEach((n) => localStorage.removeItem(n)); - } - scopedKey(e) { - return `-${this.scope}${this.module ? `:${this.module}` : ""}:${e}`; - } - static clearAll() { - new Qs("CBWSDK").clear(), new Qs("walletlink").clear(); - } -} -const fn = { - rpc: { - invalidInput: -32e3, - resourceNotFound: -32001, - resourceUnavailable: -32002, - transactionRejected: -32003, - methodNotSupported: -32004, - limitExceeded: -32005, - parse: -32700, - invalidRequest: -32600, - methodNotFound: -32601, - invalidParams: -32602, - internal: -32603 - }, - provider: { - userRejectedRequest: 4001, - unauthorized: 4100, - unsupportedMethod: 4200, - disconnected: 4900, - chainDisconnected: 4901, - unsupportedChain: 4902 - } -}, N1 = { - "-32700": { - standard: "JSON RPC 2.0", - message: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text." - }, - "-32600": { - standard: "JSON RPC 2.0", - message: "The JSON sent is not a valid Request object." - }, - "-32601": { - standard: "JSON RPC 2.0", - message: "The method does not exist / is not available." - }, - "-32602": { - standard: "JSON RPC 2.0", - message: "Invalid method parameter(s)." - }, - "-32603": { - standard: "JSON RPC 2.0", - message: "Internal JSON-RPC error." - }, - "-32000": { - standard: "EIP-1474", - message: "Invalid input." - }, - "-32001": { - standard: "EIP-1474", - message: "Resource not found." - }, - "-32002": { - standard: "EIP-1474", - message: "Resource unavailable." - }, - "-32003": { - standard: "EIP-1474", - message: "Transaction rejected." - }, - "-32004": { - standard: "EIP-1474", - message: "Method not supported." - }, - "-32005": { - standard: "EIP-1474", - message: "Request limit exceeded." - }, - 4001: { - standard: "EIP-1193", - message: "User rejected the request." - }, - 4100: { - standard: "EIP-1193", - message: "The requested account and/or method has not been authorized by the user." - }, - 4200: { - standard: "EIP-1193", - message: "The requested method is not supported by this Ethereum provider." - }, - 4900: { - standard: "EIP-1193", - message: "The provider is disconnected from all chains." - }, - 4901: { - standard: "EIP-1193", - message: "The provider is disconnected from the specified chain." - }, - 4902: { - standard: "EIP-3085", - message: "Unrecognized chain ID." - } -}, AE = "Unspecified error message.", RG = "Unspecified server error."; -function db(t, e = AE) { - if (t && Number.isInteger(t)) { - const r = t.toString(); - if (L1(N1, r)) - return N1[r].message; - if (PE(t)) - return RG; - } - return e; -} -function DG(t) { - if (!Number.isInteger(t)) - return !1; - const e = t.toString(); - return !!(N1[e] || PE(t)); -} -function OG(t, { shouldIncludeStack: e = !1 } = {}) { - const r = {}; - if (t && typeof t == "object" && !Array.isArray(t) && L1(t, "code") && DG(t.code)) { - const n = t; - r.code = n.code, n.message && typeof n.message == "string" ? (r.message = n.message, L1(n, "data") && (r.data = n.data)) : (r.message = db(r.code), r.data = { originalError: e_(t) }); - } else - r.code = fn.rpc.internal, r.message = t_(t, "message") ? t.message : AE, r.data = { originalError: e_(t) }; - return e && (r.stack = t_(t, "stack") ? t.stack : void 0), r; -} -function PE(t) { - return t >= -32099 && t <= -32e3; -} -function e_(t) { - return t && typeof t == "object" && !Array.isArray(t) ? Object.assign({}, t) : t; -} -function L1(t, e) { - return Object.prototype.hasOwnProperty.call(t, e); -} -function t_(t, e) { - return typeof t == "object" && t !== null && e in t && typeof t[e] == "string"; -} -const Sr = { - rpc: { - parse: (t) => Gi(fn.rpc.parse, t), - invalidRequest: (t) => Gi(fn.rpc.invalidRequest, t), - invalidParams: (t) => Gi(fn.rpc.invalidParams, t), - methodNotFound: (t) => Gi(fn.rpc.methodNotFound, t), - internal: (t) => Gi(fn.rpc.internal, t), - server: (t) => { - if (!t || typeof t != "object" || Array.isArray(t)) - throw new Error("Ethereum RPC Server errors must provide single object argument."); - const { code: e } = t; - if (!Number.isInteger(e) || e > -32005 || e < -32099) - throw new Error('"code" must be an integer such that: -32099 <= code <= -32005'); - return Gi(e, t); - }, - invalidInput: (t) => Gi(fn.rpc.invalidInput, t), - resourceNotFound: (t) => Gi(fn.rpc.resourceNotFound, t), - resourceUnavailable: (t) => Gi(fn.rpc.resourceUnavailable, t), - transactionRejected: (t) => Gi(fn.rpc.transactionRejected, t), - methodNotSupported: (t) => Gi(fn.rpc.methodNotSupported, t), - limitExceeded: (t) => Gi(fn.rpc.limitExceeded, t) - }, - provider: { - userRejectedRequest: (t) => Kc(fn.provider.userRejectedRequest, t), - unauthorized: (t) => Kc(fn.provider.unauthorized, t), - unsupportedMethod: (t) => Kc(fn.provider.unsupportedMethod, t), - disconnected: (t) => Kc(fn.provider.disconnected, t), - chainDisconnected: (t) => Kc(fn.provider.chainDisconnected, t), - unsupportedChain: (t) => Kc(fn.provider.unsupportedChain, t), - custom: (t) => { - if (!t || typeof t != "object" || Array.isArray(t)) - throw new Error("Ethereum Provider custom errors must provide single object argument."); - const { code: e, message: r, data: n } = t; - if (!r || typeof r != "string") - throw new Error('"message" must be a nonempty string'); - return new CE(e, r, n); - } - } -}; -function Gi(t, e) { - const [r, n] = ME(e); - return new IE(t, r || db(t), n); -} -function Kc(t, e) { - const [r, n] = ME(e); - return new CE(t, r || db(t), n); -} -function ME(t) { - if (t) { - if (typeof t == "string") - return [t]; - if (typeof t == "object" && !Array.isArray(t)) { - const { message: e, data: r } = t; - if (e && typeof e != "string") - throw new Error("Must specify string message."); - return [e || void 0, r]; - } - } - return []; -} -class IE extends Error { - constructor(e, r, n) { - if (!Number.isInteger(e)) - throw new Error('"code" must be an integer.'); - if (!r || typeof r != "string") - throw new Error('"message" must be a nonempty string.'); - super(r), this.code = e, n !== void 0 && (this.data = n); - } -} -class CE extends IE { - /** - * Create an Ethereum Provider JSON-RPC error. - * `code` must be an integer in the 1000 <= 4999 range. - */ - constructor(e, r, n) { - if (!NG(e)) - throw new Error('"code" must be an integer such that: 1000 <= code <= 4999'); - super(e, r, n); - } -} -function NG(t) { - return Number.isInteger(t) && t >= 1e3 && t <= 4999; -} -function pb() { - return (t) => t; -} -const Sl = pb(), LG = pb(), kG = pb(); -function xo(t) { - return Math.floor(t); -} -const TE = /^[0-9]*$/, RE = /^[a-f0-9]*$/; -function Za(t) { - return gb(crypto.getRandomValues(new Uint8Array(t))); -} -function gb(t) { - return [...t].map((e) => e.toString(16).padStart(2, "0")).join(""); -} -function Rd(t) { - return new Uint8Array(t.match(/.{1,2}/g).map((e) => Number.parseInt(e, 16))); -} -function Hf(t, e = !1) { - const r = t.toString("hex"); - return Sl(e ? `0x${r}` : r); -} -function _m(t) { - return Hf(k1(t), !0); -} -function ks(t) { - return kG(t.toString(10)); -} -function da(t) { - return Sl(`0x${BigInt(t).toString(16)}`); -} -function DE(t) { - return t.startsWith("0x") || t.startsWith("0X"); -} -function mb(t) { - return DE(t) ? t.slice(2) : t; -} -function OE(t) { - return DE(t) ? `0x${t.slice(2)}` : `0x${t}`; -} -function op(t) { - if (typeof t != "string") - return !1; - const e = mb(t).toLowerCase(); - return RE.test(e); -} -function $G(t, e = !1) { - if (typeof t == "string") { - const r = mb(t).toLowerCase(); - if (RE.test(r)) - return Sl(e ? `0x${r}` : r); - } - throw Sr.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`); -} -function vb(t, e = !1) { - let r = $G(t, !1); - return r.length % 2 === 1 && (r = Sl(`0${r}`)), e ? Sl(`0x${r}`) : r; -} -function ta(t) { - if (typeof t == "string") { - const e = mb(t).toLowerCase(); - if (op(e) && e.length === 40) - return LG(OE(e)); - } - throw Sr.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`); -} -function k1(t) { - if (Buffer.isBuffer(t)) - return t; - if (typeof t == "string") { - if (op(t)) { - const e = vb(t, !1); - return Buffer.from(e, "hex"); - } - return Buffer.from(t, "utf8"); - } - throw Sr.rpc.invalidParams(`Not binary data: ${String(t)}`); -} -function Wf(t) { - if (typeof t == "number" && Number.isInteger(t)) - return xo(t); - if (typeof t == "string") { - if (TE.test(t)) - return xo(Number(t)); - if (op(t)) - return xo(Number(BigInt(vb(t, !0)))); - } - throw Sr.rpc.invalidParams(`Not an integer: ${String(t)}`); -} -function Tf(t) { - if (t !== null && (typeof t == "bigint" || BG(t))) - return BigInt(t.toString(10)); - if (typeof t == "number") - return BigInt(Wf(t)); - if (typeof t == "string") { - if (TE.test(t)) - return BigInt(t); - if (op(t)) - return BigInt(vb(t, !0)); - } - throw Sr.rpc.invalidParams(`Not an integer: ${String(t)}`); -} -function FG(t) { - if (typeof t == "string") - return JSON.parse(t); - if (typeof t == "object") - return t; - throw Sr.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`); -} -function BG(t) { - if (t == null || typeof t.constructor != "function") - return !1; - const { constructor: e } = t; - return typeof e.config == "function" && typeof e.EUCLID == "number"; -} -async function UG() { - return crypto.subtle.generateKey({ - name: "ECDH", - namedCurve: "P-256" - }, !0, ["deriveKey"]); -} -async function jG(t, e) { - return crypto.subtle.deriveKey({ - name: "ECDH", - public: e - }, t, { - name: "AES-GCM", - length: 256 - }, !1, ["encrypt", "decrypt"]); -} -async function qG(t, e) { - const r = crypto.getRandomValues(new Uint8Array(12)), n = await crypto.subtle.encrypt({ - name: "AES-GCM", - iv: r - }, t, new TextEncoder().encode(e)); - return { iv: r, cipherText: n }; -} -async function zG(t, { iv: e, cipherText: r }) { - const n = await crypto.subtle.decrypt({ - name: "AES-GCM", - iv: e - }, t, r); - return new TextDecoder().decode(n); -} -function NE(t) { - switch (t) { - case "public": - return "spki"; - case "private": - return "pkcs8"; - } -} -async function LE(t, e) { - const r = NE(t), n = await crypto.subtle.exportKey(r, e); - return gb(new Uint8Array(n)); -} -async function kE(t, e) { - const r = NE(t), n = Rd(e).buffer; - return await crypto.subtle.importKey(r, new Uint8Array(n), { - name: "ECDH", - namedCurve: "P-256" - }, !0, t === "private" ? ["deriveKey"] : []); -} -async function HG(t, e) { - const r = JSON.stringify(t, (n, i) => { - if (!(i instanceof Error)) - return i; - const s = i; - return Object.assign(Object.assign({}, s.code ? { code: s.code } : {}), { message: s.message }); - }); - return qG(e, r); -} -async function WG(t, e) { - return JSON.parse(await zG(e, t)); -} -const Em = { - storageKey: "ownPrivateKey", - keyType: "private" -}, Sm = { - storageKey: "ownPublicKey", - keyType: "public" -}, Am = { - storageKey: "peerPublicKey", - keyType: "public" -}; -class KG { - constructor() { - this.storage = new Qs("CBWSDK", "SCWKeyManager"), this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null; - } - async getOwnPublicKey() { - return await this.loadKeysIfNeeded(), this.ownPublicKey; - } - // returns null if the shared secret is not yet derived - async getSharedSecret() { - return await this.loadKeysIfNeeded(), this.sharedSecret; - } - async setPeerPublicKey(e) { - this.sharedSecret = null, this.peerPublicKey = e, await this.storeKey(Am, e), await this.loadKeysIfNeeded(); - } - async clear() { - this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null, this.storage.removeItem(Sm.storageKey), this.storage.removeItem(Em.storageKey), this.storage.removeItem(Am.storageKey); - } - async generateKeyPair() { - const e = await UG(); - this.ownPrivateKey = e.privateKey, this.ownPublicKey = e.publicKey, await this.storeKey(Em, e.privateKey), await this.storeKey(Sm, e.publicKey); - } - async loadKeysIfNeeded() { - if (this.ownPrivateKey === null && (this.ownPrivateKey = await this.loadKey(Em)), this.ownPublicKey === null && (this.ownPublicKey = await this.loadKey(Sm)), (this.ownPrivateKey === null || this.ownPublicKey === null) && await this.generateKeyPair(), this.peerPublicKey === null && (this.peerPublicKey = await this.loadKey(Am)), this.sharedSecret === null) { - if (this.ownPrivateKey === null || this.peerPublicKey === null) - return; - this.sharedSecret = await jG(this.ownPrivateKey, this.peerPublicKey); - } - } - // storage methods - async loadKey(e) { - const r = this.storage.getItem(e.storageKey); - return r ? kE(e.keyType, r) : null; - } - async storeKey(e, r) { - const n = await LE(e.keyType, r); - this.storage.setItem(e.storageKey, n); - } -} -const rh = "4.2.4", $E = "@coinbase/wallet-sdk"; -async function FE(t, e) { - const r = Object.assign(Object.assign({}, t), { jsonrpc: "2.0", id: crypto.randomUUID() }), n = await window.fetch(e, { - method: "POST", - body: JSON.stringify(r), - mode: "cors", - headers: { - "Content-Type": "application/json", - "X-Cbw-Sdk-Version": rh, - "X-Cbw-Sdk-Platform": $E - } - }), { result: i, error: s } = await n.json(); - if (s) - throw s; - return i; -} -function VG() { - return globalThis.coinbaseWalletExtension; -} -function GG() { - var t, e; - try { - const r = globalThis; - return (t = r.ethereum) !== null && t !== void 0 ? t : (e = r.top) === null || e === void 0 ? void 0 : e.ethereum; - } catch { - return; - } -} -function YG({ metadata: t, preference: e }) { - var r, n; - const { appName: i, appLogoUrl: s, appChainIds: o } = t; - if (e.options !== "smartWalletOnly") { - const u = VG(); - if (u) - return (r = u.setAppInfo) === null || r === void 0 || r.call(u, i, s, o, e), u; - } - const a = GG(); - if (a != null && a.isCoinbaseBrowser) - return (n = a.setAppInfo) === null || n === void 0 || n.call(a, i, s, o, e), a; -} -function JG(t) { - if (!t || typeof t != "object" || Array.isArray(t)) - throw Sr.rpc.invalidParams({ - message: "Expected a single, non-array, object argument.", - data: t - }); - const { method: e, params: r } = t; - if (typeof e != "string" || e.length === 0) - throw Sr.rpc.invalidParams({ - message: "'args.method' must be a non-empty string.", - data: t - }); - if (r !== void 0 && !Array.isArray(r) && (typeof r != "object" || r === null)) - throw Sr.rpc.invalidParams({ - message: "'args.params' must be an object or array if provided.", - data: t - }); - switch (e) { - case "eth_sign": - case "eth_signTypedData_v2": - case "eth_subscribe": - case "eth_unsubscribe": - throw Sr.provider.unsupportedMethod(); - } -} -const r_ = "accounts", n_ = "activeChain", i_ = "availableChains", s_ = "walletCapabilities"; -class XG { - constructor(e) { - var r, n, i; - this.metadata = e.metadata, this.communicator = e.communicator, this.callback = e.callback, this.keyManager = new KG(), this.storage = new Qs("CBWSDK", "SCWStateManager"), this.accounts = (r = this.storage.loadObject(r_)) !== null && r !== void 0 ? r : [], this.chain = this.storage.loadObject(n_) || { - id: (i = (n = e.metadata.appChainIds) === null || n === void 0 ? void 0 : n[0]) !== null && i !== void 0 ? i : 1 - }, this.handshake = this.handshake.bind(this), this.request = this.request.bind(this), this.createRequestMessage = this.createRequestMessage.bind(this), this.decryptResponseMessage = this.decryptResponseMessage.bind(this); - } - async handshake(e) { - var r, n; - const i = await this.createRequestMessage({ - handshake: { - method: e.method, - params: Object.assign({}, this.metadata, (r = e.params) !== null && r !== void 0 ? r : {}) - } - }), s = await this.communicator.postRequestAndWaitForResponse(i); - if ("failure" in s.content) - throw s.content.failure; - const o = await kE("public", s.sender); - await this.keyManager.setPeerPublicKey(o); - const u = (await this.decryptResponseMessage(s)).result; - if ("error" in u) - throw u.error; - const l = u.value; - this.accounts = l, this.storage.storeObject(r_, l), (n = this.callback) === null || n === void 0 || n.call(this, "accountsChanged", l); - } - async request(e) { - var r; - if (this.accounts.length === 0) - throw Sr.provider.unauthorized(); - switch (e.method) { - case "eth_requestAccounts": - return (r = this.callback) === null || r === void 0 || r.call(this, "connect", { chainId: da(this.chain.id) }), this.accounts; - case "eth_accounts": - return this.accounts; - case "eth_coinbase": - return this.accounts[0]; - case "net_version": - return this.chain.id; - case "eth_chainId": - return da(this.chain.id); - case "wallet_getCapabilities": - return this.storage.loadObject(s_); - case "wallet_switchEthereumChain": - return this.handleSwitchChainRequest(e); - case "eth_ecRecover": - case "personal_sign": - case "personal_ecRecover": - case "eth_signTransaction": - case "eth_sendTransaction": - case "eth_signTypedData_v1": - case "eth_signTypedData_v3": - case "eth_signTypedData_v4": - case "eth_signTypedData": - case "wallet_addEthereumChain": - case "wallet_watchAsset": - case "wallet_sendCalls": - case "wallet_showCallsStatus": - case "wallet_grantPermissions": - return this.sendRequestToPopup(e); - default: - if (!this.chain.rpcUrl) - throw Sr.rpc.internal("No RPC URL set for chain"); - return FE(e, this.chain.rpcUrl); - } - } - async sendRequestToPopup(e) { - var r, n; - await ((n = (r = this.communicator).waitForPopupLoaded) === null || n === void 0 ? void 0 : n.call(r)); - const i = await this.sendEncryptedRequest(e), o = (await this.decryptResponseMessage(i)).result; - if ("error" in o) - throw o.error; - return o.value; - } - async cleanup() { - var e, r; - this.storage.clear(), await this.keyManager.clear(), this.accounts = [], this.chain = { - id: (r = (e = this.metadata.appChainIds) === null || e === void 0 ? void 0 : e[0]) !== null && r !== void 0 ? r : 1 - }; - } - /** - * @returns `null` if the request was successful. - * https://eips.ethereum.org/EIPS/eip-3326#wallet_switchethereumchain - */ - async handleSwitchChainRequest(e) { - var r; - const n = e.params; - if (!n || !(!((r = n[0]) === null || r === void 0) && r.chainId)) - throw Sr.rpc.invalidParams(); - const i = Wf(n[0].chainId); - if (this.updateChain(i)) - return null; - const o = await this.sendRequestToPopup(e); - return o === null && this.updateChain(i), o; - } - async sendEncryptedRequest(e) { - const r = await this.keyManager.getSharedSecret(); - if (!r) - throw Sr.provider.unauthorized("No valid session found, try requestAccounts before other methods"); - const n = await HG({ - action: e, - chainId: this.chain.id - }, r), i = await this.createRequestMessage({ encrypted: n }); - return this.communicator.postRequestAndWaitForResponse(i); - } - async createRequestMessage(e) { - const r = await LE("public", await this.keyManager.getOwnPublicKey()); - return { - id: crypto.randomUUID(), - sender: r, - content: e, - timestamp: /* @__PURE__ */ new Date() - }; - } - async decryptResponseMessage(e) { - var r, n; - const i = e.content; - if ("failure" in i) - throw i.failure; - const s = await this.keyManager.getSharedSecret(); - if (!s) - throw Sr.provider.unauthorized("Invalid session"); - const o = await WG(i.encrypted, s), a = (r = o.data) === null || r === void 0 ? void 0 : r.chains; - if (a) { - const l = Object.entries(a).map(([d, g]) => ({ - id: Number(d), - rpcUrl: g - })); - this.storage.storeObject(i_, l), this.updateChain(this.chain.id, l); - } - const u = (n = o.data) === null || n === void 0 ? void 0 : n.capabilities; - return u && this.storage.storeObject(s_, u), o; - } - updateChain(e, r) { - var n; - const i = r ?? this.storage.loadObject(i_), s = i == null ? void 0 : i.find((o) => o.id === e); - return s ? (s !== this.chain && (this.chain = s, this.storage.storeObject(n_, s), (n = this.callback) === null || n === void 0 || n.call(this, "chainChanged", da(s.id))), !0) : !1; - } -} -const ZG = /* @__PURE__ */ bv(TD), { keccak_256: QG } = ZG; -function BE(t) { - return Buffer.allocUnsafe(t).fill(0); -} -function eY(t) { - return t.toString(2).length; -} -function UE(t, e) { - let r = t.toString(16); - r.length % 2 !== 0 && (r = "0" + r); - const n = r.match(/.{1,2}/g).map((i) => parseInt(i, 16)); - for (; n.length < e; ) - n.unshift(0); - return Buffer.from(n); -} -function tY(t, e) { - const r = t < 0n; - let n; - if (r) { - const i = (1n << BigInt(e)) - 1n; - n = (~t & i) + 1n; - } else - n = t; - return n &= (1n << BigInt(e)) - 1n, n; -} -function jE(t, e, r) { - const n = BE(e); - return t = ap(t), r ? t.length < e ? (t.copy(n), n) : t.slice(0, e) : t.length < e ? (t.copy(n, e - t.length), n) : t.slice(-e); -} -function rY(t, e) { - return jE(t, e, !0); -} -function ap(t) { - if (!Buffer.isBuffer(t)) - if (Array.isArray(t)) - t = Buffer.from(t); - else if (typeof t == "string") - qE(t) ? t = Buffer.from(sY(zE(t)), "hex") : t = Buffer.from(t); - else if (typeof t == "number") - t = intToBuffer(t); - else if (t == null) - t = Buffer.allocUnsafe(0); - else if (typeof t == "bigint") - t = UE(t); - else if (t.toArray) - t = Buffer.from(t.toArray()); - else - throw new Error("invalid type"); - return t; -} -function nY(t) { - return t = ap(t), "0x" + t.toString("hex"); -} -function iY(t, e) { - if (t = ap(t), e || (e = 256), e !== 256) - throw new Error("unsupported"); - return Buffer.from(QG(new Uint8Array(t))); -} -function sY(t) { - return t.length % 2 ? "0" + t : t; -} -function qE(t) { - return typeof t == "string" && t.match(/^0x[0-9A-Fa-f]*$/); -} -function zE(t) { - return typeof t == "string" && t.startsWith("0x") ? t.slice(2) : t; -} -var HE = { - zeros: BE, - setLength: jE, - setLengthRight: rY, - isHexString: qE, - stripHexPrefix: zE, - toBuffer: ap, - bufferToHex: nY, - keccak: iY, - bitLengthFromBigInt: eY, - bufferBEFromBigInt: UE, - twosFromBigInt: tY -}; -const ii = HE; -function WE(t) { - return t.startsWith("int[") ? "int256" + t.slice(3) : t === "int" ? "int256" : t.startsWith("uint[") ? "uint256" + t.slice(4) : t === "uint" ? "uint256" : t.startsWith("fixed[") ? "fixed128x128" + t.slice(5) : t === "fixed" ? "fixed128x128" : t.startsWith("ufixed[") ? "ufixed128x128" + t.slice(6) : t === "ufixed" ? "ufixed128x128" : t; -} -function du(t) { - return Number.parseInt(/^\D+(\d+)$/.exec(t)[1], 10); -} -function o_(t) { - var e = /^\D+(\d+)x(\d+)$/.exec(t); - return [Number.parseInt(e[1], 10), Number.parseInt(e[2], 10)]; -} -function KE(t) { - var e = t.match(/(.*)\[(.*?)\]$/); - return e ? e[2] === "" ? "dynamic" : Number.parseInt(e[2], 10) : null; -} -function Qa(t) { - var e = typeof t; - if (e === "string" || e === "number") - return BigInt(t); - if (e === "bigint") - return t; - throw new Error("Argument is not a number"); -} -function js(t, e) { - var r, n, i, s; - if (t === "address") - return js("uint160", Qa(e)); - if (t === "bool") - return js("uint8", e ? 1 : 0); - if (t === "string") - return js("bytes", new Buffer(e, "utf8")); - if (aY(t)) { - if (typeof e.length > "u") - throw new Error("Not an array?"); - if (r = KE(t), r !== "dynamic" && r !== 0 && e.length > r) - throw new Error("Elements exceed array size: " + r); - i = [], t = t.slice(0, t.lastIndexOf("[")), typeof e == "string" && (e = JSON.parse(e)); - for (s in e) - i.push(js(t, e[s])); - if (r === "dynamic") { - var o = js("uint256", e.length); - i.unshift(o); - } - return Buffer.concat(i); - } else { - if (t === "bytes") - return e = new Buffer(e), i = Buffer.concat([js("uint256", e.length), e]), e.length % 32 !== 0 && (i = Buffer.concat([i, ii.zeros(32 - e.length % 32)])), i; - if (t.startsWith("bytes")) { - if (r = du(t), r < 1 || r > 32) - throw new Error("Invalid bytes width: " + r); - return ii.setLengthRight(e, 32); - } else if (t.startsWith("uint")) { - if (r = du(t), r % 8 || r < 8 || r > 256) - throw new Error("Invalid uint width: " + r); - n = Qa(e); - const a = ii.bitLengthFromBigInt(n); - if (a > r) - throw new Error("Supplied uint exceeds width: " + r + " vs " + a); - if (n < 0) - throw new Error("Supplied uint is negative"); - return ii.bufferBEFromBigInt(n, 32); - } else if (t.startsWith("int")) { - if (r = du(t), r % 8 || r < 8 || r > 256) - throw new Error("Invalid int width: " + r); - n = Qa(e); - const a = ii.bitLengthFromBigInt(n); - if (a > r) - throw new Error("Supplied int exceeds width: " + r + " vs " + a); - const u = ii.twosFromBigInt(n, 256); - return ii.bufferBEFromBigInt(u, 32); - } else if (t.startsWith("ufixed")) { - if (r = o_(t), n = Qa(e), n < 0) - throw new Error("Supplied ufixed is negative"); - return js("uint256", n * BigInt(2) ** BigInt(r[1])); - } else if (t.startsWith("fixed")) - return r = o_(t), js("int256", Qa(e) * BigInt(2) ** BigInt(r[1])); - } - throw new Error("Unsupported or invalid type: " + t); -} -function oY(t) { - return t === "string" || t === "bytes" || KE(t) === "dynamic"; -} -function aY(t) { - return t.lastIndexOf("]") === t.length - 1; -} -function cY(t, e) { - var r = [], n = [], i = 32 * t.length; - for (var s in t) { - var o = WE(t[s]), a = e[s], u = js(o, a); - oY(o) ? (r.push(js("uint256", i)), n.push(u), i += u.length) : r.push(u); - } - return Buffer.concat(r.concat(n)); -} -function VE(t, e) { - if (t.length !== e.length) - throw new Error("Number of types are not matching the values"); - for (var r, n, i = [], s = 0; s < t.length; s++) { - var o = WE(t[s]), a = e[s]; - if (o === "bytes") - i.push(a); - else if (o === "string") - i.push(new Buffer(a, "utf8")); - else if (o === "bool") - i.push(new Buffer(a ? "01" : "00", "hex")); - else if (o === "address") - i.push(ii.setLength(a, 20)); - else if (o.startsWith("bytes")) { - if (r = du(o), r < 1 || r > 32) - throw new Error("Invalid bytes width: " + r); - i.push(ii.setLengthRight(a, r)); - } else if (o.startsWith("uint")) { - if (r = du(o), r % 8 || r < 8 || r > 256) - throw new Error("Invalid uint width: " + r); - n = Qa(a); - const u = ii.bitLengthFromBigInt(n); - if (u > r) - throw new Error("Supplied uint exceeds width: " + r + " vs " + u); - i.push(ii.bufferBEFromBigInt(n, r / 8)); - } else if (o.startsWith("int")) { - if (r = du(o), r % 8 || r < 8 || r > 256) - throw new Error("Invalid int width: " + r); - n = Qa(a); - const u = ii.bitLengthFromBigInt(n); - if (u > r) - throw new Error("Supplied int exceeds width: " + r + " vs " + u); - const l = ii.twosFromBigInt(n, r); - i.push(ii.bufferBEFromBigInt(l, r / 8)); - } else - throw new Error("Unsupported or invalid type: " + o); - } - return Buffer.concat(i); -} -function uY(t, e) { - return ii.keccak(VE(t, e)); -} -var fY = { - rawEncode: cY, - solidityPack: VE, - soliditySHA3: uY -}; -const bs = HE, Kf = fY, GE = { - type: "object", - properties: { - types: { - type: "object", - additionalProperties: { - type: "array", - items: { - type: "object", - properties: { - name: { type: "string" }, - type: { type: "string" } - }, - required: ["name", "type"] - } - } - }, - primaryType: { type: "string" }, - domain: { type: "object" }, - message: { type: "object" } - }, - required: ["types", "primaryType", "domain", "message"] -}, Pm = { - /** - * Encodes an object by encoding and concatenating each of its members - * - * @param {string} primaryType - Root type - * @param {Object} data - Object to encode - * @param {Object} types - Type definitions - * @returns {string} - Encoded representation of an object - */ - encodeData(t, e, r, n = !0) { - const i = ["bytes32"], s = [this.hashType(t, r)]; - if (n) { - const o = (a, u, l) => { - if (r[u] !== void 0) - return ["bytes32", l == null ? "0x0000000000000000000000000000000000000000000000000000000000000000" : bs.keccak(this.encodeData(u, l, r, n))]; - if (l === void 0) - throw new Error(`missing value for field ${a} of type ${u}`); - if (u === "bytes") - return ["bytes32", bs.keccak(l)]; - if (u === "string") - return typeof l == "string" && (l = Buffer.from(l, "utf8")), ["bytes32", bs.keccak(l)]; - if (u.lastIndexOf("]") === u.length - 1) { - const d = u.slice(0, u.lastIndexOf("[")), g = l.map((w) => o(a, d, w)); - return ["bytes32", bs.keccak(Kf.rawEncode( - g.map(([w]) => w), - g.map(([, w]) => w) - ))]; - } - return [u, l]; - }; - for (const a of r[t]) { - const [u, l] = o(a.name, a.type, e[a.name]); - i.push(u), s.push(l); - } - } else - for (const o of r[t]) { - let a = e[o.name]; - if (a !== void 0) - if (o.type === "bytes") - i.push("bytes32"), a = bs.keccak(a), s.push(a); - else if (o.type === "string") - i.push("bytes32"), typeof a == "string" && (a = Buffer.from(a, "utf8")), a = bs.keccak(a), s.push(a); - else if (r[o.type] !== void 0) - i.push("bytes32"), a = bs.keccak(this.encodeData(o.type, a, r, n)), s.push(a); - else { - if (o.type.lastIndexOf("]") === o.type.length - 1) - throw new Error("Arrays currently unimplemented in encodeData"); - i.push(o.type), s.push(a); - } - } - return Kf.rawEncode(i, s); - }, - /** - * Encodes the type of an object by encoding a comma delimited list of its members - * - * @param {string} primaryType - Root type to encode - * @param {Object} types - Type definitions - * @returns {string} - Encoded representation of the type of an object - */ - encodeType(t, e) { - let r = "", n = this.findTypeDependencies(t, e).filter((i) => i !== t); - n = [t].concat(n.sort()); - for (const i of n) { - if (!e[i]) - throw new Error("No type definition specified: " + i); - r += i + "(" + e[i].map(({ name: o, type: a }) => a + " " + o).join(",") + ")"; - } - return r; - }, - /** - * Finds all types within a type definition object - * - * @param {string} primaryType - Root type - * @param {Object} types - Type definitions - * @param {Array} results - current set of accumulated types - * @returns {Array} - Set of all types found in the type definition - */ - findTypeDependencies(t, e, r = []) { - if (t = t.match(/^\w*/)[0], r.includes(t) || e[t] === void 0) - return r; - r.push(t); - for (const n of e[t]) - for (const i of this.findTypeDependencies(n.type, e, r)) - !r.includes(i) && r.push(i); - return r; - }, - /** - * Hashes an object - * - * @param {string} primaryType - Root type - * @param {Object} data - Object to hash - * @param {Object} types - Type definitions - * @returns {Buffer} - Hash of an object - */ - hashStruct(t, e, r, n = !0) { - return bs.keccak(this.encodeData(t, e, r, n)); - }, - /** - * Hashes the type of an object - * - * @param {string} primaryType - Root type to hash - * @param {Object} types - Type definitions - * @returns {string} - Hash of an object - */ - hashType(t, e) { - return bs.keccak(this.encodeType(t, e)); - }, - /** - * Removes properties from a message object that are not defined per EIP-712 - * - * @param {Object} data - typed message object - * @returns {Object} - typed message object with only allowed fields - */ - sanitizeData(t) { - const e = {}; - for (const r in GE.properties) - t[r] && (e[r] = t[r]); - return e.types && (e.types = Object.assign({ EIP712Domain: [] }, e.types)), e; - }, - /** - * Returns the hash of a typed message as per EIP-712 for signing - * - * @param {Object} typedData - Types message data to sign - * @returns {string} - sha3 hash for signing - */ - hash(t, e = !0) { - const r = this.sanitizeData(t), n = [Buffer.from("1901", "hex")]; - return n.push(this.hashStruct("EIP712Domain", r.domain, r.types, e)), r.primaryType !== "EIP712Domain" && n.push(this.hashStruct(r.primaryType, r.message, r.types, e)), bs.keccak(Buffer.concat(n)); - } -}; -var lY = { - TYPED_MESSAGE_SCHEMA: GE, - TypedDataUtils: Pm, - hashForSignTypedDataLegacy: function(t) { - return hY(t.data); - }, - hashForSignTypedData_v3: function(t) { - return Pm.hash(t.data, !1); - }, - hashForSignTypedData_v4: function(t) { - return Pm.hash(t.data); - } -}; -function hY(t) { - const e = new Error("Expect argument to be non-empty array"); - if (typeof t != "object" || !t.length) throw e; - const r = t.map(function(s) { - return s.type === "bytes" ? bs.toBuffer(s.value) : s.value; - }), n = t.map(function(s) { - return s.type; - }), i = t.map(function(s) { - if (!s.name) throw e; - return s.type + " " + s.name; - }); - return Kf.soliditySHA3( - ["bytes32", "bytes32"], - [ - Kf.soliditySHA3(new Array(t.length).fill("string"), i), - Kf.soliditySHA3(n, r) - ] - ); -} -const hd = /* @__PURE__ */ ts(lY), dY = "walletUsername", $1 = "Addresses", pY = "AppVersion"; -function Bn(t) { - return t.errorMessage !== void 0; -} -class gY { - // @param secret hex representation of 32-byte secret - constructor(e) { - this.secret = e; - } - /** - * - * @param plainText string to be encrypted - * returns hex string representation of bytes in the order: initialization vector (iv), - * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes. Remaining bytes are the - * encrypted plainText. - */ - async encrypt(e) { - const r = this.secret; - if (r.length !== 64) - throw Error("secret must be 256 bits"); - const n = crypto.getRandomValues(new Uint8Array(12)), i = await crypto.subtle.importKey("raw", Rd(r), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), s = new TextEncoder(), o = await window.crypto.subtle.encrypt({ - name: "AES-GCM", - iv: n - }, i, s.encode(e)), a = 16, u = o.slice(o.byteLength - a), l = o.slice(0, o.byteLength - a), d = new Uint8Array(u), g = new Uint8Array(l), w = new Uint8Array([...n, ...d, ...g]); - return gb(w); - } - /** - * - * @param cipherText hex string representation of bytes in the order: initialization vector (iv), - * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes. - */ - async decrypt(e) { - const r = this.secret; - if (r.length !== 64) - throw Error("secret must be 256 bits"); - return new Promise((n, i) => { - (async function() { - const s = await crypto.subtle.importKey("raw", Rd(r), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), o = Rd(e), a = o.slice(0, 12), u = o.slice(12, 28), l = o.slice(28), d = new Uint8Array([...l, ...u]), g = { - name: "AES-GCM", - iv: new Uint8Array(a) - }; - try { - const w = await window.crypto.subtle.decrypt(g, s, d), A = new TextDecoder(); - n(A.decode(w)); - } catch (w) { - i(w); - } - })(); - }); - } -} -class mY { - constructor(e, r, n) { - this.linkAPIUrl = e, this.sessionId = r; - const i = `${r}:${n}`; - this.auth = `Basic ${btoa(i)}`; - } - // mark unseen events as seen - async markUnseenEventsAsSeen(e) { - return Promise.all(e.map((r) => fetch(`${this.linkAPIUrl}/events/${r.eventId}/seen`, { - method: "POST", - headers: { - Authorization: this.auth - } - }))).catch((r) => console.error("Unabled to mark event as failed:", r)); - } - async fetchUnseenEvents() { - var e; - const r = await fetch(`${this.linkAPIUrl}/events?unseen=true`, { - headers: { - Authorization: this.auth - } - }); - if (r.ok) { - const { events: n, error: i } = await r.json(); - if (i) - throw new Error(`Check unseen events failed: ${i}`); - const s = (e = n == null ? void 0 : n.filter((o) => o.event === "Web3Response").map((o) => ({ - type: "Event", - sessionId: this.sessionId, - eventId: o.id, - event: o.event, - data: o.data - }))) !== null && e !== void 0 ? e : []; - return this.markUnseenEventsAsSeen(s), s; - } - throw new Error(`Check unseen events failed: ${r.status}`); - } -} -var Ao; -(function(t) { - t[t.DISCONNECTED = 0] = "DISCONNECTED", t[t.CONNECTING = 1] = "CONNECTING", t[t.CONNECTED = 2] = "CONNECTED"; -})(Ao || (Ao = {})); -class vY { - setConnectionStateListener(e) { - this.connectionStateListener = e; - } - setIncomingDataListener(e) { - this.incomingDataListener = e; - } - /** - * Constructor - * @param url WebSocket server URL - * @param [WebSocketClass] Custom WebSocket implementation - */ - constructor(e, r = WebSocket) { - this.WebSocketClass = r, this.webSocket = null, this.pendingData = [], this.url = e.replace(/^http/, "ws"); - } - /** - * Make a websocket connection - * @returns a Promise that resolves when connected - */ - async connect() { - if (this.webSocket) - throw new Error("webSocket object is not null"); - return new Promise((e, r) => { - var n; - let i; - try { - this.webSocket = i = new this.WebSocketClass(this.url); - } catch (s) { - r(s); - return; - } - (n = this.connectionStateListener) === null || n === void 0 || n.call(this, Ao.CONNECTING), i.onclose = (s) => { - var o; - this.clearWebSocket(), r(new Error(`websocket error ${s.code}: ${s.reason}`)), (o = this.connectionStateListener) === null || o === void 0 || o.call(this, Ao.DISCONNECTED); - }, i.onopen = (s) => { - var o; - e(), (o = this.connectionStateListener) === null || o === void 0 || o.call(this, Ao.CONNECTED), this.pendingData.length > 0 && ([...this.pendingData].forEach((u) => this.sendData(u)), this.pendingData = []); - }, i.onmessage = (s) => { - var o, a; - if (s.data === "h") - (o = this.incomingDataListener) === null || o === void 0 || o.call(this, { - type: "Heartbeat" - }); - else - try { - const u = JSON.parse(s.data); - (a = this.incomingDataListener) === null || a === void 0 || a.call(this, u); - } catch { - } - }; - }); - } - /** - * Disconnect from server - */ - disconnect() { - var e; - const { webSocket: r } = this; - if (r) { - this.clearWebSocket(), (e = this.connectionStateListener) === null || e === void 0 || e.call(this, Ao.DISCONNECTED), this.connectionStateListener = void 0, this.incomingDataListener = void 0; - try { - r.close(); - } catch { - } - } - } - /** - * Send data to server - * @param data text to send - */ - sendData(e) { - const { webSocket: r } = this; - if (!r) { - this.pendingData.push(e), this.connect(); - return; - } - r.send(e); - } - clearWebSocket() { - const { webSocket: e } = this; - e && (this.webSocket = null, e.onclose = null, e.onerror = null, e.onmessage = null, e.onopen = null); - } -} -const a_ = 1e4, bY = 6e4; -class yY { - /** - * Constructor - * @param session Session - * @param linkAPIUrl Coinbase Wallet link server URL - * @param listener WalletLinkConnectionUpdateListener - * @param [WebSocketClass] Custom WebSocket implementation - */ - constructor({ session: e, linkAPIUrl: r, listener: n }) { - this.destroyed = !1, this.lastHeartbeatResponse = 0, this.nextReqId = xo(1), this._connected = !1, this._linked = !1, this.shouldFetchUnseenEventsOnConnect = !1, this.requestResolutions = /* @__PURE__ */ new Map(), this.handleSessionMetadataUpdated = (s) => { - if (!s) - return; - (/* @__PURE__ */ new Map([ - ["__destroyed", this.handleDestroyed], - ["EthereumAddress", this.handleAccountUpdated], - ["WalletUsername", this.handleWalletUsernameUpdated], - ["AppVersion", this.handleAppVersionUpdated], - [ - "ChainId", - // ChainId and JsonRpcUrl are always updated together - (a) => s.JsonRpcUrl && this.handleChainUpdated(a, s.JsonRpcUrl) - ] - ])).forEach((a, u) => { - const l = s[u]; - l !== void 0 && a(l); - }); - }, this.handleDestroyed = (s) => { - var o; - s === "1" && ((o = this.listener) === null || o === void 0 || o.resetAndReload()); - }, this.handleAccountUpdated = async (s) => { - var o; - const a = await this.cipher.decrypt(s); - (o = this.listener) === null || o === void 0 || o.accountUpdated(a); - }, this.handleMetadataUpdated = async (s, o) => { - var a; - const u = await this.cipher.decrypt(o); - (a = this.listener) === null || a === void 0 || a.metadataUpdated(s, u); - }, this.handleWalletUsernameUpdated = async (s) => { - this.handleMetadataUpdated(dY, s); - }, this.handleAppVersionUpdated = async (s) => { - this.handleMetadataUpdated(pY, s); - }, this.handleChainUpdated = async (s, o) => { - var a; - const u = await this.cipher.decrypt(s), l = await this.cipher.decrypt(o); - (a = this.listener) === null || a === void 0 || a.chainUpdated(u, l); - }, this.session = e, this.cipher = new gY(e.secret), this.listener = n; - const i = new vY(`${r}/rpc`, WebSocket); - i.setConnectionStateListener(async (s) => { - let o = !1; - switch (s) { - case Ao.DISCONNECTED: - if (!this.destroyed) { - const a = async () => { - await new Promise((u) => setTimeout(u, 5e3)), this.destroyed || i.connect().catch(() => { - a(); - }); - }; - a(); - } - break; - case Ao.CONNECTED: - o = await this.handleConnected(), this.updateLastHeartbeat(), setInterval(() => { - this.heartbeat(); - }, a_), this.shouldFetchUnseenEventsOnConnect && this.fetchUnseenEventsAPI(); - break; - case Ao.CONNECTING: - break; - } - this.connected !== o && (this.connected = o); - }), i.setIncomingDataListener((s) => { - var o; - switch (s.type) { - case "Heartbeat": - this.updateLastHeartbeat(); - return; - case "IsLinkedOK": - case "Linked": { - const a = s.type === "IsLinkedOK" ? s.linked : void 0; - this.linked = a || s.onlineGuests > 0; - break; - } - case "GetSessionConfigOK": - case "SessionConfigUpdated": { - this.handleSessionMetadataUpdated(s.metadata); - break; - } - case "Event": { - this.handleIncomingEvent(s); - break; - } - } - s.id !== void 0 && ((o = this.requestResolutions.get(s.id)) === null || o === void 0 || o(s)); - }), this.ws = i, this.http = new mY(r, e.id, e.key); - } - /** - * Make a connection to the server - */ - connect() { - if (this.destroyed) - throw new Error("instance is destroyed"); - this.ws.connect(); - } - /** - * Terminate connection, and mark as destroyed. To reconnect, create a new - * instance of WalletSDKConnection - */ - async destroy() { - this.destroyed || (await this.makeRequest({ - type: "SetSessionConfig", - id: xo(this.nextReqId++), - sessionId: this.session.id, - metadata: { __destroyed: "1" } - }, { timeout: 1e3 }), this.destroyed = !0, this.ws.disconnect(), this.listener = void 0); - } - get connected() { - return this._connected; - } - set connected(e) { - this._connected = e; - } - get linked() { - return this._linked; - } - set linked(e) { - var r, n; - this._linked = e, e && ((r = this.onceLinked) === null || r === void 0 || r.call(this)), (n = this.listener) === null || n === void 0 || n.linkedUpdated(e); - } - setOnceLinked(e) { - return new Promise((r) => { - this.linked ? e().then(r) : this.onceLinked = () => { - e().then(r), this.onceLinked = void 0; - }; - }); - } - async handleIncomingEvent(e) { - var r; - if (e.type !== "Event" || e.event !== "Web3Response") - return; - const n = await this.cipher.decrypt(e.data), i = JSON.parse(n); - if (i.type !== "WEB3_RESPONSE") - return; - const { id: s, response: o } = i; - (r = this.listener) === null || r === void 0 || r.handleWeb3ResponseMessage(s, o); - } - async checkUnseenEvents() { - if (!this.connected) { - this.shouldFetchUnseenEventsOnConnect = !0; - return; - } - await new Promise((e) => setTimeout(e, 250)); - try { - await this.fetchUnseenEventsAPI(); - } catch (e) { - console.error("Unable to check for unseen events", e); - } - } - async fetchUnseenEventsAPI() { - this.shouldFetchUnseenEventsOnConnect = !1, (await this.http.fetchUnseenEvents()).forEach((r) => this.handleIncomingEvent(r)); - } - /** - * Publish an event and emit event ID when successful - * @param event event name - * @param unencryptedData unencrypted event data - * @param callWebhook whether the webhook should be invoked - * @returns a Promise that emits event ID when successful - */ - async publishEvent(e, r, n = !1) { - const i = await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({}, r), { origin: location.origin, location: location.href, relaySource: "coinbaseWalletExtension" in window && window.coinbaseWalletExtension ? "injected_sdk" : "sdk" }))), s = { - type: "PublishEvent", - id: xo(this.nextReqId++), - sessionId: this.session.id, - event: e, - data: i, - callWebhook: n - }; - return this.setOnceLinked(async () => { - const o = await this.makeRequest(s); - if (o.type === "Fail") - throw new Error(o.error || "failed to publish event"); - return o.eventId; - }); - } - sendData(e) { - this.ws.sendData(JSON.stringify(e)); - } - updateLastHeartbeat() { - this.lastHeartbeatResponse = Date.now(); - } - heartbeat() { - if (Date.now() - this.lastHeartbeatResponse > a_ * 2) { - this.ws.disconnect(); - return; - } - try { - this.ws.sendData("h"); - } catch { - } - } - async makeRequest(e, r = { timeout: bY }) { - const n = e.id; - this.sendData(e); - let i; - return Promise.race([ - new Promise((s, o) => { - i = window.setTimeout(() => { - o(new Error(`request ${n} timed out`)); - }, r.timeout); - }), - new Promise((s) => { - this.requestResolutions.set(n, (o) => { - clearTimeout(i), s(o), this.requestResolutions.delete(n); - }); - }) - ]); - } - async handleConnected() { - return (await this.makeRequest({ - type: "HostSession", - id: xo(this.nextReqId++), - sessionId: this.session.id, - sessionKey: this.session.key - })).type === "Fail" ? !1 : (this.sendData({ - type: "IsLinked", - id: xo(this.nextReqId++), - sessionId: this.session.id - }), this.sendData({ - type: "GetSessionConfig", - id: xo(this.nextReqId++), - sessionId: this.session.id - }), !0); - } -} -class wY { - constructor() { - this._nextRequestId = 0, this.callbacks = /* @__PURE__ */ new Map(); - } - makeRequestId() { - this._nextRequestId = (this._nextRequestId + 1) % 2147483647; - const e = this._nextRequestId, r = OE(e.toString(16)); - return this.callbacks.get(r) && this.callbacks.delete(r), e; - } -} -const c_ = "session:id", u_ = "session:secret", f_ = "session:linked"; -class pu { - constructor(e, r, n, i = !1) { - this.storage = e, this.id = r, this.secret = n, this.key = lD(r4(`${r}, ${n} WalletLink`)), this._linked = !!i; - } - static create(e) { - const r = Za(16), n = Za(32); - return new pu(e, r, n).save(); - } - static load(e) { - const r = e.getItem(c_), n = e.getItem(f_), i = e.getItem(u_); - return r && i ? new pu(e, r, i, n === "1") : null; - } - get linked() { - return this._linked; - } - set linked(e) { - this._linked = e, this.persistLinked(); - } - save() { - return this.storage.setItem(c_, this.id), this.storage.setItem(u_, this.secret), this.persistLinked(), this; - } - persistLinked() { - this.storage.setItem(f_, this._linked ? "1" : "0"); - } -} -function xY() { - try { - return window.frameElement !== null; - } catch { - return !1; - } -} -function _Y() { - try { - return xY() && window.top ? window.top.location : window.location; - } catch { - return window.location; - } -} -function EY() { - var t; - return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t = window == null ? void 0 : window.navigator) === null || t === void 0 ? void 0 : t.userAgent); -} -function YE() { - var t, e; - return (e = (t = window == null ? void 0 : window.matchMedia) === null || t === void 0 ? void 0 : t.call(window, "(prefers-color-scheme: dark)").matches) !== null && e !== void 0 ? e : !1; -} -const SY = '@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}'; -function JE() { - const t = document.createElement("style"); - t.type = "text/css", t.appendChild(document.createTextNode(SY)), document.documentElement.appendChild(t); -} -function XE(t) { - var e, r, n = ""; - if (typeof t == "string" || typeof t == "number") n += t; - else if (typeof t == "object") if (Array.isArray(t)) for (e = 0; e < t.length; e++) t[e] && (r = XE(t[e])) && (n && (n += " "), n += r); - else for (e in t) t[e] && (n && (n += " "), n += e); - return n; -} -function Vf() { - for (var t, e, r = 0, n = ""; r < arguments.length; ) (t = arguments[r++]) && (e = XE(t)) && (n && (n += " "), n += e); - return n; -} -var cp, Jr, ZE, ec, l_, QE, F1, eS, bb, B1, U1, Al = {}, tS = [], AY = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, yb = Array.isArray; -function pa(t, e) { - for (var r in e) t[r] = e[r]; - return t; -} -function wb(t) { - t && t.parentNode && t.parentNode.removeChild(t); -} -function Nr(t, e, r) { - var n, i, s, o = {}; - for (s in e) s == "key" ? n = e[s] : s == "ref" ? i = e[s] : o[s] = e[s]; - if (arguments.length > 2 && (o.children = arguments.length > 3 ? cp.call(arguments, 2) : r), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) o[s] === void 0 && (o[s] = t.defaultProps[s]); - return Dd(t, o, n, i, null); -} -function Dd(t, e, r, n, i) { - var s = { type: t, props: e, key: r, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++ZE, __i: -1, __u: 0 }; - return i == null && Jr.vnode != null && Jr.vnode(s), s; -} -function nh(t) { - return t.children; -} -function Od(t, e) { - this.props = t, this.context = e; -} -function Au(t, e) { - if (e == null) return t.__ ? Au(t.__, t.__i + 1) : null; - for (var r; e < t.__k.length; e++) if ((r = t.__k[e]) != null && r.__e != null) return r.__e; - return typeof t.type == "function" ? Au(t) : null; -} -function rS(t) { - var e, r; - if ((t = t.__) != null && t.__c != null) { - for (t.__e = t.__c.base = null, e = 0; e < t.__k.length; e++) if ((r = t.__k[e]) != null && r.__e != null) { - t.__e = t.__c.base = r.__e; - break; - } - return rS(t); - } -} -function h_(t) { - (!t.__d && (t.__d = !0) && ec.push(t) && !h0.__r++ || l_ !== Jr.debounceRendering) && ((l_ = Jr.debounceRendering) || QE)(h0); -} -function h0() { - var t, e, r, n, i, s, o, a; - for (ec.sort(F1); t = ec.shift(); ) t.__d && (e = ec.length, n = void 0, s = (i = (r = t).__v).__e, o = [], a = [], r.__P && ((n = pa({}, i)).__v = i.__v + 1, Jr.vnode && Jr.vnode(n), xb(r.__P, n, i, r.__n, r.__P.namespaceURI, 32 & i.__u ? [s] : null, o, s ?? Au(i), !!(32 & i.__u), a), n.__v = i.__v, n.__.__k[n.__i] = n, sS(o, n, a), n.__e != s && rS(n)), ec.length > e && ec.sort(F1)); - h0.__r = 0; -} -function nS(t, e, r, n, i, s, o, a, u, l, d) { - var g, w, A, M, N, L, F = n && n.__k || tS, $ = e.length; - for (u = PY(r, e, F, u), g = 0; g < $; g++) (A = r.__k[g]) != null && (w = A.__i === -1 ? Al : F[A.__i] || Al, A.__i = g, L = xb(t, A, w, i, s, o, a, u, l, d), M = A.__e, A.ref && w.ref != A.ref && (w.ref && _b(w.ref, null, A), d.push(A.ref, A.__c || M, A)), N == null && M != null && (N = M), 4 & A.__u || w.__k === A.__k ? u = iS(A, u, t) : typeof A.type == "function" && L !== void 0 ? u = L : M && (u = M.nextSibling), A.__u &= -7); - return r.__e = N, u; -} -function PY(t, e, r, n) { - var i, s, o, a, u, l = e.length, d = r.length, g = d, w = 0; - for (t.__k = [], i = 0; i < l; i++) (s = e[i]) != null && typeof s != "boolean" && typeof s != "function" ? (a = i + w, (s = t.__k[i] = typeof s == "string" || typeof s == "number" || typeof s == "bigint" || s.constructor == String ? Dd(null, s, null, null, null) : yb(s) ? Dd(nh, { children: s }, null, null, null) : s.constructor === void 0 && s.__b > 0 ? Dd(s.type, s.props, s.key, s.ref ? s.ref : null, s.__v) : s).__ = t, s.__b = t.__b + 1, o = null, (u = s.__i = MY(s, r, a, g)) !== -1 && (g--, (o = r[u]) && (o.__u |= 2)), o == null || o.__v === null ? (u == -1 && w--, typeof s.type != "function" && (s.__u |= 4)) : u !== a && (u == a - 1 ? w-- : u == a + 1 ? w++ : (u > a ? w-- : w++, s.__u |= 4))) : s = t.__k[i] = null; - if (g) for (i = 0; i < d; i++) (o = r[i]) != null && !(2 & o.__u) && (o.__e == n && (n = Au(o)), oS(o, o)); - return n; -} -function iS(t, e, r) { - var n, i; - if (typeof t.type == "function") { - for (n = t.__k, i = 0; n && i < n.length; i++) n[i] && (n[i].__ = t, e = iS(n[i], e, r)); - return e; - } - t.__e != e && (e && t.type && !r.contains(e) && (e = Au(t)), r.insertBefore(t.__e, e || null), e = t.__e); - do - e = e && e.nextSibling; - while (e != null && e.nodeType === 8); - return e; -} -function MY(t, e, r, n) { - var i = t.key, s = t.type, o = r - 1, a = r + 1, u = e[r]; - if (u === null || u && i == u.key && s === u.type && !(2 & u.__u)) return r; - if ((typeof s != "function" || s === nh || i) && n > (u != null && !(2 & u.__u) ? 1 : 0)) for (; o >= 0 || a < e.length; ) { - if (o >= 0) { - if ((u = e[o]) && !(2 & u.__u) && i == u.key && s === u.type) return o; - o--; - } - if (a < e.length) { - if ((u = e[a]) && !(2 & u.__u) && i == u.key && s === u.type) return a; - a++; - } - } - return -1; -} -function d_(t, e, r) { - e[0] === "-" ? t.setProperty(e, r ?? "") : t[e] = r == null ? "" : typeof r != "number" || AY.test(e) ? r : r + "px"; -} -function dd(t, e, r, n, i) { - var s; - e: if (e === "style") if (typeof r == "string") t.style.cssText = r; - else { - if (typeof n == "string" && (t.style.cssText = n = ""), n) for (e in n) r && e in r || d_(t.style, e, ""); - if (r) for (e in r) n && r[e] === n[e] || d_(t.style, e, r[e]); - } - else if (e[0] === "o" && e[1] === "n") s = e !== (e = e.replace(eS, "$1")), e = e.toLowerCase() in t || e === "onFocusOut" || e === "onFocusIn" ? e.toLowerCase().slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + s] = r, r ? n ? r.u = n.u : (r.u = bb, t.addEventListener(e, s ? U1 : B1, s)) : t.removeEventListener(e, s ? U1 : B1, s); - else { - if (i == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s"); - else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try { - t[e] = r ?? ""; - break e; - } catch { - } - typeof r == "function" || (r == null || r === !1 && e[4] !== "-" ? t.removeAttribute(e) : t.setAttribute(e, e == "popover" && r == 1 ? "" : r)); - } -} -function p_(t) { - return function(e) { - if (this.l) { - var r = this.l[e.type + t]; - if (e.t == null) e.t = bb++; - else if (e.t < r.u) return; - return r(Jr.event ? Jr.event(e) : e); - } - }; -} -function xb(t, e, r, n, i, s, o, a, u, l) { - var d, g, w, A, M, N, L, F, $, K, H, V, te, R, W, pe, Ee, Y = e.type; - if (e.constructor !== void 0) return null; - 128 & r.__u && (u = !!(32 & r.__u), s = [a = e.__e = r.__e]), (d = Jr.__b) && d(e); - e: if (typeof Y == "function") try { - if (F = e.props, $ = "prototype" in Y && Y.prototype.render, K = (d = Y.contextType) && n[d.__c], H = d ? K ? K.props.value : d.__ : n, r.__c ? L = (g = e.__c = r.__c).__ = g.__E : ($ ? e.__c = g = new Y(F, H) : (e.__c = g = new Od(F, H), g.constructor = Y, g.render = CY), K && K.sub(g), g.props = F, g.state || (g.state = {}), g.context = H, g.__n = n, w = g.__d = !0, g.__h = [], g._sb = []), $ && g.__s == null && (g.__s = g.state), $ && Y.getDerivedStateFromProps != null && (g.__s == g.state && (g.__s = pa({}, g.__s)), pa(g.__s, Y.getDerivedStateFromProps(F, g.__s))), A = g.props, M = g.state, g.__v = e, w) $ && Y.getDerivedStateFromProps == null && g.componentWillMount != null && g.componentWillMount(), $ && g.componentDidMount != null && g.__h.push(g.componentDidMount); - else { - if ($ && Y.getDerivedStateFromProps == null && F !== A && g.componentWillReceiveProps != null && g.componentWillReceiveProps(F, H), !g.__e && (g.shouldComponentUpdate != null && g.shouldComponentUpdate(F, g.__s, H) === !1 || e.__v === r.__v)) { - for (e.__v !== r.__v && (g.props = F, g.state = g.__s, g.__d = !1), e.__e = r.__e, e.__k = r.__k, e.__k.some(function(S) { - S && (S.__ = e); - }), V = 0; V < g._sb.length; V++) g.__h.push(g._sb[V]); - g._sb = [], g.__h.length && o.push(g); - break e; - } - g.componentWillUpdate != null && g.componentWillUpdate(F, g.__s, H), $ && g.componentDidUpdate != null && g.__h.push(function() { - g.componentDidUpdate(A, M, N); - }); - } - if (g.context = H, g.props = F, g.__P = t, g.__e = !1, te = Jr.__r, R = 0, $) { - for (g.state = g.__s, g.__d = !1, te && te(e), d = g.render(g.props, g.state, g.context), W = 0; W < g._sb.length; W++) g.__h.push(g._sb[W]); - g._sb = []; - } else do - g.__d = !1, te && te(e), d = g.render(g.props, g.state, g.context), g.state = g.__s; - while (g.__d && ++R < 25); - g.state = g.__s, g.getChildContext != null && (n = pa(pa({}, n), g.getChildContext())), $ && !w && g.getSnapshotBeforeUpdate != null && (N = g.getSnapshotBeforeUpdate(A, M)), a = nS(t, yb(pe = d != null && d.type === nh && d.key == null ? d.props.children : d) ? pe : [pe], e, r, n, i, s, o, a, u, l), g.base = e.__e, e.__u &= -161, g.__h.length && o.push(g), L && (g.__E = g.__ = null); - } catch (S) { - if (e.__v = null, u || s != null) if (S.then) { - for (e.__u |= u ? 160 : 128; a && a.nodeType === 8 && a.nextSibling; ) a = a.nextSibling; - s[s.indexOf(a)] = null, e.__e = a; - } else for (Ee = s.length; Ee--; ) wb(s[Ee]); - else e.__e = r.__e, e.__k = r.__k; - Jr.__e(S, e, r); - } - else s == null && e.__v === r.__v ? (e.__k = r.__k, e.__e = r.__e) : a = e.__e = IY(r.__e, e, r, n, i, s, o, u, l); - return (d = Jr.diffed) && d(e), 128 & e.__u ? void 0 : a; -} -function sS(t, e, r) { - for (var n = 0; n < r.length; n++) _b(r[n], r[++n], r[++n]); - Jr.__c && Jr.__c(e, t), t.some(function(i) { - try { - t = i.__h, i.__h = [], t.some(function(s) { - s.call(i); - }); - } catch (s) { - Jr.__e(s, i.__v); - } - }); -} -function IY(t, e, r, n, i, s, o, a, u) { - var l, d, g, w, A, M, N, L = r.props, F = e.props, $ = e.type; - if ($ === "svg" ? i = "http://www.w3.org/2000/svg" : $ === "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) { - for (l = 0; l < s.length; l++) if ((A = s[l]) && "setAttribute" in A == !!$ && ($ ? A.localName === $ : A.nodeType === 3)) { - t = A, s[l] = null; - break; - } - } - if (t == null) { - if ($ === null) return document.createTextNode(F); - t = document.createElementNS(i, $, F.is && F), a && (Jr.__m && Jr.__m(e, s), a = !1), s = null; - } - if ($ === null) L === F || a && t.data === F || (t.data = F); - else { - if (s = s && cp.call(t.childNodes), L = r.props || Al, !a && s != null) for (L = {}, l = 0; l < t.attributes.length; l++) L[(A = t.attributes[l]).name] = A.value; - for (l in L) if (A = L[l], l != "children") { - if (l == "dangerouslySetInnerHTML") g = A; - else if (!(l in F)) { - if (l == "value" && "defaultValue" in F || l == "checked" && "defaultChecked" in F) continue; - dd(t, l, null, A, i); - } - } - for (l in F) A = F[l], l == "children" ? w = A : l == "dangerouslySetInnerHTML" ? d = A : l == "value" ? M = A : l == "checked" ? N = A : a && typeof A != "function" || L[l] === A || dd(t, l, A, L[l], i); - if (d) a || g && (d.__html === g.__html || d.__html === t.innerHTML) || (t.innerHTML = d.__html), e.__k = []; - else if (g && (t.innerHTML = ""), nS(t, yb(w) ? w : [w], e, r, n, $ === "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, o, s ? s[0] : r.__k && Au(r, 0), a, u), s != null) for (l = s.length; l--; ) wb(s[l]); - a || (l = "value", $ === "progress" && M == null ? t.removeAttribute("value") : M !== void 0 && (M !== t[l] || $ === "progress" && !M || $ === "option" && M !== L[l]) && dd(t, l, M, L[l], i), l = "checked", N !== void 0 && N !== t[l] && dd(t, l, N, L[l], i)); - } - return t; -} -function _b(t, e, r) { - try { - if (typeof t == "function") { - var n = typeof t.__u == "function"; - n && t.__u(), n && e == null || (t.__u = t(e)); - } else t.current = e; - } catch (i) { - Jr.__e(i, r); - } -} -function oS(t, e, r) { - var n, i; - if (Jr.unmount && Jr.unmount(t), (n = t.ref) && (n.current && n.current !== t.__e || _b(n, null, e)), (n = t.__c) != null) { - if (n.componentWillUnmount) try { - n.componentWillUnmount(); - } catch (s) { - Jr.__e(s, e); - } - n.base = n.__P = null; - } - if (n = t.__k) for (i = 0; i < n.length; i++) n[i] && oS(n[i], e, r || typeof t.type != "function"); - r || wb(t.__e), t.__c = t.__ = t.__e = void 0; -} -function CY(t, e, r) { - return this.constructor(t, r); -} -function j1(t, e, r) { - var n, i, s, o; - e === document && (e = document.documentElement), Jr.__ && Jr.__(t, e), i = (n = typeof r == "function") ? null : e.__k, s = [], o = [], xb(e, t = (!n && r || e).__k = Nr(nh, null, [t]), i || Al, Al, e.namespaceURI, !n && r ? [r] : i ? null : e.firstChild ? cp.call(e.childNodes) : null, s, !n && r ? r : i ? i.__e : e.firstChild, n, o), sS(s, t, o); -} -cp = tS.slice, Jr = { __e: function(t, e, r, n) { - for (var i, s, o; e = e.__; ) if ((i = e.__c) && !i.__) try { - if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(t, n || {}), o = i.__d), o) return i.__E = i; - } catch (a) { - t = a; - } - throw t; -} }, ZE = 0, Od.prototype.setState = function(t, e) { - var r; - r = this.__s != null && this.__s !== this.state ? this.__s : this.__s = pa({}, this.state), typeof t == "function" && (t = t(pa({}, r), this.props)), t && pa(r, t), t != null && this.__v && (e && this._sb.push(e), h_(this)); -}, Od.prototype.forceUpdate = function(t) { - this.__v && (this.__e = !0, t && this.__h.push(t), h_(this)); -}, Od.prototype.render = nh, ec = [], QE = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, F1 = function(t, e) { - return t.__v.__b - e.__v.__b; -}, h0.__r = 0, eS = /(PointerCapture)$|Capture$/i, bb = 0, B1 = p_(!1), U1 = p_(!0); -var d0, pn, Mm, g_, q1 = 0, aS = [], yn = Jr, m_ = yn.__b, v_ = yn.__r, b_ = yn.diffed, y_ = yn.__c, w_ = yn.unmount, x_ = yn.__; -function cS(t, e) { - yn.__h && yn.__h(pn, t, q1 || e), q1 = 0; - var r = pn.__H || (pn.__H = { __: [], __h: [] }); - return t >= r.__.length && r.__.push({}), r.__[t]; -} -function __(t) { - return q1 = 1, TY(uS, t); -} -function TY(t, e, r) { - var n = cS(d0++, 2); - if (n.t = t, !n.__c && (n.__ = [uS(void 0, e), function(a) { - var u = n.__N ? n.__N[0] : n.__[0], l = n.t(u, a); - u !== l && (n.__N = [l, n.__[1]], n.__c.setState({})); - }], n.__c = pn, !pn.u)) { - var i = function(a, u, l) { - if (!n.__c.__H) return !0; - var d = n.__c.__H.__.filter(function(w) { - return !!w.__c; - }); - if (d.every(function(w) { - return !w.__N; - })) return !s || s.call(this, a, u, l); - var g = n.__c.props !== a; - return d.forEach(function(w) { - if (w.__N) { - var A = w.__[0]; - w.__ = w.__N, w.__N = void 0, A !== w.__[0] && (g = !0); - } - }), s && s.call(this, a, u, l) || g; - }; - pn.u = !0; - var s = pn.shouldComponentUpdate, o = pn.componentWillUpdate; - pn.componentWillUpdate = function(a, u, l) { - if (this.__e) { - var d = s; - s = void 0, i(a, u, l), s = d; - } - o && o.call(this, a, u, l); - }, pn.shouldComponentUpdate = i; - } - return n.__N || n.__; -} -function RY(t, e) { - var r = cS(d0++, 3); - !yn.__s && NY(r.__H, e) && (r.__ = t, r.i = e, pn.__H.__h.push(r)); -} -function DY() { - for (var t; t = aS.shift(); ) if (t.__P && t.__H) try { - t.__H.__h.forEach(Nd), t.__H.__h.forEach(z1), t.__H.__h = []; - } catch (e) { - t.__H.__h = [], yn.__e(e, t.__v); - } -} -yn.__b = function(t) { - pn = null, m_ && m_(t); -}, yn.__ = function(t, e) { - t && e.__k && e.__k.__m && (t.__m = e.__k.__m), x_ && x_(t, e); -}, yn.__r = function(t) { - v_ && v_(t), d0 = 0; - var e = (pn = t.__c).__H; - e && (Mm === pn ? (e.__h = [], pn.__h = [], e.__.forEach(function(r) { - r.__N && (r.__ = r.__N), r.i = r.__N = void 0; - })) : (e.__h.forEach(Nd), e.__h.forEach(z1), e.__h = [], d0 = 0)), Mm = pn; -}, yn.diffed = function(t) { - b_ && b_(t); - var e = t.__c; - e && e.__H && (e.__H.__h.length && (aS.push(e) !== 1 && g_ === yn.requestAnimationFrame || ((g_ = yn.requestAnimationFrame) || OY)(DY)), e.__H.__.forEach(function(r) { - r.i && (r.__H = r.i), r.i = void 0; - })), Mm = pn = null; -}, yn.__c = function(t, e) { - e.some(function(r) { - try { - r.__h.forEach(Nd), r.__h = r.__h.filter(function(n) { - return !n.__ || z1(n); - }); - } catch (n) { - e.some(function(i) { - i.__h && (i.__h = []); - }), e = [], yn.__e(n, r.__v); - } - }), y_ && y_(t, e); -}, yn.unmount = function(t) { - w_ && w_(t); - var e, r = t.__c; - r && r.__H && (r.__H.__.forEach(function(n) { - try { - Nd(n); - } catch (i) { - e = i; - } - }), r.__H = void 0, e && yn.__e(e, r.__v)); -}; -var E_ = typeof requestAnimationFrame == "function"; -function OY(t) { - var e, r = function() { - clearTimeout(n), E_ && cancelAnimationFrame(e), setTimeout(t); - }, n = setTimeout(r, 100); - E_ && (e = requestAnimationFrame(r)); -} -function Nd(t) { - var e = pn, r = t.__c; - typeof r == "function" && (t.__c = void 0, r()), pn = e; -} -function z1(t) { - var e = pn; - t.__c = t.__(), pn = e; -} -function NY(t, e) { - return !t || t.length !== e.length || e.some(function(r, n) { - return r !== t[n]; - }); -} -function uS(t, e) { - return typeof e == "function" ? e(t) : e; -} -const LY = ".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}", kY = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+", $Y = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4="; -class FY { - constructor() { - this.items = /* @__PURE__ */ new Map(), this.nextItemKey = 0, this.root = null, this.darkMode = YE(); - } - attach(e) { - this.root = document.createElement("div"), this.root.className = "-cbwsdk-snackbar-root", e.appendChild(this.root), this.render(); - } - presentItem(e) { - const r = this.nextItemKey++; - return this.items.set(r, e), this.render(), () => { - this.items.delete(r), this.render(); - }; - } - clear() { - this.items.clear(), this.render(); - } - render() { - this.root && j1(Nr( - "div", - null, - Nr(fS, { darkMode: this.darkMode }, Array.from(this.items.entries()).map(([e, r]) => Nr(BY, Object.assign({}, r, { key: e })))) - ), this.root); - } -} -const fS = (t) => Nr( - "div", - { class: Vf("-cbwsdk-snackbar-container") }, - Nr("style", null, LY), - Nr("div", { class: "-cbwsdk-snackbar" }, t.children) -), BY = ({ autoExpand: t, message: e, menuItems: r }) => { - const [n, i] = __(!0), [s, o] = __(t ?? !1); - RY(() => { - const u = [ - window.setTimeout(() => { - i(!1); - }, 1), - window.setTimeout(() => { - o(!0); - }, 1e4) - ]; - return () => { - u.forEach(window.clearTimeout); - }; - }); - const a = () => { - o(!s); - }; - return Nr( - "div", - { class: Vf("-cbwsdk-snackbar-instance", n && "-cbwsdk-snackbar-instance-hidden", s && "-cbwsdk-snackbar-instance-expanded") }, - Nr( - "div", - { class: "-cbwsdk-snackbar-instance-header", onClick: a }, - Nr("img", { src: kY, class: "-cbwsdk-snackbar-instance-header-cblogo" }), - " ", - Nr("div", { class: "-cbwsdk-snackbar-instance-header-message" }, e), - Nr( - "div", - { class: "-gear-container" }, - !s && Nr( - "svg", - { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, - Nr("circle", { cx: "12", cy: "12", r: "12", fill: "#F5F7F8" }) - ), - Nr("img", { src: $Y, class: "-gear-icon", title: "Expand" }) - ) - ), - r && r.length > 0 && Nr("div", { class: "-cbwsdk-snackbar-instance-menu" }, r.map((u, l) => Nr( - "div", - { class: Vf("-cbwsdk-snackbar-instance-menu-item", u.isRed && "-cbwsdk-snackbar-instance-menu-item-is-red"), onClick: u.onClick, key: l }, - Nr( - "svg", - { width: u.svgWidth, height: u.svgHeight, viewBox: "0 0 10 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, - Nr("path", { "fill-rule": u.defaultFillRule, "clip-rule": u.defaultClipRule, d: u.path, fill: "#AAAAAA" }) - ), - Nr("span", { class: Vf("-cbwsdk-snackbar-instance-menu-item-info", u.isRed && "-cbwsdk-snackbar-instance-menu-item-info-is-red") }, u.info) - ))) - ); -}; -class UY { - constructor() { - this.attached = !1, this.snackbar = new FY(); - } - attach() { - if (this.attached) - throw new Error("Coinbase Wallet SDK UI is already attached"); - const e = document.documentElement, r = document.createElement("div"); - r.className = "-cbwsdk-css-reset", e.appendChild(r), this.snackbar.attach(r), this.attached = !0, JE(); - } - showConnecting(e) { - let r; - return e.isUnlinkedErrorState ? r = { - autoExpand: !0, - message: "Connection lost", - menuItems: [ - { - isRed: !1, - info: "Reset connection", - svgWidth: "10", - svgHeight: "11", - path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z", - defaultFillRule: "evenodd", - defaultClipRule: "evenodd", - onClick: e.onResetConnection - } - ] - } : r = { - message: "Confirm on phone", - menuItems: [ - { - isRed: !0, - info: "Cancel transaction", - svgWidth: "11", - svgHeight: "11", - path: "M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z", - defaultFillRule: "inherit", - defaultClipRule: "inherit", - onClick: e.onCancel - }, - { - isRed: !1, - info: "Reset connection", - svgWidth: "10", - svgHeight: "11", - path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z", - defaultFillRule: "evenodd", - defaultClipRule: "evenodd", - onClick: e.onResetConnection - } - ] - }, this.snackbar.presentItem(r); - } -} -const jY = ".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}"; -class qY { - constructor() { - this.root = null, this.darkMode = YE(); - } - attach() { - const e = document.documentElement; - this.root = document.createElement("div"), this.root.className = "-cbwsdk-css-reset", e.appendChild(this.root), JE(); - } - present(e) { - this.render(e); - } - clear() { - this.render(null); - } - render(e) { - this.root && (j1(null, this.root), e && j1(Nr(zY, Object.assign({}, e, { onDismiss: () => { - this.clear(); - }, darkMode: this.darkMode })), this.root)); - } -} -const zY = ({ title: t, buttonText: e, darkMode: r, onButtonClick: n, onDismiss: i }) => { - const s = r ? "dark" : "light"; - return Nr( - fS, - { darkMode: r }, - Nr( - "div", - { class: "-cbwsdk-redirect-dialog" }, - Nr("style", null, jY), - Nr("div", { class: "-cbwsdk-redirect-dialog-backdrop", onClick: i }), - Nr( - "div", - { class: Vf("-cbwsdk-redirect-dialog-box", s) }, - Nr("p", null, t), - Nr("button", { onClick: n }, e) - ) - ) - ); -}, HY = "https://keys.coinbase.com/connect", S_ = "https://www.walletlink.org", WY = "https://go.cb-w.com/walletlink"; -class A_ { - constructor() { - this.attached = !1, this.redirectDialog = new qY(); - } - attach() { - if (this.attached) - throw new Error("Coinbase Wallet SDK UI is already attached"); - this.redirectDialog.attach(), this.attached = !0; - } - redirectToCoinbaseWallet(e) { - const r = new URL(WY); - r.searchParams.append("redirect_url", _Y().href), e && r.searchParams.append("wl_url", e); - const n = document.createElement("a"); - n.target = "cbw-opener", n.href = r.href, n.rel = "noreferrer noopener", n.click(); - } - openCoinbaseWalletDeeplink(e) { - this.redirectDialog.present({ - title: "Redirecting to Coinbase Wallet...", - buttonText: "Open", - onButtonClick: () => { - this.redirectToCoinbaseWallet(e); - } - }), setTimeout(() => { - this.redirectToCoinbaseWallet(e); - }, 99); - } - showConnecting(e) { - return () => { - this.redirectDialog.clear(); - }; - } -} -class _o { - constructor(e) { - this.chainCallbackParams = { chainId: "", jsonRpcUrl: "" }, this.isMobileWeb = EY(), this.linkedUpdated = (s) => { - this.isLinked = s; - const o = this.storage.getItem($1); - if (s && (this._session.linked = s), this.isUnlinkedErrorState = !1, o) { - const a = o.split(" "), u = this.storage.getItem("IsStandaloneSigning") === "true"; - a[0] !== "" && !s && this._session.linked && !u && (this.isUnlinkedErrorState = !0); - } - }, this.metadataUpdated = (s, o) => { - this.storage.setItem(s, o); - }, this.chainUpdated = (s, o) => { - this.chainCallbackParams.chainId === s && this.chainCallbackParams.jsonRpcUrl === o || (this.chainCallbackParams = { - chainId: s, - jsonRpcUrl: o - }, this.chainCallback && this.chainCallback(o, Number.parseInt(s, 10))); - }, this.accountUpdated = (s) => { - this.accountsCallback && this.accountsCallback([s]), _o.accountRequestCallbackIds.size > 0 && (Array.from(_o.accountRequestCallbackIds.values()).forEach((o) => { - this.invokeCallback(o, { - method: "requestEthereumAccounts", - result: [s] - }); - }), _o.accountRequestCallbackIds.clear()); - }, this.resetAndReload = this.resetAndReload.bind(this), this.linkAPIUrl = e.linkAPIUrl, this.storage = e.storage, this.metadata = e.metadata, this.accountsCallback = e.accountsCallback, this.chainCallback = e.chainCallback; - const { session: r, ui: n, connection: i } = this.subscribe(); - this._session = r, this.connection = i, this.relayEventManager = new wY(), this.ui = n, this.ui.attach(); - } - subscribe() { - const e = pu.load(this.storage) || pu.create(this.storage), { linkAPIUrl: r } = this, n = new yY({ - session: e, - linkAPIUrl: r, - listener: this - }), i = this.isMobileWeb ? new A_() : new UY(); - return n.connect(), { session: e, ui: i, connection: n }; - } - resetAndReload() { - this.connection.destroy().then(() => { - const e = pu.load(this.storage); - (e == null ? void 0 : e.id) === this._session.id && Qs.clearAll(), document.location.reload(); - }).catch((e) => { - }); - } - signEthereumTransaction(e) { - return this.sendRequest({ - method: "signEthereumTransaction", - params: { - fromAddress: e.fromAddress, - toAddress: e.toAddress, - weiValue: ks(e.weiValue), - data: Hf(e.data, !0), - nonce: e.nonce, - gasPriceInWei: e.gasPriceInWei ? ks(e.gasPriceInWei) : null, - maxFeePerGas: e.gasPriceInWei ? ks(e.gasPriceInWei) : null, - maxPriorityFeePerGas: e.gasPriceInWei ? ks(e.gasPriceInWei) : null, - gasLimit: e.gasLimit ? ks(e.gasLimit) : null, - chainId: e.chainId, - shouldSubmit: !1 - } - }); - } - signAndSubmitEthereumTransaction(e) { - return this.sendRequest({ - method: "signEthereumTransaction", - params: { - fromAddress: e.fromAddress, - toAddress: e.toAddress, - weiValue: ks(e.weiValue), - data: Hf(e.data, !0), - nonce: e.nonce, - gasPriceInWei: e.gasPriceInWei ? ks(e.gasPriceInWei) : null, - maxFeePerGas: e.maxFeePerGas ? ks(e.maxFeePerGas) : null, - maxPriorityFeePerGas: e.maxPriorityFeePerGas ? ks(e.maxPriorityFeePerGas) : null, - gasLimit: e.gasLimit ? ks(e.gasLimit) : null, - chainId: e.chainId, - shouldSubmit: !0 - } - }); - } - submitEthereumTransaction(e, r) { - return this.sendRequest({ - method: "submitEthereumTransaction", - params: { - signedTransaction: Hf(e, !0), - chainId: r - } - }); - } - getWalletLinkSession() { - return this._session; - } - sendRequest(e) { - let r = null; - const n = Za(8), i = (s) => { - this.publishWeb3RequestCanceledEvent(n), this.handleErrorResponse(n, e.method, s), r == null || r(); - }; - return new Promise((s, o) => { - r = this.ui.showConnecting({ - isUnlinkedErrorState: this.isUnlinkedErrorState, - onCancel: i, - onResetConnection: this.resetAndReload - // eslint-disable-line @typescript-eslint/unbound-method - }), this.relayEventManager.callbacks.set(n, (a) => { - if (r == null || r(), Bn(a)) - return o(new Error(a.errorMessage)); - s(a); - }), this.publishWeb3RequestEvent(n, e); - }); - } - publishWeb3RequestEvent(e, r) { - const n = { type: "WEB3_REQUEST", id: e, request: r }; - this.publishEvent("Web3Request", n, !0).then((i) => { - }).catch((i) => { - this.handleWeb3ResponseMessage(n.id, { - method: r.method, - errorMessage: i.message - }); - }), this.isMobileWeb && this.openCoinbaseWalletDeeplink(r.method); - } - // copied from MobileRelay - openCoinbaseWalletDeeplink(e) { - if (this.ui instanceof A_) - switch (e) { - case "requestEthereumAccounts": - case "switchEthereumChain": - return; - default: - window.addEventListener("blur", () => { - window.addEventListener("focus", () => { - this.connection.checkUnseenEvents(); - }, { once: !0 }); - }, { once: !0 }), this.ui.openCoinbaseWalletDeeplink(); - break; - } - } - publishWeb3RequestCanceledEvent(e) { - const r = { - type: "WEB3_REQUEST_CANCELED", - id: e - }; - this.publishEvent("Web3RequestCanceled", r, !1).then(); - } - publishEvent(e, r, n) { - return this.connection.publishEvent(e, r, n); - } - handleWeb3ResponseMessage(e, r) { - if (r.method === "requestEthereumAccounts") { - _o.accountRequestCallbackIds.forEach((n) => this.invokeCallback(n, r)), _o.accountRequestCallbackIds.clear(); - return; - } - this.invokeCallback(e, r); - } - handleErrorResponse(e, r, n) { - var i; - const s = (i = n == null ? void 0 : n.message) !== null && i !== void 0 ? i : "Unspecified error message."; - this.handleWeb3ResponseMessage(e, { - method: r, - errorMessage: s - }); - } - invokeCallback(e, r) { - const n = this.relayEventManager.callbacks.get(e); - n && (n(r), this.relayEventManager.callbacks.delete(e)); - } - requestEthereumAccounts() { - const { appName: e, appLogoUrl: r } = this.metadata, n = { - method: "requestEthereumAccounts", - params: { - appName: e, - appLogoUrl: r - } - }, i = Za(8); - return new Promise((s, o) => { - this.relayEventManager.callbacks.set(i, (a) => { - if (Bn(a)) - return o(new Error(a.errorMessage)); - s(a); - }), _o.accountRequestCallbackIds.add(i), this.publishWeb3RequestEvent(i, n); - }); - } - watchAsset(e, r, n, i, s, o) { - const a = { - method: "watchAsset", - params: { - type: e, - options: { - address: r, - symbol: n, - decimals: i, - image: s - }, - chainId: o - } - }; - let u = null; - const l = Za(8), d = (g) => { - this.publishWeb3RequestCanceledEvent(l), this.handleErrorResponse(l, a.method, g), u == null || u(); - }; - return u = this.ui.showConnecting({ - isUnlinkedErrorState: this.isUnlinkedErrorState, - onCancel: d, - onResetConnection: this.resetAndReload - // eslint-disable-line @typescript-eslint/unbound-method - }), new Promise((g, w) => { - this.relayEventManager.callbacks.set(l, (A) => { - if (u == null || u(), Bn(A)) - return w(new Error(A.errorMessage)); - g(A); - }), this.publishWeb3RequestEvent(l, a); - }); - } - addEthereumChain(e, r, n, i, s, o) { - const a = { - method: "addEthereumChain", - params: { - chainId: e, - rpcUrls: r, - blockExplorerUrls: i, - chainName: s, - iconUrls: n, - nativeCurrency: o - } - }; - let u = null; - const l = Za(8), d = (g) => { - this.publishWeb3RequestCanceledEvent(l), this.handleErrorResponse(l, a.method, g), u == null || u(); - }; - return u = this.ui.showConnecting({ - isUnlinkedErrorState: this.isUnlinkedErrorState, - onCancel: d, - onResetConnection: this.resetAndReload - // eslint-disable-line @typescript-eslint/unbound-method - }), new Promise((g, w) => { - this.relayEventManager.callbacks.set(l, (A) => { - if (u == null || u(), Bn(A)) - return w(new Error(A.errorMessage)); - g(A); - }), this.publishWeb3RequestEvent(l, a); - }); - } - switchEthereumChain(e, r) { - const n = { - method: "switchEthereumChain", - params: Object.assign({ chainId: e }, { address: r }) - }; - let i = null; - const s = Za(8), o = (a) => { - this.publishWeb3RequestCanceledEvent(s), this.handleErrorResponse(s, n.method, a), i == null || i(); - }; - return i = this.ui.showConnecting({ - isUnlinkedErrorState: this.isUnlinkedErrorState, - onCancel: o, - onResetConnection: this.resetAndReload - // eslint-disable-line @typescript-eslint/unbound-method - }), new Promise((a, u) => { - this.relayEventManager.callbacks.set(s, (l) => { - if (i == null || i(), Bn(l) && l.errorCode) - return u(Sr.provider.custom({ - code: l.errorCode, - message: "Unrecognized chain ID. Try adding the chain using addEthereumChain first." - })); - if (Bn(l)) - return u(new Error(l.errorMessage)); - a(l); - }), this.publishWeb3RequestEvent(s, n); - }); - } -} -_o.accountRequestCallbackIds = /* @__PURE__ */ new Set(); -const P_ = "DefaultChainId", M_ = "DefaultJsonRpcUrl"; -class lS { - constructor(e) { - this._relay = null, this._addresses = [], this.metadata = e.metadata, this._storage = new Qs("walletlink", S_), this.callback = e.callback || null; - const r = this._storage.getItem($1); - if (r) { - const n = r.split(" "); - n[0] !== "" && (this._addresses = n.map((i) => ta(i))); - } - this.initializeRelay(); - } - getSession() { - const e = this.initializeRelay(), { id: r, secret: n } = e.getWalletLinkSession(); - return { id: r, secret: n }; - } - async handshake() { - await this._eth_requestAccounts(); - } - get selectedAddress() { - return this._addresses[0] || void 0; - } - get jsonRpcUrl() { - var e; - return (e = this._storage.getItem(M_)) !== null && e !== void 0 ? e : void 0; - } - set jsonRpcUrl(e) { - this._storage.setItem(M_, e); - } - updateProviderInfo(e, r) { - var n; - this.jsonRpcUrl = e; - const i = this.getChainId(); - this._storage.setItem(P_, r.toString(10)), Wf(r) !== i && ((n = this.callback) === null || n === void 0 || n.call(this, "chainChanged", da(r))); - } - async watchAsset(e) { - const r = Array.isArray(e) ? e[0] : e; - if (!r.type) - throw Sr.rpc.invalidParams("Type is required"); - if ((r == null ? void 0 : r.type) !== "ERC20") - throw Sr.rpc.invalidParams(`Asset of type '${r.type}' is not supported`); - if (!(r != null && r.options)) - throw Sr.rpc.invalidParams("Options are required"); - if (!(r != null && r.options.address)) - throw Sr.rpc.invalidParams("Address is required"); - const n = this.getChainId(), { address: i, symbol: s, image: o, decimals: a } = r.options, l = await this.initializeRelay().watchAsset(r.type, i, s, a, o, n == null ? void 0 : n.toString()); - return Bn(l) ? !1 : !!l.result; - } - async addEthereumChain(e) { - var r, n; - const i = e[0]; - if (((r = i.rpcUrls) === null || r === void 0 ? void 0 : r.length) === 0) - throw Sr.rpc.invalidParams("please pass in at least 1 rpcUrl"); - if (!i.chainName || i.chainName.trim() === "") - throw Sr.rpc.invalidParams("chainName is a required field"); - if (!i.nativeCurrency) - throw Sr.rpc.invalidParams("nativeCurrency is a required field"); - const s = Number.parseInt(i.chainId, 16); - if (s === this.getChainId()) - return !1; - const o = this.initializeRelay(), { rpcUrls: a = [], blockExplorerUrls: u = [], chainName: l, iconUrls: d = [], nativeCurrency: g } = i, w = await o.addEthereumChain(s.toString(), a, d, u, l, g); - if (Bn(w)) - return !1; - if (((n = w.result) === null || n === void 0 ? void 0 : n.isApproved) === !0) - return this.updateProviderInfo(a[0], s), null; - throw Sr.rpc.internal("unable to add ethereum chain"); - } - async switchEthereumChain(e) { - const r = e[0], n = Number.parseInt(r.chainId, 16), s = await this.initializeRelay().switchEthereumChain(n.toString(10), this.selectedAddress || void 0); - if (Bn(s)) - throw s; - const o = s.result; - return o.isApproved && o.rpcUrl.length > 0 && this.updateProviderInfo(o.rpcUrl, n), null; - } - async cleanup() { - this.callback = null, this._relay && this._relay.resetAndReload(), this._storage.clear(); - } - _setAddresses(e, r) { - var n; - if (!Array.isArray(e)) - throw new Error("addresses is not an array"); - const i = e.map((s) => ta(s)); - JSON.stringify(i) !== JSON.stringify(this._addresses) && (this._addresses = i, (n = this.callback) === null || n === void 0 || n.call(this, "accountsChanged", i), this._storage.setItem($1, i.join(" "))); - } - async request(e) { - const r = e.params || []; - switch (e.method) { - case "eth_accounts": - return [...this._addresses]; - case "eth_coinbase": - return this.selectedAddress || null; - case "net_version": - return this.getChainId().toString(10); - case "eth_chainId": - return da(this.getChainId()); - case "eth_requestAccounts": - return this._eth_requestAccounts(); - case "eth_ecRecover": - case "personal_ecRecover": - return this.ecRecover(e); - case "personal_sign": - return this.personalSign(e); - case "eth_signTransaction": - return this._eth_signTransaction(r); - case "eth_sendRawTransaction": - return this._eth_sendRawTransaction(r); - case "eth_sendTransaction": - return this._eth_sendTransaction(r); - case "eth_signTypedData_v1": - case "eth_signTypedData_v3": - case "eth_signTypedData_v4": - case "eth_signTypedData": - return this.signTypedData(e); - case "wallet_addEthereumChain": - return this.addEthereumChain(r); - case "wallet_switchEthereumChain": - return this.switchEthereumChain(r); - case "wallet_watchAsset": - return this.watchAsset(r); - default: - if (!this.jsonRpcUrl) - throw Sr.rpc.internal("No RPC URL set for chain"); - return FE(e, this.jsonRpcUrl); - } - } - _ensureKnownAddress(e) { - const r = ta(e); - if (!this._addresses.map((i) => ta(i)).includes(r)) - throw new Error("Unknown Ethereum address"); - } - _prepareTransactionParams(e) { - const r = e.from ? ta(e.from) : this.selectedAddress; - if (!r) - throw new Error("Ethereum address is unavailable"); - this._ensureKnownAddress(r); - const n = e.to ? ta(e.to) : null, i = e.value != null ? Tf(e.value) : BigInt(0), s = e.data ? k1(e.data) : Buffer.alloc(0), o = e.nonce != null ? Wf(e.nonce) : null, a = e.gasPrice != null ? Tf(e.gasPrice) : null, u = e.maxFeePerGas != null ? Tf(e.maxFeePerGas) : null, l = e.maxPriorityFeePerGas != null ? Tf(e.maxPriorityFeePerGas) : null, d = e.gas != null ? Tf(e.gas) : null, g = e.chainId ? Wf(e.chainId) : this.getChainId(); - return { - fromAddress: r, - toAddress: n, - weiValue: i, - data: s, - nonce: o, - gasPriceInWei: a, - maxFeePerGas: u, - maxPriorityFeePerGas: l, - gasLimit: d, - chainId: g - }; - } - async ecRecover(e) { - const { method: r, params: n } = e; - if (!Array.isArray(n)) - throw Sr.rpc.invalidParams(); - const s = await this.initializeRelay().sendRequest({ - method: "ethereumAddressFromSignedMessage", - params: { - message: _m(n[0]), - signature: _m(n[1]), - addPrefix: r === "personal_ecRecover" - } - }); - if (Bn(s)) - throw s; - return s.result; - } - getChainId() { - var e; - return Number.parseInt((e = this._storage.getItem(P_)) !== null && e !== void 0 ? e : "1", 10); - } - async _eth_requestAccounts() { - var e, r; - if (this._addresses.length > 0) - return (e = this.callback) === null || e === void 0 || e.call(this, "connect", { chainId: da(this.getChainId()) }), this._addresses; - const i = await this.initializeRelay().requestEthereumAccounts(); - if (Bn(i)) - throw i; - if (!i.result) - throw new Error("accounts received is empty"); - return this._setAddresses(i.result), (r = this.callback) === null || r === void 0 || r.call(this, "connect", { chainId: da(this.getChainId()) }), this._addresses; - } - async personalSign({ params: e }) { - if (!Array.isArray(e)) - throw Sr.rpc.invalidParams(); - const r = e[1], n = e[0]; - this._ensureKnownAddress(r); - const s = await this.initializeRelay().sendRequest({ - method: "signEthereumMessage", - params: { - address: ta(r), - message: _m(n), - addPrefix: !0, - typedDataJson: null - } - }); - if (Bn(s)) - throw s; - return s.result; - } - async _eth_signTransaction(e) { - const r = this._prepareTransactionParams(e[0] || {}), i = await this.initializeRelay().signEthereumTransaction(r); - if (Bn(i)) - throw i; - return i.result; - } - async _eth_sendRawTransaction(e) { - const r = k1(e[0]), i = await this.initializeRelay().submitEthereumTransaction(r, this.getChainId()); - if (Bn(i)) - throw i; - return i.result; - } - async _eth_sendTransaction(e) { - const r = this._prepareTransactionParams(e[0] || {}), i = await this.initializeRelay().signAndSubmitEthereumTransaction(r); - if (Bn(i)) - throw i; - return i.result; - } - async signTypedData(e) { - const { method: r, params: n } = e; - if (!Array.isArray(n)) - throw Sr.rpc.invalidParams(); - const i = (l) => { - const d = { - eth_signTypedData_v1: hd.hashForSignTypedDataLegacy, - eth_signTypedData_v3: hd.hashForSignTypedData_v3, - eth_signTypedData_v4: hd.hashForSignTypedData_v4, - eth_signTypedData: hd.hashForSignTypedData_v4 - }; - return Hf(d[r]({ - data: FG(l) - }), !0); - }, s = n[r === "eth_signTypedData_v1" ? 1 : 0], o = n[r === "eth_signTypedData_v1" ? 0 : 1]; - this._ensureKnownAddress(s); - const u = await this.initializeRelay().sendRequest({ - method: "signEthereumMessage", - params: { - address: ta(s), - message: i(o), - typedDataJson: JSON.stringify(o, null, 2), - addPrefix: !1 - } - }); - if (Bn(u)) - throw u; - return u.result; - } - initializeRelay() { - return this._relay || (this._relay = new _o({ - linkAPIUrl: S_, - storage: this._storage, - metadata: this.metadata, - accountsCallback: this._setAddresses.bind(this), - chainCallback: this.updateProviderInfo.bind(this) - })), this._relay; - } -} -const hS = "SignerType", dS = new Qs("CBWSDK", "SignerConfigurator"); -function KY() { - return dS.getItem(hS); -} -function VY(t) { - dS.setItem(hS, t); -} -async function GY(t) { - const { communicator: e, metadata: r, handshakeRequest: n, callback: i } = t; - JY(e, r, i).catch(() => { - }); - const s = { - id: crypto.randomUUID(), - event: "selectSignerType", - data: Object.assign(Object.assign({}, t.preference), { handshakeRequest: n }) - }, { data: o } = await e.postRequestAndWaitForResponse(s); - return o; -} -function YY(t) { - const { signerType: e, metadata: r, communicator: n, callback: i } = t; - switch (e) { - case "scw": - return new XG({ - metadata: r, - callback: i, - communicator: n - }); - case "walletlink": - return new lS({ - metadata: r, - callback: i - }); - } -} -async function JY(t, e, r) { - await t.onMessage(({ event: i }) => i === "WalletLinkSessionRequest"); - const n = new lS({ - metadata: e, - callback: r - }); - t.postMessage({ - event: "WalletLinkUpdate", - data: { session: n.getSession() } - }), await n.handshake(), t.postMessage({ - event: "WalletLinkUpdate", - data: { connected: !0 } - }); -} -const XY = `Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app. - -Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`, ZY = () => { - let t; - return { - getCrossOriginOpenerPolicy: () => t === void 0 ? "undefined" : t, - checkCrossOriginOpenerPolicy: async () => { - if (typeof window > "u") { - t = "non-browser-env"; - return; - } - try { - const e = `${window.location.origin}${window.location.pathname}`, r = await fetch(e, { - method: "HEAD" - }); - if (!r.ok) - throw new Error(`HTTP error! status: ${r.status}`); - const n = r.headers.get("Cross-Origin-Opener-Policy"); - t = n ?? "null", t === "same-origin" && console.error(XY); - } catch (e) { - console.error("Error checking Cross-Origin-Opener-Policy:", e.message), t = "error"; - } - } - }; -}, { checkCrossOriginOpenerPolicy: QY, getCrossOriginOpenerPolicy: eJ } = ZY(), I_ = 420, C_ = 540; -function tJ(t) { - const e = (window.innerWidth - I_) / 2 + window.screenX, r = (window.innerHeight - C_) / 2 + window.screenY; - nJ(t); - const n = window.open(t, "Smart Wallet", `width=${I_}, height=${C_}, left=${e}, top=${r}`); - if (n == null || n.focus(), !n) - throw Sr.rpc.internal("Pop up window failed to open"); - return n; -} -function rJ(t) { - t && !t.closed && t.close(); -} -function nJ(t) { - const e = { - sdkName: $E, - sdkVersion: rh, - origin: window.location.origin, - coop: eJ() - }; - for (const [r, n] of Object.entries(e)) - t.searchParams.append(r, n.toString()); -} -class iJ { - constructor({ url: e = HY, metadata: r, preference: n }) { - this.popup = null, this.listeners = /* @__PURE__ */ new Map(), this.postMessage = async (i) => { - (await this.waitForPopupLoaded()).postMessage(i, this.url.origin); - }, this.postRequestAndWaitForResponse = async (i) => { - const s = this.onMessage(({ requestId: o }) => o === i.id); - return this.postMessage(i), await s; - }, this.onMessage = async (i) => new Promise((s, o) => { - const a = (u) => { - if (u.origin !== this.url.origin) - return; - const l = u.data; - i(l) && (s(l), window.removeEventListener("message", a), this.listeners.delete(a)); - }; - window.addEventListener("message", a), this.listeners.set(a, { reject: o }); - }), this.disconnect = () => { - rJ(this.popup), this.popup = null, this.listeners.forEach(({ reject: i }, s) => { - i(Sr.provider.userRejectedRequest("Request rejected")), window.removeEventListener("message", s); - }), this.listeners.clear(); - }, this.waitForPopupLoaded = async () => this.popup && !this.popup.closed ? (this.popup.focus(), this.popup) : (this.popup = tJ(this.url), this.onMessage(({ event: i }) => i === "PopupUnload").then(this.disconnect).catch(() => { - }), this.onMessage(({ event: i }) => i === "PopupLoaded").then((i) => { - this.postMessage({ - requestId: i.id, - data: { - version: rh, - metadata: this.metadata, - preference: this.preference, - location: window.location.toString() - } - }); - }).then(() => { - if (!this.popup) - throw Sr.rpc.internal(); - return this.popup; - })), this.url = new URL(e), this.metadata = r, this.preference = n; - } -} -function sJ(t) { - const e = OG(oJ(t), { - shouldIncludeStack: !0 - }), r = new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors"); - return r.searchParams.set("version", rh), r.searchParams.set("code", e.code.toString()), r.searchParams.set("message", e.message), Object.assign(Object.assign({}, e), { docUrl: r.href }); -} -function oJ(t) { - var e; - if (typeof t == "string") - return { - message: t, - code: fn.rpc.internal - }; - if (Bn(t)) { - const r = t.errorMessage, n = (e = t.errorCode) !== null && e !== void 0 ? e : r.match(/(denied|rejected)/i) ? fn.provider.userRejectedRequest : void 0; - return Object.assign(Object.assign({}, t), { - message: r, - code: n, - data: { method: t.method } - }); - } - return t; -} -var pS = { exports: {} }; -(function(t) { - var e = Object.prototype.hasOwnProperty, r = "~"; - function n() { - } - Object.create && (n.prototype = /* @__PURE__ */ Object.create(null), new n().__proto__ || (r = !1)); - function i(u, l, d) { - this.fn = u, this.context = l, this.once = d || !1; - } - function s(u, l, d, g, w) { - if (typeof d != "function") - throw new TypeError("The listener must be a function"); - var A = new i(d, g || u, w), M = r ? r + l : l; - return u._events[M] ? u._events[M].fn ? u._events[M] = [u._events[M], A] : u._events[M].push(A) : (u._events[M] = A, u._eventsCount++), u; - } - function o(u, l) { - --u._eventsCount === 0 ? u._events = new n() : delete u._events[l]; - } - function a() { - this._events = new n(), this._eventsCount = 0; - } - a.prototype.eventNames = function() { - var l = [], d, g; - if (this._eventsCount === 0) return l; - for (g in d = this._events) - e.call(d, g) && l.push(r ? g.slice(1) : g); - return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(d)) : l; - }, a.prototype.listeners = function(l) { - var d = r ? r + l : l, g = this._events[d]; - if (!g) return []; - if (g.fn) return [g.fn]; - for (var w = 0, A = g.length, M = new Array(A); w < A; w++) - M[w] = g[w].fn; - return M; - }, a.prototype.listenerCount = function(l) { - var d = r ? r + l : l, g = this._events[d]; - return g ? g.fn ? 1 : g.length : 0; - }, a.prototype.emit = function(l, d, g, w, A, M) { - var N = r ? r + l : l; - if (!this._events[N]) return !1; - var L = this._events[N], F = arguments.length, $, K; - if (L.fn) { - switch (L.once && this.removeListener(l, L.fn, void 0, !0), F) { - case 1: - return L.fn.call(L.context), !0; - case 2: - return L.fn.call(L.context, d), !0; - case 3: - return L.fn.call(L.context, d, g), !0; - case 4: - return L.fn.call(L.context, d, g, w), !0; - case 5: - return L.fn.call(L.context, d, g, w, A), !0; - case 6: - return L.fn.call(L.context, d, g, w, A, M), !0; - } - for (K = 1, $ = new Array(F - 1); K < F; K++) - $[K - 1] = arguments[K]; - L.fn.apply(L.context, $); - } else { - var H = L.length, V; - for (K = 0; K < H; K++) - switch (L[K].once && this.removeListener(l, L[K].fn, void 0, !0), F) { - case 1: - L[K].fn.call(L[K].context); - break; - case 2: - L[K].fn.call(L[K].context, d); - break; - case 3: - L[K].fn.call(L[K].context, d, g); - break; - case 4: - L[K].fn.call(L[K].context, d, g, w); - break; - default: - if (!$) for (V = 1, $ = new Array(F - 1); V < F; V++) - $[V - 1] = arguments[V]; - L[K].fn.apply(L[K].context, $); - } - } - return !0; - }, a.prototype.on = function(l, d, g) { - return s(this, l, d, g, !1); - }, a.prototype.once = function(l, d, g) { - return s(this, l, d, g, !0); - }, a.prototype.removeListener = function(l, d, g, w) { - var A = r ? r + l : l; - if (!this._events[A]) return this; - if (!d) - return o(this, A), this; - var M = this._events[A]; - if (M.fn) - M.fn === d && (!w || M.once) && (!g || M.context === g) && o(this, A); - else { - for (var N = 0, L = [], F = M.length; N < F; N++) - (M[N].fn !== d || w && !M[N].once || g && M[N].context !== g) && L.push(M[N]); - L.length ? this._events[A] = L.length === 1 ? L[0] : L : o(this, A); - } - return this; - }, a.prototype.removeAllListeners = function(l) { - var d; - return l ? (d = r ? r + l : l, this._events[d] && o(this, d)) : (this._events = new n(), this._eventsCount = 0), this; - }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = r, a.EventEmitter = a, t.exports = a; -})(pS); -var aJ = pS.exports; -const cJ = /* @__PURE__ */ ts(aJ); -class uJ extends cJ { -} -var fJ = function(t, e) { - var r = {}; - for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); - if (t != null && typeof Object.getOwnPropertySymbols == "function") - for (var i = 0, n = Object.getOwnPropertySymbols(t); i < n.length; i++) - e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[i]) && (r[n[i]] = t[n[i]]); - return r; -}; -class lJ extends uJ { - constructor(e) { - var { metadata: r } = e, n = e.preference, { keysUrl: i } = n, s = fJ(n, ["keysUrl"]); - super(), this.signer = null, this.isCoinbaseWallet = !0, this.metadata = r, this.preference = s, this.communicator = new iJ({ - url: i, - metadata: r, - preference: s - }); - const o = KY(); - o && (this.signer = this.initSigner(o)); - } - async request(e) { - try { - if (JG(e), !this.signer) - switch (e.method) { - case "eth_requestAccounts": { - const r = await this.requestSignerSelection(e), n = this.initSigner(r); - await n.handshake(e), this.signer = n, VY(r); - break; - } - case "net_version": - return 1; - case "eth_chainId": - return da(1); - default: - throw Sr.provider.unauthorized("Must call 'eth_requestAccounts' before other methods"); - } - return this.signer.request(e); - } catch (r) { - const { code: n } = r; - return n === fn.provider.unauthorized && this.disconnect(), Promise.reject(sJ(r)); - } - } - /** @deprecated Use `.request({ method: 'eth_requestAccounts' })` instead. */ - async enable() { - return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'), await this.request({ - method: "eth_requestAccounts" - }); - } - async disconnect() { - var e; - await ((e = this.signer) === null || e === void 0 ? void 0 : e.cleanup()), this.signer = null, Qs.clearAll(), this.emit("disconnect", Sr.provider.disconnected("User initiated disconnection")); - } - requestSignerSelection(e) { - return GY({ - communicator: this.communicator, - preference: this.preference, - metadata: this.metadata, - handshakeRequest: e, - callback: this.emit.bind(this) - }); - } - initSigner(e) { - return YY({ - signerType: e, - metadata: this.metadata, - communicator: this.communicator, - callback: this.emit.bind(this) - }); - } -} -function hJ(t) { - if (t) { - if (!["all", "smartWalletOnly", "eoaOnly"].includes(t.options)) - throw new Error(`Invalid options: ${t.options}`); - if (t.attribution && t.attribution.auto !== void 0 && t.attribution.dataSuffix !== void 0) - throw new Error("Attribution cannot contain both auto and dataSuffix properties"); - } -} -function dJ(t) { - var e; - const r = { - metadata: t.metadata, - preference: t.preference - }; - return (e = YG(r)) !== null && e !== void 0 ? e : new lJ(r); -} -const pJ = { - options: "all" -}; -function gJ(t) { - var e; - new Qs("CBWSDK").setItem("VERSION", rh), QY(); - const n = { - metadata: { - appName: t.appName || "Dapp", - appLogoUrl: t.appLogoUrl || "", - appChainIds: t.appChainIds || [] - }, - preference: Object.assign(pJ, (e = t.preference) !== null && e !== void 0 ? e : {}) - }; - hJ(n.preference); - let i = null; - return { - getProvider: () => (i || (i = dJ(n)), i) - }; -} -function gS(t, e) { - return function() { - return t.apply(e, arguments); - }; -} -const { toString: mJ } = Object.prototype, { getPrototypeOf: Eb } = Object, up = /* @__PURE__ */ ((t) => (e) => { - const r = mJ.call(e); - return t[r] || (t[r] = r.slice(8, -1).toLowerCase()); -})(/* @__PURE__ */ Object.create(null)), As = (t) => (t = t.toLowerCase(), (e) => up(e) === t), fp = (t) => (e) => typeof e === t, { isArray: zu } = Array, Pl = fp("undefined"); -function vJ(t) { - return t !== null && !Pl(t) && t.constructor !== null && !Pl(t.constructor) && Di(t.constructor.isBuffer) && t.constructor.isBuffer(t); -} -const mS = As("ArrayBuffer"); -function bJ(t) { - let e; - return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? e = ArrayBuffer.isView(t) : e = t && t.buffer && mS(t.buffer), e; -} -const yJ = fp("string"), Di = fp("function"), vS = fp("number"), lp = (t) => t !== null && typeof t == "object", wJ = (t) => t === !0 || t === !1, Ld = (t) => { - if (up(t) !== "object") - return !1; - const e = Eb(t); - return (e === null || e === Object.prototype || Object.getPrototypeOf(e) === null) && !(Symbol.toStringTag in t) && !(Symbol.iterator in t); -}, xJ = As("Date"), _J = As("File"), EJ = As("Blob"), SJ = As("FileList"), AJ = (t) => lp(t) && Di(t.pipe), PJ = (t) => { - let e; - return t && (typeof FormData == "function" && t instanceof FormData || Di(t.append) && ((e = up(t)) === "formdata" || // detect form-data instance - e === "object" && Di(t.toString) && t.toString() === "[object FormData]")); -}, MJ = As("URLSearchParams"), [IJ, CJ, TJ, RJ] = ["ReadableStream", "Request", "Response", "Headers"].map(As), DJ = (t) => t.trim ? t.trim() : t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); -function ih(t, e, { allOwnKeys: r = !1 } = {}) { - if (t === null || typeof t > "u") - return; - let n, i; - if (typeof t != "object" && (t = [t]), zu(t)) - for (n = 0, i = t.length; n < i; n++) - e.call(null, t[n], n, t); - else { - const s = r ? Object.getOwnPropertyNames(t) : Object.keys(t), o = s.length; - let a; - for (n = 0; n < o; n++) - a = s[n], e.call(null, t[a], a, t); - } -} -function bS(t, e) { - e = e.toLowerCase(); - const r = Object.keys(t); - let n = r.length, i; - for (; n-- > 0; ) - if (i = r[n], e === i.toLowerCase()) - return i; - return null; -} -const nc = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, yS = (t) => !Pl(t) && t !== nc; -function H1() { - const { caseless: t } = yS(this) && this || {}, e = {}, r = (n, i) => { - const s = t && bS(e, i) || i; - Ld(e[s]) && Ld(n) ? e[s] = H1(e[s], n) : Ld(n) ? e[s] = H1({}, n) : zu(n) ? e[s] = n.slice() : e[s] = n; - }; - for (let n = 0, i = arguments.length; n < i; n++) - arguments[n] && ih(arguments[n], r); - return e; -} -const OJ = (t, e, r, { allOwnKeys: n } = {}) => (ih(e, (i, s) => { - r && Di(i) ? t[s] = gS(i, r) : t[s] = i; -}, { allOwnKeys: n }), t), NJ = (t) => (t.charCodeAt(0) === 65279 && (t = t.slice(1)), t), LJ = (t, e, r, n) => { - t.prototype = Object.create(e.prototype, n), t.prototype.constructor = t, Object.defineProperty(t, "super", { - value: e.prototype - }), r && Object.assign(t.prototype, r); -}, kJ = (t, e, r, n) => { - let i, s, o; - const a = {}; - if (e = e || {}, t == null) return e; - do { - for (i = Object.getOwnPropertyNames(t), s = i.length; s-- > 0; ) - o = i[s], (!n || n(o, t, e)) && !a[o] && (e[o] = t[o], a[o] = !0); - t = r !== !1 && Eb(t); - } while (t && (!r || r(t, e)) && t !== Object.prototype); - return e; -}, $J = (t, e, r) => { - t = String(t), (r === void 0 || r > t.length) && (r = t.length), r -= e.length; - const n = t.indexOf(e, r); - return n !== -1 && n === r; -}, FJ = (t) => { - if (!t) return null; - if (zu(t)) return t; - let e = t.length; - if (!vS(e)) return null; - const r = new Array(e); - for (; e-- > 0; ) - r[e] = t[e]; - return r; -}, BJ = /* @__PURE__ */ ((t) => (e) => t && e instanceof t)(typeof Uint8Array < "u" && Eb(Uint8Array)), UJ = (t, e) => { - const n = (t && t[Symbol.iterator]).call(t); - let i; - for (; (i = n.next()) && !i.done; ) { - const s = i.value; - e.call(t, s[0], s[1]); - } -}, jJ = (t, e) => { - let r; - const n = []; - for (; (r = t.exec(e)) !== null; ) - n.push(r); - return n; -}, qJ = As("HTMLFormElement"), zJ = (t) => t.toLowerCase().replace( - /[-_\s]([a-z\d])(\w*)/g, - function(r, n, i) { - return n.toUpperCase() + i; - } -), T_ = (({ hasOwnProperty: t }) => (e, r) => t.call(e, r))(Object.prototype), HJ = As("RegExp"), wS = (t, e) => { - const r = Object.getOwnPropertyDescriptors(t), n = {}; - ih(r, (i, s) => { - let o; - (o = e(i, s, t)) !== !1 && (n[s] = o || i); - }), Object.defineProperties(t, n); -}, WJ = (t) => { - wS(t, (e, r) => { - if (Di(t) && ["arguments", "caller", "callee"].indexOf(r) !== -1) - return !1; - const n = t[r]; - if (Di(n)) { - if (e.enumerable = !1, "writable" in e) { - e.writable = !1; - return; - } - e.set || (e.set = () => { - throw Error("Can not rewrite read-only method '" + r + "'"); - }); - } - }); -}, KJ = (t, e) => { - const r = {}, n = (i) => { - i.forEach((s) => { - r[s] = !0; - }); - }; - return zu(t) ? n(t) : n(String(t).split(e)), r; -}, VJ = () => { -}, GJ = (t, e) => t != null && Number.isFinite(t = +t) ? t : e, Im = "abcdefghijklmnopqrstuvwxyz", R_ = "0123456789", xS = { - DIGIT: R_, - ALPHA: Im, - ALPHA_DIGIT: Im + Im.toUpperCase() + R_ -}, YJ = (t = 16, e = xS.ALPHA_DIGIT) => { - let r = ""; - const { length: n } = e; - for (; t--; ) - r += e[Math.random() * n | 0]; - return r; -}; -function JJ(t) { - return !!(t && Di(t.append) && t[Symbol.toStringTag] === "FormData" && t[Symbol.iterator]); -} -const XJ = (t) => { - const e = new Array(10), r = (n, i) => { - if (lp(n)) { - if (e.indexOf(n) >= 0) - return; - if (!("toJSON" in n)) { - e[i] = n; - const s = zu(n) ? [] : {}; - return ih(n, (o, a) => { - const u = r(o, i + 1); - !Pl(u) && (s[a] = u); - }), e[i] = void 0, s; - } - } - return n; - }; - return r(t, 0); -}, ZJ = As("AsyncFunction"), QJ = (t) => t && (lp(t) || Di(t)) && Di(t.then) && Di(t.catch), _S = ((t, e) => t ? setImmediate : e ? ((r, n) => (nc.addEventListener("message", ({ source: i, data: s }) => { - i === nc && s === r && n.length && n.shift()(); -}, !1), (i) => { - n.push(i), nc.postMessage(r, "*"); -}))(`axios@${Math.random()}`, []) : (r) => setTimeout(r))( - typeof setImmediate == "function", - Di(nc.postMessage) -), eX = typeof queueMicrotask < "u" ? queueMicrotask.bind(nc) : typeof process < "u" && process.nextTick || _S, Oe = { - isArray: zu, - isArrayBuffer: mS, - isBuffer: vJ, - isFormData: PJ, - isArrayBufferView: bJ, - isString: yJ, - isNumber: vS, - isBoolean: wJ, - isObject: lp, - isPlainObject: Ld, - isReadableStream: IJ, - isRequest: CJ, - isResponse: TJ, - isHeaders: RJ, - isUndefined: Pl, - isDate: xJ, - isFile: _J, - isBlob: EJ, - isRegExp: HJ, - isFunction: Di, - isStream: AJ, - isURLSearchParams: MJ, - isTypedArray: BJ, - isFileList: SJ, - forEach: ih, - merge: H1, - extend: OJ, - trim: DJ, - stripBOM: NJ, - inherits: LJ, - toFlatObject: kJ, - kindOf: up, - kindOfTest: As, - endsWith: $J, - toArray: FJ, - forEachEntry: UJ, - matchAll: jJ, - isHTMLForm: qJ, - hasOwnProperty: T_, - hasOwnProp: T_, - // an alias to avoid ESLint no-prototype-builtins detection - reduceDescriptors: wS, - freezeMethods: WJ, - toObjectSet: KJ, - toCamelCase: zJ, - noop: VJ, - toFiniteNumber: GJ, - findKey: bS, - global: nc, - isContextDefined: yS, - ALPHABET: xS, - generateString: YJ, - isSpecCompliantForm: JJ, - toJSONObject: XJ, - isAsyncFn: ZJ, - isThenable: QJ, - setImmediate: _S, - asap: eX -}; -function sr(t, e, r, n, i) { - Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = t, this.name = "AxiosError", e && (this.code = e), r && (this.config = r), n && (this.request = n), i && (this.response = i, this.status = i.status ? i.status : null); -} -Oe.inherits(sr, Error, { - toJSON: function() { - return { - // Standard - message: this.message, - name: this.name, - // Microsoft - description: this.description, - number: this.number, - // Mozilla - fileName: this.fileName, - lineNumber: this.lineNumber, - columnNumber: this.columnNumber, - stack: this.stack, - // Axios - config: Oe.toJSONObject(this.config), - code: this.code, - status: this.status - }; - } -}); -const ES = sr.prototype, SS = {}; -[ - "ERR_BAD_OPTION_VALUE", - "ERR_BAD_OPTION", - "ECONNABORTED", - "ETIMEDOUT", - "ERR_NETWORK", - "ERR_FR_TOO_MANY_REDIRECTS", - "ERR_DEPRECATED", - "ERR_BAD_RESPONSE", - "ERR_BAD_REQUEST", - "ERR_CANCELED", - "ERR_NOT_SUPPORT", - "ERR_INVALID_URL" - // eslint-disable-next-line func-names -].forEach((t) => { - SS[t] = { value: t }; -}); -Object.defineProperties(sr, SS); -Object.defineProperty(ES, "isAxiosError", { value: !0 }); -sr.from = (t, e, r, n, i, s) => { - const o = Object.create(ES); - return Oe.toFlatObject(t, o, function(u) { - return u !== Error.prototype; - }, (a) => a !== "isAxiosError"), sr.call(o, t.message, e, r, n, i), o.cause = t, o.name = t.name, s && Object.assign(o, s), o; -}; -const tX = null; -function W1(t) { - return Oe.isPlainObject(t) || Oe.isArray(t); -} -function AS(t) { - return Oe.endsWith(t, "[]") ? t.slice(0, -2) : t; -} -function D_(t, e, r) { - return t ? t.concat(e).map(function(i, s) { - return i = AS(i), !r && s ? "[" + i + "]" : i; - }).join(r ? "." : "") : e; -} -function rX(t) { - return Oe.isArray(t) && !t.some(W1); -} -const nX = Oe.toFlatObject(Oe, {}, null, function(e) { - return /^is[A-Z]/.test(e); -}); -function hp(t, e, r) { - if (!Oe.isObject(t)) - throw new TypeError("target must be an object"); - e = e || new FormData(), r = Oe.toFlatObject(r, { - metaTokens: !0, - dots: !1, - indexes: !1 - }, !1, function(N, L) { - return !Oe.isUndefined(L[N]); - }); - const n = r.metaTokens, i = r.visitor || d, s = r.dots, o = r.indexes, u = (r.Blob || typeof Blob < "u" && Blob) && Oe.isSpecCompliantForm(e); - if (!Oe.isFunction(i)) - throw new TypeError("visitor must be a function"); - function l(M) { - if (M === null) return ""; - if (Oe.isDate(M)) - return M.toISOString(); - if (!u && Oe.isBlob(M)) - throw new sr("Blob is not supported. Use a Buffer instead."); - return Oe.isArrayBuffer(M) || Oe.isTypedArray(M) ? u && typeof Blob == "function" ? new Blob([M]) : Buffer.from(M) : M; - } - function d(M, N, L) { - let F = M; - if (M && !L && typeof M == "object") { - if (Oe.endsWith(N, "{}")) - N = n ? N : N.slice(0, -2), M = JSON.stringify(M); - else if (Oe.isArray(M) && rX(M) || (Oe.isFileList(M) || Oe.endsWith(N, "[]")) && (F = Oe.toArray(M))) - return N = AS(N), F.forEach(function(K, H) { - !(Oe.isUndefined(K) || K === null) && e.append( - // eslint-disable-next-line no-nested-ternary - o === !0 ? D_([N], H, s) : o === null ? N : N + "[]", - l(K) - ); - }), !1; - } - return W1(M) ? !0 : (e.append(D_(L, N, s), l(M)), !1); - } - const g = [], w = Object.assign(nX, { - defaultVisitor: d, - convertValue: l, - isVisitable: W1 - }); - function A(M, N) { - if (!Oe.isUndefined(M)) { - if (g.indexOf(M) !== -1) - throw Error("Circular reference detected in " + N.join(".")); - g.push(M), Oe.forEach(M, function(F, $) { - (!(Oe.isUndefined(F) || F === null) && i.call( - e, - F, - Oe.isString($) ? $.trim() : $, - N, - w - )) === !0 && A(F, N ? N.concat($) : [$]); - }), g.pop(); - } - } - if (!Oe.isObject(t)) - throw new TypeError("data must be an object"); - return A(t), e; -} -function O_(t) { - const e = { - "!": "%21", - "'": "%27", - "(": "%28", - ")": "%29", - "~": "%7E", - "%20": "+", - "%00": "\0" - }; - return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g, function(n) { - return e[n]; - }); -} -function Sb(t, e) { - this._pairs = [], t && hp(t, this, e); -} -const PS = Sb.prototype; -PS.append = function(e, r) { - this._pairs.push([e, r]); -}; -PS.toString = function(e) { - const r = e ? function(n) { - return e.call(this, n, O_); - } : O_; - return this._pairs.map(function(i) { - return r(i[0]) + "=" + r(i[1]); - }, "").join("&"); -}; -function iX(t) { - return encodeURIComponent(t).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]"); -} -function MS(t, e, r) { - if (!e) - return t; - const n = r && r.encode || iX; - Oe.isFunction(r) && (r = { - serialize: r - }); - const i = r && r.serialize; - let s; - if (i ? s = i(e, r) : s = Oe.isURLSearchParams(e) ? e.toString() : new Sb(e, r).toString(n), s) { - const o = t.indexOf("#"); - o !== -1 && (t = t.slice(0, o)), t += (t.indexOf("?") === -1 ? "?" : "&") + s; - } - return t; -} -class N_ { - constructor() { - this.handlers = []; - } - /** - * Add a new interceptor to the stack - * - * @param {Function} fulfilled The function to handle `then` for a `Promise` - * @param {Function} rejected The function to handle `reject` for a `Promise` - * - * @return {Number} An ID used to remove interceptor later - */ - use(e, r, n) { - return this.handlers.push({ - fulfilled: e, - rejected: r, - synchronous: n ? n.synchronous : !1, - runWhen: n ? n.runWhen : null - }), this.handlers.length - 1; - } - /** - * Remove an interceptor from the stack - * - * @param {Number} id The ID that was returned by `use` - * - * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise - */ - eject(e) { - this.handlers[e] && (this.handlers[e] = null); - } - /** - * Clear all interceptors from the stack - * - * @returns {void} - */ - clear() { - this.handlers && (this.handlers = []); - } - /** - * Iterate over all the registered interceptors - * - * This method is particularly useful for skipping over any - * interceptors that may have become `null` calling `eject`. - * - * @param {Function} fn The function to call for each interceptor - * - * @returns {void} - */ - forEach(e) { - Oe.forEach(this.handlers, function(n) { - n !== null && e(n); - }); - } -} -const IS = { - silentJSONParsing: !0, - forcedJSONParsing: !0, - clarifyTimeoutError: !1 -}, sX = typeof URLSearchParams < "u" ? URLSearchParams : Sb, oX = typeof FormData < "u" ? FormData : null, aX = typeof Blob < "u" ? Blob : null, cX = { - isBrowser: !0, - classes: { - URLSearchParams: sX, - FormData: oX, - Blob: aX - }, - protocols: ["http", "https", "file", "blob", "url", "data"] -}, Ab = typeof window < "u" && typeof document < "u", K1 = typeof navigator == "object" && navigator || void 0, uX = Ab && (!K1 || ["ReactNative", "NativeScript", "NS"].indexOf(K1.product) < 0), fX = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef -self instanceof WorkerGlobalScope && typeof self.importScripts == "function", lX = Ab && window.location.href || "http://localhost", hX = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - hasBrowserEnv: Ab, - hasStandardBrowserEnv: uX, - hasStandardBrowserWebWorkerEnv: fX, - navigator: K1, - origin: lX -}, Symbol.toStringTag, { value: "Module" })), Yn = { - ...hX, - ...cX -}; -function dX(t, e) { - return hp(t, new Yn.classes.URLSearchParams(), Object.assign({ - visitor: function(r, n, i, s) { - return Yn.isNode && Oe.isBuffer(r) ? (this.append(n, r.toString("base64")), !1) : s.defaultVisitor.apply(this, arguments); - } - }, e)); -} -function pX(t) { - return Oe.matchAll(/\w+|\[(\w*)]/g, t).map((e) => e[0] === "[]" ? "" : e[1] || e[0]); -} -function gX(t) { - const e = {}, r = Object.keys(t); - let n; - const i = r.length; - let s; - for (n = 0; n < i; n++) - s = r[n], e[s] = t[s]; - return e; -} -function CS(t) { - function e(r, n, i, s) { - let o = r[s++]; - if (o === "__proto__") return !0; - const a = Number.isFinite(+o), u = s >= r.length; - return o = !o && Oe.isArray(i) ? i.length : o, u ? (Oe.hasOwnProp(i, o) ? i[o] = [i[o], n] : i[o] = n, !a) : ((!i[o] || !Oe.isObject(i[o])) && (i[o] = []), e(r, n, i[o], s) && Oe.isArray(i[o]) && (i[o] = gX(i[o])), !a); - } - if (Oe.isFormData(t) && Oe.isFunction(t.entries)) { - const r = {}; - return Oe.forEachEntry(t, (n, i) => { - e(pX(n), i, r, 0); - }), r; - } - return null; -} -function mX(t, e, r) { - if (Oe.isString(t)) - try { - return (e || JSON.parse)(t), Oe.trim(t); - } catch (n) { - if (n.name !== "SyntaxError") - throw n; - } - return (r || JSON.stringify)(t); -} -const sh = { - transitional: IS, - adapter: ["xhr", "http", "fetch"], - transformRequest: [function(e, r) { - const n = r.getContentType() || "", i = n.indexOf("application/json") > -1, s = Oe.isObject(e); - if (s && Oe.isHTMLForm(e) && (e = new FormData(e)), Oe.isFormData(e)) - return i ? JSON.stringify(CS(e)) : e; - if (Oe.isArrayBuffer(e) || Oe.isBuffer(e) || Oe.isStream(e) || Oe.isFile(e) || Oe.isBlob(e) || Oe.isReadableStream(e)) - return e; - if (Oe.isArrayBufferView(e)) - return e.buffer; - if (Oe.isURLSearchParams(e)) - return r.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), e.toString(); - let a; - if (s) { - if (n.indexOf("application/x-www-form-urlencoded") > -1) - return dX(e, this.formSerializer).toString(); - if ((a = Oe.isFileList(e)) || n.indexOf("multipart/form-data") > -1) { - const u = this.env && this.env.FormData; - return hp( - a ? { "files[]": e } : e, - u && new u(), - this.formSerializer - ); - } - } - return s || i ? (r.setContentType("application/json", !1), mX(e)) : e; - }], - transformResponse: [function(e) { - const r = this.transitional || sh.transitional, n = r && r.forcedJSONParsing, i = this.responseType === "json"; - if (Oe.isResponse(e) || Oe.isReadableStream(e)) - return e; - if (e && Oe.isString(e) && (n && !this.responseType || i)) { - const o = !(r && r.silentJSONParsing) && i; - try { - return JSON.parse(e); - } catch (a) { - if (o) - throw a.name === "SyntaxError" ? sr.from(a, sr.ERR_BAD_RESPONSE, this, null, this.response) : a; - } - } - return e; - }], - /** - * A timeout in milliseconds to abort a request. If set to 0 (default) a - * timeout is not created. - */ - timeout: 0, - xsrfCookieName: "XSRF-TOKEN", - xsrfHeaderName: "X-XSRF-TOKEN", - maxContentLength: -1, - maxBodyLength: -1, - env: { - FormData: Yn.classes.FormData, - Blob: Yn.classes.Blob - }, - validateStatus: function(e) { - return e >= 200 && e < 300; - }, - headers: { - common: { - Accept: "application/json, text/plain, */*", - "Content-Type": void 0 - } - } -}; -Oe.forEach(["delete", "get", "head", "post", "put", "patch"], (t) => { - sh.headers[t] = {}; -}); -const vX = Oe.toObjectSet([ - "age", - "authorization", - "content-length", - "content-type", - "etag", - "expires", - "from", - "host", - "if-modified-since", - "if-unmodified-since", - "last-modified", - "location", - "max-forwards", - "proxy-authorization", - "referer", - "retry-after", - "user-agent" -]), bX = (t) => { - const e = {}; - let r, n, i; - return t && t.split(` -`).forEach(function(o) { - i = o.indexOf(":"), r = o.substring(0, i).trim().toLowerCase(), n = o.substring(i + 1).trim(), !(!r || e[r] && vX[r]) && (r === "set-cookie" ? e[r] ? e[r].push(n) : e[r] = [n] : e[r] = e[r] ? e[r] + ", " + n : n); - }), e; -}, L_ = Symbol("internals"); -function Rf(t) { - return t && String(t).trim().toLowerCase(); -} -function kd(t) { - return t === !1 || t == null ? t : Oe.isArray(t) ? t.map(kd) : String(t); -} -function yX(t) { - const e = /* @__PURE__ */ Object.create(null), r = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g; - let n; - for (; n = r.exec(t); ) - e[n[1]] = n[2]; - return e; -} -const wX = (t) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()); -function Cm(t, e, r, n, i) { - if (Oe.isFunction(n)) - return n.call(this, e, r); - if (i && (e = r), !!Oe.isString(e)) { - if (Oe.isString(n)) - return e.indexOf(n) !== -1; - if (Oe.isRegExp(n)) - return n.test(e); - } -} -function xX(t) { - return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (e, r, n) => r.toUpperCase() + n); -} -function _X(t, e) { - const r = Oe.toCamelCase(" " + e); - ["get", "set", "has"].forEach((n) => { - Object.defineProperty(t, n + r, { - value: function(i, s, o) { - return this[n].call(this, e, i, s, o); - }, - configurable: !0 - }); - }); -} -let yi = class { - constructor(e) { - e && this.set(e); - } - set(e, r, n) { - const i = this; - function s(a, u, l) { - const d = Rf(u); - if (!d) - throw new Error("header name must be a non-empty string"); - const g = Oe.findKey(i, d); - (!g || i[g] === void 0 || l === !0 || l === void 0 && i[g] !== !1) && (i[g || u] = kd(a)); - } - const o = (a, u) => Oe.forEach(a, (l, d) => s(l, d, u)); - if (Oe.isPlainObject(e) || e instanceof this.constructor) - o(e, r); - else if (Oe.isString(e) && (e = e.trim()) && !wX(e)) - o(bX(e), r); - else if (Oe.isHeaders(e)) - for (const [a, u] of e.entries()) - s(u, a, n); - else - e != null && s(r, e, n); - return this; - } - get(e, r) { - if (e = Rf(e), e) { - const n = Oe.findKey(this, e); - if (n) { - const i = this[n]; - if (!r) - return i; - if (r === !0) - return yX(i); - if (Oe.isFunction(r)) - return r.call(this, i, n); - if (Oe.isRegExp(r)) - return r.exec(i); - throw new TypeError("parser must be boolean|regexp|function"); - } - } - } - has(e, r) { - if (e = Rf(e), e) { - const n = Oe.findKey(this, e); - return !!(n && this[n] !== void 0 && (!r || Cm(this, this[n], n, r))); - } - return !1; - } - delete(e, r) { - const n = this; - let i = !1; - function s(o) { - if (o = Rf(o), o) { - const a = Oe.findKey(n, o); - a && (!r || Cm(n, n[a], a, r)) && (delete n[a], i = !0); - } - } - return Oe.isArray(e) ? e.forEach(s) : s(e), i; - } - clear(e) { - const r = Object.keys(this); - let n = r.length, i = !1; - for (; n--; ) { - const s = r[n]; - (!e || Cm(this, this[s], s, e, !0)) && (delete this[s], i = !0); - } - return i; - } - normalize(e) { - const r = this, n = {}; - return Oe.forEach(this, (i, s) => { - const o = Oe.findKey(n, s); - if (o) { - r[o] = kd(i), delete r[s]; - return; - } - const a = e ? xX(s) : String(s).trim(); - a !== s && delete r[s], r[a] = kd(i), n[a] = !0; - }), this; - } - concat(...e) { - return this.constructor.concat(this, ...e); - } - toJSON(e) { - const r = /* @__PURE__ */ Object.create(null); - return Oe.forEach(this, (n, i) => { - n != null && n !== !1 && (r[i] = e && Oe.isArray(n) ? n.join(", ") : n); - }), r; - } - [Symbol.iterator]() { - return Object.entries(this.toJSON())[Symbol.iterator](); - } - toString() { - return Object.entries(this.toJSON()).map(([e, r]) => e + ": " + r).join(` -`); - } - get [Symbol.toStringTag]() { - return "AxiosHeaders"; - } - static from(e) { - return e instanceof this ? e : new this(e); - } - static concat(e, ...r) { - const n = new this(e); - return r.forEach((i) => n.set(i)), n; - } - static accessor(e) { - const n = (this[L_] = this[L_] = { - accessors: {} - }).accessors, i = this.prototype; - function s(o) { - const a = Rf(o); - n[a] || (_X(i, o), n[a] = !0); - } - return Oe.isArray(e) ? e.forEach(s) : s(e), this; - } -}; -yi.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]); -Oe.reduceDescriptors(yi.prototype, ({ value: t }, e) => { - let r = e[0].toUpperCase() + e.slice(1); - return { - get: () => t, - set(n) { - this[r] = n; - } - }; -}); -Oe.freezeMethods(yi); -function Tm(t, e) { - const r = this || sh, n = e || r, i = yi.from(n.headers); - let s = n.data; - return Oe.forEach(t, function(a) { - s = a.call(r, s, i.normalize(), e ? e.status : void 0); - }), i.normalize(), s; -} -function TS(t) { - return !!(t && t.__CANCEL__); -} -function Hu(t, e, r) { - sr.call(this, t ?? "canceled", sr.ERR_CANCELED, e, r), this.name = "CanceledError"; -} -Oe.inherits(Hu, sr, { - __CANCEL__: !0 -}); -function RS(t, e, r) { - const n = r.config.validateStatus; - !r.status || !n || n(r.status) ? t(r) : e(new sr( - "Request failed with status code " + r.status, - [sr.ERR_BAD_REQUEST, sr.ERR_BAD_RESPONSE][Math.floor(r.status / 100) - 4], - r.config, - r.request, - r - )); -} -function EX(t) { - const e = /^([-+\w]{1,25})(:?\/\/|:)/.exec(t); - return e && e[1] || ""; -} -function SX(t, e) { - t = t || 10; - const r = new Array(t), n = new Array(t); - let i = 0, s = 0, o; - return e = e !== void 0 ? e : 1e3, function(u) { - const l = Date.now(), d = n[s]; - o || (o = l), r[i] = u, n[i] = l; - let g = s, w = 0; - for (; g !== i; ) - w += r[g++], g = g % t; - if (i = (i + 1) % t, i === s && (s = (s + 1) % t), l - o < e) - return; - const A = d && l - d; - return A ? Math.round(w * 1e3 / A) : void 0; - }; -} -function AX(t, e) { - let r = 0, n = 1e3 / e, i, s; - const o = (l, d = Date.now()) => { - r = d, i = null, s && (clearTimeout(s), s = null), t.apply(null, l); - }; - return [(...l) => { - const d = Date.now(), g = d - r; - g >= n ? o(l, d) : (i = l, s || (s = setTimeout(() => { - s = null, o(i); - }, n - g))); - }, () => i && o(i)]; -} -const p0 = (t, e, r = 3) => { - let n = 0; - const i = SX(50, 250); - return AX((s) => { - const o = s.loaded, a = s.lengthComputable ? s.total : void 0, u = o - n, l = i(u), d = o <= a; - n = o; - const g = { - loaded: o, - total: a, - progress: a ? o / a : void 0, - bytes: u, - rate: l || void 0, - estimated: l && a && d ? (a - o) / l : void 0, - event: s, - lengthComputable: a != null, - [e ? "download" : "upload"]: !0 - }; - t(g); - }, r); -}, k_ = (t, e) => { - const r = t != null; - return [(n) => e[0]({ - lengthComputable: r, - total: t, - loaded: n - }), e[1]]; -}, $_ = (t) => (...e) => Oe.asap(() => t(...e)), PX = Yn.hasStandardBrowserEnv ? /* @__PURE__ */ ((t, e) => (r) => (r = new URL(r, Yn.origin), t.protocol === r.protocol && t.host === r.host && (e || t.port === r.port)))( - new URL(Yn.origin), - Yn.navigator && /(msie|trident)/i.test(Yn.navigator.userAgent) -) : () => !0, MX = Yn.hasStandardBrowserEnv ? ( - // Standard browser envs support document.cookie - { - write(t, e, r, n, i, s) { - const o = [t + "=" + encodeURIComponent(e)]; - Oe.isNumber(r) && o.push("expires=" + new Date(r).toGMTString()), Oe.isString(n) && o.push("path=" + n), Oe.isString(i) && o.push("domain=" + i), s === !0 && o.push("secure"), document.cookie = o.join("; "); - }, - read(t) { - const e = document.cookie.match(new RegExp("(^|;\\s*)(" + t + ")=([^;]*)")); - return e ? decodeURIComponent(e[3]) : null; - }, - remove(t) { - this.write(t, "", Date.now() - 864e5); - } - } -) : ( - // Non-standard browser env (web workers, react-native) lack needed support. - { - write() { - }, - read() { - return null; - }, - remove() { - } - } -); -function IX(t) { - return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t); -} -function CX(t, e) { - return e ? t.replace(/\/?\/$/, "") + "/" + e.replace(/^\/+/, "") : t; -} -function DS(t, e) { - return t && !IX(e) ? CX(t, e) : e; -} -const F_ = (t) => t instanceof yi ? { ...t } : t; -function pc(t, e) { - e = e || {}; - const r = {}; - function n(l, d, g, w) { - return Oe.isPlainObject(l) && Oe.isPlainObject(d) ? Oe.merge.call({ caseless: w }, l, d) : Oe.isPlainObject(d) ? Oe.merge({}, d) : Oe.isArray(d) ? d.slice() : d; - } - function i(l, d, g, w) { - if (Oe.isUndefined(d)) { - if (!Oe.isUndefined(l)) - return n(void 0, l, g, w); - } else return n(l, d, g, w); - } - function s(l, d) { - if (!Oe.isUndefined(d)) - return n(void 0, d); - } - function o(l, d) { - if (Oe.isUndefined(d)) { - if (!Oe.isUndefined(l)) - return n(void 0, l); - } else return n(void 0, d); - } - function a(l, d, g) { - if (g in e) - return n(l, d); - if (g in t) - return n(void 0, l); - } - const u = { - url: s, - method: s, - data: s, - baseURL: o, - transformRequest: o, - transformResponse: o, - paramsSerializer: o, - timeout: o, - timeoutMessage: o, - withCredentials: o, - withXSRFToken: o, - adapter: o, - responseType: o, - xsrfCookieName: o, - xsrfHeaderName: o, - onUploadProgress: o, - onDownloadProgress: o, - decompress: o, - maxContentLength: o, - maxBodyLength: o, - beforeRedirect: o, - transport: o, - httpAgent: o, - httpsAgent: o, - cancelToken: o, - socketPath: o, - responseEncoding: o, - validateStatus: a, - headers: (l, d, g) => i(F_(l), F_(d), g, !0) - }; - return Oe.forEach(Object.keys(Object.assign({}, t, e)), function(d) { - const g = u[d] || i, w = g(t[d], e[d], d); - Oe.isUndefined(w) && g !== a || (r[d] = w); - }), r; -} -const OS = (t) => { - const e = pc({}, t); - let { data: r, withXSRFToken: n, xsrfHeaderName: i, xsrfCookieName: s, headers: o, auth: a } = e; - e.headers = o = yi.from(o), e.url = MS(DS(e.baseURL, e.url), t.params, t.paramsSerializer), a && o.set( - "Authorization", - "Basic " + btoa((a.username || "") + ":" + (a.password ? unescape(encodeURIComponent(a.password)) : "")) - ); - let u; - if (Oe.isFormData(r)) { - if (Yn.hasStandardBrowserEnv || Yn.hasStandardBrowserWebWorkerEnv) - o.setContentType(void 0); - else if ((u = o.getContentType()) !== !1) { - const [l, ...d] = u ? u.split(";").map((g) => g.trim()).filter(Boolean) : []; - o.setContentType([l || "multipart/form-data", ...d].join("; ")); - } - } - if (Yn.hasStandardBrowserEnv && (n && Oe.isFunction(n) && (n = n(e)), n || n !== !1 && PX(e.url))) { - const l = i && s && MX.read(s); - l && o.set(i, l); - } - return e; -}, TX = typeof XMLHttpRequest < "u", RX = TX && function(t) { - return new Promise(function(r, n) { - const i = OS(t); - let s = i.data; - const o = yi.from(i.headers).normalize(); - let { responseType: a, onUploadProgress: u, onDownloadProgress: l } = i, d, g, w, A, M; - function N() { - A && A(), M && M(), i.cancelToken && i.cancelToken.unsubscribe(d), i.signal && i.signal.removeEventListener("abort", d); - } - let L = new XMLHttpRequest(); - L.open(i.method.toUpperCase(), i.url, !0), L.timeout = i.timeout; - function F() { - if (!L) - return; - const K = yi.from( - "getAllResponseHeaders" in L && L.getAllResponseHeaders() - ), V = { - data: !a || a === "text" || a === "json" ? L.responseText : L.response, - status: L.status, - statusText: L.statusText, - headers: K, - config: t, - request: L - }; - RS(function(R) { - r(R), N(); - }, function(R) { - n(R), N(); - }, V), L = null; - } - "onloadend" in L ? L.onloadend = F : L.onreadystatechange = function() { - !L || L.readyState !== 4 || L.status === 0 && !(L.responseURL && L.responseURL.indexOf("file:") === 0) || setTimeout(F); - }, L.onabort = function() { - L && (n(new sr("Request aborted", sr.ECONNABORTED, t, L)), L = null); - }, L.onerror = function() { - n(new sr("Network Error", sr.ERR_NETWORK, t, L)), L = null; - }, L.ontimeout = function() { - let H = i.timeout ? "timeout of " + i.timeout + "ms exceeded" : "timeout exceeded"; - const V = i.transitional || IS; - i.timeoutErrorMessage && (H = i.timeoutErrorMessage), n(new sr( - H, - V.clarifyTimeoutError ? sr.ETIMEDOUT : sr.ECONNABORTED, - t, - L - )), L = null; - }, s === void 0 && o.setContentType(null), "setRequestHeader" in L && Oe.forEach(o.toJSON(), function(H, V) { - L.setRequestHeader(V, H); - }), Oe.isUndefined(i.withCredentials) || (L.withCredentials = !!i.withCredentials), a && a !== "json" && (L.responseType = i.responseType), l && ([w, M] = p0(l, !0), L.addEventListener("progress", w)), u && L.upload && ([g, A] = p0(u), L.upload.addEventListener("progress", g), L.upload.addEventListener("loadend", A)), (i.cancelToken || i.signal) && (d = (K) => { - L && (n(!K || K.type ? new Hu(null, t, L) : K), L.abort(), L = null); - }, i.cancelToken && i.cancelToken.subscribe(d), i.signal && (i.signal.aborted ? d() : i.signal.addEventListener("abort", d))); - const $ = EX(i.url); - if ($ && Yn.protocols.indexOf($) === -1) { - n(new sr("Unsupported protocol " + $ + ":", sr.ERR_BAD_REQUEST, t)); - return; - } - L.send(s || null); - }); -}, DX = (t, e) => { - const { length: r } = t = t ? t.filter(Boolean) : []; - if (e || r) { - let n = new AbortController(), i; - const s = function(l) { - if (!i) { - i = !0, a(); - const d = l instanceof Error ? l : this.reason; - n.abort(d instanceof sr ? d : new Hu(d instanceof Error ? d.message : d)); - } - }; - let o = e && setTimeout(() => { - o = null, s(new sr(`timeout ${e} of ms exceeded`, sr.ETIMEDOUT)); - }, e); - const a = () => { - t && (o && clearTimeout(o), o = null, t.forEach((l) => { - l.unsubscribe ? l.unsubscribe(s) : l.removeEventListener("abort", s); - }), t = null); - }; - t.forEach((l) => l.addEventListener("abort", s)); - const { signal: u } = n; - return u.unsubscribe = () => Oe.asap(a), u; - } -}, OX = function* (t, e) { - let r = t.byteLength; - if (r < e) { - yield t; - return; - } - let n = 0, i; - for (; n < r; ) - i = n + e, yield t.slice(n, i), n = i; -}, NX = async function* (t, e) { - for await (const r of LX(t)) - yield* OX(r, e); -}, LX = async function* (t) { - if (t[Symbol.asyncIterator]) { - yield* t; - return; - } - const e = t.getReader(); - try { - for (; ; ) { - const { done: r, value: n } = await e.read(); - if (r) - break; - yield n; - } - } finally { - await e.cancel(); - } -}, B_ = (t, e, r, n) => { - const i = NX(t, e); - let s = 0, o, a = (u) => { - o || (o = !0, n && n(u)); - }; - return new ReadableStream({ - async pull(u) { - try { - const { done: l, value: d } = await i.next(); - if (l) { - a(), u.close(); - return; - } - let g = d.byteLength; - if (r) { - let w = s += g; - r(w); - } - u.enqueue(new Uint8Array(d)); - } catch (l) { - throw a(l), l; - } - }, - cancel(u) { - return a(u), i.return(); - } - }, { - highWaterMark: 2 - }); -}, dp = typeof fetch == "function" && typeof Request == "function" && typeof Response == "function", NS = dp && typeof ReadableStream == "function", kX = dp && (typeof TextEncoder == "function" ? /* @__PURE__ */ ((t) => (e) => t.encode(e))(new TextEncoder()) : async (t) => new Uint8Array(await new Response(t).arrayBuffer())), LS = (t, ...e) => { - try { - return !!t(...e); - } catch { - return !1; - } -}, $X = NS && LS(() => { - let t = !1; - const e = new Request(Yn.origin, { - body: new ReadableStream(), - method: "POST", - get duplex() { - return t = !0, "half"; - } - }).headers.has("Content-Type"); - return t && !e; -}), U_ = 64 * 1024, V1 = NS && LS(() => Oe.isReadableStream(new Response("").body)), g0 = { - stream: V1 && ((t) => t.body) -}; -dp && ((t) => { - ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((e) => { - !g0[e] && (g0[e] = Oe.isFunction(t[e]) ? (r) => r[e]() : (r, n) => { - throw new sr(`Response type '${e}' is not supported`, sr.ERR_NOT_SUPPORT, n); - }); - }); -})(new Response()); -const FX = async (t) => { - if (t == null) - return 0; - if (Oe.isBlob(t)) - return t.size; - if (Oe.isSpecCompliantForm(t)) - return (await new Request(Yn.origin, { - method: "POST", - body: t - }).arrayBuffer()).byteLength; - if (Oe.isArrayBufferView(t) || Oe.isArrayBuffer(t)) - return t.byteLength; - if (Oe.isURLSearchParams(t) && (t = t + ""), Oe.isString(t)) - return (await kX(t)).byteLength; -}, BX = async (t, e) => { - const r = Oe.toFiniteNumber(t.getContentLength()); - return r ?? FX(e); -}, UX = dp && (async (t) => { - let { - url: e, - method: r, - data: n, - signal: i, - cancelToken: s, - timeout: o, - onDownloadProgress: a, - onUploadProgress: u, - responseType: l, - headers: d, - withCredentials: g = "same-origin", - fetchOptions: w - } = OS(t); - l = l ? (l + "").toLowerCase() : "text"; - let A = DX([i, s && s.toAbortSignal()], o), M; - const N = A && A.unsubscribe && (() => { - A.unsubscribe(); - }); - let L; - try { - if (u && $X && r !== "get" && r !== "head" && (L = await BX(d, n)) !== 0) { - let V = new Request(e, { - method: "POST", - body: n, - duplex: "half" - }), te; - if (Oe.isFormData(n) && (te = V.headers.get("content-type")) && d.setContentType(te), V.body) { - const [R, W] = k_( - L, - p0($_(u)) - ); - n = B_(V.body, U_, R, W); - } - } - Oe.isString(g) || (g = g ? "include" : "omit"); - const F = "credentials" in Request.prototype; - M = new Request(e, { - ...w, - signal: A, - method: r.toUpperCase(), - headers: d.normalize().toJSON(), - body: n, - duplex: "half", - credentials: F ? g : void 0 - }); - let $ = await fetch(M); - const K = V1 && (l === "stream" || l === "response"); - if (V1 && (a || K && N)) { - const V = {}; - ["status", "statusText", "headers"].forEach((pe) => { - V[pe] = $[pe]; - }); - const te = Oe.toFiniteNumber($.headers.get("content-length")), [R, W] = a && k_( - te, - p0($_(a), !0) - ) || []; - $ = new Response( - B_($.body, U_, R, () => { - W && W(), N && N(); - }), - V - ); - } - l = l || "text"; - let H = await g0[Oe.findKey(g0, l) || "text"]($, t); - return !K && N && N(), await new Promise((V, te) => { - RS(V, te, { - data: H, - headers: yi.from($.headers), - status: $.status, - statusText: $.statusText, - config: t, - request: M - }); - }); - } catch (F) { - throw N && N(), F && F.name === "TypeError" && /fetch/i.test(F.message) ? Object.assign( - new sr("Network Error", sr.ERR_NETWORK, t, M), - { - cause: F.cause || F - } - ) : sr.from(F, F && F.code, t, M); - } -}), G1 = { - http: tX, - xhr: RX, - fetch: UX -}; -Oe.forEach(G1, (t, e) => { - if (t) { - try { - Object.defineProperty(t, "name", { value: e }); - } catch { - } - Object.defineProperty(t, "adapterName", { value: e }); - } -}); -const j_ = (t) => `- ${t}`, jX = (t) => Oe.isFunction(t) || t === null || t === !1, kS = { - getAdapter: (t) => { - t = Oe.isArray(t) ? t : [t]; - const { length: e } = t; - let r, n; - const i = {}; - for (let s = 0; s < e; s++) { - r = t[s]; - let o; - if (n = r, !jX(r) && (n = G1[(o = String(r)).toLowerCase()], n === void 0)) - throw new sr(`Unknown adapter '${o}'`); - if (n) - break; - i[o || "#" + s] = n; - } - if (!n) { - const s = Object.entries(i).map( - ([a, u]) => `adapter ${a} ` + (u === !1 ? "is not supported by the environment" : "is not available in the build") - ); - let o = e ? s.length > 1 ? `since : -` + s.map(j_).join(` -`) : " " + j_(s[0]) : "as no adapter specified"; - throw new sr( - "There is no suitable adapter to dispatch the request " + o, - "ERR_NOT_SUPPORT" - ); - } - return n; - }, - adapters: G1 -}; -function Rm(t) { - if (t.cancelToken && t.cancelToken.throwIfRequested(), t.signal && t.signal.aborted) - throw new Hu(null, t); -} -function q_(t) { - return Rm(t), t.headers = yi.from(t.headers), t.data = Tm.call( - t, - t.transformRequest - ), ["post", "put", "patch"].indexOf(t.method) !== -1 && t.headers.setContentType("application/x-www-form-urlencoded", !1), kS.getAdapter(t.adapter || sh.adapter)(t).then(function(n) { - return Rm(t), n.data = Tm.call( - t, - t.transformResponse, - n - ), n.headers = yi.from(n.headers), n; - }, function(n) { - return TS(n) || (Rm(t), n && n.response && (n.response.data = Tm.call( - t, - t.transformResponse, - n.response - ), n.response.headers = yi.from(n.response.headers))), Promise.reject(n); - }); -} -const $S = "1.7.8", pp = {}; -["object", "boolean", "number", "function", "string", "symbol"].forEach((t, e) => { - pp[t] = function(n) { - return typeof n === t || "a" + (e < 1 ? "n " : " ") + t; - }; -}); -const z_ = {}; -pp.transitional = function(e, r, n) { - function i(s, o) { - return "[Axios v" + $S + "] Transitional option '" + s + "'" + o + (n ? ". " + n : ""); - } - return (s, o, a) => { - if (e === !1) - throw new sr( - i(o, " has been removed" + (r ? " in " + r : "")), - sr.ERR_DEPRECATED - ); - return r && !z_[o] && (z_[o] = !0, console.warn( - i( - o, - " has been deprecated since v" + r + " and will be removed in the near future" - ) - )), e ? e(s, o, a) : !0; - }; -}; -pp.spelling = function(e) { - return (r, n) => (console.warn(`${n} is likely a misspelling of ${e}`), !0); -}; -function qX(t, e, r) { - if (typeof t != "object") - throw new sr("options must be an object", sr.ERR_BAD_OPTION_VALUE); - const n = Object.keys(t); - let i = n.length; - for (; i-- > 0; ) { - const s = n[i], o = e[s]; - if (o) { - const a = t[s], u = a === void 0 || o(a, s, t); - if (u !== !0) - throw new sr("option " + s + " must be " + u, sr.ERR_BAD_OPTION_VALUE); - continue; - } - if (r !== !0) - throw new sr("Unknown option " + s, sr.ERR_BAD_OPTION); - } -} -const $d = { - assertOptions: qX, - validators: pp -}, $s = $d.validators; -let oc = class { - constructor(e) { - this.defaults = e, this.interceptors = { - request: new N_(), - response: new N_() - }; - } - /** - * Dispatch a request - * - * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults) - * @param {?Object} config - * - * @returns {Promise} The Promise to be fulfilled - */ - async request(e, r) { - try { - return await this._request(e, r); - } catch (n) { - if (n instanceof Error) { - let i = {}; - Error.captureStackTrace ? Error.captureStackTrace(i) : i = new Error(); - const s = i.stack ? i.stack.replace(/^.+\n/, "") : ""; - try { - n.stack ? s && !String(n.stack).endsWith(s.replace(/^.+\n.+\n/, "")) && (n.stack += ` -` + s) : n.stack = s; - } catch { - } - } - throw n; - } - } - _request(e, r) { - typeof e == "string" ? (r = r || {}, r.url = e) : r = e || {}, r = pc(this.defaults, r); - const { transitional: n, paramsSerializer: i, headers: s } = r; - n !== void 0 && $d.assertOptions(n, { - silentJSONParsing: $s.transitional($s.boolean), - forcedJSONParsing: $s.transitional($s.boolean), - clarifyTimeoutError: $s.transitional($s.boolean) - }, !1), i != null && (Oe.isFunction(i) ? r.paramsSerializer = { - serialize: i - } : $d.assertOptions(i, { - encode: $s.function, - serialize: $s.function - }, !0)), $d.assertOptions(r, { - baseUrl: $s.spelling("baseURL"), - withXsrfToken: $s.spelling("withXSRFToken") - }, !0), r.method = (r.method || this.defaults.method || "get").toLowerCase(); - let o = s && Oe.merge( - s.common, - s[r.method] - ); - s && Oe.forEach( - ["delete", "get", "head", "post", "put", "patch", "common"], - (M) => { - delete s[M]; - } - ), r.headers = yi.concat(o, s); - const a = []; - let u = !0; - this.interceptors.request.forEach(function(N) { - typeof N.runWhen == "function" && N.runWhen(r) === !1 || (u = u && N.synchronous, a.unshift(N.fulfilled, N.rejected)); - }); - const l = []; - this.interceptors.response.forEach(function(N) { - l.push(N.fulfilled, N.rejected); - }); - let d, g = 0, w; - if (!u) { - const M = [q_.bind(this), void 0]; - for (M.unshift.apply(M, a), M.push.apply(M, l), w = M.length, d = Promise.resolve(r); g < w; ) - d = d.then(M[g++], M[g++]); - return d; - } - w = a.length; - let A = r; - for (g = 0; g < w; ) { - const M = a[g++], N = a[g++]; - try { - A = M(A); - } catch (L) { - N.call(this, L); - break; - } - } - try { - d = q_.call(this, A); - } catch (M) { - return Promise.reject(M); - } - for (g = 0, w = l.length; g < w; ) - d = d.then(l[g++], l[g++]); - return d; - } - getUri(e) { - e = pc(this.defaults, e); - const r = DS(e.baseURL, e.url); - return MS(r, e.params, e.paramsSerializer); - } -}; -Oe.forEach(["delete", "get", "head", "options"], function(e) { - oc.prototype[e] = function(r, n) { - return this.request(pc(n || {}, { - method: e, - url: r, - data: (n || {}).data - })); - }; -}); -Oe.forEach(["post", "put", "patch"], function(e) { - function r(n) { - return function(s, o, a) { - return this.request(pc(a || {}, { - method: e, - headers: n ? { - "Content-Type": "multipart/form-data" - } : {}, - url: s, - data: o - })); - }; - } - oc.prototype[e] = r(), oc.prototype[e + "Form"] = r(!0); -}); -let zX = class FS { - constructor(e) { - if (typeof e != "function") - throw new TypeError("executor must be a function."); - let r; - this.promise = new Promise(function(s) { - r = s; - }); - const n = this; - this.promise.then((i) => { - if (!n._listeners) return; - let s = n._listeners.length; - for (; s-- > 0; ) - n._listeners[s](i); - n._listeners = null; - }), this.promise.then = (i) => { - let s; - const o = new Promise((a) => { - n.subscribe(a), s = a; - }).then(i); - return o.cancel = function() { - n.unsubscribe(s); - }, o; - }, e(function(s, o, a) { - n.reason || (n.reason = new Hu(s, o, a), r(n.reason)); - }); - } - /** - * Throws a `CanceledError` if cancellation has been requested. - */ - throwIfRequested() { - if (this.reason) - throw this.reason; - } - /** - * Subscribe to the cancel signal - */ - subscribe(e) { - if (this.reason) { - e(this.reason); - return; - } - this._listeners ? this._listeners.push(e) : this._listeners = [e]; - } - /** - * Unsubscribe from the cancel signal - */ - unsubscribe(e) { - if (!this._listeners) - return; - const r = this._listeners.indexOf(e); - r !== -1 && this._listeners.splice(r, 1); - } - toAbortSignal() { - const e = new AbortController(), r = (n) => { - e.abort(n); - }; - return this.subscribe(r), e.signal.unsubscribe = () => this.unsubscribe(r), e.signal; - } - /** - * Returns an object that contains a new `CancelToken` and a function that, when called, - * cancels the `CancelToken`. - */ - static source() { - let e; - return { - token: new FS(function(i) { - e = i; - }), - cancel: e - }; - } -}; -function HX(t) { - return function(r) { - return t.apply(null, r); - }; -} -function WX(t) { - return Oe.isObject(t) && t.isAxiosError === !0; -} -const Y1 = { - Continue: 100, - SwitchingProtocols: 101, - Processing: 102, - EarlyHints: 103, - Ok: 200, - Created: 201, - Accepted: 202, - NonAuthoritativeInformation: 203, - NoContent: 204, - ResetContent: 205, - PartialContent: 206, - MultiStatus: 207, - AlreadyReported: 208, - ImUsed: 226, - MultipleChoices: 300, - MovedPermanently: 301, - Found: 302, - SeeOther: 303, - NotModified: 304, - UseProxy: 305, - Unused: 306, - TemporaryRedirect: 307, - PermanentRedirect: 308, - BadRequest: 400, - Unauthorized: 401, - PaymentRequired: 402, - Forbidden: 403, - NotFound: 404, - MethodNotAllowed: 405, - NotAcceptable: 406, - ProxyAuthenticationRequired: 407, - RequestTimeout: 408, - Conflict: 409, - Gone: 410, - LengthRequired: 411, - PreconditionFailed: 412, - PayloadTooLarge: 413, - UriTooLong: 414, - UnsupportedMediaType: 415, - RangeNotSatisfiable: 416, - ExpectationFailed: 417, - ImATeapot: 418, - MisdirectedRequest: 421, - UnprocessableEntity: 422, - Locked: 423, - FailedDependency: 424, - TooEarly: 425, - UpgradeRequired: 426, - PreconditionRequired: 428, - TooManyRequests: 429, - RequestHeaderFieldsTooLarge: 431, - UnavailableForLegalReasons: 451, - InternalServerError: 500, - NotImplemented: 501, - BadGateway: 502, - ServiceUnavailable: 503, - GatewayTimeout: 504, - HttpVersionNotSupported: 505, - VariantAlsoNegotiates: 506, - InsufficientStorage: 507, - LoopDetected: 508, - NotExtended: 510, - NetworkAuthenticationRequired: 511 -}; -Object.entries(Y1).forEach(([t, e]) => { - Y1[e] = t; -}); -function BS(t) { - const e = new oc(t), r = gS(oc.prototype.request, e); - return Oe.extend(r, oc.prototype, e, { allOwnKeys: !0 }), Oe.extend(r, e, null, { allOwnKeys: !0 }), r.create = function(i) { - return BS(pc(t, i)); - }, r; -} -const mn = BS(sh); -mn.Axios = oc; -mn.CanceledError = Hu; -mn.CancelToken = zX; -mn.isCancel = TS; -mn.VERSION = $S; -mn.toFormData = hp; -mn.AxiosError = sr; -mn.Cancel = mn.CanceledError; -mn.all = function(e) { - return Promise.all(e); -}; -mn.spread = HX; -mn.isAxiosError = WX; -mn.mergeConfig = pc; -mn.AxiosHeaders = yi; -mn.formToJSON = (t) => CS(Oe.isHTMLForm(t) ? new FormData(t) : t); -mn.getAdapter = kS.getAdapter; -mn.HttpStatusCode = Y1; -mn.default = mn; -const { - Axios: Jse, - AxiosError: KX, - CanceledError: Xse, - isCancel: Zse, - CancelToken: Qse, - VERSION: eoe, - all: toe, - Cancel: roe, - isAxiosError: noe, - spread: ioe, - toFormData: soe, - AxiosHeaders: ooe, - HttpStatusCode: aoe, - formToJSON: coe, - getAdapter: uoe, - mergeConfig: foe -} = mn, US = mn.create({ - timeout: 6e4, - headers: { - "Content-Type": "application/json" - } -}); -function VX(t) { - var e, r, n; - if (((e = t.data) == null ? void 0 : e.success) !== !0) { - const i = new KX( - (r = t.data) == null ? void 0 : r.errorMessage, - (n = t.data) == null ? void 0 : n.errorCode, - t.config, - t.request, - t - ); - return Promise.reject(i); - } else - return t; -} -US.interceptors.response.use( - VX -); -class GX { - constructor(e) { - Rs(this, "_apiBase", ""); - this.request = e; - } - setApiBase(e) { - this._apiBase = e || ""; - } - async getNonce(e) { - const { data: r } = await this.request.post(`${this._apiBase}/api/v2/user/nonce`, e); - return r.data; - } - async getEmailCode(e) { - const { data: r } = await this.request.post(`${this._apiBase}/api/v2/user/get_code`, e); - return r.data; - } - async emailLogin(e) { - return (await this.request.post(`${this._apiBase}/api/v2/user/login`, e)).data; - } - async walletLogin(e) { - return (await this.request.post(`${this._apiBase}/api/v2/user/login`, e)).data; - } - async tonLogin(e) { - return (await this.request.post(`${this._apiBase}/api/v2/user/login`, e)).data; - } -} -const ya = new GX(US), YX = { - projectId: "7a4434fefbcc9af474fb5c995e47d286", - metadata: { - name: "codatta", - description: "codatta", - url: "https://codatta.io/", - icons: ["https://avatars.githubusercontent.com/u/171659315"] - } -}, JX = gJ({ - appName: "codatta", - appLogoUrl: "https://avatars.githubusercontent.com/u/171659315" -}), jS = Sa({ - saveLastUsedWallet: () => { - }, - lastUsedWallet: null, - wallets: [], - initialized: !1, - featuredWallets: [] -}); -function gp() { - return Tn(jS); -} -function loe(t) { - const { apiBaseUrl: e } = t, [r, n] = fr([]), [i, s] = fr([]), [o, a] = fr(null), [u, l] = fr(!1), d = (A) => { - console.log("saveLastUsedWallet", A); - }; - function g(A) { - const M = A.filter((F) => F.featured || F.installed), N = A.filter((F) => !F.featured && !F.installed), L = [...M, ...N]; - n(L), s(M); - } - async function w() { - const A = [], M = /* @__PURE__ */ new Map(); - RR.forEach((L) => { - const F = new ml(L); - L.name === "Coinbase Wallet" && F.EIP6963Detected({ - info: { name: "Coinbase Wallet", uuid: "coinbase", icon: L.image, rdns: "coinbase" }, - provider: JX.getProvider() - }), M.set(F.key, F), A.push(F); - }), (await TG()).forEach((L) => { - const F = M.get(L.info.name); - if (F) - F.EIP6963Detected(L); - else { - const $ = new ml(L); - M.set($.key, $), A.push($); - } - }); - try { - const L = JSON.parse(localStorage.getItem("xn-last-used-info") || "{}"), F = M.get(L.key); - if (F) { - if (F.lastUsed = !0, L.provider === "UniversalProvider") { - const $ = await EE.init(YX); - $.session && F.setUniversalProvider($); - } - a(F); - } - } catch (L) { - console.log(L); - } - g(A), l(!0); - } - return Xn(() => { - w(), ya.setApiBase(e); - }, []), /* @__PURE__ */ me.jsx( - jS.Provider, - { - value: { - saveLastUsedWallet: d, - wallets: r, - initialized: u, - lastUsedWallet: o, - featuredWallets: i - }, - children: t.children - } - ); -} -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const XX = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), qS = (...t) => t.filter((e, r, n) => !!e && e.trim() !== "" && n.indexOf(e) === r).join(" ").trim(); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -var ZX = { - xmlns: "http://www.w3.org/2000/svg", - width: 24, - height: 24, - viewBox: "0 0 24 24", - fill: "none", - stroke: "currentColor", - strokeWidth: 2, - strokeLinecap: "round", - strokeLinejoin: "round" -}; -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const QX = gv( - ({ - color: t = "currentColor", - size: e = 24, - strokeWidth: r = 2, - absoluteStrokeWidth: n, - className: i = "", - children: s, - iconNode: o, - ...a - }, u) => jd( - "svg", - { - ref: u, - ...ZX, - width: e, - height: e, - stroke: t, - strokeWidth: n ? Number(r) * 24 / Number(e) : r, - className: qS("lucide", i), - ...a - }, - [ - ...o.map(([l, d]) => jd(l, d)), - ...Array.isArray(s) ? s : [s] - ] - ) -); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const Ps = (t, e) => { - const r = gv( - ({ className: n, ...i }, s) => jd(QX, { - ref: s, - iconNode: e, - className: qS(`lucide-${XX(t)}`, n), - ...i - }) - ); - return r.displayName = `${t}`, r; -}; -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const eZ = Ps("ArrowLeft", [ - ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }], - ["path", { d: "M19 12H5", key: "x3x0zl" }] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const zS = Ps("ArrowRight", [ - ["path", { d: "M5 12h14", key: "1ays0h" }], - ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const tZ = Ps("ChevronRight", [ - ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const rZ = Ps("CircleCheckBig", [ - ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }], - ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const nZ = Ps("Download", [ - ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }], - ["polyline", { points: "7 10 12 15 17 10", key: "2ggqvy" }], - ["line", { x1: "12", x2: "12", y1: "15", y2: "3", key: "1vk2je" }] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const iZ = Ps("Globe", [ - ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }], - ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }], - ["path", { d: "M2 12h20", key: "9i4pu4" }] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const HS = Ps("Laptop", [ - [ - "path", - { - d: "M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16", - key: "tarvll" - } - ] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const sZ = Ps("Link2", [ - ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }], - ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }], - ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const gc = Ps("LoaderCircle", [ - ["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const oZ = Ps("Mail", [ - ["rect", { width: "20", height: "16", x: "2", y: "4", rx: "2", key: "18n3k1" }], - ["path", { d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7", key: "1ocrg3" }] -]); -/** - * @license lucide-react v0.460.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */ -const WS = Ps("Search", [ - ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }], - ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }] -]), H_ = /* @__PURE__ */ new Set(); -function mp(t, e, r) { - t || H_.has(e) || (console.warn(e), H_.add(e)); -} -function aZ(t) { - if (typeof Proxy > "u") - return t; - const e = /* @__PURE__ */ new Map(), r = (...n) => (process.env.NODE_ENV !== "production" && mp(!1, "motion() is deprecated. Use motion.create() instead."), t(...n)); - return new Proxy(r, { - /** - * Called when `motion` is referenced with a prop: `motion.div`, `motion.input` etc. - * The prop name is passed through as `key` and we can use that to generate a `motion` - * DOM component with that name. - */ - get: (n, i) => i === "create" ? t : (e.has(i) || e.set(i, t(i)), e.get(i)) - }); -} -function vp(t) { - return t !== null && typeof t == "object" && typeof t.start == "function"; -} -const J1 = (t) => Array.isArray(t); -function KS(t, e) { - if (!Array.isArray(e)) - return !1; - const r = e.length; - if (r !== t.length) - return !1; - for (let n = 0; n < r; n++) - if (e[n] !== t[n]) - return !1; - return !0; -} -function Ml(t) { - return typeof t == "string" || Array.isArray(t); -} -function W_(t) { - const e = [{}, {}]; - return t == null || t.values.forEach((r, n) => { - e[0][n] = r.get(), e[1][n] = r.getVelocity(); - }), e; -} -function Pb(t, e, r, n) { - if (typeof e == "function") { - const [i, s] = W_(n); - e = e(r !== void 0 ? r : t.custom, i, s); - } - if (typeof e == "string" && (e = t.variants && t.variants[e]), typeof e == "function") { - const [i, s] = W_(n); - e = e(r !== void 0 ? r : t.custom, i, s); - } - return e; -} -function bp(t, e, r) { - const n = t.getProps(); - return Pb(n, e, r !== void 0 ? r : n.custom, t); -} -const Mb = [ - "animate", - "whileInView", - "whileFocus", - "whileHover", - "whileTap", - "whileDrag", - "exit" -], Ib = ["initial", ...Mb], oh = [ - "transformPerspective", - "x", - "y", - "z", - "translateX", - "translateY", - "translateZ", - "scale", - "scaleX", - "scaleY", - "rotate", - "rotateX", - "rotateY", - "rotateZ", - "skew", - "skewX", - "skewY" -], Sc = new Set(oh), Ks = (t) => t * 1e3, Co = (t) => t / 1e3, cZ = { - type: "spring", - stiffness: 500, - damping: 25, - restSpeed: 10 -}, uZ = (t) => ({ - type: "spring", - stiffness: 550, - damping: t === 0 ? 2 * Math.sqrt(550) : 30, - restSpeed: 10 -}), fZ = { - type: "keyframes", - duration: 0.8 -}, lZ = { - type: "keyframes", - ease: [0.25, 0.1, 0.35, 1], - duration: 0.3 -}, hZ = (t, { keyframes: e }) => e.length > 2 ? fZ : Sc.has(t) ? t.startsWith("scale") ? uZ(e[1]) : cZ : lZ; -function Cb(t, e) { - return t ? t[e] || t.default || t : void 0; -} -const dZ = { - useManualTiming: !1 -}, pZ = (t) => t !== null; -function yp(t, { repeat: e, repeatType: r = "loop" }, n) { - const i = t.filter(pZ), s = e && r !== "loop" && e % 2 === 1 ? 0 : i.length - 1; - return !s || n === void 0 ? i[s] : n; -} -const Un = (t) => t; -function gZ(t) { - let e = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), n = !1, i = !1; - const s = /* @__PURE__ */ new WeakSet(); - let o = { - delta: 0, - timestamp: 0, - isProcessing: !1 - }; - function a(l) { - s.has(l) && (u.schedule(l), t()), l(o); - } - const u = { - /** - * Schedule a process to run on the next frame. - */ - schedule: (l, d = !1, g = !1) => { - const A = g && n ? e : r; - return d && s.add(l), A.has(l) || A.add(l), l; - }, - /** - * Cancel the provided callback from running on the next frame. - */ - cancel: (l) => { - r.delete(l), s.delete(l); - }, - /** - * Execute all schedule callbacks. - */ - process: (l) => { - if (o = l, n) { - i = !0; - return; - } - n = !0, [e, r] = [r, e], r.clear(), e.forEach(a), n = !1, i && (i = !1, u.process(l)); - } - }; - return u; -} -const pd = [ - "read", - // Read - "resolveKeyframes", - // Write/Read/Write/Read - "update", - // Compute - "preRender", - // Compute - "render", - // Write - "postRender" - // Compute -], mZ = 40; -function VS(t, e) { - let r = !1, n = !0; - const i = { - delta: 0, - timestamp: 0, - isProcessing: !1 - }, s = () => r = !0, o = pd.reduce((F, $) => (F[$] = gZ(s), F), {}), { read: a, resolveKeyframes: u, update: l, preRender: d, render: g, postRender: w } = o, A = () => { - const F = performance.now(); - r = !1, i.delta = n ? 1e3 / 60 : Math.max(Math.min(F - i.timestamp, mZ), 1), i.timestamp = F, i.isProcessing = !0, a.process(i), u.process(i), l.process(i), d.process(i), g.process(i), w.process(i), i.isProcessing = !1, r && e && (n = !1, t(A)); - }, M = () => { - r = !0, n = !0, i.isProcessing || t(A); - }; - return { schedule: pd.reduce((F, $) => { - const K = o[$]; - return F[$] = (H, V = !1, te = !1) => (r || M(), K.schedule(H, V, te)), F; - }, {}), cancel: (F) => { - for (let $ = 0; $ < pd.length; $++) - o[pd[$]].cancel(F); - }, state: i, steps: o }; -} -const { schedule: Lr, cancel: wa, state: Fn, steps: Dm } = VS(typeof requestAnimationFrame < "u" ? requestAnimationFrame : Un, !0), GS = (t, e, r) => (((1 - 3 * r + 3 * e) * t + (3 * r - 6 * e)) * t + 3 * e) * t, vZ = 1e-7, bZ = 12; -function yZ(t, e, r, n, i) { - let s, o, a = 0; - do - o = e + (r - e) / 2, s = GS(o, n, i) - t, s > 0 ? r = o : e = o; - while (Math.abs(s) > vZ && ++a < bZ); - return o; -} -function ah(t, e, r, n) { - if (t === e && r === n) - return Un; - const i = (s) => yZ(s, 0, 1, t, r); - return (s) => s === 0 || s === 1 ? s : GS(i(s), e, n); -} -const YS = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, JS = (t) => (e) => 1 - t(1 - e), XS = /* @__PURE__ */ ah(0.33, 1.53, 0.69, 0.99), Tb = /* @__PURE__ */ JS(XS), ZS = /* @__PURE__ */ YS(Tb), QS = (t) => (t *= 2) < 1 ? 0.5 * Tb(t) : 0.5 * (2 - Math.pow(2, -10 * (t - 1))), Rb = (t) => 1 - Math.sin(Math.acos(t)), e7 = JS(Rb), t7 = YS(Rb), r7 = (t) => /^0[^.\s]+$/u.test(t); -function wZ(t) { - return typeof t == "number" ? t === 0 : t !== null ? t === "none" || t === "0" || r7(t) : !0; -} -let Wu = Un, Uo = Un; -process.env.NODE_ENV !== "production" && (Wu = (t, e) => { - !t && typeof console < "u" && console.warn(e); -}, Uo = (t, e) => { - if (!t) - throw new Error(e); -}); -const n7 = (t) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t), i7 = (t) => (e) => typeof e == "string" && e.startsWith(t), s7 = /* @__PURE__ */ i7("--"), xZ = /* @__PURE__ */ i7("var(--"), Db = (t) => xZ(t) ? _Z.test(t.split("/*")[0].trim()) : !1, _Z = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu, EZ = ( - // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words - /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u -); -function SZ(t) { - const e = EZ.exec(t); - if (!e) - return [,]; - const [, r, n, i] = e; - return [`--${r ?? n}`, i]; -} -const AZ = 4; -function o7(t, e, r = 1) { - Uo(r <= AZ, `Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`); - const [n, i] = SZ(t); - if (!n) - return; - const s = window.getComputedStyle(e).getPropertyValue(n); - if (s) { - const o = s.trim(); - return n7(o) ? parseFloat(o) : o; - } - return Db(i) ? o7(i, e, r + 1) : i; -} -const xa = (t, e, r) => r > e ? e : r < t ? t : r, Ku = { - test: (t) => typeof t == "number", - parse: parseFloat, - transform: (t) => t -}, Il = { - ...Ku, - transform: (t) => xa(0, 1, t) -}, gd = { - ...Ku, - default: 1 -}, ch = (t) => ({ - test: (e) => typeof e == "string" && e.endsWith(t) && e.split(" ").length === 1, - parse: parseFloat, - transform: (e) => `${e}${t}` -}), sa = /* @__PURE__ */ ch("deg"), Vs = /* @__PURE__ */ ch("%"), Vt = /* @__PURE__ */ ch("px"), PZ = /* @__PURE__ */ ch("vh"), MZ = /* @__PURE__ */ ch("vw"), K_ = { - ...Vs, - parse: (t) => Vs.parse(t) / 100, - transform: (t) => Vs.transform(t * 100) -}, IZ = /* @__PURE__ */ new Set([ - "width", - "height", - "top", - "left", - "right", - "bottom", - "x", - "y", - "translateX", - "translateY" -]), V_ = (t) => t === Ku || t === Vt, G_ = (t, e) => parseFloat(t.split(", ")[e]), Y_ = (t, e) => (r, { transform: n }) => { - if (n === "none" || !n) - return 0; - const i = n.match(/^matrix3d\((.+)\)$/u); - if (i) - return G_(i[1], e); - { - const s = n.match(/^matrix\((.+)\)$/u); - return s ? G_(s[1], t) : 0; - } -}, CZ = /* @__PURE__ */ new Set(["x", "y", "z"]), TZ = oh.filter((t) => !CZ.has(t)); -function RZ(t) { - const e = []; - return TZ.forEach((r) => { - const n = t.getValue(r); - n !== void 0 && (e.push([r, n.get()]), n.set(r.startsWith("scale") ? 1 : 0)); - }), e; -} -const Pu = { - // Dimensions - width: ({ x: t }, { paddingLeft: e = "0", paddingRight: r = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(r), - height: ({ y: t }, { paddingTop: e = "0", paddingBottom: r = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(r), - top: (t, { top: e }) => parseFloat(e), - left: (t, { left: e }) => parseFloat(e), - bottom: ({ y: t }, { top: e }) => parseFloat(e) + (t.max - t.min), - right: ({ x: t }, { left: e }) => parseFloat(e) + (t.max - t.min), - // Transform - x: Y_(4, 13), - y: Y_(5, 14) -}; -Pu.translateX = Pu.x; -Pu.translateY = Pu.y; -const a7 = (t) => (e) => e.test(t), DZ = { - test: (t) => t === "auto", - parse: (t) => t -}, c7 = [Ku, Vt, Vs, sa, MZ, PZ, DZ], J_ = (t) => c7.find(a7(t)), ac = /* @__PURE__ */ new Set(); -let X1 = !1, Z1 = !1; -function u7() { - if (Z1) { - const t = Array.from(ac).filter((n) => n.needsMeasurement), e = new Set(t.map((n) => n.element)), r = /* @__PURE__ */ new Map(); - e.forEach((n) => { - const i = RZ(n); - i.length && (r.set(n, i), n.render()); - }), t.forEach((n) => n.measureInitialState()), e.forEach((n) => { - n.render(); - const i = r.get(n); - i && i.forEach(([s, o]) => { - var a; - (a = n.getValue(s)) === null || a === void 0 || a.set(o); - }); - }), t.forEach((n) => n.measureEndState()), t.forEach((n) => { - n.suspendedScrollY !== void 0 && window.scrollTo(0, n.suspendedScrollY); - }); - } - Z1 = !1, X1 = !1, ac.forEach((t) => t.complete()), ac.clear(); -} -function f7() { - ac.forEach((t) => { - t.readKeyframes(), t.needsMeasurement && (Z1 = !0); - }); -} -function OZ() { - f7(), u7(); -} -class Ob { - constructor(e, r, n, i, s, o = !1) { - this.isComplete = !1, this.isAsync = !1, this.needsMeasurement = !1, this.isScheduled = !1, this.unresolvedKeyframes = [...e], this.onComplete = r, this.name = n, this.motionValue = i, this.element = s, this.isAsync = o; - } - scheduleResolve() { - this.isScheduled = !0, this.isAsync ? (ac.add(this), X1 || (X1 = !0, Lr.read(f7), Lr.resolveKeyframes(u7))) : (this.readKeyframes(), this.complete()); - } - readKeyframes() { - const { unresolvedKeyframes: e, name: r, element: n, motionValue: i } = this; - for (let s = 0; s < e.length; s++) - if (e[s] === null) - if (s === 0) { - const o = i == null ? void 0 : i.get(), a = e[e.length - 1]; - if (o !== void 0) - e[0] = o; - else if (n && r) { - const u = n.readValue(r, a); - u != null && (e[0] = u); - } - e[0] === void 0 && (e[0] = a), i && o === void 0 && i.set(e[0]); - } else - e[s] = e[s - 1]; - } - setFinalKeyframe() { - } - measureInitialState() { - } - renderEndStyles() { - } - measureEndState() { - } - complete() { - this.isComplete = !0, this.onComplete(this.unresolvedKeyframes, this.finalKeyframe), ac.delete(this); - } - cancel() { - this.isComplete || (this.isScheduled = !1, ac.delete(this)); - } - resume() { - this.isComplete || this.scheduleResolve(); - } -} -const Gf = (t) => Math.round(t * 1e5) / 1e5, Nb = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu; -function NZ(t) { - return t == null; -} -const LZ = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu, Lb = (t, e) => (r) => !!(typeof r == "string" && LZ.test(r) && r.startsWith(t) || e && !NZ(r) && Object.prototype.hasOwnProperty.call(r, e)), l7 = (t, e, r) => (n) => { - if (typeof n != "string") - return n; - const [i, s, o, a] = n.match(Nb); - return { - [t]: parseFloat(i), - [e]: parseFloat(s), - [r]: parseFloat(o), - alpha: a !== void 0 ? parseFloat(a) : 1 - }; -}, kZ = (t) => xa(0, 255, t), Om = { - ...Ku, - transform: (t) => Math.round(kZ(t)) -}, ic = { - test: /* @__PURE__ */ Lb("rgb", "red"), - parse: /* @__PURE__ */ l7("red", "green", "blue"), - transform: ({ red: t, green: e, blue: r, alpha: n = 1 }) => "rgba(" + Om.transform(t) + ", " + Om.transform(e) + ", " + Om.transform(r) + ", " + Gf(Il.transform(n)) + ")" -}; -function $Z(t) { - let e = "", r = "", n = "", i = ""; - return t.length > 5 ? (e = t.substring(1, 3), r = t.substring(3, 5), n = t.substring(5, 7), i = t.substring(7, 9)) : (e = t.substring(1, 2), r = t.substring(2, 3), n = t.substring(3, 4), i = t.substring(4, 5), e += e, r += r, n += n, i += i), { - red: parseInt(e, 16), - green: parseInt(r, 16), - blue: parseInt(n, 16), - alpha: i ? parseInt(i, 16) / 255 : 1 - }; -} -const Q1 = { - test: /* @__PURE__ */ Lb("#"), - parse: $Z, - transform: ic.transform -}, Qc = { - test: /* @__PURE__ */ Lb("hsl", "hue"), - parse: /* @__PURE__ */ l7("hue", "saturation", "lightness"), - transform: ({ hue: t, saturation: e, lightness: r, alpha: n = 1 }) => "hsla(" + Math.round(t) + ", " + Vs.transform(Gf(e)) + ", " + Vs.transform(Gf(r)) + ", " + Gf(Il.transform(n)) + ")" -}, Gn = { - test: (t) => ic.test(t) || Q1.test(t) || Qc.test(t), - parse: (t) => ic.test(t) ? ic.parse(t) : Qc.test(t) ? Qc.parse(t) : Q1.parse(t), - transform: (t) => typeof t == "string" ? t : t.hasOwnProperty("red") ? ic.transform(t) : Qc.transform(t) -}, FZ = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu; -function BZ(t) { - var e, r; - return isNaN(t) && typeof t == "string" && (((e = t.match(Nb)) === null || e === void 0 ? void 0 : e.length) || 0) + (((r = t.match(FZ)) === null || r === void 0 ? void 0 : r.length) || 0) > 0; -} -const h7 = "number", d7 = "color", UZ = "var", jZ = "var(", X_ = "${}", qZ = /var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu; -function Cl(t) { - const e = t.toString(), r = [], n = { - color: [], - number: [], - var: [] - }, i = []; - let s = 0; - const a = e.replace(qZ, (u) => (Gn.test(u) ? (n.color.push(s), i.push(d7), r.push(Gn.parse(u))) : u.startsWith(jZ) ? (n.var.push(s), i.push(UZ), r.push(u)) : (n.number.push(s), i.push(h7), r.push(parseFloat(u))), ++s, X_)).split(X_); - return { values: r, split: a, indexes: n, types: i }; -} -function p7(t) { - return Cl(t).values; -} -function g7(t) { - const { split: e, types: r } = Cl(t), n = e.length; - return (i) => { - let s = ""; - for (let o = 0; o < n; o++) - if (s += e[o], i[o] !== void 0) { - const a = r[o]; - a === h7 ? s += Gf(i[o]) : a === d7 ? s += Gn.transform(i[o]) : s += i[o]; - } - return s; - }; -} -const zZ = (t) => typeof t == "number" ? 0 : t; -function HZ(t) { - const e = p7(t); - return g7(t)(e.map(zZ)); -} -const _a = { - test: BZ, - parse: p7, - createTransformer: g7, - getAnimatableNone: HZ -}, WZ = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]); -function KZ(t) { - const [e, r] = t.slice(0, -1).split("("); - if (e === "drop-shadow") - return t; - const [n] = r.match(Nb) || []; - if (!n) - return t; - const i = r.replace(n, ""); - let s = WZ.has(e) ? 1 : 0; - return n !== r && (s *= 100), e + "(" + s + i + ")"; -} -const VZ = /\b([a-z-]*)\(.*?\)/gu, ev = { - ..._a, - getAnimatableNone: (t) => { - const e = t.match(VZ); - return e ? e.map(KZ).join(" ") : t; - } -}, GZ = { - // Border props - borderWidth: Vt, - borderTopWidth: Vt, - borderRightWidth: Vt, - borderBottomWidth: Vt, - borderLeftWidth: Vt, - borderRadius: Vt, - radius: Vt, - borderTopLeftRadius: Vt, - borderTopRightRadius: Vt, - borderBottomRightRadius: Vt, - borderBottomLeftRadius: Vt, - // Positioning props - width: Vt, - maxWidth: Vt, - height: Vt, - maxHeight: Vt, - top: Vt, - right: Vt, - bottom: Vt, - left: Vt, - // Spacing props - padding: Vt, - paddingTop: Vt, - paddingRight: Vt, - paddingBottom: Vt, - paddingLeft: Vt, - margin: Vt, - marginTop: Vt, - marginRight: Vt, - marginBottom: Vt, - marginLeft: Vt, - // Misc - backgroundPositionX: Vt, - backgroundPositionY: Vt -}, YZ = { - rotate: sa, - rotateX: sa, - rotateY: sa, - rotateZ: sa, - scale: gd, - scaleX: gd, - scaleY: gd, - scaleZ: gd, - skew: sa, - skewX: sa, - skewY: sa, - distance: Vt, - translateX: Vt, - translateY: Vt, - translateZ: Vt, - x: Vt, - y: Vt, - z: Vt, - perspective: Vt, - transformPerspective: Vt, - opacity: Il, - originX: K_, - originY: K_, - originZ: Vt -}, Z_ = { - ...Ku, - transform: Math.round -}, kb = { - ...GZ, - ...YZ, - zIndex: Z_, - size: Vt, - // SVG - fillOpacity: Il, - strokeOpacity: Il, - numOctaves: Z_ -}, JZ = { - ...kb, - // Color props - color: Gn, - backgroundColor: Gn, - outlineColor: Gn, - fill: Gn, - stroke: Gn, - // Border props - borderColor: Gn, - borderTopColor: Gn, - borderRightColor: Gn, - borderBottomColor: Gn, - borderLeftColor: Gn, - filter: ev, - WebkitFilter: ev -}, $b = (t) => JZ[t]; -function m7(t, e) { - let r = $b(t); - return r !== ev && (r = _a), r.getAnimatableNone ? r.getAnimatableNone(e) : void 0; -} -const XZ = /* @__PURE__ */ new Set(["auto", "none", "0"]); -function ZZ(t, e, r) { - let n = 0, i; - for (; n < t.length && !i; ) { - const s = t[n]; - typeof s == "string" && !XZ.has(s) && Cl(s).values.length && (i = t[n]), n++; - } - if (i && r) - for (const s of e) - t[s] = m7(r, i); -} -class v7 extends Ob { - constructor(e, r, n, i, s) { - super(e, r, n, i, s, !0); - } - readKeyframes() { - const { unresolvedKeyframes: e, element: r, name: n } = this; - if (!r || !r.current) - return; - super.readKeyframes(); - for (let u = 0; u < e.length; u++) { - let l = e[u]; - if (typeof l == "string" && (l = l.trim(), Db(l))) { - const d = o7(l, r.current); - d !== void 0 && (e[u] = d), u === e.length - 1 && (this.finalKeyframe = l); - } - } - if (this.resolveNoneKeyframes(), !IZ.has(n) || e.length !== 2) - return; - const [i, s] = e, o = J_(i), a = J_(s); - if (o !== a) - if (V_(o) && V_(a)) - for (let u = 0; u < e.length; u++) { - const l = e[u]; - typeof l == "string" && (e[u] = parseFloat(l)); - } - else - this.needsMeasurement = !0; - } - resolveNoneKeyframes() { - const { unresolvedKeyframes: e, name: r } = this, n = []; - for (let i = 0; i < e.length; i++) - wZ(e[i]) && n.push(i); - n.length && ZZ(e, n, r); - } - measureInitialState() { - const { element: e, unresolvedKeyframes: r, name: n } = this; - if (!e || !e.current) - return; - n === "height" && (this.suspendedScrollY = window.pageYOffset), this.measuredOrigin = Pu[n](e.measureViewportBox(), window.getComputedStyle(e.current)), r[0] = this.measuredOrigin; - const i = r[r.length - 1]; - i !== void 0 && e.getValue(n, i).jump(i, !1); - } - measureEndState() { - var e; - const { element: r, name: n, unresolvedKeyframes: i } = this; - if (!r || !r.current) - return; - const s = r.getValue(n); - s && s.jump(this.measuredOrigin, !1); - const o = i.length - 1, a = i[o]; - i[o] = Pu[n](r.measureViewportBox(), window.getComputedStyle(r.current)), a !== null && this.finalKeyframe === void 0 && (this.finalKeyframe = a), !((e = this.removedTransforms) === null || e === void 0) && e.length && this.removedTransforms.forEach(([u, l]) => { - r.getValue(u).set(l); - }), this.resolveNoneKeyframes(); - } -} -function Fb(t) { - return typeof t == "function"; -} -let Fd; -function QZ() { - Fd = void 0; -} -const Gs = { - now: () => (Fd === void 0 && Gs.set(Fn.isProcessing || dZ.useManualTiming ? Fn.timestamp : performance.now()), Fd), - set: (t) => { - Fd = t, queueMicrotask(QZ); - } -}, Q_ = (t, e) => e === "zIndex" ? !1 : !!(typeof t == "number" || Array.isArray(t) || typeof t == "string" && // It's animatable if we have a string -(_a.test(t) || t === "0") && // And it contains numbers and/or colors -!t.startsWith("url(")); -function eQ(t) { - const e = t[0]; - if (t.length === 1) - return !0; - for (let r = 0; r < t.length; r++) - if (t[r] !== e) - return !0; -} -function tQ(t, e, r, n) { - const i = t[0]; - if (i === null) - return !1; - if (e === "display" || e === "visibility") - return !0; - const s = t[t.length - 1], o = Q_(i, e), a = Q_(s, e); - return Wu(o === a, `You are trying to animate ${e} from "${i}" to "${s}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${s} via the \`style\` property.`), !o || !a ? !1 : eQ(t) || (r === "spring" || Fb(r)) && n; -} -const rQ = 40; -class b7 { - constructor({ autoplay: e = !0, delay: r = 0, type: n = "keyframes", repeat: i = 0, repeatDelay: s = 0, repeatType: o = "loop", ...a }) { - this.isStopped = !1, this.hasAttemptedResolve = !1, this.createdAt = Gs.now(), this.options = { - autoplay: e, - delay: r, - type: n, - repeat: i, - repeatDelay: s, - repeatType: o, - ...a - }, this.updateFinishedPromise(); - } - /** - * This method uses the createdAt and resolvedAt to calculate the - * animation startTime. *Ideally*, we would use the createdAt time as t=0 - * as the following frame would then be the first frame of the animation in - * progress, which would feel snappier. - * - * However, if there's a delay (main thread work) between the creation of - * the animation and the first commited frame, we prefer to use resolvedAt - * to avoid a sudden jump into the animation. - */ - calcStartTime() { - return this.resolvedAt ? this.resolvedAt - this.createdAt > rQ ? this.resolvedAt : this.createdAt : this.createdAt; - } - /** - * A getter for resolved data. If keyframes are not yet resolved, accessing - * this.resolved will synchronously flush all pending keyframe resolvers. - * This is a deoptimisation, but at its worst still batches read/writes. - */ - get resolved() { - return !this._resolved && !this.hasAttemptedResolve && OZ(), this._resolved; - } - /** - * A method to be called when the keyframes resolver completes. This method - * will check if its possible to run the animation and, if not, skip it. - * Otherwise, it will call initPlayback on the implementing class. - */ - onKeyframesResolved(e, r) { - this.resolvedAt = Gs.now(), this.hasAttemptedResolve = !0; - const { name: n, type: i, velocity: s, delay: o, onComplete: a, onUpdate: u, isGenerator: l } = this.options; - if (!l && !tQ(e, n, i, s)) - if (o) - this.options.duration = 0; - else { - u == null || u(yp(e, this.options, r)), a == null || a(), this.resolveFinishedPromise(); - return; - } - const d = this.initPlayback(e, r); - d !== !1 && (this._resolved = { - keyframes: e, - finalKeyframe: r, - ...d - }, this.onPostResolved()); - } - onPostResolved() { - } - /** - * Allows the returned animation to be awaited or promise-chained. Currently - * resolves when the animation finishes at all but in a future update could/should - * reject if its cancels. - */ - then(e, r) { - return this.currentFinishedPromise.then(e, r); - } - flatten() { - this.options.type = "keyframes", this.options.ease = "linear"; - } - updateFinishedPromise() { - this.currentFinishedPromise = new Promise((e) => { - this.resolveFinishedPromise = e; - }); - } -} -function y7(t, e) { - return e ? t * (1e3 / e) : 0; -} -const nQ = 5; -function w7(t, e, r) { - const n = Math.max(e - nQ, 0); - return y7(r - t(n), e - n); -} -const Nm = 1e-3, iQ = 0.01, e6 = 10, sQ = 0.05, oQ = 1; -function aQ({ duration: t = 800, bounce: e = 0.25, velocity: r = 0, mass: n = 1 }) { - let i, s; - Wu(t <= Ks(e6), "Spring duration must be 10 seconds or less"); - let o = 1 - e; - o = xa(sQ, oQ, o), t = xa(iQ, e6, Co(t)), o < 1 ? (i = (l) => { - const d = l * o, g = d * t, w = d - r, A = tv(l, o), M = Math.exp(-g); - return Nm - w / A * M; - }, s = (l) => { - const g = l * o * t, w = g * r + r, A = Math.pow(o, 2) * Math.pow(l, 2) * t, M = Math.exp(-g), N = tv(Math.pow(l, 2), o); - return (-i(l) + Nm > 0 ? -1 : 1) * ((w - A) * M) / N; - }) : (i = (l) => { - const d = Math.exp(-l * t), g = (l - r) * t + 1; - return -Nm + d * g; - }, s = (l) => { - const d = Math.exp(-l * t), g = (r - l) * (t * t); - return d * g; - }); - const a = 5 / t, u = uQ(i, s, a); - if (t = Ks(t), isNaN(u)) - return { - stiffness: 100, - damping: 10, - duration: t - }; - { - const l = Math.pow(u, 2) * n; - return { - stiffness: l, - damping: o * 2 * Math.sqrt(n * l), - duration: t - }; - } -} -const cQ = 12; -function uQ(t, e, r) { - let n = r; - for (let i = 1; i < cQ; i++) - n = n - t(n) / e(n); - return n; -} -function tv(t, e) { - return t * Math.sqrt(1 - e * e); -} -const fQ = ["duration", "bounce"], lQ = ["stiffness", "damping", "mass"]; -function t6(t, e) { - return e.some((r) => t[r] !== void 0); -} -function hQ(t) { - let e = { - velocity: 0, - stiffness: 100, - damping: 10, - mass: 1, - isResolvedFromDuration: !1, - ...t - }; - if (!t6(t, lQ) && t6(t, fQ)) { - const r = aQ(t); - e = { - ...e, - ...r, - mass: 1 - }, e.isResolvedFromDuration = !0; - } - return e; -} -function x7({ keyframes: t, restDelta: e, restSpeed: r, ...n }) { - const i = t[0], s = t[t.length - 1], o = { done: !1, value: i }, { stiffness: a, damping: u, mass: l, duration: d, velocity: g, isResolvedFromDuration: w } = hQ({ - ...n, - velocity: -Co(n.velocity || 0) - }), A = g || 0, M = u / (2 * Math.sqrt(a * l)), N = s - i, L = Co(Math.sqrt(a / l)), F = Math.abs(N) < 5; - r || (r = F ? 0.01 : 2), e || (e = F ? 5e-3 : 0.5); - let $; - if (M < 1) { - const K = tv(L, M); - $ = (H) => { - const V = Math.exp(-M * L * H); - return s - V * ((A + M * L * N) / K * Math.sin(K * H) + N * Math.cos(K * H)); - }; - } else if (M === 1) - $ = (K) => s - Math.exp(-L * K) * (N + (A + L * N) * K); - else { - const K = L * Math.sqrt(M * M - 1); - $ = (H) => { - const V = Math.exp(-M * L * H), te = Math.min(K * H, 300); - return s - V * ((A + M * L * N) * Math.sinh(te) + K * N * Math.cosh(te)) / K; - }; - } - return { - calculatedDuration: w && d || null, - next: (K) => { - const H = $(K); - if (w) - o.done = K >= d; - else { - let V = 0; - M < 1 && (V = K === 0 ? Ks(A) : w7($, K, H)); - const te = Math.abs(V) <= r, R = Math.abs(s - H) <= e; - o.done = te && R; - } - return o.value = o.done ? s : H, o; - } - }; -} -function r6({ keyframes: t, velocity: e = 0, power: r = 0.8, timeConstant: n = 325, bounceDamping: i = 10, bounceStiffness: s = 500, modifyTarget: o, min: a, max: u, restDelta: l = 0.5, restSpeed: d }) { - const g = t[0], w = { - done: !1, - value: g - }, A = (W) => a !== void 0 && W < a || u !== void 0 && W > u, M = (W) => a === void 0 ? u : u === void 0 || Math.abs(a - W) < Math.abs(u - W) ? a : u; - let N = r * e; - const L = g + N, F = o === void 0 ? L : o(L); - F !== L && (N = F - g); - const $ = (W) => -N * Math.exp(-W / n), K = (W) => F + $(W), H = (W) => { - const pe = $(W), Ee = K(W); - w.done = Math.abs(pe) <= l, w.value = w.done ? F : Ee; - }; - let V, te; - const R = (W) => { - A(w.value) && (V = W, te = x7({ - keyframes: [w.value, M(w.value)], - velocity: w7(K, W, w.value), - // TODO: This should be passing * 1000 - damping: i, - stiffness: s, - restDelta: l, - restSpeed: d - })); - }; - return R(0), { - calculatedDuration: null, - next: (W) => { - let pe = !1; - return !te && V === void 0 && (pe = !0, H(W), R(W)), V !== void 0 && W >= V ? te.next(W - V) : (!pe && H(W), w); - } - }; -} -const dQ = /* @__PURE__ */ ah(0.42, 0, 1, 1), pQ = /* @__PURE__ */ ah(0, 0, 0.58, 1), _7 = /* @__PURE__ */ ah(0.42, 0, 0.58, 1), gQ = (t) => Array.isArray(t) && typeof t[0] != "number", Bb = (t) => Array.isArray(t) && typeof t[0] == "number", n6 = { - linear: Un, - easeIn: dQ, - easeInOut: _7, - easeOut: pQ, - circIn: Rb, - circInOut: t7, - circOut: e7, - backIn: Tb, - backInOut: ZS, - backOut: XS, - anticipate: QS -}, i6 = (t) => { - if (Bb(t)) { - Uo(t.length === 4, "Cubic bezier arrays must contain four numerical values."); - const [e, r, n, i] = t; - return ah(e, r, n, i); - } else if (typeof t == "string") - return Uo(n6[t] !== void 0, `Invalid easing type '${t}'`), n6[t]; - return t; -}, mQ = (t, e) => (r) => e(t(r)), To = (...t) => t.reduce(mQ), Mu = (t, e, r) => { - const n = e - t; - return n === 0 ? 1 : (r - t) / n; -}, Qr = (t, e, r) => t + (e - t) * r; -function Lm(t, e, r) { - return r < 0 && (r += 1), r > 1 && (r -= 1), r < 1 / 6 ? t + (e - t) * 6 * r : r < 1 / 2 ? e : r < 2 / 3 ? t + (e - t) * (2 / 3 - r) * 6 : t; -} -function vQ({ hue: t, saturation: e, lightness: r, alpha: n }) { - t /= 360, e /= 100, r /= 100; - let i = 0, s = 0, o = 0; - if (!e) - i = s = o = r; - else { - const a = r < 0.5 ? r * (1 + e) : r + e - r * e, u = 2 * r - a; - i = Lm(u, a, t + 1 / 3), s = Lm(u, a, t), o = Lm(u, a, t - 1 / 3); - } - return { - red: Math.round(i * 255), - green: Math.round(s * 255), - blue: Math.round(o * 255), - alpha: n - }; -} -function m0(t, e) { - return (r) => r > 0 ? e : t; -} -const km = (t, e, r) => { - const n = t * t, i = r * (e * e - n) + n; - return i < 0 ? 0 : Math.sqrt(i); -}, bQ = [Q1, ic, Qc], yQ = (t) => bQ.find((e) => e.test(t)); -function s6(t) { - const e = yQ(t); - if (Wu(!!e, `'${t}' is not an animatable color. Use the equivalent color code instead.`), !e) - return !1; - let r = e.parse(t); - return e === Qc && (r = vQ(r)), r; -} -const o6 = (t, e) => { - const r = s6(t), n = s6(e); - if (!r || !n) - return m0(t, e); - const i = { ...r }; - return (s) => (i.red = km(r.red, n.red, s), i.green = km(r.green, n.green, s), i.blue = km(r.blue, n.blue, s), i.alpha = Qr(r.alpha, n.alpha, s), ic.transform(i)); -}, rv = /* @__PURE__ */ new Set(["none", "hidden"]); -function wQ(t, e) { - return rv.has(t) ? (r) => r <= 0 ? t : e : (r) => r >= 1 ? e : t; -} -function xQ(t, e) { - return (r) => Qr(t, e, r); -} -function Ub(t) { - return typeof t == "number" ? xQ : typeof t == "string" ? Db(t) ? m0 : Gn.test(t) ? o6 : SQ : Array.isArray(t) ? E7 : typeof t == "object" ? Gn.test(t) ? o6 : _Q : m0; -} -function E7(t, e) { - const r = [...t], n = r.length, i = t.map((s, o) => Ub(s)(s, e[o])); - return (s) => { - for (let o = 0; o < n; o++) - r[o] = i[o](s); - return r; - }; -} -function _Q(t, e) { - const r = { ...t, ...e }, n = {}; - for (const i in r) - t[i] !== void 0 && e[i] !== void 0 && (n[i] = Ub(t[i])(t[i], e[i])); - return (i) => { - for (const s in n) - r[s] = n[s](i); - return r; - }; -} -function EQ(t, e) { - var r; - const n = [], i = { color: 0, var: 0, number: 0 }; - for (let s = 0; s < e.values.length; s++) { - const o = e.types[s], a = t.indexes[o][i[o]], u = (r = t.values[a]) !== null && r !== void 0 ? r : 0; - n[s] = u, i[o]++; - } - return n; -} -const SQ = (t, e) => { - const r = _a.createTransformer(e), n = Cl(t), i = Cl(e); - return n.indexes.var.length === i.indexes.var.length && n.indexes.color.length === i.indexes.color.length && n.indexes.number.length >= i.indexes.number.length ? rv.has(t) && !i.values.length || rv.has(e) && !n.values.length ? wQ(t, e) : To(E7(EQ(n, i), i.values), r) : (Wu(!0, `Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`), m0(t, e)); -}; -function S7(t, e, r) { - return typeof t == "number" && typeof e == "number" && typeof r == "number" ? Qr(t, e, r) : Ub(t)(t, e); -} -function AQ(t, e, r) { - const n = [], i = r || S7, s = t.length - 1; - for (let o = 0; o < s; o++) { - let a = i(t[o], t[o + 1]); - if (e) { - const u = Array.isArray(e) ? e[o] || Un : e; - a = To(u, a); - } - n.push(a); - } - return n; -} -function PQ(t, e, { clamp: r = !0, ease: n, mixer: i } = {}) { - const s = t.length; - if (Uo(s === e.length, "Both input and output ranges must be the same length"), s === 1) - return () => e[0]; - if (s === 2 && t[0] === t[1]) - return () => e[1]; - t[0] > t[s - 1] && (t = [...t].reverse(), e = [...e].reverse()); - const o = AQ(e, n, i), a = o.length, u = (l) => { - let d = 0; - if (a > 1) - for (; d < t.length - 2 && !(l < t[d + 1]); d++) - ; - const g = Mu(t[d], t[d + 1], l); - return o[d](g); - }; - return r ? (l) => u(xa(t[0], t[s - 1], l)) : u; -} -function MQ(t, e) { - const r = t[t.length - 1]; - for (let n = 1; n <= e; n++) { - const i = Mu(0, e, n); - t.push(Qr(r, 1, i)); - } -} -function IQ(t) { - const e = [0]; - return MQ(e, t.length - 1), e; -} -function CQ(t, e) { - return t.map((r) => r * e); -} -function TQ(t, e) { - return t.map(() => e || _7).splice(0, t.length - 1); -} -function v0({ duration: t = 300, keyframes: e, times: r, ease: n = "easeInOut" }) { - const i = gQ(n) ? n.map(i6) : i6(n), s = { - done: !1, - value: e[0] - }, o = CQ( - // Only use the provided offsets if they're the correct length - // TODO Maybe we should warn here if there's a length mismatch - r && r.length === e.length ? r : IQ(e), - t - ), a = PQ(o, e, { - ease: Array.isArray(i) ? i : TQ(e, i) - }); - return { - calculatedDuration: t, - next: (u) => (s.value = a(u), s.done = u >= t, s) - }; -} -const a6 = 2e4; -function RQ(t) { - let e = 0; - const r = 50; - let n = t.next(e); - for (; !n.done && e < a6; ) - e += r, n = t.next(e); - return e >= a6 ? 1 / 0 : e; -} -const DQ = (t) => { - const e = ({ timestamp: r }) => t(r); - return { - start: () => Lr.update(e, !0), - stop: () => wa(e), - /** - * If we're processing this frame we can use the - * framelocked timestamp to keep things in sync. - */ - now: () => Fn.isProcessing ? Fn.timestamp : Gs.now() - }; -}, OQ = { - decay: r6, - inertia: r6, - tween: v0, - keyframes: v0, - spring: x7 -}, NQ = (t) => t / 100; -class jb extends b7 { - constructor(e) { - super(e), this.holdTime = null, this.cancelTime = null, this.currentTime = 0, this.playbackSpeed = 1, this.pendingPlayState = "running", this.startTime = null, this.state = "idle", this.stop = () => { - if (this.resolver.cancel(), this.isStopped = !0, this.state === "idle") - return; - this.teardown(); - const { onStop: u } = this.options; - u && u(); - }; - const { name: r, motionValue: n, element: i, keyframes: s } = this.options, o = (i == null ? void 0 : i.KeyframeResolver) || Ob, a = (u, l) => this.onKeyframesResolved(u, l); - this.resolver = new o(s, a, r, n, i), this.resolver.scheduleResolve(); - } - flatten() { - super.flatten(), this._resolved && Object.assign(this._resolved, this.initPlayback(this._resolved.keyframes)); - } - initPlayback(e) { - const { type: r = "keyframes", repeat: n = 0, repeatDelay: i = 0, repeatType: s, velocity: o = 0 } = this.options, a = Fb(r) ? r : OQ[r] || v0; - let u, l; - a !== v0 && typeof e[0] != "number" && (process.env.NODE_ENV !== "production" && Uo(e.length === 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${e}`), u = To(NQ, S7(e[0], e[1])), e = [0, 100]); - const d = a({ ...this.options, keyframes: e }); - s === "mirror" && (l = a({ - ...this.options, - keyframes: [...e].reverse(), - velocity: -o - })), d.calculatedDuration === null && (d.calculatedDuration = RQ(d)); - const { calculatedDuration: g } = d, w = g + i, A = w * (n + 1) - i; - return { - generator: d, - mirroredGenerator: l, - mapPercentToKeyframes: u, - calculatedDuration: g, - resolvedDuration: w, - totalDuration: A - }; - } - onPostResolved() { - const { autoplay: e = !0 } = this.options; - this.play(), this.pendingPlayState === "paused" || !e ? this.pause() : this.state = this.pendingPlayState; - } - tick(e, r = !1) { - const { resolved: n } = this; - if (!n) { - const { keyframes: W } = this.options; - return { done: !0, value: W[W.length - 1] }; - } - const { finalKeyframe: i, generator: s, mirroredGenerator: o, mapPercentToKeyframes: a, keyframes: u, calculatedDuration: l, totalDuration: d, resolvedDuration: g } = n; - if (this.startTime === null) - return s.next(0); - const { delay: w, repeat: A, repeatType: M, repeatDelay: N, onUpdate: L } = this.options; - this.speed > 0 ? this.startTime = Math.min(this.startTime, e) : this.speed < 0 && (this.startTime = Math.min(e - d / this.speed, this.startTime)), r ? this.currentTime = e : this.holdTime !== null ? this.currentTime = this.holdTime : this.currentTime = Math.round(e - this.startTime) * this.speed; - const F = this.currentTime - w * (this.speed >= 0 ? 1 : -1), $ = this.speed >= 0 ? F < 0 : F > d; - this.currentTime = Math.max(F, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = d); - let K = this.currentTime, H = s; - if (A) { - const W = Math.min(this.currentTime, d) / g; - let pe = Math.floor(W), Ee = W % 1; - !Ee && W >= 1 && (Ee = 1), Ee === 1 && pe--, pe = Math.min(pe, A + 1), !!(pe % 2) && (M === "reverse" ? (Ee = 1 - Ee, N && (Ee -= N / g)) : M === "mirror" && (H = o)), K = xa(0, 1, Ee) * g; - } - const V = $ ? { done: !1, value: u[0] } : H.next(K); - a && (V.value = a(V.value)); - let { done: te } = V; - !$ && l !== null && (te = this.speed >= 0 ? this.currentTime >= d : this.currentTime <= 0); - const R = this.holdTime === null && (this.state === "finished" || this.state === "running" && te); - return R && i !== void 0 && (V.value = yp(u, this.options, i)), L && L(V.value), R && this.finish(), V; - } - get duration() { - const { resolved: e } = this; - return e ? Co(e.calculatedDuration) : 0; - } - get time() { - return Co(this.currentTime); - } - set time(e) { - e = Ks(e), this.currentTime = e, this.holdTime !== null || this.speed === 0 ? this.holdTime = e : this.driver && (this.startTime = this.driver.now() - e / this.speed); - } - get speed() { - return this.playbackSpeed; - } - set speed(e) { - const r = this.playbackSpeed !== e; - this.playbackSpeed = e, r && (this.time = Co(this.currentTime)); - } - play() { - if (this.resolver.isScheduled || this.resolver.resume(), !this._resolved) { - this.pendingPlayState = "running"; - return; - } - if (this.isStopped) - return; - const { driver: e = DQ, onPlay: r, startTime: n } = this.options; - this.driver || (this.driver = e((s) => this.tick(s))), r && r(); - const i = this.driver.now(); - this.holdTime !== null ? this.startTime = i - this.holdTime : this.startTime ? this.state === "finished" && (this.startTime = i) : this.startTime = n ?? this.calcStartTime(), this.state === "finished" && this.updateFinishedPromise(), this.cancelTime = this.startTime, this.holdTime = null, this.state = "running", this.driver.start(); - } - pause() { - var e; - if (!this._resolved) { - this.pendingPlayState = "paused"; - return; - } - this.state = "paused", this.holdTime = (e = this.currentTime) !== null && e !== void 0 ? e : 0; - } - complete() { - this.state !== "running" && this.play(), this.pendingPlayState = this.state = "finished", this.holdTime = null; - } - finish() { - this.teardown(), this.state = "finished"; - const { onComplete: e } = this.options; - e && e(); - } - cancel() { - this.cancelTime !== null && this.tick(this.cancelTime), this.teardown(), this.updateFinishedPromise(); - } - teardown() { - this.state = "idle", this.stopDriver(), this.resolveFinishedPromise(), this.updateFinishedPromise(), this.startTime = this.cancelTime = null, this.resolver.cancel(); - } - stopDriver() { - this.driver && (this.driver.stop(), this.driver = void 0); - } - sample(e) { - return this.startTime = 0, this.tick(e, !0); - } -} -const LQ = /* @__PURE__ */ new Set([ - "opacity", - "clipPath", - "filter", - "transform" - // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved - // or until we implement support for linear() easing. - // "background-color" -]), kQ = 10, $Q = (t, e) => { - let r = ""; - const n = Math.max(Math.round(e / kQ), 2); - for (let i = 0; i < n; i++) - r += t(Mu(0, n - 1, i)) + ", "; - return `linear(${r.substring(0, r.length - 2)})`; -}; -function qb(t) { - let e; - return () => (e === void 0 && (e = t()), e); -} -const FQ = { - linearEasing: void 0 -}; -function BQ(t, e) { - const r = qb(t); - return () => { - var n; - return (n = FQ[e]) !== null && n !== void 0 ? n : r(); - }; -} -const b0 = /* @__PURE__ */ BQ(() => { - try { - document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" }); - } catch { - return !1; - } - return !0; -}, "linearEasing"); -function A7(t) { - return !!(typeof t == "function" && b0() || !t || typeof t == "string" && (t in nv || b0()) || Bb(t) || Array.isArray(t) && t.every(A7)); -} -const Bf = ([t, e, r, n]) => `cubic-bezier(${t}, ${e}, ${r}, ${n})`, nv = { - linear: "linear", - ease: "ease", - easeIn: "ease-in", - easeOut: "ease-out", - easeInOut: "ease-in-out", - circIn: /* @__PURE__ */ Bf([0, 0.65, 0.55, 1]), - circOut: /* @__PURE__ */ Bf([0.55, 0, 1, 0.45]), - backIn: /* @__PURE__ */ Bf([0.31, 0.01, 0.66, -0.59]), - backOut: /* @__PURE__ */ Bf([0.33, 1.53, 0.69, 0.99]) -}; -function P7(t, e) { - if (t) - return typeof t == "function" && b0() ? $Q(t, e) : Bb(t) ? Bf(t) : Array.isArray(t) ? t.map((r) => P7(r, e) || nv.easeOut) : nv[t]; -} -function UQ(t, e, r, { delay: n = 0, duration: i = 300, repeat: s = 0, repeatType: o = "loop", ease: a = "easeInOut", times: u } = {}) { - const l = { [e]: r }; - u && (l.offset = u); - const d = P7(a, i); - return Array.isArray(d) && (l.easing = d), t.animate(l, { - delay: n, - duration: i, - easing: Array.isArray(d) ? "linear" : d, - fill: "both", - iterations: s + 1, - direction: o === "reverse" ? "alternate" : "normal" - }); -} -function c6(t, e) { - t.timeline = e, t.onfinish = null; -} -const jQ = /* @__PURE__ */ qb(() => Object.hasOwnProperty.call(Element.prototype, "animate")), y0 = 10, qQ = 2e4; -function zQ(t) { - return Fb(t.type) || t.type === "spring" || !A7(t.ease); -} -function HQ(t, e) { - const r = new jb({ - ...e, - keyframes: t, - repeat: 0, - delay: 0, - isGenerator: !0 - }); - let n = { done: !1, value: t[0] }; - const i = []; - let s = 0; - for (; !n.done && s < qQ; ) - n = r.sample(s), i.push(n.value), s += y0; - return { - times: void 0, - keyframes: i, - duration: s - y0, - ease: "linear" - }; -} -const M7 = { - anticipate: QS, - backInOut: ZS, - circInOut: t7 -}; -function WQ(t) { - return t in M7; -} -class u6 extends b7 { - constructor(e) { - super(e); - const { name: r, motionValue: n, element: i, keyframes: s } = this.options; - this.resolver = new v7(s, (o, a) => this.onKeyframesResolved(o, a), r, n, i), this.resolver.scheduleResolve(); - } - initPlayback(e, r) { - var n; - let { duration: i = 300, times: s, ease: o, type: a, motionValue: u, name: l, startTime: d } = this.options; - if (!(!((n = u.owner) === null || n === void 0) && n.current)) - return !1; - if (typeof o == "string" && b0() && WQ(o) && (o = M7[o]), zQ(this.options)) { - const { onComplete: w, onUpdate: A, motionValue: M, element: N, ...L } = this.options, F = HQ(e, L); - e = F.keyframes, e.length === 1 && (e[1] = e[0]), i = F.duration, s = F.times, o = F.ease, a = "keyframes"; - } - const g = UQ(u.owner.current, l, e, { ...this.options, duration: i, times: s, ease: o }); - return g.startTime = d ?? this.calcStartTime(), this.pendingTimeline ? (c6(g, this.pendingTimeline), this.pendingTimeline = void 0) : g.onfinish = () => { - const { onComplete: w } = this.options; - u.set(yp(e, this.options, r)), w && w(), this.cancel(), this.resolveFinishedPromise(); - }, { - animation: g, - duration: i, - times: s, - type: a, - ease: o, - keyframes: e - }; - } - get duration() { - const { resolved: e } = this; - if (!e) - return 0; - const { duration: r } = e; - return Co(r); - } - get time() { - const { resolved: e } = this; - if (!e) - return 0; - const { animation: r } = e; - return Co(r.currentTime || 0); - } - set time(e) { - const { resolved: r } = this; - if (!r) - return; - const { animation: n } = r; - n.currentTime = Ks(e); - } - get speed() { - const { resolved: e } = this; - if (!e) - return 1; - const { animation: r } = e; - return r.playbackRate; - } - set speed(e) { - const { resolved: r } = this; - if (!r) - return; - const { animation: n } = r; - n.playbackRate = e; - } - get state() { - const { resolved: e } = this; - if (!e) - return "idle"; - const { animation: r } = e; - return r.playState; - } - get startTime() { - const { resolved: e } = this; - if (!e) - return null; - const { animation: r } = e; - return r.startTime; - } - /** - * Replace the default DocumentTimeline with another AnimationTimeline. - * Currently used for scroll animations. - */ - attachTimeline(e) { - if (!this._resolved) - this.pendingTimeline = e; - else { - const { resolved: r } = this; - if (!r) - return Un; - const { animation: n } = r; - c6(n, e); - } - return Un; - } - play() { - if (this.isStopped) - return; - const { resolved: e } = this; - if (!e) - return; - const { animation: r } = e; - r.playState === "finished" && this.updateFinishedPromise(), r.play(); - } - pause() { - const { resolved: e } = this; - if (!e) - return; - const { animation: r } = e; - r.pause(); - } - stop() { - if (this.resolver.cancel(), this.isStopped = !0, this.state === "idle") - return; - this.resolveFinishedPromise(), this.updateFinishedPromise(); - const { resolved: e } = this; - if (!e) - return; - const { animation: r, keyframes: n, duration: i, type: s, ease: o, times: a } = e; - if (r.playState === "idle" || r.playState === "finished") - return; - if (this.time) { - const { motionValue: l, onUpdate: d, onComplete: g, element: w, ...A } = this.options, M = new jb({ - ...A, - keyframes: n, - duration: i, - type: s, - ease: o, - times: a, - isGenerator: !0 - }), N = Ks(this.time); - l.setWithVelocity(M.sample(N - y0).value, M.sample(N).value, y0); - } - const { onStop: u } = this.options; - u && u(), this.cancel(); - } - complete() { - const { resolved: e } = this; - e && e.animation.finish(); - } - cancel() { - const { resolved: e } = this; - e && e.animation.cancel(); - } - static supports(e) { - const { motionValue: r, name: n, repeatDelay: i, repeatType: s, damping: o, type: a } = e; - return jQ() && n && LQ.has(n) && r && r.owner && r.owner.current instanceof HTMLElement && /** - * If we're outputting values to onUpdate then we can't use WAAPI as there's - * no way to read the value from WAAPI every frame. - */ - !r.owner.getProps().onUpdate && !i && s !== "mirror" && o !== 0 && a !== "inertia"; - } -} -const KQ = qb(() => window.ScrollTimeline !== void 0); -class VQ { - constructor(e) { - this.stop = () => this.runAll("stop"), this.animations = e.filter(Boolean); - } - then(e, r) { - return Promise.all(this.animations).then(e).catch(r); - } - /** - * TODO: Filter out cancelled or stopped animations before returning - */ - getAll(e) { - return this.animations[0][e]; - } - setAll(e, r) { - for (let n = 0; n < this.animations.length; n++) - this.animations[n][e] = r; - } - attachTimeline(e, r) { - const n = this.animations.map((i) => KQ() && i.attachTimeline ? i.attachTimeline(e) : r(i)); - return () => { - n.forEach((i, s) => { - i && i(), this.animations[s].stop(); - }); - }; - } - get time() { - return this.getAll("time"); - } - set time(e) { - this.setAll("time", e); - } - get speed() { - return this.getAll("speed"); - } - set speed(e) { - this.setAll("speed", e); - } - get startTime() { - return this.getAll("startTime"); - } - get duration() { - let e = 0; - for (let r = 0; r < this.animations.length; r++) - e = Math.max(e, this.animations[r].duration); - return e; - } - runAll(e) { - this.animations.forEach((r) => r[e]()); - } - flatten() { - this.runAll("flatten"); - } - play() { - this.runAll("play"); - } - pause() { - this.runAll("pause"); - } - cancel() { - this.runAll("cancel"); - } - complete() { - this.runAll("complete"); - } -} -function GQ({ when: t, delay: e, delayChildren: r, staggerChildren: n, staggerDirection: i, repeat: s, repeatType: o, repeatDelay: a, from: u, elapsed: l, ...d }) { - return !!Object.keys(d).length; -} -const zb = (t, e, r, n = {}, i, s) => (o) => { - const a = Cb(n, t) || {}, u = a.delay || n.delay || 0; - let { elapsed: l = 0 } = n; - l = l - Ks(u); - let d = { - keyframes: Array.isArray(r) ? r : [null, r], - ease: "easeOut", - velocity: e.getVelocity(), - ...a, - delay: -l, - onUpdate: (w) => { - e.set(w), a.onUpdate && a.onUpdate(w); - }, - onComplete: () => { - o(), a.onComplete && a.onComplete(); - }, - name: t, - motionValue: e, - element: s ? void 0 : i - }; - GQ(a) || (d = { - ...d, - ...hZ(t, d) - }), d.duration && (d.duration = Ks(d.duration)), d.repeatDelay && (d.repeatDelay = Ks(d.repeatDelay)), d.from !== void 0 && (d.keyframes[0] = d.from); - let g = !1; - if ((d.type === !1 || d.duration === 0 && !d.repeatDelay) && (d.duration = 0, d.delay === 0 && (g = !0)), g && !s && e.get() !== void 0) { - const w = yp(d.keyframes, a); - if (w !== void 0) - return Lr.update(() => { - d.onUpdate(w), d.onComplete(); - }), new VQ([]); - } - return !s && u6.supports(d) ? new u6(d) : new jb(d); -}, YQ = (t) => !!(t && typeof t == "object" && t.mix && t.toValue), JQ = (t) => J1(t) ? t[t.length - 1] || 0 : t; -function Hb(t, e) { - t.indexOf(e) === -1 && t.push(e); -} -function Wb(t, e) { - const r = t.indexOf(e); - r > -1 && t.splice(r, 1); -} -class Kb { - constructor() { - this.subscriptions = []; - } - add(e) { - return Hb(this.subscriptions, e), () => Wb(this.subscriptions, e); - } - notify(e, r, n) { - const i = this.subscriptions.length; - if (i) - if (i === 1) - this.subscriptions[0](e, r, n); - else - for (let s = 0; s < i; s++) { - const o = this.subscriptions[s]; - o && o(e, r, n); - } - } - getSize() { - return this.subscriptions.length; - } - clear() { - this.subscriptions.length = 0; - } -} -const f6 = 30, XQ = (t) => !isNaN(parseFloat(t)); -class ZQ { - /** - * @param init - The initiating value - * @param config - Optional configuration options - * - * - `transformer`: A function to transform incoming values with. - * - * @internal - */ - constructor(e, r = {}) { - this.version = "11.11.17", this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (n, i = !0) => { - const s = Gs.now(); - this.updatedAt !== s && this.setPrevFrameValue(), this.prev = this.current, this.setCurrent(n), this.current !== this.prev && this.events.change && this.events.change.notify(this.current), i && this.events.renderRequest && this.events.renderRequest.notify(this.current); - }, this.hasAnimated = !1, this.setCurrent(e), this.owner = r.owner; - } - setCurrent(e) { - this.current = e, this.updatedAt = Gs.now(), this.canTrackVelocity === null && e !== void 0 && (this.canTrackVelocity = XQ(this.current)); - } - setPrevFrameValue(e = this.current) { - this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt; - } - /** - * Adds a function that will be notified when the `MotionValue` is updated. - * - * It returns a function that, when called, will cancel the subscription. - * - * When calling `onChange` inside a React component, it should be wrapped with the - * `useEffect` hook. As it returns an unsubscribe function, this should be returned - * from the `useEffect` function to ensure you don't add duplicate subscribers.. - * - * ```jsx - * export const MyComponent = () => { - * const x = useMotionValue(0) - * const y = useMotionValue(0) - * const opacity = useMotionValue(1) - * - * useEffect(() => { - * function updateOpacity() { - * const maxXY = Math.max(x.get(), y.get()) - * const newOpacity = transform(maxXY, [0, 100], [1, 0]) - * opacity.set(newOpacity) - * } - * - * const unsubscribeX = x.on("change", updateOpacity) - * const unsubscribeY = y.on("change", updateOpacity) - * - * return () => { - * unsubscribeX() - * unsubscribeY() - * } - * }, []) - * - * return - * } - * ``` - * - * @param subscriber - A function that receives the latest value. - * @returns A function that, when called, will cancel this subscription. - * - * @deprecated - */ - onChange(e) { - return process.env.NODE_ENV !== "production" && mp(!1, 'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'), this.on("change", e); - } - on(e, r) { - this.events[e] || (this.events[e] = new Kb()); - const n = this.events[e].add(r); - return e === "change" ? () => { - n(), Lr.read(() => { - this.events.change.getSize() || this.stop(); - }); - } : n; - } - clearListeners() { - for (const e in this.events) - this.events[e].clear(); - } - /** - * Attaches a passive effect to the `MotionValue`. - * - * @internal - */ - attach(e, r) { - this.passiveEffect = e, this.stopPassiveEffect = r; - } - /** - * Sets the state of the `MotionValue`. - * - * @remarks - * - * ```jsx - * const x = useMotionValue(0) - * x.set(10) - * ``` - * - * @param latest - Latest value to set. - * @param render - Whether to notify render subscribers. Defaults to `true` - * - * @public - */ - set(e, r = !0) { - !r || !this.passiveEffect ? this.updateAndNotify(e, r) : this.passiveEffect(e, this.updateAndNotify); - } - setWithVelocity(e, r, n) { - this.set(r), this.prev = void 0, this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt - n; - } - /** - * Set the state of the `MotionValue`, stopping any active animations, - * effects, and resets velocity to `0`. - */ - jump(e, r = !0) { - this.updateAndNotify(e), this.prev = e, this.prevUpdatedAt = this.prevFrameValue = void 0, r && this.stop(), this.stopPassiveEffect && this.stopPassiveEffect(); - } - /** - * Returns the latest state of `MotionValue` - * - * @returns - The latest state of `MotionValue` - * - * @public - */ - get() { - return this.current; - } - /** - * @public - */ - getPrevious() { - return this.prev; - } - /** - * Returns the latest velocity of `MotionValue` - * - * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical. - * - * @public - */ - getVelocity() { - const e = Gs.now(); - if (!this.canTrackVelocity || this.prevFrameValue === void 0 || e - this.updatedAt > f6) - return 0; - const r = Math.min(this.updatedAt - this.prevUpdatedAt, f6); - return y7(parseFloat(this.current) - parseFloat(this.prevFrameValue), r); - } - /** - * Registers a new animation to control this `MotionValue`. Only one - * animation can drive a `MotionValue` at one time. - * - * ```jsx - * value.start() - * ``` - * - * @param animation - A function that starts the provided animation - * - * @internal - */ - start(e) { - return this.stop(), new Promise((r) => { - this.hasAnimated = !0, this.animation = e(r), this.events.animationStart && this.events.animationStart.notify(); - }).then(() => { - this.events.animationComplete && this.events.animationComplete.notify(), this.clearAnimation(); - }); - } - /** - * Stop the currently active animation. - * - * @public - */ - stop() { - this.animation && (this.animation.stop(), this.events.animationCancel && this.events.animationCancel.notify()), this.clearAnimation(); - } - /** - * Returns `true` if this value is currently animating. - * - * @public - */ - isAnimating() { - return !!this.animation; - } - clearAnimation() { - delete this.animation; - } - /** - * Destroy and clean up subscribers to this `MotionValue`. - * - * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically - * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually - * created a `MotionValue` via the `motionValue` function. - * - * @public - */ - destroy() { - this.clearListeners(), this.stop(), this.stopPassiveEffect && this.stopPassiveEffect(); - } -} -function Tl(t, e) { - return new ZQ(t, e); -} -function QQ(t, e, r) { - t.hasValue(e) ? t.getValue(e).set(r) : t.addValue(e, Tl(r)); -} -function eee(t, e) { - const r = bp(t, e); - let { transitionEnd: n = {}, transition: i = {}, ...s } = r || {}; - s = { ...s, ...n }; - for (const o in s) { - const a = JQ(s[o]); - QQ(t, o, a); - } -} -const Vb = (t) => t.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase(), tee = "framerAppearId", I7 = "data-" + Vb(tee); -function C7(t) { - return t.props[I7]; -} -const Jn = (t) => !!(t && t.getVelocity); -function ree(t) { - return !!(Jn(t) && t.add); -} -function iv(t, e) { - const r = t.getValue("willChange"); - if (ree(r)) - return r.add(e); -} -function nee({ protectedKeys: t, needsAnimating: e }, r) { - const n = t.hasOwnProperty(r) && e[r] !== !0; - return e[r] = !1, n; -} -function T7(t, e, { delay: r = 0, transitionOverride: n, type: i } = {}) { - var s; - let { transition: o = t.getDefaultTransition(), transitionEnd: a, ...u } = e; - n && (o = n); - const l = [], d = i && t.animationState && t.animationState.getState()[i]; - for (const g in u) { - const w = t.getValue(g, (s = t.latestValues[g]) !== null && s !== void 0 ? s : null), A = u[g]; - if (A === void 0 || d && nee(d, g)) - continue; - const M = { - delay: r, - ...Cb(o || {}, g) - }; - let N = !1; - if (window.MotionHandoffAnimation) { - const F = C7(t); - if (F) { - const $ = window.MotionHandoffAnimation(F, g, Lr); - $ !== null && (M.startTime = $, N = !0); - } - } - iv(t, g), w.start(zb(g, w, A, t.shouldReduceMotion && Sc.has(g) ? { type: !1 } : M, t, N)); - const L = w.animation; - L && l.push(L); - } - return a && Promise.all(l).then(() => { - Lr.update(() => { - a && eee(t, a); - }); - }), l; -} -function sv(t, e, r = {}) { - var n; - const i = bp(t, e, r.type === "exit" ? (n = t.presenceContext) === null || n === void 0 ? void 0 : n.custom : void 0); - let { transition: s = t.getDefaultTransition() || {} } = i || {}; - r.transitionOverride && (s = r.transitionOverride); - const o = i ? () => Promise.all(T7(t, i, r)) : () => Promise.resolve(), a = t.variantChildren && t.variantChildren.size ? (l = 0) => { - const { delayChildren: d = 0, staggerChildren: g, staggerDirection: w } = s; - return iee(t, e, d + l, g, w, r); - } : () => Promise.resolve(), { when: u } = s; - if (u) { - const [l, d] = u === "beforeChildren" ? [o, a] : [a, o]; - return l().then(() => d()); - } else - return Promise.all([o(), a(r.delay)]); -} -function iee(t, e, r = 0, n = 0, i = 1, s) { - const o = [], a = (t.variantChildren.size - 1) * n, u = i === 1 ? (l = 0) => l * n : (l = 0) => a - l * n; - return Array.from(t.variantChildren).sort(see).forEach((l, d) => { - l.notify("AnimationStart", e), o.push(sv(l, e, { - ...s, - delay: r + u(d) - }).then(() => l.notify("AnimationComplete", e))); - }), Promise.all(o); -} -function see(t, e) { - return t.sortNodePosition(e); -} -function oee(t, e, r = {}) { - t.notify("AnimationStart", e); - let n; - if (Array.isArray(e)) { - const i = e.map((s) => sv(t, s, r)); - n = Promise.all(i); - } else if (typeof e == "string") - n = sv(t, e, r); - else { - const i = typeof e == "function" ? bp(t, e, r.custom) : e; - n = Promise.all(T7(t, i, r)); - } - return n.then(() => { - t.notify("AnimationComplete", e); - }); -} -const aee = Ib.length; -function R7(t) { - if (!t) - return; - if (!t.isControllingVariants) { - const r = t.parent ? R7(t.parent) || {} : {}; - return t.props.initial !== void 0 && (r.initial = t.props.initial), r; - } - const e = {}; - for (let r = 0; r < aee; r++) { - const n = Ib[r], i = t.props[n]; - (Ml(i) || i === !1) && (e[n] = i); - } - return e; -} -const cee = [...Mb].reverse(), uee = Mb.length; -function fee(t) { - return (e) => Promise.all(e.map(({ animation: r, options: n }) => oee(t, r, n))); -} -function lee(t) { - let e = fee(t), r = l6(), n = !0; - const i = (u) => (l, d) => { - var g; - const w = bp(t, d, u === "exit" ? (g = t.presenceContext) === null || g === void 0 ? void 0 : g.custom : void 0); - if (w) { - const { transition: A, transitionEnd: M, ...N } = w; - l = { ...l, ...N, ...M }; - } - return l; - }; - function s(u) { - e = u(t); - } - function o(u) { - const { props: l } = t, d = R7(t.parent) || {}, g = [], w = /* @__PURE__ */ new Set(); - let A = {}, M = 1 / 0; - for (let L = 0; L < uee; L++) { - const F = cee[L], $ = r[F], K = l[F] !== void 0 ? l[F] : d[F], H = Ml(K), V = F === u ? $.isActive : null; - V === !1 && (M = L); - let te = K === d[F] && K !== l[F] && H; - if (te && n && t.manuallyAnimateOnMount && (te = !1), $.protectedKeys = { ...A }, // If it isn't active and hasn't *just* been set as inactive - !$.isActive && V === null || // If we didn't and don't have any defined prop for this animation type - !K && !$.prevProp || // Or if the prop doesn't define an animation - vp(K) || typeof K == "boolean") - continue; - const R = hee($.prevProp, K); - let W = R || // If we're making this variant active, we want to always make it active - F === u && $.isActive && !te && H || // If we removed a higher-priority variant (i is in reverse order) - L > M && H, pe = !1; - const Ee = Array.isArray(K) ? K : [K]; - let Y = Ee.reduce(i(F), {}); - V === !1 && (Y = {}); - const { prevResolvedValues: S = {} } = $, m = { - ...S, - ...Y - }, f = (x) => { - W = !0, w.has(x) && (pe = !0, w.delete(x)), $.needsAnimating[x] = !0; - const _ = t.getValue(x); - _ && (_.liveStyle = !1); - }; - for (const x in m) { - const _ = Y[x], E = S[x]; - if (A.hasOwnProperty(x)) - continue; - let v = !1; - J1(_) && J1(E) ? v = !KS(_, E) : v = _ !== E, v ? _ != null ? f(x) : w.add(x) : _ !== void 0 && w.has(x) ? f(x) : $.protectedKeys[x] = !0; - } - $.prevProp = K, $.prevResolvedValues = Y, $.isActive && (A = { ...A, ...Y }), n && t.blockInitialAnimation && (W = !1), W && (!(te && R) || pe) && g.push(...Ee.map((x) => ({ - animation: x, - options: { type: F } - }))); - } - if (w.size) { - const L = {}; - w.forEach((F) => { - const $ = t.getBaseTarget(F), K = t.getValue(F); - K && (K.liveStyle = !0), L[F] = $ ?? null; - }), g.push({ animation: L }); - } - let N = !!g.length; - return n && (l.initial === !1 || l.initial === l.animate) && !t.manuallyAnimateOnMount && (N = !1), n = !1, N ? e(g) : Promise.resolve(); - } - function a(u, l) { - var d; - if (r[u].isActive === l) - return Promise.resolve(); - (d = t.variantChildren) === null || d === void 0 || d.forEach((w) => { - var A; - return (A = w.animationState) === null || A === void 0 ? void 0 : A.setActive(u, l); - }), r[u].isActive = l; - const g = o(u); - for (const w in r) - r[w].protectedKeys = {}; - return g; - } - return { - animateChanges: o, - setActive: a, - setAnimateFunction: s, - getState: () => r, - reset: () => { - r = l6(), n = !0; - } - }; -} -function hee(t, e) { - return typeof e == "string" ? e !== t : Array.isArray(e) ? !KS(e, t) : !1; -} -function Ka(t = !1) { - return { - isActive: t, - protectedKeys: {}, - needsAnimating: {}, - prevResolvedValues: {} - }; -} -function l6() { - return { - animate: Ka(!0), - whileInView: Ka(), - whileHover: Ka(), - whileTap: Ka(), - whileDrag: Ka(), - whileFocus: Ka(), - exit: Ka() - }; -} -class Ta { - constructor(e) { - this.isMounted = !1, this.node = e; - } - update() { - } -} -class dee extends Ta { - /** - * We dynamically generate the AnimationState manager as it contains a reference - * to the underlying animation library. We only want to load that if we load this, - * so people can optionally code split it out using the `m` component. - */ - constructor(e) { - super(e), e.animationState || (e.animationState = lee(e)); - } - updateAnimationControlsSubscription() { - const { animate: e } = this.node.getProps(); - vp(e) && (this.unmountControls = e.subscribe(this.node)); - } - /** - * Subscribe any provided AnimationControls to the component's VisualElement - */ - mount() { - this.updateAnimationControlsSubscription(); - } - update() { - const { animate: e } = this.node.getProps(), { animate: r } = this.node.prevProps || {}; - e !== r && this.updateAnimationControlsSubscription(); - } - unmount() { - var e; - this.node.animationState.reset(), (e = this.unmountControls) === null || e === void 0 || e.call(this); - } -} -let pee = 0; -class gee extends Ta { - constructor() { - super(...arguments), this.id = pee++; - } - update() { - if (!this.node.presenceContext) - return; - const { isPresent: e, onExitComplete: r } = this.node.presenceContext, { isPresent: n } = this.node.prevPresenceContext || {}; - if (!this.node.animationState || e === n) - return; - const i = this.node.animationState.setActive("exit", !e); - r && !e && i.then(() => r(this.id)); - } - mount() { - const { register: e } = this.node.presenceContext || {}; - e && (this.unmount = e(this.id)); - } - unmount() { - } -} -const mee = { - animation: { - Feature: dee - }, - exit: { - Feature: gee - } -}, D7 = (t) => t.pointerType === "mouse" ? typeof t.button != "number" || t.button <= 0 : t.isPrimary !== !1; -function wp(t, e = "page") { - return { - point: { - x: t[`${e}X`], - y: t[`${e}Y`] - } - }; -} -const vee = (t) => (e) => D7(e) && t(e, wp(e)); -function Po(t, e, r, n = { passive: !0 }) { - return t.addEventListener(e, r, n), () => t.removeEventListener(e, r); -} -function Ro(t, e, r, n) { - return Po(t, e, vee(r), n); -} -const h6 = (t, e) => Math.abs(t - e); -function bee(t, e) { - const r = h6(t.x, e.x), n = h6(t.y, e.y); - return Math.sqrt(r ** 2 + n ** 2); -} -class O7 { - constructor(e, r, { transformPagePoint: n, contextWindow: i, dragSnapToOrigin: s = !1 } = {}) { - if (this.startEvent = null, this.lastMoveEvent = null, this.lastMoveEventInfo = null, this.handlers = {}, this.contextWindow = window, this.updatePoint = () => { - if (!(this.lastMoveEvent && this.lastMoveEventInfo)) - return; - const g = Fm(this.lastMoveEventInfo, this.history), w = this.startEvent !== null, A = bee(g.offset, { x: 0, y: 0 }) >= 3; - if (!w && !A) - return; - const { point: M } = g, { timestamp: N } = Fn; - this.history.push({ ...M, timestamp: N }); - const { onStart: L, onMove: F } = this.handlers; - w || (L && L(this.lastMoveEvent, g), this.startEvent = this.lastMoveEvent), F && F(this.lastMoveEvent, g); - }, this.handlePointerMove = (g, w) => { - this.lastMoveEvent = g, this.lastMoveEventInfo = $m(w, this.transformPagePoint), Lr.update(this.updatePoint, !0); - }, this.handlePointerUp = (g, w) => { - this.end(); - const { onEnd: A, onSessionEnd: M, resumeAnimation: N } = this.handlers; - if (this.dragSnapToOrigin && N && N(), !(this.lastMoveEvent && this.lastMoveEventInfo)) - return; - const L = Fm(g.type === "pointercancel" ? this.lastMoveEventInfo : $m(w, this.transformPagePoint), this.history); - this.startEvent && A && A(g, L), M && M(g, L); - }, !D7(e)) - return; - this.dragSnapToOrigin = s, this.handlers = r, this.transformPagePoint = n, this.contextWindow = i || window; - const o = wp(e), a = $m(o, this.transformPagePoint), { point: u } = a, { timestamp: l } = Fn; - this.history = [{ ...u, timestamp: l }]; - const { onSessionStart: d } = r; - d && d(e, Fm(a, this.history)), this.removeListeners = To(Ro(this.contextWindow, "pointermove", this.handlePointerMove), Ro(this.contextWindow, "pointerup", this.handlePointerUp), Ro(this.contextWindow, "pointercancel", this.handlePointerUp)); - } - updateHandlers(e) { - this.handlers = e; - } - end() { - this.removeListeners && this.removeListeners(), wa(this.updatePoint); - } -} -function $m(t, e) { - return e ? { point: e(t.point) } : t; -} -function d6(t, e) { - return { x: t.x - e.x, y: t.y - e.y }; -} -function Fm({ point: t }, e) { - return { - point: t, - delta: d6(t, N7(e)), - offset: d6(t, yee(e)), - velocity: wee(e, 0.1) - }; -} -function yee(t) { - return t[0]; -} -function N7(t) { - return t[t.length - 1]; -} -function wee(t, e) { - if (t.length < 2) - return { x: 0, y: 0 }; - let r = t.length - 1, n = null; - const i = N7(t); - for (; r >= 0 && (n = t[r], !(i.timestamp - n.timestamp > Ks(e))); ) - r--; - if (!n) - return { x: 0, y: 0 }; - const s = Co(i.timestamp - n.timestamp); - if (s === 0) - return { x: 0, y: 0 }; - const o = { - x: (i.x - n.x) / s, - y: (i.y - n.y) / s - }; - return o.x === 1 / 0 && (o.x = 0), o.y === 1 / 0 && (o.y = 0), o; -} -function L7(t) { - let e = null; - return () => { - const r = () => { - e = null; - }; - return e === null ? (e = t, r) : !1; - }; -} -const p6 = L7("dragHorizontal"), g6 = L7("dragVertical"); -function k7(t) { - let e = !1; - if (t === "y") - e = g6(); - else if (t === "x") - e = p6(); - else { - const r = p6(), n = g6(); - r && n ? e = () => { - r(), n(); - } : (r && r(), n && n()); - } - return e; -} -function $7() { - const t = k7(!0); - return t ? (t(), !1) : !0; -} -function eu(t) { - return t && typeof t == "object" && Object.prototype.hasOwnProperty.call(t, "current"); -} -const F7 = 1e-4, xee = 1 - F7, _ee = 1 + F7, B7 = 0.01, Eee = 0 - B7, See = 0 + B7; -function Li(t) { - return t.max - t.min; -} -function Aee(t, e, r) { - return Math.abs(t - e) <= r; -} -function m6(t, e, r, n = 0.5) { - t.origin = n, t.originPoint = Qr(e.min, e.max, t.origin), t.scale = Li(r) / Li(e), t.translate = Qr(r.min, r.max, t.origin) - t.originPoint, (t.scale >= xee && t.scale <= _ee || isNaN(t.scale)) && (t.scale = 1), (t.translate >= Eee && t.translate <= See || isNaN(t.translate)) && (t.translate = 0); -} -function Yf(t, e, r, n) { - m6(t.x, e.x, r.x, n ? n.originX : void 0), m6(t.y, e.y, r.y, n ? n.originY : void 0); -} -function v6(t, e, r) { - t.min = r.min + e.min, t.max = t.min + Li(e); -} -function Pee(t, e, r) { - v6(t.x, e.x, r.x), v6(t.y, e.y, r.y); -} -function b6(t, e, r) { - t.min = e.min - r.min, t.max = t.min + Li(e); -} -function Jf(t, e, r) { - b6(t.x, e.x, r.x), b6(t.y, e.y, r.y); -} -function Mee(t, { min: e, max: r }, n) { - return e !== void 0 && t < e ? t = n ? Qr(e, t, n.min) : Math.max(t, e) : r !== void 0 && t > r && (t = n ? Qr(r, t, n.max) : Math.min(t, r)), t; -} -function y6(t, e, r) { - return { - min: e !== void 0 ? t.min + e : void 0, - max: r !== void 0 ? t.max + r - (t.max - t.min) : void 0 - }; -} -function Iee(t, { top: e, left: r, bottom: n, right: i }) { - return { - x: y6(t.x, r, i), - y: y6(t.y, e, n) - }; -} -function w6(t, e) { - let r = e.min - t.min, n = e.max - t.max; - return e.max - e.min < t.max - t.min && ([r, n] = [n, r]), { min: r, max: n }; -} -function Cee(t, e) { - return { - x: w6(t.x, e.x), - y: w6(t.y, e.y) - }; -} -function Tee(t, e) { - let r = 0.5; - const n = Li(t), i = Li(e); - return i > n ? r = Mu(e.min, e.max - n, t.min) : n > i && (r = Mu(t.min, t.max - i, e.min)), xa(0, 1, r); -} -function Ree(t, e) { - const r = {}; - return e.min !== void 0 && (r.min = e.min - t.min), e.max !== void 0 && (r.max = e.max - t.min), r; -} -const ov = 0.35; -function Dee(t = ov) { - return t === !1 ? t = 0 : t === !0 && (t = ov), { - x: x6(t, "left", "right"), - y: x6(t, "top", "bottom") - }; -} -function x6(t, e, r) { - return { - min: _6(t, e), - max: _6(t, r) - }; -} -function _6(t, e) { - return typeof t == "number" ? t : t[e] || 0; -} -const E6 = () => ({ - translate: 0, - scale: 1, - origin: 0, - originPoint: 0 -}), tu = () => ({ - x: E6(), - y: E6() -}), S6 = () => ({ min: 0, max: 0 }), ln = () => ({ - x: S6(), - y: S6() -}); -function Xi(t) { - return [t("x"), t("y")]; -} -function U7({ top: t, left: e, right: r, bottom: n }) { - return { - x: { min: e, max: r }, - y: { min: t, max: n } - }; -} -function Oee({ x: t, y: e }) { - return { top: e.min, right: t.max, bottom: e.max, left: t.min }; -} -function Nee(t, e) { - if (!e) - return t; - const r = e({ x: t.left, y: t.top }), n = e({ x: t.right, y: t.bottom }); - return { - top: r.y, - left: r.x, - bottom: n.y, - right: n.x - }; -} -function Bm(t) { - return t === void 0 || t === 1; -} -function av({ scale: t, scaleX: e, scaleY: r }) { - return !Bm(t) || !Bm(e) || !Bm(r); -} -function Ga(t) { - return av(t) || j7(t) || t.z || t.rotate || t.rotateX || t.rotateY || t.skewX || t.skewY; -} -function j7(t) { - return A6(t.x) || A6(t.y); -} -function A6(t) { - return t && t !== "0%"; -} -function w0(t, e, r) { - const n = t - r, i = e * n; - return r + i; -} -function P6(t, e, r, n, i) { - return i !== void 0 && (t = w0(t, i, n)), w0(t, r, n) + e; -} -function cv(t, e = 0, r = 1, n, i) { - t.min = P6(t.min, e, r, n, i), t.max = P6(t.max, e, r, n, i); -} -function q7(t, { x: e, y: r }) { - cv(t.x, e.translate, e.scale, e.originPoint), cv(t.y, r.translate, r.scale, r.originPoint); -} -const M6 = 0.999999999999, I6 = 1.0000000000001; -function Lee(t, e, r, n = !1) { - const i = r.length; - if (!i) - return; - e.x = e.y = 1; - let s, o; - for (let a = 0; a < i; a++) { - s = r[a], o = s.projectionDelta; - const { visualElement: u } = s.options; - u && u.props.style && u.props.style.display === "contents" || (n && s.options.layoutScroll && s.scroll && s !== s.root && nu(t, { - x: -s.scroll.offset.x, - y: -s.scroll.offset.y - }), o && (e.x *= o.x.scale, e.y *= o.y.scale, q7(t, o)), n && Ga(s.latestValues) && nu(t, s.latestValues)); - } - e.x < I6 && e.x > M6 && (e.x = 1), e.y < I6 && e.y > M6 && (e.y = 1); -} -function ru(t, e) { - t.min = t.min + e, t.max = t.max + e; -} -function C6(t, e, r, n, i = 0.5) { - const s = Qr(t.min, t.max, i); - cv(t, e, r, s, n); -} -function nu(t, e) { - C6(t.x, e.x, e.scaleX, e.scale, e.originX), C6(t.y, e.y, e.scaleY, e.scale, e.originY); -} -function z7(t, e) { - return U7(Nee(t.getBoundingClientRect(), e)); -} -function kee(t, e, r) { - const n = z7(t, r), { scroll: i } = e; - return i && (ru(n.x, i.offset.x), ru(n.y, i.offset.y)), n; -} -const H7 = ({ current: t }) => t ? t.ownerDocument.defaultView : null, $ee = /* @__PURE__ */ new WeakMap(); -class Fee { - constructor(e) { - this.openGlobalLock = null, this.isDragging = !1, this.currentDirection = null, this.originPoint = { x: 0, y: 0 }, this.constraints = !1, this.hasMutatedConstraints = !1, this.elastic = ln(), this.visualElement = e; - } - start(e, { snapToCursor: r = !1 } = {}) { - const { presenceContext: n } = this.visualElement; - if (n && n.isPresent === !1) - return; - const i = (d) => { - const { dragSnapToOrigin: g } = this.getProps(); - g ? this.pauseAnimation() : this.stopAnimation(), r && this.snapToCursor(wp(d, "page").point); - }, s = (d, g) => { - const { drag: w, dragPropagation: A, onDragStart: M } = this.getProps(); - if (w && !A && (this.openGlobalLock && this.openGlobalLock(), this.openGlobalLock = k7(w), !this.openGlobalLock)) - return; - this.isDragging = !0, this.currentDirection = null, this.resolveConstraints(), this.visualElement.projection && (this.visualElement.projection.isAnimationBlocked = !0, this.visualElement.projection.target = void 0), Xi((L) => { - let F = this.getAxisMotionValue(L).get() || 0; - if (Vs.test(F)) { - const { projection: $ } = this.visualElement; - if ($ && $.layout) { - const K = $.layout.layoutBox[L]; - K && (F = Li(K) * (parseFloat(F) / 100)); - } - } - this.originPoint[L] = F; - }), M && Lr.postRender(() => M(d, g)), iv(this.visualElement, "transform"); - const { animationState: N } = this.visualElement; - N && N.setActive("whileDrag", !0); - }, o = (d, g) => { - const { dragPropagation: w, dragDirectionLock: A, onDirectionLock: M, onDrag: N } = this.getProps(); - if (!w && !this.openGlobalLock) - return; - const { offset: L } = g; - if (A && this.currentDirection === null) { - this.currentDirection = Bee(L), this.currentDirection !== null && M && M(this.currentDirection); - return; - } - this.updateAxis("x", g.point, L), this.updateAxis("y", g.point, L), this.visualElement.render(), N && N(d, g); - }, a = (d, g) => this.stop(d, g), u = () => Xi((d) => { - var g; - return this.getAnimationState(d) === "paused" && ((g = this.getAxisMotionValue(d).animation) === null || g === void 0 ? void 0 : g.play()); - }), { dragSnapToOrigin: l } = this.getProps(); - this.panSession = new O7(e, { - onSessionStart: i, - onStart: s, - onMove: o, - onSessionEnd: a, - resumeAnimation: u - }, { - transformPagePoint: this.visualElement.getTransformPagePoint(), - dragSnapToOrigin: l, - contextWindow: H7(this.visualElement) - }); - } - stop(e, r) { - const n = this.isDragging; - if (this.cancel(), !n) - return; - const { velocity: i } = r; - this.startAnimation(i); - const { onDragEnd: s } = this.getProps(); - s && Lr.postRender(() => s(e, r)); - } - cancel() { - this.isDragging = !1; - const { projection: e, animationState: r } = this.visualElement; - e && (e.isAnimationBlocked = !1), this.panSession && this.panSession.end(), this.panSession = void 0; - const { dragPropagation: n } = this.getProps(); - !n && this.openGlobalLock && (this.openGlobalLock(), this.openGlobalLock = null), r && r.setActive("whileDrag", !1); - } - updateAxis(e, r, n) { - const { drag: i } = this.getProps(); - if (!n || !md(e, i, this.currentDirection)) - return; - const s = this.getAxisMotionValue(e); - let o = this.originPoint[e] + n[e]; - this.constraints && this.constraints[e] && (o = Mee(o, this.constraints[e], this.elastic[e])), s.set(o); - } - resolveConstraints() { - var e; - const { dragConstraints: r, dragElastic: n } = this.getProps(), i = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(!1) : (e = this.visualElement.projection) === null || e === void 0 ? void 0 : e.layout, s = this.constraints; - r && eu(r) ? this.constraints || (this.constraints = this.resolveRefConstraints()) : r && i ? this.constraints = Iee(i.layoutBox, r) : this.constraints = !1, this.elastic = Dee(n), s !== this.constraints && i && this.constraints && !this.hasMutatedConstraints && Xi((o) => { - this.constraints !== !1 && this.getAxisMotionValue(o) && (this.constraints[o] = Ree(i.layoutBox[o], this.constraints[o])); - }); - } - resolveRefConstraints() { - const { dragConstraints: e, onMeasureDragConstraints: r } = this.getProps(); - if (!e || !eu(e)) - return !1; - const n = e.current; - Uo(n !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop."); - const { projection: i } = this.visualElement; - if (!i || !i.layout) - return !1; - const s = kee(n, i.root, this.visualElement.getTransformPagePoint()); - let o = Cee(i.layout.layoutBox, s); - if (r) { - const a = r(Oee(o)); - this.hasMutatedConstraints = !!a, a && (o = U7(a)); - } - return o; - } - startAnimation(e) { - const { drag: r, dragMomentum: n, dragElastic: i, dragTransition: s, dragSnapToOrigin: o, onDragTransitionEnd: a } = this.getProps(), u = this.constraints || {}, l = Xi((d) => { - if (!md(d, r, this.currentDirection)) - return; - let g = u && u[d] || {}; - o && (g = { min: 0, max: 0 }); - const w = i ? 200 : 1e6, A = i ? 40 : 1e7, M = { - type: "inertia", - velocity: n ? e[d] : 0, - bounceStiffness: w, - bounceDamping: A, - timeConstant: 750, - restDelta: 1, - restSpeed: 10, - ...s, - ...g - }; - return this.startAxisValueAnimation(d, M); - }); - return Promise.all(l).then(a); - } - startAxisValueAnimation(e, r) { - const n = this.getAxisMotionValue(e); - return iv(this.visualElement, e), n.start(zb(e, n, 0, r, this.visualElement, !1)); - } - stopAnimation() { - Xi((e) => this.getAxisMotionValue(e).stop()); - } - pauseAnimation() { - Xi((e) => { - var r; - return (r = this.getAxisMotionValue(e).animation) === null || r === void 0 ? void 0 : r.pause(); - }); - } - getAnimationState(e) { - var r; - return (r = this.getAxisMotionValue(e).animation) === null || r === void 0 ? void 0 : r.state; - } - /** - * Drag works differently depending on which props are provided. - * - * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values. - * - Otherwise, we apply the delta to the x/y motion values. - */ - getAxisMotionValue(e) { - const r = `_drag${e.toUpperCase()}`, n = this.visualElement.getProps(), i = n[r]; - return i || this.visualElement.getValue(e, (n.initial ? n.initial[e] : void 0) || 0); - } - snapToCursor(e) { - Xi((r) => { - const { drag: n } = this.getProps(); - if (!md(r, n, this.currentDirection)) - return; - const { projection: i } = this.visualElement, s = this.getAxisMotionValue(r); - if (i && i.layout) { - const { min: o, max: a } = i.layout.layoutBox[r]; - s.set(e[r] - Qr(o, a, 0.5)); - } - }); - } - /** - * When the viewport resizes we want to check if the measured constraints - * have changed and, if so, reposition the element within those new constraints - * relative to where it was before the resize. - */ - scalePositionWithinConstraints() { - if (!this.visualElement.current) - return; - const { drag: e, dragConstraints: r } = this.getProps(), { projection: n } = this.visualElement; - if (!eu(r) || !n || !this.constraints) - return; - this.stopAnimation(); - const i = { x: 0, y: 0 }; - Xi((o) => { - const a = this.getAxisMotionValue(o); - if (a && this.constraints !== !1) { - const u = a.get(); - i[o] = Tee({ min: u, max: u }, this.constraints[o]); - } - }); - const { transformTemplate: s } = this.visualElement.getProps(); - this.visualElement.current.style.transform = s ? s({}, "") : "none", n.root && n.root.updateScroll(), n.updateLayout(), this.resolveConstraints(), Xi((o) => { - if (!md(o, e, null)) - return; - const a = this.getAxisMotionValue(o), { min: u, max: l } = this.constraints[o]; - a.set(Qr(u, l, i[o])); - }); - } - addListeners() { - if (!this.visualElement.current) - return; - $ee.set(this.visualElement, this); - const e = this.visualElement.current, r = Ro(e, "pointerdown", (u) => { - const { drag: l, dragListener: d = !0 } = this.getProps(); - l && d && this.start(u); - }), n = () => { - const { dragConstraints: u } = this.getProps(); - eu(u) && u.current && (this.constraints = this.resolveRefConstraints()); - }, { projection: i } = this.visualElement, s = i.addEventListener("measure", n); - i && !i.layout && (i.root && i.root.updateScroll(), i.updateLayout()), Lr.read(n); - const o = Po(window, "resize", () => this.scalePositionWithinConstraints()), a = i.addEventListener("didUpdate", ({ delta: u, hasLayoutChanged: l }) => { - this.isDragging && l && (Xi((d) => { - const g = this.getAxisMotionValue(d); - g && (this.originPoint[d] += u[d].translate, g.set(g.get() + u[d].translate)); - }), this.visualElement.render()); - }); - return () => { - o(), r(), s(), a && a(); - }; - } - getProps() { - const e = this.visualElement.getProps(), { drag: r = !1, dragDirectionLock: n = !1, dragPropagation: i = !1, dragConstraints: s = !1, dragElastic: o = ov, dragMomentum: a = !0 } = e; - return { - ...e, - drag: r, - dragDirectionLock: n, - dragPropagation: i, - dragConstraints: s, - dragElastic: o, - dragMomentum: a - }; - } -} -function md(t, e, r) { - return (e === !0 || e === t) && (r === null || r === t); -} -function Bee(t, e = 10) { - let r = null; - return Math.abs(t.y) > e ? r = "y" : Math.abs(t.x) > e && (r = "x"), r; -} -class Uee extends Ta { - constructor(e) { - super(e), this.removeGroupControls = Un, this.removeListeners = Un, this.controls = new Fee(e); - } - mount() { - const { dragControls: e } = this.node.getProps(); - e && (this.removeGroupControls = e.subscribe(this.controls)), this.removeListeners = this.controls.addListeners() || Un; - } - unmount() { - this.removeGroupControls(), this.removeListeners(); - } -} -const T6 = (t) => (e, r) => { - t && Lr.postRender(() => t(e, r)); -}; -class jee extends Ta { - constructor() { - super(...arguments), this.removePointerDownListener = Un; - } - onPointerDown(e) { - this.session = new O7(e, this.createPanHandlers(), { - transformPagePoint: this.node.getTransformPagePoint(), - contextWindow: H7(this.node) - }); - } - createPanHandlers() { - const { onPanSessionStart: e, onPanStart: r, onPan: n, onPanEnd: i } = this.node.getProps(); - return { - onSessionStart: T6(e), - onStart: T6(r), - onMove: n, - onEnd: (s, o) => { - delete this.session, i && Lr.postRender(() => i(s, o)); - } - }; - } - mount() { - this.removePointerDownListener = Ro(this.node.current, "pointerdown", (e) => this.onPointerDown(e)); - } - update() { - this.session && this.session.updateHandlers(this.createPanHandlers()); - } - unmount() { - this.removePointerDownListener(), this.session && this.session.end(); - } -} -const xp = Sa(null); -function qee() { - const t = Tn(xp); - if (t === null) - return [!0, null]; - const { isPresent: e, onExitComplete: r, register: n } = t, i = mv(); - Xn(() => n(i), []); - const s = vv(() => r && r(i), [i, r]); - return !e && r ? [!1, s] : [!0]; -} -const Gb = Sa({}), W7 = Sa({}), Bd = { - /** - * Global flag as to whether the tree has animated since the last time - * we resized the window - */ - hasAnimatedSinceResize: !0, - /** - * We set this to true once, on the first update. Any nodes added to the tree beyond that - * update will be given a `data-projection-id` attribute. - */ - hasEverUpdated: !1 -}; -function R6(t, e) { - return e.max === e.min ? 0 : t / (e.max - e.min) * 100; -} -const Df = { - correct: (t, e) => { - if (!e.target) - return t; - if (typeof t == "string") - if (Vt.test(t)) - t = parseFloat(t); - else - return t; - const r = R6(t, e.target.x), n = R6(t, e.target.y); - return `${r}% ${n}%`; - } -}, zee = { - correct: (t, { treeScale: e, projectionDelta: r }) => { - const n = t, i = _a.parse(t); - if (i.length > 5) - return n; - const s = _a.createTransformer(t), o = typeof i[0] != "number" ? 1 : 0, a = r.x.scale * e.x, u = r.y.scale * e.y; - i[0 + o] /= a, i[1 + o] /= u; - const l = Qr(a, u, 0.5); - return typeof i[2 + o] == "number" && (i[2 + o] /= l), typeof i[3 + o] == "number" && (i[3 + o] /= l), s(i); - } -}, x0 = {}; -function Hee(t) { - Object.assign(x0, t); -} -const { schedule: Yb } = VS(queueMicrotask, !1); -class Wee extends AR { - /** - * This only mounts projection nodes for components that - * need measuring, we might want to do it for all components - * in order to incorporate transforms - */ - componentDidMount() { - const { visualElement: e, layoutGroup: r, switchLayoutGroup: n, layoutId: i } = this.props, { projection: s } = e; - Hee(Kee), s && (r.group && r.group.add(s), n && n.register && i && n.register(s), s.root.didUpdate(), s.addEventListener("animationComplete", () => { - this.safeToRemove(); - }), s.setOptions({ - ...s.options, - onExitComplete: () => this.safeToRemove() - })), Bd.hasEverUpdated = !0; - } - getSnapshotBeforeUpdate(e) { - const { layoutDependency: r, visualElement: n, drag: i, isPresent: s } = this.props, o = n.projection; - return o && (o.isPresent = s, i || e.layoutDependency !== r || r === void 0 ? o.willUpdate() : this.safeToRemove(), e.isPresent !== s && (s ? o.promote() : o.relegate() || Lr.postRender(() => { - const a = o.getStack(); - (!a || !a.members.length) && this.safeToRemove(); - }))), null; - } - componentDidUpdate() { - const { projection: e } = this.props.visualElement; - e && (e.root.didUpdate(), Yb.postRender(() => { - !e.currentAnimation && e.isLead() && this.safeToRemove(); - })); - } - componentWillUnmount() { - const { visualElement: e, layoutGroup: r, switchLayoutGroup: n } = this.props, { projection: i } = e; - i && (i.scheduleCheckAfterUnmount(), r && r.group && r.group.remove(i), n && n.deregister && n.deregister(i)); - } - safeToRemove() { - const { safeToRemove: e } = this.props; - e && e(); - } - render() { - return null; - } -} -function K7(t) { - const [e, r] = qee(), n = Tn(Gb); - return me.jsx(Wee, { ...t, layoutGroup: n, switchLayoutGroup: Tn(W7), isPresent: e, safeToRemove: r }); -} -const Kee = { - borderRadius: { - ...Df, - applyTo: [ - "borderTopLeftRadius", - "borderTopRightRadius", - "borderBottomLeftRadius", - "borderBottomRightRadius" - ] - }, - borderTopLeftRadius: Df, - borderTopRightRadius: Df, - borderBottomLeftRadius: Df, - borderBottomRightRadius: Df, - boxShadow: zee -}, V7 = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"], Vee = V7.length, D6 = (t) => typeof t == "string" ? parseFloat(t) : t, O6 = (t) => typeof t == "number" || Vt.test(t); -function Gee(t, e, r, n, i, s) { - i ? (t.opacity = Qr( - 0, - // TODO Reinstate this if only child - r.opacity !== void 0 ? r.opacity : 1, - Yee(n) - ), t.opacityExit = Qr(e.opacity !== void 0 ? e.opacity : 1, 0, Jee(n))) : s && (t.opacity = Qr(e.opacity !== void 0 ? e.opacity : 1, r.opacity !== void 0 ? r.opacity : 1, n)); - for (let o = 0; o < Vee; o++) { - const a = `border${V7[o]}Radius`; - let u = N6(e, a), l = N6(r, a); - if (u === void 0 && l === void 0) - continue; - u || (u = 0), l || (l = 0), u === 0 || l === 0 || O6(u) === O6(l) ? (t[a] = Math.max(Qr(D6(u), D6(l), n), 0), (Vs.test(l) || Vs.test(u)) && (t[a] += "%")) : t[a] = l; - } - (e.rotate || r.rotate) && (t.rotate = Qr(e.rotate || 0, r.rotate || 0, n)); -} -function N6(t, e) { - return t[e] !== void 0 ? t[e] : t.borderRadius; -} -const Yee = /* @__PURE__ */ G7(0, 0.5, e7), Jee = /* @__PURE__ */ G7(0.5, 0.95, Un); -function G7(t, e, r) { - return (n) => n < t ? 0 : n > e ? 1 : r(Mu(t, e, n)); -} -function L6(t, e) { - t.min = e.min, t.max = e.max; -} -function Yi(t, e) { - L6(t.x, e.x), L6(t.y, e.y); -} -function k6(t, e) { - t.translate = e.translate, t.scale = e.scale, t.originPoint = e.originPoint, t.origin = e.origin; -} -function $6(t, e, r, n, i) { - return t -= e, t = w0(t, 1 / r, n), i !== void 0 && (t = w0(t, 1 / i, n)), t; -} -function Xee(t, e = 0, r = 1, n = 0.5, i, s = t, o = t) { - if (Vs.test(e) && (e = parseFloat(e), e = Qr(o.min, o.max, e / 100) - o.min), typeof e != "number") - return; - let a = Qr(s.min, s.max, n); - t === s && (a -= e), t.min = $6(t.min, e, r, a, i), t.max = $6(t.max, e, r, a, i); -} -function F6(t, e, [r, n, i], s, o) { - Xee(t, e[r], e[n], e[i], e.scale, s, o); -} -const Zee = ["x", "scaleX", "originX"], Qee = ["y", "scaleY", "originY"]; -function B6(t, e, r, n) { - F6(t.x, e, Zee, r ? r.x : void 0, n ? n.x : void 0), F6(t.y, e, Qee, r ? r.y : void 0, n ? n.y : void 0); -} -function U6(t) { - return t.translate === 0 && t.scale === 1; -} -function Y7(t) { - return U6(t.x) && U6(t.y); -} -function j6(t, e) { - return t.min === e.min && t.max === e.max; -} -function ete(t, e) { - return j6(t.x, e.x) && j6(t.y, e.y); -} -function q6(t, e) { - return Math.round(t.min) === Math.round(e.min) && Math.round(t.max) === Math.round(e.max); -} -function J7(t, e) { - return q6(t.x, e.x) && q6(t.y, e.y); -} -function z6(t) { - return Li(t.x) / Li(t.y); -} -function H6(t, e) { - return t.translate === e.translate && t.scale === e.scale && t.originPoint === e.originPoint; -} -class tte { - constructor() { - this.members = []; - } - add(e) { - Hb(this.members, e), e.scheduleRender(); - } - remove(e) { - if (Wb(this.members, e), e === this.prevLead && (this.prevLead = void 0), e === this.lead) { - const r = this.members[this.members.length - 1]; - r && this.promote(r); - } - } - relegate(e) { - const r = this.members.findIndex((i) => e === i); - if (r === 0) - return !1; - let n; - for (let i = r; i >= 0; i--) { - const s = this.members[i]; - if (s.isPresent !== !1) { - n = s; - break; - } - } - return n ? (this.promote(n), !0) : !1; - } - promote(e, r) { - const n = this.lead; - if (e !== n && (this.prevLead = n, this.lead = e, e.show(), n)) { - n.instance && n.scheduleRender(), e.scheduleRender(), e.resumeFrom = n, r && (e.resumeFrom.preserveOpacity = !0), n.snapshot && (e.snapshot = n.snapshot, e.snapshot.latestValues = n.animationValues || n.latestValues), e.root && e.root.isUpdating && (e.isLayoutDirty = !0); - const { crossfade: i } = e.options; - i === !1 && n.hide(); - } - } - exitAnimationComplete() { - this.members.forEach((e) => { - const { options: r, resumingFrom: n } = e; - r.onExitComplete && r.onExitComplete(), n && n.options.onExitComplete && n.options.onExitComplete(); - }); - } - scheduleRender() { - this.members.forEach((e) => { - e.instance && e.scheduleRender(!1); - }); - } - /** - * Clear any leads that have been removed this render to prevent them from being - * used in future animations and to prevent memory leaks - */ - removeLeadSnapshot() { - this.lead && this.lead.snapshot && (this.lead.snapshot = void 0); - } -} -function rte(t, e, r) { - let n = ""; - const i = t.x.translate / e.x, s = t.y.translate / e.y, o = (r == null ? void 0 : r.z) || 0; - if ((i || s || o) && (n = `translate3d(${i}px, ${s}px, ${o}px) `), (e.x !== 1 || e.y !== 1) && (n += `scale(${1 / e.x}, ${1 / e.y}) `), r) { - const { transformPerspective: l, rotate: d, rotateX: g, rotateY: w, skewX: A, skewY: M } = r; - l && (n = `perspective(${l}px) ${n}`), d && (n += `rotate(${d}deg) `), g && (n += `rotateX(${g}deg) `), w && (n += `rotateY(${w}deg) `), A && (n += `skewX(${A}deg) `), M && (n += `skewY(${M}deg) `); - } - const a = t.x.scale * e.x, u = t.y.scale * e.y; - return (a !== 1 || u !== 1) && (n += `scale(${a}, ${u})`), n || "none"; -} -const nte = (t, e) => t.depth - e.depth; -class ite { - constructor() { - this.children = [], this.isDirty = !1; - } - add(e) { - Hb(this.children, e), this.isDirty = !0; - } - remove(e) { - Wb(this.children, e), this.isDirty = !0; - } - forEach(e) { - this.isDirty && this.children.sort(nte), this.isDirty = !1, this.children.forEach(e); - } -} -function Ud(t) { - const e = Jn(t) ? t.get() : t; - return YQ(e) ? e.toValue() : e; -} -function ste(t, e) { - const r = Gs.now(), n = ({ timestamp: i }) => { - const s = i - r; - s >= e && (wa(n), t(s - e)); - }; - return Lr.read(n, !0), () => wa(n); -} -function ote(t) { - return t instanceof SVGElement && t.tagName !== "svg"; -} -function ate(t, e, r) { - const n = Jn(t) ? t : Tl(t); - return n.start(zb("", n, e, r)), n.animation; -} -const Ya = { - type: "projectionFrame", - totalNodes: 0, - resolvedTargetDeltas: 0, - recalculatedProjection: 0 -}, Uf = typeof window < "u" && window.MotionDebug !== void 0, Um = ["", "X", "Y", "Z"], cte = { visibility: "hidden" }, W6 = 1e3; -let ute = 0; -function jm(t, e, r, n) { - const { latestValues: i } = e; - i[t] && (r[t] = i[t], e.setStaticValue(t, 0), n && (n[t] = 0)); -} -function X7(t) { - if (t.hasCheckedOptimisedAppear = !0, t.root === t) - return; - const { visualElement: e } = t.options; - if (!e) - return; - const r = C7(e); - if (window.MotionHasOptimisedAnimation(r, "transform")) { - const { layout: i, layoutId: s } = t.options; - window.MotionCancelOptimisedAnimation(r, "transform", Lr, !(i || s)); - } - const { parent: n } = t; - n && !n.hasCheckedOptimisedAppear && X7(n); -} -function Z7({ attachResizeListener: t, defaultParent: e, measureScroll: r, checkIsScrollRoot: n, resetTransform: i }) { - return class { - constructor(o = {}, a = e == null ? void 0 : e()) { - this.id = ute++, this.animationId = 0, this.children = /* @__PURE__ */ new Set(), this.options = {}, this.isTreeAnimating = !1, this.isAnimationBlocked = !1, this.isLayoutDirty = !1, this.isProjectionDirty = !1, this.isSharedProjectionDirty = !1, this.isTransformDirty = !1, this.updateManuallyBlocked = !1, this.updateBlockedByResize = !1, this.isUpdating = !1, this.isSVG = !1, this.needsReset = !1, this.shouldResetTransform = !1, this.hasCheckedOptimisedAppear = !1, this.treeScale = { x: 1, y: 1 }, this.eventHandlers = /* @__PURE__ */ new Map(), this.hasTreeAnimated = !1, this.updateScheduled = !1, this.scheduleUpdate = () => this.update(), this.projectionUpdateScheduled = !1, this.checkUpdateFailed = () => { - this.isUpdating && (this.isUpdating = !1, this.clearAllSnapshots()); - }, this.updateProjection = () => { - this.projectionUpdateScheduled = !1, Uf && (Ya.totalNodes = Ya.resolvedTargetDeltas = Ya.recalculatedProjection = 0), this.nodes.forEach(hte), this.nodes.forEach(vte), this.nodes.forEach(bte), this.nodes.forEach(dte), Uf && window.MotionDebug.record(Ya); - }, this.resolvedRelativeTargetAt = 0, this.hasProjected = !1, this.isVisible = !0, this.animationProgress = 0, this.sharedNodes = /* @__PURE__ */ new Map(), this.latestValues = o, this.root = a ? a.root || a : this, this.path = a ? [...a.path, a] : [], this.parent = a, this.depth = a ? a.depth + 1 : 0; - for (let u = 0; u < this.path.length; u++) - this.path[u].shouldResetTransform = !0; - this.root === this && (this.nodes = new ite()); - } - addEventListener(o, a) { - return this.eventHandlers.has(o) || this.eventHandlers.set(o, new Kb()), this.eventHandlers.get(o).add(a); - } - notifyListeners(o, ...a) { - const u = this.eventHandlers.get(o); - u && u.notify(...a); - } - hasListeners(o) { - return this.eventHandlers.has(o); - } - /** - * Lifecycles - */ - mount(o, a = this.root.hasTreeAnimated) { - if (this.instance) - return; - this.isSVG = ote(o), this.instance = o; - const { layoutId: u, layout: l, visualElement: d } = this.options; - if (d && !d.current && d.mount(o), this.root.nodes.add(this), this.parent && this.parent.children.add(this), a && (l || u) && (this.isLayoutDirty = !0), t) { - let g; - const w = () => this.root.updateBlockedByResize = !1; - t(o, () => { - this.root.updateBlockedByResize = !0, g && g(), g = ste(w, 250), Bd.hasAnimatedSinceResize && (Bd.hasAnimatedSinceResize = !1, this.nodes.forEach(V6)); - }); - } - u && this.root.registerSharedNode(u, this), this.options.animate !== !1 && d && (u || l) && this.addEventListener("didUpdate", ({ delta: g, hasLayoutChanged: w, hasRelativeTargetChanged: A, layout: M }) => { - if (this.isTreeAnimationBlocked()) { - this.target = void 0, this.relativeTarget = void 0; - return; - } - const N = this.options.transition || d.getDefaultTransition() || Ete, { onLayoutAnimationStart: L, onLayoutAnimationComplete: F } = d.getProps(), $ = !this.targetLayout || !J7(this.targetLayout, M) || A, K = !w && A; - if (this.options.layoutRoot || this.resumeFrom && this.resumeFrom.instance || K || w && ($ || !this.currentAnimation)) { - this.resumeFrom && (this.resumingFrom = this.resumeFrom, this.resumingFrom.resumingFrom = void 0), this.setAnimationOrigin(g, K); - const H = { - ...Cb(N, "layout"), - onPlay: L, - onComplete: F - }; - (d.shouldReduceMotion || this.options.layoutRoot) && (H.delay = 0, H.type = !1), this.startAnimation(H); - } else - w || V6(this), this.isLead() && this.options.onExitComplete && this.options.onExitComplete(); - this.targetLayout = M; - }); - } - unmount() { - this.options.layoutId && this.willUpdate(), this.root.nodes.remove(this); - const o = this.getStack(); - o && o.remove(this), this.parent && this.parent.children.delete(this), this.instance = void 0, wa(this.updateProjection); - } - // only on the root - blockUpdate() { - this.updateManuallyBlocked = !0; - } - unblockUpdate() { - this.updateManuallyBlocked = !1; - } - isUpdateBlocked() { - return this.updateManuallyBlocked || this.updateBlockedByResize; - } - isTreeAnimationBlocked() { - return this.isAnimationBlocked || this.parent && this.parent.isTreeAnimationBlocked() || !1; - } - // Note: currently only running on root node - startUpdate() { - this.isUpdateBlocked() || (this.isUpdating = !0, this.nodes && this.nodes.forEach(yte), this.animationId++); - } - getTransformTemplate() { - const { visualElement: o } = this.options; - return o && o.getProps().transformTemplate; - } - willUpdate(o = !0) { - if (this.root.hasTreeAnimated = !0, this.root.isUpdateBlocked()) { - this.options.onExitComplete && this.options.onExitComplete(); - return; - } - if (window.MotionCancelOptimisedAnimation && !this.hasCheckedOptimisedAppear && X7(this), !this.root.isUpdating && this.root.startUpdate(), this.isLayoutDirty) - return; - this.isLayoutDirty = !0; - for (let d = 0; d < this.path.length; d++) { - const g = this.path[d]; - g.shouldResetTransform = !0, g.updateScroll("snapshot"), g.options.layoutRoot && g.willUpdate(!1); - } - const { layoutId: a, layout: u } = this.options; - if (a === void 0 && !u) - return; - const l = this.getTransformTemplate(); - this.prevTransformTemplateValue = l ? l(this.latestValues, "") : void 0, this.updateSnapshot(), o && this.notifyListeners("willUpdate"); - } - update() { - if (this.updateScheduled = !1, this.isUpdateBlocked()) { - this.unblockUpdate(), this.clearAllSnapshots(), this.nodes.forEach(K6); - return; - } - this.isUpdating || this.nodes.forEach(gte), this.isUpdating = !1, this.nodes.forEach(mte), this.nodes.forEach(fte), this.nodes.forEach(lte), this.clearAllSnapshots(); - const a = Gs.now(); - Fn.delta = xa(0, 1e3 / 60, a - Fn.timestamp), Fn.timestamp = a, Fn.isProcessing = !0, Dm.update.process(Fn), Dm.preRender.process(Fn), Dm.render.process(Fn), Fn.isProcessing = !1; - } - didUpdate() { - this.updateScheduled || (this.updateScheduled = !0, Yb.read(this.scheduleUpdate)); - } - clearAllSnapshots() { - this.nodes.forEach(pte), this.sharedNodes.forEach(wte); - } - scheduleUpdateProjection() { - this.projectionUpdateScheduled || (this.projectionUpdateScheduled = !0, Lr.preRender(this.updateProjection, !1, !0)); - } - scheduleCheckAfterUnmount() { - Lr.postRender(() => { - this.isLayoutDirty ? this.root.didUpdate() : this.root.checkUpdateFailed(); - }); - } - /** - * Update measurements - */ - updateSnapshot() { - this.snapshot || !this.instance || (this.snapshot = this.measure()); - } - updateLayout() { - if (!this.instance || (this.updateScroll(), !(this.options.alwaysMeasureLayout && this.isLead()) && !this.isLayoutDirty)) - return; - if (this.resumeFrom && !this.resumeFrom.instance) - for (let u = 0; u < this.path.length; u++) - this.path[u].updateScroll(); - const o = this.layout; - this.layout = this.measure(!1), this.layoutCorrected = ln(), this.isLayoutDirty = !1, this.projectionDelta = void 0, this.notifyListeners("measure", this.layout.layoutBox); - const { visualElement: a } = this.options; - a && a.notify("LayoutMeasure", this.layout.layoutBox, o ? o.layoutBox : void 0); - } - updateScroll(o = "measure") { - let a = !!(this.options.layoutScroll && this.instance); - if (this.scroll && this.scroll.animationId === this.root.animationId && this.scroll.phase === o && (a = !1), a) { - const u = n(this.instance); - this.scroll = { - animationId: this.root.animationId, - phase: o, - isRoot: u, - offset: r(this.instance), - wasRoot: this.scroll ? this.scroll.isRoot : u - }; - } - } - resetTransform() { - if (!i) - return; - const o = this.isLayoutDirty || this.shouldResetTransform || this.options.alwaysMeasureLayout, a = this.projectionDelta && !Y7(this.projectionDelta), u = this.getTransformTemplate(), l = u ? u(this.latestValues, "") : void 0, d = l !== this.prevTransformTemplateValue; - o && (a || Ga(this.latestValues) || d) && (i(this.instance, l), this.shouldResetTransform = !1, this.scheduleRender()); - } - measure(o = !0) { - const a = this.measurePageBox(); - let u = this.removeElementScroll(a); - return o && (u = this.removeTransform(u)), Ste(u), { - animationId: this.root.animationId, - measuredBox: a, - layoutBox: u, - latestValues: {}, - source: this.id - }; - } - measurePageBox() { - var o; - const { visualElement: a } = this.options; - if (!a) - return ln(); - const u = a.measureViewportBox(); - if (!(((o = this.scroll) === null || o === void 0 ? void 0 : o.wasRoot) || this.path.some(Ate))) { - const { scroll: d } = this.root; - d && (ru(u.x, d.offset.x), ru(u.y, d.offset.y)); - } - return u; - } - removeElementScroll(o) { - var a; - const u = ln(); - if (Yi(u, o), !((a = this.scroll) === null || a === void 0) && a.wasRoot) - return u; - for (let l = 0; l < this.path.length; l++) { - const d = this.path[l], { scroll: g, options: w } = d; - d !== this.root && g && w.layoutScroll && (g.wasRoot && Yi(u, o), ru(u.x, g.offset.x), ru(u.y, g.offset.y)); - } - return u; - } - applyTransform(o, a = !1) { - const u = ln(); - Yi(u, o); - for (let l = 0; l < this.path.length; l++) { - const d = this.path[l]; - !a && d.options.layoutScroll && d.scroll && d !== d.root && nu(u, { - x: -d.scroll.offset.x, - y: -d.scroll.offset.y - }), Ga(d.latestValues) && nu(u, d.latestValues); - } - return Ga(this.latestValues) && nu(u, this.latestValues), u; - } - removeTransform(o) { - const a = ln(); - Yi(a, o); - for (let u = 0; u < this.path.length; u++) { - const l = this.path[u]; - if (!l.instance || !Ga(l.latestValues)) - continue; - av(l.latestValues) && l.updateSnapshot(); - const d = ln(), g = l.measurePageBox(); - Yi(d, g), B6(a, l.latestValues, l.snapshot ? l.snapshot.layoutBox : void 0, d); - } - return Ga(this.latestValues) && B6(a, this.latestValues), a; - } - setTargetDelta(o) { - this.targetDelta = o, this.root.scheduleUpdateProjection(), this.isProjectionDirty = !0; - } - setOptions(o) { - this.options = { - ...this.options, - ...o, - crossfade: o.crossfade !== void 0 ? o.crossfade : !0 - }; - } - clearMeasurements() { - this.scroll = void 0, this.layout = void 0, this.snapshot = void 0, this.prevTransformTemplateValue = void 0, this.targetDelta = void 0, this.target = void 0, this.isLayoutDirty = !1; - } - forceRelativeParentToResolveTarget() { - this.relativeParent && this.relativeParent.resolvedRelativeTargetAt !== Fn.timestamp && this.relativeParent.resolveTargetDelta(!0); - } - resolveTargetDelta(o = !1) { - var a; - const u = this.getLead(); - this.isProjectionDirty || (this.isProjectionDirty = u.isProjectionDirty), this.isTransformDirty || (this.isTransformDirty = u.isTransformDirty), this.isSharedProjectionDirty || (this.isSharedProjectionDirty = u.isSharedProjectionDirty); - const l = !!this.resumingFrom || this !== u; - if (!(o || l && this.isSharedProjectionDirty || this.isProjectionDirty || !((a = this.parent) === null || a === void 0) && a.isProjectionDirty || this.attemptToResolveRelativeTarget || this.root.updateBlockedByResize)) - return; - const { layout: g, layoutId: w } = this.options; - if (!(!this.layout || !(g || w))) { - if (this.resolvedRelativeTargetAt = Fn.timestamp, !this.targetDelta && !this.relativeTarget) { - const A = this.getClosestProjectingParent(); - A && A.layout && this.animationProgress !== 1 ? (this.relativeParent = A, this.forceRelativeParentToResolveTarget(), this.relativeTarget = ln(), this.relativeTargetOrigin = ln(), Jf(this.relativeTargetOrigin, this.layout.layoutBox, A.layout.layoutBox), Yi(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0; - } - if (!(!this.relativeTarget && !this.targetDelta)) { - if (this.target || (this.target = ln(), this.targetWithTransforms = ln()), this.relativeTarget && this.relativeTargetOrigin && this.relativeParent && this.relativeParent.target ? (this.forceRelativeParentToResolveTarget(), Pee(this.target, this.relativeTarget, this.relativeParent.target)) : this.targetDelta ? (this.resumingFrom ? this.target = this.applyTransform(this.layout.layoutBox) : Yi(this.target, this.layout.layoutBox), q7(this.target, this.targetDelta)) : Yi(this.target, this.layout.layoutBox), this.attemptToResolveRelativeTarget) { - this.attemptToResolveRelativeTarget = !1; - const A = this.getClosestProjectingParent(); - A && !!A.resumingFrom == !!this.resumingFrom && !A.options.layoutScroll && A.target && this.animationProgress !== 1 ? (this.relativeParent = A, this.forceRelativeParentToResolveTarget(), this.relativeTarget = ln(), this.relativeTargetOrigin = ln(), Jf(this.relativeTargetOrigin, this.target, A.target), Yi(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0; - } - Uf && Ya.resolvedTargetDeltas++; - } - } - } - getClosestProjectingParent() { - if (!(!this.parent || av(this.parent.latestValues) || j7(this.parent.latestValues))) - return this.parent.isProjecting() ? this.parent : this.parent.getClosestProjectingParent(); - } - isProjecting() { - return !!((this.relativeTarget || this.targetDelta || this.options.layoutRoot) && this.layout); - } - calcProjection() { - var o; - const a = this.getLead(), u = !!this.resumingFrom || this !== a; - let l = !0; - if ((this.isProjectionDirty || !((o = this.parent) === null || o === void 0) && o.isProjectionDirty) && (l = !1), u && (this.isSharedProjectionDirty || this.isTransformDirty) && (l = !1), this.resolvedRelativeTargetAt === Fn.timestamp && (l = !1), l) - return; - const { layout: d, layoutId: g } = this.options; - if (this.isTreeAnimating = !!(this.parent && this.parent.isTreeAnimating || this.currentAnimation || this.pendingAnimation), this.isTreeAnimating || (this.targetDelta = this.relativeTarget = void 0), !this.layout || !(d || g)) - return; - Yi(this.layoutCorrected, this.layout.layoutBox); - const w = this.treeScale.x, A = this.treeScale.y; - Lee(this.layoutCorrected, this.treeScale, this.path, u), a.layout && !a.target && (this.treeScale.x !== 1 || this.treeScale.y !== 1) && (a.target = a.layout.layoutBox, a.targetWithTransforms = ln()); - const { target: M } = a; - if (!M) { - this.prevProjectionDelta && (this.createProjectionDeltas(), this.scheduleRender()); - return; - } - !this.projectionDelta || !this.prevProjectionDelta ? this.createProjectionDeltas() : (k6(this.prevProjectionDelta.x, this.projectionDelta.x), k6(this.prevProjectionDelta.y, this.projectionDelta.y)), Yf(this.projectionDelta, this.layoutCorrected, M, this.latestValues), (this.treeScale.x !== w || this.treeScale.y !== A || !H6(this.projectionDelta.x, this.prevProjectionDelta.x) || !H6(this.projectionDelta.y, this.prevProjectionDelta.y)) && (this.hasProjected = !0, this.scheduleRender(), this.notifyListeners("projectionUpdate", M)), Uf && Ya.recalculatedProjection++; - } - hide() { - this.isVisible = !1; - } - show() { - this.isVisible = !0; - } - scheduleRender(o = !0) { - var a; - if ((a = this.options.visualElement) === null || a === void 0 || a.scheduleRender(), o) { - const u = this.getStack(); - u && u.scheduleRender(); - } - this.resumingFrom && !this.resumingFrom.instance && (this.resumingFrom = void 0); - } - createProjectionDeltas() { - this.prevProjectionDelta = tu(), this.projectionDelta = tu(), this.projectionDeltaWithTransform = tu(); - } - setAnimationOrigin(o, a = !1) { - const u = this.snapshot, l = u ? u.latestValues : {}, d = { ...this.latestValues }, g = tu(); - (!this.relativeParent || !this.relativeParent.options.layoutRoot) && (this.relativeTarget = this.relativeTargetOrigin = void 0), this.attemptToResolveRelativeTarget = !a; - const w = ln(), A = u ? u.source : void 0, M = this.layout ? this.layout.source : void 0, N = A !== M, L = this.getStack(), F = !L || L.members.length <= 1, $ = !!(N && !F && this.options.crossfade === !0 && !this.path.some(_te)); - this.animationProgress = 0; - let K; - this.mixTargetDelta = (H) => { - const V = H / 1e3; - G6(g.x, o.x, V), G6(g.y, o.y, V), this.setTargetDelta(g), this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout && (Jf(w, this.layout.layoutBox, this.relativeParent.layout.layoutBox), xte(this.relativeTarget, this.relativeTargetOrigin, w, V), K && ete(this.relativeTarget, K) && (this.isProjectionDirty = !1), K || (K = ln()), Yi(K, this.relativeTarget)), N && (this.animationValues = d, Gee(d, l, this.latestValues, V, $, F)), this.root.scheduleUpdateProjection(), this.scheduleRender(), this.animationProgress = V; - }, this.mixTargetDelta(this.options.layoutRoot ? 1e3 : 0); - } - startAnimation(o) { - this.notifyListeners("animationStart"), this.currentAnimation && this.currentAnimation.stop(), this.resumingFrom && this.resumingFrom.currentAnimation && this.resumingFrom.currentAnimation.stop(), this.pendingAnimation && (wa(this.pendingAnimation), this.pendingAnimation = void 0), this.pendingAnimation = Lr.update(() => { - Bd.hasAnimatedSinceResize = !0, this.currentAnimation = ate(0, W6, { - ...o, - onUpdate: (a) => { - this.mixTargetDelta(a), o.onUpdate && o.onUpdate(a); - }, - onComplete: () => { - o.onComplete && o.onComplete(), this.completeAnimation(); - } - }), this.resumingFrom && (this.resumingFrom.currentAnimation = this.currentAnimation), this.pendingAnimation = void 0; - }); - } - completeAnimation() { - this.resumingFrom && (this.resumingFrom.currentAnimation = void 0, this.resumingFrom.preserveOpacity = void 0); - const o = this.getStack(); - o && o.exitAnimationComplete(), this.resumingFrom = this.currentAnimation = this.animationValues = void 0, this.notifyListeners("animationComplete"); - } - finishAnimation() { - this.currentAnimation && (this.mixTargetDelta && this.mixTargetDelta(W6), this.currentAnimation.stop()), this.completeAnimation(); - } - applyTransformsToTarget() { - const o = this.getLead(); - let { targetWithTransforms: a, target: u, layout: l, latestValues: d } = o; - if (!(!a || !u || !l)) { - if (this !== o && this.layout && l && Q7(this.options.animationType, this.layout.layoutBox, l.layoutBox)) { - u = this.target || ln(); - const g = Li(this.layout.layoutBox.x); - u.x.min = o.target.x.min, u.x.max = u.x.min + g; - const w = Li(this.layout.layoutBox.y); - u.y.min = o.target.y.min, u.y.max = u.y.min + w; - } - Yi(a, u), nu(a, d), Yf(this.projectionDeltaWithTransform, this.layoutCorrected, a, d); - } - } - registerSharedNode(o, a) { - this.sharedNodes.has(o) || this.sharedNodes.set(o, new tte()), this.sharedNodes.get(o).add(a); - const l = a.options.initialPromotionConfig; - a.promote({ - transition: l ? l.transition : void 0, - preserveFollowOpacity: l && l.shouldPreserveFollowOpacity ? l.shouldPreserveFollowOpacity(a) : void 0 - }); - } - isLead() { - const o = this.getStack(); - return o ? o.lead === this : !0; - } - getLead() { - var o; - const { layoutId: a } = this.options; - return a ? ((o = this.getStack()) === null || o === void 0 ? void 0 : o.lead) || this : this; - } - getPrevLead() { - var o; - const { layoutId: a } = this.options; - return a ? (o = this.getStack()) === null || o === void 0 ? void 0 : o.prevLead : void 0; - } - getStack() { - const { layoutId: o } = this.options; - if (o) - return this.root.sharedNodes.get(o); - } - promote({ needsReset: o, transition: a, preserveFollowOpacity: u } = {}) { - const l = this.getStack(); - l && l.promote(this, u), o && (this.projectionDelta = void 0, this.needsReset = !0), a && this.setOptions({ transition: a }); - } - relegate() { - const o = this.getStack(); - return o ? o.relegate(this) : !1; - } - resetSkewAndRotation() { - const { visualElement: o } = this.options; - if (!o) - return; - let a = !1; - const { latestValues: u } = o; - if ((u.z || u.rotate || u.rotateX || u.rotateY || u.rotateZ || u.skewX || u.skewY) && (a = !0), !a) - return; - const l = {}; - u.z && jm("z", o, l, this.animationValues); - for (let d = 0; d < Um.length; d++) - jm(`rotate${Um[d]}`, o, l, this.animationValues), jm(`skew${Um[d]}`, o, l, this.animationValues); - o.render(); - for (const d in l) - o.setStaticValue(d, l[d]), this.animationValues && (this.animationValues[d] = l[d]); - o.scheduleRender(); - } - getProjectionStyles(o) { - var a, u; - if (!this.instance || this.isSVG) - return; - if (!this.isVisible) - return cte; - const l = { - visibility: "" - }, d = this.getTransformTemplate(); - if (this.needsReset) - return this.needsReset = !1, l.opacity = "", l.pointerEvents = Ud(o == null ? void 0 : o.pointerEvents) || "", l.transform = d ? d(this.latestValues, "") : "none", l; - const g = this.getLead(); - if (!this.projectionDelta || !this.layout || !g.target) { - const N = {}; - return this.options.layoutId && (N.opacity = this.latestValues.opacity !== void 0 ? this.latestValues.opacity : 1, N.pointerEvents = Ud(o == null ? void 0 : o.pointerEvents) || ""), this.hasProjected && !Ga(this.latestValues) && (N.transform = d ? d({}, "") : "none", this.hasProjected = !1), N; - } - const w = g.animationValues || g.latestValues; - this.applyTransformsToTarget(), l.transform = rte(this.projectionDeltaWithTransform, this.treeScale, w), d && (l.transform = d(w, l.transform)); - const { x: A, y: M } = this.projectionDelta; - l.transformOrigin = `${A.origin * 100}% ${M.origin * 100}% 0`, g.animationValues ? l.opacity = g === this ? (u = (a = w.opacity) !== null && a !== void 0 ? a : this.latestValues.opacity) !== null && u !== void 0 ? u : 1 : this.preserveOpacity ? this.latestValues.opacity : w.opacityExit : l.opacity = g === this ? w.opacity !== void 0 ? w.opacity : "" : w.opacityExit !== void 0 ? w.opacityExit : 0; - for (const N in x0) { - if (w[N] === void 0) - continue; - const { correct: L, applyTo: F } = x0[N], $ = l.transform === "none" ? w[N] : L(w[N], g); - if (F) { - const K = F.length; - for (let H = 0; H < K; H++) - l[F[H]] = $; - } else - l[N] = $; - } - return this.options.layoutId && (l.pointerEvents = g === this ? Ud(o == null ? void 0 : o.pointerEvents) || "" : "none"), l; - } - clearSnapshot() { - this.resumeFrom = this.snapshot = void 0; - } - // Only run on root - resetTree() { - this.root.nodes.forEach((o) => { - var a; - return (a = o.currentAnimation) === null || a === void 0 ? void 0 : a.stop(); - }), this.root.nodes.forEach(K6), this.root.sharedNodes.clear(); - } - }; -} -function fte(t) { - t.updateLayout(); -} -function lte(t) { - var e; - const r = ((e = t.resumeFrom) === null || e === void 0 ? void 0 : e.snapshot) || t.snapshot; - if (t.isLead() && t.layout && r && t.hasListeners("didUpdate")) { - const { layoutBox: n, measuredBox: i } = t.layout, { animationType: s } = t.options, o = r.source !== t.layout.source; - s === "size" ? Xi((g) => { - const w = o ? r.measuredBox[g] : r.layoutBox[g], A = Li(w); - w.min = n[g].min, w.max = w.min + A; - }) : Q7(s, r.layoutBox, n) && Xi((g) => { - const w = o ? r.measuredBox[g] : r.layoutBox[g], A = Li(n[g]); - w.max = w.min + A, t.relativeTarget && !t.currentAnimation && (t.isProjectionDirty = !0, t.relativeTarget[g].max = t.relativeTarget[g].min + A); - }); - const a = tu(); - Yf(a, n, r.layoutBox); - const u = tu(); - o ? Yf(u, t.applyTransform(i, !0), r.measuredBox) : Yf(u, n, r.layoutBox); - const l = !Y7(a); - let d = !1; - if (!t.resumeFrom) { - const g = t.getClosestProjectingParent(); - if (g && !g.resumeFrom) { - const { snapshot: w, layout: A } = g; - if (w && A) { - const M = ln(); - Jf(M, r.layoutBox, w.layoutBox); - const N = ln(); - Jf(N, n, A.layoutBox), J7(M, N) || (d = !0), g.options.layoutRoot && (t.relativeTarget = N, t.relativeTargetOrigin = M, t.relativeParent = g); - } - } - } - t.notifyListeners("didUpdate", { - layout: n, - snapshot: r, - delta: u, - layoutDelta: a, - hasLayoutChanged: l, - hasRelativeTargetChanged: d - }); - } else if (t.isLead()) { - const { onExitComplete: n } = t.options; - n && n(); - } - t.options.transition = void 0; -} -function hte(t) { - Uf && Ya.totalNodes++, t.parent && (t.isProjecting() || (t.isProjectionDirty = t.parent.isProjectionDirty), t.isSharedProjectionDirty || (t.isSharedProjectionDirty = !!(t.isProjectionDirty || t.parent.isProjectionDirty || t.parent.isSharedProjectionDirty)), t.isTransformDirty || (t.isTransformDirty = t.parent.isTransformDirty)); -} -function dte(t) { - t.isProjectionDirty = t.isSharedProjectionDirty = t.isTransformDirty = !1; -} -function pte(t) { - t.clearSnapshot(); -} -function K6(t) { - t.clearMeasurements(); -} -function gte(t) { - t.isLayoutDirty = !1; -} -function mte(t) { - const { visualElement: e } = t.options; - e && e.getProps().onBeforeLayoutMeasure && e.notify("BeforeLayoutMeasure"), t.resetTransform(); -} -function V6(t) { - t.finishAnimation(), t.targetDelta = t.relativeTarget = t.target = void 0, t.isProjectionDirty = !0; -} -function vte(t) { - t.resolveTargetDelta(); -} -function bte(t) { - t.calcProjection(); -} -function yte(t) { - t.resetSkewAndRotation(); -} -function wte(t) { - t.removeLeadSnapshot(); -} -function G6(t, e, r) { - t.translate = Qr(e.translate, 0, r), t.scale = Qr(e.scale, 1, r), t.origin = e.origin, t.originPoint = e.originPoint; -} -function Y6(t, e, r, n) { - t.min = Qr(e.min, r.min, n), t.max = Qr(e.max, r.max, n); -} -function xte(t, e, r, n) { - Y6(t.x, e.x, r.x, n), Y6(t.y, e.y, r.y, n); -} -function _te(t) { - return t.animationValues && t.animationValues.opacityExit !== void 0; -} -const Ete = { - duration: 0.45, - ease: [0.4, 0, 0.1, 1] -}, J6 = (t) => typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().includes(t), X6 = J6("applewebkit/") && !J6("chrome/") ? Math.round : Un; -function Z6(t) { - t.min = X6(t.min), t.max = X6(t.max); -} -function Ste(t) { - Z6(t.x), Z6(t.y); -} -function Q7(t, e, r) { - return t === "position" || t === "preserve-aspect" && !Aee(z6(e), z6(r), 0.2); -} -function Ate(t) { - var e; - return t !== t.root && ((e = t.scroll) === null || e === void 0 ? void 0 : e.wasRoot); -} -const Pte = Z7({ - attachResizeListener: (t, e) => Po(t, "resize", e), - measureScroll: () => ({ - x: document.documentElement.scrollLeft || document.body.scrollLeft, - y: document.documentElement.scrollTop || document.body.scrollTop - }), - checkIsScrollRoot: () => !0 -}), qm = { - current: void 0 -}, e9 = Z7({ - measureScroll: (t) => ({ - x: t.scrollLeft, - y: t.scrollTop - }), - defaultParent: () => { - if (!qm.current) { - const t = new Pte({}); - t.mount(window), t.setOptions({ layoutScroll: !0 }), qm.current = t; - } - return qm.current; - }, - resetTransform: (t, e) => { - t.style.transform = e !== void 0 ? e : "none"; - }, - checkIsScrollRoot: (t) => window.getComputedStyle(t).position === "fixed" -}), Mte = { - pan: { - Feature: jee - }, - drag: { - Feature: Uee, - ProjectionNode: e9, - MeasureLayout: K7 - } -}; -function Q6(t, e) { - const r = e ? "pointerenter" : "pointerleave", n = e ? "onHoverStart" : "onHoverEnd", i = (s, o) => { - if (s.pointerType === "touch" || $7()) - return; - const a = t.getProps(); - t.animationState && a.whileHover && t.animationState.setActive("whileHover", e); - const u = a[n]; - u && Lr.postRender(() => u(s, o)); - }; - return Ro(t.current, r, i, { - passive: !t.getProps()[n] - }); -} -class Ite extends Ta { - mount() { - this.unmount = To(Q6(this.node, !0), Q6(this.node, !1)); - } - unmount() { - } -} -class Cte extends Ta { - constructor() { - super(...arguments), this.isActive = !1; - } - onFocus() { - let e = !1; - try { - e = this.node.current.matches(":focus-visible"); - } catch { - e = !0; - } - !e || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !0), this.isActive = !0); - } - onBlur() { - !this.isActive || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !1), this.isActive = !1); - } - mount() { - this.unmount = To(Po(this.node.current, "focus", () => this.onFocus()), Po(this.node.current, "blur", () => this.onBlur())); - } - unmount() { - } -} -const t9 = (t, e) => e ? t === e ? !0 : t9(t, e.parentElement) : !1; -function zm(t, e) { - if (!e) - return; - const r = new PointerEvent("pointer" + t); - e(r, wp(r)); -} -class Tte extends Ta { - constructor() { - super(...arguments), this.removeStartListeners = Un, this.removeEndListeners = Un, this.removeAccessibleListeners = Un, this.startPointerPress = (e, r) => { - if (this.isPressing) - return; - this.removeEndListeners(); - const n = this.node.getProps(), s = Ro(window, "pointerup", (a, u) => { - if (!this.checkPressEnd()) - return; - const { onTap: l, onTapCancel: d, globalTapTarget: g } = this.node.getProps(), w = !g && !t9(this.node.current, a.target) ? d : l; - w && Lr.update(() => w(a, u)); - }, { - passive: !(n.onTap || n.onPointerUp) - }), o = Ro(window, "pointercancel", (a, u) => this.cancelPress(a, u), { - passive: !(n.onTapCancel || n.onPointerCancel) - }); - this.removeEndListeners = To(s, o), this.startPress(e, r); - }, this.startAccessiblePress = () => { - const e = (s) => { - if (s.key !== "Enter" || this.isPressing) - return; - const o = (a) => { - a.key !== "Enter" || !this.checkPressEnd() || zm("up", (u, l) => { - const { onTap: d } = this.node.getProps(); - d && Lr.postRender(() => d(u, l)); - }); - }; - this.removeEndListeners(), this.removeEndListeners = Po(this.node.current, "keyup", o), zm("down", (a, u) => { - this.startPress(a, u); - }); - }, r = Po(this.node.current, "keydown", e), n = () => { - this.isPressing && zm("cancel", (s, o) => this.cancelPress(s, o)); - }, i = Po(this.node.current, "blur", n); - this.removeAccessibleListeners = To(r, i); - }; - } - startPress(e, r) { - this.isPressing = !0; - const { onTapStart: n, whileTap: i } = this.node.getProps(); - i && this.node.animationState && this.node.animationState.setActive("whileTap", !0), n && Lr.postRender(() => n(e, r)); - } - checkPressEnd() { - return this.removeEndListeners(), this.isPressing = !1, this.node.getProps().whileTap && this.node.animationState && this.node.animationState.setActive("whileTap", !1), !$7(); - } - cancelPress(e, r) { - if (!this.checkPressEnd()) - return; - const { onTapCancel: n } = this.node.getProps(); - n && Lr.postRender(() => n(e, r)); - } - mount() { - const e = this.node.getProps(), r = Ro(e.globalTapTarget ? window : this.node.current, "pointerdown", this.startPointerPress, { - passive: !(e.onTapStart || e.onPointerStart) - }), n = Po(this.node.current, "focus", this.startAccessiblePress); - this.removeStartListeners = To(r, n); - } - unmount() { - this.removeStartListeners(), this.removeEndListeners(), this.removeAccessibleListeners(); - } -} -const uv = /* @__PURE__ */ new WeakMap(), Hm = /* @__PURE__ */ new WeakMap(), Rte = (t) => { - const e = uv.get(t.target); - e && e(t); -}, Dte = (t) => { - t.forEach(Rte); -}; -function Ote({ root: t, ...e }) { - const r = t || document; - Hm.has(r) || Hm.set(r, {}); - const n = Hm.get(r), i = JSON.stringify(e); - return n[i] || (n[i] = new IntersectionObserver(Dte, { root: t, ...e })), n[i]; -} -function Nte(t, e, r) { - const n = Ote(e); - return uv.set(t, r), n.observe(t), () => { - uv.delete(t), n.unobserve(t); - }; -} -const Lte = { - some: 0, - all: 1 -}; -class kte extends Ta { - constructor() { - super(...arguments), this.hasEnteredView = !1, this.isInView = !1; - } - startObserver() { - this.unmount(); - const { viewport: e = {} } = this.node.getProps(), { root: r, margin: n, amount: i = "some", once: s } = e, o = { - root: r ? r.current : void 0, - rootMargin: n, - threshold: typeof i == "number" ? i : Lte[i] - }, a = (u) => { - const { isIntersecting: l } = u; - if (this.isInView === l || (this.isInView = l, s && !l && this.hasEnteredView)) - return; - l && (this.hasEnteredView = !0), this.node.animationState && this.node.animationState.setActive("whileInView", l); - const { onViewportEnter: d, onViewportLeave: g } = this.node.getProps(), w = l ? d : g; - w && w(u); - }; - return Nte(this.node.current, o, a); - } - mount() { - this.startObserver(); - } - update() { - if (typeof IntersectionObserver > "u") - return; - const { props: e, prevProps: r } = this.node; - ["amount", "margin", "root"].some($te(e, r)) && this.startObserver(); - } - unmount() { - } -} -function $te({ viewport: t = {} }, { viewport: e = {} } = {}) { - return (r) => t[r] !== e[r]; -} -const Fte = { - inView: { - Feature: kte - }, - tap: { - Feature: Tte - }, - focus: { - Feature: Cte - }, - hover: { - Feature: Ite - } -}, Bte = { - layout: { - ProjectionNode: e9, - MeasureLayout: K7 - } -}, Jb = Sa({ - transformPagePoint: (t) => t, - isStatic: !1, - reducedMotion: "never" -}), _p = Sa({}), Xb = typeof window < "u", r9 = Xb ? PR : Xn, n9 = Sa({ strict: !1 }); -function Ute(t, e, r, n, i) { - var s, o; - const { visualElement: a } = Tn(_p), u = Tn(n9), l = Tn(xp), d = Tn(Jb).reducedMotion, g = bi(); - n = n || u.renderer, !g.current && n && (g.current = n(t, { - visualState: e, - parent: a, - props: r, - presenceContext: l, - blockInitialAnimation: l ? l.initial === !1 : !1, - reducedMotionConfig: d - })); - const w = g.current, A = Tn(W7); - w && !w.projection && i && (w.type === "html" || w.type === "svg") && jte(g.current, r, i, A); - const M = bi(!1); - v5(() => { - w && M.current && w.update(r, l); - }); - const N = r[I7], L = bi(!!N && !(!((s = window.MotionHandoffIsComplete) === null || s === void 0) && s.call(window, N)) && ((o = window.MotionHasOptimisedAnimation) === null || o === void 0 ? void 0 : o.call(window, N))); - return r9(() => { - w && (M.current = !0, window.MotionIsMounted = !0, w.updateFeatures(), Yb.render(w.render), L.current && w.animationState && w.animationState.animateChanges()); - }), Xn(() => { - w && (!L.current && w.animationState && w.animationState.animateChanges(), L.current && (queueMicrotask(() => { - var F; - (F = window.MotionHandoffMarkAsComplete) === null || F === void 0 || F.call(window, N); - }), L.current = !1)); - }), w; -} -function jte(t, e, r, n) { - const { layoutId: i, layout: s, drag: o, dragConstraints: a, layoutScroll: u, layoutRoot: l } = e; - t.projection = new r(t.latestValues, e["data-framer-portal-id"] ? void 0 : i9(t.parent)), t.projection.setOptions({ - layoutId: i, - layout: s, - alwaysMeasureLayout: !!o || a && eu(a), - visualElement: t, - /** - * TODO: Update options in an effect. This could be tricky as it'll be too late - * to update by the time layout animations run. - * We also need to fix this safeToRemove by linking it up to the one returned by usePresence, - * ensuring it gets called if there's no potential layout animations. - * - */ - animationType: typeof s == "string" ? s : "both", - initialPromotionConfig: n, - layoutScroll: u, - layoutRoot: l - }); -} -function i9(t) { - if (t) - return t.options.allowProjection !== !1 ? t.projection : i9(t.parent); -} -function qte(t, e, r) { - return vv( - (n) => { - n && t.mount && t.mount(n), e && (n ? e.mount(n) : e.unmount()), r && (typeof r == "function" ? r(n) : eu(r) && (r.current = n)); - }, - /** - * Only pass a new ref callback to React if we've received a visual element - * factory. Otherwise we'll be mounting/remounting every time externalRef - * or other dependencies change. - */ - [e] - ); -} -function Ep(t) { - return vp(t.animate) || Ib.some((e) => Ml(t[e])); -} -function s9(t) { - return !!(Ep(t) || t.variants); -} -function zte(t, e) { - if (Ep(t)) { - const { initial: r, animate: n } = t; - return { - initial: r === !1 || Ml(r) ? r : void 0, - animate: Ml(n) ? n : void 0 - }; - } - return t.inherit !== !1 ? e : {}; -} -function Hte(t) { - const { initial: e, animate: r } = zte(t, Tn(_p)); - return Oi(() => ({ initial: e, animate: r }), [e5(e), e5(r)]); -} -function e5(t) { - return Array.isArray(t) ? t.join(" ") : t; -} -const t5 = { - animation: [ - "animate", - "variants", - "whileHover", - "whileTap", - "exit", - "whileInView", - "whileFocus", - "whileDrag" - ], - exit: ["exit"], - drag: ["drag", "dragControls"], - focus: ["whileFocus"], - hover: ["whileHover", "onHoverStart", "onHoverEnd"], - tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"], - pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"], - inView: ["whileInView", "onViewportEnter", "onViewportLeave"], - layout: ["layout", "layoutId"] -}, Iu = {}; -for (const t in t5) - Iu[t] = { - isEnabled: (e) => t5[t].some((r) => !!e[r]) - }; -function Wte(t) { - for (const e in t) - Iu[e] = { - ...Iu[e], - ...t[e] - }; -} -const Kte = Symbol.for("motionComponentSymbol"); -function Vte({ preloadedFeatures: t, createVisualElement: e, useRender: r, useVisualState: n, Component: i }) { - t && Wte(t); - function s(a, u) { - let l; - const d = { - ...Tn(Jb), - ...a, - layoutId: Gte(a) - }, { isStatic: g } = d, w = Hte(a), A = n(a, g); - if (!g && Xb) { - Yte(d, t); - const M = Jte(d); - l = M.MeasureLayout, w.visualElement = Ute(i, A, d, e, M.ProjectionNode); - } - return me.jsxs(_p.Provider, { value: w, children: [l && w.visualElement ? me.jsx(l, { visualElement: w.visualElement, ...d }) : null, r(i, a, qte(A, w.visualElement, u), A, g, w.visualElement)] }); - } - const o = gv(s); - return o[Kte] = i, o; -} -function Gte({ layoutId: t }) { - const e = Tn(Gb).id; - return e && t !== void 0 ? e + "-" + t : t; -} -function Yte(t, e) { - const r = Tn(n9).strict; - if (process.env.NODE_ENV !== "production" && e && r) { - const n = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead."; - t.ignoreStrict ? Wu(!1, n) : Uo(!1, n); - } -} -function Jte(t) { - const { drag: e, layout: r } = Iu; - if (!e && !r) - return {}; - const n = { ...e, ...r }; - return { - MeasureLayout: e != null && e.isEnabled(t) || r != null && r.isEnabled(t) ? n.MeasureLayout : void 0, - ProjectionNode: n.ProjectionNode - }; -} -const Xte = [ - "animate", - "circle", - "defs", - "desc", - "ellipse", - "g", - "image", - "line", - "filter", - "marker", - "mask", - "metadata", - "path", - "pattern", - "polygon", - "polyline", - "rect", - "stop", - "switch", - "symbol", - "svg", - "text", - "tspan", - "use", - "view" -]; -function Zb(t) { - return ( - /** - * If it's not a string, it's a custom React component. Currently we only support - * HTML custom React components. - */ - typeof t != "string" || /** - * If it contains a dash, the element is a custom HTML webcomponent. - */ - t.includes("-") ? !1 : ( - /** - * If it's in our list of lowercase SVG tags, it's an SVG component - */ - !!(Xte.indexOf(t) > -1 || /** - * If it contains a capital letter, it's an SVG component - */ - /[A-Z]/u.test(t)) - ) - ); -} -function o9(t, { style: e, vars: r }, n, i) { - Object.assign(t.style, e, i && i.getProjectionStyles(n)); - for (const s in r) - t.style.setProperty(s, r[s]); -} -const a9 = /* @__PURE__ */ new Set([ - "baseFrequency", - "diffuseConstant", - "kernelMatrix", - "kernelUnitLength", - "keySplines", - "keyTimes", - "limitingConeAngle", - "markerHeight", - "markerWidth", - "numOctaves", - "targetX", - "targetY", - "surfaceScale", - "specularConstant", - "specularExponent", - "stdDeviation", - "tableValues", - "viewBox", - "gradientTransform", - "pathLength", - "startOffset", - "textLength", - "lengthAdjust" -]); -function c9(t, e, r, n) { - o9(t, e, void 0, n); - for (const i in e.attrs) - t.setAttribute(a9.has(i) ? i : Vb(i), e.attrs[i]); -} -function u9(t, { layout: e, layoutId: r }) { - return Sc.has(t) || t.startsWith("origin") || (e || r !== void 0) && (!!x0[t] || t === "opacity"); -} -function Qb(t, e, r) { - var n; - const { style: i } = t, s = {}; - for (const o in i) - (Jn(i[o]) || e.style && Jn(e.style[o]) || u9(o, t) || ((n = r == null ? void 0 : r.getValue(o)) === null || n === void 0 ? void 0 : n.liveStyle) !== void 0) && (s[o] = i[o]); - return s; -} -function f9(t, e, r) { - const n = Qb(t, e, r); - for (const i in t) - if (Jn(t[i]) || Jn(e[i])) { - const s = oh.indexOf(i) !== -1 ? "attr" + i.charAt(0).toUpperCase() + i.substring(1) : i; - n[s] = t[i]; - } - return n; -} -function ey(t) { - const e = bi(null); - return e.current === null && (e.current = t()), e.current; -} -function Zte({ scrapeMotionValuesFromProps: t, createRenderState: e, onMount: r }, n, i, s) { - const o = { - latestValues: Qte(n, i, s, t), - renderState: e() - }; - return r && (o.mount = (a) => r(n, a, o)), o; -} -const l9 = (t) => (e, r) => { - const n = Tn(_p), i = Tn(xp), s = () => Zte(t, e, n, i); - return r ? s() : ey(s); -}; -function Qte(t, e, r, n) { - const i = {}, s = n(t, {}); - for (const w in s) - i[w] = Ud(s[w]); - let { initial: o, animate: a } = t; - const u = Ep(t), l = s9(t); - e && l && !u && t.inherit !== !1 && (o === void 0 && (o = e.initial), a === void 0 && (a = e.animate)); - let d = r ? r.initial === !1 : !1; - d = d || o === !1; - const g = d ? a : o; - if (g && typeof g != "boolean" && !vp(g)) { - const w = Array.isArray(g) ? g : [g]; - for (let A = 0; A < w.length; A++) { - const M = Pb(t, w[A]); - if (M) { - const { transitionEnd: N, transition: L, ...F } = M; - for (const $ in F) { - let K = F[$]; - if (Array.isArray(K)) { - const H = d ? K.length - 1 : 0; - K = K[H]; - } - K !== null && (i[$] = K); - } - for (const $ in N) - i[$] = N[$]; - } - } - } - return i; -} -const ty = () => ({ - style: {}, - transform: {}, - transformOrigin: {}, - vars: {} -}), h9 = () => ({ - ...ty(), - attrs: {} -}), d9 = (t, e) => e && typeof t == "number" ? e.transform(t) : t, ere = { - x: "translateX", - y: "translateY", - z: "translateZ", - transformPerspective: "perspective" -}, tre = oh.length; -function rre(t, e, r) { - let n = "", i = !0; - for (let s = 0; s < tre; s++) { - const o = oh[s], a = t[o]; - if (a === void 0) - continue; - let u = !0; - if (typeof a == "number" ? u = a === (o.startsWith("scale") ? 1 : 0) : u = parseFloat(a) === 0, !u || r) { - const l = d9(a, kb[o]); - if (!u) { - i = !1; - const d = ere[o] || o; - n += `${d}(${l}) `; - } - r && (e[o] = l); - } - } - return n = n.trim(), r ? n = r(e, i ? "" : n) : i && (n = "none"), n; -} -function ry(t, e, r) { - const { style: n, vars: i, transformOrigin: s } = t; - let o = !1, a = !1; - for (const u in e) { - const l = e[u]; - if (Sc.has(u)) { - o = !0; - continue; - } else if (s7(u)) { - i[u] = l; - continue; - } else { - const d = d9(l, kb[u]); - u.startsWith("origin") ? (a = !0, s[u] = d) : n[u] = d; - } - } - if (e.transform || (o || r ? n.transform = rre(e, t.transform, r) : n.transform && (n.transform = "none")), a) { - const { originX: u = "50%", originY: l = "50%", originZ: d = 0 } = s; - n.transformOrigin = `${u} ${l} ${d}`; - } -} -function r5(t, e, r) { - return typeof t == "string" ? t : Vt.transform(e + r * t); -} -function nre(t, e, r) { - const n = r5(e, t.x, t.width), i = r5(r, t.y, t.height); - return `${n} ${i}`; -} -const ire = { - offset: "stroke-dashoffset", - array: "stroke-dasharray" -}, sre = { - offset: "strokeDashoffset", - array: "strokeDasharray" -}; -function ore(t, e, r = 1, n = 0, i = !0) { - t.pathLength = 1; - const s = i ? ire : sre; - t[s.offset] = Vt.transform(-n); - const o = Vt.transform(e), a = Vt.transform(r); - t[s.array] = `${o} ${a}`; -} -function ny(t, { - attrX: e, - attrY: r, - attrScale: n, - originX: i, - originY: s, - pathLength: o, - pathSpacing: a = 1, - pathOffset: u = 0, - // This is object creation, which we try to avoid per-frame. - ...l -}, d, g) { - if (ry(t, l, g), d) { - t.style.viewBox && (t.attrs.viewBox = t.style.viewBox); - return; - } - t.attrs = t.style, t.style = {}; - const { attrs: w, style: A, dimensions: M } = t; - w.transform && (M && (A.transform = w.transform), delete w.transform), M && (i !== void 0 || s !== void 0 || A.transform) && (A.transformOrigin = nre(M, i !== void 0 ? i : 0.5, s !== void 0 ? s : 0.5)), e !== void 0 && (w.x = e), r !== void 0 && (w.y = r), n !== void 0 && (w.scale = n), o !== void 0 && ore(w, o, a, u, !1); -} -const iy = (t) => typeof t == "string" && t.toLowerCase() === "svg", are = { - useVisualState: l9({ - scrapeMotionValuesFromProps: f9, - createRenderState: h9, - onMount: (t, e, { renderState: r, latestValues: n }) => { - Lr.read(() => { - try { - r.dimensions = typeof e.getBBox == "function" ? e.getBBox() : e.getBoundingClientRect(); - } catch { - r.dimensions = { - x: 0, - y: 0, - width: 0, - height: 0 - }; - } - }), Lr.render(() => { - ny(r, n, iy(e.tagName), t.transformTemplate), c9(e, r); - }); - } - }) -}, cre = { - useVisualState: l9({ - scrapeMotionValuesFromProps: Qb, - createRenderState: ty - }) -}; -function p9(t, e, r) { - for (const n in e) - !Jn(e[n]) && !u9(n, r) && (t[n] = e[n]); -} -function ure({ transformTemplate: t }, e) { - return Oi(() => { - const r = ty(); - return ry(r, e, t), Object.assign({}, r.vars, r.style); - }, [e]); -} -function fre(t, e) { - const r = t.style || {}, n = {}; - return p9(n, r, t), Object.assign(n, ure(t, e)), n; -} -function lre(t, e) { - const r = {}, n = fre(t, e); - return t.drag && t.dragListener !== !1 && (r.draggable = !1, n.userSelect = n.WebkitUserSelect = n.WebkitTouchCallout = "none", n.touchAction = t.drag === !0 ? "none" : `pan-${t.drag === "x" ? "y" : "x"}`), t.tabIndex === void 0 && (t.onTap || t.onTapStart || t.whileTap) && (r.tabIndex = 0), r.style = n, r; -} -const hre = /* @__PURE__ */ new Set([ - "animate", - "exit", - "variants", - "initial", - "style", - "values", - "variants", - "transition", - "transformTemplate", - "custom", - "inherit", - "onBeforeLayoutMeasure", - "onAnimationStart", - "onAnimationComplete", - "onUpdate", - "onDragStart", - "onDrag", - "onDragEnd", - "onMeasureDragConstraints", - "onDirectionLock", - "onDragTransitionEnd", - "_dragX", - "_dragY", - "onHoverStart", - "onHoverEnd", - "onViewportEnter", - "onViewportLeave", - "globalTapTarget", - "ignoreStrict", - "viewport" -]); -function _0(t) { - return t.startsWith("while") || t.startsWith("drag") && t !== "draggable" || t.startsWith("layout") || t.startsWith("onTap") || t.startsWith("onPan") || t.startsWith("onLayout") || hre.has(t); -} -let g9 = (t) => !_0(t); -function dre(t) { - t && (g9 = (e) => e.startsWith("on") ? !_0(e) : t(e)); -} -try { - dre(require("@emotion/is-prop-valid").default); -} catch { -} -function pre(t, e, r) { - const n = {}; - for (const i in t) - i === "values" && typeof t.values == "object" || (g9(i) || r === !0 && _0(i) || !e && !_0(i) || // If trying to use native HTML drag events, forward drag listeners - t.draggable && i.startsWith("onDrag")) && (n[i] = t[i]); - return n; -} -function gre(t, e, r, n) { - const i = Oi(() => { - const s = h9(); - return ny(s, e, iy(n), t.transformTemplate), { - ...s.attrs, - style: { ...s.style } - }; - }, [e]); - if (t.style) { - const s = {}; - p9(s, t.style, t), i.style = { ...s, ...i.style }; - } - return i; -} -function mre(t = !1) { - return (r, n, i, { latestValues: s }, o) => { - const u = (Zb(r) ? gre : lre)(n, s, o, r), l = pre(n, typeof r == "string", t), d = r !== b5 ? { ...l, ...u, ref: i } : {}, { children: g } = n, w = Oi(() => Jn(g) ? g.get() : g, [g]); - return jd(r, { - ...d, - children: w - }); - }; -} -function vre(t, e) { - return function(n, { forwardMotionProps: i } = { forwardMotionProps: !1 }) { - const o = { - ...Zb(n) ? are : cre, - preloadedFeatures: t, - useRender: mre(i), - createVisualElement: e, - Component: n - }; - return Vte(o); - }; -} -const fv = { current: null }, m9 = { current: !1 }; -function bre() { - if (m9.current = !0, !!Xb) - if (window.matchMedia) { - const t = window.matchMedia("(prefers-reduced-motion)"), e = () => fv.current = t.matches; - t.addListener(e), e(); - } else - fv.current = !1; -} -function yre(t, e, r) { - for (const n in e) { - const i = e[n], s = r[n]; - if (Jn(i)) - t.addValue(n, i), process.env.NODE_ENV === "development" && mp(i.version === "11.11.17", `Attempting to mix Motion versions ${i.version} with 11.11.17 may not work as expected.`); - else if (Jn(s)) - t.addValue(n, Tl(i, { owner: t })); - else if (s !== i) - if (t.hasValue(n)) { - const o = t.getValue(n); - o.liveStyle === !0 ? o.jump(i) : o.hasAnimated || o.set(i); - } else { - const o = t.getStaticValue(n); - t.addValue(n, Tl(o !== void 0 ? o : i, { owner: t })); - } - } - for (const n in r) - e[n] === void 0 && t.removeValue(n); - return e; -} -const n5 = /* @__PURE__ */ new WeakMap(), wre = [...c7, Gn, _a], xre = (t) => wre.find(a7(t)), i5 = [ - "AnimationStart", - "AnimationComplete", - "Update", - "BeforeLayoutMeasure", - "LayoutMeasure", - "LayoutAnimationStart", - "LayoutAnimationComplete" -]; -class _re { - /** - * This method takes React props and returns found MotionValues. For example, HTML - * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays. - * - * This isn't an abstract method as it needs calling in the constructor, but it is - * intended to be one. - */ - scrapeMotionValuesFromProps(e, r, n) { - return {}; - } - constructor({ parent: e, props: r, presenceContext: n, reducedMotionConfig: i, blockInitialAnimation: s, visualState: o }, a = {}) { - this.current = null, this.children = /* @__PURE__ */ new Set(), this.isVariantNode = !1, this.isControllingVariants = !1, this.shouldReduceMotion = null, this.values = /* @__PURE__ */ new Map(), this.KeyframeResolver = Ob, this.features = {}, this.valueSubscriptions = /* @__PURE__ */ new Map(), this.prevMotionValues = {}, this.events = {}, this.propEventSubscriptions = {}, this.notifyUpdate = () => this.notify("Update", this.latestValues), this.render = () => { - this.current && (this.triggerBuild(), this.renderInstance(this.current, this.renderState, this.props.style, this.projection)); - }, this.renderScheduledAt = 0, this.scheduleRender = () => { - const w = Gs.now(); - this.renderScheduledAt < w && (this.renderScheduledAt = w, Lr.render(this.render, !1, !0)); - }; - const { latestValues: u, renderState: l } = o; - this.latestValues = u, this.baseTarget = { ...u }, this.initialValues = r.initial ? { ...u } : {}, this.renderState = l, this.parent = e, this.props = r, this.presenceContext = n, this.depth = e ? e.depth + 1 : 0, this.reducedMotionConfig = i, this.options = a, this.blockInitialAnimation = !!s, this.isControllingVariants = Ep(r), this.isVariantNode = s9(r), this.isVariantNode && (this.variantChildren = /* @__PURE__ */ new Set()), this.manuallyAnimateOnMount = !!(e && e.current); - const { willChange: d, ...g } = this.scrapeMotionValuesFromProps(r, {}, this); - for (const w in g) { - const A = g[w]; - u[w] !== void 0 && Jn(A) && A.set(u[w], !1); - } - } - mount(e) { - this.current = e, n5.set(e, this), this.projection && !this.projection.instance && this.projection.mount(e), this.parent && this.isVariantNode && !this.isControllingVariants && (this.removeFromVariantTree = this.parent.addVariantChild(this)), this.values.forEach((r, n) => this.bindToMotionValue(n, r)), m9.current || bre(), this.shouldReduceMotion = this.reducedMotionConfig === "never" ? !1 : this.reducedMotionConfig === "always" ? !0 : fv.current, process.env.NODE_ENV !== "production" && mp(this.shouldReduceMotion !== !0, "You have Reduced Motion enabled on your device. Animations may not appear as expected."), this.parent && this.parent.children.add(this), this.update(this.props, this.presenceContext); - } - unmount() { - n5.delete(this.current), this.projection && this.projection.unmount(), wa(this.notifyUpdate), wa(this.render), this.valueSubscriptions.forEach((e) => e()), this.valueSubscriptions.clear(), this.removeFromVariantTree && this.removeFromVariantTree(), this.parent && this.parent.children.delete(this); - for (const e in this.events) - this.events[e].clear(); - for (const e in this.features) { - const r = this.features[e]; - r && (r.unmount(), r.isMounted = !1); - } - this.current = null; - } - bindToMotionValue(e, r) { - this.valueSubscriptions.has(e) && this.valueSubscriptions.get(e)(); - const n = Sc.has(e), i = r.on("change", (a) => { - this.latestValues[e] = a, this.props.onUpdate && Lr.preRender(this.notifyUpdate), n && this.projection && (this.projection.isTransformDirty = !0); - }), s = r.on("renderRequest", this.scheduleRender); - let o; - window.MotionCheckAppearSync && (o = window.MotionCheckAppearSync(this, e, r)), this.valueSubscriptions.set(e, () => { - i(), s(), o && o(), r.owner && r.stop(); - }); - } - sortNodePosition(e) { - return !this.current || !this.sortInstanceNodePosition || this.type !== e.type ? 0 : this.sortInstanceNodePosition(this.current, e.current); - } - updateFeatures() { - let e = "animation"; - for (e in Iu) { - const r = Iu[e]; - if (!r) - continue; - const { isEnabled: n, Feature: i } = r; - if (!this.features[e] && i && n(this.props) && (this.features[e] = new i(this)), this.features[e]) { - const s = this.features[e]; - s.isMounted ? s.update() : (s.mount(), s.isMounted = !0); - } - } - } - triggerBuild() { - this.build(this.renderState, this.latestValues, this.props); - } - /** - * Measure the current viewport box with or without transforms. - * Only measures axis-aligned boxes, rotate and skew must be manually - * removed with a re-render to work. - */ - measureViewportBox() { - return this.current ? this.measureInstanceViewportBox(this.current, this.props) : ln(); - } - getStaticValue(e) { - return this.latestValues[e]; - } - setStaticValue(e, r) { - this.latestValues[e] = r; - } - /** - * Update the provided props. Ensure any newly-added motion values are - * added to our map, old ones removed, and listeners updated. - */ - update(e, r) { - (e.transformTemplate || this.props.transformTemplate) && this.scheduleRender(), this.prevProps = this.props, this.props = e, this.prevPresenceContext = this.presenceContext, this.presenceContext = r; - for (let n = 0; n < i5.length; n++) { - const i = i5[n]; - this.propEventSubscriptions[i] && (this.propEventSubscriptions[i](), delete this.propEventSubscriptions[i]); - const s = "on" + i, o = e[s]; - o && (this.propEventSubscriptions[i] = this.on(i, o)); - } - this.prevMotionValues = yre(this, this.scrapeMotionValuesFromProps(e, this.prevProps, this), this.prevMotionValues), this.handleChildMotionValue && this.handleChildMotionValue(); - } - getProps() { - return this.props; - } - /** - * Returns the variant definition with a given name. - */ - getVariant(e) { - return this.props.variants ? this.props.variants[e] : void 0; - } - /** - * Returns the defined default transition on this component. - */ - getDefaultTransition() { - return this.props.transition; - } - getTransformPagePoint() { - return this.props.transformPagePoint; - } - getClosestVariantNode() { - return this.isVariantNode ? this : this.parent ? this.parent.getClosestVariantNode() : void 0; - } - /** - * Add a child visual element to our set of children. - */ - addVariantChild(e) { - const r = this.getClosestVariantNode(); - if (r) - return r.variantChildren && r.variantChildren.add(e), () => r.variantChildren.delete(e); - } - /** - * Add a motion value and bind it to this visual element. - */ - addValue(e, r) { - const n = this.values.get(e); - r !== n && (n && this.removeValue(e), this.bindToMotionValue(e, r), this.values.set(e, r), this.latestValues[e] = r.get()); - } - /** - * Remove a motion value and unbind any active subscriptions. - */ - removeValue(e) { - this.values.delete(e); - const r = this.valueSubscriptions.get(e); - r && (r(), this.valueSubscriptions.delete(e)), delete this.latestValues[e], this.removeValueFromRenderState(e, this.renderState); - } - /** - * Check whether we have a motion value for this key - */ - hasValue(e) { - return this.values.has(e); - } - getValue(e, r) { - if (this.props.values && this.props.values[e]) - return this.props.values[e]; - let n = this.values.get(e); - return n === void 0 && r !== void 0 && (n = Tl(r === null ? void 0 : r, { owner: this }), this.addValue(e, n)), n; - } - /** - * If we're trying to animate to a previously unencountered value, - * we need to check for it in our state and as a last resort read it - * directly from the instance (which might have performance implications). - */ - readValue(e, r) { - var n; - let i = this.latestValues[e] !== void 0 || !this.current ? this.latestValues[e] : (n = this.getBaseTargetFromProps(this.props, e)) !== null && n !== void 0 ? n : this.readValueFromInstance(this.current, e, this.options); - return i != null && (typeof i == "string" && (n7(i) || r7(i)) ? i = parseFloat(i) : !xre(i) && _a.test(r) && (i = m7(e, r)), this.setBaseTarget(e, Jn(i) ? i.get() : i)), Jn(i) ? i.get() : i; - } - /** - * Set the base target to later animate back to. This is currently - * only hydrated on creation and when we first read a value. - */ - setBaseTarget(e, r) { - this.baseTarget[e] = r; - } - /** - * Find the base target for a value thats been removed from all animation - * props. - */ - getBaseTarget(e) { - var r; - const { initial: n } = this.props; - let i; - if (typeof n == "string" || typeof n == "object") { - const o = Pb(this.props, n, (r = this.presenceContext) === null || r === void 0 ? void 0 : r.custom); - o && (i = o[e]); - } - if (n && i !== void 0) - return i; - const s = this.getBaseTargetFromProps(this.props, e); - return s !== void 0 && !Jn(s) ? s : this.initialValues[e] !== void 0 && i === void 0 ? void 0 : this.baseTarget[e]; - } - on(e, r) { - return this.events[e] || (this.events[e] = new Kb()), this.events[e].add(r); - } - notify(e, ...r) { - this.events[e] && this.events[e].notify(...r); - } -} -class v9 extends _re { - constructor() { - super(...arguments), this.KeyframeResolver = v7; - } - sortInstanceNodePosition(e, r) { - return e.compareDocumentPosition(r) & 2 ? 1 : -1; - } - getBaseTargetFromProps(e, r) { - return e.style ? e.style[r] : void 0; - } - removeValueFromRenderState(e, { vars: r, style: n }) { - delete r[e], delete n[e]; - } -} -function Ere(t) { - return window.getComputedStyle(t); -} -class Sre extends v9 { - constructor() { - super(...arguments), this.type = "html", this.renderInstance = o9; - } - readValueFromInstance(e, r) { - if (Sc.has(r)) { - const n = $b(r); - return n && n.default || 0; - } else { - const n = Ere(e), i = (s7(r) ? n.getPropertyValue(r) : n[r]) || 0; - return typeof i == "string" ? i.trim() : i; - } - } - measureInstanceViewportBox(e, { transformPagePoint: r }) { - return z7(e, r); - } - build(e, r, n) { - ry(e, r, n.transformTemplate); - } - scrapeMotionValuesFromProps(e, r, n) { - return Qb(e, r, n); - } - handleChildMotionValue() { - this.childSubscription && (this.childSubscription(), delete this.childSubscription); - const { children: e } = this.props; - Jn(e) && (this.childSubscription = e.on("change", (r) => { - this.current && (this.current.textContent = `${r}`); - })); - } -} -class Are extends v9 { - constructor() { - super(...arguments), this.type = "svg", this.isSVGTag = !1, this.measureInstanceViewportBox = ln; - } - getBaseTargetFromProps(e, r) { - return e[r]; - } - readValueFromInstance(e, r) { - if (Sc.has(r)) { - const n = $b(r); - return n && n.default || 0; - } - return r = a9.has(r) ? r : Vb(r), e.getAttribute(r); - } - scrapeMotionValuesFromProps(e, r, n) { - return f9(e, r, n); - } - build(e, r, n) { - ny(e, r, this.isSVGTag, n.transformTemplate); - } - renderInstance(e, r, n, i) { - c9(e, r, n, i); - } - mount(e) { - this.isSVGTag = iy(e.tagName), super.mount(e); - } -} -const Pre = (t, e) => Zb(t) ? new Are(e) : new Sre(e, { - allowProjection: t !== b5 -}), Mre = /* @__PURE__ */ vre({ - ...mee, - ...Fte, - ...Mte, - ...Bte -}, Pre), Ire = /* @__PURE__ */ aZ(Mre); -class Cre extends Gt.Component { - getSnapshotBeforeUpdate(e) { - const r = this.props.childRef.current; - if (r && e.isPresent && !this.props.isPresent) { - const n = this.props.sizeRef.current; - n.height = r.offsetHeight || 0, n.width = r.offsetWidth || 0, n.top = r.offsetTop, n.left = r.offsetLeft; - } - return null; - } - /** - * Required with getSnapshotBeforeUpdate to stop React complaining. - */ - componentDidUpdate() { - } - render() { - return this.props.children; - } -} -function Tre({ children: t, isPresent: e }) { - const r = mv(), n = bi(null), i = bi({ - width: 0, - height: 0, - top: 0, - left: 0 - }), { nonce: s } = Tn(Jb); - return v5(() => { - const { width: o, height: a, top: u, left: l } = i.current; - if (e || !n.current || !o || !a) - return; - n.current.dataset.motionPopId = r; - const d = document.createElement("style"); - return s && (d.nonce = s), document.head.appendChild(d), d.sheet && d.sheet.insertRule(` - [data-motion-pop-id="${r}"] { - position: absolute !important; - width: ${o}px !important; - height: ${a}px !important; - top: ${u}px !important; - left: ${l}px !important; - } - `), () => { - document.head.removeChild(d); - }; - }, [e]), me.jsx(Cre, { isPresent: e, childRef: n, sizeRef: i, children: Gt.cloneElement(t, { ref: n }) }); -} -const Rre = ({ children: t, initial: e, isPresent: r, onExitComplete: n, custom: i, presenceAffectsLayout: s, mode: o }) => { - const a = ey(Dre), u = mv(), l = vv((g) => { - a.set(g, !0); - for (const w of a.values()) - if (!w) - return; - n && n(); - }, [a, n]), d = Oi( - () => ({ - id: u, - initial: e, - isPresent: r, - custom: i, - onExitComplete: l, - register: (g) => (a.set(g, !1), () => a.delete(g)) - }), - /** - * If the presence of a child affects the layout of the components around it, - * we want to make a new context value to ensure they get re-rendered - * so they can detect that layout change. - */ - s ? [Math.random(), l] : [r, l] - ); - return Oi(() => { - a.forEach((g, w) => a.set(w, !1)); - }, [r]), Gt.useEffect(() => { - !r && !a.size && n && n(); - }, [r]), o === "popLayout" && (t = me.jsx(Tre, { isPresent: r, children: t })), me.jsx(xp.Provider, { value: d, children: t }); -}; -function Dre() { - return /* @__PURE__ */ new Map(); -} -const vd = (t) => t.key || ""; -function s5(t) { - const e = []; - return MR.forEach(t, (r) => { - IR(r) && e.push(r); - }), e; -} -const Ore = ({ children: t, exitBeforeEnter: e, custom: r, initial: n = !0, onExitComplete: i, presenceAffectsLayout: s = !0, mode: o = "sync" }) => { - Uo(!e, "Replace exitBeforeEnter with mode='wait'"); - const a = Oi(() => s5(t), [t]), u = a.map(vd), l = bi(!0), d = bi(a), g = ey(() => /* @__PURE__ */ new Map()), [w, A] = fr(a), [M, N] = fr(a); - r9(() => { - l.current = !1, d.current = a; - for (let $ = 0; $ < M.length; $++) { - const K = vd(M[$]); - u.includes(K) ? g.delete(K) : g.get(K) !== !0 && g.set(K, !1); - } - }, [M, u.length, u.join("-")]); - const L = []; - if (a !== w) { - let $ = [...a]; - for (let K = 0; K < M.length; K++) { - const H = M[K], V = vd(H); - u.includes(V) || ($.splice(K, 0, H), L.push(H)); - } - o === "wait" && L.length && ($ = L), N(s5($)), A(a); - return; - } - process.env.NODE_ENV !== "production" && o === "wait" && M.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`); - const { forceRender: F } = Tn(Gb); - return me.jsx(me.Fragment, { children: M.map(($) => { - const K = vd($), H = a === M || u.includes(K), V = () => { - if (g.has(K)) - g.set(K, !0); - else - return; - let te = !0; - g.forEach((R) => { - R || (te = !1); - }), te && (F == null || F(), N(d.current), i && i()); - }; - return me.jsx(Rre, { isPresent: H, initial: !l.current || n ? void 0 : !1, custom: H ? void 0 : r, presenceAffectsLayout: s, mode: o, onExitComplete: H ? void 0 : V, children: $ }, K); - }) }); -}, Ac = (t) => /* @__PURE__ */ me.jsx(Ore, { children: /* @__PURE__ */ me.jsx( - Ire.div, - { - initial: { x: 0, opacity: 0 }, - animate: { x: 0, opacity: 1 }, - exit: { x: 30, opacity: 0 }, - transition: { duration: 0.3 }, - className: t.className, - children: t.children - } -) }); -function sy(t) { - const { icon: e, title: r, extra: n, onClick: i } = t; - function s() { - i && i(); - } - return /* @__PURE__ */ me.jsxs( - "div", - { - className: "xc-rounded-lg xc-group xc-flex xc-cursor-pointer xc-items-center xc-gap-2 xc-border xc-border-white xc-border-opacity-15 xc-px-4 xc-py-2 xc-transition-all hover:xc-shadow-lg", - onClick: s, - children: [ - e, - r, - /* @__PURE__ */ me.jsxs("div", { className: "xc-relative xc-ml-auto xc-h-6", children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-relative xc-left-0 xc-opacity-100 xc-transition-all group-hover:xc-left-2 group-hover:xc-opacity-0", children: n }), - /* @__PURE__ */ me.jsx("div", { className: "xc-absolute xc-right-2 xc-top-0 xc-text-gray-400 xc-opacity-0 xc-transition-all group-hover:xc-right-0 group-hover:xc-opacity-100", children: /* @__PURE__ */ me.jsx(tZ, {}) }) - ] }) - ] - } - ); -} -function Nre(t) { - return t.lastUsed ? /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-items-center xc-gap-2 xc-rounded-full xc-py-1 xc-text-xs xc-text-gray-500", children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-h-1 xc-w-1 xc-rounded-full xc-bg-[#009E8C]" }), - "Last Used" - ] }) : t.installed ? /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-items-center xc-gap-2 xc-rounded-full xc-py-1 xc-text-xs xc-text-gray-500", children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-h-1 xc-w-1 xc-rounded-full xc-bg-[#2596FF]" }), - "Installed" - ] }) : null; -} -function b9(t) { - var o, a; - const { wallet: e, onClick: r } = t, n = /* @__PURE__ */ me.jsx("img", { className: "xc-rounded-md xc-h-5 xc-w-5", src: (o = e.config) == null ? void 0 : o.image }), i = ((a = e.config) == null ? void 0 : a.name) || "", s = Oi(() => Nre(e), [e]); - return /* @__PURE__ */ me.jsx(sy, { icon: n, title: i, extra: s, onClick: () => r(e) }); -} -function y9(t) { - var e, r, n = ""; - if (typeof t == "string" || typeof t == "number") n += t; - else if (typeof t == "object") if (Array.isArray(t)) { - var i = t.length; - for (e = 0; e < i; e++) t[e] && (r = y9(t[e])) && (n && (n += " "), n += r); - } else for (r in t) t[r] && (n && (n += " "), n += r); - return n; -} -function Lre() { - for (var t, e, r = 0, n = "", i = arguments.length; r < i; r++) (t = arguments[r]) && (e = y9(t)) && (n && (n += " "), n += e); - return n; -} -const kre = Lre, oy = "-", $re = (t) => { - const e = Bre(t), { - conflictingClassGroups: r, - conflictingClassGroupModifiers: n - } = t; - return { - getClassGroupId: (o) => { - const a = o.split(oy); - return a[0] === "" && a.length !== 1 && a.shift(), w9(a, e) || Fre(o); - }, - getConflictingClassGroupIds: (o, a) => { - const u = r[o] || []; - return a && n[o] ? [...u, ...n[o]] : u; - } - }; -}, w9 = (t, e) => { - var o; - if (t.length === 0) - return e.classGroupId; - const r = t[0], n = e.nextPart.get(r), i = n ? w9(t.slice(1), n) : void 0; - if (i) - return i; - if (e.validators.length === 0) - return; - const s = t.join(oy); - return (o = e.validators.find(({ - validator: a - }) => a(s))) == null ? void 0 : o.classGroupId; -}, o5 = /^\[(.+)\]$/, Fre = (t) => { - if (o5.test(t)) { - const e = o5.exec(t)[1], r = e == null ? void 0 : e.substring(0, e.indexOf(":")); - if (r) - return "arbitrary.." + r; - } -}, Bre = (t) => { - const { - theme: e, - prefix: r - } = t, n = { - nextPart: /* @__PURE__ */ new Map(), - validators: [] - }; - return jre(Object.entries(t.classGroups), r).forEach(([s, o]) => { - lv(o, n, s, e); - }), n; -}, lv = (t, e, r, n) => { - t.forEach((i) => { - if (typeof i == "string") { - const s = i === "" ? e : a5(e, i); - s.classGroupId = r; - return; - } - if (typeof i == "function") { - if (Ure(i)) { - lv(i(n), e, r, n); - return; - } - e.validators.push({ - validator: i, - classGroupId: r - }); - return; - } - Object.entries(i).forEach(([s, o]) => { - lv(o, a5(e, s), r, n); - }); - }); -}, a5 = (t, e) => { - let r = t; - return e.split(oy).forEach((n) => { - r.nextPart.has(n) || r.nextPart.set(n, { - nextPart: /* @__PURE__ */ new Map(), - validators: [] - }), r = r.nextPart.get(n); - }), r; -}, Ure = (t) => t.isThemeGetter, jre = (t, e) => e ? t.map(([r, n]) => { - const i = n.map((s) => typeof s == "string" ? e + s : typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([o, a]) => [e + o, a])) : s); - return [r, i]; -}) : t, qre = (t) => { - if (t < 1) - return { - get: () => { - }, - set: () => { - } - }; - let e = 0, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(); - const i = (s, o) => { - r.set(s, o), e++, e > t && (e = 0, n = r, r = /* @__PURE__ */ new Map()); - }; - return { - get(s) { - let o = r.get(s); - if (o !== void 0) - return o; - if ((o = n.get(s)) !== void 0) - return i(s, o), o; - }, - set(s, o) { - r.has(s) ? r.set(s, o) : i(s, o); - } - }; -}, x9 = "!", zre = (t) => { - const { - separator: e, - experimentalParseClassName: r - } = t, n = e.length === 1, i = e[0], s = e.length, o = (a) => { - const u = []; - let l = 0, d = 0, g; - for (let L = 0; L < a.length; L++) { - let F = a[L]; - if (l === 0) { - if (F === i && (n || a.slice(L, L + s) === e)) { - u.push(a.slice(d, L)), d = L + s; - continue; - } - if (F === "/") { - g = L; - continue; - } - } - F === "[" ? l++ : F === "]" && l--; - } - const w = u.length === 0 ? a : a.substring(d), A = w.startsWith(x9), M = A ? w.substring(1) : w, N = g && g > d ? g - d : void 0; - return { - modifiers: u, - hasImportantModifier: A, - baseClassName: M, - maybePostfixModifierPosition: N - }; - }; - return r ? (a) => r({ - className: a, - parseClassName: o - }) : o; -}, Hre = (t) => { - if (t.length <= 1) - return t; - const e = []; - let r = []; - return t.forEach((n) => { - n[0] === "[" ? (e.push(...r.sort(), n), r = []) : r.push(n); - }), e.push(...r.sort()), e; -}, Wre = (t) => ({ - cache: qre(t.cacheSize), - parseClassName: zre(t), - ...$re(t) -}), Kre = /\s+/, Vre = (t, e) => { - const { - parseClassName: r, - getClassGroupId: n, - getConflictingClassGroupIds: i - } = e, s = [], o = t.trim().split(Kre); - let a = ""; - for (let u = o.length - 1; u >= 0; u -= 1) { - const l = o[u], { - modifiers: d, - hasImportantModifier: g, - baseClassName: w, - maybePostfixModifierPosition: A - } = r(l); - let M = !!A, N = n(M ? w.substring(0, A) : w); - if (!N) { - if (!M) { - a = l + (a.length > 0 ? " " + a : a); - continue; - } - if (N = n(w), !N) { - a = l + (a.length > 0 ? " " + a : a); - continue; - } - M = !1; - } - const L = Hre(d).join(":"), F = g ? L + x9 : L, $ = F + N; - if (s.includes($)) - continue; - s.push($); - const K = i(N, M); - for (let H = 0; H < K.length; ++H) { - const V = K[H]; - s.push(F + V); - } - a = l + (a.length > 0 ? " " + a : a); - } - return a; -}; -function Gre() { - let t = 0, e, r, n = ""; - for (; t < arguments.length; ) - (e = arguments[t++]) && (r = _9(e)) && (n && (n += " "), n += r); - return n; -} -const _9 = (t) => { - if (typeof t == "string") - return t; - let e, r = ""; - for (let n = 0; n < t.length; n++) - t[n] && (e = _9(t[n])) && (r && (r += " "), r += e); - return r; -}; -function Yre(t, ...e) { - let r, n, i, s = o; - function o(u) { - const l = e.reduce((d, g) => g(d), t()); - return r = Wre(l), n = r.cache.get, i = r.cache.set, s = a, a(u); - } - function a(u) { - const l = n(u); - if (l) - return l; - const d = Vre(u, r); - return i(u, d), d; - } - return function() { - return s(Gre.apply(null, arguments)); - }; -} -const Gr = (t) => { - const e = (r) => r[t] || []; - return e.isThemeGetter = !0, e; -}, E9 = /^\[(?:([a-z-]+):)?(.+)\]$/i, Jre = /^\d+\/\d+$/, Xre = /* @__PURE__ */ new Set(["px", "full", "screen"]), Zre = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, Qre = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, ene = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, tne = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, rne = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, vo = (t) => gu(t) || Xre.has(t) || Jre.test(t), ra = (t) => Vu(t, "length", fne), gu = (t) => !!t && !Number.isNaN(Number(t)), Wm = (t) => Vu(t, "number", gu), Of = (t) => !!t && Number.isInteger(Number(t)), nne = (t) => t.endsWith("%") && gu(t.slice(0, -1)), cr = (t) => E9.test(t), na = (t) => Zre.test(t), ine = /* @__PURE__ */ new Set(["length", "size", "percentage"]), sne = (t) => Vu(t, ine, S9), one = (t) => Vu(t, "position", S9), ane = /* @__PURE__ */ new Set(["image", "url"]), cne = (t) => Vu(t, ane, hne), une = (t) => Vu(t, "", lne), Nf = () => !0, Vu = (t, e, r) => { - const n = E9.exec(t); - return n ? n[1] ? typeof e == "string" ? n[1] === e : e.has(n[1]) : r(n[2]) : !1; -}, fne = (t) => ( - // `colorFunctionRegex` check is necessary because color functions can have percentages in them which which would be incorrectly classified as lengths. - // For example, `hsl(0 0% 0%)` would be classified as a length without this check. - // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough. - Qre.test(t) && !ene.test(t) -), S9 = () => !1, lne = (t) => tne.test(t), hne = (t) => rne.test(t), dne = () => { - const t = Gr("colors"), e = Gr("spacing"), r = Gr("blur"), n = Gr("brightness"), i = Gr("borderColor"), s = Gr("borderRadius"), o = Gr("borderSpacing"), a = Gr("borderWidth"), u = Gr("contrast"), l = Gr("grayscale"), d = Gr("hueRotate"), g = Gr("invert"), w = Gr("gap"), A = Gr("gradientColorStops"), M = Gr("gradientColorStopPositions"), N = Gr("inset"), L = Gr("margin"), F = Gr("opacity"), $ = Gr("padding"), K = Gr("saturate"), H = Gr("scale"), V = Gr("sepia"), te = Gr("skew"), R = Gr("space"), W = Gr("translate"), pe = () => ["auto", "contain", "none"], Ee = () => ["auto", "hidden", "clip", "visible", "scroll"], Y = () => ["auto", cr, e], S = () => [cr, e], m = () => ["", vo, ra], f = () => ["auto", gu, cr], p = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], b = () => ["solid", "dashed", "dotted", "double", "none"], x = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], _ = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], E = () => ["", "0", cr], v = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], P = () => [gu, cr]; - return { - cacheSize: 500, - separator: ":", - theme: { - colors: [Nf], - spacing: [vo, ra], - blur: ["none", "", na, cr], - brightness: P(), - borderColor: [t], - borderRadius: ["none", "", "full", na, cr], - borderSpacing: S(), - borderWidth: m(), - contrast: P(), - grayscale: E(), - hueRotate: P(), - invert: E(), - gap: S(), - gradientColorStops: [t], - gradientColorStopPositions: [nne, ra], - inset: Y(), - margin: Y(), - opacity: P(), - padding: S(), - saturate: P(), - scale: P(), - sepia: E(), - skew: P(), - space: S(), - translate: S() - }, - classGroups: { - // Layout - /** - * Aspect Ratio - * @see https://tailwindcss.com/docs/aspect-ratio - */ - aspect: [{ - aspect: ["auto", "square", "video", cr] - }], - /** - * Container - * @see https://tailwindcss.com/docs/container - */ - container: ["container"], - /** - * Columns - * @see https://tailwindcss.com/docs/columns - */ - columns: [{ - columns: [na] - }], - /** - * Break After - * @see https://tailwindcss.com/docs/break-after - */ - "break-after": [{ - "break-after": v() - }], - /** - * Break Before - * @see https://tailwindcss.com/docs/break-before - */ - "break-before": [{ - "break-before": v() - }], - /** - * Break Inside - * @see https://tailwindcss.com/docs/break-inside - */ - "break-inside": [{ - "break-inside": ["auto", "avoid", "avoid-page", "avoid-column"] - }], - /** - * Box Decoration Break - * @see https://tailwindcss.com/docs/box-decoration-break - */ - "box-decoration": [{ - "box-decoration": ["slice", "clone"] - }], - /** - * Box Sizing - * @see https://tailwindcss.com/docs/box-sizing - */ - box: [{ - box: ["border", "content"] - }], - /** - * Display - * @see https://tailwindcss.com/docs/display - */ - display: ["block", "inline-block", "inline", "flex", "inline-flex", "table", "inline-table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row-group", "table-row", "flow-root", "grid", "inline-grid", "contents", "list-item", "hidden"], - /** - * Floats - * @see https://tailwindcss.com/docs/float - */ - float: [{ - float: ["right", "left", "none", "start", "end"] - }], - /** - * Clear - * @see https://tailwindcss.com/docs/clear - */ - clear: [{ - clear: ["left", "right", "both", "none", "start", "end"] - }], - /** - * Isolation - * @see https://tailwindcss.com/docs/isolation - */ - isolation: ["isolate", "isolation-auto"], - /** - * Object Fit - * @see https://tailwindcss.com/docs/object-fit - */ - "object-fit": [{ - object: ["contain", "cover", "fill", "none", "scale-down"] - }], - /** - * Object Position - * @see https://tailwindcss.com/docs/object-position - */ - "object-position": [{ - object: [...p(), cr] - }], - /** - * Overflow - * @see https://tailwindcss.com/docs/overflow - */ - overflow: [{ - overflow: Ee() - }], - /** - * Overflow X - * @see https://tailwindcss.com/docs/overflow - */ - "overflow-x": [{ - "overflow-x": Ee() - }], - /** - * Overflow Y - * @see https://tailwindcss.com/docs/overflow - */ - "overflow-y": [{ - "overflow-y": Ee() - }], - /** - * Overscroll Behavior - * @see https://tailwindcss.com/docs/overscroll-behavior - */ - overscroll: [{ - overscroll: pe() - }], - /** - * Overscroll Behavior X - * @see https://tailwindcss.com/docs/overscroll-behavior - */ - "overscroll-x": [{ - "overscroll-x": pe() - }], - /** - * Overscroll Behavior Y - * @see https://tailwindcss.com/docs/overscroll-behavior - */ - "overscroll-y": [{ - "overscroll-y": pe() - }], - /** - * Position - * @see https://tailwindcss.com/docs/position - */ - position: ["static", "fixed", "absolute", "relative", "sticky"], - /** - * Top / Right / Bottom / Left - * @see https://tailwindcss.com/docs/top-right-bottom-left - */ - inset: [{ - inset: [N] - }], - /** - * Right / Left - * @see https://tailwindcss.com/docs/top-right-bottom-left - */ - "inset-x": [{ - "inset-x": [N] - }], - /** - * Top / Bottom - * @see https://tailwindcss.com/docs/top-right-bottom-left - */ - "inset-y": [{ - "inset-y": [N] - }], - /** - * Start - * @see https://tailwindcss.com/docs/top-right-bottom-left - */ - start: [{ - start: [N] - }], - /** - * End - * @see https://tailwindcss.com/docs/top-right-bottom-left - */ - end: [{ - end: [N] - }], - /** - * Top - * @see https://tailwindcss.com/docs/top-right-bottom-left - */ - top: [{ - top: [N] - }], - /** - * Right - * @see https://tailwindcss.com/docs/top-right-bottom-left - */ - right: [{ - right: [N] - }], - /** - * Bottom - * @see https://tailwindcss.com/docs/top-right-bottom-left - */ - bottom: [{ - bottom: [N] - }], - /** - * Left - * @see https://tailwindcss.com/docs/top-right-bottom-left - */ - left: [{ - left: [N] - }], - /** - * Visibility - * @see https://tailwindcss.com/docs/visibility - */ - visibility: ["visible", "invisible", "collapse"], - /** - * Z-Index - * @see https://tailwindcss.com/docs/z-index - */ - z: [{ - z: ["auto", Of, cr] - }], - // Flexbox and Grid - /** - * Flex Basis - * @see https://tailwindcss.com/docs/flex-basis - */ - basis: [{ - basis: Y() - }], - /** - * Flex Direction - * @see https://tailwindcss.com/docs/flex-direction - */ - "flex-direction": [{ - flex: ["row", "row-reverse", "col", "col-reverse"] - }], - /** - * Flex Wrap - * @see https://tailwindcss.com/docs/flex-wrap - */ - "flex-wrap": [{ - flex: ["wrap", "wrap-reverse", "nowrap"] - }], - /** - * Flex - * @see https://tailwindcss.com/docs/flex - */ - flex: [{ - flex: ["1", "auto", "initial", "none", cr] - }], - /** - * Flex Grow - * @see https://tailwindcss.com/docs/flex-grow - */ - grow: [{ - grow: E() - }], - /** - * Flex Shrink - * @see https://tailwindcss.com/docs/flex-shrink - */ - shrink: [{ - shrink: E() - }], - /** - * Order - * @see https://tailwindcss.com/docs/order - */ - order: [{ - order: ["first", "last", "none", Of, cr] - }], - /** - * Grid Template Columns - * @see https://tailwindcss.com/docs/grid-template-columns - */ - "grid-cols": [{ - "grid-cols": [Nf] - }], - /** - * Grid Column Start / End - * @see https://tailwindcss.com/docs/grid-column - */ - "col-start-end": [{ - col: ["auto", { - span: ["full", Of, cr] - }, cr] - }], - /** - * Grid Column Start - * @see https://tailwindcss.com/docs/grid-column - */ - "col-start": [{ - "col-start": f() - }], - /** - * Grid Column End - * @see https://tailwindcss.com/docs/grid-column - */ - "col-end": [{ - "col-end": f() - }], - /** - * Grid Template Rows - * @see https://tailwindcss.com/docs/grid-template-rows - */ - "grid-rows": [{ - "grid-rows": [Nf] - }], - /** - * Grid Row Start / End - * @see https://tailwindcss.com/docs/grid-row - */ - "row-start-end": [{ - row: ["auto", { - span: [Of, cr] - }, cr] - }], - /** - * Grid Row Start - * @see https://tailwindcss.com/docs/grid-row - */ - "row-start": [{ - "row-start": f() - }], - /** - * Grid Row End - * @see https://tailwindcss.com/docs/grid-row - */ - "row-end": [{ - "row-end": f() - }], - /** - * Grid Auto Flow - * @see https://tailwindcss.com/docs/grid-auto-flow - */ - "grid-flow": [{ - "grid-flow": ["row", "col", "dense", "row-dense", "col-dense"] - }], - /** - * Grid Auto Columns - * @see https://tailwindcss.com/docs/grid-auto-columns - */ - "auto-cols": [{ - "auto-cols": ["auto", "min", "max", "fr", cr] - }], - /** - * Grid Auto Rows - * @see https://tailwindcss.com/docs/grid-auto-rows - */ - "auto-rows": [{ - "auto-rows": ["auto", "min", "max", "fr", cr] - }], - /** - * Gap - * @see https://tailwindcss.com/docs/gap - */ - gap: [{ - gap: [w] - }], - /** - * Gap X - * @see https://tailwindcss.com/docs/gap - */ - "gap-x": [{ - "gap-x": [w] - }], - /** - * Gap Y - * @see https://tailwindcss.com/docs/gap - */ - "gap-y": [{ - "gap-y": [w] - }], - /** - * Justify Content - * @see https://tailwindcss.com/docs/justify-content - */ - "justify-content": [{ - justify: ["normal", ..._()] - }], - /** - * Justify Items - * @see https://tailwindcss.com/docs/justify-items - */ - "justify-items": [{ - "justify-items": ["start", "end", "center", "stretch"] - }], - /** - * Justify Self - * @see https://tailwindcss.com/docs/justify-self - */ - "justify-self": [{ - "justify-self": ["auto", "start", "end", "center", "stretch"] - }], - /** - * Align Content - * @see https://tailwindcss.com/docs/align-content - */ - "align-content": [{ - content: ["normal", ..._(), "baseline"] - }], - /** - * Align Items - * @see https://tailwindcss.com/docs/align-items - */ - "align-items": [{ - items: ["start", "end", "center", "baseline", "stretch"] - }], - /** - * Align Self - * @see https://tailwindcss.com/docs/align-self - */ - "align-self": [{ - self: ["auto", "start", "end", "center", "stretch", "baseline"] - }], - /** - * Place Content - * @see https://tailwindcss.com/docs/place-content - */ - "place-content": [{ - "place-content": [..._(), "baseline"] - }], - /** - * Place Items - * @see https://tailwindcss.com/docs/place-items - */ - "place-items": [{ - "place-items": ["start", "end", "center", "baseline", "stretch"] - }], - /** - * Place Self - * @see https://tailwindcss.com/docs/place-self - */ - "place-self": [{ - "place-self": ["auto", "start", "end", "center", "stretch"] - }], - // Spacing - /** - * Padding - * @see https://tailwindcss.com/docs/padding - */ - p: [{ - p: [$] - }], - /** - * Padding X - * @see https://tailwindcss.com/docs/padding - */ - px: [{ - px: [$] - }], - /** - * Padding Y - * @see https://tailwindcss.com/docs/padding - */ - py: [{ - py: [$] - }], - /** - * Padding Start - * @see https://tailwindcss.com/docs/padding - */ - ps: [{ - ps: [$] - }], - /** - * Padding End - * @see https://tailwindcss.com/docs/padding - */ - pe: [{ - pe: [$] - }], - /** - * Padding Top - * @see https://tailwindcss.com/docs/padding - */ - pt: [{ - pt: [$] - }], - /** - * Padding Right - * @see https://tailwindcss.com/docs/padding - */ - pr: [{ - pr: [$] - }], - /** - * Padding Bottom - * @see https://tailwindcss.com/docs/padding - */ - pb: [{ - pb: [$] - }], - /** - * Padding Left - * @see https://tailwindcss.com/docs/padding - */ - pl: [{ - pl: [$] - }], - /** - * Margin - * @see https://tailwindcss.com/docs/margin - */ - m: [{ - m: [L] - }], - /** - * Margin X - * @see https://tailwindcss.com/docs/margin - */ - mx: [{ - mx: [L] - }], - /** - * Margin Y - * @see https://tailwindcss.com/docs/margin - */ - my: [{ - my: [L] - }], - /** - * Margin Start - * @see https://tailwindcss.com/docs/margin - */ - ms: [{ - ms: [L] - }], - /** - * Margin End - * @see https://tailwindcss.com/docs/margin - */ - me: [{ - me: [L] - }], - /** - * Margin Top - * @see https://tailwindcss.com/docs/margin - */ - mt: [{ - mt: [L] - }], - /** - * Margin Right - * @see https://tailwindcss.com/docs/margin - */ - mr: [{ - mr: [L] - }], - /** - * Margin Bottom - * @see https://tailwindcss.com/docs/margin - */ - mb: [{ - mb: [L] - }], - /** - * Margin Left - * @see https://tailwindcss.com/docs/margin - */ - ml: [{ - ml: [L] - }], - /** - * Space Between X - * @see https://tailwindcss.com/docs/space - */ - "space-x": [{ - "space-x": [R] - }], - /** - * Space Between X Reverse - * @see https://tailwindcss.com/docs/space - */ - "space-x-reverse": ["space-x-reverse"], - /** - * Space Between Y - * @see https://tailwindcss.com/docs/space - */ - "space-y": [{ - "space-y": [R] - }], - /** - * Space Between Y Reverse - * @see https://tailwindcss.com/docs/space - */ - "space-y-reverse": ["space-y-reverse"], - // Sizing - /** - * Width - * @see https://tailwindcss.com/docs/width - */ - w: [{ - w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", cr, e] - }], - /** - * Min-Width - * @see https://tailwindcss.com/docs/min-width - */ - "min-w": [{ - "min-w": [cr, e, "min", "max", "fit"] - }], - /** - * Max-Width - * @see https://tailwindcss.com/docs/max-width - */ - "max-w": [{ - "max-w": [cr, e, "none", "full", "min", "max", "fit", "prose", { - screen: [na] - }, na] - }], - /** - * Height - * @see https://tailwindcss.com/docs/height - */ - h: [{ - h: [cr, e, "auto", "min", "max", "fit", "svh", "lvh", "dvh"] - }], - /** - * Min-Height - * @see https://tailwindcss.com/docs/min-height - */ - "min-h": [{ - "min-h": [cr, e, "min", "max", "fit", "svh", "lvh", "dvh"] - }], - /** - * Max-Height - * @see https://tailwindcss.com/docs/max-height - */ - "max-h": [{ - "max-h": [cr, e, "min", "max", "fit", "svh", "lvh", "dvh"] - }], - /** - * Size - * @see https://tailwindcss.com/docs/size - */ - size: [{ - size: [cr, e, "auto", "min", "max", "fit"] - }], - // Typography - /** - * Font Size - * @see https://tailwindcss.com/docs/font-size - */ - "font-size": [{ - text: ["base", na, ra] - }], - /** - * Font Smoothing - * @see https://tailwindcss.com/docs/font-smoothing - */ - "font-smoothing": ["antialiased", "subpixel-antialiased"], - /** - * Font Style - * @see https://tailwindcss.com/docs/font-style - */ - "font-style": ["italic", "not-italic"], - /** - * Font Weight - * @see https://tailwindcss.com/docs/font-weight - */ - "font-weight": [{ - font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black", Wm] - }], - /** - * Font Family - * @see https://tailwindcss.com/docs/font-family - */ - "font-family": [{ - font: [Nf] - }], - /** - * Font Variant Numeric - * @see https://tailwindcss.com/docs/font-variant-numeric - */ - "fvn-normal": ["normal-nums"], - /** - * Font Variant Numeric - * @see https://tailwindcss.com/docs/font-variant-numeric - */ - "fvn-ordinal": ["ordinal"], - /** - * Font Variant Numeric - * @see https://tailwindcss.com/docs/font-variant-numeric - */ - "fvn-slashed-zero": ["slashed-zero"], - /** - * Font Variant Numeric - * @see https://tailwindcss.com/docs/font-variant-numeric - */ - "fvn-figure": ["lining-nums", "oldstyle-nums"], - /** - * Font Variant Numeric - * @see https://tailwindcss.com/docs/font-variant-numeric - */ - "fvn-spacing": ["proportional-nums", "tabular-nums"], - /** - * Font Variant Numeric - * @see https://tailwindcss.com/docs/font-variant-numeric - */ - "fvn-fraction": ["diagonal-fractions", "stacked-fractions"], - /** - * Letter Spacing - * @see https://tailwindcss.com/docs/letter-spacing - */ - tracking: [{ - tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", cr] - }], - /** - * Line Clamp - * @see https://tailwindcss.com/docs/line-clamp - */ - "line-clamp": [{ - "line-clamp": ["none", gu, Wm] - }], - /** - * Line Height - * @see https://tailwindcss.com/docs/line-height - */ - leading: [{ - leading: ["none", "tight", "snug", "normal", "relaxed", "loose", vo, cr] - }], - /** - * List Style Image - * @see https://tailwindcss.com/docs/list-style-image - */ - "list-image": [{ - "list-image": ["none", cr] - }], - /** - * List Style Type - * @see https://tailwindcss.com/docs/list-style-type - */ - "list-style-type": [{ - list: ["none", "disc", "decimal", cr] - }], - /** - * List Style Position - * @see https://tailwindcss.com/docs/list-style-position - */ - "list-style-position": [{ - list: ["inside", "outside"] - }], - /** - * Placeholder Color - * @deprecated since Tailwind CSS v3.0.0 - * @see https://tailwindcss.com/docs/placeholder-color - */ - "placeholder-color": [{ - placeholder: [t] - }], - /** - * Placeholder Opacity - * @see https://tailwindcss.com/docs/placeholder-opacity - */ - "placeholder-opacity": [{ - "placeholder-opacity": [F] - }], - /** - * Text Alignment - * @see https://tailwindcss.com/docs/text-align - */ - "text-alignment": [{ - text: ["left", "center", "right", "justify", "start", "end"] - }], - /** - * Text Color - * @see https://tailwindcss.com/docs/text-color - */ - "text-color": [{ - text: [t] - }], - /** - * Text Opacity - * @see https://tailwindcss.com/docs/text-opacity - */ - "text-opacity": [{ - "text-opacity": [F] - }], - /** - * Text Decoration - * @see https://tailwindcss.com/docs/text-decoration - */ - "text-decoration": ["underline", "overline", "line-through", "no-underline"], - /** - * Text Decoration Style - * @see https://tailwindcss.com/docs/text-decoration-style - */ - "text-decoration-style": [{ - decoration: [...b(), "wavy"] - }], - /** - * Text Decoration Thickness - * @see https://tailwindcss.com/docs/text-decoration-thickness - */ - "text-decoration-thickness": [{ - decoration: ["auto", "from-font", vo, ra] - }], - /** - * Text Underline Offset - * @see https://tailwindcss.com/docs/text-underline-offset - */ - "underline-offset": [{ - "underline-offset": ["auto", vo, cr] - }], - /** - * Text Decoration Color - * @see https://tailwindcss.com/docs/text-decoration-color - */ - "text-decoration-color": [{ - decoration: [t] - }], - /** - * Text Transform - * @see https://tailwindcss.com/docs/text-transform - */ - "text-transform": ["uppercase", "lowercase", "capitalize", "normal-case"], - /** - * Text Overflow - * @see https://tailwindcss.com/docs/text-overflow - */ - "text-overflow": ["truncate", "text-ellipsis", "text-clip"], - /** - * Text Wrap - * @see https://tailwindcss.com/docs/text-wrap - */ - "text-wrap": [{ - text: ["wrap", "nowrap", "balance", "pretty"] - }], - /** - * Text Indent - * @see https://tailwindcss.com/docs/text-indent - */ - indent: [{ - indent: S() - }], - /** - * Vertical Alignment - * @see https://tailwindcss.com/docs/vertical-align - */ - "vertical-align": [{ - align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", cr] - }], - /** - * Whitespace - * @see https://tailwindcss.com/docs/whitespace - */ - whitespace: [{ - whitespace: ["normal", "nowrap", "pre", "pre-line", "pre-wrap", "break-spaces"] - }], - /** - * Word Break - * @see https://tailwindcss.com/docs/word-break - */ - break: [{ - break: ["normal", "words", "all", "keep"] - }], - /** - * Hyphens - * @see https://tailwindcss.com/docs/hyphens - */ - hyphens: [{ - hyphens: ["none", "manual", "auto"] - }], - /** - * Content - * @see https://tailwindcss.com/docs/content - */ - content: [{ - content: ["none", cr] - }], - // Backgrounds - /** - * Background Attachment - * @see https://tailwindcss.com/docs/background-attachment - */ - "bg-attachment": [{ - bg: ["fixed", "local", "scroll"] - }], - /** - * Background Clip - * @see https://tailwindcss.com/docs/background-clip - */ - "bg-clip": [{ - "bg-clip": ["border", "padding", "content", "text"] - }], - /** - * Background Opacity - * @deprecated since Tailwind CSS v3.0.0 - * @see https://tailwindcss.com/docs/background-opacity - */ - "bg-opacity": [{ - "bg-opacity": [F] - }], - /** - * Background Origin - * @see https://tailwindcss.com/docs/background-origin - */ - "bg-origin": [{ - "bg-origin": ["border", "padding", "content"] - }], - /** - * Background Position - * @see https://tailwindcss.com/docs/background-position - */ - "bg-position": [{ - bg: [...p(), one] - }], - /** - * Background Repeat - * @see https://tailwindcss.com/docs/background-repeat - */ - "bg-repeat": [{ - bg: ["no-repeat", { - repeat: ["", "x", "y", "round", "space"] - }] - }], - /** - * Background Size - * @see https://tailwindcss.com/docs/background-size - */ - "bg-size": [{ - bg: ["auto", "cover", "contain", sne] - }], - /** - * Background Image - * @see https://tailwindcss.com/docs/background-image - */ - "bg-image": [{ - bg: ["none", { - "gradient-to": ["t", "tr", "r", "br", "b", "bl", "l", "tl"] - }, cne] - }], - /** - * Background Color - * @see https://tailwindcss.com/docs/background-color - */ - "bg-color": [{ - bg: [t] - }], - /** - * Gradient Color Stops From Position - * @see https://tailwindcss.com/docs/gradient-color-stops - */ - "gradient-from-pos": [{ - from: [M] - }], - /** - * Gradient Color Stops Via Position - * @see https://tailwindcss.com/docs/gradient-color-stops - */ - "gradient-via-pos": [{ - via: [M] - }], - /** - * Gradient Color Stops To Position - * @see https://tailwindcss.com/docs/gradient-color-stops - */ - "gradient-to-pos": [{ - to: [M] - }], - /** - * Gradient Color Stops From - * @see https://tailwindcss.com/docs/gradient-color-stops - */ - "gradient-from": [{ - from: [A] - }], - /** - * Gradient Color Stops Via - * @see https://tailwindcss.com/docs/gradient-color-stops - */ - "gradient-via": [{ - via: [A] - }], - /** - * Gradient Color Stops To - * @see https://tailwindcss.com/docs/gradient-color-stops - */ - "gradient-to": [{ - to: [A] - }], - // Borders - /** - * Border Radius - * @see https://tailwindcss.com/docs/border-radius - */ - rounded: [{ - rounded: [s] - }], - /** - * Border Radius Start - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-s": [{ - "rounded-s": [s] - }], - /** - * Border Radius End - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-e": [{ - "rounded-e": [s] - }], - /** - * Border Radius Top - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-t": [{ - "rounded-t": [s] - }], - /** - * Border Radius Right - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-r": [{ - "rounded-r": [s] - }], - /** - * Border Radius Bottom - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-b": [{ - "rounded-b": [s] - }], - /** - * Border Radius Left - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-l": [{ - "rounded-l": [s] - }], - /** - * Border Radius Start Start - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-ss": [{ - "rounded-ss": [s] - }], - /** - * Border Radius Start End - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-se": [{ - "rounded-se": [s] - }], - /** - * Border Radius End End - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-ee": [{ - "rounded-ee": [s] - }], - /** - * Border Radius End Start - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-es": [{ - "rounded-es": [s] - }], - /** - * Border Radius Top Left - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-tl": [{ - "rounded-tl": [s] - }], - /** - * Border Radius Top Right - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-tr": [{ - "rounded-tr": [s] - }], - /** - * Border Radius Bottom Right - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-br": [{ - "rounded-br": [s] - }], - /** - * Border Radius Bottom Left - * @see https://tailwindcss.com/docs/border-radius - */ - "rounded-bl": [{ - "rounded-bl": [s] - }], - /** - * Border Width - * @see https://tailwindcss.com/docs/border-width - */ - "border-w": [{ - border: [a] - }], - /** - * Border Width X - * @see https://tailwindcss.com/docs/border-width - */ - "border-w-x": [{ - "border-x": [a] - }], - /** - * Border Width Y - * @see https://tailwindcss.com/docs/border-width - */ - "border-w-y": [{ - "border-y": [a] - }], - /** - * Border Width Start - * @see https://tailwindcss.com/docs/border-width - */ - "border-w-s": [{ - "border-s": [a] - }], - /** - * Border Width End - * @see https://tailwindcss.com/docs/border-width - */ - "border-w-e": [{ - "border-e": [a] - }], - /** - * Border Width Top - * @see https://tailwindcss.com/docs/border-width - */ - "border-w-t": [{ - "border-t": [a] - }], - /** - * Border Width Right - * @see https://tailwindcss.com/docs/border-width - */ - "border-w-r": [{ - "border-r": [a] - }], - /** - * Border Width Bottom - * @see https://tailwindcss.com/docs/border-width - */ - "border-w-b": [{ - "border-b": [a] - }], - /** - * Border Width Left - * @see https://tailwindcss.com/docs/border-width - */ - "border-w-l": [{ - "border-l": [a] - }], - /** - * Border Opacity - * @see https://tailwindcss.com/docs/border-opacity - */ - "border-opacity": [{ - "border-opacity": [F] - }], - /** - * Border Style - * @see https://tailwindcss.com/docs/border-style - */ - "border-style": [{ - border: [...b(), "hidden"] - }], - /** - * Divide Width X - * @see https://tailwindcss.com/docs/divide-width - */ - "divide-x": [{ - "divide-x": [a] - }], - /** - * Divide Width X Reverse - * @see https://tailwindcss.com/docs/divide-width - */ - "divide-x-reverse": ["divide-x-reverse"], - /** - * Divide Width Y - * @see https://tailwindcss.com/docs/divide-width - */ - "divide-y": [{ - "divide-y": [a] - }], - /** - * Divide Width Y Reverse - * @see https://tailwindcss.com/docs/divide-width - */ - "divide-y-reverse": ["divide-y-reverse"], - /** - * Divide Opacity - * @see https://tailwindcss.com/docs/divide-opacity - */ - "divide-opacity": [{ - "divide-opacity": [F] - }], - /** - * Divide Style - * @see https://tailwindcss.com/docs/divide-style - */ - "divide-style": [{ - divide: b() - }], - /** - * Border Color - * @see https://tailwindcss.com/docs/border-color - */ - "border-color": [{ - border: [i] - }], - /** - * Border Color X - * @see https://tailwindcss.com/docs/border-color - */ - "border-color-x": [{ - "border-x": [i] - }], - /** - * Border Color Y - * @see https://tailwindcss.com/docs/border-color - */ - "border-color-y": [{ - "border-y": [i] - }], - /** - * Border Color S - * @see https://tailwindcss.com/docs/border-color - */ - "border-color-s": [{ - "border-s": [i] - }], - /** - * Border Color E - * @see https://tailwindcss.com/docs/border-color - */ - "border-color-e": [{ - "border-e": [i] - }], - /** - * Border Color Top - * @see https://tailwindcss.com/docs/border-color - */ - "border-color-t": [{ - "border-t": [i] - }], - /** - * Border Color Right - * @see https://tailwindcss.com/docs/border-color - */ - "border-color-r": [{ - "border-r": [i] - }], - /** - * Border Color Bottom - * @see https://tailwindcss.com/docs/border-color - */ - "border-color-b": [{ - "border-b": [i] - }], - /** - * Border Color Left - * @see https://tailwindcss.com/docs/border-color - */ - "border-color-l": [{ - "border-l": [i] - }], - /** - * Divide Color - * @see https://tailwindcss.com/docs/divide-color - */ - "divide-color": [{ - divide: [i] - }], - /** - * Outline Style - * @see https://tailwindcss.com/docs/outline-style - */ - "outline-style": [{ - outline: ["", ...b()] - }], - /** - * Outline Offset - * @see https://tailwindcss.com/docs/outline-offset - */ - "outline-offset": [{ - "outline-offset": [vo, cr] - }], - /** - * Outline Width - * @see https://tailwindcss.com/docs/outline-width - */ - "outline-w": [{ - outline: [vo, ra] - }], - /** - * Outline Color - * @see https://tailwindcss.com/docs/outline-color - */ - "outline-color": [{ - outline: [t] - }], - /** - * Ring Width - * @see https://tailwindcss.com/docs/ring-width - */ - "ring-w": [{ - ring: m() - }], - /** - * Ring Width Inset - * @see https://tailwindcss.com/docs/ring-width - */ - "ring-w-inset": ["ring-inset"], - /** - * Ring Color - * @see https://tailwindcss.com/docs/ring-color - */ - "ring-color": [{ - ring: [t] - }], - /** - * Ring Opacity - * @see https://tailwindcss.com/docs/ring-opacity - */ - "ring-opacity": [{ - "ring-opacity": [F] - }], - /** - * Ring Offset Width - * @see https://tailwindcss.com/docs/ring-offset-width - */ - "ring-offset-w": [{ - "ring-offset": [vo, ra] - }], - /** - * Ring Offset Color - * @see https://tailwindcss.com/docs/ring-offset-color - */ - "ring-offset-color": [{ - "ring-offset": [t] - }], - // Effects - /** - * Box Shadow - * @see https://tailwindcss.com/docs/box-shadow - */ - shadow: [{ - shadow: ["", "inner", "none", na, une] - }], - /** - * Box Shadow Color - * @see https://tailwindcss.com/docs/box-shadow-color - */ - "shadow-color": [{ - shadow: [Nf] - }], - /** - * Opacity - * @see https://tailwindcss.com/docs/opacity - */ - opacity: [{ - opacity: [F] - }], - /** - * Mix Blend Mode - * @see https://tailwindcss.com/docs/mix-blend-mode - */ - "mix-blend": [{ - "mix-blend": [...x(), "plus-lighter", "plus-darker"] - }], - /** - * Background Blend Mode - * @see https://tailwindcss.com/docs/background-blend-mode - */ - "bg-blend": [{ - "bg-blend": x() - }], - // Filters - /** - * Filter - * @deprecated since Tailwind CSS v3.0.0 - * @see https://tailwindcss.com/docs/filter - */ - filter: [{ - filter: ["", "none"] - }], - /** - * Blur - * @see https://tailwindcss.com/docs/blur - */ - blur: [{ - blur: [r] - }], - /** - * Brightness - * @see https://tailwindcss.com/docs/brightness - */ - brightness: [{ - brightness: [n] - }], - /** - * Contrast - * @see https://tailwindcss.com/docs/contrast - */ - contrast: [{ - contrast: [u] - }], - /** - * Drop Shadow - * @see https://tailwindcss.com/docs/drop-shadow - */ - "drop-shadow": [{ - "drop-shadow": ["", "none", na, cr] - }], - /** - * Grayscale - * @see https://tailwindcss.com/docs/grayscale - */ - grayscale: [{ - grayscale: [l] - }], - /** - * Hue Rotate - * @see https://tailwindcss.com/docs/hue-rotate - */ - "hue-rotate": [{ - "hue-rotate": [d] - }], - /** - * Invert - * @see https://tailwindcss.com/docs/invert - */ - invert: [{ - invert: [g] - }], - /** - * Saturate - * @see https://tailwindcss.com/docs/saturate - */ - saturate: [{ - saturate: [K] - }], - /** - * Sepia - * @see https://tailwindcss.com/docs/sepia - */ - sepia: [{ - sepia: [V] - }], - /** - * Backdrop Filter - * @deprecated since Tailwind CSS v3.0.0 - * @see https://tailwindcss.com/docs/backdrop-filter - */ - "backdrop-filter": [{ - "backdrop-filter": ["", "none"] - }], - /** - * Backdrop Blur - * @see https://tailwindcss.com/docs/backdrop-blur - */ - "backdrop-blur": [{ - "backdrop-blur": [r] - }], - /** - * Backdrop Brightness - * @see https://tailwindcss.com/docs/backdrop-brightness - */ - "backdrop-brightness": [{ - "backdrop-brightness": [n] - }], - /** - * Backdrop Contrast - * @see https://tailwindcss.com/docs/backdrop-contrast - */ - "backdrop-contrast": [{ - "backdrop-contrast": [u] - }], - /** - * Backdrop Grayscale - * @see https://tailwindcss.com/docs/backdrop-grayscale - */ - "backdrop-grayscale": [{ - "backdrop-grayscale": [l] - }], - /** - * Backdrop Hue Rotate - * @see https://tailwindcss.com/docs/backdrop-hue-rotate - */ - "backdrop-hue-rotate": [{ - "backdrop-hue-rotate": [d] - }], - /** - * Backdrop Invert - * @see https://tailwindcss.com/docs/backdrop-invert - */ - "backdrop-invert": [{ - "backdrop-invert": [g] - }], - /** - * Backdrop Opacity - * @see https://tailwindcss.com/docs/backdrop-opacity - */ - "backdrop-opacity": [{ - "backdrop-opacity": [F] - }], - /** - * Backdrop Saturate - * @see https://tailwindcss.com/docs/backdrop-saturate - */ - "backdrop-saturate": [{ - "backdrop-saturate": [K] - }], - /** - * Backdrop Sepia - * @see https://tailwindcss.com/docs/backdrop-sepia - */ - "backdrop-sepia": [{ - "backdrop-sepia": [V] - }], - // Tables - /** - * Border Collapse - * @see https://tailwindcss.com/docs/border-collapse - */ - "border-collapse": [{ - border: ["collapse", "separate"] - }], - /** - * Border Spacing - * @see https://tailwindcss.com/docs/border-spacing - */ - "border-spacing": [{ - "border-spacing": [o] - }], - /** - * Border Spacing X - * @see https://tailwindcss.com/docs/border-spacing - */ - "border-spacing-x": [{ - "border-spacing-x": [o] - }], - /** - * Border Spacing Y - * @see https://tailwindcss.com/docs/border-spacing - */ - "border-spacing-y": [{ - "border-spacing-y": [o] - }], - /** - * Table Layout - * @see https://tailwindcss.com/docs/table-layout - */ - "table-layout": [{ - table: ["auto", "fixed"] - }], - /** - * Caption Side - * @see https://tailwindcss.com/docs/caption-side - */ - caption: [{ - caption: ["top", "bottom"] - }], - // Transitions and Animation - /** - * Tranisition Property - * @see https://tailwindcss.com/docs/transition-property - */ - transition: [{ - transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", cr] - }], - /** - * Transition Duration - * @see https://tailwindcss.com/docs/transition-duration - */ - duration: [{ - duration: P() - }], - /** - * Transition Timing Function - * @see https://tailwindcss.com/docs/transition-timing-function - */ - ease: [{ - ease: ["linear", "in", "out", "in-out", cr] - }], - /** - * Transition Delay - * @see https://tailwindcss.com/docs/transition-delay - */ - delay: [{ - delay: P() - }], - /** - * Animation - * @see https://tailwindcss.com/docs/animation - */ - animate: [{ - animate: ["none", "spin", "ping", "pulse", "bounce", cr] - }], - // Transforms - /** - * Transform - * @see https://tailwindcss.com/docs/transform - */ - transform: [{ - transform: ["", "gpu", "none"] - }], - /** - * Scale - * @see https://tailwindcss.com/docs/scale - */ - scale: [{ - scale: [H] - }], - /** - * Scale X - * @see https://tailwindcss.com/docs/scale - */ - "scale-x": [{ - "scale-x": [H] - }], - /** - * Scale Y - * @see https://tailwindcss.com/docs/scale - */ - "scale-y": [{ - "scale-y": [H] - }], - /** - * Rotate - * @see https://tailwindcss.com/docs/rotate - */ - rotate: [{ - rotate: [Of, cr] - }], - /** - * Translate X - * @see https://tailwindcss.com/docs/translate - */ - "translate-x": [{ - "translate-x": [W] - }], - /** - * Translate Y - * @see https://tailwindcss.com/docs/translate - */ - "translate-y": [{ - "translate-y": [W] - }], - /** - * Skew X - * @see https://tailwindcss.com/docs/skew - */ - "skew-x": [{ - "skew-x": [te] - }], - /** - * Skew Y - * @see https://tailwindcss.com/docs/skew - */ - "skew-y": [{ - "skew-y": [te] - }], - /** - * Transform Origin - * @see https://tailwindcss.com/docs/transform-origin - */ - "transform-origin": [{ - origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", cr] - }], - // Interactivity - /** - * Accent Color - * @see https://tailwindcss.com/docs/accent-color - */ - accent: [{ - accent: ["auto", t] - }], - /** - * Appearance - * @see https://tailwindcss.com/docs/appearance - */ - appearance: [{ - appearance: ["none", "auto"] - }], - /** - * Cursor - * @see https://tailwindcss.com/docs/cursor - */ - cursor: [{ - cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", cr] - }], - /** - * Caret Color - * @see https://tailwindcss.com/docs/just-in-time-mode#caret-color-utilities - */ - "caret-color": [{ - caret: [t] - }], - /** - * Pointer Events - * @see https://tailwindcss.com/docs/pointer-events - */ - "pointer-events": [{ - "pointer-events": ["none", "auto"] - }], - /** - * Resize - * @see https://tailwindcss.com/docs/resize - */ - resize: [{ - resize: ["none", "y", "x", ""] - }], - /** - * Scroll Behavior - * @see https://tailwindcss.com/docs/scroll-behavior - */ - "scroll-behavior": [{ - scroll: ["auto", "smooth"] - }], - /** - * Scroll Margin - * @see https://tailwindcss.com/docs/scroll-margin - */ - "scroll-m": [{ - "scroll-m": S() - }], - /** - * Scroll Margin X - * @see https://tailwindcss.com/docs/scroll-margin - */ - "scroll-mx": [{ - "scroll-mx": S() - }], - /** - * Scroll Margin Y - * @see https://tailwindcss.com/docs/scroll-margin - */ - "scroll-my": [{ - "scroll-my": S() - }], - /** - * Scroll Margin Start - * @see https://tailwindcss.com/docs/scroll-margin - */ - "scroll-ms": [{ - "scroll-ms": S() - }], - /** - * Scroll Margin End - * @see https://tailwindcss.com/docs/scroll-margin - */ - "scroll-me": [{ - "scroll-me": S() - }], - /** - * Scroll Margin Top - * @see https://tailwindcss.com/docs/scroll-margin - */ - "scroll-mt": [{ - "scroll-mt": S() - }], - /** - * Scroll Margin Right - * @see https://tailwindcss.com/docs/scroll-margin - */ - "scroll-mr": [{ - "scroll-mr": S() - }], - /** - * Scroll Margin Bottom - * @see https://tailwindcss.com/docs/scroll-margin - */ - "scroll-mb": [{ - "scroll-mb": S() - }], - /** - * Scroll Margin Left - * @see https://tailwindcss.com/docs/scroll-margin - */ - "scroll-ml": [{ - "scroll-ml": S() - }], - /** - * Scroll Padding - * @see https://tailwindcss.com/docs/scroll-padding - */ - "scroll-p": [{ - "scroll-p": S() - }], - /** - * Scroll Padding X - * @see https://tailwindcss.com/docs/scroll-padding - */ - "scroll-px": [{ - "scroll-px": S() - }], - /** - * Scroll Padding Y - * @see https://tailwindcss.com/docs/scroll-padding - */ - "scroll-py": [{ - "scroll-py": S() - }], - /** - * Scroll Padding Start - * @see https://tailwindcss.com/docs/scroll-padding - */ - "scroll-ps": [{ - "scroll-ps": S() - }], - /** - * Scroll Padding End - * @see https://tailwindcss.com/docs/scroll-padding - */ - "scroll-pe": [{ - "scroll-pe": S() - }], - /** - * Scroll Padding Top - * @see https://tailwindcss.com/docs/scroll-padding - */ - "scroll-pt": [{ - "scroll-pt": S() - }], - /** - * Scroll Padding Right - * @see https://tailwindcss.com/docs/scroll-padding - */ - "scroll-pr": [{ - "scroll-pr": S() - }], - /** - * Scroll Padding Bottom - * @see https://tailwindcss.com/docs/scroll-padding - */ - "scroll-pb": [{ - "scroll-pb": S() - }], - /** - * Scroll Padding Left - * @see https://tailwindcss.com/docs/scroll-padding - */ - "scroll-pl": [{ - "scroll-pl": S() - }], - /** - * Scroll Snap Align - * @see https://tailwindcss.com/docs/scroll-snap-align - */ - "snap-align": [{ - snap: ["start", "end", "center", "align-none"] - }], - /** - * Scroll Snap Stop - * @see https://tailwindcss.com/docs/scroll-snap-stop - */ - "snap-stop": [{ - snap: ["normal", "always"] - }], - /** - * Scroll Snap Type - * @see https://tailwindcss.com/docs/scroll-snap-type - */ - "snap-type": [{ - snap: ["none", "x", "y", "both"] - }], - /** - * Scroll Snap Type Strictness - * @see https://tailwindcss.com/docs/scroll-snap-type - */ - "snap-strictness": [{ - snap: ["mandatory", "proximity"] - }], - /** - * Touch Action - * @see https://tailwindcss.com/docs/touch-action - */ - touch: [{ - touch: ["auto", "none", "manipulation"] - }], - /** - * Touch Action X - * @see https://tailwindcss.com/docs/touch-action - */ - "touch-x": [{ - "touch-pan": ["x", "left", "right"] - }], - /** - * Touch Action Y - * @see https://tailwindcss.com/docs/touch-action - */ - "touch-y": [{ - "touch-pan": ["y", "up", "down"] - }], - /** - * Touch Action Pinch Zoom - * @see https://tailwindcss.com/docs/touch-action - */ - "touch-pz": ["touch-pinch-zoom"], - /** - * User Select - * @see https://tailwindcss.com/docs/user-select - */ - select: [{ - select: ["none", "text", "all", "auto"] - }], - /** - * Will Change - * @see https://tailwindcss.com/docs/will-change - */ - "will-change": [{ - "will-change": ["auto", "scroll", "contents", "transform", cr] - }], - // SVG - /** - * Fill - * @see https://tailwindcss.com/docs/fill - */ - fill: [{ - fill: [t, "none"] - }], - /** - * Stroke Width - * @see https://tailwindcss.com/docs/stroke-width - */ - "stroke-w": [{ - stroke: [vo, ra, Wm] - }], - /** - * Stroke - * @see https://tailwindcss.com/docs/stroke - */ - stroke: [{ - stroke: [t, "none"] - }], - // Accessibility - /** - * Screen Readers - * @see https://tailwindcss.com/docs/screen-readers - */ - sr: ["sr-only", "not-sr-only"], - /** - * Forced Color Adjust - * @see https://tailwindcss.com/docs/forced-color-adjust - */ - "forced-color-adjust": [{ - "forced-color-adjust": ["auto", "none"] - }] - }, - conflictingClassGroups: { - overflow: ["overflow-x", "overflow-y"], - overscroll: ["overscroll-x", "overscroll-y"], - inset: ["inset-x", "inset-y", "start", "end", "top", "right", "bottom", "left"], - "inset-x": ["right", "left"], - "inset-y": ["top", "bottom"], - flex: ["basis", "grow", "shrink"], - gap: ["gap-x", "gap-y"], - p: ["px", "py", "ps", "pe", "pt", "pr", "pb", "pl"], - px: ["pr", "pl"], - py: ["pt", "pb"], - m: ["mx", "my", "ms", "me", "mt", "mr", "mb", "ml"], - mx: ["mr", "ml"], - my: ["mt", "mb"], - size: ["w", "h"], - "font-size": ["leading"], - "fvn-normal": ["fvn-ordinal", "fvn-slashed-zero", "fvn-figure", "fvn-spacing", "fvn-fraction"], - "fvn-ordinal": ["fvn-normal"], - "fvn-slashed-zero": ["fvn-normal"], - "fvn-figure": ["fvn-normal"], - "fvn-spacing": ["fvn-normal"], - "fvn-fraction": ["fvn-normal"], - "line-clamp": ["display", "overflow"], - rounded: ["rounded-s", "rounded-e", "rounded-t", "rounded-r", "rounded-b", "rounded-l", "rounded-ss", "rounded-se", "rounded-ee", "rounded-es", "rounded-tl", "rounded-tr", "rounded-br", "rounded-bl"], - "rounded-s": ["rounded-ss", "rounded-es"], - "rounded-e": ["rounded-se", "rounded-ee"], - "rounded-t": ["rounded-tl", "rounded-tr"], - "rounded-r": ["rounded-tr", "rounded-br"], - "rounded-b": ["rounded-br", "rounded-bl"], - "rounded-l": ["rounded-tl", "rounded-bl"], - "border-spacing": ["border-spacing-x", "border-spacing-y"], - "border-w": ["border-w-s", "border-w-e", "border-w-t", "border-w-r", "border-w-b", "border-w-l"], - "border-w-x": ["border-w-r", "border-w-l"], - "border-w-y": ["border-w-t", "border-w-b"], - "border-color": ["border-color-s", "border-color-e", "border-color-t", "border-color-r", "border-color-b", "border-color-l"], - "border-color-x": ["border-color-r", "border-color-l"], - "border-color-y": ["border-color-t", "border-color-b"], - "scroll-m": ["scroll-mx", "scroll-my", "scroll-ms", "scroll-me", "scroll-mt", "scroll-mr", "scroll-mb", "scroll-ml"], - "scroll-mx": ["scroll-mr", "scroll-ml"], - "scroll-my": ["scroll-mt", "scroll-mb"], - "scroll-p": ["scroll-px", "scroll-py", "scroll-ps", "scroll-pe", "scroll-pt", "scroll-pr", "scroll-pb", "scroll-pl"], - "scroll-px": ["scroll-pr", "scroll-pl"], - "scroll-py": ["scroll-pt", "scroll-pb"], - touch: ["touch-x", "touch-y", "touch-pz"], - "touch-x": ["touch"], - "touch-y": ["touch"], - "touch-pz": ["touch"] - }, - conflictingClassGroupModifiers: { - "font-size": ["leading"] - } - }; -}, pne = /* @__PURE__ */ Yre(dne); -function Do(...t) { - return pne(kre(t)); -} -function A9(t) { - const { className: e } = t; - return /* @__PURE__ */ me.jsxs("div", { className: Do("xc-flex xc-items-center xc-gap-2"), children: [ - /* @__PURE__ */ me.jsx("hr", { className: Do("xc-flex-1 xc-border-gray-200", e) }), - /* @__PURE__ */ me.jsx("div", { className: "xc-shrink-0", children: t.children }), - /* @__PURE__ */ me.jsx("hr", { className: Do("xc-flex-1 xc-border-gray-200", e) }) - ] }); -} -const gne = "https://static.codatta.io/codatta-connect/wallet-icons.svg?v=2#ton"; -function mne(t) { - const { onClick: e } = t; - function r() { - e && e(); - } - return /* @__PURE__ */ me.jsx(A9, { className: "xc-opacity-20", children: /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-items-center xc-gap-2 xc-cursor-pointer", onClick: r, children: [ - /* @__PURE__ */ me.jsx("span", { className: "xc-text-sm", children: "View more wallets" }), - /* @__PURE__ */ me.jsx(zS, { size: 16 }) - ] }) }); -} -function vne(t) { - const [e, r] = fr(""), { featuredWallets: n, initialized: i } = gp(), { onEmailConfirm: s, onSelectWallet: o, onSelectMoreWallets: a, onSelectTonConnect: u, config: l } = t, d = Oi(() => { - const N = /[\u4e00-\u9fff]|[\u3400-\u4dbf]|[\u{20000}-\u{2a6df}]|[\u{2a700}-\u{2b73f}]|[\u{2b740}-\u{2b81f}]|[\u{2b820}-\u{2ceaf}]|[\uf900-\ufaff]|[\u3300-\u33ff]|[\ufe30-\ufe4f]/gu, L = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; - return !N.test(e) && L.test(e); - }, [e]); - function g(N) { - o(N); - } - function w(N) { - r(N.target.value); - } - async function A() { - s(e); - } - function M(N) { - N.key === "Enter" && d && A(); - } - return /* @__PURE__ */ me.jsx(Ac, { children: i && /* @__PURE__ */ me.jsxs(me.Fragment, { children: [ - t.header || /* @__PURE__ */ me.jsx("div", { className: "xc-mb-6 xc-text-xl xc-font-bold", children: "Log in or sign up" }), - l.showEmailSignIn && /* @__PURE__ */ me.jsxs("div", { className: "xc-mb-4", children: [ - /* @__PURE__ */ me.jsx("input", { className: "xc-w-full xc-bg-transparent xc-border-white xc-border xc-border-opacity-15 xc-h-10 xc-rounded-lg xc-px-3 xc-mb-3", placeholder: "Enter your email", type: "email", onChange: w, onKeyDown: M }), - /* @__PURE__ */ me.jsx("button", { disabled: !d, className: "xc-bg-[rgb(135,93,255)] xc-text-white xc-w-full xc-rounded-lg xc-py-2 disabled:xc-bg-opacity-10 disabled:xc-text-opacity-50 disabled:xc-bg-white xc-transition-all", onClick: A, children: "Continue" }) - ] }), - l.showEmailSignIn && (l.showFeaturedWallets || l.showTonConnect) && /* @__PURE__ */ me.jsx("div", { className: "xc-mb-4", children: /* @__PURE__ */ me.jsxs(A9, { className: "xc-opacity-20", children: [ - " ", - /* @__PURE__ */ me.jsx("span", { className: "xc-text-sm xc-opacity-20", children: "OR" }) - ] }) }), - /* @__PURE__ */ me.jsxs("div", { children: [ - /* @__PURE__ */ me.jsxs("div", { className: "xc-mb-4 xc-flex xc-max-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar", children: [ - l.showFeaturedWallets && n && n.map((N) => /* @__PURE__ */ me.jsx( - b9, - { - wallet: N, - onClick: g - }, - `feature-${N.key}` - )), - l.showTonConnect && /* @__PURE__ */ me.jsx( - sy, - { - icon: /* @__PURE__ */ me.jsx("img", { className: "xc-h-5 xc-w-5", src: gne }), - title: "TON Connect", - onClick: u - } - ) - ] }), - l.showMoreWallets && /* @__PURE__ */ me.jsx(mne, { onClick: a }) - ] }) - ] }) }); -} -function uh(t) { - const { title: e } = t; - return /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-items-center xc-gap-2", children: [ - /* @__PURE__ */ me.jsx(eZ, { onClick: t.onBack, size: 20, className: "xc-cursor-pointer" }), - /* @__PURE__ */ me.jsx("span", { children: e }) - ] }); -} -var bne = Object.defineProperty, yne = Object.defineProperties, wne = Object.getOwnPropertyDescriptors, E0 = Object.getOwnPropertySymbols, P9 = Object.prototype.hasOwnProperty, M9 = Object.prototype.propertyIsEnumerable, c5 = (t, e, r) => e in t ? bne(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, xne = (t, e) => { - for (var r in e || (e = {})) P9.call(e, r) && c5(t, r, e[r]); - if (E0) for (var r of E0(e)) M9.call(e, r) && c5(t, r, e[r]); - return t; -}, _ne = (t, e) => yne(t, wne(e)), Ene = (t, e) => { - var r = {}; - for (var n in t) P9.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); - if (t != null && E0) for (var n of E0(t)) e.indexOf(n) < 0 && M9.call(t, n) && (r[n] = t[n]); - return r; -}; -function Sne(t) { - let e = setTimeout(t, 0), r = setTimeout(t, 10), n = setTimeout(t, 50); - return [e, r, n]; -} -function Ane(t) { - let e = Gt.useRef(); - return Gt.useEffect(() => { - e.current = t; - }), e.current; -} -var Pne = 18, I9 = 40, Mne = `${I9}px`, Ine = ["[data-lastpass-icon-root]", "com-1password-button", "[data-dashlanecreated]", '[style$="2147483647 !important;"]'].join(","); -function Cne({ containerRef: t, inputRef: e, pushPasswordManagerStrategy: r, isFocused: n }) { - let [i, s] = Gt.useState(!1), [o, a] = Gt.useState(!1), [u, l] = Gt.useState(!1), d = Gt.useMemo(() => r === "none" ? !1 : (r === "increase-width" || r === "experimental-no-flickering") && i && o, [i, o, r]), g = Gt.useCallback(() => { - let w = t.current, A = e.current; - if (!w || !A || u || r === "none") return; - let M = w, N = M.getBoundingClientRect().left + M.offsetWidth, L = M.getBoundingClientRect().top + M.offsetHeight / 2, F = N - Pne, $ = L; - document.querySelectorAll(Ine).length === 0 && document.elementFromPoint(F, $) === w || (s(!0), l(!0)); - }, [t, e, u, r]); - return Gt.useEffect(() => { - let w = t.current; - if (!w || r === "none") return; - function A() { - let N = window.innerWidth - w.getBoundingClientRect().right; - a(N >= I9); - } - A(); - let M = setInterval(A, 1e3); - return () => { - clearInterval(M); - }; - }, [t, r]), Gt.useEffect(() => { - let w = n || document.activeElement === e.current; - if (r === "none" || !w) return; - let A = setTimeout(g, 0), M = setTimeout(g, 2e3), N = setTimeout(g, 5e3), L = setTimeout(() => { - l(!0); - }, 6e3); - return () => { - clearTimeout(A), clearTimeout(M), clearTimeout(N), clearTimeout(L); - }; - }, [e, n, r, g]), { hasPWMBadge: i, willPushPWMBadge: d, PWM_BADGE_SPACE_WIDTH: Mne }; -} -var C9 = Gt.createContext({}), T9 = Gt.forwardRef((t, e) => { - var r = t, { value: n, onChange: i, maxLength: s, textAlign: o = "left", pattern: a, placeholder: u, inputMode: l = "numeric", onComplete: d, pushPasswordManagerStrategy: g = "increase-width", pasteTransformer: w, containerClassName: A, noScriptCSSFallback: M = Tne, render: N, children: L } = r, F = Ene(r, ["value", "onChange", "maxLength", "textAlign", "pattern", "placeholder", "inputMode", "onComplete", "pushPasswordManagerStrategy", "pasteTransformer", "containerClassName", "noScriptCSSFallback", "render", "children"]), $, K, H, V, te; - let [R, W] = Gt.useState(typeof F.defaultValue == "string" ? F.defaultValue : ""), pe = n ?? R, Ee = Ane(pe), Y = Gt.useCallback((ie) => { - i == null || i(ie), W(ie); - }, [i]), S = Gt.useMemo(() => a ? typeof a == "string" ? new RegExp(a) : a : null, [a]), m = Gt.useRef(null), f = Gt.useRef(null), p = Gt.useRef({ value: pe, onChange: Y, isIOS: typeof window < "u" && ((K = ($ = window == null ? void 0 : window.CSS) == null ? void 0 : $.supports) == null ? void 0 : K.call($, "-webkit-touch-callout", "none")) }), b = Gt.useRef({ prev: [(H = m.current) == null ? void 0 : H.selectionStart, (V = m.current) == null ? void 0 : V.selectionEnd, (te = m.current) == null ? void 0 : te.selectionDirection] }); - Gt.useImperativeHandle(e, () => m.current, []), Gt.useEffect(() => { - let ie = m.current, ue = f.current; - if (!ie || !ue) return; - p.current.value !== ie.value && p.current.onChange(ie.value), b.current.prev = [ie.selectionStart, ie.selectionEnd, ie.selectionDirection]; - function ve() { - if (document.activeElement !== ie) { - I(null), ce(null); - return; - } - let Ce = ie.selectionStart, $e = ie.selectionEnd, Me = ie.selectionDirection, Ne = ie.maxLength, Ke = ie.value, Le = b.current.prev, qe = -1, ze = -1, _e; - if (Ke.length !== 0 && Ce !== null && $e !== null) { - let Qe = Ce === $e, tt = Ce === Ke.length && Ke.length < Ne; - if (Qe && !tt) { - let Ye = Ce; - if (Ye === 0) qe = 0, ze = 1, _e = "forward"; - else if (Ye === Ne) qe = Ye - 1, ze = Ye, _e = "backward"; - else if (Ne > 1 && Ke.length > 1) { - let dt = 0; - if (Le[0] !== null && Le[1] !== null) { - _e = Ye < Le[1] ? "backward" : "forward"; - let lt = Le[0] === Le[1] && Le[0] < Ne; - _e === "backward" && !lt && (dt = -1); - } - qe = dt + Ye, ze = dt + Ye + 1; - } - } - qe !== -1 && ze !== -1 && qe !== ze && m.current.setSelectionRange(qe, ze, _e); - } - let Ze = qe !== -1 ? qe : Ce, at = ze !== -1 ? ze : $e, ke = _e ?? Me; - I(Ze), ce(at), b.current.prev = [Ze, at, ke]; - } - if (document.addEventListener("selectionchange", ve, { capture: !0 }), ve(), document.activeElement === ie && v(!0), !document.getElementById("input-otp-style")) { - let Ce = document.createElement("style"); - if (Ce.id = "input-otp-style", document.head.appendChild(Ce), Ce.sheet) { - let $e = "background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;"; - Lf(Ce.sheet, "[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"), Lf(Ce.sheet, `[data-input-otp]:autofill { ${$e} }`), Lf(Ce.sheet, `[data-input-otp]:-webkit-autofill { ${$e} }`), Lf(Ce.sheet, "@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"), Lf(Ce.sheet, "[data-input-otp] + * { pointer-events: all !important; }"); - } - } - let Pe = () => { - ue && ue.style.setProperty("--root-height", `${ie.clientHeight}px`); - }; - Pe(); - let De = new ResizeObserver(Pe); - return De.observe(ie), () => { - document.removeEventListener("selectionchange", ve, { capture: !0 }), De.disconnect(); - }; - }, []); - let [x, _] = Gt.useState(!1), [E, v] = Gt.useState(!1), [P, I] = Gt.useState(null), [B, ce] = Gt.useState(null); - Gt.useEffect(() => { - Sne(() => { - var ie, ue, ve, Pe; - (ie = m.current) == null || ie.dispatchEvent(new Event("input")); - let De = (ue = m.current) == null ? void 0 : ue.selectionStart, Ce = (ve = m.current) == null ? void 0 : ve.selectionEnd, $e = (Pe = m.current) == null ? void 0 : Pe.selectionDirection; - De !== null && Ce !== null && (I(De), ce(Ce), b.current.prev = [De, Ce, $e]); - }); - }, [pe, E]), Gt.useEffect(() => { - Ee !== void 0 && pe !== Ee && Ee.length < s && pe.length === s && (d == null || d(pe)); - }, [s, d, Ee, pe]); - let D = Cne({ containerRef: f, inputRef: m, pushPasswordManagerStrategy: g, isFocused: E }), oe = Gt.useCallback((ie) => { - let ue = ie.currentTarget.value.slice(0, s); - if (ue.length > 0 && S && !S.test(ue)) { - ie.preventDefault(); - return; - } - typeof Ee == "string" && ue.length < Ee.length && document.dispatchEvent(new Event("selectionchange")), Y(ue); - }, [s, Y, Ee, S]), Z = Gt.useCallback(() => { - var ie; - if (m.current) { - let ue = Math.min(m.current.value.length, s - 1), ve = m.current.value.length; - (ie = m.current) == null || ie.setSelectionRange(ue, ve), I(ue), ce(ve); - } - v(!0); - }, [s]), J = Gt.useCallback((ie) => { - var ue, ve; - let Pe = m.current; - if (!w && (!p.current.isIOS || !ie.clipboardData || !Pe)) return; - let De = ie.clipboardData.getData("text/plain"), Ce = w ? w(De) : De; - console.log({ _content: De, content: Ce }), ie.preventDefault(); - let $e = (ue = m.current) == null ? void 0 : ue.selectionStart, Me = (ve = m.current) == null ? void 0 : ve.selectionEnd, Ne = ($e !== Me ? pe.slice(0, $e) + Ce + pe.slice(Me) : pe.slice(0, $e) + Ce + pe.slice($e)).slice(0, s); - if (Ne.length > 0 && S && !S.test(Ne)) return; - Pe.value = Ne, Y(Ne); - let Ke = Math.min(Ne.length, s - 1), Le = Ne.length; - Pe.setSelectionRange(Ke, Le), I(Ke), ce(Le); - }, [s, Y, S, pe]), Q = Gt.useMemo(() => ({ position: "relative", cursor: F.disabled ? "default" : "text", userSelect: "none", WebkitUserSelect: "none", pointerEvents: "none" }), [F.disabled]), T = Gt.useMemo(() => ({ position: "absolute", inset: 0, width: D.willPushPWMBadge ? `calc(100% + ${D.PWM_BADGE_SPACE_WIDTH})` : "100%", clipPath: D.willPushPWMBadge ? `inset(0 ${D.PWM_BADGE_SPACE_WIDTH} 0 0)` : void 0, height: "100%", display: "flex", textAlign: o, opacity: "1", color: "transparent", pointerEvents: "all", background: "transparent", caretColor: "transparent", border: "0 solid transparent", outline: "0 solid transparent", boxShadow: "none", lineHeight: "1", letterSpacing: "-.5em", fontSize: "var(--root-height)", fontFamily: "monospace", fontVariantNumeric: "tabular-nums" }), [D.PWM_BADGE_SPACE_WIDTH, D.willPushPWMBadge, o]), X = Gt.useMemo(() => Gt.createElement("input", _ne(xne({ autoComplete: F.autoComplete || "one-time-code" }, F), { "data-input-otp": !0, "data-input-otp-placeholder-shown": pe.length === 0 || void 0, "data-input-otp-mss": P, "data-input-otp-mse": B, inputMode: l, pattern: S == null ? void 0 : S.source, "aria-placeholder": u, style: T, maxLength: s, value: pe, ref: m, onPaste: (ie) => { - var ue; - J(ie), (ue = F.onPaste) == null || ue.call(F, ie); - }, onChange: oe, onMouseOver: (ie) => { - var ue; - _(!0), (ue = F.onMouseOver) == null || ue.call(F, ie); - }, onMouseLeave: (ie) => { - var ue; - _(!1), (ue = F.onMouseLeave) == null || ue.call(F, ie); - }, onFocus: (ie) => { - var ue; - Z(), (ue = F.onFocus) == null || ue.call(F, ie); - }, onBlur: (ie) => { - var ue; - v(!1), (ue = F.onBlur) == null || ue.call(F, ie); - } })), [oe, Z, J, l, T, s, B, P, F, S == null ? void 0 : S.source, pe]), re = Gt.useMemo(() => ({ slots: Array.from({ length: s }).map((ie, ue) => { - var ve; - let Pe = E && P !== null && B !== null && (P === B && ue === P || ue >= P && ue < B), De = pe[ue] !== void 0 ? pe[ue] : null, Ce = pe[0] !== void 0 ? null : (ve = u == null ? void 0 : u[ue]) != null ? ve : null; - return { char: De, placeholderChar: Ce, isActive: Pe, hasFakeCaret: Pe && De === null }; - }), isFocused: E, isHovering: !F.disabled && x }), [E, x, s, B, P, F.disabled, pe]), de = Gt.useMemo(() => N ? N(re) : Gt.createElement(C9.Provider, { value: re }, L), [L, re, N]); - return Gt.createElement(Gt.Fragment, null, M !== null && Gt.createElement("noscript", null, Gt.createElement("style", null, M)), Gt.createElement("div", { ref: f, "data-input-otp-container": !0, style: Q, className: A }, de, Gt.createElement("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" } }, X))); -}); -T9.displayName = "Input"; -function Lf(t, e) { - try { - t.insertRule(e); - } catch { - console.error("input-otp could not insert CSS rule:", e); - } -} -var Tne = ` -[data-input-otp] { - --nojs-bg: white !important; - --nojs-fg: black !important; - - background-color: var(--nojs-bg) !important; - color: var(--nojs-fg) !important; - caret-color: var(--nojs-fg) !important; - letter-spacing: .25em !important; - text-align: center !important; - border: 1px solid var(--nojs-fg) !important; - border-radius: 4px !important; - width: 100% !important; -} -@media (prefers-color-scheme: dark) { - [data-input-otp] { - --nojs-bg: black !important; - --nojs-fg: white !important; - } -}`; -const R9 = Gt.forwardRef(({ className: t, containerClassName: e, ...r }, n) => /* @__PURE__ */ me.jsx( - T9, - { - ref: n, - containerClassName: Do( - "xc-flex xc-items-center xc-gap-2 xc-has-[:disabled]:opacity-50", - e - ), - className: Do("disabled:xc-cursor-not-allowed", t), - ...r - } -)); -R9.displayName = "InputOTP"; -const D9 = Gt.forwardRef(({ className: t, ...e }, r) => /* @__PURE__ */ me.jsx("div", { ref: r, className: Do("xc-flex xc-items-center", t), ...e })); -D9.displayName = "InputOTPGroup"; -const Ja = Gt.forwardRef(({ index: t, className: e, ...r }, n) => { - const i = Gt.useContext(C9), { char: s, hasFakeCaret: o, isActive: a } = i.slots[t]; - return /* @__PURE__ */ me.jsxs( - "div", - { - ref: n, - className: Do( - "xc-relative xc-rounded-xl xc-text-2xl xc-flex xc-h-12 xc-w-12 xc-items-center xc-justify-center xc-border xc-border-white xc-border-opacity-20 xc-transition-all", - a && "xc-z-10 xc-ring-2 xc-ring-ring xc-ring-[rgb(135,93,255)] xc-ring-offset-background", - e - ), - ...r, - children: [ - s, - o && /* @__PURE__ */ me.jsx("div", { className: "xc-pointer-events-none xc-absolute xc-inset-0 xc-flex xc-items-center xc-justify-center", children: /* @__PURE__ */ me.jsx("div", { className: "xc-h-4 xc-w-px xc-animate-caret-blink xc-bg-foreground xc-duration-1000" }) }) - ] - } - ); -}); -Ja.displayName = "InputOTPSlot"; -function Rne(t) { - const { spinning: e, children: r, className: n } = t; - return /* @__PURE__ */ me.jsxs("div", { className: "xc-inline-block xc-relative", children: [ - r, - e && /* @__PURE__ */ me.jsx("div", { className: Do("xc-absolute xc-top-0 xc-left-0 xc-w-full xc-h-full xc-bg-black xc-bg-opacity-10 xc-flex xc-items-center xc-justify-center", n), children: /* @__PURE__ */ me.jsx(gc, { className: "xc-animate-spin" }) }) - ] }); -} -const O9 = Sa({ - channel: "", - device: "WEB", - app: "", - inviterCode: "" -}); -function ay() { - return Tn(O9); -} -function Dne(t) { - const { config: e } = t, [r, n] = fr(e.channel), [i, s] = fr(e.device), [o, a] = fr(e.app), [u, l] = fr(e.inviterCode); - return Xn(() => { - n(e.channel), s(e.device), a(e.app), l(e.inviterCode); - }, [e]), /* @__PURE__ */ me.jsx( - O9.Provider, - { - value: { - channel: r, - device: i, - app: o, - inviterCode: u - }, - children: t.children - } - ); -} -function One(t) { - const { email: e } = t, [r, n] = fr(0), [i, s] = fr(!1), [o, a] = fr(!1), [u, l] = fr(""), [d, g] = fr(""), w = ay(); - async function A() { - n(60); - const L = setInterval(() => { - n((F) => F === 0 ? (clearInterval(L), 0) : F - 1); - }, 1e3); - } - async function M(L) { - a(!0); - try { - l(""), await ya.getEmailCode({ account_type: "email", email: L }), A(); - } catch (F) { - l(F.message); - } - a(!1); - } - Xn(() => { - e && M(e); - }, [e]); - async function N(L) { - if (g(""), !(L.length < 6)) { - s(!0); - try { - const F = await ya.emailLogin({ - account_type: "email", - connector: "codatta_email", - account_enum: "C", - email_code: L, - email: e, - inviter_code: w.inviterCode, - source: { - device: w.device, - channel: w.channel, - app: w.app - } - }); - t.onLogin(F.data); - } catch (F) { - g(F.message); - } - s(!1); - } - } - return /* @__PURE__ */ me.jsxs(Ac, { children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-mb-12", children: /* @__PURE__ */ me.jsx(uh, { title: "Sign in with email", onBack: t.onBack }) }), - /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-12", children: [ - /* @__PURE__ */ me.jsx(oZ, { className: "xc-mb-4", size: 60 }), - /* @__PURE__ */ me.jsx("div", { className: "xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-8 xc-h-16", children: u ? /* @__PURE__ */ me.jsx("div", { className: "xc-text-[#ff0000] xc-text-center", children: /* @__PURE__ */ me.jsx("p", { className: "xc-px-8", children: u }) }) : o ? /* @__PURE__ */ me.jsx(gc, { className: "xc-animate-spin" }) : /* @__PURE__ */ me.jsxs(me.Fragment, { children: [ - /* @__PURE__ */ me.jsx("p", { className: "xc-text-lg xc-mb-1", children: "We’ve sent a verification code to" }), - /* @__PURE__ */ me.jsx("p", { className: "xc-font-bold xc-text-center", children: e }) - ] }) }), - /* @__PURE__ */ me.jsx("div", { className: "xc-mb-2 xc-h-12", children: /* @__PURE__ */ me.jsx(Rne, { spinning: i, className: "xc-rounded-xl", children: /* @__PURE__ */ me.jsx(R9, { maxLength: 6, onChange: N, disabled: i, className: "disabled:xc-opacity-20", children: /* @__PURE__ */ me.jsx(D9, { children: /* @__PURE__ */ me.jsxs("div", { className: Do("xc-flex xc-gap-2", i ? "xc-opacity-20" : ""), children: [ - /* @__PURE__ */ me.jsx(Ja, { index: 0 }), - /* @__PURE__ */ me.jsx(Ja, { index: 1 }), - /* @__PURE__ */ me.jsx(Ja, { index: 2 }), - /* @__PURE__ */ me.jsx(Ja, { index: 3 }), - /* @__PURE__ */ me.jsx(Ja, { index: 4 }), - /* @__PURE__ */ me.jsx(Ja, { index: 5 }) - ] }) }) }) }) }), - d && /* @__PURE__ */ me.jsx("div", { className: "xc-text-[#ff0000] xc-text-center", children: /* @__PURE__ */ me.jsx("p", { children: d }) }) - ] }), - /* @__PURE__ */ me.jsxs("div", { className: "xc-text-center xc-text-sm xc-text-gray-400", children: [ - "Not get it? ", - r ? `Recend in ${r}s` : /* @__PURE__ */ me.jsx("button", { onClick: () => M(e), children: "Send again" }) - ] }) - ] }); -} -var N9 = { exports: {} }; -(function(t, e) { - (function(r, n) { - t.exports = n(); - })(gn, () => (() => { - var r = { 873: (o, a) => { - var u, l, d = function() { - var g = function(f, p) { - var b = f, x = F[p], _ = null, E = 0, v = null, P = [], I = {}, B = function(re, de) { - _ = function(ie) { - for (var ue = new Array(ie), ve = 0; ve < ie; ve += 1) { - ue[ve] = new Array(ie); - for (var Pe = 0; Pe < ie; Pe += 1) ue[ve][Pe] = null; - } - return ue; - }(E = 4 * b + 17), ce(0, 0), ce(E - 7, 0), ce(0, E - 7), oe(), D(), J(re, de), b >= 7 && Z(re), v == null && (v = T(b, x, P)), Q(v, de); - }, ce = function(re, de) { - for (var ie = -1; ie <= 7; ie += 1) if (!(re + ie <= -1 || E <= re + ie)) for (var ue = -1; ue <= 7; ue += 1) de + ue <= -1 || E <= de + ue || (_[re + ie][de + ue] = 0 <= ie && ie <= 6 && (ue == 0 || ue == 6) || 0 <= ue && ue <= 6 && (ie == 0 || ie == 6) || 2 <= ie && ie <= 4 && 2 <= ue && ue <= 4); - }, D = function() { - for (var re = 8; re < E - 8; re += 1) _[re][6] == null && (_[re][6] = re % 2 == 0); - for (var de = 8; de < E - 8; de += 1) _[6][de] == null && (_[6][de] = de % 2 == 0); - }, oe = function() { - for (var re = $.getPatternPosition(b), de = 0; de < re.length; de += 1) for (var ie = 0; ie < re.length; ie += 1) { - var ue = re[de], ve = re[ie]; - if (_[ue][ve] == null) for (var Pe = -2; Pe <= 2; Pe += 1) for (var De = -2; De <= 2; De += 1) _[ue + Pe][ve + De] = Pe == -2 || Pe == 2 || De == -2 || De == 2 || Pe == 0 && De == 0; - } - }, Z = function(re) { - for (var de = $.getBCHTypeNumber(b), ie = 0; ie < 18; ie += 1) { - var ue = !re && (de >> ie & 1) == 1; - _[Math.floor(ie / 3)][ie % 3 + E - 8 - 3] = ue; - } - for (ie = 0; ie < 18; ie += 1) ue = !re && (de >> ie & 1) == 1, _[ie % 3 + E - 8 - 3][Math.floor(ie / 3)] = ue; - }, J = function(re, de) { - for (var ie = x << 3 | de, ue = $.getBCHTypeInfo(ie), ve = 0; ve < 15; ve += 1) { - var Pe = !re && (ue >> ve & 1) == 1; - ve < 6 ? _[ve][8] = Pe : ve < 8 ? _[ve + 1][8] = Pe : _[E - 15 + ve][8] = Pe; - } - for (ve = 0; ve < 15; ve += 1) Pe = !re && (ue >> ve & 1) == 1, ve < 8 ? _[8][E - ve - 1] = Pe : ve < 9 ? _[8][15 - ve - 1 + 1] = Pe : _[8][15 - ve - 1] = Pe; - _[E - 8][8] = !re; - }, Q = function(re, de) { - for (var ie = -1, ue = E - 1, ve = 7, Pe = 0, De = $.getMaskFunction(de), Ce = E - 1; Ce > 0; Ce -= 2) for (Ce == 6 && (Ce -= 1); ; ) { - for (var $e = 0; $e < 2; $e += 1) if (_[ue][Ce - $e] == null) { - var Me = !1; - Pe < re.length && (Me = (re[Pe] >>> ve & 1) == 1), De(ue, Ce - $e) && (Me = !Me), _[ue][Ce - $e] = Me, (ve -= 1) == -1 && (Pe += 1, ve = 7); - } - if ((ue += ie) < 0 || E <= ue) { - ue -= ie, ie = -ie; - break; - } - } - }, T = function(re, de, ie) { - for (var ue = V.getRSBlocks(re, de), ve = te(), Pe = 0; Pe < ie.length; Pe += 1) { - var De = ie[Pe]; - ve.put(De.getMode(), 4), ve.put(De.getLength(), $.getLengthInBits(De.getMode(), re)), De.write(ve); - } - var Ce = 0; - for (Pe = 0; Pe < ue.length; Pe += 1) Ce += ue[Pe].dataCount; - if (ve.getLengthInBits() > 8 * Ce) throw "code length overflow. (" + ve.getLengthInBits() + ">" + 8 * Ce + ")"; - for (ve.getLengthInBits() + 4 <= 8 * Ce && ve.put(0, 4); ve.getLengthInBits() % 8 != 0; ) ve.putBit(!1); - for (; !(ve.getLengthInBits() >= 8 * Ce || (ve.put(236, 8), ve.getLengthInBits() >= 8 * Ce)); ) ve.put(17, 8); - return function($e, Me) { - for (var Ne = 0, Ke = 0, Le = 0, qe = new Array(Me.length), ze = new Array(Me.length), _e = 0; _e < Me.length; _e += 1) { - var Ze = Me[_e].dataCount, at = Me[_e].totalCount - Ze; - Ke = Math.max(Ke, Ze), Le = Math.max(Le, at), qe[_e] = new Array(Ze); - for (var ke = 0; ke < qe[_e].length; ke += 1) qe[_e][ke] = 255 & $e.getBuffer()[ke + Ne]; - Ne += Ze; - var Qe = $.getErrorCorrectPolynomial(at), tt = H(qe[_e], Qe.getLength() - 1).mod(Qe); - for (ze[_e] = new Array(Qe.getLength() - 1), ke = 0; ke < ze[_e].length; ke += 1) { - var Ye = ke + tt.getLength() - ze[_e].length; - ze[_e][ke] = Ye >= 0 ? tt.getAt(Ye) : 0; - } - } - var dt = 0; - for (ke = 0; ke < Me.length; ke += 1) dt += Me[ke].totalCount; - var lt = new Array(dt), ct = 0; - for (ke = 0; ke < Ke; ke += 1) for (_e = 0; _e < Me.length; _e += 1) ke < qe[_e].length && (lt[ct] = qe[_e][ke], ct += 1); - for (ke = 0; ke < Le; ke += 1) for (_e = 0; _e < Me.length; _e += 1) ke < ze[_e].length && (lt[ct] = ze[_e][ke], ct += 1); - return lt; - }(ve, ue); - }; - I.addData = function(re, de) { - var ie = null; - switch (de = de || "Byte") { - case "Numeric": - ie = R(re); - break; - case "Alphanumeric": - ie = W(re); - break; - case "Byte": - ie = pe(re); - break; - case "Kanji": - ie = Ee(re); - break; - default: - throw "mode:" + de; - } - P.push(ie), v = null; - }, I.isDark = function(re, de) { - if (re < 0 || E <= re || de < 0 || E <= de) throw re + "," + de; - return _[re][de]; - }, I.getModuleCount = function() { - return E; - }, I.make = function() { - if (b < 1) { - for (var re = 1; re < 40; re++) { - for (var de = V.getRSBlocks(re, x), ie = te(), ue = 0; ue < P.length; ue++) { - var ve = P[ue]; - ie.put(ve.getMode(), 4), ie.put(ve.getLength(), $.getLengthInBits(ve.getMode(), re)), ve.write(ie); - } - var Pe = 0; - for (ue = 0; ue < de.length; ue++) Pe += de[ue].dataCount; - if (ie.getLengthInBits() <= 8 * Pe) break; - } - b = re; - } - B(!1, function() { - for (var De = 0, Ce = 0, $e = 0; $e < 8; $e += 1) { - B(!0, $e); - var Me = $.getLostPoint(I); - ($e == 0 || De > Me) && (De = Me, Ce = $e); - } - return Ce; - }()); - }, I.createTableTag = function(re, de) { - re = re || 2; - var ie = ""; - ie += '"; - }, I.createSvgTag = function(re, de, ie, ue) { - var ve = {}; - typeof arguments[0] == "object" && (re = (ve = arguments[0]).cellSize, de = ve.margin, ie = ve.alt, ue = ve.title), re = re || 2, de = de === void 0 ? 4 * re : de, (ie = typeof ie == "string" ? { text: ie } : ie || {}).text = ie.text || null, ie.id = ie.text ? ie.id || "qrcode-description" : null, (ue = typeof ue == "string" ? { text: ue } : ue || {}).text = ue.text || null, ue.id = ue.text ? ue.id || "qrcode-title" : null; - var Pe, De, Ce, $e, Me = I.getModuleCount() * re + 2 * de, Ne = ""; - for ($e = "l" + re + ",0 0," + re + " -" + re + ",0 0,-" + re + "z ", Ne += '' + X(ue.text) + "" : "", Ne += ie.text ? '' + X(ie.text) + "" : "", Ne += '', Ne += '"; - }, I.createDataURL = function(re, de) { - re = re || 2, de = de === void 0 ? 4 * re : de; - var ie = I.getModuleCount() * re + 2 * de, ue = de, ve = ie - de; - return m(ie, ie, function(Pe, De) { - if (ue <= Pe && Pe < ve && ue <= De && De < ve) { - var Ce = Math.floor((Pe - ue) / re), $e = Math.floor((De - ue) / re); - return I.isDark($e, Ce) ? 0 : 1; - } - return 1; - }); - }, I.createImgTag = function(re, de, ie) { - re = re || 2, de = de === void 0 ? 4 * re : de; - var ue = I.getModuleCount() * re + 2 * de, ve = ""; - return ve += ""; - }; - var X = function(re) { - for (var de = "", ie = 0; ie < re.length; ie += 1) { - var ue = re.charAt(ie); - switch (ue) { - case "<": - de += "<"; - break; - case ">": - de += ">"; - break; - case "&": - de += "&"; - break; - case '"': - de += """; - break; - default: - de += ue; - } - } - return de; - }; - return I.createASCII = function(re, de) { - if ((re = re || 1) < 2) return function(qe) { - qe = qe === void 0 ? 2 : qe; - var ze, _e, Ze, at, ke, Qe = 1 * I.getModuleCount() + 2 * qe, tt = qe, Ye = Qe - qe, dt = { "██": "█", "█ ": "▀", " █": "▄", " ": " " }, lt = { "██": "▀", "█ ": "▀", " █": " ", " ": " " }, ct = ""; - for (ze = 0; ze < Qe; ze += 2) { - for (Ze = Math.floor((ze - tt) / 1), at = Math.floor((ze + 1 - tt) / 1), _e = 0; _e < Qe; _e += 1) ke = "█", tt <= _e && _e < Ye && tt <= ze && ze < Ye && I.isDark(Ze, Math.floor((_e - tt) / 1)) && (ke = " "), tt <= _e && _e < Ye && tt <= ze + 1 && ze + 1 < Ye && I.isDark(at, Math.floor((_e - tt) / 1)) ? ke += " " : ke += "█", ct += qe < 1 && ze + 1 >= Ye ? lt[ke] : dt[ke]; - ct += ` -`; - } - return Qe % 2 && qe > 0 ? ct.substring(0, ct.length - Qe - 1) + Array(Qe + 1).join("▀") : ct.substring(0, ct.length - 1); - }(de); - re -= 1, de = de === void 0 ? 2 * re : de; - var ie, ue, ve, Pe, De = I.getModuleCount() * re + 2 * de, Ce = de, $e = De - de, Me = Array(re + 1).join("██"), Ne = Array(re + 1).join(" "), Ke = "", Le = ""; - for (ie = 0; ie < De; ie += 1) { - for (ve = Math.floor((ie - Ce) / re), Le = "", ue = 0; ue < De; ue += 1) Pe = 1, Ce <= ue && ue < $e && Ce <= ie && ie < $e && I.isDark(ve, Math.floor((ue - Ce) / re)) && (Pe = 0), Le += Pe ? Me : Ne; - for (ve = 0; ve < re; ve += 1) Ke += Le + ` -`; - } - return Ke.substring(0, Ke.length - 1); - }, I.renderTo2dContext = function(re, de) { - de = de || 2; - for (var ie = I.getModuleCount(), ue = 0; ue < ie; ue++) for (var ve = 0; ve < ie; ve++) re.fillStyle = I.isDark(ue, ve) ? "black" : "white", re.fillRect(ue * de, ve * de, de, de); - }, I; - }; - g.stringToBytes = (g.stringToBytesFuncs = { default: function(f) { - for (var p = [], b = 0; b < f.length; b += 1) { - var x = f.charCodeAt(b); - p.push(255 & x); - } - return p; - } }).default, g.createStringToBytes = function(f, p) { - var b = function() { - for (var _ = S(f), E = function() { - var D = _.read(); - if (D == -1) throw "eof"; - return D; - }, v = 0, P = {}; ; ) { - var I = _.read(); - if (I == -1) break; - var B = E(), ce = E() << 8 | E(); - P[String.fromCharCode(I << 8 | B)] = ce, v += 1; - } - if (v != p) throw v + " != " + p; - return P; - }(), x = 63; - return function(_) { - for (var E = [], v = 0; v < _.length; v += 1) { - var P = _.charCodeAt(v); - if (P < 128) E.push(P); - else { - var I = b[_.charAt(v)]; - typeof I == "number" ? (255 & I) == I ? E.push(I) : (E.push(I >>> 8), E.push(255 & I)) : E.push(x); - } - } - return E; - }; - }; - var w, A, M, N, L, F = { L: 1, M: 0, Q: 3, H: 2 }, $ = (w = [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50], [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], [6, 26, 48, 70], [6, 26, 50, 74], [6, 30, 54, 78], [6, 30, 56, 82], [6, 30, 58, 86], [6, 34, 62, 90], [6, 28, 50, 72, 94], [6, 26, 50, 74, 98], [6, 30, 54, 78, 102], [6, 28, 54, 80, 106], [6, 32, 58, 84, 110], [6, 30, 58, 86, 114], [6, 34, 62, 90, 118], [6, 26, 50, 74, 98, 122], [6, 30, 54, 78, 102, 126], [6, 26, 52, 78, 104, 130], [6, 30, 56, 82, 108, 134], [6, 34, 60, 86, 112, 138], [6, 30, 58, 86, 114, 142], [6, 34, 62, 90, 118, 146], [6, 30, 54, 78, 102, 126, 150], [6, 24, 50, 76, 102, 128, 154], [6, 28, 54, 80, 106, 132, 158], [6, 32, 58, 84, 110, 136, 162], [6, 26, 54, 82, 110, 138, 166], [6, 30, 58, 86, 114, 142, 170]], A = 1335, M = 7973, L = function(f) { - for (var p = 0; f != 0; ) p += 1, f >>>= 1; - return p; - }, (N = {}).getBCHTypeInfo = function(f) { - for (var p = f << 10; L(p) - L(A) >= 0; ) p ^= A << L(p) - L(A); - return 21522 ^ (f << 10 | p); - }, N.getBCHTypeNumber = function(f) { - for (var p = f << 12; L(p) - L(M) >= 0; ) p ^= M << L(p) - L(M); - return f << 12 | p; - }, N.getPatternPosition = function(f) { - return w[f - 1]; - }, N.getMaskFunction = function(f) { - switch (f) { - case 0: - return function(p, b) { - return (p + b) % 2 == 0; - }; - case 1: - return function(p, b) { - return p % 2 == 0; - }; - case 2: - return function(p, b) { - return b % 3 == 0; - }; - case 3: - return function(p, b) { - return (p + b) % 3 == 0; - }; - case 4: - return function(p, b) { - return (Math.floor(p / 2) + Math.floor(b / 3)) % 2 == 0; - }; - case 5: - return function(p, b) { - return p * b % 2 + p * b % 3 == 0; - }; - case 6: - return function(p, b) { - return (p * b % 2 + p * b % 3) % 2 == 0; - }; - case 7: - return function(p, b) { - return (p * b % 3 + (p + b) % 2) % 2 == 0; - }; - default: - throw "bad maskPattern:" + f; - } - }, N.getErrorCorrectPolynomial = function(f) { - for (var p = H([1], 0), b = 0; b < f; b += 1) p = p.multiply(H([1, K.gexp(b)], 0)); - return p; - }, N.getLengthInBits = function(f, p) { - if (1 <= p && p < 10) switch (f) { - case 1: - return 10; - case 2: - return 9; - case 4: - case 8: - return 8; - default: - throw "mode:" + f; - } - else if (p < 27) switch (f) { - case 1: - return 12; - case 2: - return 11; - case 4: - return 16; - case 8: - return 10; - default: - throw "mode:" + f; - } - else { - if (!(p < 41)) throw "type:" + p; - switch (f) { - case 1: - return 14; - case 2: - return 13; - case 4: - return 16; - case 8: - return 12; - default: - throw "mode:" + f; - } - } - }, N.getLostPoint = function(f) { - for (var p = f.getModuleCount(), b = 0, x = 0; x < p; x += 1) for (var _ = 0; _ < p; _ += 1) { - for (var E = 0, v = f.isDark(x, _), P = -1; P <= 1; P += 1) if (!(x + P < 0 || p <= x + P)) for (var I = -1; I <= 1; I += 1) _ + I < 0 || p <= _ + I || P == 0 && I == 0 || v == f.isDark(x + P, _ + I) && (E += 1); - E > 5 && (b += 3 + E - 5); - } - for (x = 0; x < p - 1; x += 1) for (_ = 0; _ < p - 1; _ += 1) { - var B = 0; - f.isDark(x, _) && (B += 1), f.isDark(x + 1, _) && (B += 1), f.isDark(x, _ + 1) && (B += 1), f.isDark(x + 1, _ + 1) && (B += 1), B != 0 && B != 4 || (b += 3); - } - for (x = 0; x < p; x += 1) for (_ = 0; _ < p - 6; _ += 1) f.isDark(x, _) && !f.isDark(x, _ + 1) && f.isDark(x, _ + 2) && f.isDark(x, _ + 3) && f.isDark(x, _ + 4) && !f.isDark(x, _ + 5) && f.isDark(x, _ + 6) && (b += 40); - for (_ = 0; _ < p; _ += 1) for (x = 0; x < p - 6; x += 1) f.isDark(x, _) && !f.isDark(x + 1, _) && f.isDark(x + 2, _) && f.isDark(x + 3, _) && f.isDark(x + 4, _) && !f.isDark(x + 5, _) && f.isDark(x + 6, _) && (b += 40); - var ce = 0; - for (_ = 0; _ < p; _ += 1) for (x = 0; x < p; x += 1) f.isDark(x, _) && (ce += 1); - return b + Math.abs(100 * ce / p / p - 50) / 5 * 10; - }, N), K = function() { - for (var f = new Array(256), p = new Array(256), b = 0; b < 8; b += 1) f[b] = 1 << b; - for (b = 8; b < 256; b += 1) f[b] = f[b - 4] ^ f[b - 5] ^ f[b - 6] ^ f[b - 8]; - for (b = 0; b < 255; b += 1) p[f[b]] = b; - return { glog: function(x) { - if (x < 1) throw "glog(" + x + ")"; - return p[x]; - }, gexp: function(x) { - for (; x < 0; ) x += 255; - for (; x >= 256; ) x -= 255; - return f[x]; - } }; - }(); - function H(f, p) { - if (f.length === void 0) throw f.length + "/" + p; - var b = function() { - for (var _ = 0; _ < f.length && f[_] == 0; ) _ += 1; - for (var E = new Array(f.length - _ + p), v = 0; v < f.length - _; v += 1) E[v] = f[v + _]; - return E; - }(), x = { getAt: function(_) { - return b[_]; - }, getLength: function() { - return b.length; - }, multiply: function(_) { - for (var E = new Array(x.getLength() + _.getLength() - 1), v = 0; v < x.getLength(); v += 1) for (var P = 0; P < _.getLength(); P += 1) E[v + P] ^= K.gexp(K.glog(x.getAt(v)) + K.glog(_.getAt(P))); - return H(E, 0); - }, mod: function(_) { - if (x.getLength() - _.getLength() < 0) return x; - for (var E = K.glog(x.getAt(0)) - K.glog(_.getAt(0)), v = new Array(x.getLength()), P = 0; P < x.getLength(); P += 1) v[P] = x.getAt(P); - for (P = 0; P < _.getLength(); P += 1) v[P] ^= K.gexp(K.glog(_.getAt(P)) + E); - return H(v, 0).mod(_); - } }; - return x; - } - var V = /* @__PURE__ */ function() { - var f = [[1, 26, 19], [1, 26, 16], [1, 26, 13], [1, 26, 9], [1, 44, 34], [1, 44, 28], [1, 44, 22], [1, 44, 16], [1, 70, 55], [1, 70, 44], [2, 35, 17], [2, 35, 13], [1, 100, 80], [2, 50, 32], [2, 50, 24], [4, 25, 9], [1, 134, 108], [2, 67, 43], [2, 33, 15, 2, 34, 16], [2, 33, 11, 2, 34, 12], [2, 86, 68], [4, 43, 27], [4, 43, 19], [4, 43, 15], [2, 98, 78], [4, 49, 31], [2, 32, 14, 4, 33, 15], [4, 39, 13, 1, 40, 14], [2, 121, 97], [2, 60, 38, 2, 61, 39], [4, 40, 18, 2, 41, 19], [4, 40, 14, 2, 41, 15], [2, 146, 116], [3, 58, 36, 2, 59, 37], [4, 36, 16, 4, 37, 17], [4, 36, 12, 4, 37, 13], [2, 86, 68, 2, 87, 69], [4, 69, 43, 1, 70, 44], [6, 43, 19, 2, 44, 20], [6, 43, 15, 2, 44, 16], [4, 101, 81], [1, 80, 50, 4, 81, 51], [4, 50, 22, 4, 51, 23], [3, 36, 12, 8, 37, 13], [2, 116, 92, 2, 117, 93], [6, 58, 36, 2, 59, 37], [4, 46, 20, 6, 47, 21], [7, 42, 14, 4, 43, 15], [4, 133, 107], [8, 59, 37, 1, 60, 38], [8, 44, 20, 4, 45, 21], [12, 33, 11, 4, 34, 12], [3, 145, 115, 1, 146, 116], [4, 64, 40, 5, 65, 41], [11, 36, 16, 5, 37, 17], [11, 36, 12, 5, 37, 13], [5, 109, 87, 1, 110, 88], [5, 65, 41, 5, 66, 42], [5, 54, 24, 7, 55, 25], [11, 36, 12, 7, 37, 13], [5, 122, 98, 1, 123, 99], [7, 73, 45, 3, 74, 46], [15, 43, 19, 2, 44, 20], [3, 45, 15, 13, 46, 16], [1, 135, 107, 5, 136, 108], [10, 74, 46, 1, 75, 47], [1, 50, 22, 15, 51, 23], [2, 42, 14, 17, 43, 15], [5, 150, 120, 1, 151, 121], [9, 69, 43, 4, 70, 44], [17, 50, 22, 1, 51, 23], [2, 42, 14, 19, 43, 15], [3, 141, 113, 4, 142, 114], [3, 70, 44, 11, 71, 45], [17, 47, 21, 4, 48, 22], [9, 39, 13, 16, 40, 14], [3, 135, 107, 5, 136, 108], [3, 67, 41, 13, 68, 42], [15, 54, 24, 5, 55, 25], [15, 43, 15, 10, 44, 16], [4, 144, 116, 4, 145, 117], [17, 68, 42], [17, 50, 22, 6, 51, 23], [19, 46, 16, 6, 47, 17], [2, 139, 111, 7, 140, 112], [17, 74, 46], [7, 54, 24, 16, 55, 25], [34, 37, 13], [4, 151, 121, 5, 152, 122], [4, 75, 47, 14, 76, 48], [11, 54, 24, 14, 55, 25], [16, 45, 15, 14, 46, 16], [6, 147, 117, 4, 148, 118], [6, 73, 45, 14, 74, 46], [11, 54, 24, 16, 55, 25], [30, 46, 16, 2, 47, 17], [8, 132, 106, 4, 133, 107], [8, 75, 47, 13, 76, 48], [7, 54, 24, 22, 55, 25], [22, 45, 15, 13, 46, 16], [10, 142, 114, 2, 143, 115], [19, 74, 46, 4, 75, 47], [28, 50, 22, 6, 51, 23], [33, 46, 16, 4, 47, 17], [8, 152, 122, 4, 153, 123], [22, 73, 45, 3, 74, 46], [8, 53, 23, 26, 54, 24], [12, 45, 15, 28, 46, 16], [3, 147, 117, 10, 148, 118], [3, 73, 45, 23, 74, 46], [4, 54, 24, 31, 55, 25], [11, 45, 15, 31, 46, 16], [7, 146, 116, 7, 147, 117], [21, 73, 45, 7, 74, 46], [1, 53, 23, 37, 54, 24], [19, 45, 15, 26, 46, 16], [5, 145, 115, 10, 146, 116], [19, 75, 47, 10, 76, 48], [15, 54, 24, 25, 55, 25], [23, 45, 15, 25, 46, 16], [13, 145, 115, 3, 146, 116], [2, 74, 46, 29, 75, 47], [42, 54, 24, 1, 55, 25], [23, 45, 15, 28, 46, 16], [17, 145, 115], [10, 74, 46, 23, 75, 47], [10, 54, 24, 35, 55, 25], [19, 45, 15, 35, 46, 16], [17, 145, 115, 1, 146, 116], [14, 74, 46, 21, 75, 47], [29, 54, 24, 19, 55, 25], [11, 45, 15, 46, 46, 16], [13, 145, 115, 6, 146, 116], [14, 74, 46, 23, 75, 47], [44, 54, 24, 7, 55, 25], [59, 46, 16, 1, 47, 17], [12, 151, 121, 7, 152, 122], [12, 75, 47, 26, 76, 48], [39, 54, 24, 14, 55, 25], [22, 45, 15, 41, 46, 16], [6, 151, 121, 14, 152, 122], [6, 75, 47, 34, 76, 48], [46, 54, 24, 10, 55, 25], [2, 45, 15, 64, 46, 16], [17, 152, 122, 4, 153, 123], [29, 74, 46, 14, 75, 47], [49, 54, 24, 10, 55, 25], [24, 45, 15, 46, 46, 16], [4, 152, 122, 18, 153, 123], [13, 74, 46, 32, 75, 47], [48, 54, 24, 14, 55, 25], [42, 45, 15, 32, 46, 16], [20, 147, 117, 4, 148, 118], [40, 75, 47, 7, 76, 48], [43, 54, 24, 22, 55, 25], [10, 45, 15, 67, 46, 16], [19, 148, 118, 6, 149, 119], [18, 75, 47, 31, 76, 48], [34, 54, 24, 34, 55, 25], [20, 45, 15, 61, 46, 16]], p = function(x, _) { - var E = {}; - return E.totalCount = x, E.dataCount = _, E; - }, b = { getRSBlocks: function(x, _) { - var E = function(Z, J) { - switch (J) { - case F.L: - return f[4 * (Z - 1) + 0]; - case F.M: - return f[4 * (Z - 1) + 1]; - case F.Q: - return f[4 * (Z - 1) + 2]; - case F.H: - return f[4 * (Z - 1) + 3]; - default: - return; - } - }(x, _); - if (E === void 0) throw "bad rs block @ typeNumber:" + x + "/errorCorrectionLevel:" + _; - for (var v = E.length / 3, P = [], I = 0; I < v; I += 1) for (var B = E[3 * I + 0], ce = E[3 * I + 1], D = E[3 * I + 2], oe = 0; oe < B; oe += 1) P.push(p(ce, D)); - return P; - } }; - return b; - }(), te = function() { - var f = [], p = 0, b = { getBuffer: function() { - return f; - }, getAt: function(x) { - var _ = Math.floor(x / 8); - return (f[_] >>> 7 - x % 8 & 1) == 1; - }, put: function(x, _) { - for (var E = 0; E < _; E += 1) b.putBit((x >>> _ - E - 1 & 1) == 1); - }, getLengthInBits: function() { - return p; - }, putBit: function(x) { - var _ = Math.floor(p / 8); - f.length <= _ && f.push(0), x && (f[_] |= 128 >>> p % 8), p += 1; - } }; - return b; - }, R = function(f) { - var p = f, b = { getMode: function() { - return 1; - }, getLength: function(E) { - return p.length; - }, write: function(E) { - for (var v = p, P = 0; P + 2 < v.length; ) E.put(x(v.substring(P, P + 3)), 10), P += 3; - P < v.length && (v.length - P == 1 ? E.put(x(v.substring(P, P + 1)), 4) : v.length - P == 2 && E.put(x(v.substring(P, P + 2)), 7)); - } }, x = function(E) { - for (var v = 0, P = 0; P < E.length; P += 1) v = 10 * v + _(E.charAt(P)); - return v; - }, _ = function(E) { - if ("0" <= E && E <= "9") return E.charCodeAt(0) - 48; - throw "illegal char :" + E; - }; - return b; - }, W = function(f) { - var p = f, b = { getMode: function() { - return 2; - }, getLength: function(_) { - return p.length; - }, write: function(_) { - for (var E = p, v = 0; v + 1 < E.length; ) _.put(45 * x(E.charAt(v)) + x(E.charAt(v + 1)), 11), v += 2; - v < E.length && _.put(x(E.charAt(v)), 6); - } }, x = function(_) { - if ("0" <= _ && _ <= "9") return _.charCodeAt(0) - 48; - if ("A" <= _ && _ <= "Z") return _.charCodeAt(0) - 65 + 10; - switch (_) { - case " ": - return 36; - case "$": - return 37; - case "%": - return 38; - case "*": - return 39; - case "+": - return 40; - case "-": - return 41; - case ".": - return 42; - case "/": - return 43; - case ":": - return 44; - default: - throw "illegal char :" + _; - } - }; - return b; - }, pe = function(f) { - var p = g.stringToBytes(f); - return { getMode: function() { - return 4; - }, getLength: function(b) { - return p.length; - }, write: function(b) { - for (var x = 0; x < p.length; x += 1) b.put(p[x], 8); - } }; - }, Ee = function(f) { - var p = g.stringToBytesFuncs.SJIS; - if (!p) throw "sjis not supported."; - (function() { - var _ = p("友"); - if (_.length != 2 || (_[0] << 8 | _[1]) != 38726) throw "sjis not supported."; - })(); - var b = p(f), x = { getMode: function() { - return 8; - }, getLength: function(_) { - return ~~(b.length / 2); - }, write: function(_) { - for (var E = b, v = 0; v + 1 < E.length; ) { - var P = (255 & E[v]) << 8 | 255 & E[v + 1]; - if (33088 <= P && P <= 40956) P -= 33088; - else { - if (!(57408 <= P && P <= 60351)) throw "illegal char at " + (v + 1) + "/" + P; - P -= 49472; - } - P = 192 * (P >>> 8 & 255) + (255 & P), _.put(P, 13), v += 2; - } - if (v < E.length) throw "illegal char at " + (v + 1); - } }; - return x; - }, Y = function() { - var f = [], p = { writeByte: function(b) { - f.push(255 & b); - }, writeShort: function(b) { - p.writeByte(b), p.writeByte(b >>> 8); - }, writeBytes: function(b, x, _) { - x = x || 0, _ = _ || b.length; - for (var E = 0; E < _; E += 1) p.writeByte(b[E + x]); - }, writeString: function(b) { - for (var x = 0; x < b.length; x += 1) p.writeByte(b.charCodeAt(x)); - }, toByteArray: function() { - return f; - }, toString: function() { - var b = ""; - b += "["; - for (var x = 0; x < f.length; x += 1) x > 0 && (b += ","), b += f[x]; - return b + "]"; - } }; - return p; - }, S = function(f) { - var p = f, b = 0, x = 0, _ = 0, E = { read: function() { - for (; _ < 8; ) { - if (b >= p.length) { - if (_ == 0) return -1; - throw "unexpected end of file./" + _; - } - var P = p.charAt(b); - if (b += 1, P == "=") return _ = 0, -1; - P.match(/^\s$/) || (x = x << 6 | v(P.charCodeAt(0)), _ += 6); - } - var I = x >>> _ - 8 & 255; - return _ -= 8, I; - } }, v = function(P) { - if (65 <= P && P <= 90) return P - 65; - if (97 <= P && P <= 122) return P - 97 + 26; - if (48 <= P && P <= 57) return P - 48 + 52; - if (P == 43) return 62; - if (P == 47) return 63; - throw "c:" + P; - }; - return E; - }, m = function(f, p, b) { - for (var x = function(ce, D) { - var oe = ce, Z = D, J = new Array(ce * D), Q = { setPixel: function(re, de, ie) { - J[de * oe + re] = ie; - }, write: function(re) { - re.writeString("GIF87a"), re.writeShort(oe), re.writeShort(Z), re.writeByte(128), re.writeByte(0), re.writeByte(0), re.writeByte(0), re.writeByte(0), re.writeByte(0), re.writeByte(255), re.writeByte(255), re.writeByte(255), re.writeString(","), re.writeShort(0), re.writeShort(0), re.writeShort(oe), re.writeShort(Z), re.writeByte(0); - var de = T(2); - re.writeByte(2); - for (var ie = 0; de.length - ie > 255; ) re.writeByte(255), re.writeBytes(de, ie, 255), ie += 255; - re.writeByte(de.length - ie), re.writeBytes(de, ie, de.length - ie), re.writeByte(0), re.writeString(";"); - } }, T = function(re) { - for (var de = 1 << re, ie = 1 + (1 << re), ue = re + 1, ve = X(), Pe = 0; Pe < de; Pe += 1) ve.add(String.fromCharCode(Pe)); - ve.add(String.fromCharCode(de)), ve.add(String.fromCharCode(ie)); - var De, Ce, $e, Me = Y(), Ne = (De = Me, Ce = 0, $e = 0, { write: function(ze, _e) { - if (ze >>> _e) throw "length over"; - for (; Ce + _e >= 8; ) De.writeByte(255 & (ze << Ce | $e)), _e -= 8 - Ce, ze >>>= 8 - Ce, $e = 0, Ce = 0; - $e |= ze << Ce, Ce += _e; - }, flush: function() { - Ce > 0 && De.writeByte($e); - } }); - Ne.write(de, ue); - var Ke = 0, Le = String.fromCharCode(J[Ke]); - for (Ke += 1; Ke < J.length; ) { - var qe = String.fromCharCode(J[Ke]); - Ke += 1, ve.contains(Le + qe) ? Le += qe : (Ne.write(ve.indexOf(Le), ue), ve.size() < 4095 && (ve.size() == 1 << ue && (ue += 1), ve.add(Le + qe)), Le = qe); - } - return Ne.write(ve.indexOf(Le), ue), Ne.write(ie, ue), Ne.flush(), Me.toByteArray(); - }, X = function() { - var re = {}, de = 0, ie = { add: function(ue) { - if (ie.contains(ue)) throw "dup key:" + ue; - re[ue] = de, de += 1; - }, size: function() { - return de; - }, indexOf: function(ue) { - return re[ue]; - }, contains: function(ue) { - return re[ue] !== void 0; - } }; - return ie; - }; - return Q; - }(f, p), _ = 0; _ < p; _ += 1) for (var E = 0; E < f; E += 1) x.setPixel(E, _, b(E, _)); - var v = Y(); - x.write(v); - for (var P = function() { - var ce = 0, D = 0, oe = 0, Z = "", J = {}, Q = function(X) { - Z += String.fromCharCode(T(63 & X)); - }, T = function(X) { - if (!(X < 0)) { - if (X < 26) return 65 + X; - if (X < 52) return X - 26 + 97; - if (X < 62) return X - 52 + 48; - if (X == 62) return 43; - if (X == 63) return 47; - } - throw "n:" + X; - }; - return J.writeByte = function(X) { - for (ce = ce << 8 | 255 & X, D += 8, oe += 1; D >= 6; ) Q(ce >>> D - 6), D -= 6; - }, J.flush = function() { - if (D > 0 && (Q(ce << 6 - D), ce = 0, D = 0), oe % 3 != 0) for (var X = 3 - oe % 3, re = 0; re < X; re += 1) Z += "="; - }, J.toString = function() { - return Z; - }, J; - }(), I = v.toByteArray(), B = 0; B < I.length; B += 1) P.writeByte(I[B]); - return P.flush(), "data:image/gif;base64," + P; - }; - return g; - }(); - d.stringToBytesFuncs["UTF-8"] = function(g) { - return function(w) { - for (var A = [], M = 0; M < w.length; M++) { - var N = w.charCodeAt(M); - N < 128 ? A.push(N) : N < 2048 ? A.push(192 | N >> 6, 128 | 63 & N) : N < 55296 || N >= 57344 ? A.push(224 | N >> 12, 128 | N >> 6 & 63, 128 | 63 & N) : (M++, N = 65536 + ((1023 & N) << 10 | 1023 & w.charCodeAt(M)), A.push(240 | N >> 18, 128 | N >> 12 & 63, 128 | N >> 6 & 63, 128 | 63 & N)); - } - return A; - }(g); - }, (l = typeof (u = function() { - return d; - }) == "function" ? u.apply(a, []) : u) === void 0 || (o.exports = l); - } }, n = {}; - function i(o) { - var a = n[o]; - if (a !== void 0) return a.exports; - var u = n[o] = { exports: {} }; - return r[o](u, u.exports, i), u.exports; - } - i.n = (o) => { - var a = o && o.__esModule ? () => o.default : () => o; - return i.d(a, { a }), a; - }, i.d = (o, a) => { - for (var u in a) i.o(a, u) && !i.o(o, u) && Object.defineProperty(o, u, { enumerable: !0, get: a[u] }); - }, i.o = (o, a) => Object.prototype.hasOwnProperty.call(o, a); - var s = {}; - return (() => { - i.d(s, { default: () => Y }); - const o = (S) => !!S && typeof S == "object" && !Array.isArray(S); - function a(S, ...m) { - if (!m.length) return S; - const f = m.shift(); - return f !== void 0 && o(S) && o(f) ? (S = Object.assign({}, S), Object.keys(f).forEach((p) => { - const b = S[p], x = f[p]; - Array.isArray(b) && Array.isArray(x) ? S[p] = x : o(b) && o(x) ? S[p] = a(Object.assign({}, b), x) : S[p] = x; - }), a(S, ...m)) : S; - } - function u(S, m) { - const f = document.createElement("a"); - f.download = m, f.href = S, document.body.appendChild(f), f.click(), document.body.removeChild(f); - } - const l = { L: 0.07, M: 0.15, Q: 0.25, H: 0.3 }; - class d { - constructor({ svg: m, type: f, window: p }) { - this._svg = m, this._type = f, this._window = p; - } - draw(m, f, p, b) { - let x; - switch (this._type) { - case "dots": - x = this._drawDot; - break; - case "classy": - x = this._drawClassy; - break; - case "classy-rounded": - x = this._drawClassyRounded; - break; - case "rounded": - x = this._drawRounded; - break; - case "extra-rounded": - x = this._drawExtraRounded; - break; - default: - x = this._drawSquare; - } - x.call(this, { x: m, y: f, size: p, getNeighbor: b }); - } - _rotateFigure({ x: m, y: f, size: p, rotation: b = 0, draw: x }) { - var _; - const E = m + p / 2, v = f + p / 2; - x(), (_ = this._element) === null || _ === void 0 || _.setAttribute("transform", `rotate(${180 * b / Math.PI},${E},${v})`); - } - _basicDot(m) { - const { size: f, x: p, y: b } = m; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "circle"), this._element.setAttribute("cx", String(p + f / 2)), this._element.setAttribute("cy", String(b + f / 2)), this._element.setAttribute("r", String(f / 2)); - } })); - } - _basicSquare(m) { - const { size: f, x: p, y: b } = m; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"), this._element.setAttribute("x", String(p)), this._element.setAttribute("y", String(b)), this._element.setAttribute("width", String(f)), this._element.setAttribute("height", String(f)); - } })); - } - _basicSideRounded(m) { - const { size: f, x: p, y: b } = m; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${p} ${b}v ${f}h ` + f / 2 + `a ${f / 2} ${f / 2}, 0, 0, 0, 0 ${-f}`); - } })); - } - _basicCornerRounded(m) { - const { size: f, x: p, y: b } = m; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${p} ${b}v ${f}h ${f}v ` + -f / 2 + `a ${f / 2} ${f / 2}, 0, 0, 0, ${-f / 2} ${-f / 2}`); - } })); - } - _basicCornerExtraRounded(m) { - const { size: f, x: p, y: b } = m; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${p} ${b}v ${f}h ${f}a ${f} ${f}, 0, 0, 0, ${-f} ${-f}`); - } })); - } - _basicCornersRounded(m) { - const { size: f, x: p, y: b } = m; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${p} ${b}v ` + f / 2 + `a ${f / 2} ${f / 2}, 0, 0, 0, ${f / 2} ${f / 2}h ` + f / 2 + "v " + -f / 2 + `a ${f / 2} ${f / 2}, 0, 0, 0, ${-f / 2} ${-f / 2}`); - } })); - } - _drawDot({ x: m, y: f, size: p }) { - this._basicDot({ x: m, y: f, size: p, rotation: 0 }); - } - _drawSquare({ x: m, y: f, size: p }) { - this._basicSquare({ x: m, y: f, size: p, rotation: 0 }); - } - _drawRounded({ x: m, y: f, size: p, getNeighbor: b }) { - const x = b ? +b(-1, 0) : 0, _ = b ? +b(1, 0) : 0, E = b ? +b(0, -1) : 0, v = b ? +b(0, 1) : 0, P = x + _ + E + v; - if (P !== 0) if (P > 2 || x && _ || E && v) this._basicSquare({ x: m, y: f, size: p, rotation: 0 }); - else { - if (P === 2) { - let I = 0; - return x && E ? I = Math.PI / 2 : E && _ ? I = Math.PI : _ && v && (I = -Math.PI / 2), void this._basicCornerRounded({ x: m, y: f, size: p, rotation: I }); - } - if (P === 1) { - let I = 0; - return E ? I = Math.PI / 2 : _ ? I = Math.PI : v && (I = -Math.PI / 2), void this._basicSideRounded({ x: m, y: f, size: p, rotation: I }); - } - } - else this._basicDot({ x: m, y: f, size: p, rotation: 0 }); - } - _drawExtraRounded({ x: m, y: f, size: p, getNeighbor: b }) { - const x = b ? +b(-1, 0) : 0, _ = b ? +b(1, 0) : 0, E = b ? +b(0, -1) : 0, v = b ? +b(0, 1) : 0, P = x + _ + E + v; - if (P !== 0) if (P > 2 || x && _ || E && v) this._basicSquare({ x: m, y: f, size: p, rotation: 0 }); - else { - if (P === 2) { - let I = 0; - return x && E ? I = Math.PI / 2 : E && _ ? I = Math.PI : _ && v && (I = -Math.PI / 2), void this._basicCornerExtraRounded({ x: m, y: f, size: p, rotation: I }); - } - if (P === 1) { - let I = 0; - return E ? I = Math.PI / 2 : _ ? I = Math.PI : v && (I = -Math.PI / 2), void this._basicSideRounded({ x: m, y: f, size: p, rotation: I }); - } - } - else this._basicDot({ x: m, y: f, size: p, rotation: 0 }); - } - _drawClassy({ x: m, y: f, size: p, getNeighbor: b }) { - const x = b ? +b(-1, 0) : 0, _ = b ? +b(1, 0) : 0, E = b ? +b(0, -1) : 0, v = b ? +b(0, 1) : 0; - x + _ + E + v !== 0 ? x || E ? _ || v ? this._basicSquare({ x: m, y: f, size: p, rotation: 0 }) : this._basicCornerRounded({ x: m, y: f, size: p, rotation: Math.PI / 2 }) : this._basicCornerRounded({ x: m, y: f, size: p, rotation: -Math.PI / 2 }) : this._basicCornersRounded({ x: m, y: f, size: p, rotation: Math.PI / 2 }); - } - _drawClassyRounded({ x: m, y: f, size: p, getNeighbor: b }) { - const x = b ? +b(-1, 0) : 0, _ = b ? +b(1, 0) : 0, E = b ? +b(0, -1) : 0, v = b ? +b(0, 1) : 0; - x + _ + E + v !== 0 ? x || E ? _ || v ? this._basicSquare({ x: m, y: f, size: p, rotation: 0 }) : this._basicCornerExtraRounded({ x: m, y: f, size: p, rotation: Math.PI / 2 }) : this._basicCornerExtraRounded({ x: m, y: f, size: p, rotation: -Math.PI / 2 }) : this._basicCornersRounded({ x: m, y: f, size: p, rotation: Math.PI / 2 }); - } - } - class g { - constructor({ svg: m, type: f, window: p }) { - this._svg = m, this._type = f, this._window = p; - } - draw(m, f, p, b) { - let x; - switch (this._type) { - case "square": - x = this._drawSquare; - break; - case "extra-rounded": - x = this._drawExtraRounded; - break; - default: - x = this._drawDot; - } - x.call(this, { x: m, y: f, size: p, rotation: b }); - } - _rotateFigure({ x: m, y: f, size: p, rotation: b = 0, draw: x }) { - var _; - const E = m + p / 2, v = f + p / 2; - x(), (_ = this._element) === null || _ === void 0 || _.setAttribute("transform", `rotate(${180 * b / Math.PI},${E},${v})`); - } - _basicDot(m) { - const { size: f, x: p, y: b } = m, x = f / 7; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${p + f / 2} ${b}a ${f / 2} ${f / 2} 0 1 0 0.1 0zm 0 ${x}a ${f / 2 - x} ${f / 2 - x} 0 1 1 -0.1 0Z`); - } })); - } - _basicSquare(m) { - const { size: f, x: p, y: b } = m, x = f / 7; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${p} ${b}v ${f}h ${f}v ` + -f + `zM ${p + x} ${b + x}h ` + (f - 2 * x) + "v " + (f - 2 * x) + "h " + (2 * x - f) + "z"); - } })); - } - _basicExtraRounded(m) { - const { size: f, x: p, y: b } = m, x = f / 7; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${p} ${b + 2.5 * x}v ` + 2 * x + `a ${2.5 * x} ${2.5 * x}, 0, 0, 0, ${2.5 * x} ${2.5 * x}h ` + 2 * x + `a ${2.5 * x} ${2.5 * x}, 0, 0, 0, ${2.5 * x} ${2.5 * -x}v ` + -2 * x + `a ${2.5 * x} ${2.5 * x}, 0, 0, 0, ${2.5 * -x} ${2.5 * -x}h ` + -2 * x + `a ${2.5 * x} ${2.5 * x}, 0, 0, 0, ${2.5 * -x} ${2.5 * x}M ${p + 2.5 * x} ${b + x}h ` + 2 * x + `a ${1.5 * x} ${1.5 * x}, 0, 0, 1, ${1.5 * x} ${1.5 * x}v ` + 2 * x + `a ${1.5 * x} ${1.5 * x}, 0, 0, 1, ${1.5 * -x} ${1.5 * x}h ` + -2 * x + `a ${1.5 * x} ${1.5 * x}, 0, 0, 1, ${1.5 * -x} ${1.5 * -x}v ` + -2 * x + `a ${1.5 * x} ${1.5 * x}, 0, 0, 1, ${1.5 * x} ${1.5 * -x}`); - } })); - } - _drawDot({ x: m, y: f, size: p, rotation: b }) { - this._basicDot({ x: m, y: f, size: p, rotation: b }); - } - _drawSquare({ x: m, y: f, size: p, rotation: b }) { - this._basicSquare({ x: m, y: f, size: p, rotation: b }); - } - _drawExtraRounded({ x: m, y: f, size: p, rotation: b }) { - this._basicExtraRounded({ x: m, y: f, size: p, rotation: b }); - } - } - class w { - constructor({ svg: m, type: f, window: p }) { - this._svg = m, this._type = f, this._window = p; - } - draw(m, f, p, b) { - let x; - x = this._type === "square" ? this._drawSquare : this._drawDot, x.call(this, { x: m, y: f, size: p, rotation: b }); - } - _rotateFigure({ x: m, y: f, size: p, rotation: b = 0, draw: x }) { - var _; - const E = m + p / 2, v = f + p / 2; - x(), (_ = this._element) === null || _ === void 0 || _.setAttribute("transform", `rotate(${180 * b / Math.PI},${E},${v})`); - } - _basicDot(m) { - const { size: f, x: p, y: b } = m; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "circle"), this._element.setAttribute("cx", String(p + f / 2)), this._element.setAttribute("cy", String(b + f / 2)), this._element.setAttribute("r", String(f / 2)); - } })); - } - _basicSquare(m) { - const { size: f, x: p, y: b } = m; - this._rotateFigure(Object.assign(Object.assign({}, m), { draw: () => { - this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"), this._element.setAttribute("x", String(p)), this._element.setAttribute("y", String(b)), this._element.setAttribute("width", String(f)), this._element.setAttribute("height", String(f)); - } })); - } - _drawDot({ x: m, y: f, size: p, rotation: b }) { - this._basicDot({ x: m, y: f, size: p, rotation: b }); - } - _drawSquare({ x: m, y: f, size: p, rotation: b }) { - this._basicSquare({ x: m, y: f, size: p, rotation: b }); - } - } - const A = "circle", M = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]], N = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]; - class L { - constructor(m, f) { - this._roundSize = (p) => this._options.dotsOptions.roundSize ? Math.floor(p) : p, this._window = f, this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "svg"), this._element.setAttribute("width", String(m.width)), this._element.setAttribute("height", String(m.height)), this._element.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), m.dotsOptions.roundSize || this._element.setAttribute("shape-rendering", "crispEdges"), this._element.setAttribute("viewBox", `0 0 ${m.width} ${m.height}`), this._defs = this._window.document.createElementNS("http://www.w3.org/2000/svg", "defs"), this._element.appendChild(this._defs), this._imageUri = m.image, this._instanceId = L.instanceCount++, this._options = m; - } - get width() { - return this._options.width; - } - get height() { - return this._options.height; - } - getElement() { - return this._element; - } - async drawQR(m) { - const f = m.getModuleCount(), p = Math.min(this._options.width, this._options.height) - 2 * this._options.margin, b = this._options.shape === A ? p / Math.sqrt(2) : p, x = this._roundSize(b / f); - let _ = { hideXDots: 0, hideYDots: 0, width: 0, height: 0 }; - if (this._qr = m, this._options.image) { - if (await this.loadImage(), !this._image) return; - const { imageOptions: E, qrOptions: v } = this._options, P = E.imageSize * l[v.errorCorrectionLevel], I = Math.floor(P * f * f); - _ = function({ originalHeight: B, originalWidth: ce, maxHiddenDots: D, maxHiddenAxisDots: oe, dotSize: Z }) { - const J = { x: 0, y: 0 }, Q = { x: 0, y: 0 }; - if (B <= 0 || ce <= 0 || D <= 0 || Z <= 0) return { height: 0, width: 0, hideYDots: 0, hideXDots: 0 }; - const T = B / ce; - return J.x = Math.floor(Math.sqrt(D / T)), J.x <= 0 && (J.x = 1), oe && oe < J.x && (J.x = oe), J.x % 2 == 0 && J.x--, Q.x = J.x * Z, J.y = 1 + 2 * Math.ceil((J.x * T - 1) / 2), Q.y = Math.round(Q.x * T), (J.y * J.x > D || oe && oe < J.y) && (oe && oe < J.y ? (J.y = oe, J.y % 2 == 0 && J.x--) : J.y -= 2, Q.y = J.y * Z, J.x = 1 + 2 * Math.ceil((J.y / T - 1) / 2), Q.x = Math.round(Q.y / T)), { height: Q.y, width: Q.x, hideYDots: J.y, hideXDots: J.x }; - }({ originalWidth: this._image.width, originalHeight: this._image.height, maxHiddenDots: I, maxHiddenAxisDots: f - 14, dotSize: x }); - } - this.drawBackground(), this.drawDots((E, v) => { - var P, I, B, ce, D, oe; - return !(this._options.imageOptions.hideBackgroundDots && E >= (f - _.hideYDots) / 2 && E < (f + _.hideYDots) / 2 && v >= (f - _.hideXDots) / 2 && v < (f + _.hideXDots) / 2 || !((P = M[E]) === null || P === void 0) && P[v] || !((I = M[E - f + 7]) === null || I === void 0) && I[v] || !((B = M[E]) === null || B === void 0) && B[v - f + 7] || !((ce = N[E]) === null || ce === void 0) && ce[v] || !((D = N[E - f + 7]) === null || D === void 0) && D[v] || !((oe = N[E]) === null || oe === void 0) && oe[v - f + 7]); - }), this.drawCorners(), this._options.image && await this.drawImage({ width: _.width, height: _.height, count: f, dotSize: x }); - } - drawBackground() { - var m, f, p; - const b = this._element, x = this._options; - if (b) { - const _ = (m = x.backgroundOptions) === null || m === void 0 ? void 0 : m.gradient, E = (f = x.backgroundOptions) === null || f === void 0 ? void 0 : f.color; - let v = x.height, P = x.width; - if (_ || E) { - const I = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"); - this._backgroundClipPath = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), this._backgroundClipPath.setAttribute("id", `clip-path-background-color-${this._instanceId}`), this._defs.appendChild(this._backgroundClipPath), !((p = x.backgroundOptions) === null || p === void 0) && p.round && (v = P = Math.min(x.width, x.height), I.setAttribute("rx", String(v / 2 * x.backgroundOptions.round))), I.setAttribute("x", String(this._roundSize((x.width - P) / 2))), I.setAttribute("y", String(this._roundSize((x.height - v) / 2))), I.setAttribute("width", String(P)), I.setAttribute("height", String(v)), this._backgroundClipPath.appendChild(I), this._createColor({ options: _, color: E, additionalRotation: 0, x: 0, y: 0, height: x.height, width: x.width, name: `background-color-${this._instanceId}` }); - } - } - } - drawDots(m) { - var f, p; - if (!this._qr) throw "QR code is not defined"; - const b = this._options, x = this._qr.getModuleCount(); - if (x > b.width || x > b.height) throw "The canvas is too small."; - const _ = Math.min(b.width, b.height) - 2 * b.margin, E = b.shape === A ? _ / Math.sqrt(2) : _, v = this._roundSize(E / x), P = this._roundSize((b.width - x * v) / 2), I = this._roundSize((b.height - x * v) / 2), B = new d({ svg: this._element, type: b.dotsOptions.type, window: this._window }); - this._dotsClipPath = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), this._dotsClipPath.setAttribute("id", `clip-path-dot-color-${this._instanceId}`), this._defs.appendChild(this._dotsClipPath), this._createColor({ options: (f = b.dotsOptions) === null || f === void 0 ? void 0 : f.gradient, color: b.dotsOptions.color, additionalRotation: 0, x: 0, y: 0, height: b.height, width: b.width, name: `dot-color-${this._instanceId}` }); - for (let ce = 0; ce < x; ce++) for (let D = 0; D < x; D++) m && !m(ce, D) || !((p = this._qr) === null || p === void 0) && p.isDark(ce, D) && (B.draw(P + D * v, I + ce * v, v, (oe, Z) => !(D + oe < 0 || ce + Z < 0 || D + oe >= x || ce + Z >= x) && !(m && !m(ce + Z, D + oe)) && !!this._qr && this._qr.isDark(ce + Z, D + oe)), B._element && this._dotsClipPath && this._dotsClipPath.appendChild(B._element)); - if (b.shape === A) { - const ce = this._roundSize((_ / v - x) / 2), D = x + 2 * ce, oe = P - ce * v, Z = I - ce * v, J = [], Q = this._roundSize(D / 2); - for (let T = 0; T < D; T++) { - J[T] = []; - for (let X = 0; X < D; X++) T >= ce - 1 && T <= D - ce && X >= ce - 1 && X <= D - ce || Math.sqrt((T - Q) * (T - Q) + (X - Q) * (X - Q)) > Q ? J[T][X] = 0 : J[T][X] = this._qr.isDark(X - 2 * ce < 0 ? X : X >= x ? X - 2 * ce : X - ce, T - 2 * ce < 0 ? T : T >= x ? T - 2 * ce : T - ce) ? 1 : 0; - } - for (let T = 0; T < D; T++) for (let X = 0; X < D; X++) J[T][X] && (B.draw(oe + X * v, Z + T * v, v, (re, de) => { - var ie; - return !!(!((ie = J[T + de]) === null || ie === void 0) && ie[X + re]); - }), B._element && this._dotsClipPath && this._dotsClipPath.appendChild(B._element)); - } - } - drawCorners() { - if (!this._qr) throw "QR code is not defined"; - const m = this._element, f = this._options; - if (!m) throw "Element code is not defined"; - const p = this._qr.getModuleCount(), b = Math.min(f.width, f.height) - 2 * f.margin, x = f.shape === A ? b / Math.sqrt(2) : b, _ = this._roundSize(x / p), E = 7 * _, v = 3 * _, P = this._roundSize((f.width - p * _) / 2), I = this._roundSize((f.height - p * _) / 2); - [[0, 0, 0], [1, 0, Math.PI / 2], [0, 1, -Math.PI / 2]].forEach(([B, ce, D]) => { - var oe, Z, J, Q, T, X, re, de, ie, ue, ve, Pe; - const De = P + B * _ * (p - 7), Ce = I + ce * _ * (p - 7); - let $e = this._dotsClipPath, Me = this._dotsClipPath; - if ((!((oe = f.cornersSquareOptions) === null || oe === void 0) && oe.gradient || !((Z = f.cornersSquareOptions) === null || Z === void 0) && Z.color) && ($e = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), $e.setAttribute("id", `clip-path-corners-square-color-${B}-${ce}-${this._instanceId}`), this._defs.appendChild($e), this._cornersSquareClipPath = this._cornersDotClipPath = Me = $e, this._createColor({ options: (J = f.cornersSquareOptions) === null || J === void 0 ? void 0 : J.gradient, color: (Q = f.cornersSquareOptions) === null || Q === void 0 ? void 0 : Q.color, additionalRotation: D, x: De, y: Ce, height: E, width: E, name: `corners-square-color-${B}-${ce}-${this._instanceId}` })), (T = f.cornersSquareOptions) === null || T === void 0 ? void 0 : T.type) { - const Ne = new g({ svg: this._element, type: f.cornersSquareOptions.type, window: this._window }); - Ne.draw(De, Ce, E, D), Ne._element && $e && $e.appendChild(Ne._element); - } else { - const Ne = new d({ svg: this._element, type: f.dotsOptions.type, window: this._window }); - for (let Ke = 0; Ke < M.length; Ke++) for (let Le = 0; Le < M[Ke].length; Le++) !((X = M[Ke]) === null || X === void 0) && X[Le] && (Ne.draw(De + Le * _, Ce + Ke * _, _, (qe, ze) => { - var _e; - return !!(!((_e = M[Ke + ze]) === null || _e === void 0) && _e[Le + qe]); - }), Ne._element && $e && $e.appendChild(Ne._element)); - } - if ((!((re = f.cornersDotOptions) === null || re === void 0) && re.gradient || !((de = f.cornersDotOptions) === null || de === void 0) && de.color) && (Me = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), Me.setAttribute("id", `clip-path-corners-dot-color-${B}-${ce}-${this._instanceId}`), this._defs.appendChild(Me), this._cornersDotClipPath = Me, this._createColor({ options: (ie = f.cornersDotOptions) === null || ie === void 0 ? void 0 : ie.gradient, color: (ue = f.cornersDotOptions) === null || ue === void 0 ? void 0 : ue.color, additionalRotation: D, x: De + 2 * _, y: Ce + 2 * _, height: v, width: v, name: `corners-dot-color-${B}-${ce}-${this._instanceId}` })), (ve = f.cornersDotOptions) === null || ve === void 0 ? void 0 : ve.type) { - const Ne = new w({ svg: this._element, type: f.cornersDotOptions.type, window: this._window }); - Ne.draw(De + 2 * _, Ce + 2 * _, v, D), Ne._element && Me && Me.appendChild(Ne._element); - } else { - const Ne = new d({ svg: this._element, type: f.dotsOptions.type, window: this._window }); - for (let Ke = 0; Ke < N.length; Ke++) for (let Le = 0; Le < N[Ke].length; Le++) !((Pe = N[Ke]) === null || Pe === void 0) && Pe[Le] && (Ne.draw(De + Le * _, Ce + Ke * _, _, (qe, ze) => { - var _e; - return !!(!((_e = N[Ke + ze]) === null || _e === void 0) && _e[Le + qe]); - }), Ne._element && Me && Me.appendChild(Ne._element)); - } - }); - } - loadImage() { - return new Promise((m, f) => { - var p; - const b = this._options; - if (!b.image) return f("Image is not defined"); - if (!((p = b.nodeCanvas) === null || p === void 0) && p.loadImage) b.nodeCanvas.loadImage(b.image).then((x) => { - var _, E; - if (this._image = x, this._options.imageOptions.saveAsBlob) { - const v = (_ = b.nodeCanvas) === null || _ === void 0 ? void 0 : _.createCanvas(this._image.width, this._image.height); - (E = v == null ? void 0 : v.getContext("2d")) === null || E === void 0 || E.drawImage(x, 0, 0), this._imageUri = v == null ? void 0 : v.toDataURL(); - } - m(); - }).catch(f); - else { - const x = new this._window.Image(); - typeof b.imageOptions.crossOrigin == "string" && (x.crossOrigin = b.imageOptions.crossOrigin), this._image = x, x.onload = async () => { - this._options.imageOptions.saveAsBlob && (this._imageUri = await async function(_, E) { - return new Promise((v) => { - const P = new E.XMLHttpRequest(); - P.onload = function() { - const I = new E.FileReader(); - I.onloadend = function() { - v(I.result); - }, I.readAsDataURL(P.response); - }, P.open("GET", _), P.responseType = "blob", P.send(); - }); - }(b.image || "", this._window)), m(); - }, x.src = b.image; - } - }); - } - async drawImage({ width: m, height: f, count: p, dotSize: b }) { - const x = this._options, _ = this._roundSize((x.width - p * b) / 2), E = this._roundSize((x.height - p * b) / 2), v = _ + this._roundSize(x.imageOptions.margin + (p * b - m) / 2), P = E + this._roundSize(x.imageOptions.margin + (p * b - f) / 2), I = m - 2 * x.imageOptions.margin, B = f - 2 * x.imageOptions.margin, ce = this._window.document.createElementNS("http://www.w3.org/2000/svg", "image"); - ce.setAttribute("href", this._imageUri || ""), ce.setAttribute("x", String(v)), ce.setAttribute("y", String(P)), ce.setAttribute("width", `${I}px`), ce.setAttribute("height", `${B}px`), this._element.appendChild(ce); - } - _createColor({ options: m, color: f, additionalRotation: p, x: b, y: x, height: _, width: E, name: v }) { - const P = E > _ ? E : _, I = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"); - if (I.setAttribute("x", String(b)), I.setAttribute("y", String(x)), I.setAttribute("height", String(_)), I.setAttribute("width", String(E)), I.setAttribute("clip-path", `url('#clip-path-${v}')`), m) { - let B; - if (m.type === "radial") B = this._window.document.createElementNS("http://www.w3.org/2000/svg", "radialGradient"), B.setAttribute("id", v), B.setAttribute("gradientUnits", "userSpaceOnUse"), B.setAttribute("fx", String(b + E / 2)), B.setAttribute("fy", String(x + _ / 2)), B.setAttribute("cx", String(b + E / 2)), B.setAttribute("cy", String(x + _ / 2)), B.setAttribute("r", String(P / 2)); - else { - const ce = ((m.rotation || 0) + p) % (2 * Math.PI), D = (ce + 2 * Math.PI) % (2 * Math.PI); - let oe = b + E / 2, Z = x + _ / 2, J = b + E / 2, Q = x + _ / 2; - D >= 0 && D <= 0.25 * Math.PI || D > 1.75 * Math.PI && D <= 2 * Math.PI ? (oe -= E / 2, Z -= _ / 2 * Math.tan(ce), J += E / 2, Q += _ / 2 * Math.tan(ce)) : D > 0.25 * Math.PI && D <= 0.75 * Math.PI ? (Z -= _ / 2, oe -= E / 2 / Math.tan(ce), Q += _ / 2, J += E / 2 / Math.tan(ce)) : D > 0.75 * Math.PI && D <= 1.25 * Math.PI ? (oe += E / 2, Z += _ / 2 * Math.tan(ce), J -= E / 2, Q -= _ / 2 * Math.tan(ce)) : D > 1.25 * Math.PI && D <= 1.75 * Math.PI && (Z += _ / 2, oe += E / 2 / Math.tan(ce), Q -= _ / 2, J -= E / 2 / Math.tan(ce)), B = this._window.document.createElementNS("http://www.w3.org/2000/svg", "linearGradient"), B.setAttribute("id", v), B.setAttribute("gradientUnits", "userSpaceOnUse"), B.setAttribute("x1", String(Math.round(oe))), B.setAttribute("y1", String(Math.round(Z))), B.setAttribute("x2", String(Math.round(J))), B.setAttribute("y2", String(Math.round(Q))); - } - m.colorStops.forEach(({ offset: ce, color: D }) => { - const oe = this._window.document.createElementNS("http://www.w3.org/2000/svg", "stop"); - oe.setAttribute("offset", 100 * ce + "%"), oe.setAttribute("stop-color", D), B.appendChild(oe); - }), I.setAttribute("fill", `url('#${v}')`), this._defs.appendChild(B); - } else f && I.setAttribute("fill", f); - this._element.appendChild(I); - } - } - L.instanceCount = 0; - const F = L, $ = "canvas", K = {}; - for (let S = 0; S <= 40; S++) K[S] = S; - const H = { type: $, shape: "square", width: 300, height: 300, data: "", margin: 0, qrOptions: { typeNumber: K[0], mode: void 0, errorCorrectionLevel: "Q" }, imageOptions: { saveAsBlob: !0, hideBackgroundDots: !0, imageSize: 0.4, crossOrigin: void 0, margin: 0 }, dotsOptions: { type: "square", color: "#000", roundSize: !0 }, backgroundOptions: { round: 0, color: "#fff" } }; - function V(S) { - const m = Object.assign({}, S); - if (!m.colorStops || !m.colorStops.length) throw "Field 'colorStops' is required in gradient"; - return m.rotation ? m.rotation = Number(m.rotation) : m.rotation = 0, m.colorStops = m.colorStops.map((f) => Object.assign(Object.assign({}, f), { offset: Number(f.offset) })), m; - } - function te(S) { - const m = Object.assign({}, S); - return m.width = Number(m.width), m.height = Number(m.height), m.margin = Number(m.margin), m.imageOptions = Object.assign(Object.assign({}, m.imageOptions), { hideBackgroundDots: !!m.imageOptions.hideBackgroundDots, imageSize: Number(m.imageOptions.imageSize), margin: Number(m.imageOptions.margin) }), m.margin > Math.min(m.width, m.height) && (m.margin = Math.min(m.width, m.height)), m.dotsOptions = Object.assign({}, m.dotsOptions), m.dotsOptions.gradient && (m.dotsOptions.gradient = V(m.dotsOptions.gradient)), m.cornersSquareOptions && (m.cornersSquareOptions = Object.assign({}, m.cornersSquareOptions), m.cornersSquareOptions.gradient && (m.cornersSquareOptions.gradient = V(m.cornersSquareOptions.gradient))), m.cornersDotOptions && (m.cornersDotOptions = Object.assign({}, m.cornersDotOptions), m.cornersDotOptions.gradient && (m.cornersDotOptions.gradient = V(m.cornersDotOptions.gradient))), m.backgroundOptions && (m.backgroundOptions = Object.assign({}, m.backgroundOptions), m.backgroundOptions.gradient && (m.backgroundOptions.gradient = V(m.backgroundOptions.gradient))), m; - } - var R = i(873), W = i.n(R); - function pe(S) { - if (!S) throw new Error("Extension must be defined"); - S[0] === "." && (S = S.substring(1)); - const m = { bmp: "image/bmp", gif: "image/gif", ico: "image/vnd.microsoft.icon", jpeg: "image/jpeg", jpg: "image/jpeg", png: "image/png", svg: "image/svg+xml", tif: "image/tiff", tiff: "image/tiff", webp: "image/webp", pdf: "application/pdf" }[S.toLowerCase()]; - if (!m) throw new Error(`Extension "${S}" is not supported`); - return m; - } - class Ee { - constructor(m) { - m != null && m.jsdom ? this._window = new m.jsdom("", { resources: "usable" }).window : this._window = window, this._options = m ? te(a(H, m)) : H, this.update(); - } - static _clearContainer(m) { - m && (m.innerHTML = ""); - } - _setupSvg() { - if (!this._qr) return; - const m = new F(this._options, this._window); - this._svg = m.getElement(), this._svgDrawingPromise = m.drawQR(this._qr).then(() => { - var f; - this._svg && ((f = this._extension) === null || f === void 0 || f.call(this, m.getElement(), this._options)); - }); - } - _setupCanvas() { - var m, f; - this._qr && (!((m = this._options.nodeCanvas) === null || m === void 0) && m.createCanvas ? (this._nodeCanvas = this._options.nodeCanvas.createCanvas(this._options.width, this._options.height), this._nodeCanvas.width = this._options.width, this._nodeCanvas.height = this._options.height) : (this._domCanvas = document.createElement("canvas"), this._domCanvas.width = this._options.width, this._domCanvas.height = this._options.height), this._setupSvg(), this._canvasDrawingPromise = (f = this._svgDrawingPromise) === null || f === void 0 ? void 0 : f.then(() => { - var p; - if (!this._svg) return; - const b = this._svg, x = new this._window.XMLSerializer().serializeToString(b), _ = btoa(x), E = `data:${pe("svg")};base64,${_}`; - if (!((p = this._options.nodeCanvas) === null || p === void 0) && p.loadImage) return this._options.nodeCanvas.loadImage(E).then((v) => { - var P, I; - v.width = this._options.width, v.height = this._options.height, (I = (P = this._nodeCanvas) === null || P === void 0 ? void 0 : P.getContext("2d")) === null || I === void 0 || I.drawImage(v, 0, 0); - }); - { - const v = new this._window.Image(); - return new Promise((P) => { - v.onload = () => { - var I, B; - (B = (I = this._domCanvas) === null || I === void 0 ? void 0 : I.getContext("2d")) === null || B === void 0 || B.drawImage(v, 0, 0), P(); - }, v.src = E; - }); - } - })); - } - async _getElement(m = "png") { - if (!this._qr) throw "QR code is empty"; - return m.toLowerCase() === "svg" ? (this._svg && this._svgDrawingPromise || this._setupSvg(), await this._svgDrawingPromise, this._svg) : ((this._domCanvas || this._nodeCanvas) && this._canvasDrawingPromise || this._setupCanvas(), await this._canvasDrawingPromise, this._domCanvas || this._nodeCanvas); - } - update(m) { - Ee._clearContainer(this._container), this._options = m ? te(a(this._options, m)) : this._options, this._options.data && (this._qr = W()(this._options.qrOptions.typeNumber, this._options.qrOptions.errorCorrectionLevel), this._qr.addData(this._options.data, this._options.qrOptions.mode || function(f) { - switch (!0) { - case /^[0-9]*$/.test(f): - return "Numeric"; - case /^[0-9A-Z $%*+\-./:]*$/.test(f): - return "Alphanumeric"; - default: - return "Byte"; - } - }(this._options.data)), this._qr.make(), this._options.type === $ ? this._setupCanvas() : this._setupSvg(), this.append(this._container)); - } - append(m) { - if (m) { - if (typeof m.appendChild != "function") throw "Container should be a single DOM node"; - this._options.type === $ ? this._domCanvas && m.appendChild(this._domCanvas) : this._svg && m.appendChild(this._svg), this._container = m; - } - } - applyExtension(m) { - if (!m) throw "Extension function should be defined."; - this._extension = m, this.update(); - } - deleteExtension() { - this._extension = void 0, this.update(); - } - async getRawData(m = "png") { - if (!this._qr) throw "QR code is empty"; - const f = await this._getElement(m), p = pe(m); - if (!f) return null; - if (m.toLowerCase() === "svg") { - const b = `\r -${new this._window.XMLSerializer().serializeToString(f)}`; - return typeof Blob > "u" || this._options.jsdom ? Buffer.from(b) : new Blob([b], { type: p }); - } - return new Promise((b) => { - const x = f; - if ("toBuffer" in x) if (p === "image/png") b(x.toBuffer(p)); - else if (p === "image/jpeg") b(x.toBuffer(p)); - else { - if (p !== "application/pdf") throw Error("Unsupported extension"); - b(x.toBuffer(p)); - } - else "toBlob" in x && x.toBlob(b, p, 1); - }); - } - async download(m) { - if (!this._qr) throw "QR code is empty"; - if (typeof Blob > "u") throw "Cannot download in Node.js, call getRawData instead."; - let f = "png", p = "qr"; - typeof m == "string" ? (f = m, console.warn("Extension is deprecated as argument for 'download' method, please pass object { name: '...', extension: '...' } as argument")) : typeof m == "object" && m !== null && (m.name && (p = m.name), m.extension && (f = m.extension)); - const b = await this._getElement(f); - if (b) if (f.toLowerCase() === "svg") { - let x = new XMLSerializer().serializeToString(b); - x = `\r -` + x, u(`data:${pe(f)};charset=utf-8,${encodeURIComponent(x)}`, `${p}.svg`); - } else u(b.toDataURL(pe(f)), `${p}.${f}`); - } - } - const Y = Ee; - })(), s.default; - })()); -})(N9); -var Nne = N9.exports; -const L9 = /* @__PURE__ */ ts(Nne); -class ia extends yt { - constructor(e) { - const { docsPath: r, field: n, metaMessages: i } = e; - super(`Invalid Sign-In with Ethereum message field "${n}".`, { - docsPath: r, - metaMessages: i, - name: "SiweInvalidMessageFieldError" - }); - } -} -function u5(t) { - if (/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(t) || /%[^0-9a-f]/i.test(t) || /%[0-9a-f](:?[^0-9a-f]|$)/i.test(t)) - return !1; - const e = Lne(t), r = e[1], n = e[2], i = e[3], s = e[4], o = e[5]; - if (!(r != null && r.length && i.length >= 0)) - return !1; - if (n != null && n.length) { - if (!(i.length === 0 || /^\//.test(i))) - return !1; - } else if (/^\/\//.test(i)) - return !1; - if (!/^[a-z][a-z0-9\+\-\.]*$/.test(r.toLowerCase())) - return !1; - let a = ""; - return a += `${r}:`, n != null && n.length && (a += `//${n}`), a += i, s != null && s.length && (a += `?${s}`), o != null && o.length && (a += `#${o}`), a; -} -function Lne(t) { - return t.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/); -} -function k9(t) { - const { chainId: e, domain: r, expirationTime: n, issuedAt: i = /* @__PURE__ */ new Date(), nonce: s, notBefore: o, requestId: a, resources: u, scheme: l, uri: d, version: g } = t; - { - if (e !== Math.floor(e)) - throw new ia({ - field: "chainId", - metaMessages: [ - "- Chain ID must be a EIP-155 chain ID.", - "- See https://eips.ethereum.org/EIPS/eip-155", - "", - `Provided value: ${e}` - ] - }); - if (!(kne.test(r) || $ne.test(r) || Fne.test(r))) - throw new ia({ - field: "domain", - metaMessages: [ - "- Domain must be an RFC 3986 authority.", - "- See https://www.rfc-editor.org/rfc/rfc3986", - "", - `Provided value: ${r}` - ] - }); - if (!Bne.test(s)) - throw new ia({ - field: "nonce", - metaMessages: [ - "- Nonce must be at least 8 characters.", - "- Nonce must be alphanumeric.", - "", - `Provided value: ${s}` - ] - }); - if (!u5(d)) - throw new ia({ - field: "uri", - metaMessages: [ - "- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.", - "- See https://www.rfc-editor.org/rfc/rfc3986", - "", - `Provided value: ${d}` - ] - }); - if (g !== "1") - throw new ia({ - field: "version", - metaMessages: [ - "- Version must be '1'.", - "", - `Provided value: ${g}` - ] - }); - if (l && !Une.test(l)) - throw new ia({ - field: "scheme", - metaMessages: [ - "- Scheme must be an RFC 3986 URI scheme.", - "- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1", - "", - `Provided value: ${l}` - ] - }); - const F = t.statement; - if (F != null && F.includes(` -`)) - throw new ia({ - field: "statement", - metaMessages: [ - "- Statement must not include '\\n'.", - "", - `Provided value: ${F}` - ] - }); - } - const w = k5(t.address), A = l ? `${l}://${r}` : r, M = t.statement ? `${t.statement} -` : "", N = `${A} wants you to sign in with your Ethereum account: -${w} - -${M}`; - let L = `URI: ${d} -Version: ${g} -Chain ID: ${e} -Nonce: ${s} -Issued At: ${i.toISOString()}`; - if (n && (L += ` -Expiration Time: ${n.toISOString()}`), o && (L += ` -Not Before: ${o.toISOString()}`), a && (L += ` -Request ID: ${a}`), u) { - let F = ` -Resources:`; - for (const $ of u) { - if (!u5($)) - throw new ia({ - field: "resources", - metaMessages: [ - "- Every resource must be a RFC 3986 URI.", - "- See https://www.rfc-editor.org/rfc/rfc3986", - "", - `Provided value: ${$}` - ] - }); - F += ` -- ${$}`; - } - L += F; - } - return `${N} -${L}`; -} -const kne = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/, $ne = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/, Fne = /^localhost(:[0-9]{1,5})?$/, Bne = /^[a-zA-Z0-9]{8,}$/, Une = /^([a-zA-Z][a-zA-Z0-9+-.]*)$/, $9 = "7a4434fefbcc9af474fb5c995e47d286", jne = { - projectId: $9, - metadata: { - name: "codatta", - description: "codatta", - url: "https://codatta.io/", - icons: ["https://avatars.githubusercontent.com/u/171659315"] - } -}, qne = { - namespaces: { - eip155: { - methods: [ - "eth_sendTransaction", - "eth_signTransaction", - "eth_sign", - "personal_sign", - "eth_signTypedData" - ], - chains: ["eip155:1"], - events: ["chainChanged", "accountsChanged", "disconnect"], - rpcMap: { - 1: `https://rpc.walletconnect.com?chainId=eip155:1&projectId=${$9}` - } - } - }, - skipPairing: !1 -}; -function zne(t, e) { - const r = window.location.host, n = window.location.href; - return k9({ - address: t, - chainId: 1, - domain: r, - nonce: e, - uri: n, - version: "1" - }); -} -function Hne(t) { - var pe, Ee, Y; - const e = bi(null), { wallet: r, onGetExtension: n, onSignFinish: i } = t, [s, o] = fr(""), [a, u] = fr(!1), [l, d] = fr(""), [g, w] = fr("scan"), A = bi(), [M, N] = fr((pe = r.config) == null ? void 0 : pe.image), [L, F] = fr(!1), { saveLastUsedWallet: $ } = gp(); - async function K(S) { - var f, p, b, x; - u(!0); - const m = await CG.init(jne); - m.session && await m.disconnect(); - try { - if (w("scan"), m.on("display_uri", (ce) => { - console.log("display_uri", ce), o(ce), u(!1), w("scan"); - }), m.on("error", (ce) => { - console.log(ce); - }), m.on("session_update", (ce) => { - console.log("session_update", ce); - }), !await m.connect(qne)) throw new Error("Walletconnect init failed"); - const E = new ml(m); - N(((f = E.config) == null ? void 0 : f.image) || ((p = S.config) == null ? void 0 : p.image)); - const v = await E.getAddress(), P = await ya.getNonce({ account_type: "block_chain" }); - console.log("get nonce", P); - const I = zne(v, P); - w("sign"); - const B = await E.signMessage(I, v); - w("waiting"), await i(E, { - message: I, - nonce: P, - signature: B, - address: v, - wallet_name: ((b = E.config) == null ? void 0 : b.name) || ((x = S.config) == null ? void 0 : x.name) || "" - }), $(E); - } catch (_) { - console.log("err", _), d(_.details || _.message); - } - } - function H() { - A.current = new L9({ - width: 264, - height: 264, - margin: 0, - type: "svg", - // image: wallet.config?.image, - qrOptions: { - errorCorrectionLevel: "M" - }, - dotsOptions: { - color: "black", - type: "rounded" - }, - backgroundOptions: { - color: "transparent" - } - }), A.current.append(e.current); - } - function V(S) { - var m; - console.log(A.current), (m = A.current) == null || m.update({ - data: S - }); - } - Xn(() => { - s && V(s); - }, [s]), Xn(() => { - K(r); - }, [r]), Xn(() => { - H(); - }, []); - function te() { - d(""), V(""), K(r); - } - function R() { - F(!0), navigator.clipboard.writeText(s), setTimeout(() => { - F(!1); - }, 2500); - } - function W() { - var f; - const S = (f = r.config) == null ? void 0 : f.desktop_link; - if (!S) return; - const m = `${S}?uri=${encodeURIComponent(s)}`; - window.open(m, "_blank"); - } - return /* @__PURE__ */ me.jsxs("div", { children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-text-center", children: /* @__PURE__ */ me.jsxs("div", { className: "xc-relative xc-mx-auto xc-mb-6 xc-block xc-max-h-[272px] xc-max-w-[272px] xc-rounded-xl xc-bg-white xc-p-1", children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-aspect-[1/1] xc-flex xc-h-full xc-w-full xc-justify-center", ref: e }), - /* @__PURE__ */ me.jsx("div", { className: "xc-absolute xc-left-0 xc-top-0 xc-flex xc-h-full xc-w-full xc-items-center xc-justify-center", children: a ? /* @__PURE__ */ me.jsx(gc, { className: "xc-h-6 xc-w-6 xc-animate-spin xc-text-black", size: 20 }) : /* @__PURE__ */ me.jsx("img", { className: "xc-h-10 xc-w-10", src: M }) }) - ] }) }), - /* @__PURE__ */ me.jsxs("div", { className: "xc-m-auto xc-mb-6 xc-flex xc-max-w-[400px] xc-flex-wrap xc-items-center xc-justify-between xc-gap-3", children: [ - /* @__PURE__ */ me.jsx( - "button", - { - disabled: !s, - onClick: R, - className: "xc-disabled:hover-text-white xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black xc-disabled:cursor-not-allowed xc-disabled:opacity-40 xc-disabled:hover:bg-transparent", - children: L ? /* @__PURE__ */ me.jsxs(me.Fragment, { children: [ - " ", - /* @__PURE__ */ me.jsx(rZ, {}), - " Copied!" - ] }) : /* @__PURE__ */ me.jsxs(me.Fragment, { children: [ - /* @__PURE__ */ me.jsx(sZ, {}), - "Copy QR URL" - ] }) - } - ), - ((Ee = r.config) == null ? void 0 : Ee.getWallet) && /* @__PURE__ */ me.jsxs( - "button", - { - className: "xc-rounded-2 xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black", - onClick: n, - children: [ - /* @__PURE__ */ me.jsx(nZ, {}), - "Get Extension" - ] - } - ), - ((Y = r.config) == null ? void 0 : Y.desktop_link) && /* @__PURE__ */ me.jsxs( - "button", - { - disabled: !s, - className: "xc-rounded-2 xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black", - onClick: W, - children: [ - /* @__PURE__ */ me.jsx(HS, {}), - "Desktop" - ] - } - ) - ] }), - /* @__PURE__ */ me.jsx("div", { className: "xc-text-center", children: l ? /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center", children: [ - /* @__PURE__ */ me.jsx("p", { className: "xc-text-danger xc-mb-2 xc-text-center", children: l }), - /* @__PURE__ */ me.jsx("button", { className: "xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1", onClick: te, children: "Retry" }) - ] }) : /* @__PURE__ */ me.jsxs(me.Fragment, { children: [ - g === "scan" && /* @__PURE__ */ me.jsx("p", { children: "Scan this QR code from your mobile wallet or phone's camera to connect." }), - g === "connect" && /* @__PURE__ */ me.jsx("p", { children: "Click connect in your wallet app" }), - g === "sign" && /* @__PURE__ */ me.jsx("p", { children: "Click sign-in in your wallet to confirm you own this wallet." }), - g === "waiting" && /* @__PURE__ */ me.jsx("div", { className: "xc-text-center", children: /* @__PURE__ */ me.jsx(gc, { className: "xc-inline-block xc-animate-spin" }) }) - ] }) }) - ] }); -} -const Wne = "Accept connection request in the wallet", Kne = "Accept sign-in request in your wallet"; -function Vne(t, e) { - const r = window.location.host, n = window.location.href; - return k9({ - address: t, - chainId: 1, - domain: r, - nonce: e, - uri: n, - version: "1" - }); -} -function Gne(t) { - var g; - const [e, r] = fr(), { wallet: n, onSignFinish: i } = t, s = bi(), [o, a] = fr("connect"), { saveLastUsedWallet: u } = gp(); - async function l(w) { - var A; - try { - a("connect"); - const M = await n.connect(); - if (!M || M.length === 0) - throw new Error("Wallet connect error"); - const N = Vne(M[0], w); - a("sign"); - const L = await n.signMessage(N, M[0]); - if (!L || L.length === 0) - throw new Error("user sign error"); - a("waiting"), await i(n, { address: M[0], signature: L, message: N, nonce: w, wallet_name: ((A = n.config) == null ? void 0 : A.name) || "" }), u(n); - } catch (M) { - console.log(M.details), r(M.details || M.message); - } - } - async function d() { - try { - r(""); - const w = await ya.getNonce({ account_type: "block_chain" }); - s.current = w, l(s.current); - } catch (w) { - console.log(w.details), r(w.message); - } - } - return Xn(() => { - d(); - }, []), /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center xc-justify-center xc-gap-4", children: [ - /* @__PURE__ */ me.jsx("img", { className: "xc-rounded-md xc-h-16 xc-w-16", src: (g = n.config) == null ? void 0 : g.image, alt: "" }), - e && /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center", children: [ - /* @__PURE__ */ me.jsx("p", { className: "xc-text-danger xc-mb-2 xc-text-center", children: e }), - /* @__PURE__ */ me.jsx("div", { className: "xc-flex xc-gap-2", children: /* @__PURE__ */ me.jsx("button", { className: "xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1", onClick: d, children: "Retry" }) }) - ] }), - !e && /* @__PURE__ */ me.jsxs(me.Fragment, { children: [ - o === "connect" && /* @__PURE__ */ me.jsx("span", { className: "xc-text-center", children: Wne }), - o === "sign" && /* @__PURE__ */ me.jsx("span", { className: "xc-text-center", children: Kne }), - o === "waiting" && /* @__PURE__ */ me.jsx("span", { className: "xc-text-center", children: /* @__PURE__ */ me.jsx(gc, { className: "xc-animate-spin" }) }) - ] }) - ] }); -} -const Vc = "https://static.codatta.io/codatta-connect/wallet-icons.svg", Yne = "https://itunes.apple.com/app/", Jne = "https://play.google.com/store/apps/details?id=", Xne = "https://chromewebstore.google.com/detail/", Zne = "https://chromewebstore.google.com/detail/", Qne = "https://addons.mozilla.org/en-US/firefox/addon/", eie = "https://microsoftedge.microsoft.com/addons/detail/"; -function Gc(t) { - const { icon: e, title: r, link: n } = t; - return /* @__PURE__ */ me.jsxs( - "a", - { - href: n, - target: "_blank", - className: "xc-flex xc-w-full xc-cursor-pointer xc-items-center xc-gap-2 xc-rounded-full xc-border xc-border-white xc-border-opacity-15 xc-px-6 xc-py-3 xc-transition-all xc-hover:bg-white xc-hover:bg-opacity-5", - children: [ - /* @__PURE__ */ me.jsx("img", { className: "xc-rounded-1 xc-h-6 xc-w-6", src: e, alt: "" }), - r, - /* @__PURE__ */ me.jsx(zS, { className: "xc-ml-auto xc-text-gray-400" }) - ] - } - ); -} -function tie(t) { - const e = { - appStoreLink: "", - playStoreLink: "", - chromeStoreLink: "", - braveStoreLink: "", - firefoxStoreLink: "", - edgeStoreLink: "" - }; - return t != null && t.app_store_id && (e.appStoreLink = `${Yne}${t.app_store_id}`), t != null && t.play_store_id && (e.playStoreLink = `${Jne}${t.play_store_id}`), t != null && t.chrome_store_id && (e.chromeStoreLink = `${Xne}${t.chrome_store_id}`), t != null && t.brave_store_id && (e.braveStoreLink = `${Zne}${t.brave_store_id}`), t != null && t.firefox_addon_id && (e.firefoxStoreLink = `${Qne}${t.firefox_addon_id}`), t != null && t.edge_addon_id && (e.edgeStoreLink = `${eie}${t.edge_addon_id}`), e; -} -function rie(t) { - var i, s, o; - const { wallet: e } = t, r = (i = e.config) == null ? void 0 : i.getWallet, n = tie(r); - return /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center", children: [ - /* @__PURE__ */ me.jsx("img", { className: "xc-rounded-md xc-mb-2 xc-h-12 xc-w-12", src: (s = e.config) == null ? void 0 : s.image, alt: "" }), - /* @__PURE__ */ me.jsxs("p", { className: "xc-text-lg xc-font-bold", children: [ - "Install ", - (o = e.config) == null ? void 0 : o.name, - " to connect" - ] }), - /* @__PURE__ */ me.jsx("p", { className: "xc-mb-6 xc-text-sm xc-text-gray-500", children: "Select from your preferred options below:" }), - /* @__PURE__ */ me.jsxs("div", { className: "xc-grid xc-w-full xc-grid-cols-1 xc-gap-3", children: [ - (r == null ? void 0 : r.chrome_store_id) && /* @__PURE__ */ me.jsx( - Gc, - { - link: n.chromeStoreLink, - icon: `${Vc}#chrome`, - title: "Google Play Store" - } - ), - (r == null ? void 0 : r.app_store_id) && /* @__PURE__ */ me.jsx( - Gc, - { - link: n.appStoreLink, - icon: `${Vc}#apple-dark`, - title: "Apple App Store" - } - ), - (r == null ? void 0 : r.play_store_id) && /* @__PURE__ */ me.jsx( - Gc, - { - link: n.playStoreLink, - icon: `${Vc}#android`, - title: "Google Play Store" - } - ), - (r == null ? void 0 : r.edge_addon_id) && /* @__PURE__ */ me.jsx( - Gc, - { - link: n.edgeStoreLink, - icon: `${Vc}#edge`, - title: "Microsoft Edge" - } - ), - (r == null ? void 0 : r.brave_store_id) && /* @__PURE__ */ me.jsx( - Gc, - { - link: n.braveStoreLink, - icon: `${Vc}#brave`, - title: "Brave extension" - } - ), - (r == null ? void 0 : r.firefox_addon_id) && /* @__PURE__ */ me.jsx( - Gc, - { - link: n.firefoxStoreLink, - icon: `${Vc}#firefox`, - title: "Mozilla Firefox" - } - ) - ] }) - ] }); -} -function nie(t) { - const { wallet: e } = t, [r, n] = fr(e.installed ? "connect" : "qr"), i = ay(); - async function s(o, a) { - var l; - const u = await ya.walletLogin({ - account_type: "block_chain", - account_enum: "C", - connector: "codatta_wallet", - inviter_code: i.inviterCode, - wallet_name: ((l = o.config) == null ? void 0 : l.name) || o.key, - address: await o.getAddress(), - chain: (await o.getChain()).toString(), - nonce: a.nonce, - signature: a.signature, - message: a.message, - source: { - device: i.device, - channel: i.channel, - app: i.app - } - }); - await t.onLogin(u.data); - } - return /* @__PURE__ */ me.jsxs(Ac, { children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-mb-6", children: /* @__PURE__ */ me.jsx(uh, { title: "Connect wallet", onBack: t.onBack }) }), - r === "qr" && /* @__PURE__ */ me.jsx( - Hne, - { - wallet: e, - onGetExtension: () => n("get-extension"), - onSignFinish: s - } - ), - r === "connect" && /* @__PURE__ */ me.jsx( - Gne, - { - onShowQrCode: () => n("qr"), - wallet: e, - onSignFinish: s - } - ), - r === "get-extension" && /* @__PURE__ */ me.jsx(rie, { wallet: e }) - ] }); -} -function iie(t) { - const { wallet: e, onClick: r } = t, n = /* @__PURE__ */ me.jsx("img", { className: "xc-rounded-md xc-h-5 xc-w-5", src: e.imageUrl }), i = e.name || ""; - return /* @__PURE__ */ me.jsx(sy, { icon: n, title: i, onClick: () => r(e) }); -} -function sie(t) { - const { connector: e } = t, [r, n] = fr(), [i, s] = fr([]), o = Oi(() => r ? i.filter((d) => d.name.toLowerCase().includes(r.toLowerCase())) : i, [r, i]); - function a(d) { - n(d.target.value); - } - async function u() { - const d = await e.getWallets(); - s(d), console.log(d); - } - Xn(() => { - u(); - }, []); - function l(d) { - t.onSelect(d); - } - return /* @__PURE__ */ me.jsxs(Ac, { children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-mb-6", children: /* @__PURE__ */ me.jsx(uh, { title: "Select wallet", onBack: t.onBack }) }), - /* @__PURE__ */ me.jsxs("div", { className: "xc-mb-6 xc-flex xc-gap-3 xc-px-4 xc-py-2 xc-border xc-rounded-xl xc-w-full xc-overflow-hidden xc-items-center xc-border-opacity-15 xc-border-white focus-within:xc-border-opacity-40", children: [ - /* @__PURE__ */ me.jsx(WS, { className: "xc-shrink-0 xc-opacity-50" }), - /* @__PURE__ */ me.jsx("input", { type: "text", className: "xc-flex-1 xc-bg-transparent xc-appearance-none xc-outline-none", placeholder: "Search wallet", onInput: a }) - ] }), - /* @__PURE__ */ me.jsx("div", { className: "xc-mb-4 xc-flex xc-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar", children: o == null ? void 0 : o.map((d) => /* @__PURE__ */ me.jsx(iie, { wallet: d, onClick: l }, d.name)) }) - ] }); -} -var F9 = { exports: {} }; -(function(t) { - (function(e, r) { - t.exports ? t.exports = r() : (e.nacl || (e.nacl = {}), e.nacl.util = r()); - })(gn, function() { - var e = {}; - function r(n) { - if (!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(n)) - throw new TypeError("invalid encoding"); - } - return e.decodeUTF8 = function(n) { - if (typeof n != "string") throw new TypeError("expected string"); - var i, s = unescape(encodeURIComponent(n)), o = new Uint8Array(s.length); - for (i = 0; i < s.length; i++) o[i] = s.charCodeAt(i); - return o; - }, e.encodeUTF8 = function(n) { - var i, s = []; - for (i = 0; i < n.length; i++) s.push(String.fromCharCode(n[i])); - return decodeURIComponent(escape(s.join(""))); - }, typeof atob > "u" ? typeof Buffer.from < "u" ? (e.encodeBase64 = function(n) { - return Buffer.from(n).toString("base64"); - }, e.decodeBase64 = function(n) { - return r(n), new Uint8Array(Array.prototype.slice.call(Buffer.from(n, "base64"), 0)); - }) : (e.encodeBase64 = function(n) { - return new Buffer(n).toString("base64"); - }, e.decodeBase64 = function(n) { - return r(n), new Uint8Array(Array.prototype.slice.call(new Buffer(n, "base64"), 0)); - }) : (e.encodeBase64 = function(n) { - var i, s = [], o = n.length; - for (i = 0; i < o; i++) s.push(String.fromCharCode(n[i])); - return btoa(s.join("")); - }, e.decodeBase64 = function(n) { - r(n); - var i, s = atob(n), o = new Uint8Array(s.length); - for (i = 0; i < s.length; i++) o[i] = s.charCodeAt(i); - return o; - }), e; - }); -})(F9); -var oie = F9.exports; -const Rl = /* @__PURE__ */ ts(oie); -var B9 = { exports: {} }; -(function(t) { - (function(e) { - var r = function(k) { - var j, z = new Float64Array(16); - if (k) for (j = 0; j < k.length; j++) z[j] = k[j]; - return z; - }, n = function() { - throw new Error("no PRNG"); - }, i = new Uint8Array(16), s = new Uint8Array(32); - s[0] = 9; - var o = r(), a = r([1]), u = r([56129, 1]), l = r([30883, 4953, 19914, 30187, 55467, 16705, 2637, 112, 59544, 30585, 16505, 36039, 65139, 11119, 27886, 20995]), d = r([61785, 9906, 39828, 60374, 45398, 33411, 5274, 224, 53552, 61171, 33010, 6542, 64743, 22239, 55772, 9222]), g = r([54554, 36645, 11616, 51542, 42930, 38181, 51040, 26924, 56412, 64982, 57905, 49316, 21502, 52590, 14035, 8553]), w = r([26200, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214]), A = r([41136, 18958, 6951, 50414, 58488, 44335, 6150, 12099, 55207, 15867, 153, 11085, 57099, 20417, 9344, 11139]); - function M(k, j, z, C) { - k[j] = z >> 24 & 255, k[j + 1] = z >> 16 & 255, k[j + 2] = z >> 8 & 255, k[j + 3] = z & 255, k[j + 4] = C >> 24 & 255, k[j + 5] = C >> 16 & 255, k[j + 6] = C >> 8 & 255, k[j + 7] = C & 255; - } - function N(k, j, z, C, G) { - var U, se = 0; - for (U = 0; U < G; U++) se |= k[j + U] ^ z[C + U]; - return (1 & se - 1 >>> 8) - 1; - } - function L(k, j, z, C) { - return N(k, j, z, C, 16); - } - function F(k, j, z, C) { - return N(k, j, z, C, 32); - } - function $(k, j, z, C) { - for (var G = C[0] & 255 | (C[1] & 255) << 8 | (C[2] & 255) << 16 | (C[3] & 255) << 24, U = z[0] & 255 | (z[1] & 255) << 8 | (z[2] & 255) << 16 | (z[3] & 255) << 24, se = z[4] & 255 | (z[5] & 255) << 8 | (z[6] & 255) << 16 | (z[7] & 255) << 24, he = z[8] & 255 | (z[9] & 255) << 8 | (z[10] & 255) << 16 | (z[11] & 255) << 24, xe = z[12] & 255 | (z[13] & 255) << 8 | (z[14] & 255) << 16 | (z[15] & 255) << 24, Te = C[4] & 255 | (C[5] & 255) << 8 | (C[6] & 255) << 16 | (C[7] & 255) << 24, Re = j[0] & 255 | (j[1] & 255) << 8 | (j[2] & 255) << 16 | (j[3] & 255) << 24, nt = j[4] & 255 | (j[5] & 255) << 8 | (j[6] & 255) << 16 | (j[7] & 255) << 24, Ue = j[8] & 255 | (j[9] & 255) << 8 | (j[10] & 255) << 16 | (j[11] & 255) << 24, pt = j[12] & 255 | (j[13] & 255) << 8 | (j[14] & 255) << 16 | (j[15] & 255) << 24, it = C[8] & 255 | (C[9] & 255) << 8 | (C[10] & 255) << 16 | (C[11] & 255) << 24, et = z[16] & 255 | (z[17] & 255) << 8 | (z[18] & 255) << 16 | (z[19] & 255) << 24, St = z[20] & 255 | (z[21] & 255) << 8 | (z[22] & 255) << 16 | (z[23] & 255) << 24, Tt = z[24] & 255 | (z[25] & 255) << 8 | (z[26] & 255) << 16 | (z[27] & 255) << 24, At = z[28] & 255 | (z[29] & 255) << 8 | (z[30] & 255) << 16 | (z[31] & 255) << 24, _t = C[12] & 255 | (C[13] & 255) << 8 | (C[14] & 255) << 16 | (C[15] & 255) << 24, ht = G, xt = U, st = se, bt = he, ut = xe, ot = Te, Se = Re, Ae = nt, Ve = Ue, Be = pt, je = it, Je = et, Lt = St, zt = Tt, Xt = At, Ht = _t, le, tr = 0; tr < 20; tr += 2) - le = ht + Lt | 0, ut ^= le << 7 | le >>> 25, le = ut + ht | 0, Ve ^= le << 9 | le >>> 23, le = Ve + ut | 0, Lt ^= le << 13 | le >>> 19, le = Lt + Ve | 0, ht ^= le << 18 | le >>> 14, le = ot + xt | 0, Be ^= le << 7 | le >>> 25, le = Be + ot | 0, zt ^= le << 9 | le >>> 23, le = zt + Be | 0, xt ^= le << 13 | le >>> 19, le = xt + zt | 0, ot ^= le << 18 | le >>> 14, le = je + Se | 0, Xt ^= le << 7 | le >>> 25, le = Xt + je | 0, st ^= le << 9 | le >>> 23, le = st + Xt | 0, Se ^= le << 13 | le >>> 19, le = Se + st | 0, je ^= le << 18 | le >>> 14, le = Ht + Je | 0, bt ^= le << 7 | le >>> 25, le = bt + Ht | 0, Ae ^= le << 9 | le >>> 23, le = Ae + bt | 0, Je ^= le << 13 | le >>> 19, le = Je + Ae | 0, Ht ^= le << 18 | le >>> 14, le = ht + bt | 0, xt ^= le << 7 | le >>> 25, le = xt + ht | 0, st ^= le << 9 | le >>> 23, le = st + xt | 0, bt ^= le << 13 | le >>> 19, le = bt + st | 0, ht ^= le << 18 | le >>> 14, le = ot + ut | 0, Se ^= le << 7 | le >>> 25, le = Se + ot | 0, Ae ^= le << 9 | le >>> 23, le = Ae + Se | 0, ut ^= le << 13 | le >>> 19, le = ut + Ae | 0, ot ^= le << 18 | le >>> 14, le = je + Be | 0, Je ^= le << 7 | le >>> 25, le = Je + je | 0, Ve ^= le << 9 | le >>> 23, le = Ve + Je | 0, Be ^= le << 13 | le >>> 19, le = Be + Ve | 0, je ^= le << 18 | le >>> 14, le = Ht + Xt | 0, Lt ^= le << 7 | le >>> 25, le = Lt + Ht | 0, zt ^= le << 9 | le >>> 23, le = zt + Lt | 0, Xt ^= le << 13 | le >>> 19, le = Xt + zt | 0, Ht ^= le << 18 | le >>> 14; - ht = ht + G | 0, xt = xt + U | 0, st = st + se | 0, bt = bt + he | 0, ut = ut + xe | 0, ot = ot + Te | 0, Se = Se + Re | 0, Ae = Ae + nt | 0, Ve = Ve + Ue | 0, Be = Be + pt | 0, je = je + it | 0, Je = Je + et | 0, Lt = Lt + St | 0, zt = zt + Tt | 0, Xt = Xt + At | 0, Ht = Ht + _t | 0, k[0] = ht >>> 0 & 255, k[1] = ht >>> 8 & 255, k[2] = ht >>> 16 & 255, k[3] = ht >>> 24 & 255, k[4] = xt >>> 0 & 255, k[5] = xt >>> 8 & 255, k[6] = xt >>> 16 & 255, k[7] = xt >>> 24 & 255, k[8] = st >>> 0 & 255, k[9] = st >>> 8 & 255, k[10] = st >>> 16 & 255, k[11] = st >>> 24 & 255, k[12] = bt >>> 0 & 255, k[13] = bt >>> 8 & 255, k[14] = bt >>> 16 & 255, k[15] = bt >>> 24 & 255, k[16] = ut >>> 0 & 255, k[17] = ut >>> 8 & 255, k[18] = ut >>> 16 & 255, k[19] = ut >>> 24 & 255, k[20] = ot >>> 0 & 255, k[21] = ot >>> 8 & 255, k[22] = ot >>> 16 & 255, k[23] = ot >>> 24 & 255, k[24] = Se >>> 0 & 255, k[25] = Se >>> 8 & 255, k[26] = Se >>> 16 & 255, k[27] = Se >>> 24 & 255, k[28] = Ae >>> 0 & 255, k[29] = Ae >>> 8 & 255, k[30] = Ae >>> 16 & 255, k[31] = Ae >>> 24 & 255, k[32] = Ve >>> 0 & 255, k[33] = Ve >>> 8 & 255, k[34] = Ve >>> 16 & 255, k[35] = Ve >>> 24 & 255, k[36] = Be >>> 0 & 255, k[37] = Be >>> 8 & 255, k[38] = Be >>> 16 & 255, k[39] = Be >>> 24 & 255, k[40] = je >>> 0 & 255, k[41] = je >>> 8 & 255, k[42] = je >>> 16 & 255, k[43] = je >>> 24 & 255, k[44] = Je >>> 0 & 255, k[45] = Je >>> 8 & 255, k[46] = Je >>> 16 & 255, k[47] = Je >>> 24 & 255, k[48] = Lt >>> 0 & 255, k[49] = Lt >>> 8 & 255, k[50] = Lt >>> 16 & 255, k[51] = Lt >>> 24 & 255, k[52] = zt >>> 0 & 255, k[53] = zt >>> 8 & 255, k[54] = zt >>> 16 & 255, k[55] = zt >>> 24 & 255, k[56] = Xt >>> 0 & 255, k[57] = Xt >>> 8 & 255, k[58] = Xt >>> 16 & 255, k[59] = Xt >>> 24 & 255, k[60] = Ht >>> 0 & 255, k[61] = Ht >>> 8 & 255, k[62] = Ht >>> 16 & 255, k[63] = Ht >>> 24 & 255; - } - function K(k, j, z, C) { - for (var G = C[0] & 255 | (C[1] & 255) << 8 | (C[2] & 255) << 16 | (C[3] & 255) << 24, U = z[0] & 255 | (z[1] & 255) << 8 | (z[2] & 255) << 16 | (z[3] & 255) << 24, se = z[4] & 255 | (z[5] & 255) << 8 | (z[6] & 255) << 16 | (z[7] & 255) << 24, he = z[8] & 255 | (z[9] & 255) << 8 | (z[10] & 255) << 16 | (z[11] & 255) << 24, xe = z[12] & 255 | (z[13] & 255) << 8 | (z[14] & 255) << 16 | (z[15] & 255) << 24, Te = C[4] & 255 | (C[5] & 255) << 8 | (C[6] & 255) << 16 | (C[7] & 255) << 24, Re = j[0] & 255 | (j[1] & 255) << 8 | (j[2] & 255) << 16 | (j[3] & 255) << 24, nt = j[4] & 255 | (j[5] & 255) << 8 | (j[6] & 255) << 16 | (j[7] & 255) << 24, Ue = j[8] & 255 | (j[9] & 255) << 8 | (j[10] & 255) << 16 | (j[11] & 255) << 24, pt = j[12] & 255 | (j[13] & 255) << 8 | (j[14] & 255) << 16 | (j[15] & 255) << 24, it = C[8] & 255 | (C[9] & 255) << 8 | (C[10] & 255) << 16 | (C[11] & 255) << 24, et = z[16] & 255 | (z[17] & 255) << 8 | (z[18] & 255) << 16 | (z[19] & 255) << 24, St = z[20] & 255 | (z[21] & 255) << 8 | (z[22] & 255) << 16 | (z[23] & 255) << 24, Tt = z[24] & 255 | (z[25] & 255) << 8 | (z[26] & 255) << 16 | (z[27] & 255) << 24, At = z[28] & 255 | (z[29] & 255) << 8 | (z[30] & 255) << 16 | (z[31] & 255) << 24, _t = C[12] & 255 | (C[13] & 255) << 8 | (C[14] & 255) << 16 | (C[15] & 255) << 24, ht = G, xt = U, st = se, bt = he, ut = xe, ot = Te, Se = Re, Ae = nt, Ve = Ue, Be = pt, je = it, Je = et, Lt = St, zt = Tt, Xt = At, Ht = _t, le, tr = 0; tr < 20; tr += 2) - le = ht + Lt | 0, ut ^= le << 7 | le >>> 25, le = ut + ht | 0, Ve ^= le << 9 | le >>> 23, le = Ve + ut | 0, Lt ^= le << 13 | le >>> 19, le = Lt + Ve | 0, ht ^= le << 18 | le >>> 14, le = ot + xt | 0, Be ^= le << 7 | le >>> 25, le = Be + ot | 0, zt ^= le << 9 | le >>> 23, le = zt + Be | 0, xt ^= le << 13 | le >>> 19, le = xt + zt | 0, ot ^= le << 18 | le >>> 14, le = je + Se | 0, Xt ^= le << 7 | le >>> 25, le = Xt + je | 0, st ^= le << 9 | le >>> 23, le = st + Xt | 0, Se ^= le << 13 | le >>> 19, le = Se + st | 0, je ^= le << 18 | le >>> 14, le = Ht + Je | 0, bt ^= le << 7 | le >>> 25, le = bt + Ht | 0, Ae ^= le << 9 | le >>> 23, le = Ae + bt | 0, Je ^= le << 13 | le >>> 19, le = Je + Ae | 0, Ht ^= le << 18 | le >>> 14, le = ht + bt | 0, xt ^= le << 7 | le >>> 25, le = xt + ht | 0, st ^= le << 9 | le >>> 23, le = st + xt | 0, bt ^= le << 13 | le >>> 19, le = bt + st | 0, ht ^= le << 18 | le >>> 14, le = ot + ut | 0, Se ^= le << 7 | le >>> 25, le = Se + ot | 0, Ae ^= le << 9 | le >>> 23, le = Ae + Se | 0, ut ^= le << 13 | le >>> 19, le = ut + Ae | 0, ot ^= le << 18 | le >>> 14, le = je + Be | 0, Je ^= le << 7 | le >>> 25, le = Je + je | 0, Ve ^= le << 9 | le >>> 23, le = Ve + Je | 0, Be ^= le << 13 | le >>> 19, le = Be + Ve | 0, je ^= le << 18 | le >>> 14, le = Ht + Xt | 0, Lt ^= le << 7 | le >>> 25, le = Lt + Ht | 0, zt ^= le << 9 | le >>> 23, le = zt + Lt | 0, Xt ^= le << 13 | le >>> 19, le = Xt + zt | 0, Ht ^= le << 18 | le >>> 14; - k[0] = ht >>> 0 & 255, k[1] = ht >>> 8 & 255, k[2] = ht >>> 16 & 255, k[3] = ht >>> 24 & 255, k[4] = ot >>> 0 & 255, k[5] = ot >>> 8 & 255, k[6] = ot >>> 16 & 255, k[7] = ot >>> 24 & 255, k[8] = je >>> 0 & 255, k[9] = je >>> 8 & 255, k[10] = je >>> 16 & 255, k[11] = je >>> 24 & 255, k[12] = Ht >>> 0 & 255, k[13] = Ht >>> 8 & 255, k[14] = Ht >>> 16 & 255, k[15] = Ht >>> 24 & 255, k[16] = Se >>> 0 & 255, k[17] = Se >>> 8 & 255, k[18] = Se >>> 16 & 255, k[19] = Se >>> 24 & 255, k[20] = Ae >>> 0 & 255, k[21] = Ae >>> 8 & 255, k[22] = Ae >>> 16 & 255, k[23] = Ae >>> 24 & 255, k[24] = Ve >>> 0 & 255, k[25] = Ve >>> 8 & 255, k[26] = Ve >>> 16 & 255, k[27] = Ve >>> 24 & 255, k[28] = Be >>> 0 & 255, k[29] = Be >>> 8 & 255, k[30] = Be >>> 16 & 255, k[31] = Be >>> 24 & 255; - } - function H(k, j, z, C) { - $(k, j, z, C); - } - function V(k, j, z, C) { - K(k, j, z, C); - } - var te = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]); - function R(k, j, z, C, G, U, se) { - var he = new Uint8Array(16), xe = new Uint8Array(64), Te, Re; - for (Re = 0; Re < 16; Re++) he[Re] = 0; - for (Re = 0; Re < 8; Re++) he[Re] = U[Re]; - for (; G >= 64; ) { - for (H(xe, he, se, te), Re = 0; Re < 64; Re++) k[j + Re] = z[C + Re] ^ xe[Re]; - for (Te = 1, Re = 8; Re < 16; Re++) - Te = Te + (he[Re] & 255) | 0, he[Re] = Te & 255, Te >>>= 8; - G -= 64, j += 64, C += 64; - } - if (G > 0) - for (H(xe, he, se, te), Re = 0; Re < G; Re++) k[j + Re] = z[C + Re] ^ xe[Re]; - return 0; - } - function W(k, j, z, C, G) { - var U = new Uint8Array(16), se = new Uint8Array(64), he, xe; - for (xe = 0; xe < 16; xe++) U[xe] = 0; - for (xe = 0; xe < 8; xe++) U[xe] = C[xe]; - for (; z >= 64; ) { - for (H(se, U, G, te), xe = 0; xe < 64; xe++) k[j + xe] = se[xe]; - for (he = 1, xe = 8; xe < 16; xe++) - he = he + (U[xe] & 255) | 0, U[xe] = he & 255, he >>>= 8; - z -= 64, j += 64; - } - if (z > 0) - for (H(se, U, G, te), xe = 0; xe < z; xe++) k[j + xe] = se[xe]; - return 0; - } - function pe(k, j, z, C, G) { - var U = new Uint8Array(32); - V(U, C, G, te); - for (var se = new Uint8Array(8), he = 0; he < 8; he++) se[he] = C[he + 16]; - return W(k, j, z, se, U); - } - function Ee(k, j, z, C, G, U, se) { - var he = new Uint8Array(32); - V(he, U, se, te); - for (var xe = new Uint8Array(8), Te = 0; Te < 8; Te++) xe[Te] = U[Te + 16]; - return R(k, j, z, C, G, xe, he); - } - var Y = function(k) { - 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; - var j, z, C, G, U, se, he, xe; - j = k[0] & 255 | (k[1] & 255) << 8, this.r[0] = j & 8191, z = k[2] & 255 | (k[3] & 255) << 8, this.r[1] = (j >>> 13 | z << 3) & 8191, C = k[4] & 255 | (k[5] & 255) << 8, this.r[2] = (z >>> 10 | C << 6) & 7939, G = k[6] & 255 | (k[7] & 255) << 8, this.r[3] = (C >>> 7 | G << 9) & 8191, U = k[8] & 255 | (k[9] & 255) << 8, this.r[4] = (G >>> 4 | U << 12) & 255, this.r[5] = U >>> 1 & 8190, se = k[10] & 255 | (k[11] & 255) << 8, this.r[6] = (U >>> 14 | se << 2) & 8191, he = k[12] & 255 | (k[13] & 255) << 8, this.r[7] = (se >>> 11 | he << 5) & 8065, xe = k[14] & 255 | (k[15] & 255) << 8, this.r[8] = (he >>> 8 | xe << 8) & 8191, this.r[9] = xe >>> 5 & 127, this.pad[0] = k[16] & 255 | (k[17] & 255) << 8, this.pad[1] = k[18] & 255 | (k[19] & 255) << 8, this.pad[2] = k[20] & 255 | (k[21] & 255) << 8, this.pad[3] = k[22] & 255 | (k[23] & 255) << 8, this.pad[4] = k[24] & 255 | (k[25] & 255) << 8, this.pad[5] = k[26] & 255 | (k[27] & 255) << 8, this.pad[6] = k[28] & 255 | (k[29] & 255) << 8, this.pad[7] = k[30] & 255 | (k[31] & 255) << 8; - }; - Y.prototype.blocks = function(k, j, z) { - for (var C = this.fin ? 0 : 2048, G, U, se, he, xe, Te, Re, nt, Ue, pt, it, et, St, Tt, At, _t, ht, xt, st, bt = this.h[0], ut = this.h[1], ot = this.h[2], Se = this.h[3], Ae = this.h[4], Ve = this.h[5], Be = this.h[6], je = this.h[7], Je = this.h[8], Lt = this.h[9], zt = this.r[0], Xt = this.r[1], Ht = this.r[2], le = this.r[3], tr = this.r[4], dr = this.r[5], pr = this.r[6], Zt = this.r[7], gr = this.r[8], lr = this.r[9]; z >= 16; ) - G = k[j + 0] & 255 | (k[j + 1] & 255) << 8, bt += G & 8191, U = k[j + 2] & 255 | (k[j + 3] & 255) << 8, ut += (G >>> 13 | U << 3) & 8191, se = k[j + 4] & 255 | (k[j + 5] & 255) << 8, ot += (U >>> 10 | se << 6) & 8191, he = k[j + 6] & 255 | (k[j + 7] & 255) << 8, Se += (se >>> 7 | he << 9) & 8191, xe = k[j + 8] & 255 | (k[j + 9] & 255) << 8, Ae += (he >>> 4 | xe << 12) & 8191, Ve += xe >>> 1 & 8191, Te = k[j + 10] & 255 | (k[j + 11] & 255) << 8, Be += (xe >>> 14 | Te << 2) & 8191, Re = k[j + 12] & 255 | (k[j + 13] & 255) << 8, je += (Te >>> 11 | Re << 5) & 8191, nt = k[j + 14] & 255 | (k[j + 15] & 255) << 8, Je += (Re >>> 8 | nt << 8) & 8191, Lt += nt >>> 5 | C, Ue = 0, pt = Ue, pt += bt * zt, pt += ut * (5 * lr), pt += ot * (5 * gr), pt += Se * (5 * Zt), pt += Ae * (5 * pr), Ue = pt >>> 13, pt &= 8191, pt += Ve * (5 * dr), pt += Be * (5 * tr), pt += je * (5 * le), pt += Je * (5 * Ht), pt += Lt * (5 * Xt), Ue += pt >>> 13, pt &= 8191, it = Ue, it += bt * Xt, it += ut * zt, it += ot * (5 * lr), it += Se * (5 * gr), it += Ae * (5 * Zt), Ue = it >>> 13, it &= 8191, it += Ve * (5 * pr), it += Be * (5 * dr), it += je * (5 * tr), it += Je * (5 * le), it += Lt * (5 * Ht), Ue += it >>> 13, it &= 8191, et = Ue, et += bt * Ht, et += ut * Xt, et += ot * zt, et += Se * (5 * lr), et += Ae * (5 * gr), Ue = et >>> 13, et &= 8191, et += Ve * (5 * Zt), et += Be * (5 * pr), et += je * (5 * dr), et += Je * (5 * tr), et += Lt * (5 * le), Ue += et >>> 13, et &= 8191, St = Ue, St += bt * le, St += ut * Ht, St += ot * Xt, St += Se * zt, St += Ae * (5 * lr), Ue = St >>> 13, St &= 8191, St += Ve * (5 * gr), St += Be * (5 * Zt), St += je * (5 * pr), St += Je * (5 * dr), St += Lt * (5 * tr), Ue += St >>> 13, St &= 8191, Tt = Ue, Tt += bt * tr, Tt += ut * le, Tt += ot * Ht, Tt += Se * Xt, Tt += Ae * zt, Ue = Tt >>> 13, Tt &= 8191, Tt += Ve * (5 * lr), Tt += Be * (5 * gr), Tt += je * (5 * Zt), Tt += Je * (5 * pr), Tt += Lt * (5 * dr), Ue += Tt >>> 13, Tt &= 8191, At = Ue, At += bt * dr, At += ut * tr, At += ot * le, At += Se * Ht, At += Ae * Xt, Ue = At >>> 13, At &= 8191, At += Ve * zt, At += Be * (5 * lr), At += je * (5 * gr), At += Je * (5 * Zt), At += Lt * (5 * pr), Ue += At >>> 13, At &= 8191, _t = Ue, _t += bt * pr, _t += ut * dr, _t += ot * tr, _t += Se * le, _t += Ae * Ht, Ue = _t >>> 13, _t &= 8191, _t += Ve * Xt, _t += Be * zt, _t += je * (5 * lr), _t += Je * (5 * gr), _t += Lt * (5 * Zt), Ue += _t >>> 13, _t &= 8191, ht = Ue, ht += bt * Zt, ht += ut * pr, ht += ot * dr, ht += Se * tr, ht += Ae * le, Ue = ht >>> 13, ht &= 8191, ht += Ve * Ht, ht += Be * Xt, ht += je * zt, ht += Je * (5 * lr), ht += Lt * (5 * gr), Ue += ht >>> 13, ht &= 8191, xt = Ue, xt += bt * gr, xt += ut * Zt, xt += ot * pr, xt += Se * dr, xt += Ae * tr, Ue = xt >>> 13, xt &= 8191, xt += Ve * le, xt += Be * Ht, xt += je * Xt, xt += Je * zt, xt += Lt * (5 * lr), Ue += xt >>> 13, xt &= 8191, st = Ue, st += bt * lr, st += ut * gr, st += ot * Zt, st += Se * pr, st += Ae * dr, Ue = st >>> 13, st &= 8191, st += Ve * tr, st += Be * le, st += je * Ht, st += Je * Xt, st += Lt * zt, Ue += st >>> 13, st &= 8191, Ue = (Ue << 2) + Ue | 0, Ue = Ue + pt | 0, pt = Ue & 8191, Ue = Ue >>> 13, it += Ue, bt = pt, ut = it, ot = et, Se = St, Ae = Tt, Ve = At, Be = _t, je = ht, Je = xt, Lt = st, j += 16, z -= 16; - this.h[0] = bt, this.h[1] = ut, this.h[2] = ot, this.h[3] = Se, this.h[4] = Ae, this.h[5] = Ve, this.h[6] = Be, this.h[7] = je, this.h[8] = Je, this.h[9] = Lt; - }, Y.prototype.finish = function(k, j) { - var z = new Uint16Array(10), C, G, U, se; - if (this.leftover) { - for (se = this.leftover, this.buffer[se++] = 1; se < 16; se++) this.buffer[se] = 0; - this.fin = 1, this.blocks(this.buffer, 0, 16); - } - for (C = this.h[1] >>> 13, this.h[1] &= 8191, se = 2; se < 10; se++) - this.h[se] += C, C = this.h[se] >>> 13, this.h[se] &= 8191; - for (this.h[0] += C * 5, C = this.h[0] >>> 13, this.h[0] &= 8191, this.h[1] += C, C = this.h[1] >>> 13, this.h[1] &= 8191, this.h[2] += C, z[0] = this.h[0] + 5, C = z[0] >>> 13, z[0] &= 8191, se = 1; se < 10; se++) - z[se] = this.h[se] + C, C = z[se] >>> 13, z[se] &= 8191; - for (z[9] -= 8192, G = (C ^ 1) - 1, se = 0; se < 10; se++) z[se] &= G; - for (G = ~G, se = 0; se < 10; se++) this.h[se] = this.h[se] & G | z[se]; - 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, U = this.h[0] + this.pad[0], this.h[0] = U & 65535, se = 1; se < 8; se++) - U = (this.h[se] + this.pad[se] | 0) + (U >>> 16) | 0, this.h[se] = U & 65535; - k[j + 0] = this.h[0] >>> 0 & 255, k[j + 1] = this.h[0] >>> 8 & 255, k[j + 2] = this.h[1] >>> 0 & 255, k[j + 3] = this.h[1] >>> 8 & 255, k[j + 4] = this.h[2] >>> 0 & 255, k[j + 5] = this.h[2] >>> 8 & 255, k[j + 6] = this.h[3] >>> 0 & 255, k[j + 7] = this.h[3] >>> 8 & 255, k[j + 8] = this.h[4] >>> 0 & 255, k[j + 9] = this.h[4] >>> 8 & 255, k[j + 10] = this.h[5] >>> 0 & 255, k[j + 11] = this.h[5] >>> 8 & 255, k[j + 12] = this.h[6] >>> 0 & 255, k[j + 13] = this.h[6] >>> 8 & 255, k[j + 14] = this.h[7] >>> 0 & 255, k[j + 15] = this.h[7] >>> 8 & 255; - }, Y.prototype.update = function(k, j, z) { - var C, G; - if (this.leftover) { - for (G = 16 - this.leftover, G > z && (G = z), C = 0; C < G; C++) - this.buffer[this.leftover + C] = k[j + C]; - if (z -= G, j += G, this.leftover += G, this.leftover < 16) - return; - this.blocks(this.buffer, 0, 16), this.leftover = 0; - } - if (z >= 16 && (G = z - z % 16, this.blocks(k, j, G), j += G, z -= G), z) { - for (C = 0; C < z; C++) - this.buffer[this.leftover + C] = k[j + C]; - this.leftover += z; - } - }; - function S(k, j, z, C, G, U) { - var se = new Y(U); - return se.update(z, C, G), se.finish(k, j), 0; - } - function m(k, j, z, C, G, U) { - var se = new Uint8Array(16); - return S(se, 0, z, C, G, U), L(k, j, se, 0); - } - function f(k, j, z, C, G) { - var U; - if (z < 32) return -1; - for (Ee(k, 0, j, 0, z, C, G), S(k, 16, k, 32, z - 32, k), U = 0; U < 16; U++) k[U] = 0; - return 0; - } - function p(k, j, z, C, G) { - var U, se = new Uint8Array(32); - if (z < 32 || (pe(se, 0, 32, C, G), m(j, 16, j, 32, z - 32, se) !== 0)) return -1; - for (Ee(k, 0, j, 0, z, C, G), U = 0; U < 32; U++) k[U] = 0; - return 0; - } - function b(k, j) { - var z; - for (z = 0; z < 16; z++) k[z] = j[z] | 0; - } - function x(k) { - var j, z, C = 1; - for (j = 0; j < 16; j++) - z = k[j] + C + 65535, C = Math.floor(z / 65536), k[j] = z - C * 65536; - k[0] += C - 1 + 37 * (C - 1); - } - function _(k, j, z) { - for (var C, G = ~(z - 1), U = 0; U < 16; U++) - C = G & (k[U] ^ j[U]), k[U] ^= C, j[U] ^= C; - } - function E(k, j) { - var z, C, G, U = r(), se = r(); - for (z = 0; z < 16; z++) se[z] = j[z]; - for (x(se), x(se), x(se), C = 0; C < 2; C++) { - for (U[0] = se[0] - 65517, z = 1; z < 15; z++) - U[z] = se[z] - 65535 - (U[z - 1] >> 16 & 1), U[z - 1] &= 65535; - U[15] = se[15] - 32767 - (U[14] >> 16 & 1), G = U[15] >> 16 & 1, U[14] &= 65535, _(se, U, 1 - G); - } - for (z = 0; z < 16; z++) - k[2 * z] = se[z] & 255, k[2 * z + 1] = se[z] >> 8; - } - function v(k, j) { - var z = new Uint8Array(32), C = new Uint8Array(32); - return E(z, k), E(C, j), F(z, 0, C, 0); - } - function P(k) { - var j = new Uint8Array(32); - return E(j, k), j[0] & 1; - } - function I(k, j) { - var z; - for (z = 0; z < 16; z++) k[z] = j[2 * z] + (j[2 * z + 1] << 8); - k[15] &= 32767; - } - function B(k, j, z) { - for (var C = 0; C < 16; C++) k[C] = j[C] + z[C]; - } - function ce(k, j, z) { - for (var C = 0; C < 16; C++) k[C] = j[C] - z[C]; - } - function D(k, j, z) { - var C, G, U = 0, se = 0, he = 0, xe = 0, Te = 0, Re = 0, nt = 0, Ue = 0, pt = 0, it = 0, et = 0, St = 0, Tt = 0, At = 0, _t = 0, ht = 0, xt = 0, st = 0, bt = 0, ut = 0, ot = 0, Se = 0, Ae = 0, Ve = 0, Be = 0, je = 0, Je = 0, Lt = 0, zt = 0, Xt = 0, Ht = 0, le = z[0], tr = z[1], dr = z[2], pr = z[3], Zt = z[4], gr = z[5], lr = z[6], Rr = z[7], mr = z[8], yr = z[9], $r = z[10], Fr = z[11], Ir = z[12], nn = z[13], sn = z[14], on = z[15]; - C = j[0], U += C * le, se += C * tr, he += C * dr, xe += C * pr, Te += C * Zt, Re += C * gr, nt += C * lr, Ue += C * Rr, pt += C * mr, it += C * yr, et += C * $r, St += C * Fr, Tt += C * Ir, At += C * nn, _t += C * sn, ht += C * on, C = j[1], se += C * le, he += C * tr, xe += C * dr, Te += C * pr, Re += C * Zt, nt += C * gr, Ue += C * lr, pt += C * Rr, it += C * mr, et += C * yr, St += C * $r, Tt += C * Fr, At += C * Ir, _t += C * nn, ht += C * sn, xt += C * on, C = j[2], he += C * le, xe += C * tr, Te += C * dr, Re += C * pr, nt += C * Zt, Ue += C * gr, pt += C * lr, it += C * Rr, et += C * mr, St += C * yr, Tt += C * $r, At += C * Fr, _t += C * Ir, ht += C * nn, xt += C * sn, st += C * on, C = j[3], xe += C * le, Te += C * tr, Re += C * dr, nt += C * pr, Ue += C * Zt, pt += C * gr, it += C * lr, et += C * Rr, St += C * mr, Tt += C * yr, At += C * $r, _t += C * Fr, ht += C * Ir, xt += C * nn, st += C * sn, bt += C * on, C = j[4], Te += C * le, Re += C * tr, nt += C * dr, Ue += C * pr, pt += C * Zt, it += C * gr, et += C * lr, St += C * Rr, Tt += C * mr, At += C * yr, _t += C * $r, ht += C * Fr, xt += C * Ir, st += C * nn, bt += C * sn, ut += C * on, C = j[5], Re += C * le, nt += C * tr, Ue += C * dr, pt += C * pr, it += C * Zt, et += C * gr, St += C * lr, Tt += C * Rr, At += C * mr, _t += C * yr, ht += C * $r, xt += C * Fr, st += C * Ir, bt += C * nn, ut += C * sn, ot += C * on, C = j[6], nt += C * le, Ue += C * tr, pt += C * dr, it += C * pr, et += C * Zt, St += C * gr, Tt += C * lr, At += C * Rr, _t += C * mr, ht += C * yr, xt += C * $r, st += C * Fr, bt += C * Ir, ut += C * nn, ot += C * sn, Se += C * on, C = j[7], Ue += C * le, pt += C * tr, it += C * dr, et += C * pr, St += C * Zt, Tt += C * gr, At += C * lr, _t += C * Rr, ht += C * mr, xt += C * yr, st += C * $r, bt += C * Fr, ut += C * Ir, ot += C * nn, Se += C * sn, Ae += C * on, C = j[8], pt += C * le, it += C * tr, et += C * dr, St += C * pr, Tt += C * Zt, At += C * gr, _t += C * lr, ht += C * Rr, xt += C * mr, st += C * yr, bt += C * $r, ut += C * Fr, ot += C * Ir, Se += C * nn, Ae += C * sn, Ve += C * on, C = j[9], it += C * le, et += C * tr, St += C * dr, Tt += C * pr, At += C * Zt, _t += C * gr, ht += C * lr, xt += C * Rr, st += C * mr, bt += C * yr, ut += C * $r, ot += C * Fr, Se += C * Ir, Ae += C * nn, Ve += C * sn, Be += C * on, C = j[10], et += C * le, St += C * tr, Tt += C * dr, At += C * pr, _t += C * Zt, ht += C * gr, xt += C * lr, st += C * Rr, bt += C * mr, ut += C * yr, ot += C * $r, Se += C * Fr, Ae += C * Ir, Ve += C * nn, Be += C * sn, je += C * on, C = j[11], St += C * le, Tt += C * tr, At += C * dr, _t += C * pr, ht += C * Zt, xt += C * gr, st += C * lr, bt += C * Rr, ut += C * mr, ot += C * yr, Se += C * $r, Ae += C * Fr, Ve += C * Ir, Be += C * nn, je += C * sn, Je += C * on, C = j[12], Tt += C * le, At += C * tr, _t += C * dr, ht += C * pr, xt += C * Zt, st += C * gr, bt += C * lr, ut += C * Rr, ot += C * mr, Se += C * yr, Ae += C * $r, Ve += C * Fr, Be += C * Ir, je += C * nn, Je += C * sn, Lt += C * on, C = j[13], At += C * le, _t += C * tr, ht += C * dr, xt += C * pr, st += C * Zt, bt += C * gr, ut += C * lr, ot += C * Rr, Se += C * mr, Ae += C * yr, Ve += C * $r, Be += C * Fr, je += C * Ir, Je += C * nn, Lt += C * sn, zt += C * on, C = j[14], _t += C * le, ht += C * tr, xt += C * dr, st += C * pr, bt += C * Zt, ut += C * gr, ot += C * lr, Se += C * Rr, Ae += C * mr, Ve += C * yr, Be += C * $r, je += C * Fr, Je += C * Ir, Lt += C * nn, zt += C * sn, Xt += C * on, C = j[15], ht += C * le, xt += C * tr, st += C * dr, bt += C * pr, ut += C * Zt, ot += C * gr, Se += C * lr, Ae += C * Rr, Ve += C * mr, Be += C * yr, je += C * $r, Je += C * Fr, Lt += C * Ir, zt += C * nn, Xt += C * sn, Ht += C * on, U += 38 * xt, se += 38 * st, he += 38 * bt, xe += 38 * ut, Te += 38 * ot, Re += 38 * Se, nt += 38 * Ae, Ue += 38 * Ve, pt += 38 * Be, it += 38 * je, et += 38 * Je, St += 38 * Lt, Tt += 38 * zt, At += 38 * Xt, _t += 38 * Ht, G = 1, C = U + G + 65535, G = Math.floor(C / 65536), U = C - G * 65536, C = se + G + 65535, G = Math.floor(C / 65536), se = C - G * 65536, C = he + G + 65535, G = Math.floor(C / 65536), he = C - G * 65536, C = xe + G + 65535, G = Math.floor(C / 65536), xe = C - G * 65536, C = Te + G + 65535, G = Math.floor(C / 65536), Te = C - G * 65536, C = Re + G + 65535, G = Math.floor(C / 65536), Re = C - G * 65536, C = nt + G + 65535, G = Math.floor(C / 65536), nt = C - G * 65536, C = Ue + G + 65535, G = Math.floor(C / 65536), Ue = C - G * 65536, C = pt + G + 65535, G = Math.floor(C / 65536), pt = C - G * 65536, C = it + G + 65535, G = Math.floor(C / 65536), it = C - G * 65536, C = et + G + 65535, G = Math.floor(C / 65536), et = C - G * 65536, C = St + G + 65535, G = Math.floor(C / 65536), St = C - G * 65536, C = Tt + G + 65535, G = Math.floor(C / 65536), Tt = C - G * 65536, C = At + G + 65535, G = Math.floor(C / 65536), At = C - G * 65536, C = _t + G + 65535, G = Math.floor(C / 65536), _t = C - G * 65536, C = ht + G + 65535, G = Math.floor(C / 65536), ht = C - G * 65536, U += G - 1 + 37 * (G - 1), G = 1, C = U + G + 65535, G = Math.floor(C / 65536), U = C - G * 65536, C = se + G + 65535, G = Math.floor(C / 65536), se = C - G * 65536, C = he + G + 65535, G = Math.floor(C / 65536), he = C - G * 65536, C = xe + G + 65535, G = Math.floor(C / 65536), xe = C - G * 65536, C = Te + G + 65535, G = Math.floor(C / 65536), Te = C - G * 65536, C = Re + G + 65535, G = Math.floor(C / 65536), Re = C - G * 65536, C = nt + G + 65535, G = Math.floor(C / 65536), nt = C - G * 65536, C = Ue + G + 65535, G = Math.floor(C / 65536), Ue = C - G * 65536, C = pt + G + 65535, G = Math.floor(C / 65536), pt = C - G * 65536, C = it + G + 65535, G = Math.floor(C / 65536), it = C - G * 65536, C = et + G + 65535, G = Math.floor(C / 65536), et = C - G * 65536, C = St + G + 65535, G = Math.floor(C / 65536), St = C - G * 65536, C = Tt + G + 65535, G = Math.floor(C / 65536), Tt = C - G * 65536, C = At + G + 65535, G = Math.floor(C / 65536), At = C - G * 65536, C = _t + G + 65535, G = Math.floor(C / 65536), _t = C - G * 65536, C = ht + G + 65535, G = Math.floor(C / 65536), ht = C - G * 65536, U += G - 1 + 37 * (G - 1), k[0] = U, k[1] = se, k[2] = he, k[3] = xe, k[4] = Te, k[5] = Re, k[6] = nt, k[7] = Ue, k[8] = pt, k[9] = it, k[10] = et, k[11] = St, k[12] = Tt, k[13] = At, k[14] = _t, k[15] = ht; - } - function oe(k, j) { - D(k, j, j); - } - function Z(k, j) { - var z = r(), C; - for (C = 0; C < 16; C++) z[C] = j[C]; - for (C = 253; C >= 0; C--) - oe(z, z), C !== 2 && C !== 4 && D(z, z, j); - for (C = 0; C < 16; C++) k[C] = z[C]; - } - function J(k, j) { - var z = r(), C; - for (C = 0; C < 16; C++) z[C] = j[C]; - for (C = 250; C >= 0; C--) - oe(z, z), C !== 1 && D(z, z, j); - for (C = 0; C < 16; C++) k[C] = z[C]; - } - function Q(k, j, z) { - var C = new Uint8Array(32), G = new Float64Array(80), U, se, he = r(), xe = r(), Te = r(), Re = r(), nt = r(), Ue = r(); - for (se = 0; se < 31; se++) C[se] = j[se]; - for (C[31] = j[31] & 127 | 64, C[0] &= 248, I(G, z), se = 0; se < 16; se++) - xe[se] = G[se], Re[se] = he[se] = Te[se] = 0; - for (he[0] = Re[0] = 1, se = 254; se >= 0; --se) - U = C[se >>> 3] >>> (se & 7) & 1, _(he, xe, U), _(Te, Re, U), B(nt, he, Te), ce(he, he, Te), B(Te, xe, Re), ce(xe, xe, Re), oe(Re, nt), oe(Ue, he), D(he, Te, he), D(Te, xe, nt), B(nt, he, Te), ce(he, he, Te), oe(xe, he), ce(Te, Re, Ue), D(he, Te, u), B(he, he, Re), D(Te, Te, he), D(he, Re, Ue), D(Re, xe, G), oe(xe, nt), _(he, xe, U), _(Te, Re, U); - for (se = 0; se < 16; se++) - G[se + 16] = he[se], G[se + 32] = Te[se], G[se + 48] = xe[se], G[se + 64] = Re[se]; - var pt = G.subarray(32), it = G.subarray(16); - return Z(pt, pt), D(it, it, pt), E(k, it), 0; - } - function T(k, j) { - return Q(k, j, s); - } - function X(k, j) { - return n(j, 32), T(k, j); - } - function re(k, j, z) { - var C = new Uint8Array(32); - return Q(C, z, j), V(k, i, C, te); - } - var de = f, ie = p; - function ue(k, j, z, C, G, U) { - var se = new Uint8Array(32); - return re(se, G, U), de(k, j, z, C, se); - } - function ve(k, j, z, C, G, U) { - var se = new Uint8Array(32); - return re(se, G, U), ie(k, j, z, C, se); - } - var Pe = [ - 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 De(k, j, z, C) { - for (var G = new Int32Array(16), U = new Int32Array(16), se, he, xe, Te, Re, nt, Ue, pt, it, et, St, Tt, At, _t, ht, xt, st, bt, ut, ot, Se, Ae, Ve, Be, je, Je, Lt = k[0], zt = k[1], Xt = k[2], Ht = k[3], le = k[4], tr = k[5], dr = k[6], pr = k[7], Zt = j[0], gr = j[1], lr = j[2], Rr = j[3], mr = j[4], yr = j[5], $r = j[6], Fr = j[7], Ir = 0; C >= 128; ) { - for (ut = 0; ut < 16; ut++) - ot = 8 * ut + Ir, G[ut] = z[ot + 0] << 24 | z[ot + 1] << 16 | z[ot + 2] << 8 | z[ot + 3], U[ut] = z[ot + 4] << 24 | z[ot + 5] << 16 | z[ot + 6] << 8 | z[ot + 7]; - for (ut = 0; ut < 80; ut++) - if (se = Lt, he = zt, xe = Xt, Te = Ht, Re = le, nt = tr, Ue = dr, pt = pr, it = Zt, et = gr, St = lr, Tt = Rr, At = mr, _t = yr, ht = $r, xt = Fr, Se = pr, Ae = Fr, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = (le >>> 14 | mr << 18) ^ (le >>> 18 | mr << 14) ^ (mr >>> 9 | le << 23), Ae = (mr >>> 14 | le << 18) ^ (mr >>> 18 | le << 14) ^ (le >>> 9 | mr << 23), Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Se = le & tr ^ ~le & dr, Ae = mr & yr ^ ~mr & $r, Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Se = Pe[ut * 2], Ae = Pe[ut * 2 + 1], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Se = G[ut % 16], Ae = U[ut % 16], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, st = je & 65535 | Je << 16, bt = Ve & 65535 | Be << 16, Se = st, Ae = bt, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = (Lt >>> 28 | Zt << 4) ^ (Zt >>> 2 | Lt << 30) ^ (Zt >>> 7 | Lt << 25), Ae = (Zt >>> 28 | Lt << 4) ^ (Lt >>> 2 | Zt << 30) ^ (Lt >>> 7 | Zt << 25), Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Se = Lt & zt ^ Lt & Xt ^ zt & Xt, Ae = Zt & gr ^ Zt & lr ^ gr & lr, Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, pt = je & 65535 | Je << 16, xt = Ve & 65535 | Be << 16, Se = Te, Ae = Tt, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = st, Ae = bt, Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, Te = je & 65535 | Je << 16, Tt = Ve & 65535 | Be << 16, zt = se, Xt = he, Ht = xe, le = Te, tr = Re, dr = nt, pr = Ue, Lt = pt, gr = it, lr = et, Rr = St, mr = Tt, yr = At, $r = _t, Fr = ht, Zt = xt, ut % 16 === 15) - for (ot = 0; ot < 16; ot++) - Se = G[ot], Ae = U[ot], Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = G[(ot + 9) % 16], Ae = U[(ot + 9) % 16], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, st = G[(ot + 1) % 16], bt = U[(ot + 1) % 16], Se = (st >>> 1 | bt << 31) ^ (st >>> 8 | bt << 24) ^ st >>> 7, Ae = (bt >>> 1 | st << 31) ^ (bt >>> 8 | st << 24) ^ (bt >>> 7 | st << 25), Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, st = G[(ot + 14) % 16], bt = U[(ot + 14) % 16], Se = (st >>> 19 | bt << 13) ^ (bt >>> 29 | st << 3) ^ st >>> 6, Ae = (bt >>> 19 | st << 13) ^ (st >>> 29 | bt << 3) ^ (bt >>> 6 | st << 26), Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, G[ot] = je & 65535 | Je << 16, U[ot] = Ve & 65535 | Be << 16; - Se = Lt, Ae = Zt, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = k[0], Ae = j[0], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, k[0] = Lt = je & 65535 | Je << 16, j[0] = Zt = Ve & 65535 | Be << 16, Se = zt, Ae = gr, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = k[1], Ae = j[1], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, k[1] = zt = je & 65535 | Je << 16, j[1] = gr = Ve & 65535 | Be << 16, Se = Xt, Ae = lr, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = k[2], Ae = j[2], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, k[2] = Xt = je & 65535 | Je << 16, j[2] = lr = Ve & 65535 | Be << 16, Se = Ht, Ae = Rr, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = k[3], Ae = j[3], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, k[3] = Ht = je & 65535 | Je << 16, j[3] = Rr = Ve & 65535 | Be << 16, Se = le, Ae = mr, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = k[4], Ae = j[4], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, k[4] = le = je & 65535 | Je << 16, j[4] = mr = Ve & 65535 | Be << 16, Se = tr, Ae = yr, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = k[5], Ae = j[5], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, k[5] = tr = je & 65535 | Je << 16, j[5] = yr = Ve & 65535 | Be << 16, Se = dr, Ae = $r, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = k[6], Ae = j[6], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, k[6] = dr = je & 65535 | Je << 16, j[6] = $r = Ve & 65535 | Be << 16, Se = pr, Ae = Fr, Ve = Ae & 65535, Be = Ae >>> 16, je = Se & 65535, Je = Se >>> 16, Se = k[7], Ae = j[7], Ve += Ae & 65535, Be += Ae >>> 16, je += Se & 65535, Je += Se >>> 16, Be += Ve >>> 16, je += Be >>> 16, Je += je >>> 16, k[7] = pr = je & 65535 | Je << 16, j[7] = Fr = Ve & 65535 | Be << 16, Ir += 128, C -= 128; - } - return C; - } - function Ce(k, j, z) { - var C = new Int32Array(8), G = new Int32Array(8), U = new Uint8Array(256), se, he = z; - for (C[0] = 1779033703, C[1] = 3144134277, C[2] = 1013904242, C[3] = 2773480762, C[4] = 1359893119, C[5] = 2600822924, C[6] = 528734635, C[7] = 1541459225, G[0] = 4089235720, G[1] = 2227873595, G[2] = 4271175723, G[3] = 1595750129, G[4] = 2917565137, G[5] = 725511199, G[6] = 4215389547, G[7] = 327033209, De(C, G, j, z), z %= 128, se = 0; se < z; se++) U[se] = j[he - z + se]; - for (U[z] = 128, z = 256 - 128 * (z < 112 ? 1 : 0), U[z - 9] = 0, M(U, z - 8, he / 536870912 | 0, he << 3), De(C, G, U, z), se = 0; se < 8; se++) M(k, 8 * se, C[se], G[se]); - return 0; - } - function $e(k, j) { - var z = r(), C = r(), G = r(), U = r(), se = r(), he = r(), xe = r(), Te = r(), Re = r(); - ce(z, k[1], k[0]), ce(Re, j[1], j[0]), D(z, z, Re), B(C, k[0], k[1]), B(Re, j[0], j[1]), D(C, C, Re), D(G, k[3], j[3]), D(G, G, d), D(U, k[2], j[2]), B(U, U, U), ce(se, C, z), ce(he, U, G), B(xe, U, G), B(Te, C, z), D(k[0], se, he), D(k[1], Te, xe), D(k[2], xe, he), D(k[3], se, Te); - } - function Me(k, j, z) { - var C; - for (C = 0; C < 4; C++) - _(k[C], j[C], z); - } - function Ne(k, j) { - var z = r(), C = r(), G = r(); - Z(G, j[2]), D(z, j[0], G), D(C, j[1], G), E(k, C), k[31] ^= P(z) << 7; - } - function Ke(k, j, z) { - var C, G; - for (b(k[0], o), b(k[1], a), b(k[2], a), b(k[3], o), G = 255; G >= 0; --G) - C = z[G / 8 | 0] >> (G & 7) & 1, Me(k, j, C), $e(j, k), $e(k, k), Me(k, j, C); - } - function Le(k, j) { - var z = [r(), r(), r(), r()]; - b(z[0], g), b(z[1], w), b(z[2], a), D(z[3], g, w), Ke(k, z, j); - } - function qe(k, j, z) { - var C = new Uint8Array(64), G = [r(), r(), r(), r()], U; - for (z || n(j, 32), Ce(C, j, 32), C[0] &= 248, C[31] &= 127, C[31] |= 64, Le(G, C), Ne(k, G), U = 0; U < 32; U++) j[U + 32] = k[U]; - return 0; - } - var ze = 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 _e(k, j) { - var z, C, G, U; - for (C = 63; C >= 32; --C) { - for (z = 0, G = C - 32, U = C - 12; G < U; ++G) - j[G] += z - 16 * j[C] * ze[G - (C - 32)], z = Math.floor((j[G] + 128) / 256), j[G] -= z * 256; - j[G] += z, j[C] = 0; - } - for (z = 0, G = 0; G < 32; G++) - j[G] += z - (j[31] >> 4) * ze[G], z = j[G] >> 8, j[G] &= 255; - for (G = 0; G < 32; G++) j[G] -= z * ze[G]; - for (C = 0; C < 32; C++) - j[C + 1] += j[C] >> 8, k[C] = j[C] & 255; - } - function Ze(k) { - var j = new Float64Array(64), z; - for (z = 0; z < 64; z++) j[z] = k[z]; - for (z = 0; z < 64; z++) k[z] = 0; - _e(k, j); - } - function at(k, j, z, C) { - var G = new Uint8Array(64), U = new Uint8Array(64), se = new Uint8Array(64), he, xe, Te = new Float64Array(64), Re = [r(), r(), r(), r()]; - Ce(G, C, 32), G[0] &= 248, G[31] &= 127, G[31] |= 64; - var nt = z + 64; - for (he = 0; he < z; he++) k[64 + he] = j[he]; - for (he = 0; he < 32; he++) k[32 + he] = G[32 + he]; - for (Ce(se, k.subarray(32), z + 32), Ze(se), Le(Re, se), Ne(k, Re), he = 32; he < 64; he++) k[he] = C[he]; - for (Ce(U, k, z + 64), Ze(U), he = 0; he < 64; he++) Te[he] = 0; - for (he = 0; he < 32; he++) Te[he] = se[he]; - for (he = 0; he < 32; he++) - for (xe = 0; xe < 32; xe++) - Te[he + xe] += U[he] * G[xe]; - return _e(k.subarray(32), Te), nt; - } - function ke(k, j) { - var z = r(), C = r(), G = r(), U = r(), se = r(), he = r(), xe = r(); - return b(k[2], a), I(k[1], j), oe(G, k[1]), D(U, G, l), ce(G, G, k[2]), B(U, k[2], U), oe(se, U), oe(he, se), D(xe, he, se), D(z, xe, G), D(z, z, U), J(z, z), D(z, z, G), D(z, z, U), D(z, z, U), D(k[0], z, U), oe(C, k[0]), D(C, C, U), v(C, G) && D(k[0], k[0], A), oe(C, k[0]), D(C, C, U), v(C, G) ? -1 : (P(k[0]) === j[31] >> 7 && ce(k[0], o, k[0]), D(k[3], k[0], k[1]), 0); - } - function Qe(k, j, z, C) { - var G, U = new Uint8Array(32), se = new Uint8Array(64), he = [r(), r(), r(), r()], xe = [r(), r(), r(), r()]; - if (z < 64 || ke(xe, C)) return -1; - for (G = 0; G < z; G++) k[G] = j[G]; - for (G = 0; G < 32; G++) k[G + 32] = C[G]; - if (Ce(se, k, z), Ze(se), Ke(he, xe, se), Le(xe, j.subarray(32)), $e(he, xe), Ne(U, he), z -= 64, F(j, 0, U, 0)) { - for (G = 0; G < z; G++) k[G] = 0; - return -1; - } - for (G = 0; G < z; G++) k[G] = j[G + 64]; - return z; - } - var tt = 32, Ye = 24, dt = 32, lt = 16, ct = 32, qt = 32, Yt = 32, Et = 32, Qt = 32, Jt = Ye, Dt = dt, kt = lt, Ct = 64, gt = 32, Rt = 64, Nt = 32, vt = 64; - e.lowlevel = { - crypto_core_hsalsa20: V, - crypto_stream_xor: Ee, - crypto_stream: pe, - crypto_stream_salsa20_xor: R, - crypto_stream_salsa20: W, - crypto_onetimeauth: S, - crypto_onetimeauth_verify: m, - crypto_verify_16: L, - crypto_verify_32: F, - crypto_secretbox: f, - crypto_secretbox_open: p, - crypto_scalarmult: Q, - crypto_scalarmult_base: T, - crypto_box_beforenm: re, - crypto_box_afternm: de, - crypto_box: ue, - crypto_box_open: ve, - crypto_box_keypair: X, - crypto_hash: Ce, - crypto_sign: at, - crypto_sign_keypair: qe, - crypto_sign_open: Qe, - crypto_secretbox_KEYBYTES: tt, - crypto_secretbox_NONCEBYTES: Ye, - crypto_secretbox_ZEROBYTES: dt, - crypto_secretbox_BOXZEROBYTES: lt, - crypto_scalarmult_BYTES: ct, - crypto_scalarmult_SCALARBYTES: qt, - crypto_box_PUBLICKEYBYTES: Yt, - crypto_box_SECRETKEYBYTES: Et, - crypto_box_BEFORENMBYTES: Qt, - crypto_box_NONCEBYTES: Jt, - crypto_box_ZEROBYTES: Dt, - crypto_box_BOXZEROBYTES: kt, - crypto_sign_BYTES: Ct, - crypto_sign_PUBLICKEYBYTES: gt, - crypto_sign_SECRETKEYBYTES: Rt, - crypto_sign_SEEDBYTES: Nt, - crypto_hash_BYTES: vt, - gf: r, - D: l, - L: ze, - pack25519: E, - unpack25519: I, - M: D, - A: B, - S: oe, - Z: ce, - pow2523: J, - add: $e, - set25519: b, - modL: _e, - scalarmult: Ke, - scalarbase: Le - }; - function $t(k, j) { - if (k.length !== tt) throw new Error("bad key size"); - if (j.length !== Ye) throw new Error("bad nonce size"); - } - function Bt(k, j) { - if (k.length !== Yt) throw new Error("bad public key size"); - if (j.length !== Et) throw new Error("bad secret key size"); - } - function rt() { - for (var k = 0; k < arguments.length; k++) - if (!(arguments[k] instanceof Uint8Array)) - throw new TypeError("unexpected type, use Uint8Array"); - } - function Ft(k) { - for (var j = 0; j < k.length; j++) k[j] = 0; - } - e.randomBytes = function(k) { - var j = new Uint8Array(k); - return n(j, k), j; - }, e.secretbox = function(k, j, z) { - rt(k, j, z), $t(z, j); - for (var C = new Uint8Array(dt + k.length), G = new Uint8Array(C.length), U = 0; U < k.length; U++) C[U + dt] = k[U]; - return f(G, C, C.length, j, z), G.subarray(lt); - }, e.secretbox.open = function(k, j, z) { - rt(k, j, z), $t(z, j); - for (var C = new Uint8Array(lt + k.length), G = new Uint8Array(C.length), U = 0; U < k.length; U++) C[U + lt] = k[U]; - return C.length < 32 || p(G, C, C.length, j, z) !== 0 ? null : G.subarray(dt); - }, e.secretbox.keyLength = tt, e.secretbox.nonceLength = Ye, e.secretbox.overheadLength = lt, e.scalarMult = function(k, j) { - if (rt(k, j), k.length !== qt) throw new Error("bad n size"); - if (j.length !== ct) throw new Error("bad p size"); - var z = new Uint8Array(ct); - return Q(z, k, j), z; - }, e.scalarMult.base = function(k) { - if (rt(k), k.length !== qt) throw new Error("bad n size"); - var j = new Uint8Array(ct); - return T(j, k), j; - }, e.scalarMult.scalarLength = qt, e.scalarMult.groupElementLength = ct, e.box = function(k, j, z, C) { - var G = e.box.before(z, C); - return e.secretbox(k, j, G); - }, e.box.before = function(k, j) { - rt(k, j), Bt(k, j); - var z = new Uint8Array(Qt); - return re(z, k, j), z; - }, e.box.after = e.secretbox, e.box.open = function(k, j, z, C) { - var G = e.box.before(z, C); - return e.secretbox.open(k, j, G); - }, e.box.open.after = e.secretbox.open, e.box.keyPair = function() { - var k = new Uint8Array(Yt), j = new Uint8Array(Et); - return X(k, j), { publicKey: k, secretKey: j }; - }, e.box.keyPair.fromSecretKey = function(k) { - if (rt(k), k.length !== Et) - throw new Error("bad secret key size"); - var j = new Uint8Array(Yt); - return T(j, k), { publicKey: j, secretKey: new Uint8Array(k) }; - }, e.box.publicKeyLength = Yt, e.box.secretKeyLength = Et, e.box.sharedKeyLength = Qt, e.box.nonceLength = Jt, e.box.overheadLength = e.secretbox.overheadLength, e.sign = function(k, j) { - if (rt(k, j), j.length !== Rt) - throw new Error("bad secret key size"); - var z = new Uint8Array(Ct + k.length); - return at(z, k, k.length, j), z; - }, e.sign.open = function(k, j) { - if (rt(k, j), j.length !== gt) - throw new Error("bad public key size"); - var z = new Uint8Array(k.length), C = Qe(z, k, k.length, j); - if (C < 0) return null; - for (var G = new Uint8Array(C), U = 0; U < G.length; U++) G[U] = z[U]; - return G; - }, e.sign.detached = function(k, j) { - for (var z = e.sign(k, j), C = new Uint8Array(Ct), G = 0; G < C.length; G++) C[G] = z[G]; - return C; - }, e.sign.detached.verify = function(k, j, z) { - if (rt(k, j, z), j.length !== Ct) - throw new Error("bad signature size"); - if (z.length !== gt) - throw new Error("bad public key size"); - var C = new Uint8Array(Ct + k.length), G = new Uint8Array(Ct + k.length), U; - for (U = 0; U < Ct; U++) C[U] = j[U]; - for (U = 0; U < k.length; U++) C[U + Ct] = k[U]; - return Qe(G, C, C.length, z) >= 0; - }, e.sign.keyPair = function() { - var k = new Uint8Array(gt), j = new Uint8Array(Rt); - return qe(k, j), { publicKey: k, secretKey: j }; - }, e.sign.keyPair.fromSecretKey = function(k) { - if (rt(k), k.length !== Rt) - throw new Error("bad secret key size"); - for (var j = new Uint8Array(gt), z = 0; z < j.length; z++) j[z] = k[32 + z]; - return { publicKey: j, secretKey: new Uint8Array(k) }; - }, e.sign.keyPair.fromSeed = function(k) { - if (rt(k), k.length !== Nt) - throw new Error("bad seed size"); - for (var j = new Uint8Array(gt), z = new Uint8Array(Rt), C = 0; C < 32; C++) z[C] = k[C]; - return qe(j, z, !0), { publicKey: j, secretKey: z }; - }, e.sign.publicKeyLength = gt, e.sign.secretKeyLength = Rt, e.sign.seedLength = Nt, e.sign.signatureLength = Ct, e.hash = function(k) { - rt(k); - var j = new Uint8Array(vt); - return Ce(j, k, k.length), j; - }, e.hash.hashLength = vt, e.verify = function(k, j) { - return rt(k, j), k.length === 0 || j.length === 0 || k.length !== j.length ? !1 : N(k, 0, j, 0, k.length) === 0; - }, e.setPRNG = function(k) { - n = k; - }, function() { - var k = typeof self < "u" ? self.crypto || self.msCrypto : null; - if (k && k.getRandomValues) { - var j = 65536; - e.setPRNG(function(z, C) { - var G, U = new Uint8Array(C); - for (G = 0; G < C; G += j) - k.getRandomValues(U.subarray(G, G + Math.min(C - G, j))); - for (G = 0; G < C; G++) z[G] = U[G]; - Ft(U); - }); - } else typeof A4 < "u" && (k = zl, k && k.randomBytes && e.setPRNG(function(z, C) { - var G, U = k.randomBytes(C); - for (G = 0; G < C; G++) z[G] = U[G]; - Ft(U); - })); - }(); - })(t.exports ? t.exports : self.nacl = self.nacl || {}); -})(B9); -var aie = B9.exports; -const bd = /* @__PURE__ */ ts(aie); -var ua; -(function(t) { - t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.BAD_REQUEST_ERROR = 1] = "BAD_REQUEST_ERROR", t[t.MANIFEST_NOT_FOUND_ERROR = 2] = "MANIFEST_NOT_FOUND_ERROR", t[t.MANIFEST_CONTENT_ERROR = 3] = "MANIFEST_CONTENT_ERROR", t[t.UNKNOWN_APP_ERROR = 100] = "UNKNOWN_APP_ERROR", t[t.USER_REJECTS_ERROR = 300] = "USER_REJECTS_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; -})(ua || (ua = {})); -var f5; -(function(t) { - t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; -})(f5 || (f5 = {})); -var iu; -(function(t) { - t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.BAD_REQUEST_ERROR = 1] = "BAD_REQUEST_ERROR", t[t.UNKNOWN_APP_ERROR = 100] = "UNKNOWN_APP_ERROR", t[t.USER_REJECTS_ERROR = 300] = "USER_REJECTS_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; -})(iu || (iu = {})); -var l5; -(function(t) { - t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.BAD_REQUEST_ERROR = 1] = "BAD_REQUEST_ERROR", t[t.UNKNOWN_APP_ERROR = 100] = "UNKNOWN_APP_ERROR", t[t.USER_REJECTS_ERROR = 300] = "USER_REJECTS_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; -})(l5 || (l5 = {})); -var h5; -(function(t) { - t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.BAD_REQUEST_ERROR = 1] = "BAD_REQUEST_ERROR", t[t.UNKNOWN_APP_ERROR = 100] = "UNKNOWN_APP_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; -})(h5 || (h5 = {})); -var d5; -(function(t) { - t.MAINNET = "-239", t.TESTNET = "-3"; -})(d5 || (d5 = {})); -function cie(t, e) { - const r = Rl.encodeBase64(t); - return e ? encodeURIComponent(r) : r; -} -function uie(t, e) { - return e && (t = decodeURIComponent(t)), Rl.decodeBase64(t); -} -function fie(t, e = !1) { - let r; - return t instanceof Uint8Array ? r = t : (typeof t != "string" && (t = JSON.stringify(t)), r = Rl.decodeUTF8(t)), cie(r, e); -} -function lie(t, e = !1) { - const r = uie(t, e); - return { - toString() { - return Rl.encodeUTF8(r); - }, - toObject() { - try { - return JSON.parse(Rl.encodeUTF8(r)); - } catch { - return null; - } - }, - toUint8Array() { - return r; - } - }; -} -const U9 = { - encode: fie, - decode: lie -}; -function hie(t, e) { - const r = new Uint8Array(t.length + e.length); - return r.set(t), r.set(e, t.length), r; -} -function die(t, e) { - if (e >= t.length) - throw new Error("Index is out of buffer"); - const r = t.slice(0, e), n = t.slice(e); - return [r, n]; -} -function Km(t) { - let e = ""; - return t.forEach((r) => { - e += ("0" + (r & 255).toString(16)).slice(-2); - }), e; -} -function S0(t) { - if (t.length % 2 !== 0) - throw new Error(`Cannot convert ${t} to bytesArray`); - const e = new Uint8Array(t.length / 2); - for (let r = 0; r < t.length; r += 2) - e[r / 2] = parseInt(t.slice(r, r + 2), 16); - return e; -} -class hv { - constructor(e) { - this.nonceLength = 24, this.keyPair = e ? this.createKeypairFromString(e) : this.createKeypair(), this.sessionId = Km(this.keyPair.publicKey); - } - createKeypair() { - return bd.box.keyPair(); - } - createKeypairFromString(e) { - return { - publicKey: S0(e.publicKey), - secretKey: S0(e.secretKey) - }; - } - createNonce() { - return bd.randomBytes(this.nonceLength); - } - encrypt(e, r) { - const n = new TextEncoder().encode(e), i = this.createNonce(), s = bd.box(n, i, r, this.keyPair.secretKey); - return hie(i, s); - } - decrypt(e, r) { - const [n, i] = die(e, this.nonceLength), s = bd.box.open(i, n, r, this.keyPair.secretKey); - if (!s) - throw new Error(`Decryption error: - message: ${e.toString()} - sender pubkey: ${r.toString()} - keypair pubkey: ${this.keyPair.publicKey.toString()} - keypair secretkey: ${this.keyPair.secretKey.toString()}`); - return new TextDecoder().decode(s); - } - stringifyKeypair() { - return { - publicKey: Km(this.keyPair.publicKey), - secretKey: Km(this.keyPair.secretKey) - }; - } -} -/*! ***************************************************************************** -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. -***************************************************************************** */ -function pie(t, e) { - var r = {}; - for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); - if (t != null && typeof Object.getOwnPropertySymbols == "function") - for (var i = 0, n = Object.getOwnPropertySymbols(t); i < n.length; i++) - e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[i]) && (r[n[i]] = t[n[i]]); - return r; -} -function Mt(t, e, r, n) { - function i(s) { - return s instanceof r ? s : new r(function(o) { - o(s); - }); - } - return new (r || (r = Promise))(function(s, o) { - function a(d) { - try { - l(n.next(d)); - } catch (g) { - o(g); - } - } - function u(d) { - try { - l(n.throw(d)); - } catch (g) { - o(g); - } - } - function l(d) { - d.done ? s(d.value) : i(d.value).then(a, u); - } - l((n = n.apply(t, [])).next()); - }); -} -class Ut extends Error { - constructor(e, r) { - super(e, r), this.message = `${Ut.prefix} ${this.constructor.name}${this.info ? ": " + this.info : ""}${e ? ` -` + e : ""}`, Object.setPrototypeOf(this, Ut.prototype); - } - get info() { - return ""; - } -} -Ut.prefix = "[TON_CONNECT_SDK_ERROR]"; -class cy extends Ut { - get info() { - return "Passed DappMetadata is in incorrect format."; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, cy.prototype); - } -} -class Sp extends Ut { - get info() { - return "Passed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, Sp.prototype); - } -} -class Ap extends Ut { - get info() { - return "Manifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, Ap.prototype); - } -} -class uy extends Ut { - get info() { - return "Wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection."; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, uy.prototype); - } -} -class A0 extends Ut { - get info() { - return "Send transaction or other protocol methods called while wallet is not connected."; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, A0.prototype); - } -} -function gie(t) { - return "jsBridgeKey" in t; -} -class Pp extends Ut { - get info() { - return "User rejects the action in the wallet."; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, Pp.prototype); - } -} -class Mp extends Ut { - get info() { - return "Request to the wallet contains errors."; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, Mp.prototype); - } -} -class Ip extends Ut { - get info() { - return "App tries to send rpc request to the injected wallet while not connected."; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, Ip.prototype); - } -} -class fy extends Ut { - get info() { - return "There is an attempt to connect to the injected wallet while it is not exists in the webpage."; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, fy.prototype); - } -} -class ly extends Ut { - get info() { - return "An error occurred while fetching the wallets list."; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, ly.prototype); - } -} -class Ea extends Ut { - constructor(...e) { - super(...e), Object.setPrototypeOf(this, Ea.prototype); - } -} -const p5 = { - [ua.UNKNOWN_ERROR]: Ea, - [ua.USER_REJECTS_ERROR]: Pp, - [ua.BAD_REQUEST_ERROR]: Mp, - [ua.UNKNOWN_APP_ERROR]: Ip, - [ua.MANIFEST_NOT_FOUND_ERROR]: Ap, - [ua.MANIFEST_CONTENT_ERROR]: Sp -}; -class mie { - parseError(e) { - let r = Ea; - return e.code in p5 && (r = p5[e.code] || Ea), new r(e.message); - } -} -const vie = new mie(); -class bie { - isError(e) { - return "error" in e; - } -} -const g5 = { - [iu.UNKNOWN_ERROR]: Ea, - [iu.USER_REJECTS_ERROR]: Pp, - [iu.BAD_REQUEST_ERROR]: Mp, - [iu.UNKNOWN_APP_ERROR]: Ip -}; -class yie extends bie { - convertToRpcRequest(e) { - return { - method: "sendTransaction", - params: [JSON.stringify(e)] - }; - } - parseAndThrowError(e) { - let r = Ea; - throw e.error.code in g5 && (r = g5[e.error.code] || Ea), new r(e.error.message); - } - convertFromRpcResponse(e) { - return { - boc: e.result - }; - } -} -const yd = new yie(); -class wie { - constructor(e, r) { - this.storage = e, this.storeKey = "ton-connect-storage_http-bridge-gateway::" + r; - } - storeLastEventId(e) { - return Mt(this, void 0, void 0, function* () { - return this.storage.setItem(this.storeKey, e); - }); - } - removeLastEventId() { - return Mt(this, void 0, void 0, function* () { - return this.storage.removeItem(this.storeKey); - }); - } - getLastEventId() { - return Mt(this, void 0, void 0, function* () { - const e = yield this.storage.getItem(this.storeKey); - return e || null; - }); - } -} -function xie(t) { - return t.slice(-1) === "/" ? t.slice(0, -1) : t; -} -function j9(t, e) { - return xie(t) + "/" + e; -} -function _ie(t) { - if (!t) - return !1; - const e = new URL(t); - return e.protocol === "tg:" || e.hostname === "t.me"; -} -function Eie(t) { - return t.replaceAll(".", "%2E").replaceAll("-", "%2D").replaceAll("_", "%5F").replaceAll("&", "-").replaceAll("=", "__").replaceAll("%", "--"); -} -function q9(t, e) { - return Mt(this, void 0, void 0, function* () { - return new Promise((r, n) => { - var i, s; - if (!((i = void 0) === null || i === void 0) && i.aborted) { - n(new Ut("Delay aborted")); - return; - } - const o = setTimeout(() => r(), t); - (s = void 0) === null || s === void 0 || s.addEventListener("abort", () => { - clearTimeout(o), n(new Ut("Delay aborted")); - }); - }); - }); -} -function xs(t) { - const e = new AbortController(); - return t != null && t.aborted ? e.abort() : t == null || t.addEventListener("abort", () => e.abort(), { once: !0 }), e; -} -function Xf(t, e) { - var r, n; - return Mt(this, void 0, void 0, function* () { - const i = (r = e == null ? void 0 : e.attempts) !== null && r !== void 0 ? r : 10, s = (n = e == null ? void 0 : e.delayMs) !== null && n !== void 0 ? n : 200, o = xs(e == null ? void 0 : e.signal); - if (typeof t != "function") - throw new Ut(`Expected a function, got ${typeof t}`); - let a = 0, u; - for (; a < i; ) { - if (o.signal.aborted) - throw new Ut(`Aborted after attempts ${a}`); - try { - return yield t({ signal: o.signal }); - } catch (l) { - u = l, a++, a < i && (yield q9(s)); - } - } - throw u; - }); -} -function Sn(...t) { - try { - console.debug("[TON_CONNECT_SDK]", ...t); - } catch { - } -} -function Oo(...t) { - try { - console.error("[TON_CONNECT_SDK]", ...t); - } catch { - } -} -function Sie(...t) { - try { - console.warn("[TON_CONNECT_SDK]", ...t); - } catch { - } -} -function Aie(t, e) { - let r = null, n = null, i = null, s = null, o = null; - const a = (g, ...w) => Mt(this, void 0, void 0, function* () { - if (s = g ?? null, o == null || o.abort(), o = xs(g), o.signal.aborted) - throw new Ut("Resource creation was aborted"); - n = w ?? null; - const A = t(o.signal, ...w); - i = A; - const M = yield A; - if (i !== A && M !== r) - throw yield e(M), new Ut("Resource creation was aborted by a new resource creation"); - return r = M, r; - }); - return { - create: a, - current: () => r ?? null, - dispose: () => Mt(this, void 0, void 0, function* () { - try { - const g = r; - r = null; - const w = i; - i = null; - try { - o == null || o.abort(); - } catch { - } - yield Promise.allSettled([ - g ? e(g) : Promise.resolve(), - w ? e(yield w) : Promise.resolve() - ]); - } catch { - } - }), - recreate: (g) => Mt(this, void 0, void 0, function* () { - const w = r, A = i, M = n, N = s; - if (yield q9(g), w === r && A === i && M === n && N === s) - return yield a(s, ...M ?? []); - throw new Ut("Resource recreation was aborted by a new resource creation"); - }) - }; -} -function Pie(t, e) { - const r = e == null ? void 0 : e.timeout, n = e == null ? void 0 : e.signal, i = xs(n); - return new Promise((s, o) => Mt(this, void 0, void 0, function* () { - if (i.signal.aborted) { - o(new Ut("Operation aborted")); - return; - } - let a; - typeof r < "u" && (a = setTimeout(() => { - i.abort(), o(new Ut(`Timeout after ${r}ms`)); - }, r)), i.signal.addEventListener("abort", () => { - clearTimeout(a), o(new Ut("Operation aborted")); - }, { once: !0 }); - const u = { timeout: r, abort: i.signal }; - yield t((...l) => { - clearTimeout(a), s(...l); - }, () => { - clearTimeout(a), o(); - }, u); - })); -} -class Vm { - constructor(e, r, n, i, s) { - this.bridgeUrl = r, this.sessionId = n, this.listener = i, this.errorsListener = s, this.ssePath = "events", this.postPath = "message", this.heartbeatMessage = "heartbeat", this.defaultTtl = 300, this.defaultReconnectDelay = 2e3, this.defaultResendDelay = 5e3, this.eventSource = Aie((o, a) => Mt(this, void 0, void 0, function* () { - const u = { - bridgeUrl: this.bridgeUrl, - ssePath: this.ssePath, - sessionId: this.sessionId, - bridgeGatewayStorage: this.bridgeGatewayStorage, - errorHandler: this.errorsHandler.bind(this), - messageHandler: this.messagesHandler.bind(this), - signal: o, - openingDeadlineMS: a - }; - return yield Mie(u); - }), (o) => Mt(this, void 0, void 0, function* () { - o.close(); - })), this.bridgeGatewayStorage = new wie(e, r); - } - get isReady() { - const e = this.eventSource.current(); - return (e == null ? void 0 : e.readyState) === EventSource.OPEN; - } - get isClosed() { - const e = this.eventSource.current(); - return (e == null ? void 0 : e.readyState) !== EventSource.OPEN; - } - get isConnecting() { - const e = this.eventSource.current(); - return (e == null ? void 0 : e.readyState) === EventSource.CONNECTING; - } - registerSession(e) { - return Mt(this, void 0, void 0, function* () { - yield this.eventSource.create(e == null ? void 0 : e.signal, e == null ? void 0 : e.openingDeadlineMS); - }); - } - send(e, r, n, i) { - var s; - return Mt(this, void 0, void 0, function* () { - const o = {}; - typeof i == "number" ? o.ttl = i : (o.ttl = i == null ? void 0 : i.ttl, o.signal = i == null ? void 0 : i.signal, o.attempts = i == null ? void 0 : i.attempts); - const a = new URL(j9(this.bridgeUrl, this.postPath)); - a.searchParams.append("client_id", this.sessionId), a.searchParams.append("to", r), a.searchParams.append("ttl", ((o == null ? void 0 : o.ttl) || this.defaultTtl).toString()), a.searchParams.append("topic", n); - const u = U9.encode(e); - yield Xf((l) => Mt(this, void 0, void 0, function* () { - const d = yield this.post(a, u, l.signal); - if (!d.ok) - throw new Ut(`Bridge send failed, status ${d.status}`); - }), { - attempts: (s = o == null ? void 0 : o.attempts) !== null && s !== void 0 ? s : Number.MAX_SAFE_INTEGER, - delayMs: this.defaultResendDelay, - signal: o == null ? void 0 : o.signal - }); - }); - } - pause() { - this.eventSource.dispose().catch((e) => Oo(`Bridge pause failed, ${e}`)); - } - unPause() { - return Mt(this, void 0, void 0, function* () { - yield this.eventSource.recreate(0); - }); - } - close() { - return Mt(this, void 0, void 0, function* () { - yield this.eventSource.dispose().catch((e) => Oo(`Bridge close failed, ${e}`)); - }); - } - setListener(e) { - this.listener = e; - } - setErrorsListener(e) { - this.errorsListener = e; - } - post(e, r, n) { - return Mt(this, void 0, void 0, function* () { - const i = yield fetch(e, { - method: "post", - body: r, - signal: n - }); - if (!i.ok) - throw new Ut(`Bridge send failed, status ${i.status}`); - return i; - }); - } - errorsHandler(e, r) { - return Mt(this, void 0, void 0, function* () { - if (this.isConnecting) - throw e.close(), new Ut("Bridge error, failed to connect"); - if (this.isReady) { - try { - this.errorsListener(r); - } catch { - } - return; - } - if (this.isClosed) - return e.close(), Sn(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`), yield this.eventSource.recreate(this.defaultReconnectDelay); - throw new Ut("Bridge error, unknown state"); - }); - } - messagesHandler(e) { - return Mt(this, void 0, void 0, function* () { - if (e.data === this.heartbeatMessage || (yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId), this.isClosed)) - return; - let r; - try { - r = JSON.parse(e.data); - } catch (n) { - throw new Ut(`Bridge message parse failed, message ${n.data}`); - } - this.listener(r); - }); - } -} -function Mie(t) { - return Mt(this, void 0, void 0, function* () { - return yield Pie((e, r, n) => Mt(this, void 0, void 0, function* () { - var i; - const o = xs(n.signal).signal; - if (o.aborted) { - r(new Ut("Bridge connection aborted")); - return; - } - const a = new URL(j9(t.bridgeUrl, t.ssePath)); - a.searchParams.append("client_id", t.sessionId); - const u = yield t.bridgeGatewayStorage.getLastEventId(); - if (u && a.searchParams.append("last_event_id", u), o.aborted) { - r(new Ut("Bridge connection aborted")); - return; - } - const l = new EventSource(a.toString()); - l.onerror = (d) => Mt(this, void 0, void 0, function* () { - if (o.aborted) { - l.close(), r(new Ut("Bridge connection aborted")); - return; - } - try { - const g = yield t.errorHandler(l, d); - g !== l && l.close(), g && g !== l && e(g); - } catch (g) { - l.close(), r(g); - } - }), l.onopen = () => { - if (o.aborted) { - l.close(), r(new Ut("Bridge connection aborted")); - return; - } - e(l); - }, l.onmessage = (d) => { - if (o.aborted) { - l.close(), r(new Ut("Bridge connection aborted")); - return; - } - t.messageHandler(d); - }, (i = t.signal) === null || i === void 0 || i.addEventListener("abort", () => { - l.close(), r(new Ut("Bridge connection aborted")); - }); - }), { timeout: t.openingDeadlineMS, signal: t.signal }); - }); -} -function Zf(t) { - return !("connectEvent" in t); -} -class Dl { - constructor(e) { - this.storage = e, this.storeKey = "ton-connect-storage_bridge-connection"; - } - storeConnection(e) { - return Mt(this, void 0, void 0, function* () { - if (e.type === "injected") - return this.storage.setItem(this.storeKey, JSON.stringify(e)); - if (!Zf(e)) { - const n = { - sessionKeyPair: e.session.sessionCrypto.stringifyKeypair(), - walletPublicKey: e.session.walletPublicKey, - bridgeUrl: e.session.bridgeUrl - }, i = { - type: "http", - connectEvent: e.connectEvent, - session: n, - lastWalletEventId: e.lastWalletEventId, - nextRpcRequestId: e.nextRpcRequestId - }; - return this.storage.setItem(this.storeKey, JSON.stringify(i)); - } - const r = { - type: "http", - connectionSource: e.connectionSource, - sessionCrypto: e.sessionCrypto.stringifyKeypair() - }; - return this.storage.setItem(this.storeKey, JSON.stringify(r)); - }); - } - removeConnection() { - return Mt(this, void 0, void 0, function* () { - return this.storage.removeItem(this.storeKey); - }); - } - getConnection() { - return Mt(this, void 0, void 0, function* () { - const e = yield this.storage.getItem(this.storeKey); - if (!e) - return null; - const r = JSON.parse(e); - if (r.type === "injected") - return r; - if ("connectEvent" in r) { - const n = new hv(r.session.sessionKeyPair); - return { - type: "http", - connectEvent: r.connectEvent, - lastWalletEventId: r.lastWalletEventId, - nextRpcRequestId: r.nextRpcRequestId, - session: { - sessionCrypto: n, - bridgeUrl: r.session.bridgeUrl, - walletPublicKey: r.session.walletPublicKey - } - }; - } - return { - type: "http", - sessionCrypto: new hv(r.sessionCrypto), - connectionSource: r.connectionSource - }; - }); - } - getHttpConnection() { - return Mt(this, void 0, void 0, function* () { - const e = yield this.getConnection(); - if (!e) - throw new Ut("Trying to read HTTP connection source while nothing is stored"); - if (e.type === "injected") - throw new Ut("Trying to read HTTP connection source while injected connection is stored"); - return e; - }); - } - getHttpPendingConnection() { - return Mt(this, void 0, void 0, function* () { - const e = yield this.getConnection(); - if (!e) - throw new Ut("Trying to read HTTP connection source while nothing is stored"); - if (e.type === "injected") - throw new Ut("Trying to read HTTP connection source while injected connection is stored"); - if (!Zf(e)) - throw new Ut("Trying to read HTTP-pending connection while http connection is stored"); - return e; - }); - } - getInjectedConnection() { - return Mt(this, void 0, void 0, function* () { - const e = yield this.getConnection(); - if (!e) - throw new Ut("Trying to read Injected bridge connection source while nothing is stored"); - if ((e == null ? void 0 : e.type) === "http") - throw new Ut("Trying to read Injected bridge connection source while HTTP connection is stored"); - return e; - }); - } - storedConnectionType() { - return Mt(this, void 0, void 0, function* () { - const e = yield this.storage.getItem(this.storeKey); - return e ? JSON.parse(e).type : null; - }); - } - storeLastWalletEventId(e) { - return Mt(this, void 0, void 0, function* () { - const r = yield this.getConnection(); - if (r && r.type === "http" && !Zf(r)) - return r.lastWalletEventId = e, this.storeConnection(r); - }); - } - getLastWalletEventId() { - return Mt(this, void 0, void 0, function* () { - const e = yield this.getConnection(); - if (e && "lastWalletEventId" in e) - return e.lastWalletEventId; - }); - } - increaseNextRpcRequestId() { - return Mt(this, void 0, void 0, function* () { - const e = yield this.getConnection(); - if (e && "nextRpcRequestId" in e) { - const r = e.nextRpcRequestId || 0; - return e.nextRpcRequestId = r + 1, this.storeConnection(e); - } - }); - } - getNextRpcRequestId() { - return Mt(this, void 0, void 0, function* () { - const e = yield this.getConnection(); - return e && "nextRpcRequestId" in e && e.nextRpcRequestId || 0; - }); - } -} -const z9 = 2; -class Ol { - constructor(e, r) { - this.storage = e, this.walletConnectionSource = r, this.type = "http", this.standardUniversalLink = "tc://", this.pendingRequests = /* @__PURE__ */ new Map(), this.session = null, this.gateway = null, this.pendingGateways = [], this.listeners = [], this.defaultOpeningDeadlineMS = 12e3, this.defaultRetryTimeoutMS = 2e3, this.connectionStorage = new Dl(e); - } - static fromStorage(e) { - return Mt(this, void 0, void 0, function* () { - const n = yield new Dl(e).getHttpConnection(); - return Zf(n) ? new Ol(e, n.connectionSource) : new Ol(e, { bridgeUrl: n.session.bridgeUrl }); - }); - } - connect(e, r) { - var n; - const i = xs(r == null ? void 0 : r.signal); - (n = this.abortController) === null || n === void 0 || n.abort(), this.abortController = i, this.closeGateways(); - const s = new hv(); - this.session = { - sessionCrypto: s, - bridgeUrl: "bridgeUrl" in this.walletConnectionSource ? this.walletConnectionSource.bridgeUrl : "" - }, this.connectionStorage.storeConnection({ - type: "http", - connectionSource: this.walletConnectionSource, - sessionCrypto: s - }).then(() => Mt(this, void 0, void 0, function* () { - i.signal.aborted || (yield Xf((a) => { - var u; - return this.openGateways(s, { - openingDeadlineMS: (u = r == null ? void 0 : r.openingDeadlineMS) !== null && u !== void 0 ? u : this.defaultOpeningDeadlineMS, - signal: a == null ? void 0 : a.signal - }); - }, { - attempts: Number.MAX_SAFE_INTEGER, - delayMs: this.defaultRetryTimeoutMS, - signal: i.signal - })); - })); - const o = "universalLink" in this.walletConnectionSource && this.walletConnectionSource.universalLink ? this.walletConnectionSource.universalLink : this.standardUniversalLink; - return this.generateUniversalLink(o, e); - } - restoreConnection(e) { - var r, n; - return Mt(this, void 0, void 0, function* () { - const i = xs(e == null ? void 0 : e.signal); - if ((r = this.abortController) === null || r === void 0 || r.abort(), this.abortController = i, i.signal.aborted) - return; - this.closeGateways(); - const s = yield this.connectionStorage.getHttpConnection(); - if (!s || i.signal.aborted) - return; - const o = (n = e == null ? void 0 : e.openingDeadlineMS) !== null && n !== void 0 ? n : this.defaultOpeningDeadlineMS; - if (Zf(s)) - return this.session = { - sessionCrypto: s.sessionCrypto, - bridgeUrl: "bridgeUrl" in this.walletConnectionSource ? this.walletConnectionSource.bridgeUrl : "" - }, yield this.openGateways(s.sessionCrypto, { - openingDeadlineMS: o, - signal: i == null ? void 0 : i.signal - }); - if (Array.isArray(this.walletConnectionSource)) - throw new Ut("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected."); - if (this.session = s.session, this.gateway && (Sn("Gateway is already opened, closing previous gateway"), yield this.gateway.close()), this.gateway = new Vm(this.storage, this.walletConnectionSource.bridgeUrl, s.session.sessionCrypto.sessionId, this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this)), !i.signal.aborted) { - this.listeners.forEach((a) => a(s.connectEvent)); - try { - yield Xf((a) => this.gateway.registerSession({ - openingDeadlineMS: o, - signal: a.signal - }), { - attempts: Number.MAX_SAFE_INTEGER, - delayMs: this.defaultRetryTimeoutMS, - signal: i.signal - }); - } catch { - yield this.disconnect({ signal: i.signal }); - return; - } - } - }); - } - sendRequest(e, r) { - const n = {}; - return typeof r == "function" ? n.onRequestSent = r : (n.onRequestSent = r == null ? void 0 : r.onRequestSent, n.signal = r == null ? void 0 : r.signal, n.attempts = r == null ? void 0 : r.attempts), new Promise((i, s) => Mt(this, void 0, void 0, function* () { - var o; - if (!this.gateway || !this.session || !("walletPublicKey" in this.session)) - throw new Ut("Trying to send bridge request without session"); - const a = (yield this.connectionStorage.getNextRpcRequestId()).toString(); - yield this.connectionStorage.increaseNextRpcRequestId(), Sn("Send http-bridge request:", Object.assign(Object.assign({}, e), { id: a })); - const u = this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({}, e), { id: a })), S0(this.session.walletPublicKey)); - try { - yield this.gateway.send(u, this.session.walletPublicKey, e.method, { attempts: n == null ? void 0 : n.attempts, signal: n == null ? void 0 : n.signal }), (o = n == null ? void 0 : n.onRequestSent) === null || o === void 0 || o.call(n), this.pendingRequests.set(a.toString(), i); - } catch (l) { - s(l); - } - })); - } - closeConnection() { - this.closeGateways(), this.listeners = [], this.session = null, this.gateway = null; - } - disconnect(e) { - return Mt(this, void 0, void 0, function* () { - return new Promise((r) => Mt(this, void 0, void 0, function* () { - let n = !1, i = null; - const s = () => { - n || (n = !0, this.removeBridgeAndSession().then(r)); - }; - try { - this.closeGateways(); - const o = xs(e == null ? void 0 : e.signal); - i = setTimeout(() => { - o.abort(); - }, this.defaultOpeningDeadlineMS), yield this.sendRequest({ method: "disconnect", params: [] }, { - onRequestSent: s, - signal: o.signal, - attempts: 1 - }); - } catch (o) { - Sn("Disconnect error:", o), n || this.removeBridgeAndSession().then(r); - } finally { - i && clearTimeout(i), s(); - } - })); - }); - } - listen(e) { - return this.listeners.push(e), () => this.listeners = this.listeners.filter((r) => r !== e); - } - pause() { - var e; - (e = this.gateway) === null || e === void 0 || e.pause(), this.pendingGateways.forEach((r) => r.pause()); - } - unPause() { - return Mt(this, void 0, void 0, function* () { - const e = this.pendingGateways.map((r) => r.unPause()); - this.gateway && e.push(this.gateway.unPause()), yield Promise.all(e); - }); - } - pendingGatewaysListener(e, r, n) { - return Mt(this, void 0, void 0, function* () { - if (!this.pendingGateways.includes(e)) { - yield e.close(); - return; - } - return this.closeGateways({ except: e }), this.gateway && (Sn("Gateway is already opened, closing previous gateway"), yield this.gateway.close()), this.session.bridgeUrl = r, this.gateway = e, this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)), this.gateway.setListener(this.gatewayListener.bind(this)), this.gatewayListener(n); - }); - } - gatewayListener(e) { - return Mt(this, void 0, void 0, function* () { - const r = JSON.parse(this.session.sessionCrypto.decrypt(U9.decode(e.message).toUint8Array(), S0(e.from))); - if (Sn("Wallet message received:", r), !("event" in r)) { - const i = r.id.toString(), s = this.pendingRequests.get(i); - if (!s) { - Sn(`Response id ${i} doesn't match any request's id`); - return; - } - s(r), this.pendingRequests.delete(i); - return; - } - if (r.id !== void 0) { - const i = yield this.connectionStorage.getLastWalletEventId(); - if (i !== void 0 && r.id <= i) { - Oo(`Received event id (=${r.id}) must be greater than stored last wallet event id (=${i}) `); - return; - } - r.event !== "connect" && (yield this.connectionStorage.storeLastWalletEventId(r.id)); - } - const n = this.listeners; - r.event === "connect" && (yield this.updateSession(r, e.from)), r.event === "disconnect" && (Sn("Removing bridge and session: received disconnect event"), yield this.removeBridgeAndSession()), n.forEach((i) => i(r)); - }); - } - gatewayErrorsListener(e) { - return Mt(this, void 0, void 0, function* () { - throw new Ut(`Bridge error ${JSON.stringify(e)}`); - }); - } - updateSession(e, r) { - return Mt(this, void 0, void 0, function* () { - this.session = Object.assign(Object.assign({}, this.session), { walletPublicKey: r }); - const n = e.payload.items.find((s) => s.name === "ton_addr"), i = Object.assign(Object.assign({}, e), { payload: Object.assign(Object.assign({}, e.payload), { items: [n] }) }); - yield this.connectionStorage.storeConnection({ - type: "http", - session: this.session, - lastWalletEventId: e.id, - connectEvent: i, - nextRpcRequestId: 0 - }); - }); - } - removeBridgeAndSession() { - return Mt(this, void 0, void 0, function* () { - this.closeConnection(), yield this.connectionStorage.removeConnection(); - }); - } - generateUniversalLink(e, r) { - return _ie(e) ? this.generateTGUniversalLink(e, r) : this.generateRegularUniversalLink(e, r); - } - generateRegularUniversalLink(e, r) { - const n = new URL(e); - return n.searchParams.append("v", z9.toString()), n.searchParams.append("id", this.session.sessionCrypto.sessionId), n.searchParams.append("r", JSON.stringify(r)), n.toString(); - } - generateTGUniversalLink(e, r) { - const i = this.generateRegularUniversalLink("about:blank", r).split("?")[1], s = "tonconnect-" + Eie(i), o = this.convertToDirectLink(e), a = new URL(o); - return a.searchParams.append("startapp", s), a.toString(); - } - // TODO: Remove this method after all dApps and the wallets-list.json have been updated - convertToDirectLink(e) { - const r = new URL(e); - return r.searchParams.has("attach") && (r.searchParams.delete("attach"), r.pathname += "/start"), r.toString(); - } - openGateways(e, r) { - return Mt(this, void 0, void 0, function* () { - if (Array.isArray(this.walletConnectionSource)) { - this.pendingGateways.map((n) => n.close().catch()), this.pendingGateways = this.walletConnectionSource.map((n) => { - const i = new Vm(this.storage, n.bridgeUrl, e.sessionId, () => { - }, () => { - }); - return i.setListener((s) => this.pendingGatewaysListener(i, n.bridgeUrl, s)), i; - }), yield Promise.allSettled(this.pendingGateways.map((n) => Xf((i) => { - var s; - return this.pendingGateways.some((o) => o === n) ? n.registerSession({ - openingDeadlineMS: (s = r == null ? void 0 : r.openingDeadlineMS) !== null && s !== void 0 ? s : this.defaultOpeningDeadlineMS, - signal: i.signal - }) : n.close(); - }, { - attempts: Number.MAX_SAFE_INTEGER, - delayMs: this.defaultRetryTimeoutMS, - signal: r == null ? void 0 : r.signal - }))); - return; - } else - return this.gateway && (Sn("Gateway is already opened, closing previous gateway"), yield this.gateway.close()), this.gateway = new Vm(this.storage, this.walletConnectionSource.bridgeUrl, e.sessionId, this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this)), yield this.gateway.registerSession({ - openingDeadlineMS: r == null ? void 0 : r.openingDeadlineMS, - signal: r == null ? void 0 : r.signal - }); - }); - } - closeGateways(e) { - var r; - (r = this.gateway) === null || r === void 0 || r.close(), this.pendingGateways.filter((n) => n !== (e == null ? void 0 : e.except)).forEach((n) => n.close()), this.pendingGateways = []; - } -} -function m5(t, e) { - return H9(t, [e]); -} -function H9(t, e) { - return !t || typeof t != "object" ? !1 : e.every((r) => r in t); -} -function Iie(t) { - try { - return !m5(t, "tonconnect") || !m5(t.tonconnect, "walletInfo") ? !1 : H9(t.tonconnect.walletInfo, [ - "name", - "app_name", - "image", - "about_url", - "platforms" - ]); - } catch { - return !1; - } -} -class su { - constructor() { - this.storage = {}; - } - static getInstance() { - return su.instance || (su.instance = new su()), su.instance; - } - get length() { - return Object.keys(this.storage).length; - } - clear() { - this.storage = {}; - } - getItem(e) { - var r; - return (r = this.storage[e]) !== null && r !== void 0 ? r : null; - } - key(e) { - var r; - const n = Object.keys(this.storage); - return e < 0 || e >= n.length ? null : (r = n[e]) !== null && r !== void 0 ? r : null; - } - removeItem(e) { - delete this.storage[e]; - } - setItem(e, r) { - this.storage[e] = r; - } -} -function Cp() { - if (!(typeof window > "u")) - return window; -} -function Cie() { - const t = Cp(); - if (!t) - return []; - try { - return Object.keys(t); - } catch { - return []; - } -} -function Tie() { - if (!(typeof document > "u")) - return document; -} -function Rie() { - var t; - const e = (t = Cp()) === null || t === void 0 ? void 0 : t.location.origin; - return e ? e + "/tonconnect-manifest.json" : ""; -} -function Die() { - if (Oie()) - return localStorage; - if (Nie()) - throw new Ut("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector"); - return su.getInstance(); -} -function Oie() { - try { - return typeof localStorage < "u"; - } catch { - return !1; - } -} -function Nie() { - return typeof process < "u" && process.versions != null && process.versions.node != null; -} -class mi { - constructor(e, r) { - this.injectedWalletKey = r, this.type = "injected", this.unsubscribeCallback = null, this.listenSubscriptions = !1, this.listeners = []; - const n = mi.window; - if (!mi.isWindowContainsWallet(n, r)) - throw new fy(); - this.connectionStorage = new Dl(e), this.injectedWallet = n[r].tonconnect; - } - static fromStorage(e) { - return Mt(this, void 0, void 0, function* () { - const n = yield new Dl(e).getInjectedConnection(); - return new mi(e, n.jsBridgeKey); - }); - } - static isWalletInjected(e) { - return mi.isWindowContainsWallet(this.window, e); - } - static isInsideWalletBrowser(e) { - return mi.isWindowContainsWallet(this.window, e) ? this.window[e].tonconnect.isWalletBrowser : !1; - } - static getCurrentlyInjectedWallets() { - return this.window ? Cie().filter(([n, i]) => Iie(i)).map(([n, i]) => ({ - name: i.tonconnect.walletInfo.name, - appName: i.tonconnect.walletInfo.app_name, - aboutUrl: i.tonconnect.walletInfo.about_url, - imageUrl: i.tonconnect.walletInfo.image, - tondns: i.tonconnect.walletInfo.tondns, - jsBridgeKey: n, - injected: !0, - embedded: i.tonconnect.isWalletBrowser, - platforms: i.tonconnect.walletInfo.platforms - })) : []; - } - static isWindowContainsWallet(e, r) { - return !!e && r in e && typeof e[r] == "object" && "tonconnect" in e[r]; - } - connect(e) { - this._connect(z9, e); - } - restoreConnection() { - return Mt(this, void 0, void 0, function* () { - try { - Sn("Injected Provider restoring connection..."); - const e = yield this.injectedWallet.restoreConnection(); - Sn("Injected Provider restoring connection response", e), e.event === "connect" ? (this.makeSubscriptions(), this.listeners.forEach((r) => r(e))) : yield this.connectionStorage.removeConnection(); - } catch (e) { - yield this.connectionStorage.removeConnection(), console.error(e); - } - }); - } - closeConnection() { - this.listenSubscriptions && this.injectedWallet.disconnect(), this.closeAllListeners(); - } - disconnect() { - return Mt(this, void 0, void 0, function* () { - return new Promise((e) => { - const r = () => { - this.closeAllListeners(), this.connectionStorage.removeConnection().then(e); - }; - try { - this.injectedWallet.disconnect(), r(); - } catch (n) { - Sn(n), this.sendRequest({ - method: "disconnect", - params: [] - }, r); - } - }); - }); - } - closeAllListeners() { - var e; - this.listenSubscriptions = !1, this.listeners = [], (e = this.unsubscribeCallback) === null || e === void 0 || e.call(this); - } - listen(e) { - return this.listeners.push(e), () => this.listeners = this.listeners.filter((r) => r !== e); - } - sendRequest(e, r) { - var n; - return Mt(this, void 0, void 0, function* () { - const i = {}; - typeof r == "function" ? i.onRequestSent = r : (i.onRequestSent = r == null ? void 0 : r.onRequestSent, i.signal = r == null ? void 0 : r.signal); - const s = (yield this.connectionStorage.getNextRpcRequestId()).toString(); - yield this.connectionStorage.increaseNextRpcRequestId(), Sn("Send injected-bridge request:", Object.assign(Object.assign({}, e), { id: s })); - const o = this.injectedWallet.send(Object.assign(Object.assign({}, e), { id: s })); - return o.then((a) => Sn("Wallet message received:", a)), (n = i == null ? void 0 : i.onRequestSent) === null || n === void 0 || n.call(i), o; - }); - } - _connect(e, r) { - return Mt(this, void 0, void 0, function* () { - try { - Sn(`Injected Provider connect request: protocolVersion: ${e}, message:`, r); - const n = yield this.injectedWallet.connect(e, r); - Sn("Injected Provider connect response:", n), n.event === "connect" && (yield this.updateSession(), this.makeSubscriptions()), this.listeners.forEach((i) => i(n)); - } catch (n) { - Sn("Injected Provider connect error:", n); - const i = { - event: "connect_error", - payload: { - code: 0, - message: n == null ? void 0 : n.toString() - } - }; - this.listeners.forEach((s) => s(i)); - } - }); - } - makeSubscriptions() { - this.listenSubscriptions = !0, this.unsubscribeCallback = this.injectedWallet.listen((e) => { - Sn("Wallet message received:", e), this.listenSubscriptions && this.listeners.forEach((r) => r(e)), e.event === "disconnect" && this.disconnect(); - }); - } - updateSession() { - return this.connectionStorage.storeConnection({ - type: "injected", - jsBridgeKey: this.injectedWalletKey, - nextRpcRequestId: 0 - }); - } -} -mi.window = Cp(); -class Lie { - constructor() { - this.localStorage = Die(); - } - getItem(e) { - return Mt(this, void 0, void 0, function* () { - return this.localStorage.getItem(e); - }); - } - removeItem(e) { - return Mt(this, void 0, void 0, function* () { - this.localStorage.removeItem(e); - }); - } - setItem(e, r) { - return Mt(this, void 0, void 0, function* () { - this.localStorage.setItem(e, r); - }); - } -} -function W9(t) { - return $ie(t) && t.injected; -} -function kie(t) { - return W9(t) && t.embedded; -} -function $ie(t) { - return "jsBridgeKey" in t; -} -const Fie = [ - { - app_name: "telegram-wallet", - name: "Wallet", - image: "https://wallet.tg/images/logo-288.png", - about_url: "https://wallet.tg/", - universal_url: "https://t.me/wallet?attach=wallet", - bridge: [ - { - type: "sse", - url: "https://bridge.ton.space/bridge" - } - ], - platforms: ["ios", "android", "macos", "windows", "linux"] - }, - { - app_name: "tonkeeper", - name: "Tonkeeper", - image: "https://tonkeeper.com/assets/tonconnect-icon.png", - tondns: "tonkeeper.ton", - about_url: "https://tonkeeper.com", - universal_url: "https://app.tonkeeper.com/ton-connect", - deepLink: "tonkeeper-tc://", - bridge: [ - { - type: "sse", - url: "https://bridge.tonapi.io/bridge" - }, - { - type: "js", - key: "tonkeeper" - } - ], - platforms: ["ios", "android", "chrome", "firefox", "macos"] - }, - { - app_name: "mytonwallet", - name: "MyTonWallet", - image: "https://static.mytonwallet.io/icon-256.png", - about_url: "https://mytonwallet.io", - universal_url: "https://connect.mytonwallet.org", - bridge: [ - { - type: "js", - key: "mytonwallet" - }, - { - type: "sse", - url: "https://tonconnectbridge.mytonwallet.org/bridge/" - } - ], - platforms: ["chrome", "windows", "macos", "linux", "ios", "android", "firefox"] - }, - { - app_name: "openmask", - name: "OpenMask", - image: "https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png", - about_url: "https://www.openmask.app/", - bridge: [ - { - type: "js", - key: "openmask" - } - ], - platforms: ["chrome"] - }, - { - app_name: "tonhub", - name: "Tonhub", - image: "https://tonhub.com/tonconnect_logo.png", - about_url: "https://tonhub.com", - universal_url: "https://tonhub.com/ton-connect", - bridge: [ - { - type: "js", - key: "tonhub" - }, - { - type: "sse", - url: "https://connect.tonhubapi.com/tonconnect" - } - ], - platforms: ["ios", "android"] - }, - { - app_name: "dewallet", - name: "DeWallet", - image: "https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png", - about_url: "https://delabwallet.com", - universal_url: "https://t.me/dewallet?attach=wallet", - bridge: [ - { - type: "sse", - url: "https://sse-bridge.delab.team/bridge" - } - ], - platforms: ["ios", "android"] - }, - { - app_name: "xtonwallet", - name: "XTONWallet", - image: "https://xtonwallet.com/assets/img/icon-256-back.png", - about_url: "https://xtonwallet.com", - bridge: [ - { - type: "js", - key: "xtonwallet" - } - ], - platforms: ["chrome", "firefox"] - }, - { - app_name: "tonwallet", - name: "TON Wallet", - image: "https://wallet.ton.org/assets/ui/qr-logo.png", - about_url: "https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd", - bridge: [ - { - type: "js", - key: "tonwallet" - } - ], - platforms: ["chrome"] - }, - { - app_name: "bitgetTonWallet", - name: "Bitget Wallet", - image: "https://raw.githubusercontent.com/bitkeepwallet/download/main/logo/png/bitget_wallet_logo_0_gas_fee.png", - about_url: "https://web3.bitget.com", - deepLink: "bitkeep://", - bridge: [ - { - type: "js", - key: "bitgetTonWallet" - }, - { - type: "sse", - url: "https://bridge.tonapi.io/bridge" - } - ], - platforms: ["ios", "android", "chrome"], - universal_url: "https://bkcode.vip/ton-connect" - }, - { - app_name: "safepalwallet", - name: "SafePal", - image: "https://s.pvcliping.com/web/public_image/SafePal_x288.png", - tondns: "", - about_url: "https://www.safepal.com", - universal_url: "https://link.safepal.io/ton-connect", - deepLink: "safepal-tc://", - bridge: [ - { - type: "sse", - url: "https://ton-bridge.safepal.com/tonbridge/v1/bridge" - }, - { - type: "js", - key: "safepalwallet" - } - ], - platforms: ["ios", "android", "chrome", "firefox"] - }, - { - app_name: "okxTonWallet", - name: "OKX Wallet", - image: "https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png", - about_url: "https://www.okx.com/web3", - universal_url: "https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect", - bridge: [ - { - type: "js", - key: "okxTonWallet" - }, - { - type: "sse", - url: "https://www.okx.com/tonbridge/discover/rpc/bridge" - } - ], - platforms: ["chrome", "safari", "firefox", "ios", "android"] - }, - { - app_name: "okxTonWalletTr", - name: "OKX TR Wallet", - image: "https://static.okx.com/cdn/assets/imgs/247/587A8296F0BB640F.png", - about_url: "https://tr.okx.com/web3", - universal_url: "https://tr.okx.com/download?appendQuery=true&deeplink=okxtr://web3/wallet/tonconnect", - bridge: [ - { - type: "js", - key: "okxTonWallet" - }, - { - type: "sse", - url: "https://www.okx.com/tonbridge/discover/rpc/bridge" - } - ], - platforms: ["chrome", "safari", "firefox", "ios", "android"] - } -]; -class dv { - constructor(e) { - this.walletsListCache = null, this.walletsListCacheCreationTimestamp = null, this.walletsListSource = "https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json", e != null && e.walletsListSource && (this.walletsListSource = e.walletsListSource), e != null && e.cacheTTLMs && (this.cacheTTLMs = e.cacheTTLMs); - } - getWallets() { - return Mt(this, void 0, void 0, function* () { - return this.cacheTTLMs && this.walletsListCacheCreationTimestamp && Date.now() > this.walletsListCacheCreationTimestamp + this.cacheTTLMs && (this.walletsListCache = null), this.walletsListCache || (this.walletsListCache = this.fetchWalletsList(), this.walletsListCache.then(() => { - this.walletsListCacheCreationTimestamp = Date.now(); - }).catch(() => { - this.walletsListCache = null, this.walletsListCacheCreationTimestamp = null; - })), this.walletsListCache; - }); - } - getEmbeddedWallet() { - return Mt(this, void 0, void 0, function* () { - const r = (yield this.getWallets()).filter(kie); - return r.length !== 1 ? null : r[0]; - }); - } - fetchWalletsList() { - return Mt(this, void 0, void 0, function* () { - let e = []; - try { - if (e = yield (yield fetch(this.walletsListSource)).json(), !Array.isArray(e)) - throw new ly("Wrong wallets list format, wallets list must be an array."); - const i = e.filter((s) => !this.isCorrectWalletConfigDTO(s)); - i.length && (Oo(`Wallet(s) ${i.map((s) => s.name).join(", ")} config format is wrong. They were removed from the wallets list.`), e = e.filter((s) => this.isCorrectWalletConfigDTO(s))); - } catch (n) { - Oo(n), e = Fie; - } - let r = []; - try { - r = mi.getCurrentlyInjectedWallets(); - } catch (n) { - Oo(n); - } - return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e), r); - }); - } - walletConfigDTOListToWalletConfigList(e) { - return e.map((r) => { - const i = { - name: r.name, - appName: r.app_name, - imageUrl: r.image, - aboutUrl: r.about_url, - tondns: r.tondns, - platforms: r.platforms - }; - return r.bridge.forEach((s) => { - if (s.type === "sse" && (i.bridgeUrl = s.url, i.universalLink = r.universal_url, i.deepLink = r.deepLink), s.type === "js") { - const o = s.key; - i.jsBridgeKey = o, i.injected = mi.isWalletInjected(o), i.embedded = mi.isInsideWalletBrowser(o); - } - }), i; - }); - } - mergeWalletsLists(e, r) { - return [...new Set(e.concat(r).map((i) => i.name)).values()].map((i) => { - const s = e.find((a) => a.name === i), o = r.find((a) => a.name === i); - return Object.assign(Object.assign({}, s && Object.assign({}, s)), o && Object.assign({}, o)); - }); - } - // eslint-disable-next-line complexity - isCorrectWalletConfigDTO(e) { - if (!e || typeof e != "object") - return !1; - const r = "name" in e, n = "app_name" in e, i = "image" in e, s = "about_url" in e, o = "platforms" in e; - if (!r || !i || !s || !o || !n || !e.platforms || !Array.isArray(e.platforms) || !e.platforms.length || !("bridge" in e) || !Array.isArray(e.bridge) || !e.bridge.length) - return !1; - const a = e.bridge; - if (a.some((d) => !d || typeof d != "object" || !("type" in d))) - return !1; - const u = a.find((d) => d.type === "sse"); - if (u && (!("url" in u) || !u.url || !e.universal_url)) - return !1; - const l = a.find((d) => d.type === "js"); - return !(l && (!("key" in l) || !l.key)); - } -} -class P0 extends Ut { - get info() { - return "Wallet doesn't support requested feature method."; - } - constructor(...e) { - super(...e), Object.setPrototypeOf(this, P0.prototype); - } -} -function Bie(t, e) { - const r = t.includes("SendTransaction"), n = t.find((i) => i && typeof i == "object" && i.name === "SendTransaction"); - if (!r && !n) - throw new P0("Wallet doesn't support SendTransaction feature."); - if (n && n.maxMessages !== void 0) { - if (n.maxMessages < e.requiredMessagesNumber) - throw new P0(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${n.maxMessages}, but ${e.requiredMessagesNumber} is required.`); - return; - } - Sie("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet."); -} -function Uie() { - return { - type: "request-version" - }; -} -function jie(t) { - return { - type: "response-version", - version: t - }; -} -function Gu(t) { - return { - ton_connect_sdk_lib: t.ton_connect_sdk_lib, - ton_connect_ui_lib: t.ton_connect_ui_lib - }; -} -function Yu(t, e) { - var r, n, i, s, o, a, u, l; - const g = ((r = e == null ? void 0 : e.connectItems) === null || r === void 0 ? void 0 : r.tonProof) && "proof" in e.connectItems.tonProof ? "ton_proof" : "ton_addr"; - return { - wallet_address: (i = (n = e == null ? void 0 : e.account) === null || n === void 0 ? void 0 : n.address) !== null && i !== void 0 ? i : null, - wallet_type: (s = e == null ? void 0 : e.device.appName) !== null && s !== void 0 ? s : null, - wallet_version: (o = e == null ? void 0 : e.device.appVersion) !== null && o !== void 0 ? o : null, - auth_type: g, - custom_data: Object.assign({ chain_id: (u = (a = e == null ? void 0 : e.account) === null || a === void 0 ? void 0 : a.chain) !== null && u !== void 0 ? u : null, provider: (l = e == null ? void 0 : e.provider) !== null && l !== void 0 ? l : null }, Gu(t)) - }; -} -function qie(t) { - return { - type: "connection-started", - custom_data: Gu(t) - }; -} -function zie(t, e) { - return Object.assign({ type: "connection-completed", is_success: !0 }, Yu(t, e)); -} -function Hie(t, e, r) { - return { - type: "connection-error", - is_success: !1, - error_message: e, - error_code: r ?? null, - custom_data: Gu(t) - }; -} -function Wie(t) { - return { - type: "connection-restoring-started", - custom_data: Gu(t) - }; -} -function Kie(t, e) { - return Object.assign({ type: "connection-restoring-completed", is_success: !0 }, Yu(t, e)); -} -function Vie(t, e) { - return { - type: "connection-restoring-error", - is_success: !1, - error_message: e, - custom_data: Gu(t) - }; -} -function hy(t, e) { - var r, n, i, s; - return { - valid_until: (r = String(e.validUntil)) !== null && r !== void 0 ? r : null, - from: (s = (n = e.from) !== null && n !== void 0 ? n : (i = t == null ? void 0 : t.account) === null || i === void 0 ? void 0 : i.address) !== null && s !== void 0 ? s : null, - messages: e.messages.map((o) => { - var a, u; - return { - address: (a = o.address) !== null && a !== void 0 ? a : null, - amount: (u = o.amount) !== null && u !== void 0 ? u : null - }; - }) - }; -} -function Gie(t, e, r) { - return Object.assign(Object.assign({ type: "transaction-sent-for-signature" }, Yu(t, e)), hy(e, r)); -} -function Yie(t, e, r, n) { - return Object.assign(Object.assign({ type: "transaction-signed", is_success: !0, signed_transaction: n.boc }, Yu(t, e)), hy(e, r)); -} -function Jie(t, e, r, n, i) { - return Object.assign(Object.assign({ type: "transaction-signing-failed", is_success: !1, error_message: n, error_code: i ?? null }, Yu(t, e)), hy(e, r)); -} -function Xie(t, e, r) { - return Object.assign({ type: "disconnection", scope: r }, Yu(t, e)); -} -class Zie { - constructor() { - this.window = Cp(); - } - /** - * Dispatches an event with the given name and details to the browser window. - * @param eventName - The name of the event to dispatch. - * @param eventDetails - The details of the event to dispatch. - * @returns A promise that resolves when the event has been dispatched. - */ - dispatchEvent(e, r) { - var n; - return Mt(this, void 0, void 0, function* () { - const i = new CustomEvent(e, { detail: r }); - (n = this.window) === null || n === void 0 || n.dispatchEvent(i); - }); - } - /** - * Adds an event listener to the browser window. - * @param eventName - The name of the event to listen for. - * @param listener - The listener to add. - * @param options - The options for the listener. - * @returns A function that removes the listener. - */ - addEventListener(e, r, n) { - var i; - return Mt(this, void 0, void 0, function* () { - return (i = this.window) === null || i === void 0 || i.addEventListener(e, r, n), () => { - var s; - return (s = this.window) === null || s === void 0 ? void 0 : s.removeEventListener(e, r); - }; - }); - } -} -class Qie { - constructor(e) { - var r; - this.eventPrefix = "ton-connect-", this.tonConnectUiVersion = null, this.eventDispatcher = (r = e == null ? void 0 : e.eventDispatcher) !== null && r !== void 0 ? r : new Zie(), this.tonConnectSdkVersion = e.tonConnectSdkVersion, this.init().catch(); - } - /** - * Version of the library. - */ - get version() { - return Gu({ - ton_connect_sdk_lib: this.tonConnectSdkVersion, - ton_connect_ui_lib: this.tonConnectUiVersion - }); - } - /** - * Called once when the tracker is created and request version other libraries. - */ - init() { - return Mt(this, void 0, void 0, function* () { - try { - yield this.setRequestVersionHandler(), this.tonConnectUiVersion = yield this.requestTonConnectUiVersion(); - } catch { - } - }); - } - /** - * Set request version handler. - * @private - */ - setRequestVersionHandler() { - return Mt(this, void 0, void 0, function* () { - yield this.eventDispatcher.addEventListener("ton-connect-request-version", () => Mt(this, void 0, void 0, function* () { - yield this.eventDispatcher.dispatchEvent("ton-connect-response-version", jie(this.tonConnectSdkVersion)); - })); - }); - } - /** - * Request TonConnect UI version. - * @private - */ - requestTonConnectUiVersion() { - return Mt(this, void 0, void 0, function* () { - return new Promise((e, r) => Mt(this, void 0, void 0, function* () { - try { - yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version", (n) => { - e(n.detail.version); - }, { once: !0 }), yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version", Uie()); - } catch (n) { - r(n); - } - })); - }); - } - /** - * Emit user action event to the window. - * @param eventDetails - * @private - */ - dispatchUserActionEvent(e) { - try { - this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`, e).catch(); - } catch { - } - } - /** - * Track connection init event. - * @param args - */ - trackConnectionStarted(...e) { - try { - const r = qie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } - /** - * Track connection success event. - * @param args - */ - trackConnectionCompleted(...e) { - try { - const r = zie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } - /** - * Track connection error event. - * @param args - */ - trackConnectionError(...e) { - try { - const r = Hie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } - /** - * Track connection restoring init event. - * @param args - */ - trackConnectionRestoringStarted(...e) { - try { - const r = Wie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } - /** - * Track connection restoring success event. - * @param args - */ - trackConnectionRestoringCompleted(...e) { - try { - const r = Kie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } - /** - * Track connection restoring error event. - * @param args - */ - trackConnectionRestoringError(...e) { - try { - const r = Vie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } - /** - * Track disconnect event. - * @param args - */ - trackDisconnection(...e) { - try { - const r = Xie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } - /** - * Track transaction init event. - * @param args - */ - trackTransactionSentForSignature(...e) { - try { - const r = Gie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } - /** - * Track transaction signed event. - * @param args - */ - trackTransactionSigned(...e) { - try { - const r = Yie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } - /** - * Track transaction error event. - * @param args - */ - trackTransactionSigningFailed(...e) { - try { - const r = Jie(this.version, ...e); - this.dispatchUserActionEvent(r); - } catch { - } - } -} -const ese = "3.0.5"; -class Tp { - constructor(e) { - if (this.walletsList = new dv(), this._wallet = null, this.provider = null, this.statusChangeSubscriptions = [], this.statusChangeErrorSubscriptions = [], this.dappSettings = { - manifestUrl: (e == null ? void 0 : e.manifestUrl) || Rie(), - storage: (e == null ? void 0 : e.storage) || new Lie() - }, this.walletsList = new dv({ - walletsListSource: e == null ? void 0 : e.walletsListSource, - cacheTTLMs: e == null ? void 0 : e.walletsListCacheTTLMs - }), this.tracker = new Qie({ - eventDispatcher: e == null ? void 0 : e.eventDispatcher, - tonConnectSdkVersion: ese - }), !this.dappSettings.manifestUrl) - throw new cy("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"); - this.bridgeConnectionStorage = new Dl(this.dappSettings.storage), e != null && e.disableAutoPauseConnection || this.addWindowFocusAndBlurSubscriptions(); - } - /** - * Returns available wallets list. - */ - static getWallets() { - return this.walletsList.getWallets(); - } - /** - * Shows if the wallet is connected right now. - */ - get connected() { - return this._wallet !== null; - } - /** - * Current connected account or null if no account is connected. - */ - get account() { - var e; - return ((e = this._wallet) === null || e === void 0 ? void 0 : e.account) || null; - } - /** - * Current connected wallet or null if no account is connected. - */ - get wallet() { - return this._wallet; - } - set wallet(e) { - this._wallet = e, this.statusChangeSubscriptions.forEach((r) => r(this._wallet)); - } - /** - * Returns available wallets list. - */ - getWallets() { - return this.walletsList.getWallets(); - } - /** - * Allows to subscribe to connection status changes and handle connection errors. - * @param callback will be called after connections status changes with actual wallet or null. - * @param errorsHandler (optional) will be called with some instance of TonConnectError when connect error is received. - * @returns unsubscribe callback. - */ - onStatusChange(e, r) { - return this.statusChangeSubscriptions.push(e), r && this.statusChangeErrorSubscriptions.push(r), () => { - this.statusChangeSubscriptions = this.statusChangeSubscriptions.filter((n) => n !== e), r && (this.statusChangeErrorSubscriptions = this.statusChangeErrorSubscriptions.filter((n) => n !== r)); - }; - } - connect(e, r) { - var n, i; - const s = {}; - if (typeof r == "object" && "tonProof" in r && (s.request = r), typeof r == "object" && ("openingDeadlineMS" in r || "signal" in r || "request" in r) && (s.request = r == null ? void 0 : r.request, s.openingDeadlineMS = r == null ? void 0 : r.openingDeadlineMS, s.signal = r == null ? void 0 : r.signal), this.connected) - throw new uy(); - const o = xs(s == null ? void 0 : s.signal); - if ((n = this.abortController) === null || n === void 0 || n.abort(), this.abortController = o, o.signal.aborted) - throw new Ut("Connection was aborted"); - return (i = this.provider) === null || i === void 0 || i.closeConnection(), this.provider = this.createProvider(e), o.signal.addEventListener("abort", () => { - var a; - (a = this.provider) === null || a === void 0 || a.closeConnection(), this.provider = null; - }), this.tracker.trackConnectionStarted(), this.provider.connect(this.createConnectRequest(s == null ? void 0 : s.request), { - openingDeadlineMS: s == null ? void 0 : s.openingDeadlineMS, - signal: o.signal - }); - } - /** - * Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded. - */ - restoreConnection(e) { - var r, n; - return Mt(this, void 0, void 0, function* () { - this.tracker.trackConnectionRestoringStarted(); - const i = xs(e == null ? void 0 : e.signal); - if ((r = this.abortController) === null || r === void 0 || r.abort(), this.abortController = i, i.signal.aborted) { - this.tracker.trackConnectionRestoringError("Connection restoring was aborted"); - return; - } - const [s, o] = yield Promise.all([ - this.bridgeConnectionStorage.storedConnectionType(), - this.walletsList.getEmbeddedWallet() - ]); - if (i.signal.aborted) { - this.tracker.trackConnectionRestoringError("Connection restoring was aborted"); - return; - } - let a = null; - try { - switch (s) { - case "http": - a = yield Ol.fromStorage(this.dappSettings.storage); - break; - case "injected": - a = yield mi.fromStorage(this.dappSettings.storage); - break; - default: - if (o) - a = this.createProvider(o); - else - return; - } - } catch { - this.tracker.trackConnectionRestoringError("Provider is not restored"), yield this.bridgeConnectionStorage.removeConnection(), a == null || a.closeConnection(), a = null; - return; - } - if (i.signal.aborted) { - a == null || a.closeConnection(), this.tracker.trackConnectionRestoringError("Connection restoring was aborted"); - return; - } - if (!a) { - Oo("Provider is not restored"), this.tracker.trackConnectionRestoringError("Provider is not restored"); - return; - } - (n = this.provider) === null || n === void 0 || n.closeConnection(), this.provider = a, a.listen(this.walletEventsListener.bind(this)); - const u = () => { - this.tracker.trackConnectionRestoringError("Connection restoring was aborted"), a == null || a.closeConnection(), a = null; - }; - i.signal.addEventListener("abort", u); - const l = Xf((g) => Mt(this, void 0, void 0, function* () { - yield a == null ? void 0 : a.restoreConnection({ - openingDeadlineMS: e == null ? void 0 : e.openingDeadlineMS, - signal: g.signal - }), i.signal.removeEventListener("abort", u), this.connected ? this.tracker.trackConnectionRestoringCompleted(this.wallet) : this.tracker.trackConnectionRestoringError("Connection restoring failed"); - }), { - attempts: Number.MAX_SAFE_INTEGER, - delayMs: 2e3, - signal: e == null ? void 0 : e.signal - }), d = new Promise( - (g) => setTimeout(() => g(), 12e3) - // connection deadline - ); - return Promise.race([l, d]); - }); - } - sendTransaction(e, r) { - return Mt(this, void 0, void 0, function* () { - const n = {}; - typeof r == "function" ? n.onRequestSent = r : (n.onRequestSent = r == null ? void 0 : r.onRequestSent, n.signal = r == null ? void 0 : r.signal); - const i = xs(n == null ? void 0 : n.signal); - if (i.signal.aborted) - throw new Ut("Transaction sending was aborted"); - this.checkConnection(), Bie(this.wallet.device.features, { - requiredMessagesNumber: e.messages.length - }), this.tracker.trackTransactionSentForSignature(this.wallet, e); - const { validUntil: s } = e, o = pie(e, ["validUntil"]), a = e.from || this.account.address, u = e.network || this.account.chain, l = yield this.provider.sendRequest(yd.convertToRpcRequest(Object.assign(Object.assign({}, o), { - valid_until: s, - from: a, - network: u - })), { onRequestSent: n.onRequestSent, signal: i.signal }); - if (yd.isError(l)) - return this.tracker.trackTransactionSigningFailed(this.wallet, e, l.error.message, l.error.code), yd.parseAndThrowError(l); - const d = yd.convertFromRpcResponse(l); - return this.tracker.trackTransactionSigned(this.wallet, e, d), d; - }); - } - /** - * Disconnect form thw connected wallet and drop current session. - */ - disconnect(e) { - var r; - return Mt(this, void 0, void 0, function* () { - if (!this.connected) - throw new A0(); - const n = xs(e == null ? void 0 : e.signal), i = this.abortController; - if (this.abortController = n, n.signal.aborted) - throw new Ut("Disconnect was aborted"); - this.onWalletDisconnected("dapp"), yield (r = this.provider) === null || r === void 0 ? void 0 : r.disconnect({ - signal: n.signal - }), i == null || i.abort(); - }); - } - /** - * Pause bridge HTTP connection. Might be helpful, if you want to pause connections while browser tab is unfocused, - * or if you use SDK with NodeJS and want to save server resources. - */ - pauseConnection() { - var e; - ((e = this.provider) === null || e === void 0 ? void 0 : e.type) === "http" && this.provider.pause(); - } - /** - * Unpause bridge HTTP connection if it is paused. - */ - unPauseConnection() { - var e; - return ((e = this.provider) === null || e === void 0 ? void 0 : e.type) !== "http" ? Promise.resolve() : this.provider.unPause(); - } - addWindowFocusAndBlurSubscriptions() { - const e = Tie(); - if (e) - try { - e.addEventListener("visibilitychange", () => { - e.hidden ? this.pauseConnection() : this.unPauseConnection().catch(); - }); - } catch (r) { - Oo("Cannot subscribe to the document.visibilitychange: ", r); - } - } - createProvider(e) { - let r; - return !Array.isArray(e) && gie(e) ? r = new mi(this.dappSettings.storage, e.jsBridgeKey) : r = new Ol(this.dappSettings.storage, e), r.listen(this.walletEventsListener.bind(this)), r; - } - walletEventsListener(e) { - switch (e.event) { - case "connect": - this.onWalletConnected(e.payload); - break; - case "connect_error": - this.onWalletConnectError(e.payload); - break; - case "disconnect": - this.onWalletDisconnected("wallet"); - } - } - onWalletConnected(e) { - const r = e.items.find((s) => s.name === "ton_addr"), n = e.items.find((s) => s.name === "ton_proof"); - if (!r) - throw new Ut("ton_addr connection item was not found"); - const i = { - device: e.device, - provider: this.provider.type, - account: { - address: r.address, - chain: r.network, - walletStateInit: r.walletStateInit, - publicKey: r.publicKey - } - }; - n && (i.connectItems = { - tonProof: n - }), this.wallet = i, this.tracker.trackConnectionCompleted(i); - } - onWalletConnectError(e) { - const r = vie.parseError(e); - if (this.statusChangeErrorSubscriptions.forEach((n) => n(r)), Sn(r), this.tracker.trackConnectionError(e.message, e.code), r instanceof Ap || r instanceof Sp) - throw Oo(r), r; - } - onWalletDisconnected(e) { - this.tracker.trackDisconnection(this.wallet, e), this.wallet = null; - } - checkConnection() { - if (!this.connected) - throw new A0(); - } - createConnectRequest(e) { - const r = [ - { - name: "ton_addr" - } - ]; - return e != null && e.tonProof && r.push({ - name: "ton_proof", - payload: e.tonProof - }), { - manifestUrl: this.dappSettings.manifestUrl, - items: r - }; - } -} -Tp.walletsList = new dv(); -Tp.isWalletInjected = (t) => mi.isWalletInjected(t); -Tp.isInsideWalletBrowser = (t) => mi.isInsideWalletBrowser(t); -for (let t = 0; t <= 255; t++) { - let e = t.toString(16); - e.length < 2 && (e = "0" + e); -} -function Gm(t) { - const { children: e, onClick: r } = t; - return /* @__PURE__ */ me.jsx("button", { onClick: r, className: "xc-border xc-px-4 xc-py-2 xc-rounded-full xc-text-sm xc-flex xc-gap-2 xc-items-center", children: e }); -} -function tse(t) { - const { wallet: e, connector: r, loading: n } = t, i = bi(null), s = bi(), [o, a] = fr(), [u, l] = fr(), [d, g] = fr("connect"), [w, A] = fr(!1), [M, N] = fr(); - function L(W) { - var pe; - (pe = s.current) == null || pe.update({ - data: W - }); - } - async function F() { - A(!0); - try { - a(""); - const W = await ya.getNonce({ account_type: "block_chain" }); - if ("universalLink" in e && e.universalLink) { - const pe = r.connect({ - universalLink: e.universalLink, - bridgeUrl: e.bridgeUrl - }, { - request: { tonProof: W } - }); - if (!pe) return; - N(pe), L(pe), l(W); - } - } catch (W) { - a(W.message); - } - A(!1); - } - function $() { - s.current = new L9({ - width: 264, - height: 264, - margin: 0, - type: "svg", - qrOptions: { - errorCorrectionLevel: "M" - }, - dotsOptions: { - color: "black", - type: "rounded" - }, - backgroundOptions: { - color: "transparent" - } - }), s.current.append(i.current); - } - function K() { - r.connect(e, { - request: { tonProof: u } - }); - } - function H() { - if ("deepLink" in e) { - if (!e.deepLink || !M) return; - const W = new URL(M), pe = `${e.deepLink}${W.search}`; - window.open(pe); - } - } - function V() { - "universalLink" in e && e.universalLink && /t.me/.test(e.universalLink) && window.open(M); - } - const te = Oi(() => !!("deepLink" in e && e.deepLink), [e]), R = Oi(() => !!("universalLink" in e && e.universalLink && /t.me/.test(e.universalLink)), [e]); - return Xn(() => { - $(), F(); - }, []), /* @__PURE__ */ me.jsxs(Ac, { children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-mb-6", children: /* @__PURE__ */ me.jsx(uh, { title: "Connect wallet", onBack: t.onBack }) }), - /* @__PURE__ */ me.jsxs("div", { className: "xc-text-center xc-mb-6", children: [ - /* @__PURE__ */ me.jsxs("div", { className: "xc-relative xc-mx-auto xc-mb-6 xc-block xc-max-h-[272px] xc-max-w-[272px] xc-rounded-xl xc-bg-white xc-p-1", children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-aspect-[1/1] xc-flex xc-h-full xc-w-full xc-justify-center", ref: i }), - /* @__PURE__ */ me.jsx("div", { className: "xc-absolute xc-left-0 xc-top-0 xc-flex xc-h-full xc-w-full xc-items-center xc-justify-center", children: w ? /* @__PURE__ */ me.jsx(gc, { className: "xc-h-6 xc-w-6 xc-animate-spin xc-text-black", size: 20 }) : /* @__PURE__ */ me.jsx("img", { className: "xc-h-10 xc-w-10 xc-rounded-md", src: e.imageUrl }) }) - ] }), - /* @__PURE__ */ me.jsx("p", { className: "xc-text-center", children: "Scan the QR code below with your phone's camera. " }) - ] }), - /* @__PURE__ */ me.jsxs("div", { className: "xc-flex xc-justify-center xc-gap-2", children: [ - n && /* @__PURE__ */ me.jsx(gc, { className: "xc-animate-spin" }), - !w && !n && /* @__PURE__ */ me.jsxs(me.Fragment, { children: [ - W9(e) && /* @__PURE__ */ me.jsxs(Gm, { onClick: K, children: [ - /* @__PURE__ */ me.jsx(iZ, { className: "xc-opacity-80" }), - "Extension" - ] }), - te && /* @__PURE__ */ me.jsxs(Gm, { onClick: H, children: [ - /* @__PURE__ */ me.jsx(HS, { className: "xc-opacity-80" }), - "Desktop" - ] }), - R && /* @__PURE__ */ me.jsx(Gm, { onClick: V, children: "Telegram Mini App" }) - ] }) - ] }) - ] }); -} -function rse(t) { - const [e, r] = fr(""), [n, i] = fr(), [s, o] = fr(), a = ay(), [u, l] = fr(!1); - async function d(w) { - var M, N; - if (!w || !((M = w.connectItems) != null && M.tonProof)) return; - l(!0); - const A = await ya.tonLogin({ - account_type: "block_chain", - connector: "codatta_ton", - account_enum: "C", - wallet_name: w == null ? void 0 : w.device.appName, - inviter_code: a.inviterCode, - address: w.account.address, - chain: w.account.chain, - connect_info: [ - { name: "ton_addr", network: w.account.chain, ...w.account }, - (N = w.connectItems) == null ? void 0 : N.tonProof - ], - source: { - device: a.device, - channel: a.channel, - app: a.app - } - }); - await t.onLogin(A.data), l(!1); - } - Xn(() => { - const w = new Tp({ - manifestUrl: "https://static.codatta.io/static/tonconnect-manifest.json?v=2" - }), A = w.onStatusChange(d); - return o(w), r("select"), A; - }, []); - function g(w) { - r("connect"), i(w); - } - return /* @__PURE__ */ me.jsxs(Ac, { children: [ - e === "select" && /* @__PURE__ */ me.jsx( - sie, - { - connector: s, - onSelect: g, - onBack: t.onBack - } - ), - e === "connect" && /* @__PURE__ */ me.jsx( - tse, - { - connector: s, - wallet: n, - onBack: t.onBack, - loading: u - } - ) - ] }); -} -function nse(t) { - const { children: e, className: r } = t, n = bi(null), [i, s] = pv.useState(0); - function o() { - var a; - try { - const u = ((a = n.current) == null ? void 0 : a.children) || []; - let l = 0; - for (let d = 0; d < u.length; d++) - l += u[d].offsetHeight; - s(l); - } catch (u) { - console.error(u); - } - } - return Xn(() => { - const a = new MutationObserver(o); - return a.observe(n.current, { childList: !0, subtree: !0 }), () => a.disconnect(); - }, []), Xn(() => { - console.log("maxHeight", i); - }, [i]), /* @__PURE__ */ me.jsx( - "div", - { - ref: n, - className: r, - style: { - transition: "all 0.2s ease-in-out", - overflow: "hidden", - height: i - }, - children: e - } - ); -} -function ise() { - return /* @__PURE__ */ me.jsxs("svg", { width: "121", height: "120", viewBox: "0 0 121 120", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [ - /* @__PURE__ */ me.jsx("rect", { x: "0.5", width: "120", height: "120", rx: "60", fill: "#404049" }), - /* @__PURE__ */ me.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M52.8709 61.106C52.8208 61.4482 52.7948 61.7979 52.7948 62.1535C52.7948 66.2529 56.2445 69.5761 60.5 69.5761C64.7554 69.5761 68.2052 66.2529 68.2052 62.1535C68.2052 61.7979 68.1792 61.4482 68.129 61.106H86.826V77.6174C86.826 78.6422 85.9636 79.473 84.8997 79.473H36.1002C35.0364 79.473 34.174 78.6422 34.174 77.6174V61.106H52.8709Z", fill: "#252532" }), - /* @__PURE__ */ me.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M69.061 60.9416C69.061 65.6697 65.2281 69.5026 60.5 69.5026C55.7719 69.5026 51.939 65.6697 51.939 60.9416C51.939 60.7884 51.943 60.6362 51.951 60.485H33.5L39.7959 41.8696C40.0673 41.0671 40.8202 40.527 41.6674 40.527H79.3326C80.1798 40.527 80.9327 41.0671 81.2041 41.8696L87.5 60.485H69.049C69.057 60.6362 69.061 60.7884 69.061 60.9416Z", fill: "#252532" }), - /* @__PURE__ */ me.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M67.8081 61.5708C67.8081 65.2243 64.5361 68.8446 60.4999 68.8446C56.4637 68.8446 53.1918 65.2243 53.1918 61.5708C53.1918 61.4524 53.1952 60.6762 53.202 60.5594H39.4268L44.8013 47.4919C45.033 46.8717 45.6757 46.4543 46.3989 46.4543H74.601C75.3242 46.4543 75.9669 46.8717 76.1986 47.4919L81.5731 60.5594H67.7979C67.8046 60.6762 67.8081 61.4524 67.8081 61.5708Z", fill: "#404049" }), - /* @__PURE__ */ me.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M34.3232 60.6199V78.063C34.3232 78.6995 34.8392 79.2155 35.4757 79.2155H85.5245C86.1609 79.2155 86.6769 78.6995 86.6769 78.063V60.6199L80.4244 42.1328C80.2661 41.6647 79.8269 41.3496 79.3327 41.3496H41.6674C41.1733 41.3496 40.7341 41.6647 40.5758 42.1328L34.3232 60.6199Z", stroke: "#77777D", "stroke-width": "2" }), - /* @__PURE__ */ me.jsx("path", { d: "M34.817 60.2823C37.4094 60.2823 48.1095 60.2823 51.1124 60.2823C52.348 60.2823 52.348 61.1507 52.348 61.5994C52.348 65.9638 55.9675 69.5019 60.4323 69.5019C64.8971 69.5019 68.5165 65.9638 68.5165 61.5994C68.5165 61.1507 68.5165 60.2823 69.7521 60.2823H86.1829", stroke: "#77777D", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }) - ] }); -} -function sse(t) { - const { wallets: e } = gp(), [r, n] = fr(), i = Oi(() => r ? e.filter((a) => a.key.toLowerCase().includes(r.toLowerCase())) : e, [r]); - function s(a) { - t.onSelectWallet(a); - } - function o(a) { - n(a.target.value); - } - return /* @__PURE__ */ me.jsxs(Ac, { children: [ - /* @__PURE__ */ me.jsx("div", { className: "xc-mb-6", children: /* @__PURE__ */ me.jsx(uh, { title: "Select wallet", onBack: t.onBack }) }), - /* @__PURE__ */ me.jsxs("div", { className: "xc-mb-6 xc-flex xc-gap-3 xc-px-4 xc-py-2 xc-border xc-rounded-xl xc-w-full xc-overflow-hidden xc-items-center xc-border-opacity-15 xc-border-white focus-within:xc-border-opacity-40", children: [ - /* @__PURE__ */ me.jsx(WS, { className: "xc-shrink-0 xc-opacity-50" }), - /* @__PURE__ */ me.jsx("input", { type: "text", className: "xc-flex-1 xc-bg-transparent xc-appearance-none xc-outline-none", placeholder: "Search wallet", onInput: o }) - ] }), - /* @__PURE__ */ me.jsx("div", { className: "xc-mb-4 xc-flex xc-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar", children: i.length ? i.map((a) => /* @__PURE__ */ me.jsx( - b9, - { - wallet: a, - onClick: s - }, - `feature-${a.key}` - )) : /* @__PURE__ */ me.jsx(ise, {}) }) - ] }); -} -function doe(t) { - const { onLogin: e, header: r, showEmailSignIn: n = !0, showMoreWallets: i = !0, showTonConnect: s = !0, showFeaturedWallets: o = !0 } = t, [a, u] = fr(""), [l, d] = fr(null), [g, w] = fr(""); - function A(F) { - d(F), u("evm-wallet"); - } - function M(F) { - u("email"), w(F); - } - async function N(F) { - await e(F); - } - function L() { - u("ton-wallet"); - } - return Xn(() => { - u("index"); - }, []), /* @__PURE__ */ me.jsx(Dne, { config: t.config, children: /* @__PURE__ */ me.jsxs(nse, { className: "xc-rounded-2xl xc-transition-height xc-box-content xc-w-full xc-min-w-[277px] xc-max-w-[420px] xc-p-6 xc-bg-[rgb(28,28,38)] xc-text-white", children: [ - a === "evm-wallet" && /* @__PURE__ */ me.jsx( - nie, - { - onBack: () => u("index"), - onLogin: N, - wallet: l - } - ), - a === "ton-wallet" && /* @__PURE__ */ me.jsx( - rse, - { - onBack: () => u("index"), - onLogin: N - } - ), - a === "email" && /* @__PURE__ */ me.jsx(One, { email: g, onBack: () => u("index"), onLogin: N }), - a === "index" && /* @__PURE__ */ me.jsx( - vne, - { - header: r, - onEmailConfirm: M, - onSelectWallet: A, - onSelectMoreWallets: () => { - u("all-wallet"); - }, - onSelectTonConnect: L, - config: { - showEmailSignIn: n, - showFeaturedWallets: o, - showMoreWallets: i, - showTonConnect: s - } - } - ), - a === "all-wallet" && /* @__PURE__ */ me.jsx( - sse, - { - onBack: () => u("index"), - onSelectWallet: A - } - ) - ] }) }); -} -export { - loe as C, - M5 as H, - JX as a, - Nl as b, - use as c, - doe as d, - Hd as e, - cse as h, - fse as r, - r4 as s, - I0 as t, - gp as u -}; diff --git a/dist/main-CtRNJ0s5.js b/dist/main-CtRNJ0s5.js new file mode 100644 index 0000000..dc86cf4 --- /dev/null +++ b/dist/main-CtRNJ0s5.js @@ -0,0 +1,44353 @@ +import * as Jt from "react"; +import Wv, { createContext as Xo, useContext as In, useState as Xt, useEffect as Rn, forwardRef as Kv, createElement as sd, useId as Vv, useCallback as Gv, Component as lT, useLayoutEffect as hT, useRef as Kn, useInsertionEffect as H5, useMemo as hi, Fragment as W5, Children as dT, isValidElement as pT } from "react"; +import "https://o.alicdn.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js"; +var Zn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +function Hi(t) { + return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t; +} +function K5(t) { + if (Object.prototype.hasOwnProperty.call(t, "__esModule")) return t; + var e = t.default; + if (typeof e == "function") { + var r = function n() { + var i = !1; + try { + i = this instanceof n; + } catch { + } + return i ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments); + }; + r.prototype = e.prototype; + } else r = {}; + return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(t).forEach(function(n) { + var i = Object.getOwnPropertyDescriptor(t, n); + Object.defineProperty(r, n, i.get ? i : { + enumerable: !0, + get: function() { + return t[n]; + } + }); + }), r; +} +var ch = { exports: {} }, xu = {}; +/** + * @license React + * react-jsx-runtime.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var Tw; +function gT() { + if (Tw) return xu; + Tw = 1; + var t = Wv, e = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 }; + function o(a, f, u) { + var h, g = {}, v = null, x = null; + u !== void 0 && (v = "" + u), f.key !== void 0 && (v = "" + f.key), f.ref !== void 0 && (x = f.ref); + for (h in f) n.call(f, h) && !s.hasOwnProperty(h) && (g[h] = f[h]); + if (a && a.defaultProps) for (h in f = a.defaultProps, f) g[h] === void 0 && (g[h] = f[h]); + return { $$typeof: e, type: a, key: v, ref: x, props: g, _owner: i.current }; + } + return xu.Fragment = r, xu.jsx = o, xu.jsxs = o, xu; +} +var _u = {}; +/** + * @license React + * react-jsx-runtime.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var Dw; +function mT() { + return Dw || (Dw = 1, process.env.NODE_ENV !== "production" && (function() { + var t = Wv, e = Symbol.for("react.element"), r = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), o = Symbol.for("react.provider"), a = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), u = Symbol.for("react.suspense"), h = Symbol.for("react.suspense_list"), g = Symbol.for("react.memo"), v = Symbol.for("react.lazy"), x = Symbol.for("react.offscreen"), S = Symbol.iterator, R = "@@iterator"; + function D(F) { + if (F === null || typeof F != "object") + return null; + var ie = S && F[S] || F[R]; + return typeof ie == "function" ? ie : null; + } + var k = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + function N(F) { + { + for (var ie = arguments.length, le = new Array(ie > 1 ? ie - 1 : 0), me = 1; me < ie; me++) + le[me - 1] = arguments[me]; + z("error", F, le); + } + } + function z(F, ie, le) { + { + var me = k.ReactDebugCurrentFrame, Ee = me.getStackAddendum(); + Ee !== "" && (ie += "%s", le = le.concat([Ee])); + var Le = le.map(function(Ie) { + return String(Ie); + }); + Le.unshift("Warning: " + ie), Function.prototype.apply.call(console[F], console, Le); + } + } + var B = !1, $ = !1, U = !1, C = !1, W = !1, J; + J = Symbol.for("react.module.reference"); + function ne(F) { + return !!(typeof F == "string" || typeof F == "function" || F === n || F === s || W || F === i || F === u || F === h || C || F === x || B || $ || U || typeof F == "object" && F !== null && (F.$$typeof === v || F.$$typeof === g || F.$$typeof === o || F.$$typeof === a || F.$$typeof === f || // This needs to include all possible module reference object + // types supported by any Flight configuration anywhere since + // we don't know which Flight build this will end up being used + // with. + F.$$typeof === J || F.getModuleId !== void 0)); + } + function K(F, ie, le) { + var me = F.displayName; + if (me) + return me; + var Ee = ie.displayName || ie.name || ""; + return Ee !== "" ? le + "(" + Ee + ")" : le; + } + function E(F) { + return F.displayName || "Context"; + } + function b(F) { + if (F == null) + return null; + if (typeof F.tag == "number" && N("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof F == "function") + return F.displayName || F.name || null; + if (typeof F == "string") + return F; + switch (F) { + case n: + return "Fragment"; + case r: + return "Portal"; + case s: + return "Profiler"; + case i: + return "StrictMode"; + case u: + return "Suspense"; + case h: + return "SuspenseList"; + } + if (typeof F == "object") + switch (F.$$typeof) { + case a: + var ie = F; + return E(ie) + ".Consumer"; + case o: + var le = F; + return E(le._context) + ".Provider"; + case f: + return K(F, F.render, "ForwardRef"); + case g: + var me = F.displayName || null; + return me !== null ? me : b(F.type) || "Memo"; + case v: { + var Ee = F, Le = Ee._payload, Ie = Ee._init; + try { + return b(Ie(Le)); + } catch { + return null; + } + } + } + return null; + } + var l = Object.assign, p = 0, m, w, P, _, y, M, I; + function q() { + } + q.__reactDisabledLog = !0; + function ce() { + { + if (p === 0) { + m = console.log, w = console.info, P = console.warn, _ = console.error, y = console.group, M = console.groupCollapsed, I = console.groupEnd; + var F = { + configurable: !0, + enumerable: !0, + value: q, + writable: !0 + }; + Object.defineProperties(console, { + info: F, + log: F, + warn: F, + error: F, + group: F, + groupCollapsed: F, + groupEnd: F + }); + } + p++; + } + } + function L() { + { + if (p--, p === 0) { + var F = { + configurable: !0, + enumerable: !0, + writable: !0 + }; + Object.defineProperties(console, { + log: l({}, F, { + value: m + }), + info: l({}, F, { + value: w + }), + warn: l({}, F, { + value: P + }), + error: l({}, F, { + value: _ + }), + group: l({}, F, { + value: y + }), + groupCollapsed: l({}, F, { + value: M + }), + groupEnd: l({}, F, { + value: I + }) + }); + } + p < 0 && N("disabledDepth fell below zero. This is a bug in React. Please file an issue."); + } + } + var oe = k.ReactCurrentDispatcher, Q; + function X(F, ie, le) { + { + if (Q === void 0) + try { + throw Error(); + } catch (Ee) { + var me = Ee.stack.trim().match(/\n( *(at )?)/); + Q = me && me[1] || ""; + } + return ` +` + Q + F; + } + } + var ee = !1, O; + { + var Z = typeof WeakMap == "function" ? WeakMap : Map; + O = new Z(); + } + function re(F, ie) { + if (!F || ee) + return ""; + { + var le = O.get(F); + if (le !== void 0) + return le; + } + var me; + ee = !0; + var Ee = Error.prepareStackTrace; + Error.prepareStackTrace = void 0; + var Le; + Le = oe.current, oe.current = null, ce(); + try { + if (ie) { + var Ie = function() { + throw Error(); + }; + if (Object.defineProperty(Ie.prototype, "props", { + set: function() { + throw Error(); + } + }), typeof Reflect == "object" && Reflect.construct) { + try { + Reflect.construct(Ie, []); + } catch (wt) { + me = wt; + } + Reflect.construct(F, [], Ie); + } else { + try { + Ie.call(); + } catch (wt) { + me = wt; + } + F.call(Ie.prototype); + } + } else { + try { + throw Error(); + } catch (wt) { + me = wt; + } + F(); + } + } catch (wt) { + if (wt && me && typeof wt.stack == "string") { + for (var Qe = wt.stack.split(` +`), Xe = me.stack.split(` +`), tt = Qe.length - 1, st = Xe.length - 1; tt >= 1 && st >= 0 && Qe[tt] !== Xe[st]; ) + st--; + for (; tt >= 1 && st >= 0; tt--, st--) + if (Qe[tt] !== Xe[st]) { + if (tt !== 1 || st !== 1) + do + if (tt--, st--, st < 0 || Qe[tt] !== Xe[st]) { + var vt = ` +` + Qe[tt].replace(" at new ", " at "); + return F.displayName && vt.includes("") && (vt = vt.replace("", F.displayName)), typeof F == "function" && O.set(F, vt), vt; + } + while (tt >= 1 && st >= 0); + break; + } + } + } finally { + ee = !1, oe.current = Le, L(), Error.prepareStackTrace = Ee; + } + var Ct = F ? F.displayName || F.name : "", Mt = Ct ? X(Ct) : ""; + return typeof F == "function" && O.set(F, Mt), Mt; + } + function he(F, ie, le) { + return re(F, !1); + } + function ae(F) { + var ie = F.prototype; + return !!(ie && ie.isReactComponent); + } + function fe(F, ie, le) { + if (F == null) + return ""; + if (typeof F == "function") + return re(F, ae(F)); + if (typeof F == "string") + return X(F); + switch (F) { + case u: + return X("Suspense"); + case h: + return X("SuspenseList"); + } + if (typeof F == "object") + switch (F.$$typeof) { + case f: + return he(F.render); + case g: + return fe(F.type, ie, le); + case v: { + var me = F, Ee = me._payload, Le = me._init; + try { + return fe(Le(Ee), ie, le); + } catch { + } + } + } + return ""; + } + var be = Object.prototype.hasOwnProperty, Ae = {}, Te = k.ReactDebugCurrentFrame; + function Re(F) { + if (F) { + var ie = F._owner, le = fe(F.type, F._source, ie ? ie.type : null); + Te.setExtraStackFrame(le); + } else + Te.setExtraStackFrame(null); + } + function $e(F, ie, le, me, Ee) { + { + var Le = Function.call.bind(be); + for (var Ie in F) + if (Le(F, Ie)) { + var Qe = void 0; + try { + if (typeof F[Ie] != "function") { + var Xe = Error((me || "React class") + ": " + le + " type `" + Ie + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof F[Ie] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); + throw Xe.name = "Invariant Violation", Xe; + } + Qe = F[Ie](ie, Ie, me, le, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); + } catch (tt) { + Qe = tt; + } + Qe && !(Qe instanceof Error) && (Re(Ee), N("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", me || "React class", le, Ie, typeof Qe), Re(null)), Qe instanceof Error && !(Qe.message in Ae) && (Ae[Qe.message] = !0, Re(Ee), N("Failed %s type: %s", le, Qe.message), Re(null)); + } + } + } + var Me = Array.isArray; + function Oe(F) { + return Me(F); + } + function ze(F) { + { + var ie = typeof Symbol == "function" && Symbol.toStringTag, le = ie && F[Symbol.toStringTag] || F.constructor.name || "Object"; + return le; + } + } + function De(F) { + try { + return je(F), !1; + } catch { + return !0; + } + } + function je(F) { + return "" + F; + } + function Ue(F) { + if (De(F)) + return N("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ze(F)), je(F); + } + var _e = k.ReactCurrentOwner, Ze = { + key: !0, + ref: !0, + __self: !0, + __source: !0 + }, ot, ke; + function rt(F) { + if (be.call(F, "ref")) { + var ie = Object.getOwnPropertyDescriptor(F, "ref").get; + if (ie && ie.isReactWarning) + return !1; + } + return F.ref !== void 0; + } + function nt(F) { + if (be.call(F, "key")) { + var ie = Object.getOwnPropertyDescriptor(F, "key").get; + if (ie && ie.isReactWarning) + return !1; + } + return F.key !== void 0; + } + function Ge(F, ie) { + typeof F.ref == "string" && _e.current; + } + function ht(F, ie) { + { + var le = function() { + ot || (ot = !0, N("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", ie)); + }; + le.isReactWarning = !0, Object.defineProperty(F, "key", { + get: le, + configurable: !0 + }); + } + } + function lt(F, ie) { + { + var le = function() { + ke || (ke = !0, N("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", ie)); + }; + le.isReactWarning = !0, Object.defineProperty(F, "ref", { + get: le, + configurable: !0 + }); + } + } + var ct = function(F, ie, le, me, Ee, Le, Ie) { + var Qe = { + // This tag allows us to uniquely identify this as a React Element + $$typeof: e, + // Built-in properties that belong on the element + type: F, + key: ie, + ref: le, + props: Ie, + // Record the component responsible for creating this element. + _owner: Le + }; + return Qe._store = {}, Object.defineProperty(Qe._store, "validated", { + configurable: !1, + enumerable: !1, + writable: !0, + value: !1 + }), Object.defineProperty(Qe, "_self", { + configurable: !1, + enumerable: !1, + writable: !1, + value: me + }), Object.defineProperty(Qe, "_source", { + configurable: !1, + enumerable: !1, + writable: !1, + value: Ee + }), Object.freeze && (Object.freeze(Qe.props), Object.freeze(Qe)), Qe; + }; + function qt(F, ie, le, me, Ee) { + { + var Le, Ie = {}, Qe = null, Xe = null; + le !== void 0 && (Ue(le), Qe = "" + le), nt(ie) && (Ue(ie.key), Qe = "" + ie.key), rt(ie) && (Xe = ie.ref, Ge(ie, Ee)); + for (Le in ie) + be.call(ie, Le) && !Ze.hasOwnProperty(Le) && (Ie[Le] = ie[Le]); + if (F && F.defaultProps) { + var tt = F.defaultProps; + for (Le in tt) + Ie[Le] === void 0 && (Ie[Le] = tt[Le]); + } + if (Qe || Xe) { + var st = typeof F == "function" ? F.displayName || F.name || "Unknown" : F; + Qe && ht(Ie, st), Xe && lt(Ie, st); + } + return ct(F, Qe, Xe, Ee, me, _e.current, Ie); + } + } + var Gt = k.ReactCurrentOwner, Et = k.ReactDebugCurrentFrame; + function Yt(F) { + if (F) { + var ie = F._owner, le = fe(F.type, F._source, ie ? ie.type : null); + Et.setExtraStackFrame(le); + } else + Et.setExtraStackFrame(null); + } + var tr; + tr = !1; + function Tt(F) { + return typeof F == "object" && F !== null && F.$$typeof === e; + } + function kt() { + { + if (Gt.current) { + var F = b(Gt.current.type); + if (F) + return ` + +Check the render method of \`` + F + "`."; + } + return ""; + } + } + function It(F) { + return ""; + } + var dt = {}; + function Dt(F) { + { + var ie = kt(); + if (!ie) { + var le = typeof F == "string" ? F : F.displayName || F.name; + le && (ie = ` + +Check the top-level render call using <` + le + ">."); + } + return ie; + } + } + function Nt(F, ie) { + { + if (!F._store || F._store.validated || F.key != null) + return; + F._store.validated = !0; + var le = Dt(ie); + if (dt[le]) + return; + dt[le] = !0; + var me = ""; + F && F._owner && F._owner !== Gt.current && (me = " It was passed a child from " + b(F._owner.type) + "."), Yt(F), N('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', le, me), Yt(null); + } + } + function mt(F, ie) { + { + if (typeof F != "object") + return; + if (Oe(F)) + for (var le = 0; le < F.length; le++) { + var me = F[le]; + Tt(me) && Nt(me, ie); + } + else if (Tt(F)) + F._store && (F._store.validated = !0); + else if (F) { + var Ee = D(F); + if (typeof Ee == "function" && Ee !== F.entries) + for (var Le = Ee.call(F), Ie; !(Ie = Le.next()).done; ) + Tt(Ie.value) && Nt(Ie.value, ie); + } + } + } + function Bt(F) { + { + var ie = F.type; + if (ie == null || typeof ie == "string") + return; + var le; + if (typeof ie == "function") + le = ie.propTypes; + else if (typeof ie == "object" && (ie.$$typeof === f || // Note: Memo only checks outer props here. + // Inner props are checked in the reconciler. + ie.$$typeof === g)) + le = ie.propTypes; + else + return; + if (le) { + var me = b(ie); + $e(le, F.props, "prop", me, F); + } else if (ie.PropTypes !== void 0 && !tr) { + tr = !0; + var Ee = b(ie); + N("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", Ee || "Unknown"); + } + typeof ie.getDefaultProps == "function" && !ie.getDefaultProps.isReactClassApproved && N("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); + } + } + function Ft(F) { + { + for (var ie = Object.keys(F.props), le = 0; le < ie.length; le++) { + var me = ie[le]; + if (me !== "children" && me !== "key") { + Yt(F), N("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", me), Yt(null); + break; + } + } + F.ref !== null && (Yt(F), N("Invalid attribute `ref` supplied to `React.Fragment`."), Yt(null)); + } + } + var et = {}; + function $t(F, ie, le, me, Ee, Le) { + { + var Ie = ne(F); + if (!Ie) { + var Qe = ""; + (F === void 0 || typeof F == "object" && F !== null && Object.keys(F).length === 0) && (Qe += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); + var Xe = It(); + Xe ? Qe += Xe : Qe += kt(); + var tt; + F === null ? tt = "null" : Oe(F) ? tt = "array" : F !== void 0 && F.$$typeof === e ? (tt = "<" + (b(F.type) || "Unknown") + " />", Qe = " Did you accidentally export a JSX literal instead of a component?") : tt = typeof F, N("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", tt, Qe); + } + var st = qt(F, ie, le, Ee, Le); + if (st == null) + return st; + if (Ie) { + var vt = ie.children; + if (vt !== void 0) + if (me) + if (Oe(vt)) { + for (var Ct = 0; Ct < vt.length; Ct++) + mt(vt[Ct], F); + Object.freeze && Object.freeze(vt); + } else + N("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); + else + mt(vt, F); + } + if (be.call(ie, "key")) { + var Mt = b(F), wt = Object.keys(ie).filter(function(_t) { + return _t !== "key"; + }), Rt = wt.length > 0 ? "{key: someKey, " + wt.join(": ..., ") + ": ...}" : "{key: someKey}"; + if (!et[Mt + Rt]) { + var gt = wt.length > 0 ? "{" + wt.join(": ..., ") + ": ...}" : "{}"; + N(`A props object containing a "key" prop is being spread into JSX: + let props = %s; + <%s {...props} /> +React keys must be passed directly to JSX without using spread: + let props = %s; + <%s key={someKey} {...props} />`, Rt, Mt, gt, Mt), et[Mt + Rt] = !0; + } + } + return F === n ? Ft(st) : Bt(st), st; + } + } + function H(F, ie, le) { + return $t(F, ie, le, !0); + } + function V(F, ie, le) { + return $t(F, ie, le, !1); + } + var Y = V, T = H; + _u.Fragment = n, _u.jsx = Y, _u.jsxs = T; + })()), _u; +} +var Ow; +function vT() { + return Ow || (Ow = 1, process.env.NODE_ENV === "production" ? ch.exports = gT() : ch.exports = mT()), ch.exports; +} +var pe = vT(); +const ys = "https://static.codatta.io/codatta-connect/wallet-icons.svg?v=2", bT = [ + { + featured: !0, + name: "MetaMask", + rdns: "io.metamask", + image: `${ys}#metamask`, + getWallet: { + chrome_store_id: "nkbihfbeogaeaoehlefnkodbefgpgknn", + brave_store_id: "nkbihfbeogaeaoehlefnkodbefgpgknn", + edge_addon_id: "ejbalbakoplchlghecdalmeeeajnimhm", + firefox_addon_id: "ether-metamask", + play_store_id: "io.metamask", + app_store_id: "id1438144202" + }, + deep_link: "metamask://wc", + universal_link: "https://metamask.app.link/wc" + }, + { + name: "Binance Wallet", + featured: !0, + image: `${ys}#ebac7b39-688c-41e3-7912-a4fefba74600`, + getWallet: { + chrome_store_id: "cadiboklkpojfamcoggejbbdjcoiljjk", + play_store_id: "com.binance.dev", + app_store_id: "id1436799971" + } + }, + { + featured: !0, + name: "OKX Wallet", + rdns: "com.okex.wallet", + image: `${ys}#okx`, + getWallet: { + chrome_store_id: "mcohilncbfahbmgdjkbpemcciiolgcge", + brave_store_id: "mcohilncbfahbmgdjkbpemcciiolgcge", + edge_addon_id: "pbpjkcldjiffchgbbndmhojiacbgflha", + play_store_id: "com.okinc.okex.gp", + app_store_id: "id1327268470" + }, + deep_link: "okex://main/wc", + universal_link: "okex://main/wc" + }, + { + featured: !0, + name: "WalletConnect", + image: `${ys}#walletconnect` + }, + { + featured: !1, + name: "Coinbase Wallet", + image: `${ys}#coinbase` + }, + { + featured: !1, + name: "GateWallet", + rdns: "io.gate.wallet", + image: `${ys}#6e528abf-7a7d-47bd-d84d-481f169b1200`, + getWallet: { + chrome_store_id: "cpmkedoipcpimgecpmgpldfpohjplkpp", + brave_store_id: "cpmkedoipcpimgecpmgpldfpohjplkpp", + play_store_id: "com.gateio.gateio", + app_store_id: "id1294998195", + mac_app_store_id: "id1609559473" + }, + deep_link: "https://www.gate.io/mobileapp", + universal_link: "https://www.gate.io/mobileapp" + }, + { + featured: !1, + name: "Onekey", + rdns: "so.onekey.app.wallet", + image: `${ys}#onekey`, + getWallet: { + chrome_store_id: "jnmbobjmhlngoefaiojfljckilhhlhcj", + brave_store_id: "jnmbobjmhlngoefaiojfljckilhhlhcj", + play_store_id: "so.onekey.app.wallet", + app_store_id: "id1609559473" + }, + deep_link: "onekey-wallet://", + universal_link: "onekey://wc" + }, + { + featured: !1, + name: "Infinity Wallet", + image: `${ys}#9f259366-0bcd-4817-0af9-f78773e41900`, + desktop_link: "infinity://wc" + }, + { + name: "Rabby Wallet", + rdns: "io.rabby", + featured: !1, + image: `${ys}#rabby`, + getWallet: { + chrome_store_id: "acmacodkjbdgmoleebolmdjonilkdbch", + brave_store_id: "acmacodkjbdgmoleebolmdjonilkdbch", + play_store_id: "com.debank.rabbymobile", + app_store_id: "id6474381673" + } + }, + { + name: "Rainbow Wallet", + rdns: "me.rainbow", + featured: !1, + image: `${ys}#rainbow`, + getWallet: { + chrome_store_id: "opfgelmcmbiajamepnmloijbpoleiama", + edge_addon_id: "cpojfbodiccabbabgimdeohkkpjfpbnf", + firefox_addon_id: "rainbow-extension", + app_store_id: "id1457119021", + play_store_id: "me.rainbow" + } + } +]; +function yT(t, e) { + return t.exec(e)?.groups; +} +const Nw = /^tuple(?(\[(\d*)\])*)$/; +function km(t) { + let e = t.type; + if (Nw.test(t.type) && "components" in t) { + e = "("; + const r = t.components.length; + for (let i = 0; i < r; i++) { + const s = t.components[i]; + e += km(s), i < r - 1 && (e += ", "); + } + const n = yT(Nw, t.type); + return e += `)${n?.array ?? ""}`, km({ + ...t, + type: e + }); + } + return "indexed" in t && t.indexed && (e = `${e} indexed`), t.name ? `${e} ${t.name}` : e; +} +function Eu(t) { + let e = ""; + const r = t.length; + for (let n = 0; n < r; n++) { + const i = t[n]; + e += km(i), n !== r - 1 && (e += ", "); + } + return e; +} +function wT(t) { + return t.type === "function" ? `function ${t.name}(${Eu(t.inputs)})${t.stateMutability && t.stateMutability !== "nonpayable" ? ` ${t.stateMutability}` : ""}${t.outputs?.length ? ` returns (${Eu(t.outputs)})` : ""}` : t.type === "event" ? `event ${t.name}(${Eu(t.inputs)})` : t.type === "error" ? `error ${t.name}(${Eu(t.inputs)})` : t.type === "constructor" ? `constructor(${Eu(t.inputs)})${t.stateMutability === "payable" ? " payable" : ""}` : t.type === "fallback" ? `fallback() external${t.stateMutability === "payable" ? " payable" : ""}` : "receive() external payable"; +} +function Hn(t, e, r) { + const n = t[e.name]; + if (typeof n == "function") + return n; + const i = t[r]; + return typeof i == "function" ? i : (s) => e(t, s); +} +function Bc(t, { includeName: e = !1 } = {}) { + if (t.type !== "function" && t.type !== "event" && t.type !== "error") + throw new DT(t.type); + return `${t.name}(${Yv(t.inputs, { includeName: e })})`; +} +function Yv(t, { includeName: e = !1 } = {}) { + return t ? t.map((r) => xT(r, { includeName: e })).join(e ? ", " : ",") : ""; +} +function xT(t, { includeName: e }) { + return t.type.startsWith("tuple") ? `(${Yv(t.components, { includeName: e })})${t.type.slice(5)}` : t.type + (e && t.name ? ` ${t.name}` : ""); +} +function Uo(t, { strict: e = !0 } = {}) { + return !t || typeof t != "string" ? !1 : e ? /^0x[0-9a-fA-F]*$/.test(t) : t.startsWith("0x"); +} +function yn(t) { + return Uo(t, { strict: !1 }) ? Math.ceil((t.length - 2) / 2) : t.length; +} +const V5 = "2.31.3"; +let $p = { + getDocsUrl: ({ docsBaseUrl: t, docsPath: e = "", docsSlug: r }) => e ? `${t ?? "https://viem.sh"}${e}${r ? `#${r}` : ""}` : void 0, + version: `viem@${V5}` +}; +class pt extends Error { + constructor(e, r = {}) { + const n = r.cause instanceof pt ? r.cause.details : r.cause?.message ? r.cause.message : r.details, i = r.cause instanceof pt && r.cause.docsPath || r.docsPath, s = $p.getDocsUrl?.({ ...r, docsPath: i }), o = [ + e || "An error occurred.", + "", + ...r.metaMessages ? [...r.metaMessages, ""] : [], + ...s ? [`Docs: ${s}`] : [], + ...n ? [`Details: ${n}`] : [], + ...$p.version ? [`Version: ${$p.version}`] : [] + ].join(` +`); + super(o, r.cause ? { cause: r.cause } : void 0), Object.defineProperty(this, "details", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "docsPath", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "metaMessages", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "shortMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "version", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "name", { + enumerable: !0, + configurable: !0, + writable: !0, + value: "BaseError" + }), this.details = n, this.docsPath = i, this.metaMessages = r.metaMessages, this.name = r.name ?? this.name, this.shortMessage = e, this.version = V5; + } + walk(e) { + return G5(this, e); + } +} +function G5(t, e) { + return e?.(t) ? t : t && typeof t == "object" && "cause" in t && t.cause !== void 0 ? G5(t.cause, e) : e ? null : t; +} +class _T extends pt { + constructor({ docsPath: e }) { + super([ + "A constructor was not found on the ABI.", + "Make sure you are using the correct ABI and that the constructor exists on it." + ].join(` +`), { + docsPath: e, + name: "AbiConstructorNotFoundError" + }); + } +} +class Lw extends pt { + constructor({ docsPath: e }) { + super([ + "Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.", + "Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists." + ].join(` +`), { + docsPath: e, + name: "AbiConstructorParamsNotFoundError" + }); + } +} +class ET extends pt { + constructor({ data: e, params: r, size: n }) { + super([`Data size of ${n} bytes is too small for given parameters.`].join(` +`), { + metaMessages: [ + `Params: (${Yv(r, { includeName: !0 })})`, + `Data: ${e} (${n} bytes)` + ], + name: "AbiDecodingDataSizeTooSmallError" + }), Object.defineProperty(this, "data", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "params", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "size", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.data = e, this.params = r, this.size = n; + } +} +class Jv extends pt { + constructor() { + super('Cannot decode zero data ("0x") with ABI parameters.', { + name: "AbiDecodingZeroDataError" + }); + } +} +class ST extends pt { + constructor({ expectedLength: e, givenLength: r, type: n }) { + super([ + `ABI encoding array length mismatch for type ${n}.`, + `Expected length: ${e}`, + `Given length: ${r}` + ].join(` +`), { name: "AbiEncodingArrayLengthMismatchError" }); + } +} +class AT extends pt { + constructor({ expectedSize: e, value: r }) { + super(`Size of bytes "${r}" (bytes${yn(r)}) does not match expected size (bytes${e}).`, { name: "AbiEncodingBytesSizeMismatchError" }); + } +} +class PT extends pt { + constructor({ expectedLength: e, givenLength: r }) { + super([ + "ABI encoding params/values length mismatch.", + `Expected length (params): ${e}`, + `Given length (values): ${r}` + ].join(` +`), { name: "AbiEncodingLengthMismatchError" }); + } +} +class Y5 extends pt { + constructor(e, { docsPath: r }) { + super([ + `Encoded error signature "${e}" not found on ABI.`, + "Make sure you are using the correct ABI and that the error exists on it.", + `You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.` + ].join(` +`), { + docsPath: r, + name: "AbiErrorSignatureNotFoundError" + }), Object.defineProperty(this, "signature", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.signature = e; + } +} +class kw extends pt { + constructor(e, { docsPath: r } = {}) { + super([ + `Function ${e ? `"${e}" ` : ""}not found on ABI.`, + "Make sure you are using the correct ABI and that the function exists on it." + ].join(` +`), { + docsPath: r, + name: "AbiFunctionNotFoundError" + }); + } +} +class MT extends pt { + constructor(e, r) { + super("Found ambiguous types in overloaded ABI items.", { + metaMessages: [ + `\`${e.type}\` in \`${Bc(e.abiItem)}\`, and`, + `\`${r.type}\` in \`${Bc(r.abiItem)}\``, + "", + "These types encode differently and cannot be distinguished at runtime.", + "Remove one of the ambiguous items in the ABI." + ], + name: "AbiItemAmbiguityError" + }); + } +} +class IT extends pt { + constructor({ expectedSize: e, givenSize: r }) { + super(`Expected bytes${e}, got bytes${r}.`, { + name: "BytesSizeMismatchError" + }); + } +} +class CT extends pt { + constructor(e, { docsPath: r }) { + super([ + `Type "${e}" is not a valid encoding type.`, + "Please provide a valid ABI type." + ].join(` +`), { docsPath: r, name: "InvalidAbiEncodingType" }); + } +} +class RT extends pt { + constructor(e, { docsPath: r }) { + super([ + `Type "${e}" is not a valid decoding type.`, + "Please provide a valid ABI type." + ].join(` +`), { docsPath: r, name: "InvalidAbiDecodingType" }); + } +} +class TT extends pt { + constructor(e) { + super([`Value "${e}" is not a valid array.`].join(` +`), { + name: "InvalidArrayError" + }); + } +} +class DT extends pt { + constructor(e) { + super([ + `"${e}" is not a valid definition type.`, + 'Valid types: "function", "event", "error"' + ].join(` +`), { name: "InvalidDefinitionTypeError" }); + } +} +class J5 extends pt { + constructor({ offset: e, position: r, size: n }) { + super(`Slice ${r === "start" ? "starting" : "ending"} at offset "${e}" is out-of-bounds (size: ${n}).`, { name: "SliceOffsetOutOfBoundsError" }); + } +} +class X5 extends pt { + constructor({ size: e, targetSize: r, type: n }) { + super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${r}).`, { name: "SizeExceedsPaddingSizeError" }); + } +} +class $w extends pt { + constructor({ size: e, targetSize: r, type: n }) { + super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${r} ${n} long, but is ${e} ${n} long.`, { name: "InvalidBytesLengthError" }); + } +} +function Kc(t, { dir: e, size: r = 32 } = {}) { + return typeof t == "string" ? jo(t, { dir: e, size: r }) : OT(t, { dir: e, size: r }); +} +function jo(t, { dir: e, size: r = 32 } = {}) { + if (r === null) + return t; + const n = t.replace("0x", ""); + if (n.length > r * 2) + throw new X5({ + size: Math.ceil(n.length / 2), + targetSize: r, + type: "hex" + }); + return `0x${n[e === "right" ? "padEnd" : "padStart"](r * 2, "0")}`; +} +function OT(t, { dir: e, size: r = 32 } = {}) { + if (r === null) + return t; + if (t.length > r) + throw new X5({ + size: t.length, + targetSize: r, + type: "bytes" + }); + const n = new Uint8Array(r); + for (let i = 0; i < r; i++) { + const s = e === "right"; + n[s ? i : r - i - 1] = t[s ? i : t.length - i - 1]; + } + return n; +} +class Z5 extends pt { + constructor({ max: e, min: r, signed: n, size: i, value: s }) { + super(`Number "${s}" is not in safe ${i ? `${i * 8}-bit ${n ? "signed" : "unsigned"} ` : ""}integer range ${e ? `(${r} to ${e})` : `(above ${r})`}`, { name: "IntegerOutOfRangeError" }); + } +} +class NT extends pt { + constructor(e) { + super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, { + name: "InvalidBytesBooleanError" + }); + } +} +class LT extends pt { + constructor({ givenSize: e, maxSize: r }) { + super(`Size cannot exceed ${r} bytes. Given size: ${e} bytes.`, { name: "SizeOverflowError" }); + } +} +function Fd(t, { dir: e = "left" } = {}) { + let r = typeof t == "string" ? t.replace("0x", "") : t, n = 0; + for (let i = 0; i < r.length - 1 && r[e === "left" ? i : r.length - i - 1].toString() === "0"; i++) + n++; + return r = e === "left" ? r.slice(n) : r.slice(0, r.length - n), typeof t == "string" ? (r.length === 1 && e === "right" && (r = `${r}0`), `0x${r.length % 2 === 1 ? `0${r}` : r}`) : r; +} +function Ns(t, { size: e }) { + if (yn(t) > e) + throw new LT({ + givenSize: yn(t), + maxSize: e + }); +} +function qo(t, e = {}) { + const { signed: r } = e; + e.size && Ns(t, { size: e.size }); + const n = BigInt(t); + if (!r) + return n; + const i = (t.length - 2) / 2, s = (1n << BigInt(i) * 8n - 1n) - 1n; + return n <= s ? n : n - BigInt(`0x${"f".padStart(i * 2, "f")}`) - 1n; +} +function zo(t, e = {}) { + return Number(qo(t, e)); +} +const kT = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0")); +function od(t, e = {}) { + return typeof t == "number" || typeof t == "bigint" ? br(t, e) : typeof t == "string" ? jd(t, e) : typeof t == "boolean" ? Q5(t, e) : di(t, e); +} +function Q5(t, e = {}) { + const r = `0x${Number(t)}`; + return typeof e.size == "number" ? (Ns(r, { size: e.size }), Kc(r, { size: e.size })) : r; +} +function di(t, e = {}) { + let r = ""; + for (let i = 0; i < t.length; i++) + r += kT[t[i]]; + const n = `0x${r}`; + return typeof e.size == "number" ? (Ns(n, { size: e.size }), Kc(n, { dir: "right", size: e.size })) : n; +} +function br(t, e = {}) { + const { signed: r, size: n } = e, i = BigInt(t); + let s; + n ? r ? s = (1n << BigInt(n) * 8n - 1n) - 1n : s = 2n ** (BigInt(n) * 8n) - 1n : typeof t == "number" && (s = BigInt(Number.MAX_SAFE_INTEGER)); + const o = typeof s == "bigint" && r ? -s - 1n : 0; + if (s && i > s || i < o) { + const f = typeof t == "bigint" ? "n" : ""; + throw new Z5({ + max: s ? `${s}${f}` : void 0, + min: `${o}${f}`, + signed: r, + size: n, + value: `${t}${f}` + }); + } + const a = `0x${(r && i < 0 ? (1n << BigInt(n * 8)) + BigInt(i) : i).toString(16)}`; + return n ? Kc(a, { size: n }) : a; +} +const $T = /* @__PURE__ */ new TextEncoder(); +function jd(t, e = {}) { + const r = $T.encode(t); + return di(r, e); +} +const BT = /* @__PURE__ */ new TextEncoder(); +function Xv(t, e = {}) { + return typeof t == "number" || typeof t == "bigint" ? jT(t, e) : typeof t == "boolean" ? FT(t, e) : Uo(t) ? lo(t, e) : e4(t, e); +} +function FT(t, e = {}) { + const r = new Uint8Array(1); + return r[0] = Number(t), typeof e.size == "number" ? (Ns(r, { size: e.size }), Kc(r, { size: e.size })) : r; +} +const Ks = { + zero: 48, + nine: 57, + A: 65, + F: 70, + a: 97, + f: 102 +}; +function Bw(t) { + if (t >= Ks.zero && t <= Ks.nine) + return t - Ks.zero; + if (t >= Ks.A && t <= Ks.F) + return t - (Ks.A - 10); + if (t >= Ks.a && t <= Ks.f) + return t - (Ks.a - 10); +} +function lo(t, e = {}) { + let r = t; + e.size && (Ns(r, { size: e.size }), r = Kc(r, { dir: "right", size: e.size })); + let n = r.slice(2); + n.length % 2 && (n = `0${n}`); + const i = n.length / 2, s = new Uint8Array(i); + for (let o = 0, a = 0; o < i; o++) { + const f = Bw(n.charCodeAt(a++)), u = Bw(n.charCodeAt(a++)); + if (f === void 0 || u === void 0) + throw new pt(`Invalid byte sequence ("${n[a - 2]}${n[a - 1]}" in "${n}").`); + s[o] = f * 16 + u; + } + return s; +} +function jT(t, e) { + const r = br(t, e); + return lo(r); +} +function e4(t, e = {}) { + const r = BT.encode(t); + return typeof e.size == "number" ? (Ns(r, { size: e.size }), Kc(r, { dir: "right", size: e.size })) : r; +} +const uh = /* @__PURE__ */ BigInt(2 ** 32 - 1), Fw = /* @__PURE__ */ BigInt(32); +function UT(t, e = !1) { + return e ? { h: Number(t & uh), l: Number(t >> Fw & uh) } : { h: Number(t >> Fw & uh) | 0, l: Number(t & uh) | 0 }; +} +function qT(t, e = !1) { + const r = t.length; + let n = new Uint32Array(r), i = new Uint32Array(r); + for (let s = 0; s < r; s++) { + const { h: o, l: a } = UT(t[s], e); + [n[s], i[s]] = [o, a]; + } + return [n, i]; +} +const zT = (t, e, r) => t << r | e >>> 32 - r, HT = (t, e, r) => e << r | t >>> 32 - r, WT = (t, e, r) => e << r - 32 | t >>> 64 - r, KT = (t, e, r) => t << r - 32 | e >>> 64 - r, hc = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0; +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +function VT(t) { + return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array"; +} +function ad(t) { + if (!Number.isSafeInteger(t) || t < 0) + throw new Error("positive integer expected, got " + t); +} +function Da(t, ...e) { + if (!VT(t)) + throw new Error("Uint8Array expected"); + if (e.length > 0 && !e.includes(t.length)) + throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length); +} +function cre(t) { + if (typeof t != "function" || typeof t.create != "function") + throw new Error("Hash should be wrapped by utils.createHasher"); + ad(t.outputLen), ad(t.blockLen); +} +function cd(t, e = !0) { + if (t.destroyed) + throw new Error("Hash instance has been destroyed"); + if (e && t.finished) + throw new Error("Hash#digest() has already been called"); +} +function t4(t, e) { + Da(t); + const r = e.outputLen; + if (t.length < r) + throw new Error("digestInto() expects output buffer of length at least " + r); +} +function GT(t) { + return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4)); +} +function hf(...t) { + for (let e = 0; e < t.length; e++) + t[e].fill(0); +} +function Bp(t) { + return new DataView(t.buffer, t.byteOffset, t.byteLength); +} +function ws(t, e) { + return t << 32 - e | t >>> e; +} +const YT = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; +function JT(t) { + return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255; +} +function XT(t) { + for (let e = 0; e < t.length; e++) + t[e] = JT(t[e]); + return t; +} +const jw = YT ? (t) => t : XT, r4 = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", ZT = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0")); +function QT(t) { + if (Da(t), r4) + return t.toHex(); + let e = ""; + for (let r = 0; r < t.length; r++) + e += ZT[t[r]]; + return e; +} +const Vs = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; +function Uw(t) { + if (t >= Vs._0 && t <= Vs._9) + return t - Vs._0; + if (t >= Vs.A && t <= Vs.F) + return t - (Vs.A - 10); + if (t >= Vs.a && t <= Vs.f) + return t - (Vs.a - 10); +} +function ure(t) { + if (typeof t != "string") + throw new Error("hex string expected, got " + typeof t); + if (r4) + return Uint8Array.fromHex(t); + const e = t.length, r = e / 2; + if (e % 2) + throw new Error("hex string expected, got unpadded hex of length " + e); + const n = new Uint8Array(r); + for (let i = 0, s = 0; i < r; i++, s += 2) { + const o = Uw(t.charCodeAt(s)), a = Uw(t.charCodeAt(s + 1)); + if (o === void 0 || a === void 0) { + const f = t[s] + t[s + 1]; + throw new Error('hex string expected, got non-hex character "' + f + '" at index ' + s); + } + n[i] = o * 16 + a; + } + return n; +} +function eD(t) { + if (typeof t != "string") + throw new Error("string expected"); + return new Uint8Array(new TextEncoder().encode(t)); +} +function Zv(t) { + return typeof t == "string" && (t = eD(t)), Da(t), t; +} +function fre(...t) { + let e = 0; + for (let n = 0; n < t.length; n++) { + const i = t[n]; + Da(i), e += i.length; + } + const r = new Uint8Array(e); + for (let n = 0, i = 0; n < t.length; n++) { + const s = t[n]; + r.set(s, i), i += s.length; + } + return r; +} +class n4 { +} +function i4(t) { + const e = (n) => t().update(Zv(n)).digest(), r = t(); + return e.outputLen = r.outputLen, e.blockLen = r.blockLen, e.create = () => t(), e; +} +function lre(t = 32) { + if (hc && typeof hc.getRandomValues == "function") + return hc.getRandomValues(new Uint8Array(t)); + if (hc && typeof hc.randomBytes == "function") + return Uint8Array.from(hc.randomBytes(t)); + throw new Error("crypto.getRandomValues must be defined"); +} +const tD = BigInt(0), Su = BigInt(1), rD = BigInt(2), nD = BigInt(7), iD = BigInt(256), sD = BigInt(113), s4 = [], o4 = [], a4 = []; +for (let t = 0, e = Su, r = 1, n = 0; t < 24; t++) { + [r, n] = [n, (2 * r + 3 * n) % 5], s4.push(2 * (5 * n + r)), o4.push((t + 1) * (t + 2) / 2 % 64); + let i = tD; + for (let s = 0; s < 7; s++) + e = (e << Su ^ (e >> nD) * sD) % iD, e & rD && (i ^= Su << (Su << /* @__PURE__ */ BigInt(s)) - Su); + a4.push(i); +} +const c4 = qT(a4, !0), oD = c4[0], aD = c4[1], qw = (t, e, r) => r > 32 ? WT(t, e, r) : zT(t, e, r), zw = (t, e, r) => r > 32 ? KT(t, e, r) : HT(t, e, r); +function cD(t, e = 24) { + const r = new Uint32Array(10); + for (let n = 24 - e; n < 24; n++) { + for (let o = 0; o < 10; o++) + r[o] = t[o] ^ t[o + 10] ^ t[o + 20] ^ t[o + 30] ^ t[o + 40]; + for (let o = 0; o < 10; o += 2) { + const a = (o + 8) % 10, f = (o + 2) % 10, u = r[f], h = r[f + 1], g = qw(u, h, 1) ^ r[a], v = zw(u, h, 1) ^ r[a + 1]; + for (let x = 0; x < 50; x += 10) + t[o + x] ^= g, t[o + x + 1] ^= v; + } + let i = t[2], s = t[3]; + for (let o = 0; o < 24; o++) { + const a = o4[o], f = qw(i, s, a), u = zw(i, s, a), h = s4[o]; + i = t[h], s = t[h + 1], t[h] = f, t[h + 1] = u; + } + for (let o = 0; o < 50; o += 10) { + for (let a = 0; a < 10; a++) + r[a] = t[o + a]; + for (let a = 0; a < 10; a++) + t[o + a] ^= ~r[(a + 2) % 10] & r[(a + 4) % 10]; + } + t[0] ^= oD[n], t[1] ^= aD[n]; + } + hf(r); +} +class Qv extends n4 { + // NOTE: we accept arguments in bytes instead of bits here. + constructor(e, r, n, i = !1, s = 24) { + if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = e, this.suffix = r, this.outputLen = n, this.enableXOF = i, this.rounds = s, ad(n), !(0 < e && e < 200)) + throw new Error("only keccak-f1600 function is supported"); + this.state = new Uint8Array(200), this.state32 = GT(this.state); + } + clone() { + return this._cloneInto(); + } + keccak() { + jw(this.state32), cD(this.state32, this.rounds), jw(this.state32), this.posOut = 0, this.pos = 0; + } + update(e) { + cd(this), e = Zv(e), Da(e); + const { blockLen: r, state: n } = this, i = e.length; + for (let s = 0; s < i; ) { + const o = Math.min(r - this.pos, i - s); + for (let a = 0; a < o; a++) + n[this.pos++] ^= e[s++]; + this.pos === r && this.keccak(); + } + return this; + } + finish() { + if (this.finished) + return; + this.finished = !0; + const { state: e, suffix: r, pos: n, blockLen: i } = this; + e[n] ^= r, (r & 128) !== 0 && n === i - 1 && this.keccak(), e[i - 1] ^= 128, this.keccak(); + } + writeInto(e) { + cd(this, !1), Da(e), this.finish(); + const r = this.state, { blockLen: n } = this; + for (let i = 0, s = e.length; i < s; ) { + this.posOut >= n && this.keccak(); + const o = Math.min(n - this.posOut, s - i); + e.set(r.subarray(this.posOut, this.posOut + o), i), this.posOut += o, i += o; + } + return e; + } + xofInto(e) { + if (!this.enableXOF) + throw new Error("XOF is not possible for this instance"); + return this.writeInto(e); + } + xof(e) { + return ad(e), this.xofInto(new Uint8Array(e)); + } + digestInto(e) { + if (t4(e, this), this.finished) + throw new Error("digest() was already called"); + return this.writeInto(e), this.destroy(), e; + } + digest() { + return this.digestInto(new Uint8Array(this.outputLen)); + } + destroy() { + this.destroyed = !0, hf(this.state); + } + _cloneInto(e) { + const { blockLen: r, suffix: n, outputLen: i, rounds: s, enableXOF: o } = this; + return e || (e = new Qv(r, n, i, o, s)), e.state32.set(this.state32), e.pos = this.pos, e.posOut = this.posOut, e.finished = this.finished, e.rounds = s, e.suffix = n, e.outputLen = i, e.enableXOF = o, e.destroyed = this.destroyed, e; + } +} +const uD = (t, e, r) => i4(() => new Qv(e, t, r)), fD = uD(1, 136, 256 / 8); +function Ud(t, e) { + const r = e || "hex", n = fD(Uo(t, { strict: !1 }) ? Xv(t) : t); + return r === "bytes" ? n : od(n); +} +const lD = (t) => Ud(Xv(t)); +function hD(t) { + return lD(t); +} +function dD(t) { + let e = !0, r = "", n = 0, i = "", s = !1; + for (let o = 0; o < t.length; o++) { + const a = t[o]; + if (["(", ")", ","].includes(a) && (e = !0), a === "(" && n++, a === ")" && n--, !!e) { + if (n === 0) { + if (a === " " && ["event", "function", ""].includes(i)) + i = ""; + else if (i += a, a === ")") { + s = !0; + break; + } + continue; + } + if (a === " ") { + t[o - 1] !== "," && r !== "," && r !== ",(" && (r = "", e = !1); + continue; + } + i += a, r += a; + } + } + if (!s) + throw new pt("Unable to normalize signature."); + return i; +} +const pD = (t) => { + const e = typeof t == "string" ? t : wT(t); + return dD(e); +}; +function u4(t) { + return hD(pD(t)); +} +const gD = u4; +class Ho extends pt { + constructor({ address: e }) { + super(`Address "${e}" is invalid.`, { + metaMessages: [ + "- Address must be a hex value of 20 bytes (40 hex characters).", + "- Address must match its checksum counterpart." + ], + name: "InvalidAddressError" + }); + } +} +class qd extends Map { + constructor(e) { + super(), Object.defineProperty(this, "maxSize", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.maxSize = e; + } + get(e) { + const r = super.get(e); + return super.has(e) && r !== void 0 && (this.delete(e), super.set(e, r)), r; + } + set(e, r) { + if (super.set(e, r), this.maxSize && this.size > this.maxSize) { + const n = this.keys().next().value; + n && this.delete(n); + } + return this; + } +} +const Fp = /* @__PURE__ */ new qd(8192); +function Vf(t, e) { + if (Fp.has(`${t}.${e}`)) + return Fp.get(`${t}.${e}`); + const r = t.substring(2).toLowerCase(), n = Ud(e4(r), "bytes"), i = r.split(""); + for (let o = 0; o < 40; o += 2) + n[o >> 1] >> 4 >= 8 && i[o] && (i[o] = i[o].toUpperCase()), (n[o >> 1] & 15) >= 8 && i[o + 1] && (i[o + 1] = i[o + 1].toUpperCase()); + const s = `0x${i.join("")}`; + return Fp.set(`${t}.${e}`, s), s; +} +function e1(t, e) { + if (!fs(t, { strict: !1 })) + throw new Ho({ address: t }); + return Vf(t, e); +} +const mD = /^0x[a-fA-F0-9]{40}$/, jp = /* @__PURE__ */ new qd(8192); +function fs(t, e) { + const { strict: r = !0 } = e ?? {}, n = `${t}.${r}`; + if (jp.has(n)) + return jp.get(n); + const i = mD.test(t) ? t.toLowerCase() === t ? !0 : r ? Vf(t) === t : !0 : !1; + return jp.set(n, i), i; +} +function Wo(t) { + return typeof t[0] == "string" ? zd(t) : vD(t); +} +function vD(t) { + let e = 0; + for (const i of t) + e += i.length; + const r = new Uint8Array(e); + let n = 0; + for (const i of t) + r.set(i, n), n += i.length; + return r; +} +function zd(t) { + return `0x${t.reduce((e, r) => e + r.replace("0x", ""), "")}`; +} +function ud(t, e, r, { strict: n } = {}) { + return Uo(t, { strict: !1 }) ? $m(t, e, r, { + strict: n + }) : h4(t, e, r, { + strict: n + }); +} +function f4(t, e) { + if (typeof e == "number" && e > 0 && e > yn(t) - 1) + throw new J5({ + offset: e, + position: "start", + size: yn(t) + }); +} +function l4(t, e, r) { + if (typeof e == "number" && typeof r == "number" && yn(t) !== r - e) + throw new J5({ + offset: r, + position: "end", + size: yn(t) + }); +} +function h4(t, e, r, { strict: n } = {}) { + f4(t, e); + const i = t.slice(e, r); + return n && l4(i, e, r), i; +} +function $m(t, e, r, { strict: n } = {}) { + f4(t, e); + const i = `0x${t.replace("0x", "").slice((e ?? 0) * 2, (r ?? t.length) * 2)}`; + return n && l4(i, e, r), i; +} +const bD = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, d4 = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/; +function p4(t, e) { + if (t.length !== e.length) + throw new PT({ + expectedLength: t.length, + givenLength: e.length + }); + const r = yD({ + params: t, + values: e + }), n = r1(r); + return n.length === 0 ? "0x" : n; +} +function yD({ params: t, values: e }) { + const r = []; + for (let n = 0; n < t.length; n++) + r.push(t1({ param: t[n], value: e[n] })); + return r; +} +function t1({ param: t, value: e }) { + const r = n1(t.type); + if (r) { + const [n, i] = r; + return xD(e, { length: n, param: { ...t, type: i } }); + } + if (t.type === "tuple") + return PD(e, { + param: t + }); + if (t.type === "address") + return wD(e); + if (t.type === "bool") + return ED(e); + if (t.type.startsWith("uint") || t.type.startsWith("int")) { + const n = t.type.startsWith("int"), [, , i = "256"] = d4.exec(t.type) ?? []; + return SD(e, { + signed: n, + size: Number(i) + }); + } + if (t.type.startsWith("bytes")) + return _D(e, { param: t }); + if (t.type === "string") + return AD(e); + throw new CT(t.type, { + docsPath: "/docs/contract/encodeAbiParameters" + }); +} +function r1(t) { + let e = 0; + for (let s = 0; s < t.length; s++) { + const { dynamic: o, encoded: a } = t[s]; + o ? e += 32 : e += yn(a); + } + const r = [], n = []; + let i = 0; + for (let s = 0; s < t.length; s++) { + const { dynamic: o, encoded: a } = t[s]; + o ? (r.push(br(e + i, { size: 32 })), n.push(a), i += yn(a)) : r.push(a); + } + return Wo([...r, ...n]); +} +function wD(t) { + if (!fs(t)) + throw new Ho({ address: t }); + return { dynamic: !1, encoded: jo(t.toLowerCase()) }; +} +function xD(t, { length: e, param: r }) { + const n = e === null; + if (!Array.isArray(t)) + throw new TT(t); + if (!n && t.length !== e) + throw new ST({ + expectedLength: e, + givenLength: t.length, + type: `${r.type}[${e}]` + }); + let i = !1; + const s = []; + for (let o = 0; o < t.length; o++) { + const a = t1({ param: r, value: t[o] }); + a.dynamic && (i = !0), s.push(a); + } + if (n || i) { + const o = r1(s); + if (n) { + const a = br(s.length, { size: 32 }); + return { + dynamic: !0, + encoded: s.length > 0 ? Wo([a, o]) : a + }; + } + if (i) + return { dynamic: !0, encoded: o }; + } + return { + dynamic: !1, + encoded: Wo(s.map(({ encoded: o }) => o)) + }; +} +function _D(t, { param: e }) { + const [, r] = e.type.split("bytes"), n = yn(t); + if (!r) { + let i = t; + return n % 32 !== 0 && (i = jo(i, { + dir: "right", + size: Math.ceil((t.length - 2) / 2 / 32) * 32 + })), { + dynamic: !0, + encoded: Wo([jo(br(n, { size: 32 })), i]) + }; + } + if (n !== Number.parseInt(r)) + throw new AT({ + expectedSize: Number.parseInt(r), + value: t + }); + return { dynamic: !1, encoded: jo(t, { dir: "right" }) }; +} +function ED(t) { + if (typeof t != "boolean") + throw new pt(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`); + return { dynamic: !1, encoded: jo(Q5(t)) }; +} +function SD(t, { signed: e, size: r = 256 }) { + if (typeof r == "number") { + const n = 2n ** (BigInt(r) - (e ? 1n : 0n)) - 1n, i = e ? -n - 1n : 0n; + if (t > n || t < i) + throw new Z5({ + max: n.toString(), + min: i.toString(), + signed: e, + size: r / 8, + value: t.toString() + }); + } + return { + dynamic: !1, + encoded: br(t, { + size: 32, + signed: e + }) + }; +} +function AD(t) { + const e = jd(t), r = Math.ceil(yn(e) / 32), n = []; + for (let i = 0; i < r; i++) + n.push(jo(ud(e, i * 32, (i + 1) * 32), { + dir: "right" + })); + return { + dynamic: !0, + encoded: Wo([ + jo(br(yn(e), { size: 32 })), + ...n + ]) + }; +} +function PD(t, { param: e }) { + let r = !1; + const n = []; + for (let i = 0; i < e.components.length; i++) { + const s = e.components[i], o = Array.isArray(t) ? i : s.name, a = t1({ + param: s, + value: t[o] + }); + n.push(a), a.dynamic && (r = !0); + } + return { + dynamic: r, + encoded: r ? r1(n) : Wo(n.map(({ encoded: i }) => i)) + }; +} +function n1(t) { + const e = t.match(/^(.*)\[(\d+)?\]$/); + return e ? ( + // Return `null` if the array is dynamic. + [e[2] ? Number(e[2]) : null, e[1]] + ) : void 0; +} +const i1 = (t) => ud(u4(t), 0, 4); +function g4(t) { + const { abi: e, args: r = [], name: n } = t, i = Uo(n, { strict: !1 }), s = e.filter((a) => i ? a.type === "function" ? i1(a) === n : a.type === "event" ? gD(a) === n : !1 : "name" in a && a.name === n); + if (s.length === 0) + return; + if (s.length === 1) + return s[0]; + let o; + for (const a of s) { + if (!("inputs" in a)) + continue; + if (!r || r.length === 0) { + if (!a.inputs || a.inputs.length === 0) + return a; + continue; + } + if (!a.inputs || a.inputs.length === 0 || a.inputs.length !== r.length) + continue; + if (r.every((u, h) => { + const g = "inputs" in a && a.inputs[h]; + return g ? Bm(u, g) : !1; + })) { + if (o && "inputs" in o && o.inputs) { + const u = m4(a.inputs, o.inputs, r); + if (u) + throw new MT({ + abiItem: a, + type: u[0] + }, { + abiItem: o, + type: u[1] + }); + } + o = a; + } + } + return o || s[0]; +} +function Bm(t, e) { + const r = typeof t, n = e.type; + switch (n) { + case "address": + return fs(t, { strict: !1 }); + case "bool": + return r === "boolean"; + case "function": + return r === "string"; + case "string": + return r === "string"; + default: + return n === "tuple" && "components" in e ? Object.values(e.components).every((i, s) => Bm(Object.values(t)[s], i)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(n) ? r === "number" || r === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(n) ? r === "string" || t instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(n) ? Array.isArray(t) && t.every((i) => Bm(i, { + ...e, + // Pop off `[]` or `[M]` from end of type + type: n.replace(/(\[[0-9]{0,}\])$/, "") + })) : !1; + } +} +function m4(t, e, r) { + for (const n in t) { + const i = t[n], s = e[n]; + if (i.type === "tuple" && s.type === "tuple" && "components" in i && "components" in s) + return m4(i.components, s.components, r[n]); + const o = [i.type, s.type]; + if (o.includes("address") && o.includes("bytes20") ? !0 : o.includes("address") && o.includes("string") ? fs(r[n], { strict: !1 }) : o.includes("address") && o.includes("bytes") ? fs(r[n], { strict: !1 }) : !1) + return o; + } +} +function pi(t) { + return typeof t == "string" ? { address: t, type: "json-rpc" } : t; +} +const Hw = "/docs/contract/encodeFunctionData"; +function MD(t) { + const { abi: e, args: r, functionName: n } = t; + let i = e[0]; + if (n) { + const s = g4({ + abi: e, + args: r, + name: n + }); + if (!s) + throw new kw(n, { docsPath: Hw }); + i = s; + } + if (i.type !== "function") + throw new kw(void 0, { docsPath: Hw }); + return { + abi: [i], + functionName: i1(Bc(i)) + }; +} +function v4(t) { + const { args: e } = t, { abi: r, functionName: n } = t.abi.length === 1 && t.functionName?.startsWith("0x") ? t : MD(t), i = r[0], s = n, o = "inputs" in i && i.inputs ? p4(i.inputs, e ?? []) : void 0; + return zd([s, o ?? "0x"]); +} +const ID = { + 1: "An `assert` condition failed.", + 17: "Arithmetic operation resulted in underflow or overflow.", + 18: "Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).", + 33: "Attempted to convert to an invalid type.", + 34: "Attempted to access a storage byte array that is incorrectly encoded.", + 49: "Performed `.pop()` on an empty array", + 50: "Array index is out of bounds.", + 65: "Allocated too much memory or created an array which is too large.", + 81: "Attempted to call a zero-initialized variable of internal function type." +}, CD = { + inputs: [ + { + name: "message", + type: "string" + } + ], + name: "Error", + type: "error" +}, RD = { + inputs: [ + { + name: "reason", + type: "uint256" + } + ], + name: "Panic", + type: "error" +}; +class Ww extends pt { + constructor({ offset: e }) { + super(`Offset \`${e}\` cannot be negative.`, { + name: "NegativeOffsetError" + }); + } +} +class TD extends pt { + constructor({ length: e, position: r }) { + super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`, { name: "PositionOutOfBoundsError" }); + } +} +class DD extends pt { + constructor({ count: e, limit: r }) { + super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`, { name: "RecursiveReadLimitExceededError" }); + } +} +const OD = { + bytes: new Uint8Array(), + dataView: new DataView(new ArrayBuffer(0)), + position: 0, + positionReadCount: /* @__PURE__ */ new Map(), + recursiveReadCount: 0, + recursiveReadLimit: Number.POSITIVE_INFINITY, + assertReadLimit() { + if (this.recursiveReadCount >= this.recursiveReadLimit) + throw new DD({ + count: this.recursiveReadCount + 1, + limit: this.recursiveReadLimit + }); + }, + assertPosition(t) { + if (t < 0 || t > this.bytes.length - 1) + throw new TD({ + length: this.bytes.length, + position: t + }); + }, + decrementPosition(t) { + if (t < 0) + throw new Ww({ offset: t }); + const e = this.position - t; + this.assertPosition(e), this.position = e; + }, + getReadCount(t) { + return this.positionReadCount.get(t || this.position) || 0; + }, + incrementPosition(t) { + if (t < 0) + throw new Ww({ offset: t }); + const e = this.position + t; + this.assertPosition(e), this.position = e; + }, + inspectByte(t) { + const e = t ?? this.position; + return this.assertPosition(e), this.bytes[e]; + }, + inspectBytes(t, e) { + const r = e ?? this.position; + return this.assertPosition(r + t - 1), this.bytes.subarray(r, r + t); + }, + inspectUint8(t) { + const e = t ?? this.position; + return this.assertPosition(e), this.bytes[e]; + }, + inspectUint16(t) { + const e = t ?? this.position; + return this.assertPosition(e + 1), this.dataView.getUint16(e); + }, + inspectUint24(t) { + const e = t ?? this.position; + return this.assertPosition(e + 2), (this.dataView.getUint16(e) << 8) + this.dataView.getUint8(e + 2); + }, + inspectUint32(t) { + const e = t ?? this.position; + return this.assertPosition(e + 3), this.dataView.getUint32(e); + }, + pushByte(t) { + this.assertPosition(this.position), this.bytes[this.position] = t, this.position++; + }, + pushBytes(t) { + this.assertPosition(this.position + t.length - 1), this.bytes.set(t, this.position), this.position += t.length; + }, + pushUint8(t) { + this.assertPosition(this.position), this.bytes[this.position] = t, this.position++; + }, + pushUint16(t) { + this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, t), this.position += 2; + }, + pushUint24(t) { + this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, t >> 8), this.dataView.setUint8(this.position + 2, t & 255), this.position += 3; + }, + pushUint32(t) { + this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, t), this.position += 4; + }, + readByte() { + this.assertReadLimit(), this._touch(); + const t = this.inspectByte(); + return this.position++, t; + }, + readBytes(t, e) { + this.assertReadLimit(), this._touch(); + const r = this.inspectBytes(t); + return this.position += e ?? t, r; + }, + readUint8() { + this.assertReadLimit(), this._touch(); + const t = this.inspectUint8(); + return this.position += 1, t; + }, + readUint16() { + this.assertReadLimit(), this._touch(); + const t = this.inspectUint16(); + return this.position += 2, t; + }, + readUint24() { + this.assertReadLimit(), this._touch(); + const t = this.inspectUint24(); + return this.position += 3, t; + }, + readUint32() { + this.assertReadLimit(), this._touch(); + const t = this.inspectUint32(); + return this.position += 4, t; + }, + get remaining() { + return this.bytes.length - this.position; + }, + setPosition(t) { + const e = this.position; + return this.assertPosition(t), this.position = t, () => this.position = e; + }, + _touch() { + if (this.recursiveReadLimit === Number.POSITIVE_INFINITY) + return; + const t = this.getReadCount(); + this.positionReadCount.set(this.position, t + 1), t > 0 && this.recursiveReadCount++; + } +}; +function s1(t, { recursiveReadLimit: e = 8192 } = {}) { + const r = Object.create(OD); + return r.bytes = t, r.dataView = new DataView(t.buffer, t.byteOffset, t.byteLength), r.positionReadCount = /* @__PURE__ */ new Map(), r.recursiveReadLimit = e, r; +} +function ND(t, e = {}) { + typeof e.size < "u" && Ns(t, { size: e.size }); + const r = di(t, e); + return qo(r, e); +} +function LD(t, e = {}) { + let r = t; + if (typeof e.size < "u" && (Ns(r, { size: e.size }), r = Fd(r)), r.length > 1 || r[0] > 1) + throw new NT(r); + return !!r[0]; +} +function io(t, e = {}) { + typeof e.size < "u" && Ns(t, { size: e.size }); + const r = di(t, e); + return zo(r, e); +} +function kD(t, e = {}) { + let r = t; + return typeof e.size < "u" && (Ns(r, { size: e.size }), r = Fd(r, { dir: "right" })), new TextDecoder().decode(r); +} +function $D(t, e) { + const r = typeof e == "string" ? lo(e) : e, n = s1(r); + if (yn(r) === 0 && t.length > 0) + throw new Jv(); + if (yn(e) && yn(e) < 32) + throw new ET({ + data: typeof e == "string" ? e : di(e), + params: t, + size: yn(e) + }); + let i = 0; + const s = []; + for (let o = 0; o < t.length; ++o) { + const a = t[o]; + n.setPosition(i); + const [f, u] = Cc(n, a, { + staticPosition: 0 + }); + i += u, s.push(f); + } + return s; +} +function Cc(t, e, { staticPosition: r }) { + const n = n1(e.type); + if (n) { + const [i, s] = n; + return FD(t, { ...e, type: s }, { length: i, staticPosition: r }); + } + if (e.type === "tuple") + return zD(t, e, { staticPosition: r }); + if (e.type === "address") + return BD(t); + if (e.type === "bool") + return jD(t); + if (e.type.startsWith("bytes")) + return UD(t, e, { staticPosition: r }); + if (e.type.startsWith("uint") || e.type.startsWith("int")) + return qD(t, e); + if (e.type === "string") + return HD(t, { staticPosition: r }); + throw new RT(e.type, { + docsPath: "/docs/contract/decodeAbiParameters" + }); +} +const Kw = 32, Fm = 32; +function BD(t) { + const e = t.readBytes(32); + return [Vf(di(h4(e, -20))), 32]; +} +function FD(t, e, { length: r, staticPosition: n }) { + if (!r) { + const o = io(t.readBytes(Fm)), a = n + o, f = a + Kw; + t.setPosition(a); + const u = io(t.readBytes(Kw)), h = df(e); + let g = 0; + const v = []; + for (let x = 0; x < u; ++x) { + t.setPosition(f + (h ? x * 32 : g)); + const [S, R] = Cc(t, e, { + staticPosition: f + }); + g += R, v.push(S); + } + return t.setPosition(n + 32), [v, 32]; + } + if (df(e)) { + const o = io(t.readBytes(Fm)), a = n + o, f = []; + for (let u = 0; u < r; ++u) { + t.setPosition(a + u * 32); + const [h] = Cc(t, e, { + staticPosition: a + }); + f.push(h); + } + return t.setPosition(n + 32), [f, 32]; + } + let i = 0; + const s = []; + for (let o = 0; o < r; ++o) { + const [a, f] = Cc(t, e, { + staticPosition: n + i + }); + i += f, s.push(a); + } + return [s, i]; +} +function jD(t) { + return [LD(t.readBytes(32), { size: 32 }), 32]; +} +function UD(t, e, { staticPosition: r }) { + const [n, i] = e.type.split("bytes"); + if (!i) { + const o = io(t.readBytes(32)); + t.setPosition(r + o); + const a = io(t.readBytes(32)); + if (a === 0) + return t.setPosition(r + 32), ["0x", 32]; + const f = t.readBytes(a); + return t.setPosition(r + 32), [di(f), 32]; + } + return [di(t.readBytes(Number.parseInt(i), 32)), 32]; +} +function qD(t, e) { + const r = e.type.startsWith("int"), n = Number.parseInt(e.type.split("int")[1] || "256"), i = t.readBytes(32); + return [ + n > 48 ? ND(i, { signed: r }) : io(i, { signed: r }), + 32 + ]; +} +function zD(t, e, { staticPosition: r }) { + const n = e.components.length === 0 || e.components.some(({ name: o }) => !o), i = n ? [] : {}; + let s = 0; + if (df(e)) { + const o = io(t.readBytes(Fm)), a = r + o; + for (let f = 0; f < e.components.length; ++f) { + const u = e.components[f]; + t.setPosition(a + s); + const [h, g] = Cc(t, u, { + staticPosition: a + }); + s += g, i[n ? f : u?.name] = h; + } + return t.setPosition(r + 32), [i, 32]; + } + for (let o = 0; o < e.components.length; ++o) { + const a = e.components[o], [f, u] = Cc(t, a, { + staticPosition: r + }); + i[n ? o : a?.name] = f, s += u; + } + return [i, s]; +} +function HD(t, { staticPosition: e }) { + const r = io(t.readBytes(32)), n = e + r; + t.setPosition(n); + const i = io(t.readBytes(32)); + if (i === 0) + return t.setPosition(e + 32), ["", 32]; + const s = t.readBytes(i, 32), o = kD(Fd(s)); + return t.setPosition(e + 32), [o, 32]; +} +function df(t) { + const { type: e } = t; + if (e === "string" || e === "bytes" || e.endsWith("[]")) + return !0; + if (e === "tuple") + return t.components?.some(df); + const r = n1(t.type); + return !!(r && df({ ...t, type: r[1] })); +} +function WD(t) { + const { abi: e, data: r } = t, n = ud(r, 0, 4); + if (n === "0x") + throw new Jv(); + const s = [...e || [], CD, RD].find((o) => o.type === "error" && n === i1(Bc(o))); + if (!s) + throw new Y5(n, { + docsPath: "/docs/contract/decodeErrorResult" + }); + return { + abiItem: s, + args: "inputs" in s && s.inputs && s.inputs.length > 0 ? $D(s.inputs, ud(r, 4)) : void 0, + errorName: s.name + }; +} +const Ua = (t, e, r) => JSON.stringify(t, (n, i) => typeof i == "bigint" ? i.toString() : i, r); +function b4({ abiItem: t, args: e, includeFunctionName: r = !0, includeName: n = !1 }) { + if ("name" in t && "inputs" in t && t.inputs) + return `${r ? t.name : ""}(${t.inputs.map((i, s) => `${n && i.name ? `${i.name}: ` : ""}${typeof e[s] == "object" ? Ua(e[s]) : e[s]}`).join(", ")})`; +} +const KD = { + gwei: 9, + wei: 18 +}, VD = { + ether: -9, + wei: 9 +}; +function y4(t, e) { + let r = t.toString(); + const n = r.startsWith("-"); + n && (r = r.slice(1)), r = r.padStart(e, "0"); + let [i, s] = [ + r.slice(0, r.length - e), + r.slice(r.length - e) + ]; + return s = s.replace(/(0+)$/, ""), `${n ? "-" : ""}${i || "0"}${s ? `.${s}` : ""}`; +} +function w4(t, e = "wei") { + return y4(t, KD[e]); +} +function us(t, e = "wei") { + return y4(t, VD[e]); +} +class GD extends pt { + constructor({ address: e }) { + super(`State for account "${e}" is set multiple times.`, { + name: "AccountStateConflictError" + }); + } +} +class YD extends pt { + constructor() { + super("state and stateDiff are set on the same account.", { + name: "StateAssignmentConflictError" + }); + } +} +function Hd(t) { + const e = Object.entries(t).map(([n, i]) => i === void 0 || i === !1 ? null : [n, i]).filter(Boolean), r = e.reduce((n, [i]) => Math.max(n, i.length), 0); + return e.map(([n, i]) => ` ${`${n}:`.padEnd(r + 1)} ${i}`).join(` +`); +} +class JD extends pt { + constructor() { + super([ + "Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.", + "Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others." + ].join(` +`), { name: "FeeConflictError" }); + } +} +class XD extends pt { + constructor({ transaction: e }) { + super("Cannot infer a transaction type from provided transaction.", { + metaMessages: [ + "Provided Transaction:", + "{", + Hd(e), + "}", + "", + "To infer the type, either provide:", + "- a `type` to the Transaction, or", + "- an EIP-1559 Transaction with `maxFeePerGas`, or", + "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or", + "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or", + "- an EIP-7702 Transaction with `authorizationList`, or", + "- a Legacy Transaction with `gasPrice`" + ], + name: "InvalidSerializableTransactionError" + }); + } +} +class ZD extends pt { + constructor(e, { account: r, docsPath: n, chain: i, data: s, gas: o, gasPrice: a, maxFeePerGas: f, maxPriorityFeePerGas: u, nonce: h, to: g, value: v }) { + const x = Hd({ + chain: i && `${i?.name} (id: ${i?.id})`, + from: r?.address, + to: g, + value: typeof v < "u" && `${w4(v)} ${i?.nativeCurrency?.symbol || "ETH"}`, + data: s, + gas: o, + gasPrice: typeof a < "u" && `${us(a)} gwei`, + maxFeePerGas: typeof f < "u" && `${us(f)} gwei`, + maxPriorityFeePerGas: typeof u < "u" && `${us(u)} gwei`, + nonce: h + }); + super(e.shortMessage, { + cause: e, + docsPath: n, + metaMessages: [ + ...e.metaMessages ? [...e.metaMessages, " "] : [], + "Request Arguments:", + x + ].filter(Boolean), + name: "TransactionExecutionError" + }), Object.defineProperty(this, "cause", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.cause = e; + } +} +const QD = (t) => t, x4 = (t) => t; +class eO extends pt { + constructor(e, { abi: r, args: n, contractAddress: i, docsPath: s, functionName: o, sender: a }) { + const f = g4({ abi: r, args: n, name: o }), u = f ? b4({ + abiItem: f, + args: n, + includeFunctionName: !1, + includeName: !1 + }) : void 0, h = f ? Bc(f, { includeName: !0 }) : void 0, g = Hd({ + address: i && QD(i), + function: h, + args: u && u !== "()" && `${[...Array(o?.length ?? 0).keys()].map(() => " ").join("")}${u}`, + sender: a + }); + super(e.shortMessage || `An unknown error occurred while executing the contract function "${o}".`, { + cause: e, + docsPath: s, + metaMessages: [ + ...e.metaMessages ? [...e.metaMessages, " "] : [], + g && "Contract Call:", + g + ].filter(Boolean), + name: "ContractFunctionExecutionError" + }), Object.defineProperty(this, "abi", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "args", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "cause", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "contractAddress", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "formattedArgs", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "functionName", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "sender", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.abi = r, this.args = n, this.cause = e, this.contractAddress = i, this.functionName = o, this.sender = a; + } +} +class tO extends pt { + constructor({ abi: e, data: r, functionName: n, message: i }) { + let s, o, a, f; + if (r && r !== "0x") + try { + o = WD({ abi: e, data: r }); + const { abiItem: h, errorName: g, args: v } = o; + if (g === "Error") + f = v[0]; + else if (g === "Panic") { + const [x] = v; + f = ID[x]; + } else { + const x = h ? Bc(h, { includeName: !0 }) : void 0, S = h && v ? b4({ + abiItem: h, + args: v, + includeFunctionName: !1, + includeName: !1 + }) : void 0; + a = [ + x ? `Error: ${x}` : "", + S && S !== "()" ? ` ${[...Array(g?.length ?? 0).keys()].map(() => " ").join("")}${S}` : "" + ]; + } + } catch (h) { + s = h; + } + else i && (f = i); + let u; + s instanceof Y5 && (u = s.signature, a = [ + `Unable to decode signature "${u}" as it was not found on the provided ABI.`, + "Make sure you are using the correct ABI and that the error exists on it.", + `You can look up the decoded signature here: https://openchain.xyz/signatures?query=${u}.` + ]), super(f && f !== "execution reverted" || u ? [ + `The contract function "${n}" reverted with the following ${u ? "signature" : "reason"}:`, + f || u + ].join(` +`) : `The contract function "${n}" reverted.`, { + cause: s, + metaMessages: a, + name: "ContractFunctionRevertedError" + }), Object.defineProperty(this, "data", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "raw", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "reason", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "signature", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.data = o, this.raw = r, this.reason = f, this.signature = u; + } +} +class rO extends pt { + constructor({ functionName: e }) { + super(`The contract function "${e}" returned no data ("0x").`, { + metaMessages: [ + "This could be due to any of the following:", + ` - The contract does not have the function "${e}",`, + " - The parameters passed to the contract function may be invalid, or", + " - The address is not a contract." + ], + name: "ContractFunctionZeroDataError" + }); + } +} +class nO extends pt { + constructor({ data: e, message: r }) { + super(r || "", { name: "RawContractError" }), Object.defineProperty(this, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 3 + }), Object.defineProperty(this, "data", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.data = e; + } +} +class _4 extends pt { + constructor({ body: e, cause: r, details: n, headers: i, status: s, url: o }) { + super("HTTP request failed.", { + cause: r, + details: n, + metaMessages: [ + s && `Status: ${s}`, + `URL: ${x4(o)}`, + e && `Request body: ${Ua(e)}` + ].filter(Boolean), + name: "HttpRequestError" + }), Object.defineProperty(this, "body", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "headers", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "status", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "url", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.body = e, this.headers = i, this.status = s, this.url = o; + } +} +class E4 extends pt { + constructor({ body: e, error: r, url: n }) { + super("RPC Request failed.", { + cause: r, + details: r.message, + metaMessages: [`URL: ${x4(n)}`, `Request body: ${Ua(e)}`], + name: "RpcRequestError" + }), Object.defineProperty(this, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), Object.defineProperty(this, "data", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.code = r.code, this.data = r.data; + } +} +const iO = -1; +class gi extends pt { + constructor(e, { code: r, docsPath: n, metaMessages: i, name: s, shortMessage: o }) { + super(o, { + cause: e, + docsPath: n, + metaMessages: i || e?.metaMessages, + name: s || "RpcError" + }), Object.defineProperty(this, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.name = s || e.name, this.code = e instanceof E4 ? e.code : r ?? iO; + } +} +class Mi extends gi { + constructor(e, r) { + super(e, r), Object.defineProperty(this, "data", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.data = r.data; + } +} +class pf extends gi { + constructor(e) { + super(e, { + code: pf.code, + name: "ParseRpcError", + shortMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text." + }); + } +} +Object.defineProperty(pf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32700 +}); +class gf extends gi { + constructor(e) { + super(e, { + code: gf.code, + name: "InvalidRequestRpcError", + shortMessage: "JSON is not a valid request object." + }); + } +} +Object.defineProperty(gf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32600 +}); +class mf extends gi { + constructor(e, { method: r } = {}) { + super(e, { + code: mf.code, + name: "MethodNotFoundRpcError", + shortMessage: `The method${r ? ` "${r}"` : ""} does not exist / is not available.` + }); + } +} +Object.defineProperty(mf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32601 +}); +class vf extends gi { + constructor(e) { + super(e, { + code: vf.code, + name: "InvalidParamsRpcError", + shortMessage: [ + "Invalid parameters were provided to the RPC method.", + "Double check you have provided the correct parameters." + ].join(` +`) + }); + } +} +Object.defineProperty(vf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32602 +}); +class Oa extends gi { + constructor(e) { + super(e, { + code: Oa.code, + name: "InternalRpcError", + shortMessage: "An internal error was received." + }); + } +} +Object.defineProperty(Oa, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32603 +}); +class bf extends gi { + constructor(e) { + super(e, { + code: bf.code, + name: "InvalidInputRpcError", + shortMessage: [ + "Missing or invalid parameters.", + "Double check you have provided the correct parameters." + ].join(` +`) + }); + } +} +Object.defineProperty(bf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32e3 +}); +class yf extends gi { + constructor(e) { + super(e, { + code: yf.code, + name: "ResourceNotFoundRpcError", + shortMessage: "Requested resource not found." + }), Object.defineProperty(this, "name", { + enumerable: !0, + configurable: !0, + writable: !0, + value: "ResourceNotFoundRpcError" + }); + } +} +Object.defineProperty(yf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32001 +}); +class wf extends gi { + constructor(e) { + super(e, { + code: wf.code, + name: "ResourceUnavailableRpcError", + shortMessage: "Requested resource not available." + }); + } +} +Object.defineProperty(wf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32002 +}); +class xf extends gi { + constructor(e) { + super(e, { + code: xf.code, + name: "TransactionRejectedRpcError", + shortMessage: "Transaction creation failed." + }); + } +} +Object.defineProperty(xf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32003 +}); +class Aa extends gi { + constructor(e, { method: r } = {}) { + super(e, { + code: Aa.code, + name: "MethodNotSupportedRpcError", + shortMessage: `Method${r ? ` "${r}"` : ""} is not supported.` + }); + } +} +Object.defineProperty(Aa, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32004 +}); +class Fc extends gi { + constructor(e) { + super(e, { + code: Fc.code, + name: "LimitExceededRpcError", + shortMessage: "Request exceeds defined limit." + }); + } +} +Object.defineProperty(Fc, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32005 +}); +class _f extends gi { + constructor(e) { + super(e, { + code: _f.code, + name: "JsonRpcVersionUnsupportedError", + shortMessage: "Version of JSON-RPC protocol is not supported." + }); + } +} +Object.defineProperty(_f, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: -32006 +}); +class Rc extends Mi { + constructor(e) { + super(e, { + code: Rc.code, + name: "UserRejectedRequestError", + shortMessage: "User rejected the request." + }); + } +} +Object.defineProperty(Rc, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 4001 +}); +class Ef extends Mi { + constructor(e) { + super(e, { + code: Ef.code, + name: "UnauthorizedProviderError", + shortMessage: "The requested method and/or account has not been authorized by the user." + }); + } +} +Object.defineProperty(Ef, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 4100 +}); +class Sf extends Mi { + constructor(e, { method: r } = {}) { + super(e, { + code: Sf.code, + name: "UnsupportedProviderMethodError", + shortMessage: `The Provider does not support the requested method${r ? ` " ${r}"` : ""}.` + }); + } +} +Object.defineProperty(Sf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 4200 +}); +class Af extends Mi { + constructor(e) { + super(e, { + code: Af.code, + name: "ProviderDisconnectedError", + shortMessage: "The Provider is disconnected from all chains." + }); + } +} +Object.defineProperty(Af, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 4900 +}); +class Pf extends Mi { + constructor(e) { + super(e, { + code: Pf.code, + name: "ChainDisconnectedError", + shortMessage: "The Provider is not connected to the requested chain." + }); + } +} +Object.defineProperty(Pf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 4901 +}); +class Mf extends Mi { + constructor(e) { + super(e, { + code: Mf.code, + name: "SwitchChainError", + shortMessage: "An error occurred when attempting to switch chain." + }); + } +} +Object.defineProperty(Mf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 4902 +}); +class jc extends Mi { + constructor(e) { + super(e, { + code: jc.code, + name: "UnsupportedNonOptionalCapabilityError", + shortMessage: "This Wallet does not support a capability that was not marked as optional." + }); + } +} +Object.defineProperty(jc, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 5700 +}); +class If extends Mi { + constructor(e) { + super(e, { + code: If.code, + name: "UnsupportedChainIdError", + shortMessage: "This Wallet does not support the requested chain ID." + }); + } +} +Object.defineProperty(If, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 5710 +}); +class Cf extends Mi { + constructor(e) { + super(e, { + code: Cf.code, + name: "DuplicateIdError", + shortMessage: "There is already a bundle submitted with this ID." + }); + } +} +Object.defineProperty(Cf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 5720 +}); +class Rf extends Mi { + constructor(e) { + super(e, { + code: Rf.code, + name: "UnknownBundleIdError", + shortMessage: "This bundle id is unknown / has not been submitted" + }); + } +} +Object.defineProperty(Rf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 5730 +}); +class Tf extends Mi { + constructor(e) { + super(e, { + code: Tf.code, + name: "BundleTooLargeError", + shortMessage: "The call bundle is too large for the Wallet to process." + }); + } +} +Object.defineProperty(Tf, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 5740 +}); +class Df extends Mi { + constructor(e) { + super(e, { + code: Df.code, + name: "AtomicReadyWalletRejectedUpgradeError", + shortMessage: "The Wallet can support atomicity after an upgrade, but the user rejected the upgrade." + }); + } +} +Object.defineProperty(Df, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 5750 +}); +class Uc extends Mi { + constructor(e) { + super(e, { + code: Uc.code, + name: "AtomicityNotSupportedError", + shortMessage: "The wallet does not support atomic execution but the request requires it." + }); + } +} +Object.defineProperty(Uc, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 5760 +}); +class sO extends gi { + constructor(e) { + super(e, { + name: "UnknownRpcError", + shortMessage: "An unknown RPC error occurred." + }); + } +} +const oO = 3; +function aO(t, { abi: e, address: r, args: n, docsPath: i, functionName: s, sender: o }) { + const a = t instanceof nO ? t : t instanceof pt ? t.walk((S) => "data" in S) || t.walk() : {}, { code: f, data: u, details: h, message: g, shortMessage: v } = a, x = t instanceof Jv ? new rO({ functionName: s }) : [oO, Oa.code].includes(f) && (u || h || g || v) ? new tO({ + abi: e, + data: typeof u == "object" ? u.data : u, + functionName: s, + message: a instanceof E4 ? h : v ?? g + }) : t; + return new eO(x, { + abi: e, + args: n, + contractAddress: r, + docsPath: i, + functionName: s, + sender: o + }); +} +function cO(t) { + const e = Ud(`0x${t.substring(4)}`).substring(26); + return Vf(`0x${e}`); +} +async function uO({ hash: t, signature: e }) { + const r = Uo(t) ? t : od(t), { secp256k1: n } = await import("./secp256k1-C66jOJWb.js"); + return `0x${(() => { + if (typeof e == "object" && "r" in e && "s" in e) { + const { r: u, s: h, v: g, yParity: v } = e, x = Number(v ?? g), S = Vw(x); + return new n.Signature(qo(u), qo(h)).addRecoveryBit(S); + } + const o = Uo(e) ? e : od(e); + if (yn(o) !== 65) + throw new Error("invalid signature length"); + const a = zo(`0x${o.slice(130)}`), f = Vw(a); + return n.Signature.fromCompact(o.substring(2, 130)).addRecoveryBit(f); + })().recoverPublicKey(r.substring(2)).toHex(!1)}`; +} +function Vw(t) { + if (t === 0 || t === 1) + return t; + if (t === 27) + return 0; + if (t === 28) + return 1; + throw new Error("Invalid yParityOrV value"); +} +async function fO({ hash: t, signature: e }) { + return cO(await uO({ hash: t, signature: e })); +} +function lO(t, e = "hex") { + const r = S4(t), n = s1(new Uint8Array(r.length)); + return r.encode(n), e === "hex" ? di(n.bytes) : n.bytes; +} +function S4(t) { + return Array.isArray(t) ? hO(t.map((e) => S4(e))) : dO(t); +} +function hO(t) { + const e = t.reduce((i, s) => i + s.length, 0), r = A4(e); + return { + length: e <= 55 ? 1 + e : 1 + r + e, + encode(i) { + e <= 55 ? i.pushByte(192 + e) : (i.pushByte(247 + r), r === 1 ? i.pushUint8(e) : r === 2 ? i.pushUint16(e) : r === 3 ? i.pushUint24(e) : i.pushUint32(e)); + for (const { encode: s } of t) + s(i); + } + }; +} +function dO(t) { + const e = typeof t == "string" ? lo(t) : t, r = A4(e.length); + return { + length: e.length === 1 && e[0] < 128 ? 1 : e.length <= 55 ? 1 + e.length : 1 + r + e.length, + encode(i) { + e.length === 1 && e[0] < 128 ? i.pushBytes(e) : e.length <= 55 ? (i.pushByte(128 + e.length), i.pushBytes(e)) : (i.pushByte(183 + r), r === 1 ? i.pushUint8(e.length) : r === 2 ? i.pushUint16(e.length) : r === 3 ? i.pushUint24(e.length) : i.pushUint32(e.length), i.pushBytes(e)); + } + }; +} +function A4(t) { + if (t < 2 ** 8) + return 1; + if (t < 2 ** 16) + return 2; + if (t < 2 ** 24) + return 3; + if (t < 2 ** 32) + return 4; + throw new pt("Length is too large."); +} +function pO(t) { + const { chainId: e, nonce: r, to: n } = t, i = t.contractAddress ?? t.address, s = Ud(zd([ + "0x05", + lO([ + e ? br(e) : "0x", + i, + r ? br(r) : "0x" + ]) + ])); + return n === "bytes" ? lo(s) : s; +} +async function P4(t) { + const { authorization: e, signature: r } = t; + return fO({ + hash: pO(e), + signature: r ?? e + }); +} +class gO extends pt { + constructor(e, { account: r, docsPath: n, chain: i, data: s, gas: o, gasPrice: a, maxFeePerGas: f, maxPriorityFeePerGas: u, nonce: h, to: g, value: v }) { + const x = Hd({ + from: r?.address, + to: g, + value: typeof v < "u" && `${w4(v)} ${i?.nativeCurrency?.symbol || "ETH"}`, + data: s, + gas: o, + gasPrice: typeof a < "u" && `${us(a)} gwei`, + maxFeePerGas: typeof f < "u" && `${us(f)} gwei`, + maxPriorityFeePerGas: typeof u < "u" && `${us(u)} gwei`, + nonce: h + }); + super(e.shortMessage, { + cause: e, + docsPath: n, + metaMessages: [ + ...e.metaMessages ? [...e.metaMessages, " "] : [], + "Estimate Gas Arguments:", + x + ].filter(Boolean), + name: "EstimateGasExecutionError" + }), Object.defineProperty(this, "cause", { + enumerable: !0, + configurable: !0, + writable: !0, + value: void 0 + }), this.cause = e; + } +} +class xc extends pt { + constructor({ cause: e, message: r } = {}) { + const n = r?.replace("execution reverted: ", "")?.replace("execution reverted", ""); + super(`Execution reverted ${n ? `with reason: ${n}` : "for an unknown reason"}.`, { + cause: e, + name: "ExecutionRevertedError" + }); + } +} +Object.defineProperty(xc, "code", { + enumerable: !0, + configurable: !0, + writable: !0, + value: 3 +}); +Object.defineProperty(xc, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /execution reverted/ +}); +class fd extends pt { + constructor({ cause: e, maxFeePerGas: r } = {}) { + super(`The fee cap (\`maxFeePerGas\`${r ? ` = ${us(r)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, { + cause: e, + name: "FeeCapTooHighError" + }); + } +} +Object.defineProperty(fd, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/ +}); +class jm extends pt { + constructor({ cause: e, maxFeePerGas: r } = {}) { + super(`The fee cap (\`maxFeePerGas\`${r ? ` = ${us(r)}` : ""} gwei) cannot be lower than the block base fee.`, { + cause: e, + name: "FeeCapTooLowError" + }); + } +} +Object.defineProperty(jm, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/ +}); +class Um extends pt { + constructor({ cause: e, nonce: r } = {}) { + super(`Nonce provided for the transaction ${r ? `(${r}) ` : ""}is higher than the next one expected.`, { cause: e, name: "NonceTooHighError" }); + } +} +Object.defineProperty(Um, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /nonce too high/ +}); +class qm extends pt { + constructor({ cause: e, nonce: r } = {}) { + super([ + `Nonce provided for the transaction ${r ? `(${r}) ` : ""}is lower than the current nonce of the account.`, + "Try increasing the nonce or find the latest nonce with `getTransactionCount`." + ].join(` +`), { cause: e, name: "NonceTooLowError" }); + } +} +Object.defineProperty(qm, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /nonce too low|transaction already imported|already known/ +}); +class zm extends pt { + constructor({ cause: e, nonce: r } = {}) { + super(`Nonce provided for the transaction ${r ? `(${r}) ` : ""}exceeds the maximum allowed nonce.`, { cause: e, name: "NonceMaxValueError" }); + } +} +Object.defineProperty(zm, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /nonce has max value/ +}); +class Hm extends pt { + constructor({ cause: e } = {}) { + super([ + "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account." + ].join(` +`), { + cause: e, + metaMessages: [ + "This error could arise when the account does not have enough funds to:", + " - pay for the total gas fee,", + " - pay for the value to send.", + " ", + "The cost of the transaction is calculated as `gas * gas fee + value`, where:", + " - `gas` is the amount of gas needed for transaction to execute,", + " - `gas fee` is the gas fee,", + " - `value` is the amount of ether to send to the recipient." + ], + name: "InsufficientFundsError" + }); + } +} +Object.defineProperty(Hm, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /insufficient funds|exceeds transaction sender account balance/ +}); +class Wm extends pt { + constructor({ cause: e, gas: r } = {}) { + super(`The amount of gas ${r ? `(${r}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, { + cause: e, + name: "IntrinsicGasTooHighError" + }); + } +} +Object.defineProperty(Wm, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /intrinsic gas too high|gas limit reached/ +}); +class Km extends pt { + constructor({ cause: e, gas: r } = {}) { + super(`The amount of gas ${r ? `(${r}) ` : ""}provided for the transaction is too low.`, { + cause: e, + name: "IntrinsicGasTooLowError" + }); + } +} +Object.defineProperty(Km, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /intrinsic gas too low/ +}); +class Vm extends pt { + constructor({ cause: e }) { + super("The transaction type is not supported for this chain.", { + cause: e, + name: "TransactionTypeNotSupportedError" + }); + } +} +Object.defineProperty(Vm, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /transaction type not valid/ +}); +class ld extends pt { + constructor({ cause: e, maxPriorityFeePerGas: r, maxFeePerGas: n } = {}) { + super([ + `The provided tip (\`maxPriorityFeePerGas\`${r ? ` = ${us(r)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n ? ` = ${us(n)} gwei` : ""}).` + ].join(` +`), { + cause: e, + name: "TipAboveFeeCapError" + }); + } +} +Object.defineProperty(ld, "nodeMessage", { + enumerable: !0, + configurable: !0, + writable: !0, + value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/ +}); +class o1 extends pt { + constructor({ cause: e }) { + super(`An error occurred while executing: ${e?.shortMessage}`, { + cause: e, + name: "UnknownNodeError" + }); + } +} +function M4(t, e) { + const r = (t.details || "").toLowerCase(), n = t instanceof pt ? t.walk((i) => i?.code === xc.code) : t; + return n instanceof pt ? new xc({ + cause: t, + message: n.details + }) : xc.nodeMessage.test(r) ? new xc({ + cause: t, + message: t.details + }) : fd.nodeMessage.test(r) ? new fd({ + cause: t, + maxFeePerGas: e?.maxFeePerGas + }) : jm.nodeMessage.test(r) ? new jm({ + cause: t, + maxFeePerGas: e?.maxFeePerGas + }) : Um.nodeMessage.test(r) ? new Um({ cause: t, nonce: e?.nonce }) : qm.nodeMessage.test(r) ? new qm({ cause: t, nonce: e?.nonce }) : zm.nodeMessage.test(r) ? new zm({ cause: t, nonce: e?.nonce }) : Hm.nodeMessage.test(r) ? new Hm({ cause: t }) : Wm.nodeMessage.test(r) ? new Wm({ cause: t, gas: e?.gas }) : Km.nodeMessage.test(r) ? new Km({ cause: t, gas: e?.gas }) : Vm.nodeMessage.test(r) ? new Vm({ cause: t }) : ld.nodeMessage.test(r) ? new ld({ + cause: t, + maxFeePerGas: e?.maxFeePerGas, + maxPriorityFeePerGas: e?.maxPriorityFeePerGas + }) : new o1({ + cause: t + }); +} +function mO(t, { docsPath: e, ...r }) { + const n = (() => { + const i = M4(t, r); + return i instanceof o1 ? t : i; + })(); + return new gO(n, { + docsPath: e, + ...r + }); +} +function I4(t, { format: e }) { + if (!e) + return {}; + const r = {}; + function n(s) { + const o = Object.keys(s); + for (const a of o) + a in t && (r[a] = t[a]), s[a] && typeof s[a] == "object" && !Array.isArray(s[a]) && n(s[a]); + } + const i = e(t || {}); + return n(i), r; +} +const vO = { + legacy: "0x0", + eip2930: "0x1", + eip1559: "0x2", + eip4844: "0x3", + eip7702: "0x4" +}; +function a1(t) { + const e = {}; + return typeof t.authorizationList < "u" && (e.authorizationList = bO(t.authorizationList)), typeof t.accessList < "u" && (e.accessList = t.accessList), typeof t.blobVersionedHashes < "u" && (e.blobVersionedHashes = t.blobVersionedHashes), typeof t.blobs < "u" && (typeof t.blobs[0] != "string" ? e.blobs = t.blobs.map((r) => di(r)) : e.blobs = t.blobs), typeof t.data < "u" && (e.data = t.data), typeof t.from < "u" && (e.from = t.from), typeof t.gas < "u" && (e.gas = br(t.gas)), typeof t.gasPrice < "u" && (e.gasPrice = br(t.gasPrice)), typeof t.maxFeePerBlobGas < "u" && (e.maxFeePerBlobGas = br(t.maxFeePerBlobGas)), typeof t.maxFeePerGas < "u" && (e.maxFeePerGas = br(t.maxFeePerGas)), typeof t.maxPriorityFeePerGas < "u" && (e.maxPriorityFeePerGas = br(t.maxPriorityFeePerGas)), typeof t.nonce < "u" && (e.nonce = br(t.nonce)), typeof t.to < "u" && (e.to = t.to), typeof t.type < "u" && (e.type = vO[t.type]), typeof t.value < "u" && (e.value = br(t.value)), e; +} +function bO(t) { + return t.map((e) => ({ + address: e.address, + r: e.r ? br(BigInt(e.r)) : e.r, + s: e.s ? br(BigInt(e.s)) : e.s, + chainId: br(e.chainId), + nonce: br(e.nonce), + ...typeof e.yParity < "u" ? { yParity: br(e.yParity) } : {}, + ...typeof e.v < "u" && typeof e.yParity > "u" ? { v: br(e.v) } : {} + })); +} +function Gw(t) { + if (!(!t || t.length === 0)) + return t.reduce((e, { slot: r, value: n }) => { + if (r.length !== 66) + throw new $w({ + size: r.length, + targetSize: 66, + type: "hex" + }); + if (n.length !== 66) + throw new $w({ + size: n.length, + targetSize: 66, + type: "hex" + }); + return e[r] = n, e; + }, {}); +} +function yO(t) { + const { balance: e, nonce: r, state: n, stateDiff: i, code: s } = t, o = {}; + if (s !== void 0 && (o.code = s), e !== void 0 && (o.balance = br(e)), r !== void 0 && (o.nonce = br(r)), n !== void 0 && (o.state = Gw(n)), i !== void 0) { + if (o.state) + throw new YD(); + o.stateDiff = Gw(i); + } + return o; +} +function wO(t) { + if (!t) + return; + const e = {}; + for (const { address: r, ...n } of t) { + if (!fs(r, { strict: !1 })) + throw new Ho({ address: r }); + if (e[r]) + throw new GD({ address: r }); + e[r] = yO(n); + } + return e; +} +const xO = 2n ** 256n - 1n; +function Wd(t) { + const { account: e, gasPrice: r, maxFeePerGas: n, maxPriorityFeePerGas: i, to: s } = t, o = e ? pi(e) : void 0; + if (o && !fs(o.address)) + throw new Ho({ address: o.address }); + if (s && !fs(s)) + throw new Ho({ address: s }); + if (typeof r < "u" && (typeof n < "u" || typeof i < "u")) + throw new JD(); + if (n && n > xO) + throw new fd({ maxFeePerGas: n }); + if (i && n && i > n) + throw new ld({ maxFeePerGas: n, maxPriorityFeePerGas: i }); +} +class _O extends pt { + constructor() { + super("`baseFeeMultiplier` must be greater than 1.", { + name: "BaseFeeScalarError" + }); + } +} +class c1 extends pt { + constructor() { + super("Chain does not support EIP-1559 fees.", { + name: "Eip1559FeesNotSupportedError" + }); + } +} +class EO extends pt { + constructor({ maxPriorityFeePerGas: e }) { + super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${us(e)} gwei).`, { name: "MaxFeePerGasTooLowError" }); + } +} +class SO extends pt { + constructor({ blockHash: e, blockNumber: r }) { + let n = "Block"; + e && (n = `Block at hash "${e}"`), r && (n = `Block at number "${r}"`), super(`${n} could not be found.`, { name: "BlockNotFoundError" }); + } +} +const AO = { + "0x0": "legacy", + "0x1": "eip2930", + "0x2": "eip1559", + "0x3": "eip4844", + "0x4": "eip7702" +}; +function PO(t) { + const e = { + ...t, + blockHash: t.blockHash ? t.blockHash : null, + blockNumber: t.blockNumber ? BigInt(t.blockNumber) : null, + chainId: t.chainId ? zo(t.chainId) : void 0, + gas: t.gas ? BigInt(t.gas) : void 0, + gasPrice: t.gasPrice ? BigInt(t.gasPrice) : void 0, + maxFeePerBlobGas: t.maxFeePerBlobGas ? BigInt(t.maxFeePerBlobGas) : void 0, + maxFeePerGas: t.maxFeePerGas ? BigInt(t.maxFeePerGas) : void 0, + maxPriorityFeePerGas: t.maxPriorityFeePerGas ? BigInt(t.maxPriorityFeePerGas) : void 0, + nonce: t.nonce ? zo(t.nonce) : void 0, + to: t.to ? t.to : null, + transactionIndex: t.transactionIndex ? Number(t.transactionIndex) : null, + type: t.type ? AO[t.type] : void 0, + typeHex: t.type ? t.type : void 0, + value: t.value ? BigInt(t.value) : void 0, + v: t.v ? BigInt(t.v) : void 0 + }; + return t.authorizationList && (e.authorizationList = MO(t.authorizationList)), e.yParity = (() => { + if (t.yParity) + return Number(t.yParity); + if (typeof e.v == "bigint") { + if (e.v === 0n || e.v === 27n) + return 0; + if (e.v === 1n || e.v === 28n) + return 1; + if (e.v >= 35n) + return e.v % 2n === 0n ? 1 : 0; + } + })(), e.type === "legacy" && (delete e.accessList, delete e.maxFeePerBlobGas, delete e.maxFeePerGas, delete e.maxPriorityFeePerGas, delete e.yParity), e.type === "eip2930" && (delete e.maxFeePerBlobGas, delete e.maxFeePerGas, delete e.maxPriorityFeePerGas), e.type === "eip1559" && delete e.maxFeePerBlobGas, e; +} +function MO(t) { + return t.map((e) => ({ + address: e.address, + chainId: Number(e.chainId), + nonce: Number(e.nonce), + r: e.r, + s: e.s, + yParity: Number(e.yParity) + })); +} +function IO(t) { + const e = (t.transactions ?? []).map((r) => typeof r == "string" ? r : PO(r)); + return { + ...t, + baseFeePerGas: t.baseFeePerGas ? BigInt(t.baseFeePerGas) : null, + blobGasUsed: t.blobGasUsed ? BigInt(t.blobGasUsed) : void 0, + difficulty: t.difficulty ? BigInt(t.difficulty) : void 0, + excessBlobGas: t.excessBlobGas ? BigInt(t.excessBlobGas) : void 0, + gasLimit: t.gasLimit ? BigInt(t.gasLimit) : void 0, + gasUsed: t.gasUsed ? BigInt(t.gasUsed) : void 0, + hash: t.hash ? t.hash : null, + logsBloom: t.logsBloom ? t.logsBloom : null, + nonce: t.nonce ? t.nonce : null, + number: t.number ? BigInt(t.number) : null, + size: t.size ? BigInt(t.size) : void 0, + timestamp: t.timestamp ? BigInt(t.timestamp) : void 0, + transactions: e, + totalDifficulty: t.totalDifficulty ? BigInt(t.totalDifficulty) : null + }; +} +async function hd(t, { blockHash: e, blockNumber: r, blockTag: n, includeTransactions: i } = {}) { + const s = n ?? "latest", o = i ?? !1, a = r !== void 0 ? br(r) : void 0; + let f = null; + if (e ? f = await t.request({ + method: "eth_getBlockByHash", + params: [e, o] + }, { dedupe: !0 }) : f = await t.request({ + method: "eth_getBlockByNumber", + params: [a || s, o] + }, { dedupe: !!a }), !f) + throw new SO({ blockHash: e, blockNumber: r }); + return (t.chain?.formatters?.block?.format || IO)(f); +} +async function C4(t) { + const e = await t.request({ + method: "eth_gasPrice" + }); + return BigInt(e); +} +async function CO(t, e) { + const { block: r, chain: n = t.chain, request: i } = e || {}; + try { + const s = n?.fees?.maxPriorityFeePerGas ?? n?.fees?.defaultPriorityFee; + if (typeof s == "function") { + const a = r || await Hn(t, hd, "getBlock")({}), f = await s({ + block: a, + client: t, + request: i + }); + if (f === null) + throw new Error(); + return f; + } + if (typeof s < "u") + return s; + const o = await t.request({ + method: "eth_maxPriorityFeePerGas" + }); + return qo(o); + } catch { + const [s, o] = await Promise.all([ + r ? Promise.resolve(r) : Hn(t, hd, "getBlock")({}), + Hn(t, C4, "getGasPrice")({}) + ]); + if (typeof s.baseFeePerGas != "bigint") + throw new c1(); + const a = o - s.baseFeePerGas; + return a < 0n ? 0n : a; + } +} +async function Yw(t, e) { + const { block: r, chain: n = t.chain, request: i, type: s = "eip1559" } = e || {}, o = await (async () => typeof n?.fees?.baseFeeMultiplier == "function" ? n.fees.baseFeeMultiplier({ + block: r, + client: t, + request: i + }) : n?.fees?.baseFeeMultiplier ?? 1.2)(); + if (o < 1) + throw new _O(); + const f = 10 ** (o.toString().split(".")[1]?.length ?? 0), u = (v) => v * BigInt(Math.ceil(o * f)) / BigInt(f), h = r || await Hn(t, hd, "getBlock")({}); + if (typeof n?.fees?.estimateFeesPerGas == "function") { + const v = await n.fees.estimateFeesPerGas({ + block: r, + client: t, + multiply: u, + request: i, + type: s + }); + if (v !== null) + return v; + } + if (s === "eip1559") { + if (typeof h.baseFeePerGas != "bigint") + throw new c1(); + const v = typeof i?.maxPriorityFeePerGas == "bigint" ? i.maxPriorityFeePerGas : await CO(t, { + block: h, + chain: n, + request: i + }), x = u(h.baseFeePerGas); + return { + maxFeePerGas: i?.maxFeePerGas ?? x + v, + maxPriorityFeePerGas: v + }; + } + return { + gasPrice: i?.gasPrice ?? u(await Hn(t, C4, "getGasPrice")({})) + }; +} +async function R4(t, { address: e, blockTag: r = "latest", blockNumber: n }) { + const i = await t.request({ + method: "eth_getTransactionCount", + params: [ + e, + typeof n == "bigint" ? br(n) : r + ] + }, { + dedupe: !!n + }); + return zo(i); +} +function T4(t) { + const { kzg: e } = t, r = t.to ?? (typeof t.blobs[0] == "string" ? "hex" : "bytes"), n = typeof t.blobs[0] == "string" ? t.blobs.map((s) => lo(s)) : t.blobs, i = []; + for (const s of n) + i.push(Uint8Array.from(e.blobToKzgCommitment(s))); + return r === "bytes" ? i : i.map((s) => di(s)); +} +function D4(t) { + const { kzg: e } = t, r = t.to ?? (typeof t.blobs[0] == "string" ? "hex" : "bytes"), n = typeof t.blobs[0] == "string" ? t.blobs.map((o) => lo(o)) : t.blobs, i = typeof t.commitments[0] == "string" ? t.commitments.map((o) => lo(o)) : t.commitments, s = []; + for (let o = 0; o < n.length; o++) { + const a = n[o], f = i[o]; + s.push(Uint8Array.from(e.computeBlobKzgProof(a, f))); + } + return r === "bytes" ? s : s.map((o) => di(o)); +} +function RO(t, e, r, n) { + if (typeof t.setBigUint64 == "function") + return t.setBigUint64(e, r, n); + const i = BigInt(32), s = BigInt(4294967295), o = Number(r >> i & s), a = Number(r & s), f = n ? 4 : 0, u = n ? 0 : 4; + t.setUint32(e + f, o, n), t.setUint32(e + u, a, n); +} +function TO(t, e, r) { + return t & e ^ ~t & r; +} +function DO(t, e, r) { + return t & e ^ t & r ^ e & r; +} +class OO extends n4 { + constructor(e, r, n, i) { + super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = e, this.outputLen = r, this.padOffset = n, this.isLE = i, this.buffer = new Uint8Array(e), this.view = Bp(this.buffer); + } + update(e) { + cd(this), e = Zv(e), Da(e); + const { view: r, buffer: n, blockLen: i } = this, s = e.length; + for (let o = 0; o < s; ) { + const a = Math.min(i - this.pos, s - o); + if (a === i) { + const f = Bp(e); + for (; i <= s - o; o += i) + this.process(f, o); + continue; + } + n.set(e.subarray(o, o + a), this.pos), this.pos += a, o += a, this.pos === i && (this.process(r, 0), this.pos = 0); + } + return this.length += e.length, this.roundClean(), this; + } + digestInto(e) { + cd(this), t4(e, this), this.finished = !0; + const { buffer: r, view: n, blockLen: i, isLE: s } = this; + let { pos: o } = this; + r[o++] = 128, hf(this.buffer.subarray(o)), this.padOffset > i - o && (this.process(n, 0), o = 0); + for (let g = o; g < i; g++) + r[g] = 0; + RO(n, i - 8, BigInt(this.length * 8), s), this.process(n, 0); + const a = Bp(e), f = this.outputLen; + if (f % 4) + throw new Error("_sha2: outputLen should be aligned to 32bit"); + const u = f / 4, h = this.get(); + if (u > h.length) + throw new Error("_sha2: outputLen bigger than state"); + for (let g = 0; g < u; g++) + a.setUint32(4 * g, h[g], s); + } + digest() { + const { buffer: e, outputLen: r } = this; + this.digestInto(e); + const n = e.slice(0, r); + return this.destroy(), n; + } + _cloneInto(e) { + e || (e = new this.constructor()), e.set(...this.get()); + const { blockLen: r, buffer: n, length: i, finished: s, destroyed: o, pos: a } = this; + return e.destroyed = o, e.finished = s, e.length = i, e.pos = a, i % r && e.buffer.set(n), e; + } + clone() { + return this._cloneInto(); + } +} +const Ao = /* @__PURE__ */ Uint32Array.from([ + 1779033703, + 3144134277, + 1013904242, + 2773480762, + 1359893119, + 2600822924, + 528734635, + 1541459225 +]), NO = /* @__PURE__ */ Uint32Array.from([ + 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 +]), Po = /* @__PURE__ */ new Uint32Array(64); +class LO extends OO { + constructor(e = 32) { + super(64, e, 8, !1), this.A = Ao[0] | 0, this.B = Ao[1] | 0, this.C = Ao[2] | 0, this.D = Ao[3] | 0, this.E = Ao[4] | 0, this.F = Ao[5] | 0, this.G = Ao[6] | 0, this.H = Ao[7] | 0; + } + get() { + const { A: e, B: r, C: n, D: i, E: s, F: o, G: a, H: f } = this; + return [e, r, n, i, s, o, a, f]; + } + // prettier-ignore + set(e, r, n, i, s, o, a, f) { + this.A = e | 0, this.B = r | 0, this.C = n | 0, this.D = i | 0, this.E = s | 0, this.F = o | 0, this.G = a | 0, this.H = f | 0; + } + process(e, r) { + for (let g = 0; g < 16; g++, r += 4) + Po[g] = e.getUint32(r, !1); + for (let g = 16; g < 64; g++) { + const v = Po[g - 15], x = Po[g - 2], S = ws(v, 7) ^ ws(v, 18) ^ v >>> 3, R = ws(x, 17) ^ ws(x, 19) ^ x >>> 10; + Po[g] = R + Po[g - 7] + S + Po[g - 16] | 0; + } + let { A: n, B: i, C: s, D: o, E: a, F: f, G: u, H: h } = this; + for (let g = 0; g < 64; g++) { + const v = ws(a, 6) ^ ws(a, 11) ^ ws(a, 25), x = h + v + TO(a, f, u) + NO[g] + Po[g] | 0, R = (ws(n, 2) ^ ws(n, 13) ^ ws(n, 22)) + DO(n, i, s) | 0; + h = u, u = f, f = a, a = o + x | 0, o = s, s = i, i = n, n = x + R | 0; + } + n = n + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, a = a + this.E | 0, f = f + this.F | 0, u = u + this.G | 0, h = h + this.H | 0, this.set(n, i, s, o, a, f, u, h); + } + roundClean() { + hf(Po); + } + destroy() { + this.set(0, 0, 0, 0, 0, 0, 0, 0), hf(this.buffer); + } +} +const kO = /* @__PURE__ */ i4(() => new LO()), O4 = kO; +function $O(t, e) { + return O4(Uo(t, { strict: !1 }) ? Xv(t) : t); +} +function BO(t) { + const { commitment: e, version: r = 1 } = t, n = t.to ?? (typeof e == "string" ? "hex" : "bytes"), i = $O(e); + return i.set([r], 0), n === "bytes" ? i : di(i); +} +function FO(t) { + const { commitments: e, version: r } = t, n = t.to, i = []; + for (const s of e) + i.push(BO({ + commitment: s, + to: n, + version: r + })); + return i; +} +const Jw = 6, N4 = 32, u1 = 4096, L4 = N4 * u1, Xw = L4 * Jw - // terminator byte (0x80). +1 - // zero byte (0x00) appended to each field element. +1 * u1 * Jw; +class jO extends pt { + constructor({ maxSize: e, size: r }) { + super("Blob size is too large.", { + metaMessages: [`Max: ${e} bytes`, `Given: ${r} bytes`], + name: "BlobSizeTooLargeError" + }); + } +} +class UO extends pt { + constructor() { + super("Blob data must not be empty.", { name: "EmptyBlobError" }); + } +} +function qO(t) { + const e = typeof t.data == "string" ? lo(t.data) : t.data, r = yn(e); + if (!r) + throw new UO(); + if (r > Xw) + throw new jO({ + maxSize: Xw, + size: r + }); + const n = []; + let i = !0, s = 0; + for (; i; ) { + const o = s1(new Uint8Array(L4)); + let a = 0; + for (; a < u1; ) { + const f = e.slice(s, s + (N4 - 1)); + if (o.pushByte(0), o.pushBytes(f), f.length < 31) { + o.pushByte(128), i = !1; + break; + } + a++, s += 31; + } + n.push(o); + } + return n.map((o) => di(o.bytes)); +} +function zO(t) { + const { data: e, kzg: r, to: n } = t, i = t.blobs ?? qO({ data: e }), s = t.commitments ?? T4({ blobs: i, kzg: r, to: n }), o = t.proofs ?? D4({ blobs: i, commitments: s, kzg: r, to: n }), a = []; + for (let f = 0; f < i.length; f++) + a.push({ + blob: i[f], + commitment: s[f], + proof: o[f] + }); + return a; +} +function HO(t) { + if (t.type) + return t.type; + if (typeof t.authorizationList < "u") + return "eip7702"; + if (typeof t.blobs < "u" || typeof t.blobVersionedHashes < "u" || typeof t.maxFeePerBlobGas < "u" || typeof t.sidecars < "u") + return "eip4844"; + if (typeof t.maxFeePerGas < "u" || typeof t.maxPriorityFeePerGas < "u") + return "eip1559"; + if (typeof t.gasPrice < "u") + return typeof t.accessList < "u" ? "eip2930" : "legacy"; + throw new XD({ transaction: t }); +} +async function Gf(t) { + const e = await t.request({ + method: "eth_chainId" + }, { dedupe: !0 }); + return zo(e); +} +const k4 = [ + "blobVersionedHashes", + "chainId", + "fees", + "gas", + "nonce", + "type" +], Zw = /* @__PURE__ */ new Map(); +async function f1(t, e) { + const { account: r = t.account, blobs: n, chain: i, gas: s, kzg: o, nonce: a, nonceManager: f, parameters: u = k4, type: h } = e, g = r && pi(r), v = { ...e, ...g ? { from: g?.address } : {} }; + let x; + async function S() { + return x || (x = await Hn(t, hd, "getBlock")({ blockTag: "latest" }), x); + } + let R; + async function D() { + return R || (i ? i.id : typeof e.chainId < "u" ? e.chainId : (R = await Hn(t, Gf, "getChainId")({}), R)); + } + if (u.includes("nonce") && typeof a > "u" && g) + if (f) { + const k = await D(); + v.nonce = await f.consume({ + address: g.address, + chainId: k, + client: t + }); + } else + v.nonce = await Hn(t, R4, "getTransactionCount")({ + address: g.address, + blockTag: "pending" + }); + if ((u.includes("blobVersionedHashes") || u.includes("sidecars")) && n && o) { + const k = T4({ blobs: n, kzg: o }); + if (u.includes("blobVersionedHashes")) { + const N = FO({ + commitments: k, + to: "hex" + }); + v.blobVersionedHashes = N; + } + if (u.includes("sidecars")) { + const N = D4({ blobs: n, commitments: k, kzg: o }), z = zO({ + blobs: n, + commitments: k, + proofs: N, + to: "hex" + }); + v.sidecars = z; + } + } + if (u.includes("chainId") && (v.chainId = await D()), (u.includes("fees") || u.includes("type")) && typeof h > "u") + try { + v.type = HO(v); + } catch { + let k = Zw.get(t.uid); + typeof k > "u" && (k = typeof (await S())?.baseFeePerGas == "bigint", Zw.set(t.uid, k)), v.type = k ? "eip1559" : "legacy"; + } + if (u.includes("fees")) + if (v.type !== "legacy" && v.type !== "eip2930") { + if (typeof v.maxFeePerGas > "u" || typeof v.maxPriorityFeePerGas > "u") { + const k = await S(), { maxFeePerGas: N, maxPriorityFeePerGas: z } = await Yw(t, { + block: k, + chain: i, + request: v + }); + if (typeof e.maxPriorityFeePerGas > "u" && e.maxFeePerGas && e.maxFeePerGas < z) + throw new EO({ + maxPriorityFeePerGas: z + }); + v.maxPriorityFeePerGas = z, v.maxFeePerGas = N; + } + } else { + if (typeof e.maxFeePerGas < "u" || typeof e.maxPriorityFeePerGas < "u") + throw new c1(); + if (typeof e.gasPrice > "u") { + const k = await S(), { gasPrice: N } = await Yw(t, { + block: k, + chain: i, + request: v, + type: "legacy" + }); + v.gasPrice = N; + } + } + return u.includes("gas") && typeof s > "u" && (v.gas = await Hn(t, KO, "estimateGas")({ + ...v, + account: g && { address: g.address, type: "json-rpc" } + })), Wd(v), delete v.parameters, v; +} +async function WO(t, { address: e, blockNumber: r, blockTag: n = "latest" }) { + const i = typeof r == "bigint" ? br(r) : void 0, s = await t.request({ + method: "eth_getBalance", + params: [e, i || n] + }); + return BigInt(s); +} +async function KO(t, e) { + const { account: r = t.account } = e, n = r ? pi(r) : void 0; + try { + let K = function(b) { + const { block: l, request: p, rpcStateOverride: m } = b; + return t.request({ + method: "eth_estimateGas", + params: m ? [p, l ?? "latest", m] : l ? [p, l] : [p] + }); + }; + const { accessList: i, authorizationList: s, blobs: o, blobVersionedHashes: a, blockNumber: f, blockTag: u, data: h, gas: g, gasPrice: v, maxFeePerBlobGas: x, maxFeePerGas: S, maxPriorityFeePerGas: R, nonce: D, value: k, stateOverride: N, ...z } = await f1(t, { + ...e, + parameters: ( + // Some RPC Providers do not compute versioned hashes from blobs. We will need + // to compute them. + n?.type === "local" ? void 0 : ["blobVersionedHashes"] + ) + }), $ = (typeof f == "bigint" ? br(f) : void 0) || u, U = wO(N), C = await (async () => { + if (z.to) + return z.to; + if (s && s.length > 0) + return await P4({ + authorization: s[0] + }).catch(() => { + throw new pt("`to` is required. Could not infer from `authorizationList`"); + }); + })(); + Wd(e); + const W = t.chain?.formatters?.transactionRequest?.format, ne = (W || a1)({ + // Pick out extra data that might exist on the chain's transaction request type. + ...I4(z, { format: W }), + from: n?.address, + accessList: i, + authorizationList: s, + blobs: o, + blobVersionedHashes: a, + data: h, + gas: g, + gasPrice: v, + maxFeePerBlobGas: x, + maxFeePerGas: S, + maxPriorityFeePerGas: R, + nonce: D, + to: C, + value: k + }); + let E = BigInt(await K({ block: $, request: ne, rpcStateOverride: U })); + if (s) { + const b = await WO(t, { address: ne.from }), l = await Promise.all(s.map(async (p) => { + const { address: m } = p, w = await K({ + block: $, + request: { + authorizationList: void 0, + data: h, + from: n?.address, + to: m, + value: br(b) + }, + rpcStateOverride: U + }).catch(() => 100000n); + return 2n * BigInt(w); + })); + E += l.reduce((p, m) => p + m, 0n); + } + return E; + } catch (i) { + throw mO(i, { + ...e, + account: n, + chain: t.chain + }); + } +} +function VO(t, e) { + if (!fs(t, { strict: !1 })) + throw new Ho({ address: t }); + if (!fs(e, { strict: !1 })) + throw new Ho({ address: e }); + return t.toLowerCase() === e.toLowerCase(); +} +class GO extends pt { + constructor({ chain: e, currentChainId: r }) { + super(`The current chain of the wallet (id: ${r}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`, { + metaMessages: [ + `Current Chain ID: ${r}`, + `Expected Chain ID: ${e.id} – ${e.name}` + ], + name: "ChainMismatchError" + }); + } +} +class YO extends pt { + constructor() { + super([ + "No chain was provided to the request.", + "Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient." + ].join(` +`), { + name: "ChainNotFoundError" + }); + } +} +const Up = "/docs/contract/encodeDeployData"; +function JO(t) { + const { abi: e, args: r, bytecode: n } = t; + if (!r || r.length === 0) + return n; + const i = e.find((o) => "type" in o && o.type === "constructor"); + if (!i) + throw new _T({ docsPath: Up }); + if (!("inputs" in i)) + throw new Lw({ docsPath: Up }); + if (!i.inputs || i.inputs.length === 0) + throw new Lw({ docsPath: Up }); + const s = p4(i.inputs, r); + return zd([n, s]); +} +function XO() { + let t = () => { + }, e = () => { + }; + return { promise: new Promise((n, i) => { + t = n, e = i; + }), resolve: t, reject: e }; +} +const qp = /* @__PURE__ */ new Map(), Qw = /* @__PURE__ */ new Map(); +let ZO = 0; +function QO(t, e, r) { + const n = ++ZO, i = () => qp.get(t) || [], s = () => { + const h = i(); + qp.set(t, h.filter((g) => g.id !== n)); + }, o = () => { + const h = i(); + if (!h.some((v) => v.id === n)) + return; + const g = Qw.get(t); + if (h.length === 1 && g) { + const v = g(); + v instanceof Promise && v.catch(() => { + }); + } + s(); + }, a = i(); + if (qp.set(t, [ + ...a, + { id: n, fns: e } + ]), a && a.length > 0) + return o; + const f = {}; + for (const h in e) + f[h] = ((...g) => { + const v = i(); + if (v.length !== 0) + for (const x of v) + x.fns[h]?.(...g); + }); + const u = r(f); + return typeof u == "function" && Qw.set(t, u), o; +} +async function Gm(t) { + return new Promise((e) => setTimeout(e, t)); +} +function eN(t, { emitOnBegin: e, initialWaitTime: r, interval: n }) { + let i = !0; + const s = () => i = !1; + return (async () => { + let a; + a = await t({ unpoll: s }); + const f = await r?.(a) ?? n; + await Gm(f); + const u = async () => { + i && (await t({ unpoll: s }), await Gm(n), u()); + }; + u(); + })(), s; +} +class qa extends pt { + constructor({ docsPath: e } = {}) { + super([ + "Could not find an Account to execute with this Action.", + "Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client." + ].join(` +`), { + docsPath: e, + docsSlug: "account", + name: "AccountNotFoundError" + }); + } +} +class Nh extends pt { + constructor({ docsPath: e, metaMessages: r, type: n }) { + super(`Account type "${n}" is not supported.`, { + docsPath: e, + metaMessages: r, + name: "AccountTypeNotSupportedError" + }); + } +} +function $4({ chain: t, currentChainId: e }) { + if (!t) + throw new YO(); + if (e !== t.id) + throw new GO({ chain: t, currentChainId: e }); +} +function B4(t, { docsPath: e, ...r }) { + const n = (() => { + const i = M4(t, r); + return i instanceof o1 ? t : i; + })(); + return new ZD(n, { + docsPath: e, + ...r + }); +} +async function F4(t, { serializedTransaction: e }) { + return t.request({ + method: "eth_sendRawTransaction", + params: [e] + }, { retryCount: 0 }); +} +const zp = new qd(128); +async function Kd(t, e) { + const { account: r = t.account, chain: n = t.chain, accessList: i, authorizationList: s, blobs: o, data: a, gas: f, gasPrice: u, maxFeePerBlobGas: h, maxFeePerGas: g, maxPriorityFeePerGas: v, nonce: x, type: S, value: R, ...D } = e; + if (typeof r > "u") + throw new qa({ + docsPath: "/docs/actions/wallet/sendTransaction" + }); + const k = r ? pi(r) : null; + try { + Wd(e); + const N = await (async () => { + if (e.to) + return e.to; + if (e.to !== null && s && s.length > 0) + return await P4({ + authorization: s[0] + }).catch(() => { + throw new pt("`to` is required. Could not infer from `authorizationList`."); + }); + })(); + if (k?.type === "json-rpc" || k === null) { + let z; + n !== null && (z = await Hn(t, Gf, "getChainId")({}), $4({ + currentChainId: z, + chain: n + })); + const B = t.chain?.formatters?.transactionRequest?.format, U = (B || a1)({ + // Pick out extra data that might exist on the chain's transaction request type. + ...I4(D, { format: B }), + accessList: i, + authorizationList: s, + blobs: o, + chainId: z, + data: a, + from: k?.address, + gas: f, + gasPrice: u, + maxFeePerBlobGas: h, + maxFeePerGas: g, + maxPriorityFeePerGas: v, + nonce: x, + to: N, + type: S, + value: R + }), C = zp.get(t.uid), W = C ? "wallet_sendTransaction" : "eth_sendTransaction"; + try { + return await t.request({ + method: W, + params: [U] + }, { retryCount: 0 }); + } catch (J) { + if (C === !1) + throw J; + const ne = J; + if (ne.name === "InvalidInputRpcError" || ne.name === "InvalidParamsRpcError" || ne.name === "MethodNotFoundRpcError" || ne.name === "MethodNotSupportedRpcError") + return await t.request({ + method: "wallet_sendTransaction", + params: [U] + }, { retryCount: 0 }).then((K) => (zp.set(t.uid, !0), K)).catch((K) => { + const E = K; + throw E.name === "MethodNotFoundRpcError" || E.name === "MethodNotSupportedRpcError" ? (zp.set(t.uid, !1), ne) : E; + }); + throw ne; + } + } + if (k?.type === "local") { + const z = await Hn(t, f1, "prepareTransactionRequest")({ + account: k, + accessList: i, + authorizationList: s, + blobs: o, + chain: n, + data: a, + gas: f, + gasPrice: u, + maxFeePerBlobGas: h, + maxFeePerGas: g, + maxPriorityFeePerGas: v, + nonce: x, + nonceManager: k.nonceManager, + parameters: [...k4, "sidecars"], + type: S, + value: R, + ...D, + to: N + }), B = n?.serializers?.transaction, $ = await k.signTransaction(z, { + serializer: B + }); + return await Hn(t, F4, "sendRawTransaction")({ + serializedTransaction: $ + }); + } + throw k?.type === "smart" ? new Nh({ + metaMessages: [ + "Consider using the `sendUserOperation` Action instead." + ], + docsPath: "/docs/actions/bundler/sendUserOperation", + type: "smart" + }) : new Nh({ + docsPath: "/docs/actions/wallet/sendTransaction", + type: k?.type + }); + } catch (N) { + throw N instanceof Nh ? N : B4(N, { + ...e, + account: k, + chain: e.chain || void 0 + }); + } +} +async function tN(t, e) { + const { abi: r, account: n = t.account, address: i, args: s, dataSuffix: o, functionName: a, ...f } = e; + if (typeof n > "u") + throw new qa({ + docsPath: "/docs/contract/writeContract" + }); + const u = n ? pi(n) : null, h = v4({ + abi: r, + args: s, + functionName: a + }); + try { + return await Hn(t, Kd, "sendTransaction")({ + data: `${h}${o ? o.replace("0x", "") : ""}`, + to: i, + account: u, + ...f + }); + } catch (g) { + throw aO(g, { + abi: r, + address: i, + args: s, + docsPath: "/docs/contract/writeContract", + functionName: a, + sender: u?.address + }); + } +} +const rN = { + "0x0": "reverted", + "0x1": "success" +}, j4 = "0x5792579257925792579257925792579257925792579257925792579257925792", U4 = br(0, { + size: 32 +}); +async function nN(t, e) { + const { account: r = t.account, capabilities: n, chain: i = t.chain, experimental_fallback: s, experimental_fallbackDelay: o = 32, forceAtomic: a = !1, id: f, version: u = "2.0.0" } = e, h = r ? pi(r) : null, g = e.calls.map((v) => { + const x = v, S = x.abi ? v4({ + abi: x.abi, + functionName: x.functionName, + args: x.args + }) : x.data; + return { + data: x.dataSuffix && S ? Wo([S, x.dataSuffix]) : S, + to: x.to, + value: x.value ? br(x.value) : void 0 + }; + }); + try { + const v = await t.request({ + method: "wallet_sendCalls", + params: [ + { + atomicRequired: a, + calls: g, + capabilities: n, + chainId: br(i.id), + from: h?.address, + id: f, + version: u + } + ] + }, { retryCount: 0 }); + return typeof v == "string" ? { id: v } : v; + } catch (v) { + const x = v; + if (s && (x.name === "MethodNotFoundRpcError" || x.name === "MethodNotSupportedRpcError" || x.name === "UnknownRpcError" || x.details.toLowerCase().includes("does not exist / is not available") || x.details.toLowerCase().includes("missing or invalid. request()") || x.details.toLowerCase().includes("did not match any variant of untagged enum") || x.details.toLowerCase().includes("account upgraded to unsupported contract") || x.details.toLowerCase().includes("eip-7702 not supported") || x.details.toLowerCase().includes("unsupported wc_ method"))) { + if (n && Object.values(n).some((N) => !N.optional)) { + const N = "non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`."; + throw new jc(new pt(N, { + details: N + })); + } + if (a && g.length > 1) { + const k = "`forceAtomic` is not supported on fallback to `eth_sendTransaction`."; + throw new Uc(new pt(k, { + details: k + })); + } + const S = []; + for (const k of g) { + const N = Kd(t, { + account: h, + chain: i, + data: k.data, + to: k.to, + value: k.value ? qo(k.value) : void 0 + }); + S.push(N), o > 0 && await new Promise((z) => setTimeout(z, o)); + } + const R = await Promise.allSettled(S); + if (R.every((k) => k.status === "rejected")) + throw R[0].reason; + const D = R.map((k) => k.status === "fulfilled" ? k.value : U4); + return { + id: Wo([ + ...D, + br(i.id, { size: 32 }), + j4 + ]) + }; + } + throw B4(v, { + ...e, + account: h, + chain: e.chain + }); + } +} +async function q4(t, e) { + async function r(h) { + if (h.endsWith(j4.slice(2))) { + const v = Fd($m(h, -64, -32)), x = $m(h, 0, -64).slice(2).match(/.{1,64}/g), S = await Promise.all(x.map((D) => U4.slice(2) !== D ? t.request({ + method: "eth_getTransactionReceipt", + params: [`0x${D}`] + }, { dedupe: !0 }) : void 0)), R = S.some((D) => D === null) ? 100 : S.every((D) => D?.status === "0x1") ? 200 : S.every((D) => D?.status === "0x0") ? 500 : 600; + return { + atomic: !1, + chainId: zo(v), + receipts: S.filter(Boolean), + status: R, + version: "2.0.0" + }; + } + return t.request({ + method: "wallet_getCallsStatus", + params: [h] + }); + } + const { atomic: n = !1, chainId: i, receipts: s, version: o = "2.0.0", ...a } = await r(e.id), [f, u] = (() => { + const h = a.status; + return h >= 100 && h < 200 ? ["pending", h] : h >= 200 && h < 300 ? ["success", h] : h >= 300 && h < 700 ? ["failure", h] : h === "CONFIRMED" ? ["success", 200] : h === "PENDING" ? ["pending", 100] : [void 0, h]; + })(); + return { + ...a, + atomic: n, + // @ts-expect-error: for backwards compatibility + chainId: i ? zo(i) : void 0, + receipts: s?.map((h) => ({ + ...h, + blockNumber: qo(h.blockNumber), + gasUsed: qo(h.gasUsed), + status: rN[h.status] + })) ?? [], + statusCode: u, + status: f, + version: o + }; +} +async function iN(t, e) { + const { id: r, pollingInterval: n = t.pollingInterval, status: i = ({ statusCode: v }) => v >= 200, timeout: s = 6e4 } = e, o = Ua(["waitForCallsStatus", t.uid, r]), { promise: a, resolve: f, reject: u } = XO(); + let h; + const g = QO(o, { resolve: f, reject: u }, (v) => { + const x = eN(async () => { + const S = (R) => { + clearTimeout(h), x(), R(), g(); + }; + try { + const R = await q4(t, { id: r }); + if (!i(R)) + return; + S(() => v.resolve(R)); + } catch (R) { + S(() => v.reject(R)); + } + }, { + interval: n, + emitOnBegin: !0 + }); + return x; + }); + return h = s ? setTimeout(() => { + g(), clearTimeout(h), u(new sN({ id: r })); + }, s) : void 0, await a; +} +class sN extends pt { + constructor({ id: e }) { + super(`Timed out while waiting for call bundle with id "${e}" to be confirmed.`, { name: "WaitForCallsStatusTimeoutError" }); + } +} +const Ym = 256; +let fh = Ym, lh; +function z4(t = 11) { + if (!lh || fh + t > Ym * 2) { + lh = "", fh = 0; + for (let e = 0; e < Ym; e++) + lh += (256 + Math.random() * 256 | 0).toString(16).substring(1); + } + return lh.substring(fh, fh++ + t); +} +function oN(t) { + const { batch: e, chain: r, ccipRead: n, key: i = "base", name: s = "Base Client", type: o = "base" } = t, a = r?.blockTime ?? 12e3, f = Math.min(Math.max(Math.floor(a / 2), 500), 4e3), u = t.pollingInterval ?? f, h = t.cacheTime ?? u, g = t.account ? pi(t.account) : void 0, { config: v, request: x, value: S } = t.transport({ + chain: r, + pollingInterval: u + }), R = { ...v, ...S }, D = { + account: g, + batch: e, + cacheTime: h, + ccipRead: n, + chain: r, + key: i, + name: s, + pollingInterval: u, + request: x, + transport: R, + type: o, + uid: z4() + }; + function k(N) { + return (z) => { + const B = z(N); + for (const U in D) + delete B[U]; + const $ = { ...N, ...B }; + return Object.assign($, { extend: k($) }); + }; + } + return Object.assign(D, { extend: k(D) }); +} +const hh = /* @__PURE__ */ new qd(8192); +function aN(t, { enabled: e = !0, id: r }) { + if (!e || !r) + return t(); + if (hh.get(r)) + return hh.get(r); + const n = t().finally(() => hh.delete(r)); + return hh.set(r, n), n; +} +function cN(t, { delay: e = 100, retryCount: r = 2, shouldRetry: n = () => !0 } = {}) { + return new Promise((i, s) => { + const o = async ({ count: a = 0 } = {}) => { + const f = async ({ error: u }) => { + const h = typeof e == "function" ? e({ count: a, error: u }) : e; + h && await Gm(h), o({ count: a + 1 }); + }; + try { + const u = await t(); + i(u); + } catch (u) { + if (a < r && await n({ count: a, error: u })) + return f({ error: u }); + s(u); + } + }; + o(); + }); +} +function uN(t, e = {}) { + return async (r, n = {}) => { + const { dedupe: i = !1, methods: s, retryDelay: o = 150, retryCount: a = 3, uid: f } = { + ...e, + ...n + }, { method: u } = r; + if (s?.exclude?.includes(u)) + throw new Aa(new Error("method not supported"), { + method: u + }); + if (s?.include && !s.include.includes(u)) + throw new Aa(new Error("method not supported"), { + method: u + }); + const h = i ? jd(`${f}.${Ua(r)}`) : void 0; + return aN(() => cN(async () => { + try { + return await t(r); + } catch (g) { + const v = g; + switch (v.code) { + // -32700 + case pf.code: + throw new pf(v); + // -32600 + case gf.code: + throw new gf(v); + // -32601 + case mf.code: + throw new mf(v, { method: r.method }); + // -32602 + case vf.code: + throw new vf(v); + // -32603 + case Oa.code: + throw new Oa(v); + // -32000 + case bf.code: + throw new bf(v); + // -32001 + case yf.code: + throw new yf(v); + // -32002 + case wf.code: + throw new wf(v); + // -32003 + case xf.code: + throw new xf(v); + // -32004 + case Aa.code: + throw new Aa(v, { + method: r.method + }); + // -32005 + case Fc.code: + throw new Fc(v); + // -32006 + case _f.code: + throw new _f(v); + // 4001 + case Rc.code: + throw new Rc(v); + // 4100 + case Ef.code: + throw new Ef(v); + // 4200 + case Sf.code: + throw new Sf(v); + // 4900 + case Af.code: + throw new Af(v); + // 4901 + case Pf.code: + throw new Pf(v); + // 4902 + case Mf.code: + throw new Mf(v); + // 5700 + case jc.code: + throw new jc(v); + // 5710 + case If.code: + throw new If(v); + // 5720 + case Cf.code: + throw new Cf(v); + // 5730 + case Rf.code: + throw new Rf(v); + // 5740 + case Tf.code: + throw new Tf(v); + // 5750 + case Df.code: + throw new Df(v); + // 5760 + case Uc.code: + throw new Uc(v); + // CAIP-25: User Rejected Error + // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25 + case 5e3: + throw new Rc(v); + default: + throw g instanceof pt ? g : new sO(v); + } + } + }, { + delay: ({ count: g, error: v }) => { + if (v && v instanceof _4) { + const x = v?.headers?.get("Retry-After"); + if (x?.match(/\d/)) + return Number.parseInt(x) * 1e3; + } + return ~~(1 << g) * o; + }, + retryCount: a, + shouldRetry: ({ error: g }) => fN(g) + }), { enabled: i, id: h }); + }; +} +function fN(t) { + return "code" in t && typeof t.code == "number" ? t.code === -1 || t.code === Fc.code || t.code === Oa.code : t instanceof _4 && t.status ? t.status === 403 || t.status === 408 || t.status === 413 || t.status === 429 || t.status === 500 || t.status === 502 || t.status === 503 || t.status === 504 : !0; +} +function lN({ key: t, methods: e, name: r, request: n, retryCount: i = 3, retryDelay: s = 150, timeout: o, type: a }, f) { + const u = z4(); + return { + config: { + key: t, + methods: e, + name: r, + request: n, + retryCount: i, + retryDelay: s, + timeout: o, + type: a + }, + request: uN(n, { methods: e, retryCount: i, retryDelay: s, uid: u }), + value: f + }; +} +function dh(t, e = {}) { + const { key: r = "custom", methods: n, name: i = "Custom Provider", retryDelay: s } = e; + return ({ retryCount: o }) => lN({ + key: r, + methods: n, + name: i, + request: t.request.bind(t), + retryCount: e.retryCount ?? o, + retryDelay: s, + type: "custom" + }); +} +function hN(t) { + return { + formatters: void 0, + fees: void 0, + serializers: void 0, + ...t + }; +} +class dN extends pt { + constructor({ domain: e }) { + super(`Invalid domain "${Ua(e)}".`, { + metaMessages: ["Must be a valid EIP-712 domain."] + }); + } +} +class pN extends pt { + constructor({ primaryType: e, types: r }) { + super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(r))}\`.`, { + docsPath: "/api/glossary/Errors#typeddatainvalidprimarytypeerror", + metaMessages: ["Check that the primary type is a key in `types`."] + }); + } +} +class gN extends pt { + constructor({ type: e }) { + super(`Struct type "${e}" is invalid.`, { + metaMessages: ["Struct type must not be a Solidity type."], + name: "InvalidStructTypeError" + }); + } +} +function mN(t) { + const { domain: e, message: r, primaryType: n, types: i } = t, s = (f, u) => { + const h = { ...u }; + for (const g of f) { + const { name: v, type: x } = g; + x === "address" && (h[v] = h[v].toLowerCase()); + } + return h; + }, o = i.EIP712Domain ? e ? s(i.EIP712Domain, e) : {} : {}, a = (() => { + if (n !== "EIP712Domain") + return s(i[n], r); + })(); + return Ua({ domain: o, message: a, primaryType: n, types: i }); +} +function vN(t) { + const { domain: e, message: r, primaryType: n, types: i } = t, s = (o, a) => { + for (const f of o) { + const { name: u, type: h } = f, g = a[u], v = h.match(d4); + if (v && (typeof g == "number" || typeof g == "bigint")) { + const [R, D, k] = v; + br(g, { + signed: D === "int", + size: Number.parseInt(k) / 8 + }); + } + if (h === "address" && typeof g == "string" && !fs(g)) + throw new Ho({ address: g }); + const x = h.match(bD); + if (x) { + const [R, D] = x; + if (D && yn(g) !== Number.parseInt(D)) + throw new IT({ + expectedSize: Number.parseInt(D), + givenSize: yn(g) + }); + } + const S = i[h]; + S && (yN(h), s(S, g)); + } + }; + if (i.EIP712Domain && e) { + if (typeof e != "object") + throw new dN({ domain: e }); + s(i.EIP712Domain, e); + } + if (n !== "EIP712Domain") + if (i[n]) + s(i[n], r); + else + throw new pN({ primaryType: n, types: i }); +} +function bN({ domain: t }) { + return [ + typeof t?.name == "string" && { name: "name", type: "string" }, + t?.version && { name: "version", type: "string" }, + (typeof t?.chainId == "number" || typeof t?.chainId == "bigint") && { + name: "chainId", + type: "uint256" + }, + t?.verifyingContract && { + name: "verifyingContract", + type: "address" + }, + t?.salt && { name: "salt", type: "bytes32" } + ].filter(Boolean); +} +function yN(t) { + if (t === "address" || t === "bool" || t === "string" || t.startsWith("bytes") || t.startsWith("uint") || t.startsWith("int")) + throw new gN({ type: t }); +} +async function wN(t, { chain: e }) { + const { id: r, name: n, nativeCurrency: i, rpcUrls: s, blockExplorers: o } = e; + await t.request({ + method: "wallet_addEthereumChain", + params: [ + { + chainId: br(r), + chainName: n, + nativeCurrency: i, + rpcUrls: s.default.http, + blockExplorerUrls: o ? Object.values(o).map(({ url: a }) => a) : void 0 + } + ] + }, { dedupe: !0, retryCount: 0 }); +} +function xN(t, e) { + const { abi: r, args: n, bytecode: i, ...s } = e, o = JO({ abi: r, args: n, bytecode: i }); + return Kd(t, { + ...s, + ...s.authorizationList ? { to: null } : {}, + data: o + }); +} +async function _N(t) { + return t.account?.type === "local" ? [t.account.address] : (await t.request({ method: "eth_accounts" }, { dedupe: !0 })).map((r) => Vf(r)); +} +async function EN(t, e = {}) { + const { account: r = t.account, chainId: n } = e, i = r ? pi(r) : void 0, s = n ? [i?.address, [br(n)]] : [i?.address], o = await t.request({ + method: "wallet_getCapabilities", + params: s + }), a = {}; + for (const [f, u] of Object.entries(o)) { + a[Number(f)] = {}; + for (let [h, g] of Object.entries(u)) + h === "addSubAccount" && (h = "unstable_addSubAccount"), a[Number(f)][h] = g; + } + return typeof n == "number" ? a[n] : a; +} +async function SN(t) { + return await t.request({ method: "wallet_getPermissions" }, { dedupe: !0 }); +} +async function H4(t, e) { + const { account: r = t.account, chainId: n, nonce: i } = e; + if (!r) + throw new qa({ + docsPath: "/docs/eip7702/prepareAuthorization" + }); + const s = pi(r), o = (() => { + if (e.executor) + return e.executor === "self" ? e.executor : pi(e.executor); + })(), a = { + address: e.contractAddress ?? e.address, + chainId: n, + nonce: i + }; + return typeof a.chainId > "u" && (a.chainId = t.chain?.id ?? await Hn(t, Gf, "getChainId")({})), typeof a.nonce > "u" && (a.nonce = await Hn(t, R4, "getTransactionCount")({ + address: s.address, + blockTag: "pending" + }), (o === "self" || o?.address && VO(o.address, s.address)) && (a.nonce += 1)), a; +} +async function AN(t) { + return (await t.request({ method: "eth_requestAccounts" }, { dedupe: !0, retryCount: 0 })).map((r) => e1(r)); +} +async function PN(t, e) { + return t.request({ + method: "wallet_requestPermissions", + params: [e] + }, { retryCount: 0 }); +} +async function MN(t, e) { + const { id: r } = e; + await t.request({ + method: "wallet_showCallsStatus", + params: [r] + }); +} +async function IN(t, e) { + const { account: r = t.account } = e; + if (!r) + throw new qa({ + docsPath: "/docs/eip7702/signAuthorization" + }); + const n = pi(r); + if (!n.signAuthorization) + throw new Nh({ + docsPath: "/docs/eip7702/signAuthorization", + metaMessages: [ + "The `signAuthorization` Action does not support JSON-RPC Accounts." + ], + type: n.type + }); + const i = await H4(t, e); + return n.signAuthorization(i); +} +async function CN(t, { account: e = t.account, message: r }) { + if (!e) + throw new qa({ + docsPath: "/docs/actions/wallet/signMessage" + }); + const n = pi(e); + if (n.signMessage) + return n.signMessage({ message: r }); + const i = typeof r == "string" ? jd(r) : r.raw instanceof Uint8Array ? od(r.raw) : r.raw; + return t.request({ + method: "personal_sign", + params: [i, n.address] + }, { retryCount: 0 }); +} +async function RN(t, e) { + const { account: r = t.account, chain: n = t.chain, ...i } = e; + if (!r) + throw new qa({ + docsPath: "/docs/actions/wallet/signTransaction" + }); + const s = pi(r); + Wd({ + account: s, + ...e + }); + const o = await Hn(t, Gf, "getChainId")({}); + n !== null && $4({ + currentChainId: o, + chain: n + }); + const f = (n?.formatters || t.chain?.formatters)?.transactionRequest?.format || a1; + return s.signTransaction ? s.signTransaction({ + ...i, + chainId: o + }, { serializer: t.chain?.serializers?.transaction }) : await t.request({ + method: "eth_signTransaction", + params: [ + { + ...f(i), + chainId: br(o), + from: s.address + } + ] + }, { retryCount: 0 }); +} +async function TN(t, e) { + const { account: r = t.account, domain: n, message: i, primaryType: s } = e; + if (!r) + throw new qa({ + docsPath: "/docs/actions/wallet/signTypedData" + }); + const o = pi(r), a = { + EIP712Domain: bN({ domain: n }), + ...e.types + }; + if (vN({ domain: n, message: i, primaryType: s, types: a }), o.signTypedData) + return o.signTypedData({ domain: n, message: i, primaryType: s, types: a }); + const f = mN({ domain: n, message: i, primaryType: s, types: a }); + return t.request({ + method: "eth_signTypedData_v4", + params: [o.address, f] + }, { retryCount: 0 }); +} +async function DN(t, { id: e }) { + await t.request({ + method: "wallet_switchEthereumChain", + params: [ + { + chainId: br(e) + } + ] + }, { retryCount: 0 }); +} +async function ON(t, e) { + return await t.request({ + method: "wallet_watchAsset", + params: e + }, { retryCount: 0 }); +} +function NN(t) { + return { + addChain: (e) => wN(t, e), + deployContract: (e) => xN(t, e), + getAddresses: () => _N(t), + getCallsStatus: (e) => q4(t, e), + getCapabilities: (e) => EN(t, e), + getChainId: () => Gf(t), + getPermissions: () => SN(t), + prepareAuthorization: (e) => H4(t, e), + prepareTransactionRequest: (e) => f1(t, e), + requestAddresses: () => AN(t), + requestPermissions: (e) => PN(t, e), + sendCalls: (e) => nN(t, e), + sendRawTransaction: (e) => F4(t, e), + sendTransaction: (e) => Kd(t, e), + showCallsStatus: (e) => MN(t, e), + signAuthorization: (e) => IN(t, e), + signMessage: (e) => CN(t, e), + signTransaction: (e) => RN(t, e), + signTypedData: (e) => TN(t, e), + switchChain: (e) => DN(t, e), + waitForCallsStatus: (e) => iN(t, e), + watchAsset: (e) => ON(t, e), + writeContract: (e) => tN(t, e) + }; +} +function ph(t) { + const { key: e = "wallet", name: r = "Wallet Client", transport: n } = t; + return oN({ + ...t, + key: e, + name: r, + transport: n, + type: "walletClient" + }).extend(NN); +} +class Tc { + _key; + _config = null; + _provider = null; + _connected = !1; + _address = null; + _fatured = !1; + _installed = !1; + lastUsed = !1; + _client = null; + get address() { + return this._address; + } + get connected() { + return this._connected; + } + get featured() { + return this._fatured; + } + get key() { + return this._key; + } + get installed() { + return this._installed; + } + get provider() { + return this._provider; + } + get client() { + return this._client ? this._client : null; + } + get config() { + return this._config; + } + static fromWalletConfig(e) { + return new Tc(e); + } + constructor(e) { + if ("name" in e && "image" in e) + this._key = e.name, this._config = e, this._fatured = e.featured; + else if ("session" in e) { + if (!e.session) throw new Error("session is null"); + this._key = e.session?.peer.metadata.name, this._provider = e, this._client = ph({ transport: dh(this._provider) }), this._config = { + name: e.session.peer.metadata.name, + image: e.session.peer.metadata.icons[0], + featured: !1 + }, this.testConnect(); + } else if ("info" in e) + this._key = e.info.name, this._provider = e.provider, this._installed = !0, this._client = ph({ transport: dh(this._provider) }), this._config = { + name: e.info.name, + image: e.info.icon, + featured: !1 + }, this.testConnect(); + else + throw new Error("unknown params"); + } + EIP6963Detected(e) { + this._provider = e.provider, this._client = ph({ transport: dh(this._provider) }), this._installed = !0, this._provider.on("disconnect", this.disconnect), this._provider.on("accountsChanged", (r) => { + this._address = r[0], this._connected = !0; + }), this.testConnect(); + } + setUniversalProvider(e) { + this._provider = e, this._client = ph({ transport: dh(this._provider) }), this.testConnect(); + } + async switchChain(e) { + try { + return await this.client?.getChainId() === e.id || await this.client?.switchChain(e), !0; + } catch (r) { + if (r.code === 4902) + return await this.client?.addChain({ chain: e }), await this.client?.switchChain(e), !0; + throw r; + } + } + async testConnect() { + const e = await this.client?.getAddresses(); + e && e.length > 0 ? (this._address = e[0], this._connected = !0) : (this._address = null, this._connected = !1); + } + async connect() { + const e = await this.client?.requestAddresses(); + if (!e) throw new Error("connect failed"); + return e; + } + async getAddress() { + const e = await this.client?.getAddresses(); + if (!e) throw new Error("get address failed"); + return e[0]; + } + async getChain() { + const e = await this.client?.getChainId(); + if (!e) throw new Error("get chain failed"); + return e; + } + async signMessage(e, r) { + return await this.client?.signMessage({ message: e, account: r }); + } + async disconnect() { + this._provider && "session" in this._provider && await this._provider.disconnect(), this._connected = !1, this._address = null; + } +} +var gh = { exports: {} }, e2; +function LN() { + if (e2) return gh.exports; + e2 = 1; + var t = typeof Reflect == "object" ? Reflect : null, e = t && typeof t.apply == "function" ? t.apply : function($, U, C) { + return Function.prototype.apply.call($, U, C); + }, r; + t && typeof t.ownKeys == "function" ? r = t.ownKeys : Object.getOwnPropertySymbols ? r = function($) { + return Object.getOwnPropertyNames($).concat(Object.getOwnPropertySymbols($)); + } : r = function($) { + return Object.getOwnPropertyNames($); + }; + function n(B) { + console && console.warn && console.warn(B); + } + var i = Number.isNaN || function($) { + return $ !== $; + }; + function s() { + s.init.call(this); + } + gh.exports = s, gh.exports.once = k, s.EventEmitter = s, s.prototype._events = void 0, s.prototype._eventsCount = 0, s.prototype._maxListeners = void 0; + var o = 10; + function a(B) { + if (typeof B != "function") + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof B); + } + Object.defineProperty(s, "defaultMaxListeners", { + enumerable: !0, + get: function() { + return o; + }, + set: function(B) { + if (typeof B != "number" || B < 0 || i(B)) + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + B + "."); + o = B; + } + }), s.init = function() { + (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0; + }, s.prototype.setMaxListeners = function($) { + if (typeof $ != "number" || $ < 0 || i($)) + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + $ + "."); + return this._maxListeners = $, this; + }; + function f(B) { + return B._maxListeners === void 0 ? s.defaultMaxListeners : B._maxListeners; + } + s.prototype.getMaxListeners = function() { + return f(this); + }, s.prototype.emit = function($) { + for (var U = [], C = 1; C < arguments.length; C++) U.push(arguments[C]); + var W = $ === "error", J = this._events; + if (J !== void 0) + W = W && J.error === void 0; + else if (!W) + return !1; + if (W) { + var ne; + if (U.length > 0 && (ne = U[0]), ne instanceof Error) + throw ne; + var K = new Error("Unhandled error." + (ne ? " (" + ne.message + ")" : "")); + throw K.context = ne, K; + } + var E = J[$]; + if (E === void 0) + return !1; + if (typeof E == "function") + e(E, this, U); + else + for (var b = E.length, l = S(E, b), C = 0; C < b; ++C) + e(l[C], this, U); + return !0; + }; + function u(B, $, U, C) { + var W, J, ne; + if (a(U), J = B._events, J === void 0 ? (J = B._events = /* @__PURE__ */ Object.create(null), B._eventsCount = 0) : (J.newListener !== void 0 && (B.emit( + "newListener", + $, + U.listener ? U.listener : U + ), J = B._events), ne = J[$]), ne === void 0) + ne = J[$] = U, ++B._eventsCount; + else if (typeof ne == "function" ? ne = J[$] = C ? [U, ne] : [ne, U] : C ? ne.unshift(U) : ne.push(U), W = f(B), W > 0 && ne.length > W && !ne.warned) { + ne.warned = !0; + var K = new Error("Possible EventEmitter memory leak detected. " + ne.length + " " + String($) + " listeners added. Use emitter.setMaxListeners() to increase limit"); + K.name = "MaxListenersExceededWarning", K.emitter = B, K.type = $, K.count = ne.length, n(K); + } + return B; + } + s.prototype.addListener = function($, U) { + return u(this, $, U, !1); + }, s.prototype.on = s.prototype.addListener, s.prototype.prependListener = function($, U) { + return u(this, $, U, !0); + }; + function h() { + 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 g(B, $, U) { + var C = { fired: !1, wrapFn: void 0, target: B, type: $, listener: U }, W = h.bind(C); + return W.listener = U, C.wrapFn = W, W; + } + s.prototype.once = function($, U) { + return a(U), this.on($, g(this, $, U)), this; + }, s.prototype.prependOnceListener = function($, U) { + return a(U), this.prependListener($, g(this, $, U)), this; + }, s.prototype.removeListener = function($, U) { + var C, W, J, ne, K; + if (a(U), W = this._events, W === void 0) + return this; + if (C = W[$], C === void 0) + return this; + if (C === U || C.listener === U) + --this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete W[$], W.removeListener && this.emit("removeListener", $, C.listener || U)); + else if (typeof C != "function") { + for (J = -1, ne = C.length - 1; ne >= 0; ne--) + if (C[ne] === U || C[ne].listener === U) { + K = C[ne].listener, J = ne; + break; + } + if (J < 0) + return this; + J === 0 ? C.shift() : R(C, J), C.length === 1 && (W[$] = C[0]), W.removeListener !== void 0 && this.emit("removeListener", $, K || U); + } + return this; + }, s.prototype.off = s.prototype.removeListener, s.prototype.removeAllListeners = function($) { + var U, C, W; + if (C = this._events, C === void 0) + return this; + if (C.removeListener === void 0) + return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : C[$] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete C[$]), this; + if (arguments.length === 0) { + var J = Object.keys(C), ne; + for (W = 0; W < J.length; ++W) + ne = J[W], ne !== "removeListener" && this.removeAllListeners(ne); + return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this; + } + if (U = C[$], typeof U == "function") + this.removeListener($, U); + else if (U !== void 0) + for (W = U.length - 1; W >= 0; W--) + this.removeListener($, U[W]); + return this; + }; + function v(B, $, U) { + var C = B._events; + if (C === void 0) + return []; + var W = C[$]; + return W === void 0 ? [] : typeof W == "function" ? U ? [W.listener || W] : [W] : U ? D(W) : S(W, W.length); + } + s.prototype.listeners = function($) { + return v(this, $, !0); + }, s.prototype.rawListeners = function($) { + return v(this, $, !1); + }, s.listenerCount = function(B, $) { + return typeof B.listenerCount == "function" ? B.listenerCount($) : x.call(B, $); + }, s.prototype.listenerCount = x; + function x(B) { + var $ = this._events; + if ($ !== void 0) { + var U = $[B]; + if (typeof U == "function") + return 1; + if (U !== void 0) + return U.length; + } + return 0; + } + s.prototype.eventNames = function() { + return this._eventsCount > 0 ? r(this._events) : []; + }; + function S(B, $) { + for (var U = new Array($), C = 0; C < $; ++C) + U[C] = B[C]; + return U; + } + function R(B, $) { + for (; $ + 1 < B.length; $++) + B[$] = B[$ + 1]; + B.pop(); + } + function D(B) { + for (var $ = new Array(B.length), U = 0; U < $.length; ++U) + $[U] = B[U].listener || B[U]; + return $; + } + function k(B, $) { + return new Promise(function(U, C) { + function W(ne) { + B.removeListener($, J), C(ne); + } + function J() { + typeof B.removeListener == "function" && B.removeListener("error", W), U([].slice.call(arguments)); + } + z(B, $, J, { once: !0 }), $ !== "error" && N(B, W, { once: !0 }); + }); + } + function N(B, $, U) { + typeof B.on == "function" && z(B, "error", $, U); + } + function z(B, $, U, C) { + if (typeof B.on == "function") + C.once ? B.once($, U) : B.on($, U); + else if (typeof B.addEventListener == "function") + B.addEventListener($, function W(J) { + C.once && B.removeEventListener($, W), U(J); + }); + else + throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof B); + } + return gh.exports; +} +var Wi = LN(); +const l1 = /* @__PURE__ */ Hi(Wi); +var Hp = {}; +/*! ***************************************************************************** +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. +***************************************************************************** */ +var Jm = function(t, e) { + return Jm = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) { + r.__proto__ = n; + } || function(r, n) { + for (var i in n) n.hasOwnProperty(i) && (r[i] = n[i]); + }, Jm(t, e); +}; +function kN(t, e) { + Jm(t, e); + function r() { + this.constructor = t; + } + t.prototype = e === null ? Object.create(e) : (r.prototype = e.prototype, new r()); +} +var Xm = function() { + return Xm = Object.assign || function(e) { + for (var r, n = 1, i = arguments.length; n < i; n++) { + r = arguments[n]; + for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]); + } + return e; + }, Xm.apply(this, arguments); +}; +function $N(t, e) { + var r = {}; + for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); + if (t != null && typeof Object.getOwnPropertySymbols == "function") + for (var i = 0, n = Object.getOwnPropertySymbols(t); i < n.length; i++) + e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[i]) && (r[n[i]] = t[n[i]]); + return r; +} +function BN(t, e, r, n) { + var i = arguments.length, s = i < 3 ? e : n === null ? n = Object.getOwnPropertyDescriptor(e, r) : n, o; + if (typeof Reflect == "object" && typeof Reflect.decorate == "function") s = Reflect.decorate(t, e, r, n); + else for (var a = t.length - 1; a >= 0; a--) (o = t[a]) && (s = (i < 3 ? o(s) : i > 3 ? o(e, r, s) : o(e, r)) || s); + return i > 3 && s && Object.defineProperty(e, r, s), s; +} +function FN(t, e) { + return function(r, n) { + e(r, n, t); + }; +} +function jN(t, e) { + if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(t, e); +} +function UN(t, e, r, n) { + function i(s) { + return s instanceof r ? s : new r(function(o) { + o(s); + }); + } + return new (r || (r = Promise))(function(s, o) { + function a(h) { + try { + u(n.next(h)); + } catch (g) { + o(g); + } + } + function f(h) { + try { + u(n.throw(h)); + } catch (g) { + o(g); + } + } + function u(h) { + h.done ? s(h.value) : i(h.value).then(a, f); + } + u((n = n.apply(t, e || [])).next()); + }); +} +function qN(t, e) { + var r = { label: 0, sent: function() { + if (s[0] & 1) throw s[1]; + return s[1]; + }, trys: [], ops: [] }, n, i, 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(h) { + return f([u, h]); + }; + } + function f(u) { + if (n) throw new TypeError("Generator is already executing."); + for (; r; ) try { + if (n = 1, i && (s = u[0] & 2 ? i.return : u[0] ? i.throw || ((s = i.return) && s.call(i), 0) : i.next) && !(s = s.call(i, u[1])).done) return s; + switch (i = 0, s && (u = [u[0] & 2, s.value]), u[0]) { + case 0: + case 1: + s = u; + break; + case 4: + return r.label++, { value: u[1], done: !1 }; + case 5: + r.label++, i = u[1], u = [0]; + continue; + case 7: + u = r.ops.pop(), r.trys.pop(); + continue; + default: + if (s = r.trys, !(s = s.length > 0 && s[s.length - 1]) && (u[0] === 6 || u[0] === 2)) { + r = 0; + continue; + } + if (u[0] === 3 && (!s || u[1] > s[0] && u[1] < s[3])) { + r.label = u[1]; + break; + } + if (u[0] === 6 && r.label < s[1]) { + r.label = s[1], s = u; + break; + } + if (s && r.label < s[2]) { + r.label = s[2], r.ops.push(u); + break; + } + s[2] && r.ops.pop(), r.trys.pop(); + continue; + } + u = e.call(t, r); + } catch (h) { + u = [6, h], i = 0; + } finally { + n = s = 0; + } + if (u[0] & 5) throw u[1]; + return { value: u[0] ? u[1] : void 0, done: !0 }; + } +} +function zN(t, e, r, n) { + n === void 0 && (n = r), t[n] = e[r]; +} +function HN(t, e) { + for (var r in t) r !== "default" && !e.hasOwnProperty(r) && (e[r] = t[r]); +} +function Zm(t) { + var e = typeof Symbol == "function" && Symbol.iterator, r = e && t[e], n = 0; + if (r) return r.call(t); + if (t && typeof t.length == "number") return { + next: function() { + return t && n >= t.length && (t = void 0), { value: t && t[n++], done: !t }; + } + }; + throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined."); +} +function W4(t, e) { + var r = typeof Symbol == "function" && t[Symbol.iterator]; + if (!r) return t; + var n = r.call(t), i, s = [], o; + try { + for (; (e === void 0 || e-- > 0) && !(i = n.next()).done; ) s.push(i.value); + } catch (a) { + o = { error: a }; + } finally { + try { + i && !i.done && (r = n.return) && r.call(n); + } finally { + if (o) throw o.error; + } + } + return s; +} +function WN() { + for (var t = [], e = 0; e < arguments.length; e++) + t = t.concat(W4(arguments[e])); + return t; +} +function KN() { + for (var t = 0, e = 0, r = arguments.length; e < r; e++) t += arguments[e].length; + for (var n = Array(t), i = 0, e = 0; e < r; e++) + for (var s = arguments[e], o = 0, a = s.length; o < a; o++, i++) + n[i] = s[o]; + return n; +} +function Of(t) { + return this instanceof Of ? (this.v = t, this) : new Of(t); +} +function VN(t, e, r) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var n = r.apply(t, e || []), i, s = []; + return i = {}, o("next"), o("throw"), o("return"), i[Symbol.asyncIterator] = function() { + return this; + }, i; + function o(v) { + n[v] && (i[v] = function(x) { + return new Promise(function(S, R) { + s.push([v, x, S, R]) > 1 || a(v, x); + }); + }); + } + function a(v, x) { + try { + f(n[v](x)); + } catch (S) { + g(s[0][3], S); + } + } + function f(v) { + v.value instanceof Of ? Promise.resolve(v.value.v).then(u, h) : g(s[0][2], v); + } + function u(v) { + a("next", v); + } + function h(v) { + a("throw", v); + } + function g(v, x) { + v(x), s.shift(), s.length && a(s[0][0], s[0][1]); + } +} +function GN(t) { + var e, r; + return e = {}, n("next"), n("throw", function(i) { + throw i; + }), n("return"), e[Symbol.iterator] = function() { + return this; + }, e; + function n(i, s) { + e[i] = t[i] ? function(o) { + return (r = !r) ? { value: Of(t[i](o)), done: i === "return" } : s ? s(o) : o; + } : s; + } +} +function YN(t) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var e = t[Symbol.asyncIterator], r; + return e ? e.call(t) : (t = typeof Zm == "function" ? Zm(t) : t[Symbol.iterator](), r = {}, n("next"), n("throw"), n("return"), r[Symbol.asyncIterator] = function() { + return this; + }, r); + function n(s) { + r[s] = t[s] && function(o) { + return new Promise(function(a, f) { + o = t[s](o), i(a, f, o.done, o.value); + }); + }; + } + function i(s, o, a, f) { + Promise.resolve(f).then(function(u) { + s({ value: u, done: a }); + }, o); + } +} +function JN(t, e) { + return Object.defineProperty ? Object.defineProperty(t, "raw", { value: e }) : t.raw = e, t; +} +function XN(t) { + if (t && t.__esModule) return t; + var e = {}; + if (t != null) for (var r in t) Object.hasOwnProperty.call(t, r) && (e[r] = t[r]); + return e.default = t, e; +} +function ZN(t) { + return t && t.__esModule ? t : { default: t }; +} +function QN(t, e) { + if (!e.has(t)) + throw new TypeError("attempted to get private field on non-instance"); + return e.get(t); +} +function eL(t, e, r) { + if (!e.has(t)) + throw new TypeError("attempted to set private field on non-instance"); + return e.set(t, r), r; +} +const tL = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + get __assign() { + return Xm; + }, + __asyncDelegator: GN, + __asyncGenerator: VN, + __asyncValues: YN, + __await: Of, + __awaiter: UN, + __classPrivateFieldGet: QN, + __classPrivateFieldSet: eL, + __createBinding: zN, + __decorate: BN, + __exportStar: HN, + __extends: kN, + __generator: qN, + __importDefault: ZN, + __importStar: XN, + __makeTemplateObject: JN, + __metadata: jN, + __param: FN, + __read: W4, + __rest: $N, + __spread: WN, + __spreadArrays: KN, + __values: Zm +}, Symbol.toStringTag, { value: "Module" })), Yf = /* @__PURE__ */ K5(tL); +var Wp = {}, Au = {}, t2; +function rL() { + if (t2) return Au; + t2 = 1, Object.defineProperty(Au, "__esModule", { value: !0 }), Au.delay = void 0; + function t(e) { + return new Promise((r) => { + setTimeout(() => { + r(!0); + }, e); + }); + } + return Au.delay = t, Au; +} +var la = {}, Kp = {}, ha = {}, r2; +function nL() { + return r2 || (r2 = 1, Object.defineProperty(ha, "__esModule", { value: !0 }), ha.ONE_THOUSAND = ha.ONE_HUNDRED = void 0, ha.ONE_HUNDRED = 100, ha.ONE_THOUSAND = 1e3), ha; +} +var Vp = {}, n2; +function iL() { + return n2 || (n2 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }), t.ONE_YEAR = t.FOUR_WEEKS = t.THREE_WEEKS = t.TWO_WEEKS = t.ONE_WEEK = t.THIRTY_DAYS = t.SEVEN_DAYS = t.FIVE_DAYS = t.THREE_DAYS = t.ONE_DAY = t.TWENTY_FOUR_HOURS = t.TWELVE_HOURS = t.SIX_HOURS = t.THREE_HOURS = t.ONE_HOUR = t.SIXTY_MINUTES = t.THIRTY_MINUTES = t.TEN_MINUTES = t.FIVE_MINUTES = t.ONE_MINUTE = t.SIXTY_SECONDS = t.THIRTY_SECONDS = t.TEN_SECONDS = t.FIVE_SECONDS = t.ONE_SECOND = void 0, t.ONE_SECOND = 1, t.FIVE_SECONDS = 5, t.TEN_SECONDS = 10, t.THIRTY_SECONDS = 30, t.SIXTY_SECONDS = 60, t.ONE_MINUTE = t.SIXTY_SECONDS, t.FIVE_MINUTES = t.ONE_MINUTE * 5, t.TEN_MINUTES = t.ONE_MINUTE * 10, t.THIRTY_MINUTES = t.ONE_MINUTE * 30, t.SIXTY_MINUTES = t.ONE_MINUTE * 60, t.ONE_HOUR = t.SIXTY_MINUTES, t.THREE_HOURS = t.ONE_HOUR * 3, t.SIX_HOURS = t.ONE_HOUR * 6, t.TWELVE_HOURS = t.ONE_HOUR * 12, t.TWENTY_FOUR_HOURS = t.ONE_HOUR * 24, t.ONE_DAY = t.TWENTY_FOUR_HOURS, t.THREE_DAYS = t.ONE_DAY * 3, t.FIVE_DAYS = t.ONE_DAY * 5, t.SEVEN_DAYS = t.ONE_DAY * 7, t.THIRTY_DAYS = t.ONE_DAY * 30, t.ONE_WEEK = t.SEVEN_DAYS, t.TWO_WEEKS = t.ONE_WEEK * 2, t.THREE_WEEKS = t.ONE_WEEK * 3, t.FOUR_WEEKS = t.ONE_WEEK * 4, t.ONE_YEAR = t.ONE_DAY * 365; + })(Vp)), Vp; +} +var i2; +function K4() { + return i2 || (i2 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }); + const e = Yf; + e.__exportStar(nL(), t), e.__exportStar(iL(), t); + })(Kp)), Kp; +} +var s2; +function sL() { + if (s2) return la; + s2 = 1, Object.defineProperty(la, "__esModule", { value: !0 }), la.fromMiliseconds = la.toMiliseconds = void 0; + const t = K4(); + function e(n) { + return n * t.ONE_THOUSAND; + } + la.toMiliseconds = e; + function r(n) { + return Math.floor(n / t.ONE_THOUSAND); + } + return la.fromMiliseconds = r, la; +} +var o2; +function oL() { + return o2 || (o2 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }); + const e = Yf; + e.__exportStar(rL(), t), e.__exportStar(sL(), t); + })(Wp)), Wp; +} +var dc = {}, a2; +function aL() { + if (a2) return dc; + a2 = 1, Object.defineProperty(dc, "__esModule", { value: !0 }), dc.Watch = void 0; + class t { + constructor() { + this.timestamps = /* @__PURE__ */ new Map(); + } + start(r) { + if (this.timestamps.has(r)) + throw new Error(`Watch already started for label: ${r}`); + this.timestamps.set(r, { started: Date.now() }); + } + stop(r) { + const n = this.get(r); + if (typeof n.elapsed < "u") + throw new Error(`Watch already stopped for label: ${r}`); + const i = Date.now() - n.started; + this.timestamps.set(r, { started: n.started, elapsed: i }); + } + get(r) { + const n = this.timestamps.get(r); + if (typeof n > "u") + throw new Error(`No timestamp found for label: ${r}`); + return n; + } + elapsed(r) { + const n = this.get(r); + return n.elapsed || Date.now() - n.started; + } + } + return dc.Watch = t, dc.default = t, dc; +} +var Gp = {}, Pu = {}, c2; +function cL() { + if (c2) return Pu; + c2 = 1, Object.defineProperty(Pu, "__esModule", { value: !0 }), Pu.IWatch = void 0; + class t { + } + return Pu.IWatch = t, Pu; +} +var u2; +function uL() { + return u2 || (u2 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }), Yf.__exportStar(cL(), t); + })(Gp)), Gp; +} +var f2; +function fL() { + return f2 || (f2 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }); + const e = Yf; + e.__exportStar(oL(), t), e.__exportStar(aL(), t), e.__exportStar(uL(), t), e.__exportStar(K4(), t); + })(Hp)), Hp; +} +var bt = fL(); +class za { +} +let lL = class extends za { + constructor(e) { + super(); + } +}; +const l2 = bt.FIVE_SECONDS, Vc = { pulse: "heartbeat_pulse" }; +let hL = class V4 extends lL { + constructor(e) { + super(e), this.events = new Wi.EventEmitter(), this.interval = l2, this.interval = e?.interval || l2; + } + static async init(e) { + const r = new V4(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(), bt.toMiliseconds(this.interval)); + } + pulse() { + this.events.emit(Vc.pulse); + } +}; +const dL = /"(?:_|\\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*:/, pL = /"(?: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*:/, gL = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/; +function mL(t, e) { + if (t === "__proto__" || t === "constructor" && e && typeof e == "object" && "prototype" in e) { + vL(t); + return; + } + return e; +} +function vL(t) { + console.warn(`[destr] Dropping "${t}" key to prevent prototype pollution.`); +} +function mh(t, e = {}) { + if (typeof t != "string") + return t; + const r = t.trim(); + if ( + // eslint-disable-next-line unicorn/prefer-at + t[0] === '"' && t.endsWith('"') && !t.includes("\\") + ) + return r.slice(1, -1); + if (r.length <= 9) { + const n = r.toLowerCase(); + if (n === "true") + return !0; + if (n === "false") + return !1; + if (n === "undefined") + return; + if (n === "null") + return null; + if (n === "nan") + return Number.NaN; + if (n === "infinity") + return Number.POSITIVE_INFINITY; + if (n === "-infinity") + return Number.NEGATIVE_INFINITY; + } + if (!gL.test(t)) { + if (e.strict) + throw new SyntaxError("[destr] Invalid JSON"); + return t; + } + try { + if (dL.test(t) || pL.test(t)) { + if (e.strict) + throw new Error("[destr] Possible prototype pollution"); + return JSON.parse(t, mL); + } + return JSON.parse(t); + } catch (n) { + if (e.strict) + throw n; + return t; + } +} +function bL(t) { + return !t || typeof t.then != "function" ? Promise.resolve(t) : t; +} +function Mn(t, ...e) { + try { + return bL(t(...e)); + } catch (r) { + return Promise.reject(r); + } +} +function yL(t) { + const e = typeof t; + return t === null || e !== "object" && e !== "function"; +} +function wL(t) { + const e = Object.getPrototypeOf(t); + return !e || e.isPrototypeOf(Object); +} +function Lh(t) { + if (yL(t)) + return String(t); + if (wL(t) || Array.isArray(t)) + return JSON.stringify(t); + if (typeof t.toJSON == "function") + return Lh(t.toJSON()); + throw new Error("[unstorage] Cannot stringify value!"); +} +function G4() { + if (typeof Buffer > "u") + throw new TypeError("[unstorage] Buffer is not supported!"); +} +const Qm = "base64:"; +function xL(t) { + if (typeof t == "string") + return t; + G4(); + const e = Buffer.from(t).toString("base64"); + return Qm + e; +} +function _L(t) { + return typeof t != "string" || !t.startsWith(Qm) ? t : (G4(), Buffer.from(t.slice(Qm.length), "base64")); +} +function ci(t) { + return t ? t.split("?")[0].replace(/[/\\]/g, ":").replace(/:+/g, ":").replace(/^:|:$/g, "") : ""; +} +function EL(...t) { + return ci(t.join(":")); +} +function vh(t) { + return t = ci(t), t ? t + ":" : ""; +} +const SL = "memory", AL = () => { + const t = /* @__PURE__ */ new Map(); + return { + name: SL, + getInstance: () => t, + hasItem(e) { + return t.has(e); + }, + getItem(e) { + return t.get(e) ?? null; + }, + getItemRaw(e) { + return t.get(e) ?? null; + }, + setItem(e, r) { + t.set(e, r); + }, + setItemRaw(e, r) { + t.set(e, r); + }, + removeItem(e) { + t.delete(e); + }, + getKeys() { + return [...t.keys()]; + }, + clear() { + t.clear(); + }, + dispose() { + t.clear(); + } + }; +}; +function PL(t = {}) { + const e = { + mounts: { "": t.driver || AL() }, + mountpoints: [""], + watching: !1, + watchListeners: [], + unwatch: {} + }, r = (u) => { + for (const h of e.mountpoints) + if (u.startsWith(h)) + return { + base: h, + relativeKey: u.slice(h.length), + driver: e.mounts[h] + }; + return { + base: "", + relativeKey: u, + driver: e.mounts[""] + }; + }, n = (u, h) => e.mountpoints.filter( + (g) => g.startsWith(u) || h && u.startsWith(g) + ).map((g) => ({ + relativeBase: u.length > g.length ? u.slice(g.length) : void 0, + mountpoint: g, + driver: e.mounts[g] + })), i = (u, h) => { + if (e.watching) { + h = ci(h); + for (const g of e.watchListeners) + g(u, h); + } + }, s = async () => { + if (!e.watching) { + e.watching = !0; + for (const u in e.mounts) + e.unwatch[u] = await h2( + e.mounts[u], + i, + u + ); + } + }, o = async () => { + if (e.watching) { + for (const u in e.unwatch) + await e.unwatch[u](); + e.unwatch = {}, e.watching = !1; + } + }, a = (u, h, g) => { + const v = /* @__PURE__ */ new Map(), x = (S) => { + let R = v.get(S.base); + return R || (R = { + driver: S.driver, + base: S.base, + items: [] + }, v.set(S.base, R)), R; + }; + for (const S of u) { + const R = typeof S == "string", D = ci(R ? S : S.key), k = R ? void 0 : S.value, N = R || !S.options ? h : { ...h, ...S.options }, z = r(D); + x(z).items.push({ + key: D, + value: k, + relativeKey: z.relativeKey, + options: N + }); + } + return Promise.all([...v.values()].map((S) => g(S))).then( + (S) => S.flat() + ); + }, f = { + // Item + hasItem(u, h = {}) { + u = ci(u); + const { relativeKey: g, driver: v } = r(u); + return Mn(v.hasItem, g, h); + }, + getItem(u, h = {}) { + u = ci(u); + const { relativeKey: g, driver: v } = r(u); + return Mn(v.getItem, g, h).then( + (x) => mh(x) + ); + }, + getItems(u, h) { + return a(u, h, (g) => g.driver.getItems ? Mn( + g.driver.getItems, + g.items.map((v) => ({ + key: v.relativeKey, + options: v.options + })), + h + ).then( + (v) => v.map((x) => ({ + key: EL(g.base, x.key), + value: mh(x.value) + })) + ) : Promise.all( + g.items.map((v) => Mn( + g.driver.getItem, + v.relativeKey, + v.options + ).then((x) => ({ + key: v.key, + value: mh(x) + }))) + )); + }, + getItemRaw(u, h = {}) { + u = ci(u); + const { relativeKey: g, driver: v } = r(u); + return v.getItemRaw ? Mn(v.getItemRaw, g, h) : Mn(v.getItem, g, h).then( + (x) => _L(x) + ); + }, + async setItem(u, h, g = {}) { + if (h === void 0) + return f.removeItem(u); + u = ci(u); + const { relativeKey: v, driver: x } = r(u); + x.setItem && (await Mn(x.setItem, v, Lh(h), g), x.watch || i("update", u)); + }, + async setItems(u, h) { + await a(u, h, async (g) => { + if (g.driver.setItems) + return Mn( + g.driver.setItems, + g.items.map((v) => ({ + key: v.relativeKey, + value: Lh(v.value), + options: v.options + })), + h + ); + g.driver.setItem && await Promise.all( + g.items.map((v) => Mn( + g.driver.setItem, + v.relativeKey, + Lh(v.value), + v.options + )) + ); + }); + }, + async setItemRaw(u, h, g = {}) { + if (h === void 0) + return f.removeItem(u, g); + u = ci(u); + const { relativeKey: v, driver: x } = r(u); + if (x.setItemRaw) + await Mn(x.setItemRaw, v, h, g); + else if (x.setItem) + await Mn(x.setItem, v, xL(h), g); + else + return; + x.watch || i("update", u); + }, + async removeItem(u, h = {}) { + typeof h == "boolean" && (h = { removeMeta: h }), u = ci(u); + const { relativeKey: g, driver: v } = r(u); + v.removeItem && (await Mn(v.removeItem, g, h), (h.removeMeta || h.removeMata) && await Mn(v.removeItem, g + "$", h), v.watch || i("remove", u)); + }, + // Meta + async getMeta(u, h = {}) { + typeof h == "boolean" && (h = { nativeOnly: h }), u = ci(u); + const { relativeKey: g, driver: v } = r(u), x = /* @__PURE__ */ Object.create(null); + if (v.getMeta && Object.assign(x, await Mn(v.getMeta, g, h)), !h.nativeOnly) { + const S = await Mn( + v.getItem, + g + "$", + h + ).then((R) => mh(R)); + S && typeof S == "object" && (typeof S.atime == "string" && (S.atime = new Date(S.atime)), typeof S.mtime == "string" && (S.mtime = new Date(S.mtime)), Object.assign(x, S)); + } + return x; + }, + setMeta(u, h, g = {}) { + return this.setItem(u + "$", h, g); + }, + removeMeta(u, h = {}) { + return this.removeItem(u + "$", h); + }, + // Keys + async getKeys(u, h = {}) { + u = vh(u); + const g = n(u, !0); + let v = []; + const x = []; + for (const S of g) { + const R = await Mn( + S.driver.getKeys, + S.relativeBase, + h + ); + for (const D of R) { + const k = S.mountpoint + ci(D); + v.some((N) => k.startsWith(N)) || x.push(k); + } + v = [ + S.mountpoint, + ...v.filter((D) => !D.startsWith(S.mountpoint)) + ]; + } + return u ? x.filter( + (S) => S.startsWith(u) && S[S.length - 1] !== "$" + ) : x.filter((S) => S[S.length - 1] !== "$"); + }, + // Utils + async clear(u, h = {}) { + u = vh(u), await Promise.all( + n(u, !1).map(async (g) => { + if (g.driver.clear) + return Mn(g.driver.clear, g.relativeBase, h); + if (g.driver.removeItem) { + const v = await g.driver.getKeys(g.relativeBase || "", h); + return Promise.all( + v.map((x) => g.driver.removeItem(x, h)) + ); + } + }) + ); + }, + async dispose() { + await Promise.all( + Object.values(e.mounts).map((u) => d2(u)) + ); + }, + async watch(u) { + return await s(), e.watchListeners.push(u), async () => { + e.watchListeners = e.watchListeners.filter( + (h) => h !== u + ), e.watchListeners.length === 0 && await o(); + }; + }, + async unwatch() { + e.watchListeners = [], await o(); + }, + // Mount + mount(u, h) { + if (u = vh(u), u && e.mounts[u]) + throw new Error(`already mounted at ${u}`); + return u && (e.mountpoints.push(u), e.mountpoints.sort((g, v) => v.length - g.length)), e.mounts[u] = h, e.watching && Promise.resolve(h2(h, i, u)).then((g) => { + e.unwatch[u] = g; + }).catch(console.error), f; + }, + async unmount(u, h = !0) { + u = vh(u), !(!u || !e.mounts[u]) && (e.watching && u in e.unwatch && (e.unwatch[u](), delete e.unwatch[u]), h && await d2(e.mounts[u]), e.mountpoints = e.mountpoints.filter((g) => g !== u), delete e.mounts[u]); + }, + getMount(u = "") { + u = ci(u) + ":"; + const h = r(u); + return { + driver: h.driver, + base: h.base + }; + }, + getMounts(u = "", h = {}) { + return u = ci(u), n(u, h.parents).map((v) => ({ + driver: v.driver, + base: v.mountpoint + })); + }, + // Aliases + keys: (u, h = {}) => f.getKeys(u, h), + get: (u, h = {}) => f.getItem(u, h), + set: (u, h, g = {}) => f.setItem(u, h, g), + has: (u, h = {}) => f.hasItem(u, h), + del: (u, h = {}) => f.removeItem(u, h), + remove: (u, h = {}) => f.removeItem(u, h) + }; + return f; +} +function h2(t, e, r) { + return t.watch ? t.watch((n, i) => e(n, r + i)) : () => { + }; +} +async function d2(t) { + typeof t.dispose == "function" && await Mn(t.dispose); +} +function Ha(t) { + return new Promise((e, r) => { + t.oncomplete = t.onsuccess = () => e(t.result), t.onabort = t.onerror = () => r(t.error); + }); +} +function Y4(t, e) { + const r = indexedDB.open(t); + r.onupgradeneeded = () => r.result.createObjectStore(e); + const n = Ha(r); + return (i, s) => n.then((o) => s(o.transaction(e, i).objectStore(e))); +} +let Yp; +function Jf() { + return Yp || (Yp = Y4("keyval-store", "keyval")), Yp; +} +function p2(t, e = Jf()) { + return e("readonly", (r) => Ha(r.get(t))); +} +function ML(t, e, r = Jf()) { + return r("readwrite", (n) => (n.put(e, t), Ha(n.transaction))); +} +function IL(t, e = Jf()) { + return e("readwrite", (r) => (r.delete(t), Ha(r.transaction))); +} +function CL(t = Jf()) { + return t("readwrite", (e) => (e.clear(), Ha(e.transaction))); +} +function RL(t, e) { + return t.openCursor().onsuccess = function() { + this.result && (e(this.result), this.result.continue()); + }, Ha(t.transaction); +} +function TL(t = Jf()) { + return t("readonly", (e) => { + if (e.getAllKeys) + return Ha(e.getAllKeys()); + const r = []; + return RL(e, (n) => r.push(n.key)).then(() => r); + }); +} +const DL = (t) => JSON.stringify(t, (e, r) => typeof r == "bigint" ? r.toString() + "n" : r), OL = (t) => { + const 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 = t.replace(e, '$1"$2n"$3'); + return JSON.parse(r, (n, i) => typeof i == "string" && i.match(/^\d+n$/) ? BigInt(i.substring(0, i.length - 1)) : i); +}; +function Na(t) { + if (typeof t != "string") + throw new Error(`Cannot safe json parse value of type ${typeof t}`); + try { + return OL(t); + } catch { + return t; + } +} +function ho(t) { + return typeof t == "string" ? t : DL(t) || ""; +} +const NL = "idb-keyval"; +var LL = (t = {}) => { + const e = t.base && t.base.length > 0 ? `${t.base}:` : "", r = (i) => e + i; + let n; + return t.dbName && t.storeName && (n = Y4(t.dbName, t.storeName)), { name: NL, options: t, async hasItem(i) { + return !(typeof await p2(r(i), n) > "u"); + }, async getItem(i) { + return await p2(r(i), n) ?? null; + }, setItem(i, s) { + return ML(r(i), s, n); + }, removeItem(i) { + return IL(r(i), n); + }, getKeys() { + return TL(n); + }, clear() { + return CL(n); + } }; +}; +const kL = "WALLET_CONNECT_V2_INDEXED_DB", $L = "keyvaluestorage"; +let BL = class { + constructor() { + this.indexedDb = PL({ driver: LL({ dbName: kL, storeName: $L }) }); + } + 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) { + const r = await this.indexedDb.getItem(e); + if (r !== null) return r; + } + async setItem(e, r) { + await this.indexedDb.setItem(e, ho(r)); + } + async removeItem(e) { + await this.indexedDb.removeItem(e); + } +}; +var Jp = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, kh = { exports: {} }; +(function() { + let t; + function e() { + } + t = e, t.prototype.getItem = function(r) { + return this.hasOwnProperty(r) ? String(this[r]) : null; + }, t.prototype.setItem = function(r, n) { + this[r] = String(n); + }, t.prototype.removeItem = function(r) { + delete this[r]; + }, t.prototype.clear = function() { + const r = this; + Object.keys(r).forEach(function(n) { + r[n] = void 0, delete r[n]; + }); + }, t.prototype.key = function(r) { + return r = r || 0, Object.keys(this)[r]; + }, t.prototype.__defineGetter__("length", function() { + return Object.keys(this).length; + }), typeof Jp < "u" && Jp.localStorage ? kh.exports = Jp.localStorage : typeof window < "u" && window.localStorage ? kh.exports = window.localStorage : kh.exports = new e(); +})(); +function FL(t) { + var e; + return [t[0], Na((e = t[1]) != null ? e : "")]; +} +let jL = class { + constructor() { + this.localStorage = kh.exports; + } + async getKeys() { + return Object.keys(this.localStorage); + } + async getEntries() { + return Object.entries(this.localStorage).map(FL); + } + async getItem(e) { + const r = this.localStorage.getItem(e); + if (r !== null) return Na(r); + } + async setItem(e, r) { + this.localStorage.setItem(e, ho(r)); + } + async removeItem(e) { + this.localStorage.removeItem(e); + } +}; +const UL = "wc_storage_version", g2 = 1, qL = async (t, e, r) => { + const n = UL, i = await e.getItem(n); + if (i && i >= g2) { + r(e); + return; + } + const s = await t.getKeys(); + if (!s.length) { + r(e); + return; + } + const o = []; + for (; s.length; ) { + const a = s.shift(); + if (!a) continue; + const f = a.toLowerCase(); + if (f.includes("wc@") || f.includes("walletconnect") || f.includes("wc_") || f.includes("wallet_connect")) { + const u = await t.getItem(a); + await e.setItem(a, u), o.push(a); + } + } + await e.setItem(n, g2), r(e), zL(t, o); +}, zL = async (t, e) => { + e.length && e.forEach(async (r) => { + await t.removeItem(r); + }); +}; +let HL = class { + constructor() { + this.initialized = !1, this.setInitialized = (r) => { + this.storage = r, this.initialized = !0; + }; + const e = new jL(); + this.storage = e; + try { + const r = new BL(); + qL(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) => { + const r = setInterval(() => { + this.initialized && (clearInterval(r), e()); + }, 20); + }); + } +}; +var Xp, m2; +function WL() { + if (m2) return Xp; + m2 = 1; + function t(r) { + try { + return JSON.stringify(r); + } catch { + return '"[Circular]"'; + } + } + Xp = e; + function e(r, n, i) { + var s = i && i.stringify || t, o = 1; + if (typeof r == "object" && r !== null) { + var a = n.length + o; + if (a === 1) return r; + var f = new Array(a); + f[0] = s(r); + for (var u = 1; u < a; u++) + f[u] = s(n[u]); + return f.join(" "); + } + if (typeof r != "string") + return r; + var h = n.length; + if (h === 0) return r; + for (var g = "", v = 1 - o, x = -1, S = r && r.length || 0, R = 0; R < S; ) { + if (r.charCodeAt(R) === 37 && R + 1 < S) { + switch (x = x > -1 ? x : 0, r.charCodeAt(R + 1)) { + case 100: + // 'd' + case 102: + if (v >= h || n[v] == null) break; + x < R && (g += r.slice(x, R)), g += Number(n[v]), x = R + 2, R++; + break; + case 105: + if (v >= h || n[v] == null) break; + x < R && (g += r.slice(x, R)), g += Math.floor(Number(n[v])), x = R + 2, R++; + break; + case 79: + // 'O' + case 111: + // 'o' + case 106: + if (v >= h || n[v] === void 0) break; + x < R && (g += r.slice(x, R)); + var D = typeof n[v]; + if (D === "string") { + g += "'" + n[v] + "'", x = R + 2, R++; + break; + } + if (D === "function") { + g += n[v].name || "", x = R + 2, R++; + break; + } + g += s(n[v]), x = R + 2, R++; + break; + case 115: + if (v >= h) + break; + x < R && (g += r.slice(x, R)), g += String(n[v]), x = R + 2, R++; + break; + case 37: + x < R && (g += r.slice(x, R)), g += "%", x = R + 2, R++, v--; + break; + } + ++v; + } + ++R; + } + return x === -1 ? r : (x < S && (g += r.slice(x)), g); + } + return Xp; +} +var Zp, v2; +function KL() { + if (v2) return Zp; + v2 = 1; + const t = WL(); + Zp = i; + const e = $().console || {}, r = { + mapHttpRequest: S, + mapHttpResponse: S, + wrapRequestSerializer: R, + wrapResponseSerializer: R, + wrapErrorSerializer: R, + req: S, + res: S, + err: v + }; + function n(U, C) { + return Array.isArray(U) ? U.filter(function(J) { + return J !== "!stdSerializers.err"; + }) : U === !0 ? Object.keys(C) : !1; + } + function i(U) { + U = U || {}, U.browser = U.browser || {}; + const C = U.browser.transmit; + if (C && typeof C.send != "function") + throw Error("pino: transmit option must have a send function"); + const W = U.browser.write || e; + U.browser.write && (U.browser.asObject = !0); + const J = U.serializers || {}, ne = n(U.browser.serialize, J); + let K = U.browser.serialize; + Array.isArray(U.browser.serialize) && U.browser.serialize.indexOf("!stdSerializers.err") > -1 && (K = !1); + const E = ["error", "fatal", "warn", "info", "debug", "trace"]; + typeof W == "function" && (W.error = W.fatal = W.warn = W.info = W.debug = W.trace = W), U.enabled === !1 && (U.level = "silent"); + const b = U.level || "info", l = Object.create(W); + l.log || (l.log = D), Object.defineProperty(l, "levelVal", { + get: m + }), Object.defineProperty(l, "level", { + get: w, + set: P + }); + const p = { + transmit: C, + serialize: ne, + asObject: U.browser.asObject, + levels: E, + timestamp: x(U) + }; + l.levels = i.levels, l.level = b, l.setMaxListeners = l.getMaxListeners = l.emit = l.addListener = l.on = l.prependListener = l.once = l.prependOnceListener = l.removeListener = l.removeAllListeners = l.listeners = l.listenerCount = l.eventNames = l.write = l.flush = D, l.serializers = J, l._serialize = ne, l._stdErrSerialize = K, l.child = _, C && (l._logEvent = g()); + function m() { + return this.level === "silent" ? 1 / 0 : this.levels.values[this.level]; + } + function w() { + return this._level; + } + function P(y) { + if (y !== "silent" && !this.levels.values[y]) + throw Error("unknown level " + y); + this._level = y, s(p, l, "error", "log"), s(p, l, "fatal", "error"), s(p, l, "warn", "error"), s(p, l, "info", "log"), s(p, l, "debug", "log"), s(p, l, "trace", "log"); + } + function _(y, M) { + if (!y) + throw new Error("missing bindings for child Pino"); + M = M || {}, ne && y.serializers && (M.serializers = y.serializers); + const I = M.serializers; + if (ne && I) { + var q = Object.assign({}, J, I), ce = U.browser.serialize === !0 ? Object.keys(q) : ne; + delete y.serializers, f([y], ce, q, this._stdErrSerialize); + } + function L(oe) { + this._childLevel = (oe._childLevel | 0) + 1, this.error = u(oe, y, "error"), this.fatal = u(oe, y, "fatal"), this.warn = u(oe, y, "warn"), this.info = u(oe, y, "info"), this.debug = u(oe, y, "debug"), this.trace = u(oe, y, "trace"), q && (this.serializers = q, this._serialize = ce), C && (this._logEvent = g( + [].concat(oe._logEvent.bindings, y) + )); + } + return L.prototype = this, new L(this); + } + return l; + } + i.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" + } + }, i.stdSerializers = r, i.stdTimeFunctions = Object.assign({}, { nullTime: k, epochTime: N, unixTime: z, isoTime: B }); + function s(U, C, W, J) { + const ne = Object.getPrototypeOf(C); + C[W] = C.levelVal > C.levels.values[W] ? D : ne[W] ? ne[W] : e[W] || e[J] || D, o(U, C, W); + } + function o(U, C, W) { + !U.transmit && C[W] === D || (C[W] = /* @__PURE__ */ (function(J) { + return function() { + const K = U.timestamp(), E = new Array(arguments.length), b = Object.getPrototypeOf && Object.getPrototypeOf(this) === e ? e : this; + for (var l = 0; l < E.length; l++) E[l] = arguments[l]; + if (U.serialize && !U.asObject && f(E, this._serialize, this.serializers, this._stdErrSerialize), U.asObject ? J.call(b, a(this, W, E, K)) : J.apply(b, E), U.transmit) { + const p = U.transmit.level || C.level, m = i.levels.values[p], w = i.levels.values[W]; + if (w < m) return; + h(this, { + ts: K, + methodLevel: W, + methodValue: w, + transmitValue: i.levels.values[U.transmit.level || C.level], + send: U.transmit.send, + val: C.levelVal + }, E); + } + }; + })(C[W])); + } + function a(U, C, W, J) { + U._serialize && f(W, U._serialize, U.serializers, U._stdErrSerialize); + const ne = W.slice(); + let K = ne[0]; + const E = {}; + J && (E.time = J), E.level = i.levels.values[C]; + let b = (U._childLevel | 0) + 1; + if (b < 1 && (b = 1), K !== null && typeof K == "object") { + for (; b-- && typeof ne[0] == "object"; ) + Object.assign(E, ne.shift()); + K = ne.length ? t(ne.shift(), ne) : void 0; + } else typeof K == "string" && (K = t(ne.shift(), ne)); + return K !== void 0 && (E.msg = K), E; + } + function f(U, C, W, J) { + for (const ne in U) + if (J && U[ne] instanceof Error) + U[ne] = i.stdSerializers.err(U[ne]); + else if (typeof U[ne] == "object" && !Array.isArray(U[ne])) + for (const K in U[ne]) + C && C.indexOf(K) > -1 && K in W && (U[ne][K] = W[K](U[ne][K])); + } + function u(U, C, W) { + return function() { + const J = new Array(1 + arguments.length); + J[0] = C; + for (var ne = 1; ne < J.length; ne++) + J[ne] = arguments[ne - 1]; + return U[W].apply(this, J); + }; + } + function h(U, C, W) { + const J = C.send, ne = C.ts, K = C.methodLevel, E = C.methodValue, b = C.val, l = U._logEvent.bindings; + f( + W, + U._serialize || Object.keys(U.serializers), + U.serializers, + U._stdErrSerialize === void 0 ? !0 : U._stdErrSerialize + ), U._logEvent.ts = ne, U._logEvent.messages = W.filter(function(p) { + return l.indexOf(p) === -1; + }), U._logEvent.level.label = K, U._logEvent.level.value = E, J(K, U._logEvent, b), U._logEvent = g(l); + } + function g(U) { + return { + ts: 0, + messages: [], + bindings: U || [], + level: { label: "", value: 0 } + }; + } + function v(U) { + const C = { + type: U.constructor.name, + msg: U.message, + stack: U.stack + }; + for (const W in U) + C[W] === void 0 && (C[W] = U[W]); + return C; + } + function x(U) { + return typeof U.timestamp == "function" ? U.timestamp : U.timestamp === !1 ? k : N; + } + function S() { + return {}; + } + function R(U) { + return U; + } + function D() { + } + function k() { + return !1; + } + function N() { + return Date.now(); + } + function z() { + return Math.round(Date.now() / 1e3); + } + function B() { + return new Date(Date.now()).toISOString(); + } + function $() { + function U(C) { + return typeof C < "u" && C; + } + try { + return typeof globalThis < "u" || Object.defineProperty(Object.prototype, "globalThis", { + get: function() { + return delete Object.prototype.globalThis, this.globalThis = this; + }, + configurable: !0 + }), globalThis; + } catch { + return U(self) || U(window) || U(this) || {}; + } + } + return Zp; +} +var yc = KL(); +const Xf = /* @__PURE__ */ Hi(yc), VL = { level: "info" }, Zf = "custom_context", h1 = 1e3 * 1024; +let GL = 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; + } +}, b2 = class { + constructor(e) { + this.head = null, this.tail = null, this.lengthInNodes = 0, this.maxSizeInBytes = e, this.sizeInBytes = 0; + } + append(e) { + const r = new GL(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; + const e = this.head; + this.head = this.head.next, this.head || (this.tail = null), this.lengthInNodes--, this.sizeInBytes -= e.size; + } + toArray() { + const e = []; + let 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 }; + const r = e.value; + return e = e.next, { done: !1, value: r }; + } }; + } +}, J4 = class { + constructor(e, r = h1) { + this.level = e ?? "error", this.levelValue = yc.levels.values[this.level], this.MAX_LOG_SIZE_IN_BYTES = r, this.logs = new b2(this.MAX_LOG_SIZE_IN_BYTES); + } + forwardToConsole(e, r) { + r === yc.levels.values.error ? console.error(e) : r === yc.levels.values.warn ? console.warn(e) : r === yc.levels.values.debug ? console.debug(e) : r === yc.levels.values.trace ? console.trace(e) : console.log(e); + } + appendToLogs(e) { + this.logs.append(ho({ timestamp: (/* @__PURE__ */ new Date()).toISOString(), log: e })); + const 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 b2(this.MAX_LOG_SIZE_IN_BYTES); + } + getLogArray() { + return Array.from(this.logs); + } + logsToBlob(e) { + const r = this.getLogArray(); + return r.push(ho({ extraMetadata: e })), new Blob(r, { type: "application/json" }); + } +}, YL = class { + constructor(e, r = h1) { + this.baseChunkLogger = new J4(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) { + const r = URL.createObjectURL(this.logsToBlob(e)), n = document.createElement("a"); + n.href = r, n.download = `walletconnect-logs-${(/* @__PURE__ */ new Date()).toISOString()}.txt`, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(r); + } +}, JL = class { + constructor(e, r = h1) { + this.baseChunkLogger = new J4(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); + } +}; +var XL = Object.defineProperty, ZL = Object.defineProperties, QL = Object.getOwnPropertyDescriptors, y2 = Object.getOwnPropertySymbols, ek = Object.prototype.hasOwnProperty, tk = Object.prototype.propertyIsEnumerable, w2 = (t, e, r) => e in t ? XL(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, dd = (t, e) => { + for (var r in e || (e = {})) ek.call(e, r) && w2(t, r, e[r]); + if (y2) for (var r of y2(e)) tk.call(e, r) && w2(t, r, e[r]); + return t; +}, pd = (t, e) => ZL(t, QL(e)); +function Vd(t) { + return pd(dd({}, t), { level: t?.level || VL.level }); +} +function rk(t, e = Zf) { + return t[e] || ""; +} +function nk(t, e, r = Zf) { + return t[r] = e, t; +} +function mi(t, e = Zf) { + let r = ""; + return typeof t.bindings > "u" ? r = rk(t, e) : r = t.bindings().context || "", r; +} +function ik(t, e, r = Zf) { + const n = mi(t, r); + return n.trim() ? `${n}/${e}` : e; +} +function ri(t, e, r = Zf) { + const n = ik(t, e, r), i = t.child({ context: n }); + return nk(i, n, r); +} +function sk(t) { + var e, r; + const n = new YL((e = t.opts) == null ? void 0 : e.level, t.maxSizeInBytes); + return { logger: Xf(pd(dd({}, t.opts), { level: "trace", browser: pd(dd({}, (r = t.opts) == null ? void 0 : r.browser), { write: (i) => n.write(i) }) })), chunkLoggerController: n }; +} +function ok(t) { + var e; + const r = new JL((e = t.opts) == null ? void 0 : e.level, t.maxSizeInBytes); + return { logger: Xf(pd(dd({}, t.opts), { level: "trace" }), r), chunkLoggerController: r }; +} +function ak(t) { + return typeof t.loggerOverride < "u" && typeof t.loggerOverride != "string" ? { logger: t.loggerOverride, chunkLoggerController: null } : typeof window < "u" ? sk(t) : ok(t); +} +let ck = class extends za { + constructor(e) { + super(), this.opts = e, this.protocol = "wc", this.version = 2; + } +}, uk = class extends za { + constructor(e, r) { + super(), this.core = e, this.logger = r, this.records = /* @__PURE__ */ new Map(); + } +}, fk = class { + constructor(e, r) { + this.logger = e, this.core = r; + } +}, lk = class extends za { + constructor(e, r) { + super(), this.relayer = e, this.logger = r; + } +}, hk = class extends za { + constructor(e) { + super(); + } +}, dk = class { + constructor(e, r, n, i) { + this.core = e, this.logger = r, this.name = n; + } +}, pk = class extends za { + constructor(e, r) { + super(), this.relayer = e, this.logger = r; + } +}, gk = class extends za { + constructor(e, r) { + super(), this.core = e, this.logger = r; + } +}, mk = class { + constructor(e, r, n) { + this.core = e, this.logger = r, this.store = n; + } +}, vk = class { + constructor(e, r) { + this.projectId = e, this.logger = r; + } +}, bk = class { + constructor(e, r, n) { + this.core = e, this.logger = r, this.telemetryEnabled = n; + } +}, yk = class { + constructor(e) { + this.opts = e, this.protocol = "wc", this.version = 2; + } +}, wk = class { + constructor(e) { + this.client = e; + } +}; +var Qp = {}, eg = {}, Mu = {}, Iu = {}, x2; +function xk() { + if (x2) return Iu; + x2 = 1, Object.defineProperty(Iu, "__esModule", { value: !0 }), Iu.BrowserRandomSource = void 0; + const t = 65536; + class e { + constructor() { + this.isAvailable = !1, this.isInstantiated = !1; + const n = typeof self < "u" ? self.crypto || self.msCrypto : null; + n && n.getRandomValues !== void 0 && (this._crypto = n, this.isAvailable = !0, this.isInstantiated = !0); + } + randomBytes(n) { + if (!this.isAvailable || !this._crypto) + throw new Error("Browser random byte generator is not available."); + const i = new Uint8Array(n); + for (let s = 0; s < i.length; s += t) + this._crypto.getRandomValues(i.subarray(s, s + Math.min(i.length - s, t))); + return i; + } + } + return Iu.BrowserRandomSource = e, Iu; +} +function X4(t) { + throw new Error('Could not dynamically require "' + t + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} +var Cu = {}, bh = {}, _2; +function ls() { + if (_2) return bh; + _2 = 1, Object.defineProperty(bh, "__esModule", { value: !0 }); + function t(e) { + for (var r = 0; r < e.length; r++) + e[r] = 0; + return e; + } + return bh.wipe = t, bh; +} +const _k = {}, Ek = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + default: _k +}, Symbol.toStringTag, { value: "Module" })), Qf = /* @__PURE__ */ K5(Ek); +var E2; +function Sk() { + if (E2) return Cu; + E2 = 1, Object.defineProperty(Cu, "__esModule", { value: !0 }), Cu.NodeRandomSource = void 0; + const t = ls(); + class e { + constructor() { + if (this.isAvailable = !1, this.isInstantiated = !1, typeof X4 < "u") { + const n = Qf; + n && n.randomBytes && (this._crypto = n, this.isAvailable = !0, this.isInstantiated = !0); + } + } + randomBytes(n) { + if (!this.isAvailable || !this._crypto) + throw new Error("Node.js random byte generator is not available."); + let i = this._crypto.randomBytes(n); + if (i.length !== n) + throw new Error("NodeRandomSource: got fewer bytes than requested"); + const s = new Uint8Array(n); + for (let o = 0; o < s.length; o++) + s[o] = i[o]; + return (0, t.wipe)(i), s; + } + } + return Cu.NodeRandomSource = e, Cu; +} +var S2; +function Ak() { + if (S2) return Mu; + S2 = 1, Object.defineProperty(Mu, "__esModule", { value: !0 }), Mu.SystemRandomSource = void 0; + const t = xk(), e = Sk(); + class r { + constructor() { + if (this.isAvailable = !1, this.name = "", this._source = new t.BrowserRandomSource(), this._source.isAvailable) { + this.isAvailable = !0, this.name = "Browser"; + return; + } + if (this._source = new e.NodeRandomSource(), this._source.isAvailable) { + this.isAvailable = !0, this.name = "Node"; + return; + } + } + randomBytes(i) { + if (!this.isAvailable) + throw new Error("System random byte generator is not available."); + return this._source.randomBytes(i); + } + } + return Mu.SystemRandomSource = r, Mu; +} +var dr = {}, tg = {}, A2; +function Pk() { + return A2 || (A2 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }); + function e(a, f) { + var u = a >>> 16 & 65535, h = a & 65535, g = f >>> 16 & 65535, v = f & 65535; + return h * v + (u * v + h * g << 16 >>> 0) | 0; + } + t.mul = Math.imul || e; + function r(a, f) { + return a + f | 0; + } + t.add = r; + function n(a, f) { + return a - f | 0; + } + t.sub = n; + function i(a, f) { + return a << f | a >>> 32 - f; + } + t.rotl = i; + function s(a, f) { + return a << 32 - f | a >>> f; + } + t.rotr = s; + function o(a) { + return typeof a == "number" && isFinite(a) && Math.floor(a) === a; + } + t.isInteger = Number.isInteger || o, t.MAX_SAFE_INTEGER = 9007199254740991, t.isSafeInteger = function(a) { + return t.isInteger(a) && a >= -t.MAX_SAFE_INTEGER && a <= t.MAX_SAFE_INTEGER; + }; + })(tg)), tg; +} +var P2; +function el() { + if (P2) return dr; + P2 = 1, Object.defineProperty(dr, "__esModule", { value: !0 }); + var t = Pk(); + function e(p, m) { + return m === void 0 && (m = 0), (p[m + 0] << 8 | p[m + 1]) << 16 >> 16; + } + dr.readInt16BE = e; + function r(p, m) { + return m === void 0 && (m = 0), (p[m + 0] << 8 | p[m + 1]) >>> 0; + } + dr.readUint16BE = r; + function n(p, m) { + return m === void 0 && (m = 0), (p[m + 1] << 8 | p[m]) << 16 >> 16; + } + dr.readInt16LE = n; + function i(p, m) { + return m === void 0 && (m = 0), (p[m + 1] << 8 | p[m]) >>> 0; + } + dr.readUint16LE = i; + function s(p, m, w) { + return m === void 0 && (m = new Uint8Array(2)), w === void 0 && (w = 0), m[w + 0] = p >>> 8, m[w + 1] = p >>> 0, m; + } + dr.writeUint16BE = s, dr.writeInt16BE = s; + function o(p, m, w) { + return m === void 0 && (m = new Uint8Array(2)), w === void 0 && (w = 0), m[w + 0] = p >>> 0, m[w + 1] = p >>> 8, m; + } + dr.writeUint16LE = o, dr.writeInt16LE = o; + function a(p, m) { + return m === void 0 && (m = 0), p[m] << 24 | p[m + 1] << 16 | p[m + 2] << 8 | p[m + 3]; + } + dr.readInt32BE = a; + function f(p, m) { + return m === void 0 && (m = 0), (p[m] << 24 | p[m + 1] << 16 | p[m + 2] << 8 | p[m + 3]) >>> 0; + } + dr.readUint32BE = f; + function u(p, m) { + return m === void 0 && (m = 0), p[m + 3] << 24 | p[m + 2] << 16 | p[m + 1] << 8 | p[m]; + } + dr.readInt32LE = u; + function h(p, m) { + return m === void 0 && (m = 0), (p[m + 3] << 24 | p[m + 2] << 16 | p[m + 1] << 8 | p[m]) >>> 0; + } + dr.readUint32LE = h; + function g(p, m, w) { + return m === void 0 && (m = new Uint8Array(4)), w === void 0 && (w = 0), m[w + 0] = p >>> 24, m[w + 1] = p >>> 16, m[w + 2] = p >>> 8, m[w + 3] = p >>> 0, m; + } + dr.writeUint32BE = g, dr.writeInt32BE = g; + function v(p, m, w) { + return m === void 0 && (m = new Uint8Array(4)), w === void 0 && (w = 0), m[w + 0] = p >>> 0, m[w + 1] = p >>> 8, m[w + 2] = p >>> 16, m[w + 3] = p >>> 24, m; + } + dr.writeUint32LE = v, dr.writeInt32LE = v; + function x(p, m) { + m === void 0 && (m = 0); + var w = a(p, m), P = a(p, m + 4); + return w * 4294967296 + P - (P >> 31) * 4294967296; + } + dr.readInt64BE = x; + function S(p, m) { + m === void 0 && (m = 0); + var w = f(p, m), P = f(p, m + 4); + return w * 4294967296 + P; + } + dr.readUint64BE = S; + function R(p, m) { + m === void 0 && (m = 0); + var w = u(p, m), P = u(p, m + 4); + return P * 4294967296 + w - (w >> 31) * 4294967296; + } + dr.readInt64LE = R; + function D(p, m) { + m === void 0 && (m = 0); + var w = h(p, m), P = h(p, m + 4); + return P * 4294967296 + w; + } + dr.readUint64LE = D; + function k(p, m, w) { + return m === void 0 && (m = new Uint8Array(8)), w === void 0 && (w = 0), g(p / 4294967296 >>> 0, m, w), g(p >>> 0, m, w + 4), m; + } + dr.writeUint64BE = k, dr.writeInt64BE = k; + function N(p, m, w) { + return m === void 0 && (m = new Uint8Array(8)), w === void 0 && (w = 0), v(p >>> 0, m, w), v(p / 4294967296 >>> 0, m, w + 4), m; + } + dr.writeUint64LE = N, dr.writeInt64LE = N; + function z(p, m, w) { + if (w === void 0 && (w = 0), p % 8 !== 0) + throw new Error("readUintBE supports only bitLengths divisible by 8"); + if (p / 8 > m.length - w) + throw new Error("readUintBE: array is too short for the given bitLength"); + for (var P = 0, _ = 1, y = p / 8 + w - 1; y >= w; y--) + P += m[y] * _, _ *= 256; + return P; + } + dr.readUintBE = z; + function B(p, m, w) { + if (w === void 0 && (w = 0), p % 8 !== 0) + throw new Error("readUintLE supports only bitLengths divisible by 8"); + if (p / 8 > m.length - w) + throw new Error("readUintLE: array is too short for the given bitLength"); + for (var P = 0, _ = 1, y = w; y < w + p / 8; y++) + P += m[y] * _, _ *= 256; + return P; + } + dr.readUintLE = B; + function $(p, m, w, P) { + if (w === void 0 && (w = new Uint8Array(p / 8)), P === void 0 && (P = 0), p % 8 !== 0) + throw new Error("writeUintBE supports only bitLengths divisible by 8"); + if (!t.isSafeInteger(m)) + throw new Error("writeUintBE value must be an integer"); + for (var _ = 1, y = p / 8 + P - 1; y >= P; y--) + w[y] = m / _ & 255, _ *= 256; + return w; + } + dr.writeUintBE = $; + function U(p, m, w, P) { + if (w === void 0 && (w = new Uint8Array(p / 8)), P === void 0 && (P = 0), p % 8 !== 0) + throw new Error("writeUintLE supports only bitLengths divisible by 8"); + if (!t.isSafeInteger(m)) + throw new Error("writeUintLE value must be an integer"); + for (var _ = 1, y = P; y < P + p / 8; y++) + w[y] = m / _ & 255, _ *= 256; + return w; + } + dr.writeUintLE = U; + function C(p, m) { + m === void 0 && (m = 0); + var w = new DataView(p.buffer, p.byteOffset, p.byteLength); + return w.getFloat32(m); + } + dr.readFloat32BE = C; + function W(p, m) { + m === void 0 && (m = 0); + var w = new DataView(p.buffer, p.byteOffset, p.byteLength); + return w.getFloat32(m, !0); + } + dr.readFloat32LE = W; + function J(p, m) { + m === void 0 && (m = 0); + var w = new DataView(p.buffer, p.byteOffset, p.byteLength); + return w.getFloat64(m); + } + dr.readFloat64BE = J; + function ne(p, m) { + m === void 0 && (m = 0); + var w = new DataView(p.buffer, p.byteOffset, p.byteLength); + return w.getFloat64(m, !0); + } + dr.readFloat64LE = ne; + function K(p, m, w) { + m === void 0 && (m = new Uint8Array(4)), w === void 0 && (w = 0); + var P = new DataView(m.buffer, m.byteOffset, m.byteLength); + return P.setFloat32(w, p), m; + } + dr.writeFloat32BE = K; + function E(p, m, w) { + m === void 0 && (m = new Uint8Array(4)), w === void 0 && (w = 0); + var P = new DataView(m.buffer, m.byteOffset, m.byteLength); + return P.setFloat32(w, p, !0), m; + } + dr.writeFloat32LE = E; + function b(p, m, w) { + m === void 0 && (m = new Uint8Array(8)), w === void 0 && (w = 0); + var P = new DataView(m.buffer, m.byteOffset, m.byteLength); + return P.setFloat64(w, p), m; + } + dr.writeFloat64BE = b; + function l(p, m, w) { + m === void 0 && (m = new Uint8Array(8)), w === void 0 && (w = 0); + var P = new DataView(m.buffer, m.byteOffset, m.byteLength); + return P.setFloat64(w, p, !0), m; + } + return dr.writeFloat64LE = l, dr; +} +var M2; +function d1() { + return M2 || (M2 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }), t.randomStringForEntropy = t.randomString = t.randomUint32 = t.randomBytes = t.defaultRandomSource = void 0; + const e = Ak(), r = el(), n = ls(); + t.defaultRandomSource = new e.SystemRandomSource(); + function i(u, h = t.defaultRandomSource) { + return h.randomBytes(u); + } + t.randomBytes = i; + function s(u = t.defaultRandomSource) { + const h = i(4, u), g = (0, r.readUint32LE)(h); + return (0, n.wipe)(h), g; + } + t.randomUint32 = s; + const o = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + function a(u, h = o, g = t.defaultRandomSource) { + if (h.length < 2) + throw new Error("randomString charset is too short"); + if (h.length > 256) + throw new Error("randomString charset is too long"); + let v = ""; + const x = h.length, S = 256 - 256 % x; + for (; u > 0; ) { + const R = i(Math.ceil(u * 256 / S), g); + for (let D = 0; D < R.length && u > 0; D++) { + const k = R[D]; + k < S && (v += h.charAt(k % x), u--); + } + (0, n.wipe)(R); + } + return v; + } + t.randomString = a; + function f(u, h = o, g = t.defaultRandomSource) { + const v = Math.ceil(u / (Math.log(h.length) / Math.LN2)); + return a(v, h, g); + } + t.randomStringForEntropy = f; + })(eg)), eg; +} +var rg = {}, I2; +function Mk() { + return I2 || (I2 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }); + var e = el(), r = ls(); + t.DIGEST_LENGTH = 64, t.BLOCK_SIZE = 128; + var n = ( + /** @class */ + (function() { + function a() { + 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 a.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; + }, a.prototype.reset = function() { + return this._initState(), this._bufferLength = 0, this._bytesHashed = 0, this._finished = !1, this; + }, a.prototype.clean = function() { + r.wipe(this._buffer), r.wipe(this._tempHi), r.wipe(this._tempLo), this.reset(); + }, a.prototype.update = function(f, u) { + if (u === void 0 && (u = f.length), this._finished) + throw new Error("SHA512: can't update because hash was finished."); + var h = 0; + if (this._bytesHashed += u, this._bufferLength > 0) { + for (; this._bufferLength < t.BLOCK_SIZE && u > 0; ) + this._buffer[this._bufferLength++] = f[h++], u--; + this._bufferLength === this.blockSize && (s(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, this.blockSize), this._bufferLength = 0); + } + for (u >= this.blockSize && (h = s(this._tempHi, this._tempLo, this._stateHi, this._stateLo, f, h, u), u %= this.blockSize); u > 0; ) + this._buffer[this._bufferLength++] = f[h++], u--; + return this; + }, a.prototype.finish = function(f) { + if (!this._finished) { + var u = this._bytesHashed, h = this._bufferLength, g = u / 536870912 | 0, v = u << 3, x = u % 128 < 112 ? 128 : 256; + this._buffer[h] = 128; + for (var S = h + 1; S < x - 8; S++) + this._buffer[S] = 0; + e.writeUint32BE(g, this._buffer, x - 8), e.writeUint32BE(v, this._buffer, x - 4), s(this._tempHi, this._tempLo, this._stateHi, this._stateLo, this._buffer, 0, x), this._finished = !0; + } + for (var S = 0; S < this.digestLength / 8; S++) + e.writeUint32BE(this._stateHi[S], f, S * 8), e.writeUint32BE(this._stateLo[S], f, S * 8 + 4); + return this; + }, a.prototype.digest = function() { + var f = new Uint8Array(this.digestLength); + return this.finish(f), f; + }, a.prototype.saveState = function() { + if (this._finished) + throw new Error("SHA256: cannot save finished state"); + return { + stateHi: new Int32Array(this._stateHi), + stateLo: new Int32Array(this._stateLo), + buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, + bufferLength: this._bufferLength, + bytesHashed: this._bytesHashed + }; + }, a.prototype.restoreState = function(f) { + return this._stateHi.set(f.stateHi), this._stateLo.set(f.stateLo), this._bufferLength = f.bufferLength, f.buffer && this._buffer.set(f.buffer), this._bytesHashed = f.bytesHashed, this._finished = !1, this; + }, a.prototype.cleanSavedState = function(f) { + r.wipe(f.stateHi), r.wipe(f.stateLo), f.buffer && r.wipe(f.buffer), f.bufferLength = 0, f.bytesHashed = 0; + }, a; + })() + ); + t.SHA512 = n; + var i = 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 s(a, f, u, h, g, v, x) { + for (var S = u[0], R = u[1], D = u[2], k = u[3], N = u[4], z = u[5], B = u[6], $ = u[7], U = h[0], C = h[1], W = h[2], J = h[3], ne = h[4], K = h[5], E = h[6], b = h[7], l, p, m, w, P, _, y, M; x >= 128; ) { + for (var I = 0; I < 16; I++) { + var q = 8 * I + v; + a[I] = e.readUint32BE(g, q), f[I] = e.readUint32BE(g, q + 4); + } + for (var I = 0; I < 80; I++) { + var ce = S, L = R, oe = D, Q = k, X = N, ee = z, O = B, Z = $, re = U, he = C, ae = W, fe = J, be = ne, Ae = K, Te = E, Re = b; + if (l = $, p = b, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = (N >>> 14 | ne << 18) ^ (N >>> 18 | ne << 14) ^ (ne >>> 9 | N << 23), p = (ne >>> 14 | N << 18) ^ (ne >>> 18 | N << 14) ^ (N >>> 9 | ne << 23), P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, l = N & z ^ ~N & B, p = ne & K ^ ~ne & E, P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, l = i[I * 2], p = i[I * 2 + 1], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, l = a[I % 16], p = f[I % 16], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, m = y & 65535 | M << 16, w = P & 65535 | _ << 16, l = m, p = w, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = (S >>> 28 | U << 4) ^ (U >>> 2 | S << 30) ^ (U >>> 7 | S << 25), p = (U >>> 28 | S << 4) ^ (S >>> 2 | U << 30) ^ (S >>> 7 | U << 25), P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, l = S & R ^ S & D ^ R & D, p = U & C ^ U & W ^ C & W, P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, Z = y & 65535 | M << 16, Re = P & 65535 | _ << 16, l = Q, p = fe, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = m, p = w, P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, Q = y & 65535 | M << 16, fe = P & 65535 | _ << 16, R = ce, D = L, k = oe, N = Q, z = X, B = ee, $ = O, S = Z, C = re, W = he, J = ae, ne = fe, K = be, E = Ae, b = Te, U = Re, I % 16 === 15) + for (var q = 0; q < 16; q++) + l = a[q], p = f[q], P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = a[(q + 9) % 16], p = f[(q + 9) % 16], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, m = a[(q + 1) % 16], w = f[(q + 1) % 16], l = (m >>> 1 | w << 31) ^ (m >>> 8 | w << 24) ^ m >>> 7, p = (w >>> 1 | m << 31) ^ (w >>> 8 | m << 24) ^ (w >>> 7 | m << 25), P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, m = a[(q + 14) % 16], w = f[(q + 14) % 16], l = (m >>> 19 | w << 13) ^ (w >>> 29 | m << 3) ^ m >>> 6, p = (w >>> 19 | m << 13) ^ (m >>> 29 | w << 3) ^ (w >>> 6 | m << 26), P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, a[q] = y & 65535 | M << 16, f[q] = P & 65535 | _ << 16; + } + l = S, p = U, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = u[0], p = h[0], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, u[0] = S = y & 65535 | M << 16, h[0] = U = P & 65535 | _ << 16, l = R, p = C, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = u[1], p = h[1], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, u[1] = R = y & 65535 | M << 16, h[1] = C = P & 65535 | _ << 16, l = D, p = W, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = u[2], p = h[2], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, u[2] = D = y & 65535 | M << 16, h[2] = W = P & 65535 | _ << 16, l = k, p = J, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = u[3], p = h[3], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, u[3] = k = y & 65535 | M << 16, h[3] = J = P & 65535 | _ << 16, l = N, p = ne, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = u[4], p = h[4], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, u[4] = N = y & 65535 | M << 16, h[4] = ne = P & 65535 | _ << 16, l = z, p = K, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = u[5], p = h[5], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, u[5] = z = y & 65535 | M << 16, h[5] = K = P & 65535 | _ << 16, l = B, p = E, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = u[6], p = h[6], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, u[6] = B = y & 65535 | M << 16, h[6] = E = P & 65535 | _ << 16, l = $, p = b, P = p & 65535, _ = p >>> 16, y = l & 65535, M = l >>> 16, l = u[7], p = h[7], P += p & 65535, _ += p >>> 16, y += l & 65535, M += l >>> 16, _ += P >>> 16, y += _ >>> 16, M += y >>> 16, u[7] = $ = y & 65535 | M << 16, h[7] = b = P & 65535 | _ << 16, v += 128, x -= 128; + } + return v; + } + function o(a) { + var f = new n(); + f.update(a); + var u = f.digest(); + return f.clean(), u; + } + t.hash = o; + })(rg)), rg; +} +var C2; +function Ik() { + return C2 || (C2 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }), t.convertSecretKeyToX25519 = t.convertPublicKeyToX25519 = t.verify = t.sign = t.extractPublicKeyFromSecretKey = t.generateKeyPair = t.generateKeyPairFromSeed = t.SEED_LENGTH = t.SECRET_KEY_LENGTH = t.PUBLIC_KEY_LENGTH = t.SIGNATURE_LENGTH = void 0; + const e = d1(), r = Mk(), n = ls(); + t.SIGNATURE_LENGTH = 64, t.PUBLIC_KEY_LENGTH = 32, t.SECRET_KEY_LENGTH = 64, t.SEED_LENGTH = 32; + function i(Q) { + const X = new Float64Array(16); + if (Q) + for (let ee = 0; ee < Q.length; ee++) + X[ee] = Q[ee]; + return X; + } + const s = new Uint8Array(32); + s[0] = 9; + const o = i(), a = i([1]), f = i([ + 30883, + 4953, + 19914, + 30187, + 55467, + 16705, + 2637, + 112, + 59544, + 30585, + 16505, + 36039, + 65139, + 11119, + 27886, + 20995 + ]), u = i([ + 61785, + 9906, + 39828, + 60374, + 45398, + 33411, + 5274, + 224, + 53552, + 61171, + 33010, + 6542, + 64743, + 22239, + 55772, + 9222 + ]), h = i([ + 54554, + 36645, + 11616, + 51542, + 42930, + 38181, + 51040, + 26924, + 56412, + 64982, + 57905, + 49316, + 21502, + 52590, + 14035, + 8553 + ]), g = i([ + 26200, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214, + 26214 + ]), v = i([ + 41136, + 18958, + 6951, + 50414, + 58488, + 44335, + 6150, + 12099, + 55207, + 15867, + 153, + 11085, + 57099, + 20417, + 9344, + 11139 + ]); + function x(Q, X) { + for (let ee = 0; ee < 16; ee++) + Q[ee] = X[ee] | 0; + } + function S(Q) { + let X = 1; + for (let ee = 0; ee < 16; ee++) { + let O = Q[ee] + X + 65535; + X = Math.floor(O / 65536), Q[ee] = O - X * 65536; + } + Q[0] += X - 1 + 37 * (X - 1); + } + function R(Q, X, ee) { + const O = ~(ee - 1); + for (let Z = 0; Z < 16; Z++) { + const re = O & (Q[Z] ^ X[Z]); + Q[Z] ^= re, X[Z] ^= re; + } + } + function D(Q, X) { + const ee = i(), O = i(); + for (let Z = 0; Z < 16; Z++) + O[Z] = X[Z]; + S(O), S(O), S(O); + for (let Z = 0; Z < 2; Z++) { + ee[0] = O[0] - 65517; + for (let he = 1; he < 15; he++) + ee[he] = O[he] - 65535 - (ee[he - 1] >> 16 & 1), ee[he - 1] &= 65535; + ee[15] = O[15] - 32767 - (ee[14] >> 16 & 1); + const re = ee[15] >> 16 & 1; + ee[14] &= 65535, R(O, ee, 1 - re); + } + for (let Z = 0; Z < 16; Z++) + Q[2 * Z] = O[Z] & 255, Q[2 * Z + 1] = O[Z] >> 8; + } + function k(Q, X) { + let ee = 0; + for (let O = 0; O < 32; O++) + ee |= Q[O] ^ X[O]; + return (1 & ee - 1 >>> 8) - 1; + } + function N(Q, X) { + const ee = new Uint8Array(32), O = new Uint8Array(32); + return D(ee, Q), D(O, X), k(ee, O); + } + function z(Q) { + const X = new Uint8Array(32); + return D(X, Q), X[0] & 1; + } + function B(Q, X) { + for (let ee = 0; ee < 16; ee++) + Q[ee] = X[2 * ee] + (X[2 * ee + 1] << 8); + Q[15] &= 32767; + } + function $(Q, X, ee) { + for (let O = 0; O < 16; O++) + Q[O] = X[O] + ee[O]; + } + function U(Q, X, ee) { + for (let O = 0; O < 16; O++) + Q[O] = X[O] - ee[O]; + } + function C(Q, X, ee) { + let O, Z, re = 0, he = 0, ae = 0, fe = 0, be = 0, Ae = 0, Te = 0, Re = 0, $e = 0, Me = 0, Oe = 0, ze = 0, De = 0, je = 0, Ue = 0, _e = 0, Ze = 0, ot = 0, ke = 0, rt = 0, nt = 0, Ge = 0, ht = 0, lt = 0, ct = 0, qt = 0, Gt = 0, Et = 0, Yt = 0, tr = 0, Tt = 0, kt = ee[0], It = ee[1], dt = ee[2], Dt = ee[3], Nt = ee[4], mt = ee[5], Bt = ee[6], Ft = ee[7], et = ee[8], $t = ee[9], H = ee[10], V = ee[11], Y = ee[12], T = ee[13], F = ee[14], ie = ee[15]; + O = X[0], re += O * kt, he += O * It, ae += O * dt, fe += O * Dt, be += O * Nt, Ae += O * mt, Te += O * Bt, Re += O * Ft, $e += O * et, Me += O * $t, Oe += O * H, ze += O * V, De += O * Y, je += O * T, Ue += O * F, _e += O * ie, O = X[1], he += O * kt, ae += O * It, fe += O * dt, be += O * Dt, Ae += O * Nt, Te += O * mt, Re += O * Bt, $e += O * Ft, Me += O * et, Oe += O * $t, ze += O * H, De += O * V, je += O * Y, Ue += O * T, _e += O * F, Ze += O * ie, O = X[2], ae += O * kt, fe += O * It, be += O * dt, Ae += O * Dt, Te += O * Nt, Re += O * mt, $e += O * Bt, Me += O * Ft, Oe += O * et, ze += O * $t, De += O * H, je += O * V, Ue += O * Y, _e += O * T, Ze += O * F, ot += O * ie, O = X[3], fe += O * kt, be += O * It, Ae += O * dt, Te += O * Dt, Re += O * Nt, $e += O * mt, Me += O * Bt, Oe += O * Ft, ze += O * et, De += O * $t, je += O * H, Ue += O * V, _e += O * Y, Ze += O * T, ot += O * F, ke += O * ie, O = X[4], be += O * kt, Ae += O * It, Te += O * dt, Re += O * Dt, $e += O * Nt, Me += O * mt, Oe += O * Bt, ze += O * Ft, De += O * et, je += O * $t, Ue += O * H, _e += O * V, Ze += O * Y, ot += O * T, ke += O * F, rt += O * ie, O = X[5], Ae += O * kt, Te += O * It, Re += O * dt, $e += O * Dt, Me += O * Nt, Oe += O * mt, ze += O * Bt, De += O * Ft, je += O * et, Ue += O * $t, _e += O * H, Ze += O * V, ot += O * Y, ke += O * T, rt += O * F, nt += O * ie, O = X[6], Te += O * kt, Re += O * It, $e += O * dt, Me += O * Dt, Oe += O * Nt, ze += O * mt, De += O * Bt, je += O * Ft, Ue += O * et, _e += O * $t, Ze += O * H, ot += O * V, ke += O * Y, rt += O * T, nt += O * F, Ge += O * ie, O = X[7], Re += O * kt, $e += O * It, Me += O * dt, Oe += O * Dt, ze += O * Nt, De += O * mt, je += O * Bt, Ue += O * Ft, _e += O * et, Ze += O * $t, ot += O * H, ke += O * V, rt += O * Y, nt += O * T, Ge += O * F, ht += O * ie, O = X[8], $e += O * kt, Me += O * It, Oe += O * dt, ze += O * Dt, De += O * Nt, je += O * mt, Ue += O * Bt, _e += O * Ft, Ze += O * et, ot += O * $t, ke += O * H, rt += O * V, nt += O * Y, Ge += O * T, ht += O * F, lt += O * ie, O = X[9], Me += O * kt, Oe += O * It, ze += O * dt, De += O * Dt, je += O * Nt, Ue += O * mt, _e += O * Bt, Ze += O * Ft, ot += O * et, ke += O * $t, rt += O * H, nt += O * V, Ge += O * Y, ht += O * T, lt += O * F, ct += O * ie, O = X[10], Oe += O * kt, ze += O * It, De += O * dt, je += O * Dt, Ue += O * Nt, _e += O * mt, Ze += O * Bt, ot += O * Ft, ke += O * et, rt += O * $t, nt += O * H, Ge += O * V, ht += O * Y, lt += O * T, ct += O * F, qt += O * ie, O = X[11], ze += O * kt, De += O * It, je += O * dt, Ue += O * Dt, _e += O * Nt, Ze += O * mt, ot += O * Bt, ke += O * Ft, rt += O * et, nt += O * $t, Ge += O * H, ht += O * V, lt += O * Y, ct += O * T, qt += O * F, Gt += O * ie, O = X[12], De += O * kt, je += O * It, Ue += O * dt, _e += O * Dt, Ze += O * Nt, ot += O * mt, ke += O * Bt, rt += O * Ft, nt += O * et, Ge += O * $t, ht += O * H, lt += O * V, ct += O * Y, qt += O * T, Gt += O * F, Et += O * ie, O = X[13], je += O * kt, Ue += O * It, _e += O * dt, Ze += O * Dt, ot += O * Nt, ke += O * mt, rt += O * Bt, nt += O * Ft, Ge += O * et, ht += O * $t, lt += O * H, ct += O * V, qt += O * Y, Gt += O * T, Et += O * F, Yt += O * ie, O = X[14], Ue += O * kt, _e += O * It, Ze += O * dt, ot += O * Dt, ke += O * Nt, rt += O * mt, nt += O * Bt, Ge += O * Ft, ht += O * et, lt += O * $t, ct += O * H, qt += O * V, Gt += O * Y, Et += O * T, Yt += O * F, tr += O * ie, O = X[15], _e += O * kt, Ze += O * It, ot += O * dt, ke += O * Dt, rt += O * Nt, nt += O * mt, Ge += O * Bt, ht += O * Ft, lt += O * et, ct += O * $t, qt += O * H, Gt += O * V, Et += O * Y, Yt += O * T, tr += O * F, Tt += O * ie, re += 38 * Ze, he += 38 * ot, ae += 38 * ke, fe += 38 * rt, be += 38 * nt, Ae += 38 * Ge, Te += 38 * ht, Re += 38 * lt, $e += 38 * ct, Me += 38 * qt, Oe += 38 * Gt, ze += 38 * Et, De += 38 * Yt, je += 38 * tr, Ue += 38 * Tt, Z = 1, O = re + Z + 65535, Z = Math.floor(O / 65536), re = O - Z * 65536, O = he + Z + 65535, Z = Math.floor(O / 65536), he = O - Z * 65536, O = ae + Z + 65535, Z = Math.floor(O / 65536), ae = O - Z * 65536, O = fe + Z + 65535, Z = Math.floor(O / 65536), fe = O - Z * 65536, O = be + Z + 65535, Z = Math.floor(O / 65536), be = O - Z * 65536, O = Ae + Z + 65535, Z = Math.floor(O / 65536), Ae = O - Z * 65536, O = Te + Z + 65535, Z = Math.floor(O / 65536), Te = O - Z * 65536, O = Re + Z + 65535, Z = Math.floor(O / 65536), Re = O - Z * 65536, O = $e + Z + 65535, Z = Math.floor(O / 65536), $e = O - Z * 65536, O = Me + Z + 65535, Z = Math.floor(O / 65536), Me = O - Z * 65536, O = Oe + Z + 65535, Z = Math.floor(O / 65536), Oe = O - Z * 65536, O = ze + Z + 65535, Z = Math.floor(O / 65536), ze = O - Z * 65536, O = De + Z + 65535, Z = Math.floor(O / 65536), De = O - Z * 65536, O = je + Z + 65535, Z = Math.floor(O / 65536), je = O - Z * 65536, O = Ue + Z + 65535, Z = Math.floor(O / 65536), Ue = O - Z * 65536, O = _e + Z + 65535, Z = Math.floor(O / 65536), _e = O - Z * 65536, re += Z - 1 + 37 * (Z - 1), Z = 1, O = re + Z + 65535, Z = Math.floor(O / 65536), re = O - Z * 65536, O = he + Z + 65535, Z = Math.floor(O / 65536), he = O - Z * 65536, O = ae + Z + 65535, Z = Math.floor(O / 65536), ae = O - Z * 65536, O = fe + Z + 65535, Z = Math.floor(O / 65536), fe = O - Z * 65536, O = be + Z + 65535, Z = Math.floor(O / 65536), be = O - Z * 65536, O = Ae + Z + 65535, Z = Math.floor(O / 65536), Ae = O - Z * 65536, O = Te + Z + 65535, Z = Math.floor(O / 65536), Te = O - Z * 65536, O = Re + Z + 65535, Z = Math.floor(O / 65536), Re = O - Z * 65536, O = $e + Z + 65535, Z = Math.floor(O / 65536), $e = O - Z * 65536, O = Me + Z + 65535, Z = Math.floor(O / 65536), Me = O - Z * 65536, O = Oe + Z + 65535, Z = Math.floor(O / 65536), Oe = O - Z * 65536, O = ze + Z + 65535, Z = Math.floor(O / 65536), ze = O - Z * 65536, O = De + Z + 65535, Z = Math.floor(O / 65536), De = O - Z * 65536, O = je + Z + 65535, Z = Math.floor(O / 65536), je = O - Z * 65536, O = Ue + Z + 65535, Z = Math.floor(O / 65536), Ue = O - Z * 65536, O = _e + Z + 65535, Z = Math.floor(O / 65536), _e = O - Z * 65536, re += Z - 1 + 37 * (Z - 1), Q[0] = re, Q[1] = he, Q[2] = ae, Q[3] = fe, Q[4] = be, Q[5] = Ae, Q[6] = Te, Q[7] = Re, Q[8] = $e, Q[9] = Me, Q[10] = Oe, Q[11] = ze, Q[12] = De, Q[13] = je, Q[14] = Ue, Q[15] = _e; + } + function W(Q, X) { + C(Q, X, X); + } + function J(Q, X) { + const ee = i(); + let O; + for (O = 0; O < 16; O++) + ee[O] = X[O]; + for (O = 253; O >= 0; O--) + W(ee, ee), O !== 2 && O !== 4 && C(ee, ee, X); + for (O = 0; O < 16; O++) + Q[O] = ee[O]; + } + function ne(Q, X) { + const ee = i(); + let O; + for (O = 0; O < 16; O++) + ee[O] = X[O]; + for (O = 250; O >= 0; O--) + W(ee, ee), O !== 1 && C(ee, ee, X); + for (O = 0; O < 16; O++) + Q[O] = ee[O]; + } + function K(Q, X) { + const ee = i(), O = i(), Z = i(), re = i(), he = i(), ae = i(), fe = i(), be = i(), Ae = i(); + U(ee, Q[1], Q[0]), U(Ae, X[1], X[0]), C(ee, ee, Ae), $(O, Q[0], Q[1]), $(Ae, X[0], X[1]), C(O, O, Ae), C(Z, Q[3], X[3]), C(Z, Z, u), C(re, Q[2], X[2]), $(re, re, re), U(he, O, ee), U(ae, re, Z), $(fe, re, Z), $(be, O, ee), C(Q[0], he, ae), C(Q[1], be, fe), C(Q[2], fe, ae), C(Q[3], he, be); + } + function E(Q, X, ee) { + for (let O = 0; O < 4; O++) + R(Q[O], X[O], ee); + } + function b(Q, X) { + const ee = i(), O = i(), Z = i(); + J(Z, X[2]), C(ee, X[0], Z), C(O, X[1], Z), D(Q, O), Q[31] ^= z(ee) << 7; + } + function l(Q, X, ee) { + x(Q[0], o), x(Q[1], a), x(Q[2], a), x(Q[3], o); + for (let O = 255; O >= 0; --O) { + const Z = ee[O / 8 | 0] >> (O & 7) & 1; + E(Q, X, Z), K(X, Q), K(Q, Q), E(Q, X, Z); + } + } + function p(Q, X) { + const ee = [i(), i(), i(), i()]; + x(ee[0], h), x(ee[1], g), x(ee[2], a), C(ee[3], h, g), l(Q, ee, X); + } + function m(Q) { + if (Q.length !== t.SEED_LENGTH) + throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`); + const X = (0, r.hash)(Q); + X[0] &= 248, X[31] &= 127, X[31] |= 64; + const ee = new Uint8Array(32), O = [i(), i(), i(), i()]; + p(O, X), b(ee, O); + const Z = new Uint8Array(64); + return Z.set(Q), Z.set(ee, 32), { + publicKey: ee, + secretKey: Z + }; + } + t.generateKeyPairFromSeed = m; + function w(Q) { + const X = (0, e.randomBytes)(32, Q), ee = m(X); + return (0, n.wipe)(X), ee; + } + t.generateKeyPair = w; + function P(Q) { + if (Q.length !== t.SECRET_KEY_LENGTH) + throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`); + return new Uint8Array(Q.subarray(32)); + } + t.extractPublicKeyFromSecretKey = P; + const _ = 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 y(Q, X) { + let ee, O, Z, re; + for (O = 63; O >= 32; --O) { + for (ee = 0, Z = O - 32, re = O - 12; Z < re; ++Z) + X[Z] += ee - 16 * X[O] * _[Z - (O - 32)], ee = Math.floor((X[Z] + 128) / 256), X[Z] -= ee * 256; + X[Z] += ee, X[O] = 0; + } + for (ee = 0, Z = 0; Z < 32; Z++) + X[Z] += ee - (X[31] >> 4) * _[Z], ee = X[Z] >> 8, X[Z] &= 255; + for (Z = 0; Z < 32; Z++) + X[Z] -= ee * _[Z]; + for (O = 0; O < 32; O++) + X[O + 1] += X[O] >> 8, Q[O] = X[O] & 255; + } + function M(Q) { + const X = new Float64Array(64); + for (let ee = 0; ee < 64; ee++) + X[ee] = Q[ee]; + for (let ee = 0; ee < 64; ee++) + Q[ee] = 0; + y(Q, X); + } + function I(Q, X) { + const ee = new Float64Array(64), O = [i(), i(), i(), i()], Z = (0, r.hash)(Q.subarray(0, 32)); + Z[0] &= 248, Z[31] &= 127, Z[31] |= 64; + const re = new Uint8Array(64); + re.set(Z.subarray(32), 32); + const he = new r.SHA512(); + he.update(re.subarray(32)), he.update(X); + const ae = he.digest(); + he.clean(), M(ae), p(O, ae), b(re, O), he.reset(), he.update(re.subarray(0, 32)), he.update(Q.subarray(32)), he.update(X); + const fe = he.digest(); + M(fe); + for (let be = 0; be < 32; be++) + ee[be] = ae[be]; + for (let be = 0; be < 32; be++) + for (let Ae = 0; Ae < 32; Ae++) + ee[be + Ae] += fe[be] * Z[Ae]; + return y(re.subarray(32), ee), re; + } + t.sign = I; + function q(Q, X) { + const ee = i(), O = i(), Z = i(), re = i(), he = i(), ae = i(), fe = i(); + return x(Q[2], a), B(Q[1], X), W(Z, Q[1]), C(re, Z, f), U(Z, Z, Q[2]), $(re, Q[2], re), W(he, re), W(ae, he), C(fe, ae, he), C(ee, fe, Z), C(ee, ee, re), ne(ee, ee), C(ee, ee, Z), C(ee, ee, re), C(ee, ee, re), C(Q[0], ee, re), W(O, Q[0]), C(O, O, re), N(O, Z) && C(Q[0], Q[0], v), W(O, Q[0]), C(O, O, re), N(O, Z) ? -1 : (z(Q[0]) === X[31] >> 7 && U(Q[0], o, Q[0]), C(Q[3], Q[0], Q[1]), 0); + } + function ce(Q, X, ee) { + const O = new Uint8Array(32), Z = [i(), i(), i(), i()], re = [i(), i(), i(), i()]; + if (ee.length !== t.SIGNATURE_LENGTH) + throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`); + if (q(re, Q)) + return !1; + const he = new r.SHA512(); + he.update(ee.subarray(0, 32)), he.update(Q), he.update(X); + const ae = he.digest(); + return M(ae), l(Z, re, ae), p(re, ee.subarray(32)), K(Z, re), b(O, Z), !k(ee, O); + } + t.verify = ce; + function L(Q) { + let X = [i(), i(), i(), i()]; + if (q(X, Q)) + throw new Error("Ed25519: invalid public key"); + let ee = i(), O = i(), Z = X[1]; + $(ee, a, Z), U(O, a, Z), J(O, O), C(ee, ee, O); + let re = new Uint8Array(32); + return D(re, ee), re; + } + t.convertPublicKeyToX25519 = L; + function oe(Q) { + const X = (0, r.hash)(Q.subarray(0, 32)); + X[0] &= 248, X[31] &= 127, X[31] |= 64; + const ee = new Uint8Array(X.subarray(0, 32)); + return (0, n.wipe)(X), ee; + } + t.convertSecretKeyToX25519 = oe; + })(Qp)), Qp; +} +var Z4 = Ik(), tl = d1(); +const Ck = "EdDSA", Rk = "JWT", gd = ".", Gd = "base64url", Q4 = "utf8", e8 = "utf8", Tk = ":", Dk = "did", Ok = "key", R2 = "base58btc", Nk = "z", Lk = "K36", kk = 32; +function t8(t = 0) { + return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? globalThis.Buffer.allocUnsafe(t) : new Uint8Array(t); +} +function $h(t, e) { + e || (e = t.reduce((i, s) => i + s.length, 0)); + const r = t8(e); + let n = 0; + for (const i of t) + r.set(i, n), n += i.length; + return r; +} +function $k(t, e) { + if (t.length >= 255) + throw new TypeError("Alphabet too long"); + for (var r = new Uint8Array(256), n = 0; n < r.length; n++) + r[n] = 255; + for (var i = 0; i < t.length; i++) { + var s = t.charAt(i), o = s.charCodeAt(0); + if (r[o] !== 255) + throw new TypeError(s + " is ambiguous"); + r[o] = i; + } + var a = t.length, f = t.charAt(0), u = Math.log(a) / Math.log(256), h = Math.log(256) / Math.log(a); + function g(S) { + if (S instanceof Uint8Array || (ArrayBuffer.isView(S) ? S = new Uint8Array(S.buffer, S.byteOffset, S.byteLength) : Array.isArray(S) && (S = Uint8Array.from(S))), !(S instanceof Uint8Array)) + throw new TypeError("Expected Uint8Array"); + if (S.length === 0) + return ""; + for (var R = 0, D = 0, k = 0, N = S.length; k !== N && S[k] === 0; ) + k++, R++; + for (var z = (N - k) * h + 1 >>> 0, B = new Uint8Array(z); k !== N; ) { + for (var $ = S[k], U = 0, C = z - 1; ($ !== 0 || U < D) && C !== -1; C--, U++) + $ += 256 * B[C] >>> 0, B[C] = $ % a >>> 0, $ = $ / a >>> 0; + if ($ !== 0) + throw new Error("Non-zero carry"); + D = U, k++; + } + for (var W = z - D; W !== z && B[W] === 0; ) + W++; + for (var J = f.repeat(R); W < z; ++W) + J += t.charAt(B[W]); + return J; + } + function v(S) { + if (typeof S != "string") + throw new TypeError("Expected String"); + if (S.length === 0) + return new Uint8Array(); + var R = 0; + if (S[R] !== " ") { + for (var D = 0, k = 0; S[R] === f; ) + D++, R++; + for (var N = (S.length - R) * u + 1 >>> 0, z = new Uint8Array(N); S[R]; ) { + var B = r[S.charCodeAt(R)]; + if (B === 255) + return; + for (var $ = 0, U = N - 1; (B !== 0 || $ < k) && U !== -1; U--, $++) + B += a * z[U] >>> 0, z[U] = B % 256 >>> 0, B = B / 256 >>> 0; + if (B !== 0) + throw new Error("Non-zero carry"); + k = $, R++; + } + if (S[R] !== " ") { + for (var C = N - k; C !== N && z[C] === 0; ) + C++; + for (var W = new Uint8Array(D + (N - C)), J = D; C !== N; ) + W[J++] = z[C++]; + return W; + } + } + } + function x(S) { + var R = v(S); + if (R) + return R; + throw new Error(`Non-${e} character`); + } + return { + encode: g, + decodeUnsafe: v, + decode: x + }; +} +var Bk = $k, Fk = Bk; +const jk = (t) => { + if (t instanceof Uint8Array && t.constructor.name === "Uint8Array") + return t; + if (t instanceof ArrayBuffer) + return new Uint8Array(t); + if (ArrayBuffer.isView(t)) + return new Uint8Array(t.buffer, t.byteOffset, t.byteLength); + throw new Error("Unknown type, must be binary type"); +}, Uk = (t) => new TextEncoder().encode(t), qk = (t) => new TextDecoder().decode(t); +class zk { + constructor(e, r, n) { + this.name = e, this.prefix = r, this.baseEncode = n; + } + encode(e) { + if (e instanceof Uint8Array) + return `${this.prefix}${this.baseEncode(e)}`; + throw Error("Unknown type, must be binary type"); + } +} +class Hk { + constructor(e, r, n) { + 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 = n; + } + 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 r8(this, e); + } +} +class Wk { + constructor(e) { + this.decoders = e; + } + or(e) { + return r8(this, e); + } + decode(e) { + const r = e[0], n = this.decoders[r]; + if (n) + return n.decode(e); + throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + } +} +const r8 = (t, e) => new Wk({ + ...t.decoders || { [t.prefix]: t }, + ...e.decoders || { [e.prefix]: e } +}); +class Kk { + constructor(e, r, n, i) { + this.name = e, this.prefix = r, this.baseEncode = n, this.baseDecode = i, this.encoder = new zk(e, r, n), this.decoder = new Hk(e, r, i); + } + encode(e) { + return this.encoder.encode(e); + } + decode(e) { + return this.decoder.decode(e); + } +} +const Yd = ({ name: t, prefix: e, encode: r, decode: n }) => new Kk(t, e, r, n), rl = ({ prefix: t, name: e, alphabet: r }) => { + const { encode: n, decode: i } = Fk(r, e); + return Yd({ + prefix: t, + name: e, + encode: n, + decode: (s) => jk(i(s)) + }); +}, Vk = (t, e, r, n) => { + const i = {}; + for (let h = 0; h < e.length; ++h) + i[e[h]] = h; + let s = t.length; + for (; t[s - 1] === "="; ) + --s; + const o = new Uint8Array(s * r / 8 | 0); + let a = 0, f = 0, u = 0; + for (let h = 0; h < s; ++h) { + const g = i[t[h]]; + if (g === void 0) + throw new SyntaxError(`Non-${n} character`); + f = f << r | g, a += r, a >= 8 && (a -= 8, o[u++] = 255 & f >> a); + } + if (a >= r || 255 & f << 8 - a) + throw new SyntaxError("Unexpected end of data"); + return o; +}, Gk = (t, e, r) => { + const n = e[e.length - 1] === "=", i = (1 << r) - 1; + let s = "", o = 0, a = 0; + for (let f = 0; f < t.length; ++f) + for (a = a << 8 | t[f], o += 8; o > r; ) + o -= r, s += e[i & a >> o]; + if (o && (s += e[i & a << r - o]), n) + for (; s.length * r & 7; ) + s += "="; + return s; +}, $n = ({ name: t, prefix: e, bitsPerChar: r, alphabet: n }) => Yd({ + prefix: e, + name: t, + encode(i) { + return Gk(i, n, r); + }, + decode(i) { + return Vk(i, n, r, t); + } +}), Yk = Yd({ + prefix: "\0", + name: "identity", + encode: (t) => qk(t), + decode: (t) => Uk(t) +}), Jk = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + identity: Yk +}, Symbol.toStringTag, { value: "Module" })), Xk = $n({ + prefix: "0", + name: "base2", + alphabet: "01", + bitsPerChar: 1 +}), Zk = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base2: Xk +}, Symbol.toStringTag, { value: "Module" })), Qk = $n({ + prefix: "7", + name: "base8", + alphabet: "01234567", + bitsPerChar: 3 +}), e$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base8: Qk +}, Symbol.toStringTag, { value: "Module" })), t$ = rl({ + prefix: "9", + name: "base10", + alphabet: "0123456789" +}), r$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base10: t$ +}, Symbol.toStringTag, { value: "Module" })), n$ = $n({ + prefix: "f", + name: "base16", + alphabet: "0123456789abcdef", + bitsPerChar: 4 +}), i$ = $n({ + prefix: "F", + name: "base16upper", + alphabet: "0123456789ABCDEF", + bitsPerChar: 4 +}), s$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base16: n$, + base16upper: i$ +}, Symbol.toStringTag, { value: "Module" })), o$ = $n({ + prefix: "b", + name: "base32", + alphabet: "abcdefghijklmnopqrstuvwxyz234567", + bitsPerChar: 5 +}), a$ = $n({ + prefix: "B", + name: "base32upper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", + bitsPerChar: 5 +}), c$ = $n({ + prefix: "c", + name: "base32pad", + alphabet: "abcdefghijklmnopqrstuvwxyz234567=", + bitsPerChar: 5 +}), u$ = $n({ + prefix: "C", + name: "base32padupper", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", + bitsPerChar: 5 +}), f$ = $n({ + prefix: "v", + name: "base32hex", + alphabet: "0123456789abcdefghijklmnopqrstuv", + bitsPerChar: 5 +}), l$ = $n({ + prefix: "V", + name: "base32hexupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", + bitsPerChar: 5 +}), h$ = $n({ + prefix: "t", + name: "base32hexpad", + alphabet: "0123456789abcdefghijklmnopqrstuv=", + bitsPerChar: 5 +}), d$ = $n({ + prefix: "T", + name: "base32hexpadupper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", + bitsPerChar: 5 +}), p$ = $n({ + prefix: "h", + name: "base32z", + alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", + bitsPerChar: 5 +}), g$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base32: o$, + base32hex: f$, + base32hexpad: h$, + base32hexpadupper: d$, + base32hexupper: l$, + base32pad: c$, + base32padupper: u$, + base32upper: a$, + base32z: p$ +}, Symbol.toStringTag, { value: "Module" })), m$ = rl({ + prefix: "k", + name: "base36", + alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" +}), v$ = rl({ + prefix: "K", + name: "base36upper", + alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" +}), b$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base36: m$, + base36upper: v$ +}, Symbol.toStringTag, { value: "Module" })), y$ = rl({ + name: "base58btc", + prefix: "z", + alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" +}), w$ = rl({ + name: "base58flickr", + prefix: "Z", + alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" +}), x$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base58btc: y$, + base58flickr: w$ +}, Symbol.toStringTag, { value: "Module" })), _$ = $n({ + prefix: "m", + name: "base64", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", + bitsPerChar: 6 +}), E$ = $n({ + prefix: "M", + name: "base64pad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + bitsPerChar: 6 +}), S$ = $n({ + prefix: "u", + name: "base64url", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", + bitsPerChar: 6 +}), A$ = $n({ + prefix: "U", + name: "base64urlpad", + alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", + bitsPerChar: 6 +}), P$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base64: _$, + base64pad: E$, + base64url: S$, + base64urlpad: A$ +}, Symbol.toStringTag, { value: "Module" })), n8 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), M$ = n8.reduce((t, e, r) => (t[r] = e, t), []), I$ = n8.reduce((t, e, r) => (t[e.codePointAt(0)] = r, t), []); +function C$(t) { + return t.reduce((e, r) => (e += M$[r], e), ""); +} +function R$(t) { + const e = []; + for (const r of t) { + const n = I$[r.codePointAt(0)]; + if (n === void 0) + throw new Error(`Non-base256emoji character: ${r}`); + e.push(n); + } + return new Uint8Array(e); +} +const T$ = Yd({ + prefix: "🚀", + name: "base256emoji", + encode: C$, + decode: R$ +}), D$ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + base256emoji: T$ +}, Symbol.toStringTag, { value: "Module" })); +new TextEncoder(); +new TextDecoder(); +const T2 = { + ...Jk, + ...Zk, + ...e$, + ...r$, + ...s$, + ...g$, + ...b$, + ...x$, + ...P$, + ...D$ +}; +function i8(t, e, r, n) { + return { + name: t, + prefix: e, + encoder: { + name: t, + prefix: e, + encode: r + }, + decoder: { decode: n } + }; +} +const D2 = i8("utf8", "u", (t) => "u" + new TextDecoder("utf8").decode(t), (t) => new TextEncoder().encode(t.substring(1))), ng = i8("ascii", "a", (t) => { + let e = "a"; + for (let r = 0; r < t.length; r++) + e += String.fromCharCode(t[r]); + return e; +}, (t) => { + t = t.substring(1); + const e = t8(t.length); + for (let r = 0; r < t.length; r++) + e[r] = t.charCodeAt(r); + return e; +}), s8 = { + utf8: D2, + "utf-8": D2, + hex: T2.base16, + latin1: ng, + ascii: ng, + binary: ng, + ...T2 +}; +function Tn(t, e = "utf8") { + const r = s8[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(t.buffer, t.byteOffset, t.byteLength).toString("utf8") : r.encoder.encode(t).substring(1); +} +function Cn(t, e = "utf8") { + const r = s8[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(t, "utf8") : r.decoder.decode(`${r.prefix}${t}`); +} +function O2(t) { + return Na(Tn(Cn(t, Gd), Q4)); +} +function md(t) { + return Tn(Cn(ho(t), Q4), Gd); +} +function o8(t) { + const e = Cn(Lk, R2), r = Nk + Tn($h([e, t]), R2); + return [Dk, Ok, r].join(Tk); +} +function O$(t) { + return Tn(t, Gd); +} +function N$(t) { + return Cn(t, Gd); +} +function L$(t) { + return Cn([md(t.header), md(t.payload)].join(gd), e8); +} +function k$(t) { + return [ + md(t.header), + md(t.payload), + O$(t.signature) + ].join(gd); +} +function ev(t) { + const e = t.split(gd), r = O2(e[0]), n = O2(e[1]), i = N$(e[2]), s = Cn(e.slice(0, 2).join(gd), e8); + return { header: r, payload: n, signature: i, data: s }; +} +function N2(t = tl.randomBytes(kk)) { + return Z4.generateKeyPairFromSeed(t); +} +async function $$(t, e, r, n, i = bt.fromMiliseconds(Date.now())) { + const s = { alg: Ck, typ: Rk }, o = o8(n.publicKey), a = i + r, f = { iss: o, sub: t, aud: e, iat: i, exp: a }, u = L$({ header: s, payload: f }), h = Z4.sign(n.secretKey, u); + return k$({ header: s, payload: f, signature: h }); +} +var L2 = function(t, e, r) { + if (r || arguments.length === 2) for (var n = 0, i = e.length, s; n < i; n++) + (s || !(n in e)) && (s || (s = Array.prototype.slice.call(e, 0, n)), s[n] = e[n]); + return t.concat(s || Array.prototype.slice.call(e)); +}, B$ = ( + /** @class */ + /* @__PURE__ */ (function() { + function t(e, r, n) { + this.name = e, this.version = r, this.os = n, this.type = "browser"; + } + return t; + })() +), F$ = ( + /** @class */ + /* @__PURE__ */ (function() { + function t(e) { + this.version = e, this.type = "node", this.name = "node", this.os = process.platform; + } + return t; + })() +), j$ = ( + /** @class */ + /* @__PURE__ */ (function() { + function t(e, r, n, i) { + this.name = e, this.version = r, this.os = n, this.bot = i, this.type = "bot-device"; + } + return t; + })() +), U$ = ( + /** @class */ + /* @__PURE__ */ (function() { + function t() { + this.type = "bot", this.bot = !0, this.name = "bot", this.version = null, this.os = null; + } + return t; + })() +), q$ = ( + /** @class */ + /* @__PURE__ */ (function() { + function t() { + this.type = "react-native", this.name = "react-native", this.version = null, this.os = null; + } + return t; + })() +), z$ = /alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/, H$ = /(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/, k2 = 3, W$ = [ + ["aol", /AOLShield\/([0-9\._]+)/], + ["edge", /Edge\/([0-9\._]+)/], + ["edge-ios", /EdgiOS\/([0-9\._]+)/], + ["yandexbrowser", /YaBrowser\/([0-9\._]+)/], + ["kakaotalk", /KAKAOTALK\s([0-9\.]+)/], + ["samsung", /SamsungBrowser\/([0-9\.]+)/], + ["silk", /\bSilk\/([0-9._-]+)\b/], + ["miui", /MiuiBrowser\/([0-9\.]+)$/], + ["beaker", /BeakerBrowser\/([0-9\.]+)/], + ["edge-chromium", /EdgA?\/([0-9\.]+)/], + [ + "chromium-webview", + /(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/ + ], + ["chrome", /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/], + ["phantomjs", /PhantomJS\/([0-9\.]+)(:?\s|$)/], + ["crios", /CriOS\/([0-9\.]+)(:?\s|$)/], + ["firefox", /Firefox\/([0-9\.]+)(?:\s|$)/], + ["fxios", /FxiOS\/([0-9\.]+)/], + ["opera-mini", /Opera Mini.*Version\/([0-9\.]+)/], + ["opera", /Opera\/([0-9\.]+)(?:\s|$)/], + ["opera", /OPR\/([0-9\.]+)(:?\s|$)/], + ["pie", /^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/], + ["pie", /^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/], + ["netfront", /^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/], + ["ie", /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/], + ["ie", /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/], + ["ie", /MSIE\s(7\.0)/], + ["bb10", /BB10;\sTouch.*Version\/([0-9\.]+)/], + ["android", /Android\s([0-9\.]+)/], + ["ios", /Version\/([0-9\._]+).*Mobile.*Safari.*/], + ["safari", /Version\/([0-9\._]+).*Safari/], + ["facebook", /FB[AS]V\/([0-9\.]+)/], + ["instagram", /Instagram\s([0-9\.]+)/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Mobile/], + ["ios-webview", /AppleWebKit\/([0-9\.]+).*Gecko\)$/], + ["curl", /^curl\/([0-9\.]+)$/], + ["searchbot", z$] +], $2 = [ + ["iOS", /iP(hone|od|ad)/], + ["Android OS", /Android/], + ["BlackBerry OS", /BlackBerry|BB10/], + ["Windows Mobile", /IEMobile/], + ["Amazon OS", /Kindle/], + ["Windows 3.11", /Win16/], + ["Windows 95", /(Windows 95)|(Win95)|(Windows_95)/], + ["Windows 98", /(Windows 98)|(Win98)/], + ["Windows 2000", /(Windows NT 5.0)|(Windows 2000)/], + ["Windows XP", /(Windows NT 5.1)|(Windows XP)/], + ["Windows Server 2003", /(Windows NT 5.2)/], + ["Windows Vista", /(Windows NT 6.0)/], + ["Windows 7", /(Windows NT 6.1)/], + ["Windows 8", /(Windows NT 6.2)/], + ["Windows 8.1", /(Windows NT 6.3)/], + ["Windows 10", /(Windows NT 10.0)/], + ["Windows ME", /Windows ME/], + ["Windows CE", /Windows CE|WinCE|Microsoft Pocket Internet Explorer/], + ["Open BSD", /OpenBSD/], + ["Sun OS", /SunOS/], + ["Chrome OS", /CrOS/], + ["Linux", /(Linux)|(X11)/], + ["Mac OS", /(Mac_PowerPC)|(Macintosh)/], + ["QNX", /QNX/], + ["BeOS", /BeOS/], + ["OS/2", /OS\/2/] +]; +function K$(t) { + return typeof document > "u" && typeof navigator < "u" && navigator.product === "ReactNative" ? new q$() : typeof navigator < "u" ? G$(navigator.userAgent) : J$(); +} +function V$(t) { + return t !== "" && W$.reduce(function(e, r) { + var n = r[0], i = r[1]; + if (e) + return e; + var s = i.exec(t); + return !!s && [n, s]; + }, !1); +} +function G$(t) { + var e = V$(t); + if (!e) + return null; + var r = e[0], n = e[1]; + if (r === "searchbot") + return new U$(); + var i = n[1] && n[1].split(".").join("_").split("_").slice(0, 3); + i ? i.length < k2 && (i = L2(L2([], i, !0), X$(k2 - i.length), !0)) : i = []; + var s = i.join("."), o = Y$(t), a = H$.exec(t); + return a && a[1] ? new j$(r, s, o, a[1]) : new B$(r, s, o); +} +function Y$(t) { + for (var e = 0, r = $2.length; e < r; e++) { + var n = $2[e], i = n[0], s = n[1], o = s.exec(t); + if (o) + return i; + } + return null; +} +function J$() { + var t = typeof process < "u" && process.version; + return t ? new F$(process.version.slice(1)) : null; +} +function X$(t) { + for (var e = [], r = 0; r < t; r++) + e.push("0"); + return e; +} +var zr = {}, B2; +function a8() { + if (B2) return zr; + B2 = 1, Object.defineProperty(zr, "__esModule", { value: !0 }), zr.getLocalStorage = zr.getLocalStorageOrThrow = zr.getCrypto = zr.getCryptoOrThrow = zr.getLocation = zr.getLocationOrThrow = zr.getNavigator = zr.getNavigatorOrThrow = zr.getDocument = zr.getDocumentOrThrow = zr.getFromWindowOrThrow = zr.getFromWindow = void 0; + function t(v) { + let x; + return typeof window < "u" && typeof window[v] < "u" && (x = window[v]), x; + } + zr.getFromWindow = t; + function e(v) { + const x = t(v); + if (!x) + throw new Error(`${v} is not defined in Window`); + return x; + } + zr.getFromWindowOrThrow = e; + function r() { + return e("document"); + } + zr.getDocumentOrThrow = r; + function n() { + return t("document"); + } + zr.getDocument = n; + function i() { + return e("navigator"); + } + zr.getNavigatorOrThrow = i; + function s() { + return t("navigator"); + } + zr.getNavigator = s; + function o() { + return e("location"); + } + zr.getLocationOrThrow = o; + function a() { + return t("location"); + } + zr.getLocation = a; + function f() { + return e("crypto"); + } + zr.getCryptoOrThrow = f; + function u() { + return t("crypto"); + } + zr.getCrypto = u; + function h() { + return e("localStorage"); + } + zr.getLocalStorageOrThrow = h; + function g() { + return t("localStorage"); + } + return zr.getLocalStorage = g, zr; +} +var La = a8(), Ru = {}, F2; +function Z$() { + if (F2) return Ru; + F2 = 1, Object.defineProperty(Ru, "__esModule", { value: !0 }), Ru.getWindowMetadata = void 0; + const t = a8(); + function e() { + let r, n; + try { + r = t.getDocumentOrThrow(), n = t.getLocationOrThrow(); + } catch { + return null; + } + function i() { + const x = r.getElementsByTagName("link"), S = []; + for (let R = 0; R < x.length; R++) { + const D = x[R], k = D.getAttribute("rel"); + if (k && k.toLowerCase().indexOf("icon") > -1) { + const N = D.getAttribute("href"); + if (N) + if (N.toLowerCase().indexOf("https:") === -1 && N.toLowerCase().indexOf("http:") === -1 && N.indexOf("//") !== 0) { + let z = n.protocol + "//" + n.host; + if (N.indexOf("/") === 0) + z += N; + else { + const B = n.pathname.split("/"); + B.pop(); + const $ = B.join("/"); + z += $ + "/" + N; + } + S.push(z); + } else if (N.indexOf("//") === 0) { + const z = n.protocol + N; + S.push(z); + } else + S.push(N); + } + } + return S; + } + function s(...x) { + const S = r.getElementsByTagName("meta"); + for (let R = 0; R < S.length; R++) { + const D = S[R], k = ["itemprop", "property", "name"].map((N) => D.getAttribute(N)).filter((N) => N ? x.includes(N) : !1); + if (k.length && k) { + const N = D.getAttribute("content"); + if (N) + return N; + } + } + return ""; + } + function o() { + let x = s("name", "og:site_name", "og:title", "twitter:title"); + return x || (x = r.title), x; + } + function a() { + return s("description", "og:description", "twitter:description", "keywords"); + } + const f = o(), u = a(), h = n.origin, g = i(); + return { + description: u, + url: h, + icons: g, + name: f + }; + } + return Ru.getWindowMetadata = e, Ru; +} +var Q$ = Z$(), ig = {}, sg, j2; +function eB() { + return j2 || (j2 = 1, sg = (t) => encodeURIComponent(t).replace(/[!'()*]/g, (e) => `%${e.charCodeAt(0).toString(16).toUpperCase()}`)), sg; +} +var og, U2; +function tB() { + if (U2) return og; + U2 = 1; + var t = "%[a-f0-9]{2}", e = new RegExp("(" + t + ")|([^%]+?)", "gi"), r = new RegExp("(" + t + ")+", "gi"); + function n(o, a) { + try { + return [decodeURIComponent(o.join(""))]; + } catch { + } + if (o.length === 1) + return o; + a = a || 1; + var f = o.slice(0, a), u = o.slice(a); + return Array.prototype.concat.call([], n(f), n(u)); + } + function i(o) { + try { + return decodeURIComponent(o); + } catch { + for (var a = o.match(e) || [], f = 1; f < a.length; f++) + o = n(a, f).join(""), a = o.match(e) || []; + return o; + } + } + function s(o) { + for (var a = { + "%FE%FF": "��", + "%FF%FE": "��" + }, f = r.exec(o); f; ) { + try { + a[f[0]] = decodeURIComponent(f[0]); + } catch { + var u = i(f[0]); + u !== f[0] && (a[f[0]] = u); + } + f = r.exec(o); + } + a["%C2"] = "�"; + for (var h = Object.keys(a), g = 0; g < h.length; g++) { + var v = h[g]; + o = o.replace(new RegExp(v, "g"), a[v]); + } + return o; + } + return og = function(o) { + if (typeof o != "string") + throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof o + "`"); + try { + return o = o.replace(/\+/g, " "), decodeURIComponent(o); + } catch { + return s(o); + } + }, og; +} +var ag, q2; +function rB() { + return q2 || (q2 = 1, ag = (t, e) => { + if (!(typeof t == "string" && typeof e == "string")) + throw new TypeError("Expected the arguments to be of type `string`"); + if (e === "") + return [t]; + const r = t.indexOf(e); + return r === -1 ? [t] : [ + t.slice(0, r), + t.slice(r + e.length) + ]; + }), ag; +} +var cg, z2; +function nB() { + return z2 || (z2 = 1, cg = function(t, e) { + for (var r = {}, n = Object.keys(t), i = Array.isArray(e), s = 0; s < n.length; s++) { + var o = n[s], a = t[o]; + (i ? e.indexOf(o) !== -1 : e(o, a, t)) && (r[o] = a); + } + return r; + }), cg; +} +var H2; +function iB() { + return H2 || (H2 = 1, (function(t) { + const e = eB(), r = tB(), n = rB(), i = nB(), s = (N) => N == null, o = Symbol("encodeFragmentIdentifier"); + function a(N) { + switch (N.arrayFormat) { + case "index": + return (z) => (B, $) => { + const U = B.length; + return $ === void 0 || N.skipNull && $ === null || N.skipEmptyString && $ === "" ? B : $ === null ? [...B, [h(z, N), "[", U, "]"].join("")] : [ + ...B, + [h(z, N), "[", h(U, N), "]=", h($, N)].join("") + ]; + }; + case "bracket": + return (z) => (B, $) => $ === void 0 || N.skipNull && $ === null || N.skipEmptyString && $ === "" ? B : $ === null ? [...B, [h(z, N), "[]"].join("")] : [...B, [h(z, N), "[]=", h($, N)].join("")]; + case "colon-list-separator": + return (z) => (B, $) => $ === void 0 || N.skipNull && $ === null || N.skipEmptyString && $ === "" ? B : $ === null ? [...B, [h(z, N), ":list="].join("")] : [...B, [h(z, N), ":list=", h($, N)].join("")]; + case "comma": + case "separator": + case "bracket-separator": { + const z = N.arrayFormat === "bracket-separator" ? "[]=" : "="; + return (B) => ($, U) => U === void 0 || N.skipNull && U === null || N.skipEmptyString && U === "" ? $ : (U = U === null ? "" : U, $.length === 0 ? [[h(B, N), z, h(U, N)].join("")] : [[$, h(U, N)].join(N.arrayFormatSeparator)]); + } + default: + return (z) => (B, $) => $ === void 0 || N.skipNull && $ === null || N.skipEmptyString && $ === "" ? B : $ === null ? [...B, h(z, N)] : [...B, [h(z, N), "=", h($, N)].join("")]; + } + } + function f(N) { + let z; + switch (N.arrayFormat) { + case "index": + return (B, $, U) => { + if (z = /\[(\d*)\]$/.exec(B), B = B.replace(/\[\d*\]$/, ""), !z) { + U[B] = $; + return; + } + U[B] === void 0 && (U[B] = {}), U[B][z[1]] = $; + }; + case "bracket": + return (B, $, U) => { + if (z = /(\[\])$/.exec(B), B = B.replace(/\[\]$/, ""), !z) { + U[B] = $; + return; + } + if (U[B] === void 0) { + U[B] = [$]; + return; + } + U[B] = [].concat(U[B], $); + }; + case "colon-list-separator": + return (B, $, U) => { + if (z = /(:list)$/.exec(B), B = B.replace(/:list$/, ""), !z) { + U[B] = $; + return; + } + if (U[B] === void 0) { + U[B] = [$]; + return; + } + U[B] = [].concat(U[B], $); + }; + case "comma": + case "separator": + return (B, $, U) => { + const C = typeof $ == "string" && $.includes(N.arrayFormatSeparator), W = typeof $ == "string" && !C && g($, N).includes(N.arrayFormatSeparator); + $ = W ? g($, N) : $; + const J = C || W ? $.split(N.arrayFormatSeparator).map((ne) => g(ne, N)) : $ === null ? $ : g($, N); + U[B] = J; + }; + case "bracket-separator": + return (B, $, U) => { + const C = /(\[\])$/.test(B); + if (B = B.replace(/\[\]$/, ""), !C) { + U[B] = $ && g($, N); + return; + } + const W = $ === null ? [] : $.split(N.arrayFormatSeparator).map((J) => g(J, N)); + if (U[B] === void 0) { + U[B] = W; + return; + } + U[B] = [].concat(U[B], W); + }; + default: + return (B, $, U) => { + if (U[B] === void 0) { + U[B] = $; + return; + } + U[B] = [].concat(U[B], $); + }; + } + } + function u(N) { + if (typeof N != "string" || N.length !== 1) + throw new TypeError("arrayFormatSeparator must be single character string"); + } + function h(N, z) { + return z.encode ? z.strict ? e(N) : encodeURIComponent(N) : N; + } + function g(N, z) { + return z.decode ? r(N) : N; + } + function v(N) { + return Array.isArray(N) ? N.sort() : typeof N == "object" ? v(Object.keys(N)).sort((z, B) => Number(z) - Number(B)).map((z) => N[z]) : N; + } + function x(N) { + const z = N.indexOf("#"); + return z !== -1 && (N = N.slice(0, z)), N; + } + function S(N) { + let z = ""; + const B = N.indexOf("#"); + return B !== -1 && (z = N.slice(B)), z; + } + function R(N) { + N = x(N); + const z = N.indexOf("?"); + return z === -1 ? "" : N.slice(z + 1); + } + function D(N, z) { + return z.parseNumbers && !Number.isNaN(Number(N)) && typeof N == "string" && N.trim() !== "" ? N = Number(N) : z.parseBooleans && N !== null && (N.toLowerCase() === "true" || N.toLowerCase() === "false") && (N = N.toLowerCase() === "true"), N; + } + function k(N, z) { + z = Object.assign({ + decode: !0, + sort: !0, + arrayFormat: "none", + arrayFormatSeparator: ",", + parseNumbers: !1, + parseBooleans: !1 + }, z), u(z.arrayFormatSeparator); + const B = f(z), $ = /* @__PURE__ */ Object.create(null); + if (typeof N != "string" || (N = N.trim().replace(/^[?#&]/, ""), !N)) + return $; + for (const U of N.split("&")) { + if (U === "") + continue; + let [C, W] = n(z.decode ? U.replace(/\+/g, " ") : U, "="); + W = W === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(z.arrayFormat) ? W : g(W, z), B(g(C, z), W, $); + } + for (const U of Object.keys($)) { + const C = $[U]; + if (typeof C == "object" && C !== null) + for (const W of Object.keys(C)) + C[W] = D(C[W], z); + else + $[U] = D(C, z); + } + return z.sort === !1 ? $ : (z.sort === !0 ? Object.keys($).sort() : Object.keys($).sort(z.sort)).reduce((U, C) => { + const W = $[C]; + return W && typeof W == "object" && !Array.isArray(W) ? U[C] = v(W) : U[C] = W, U; + }, /* @__PURE__ */ Object.create(null)); + } + t.extract = R, t.parse = k, t.stringify = (N, z) => { + if (!N) + return ""; + z = Object.assign({ + encode: !0, + strict: !0, + arrayFormat: "none", + arrayFormatSeparator: "," + }, z), u(z.arrayFormatSeparator); + const B = (W) => z.skipNull && s(N[W]) || z.skipEmptyString && N[W] === "", $ = a(z), U = {}; + for (const W of Object.keys(N)) + B(W) || (U[W] = N[W]); + const C = Object.keys(U); + return z.sort !== !1 && C.sort(z.sort), C.map((W) => { + const J = N[W]; + return J === void 0 ? "" : J === null ? h(W, z) : Array.isArray(J) ? J.length === 0 && z.arrayFormat === "bracket-separator" ? h(W, z) + "[]" : J.reduce($(W), []).join("&") : h(W, z) + "=" + h(J, z); + }).filter((W) => W.length > 0).join("&"); + }, t.parseUrl = (N, z) => { + z = Object.assign({ + decode: !0 + }, z); + const [B, $] = n(N, "#"); + return Object.assign( + { + url: B.split("?")[0] || "", + query: k(R(N), z) + }, + z && z.parseFragmentIdentifier && $ ? { fragmentIdentifier: g($, z) } : {} + ); + }, t.stringifyUrl = (N, z) => { + z = Object.assign({ + encode: !0, + strict: !0, + [o]: !0 + }, z); + const B = x(N.url).split("?")[0] || "", $ = t.extract(N.url), U = t.parse($, { sort: !1 }), C = Object.assign(U, N.query); + let W = t.stringify(C, z); + W && (W = `?${W}`); + let J = S(N.url); + return N.fragmentIdentifier && (J = `#${z[o] ? h(N.fragmentIdentifier, z) : N.fragmentIdentifier}`), `${B}${W}${J}`; + }, t.pick = (N, z, B) => { + B = Object.assign({ + parseFragmentIdentifier: !0, + [o]: !1 + }, B); + const { url: $, query: U, fragmentIdentifier: C } = t.parseUrl(N, B); + return t.stringifyUrl({ + url: $, + query: i(U, z), + fragmentIdentifier: C + }, B); + }, t.exclude = (N, z, B) => { + const $ = Array.isArray(z) ? (U) => !z.includes(U) : (U, C) => !z(U, C); + return t.pick(N, $, B); + }; + })(ig)), ig; +} +var vd = iB(), ug = { exports: {} }; +/** + * [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 + */ +var W2; +function sB() { + return W2 || (W2 = 1, (function(t) { + (function() { + var e = "input is invalid type", r = "finalize already called", n = typeof window == "object", i = n ? window : {}; + i.JS_SHA3_NO_WINDOW && (n = !1); + var s = !n && typeof self == "object", o = !i.JS_SHA3_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node; + o ? i = Zn : s && (i = self); + var a = !i.JS_SHA3_NO_COMMON_JS && !0 && t.exports, f = !i.JS_SHA3_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", u = "0123456789abcdef".split(""), h = [31, 7936, 2031616, 520093696], g = [4, 1024, 262144, 67108864], v = [1, 256, 65536, 16777216], x = [6, 1536, 393216, 100663296], S = [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 + ], D = [224, 256, 384, 512], k = [128, 256], N = ["hex", "buffer", "arrayBuffer", "array", "digest"], z = { + 128: 168, + 256: 136 + }; + (i.JS_SHA3_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(L) { + return Object.prototype.toString.call(L) === "[object Array]"; + }), f && (i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(L) { + return typeof L == "object" && L.buffer && L.buffer.constructor === ArrayBuffer; + }); + for (var B = function(L, oe, Q) { + return function(X) { + return new I(L, oe, L).update(X)[Q](); + }; + }, $ = function(L, oe, Q) { + return function(X, ee) { + return new I(L, oe, ee).update(X)[Q](); + }; + }, U = function(L, oe, Q) { + return function(X, ee, O, Z) { + return l["cshake" + L].update(X, ee, O, Z)[Q](); + }; + }, C = function(L, oe, Q) { + return function(X, ee, O, Z) { + return l["kmac" + L].update(X, ee, O, Z)[Q](); + }; + }, W = function(L, oe, Q, X) { + for (var ee = 0; ee < N.length; ++ee) { + var O = N[ee]; + L[O] = oe(Q, X, O); + } + return L; + }, J = function(L, oe) { + var Q = B(L, oe, "hex"); + return Q.create = function() { + return new I(L, oe, L); + }, Q.update = function(X) { + return Q.create().update(X); + }, W(Q, B, L, oe); + }, ne = function(L, oe) { + var Q = $(L, oe, "hex"); + return Q.create = function(X) { + return new I(L, oe, X); + }, Q.update = function(X, ee) { + return Q.create(ee).update(X); + }, W(Q, $, L, oe); + }, K = function(L, oe) { + var Q = z[L], X = U(L, oe, "hex"); + return X.create = function(ee, O, Z) { + return !O && !Z ? l["shake" + L].create(ee) : new I(L, oe, ee).bytepad([O, Z], Q); + }, X.update = function(ee, O, Z, re) { + return X.create(O, Z, re).update(ee); + }, W(X, U, L, oe); + }, E = function(L, oe) { + var Q = z[L], X = C(L, oe, "hex"); + return X.create = function(ee, O, Z) { + return new q(L, oe, O).bytepad(["KMAC", Z], Q).bytepad([ee], Q); + }, X.update = function(ee, O, Z, re) { + return X.create(ee, Z, re).update(O); + }, W(X, C, L, oe); + }, b = [ + { name: "keccak", padding: v, bits: D, createMethod: J }, + { name: "sha3", padding: x, bits: D, createMethod: J }, + { name: "shake", padding: h, bits: k, createMethod: ne }, + { name: "cshake", padding: g, bits: k, createMethod: K }, + { name: "kmac", padding: g, bits: k, createMethod: E } + ], l = {}, p = [], m = 0; m < b.length; ++m) + for (var w = b[m], P = w.bits, _ = 0; _ < P.length; ++_) { + var y = w.name + "_" + P[_]; + if (p.push(y), l[y] = w.createMethod(P[_], w.padding), w.name !== "sha3") { + var M = w.name + P[_]; + p.push(M), l[M] = l[y]; + } + } + function I(L, oe, Q) { + this.blocks = [], this.s = [], this.padding = oe, this.outputBits = Q, this.reset = !0, this.finalized = !1, this.block = 0, this.start = 0, this.blockCount = 1600 - (L << 1) >> 5, this.byteCount = this.blockCount << 2, this.outputBlocks = Q >> 5, this.extraBytes = (Q & 31) >> 3; + for (var X = 0; X < 50; ++X) + this.s[X] = 0; + } + I.prototype.update = function(L) { + if (this.finalized) + throw new Error(r); + var oe, Q = typeof L; + if (Q !== "string") { + if (Q === "object") { + if (L === null) + throw new Error(e); + if (f && L.constructor === ArrayBuffer) + L = new Uint8Array(L); + else if (!Array.isArray(L) && (!f || !ArrayBuffer.isView(L))) + throw new Error(e); + } else + throw new Error(e); + oe = !0; + } + for (var X = this.blocks, ee = this.byteCount, O = L.length, Z = this.blockCount, re = 0, he = this.s, ae, fe; re < O; ) { + if (this.reset) + for (this.reset = !1, X[0] = this.block, ae = 1; ae < Z + 1; ++ae) + X[ae] = 0; + if (oe) + for (ae = this.start; re < O && ae < ee; ++re) + X[ae >> 2] |= L[re] << S[ae++ & 3]; + else + for (ae = this.start; re < O && ae < ee; ++re) + fe = L.charCodeAt(re), fe < 128 ? X[ae >> 2] |= fe << S[ae++ & 3] : fe < 2048 ? (X[ae >> 2] |= (192 | fe >> 6) << S[ae++ & 3], X[ae >> 2] |= (128 | fe & 63) << S[ae++ & 3]) : fe < 55296 || fe >= 57344 ? (X[ae >> 2] |= (224 | fe >> 12) << S[ae++ & 3], X[ae >> 2] |= (128 | fe >> 6 & 63) << S[ae++ & 3], X[ae >> 2] |= (128 | fe & 63) << S[ae++ & 3]) : (fe = 65536 + ((fe & 1023) << 10 | L.charCodeAt(++re) & 1023), X[ae >> 2] |= (240 | fe >> 18) << S[ae++ & 3], X[ae >> 2] |= (128 | fe >> 12 & 63) << S[ae++ & 3], X[ae >> 2] |= (128 | fe >> 6 & 63) << S[ae++ & 3], X[ae >> 2] |= (128 | fe & 63) << S[ae++ & 3]); + if (this.lastByteIndex = ae, ae >= ee) { + for (this.start = ae - ee, this.block = X[Z], ae = 0; ae < Z; ++ae) + he[ae] ^= X[ae]; + ce(he), this.reset = !0; + } else + this.start = ae; + } + return this; + }, I.prototype.encode = function(L, oe) { + var Q = L & 255, X = 1, ee = [Q]; + for (L = L >> 8, Q = L & 255; Q > 0; ) + ee.unshift(Q), L = L >> 8, Q = L & 255, ++X; + return oe ? ee.push(X) : ee.unshift(X), this.update(ee), ee.length; + }, I.prototype.encodeString = function(L) { + var oe, Q = typeof L; + if (Q !== "string") { + if (Q === "object") { + if (L === null) + throw new Error(e); + if (f && L.constructor === ArrayBuffer) + L = new Uint8Array(L); + else if (!Array.isArray(L) && (!f || !ArrayBuffer.isView(L))) + throw new Error(e); + } else + throw new Error(e); + oe = !0; + } + var X = 0, ee = L.length; + if (oe) + X = ee; + else + for (var O = 0; O < L.length; ++O) { + var Z = L.charCodeAt(O); + Z < 128 ? X += 1 : Z < 2048 ? X += 2 : Z < 55296 || Z >= 57344 ? X += 3 : (Z = 65536 + ((Z & 1023) << 10 | L.charCodeAt(++O) & 1023), X += 4); + } + return X += this.encode(X * 8), this.update(L), X; + }, I.prototype.bytepad = function(L, oe) { + for (var Q = this.encode(oe), X = 0; X < L.length; ++X) + Q += this.encodeString(L[X]); + var ee = oe - Q % oe, O = []; + return O.length = ee, this.update(O), this; + }, I.prototype.finalize = function() { + if (!this.finalized) { + this.finalized = !0; + var L = this.blocks, oe = this.lastByteIndex, Q = this.blockCount, X = this.s; + if (L[oe >> 2] |= this.padding[oe & 3], this.lastByteIndex === this.byteCount) + for (L[0] = L[Q], oe = 1; oe < Q + 1; ++oe) + L[oe] = 0; + for (L[Q - 1] |= 2147483648, oe = 0; oe < Q; ++oe) + X[oe] ^= L[oe]; + ce(X); + } + }, I.prototype.toString = I.prototype.hex = function() { + this.finalize(); + for (var L = this.blockCount, oe = this.s, Q = this.outputBlocks, X = this.extraBytes, ee = 0, O = 0, Z = "", re; O < Q; ) { + for (ee = 0; ee < L && O < Q; ++ee, ++O) + re = oe[ee], Z += u[re >> 4 & 15] + u[re & 15] + u[re >> 12 & 15] + u[re >> 8 & 15] + u[re >> 20 & 15] + u[re >> 16 & 15] + u[re >> 28 & 15] + u[re >> 24 & 15]; + O % L === 0 && (ce(oe), ee = 0); + } + return X && (re = oe[ee], Z += u[re >> 4 & 15] + u[re & 15], X > 1 && (Z += u[re >> 12 & 15] + u[re >> 8 & 15]), X > 2 && (Z += u[re >> 20 & 15] + u[re >> 16 & 15])), Z; + }, I.prototype.arrayBuffer = function() { + this.finalize(); + var L = this.blockCount, oe = this.s, Q = this.outputBlocks, X = this.extraBytes, ee = 0, O = 0, Z = this.outputBits >> 3, re; + X ? re = new ArrayBuffer(Q + 1 << 2) : re = new ArrayBuffer(Z); + for (var he = new Uint32Array(re); O < Q; ) { + for (ee = 0; ee < L && O < Q; ++ee, ++O) + he[O] = oe[ee]; + O % L === 0 && ce(oe); + } + return X && (he[ee] = oe[ee], re = re.slice(0, Z)), re; + }, I.prototype.buffer = I.prototype.arrayBuffer, I.prototype.digest = I.prototype.array = function() { + this.finalize(); + for (var L = this.blockCount, oe = this.s, Q = this.outputBlocks, X = this.extraBytes, ee = 0, O = 0, Z = [], re, he; O < Q; ) { + for (ee = 0; ee < L && O < Q; ++ee, ++O) + re = O << 2, he = oe[ee], Z[re] = he & 255, Z[re + 1] = he >> 8 & 255, Z[re + 2] = he >> 16 & 255, Z[re + 3] = he >> 24 & 255; + O % L === 0 && ce(oe); + } + return X && (re = O << 2, he = oe[ee], Z[re] = he & 255, X > 1 && (Z[re + 1] = he >> 8 & 255), X > 2 && (Z[re + 2] = he >> 16 & 255)), Z; + }; + function q(L, oe, Q) { + I.call(this, L, oe, Q); + } + q.prototype = new I(), q.prototype.finalize = function() { + return this.encode(this.outputBits, !0), I.prototype.finalize.call(this); + }; + var ce = function(L) { + var oe, Q, X, ee, O, Z, re, he, ae, fe, be, Ae, Te, Re, $e, Me, Oe, ze, De, je, Ue, _e, Ze, ot, ke, rt, nt, Ge, ht, lt, ct, qt, Gt, Et, Yt, tr, Tt, kt, It, dt, Dt, Nt, mt, Bt, Ft, et, $t, H, V, Y, T, F, ie, le, me, Ee, Le, Ie, Qe, Xe, tt, st, vt; + for (X = 0; X < 48; X += 2) + ee = L[0] ^ L[10] ^ L[20] ^ L[30] ^ L[40], O = L[1] ^ L[11] ^ L[21] ^ L[31] ^ L[41], Z = L[2] ^ L[12] ^ L[22] ^ L[32] ^ L[42], re = L[3] ^ L[13] ^ L[23] ^ L[33] ^ L[43], he = L[4] ^ L[14] ^ L[24] ^ L[34] ^ L[44], ae = L[5] ^ L[15] ^ L[25] ^ L[35] ^ L[45], fe = L[6] ^ L[16] ^ L[26] ^ L[36] ^ L[46], be = L[7] ^ L[17] ^ L[27] ^ L[37] ^ L[47], Ae = L[8] ^ L[18] ^ L[28] ^ L[38] ^ L[48], Te = L[9] ^ L[19] ^ L[29] ^ L[39] ^ L[49], oe = Ae ^ (Z << 1 | re >>> 31), Q = Te ^ (re << 1 | Z >>> 31), L[0] ^= oe, L[1] ^= Q, L[10] ^= oe, L[11] ^= Q, L[20] ^= oe, L[21] ^= Q, L[30] ^= oe, L[31] ^= Q, L[40] ^= oe, L[41] ^= Q, oe = ee ^ (he << 1 | ae >>> 31), Q = O ^ (ae << 1 | he >>> 31), L[2] ^= oe, L[3] ^= Q, L[12] ^= oe, L[13] ^= Q, L[22] ^= oe, L[23] ^= Q, L[32] ^= oe, L[33] ^= Q, L[42] ^= oe, L[43] ^= Q, oe = Z ^ (fe << 1 | be >>> 31), Q = re ^ (be << 1 | fe >>> 31), L[4] ^= oe, L[5] ^= Q, L[14] ^= oe, L[15] ^= Q, L[24] ^= oe, L[25] ^= Q, L[34] ^= oe, L[35] ^= Q, L[44] ^= oe, L[45] ^= Q, oe = he ^ (Ae << 1 | Te >>> 31), Q = ae ^ (Te << 1 | Ae >>> 31), L[6] ^= oe, L[7] ^= Q, L[16] ^= oe, L[17] ^= Q, L[26] ^= oe, L[27] ^= Q, L[36] ^= oe, L[37] ^= Q, L[46] ^= oe, L[47] ^= Q, oe = fe ^ (ee << 1 | O >>> 31), Q = be ^ (O << 1 | ee >>> 31), L[8] ^= oe, L[9] ^= Q, L[18] ^= oe, L[19] ^= Q, L[28] ^= oe, L[29] ^= Q, L[38] ^= oe, L[39] ^= Q, L[48] ^= oe, L[49] ^= Q, Re = L[0], $e = L[1], et = L[11] << 4 | L[10] >>> 28, $t = L[10] << 4 | L[11] >>> 28, Ge = L[20] << 3 | L[21] >>> 29, ht = L[21] << 3 | L[20] >>> 29, Xe = L[31] << 9 | L[30] >>> 23, tt = L[30] << 9 | L[31] >>> 23, Nt = L[40] << 18 | L[41] >>> 14, mt = L[41] << 18 | L[40] >>> 14, Et = L[2] << 1 | L[3] >>> 31, Yt = L[3] << 1 | L[2] >>> 31, Me = L[13] << 12 | L[12] >>> 20, Oe = L[12] << 12 | L[13] >>> 20, H = L[22] << 10 | L[23] >>> 22, V = L[23] << 10 | L[22] >>> 22, lt = L[33] << 13 | L[32] >>> 19, ct = L[32] << 13 | L[33] >>> 19, st = L[42] << 2 | L[43] >>> 30, vt = L[43] << 2 | L[42] >>> 30, le = L[5] << 30 | L[4] >>> 2, me = L[4] << 30 | L[5] >>> 2, tr = L[14] << 6 | L[15] >>> 26, Tt = L[15] << 6 | L[14] >>> 26, ze = L[25] << 11 | L[24] >>> 21, De = L[24] << 11 | L[25] >>> 21, Y = L[34] << 15 | L[35] >>> 17, T = L[35] << 15 | L[34] >>> 17, qt = L[45] << 29 | L[44] >>> 3, Gt = L[44] << 29 | L[45] >>> 3, ot = L[6] << 28 | L[7] >>> 4, ke = L[7] << 28 | L[6] >>> 4, Ee = L[17] << 23 | L[16] >>> 9, Le = L[16] << 23 | L[17] >>> 9, kt = L[26] << 25 | L[27] >>> 7, It = L[27] << 25 | L[26] >>> 7, je = L[36] << 21 | L[37] >>> 11, Ue = L[37] << 21 | L[36] >>> 11, F = L[47] << 24 | L[46] >>> 8, ie = L[46] << 24 | L[47] >>> 8, Bt = L[8] << 27 | L[9] >>> 5, Ft = L[9] << 27 | L[8] >>> 5, rt = L[18] << 20 | L[19] >>> 12, nt = L[19] << 20 | L[18] >>> 12, Ie = L[29] << 7 | L[28] >>> 25, Qe = L[28] << 7 | L[29] >>> 25, dt = L[38] << 8 | L[39] >>> 24, Dt = L[39] << 8 | L[38] >>> 24, _e = L[48] << 14 | L[49] >>> 18, Ze = L[49] << 14 | L[48] >>> 18, L[0] = Re ^ ~Me & ze, L[1] = $e ^ ~Oe & De, L[10] = ot ^ ~rt & Ge, L[11] = ke ^ ~nt & ht, L[20] = Et ^ ~tr & kt, L[21] = Yt ^ ~Tt & It, L[30] = Bt ^ ~et & H, L[31] = Ft ^ ~$t & V, L[40] = le ^ ~Ee & Ie, L[41] = me ^ ~Le & Qe, L[2] = Me ^ ~ze & je, L[3] = Oe ^ ~De & Ue, L[12] = rt ^ ~Ge & lt, L[13] = nt ^ ~ht & ct, L[22] = tr ^ ~kt & dt, L[23] = Tt ^ ~It & Dt, L[32] = et ^ ~H & Y, L[33] = $t ^ ~V & T, L[42] = Ee ^ ~Ie & Xe, L[43] = Le ^ ~Qe & tt, L[4] = ze ^ ~je & _e, L[5] = De ^ ~Ue & Ze, L[14] = Ge ^ ~lt & qt, L[15] = ht ^ ~ct & Gt, L[24] = kt ^ ~dt & Nt, L[25] = It ^ ~Dt & mt, L[34] = H ^ ~Y & F, L[35] = V ^ ~T & ie, L[44] = Ie ^ ~Xe & st, L[45] = Qe ^ ~tt & vt, L[6] = je ^ ~_e & Re, L[7] = Ue ^ ~Ze & $e, L[16] = lt ^ ~qt & ot, L[17] = ct ^ ~Gt & ke, L[26] = dt ^ ~Nt & Et, L[27] = Dt ^ ~mt & Yt, L[36] = Y ^ ~F & Bt, L[37] = T ^ ~ie & Ft, L[46] = Xe ^ ~st & le, L[47] = tt ^ ~vt & me, L[8] = _e ^ ~Re & Me, L[9] = Ze ^ ~$e & Oe, L[18] = qt ^ ~ot & rt, L[19] = Gt ^ ~ke & nt, L[28] = Nt ^ ~Et & tr, L[29] = mt ^ ~Yt & Tt, L[38] = F ^ ~Bt & et, L[39] = ie ^ ~Ft & $t, L[48] = st ^ ~le & Ee, L[49] = vt ^ ~me & Le, L[0] ^= R[X], L[1] ^= R[X + 1]; + }; + if (a) + t.exports = l; + else + for (m = 0; m < p.length; ++m) + i[p[m]] = l[p[m]]; + })(); + })(ug)), ug.exports; +} +var oB = sB(); +const aB = /* @__PURE__ */ Hi(oB), cB = "logger/5.7.0"; +let K2 = !1, V2 = !1; +const Bh = { debug: 1, default: 2, info: 2, warning: 3, error: 4, off: 5 }; +let G2 = Bh.default, fg = null; +function uB() { + try { + const t = []; + if (["NFD", "NFC", "NFKD", "NFKC"].forEach((e) => { + try { + if ("test".normalize(e) !== "test") + throw new Error("bad normalize"); + } catch { + t.push(e); + } + }), t.length) + throw new Error("missing " + t.join(", ")); + if ("é".normalize("NFD") !== "é") + throw new Error("broken implementation"); + } catch (t) { + return t.message; + } + return null; +} +const Y2 = uB(); +var tv; +(function(t) { + t.DEBUG = "DEBUG", t.INFO = "INFO", t.WARNING = "WARNING", t.ERROR = "ERROR", t.OFF = "OFF"; +})(tv || (tv = {})); +var os; +(function(t) { + t.UNKNOWN_ERROR = "UNKNOWN_ERROR", t.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", t.UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION", t.NETWORK_ERROR = "NETWORK_ERROR", t.SERVER_ERROR = "SERVER_ERROR", t.TIMEOUT = "TIMEOUT", t.BUFFER_OVERRUN = "BUFFER_OVERRUN", t.NUMERIC_FAULT = "NUMERIC_FAULT", t.MISSING_NEW = "MISSING_NEW", t.INVALID_ARGUMENT = "INVALID_ARGUMENT", t.MISSING_ARGUMENT = "MISSING_ARGUMENT", t.UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT", t.CALL_EXCEPTION = "CALL_EXCEPTION", t.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", t.NONCE_EXPIRED = "NONCE_EXPIRED", t.REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED", t.UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT", t.TRANSACTION_REPLACED = "TRANSACTION_REPLACED", t.ACTION_REJECTED = "ACTION_REJECTED"; +})(os || (os = {})); +const J2 = "0123456789abcdef"; +class Yr { + constructor(e) { + Object.defineProperty(this, "version", { + enumerable: !0, + value: e, + writable: !1 + }); + } + _log(e, r) { + const n = e.toLowerCase(); + Bh[n] == null && this.throwArgumentError("invalid log level name", "logLevel", e), !(G2 > Bh[n]) && console.log.apply(console, r); + } + debug(...e) { + this._log(Yr.levels.DEBUG, e); + } + info(...e) { + this._log(Yr.levels.INFO, e); + } + warn(...e) { + this._log(Yr.levels.WARNING, e); + } + makeError(e, r, n) { + if (V2) + return this.makeError("censored error", r, {}); + r || (r = Yr.errors.UNKNOWN_ERROR), n || (n = {}); + const i = []; + Object.keys(n).forEach((f) => { + const u = n[f]; + try { + if (u instanceof Uint8Array) { + let h = ""; + for (let g = 0; g < u.length; g++) + h += J2[u[g] >> 4], h += J2[u[g] & 15]; + i.push(f + "=Uint8Array(0x" + h + ")"); + } else + i.push(f + "=" + JSON.stringify(u)); + } catch { + i.push(f + "=" + JSON.stringify(n[f].toString())); + } + }), i.push(`code=${r}`), i.push(`version=${this.version}`); + const s = e; + let o = ""; + switch (r) { + case os.NUMERIC_FAULT: { + o = "NUMERIC_FAULT"; + const 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 os.CALL_EXCEPTION: + case os.INSUFFICIENT_FUNDS: + case os.MISSING_NEW: + case os.NONCE_EXPIRED: + case os.REPLACEMENT_UNDERPRICED: + case os.TRANSACTION_REPLACED: + case os.UNPREDICTABLE_GAS_LIMIT: + o = r; + break; + } + o && (e += " [ See: https://links.ethers.org/v5-errors-" + o + " ]"), i.length && (e += " (" + i.join(", ") + ")"); + const a = new Error(e); + return a.reason = s, a.code = r, Object.keys(n).forEach(function(f) { + a[f] = n[f]; + }), a; + } + throwError(e, r, n) { + throw this.makeError(e, r, n); + } + throwArgumentError(e, r, n) { + return this.throwError(e, Yr.errors.INVALID_ARGUMENT, { + argument: r, + value: n + }); + } + assert(e, r, n, i) { + e || this.throwError(r, n, i); + } + assertArgument(e, r, n, i) { + e || this.throwArgumentError(r, n, i); + } + checkNormalize(e) { + Y2 && this.throwError("platform missing String.prototype.normalize", Yr.errors.UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", + form: Y2 + }); + } + checkSafeUint53(e, r) { + typeof e == "number" && (r == null && (r = "value not safe"), (e < 0 || e >= 9007199254740991) && this.throwError(r, Yr.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", + value: e + }), e % 1 && this.throwError(r, Yr.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value: e + })); + } + checkArgumentCount(e, r, n) { + n ? n = ": " + n : n = "", e < r && this.throwError("missing argument" + n, Yr.errors.MISSING_ARGUMENT, { + count: e, + expectedCount: r + }), e > r && this.throwError("too many arguments" + n, Yr.errors.UNEXPECTED_ARGUMENT, { + count: e, + expectedCount: r + }); + } + checkNew(e, r) { + (e === Object || e == null) && this.throwError("missing new", Yr.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", Yr.errors.UNSUPPORTED_OPERATION, { name: e.name, operation: "new" }) : (e === Object || e == null) && this.throwError("missing new", Yr.errors.MISSING_NEW, { name: r.name }); + } + static globalLogger() { + return fg || (fg = new Yr(cB)), fg; + } + static setCensorship(e, r) { + if (!e && r && this.globalLogger().throwError("cannot permanently disable censorship", Yr.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }), K2) { + if (!e) + return; + this.globalLogger().throwError("error censorship permanent", Yr.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + V2 = !!e, K2 = !!r; + } + static setLogLevel(e) { + const r = Bh[e.toLowerCase()]; + if (r == null) { + Yr.globalLogger().warn("invalid log level - " + e); + return; + } + G2 = r; + } + static from(e) { + return new Yr(e); + } +} +Yr.errors = os; +Yr.levels = tv; +const fB = "bytes/5.7.0", ln = new Yr(fB); +function c8(t) { + return !!t.toHexString; +} +function Dc(t) { + return t.slice || (t.slice = function() { + const e = Array.prototype.slice.call(arguments); + return Dc(new Uint8Array(Array.prototype.slice.apply(t, e))); + }), t; +} +function lB(t) { + return Is(t) && !(t.length % 2) || p1(t); +} +function X2(t) { + return typeof t == "number" && t == t && t % 1 === 0; +} +function p1(t) { + if (t == null) + return !1; + if (t.constructor === Uint8Array) + return !0; + if (typeof t == "string" || !X2(t.length) || t.length < 0) + return !1; + for (let e = 0; e < t.length; e++) { + const r = t[e]; + if (!X2(r) || r < 0 || r >= 256) + return !1; + } + return !0; +} +function bn(t, e) { + if (e || (e = {}), typeof t == "number") { + ln.checkSafeUint53(t, "invalid arrayify value"); + const r = []; + for (; t; ) + r.unshift(t & 255), t = parseInt(String(t / 256)); + return r.length === 0 && r.push(0), Dc(new Uint8Array(r)); + } + if (e.allowMissingPrefix && typeof t == "string" && t.substring(0, 2) !== "0x" && (t = "0x" + t), c8(t) && (t = t.toHexString()), Is(t)) { + let r = t.substring(2); + r.length % 2 && (e.hexPad === "left" ? r = "0" + r : e.hexPad === "right" ? r += "0" : ln.throwArgumentError("hex data is odd-length", "value", t)); + const n = []; + for (let i = 0; i < r.length; i += 2) + n.push(parseInt(r.substring(i, i + 2), 16)); + return Dc(new Uint8Array(n)); + } + return p1(t) ? Dc(new Uint8Array(t)) : ln.throwArgumentError("invalid arrayify value", "value", t); +} +function hB(t) { + const e = t.map((i) => bn(i)), r = e.reduce((i, s) => i + s.length, 0), n = new Uint8Array(r); + return e.reduce((i, s) => (n.set(s, i), i + s.length), 0), Dc(n); +} +function dB(t, e) { + t = bn(t), t.length > e && ln.throwArgumentError("value out of range", "value", arguments[0]); + const r = new Uint8Array(e); + return r.set(t, e - t.length), Dc(r); +} +function Is(t, e) { + return !(typeof t != "string" || !t.match(/^0x[0-9A-Fa-f]*$/) || e && t.length !== 2 + 2 * e); +} +const lg = "0123456789abcdef"; +function _i(t, e) { + if (e || (e = {}), typeof t == "number") { + ln.checkSafeUint53(t, "invalid hexlify value"); + let r = ""; + for (; t; ) + r = lg[t & 15] + r, t = Math.floor(t / 16); + return r.length ? (r.length % 2 && (r = "0" + r), "0x" + r) : "0x00"; + } + if (typeof t == "bigint") + return t = t.toString(16), t.length % 2 ? "0x0" + t : "0x" + t; + if (e.allowMissingPrefix && typeof t == "string" && t.substring(0, 2) !== "0x" && (t = "0x" + t), c8(t)) + return t.toHexString(); + if (Is(t)) + return t.length % 2 && (e.hexPad === "left" ? t = "0x0" + t.substring(2) : e.hexPad === "right" ? t += "0" : ln.throwArgumentError("hex data is odd-length", "value", t)), t.toLowerCase(); + if (p1(t)) { + let r = "0x"; + for (let n = 0; n < t.length; n++) { + let i = t[n]; + r += lg[(i & 240) >> 4] + lg[i & 15]; + } + return r; + } + return ln.throwArgumentError("invalid hexlify value", "value", t); +} +function pB(t) { + if (typeof t != "string") + t = _i(t); + else if (!Is(t) || t.length % 2) + return null; + return (t.length - 2) / 2; +} +function Z2(t, e, r) { + return typeof t != "string" ? t = _i(t) : (!Is(t) || t.length % 2) && ln.throwArgumentError("invalid hexData", "value", t), e = 2 + 2 * e, "0x" + t.substring(e); +} +function Oc(t, e) { + for (typeof t != "string" ? t = _i(t) : Is(t) || ln.throwArgumentError("invalid hex string", "value", t), t.length > 2 * e + 2 && ln.throwArgumentError("value out of range", "value", arguments[1]); t.length < 2 * e + 2; ) + t = "0x0" + t.substring(2); + return t; +} +function u8(t) { + const e = { + r: "0x", + s: "0x", + _vs: "0x", + recoveryParam: 0, + v: 0, + yParityAndS: "0x", + compact: "0x" + }; + if (lB(t)) { + let r = bn(t); + r.length === 64 ? (e.v = 27 + (r[32] >> 7), r[32] &= 127, e.r = _i(r.slice(0, 32)), e.s = _i(r.slice(32, 64))) : r.length === 65 ? (e.r = _i(r.slice(0, 32)), e.s = _i(r.slice(32, 64)), e.v = r[64]) : ln.throwArgumentError("invalid signature string", "signature", t), e.v < 27 && (e.v === 0 || e.v === 1 ? e.v += 27 : ln.throwArgumentError("signature invalid v byte", "signature", t)), e.recoveryParam = 1 - e.v % 2, e.recoveryParam && (r[32] |= 128), e._vs = _i(r.slice(32, 64)); + } else { + if (e.r = t.r, e.s = t.s, e.v = t.v, e.recoveryParam = t.recoveryParam, e._vs = t._vs, e._vs != null) { + const i = dB(bn(e._vs), 32); + e._vs = _i(i); + const s = i[0] >= 128 ? 1 : 0; + e.recoveryParam == null ? e.recoveryParam = s : e.recoveryParam !== s && ln.throwArgumentError("signature recoveryParam mismatch _vs", "signature", t), i[0] &= 127; + const o = _i(i); + e.s == null ? e.s = o : e.s !== o && ln.throwArgumentError("signature v mismatch _vs", "signature", t); + } + if (e.recoveryParam == null) + e.v == null ? ln.throwArgumentError("signature missing v and recoveryParam", "signature", t) : 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 { + const i = e.v === 0 || e.v === 1 ? e.v : 1 - e.v % 2; + e.recoveryParam !== i && ln.throwArgumentError("signature recoveryParam mismatch v", "signature", t); + } + e.r == null || !Is(e.r) ? ln.throwArgumentError("signature missing or invalid r", "signature", t) : e.r = Oc(e.r, 32), e.s == null || !Is(e.s) ? ln.throwArgumentError("signature missing or invalid s", "signature", t) : e.s = Oc(e.s, 32); + const r = bn(e.s); + r[0] >= 128 && ln.throwArgumentError("signature s out of range", "signature", t), e.recoveryParam && (r[0] |= 128); + const n = _i(r); + e._vs && (Is(e._vs) || ln.throwArgumentError("signature invalid _vs", "signature", t), e._vs = Oc(e._vs, 32)), e._vs == null ? e._vs = n : e._vs !== n && ln.throwArgumentError("signature _vs mismatch v and s", "signature", t); + } + return e.yParityAndS = e._vs, e.compact = e.r + e.yParityAndS.substring(2), e; +} +function g1(t) { + return "0x" + aB.keccak_256(bn(t)); +} +var Fh = { exports: {} }, gB = Fh.exports, Q2; +function mB() { + return Q2 || (Q2 = 1, (function(t) { + (function(e, r) { + function n(b, l) { + if (!b) throw new Error(l || "Assertion failed"); + } + function i(b, l) { + b.super_ = l; + var p = function() { + }; + p.prototype = l.prototype, b.prototype = new p(), b.prototype.constructor = b; + } + function s(b, l, p) { + if (s.isBN(b)) + return b; + this.negative = 0, this.words = null, this.length = 0, this.red = null, b !== null && ((l === "le" || l === "be") && (p = l, l = 10), this._init(b || 0, l || 10, p || "be")); + } + typeof e == "object" ? e.exports = s : r.BN = s, s.BN = s, s.wordSize = 26; + var o; + try { + typeof window < "u" && typeof window.Buffer < "u" ? o = window.Buffer : o = Qf.Buffer; + } catch { + } + s.isBN = function(l) { + return l instanceof s ? !0 : l !== null && typeof l == "object" && l.constructor.wordSize === s.wordSize && Array.isArray(l.words); + }, s.max = function(l, p) { + return l.cmp(p) > 0 ? l : p; + }, s.min = function(l, p) { + return l.cmp(p) < 0 ? l : p; + }, s.prototype._init = function(l, p, m) { + if (typeof l == "number") + return this._initNumber(l, p, m); + if (typeof l == "object") + return this._initArray(l, p, m); + p === "hex" && (p = 16), n(p === (p | 0) && p >= 2 && p <= 36), l = l.toString().replace(/\s+/g, ""); + var w = 0; + l[0] === "-" && (w++, this.negative = 1), w < l.length && (p === 16 ? this._parseHex(l, w, m) : (this._parseBase(l, p, w), m === "le" && this._initArray(this.toArray(), p, m))); + }, s.prototype._initNumber = function(l, p, m) { + l < 0 && (this.negative = 1, l = -l), l < 67108864 ? (this.words = [l & 67108863], this.length = 1) : l < 4503599627370496 ? (this.words = [ + l & 67108863, + l / 67108864 & 67108863 + ], this.length = 2) : (n(l < 9007199254740992), this.words = [ + l & 67108863, + l / 67108864 & 67108863, + 1 + ], this.length = 3), m === "le" && this._initArray(this.toArray(), p, m); + }, s.prototype._initArray = function(l, p, m) { + if (n(typeof l.length == "number"), l.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(l.length / 3), this.words = new Array(this.length); + for (var w = 0; w < this.length; w++) + this.words[w] = 0; + var P, _, y = 0; + if (m === "be") + for (w = l.length - 1, P = 0; w >= 0; w -= 3) + _ = l[w] | l[w - 1] << 8 | l[w - 2] << 16, this.words[P] |= _ << y & 67108863, this.words[P + 1] = _ >>> 26 - y & 67108863, y += 24, y >= 26 && (y -= 26, P++); + else if (m === "le") + for (w = 0, P = 0; w < l.length; w += 3) + _ = l[w] | l[w + 1] << 8 | l[w + 2] << 16, this.words[P] |= _ << y & 67108863, this.words[P + 1] = _ >>> 26 - y & 67108863, y += 24, y >= 26 && (y -= 26, P++); + return this._strip(); + }; + function a(b, l) { + var p = b.charCodeAt(l); + if (p >= 48 && p <= 57) + return p - 48; + if (p >= 65 && p <= 70) + return p - 55; + if (p >= 97 && p <= 102) + return p - 87; + n(!1, "Invalid character in " + b); + } + function f(b, l, p) { + var m = a(b, p); + return p - 1 >= l && (m |= a(b, p - 1) << 4), m; + } + s.prototype._parseHex = function(l, p, m) { + this.length = Math.ceil((l.length - p) / 6), this.words = new Array(this.length); + for (var w = 0; w < this.length; w++) + this.words[w] = 0; + var P = 0, _ = 0, y; + if (m === "be") + for (w = l.length - 1; w >= p; w -= 2) + y = f(l, p, w) << P, this.words[_] |= y & 67108863, P >= 18 ? (P -= 18, _ += 1, this.words[_] |= y >>> 26) : P += 8; + else { + var M = l.length - p; + for (w = M % 2 === 0 ? p + 1 : p; w < l.length; w += 2) + y = f(l, p, w) << P, this.words[_] |= y & 67108863, P >= 18 ? (P -= 18, _ += 1, this.words[_] |= y >>> 26) : P += 8; + } + this._strip(); + }; + function u(b, l, p, m) { + for (var w = 0, P = 0, _ = Math.min(b.length, p), y = l; y < _; y++) { + var M = b.charCodeAt(y) - 48; + w *= m, M >= 49 ? P = M - 49 + 10 : M >= 17 ? P = M - 17 + 10 : P = M, n(M >= 0 && P < m, "Invalid character"), w += P; + } + return w; + } + s.prototype._parseBase = function(l, p, m) { + this.words = [0], this.length = 1; + for (var w = 0, P = 1; P <= 67108863; P *= p) + w++; + w--, P = P / p | 0; + for (var _ = l.length - m, y = _ % w, M = Math.min(_, _ - y) + m, I = 0, q = m; q < M; q += w) + I = u(l, q, q + w, p), this.imuln(P), this.words[0] + I < 67108864 ? this.words[0] += I : this._iaddn(I); + if (y !== 0) { + var ce = 1; + for (I = u(l, q, l.length, p), q = 0; q < y; q++) + ce *= p; + this.imuln(ce), this.words[0] + I < 67108864 ? this.words[0] += I : this._iaddn(I); + } + this._strip(); + }, s.prototype.copy = function(l) { + l.words = new Array(this.length); + for (var p = 0; p < this.length; p++) + l.words[p] = this.words[p]; + l.length = this.length, l.negative = this.negative, l.red = this.red; + }; + function h(b, l) { + b.words = l.words, b.length = l.length, b.negative = l.negative, b.red = l.red; + } + if (s.prototype._move = function(l) { + h(l, this); + }, s.prototype.clone = function() { + var l = new s(null); + return this.copy(l), l; + }, s.prototype._expand = function(l) { + for (; this.length < l; ) + this.words[this.length++] = 0; + return this; + }, s.prototype._strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, s.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, typeof Symbol < "u" && typeof Symbol.for == "function") + try { + s.prototype[Symbol.for("nodejs.util.inspect.custom")] = g; + } catch { + s.prototype.inspect = g; + } + else + s.prototype.inspect = g; + function g() { + 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" + ], x = [ + 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 + ], S = [ + 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 + ]; + s.prototype.toString = function(l, p) { + l = l || 10, p = p | 0 || 1; + var m; + if (l === 16 || l === "hex") { + m = ""; + for (var w = 0, P = 0, _ = 0; _ < this.length; _++) { + var y = this.words[_], M = ((y << w | P) & 16777215).toString(16); + P = y >>> 24 - w & 16777215, w += 2, w >= 26 && (w -= 26, _--), P !== 0 || _ !== this.length - 1 ? m = v[6 - M.length] + M + m : m = M + m; + } + for (P !== 0 && (m = P.toString(16) + m); m.length % p !== 0; ) + m = "0" + m; + return this.negative !== 0 && (m = "-" + m), m; + } + if (l === (l | 0) && l >= 2 && l <= 36) { + var I = x[l], q = S[l]; + m = ""; + var ce = this.clone(); + for (ce.negative = 0; !ce.isZero(); ) { + var L = ce.modrn(q).toString(l); + ce = ce.idivn(q), ce.isZero() ? m = L + m : m = v[I - L.length] + L + m; + } + for (this.isZero() && (m = "0" + m); m.length % p !== 0; ) + m = "0" + m; + return this.negative !== 0 && (m = "-" + m), m; + } + n(!1, "Base should be between 2 and 36"); + }, s.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 && n(!1, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -l : l; + }, s.prototype.toJSON = function() { + return this.toString(16, 2); + }, o && (s.prototype.toBuffer = function(l, p) { + return this.toArrayLike(o, l, p); + }), s.prototype.toArray = function(l, p) { + return this.toArrayLike(Array, l, p); + }; + var R = function(l, p) { + return l.allocUnsafe ? l.allocUnsafe(p) : new l(p); + }; + s.prototype.toArrayLike = function(l, p, m) { + this._strip(); + var w = this.byteLength(), P = m || Math.max(1, w); + n(w <= P, "byte array longer than desired length"), n(P > 0, "Requested array length <= 0"); + var _ = R(l, P), y = p === "le" ? "LE" : "BE"; + return this["_toArrayLike" + y](_, w), _; + }, s.prototype._toArrayLikeLE = function(l, p) { + for (var m = 0, w = 0, P = 0, _ = 0; P < this.length; P++) { + var y = this.words[P] << _ | w; + l[m++] = y & 255, m < l.length && (l[m++] = y >> 8 & 255), m < l.length && (l[m++] = y >> 16 & 255), _ === 6 ? (m < l.length && (l[m++] = y >> 24 & 255), w = 0, _ = 0) : (w = y >>> 24, _ += 2); + } + if (m < l.length) + for (l[m++] = w; m < l.length; ) + l[m++] = 0; + }, s.prototype._toArrayLikeBE = function(l, p) { + for (var m = l.length - 1, w = 0, P = 0, _ = 0; P < this.length; P++) { + var y = this.words[P] << _ | w; + l[m--] = y & 255, m >= 0 && (l[m--] = y >> 8 & 255), m >= 0 && (l[m--] = y >> 16 & 255), _ === 6 ? (m >= 0 && (l[m--] = y >> 24 & 255), w = 0, _ = 0) : (w = y >>> 24, _ += 2); + } + if (m >= 0) + for (l[m--] = w; m >= 0; ) + l[m--] = 0; + }, Math.clz32 ? s.prototype._countBits = function(l) { + return 32 - Math.clz32(l); + } : s.prototype._countBits = function(l) { + var p = l, m = 0; + return p >= 4096 && (m += 13, p >>>= 13), p >= 64 && (m += 7, p >>>= 7), p >= 8 && (m += 4, p >>>= 4), p >= 2 && (m += 2, p >>>= 2), m + p; + }, s.prototype._zeroBits = function(l) { + if (l === 0) return 26; + var p = l, m = 0; + return (p & 8191) === 0 && (m += 13, p >>>= 13), (p & 127) === 0 && (m += 7, p >>>= 7), (p & 15) === 0 && (m += 4, p >>>= 4), (p & 3) === 0 && (m += 2, p >>>= 2), (p & 1) === 0 && m++, m; + }, s.prototype.bitLength = function() { + var l = this.words[this.length - 1], p = this._countBits(l); + return (this.length - 1) * 26 + p; + }; + function D(b) { + for (var l = new Array(b.bitLength()), p = 0; p < l.length; p++) { + var m = p / 26 | 0, w = p % 26; + l[p] = b.words[m] >>> w & 1; + } + return l; + } + s.prototype.zeroBits = function() { + if (this.isZero()) return 0; + for (var l = 0, p = 0; p < this.length; p++) { + var m = this._zeroBits(this.words[p]); + if (l += m, m !== 26) break; + } + return l; + }, s.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, s.prototype.toTwos = function(l) { + return this.negative !== 0 ? this.abs().inotn(l).iaddn(1) : this.clone(); + }, s.prototype.fromTwos = function(l) { + return this.testn(l - 1) ? this.notn(l).iaddn(1).ineg() : this.clone(); + }, s.prototype.isNeg = function() { + return this.negative !== 0; + }, s.prototype.neg = function() { + return this.clone().ineg(); + }, s.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, s.prototype.iuor = function(l) { + for (; this.length < l.length; ) + this.words[this.length++] = 0; + for (var p = 0; p < l.length; p++) + this.words[p] = this.words[p] | l.words[p]; + return this._strip(); + }, s.prototype.ior = function(l) { + return n((this.negative | l.negative) === 0), this.iuor(l); + }, s.prototype.or = function(l) { + return this.length > l.length ? this.clone().ior(l) : l.clone().ior(this); + }, s.prototype.uor = function(l) { + return this.length > l.length ? this.clone().iuor(l) : l.clone().iuor(this); + }, s.prototype.iuand = function(l) { + var p; + this.length > l.length ? p = l : p = this; + for (var m = 0; m < p.length; m++) + this.words[m] = this.words[m] & l.words[m]; + return this.length = p.length, this._strip(); + }, s.prototype.iand = function(l) { + return n((this.negative | l.negative) === 0), this.iuand(l); + }, s.prototype.and = function(l) { + return this.length > l.length ? this.clone().iand(l) : l.clone().iand(this); + }, s.prototype.uand = function(l) { + return this.length > l.length ? this.clone().iuand(l) : l.clone().iuand(this); + }, s.prototype.iuxor = function(l) { + var p, m; + this.length > l.length ? (p = this, m = l) : (p = l, m = this); + for (var w = 0; w < m.length; w++) + this.words[w] = p.words[w] ^ m.words[w]; + if (this !== p) + for (; w < p.length; w++) + this.words[w] = p.words[w]; + return this.length = p.length, this._strip(); + }, s.prototype.ixor = function(l) { + return n((this.negative | l.negative) === 0), this.iuxor(l); + }, s.prototype.xor = function(l) { + return this.length > l.length ? this.clone().ixor(l) : l.clone().ixor(this); + }, s.prototype.uxor = function(l) { + return this.length > l.length ? this.clone().iuxor(l) : l.clone().iuxor(this); + }, s.prototype.inotn = function(l) { + n(typeof l == "number" && l >= 0); + var p = Math.ceil(l / 26) | 0, m = l % 26; + this._expand(p), m > 0 && p--; + for (var w = 0; w < p; w++) + this.words[w] = ~this.words[w] & 67108863; + return m > 0 && (this.words[w] = ~this.words[w] & 67108863 >> 26 - m), this._strip(); + }, s.prototype.notn = function(l) { + return this.clone().inotn(l); + }, s.prototype.setn = function(l, p) { + n(typeof l == "number" && l >= 0); + var m = l / 26 | 0, w = l % 26; + return this._expand(m + 1), p ? this.words[m] = this.words[m] | 1 << w : this.words[m] = this.words[m] & ~(1 << w), this._strip(); + }, s.prototype.iadd = function(l) { + var p; + if (this.negative !== 0 && l.negative === 0) + return this.negative = 0, p = this.isub(l), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && l.negative !== 0) + return l.negative = 0, p = this.isub(l), l.negative = 1, p._normSign(); + var m, w; + this.length > l.length ? (m = this, w = l) : (m = l, w = this); + for (var P = 0, _ = 0; _ < w.length; _++) + p = (m.words[_] | 0) + (w.words[_] | 0) + P, this.words[_] = p & 67108863, P = p >>> 26; + for (; P !== 0 && _ < m.length; _++) + p = (m.words[_] | 0) + P, this.words[_] = p & 67108863, P = p >>> 26; + if (this.length = m.length, P !== 0) + this.words[this.length] = P, this.length++; + else if (m !== this) + for (; _ < m.length; _++) + this.words[_] = m.words[_]; + return this; + }, s.prototype.add = function(l) { + var p; + return l.negative !== 0 && this.negative === 0 ? (l.negative = 0, p = this.sub(l), l.negative ^= 1, p) : l.negative === 0 && this.negative !== 0 ? (this.negative = 0, p = l.sub(this), this.negative = 1, p) : this.length > l.length ? this.clone().iadd(l) : l.clone().iadd(this); + }, s.prototype.isub = function(l) { + if (l.negative !== 0) { + l.negative = 0; + var p = this.iadd(l); + return l.negative = 1, p._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(l), this.negative = 1, this._normSign(); + var m = this.cmp(l); + if (m === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var w, P; + m > 0 ? (w = this, P = l) : (w = l, P = this); + for (var _ = 0, y = 0; y < P.length; y++) + p = (w.words[y] | 0) - (P.words[y] | 0) + _, _ = p >> 26, this.words[y] = p & 67108863; + for (; _ !== 0 && y < w.length; y++) + p = (w.words[y] | 0) + _, _ = p >> 26, this.words[y] = p & 67108863; + if (_ === 0 && y < w.length && w !== this) + for (; y < w.length; y++) + this.words[y] = w.words[y]; + return this.length = Math.max(this.length, y), w !== this && (this.negative = 1), this._strip(); + }, s.prototype.sub = function(l) { + return this.clone().isub(l); + }; + function k(b, l, p) { + p.negative = l.negative ^ b.negative; + var m = b.length + l.length | 0; + p.length = m, m = m - 1 | 0; + var w = b.words[0] | 0, P = l.words[0] | 0, _ = w * P, y = _ & 67108863, M = _ / 67108864 | 0; + p.words[0] = y; + for (var I = 1; I < m; I++) { + for (var q = M >>> 26, ce = M & 67108863, L = Math.min(I, l.length - 1), oe = Math.max(0, I - b.length + 1); oe <= L; oe++) { + var Q = I - oe | 0; + w = b.words[Q] | 0, P = l.words[oe] | 0, _ = w * P + ce, q += _ / 67108864 | 0, ce = _ & 67108863; + } + p.words[I] = ce | 0, M = q | 0; + } + return M !== 0 ? p.words[I] = M | 0 : p.length--, p._strip(); + } + var N = function(l, p, m) { + var w = l.words, P = p.words, _ = m.words, y = 0, M, I, q, ce = w[0] | 0, L = ce & 8191, oe = ce >>> 13, Q = w[1] | 0, X = Q & 8191, ee = Q >>> 13, O = w[2] | 0, Z = O & 8191, re = O >>> 13, he = w[3] | 0, ae = he & 8191, fe = he >>> 13, be = w[4] | 0, Ae = be & 8191, Te = be >>> 13, Re = w[5] | 0, $e = Re & 8191, Me = Re >>> 13, Oe = w[6] | 0, ze = Oe & 8191, De = Oe >>> 13, je = w[7] | 0, Ue = je & 8191, _e = je >>> 13, Ze = w[8] | 0, ot = Ze & 8191, ke = Ze >>> 13, rt = w[9] | 0, nt = rt & 8191, Ge = rt >>> 13, ht = P[0] | 0, lt = ht & 8191, ct = ht >>> 13, qt = P[1] | 0, Gt = qt & 8191, Et = qt >>> 13, Yt = P[2] | 0, tr = Yt & 8191, Tt = Yt >>> 13, kt = P[3] | 0, It = kt & 8191, dt = kt >>> 13, Dt = P[4] | 0, Nt = Dt & 8191, mt = Dt >>> 13, Bt = P[5] | 0, Ft = Bt & 8191, et = Bt >>> 13, $t = P[6] | 0, H = $t & 8191, V = $t >>> 13, Y = P[7] | 0, T = Y & 8191, F = Y >>> 13, ie = P[8] | 0, le = ie & 8191, me = ie >>> 13, Ee = P[9] | 0, Le = Ee & 8191, Ie = Ee >>> 13; + m.negative = l.negative ^ p.negative, m.length = 19, M = Math.imul(L, lt), I = Math.imul(L, ct), I = I + Math.imul(oe, lt) | 0, q = Math.imul(oe, ct); + var Qe = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (Qe >>> 26) | 0, Qe &= 67108863, M = Math.imul(X, lt), I = Math.imul(X, ct), I = I + Math.imul(ee, lt) | 0, q = Math.imul(ee, ct), M = M + Math.imul(L, Gt) | 0, I = I + Math.imul(L, Et) | 0, I = I + Math.imul(oe, Gt) | 0, q = q + Math.imul(oe, Et) | 0; + var Xe = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (Xe >>> 26) | 0, Xe &= 67108863, M = Math.imul(Z, lt), I = Math.imul(Z, ct), I = I + Math.imul(re, lt) | 0, q = Math.imul(re, ct), M = M + Math.imul(X, Gt) | 0, I = I + Math.imul(X, Et) | 0, I = I + Math.imul(ee, Gt) | 0, q = q + Math.imul(ee, Et) | 0, M = M + Math.imul(L, tr) | 0, I = I + Math.imul(L, Tt) | 0, I = I + Math.imul(oe, tr) | 0, q = q + Math.imul(oe, Tt) | 0; + var tt = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (tt >>> 26) | 0, tt &= 67108863, M = Math.imul(ae, lt), I = Math.imul(ae, ct), I = I + Math.imul(fe, lt) | 0, q = Math.imul(fe, ct), M = M + Math.imul(Z, Gt) | 0, I = I + Math.imul(Z, Et) | 0, I = I + Math.imul(re, Gt) | 0, q = q + Math.imul(re, Et) | 0, M = M + Math.imul(X, tr) | 0, I = I + Math.imul(X, Tt) | 0, I = I + Math.imul(ee, tr) | 0, q = q + Math.imul(ee, Tt) | 0, M = M + Math.imul(L, It) | 0, I = I + Math.imul(L, dt) | 0, I = I + Math.imul(oe, It) | 0, q = q + Math.imul(oe, dt) | 0; + var st = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (st >>> 26) | 0, st &= 67108863, M = Math.imul(Ae, lt), I = Math.imul(Ae, ct), I = I + Math.imul(Te, lt) | 0, q = Math.imul(Te, ct), M = M + Math.imul(ae, Gt) | 0, I = I + Math.imul(ae, Et) | 0, I = I + Math.imul(fe, Gt) | 0, q = q + Math.imul(fe, Et) | 0, M = M + Math.imul(Z, tr) | 0, I = I + Math.imul(Z, Tt) | 0, I = I + Math.imul(re, tr) | 0, q = q + Math.imul(re, Tt) | 0, M = M + Math.imul(X, It) | 0, I = I + Math.imul(X, dt) | 0, I = I + Math.imul(ee, It) | 0, q = q + Math.imul(ee, dt) | 0, M = M + Math.imul(L, Nt) | 0, I = I + Math.imul(L, mt) | 0, I = I + Math.imul(oe, Nt) | 0, q = q + Math.imul(oe, mt) | 0; + var vt = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (vt >>> 26) | 0, vt &= 67108863, M = Math.imul($e, lt), I = Math.imul($e, ct), I = I + Math.imul(Me, lt) | 0, q = Math.imul(Me, ct), M = M + Math.imul(Ae, Gt) | 0, I = I + Math.imul(Ae, Et) | 0, I = I + Math.imul(Te, Gt) | 0, q = q + Math.imul(Te, Et) | 0, M = M + Math.imul(ae, tr) | 0, I = I + Math.imul(ae, Tt) | 0, I = I + Math.imul(fe, tr) | 0, q = q + Math.imul(fe, Tt) | 0, M = M + Math.imul(Z, It) | 0, I = I + Math.imul(Z, dt) | 0, I = I + Math.imul(re, It) | 0, q = q + Math.imul(re, dt) | 0, M = M + Math.imul(X, Nt) | 0, I = I + Math.imul(X, mt) | 0, I = I + Math.imul(ee, Nt) | 0, q = q + Math.imul(ee, mt) | 0, M = M + Math.imul(L, Ft) | 0, I = I + Math.imul(L, et) | 0, I = I + Math.imul(oe, Ft) | 0, q = q + Math.imul(oe, et) | 0; + var Ct = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (Ct >>> 26) | 0, Ct &= 67108863, M = Math.imul(ze, lt), I = Math.imul(ze, ct), I = I + Math.imul(De, lt) | 0, q = Math.imul(De, ct), M = M + Math.imul($e, Gt) | 0, I = I + Math.imul($e, Et) | 0, I = I + Math.imul(Me, Gt) | 0, q = q + Math.imul(Me, Et) | 0, M = M + Math.imul(Ae, tr) | 0, I = I + Math.imul(Ae, Tt) | 0, I = I + Math.imul(Te, tr) | 0, q = q + Math.imul(Te, Tt) | 0, M = M + Math.imul(ae, It) | 0, I = I + Math.imul(ae, dt) | 0, I = I + Math.imul(fe, It) | 0, q = q + Math.imul(fe, dt) | 0, M = M + Math.imul(Z, Nt) | 0, I = I + Math.imul(Z, mt) | 0, I = I + Math.imul(re, Nt) | 0, q = q + Math.imul(re, mt) | 0, M = M + Math.imul(X, Ft) | 0, I = I + Math.imul(X, et) | 0, I = I + Math.imul(ee, Ft) | 0, q = q + Math.imul(ee, et) | 0, M = M + Math.imul(L, H) | 0, I = I + Math.imul(L, V) | 0, I = I + Math.imul(oe, H) | 0, q = q + Math.imul(oe, V) | 0; + var Mt = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (Mt >>> 26) | 0, Mt &= 67108863, M = Math.imul(Ue, lt), I = Math.imul(Ue, ct), I = I + Math.imul(_e, lt) | 0, q = Math.imul(_e, ct), M = M + Math.imul(ze, Gt) | 0, I = I + Math.imul(ze, Et) | 0, I = I + Math.imul(De, Gt) | 0, q = q + Math.imul(De, Et) | 0, M = M + Math.imul($e, tr) | 0, I = I + Math.imul($e, Tt) | 0, I = I + Math.imul(Me, tr) | 0, q = q + Math.imul(Me, Tt) | 0, M = M + Math.imul(Ae, It) | 0, I = I + Math.imul(Ae, dt) | 0, I = I + Math.imul(Te, It) | 0, q = q + Math.imul(Te, dt) | 0, M = M + Math.imul(ae, Nt) | 0, I = I + Math.imul(ae, mt) | 0, I = I + Math.imul(fe, Nt) | 0, q = q + Math.imul(fe, mt) | 0, M = M + Math.imul(Z, Ft) | 0, I = I + Math.imul(Z, et) | 0, I = I + Math.imul(re, Ft) | 0, q = q + Math.imul(re, et) | 0, M = M + Math.imul(X, H) | 0, I = I + Math.imul(X, V) | 0, I = I + Math.imul(ee, H) | 0, q = q + Math.imul(ee, V) | 0, M = M + Math.imul(L, T) | 0, I = I + Math.imul(L, F) | 0, I = I + Math.imul(oe, T) | 0, q = q + Math.imul(oe, F) | 0; + var wt = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (wt >>> 26) | 0, wt &= 67108863, M = Math.imul(ot, lt), I = Math.imul(ot, ct), I = I + Math.imul(ke, lt) | 0, q = Math.imul(ke, ct), M = M + Math.imul(Ue, Gt) | 0, I = I + Math.imul(Ue, Et) | 0, I = I + Math.imul(_e, Gt) | 0, q = q + Math.imul(_e, Et) | 0, M = M + Math.imul(ze, tr) | 0, I = I + Math.imul(ze, Tt) | 0, I = I + Math.imul(De, tr) | 0, q = q + Math.imul(De, Tt) | 0, M = M + Math.imul($e, It) | 0, I = I + Math.imul($e, dt) | 0, I = I + Math.imul(Me, It) | 0, q = q + Math.imul(Me, dt) | 0, M = M + Math.imul(Ae, Nt) | 0, I = I + Math.imul(Ae, mt) | 0, I = I + Math.imul(Te, Nt) | 0, q = q + Math.imul(Te, mt) | 0, M = M + Math.imul(ae, Ft) | 0, I = I + Math.imul(ae, et) | 0, I = I + Math.imul(fe, Ft) | 0, q = q + Math.imul(fe, et) | 0, M = M + Math.imul(Z, H) | 0, I = I + Math.imul(Z, V) | 0, I = I + Math.imul(re, H) | 0, q = q + Math.imul(re, V) | 0, M = M + Math.imul(X, T) | 0, I = I + Math.imul(X, F) | 0, I = I + Math.imul(ee, T) | 0, q = q + Math.imul(ee, F) | 0, M = M + Math.imul(L, le) | 0, I = I + Math.imul(L, me) | 0, I = I + Math.imul(oe, le) | 0, q = q + Math.imul(oe, me) | 0; + var Rt = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (Rt >>> 26) | 0, Rt &= 67108863, M = Math.imul(nt, lt), I = Math.imul(nt, ct), I = I + Math.imul(Ge, lt) | 0, q = Math.imul(Ge, ct), M = M + Math.imul(ot, Gt) | 0, I = I + Math.imul(ot, Et) | 0, I = I + Math.imul(ke, Gt) | 0, q = q + Math.imul(ke, Et) | 0, M = M + Math.imul(Ue, tr) | 0, I = I + Math.imul(Ue, Tt) | 0, I = I + Math.imul(_e, tr) | 0, q = q + Math.imul(_e, Tt) | 0, M = M + Math.imul(ze, It) | 0, I = I + Math.imul(ze, dt) | 0, I = I + Math.imul(De, It) | 0, q = q + Math.imul(De, dt) | 0, M = M + Math.imul($e, Nt) | 0, I = I + Math.imul($e, mt) | 0, I = I + Math.imul(Me, Nt) | 0, q = q + Math.imul(Me, mt) | 0, M = M + Math.imul(Ae, Ft) | 0, I = I + Math.imul(Ae, et) | 0, I = I + Math.imul(Te, Ft) | 0, q = q + Math.imul(Te, et) | 0, M = M + Math.imul(ae, H) | 0, I = I + Math.imul(ae, V) | 0, I = I + Math.imul(fe, H) | 0, q = q + Math.imul(fe, V) | 0, M = M + Math.imul(Z, T) | 0, I = I + Math.imul(Z, F) | 0, I = I + Math.imul(re, T) | 0, q = q + Math.imul(re, F) | 0, M = M + Math.imul(X, le) | 0, I = I + Math.imul(X, me) | 0, I = I + Math.imul(ee, le) | 0, q = q + Math.imul(ee, me) | 0, M = M + Math.imul(L, Le) | 0, I = I + Math.imul(L, Ie) | 0, I = I + Math.imul(oe, Le) | 0, q = q + Math.imul(oe, Ie) | 0; + var gt = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (gt >>> 26) | 0, gt &= 67108863, M = Math.imul(nt, Gt), I = Math.imul(nt, Et), I = I + Math.imul(Ge, Gt) | 0, q = Math.imul(Ge, Et), M = M + Math.imul(ot, tr) | 0, I = I + Math.imul(ot, Tt) | 0, I = I + Math.imul(ke, tr) | 0, q = q + Math.imul(ke, Tt) | 0, M = M + Math.imul(Ue, It) | 0, I = I + Math.imul(Ue, dt) | 0, I = I + Math.imul(_e, It) | 0, q = q + Math.imul(_e, dt) | 0, M = M + Math.imul(ze, Nt) | 0, I = I + Math.imul(ze, mt) | 0, I = I + Math.imul(De, Nt) | 0, q = q + Math.imul(De, mt) | 0, M = M + Math.imul($e, Ft) | 0, I = I + Math.imul($e, et) | 0, I = I + Math.imul(Me, Ft) | 0, q = q + Math.imul(Me, et) | 0, M = M + Math.imul(Ae, H) | 0, I = I + Math.imul(Ae, V) | 0, I = I + Math.imul(Te, H) | 0, q = q + Math.imul(Te, V) | 0, M = M + Math.imul(ae, T) | 0, I = I + Math.imul(ae, F) | 0, I = I + Math.imul(fe, T) | 0, q = q + Math.imul(fe, F) | 0, M = M + Math.imul(Z, le) | 0, I = I + Math.imul(Z, me) | 0, I = I + Math.imul(re, le) | 0, q = q + Math.imul(re, me) | 0, M = M + Math.imul(X, Le) | 0, I = I + Math.imul(X, Ie) | 0, I = I + Math.imul(ee, Le) | 0, q = q + Math.imul(ee, Ie) | 0; + var _t = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, M = Math.imul(nt, tr), I = Math.imul(nt, Tt), I = I + Math.imul(Ge, tr) | 0, q = Math.imul(Ge, Tt), M = M + Math.imul(ot, It) | 0, I = I + Math.imul(ot, dt) | 0, I = I + Math.imul(ke, It) | 0, q = q + Math.imul(ke, dt) | 0, M = M + Math.imul(Ue, Nt) | 0, I = I + Math.imul(Ue, mt) | 0, I = I + Math.imul(_e, Nt) | 0, q = q + Math.imul(_e, mt) | 0, M = M + Math.imul(ze, Ft) | 0, I = I + Math.imul(ze, et) | 0, I = I + Math.imul(De, Ft) | 0, q = q + Math.imul(De, et) | 0, M = M + Math.imul($e, H) | 0, I = I + Math.imul($e, V) | 0, I = I + Math.imul(Me, H) | 0, q = q + Math.imul(Me, V) | 0, M = M + Math.imul(Ae, T) | 0, I = I + Math.imul(Ae, F) | 0, I = I + Math.imul(Te, T) | 0, q = q + Math.imul(Te, F) | 0, M = M + Math.imul(ae, le) | 0, I = I + Math.imul(ae, me) | 0, I = I + Math.imul(fe, le) | 0, q = q + Math.imul(fe, me) | 0, M = M + Math.imul(Z, Le) | 0, I = I + Math.imul(Z, Ie) | 0, I = I + Math.imul(re, Le) | 0, q = q + Math.imul(re, Ie) | 0; + var at = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (at >>> 26) | 0, at &= 67108863, M = Math.imul(nt, It), I = Math.imul(nt, dt), I = I + Math.imul(Ge, It) | 0, q = Math.imul(Ge, dt), M = M + Math.imul(ot, Nt) | 0, I = I + Math.imul(ot, mt) | 0, I = I + Math.imul(ke, Nt) | 0, q = q + Math.imul(ke, mt) | 0, M = M + Math.imul(Ue, Ft) | 0, I = I + Math.imul(Ue, et) | 0, I = I + Math.imul(_e, Ft) | 0, q = q + Math.imul(_e, et) | 0, M = M + Math.imul(ze, H) | 0, I = I + Math.imul(ze, V) | 0, I = I + Math.imul(De, H) | 0, q = q + Math.imul(De, V) | 0, M = M + Math.imul($e, T) | 0, I = I + Math.imul($e, F) | 0, I = I + Math.imul(Me, T) | 0, q = q + Math.imul(Me, F) | 0, M = M + Math.imul(Ae, le) | 0, I = I + Math.imul(Ae, me) | 0, I = I + Math.imul(Te, le) | 0, q = q + Math.imul(Te, me) | 0, M = M + Math.imul(ae, Le) | 0, I = I + Math.imul(ae, Ie) | 0, I = I + Math.imul(fe, Le) | 0, q = q + Math.imul(fe, Ie) | 0; + var yt = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (yt >>> 26) | 0, yt &= 67108863, M = Math.imul(nt, Nt), I = Math.imul(nt, mt), I = I + Math.imul(Ge, Nt) | 0, q = Math.imul(Ge, mt), M = M + Math.imul(ot, Ft) | 0, I = I + Math.imul(ot, et) | 0, I = I + Math.imul(ke, Ft) | 0, q = q + Math.imul(ke, et) | 0, M = M + Math.imul(Ue, H) | 0, I = I + Math.imul(Ue, V) | 0, I = I + Math.imul(_e, H) | 0, q = q + Math.imul(_e, V) | 0, M = M + Math.imul(ze, T) | 0, I = I + Math.imul(ze, F) | 0, I = I + Math.imul(De, T) | 0, q = q + Math.imul(De, F) | 0, M = M + Math.imul($e, le) | 0, I = I + Math.imul($e, me) | 0, I = I + Math.imul(Me, le) | 0, q = q + Math.imul(Me, me) | 0, M = M + Math.imul(Ae, Le) | 0, I = I + Math.imul(Ae, Ie) | 0, I = I + Math.imul(Te, Le) | 0, q = q + Math.imul(Te, Ie) | 0; + var ut = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (ut >>> 26) | 0, ut &= 67108863, M = Math.imul(nt, Ft), I = Math.imul(nt, et), I = I + Math.imul(Ge, Ft) | 0, q = Math.imul(Ge, et), M = M + Math.imul(ot, H) | 0, I = I + Math.imul(ot, V) | 0, I = I + Math.imul(ke, H) | 0, q = q + Math.imul(ke, V) | 0, M = M + Math.imul(Ue, T) | 0, I = I + Math.imul(Ue, F) | 0, I = I + Math.imul(_e, T) | 0, q = q + Math.imul(_e, F) | 0, M = M + Math.imul(ze, le) | 0, I = I + Math.imul(ze, me) | 0, I = I + Math.imul(De, le) | 0, q = q + Math.imul(De, me) | 0, M = M + Math.imul($e, Le) | 0, I = I + Math.imul($e, Ie) | 0, I = I + Math.imul(Me, Le) | 0, q = q + Math.imul(Me, Ie) | 0; + var it = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (it >>> 26) | 0, it &= 67108863, M = Math.imul(nt, H), I = Math.imul(nt, V), I = I + Math.imul(Ge, H) | 0, q = Math.imul(Ge, V), M = M + Math.imul(ot, T) | 0, I = I + Math.imul(ot, F) | 0, I = I + Math.imul(ke, T) | 0, q = q + Math.imul(ke, F) | 0, M = M + Math.imul(Ue, le) | 0, I = I + Math.imul(Ue, me) | 0, I = I + Math.imul(_e, le) | 0, q = q + Math.imul(_e, me) | 0, M = M + Math.imul(ze, Le) | 0, I = I + Math.imul(ze, Ie) | 0, I = I + Math.imul(De, Le) | 0, q = q + Math.imul(De, Ie) | 0; + var Se = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (Se >>> 26) | 0, Se &= 67108863, M = Math.imul(nt, T), I = Math.imul(nt, F), I = I + Math.imul(Ge, T) | 0, q = Math.imul(Ge, F), M = M + Math.imul(ot, le) | 0, I = I + Math.imul(ot, me) | 0, I = I + Math.imul(ke, le) | 0, q = q + Math.imul(ke, me) | 0, M = M + Math.imul(Ue, Le) | 0, I = I + Math.imul(Ue, Ie) | 0, I = I + Math.imul(_e, Le) | 0, q = q + Math.imul(_e, Ie) | 0; + var Pe = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (Pe >>> 26) | 0, Pe &= 67108863, M = Math.imul(nt, le), I = Math.imul(nt, me), I = I + Math.imul(Ge, le) | 0, q = Math.imul(Ge, me), M = M + Math.imul(ot, Le) | 0, I = I + Math.imul(ot, Ie) | 0, I = I + Math.imul(ke, Le) | 0, q = q + Math.imul(ke, Ie) | 0; + var Ke = (y + M | 0) + ((I & 8191) << 13) | 0; + y = (q + (I >>> 13) | 0) + (Ke >>> 26) | 0, Ke &= 67108863, M = Math.imul(nt, Le), I = Math.imul(nt, Ie), I = I + Math.imul(Ge, Le) | 0, q = Math.imul(Ge, Ie); + var Fe = (y + M | 0) + ((I & 8191) << 13) | 0; + return y = (q + (I >>> 13) | 0) + (Fe >>> 26) | 0, Fe &= 67108863, _[0] = Qe, _[1] = Xe, _[2] = tt, _[3] = st, _[4] = vt, _[5] = Ct, _[6] = Mt, _[7] = wt, _[8] = Rt, _[9] = gt, _[10] = _t, _[11] = at, _[12] = yt, _[13] = ut, _[14] = it, _[15] = Se, _[16] = Pe, _[17] = Ke, _[18] = Fe, y !== 0 && (_[19] = y, m.length++), m; + }; + Math.imul || (N = k); + function z(b, l, p) { + p.negative = l.negative ^ b.negative, p.length = b.length + l.length; + for (var m = 0, w = 0, P = 0; P < p.length - 1; P++) { + var _ = w; + w = 0; + for (var y = m & 67108863, M = Math.min(P, l.length - 1), I = Math.max(0, P - b.length + 1); I <= M; I++) { + var q = P - I, ce = b.words[q] | 0, L = l.words[I] | 0, oe = ce * L, Q = oe & 67108863; + _ = _ + (oe / 67108864 | 0) | 0, Q = Q + y | 0, y = Q & 67108863, _ = _ + (Q >>> 26) | 0, w += _ >>> 26, _ &= 67108863; + } + p.words[P] = y, m = _, _ = w; + } + return m !== 0 ? p.words[P] = m : p.length--, p._strip(); + } + function B(b, l, p) { + return z(b, l, p); + } + s.prototype.mulTo = function(l, p) { + var m, w = this.length + l.length; + return this.length === 10 && l.length === 10 ? m = N(this, l, p) : w < 63 ? m = k(this, l, p) : w < 1024 ? m = z(this, l, p) : m = B(this, l, p), m; + }, s.prototype.mul = function(l) { + var p = new s(null); + return p.words = new Array(this.length + l.length), this.mulTo(l, p); + }, s.prototype.mulf = function(l) { + var p = new s(null); + return p.words = new Array(this.length + l.length), B(this, l, p); + }, s.prototype.imul = function(l) { + return this.clone().mulTo(l, this); + }, s.prototype.imuln = function(l) { + var p = l < 0; + p && (l = -l), n(typeof l == "number"), n(l < 67108864); + for (var m = 0, w = 0; w < this.length; w++) { + var P = (this.words[w] | 0) * l, _ = (P & 67108863) + (m & 67108863); + m >>= 26, m += P / 67108864 | 0, m += _ >>> 26, this.words[w] = _ & 67108863; + } + return m !== 0 && (this.words[w] = m, this.length++), p ? this.ineg() : this; + }, s.prototype.muln = function(l) { + return this.clone().imuln(l); + }, s.prototype.sqr = function() { + return this.mul(this); + }, s.prototype.isqr = function() { + return this.imul(this.clone()); + }, s.prototype.pow = function(l) { + var p = D(l); + if (p.length === 0) return new s(1); + for (var m = this, w = 0; w < p.length && p[w] === 0; w++, m = m.sqr()) + ; + if (++w < p.length) + for (var P = m.sqr(); w < p.length; w++, P = P.sqr()) + p[w] !== 0 && (m = m.mul(P)); + return m; + }, s.prototype.iushln = function(l) { + n(typeof l == "number" && l >= 0); + var p = l % 26, m = (l - p) / 26, w = 67108863 >>> 26 - p << 26 - p, P; + if (p !== 0) { + var _ = 0; + for (P = 0; P < this.length; P++) { + var y = this.words[P] & w, M = (this.words[P] | 0) - y << p; + this.words[P] = M | _, _ = y >>> 26 - p; + } + _ && (this.words[P] = _, this.length++); + } + if (m !== 0) { + for (P = this.length - 1; P >= 0; P--) + this.words[P + m] = this.words[P]; + for (P = 0; P < m; P++) + this.words[P] = 0; + this.length += m; + } + return this._strip(); + }, s.prototype.ishln = function(l) { + return n(this.negative === 0), this.iushln(l); + }, s.prototype.iushrn = function(l, p, m) { + n(typeof l == "number" && l >= 0); + var w; + p ? w = (p - p % 26) / 26 : w = 0; + var P = l % 26, _ = Math.min((l - P) / 26, this.length), y = 67108863 ^ 67108863 >>> P << P, M = m; + if (w -= _, w = Math.max(0, w), M) { + for (var I = 0; I < _; I++) + M.words[I] = this.words[I]; + M.length = _; + } + if (_ !== 0) if (this.length > _) + for (this.length -= _, I = 0; I < this.length; I++) + this.words[I] = this.words[I + _]; + else + this.words[0] = 0, this.length = 1; + var q = 0; + for (I = this.length - 1; I >= 0 && (q !== 0 || I >= w); I--) { + var ce = this.words[I] | 0; + this.words[I] = q << 26 - P | ce >>> P, q = ce & y; + } + return M && q !== 0 && (M.words[M.length++] = q), this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip(); + }, s.prototype.ishrn = function(l, p, m) { + return n(this.negative === 0), this.iushrn(l, p, m); + }, s.prototype.shln = function(l) { + return this.clone().ishln(l); + }, s.prototype.ushln = function(l) { + return this.clone().iushln(l); + }, s.prototype.shrn = function(l) { + return this.clone().ishrn(l); + }, s.prototype.ushrn = function(l) { + return this.clone().iushrn(l); + }, s.prototype.testn = function(l) { + n(typeof l == "number" && l >= 0); + var p = l % 26, m = (l - p) / 26, w = 1 << p; + if (this.length <= m) return !1; + var P = this.words[m]; + return !!(P & w); + }, s.prototype.imaskn = function(l) { + n(typeof l == "number" && l >= 0); + var p = l % 26, m = (l - p) / 26; + if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= m) + return this; + if (p !== 0 && m++, this.length = Math.min(m, this.length), p !== 0) { + var w = 67108863 ^ 67108863 >>> p << p; + this.words[this.length - 1] &= w; + } + return this._strip(); + }, s.prototype.maskn = function(l) { + return this.clone().imaskn(l); + }, s.prototype.iaddn = function(l) { + return n(typeof l == "number"), n(l < 67108864), l < 0 ? this.isubn(-l) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) <= l ? (this.words[0] = l - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(l), this.negative = 1, this) : this._iaddn(l); + }, s.prototype._iaddn = function(l) { + this.words[0] += l; + for (var p = 0; p < this.length && this.words[p] >= 67108864; p++) + this.words[p] -= 67108864, p === this.length - 1 ? this.words[p + 1] = 1 : this.words[p + 1]++; + return this.length = Math.max(this.length, p + 1), this; + }, s.prototype.isubn = function(l) { + if (n(typeof l == "number"), n(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 p = 0; p < this.length && this.words[p] < 0; p++) + this.words[p] += 67108864, this.words[p + 1] -= 1; + return this._strip(); + }, s.prototype.addn = function(l) { + return this.clone().iaddn(l); + }, s.prototype.subn = function(l) { + return this.clone().isubn(l); + }, s.prototype.iabs = function() { + return this.negative = 0, this; + }, s.prototype.abs = function() { + return this.clone().iabs(); + }, s.prototype._ishlnsubmul = function(l, p, m) { + var w = l.length + m, P; + this._expand(w); + var _, y = 0; + for (P = 0; P < l.length; P++) { + _ = (this.words[P + m] | 0) + y; + var M = (l.words[P] | 0) * p; + _ -= M & 67108863, y = (_ >> 26) - (M / 67108864 | 0), this.words[P + m] = _ & 67108863; + } + for (; P < this.length - m; P++) + _ = (this.words[P + m] | 0) + y, y = _ >> 26, this.words[P + m] = _ & 67108863; + if (y === 0) return this._strip(); + for (n(y === -1), y = 0, P = 0; P < this.length; P++) + _ = -(this.words[P] | 0) + y, y = _ >> 26, this.words[P] = _ & 67108863; + return this.negative = 1, this._strip(); + }, s.prototype._wordDiv = function(l, p) { + var m = this.length - l.length, w = this.clone(), P = l, _ = P.words[P.length - 1] | 0, y = this._countBits(_); + m = 26 - y, m !== 0 && (P = P.ushln(m), w.iushln(m), _ = P.words[P.length - 1] | 0); + var M = w.length - P.length, I; + if (p !== "mod") { + I = new s(null), I.length = M + 1, I.words = new Array(I.length); + for (var q = 0; q < I.length; q++) + I.words[q] = 0; + } + var ce = w.clone()._ishlnsubmul(P, 1, M); + ce.negative === 0 && (w = ce, I && (I.words[M] = 1)); + for (var L = M - 1; L >= 0; L--) { + var oe = (w.words[P.length + L] | 0) * 67108864 + (w.words[P.length + L - 1] | 0); + for (oe = Math.min(oe / _ | 0, 67108863), w._ishlnsubmul(P, oe, L); w.negative !== 0; ) + oe--, w.negative = 0, w._ishlnsubmul(P, 1, L), w.isZero() || (w.negative ^= 1); + I && (I.words[L] = oe); + } + return I && I._strip(), w._strip(), p !== "div" && m !== 0 && w.iushrn(m), { + div: I || null, + mod: w + }; + }, s.prototype.divmod = function(l, p, m) { + if (n(!l.isZero()), this.isZero()) + return { + div: new s(0), + mod: new s(0) + }; + var w, P, _; + return this.negative !== 0 && l.negative === 0 ? (_ = this.neg().divmod(l, p), p !== "mod" && (w = _.div.neg()), p !== "div" && (P = _.mod.neg(), m && P.negative !== 0 && P.iadd(l)), { + div: w, + mod: P + }) : this.negative === 0 && l.negative !== 0 ? (_ = this.divmod(l.neg(), p), p !== "mod" && (w = _.div.neg()), { + div: w, + mod: _.mod + }) : (this.negative & l.negative) !== 0 ? (_ = this.neg().divmod(l.neg(), p), p !== "div" && (P = _.mod.neg(), m && P.negative !== 0 && P.isub(l)), { + div: _.div, + mod: P + }) : l.length > this.length || this.cmp(l) < 0 ? { + div: new s(0), + mod: this + } : l.length === 1 ? p === "div" ? { + div: this.divn(l.words[0]), + mod: null + } : p === "mod" ? { + div: null, + mod: new s(this.modrn(l.words[0])) + } : { + div: this.divn(l.words[0]), + mod: new s(this.modrn(l.words[0])) + } : this._wordDiv(l, p); + }, s.prototype.div = function(l) { + return this.divmod(l, "div", !1).div; + }, s.prototype.mod = function(l) { + return this.divmod(l, "mod", !1).mod; + }, s.prototype.umod = function(l) { + return this.divmod(l, "mod", !0).mod; + }, s.prototype.divRound = function(l) { + var p = this.divmod(l); + if (p.mod.isZero()) return p.div; + var m = p.div.negative !== 0 ? p.mod.isub(l) : p.mod, w = l.ushrn(1), P = l.andln(1), _ = m.cmp(w); + return _ < 0 || P === 1 && _ === 0 ? p.div : p.div.negative !== 0 ? p.div.isubn(1) : p.div.iaddn(1); + }, s.prototype.modrn = function(l) { + var p = l < 0; + p && (l = -l), n(l <= 67108863); + for (var m = (1 << 26) % l, w = 0, P = this.length - 1; P >= 0; P--) + w = (m * w + (this.words[P] | 0)) % l; + return p ? -w : w; + }, s.prototype.modn = function(l) { + return this.modrn(l); + }, s.prototype.idivn = function(l) { + var p = l < 0; + p && (l = -l), n(l <= 67108863); + for (var m = 0, w = this.length - 1; w >= 0; w--) { + var P = (this.words[w] | 0) + m * 67108864; + this.words[w] = P / l | 0, m = P % l; + } + return this._strip(), p ? this.ineg() : this; + }, s.prototype.divn = function(l) { + return this.clone().idivn(l); + }, s.prototype.egcd = function(l) { + n(l.negative === 0), n(!l.isZero()); + var p = this, m = l.clone(); + p.negative !== 0 ? p = p.umod(l) : p = p.clone(); + for (var w = new s(1), P = new s(0), _ = new s(0), y = new s(1), M = 0; p.isEven() && m.isEven(); ) + p.iushrn(1), m.iushrn(1), ++M; + for (var I = m.clone(), q = p.clone(); !p.isZero(); ) { + for (var ce = 0, L = 1; (p.words[0] & L) === 0 && ce < 26; ++ce, L <<= 1) ; + if (ce > 0) + for (p.iushrn(ce); ce-- > 0; ) + (w.isOdd() || P.isOdd()) && (w.iadd(I), P.isub(q)), w.iushrn(1), P.iushrn(1); + for (var oe = 0, Q = 1; (m.words[0] & Q) === 0 && oe < 26; ++oe, Q <<= 1) ; + if (oe > 0) + for (m.iushrn(oe); oe-- > 0; ) + (_.isOdd() || y.isOdd()) && (_.iadd(I), y.isub(q)), _.iushrn(1), y.iushrn(1); + p.cmp(m) >= 0 ? (p.isub(m), w.isub(_), P.isub(y)) : (m.isub(p), _.isub(w), y.isub(P)); + } + return { + a: _, + b: y, + gcd: m.iushln(M) + }; + }, s.prototype._invmp = function(l) { + n(l.negative === 0), n(!l.isZero()); + var p = this, m = l.clone(); + p.negative !== 0 ? p = p.umod(l) : p = p.clone(); + for (var w = new s(1), P = new s(0), _ = m.clone(); p.cmpn(1) > 0 && m.cmpn(1) > 0; ) { + for (var y = 0, M = 1; (p.words[0] & M) === 0 && y < 26; ++y, M <<= 1) ; + if (y > 0) + for (p.iushrn(y); y-- > 0; ) + w.isOdd() && w.iadd(_), w.iushrn(1); + for (var I = 0, q = 1; (m.words[0] & q) === 0 && I < 26; ++I, q <<= 1) ; + if (I > 0) + for (m.iushrn(I); I-- > 0; ) + P.isOdd() && P.iadd(_), P.iushrn(1); + p.cmp(m) >= 0 ? (p.isub(m), w.isub(P)) : (m.isub(p), P.isub(w)); + } + var ce; + return p.cmpn(1) === 0 ? ce = w : ce = P, ce.cmpn(0) < 0 && ce.iadd(l), ce; + }, s.prototype.gcd = function(l) { + if (this.isZero()) return l.abs(); + if (l.isZero()) return this.abs(); + var p = this.clone(), m = l.clone(); + p.negative = 0, m.negative = 0; + for (var w = 0; p.isEven() && m.isEven(); w++) + p.iushrn(1), m.iushrn(1); + do { + for (; p.isEven(); ) + p.iushrn(1); + for (; m.isEven(); ) + m.iushrn(1); + var P = p.cmp(m); + if (P < 0) { + var _ = p; + p = m, m = _; + } else if (P === 0 || m.cmpn(1) === 0) + break; + p.isub(m); + } while (!0); + return m.iushln(w); + }, s.prototype.invm = function(l) { + return this.egcd(l).a.umod(l); + }, s.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, s.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, s.prototype.andln = function(l) { + return this.words[0] & l; + }, s.prototype.bincn = function(l) { + n(typeof l == "number"); + var p = l % 26, m = (l - p) / 26, w = 1 << p; + if (this.length <= m) + return this._expand(m + 1), this.words[m] |= w, this; + for (var P = w, _ = m; P !== 0 && _ < this.length; _++) { + var y = this.words[_] | 0; + y += P, P = y >>> 26, y &= 67108863, this.words[_] = y; + } + return P !== 0 && (this.words[_] = P, this.length++), this; + }, s.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, s.prototype.cmpn = function(l) { + var p = l < 0; + if (this.negative !== 0 && !p) return -1; + if (this.negative === 0 && p) return 1; + this._strip(); + var m; + if (this.length > 1) + m = 1; + else { + p && (l = -l), n(l <= 67108863, "Number is too big"); + var w = this.words[0] | 0; + m = w === l ? 0 : w < l ? -1 : 1; + } + return this.negative !== 0 ? -m | 0 : m; + }, s.prototype.cmp = function(l) { + if (this.negative !== 0 && l.negative === 0) return -1; + if (this.negative === 0 && l.negative !== 0) return 1; + var p = this.ucmp(l); + return this.negative !== 0 ? -p | 0 : p; + }, s.prototype.ucmp = function(l) { + if (this.length > l.length) return 1; + if (this.length < l.length) return -1; + for (var p = 0, m = this.length - 1; m >= 0; m--) { + var w = this.words[m] | 0, P = l.words[m] | 0; + if (w !== P) { + w < P ? p = -1 : w > P && (p = 1); + break; + } + } + return p; + }, s.prototype.gtn = function(l) { + return this.cmpn(l) === 1; + }, s.prototype.gt = function(l) { + return this.cmp(l) === 1; + }, s.prototype.gten = function(l) { + return this.cmpn(l) >= 0; + }, s.prototype.gte = function(l) { + return this.cmp(l) >= 0; + }, s.prototype.ltn = function(l) { + return this.cmpn(l) === -1; + }, s.prototype.lt = function(l) { + return this.cmp(l) === -1; + }, s.prototype.lten = function(l) { + return this.cmpn(l) <= 0; + }, s.prototype.lte = function(l) { + return this.cmp(l) <= 0; + }, s.prototype.eqn = function(l) { + return this.cmpn(l) === 0; + }, s.prototype.eq = function(l) { + return this.cmp(l) === 0; + }, s.red = function(l) { + return new K(l); + }, s.prototype.toRed = function(l) { + return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), l.convertTo(this)._forceRed(l); + }, s.prototype.fromRed = function() { + return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, s.prototype._forceRed = function(l) { + return this.red = l, this; + }, s.prototype.forceRed = function(l) { + return n(!this.red, "Already a number in reduction context"), this._forceRed(l); + }, s.prototype.redAdd = function(l) { + return n(this.red, "redAdd works only with red numbers"), this.red.add(this, l); + }, s.prototype.redIAdd = function(l) { + return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, l); + }, s.prototype.redSub = function(l) { + return n(this.red, "redSub works only with red numbers"), this.red.sub(this, l); + }, s.prototype.redISub = function(l) { + return n(this.red, "redISub works only with red numbers"), this.red.isub(this, l); + }, s.prototype.redShl = function(l) { + return n(this.red, "redShl works only with red numbers"), this.red.shl(this, l); + }, s.prototype.redMul = function(l) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, l), this.red.mul(this, l); + }, s.prototype.redIMul = function(l) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, l), this.red.imul(this, l); + }, s.prototype.redSqr = function() { + return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, s.prototype.redISqr = function() { + return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, s.prototype.redSqrt = function() { + return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, s.prototype.redInvm = function() { + return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, s.prototype.redNeg = function() { + return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, s.prototype.redPow = function(l) { + return n(this.red && !l.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, l); + }; + var $ = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function U(b, l) { + this.name = b, this.p = new s(l, 16), this.n = this.p.bitLength(), this.k = new s(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + U.prototype._tmp = function() { + var l = new s(null); + return l.words = new Array(Math.ceil(this.n / 13)), l; + }, U.prototype.ireduce = function(l) { + var p = l, m; + do + this.split(p, this.tmp), p = this.imulK(p), p = p.iadd(this.tmp), m = p.bitLength(); + while (m > this.n); + var w = m < this.n ? -1 : p.ucmp(this.p); + return w === 0 ? (p.words[0] = 0, p.length = 1) : w > 0 ? p.isub(this.p) : p.strip !== void 0 ? p.strip() : p._strip(), p; + }, U.prototype.split = function(l, p) { + l.iushrn(this.n, 0, p); + }, U.prototype.imulK = function(l) { + return l.imul(this.k); + }; + function C() { + U.call( + this, + "k256", + "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f" + ); + } + i(C, U), C.prototype.split = function(l, p) { + for (var m = 4194303, w = Math.min(l.length, 9), P = 0; P < w; P++) + p.words[P] = l.words[P]; + if (p.length = w, l.length <= 9) { + l.words[0] = 0, l.length = 1; + return; + } + var _ = l.words[9]; + for (p.words[p.length++] = _ & m, P = 10; P < l.length; P++) { + var y = l.words[P] | 0; + l.words[P - 10] = (y & m) << 4 | _ >>> 22, _ = y; + } + _ >>>= 22, l.words[P - 10] = _, _ === 0 && l.length > 10 ? l.length -= 10 : l.length -= 9; + }, C.prototype.imulK = function(l) { + l.words[l.length] = 0, l.words[l.length + 1] = 0, l.length += 2; + for (var p = 0, m = 0; m < l.length; m++) { + var w = l.words[m] | 0; + p += w * 977, l.words[m] = p & 67108863, p = w * 64 + (p / 67108864 | 0); + } + return l.words[l.length - 1] === 0 && (l.length--, l.words[l.length - 1] === 0 && l.length--), l; + }; + function W() { + U.call( + this, + "p224", + "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001" + ); + } + i(W, U); + function J() { + U.call( + this, + "p192", + "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff" + ); + } + i(J, U); + function ne() { + U.call( + this, + "25519", + "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed" + ); + } + i(ne, U), ne.prototype.imulK = function(l) { + for (var p = 0, m = 0; m < l.length; m++) { + var w = (l.words[m] | 0) * 19 + p, P = w & 67108863; + w >>>= 26, l.words[m] = P, p = w; + } + return p !== 0 && (l.words[l.length++] = p), l; + }, s._prime = function(l) { + if ($[l]) return $[l]; + var p; + if (l === "k256") + p = new C(); + else if (l === "p224") + p = new W(); + else if (l === "p192") + p = new J(); + else if (l === "p25519") + p = new ne(); + else + throw new Error("Unknown prime " + l); + return $[l] = p, p; + }; + function K(b) { + if (typeof b == "string") { + var l = s._prime(b); + this.m = l.p, this.prime = l; + } else + n(b.gtn(1), "modulus must be greater than 1"), this.m = b, this.prime = null; + } + K.prototype._verify1 = function(l) { + n(l.negative === 0, "red works only with positives"), n(l.red, "red works only with red numbers"); + }, K.prototype._verify2 = function(l, p) { + n((l.negative | p.negative) === 0, "red works only with positives"), n( + l.red && l.red === p.red, + "red works only with red numbers" + ); + }, K.prototype.imod = function(l) { + return this.prime ? this.prime.ireduce(l)._forceRed(this) : (h(l, l.umod(this.m)._forceRed(this)), l); + }, K.prototype.neg = function(l) { + return l.isZero() ? l.clone() : this.m.sub(l)._forceRed(this); + }, K.prototype.add = function(l, p) { + this._verify2(l, p); + var m = l.add(p); + return m.cmp(this.m) >= 0 && m.isub(this.m), m._forceRed(this); + }, K.prototype.iadd = function(l, p) { + this._verify2(l, p); + var m = l.iadd(p); + return m.cmp(this.m) >= 0 && m.isub(this.m), m; + }, K.prototype.sub = function(l, p) { + this._verify2(l, p); + var m = l.sub(p); + return m.cmpn(0) < 0 && m.iadd(this.m), m._forceRed(this); + }, K.prototype.isub = function(l, p) { + this._verify2(l, p); + var m = l.isub(p); + return m.cmpn(0) < 0 && m.iadd(this.m), m; + }, K.prototype.shl = function(l, p) { + return this._verify1(l), this.imod(l.ushln(p)); + }, K.prototype.imul = function(l, p) { + return this._verify2(l, p), this.imod(l.imul(p)); + }, K.prototype.mul = function(l, p) { + return this._verify2(l, p), this.imod(l.mul(p)); + }, K.prototype.isqr = function(l) { + return this.imul(l, l.clone()); + }, K.prototype.sqr = function(l) { + return this.mul(l, l); + }, K.prototype.sqrt = function(l) { + if (l.isZero()) return l.clone(); + var p = this.m.andln(3); + if (n(p % 2 === 1), p === 3) { + var m = this.m.add(new s(1)).iushrn(2); + return this.pow(l, m); + } + for (var w = this.m.subn(1), P = 0; !w.isZero() && w.andln(1) === 0; ) + P++, w.iushrn(1); + n(!w.isZero()); + var _ = new s(1).toRed(this), y = _.redNeg(), M = this.m.subn(1).iushrn(1), I = this.m.bitLength(); + for (I = new s(2 * I * I).toRed(this); this.pow(I, M).cmp(y) !== 0; ) + I.redIAdd(y); + for (var q = this.pow(I, w), ce = this.pow(l, w.addn(1).iushrn(1)), L = this.pow(l, w), oe = P; L.cmp(_) !== 0; ) { + for (var Q = L, X = 0; Q.cmp(_) !== 0; X++) + Q = Q.redSqr(); + n(X < oe); + var ee = this.pow(q, new s(1).iushln(oe - X - 1)); + ce = ce.redMul(ee), q = ee.redSqr(), L = L.redMul(q), oe = X; + } + return ce; + }, K.prototype.invm = function(l) { + var p = l._invmp(this.m); + return p.negative !== 0 ? (p.negative = 0, this.imod(p).redNeg()) : this.imod(p); + }, K.prototype.pow = function(l, p) { + if (p.isZero()) return new s(1).toRed(this); + if (p.cmpn(1) === 0) return l.clone(); + var m = 4, w = new Array(1 << m); + w[0] = new s(1).toRed(this), w[1] = l; + for (var P = 2; P < w.length; P++) + w[P] = this.mul(w[P - 1], l); + var _ = w[0], y = 0, M = 0, I = p.bitLength() % 26; + for (I === 0 && (I = 26), P = p.length - 1; P >= 0; P--) { + for (var q = p.words[P], ce = I - 1; ce >= 0; ce--) { + var L = q >> ce & 1; + if (_ !== w[0] && (_ = this.sqr(_)), L === 0 && y === 0) { + M = 0; + continue; + } + y <<= 1, y |= L, M++, !(M !== m && (P !== 0 || ce !== 0)) && (_ = this.mul(_, w[y]), M = 0, y = 0); + } + I = 26; + } + return _; + }, K.prototype.convertTo = function(l) { + var p = l.umod(this.m); + return p === l ? p.clone() : p; + }, K.prototype.convertFrom = function(l) { + var p = l.clone(); + return p.red = null, p; + }, s.mont = function(l) { + return new E(l); + }; + function E(b) { + K.call(this, b), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new s(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(E, K), E.prototype.convertTo = function(l) { + return this.imod(l.ushln(this.shift)); + }, E.prototype.convertFrom = function(l) { + var p = this.imod(l.mul(this.rinv)); + return p.red = null, p; + }, E.prototype.imul = function(l, p) { + if (l.isZero() || p.isZero()) + return l.words[0] = 0, l.length = 1, l; + var m = l.imul(p), w = m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), P = m.isub(w).iushrn(this.shift), _ = P; + return P.cmp(this.m) >= 0 ? _ = P.isub(this.m) : P.cmpn(0) < 0 && (_ = P.iadd(this.m)), _._forceRed(this); + }, E.prototype.mul = function(l, p) { + if (l.isZero() || p.isZero()) return new s(0)._forceRed(this); + var m = l.mul(p), w = m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), P = m.isub(w).iushrn(this.shift), _ = P; + return P.cmp(this.m) >= 0 ? _ = P.isub(this.m) : P.cmpn(0) < 0 && (_ = P.iadd(this.m)), _._forceRed(this); + }, E.prototype.invm = function(l) { + var p = this.imod(l._invmp(this.m).mul(this.r2)); + return p._forceRed(this); + }; + })(t, gB); + })(Fh)), Fh.exports; +} +var vB = mB(); +const or = /* @__PURE__ */ Hi(vB); +var bB = or.BN; +function yB(t) { + return new bB(t, 36).toString(16); +} +const wB = "strings/5.7.0", xB = new Yr(wB); +var bd; +(function(t) { + t.current = "", t.NFC = "NFC", t.NFD = "NFD", t.NFKC = "NFKC", t.NFKD = "NFKD"; +})(bd || (bd = {})); +var ex; +(function(t) { + t.UNEXPECTED_CONTINUE = "unexpected continuation byte", t.BAD_PREFIX = "bad codepoint prefix", t.OVERRUN = "string overrun", t.MISSING_CONTINUE = "missing continuation byte", t.OUT_OF_RANGE = "out of UTF-8 range", t.UTF16_SURROGATE = "UTF-16 surrogate", t.OVERLONG = "overlong representation"; +})(ex || (ex = {})); +function hg(t, e = bd.current) { + e != bd.current && (xB.checkNormalize(), t = t.normalize(e)); + let r = []; + for (let n = 0; n < t.length; n++) { + const i = t.charCodeAt(n); + if (i < 128) + r.push(i); + else if (i < 2048) + r.push(i >> 6 | 192), r.push(i & 63 | 128); + else if ((i & 64512) == 55296) { + n++; + const s = t.charCodeAt(n); + if (n >= t.length || (s & 64512) !== 56320) + throw new Error("invalid utf-8 string"); + const o = 65536 + ((i & 1023) << 10) + (s & 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(i >> 12 | 224), r.push(i >> 6 & 63 | 128), r.push(i & 63 | 128); + } + return bn(r); +} +const _B = `Ethereum Signed Message: +`; +function f8(t) { + return typeof t == "string" && (t = hg(t)), g1(hB([ + hg(_B), + hg(String(t.length)), + t + ])); +} +const EB = "address/5.7.0", Ku = new Yr(EB); +function tx(t) { + Is(t, 20) || Ku.throwArgumentError("invalid address", "address", t), t = t.toLowerCase(); + const e = t.substring(2).split(""), r = new Uint8Array(40); + for (let i = 0; i < 40; i++) + r[i] = e[i].charCodeAt(0); + const n = bn(g1(r)); + for (let i = 0; i < 40; i += 2) + n[i >> 1] >> 4 >= 8 && (e[i] = e[i].toUpperCase()), (n[i >> 1] & 15) >= 8 && (e[i + 1] = e[i + 1].toUpperCase()); + return "0x" + e.join(""); +} +const SB = 9007199254740991; +function AB(t) { + return Math.log10 ? Math.log10(t) : Math.log(t) / Math.LN10; +} +const m1 = {}; +for (let t = 0; t < 10; t++) + m1[String(t)] = String(t); +for (let t = 0; t < 26; t++) + m1[String.fromCharCode(65 + t)] = String(10 + t); +const rx = Math.floor(AB(SB)); +function PB(t) { + t = t.toUpperCase(), t = t.substring(4) + t.substring(0, 2) + "00"; + let e = t.split("").map((n) => m1[n]).join(""); + for (; e.length >= rx; ) { + let n = e.substring(0, rx); + e = parseInt(n, 10) % 97 + e.substring(n.length); + } + let r = String(98 - parseInt(e, 10) % 97); + for (; r.length < 2; ) + r = "0" + r; + return r; +} +function MB(t) { + let e = null; + if (typeof t != "string" && Ku.throwArgumentError("invalid address", "address", t), t.match(/^(0x)?[0-9a-fA-F]{40}$/)) + t.substring(0, 2) !== "0x" && (t = "0x" + t), e = tx(t), t.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && e !== t && Ku.throwArgumentError("bad address checksum", "address", t); + else if (t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + for (t.substring(2, 4) !== PB(t) && Ku.throwArgumentError("bad icap checksum", "address", t), e = yB(t.substring(4)); e.length < 40; ) + e = "0" + e; + e = tx("0x" + e); + } else + Ku.throwArgumentError("invalid address", "address", t); + return e; +} +function Tu(t, e, r) { + Object.defineProperty(t, e, { + enumerable: !0, + value: r, + writable: !1 + }); +} +var dg = {}, Or = {}, pg, nx; +function Wa() { + if (nx) return pg; + nx = 1, pg = t; + function t(e, r) { + if (!e) + throw new Error(r || "Assertion failed"); + } + return t.equal = function(r, n, i) { + if (r != n) + throw new Error(i || "Assertion failed: " + r + " != " + n); + }, pg; +} +var yh = { exports: {} }, ix; +function Jd() { + return ix || (ix = 1, typeof Object.create == "function" ? yh.exports = function(e, r) { + r && (e.super_ = r, e.prototype = Object.create(r.prototype, { + constructor: { + value: e, + enumerable: !1, + writable: !0, + configurable: !0 + } + })); + } : yh.exports = function(e, r) { + if (r) { + e.super_ = r; + var n = function() { + }; + n.prototype = r.prototype, e.prototype = new n(), e.prototype.constructor = e; + } + }), yh.exports; +} +var sx; +function Ls() { + if (sx) return Or; + sx = 1; + var t = Wa(), e = Jd(); + Or.inherits = e; + function r(E, b) { + return (E.charCodeAt(b) & 64512) !== 55296 || b < 0 || b + 1 >= E.length ? !1 : (E.charCodeAt(b + 1) & 64512) === 56320; + } + function n(E, b) { + if (Array.isArray(E)) + return E.slice(); + if (!E) + return []; + var l = []; + if (typeof E == "string") + if (b) { + if (b === "hex") + for (E = E.replace(/[^a-z0-9]+/ig, ""), E.length % 2 !== 0 && (E = "0" + E), m = 0; m < E.length; m += 2) + l.push(parseInt(E[m] + E[m + 1], 16)); + } else for (var p = 0, m = 0; m < E.length; m++) { + var w = E.charCodeAt(m); + w < 128 ? l[p++] = w : w < 2048 ? (l[p++] = w >> 6 | 192, l[p++] = w & 63 | 128) : r(E, m) ? (w = 65536 + ((w & 1023) << 10) + (E.charCodeAt(++m) & 1023), l[p++] = w >> 18 | 240, l[p++] = w >> 12 & 63 | 128, l[p++] = w >> 6 & 63 | 128, l[p++] = w & 63 | 128) : (l[p++] = w >> 12 | 224, l[p++] = w >> 6 & 63 | 128, l[p++] = w & 63 | 128); + } + else + for (m = 0; m < E.length; m++) + l[m] = E[m] | 0; + return l; + } + Or.toArray = n; + function i(E) { + for (var b = "", l = 0; l < E.length; l++) + b += a(E[l].toString(16)); + return b; + } + Or.toHex = i; + function s(E) { + var b = E >>> 24 | E >>> 8 & 65280 | E << 8 & 16711680 | (E & 255) << 24; + return b >>> 0; + } + Or.htonl = s; + function o(E, b) { + for (var l = "", p = 0; p < E.length; p++) { + var m = E[p]; + b === "little" && (m = s(m)), l += f(m.toString(16)); + } + return l; + } + Or.toHex32 = o; + function a(E) { + return E.length === 1 ? "0" + E : E; + } + Or.zero2 = a; + function f(E) { + return E.length === 7 ? "0" + E : E.length === 6 ? "00" + E : E.length === 5 ? "000" + E : E.length === 4 ? "0000" + E : E.length === 3 ? "00000" + E : E.length === 2 ? "000000" + E : E.length === 1 ? "0000000" + E : E; + } + Or.zero8 = f; + function u(E, b, l, p) { + var m = l - b; + t(m % 4 === 0); + for (var w = new Array(m / 4), P = 0, _ = b; P < w.length; P++, _ += 4) { + var y; + p === "big" ? y = E[_] << 24 | E[_ + 1] << 16 | E[_ + 2] << 8 | E[_ + 3] : y = E[_ + 3] << 24 | E[_ + 2] << 16 | E[_ + 1] << 8 | E[_], w[P] = y >>> 0; + } + return w; + } + Or.join32 = u; + function h(E, b) { + for (var l = new Array(E.length * 4), p = 0, m = 0; p < E.length; p++, m += 4) { + var w = E[p]; + b === "big" ? (l[m] = w >>> 24, l[m + 1] = w >>> 16 & 255, l[m + 2] = w >>> 8 & 255, l[m + 3] = w & 255) : (l[m + 3] = w >>> 24, l[m + 2] = w >>> 16 & 255, l[m + 1] = w >>> 8 & 255, l[m] = w & 255); + } + return l; + } + Or.split32 = h; + function g(E, b) { + return E >>> b | E << 32 - b; + } + Or.rotr32 = g; + function v(E, b) { + return E << b | E >>> 32 - b; + } + Or.rotl32 = v; + function x(E, b) { + return E + b >>> 0; + } + Or.sum32 = x; + function S(E, b, l) { + return E + b + l >>> 0; + } + Or.sum32_3 = S; + function R(E, b, l, p) { + return E + b + l + p >>> 0; + } + Or.sum32_4 = R; + function D(E, b, l, p, m) { + return E + b + l + p + m >>> 0; + } + Or.sum32_5 = D; + function k(E, b, l, p) { + var m = E[b], w = E[b + 1], P = p + w >>> 0, _ = (P < p ? 1 : 0) + l + m; + E[b] = _ >>> 0, E[b + 1] = P; + } + Or.sum64 = k; + function N(E, b, l, p) { + var m = b + p >>> 0, w = (m < b ? 1 : 0) + E + l; + return w >>> 0; + } + Or.sum64_hi = N; + function z(E, b, l, p) { + var m = b + p; + return m >>> 0; + } + Or.sum64_lo = z; + function B(E, b, l, p, m, w, P, _) { + var y = 0, M = b; + M = M + p >>> 0, y += M < b ? 1 : 0, M = M + w >>> 0, y += M < w ? 1 : 0, M = M + _ >>> 0, y += M < _ ? 1 : 0; + var I = E + l + m + P + y; + return I >>> 0; + } + Or.sum64_4_hi = B; + function $(E, b, l, p, m, w, P, _) { + var y = b + p + w + _; + return y >>> 0; + } + Or.sum64_4_lo = $; + function U(E, b, l, p, m, w, P, _, y, M) { + var I = 0, q = b; + q = q + p >>> 0, I += q < b ? 1 : 0, q = q + w >>> 0, I += q < w ? 1 : 0, q = q + _ >>> 0, I += q < _ ? 1 : 0, q = q + M >>> 0, I += q < M ? 1 : 0; + var ce = E + l + m + P + y + I; + return ce >>> 0; + } + Or.sum64_5_hi = U; + function C(E, b, l, p, m, w, P, _, y, M) { + var I = b + p + w + _ + M; + return I >>> 0; + } + Or.sum64_5_lo = C; + function W(E, b, l) { + var p = b << 32 - l | E >>> l; + return p >>> 0; + } + Or.rotr64_hi = W; + function J(E, b, l) { + var p = E << 32 - l | b >>> l; + return p >>> 0; + } + Or.rotr64_lo = J; + function ne(E, b, l) { + return E >>> l; + } + Or.shr64_hi = ne; + function K(E, b, l) { + var p = E << 32 - l | b >>> l; + return p >>> 0; + } + return Or.shr64_lo = K, Or; +} +var gg = {}, ox; +function nl() { + if (ox) return gg; + ox = 1; + var t = Ls(), e = Wa(); + function r() { + 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; + } + return gg.BlockHash = r, r.prototype.update = function(i, s) { + if (i = t.toArray(i, s), this.pending ? this.pending = this.pending.concat(i) : this.pending = i, this.pendingTotal += i.length, this.pending.length >= this._delta8) { + i = this.pending; + var o = i.length % this._delta8; + this.pending = i.slice(i.length - o, i.length), this.pending.length === 0 && (this.pending = null), i = t.join32(i, 0, i.length - o, this.endian); + for (var a = 0; a < i.length; a += this._delta32) + this._update(i, a, a + this._delta32); + } + return this; + }, r.prototype.digest = function(i) { + return this.update(this._pad()), e(this.pending === null), this._digest(i); + }, r.prototype._pad = function() { + var i = this.pendingTotal, s = this._delta8, o = s - (i + this.padLength) % s, a = new Array(o + this.padLength); + a[0] = 128; + for (var f = 1; f < o; f++) + a[f] = 0; + if (i <<= 3, this.endian === "big") { + for (var u = 8; u < this.padLength; u++) + a[f++] = 0; + a[f++] = 0, a[f++] = 0, a[f++] = 0, a[f++] = 0, a[f++] = i >>> 24 & 255, a[f++] = i >>> 16 & 255, a[f++] = i >>> 8 & 255, a[f++] = i & 255; + } else + for (a[f++] = i & 255, a[f++] = i >>> 8 & 255, a[f++] = i >>> 16 & 255, a[f++] = i >>> 24 & 255, a[f++] = 0, a[f++] = 0, a[f++] = 0, a[f++] = 0, u = 8; u < this.padLength; u++) + a[f++] = 0; + return a; + }, gg; +} +var da = {}, xs = {}, ax; +function l8() { + if (ax) return xs; + ax = 1; + var t = Ls(), e = t.rotr32; + function r(h, g, v, x) { + if (h === 0) + return n(g, v, x); + if (h === 1 || h === 3) + return s(g, v, x); + if (h === 2) + return i(g, v, x); + } + xs.ft_1 = r; + function n(h, g, v) { + return h & g ^ ~h & v; + } + xs.ch32 = n; + function i(h, g, v) { + return h & g ^ h & v ^ g & v; + } + xs.maj32 = i; + function s(h, g, v) { + return h ^ g ^ v; + } + xs.p32 = s; + function o(h) { + return e(h, 2) ^ e(h, 13) ^ e(h, 22); + } + xs.s0_256 = o; + function a(h) { + return e(h, 6) ^ e(h, 11) ^ e(h, 25); + } + xs.s1_256 = a; + function f(h) { + return e(h, 7) ^ e(h, 18) ^ h >>> 3; + } + xs.g0_256 = f; + function u(h) { + return e(h, 17) ^ e(h, 19) ^ h >>> 10; + } + return xs.g1_256 = u, xs; +} +var mg, cx; +function IB() { + if (cx) return mg; + cx = 1; + var t = Ls(), e = nl(), r = l8(), n = t.rotl32, i = t.sum32, s = t.sum32_5, o = r.ft_1, a = e.BlockHash, f = [ + 1518500249, + 1859775393, + 2400959708, + 3395469782 + ]; + function u() { + if (!(this instanceof u)) + return new u(); + a.call(this), this.h = [ + 1732584193, + 4023233417, + 2562383102, + 271733878, + 3285377520 + ], this.W = new Array(80); + } + return t.inherits(u, a), mg = u, u.blockSize = 512, u.outSize = 160, u.hmacStrength = 80, u.padLength = 64, u.prototype._update = function(g, v) { + for (var x = this.W, S = 0; S < 16; S++) + x[S] = g[v + S]; + for (; S < x.length; S++) + x[S] = n(x[S - 3] ^ x[S - 8] ^ x[S - 14] ^ x[S - 16], 1); + var R = this.h[0], D = this.h[1], k = this.h[2], N = this.h[3], z = this.h[4]; + for (S = 0; S < x.length; S++) { + var B = ~~(S / 20), $ = s(n(R, 5), o(B, D, k, N), z, x[S], f[B]); + z = N, N = k, k = n(D, 30), D = R, R = $; + } + this.h[0] = i(this.h[0], R), this.h[1] = i(this.h[1], D), this.h[2] = i(this.h[2], k), this.h[3] = i(this.h[3], N), this.h[4] = i(this.h[4], z); + }, u.prototype._digest = function(g) { + return g === "hex" ? t.toHex32(this.h, "big") : t.split32(this.h, "big"); + }, mg; +} +var vg, ux; +function h8() { + if (ux) return vg; + ux = 1; + var t = Ls(), e = nl(), r = l8(), n = Wa(), i = t.sum32, s = t.sum32_4, o = t.sum32_5, a = r.ch32, f = r.maj32, u = r.s0_256, h = r.s1_256, g = r.g0_256, v = r.g1_256, x = e.BlockHash, S = [ + 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 R() { + if (!(this instanceof R)) + return new R(); + x.call(this), this.h = [ + 1779033703, + 3144134277, + 1013904242, + 2773480762, + 1359893119, + 2600822924, + 528734635, + 1541459225 + ], this.k = S, this.W = new Array(64); + } + return t.inherits(R, x), vg = R, R.blockSize = 512, R.outSize = 256, R.hmacStrength = 192, R.padLength = 64, R.prototype._update = function(k, N) { + for (var z = this.W, B = 0; B < 16; B++) + z[B] = k[N + B]; + for (; B < z.length; B++) + z[B] = s(v(z[B - 2]), z[B - 7], g(z[B - 15]), z[B - 16]); + var $ = this.h[0], U = this.h[1], C = this.h[2], W = this.h[3], J = this.h[4], ne = this.h[5], K = this.h[6], E = this.h[7]; + for (n(this.k.length === z.length), B = 0; B < z.length; B++) { + var b = o(E, h(J), a(J, ne, K), this.k[B], z[B]), l = i(u($), f($, U, C)); + E = K, K = ne, ne = J, J = i(W, b), W = C, C = U, U = $, $ = i(b, l); + } + this.h[0] = i(this.h[0], $), this.h[1] = i(this.h[1], U), this.h[2] = i(this.h[2], C), this.h[3] = i(this.h[3], W), this.h[4] = i(this.h[4], J), this.h[5] = i(this.h[5], ne), this.h[6] = i(this.h[6], K), this.h[7] = i(this.h[7], E); + }, R.prototype._digest = function(k) { + return k === "hex" ? t.toHex32(this.h, "big") : t.split32(this.h, "big"); + }, vg; +} +var bg, fx; +function CB() { + if (fx) return bg; + fx = 1; + var t = Ls(), e = h8(); + function r() { + if (!(this instanceof r)) + return new r(); + e.call(this), this.h = [ + 3238371032, + 914150663, + 812702999, + 4144912697, + 4290775857, + 1750603025, + 1694076839, + 3204075428 + ]; + } + return t.inherits(r, e), bg = r, r.blockSize = 512, r.outSize = 224, r.hmacStrength = 192, r.padLength = 64, r.prototype._digest = function(i) { + return i === "hex" ? t.toHex32(this.h.slice(0, 7), "big") : t.split32(this.h.slice(0, 7), "big"); + }, bg; +} +var yg, lx; +function d8() { + if (lx) return yg; + lx = 1; + var t = Ls(), e = nl(), r = Wa(), n = t.rotr64_hi, i = t.rotr64_lo, s = t.shr64_hi, o = t.shr64_lo, a = t.sum64, f = t.sum64_hi, u = t.sum64_lo, h = t.sum64_4_hi, g = t.sum64_4_lo, v = t.sum64_5_hi, x = t.sum64_5_lo, S = e.BlockHash, R = [ + 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 D() { + if (!(this instanceof D)) + return new D(); + S.call(this), this.h = [ + 1779033703, + 4089235720, + 3144134277, + 2227873595, + 1013904242, + 4271175723, + 2773480762, + 1595750129, + 1359893119, + 2917565137, + 2600822924, + 725511199, + 528734635, + 4215389547, + 1541459225, + 327033209 + ], this.k = R, this.W = new Array(160); + } + t.inherits(D, S), yg = D, D.blockSize = 1024, D.outSize = 512, D.hmacStrength = 192, D.padLength = 128, D.prototype._prepareBlock = function(l, p) { + for (var m = this.W, w = 0; w < 32; w++) + m[w] = l[p + w]; + for (; w < m.length; w += 2) { + var P = K(m[w - 4], m[w - 3]), _ = E(m[w - 4], m[w - 3]), y = m[w - 14], M = m[w - 13], I = J(m[w - 30], m[w - 29]), q = ne(m[w - 30], m[w - 29]), ce = m[w - 32], L = m[w - 31]; + m[w] = h( + P, + _, + y, + M, + I, + q, + ce, + L + ), m[w + 1] = g( + P, + _, + y, + M, + I, + q, + ce, + L + ); + } + }, D.prototype._update = function(l, p) { + this._prepareBlock(l, p); + var m = this.W, w = this.h[0], P = this.h[1], _ = this.h[2], y = this.h[3], M = this.h[4], I = this.h[5], q = this.h[6], ce = this.h[7], L = this.h[8], oe = this.h[9], Q = this.h[10], X = this.h[11], ee = this.h[12], O = this.h[13], Z = this.h[14], re = this.h[15]; + r(this.k.length === m.length); + for (var he = 0; he < m.length; he += 2) { + var ae = Z, fe = re, be = C(L, oe), Ae = W(L, oe), Te = k(L, oe, Q, X, ee), Re = N(L, oe, Q, X, ee, O), $e = this.k[he], Me = this.k[he + 1], Oe = m[he], ze = m[he + 1], De = v( + ae, + fe, + be, + Ae, + Te, + Re, + $e, + Me, + Oe, + ze + ), je = x( + ae, + fe, + be, + Ae, + Te, + Re, + $e, + Me, + Oe, + ze + ); + ae = $(w, P), fe = U(w, P), be = z(w, P, _, y, M), Ae = B(w, P, _, y, M, I); + var Ue = f(ae, fe, be, Ae), _e = u(ae, fe, be, Ae); + Z = ee, re = O, ee = Q, O = X, Q = L, X = oe, L = f(q, ce, De, je), oe = u(ce, ce, De, je), q = M, ce = I, M = _, I = y, _ = w, y = P, w = f(De, je, Ue, _e), P = u(De, je, Ue, _e); + } + a(this.h, 0, w, P), a(this.h, 2, _, y), a(this.h, 4, M, I), a(this.h, 6, q, ce), a(this.h, 8, L, oe), a(this.h, 10, Q, X), a(this.h, 12, ee, O), a(this.h, 14, Z, re); + }, D.prototype._digest = function(l) { + return l === "hex" ? t.toHex32(this.h, "big") : t.split32(this.h, "big"); + }; + function k(b, l, p, m, w) { + var P = b & p ^ ~b & w; + return P < 0 && (P += 4294967296), P; + } + function N(b, l, p, m, w, P) { + var _ = l & m ^ ~l & P; + return _ < 0 && (_ += 4294967296), _; + } + function z(b, l, p, m, w) { + var P = b & p ^ b & w ^ p & w; + return P < 0 && (P += 4294967296), P; + } + function B(b, l, p, m, w, P) { + var _ = l & m ^ l & P ^ m & P; + return _ < 0 && (_ += 4294967296), _; + } + function $(b, l) { + var p = n(b, l, 28), m = n(l, b, 2), w = n(l, b, 7), P = p ^ m ^ w; + return P < 0 && (P += 4294967296), P; + } + function U(b, l) { + var p = i(b, l, 28), m = i(l, b, 2), w = i(l, b, 7), P = p ^ m ^ w; + return P < 0 && (P += 4294967296), P; + } + function C(b, l) { + var p = n(b, l, 14), m = n(b, l, 18), w = n(l, b, 9), P = p ^ m ^ w; + return P < 0 && (P += 4294967296), P; + } + function W(b, l) { + var p = i(b, l, 14), m = i(b, l, 18), w = i(l, b, 9), P = p ^ m ^ w; + return P < 0 && (P += 4294967296), P; + } + function J(b, l) { + var p = n(b, l, 1), m = n(b, l, 8), w = s(b, l, 7), P = p ^ m ^ w; + return P < 0 && (P += 4294967296), P; + } + function ne(b, l) { + var p = i(b, l, 1), m = i(b, l, 8), w = o(b, l, 7), P = p ^ m ^ w; + return P < 0 && (P += 4294967296), P; + } + function K(b, l) { + var p = n(b, l, 19), m = n(l, b, 29), w = s(b, l, 6), P = p ^ m ^ w; + return P < 0 && (P += 4294967296), P; + } + function E(b, l) { + var p = i(b, l, 19), m = i(l, b, 29), w = o(b, l, 6), P = p ^ m ^ w; + return P < 0 && (P += 4294967296), P; + } + return yg; +} +var wg, hx; +function RB() { + if (hx) return wg; + hx = 1; + var t = Ls(), e = d8(); + function r() { + if (!(this instanceof r)) + return new r(); + e.call(this), this.h = [ + 3418070365, + 3238371032, + 1654270250, + 914150663, + 2438529370, + 812702999, + 355462360, + 4144912697, + 1731405415, + 4290775857, + 2394180231, + 1750603025, + 3675008525, + 1694076839, + 1203062813, + 3204075428 + ]; + } + return t.inherits(r, e), wg = r, r.blockSize = 1024, r.outSize = 384, r.hmacStrength = 192, r.padLength = 128, r.prototype._digest = function(i) { + return i === "hex" ? t.toHex32(this.h.slice(0, 12), "big") : t.split32(this.h.slice(0, 12), "big"); + }, wg; +} +var dx; +function TB() { + return dx || (dx = 1, da.sha1 = IB(), da.sha224 = CB(), da.sha256 = h8(), da.sha384 = RB(), da.sha512 = d8()), da; +} +var xg = {}, px; +function DB() { + if (px) return xg; + px = 1; + var t = Ls(), e = nl(), r = t.rotl32, n = t.sum32, i = t.sum32_3, s = t.sum32_4, o = e.BlockHash; + function a() { + if (!(this instanceof a)) + return new a(); + o.call(this), this.h = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], this.endian = "little"; + } + t.inherits(a, o), xg.ripemd160 = a, a.blockSize = 512, a.outSize = 160, a.hmacStrength = 192, a.padLength = 64, a.prototype._update = function(D, k) { + for (var N = this.h[0], z = this.h[1], B = this.h[2], $ = this.h[3], U = this.h[4], C = N, W = z, J = B, ne = $, K = U, E = 0; E < 80; E++) { + var b = n( + r( + s(N, f(E, z, B, $), D[g[E] + k], u(E)), + x[E] + ), + U + ); + N = U, U = $, $ = r(B, 10), B = z, z = b, b = n( + r( + s(C, f(79 - E, W, J, ne), D[v[E] + k], h(E)), + S[E] + ), + K + ), C = K, K = ne, ne = r(J, 10), J = W, W = b; + } + b = i(this.h[1], B, ne), this.h[1] = i(this.h[2], $, K), this.h[2] = i(this.h[3], U, C), this.h[3] = i(this.h[4], N, W), this.h[4] = i(this.h[0], z, J), this.h[0] = b; + }, a.prototype._digest = function(D) { + return D === "hex" ? t.toHex32(this.h, "little") : t.split32(this.h, "little"); + }; + function f(R, D, k, N) { + return R <= 15 ? D ^ k ^ N : R <= 31 ? D & k | ~D & N : R <= 47 ? (D | ~k) ^ N : R <= 63 ? D & N | k & ~N : D ^ (k | ~N); + } + function u(R) { + return R <= 15 ? 0 : R <= 31 ? 1518500249 : R <= 47 ? 1859775393 : R <= 63 ? 2400959708 : 2840853838; + } + function h(R) { + return R <= 15 ? 1352829926 : R <= 31 ? 1548603684 : R <= 47 ? 1836072691 : R <= 63 ? 2053994217 : 0; + } + var g = [ + 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 + ], v = [ + 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 + ], x = [ + 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 + ], S = [ + 8, + 9, + 9, + 11, + 13, + 15, + 15, + 5, + 7, + 7, + 8, + 11, + 14, + 14, + 12, + 6, + 9, + 13, + 15, + 7, + 12, + 8, + 9, + 11, + 7, + 7, + 12, + 7, + 6, + 15, + 13, + 11, + 9, + 7, + 15, + 11, + 8, + 6, + 6, + 14, + 12, + 13, + 5, + 14, + 13, + 13, + 7, + 5, + 15, + 5, + 8, + 11, + 14, + 14, + 6, + 14, + 6, + 9, + 12, + 9, + 12, + 5, + 15, + 8, + 8, + 5, + 12, + 9, + 12, + 5, + 14, + 6, + 8, + 13, + 6, + 5, + 15, + 13, + 11, + 11 + ]; + return xg; +} +var _g, gx; +function OB() { + if (gx) return _g; + gx = 1; + var t = Ls(), e = Wa(); + function r(n, i, s) { + if (!(this instanceof r)) + return new r(n, i, s); + this.Hash = n, this.blockSize = n.blockSize / 8, this.outSize = n.outSize / 8, this.inner = null, this.outer = null, this._init(t.toArray(i, s)); + } + return _g = r, r.prototype._init = function(i) { + i.length > this.blockSize && (i = new this.Hash().update(i).digest()), e(i.length <= this.blockSize); + for (var s = i.length; s < this.blockSize; s++) + i.push(0); + for (s = 0; s < i.length; s++) + i[s] ^= 54; + for (this.inner = new this.Hash().update(i), s = 0; s < i.length; s++) + i[s] ^= 106; + this.outer = new this.Hash().update(i); + }, r.prototype.update = function(i, s) { + return this.inner.update(i, s), this; + }, r.prototype.digest = function(i) { + return this.outer.update(this.inner.digest()), this.outer.digest(i); + }, _g; +} +var mx; +function Xd() { + return mx || (mx = 1, (function(t) { + var e = t; + e.utils = Ls(), e.common = nl(), e.sha = TB(), e.ripemd = DB(), e.hmac = OB(), e.sha1 = e.sha.sha1, e.sha256 = e.sha.sha256, e.sha224 = e.sha.sha224, e.sha384 = e.sha.sha384, e.sha512 = e.sha.sha512, e.ripemd160 = e.ripemd.ripemd160; + })(dg)), dg; +} +var NB = Xd(); +const Xs = /* @__PURE__ */ Hi(NB); +function Gc(t, e, r) { + return r = { + path: e, + exports: {}, + require: function(n, i) { + return LB(n, i ?? r.path); + } + }, t(r, r.exports), r.exports; +} +function LB() { + throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs"); +} +var v1 = p8; +function p8(t, e) { + if (!t) + throw new Error(e || "Assertion failed"); +} +p8.equal = function(e, r, n) { + if (e != r) + throw new Error(n || "Assertion failed: " + e + " != " + r); +}; +var as = Gc(function(t, e) { + var r = e; + function n(o, a) { + if (Array.isArray(o)) + return o.slice(); + if (!o) + return []; + var f = []; + if (typeof o != "string") { + for (var u = 0; u < o.length; u++) + f[u] = o[u] | 0; + return f; + } + if (a === "hex") { + o = o.replace(/[^a-z0-9]+/ig, ""), o.length % 2 !== 0 && (o = "0" + o); + for (var u = 0; u < o.length; u += 2) + f.push(parseInt(o[u] + o[u + 1], 16)); + } else + for (var u = 0; u < o.length; u++) { + var h = o.charCodeAt(u), g = h >> 8, v = h & 255; + g ? f.push(g, v) : f.push(v); + } + return f; + } + r.toArray = n; + function i(o) { + return o.length === 1 ? "0" + o : o; + } + r.zero2 = i; + function s(o) { + for (var a = "", f = 0; f < o.length; f++) + a += i(o[f].toString(16)); + return a; + } + r.toHex = s, r.encode = function(a, f) { + return f === "hex" ? s(a) : a; + }; +}), Ii = Gc(function(t, e) { + var r = e; + r.assert = v1, r.toArray = as.toArray, r.zero2 = as.zero2, r.toHex = as.toHex, r.encode = as.encode; + function n(f, u, h) { + var g = new Array(Math.max(f.bitLength(), h) + 1); + g.fill(0); + for (var v = 1 << u + 1, x = f.clone(), S = 0; S < g.length; S++) { + var R, D = x.andln(v - 1); + x.isOdd() ? (D > (v >> 1) - 1 ? R = (v >> 1) - D : R = D, x.isubn(R)) : R = 0, g[S] = R, x.iushrn(1); + } + return g; + } + r.getNAF = n; + function i(f, u) { + var h = [ + [], + [] + ]; + f = f.clone(), u = u.clone(); + for (var g = 0, v = 0, x; f.cmpn(-g) > 0 || u.cmpn(-v) > 0; ) { + var S = f.andln(3) + g & 3, R = u.andln(3) + v & 3; + S === 3 && (S = -1), R === 3 && (R = -1); + var D; + (S & 1) === 0 ? D = 0 : (x = f.andln(7) + g & 7, (x === 3 || x === 5) && R === 2 ? D = -S : D = S), h[0].push(D); + var k; + (R & 1) === 0 ? k = 0 : (x = u.andln(7) + v & 7, (x === 3 || x === 5) && S === 2 ? k = -R : k = R), h[1].push(k), 2 * g === D + 1 && (g = 1 - g), 2 * v === k + 1 && (v = 1 - v), f.iushrn(1), u.iushrn(1); + } + return h; + } + r.getJSF = i; + function s(f, u, h) { + var g = "_" + u; + f.prototype[u] = function() { + return this[g] !== void 0 ? this[g] : this[g] = h.call(this); + }; + } + r.cachedProperty = s; + function o(f) { + return typeof f == "string" ? r.toArray(f, "hex") : f; + } + r.parseBytes = o; + function a(f) { + return new or(f, "hex", "le"); + } + r.intFromLE = a; +}), yd = Ii.getNAF, kB = Ii.getJSF, wd = Ii.assert; +function Zo(t, e) { + this.type = t, this.p = new or(e.p, 16), this.red = e.prime ? or.red(e.prime) : or.mont(this.p), this.zero = new or(0).toRed(this.red), this.one = new or(1).toRed(this.red), this.two = new or(2).toRed(this.red), this.n = e.n && new or(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 r = this.n && this.p.div(this.n); + !r || r.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = !0, this.redN = this.n.toRed(this.red)); +} +var Ka = Zo; +Zo.prototype.point = function() { + throw new Error("Not implemented"); +}; +Zo.prototype.validate = function() { + throw new Error("Not implemented"); +}; +Zo.prototype._fixedNafMul = function(e, r) { + wd(e.precomputed); + var n = e._getDoubles(), i = yd(r, 1, this._bitLength), s = (1 << n.step + 1) - (n.step % 2 === 0 ? 2 : 1); + s /= 3; + var o = [], a, f; + for (a = 0; a < i.length; a += n.step) { + f = 0; + for (var u = a + n.step - 1; u >= a; u--) + f = (f << 1) + i[u]; + o.push(f); + } + for (var h = this.jpoint(null, null, null), g = this.jpoint(null, null, null), v = s; v > 0; v--) { + for (a = 0; a < o.length; a++) + f = o[a], f === v ? g = g.mixedAdd(n.points[a]) : f === -v && (g = g.mixedAdd(n.points[a].neg())); + h = h.add(g); + } + return h.toP(); +}; +Zo.prototype._wnafMul = function(e, r) { + var n = 4, i = e._getNAFPoints(n); + n = i.wnd; + for (var s = i.points, o = yd(r, n, this._bitLength), a = this.jpoint(null, null, null), f = o.length - 1; f >= 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 h = o[f]; + wd(h !== 0), e.type === "affine" ? h > 0 ? a = a.mixedAdd(s[h - 1 >> 1]) : a = a.mixedAdd(s[-h - 1 >> 1].neg()) : h > 0 ? a = a.add(s[h - 1 >> 1]) : a = a.add(s[-h - 1 >> 1].neg()); + } + return e.type === "affine" ? a.toP() : a; +}; +Zo.prototype._wnafMulAdd = function(e, r, n, i, s) { + var o = this._wnafT1, a = this._wnafT2, f = this._wnafT3, u = 0, h, g, v; + for (h = 0; h < i; h++) { + v = r[h]; + var x = v._getNAFPoints(e); + o[h] = x.wnd, a[h] = x.points; + } + for (h = i - 1; h >= 1; h -= 2) { + var S = h - 1, R = h; + if (o[S] !== 1 || o[R] !== 1) { + f[S] = yd(n[S], o[S], this._bitLength), f[R] = yd(n[R], o[R], this._bitLength), u = Math.max(f[S].length, u), u = Math.max(f[R].length, u); + continue; + } + var D = [ + r[S], + /* 1 */ + null, + /* 3 */ + null, + /* 5 */ + r[R] + /* 7 */ + ]; + r[S].y.cmp(r[R].y) === 0 ? (D[1] = r[S].add(r[R]), D[2] = r[S].toJ().mixedAdd(r[R].neg())) : r[S].y.cmp(r[R].y.redNeg()) === 0 ? (D[1] = r[S].toJ().mixedAdd(r[R]), D[2] = r[S].add(r[R].neg())) : (D[1] = r[S].toJ().mixedAdd(r[R]), D[2] = r[S].toJ().mixedAdd(r[R].neg())); + var k = [ + -3, + /* -1 -1 */ + -1, + /* -1 0 */ + -5, + /* -1 1 */ + -7, + /* 0 -1 */ + 0, + /* 0 0 */ + 7, + /* 0 1 */ + 5, + /* 1 -1 */ + 1, + /* 1 0 */ + 3 + /* 1 1 */ + ], N = kB(n[S], n[R]); + for (u = Math.max(N[0].length, u), f[S] = new Array(u), f[R] = new Array(u), g = 0; g < u; g++) { + var z = N[0][g] | 0, B = N[1][g] | 0; + f[S][g] = k[(z + 1) * 3 + (B + 1)], f[R][g] = 0, a[S] = D; + } + } + var $ = this.jpoint(null, null, null), U = this._wnafT4; + for (h = u; h >= 0; h--) { + for (var C = 0; h >= 0; ) { + var W = !0; + for (g = 0; g < i; g++) + U[g] = f[g][h] | 0, U[g] !== 0 && (W = !1); + if (!W) + break; + C++, h--; + } + if (h >= 0 && C++, $ = $.dblp(C), h < 0) + break; + for (g = 0; g < i; g++) { + var J = U[g]; + J !== 0 && (J > 0 ? v = a[g][J - 1 >> 1] : J < 0 && (v = a[g][-J - 1 >> 1].neg()), v.type === "affine" ? $ = $.mixedAdd(v) : $ = $.add(v)); + } + } + for (h = 0; h < i; h++) + a[h] = null; + return s ? $ : $.toP(); +}; +function Ki(t, e) { + this.curve = t, this.type = e, this.precomputed = null; +} +Zo.BasePoint = Ki; +Ki.prototype.eq = function() { + throw new Error("Not implemented"); +}; +Ki.prototype.validate = function() { + return this.curve.validate(this); +}; +Zo.prototype.decodePoint = function(e, r) { + e = Ii.toArray(e, r); + var n = this.p.byteLength(); + if ((e[0] === 4 || e[0] === 6 || e[0] === 7) && e.length - 1 === 2 * n) { + e[0] === 6 ? wd(e[e.length - 1] % 2 === 0) : e[0] === 7 && wd(e[e.length - 1] % 2 === 1); + var i = this.point( + e.slice(1, 1 + n), + e.slice(1 + n, 1 + 2 * n) + ); + return i; + } else if ((e[0] === 2 || e[0] === 3) && e.length - 1 === n) + return this.pointFromX(e.slice(1, 1 + n), e[0] === 3); + throw new Error("Unknown point format"); +}; +Ki.prototype.encodeCompressed = function(e) { + return this.encode(e, !0); +}; +Ki.prototype._encode = function(e) { + var r = this.curve.p.byteLength(), n = this.getX().toArray("be", r); + return e ? [this.getY().isEven() ? 2 : 3].concat(n) : [4].concat(n, this.getY().toArray("be", r)); +}; +Ki.prototype.encode = function(e, r) { + return Ii.encode(this._encode(r), e); +}; +Ki.prototype.precompute = function(e) { + if (this.precomputed) + return this; + var r = { + doubles: null, + naf: null, + beta: null + }; + return r.naf = this._getNAFPoints(8), r.doubles = this._getDoubles(4, e), r.beta = this._getBeta(), this.precomputed = r, this; +}; +Ki.prototype._hasDoubles = function(e) { + if (!this.precomputed) + return !1; + var r = this.precomputed.doubles; + return r ? r.points.length >= Math.ceil((e.bitLength() + 1) / r.step) : !1; +}; +Ki.prototype._getDoubles = function(e, r) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var n = [this], i = this, s = 0; s < r; s += e) { + for (var o = 0; o < e; o++) + i = i.dbl(); + n.push(i); + } + return { + step: e, + points: n + }; +}; +Ki.prototype._getNAFPoints = function(e) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var r = [this], n = (1 << e) - 1, i = n === 1 ? null : this.dbl(), s = 1; s < n; s++) + r[s] = r[s - 1].add(i); + return { + wnd: e, + points: r + }; +}; +Ki.prototype._getBeta = function() { + return null; +}; +Ki.prototype.dblp = function(e) { + for (var r = this, n = 0; n < e; n++) + r = r.dbl(); + return r; +}; +var b1 = Gc(function(t) { + typeof Object.create == "function" ? t.exports = function(r, n) { + n && (r.super_ = n, r.prototype = Object.create(n.prototype, { + constructor: { + value: r, + enumerable: !1, + writable: !0, + configurable: !0 + } + })); + } : t.exports = function(r, n) { + if (n) { + r.super_ = n; + var i = function() { + }; + i.prototype = n.prototype, r.prototype = new i(), r.prototype.constructor = r; + } + }; +}), $B = Ii.assert; +function Vi(t) { + Ka.call(this, "short", t), this.a = new or(t.a, 16).toRed(this.red), this.b = new or(t.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(t), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); +} +b1(Vi, Ka); +var BB = Vi; +Vi.prototype._getEndomorphism = function(e) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var r, n; + if (e.beta) + r = new or(e.beta, 16).toRed(this.red); + else { + var i = this._getEndoRoots(this.p); + r = i[0].cmp(i[1]) < 0 ? i[0] : i[1], r = r.toRed(this.red); + } + if (e.lambda) + n = new or(e.lambda, 16); + else { + var s = this._getEndoRoots(this.n); + this.g.mul(s[0]).x.cmp(this.g.x.redMul(r)) === 0 ? n = s[0] : (n = s[1], $B(this.g.mul(n).x.cmp(this.g.x.redMul(r)) === 0)); + } + var o; + return e.basis ? o = e.basis.map(function(a) { + return { + a: new or(a.a, 16), + b: new or(a.b, 16) + }; + }) : o = this._getEndoBasis(n), { + beta: r, + lambda: n, + basis: o + }; + } +}; +Vi.prototype._getEndoRoots = function(e) { + var r = e === this.p ? this.red : or.mont(e), n = new or(2).toRed(r).redInvm(), i = n.redNeg(), s = new or(3).toRed(r).redNeg().redSqrt().redMul(n), o = i.redAdd(s).fromRed(), a = i.redSub(s).fromRed(); + return [o, a]; +}; +Vi.prototype._getEndoBasis = function(e) { + for (var r = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), n = e, i = this.n.clone(), s = new or(1), o = new or(0), a = new or(0), f = new or(1), u, h, g, v, x, S, R, D = 0, k, N; n.cmpn(0) !== 0; ) { + var z = i.div(n); + k = i.sub(z.mul(n)), N = a.sub(z.mul(s)); + var B = f.sub(z.mul(o)); + if (!g && k.cmp(r) < 0) + u = R.neg(), h = s, g = k.neg(), v = N; + else if (g && ++D === 2) + break; + R = k, i = n, n = k, a = s, s = N, f = o, o = B; + } + x = k.neg(), S = N; + var $ = g.sqr().add(v.sqr()), U = x.sqr().add(S.sqr()); + return U.cmp($) >= 0 && (x = u, S = h), g.negative && (g = g.neg(), v = v.neg()), x.negative && (x = x.neg(), S = S.neg()), [ + { a: g, b: v }, + { a: x, b: S } + ]; +}; +Vi.prototype._endoSplit = function(e) { + var r = this.endo.basis, n = r[0], i = r[1], s = i.b.mul(e).divRound(this.n), o = n.b.neg().mul(e).divRound(this.n), a = s.mul(n.a), f = o.mul(i.a), u = s.mul(n.b), h = o.mul(i.b), g = e.sub(a).sub(f), v = u.add(h).neg(); + return { k1: g, k2: v }; +}; +Vi.prototype.pointFromX = function(e, r) { + e = new or(e, 16), e.red || (e = e.toRed(this.red)); + var n = e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b), i = n.redSqrt(); + if (i.redSqr().redSub(n).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var s = i.fromRed().isOdd(); + return (r && !s || !r && s) && (i = i.redNeg()), this.point(e, i); +}; +Vi.prototype.validate = function(e) { + if (e.inf) + return !0; + var r = e.x, n = e.y, i = this.a.redMul(r), s = r.redSqr().redMul(r).redIAdd(i).redIAdd(this.b); + return n.redSqr().redISub(s).cmpn(0) === 0; +}; +Vi.prototype._endoWnafMulAdd = function(e, r, n) { + for (var i = this._endoWnafT1, s = this._endoWnafT2, o = 0; o < e.length; o++) { + var a = this._endoSplit(r[o]), f = e[o], u = f._getBeta(); + a.k1.negative && (a.k1.ineg(), f = f.neg(!0)), a.k2.negative && (a.k2.ineg(), u = u.neg(!0)), i[o * 2] = f, i[o * 2 + 1] = u, s[o * 2] = a.k1, s[o * 2 + 1] = a.k2; + } + for (var h = this._wnafMulAdd(1, i, s, o * 2, n), g = 0; g < o * 2; g++) + i[g] = null, s[g] = null; + return h; +}; +function Dn(t, e, r, n) { + Ka.BasePoint.call(this, t, "affine"), e === null && r === null ? (this.x = null, this.y = null, this.inf = !0) : (this.x = new or(e, 16), this.y = new or(r, 16), n && (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); +} +b1(Dn, Ka.BasePoint); +Vi.prototype.point = function(e, r, n) { + return new Dn(this, e, r, n); +}; +Vi.prototype.pointFromJSON = function(e, r) { + return Dn.fromJSON(this, e, r); +}; +Dn.prototype._getBeta = function() { + if (this.curve.endo) { + var e = this.precomputed; + if (e && e.beta) + return e.beta; + var r = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (e) { + var n = this.curve, i = function(s) { + return n.point(s.x.redMul(n.endo.beta), s.y); + }; + e.beta = r, r.precomputed = { + beta: null, + naf: e.naf && { + wnd: e.naf.wnd, + points: e.naf.points.map(i) + }, + doubles: e.doubles && { + step: e.doubles.step, + points: e.doubles.points.map(i) + } + }; + } + return r; + } +}; +Dn.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1) + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1) + } + }] : [this.x, this.y]; +}; +Dn.fromJSON = function(e, r, n) { + typeof r == "string" && (r = JSON.parse(r)); + var i = e.point(r[0], r[1], n); + if (!r[2]) + return i; + function s(a) { + return e.point(a[0], a[1], n); + } + var o = r[2]; + return i.precomputed = { + beta: null, + doubles: o.doubles && { + step: o.doubles.step, + points: [i].concat(o.doubles.points.map(s)) + }, + naf: o.naf && { + wnd: o.naf.wnd, + points: [i].concat(o.naf.points.map(s)) + } + }, i; +}; +Dn.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}; +Dn.prototype.isInfinity = function() { + return this.inf; +}; +Dn.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 r = this.y.redSub(e.y); + r.cmpn(0) !== 0 && (r = r.redMul(this.x.redSub(e.x).redInvm())); + var n = r.redSqr().redISub(this.x).redISub(e.x), i = r.redMul(this.x.redSub(n)).redISub(this.y); + return this.curve.point(n, i); +}; +Dn.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 r = this.curve.a, n = this.x.redSqr(), i = e.redInvm(), s = n.redAdd(n).redIAdd(n).redIAdd(r).redMul(i), 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); +}; +Dn.prototype.getX = function() { + return this.x.fromRed(); +}; +Dn.prototype.getY = function() { + return this.y.fromRed(); +}; +Dn.prototype.mul = function(e) { + return e = new or(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); +}; +Dn.prototype.mulAdd = function(e, r, n) { + var i = [this, r], s = [e, n]; + return this.curve.endo ? this.curve._endoWnafMulAdd(i, s) : this.curve._wnafMulAdd(1, i, s, 2); +}; +Dn.prototype.jmulAdd = function(e, r, n) { + var i = [this, r], s = [e, n]; + return this.curve.endo ? this.curve._endoWnafMulAdd(i, s, !0) : this.curve._wnafMulAdd(1, i, s, 2, !0); +}; +Dn.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); +}; +Dn.prototype.neg = function(e) { + if (this.inf) + return this; + var r = this.curve.point(this.x, this.y.redNeg()); + if (e && this.precomputed) { + var n = this.precomputed, i = function(s) { + return s.neg(); + }; + r.precomputed = { + naf: n.naf && { + wnd: n.naf.wnd, + points: n.naf.points.map(i) + }, + doubles: n.doubles && { + step: n.doubles.step, + points: n.doubles.points.map(i) + } + }; + } + return r; +}; +Dn.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 Bn(t, e, r, n) { + Ka.BasePoint.call(this, t, "jacobian"), e === null && r === null && n === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new or(0)) : (this.x = new or(e, 16), this.y = new or(r, 16), this.z = new or(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.zOne = this.z === this.curve.one; +} +b1(Bn, Ka.BasePoint); +Vi.prototype.jpoint = function(e, r, n) { + return new Bn(this, e, r, n); +}; +Bn.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var e = this.z.redInvm(), r = e.redSqr(), n = this.x.redMul(r), i = this.y.redMul(r).redMul(e); + return this.curve.point(n, i); +}; +Bn.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}; +Bn.prototype.add = function(e) { + if (this.isInfinity()) + return e; + if (e.isInfinity()) + return this; + var r = e.z.redSqr(), n = this.z.redSqr(), i = this.x.redMul(r), s = e.x.redMul(n), o = this.y.redMul(r.redMul(e.z)), a = e.y.redMul(n.redMul(this.z)), f = i.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 h = f.redSqr(), g = h.redMul(f), v = i.redMul(h), x = u.redSqr().redIAdd(g).redISub(v).redISub(v), S = u.redMul(v.redISub(x)).redISub(o.redMul(g)), R = this.z.redMul(e.z).redMul(f); + return this.curve.jpoint(x, S, R); +}; +Bn.prototype.mixedAdd = function(e) { + if (this.isInfinity()) + return e.toJ(); + if (e.isInfinity()) + return this; + var r = this.z.redSqr(), n = this.x, i = e.x.redMul(r), s = this.y, o = e.y.redMul(r).redMul(this.z), a = n.redSub(i), 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(), h = u.redMul(a), g = n.redMul(u), v = f.redSqr().redIAdd(h).redISub(g).redISub(g), x = f.redMul(g.redISub(v)).redISub(s.redMul(h)), S = this.z.redMul(a); + return this.curve.jpoint(v, x, S); +}; +Bn.prototype.dblp = function(e) { + if (e === 0) + return this; + if (this.isInfinity()) + return this; + if (!e) + return this.dbl(); + var r; + if (this.curve.zeroA || this.curve.threeA) { + var n = this; + for (r = 0; r < e; r++) + n = n.dbl(); + return n; + } + var i = this.curve.a, s = this.curve.tinv, o = this.x, a = this.y, f = this.z, u = f.redSqr().redSqr(), h = a.redAdd(a); + for (r = 0; r < e; r++) { + var g = o.redSqr(), v = h.redSqr(), x = v.redSqr(), S = g.redAdd(g).redIAdd(g).redIAdd(i.redMul(u)), R = o.redMul(v), D = S.redSqr().redISub(R.redAdd(R)), k = R.redISub(D), N = S.redMul(k); + N = N.redIAdd(N).redISub(x); + var z = h.redMul(f); + r + 1 < e && (u = u.redMul(x)), o = D, f = z, h = N; + } + return this.curve.jpoint(o, h.redMul(s), f); +}; +Bn.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); +}; +Bn.prototype._zeroDbl = function() { + var e, r, n; + if (this.zOne) { + var i = this.x.redSqr(), s = this.y.redSqr(), o = s.redSqr(), a = this.x.redAdd(s).redSqr().redISub(i).redISub(o); + a = a.redIAdd(a); + var f = i.redAdd(i).redIAdd(i), u = f.redSqr().redISub(a).redISub(a), h = o.redIAdd(o); + h = h.redIAdd(h), h = h.redIAdd(h), e = u, r = f.redMul(a.redISub(u)).redISub(h), n = this.y.redAdd(this.y); + } else { + var g = this.x.redSqr(), v = this.y.redSqr(), x = v.redSqr(), S = this.x.redAdd(v).redSqr().redISub(g).redISub(x); + S = S.redIAdd(S); + var R = g.redAdd(g).redIAdd(g), D = R.redSqr(), k = x.redIAdd(x); + k = k.redIAdd(k), k = k.redIAdd(k), e = D.redISub(S).redISub(S), r = R.redMul(S.redISub(e)).redISub(k), n = this.y.redMul(this.z), n = n.redIAdd(n); + } + return this.curve.jpoint(e, r, n); +}; +Bn.prototype._threeDbl = function() { + var e, r, n; + if (this.zOne) { + var i = this.x.redSqr(), s = this.y.redSqr(), o = s.redSqr(), a = this.x.redAdd(s).redSqr().redISub(i).redISub(o); + a = a.redIAdd(a); + var f = i.redAdd(i).redIAdd(i).redIAdd(this.curve.a), u = f.redSqr().redISub(a).redISub(a); + e = u; + var h = o.redIAdd(o); + h = h.redIAdd(h), h = h.redIAdd(h), r = f.redMul(a.redISub(u)).redISub(h), n = this.y.redAdd(this.y); + } else { + var g = this.z.redSqr(), v = this.y.redSqr(), x = this.x.redMul(v), S = this.x.redSub(g).redMul(this.x.redAdd(g)); + S = S.redAdd(S).redIAdd(S); + var R = x.redIAdd(x); + R = R.redIAdd(R); + var D = R.redAdd(R); + e = S.redSqr().redISub(D), n = this.y.redAdd(this.z).redSqr().redISub(v).redISub(g); + var k = v.redSqr(); + k = k.redIAdd(k), k = k.redIAdd(k), k = k.redIAdd(k), r = S.redMul(R.redISub(e)).redISub(k); + } + return this.curve.jpoint(e, r, n); +}; +Bn.prototype._dbl = function() { + var e = this.curve.a, r = this.x, n = this.y, i = this.z, s = i.redSqr().redSqr(), o = r.redSqr(), a = n.redSqr(), f = o.redAdd(o).redIAdd(o).redIAdd(e.redMul(s)), u = r.redAdd(r); + u = u.redIAdd(u); + var h = u.redMul(a), g = f.redSqr().redISub(h.redAdd(h)), v = h.redISub(g), x = a.redSqr(); + x = x.redIAdd(x), x = x.redIAdd(x), x = x.redIAdd(x); + var S = f.redMul(v).redISub(x), R = n.redAdd(n).redMul(i); + return this.curve.jpoint(g, S, R); +}; +Bn.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var e = this.x.redSqr(), r = this.y.redSqr(), n = this.z.redSqr(), i = r.redSqr(), s = e.redAdd(e).redIAdd(e), o = s.redSqr(), a = this.x.redAdd(r).redSqr().redISub(e).redISub(i); + a = a.redIAdd(a), a = a.redAdd(a).redIAdd(a), a = a.redISub(o); + var f = a.redSqr(), u = i.redIAdd(i); + u = u.redIAdd(u), u = u.redIAdd(u), u = u.redIAdd(u); + var h = s.redIAdd(a).redSqr().redISub(o).redISub(f).redISub(u), g = r.redMul(h); + g = g.redIAdd(g), g = g.redIAdd(g); + var v = this.x.redMul(f).redISub(g); + v = v.redIAdd(v), v = v.redIAdd(v); + var x = this.y.redMul(h.redMul(u.redISub(h)).redISub(a.redMul(f))); + x = x.redIAdd(x), x = x.redIAdd(x), x = x.redIAdd(x); + var S = this.z.redAdd(a).redSqr().redISub(n).redISub(f); + return this.curve.jpoint(v, x, S); +}; +Bn.prototype.mul = function(e, r) { + return e = new or(e, r), this.curve._wnafMul(this, e); +}; +Bn.prototype.eq = function(e) { + if (e.type === "affine") + return this.eq(e.toJ()); + if (this === e) + return !0; + var r = this.z.redSqr(), n = e.z.redSqr(); + if (this.x.redMul(n).redISub(e.x.redMul(r)).cmpn(0) !== 0) + return !1; + var i = r.redMul(this.z), s = n.redMul(e.z); + return this.y.redMul(s).redISub(e.y.redMul(i)).cmpn(0) === 0; +}; +Bn.prototype.eqXToP = function(e) { + var r = this.z.redSqr(), n = e.toRed(this.curve.red).redMul(r); + if (this.x.cmp(n) === 0) + return !0; + for (var i = e.clone(), s = this.curve.redN.redMul(r); ; ) { + if (i.iadd(this.curve.n), i.cmp(this.curve.p) >= 0) + return !1; + if (n.redIAdd(s), this.x.cmp(n) === 0) + return !0; + } +}; +Bn.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; +}; +Bn.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; +}; +var jh = Gc(function(t, e) { + var r = e; + r.base = Ka, r.short = BB, r.mont = /*RicMoo:ethers:require(./mont)*/ + null, r.edwards = /*RicMoo:ethers:require(./edwards)*/ + null; +}), Uh = Gc(function(t, e) { + var r = e, n = Ii.assert; + function i(a) { + a.type === "short" ? this.curve = new jh.short(a) : a.type === "edwards" ? this.curve = new jh.edwards(a) : this.curve = new jh.mont(a), this.g = this.curve.g, this.n = this.curve.n, this.hash = a.hash, n(this.g.validate(), "Invalid curve"), n(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + r.PresetCurve = i; + function s(a, f) { + Object.defineProperty(r, a, { + configurable: !0, + enumerable: !0, + get: function() { + var u = new i(f); + return Object.defineProperty(r, 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: Xs.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: Xs.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: Xs.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: Xs.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: Xs.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: Xs.sha256, + gRed: !1, + g: [ + "9" + ] + }), s("ed25519", { + type: "edwards", + prime: "p25519", + p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", + a: "-1", + c: "1", + // -121665 * (121666^(-1)) (mod P) + d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", + n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", + hash: Xs.sha256, + gRed: !1, + g: [ + "216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", + // 4/5 + "6666666666666666666666666666666666666666666666666666666666666658" + ] + }); + var o; + try { + o = /*RicMoo:ethers:require(./precomputed/secp256k1)*/ + 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: Xs.sha256, + // Precomputed endomorphism + beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", + lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", + basis: [ + { + a: "3086d221a7d46bcde86c90e49284eb15", + b: "-e4437ed6010e88286f547fa90abfe4c3" + }, + { + a: "114ca50f7a8e2f3f657c1108d9d44cfd8", + b: "3086d221a7d46bcde86c90e49284eb15" + } + ], + gRed: !1, + g: [ + "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", + o + ] + }); +}); +function Ko(t) { + if (!(this instanceof Ko)) + return new Ko(t); + this.hash = t.hash, this.predResist = !!t.predResist, this.outLen = this.hash.outSize, this.minEntropy = t.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var e = as.toArray(t.entropy, t.entropyEnc || "hex"), r = as.toArray(t.nonce, t.nonceEnc || "hex"), n = as.toArray(t.pers, t.persEnc || "hex"); + v1( + e.length >= this.minEntropy / 8, + "Not enough entropy. Minimum is: " + this.minEntropy + " bits" + ), this._init(e, r, n); +} +var g8 = Ko; +Ko.prototype._init = function(e, r, n) { + var i = e.concat(r).concat(n); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var s = 0; s < this.V.length; s++) + this.K[s] = 0, this.V[s] = 1; + this._update(i), this._reseed = 1, this.reseedInterval = 281474976710656; +}; +Ko.prototype._hmac = function() { + return new Xs.hmac(this.hash, this.K); +}; +Ko.prototype._update = function(e) { + var r = this._hmac().update(this.V).update([0]); + e && (r = r.update(e)), this.K = r.digest(), this.V = this._hmac().update(this.V).digest(), e && (this.K = this._hmac().update(this.V).update([1]).update(e).digest(), this.V = this._hmac().update(this.V).digest()); +}; +Ko.prototype.reseed = function(e, r, n, i) { + typeof r != "string" && (i = n, n = r, r = null), e = as.toArray(e, r), n = as.toArray(n, i), v1( + e.length >= this.minEntropy / 8, + "Not enough entropy. Minimum is: " + this.minEntropy + " bits" + ), this._update(e.concat(n || [])), this._reseed = 1; +}; +Ko.prototype.generate = function(e, r, n, i) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof r != "string" && (i = n, n = r, r = null), n && (n = as.toArray(n, i || "hex"), this._update(n)); + for (var s = []; s.length < e; ) + this.V = this._hmac().update(this.V).digest(), s = s.concat(this.V); + var o = s.slice(0, e); + return this._update(n), this._reseed++, as.encode(o, r); +}; +var rv = Ii.assert; +function Vn(t, e) { + this.ec = t, this.priv = null, this.pub = null, e.priv && this._importPrivate(e.priv, e.privEnc), e.pub && this._importPublic(e.pub, e.pubEnc); +} +var y1 = Vn; +Vn.fromPublic = function(e, r, n) { + return r instanceof Vn ? r : new Vn(e, { + pub: r, + pubEnc: n + }); +}; +Vn.fromPrivate = function(e, r, n) { + return r instanceof Vn ? r : new Vn(e, { + priv: r, + privEnc: n + }); +}; +Vn.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" }; +}; +Vn.prototype.getPublic = function(e, r) { + return typeof e == "string" && (r = e, e = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), r ? this.pub.encode(r, e) : this.pub; +}; +Vn.prototype.getPrivate = function(e) { + return e === "hex" ? this.priv.toString(16, 2) : this.priv; +}; +Vn.prototype._importPrivate = function(e, r) { + this.priv = new or(e, r || 16), this.priv = this.priv.umod(this.ec.curve.n); +}; +Vn.prototype._importPublic = function(e, r) { + if (e.x || e.y) { + this.ec.curve.type === "mont" ? rv(e.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && rv(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, r); +}; +Vn.prototype.derive = function(e) { + return e.validate() || rv(e.validate(), "public point not validated"), e.mul(this.priv).getX(); +}; +Vn.prototype.sign = function(e, r, n) { + return this.ec.sign(e, this, r, n); +}; +Vn.prototype.verify = function(e, r) { + return this.ec.verify(e, r, this); +}; +Vn.prototype.inspect = function() { + return ""; +}; +var FB = Ii.assert; +function Zd(t, e) { + if (t instanceof Zd) + return t; + this._importDER(t, e) || (FB(t.r && t.s, "Signature without r or s"), this.r = new or(t.r, 16), this.s = new or(t.s, 16), t.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = t.recoveryParam); +} +var Qd = Zd; +function jB() { + this.place = 0; +} +function Eg(t, e) { + var r = t[e.place++]; + if (!(r & 128)) + return r; + var n = r & 15; + if (n === 0 || n > 4) + return !1; + for (var i = 0, s = 0, o = e.place; s < n; s++, o++) + i <<= 8, i |= t[o], i >>>= 0; + return i <= 127 ? !1 : (e.place = o, i); +} +function vx(t) { + for (var e = 0, r = t.length - 1; !t[e] && !(t[e + 1] & 128) && e < r; ) + e++; + return e === 0 ? t : t.slice(e); +} +Zd.prototype._importDER = function(e, r) { + e = Ii.toArray(e, r); + var n = new jB(); + if (e[n.place++] !== 48) + return !1; + var i = Eg(e, n); + if (i === !1 || i + n.place !== e.length || e[n.place++] !== 2) + return !1; + var s = Eg(e, n); + if (s === !1) + return !1; + var o = e.slice(n.place, s + n.place); + if (n.place += s, e[n.place++] !== 2) + return !1; + var a = Eg(e, n); + if (a === !1 || e.length !== a + n.place) + return !1; + var f = e.slice(n.place, a + n.place); + if (o[0] === 0) + if (o[1] & 128) + o = o.slice(1); + else + return !1; + if (f[0] === 0) + if (f[1] & 128) + f = f.slice(1); + else + return !1; + return this.r = new or(o), this.s = new or(f), this.recoveryParam = null, !0; +}; +function Sg(t, e) { + if (e < 128) { + t.push(e); + return; + } + var r = 1 + (Math.log(e) / Math.LN2 >>> 3); + for (t.push(r | 128); --r; ) + t.push(e >>> (r << 3) & 255); + t.push(e); +} +Zd.prototype.toDER = function(e) { + var r = this.r.toArray(), n = this.s.toArray(); + for (r[0] & 128 && (r = [0].concat(r)), n[0] & 128 && (n = [0].concat(n)), r = vx(r), n = vx(n); !n[0] && !(n[1] & 128); ) + n = n.slice(1); + var i = [2]; + Sg(i, r.length), i = i.concat(r), i.push(2), Sg(i, n.length); + var s = i.concat(n), o = [48]; + return Sg(o, s.length), o = o.concat(s), Ii.encode(o, e); +}; +var UB = ( + /*RicMoo:ethers:require(brorand)*/ + (function() { + throw new Error("unsupported"); + }) +), m8 = Ii.assert; +function zi(t) { + if (!(this instanceof zi)) + return new zi(t); + typeof t == "string" && (m8( + Object.prototype.hasOwnProperty.call(Uh, t), + "Unknown curve " + t + ), t = Uh[t]), t instanceof Uh.PresetCurve && (t = { curve: t }), this.curve = t.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = t.curve.g, this.g.precompute(t.curve.n.bitLength() + 1), this.hash = t.hash || t.curve.hash; +} +var qB = zi; +zi.prototype.keyPair = function(e) { + return new y1(this, e); +}; +zi.prototype.keyFromPrivate = function(e, r) { + return y1.fromPrivate(this, e, r); +}; +zi.prototype.keyFromPublic = function(e, r) { + return y1.fromPublic(this, e, r); +}; +zi.prototype.genKeyPair = function(e) { + e || (e = {}); + for (var r = new g8({ + hash: this.hash, + pers: e.pers, + persEnc: e.persEnc || "utf8", + entropy: e.entropy || UB(this.hash.hmacStrength), + entropyEnc: e.entropy && e.entropyEnc || "utf8", + nonce: this.n.toArray() + }), n = this.n.byteLength(), i = this.n.sub(new or(2)); ; ) { + var s = new or(r.generate(n)); + if (!(s.cmp(i) > 0)) + return s.iaddn(1), this.keyFromPrivate(s); + } +}; +zi.prototype._truncateToN = function(e, r) { + var n = e.byteLength() * 8 - this.n.bitLength(); + return n > 0 && (e = e.ushrn(n)), !r && e.cmp(this.n) >= 0 ? e.sub(this.n) : e; +}; +zi.prototype.sign = function(e, r, n, i) { + typeof n == "object" && (i = n, n = null), i || (i = {}), r = this.keyFromPrivate(r, n), e = this._truncateToN(new or(e, 16)); + for (var s = this.n.byteLength(), o = r.getPrivate().toArray("be", s), a = e.toArray("be", s), f = new g8({ + hash: this.hash, + entropy: o, + nonce: a, + pers: i.pers, + persEnc: i.persEnc || "utf8" + }), u = this.n.sub(new or(1)), h = 0; ; h++) { + var g = i.k ? i.k(h) : new or(f.generate(this.n.byteLength())); + if (g = this._truncateToN(g, !0), !(g.cmpn(1) <= 0 || g.cmp(u) >= 0)) { + var v = this.g.mul(g); + if (!v.isInfinity()) { + var x = v.getX(), S = x.umod(this.n); + if (S.cmpn(0) !== 0) { + var R = g.invm(this.n).mul(S.mul(r.getPrivate()).iadd(e)); + if (R = R.umod(this.n), R.cmpn(0) !== 0) { + var D = (v.getY().isOdd() ? 1 : 0) | (x.cmp(S) !== 0 ? 2 : 0); + return i.canonical && R.cmp(this.nh) > 0 && (R = this.n.sub(R), D ^= 1), new Qd({ r: S, s: R, recoveryParam: D }); + } + } + } + } + } +}; +zi.prototype.verify = function(e, r, n, i) { + e = this._truncateToN(new or(e, 16)), n = this.keyFromPublic(n, i), r = new Qd(r, "hex"); + var s = r.r, o = r.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), h; + return this.curve._maxwellTrick ? (h = this.g.jmulAdd(f, n.getPublic(), u), h.isInfinity() ? !1 : h.eqXToP(s)) : (h = this.g.mulAdd(f, n.getPublic(), u), h.isInfinity() ? !1 : h.getX().umod(this.n).cmp(s) === 0); +}; +zi.prototype.recoverPubKey = function(t, e, r, n) { + m8((3 & r) === r, "The recovery param is more than two bits"), e = new Qd(e, n); + var i = this.n, s = new or(t), o = e.r, a = e.s, f = r & 1, u = r >> 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 h = e.r.invm(i), g = i.sub(s).mul(h).umod(i), v = a.mul(h).umod(i); + return this.g.mulAdd(g, o, v); +}; +zi.prototype.getKeyRecoveryParam = function(t, e, r, n) { + if (e = new Qd(e, n), e.recoveryParam !== null) + return e.recoveryParam; + for (var i = 0; i < 4; i++) { + var s; + try { + s = this.recoverPubKey(t, e, i); + } catch { + continue; + } + if (s.eq(r)) + return i; + } + throw new Error("Unable to find valid recovery factor"); +}; +var zB = Gc(function(t, e) { + var r = e; + r.version = "6.5.4", r.utils = Ii, r.rand = /*RicMoo:ethers:require(brorand)*/ + (function() { + throw new Error("unsupported"); + }), r.curve = jh, r.curves = Uh, r.ec = qB, r.eddsa = /*RicMoo:ethers:require(./elliptic/eddsa)*/ + null; +}), HB = zB.ec; +const WB = "signing-key/5.7.0", nv = new Yr(WB); +let Ag = null; +function Do() { + return Ag || (Ag = new HB("secp256k1")), Ag; +} +class KB { + constructor(e) { + Tu(this, "curve", "secp256k1"), Tu(this, "privateKey", _i(e)), pB(this.privateKey) !== 32 && nv.throwArgumentError("invalid private key", "privateKey", "[[ REDACTED ]]"); + const r = Do().keyFromPrivate(bn(this.privateKey)); + Tu(this, "publicKey", "0x" + r.getPublic(!1, "hex")), Tu(this, "compressedPublicKey", "0x" + r.getPublic(!0, "hex")), Tu(this, "_isSigningKey", !0); + } + _addPoint(e) { + const r = Do().keyFromPublic(bn(this.publicKey)), n = Do().keyFromPublic(bn(e)); + return "0x" + r.pub.add(n.pub).encodeCompressed("hex"); + } + signDigest(e) { + const r = Do().keyFromPrivate(bn(this.privateKey)), n = bn(e); + n.length !== 32 && nv.throwArgumentError("bad digest length", "digest", e); + const i = r.sign(n, { canonical: !0 }); + return u8({ + recoveryParam: i.recoveryParam, + r: Oc("0x" + i.r.toString(16), 32), + s: Oc("0x" + i.s.toString(16), 32) + }); + } + computeSharedSecret(e) { + const r = Do().keyFromPrivate(bn(this.privateKey)), n = Do().keyFromPublic(bn(v8(e))); + return Oc("0x" + r.derive(n.getPublic()).toString(16), 32); + } + static isSigningKey(e) { + return !!(e && e._isSigningKey); + } +} +function VB(t, e) { + const r = u8(e), n = { r: bn(r.r), s: bn(r.s) }; + return "0x" + Do().recoverPubKey(bn(t), n, r.recoveryParam).encode("hex", !1); +} +function v8(t, e) { + const r = bn(t); + return r.length === 32 ? new KB(r).publicKey : r.length === 33 ? "0x" + Do().keyFromPublic(r).getPublic(!1, "hex") : r.length === 65 ? _i(r) : nv.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); +} +var bx; +(function(t) { + t[t.legacy = 0] = "legacy", t[t.eip2930 = 1] = "eip2930", t[t.eip1559 = 2] = "eip1559"; +})(bx || (bx = {})); +function GB(t) { + const e = v8(t); + return MB(Z2(g1(Z2(e, 1)), 12)); +} +function YB(t, e) { + return GB(VB(bn(t), e)); +} +var Pg = {}, Du = {}, yx; +function JB() { + if (yx) return Du; + yx = 1, Object.defineProperty(Du, "__esModule", { value: !0 }); + var t = el(), e = ls(), r = 20; + function n(a, f, u) { + for (var h = 1634760805, g = 857760878, v = 2036477234, x = 1797285236, S = u[3] << 24 | u[2] << 16 | u[1] << 8 | u[0], R = u[7] << 24 | u[6] << 16 | u[5] << 8 | u[4], D = u[11] << 24 | u[10] << 16 | u[9] << 8 | u[8], k = u[15] << 24 | u[14] << 16 | u[13] << 8 | u[12], N = u[19] << 24 | u[18] << 16 | u[17] << 8 | u[16], z = u[23] << 24 | u[22] << 16 | u[21] << 8 | u[20], B = u[27] << 24 | u[26] << 16 | u[25] << 8 | u[24], $ = u[31] << 24 | u[30] << 16 | u[29] << 8 | u[28], U = f[3] << 24 | f[2] << 16 | f[1] << 8 | f[0], C = f[7] << 24 | f[6] << 16 | f[5] << 8 | f[4], W = f[11] << 24 | f[10] << 16 | f[9] << 8 | f[8], J = f[15] << 24 | f[14] << 16 | f[13] << 8 | f[12], ne = h, K = g, E = v, b = x, l = S, p = R, m = D, w = k, P = N, _ = z, y = B, M = $, I = U, q = C, ce = W, L = J, oe = 0; oe < r; oe += 2) + ne = ne + l | 0, I ^= ne, I = I >>> 16 | I << 16, P = P + I | 0, l ^= P, l = l >>> 20 | l << 12, K = K + p | 0, q ^= K, q = q >>> 16 | q << 16, _ = _ + q | 0, p ^= _, p = p >>> 20 | p << 12, E = E + m | 0, ce ^= E, ce = ce >>> 16 | ce << 16, y = y + ce | 0, m ^= y, m = m >>> 20 | m << 12, b = b + w | 0, L ^= b, L = L >>> 16 | L << 16, M = M + L | 0, w ^= M, w = w >>> 20 | w << 12, E = E + m | 0, ce ^= E, ce = ce >>> 24 | ce << 8, y = y + ce | 0, m ^= y, m = m >>> 25 | m << 7, b = b + w | 0, L ^= b, L = L >>> 24 | L << 8, M = M + L | 0, w ^= M, w = w >>> 25 | w << 7, K = K + p | 0, q ^= K, q = q >>> 24 | q << 8, _ = _ + q | 0, p ^= _, p = p >>> 25 | p << 7, ne = ne + l | 0, I ^= ne, I = I >>> 24 | I << 8, P = P + I | 0, l ^= P, l = l >>> 25 | l << 7, ne = ne + p | 0, L ^= ne, L = L >>> 16 | L << 16, y = y + L | 0, p ^= y, p = p >>> 20 | p << 12, K = K + m | 0, I ^= K, I = I >>> 16 | I << 16, M = M + I | 0, m ^= M, m = m >>> 20 | m << 12, E = E + w | 0, q ^= E, q = q >>> 16 | q << 16, P = P + q | 0, w ^= P, w = w >>> 20 | w << 12, b = b + l | 0, ce ^= b, ce = ce >>> 16 | ce << 16, _ = _ + ce | 0, l ^= _, l = l >>> 20 | l << 12, E = E + w | 0, q ^= E, q = q >>> 24 | q << 8, P = P + q | 0, w ^= P, w = w >>> 25 | w << 7, b = b + l | 0, ce ^= b, ce = ce >>> 24 | ce << 8, _ = _ + ce | 0, l ^= _, l = l >>> 25 | l << 7, K = K + m | 0, I ^= K, I = I >>> 24 | I << 8, M = M + I | 0, m ^= M, m = m >>> 25 | m << 7, ne = ne + p | 0, L ^= ne, L = L >>> 24 | L << 8, y = y + L | 0, p ^= y, p = p >>> 25 | p << 7; + t.writeUint32LE(ne + h | 0, a, 0), t.writeUint32LE(K + g | 0, a, 4), t.writeUint32LE(E + v | 0, a, 8), t.writeUint32LE(b + x | 0, a, 12), t.writeUint32LE(l + S | 0, a, 16), t.writeUint32LE(p + R | 0, a, 20), t.writeUint32LE(m + D | 0, a, 24), t.writeUint32LE(w + k | 0, a, 28), t.writeUint32LE(P + N | 0, a, 32), t.writeUint32LE(_ + z | 0, a, 36), t.writeUint32LE(y + B | 0, a, 40), t.writeUint32LE(M + $ | 0, a, 44), t.writeUint32LE(I + U | 0, a, 48), t.writeUint32LE(q + C | 0, a, 52), t.writeUint32LE(ce + W | 0, a, 56), t.writeUint32LE(L + J | 0, a, 60); + } + function i(a, f, u, h, g) { + if (g === void 0 && (g = 0), a.length !== 32) + throw new Error("ChaCha: key size must be 32 bytes"); + if (h.length < u.length) + throw new Error("ChaCha: destination is shorter than source"); + var v, x; + if (g === 0) { + if (f.length !== 8 && f.length !== 12) + throw new Error("ChaCha nonce must be 8 or 12 bytes"); + v = new Uint8Array(16), x = v.length - f.length, v.set(f, x); + } else { + if (f.length !== 16) + throw new Error("ChaCha nonce with counter must be 16 bytes"); + v = f, x = g; + } + for (var S = new Uint8Array(64), R = 0; R < u.length; R += 64) { + n(S, v, a); + for (var D = R; D < R + 64 && D < u.length; D++) + h[D] = u[D] ^ S[D - R]; + o(v, 0, x); + } + return e.wipe(S), g === 0 && e.wipe(v), h; + } + Du.streamXOR = i; + function s(a, f, u, h) { + return h === void 0 && (h = 0), e.wipe(u), i(a, f, u, u, h); + } + Du.stream = s; + function o(a, f, u) { + for (var h = 1; u--; ) + h = h + (a[f] & 255) | 0, a[f] = h & 255, h >>>= 8, f++; + if (h > 0) + throw new Error("ChaCha: counter overflow"); + } + return Du; +} +var Mg = {}, pa = {}, wx; +function w1() { + if (wx) return pa; + wx = 1, Object.defineProperty(pa, "__esModule", { value: !0 }); + function t(i, s, o) { + return ~(i - 1) & s | i - 1 & o; + } + pa.select = t; + function e(i, s) { + return (i | 0) - (s | 0) - 1 >>> 31 & 1; + } + pa.lessOrEqual = e; + function r(i, s) { + if (i.length !== s.length) + return 0; + for (var o = 0, a = 0; a < i.length; a++) + o |= i[a] ^ s[a]; + return 1 & o - 1 >>> 8; + } + pa.compare = r; + function n(i, s) { + return i.length === 0 || s.length === 0 ? !1 : r(i, s) !== 0; + } + return pa.equal = n, pa; +} +var xx; +function XB() { + return xx || (xx = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }); + var e = w1(), r = ls(); + t.DIGEST_LENGTH = 16; + var n = ( + /** @class */ + (function() { + function o(a) { + this.digestLength = t.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 f = a[0] | a[1] << 8; + this._r[0] = f & 8191; + var u = a[2] | a[3] << 8; + this._r[1] = (f >>> 13 | u << 3) & 8191; + var h = a[4] | a[5] << 8; + this._r[2] = (u >>> 10 | h << 6) & 7939; + var g = a[6] | a[7] << 8; + this._r[3] = (h >>> 7 | g << 9) & 8191; + var v = a[8] | a[9] << 8; + this._r[4] = (g >>> 4 | v << 12) & 255, this._r[5] = v >>> 1 & 8190; + var x = a[10] | a[11] << 8; + this._r[6] = (v >>> 14 | x << 2) & 8191; + var S = a[12] | a[13] << 8; + this._r[7] = (x >>> 11 | S << 5) & 8065; + var R = a[14] | a[15] << 8; + this._r[8] = (S >>> 8 | R << 8) & 8191, this._r[9] = R >>> 5 & 127, this._pad[0] = a[16] | a[17] << 8, this._pad[1] = a[18] | a[19] << 8, this._pad[2] = a[20] | a[21] << 8, this._pad[3] = a[22] | a[23] << 8, this._pad[4] = a[24] | a[25] << 8, this._pad[5] = a[26] | a[27] << 8, this._pad[6] = a[28] | a[29] << 8, this._pad[7] = a[30] | a[31] << 8; + } + return o.prototype._blocks = function(a, f, u) { + for (var h = this._fin ? 0 : 2048, g = this._h[0], v = this._h[1], x = this._h[2], S = this._h[3], R = this._h[4], D = this._h[5], k = this._h[6], N = this._h[7], z = this._h[8], B = this._h[9], $ = this._r[0], U = this._r[1], C = this._r[2], W = this._r[3], J = this._r[4], ne = this._r[5], K = this._r[6], E = this._r[7], b = this._r[8], l = this._r[9]; u >= 16; ) { + var p = a[f + 0] | a[f + 1] << 8; + g += p & 8191; + var m = a[f + 2] | a[f + 3] << 8; + v += (p >>> 13 | m << 3) & 8191; + var w = a[f + 4] | a[f + 5] << 8; + x += (m >>> 10 | w << 6) & 8191; + var P = a[f + 6] | a[f + 7] << 8; + S += (w >>> 7 | P << 9) & 8191; + var _ = a[f + 8] | a[f + 9] << 8; + R += (P >>> 4 | _ << 12) & 8191, D += _ >>> 1 & 8191; + var y = a[f + 10] | a[f + 11] << 8; + k += (_ >>> 14 | y << 2) & 8191; + var M = a[f + 12] | a[f + 13] << 8; + N += (y >>> 11 | M << 5) & 8191; + var I = a[f + 14] | a[f + 15] << 8; + z += (M >>> 8 | I << 8) & 8191, B += I >>> 5 | h; + var q = 0, ce = q; + ce += g * $, ce += v * (5 * l), ce += x * (5 * b), ce += S * (5 * E), ce += R * (5 * K), q = ce >>> 13, ce &= 8191, ce += D * (5 * ne), ce += k * (5 * J), ce += N * (5 * W), ce += z * (5 * C), ce += B * (5 * U), q += ce >>> 13, ce &= 8191; + var L = q; + L += g * U, L += v * $, L += x * (5 * l), L += S * (5 * b), L += R * (5 * E), q = L >>> 13, L &= 8191, L += D * (5 * K), L += k * (5 * ne), L += N * (5 * J), L += z * (5 * W), L += B * (5 * C), q += L >>> 13, L &= 8191; + var oe = q; + oe += g * C, oe += v * U, oe += x * $, oe += S * (5 * l), oe += R * (5 * b), q = oe >>> 13, oe &= 8191, oe += D * (5 * E), oe += k * (5 * K), oe += N * (5 * ne), oe += z * (5 * J), oe += B * (5 * W), q += oe >>> 13, oe &= 8191; + var Q = q; + Q += g * W, Q += v * C, Q += x * U, Q += S * $, Q += R * (5 * l), q = Q >>> 13, Q &= 8191, Q += D * (5 * b), Q += k * (5 * E), Q += N * (5 * K), Q += z * (5 * ne), Q += B * (5 * J), q += Q >>> 13, Q &= 8191; + var X = q; + X += g * J, X += v * W, X += x * C, X += S * U, X += R * $, q = X >>> 13, X &= 8191, X += D * (5 * l), X += k * (5 * b), X += N * (5 * E), X += z * (5 * K), X += B * (5 * ne), q += X >>> 13, X &= 8191; + var ee = q; + ee += g * ne, ee += v * J, ee += x * W, ee += S * C, ee += R * U, q = ee >>> 13, ee &= 8191, ee += D * $, ee += k * (5 * l), ee += N * (5 * b), ee += z * (5 * E), ee += B * (5 * K), q += ee >>> 13, ee &= 8191; + var O = q; + O += g * K, O += v * ne, O += x * J, O += S * W, O += R * C, q = O >>> 13, O &= 8191, O += D * U, O += k * $, O += N * (5 * l), O += z * (5 * b), O += B * (5 * E), q += O >>> 13, O &= 8191; + var Z = q; + Z += g * E, Z += v * K, Z += x * ne, Z += S * J, Z += R * W, q = Z >>> 13, Z &= 8191, Z += D * C, Z += k * U, Z += N * $, Z += z * (5 * l), Z += B * (5 * b), q += Z >>> 13, Z &= 8191; + var re = q; + re += g * b, re += v * E, re += x * K, re += S * ne, re += R * J, q = re >>> 13, re &= 8191, re += D * W, re += k * C, re += N * U, re += z * $, re += B * (5 * l), q += re >>> 13, re &= 8191; + var he = q; + he += g * l, he += v * b, he += x * E, he += S * K, he += R * ne, q = he >>> 13, he &= 8191, he += D * J, he += k * W, he += N * C, he += z * U, he += B * $, q += he >>> 13, he &= 8191, q = (q << 2) + q | 0, q = q + ce | 0, ce = q & 8191, q = q >>> 13, L += q, g = ce, v = L, x = oe, S = Q, R = X, D = ee, k = O, N = Z, z = re, B = he, f += 16, u -= 16; + } + this._h[0] = g, this._h[1] = v, this._h[2] = x, this._h[3] = S, this._h[4] = R, this._h[5] = D, this._h[6] = k, this._h[7] = N, this._h[8] = z, this._h[9] = B; + }, o.prototype.finish = function(a, f) { + f === void 0 && (f = 0); + var u = new Uint16Array(10), h, g, v, x; + if (this._leftover) { + for (x = this._leftover, this._buffer[x++] = 1; x < 16; x++) + this._buffer[x] = 0; + this._fin = 1, this._blocks(this._buffer, 0, 16); + } + for (h = this._h[1] >>> 13, this._h[1] &= 8191, x = 2; x < 10; x++) + this._h[x] += h, h = this._h[x] >>> 13, this._h[x] &= 8191; + for (this._h[0] += h * 5, h = this._h[0] >>> 13, this._h[0] &= 8191, this._h[1] += h, h = this._h[1] >>> 13, this._h[1] &= 8191, this._h[2] += h, u[0] = this._h[0] + 5, h = u[0] >>> 13, u[0] &= 8191, x = 1; x < 10; x++) + u[x] = this._h[x] + h, h = u[x] >>> 13, u[x] &= 8191; + for (u[9] -= 8192, g = (h ^ 1) - 1, x = 0; x < 10; x++) + u[x] &= g; + for (g = ~g, x = 0; x < 10; x++) + this._h[x] = this._h[x] & g | u[x]; + 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, v = this._h[0] + this._pad[0], this._h[0] = v & 65535, x = 1; x < 8; x++) + v = (this._h[x] + this._pad[x] | 0) + (v >>> 16) | 0, this._h[x] = v & 65535; + return a[f + 0] = this._h[0] >>> 0, a[f + 1] = this._h[0] >>> 8, a[f + 2] = this._h[1] >>> 0, a[f + 3] = this._h[1] >>> 8, a[f + 4] = this._h[2] >>> 0, a[f + 5] = this._h[2] >>> 8, a[f + 6] = this._h[3] >>> 0, a[f + 7] = this._h[3] >>> 8, a[f + 8] = this._h[4] >>> 0, a[f + 9] = this._h[4] >>> 8, a[f + 10] = this._h[5] >>> 0, a[f + 11] = this._h[5] >>> 8, a[f + 12] = this._h[6] >>> 0, a[f + 13] = this._h[6] >>> 8, a[f + 14] = this._h[7] >>> 0, a[f + 15] = this._h[7] >>> 8, this._finished = !0, this; + }, o.prototype.update = function(a) { + var f = 0, u = a.length, h; + if (this._leftover) { + h = 16 - this._leftover, h > u && (h = u); + for (var g = 0; g < h; g++) + this._buffer[this._leftover + g] = a[f + g]; + if (u -= h, f += h, this._leftover += h, this._leftover < 16) + return this; + this._blocks(this._buffer, 0, 16), this._leftover = 0; + } + if (u >= 16 && (h = u - u % 16, this._blocks(a, f, h), f += h, u -= h), u) { + for (var g = 0; g < u; g++) + this._buffer[this._leftover + g] = a[f + g]; + this._leftover += u; + } + return this; + }, o.prototype.digest = function() { + if (this._finished) + throw new Error("Poly1305 was finished"); + var a = new Uint8Array(16); + return this.finish(a), a; + }, o.prototype.clean = function() { + return r.wipe(this._buffer), r.wipe(this._r), r.wipe(this._h), r.wipe(this._pad), this._leftover = 0, this._fin = 0, this._finished = !0, this; + }, o; + })() + ); + t.Poly1305 = n; + function i(o, a) { + var f = new n(o); + f.update(a); + var u = f.digest(); + return f.clean(), u; + } + t.oneTimeAuth = i; + function s(o, a) { + return o.length !== t.DIGEST_LENGTH || a.length !== t.DIGEST_LENGTH ? !1 : e.equal(o, a); + } + t.equal = s; + })(Mg)), Mg; +} +var _x; +function ZB() { + return _x || (_x = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }); + var e = JB(), r = XB(), n = ls(), i = el(), s = w1(); + t.KEY_LENGTH = 32, t.NONCE_LENGTH = 12, t.TAG_LENGTH = 16; + var o = new Uint8Array(16), a = ( + /** @class */ + (function() { + function f(u) { + if (this.nonceLength = t.NONCE_LENGTH, this.tagLength = t.TAG_LENGTH, u.length !== t.KEY_LENGTH) + throw new Error("ChaCha20Poly1305 needs 32-byte key"); + this._key = new Uint8Array(u); + } + return f.prototype.seal = function(u, h, g, v) { + if (u.length > 16) + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + var x = new Uint8Array(16); + x.set(u, x.length - u.length); + var S = new Uint8Array(32); + e.stream(this._key, x, S, 4); + var R = h.length + this.tagLength, D; + if (v) { + if (v.length !== R) + throw new Error("ChaCha20Poly1305: incorrect destination length"); + D = v; + } else + D = new Uint8Array(R); + return e.streamXOR(this._key, x, h, D, 4), this._authenticate(D.subarray(D.length - this.tagLength, D.length), S, D.subarray(0, D.length - this.tagLength), g), n.wipe(x), D; + }, f.prototype.open = function(u, h, g, v) { + if (u.length > 16) + throw new Error("ChaCha20Poly1305: incorrect nonce length"); + if (h.length < this.tagLength) + return null; + var x = new Uint8Array(16); + x.set(u, x.length - u.length); + var S = new Uint8Array(32); + e.stream(this._key, x, S, 4); + var R = new Uint8Array(this.tagLength); + if (this._authenticate(R, S, h.subarray(0, h.length - this.tagLength), g), !s.equal(R, h.subarray(h.length - this.tagLength, h.length))) + return null; + var D = h.length - this.tagLength, k; + if (v) { + if (v.length !== D) + throw new Error("ChaCha20Poly1305: incorrect destination length"); + k = v; + } else + k = new Uint8Array(D); + return e.streamXOR(this._key, x, h.subarray(0, h.length - this.tagLength), k, 4), n.wipe(x), k; + }, f.prototype.clean = function() { + return n.wipe(this._key), this; + }, f.prototype._authenticate = function(u, h, g, v) { + var x = new r.Poly1305(h); + v && (x.update(v), v.length % 16 > 0 && x.update(o.subarray(v.length % 16))), x.update(g), g.length % 16 > 0 && x.update(o.subarray(g.length % 16)); + var S = new Uint8Array(8); + v && i.writeUint64LE(v.length, S), x.update(S), i.writeUint64LE(g.length, S), x.update(S); + for (var R = x.digest(), D = 0; D < R.length; D++) + u[D] = R[D]; + x.clean(), n.wipe(R), n.wipe(S); + }, f; + })() + ); + t.ChaCha20Poly1305 = a; + })(Pg)), Pg; +} +var b8 = ZB(), wh = {}, pc = {}, xh = {}, Ex; +function QB() { + if (Ex) return xh; + Ex = 1, Object.defineProperty(xh, "__esModule", { value: !0 }); + function t(e) { + return typeof e.saveState < "u" && typeof e.restoreState < "u" && typeof e.cleanSavedState < "u"; + } + return xh.isSerializableHash = t, xh; +} +var Sx; +function eF() { + if (Sx) return pc; + Sx = 1, Object.defineProperty(pc, "__esModule", { value: !0 }); + var t = QB(), e = w1(), r = ls(), n = ( + /** @class */ + (function() { + function s(o, a) { + this._finished = !1, this._inner = new o(), this._outer = new o(), this.blockSize = this._outer.blockSize, this.digestLength = this._outer.digestLength; + var f = new Uint8Array(this.blockSize); + a.length > this.blockSize ? this._inner.update(a).finish(f).clean() : f.set(a); + for (var u = 0; u < f.length; u++) + f[u] ^= 54; + this._inner.update(f); + for (var u = 0; u < f.length; u++) + f[u] ^= 106; + this._outer.update(f), t.isSerializableHash(this._inner) && t.isSerializableHash(this._outer) && (this._innerKeyedState = this._inner.saveState(), this._outerKeyedState = this._outer.saveState()), r.wipe(f); + } + return s.prototype.reset = function() { + if (!t.isSerializableHash(this._inner) || !t.isSerializableHash(this._outer)) + throw new Error("hmac: can't reset() because hash doesn't implement restoreState()"); + return this._inner.restoreState(this._innerKeyedState), this._outer.restoreState(this._outerKeyedState), this._finished = !1, this; + }, s.prototype.clean = function() { + t.isSerializableHash(this._inner) && this._inner.cleanSavedState(this._innerKeyedState), t.isSerializableHash(this._outer) && this._outer.cleanSavedState(this._outerKeyedState), this._inner.clean(), this._outer.clean(); + }, s.prototype.update = function(o) { + return this._inner.update(o), this; + }, s.prototype.finish = function(o) { + return this._finished ? (this._outer.finish(o), this) : (this._inner.finish(o), this._outer.update(o.subarray(0, this.digestLength)).finish(o), this._finished = !0, this); + }, s.prototype.digest = function() { + var o = new Uint8Array(this.digestLength); + return this.finish(o), o; + }, s.prototype.saveState = function() { + if (!t.isSerializableHash(this._inner)) + throw new Error("hmac: can't saveState() because hash doesn't implement it"); + return this._inner.saveState(); + }, s.prototype.restoreState = function(o) { + if (!t.isSerializableHash(this._inner) || !t.isSerializableHash(this._outer)) + throw new Error("hmac: can't restoreState() because hash doesn't implement it"); + return this._inner.restoreState(o), this._outer.restoreState(this._outerKeyedState), this._finished = !1, this; + }, s.prototype.cleanSavedState = function(o) { + if (!t.isSerializableHash(this._inner)) + throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it"); + this._inner.cleanSavedState(o); + }, s; + })() + ); + pc.HMAC = n; + function i(s, o, a) { + var f = new n(s, o); + f.update(a); + var u = f.digest(); + return f.clean(), u; + } + return pc.hmac = i, pc.equal = e.equal, pc; +} +var Ax; +function tF() { + if (Ax) return wh; + Ax = 1, Object.defineProperty(wh, "__esModule", { value: !0 }); + var t = eF(), e = ls(), r = ( + /** @class */ + (function() { + function n(i, s, o, a) { + o === void 0 && (o = new Uint8Array(0)), this._counter = new Uint8Array(1), this._hash = i, this._info = a; + var f = t.hmac(this._hash, o, s); + this._hmac = new t.HMAC(i, f), this._buffer = new Uint8Array(this._hmac.digestLength), this._bufpos = this._buffer.length; + } + return n.prototype._fillBuffer = function() { + this._counter[0]++; + var i = this._counter[0]; + if (i === 0) + throw new Error("hkdf: cannot expand more"); + this._hmac.reset(), i > 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; + }, n.prototype.expand = function(i) { + for (var s = new Uint8Array(i), o = 0; o < s.length; o++) + this._bufpos === this._buffer.length && this._fillBuffer(), s[o] = this._buffer[this._bufpos++]; + return s; + }, n.prototype.clean = function() { + this._hmac.clean(), e.wipe(this._buffer), e.wipe(this._counter), this._bufpos = 0; + }, n; + })() + ); + return wh.HKDF = r, wh; +} +var rF = tF(), Ig = {}, Px; +function nF() { + return Px || (Px = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }); + var e = el(), r = ls(); + t.DIGEST_LENGTH = 32, t.BLOCK_SIZE = 64; + var n = ( + /** @class */ + (function() { + function a() { + this.digestLength = t.DIGEST_LENGTH, this.blockSize = t.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 a.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; + }, a.prototype.reset = function() { + return this._initState(), this._bufferLength = 0, this._bytesHashed = 0, this._finished = !1, this; + }, a.prototype.clean = function() { + r.wipe(this._buffer), r.wipe(this._temp), this.reset(); + }, a.prototype.update = function(f, u) { + if (u === void 0 && (u = f.length), this._finished) + throw new Error("SHA256: can't update because hash was finished."); + var h = 0; + if (this._bytesHashed += u, this._bufferLength > 0) { + for (; this._bufferLength < this.blockSize && u > 0; ) + this._buffer[this._bufferLength++] = f[h++], u--; + this._bufferLength === this.blockSize && (s(this._temp, this._state, this._buffer, 0, this.blockSize), this._bufferLength = 0); + } + for (u >= this.blockSize && (h = s(this._temp, this._state, f, h, u), u %= this.blockSize); u > 0; ) + this._buffer[this._bufferLength++] = f[h++], u--; + return this; + }, a.prototype.finish = function(f) { + if (!this._finished) { + var u = this._bytesHashed, h = this._bufferLength, g = u / 536870912 | 0, v = u << 3, x = u % 64 < 56 ? 64 : 128; + this._buffer[h] = 128; + for (var S = h + 1; S < x - 8; S++) + this._buffer[S] = 0; + e.writeUint32BE(g, this._buffer, x - 8), e.writeUint32BE(v, this._buffer, x - 4), s(this._temp, this._state, this._buffer, 0, x), this._finished = !0; + } + for (var S = 0; S < this.digestLength / 4; S++) + e.writeUint32BE(this._state[S], f, S * 4); + return this; + }, a.prototype.digest = function() { + var f = new Uint8Array(this.digestLength); + return this.finish(f), f; + }, a.prototype.saveState = function() { + if (this._finished) + throw new Error("SHA256: cannot save finished state"); + return { + state: new Int32Array(this._state), + buffer: this._bufferLength > 0 ? new Uint8Array(this._buffer) : void 0, + bufferLength: this._bufferLength, + bytesHashed: this._bytesHashed + }; + }, a.prototype.restoreState = function(f) { + return this._state.set(f.state), this._bufferLength = f.bufferLength, f.buffer && this._buffer.set(f.buffer), this._bytesHashed = f.bytesHashed, this._finished = !1, this; + }, a.prototype.cleanSavedState = function(f) { + r.wipe(f.state), f.buffer && r.wipe(f.buffer), f.bufferLength = 0, f.bytesHashed = 0; + }, a; + })() + ); + t.SHA256 = n; + var i = 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 s(a, f, u, h, g) { + for (; g >= 64; ) { + for (var v = f[0], x = f[1], S = f[2], R = f[3], D = f[4], k = f[5], N = f[6], z = f[7], B = 0; B < 16; B++) { + var $ = h + B * 4; + a[B] = e.readUint32BE(u, $); + } + for (var B = 16; B < 64; B++) { + var U = a[B - 2], C = (U >>> 17 | U << 15) ^ (U >>> 19 | U << 13) ^ U >>> 10; + U = a[B - 15]; + var W = (U >>> 7 | U << 25) ^ (U >>> 18 | U << 14) ^ U >>> 3; + a[B] = (C + a[B - 7] | 0) + (W + a[B - 16] | 0); + } + for (var B = 0; B < 64; B++) { + var C = (((D >>> 6 | D << 26) ^ (D >>> 11 | D << 21) ^ (D >>> 25 | D << 7)) + (D & k ^ ~D & N) | 0) + (z + (i[B] + a[B] | 0) | 0) | 0, W = ((v >>> 2 | v << 30) ^ (v >>> 13 | v << 19) ^ (v >>> 22 | v << 10)) + (v & x ^ v & S ^ x & S) | 0; + z = N, N = k, k = D, D = R + C | 0, R = S, S = x, x = v, v = C + W | 0; + } + f[0] += v, f[1] += x, f[2] += S, f[3] += R, f[4] += D, f[5] += k, f[6] += N, f[7] += z, h += 64, g -= 64; + } + return h; + } + function o(a) { + var f = new n(); + f.update(a); + var u = f.digest(); + return f.clean(), u; + } + t.hash = o; + })(Ig)), Ig; +} +var e0 = nF(), Cg = {}, Mx; +function iF() { + return Mx || (Mx = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }), t.sharedKey = t.generateKeyPair = t.generateKeyPairFromSeed = t.scalarMultBase = t.scalarMult = t.SHARED_KEY_LENGTH = t.SECRET_KEY_LENGTH = t.PUBLIC_KEY_LENGTH = void 0; + const e = d1(), r = ls(); + t.PUBLIC_KEY_LENGTH = 32, t.SECRET_KEY_LENGTH = 32, t.SHARED_KEY_LENGTH = 32; + function n(B) { + const $ = new Float64Array(16); + if (B) + for (let U = 0; U < B.length; U++) + $[U] = B[U]; + return $; + } + const i = new Uint8Array(32); + i[0] = 9; + const s = n([56129, 1]); + function o(B) { + let $ = 1; + for (let U = 0; U < 16; U++) { + let C = B[U] + $ + 65535; + $ = Math.floor(C / 65536), B[U] = C - $ * 65536; + } + B[0] += $ - 1 + 37 * ($ - 1); + } + function a(B, $, U) { + const C = ~(U - 1); + for (let W = 0; W < 16; W++) { + const J = C & (B[W] ^ $[W]); + B[W] ^= J, $[W] ^= J; + } + } + function f(B, $) { + const U = n(), C = n(); + for (let W = 0; W < 16; W++) + C[W] = $[W]; + o(C), o(C), o(C); + for (let W = 0; W < 2; W++) { + U[0] = C[0] - 65517; + for (let ne = 1; ne < 15; ne++) + U[ne] = C[ne] - 65535 - (U[ne - 1] >> 16 & 1), U[ne - 1] &= 65535; + U[15] = C[15] - 32767 - (U[14] >> 16 & 1); + const J = U[15] >> 16 & 1; + U[14] &= 65535, a(C, U, 1 - J); + } + for (let W = 0; W < 16; W++) + B[2 * W] = C[W] & 255, B[2 * W + 1] = C[W] >> 8; + } + function u(B, $) { + for (let U = 0; U < 16; U++) + B[U] = $[2 * U] + ($[2 * U + 1] << 8); + B[15] &= 32767; + } + function h(B, $, U) { + for (let C = 0; C < 16; C++) + B[C] = $[C] + U[C]; + } + function g(B, $, U) { + for (let C = 0; C < 16; C++) + B[C] = $[C] - U[C]; + } + function v(B, $, U) { + let C, W, J = 0, ne = 0, K = 0, E = 0, b = 0, l = 0, p = 0, m = 0, w = 0, P = 0, _ = 0, y = 0, M = 0, I = 0, q = 0, ce = 0, L = 0, oe = 0, Q = 0, X = 0, ee = 0, O = 0, Z = 0, re = 0, he = 0, ae = 0, fe = 0, be = 0, Ae = 0, Te = 0, Re = 0, $e = U[0], Me = U[1], Oe = U[2], ze = U[3], De = U[4], je = U[5], Ue = U[6], _e = U[7], Ze = U[8], ot = U[9], ke = U[10], rt = U[11], nt = U[12], Ge = U[13], ht = U[14], lt = U[15]; + C = $[0], J += C * $e, ne += C * Me, K += C * Oe, E += C * ze, b += C * De, l += C * je, p += C * Ue, m += C * _e, w += C * Ze, P += C * ot, _ += C * ke, y += C * rt, M += C * nt, I += C * Ge, q += C * ht, ce += C * lt, C = $[1], ne += C * $e, K += C * Me, E += C * Oe, b += C * ze, l += C * De, p += C * je, m += C * Ue, w += C * _e, P += C * Ze, _ += C * ot, y += C * ke, M += C * rt, I += C * nt, q += C * Ge, ce += C * ht, L += C * lt, C = $[2], K += C * $e, E += C * Me, b += C * Oe, l += C * ze, p += C * De, m += C * je, w += C * Ue, P += C * _e, _ += C * Ze, y += C * ot, M += C * ke, I += C * rt, q += C * nt, ce += C * Ge, L += C * ht, oe += C * lt, C = $[3], E += C * $e, b += C * Me, l += C * Oe, p += C * ze, m += C * De, w += C * je, P += C * Ue, _ += C * _e, y += C * Ze, M += C * ot, I += C * ke, q += C * rt, ce += C * nt, L += C * Ge, oe += C * ht, Q += C * lt, C = $[4], b += C * $e, l += C * Me, p += C * Oe, m += C * ze, w += C * De, P += C * je, _ += C * Ue, y += C * _e, M += C * Ze, I += C * ot, q += C * ke, ce += C * rt, L += C * nt, oe += C * Ge, Q += C * ht, X += C * lt, C = $[5], l += C * $e, p += C * Me, m += C * Oe, w += C * ze, P += C * De, _ += C * je, y += C * Ue, M += C * _e, I += C * Ze, q += C * ot, ce += C * ke, L += C * rt, oe += C * nt, Q += C * Ge, X += C * ht, ee += C * lt, C = $[6], p += C * $e, m += C * Me, w += C * Oe, P += C * ze, _ += C * De, y += C * je, M += C * Ue, I += C * _e, q += C * Ze, ce += C * ot, L += C * ke, oe += C * rt, Q += C * nt, X += C * Ge, ee += C * ht, O += C * lt, C = $[7], m += C * $e, w += C * Me, P += C * Oe, _ += C * ze, y += C * De, M += C * je, I += C * Ue, q += C * _e, ce += C * Ze, L += C * ot, oe += C * ke, Q += C * rt, X += C * nt, ee += C * Ge, O += C * ht, Z += C * lt, C = $[8], w += C * $e, P += C * Me, _ += C * Oe, y += C * ze, M += C * De, I += C * je, q += C * Ue, ce += C * _e, L += C * Ze, oe += C * ot, Q += C * ke, X += C * rt, ee += C * nt, O += C * Ge, Z += C * ht, re += C * lt, C = $[9], P += C * $e, _ += C * Me, y += C * Oe, M += C * ze, I += C * De, q += C * je, ce += C * Ue, L += C * _e, oe += C * Ze, Q += C * ot, X += C * ke, ee += C * rt, O += C * nt, Z += C * Ge, re += C * ht, he += C * lt, C = $[10], _ += C * $e, y += C * Me, M += C * Oe, I += C * ze, q += C * De, ce += C * je, L += C * Ue, oe += C * _e, Q += C * Ze, X += C * ot, ee += C * ke, O += C * rt, Z += C * nt, re += C * Ge, he += C * ht, ae += C * lt, C = $[11], y += C * $e, M += C * Me, I += C * Oe, q += C * ze, ce += C * De, L += C * je, oe += C * Ue, Q += C * _e, X += C * Ze, ee += C * ot, O += C * ke, Z += C * rt, re += C * nt, he += C * Ge, ae += C * ht, fe += C * lt, C = $[12], M += C * $e, I += C * Me, q += C * Oe, ce += C * ze, L += C * De, oe += C * je, Q += C * Ue, X += C * _e, ee += C * Ze, O += C * ot, Z += C * ke, re += C * rt, he += C * nt, ae += C * Ge, fe += C * ht, be += C * lt, C = $[13], I += C * $e, q += C * Me, ce += C * Oe, L += C * ze, oe += C * De, Q += C * je, X += C * Ue, ee += C * _e, O += C * Ze, Z += C * ot, re += C * ke, he += C * rt, ae += C * nt, fe += C * Ge, be += C * ht, Ae += C * lt, C = $[14], q += C * $e, ce += C * Me, L += C * Oe, oe += C * ze, Q += C * De, X += C * je, ee += C * Ue, O += C * _e, Z += C * Ze, re += C * ot, he += C * ke, ae += C * rt, fe += C * nt, be += C * Ge, Ae += C * ht, Te += C * lt, C = $[15], ce += C * $e, L += C * Me, oe += C * Oe, Q += C * ze, X += C * De, ee += C * je, O += C * Ue, Z += C * _e, re += C * Ze, he += C * ot, ae += C * ke, fe += C * rt, be += C * nt, Ae += C * Ge, Te += C * ht, Re += C * lt, J += 38 * L, ne += 38 * oe, K += 38 * Q, E += 38 * X, b += 38 * ee, l += 38 * O, p += 38 * Z, m += 38 * re, w += 38 * he, P += 38 * ae, _ += 38 * fe, y += 38 * be, M += 38 * Ae, I += 38 * Te, q += 38 * Re, W = 1, C = J + W + 65535, W = Math.floor(C / 65536), J = C - W * 65536, C = ne + W + 65535, W = Math.floor(C / 65536), ne = C - W * 65536, C = K + W + 65535, W = Math.floor(C / 65536), K = C - W * 65536, C = E + W + 65535, W = Math.floor(C / 65536), E = C - W * 65536, C = b + W + 65535, W = Math.floor(C / 65536), b = C - W * 65536, C = l + W + 65535, W = Math.floor(C / 65536), l = C - W * 65536, C = p + W + 65535, W = Math.floor(C / 65536), p = C - W * 65536, C = m + W + 65535, W = Math.floor(C / 65536), m = C - W * 65536, C = w + W + 65535, W = Math.floor(C / 65536), w = C - W * 65536, C = P + W + 65535, W = Math.floor(C / 65536), P = C - W * 65536, C = _ + W + 65535, W = Math.floor(C / 65536), _ = C - W * 65536, C = y + W + 65535, W = Math.floor(C / 65536), y = C - W * 65536, C = M + W + 65535, W = Math.floor(C / 65536), M = C - W * 65536, C = I + W + 65535, W = Math.floor(C / 65536), I = C - W * 65536, C = q + W + 65535, W = Math.floor(C / 65536), q = C - W * 65536, C = ce + W + 65535, W = Math.floor(C / 65536), ce = C - W * 65536, J += W - 1 + 37 * (W - 1), W = 1, C = J + W + 65535, W = Math.floor(C / 65536), J = C - W * 65536, C = ne + W + 65535, W = Math.floor(C / 65536), ne = C - W * 65536, C = K + W + 65535, W = Math.floor(C / 65536), K = C - W * 65536, C = E + W + 65535, W = Math.floor(C / 65536), E = C - W * 65536, C = b + W + 65535, W = Math.floor(C / 65536), b = C - W * 65536, C = l + W + 65535, W = Math.floor(C / 65536), l = C - W * 65536, C = p + W + 65535, W = Math.floor(C / 65536), p = C - W * 65536, C = m + W + 65535, W = Math.floor(C / 65536), m = C - W * 65536, C = w + W + 65535, W = Math.floor(C / 65536), w = C - W * 65536, C = P + W + 65535, W = Math.floor(C / 65536), P = C - W * 65536, C = _ + W + 65535, W = Math.floor(C / 65536), _ = C - W * 65536, C = y + W + 65535, W = Math.floor(C / 65536), y = C - W * 65536, C = M + W + 65535, W = Math.floor(C / 65536), M = C - W * 65536, C = I + W + 65535, W = Math.floor(C / 65536), I = C - W * 65536, C = q + W + 65535, W = Math.floor(C / 65536), q = C - W * 65536, C = ce + W + 65535, W = Math.floor(C / 65536), ce = C - W * 65536, J += W - 1 + 37 * (W - 1), B[0] = J, B[1] = ne, B[2] = K, B[3] = E, B[4] = b, B[5] = l, B[6] = p, B[7] = m, B[8] = w, B[9] = P, B[10] = _, B[11] = y, B[12] = M, B[13] = I, B[14] = q, B[15] = ce; + } + function x(B, $) { + v(B, $, $); + } + function S(B, $) { + const U = n(); + for (let C = 0; C < 16; C++) + U[C] = $[C]; + for (let C = 253; C >= 0; C--) + x(U, U), C !== 2 && C !== 4 && v(U, U, $); + for (let C = 0; C < 16; C++) + B[C] = U[C]; + } + function R(B, $) { + const U = new Uint8Array(32), C = new Float64Array(80), W = n(), J = n(), ne = n(), K = n(), E = n(), b = n(); + for (let w = 0; w < 31; w++) + U[w] = B[w]; + U[31] = B[31] & 127 | 64, U[0] &= 248, u(C, $); + for (let w = 0; w < 16; w++) + J[w] = C[w]; + W[0] = K[0] = 1; + for (let w = 254; w >= 0; --w) { + const P = U[w >>> 3] >>> (w & 7) & 1; + a(W, J, P), a(ne, K, P), h(E, W, ne), g(W, W, ne), h(ne, J, K), g(J, J, K), x(K, E), x(b, W), v(W, ne, W), v(ne, J, E), h(E, W, ne), g(W, W, ne), x(J, W), g(ne, K, b), v(W, ne, s), h(W, W, K), v(ne, ne, W), v(W, K, b), v(K, J, C), x(J, E), a(W, J, P), a(ne, K, P); + } + for (let w = 0; w < 16; w++) + C[w + 16] = W[w], C[w + 32] = ne[w], C[w + 48] = J[w], C[w + 64] = K[w]; + const l = C.subarray(32), p = C.subarray(16); + S(l, l), v(p, p, l); + const m = new Uint8Array(32); + return f(m, p), m; + } + t.scalarMult = R; + function D(B) { + return R(B, i); + } + t.scalarMultBase = D; + function k(B) { + if (B.length !== t.SECRET_KEY_LENGTH) + throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`); + const $ = new Uint8Array(B); + return { + publicKey: D($), + secretKey: $ + }; + } + t.generateKeyPairFromSeed = k; + function N(B) { + const $ = (0, e.randomBytes)(32, B), U = k($); + return (0, r.wipe)($), U; + } + t.generateKeyPair = N; + function z(B, $, U = !1) { + if (B.length !== t.PUBLIC_KEY_LENGTH) + throw new Error("X25519: incorrect secret key length"); + if ($.length !== t.PUBLIC_KEY_LENGTH) + throw new Error("X25519: incorrect public key length"); + const C = R(B, $); + if (U) { + let W = 0; + for (let J = 0; J < C.length; J++) + W |= C[J]; + if (W === 0) + throw new Error("X25519: invalid shared key"); + } + return C; + } + t.sharedKey = z; + })(Cg)), Cg; +} +var y8 = iF(), Rg = {}; +const sF = "6.6.0", oF = { + version: sF +}; +var Tg = {}, qh = { exports: {} }, aF = qh.exports, Ix; +function go() { + return Ix || (Ix = 1, (function(t) { + (function(e, r) { + function n(K, E) { + if (!K) throw new Error(E || "Assertion failed"); + } + function i(K, E) { + K.super_ = E; + var b = function() { + }; + b.prototype = E.prototype, K.prototype = new b(), K.prototype.constructor = K; + } + function s(K, E, b) { + if (s.isBN(K)) + return K; + this.negative = 0, this.words = null, this.length = 0, this.red = null, K !== null && ((E === "le" || E === "be") && (b = E, E = 10), this._init(K || 0, E || 10, b || "be")); + } + typeof e == "object" ? e.exports = s : r.BN = s, s.BN = s, s.wordSize = 26; + var o; + try { + typeof window < "u" && typeof window.Buffer < "u" ? o = window.Buffer : o = Qf.Buffer; + } catch { + } + s.isBN = function(E) { + return E instanceof s ? !0 : E !== null && typeof E == "object" && E.constructor.wordSize === s.wordSize && Array.isArray(E.words); + }, s.max = function(E, b) { + return E.cmp(b) > 0 ? E : b; + }, s.min = function(E, b) { + return E.cmp(b) < 0 ? E : b; + }, s.prototype._init = function(E, b, l) { + if (typeof E == "number") + return this._initNumber(E, b, l); + if (typeof E == "object") + return this._initArray(E, b, l); + b === "hex" && (b = 16), n(b === (b | 0) && b >= 2 && b <= 36), E = E.toString().replace(/\s+/g, ""); + var p = 0; + E[0] === "-" && (p++, this.negative = 1), p < E.length && (b === 16 ? this._parseHex(E, p, l) : (this._parseBase(E, b, p), l === "le" && this._initArray(this.toArray(), b, l))); + }, s.prototype._initNumber = function(E, b, l) { + E < 0 && (this.negative = 1, E = -E), E < 67108864 ? (this.words = [E & 67108863], this.length = 1) : E < 4503599627370496 ? (this.words = [ + E & 67108863, + E / 67108864 & 67108863 + ], this.length = 2) : (n(E < 9007199254740992), this.words = [ + E & 67108863, + E / 67108864 & 67108863, + 1 + ], this.length = 3), l === "le" && this._initArray(this.toArray(), b, l); + }, s.prototype._initArray = function(E, b, l) { + if (n(typeof E.length == "number"), E.length <= 0) + return this.words = [0], this.length = 1, this; + this.length = Math.ceil(E.length / 3), this.words = new Array(this.length); + for (var p = 0; p < this.length; p++) + this.words[p] = 0; + var m, w, P = 0; + if (l === "be") + for (p = E.length - 1, m = 0; p >= 0; p -= 3) + w = E[p] | E[p - 1] << 8 | E[p - 2] << 16, this.words[m] |= w << P & 67108863, this.words[m + 1] = w >>> 26 - P & 67108863, P += 24, P >= 26 && (P -= 26, m++); + else if (l === "le") + for (p = 0, m = 0; p < E.length; p += 3) + w = E[p] | E[p + 1] << 8 | E[p + 2] << 16, this.words[m] |= w << P & 67108863, this.words[m + 1] = w >>> 26 - P & 67108863, P += 24, P >= 26 && (P -= 26, m++); + return this.strip(); + }; + function a(K, E) { + var b = K.charCodeAt(E); + return b >= 65 && b <= 70 ? b - 55 : b >= 97 && b <= 102 ? b - 87 : b - 48 & 15; + } + function f(K, E, b) { + var l = a(K, b); + return b - 1 >= E && (l |= a(K, b - 1) << 4), l; + } + s.prototype._parseHex = function(E, b, l) { + this.length = Math.ceil((E.length - b) / 6), this.words = new Array(this.length); + for (var p = 0; p < this.length; p++) + this.words[p] = 0; + var m = 0, w = 0, P; + if (l === "be") + for (p = E.length - 1; p >= b; p -= 2) + P = f(E, b, p) << m, this.words[w] |= P & 67108863, m >= 18 ? (m -= 18, w += 1, this.words[w] |= P >>> 26) : m += 8; + else { + var _ = E.length - b; + for (p = _ % 2 === 0 ? b + 1 : b; p < E.length; p += 2) + P = f(E, b, p) << m, this.words[w] |= P & 67108863, m >= 18 ? (m -= 18, w += 1, this.words[w] |= P >>> 26) : m += 8; + } + this.strip(); + }; + function u(K, E, b, l) { + for (var p = 0, m = Math.min(K.length, b), w = E; w < m; w++) { + var P = K.charCodeAt(w) - 48; + p *= l, P >= 49 ? p += P - 49 + 10 : P >= 17 ? p += P - 17 + 10 : p += P; + } + return p; + } + s.prototype._parseBase = function(E, b, l) { + this.words = [0], this.length = 1; + for (var p = 0, m = 1; m <= 67108863; m *= b) + p++; + p--, m = m / b | 0; + for (var w = E.length - l, P = w % p, _ = Math.min(w, w - P) + l, y = 0, M = l; M < _; M += p) + y = u(E, M, M + p, b), this.imuln(m), this.words[0] + y < 67108864 ? this.words[0] += y : this._iaddn(y); + if (P !== 0) { + var I = 1; + for (y = u(E, M, E.length, b), M = 0; M < P; M++) + I *= b; + this.imuln(I), this.words[0] + y < 67108864 ? this.words[0] += y : this._iaddn(y); + } + this.strip(); + }, s.prototype.copy = function(E) { + E.words = new Array(this.length); + for (var b = 0; b < this.length; b++) + E.words[b] = this.words[b]; + E.length = this.length, E.negative = this.negative, E.red = this.red; + }, s.prototype.clone = function() { + var E = new s(null); + return this.copy(E), E; + }, s.prototype._expand = function(E) { + for (; this.length < E; ) + this.words[this.length++] = 0; + return this; + }, s.prototype.strip = function() { + for (; this.length > 1 && this.words[this.length - 1] === 0; ) + this.length--; + return this._normSign(); + }, s.prototype._normSign = function() { + return this.length === 1 && this.words[0] === 0 && (this.negative = 0), this; + }, s.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" + ], 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 + ], 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 + ]; + s.prototype.toString = function(E, b) { + E = E || 10, b = b | 0 || 1; + var l; + if (E === 16 || E === "hex") { + l = ""; + for (var p = 0, m = 0, w = 0; w < this.length; w++) { + var P = this.words[w], _ = ((P << p | m) & 16777215).toString(16); + m = P >>> 24 - p & 16777215, p += 2, p >= 26 && (p -= 26, w--), m !== 0 || w !== this.length - 1 ? l = h[6 - _.length] + _ + l : l = _ + l; + } + for (m !== 0 && (l = m.toString(16) + l); l.length % b !== 0; ) + l = "0" + l; + return this.negative !== 0 && (l = "-" + l), l; + } + if (E === (E | 0) && E >= 2 && E <= 36) { + var y = g[E], M = v[E]; + l = ""; + var I = this.clone(); + for (I.negative = 0; !I.isZero(); ) { + var q = I.modn(M).toString(E); + I = I.idivn(M), I.isZero() ? l = q + l : l = h[y - q.length] + q + l; + } + for (this.isZero() && (l = "0" + l); l.length % b !== 0; ) + l = "0" + l; + return this.negative !== 0 && (l = "-" + l), l; + } + n(!1, "Base should be between 2 and 36"); + }, s.prototype.toNumber = function() { + var E = this.words[0]; + return this.length === 2 ? E += this.words[1] * 67108864 : this.length === 3 && this.words[2] === 1 ? E += 4503599627370496 + this.words[1] * 67108864 : this.length > 2 && n(!1, "Number can only safely store up to 53 bits"), this.negative !== 0 ? -E : E; + }, s.prototype.toJSON = function() { + return this.toString(16); + }, s.prototype.toBuffer = function(E, b) { + return n(typeof o < "u"), this.toArrayLike(o, E, b); + }, s.prototype.toArray = function(E, b) { + return this.toArrayLike(Array, E, b); + }, s.prototype.toArrayLike = function(E, b, l) { + var p = this.byteLength(), m = l || Math.max(1, p); + n(p <= m, "byte array longer than desired length"), n(m > 0, "Requested array length <= 0"), this.strip(); + var w = b === "le", P = new E(m), _, y, M = this.clone(); + if (w) { + for (y = 0; !M.isZero(); y++) + _ = M.andln(255), M.iushrn(8), P[y] = _; + for (; y < m; y++) + P[y] = 0; + } else { + for (y = 0; y < m - p; y++) + P[y] = 0; + for (y = 0; !M.isZero(); y++) + _ = M.andln(255), M.iushrn(8), P[m - y - 1] = _; + } + return P; + }, Math.clz32 ? s.prototype._countBits = function(E) { + return 32 - Math.clz32(E); + } : s.prototype._countBits = function(E) { + var b = E, l = 0; + return b >= 4096 && (l += 13, b >>>= 13), b >= 64 && (l += 7, b >>>= 7), b >= 8 && (l += 4, b >>>= 4), b >= 2 && (l += 2, b >>>= 2), l + b; + }, s.prototype._zeroBits = function(E) { + if (E === 0) return 26; + var b = E, l = 0; + return (b & 8191) === 0 && (l += 13, b >>>= 13), (b & 127) === 0 && (l += 7, b >>>= 7), (b & 15) === 0 && (l += 4, b >>>= 4), (b & 3) === 0 && (l += 2, b >>>= 2), (b & 1) === 0 && l++, l; + }, s.prototype.bitLength = function() { + var E = this.words[this.length - 1], b = this._countBits(E); + return (this.length - 1) * 26 + b; + }; + function x(K) { + for (var E = new Array(K.bitLength()), b = 0; b < E.length; b++) { + var l = b / 26 | 0, p = b % 26; + E[b] = (K.words[l] & 1 << p) >>> p; + } + return E; + } + s.prototype.zeroBits = function() { + if (this.isZero()) return 0; + for (var E = 0, b = 0; b < this.length; b++) { + var l = this._zeroBits(this.words[b]); + if (E += l, l !== 26) break; + } + return E; + }, s.prototype.byteLength = function() { + return Math.ceil(this.bitLength() / 8); + }, s.prototype.toTwos = function(E) { + return this.negative !== 0 ? this.abs().inotn(E).iaddn(1) : this.clone(); + }, s.prototype.fromTwos = function(E) { + return this.testn(E - 1) ? this.notn(E).iaddn(1).ineg() : this.clone(); + }, s.prototype.isNeg = function() { + return this.negative !== 0; + }, s.prototype.neg = function() { + return this.clone().ineg(); + }, s.prototype.ineg = function() { + return this.isZero() || (this.negative ^= 1), this; + }, s.prototype.iuor = function(E) { + for (; this.length < E.length; ) + this.words[this.length++] = 0; + for (var b = 0; b < E.length; b++) + this.words[b] = this.words[b] | E.words[b]; + return this.strip(); + }, s.prototype.ior = function(E) { + return n((this.negative | E.negative) === 0), this.iuor(E); + }, s.prototype.or = function(E) { + return this.length > E.length ? this.clone().ior(E) : E.clone().ior(this); + }, s.prototype.uor = function(E) { + return this.length > E.length ? this.clone().iuor(E) : E.clone().iuor(this); + }, s.prototype.iuand = function(E) { + var b; + this.length > E.length ? b = E : b = this; + for (var l = 0; l < b.length; l++) + this.words[l] = this.words[l] & E.words[l]; + return this.length = b.length, this.strip(); + }, s.prototype.iand = function(E) { + return n((this.negative | E.negative) === 0), this.iuand(E); + }, s.prototype.and = function(E) { + return this.length > E.length ? this.clone().iand(E) : E.clone().iand(this); + }, s.prototype.uand = function(E) { + return this.length > E.length ? this.clone().iuand(E) : E.clone().iuand(this); + }, s.prototype.iuxor = function(E) { + var b, l; + this.length > E.length ? (b = this, l = E) : (b = E, l = this); + for (var p = 0; p < l.length; p++) + this.words[p] = b.words[p] ^ l.words[p]; + if (this !== b) + for (; p < b.length; p++) + this.words[p] = b.words[p]; + return this.length = b.length, this.strip(); + }, s.prototype.ixor = function(E) { + return n((this.negative | E.negative) === 0), this.iuxor(E); + }, s.prototype.xor = function(E) { + return this.length > E.length ? this.clone().ixor(E) : E.clone().ixor(this); + }, s.prototype.uxor = function(E) { + return this.length > E.length ? this.clone().iuxor(E) : E.clone().iuxor(this); + }, s.prototype.inotn = function(E) { + n(typeof E == "number" && E >= 0); + var b = Math.ceil(E / 26) | 0, l = E % 26; + this._expand(b), l > 0 && b--; + for (var p = 0; p < b; p++) + this.words[p] = ~this.words[p] & 67108863; + return l > 0 && (this.words[p] = ~this.words[p] & 67108863 >> 26 - l), this.strip(); + }, s.prototype.notn = function(E) { + return this.clone().inotn(E); + }, s.prototype.setn = function(E, b) { + n(typeof E == "number" && E >= 0); + var l = E / 26 | 0, p = E % 26; + return this._expand(l + 1), b ? this.words[l] = this.words[l] | 1 << p : this.words[l] = this.words[l] & ~(1 << p), this.strip(); + }, s.prototype.iadd = function(E) { + var b; + if (this.negative !== 0 && E.negative === 0) + return this.negative = 0, b = this.isub(E), this.negative ^= 1, this._normSign(); + if (this.negative === 0 && E.negative !== 0) + return E.negative = 0, b = this.isub(E), E.negative = 1, b._normSign(); + var l, p; + this.length > E.length ? (l = this, p = E) : (l = E, p = this); + for (var m = 0, w = 0; w < p.length; w++) + b = (l.words[w] | 0) + (p.words[w] | 0) + m, this.words[w] = b & 67108863, m = b >>> 26; + for (; m !== 0 && w < l.length; w++) + b = (l.words[w] | 0) + m, this.words[w] = b & 67108863, m = b >>> 26; + if (this.length = l.length, m !== 0) + this.words[this.length] = m, this.length++; + else if (l !== this) + for (; w < l.length; w++) + this.words[w] = l.words[w]; + return this; + }, s.prototype.add = function(E) { + var b; + return E.negative !== 0 && this.negative === 0 ? (E.negative = 0, b = this.sub(E), E.negative ^= 1, b) : E.negative === 0 && this.negative !== 0 ? (this.negative = 0, b = E.sub(this), this.negative = 1, b) : this.length > E.length ? this.clone().iadd(E) : E.clone().iadd(this); + }, s.prototype.isub = function(E) { + if (E.negative !== 0) { + E.negative = 0; + var b = this.iadd(E); + return E.negative = 1, b._normSign(); + } else if (this.negative !== 0) + return this.negative = 0, this.iadd(E), this.negative = 1, this._normSign(); + var l = this.cmp(E); + if (l === 0) + return this.negative = 0, this.length = 1, this.words[0] = 0, this; + var p, m; + l > 0 ? (p = this, m = E) : (p = E, m = this); + for (var w = 0, P = 0; P < m.length; P++) + b = (p.words[P] | 0) - (m.words[P] | 0) + w, w = b >> 26, this.words[P] = b & 67108863; + for (; w !== 0 && P < p.length; P++) + b = (p.words[P] | 0) + w, w = b >> 26, this.words[P] = b & 67108863; + if (w === 0 && P < p.length && p !== this) + for (; P < p.length; P++) + this.words[P] = p.words[P]; + return this.length = Math.max(this.length, P), p !== this && (this.negative = 1), this.strip(); + }, s.prototype.sub = function(E) { + return this.clone().isub(E); + }; + function S(K, E, b) { + b.negative = E.negative ^ K.negative; + var l = K.length + E.length | 0; + b.length = l, l = l - 1 | 0; + var p = K.words[0] | 0, m = E.words[0] | 0, w = p * m, P = w & 67108863, _ = w / 67108864 | 0; + b.words[0] = P; + for (var y = 1; y < l; y++) { + for (var M = _ >>> 26, I = _ & 67108863, q = Math.min(y, E.length - 1), ce = Math.max(0, y - K.length + 1); ce <= q; ce++) { + var L = y - ce | 0; + p = K.words[L] | 0, m = E.words[ce] | 0, w = p * m + I, M += w / 67108864 | 0, I = w & 67108863; + } + b.words[y] = I | 0, _ = M | 0; + } + return _ !== 0 ? b.words[y] = _ | 0 : b.length--, b.strip(); + } + var R = function(E, b, l) { + var p = E.words, m = b.words, w = l.words, P = 0, _, y, M, I = p[0] | 0, q = I & 8191, ce = I >>> 13, L = p[1] | 0, oe = L & 8191, Q = L >>> 13, X = p[2] | 0, ee = X & 8191, O = X >>> 13, Z = p[3] | 0, re = Z & 8191, he = Z >>> 13, ae = p[4] | 0, fe = ae & 8191, be = ae >>> 13, Ae = p[5] | 0, Te = Ae & 8191, Re = Ae >>> 13, $e = p[6] | 0, Me = $e & 8191, Oe = $e >>> 13, ze = p[7] | 0, De = ze & 8191, je = ze >>> 13, Ue = p[8] | 0, _e = Ue & 8191, Ze = Ue >>> 13, ot = p[9] | 0, ke = ot & 8191, rt = ot >>> 13, nt = m[0] | 0, Ge = nt & 8191, ht = nt >>> 13, lt = m[1] | 0, ct = lt & 8191, qt = lt >>> 13, Gt = m[2] | 0, Et = Gt & 8191, Yt = Gt >>> 13, tr = m[3] | 0, Tt = tr & 8191, kt = tr >>> 13, It = m[4] | 0, dt = It & 8191, Dt = It >>> 13, Nt = m[5] | 0, mt = Nt & 8191, Bt = Nt >>> 13, Ft = m[6] | 0, et = Ft & 8191, $t = Ft >>> 13, H = m[7] | 0, V = H & 8191, Y = H >>> 13, T = m[8] | 0, F = T & 8191, ie = T >>> 13, le = m[9] | 0, me = le & 8191, Ee = le >>> 13; + l.negative = E.negative ^ b.negative, l.length = 19, _ = Math.imul(q, Ge), y = Math.imul(q, ht), y = y + Math.imul(ce, Ge) | 0, M = Math.imul(ce, ht); + var Le = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (Le >>> 26) | 0, Le &= 67108863, _ = Math.imul(oe, Ge), y = Math.imul(oe, ht), y = y + Math.imul(Q, Ge) | 0, M = Math.imul(Q, ht), _ = _ + Math.imul(q, ct) | 0, y = y + Math.imul(q, qt) | 0, y = y + Math.imul(ce, ct) | 0, M = M + Math.imul(ce, qt) | 0; + var Ie = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (Ie >>> 26) | 0, Ie &= 67108863, _ = Math.imul(ee, Ge), y = Math.imul(ee, ht), y = y + Math.imul(O, Ge) | 0, M = Math.imul(O, ht), _ = _ + Math.imul(oe, ct) | 0, y = y + Math.imul(oe, qt) | 0, y = y + Math.imul(Q, ct) | 0, M = M + Math.imul(Q, qt) | 0, _ = _ + Math.imul(q, Et) | 0, y = y + Math.imul(q, Yt) | 0, y = y + Math.imul(ce, Et) | 0, M = M + Math.imul(ce, Yt) | 0; + var Qe = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (Qe >>> 26) | 0, Qe &= 67108863, _ = Math.imul(re, Ge), y = Math.imul(re, ht), y = y + Math.imul(he, Ge) | 0, M = Math.imul(he, ht), _ = _ + Math.imul(ee, ct) | 0, y = y + Math.imul(ee, qt) | 0, y = y + Math.imul(O, ct) | 0, M = M + Math.imul(O, qt) | 0, _ = _ + Math.imul(oe, Et) | 0, y = y + Math.imul(oe, Yt) | 0, y = y + Math.imul(Q, Et) | 0, M = M + Math.imul(Q, Yt) | 0, _ = _ + Math.imul(q, Tt) | 0, y = y + Math.imul(q, kt) | 0, y = y + Math.imul(ce, Tt) | 0, M = M + Math.imul(ce, kt) | 0; + var Xe = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (Xe >>> 26) | 0, Xe &= 67108863, _ = Math.imul(fe, Ge), y = Math.imul(fe, ht), y = y + Math.imul(be, Ge) | 0, M = Math.imul(be, ht), _ = _ + Math.imul(re, ct) | 0, y = y + Math.imul(re, qt) | 0, y = y + Math.imul(he, ct) | 0, M = M + Math.imul(he, qt) | 0, _ = _ + Math.imul(ee, Et) | 0, y = y + Math.imul(ee, Yt) | 0, y = y + Math.imul(O, Et) | 0, M = M + Math.imul(O, Yt) | 0, _ = _ + Math.imul(oe, Tt) | 0, y = y + Math.imul(oe, kt) | 0, y = y + Math.imul(Q, Tt) | 0, M = M + Math.imul(Q, kt) | 0, _ = _ + Math.imul(q, dt) | 0, y = y + Math.imul(q, Dt) | 0, y = y + Math.imul(ce, dt) | 0, M = M + Math.imul(ce, Dt) | 0; + var tt = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (tt >>> 26) | 0, tt &= 67108863, _ = Math.imul(Te, Ge), y = Math.imul(Te, ht), y = y + Math.imul(Re, Ge) | 0, M = Math.imul(Re, ht), _ = _ + Math.imul(fe, ct) | 0, y = y + Math.imul(fe, qt) | 0, y = y + Math.imul(be, ct) | 0, M = M + Math.imul(be, qt) | 0, _ = _ + Math.imul(re, Et) | 0, y = y + Math.imul(re, Yt) | 0, y = y + Math.imul(he, Et) | 0, M = M + Math.imul(he, Yt) | 0, _ = _ + Math.imul(ee, Tt) | 0, y = y + Math.imul(ee, kt) | 0, y = y + Math.imul(O, Tt) | 0, M = M + Math.imul(O, kt) | 0, _ = _ + Math.imul(oe, dt) | 0, y = y + Math.imul(oe, Dt) | 0, y = y + Math.imul(Q, dt) | 0, M = M + Math.imul(Q, Dt) | 0, _ = _ + Math.imul(q, mt) | 0, y = y + Math.imul(q, Bt) | 0, y = y + Math.imul(ce, mt) | 0, M = M + Math.imul(ce, Bt) | 0; + var st = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (st >>> 26) | 0, st &= 67108863, _ = Math.imul(Me, Ge), y = Math.imul(Me, ht), y = y + Math.imul(Oe, Ge) | 0, M = Math.imul(Oe, ht), _ = _ + Math.imul(Te, ct) | 0, y = y + Math.imul(Te, qt) | 0, y = y + Math.imul(Re, ct) | 0, M = M + Math.imul(Re, qt) | 0, _ = _ + Math.imul(fe, Et) | 0, y = y + Math.imul(fe, Yt) | 0, y = y + Math.imul(be, Et) | 0, M = M + Math.imul(be, Yt) | 0, _ = _ + Math.imul(re, Tt) | 0, y = y + Math.imul(re, kt) | 0, y = y + Math.imul(he, Tt) | 0, M = M + Math.imul(he, kt) | 0, _ = _ + Math.imul(ee, dt) | 0, y = y + Math.imul(ee, Dt) | 0, y = y + Math.imul(O, dt) | 0, M = M + Math.imul(O, Dt) | 0, _ = _ + Math.imul(oe, mt) | 0, y = y + Math.imul(oe, Bt) | 0, y = y + Math.imul(Q, mt) | 0, M = M + Math.imul(Q, Bt) | 0, _ = _ + Math.imul(q, et) | 0, y = y + Math.imul(q, $t) | 0, y = y + Math.imul(ce, et) | 0, M = M + Math.imul(ce, $t) | 0; + var vt = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (vt >>> 26) | 0, vt &= 67108863, _ = Math.imul(De, Ge), y = Math.imul(De, ht), y = y + Math.imul(je, Ge) | 0, M = Math.imul(je, ht), _ = _ + Math.imul(Me, ct) | 0, y = y + Math.imul(Me, qt) | 0, y = y + Math.imul(Oe, ct) | 0, M = M + Math.imul(Oe, qt) | 0, _ = _ + Math.imul(Te, Et) | 0, y = y + Math.imul(Te, Yt) | 0, y = y + Math.imul(Re, Et) | 0, M = M + Math.imul(Re, Yt) | 0, _ = _ + Math.imul(fe, Tt) | 0, y = y + Math.imul(fe, kt) | 0, y = y + Math.imul(be, Tt) | 0, M = M + Math.imul(be, kt) | 0, _ = _ + Math.imul(re, dt) | 0, y = y + Math.imul(re, Dt) | 0, y = y + Math.imul(he, dt) | 0, M = M + Math.imul(he, Dt) | 0, _ = _ + Math.imul(ee, mt) | 0, y = y + Math.imul(ee, Bt) | 0, y = y + Math.imul(O, mt) | 0, M = M + Math.imul(O, Bt) | 0, _ = _ + Math.imul(oe, et) | 0, y = y + Math.imul(oe, $t) | 0, y = y + Math.imul(Q, et) | 0, M = M + Math.imul(Q, $t) | 0, _ = _ + Math.imul(q, V) | 0, y = y + Math.imul(q, Y) | 0, y = y + Math.imul(ce, V) | 0, M = M + Math.imul(ce, Y) | 0; + var Ct = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (Ct >>> 26) | 0, Ct &= 67108863, _ = Math.imul(_e, Ge), y = Math.imul(_e, ht), y = y + Math.imul(Ze, Ge) | 0, M = Math.imul(Ze, ht), _ = _ + Math.imul(De, ct) | 0, y = y + Math.imul(De, qt) | 0, y = y + Math.imul(je, ct) | 0, M = M + Math.imul(je, qt) | 0, _ = _ + Math.imul(Me, Et) | 0, y = y + Math.imul(Me, Yt) | 0, y = y + Math.imul(Oe, Et) | 0, M = M + Math.imul(Oe, Yt) | 0, _ = _ + Math.imul(Te, Tt) | 0, y = y + Math.imul(Te, kt) | 0, y = y + Math.imul(Re, Tt) | 0, M = M + Math.imul(Re, kt) | 0, _ = _ + Math.imul(fe, dt) | 0, y = y + Math.imul(fe, Dt) | 0, y = y + Math.imul(be, dt) | 0, M = M + Math.imul(be, Dt) | 0, _ = _ + Math.imul(re, mt) | 0, y = y + Math.imul(re, Bt) | 0, y = y + Math.imul(he, mt) | 0, M = M + Math.imul(he, Bt) | 0, _ = _ + Math.imul(ee, et) | 0, y = y + Math.imul(ee, $t) | 0, y = y + Math.imul(O, et) | 0, M = M + Math.imul(O, $t) | 0, _ = _ + Math.imul(oe, V) | 0, y = y + Math.imul(oe, Y) | 0, y = y + Math.imul(Q, V) | 0, M = M + Math.imul(Q, Y) | 0, _ = _ + Math.imul(q, F) | 0, y = y + Math.imul(q, ie) | 0, y = y + Math.imul(ce, F) | 0, M = M + Math.imul(ce, ie) | 0; + var Mt = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (Mt >>> 26) | 0, Mt &= 67108863, _ = Math.imul(ke, Ge), y = Math.imul(ke, ht), y = y + Math.imul(rt, Ge) | 0, M = Math.imul(rt, ht), _ = _ + Math.imul(_e, ct) | 0, y = y + Math.imul(_e, qt) | 0, y = y + Math.imul(Ze, ct) | 0, M = M + Math.imul(Ze, qt) | 0, _ = _ + Math.imul(De, Et) | 0, y = y + Math.imul(De, Yt) | 0, y = y + Math.imul(je, Et) | 0, M = M + Math.imul(je, Yt) | 0, _ = _ + Math.imul(Me, Tt) | 0, y = y + Math.imul(Me, kt) | 0, y = y + Math.imul(Oe, Tt) | 0, M = M + Math.imul(Oe, kt) | 0, _ = _ + Math.imul(Te, dt) | 0, y = y + Math.imul(Te, Dt) | 0, y = y + Math.imul(Re, dt) | 0, M = M + Math.imul(Re, Dt) | 0, _ = _ + Math.imul(fe, mt) | 0, y = y + Math.imul(fe, Bt) | 0, y = y + Math.imul(be, mt) | 0, M = M + Math.imul(be, Bt) | 0, _ = _ + Math.imul(re, et) | 0, y = y + Math.imul(re, $t) | 0, y = y + Math.imul(he, et) | 0, M = M + Math.imul(he, $t) | 0, _ = _ + Math.imul(ee, V) | 0, y = y + Math.imul(ee, Y) | 0, y = y + Math.imul(O, V) | 0, M = M + Math.imul(O, Y) | 0, _ = _ + Math.imul(oe, F) | 0, y = y + Math.imul(oe, ie) | 0, y = y + Math.imul(Q, F) | 0, M = M + Math.imul(Q, ie) | 0, _ = _ + Math.imul(q, me) | 0, y = y + Math.imul(q, Ee) | 0, y = y + Math.imul(ce, me) | 0, M = M + Math.imul(ce, Ee) | 0; + var wt = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (wt >>> 26) | 0, wt &= 67108863, _ = Math.imul(ke, ct), y = Math.imul(ke, qt), y = y + Math.imul(rt, ct) | 0, M = Math.imul(rt, qt), _ = _ + Math.imul(_e, Et) | 0, y = y + Math.imul(_e, Yt) | 0, y = y + Math.imul(Ze, Et) | 0, M = M + Math.imul(Ze, Yt) | 0, _ = _ + Math.imul(De, Tt) | 0, y = y + Math.imul(De, kt) | 0, y = y + Math.imul(je, Tt) | 0, M = M + Math.imul(je, kt) | 0, _ = _ + Math.imul(Me, dt) | 0, y = y + Math.imul(Me, Dt) | 0, y = y + Math.imul(Oe, dt) | 0, M = M + Math.imul(Oe, Dt) | 0, _ = _ + Math.imul(Te, mt) | 0, y = y + Math.imul(Te, Bt) | 0, y = y + Math.imul(Re, mt) | 0, M = M + Math.imul(Re, Bt) | 0, _ = _ + Math.imul(fe, et) | 0, y = y + Math.imul(fe, $t) | 0, y = y + Math.imul(be, et) | 0, M = M + Math.imul(be, $t) | 0, _ = _ + Math.imul(re, V) | 0, y = y + Math.imul(re, Y) | 0, y = y + Math.imul(he, V) | 0, M = M + Math.imul(he, Y) | 0, _ = _ + Math.imul(ee, F) | 0, y = y + Math.imul(ee, ie) | 0, y = y + Math.imul(O, F) | 0, M = M + Math.imul(O, ie) | 0, _ = _ + Math.imul(oe, me) | 0, y = y + Math.imul(oe, Ee) | 0, y = y + Math.imul(Q, me) | 0, M = M + Math.imul(Q, Ee) | 0; + var Rt = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (Rt >>> 26) | 0, Rt &= 67108863, _ = Math.imul(ke, Et), y = Math.imul(ke, Yt), y = y + Math.imul(rt, Et) | 0, M = Math.imul(rt, Yt), _ = _ + Math.imul(_e, Tt) | 0, y = y + Math.imul(_e, kt) | 0, y = y + Math.imul(Ze, Tt) | 0, M = M + Math.imul(Ze, kt) | 0, _ = _ + Math.imul(De, dt) | 0, y = y + Math.imul(De, Dt) | 0, y = y + Math.imul(je, dt) | 0, M = M + Math.imul(je, Dt) | 0, _ = _ + Math.imul(Me, mt) | 0, y = y + Math.imul(Me, Bt) | 0, y = y + Math.imul(Oe, mt) | 0, M = M + Math.imul(Oe, Bt) | 0, _ = _ + Math.imul(Te, et) | 0, y = y + Math.imul(Te, $t) | 0, y = y + Math.imul(Re, et) | 0, M = M + Math.imul(Re, $t) | 0, _ = _ + Math.imul(fe, V) | 0, y = y + Math.imul(fe, Y) | 0, y = y + Math.imul(be, V) | 0, M = M + Math.imul(be, Y) | 0, _ = _ + Math.imul(re, F) | 0, y = y + Math.imul(re, ie) | 0, y = y + Math.imul(he, F) | 0, M = M + Math.imul(he, ie) | 0, _ = _ + Math.imul(ee, me) | 0, y = y + Math.imul(ee, Ee) | 0, y = y + Math.imul(O, me) | 0, M = M + Math.imul(O, Ee) | 0; + var gt = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (gt >>> 26) | 0, gt &= 67108863, _ = Math.imul(ke, Tt), y = Math.imul(ke, kt), y = y + Math.imul(rt, Tt) | 0, M = Math.imul(rt, kt), _ = _ + Math.imul(_e, dt) | 0, y = y + Math.imul(_e, Dt) | 0, y = y + Math.imul(Ze, dt) | 0, M = M + Math.imul(Ze, Dt) | 0, _ = _ + Math.imul(De, mt) | 0, y = y + Math.imul(De, Bt) | 0, y = y + Math.imul(je, mt) | 0, M = M + Math.imul(je, Bt) | 0, _ = _ + Math.imul(Me, et) | 0, y = y + Math.imul(Me, $t) | 0, y = y + Math.imul(Oe, et) | 0, M = M + Math.imul(Oe, $t) | 0, _ = _ + Math.imul(Te, V) | 0, y = y + Math.imul(Te, Y) | 0, y = y + Math.imul(Re, V) | 0, M = M + Math.imul(Re, Y) | 0, _ = _ + Math.imul(fe, F) | 0, y = y + Math.imul(fe, ie) | 0, y = y + Math.imul(be, F) | 0, M = M + Math.imul(be, ie) | 0, _ = _ + Math.imul(re, me) | 0, y = y + Math.imul(re, Ee) | 0, y = y + Math.imul(he, me) | 0, M = M + Math.imul(he, Ee) | 0; + var _t = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (_t >>> 26) | 0, _t &= 67108863, _ = Math.imul(ke, dt), y = Math.imul(ke, Dt), y = y + Math.imul(rt, dt) | 0, M = Math.imul(rt, Dt), _ = _ + Math.imul(_e, mt) | 0, y = y + Math.imul(_e, Bt) | 0, y = y + Math.imul(Ze, mt) | 0, M = M + Math.imul(Ze, Bt) | 0, _ = _ + Math.imul(De, et) | 0, y = y + Math.imul(De, $t) | 0, y = y + Math.imul(je, et) | 0, M = M + Math.imul(je, $t) | 0, _ = _ + Math.imul(Me, V) | 0, y = y + Math.imul(Me, Y) | 0, y = y + Math.imul(Oe, V) | 0, M = M + Math.imul(Oe, Y) | 0, _ = _ + Math.imul(Te, F) | 0, y = y + Math.imul(Te, ie) | 0, y = y + Math.imul(Re, F) | 0, M = M + Math.imul(Re, ie) | 0, _ = _ + Math.imul(fe, me) | 0, y = y + Math.imul(fe, Ee) | 0, y = y + Math.imul(be, me) | 0, M = M + Math.imul(be, Ee) | 0; + var at = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (at >>> 26) | 0, at &= 67108863, _ = Math.imul(ke, mt), y = Math.imul(ke, Bt), y = y + Math.imul(rt, mt) | 0, M = Math.imul(rt, Bt), _ = _ + Math.imul(_e, et) | 0, y = y + Math.imul(_e, $t) | 0, y = y + Math.imul(Ze, et) | 0, M = M + Math.imul(Ze, $t) | 0, _ = _ + Math.imul(De, V) | 0, y = y + Math.imul(De, Y) | 0, y = y + Math.imul(je, V) | 0, M = M + Math.imul(je, Y) | 0, _ = _ + Math.imul(Me, F) | 0, y = y + Math.imul(Me, ie) | 0, y = y + Math.imul(Oe, F) | 0, M = M + Math.imul(Oe, ie) | 0, _ = _ + Math.imul(Te, me) | 0, y = y + Math.imul(Te, Ee) | 0, y = y + Math.imul(Re, me) | 0, M = M + Math.imul(Re, Ee) | 0; + var yt = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (yt >>> 26) | 0, yt &= 67108863, _ = Math.imul(ke, et), y = Math.imul(ke, $t), y = y + Math.imul(rt, et) | 0, M = Math.imul(rt, $t), _ = _ + Math.imul(_e, V) | 0, y = y + Math.imul(_e, Y) | 0, y = y + Math.imul(Ze, V) | 0, M = M + Math.imul(Ze, Y) | 0, _ = _ + Math.imul(De, F) | 0, y = y + Math.imul(De, ie) | 0, y = y + Math.imul(je, F) | 0, M = M + Math.imul(je, ie) | 0, _ = _ + Math.imul(Me, me) | 0, y = y + Math.imul(Me, Ee) | 0, y = y + Math.imul(Oe, me) | 0, M = M + Math.imul(Oe, Ee) | 0; + var ut = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (ut >>> 26) | 0, ut &= 67108863, _ = Math.imul(ke, V), y = Math.imul(ke, Y), y = y + Math.imul(rt, V) | 0, M = Math.imul(rt, Y), _ = _ + Math.imul(_e, F) | 0, y = y + Math.imul(_e, ie) | 0, y = y + Math.imul(Ze, F) | 0, M = M + Math.imul(Ze, ie) | 0, _ = _ + Math.imul(De, me) | 0, y = y + Math.imul(De, Ee) | 0, y = y + Math.imul(je, me) | 0, M = M + Math.imul(je, Ee) | 0; + var it = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (it >>> 26) | 0, it &= 67108863, _ = Math.imul(ke, F), y = Math.imul(ke, ie), y = y + Math.imul(rt, F) | 0, M = Math.imul(rt, ie), _ = _ + Math.imul(_e, me) | 0, y = y + Math.imul(_e, Ee) | 0, y = y + Math.imul(Ze, me) | 0, M = M + Math.imul(Ze, Ee) | 0; + var Se = (P + _ | 0) + ((y & 8191) << 13) | 0; + P = (M + (y >>> 13) | 0) + (Se >>> 26) | 0, Se &= 67108863, _ = Math.imul(ke, me), y = Math.imul(ke, Ee), y = y + Math.imul(rt, me) | 0, M = Math.imul(rt, Ee); + var Pe = (P + _ | 0) + ((y & 8191) << 13) | 0; + return P = (M + (y >>> 13) | 0) + (Pe >>> 26) | 0, Pe &= 67108863, w[0] = Le, w[1] = Ie, w[2] = Qe, w[3] = Xe, w[4] = tt, w[5] = st, w[6] = vt, w[7] = Ct, w[8] = Mt, w[9] = wt, w[10] = Rt, w[11] = gt, w[12] = _t, w[13] = at, w[14] = yt, w[15] = ut, w[16] = it, w[17] = Se, w[18] = Pe, P !== 0 && (w[19] = P, l.length++), l; + }; + Math.imul || (R = S); + function D(K, E, b) { + b.negative = E.negative ^ K.negative, b.length = K.length + E.length; + for (var l = 0, p = 0, m = 0; m < b.length - 1; m++) { + var w = p; + p = 0; + for (var P = l & 67108863, _ = Math.min(m, E.length - 1), y = Math.max(0, m - K.length + 1); y <= _; y++) { + var M = m - y, I = K.words[M] | 0, q = E.words[y] | 0, ce = I * q, L = ce & 67108863; + w = w + (ce / 67108864 | 0) | 0, L = L + P | 0, P = L & 67108863, w = w + (L >>> 26) | 0, p += w >>> 26, w &= 67108863; + } + b.words[m] = P, l = w, w = p; + } + return l !== 0 ? b.words[m] = l : b.length--, b.strip(); + } + function k(K, E, b) { + var l = new N(); + return l.mulp(K, E, b); + } + s.prototype.mulTo = function(E, b) { + var l, p = this.length + E.length; + return this.length === 10 && E.length === 10 ? l = R(this, E, b) : p < 63 ? l = S(this, E, b) : p < 1024 ? l = D(this, E, b) : l = k(this, E, b), l; + }; + function N(K, E) { + this.x = K, this.y = E; + } + N.prototype.makeRBT = function(E) { + for (var b = new Array(E), l = s.prototype._countBits(E) - 1, p = 0; p < E; p++) + b[p] = this.revBin(p, l, E); + return b; + }, N.prototype.revBin = function(E, b, l) { + if (E === 0 || E === l - 1) return E; + for (var p = 0, m = 0; m < b; m++) + p |= (E & 1) << b - m - 1, E >>= 1; + return p; + }, N.prototype.permute = function(E, b, l, p, m, w) { + for (var P = 0; P < w; P++) + p[P] = b[E[P]], m[P] = l[E[P]]; + }, N.prototype.transform = function(E, b, l, p, m, w) { + this.permute(w, E, b, l, p, m); + for (var P = 1; P < m; P <<= 1) + for (var _ = P << 1, y = Math.cos(2 * Math.PI / _), M = Math.sin(2 * Math.PI / _), I = 0; I < m; I += _) + for (var q = y, ce = M, L = 0; L < P; L++) { + var oe = l[I + L], Q = p[I + L], X = l[I + L + P], ee = p[I + L + P], O = q * X - ce * ee; + ee = q * ee + ce * X, X = O, l[I + L] = oe + X, p[I + L] = Q + ee, l[I + L + P] = oe - X, p[I + L + P] = Q - ee, L !== _ && (O = y * q - M * ce, ce = y * ce + M * q, q = O); + } + }, N.prototype.guessLen13b = function(E, b) { + var l = Math.max(b, E) | 1, p = l & 1, m = 0; + for (l = l / 2 | 0; l; l = l >>> 1) + m++; + return 1 << m + 1 + p; + }, N.prototype.conjugate = function(E, b, l) { + if (!(l <= 1)) + for (var p = 0; p < l / 2; p++) { + var m = E[p]; + E[p] = E[l - p - 1], E[l - p - 1] = m, m = b[p], b[p] = -b[l - p - 1], b[l - p - 1] = -m; + } + }, N.prototype.normalize13b = function(E, b) { + for (var l = 0, p = 0; p < b / 2; p++) { + var m = Math.round(E[2 * p + 1] / b) * 8192 + Math.round(E[2 * p] / b) + l; + E[p] = m & 67108863, m < 67108864 ? l = 0 : l = m / 67108864 | 0; + } + return E; + }, N.prototype.convert13b = function(E, b, l, p) { + for (var m = 0, w = 0; w < b; w++) + m = m + (E[w] | 0), l[2 * w] = m & 8191, m = m >>> 13, l[2 * w + 1] = m & 8191, m = m >>> 13; + for (w = 2 * b; w < p; ++w) + l[w] = 0; + n(m === 0), n((m & -8192) === 0); + }, N.prototype.stub = function(E) { + for (var b = new Array(E), l = 0; l < E; l++) + b[l] = 0; + return b; + }, N.prototype.mulp = function(E, b, l) { + var p = 2 * this.guessLen13b(E.length, b.length), m = this.makeRBT(p), w = this.stub(p), P = new Array(p), _ = new Array(p), y = new Array(p), M = new Array(p), I = new Array(p), q = new Array(p), ce = l.words; + ce.length = p, this.convert13b(E.words, E.length, P, p), this.convert13b(b.words, b.length, M, p), this.transform(P, w, _, y, p, m), this.transform(M, w, I, q, p, m); + for (var L = 0; L < p; L++) { + var oe = _[L] * I[L] - y[L] * q[L]; + y[L] = _[L] * q[L] + y[L] * I[L], _[L] = oe; + } + return this.conjugate(_, y, p), this.transform(_, y, ce, w, p, m), this.conjugate(ce, w, p), this.normalize13b(ce, p), l.negative = E.negative ^ b.negative, l.length = E.length + b.length, l.strip(); + }, s.prototype.mul = function(E) { + var b = new s(null); + return b.words = new Array(this.length + E.length), this.mulTo(E, b); + }, s.prototype.mulf = function(E) { + var b = new s(null); + return b.words = new Array(this.length + E.length), k(this, E, b); + }, s.prototype.imul = function(E) { + return this.clone().mulTo(E, this); + }, s.prototype.imuln = function(E) { + n(typeof E == "number"), n(E < 67108864); + for (var b = 0, l = 0; l < this.length; l++) { + var p = (this.words[l] | 0) * E, m = (p & 67108863) + (b & 67108863); + b >>= 26, b += p / 67108864 | 0, b += m >>> 26, this.words[l] = m & 67108863; + } + return b !== 0 && (this.words[l] = b, this.length++), this; + }, s.prototype.muln = function(E) { + return this.clone().imuln(E); + }, s.prototype.sqr = function() { + return this.mul(this); + }, s.prototype.isqr = function() { + return this.imul(this.clone()); + }, s.prototype.pow = function(E) { + var b = x(E); + if (b.length === 0) return new s(1); + for (var l = this, p = 0; p < b.length && b[p] === 0; p++, l = l.sqr()) + ; + if (++p < b.length) + for (var m = l.sqr(); p < b.length; p++, m = m.sqr()) + b[p] !== 0 && (l = l.mul(m)); + return l; + }, s.prototype.iushln = function(E) { + n(typeof E == "number" && E >= 0); + var b = E % 26, l = (E - b) / 26, p = 67108863 >>> 26 - b << 26 - b, m; + if (b !== 0) { + var w = 0; + for (m = 0; m < this.length; m++) { + var P = this.words[m] & p, _ = (this.words[m] | 0) - P << b; + this.words[m] = _ | w, w = P >>> 26 - b; + } + w && (this.words[m] = w, this.length++); + } + if (l !== 0) { + for (m = this.length - 1; m >= 0; m--) + this.words[m + l] = this.words[m]; + for (m = 0; m < l; m++) + this.words[m] = 0; + this.length += l; + } + return this.strip(); + }, s.prototype.ishln = function(E) { + return n(this.negative === 0), this.iushln(E); + }, s.prototype.iushrn = function(E, b, l) { + n(typeof E == "number" && E >= 0); + var p; + b ? p = (b - b % 26) / 26 : p = 0; + var m = E % 26, w = Math.min((E - m) / 26, this.length), P = 67108863 ^ 67108863 >>> m << m, _ = l; + if (p -= w, p = Math.max(0, p), _) { + for (var y = 0; y < w; y++) + _.words[y] = this.words[y]; + _.length = w; + } + if (w !== 0) if (this.length > w) + for (this.length -= w, y = 0; y < this.length; y++) + this.words[y] = this.words[y + w]; + else + this.words[0] = 0, this.length = 1; + var M = 0; + for (y = this.length - 1; y >= 0 && (M !== 0 || y >= p); y--) { + var I = this.words[y] | 0; + this.words[y] = M << 26 - m | I >>> m, M = I & P; + } + return _ && M !== 0 && (_.words[_.length++] = M), this.length === 0 && (this.words[0] = 0, this.length = 1), this.strip(); + }, s.prototype.ishrn = function(E, b, l) { + return n(this.negative === 0), this.iushrn(E, b, l); + }, s.prototype.shln = function(E) { + return this.clone().ishln(E); + }, s.prototype.ushln = function(E) { + return this.clone().iushln(E); + }, s.prototype.shrn = function(E) { + return this.clone().ishrn(E); + }, s.prototype.ushrn = function(E) { + return this.clone().iushrn(E); + }, s.prototype.testn = function(E) { + n(typeof E == "number" && E >= 0); + var b = E % 26, l = (E - b) / 26, p = 1 << b; + if (this.length <= l) return !1; + var m = this.words[l]; + return !!(m & p); + }, s.prototype.imaskn = function(E) { + n(typeof E == "number" && E >= 0); + var b = E % 26, l = (E - b) / 26; + if (n(this.negative === 0, "imaskn works only with positive numbers"), this.length <= l) + return this; + if (b !== 0 && l++, this.length = Math.min(l, this.length), b !== 0) { + var p = 67108863 ^ 67108863 >>> b << b; + this.words[this.length - 1] &= p; + } + return this.strip(); + }, s.prototype.maskn = function(E) { + return this.clone().imaskn(E); + }, s.prototype.iaddn = function(E) { + return n(typeof E == "number"), n(E < 67108864), E < 0 ? this.isubn(-E) : this.negative !== 0 ? this.length === 1 && (this.words[0] | 0) < E ? (this.words[0] = E - (this.words[0] | 0), this.negative = 0, this) : (this.negative = 0, this.isubn(E), this.negative = 1, this) : this._iaddn(E); + }, s.prototype._iaddn = function(E) { + this.words[0] += E; + for (var b = 0; b < this.length && this.words[b] >= 67108864; b++) + this.words[b] -= 67108864, b === this.length - 1 ? this.words[b + 1] = 1 : this.words[b + 1]++; + return this.length = Math.max(this.length, b + 1), this; + }, s.prototype.isubn = function(E) { + if (n(typeof E == "number"), n(E < 67108864), E < 0) return this.iaddn(-E); + if (this.negative !== 0) + return this.negative = 0, this.iaddn(E), this.negative = 1, this; + if (this.words[0] -= E, this.length === 1 && this.words[0] < 0) + this.words[0] = -this.words[0], this.negative = 1; + else + for (var b = 0; b < this.length && this.words[b] < 0; b++) + this.words[b] += 67108864, this.words[b + 1] -= 1; + return this.strip(); + }, s.prototype.addn = function(E) { + return this.clone().iaddn(E); + }, s.prototype.subn = function(E) { + return this.clone().isubn(E); + }, s.prototype.iabs = function() { + return this.negative = 0, this; + }, s.prototype.abs = function() { + return this.clone().iabs(); + }, s.prototype._ishlnsubmul = function(E, b, l) { + var p = E.length + l, m; + this._expand(p); + var w, P = 0; + for (m = 0; m < E.length; m++) { + w = (this.words[m + l] | 0) + P; + var _ = (E.words[m] | 0) * b; + w -= _ & 67108863, P = (w >> 26) - (_ / 67108864 | 0), this.words[m + l] = w & 67108863; + } + for (; m < this.length - l; m++) + w = (this.words[m + l] | 0) + P, P = w >> 26, this.words[m + l] = w & 67108863; + if (P === 0) return this.strip(); + for (n(P === -1), P = 0, m = 0; m < this.length; m++) + w = -(this.words[m] | 0) + P, P = w >> 26, this.words[m] = w & 67108863; + return this.negative = 1, this.strip(); + }, s.prototype._wordDiv = function(E, b) { + var l = this.length - E.length, p = this.clone(), m = E, w = m.words[m.length - 1] | 0, P = this._countBits(w); + l = 26 - P, l !== 0 && (m = m.ushln(l), p.iushln(l), w = m.words[m.length - 1] | 0); + var _ = p.length - m.length, y; + if (b !== "mod") { + y = new s(null), y.length = _ + 1, y.words = new Array(y.length); + for (var M = 0; M < y.length; M++) + y.words[M] = 0; + } + var I = p.clone()._ishlnsubmul(m, 1, _); + I.negative === 0 && (p = I, y && (y.words[_] = 1)); + for (var q = _ - 1; q >= 0; q--) { + var ce = (p.words[m.length + q] | 0) * 67108864 + (p.words[m.length + q - 1] | 0); + for (ce = Math.min(ce / w | 0, 67108863), p._ishlnsubmul(m, ce, q); p.negative !== 0; ) + ce--, p.negative = 0, p._ishlnsubmul(m, 1, q), p.isZero() || (p.negative ^= 1); + y && (y.words[q] = ce); + } + return y && y.strip(), p.strip(), b !== "div" && l !== 0 && p.iushrn(l), { + div: y || null, + mod: p + }; + }, s.prototype.divmod = function(E, b, l) { + if (n(!E.isZero()), this.isZero()) + return { + div: new s(0), + mod: new s(0) + }; + var p, m, w; + return this.negative !== 0 && E.negative === 0 ? (w = this.neg().divmod(E, b), b !== "mod" && (p = w.div.neg()), b !== "div" && (m = w.mod.neg(), l && m.negative !== 0 && m.iadd(E)), { + div: p, + mod: m + }) : this.negative === 0 && E.negative !== 0 ? (w = this.divmod(E.neg(), b), b !== "mod" && (p = w.div.neg()), { + div: p, + mod: w.mod + }) : (this.negative & E.negative) !== 0 ? (w = this.neg().divmod(E.neg(), b), b !== "div" && (m = w.mod.neg(), l && m.negative !== 0 && m.isub(E)), { + div: w.div, + mod: m + }) : E.length > this.length || this.cmp(E) < 0 ? { + div: new s(0), + mod: this + } : E.length === 1 ? b === "div" ? { + div: this.divn(E.words[0]), + mod: null + } : b === "mod" ? { + div: null, + mod: new s(this.modn(E.words[0])) + } : { + div: this.divn(E.words[0]), + mod: new s(this.modn(E.words[0])) + } : this._wordDiv(E, b); + }, s.prototype.div = function(E) { + return this.divmod(E, "div", !1).div; + }, s.prototype.mod = function(E) { + return this.divmod(E, "mod", !1).mod; + }, s.prototype.umod = function(E) { + return this.divmod(E, "mod", !0).mod; + }, s.prototype.divRound = function(E) { + var b = this.divmod(E); + if (b.mod.isZero()) return b.div; + var l = b.div.negative !== 0 ? b.mod.isub(E) : b.mod, p = E.ushrn(1), m = E.andln(1), w = l.cmp(p); + return w < 0 || m === 1 && w === 0 ? b.div : b.div.negative !== 0 ? b.div.isubn(1) : b.div.iaddn(1); + }, s.prototype.modn = function(E) { + n(E <= 67108863); + for (var b = (1 << 26) % E, l = 0, p = this.length - 1; p >= 0; p--) + l = (b * l + (this.words[p] | 0)) % E; + return l; + }, s.prototype.idivn = function(E) { + n(E <= 67108863); + for (var b = 0, l = this.length - 1; l >= 0; l--) { + var p = (this.words[l] | 0) + b * 67108864; + this.words[l] = p / E | 0, b = p % E; + } + return this.strip(); + }, s.prototype.divn = function(E) { + return this.clone().idivn(E); + }, s.prototype.egcd = function(E) { + n(E.negative === 0), n(!E.isZero()); + var b = this, l = E.clone(); + b.negative !== 0 ? b = b.umod(E) : b = b.clone(); + for (var p = new s(1), m = new s(0), w = new s(0), P = new s(1), _ = 0; b.isEven() && l.isEven(); ) + b.iushrn(1), l.iushrn(1), ++_; + for (var y = l.clone(), M = b.clone(); !b.isZero(); ) { + for (var I = 0, q = 1; (b.words[0] & q) === 0 && I < 26; ++I, q <<= 1) ; + if (I > 0) + for (b.iushrn(I); I-- > 0; ) + (p.isOdd() || m.isOdd()) && (p.iadd(y), m.isub(M)), p.iushrn(1), m.iushrn(1); + for (var ce = 0, L = 1; (l.words[0] & L) === 0 && ce < 26; ++ce, L <<= 1) ; + if (ce > 0) + for (l.iushrn(ce); ce-- > 0; ) + (w.isOdd() || P.isOdd()) && (w.iadd(y), P.isub(M)), w.iushrn(1), P.iushrn(1); + b.cmp(l) >= 0 ? (b.isub(l), p.isub(w), m.isub(P)) : (l.isub(b), w.isub(p), P.isub(m)); + } + return { + a: w, + b: P, + gcd: l.iushln(_) + }; + }, s.prototype._invmp = function(E) { + n(E.negative === 0), n(!E.isZero()); + var b = this, l = E.clone(); + b.negative !== 0 ? b = b.umod(E) : b = b.clone(); + for (var p = new s(1), m = new s(0), w = l.clone(); b.cmpn(1) > 0 && l.cmpn(1) > 0; ) { + for (var P = 0, _ = 1; (b.words[0] & _) === 0 && P < 26; ++P, _ <<= 1) ; + if (P > 0) + for (b.iushrn(P); P-- > 0; ) + p.isOdd() && p.iadd(w), p.iushrn(1); + for (var y = 0, M = 1; (l.words[0] & M) === 0 && y < 26; ++y, M <<= 1) ; + if (y > 0) + for (l.iushrn(y); y-- > 0; ) + m.isOdd() && m.iadd(w), m.iushrn(1); + b.cmp(l) >= 0 ? (b.isub(l), p.isub(m)) : (l.isub(b), m.isub(p)); + } + var I; + return b.cmpn(1) === 0 ? I = p : I = m, I.cmpn(0) < 0 && I.iadd(E), I; + }, s.prototype.gcd = function(E) { + if (this.isZero()) return E.abs(); + if (E.isZero()) return this.abs(); + var b = this.clone(), l = E.clone(); + b.negative = 0, l.negative = 0; + for (var p = 0; b.isEven() && l.isEven(); p++) + b.iushrn(1), l.iushrn(1); + do { + for (; b.isEven(); ) + b.iushrn(1); + for (; l.isEven(); ) + l.iushrn(1); + var m = b.cmp(l); + if (m < 0) { + var w = b; + b = l, l = w; + } else if (m === 0 || l.cmpn(1) === 0) + break; + b.isub(l); + } while (!0); + return l.iushln(p); + }, s.prototype.invm = function(E) { + return this.egcd(E).a.umod(E); + }, s.prototype.isEven = function() { + return (this.words[0] & 1) === 0; + }, s.prototype.isOdd = function() { + return (this.words[0] & 1) === 1; + }, s.prototype.andln = function(E) { + return this.words[0] & E; + }, s.prototype.bincn = function(E) { + n(typeof E == "number"); + var b = E % 26, l = (E - b) / 26, p = 1 << b; + if (this.length <= l) + return this._expand(l + 1), this.words[l] |= p, this; + for (var m = p, w = l; m !== 0 && w < this.length; w++) { + var P = this.words[w] | 0; + P += m, m = P >>> 26, P &= 67108863, this.words[w] = P; + } + return m !== 0 && (this.words[w] = m, this.length++), this; + }, s.prototype.isZero = function() { + return this.length === 1 && this.words[0] === 0; + }, s.prototype.cmpn = function(E) { + var b = E < 0; + if (this.negative !== 0 && !b) return -1; + if (this.negative === 0 && b) return 1; + this.strip(); + var l; + if (this.length > 1) + l = 1; + else { + b && (E = -E), n(E <= 67108863, "Number is too big"); + var p = this.words[0] | 0; + l = p === E ? 0 : p < E ? -1 : 1; + } + return this.negative !== 0 ? -l | 0 : l; + }, s.prototype.cmp = function(E) { + if (this.negative !== 0 && E.negative === 0) return -1; + if (this.negative === 0 && E.negative !== 0) return 1; + var b = this.ucmp(E); + return this.negative !== 0 ? -b | 0 : b; + }, s.prototype.ucmp = function(E) { + if (this.length > E.length) return 1; + if (this.length < E.length) return -1; + for (var b = 0, l = this.length - 1; l >= 0; l--) { + var p = this.words[l] | 0, m = E.words[l] | 0; + if (p !== m) { + p < m ? b = -1 : p > m && (b = 1); + break; + } + } + return b; + }, s.prototype.gtn = function(E) { + return this.cmpn(E) === 1; + }, s.prototype.gt = function(E) { + return this.cmp(E) === 1; + }, s.prototype.gten = function(E) { + return this.cmpn(E) >= 0; + }, s.prototype.gte = function(E) { + return this.cmp(E) >= 0; + }, s.prototype.ltn = function(E) { + return this.cmpn(E) === -1; + }, s.prototype.lt = function(E) { + return this.cmp(E) === -1; + }, s.prototype.lten = function(E) { + return this.cmpn(E) <= 0; + }, s.prototype.lte = function(E) { + return this.cmp(E) <= 0; + }, s.prototype.eqn = function(E) { + return this.cmpn(E) === 0; + }, s.prototype.eq = function(E) { + return this.cmp(E) === 0; + }, s.red = function(E) { + return new J(E); + }, s.prototype.toRed = function(E) { + return n(!this.red, "Already a number in reduction context"), n(this.negative === 0, "red works only with positives"), E.convertTo(this)._forceRed(E); + }, s.prototype.fromRed = function() { + return n(this.red, "fromRed works only with numbers in reduction context"), this.red.convertFrom(this); + }, s.prototype._forceRed = function(E) { + return this.red = E, this; + }, s.prototype.forceRed = function(E) { + return n(!this.red, "Already a number in reduction context"), this._forceRed(E); + }, s.prototype.redAdd = function(E) { + return n(this.red, "redAdd works only with red numbers"), this.red.add(this, E); + }, s.prototype.redIAdd = function(E) { + return n(this.red, "redIAdd works only with red numbers"), this.red.iadd(this, E); + }, s.prototype.redSub = function(E) { + return n(this.red, "redSub works only with red numbers"), this.red.sub(this, E); + }, s.prototype.redISub = function(E) { + return n(this.red, "redISub works only with red numbers"), this.red.isub(this, E); + }, s.prototype.redShl = function(E) { + return n(this.red, "redShl works only with red numbers"), this.red.shl(this, E); + }, s.prototype.redMul = function(E) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, E), this.red.mul(this, E); + }, s.prototype.redIMul = function(E) { + return n(this.red, "redMul works only with red numbers"), this.red._verify2(this, E), this.red.imul(this, E); + }, s.prototype.redSqr = function() { + return n(this.red, "redSqr works only with red numbers"), this.red._verify1(this), this.red.sqr(this); + }, s.prototype.redISqr = function() { + return n(this.red, "redISqr works only with red numbers"), this.red._verify1(this), this.red.isqr(this); + }, s.prototype.redSqrt = function() { + return n(this.red, "redSqrt works only with red numbers"), this.red._verify1(this), this.red.sqrt(this); + }, s.prototype.redInvm = function() { + return n(this.red, "redInvm works only with red numbers"), this.red._verify1(this), this.red.invm(this); + }, s.prototype.redNeg = function() { + return n(this.red, "redNeg works only with red numbers"), this.red._verify1(this), this.red.neg(this); + }, s.prototype.redPow = function(E) { + return n(this.red && !E.red, "redPow(normalNum)"), this.red._verify1(this), this.red.pow(this, E); + }; + var z = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + function B(K, E) { + this.name = K, this.p = new s(E, 16), this.n = this.p.bitLength(), this.k = new s(1).iushln(this.n).isub(this.p), this.tmp = this._tmp(); + } + B.prototype._tmp = function() { + var E = new s(null); + return E.words = new Array(Math.ceil(this.n / 13)), E; + }, B.prototype.ireduce = function(E) { + var b = E, l; + do + this.split(b, this.tmp), b = this.imulK(b), b = b.iadd(this.tmp), l = b.bitLength(); + while (l > this.n); + var p = l < this.n ? -1 : b.ucmp(this.p); + return p === 0 ? (b.words[0] = 0, b.length = 1) : p > 0 ? b.isub(this.p) : b.strip !== void 0 ? b.strip() : b._strip(), b; + }, B.prototype.split = function(E, b) { + E.iushrn(this.n, 0, b); + }, B.prototype.imulK = function(E) { + return E.imul(this.k); + }; + function $() { + B.call( + this, + "k256", + "ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f" + ); + } + i($, B), $.prototype.split = function(E, b) { + for (var l = 4194303, p = Math.min(E.length, 9), m = 0; m < p; m++) + b.words[m] = E.words[m]; + if (b.length = p, E.length <= 9) { + E.words[0] = 0, E.length = 1; + return; + } + var w = E.words[9]; + for (b.words[b.length++] = w & l, m = 10; m < E.length; m++) { + var P = E.words[m] | 0; + E.words[m - 10] = (P & l) << 4 | w >>> 22, w = P; + } + w >>>= 22, E.words[m - 10] = w, w === 0 && E.length > 10 ? E.length -= 10 : E.length -= 9; + }, $.prototype.imulK = function(E) { + E.words[E.length] = 0, E.words[E.length + 1] = 0, E.length += 2; + for (var b = 0, l = 0; l < E.length; l++) { + var p = E.words[l] | 0; + b += p * 977, E.words[l] = b & 67108863, b = p * 64 + (b / 67108864 | 0); + } + return E.words[E.length - 1] === 0 && (E.length--, E.words[E.length - 1] === 0 && E.length--), E; + }; + function U() { + B.call( + this, + "p224", + "ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001" + ); + } + i(U, B); + function C() { + B.call( + this, + "p192", + "ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff" + ); + } + i(C, B); + function W() { + B.call( + this, + "25519", + "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed" + ); + } + i(W, B), W.prototype.imulK = function(E) { + for (var b = 0, l = 0; l < E.length; l++) { + var p = (E.words[l] | 0) * 19 + b, m = p & 67108863; + p >>>= 26, E.words[l] = m, b = p; + } + return b !== 0 && (E.words[E.length++] = b), E; + }, s._prime = function(E) { + if (z[E]) return z[E]; + var b; + if (E === "k256") + b = new $(); + else if (E === "p224") + b = new U(); + else if (E === "p192") + b = new C(); + else if (E === "p25519") + b = new W(); + else + throw new Error("Unknown prime " + E); + return z[E] = b, b; + }; + function J(K) { + if (typeof K == "string") { + var E = s._prime(K); + this.m = E.p, this.prime = E; + } else + n(K.gtn(1), "modulus must be greater than 1"), this.m = K, this.prime = null; + } + J.prototype._verify1 = function(E) { + n(E.negative === 0, "red works only with positives"), n(E.red, "red works only with red numbers"); + }, J.prototype._verify2 = function(E, b) { + n((E.negative | b.negative) === 0, "red works only with positives"), n( + E.red && E.red === b.red, + "red works only with red numbers" + ); + }, J.prototype.imod = function(E) { + return this.prime ? this.prime.ireduce(E)._forceRed(this) : E.umod(this.m)._forceRed(this); + }, J.prototype.neg = function(E) { + return E.isZero() ? E.clone() : this.m.sub(E)._forceRed(this); + }, J.prototype.add = function(E, b) { + this._verify2(E, b); + var l = E.add(b); + return l.cmp(this.m) >= 0 && l.isub(this.m), l._forceRed(this); + }, J.prototype.iadd = function(E, b) { + this._verify2(E, b); + var l = E.iadd(b); + return l.cmp(this.m) >= 0 && l.isub(this.m), l; + }, J.prototype.sub = function(E, b) { + this._verify2(E, b); + var l = E.sub(b); + return l.cmpn(0) < 0 && l.iadd(this.m), l._forceRed(this); + }, J.prototype.isub = function(E, b) { + this._verify2(E, b); + var l = E.isub(b); + return l.cmpn(0) < 0 && l.iadd(this.m), l; + }, J.prototype.shl = function(E, b) { + return this._verify1(E), this.imod(E.ushln(b)); + }, J.prototype.imul = function(E, b) { + return this._verify2(E, b), this.imod(E.imul(b)); + }, J.prototype.mul = function(E, b) { + return this._verify2(E, b), this.imod(E.mul(b)); + }, J.prototype.isqr = function(E) { + return this.imul(E, E.clone()); + }, J.prototype.sqr = function(E) { + return this.mul(E, E); + }, J.prototype.sqrt = function(E) { + if (E.isZero()) return E.clone(); + var b = this.m.andln(3); + if (n(b % 2 === 1), b === 3) { + var l = this.m.add(new s(1)).iushrn(2); + return this.pow(E, l); + } + for (var p = this.m.subn(1), m = 0; !p.isZero() && p.andln(1) === 0; ) + m++, p.iushrn(1); + n(!p.isZero()); + var w = new s(1).toRed(this), P = w.redNeg(), _ = this.m.subn(1).iushrn(1), y = this.m.bitLength(); + for (y = new s(2 * y * y).toRed(this); this.pow(y, _).cmp(P) !== 0; ) + y.redIAdd(P); + for (var M = this.pow(y, p), I = this.pow(E, p.addn(1).iushrn(1)), q = this.pow(E, p), ce = m; q.cmp(w) !== 0; ) { + for (var L = q, oe = 0; L.cmp(w) !== 0; oe++) + L = L.redSqr(); + n(oe < ce); + var Q = this.pow(M, new s(1).iushln(ce - oe - 1)); + I = I.redMul(Q), M = Q.redSqr(), q = q.redMul(M), ce = oe; + } + return I; + }, J.prototype.invm = function(E) { + var b = E._invmp(this.m); + return b.negative !== 0 ? (b.negative = 0, this.imod(b).redNeg()) : this.imod(b); + }, J.prototype.pow = function(E, b) { + if (b.isZero()) return new s(1).toRed(this); + if (b.cmpn(1) === 0) return E.clone(); + var l = 4, p = new Array(1 << l); + p[0] = new s(1).toRed(this), p[1] = E; + for (var m = 2; m < p.length; m++) + p[m] = this.mul(p[m - 1], E); + var w = p[0], P = 0, _ = 0, y = b.bitLength() % 26; + for (y === 0 && (y = 26), m = b.length - 1; m >= 0; m--) { + for (var M = b.words[m], I = y - 1; I >= 0; I--) { + var q = M >> I & 1; + if (w !== p[0] && (w = this.sqr(w)), q === 0 && P === 0) { + _ = 0; + continue; + } + P <<= 1, P |= q, _++, !(_ !== l && (m !== 0 || I !== 0)) && (w = this.mul(w, p[P]), _ = 0, P = 0); + } + y = 26; + } + return w; + }, J.prototype.convertTo = function(E) { + var b = E.umod(this.m); + return b === E ? b.clone() : b; + }, J.prototype.convertFrom = function(E) { + var b = E.clone(); + return b.red = null, b; + }, s.mont = function(E) { + return new ne(E); + }; + function ne(K) { + J.call(this, K), this.shift = this.m.bitLength(), this.shift % 26 !== 0 && (this.shift += 26 - this.shift % 26), this.r = new s(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(ne, J), ne.prototype.convertTo = function(E) { + return this.imod(E.ushln(this.shift)); + }, ne.prototype.convertFrom = function(E) { + var b = this.imod(E.mul(this.rinv)); + return b.red = null, b; + }, ne.prototype.imul = function(E, b) { + if (E.isZero() || b.isZero()) + return E.words[0] = 0, E.length = 1, E; + var l = E.imul(b), p = l.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), m = l.isub(p).iushrn(this.shift), w = m; + return m.cmp(this.m) >= 0 ? w = m.isub(this.m) : m.cmpn(0) < 0 && (w = m.iadd(this.m)), w._forceRed(this); + }, ne.prototype.mul = function(E, b) { + if (E.isZero() || b.isZero()) return new s(0)._forceRed(this); + var l = E.mul(b), p = l.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m), m = l.isub(p).iushrn(this.shift), w = m; + return m.cmp(this.m) >= 0 ? w = m.isub(this.m) : m.cmpn(0) < 0 && (w = m.iadd(this.m)), w._forceRed(this); + }, ne.prototype.invm = function(E) { + var b = this.imod(E._invmp(this.m).mul(this.r2)); + return b._forceRed(this); + }; + })(t, aF); + })(qh)), qh.exports; +} +var Dg = {}, Cx; +function w8() { + return Cx || (Cx = 1, (function(t) { + var e = t; + function r(s, o) { + if (Array.isArray(s)) + return s.slice(); + if (!s) + return []; + var a = []; + if (typeof s != "string") { + for (var f = 0; f < s.length; f++) + a[f] = s[f] | 0; + return a; + } + if (o === "hex") { + s = s.replace(/[^a-z0-9]+/ig, ""), s.length % 2 !== 0 && (s = "0" + s); + for (var f = 0; f < s.length; f += 2) + a.push(parseInt(s[f] + s[f + 1], 16)); + } else + for (var f = 0; f < s.length; f++) { + var u = s.charCodeAt(f), h = u >> 8, g = u & 255; + h ? a.push(h, g) : a.push(g); + } + return a; + } + e.toArray = r; + function n(s) { + return s.length === 1 ? "0" + s : s; + } + e.zero2 = n; + function i(s) { + for (var o = "", a = 0; a < s.length; a++) + o += n(s[a].toString(16)); + return o; + } + e.toHex = i, e.encode = function(o, a) { + return a === "hex" ? i(o) : o; + }; + })(Dg)), Dg; +} +var Rx; +function Gi() { + return Rx || (Rx = 1, (function(t) { + var e = t, r = go(), n = Wa(), i = w8(); + e.assert = n, e.toArray = i.toArray, e.zero2 = i.zero2, e.toHex = i.toHex, e.encode = i.encode; + function s(h, g, v) { + var x = new Array(Math.max(h.bitLength(), v) + 1), S; + for (S = 0; S < x.length; S += 1) + x[S] = 0; + var R = 1 << g + 1, D = h.clone(); + for (S = 0; S < x.length; S++) { + var k, N = D.andln(R - 1); + D.isOdd() ? (N > (R >> 1) - 1 ? k = (R >> 1) - N : k = N, D.isubn(k)) : k = 0, x[S] = k, D.iushrn(1); + } + return x; + } + e.getNAF = s; + function o(h, g) { + var v = [ + [], + [] + ]; + h = h.clone(), g = g.clone(); + for (var x = 0, S = 0, R; h.cmpn(-x) > 0 || g.cmpn(-S) > 0; ) { + var D = h.andln(3) + x & 3, k = g.andln(3) + S & 3; + D === 3 && (D = -1), k === 3 && (k = -1); + var N; + (D & 1) === 0 ? N = 0 : (R = h.andln(7) + x & 7, (R === 3 || R === 5) && k === 2 ? N = -D : N = D), v[0].push(N); + var z; + (k & 1) === 0 ? z = 0 : (R = g.andln(7) + S & 7, (R === 3 || R === 5) && D === 2 ? z = -k : z = k), v[1].push(z), 2 * x === N + 1 && (x = 1 - x), 2 * S === z + 1 && (S = 1 - S), h.iushrn(1), g.iushrn(1); + } + return v; + } + e.getJSF = o; + function a(h, g, v) { + var x = "_" + g; + h.prototype[g] = function() { + return this[x] !== void 0 ? this[x] : this[x] = v.call(this); + }; + } + e.cachedProperty = a; + function f(h) { + return typeof h == "string" ? e.toArray(h, "hex") : h; + } + e.parseBytes = f; + function u(h) { + return new r(h, "hex", "le"); + } + e.intFromLE = u; + })(Tg)), Tg; +} +var _h = { exports: {} }, Tx; +function x8() { + if (Tx) return _h.exports; + Tx = 1; + var t; + _h.exports = function(i) { + return t || (t = new e(null)), t.generate(i); + }; + function e(n) { + this.rand = n; + } + if (_h.exports.Rand = e, e.prototype.generate = function(i) { + return this._rand(i); + }, e.prototype._rand = function(i) { + if (this.rand.getBytes) + return this.rand.getBytes(i); + for (var s = new Uint8Array(i), o = 0; o < s.length; o++) + s[o] = this.rand.getByte(); + return s; + }, typeof self == "object") + self.crypto && self.crypto.getRandomValues ? e.prototype._rand = function(i) { + var s = new Uint8Array(i); + return self.crypto.getRandomValues(s), s; + } : self.msCrypto && self.msCrypto.getRandomValues ? e.prototype._rand = function(i) { + var s = new Uint8Array(i); + return self.msCrypto.getRandomValues(s), s; + } : typeof window == "object" && (e.prototype._rand = function() { + throw new Error("Not implemented yet"); + }); + else + try { + var r = Qf; + if (typeof r.randomBytes != "function") + throw new Error("Not supported"); + e.prototype._rand = function(i) { + return r.randomBytes(i); + }; + } catch { + } + return _h.exports; +} +var Og = {}, Ng, Dx; +function t0() { + if (Dx) return Ng; + Dx = 1; + var t = go(), e = Gi(), r = e.getNAF, n = e.getJSF, i = e.assert; + function s(a, f) { + this.type = a, this.p = new t(f.p, 16), this.red = f.prime ? t.red(f.prime) : t.mont(this.p), this.zero = new t(0).toRed(this.red), this.one = new t(1).toRed(this.red), this.two = new t(2).toRed(this.red), this.n = f.n && new t(f.n, 16), this.g = f.g && this.pointFromJSON(f.g, f.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 u = this.n && this.p.div(this.n); + !u || u.cmpn(100) > 0 ? this.redN = null : (this._maxwellTrick = !0, this.redN = this.n.toRed(this.red)); + } + Ng = s, s.prototype.point = function() { + throw new Error("Not implemented"); + }, s.prototype.validate = function() { + throw new Error("Not implemented"); + }, s.prototype._fixedNafMul = function(f, u) { + i(f.precomputed); + var h = f._getDoubles(), g = r(u, 1, this._bitLength), v = (1 << h.step + 1) - (h.step % 2 === 0 ? 2 : 1); + v /= 3; + var x = [], S, R; + for (S = 0; S < g.length; S += h.step) { + R = 0; + for (var D = S + h.step - 1; D >= S; D--) + R = (R << 1) + g[D]; + x.push(R); + } + for (var k = this.jpoint(null, null, null), N = this.jpoint(null, null, null), z = v; z > 0; z--) { + for (S = 0; S < x.length; S++) + R = x[S], R === z ? N = N.mixedAdd(h.points[S]) : R === -z && (N = N.mixedAdd(h.points[S].neg())); + k = k.add(N); + } + return k.toP(); + }, s.prototype._wnafMul = function(f, u) { + var h = 4, g = f._getNAFPoints(h); + h = g.wnd; + for (var v = g.points, x = r(u, h, this._bitLength), S = this.jpoint(null, null, null), R = x.length - 1; R >= 0; R--) { + for (var D = 0; R >= 0 && x[R] === 0; R--) + D++; + if (R >= 0 && D++, S = S.dblp(D), R < 0) + break; + var k = x[R]; + i(k !== 0), f.type === "affine" ? k > 0 ? S = S.mixedAdd(v[k - 1 >> 1]) : S = S.mixedAdd(v[-k - 1 >> 1].neg()) : k > 0 ? S = S.add(v[k - 1 >> 1]) : S = S.add(v[-k - 1 >> 1].neg()); + } + return f.type === "affine" ? S.toP() : S; + }, s.prototype._wnafMulAdd = function(f, u, h, g, v) { + var x = this._wnafT1, S = this._wnafT2, R = this._wnafT3, D = 0, k, N, z; + for (k = 0; k < g; k++) { + z = u[k]; + var B = z._getNAFPoints(f); + x[k] = B.wnd, S[k] = B.points; + } + for (k = g - 1; k >= 1; k -= 2) { + var $ = k - 1, U = k; + if (x[$] !== 1 || x[U] !== 1) { + R[$] = r(h[$], x[$], this._bitLength), R[U] = r(h[U], x[U], this._bitLength), D = Math.max(R[$].length, D), D = Math.max(R[U].length, D); + continue; + } + var C = [ + u[$], + /* 1 */ + null, + /* 3 */ + null, + /* 5 */ + u[U] + /* 7 */ + ]; + u[$].y.cmp(u[U].y) === 0 ? (C[1] = u[$].add(u[U]), C[2] = u[$].toJ().mixedAdd(u[U].neg())) : u[$].y.cmp(u[U].y.redNeg()) === 0 ? (C[1] = u[$].toJ().mixedAdd(u[U]), C[2] = u[$].add(u[U].neg())) : (C[1] = u[$].toJ().mixedAdd(u[U]), C[2] = u[$].toJ().mixedAdd(u[U].neg())); + var W = [ + -3, + /* -1 -1 */ + -1, + /* -1 0 */ + -5, + /* -1 1 */ + -7, + /* 0 -1 */ + 0, + /* 0 0 */ + 7, + /* 0 1 */ + 5, + /* 1 -1 */ + 1, + /* 1 0 */ + 3 + /* 1 1 */ + ], J = n(h[$], h[U]); + for (D = Math.max(J[0].length, D), R[$] = new Array(D), R[U] = new Array(D), N = 0; N < D; N++) { + var ne = J[0][N] | 0, K = J[1][N] | 0; + R[$][N] = W[(ne + 1) * 3 + (K + 1)], R[U][N] = 0, S[$] = C; + } + } + var E = this.jpoint(null, null, null), b = this._wnafT4; + for (k = D; k >= 0; k--) { + for (var l = 0; k >= 0; ) { + var p = !0; + for (N = 0; N < g; N++) + b[N] = R[N][k] | 0, b[N] !== 0 && (p = !1); + if (!p) + break; + l++, k--; + } + if (k >= 0 && l++, E = E.dblp(l), k < 0) + break; + for (N = 0; N < g; N++) { + var m = b[N]; + m !== 0 && (m > 0 ? z = S[N][m - 1 >> 1] : m < 0 && (z = S[N][-m - 1 >> 1].neg()), z.type === "affine" ? E = E.mixedAdd(z) : E = E.add(z)); + } + } + for (k = 0; k < g; k++) + S[k] = null; + return v ? E : E.toP(); + }; + function o(a, f) { + this.curve = a, this.type = f, this.precomputed = null; + } + return s.BasePoint = o, o.prototype.eq = function() { + throw new Error("Not implemented"); + }, o.prototype.validate = function() { + return this.curve.validate(this); + }, s.prototype.decodePoint = function(f, u) { + f = e.toArray(f, u); + var h = this.p.byteLength(); + if ((f[0] === 4 || f[0] === 6 || f[0] === 7) && f.length - 1 === 2 * h) { + f[0] === 6 ? i(f[f.length - 1] % 2 === 0) : f[0] === 7 && i(f[f.length - 1] % 2 === 1); + var g = this.point( + f.slice(1, 1 + h), + f.slice(1 + h, 1 + 2 * h) + ); + return g; + } else if ((f[0] === 2 || f[0] === 3) && f.length - 1 === h) + return this.pointFromX(f.slice(1, 1 + h), f[0] === 3); + throw new Error("Unknown point format"); + }, o.prototype.encodeCompressed = function(f) { + return this.encode(f, !0); + }, o.prototype._encode = function(f) { + var u = this.curve.p.byteLength(), h = this.getX().toArray("be", u); + return f ? [this.getY().isEven() ? 2 : 3].concat(h) : [4].concat(h, this.getY().toArray("be", u)); + }, o.prototype.encode = function(f, u) { + return e.encode(this._encode(u), f); + }, o.prototype.precompute = function(f) { + if (this.precomputed) + return this; + var u = { + doubles: null, + naf: null, + beta: null + }; + return u.naf = this._getNAFPoints(8), u.doubles = this._getDoubles(4, f), u.beta = this._getBeta(), this.precomputed = u, this; + }, o.prototype._hasDoubles = function(f) { + if (!this.precomputed) + return !1; + var u = this.precomputed.doubles; + return u ? u.points.length >= Math.ceil((f.bitLength() + 1) / u.step) : !1; + }, o.prototype._getDoubles = function(f, u) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + for (var h = [this], g = this, v = 0; v < u; v += f) { + for (var x = 0; x < f; x++) + g = g.dbl(); + h.push(g); + } + return { + step: f, + points: h + }; + }, o.prototype._getNAFPoints = function(f) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + for (var u = [this], h = (1 << f) - 1, g = h === 1 ? null : this.dbl(), v = 1; v < h; v++) + u[v] = u[v - 1].add(g); + return { + wnd: f, + points: u + }; + }, o.prototype._getBeta = function() { + return null; + }, o.prototype.dblp = function(f) { + for (var u = this, h = 0; h < f; h++) + u = u.dbl(); + return u; + }, Ng; +} +var Lg, Ox; +function cF() { + if (Ox) return Lg; + Ox = 1; + var t = Gi(), e = go(), r = Jd(), n = t0(), i = t.assert; + function s(f) { + n.call(this, "short", f), this.a = new e(f.a, 16).toRed(this.red), this.b = new e(f.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(f), this._endoWnafT1 = new Array(4), this._endoWnafT2 = new Array(4); + } + r(s, n), Lg = s, s.prototype._getEndomorphism = function(u) { + if (!(!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1)) { + var h, g; + if (u.beta) + h = new e(u.beta, 16).toRed(this.red); + else { + var v = this._getEndoRoots(this.p); + h = v[0].cmp(v[1]) < 0 ? v[0] : v[1], h = h.toRed(this.red); + } + if (u.lambda) + g = new e(u.lambda, 16); + else { + var x = this._getEndoRoots(this.n); + this.g.mul(x[0]).x.cmp(this.g.x.redMul(h)) === 0 ? g = x[0] : (g = x[1], i(this.g.mul(g).x.cmp(this.g.x.redMul(h)) === 0)); + } + var S; + return u.basis ? S = u.basis.map(function(R) { + return { + a: new e(R.a, 16), + b: new e(R.b, 16) + }; + }) : S = this._getEndoBasis(g), { + beta: h, + lambda: g, + basis: S + }; + } + }, s.prototype._getEndoRoots = function(u) { + var h = u === this.p ? this.red : e.mont(u), g = new e(2).toRed(h).redInvm(), v = g.redNeg(), x = new e(3).toRed(h).redNeg().redSqrt().redMul(g), S = v.redAdd(x).fromRed(), R = v.redSub(x).fromRed(); + return [S, R]; + }, s.prototype._getEndoBasis = function(u) { + for (var h = this.n.ushrn(Math.floor(this.n.bitLength() / 2)), g = u, v = this.n.clone(), x = new e(1), S = new e(0), R = new e(0), D = new e(1), k, N, z, B, $, U, C, W = 0, J, ne; g.cmpn(0) !== 0; ) { + var K = v.div(g); + J = v.sub(K.mul(g)), ne = R.sub(K.mul(x)); + var E = D.sub(K.mul(S)); + if (!z && J.cmp(h) < 0) + k = C.neg(), N = x, z = J.neg(), B = ne; + else if (z && ++W === 2) + break; + C = J, v = g, g = J, R = x, x = ne, D = S, S = E; + } + $ = J.neg(), U = ne; + var b = z.sqr().add(B.sqr()), l = $.sqr().add(U.sqr()); + return l.cmp(b) >= 0 && ($ = k, U = N), z.negative && (z = z.neg(), B = B.neg()), $.negative && ($ = $.neg(), U = U.neg()), [ + { a: z, b: B }, + { a: $, b: U } + ]; + }, s.prototype._endoSplit = function(u) { + var h = this.endo.basis, g = h[0], v = h[1], x = v.b.mul(u).divRound(this.n), S = g.b.neg().mul(u).divRound(this.n), R = x.mul(g.a), D = S.mul(v.a), k = x.mul(g.b), N = S.mul(v.b), z = u.sub(R).sub(D), B = k.add(N).neg(); + return { k1: z, k2: B }; + }, s.prototype.pointFromX = function(u, h) { + u = new e(u, 16), u.red || (u = u.toRed(this.red)); + var g = u.redSqr().redMul(u).redIAdd(u.redMul(this.a)).redIAdd(this.b), v = g.redSqrt(); + if (v.redSqr().redSub(g).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var x = v.fromRed().isOdd(); + return (h && !x || !h && x) && (v = v.redNeg()), this.point(u, v); + }, s.prototype.validate = function(u) { + if (u.inf) + return !0; + var h = u.x, g = u.y, v = this.a.redMul(h), x = h.redSqr().redMul(h).redIAdd(v).redIAdd(this.b); + return g.redSqr().redISub(x).cmpn(0) === 0; + }, s.prototype._endoWnafMulAdd = function(u, h, g) { + for (var v = this._endoWnafT1, x = this._endoWnafT2, S = 0; S < u.length; S++) { + var R = this._endoSplit(h[S]), D = u[S], k = D._getBeta(); + R.k1.negative && (R.k1.ineg(), D = D.neg(!0)), R.k2.negative && (R.k2.ineg(), k = k.neg(!0)), v[S * 2] = D, v[S * 2 + 1] = k, x[S * 2] = R.k1, x[S * 2 + 1] = R.k2; + } + for (var N = this._wnafMulAdd(1, v, x, S * 2, g), z = 0; z < S * 2; z++) + v[z] = null, x[z] = null; + return N; + }; + function o(f, u, h, g) { + n.BasePoint.call(this, f, "affine"), u === null && h === null ? (this.x = null, this.y = null, this.inf = !0) : (this.x = new e(u, 16), this.y = new e(h, 16), g && (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); + } + r(o, n.BasePoint), s.prototype.point = function(u, h, g) { + return new o(this, u, h, g); + }, s.prototype.pointFromJSON = function(u, h) { + return o.fromJSON(this, u, h); + }, o.prototype._getBeta = function() { + if (this.curve.endo) { + var u = this.precomputed; + if (u && u.beta) + return u.beta; + var h = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (u) { + var g = this.curve, v = function(x) { + return g.point(x.x.redMul(g.endo.beta), x.y); + }; + u.beta = h, h.precomputed = { + beta: null, + naf: u.naf && { + wnd: u.naf.wnd, + points: u.naf.points.map(v) + }, + doubles: u.doubles && { + step: u.doubles.step, + points: u.doubles.points.map(v) + } + }; + } + return h; + } + }, o.prototype.toJSON = function() { + return this.precomputed ? [this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1) + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1) + } + }] : [this.x, this.y]; + }, o.fromJSON = function(u, h, g) { + typeof h == "string" && (h = JSON.parse(h)); + var v = u.point(h[0], h[1], g); + if (!h[2]) + return v; + function x(R) { + return u.point(R[0], R[1], g); + } + var S = h[2]; + return v.precomputed = { + beta: null, + doubles: S.doubles && { + step: S.doubles.step, + points: [v].concat(S.doubles.points.map(x)) + }, + naf: S.naf && { + wnd: S.naf.wnd, + points: [v].concat(S.naf.points.map(x)) + } + }, v; + }, o.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, o.prototype.isInfinity = function() { + return this.inf; + }, o.prototype.add = function(u) { + if (this.inf) + return u; + if (u.inf) + return this; + if (this.eq(u)) + return this.dbl(); + if (this.neg().eq(u)) + return this.curve.point(null, null); + if (this.x.cmp(u.x) === 0) + return this.curve.point(null, null); + var h = this.y.redSub(u.y); + h.cmpn(0) !== 0 && (h = h.redMul(this.x.redSub(u.x).redInvm())); + var g = h.redSqr().redISub(this.x).redISub(u.x), v = h.redMul(this.x.redSub(g)).redISub(this.y); + return this.curve.point(g, v); + }, o.prototype.dbl = function() { + if (this.inf) + return this; + var u = this.y.redAdd(this.y); + if (u.cmpn(0) === 0) + return this.curve.point(null, null); + var h = this.curve.a, g = this.x.redSqr(), v = u.redInvm(), x = g.redAdd(g).redIAdd(g).redIAdd(h).redMul(v), S = x.redSqr().redISub(this.x.redAdd(this.x)), R = x.redMul(this.x.redSub(S)).redISub(this.y); + return this.curve.point(S, R); + }, o.prototype.getX = function() { + return this.x.fromRed(); + }, o.prototype.getY = function() { + return this.y.fromRed(); + }, o.prototype.mul = function(u) { + return u = new e(u, 16), this.isInfinity() ? this : this._hasDoubles(u) ? this.curve._fixedNafMul(this, u) : this.curve.endo ? this.curve._endoWnafMulAdd([this], [u]) : this.curve._wnafMul(this, u); + }, o.prototype.mulAdd = function(u, h, g) { + var v = [this, h], x = [u, g]; + return this.curve.endo ? this.curve._endoWnafMulAdd(v, x) : this.curve._wnafMulAdd(1, v, x, 2); + }, o.prototype.jmulAdd = function(u, h, g) { + var v = [this, h], x = [u, g]; + return this.curve.endo ? this.curve._endoWnafMulAdd(v, x, !0) : this.curve._wnafMulAdd(1, v, x, 2, !0); + }, o.prototype.eq = function(u) { + return this === u || this.inf === u.inf && (this.inf || this.x.cmp(u.x) === 0 && this.y.cmp(u.y) === 0); + }, o.prototype.neg = function(u) { + if (this.inf) + return this; + var h = this.curve.point(this.x, this.y.redNeg()); + if (u && this.precomputed) { + var g = this.precomputed, v = function(x) { + return x.neg(); + }; + h.precomputed = { + naf: g.naf && { + wnd: g.naf.wnd, + points: g.naf.points.map(v) + }, + doubles: g.doubles && { + step: g.doubles.step, + points: g.doubles.points.map(v) + } + }; + } + return h; + }, o.prototype.toJ = function() { + if (this.inf) + return this.curve.jpoint(null, null, null); + var u = this.curve.jpoint(this.x, this.y, this.curve.one); + return u; + }; + function a(f, u, h, g) { + n.BasePoint.call(this, f, "jacobian"), u === null && h === null && g === null ? (this.x = this.curve.one, this.y = this.curve.one, this.z = new e(0)) : (this.x = new e(u, 16), this.y = new e(h, 16), this.z = new e(g, 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; + } + return r(a, n.BasePoint), s.prototype.jpoint = function(u, h, g) { + return new a(this, u, h, g); + }, a.prototype.toP = function() { + if (this.isInfinity()) + return this.curve.point(null, null); + var u = this.z.redInvm(), h = u.redSqr(), g = this.x.redMul(h), v = this.y.redMul(h).redMul(u); + return this.curve.point(g, v); + }, a.prototype.neg = function() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }, a.prototype.add = function(u) { + if (this.isInfinity()) + return u; + if (u.isInfinity()) + return this; + var h = u.z.redSqr(), g = this.z.redSqr(), v = this.x.redMul(h), x = u.x.redMul(g), S = this.y.redMul(h.redMul(u.z)), R = u.y.redMul(g.redMul(this.z)), D = v.redSub(x), k = S.redSub(R); + if (D.cmpn(0) === 0) + return k.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var N = D.redSqr(), z = N.redMul(D), B = v.redMul(N), $ = k.redSqr().redIAdd(z).redISub(B).redISub(B), U = k.redMul(B.redISub($)).redISub(S.redMul(z)), C = this.z.redMul(u.z).redMul(D); + return this.curve.jpoint($, U, C); + }, a.prototype.mixedAdd = function(u) { + if (this.isInfinity()) + return u.toJ(); + if (u.isInfinity()) + return this; + var h = this.z.redSqr(), g = this.x, v = u.x.redMul(h), x = this.y, S = u.y.redMul(h).redMul(this.z), R = g.redSub(v), D = x.redSub(S); + if (R.cmpn(0) === 0) + return D.cmpn(0) !== 0 ? this.curve.jpoint(null, null, null) : this.dbl(); + var k = R.redSqr(), N = k.redMul(R), z = g.redMul(k), B = D.redSqr().redIAdd(N).redISub(z).redISub(z), $ = D.redMul(z.redISub(B)).redISub(x.redMul(N)), U = this.z.redMul(R); + return this.curve.jpoint(B, $, U); + }, a.prototype.dblp = function(u) { + if (u === 0) + return this; + if (this.isInfinity()) + return this; + if (!u) + return this.dbl(); + var h; + if (this.curve.zeroA || this.curve.threeA) { + var g = this; + for (h = 0; h < u; h++) + g = g.dbl(); + return g; + } + var v = this.curve.a, x = this.curve.tinv, S = this.x, R = this.y, D = this.z, k = D.redSqr().redSqr(), N = R.redAdd(R); + for (h = 0; h < u; h++) { + var z = S.redSqr(), B = N.redSqr(), $ = B.redSqr(), U = z.redAdd(z).redIAdd(z).redIAdd(v.redMul(k)), C = S.redMul(B), W = U.redSqr().redISub(C.redAdd(C)), J = C.redISub(W), ne = U.redMul(J); + ne = ne.redIAdd(ne).redISub($); + var K = N.redMul(D); + h + 1 < u && (k = k.redMul($)), S = W, D = K, N = ne; + } + return this.curve.jpoint(S, N.redMul(x), D); + }, a.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.zeroA ? this._zeroDbl() : this.curve.threeA ? this._threeDbl() : this._dbl(); + }, a.prototype._zeroDbl = function() { + var u, h, g; + if (this.zOne) { + var v = this.x.redSqr(), x = this.y.redSqr(), S = x.redSqr(), R = this.x.redAdd(x).redSqr().redISub(v).redISub(S); + R = R.redIAdd(R); + var D = v.redAdd(v).redIAdd(v), k = D.redSqr().redISub(R).redISub(R), N = S.redIAdd(S); + N = N.redIAdd(N), N = N.redIAdd(N), u = k, h = D.redMul(R.redISub(k)).redISub(N), g = this.y.redAdd(this.y); + } else { + var z = this.x.redSqr(), B = this.y.redSqr(), $ = B.redSqr(), U = this.x.redAdd(B).redSqr().redISub(z).redISub($); + U = U.redIAdd(U); + var C = z.redAdd(z).redIAdd(z), W = C.redSqr(), J = $.redIAdd($); + J = J.redIAdd(J), J = J.redIAdd(J), u = W.redISub(U).redISub(U), h = C.redMul(U.redISub(u)).redISub(J), g = this.y.redMul(this.z), g = g.redIAdd(g); + } + return this.curve.jpoint(u, h, g); + }, a.prototype._threeDbl = function() { + var u, h, g; + if (this.zOne) { + var v = this.x.redSqr(), x = this.y.redSqr(), S = x.redSqr(), R = this.x.redAdd(x).redSqr().redISub(v).redISub(S); + R = R.redIAdd(R); + var D = v.redAdd(v).redIAdd(v).redIAdd(this.curve.a), k = D.redSqr().redISub(R).redISub(R); + u = k; + var N = S.redIAdd(S); + N = N.redIAdd(N), N = N.redIAdd(N), h = D.redMul(R.redISub(k)).redISub(N), g = this.y.redAdd(this.y); + } else { + var z = this.z.redSqr(), B = this.y.redSqr(), $ = this.x.redMul(B), U = this.x.redSub(z).redMul(this.x.redAdd(z)); + U = U.redAdd(U).redIAdd(U); + var C = $.redIAdd($); + C = C.redIAdd(C); + var W = C.redAdd(C); + u = U.redSqr().redISub(W), g = this.y.redAdd(this.z).redSqr().redISub(B).redISub(z); + var J = B.redSqr(); + J = J.redIAdd(J), J = J.redIAdd(J), J = J.redIAdd(J), h = U.redMul(C.redISub(u)).redISub(J); + } + return this.curve.jpoint(u, h, g); + }, a.prototype._dbl = function() { + var u = this.curve.a, h = this.x, g = this.y, v = this.z, x = v.redSqr().redSqr(), S = h.redSqr(), R = g.redSqr(), D = S.redAdd(S).redIAdd(S).redIAdd(u.redMul(x)), k = h.redAdd(h); + k = k.redIAdd(k); + var N = k.redMul(R), z = D.redSqr().redISub(N.redAdd(N)), B = N.redISub(z), $ = R.redSqr(); + $ = $.redIAdd($), $ = $.redIAdd($), $ = $.redIAdd($); + var U = D.redMul(B).redISub($), C = g.redAdd(g).redMul(v); + return this.curve.jpoint(z, U, C); + }, a.prototype.trpl = function() { + if (!this.curve.zeroA) + return this.dbl().add(this); + var u = this.x.redSqr(), h = this.y.redSqr(), g = this.z.redSqr(), v = h.redSqr(), x = u.redAdd(u).redIAdd(u), S = x.redSqr(), R = this.x.redAdd(h).redSqr().redISub(u).redISub(v); + R = R.redIAdd(R), R = R.redAdd(R).redIAdd(R), R = R.redISub(S); + var D = R.redSqr(), k = v.redIAdd(v); + k = k.redIAdd(k), k = k.redIAdd(k), k = k.redIAdd(k); + var N = x.redIAdd(R).redSqr().redISub(S).redISub(D).redISub(k), z = h.redMul(N); + z = z.redIAdd(z), z = z.redIAdd(z); + var B = this.x.redMul(D).redISub(z); + B = B.redIAdd(B), B = B.redIAdd(B); + var $ = this.y.redMul(N.redMul(k.redISub(N)).redISub(R.redMul(D))); + $ = $.redIAdd($), $ = $.redIAdd($), $ = $.redIAdd($); + var U = this.z.redAdd(R).redSqr().redISub(g).redISub(D); + return this.curve.jpoint(B, $, U); + }, a.prototype.mul = function(u, h) { + return u = new e(u, h), this.curve._wnafMul(this, u); + }, a.prototype.eq = function(u) { + if (u.type === "affine") + return this.eq(u.toJ()); + if (this === u) + return !0; + var h = this.z.redSqr(), g = u.z.redSqr(); + if (this.x.redMul(g).redISub(u.x.redMul(h)).cmpn(0) !== 0) + return !1; + var v = h.redMul(this.z), x = g.redMul(u.z); + return this.y.redMul(x).redISub(u.y.redMul(v)).cmpn(0) === 0; + }, a.prototype.eqXToP = function(u) { + var h = this.z.redSqr(), g = u.toRed(this.curve.red).redMul(h); + if (this.x.cmp(g) === 0) + return !0; + for (var v = u.clone(), x = this.curve.redN.redMul(h); ; ) { + if (v.iadd(this.curve.n), v.cmp(this.curve.p) >= 0) + return !1; + if (g.redIAdd(x), this.x.cmp(g) === 0) + return !0; + } + }, a.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, a.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; + }, Lg; +} +var kg, Nx; +function uF() { + if (Nx) return kg; + Nx = 1; + var t = go(), e = Jd(), r = t0(), n = Gi(); + function i(o) { + r.call(this, "mont", o), this.a = new t(o.a, 16).toRed(this.red), this.b = new t(o.b, 16).toRed(this.red), this.i4 = new t(4).toRed(this.red).redInvm(), this.two = new t(2).toRed(this.red), this.a24 = this.i4.redMul(this.a.redAdd(this.two)); + } + e(i, r), kg = i, i.prototype.validate = function(a) { + var f = a.normalize().x, u = f.redSqr(), h = u.redMul(f).redAdd(u.redMul(this.a)).redAdd(f), g = h.redSqrt(); + return g.redSqr().cmp(h) === 0; + }; + function s(o, a, f) { + r.BasePoint.call(this, o, "projective"), a === null && f === null ? (this.x = this.curve.one, this.z = this.curve.zero) : (this.x = new t(a, 16), this.z = new t(f, 16), this.x.red || (this.x = this.x.toRed(this.curve.red)), this.z.red || (this.z = this.z.toRed(this.curve.red))); + } + return e(s, r.BasePoint), i.prototype.decodePoint = function(a, f) { + return this.point(n.toArray(a, f), 1); + }, i.prototype.point = function(a, f) { + return new s(this, a, f); + }, i.prototype.pointFromJSON = function(a) { + return s.fromJSON(this, a); + }, s.prototype.precompute = function() { + }, s.prototype._encode = function() { + return this.getX().toArray("be", this.curve.p.byteLength()); + }, s.fromJSON = function(a, f) { + return new s(a, f[0], f[1] || a.one); + }, s.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, s.prototype.isInfinity = function() { + return this.z.cmpn(0) === 0; + }, s.prototype.dbl = function() { + var a = this.x.redAdd(this.z), f = a.redSqr(), u = this.x.redSub(this.z), h = u.redSqr(), g = f.redSub(h), v = f.redMul(h), x = g.redMul(h.redAdd(this.curve.a24.redMul(g))); + return this.curve.point(v, x); + }, s.prototype.add = function() { + throw new Error("Not supported on Montgomery curve"); + }, s.prototype.diffAdd = function(a, f) { + var u = this.x.redAdd(this.z), h = this.x.redSub(this.z), g = a.x.redAdd(a.z), v = a.x.redSub(a.z), x = v.redMul(u), S = g.redMul(h), R = f.z.redMul(x.redAdd(S).redSqr()), D = f.x.redMul(x.redISub(S).redSqr()); + return this.curve.point(R, D); + }, s.prototype.mul = function(a) { + for (var f = a.clone(), u = this, h = this.curve.point(null, null), g = this, v = []; f.cmpn(0) !== 0; f.iushrn(1)) + v.push(f.andln(1)); + for (var x = v.length - 1; x >= 0; x--) + v[x] === 0 ? (u = u.diffAdd(h, g), h = h.dbl()) : (h = u.diffAdd(h, g), u = u.dbl()); + return h; + }, s.prototype.mulAdd = function() { + throw new Error("Not supported on Montgomery curve"); + }, s.prototype.jumlAdd = function() { + throw new Error("Not supported on Montgomery curve"); + }, s.prototype.eq = function(a) { + return this.getX().cmp(a.getX()) === 0; + }, s.prototype.normalize = function() { + return this.x = this.x.redMul(this.z.redInvm()), this.z = this.curve.one, this; + }, s.prototype.getX = function() { + return this.normalize(), this.x.fromRed(); + }, kg; +} +var $g, Lx; +function fF() { + if (Lx) return $g; + Lx = 1; + var t = Gi(), e = go(), r = Jd(), n = t0(), i = t.assert; + function s(a) { + this.twisted = (a.a | 0) !== 1, this.mOneA = this.twisted && (a.a | 0) === -1, this.extended = this.mOneA, n.call(this, "edwards", a), this.a = new e(a.a, 16).umod(this.red.m), this.a = this.a.toRed(this.red), this.c = new e(a.c, 16).toRed(this.red), this.c2 = this.c.redSqr(), this.d = new e(a.d, 16).toRed(this.red), this.dd = this.d.redAdd(this.d), i(!this.twisted || this.c.fromRed().cmpn(1) === 0), this.oneC = (a.c | 0) === 1; + } + r(s, n), $g = s, s.prototype._mulA = function(f) { + return this.mOneA ? f.redNeg() : this.a.redMul(f); + }, s.prototype._mulC = function(f) { + return this.oneC ? f : this.c.redMul(f); + }, s.prototype.jpoint = function(f, u, h, g) { + return this.point(f, u, h, g); + }, s.prototype.pointFromX = function(f, u) { + f = new e(f, 16), f.red || (f = f.toRed(this.red)); + var h = f.redSqr(), g = this.c2.redSub(this.a.redMul(h)), v = this.one.redSub(this.c2.redMul(this.d).redMul(h)), x = g.redMul(v.redInvm()), S = x.redSqrt(); + if (S.redSqr().redSub(x).cmp(this.zero) !== 0) + throw new Error("invalid point"); + var R = S.fromRed().isOdd(); + return (u && !R || !u && R) && (S = S.redNeg()), this.point(f, S); + }, s.prototype.pointFromY = function(f, u) { + f = new e(f, 16), f.red || (f = f.toRed(this.red)); + var h = f.redSqr(), g = h.redSub(this.c2), v = h.redMul(this.d).redMul(this.c2).redSub(this.a), x = g.redMul(v.redInvm()); + if (x.cmp(this.zero) === 0) { + if (u) + throw new Error("invalid point"); + return this.point(this.zero, f); + } + var S = x.redSqrt(); + if (S.redSqr().redSub(x).cmp(this.zero) !== 0) + throw new Error("invalid point"); + return S.fromRed().isOdd() !== u && (S = S.redNeg()), this.point(S, f); + }, s.prototype.validate = function(f) { + if (f.isInfinity()) + return !0; + f.normalize(); + var u = f.x.redSqr(), h = f.y.redSqr(), g = u.redMul(this.a).redAdd(h), v = this.c2.redMul(this.one.redAdd(this.d.redMul(u).redMul(h))); + return g.cmp(v) === 0; + }; + function o(a, f, u, h, g) { + n.BasePoint.call(this, a, "projective"), f === null && u === null && h === 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 e(f, 16), this.y = new e(u, 16), this.z = h ? new e(h, 16) : this.curve.one, this.t = g && new e(g, 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())))); + } + return r(o, n.BasePoint), s.prototype.pointFromJSON = function(f) { + return o.fromJSON(this, f); + }, s.prototype.point = function(f, u, h, g) { + return new o(this, f, u, h, g); + }, o.fromJSON = function(f, u) { + return new o(f, u[0], u[1], u[2]); + }, o.prototype.inspect = function() { + return this.isInfinity() ? "" : ""; + }, o.prototype.isInfinity = function() { + return this.x.cmpn(0) === 0 && (this.y.cmp(this.z) === 0 || this.zOne && this.y.cmp(this.curve.c) === 0); + }, o.prototype._extDbl = function() { + var f = this.x.redSqr(), u = this.y.redSqr(), h = this.z.redSqr(); + h = h.redIAdd(h); + var g = this.curve._mulA(f), v = this.x.redAdd(this.y).redSqr().redISub(f).redISub(u), x = g.redAdd(u), S = x.redSub(h), R = g.redSub(u), D = v.redMul(S), k = x.redMul(R), N = v.redMul(R), z = S.redMul(x); + return this.curve.point(D, k, z, N); + }, o.prototype._projDbl = function() { + var f = this.x.redAdd(this.y).redSqr(), u = this.x.redSqr(), h = this.y.redSqr(), g, v, x, S, R, D; + if (this.curve.twisted) { + S = this.curve._mulA(u); + var k = S.redAdd(h); + this.zOne ? (g = f.redSub(u).redSub(h).redMul(k.redSub(this.curve.two)), v = k.redMul(S.redSub(h)), x = k.redSqr().redSub(k).redSub(k)) : (R = this.z.redSqr(), D = k.redSub(R).redISub(R), g = f.redSub(u).redISub(h).redMul(D), v = k.redMul(S.redSub(h)), x = k.redMul(D)); + } else + S = u.redAdd(h), R = this.curve._mulC(this.z).redSqr(), D = S.redSub(R).redSub(R), g = this.curve._mulC(f.redISub(S)).redMul(D), v = this.curve._mulC(S).redMul(u.redISub(h)), x = S.redMul(D); + return this.curve.point(g, v, x); + }, o.prototype.dbl = function() { + return this.isInfinity() ? this : this.curve.extended ? this._extDbl() : this._projDbl(); + }, o.prototype._extAdd = function(f) { + var u = this.y.redSub(this.x).redMul(f.y.redSub(f.x)), h = this.y.redAdd(this.x).redMul(f.y.redAdd(f.x)), g = this.t.redMul(this.curve.dd).redMul(f.t), v = this.z.redMul(f.z.redAdd(f.z)), x = h.redSub(u), S = v.redSub(g), R = v.redAdd(g), D = h.redAdd(u), k = x.redMul(S), N = R.redMul(D), z = x.redMul(D), B = S.redMul(R); + return this.curve.point(k, N, B, z); + }, o.prototype._projAdd = function(f) { + var u = this.z.redMul(f.z), h = u.redSqr(), g = this.x.redMul(f.x), v = this.y.redMul(f.y), x = this.curve.d.redMul(g).redMul(v), S = h.redSub(x), R = h.redAdd(x), D = this.x.redAdd(this.y).redMul(f.x.redAdd(f.y)).redISub(g).redISub(v), k = u.redMul(S).redMul(D), N, z; + return this.curve.twisted ? (N = u.redMul(R).redMul(v.redSub(this.curve._mulA(g))), z = S.redMul(R)) : (N = u.redMul(R).redMul(v.redSub(g)), z = this.curve._mulC(S).redMul(R)), this.curve.point(k, N, z); + }, o.prototype.add = function(f) { + return this.isInfinity() ? f : f.isInfinity() ? this : this.curve.extended ? this._extAdd(f) : this._projAdd(f); + }, o.prototype.mul = function(f) { + return this._hasDoubles(f) ? this.curve._fixedNafMul(this, f) : this.curve._wnafMul(this, f); + }, o.prototype.mulAdd = function(f, u, h) { + return this.curve._wnafMulAdd(1, [this, u], [f, h], 2, !1); + }, o.prototype.jmulAdd = function(f, u, h) { + return this.curve._wnafMulAdd(1, [this, u], [f, h], 2, !0); + }, o.prototype.normalize = function() { + if (this.zOne) + return this; + var f = this.z.redInvm(); + return this.x = this.x.redMul(f), this.y = this.y.redMul(f), this.t && (this.t = this.t.redMul(f)), this.z = this.curve.one, this.zOne = !0, this; + }, o.prototype.neg = function() { + return this.curve.point( + this.x.redNeg(), + this.y, + this.z, + this.t && this.t.redNeg() + ); + }, o.prototype.getX = function() { + return this.normalize(), this.x.fromRed(); + }, o.prototype.getY = function() { + return this.normalize(), this.y.fromRed(); + }, o.prototype.eq = function(f) { + return this === f || this.getX().cmp(f.getX()) === 0 && this.getY().cmp(f.getY()) === 0; + }, o.prototype.eqXToP = function(f) { + var u = f.toRed(this.curve.red).redMul(this.z); + if (this.x.cmp(u) === 0) + return !0; + for (var h = f.clone(), g = this.curve.redN.redMul(this.z); ; ) { + if (h.iadd(this.curve.n), h.cmp(this.curve.p) >= 0) + return !1; + if (u.redIAdd(g), this.x.cmp(u) === 0) + return !0; + } + }, o.prototype.toP = o.prototype.normalize, o.prototype.mixedAdd = o.prototype.add, $g; +} +var kx; +function _8() { + return kx || (kx = 1, (function(t) { + var e = t; + e.base = t0(), e.short = cF(), e.mont = uF(), e.edwards = fF(); + })(Og)), Og; +} +var Bg = {}, Fg, $x; +function lF() { + return $x || ($x = 1, Fg = { + 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" + ] + ] + } + }), Fg; +} +var Bx; +function x1() { + return Bx || (Bx = 1, (function(t) { + var e = t, r = Xd(), n = _8(), i = Gi(), s = i.assert; + function o(u) { + u.type === "short" ? this.curve = new n.short(u) : u.type === "edwards" ? this.curve = new n.edwards(u) : this.curve = new n.mont(u), this.g = this.curve.g, this.n = this.curve.n, this.hash = u.hash, s(this.g.validate(), "Invalid curve"), s(this.g.mul(this.n).isInfinity(), "Invalid curve, G*N != O"); + } + e.PresetCurve = o; + function a(u, h) { + Object.defineProperty(e, u, { + configurable: !0, + enumerable: !0, + get: function() { + var g = new o(h); + return Object.defineProperty(e, u, { + configurable: !0, + enumerable: !0, + value: g + }), g; + } + }); + } + a("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.sha256, + gRed: !1, + g: [ + "188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012", + "07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811" + ] + }), a("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.sha256, + gRed: !1, + g: [ + "b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21", + "bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34" + ] + }), a("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.sha256, + gRed: !1, + g: [ + "6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296", + "4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5" + ] + }), a("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.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" + ] + }), a("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.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" + ] + }), a("curve25519", { + type: "mont", + prime: "p25519", + p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", + a: "76d06", + b: "1", + n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", + hash: r.sha256, + gRed: !1, + g: [ + "9" + ] + }), a("ed25519", { + type: "edwards", + prime: "p25519", + p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", + a: "-1", + c: "1", + // -121665 * (121666^(-1)) (mod P) + d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", + n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", + hash: r.sha256, + gRed: !1, + g: [ + "216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", + // 4/5 + "6666666666666666666666666666666666666666666666666666666666666658" + ] + }); + var f; + try { + f = lF(); + } catch { + f = void 0; + } + a("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.sha256, + // Precomputed endomorphism + beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", + lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", + basis: [ + { + a: "3086d221a7d46bcde86c90e49284eb15", + b: "-e4437ed6010e88286f547fa90abfe4c3" + }, + { + a: "114ca50f7a8e2f3f657c1108d9d44cfd8", + b: "3086d221a7d46bcde86c90e49284eb15" + } + ], + gRed: !1, + g: [ + "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", + "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8", + f + ] + }); + })(Bg)), Bg; +} +var jg, Fx; +function hF() { + if (Fx) return jg; + Fx = 1; + var t = Xd(), e = w8(), r = Wa(); + function n(i) { + if (!(this instanceof n)) + return new n(i); + this.hash = i.hash, this.predResist = !!i.predResist, this.outLen = this.hash.outSize, this.minEntropy = i.minEntropy || this.hash.hmacStrength, this._reseed = null, this.reseedInterval = null, this.K = null, this.V = null; + var s = e.toArray(i.entropy, i.entropyEnc || "hex"), o = e.toArray(i.nonce, i.nonceEnc || "hex"), a = e.toArray(i.pers, i.persEnc || "hex"); + r( + s.length >= this.minEntropy / 8, + "Not enough entropy. Minimum is: " + this.minEntropy + " bits" + ), this._init(s, o, a); + } + return jg = n, n.prototype._init = function(s, o, a) { + var f = s.concat(o).concat(a); + this.K = new Array(this.outLen / 8), this.V = new Array(this.outLen / 8); + for (var u = 0; u < this.V.length; u++) + this.K[u] = 0, this.V[u] = 1; + this._update(f), this._reseed = 1, this.reseedInterval = 281474976710656; + }, n.prototype._hmac = function() { + return new t.hmac(this.hash, this.K); + }, n.prototype._update = function(s) { + var o = this._hmac().update(this.V).update([0]); + s && (o = o.update(s)), this.K = o.digest(), this.V = this._hmac().update(this.V).digest(), s && (this.K = this._hmac().update(this.V).update([1]).update(s).digest(), this.V = this._hmac().update(this.V).digest()); + }, n.prototype.reseed = function(s, o, a, f) { + typeof o != "string" && (f = a, a = o, o = null), s = e.toArray(s, o), a = e.toArray(a, f), r( + s.length >= this.minEntropy / 8, + "Not enough entropy. Minimum is: " + this.minEntropy + " bits" + ), this._update(s.concat(a || [])), this._reseed = 1; + }, n.prototype.generate = function(s, o, a, f) { + if (this._reseed > this.reseedInterval) + throw new Error("Reseed is required"); + typeof o != "string" && (f = a, a = o, o = null), a && (a = e.toArray(a, f || "hex"), this._update(a)); + for (var u = []; u.length < s; ) + this.V = this._hmac().update(this.V).digest(), u = u.concat(this.V); + var h = u.slice(0, s); + return this._update(a), this._reseed++, e.encode(h, o); + }, jg; +} +var Ug, jx; +function dF() { + if (jx) return Ug; + jx = 1; + var t = go(), e = Gi(), r = e.assert; + function n(i, s) { + this.ec = i, this.priv = null, this.pub = null, s.priv && this._importPrivate(s.priv, s.privEnc), s.pub && this._importPublic(s.pub, s.pubEnc); + } + return Ug = n, n.fromPublic = function(s, o, a) { + return o instanceof n ? o : new n(s, { + pub: o, + pubEnc: a + }); + }, n.fromPrivate = function(s, o, a) { + return o instanceof n ? o : new n(s, { + priv: o, + privEnc: a + }); + }, n.prototype.validate = function() { + var s = this.getPublic(); + return s.isInfinity() ? { result: !1, reason: "Invalid public key" } : s.validate() ? s.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" }; + }, n.prototype.getPublic = function(s, o) { + return typeof s == "string" && (o = s, s = null), this.pub || (this.pub = this.ec.g.mul(this.priv)), o ? this.pub.encode(o, s) : this.pub; + }, n.prototype.getPrivate = function(s) { + return s === "hex" ? this.priv.toString(16, 2) : this.priv; + }, n.prototype._importPrivate = function(s, o) { + this.priv = new t(s, o || 16), this.priv = this.priv.umod(this.ec.curve.n); + }, n.prototype._importPublic = function(s, o) { + if (s.x || s.y) { + this.ec.curve.type === "mont" ? r(s.x, "Need x coordinate") : (this.ec.curve.type === "short" || this.ec.curve.type === "edwards") && r(s.x && s.y, "Need both x and y coordinate"), this.pub = this.ec.curve.point(s.x, s.y); + return; + } + this.pub = this.ec.curve.decodePoint(s, o); + }, n.prototype.derive = function(s) { + return s.validate() || r(s.validate(), "public point not validated"), s.mul(this.priv).getX(); + }, n.prototype.sign = function(s, o, a) { + return this.ec.sign(s, this, o, a); + }, n.prototype.verify = function(s, o, a) { + return this.ec.verify(s, o, this, void 0, a); + }, n.prototype.inspect = function() { + return ""; + }, Ug; +} +var qg, Ux; +function pF() { + if (Ux) return qg; + Ux = 1; + var t = go(), e = Gi(), r = e.assert; + function n(f, u) { + if (f instanceof n) + return f; + this._importDER(f, u) || (r(f.r && f.s, "Signature without r or s"), this.r = new t(f.r, 16), this.s = new t(f.s, 16), f.recoveryParam === void 0 ? this.recoveryParam = null : this.recoveryParam = f.recoveryParam); + } + qg = n; + function i() { + this.place = 0; + } + function s(f, u) { + var h = f[u.place++]; + if (!(h & 128)) + return h; + var g = h & 15; + if (g === 0 || g > 4 || f[u.place] === 0) + return !1; + for (var v = 0, x = 0, S = u.place; x < g; x++, S++) + v <<= 8, v |= f[S], v >>>= 0; + return v <= 127 ? !1 : (u.place = S, v); + } + function o(f) { + for (var u = 0, h = f.length - 1; !f[u] && !(f[u + 1] & 128) && u < h; ) + u++; + return u === 0 ? f : f.slice(u); + } + n.prototype._importDER = function(u, h) { + u = e.toArray(u, h); + var g = new i(); + if (u[g.place++] !== 48) + return !1; + var v = s(u, g); + if (v === !1 || v + g.place !== u.length || u[g.place++] !== 2) + return !1; + var x = s(u, g); + if (x === !1 || (u[g.place] & 128) !== 0) + return !1; + var S = u.slice(g.place, x + g.place); + if (g.place += x, u[g.place++] !== 2) + return !1; + var R = s(u, g); + if (R === !1 || u.length !== R + g.place || (u[g.place] & 128) !== 0) + return !1; + var D = u.slice(g.place, R + g.place); + if (S[0] === 0) + if (S[1] & 128) + S = S.slice(1); + else + return !1; + if (D[0] === 0) + if (D[1] & 128) + D = D.slice(1); + else + return !1; + return this.r = new t(S), this.s = new t(D), this.recoveryParam = null, !0; + }; + function a(f, u) { + if (u < 128) { + f.push(u); + return; + } + var h = 1 + (Math.log(u) / Math.LN2 >>> 3); + for (f.push(h | 128); --h; ) + f.push(u >>> (h << 3) & 255); + f.push(u); + } + return n.prototype.toDER = function(u) { + var h = this.r.toArray(), g = this.s.toArray(); + for (h[0] & 128 && (h = [0].concat(h)), g[0] & 128 && (g = [0].concat(g)), h = o(h), g = o(g); !g[0] && !(g[1] & 128); ) + g = g.slice(1); + var v = [2]; + a(v, h.length), v = v.concat(h), v.push(2), a(v, g.length); + var x = v.concat(g), S = [48]; + return a(S, x.length), S = S.concat(x), e.encode(S, u); + }, qg; +} +var zg, qx; +function gF() { + if (qx) return zg; + qx = 1; + var t = go(), e = hF(), r = Gi(), n = x1(), i = x8(), s = r.assert, o = dF(), a = pF(); + function f(u) { + if (!(this instanceof f)) + return new f(u); + typeof u == "string" && (s( + Object.prototype.hasOwnProperty.call(n, u), + "Unknown curve " + u + ), u = n[u]), u instanceof n.PresetCurve && (u = { curve: u }), this.curve = u.curve.curve, this.n = this.curve.n, this.nh = this.n.ushrn(1), this.g = this.curve.g, this.g = u.curve.g, this.g.precompute(u.curve.n.bitLength() + 1), this.hash = u.hash || u.curve.hash; + } + return zg = f, f.prototype.keyPair = function(h) { + return new o(this, h); + }, f.prototype.keyFromPrivate = function(h, g) { + return o.fromPrivate(this, h, g); + }, f.prototype.keyFromPublic = function(h, g) { + return o.fromPublic(this, h, g); + }, f.prototype.genKeyPair = function(h) { + h || (h = {}); + for (var g = new e({ + hash: this.hash, + pers: h.pers, + persEnc: h.persEnc || "utf8", + entropy: h.entropy || i(this.hash.hmacStrength), + entropyEnc: h.entropy && h.entropyEnc || "utf8", + nonce: this.n.toArray() + }), v = this.n.byteLength(), x = this.n.sub(new t(2)); ; ) { + var S = new t(g.generate(v)); + if (!(S.cmp(x) > 0)) + return S.iaddn(1), this.keyFromPrivate(S); + } + }, f.prototype._truncateToN = function(h, g, v) { + var x; + if (t.isBN(h) || typeof h == "number") + h = new t(h, 16), x = h.byteLength(); + else if (typeof h == "object") + x = h.length, h = new t(h, 16); + else { + var S = h.toString(); + x = S.length + 1 >>> 1, h = new t(S, 16); + } + typeof v != "number" && (v = x * 8); + var R = v - this.n.bitLength(); + return R > 0 && (h = h.ushrn(R)), !g && h.cmp(this.n) >= 0 ? h.sub(this.n) : h; + }, f.prototype.sign = function(h, g, v, x) { + typeof v == "object" && (x = v, v = null), x || (x = {}), g = this.keyFromPrivate(g, v), h = this._truncateToN(h, !1, x.msgBitLength); + for (var S = this.n.byteLength(), R = g.getPrivate().toArray("be", S), D = h.toArray("be", S), k = new e({ + hash: this.hash, + entropy: R, + nonce: D, + pers: x.pers, + persEnc: x.persEnc || "utf8" + }), N = this.n.sub(new t(1)), z = 0; ; z++) { + var B = x.k ? x.k(z) : new t(k.generate(this.n.byteLength())); + if (B = this._truncateToN(B, !0), !(B.cmpn(1) <= 0 || B.cmp(N) >= 0)) { + var $ = this.g.mul(B); + if (!$.isInfinity()) { + var U = $.getX(), C = U.umod(this.n); + if (C.cmpn(0) !== 0) { + var W = B.invm(this.n).mul(C.mul(g.getPrivate()).iadd(h)); + if (W = W.umod(this.n), W.cmpn(0) !== 0) { + var J = ($.getY().isOdd() ? 1 : 0) | (U.cmp(C) !== 0 ? 2 : 0); + return x.canonical && W.cmp(this.nh) > 0 && (W = this.n.sub(W), J ^= 1), new a({ r: C, s: W, recoveryParam: J }); + } + } + } + } + } + }, f.prototype.verify = function(h, g, v, x, S) { + S || (S = {}), h = this._truncateToN(h, !1, S.msgBitLength), v = this.keyFromPublic(v, x), g = new a(g, "hex"); + var R = g.r, D = g.s; + if (R.cmpn(1) < 0 || R.cmp(this.n) >= 0 || D.cmpn(1) < 0 || D.cmp(this.n) >= 0) + return !1; + var k = D.invm(this.n), N = k.mul(h).umod(this.n), z = k.mul(R).umod(this.n), B; + return this.curve._maxwellTrick ? (B = this.g.jmulAdd(N, v.getPublic(), z), B.isInfinity() ? !1 : B.eqXToP(R)) : (B = this.g.mulAdd(N, v.getPublic(), z), B.isInfinity() ? !1 : B.getX().umod(this.n).cmp(R) === 0); + }, f.prototype.recoverPubKey = function(u, h, g, v) { + s((3 & g) === g, "The recovery param is more than two bits"), h = new a(h, v); + var x = this.n, S = new t(u), R = h.r, D = h.s, k = g & 1, N = g >> 1; + if (R.cmp(this.curve.p.umod(this.curve.n)) >= 0 && N) + throw new Error("Unable to find sencond key candinate"); + N ? R = this.curve.pointFromX(R.add(this.curve.n), k) : R = this.curve.pointFromX(R, k); + var z = h.r.invm(x), B = x.sub(S).mul(z).umod(x), $ = D.mul(z).umod(x); + return this.g.mulAdd(B, R, $); + }, f.prototype.getKeyRecoveryParam = function(u, h, g, v) { + if (h = new a(h, v), h.recoveryParam !== null) + return h.recoveryParam; + for (var x = 0; x < 4; x++) { + var S; + try { + S = this.recoverPubKey(u, h, x); + } catch { + continue; + } + if (S.eq(g)) + return x; + } + throw new Error("Unable to find valid recovery factor"); + }, zg; +} +var Hg, zx; +function mF() { + if (zx) return Hg; + zx = 1; + var t = Gi(), e = t.assert, r = t.parseBytes, n = t.cachedProperty; + function i(s, o) { + this.eddsa = s, this._secret = r(o.secret), s.isPoint(o.pub) ? this._pub = o.pub : this._pubBytes = r(o.pub); + } + return i.fromPublic = function(o, a) { + return a instanceof i ? a : new i(o, { pub: a }); + }, i.fromSecret = function(o, a) { + return a instanceof i ? a : new i(o, { secret: a }); + }, i.prototype.secret = function() { + return this._secret; + }, n(i, "pubBytes", function() { + return this.eddsa.encodePoint(this.pub()); + }), n(i, "pub", function() { + return this._pubBytes ? this.eddsa.decodePoint(this._pubBytes) : this.eddsa.g.mul(this.priv()); + }), n(i, "privBytes", function() { + var o = this.eddsa, a = this.hash(), f = o.encodingLength - 1, u = a.slice(0, o.encodingLength); + return u[0] &= 248, u[f] &= 127, u[f] |= 64, u; + }), n(i, "priv", function() { + return this.eddsa.decodeInt(this.privBytes()); + }), n(i, "hash", function() { + return this.eddsa.hash().update(this.secret()).digest(); + }), n(i, "messagePrefix", function() { + return this.hash().slice(this.eddsa.encodingLength); + }), i.prototype.sign = function(o) { + return e(this._secret, "KeyPair can only verify"), this.eddsa.sign(o, this); + }, i.prototype.verify = function(o, a) { + return this.eddsa.verify(o, a, this); + }, i.prototype.getSecret = function(o) { + return e(this._secret, "KeyPair is public only"), t.encode(this.secret(), o); + }, i.prototype.getPublic = function(o) { + return t.encode(this.pubBytes(), o); + }, Hg = i, Hg; +} +var Wg, Hx; +function vF() { + if (Hx) return Wg; + Hx = 1; + var t = go(), e = Gi(), r = e.assert, n = e.cachedProperty, i = e.parseBytes; + function s(o, a) { + this.eddsa = o, typeof a != "object" && (a = i(a)), Array.isArray(a) && (r(a.length === o.encodingLength * 2, "Signature has invalid size"), a = { + R: a.slice(0, o.encodingLength), + S: a.slice(o.encodingLength) + }), r(a.R && a.S, "Signature without R or S"), o.isPoint(a.R) && (this._R = a.R), a.S instanceof t && (this._S = a.S), this._Rencoded = Array.isArray(a.R) ? a.R : a.Rencoded, this._Sencoded = Array.isArray(a.S) ? a.S : a.Sencoded; + } + return n(s, "S", function() { + return this.eddsa.decodeInt(this.Sencoded()); + }), n(s, "R", function() { + return this.eddsa.decodePoint(this.Rencoded()); + }), n(s, "Rencoded", function() { + return this.eddsa.encodePoint(this.R()); + }), n(s, "Sencoded", function() { + return this.eddsa.encodeInt(this.S()); + }), s.prototype.toBytes = function() { + return this.Rencoded().concat(this.Sencoded()); + }, s.prototype.toHex = function() { + return e.encode(this.toBytes(), "hex").toUpperCase(); + }, Wg = s, Wg; +} +var Kg, Wx; +function bF() { + if (Wx) return Kg; + Wx = 1; + var t = Xd(), e = x1(), r = Gi(), n = r.assert, i = r.parseBytes, s = mF(), o = vF(); + function a(f) { + if (n(f === "ed25519", "only tested with ed25519 so far"), !(this instanceof a)) + return new a(f); + f = e[f].curve, this.curve = f, this.g = f.g, this.g.precompute(f.n.bitLength() + 1), this.pointClass = f.point().constructor, this.encodingLength = Math.ceil(f.n.bitLength() / 8), this.hash = t.sha512; + } + return Kg = a, a.prototype.sign = function(u, h) { + u = i(u); + var g = this.keyFromSecret(h), v = this.hashInt(g.messagePrefix(), u), x = this.g.mul(v), S = this.encodePoint(x), R = this.hashInt(S, g.pubBytes(), u).mul(g.priv()), D = v.add(R).umod(this.curve.n); + return this.makeSignature({ R: x, S: D, Rencoded: S }); + }, a.prototype.verify = function(u, h, g) { + if (u = i(u), h = this.makeSignature(h), h.S().gte(h.eddsa.curve.n) || h.S().isNeg()) + return !1; + var v = this.keyFromPublic(g), x = this.hashInt(h.Rencoded(), v.pubBytes(), u), S = this.g.mul(h.S()), R = h.R().add(v.pub().mul(x)); + return R.eq(S); + }, a.prototype.hashInt = function() { + for (var u = this.hash(), h = 0; h < arguments.length; h++) + u.update(arguments[h]); + return r.intFromLE(u.digest()).umod(this.curve.n); + }, a.prototype.keyFromPublic = function(u) { + return s.fromPublic(this, u); + }, a.prototype.keyFromSecret = function(u) { + return s.fromSecret(this, u); + }, a.prototype.makeSignature = function(u) { + return u instanceof o ? u : new o(this, u); + }, a.prototype.encodePoint = function(u) { + var h = u.getY().toArray("le", this.encodingLength); + return h[this.encodingLength - 1] |= u.getX().isOdd() ? 128 : 0, h; + }, a.prototype.decodePoint = function(u) { + u = r.parseBytes(u); + var h = u.length - 1, g = u.slice(0, h).concat(u[h] & -129), v = (u[h] & 128) !== 0, x = r.intFromLE(g); + return this.curve.pointFromY(x, v); + }, a.prototype.encodeInt = function(u) { + return u.toArray("le", this.encodingLength); + }, a.prototype.decodeInt = function(u) { + return r.intFromLE(u); + }, a.prototype.isPoint = function(u) { + return u instanceof this.pointClass; + }, Kg; +} +var Kx; +function yF() { + return Kx || (Kx = 1, (function(t) { + var e = t; + e.version = oF.version, e.utils = Gi(), e.rand = x8(), e.curve = _8(), e.curves = x1(), e.ec = gF(), e.eddsa = bF(); + })(Rg)), Rg; +} +var wF = yF(); +const xF = { 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" } }, _F = ":"; +function Nc(t) { + const [e, r] = t.split(_F); + return { namespace: e, reference: r }; +} +function E8(t, e) { + return t.includes(":") ? [t] : e.chains || []; +} +var EF = Object.defineProperty, Vx = Object.getOwnPropertySymbols, SF = Object.prototype.hasOwnProperty, AF = Object.prototype.propertyIsEnumerable, Gx = (t, e, r) => e in t ? EF(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Yx = (t, e) => { + for (var r in e || (e = {})) SF.call(e, r) && Gx(t, r, e[r]); + if (Vx) for (var r of Vx(e)) AF.call(e, r) && Gx(t, r, e[r]); + return t; +}; +const PF = "ReactNative", Ei = { reactNative: "react-native", node: "node", browser: "browser", unknown: "unknown" }, MF = "js"; +function xd() { + return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; +} +function Yc() { + return !La.getDocument() && !!La.getNavigator() && navigator.product === PF; +} +function il() { + return !xd() && !!La.getNavigator() && !!La.getDocument(); +} +function sl() { + return Yc() ? Ei.reactNative : xd() ? Ei.node : il() ? Ei.browser : Ei.unknown; +} +function IF() { + var t; + try { + return Yc() && typeof global < "u" && typeof (global == null ? void 0 : global.Application) < "u" ? (t = global.Application) == null ? void 0 : t.applicationId : void 0; + } catch { + return; + } +} +function CF(t, e) { + let r = vd.parse(t); + return r = Yx(Yx({}, r), e), t = vd.stringify(r), t; +} +function S8() { + return Q$.getWindowMetadata() || { name: "", description: "", url: "", icons: [""] }; +} +function RF() { + if (sl() === Ei.reactNative && typeof global < "u" && typeof (global == null ? void 0 : global.Platform) < "u") { + const { OS: r, Version: n } = global.Platform; + return [r, n].join("-"); + } + const t = K$(); + if (t === null) return "unknown"; + const e = t.os ? t.os.replace(" ", "").toLowerCase() : "unknown"; + return t.type === "browser" ? [e, t.name, t.version].join("-") : [e, t.version].join("-"); +} +function TF() { + var t; + const e = sl(); + return e === Ei.browser ? [e, ((t = La.getLocation()) == null ? void 0 : t.host) || "unknown"].join(":") : e; +} +function A8(t, e, r) { + const n = RF(), i = TF(); + return [[t, e].join("-"), [MF, r].join("-"), n, i].join("/"); +} +function DF({ protocol: t, version: e, relayUrl: r, sdkVersion: n, auth: i, projectId: s, useOnCloseEvent: o, bundleId: a }) { + const f = r.split("?"), u = A8(t, e, n), h = { auth: i, ua: u, projectId: s, useOnCloseEvent: o, origin: a || void 0 }, g = CF(f[1] || "", h); + return f[0] + "?" + g; +} +function Pa(t, e) { + return t.filter((r) => e.includes(r)).length === t.length; +} +function P8(t) { + return Object.fromEntries(t.entries()); +} +function M8(t) { + return new Map(Object.entries(t)); +} +function ba(t = bt.FIVE_MINUTES, e) { + const r = bt.toMiliseconds(t || bt.FIVE_MINUTES); + let n, i, s; + return { resolve: (o) => { + s && n && (clearTimeout(s), n(o)); + }, reject: (o) => { + s && i && (clearTimeout(s), i(o)); + }, done: () => new Promise((o, a) => { + s = setTimeout(() => { + a(new Error(e)); + }, r), n = o, i = a; + }) }; +} +function Lc(t, e, r) { + return new Promise(async (n, i) => { + const s = setTimeout(() => i(new Error(r)), e); + try { + const o = await t; + n(o); + } catch (o) { + i(o); + } + clearTimeout(s); + }); +} +function I8(t, e) { + if (typeof e == "string" && e.startsWith(`${t}:`)) return e; + if (t.toLowerCase() === "topic") { + if (typeof e != "string") throw new Error('Value must be "string" for expirer target type: topic'); + return `topic:${e}`; + } else if (t.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: ${t}`); +} +function OF(t) { + return I8("topic", t); +} +function NF(t) { + return I8("id", t); +} +function C8(t) { + const [e, r] = t.split(":"), n = { id: void 0, topic: void 0 }; + if (e === "topic" && typeof r == "string") n.topic = r; + else if (e === "id" && Number.isInteger(Number(r))) n.id = Number(r); + else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`); + return n; +} +function _n(t, e) { + return bt.fromMiliseconds(Date.now() + bt.toMiliseconds(t)); +} +function Oo(t) { + return Date.now() >= bt.toMiliseconds(t); +} +function wr(t, e) { + return `${t}${e ? `:${e}` : ""}`; +} +function zh(t = [], e = []) { + return [.../* @__PURE__ */ new Set([...t, ...e])]; +} +async function LF({ id: t, topic: e, wcDeepLink: r }) { + var n; + try { + if (!r) return; + const i = typeof r == "string" ? JSON.parse(r) : r, s = i?.href; + if (typeof s != "string") return; + const o = kF(s, t, e), a = sl(); + if (a === Ei.browser) { + if (!((n = La.getDocument()) != null && n.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, BF() ? "_blank" : "_self", "noreferrer noopener"); + } else a === Ei.reactNative && typeof (global == null ? void 0 : global.Linking) < "u" && await global.Linking.openURL(o); + } catch (i) { + console.error(i); + } +} +function kF(t, e, r) { + const n = `requestId=${e}&sessionTopic=${r}`; + t.endsWith("/") && (t = t.slice(0, -1)); + let i = `${t}`; + if (t.startsWith("https://t.me")) { + const s = t.includes("?") ? "&startapp=" : "?startapp="; + i = `${i}${s}${FF(n, !0)}`; + } else i = `${i}/wc?${n}`; + return i; +} +async function $F(t, e) { + let r = ""; + try { + if (il() && (r = localStorage.getItem(e), r)) return r; + r = await t.getItem(e); + } catch (n) { + console.error(n); + } + return r; +} +function Jx(t, e) { + if (!t.includes(e)) return null; + const r = t.split(/([&,?,=])/), n = r.indexOf(e); + return r[n + 2]; +} +function Xx() { + return typeof crypto < "u" && crypto != null && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu, (t) => { + const e = Math.random() * 16 | 0; + return (t === "x" ? e : e & 3 | 8).toString(16); + }); +} +function _1() { + return typeof process < "u" && process.env.IS_VITEST === "true"; +} +function BF() { + return typeof window < "u" && (!!window.TelegramWebviewProxy || !!window.Telegram || !!window.TelegramWebviewProxyProto); +} +function FF(t, e = !1) { + const r = Buffer.from(t).toString("base64"); + return e ? r.replace(/[=]/g, "") : r; +} +function R8(t) { + return Buffer.from(t, "base64").toString("utf-8"); +} +const jF = "https://rpc.walletconnect.org/v1"; +async function UF(t, e, r, n, i, s) { + switch (r.t) { + case "eip191": + return qF(t, e, r.s); + case "eip1271": + return await zF(t, e, r.s, n, i, s); + default: + throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`); + } +} +function qF(t, e, r) { + return YB(f8(e), r).toLowerCase() === t.toLowerCase(); +} +async function zF(t, e, r, n, i, s) { + const o = Nc(n); + if (!o.namespace || !o.reference) throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${n}`); + try { + const a = "0x1626ba7e", f = "0000000000000000000000000000000000000000000000000000000000000040", u = "0000000000000000000000000000000000000000000000000000000000000041", h = r.substring(2), g = f8(e).substring(2), v = a + g + f + u + h, x = await fetch(`${s || jF}/?chainId=${n}&projectId=${i}`, { method: "POST", body: JSON.stringify({ id: HF(), jsonrpc: "2.0", method: "eth_call", params: [{ to: t, data: v }, "latest"] }) }), { result: S } = await x.json(); + return S ? S.slice(0, a.length).toLowerCase() === a.toLowerCase() : !1; + } catch (a) { + return console.error("isValidEip1271Signature: ", a), !1; + } +} +function HF() { + return Date.now() + Math.floor(Math.random() * 1e3); +} +var WF = Object.defineProperty, KF = Object.defineProperties, VF = Object.getOwnPropertyDescriptors, Zx = Object.getOwnPropertySymbols, GF = Object.prototype.hasOwnProperty, YF = Object.prototype.propertyIsEnumerable, Qx = (t, e, r) => e in t ? WF(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, JF = (t, e) => { + for (var r in e || (e = {})) GF.call(e, r) && Qx(t, r, e[r]); + if (Zx) for (var r of Zx(e)) YF.call(e, r) && Qx(t, r, e[r]); + return t; +}, XF = (t, e) => KF(t, VF(e)); +const ZF = "did:pkh:", E1 = (t) => t?.split(":"), QF = (t) => { + const e = t && E1(t); + if (e) return t.includes(ZF) ? e[3] : e[1]; +}, iv = (t) => { + const e = t && E1(t); + if (e) return e[2] + ":" + e[3]; +}, _d = (t) => { + const e = t && E1(t); + if (e) return e.pop(); +}; +async function e3(t) { + const { cacao: e, projectId: r } = t, { s: n, p: i } = e, s = T8(i, i.iss), o = _d(i.iss); + return await UF(o, s, n, iv(i.iss), r); +} +const T8 = (t, e) => { + const r = `${t.domain} wants you to sign in with your Ethereum account:`, n = _d(e); + if (!t.aud && !t.uri) throw new Error("Either `aud` or `uri` is required to construct the message"); + let i = t.statement || void 0; + const s = `URI: ${t.aud || t.uri}`, o = `Version: ${t.version}`, a = `Chain ID: ${QF(e)}`, f = `Nonce: ${t.nonce}`, u = `Issued At: ${t.iat}`, h = t.exp ? `Expiration Time: ${t.exp}` : void 0, g = t.nbf ? `Not Before: ${t.nbf}` : void 0, v = t.requestId ? `Request ID: ${t.requestId}` : void 0, x = t.resources ? `Resources:${t.resources.map((R) => ` +- ${R}`).join("")}` : void 0, S = Hh(t.resources); + if (S) { + const R = Nf(S); + i = cj(i, R); + } + return [r, n, "", i, "", s, o, a, f, u, h, g, v, x].filter((R) => R != null).join(` +`); +}; +function ej(t) { + return Buffer.from(JSON.stringify(t)).toString("base64"); +} +function tj(t) { + return JSON.parse(Buffer.from(t, "base64").toString("utf-8")); +} +function ka(t) { + if (!t) throw new Error("No recap provided, value is undefined"); + if (!t.att) throw new Error("No `att` property found"); + const e = Object.keys(t.att); + if (!(e != null && e.length)) throw new Error("No resources found in `att` property"); + e.forEach((r) => { + const n = t.att[r]; + if (Array.isArray(n)) throw new Error(`Resource must be an object: ${r}`); + if (typeof n != "object") throw new Error(`Resource must be an object: ${r}`); + if (!Object.keys(n).length) throw new Error(`Resource object is empty: ${r}`); + Object.keys(n).forEach((i) => { + const s = n[i]; + if (!Array.isArray(s)) throw new Error(`Ability limits ${i} must be an array of objects, found: ${s}`); + if (!s.length) throw new Error(`Value of ${i} is empty array, must be an array with objects`); + s.forEach((o) => { + if (typeof o != "object") throw new Error(`Ability limits (${i}) must be an array of objects, found: ${o}`); + }); + }); + }); +} +function rj(t, e, r, n = {}) { + return r?.sort((i, s) => i.localeCompare(s)), { att: { [t]: nj(e, r, n) } }; +} +function nj(t, e, r = {}) { + e = e?.sort((i, s) => i.localeCompare(s)); + const n = e.map((i) => ({ [`${t}/${i}`]: [r] })); + return Object.assign({}, ...n); +} +function D8(t) { + return ka(t), `urn:recap:${ej(t).replace(/=/g, "")}`; +} +function Nf(t) { + const e = tj(t.replace("urn:recap:", "")); + return ka(e), e; +} +function ij(t, e, r) { + const n = rj(t, e, r); + return D8(n); +} +function sj(t) { + return t && t.includes("urn:recap:"); +} +function oj(t, e) { + const r = Nf(t), n = Nf(e), i = aj(r, n); + return D8(i); +} +function aj(t, e) { + ka(t), ka(e); + const r = Object.keys(t.att).concat(Object.keys(e.att)).sort((i, s) => i.localeCompare(s)), n = { att: {} }; + return r.forEach((i) => { + var s, o; + Object.keys(((s = t.att) == null ? void 0 : s[i]) || {}).concat(Object.keys(((o = e.att) == null ? void 0 : o[i]) || {})).sort((a, f) => a.localeCompare(f)).forEach((a) => { + var f, u; + n.att[i] = XF(JF({}, n.att[i]), { [a]: ((f = t.att[i]) == null ? void 0 : f[a]) || ((u = e.att[i]) == null ? void 0 : u[a]) }); + }); + }), n; +} +function cj(t = "", e) { + ka(e); + const r = "I further authorize the stated URI to perform the following actions on my behalf: "; + if (t.includes(r)) return t; + const n = []; + let i = 0; + Object.keys(e.att).forEach((a) => { + const f = Object.keys(e.att[a]).map((g) => ({ ability: g.split("/")[0], action: g.split("/")[1] })); + f.sort((g, v) => g.action.localeCompare(v.action)); + const u = {}; + f.forEach((g) => { + u[g.ability] || (u[g.ability] = []), u[g.ability].push(g.action); + }); + const h = Object.keys(u).map((g) => (i++, `(${i}) '${g}': '${u[g].join("', '")}' for '${a}'.`)); + n.push(h.join(", ").replace(".,", ".")); + }); + const s = n.join(" "), o = `${r}${s}`; + return `${t ? t + " " : ""}${o}`; +} +function t3(t) { + var e; + const r = Nf(t); + ka(r); + const n = (e = r.att) == null ? void 0 : e.eip155; + return n ? Object.keys(n).map((i) => i.split("/")[1]) : []; +} +function r3(t) { + const e = Nf(t); + ka(e); + const r = []; + return Object.values(e.att).forEach((n) => { + Object.values(n).forEach((i) => { + var s; + (s = i?.[0]) != null && s.chains && r.push(i[0].chains); + }); + }), [...new Set(r.flat())]; +} +function Hh(t) { + if (!t) return; + const e = t?.[t.length - 1]; + return sj(e) ? e : void 0; +} +const O8 = "base10", ti = "base16", ko = "base64pad", Ou = "base64url", ol = "utf8", N8 = 0, so = 1, al = 2, uj = 0, n3 = 1, ef = 12, S1 = 32; +function fj() { + const t = y8.generateKeyPair(); + return { privateKey: Tn(t.secretKey, ti), publicKey: Tn(t.publicKey, ti) }; +} +function sv() { + const t = tl.randomBytes(S1); + return Tn(t, ti); +} +function lj(t, e) { + const r = y8.sharedKey(Cn(t, ti), Cn(e, ti), !0), n = new rF.HKDF(e0.SHA256, r).expand(S1); + return Tn(n, ti); +} +function Wh(t) { + const e = e0.hash(Cn(t, ti)); + return Tn(e, ti); +} +function Qs(t) { + const e = e0.hash(Cn(t, ol)); + return Tn(e, ti); +} +function L8(t) { + return Cn(`${t}`, O8); +} +function $a(t) { + return Number(Tn(t, O8)); +} +function hj(t) { + const e = L8(typeof t.type < "u" ? t.type : N8); + if ($a(e) === so && typeof t.senderPublicKey > "u") throw new Error("Missing sender public key for type 1 envelope"); + const r = typeof t.senderPublicKey < "u" ? Cn(t.senderPublicKey, ti) : void 0, n = typeof t.iv < "u" ? Cn(t.iv, ti) : tl.randomBytes(ef), i = new b8.ChaCha20Poly1305(Cn(t.symKey, ti)).seal(n, Cn(t.message, ol)); + return k8({ type: e, sealed: i, iv: n, senderPublicKey: r, encoding: t.encoding }); +} +function dj(t, e) { + const r = L8(al), n = tl.randomBytes(ef), i = Cn(t, ol); + return k8({ type: r, sealed: i, iv: n, encoding: e }); +} +function pj(t) { + const e = new b8.ChaCha20Poly1305(Cn(t.symKey, ti)), { sealed: r, iv: n } = Lf({ encoded: t.encoded, encoding: t?.encoding }), i = e.open(n, r); + if (i === null) throw new Error("Failed to decrypt"); + return Tn(i, ol); +} +function gj(t, e) { + const { sealed: r } = Lf({ encoded: t, encoding: e }); + return Tn(r, ol); +} +function k8(t) { + const { encoding: e = ko } = t; + if ($a(t.type) === al) return Tn($h([t.type, t.sealed]), e); + if ($a(t.type) === so) { + if (typeof t.senderPublicKey > "u") throw new Error("Missing sender public key for type 1 envelope"); + return Tn($h([t.type, t.senderPublicKey, t.iv, t.sealed]), e); + } + return Tn($h([t.type, t.iv, t.sealed]), e); +} +function Lf(t) { + const { encoded: e, encoding: r = ko } = t, n = Cn(e, r), i = n.slice(uj, n3), s = n3; + if ($a(i) === so) { + const u = s + S1, h = u + ef, g = n.slice(s, u), v = n.slice(u, h), x = n.slice(h); + return { type: i, sealed: x, iv: v, senderPublicKey: g }; + } + if ($a(i) === al) { + const u = n.slice(s), h = tl.randomBytes(ef); + return { type: i, sealed: u, iv: h }; + } + const o = s + ef, a = n.slice(s, o), f = n.slice(o); + return { type: i, sealed: f, iv: a }; +} +function mj(t, e) { + const r = Lf({ encoded: t, encoding: e?.encoding }); + return $8({ type: $a(r.type), senderPublicKey: typeof r.senderPublicKey < "u" ? Tn(r.senderPublicKey, ti) : void 0, receiverPublicKey: e?.receiverPublicKey }); +} +function $8(t) { + const e = t?.type || N8; + if (e === so) { + if (typeof t?.senderPublicKey > "u") throw new Error("missing sender public key"); + if (typeof t?.receiverPublicKey > "u") throw new Error("missing receiver public key"); + } + return { type: e, senderPublicKey: t?.senderPublicKey, receiverPublicKey: t?.receiverPublicKey }; +} +function i3(t) { + return t.type === so && typeof t.senderPublicKey == "string" && typeof t.receiverPublicKey == "string"; +} +function s3(t) { + return t.type === al; +} +function vj(t) { + return new wF.ec("p256").keyFromPublic({ x: Buffer.from(t.x, "base64").toString("hex"), y: Buffer.from(t.y, "base64").toString("hex") }, "hex"); +} +function bj(t) { + let e = t.replace(/-/g, "+").replace(/_/g, "/"); + const r = e.length % 4; + return r > 0 && (e += "=".repeat(4 - r)), e; +} +function yj(t) { + return Buffer.from(bj(t), "base64"); +} +function wj(t, e) { + const [r, n, i] = t.split("."), s = yj(i); + if (s.length !== 64) throw new Error("Invalid signature length"); + const o = s.slice(0, 32).toString("hex"), a = s.slice(32, 64).toString("hex"), f = `${r}.${n}`, u = new e0.SHA256().update(Buffer.from(f)).digest(), h = vj(e), g = Buffer.from(u).toString("hex"); + if (!h.verify(g, { r: o, s: a })) throw new Error("Invalid signature"); + return ev(t).payload; +} +const xj = "irn"; +function ov(t) { + return t?.relay || { protocol: xj }; +} +function Vu(t) { + const e = xF[t]; + if (typeof e > "u") throw new Error(`Relay Protocol not supported: ${t}`); + return e; +} +var _j = Object.defineProperty, Ej = Object.defineProperties, Sj = Object.getOwnPropertyDescriptors, o3 = Object.getOwnPropertySymbols, Aj = Object.prototype.hasOwnProperty, Pj = Object.prototype.propertyIsEnumerable, a3 = (t, e, r) => e in t ? _j(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, c3 = (t, e) => { + for (var r in e || (e = {})) Aj.call(e, r) && a3(t, r, e[r]); + if (o3) for (var r of o3(e)) Pj.call(e, r) && a3(t, r, e[r]); + return t; +}, Mj = (t, e) => Ej(t, Sj(e)); +function Ij(t, e = "-") { + const r = {}, n = "relay" + e; + return Object.keys(t).forEach((i) => { + if (i.startsWith(n)) { + const s = i.replace(n, ""), o = t[i]; + r[s] = o; + } + }), r; +} +function u3(t) { + if (!t.includes("wc:")) { + const f = R8(t); + f != null && f.includes("wc:") && (t = f); + } + t = t.includes("wc://") ? t.replace("wc://", "") : t, t = t.includes("wc:") ? t.replace("wc:", "") : t; + const e = t.indexOf(":"), r = t.indexOf("?") !== -1 ? t.indexOf("?") : void 0, n = t.substring(0, e), i = t.substring(e + 1, r).split("@"), s = typeof r < "u" ? t.substring(r) : "", o = vd.parse(s), a = typeof o.methods == "string" ? o.methods.split(",") : void 0; + return { protocol: n, topic: Cj(i[0]), version: parseInt(i[1], 10), symKey: o.symKey, relay: Ij(o), methods: a, expiryTimestamp: o.expiryTimestamp ? parseInt(o.expiryTimestamp, 10) : void 0 }; +} +function Cj(t) { + return t.startsWith("//") ? t.substring(2) : t; +} +function Rj(t, e = "-") { + const r = "relay", n = {}; + return Object.keys(t).forEach((i) => { + const s = r + e + i; + t[i] && (n[s] = t[i]); + }), n; +} +function f3(t) { + return `${t.protocol}:${t.topic}@${t.version}?` + vd.stringify(c3(Mj(c3({ symKey: t.symKey }, Rj(t.relay)), { expiryTimestamp: t.expiryTimestamp }), t.methods ? { methods: t.methods.join(",") } : {})); +} +function Eh(t, e, r) { + return `${t}?wc_ev=${r}&topic=${e}`; +} +function Jc(t) { + const e = []; + return t.forEach((r) => { + const [n, i] = r.split(":"); + e.push(`${n}:${i}`); + }), e; +} +function Tj(t) { + const e = []; + return Object.values(t).forEach((r) => { + e.push(...Jc(r.accounts)); + }), e; +} +function Dj(t, e) { + const r = []; + return Object.values(t).forEach((n) => { + Jc(n.accounts).includes(e) && r.push(...n.methods); + }), r; +} +function Oj(t, e) { + const r = []; + return Object.values(t).forEach((n) => { + Jc(n.accounts).includes(e) && r.push(...n.events); + }), r; +} +function A1(t) { + return t.includes(":"); +} +function Gu(t) { + return A1(t) ? t.split(":")[0] : t; +} +function Nj(t) { + const e = {}; + return t?.forEach((r) => { + const [n, i] = r.split(":"); + e[n] || (e[n] = { accounts: [], chains: [], events: [] }), e[n].accounts.push(r), e[n].chains.push(`${n}:${i}`); + }), e; +} +function l3(t, e) { + e = e.map((n) => n.replace("did:pkh:", "")); + const r = Nj(e); + for (const [n, i] of Object.entries(r)) i.methods ? i.methods = zh(i.methods, t) : i.methods = t, i.events = ["chainChanged", "accountsChanged"]; + return r; +} +const Lj = { 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 } }, kj = { 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 ft(t, e) { + const { message: r, code: n } = kj[t]; + return { message: e ? `${r} ${e}` : r, code: n }; +} +function Nr(t, e) { + const { message: r, code: n } = Lj[t]; + return { message: e ? `${r} ${e}` : r, code: n }; +} +function Ba(t, e) { + return !!Array.isArray(t); +} +function kf(t) { + return Object.getPrototypeOf(t) === Object.prototype && Object.keys(t).length; +} +function ei(t) { + return typeof t > "u"; +} +function hn(t, e) { + return e && ei(t) ? !0 : typeof t == "string" && !!t.trim().length; +} +function P1(t, e) { + return e && ei(t) ? !0 : typeof t == "number" && !isNaN(t); +} +function $j(t, e) { + const { requiredNamespaces: r } = e, n = Object.keys(t.namespaces), i = Object.keys(r); + let s = !0; + return Pa(i, n) ? (n.forEach((o) => { + const { accounts: a, methods: f, events: u } = t.namespaces[o], h = Jc(a), g = r[o]; + (!Pa(E8(o, g), h) || !Pa(g.methods, f) || !Pa(g.events, u)) && (s = !1); + }), s) : !1; +} +function Ed(t) { + return hn(t, !1) && t.includes(":") ? t.split(":").length === 2 : !1; +} +function Bj(t) { + if (hn(t, !1) && t.includes(":")) { + const e = t.split(":"); + if (e.length === 3) { + const r = e[0] + ":" + e[1]; + return !!e[2] && Ed(r); + } + } + return !1; +} +function Fj(t) { + function e(r) { + try { + return typeof new URL(r) < "u"; + } catch { + return !1; + } + } + try { + if (hn(t, !1)) { + if (e(t)) return !0; + const r = R8(t); + return e(r); + } + } catch { + } + return !1; +} +function jj(t) { + var e; + return (e = t?.proposer) == null ? void 0 : e.publicKey; +} +function Uj(t) { + return t?.topic; +} +function qj(t, e) { + let r = null; + return hn(t?.publicKey, !1) || (r = ft("MISSING_OR_INVALID", `${e} controller public key should be a string`)), r; +} +function h3(t) { + let e = !0; + return Ba(t) ? t.length && (e = t.every((r) => hn(r, !1))) : e = !1, e; +} +function zj(t, e, r) { + let n = null; + return Ba(e) && e.length ? e.forEach((i) => { + n || Ed(i) || (n = Nr("UNSUPPORTED_CHAINS", `${r}, chain ${i} should be a string and conform to "namespace:chainId" format`)); + }) : Ed(t) || (n = Nr("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"] }`)), n; +} +function Hj(t, e, r) { + let n = null; + return Object.entries(t).forEach(([i, s]) => { + if (n) return; + const o = zj(i, E8(i, s), `${e} ${r}`); + o && (n = o); + }), n; +} +function Wj(t, e) { + let r = null; + return Ba(t) ? t.forEach((n) => { + r || Bj(n) || (r = Nr("UNSUPPORTED_ACCOUNTS", `${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`)); + }) : r = Nr("UNSUPPORTED_ACCOUNTS", `${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`), r; +} +function Kj(t, e) { + let r = null; + return Object.values(t).forEach((n) => { + if (r) return; + const i = Wj(n?.accounts, `${e} namespace`); + i && (r = i); + }), r; +} +function Vj(t, e) { + let r = null; + return h3(t?.methods) ? h3(t?.events) || (r = Nr("UNSUPPORTED_EVENTS", `${e}, events should be an array of strings or empty array for no events`)) : r = Nr("UNSUPPORTED_METHODS", `${e}, methods should be an array of strings or empty array for no methods`), r; +} +function B8(t, e) { + let r = null; + return Object.values(t).forEach((n) => { + if (r) return; + const i = Vj(n, `${e}, namespace`); + i && (r = i); + }), r; +} +function Gj(t, e, r) { + let n = null; + if (t && kf(t)) { + const i = B8(t, e); + i && (n = i); + const s = Hj(t, e, r); + s && (n = s); + } else n = ft("MISSING_OR_INVALID", `${e}, ${r} should be an object with data`); + return n; +} +function Vg(t, e) { + let r = null; + if (t && kf(t)) { + const n = B8(t, e); + n && (r = n); + const i = Kj(t, e); + i && (r = i); + } else r = ft("MISSING_OR_INVALID", `${e}, namespaces should be an object with data`); + return r; +} +function F8(t) { + return hn(t.protocol, !0); +} +function Yj(t, e) { + let r = !1; + return t ? t && Ba(t) && t.length && t.forEach((n) => { + r = F8(n); + }) : r = !0, r; +} +function Jj(t) { + return typeof t == "number"; +} +function ui(t) { + return typeof t < "u" && typeof t !== null; +} +function Xj(t) { + return !(!t || typeof t != "object" || !t.code || !P1(t.code, !1) || !t.message || !hn(t.message, !1)); +} +function Zj(t) { + return !(ei(t) || !hn(t.method, !1)); +} +function Qj(t) { + return !(ei(t) || ei(t.result) && ei(t.error) || !P1(t.id, !1) || !hn(t.jsonrpc, !1)); +} +function eU(t) { + return !(ei(t) || !hn(t.name, !1)); +} +function d3(t, e) { + return !(!Ed(e) || !Tj(t).includes(e)); +} +function tU(t, e, r) { + return hn(r, !1) ? Dj(t, e).includes(r) : !1; +} +function rU(t, e, r) { + return hn(r, !1) ? Oj(t, e).includes(r) : !1; +} +function p3(t, e, r) { + let n = null; + const i = nU(t), s = iU(e), o = Object.keys(i), a = Object.keys(s), f = g3(Object.keys(t)), u = g3(Object.keys(e)), h = f.filter((g) => !u.includes(g)); + return h.length && (n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces keys don't satisfy requiredNamespaces. + Required: ${h.toString()} + Received: ${Object.keys(e).toString()}`)), Pa(o, a) || (n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces chains don't satisfy required namespaces. + Required: ${o.toString()} + Approved: ${a.toString()}`)), Object.keys(e).forEach((g) => { + if (!g.includes(":") || n) return; + const v = Jc(e[g].accounts); + v.includes(g) || (n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces accounts don't satisfy namespace accounts for ${g} + Required: ${g} + Approved: ${v.toString()}`)); + }), o.forEach((g) => { + n || (Pa(i[g].methods, s[g].methods) ? Pa(i[g].events, s[g].events) || (n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces events don't satisfy namespace events for ${g}`)) : n = ft("NON_CONFORMING_NAMESPACES", `${r} namespaces methods don't satisfy namespace methods for ${g}`)); + }), n; +} +function nU(t) { + const e = {}; + return Object.keys(t).forEach((r) => { + var n; + r.includes(":") ? e[r] = t[r] : (n = t[r].chains) == null || n.forEach((i) => { + e[i] = { methods: t[r].methods, events: t[r].events }; + }); + }), e; +} +function g3(t) { + return [...new Set(t.map((e) => e.includes(":") ? e.split(":")[0] : e))]; +} +function iU(t) { + const e = {}; + return Object.keys(t).forEach((r) => { + r.includes(":") ? e[r] = t[r] : Jc(t[r].accounts)?.forEach((i) => { + e[i] = { accounts: t[r].accounts.filter((s) => s.includes(`${i}:`)), methods: t[r].methods, events: t[r].events }; + }); + }), e; +} +function sU(t, e) { + return P1(t, !1) && t <= e.max && t >= e.min; +} +function m3() { + const t = sl(); + return new Promise((e) => { + switch (t) { + case Ei.browser: + e(oU()); + break; + case Ei.reactNative: + e(aU()); + break; + case Ei.node: + e(cU()); + break; + default: + e(!0); + } + }); +} +function oU() { + return il() && navigator?.onLine; +} +async function aU() { + return Yc() && typeof global < "u" && global != null && global.NetInfo ? (await (global == null ? void 0 : global.NetInfo.fetch()))?.isConnected : !0; +} +function cU() { + return !0; +} +function uU(t) { + switch (sl()) { + case Ei.browser: + fU(t); + break; + case Ei.reactNative: + lU(t); + break; + } +} +function fU(t) { + !Yc() && il() && (window.addEventListener("online", () => t(!0)), window.addEventListener("offline", () => t(!1))); +} +function lU(t) { + Yc() && typeof global < "u" && global != null && global.NetInfo && global?.NetInfo.addEventListener((e) => t(e?.isConnected)); +} +const Gg = {}; +class Nu { + static get(e) { + return Gg[e]; + } + static set(e, r) { + Gg[e] = r; + } + static delete(e) { + delete Gg[e]; + } +} +const hU = "PARSE_ERROR", dU = "INVALID_REQUEST", pU = "METHOD_NOT_FOUND", gU = "INVALID_PARAMS", j8 = "INTERNAL_ERROR", M1 = "SERVER_ERROR", mU = [-32700, -32600, -32601, -32602, -32603], tf = { + [hU]: { code: -32700, message: "Parse error" }, + [dU]: { code: -32600, message: "Invalid Request" }, + [pU]: { code: -32601, message: "Method not found" }, + [gU]: { code: -32602, message: "Invalid params" }, + [j8]: { code: -32603, message: "Internal error" }, + [M1]: { code: -32e3, message: "Server error" } +}, U8 = M1; +function vU(t) { + return mU.includes(t); +} +function v3(t) { + return Object.keys(tf).includes(t) ? tf[t] : tf[U8]; +} +function bU(t) { + const e = Object.values(tf).find((r) => r.code === t); + return e || tf[U8]; +} +function q8(t, e, r) { + return t.message.includes("getaddrinfo ENOTFOUND") || t.message.includes("connect ECONNREFUSED") ? new Error(`Unavailable ${r} RPC url at ${e}`) : t; +} +var Yg = {}, Gs = {}, b3; +function yU() { + if (b3) return Gs; + b3 = 1, Object.defineProperty(Gs, "__esModule", { value: !0 }), Gs.isBrowserCryptoAvailable = Gs.getSubtleCrypto = Gs.getBrowerCrypto = void 0; + function t() { + return Zn?.crypto || Zn?.msCrypto || {}; + } + Gs.getBrowerCrypto = t; + function e() { + const n = t(); + return n.subtle || n.webkitSubtle; + } + Gs.getSubtleCrypto = e; + function r() { + return !!t() && !!e(); + } + return Gs.isBrowserCryptoAvailable = r, Gs; +} +var Ys = {}, y3; +function wU() { + if (y3) return Ys; + y3 = 1, Object.defineProperty(Ys, "__esModule", { value: !0 }), Ys.isBrowser = Ys.isNode = Ys.isReactNative = void 0; + function t() { + return typeof document > "u" && typeof navigator < "u" && navigator.product === "ReactNative"; + } + Ys.isReactNative = t; + function e() { + return typeof process < "u" && typeof process.versions < "u" && typeof process.versions.node < "u"; + } + Ys.isNode = e; + function r() { + return !t() && !e(); + } + return Ys.isBrowser = r, Ys; +} +var w3; +function xU() { + return w3 || (w3 = 1, (function(t) { + Object.defineProperty(t, "__esModule", { value: !0 }); + const e = Yf; + e.__exportStar(yU(), t), e.__exportStar(wU(), t); + })(Yg)), Yg; +} +var _U = xU(); +function No(t = 3) { + const e = Date.now() * Math.pow(10, t), r = Math.floor(Math.random() * Math.pow(10, t)); + return e + r; +} +function Ma(t = 6) { + return BigInt(No(t)); +} +function $o(t, e, r) { + return { + id: r || No(), + jsonrpc: "2.0", + method: t, + params: e + }; +} +function r0(t, e) { + return { + id: t, + jsonrpc: "2.0", + result: e + }; +} +function n0(t, e, r) { + return { + id: t, + jsonrpc: "2.0", + error: EU(e) + }; +} +function EU(t, e) { + return typeof t > "u" ? v3(j8) : (typeof t == "string" && (t = Object.assign(Object.assign({}, v3(M1)), { message: t })), vU(t.code) && (t = bU(t.code)), t); +} +let SU = class { +}, AU = class extends SU { + constructor() { + super(); + } +}, PU = class extends AU { + constructor(e) { + super(); + } +}; +const MU = "^https?:", IU = "^wss?:"; +function CU(t) { + const e = t.match(new RegExp(/^\w+:/, "gi")); + if (!(!e || !e.length)) + return e[0]; +} +function z8(t, e) { + const r = CU(t); + return typeof r > "u" ? !1 : new RegExp(e).test(r); +} +function x3(t) { + return z8(t, MU); +} +function _3(t) { + return z8(t, IU); +} +function RU(t) { + return new RegExp("wss?://localhost(:d{2,5})?").test(t); +} +function H8(t) { + return typeof t == "object" && "id" in t && "jsonrpc" in t && t.jsonrpc === "2.0"; +} +function I1(t) { + return H8(t) && "method" in t; +} +function i0(t) { + return H8(t) && (Ps(t) || qi(t)); +} +function Ps(t) { + return "result" in t; +} +function qi(t) { + return "error" in t; +} +let Yi = class extends PU { + constructor(e) { + super(e), this.events = new Wi.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($o(e.method, e.params || [], e.id || Ma().toString()), r); + } + async requestStrict(e, r) { + return new Promise(async (n, i) => { + if (!this.connection.connected) try { + await this.open(); + } catch (s) { + i(s); + } + this.events.on(`${e.id}`, (s) => { + qi(s) ? i(s.error) : n(s.result); + }); + try { + await this.connection.send(e, r); + } catch (s) { + i(s); + } + }); + } + setConnection(e = this.connection) { + return e; + } + onPayload(e) { + this.events.emit("payload", e), i0(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); + } +}; +const TU = () => 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 : require("ws"), DU = () => typeof WebSocket < "u" || typeof global < "u" && typeof global.WebSocket < "u" || typeof window < "u" && typeof window.WebSocket < "u" || typeof self < "u" && typeof self.WebSocket < "u", E3 = (t) => t.split("?")[0], S3 = 10, OU = TU(); +let NU = class { + constructor(e) { + if (this.url = e, this.events = new Wi.EventEmitter(), this.registering = !1, !_3(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 = (n) => { + this.onClose(n), e(); + }, this.socket.close(); + }); + } + async send(e) { + typeof this.socket > "u" && (this.socket = await this.register()); + try { + this.socket.send(ho(e)); + } catch (r) { + this.onError(e.id, r); + } + } + register(e = this.url) { + if (!_3(e)) throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`); + if (this.registering) { + const r = this.events.getMaxListeners(); + return (this.events.listenerCount("register_error") >= r || this.events.listenerCount("open") >= r) && this.events.setMaxListeners(r + 1), new Promise((n, i) => { + this.events.once("register_error", (s) => { + this.resetMaxListeners(), i(s); + }), this.events.once("open", () => { + if (this.resetMaxListeners(), typeof this.socket > "u") return i(new Error("WebSocket connection is missing or invalid")); + n(this.socket); + }); + }); + } + return this.url = e, this.registering = !0, new Promise((r, n) => { + const i = new URLSearchParams(e).get("origin"), s = _U.isReactNative() ? { headers: { origin: i } } : { rejectUnauthorized: !RU(e) }, o = new OU(e, [], s); + DU() ? o.onerror = (a) => { + const f = a; + n(this.emitError(f.error)); + } : o.on("error", (a) => { + n(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; + const r = typeof e.data == "string" ? Na(e.data) : e.data; + this.events.emit("payload", r); + } + onError(e, r) { + const n = this.parseError(r), i = n.message || n.toString(), s = n0(e, i); + this.events.emit("payload", s); + } + parseError(e, r = this.url) { + return q8(e, E3(r), "WS"); + } + resetMaxListeners() { + this.events.getMaxListeners() > S3 && this.events.setMaxListeners(S3); + } + emitError(e) { + const r = this.parseError(new Error(e?.message || `WebSocket connection failed for host: ${E3(this.url)}`)); + return this.events.emit("register_error", r), r; + } +}; +var Yu = { exports: {} }; +Yu.exports; +var A3; +function LU() { + return A3 || (A3 = 1, (function(t, e) { + var r = 200, n = "__lodash_hash_undefined__", i = 1, s = 2, o = 9007199254740991, a = "[object Arguments]", f = "[object Array]", u = "[object AsyncFunction]", h = "[object Boolean]", g = "[object Date]", v = "[object Error]", x = "[object Function]", S = "[object GeneratorFunction]", R = "[object Map]", D = "[object Number]", k = "[object Null]", N = "[object Object]", z = "[object Promise]", B = "[object Proxy]", $ = "[object RegExp]", U = "[object Set]", C = "[object String]", W = "[object Symbol]", J = "[object Undefined]", ne = "[object WeakMap]", K = "[object ArrayBuffer]", E = "[object DataView]", b = "[object Float32Array]", l = "[object Float64Array]", p = "[object Int8Array]", m = "[object Int16Array]", w = "[object Int32Array]", P = "[object Uint8Array]", _ = "[object Uint8ClampedArray]", y = "[object Uint16Array]", M = "[object Uint32Array]", I = /[\\^$.*+?()[\]{}|]/g, q = /^\[object .+?Constructor\]$/, ce = /^(?:0|[1-9]\d*)$/, L = {}; + L[b] = L[l] = L[p] = L[m] = L[w] = L[P] = L[_] = L[y] = L[M] = !0, L[a] = L[f] = L[K] = L[h] = L[E] = L[g] = L[v] = L[x] = L[R] = L[D] = L[N] = L[$] = L[U] = L[C] = L[ne] = !1; + var oe = typeof Zn == "object" && Zn && Zn.Object === Object && Zn, Q = typeof self == "object" && self && self.Object === Object && self, X = oe || Q || Function("return this")(), ee = e && !e.nodeType && e, O = ee && !0 && t && !t.nodeType && t, Z = O && O.exports === ee, re = Z && oe.process, he = (function() { + try { + return re && re.binding && re.binding("util"); + } catch { + } + })(), ae = he && he.isTypedArray; + function fe(ue, we) { + for (var Ve = -1, St = ue == null ? 0 : ue.length, jr = 0, ir = []; ++Ve < St; ) { + var Kr = ue[Ve]; + we(Kr, Ve, ue) && (ir[jr++] = Kr); + } + return ir; + } + function be(ue, we) { + for (var Ve = -1, St = we.length, jr = ue.length; ++Ve < St; ) + ue[jr + Ve] = we[Ve]; + return ue; + } + function Ae(ue, we) { + for (var Ve = -1, St = ue == null ? 0 : ue.length; ++Ve < St; ) + if (we(ue[Ve], Ve, ue)) + return !0; + return !1; + } + function Te(ue, we) { + for (var Ve = -1, St = Array(ue); ++Ve < ue; ) + St[Ve] = we(Ve); + return St; + } + function Re(ue) { + return function(we) { + return ue(we); + }; + } + function $e(ue, we) { + return ue.has(we); + } + function Me(ue, we) { + return ue?.[we]; + } + function Oe(ue) { + var we = -1, Ve = Array(ue.size); + return ue.forEach(function(St, jr) { + Ve[++we] = [jr, St]; + }), Ve; + } + function ze(ue, we) { + return function(Ve) { + return ue(we(Ve)); + }; + } + function De(ue) { + var we = -1, Ve = Array(ue.size); + return ue.forEach(function(St) { + Ve[++we] = St; + }), Ve; + } + var je = Array.prototype, Ue = Function.prototype, _e = Object.prototype, Ze = X["__core-js_shared__"], ot = Ue.toString, ke = _e.hasOwnProperty, rt = (function() { + var ue = /[^.]+$/.exec(Ze && Ze.keys && Ze.keys.IE_PROTO || ""); + return ue ? "Symbol(src)_1." + ue : ""; + })(), nt = _e.toString, Ge = RegExp( + "^" + ot.call(ke).replace(I, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" + ), ht = Z ? X.Buffer : void 0, lt = X.Symbol, ct = X.Uint8Array, qt = _e.propertyIsEnumerable, Gt = je.splice, Et = lt ? lt.toStringTag : void 0, Yt = Object.getOwnPropertySymbols, tr = ht ? ht.isBuffer : void 0, Tt = ze(Object.keys, Object), kt = xr(X, "DataView"), It = xr(X, "Map"), dt = xr(X, "Promise"), Dt = xr(X, "Set"), Nt = xr(X, "WeakMap"), mt = xr(Object, "create"), Bt = ks(kt), Ft = ks(It), et = ks(dt), $t = ks(Dt), H = ks(Nt), V = lt ? lt.prototype : void 0, Y = V ? V.valueOf : void 0; + function T(ue) { + var we = -1, Ve = ue == null ? 0 : ue.length; + for (this.clear(); ++we < Ve; ) { + var St = ue[we]; + this.set(St[0], St[1]); + } + } + function F() { + this.__data__ = mt ? mt(null) : {}, this.size = 0; + } + function ie(ue) { + var we = this.has(ue) && delete this.__data__[ue]; + return this.size -= we ? 1 : 0, we; + } + function le(ue) { + var we = this.__data__; + if (mt) { + var Ve = we[ue]; + return Ve === n ? void 0 : Ve; + } + return ke.call(we, ue) ? we[ue] : void 0; + } + function me(ue) { + var we = this.__data__; + return mt ? we[ue] !== void 0 : ke.call(we, ue); + } + function Ee(ue, we) { + var Ve = this.__data__; + return this.size += this.has(ue) ? 0 : 1, Ve[ue] = mt && we === void 0 ? n : we, this; + } + T.prototype.clear = F, T.prototype.delete = ie, T.prototype.get = le, T.prototype.has = me, T.prototype.set = Ee; + function Le(ue) { + var we = -1, Ve = ue == null ? 0 : ue.length; + for (this.clear(); ++we < Ve; ) { + var St = ue[we]; + this.set(St[0], St[1]); + } + } + function Ie() { + this.__data__ = [], this.size = 0; + } + function Qe(ue) { + var we = this.__data__, Ve = Ye(we, ue); + if (Ve < 0) + return !1; + var St = we.length - 1; + return Ve == St ? we.pop() : Gt.call(we, Ve, 1), --this.size, !0; + } + function Xe(ue) { + var we = this.__data__, Ve = Ye(we, ue); + return Ve < 0 ? void 0 : we[Ve][1]; + } + function tt(ue) { + return Ye(this.__data__, ue) > -1; + } + function st(ue, we) { + var Ve = this.__data__, St = Ye(Ve, ue); + return St < 0 ? (++this.size, Ve.push([ue, we])) : Ve[St][1] = we, this; + } + Le.prototype.clear = Ie, Le.prototype.delete = Qe, Le.prototype.get = Xe, Le.prototype.has = tt, Le.prototype.set = st; + function vt(ue) { + var we = -1, Ve = ue == null ? 0 : ue.length; + for (this.clear(); ++we < Ve; ) { + var St = ue[we]; + this.set(St[0], St[1]); + } + } + function Ct() { + this.size = 0, this.__data__ = { + hash: new T(), + map: new (It || Le)(), + string: new T() + }; + } + function Mt(ue) { + var we = vr(this, ue).delete(ue); + return this.size -= we ? 1 : 0, we; + } + function wt(ue) { + return vr(this, ue).get(ue); + } + function Rt(ue) { + return vr(this, ue).has(ue); + } + function gt(ue, we) { + var Ve = vr(this, ue), St = Ve.size; + return Ve.set(ue, we), this.size += Ve.size == St ? 0 : 1, this; + } + vt.prototype.clear = Ct, vt.prototype.delete = Mt, vt.prototype.get = wt, vt.prototype.has = Rt, vt.prototype.set = gt; + function _t(ue) { + var we = -1, Ve = ue == null ? 0 : ue.length; + for (this.__data__ = new vt(); ++we < Ve; ) + this.add(ue[we]); + } + function at(ue) { + return this.__data__.set(ue, n), this; + } + function yt(ue) { + return this.__data__.has(ue); + } + _t.prototype.add = _t.prototype.push = at, _t.prototype.has = yt; + function ut(ue) { + var we = this.__data__ = new Le(ue); + this.size = we.size; + } + function it() { + this.__data__ = new Le(), this.size = 0; + } + function Se(ue) { + var we = this.__data__, Ve = we.delete(ue); + return this.size = we.size, Ve; + } + function Pe(ue) { + return this.__data__.get(ue); + } + function Ke(ue) { + return this.__data__.has(ue); + } + function Fe(ue, we) { + var Ve = this.__data__; + if (Ve instanceof Le) { + var St = Ve.__data__; + if (!It || St.length < r - 1) + return St.push([ue, we]), this.size = ++Ve.size, this; + Ve = this.__data__ = new vt(St); + } + return Ve.set(ue, we), this.size = Ve.size, this; + } + ut.prototype.clear = it, ut.prototype.delete = Se, ut.prototype.get = Pe, ut.prototype.has = Ke, ut.prototype.set = Fe; + function qe(ue, we) { + var Ve = Xa(ue), St = !Ve && yl(ue), jr = !Ve && !St && iu(ue), ir = !Ve && !St && !jr && _l(ue), Kr = Ve || St || jr || ir, gn = Kr ? Te(ue.length, String) : [], Er = gn.length; + for (var Ur in ue) + ke.call(ue, Ur) && !(Kr && // Safari 9 has enumerable `arguments.length` in strict mode. + (Ur == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. + jr && (Ur == "offset" || Ur == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. + ir && (Ur == "buffer" || Ur == "byteLength" || Ur == "byteOffset") || // Skip index properties. + rn(Ur, Er))) && gn.push(Ur); + return gn; + } + function Ye(ue, we) { + for (var Ve = ue.length; Ve--; ) + if (bl(ue[Ve][0], we)) + return Ve; + return -1; + } + function Lt(ue, we, Ve) { + var St = we(ue); + return Xa(ue) ? St : be(St, Ve(ue)); + } + function zt(ue) { + return ue == null ? ue === void 0 ? J : k : Et && Et in Object(ue) ? $r(ue) : R0(ue); + } + function Zt(ue) { + return ta(ue) && zt(ue) == a; + } + function Ht(ue, we, Ve, St, jr) { + return ue === we ? !0 : ue == null || we == null || !ta(ue) && !ta(we) ? ue !== ue && we !== we : ge(ue, we, Ve, St, Ht, jr); + } + function ge(ue, we, Ve, St, jr, ir) { + var Kr = Xa(ue), gn = Xa(we), Er = Kr ? f : Ir(ue), Ur = gn ? f : Ir(we); + Er = Er == a ? N : Er, Ur = Ur == a ? N : Ur; + var on = Er == N, ni = Ur == N, mn = Er == Ur; + if (mn && iu(ue)) { + if (!iu(we)) + return !1; + Kr = !0, on = !1; + } + if (mn && !on) + return ir || (ir = new ut()), Kr || _l(ue) ? Qt(ue, we, Ve, St, jr, ir) : mr(ue, we, Er, Ve, St, jr, ir); + if (!(Ve & i)) { + var Vr = on && ke.call(ue, "__wrapped__"), Gn = ni && ke.call(we, "__wrapped__"); + if (Vr || Gn) { + var Zi = Vr ? ue.value() : ue, Ci = Gn ? we.value() : we; + return ir || (ir = new ut()), jr(Zi, Ci, Ve, St, ir); + } + } + return mn ? (ir || (ir = new ut()), lr(ue, we, Ve, St, jr, ir)) : !1; + } + function nr(ue) { + if (!xl(ue) || sn(ue)) + return !1; + var we = Za(ue) ? Ge : q; + return we.test(ks(ue)); + } + function pr(ue) { + return ta(ue) && wl(ue.length) && !!L[zt(ue)]; + } + function gr(ue) { + if (!vl(ue)) + return Tt(ue); + var we = []; + for (var Ve in Object(ue)) + ke.call(ue, Ve) && Ve != "constructor" && we.push(Ve); + return we; + } + function Qt(ue, we, Ve, St, jr, ir) { + var Kr = Ve & i, gn = ue.length, Er = we.length; + if (gn != Er && !(Kr && Er > gn)) + return !1; + var Ur = ir.get(ue); + if (Ur && ir.get(we)) + return Ur == we; + var on = -1, ni = !0, mn = Ve & s ? new _t() : void 0; + for (ir.set(ue, we), ir.set(we, ue); ++on < gn; ) { + var Vr = ue[on], Gn = we[on]; + if (St) + var Zi = Kr ? St(Gn, Vr, on, we, ue, ir) : St(Vr, Gn, on, ue, we, ir); + if (Zi !== void 0) { + if (Zi) + continue; + ni = !1; + break; + } + if (mn) { + if (!Ae(we, function(Ci, gs) { + if (!$e(mn, gs) && (Vr === Ci || jr(Vr, Ci, Ve, St, ir))) + return mn.push(gs); + })) { + ni = !1; + break; + } + } else if (!(Vr === Gn || jr(Vr, Gn, Ve, St, ir))) { + ni = !1; + break; + } + } + return ir.delete(ue), ir.delete(we), ni; + } + function mr(ue, we, Ve, St, jr, ir, Kr) { + switch (Ve) { + case E: + if (ue.byteLength != we.byteLength || ue.byteOffset != we.byteOffset) + return !1; + ue = ue.buffer, we = we.buffer; + case K: + return !(ue.byteLength != we.byteLength || !ir(new ct(ue), new ct(we))); + case h: + case g: + case D: + return bl(+ue, +we); + case v: + return ue.name == we.name && ue.message == we.message; + case $: + case C: + return ue == we + ""; + case R: + var gn = Oe; + case U: + var Er = St & i; + if (gn || (gn = De), ue.size != we.size && !Er) + return !1; + var Ur = Kr.get(ue); + if (Ur) + return Ur == we; + St |= s, Kr.set(ue, we); + var on = Qt(gn(ue), gn(we), St, jr, ir, Kr); + return Kr.delete(ue), on; + case W: + if (Y) + return Y.call(ue) == Y.call(we); + } + return !1; + } + function lr(ue, we, Ve, St, jr, ir) { + var Kr = Ve & i, gn = Tr(ue), Er = gn.length, Ur = Tr(we), on = Ur.length; + if (Er != on && !Kr) + return !1; + for (var ni = Er; ni--; ) { + var mn = gn[ni]; + if (!(Kr ? mn in we : ke.call(we, mn))) + return !1; + } + var Vr = ir.get(ue); + if (Vr && ir.get(we)) + return Vr == we; + var Gn = !0; + ir.set(ue, we), ir.set(we, ue); + for (var Zi = Kr; ++ni < Er; ) { + mn = gn[ni]; + var Ci = ue[mn], gs = we[mn]; + if (St) + var su = Kr ? St(gs, Ci, mn, we, ue, ir) : St(Ci, gs, mn, ue, we, ir); + if (!(su === void 0 ? Ci === gs || jr(Ci, gs, Ve, St, ir) : su)) { + Gn = !1; + break; + } + Zi || (Zi = mn == "constructor"); + } + if (Gn && !Zi) { + var ra = ue.constructor, Sn = we.constructor; + ra != Sn && "constructor" in ue && "constructor" in we && !(typeof ra == "function" && ra instanceof ra && typeof Sn == "function" && Sn instanceof Sn) && (Gn = !1); + } + return ir.delete(ue), ir.delete(we), Gn; + } + function Tr(ue) { + return Lt(ue, O0, Br); + } + function vr(ue, we) { + var Ve = ue.__data__; + return nn(we) ? Ve[typeof we == "string" ? "string" : "hash"] : Ve.map; + } + function xr(ue, we) { + var Ve = Me(ue, we); + return nr(Ve) ? Ve : void 0; + } + function $r(ue) { + var we = ke.call(ue, Et), Ve = ue[Et]; + try { + ue[Et] = void 0; + var St = !0; + } catch { + } + var jr = nt.call(ue); + return St && (we ? ue[Et] = Ve : delete ue[Et]), jr; + } + var Br = Yt ? function(ue) { + return ue == null ? [] : (ue = Object(ue), fe(Yt(ue), function(we) { + return qt.call(ue, we); + })); + } : Fr, Ir = zt; + (kt && Ir(new kt(new ArrayBuffer(1))) != E || It && Ir(new It()) != R || dt && Ir(dt.resolve()) != z || Dt && Ir(new Dt()) != U || Nt && Ir(new Nt()) != ne) && (Ir = function(ue) { + var we = zt(ue), Ve = we == N ? ue.constructor : void 0, St = Ve ? ks(Ve) : ""; + if (St) + switch (St) { + case Bt: + return E; + case Ft: + return R; + case et: + return z; + case $t: + return U; + case H: + return ne; + } + return we; + }); + function rn(ue, we) { + return we = we ?? o, !!we && (typeof ue == "number" || ce.test(ue)) && ue > -1 && ue % 1 == 0 && ue < we; + } + function nn(ue) { + var we = typeof ue; + return we == "string" || we == "number" || we == "symbol" || we == "boolean" ? ue !== "__proto__" : ue === null; + } + function sn(ue) { + return !!rt && rt in ue; + } + function vl(ue) { + var we = ue && ue.constructor, Ve = typeof we == "function" && we.prototype || _e; + return ue === Ve; + } + function R0(ue) { + return nt.call(ue); + } + function ks(ue) { + if (ue != null) { + try { + return ot.call(ue); + } catch { + } + try { + return ue + ""; + } catch { + } + } + return ""; + } + function bl(ue, we) { + return ue === we || ue !== ue && we !== we; + } + var yl = Zt(/* @__PURE__ */ (function() { + return arguments; + })()) ? Zt : function(ue) { + return ta(ue) && ke.call(ue, "callee") && !qt.call(ue, "callee"); + }, Xa = Array.isArray; + function T0(ue) { + return ue != null && wl(ue.length) && !Za(ue); + } + var iu = tr || Dr; + function D0(ue, we) { + return Ht(ue, we); + } + function Za(ue) { + if (!xl(ue)) + return !1; + var we = zt(ue); + return we == x || we == S || we == u || we == B; + } + function wl(ue) { + return typeof ue == "number" && ue > -1 && ue % 1 == 0 && ue <= o; + } + function xl(ue) { + var we = typeof ue; + return ue != null && (we == "object" || we == "function"); + } + function ta(ue) { + return ue != null && typeof ue == "object"; + } + var _l = ae ? Re(ae) : pr; + function O0(ue) { + return T0(ue) ? qe(ue) : gr(ue); + } + function Fr() { + return []; + } + function Dr() { + return !1; + } + t.exports = D0; + })(Yu, Yu.exports)), Yu.exports; +} +var kU = LU(); +const $U = /* @__PURE__ */ Hi(kU), W8 = "wc", K8 = 2, V8 = "core", Ds = `${W8}@2:${V8}:`, BU = { logger: "error" }, FU = { database: ":memory:" }, jU = "crypto", P3 = "client_ed25519_seed", UU = bt.ONE_DAY, qU = "keychain", zU = "0.3", HU = "messages", WU = "0.3", KU = bt.SIX_HOURS, VU = "publisher", G8 = "irn", GU = "error", Y8 = "wss://relay.walletconnect.org", YU = "relayer", Qn = { 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" }, JU = "_subscription", $i = { payload: "payload", connect: "connect", disconnect: "disconnect", error: "error" }, XU = 0.1, av = "2.17.2", Wr = { link_mode: "link_mode", relay: "relay" }, ZU = "0.3", QU = "WALLETCONNECT_CLIENT_ID", M3 = "WALLETCONNECT_LINK_MODE_APPS", Ms = { created: "subscription_created", deleted: "subscription_deleted", sync: "subscription_sync", resubscribed: "subscription_resubscribed" }, eq = "subscription", tq = "0.3", rq = bt.FIVE_SECONDS * 1e3, nq = "pairing", iq = "0.3", Lu = { wc_pairingDelete: { req: { ttl: bt.ONE_DAY, prompt: !1, tag: 1e3 }, res: { ttl: bt.ONE_DAY, prompt: !1, tag: 1001 } }, wc_pairingPing: { req: { ttl: bt.THIRTY_SECONDS, prompt: !1, tag: 1002 }, res: { ttl: bt.THIRTY_SECONDS, prompt: !1, tag: 1003 } }, unregistered_method: { req: { ttl: bt.ONE_DAY, prompt: !1, tag: 0 }, res: { ttl: bt.ONE_DAY, prompt: !1, tag: 0 } } }, _a = { create: "pairing_create", expire: "pairing_expire", delete: "pairing_delete", ping: "pairing_ping" }, ns = { created: "history_created", updated: "history_updated", deleted: "history_deleted", sync: "history_sync" }, sq = "history", oq = "0.3", aq = "expirer", ji = { created: "expirer_created", deleted: "expirer_deleted", expired: "expirer_expired", sync: "expirer_sync" }, cq = "0.3", uq = "verify-api", fq = "https://verify.walletconnect.com", J8 = "https://verify.walletconnect.org", rf = J8, lq = `${rf}/v3`, hq = [fq, J8], dq = "echo", pq = "https://echo.walletconnect.com", As = { 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" }, Zs = { 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" }, is = { 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" }, ga = { 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" }, ma = { authenticated_session_approve_started: "authenticated_session_approve_started", 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" }, ku = { no_internet_connection: "no_internet_connection", 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" }, gq = 0.1, mq = "event-client", vq = 86400, bq = "https://pulse.walletconnect.org/batch"; +function yq(t, e) { + if (t.length >= 255) throw new TypeError("Alphabet too long"); + for (var r = new Uint8Array(256), n = 0; n < r.length; n++) r[n] = 255; + for (var i = 0; i < t.length; i++) { + var s = t.charAt(i), o = s.charCodeAt(0); + if (r[o] !== 255) throw new TypeError(s + " is ambiguous"); + r[o] = i; + } + var a = t.length, f = t.charAt(0), u = Math.log(a) / Math.log(256), h = Math.log(256) / Math.log(a); + function g(S) { + if (S instanceof Uint8Array || (ArrayBuffer.isView(S) ? S = new Uint8Array(S.buffer, S.byteOffset, S.byteLength) : Array.isArray(S) && (S = Uint8Array.from(S))), !(S instanceof Uint8Array)) throw new TypeError("Expected Uint8Array"); + if (S.length === 0) return ""; + for (var R = 0, D = 0, k = 0, N = S.length; k !== N && S[k] === 0; ) k++, R++; + for (var z = (N - k) * h + 1 >>> 0, B = new Uint8Array(z); k !== N; ) { + for (var $ = S[k], U = 0, C = z - 1; ($ !== 0 || U < D) && C !== -1; C--, U++) $ += 256 * B[C] >>> 0, B[C] = $ % a >>> 0, $ = $ / a >>> 0; + if ($ !== 0) throw new Error("Non-zero carry"); + D = U, k++; + } + for (var W = z - D; W !== z && B[W] === 0; ) W++; + for (var J = f.repeat(R); W < z; ++W) J += t.charAt(B[W]); + return J; + } + function v(S) { + if (typeof S != "string") throw new TypeError("Expected String"); + if (S.length === 0) return new Uint8Array(); + var R = 0; + if (S[R] !== " ") { + for (var D = 0, k = 0; S[R] === f; ) D++, R++; + for (var N = (S.length - R) * u + 1 >>> 0, z = new Uint8Array(N); S[R]; ) { + var B = r[S.charCodeAt(R)]; + if (B === 255) return; + for (var $ = 0, U = N - 1; (B !== 0 || $ < k) && U !== -1; U--, $++) B += a * z[U] >>> 0, z[U] = B % 256 >>> 0, B = B / 256 >>> 0; + if (B !== 0) throw new Error("Non-zero carry"); + k = $, R++; + } + if (S[R] !== " ") { + for (var C = N - k; C !== N && z[C] === 0; ) C++; + for (var W = new Uint8Array(D + (N - C)), J = D; C !== N; ) W[J++] = z[C++]; + return W; + } + } + } + function x(S) { + var R = v(S); + if (R) return R; + throw new Error(`Non-${e} character`); + } + return { encode: g, decodeUnsafe: v, decode: x }; +} +var wq = yq, xq = wq; +const X8 = (t) => { + if (t instanceof Uint8Array && t.constructor.name === "Uint8Array") return t; + if (t instanceof ArrayBuffer) return new Uint8Array(t); + if (ArrayBuffer.isView(t)) return new Uint8Array(t.buffer, t.byteOffset, t.byteLength); + throw new Error("Unknown type, must be binary type"); +}, _q = (t) => new TextEncoder().encode(t), Eq = (t) => new TextDecoder().decode(t); +class Sq { + constructor(e, r, n) { + this.name = e, this.prefix = r, this.baseEncode = n; + } + encode(e) { + if (e instanceof Uint8Array) return `${this.prefix}${this.baseEncode(e)}`; + throw Error("Unknown type, must be binary type"); + } +} +class Aq { + constructor(e, r, n) { + 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 = n; + } + 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 Z8(this, e); + } +} +class Pq { + constructor(e) { + this.decoders = e; + } + or(e) { + return Z8(this, e); + } + decode(e) { + const r = e[0], n = this.decoders[r]; + if (n) return n.decode(e); + throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`); + } +} +const Z8 = (t, e) => new Pq({ ...t.decoders || { [t.prefix]: t }, ...e.decoders || { [e.prefix]: e } }); +class Mq { + constructor(e, r, n, i) { + this.name = e, this.prefix = r, this.baseEncode = n, this.baseDecode = i, this.encoder = new Sq(e, r, n), this.decoder = new Aq(e, r, i); + } + encode(e) { + return this.encoder.encode(e); + } + decode(e) { + return this.decoder.decode(e); + } +} +const s0 = ({ name: t, prefix: e, encode: r, decode: n }) => new Mq(t, e, r, n), cl = ({ prefix: t, name: e, alphabet: r }) => { + const { encode: n, decode: i } = xq(r, e); + return s0({ prefix: t, name: e, encode: n, decode: (s) => X8(i(s)) }); +}, Iq = (t, e, r, n) => { + const i = {}; + for (let h = 0; h < e.length; ++h) i[e[h]] = h; + let s = t.length; + for (; t[s - 1] === "="; ) --s; + const o = new Uint8Array(s * r / 8 | 0); + let a = 0, f = 0, u = 0; + for (let h = 0; h < s; ++h) { + const g = i[t[h]]; + if (g === void 0) throw new SyntaxError(`Non-${n} character`); + f = f << r | g, a += r, a >= 8 && (a -= 8, o[u++] = 255 & f >> a); + } + if (a >= r || 255 & f << 8 - a) throw new SyntaxError("Unexpected end of data"); + return o; +}, Cq = (t, e, r) => { + const n = e[e.length - 1] === "=", i = (1 << r) - 1; + let s = "", o = 0, a = 0; + for (let f = 0; f < t.length; ++f) for (a = a << 8 | t[f], o += 8; o > r; ) o -= r, s += e[i & a >> o]; + if (o && (s += e[i & a << r - o]), n) for (; s.length * r & 7; ) s += "="; + return s; +}, Fn = ({ name: t, prefix: e, bitsPerChar: r, alphabet: n }) => s0({ prefix: e, name: t, encode(i) { + return Cq(i, n, r); +}, decode(i) { + return Iq(i, n, r, t); +} }), Rq = s0({ prefix: "\0", name: "identity", encode: (t) => Eq(t), decode: (t) => _q(t) }); +var Tq = Object.freeze({ __proto__: null, identity: Rq }); +const Dq = Fn({ prefix: "0", name: "base2", alphabet: "01", bitsPerChar: 1 }); +var Oq = Object.freeze({ __proto__: null, base2: Dq }); +const Nq = Fn({ prefix: "7", name: "base8", alphabet: "01234567", bitsPerChar: 3 }); +var Lq = Object.freeze({ __proto__: null, base8: Nq }); +const kq = cl({ prefix: "9", name: "base10", alphabet: "0123456789" }); +var $q = Object.freeze({ __proto__: null, base10: kq }); +const Bq = Fn({ prefix: "f", name: "base16", alphabet: "0123456789abcdef", bitsPerChar: 4 }), Fq = Fn({ prefix: "F", name: "base16upper", alphabet: "0123456789ABCDEF", bitsPerChar: 4 }); +var jq = Object.freeze({ __proto__: null, base16: Bq, base16upper: Fq }); +const Uq = Fn({ prefix: "b", name: "base32", alphabet: "abcdefghijklmnopqrstuvwxyz234567", bitsPerChar: 5 }), qq = Fn({ prefix: "B", name: "base32upper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", bitsPerChar: 5 }), zq = Fn({ prefix: "c", name: "base32pad", alphabet: "abcdefghijklmnopqrstuvwxyz234567=", bitsPerChar: 5 }), Hq = Fn({ prefix: "C", name: "base32padupper", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", bitsPerChar: 5 }), Wq = Fn({ prefix: "v", name: "base32hex", alphabet: "0123456789abcdefghijklmnopqrstuv", bitsPerChar: 5 }), Kq = Fn({ prefix: "V", name: "base32hexupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV", bitsPerChar: 5 }), Vq = Fn({ prefix: "t", name: "base32hexpad", alphabet: "0123456789abcdefghijklmnopqrstuv=", bitsPerChar: 5 }), Gq = Fn({ prefix: "T", name: "base32hexpadupper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=", bitsPerChar: 5 }), Yq = Fn({ prefix: "h", name: "base32z", alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769", bitsPerChar: 5 }); +var Jq = Object.freeze({ __proto__: null, base32: Uq, base32upper: qq, base32pad: zq, base32padupper: Hq, base32hex: Wq, base32hexupper: Kq, base32hexpad: Vq, base32hexpadupper: Gq, base32z: Yq }); +const Xq = cl({ prefix: "k", name: "base36", alphabet: "0123456789abcdefghijklmnopqrstuvwxyz" }), Zq = cl({ prefix: "K", name: "base36upper", alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" }); +var Qq = Object.freeze({ __proto__: null, base36: Xq, base36upper: Zq }); +const ez = cl({ name: "base58btc", prefix: "z", alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" }), tz = cl({ name: "base58flickr", prefix: "Z", alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" }); +var rz = Object.freeze({ __proto__: null, base58btc: ez, base58flickr: tz }); +const nz = Fn({ prefix: "m", name: "base64", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", bitsPerChar: 6 }), iz = Fn({ prefix: "M", name: "base64pad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", bitsPerChar: 6 }), sz = Fn({ prefix: "u", name: "base64url", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", bitsPerChar: 6 }), oz = Fn({ prefix: "U", name: "base64urlpad", alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=", bitsPerChar: 6 }); +var az = Object.freeze({ __proto__: null, base64: nz, base64pad: iz, base64url: sz, base64urlpad: oz }); +const Q8 = Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"), cz = Q8.reduce((t, e, r) => (t[r] = e, t), []), uz = Q8.reduce((t, e, r) => (t[e.codePointAt(0)] = r, t), []); +function fz(t) { + return t.reduce((e, r) => (e += cz[r], e), ""); +} +function lz(t) { + const e = []; + for (const r of t) { + const n = uz[r.codePointAt(0)]; + if (n === void 0) throw new Error(`Non-base256emoji character: ${r}`); + e.push(n); + } + return new Uint8Array(e); +} +const hz = s0({ prefix: "🚀", name: "base256emoji", encode: fz, decode: lz }); +var dz = Object.freeze({ __proto__: null, base256emoji: hz }), pz = eE, I3 = 128, gz = -128, mz = Math.pow(2, 31); +function eE(t, e, r) { + e = e || [], r = r || 0; + for (var n = r; t >= mz; ) e[r++] = t & 255 | I3, t /= 128; + for (; t & gz; ) e[r++] = t & 255 | I3, t >>>= 7; + return e[r] = t | 0, eE.bytes = r - n + 1, e; +} +var vz = cv, bz = 128, C3 = 127; +function cv(t, n) { + var r = 0, n = n || 0, i = 0, s = n, o, a = t.length; + do { + if (s >= a) throw cv.bytes = 0, new RangeError("Could not decode varint"); + o = t[s++], r += i < 28 ? (o & C3) << i : (o & C3) * Math.pow(2, i), i += 7; + } while (o >= bz); + return cv.bytes = s - n, r; +} +var yz = Math.pow(2, 7), wz = Math.pow(2, 14), xz = Math.pow(2, 21), _z = Math.pow(2, 28), Ez = Math.pow(2, 35), Sz = Math.pow(2, 42), Az = Math.pow(2, 49), Pz = Math.pow(2, 56), Mz = Math.pow(2, 63), Iz = function(t) { + return t < yz ? 1 : t < wz ? 2 : t < xz ? 3 : t < _z ? 4 : t < Ez ? 5 : t < Sz ? 6 : t < Az ? 7 : t < Pz ? 8 : t < Mz ? 9 : 10; +}, Cz = { encode: pz, decode: vz, encodingLength: Iz }, tE = Cz; +const R3 = (t, e, r = 0) => (tE.encode(t, e, r), e), T3 = (t) => tE.encodingLength(t), uv = (t, e) => { + const r = e.byteLength, n = T3(t), i = n + T3(r), s = new Uint8Array(i + r); + return R3(t, s, 0), R3(r, s, n), s.set(e, i), new Rz(t, r, e, s); +}; +class Rz { + constructor(e, r, n, i) { + this.code = e, this.size = r, this.digest = n, this.bytes = i; + } +} +const rE = ({ name: t, code: e, encode: r }) => new Tz(t, e, r); +class Tz { + constructor(e, r, n) { + this.name = e, this.code = r, this.encode = n; + } + digest(e) { + if (e instanceof Uint8Array) { + const r = this.encode(e); + return r instanceof Uint8Array ? uv(this.code, r) : r.then((n) => uv(this.code, n)); + } else throw Error("Unknown type, must be binary type"); + } +} +const nE = (t) => async (e) => new Uint8Array(await crypto.subtle.digest(t, e)), Dz = rE({ name: "sha2-256", code: 18, encode: nE("SHA-256") }), Oz = rE({ name: "sha2-512", code: 19, encode: nE("SHA-512") }); +var Nz = Object.freeze({ __proto__: null, sha256: Dz, sha512: Oz }); +const iE = 0, Lz = "identity", sE = X8, kz = (t) => uv(iE, sE(t)), $z = { code: iE, name: Lz, encode: sE, digest: kz }; +var Bz = Object.freeze({ __proto__: null, identity: $z }); +new TextEncoder(), new TextDecoder(); +const D3 = { ...Tq, ...Oq, ...Lq, ...$q, ...jq, ...Jq, ...Qq, ...rz, ...az, ...dz }; +({ ...Nz, ...Bz }); +function Fz(t = 0) { + return globalThis.Buffer != null && globalThis.Buffer.allocUnsafe != null ? globalThis.Buffer.allocUnsafe(t) : new Uint8Array(t); +} +function oE(t, e, r, n) { + return { name: t, prefix: e, encoder: { name: t, prefix: e, encode: r }, decoder: { decode: n } }; +} +const O3 = oE("utf8", "u", (t) => "u" + new TextDecoder("utf8").decode(t), (t) => new TextEncoder().encode(t.substring(1))), Jg = oE("ascii", "a", (t) => { + let e = "a"; + for (let r = 0; r < t.length; r++) e += String.fromCharCode(t[r]); + return e; +}, (t) => { + t = t.substring(1); + const e = Fz(t.length); + for (let r = 0; r < t.length; r++) e[r] = t.charCodeAt(r); + return e; +}), jz = { utf8: O3, "utf-8": O3, hex: D3.base16, latin1: Jg, ascii: Jg, binary: Jg, ...D3 }; +function Uz(t, e = "utf8") { + const r = jz[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(t, "utf8") : r.decoder.decode(`${r.prefix}${t}`); +} +let qz = class { + constructor(e, r) { + this.core = e, this.logger = r, this.keychain = /* @__PURE__ */ new Map(), this.name = qU, this.version = zU, this.initialized = !1, this.storagePrefix = Ds, this.init = async () => { + if (!this.initialized) { + const n = await this.getKeyChain(); + typeof n < "u" && (this.keychain = n), this.initialized = !0; + } + }, this.has = (n) => (this.isInitialized(), this.keychain.has(n)), this.set = async (n, i) => { + this.isInitialized(), this.keychain.set(n, i), await this.persist(); + }, this.get = (n) => { + this.isInitialized(); + const i = this.keychain.get(n); + if (typeof i > "u") { + const { message: s } = ft("NO_MATCHING_KEY", `${this.name}: ${n}`); + throw new Error(s); + } + return i; + }, this.del = async (n) => { + this.isInitialized(), this.keychain.delete(n), await this.persist(); + }, this.core = e, this.logger = ri(r, this.name); + } + get context() { + return mi(this.logger); + } + get storageKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; + } + async setKeyChain(e) { + await this.core.storage.setItem(this.storageKey, P8(e)); + } + async getKeyChain() { + const e = await this.core.storage.getItem(this.storageKey); + return typeof e < "u" ? M8(e) : void 0; + } + async persist() { + await this.setKeyChain(this.keychain); + } + isInitialized() { + if (!this.initialized) { + const { message: e } = ft("NOT_INITIALIZED", this.name); + throw new Error(e); + } + } +}, zz = class { + constructor(e, r, n) { + this.core = e, this.logger = r, this.name = jU, this.randomSessionIdentifier = sv(), this.initialized = !1, this.init = async () => { + this.initialized || (await this.keychain.init(), this.initialized = !0); + }, this.hasKeys = (i) => (this.isInitialized(), this.keychain.has(i)), this.getClientId = async () => { + this.isInitialized(); + const i = await this.getClientSeed(), s = N2(i); + return o8(s.publicKey); + }, this.generateKeyPair = () => { + this.isInitialized(); + const i = fj(); + return this.setPrivateKey(i.publicKey, i.privateKey); + }, this.signJWT = async (i) => { + this.isInitialized(); + const s = await this.getClientSeed(), o = N2(s), a = this.randomSessionIdentifier; + return await $$(a, i, UU, o); + }, this.generateSharedKey = (i, s, o) => { + this.isInitialized(); + const a = this.getPrivateKey(i), f = lj(a, s); + return this.setSymKey(f, o); + }, this.setSymKey = async (i, s) => { + this.isInitialized(); + const o = s || Wh(i); + return await this.keychain.set(o, i), o; + }, this.deleteKeyPair = async (i) => { + this.isInitialized(), await this.keychain.del(i); + }, this.deleteSymKey = async (i) => { + this.isInitialized(), await this.keychain.del(i); + }, this.encode = async (i, s, o) => { + this.isInitialized(); + const a = $8(o), f = ho(s); + if (s3(a)) return dj(f, o?.encoding); + if (i3(a)) { + const v = a.senderPublicKey, x = a.receiverPublicKey; + i = await this.generateSharedKey(v, x); + } + const u = this.getSymKey(i), { type: h, senderPublicKey: g } = a; + return hj({ type: h, symKey: u, message: f, senderPublicKey: g, encoding: o?.encoding }); + }, this.decode = async (i, s, o) => { + this.isInitialized(); + const a = mj(s, o); + if (s3(a)) { + const f = gj(s, o?.encoding); + return Na(f); + } + if (i3(a)) { + const f = a.receiverPublicKey, u = a.senderPublicKey; + i = await this.generateSharedKey(f, u); + } + try { + const f = this.getSymKey(i), u = pj({ symKey: f, encoded: s, encoding: o?.encoding }); + return Na(u); + } catch (f) { + this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${await this.getClientId()}'`), this.logger.error(f); + } + }, this.getPayloadType = (i, s = ko) => { + const o = Lf({ encoded: i, encoding: s }); + return $a(o.type); + }, this.getPayloadSenderPublicKey = (i, s = ko) => { + const o = Lf({ encoded: i, encoding: s }); + return o.senderPublicKey ? Tn(o.senderPublicKey, ti) : void 0; + }, this.core = e, this.logger = ri(r, this.name), this.keychain = n || new qz(this.core, this.logger); + } + get context() { + return mi(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(P3); + } catch { + e = sv(), await this.keychain.set(P3, e); + } + return Uz(e, "base16"); + } + getSymKey(e) { + return this.keychain.get(e); + } + isInitialized() { + if (!this.initialized) { + const { message: e } = ft("NOT_INITIALIZED", this.name); + throw new Error(e); + } + } +}; +class Hz extends fk { + constructor(e, r) { + super(e, r), this.logger = e, this.core = r, this.messages = /* @__PURE__ */ new Map(), this.name = HU, this.version = WU, this.initialized = !1, this.storagePrefix = Ds, this.init = async () => { + if (!this.initialized) { + this.logger.trace("Initialized"); + try { + const n = await this.getRelayerMessages(); + typeof n < "u" && (this.messages = n), this.logger.debug(`Successfully Restored records for ${this.name}`), this.logger.trace({ type: "method", method: "restore", size: this.messages.size }); + } catch (n) { + this.logger.debug(`Failed to Restore records for ${this.name}`), this.logger.error(n); + } finally { + this.initialized = !0; + } + } + }, this.set = async (n, i) => { + this.isInitialized(); + const s = Qs(i); + let o = this.messages.get(n); + return typeof o > "u" && (o = {}), typeof o[s] < "u" || (o[s] = i, this.messages.set(n, o), await this.persist()), s; + }, this.get = (n) => { + this.isInitialized(); + let i = this.messages.get(n); + return typeof i > "u" && (i = {}), i; + }, this.has = (n, i) => { + this.isInitialized(); + const s = this.get(n), o = Qs(i); + return typeof s[o] < "u"; + }, this.del = async (n) => { + this.isInitialized(), this.messages.delete(n), await this.persist(); + }, this.logger = ri(e, this.name), this.core = r; + } + get context() { + return mi(this.logger); + } + get storageKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//" + this.name; + } + async setRelayerMessages(e) { + await this.core.storage.setItem(this.storageKey, P8(e)); + } + async getRelayerMessages() { + const e = await this.core.storage.getItem(this.storageKey); + return typeof e < "u" ? M8(e) : void 0; + } + async persist() { + await this.setRelayerMessages(this.messages); + } + isInitialized() { + if (!this.initialized) { + const { message: e } = ft("NOT_INITIALIZED", this.name); + throw new Error(e); + } + } +} +class Wz extends lk { + constructor(e, r) { + super(e, r), this.relayer = e, this.logger = r, this.events = new Wi.EventEmitter(), this.name = VU, this.queue = /* @__PURE__ */ new Map(), this.publishTimeout = bt.toMiliseconds(bt.ONE_MINUTE), this.failedPublishTimeout = bt.toMiliseconds(bt.ONE_SECOND), this.needsTransportRestart = !1, this.publish = async (n, i, s) => { + var o; + this.logger.debug("Publishing Payload"), this.logger.trace({ type: "method", method: "publish", params: { topic: n, message: i, opts: s } }); + const a = s?.ttl || KU, f = ov(s), u = s?.prompt || !1, h = s?.tag || 0, g = s?.id || Ma().toString(), v = { topic: n, message: i, opts: { ttl: a, relay: f, prompt: u, tag: h, id: g, attestation: s?.attestation } }, x = `Failed to publish payload, please try again. id:${g} tag:${h}`, S = Date.now(); + let R, D = 1; + try { + for (; R === void 0; ) { + if (Date.now() - S > this.publishTimeout) throw new Error(x); + this.logger.trace({ id: g, attempts: D }, `publisher.publish - attempt ${D}`), R = await await Lc(this.rpcPublish(n, i, a, f, u, h, g, s?.attestation).catch((k) => this.logger.warn(k)), this.publishTimeout, x), D++, R || await new Promise((k) => setTimeout(k, this.failedPublishTimeout)); + } + this.relayer.events.emit(Qn.publish, v), this.logger.debug("Successfully Published Payload"), this.logger.trace({ type: "method", method: "publish", params: { id: g, topic: n, message: i, opts: s } }); + } catch (k) { + if (this.logger.debug("Failed to Publish Payload"), this.logger.error(k), (o = s?.internal) != null && o.throwOnFailedPublish) throw k; + this.queue.set(g, v); + } + }, this.on = (n, i) => { + this.events.on(n, i); + }, this.once = (n, i) => { + this.events.once(n, i); + }, this.off = (n, i) => { + this.events.off(n, i); + }, this.removeListener = (n, i) => { + this.events.removeListener(n, i); + }, this.relayer = e, this.logger = ri(r, this.name), this.registerEventListeners(); + } + get context() { + return mi(this.logger); + } + rpcPublish(e, r, n, i, s, o, a, f) { + var u, h, g, v; + const x = { method: Vu(i.protocol).publish, params: { topic: e, message: r, ttl: n, prompt: s, tag: o, attestation: f }, id: a }; + return ei((u = x.params) == null ? void 0 : u.prompt) && ((h = x.params) == null || delete h.prompt), ei((g = x.params) == null ? void 0 : g.tag) && ((v = x.params) == null || delete v.tag), this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "message", direction: "outgoing", request: x }), this.relayer.request(x); + } + removeRequestFromQueue(e) { + this.queue.delete(e); + } + checkQueue() { + this.queue.forEach(async (e) => { + const { topic: r, message: n, opts: i } = e; + await this.publish(r, n, i); + }); + } + registerEventListeners() { + this.relayer.core.heartbeat.on(Vc.pulse, () => { + if (this.needsTransportRestart) { + this.needsTransportRestart = !1, this.relayer.events.emit(Qn.connection_stalled); + return; + } + this.checkQueue(); + }), this.relayer.on(Qn.message_ack, (e) => { + this.removeRequestFromQueue(e.id.toString()); + }); + } +} +class Kz { + constructor() { + this.map = /* @__PURE__ */ new Map(), this.set = (e, r) => { + const n = this.get(e); + this.exists(e, r) || this.map.set(e, [...n, 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; + const n = this.get(e); + if (!this.exists(e, r)) return; + const i = n.filter((s) => s !== r); + if (!i.length) { + this.map.delete(e); + return; + } + this.map.set(e, i); + }, this.clear = () => { + this.map.clear(); + }; + } + get topics() { + return Array.from(this.map.keys()); + } +} +var Vz = Object.defineProperty, Gz = Object.defineProperties, Yz = Object.getOwnPropertyDescriptors, N3 = Object.getOwnPropertySymbols, Jz = Object.prototype.hasOwnProperty, Xz = Object.prototype.propertyIsEnumerable, L3 = (t, e, r) => e in t ? Vz(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, $u = (t, e) => { + for (var r in e || (e = {})) Jz.call(e, r) && L3(t, r, e[r]); + if (N3) for (var r of N3(e)) Xz.call(e, r) && L3(t, r, e[r]); + return t; +}, Xg = (t, e) => Gz(t, Yz(e)); +class Zz extends pk { + constructor(e, r) { + super(e, r), this.relayer = e, this.logger = r, this.subscriptions = /* @__PURE__ */ new Map(), this.topicMap = new Kz(), this.events = new Wi.EventEmitter(), this.name = eq, this.version = tq, this.pending = /* @__PURE__ */ new Map(), this.cached = [], this.initialized = !1, this.pendingSubscriptionWatchLabel = "pending_sub_watch_label", this.pollingInterval = 20, this.storagePrefix = Ds, this.subscribeTimeout = bt.toMiliseconds(bt.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 (n, i) => { + this.isInitialized(), this.logger.debug("Subscribing Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: n, opts: i } }); + try { + const s = ov(i), o = { topic: n, relay: s, transportType: i?.transportType }; + this.pending.set(n, o); + const a = await this.rpcSubscribe(n, s, i); + return typeof a == "string" && (this.onSubscribe(a, o), this.logger.debug("Successfully Subscribed Topic"), this.logger.trace({ type: "method", method: "subscribe", params: { topic: n, opts: i } })), a; + } catch (s) { + throw this.logger.debug("Failed to Subscribe Topic"), this.logger.error(s), s; + } + }, this.unsubscribe = async (n, i) => { + await this.restartToComplete(), this.isInitialized(), typeof i?.id < "u" ? await this.unsubscribeById(n, i.id, i) : await this.unsubscribeByTopic(n, i); + }, this.isSubscribed = async (n) => { + if (this.topics.includes(n)) return !0; + const i = `${this.pendingSubscriptionWatchLabel}_${n}`; + return await new Promise((s, o) => { + const a = new bt.Watch(); + a.start(i); + const f = setInterval(() => { + !this.pending.has(n) && this.topics.includes(n) && (clearInterval(f), a.stop(i), s(!0)), a.elapsed(i) >= rq && (clearInterval(f), a.stop(i), o(new Error("Subscription resolution timeout"))); + }, this.pollingInterval); + }).catch(() => !1); + }, this.on = (n, i) => { + this.events.on(n, i); + }, this.once = (n, i) => { + this.events.once(n, i); + }, this.off = (n, i) => { + this.events.off(n, i); + }, this.removeListener = (n, i) => { + this.events.removeListener(n, i); + }, 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 = ri(r, this.name), this.clientId = ""; + } + get context() { + return mi(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 n = !1; + try { + n = this.getSubscription(e).topic === r; + } catch { + } + return n; + } + onEnable() { + this.cached = [], this.initialized = !0; + } + onDisable() { + this.cached = this.values, this.subscriptions.clear(), this.topicMap.clear(); + } + async unsubscribeByTopic(e, r) { + const n = this.topicMap.get(e); + await Promise.all(n.map(async (i) => await this.unsubscribeById(e, i, r))); + } + async unsubscribeById(e, r, n) { + this.logger.debug("Unsubscribing Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: r, opts: n } }); + try { + const i = ov(n); + await this.rpcUnsubscribe(e, r, i); + const s = Nr("USER_DISCONNECTED", `${this.name}, ${e}`); + await this.onUnsubscribe(e, r, s), this.logger.debug("Successfully Unsubscribed Topic"), this.logger.trace({ type: "method", method: "unsubscribe", params: { topic: e, id: r, opts: n } }); + } catch (i) { + throw this.logger.debug("Failed to Unsubscribe Topic"), this.logger.error(i), i; + } + } + async rpcSubscribe(e, r, n) { + var i; + n?.transportType === Wr.relay && await this.restartToComplete(); + const s = { method: Vu(r.protocol).subscribe, params: { topic: e } }; + this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: s }); + const o = (i = n?.internal) == null ? void 0 : i.throwOnFailedPublish; + try { + const a = Qs(e + this.clientId); + if (n?.transportType === Wr.link_mode) return setTimeout(() => { + (this.relayer.connected || this.relayer.connecting) && this.relayer.request(s).catch((u) => this.logger.warn(u)); + }, bt.toMiliseconds(bt.ONE_SECOND)), a; + const f = await Lc(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(Qn.connection_stalled), o) throw a; + } + return null; + } + async rpcBatchSubscribe(e) { + if (!e.length) return; + const r = e[0].relay, n = { method: Vu(r.protocol).batchSubscribe, params: { topics: e.map((i) => i.topic) } }; + this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: n }); + try { + return await await Lc(this.relayer.request(n).catch((i) => this.logger.warn(i)), this.subscribeTimeout); + } catch { + this.relayer.events.emit(Qn.connection_stalled); + } + } + async rpcBatchFetchMessages(e) { + if (!e.length) return; + const r = e[0].relay, n = { method: Vu(r.protocol).batchFetchMessages, params: { topics: e.map((s) => s.topic) } }; + this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: n }); + let i; + try { + i = await await Lc(this.relayer.request(n).catch((s) => this.logger.warn(s)), this.subscribeTimeout); + } catch { + this.relayer.events.emit(Qn.connection_stalled); + } + return i; + } + rpcUnsubscribe(e, r, n) { + const i = { method: Vu(n.protocol).unsubscribe, params: { topic: e, id: r } }; + return this.logger.debug("Outgoing Relay Payload"), this.logger.trace({ type: "payload", direction: "outgoing", request: i }), this.relayer.request(i); + } + onSubscribe(e, r) { + this.setSubscription(e, Xg($u({}, r), { id: e })), this.pending.delete(r.topic); + } + onBatchSubscribe(e) { + e.length && e.forEach((r) => { + this.setSubscription(r.id, $u({}, r)), this.pending.delete(r.topic); + }); + } + async onUnsubscribe(e, r, n) { + this.events.removeAllListeners(r), this.hasSubscription(r, e) && this.deleteSubscription(r, n), 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, $u({}, r)), this.topicMap.set(r.topic, e), this.events.emit(Ms.created, r); + } + getSubscription(e) { + this.logger.debug("Getting subscription"), this.logger.trace({ type: "method", method: "getSubscription", id: e }); + const r = this.subscriptions.get(e); + if (!r) { + const { message: n } = ft("NO_MATCHING_KEY", `${this.name}: ${e}`); + throw new Error(n); + } + return r; + } + deleteSubscription(e, r) { + this.logger.debug("Deleting subscription"), this.logger.trace({ type: "method", method: "deleteSubscription", id: e, reason: r }); + const n = this.getSubscription(e); + this.subscriptions.delete(e), this.topicMap.delete(n.topic, e), this.events.emit(Ms.deleted, Xg($u({}, n), { reason: r })); + } + async persist() { + await this.setRelayerSubscriptions(this.values), this.events.emit(Ms.sync); + } + async reset() { + if (this.cached.length) { + const e = Math.ceil(this.cached.length / this.batchSubscribeTopicsLimit); + for (let r = 0; r < e; r++) { + const n = this.cached.splice(0, this.batchSubscribeTopicsLimit); + await this.batchFetchMessages(n), await this.batchSubscribe(n); + } + } + this.events.emit(Ms.resubscribed); + } + async restore() { + try { + const e = await this.getRelayerSubscriptions(); + if (typeof e > "u" || !e.length) return; + if (this.subscriptions.size) { + const { message: r } = ft("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; + const r = await this.rpcBatchSubscribe(e); + Ba(r) && this.onBatchSubscribe(r.map((n, i) => Xg($u({}, e[i]), { id: n }))); + } + async batchFetchMessages(e) { + if (!e.length) return; + this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`); + const 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; + const 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(Vc.pulse, async () => { + await this.checkPending(); + }), this.events.on(Ms.created, async (e) => { + const r = Ms.created; + this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), await this.persist(); + }), this.events.on(Ms.deleted, async (e) => { + const r = Ms.deleted; + this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), await this.persist(); + }); + } + isInitialized() { + if (!this.initialized) { + const { message: e } = ft("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) => { + const r = setInterval(() => { + this.restartInProgress || (clearInterval(r), e()); + }, this.pollingInterval); + }); + } +} +var Qz = Object.defineProperty, k3 = Object.getOwnPropertySymbols, eH = Object.prototype.hasOwnProperty, tH = Object.prototype.propertyIsEnumerable, $3 = (t, e, r) => e in t ? Qz(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, B3 = (t, e) => { + for (var r in e || (e = {})) eH.call(e, r) && $3(t, r, e[r]); + if (k3) for (var r of k3(e)) tH.call(e, r) && $3(t, r, e[r]); + return t; +}; +class rH extends hk { + constructor(e) { + super(e), this.protocol = "wc", this.version = 2, this.events = new Wi.EventEmitter(), this.name = YU, this.transportExplicitlyClosed = !1, this.initialized = !1, this.connectionAttemptInProgress = !1, this.connectionStatusPollingInterval = 20, this.staleConnectionErrors = ["socket hang up", "stalled", "interrupted"], this.hasExperiencedNetworkDisruption = !1, this.requestsInFlight = /* @__PURE__ */ new Map(), this.heartBeatTimeout = bt.toMiliseconds(bt.THIRTY_SECONDS + bt.ONE_SECOND), this.request = async (r) => { + var n, i; + this.logger.debug("Publishing Request Payload"); + const s = r.id || Ma().toString(); + await this.toEstablishConnection(); + try { + const o = this.provider.request(r); + this.requestsInFlight.set(s, { promise: o, request: r }), this.logger.trace({ id: s, method: r.method, topic: (n = r.params) == null ? void 0 : n.topic }, "relayer.request - attempt to publish..."); + const a = await new Promise(async (f, u) => { + const h = () => { + u(new Error(`relayer.request - publish interrupted, id: ${s}`)); + }; + this.provider.on($i.disconnect, h); + const g = await o; + this.provider.off($i.disconnect, h), f(g); + }); + return this.logger.trace({ id: s, method: r.method, topic: (i = r.params) == null ? void 0 : i.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 (xd()) try { + clearTimeout(this.pingTimeout), this.pingTimeout = setTimeout(() => { + var r, n, i; + (i = (n = (r = this.provider) == null ? void 0 : r.connection) == null ? void 0 : n.socket) == null || i.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(Qn.connect); + }, this.onDisconnectHandler = () => { + this.logger.trace("relayer disconnected"), this.onProviderDisconnect(); + }, this.onProviderErrorHandler = (r) => { + this.logger.error(r), this.events.emit(Qn.error, r), this.logger.info("Fatal socket error received, closing transport"), this.transportClose(); + }, this.registerProviderListeners = () => { + this.provider.on($i.payload, this.onPayloadHandler), this.provider.on($i.connect, this.onConnectHandler), this.provider.on($i.disconnect, this.onDisconnectHandler), this.provider.on($i.error, this.onProviderErrorHandler); + }, this.core = e.core, this.logger = typeof e.logger < "u" && typeof e.logger != "string" ? ri(e.logger, this.name) : Xf(Vd({ level: e.logger || GU })), this.messages = new Hz(this.logger, e.core), this.subscriber = new Zz(this, this.logger), this.publisher = new Wz(this, this.logger), this.relayUrl = e?.relayUrl || Y8, this.projectId = e.projectId, this.bundleId = IF(), 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 mi(this.logger); + } + get connected() { + var e, r, n; + return ((n = (r = (e = this.provider) == null ? void 0 : e.connection) == null ? void 0 : r.socket) == null ? void 0 : n.readyState) === 1; + } + get connecting() { + var e, r, n; + return ((n = (r = (e = this.provider) == null ? void 0 : e.connection) == null ? void 0 : r.socket) == null ? void 0 : n.readyState) === 0; + } + async publish(e, r, n) { + this.isInitialized(), await this.publisher.publish(e, r, n), await this.recordMessageEvent({ topic: e, message: r, publishedAt: Date.now(), transportType: Wr.relay }); + } + async subscribe(e, r) { + var n, i, s; + this.isInitialized(), r?.transportType === "relay" && await this.toEstablishConnection(); + const o = typeof ((n = r?.internal) == null ? void 0 : n.throwOnFailedPublish) > "u" ? !0 : (i = r?.internal) == null ? void 0 : i.throwOnFailedPublish; + let a = ((s = this.subscriber.topicMap.get(e)) == null ? void 0 : s[0]) || "", f; + const u = (h) => { + h.topic === e && (this.subscriber.off(Ms.created, u), f()); + }; + return await Promise.all([new Promise((h) => { + f = h, this.subscriber.on(Ms.created, u); + }), new Promise(async (h, g) => { + a = await this.subscriber.subscribe(e, B3({ internal: { throwOnFailedPublish: o } }, r)).catch((v) => { + o && g(v); + }) || a, h(); + })]), 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.provider.disconnect && (this.hasExperiencedNetworkDisruption || this.connected) ? await Lc(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, n) => { + const i = () => { + this.provider.off($i.disconnect, i), n(new Error("Connection interrupted while trying to subscribe")); + }; + this.provider.on($i.disconnect, i), await Lc(this.provider.connect(), bt.toMiliseconds(bt.ONE_MINUTE), `Socket stalled when trying to connect to ${this.relayUrl}`).catch((s) => { + n(s); + }).finally(() => { + clearTimeout(this.reconnectTimeout), this.reconnectTimeout = void 0; + }), this.subscriber.start().catch((s) => { + this.logger.error(s), this.onDisconnectHandler(); + }), this.hasExperiencedNetworkDisruption = !1, r(); + }); + } catch (r) { + this.logger.error(r); + const n = r; + if (this.hasExperiencedNetworkDisruption = !0, !this.isConnectionStalled(n.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 m3()) 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; + } + const r = e.sort((n, i) => n.publishedAt - i.publishedAt); + this.logger.trace(`Batch of ${r.length} message events sorted`); + for (const n of r) try { + await this.onMessageEvent(n); + } catch (i) { + this.logger.warn(i); + } + this.logger.trace(`Batch of ${r.length} message events processed`); + } + async onLinkMessageEvent(e, r) { + const { topic: n } = e; + if (!r.sessionExists) { + const i = _n(bt.FIVE_MINUTES), s = { topic: n, expiry: i, relay: { protocol: "irn" }, active: !1 }; + await this.core.pairing.pairings.set(n, s); + } + this.events.emit(Qn.message, e), await this.recordMessageEvent(e); + } + startPingTimeout() { + var e, r, n, i, s; + if (xd()) try { + (r = (e = this.provider) == null ? void 0 : e.connection) != null && r.socket && ((s = (i = (n = this.provider) == null ? void 0 : n.connection) == null ? void 0 : i.socket) == null || s.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(); + const e = await this.core.crypto.signJWT(this.relayUrl); + this.provider = new Yi(new NU(DF({ sdkVersion: av, protocol: this.protocol, version: this.version, relayUrl: this.relayUrl, projectId: this.projectId, auth: e, useOnCloseEvent: !0, bundleId: this.bundleId }))), this.registerProviderListeners(); + } + async recordMessageEvent(e) { + const { topic: r, message: n } = e; + await this.messages.set(r, n); + } + async shouldIgnoreMessageEvent(e) { + const { topic: r, message: n } = e; + if (!n || n.length === 0) return this.logger.debug(`Ignoring invalid/empty message: ${n}`), !0; + if (!await this.subscriber.isSubscribed(r)) return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`), !0; + const i = this.messages.has(r, n); + return i && this.logger.debug(`Ignoring duplicate message: ${n}`), i; + } + async onProviderPayload(e) { + if (this.logger.debug("Incoming Relay Payload"), this.logger.trace({ type: "payload", direction: "incoming", payload: e }), I1(e)) { + if (!e.method.endsWith(JU)) return; + const r = e.params, { topic: n, message: i, publishedAt: s, attestation: o } = r.data, a = { topic: n, message: i, publishedAt: s, transportType: Wr.relay, attestation: o }; + this.logger.debug("Emitting Relayer Payload"), this.logger.trace(B3({ type: "event", event: r.id }, a)), this.events.emit(r.id, a), await this.acknowledgePayload(e), await this.onMessageEvent(a); + } else i0(e) && this.events.emit(Qn.message_ack, e); + } + async onMessageEvent(e) { + await this.shouldIgnoreMessageEvent(e) || (this.events.emit(Qn.message, e), await this.recordMessageEvent(e)); + } + async acknowledgePayload(e) { + const r = r0(e.id, !0); + await this.provider.connection.send(r); + } + unregisterProviderListeners() { + this.provider.off($i.payload, this.onPayloadHandler), this.provider.off($i.connect, this.onConnectHandler), this.provider.off($i.disconnect, this.onDisconnectHandler), this.provider.off($i.error, this.onProviderErrorHandler), clearTimeout(this.pingTimeout); + } + async registerEventListeners() { + let e = await m3(); + uU(async (r) => { + e !== r && (e = r, r ? await this.restartTransport().catch((n) => this.logger.error(n)) : (this.hasExperiencedNetworkDisruption = !0, await this.transportDisconnect(), this.transportExplicitlyClosed = !1)); + }); + } + async onProviderDisconnect() { + await this.subscriber.stop(), this.requestsInFlight.clear(), clearTimeout(this.pingTimeout), this.events.emit(Qn.disconnect), this.connectionAttemptInProgress = !1, !this.transportExplicitlyClosed && (this.reconnectTimeout || (this.reconnectTimeout = setTimeout(async () => { + await this.transportOpen().catch((e) => this.logger.error(e)); + }, bt.toMiliseconds(XU)))); + } + isInitialized() { + if (!this.initialized) { + const { message: e } = ft("NOT_INITIALIZED", this.name); + throw new Error(e); + } + } + async toEstablishConnection() { + await this.confirmOnlineStateOrThrow(), !this.connected && (this.connectionAttemptInProgress && await new Promise((e) => { + const r = setInterval(() => { + this.connected && (clearInterval(r), e()); + }, this.connectionStatusPollingInterval); + }), await this.transportOpen()); + } +} +var nH = Object.defineProperty, F3 = Object.getOwnPropertySymbols, iH = Object.prototype.hasOwnProperty, sH = Object.prototype.propertyIsEnumerable, j3 = (t, e, r) => e in t ? nH(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, U3 = (t, e) => { + for (var r in e || (e = {})) iH.call(e, r) && j3(t, r, e[r]); + if (F3) for (var r of F3(e)) sH.call(e, r) && j3(t, r, e[r]); + return t; +}; +class Va extends dk { + constructor(e, r, n, i = Ds, s = void 0) { + super(e, r, n, i), this.core = e, this.logger = r, this.name = n, this.map = /* @__PURE__ */ new Map(), this.version = ZU, this.cached = [], this.initialized = !1, this.storagePrefix = Ds, 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 && !ei(o) ? this.map.set(this.getKey(o), o) : jj(o) ? this.map.set(o.id, o) : Uj(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) => $U(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 }); + const f = U3(U3({}, 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 = ri(r, this.name), this.storagePrefix = i, this.getKey = s; + } + get context() { + return mi(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) { + const r = this.map.get(e); + if (!r) { + if (this.recentlyDeleted.includes(e)) { + const { message: i } = ft("MISSING_OR_INVALID", `Record was recently deleted - ${this.name}: ${e}`); + throw this.logger.error(i), new Error(i); + } + const { message: n } = ft("NO_MATCHING_KEY", `${this.name}: ${e}`); + throw this.logger.error(n), new Error(n); + } + return r; + } + async persist() { + await this.setDataStore(this.values); + } + async restore() { + try { + const e = await this.getDataStore(); + if (typeof e > "u" || !e.length) return; + if (this.map.size) { + const { message: r } = ft("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) { + const { message: e } = ft("NOT_INITIALIZED", this.name); + throw new Error(e); + } + } +} +class oH { + constructor(e, r) { + this.core = e, this.logger = r, this.name = nq, this.version = iq, this.events = new l1(), this.initialized = !1, this.storagePrefix = Ds, this.ignoredPayloadTypes = [so], 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: n }) => { + this.isInitialized(), this.registeredMethods = [.../* @__PURE__ */ new Set([...this.registeredMethods, ...n])]; + }, this.create = async (n) => { + this.isInitialized(); + const i = sv(), s = await this.core.crypto.setSymKey(i), o = _n(bt.FIVE_MINUTES), a = { protocol: G8 }, f = { topic: s, expiry: o, relay: a, active: !1, methods: n?.methods }, u = f3({ protocol: this.core.protocol, version: this.core.version, topic: s, symKey: i, relay: a, expiryTimestamp: o, methods: n?.methods }); + return this.events.emit(_a.create, f), this.core.expirer.set(s, o), await this.pairings.set(s, f), await this.core.relayer.subscribe(s, { transportType: n?.transportType }), { topic: s, uri: u }; + }, this.pair = async (n) => { + this.isInitialized(); + const i = this.core.eventClient.createEvent({ properties: { topic: n?.uri, trace: [As.pairing_started] } }); + this.isValidPair(n, i); + const { topic: s, symKey: o, relay: a, expiryTimestamp: f, methods: u } = u3(n.uri); + i.props.properties.topic = s, i.addTrace(As.pairing_uri_validation_success), i.addTrace(As.pairing_uri_not_expired); + let h; + if (this.pairings.keys.includes(s)) { + if (h = this.pairings.get(s), i.addTrace(As.existing_pairing), h.active) throw i.setError(Zs.active_pairing_already_exists), new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`); + i.addTrace(As.pairing_not_expired); + } + const g = f || _n(bt.FIVE_MINUTES), v = { topic: s, relay: a, expiry: g, active: !1, methods: u }; + this.core.expirer.set(s, g), await this.pairings.set(s, v), i.addTrace(As.store_new_pairing), n.activatePairing && await this.activate({ topic: s }), this.events.emit(_a.create, v), i.addTrace(As.emit_inactive_pairing), this.core.crypto.keychain.has(s) || await this.core.crypto.setSymKey(o, s), i.addTrace(As.subscribing_pairing_topic); + try { + await this.core.relayer.confirmOnlineStateOrThrow(); + } catch { + i.setError(Zs.no_internet_connection); + } + try { + await this.core.relayer.subscribe(s, { relay: a }); + } catch (x) { + throw i.setError(Zs.subscribe_pairing_topic_failure), x; + } + return i.addTrace(As.subscribe_pairing_topic_success), v; + }, this.activate = async ({ topic: n }) => { + this.isInitialized(); + const i = _n(bt.THIRTY_DAYS); + this.core.expirer.set(n, i), await this.pairings.update(n, { active: !0, expiry: i }); + }, this.ping = async (n) => { + this.isInitialized(), await this.isValidPing(n); + const { topic: i } = n; + if (this.pairings.keys.includes(i)) { + const s = await this.sendRequest(i, "wc_pairingPing", {}), { done: o, resolve: a, reject: f } = ba(); + this.events.once(wr("pairing_ping", s), ({ error: u }) => { + u ? f(u) : a(); + }), await o(); + } + }, this.updateExpiry = async ({ topic: n, expiry: i }) => { + this.isInitialized(), await this.pairings.update(n, { expiry: i }); + }, this.updateMetadata = async ({ topic: n, metadata: i }) => { + this.isInitialized(), await this.pairings.update(n, { peerMetadata: i }); + }, this.getPairings = () => (this.isInitialized(), this.pairings.values), this.disconnect = async (n) => { + this.isInitialized(), await this.isValidDisconnect(n); + const { topic: i } = n; + this.pairings.keys.includes(i) && (await this.sendRequest(i, "wc_pairingDelete", Nr("USER_DISCONNECTED")), await this.deletePairing(i)); + }, this.formatUriFromPairing = (n) => { + this.isInitialized(); + const { topic: i, relay: s, expiry: o, methods: a } = n, f = this.core.crypto.keychain.get(i); + return f3({ protocol: this.core.protocol, version: this.core.version, topic: i, symKey: f, relay: s, expiryTimestamp: o, methods: a }); + }, this.sendRequest = async (n, i, s) => { + const o = $o(i, s), a = await this.core.crypto.encode(n, o), f = Lu[i].req; + return this.core.history.set(n, o), this.core.relayer.publish(n, a, f), o.id; + }, this.sendResult = async (n, i, s) => { + const o = r0(n, s), a = await this.core.crypto.encode(i, o), f = await this.core.history.get(i, n), u = Lu[f.request.method].res; + await this.core.relayer.publish(i, a, u), await this.core.history.resolve(o); + }, this.sendError = async (n, i, s) => { + const o = n0(n, s), a = await this.core.crypto.encode(i, o), f = await this.core.history.get(i, n), u = Lu[f.request.method] ? Lu[f.request.method].res : Lu.unregistered_method.res; + await this.core.relayer.publish(i, a, u), await this.core.history.resolve(o); + }, this.deletePairing = async (n, i) => { + await this.core.relayer.unsubscribe(n), await Promise.all([this.pairings.delete(n, Nr("USER_DISCONNECTED")), this.core.crypto.deleteSymKey(n), i ? Promise.resolve() : this.core.expirer.del(n)]); + }, this.cleanup = async () => { + const n = this.pairings.getAll().filter((i) => Oo(i.expiry)); + await Promise.all(n.map((i) => this.deletePairing(i.topic))); + }, this.onRelayEventRequest = (n) => { + const { topic: i, payload: s } = n; + switch (s.method) { + case "wc_pairingPing": + return this.onPairingPingRequest(i, s); + case "wc_pairingDelete": + return this.onPairingDeleteRequest(i, s); + default: + return this.onUnknownRpcMethodRequest(i, s); + } + }, this.onRelayEventResponse = async (n) => { + const { topic: i, payload: s } = n, o = (await this.core.history.get(i, s.id)).request.method; + switch (o) { + case "wc_pairingPing": + return this.onPairingPingResponse(i, s); + default: + return this.onUnknownRpcMethodResponse(o); + } + }, this.onPairingPingRequest = async (n, i) => { + const { id: s } = i; + try { + this.isValidPing({ topic: n }), await this.sendResult(s, n, !0), this.events.emit(_a.ping, { id: s, topic: n }); + } catch (o) { + await this.sendError(s, n, o), this.logger.error(o); + } + }, this.onPairingPingResponse = (n, i) => { + const { id: s } = i; + setTimeout(() => { + Ps(i) ? this.events.emit(wr("pairing_ping", s), {}) : qi(i) && this.events.emit(wr("pairing_ping", s), { error: i.error }); + }, 500); + }, this.onPairingDeleteRequest = async (n, i) => { + const { id: s } = i; + try { + this.isValidDisconnect({ topic: n }), await this.deletePairing(n), this.events.emit(_a.delete, { id: s, topic: n }); + } catch (o) { + await this.sendError(s, n, o), this.logger.error(o); + } + }, this.onUnknownRpcMethodRequest = async (n, i) => { + const { id: s, method: o } = i; + try { + if (this.registeredMethods.includes(o)) return; + const a = Nr("WC_METHOD_UNSUPPORTED", o); + await this.sendError(s, n, a), this.logger.error(a); + } catch (a) { + await this.sendError(s, n, a), this.logger.error(a); + } + }, this.onUnknownRpcMethodResponse = (n) => { + this.registeredMethods.includes(n) || this.logger.error(Nr("WC_METHOD_UNSUPPORTED", n)); + }, this.isValidPair = (n, i) => { + var s; + if (!ui(n)) { + const { message: a } = ft("MISSING_OR_INVALID", `pair() params: ${n}`); + throw i.setError(Zs.malformed_pairing_uri), new Error(a); + } + if (!Fj(n.uri)) { + const { message: a } = ft("MISSING_OR_INVALID", `pair() uri: ${n.uri}`); + throw i.setError(Zs.malformed_pairing_uri), new Error(a); + } + const o = u3(n?.uri); + if (!((s = o?.relay) != null && s.protocol)) { + const { message: a } = ft("MISSING_OR_INVALID", "pair() uri#relay-protocol"); + throw i.setError(Zs.malformed_pairing_uri), new Error(a); + } + if (!(o != null && o.symKey)) { + const { message: a } = ft("MISSING_OR_INVALID", "pair() uri#symKey"); + throw i.setError(Zs.malformed_pairing_uri), new Error(a); + } + if (o != null && o.expiryTimestamp && bt.toMiliseconds(o?.expiryTimestamp) < Date.now()) { + i.setError(Zs.pairing_expired); + const { message: a } = ft("EXPIRED", "pair() URI has expired. Please try again with a new connection URI."); + throw new Error(a); + } + }, this.isValidPing = async (n) => { + if (!ui(n)) { + const { message: s } = ft("MISSING_OR_INVALID", `ping() params: ${n}`); + throw new Error(s); + } + const { topic: i } = n; + await this.isValidPairingTopic(i); + }, this.isValidDisconnect = async (n) => { + if (!ui(n)) { + const { message: s } = ft("MISSING_OR_INVALID", `disconnect() params: ${n}`); + throw new Error(s); + } + const { topic: i } = n; + await this.isValidPairingTopic(i); + }, this.isValidPairingTopic = async (n) => { + if (!hn(n, !1)) { + const { message: i } = ft("MISSING_OR_INVALID", `pairing topic should be a string: ${n}`); + throw new Error(i); + } + if (!this.pairings.keys.includes(n)) { + const { message: i } = ft("NO_MATCHING_KEY", `pairing topic doesn't exist: ${n}`); + throw new Error(i); + } + if (Oo(this.pairings.get(n).expiry)) { + await this.deletePairing(n); + const { message: i } = ft("EXPIRED", `pairing topic: ${n}`); + throw new Error(i); + } + }, this.core = e, this.logger = ri(r, this.name), this.pairings = new Va(this.core, this.logger, this.name, this.storagePrefix); + } + get context() { + return mi(this.logger); + } + isInitialized() { + if (!this.initialized) { + const { message: e } = ft("NOT_INITIALIZED", this.name); + throw new Error(e); + } + } + registerRelayerEvents() { + this.core.relayer.on(Qn.message, async (e) => { + const { topic: r, message: n, transportType: i } = e; + if (!this.pairings.keys.includes(r) || i === Wr.link_mode || this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n))) return; + const s = await this.core.crypto.decode(r, n); + try { + I1(s) ? (this.core.history.set(r, s), this.onRelayEventRequest({ topic: r, payload: s })) : i0(s) && (await this.core.history.resolve(s), await this.onRelayEventResponse({ topic: r, payload: s }), this.core.history.delete(r, s.id)); + } catch (o) { + this.logger.error(o); + } + }); + } + registerExpirerEvents() { + this.core.expirer.on(ji.expired, async (e) => { + const { topic: r } = C8(e.target); + r && this.pairings.keys.includes(r) && (await this.deletePairing(r, !0), this.events.emit(_a.expire, { topic: r })); + }); + } +} +class aH extends uk { + constructor(e, r) { + super(e, r), this.core = e, this.logger = r, this.records = /* @__PURE__ */ new Map(), this.events = new Wi.EventEmitter(), this.name = sq, this.version = oq, this.cached = [], this.initialized = !1, this.storagePrefix = Ds, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((n) => this.records.set(n.id, n)), this.cached = [], this.registerEventListeners(), this.initialized = !0); + }, this.set = (n, i, s) => { + if (this.isInitialized(), this.logger.debug("Setting JSON-RPC request history record"), this.logger.trace({ type: "method", method: "set", topic: n, request: i, chainId: s }), this.records.has(i.id)) return; + const o = { id: i.id, topic: n, request: { method: i.method, params: i.params || null }, chainId: s, expiry: _n(bt.THIRTY_DAYS) }; + this.records.set(o.id, o), this.persist(), this.events.emit(ns.created, o); + }, this.resolve = async (n) => { + if (this.isInitialized(), this.logger.debug("Updating JSON-RPC response history record"), this.logger.trace({ type: "method", method: "update", response: n }), !this.records.has(n.id)) return; + const i = await this.getRecord(n.id); + typeof i.response > "u" && (i.response = qi(n) ? { error: n.error } : { result: n.result }, this.records.set(i.id, i), this.persist(), this.events.emit(ns.updated, i)); + }, this.get = async (n, i) => (this.isInitialized(), this.logger.debug("Getting record"), this.logger.trace({ type: "method", method: "get", topic: n, id: i }), await this.getRecord(i)), this.delete = (n, i) => { + this.isInitialized(), this.logger.debug("Deleting record"), this.logger.trace({ type: "method", method: "delete", id: i }), this.values.forEach((s) => { + if (s.topic === n) { + if (typeof i < "u" && s.id !== i) return; + this.records.delete(s.id), this.events.emit(ns.deleted, s); + } + }), this.persist(); + }, this.exists = async (n, i) => (this.isInitialized(), this.records.has(i) ? (await this.getRecord(i)).topic === n : !1), this.on = (n, i) => { + this.events.on(n, i); + }, this.once = (n, i) => { + this.events.once(n, i); + }, this.off = (n, i) => { + this.events.off(n, i); + }, this.removeListener = (n, i) => { + this.events.removeListener(n, i); + }, this.logger = ri(r, this.name); + } + get context() { + return mi(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() { + const e = []; + return this.values.forEach((r) => { + if (typeof r.response < "u") return; + const n = { topic: r.topic, request: $o(r.request.method, r.request.params, r.id), chainId: r.chainId }; + return e.push(n); + }), 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(); + const r = this.records.get(e); + if (!r) { + const { message: n } = ft("NO_MATCHING_KEY", `${this.name}: ${e}`); + throw new Error(n); + } + return r; + } + async persist() { + await this.setJsonRpcRecords(this.values), this.events.emit(ns.sync); + } + async restore() { + try { + const e = await this.getJsonRpcRecords(); + if (typeof e > "u" || !e.length) return; + if (this.records.size) { + const { message: r } = ft("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(ns.created, (e) => { + const r = ns.created; + this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, record: e }); + }), this.events.on(ns.updated, (e) => { + const r = ns.updated; + this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, record: e }); + }), this.events.on(ns.deleted, (e) => { + const r = ns.deleted; + this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, record: e }); + }), this.core.heartbeat.on(Vc.pulse, () => { + this.cleanup(); + }); + } + cleanup() { + try { + this.isInitialized(); + let e = !1; + this.records.forEach((r) => { + bt.toMiliseconds(r.expiry || 0) - Date.now() <= 0 && (this.logger.info(`Deleting expired history log: ${r.id}`), this.records.delete(r.id), this.events.emit(ns.deleted, r, !1), e = !0); + }), e && this.persist(); + } catch (e) { + this.logger.warn(e); + } + } + isInitialized() { + if (!this.initialized) { + const { message: e } = ft("NOT_INITIALIZED", this.name); + throw new Error(e); + } + } +} +class cH extends gk { + constructor(e, r) { + super(e, r), this.core = e, this.logger = r, this.expirations = /* @__PURE__ */ new Map(), this.events = new Wi.EventEmitter(), this.name = aq, this.version = cq, this.cached = [], this.initialized = !1, this.storagePrefix = Ds, this.init = async () => { + this.initialized || (this.logger.trace("Initialized"), await this.restore(), this.cached.forEach((n) => this.expirations.set(n.target, n)), this.cached = [], this.registerEventListeners(), this.initialized = !0); + }, this.has = (n) => { + try { + const i = this.formatTarget(n); + return typeof this.getExpiration(i) < "u"; + } catch { + return !1; + } + }, this.set = (n, i) => { + this.isInitialized(); + const s = this.formatTarget(n), o = { target: s, expiry: i }; + this.expirations.set(s, o), this.checkExpiry(s, o), this.events.emit(ji.created, { target: s, expiration: o }); + }, this.get = (n) => { + this.isInitialized(); + const i = this.formatTarget(n); + return this.getExpiration(i); + }, this.del = (n) => { + if (this.isInitialized(), this.has(n)) { + const i = this.formatTarget(n), s = this.getExpiration(i); + this.expirations.delete(i), this.events.emit(ji.deleted, { target: i, expiration: s }); + } + }, this.on = (n, i) => { + this.events.on(n, i); + }, this.once = (n, i) => { + this.events.once(n, i); + }, this.off = (n, i) => { + this.events.off(n, i); + }, this.removeListener = (n, i) => { + this.events.removeListener(n, i); + }, this.logger = ri(r, this.name); + } + get context() { + return mi(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 OF(e); + if (typeof e == "number") return NF(e); + const { message: r } = ft("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(ji.sync); + } + async restore() { + try { + const e = await this.getExpirations(); + if (typeof e > "u" || !e.length) return; + if (this.expirations.size) { + const { message: r } = ft("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) { + const r = this.expirations.get(e); + if (!r) { + const { message: n } = ft("NO_MATCHING_KEY", `${this.name}: ${e}`); + throw this.logger.warn(n), new Error(n); + } + return r; + } + checkExpiry(e, r) { + const { expiry: n } = r; + bt.toMiliseconds(n) - Date.now() <= 0 && this.expire(e, r); + } + expire(e, r) { + this.expirations.delete(e), this.events.emit(ji.expired, { target: e, expiration: r }); + } + checkExpirations() { + this.core.relayer.connected && this.expirations.forEach((e, r) => this.checkExpiry(r, e)); + } + registerEventListeners() { + this.core.heartbeat.on(Vc.pulse, () => this.checkExpirations()), this.events.on(ji.created, (e) => { + const r = ji.created; + this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), this.persist(); + }), this.events.on(ji.expired, (e) => { + const r = ji.expired; + this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), this.persist(); + }), this.events.on(ji.deleted, (e) => { + const r = ji.deleted; + this.logger.info(`Emitting ${r}`), this.logger.debug({ type: "event", event: r, data: e }), this.persist(); + }); + } + isInitialized() { + if (!this.initialized) { + const { message: e } = ft("NOT_INITIALIZED", this.name); + throw new Error(e); + } + } +} +class uH extends mk { + constructor(e, r, n) { + super(e, r, n), this.core = e, this.logger = r, this.store = n, this.name = uq, this.verifyUrlV3 = lq, this.storagePrefix = Ds, this.version = K8, this.init = async () => { + var i; + this.isDevEnv || (this.publicKey = await this.store.getItem(this.storeKey), this.publicKey && bt.toMiliseconds((i = this.publicKey) == null ? void 0 : i.expiresAt) < Date.now() && (this.logger.debug("verify v2 public key expired"), await this.removePublicKey())); + }, this.register = async (i) => { + if (!il() || this.isDevEnv) return; + const s = window.location.origin, { id: o, decryptedId: a } = i, f = `${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`; + try { + const u = La.getDocument(), h = this.startAbortTimer(bt.ONE_SECOND * 5), g = await new Promise((v, x) => { + const S = () => { + window.removeEventListener("message", D), u.body.removeChild(R), x("attestation aborted"); + }; + this.abortController.signal.addEventListener("abort", S); + const R = u.createElement("iframe"); + R.src = f, R.style.display = "none", R.addEventListener("error", S, { signal: this.abortController.signal }); + const D = (k) => { + if (k.data && typeof k.data == "string") try { + const N = JSON.parse(k.data); + if (N.type === "verify_attestation") { + if (ev(N.attestation).payload.id !== o) return; + clearInterval(h), u.body.removeChild(R), this.abortController.signal.removeEventListener("abort", S), window.removeEventListener("message", D), v(N.attestation === null ? "" : N.attestation); + } + } catch (N) { + this.logger.warn(N); + } + }; + u.body.appendChild(R), window.addEventListener("message", D, { signal: this.abortController.signal }); + }); + return this.logger.debug("jwt attestation", g), g; + } catch (u) { + this.logger.warn(u); + } + return ""; + }, this.resolve = async (i) => { + if (this.isDevEnv) return ""; + const { attestationId: s, hash: o, encryptedId: a } = i; + if (s === "") { + this.logger.debug("resolve: attestationId is empty, skipping"); + return; + } + if (s) { + if (ev(s).payload.id !== a) return; + const 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; + const f = this.getVerifyUrl(i?.verifyUrl); + return this.fetchAttestation(o, f); + }, this.fetchAttestation = async (i, s) => { + this.logger.debug(`resolving attestation: ${i} from url: ${s}`); + const o = this.startAbortTimer(bt.ONE_SECOND * 5), a = await fetch(`${s}/attestation/${i}?v2Supported=true`, { signal: this.abortController.signal }); + return clearTimeout(o), a.status === 200 ? await a.json() : void 0; + }, this.getVerifyUrl = (i) => { + let s = i || rf; + return hq.includes(s) || (this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${rf}`), s = rf), s; + }, this.fetchPublicKey = async () => { + try { + this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`); + const i = this.startAbortTimer(bt.FIVE_SECONDS), s = await fetch(`${this.verifyUrlV3}/public-key`, { signal: this.abortController.signal }); + return clearTimeout(i), await s.json(); + } catch (i) { + this.logger.warn(i); + } + }, this.persistPublicKey = async (i) => { + this.logger.debug("persisting public key to local storage", i), await this.store.setItem(this.storeKey, i), this.publicKey = i; + }, 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 (i) => { + const s = await this.getPublicKey(); + try { + if (s) return this.validateAttestation(i, s); + } catch (a) { + this.logger.error(a), this.logger.warn("error validating attestation"); + } + const o = await this.fetchAndPersistPublicKey(); + try { + if (o) return this.validateAttestation(i, 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) => { + const o = await this.fetchPublicKey(); + o && (await this.persistPublicKey(o), s(o)); + }); + const i = await this.fetchPromise; + return this.fetchPromise = void 0, i; + }, this.validateAttestation = (i, s) => { + const o = wj(i, s.publicKey), a = { hasExpired: bt.toMiliseconds(o.exp) < Date.now(), payload: o }; + if (a.hasExpired) throw this.logger.warn("resolve: jwt attestation expired"), new Error("JWT attestation expired"); + return { origin: a.payload.origin, isScam: a.payload.isScam, isVerified: a.payload.isVerified }; + }, this.logger = ri(r, this.name), this.abortController = new AbortController(), this.isDevEnv = _1(), this.init(); + } + get storeKey() { + return this.storagePrefix + this.version + this.core.customStoragePrefix + "//verify:public:key"; + } + get context() { + return mi(this.logger); + } + startAbortTimer(e) { + return this.abortController = new AbortController(), setTimeout(() => this.abortController.abort(), bt.toMiliseconds(e)); + } +} +class fH extends vk { + constructor(e, r) { + super(e, r), this.projectId = e, this.logger = r, this.context = dq, this.registerDeviceToken = async (n) => { + const { clientId: i, token: s, notificationType: o, enableEncrypted: a = !1 } = n, f = `${pq}/${this.projectId}/clients`; + await fetch(f, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ client_id: i, type: o, token: s, always_raw: a }) }); + }, this.logger = ri(r, this.context); + } +} +var lH = Object.defineProperty, q3 = Object.getOwnPropertySymbols, hH = Object.prototype.hasOwnProperty, dH = Object.prototype.propertyIsEnumerable, z3 = (t, e, r) => e in t ? lH(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Bu = (t, e) => { + for (var r in e || (e = {})) hH.call(e, r) && z3(t, r, e[r]); + if (q3) for (var r of q3(e)) dH.call(e, r) && z3(t, r, e[r]); + return t; +}; +class pH extends bk { + constructor(e, r, n = !0) { + super(e, r, n), this.core = e, this.logger = r, this.context = mq, this.storagePrefix = Ds, this.storageVersion = gq, this.events = /* @__PURE__ */ new Map(), this.shouldPersist = !1, this.init = async () => { + if (!_1()) try { + const i = { eventId: Xx(), timestamp: Date.now(), domain: this.getAppDomain(), props: { event: "INIT", type: "", properties: { client_id: await this.core.crypto.getClientId(), user_agent: A8(this.core.relayer.protocol, this.core.relayer.version, av) } } }; + await this.sendEvent([i]); + } catch (i) { + this.logger.warn(i); + } + }, this.createEvent = (i) => { + const { event: s = "ERROR", type: o = "", properties: { topic: a, trace: f } } = i, u = Xx(), h = this.core.projectId || "", g = Date.now(), v = Bu({ eventId: u, timestamp: g, props: { event: s, type: o, properties: { topic: a, trace: f } }, bundleId: h, domain: this.getAppDomain() }, this.setMethods(u)); + return this.telemetryEnabled && (this.events.set(u, v), this.shouldPersist = !0), v; + }, this.getEvent = (i) => { + const { eventId: s, topic: o } = i; + if (s) return this.events.get(s); + const a = Array.from(this.events.values()).find((f) => f.props.properties.topic === o); + if (a) return Bu(Bu({}, a), this.setMethods(a.eventId)); + }, this.deleteEvent = (i) => { + const { eventId: s } = i; + this.events.delete(s), this.shouldPersist = !0; + }, this.setEventListeners = () => { + this.core.heartbeat.on(Vc.pulse, async () => { + this.shouldPersist && await this.persist(), this.events.forEach((i) => { + bt.fromMiliseconds(Date.now()) - bt.fromMiliseconds(i.timestamp) > vq && (this.events.delete(i.eventId), this.shouldPersist = !0); + }); + }); + }, this.setMethods = (i) => ({ addTrace: (s) => this.addTrace(i, s), setError: (s) => this.setError(i, s) }), this.addTrace = (i, s) => { + const o = this.events.get(i); + o && (o.props.properties.trace.push(s), this.events.set(i, o), this.shouldPersist = !0); + }, this.setError = (i, s) => { + const o = this.events.get(i); + o && (o.props.type = s, o.timestamp = Date.now(), this.events.set(i, 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 { + const i = await this.core.storage.getItem(this.storageKey) || []; + if (!i.length) return; + i.forEach((s) => { + this.events.set(s.eventId, Bu(Bu({}, s), this.setMethods(s.eventId))); + }); + } catch (i) { + this.logger.warn(i); + } + }, this.submit = async () => { + if (!this.telemetryEnabled || this.events.size === 0) return; + const i = []; + for (const [s, o] of this.events) o.props.type && i.push(o); + if (i.length !== 0) try { + if ((await this.sendEvent(i)).ok) for (const s of i) this.events.delete(s.eventId), this.shouldPersist = !0; + } catch (s) { + this.logger.warn(s); + } + }, this.sendEvent = async (i) => { + const s = this.getAppDomain() ? "" : "&sp=desktop"; + return await fetch(`${bq}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${av}${s}`, { method: "POST", body: JSON.stringify(i) }); + }, this.getAppDomain = () => S8().url, this.logger = ri(r, this.context), this.telemetryEnabled = n, n ? this.restore().then(async () => { + await this.submit(), this.setEventListeners(); + }) : this.persist(); + } + get storageKey() { + return this.storagePrefix + this.storageVersion + this.core.customStoragePrefix + "//" + this.context; + } +} +var gH = Object.defineProperty, H3 = Object.getOwnPropertySymbols, mH = Object.prototype.hasOwnProperty, vH = Object.prototype.propertyIsEnumerable, W3 = (t, e, r) => e in t ? gH(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, K3 = (t, e) => { + for (var r in e || (e = {})) mH.call(e, r) && W3(t, r, e[r]); + if (H3) for (var r of H3(e)) vH.call(e, r) && W3(t, r, e[r]); + return t; +}; +class C1 extends ck { + constructor(e) { + var r; + super(e), this.protocol = W8, this.version = K8, this.name = V8, this.events = new Wi.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; + const u = { topic: o, message: a, publishedAt: Date.now(), transportType: Wr.link_mode }; + this.relayer.onLinkMessageEvent(u, { sessionExists: f }); + }, this.projectId = e?.projectId, this.relayUrl = e?.relayUrl || Y8, this.customStoragePrefix = e != null && e.customStoragePrefix ? `:${e.customStoragePrefix}` : ""; + const n = Vd({ level: typeof e?.logger == "string" && e.logger ? e.logger : BU.logger }), { logger: i, chunkLoggerController: s } = ak({ opts: n, maxSizeInBytes: e?.maxLogBlobSizeInBytes, loggerOverride: e?.logger }); + this.logChunkController = s, (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 = ri(i, this.name), this.heartbeat = new hL(), this.crypto = new zz(this, this.logger, e?.keychain), this.history = new aH(this, this.logger), this.expirer = new cH(this, this.logger), this.storage = e != null && e.storage ? e.storage : new HL(K3(K3({}, FU), e?.storageOptions)), this.relayer = new rH({ core: this, logger: this.logger, relayUrl: this.relayUrl, projectId: this.projectId }), this.pairing = new oH(this, this.logger), this.verify = new uH(this, this.logger, this.storage), this.echoClient = new fH(this.projectId || "", this.logger), this.linkModeSupportedApps = [], this.eventClient = new pH(this, this.logger, e?.telemetryEnabled); + } + static async init(e) { + const r = new C1(e); + await r.initialize(); + const n = await r.crypto.getClientId(); + return await r.storage.setItem(QU, n), r; + } + get context() { + return mi(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(M3, 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(M3) || [], 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; + } + } +} +const bH = C1, aE = "wc", cE = 2, uE = "client", R1 = `${aE}@${cE}:${uE}:`, Zg = { name: uE, logger: "error" }, V3 = "WALLETCONNECT_DEEPLINK_CHOICE", yH = "proposal", fE = "Proposal expired", wH = "session", gc = bt.SEVEN_DAYS, xH = "engine", Pn = { wc_sessionPropose: { req: { ttl: bt.FIVE_MINUTES, prompt: !0, tag: 1100 }, res: { ttl: bt.FIVE_MINUTES, prompt: !1, tag: 1101 }, reject: { ttl: bt.FIVE_MINUTES, prompt: !1, tag: 1120 }, autoReject: { ttl: bt.FIVE_MINUTES, prompt: !1, tag: 1121 } }, wc_sessionSettle: { req: { ttl: bt.FIVE_MINUTES, prompt: !1, tag: 1102 }, res: { ttl: bt.FIVE_MINUTES, prompt: !1, tag: 1103 } }, wc_sessionUpdate: { req: { ttl: bt.ONE_DAY, prompt: !1, tag: 1104 }, res: { ttl: bt.ONE_DAY, prompt: !1, tag: 1105 } }, wc_sessionExtend: { req: { ttl: bt.ONE_DAY, prompt: !1, tag: 1106 }, res: { ttl: bt.ONE_DAY, prompt: !1, tag: 1107 } }, wc_sessionRequest: { req: { ttl: bt.FIVE_MINUTES, prompt: !0, tag: 1108 }, res: { ttl: bt.FIVE_MINUTES, prompt: !1, tag: 1109 } }, wc_sessionEvent: { req: { ttl: bt.FIVE_MINUTES, prompt: !0, tag: 1110 }, res: { ttl: bt.FIVE_MINUTES, prompt: !1, tag: 1111 } }, wc_sessionDelete: { req: { ttl: bt.ONE_DAY, prompt: !1, tag: 1112 }, res: { ttl: bt.ONE_DAY, prompt: !1, tag: 1113 } }, wc_sessionPing: { req: { ttl: bt.ONE_DAY, prompt: !1, tag: 1114 }, res: { ttl: bt.ONE_DAY, prompt: !1, tag: 1115 } }, wc_sessionAuthenticate: { req: { ttl: bt.ONE_HOUR, prompt: !0, tag: 1116 }, res: { ttl: bt.ONE_HOUR, prompt: !1, tag: 1117 }, reject: { ttl: bt.FIVE_MINUTES, prompt: !1, tag: 1118 }, autoReject: { ttl: bt.FIVE_MINUTES, prompt: !1, tag: 1119 } } }, Qg = { min: bt.FIVE_MINUTES, max: bt.SEVEN_DAYS }, _s = { idle: "IDLE", active: "ACTIVE" }, _H = "request", EH = ["wc_sessionPropose", "wc_sessionRequest", "wc_authRequest", "wc_sessionAuthenticate"], SH = "wc", AH = "auth", PH = "authKeys", MH = "pairingTopics", IH = "requests", o0 = `${SH}@${1.5}:${AH}:`, Kh = `${o0}:PUB_KEY`; +var CH = Object.defineProperty, RH = Object.defineProperties, TH = Object.getOwnPropertyDescriptors, G3 = Object.getOwnPropertySymbols, DH = Object.prototype.hasOwnProperty, OH = Object.prototype.propertyIsEnumerable, Y3 = (t, e, r) => e in t ? CH(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, tn = (t, e) => { + for (var r in e || (e = {})) DH.call(e, r) && Y3(t, r, e[r]); + if (G3) for (var r of G3(e)) OH.call(e, r) && Y3(t, r, e[r]); + return t; +}, ss = (t, e) => RH(t, TH(e)); +class NH extends wk { + constructor(e) { + super(e), this.name = xH, this.events = new l1(), this.initialized = !1, this.requestQueue = { state: _s.idle, queue: [] }, this.sessionRequestQueue = { state: _s.idle, queue: [] }, this.requestQueueDelay = bt.ONE_SECOND, this.expectedPairingMethodMap = /* @__PURE__ */ new Map(), this.recentlyDeletedMap = /* @__PURE__ */ 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(Pn) }), this.initialized = !0, setTimeout(() => { + this.sessionRequestQueue.queue = this.getPendingSessionRequests(), this.processSessionRequestQueue(); + }, bt.toMiliseconds(this.requestQueueDelay))); + }, this.connect = async (r) => { + this.isInitialized(), await this.confirmOnlineStateOrThrow(); + const n = ss(tn({}, r), { requiredNamespaces: r.requiredNamespaces || {}, optionalNamespaces: r.optionalNamespaces || {} }); + await this.isValidConnect(n); + const { pairingTopic: i, requiredNamespaces: s, optionalNamespaces: o, sessionProperties: a, relays: f } = n; + let u = i, h, g = !1; + try { + u && (g = this.client.core.pairing.pairings.get(u).active); + } catch (B) { + throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`), B; + } + if (!u || !g) { + const { topic: B, uri: $ } = await this.client.core.pairing.create(); + u = B, h = $; + } + if (!u) { + const { message: B } = ft("NO_MATCHING_KEY", `connect() pairing topic: ${u}`); + throw new Error(B); + } + const v = await this.client.core.crypto.generateKeyPair(), x = Pn.wc_sessionPropose.req.ttl || bt.FIVE_MINUTES, S = _n(x), R = tn({ requiredNamespaces: s, optionalNamespaces: o, relays: f ?? [{ protocol: G8 }], proposer: { publicKey: v, metadata: this.client.metadata }, expiryTimestamp: S, pairingTopic: u }, a && { sessionProperties: a }), { reject: D, resolve: k, done: N } = ba(x, fE); + this.events.once(wr("session_connect"), async ({ error: B, session: $ }) => { + if (B) D(B); + else if ($) { + $.self.publicKey = v; + const U = ss(tn({}, $), { pairingTopic: R.pairingTopic, requiredNamespaces: R.requiredNamespaces, optionalNamespaces: R.optionalNamespaces, transportType: Wr.relay }); + await this.client.session.set($.topic, U), await this.setExpiry($.topic, $.expiry), u && await this.client.core.pairing.updateMetadata({ topic: u, metadata: $.peer.metadata }), this.cleanupDuplicatePairings(U), k(U); + } + }); + const z = await this.sendRequest({ topic: u, method: "wc_sessionPropose", params: R, throwOnFailedPublish: !0 }); + return await this.setProposal(z, tn({ id: z }, R)), { uri: h, approval: N }; + }, this.pair = async (r) => { + this.isInitialized(), await this.confirmOnlineStateOrThrow(); + try { + return await this.client.core.pairing.pair(r); + } catch (n) { + throw this.client.logger.error("pair() failed"), n; + } + }, this.approve = async (r) => { + var n, i, s; + const o = this.client.core.eventClient.createEvent({ properties: { topic: (n = r?.id) == null ? void 0 : n.toString(), trace: [is.session_approve_started] } }); + try { + this.isInitialized(), await this.confirmOnlineStateOrThrow(); + } catch (W) { + throw o.setError(ga.no_internet_connection), W; + } + try { + await this.isValidProposalId(r?.id); + } catch (W) { + throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`), o.setError(ga.proposal_not_found), W; + } + try { + await this.isValidApprove(r); + } catch (W) { + throw this.client.logger.error("approve() -> isValidApprove() failed"), o.setError(ga.session_approve_namespace_validation_failure), W; + } + const { id: a, relayProtocol: f, namespaces: u, sessionProperties: h, sessionConfig: g } = r, v = this.client.proposal.get(a); + this.client.core.eventClient.deleteEvent({ eventId: o.eventId }); + const { pairingTopic: x, proposer: S, requiredNamespaces: R, optionalNamespaces: D } = v; + let k = (i = this.client.core.eventClient) == null ? void 0 : i.getEvent({ topic: x }); + k || (k = (s = this.client.core.eventClient) == null ? void 0 : s.createEvent({ type: is.session_approve_started, properties: { topic: x, trace: [is.session_approve_started, is.session_namespaces_validation_success] } })); + const N = await this.client.core.crypto.generateKeyPair(), z = S.publicKey, B = await this.client.core.crypto.generateSharedKey(N, z), $ = tn(tn({ relay: { protocol: f ?? "irn" }, namespaces: u, controller: { publicKey: N, metadata: this.client.metadata }, expiry: _n(gc) }, h && { sessionProperties: h }), g && { sessionConfig: g }), U = Wr.relay; + k.addTrace(is.subscribing_session_topic); + try { + await this.client.core.relayer.subscribe(B, { transportType: U }); + } catch (W) { + throw k.setError(ga.subscribe_session_topic_failure), W; + } + k.addTrace(is.subscribe_session_topic_success); + const C = ss(tn({}, $), { topic: B, requiredNamespaces: R, optionalNamespaces: D, pairingTopic: x, acknowledged: !1, self: $.controller, peer: { publicKey: S.publicKey, metadata: S.metadata }, controller: N, transportType: Wr.relay }); + await this.client.session.set(B, C), k.addTrace(is.store_session); + try { + k.addTrace(is.publishing_session_settle), await this.sendRequest({ topic: B, method: "wc_sessionSettle", params: $, throwOnFailedPublish: !0 }).catch((W) => { + throw k?.setError(ga.session_settle_publish_failure), W; + }), k.addTrace(is.session_settle_publish_success), k.addTrace(is.publishing_session_approve), await this.sendResult({ id: a, topic: x, result: { relay: { protocol: f ?? "irn" }, responderPublicKey: N }, throwOnFailedPublish: !0 }).catch((W) => { + throw k?.setError(ga.session_approve_publish_failure), W; + }), k.addTrace(is.session_approve_publish_success); + } catch (W) { + throw this.client.logger.error(W), this.client.session.delete(B, Nr("USER_DISCONNECTED")), await this.client.core.relayer.unsubscribe(B), W; + } + return this.client.core.eventClient.deleteEvent({ eventId: k.eventId }), await this.client.core.pairing.updateMetadata({ topic: x, metadata: S.metadata }), await this.client.proposal.delete(a, Nr("USER_DISCONNECTED")), await this.client.core.pairing.activate({ topic: x }), await this.setExpiry(B, _n(gc)), { topic: B, acknowledged: () => Promise.resolve(this.client.session.get(B)) }; + }, 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; + } + const { id: n, reason: i } = r; + let s; + try { + s = this.client.proposal.get(n).pairingTopic; + } catch (o) { + throw this.client.logger.error(`reject() -> proposal.get(${n}) failed`), o; + } + s && (await this.sendError({ id: n, topic: s, error: i, rpcOpts: Pn.wc_sessionPropose.reject }), await this.client.proposal.delete(n, Nr("USER_DISCONNECTED"))); + }, this.update = async (r) => { + this.isInitialized(), await this.confirmOnlineStateOrThrow(); + try { + await this.isValidUpdate(r); + } catch (g) { + throw this.client.logger.error("update() -> isValidUpdate() failed"), g; + } + const { topic: n, namespaces: i } = r, { done: s, resolve: o, reject: a } = ba(), f = No(), u = Ma().toString(), h = this.client.session.get(n).namespaces; + return this.events.once(wr("session_update", f), ({ error: g }) => { + g ? a(g) : o(); + }), await this.client.session.update(n, { namespaces: i }), await this.sendRequest({ topic: n, method: "wc_sessionUpdate", params: { namespaces: i }, throwOnFailedPublish: !0, clientRpcId: f, relayRpcId: u }).catch((g) => { + this.client.logger.error(g), this.client.session.update(n, { namespaces: h }), a(g); + }), { acknowledged: s }; + }, this.extend = async (r) => { + this.isInitialized(), await this.confirmOnlineStateOrThrow(); + try { + await this.isValidExtend(r); + } catch (f) { + throw this.client.logger.error("extend() -> isValidExtend() failed"), f; + } + const { topic: n } = r, i = No(), { done: s, resolve: o, reject: a } = ba(); + return this.events.once(wr("session_extend", i), ({ error: f }) => { + f ? a(f) : o(); + }), await this.setExpiry(n, _n(gc)), this.sendRequest({ topic: n, method: "wc_sessionExtend", params: {}, clientRpcId: i, throwOnFailedPublish: !0 }).catch((f) => { + a(f); + }), { acknowledged: s }; + }, this.request = async (r) => { + this.isInitialized(); + try { + await this.isValidRequest(r); + } catch (S) { + throw this.client.logger.error("request() -> isValidRequest() failed"), S; + } + const { chainId: n, request: i, topic: s, expiry: o = Pn.wc_sessionRequest.req.ttl } = r, a = this.client.session.get(s); + a?.transportType === Wr.relay && await this.confirmOnlineStateOrThrow(); + const f = No(), u = Ma().toString(), { done: h, resolve: g, reject: v } = ba(o, "Request expired. Please try again."); + this.events.once(wr("session_request", f), ({ error: S, result: R }) => { + S ? v(S) : g(R); + }); + const x = this.getAppLinkIfEnabled(a.peer.metadata, a.transportType); + return x ? (await this.sendRequest({ clientRpcId: f, relayRpcId: u, topic: s, method: "wc_sessionRequest", params: { request: ss(tn({}, i), { expiryTimestamp: _n(o) }), chainId: n }, expiry: o, throwOnFailedPublish: !0, appLink: x }).catch((S) => v(S)), this.client.events.emit("session_request_sent", { topic: s, request: i, chainId: n, id: f }), await h()) : await Promise.all([new Promise(async (S) => { + await this.sendRequest({ clientRpcId: f, relayRpcId: u, topic: s, method: "wc_sessionRequest", params: { request: ss(tn({}, i), { expiryTimestamp: _n(o) }), chainId: n }, expiry: o, throwOnFailedPublish: !0 }).catch((R) => v(R)), this.client.events.emit("session_request_sent", { topic: s, request: i, chainId: n, id: f }), S(); + }), new Promise(async (S) => { + var R; + if (!((R = a.sessionConfig) != null && R.disableDeepLink)) { + const D = await $F(this.client.core.storage, V3); + await LF({ id: f, topic: s, wcDeepLink: D }); + } + S(); + }), h()]).then((S) => S[2]); + }, this.respond = async (r) => { + this.isInitialized(), await this.isValidRespond(r); + const { topic: n, response: i } = r, { id: s } = i, o = this.client.session.get(n); + o.transportType === Wr.relay && await this.confirmOnlineStateOrThrow(); + const a = this.getAppLinkIfEnabled(o.peer.metadata, o.transportType); + Ps(i) ? await this.sendResult({ id: s, topic: n, result: i.result, throwOnFailedPublish: !0, appLink: a }) : qi(i) && await this.sendError({ id: s, topic: n, error: i.error, appLink: a }), this.cleanupAfterResponse(r); + }, this.ping = async (r) => { + this.isInitialized(), await this.confirmOnlineStateOrThrow(); + try { + await this.isValidPing(r); + } catch (i) { + throw this.client.logger.error("ping() -> isValidPing() failed"), i; + } + const { topic: n } = r; + if (this.client.session.keys.includes(n)) { + const i = No(), s = Ma().toString(), { done: o, resolve: a, reject: f } = ba(); + this.events.once(wr("session_ping", i), ({ error: u }) => { + u ? f(u) : a(); + }), await Promise.all([this.sendRequest({ topic: n, method: "wc_sessionPing", params: {}, throwOnFailedPublish: !0, clientRpcId: i, relayRpcId: s }), o()]); + } else this.client.core.pairing.pairings.keys.includes(n) && await this.client.core.pairing.ping({ topic: n }); + }, this.emit = async (r) => { + this.isInitialized(), await this.confirmOnlineStateOrThrow(), await this.isValidEmit(r); + const { topic: n, event: i, chainId: s } = r, o = Ma().toString(); + await this.sendRequest({ topic: n, method: "wc_sessionEvent", params: { event: i, chainId: s }, throwOnFailedPublish: !0, relayRpcId: o }); + }, this.disconnect = async (r) => { + this.isInitialized(), await this.confirmOnlineStateOrThrow(), await this.isValidDisconnect(r); + const { topic: n } = r; + if (this.client.session.keys.includes(n)) await this.sendRequest({ topic: n, method: "wc_sessionDelete", params: Nr("USER_DISCONNECTED"), throwOnFailedPublish: !0 }), await this.deleteSession({ topic: n, emitEvent: !1 }); + else if (this.client.core.pairing.pairings.keys.includes(n)) await this.client.core.pairing.disconnect({ topic: n }); + else { + const { message: i } = ft("MISMATCHED_TOPIC", `Session or pairing topic not found: ${n}`); + throw new Error(i); + } + }, this.find = (r) => (this.isInitialized(), this.client.session.getAll().filter((n) => $j(n, r))), this.getPendingSessionRequests = () => this.client.pendingRequest.getAll(), this.authenticate = async (r, n) => { + var i; + this.isInitialized(), this.isValidAuthenticate(r); + const s = n && this.client.core.linkModeSupportedApps.includes(n) && ((i = this.client.metadata.redirect) == null ? void 0 : i.linkMode), o = s ? Wr.link_mode : Wr.relay; + o === Wr.relay && await this.confirmOnlineStateOrThrow(); + const { chains: a, statement: f = "", uri: u, domain: h, nonce: g, type: v, exp: x, nbf: S, methods: R = [], expiry: D } = r, k = [...r.resources || []], { topic: N, uri: z } = await this.client.core.pairing.create({ methods: ["wc_sessionAuthenticate"], transportType: o }); + this.client.logger.info({ message: "Generated new pairing", pairing: { topic: N, uri: z } }); + const B = await this.client.core.crypto.generateKeyPair(), $ = Wh(B); + if (await Promise.all([this.client.auth.authKeys.set(Kh, { responseTopic: $, publicKey: B }), this.client.auth.pairingTopics.set($, { topic: $, pairingTopic: N })]), await this.client.core.relayer.subscribe($, { transportType: o }), this.client.logger.info(`sending request to new pairing topic: ${N}`), R.length > 0) { + const { namespace: P } = Nc(a[0]); + let _ = ij(P, "request", R); + Hh(k) && (_ = oj(_, k.pop())), k.push(_); + } + const U = D && D > Pn.wc_sessionAuthenticate.req.ttl ? D : Pn.wc_sessionAuthenticate.req.ttl, C = { authPayload: { type: v ?? "caip122", chains: a, statement: f, aud: u, domain: h, version: "1", nonce: g, iat: (/* @__PURE__ */ new Date()).toISOString(), exp: x, nbf: S, resources: k }, requester: { publicKey: B, metadata: this.client.metadata }, expiryTimestamp: _n(U) }, W = { eip155: { chains: a, methods: [.../* @__PURE__ */ new Set(["personal_sign", ...R])], events: ["chainChanged", "accountsChanged"] } }, J = { requiredNamespaces: {}, optionalNamespaces: W, relays: [{ protocol: "irn" }], pairingTopic: N, proposer: { publicKey: B, metadata: this.client.metadata }, expiryTimestamp: _n(Pn.wc_sessionPropose.req.ttl) }, { done: ne, resolve: K, reject: E } = ba(U, "Request expired"), b = async ({ error: P, session: _ }) => { + if (this.events.off(wr("session_request", p), l), P) E(P); + else if (_) { + _.self.publicKey = B, await this.client.session.set(_.topic, _), await this.setExpiry(_.topic, _.expiry), N && await this.client.core.pairing.updateMetadata({ topic: N, metadata: _.peer.metadata }); + const y = this.client.session.get(_.topic); + await this.deleteProposal(m), K({ session: y }); + } + }, l = async (P) => { + var _, y, M; + if (await this.deletePendingAuthRequest(p, { message: "fulfilled", code: 0 }), P.error) { + const X = Nr("WC_METHOD_UNSUPPORTED", "wc_sessionAuthenticate"); + return P.error.code === X.code ? void 0 : (this.events.off(wr("session_connect"), b), E(P.error.message)); + } + await this.deleteProposal(m), this.events.off(wr("session_connect"), b); + const { cacaos: I, responder: q } = P.result, ce = [], L = []; + for (const X of I) { + await e3({ cacao: X, projectId: this.client.core.projectId }) || (this.client.logger.error(X, "Signature verification failed"), E(Nr("SESSION_SETTLEMENT_FAILED", "Signature verification failed"))); + const { p: ee } = X, O = Hh(ee.resources), Z = [iv(ee.iss)], re = _d(ee.iss); + if (O) { + const he = t3(O), ae = r3(O); + ce.push(...he), Z.push(...ae); + } + for (const he of Z) L.push(`${he}:${re}`); + } + const oe = await this.client.core.crypto.generateSharedKey(B, q.publicKey); + let Q; + ce.length > 0 && (Q = { topic: oe, acknowledged: !0, self: { publicKey: B, metadata: this.client.metadata }, peer: q, controller: q.publicKey, expiry: _n(gc), requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: N, namespaces: l3([...new Set(ce)], [...new Set(L)]), transportType: o }, await this.client.core.relayer.subscribe(oe, { transportType: o }), await this.client.session.set(oe, Q), N && await this.client.core.pairing.updateMetadata({ topic: N, metadata: q.metadata }), Q = this.client.session.get(oe)), (_ = this.client.metadata.redirect) != null && _.linkMode && (y = q.metadata.redirect) != null && y.linkMode && (M = q.metadata.redirect) != null && M.universal && n && (this.client.core.addLinkModeSupportedApp(q.metadata.redirect.universal), this.client.session.update(oe, { transportType: Wr.link_mode })), K({ auths: I, session: Q }); + }, p = No(), m = No(); + this.events.once(wr("session_connect"), b), this.events.once(wr("session_request", p), l); + let w; + try { + if (s) { + const P = $o("wc_sessionAuthenticate", C, p); + this.client.core.history.set(N, P); + const _ = await this.client.core.crypto.encode("", P, { type: al, encoding: Ou }); + w = Eh(n, N, _); + } else await Promise.all([this.sendRequest({ topic: N, method: "wc_sessionAuthenticate", params: C, expiry: r.expiry, throwOnFailedPublish: !0, clientRpcId: p }), this.sendRequest({ topic: N, method: "wc_sessionPropose", params: J, expiry: Pn.wc_sessionPropose.req.ttl, throwOnFailedPublish: !0, clientRpcId: m })]); + } catch (P) { + throw this.events.off(wr("session_connect"), b), this.events.off(wr("session_request", p), l), P; + } + return await this.setProposal(m, tn({ id: m }, J)), await this.setAuthRequest(p, { request: ss(tn({}, C), { verifyContext: {} }), pairingTopic: N, transportType: o }), { uri: w ?? z, response: ne }; + }, this.approveSessionAuthenticate = async (r) => { + const { id: n, auths: i } = r, s = this.client.core.eventClient.createEvent({ properties: { topic: n.toString(), trace: [ma.authenticated_session_approve_started] } }); + try { + this.isInitialized(); + } catch (D) { + throw s.setError(ku.no_internet_connection), D; + } + const o = this.getPendingAuthRequest(n); + if (!o) throw s.setError(ku.authenticated_session_pending_request_not_found), new Error(`Could not find pending auth request with id ${n}`); + const a = o.transportType || Wr.relay; + a === Wr.relay && await this.confirmOnlineStateOrThrow(); + const f = o.requester.publicKey, u = await this.client.core.crypto.generateKeyPair(), h = Wh(f), g = { type: so, receiverPublicKey: f, senderPublicKey: u }, v = [], x = []; + for (const D of i) { + if (!await e3({ cacao: D, projectId: this.client.core.projectId })) { + s.setError(ku.invalid_cacao); + const $ = Nr("SESSION_SETTLEMENT_FAILED", "Signature verification failed"); + throw await this.sendError({ id: n, topic: h, error: $, encodeOpts: g }), new Error($.message); + } + s.addTrace(ma.cacaos_verified); + const { p: k } = D, N = Hh(k.resources), z = [iv(k.iss)], B = _d(k.iss); + if (N) { + const $ = t3(N), U = r3(N); + v.push(...$), z.push(...U); + } + for (const $ of z) x.push(`${$}:${B}`); + } + const S = await this.client.core.crypto.generateSharedKey(u, f); + s.addTrace(ma.create_authenticated_session_topic); + let R; + if (v?.length > 0) { + R = { topic: S, acknowledged: !0, self: { publicKey: u, metadata: this.client.metadata }, peer: { publicKey: f, metadata: o.requester.metadata }, controller: f, expiry: _n(gc), authentication: i, requiredNamespaces: {}, optionalNamespaces: {}, relay: { protocol: "irn" }, pairingTopic: o.pairingTopic, namespaces: l3([...new Set(v)], [...new Set(x)]), transportType: a }, s.addTrace(ma.subscribing_authenticated_session_topic); + try { + await this.client.core.relayer.subscribe(S, { transportType: a }); + } catch (D) { + throw s.setError(ku.subscribe_authenticated_session_topic_failure), D; + } + s.addTrace(ma.subscribe_authenticated_session_topic_success), await this.client.session.set(S, R), s.addTrace(ma.store_authenticated_session), await this.client.core.pairing.updateMetadata({ topic: o.pairingTopic, metadata: o.requester.metadata }); + } + s.addTrace(ma.publishing_authenticated_session_approve); + try { + await this.sendResult({ topic: h, id: n, result: { cacaos: i, responder: { publicKey: u, metadata: this.client.metadata } }, encodeOpts: g, throwOnFailedPublish: !0, appLink: this.getAppLinkIfEnabled(o.requester.metadata, a) }); + } catch (D) { + throw s.setError(ku.authenticated_session_approve_publish_failure), D; + } + return await this.client.auth.requests.delete(n, { 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 (r) => { + this.isInitialized(); + const { id: n, reason: i } = r, s = this.getPendingAuthRequest(n); + if (!s) throw new Error(`Could not find pending auth request with id ${n}`); + s.transportType === Wr.relay && await this.confirmOnlineStateOrThrow(); + const o = s.requester.publicKey, a = await this.client.core.crypto.generateKeyPair(), f = Wh(o), u = { type: so, receiverPublicKey: o, senderPublicKey: a }; + await this.sendError({ id: n, topic: f, error: i, encodeOpts: u, rpcOpts: Pn.wc_sessionAuthenticate.reject, appLink: this.getAppLinkIfEnabled(s.requester.metadata, s.transportType) }), await this.client.auth.requests.delete(n, { message: "rejected", code: 0 }), await this.client.proposal.delete(n, Nr("USER_DISCONNECTED")); + }, this.formatAuthMessage = (r) => { + this.isInitialized(); + const { request: n, iss: i } = r; + return T8(n, i); + }, this.processRelayMessageCache = () => { + setTimeout(async () => { + if (this.relayMessageCache.length !== 0) for (; this.relayMessageCache.length > 0; ) try { + const 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 { + const n = this.client.core.pairing.pairings.get(r.pairingTopic), i = 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) === r.peer.metadata.url && s.topic && s.topic !== n.topic; + }); + if (i.length === 0) return; + this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`), await Promise.all(i.map((s) => this.client.core.pairing.disconnect({ topic: s.topic }))), this.client.logger.info("Duplicate pairings clean up finished"); + } catch (n) { + this.client.logger.error(n); + } + }, this.deleteSession = async (r) => { + var n; + const { topic: i, expirerHasDeleted: s = !1, emitEvent: o = !0, id: a = 0 } = r, { self: f } = this.client.session.get(i); + await this.client.core.relayer.unsubscribe(i), await this.client.session.delete(i, Nr("USER_DISCONNECTED")), this.addToRecentlyDeleted(i, "session"), this.client.core.crypto.keychain.has(f.publicKey) && await this.client.core.crypto.deleteKeyPair(f.publicKey), this.client.core.crypto.keychain.has(i) && await this.client.core.crypto.deleteSymKey(i), s || this.client.core.expirer.del(i), this.client.core.storage.removeItem(V3).catch((u) => this.client.logger.warn(u)), this.getPendingSessionRequests().forEach((u) => { + u.topic === i && this.deletePendingSessionRequest(u.id, Nr("USER_DISCONNECTED")); + }), i === ((n = this.sessionRequestQueue.queue[0]) == null ? void 0 : n.topic) && (this.sessionRequestQueue.state = _s.idle), o && this.client.events.emit("session_delete", { id: a, topic: i }); + }, this.deleteProposal = async (r, n) => { + if (n) try { + const i = this.client.proposal.get(r); + this.client.core.eventClient.getEvent({ topic: i.pairingTopic })?.setError(ga.proposal_expired); + } catch { + } + await Promise.all([this.client.proposal.delete(r, Nr("USER_DISCONNECTED")), n ? Promise.resolve() : this.client.core.expirer.del(r)]), this.addToRecentlyDeleted(r, "proposal"); + }, this.deletePendingSessionRequest = async (r, n, i = !1) => { + await Promise.all([this.client.pendingRequest.delete(r, n), i ? Promise.resolve() : this.client.core.expirer.del(r)]), this.addToRecentlyDeleted(r, "request"), this.sessionRequestQueue.queue = this.sessionRequestQueue.queue.filter((s) => s.id !== r), i && (this.sessionRequestQueue.state = _s.idle, this.client.events.emit("session_request_expire", { id: r })); + }, this.deletePendingAuthRequest = async (r, n, i = !1) => { + await Promise.all([this.client.auth.requests.delete(r, n), i ? Promise.resolve() : this.client.core.expirer.del(r)]); + }, this.setExpiry = async (r, n) => { + this.client.session.keys.includes(r) && (this.client.core.expirer.set(r, n), await this.client.session.update(r, { expiry: n })); + }, this.setProposal = async (r, n) => { + this.client.core.expirer.set(r, _n(Pn.wc_sessionPropose.req.ttl)), await this.client.proposal.set(r, n); + }, this.setAuthRequest = async (r, n) => { + const { request: i, pairingTopic: s, transportType: o = Wr.relay } = n; + this.client.core.expirer.set(r, i.expiryTimestamp), await this.client.auth.requests.set(r, { authPayload: i.authPayload, requester: i.requester, expiryTimestamp: i.expiryTimestamp, id: r, pairingTopic: s, verifyContext: i.verifyContext, transportType: o }); + }, this.setPendingSessionRequest = async (r) => { + const { id: n, topic: i, params: s, verifyContext: o } = r, a = s.request.expiryTimestamp || _n(Pn.wc_sessionRequest.req.ttl); + this.client.core.expirer.set(n, a), await this.client.pendingRequest.set(n, { id: n, topic: i, params: s, verifyContext: o }); + }, this.sendRequest = async (r) => { + const { topic: n, method: i, params: s, expiry: o, relayRpcId: a, clientRpcId: f, throwOnFailedPublish: u, appLink: h } = r, g = $o(i, s, f); + let v; + const x = !!h; + try { + const D = x ? Ou : ko; + v = await this.client.core.crypto.encode(n, g, { encoding: D }); + } catch (D) { + throw await this.cleanup(), this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${n} failed`), D; + } + let S; + if (EH.includes(i)) { + const D = Qs(JSON.stringify(g)), k = Qs(v); + S = await this.client.core.verify.register({ id: k, decryptedId: D }); + } + const R = Pn[i].req; + if (R.attestation = S, o && (R.ttl = o), a && (R.id = a), this.client.core.history.set(n, g), x) { + const D = Eh(h, n, v); + await global.Linking.openURL(D, this.client.name); + } else { + const D = Pn[i].req; + o && (D.ttl = o), a && (D.id = a), u ? (D.internal = ss(tn({}, D.internal), { throwOnFailedPublish: !0 }), await this.client.core.relayer.publish(n, v, D)) : this.client.core.relayer.publish(n, v, D).catch((k) => this.client.logger.error(k)); + } + return g.id; + }, this.sendResult = async (r) => { + const { id: n, topic: i, result: s, throwOnFailedPublish: o, encodeOpts: a, appLink: f } = r, u = r0(n, s); + let h; + const g = f && typeof (global == null ? void 0 : global.Linking) < "u"; + try { + const x = g ? Ou : ko; + h = await this.client.core.crypto.encode(i, u, ss(tn({}, a || {}), { encoding: x })); + } catch (x) { + throw await this.cleanup(), this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`), x; + } + let v; + try { + v = await this.client.core.history.get(i, n); + } catch (x) { + throw this.client.logger.error(`sendResult() -> history.get(${i}, ${n}) failed`), x; + } + if (g) { + const x = Eh(f, i, h); + await global.Linking.openURL(x, this.client.name); + } else { + const x = Pn[v.request.method].res; + o ? (x.internal = ss(tn({}, x.internal), { throwOnFailedPublish: !0 }), await this.client.core.relayer.publish(i, h, x)) : this.client.core.relayer.publish(i, h, x).catch((S) => this.client.logger.error(S)); + } + await this.client.core.history.resolve(u); + }, this.sendError = async (r) => { + const { id: n, topic: i, error: s, encodeOpts: o, rpcOpts: a, appLink: f } = r, u = n0(n, s); + let h; + const g = f && typeof (global == null ? void 0 : global.Linking) < "u"; + try { + const x = g ? Ou : ko; + h = await this.client.core.crypto.encode(i, u, ss(tn({}, o || {}), { encoding: x })); + } catch (x) { + throw await this.cleanup(), this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`), x; + } + let v; + try { + v = await this.client.core.history.get(i, n); + } catch (x) { + throw this.client.logger.error(`sendError() -> history.get(${i}, ${n}) failed`), x; + } + if (g) { + const x = Eh(f, i, h); + await global.Linking.openURL(x, this.client.name); + } else { + const x = a || Pn[v.request.method].res; + this.client.core.relayer.publish(i, h, x); + } + await this.client.core.history.resolve(u); + }, this.cleanup = async () => { + const r = [], n = []; + this.client.session.getAll().forEach((i) => { + let s = !1; + Oo(i.expiry) && (s = !0), this.client.core.crypto.keychain.has(i.topic) || (s = !0), s && r.push(i.topic); + }), this.client.proposal.getAll().forEach((i) => { + Oo(i.expiryTimestamp) && n.push(i.id); + }), await Promise.all([...r.map((i) => this.deleteSession({ topic: i })), ...n.map((i) => this.deleteProposal(i))]); + }, this.onRelayEventRequest = async (r) => { + this.requestQueue.queue.push(r), await this.processRequestsQueue(); + }, this.processRequestsQueue = async () => { + if (this.requestQueue.state === _s.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 = _s.active; + const r = this.requestQueue.queue.shift(); + if (r) try { + await this.processRequest(r); + } catch (n) { + this.client.logger.warn(n); + } + } + this.requestQueue.state = _s.idle; + }, this.processRequest = async (r) => { + const { topic: n, payload: i, attestation: s, transportType: o, encryptedId: a } = r, f = i.method; + if (!this.shouldIgnorePairingRequest({ topic: n, requestMethod: f })) switch (f) { + case "wc_sessionPropose": + return await this.onSessionProposeRequest({ topic: n, payload: i, attestation: s, encryptedId: a }); + case "wc_sessionSettle": + return await this.onSessionSettleRequest(n, i); + case "wc_sessionUpdate": + return await this.onSessionUpdateRequest(n, i); + case "wc_sessionExtend": + return await this.onSessionExtendRequest(n, i); + case "wc_sessionPing": + return await this.onSessionPingRequest(n, i); + case "wc_sessionDelete": + return await this.onSessionDeleteRequest(n, i); + case "wc_sessionRequest": + return await this.onSessionRequest({ topic: n, payload: i, attestation: s, encryptedId: a, transportType: o }); + case "wc_sessionEvent": + return await this.onSessionEventRequest(n, i); + case "wc_sessionAuthenticate": + return await this.onSessionAuthenticateRequest({ topic: n, payload: i, attestation: s, encryptedId: a, transportType: o }); + default: + return this.client.logger.info(`Unsupported request method ${f}`); + } + }, this.onRelayEventResponse = async (r) => { + const { topic: n, payload: i, transportType: s } = r, o = (await this.client.core.history.get(n, i.id)).request.method; + switch (o) { + case "wc_sessionPropose": + return this.onSessionProposeResponse(n, i, s); + case "wc_sessionSettle": + return this.onSessionSettleResponse(n, i); + case "wc_sessionUpdate": + return this.onSessionUpdateResponse(n, i); + case "wc_sessionExtend": + return this.onSessionExtendResponse(n, i); + case "wc_sessionPing": + return this.onSessionPingResponse(n, i); + case "wc_sessionRequest": + return this.onSessionRequestResponse(n, i); + case "wc_sessionAuthenticate": + return this.onSessionAuthenticateResponse(n, i); + default: + return this.client.logger.info(`Unsupported response method ${o}`); + } + }, this.onRelayEventUnknownPayload = (r) => { + const { topic: n } = r, { message: i } = ft("MISSING_OR_INVALID", `Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`); + throw new Error(i); + }, this.shouldIgnorePairingRequest = (r) => { + const { topic: n, requestMethod: i } = r, s = this.expectedPairingMethodMap.get(n); + return !s || s.includes(i) ? !1 : !!(s.includes("wc_sessionAuthenticate") && this.client.events.listenerCount("session_authenticate") > 0); + }, this.onSessionProposeRequest = async (r) => { + const { topic: n, payload: i, attestation: s, encryptedId: o } = r, { params: a, id: f } = i; + try { + const u = this.client.core.eventClient.getEvent({ topic: n }); + this.isValidConnect(tn({}, i.params)); + const h = a.expiryTimestamp || _n(Pn.wc_sessionPropose.req.ttl), g = tn({ id: f, pairingTopic: n, expiryTimestamp: h }, a); + await this.setProposal(f, g); + const v = await this.getVerifyContext({ attestationId: s, hash: Qs(JSON.stringify(i)), encryptedId: o, metadata: g.proposer.metadata }); + this.client.events.listenerCount("session_proposal") === 0 && (console.warn("No listener for session_proposal event"), u?.setError(Zs.proposal_listener_not_found)), u?.addTrace(As.emit_session_proposal), this.client.events.emit("session_proposal", { id: f, params: g, verifyContext: v }); + } catch (u) { + await this.sendError({ id: f, topic: n, error: u, rpcOpts: Pn.wc_sessionPropose.autoReject }), this.client.logger.error(u); + } + }, this.onSessionProposeResponse = async (r, n, i) => { + const { id: s } = n; + if (Ps(n)) { + const { result: o } = n; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", result: o }); + const a = this.client.proposal.get(s); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", proposal: a }); + const f = a.proposer.publicKey; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", selfPublicKey: f }); + const u = o.responderPublicKey; + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", peerPublicKey: u }); + const h = await this.client.core.crypto.generateSharedKey(f, u); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", sessionTopic: h }); + const g = await this.client.core.relayer.subscribe(h, { transportType: i }); + this.client.logger.trace({ type: "method", method: "onSessionProposeResponse", subscriptionId: g }), await this.client.core.pairing.activate({ topic: r }); + } else if (qi(n)) { + await this.client.proposal.delete(s, Nr("USER_DISCONNECTED")); + const o = wr("session_connect"); + if (this.events.listenerCount(o) === 0) throw new Error(`emitting ${o} without any listeners, 954`); + this.events.emit(wr("session_connect"), { error: n.error }); + } + }, this.onSessionSettleRequest = async (r, n) => { + const { id: i, params: s } = n; + try { + this.isValidSessionSettleRequest(s); + const { relay: o, controller: a, expiry: f, namespaces: u, sessionProperties: h, sessionConfig: g } = n.params, v = ss(tn(tn({ topic: r, 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 } }, h && { sessionProperties: h }), g && { sessionConfig: g }), { transportType: Wr.relay }), x = wr("session_connect"); + if (this.events.listenerCount(x) === 0) throw new Error(`emitting ${x} without any listeners 997`); + this.events.emit(wr("session_connect"), { session: v }), await this.sendResult({ id: n.id, topic: r, result: !0, throwOnFailedPublish: !0 }); + } catch (o) { + await this.sendError({ id: i, topic: r, error: o }), this.client.logger.error(o); + } + }, this.onSessionSettleResponse = async (r, n) => { + const { id: i } = n; + Ps(n) ? (await this.client.session.update(r, { acknowledged: !0 }), this.events.emit(wr("session_approve", i), {})) : qi(n) && (await this.client.session.delete(r, Nr("USER_DISCONNECTED")), this.events.emit(wr("session_approve", i), { error: n.error })); + }, this.onSessionUpdateRequest = async (r, n) => { + const { params: i, id: s } = n; + try { + const o = `${r}_session_update`, a = Nu.get(o); + if (a && this.isRequestOutOfSync(a, s)) { + this.client.logger.info(`Discarding out of sync request - ${s}`), this.sendError({ id: s, topic: r, error: Nr("INVALID_UPDATE_REQUEST") }); + return; + } + this.isValidUpdate(tn({ topic: r }, i)); + try { + Nu.set(o, s), await this.client.session.update(r, { namespaces: i.namespaces }), await this.sendResult({ id: s, topic: r, result: !0, throwOnFailedPublish: !0 }); + } catch (f) { + throw Nu.delete(o), f; + } + this.client.events.emit("session_update", { id: s, topic: r, params: i }); + } catch (o) { + await this.sendError({ id: s, topic: r, error: o }), this.client.logger.error(o); + } + }, this.isRequestOutOfSync = (r, n) => parseInt(n.toString().slice(0, -3)) <= parseInt(r.toString().slice(0, -3)), this.onSessionUpdateResponse = (r, n) => { + const { id: i } = n, s = wr("session_update", i); + if (this.events.listenerCount(s) === 0) throw new Error(`emitting ${s} without any listeners`); + Ps(n) ? this.events.emit(wr("session_update", i), {}) : qi(n) && this.events.emit(wr("session_update", i), { error: n.error }); + }, this.onSessionExtendRequest = async (r, n) => { + const { id: i } = n; + try { + this.isValidExtend({ topic: r }), await this.setExpiry(r, _n(gc)), await this.sendResult({ id: i, topic: r, result: !0, throwOnFailedPublish: !0 }), this.client.events.emit("session_extend", { id: i, topic: r }); + } catch (s) { + await this.sendError({ id: i, topic: r, error: s }), this.client.logger.error(s); + } + }, this.onSessionExtendResponse = (r, n) => { + const { id: i } = n, s = wr("session_extend", i); + if (this.events.listenerCount(s) === 0) throw new Error(`emitting ${s} without any listeners`); + Ps(n) ? this.events.emit(wr("session_extend", i), {}) : qi(n) && this.events.emit(wr("session_extend", i), { error: n.error }); + }, this.onSessionPingRequest = async (r, n) => { + const { id: i } = n; + try { + this.isValidPing({ topic: r }), await this.sendResult({ id: i, topic: r, result: !0, throwOnFailedPublish: !0 }), this.client.events.emit("session_ping", { id: i, topic: r }); + } catch (s) { + await this.sendError({ id: i, topic: r, error: s }), this.client.logger.error(s); + } + }, this.onSessionPingResponse = (r, n) => { + const { id: i } = n, s = wr("session_ping", i); + if (this.events.listenerCount(s) === 0) throw new Error(`emitting ${s} without any listeners`); + setTimeout(() => { + Ps(n) ? this.events.emit(wr("session_ping", i), {}) : qi(n) && this.events.emit(wr("session_ping", i), { error: n.error }); + }, 500); + }, this.onSessionDeleteRequest = async (r, n) => { + const { id: i } = n; + try { + this.isValidDisconnect({ topic: r, reason: n.params }), Promise.all([new Promise((s) => { + this.client.core.relayer.once(Qn.publish, async () => { + s(await this.deleteSession({ topic: r, id: i })); + }); + }), this.sendResult({ id: i, topic: r, result: !0, throwOnFailedPublish: !0 }), this.cleanupPendingSentRequestsForTopic({ topic: r, error: Nr("USER_DISCONNECTED") })]).catch((s) => this.client.logger.error(s)); + } catch (s) { + this.client.logger.error(s); + } + }, this.onSessionRequest = async (r) => { + var n, i, s; + const { topic: o, payload: a, attestation: f, encryptedId: u, transportType: h } = r, { id: g, params: v } = a; + try { + await this.isValidRequest(tn({ topic: o }, v)); + const x = this.client.session.get(o), S = await this.getVerifyContext({ attestationId: f, hash: Qs(JSON.stringify($o("wc_sessionRequest", v, g))), encryptedId: u, metadata: x.peer.metadata, transportType: h }), R = { id: g, topic: o, params: v, verifyContext: S }; + await this.setPendingSessionRequest(R), h === Wr.link_mode && (n = x.peer.metadata.redirect) != null && n.universal && this.client.core.addLinkModeSupportedApp((i = x.peer.metadata.redirect) == null ? void 0 : i.universal), (s = this.client.signConfig) != null && s.disableRequestQueue ? this.emitSessionRequest(R) : (this.addSessionRequestToSessionRequestQueue(R), this.processSessionRequestQueue()); + } catch (x) { + await this.sendError({ id: g, topic: o, error: x }), this.client.logger.error(x); + } + }, this.onSessionRequestResponse = (r, n) => { + const { id: i } = n, s = wr("session_request", i); + if (this.events.listenerCount(s) === 0) throw new Error(`emitting ${s} without any listeners`); + Ps(n) ? this.events.emit(wr("session_request", i), { result: n.result }) : qi(n) && this.events.emit(wr("session_request", i), { error: n.error }); + }, this.onSessionEventRequest = async (r, n) => { + const { id: i, params: s } = n; + try { + const o = `${r}_session_event_${s.event.name}`, a = Nu.get(o); + if (a && this.isRequestOutOfSync(a, i)) { + this.client.logger.info(`Discarding out of sync request - ${i}`); + return; + } + this.isValidEmit(tn({ topic: r }, s)), this.client.events.emit("session_event", { id: i, topic: r, params: s }), Nu.set(o, i); + } catch (o) { + await this.sendError({ id: i, topic: r, error: o }), this.client.logger.error(o); + } + }, this.onSessionAuthenticateResponse = (r, n) => { + const { id: i } = n; + this.client.logger.trace({ type: "method", method: "onSessionAuthenticateResponse", topic: r, payload: n }), Ps(n) ? this.events.emit(wr("session_request", i), { result: n.result }) : qi(n) && this.events.emit(wr("session_request", i), { error: n.error }); + }, this.onSessionAuthenticateRequest = async (r) => { + var n; + const { topic: i, payload: s, attestation: o, encryptedId: a, transportType: f } = r; + try { + const { requester: u, authPayload: h, expiryTimestamp: g } = s.params, v = await this.getVerifyContext({ attestationId: o, hash: Qs(JSON.stringify(s)), encryptedId: a, metadata: u.metadata, transportType: f }), x = { requester: u, pairingTopic: i, id: s.id, authPayload: h, verifyContext: v, expiryTimestamp: g }; + await this.setAuthRequest(s.id, { request: x, pairingTopic: i, transportType: f }), f === Wr.link_mode && (n = u.metadata.redirect) != null && n.universal && this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal), this.client.events.emit("session_authenticate", { topic: i, params: s.params, id: s.id, verifyContext: v }); + } catch (u) { + this.client.logger.error(u); + const h = s.params.requester.publicKey, g = await this.client.core.crypto.generateKeyPair(), v = this.getAppLinkIfEnabled(s.params.requester.metadata, f), x = { type: so, receiverPublicKey: h, senderPublicKey: g }; + await this.sendError({ id: s.id, topic: i, error: u, encodeOpts: x, rpcOpts: Pn.wc_sessionAuthenticate.autoReject, appLink: v }); + } + }, this.addSessionRequestToSessionRequestQueue = (r) => { + this.sessionRequestQueue.queue.push(r); + }, this.cleanupAfterResponse = (r) => { + this.deletePendingSessionRequest(r.response.id, { message: "fulfilled", code: 0 }), setTimeout(() => { + this.sessionRequestQueue.state = _s.idle, this.processSessionRequestQueue(); + }, bt.toMiliseconds(this.requestQueueDelay)); + }, this.cleanupPendingSentRequestsForTopic = ({ topic: r, error: n }) => { + const i = this.client.core.history.pending; + i.length > 0 && i.filter((s) => s.topic === r && s.request.method === "wc_sessionRequest").forEach((s) => { + const o = s.request.id, a = wr("session_request", o); + if (this.events.listenerCount(a) === 0) throw new Error(`emitting ${a} without any listeners`); + this.events.emit(wr("session_request", s.request.id), { error: n }); + }); + }, this.processSessionRequestQueue = () => { + if (this.sessionRequestQueue.state === _s.active) { + this.client.logger.info("session request queue is already active."); + return; + } + const r = this.sessionRequestQueue.queue[0]; + if (!r) { + this.client.logger.info("session request queue is empty."); + return; + } + try { + this.sessionRequestQueue.state = _s.active, this.emitSessionRequest(r); + } catch (n) { + this.client.logger.error(n); + } + }, 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; + const n = this.client.proposal.getAll().find((i) => i.pairingTopic === r.topic); + n && this.onSessionProposeRequest({ topic: r.topic, payload: $o("wc_sessionPropose", { requiredNamespaces: n.requiredNamespaces, optionalNamespaces: n.optionalNamespaces, relays: n.relays, proposer: n.proposer, sessionProperties: n.sessionProperties }, n.id) }); + }, this.isValidConnect = async (r) => { + if (!ui(r)) { + const { message: f } = ft("MISSING_OR_INVALID", `connect() params: ${JSON.stringify(r)}`); + throw new Error(f); + } + const { pairingTopic: n, requiredNamespaces: i, optionalNamespaces: s, sessionProperties: o, relays: a } = r; + if (ei(n) || await this.isValidPairingTopic(n), !Yj(a)) { + const { message: f } = ft("MISSING_OR_INVALID", `connect() relays: ${a}`); + throw new Error(f); + } + !ei(i) && kf(i) !== 0 && this.validateNamespaces(i, "requiredNamespaces"), !ei(s) && kf(s) !== 0 && this.validateNamespaces(s, "optionalNamespaces"), ei(o) || this.validateSessionProps(o, "sessionProperties"); + }, this.validateNamespaces = (r, n) => { + const i = Gj(r, "connect()", n); + if (i) throw new Error(i.message); + }, this.isValidApprove = async (r) => { + if (!ui(r)) throw new Error(ft("MISSING_OR_INVALID", `approve() params: ${r}`).message); + const { id: n, namespaces: i, relayProtocol: s, sessionProperties: o } = r; + this.checkRecentlyDeleted(n), await this.isValidProposalId(n); + const a = this.client.proposal.get(n), f = Vg(i, "approve()"); + if (f) throw new Error(f.message); + const u = p3(a.requiredNamespaces, i, "approve()"); + if (u) throw new Error(u.message); + if (!hn(s, !0)) { + const { message: h } = ft("MISSING_OR_INVALID", `approve() relayProtocol: ${s}`); + throw new Error(h); + } + ei(o) || this.validateSessionProps(o, "sessionProperties"); + }, this.isValidReject = async (r) => { + if (!ui(r)) { + const { message: s } = ft("MISSING_OR_INVALID", `reject() params: ${r}`); + throw new Error(s); + } + const { id: n, reason: i } = r; + if (this.checkRecentlyDeleted(n), await this.isValidProposalId(n), !Xj(i)) { + const { message: s } = ft("MISSING_OR_INVALID", `reject() reason: ${JSON.stringify(i)}`); + throw new Error(s); + } + }, this.isValidSessionSettleRequest = (r) => { + if (!ui(r)) { + const { message: u } = ft("MISSING_OR_INVALID", `onSessionSettleRequest() params: ${r}`); + throw new Error(u); + } + const { relay: n, controller: i, namespaces: s, expiry: o } = r; + if (!F8(n)) { + const { message: u } = ft("MISSING_OR_INVALID", "onSessionSettleRequest() relay protocol should be a string"); + throw new Error(u); + } + const a = qj(i, "onSessionSettleRequest()"); + if (a) throw new Error(a.message); + const f = Vg(s, "onSessionSettleRequest()"); + if (f) throw new Error(f.message); + if (Oo(o)) { + const { message: u } = ft("EXPIRED", "onSessionSettleRequest()"); + throw new Error(u); + } + }, this.isValidUpdate = async (r) => { + if (!ui(r)) { + const { message: f } = ft("MISSING_OR_INVALID", `update() params: ${r}`); + throw new Error(f); + } + const { topic: n, namespaces: i } = r; + this.checkRecentlyDeleted(n), await this.isValidSessionTopic(n); + const s = this.client.session.get(n), o = Vg(i, "update()"); + if (o) throw new Error(o.message); + const a = p3(s.requiredNamespaces, i, "update()"); + if (a) throw new Error(a.message); + }, this.isValidExtend = async (r) => { + if (!ui(r)) { + const { message: i } = ft("MISSING_OR_INVALID", `extend() params: ${r}`); + throw new Error(i); + } + const { topic: n } = r; + this.checkRecentlyDeleted(n), await this.isValidSessionTopic(n); + }, this.isValidRequest = async (r) => { + if (!ui(r)) { + const { message: f } = ft("MISSING_OR_INVALID", `request() params: ${r}`); + throw new Error(f); + } + const { topic: n, request: i, chainId: s, expiry: o } = r; + this.checkRecentlyDeleted(n), await this.isValidSessionTopic(n); + const { namespaces: a } = this.client.session.get(n); + if (!d3(a, s)) { + const { message: f } = ft("MISSING_OR_INVALID", `request() chainId: ${s}`); + throw new Error(f); + } + if (!Zj(i)) { + const { message: f } = ft("MISSING_OR_INVALID", `request() ${JSON.stringify(i)}`); + throw new Error(f); + } + if (!tU(a, s, i.method)) { + const { message: f } = ft("MISSING_OR_INVALID", `request() method: ${i.method}`); + throw new Error(f); + } + if (o && !sU(o, Qg)) { + const { message: f } = ft("MISSING_OR_INVALID", `request() expiry: ${o}. Expiry must be a number (in seconds) between ${Qg.min} and ${Qg.max}`); + throw new Error(f); + } + }, this.isValidRespond = async (r) => { + var n; + if (!ui(r)) { + const { message: o } = ft("MISSING_OR_INVALID", `respond() params: ${r}`); + throw new Error(o); + } + const { topic: i, response: s } = r; + try { + await this.isValidSessionTopic(i); + } catch (o) { + throw (n = r?.response) != null && n.id && this.cleanupAfterResponse(r), o; + } + if (!Qj(s)) { + const { message: o } = ft("MISSING_OR_INVALID", `respond() response: ${JSON.stringify(s)}`); + throw new Error(o); + } + }, this.isValidPing = async (r) => { + if (!ui(r)) { + const { message: i } = ft("MISSING_OR_INVALID", `ping() params: ${r}`); + throw new Error(i); + } + const { topic: n } = r; + await this.isValidSessionOrPairingTopic(n); + }, this.isValidEmit = async (r) => { + if (!ui(r)) { + const { message: a } = ft("MISSING_OR_INVALID", `emit() params: ${r}`); + throw new Error(a); + } + const { topic: n, event: i, chainId: s } = r; + await this.isValidSessionTopic(n); + const { namespaces: o } = this.client.session.get(n); + if (!d3(o, s)) { + const { message: a } = ft("MISSING_OR_INVALID", `emit() chainId: ${s}`); + throw new Error(a); + } + if (!eU(i)) { + const { message: a } = ft("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(i)}`); + throw new Error(a); + } + if (!rU(o, s, i.name)) { + const { message: a } = ft("MISSING_OR_INVALID", `emit() event: ${JSON.stringify(i)}`); + throw new Error(a); + } + }, this.isValidDisconnect = async (r) => { + if (!ui(r)) { + const { message: i } = ft("MISSING_OR_INVALID", `disconnect() params: ${r}`); + throw new Error(i); + } + const { topic: n } = r; + await this.isValidSessionOrPairingTopic(n); + }, this.isValidAuthenticate = (r) => { + const { chains: n, uri: i, domain: s, nonce: o } = r; + if (!Array.isArray(n) || n.length === 0) throw new Error("chains is required and must be a non-empty array"); + if (!hn(i, !1)) throw new Error("uri is required parameter"); + if (!hn(s, !1)) throw new Error("domain is required parameter"); + if (!hn(o, !1)) throw new Error("nonce is required parameter"); + if ([...new Set(n.map((f) => Nc(f).namespace))].length > 1) throw new Error("Multi-namespace requests are not supported. Please request single namespace only."); + const { namespace: a } = Nc(n[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) => { + const { attestationId: n, hash: i, encryptedId: s, metadata: o, transportType: a } = r, f = { verified: { verifyUrl: o.verifyUrl || rf, validation: "UNKNOWN", origin: o.url || "" } }; + try { + if (a === Wr.link_mode) { + const h = this.getAppLinkIfEnabled(o, a); + return f.verified.validation = h && new URL(h).origin === new URL(o.url).origin ? "VALID" : "INVALID", f; + } + const u = await this.client.core.verify.resolve({ attestationId: n, hash: i, 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 = (r, n) => { + Object.values(r).forEach((i) => { + if (!hn(i, !1)) { + const { message: s } = ft("MISSING_OR_INVALID", `${n} must be in Record format. Received: ${JSON.stringify(i)}`); + throw new Error(s); + } + }); + }, this.getPendingAuthRequest = (r) => { + const n = this.client.auth.requests.get(r); + return typeof n == "object" ? n : void 0; + }, this.addToRecentlyDeleted = (r, n) => { + if (this.recentlyDeletedMap.set(r, n), this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) { + let i = 0; + const s = this.recentlyDeletedLimit / 2; + for (const o of this.recentlyDeletedMap.keys()) { + if (i++ >= s) break; + this.recentlyDeletedMap.delete(o); + } + } + }, this.checkRecentlyDeleted = (r) => { + const n = this.recentlyDeletedMap.get(r); + if (n) { + const { message: i } = ft("MISSING_OR_INVALID", `Record was recently deleted - ${n}: ${r}`); + throw new Error(i); + } + }, this.isLinkModeEnabled = (r, n) => { + var i, s, o, a, f, u, h, g, v; + return !r || n !== Wr.link_mode ? !1 : ((s = (i = this.client.metadata) == null ? void 0 : i.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) !== "" && ((h = r?.redirect) == null ? void 0 : h.universal) !== void 0 && ((g = r?.redirect) == null ? void 0 : g.universal) !== "" && ((v = r?.redirect) == null ? void 0 : v.linkMode) === !0 && this.client.core.linkModeSupportedApps.includes(r.redirect.universal) && typeof (global == null ? void 0 : global.Linking) < "u"; + }, this.getAppLinkIfEnabled = (r, n) => { + var i; + return this.isLinkModeEnabled(r, n) ? (i = r?.redirect) == null ? void 0 : i.universal : void 0; + }, this.handleLinkModeMessage = ({ url: r }) => { + if (!r || !r.includes("wc_ev") || !r.includes("topic")) return; + const n = Jx(r, "topic") || "", i = decodeURIComponent(Jx(r, "wc_ev") || ""), s = this.client.session.keys.includes(n); + s && this.client.session.update(n, { transportType: Wr.link_mode }), this.client.core.dispatchEnvelope({ topic: n, message: i, sessionExists: s }); + }, this.registerLinkModeListeners = async () => { + var r; + if (_1() || Yc() && (r = this.client.metadata.redirect) != null && r.linkMode) { + const n = global == null ? void 0 : global.Linking; + if (typeof n < "u") { + n.addEventListener("url", this.handleLinkModeMessage, this.client.name); + const i = await n.getInitialURL(); + i && setTimeout(() => { + this.handleLinkModeMessage({ url: i }); + }, 50); + } + } + }; + } + isInitialized() { + if (!this.initialized) { + const { message: e } = ft("NOT_INITIALIZED", this.name); + throw new Error(e); + } + } + async confirmOnlineStateOrThrow() { + await this.client.core.relayer.confirmOnlineStateOrThrow(); + } + registerRelayerEvents() { + this.client.core.relayer.on(Qn.message, (e) => { + !this.initialized || this.relayMessageCache.length > 0 ? this.relayMessageCache.push(e) : this.onRelayMessage(e); + }); + } + async onRelayMessage(e) { + const { topic: r, message: n, attestation: i, transportType: s } = e, { publicKey: o } = this.client.auth.authKeys.keys.includes(Kh) ? this.client.auth.authKeys.get(Kh) : { publicKey: void 0 }, a = await this.client.core.crypto.decode(r, n, { receiverPublicKey: o, encoding: s === Wr.link_mode ? Ou : ko }); + try { + I1(a) ? (this.client.core.history.set(r, a), this.onRelayEventRequest({ topic: r, payload: a, attestation: i, transportType: s, encryptedId: Qs(n) })) : i0(a) ? (await this.client.core.history.resolve(a), await this.onRelayEventResponse({ topic: r, payload: a, transportType: s }), this.client.core.history.delete(r, a.id)) : this.onRelayEventUnknownPayload({ topic: r, payload: a, transportType: s }); + } catch (f) { + this.client.logger.error(f); + } + } + registerExpirerEvents() { + this.client.core.expirer.on(ji.expired, async (e) => { + const { topic: r, id: n } = C8(e.target); + if (n && this.client.pendingRequest.keys.includes(n)) return await this.deletePendingSessionRequest(n, ft("EXPIRED"), !0); + if (n && this.client.auth.requests.keys.includes(n)) return await this.deletePendingAuthRequest(n, ft("EXPIRED"), !0); + r ? this.client.session.keys.includes(r) && (await this.deleteSession({ topic: r, expirerHasDeleted: !0 }), this.client.events.emit("session_expire", { topic: r })) : n && (await this.deleteProposal(n, !0), this.client.events.emit("proposal_expire", { id: n })); + }); + } + registerPairingEvents() { + this.client.core.pairing.events.on(_a.create, (e) => this.onPairingCreated(e)), this.client.core.pairing.events.on(_a.delete, (e) => { + this.addToRecentlyDeleted(e.topic, "pairing"); + }); + } + isValidPairingTopic(e) { + if (!hn(e, !1)) { + const { message: r } = ft("MISSING_OR_INVALID", `pairing topic should be a string: ${e}`); + throw new Error(r); + } + if (!this.client.core.pairing.pairings.keys.includes(e)) { + const { message: r } = ft("NO_MATCHING_KEY", `pairing topic doesn't exist: ${e}`); + throw new Error(r); + } + if (Oo(this.client.core.pairing.pairings.get(e).expiry)) { + const { message: r } = ft("EXPIRED", `pairing topic: ${e}`); + throw new Error(r); + } + } + async isValidSessionTopic(e) { + if (!hn(e, !1)) { + const { message: r } = ft("MISSING_OR_INVALID", `session topic should be a string: ${e}`); + throw new Error(r); + } + if (this.checkRecentlyDeleted(e), !this.client.session.keys.includes(e)) { + const { message: r } = ft("NO_MATCHING_KEY", `session topic doesn't exist: ${e}`); + throw new Error(r); + } + if (Oo(this.client.session.get(e).expiry)) { + await this.deleteSession({ topic: e }); + const { message: r } = ft("EXPIRED", `session topic: ${e}`); + throw new Error(r); + } + if (!this.client.core.crypto.keychain.has(e)) { + const { message: r } = ft("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 (hn(e, !1)) { + const { message: r } = ft("NO_MATCHING_KEY", `session or pairing topic doesn't exist: ${e}`); + throw new Error(r); + } else { + const { message: r } = ft("MISSING_OR_INVALID", `session or pairing topic should be a string: ${e}`); + throw new Error(r); + } + } + async isValidProposalId(e) { + if (!Jj(e)) { + const { message: r } = ft("MISSING_OR_INVALID", `proposal id should be a number: ${e}`); + throw new Error(r); + } + if (!this.client.proposal.keys.includes(e)) { + const { message: r } = ft("NO_MATCHING_KEY", `proposal id doesn't exist: ${e}`); + throw new Error(r); + } + if (Oo(this.client.proposal.get(e).expiryTimestamp)) { + await this.deleteProposal(e); + const { message: r } = ft("EXPIRED", `proposal id: ${e}`); + throw new Error(r); + } + } +} +class LH extends Va { + constructor(e, r) { + super(e, r, yH, R1), this.core = e, this.logger = r; + } +} +let kH = class extends Va { + constructor(e, r) { + super(e, r, wH, R1), this.core = e, this.logger = r; + } +}; +class $H extends Va { + constructor(e, r) { + super(e, r, _H, R1, (n) => n.id), this.core = e, this.logger = r; + } +} +class BH extends Va { + constructor(e, r) { + super(e, r, PH, o0, () => Kh), this.core = e, this.logger = r; + } +} +class FH extends Va { + constructor(e, r) { + super(e, r, MH, o0), this.core = e, this.logger = r; + } +} +class jH extends Va { + constructor(e, r) { + super(e, r, IH, o0, (n) => n.id), this.core = e, this.logger = r; + } +} +class UH { + constructor(e, r) { + this.core = e, this.logger = r, this.authKeys = new BH(this.core, this.logger), this.pairingTopics = new FH(this.core, this.logger), this.requests = new jH(this.core, this.logger); + } + async init() { + await this.authKeys.init(), await this.pairingTopics.init(), await this.requests.init(); + } +} +class T1 extends yk { + constructor(e) { + super(e), this.protocol = aE, this.version = cE, this.name = Zg.name, this.events = new Wi.EventEmitter(), this.on = (n, i) => this.events.on(n, i), this.once = (n, i) => this.events.once(n, i), this.off = (n, i) => this.events.off(n, i), this.removeListener = (n, i) => this.events.removeListener(n, i), this.removeAllListeners = (n) => this.events.removeAllListeners(n), this.connect = async (n) => { + try { + return await this.engine.connect(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.pair = async (n) => { + try { + return await this.engine.pair(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.approve = async (n) => { + try { + return await this.engine.approve(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.reject = async (n) => { + try { + return await this.engine.reject(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.update = async (n) => { + try { + return await this.engine.update(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.extend = async (n) => { + try { + return await this.engine.extend(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.request = async (n) => { + try { + return await this.engine.request(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.respond = async (n) => { + try { + return await this.engine.respond(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.ping = async (n) => { + try { + return await this.engine.ping(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.emit = async (n) => { + try { + return await this.engine.emit(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.disconnect = async (n) => { + try { + return await this.engine.disconnect(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.find = (n) => { + try { + return this.engine.find(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.getPendingSessionRequests = () => { + try { + return this.engine.getPendingSessionRequests(); + } catch (n) { + throw this.logger.error(n.message), n; + } + }, this.authenticate = async (n, i) => { + try { + return await this.engine.authenticate(n, i); + } catch (s) { + throw this.logger.error(s.message), s; + } + }, this.formatAuthMessage = (n) => { + try { + return this.engine.formatAuthMessage(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.approveSessionAuthenticate = async (n) => { + try { + return await this.engine.approveSessionAuthenticate(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.rejectSessionAuthenticate = async (n) => { + try { + return await this.engine.rejectSessionAuthenticate(n); + } catch (i) { + throw this.logger.error(i.message), i; + } + }, this.name = e?.name || Zg.name, this.metadata = e?.metadata || S8(), this.signConfig = e?.signConfig; + const r = typeof e?.logger < "u" && typeof e?.logger != "string" ? e.logger : Xf(Vd({ level: e?.logger || Zg.logger })); + this.core = e?.core || new bH(e), this.logger = ri(r, this.name), this.session = new kH(this.core, this.logger), this.proposal = new LH(this.core, this.logger), this.pendingRequest = new $H(this.core, this.logger), this.engine = new NH(this), this.auth = new UH(this.core, this.logger); + } + static async init(e) { + const r = new T1(e); + return await r.initialize(), r; + } + get context() { + return mi(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 Ju = { exports: {} }; +/** + * @license + * Lodash + * Copyright OpenJS Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ +var qH = Ju.exports, J3; +function zH() { + return J3 || (J3 = 1, (function(t, e) { + (function() { + var r, n = "4.17.21", i = 200, s = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", o = "Expected a function", a = "Invalid `variable` option passed into `_.template`", f = "__lodash_hash_undefined__", u = 500, h = "__lodash_placeholder__", g = 1, v = 2, x = 4, S = 1, R = 2, D = 1, k = 2, N = 4, z = 8, B = 16, $ = 32, U = 64, C = 128, W = 256, J = 512, ne = 30, K = "...", E = 800, b = 16, l = 1, p = 2, m = 3, w = 1 / 0, P = 9007199254740991, _ = 17976931348623157e292, y = NaN, M = 4294967295, I = M - 1, q = M >>> 1, ce = [ + ["ary", C], + ["bind", D], + ["bindKey", k], + ["curry", z], + ["curryRight", B], + ["flip", J], + ["partial", $], + ["partialRight", U], + ["rearg", W] + ], L = "[object Arguments]", oe = "[object Array]", Q = "[object AsyncFunction]", X = "[object Boolean]", ee = "[object Date]", O = "[object DOMException]", Z = "[object Error]", re = "[object Function]", he = "[object GeneratorFunction]", ae = "[object Map]", fe = "[object Number]", be = "[object Null]", Ae = "[object Object]", Te = "[object Promise]", Re = "[object Proxy]", $e = "[object RegExp]", Me = "[object Set]", Oe = "[object String]", ze = "[object Symbol]", De = "[object Undefined]", je = "[object WeakMap]", Ue = "[object WeakSet]", _e = "[object ArrayBuffer]", Ze = "[object DataView]", ot = "[object Float32Array]", ke = "[object Float64Array]", rt = "[object Int8Array]", nt = "[object Int16Array]", Ge = "[object Int32Array]", ht = "[object Uint8Array]", lt = "[object Uint8ClampedArray]", ct = "[object Uint16Array]", qt = "[object Uint32Array]", Gt = /\b__p \+= '';/g, Et = /\b(__p \+=) '' \+/g, Yt = /(__e\(.*?\)|\b__t\)) \+\n'';/g, tr = /&(?:amp|lt|gt|quot|#39);/g, Tt = /[&<>"']/g, kt = RegExp(tr.source), It = RegExp(Tt.source), dt = /<%-([\s\S]+?)%>/g, Dt = /<%([\s\S]+?)%>/g, Nt = /<%=([\s\S]+?)%>/g, mt = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, Bt = /^\w*$/, Ft = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, et = /[\\^$.*+?()[\]{}|]/g, $t = RegExp(et.source), H = /^\s+/, V = /\s/, Y = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, T = /\{\n\/\* \[wrapped with (.+)\] \*/, F = /,? & /, ie = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, le = /[()=,{}\[\]\/\s]/, me = /\\(\\)?/g, Ee = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g, Le = /\w*$/, Ie = /^[-+]0x[0-9a-f]+$/i, Qe = /^0b[01]+$/i, Xe = /^\[object .+?Constructor\]$/, tt = /^0o[0-7]+$/i, st = /^(?:0|[1-9]\d*)$/, vt = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Ct = /($^)/, Mt = /['\n\r\u2028\u2029\\]/g, wt = "\\ud800-\\udfff", Rt = "\\u0300-\\u036f", gt = "\\ufe20-\\ufe2f", _t = "\\u20d0-\\u20ff", at = Rt + gt + _t, yt = "\\u2700-\\u27bf", ut = "a-z\\xdf-\\xf6\\xf8-\\xff", it = "\\xac\\xb1\\xd7\\xf7", Se = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Pe = "\\u2000-\\u206f", Ke = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", Fe = "A-Z\\xc0-\\xd6\\xd8-\\xde", qe = "\\ufe0e\\ufe0f", Ye = it + Se + Pe + Ke, Lt = "['’]", zt = "[" + wt + "]", Zt = "[" + Ye + "]", Ht = "[" + at + "]", ge = "\\d+", nr = "[" + yt + "]", pr = "[" + ut + "]", gr = "[^" + wt + Ye + ge + yt + ut + Fe + "]", Qt = "\\ud83c[\\udffb-\\udfff]", mr = "(?:" + Ht + "|" + Qt + ")", lr = "[^" + wt + "]", Tr = "(?:\\ud83c[\\udde6-\\uddff]){2}", vr = "[\\ud800-\\udbff][\\udc00-\\udfff]", xr = "[" + Fe + "]", $r = "\\u200d", Br = "(?:" + pr + "|" + gr + ")", Ir = "(?:" + xr + "|" + gr + ")", rn = "(?:" + Lt + "(?:d|ll|m|re|s|t|ve))?", nn = "(?:" + Lt + "(?:D|LL|M|RE|S|T|VE))?", sn = mr + "?", vl = "[" + qe + "]?", R0 = "(?:" + $r + "(?:" + [lr, Tr, vr].join("|") + ")" + vl + sn + ")*", ks = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", bl = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", yl = vl + sn + R0, Xa = "(?:" + [nr, Tr, vr].join("|") + ")" + yl, T0 = "(?:" + [lr + Ht + "?", Ht, Tr, vr, zt].join("|") + ")", iu = RegExp(Lt, "g"), D0 = RegExp(Ht, "g"), Za = RegExp(Qt + "(?=" + Qt + ")|" + T0 + yl, "g"), wl = RegExp([ + xr + "?" + pr + "+" + rn + "(?=" + [Zt, xr, "$"].join("|") + ")", + Ir + "+" + nn + "(?=" + [Zt, xr + Br, "$"].join("|") + ")", + xr + "?" + Br + "+" + rn, + xr + "+" + nn, + bl, + ks, + ge, + Xa + ].join("|"), "g"), xl = RegExp("[" + $r + wt + at + qe + "]"), ta = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/, _l = [ + "Array", + "Buffer", + "DataView", + "Date", + "Error", + "Float32Array", + "Float64Array", + "Function", + "Int8Array", + "Int16Array", + "Int32Array", + "Map", + "Math", + "Object", + "Promise", + "RegExp", + "Set", + "String", + "Symbol", + "TypeError", + "Uint8Array", + "Uint8ClampedArray", + "Uint16Array", + "Uint32Array", + "WeakMap", + "_", + "clearTimeout", + "isFinite", + "parseInt", + "setTimeout" + ], O0 = -1, Fr = {}; + Fr[ot] = Fr[ke] = Fr[rt] = Fr[nt] = Fr[Ge] = Fr[ht] = Fr[lt] = Fr[ct] = Fr[qt] = !0, Fr[L] = Fr[oe] = Fr[_e] = Fr[X] = Fr[Ze] = Fr[ee] = Fr[Z] = Fr[re] = Fr[ae] = Fr[fe] = Fr[Ae] = Fr[$e] = Fr[Me] = Fr[Oe] = Fr[je] = !1; + var Dr = {}; + Dr[L] = Dr[oe] = Dr[_e] = Dr[Ze] = Dr[X] = Dr[ee] = Dr[ot] = Dr[ke] = Dr[rt] = Dr[nt] = Dr[Ge] = Dr[ae] = Dr[fe] = Dr[Ae] = Dr[$e] = Dr[Me] = Dr[Oe] = Dr[ze] = Dr[ht] = Dr[lt] = Dr[ct] = Dr[qt] = !0, Dr[Z] = Dr[re] = Dr[je] = !1; + var ue = { + // Latin-1 Supplement block. + À: "A", + Á: "A", + Â: "A", + Ã: "A", + Ä: "A", + Å: "A", + à: "a", + á: "a", + â: "a", + ã: "a", + ä: "a", + å: "a", + Ç: "C", + ç: "c", + Ð: "D", + ð: "d", + È: "E", + É: "E", + Ê: "E", + Ë: "E", + è: "e", + é: "e", + ê: "e", + ë: "e", + Ì: "I", + Í: "I", + Î: "I", + Ï: "I", + ì: "i", + í: "i", + î: "i", + ï: "i", + Ñ: "N", + ñ: "n", + Ò: "O", + Ó: "O", + Ô: "O", + Õ: "O", + Ö: "O", + Ø: "O", + ò: "o", + ó: "o", + ô: "o", + õ: "o", + ö: "o", + ø: "o", + Ù: "U", + Ú: "U", + Û: "U", + Ü: "U", + ù: "u", + ú: "u", + û: "u", + ü: "u", + Ý: "Y", + ý: "y", + ÿ: "y", + Æ: "Ae", + æ: "ae", + Þ: "Th", + þ: "th", + ß: "ss", + // Latin Extended-A block. + Ā: "A", + Ă: "A", + Ą: "A", + ā: "a", + ă: "a", + ą: "a", + Ć: "C", + Ĉ: "C", + Ċ: "C", + Č: "C", + ć: "c", + ĉ: "c", + ċ: "c", + č: "c", + Ď: "D", + Đ: "D", + ď: "d", + đ: "d", + Ē: "E", + Ĕ: "E", + Ė: "E", + Ę: "E", + Ě: "E", + ē: "e", + ĕ: "e", + ė: "e", + ę: "e", + ě: "e", + Ĝ: "G", + Ğ: "G", + Ġ: "G", + Ģ: "G", + ĝ: "g", + ğ: "g", + ġ: "g", + ģ: "g", + Ĥ: "H", + Ħ: "H", + ĥ: "h", + ħ: "h", + Ĩ: "I", + Ī: "I", + Ĭ: "I", + Į: "I", + İ: "I", + ĩ: "i", + ī: "i", + ĭ: "i", + į: "i", + ı: "i", + Ĵ: "J", + ĵ: "j", + Ķ: "K", + ķ: "k", + ĸ: "k", + Ĺ: "L", + Ļ: "L", + Ľ: "L", + Ŀ: "L", + Ł: "L", + ĺ: "l", + ļ: "l", + ľ: "l", + ŀ: "l", + ł: "l", + Ń: "N", + Ņ: "N", + Ň: "N", + Ŋ: "N", + ń: "n", + ņ: "n", + ň: "n", + ŋ: "n", + Ō: "O", + Ŏ: "O", + Ő: "O", + ō: "o", + ŏ: "o", + ő: "o", + Ŕ: "R", + Ŗ: "R", + Ř: "R", + ŕ: "r", + ŗ: "r", + ř: "r", + Ś: "S", + Ŝ: "S", + Ş: "S", + Š: "S", + ś: "s", + ŝ: "s", + ş: "s", + š: "s", + Ţ: "T", + Ť: "T", + Ŧ: "T", + ţ: "t", + ť: "t", + ŧ: "t", + Ũ: "U", + Ū: "U", + Ŭ: "U", + Ů: "U", + Ű: "U", + Ų: "U", + ũ: "u", + ū: "u", + ŭ: "u", + ů: "u", + ű: "u", + ų: "u", + Ŵ: "W", + ŵ: "w", + Ŷ: "Y", + ŷ: "y", + Ÿ: "Y", + Ź: "Z", + Ż: "Z", + Ž: "Z", + ź: "z", + ż: "z", + ž: "z", + IJ: "IJ", + ij: "ij", + Œ: "Oe", + œ: "oe", + ʼn: "'n", + ſ: "s" + }, we = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'" + }, Ve = { + "&": "&", + "<": "<", + ">": ">", + """: '"', + "'": "'" + }, St = { + "\\": "\\", + "'": "'", + "\n": "n", + "\r": "r", + "\u2028": "u2028", + "\u2029": "u2029" + }, jr = parseFloat, ir = parseInt, Kr = typeof Zn == "object" && Zn && Zn.Object === Object && Zn, gn = typeof self == "object" && self && self.Object === Object && self, Er = Kr || gn || Function("return this")(), Ur = e && !e.nodeType && e, on = Ur && !0 && t && !t.nodeType && t, ni = on && on.exports === Ur, mn = ni && Kr.process, Vr = (function() { + try { + var ye = on && on.require && on.require("util").types; + return ye || mn && mn.binding && mn.binding("util"); + } catch { + } + })(), Gn = Vr && Vr.isArrayBuffer, Zi = Vr && Vr.isDate, Ci = Vr && Vr.isMap, gs = Vr && Vr.isRegExp, su = Vr && Vr.isSet, ra = Vr && Vr.isTypedArray; + function Sn(ye, Be, Ce) { + switch (Ce.length) { + case 0: + return ye.call(Be); + case 1: + return ye.call(Be, Ce[0]); + case 2: + return ye.call(Be, Ce[0], Ce[1]); + case 3: + return ye.call(Be, Ce[0], Ce[1], Ce[2]); + } + return ye.apply(Be, Ce); + } + function N9(ye, Be, Ce, Pt) { + for (var rr = -1, Mr = ye == null ? 0 : ye.length; ++rr < Mr; ) { + var wn = ye[rr]; + Be(Pt, wn, Ce(wn), ye); + } + return Pt; + } + function Ri(ye, Be) { + for (var Ce = -1, Pt = ye == null ? 0 : ye.length; ++Ce < Pt && Be(ye[Ce], Ce, ye) !== !1; ) + ; + return ye; + } + function L9(ye, Be) { + for (var Ce = ye == null ? 0 : ye.length; Ce-- && Be(ye[Ce], Ce, ye) !== !1; ) + ; + return ye; + } + function Db(ye, Be) { + for (var Ce = -1, Pt = ye == null ? 0 : ye.length; ++Ce < Pt; ) + if (!Be(ye[Ce], Ce, ye)) + return !1; + return !0; + } + function mo(ye, Be) { + for (var Ce = -1, Pt = ye == null ? 0 : ye.length, rr = 0, Mr = []; ++Ce < Pt; ) { + var wn = ye[Ce]; + Be(wn, Ce, ye) && (Mr[rr++] = wn); + } + return Mr; + } + function El(ye, Be) { + var Ce = ye == null ? 0 : ye.length; + return !!Ce && Qa(ye, Be, 0) > -1; + } + function N0(ye, Be, Ce) { + for (var Pt = -1, rr = ye == null ? 0 : ye.length; ++Pt < rr; ) + if (Ce(Be, ye[Pt])) + return !0; + return !1; + } + function Xr(ye, Be) { + for (var Ce = -1, Pt = ye == null ? 0 : ye.length, rr = Array(Pt); ++Ce < Pt; ) + rr[Ce] = Be(ye[Ce], Ce, ye); + return rr; + } + function vo(ye, Be) { + for (var Ce = -1, Pt = Be.length, rr = ye.length; ++Ce < Pt; ) + ye[rr + Ce] = Be[Ce]; + return ye; + } + function L0(ye, Be, Ce, Pt) { + var rr = -1, Mr = ye == null ? 0 : ye.length; + for (Pt && Mr && (Ce = ye[++rr]); ++rr < Mr; ) + Ce = Be(Ce, ye[rr], rr, ye); + return Ce; + } + function k9(ye, Be, Ce, Pt) { + var rr = ye == null ? 0 : ye.length; + for (Pt && rr && (Ce = ye[--rr]); rr--; ) + Ce = Be(Ce, ye[rr], rr, ye); + return Ce; + } + function k0(ye, Be) { + for (var Ce = -1, Pt = ye == null ? 0 : ye.length; ++Ce < Pt; ) + if (Be(ye[Ce], Ce, ye)) + return !0; + return !1; + } + var $9 = $0("length"); + function B9(ye) { + return ye.split(""); + } + function F9(ye) { + return ye.match(ie) || []; + } + function Ob(ye, Be, Ce) { + var Pt; + return Ce(ye, function(rr, Mr, wn) { + if (Be(rr, Mr, wn)) + return Pt = Mr, !1; + }), Pt; + } + function Sl(ye, Be, Ce, Pt) { + for (var rr = ye.length, Mr = Ce + (Pt ? 1 : -1); Pt ? Mr-- : ++Mr < rr; ) + if (Be(ye[Mr], Mr, ye)) + return Mr; + return -1; + } + function Qa(ye, Be, Ce) { + return Be === Be ? X9(ye, Be, Ce) : Sl(ye, Nb, Ce); + } + function j9(ye, Be, Ce, Pt) { + for (var rr = Ce - 1, Mr = ye.length; ++rr < Mr; ) + if (Pt(ye[rr], Be)) + return rr; + return -1; + } + function Nb(ye) { + return ye !== ye; + } + function Lb(ye, Be) { + var Ce = ye == null ? 0 : ye.length; + return Ce ? F0(ye, Be) / Ce : y; + } + function $0(ye) { + return function(Be) { + return Be == null ? r : Be[ye]; + }; + } + function B0(ye) { + return function(Be) { + return ye == null ? r : ye[Be]; + }; + } + function kb(ye, Be, Ce, Pt, rr) { + return rr(ye, function(Mr, wn, qr) { + Ce = Pt ? (Pt = !1, Mr) : Be(Ce, Mr, wn, qr); + }), Ce; + } + function U9(ye, Be) { + var Ce = ye.length; + for (ye.sort(Be); Ce--; ) + ye[Ce] = ye[Ce].value; + return ye; + } + function F0(ye, Be) { + for (var Ce, Pt = -1, rr = ye.length; ++Pt < rr; ) { + var Mr = Be(ye[Pt]); + Mr !== r && (Ce = Ce === r ? Mr : Ce + Mr); + } + return Ce; + } + function j0(ye, Be) { + for (var Ce = -1, Pt = Array(ye); ++Ce < ye; ) + Pt[Ce] = Be(Ce); + return Pt; + } + function q9(ye, Be) { + return Xr(Be, function(Ce) { + return [Ce, ye[Ce]]; + }); + } + function $b(ye) { + return ye && ye.slice(0, Ub(ye) + 1).replace(H, ""); + } + function vi(ye) { + return function(Be) { + return ye(Be); + }; + } + function U0(ye, Be) { + return Xr(Be, function(Ce) { + return ye[Ce]; + }); + } + function ou(ye, Be) { + return ye.has(Be); + } + function Bb(ye, Be) { + for (var Ce = -1, Pt = ye.length; ++Ce < Pt && Qa(Be, ye[Ce], 0) > -1; ) + ; + return Ce; + } + function Fb(ye, Be) { + for (var Ce = ye.length; Ce-- && Qa(Be, ye[Ce], 0) > -1; ) + ; + return Ce; + } + function z9(ye, Be) { + for (var Ce = ye.length, Pt = 0; Ce--; ) + ye[Ce] === Be && ++Pt; + return Pt; + } + var H9 = B0(ue), W9 = B0(we); + function K9(ye) { + return "\\" + St[ye]; + } + function V9(ye, Be) { + return ye == null ? r : ye[Be]; + } + function ec(ye) { + return xl.test(ye); + } + function G9(ye) { + return ta.test(ye); + } + function Y9(ye) { + for (var Be, Ce = []; !(Be = ye.next()).done; ) + Ce.push(Be.value); + return Ce; + } + function q0(ye) { + var Be = -1, Ce = Array(ye.size); + return ye.forEach(function(Pt, rr) { + Ce[++Be] = [rr, Pt]; + }), Ce; + } + function jb(ye, Be) { + return function(Ce) { + return ye(Be(Ce)); + }; + } + function bo(ye, Be) { + for (var Ce = -1, Pt = ye.length, rr = 0, Mr = []; ++Ce < Pt; ) { + var wn = ye[Ce]; + (wn === Be || wn === h) && (ye[Ce] = h, Mr[rr++] = Ce); + } + return Mr; + } + function Al(ye) { + var Be = -1, Ce = Array(ye.size); + return ye.forEach(function(Pt) { + Ce[++Be] = Pt; + }), Ce; + } + function J9(ye) { + var Be = -1, Ce = Array(ye.size); + return ye.forEach(function(Pt) { + Ce[++Be] = [Pt, Pt]; + }), Ce; + } + function X9(ye, Be, Ce) { + for (var Pt = Ce - 1, rr = ye.length; ++Pt < rr; ) + if (ye[Pt] === Be) + return Pt; + return -1; + } + function Z9(ye, Be, Ce) { + for (var Pt = Ce + 1; Pt--; ) + if (ye[Pt] === Be) + return Pt; + return Pt; + } + function tc(ye) { + return ec(ye) ? eA(ye) : $9(ye); + } + function Qi(ye) { + return ec(ye) ? tA(ye) : B9(ye); + } + function Ub(ye) { + for (var Be = ye.length; Be-- && V.test(ye.charAt(Be)); ) + ; + return Be; + } + var Q9 = B0(Ve); + function eA(ye) { + for (var Be = Za.lastIndex = 0; Za.test(ye); ) + ++Be; + return Be; + } + function tA(ye) { + return ye.match(Za) || []; + } + function rA(ye) { + return ye.match(wl) || []; + } + var nA = (function ye(Be) { + Be = Be == null ? Er : rc.defaults(Er.Object(), Be, rc.pick(Er, _l)); + var Ce = Be.Array, Pt = Be.Date, rr = Be.Error, Mr = Be.Function, wn = Be.Math, qr = Be.Object, z0 = Be.RegExp, iA = Be.String, Ti = Be.TypeError, Pl = Ce.prototype, sA = Mr.prototype, nc = qr.prototype, Ml = Be["__core-js_shared__"], Il = sA.toString, Rr = nc.hasOwnProperty, oA = 0, qb = (function() { + var c = /[^.]+$/.exec(Ml && Ml.keys && Ml.keys.IE_PROTO || ""); + return c ? "Symbol(src)_1." + c : ""; + })(), Cl = nc.toString, aA = Il.call(qr), cA = Er._, uA = z0( + "^" + Il.call(Rr).replace(et, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" + ), Rl = ni ? Be.Buffer : r, yo = Be.Symbol, Tl = Be.Uint8Array, zb = Rl ? Rl.allocUnsafe : r, Dl = jb(qr.getPrototypeOf, qr), Hb = qr.create, Wb = nc.propertyIsEnumerable, Ol = Pl.splice, Kb = yo ? yo.isConcatSpreadable : r, au = yo ? yo.iterator : r, na = yo ? yo.toStringTag : r, Nl = (function() { + try { + var c = ca(qr, "defineProperty"); + return c({}, "", {}), c; + } catch { + } + })(), fA = Be.clearTimeout !== Er.clearTimeout && Be.clearTimeout, lA = Pt && Pt.now !== Er.Date.now && Pt.now, hA = Be.setTimeout !== Er.setTimeout && Be.setTimeout, Ll = wn.ceil, kl = wn.floor, H0 = qr.getOwnPropertySymbols, dA = Rl ? Rl.isBuffer : r, Vb = Be.isFinite, pA = Pl.join, gA = jb(qr.keys, qr), xn = wn.max, jn = wn.min, mA = Pt.now, vA = Be.parseInt, Gb = wn.random, bA = Pl.reverse, W0 = ca(Be, "DataView"), cu = ca(Be, "Map"), K0 = ca(Be, "Promise"), ic = ca(Be, "Set"), uu = ca(Be, "WeakMap"), fu = ca(qr, "create"), $l = uu && new uu(), sc = {}, yA = ua(W0), wA = ua(cu), xA = ua(K0), _A = ua(ic), EA = ua(uu), Bl = yo ? yo.prototype : r, lu = Bl ? Bl.valueOf : r, Yb = Bl ? Bl.toString : r; + function te(c) { + if (en(c) && !sr(c) && !(c instanceof _r)) { + if (c instanceof Di) + return c; + if (Rr.call(c, "__wrapped__")) + return Jy(c); + } + return new Di(c); + } + var oc = /* @__PURE__ */ (function() { + function c() { + } + return function(d) { + if (!Zr(d)) + return {}; + if (Hb) + return Hb(d); + c.prototype = d; + var A = new c(); + return c.prototype = r, A; + }; + })(); + function Fl() { + } + function Di(c, d) { + this.__wrapped__ = c, this.__actions__ = [], this.__chain__ = !!d, this.__index__ = 0, this.__values__ = r; + } + te.templateSettings = { + /** + * Used to detect `data` property values to be HTML-escaped. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + escape: dt, + /** + * Used to detect code to be evaluated. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + evaluate: Dt, + /** + * Used to detect `data` property values to inject. + * + * @memberOf _.templateSettings + * @type {RegExp} + */ + interpolate: Nt, + /** + * Used to reference the data object in the template text. + * + * @memberOf _.templateSettings + * @type {string} + */ + variable: "", + /** + * Used to import variables into the compiled template. + * + * @memberOf _.templateSettings + * @type {Object} + */ + imports: { + /** + * A reference to the `lodash` function. + * + * @memberOf _.templateSettings.imports + * @type {Function} + */ + _: te + } + }, te.prototype = Fl.prototype, te.prototype.constructor = te, Di.prototype = oc(Fl.prototype), Di.prototype.constructor = Di; + function _r(c) { + this.__wrapped__ = c, this.__actions__ = [], this.__dir__ = 1, this.__filtered__ = !1, this.__iteratees__ = [], this.__takeCount__ = M, this.__views__ = []; + } + function SA() { + var c = new _r(this.__wrapped__); + return c.__actions__ = ii(this.__actions__), c.__dir__ = this.__dir__, c.__filtered__ = this.__filtered__, c.__iteratees__ = ii(this.__iteratees__), c.__takeCount__ = this.__takeCount__, c.__views__ = ii(this.__views__), c; + } + function AA() { + if (this.__filtered__) { + var c = new _r(this); + c.__dir__ = -1, c.__filtered__ = !0; + } else + c = this.clone(), c.__dir__ *= -1; + return c; + } + function PA() { + var c = this.__wrapped__.value(), d = this.__dir__, A = sr(c), j = d < 0, G = A ? c.length : 0, se = BP(0, G, this.__views__), de = se.start, ve = se.end, xe = ve - de, He = j ? ve : de - 1, We = this.__iteratees__, Je = We.length, xt = 0, Ot = jn(xe, this.__takeCount__); + if (!A || !j && G == xe && Ot == xe) + return yy(c, this.__actions__); + var Wt = []; + e: + for (; xe-- && xt < Ot; ) { + He += d; + for (var fr = -1, Kt = c[He]; ++fr < Je; ) { + var yr = We[fr], Sr = yr.iteratee, wi = yr.type, Xn = Sr(Kt); + if (wi == p) + Kt = Xn; + else if (!Xn) { + if (wi == l) + continue e; + break e; + } + } + Wt[xt++] = Kt; + } + return Wt; + } + _r.prototype = oc(Fl.prototype), _r.prototype.constructor = _r; + function ia(c) { + var d = -1, A = c == null ? 0 : c.length; + for (this.clear(); ++d < A; ) { + var j = c[d]; + this.set(j[0], j[1]); + } + } + function MA() { + this.__data__ = fu ? fu(null) : {}, this.size = 0; + } + function IA(c) { + var d = this.has(c) && delete this.__data__[c]; + return this.size -= d ? 1 : 0, d; + } + function CA(c) { + var d = this.__data__; + if (fu) { + var A = d[c]; + return A === f ? r : A; + } + return Rr.call(d, c) ? d[c] : r; + } + function RA(c) { + var d = this.__data__; + return fu ? d[c] !== r : Rr.call(d, c); + } + function TA(c, d) { + var A = this.__data__; + return this.size += this.has(c) ? 0 : 1, A[c] = fu && d === r ? f : d, this; + } + ia.prototype.clear = MA, ia.prototype.delete = IA, ia.prototype.get = CA, ia.prototype.has = RA, ia.prototype.set = TA; + function $s(c) { + var d = -1, A = c == null ? 0 : c.length; + for (this.clear(); ++d < A; ) { + var j = c[d]; + this.set(j[0], j[1]); + } + } + function DA() { + this.__data__ = [], this.size = 0; + } + function OA(c) { + var d = this.__data__, A = jl(d, c); + if (A < 0) + return !1; + var j = d.length - 1; + return A == j ? d.pop() : Ol.call(d, A, 1), --this.size, !0; + } + function NA(c) { + var d = this.__data__, A = jl(d, c); + return A < 0 ? r : d[A][1]; + } + function LA(c) { + return jl(this.__data__, c) > -1; + } + function kA(c, d) { + var A = this.__data__, j = jl(A, c); + return j < 0 ? (++this.size, A.push([c, d])) : A[j][1] = d, this; + } + $s.prototype.clear = DA, $s.prototype.delete = OA, $s.prototype.get = NA, $s.prototype.has = LA, $s.prototype.set = kA; + function Bs(c) { + var d = -1, A = c == null ? 0 : c.length; + for (this.clear(); ++d < A; ) { + var j = c[d]; + this.set(j[0], j[1]); + } + } + function $A() { + this.size = 0, this.__data__ = { + hash: new ia(), + map: new (cu || $s)(), + string: new ia() + }; + } + function BA(c) { + var d = Zl(this, c).delete(c); + return this.size -= d ? 1 : 0, d; + } + function FA(c) { + return Zl(this, c).get(c); + } + function jA(c) { + return Zl(this, c).has(c); + } + function UA(c, d) { + var A = Zl(this, c), j = A.size; + return A.set(c, d), this.size += A.size == j ? 0 : 1, this; + } + Bs.prototype.clear = $A, Bs.prototype.delete = BA, Bs.prototype.get = FA, Bs.prototype.has = jA, Bs.prototype.set = UA; + function sa(c) { + var d = -1, A = c == null ? 0 : c.length; + for (this.__data__ = new Bs(); ++d < A; ) + this.add(c[d]); + } + function qA(c) { + return this.__data__.set(c, f), this; + } + function zA(c) { + return this.__data__.has(c); + } + sa.prototype.add = sa.prototype.push = qA, sa.prototype.has = zA; + function es(c) { + var d = this.__data__ = new $s(c); + this.size = d.size; + } + function HA() { + this.__data__ = new $s(), this.size = 0; + } + function WA(c) { + var d = this.__data__, A = d.delete(c); + return this.size = d.size, A; + } + function KA(c) { + return this.__data__.get(c); + } + function VA(c) { + return this.__data__.has(c); + } + function GA(c, d) { + var A = this.__data__; + if (A instanceof $s) { + var j = A.__data__; + if (!cu || j.length < i - 1) + return j.push([c, d]), this.size = ++A.size, this; + A = this.__data__ = new Bs(j); + } + return A.set(c, d), this.size = A.size, this; + } + es.prototype.clear = HA, es.prototype.delete = WA, es.prototype.get = KA, es.prototype.has = VA, es.prototype.set = GA; + function Jb(c, d) { + var A = sr(c), j = !A && fa(c), G = !A && !j && So(c), se = !A && !j && !G && fc(c), de = A || j || G || se, ve = de ? j0(c.length, iA) : [], xe = ve.length; + for (var He in c) + (d || Rr.call(c, He)) && !(de && // Safari 9 has enumerable `arguments.length` in strict mode. + (He == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. + G && (He == "offset" || He == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. + se && (He == "buffer" || He == "byteLength" || He == "byteOffset") || // Skip index properties. + qs(He, xe))) && ve.push(He); + return ve; + } + function Xb(c) { + var d = c.length; + return d ? c[np(0, d - 1)] : r; + } + function YA(c, d) { + return Ql(ii(c), oa(d, 0, c.length)); + } + function JA(c) { + return Ql(ii(c)); + } + function V0(c, d, A) { + (A !== r && !ts(c[d], A) || A === r && !(d in c)) && Fs(c, d, A); + } + function hu(c, d, A) { + var j = c[d]; + (!(Rr.call(c, d) && ts(j, A)) || A === r && !(d in c)) && Fs(c, d, A); + } + function jl(c, d) { + for (var A = c.length; A--; ) + if (ts(c[A][0], d)) + return A; + return -1; + } + function XA(c, d, A, j) { + return wo(c, function(G, se, de) { + d(j, G, A(G), de); + }), j; + } + function Zb(c, d) { + return c && vs(d, An(d), c); + } + function ZA(c, d) { + return c && vs(d, oi(d), c); + } + function Fs(c, d, A) { + d == "__proto__" && Nl ? Nl(c, d, { + configurable: !0, + enumerable: !0, + value: A, + writable: !0 + }) : c[d] = A; + } + function G0(c, d) { + for (var A = -1, j = d.length, G = Ce(j), se = c == null; ++A < j; ) + G[A] = se ? r : Ip(c, d[A]); + return G; + } + function oa(c, d, A) { + return c === c && (A !== r && (c = c <= A ? c : A), d !== r && (c = c >= d ? c : d)), c; + } + function Oi(c, d, A, j, G, se) { + var de, ve = d & g, xe = d & v, He = d & x; + if (A && (de = G ? A(c, j, G, se) : A(c)), de !== r) + return de; + if (!Zr(c)) + return c; + var We = sr(c); + if (We) { + if (de = jP(c), !ve) + return ii(c, de); + } else { + var Je = Un(c), xt = Je == re || Je == he; + if (So(c)) + return _y(c, ve); + if (Je == Ae || Je == L || xt && !G) { + if (de = xe || xt ? {} : Uy(c), !ve) + return xe ? CP(c, ZA(de, c)) : IP(c, Zb(de, c)); + } else { + if (!Dr[Je]) + return G ? c : {}; + de = UP(c, Je, ve); + } + } + se || (se = new es()); + var Ot = se.get(c); + if (Ot) + return Ot; + se.set(c, de), mw(c) ? c.forEach(function(Kt) { + de.add(Oi(Kt, d, A, Kt, c, se)); + }) : pw(c) && c.forEach(function(Kt, yr) { + de.set(yr, Oi(Kt, d, A, yr, c, se)); + }); + var Wt = He ? xe ? pp : dp : xe ? oi : An, fr = We ? r : Wt(c); + return Ri(fr || c, function(Kt, yr) { + fr && (yr = Kt, Kt = c[yr]), hu(de, yr, Oi(Kt, d, A, yr, c, se)); + }), de; + } + function QA(c) { + var d = An(c); + return function(A) { + return Qb(A, c, d); + }; + } + function Qb(c, d, A) { + var j = A.length; + if (c == null) + return !j; + for (c = qr(c); j--; ) { + var G = A[j], se = d[G], de = c[G]; + if (de === r && !(G in c) || !se(de)) + return !1; + } + return !0; + } + function ey(c, d, A) { + if (typeof c != "function") + throw new Ti(o); + return yu(function() { + c.apply(r, A); + }, d); + } + function du(c, d, A, j) { + var G = -1, se = El, de = !0, ve = c.length, xe = [], He = d.length; + if (!ve) + return xe; + A && (d = Xr(d, vi(A))), j ? (se = N0, de = !1) : d.length >= i && (se = ou, de = !1, d = new sa(d)); + e: + for (; ++G < ve; ) { + var We = c[G], Je = A == null ? We : A(We); + if (We = j || We !== 0 ? We : 0, de && Je === Je) { + for (var xt = He; xt--; ) + if (d[xt] === Je) + continue e; + xe.push(We); + } else se(d, Je, j) || xe.push(We); + } + return xe; + } + var wo = My(ms), ty = My(J0, !0); + function eP(c, d) { + var A = !0; + return wo(c, function(j, G, se) { + return A = !!d(j, G, se), A; + }), A; + } + function Ul(c, d, A) { + for (var j = -1, G = c.length; ++j < G; ) { + var se = c[j], de = d(se); + if (de != null && (ve === r ? de === de && !yi(de) : A(de, ve))) + var ve = de, xe = se; + } + return xe; + } + function tP(c, d, A, j) { + var G = c.length; + for (A = cr(A), A < 0 && (A = -A > G ? 0 : G + A), j = j === r || j > G ? G : cr(j), j < 0 && (j += G), j = A > j ? 0 : bw(j); A < j; ) + c[A++] = d; + return c; + } + function ry(c, d) { + var A = []; + return wo(c, function(j, G, se) { + d(j, G, se) && A.push(j); + }), A; + } + function On(c, d, A, j, G) { + var se = -1, de = c.length; + for (A || (A = zP), G || (G = []); ++se < de; ) { + var ve = c[se]; + d > 0 && A(ve) ? d > 1 ? On(ve, d - 1, A, j, G) : vo(G, ve) : j || (G[G.length] = ve); + } + return G; + } + var Y0 = Iy(), ny = Iy(!0); + function ms(c, d) { + return c && Y0(c, d, An); + } + function J0(c, d) { + return c && ny(c, d, An); + } + function ql(c, d) { + return mo(d, function(A) { + return zs(c[A]); + }); + } + function aa(c, d) { + d = _o(d, c); + for (var A = 0, j = d.length; c != null && A < j; ) + c = c[bs(d[A++])]; + return A && A == j ? c : r; + } + function iy(c, d, A) { + var j = d(c); + return sr(c) ? j : vo(j, A(c)); + } + function Yn(c) { + return c == null ? c === r ? De : be : na && na in qr(c) ? $P(c) : JP(c); + } + function X0(c, d) { + return c > d; + } + function rP(c, d) { + return c != null && Rr.call(c, d); + } + function nP(c, d) { + return c != null && d in qr(c); + } + function iP(c, d, A) { + return c >= jn(d, A) && c < xn(d, A); + } + function Z0(c, d, A) { + for (var j = A ? N0 : El, G = c[0].length, se = c.length, de = se, ve = Ce(se), xe = 1 / 0, He = []; de--; ) { + var We = c[de]; + de && d && (We = Xr(We, vi(d))), xe = jn(We.length, xe), ve[de] = !A && (d || G >= 120 && We.length >= 120) ? new sa(de && We) : r; + } + We = c[0]; + var Je = -1, xt = ve[0]; + e: + for (; ++Je < G && He.length < xe; ) { + var Ot = We[Je], Wt = d ? d(Ot) : Ot; + if (Ot = A || Ot !== 0 ? Ot : 0, !(xt ? ou(xt, Wt) : j(He, Wt, A))) { + for (de = se; --de; ) { + var fr = ve[de]; + if (!(fr ? ou(fr, Wt) : j(c[de], Wt, A))) + continue e; + } + xt && xt.push(Wt), He.push(Ot); + } + } + return He; + } + function sP(c, d, A, j) { + return ms(c, function(G, se, de) { + d(j, A(G), se, de); + }), j; + } + function pu(c, d, A) { + d = _o(d, c), c = Wy(c, d); + var j = c == null ? c : c[bs(Li(d))]; + return j == null ? r : Sn(j, c, A); + } + function sy(c) { + return en(c) && Yn(c) == L; + } + function oP(c) { + return en(c) && Yn(c) == _e; + } + function aP(c) { + return en(c) && Yn(c) == ee; + } + function gu(c, d, A, j, G) { + return c === d ? !0 : c == null || d == null || !en(c) && !en(d) ? c !== c && d !== d : cP(c, d, A, j, gu, G); + } + function cP(c, d, A, j, G, se) { + var de = sr(c), ve = sr(d), xe = de ? oe : Un(c), He = ve ? oe : Un(d); + xe = xe == L ? Ae : xe, He = He == L ? Ae : He; + var We = xe == Ae, Je = He == Ae, xt = xe == He; + if (xt && So(c)) { + if (!So(d)) + return !1; + de = !0, We = !1; + } + if (xt && !We) + return se || (se = new es()), de || fc(c) ? By(c, d, A, j, G, se) : LP(c, d, xe, A, j, G, se); + if (!(A & S)) { + var Ot = We && Rr.call(c, "__wrapped__"), Wt = Je && Rr.call(d, "__wrapped__"); + if (Ot || Wt) { + var fr = Ot ? c.value() : c, Kt = Wt ? d.value() : d; + return se || (se = new es()), G(fr, Kt, A, j, se); + } + } + return xt ? (se || (se = new es()), kP(c, d, A, j, G, se)) : !1; + } + function uP(c) { + return en(c) && Un(c) == ae; + } + function Q0(c, d, A, j) { + var G = A.length, se = G, de = !j; + if (c == null) + return !se; + for (c = qr(c); G--; ) { + var ve = A[G]; + if (de && ve[2] ? ve[1] !== c[ve[0]] : !(ve[0] in c)) + return !1; + } + for (; ++G < se; ) { + ve = A[G]; + var xe = ve[0], He = c[xe], We = ve[1]; + if (de && ve[2]) { + if (He === r && !(xe in c)) + return !1; + } else { + var Je = new es(); + if (j) + var xt = j(He, We, xe, c, d, Je); + if (!(xt === r ? gu(We, He, S | R, j, Je) : xt)) + return !1; + } + } + return !0; + } + function oy(c) { + if (!Zr(c) || WP(c)) + return !1; + var d = zs(c) ? uA : Xe; + return d.test(ua(c)); + } + function fP(c) { + return en(c) && Yn(c) == $e; + } + function lP(c) { + return en(c) && Un(c) == Me; + } + function hP(c) { + return en(c) && sh(c.length) && !!Fr[Yn(c)]; + } + function ay(c) { + return typeof c == "function" ? c : c == null ? ai : typeof c == "object" ? sr(c) ? fy(c[0], c[1]) : uy(c) : Cw(c); + } + function ep(c) { + if (!bu(c)) + return gA(c); + var d = []; + for (var A in qr(c)) + Rr.call(c, A) && A != "constructor" && d.push(A); + return d; + } + function dP(c) { + if (!Zr(c)) + return YP(c); + var d = bu(c), A = []; + for (var j in c) + j == "constructor" && (d || !Rr.call(c, j)) || A.push(j); + return A; + } + function tp(c, d) { + return c < d; + } + function cy(c, d) { + var A = -1, j = si(c) ? Ce(c.length) : []; + return wo(c, function(G, se, de) { + j[++A] = d(G, se, de); + }), j; + } + function uy(c) { + var d = mp(c); + return d.length == 1 && d[0][2] ? zy(d[0][0], d[0][1]) : function(A) { + return A === c || Q0(A, c, d); + }; + } + function fy(c, d) { + return bp(c) && qy(d) ? zy(bs(c), d) : function(A) { + var j = Ip(A, c); + return j === r && j === d ? Cp(A, c) : gu(d, j, S | R); + }; + } + function zl(c, d, A, j, G) { + c !== d && Y0(d, function(se, de) { + if (G || (G = new es()), Zr(se)) + pP(c, d, de, A, zl, j, G); + else { + var ve = j ? j(wp(c, de), se, de + "", c, d, G) : r; + ve === r && (ve = se), V0(c, de, ve); + } + }, oi); + } + function pP(c, d, A, j, G, se, de) { + var ve = wp(c, A), xe = wp(d, A), He = de.get(xe); + if (He) { + V0(c, A, He); + return; + } + var We = se ? se(ve, xe, A + "", c, d, de) : r, Je = We === r; + if (Je) { + var xt = sr(xe), Ot = !xt && So(xe), Wt = !xt && !Ot && fc(xe); + We = xe, xt || Ot || Wt ? sr(ve) ? We = ve : an(ve) ? We = ii(ve) : Ot ? (Je = !1, We = _y(xe, !0)) : Wt ? (Je = !1, We = Ey(xe, !0)) : We = [] : wu(xe) || fa(xe) ? (We = ve, fa(ve) ? We = yw(ve) : (!Zr(ve) || zs(ve)) && (We = Uy(xe))) : Je = !1; + } + Je && (de.set(xe, We), G(We, xe, j, se, de), de.delete(xe)), V0(c, A, We); + } + function ly(c, d) { + var A = c.length; + if (A) + return d += d < 0 ? A : 0, qs(d, A) ? c[d] : r; + } + function hy(c, d, A) { + d.length ? d = Xr(d, function(se) { + return sr(se) ? function(de) { + return aa(de, se.length === 1 ? se[0] : se); + } : se; + }) : d = [ai]; + var j = -1; + d = Xr(d, vi(Ut())); + var G = cy(c, function(se, de, ve) { + var xe = Xr(d, function(He) { + return He(se); + }); + return { criteria: xe, index: ++j, value: se }; + }); + return U9(G, function(se, de) { + return MP(se, de, A); + }); + } + function gP(c, d) { + return dy(c, d, function(A, j) { + return Cp(c, j); + }); + } + function dy(c, d, A) { + for (var j = -1, G = d.length, se = {}; ++j < G; ) { + var de = d[j], ve = aa(c, de); + A(ve, de) && mu(se, _o(de, c), ve); + } + return se; + } + function mP(c) { + return function(d) { + return aa(d, c); + }; + } + function rp(c, d, A, j) { + var G = j ? j9 : Qa, se = -1, de = d.length, ve = c; + for (c === d && (d = ii(d)), A && (ve = Xr(c, vi(A))); ++se < de; ) + for (var xe = 0, He = d[se], We = A ? A(He) : He; (xe = G(ve, We, xe, j)) > -1; ) + ve !== c && Ol.call(ve, xe, 1), Ol.call(c, xe, 1); + return c; + } + function py(c, d) { + for (var A = c ? d.length : 0, j = A - 1; A--; ) { + var G = d[A]; + if (A == j || G !== se) { + var se = G; + qs(G) ? Ol.call(c, G, 1) : op(c, G); + } + } + return c; + } + function np(c, d) { + return c + kl(Gb() * (d - c + 1)); + } + function vP(c, d, A, j) { + for (var G = -1, se = xn(Ll((d - c) / (A || 1)), 0), de = Ce(se); se--; ) + de[j ? se : ++G] = c, c += A; + return de; + } + function ip(c, d) { + var A = ""; + if (!c || d < 1 || d > P) + return A; + do + d % 2 && (A += c), d = kl(d / 2), d && (c += c); + while (d); + return A; + } + function hr(c, d) { + return xp(Hy(c, d, ai), c + ""); + } + function bP(c) { + return Xb(lc(c)); + } + function yP(c, d) { + var A = lc(c); + return Ql(A, oa(d, 0, A.length)); + } + function mu(c, d, A, j) { + if (!Zr(c)) + return c; + d = _o(d, c); + for (var G = -1, se = d.length, de = se - 1, ve = c; ve != null && ++G < se; ) { + var xe = bs(d[G]), He = A; + if (xe === "__proto__" || xe === "constructor" || xe === "prototype") + return c; + if (G != de) { + var We = ve[xe]; + He = j ? j(We, xe, ve) : r, He === r && (He = Zr(We) ? We : qs(d[G + 1]) ? [] : {}); + } + hu(ve, xe, He), ve = ve[xe]; + } + return c; + } + var gy = $l ? function(c, d) { + return $l.set(c, d), c; + } : ai, wP = Nl ? function(c, d) { + return Nl(c, "toString", { + configurable: !0, + enumerable: !1, + value: Tp(d), + writable: !0 + }); + } : ai; + function xP(c) { + return Ql(lc(c)); + } + function Ni(c, d, A) { + var j = -1, G = c.length; + d < 0 && (d = -d > G ? 0 : G + d), A = A > G ? G : A, A < 0 && (A += G), G = d > A ? 0 : A - d >>> 0, d >>>= 0; + for (var se = Ce(G); ++j < G; ) + se[j] = c[j + d]; + return se; + } + function _P(c, d) { + var A; + return wo(c, function(j, G, se) { + return A = d(j, G, se), !A; + }), !!A; + } + function Hl(c, d, A) { + var j = 0, G = c == null ? j : c.length; + if (typeof d == "number" && d === d && G <= q) { + for (; j < G; ) { + var se = j + G >>> 1, de = c[se]; + de !== null && !yi(de) && (A ? de <= d : de < d) ? j = se + 1 : G = se; + } + return G; + } + return sp(c, d, ai, A); + } + function sp(c, d, A, j) { + var G = 0, se = c == null ? 0 : c.length; + if (se === 0) + return 0; + d = A(d); + for (var de = d !== d, ve = d === null, xe = yi(d), He = d === r; G < se; ) { + var We = kl((G + se) / 2), Je = A(c[We]), xt = Je !== r, Ot = Je === null, Wt = Je === Je, fr = yi(Je); + if (de) + var Kt = j || Wt; + else He ? Kt = Wt && (j || xt) : ve ? Kt = Wt && xt && (j || !Ot) : xe ? Kt = Wt && xt && !Ot && (j || !fr) : Ot || fr ? Kt = !1 : Kt = j ? Je <= d : Je < d; + Kt ? G = We + 1 : se = We; + } + return jn(se, I); + } + function my(c, d) { + for (var A = -1, j = c.length, G = 0, se = []; ++A < j; ) { + var de = c[A], ve = d ? d(de) : de; + if (!A || !ts(ve, xe)) { + var xe = ve; + se[G++] = de === 0 ? 0 : de; + } + } + return se; + } + function vy(c) { + return typeof c == "number" ? c : yi(c) ? y : +c; + } + function bi(c) { + if (typeof c == "string") + return c; + if (sr(c)) + return Xr(c, bi) + ""; + if (yi(c)) + return Yb ? Yb.call(c) : ""; + var d = c + ""; + return d == "0" && 1 / c == -w ? "-0" : d; + } + function xo(c, d, A) { + var j = -1, G = El, se = c.length, de = !0, ve = [], xe = ve; + if (A) + de = !1, G = N0; + else if (se >= i) { + var He = d ? null : OP(c); + if (He) + return Al(He); + de = !1, G = ou, xe = new sa(); + } else + xe = d ? [] : ve; + e: + for (; ++j < se; ) { + var We = c[j], Je = d ? d(We) : We; + if (We = A || We !== 0 ? We : 0, de && Je === Je) { + for (var xt = xe.length; xt--; ) + if (xe[xt] === Je) + continue e; + d && xe.push(Je), ve.push(We); + } else G(xe, Je, A) || (xe !== ve && xe.push(Je), ve.push(We)); + } + return ve; + } + function op(c, d) { + return d = _o(d, c), c = Wy(c, d), c == null || delete c[bs(Li(d))]; + } + function by(c, d, A, j) { + return mu(c, d, A(aa(c, d)), j); + } + function Wl(c, d, A, j) { + for (var G = c.length, se = j ? G : -1; (j ? se-- : ++se < G) && d(c[se], se, c); ) + ; + return A ? Ni(c, j ? 0 : se, j ? se + 1 : G) : Ni(c, j ? se + 1 : 0, j ? G : se); + } + function yy(c, d) { + var A = c; + return A instanceof _r && (A = A.value()), L0(d, function(j, G) { + return G.func.apply(G.thisArg, vo([j], G.args)); + }, A); + } + function ap(c, d, A) { + var j = c.length; + if (j < 2) + return j ? xo(c[0]) : []; + for (var G = -1, se = Ce(j); ++G < j; ) + for (var de = c[G], ve = -1; ++ve < j; ) + ve != G && (se[G] = du(se[G] || de, c[ve], d, A)); + return xo(On(se, 1), d, A); + } + function wy(c, d, A) { + for (var j = -1, G = c.length, se = d.length, de = {}; ++j < G; ) { + var ve = j < se ? d[j] : r; + A(de, c[j], ve); + } + return de; + } + function cp(c) { + return an(c) ? c : []; + } + function up(c) { + return typeof c == "function" ? c : ai; + } + function _o(c, d) { + return sr(c) ? c : bp(c, d) ? [c] : Yy(Cr(c)); + } + var EP = hr; + function Eo(c, d, A) { + var j = c.length; + return A = A === r ? j : A, !d && A >= j ? c : Ni(c, d, A); + } + var xy = fA || function(c) { + return Er.clearTimeout(c); + }; + function _y(c, d) { + if (d) + return c.slice(); + var A = c.length, j = zb ? zb(A) : new c.constructor(A); + return c.copy(j), j; + } + function fp(c) { + var d = new c.constructor(c.byteLength); + return new Tl(d).set(new Tl(c)), d; + } + function SP(c, d) { + var A = d ? fp(c.buffer) : c.buffer; + return new c.constructor(A, c.byteOffset, c.byteLength); + } + function AP(c) { + var d = new c.constructor(c.source, Le.exec(c)); + return d.lastIndex = c.lastIndex, d; + } + function PP(c) { + return lu ? qr(lu.call(c)) : {}; + } + function Ey(c, d) { + var A = d ? fp(c.buffer) : c.buffer; + return new c.constructor(A, c.byteOffset, c.length); + } + function Sy(c, d) { + if (c !== d) { + var A = c !== r, j = c === null, G = c === c, se = yi(c), de = d !== r, ve = d === null, xe = d === d, He = yi(d); + if (!ve && !He && !se && c > d || se && de && xe && !ve && !He || j && de && xe || !A && xe || !G) + return 1; + if (!j && !se && !He && c < d || He && A && G && !j && !se || ve && A && G || !de && G || !xe) + return -1; + } + return 0; + } + function MP(c, d, A) { + for (var j = -1, G = c.criteria, se = d.criteria, de = G.length, ve = A.length; ++j < de; ) { + var xe = Sy(G[j], se[j]); + if (xe) { + if (j >= ve) + return xe; + var He = A[j]; + return xe * (He == "desc" ? -1 : 1); + } + } + return c.index - d.index; + } + function Ay(c, d, A, j) { + for (var G = -1, se = c.length, de = A.length, ve = -1, xe = d.length, He = xn(se - de, 0), We = Ce(xe + He), Je = !j; ++ve < xe; ) + We[ve] = d[ve]; + for (; ++G < de; ) + (Je || G < se) && (We[A[G]] = c[G]); + for (; He--; ) + We[ve++] = c[G++]; + return We; + } + function Py(c, d, A, j) { + for (var G = -1, se = c.length, de = -1, ve = A.length, xe = -1, He = d.length, We = xn(se - ve, 0), Je = Ce(We + He), xt = !j; ++G < We; ) + Je[G] = c[G]; + for (var Ot = G; ++xe < He; ) + Je[Ot + xe] = d[xe]; + for (; ++de < ve; ) + (xt || G < se) && (Je[Ot + A[de]] = c[G++]); + return Je; + } + function ii(c, d) { + var A = -1, j = c.length; + for (d || (d = Ce(j)); ++A < j; ) + d[A] = c[A]; + return d; + } + function vs(c, d, A, j) { + var G = !A; + A || (A = {}); + for (var se = -1, de = d.length; ++se < de; ) { + var ve = d[se], xe = j ? j(A[ve], c[ve], ve, A, c) : r; + xe === r && (xe = c[ve]), G ? Fs(A, ve, xe) : hu(A, ve, xe); + } + return A; + } + function IP(c, d) { + return vs(c, vp(c), d); + } + function CP(c, d) { + return vs(c, Fy(c), d); + } + function Kl(c, d) { + return function(A, j) { + var G = sr(A) ? N9 : XA, se = d ? d() : {}; + return G(A, c, Ut(j, 2), se); + }; + } + function ac(c) { + return hr(function(d, A) { + var j = -1, G = A.length, se = G > 1 ? A[G - 1] : r, de = G > 2 ? A[2] : r; + for (se = c.length > 3 && typeof se == "function" ? (G--, se) : r, de && Jn(A[0], A[1], de) && (se = G < 3 ? r : se, G = 1), d = qr(d); ++j < G; ) { + var ve = A[j]; + ve && c(d, ve, j, se); + } + return d; + }); + } + function My(c, d) { + return function(A, j) { + if (A == null) + return A; + if (!si(A)) + return c(A, j); + for (var G = A.length, se = d ? G : -1, de = qr(A); (d ? se-- : ++se < G) && j(de[se], se, de) !== !1; ) + ; + return A; + }; + } + function Iy(c) { + return function(d, A, j) { + for (var G = -1, se = qr(d), de = j(d), ve = de.length; ve--; ) { + var xe = de[c ? ve : ++G]; + if (A(se[xe], xe, se) === !1) + break; + } + return d; + }; + } + function RP(c, d, A) { + var j = d & D, G = vu(c); + function se() { + var de = this && this !== Er && this instanceof se ? G : c; + return de.apply(j ? A : this, arguments); + } + return se; + } + function Cy(c) { + return function(d) { + d = Cr(d); + var A = ec(d) ? Qi(d) : r, j = A ? A[0] : d.charAt(0), G = A ? Eo(A, 1).join("") : d.slice(1); + return j[c]() + G; + }; + } + function cc(c) { + return function(d) { + return L0(Mw(Pw(d).replace(iu, "")), c, ""); + }; + } + function vu(c) { + return function() { + var d = arguments; + switch (d.length) { + case 0: + return new c(); + case 1: + return new c(d[0]); + case 2: + return new c(d[0], d[1]); + case 3: + return new c(d[0], d[1], d[2]); + case 4: + return new c(d[0], d[1], d[2], d[3]); + case 5: + return new c(d[0], d[1], d[2], d[3], d[4]); + case 6: + return new c(d[0], d[1], d[2], d[3], d[4], d[5]); + case 7: + return new c(d[0], d[1], d[2], d[3], d[4], d[5], d[6]); + } + var A = oc(c.prototype), j = c.apply(A, d); + return Zr(j) ? j : A; + }; + } + function TP(c, d, A) { + var j = vu(c); + function G() { + for (var se = arguments.length, de = Ce(se), ve = se, xe = uc(G); ve--; ) + de[ve] = arguments[ve]; + var He = se < 3 && de[0] !== xe && de[se - 1] !== xe ? [] : bo(de, xe); + if (se -= He.length, se < A) + return Ny( + c, + d, + Vl, + G.placeholder, + r, + de, + He, + r, + r, + A - se + ); + var We = this && this !== Er && this instanceof G ? j : c; + return Sn(We, this, de); + } + return G; + } + function Ry(c) { + return function(d, A, j) { + var G = qr(d); + if (!si(d)) { + var se = Ut(A, 3); + d = An(d), A = function(ve) { + return se(G[ve], ve, G); + }; + } + var de = c(d, A, j); + return de > -1 ? G[se ? d[de] : de] : r; + }; + } + function Ty(c) { + return Us(function(d) { + var A = d.length, j = A, G = Di.prototype.thru; + for (c && d.reverse(); j--; ) { + var se = d[j]; + if (typeof se != "function") + throw new Ti(o); + if (G && !de && Xl(se) == "wrapper") + var de = new Di([], !0); + } + for (j = de ? j : A; ++j < A; ) { + se = d[j]; + var ve = Xl(se), xe = ve == "wrapper" ? gp(se) : r; + xe && yp(xe[0]) && xe[1] == (C | z | $ | W) && !xe[4].length && xe[9] == 1 ? de = de[Xl(xe[0])].apply(de, xe[3]) : de = se.length == 1 && yp(se) ? de[ve]() : de.thru(se); + } + return function() { + var He = arguments, We = He[0]; + if (de && He.length == 1 && sr(We)) + return de.plant(We).value(); + for (var Je = 0, xt = A ? d[Je].apply(this, He) : We; ++Je < A; ) + xt = d[Je].call(this, xt); + return xt; + }; + }); + } + function Vl(c, d, A, j, G, se, de, ve, xe, He) { + var We = d & C, Je = d & D, xt = d & k, Ot = d & (z | B), Wt = d & J, fr = xt ? r : vu(c); + function Kt() { + for (var yr = arguments.length, Sr = Ce(yr), wi = yr; wi--; ) + Sr[wi] = arguments[wi]; + if (Ot) + var Xn = uc(Kt), xi = z9(Sr, Xn); + if (j && (Sr = Ay(Sr, j, G, Ot)), se && (Sr = Py(Sr, se, de, Ot)), yr -= xi, Ot && yr < He) { + var cn = bo(Sr, Xn); + return Ny( + c, + d, + Vl, + Kt.placeholder, + A, + Sr, + cn, + ve, + xe, + He - yr + ); + } + var rs = Je ? A : this, Ws = xt ? rs[c] : c; + return yr = Sr.length, ve ? Sr = XP(Sr, ve) : Wt && yr > 1 && Sr.reverse(), We && xe < yr && (Sr.length = xe), this && this !== Er && this instanceof Kt && (Ws = fr || vu(Ws)), Ws.apply(rs, Sr); + } + return Kt; + } + function Dy(c, d) { + return function(A, j) { + return sP(A, c, d(j), {}); + }; + } + function Gl(c, d) { + return function(A, j) { + var G; + if (A === r && j === r) + return d; + if (A !== r && (G = A), j !== r) { + if (G === r) + return j; + typeof A == "string" || typeof j == "string" ? (A = bi(A), j = bi(j)) : (A = vy(A), j = vy(j)), G = c(A, j); + } + return G; + }; + } + function lp(c) { + return Us(function(d) { + return d = Xr(d, vi(Ut())), hr(function(A) { + var j = this; + return c(d, function(G) { + return Sn(G, j, A); + }); + }); + }); + } + function Yl(c, d) { + d = d === r ? " " : bi(d); + var A = d.length; + if (A < 2) + return A ? ip(d, c) : d; + var j = ip(d, Ll(c / tc(d))); + return ec(d) ? Eo(Qi(j), 0, c).join("") : j.slice(0, c); + } + function DP(c, d, A, j) { + var G = d & D, se = vu(c); + function de() { + for (var ve = -1, xe = arguments.length, He = -1, We = j.length, Je = Ce(We + xe), xt = this && this !== Er && this instanceof de ? se : c; ++He < We; ) + Je[He] = j[He]; + for (; xe--; ) + Je[He++] = arguments[++ve]; + return Sn(xt, G ? A : this, Je); + } + return de; + } + function Oy(c) { + return function(d, A, j) { + return j && typeof j != "number" && Jn(d, A, j) && (A = j = r), d = Hs(d), A === r ? (A = d, d = 0) : A = Hs(A), j = j === r ? d < A ? 1 : -1 : Hs(j), vP(d, A, j, c); + }; + } + function Jl(c) { + return function(d, A) { + return typeof d == "string" && typeof A == "string" || (d = ki(d), A = ki(A)), c(d, A); + }; + } + function Ny(c, d, A, j, G, se, de, ve, xe, He) { + var We = d & z, Je = We ? de : r, xt = We ? r : de, Ot = We ? se : r, Wt = We ? r : se; + d |= We ? $ : U, d &= ~(We ? U : $), d & N || (d &= -4); + var fr = [ + c, + d, + G, + Ot, + Je, + Wt, + xt, + ve, + xe, + He + ], Kt = A.apply(r, fr); + return yp(c) && Ky(Kt, fr), Kt.placeholder = j, Vy(Kt, c, d); + } + function hp(c) { + var d = wn[c]; + return function(A, j) { + if (A = ki(A), j = j == null ? 0 : jn(cr(j), 292), j && Vb(A)) { + var G = (Cr(A) + "e").split("e"), se = d(G[0] + "e" + (+G[1] + j)); + return G = (Cr(se) + "e").split("e"), +(G[0] + "e" + (+G[1] - j)); + } + return d(A); + }; + } + var OP = ic && 1 / Al(new ic([, -0]))[1] == w ? function(c) { + return new ic(c); + } : Np; + function Ly(c) { + return function(d) { + var A = Un(d); + return A == ae ? q0(d) : A == Me ? J9(d) : q9(d, c(d)); + }; + } + function js(c, d, A, j, G, se, de, ve) { + var xe = d & k; + if (!xe && typeof c != "function") + throw new Ti(o); + var He = j ? j.length : 0; + if (He || (d &= -97, j = G = r), de = de === r ? de : xn(cr(de), 0), ve = ve === r ? ve : cr(ve), He -= G ? G.length : 0, d & U) { + var We = j, Je = G; + j = G = r; + } + var xt = xe ? r : gp(c), Ot = [ + c, + d, + A, + j, + G, + We, + Je, + se, + de, + ve + ]; + if (xt && GP(Ot, xt), c = Ot[0], d = Ot[1], A = Ot[2], j = Ot[3], G = Ot[4], ve = Ot[9] = Ot[9] === r ? xe ? 0 : c.length : xn(Ot[9] - He, 0), !ve && d & (z | B) && (d &= -25), !d || d == D) + var Wt = RP(c, d, A); + else d == z || d == B ? Wt = TP(c, d, ve) : (d == $ || d == (D | $)) && !G.length ? Wt = DP(c, d, A, j) : Wt = Vl.apply(r, Ot); + var fr = xt ? gy : Ky; + return Vy(fr(Wt, Ot), c, d); + } + function ky(c, d, A, j) { + return c === r || ts(c, nc[A]) && !Rr.call(j, A) ? d : c; + } + function $y(c, d, A, j, G, se) { + return Zr(c) && Zr(d) && (se.set(d, c), zl(c, d, r, $y, se), se.delete(d)), c; + } + function NP(c) { + return wu(c) ? r : c; + } + function By(c, d, A, j, G, se) { + var de = A & S, ve = c.length, xe = d.length; + if (ve != xe && !(de && xe > ve)) + return !1; + var He = se.get(c), We = se.get(d); + if (He && We) + return He == d && We == c; + var Je = -1, xt = !0, Ot = A & R ? new sa() : r; + for (se.set(c, d), se.set(d, c); ++Je < ve; ) { + var Wt = c[Je], fr = d[Je]; + if (j) + var Kt = de ? j(fr, Wt, Je, d, c, se) : j(Wt, fr, Je, c, d, se); + if (Kt !== r) { + if (Kt) + continue; + xt = !1; + break; + } + if (Ot) { + if (!k0(d, function(yr, Sr) { + if (!ou(Ot, Sr) && (Wt === yr || G(Wt, yr, A, j, se))) + return Ot.push(Sr); + })) { + xt = !1; + break; + } + } else if (!(Wt === fr || G(Wt, fr, A, j, se))) { + xt = !1; + break; + } + } + return se.delete(c), se.delete(d), xt; + } + function LP(c, d, A, j, G, se, de) { + switch (A) { + case Ze: + if (c.byteLength != d.byteLength || c.byteOffset != d.byteOffset) + return !1; + c = c.buffer, d = d.buffer; + case _e: + return !(c.byteLength != d.byteLength || !se(new Tl(c), new Tl(d))); + case X: + case ee: + case fe: + return ts(+c, +d); + case Z: + return c.name == d.name && c.message == d.message; + case $e: + case Oe: + return c == d + ""; + case ae: + var ve = q0; + case Me: + var xe = j & S; + if (ve || (ve = Al), c.size != d.size && !xe) + return !1; + var He = de.get(c); + if (He) + return He == d; + j |= R, de.set(c, d); + var We = By(ve(c), ve(d), j, G, se, de); + return de.delete(c), We; + case ze: + if (lu) + return lu.call(c) == lu.call(d); + } + return !1; + } + function kP(c, d, A, j, G, se) { + var de = A & S, ve = dp(c), xe = ve.length, He = dp(d), We = He.length; + if (xe != We && !de) + return !1; + for (var Je = xe; Je--; ) { + var xt = ve[Je]; + if (!(de ? xt in d : Rr.call(d, xt))) + return !1; + } + var Ot = se.get(c), Wt = se.get(d); + if (Ot && Wt) + return Ot == d && Wt == c; + var fr = !0; + se.set(c, d), se.set(d, c); + for (var Kt = de; ++Je < xe; ) { + xt = ve[Je]; + var yr = c[xt], Sr = d[xt]; + if (j) + var wi = de ? j(Sr, yr, xt, d, c, se) : j(yr, Sr, xt, c, d, se); + if (!(wi === r ? yr === Sr || G(yr, Sr, A, j, se) : wi)) { + fr = !1; + break; + } + Kt || (Kt = xt == "constructor"); + } + if (fr && !Kt) { + var Xn = c.constructor, xi = d.constructor; + Xn != xi && "constructor" in c && "constructor" in d && !(typeof Xn == "function" && Xn instanceof Xn && typeof xi == "function" && xi instanceof xi) && (fr = !1); + } + return se.delete(c), se.delete(d), fr; + } + function Us(c) { + return xp(Hy(c, r, Qy), c + ""); + } + function dp(c) { + return iy(c, An, vp); + } + function pp(c) { + return iy(c, oi, Fy); + } + var gp = $l ? function(c) { + return $l.get(c); + } : Np; + function Xl(c) { + for (var d = c.name + "", A = sc[d], j = Rr.call(sc, d) ? A.length : 0; j--; ) { + var G = A[j], se = G.func; + if (se == null || se == c) + return G.name; + } + return d; + } + function uc(c) { + var d = Rr.call(te, "placeholder") ? te : c; + return d.placeholder; + } + function Ut() { + var c = te.iteratee || Dp; + return c = c === Dp ? ay : c, arguments.length ? c(arguments[0], arguments[1]) : c; + } + function Zl(c, d) { + var A = c.__data__; + return HP(d) ? A[typeof d == "string" ? "string" : "hash"] : A.map; + } + function mp(c) { + for (var d = An(c), A = d.length; A--; ) { + var j = d[A], G = c[j]; + d[A] = [j, G, qy(G)]; + } + return d; + } + function ca(c, d) { + var A = V9(c, d); + return oy(A) ? A : r; + } + function $P(c) { + var d = Rr.call(c, na), A = c[na]; + try { + c[na] = r; + var j = !0; + } catch { + } + var G = Cl.call(c); + return j && (d ? c[na] = A : delete c[na]), G; + } + var vp = H0 ? function(c) { + return c == null ? [] : (c = qr(c), mo(H0(c), function(d) { + return Wb.call(c, d); + })); + } : Lp, Fy = H0 ? function(c) { + for (var d = []; c; ) + vo(d, vp(c)), c = Dl(c); + return d; + } : Lp, Un = Yn; + (W0 && Un(new W0(new ArrayBuffer(1))) != Ze || cu && Un(new cu()) != ae || K0 && Un(K0.resolve()) != Te || ic && Un(new ic()) != Me || uu && Un(new uu()) != je) && (Un = function(c) { + var d = Yn(c), A = d == Ae ? c.constructor : r, j = A ? ua(A) : ""; + if (j) + switch (j) { + case yA: + return Ze; + case wA: + return ae; + case xA: + return Te; + case _A: + return Me; + case EA: + return je; + } + return d; + }); + function BP(c, d, A) { + for (var j = -1, G = A.length; ++j < G; ) { + var se = A[j], de = se.size; + switch (se.type) { + case "drop": + c += de; + break; + case "dropRight": + d -= de; + break; + case "take": + d = jn(d, c + de); + break; + case "takeRight": + c = xn(c, d - de); + break; + } + } + return { start: c, end: d }; + } + function FP(c) { + var d = c.match(T); + return d ? d[1].split(F) : []; + } + function jy(c, d, A) { + d = _o(d, c); + for (var j = -1, G = d.length, se = !1; ++j < G; ) { + var de = bs(d[j]); + if (!(se = c != null && A(c, de))) + break; + c = c[de]; + } + return se || ++j != G ? se : (G = c == null ? 0 : c.length, !!G && sh(G) && qs(de, G) && (sr(c) || fa(c))); + } + function jP(c) { + var d = c.length, A = new c.constructor(d); + return d && typeof c[0] == "string" && Rr.call(c, "index") && (A.index = c.index, A.input = c.input), A; + } + function Uy(c) { + return typeof c.constructor == "function" && !bu(c) ? oc(Dl(c)) : {}; + } + function UP(c, d, A) { + var j = c.constructor; + switch (d) { + case _e: + return fp(c); + case X: + case ee: + return new j(+c); + case Ze: + return SP(c, A); + case ot: + case ke: + case rt: + case nt: + case Ge: + case ht: + case lt: + case ct: + case qt: + return Ey(c, A); + case ae: + return new j(); + case fe: + case Oe: + return new j(c); + case $e: + return AP(c); + case Me: + return new j(); + case ze: + return PP(c); + } + } + function qP(c, d) { + var A = d.length; + if (!A) + return c; + var j = A - 1; + return d[j] = (A > 1 ? "& " : "") + d[j], d = d.join(A > 2 ? ", " : " "), c.replace(Y, `{ +/* [wrapped with ` + d + `] */ +`); + } + function zP(c) { + return sr(c) || fa(c) || !!(Kb && c && c[Kb]); + } + function qs(c, d) { + var A = typeof c; + return d = d ?? P, !!d && (A == "number" || A != "symbol" && st.test(c)) && c > -1 && c % 1 == 0 && c < d; + } + function Jn(c, d, A) { + if (!Zr(A)) + return !1; + var j = typeof d; + return (j == "number" ? si(A) && qs(d, A.length) : j == "string" && d in A) ? ts(A[d], c) : !1; + } + function bp(c, d) { + if (sr(c)) + return !1; + var A = typeof c; + return A == "number" || A == "symbol" || A == "boolean" || c == null || yi(c) ? !0 : Bt.test(c) || !mt.test(c) || d != null && c in qr(d); + } + function HP(c) { + var d = typeof c; + return d == "string" || d == "number" || d == "symbol" || d == "boolean" ? c !== "__proto__" : c === null; + } + function yp(c) { + var d = Xl(c), A = te[d]; + if (typeof A != "function" || !(d in _r.prototype)) + return !1; + if (c === A) + return !0; + var j = gp(A); + return !!j && c === j[0]; + } + function WP(c) { + return !!qb && qb in c; + } + var KP = Ml ? zs : kp; + function bu(c) { + var d = c && c.constructor, A = typeof d == "function" && d.prototype || nc; + return c === A; + } + function qy(c) { + return c === c && !Zr(c); + } + function zy(c, d) { + return function(A) { + return A == null ? !1 : A[c] === d && (d !== r || c in qr(A)); + }; + } + function VP(c) { + var d = nh(c, function(j) { + return A.size === u && A.clear(), j; + }), A = d.cache; + return d; + } + function GP(c, d) { + var A = c[1], j = d[1], G = A | j, se = G < (D | k | C), de = j == C && A == z || j == C && A == W && c[7].length <= d[8] || j == (C | W) && d[7].length <= d[8] && A == z; + if (!(se || de)) + return c; + j & D && (c[2] = d[2], G |= A & D ? 0 : N); + var ve = d[3]; + if (ve) { + var xe = c[3]; + c[3] = xe ? Ay(xe, ve, d[4]) : ve, c[4] = xe ? bo(c[3], h) : d[4]; + } + return ve = d[5], ve && (xe = c[5], c[5] = xe ? Py(xe, ve, d[6]) : ve, c[6] = xe ? bo(c[5], h) : d[6]), ve = d[7], ve && (c[7] = ve), j & C && (c[8] = c[8] == null ? d[8] : jn(c[8], d[8])), c[9] == null && (c[9] = d[9]), c[0] = d[0], c[1] = G, c; + } + function YP(c) { + var d = []; + if (c != null) + for (var A in qr(c)) + d.push(A); + return d; + } + function JP(c) { + return Cl.call(c); + } + function Hy(c, d, A) { + return d = xn(d === r ? c.length - 1 : d, 0), function() { + for (var j = arguments, G = -1, se = xn(j.length - d, 0), de = Ce(se); ++G < se; ) + de[G] = j[d + G]; + G = -1; + for (var ve = Ce(d + 1); ++G < d; ) + ve[G] = j[G]; + return ve[d] = A(de), Sn(c, this, ve); + }; + } + function Wy(c, d) { + return d.length < 2 ? c : aa(c, Ni(d, 0, -1)); + } + function XP(c, d) { + for (var A = c.length, j = jn(d.length, A), G = ii(c); j--; ) { + var se = d[j]; + c[j] = qs(se, A) ? G[se] : r; + } + return c; + } + function wp(c, d) { + if (!(d === "constructor" && typeof c[d] == "function") && d != "__proto__") + return c[d]; + } + var Ky = Gy(gy), yu = hA || function(c, d) { + return Er.setTimeout(c, d); + }, xp = Gy(wP); + function Vy(c, d, A) { + var j = d + ""; + return xp(c, qP(j, ZP(FP(j), A))); + } + function Gy(c) { + var d = 0, A = 0; + return function() { + var j = mA(), G = b - (j - A); + if (A = j, G > 0) { + if (++d >= E) + return arguments[0]; + } else + d = 0; + return c.apply(r, arguments); + }; + } + function Ql(c, d) { + var A = -1, j = c.length, G = j - 1; + for (d = d === r ? j : d; ++A < d; ) { + var se = np(A, G), de = c[se]; + c[se] = c[A], c[A] = de; + } + return c.length = d, c; + } + var Yy = VP(function(c) { + var d = []; + return c.charCodeAt(0) === 46 && d.push(""), c.replace(Ft, function(A, j, G, se) { + d.push(G ? se.replace(me, "$1") : j || A); + }), d; + }); + function bs(c) { + if (typeof c == "string" || yi(c)) + return c; + var d = c + ""; + return d == "0" && 1 / c == -w ? "-0" : d; + } + function ua(c) { + if (c != null) { + try { + return Il.call(c); + } catch { + } + try { + return c + ""; + } catch { + } + } + return ""; + } + function ZP(c, d) { + return Ri(ce, function(A) { + var j = "_." + A[0]; + d & A[1] && !El(c, j) && c.push(j); + }), c.sort(); + } + function Jy(c) { + if (c instanceof _r) + return c.clone(); + var d = new Di(c.__wrapped__, c.__chain__); + return d.__actions__ = ii(c.__actions__), d.__index__ = c.__index__, d.__values__ = c.__values__, d; + } + function QP(c, d, A) { + (A ? Jn(c, d, A) : d === r) ? d = 1 : d = xn(cr(d), 0); + var j = c == null ? 0 : c.length; + if (!j || d < 1) + return []; + for (var G = 0, se = 0, de = Ce(Ll(j / d)); G < j; ) + de[se++] = Ni(c, G, G += d); + return de; + } + function eM(c) { + for (var d = -1, A = c == null ? 0 : c.length, j = 0, G = []; ++d < A; ) { + var se = c[d]; + se && (G[j++] = se); + } + return G; + } + function tM() { + var c = arguments.length; + if (!c) + return []; + for (var d = Ce(c - 1), A = arguments[0], j = c; j--; ) + d[j - 1] = arguments[j]; + return vo(sr(A) ? ii(A) : [A], On(d, 1)); + } + var rM = hr(function(c, d) { + return an(c) ? du(c, On(d, 1, an, !0)) : []; + }), nM = hr(function(c, d) { + var A = Li(d); + return an(A) && (A = r), an(c) ? du(c, On(d, 1, an, !0), Ut(A, 2)) : []; + }), iM = hr(function(c, d) { + var A = Li(d); + return an(A) && (A = r), an(c) ? du(c, On(d, 1, an, !0), r, A) : []; + }); + function sM(c, d, A) { + var j = c == null ? 0 : c.length; + return j ? (d = A || d === r ? 1 : cr(d), Ni(c, d < 0 ? 0 : d, j)) : []; + } + function oM(c, d, A) { + var j = c == null ? 0 : c.length; + return j ? (d = A || d === r ? 1 : cr(d), d = j - d, Ni(c, 0, d < 0 ? 0 : d)) : []; + } + function aM(c, d) { + return c && c.length ? Wl(c, Ut(d, 3), !0, !0) : []; + } + function cM(c, d) { + return c && c.length ? Wl(c, Ut(d, 3), !0) : []; + } + function uM(c, d, A, j) { + var G = c == null ? 0 : c.length; + return G ? (A && typeof A != "number" && Jn(c, d, A) && (A = 0, j = G), tP(c, d, A, j)) : []; + } + function Xy(c, d, A) { + var j = c == null ? 0 : c.length; + if (!j) + return -1; + var G = A == null ? 0 : cr(A); + return G < 0 && (G = xn(j + G, 0)), Sl(c, Ut(d, 3), G); + } + function Zy(c, d, A) { + var j = c == null ? 0 : c.length; + if (!j) + return -1; + var G = j - 1; + return A !== r && (G = cr(A), G = A < 0 ? xn(j + G, 0) : jn(G, j - 1)), Sl(c, Ut(d, 3), G, !0); + } + function Qy(c) { + var d = c == null ? 0 : c.length; + return d ? On(c, 1) : []; + } + function fM(c) { + var d = c == null ? 0 : c.length; + return d ? On(c, w) : []; + } + function lM(c, d) { + var A = c == null ? 0 : c.length; + return A ? (d = d === r ? 1 : cr(d), On(c, d)) : []; + } + function hM(c) { + for (var d = -1, A = c == null ? 0 : c.length, j = {}; ++d < A; ) { + var G = c[d]; + j[G[0]] = G[1]; + } + return j; + } + function ew(c) { + return c && c.length ? c[0] : r; + } + function dM(c, d, A) { + var j = c == null ? 0 : c.length; + if (!j) + return -1; + var G = A == null ? 0 : cr(A); + return G < 0 && (G = xn(j + G, 0)), Qa(c, d, G); + } + function pM(c) { + var d = c == null ? 0 : c.length; + return d ? Ni(c, 0, -1) : []; + } + var gM = hr(function(c) { + var d = Xr(c, cp); + return d.length && d[0] === c[0] ? Z0(d) : []; + }), mM = hr(function(c) { + var d = Li(c), A = Xr(c, cp); + return d === Li(A) ? d = r : A.pop(), A.length && A[0] === c[0] ? Z0(A, Ut(d, 2)) : []; + }), vM = hr(function(c) { + var d = Li(c), A = Xr(c, cp); + return d = typeof d == "function" ? d : r, d && A.pop(), A.length && A[0] === c[0] ? Z0(A, r, d) : []; + }); + function bM(c, d) { + return c == null ? "" : pA.call(c, d); + } + function Li(c) { + var d = c == null ? 0 : c.length; + return d ? c[d - 1] : r; + } + function yM(c, d, A) { + var j = c == null ? 0 : c.length; + if (!j) + return -1; + var G = j; + return A !== r && (G = cr(A), G = G < 0 ? xn(j + G, 0) : jn(G, j - 1)), d === d ? Z9(c, d, G) : Sl(c, Nb, G, !0); + } + function wM(c, d) { + return c && c.length ? ly(c, cr(d)) : r; + } + var xM = hr(tw); + function tw(c, d) { + return c && c.length && d && d.length ? rp(c, d) : c; + } + function _M(c, d, A) { + return c && c.length && d && d.length ? rp(c, d, Ut(A, 2)) : c; + } + function EM(c, d, A) { + return c && c.length && d && d.length ? rp(c, d, r, A) : c; + } + var SM = Us(function(c, d) { + var A = c == null ? 0 : c.length, j = G0(c, d); + return py(c, Xr(d, function(G) { + return qs(G, A) ? +G : G; + }).sort(Sy)), j; + }); + function AM(c, d) { + var A = []; + if (!(c && c.length)) + return A; + var j = -1, G = [], se = c.length; + for (d = Ut(d, 3); ++j < se; ) { + var de = c[j]; + d(de, j, c) && (A.push(de), G.push(j)); + } + return py(c, G), A; + } + function _p(c) { + return c == null ? c : bA.call(c); + } + function PM(c, d, A) { + var j = c == null ? 0 : c.length; + return j ? (A && typeof A != "number" && Jn(c, d, A) ? (d = 0, A = j) : (d = d == null ? 0 : cr(d), A = A === r ? j : cr(A)), Ni(c, d, A)) : []; + } + function MM(c, d) { + return Hl(c, d); + } + function IM(c, d, A) { + return sp(c, d, Ut(A, 2)); + } + function CM(c, d) { + var A = c == null ? 0 : c.length; + if (A) { + var j = Hl(c, d); + if (j < A && ts(c[j], d)) + return j; + } + return -1; + } + function RM(c, d) { + return Hl(c, d, !0); + } + function TM(c, d, A) { + return sp(c, d, Ut(A, 2), !0); + } + function DM(c, d) { + var A = c == null ? 0 : c.length; + if (A) { + var j = Hl(c, d, !0) - 1; + if (ts(c[j], d)) + return j; + } + return -1; + } + function OM(c) { + return c && c.length ? my(c) : []; + } + function NM(c, d) { + return c && c.length ? my(c, Ut(d, 2)) : []; + } + function LM(c) { + var d = c == null ? 0 : c.length; + return d ? Ni(c, 1, d) : []; + } + function kM(c, d, A) { + return c && c.length ? (d = A || d === r ? 1 : cr(d), Ni(c, 0, d < 0 ? 0 : d)) : []; + } + function $M(c, d, A) { + var j = c == null ? 0 : c.length; + return j ? (d = A || d === r ? 1 : cr(d), d = j - d, Ni(c, d < 0 ? 0 : d, j)) : []; + } + function BM(c, d) { + return c && c.length ? Wl(c, Ut(d, 3), !1, !0) : []; + } + function FM(c, d) { + return c && c.length ? Wl(c, Ut(d, 3)) : []; + } + var jM = hr(function(c) { + return xo(On(c, 1, an, !0)); + }), UM = hr(function(c) { + var d = Li(c); + return an(d) && (d = r), xo(On(c, 1, an, !0), Ut(d, 2)); + }), qM = hr(function(c) { + var d = Li(c); + return d = typeof d == "function" ? d : r, xo(On(c, 1, an, !0), r, d); + }); + function zM(c) { + return c && c.length ? xo(c) : []; + } + function HM(c, d) { + return c && c.length ? xo(c, Ut(d, 2)) : []; + } + function WM(c, d) { + return d = typeof d == "function" ? d : r, c && c.length ? xo(c, r, d) : []; + } + function Ep(c) { + if (!(c && c.length)) + return []; + var d = 0; + return c = mo(c, function(A) { + if (an(A)) + return d = xn(A.length, d), !0; + }), j0(d, function(A) { + return Xr(c, $0(A)); + }); + } + function rw(c, d) { + if (!(c && c.length)) + return []; + var A = Ep(c); + return d == null ? A : Xr(A, function(j) { + return Sn(d, r, j); + }); + } + var KM = hr(function(c, d) { + return an(c) ? du(c, d) : []; + }), VM = hr(function(c) { + return ap(mo(c, an)); + }), GM = hr(function(c) { + var d = Li(c); + return an(d) && (d = r), ap(mo(c, an), Ut(d, 2)); + }), YM = hr(function(c) { + var d = Li(c); + return d = typeof d == "function" ? d : r, ap(mo(c, an), r, d); + }), JM = hr(Ep); + function XM(c, d) { + return wy(c || [], d || [], hu); + } + function ZM(c, d) { + return wy(c || [], d || [], mu); + } + var QM = hr(function(c) { + var d = c.length, A = d > 1 ? c[d - 1] : r; + return A = typeof A == "function" ? (c.pop(), A) : r, rw(c, A); + }); + function nw(c) { + var d = te(c); + return d.__chain__ = !0, d; + } + function eI(c, d) { + return d(c), c; + } + function eh(c, d) { + return d(c); + } + var tI = Us(function(c) { + var d = c.length, A = d ? c[0] : 0, j = this.__wrapped__, G = function(se) { + return G0(se, c); + }; + return d > 1 || this.__actions__.length || !(j instanceof _r) || !qs(A) ? this.thru(G) : (j = j.slice(A, +A + (d ? 1 : 0)), j.__actions__.push({ + func: eh, + args: [G], + thisArg: r + }), new Di(j, this.__chain__).thru(function(se) { + return d && !se.length && se.push(r), se; + })); + }); + function rI() { + return nw(this); + } + function nI() { + return new Di(this.value(), this.__chain__); + } + function iI() { + this.__values__ === r && (this.__values__ = vw(this.value())); + var c = this.__index__ >= this.__values__.length, d = c ? r : this.__values__[this.__index__++]; + return { done: c, value: d }; + } + function sI() { + return this; + } + function oI(c) { + for (var d, A = this; A instanceof Fl; ) { + var j = Jy(A); + j.__index__ = 0, j.__values__ = r, d ? G.__wrapped__ = j : d = j; + var G = j; + A = A.__wrapped__; + } + return G.__wrapped__ = c, d; + } + function aI() { + var c = this.__wrapped__; + if (c instanceof _r) { + var d = c; + return this.__actions__.length && (d = new _r(this)), d = d.reverse(), d.__actions__.push({ + func: eh, + args: [_p], + thisArg: r + }), new Di(d, this.__chain__); + } + return this.thru(_p); + } + function cI() { + return yy(this.__wrapped__, this.__actions__); + } + var uI = Kl(function(c, d, A) { + Rr.call(c, A) ? ++c[A] : Fs(c, A, 1); + }); + function fI(c, d, A) { + var j = sr(c) ? Db : eP; + return A && Jn(c, d, A) && (d = r), j(c, Ut(d, 3)); + } + function lI(c, d) { + var A = sr(c) ? mo : ry; + return A(c, Ut(d, 3)); + } + var hI = Ry(Xy), dI = Ry(Zy); + function pI(c, d) { + return On(th(c, d), 1); + } + function gI(c, d) { + return On(th(c, d), w); + } + function mI(c, d, A) { + return A = A === r ? 1 : cr(A), On(th(c, d), A); + } + function iw(c, d) { + var A = sr(c) ? Ri : wo; + return A(c, Ut(d, 3)); + } + function sw(c, d) { + var A = sr(c) ? L9 : ty; + return A(c, Ut(d, 3)); + } + var vI = Kl(function(c, d, A) { + Rr.call(c, A) ? c[A].push(d) : Fs(c, A, [d]); + }); + function bI(c, d, A, j) { + c = si(c) ? c : lc(c), A = A && !j ? cr(A) : 0; + var G = c.length; + return A < 0 && (A = xn(G + A, 0)), oh(c) ? A <= G && c.indexOf(d, A) > -1 : !!G && Qa(c, d, A) > -1; + } + var yI = hr(function(c, d, A) { + var j = -1, G = typeof d == "function", se = si(c) ? Ce(c.length) : []; + return wo(c, function(de) { + se[++j] = G ? Sn(d, de, A) : pu(de, d, A); + }), se; + }), wI = Kl(function(c, d, A) { + Fs(c, A, d); + }); + function th(c, d) { + var A = sr(c) ? Xr : cy; + return A(c, Ut(d, 3)); + } + function xI(c, d, A, j) { + return c == null ? [] : (sr(d) || (d = d == null ? [] : [d]), A = j ? r : A, sr(A) || (A = A == null ? [] : [A]), hy(c, d, A)); + } + var _I = Kl(function(c, d, A) { + c[A ? 0 : 1].push(d); + }, function() { + return [[], []]; + }); + function EI(c, d, A) { + var j = sr(c) ? L0 : kb, G = arguments.length < 3; + return j(c, Ut(d, 4), A, G, wo); + } + function SI(c, d, A) { + var j = sr(c) ? k9 : kb, G = arguments.length < 3; + return j(c, Ut(d, 4), A, G, ty); + } + function AI(c, d) { + var A = sr(c) ? mo : ry; + return A(c, ih(Ut(d, 3))); + } + function PI(c) { + var d = sr(c) ? Xb : bP; + return d(c); + } + function MI(c, d, A) { + (A ? Jn(c, d, A) : d === r) ? d = 1 : d = cr(d); + var j = sr(c) ? YA : yP; + return j(c, d); + } + function II(c) { + var d = sr(c) ? JA : xP; + return d(c); + } + function CI(c) { + if (c == null) + return 0; + if (si(c)) + return oh(c) ? tc(c) : c.length; + var d = Un(c); + return d == ae || d == Me ? c.size : ep(c).length; + } + function RI(c, d, A) { + var j = sr(c) ? k0 : _P; + return A && Jn(c, d, A) && (d = r), j(c, Ut(d, 3)); + } + var TI = hr(function(c, d) { + if (c == null) + return []; + var A = d.length; + return A > 1 && Jn(c, d[0], d[1]) ? d = [] : A > 2 && Jn(d[0], d[1], d[2]) && (d = [d[0]]), hy(c, On(d, 1), []); + }), rh = lA || function() { + return Er.Date.now(); + }; + function DI(c, d) { + if (typeof d != "function") + throw new Ti(o); + return c = cr(c), function() { + if (--c < 1) + return d.apply(this, arguments); + }; + } + function ow(c, d, A) { + return d = A ? r : d, d = c && d == null ? c.length : d, js(c, C, r, r, r, r, d); + } + function aw(c, d) { + var A; + if (typeof d != "function") + throw new Ti(o); + return c = cr(c), function() { + return --c > 0 && (A = d.apply(this, arguments)), c <= 1 && (d = r), A; + }; + } + var Sp = hr(function(c, d, A) { + var j = D; + if (A.length) { + var G = bo(A, uc(Sp)); + j |= $; + } + return js(c, j, d, A, G); + }), cw = hr(function(c, d, A) { + var j = D | k; + if (A.length) { + var G = bo(A, uc(cw)); + j |= $; + } + return js(d, j, c, A, G); + }); + function uw(c, d, A) { + d = A ? r : d; + var j = js(c, z, r, r, r, r, r, d); + return j.placeholder = uw.placeholder, j; + } + function fw(c, d, A) { + d = A ? r : d; + var j = js(c, B, r, r, r, r, r, d); + return j.placeholder = fw.placeholder, j; + } + function lw(c, d, A) { + var j, G, se, de, ve, xe, He = 0, We = !1, Je = !1, xt = !0; + if (typeof c != "function") + throw new Ti(o); + d = ki(d) || 0, Zr(A) && (We = !!A.leading, Je = "maxWait" in A, se = Je ? xn(ki(A.maxWait) || 0, d) : se, xt = "trailing" in A ? !!A.trailing : xt); + function Ot(cn) { + var rs = j, Ws = G; + return j = G = r, He = cn, de = c.apply(Ws, rs), de; + } + function Wt(cn) { + return He = cn, ve = yu(yr, d), We ? Ot(cn) : de; + } + function fr(cn) { + var rs = cn - xe, Ws = cn - He, Rw = d - rs; + return Je ? jn(Rw, se - Ws) : Rw; + } + function Kt(cn) { + var rs = cn - xe, Ws = cn - He; + return xe === r || rs >= d || rs < 0 || Je && Ws >= se; + } + function yr() { + var cn = rh(); + if (Kt(cn)) + return Sr(cn); + ve = yu(yr, fr(cn)); + } + function Sr(cn) { + return ve = r, xt && j ? Ot(cn) : (j = G = r, de); + } + function wi() { + ve !== r && xy(ve), He = 0, j = xe = G = ve = r; + } + function Xn() { + return ve === r ? de : Sr(rh()); + } + function xi() { + var cn = rh(), rs = Kt(cn); + if (j = arguments, G = this, xe = cn, rs) { + if (ve === r) + return Wt(xe); + if (Je) + return xy(ve), ve = yu(yr, d), Ot(xe); + } + return ve === r && (ve = yu(yr, d)), de; + } + return xi.cancel = wi, xi.flush = Xn, xi; + } + var OI = hr(function(c, d) { + return ey(c, 1, d); + }), NI = hr(function(c, d, A) { + return ey(c, ki(d) || 0, A); + }); + function LI(c) { + return js(c, J); + } + function nh(c, d) { + if (typeof c != "function" || d != null && typeof d != "function") + throw new Ti(o); + var A = function() { + var j = arguments, G = d ? d.apply(this, j) : j[0], se = A.cache; + if (se.has(G)) + return se.get(G); + var de = c.apply(this, j); + return A.cache = se.set(G, de) || se, de; + }; + return A.cache = new (nh.Cache || Bs)(), A; + } + nh.Cache = Bs; + function ih(c) { + if (typeof c != "function") + throw new Ti(o); + return function() { + var d = arguments; + switch (d.length) { + case 0: + return !c.call(this); + case 1: + return !c.call(this, d[0]); + case 2: + return !c.call(this, d[0], d[1]); + case 3: + return !c.call(this, d[0], d[1], d[2]); + } + return !c.apply(this, d); + }; + } + function kI(c) { + return aw(2, c); + } + var $I = EP(function(c, d) { + d = d.length == 1 && sr(d[0]) ? Xr(d[0], vi(Ut())) : Xr(On(d, 1), vi(Ut())); + var A = d.length; + return hr(function(j) { + for (var G = -1, se = jn(j.length, A); ++G < se; ) + j[G] = d[G].call(this, j[G]); + return Sn(c, this, j); + }); + }), Ap = hr(function(c, d) { + var A = bo(d, uc(Ap)); + return js(c, $, r, d, A); + }), hw = hr(function(c, d) { + var A = bo(d, uc(hw)); + return js(c, U, r, d, A); + }), BI = Us(function(c, d) { + return js(c, W, r, r, r, d); + }); + function FI(c, d) { + if (typeof c != "function") + throw new Ti(o); + return d = d === r ? d : cr(d), hr(c, d); + } + function jI(c, d) { + if (typeof c != "function") + throw new Ti(o); + return d = d == null ? 0 : xn(cr(d), 0), hr(function(A) { + var j = A[d], G = Eo(A, 0, d); + return j && vo(G, j), Sn(c, this, G); + }); + } + function UI(c, d, A) { + var j = !0, G = !0; + if (typeof c != "function") + throw new Ti(o); + return Zr(A) && (j = "leading" in A ? !!A.leading : j, G = "trailing" in A ? !!A.trailing : G), lw(c, d, { + leading: j, + maxWait: d, + trailing: G + }); + } + function qI(c) { + return ow(c, 1); + } + function zI(c, d) { + return Ap(up(d), c); + } + function HI() { + if (!arguments.length) + return []; + var c = arguments[0]; + return sr(c) ? c : [c]; + } + function WI(c) { + return Oi(c, x); + } + function KI(c, d) { + return d = typeof d == "function" ? d : r, Oi(c, x, d); + } + function VI(c) { + return Oi(c, g | x); + } + function GI(c, d) { + return d = typeof d == "function" ? d : r, Oi(c, g | x, d); + } + function YI(c, d) { + return d == null || Qb(c, d, An(d)); + } + function ts(c, d) { + return c === d || c !== c && d !== d; + } + var JI = Jl(X0), XI = Jl(function(c, d) { + return c >= d; + }), fa = sy(/* @__PURE__ */ (function() { + return arguments; + })()) ? sy : function(c) { + return en(c) && Rr.call(c, "callee") && !Wb.call(c, "callee"); + }, sr = Ce.isArray, ZI = Gn ? vi(Gn) : oP; + function si(c) { + return c != null && sh(c.length) && !zs(c); + } + function an(c) { + return en(c) && si(c); + } + function QI(c) { + return c === !0 || c === !1 || en(c) && Yn(c) == X; + } + var So = dA || kp, eC = Zi ? vi(Zi) : aP; + function tC(c) { + return en(c) && c.nodeType === 1 && !wu(c); + } + function rC(c) { + if (c == null) + return !0; + if (si(c) && (sr(c) || typeof c == "string" || typeof c.splice == "function" || So(c) || fc(c) || fa(c))) + return !c.length; + var d = Un(c); + if (d == ae || d == Me) + return !c.size; + if (bu(c)) + return !ep(c).length; + for (var A in c) + if (Rr.call(c, A)) + return !1; + return !0; + } + function nC(c, d) { + return gu(c, d); + } + function iC(c, d, A) { + A = typeof A == "function" ? A : r; + var j = A ? A(c, d) : r; + return j === r ? gu(c, d, r, A) : !!j; + } + function Pp(c) { + if (!en(c)) + return !1; + var d = Yn(c); + return d == Z || d == O || typeof c.message == "string" && typeof c.name == "string" && !wu(c); + } + function sC(c) { + return typeof c == "number" && Vb(c); + } + function zs(c) { + if (!Zr(c)) + return !1; + var d = Yn(c); + return d == re || d == he || d == Q || d == Re; + } + function dw(c) { + return typeof c == "number" && c == cr(c); + } + function sh(c) { + return typeof c == "number" && c > -1 && c % 1 == 0 && c <= P; + } + function Zr(c) { + var d = typeof c; + return c != null && (d == "object" || d == "function"); + } + function en(c) { + return c != null && typeof c == "object"; + } + var pw = Ci ? vi(Ci) : uP; + function oC(c, d) { + return c === d || Q0(c, d, mp(d)); + } + function aC(c, d, A) { + return A = typeof A == "function" ? A : r, Q0(c, d, mp(d), A); + } + function cC(c) { + return gw(c) && c != +c; + } + function uC(c) { + if (KP(c)) + throw new rr(s); + return oy(c); + } + function fC(c) { + return c === null; + } + function lC(c) { + return c == null; + } + function gw(c) { + return typeof c == "number" || en(c) && Yn(c) == fe; + } + function wu(c) { + if (!en(c) || Yn(c) != Ae) + return !1; + var d = Dl(c); + if (d === null) + return !0; + var A = Rr.call(d, "constructor") && d.constructor; + return typeof A == "function" && A instanceof A && Il.call(A) == aA; + } + var Mp = gs ? vi(gs) : fP; + function hC(c) { + return dw(c) && c >= -P && c <= P; + } + var mw = su ? vi(su) : lP; + function oh(c) { + return typeof c == "string" || !sr(c) && en(c) && Yn(c) == Oe; + } + function yi(c) { + return typeof c == "symbol" || en(c) && Yn(c) == ze; + } + var fc = ra ? vi(ra) : hP; + function dC(c) { + return c === r; + } + function pC(c) { + return en(c) && Un(c) == je; + } + function gC(c) { + return en(c) && Yn(c) == Ue; + } + var mC = Jl(tp), vC = Jl(function(c, d) { + return c <= d; + }); + function vw(c) { + if (!c) + return []; + if (si(c)) + return oh(c) ? Qi(c) : ii(c); + if (au && c[au]) + return Y9(c[au]()); + var d = Un(c), A = d == ae ? q0 : d == Me ? Al : lc; + return A(c); + } + function Hs(c) { + if (!c) + return c === 0 ? c : 0; + if (c = ki(c), c === w || c === -w) { + var d = c < 0 ? -1 : 1; + return d * _; + } + return c === c ? c : 0; + } + function cr(c) { + var d = Hs(c), A = d % 1; + return d === d ? A ? d - A : d : 0; + } + function bw(c) { + return c ? oa(cr(c), 0, M) : 0; + } + function ki(c) { + if (typeof c == "number") + return c; + if (yi(c)) + return y; + if (Zr(c)) { + var d = typeof c.valueOf == "function" ? c.valueOf() : c; + c = Zr(d) ? d + "" : d; + } + if (typeof c != "string") + return c === 0 ? c : +c; + c = $b(c); + var A = Qe.test(c); + return A || tt.test(c) ? ir(c.slice(2), A ? 2 : 8) : Ie.test(c) ? y : +c; + } + function yw(c) { + return vs(c, oi(c)); + } + function bC(c) { + return c ? oa(cr(c), -P, P) : c === 0 ? c : 0; + } + function Cr(c) { + return c == null ? "" : bi(c); + } + var yC = ac(function(c, d) { + if (bu(d) || si(d)) { + vs(d, An(d), c); + return; + } + for (var A in d) + Rr.call(d, A) && hu(c, A, d[A]); + }), ww = ac(function(c, d) { + vs(d, oi(d), c); + }), ah = ac(function(c, d, A, j) { + vs(d, oi(d), c, j); + }), wC = ac(function(c, d, A, j) { + vs(d, An(d), c, j); + }), xC = Us(G0); + function _C(c, d) { + var A = oc(c); + return d == null ? A : Zb(A, d); + } + var EC = hr(function(c, d) { + c = qr(c); + var A = -1, j = d.length, G = j > 2 ? d[2] : r; + for (G && Jn(d[0], d[1], G) && (j = 1); ++A < j; ) + for (var se = d[A], de = oi(se), ve = -1, xe = de.length; ++ve < xe; ) { + var He = de[ve], We = c[He]; + (We === r || ts(We, nc[He]) && !Rr.call(c, He)) && (c[He] = se[He]); + } + return c; + }), SC = hr(function(c) { + return c.push(r, $y), Sn(xw, r, c); + }); + function AC(c, d) { + return Ob(c, Ut(d, 3), ms); + } + function PC(c, d) { + return Ob(c, Ut(d, 3), J0); + } + function MC(c, d) { + return c == null ? c : Y0(c, Ut(d, 3), oi); + } + function IC(c, d) { + return c == null ? c : ny(c, Ut(d, 3), oi); + } + function CC(c, d) { + return c && ms(c, Ut(d, 3)); + } + function RC(c, d) { + return c && J0(c, Ut(d, 3)); + } + function TC(c) { + return c == null ? [] : ql(c, An(c)); + } + function DC(c) { + return c == null ? [] : ql(c, oi(c)); + } + function Ip(c, d, A) { + var j = c == null ? r : aa(c, d); + return j === r ? A : j; + } + function OC(c, d) { + return c != null && jy(c, d, rP); + } + function Cp(c, d) { + return c != null && jy(c, d, nP); + } + var NC = Dy(function(c, d, A) { + d != null && typeof d.toString != "function" && (d = Cl.call(d)), c[d] = A; + }, Tp(ai)), LC = Dy(function(c, d, A) { + d != null && typeof d.toString != "function" && (d = Cl.call(d)), Rr.call(c, d) ? c[d].push(A) : c[d] = [A]; + }, Ut), kC = hr(pu); + function An(c) { + return si(c) ? Jb(c) : ep(c); + } + function oi(c) { + return si(c) ? Jb(c, !0) : dP(c); + } + function $C(c, d) { + var A = {}; + return d = Ut(d, 3), ms(c, function(j, G, se) { + Fs(A, d(j, G, se), j); + }), A; + } + function BC(c, d) { + var A = {}; + return d = Ut(d, 3), ms(c, function(j, G, se) { + Fs(A, G, d(j, G, se)); + }), A; + } + var FC = ac(function(c, d, A) { + zl(c, d, A); + }), xw = ac(function(c, d, A, j) { + zl(c, d, A, j); + }), jC = Us(function(c, d) { + var A = {}; + if (c == null) + return A; + var j = !1; + d = Xr(d, function(se) { + return se = _o(se, c), j || (j = se.length > 1), se; + }), vs(c, pp(c), A), j && (A = Oi(A, g | v | x, NP)); + for (var G = d.length; G--; ) + op(A, d[G]); + return A; + }); + function UC(c, d) { + return _w(c, ih(Ut(d))); + } + var qC = Us(function(c, d) { + return c == null ? {} : gP(c, d); + }); + function _w(c, d) { + if (c == null) + return {}; + var A = Xr(pp(c), function(j) { + return [j]; + }); + return d = Ut(d), dy(c, A, function(j, G) { + return d(j, G[0]); + }); + } + function zC(c, d, A) { + d = _o(d, c); + var j = -1, G = d.length; + for (G || (G = 1, c = r); ++j < G; ) { + var se = c == null ? r : c[bs(d[j])]; + se === r && (j = G, se = A), c = zs(se) ? se.call(c) : se; + } + return c; + } + function HC(c, d, A) { + return c == null ? c : mu(c, d, A); + } + function WC(c, d, A, j) { + return j = typeof j == "function" ? j : r, c == null ? c : mu(c, d, A, j); + } + var Ew = Ly(An), Sw = Ly(oi); + function KC(c, d, A) { + var j = sr(c), G = j || So(c) || fc(c); + if (d = Ut(d, 4), A == null) { + var se = c && c.constructor; + G ? A = j ? new se() : [] : Zr(c) ? A = zs(se) ? oc(Dl(c)) : {} : A = {}; + } + return (G ? Ri : ms)(c, function(de, ve, xe) { + return d(A, de, ve, xe); + }), A; + } + function VC(c, d) { + return c == null ? !0 : op(c, d); + } + function GC(c, d, A) { + return c == null ? c : by(c, d, up(A)); + } + function YC(c, d, A, j) { + return j = typeof j == "function" ? j : r, c == null ? c : by(c, d, up(A), j); + } + function lc(c) { + return c == null ? [] : U0(c, An(c)); + } + function JC(c) { + return c == null ? [] : U0(c, oi(c)); + } + function XC(c, d, A) { + return A === r && (A = d, d = r), A !== r && (A = ki(A), A = A === A ? A : 0), d !== r && (d = ki(d), d = d === d ? d : 0), oa(ki(c), d, A); + } + function ZC(c, d, A) { + return d = Hs(d), A === r ? (A = d, d = 0) : A = Hs(A), c = ki(c), iP(c, d, A); + } + function QC(c, d, A) { + if (A && typeof A != "boolean" && Jn(c, d, A) && (d = A = r), A === r && (typeof d == "boolean" ? (A = d, d = r) : typeof c == "boolean" && (A = c, c = r)), c === r && d === r ? (c = 0, d = 1) : (c = Hs(c), d === r ? (d = c, c = 0) : d = Hs(d)), c > d) { + var j = c; + c = d, d = j; + } + if (A || c % 1 || d % 1) { + var G = Gb(); + return jn(c + G * (d - c + jr("1e-" + ((G + "").length - 1))), d); + } + return np(c, d); + } + var eR = cc(function(c, d, A) { + return d = d.toLowerCase(), c + (A ? Aw(d) : d); + }); + function Aw(c) { + return Rp(Cr(c).toLowerCase()); + } + function Pw(c) { + return c = Cr(c), c && c.replace(vt, H9).replace(D0, ""); + } + function tR(c, d, A) { + c = Cr(c), d = bi(d); + var j = c.length; + A = A === r ? j : oa(cr(A), 0, j); + var G = A; + return A -= d.length, A >= 0 && c.slice(A, G) == d; + } + function rR(c) { + return c = Cr(c), c && It.test(c) ? c.replace(Tt, W9) : c; + } + function nR(c) { + return c = Cr(c), c && $t.test(c) ? c.replace(et, "\\$&") : c; + } + var iR = cc(function(c, d, A) { + return c + (A ? "-" : "") + d.toLowerCase(); + }), sR = cc(function(c, d, A) { + return c + (A ? " " : "") + d.toLowerCase(); + }), oR = Cy("toLowerCase"); + function aR(c, d, A) { + c = Cr(c), d = cr(d); + var j = d ? tc(c) : 0; + if (!d || j >= d) + return c; + var G = (d - j) / 2; + return Yl(kl(G), A) + c + Yl(Ll(G), A); + } + function cR(c, d, A) { + c = Cr(c), d = cr(d); + var j = d ? tc(c) : 0; + return d && j < d ? c + Yl(d - j, A) : c; + } + function uR(c, d, A) { + c = Cr(c), d = cr(d); + var j = d ? tc(c) : 0; + return d && j < d ? Yl(d - j, A) + c : c; + } + function fR(c, d, A) { + return A || d == null ? d = 0 : d && (d = +d), vA(Cr(c).replace(H, ""), d || 0); + } + function lR(c, d, A) { + return (A ? Jn(c, d, A) : d === r) ? d = 1 : d = cr(d), ip(Cr(c), d); + } + function hR() { + var c = arguments, d = Cr(c[0]); + return c.length < 3 ? d : d.replace(c[1], c[2]); + } + var dR = cc(function(c, d, A) { + return c + (A ? "_" : "") + d.toLowerCase(); + }); + function pR(c, d, A) { + return A && typeof A != "number" && Jn(c, d, A) && (d = A = r), A = A === r ? M : A >>> 0, A ? (c = Cr(c), c && (typeof d == "string" || d != null && !Mp(d)) && (d = bi(d), !d && ec(c)) ? Eo(Qi(c), 0, A) : c.split(d, A)) : []; + } + var gR = cc(function(c, d, A) { + return c + (A ? " " : "") + Rp(d); + }); + function mR(c, d, A) { + return c = Cr(c), A = A == null ? 0 : oa(cr(A), 0, c.length), d = bi(d), c.slice(A, A + d.length) == d; + } + function vR(c, d, A) { + var j = te.templateSettings; + A && Jn(c, d, A) && (d = r), c = Cr(c), d = ah({}, d, j, ky); + var G = ah({}, d.imports, j.imports, ky), se = An(G), de = U0(G, se), ve, xe, He = 0, We = d.interpolate || Ct, Je = "__p += '", xt = z0( + (d.escape || Ct).source + "|" + We.source + "|" + (We === Nt ? Ee : Ct).source + "|" + (d.evaluate || Ct).source + "|$", + "g" + ), Ot = "//# sourceURL=" + (Rr.call(d, "sourceURL") ? (d.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++O0 + "]") + ` +`; + c.replace(xt, function(Kt, yr, Sr, wi, Xn, xi) { + return Sr || (Sr = wi), Je += c.slice(He, xi).replace(Mt, K9), yr && (ve = !0, Je += `' + +__e(` + yr + `) + +'`), Xn && (xe = !0, Je += `'; +` + Xn + `; +__p += '`), Sr && (Je += `' + +((__t = (` + Sr + `)) == null ? '' : __t) + +'`), He = xi + Kt.length, Kt; + }), Je += `'; +`; + var Wt = Rr.call(d, "variable") && d.variable; + if (!Wt) + Je = `with (obj) { +` + Je + ` +} +`; + else if (le.test(Wt)) + throw new rr(a); + Je = (xe ? Je.replace(Gt, "") : Je).replace(Et, "$1").replace(Yt, "$1;"), Je = "function(" + (Wt || "obj") + `) { +` + (Wt ? "" : `obj || (obj = {}); +`) + "var __t, __p = ''" + (ve ? ", __e = _.escape" : "") + (xe ? `, __j = Array.prototype.join; +function print() { __p += __j.call(arguments, '') } +` : `; +`) + Je + `return __p +}`; + var fr = Iw(function() { + return Mr(se, Ot + "return " + Je).apply(r, de); + }); + if (fr.source = Je, Pp(fr)) + throw fr; + return fr; + } + function bR(c) { + return Cr(c).toLowerCase(); + } + function yR(c) { + return Cr(c).toUpperCase(); + } + function wR(c, d, A) { + if (c = Cr(c), c && (A || d === r)) + return $b(c); + if (!c || !(d = bi(d))) + return c; + var j = Qi(c), G = Qi(d), se = Bb(j, G), de = Fb(j, G) + 1; + return Eo(j, se, de).join(""); + } + function xR(c, d, A) { + if (c = Cr(c), c && (A || d === r)) + return c.slice(0, Ub(c) + 1); + if (!c || !(d = bi(d))) + return c; + var j = Qi(c), G = Fb(j, Qi(d)) + 1; + return Eo(j, 0, G).join(""); + } + function _R(c, d, A) { + if (c = Cr(c), c && (A || d === r)) + return c.replace(H, ""); + if (!c || !(d = bi(d))) + return c; + var j = Qi(c), G = Bb(j, Qi(d)); + return Eo(j, G).join(""); + } + function ER(c, d) { + var A = ne, j = K; + if (Zr(d)) { + var G = "separator" in d ? d.separator : G; + A = "length" in d ? cr(d.length) : A, j = "omission" in d ? bi(d.omission) : j; + } + c = Cr(c); + var se = c.length; + if (ec(c)) { + var de = Qi(c); + se = de.length; + } + if (A >= se) + return c; + var ve = A - tc(j); + if (ve < 1) + return j; + var xe = de ? Eo(de, 0, ve).join("") : c.slice(0, ve); + if (G === r) + return xe + j; + if (de && (ve += xe.length - ve), Mp(G)) { + if (c.slice(ve).search(G)) { + var He, We = xe; + for (G.global || (G = z0(G.source, Cr(Le.exec(G)) + "g")), G.lastIndex = 0; He = G.exec(We); ) + var Je = He.index; + xe = xe.slice(0, Je === r ? ve : Je); + } + } else if (c.indexOf(bi(G), ve) != ve) { + var xt = xe.lastIndexOf(G); + xt > -1 && (xe = xe.slice(0, xt)); + } + return xe + j; + } + function SR(c) { + return c = Cr(c), c && kt.test(c) ? c.replace(tr, Q9) : c; + } + var AR = cc(function(c, d, A) { + return c + (A ? " " : "") + d.toUpperCase(); + }), Rp = Cy("toUpperCase"); + function Mw(c, d, A) { + return c = Cr(c), d = A ? r : d, d === r ? G9(c) ? rA(c) : F9(c) : c.match(d) || []; + } + var Iw = hr(function(c, d) { + try { + return Sn(c, r, d); + } catch (A) { + return Pp(A) ? A : new rr(A); + } + }), PR = Us(function(c, d) { + return Ri(d, function(A) { + A = bs(A), Fs(c, A, Sp(c[A], c)); + }), c; + }); + function MR(c) { + var d = c == null ? 0 : c.length, A = Ut(); + return c = d ? Xr(c, function(j) { + if (typeof j[1] != "function") + throw new Ti(o); + return [A(j[0]), j[1]]; + }) : [], hr(function(j) { + for (var G = -1; ++G < d; ) { + var se = c[G]; + if (Sn(se[0], this, j)) + return Sn(se[1], this, j); + } + }); + } + function IR(c) { + return QA(Oi(c, g)); + } + function Tp(c) { + return function() { + return c; + }; + } + function CR(c, d) { + return c == null || c !== c ? d : c; + } + var RR = Ty(), TR = Ty(!0); + function ai(c) { + return c; + } + function Dp(c) { + return ay(typeof c == "function" ? c : Oi(c, g)); + } + function DR(c) { + return uy(Oi(c, g)); + } + function OR(c, d) { + return fy(c, Oi(d, g)); + } + var NR = hr(function(c, d) { + return function(A) { + return pu(A, c, d); + }; + }), LR = hr(function(c, d) { + return function(A) { + return pu(c, A, d); + }; + }); + function Op(c, d, A) { + var j = An(d), G = ql(d, j); + A == null && !(Zr(d) && (G.length || !j.length)) && (A = d, d = c, c = this, G = ql(d, An(d))); + var se = !(Zr(A) && "chain" in A) || !!A.chain, de = zs(c); + return Ri(G, function(ve) { + var xe = d[ve]; + c[ve] = xe, de && (c.prototype[ve] = function() { + var He = this.__chain__; + if (se || He) { + var We = c(this.__wrapped__), Je = We.__actions__ = ii(this.__actions__); + return Je.push({ func: xe, args: arguments, thisArg: c }), We.__chain__ = He, We; + } + return xe.apply(c, vo([this.value()], arguments)); + }); + }), c; + } + function kR() { + return Er._ === this && (Er._ = cA), this; + } + function Np() { + } + function $R(c) { + return c = cr(c), hr(function(d) { + return ly(d, c); + }); + } + var BR = lp(Xr), FR = lp(Db), jR = lp(k0); + function Cw(c) { + return bp(c) ? $0(bs(c)) : mP(c); + } + function UR(c) { + return function(d) { + return c == null ? r : aa(c, d); + }; + } + var qR = Oy(), zR = Oy(!0); + function Lp() { + return []; + } + function kp() { + return !1; + } + function HR() { + return {}; + } + function WR() { + return ""; + } + function KR() { + return !0; + } + function VR(c, d) { + if (c = cr(c), c < 1 || c > P) + return []; + var A = M, j = jn(c, M); + d = Ut(d), c -= M; + for (var G = j0(j, d); ++A < c; ) + d(A); + return G; + } + function GR(c) { + return sr(c) ? Xr(c, bs) : yi(c) ? [c] : ii(Yy(Cr(c))); + } + function YR(c) { + var d = ++oA; + return Cr(c) + d; + } + var JR = Gl(function(c, d) { + return c + d; + }, 0), XR = hp("ceil"), ZR = Gl(function(c, d) { + return c / d; + }, 1), QR = hp("floor"); + function eT(c) { + return c && c.length ? Ul(c, ai, X0) : r; + } + function tT(c, d) { + return c && c.length ? Ul(c, Ut(d, 2), X0) : r; + } + function rT(c) { + return Lb(c, ai); + } + function nT(c, d) { + return Lb(c, Ut(d, 2)); + } + function iT(c) { + return c && c.length ? Ul(c, ai, tp) : r; + } + function sT(c, d) { + return c && c.length ? Ul(c, Ut(d, 2), tp) : r; + } + var oT = Gl(function(c, d) { + return c * d; + }, 1), aT = hp("round"), cT = Gl(function(c, d) { + return c - d; + }, 0); + function uT(c) { + return c && c.length ? F0(c, ai) : 0; + } + function fT(c, d) { + return c && c.length ? F0(c, Ut(d, 2)) : 0; + } + return te.after = DI, te.ary = ow, te.assign = yC, te.assignIn = ww, te.assignInWith = ah, te.assignWith = wC, te.at = xC, te.before = aw, te.bind = Sp, te.bindAll = PR, te.bindKey = cw, te.castArray = HI, te.chain = nw, te.chunk = QP, te.compact = eM, te.concat = tM, te.cond = MR, te.conforms = IR, te.constant = Tp, te.countBy = uI, te.create = _C, te.curry = uw, te.curryRight = fw, te.debounce = lw, te.defaults = EC, te.defaultsDeep = SC, te.defer = OI, te.delay = NI, te.difference = rM, te.differenceBy = nM, te.differenceWith = iM, te.drop = sM, te.dropRight = oM, te.dropRightWhile = aM, te.dropWhile = cM, te.fill = uM, te.filter = lI, te.flatMap = pI, te.flatMapDeep = gI, te.flatMapDepth = mI, te.flatten = Qy, te.flattenDeep = fM, te.flattenDepth = lM, te.flip = LI, te.flow = RR, te.flowRight = TR, te.fromPairs = hM, te.functions = TC, te.functionsIn = DC, te.groupBy = vI, te.initial = pM, te.intersection = gM, te.intersectionBy = mM, te.intersectionWith = vM, te.invert = NC, te.invertBy = LC, te.invokeMap = yI, te.iteratee = Dp, te.keyBy = wI, te.keys = An, te.keysIn = oi, te.map = th, te.mapKeys = $C, te.mapValues = BC, te.matches = DR, te.matchesProperty = OR, te.memoize = nh, te.merge = FC, te.mergeWith = xw, te.method = NR, te.methodOf = LR, te.mixin = Op, te.negate = ih, te.nthArg = $R, te.omit = jC, te.omitBy = UC, te.once = kI, te.orderBy = xI, te.over = BR, te.overArgs = $I, te.overEvery = FR, te.overSome = jR, te.partial = Ap, te.partialRight = hw, te.partition = _I, te.pick = qC, te.pickBy = _w, te.property = Cw, te.propertyOf = UR, te.pull = xM, te.pullAll = tw, te.pullAllBy = _M, te.pullAllWith = EM, te.pullAt = SM, te.range = qR, te.rangeRight = zR, te.rearg = BI, te.reject = AI, te.remove = AM, te.rest = FI, te.reverse = _p, te.sampleSize = MI, te.set = HC, te.setWith = WC, te.shuffle = II, te.slice = PM, te.sortBy = TI, te.sortedUniq = OM, te.sortedUniqBy = NM, te.split = pR, te.spread = jI, te.tail = LM, te.take = kM, te.takeRight = $M, te.takeRightWhile = BM, te.takeWhile = FM, te.tap = eI, te.throttle = UI, te.thru = eh, te.toArray = vw, te.toPairs = Ew, te.toPairsIn = Sw, te.toPath = GR, te.toPlainObject = yw, te.transform = KC, te.unary = qI, te.union = jM, te.unionBy = UM, te.unionWith = qM, te.uniq = zM, te.uniqBy = HM, te.uniqWith = WM, te.unset = VC, te.unzip = Ep, te.unzipWith = rw, te.update = GC, te.updateWith = YC, te.values = lc, te.valuesIn = JC, te.without = KM, te.words = Mw, te.wrap = zI, te.xor = VM, te.xorBy = GM, te.xorWith = YM, te.zip = JM, te.zipObject = XM, te.zipObjectDeep = ZM, te.zipWith = QM, te.entries = Ew, te.entriesIn = Sw, te.extend = ww, te.extendWith = ah, Op(te, te), te.add = JR, te.attempt = Iw, te.camelCase = eR, te.capitalize = Aw, te.ceil = XR, te.clamp = XC, te.clone = WI, te.cloneDeep = VI, te.cloneDeepWith = GI, te.cloneWith = KI, te.conformsTo = YI, te.deburr = Pw, te.defaultTo = CR, te.divide = ZR, te.endsWith = tR, te.eq = ts, te.escape = rR, te.escapeRegExp = nR, te.every = fI, te.find = hI, te.findIndex = Xy, te.findKey = AC, te.findLast = dI, te.findLastIndex = Zy, te.findLastKey = PC, te.floor = QR, te.forEach = iw, te.forEachRight = sw, te.forIn = MC, te.forInRight = IC, te.forOwn = CC, te.forOwnRight = RC, te.get = Ip, te.gt = JI, te.gte = XI, te.has = OC, te.hasIn = Cp, te.head = ew, te.identity = ai, te.includes = bI, te.indexOf = dM, te.inRange = ZC, te.invoke = kC, te.isArguments = fa, te.isArray = sr, te.isArrayBuffer = ZI, te.isArrayLike = si, te.isArrayLikeObject = an, te.isBoolean = QI, te.isBuffer = So, te.isDate = eC, te.isElement = tC, te.isEmpty = rC, te.isEqual = nC, te.isEqualWith = iC, te.isError = Pp, te.isFinite = sC, te.isFunction = zs, te.isInteger = dw, te.isLength = sh, te.isMap = pw, te.isMatch = oC, te.isMatchWith = aC, te.isNaN = cC, te.isNative = uC, te.isNil = lC, te.isNull = fC, te.isNumber = gw, te.isObject = Zr, te.isObjectLike = en, te.isPlainObject = wu, te.isRegExp = Mp, te.isSafeInteger = hC, te.isSet = mw, te.isString = oh, te.isSymbol = yi, te.isTypedArray = fc, te.isUndefined = dC, te.isWeakMap = pC, te.isWeakSet = gC, te.join = bM, te.kebabCase = iR, te.last = Li, te.lastIndexOf = yM, te.lowerCase = sR, te.lowerFirst = oR, te.lt = mC, te.lte = vC, te.max = eT, te.maxBy = tT, te.mean = rT, te.meanBy = nT, te.min = iT, te.minBy = sT, te.stubArray = Lp, te.stubFalse = kp, te.stubObject = HR, te.stubString = WR, te.stubTrue = KR, te.multiply = oT, te.nth = wM, te.noConflict = kR, te.noop = Np, te.now = rh, te.pad = aR, te.padEnd = cR, te.padStart = uR, te.parseInt = fR, te.random = QC, te.reduce = EI, te.reduceRight = SI, te.repeat = lR, te.replace = hR, te.result = zC, te.round = aT, te.runInContext = ye, te.sample = PI, te.size = CI, te.snakeCase = dR, te.some = RI, te.sortedIndex = MM, te.sortedIndexBy = IM, te.sortedIndexOf = CM, te.sortedLastIndex = RM, te.sortedLastIndexBy = TM, te.sortedLastIndexOf = DM, te.startCase = gR, te.startsWith = mR, te.subtract = cT, te.sum = uT, te.sumBy = fT, te.template = vR, te.times = VR, te.toFinite = Hs, te.toInteger = cr, te.toLength = bw, te.toLower = bR, te.toNumber = ki, te.toSafeInteger = bC, te.toString = Cr, te.toUpper = yR, te.trim = wR, te.trimEnd = xR, te.trimStart = _R, te.truncate = ER, te.unescape = SR, te.uniqueId = YR, te.upperCase = AR, te.upperFirst = Rp, te.each = iw, te.eachRight = sw, te.first = ew, Op(te, (function() { + var c = {}; + return ms(te, function(d, A) { + Rr.call(te.prototype, A) || (c[A] = d); + }), c; + })(), { chain: !1 }), te.VERSION = n, Ri(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(c) { + te[c].placeholder = te; + }), Ri(["drop", "take"], function(c, d) { + _r.prototype[c] = function(A) { + A = A === r ? 1 : xn(cr(A), 0); + var j = this.__filtered__ && !d ? new _r(this) : this.clone(); + return j.__filtered__ ? j.__takeCount__ = jn(A, j.__takeCount__) : j.__views__.push({ + size: jn(A, M), + type: c + (j.__dir__ < 0 ? "Right" : "") + }), j; + }, _r.prototype[c + "Right"] = function(A) { + return this.reverse()[c](A).reverse(); + }; + }), Ri(["filter", "map", "takeWhile"], function(c, d) { + var A = d + 1, j = A == l || A == m; + _r.prototype[c] = function(G) { + var se = this.clone(); + return se.__iteratees__.push({ + iteratee: Ut(G, 3), + type: A + }), se.__filtered__ = se.__filtered__ || j, se; + }; + }), Ri(["head", "last"], function(c, d) { + var A = "take" + (d ? "Right" : ""); + _r.prototype[c] = function() { + return this[A](1).value()[0]; + }; + }), Ri(["initial", "tail"], function(c, d) { + var A = "drop" + (d ? "" : "Right"); + _r.prototype[c] = function() { + return this.__filtered__ ? new _r(this) : this[A](1); + }; + }), _r.prototype.compact = function() { + return this.filter(ai); + }, _r.prototype.find = function(c) { + return this.filter(c).head(); + }, _r.prototype.findLast = function(c) { + return this.reverse().find(c); + }, _r.prototype.invokeMap = hr(function(c, d) { + return typeof c == "function" ? new _r(this) : this.map(function(A) { + return pu(A, c, d); + }); + }), _r.prototype.reject = function(c) { + return this.filter(ih(Ut(c))); + }, _r.prototype.slice = function(c, d) { + c = cr(c); + var A = this; + return A.__filtered__ && (c > 0 || d < 0) ? new _r(A) : (c < 0 ? A = A.takeRight(-c) : c && (A = A.drop(c)), d !== r && (d = cr(d), A = d < 0 ? A.dropRight(-d) : A.take(d - c)), A); + }, _r.prototype.takeRightWhile = function(c) { + return this.reverse().takeWhile(c).reverse(); + }, _r.prototype.toArray = function() { + return this.take(M); + }, ms(_r.prototype, function(c, d) { + var A = /^(?:filter|find|map|reject)|While$/.test(d), j = /^(?:head|last)$/.test(d), G = te[j ? "take" + (d == "last" ? "Right" : "") : d], se = j || /^find/.test(d); + G && (te.prototype[d] = function() { + var de = this.__wrapped__, ve = j ? [1] : arguments, xe = de instanceof _r, He = ve[0], We = xe || sr(de), Je = function(yr) { + var Sr = G.apply(te, vo([yr], ve)); + return j && xt ? Sr[0] : Sr; + }; + We && A && typeof He == "function" && He.length != 1 && (xe = We = !1); + var xt = this.__chain__, Ot = !!this.__actions__.length, Wt = se && !xt, fr = xe && !Ot; + if (!se && We) { + de = fr ? de : new _r(this); + var Kt = c.apply(de, ve); + return Kt.__actions__.push({ func: eh, args: [Je], thisArg: r }), new Di(Kt, xt); + } + return Wt && fr ? c.apply(this, ve) : (Kt = this.thru(Je), Wt ? j ? Kt.value()[0] : Kt.value() : Kt); + }); + }), Ri(["pop", "push", "shift", "sort", "splice", "unshift"], function(c) { + var d = Pl[c], A = /^(?:push|sort|unshift)$/.test(c) ? "tap" : "thru", j = /^(?:pop|shift)$/.test(c); + te.prototype[c] = function() { + var G = arguments; + if (j && !this.__chain__) { + var se = this.value(); + return d.apply(sr(se) ? se : [], G); + } + return this[A](function(de) { + return d.apply(sr(de) ? de : [], G); + }); + }; + }), ms(_r.prototype, function(c, d) { + var A = te[d]; + if (A) { + var j = A.name + ""; + Rr.call(sc, j) || (sc[j] = []), sc[j].push({ name: d, func: A }); + } + }), sc[Vl(r, k).name] = [{ + name: "wrapper", + func: r + }], _r.prototype.clone = SA, _r.prototype.reverse = AA, _r.prototype.value = PA, te.prototype.at = tI, te.prototype.chain = rI, te.prototype.commit = nI, te.prototype.next = iI, te.prototype.plant = oI, te.prototype.reverse = aI, te.prototype.toJSON = te.prototype.valueOf = te.prototype.value = cI, te.prototype.first = te.prototype.head, au && (te.prototype[au] = sI), te; + }), rc = nA(); + on ? ((on.exports = rc)._ = rc, Ur._ = rc) : Er._ = rc; + }).call(qH); + })(Ju, Ju.exports)), Ju.exports; +} +var HH = zH(), Xu = { exports: {} }, WH = Xu.exports, X3; +function KH() { + return X3 || (X3 = 1, (function(t, e) { + var r = typeof self < "u" ? self : WH, n = (function() { + function s() { + this.fetch = !1, this.DOMException = r.DOMException; + } + return s.prototype = r, new s(); + })(); + (function(s) { + (function(o) { + var a = { + searchParams: "URLSearchParams" in s, + iterable: "Symbol" in s && "iterator" in Symbol, + blob: "FileReader" in s && "Blob" in s && (function() { + try { + return new Blob(), !0; + } catch { + return !1; + } + })(), + formData: "FormData" in s, + arrayBuffer: "ArrayBuffer" in s + }; + function f(l) { + return l && DataView.prototype.isPrototypeOf(l); + } + if (a.arrayBuffer) + var u = [ + "[object Int8Array]", + "[object Uint8Array]", + "[object Uint8ClampedArray]", + "[object Int16Array]", + "[object Uint16Array]", + "[object Int32Array]", + "[object Uint32Array]", + "[object Float32Array]", + "[object Float64Array]" + ], h = ArrayBuffer.isView || function(l) { + return l && u.indexOf(Object.prototype.toString.call(l)) > -1; + }; + function g(l) { + if (typeof l != "string" && (l = String(l)), /[^a-z0-9\-#$%&'*+.^_`|~]/i.test(l)) + throw new TypeError("Invalid character in header field name"); + return l.toLowerCase(); + } + function v(l) { + return typeof l != "string" && (l = String(l)), l; + } + function x(l) { + var p = { + next: function() { + var m = l.shift(); + return { done: m === void 0, value: m }; + } + }; + return a.iterable && (p[Symbol.iterator] = function() { + return p; + }), p; + } + function S(l) { + this.map = {}, l instanceof S ? l.forEach(function(p, m) { + this.append(m, p); + }, this) : Array.isArray(l) ? l.forEach(function(p) { + this.append(p[0], p[1]); + }, this) : l && Object.getOwnPropertyNames(l).forEach(function(p) { + this.append(p, l[p]); + }, this); + } + S.prototype.append = function(l, p) { + l = g(l), p = v(p); + var m = this.map[l]; + this.map[l] = m ? m + ", " + p : p; + }, S.prototype.delete = function(l) { + delete this.map[g(l)]; + }, S.prototype.get = function(l) { + return l = g(l), this.has(l) ? this.map[l] : null; + }, S.prototype.has = function(l) { + return this.map.hasOwnProperty(g(l)); + }, S.prototype.set = function(l, p) { + this.map[g(l)] = v(p); + }, S.prototype.forEach = function(l, p) { + for (var m in this.map) + this.map.hasOwnProperty(m) && l.call(p, this.map[m], m, this); + }, S.prototype.keys = function() { + var l = []; + return this.forEach(function(p, m) { + l.push(m); + }), x(l); + }, S.prototype.values = function() { + var l = []; + return this.forEach(function(p) { + l.push(p); + }), x(l); + }, S.prototype.entries = function() { + var l = []; + return this.forEach(function(p, m) { + l.push([m, p]); + }), x(l); + }, a.iterable && (S.prototype[Symbol.iterator] = S.prototype.entries); + function R(l) { + if (l.bodyUsed) + return Promise.reject(new TypeError("Already read")); + l.bodyUsed = !0; + } + function D(l) { + return new Promise(function(p, m) { + l.onload = function() { + p(l.result); + }, l.onerror = function() { + m(l.error); + }; + }); + } + function k(l) { + var p = new FileReader(), m = D(p); + return p.readAsArrayBuffer(l), m; + } + function N(l) { + var p = new FileReader(), m = D(p); + return p.readAsText(l), m; + } + function z(l) { + for (var p = new Uint8Array(l), m = new Array(p.length), w = 0; w < p.length; w++) + m[w] = String.fromCharCode(p[w]); + return m.join(""); + } + function B(l) { + if (l.slice) + return l.slice(0); + var p = new Uint8Array(l.byteLength); + return p.set(new Uint8Array(l)), p.buffer; + } + function $() { + return this.bodyUsed = !1, this._initBody = function(l) { + this._bodyInit = l, l ? typeof l == "string" ? this._bodyText = l : a.blob && Blob.prototype.isPrototypeOf(l) ? this._bodyBlob = l : a.formData && FormData.prototype.isPrototypeOf(l) ? this._bodyFormData = l : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) ? this._bodyText = l.toString() : a.arrayBuffer && a.blob && f(l) ? (this._bodyArrayBuffer = B(l.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : a.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(l) || h(l)) ? this._bodyArrayBuffer = B(l) : this._bodyText = l = Object.prototype.toString.call(l) : this._bodyText = "", this.headers.get("content-type") || (typeof l == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : a.searchParams && URLSearchParams.prototype.isPrototypeOf(l) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8")); + }, a.blob && (this.blob = function() { + var l = R(this); + if (l) + return l; + if (this._bodyBlob) + return Promise.resolve(this._bodyBlob); + if (this._bodyArrayBuffer) + return Promise.resolve(new Blob([this._bodyArrayBuffer])); + if (this._bodyFormData) + throw new Error("could not read FormData body as blob"); + return Promise.resolve(new Blob([this._bodyText])); + }, this.arrayBuffer = function() { + return this._bodyArrayBuffer ? R(this) || Promise.resolve(this._bodyArrayBuffer) : this.blob().then(k); + }), this.text = function() { + var l = R(this); + if (l) + return l; + if (this._bodyBlob) + return N(this._bodyBlob); + if (this._bodyArrayBuffer) + return Promise.resolve(z(this._bodyArrayBuffer)); + if (this._bodyFormData) + throw new Error("could not read FormData body as text"); + return Promise.resolve(this._bodyText); + }, a.formData && (this.formData = function() { + return this.text().then(J); + }), this.json = function() { + return this.text().then(JSON.parse); + }, this; + } + var U = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"]; + function C(l) { + var p = l.toUpperCase(); + return U.indexOf(p) > -1 ? p : l; + } + function W(l, p) { + p = p || {}; + var m = p.body; + if (l instanceof W) { + if (l.bodyUsed) + throw new TypeError("Already read"); + this.url = l.url, this.credentials = l.credentials, p.headers || (this.headers = new S(l.headers)), this.method = l.method, this.mode = l.mode, this.signal = l.signal, !m && l._bodyInit != null && (m = l._bodyInit, l.bodyUsed = !0); + } else + this.url = String(l); + if (this.credentials = p.credentials || this.credentials || "same-origin", (p.headers || !this.headers) && (this.headers = new S(p.headers)), this.method = C(p.method || this.method || "GET"), this.mode = p.mode || this.mode || null, this.signal = p.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && m) + throw new TypeError("Body not allowed for GET or HEAD requests"); + this._initBody(m); + } + W.prototype.clone = function() { + return new W(this, { body: this._bodyInit }); + }; + function J(l) { + var p = new FormData(); + return l.trim().split("&").forEach(function(m) { + if (m) { + var w = m.split("="), P = w.shift().replace(/\+/g, " "), _ = w.join("=").replace(/\+/g, " "); + p.append(decodeURIComponent(P), decodeURIComponent(_)); + } + }), p; + } + function ne(l) { + var p = new S(), m = l.replace(/\r?\n[\t ]+/g, " "); + return m.split(/\r?\n/).forEach(function(w) { + var P = w.split(":"), _ = P.shift().trim(); + if (_) { + var y = P.join(":").trim(); + p.append(_, y); + } + }), p; + } + $.call(W.prototype); + function K(l, p) { + p || (p = {}), this.type = "default", this.status = p.status === void 0 ? 200 : p.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = "statusText" in p ? p.statusText : "OK", this.headers = new S(p.headers), this.url = p.url || "", this._initBody(l); + } + $.call(K.prototype), K.prototype.clone = function() { + return new K(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new S(this.headers), + url: this.url + }); + }, K.error = function() { + var l = new K(null, { status: 0, statusText: "" }); + return l.type = "error", l; + }; + var E = [301, 302, 303, 307, 308]; + K.redirect = function(l, p) { + if (E.indexOf(p) === -1) + throw new RangeError("Invalid status code"); + return new K(null, { status: p, headers: { location: l } }); + }, o.DOMException = s.DOMException; + try { + new o.DOMException(); + } catch { + o.DOMException = function(p, m) { + this.message = p, this.name = m; + var w = Error(p); + this.stack = w.stack; + }, o.DOMException.prototype = Object.create(Error.prototype), o.DOMException.prototype.constructor = o.DOMException; + } + function b(l, p) { + return new Promise(function(m, w) { + var P = new W(l, p); + if (P.signal && P.signal.aborted) + return w(new o.DOMException("Aborted", "AbortError")); + var _ = new XMLHttpRequest(); + function y() { + _.abort(); + } + _.onload = function() { + var M = { + status: _.status, + statusText: _.statusText, + headers: ne(_.getAllResponseHeaders() || "") + }; + M.url = "responseURL" in _ ? _.responseURL : M.headers.get("X-Request-URL"); + var I = "response" in _ ? _.response : _.responseText; + m(new K(I, M)); + }, _.onerror = function() { + w(new TypeError("Network request failed")); + }, _.ontimeout = function() { + w(new TypeError("Network request failed")); + }, _.onabort = function() { + w(new o.DOMException("Aborted", "AbortError")); + }, _.open(P.method, P.url, !0), P.credentials === "include" ? _.withCredentials = !0 : P.credentials === "omit" && (_.withCredentials = !1), "responseType" in _ && a.blob && (_.responseType = "blob"), P.headers.forEach(function(M, I) { + _.setRequestHeader(I, M); + }), P.signal && (P.signal.addEventListener("abort", y), _.onreadystatechange = function() { + _.readyState === 4 && P.signal.removeEventListener("abort", y); + }), _.send(typeof P._bodyInit > "u" ? null : P._bodyInit); + }); + } + return b.polyfill = !0, s.fetch || (s.fetch = b, s.Headers = S, s.Request = W, s.Response = K), o.Headers = S, o.Request = W, o.Response = K, o.fetch = b, Object.defineProperty(o, "__esModule", { value: !0 }), o; + })({}); + })(n), n.fetch.ponyfill = !0, delete n.fetch.polyfill; + var i = n; + e = i.fetch, e.default = i.fetch, e.fetch = i.fetch, e.Headers = i.Headers, e.Request = i.Request, e.Response = i.Response, t.exports = e; + })(Xu, Xu.exports)), Xu.exports; +} +var VH = KH(); +const Z3 = /* @__PURE__ */ Hi(VH); +var GH = Object.defineProperty, YH = Object.defineProperties, JH = Object.getOwnPropertyDescriptors, Q3 = Object.getOwnPropertySymbols, XH = Object.prototype.hasOwnProperty, ZH = Object.prototype.propertyIsEnumerable, e_ = (t, e, r) => e in t ? GH(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, t_ = (t, e) => { + for (var r in e || (e = {})) XH.call(e, r) && e_(t, r, e[r]); + if (Q3) for (var r of Q3(e)) ZH.call(e, r) && e_(t, r, e[r]); + return t; +}, r_ = (t, e) => YH(t, JH(e)); +const QH = { Accept: "application/json", "Content-Type": "application/json" }, eW = "POST", n_ = { headers: QH, method: eW }, i_ = 10; +let hs = class { + constructor(e, r = !1) { + if (this.url = e, this.disableProviderPing = r, this.events = new Wi.EventEmitter(), this.isAvailable = !1, this.registering = !1, !x3(e)) throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`); + this.url = e, this.disableProviderPing = r; + } + get connected() { + return this.isAvailable; + } + 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() { + if (!this.isAvailable) throw new Error("Connection already closed"); + this.onClose(); + } + async send(e) { + this.isAvailable || await this.register(); + try { + const r = ho(e), n = await (await Z3(this.url, r_(t_({}, n_), { body: r }))).json(); + this.onPayload({ data: n }); + } catch (r) { + this.onError(e.id, r); + } + } + async register(e = this.url) { + if (!x3(e)) throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`); + if (this.registering) { + const r = this.events.getMaxListeners(); + return (this.events.listenerCount("register_error") >= r || this.events.listenerCount("open") >= r) && this.events.setMaxListeners(r + 1), new Promise((n, i) => { + this.events.once("register_error", (s) => { + this.resetMaxListeners(), i(s); + }), this.events.once("open", () => { + if (this.resetMaxListeners(), typeof this.isAvailable > "u") return i(new Error("HTTP connection is missing or invalid")); + n(); + }); + }); + } + this.url = e, this.registering = !0; + try { + if (!this.disableProviderPing) { + const r = ho({ id: 1, jsonrpc: "2.0", method: "test", params: [] }); + await Z3(e, r_(t_({}, n_), { body: r })); + } + this.onOpen(); + } catch (r) { + const n = this.parseError(r); + throw this.events.emit("register_error", n), this.onClose(), n; + } + } + onOpen() { + this.isAvailable = !0, this.registering = !1, this.events.emit("open"); + } + onClose() { + this.isAvailable = !1, this.registering = !1, this.events.emit("close"); + } + onPayload(e) { + if (typeof e.data > "u") return; + const r = typeof e.data == "string" ? Na(e.data) : e.data; + this.events.emit("payload", r); + } + onError(e, r) { + const n = this.parseError(r), i = n.message || n.toString(), s = n0(e, i); + this.events.emit("payload", s); + } + parseError(e, r = this.url) { + return q8(e, r, "HTTP"); + } + resetMaxListeners() { + this.events.getMaxListeners() > i_ && this.events.setMaxListeners(i_); + } +}; +const s_ = "error", tW = "wss://relay.walletconnect.org", rW = "wc", nW = "universal_provider", o_ = `${rW}@2:${nW}:`, lE = "https://rpc.walletconnect.org/v1/", wc = "generic", iW = `${lE}bundler`, Ji = { DEFAULT_CHAIN_CHANGED: "default_chain_changed" }; +var sW = Object.defineProperty, oW = Object.defineProperties, aW = Object.getOwnPropertyDescriptors, a_ = Object.getOwnPropertySymbols, cW = Object.prototype.hasOwnProperty, uW = Object.prototype.propertyIsEnumerable, c_ = (t, e, r) => e in t ? sW(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Sh = (t, e) => { + for (var r in e || (e = {})) cW.call(e, r) && c_(t, r, e[r]); + if (a_) for (var r of a_(e)) uW.call(e, r) && c_(t, r, e[r]); + return t; +}, fW = (t, e) => oW(t, aW(e)); +function Ai(t, e, r) { + var n; + const i = Nc(t); + return ((n = e.rpcMap) == null ? void 0 : n[i.reference]) || `${lE}?chainId=${i.namespace}:${i.reference}&projectId=${r}`; +} +function Ga(t) { + return t.includes(":") ? t.split(":")[1] : t; +} +function hE(t) { + return t.map((e) => `${e.split(":")[0]}:${e.split(":")[1]}`); +} +function lW(t, e) { + const r = Object.keys(e.namespaces).filter((i) => i.includes(t)); + if (!r.length) return []; + const n = []; + return r.forEach((i) => { + const s = e.namespaces[i].accounts; + n.push(...s); + }), n; +} +function em(t = {}, e = {}) { + const r = u_(t), n = u_(e); + return HH.merge(r, n); +} +function u_(t) { + var e, r, n, i; + const s = {}; + if (!kf(t)) return s; + for (const [o, a] of Object.entries(t)) { + const f = A1(o) ? [o] : a.chains, u = a.methods || [], h = a.events || [], g = a.rpcMap || {}, v = Gu(o); + s[v] = fW(Sh(Sh({}, s[v]), a), { chains: zh(f, (e = s[v]) == null ? void 0 : e.chains), methods: zh(u, (r = s[v]) == null ? void 0 : r.methods), events: zh(h, (n = s[v]) == null ? void 0 : n.events), rpcMap: Sh(Sh({}, g), (i = s[v]) == null ? void 0 : i.rpcMap) }); + } + return s; +} +function hW(t) { + return t.includes(":") ? t.split(":")[2] : t; +} +function f_(t) { + const e = {}; + for (const [r, n] of Object.entries(t)) { + const i = n.methods || [], s = n.events || [], o = n.accounts || [], a = A1(r) ? [r] : n.chains ? n.chains : hE(n.accounts); + e[r] = { chains: a, methods: i, events: s, accounts: o }; + } + return e; +} +function tm(t) { + return typeof t == "number" ? t : t.includes("0x") ? parseInt(t, 16) : (t = t.includes(":") ? t.split(":")[1] : t, isNaN(Number(t)) ? t : Number(t)); +} +const dE = {}, Pr = (t) => dE[t], rm = (t, e) => { + dE[t] = e; +}; +class dW { + constructor(e) { + this.name = "polkadot", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + requestAccounts() { + return this.getAccounts(); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); + } + setDefaultChain(e, r) { + this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); + } + getAccounts() { + const e = this.namespace.accounts; + return e ? e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]) || [] : []; + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + var n; + const i = Ga(r); + e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); + }), e; + } + getHttpProvider() { + const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || Ai(e, this.namespace, this.client.core.projectId); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + return new Yi(new hs(n, Pr("disableProviderPing"))); + } +} +var pW = Object.defineProperty, gW = Object.defineProperties, mW = Object.getOwnPropertyDescriptors, l_ = Object.getOwnPropertySymbols, vW = Object.prototype.hasOwnProperty, bW = Object.prototype.propertyIsEnumerable, h_ = (t, e, r) => e in t ? pW(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, d_ = (t, e) => { + for (var r in e || (e = {})) vW.call(e, r) && h_(t, r, e[r]); + if (l_) for (var r of l_(e)) bW.call(e, r) && h_(t, r, e[r]); + return t; +}, p_ = (t, e) => gW(t, mW(e)); +class yW { + constructor(e) { + this.name = "eip155", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.httpProviders = this.createHttpProviders(), this.chainId = parseInt(this.getDefaultChain()); + } + async request(e) { + switch (e.request.method) { + case "eth_requestAccounts": + return this.getAccounts(); + case "eth_accounts": + return this.getAccounts(); + case "wallet_switchEthereumChain": + return await this.handleSwitchChain(e); + case "eth_chainId": + return parseInt(this.getDefaultChain()); + case "wallet_getCapabilities": + return await this.getCapabilities(e); + case "wallet_getCallsStatus": + return await this.getCallStatus(e); + } + return this.namespace.methods.includes(e.request.method) ? await this.client.request(e) : this.getHttpProvider().request(e.request); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + setDefaultChain(e, r) { + this.httpProviders[e] || this.setHttpProvider(parseInt(e), r), this.chainId = parseInt(e), this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); + } + requestAccounts() { + return this.getAccounts(); + } + getDefaultChain() { + if (this.chainId) return this.chainId.toString(); + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + createHttpProvider(e, r) { + const n = r || Ai(`${this.name}:${e}`, this.namespace, this.client.core.projectId); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + return new Yi(new hs(n, Pr("disableProviderPing"))); + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + var n; + const i = parseInt(Ga(r)); + e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); + }), e; + } + getAccounts() { + const e = this.namespace.accounts; + return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; + } + getHttpProvider() { + const e = this.chainId, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + async handleSwitchChain(e) { + var r, n; + let i = e.request.params ? (r = e.request.params[0]) == null ? void 0 : r.chainId : "0x0"; + i = i.startsWith("0x") ? i : `0x${i}`; + const s = parseInt(i, 16); + if (this.isChainApproved(s)) this.setDefaultChain(`${s}`); + else if (this.namespace.methods.includes("wallet_switchEthereumChain")) await this.client.request({ topic: e.topic, request: { method: e.request.method, params: [{ chainId: i }] }, chainId: (n = this.namespace.chains) == null ? void 0 : n[0] }), this.setDefaultChain(`${s}`); + else throw new Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`); + return null; + } + isChainApproved(e) { + return this.namespace.chains.includes(`${this.name}:${e}`); + } + async getCapabilities(e) { + var r, n, i; + const s = (n = (r = e.request) == null ? void 0 : r.params) == null ? void 0 : n[0]; + if (!s) throw new Error("Missing address parameter in `wallet_getCapabilities` request"); + const o = this.client.session.get(e.topic), a = ((i = o?.sessionProperties) == null ? void 0 : i.capabilities) || {}; + if (a != null && a[s]) return a?.[s]; + const f = await this.client.request(e); + try { + await this.client.session.update(e.topic, { sessionProperties: p_(d_({}, o.sessionProperties || {}), { capabilities: p_(d_({}, a || {}), { [s]: f }) }) }); + } catch (u) { + console.warn("Failed to update session with capabilities", u); + } + return f; + } + async getCallStatus(e) { + var r, n; + const i = this.client.session.get(e.topic), s = (r = i.sessionProperties) == null ? void 0 : r.bundler_name; + if (s) { + const a = this.getBundlerUrl(e.chainId, s); + try { + return await this.getUserOperationReceipt(a, e); + } catch (f) { + console.warn("Failed to fetch call status from bundler", f, a); + } + } + const o = (n = i.sessionProperties) == null ? void 0 : n.bundler_url; + if (o) try { + return await this.getUserOperationReceipt(o, e); + } catch (a) { + console.warn("Failed to fetch call status from custom bundler", a, o); + } + if (this.namespace.methods.includes(e.request.method)) return await this.client.request(e); + throw new Error("Fetching call status not approved by the wallet."); + } + async getUserOperationReceipt(e, r) { + var n; + const i = new URL(e), s = await fetch(i, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify($o("eth_getUserOperationReceipt", [(n = r.request.params) == null ? void 0 : n[0]])) }); + if (!s.ok) throw new Error(`Failed to fetch user operation receipt - ${s.status}`); + return await s.json(); + } + getBundlerUrl(e, r) { + return `${iW}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${r}`; + } +} +class wW { + constructor(e) { + this.name = "solana", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + requestAccounts() { + return this.getAccounts(); + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); + } + setDefaultChain(e, r) { + this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + getAccounts() { + const e = this.namespace.accounts; + return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + var n; + const i = Ga(r); + e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); + }), e; + } + getHttpProvider() { + const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || Ai(e, this.namespace, this.client.core.projectId); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + return new Yi(new hs(n, Pr("disableProviderPing"))); + } +} +let xW = class { + constructor(e) { + this.name = "cosmos", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + requestAccounts() { + return this.getAccounts(); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); + } + setDefaultChain(e, r) { + this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); + } + getAccounts() { + const e = this.namespace.accounts; + return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + var n; + const i = Ga(r); + e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); + }), e; + } + getHttpProvider() { + const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || Ai(e, this.namespace, this.client.core.projectId); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + return new Yi(new hs(n, Pr("disableProviderPing"))); + } +}, _W = class { + constructor(e) { + this.name = "algorand", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + requestAccounts() { + return this.getAccounts(); + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); + } + setDefaultChain(e, r) { + if (!this.httpProviders[e]) { + const n = r || Ai(`${this.name}:${e}`, this.namespace, this.client.core.projectId); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + this.setHttpProvider(e, n); + } + this.chainId = e, this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + getAccounts() { + const e = this.namespace.accounts; + return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + var n; + e[r] = this.createHttpProvider(r, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); + }), e; + } + getHttpProvider() { + const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || Ai(e, this.namespace, this.client.core.projectId); + return typeof n > "u" ? void 0 : new Yi(new hs(n, Pr("disableProviderPing"))); + } +}, EW = class { + constructor(e) { + this.name = "cip34", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + requestAccounts() { + return this.getAccounts(); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); + } + setDefaultChain(e, r) { + this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); + } + getAccounts() { + const e = this.namespace.accounts; + return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + const n = this.getCardanoRPCUrl(r), i = Ga(r); + e[i] = this.createHttpProvider(i, n); + }), e; + } + getHttpProvider() { + const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + getCardanoRPCUrl(e) { + const r = this.namespace.rpcMap; + if (r) return r[e]; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || this.getCardanoRPCUrl(e); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + return new Yi(new hs(n, Pr("disableProviderPing"))); + } +}, SW = class { + constructor(e) { + this.name = "elrond", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + requestAccounts() { + return this.getAccounts(); + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); + } + setDefaultChain(e, r) { + this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + getAccounts() { + const e = this.namespace.accounts; + return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + var n; + const i = Ga(r); + e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); + }), e; + } + getHttpProvider() { + const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || Ai(e, this.namespace, this.client.core.projectId); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + return new Yi(new hs(n, Pr("disableProviderPing"))); + } +}; +class AW { + constructor(e) { + this.name = "multiversx", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + requestAccounts() { + return this.getAccounts(); + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); + } + setDefaultChain(e, r) { + this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + getAccounts() { + const e = this.namespace.accounts; + return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + var n; + const i = Ga(r); + e[i] = this.createHttpProvider(i, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); + }), e; + } + getHttpProvider() { + const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || Ai(e, this.namespace, this.client.core.projectId); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + return new Yi(new hs(n, Pr("disableProviderPing"))); + } +} +let PW = class { + constructor(e) { + this.name = "near", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + requestAccounts() { + return this.getAccounts(); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); + } + setDefaultChain(e, r) { + if (this.chainId = e, !this.httpProviders[e]) { + const n = r || Ai(`${this.name}:${e}`, this.namespace); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + this.setHttpProvider(e, n); + } + this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); + } + getAccounts() { + const e = this.namespace.accounts; + return e ? e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]) || [] : []; + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + var n; + e[r] = this.createHttpProvider(r, (n = this.namespace.rpcMap) == null ? void 0 : n[r]); + }), e; + } + getHttpProvider() { + const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || Ai(e, this.namespace); + return typeof n > "u" ? void 0 : new Yi(new hs(n, Pr("disableProviderPing"))); + } +}; +class MW { + constructor(e) { + this.name = "tezos", this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace = Object.assign(this.namespace, e); + } + requestAccounts() { + return this.getAccounts(); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider().request(e.request); + } + setDefaultChain(e, r) { + if (this.chainId = e, !this.httpProviders[e]) { + const n = r || Ai(`${this.name}:${e}`, this.namespace); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + this.setHttpProvider(e, n); + } + this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${this.chainId}`); + } + getAccounts() { + const e = this.namespace.accounts; + return e ? e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]) || [] : []; + } + createHttpProviders() { + const e = {}; + return this.namespace.chains.forEach((r) => { + e[r] = this.createHttpProvider(r); + }), e; + } + getHttpProvider() { + const e = `${this.name}:${this.chainId}`, r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || Ai(e, this.namespace); + return typeof n > "u" ? void 0 : new Yi(new hs(n)); + } +} +class IW { + constructor(e) { + this.name = wc, this.namespace = e.namespace, this.events = Pr("events"), this.client = Pr("client"), this.chainId = this.getDefaultChain(), this.httpProviders = this.createHttpProviders(); + } + updateNamespace(e) { + this.namespace.chains = [...new Set((this.namespace.chains || []).concat(e.chains || []))], this.namespace.accounts = [...new Set((this.namespace.accounts || []).concat(e.accounts || []))], this.namespace.methods = [...new Set((this.namespace.methods || []).concat(e.methods || []))], this.namespace.events = [...new Set((this.namespace.events || []).concat(e.events || []))], this.httpProviders = this.createHttpProviders(); + } + requestAccounts() { + return this.getAccounts(); + } + request(e) { + return this.namespace.methods.includes(e.request.method) ? this.client.request(e) : this.getHttpProvider(e.chainId).request(e.request); + } + setDefaultChain(e, r) { + this.httpProviders[e] || this.setHttpProvider(e, r), this.chainId = e, this.events.emit(Ji.DEFAULT_CHAIN_CHANGED, `${this.name}:${e}`); + } + getDefaultChain() { + if (this.chainId) return this.chainId; + if (this.namespace.defaultChain) return this.namespace.defaultChain; + const e = this.namespace.chains[0]; + if (!e) throw new Error("ChainId not found"); + return e.split(":")[1]; + } + getAccounts() { + const e = this.namespace.accounts; + return e ? [...new Set(e.filter((r) => r.split(":")[1] === this.chainId.toString()).map((r) => r.split(":")[2]))] : []; + } + createHttpProviders() { + var e, r; + const n = {}; + return (r = (e = this.namespace) == null ? void 0 : e.accounts) == null || r.forEach((i) => { + const s = Nc(i); + n[`${s.namespace}:${s.reference}`] = this.createHttpProvider(i); + }), n; + } + getHttpProvider(e) { + const r = this.httpProviders[e]; + if (typeof r > "u") throw new Error(`JSON-RPC provider for ${e} not found`); + return r; + } + setHttpProvider(e, r) { + const n = this.createHttpProvider(e, r); + n && (this.httpProviders[e] = n); + } + createHttpProvider(e, r) { + const n = r || Ai(e, this.namespace, this.client.core.projectId); + if (!n) throw new Error(`No RPC url provided for chainId: ${e}`); + return new Yi(new hs(n, Pr("disableProviderPing"))); + } +} +var CW = Object.defineProperty, RW = Object.defineProperties, TW = Object.getOwnPropertyDescriptors, g_ = Object.getOwnPropertySymbols, DW = Object.prototype.hasOwnProperty, OW = Object.prototype.propertyIsEnumerable, m_ = (t, e, r) => e in t ? CW(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Ah = (t, e) => { + for (var r in e || (e = {})) DW.call(e, r) && m_(t, r, e[r]); + if (g_) for (var r of g_(e)) OW.call(e, r) && m_(t, r, e[r]); + return t; +}, nm = (t, e) => RW(t, TW(e)); +let fv = class pE { + constructor(e) { + this.events = new l1(), this.rpcProviders = {}, this.shouldAbortPairingAttempt = !1, this.maxPairingAttempts = 10, this.disableProviderPing = !1, this.providerOpts = e, this.logger = typeof e?.logger < "u" && typeof e?.logger != "string" ? e.logger : Xf(Vd({ level: e?.logger || s_ })), this.disableProviderPing = e?.disableProviderPing || !1; + } + static async init(e) { + const r = new pE(e); + return await r.initialize(), r; + } + async request(e, r, n) { + const [i, s] = this.validateChain(r); + if (!this.session) throw new Error("Please call connect() before request()"); + return await this.getProvider(i).request({ request: Ah({}, e), chainId: `${i}:${s}`, topic: this.session.topic, expiry: n }); + } + sendAsync(e, r, n, i) { + const s = (/* @__PURE__ */ new Date()).getTime(); + this.request(e, n, i).then((o) => r(null, r0(s, o))).catch((o) => r(o, void 0)); + } + async enable() { + if (!this.client) throw new Error("Sign Client not initialized"); + return this.session || await this.connect({ namespaces: this.namespaces, optionalNamespaces: this.optionalNamespaces, sessionProperties: this.sessionProperties }), await this.requestAccounts(); + } + async disconnect() { + var e; + if (!this.session) throw new Error("Please call connect() before enable()"); + await this.client.disconnect({ topic: (e = this.session) == null ? void 0 : e.topic, reason: Nr("USER_DISCONNECTED") }), await this.cleanup(); + } + async connect(e) { + if (!this.client) throw new Error("Sign Client not initialized"); + if (this.setNamespaces(e), await this.cleanupPendingPairings(), !e.skipPairing) return await this.pair(e.pairingTopic); + } + async authenticate(e, r) { + if (!this.client) throw new Error("Sign Client not initialized"); + this.setNamespaces(e), await this.cleanupPendingPairings(); + const { uri: n, response: i } = await this.client.authenticate(e, r); + n && (this.uri = n, this.events.emit("display_uri", n)); + const s = await i(); + if (this.session = s.session, this.session) { + const o = f_(this.session.namespaces); + this.namespaces = em(this.namespaces, o), this.persist("namespaces", this.namespaces), this.onConnect(); + } + return s; + } + on(e, r) { + this.events.on(e, r); + } + once(e, r) { + this.events.once(e, r); + } + removeListener(e, r) { + this.events.removeListener(e, r); + } + off(e, r) { + this.events.off(e, r); + } + get isWalletConnect() { + return !0; + } + async pair(e) { + this.shouldAbortPairingAttempt = !1; + let r = 0; + do { + if (this.shouldAbortPairingAttempt) throw new Error("Pairing aborted"); + if (r >= this.maxPairingAttempts) throw new Error("Max auto pairing attempts reached"); + const { uri: n, approval: i } = await this.client.connect({ pairingTopic: e, requiredNamespaces: this.namespaces, optionalNamespaces: this.optionalNamespaces, sessionProperties: this.sessionProperties }); + n && (this.uri = n, this.events.emit("display_uri", n)), await i().then((s) => { + this.session = s; + const o = f_(s.namespaces); + this.namespaces = em(this.namespaces, o), this.persist("namespaces", this.namespaces); + }).catch((s) => { + if (s.message !== fE) throw s; + r++; + }); + } while (!this.session); + return this.onConnect(), this.session; + } + setDefaultChain(e, r) { + try { + if (!this.session) return; + const [n, i] = this.validateChain(e), s = this.getProvider(n); + s.name === wc ? s.setDefaultChain(`${n}:${i}`, r) : s.setDefaultChain(i, r); + } catch (n) { + if (!/Please call connect/.test(n.message)) throw n; + } + } + async cleanupPendingPairings(e = {}) { + this.logger.info("Cleaning up inactive pairings..."); + const r = this.client.pairing.getAll(); + if (Ba(r)) { + for (const n of r) e.deletePairings ? this.client.core.expirer.set(n.topic, 0) : await this.client.core.relayer.subscriber.unsubscribe(n.topic); + this.logger.info(`Inactive pairings cleared: ${r.length}`); + } + } + abortPairingAttempt() { + this.shouldAbortPairingAttempt = !0; + } + async checkStorage() { + if (this.namespaces = await this.getFromStore("namespaces"), this.optionalNamespaces = await this.getFromStore("optionalNamespaces") || {}, this.client.session.length) { + const e = this.client.session.keys.length - 1; + this.session = this.client.session.get(this.client.session.keys[e]), this.createProviders(); + } + } + async initialize() { + this.logger.trace("Initialized"), await this.createClient(), await this.checkStorage(), this.registerEventListeners(); + } + async createClient() { + this.client = this.providerOpts.client || await T1.init({ core: this.providerOpts.core, logger: this.providerOpts.logger || s_, relayUrl: this.providerOpts.relayUrl || tW, projectId: this.providerOpts.projectId, metadata: this.providerOpts.metadata, storageOptions: this.providerOpts.storageOptions, storage: this.providerOpts.storage, name: this.providerOpts.name, customStoragePrefix: this.providerOpts.customStoragePrefix, telemetryEnabled: this.providerOpts.telemetryEnabled }), this.logger.trace("SignClient Initialized"); + } + createProviders() { + if (!this.client) throw new Error("Sign Client not initialized"); + if (!this.session) throw new Error("Session not initialized. Please call connect() before enable()"); + const e = [...new Set(Object.keys(this.session.namespaces).map((r) => Gu(r)))]; + rm("client", this.client), rm("events", this.events), rm("disableProviderPing", this.disableProviderPing), e.forEach((r) => { + if (!this.session) return; + const n = lW(r, this.session), i = hE(n), s = em(this.namespaces, this.optionalNamespaces), o = nm(Ah({}, s[r]), { accounts: n, chains: i }); + switch (r) { + case "eip155": + this.rpcProviders[r] = new yW({ namespace: o }); + break; + case "algorand": + this.rpcProviders[r] = new _W({ namespace: o }); + break; + case "solana": + this.rpcProviders[r] = new wW({ namespace: o }); + break; + case "cosmos": + this.rpcProviders[r] = new xW({ namespace: o }); + break; + case "polkadot": + this.rpcProviders[r] = new dW({ namespace: o }); + break; + case "cip34": + this.rpcProviders[r] = new EW({ namespace: o }); + break; + case "elrond": + this.rpcProviders[r] = new SW({ namespace: o }); + break; + case "multiversx": + this.rpcProviders[r] = new AW({ namespace: o }); + break; + case "near": + this.rpcProviders[r] = new PW({ namespace: o }); + break; + case "tezos": + this.rpcProviders[r] = new MW({ namespace: o }); + break; + default: + this.rpcProviders[wc] ? this.rpcProviders[wc].updateNamespace(o) : this.rpcProviders[wc] = new IW({ namespace: o }); + } + }); + } + registerEventListeners() { + if (typeof this.client > "u") throw new Error("Sign Client is not initialized"); + this.client.on("session_ping", (e) => { + this.events.emit("session_ping", e); + }), this.client.on("session_event", (e) => { + const { params: r } = e, { event: n } = r; + if (n.name === "accountsChanged") { + const i = n.data; + i && Ba(i) && this.events.emit("accountsChanged", i.map(hW)); + } else if (n.name === "chainChanged") { + const i = r.chainId, s = r.event.data, o = Gu(i), a = tm(i) !== tm(s) ? `${o}:${tm(s)}` : i; + this.onChainChanged(a); + } else this.events.emit(n.name, n.data); + this.events.emit("session_event", e); + }), this.client.on("session_update", ({ topic: e, params: r }) => { + var n; + const { namespaces: i } = r, s = (n = this.client) == null ? void 0 : n.session.get(e); + this.session = nm(Ah({}, s), { namespaces: i }), this.onSessionUpdate(), this.events.emit("session_update", { topic: e, params: r }); + }), this.client.on("session_delete", async (e) => { + await this.cleanup(), this.events.emit("session_delete", e), this.events.emit("disconnect", nm(Ah({}, Nr("USER_DISCONNECTED")), { data: e.topic })); + }), this.on(Ji.DEFAULT_CHAIN_CHANGED, (e) => { + this.onChainChanged(e, !0); + }); + } + getProvider(e) { + return this.rpcProviders[e] || this.rpcProviders[wc]; + } + onSessionUpdate() { + Object.keys(this.rpcProviders).forEach((e) => { + var r; + this.getProvider(e).updateNamespace((r = this.session) == null ? void 0 : r.namespaces[e]); + }); + } + setNamespaces(e) { + const { namespaces: r, optionalNamespaces: n, sessionProperties: i } = e; + r && Object.keys(r).length && (this.namespaces = r), n && Object.keys(n).length && (this.optionalNamespaces = n), this.sessionProperties = i, this.persist("namespaces", r), this.persist("optionalNamespaces", n); + } + validateChain(e) { + const [r, n] = e?.split(":") || ["", ""]; + if (!this.namespaces || !Object.keys(this.namespaces).length) return [r, n]; + if (r && !Object.keys(this.namespaces || {}).map((o) => Gu(o)).includes(r)) throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`); + if (r && n) return [r, n]; + const i = Gu(Object.keys(this.namespaces)[0]), s = this.rpcProviders[i].getDefaultChain(); + return [i, s]; + } + async requestAccounts() { + const [e] = this.validateChain(); + return await this.getProvider(e).requestAccounts(); + } + onChainChanged(e, r = !1) { + if (!this.namespaces) return; + const [n, i] = this.validateChain(e); + i && (r || this.getProvider(n).setDefaultChain(i), this.namespaces[n] ? this.namespaces[n].defaultChain = i : this.namespaces[`${n}:${i}`] ? this.namespaces[`${n}:${i}`].defaultChain = i : this.namespaces[`${n}:${i}`] = { defaultChain: i }, this.persist("namespaces", this.namespaces), this.events.emit("chainChanged", i)); + } + onConnect() { + this.createProviders(), this.events.emit("connect", { session: this.session }); + } + async cleanup() { + this.session = void 0, this.namespaces = void 0, this.optionalNamespaces = void 0, this.sessionProperties = void 0, this.persist("namespaces", void 0), this.persist("optionalNamespaces", void 0), this.persist("sessionProperties", void 0), await this.cleanupPendingPairings({ deletePairings: !0 }); + } + persist(e, r) { + this.client.core.storage.setItem(`${o_}/${e}`, r); + } + async getFromStore(e) { + return await this.client.core.storage.getItem(`${o_}/${e}`); + } +}; +const NW = fv; +function LW() { + return new Promise((t) => { + const e = []; + let r; + window.addEventListener("eip6963:announceProvider", (n) => { + const { detail: i } = n; + r && clearTimeout(r), e.push(i), r = setTimeout(() => t(e), 200); + }), r = setTimeout(() => t(e), 200), window.dispatchEvent(new Event("eip6963:requestProvider")); + }); +} +class Os { + constructor(e, r) { + this.scope = e, this.module = r; + } + storeObject(e, r) { + this.setItem(e, JSON.stringify(r)); + } + loadObject(e) { + const r = this.getItem(e); + return r ? JSON.parse(r) : void 0; + } + setItem(e, r) { + localStorage.setItem(this.scopedKey(e), r); + } + getItem(e) { + return localStorage.getItem(this.scopedKey(e)); + } + removeItem(e) { + localStorage.removeItem(this.scopedKey(e)); + } + clear() { + const e = this.scopedKey(""), r = []; + for (let n = 0; n < localStorage.length; n++) { + const i = localStorage.key(n); + typeof i == "string" && i.startsWith(e) && r.push(i); + } + r.forEach((n) => localStorage.removeItem(n)); + } + scopedKey(e) { + return `-${this.scope}${this.module ? `:${this.module}` : ""}:${e}`; + } + static clearAll() { + new Os("CBWSDK").clear(), new Os("walletlink").clear(); + } +} +const un = { + rpc: { + invalidInput: -32e3, + resourceNotFound: -32001, + resourceUnavailable: -32002, + transactionRejected: -32003, + methodNotSupported: -32004, + limitExceeded: -32005, + parse: -32700, + invalidRequest: -32600, + methodNotFound: -32601, + invalidParams: -32602, + internal: -32603 + }, + provider: { + userRejectedRequest: 4001, + unauthorized: 4100, + unsupportedMethod: 4200, + disconnected: 4900, + chainDisconnected: 4901, + unsupportedChain: 4902 + } +}, lv = { + "-32700": { + standard: "JSON RPC 2.0", + message: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text." + }, + "-32600": { + standard: "JSON RPC 2.0", + message: "The JSON sent is not a valid Request object." + }, + "-32601": { + standard: "JSON RPC 2.0", + message: "The method does not exist / is not available." + }, + "-32602": { + standard: "JSON RPC 2.0", + message: "Invalid method parameter(s)." + }, + "-32603": { + standard: "JSON RPC 2.0", + message: "Internal JSON-RPC error." + }, + "-32000": { + standard: "EIP-1474", + message: "Invalid input." + }, + "-32001": { + standard: "EIP-1474", + message: "Resource not found." + }, + "-32002": { + standard: "EIP-1474", + message: "Resource unavailable." + }, + "-32003": { + standard: "EIP-1474", + message: "Transaction rejected." + }, + "-32004": { + standard: "EIP-1474", + message: "Method not supported." + }, + "-32005": { + standard: "EIP-1474", + message: "Request limit exceeded." + }, + 4001: { + standard: "EIP-1193", + message: "User rejected the request." + }, + 4100: { + standard: "EIP-1193", + message: "The requested account and/or method has not been authorized by the user." + }, + 4200: { + standard: "EIP-1193", + message: "The requested method is not supported by this Ethereum provider." + }, + 4900: { + standard: "EIP-1193", + message: "The provider is disconnected from all chains." + }, + 4901: { + standard: "EIP-1193", + message: "The provider is disconnected from the specified chain." + }, + 4902: { + standard: "EIP-3085", + message: "Unrecognized chain ID." + } +}, gE = "Unspecified error message.", kW = "Unspecified server error."; +function D1(t, e = gE) { + if (t && Number.isInteger(t)) { + const r = t.toString(); + if (hv(lv, r)) + return lv[r].message; + if (mE(t)) + return kW; + } + return e; +} +function $W(t) { + if (!Number.isInteger(t)) + return !1; + const e = t.toString(); + return !!(lv[e] || mE(t)); +} +function BW(t, { shouldIncludeStack: e = !1 } = {}) { + const r = {}; + if (t && typeof t == "object" && !Array.isArray(t) && hv(t, "code") && $W(t.code)) { + const n = t; + r.code = n.code, n.message && typeof n.message == "string" ? (r.message = n.message, hv(n, "data") && (r.data = n.data)) : (r.message = D1(r.code), r.data = { originalError: v_(t) }); + } else + r.code = un.rpc.internal, r.message = b_(t, "message") ? t.message : gE, r.data = { originalError: v_(t) }; + return e && (r.stack = b_(t, "stack") ? t.stack : void 0), r; +} +function mE(t) { + return t >= -32099 && t <= -32e3; +} +function v_(t) { + return t && typeof t == "object" && !Array.isArray(t) ? Object.assign({}, t) : t; +} +function hv(t, e) { + return Object.prototype.hasOwnProperty.call(t, e); +} +function b_(t, e) { + return typeof t == "object" && t !== null && e in t && typeof t[e] == "string"; +} +const Ar = { + rpc: { + parse: (t) => Bi(un.rpc.parse, t), + invalidRequest: (t) => Bi(un.rpc.invalidRequest, t), + invalidParams: (t) => Bi(un.rpc.invalidParams, t), + methodNotFound: (t) => Bi(un.rpc.methodNotFound, t), + internal: (t) => Bi(un.rpc.internal, t), + server: (t) => { + if (!t || typeof t != "object" || Array.isArray(t)) + throw new Error("Ethereum RPC Server errors must provide single object argument."); + const { code: e } = t; + if (!Number.isInteger(e) || e > -32005 || e < -32099) + throw new Error('"code" must be an integer such that: -32099 <= code <= -32005'); + return Bi(e, t); + }, + invalidInput: (t) => Bi(un.rpc.invalidInput, t), + resourceNotFound: (t) => Bi(un.rpc.resourceNotFound, t), + resourceUnavailable: (t) => Bi(un.rpc.resourceUnavailable, t), + transactionRejected: (t) => Bi(un.rpc.transactionRejected, t), + methodNotSupported: (t) => Bi(un.rpc.methodNotSupported, t), + limitExceeded: (t) => Bi(un.rpc.limitExceeded, t) + }, + provider: { + userRejectedRequest: (t) => mc(un.provider.userRejectedRequest, t), + unauthorized: (t) => mc(un.provider.unauthorized, t), + unsupportedMethod: (t) => mc(un.provider.unsupportedMethod, t), + disconnected: (t) => mc(un.provider.disconnected, t), + chainDisconnected: (t) => mc(un.provider.chainDisconnected, t), + unsupportedChain: (t) => mc(un.provider.unsupportedChain, t), + custom: (t) => { + if (!t || typeof t != "object" || Array.isArray(t)) + throw new Error("Ethereum Provider custom errors must provide single object argument."); + const { code: e, message: r, data: n } = t; + if (!r || typeof r != "string") + throw new Error('"message" must be a nonempty string'); + return new yE(e, r, n); + } + } +}; +function Bi(t, e) { + const [r, n] = vE(e); + return new bE(t, r || D1(t), n); +} +function mc(t, e) { + const [r, n] = vE(e); + return new yE(t, r || D1(t), n); +} +function vE(t) { + if (t) { + if (typeof t == "string") + return [t]; + if (typeof t == "object" && !Array.isArray(t)) { + const { message: e, data: r } = t; + if (e && typeof e != "string") + throw new Error("Must specify string message."); + return [e || void 0, r]; + } + } + return []; +} +class bE extends Error { + constructor(e, r, n) { + if (!Number.isInteger(e)) + throw new Error('"code" must be an integer.'); + if (!r || typeof r != "string") + throw new Error('"message" must be a nonempty string.'); + super(r), this.code = e, n !== void 0 && (this.data = n); + } +} +class yE extends bE { + /** + * Create an Ethereum Provider JSON-RPC error. + * `code` must be an integer in the 1000 <= 4999 range. + */ + constructor(e, r, n) { + if (!FW(e)) + throw new Error('"code" must be an integer such that: 1000 <= code <= 4999'); + super(e, r, n); + } +} +function FW(t) { + return Number.isInteger(t) && t >= 1e3 && t <= 4999; +} +function O1() { + return (t) => t; +} +const $f = O1(), jW = O1(), UW = O1(); +function eo(t) { + return Math.floor(t); +} +const wE = /^[0-9]*$/, xE = /^[a-f0-9]*$/; +function Ea(t) { + return N1(crypto.getRandomValues(new Uint8Array(t))); +} +function N1(t) { + return [...t].map((e) => e.toString(16).padStart(2, "0")).join(""); +} +function Vh(t) { + return new Uint8Array(t.match(/.{1,2}/g).map((e) => Number.parseInt(e, 16))); +} +function nf(t, e = !1) { + const r = t.toString("hex"); + return $f(e ? `0x${r}` : r); +} +function im(t) { + return nf(dv(t), !0); +} +function Es(t) { + return UW(t.toString(10)); +} +function Bo(t) { + return $f(`0x${BigInt(t).toString(16)}`); +} +function _E(t) { + return t.startsWith("0x") || t.startsWith("0X"); +} +function L1(t) { + return _E(t) ? t.slice(2) : t; +} +function EE(t) { + return _E(t) ? `0x${t.slice(2)}` : `0x${t}`; +} +function a0(t) { + if (typeof t != "string") + return !1; + const e = L1(t).toLowerCase(); + return xE.test(e); +} +function qW(t, e = !1) { + if (typeof t == "string") { + const r = L1(t).toLowerCase(); + if (xE.test(r)) + return $f(e ? `0x${r}` : r); + } + throw Ar.rpc.invalidParams(`"${String(t)}" is not a hexadecimal string`); +} +function k1(t, e = !1) { + let r = qW(t, !1); + return r.length % 2 === 1 && (r = $f(`0${r}`)), e ? $f(`0x${r}`) : r; +} +function Mo(t) { + if (typeof t == "string") { + const e = L1(t).toLowerCase(); + if (a0(e) && e.length === 40) + return jW(EE(e)); + } + throw Ar.rpc.invalidParams(`Invalid Ethereum address: ${String(t)}`); +} +function dv(t) { + if (Buffer.isBuffer(t)) + return t; + if (typeof t == "string") { + if (a0(t)) { + const e = k1(t, !1); + return Buffer.from(e, "hex"); + } + return Buffer.from(t, "utf8"); + } + throw Ar.rpc.invalidParams(`Not binary data: ${String(t)}`); +} +function sf(t) { + if (typeof t == "number" && Number.isInteger(t)) + return eo(t); + if (typeof t == "string") { + if (wE.test(t)) + return eo(Number(t)); + if (a0(t)) + return eo(Number(BigInt(k1(t, !0)))); + } + throw Ar.rpc.invalidParams(`Not an integer: ${String(t)}`); +} +function Fu(t) { + if (t !== null && (typeof t == "bigint" || HW(t))) + return BigInt(t.toString(10)); + if (typeof t == "number") + return BigInt(sf(t)); + if (typeof t == "string") { + if (wE.test(t)) + return BigInt(t); + if (a0(t)) + return BigInt(k1(t, !0)); + } + throw Ar.rpc.invalidParams(`Not an integer: ${String(t)}`); +} +function zW(t) { + if (typeof t == "string") + return JSON.parse(t); + if (typeof t == "object") + return t; + throw Ar.rpc.invalidParams(`Not a JSON string or an object: ${String(t)}`); +} +function HW(t) { + if (t == null || typeof t.constructor != "function") + return !1; + const { constructor: e } = t; + return typeof e.config == "function" && typeof e.EUCLID == "number"; +} +async function WW() { + return crypto.subtle.generateKey({ + name: "ECDH", + namedCurve: "P-256" + }, !0, ["deriveKey"]); +} +async function KW(t, e) { + return crypto.subtle.deriveKey({ + name: "ECDH", + public: e + }, t, { + name: "AES-GCM", + length: 256 + }, !1, ["encrypt", "decrypt"]); +} +async function VW(t, e) { + const r = crypto.getRandomValues(new Uint8Array(12)), n = await crypto.subtle.encrypt({ + name: "AES-GCM", + iv: r + }, t, new TextEncoder().encode(e)); + return { iv: r, cipherText: n }; +} +async function GW(t, { iv: e, cipherText: r }) { + const n = await crypto.subtle.decrypt({ + name: "AES-GCM", + iv: e + }, t, r); + return new TextDecoder().decode(n); +} +function SE(t) { + switch (t) { + case "public": + return "spki"; + case "private": + return "pkcs8"; + } +} +async function AE(t, e) { + const r = SE(t), n = await crypto.subtle.exportKey(r, e); + return N1(new Uint8Array(n)); +} +async function PE(t, e) { + const r = SE(t), n = Vh(e).buffer; + return await crypto.subtle.importKey(r, new Uint8Array(n), { + name: "ECDH", + namedCurve: "P-256" + }, !0, t === "private" ? ["deriveKey"] : []); +} +async function YW(t, e) { + const r = JSON.stringify(t, (n, i) => { + if (!(i instanceof Error)) + return i; + const s = i; + return Object.assign(Object.assign({}, s.code ? { code: s.code } : {}), { message: s.message }); + }); + return VW(e, r); +} +async function JW(t, e) { + return JSON.parse(await GW(e, t)); +} +const sm = { + storageKey: "ownPrivateKey", + keyType: "private" +}, om = { + storageKey: "ownPublicKey", + keyType: "public" +}, am = { + storageKey: "peerPublicKey", + keyType: "public" +}; +class XW { + constructor() { + this.storage = new Os("CBWSDK", "SCWKeyManager"), this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null; + } + async getOwnPublicKey() { + return await this.loadKeysIfNeeded(), this.ownPublicKey; + } + // returns null if the shared secret is not yet derived + async getSharedSecret() { + return await this.loadKeysIfNeeded(), this.sharedSecret; + } + async setPeerPublicKey(e) { + this.sharedSecret = null, this.peerPublicKey = e, await this.storeKey(am, e), await this.loadKeysIfNeeded(); + } + async clear() { + this.ownPrivateKey = null, this.ownPublicKey = null, this.peerPublicKey = null, this.sharedSecret = null, this.storage.removeItem(om.storageKey), this.storage.removeItem(sm.storageKey), this.storage.removeItem(am.storageKey); + } + async generateKeyPair() { + const e = await WW(); + this.ownPrivateKey = e.privateKey, this.ownPublicKey = e.publicKey, await this.storeKey(sm, e.privateKey), await this.storeKey(om, e.publicKey); + } + async loadKeysIfNeeded() { + if (this.ownPrivateKey === null && (this.ownPrivateKey = await this.loadKey(sm)), this.ownPublicKey === null && (this.ownPublicKey = await this.loadKey(om)), (this.ownPrivateKey === null || this.ownPublicKey === null) && await this.generateKeyPair(), this.peerPublicKey === null && (this.peerPublicKey = await this.loadKey(am)), this.sharedSecret === null) { + if (this.ownPrivateKey === null || this.peerPublicKey === null) + return; + this.sharedSecret = await KW(this.ownPrivateKey, this.peerPublicKey); + } + } + // storage methods + async loadKey(e) { + const r = this.storage.getItem(e.storageKey); + return r ? PE(e.keyType, r) : null; + } + async storeKey(e, r) { + const n = await AE(e.keyType, r); + this.storage.setItem(e.storageKey, n); + } +} +const ul = "4.2.4", ME = "@coinbase/wallet-sdk"; +async function IE(t, e) { + const r = Object.assign(Object.assign({}, t), { jsonrpc: "2.0", id: crypto.randomUUID() }), n = await window.fetch(e, { + method: "POST", + body: JSON.stringify(r), + mode: "cors", + headers: { + "Content-Type": "application/json", + "X-Cbw-Sdk-Version": ul, + "X-Cbw-Sdk-Platform": ME + } + }), { result: i, error: s } = await n.json(); + if (s) + throw s; + return i; +} +function ZW() { + return globalThis.coinbaseWalletExtension; +} +function QW() { + var t, e; + try { + const r = globalThis; + return (t = r.ethereum) !== null && t !== void 0 ? t : (e = r.top) === null || e === void 0 ? void 0 : e.ethereum; + } catch { + return; + } +} +function eK({ metadata: t, preference: e }) { + var r, n; + const { appName: i, appLogoUrl: s, appChainIds: o } = t; + if (e.options !== "smartWalletOnly") { + const f = ZW(); + if (f) + return (r = f.setAppInfo) === null || r === void 0 || r.call(f, i, s, o, e), f; + } + const a = QW(); + if (a?.isCoinbaseBrowser) + return (n = a.setAppInfo) === null || n === void 0 || n.call(a, i, s, o, e), a; +} +function tK(t) { + if (!t || typeof t != "object" || Array.isArray(t)) + throw Ar.rpc.invalidParams({ + message: "Expected a single, non-array, object argument.", + data: t + }); + const { method: e, params: r } = t; + if (typeof e != "string" || e.length === 0) + throw Ar.rpc.invalidParams({ + message: "'args.method' must be a non-empty string.", + data: t + }); + if (r !== void 0 && !Array.isArray(r) && (typeof r != "object" || r === null)) + throw Ar.rpc.invalidParams({ + message: "'args.params' must be an object or array if provided.", + data: t + }); + switch (e) { + case "eth_sign": + case "eth_signTypedData_v2": + case "eth_subscribe": + case "eth_unsubscribe": + throw Ar.provider.unsupportedMethod(); + } +} +const y_ = "accounts", w_ = "activeChain", x_ = "availableChains", __ = "walletCapabilities"; +class rK { + constructor(e) { + var r, n, i; + this.metadata = e.metadata, this.communicator = e.communicator, this.callback = e.callback, this.keyManager = new XW(), this.storage = new Os("CBWSDK", "SCWStateManager"), this.accounts = (r = this.storage.loadObject(y_)) !== null && r !== void 0 ? r : [], this.chain = this.storage.loadObject(w_) || { + id: (i = (n = e.metadata.appChainIds) === null || n === void 0 ? void 0 : n[0]) !== null && i !== void 0 ? i : 1 + }, this.handshake = this.handshake.bind(this), this.request = this.request.bind(this), this.createRequestMessage = this.createRequestMessage.bind(this), this.decryptResponseMessage = this.decryptResponseMessage.bind(this); + } + async handshake(e) { + var r, n; + const i = await this.createRequestMessage({ + handshake: { + method: e.method, + params: Object.assign({}, this.metadata, (r = e.params) !== null && r !== void 0 ? r : {}) + } + }), s = await this.communicator.postRequestAndWaitForResponse(i); + if ("failure" in s.content) + throw s.content.failure; + const o = await PE("public", s.sender); + await this.keyManager.setPeerPublicKey(o); + const f = (await this.decryptResponseMessage(s)).result; + if ("error" in f) + throw f.error; + const u = f.value; + this.accounts = u, this.storage.storeObject(y_, u), (n = this.callback) === null || n === void 0 || n.call(this, "accountsChanged", u); + } + async request(e) { + var r; + if (this.accounts.length === 0) + throw Ar.provider.unauthorized(); + switch (e.method) { + case "eth_requestAccounts": + return (r = this.callback) === null || r === void 0 || r.call(this, "connect", { chainId: Bo(this.chain.id) }), this.accounts; + case "eth_accounts": + return this.accounts; + case "eth_coinbase": + return this.accounts[0]; + case "net_version": + return this.chain.id; + case "eth_chainId": + return Bo(this.chain.id); + case "wallet_getCapabilities": + return this.storage.loadObject(__); + case "wallet_switchEthereumChain": + return this.handleSwitchChainRequest(e); + case "eth_ecRecover": + case "personal_sign": + case "personal_ecRecover": + case "eth_signTransaction": + case "eth_sendTransaction": + case "eth_signTypedData_v1": + case "eth_signTypedData_v3": + case "eth_signTypedData_v4": + case "eth_signTypedData": + case "wallet_addEthereumChain": + case "wallet_watchAsset": + case "wallet_sendCalls": + case "wallet_showCallsStatus": + case "wallet_grantPermissions": + return this.sendRequestToPopup(e); + default: + if (!this.chain.rpcUrl) + throw Ar.rpc.internal("No RPC URL set for chain"); + return IE(e, this.chain.rpcUrl); + } + } + async sendRequestToPopup(e) { + var r, n; + await ((n = (r = this.communicator).waitForPopupLoaded) === null || n === void 0 ? void 0 : n.call(r)); + const i = await this.sendEncryptedRequest(e), o = (await this.decryptResponseMessage(i)).result; + if ("error" in o) + throw o.error; + return o.value; + } + async cleanup() { + var e, r; + this.storage.clear(), await this.keyManager.clear(), this.accounts = [], this.chain = { + id: (r = (e = this.metadata.appChainIds) === null || e === void 0 ? void 0 : e[0]) !== null && r !== void 0 ? r : 1 + }; + } + /** + * @returns `null` if the request was successful. + * https://eips.ethereum.org/EIPS/eip-3326#wallet_switchethereumchain + */ + async handleSwitchChainRequest(e) { + var r; + const n = e.params; + if (!n || !(!((r = n[0]) === null || r === void 0) && r.chainId)) + throw Ar.rpc.invalidParams(); + const i = sf(n[0].chainId); + if (this.updateChain(i)) + return null; + const o = await this.sendRequestToPopup(e); + return o === null && this.updateChain(i), o; + } + async sendEncryptedRequest(e) { + const r = await this.keyManager.getSharedSecret(); + if (!r) + throw Ar.provider.unauthorized("No valid session found, try requestAccounts before other methods"); + const n = await YW({ + action: e, + chainId: this.chain.id + }, r), i = await this.createRequestMessage({ encrypted: n }); + return this.communicator.postRequestAndWaitForResponse(i); + } + async createRequestMessage(e) { + const r = await AE("public", await this.keyManager.getOwnPublicKey()); + return { + id: crypto.randomUUID(), + sender: r, + content: e, + timestamp: /* @__PURE__ */ new Date() + }; + } + async decryptResponseMessage(e) { + var r, n; + const i = e.content; + if ("failure" in i) + throw i.failure; + const s = await this.keyManager.getSharedSecret(); + if (!s) + throw Ar.provider.unauthorized("Invalid session"); + const o = await JW(i.encrypted, s), a = (r = o.data) === null || r === void 0 ? void 0 : r.chains; + if (a) { + const u = Object.entries(a).map(([h, g]) => ({ + id: Number(h), + rpcUrl: g + })); + this.storage.storeObject(x_, u), this.updateChain(this.chain.id, u); + } + const f = (n = o.data) === null || n === void 0 ? void 0 : n.capabilities; + return f && this.storage.storeObject(__, f), o; + } + updateChain(e, r) { + var n; + const i = r ?? this.storage.loadObject(x_), s = i?.find((o) => o.id === e); + return s ? (s !== this.chain && (this.chain = s, this.storage.storeObject(w_, s), (n = this.callback) === null || n === void 0 || n.call(this, "chainChanged", Bo(s.id))), !0) : !1; + } +} +var Hr = {}, er = {}, E_; +function nK() { + if (E_) return er; + E_ = 1, Object.defineProperty(er, "__esModule", { value: !0 }), er.toBig = er.shrSL = er.shrSH = er.rotrSL = er.rotrSH = er.rotrBL = er.rotrBH = er.rotr32L = er.rotr32H = er.rotlSL = er.rotlSH = er.rotlBL = er.rotlBH = er.add5L = er.add5H = er.add4L = er.add4H = er.add3L = er.add3H = void 0, er.add = k, er.fromBig = r, er.split = n; + const t = /* @__PURE__ */ BigInt(2 ** 32 - 1), e = /* @__PURE__ */ BigInt(32); + function r(J, ne = !1) { + return ne ? { h: Number(J & t), l: Number(J >> e & t) } : { h: Number(J >> e & t) | 0, l: Number(J & t) | 0 }; + } + function n(J, ne = !1) { + const K = J.length; + let E = new Uint32Array(K), b = new Uint32Array(K); + for (let l = 0; l < K; l++) { + const { h: p, l: m } = r(J[l], ne); + [E[l], b[l]] = [p, m]; + } + return [E, b]; + } + const i = (J, ne) => BigInt(J >>> 0) << e | BigInt(ne >>> 0); + er.toBig = i; + const s = (J, ne, K) => J >>> K; + er.shrSH = s; + const o = (J, ne, K) => J << 32 - K | ne >>> K; + er.shrSL = o; + const a = (J, ne, K) => J >>> K | ne << 32 - K; + er.rotrSH = a; + const f = (J, ne, K) => J << 32 - K | ne >>> K; + er.rotrSL = f; + const u = (J, ne, K) => J << 64 - K | ne >>> K - 32; + er.rotrBH = u; + const h = (J, ne, K) => J >>> K - 32 | ne << 64 - K; + er.rotrBL = h; + const g = (J, ne) => ne; + er.rotr32H = g; + const v = (J, ne) => J; + er.rotr32L = v; + const x = (J, ne, K) => J << K | ne >>> 32 - K; + er.rotlSH = x; + const S = (J, ne, K) => ne << K | J >>> 32 - K; + er.rotlSL = S; + const R = (J, ne, K) => ne << K - 32 | J >>> 64 - K; + er.rotlBH = R; + const D = (J, ne, K) => J << K - 32 | ne >>> 64 - K; + er.rotlBL = D; + function k(J, ne, K, E) { + const b = (ne >>> 0) + (E >>> 0); + return { h: J + K + (b / 2 ** 32 | 0) | 0, l: b | 0 }; + } + const N = (J, ne, K) => (J >>> 0) + (ne >>> 0) + (K >>> 0); + er.add3L = N; + const z = (J, ne, K, E) => ne + K + E + (J / 2 ** 32 | 0) | 0; + er.add3H = z; + const B = (J, ne, K, E) => (J >>> 0) + (ne >>> 0) + (K >>> 0) + (E >>> 0); + er.add4L = B; + const $ = (J, ne, K, E, b) => ne + K + E + b + (J / 2 ** 32 | 0) | 0; + er.add4H = $; + const U = (J, ne, K, E, b) => (J >>> 0) + (ne >>> 0) + (K >>> 0) + (E >>> 0) + (b >>> 0); + er.add5L = U; + const C = (J, ne, K, E, b, l) => ne + K + E + b + l + (J / 2 ** 32 | 0) | 0; + er.add5H = C; + const W = { + fromBig: r, + split: n, + toBig: i, + shrSH: s, + shrSL: o, + rotrSH: a, + rotrSL: f, + rotrBH: u, + rotrBL: h, + rotr32H: g, + rotr32L: v, + rotlSH: x, + rotlSL: S, + rotlBH: R, + rotlBL: D, + add: k, + add3L: N, + add3H: z, + add4L: B, + add4H: $, + add5H: C, + add5L: U + }; + return er.default = W, er; +} +var cm = {}, ju = {}, S_; +function iK() { + return S_ || (S_ = 1, Object.defineProperty(ju, "__esModule", { value: !0 }), ju.crypto = void 0, ju.crypto = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0), ju; +} +var A_; +function sK() { + return A_ || (A_ = 1, (function(t) { + /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ + Object.defineProperty(t, "__esModule", { value: !0 }), t.wrapXOFConstructorWithOpts = t.wrapConstructorWithOpts = t.wrapConstructor = t.Hash = t.nextTick = t.swap32IfBE = t.byteSwapIfBE = t.swap8IfBE = t.isLE = void 0, t.isBytes = r, t.anumber = n, t.abytes = i, t.ahash = s, t.aexists = o, t.aoutput = a, t.u8 = f, t.u32 = u, t.clean = h, t.createView = g, t.rotr = v, t.rotl = x, t.byteSwap = S, t.byteSwap32 = R, t.bytesToHex = N, t.hexToBytes = $, t.asyncLoop = C, t.utf8ToBytes = W, t.bytesToUtf8 = J, t.toBytes = ne, t.kdfInputToBytes = K, t.concatBytes = E, t.checkOpts = b, t.createHasher = p, t.createOptHasher = m, t.createXOFer = w, t.randomBytes = P; + const e = /* @__PURE__ */ iK(); + function r(_) { + return _ instanceof Uint8Array || ArrayBuffer.isView(_) && _.constructor.name === "Uint8Array"; + } + function n(_) { + if (!Number.isSafeInteger(_) || _ < 0) + throw new Error("positive integer expected, got " + _); + } + function i(_, ...y) { + if (!r(_)) + throw new Error("Uint8Array expected"); + if (y.length > 0 && !y.includes(_.length)) + throw new Error("Uint8Array expected of length " + y + ", got length=" + _.length); + } + function s(_) { + if (typeof _ != "function" || typeof _.create != "function") + throw new Error("Hash should be wrapped by utils.createHasher"); + n(_.outputLen), n(_.blockLen); + } + function o(_, y = !0) { + if (_.destroyed) + throw new Error("Hash instance has been destroyed"); + if (y && _.finished) + throw new Error("Hash#digest() has already been called"); + } + function a(_, y) { + i(_); + const M = y.outputLen; + if (_.length < M) + throw new Error("digestInto() expects output buffer of length at least " + M); + } + function f(_) { + return new Uint8Array(_.buffer, _.byteOffset, _.byteLength); + } + function u(_) { + return new Uint32Array(_.buffer, _.byteOffset, Math.floor(_.byteLength / 4)); + } + function h(..._) { + for (let y = 0; y < _.length; y++) + _[y].fill(0); + } + function g(_) { + return new DataView(_.buffer, _.byteOffset, _.byteLength); + } + function v(_, y) { + return _ << 32 - y | _ >>> y; + } + function x(_, y) { + return _ << y | _ >>> 32 - y >>> 0; + } + t.isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; + function S(_) { + return _ << 24 & 4278190080 | _ << 8 & 16711680 | _ >>> 8 & 65280 | _ >>> 24 & 255; + } + t.swap8IfBE = t.isLE ? (_) => _ : (_) => S(_), t.byteSwapIfBE = t.swap8IfBE; + function R(_) { + for (let y = 0; y < _.length; y++) + _[y] = S(_[y]); + return _; + } + t.swap32IfBE = t.isLE ? (_) => _ : R; + const D = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", k = /* @__PURE__ */ Array.from({ length: 256 }, (_, y) => y.toString(16).padStart(2, "0")); + function N(_) { + if (i(_), D) + return _.toHex(); + let y = ""; + for (let M = 0; M < _.length; M++) + y += k[_[M]]; + return y; + } + const z = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 }; + function B(_) { + if (_ >= z._0 && _ <= z._9) + return _ - z._0; + if (_ >= z.A && _ <= z.F) + return _ - (z.A - 10); + if (_ >= z.a && _ <= z.f) + return _ - (z.a - 10); + } + function $(_) { + if (typeof _ != "string") + throw new Error("hex string expected, got " + typeof _); + if (D) + return Uint8Array.fromHex(_); + const y = _.length, M = y / 2; + if (y % 2) + throw new Error("hex string expected, got unpadded hex of length " + y); + const I = new Uint8Array(M); + for (let q = 0, ce = 0; q < M; q++, ce += 2) { + const L = B(_.charCodeAt(ce)), oe = B(_.charCodeAt(ce + 1)); + if (L === void 0 || oe === void 0) { + const Q = _[ce] + _[ce + 1]; + throw new Error('hex string expected, got non-hex character "' + Q + '" at index ' + ce); + } + I[q] = L * 16 + oe; + } + return I; + } + const U = async () => { + }; + t.nextTick = U; + async function C(_, y, M) { + let I = Date.now(); + for (let q = 0; q < _; q++) { + M(q); + const ce = Date.now() - I; + ce >= 0 && ce < y || (await (0, t.nextTick)(), I += ce); + } + } + function W(_) { + if (typeof _ != "string") + throw new Error("string expected"); + return new Uint8Array(new TextEncoder().encode(_)); + } + function J(_) { + return new TextDecoder().decode(_); + } + function ne(_) { + return typeof _ == "string" && (_ = W(_)), i(_), _; + } + function K(_) { + return typeof _ == "string" && (_ = W(_)), i(_), _; + } + function E(..._) { + let y = 0; + for (let I = 0; I < _.length; I++) { + const q = _[I]; + i(q), y += q.length; + } + const M = new Uint8Array(y); + for (let I = 0, q = 0; I < _.length; I++) { + const ce = _[I]; + M.set(ce, q), q += ce.length; + } + return M; + } + function b(_, y) { + if (y !== void 0 && {}.toString.call(y) !== "[object Object]") + throw new Error("options should be object or undefined"); + return Object.assign(_, y); + } + class l { + } + t.Hash = l; + function p(_) { + const y = (I) => _().update(ne(I)).digest(), M = _(); + return y.outputLen = M.outputLen, y.blockLen = M.blockLen, y.create = () => _(), y; + } + function m(_) { + const y = (I, q) => _(q).update(ne(I)).digest(), M = _({}); + return y.outputLen = M.outputLen, y.blockLen = M.blockLen, y.create = (I) => _(I), y; + } + function w(_) { + const y = (I, q) => _(q).update(ne(I)).digest(), M = _({}); + return y.outputLen = M.outputLen, y.blockLen = M.blockLen, y.create = (I) => _(I), y; + } + t.wrapConstructor = p, t.wrapConstructorWithOpts = m, t.wrapXOFConstructorWithOpts = w; + function P(_ = 32) { + if (e.crypto && typeof e.crypto.getRandomValues == "function") + return e.crypto.getRandomValues(new Uint8Array(_)); + if (e.crypto && typeof e.crypto.randomBytes == "function") + return Uint8Array.from(e.crypto.randomBytes(_)); + throw new Error("crypto.getRandomValues must be defined"); + } + })(cm)), cm; +} +var P_; +function oK() { + if (P_) return Hr; + P_ = 1, Object.defineProperty(Hr, "__esModule", { value: !0 }), Hr.shake256 = Hr.shake128 = Hr.keccak_512 = Hr.keccak_384 = Hr.keccak_256 = Hr.keccak_224 = Hr.sha3_512 = Hr.sha3_384 = Hr.sha3_256 = Hr.sha3_224 = Hr.Keccak = void 0, Hr.keccakP = D; + const t = /* @__PURE__ */ nK(), e = /* @__PURE__ */ sK(), r = BigInt(0), n = BigInt(1), i = BigInt(2), s = BigInt(7), o = BigInt(256), a = BigInt(113), f = [], u = [], h = []; + for (let B = 0, $ = n, U = 1, C = 0; B < 24; B++) { + [U, C] = [C, (2 * U + 3 * C) % 5], f.push(2 * (5 * C + U)), u.push((B + 1) * (B + 2) / 2 % 64); + let W = r; + for (let J = 0; J < 7; J++) + $ = ($ << n ^ ($ >> s) * a) % o, $ & i && (W ^= n << (n << /* @__PURE__ */ BigInt(J)) - n); + h.push(W); + } + const g = (0, t.split)(h, !0), v = g[0], x = g[1], S = (B, $, U) => U > 32 ? (0, t.rotlBH)(B, $, U) : (0, t.rotlSH)(B, $, U), R = (B, $, U) => U > 32 ? (0, t.rotlBL)(B, $, U) : (0, t.rotlSL)(B, $, U); + function D(B, $ = 24) { + const U = new Uint32Array(10); + for (let C = 24 - $; C < 24; C++) { + for (let ne = 0; ne < 10; ne++) + U[ne] = B[ne] ^ B[ne + 10] ^ B[ne + 20] ^ B[ne + 30] ^ B[ne + 40]; + for (let ne = 0; ne < 10; ne += 2) { + const K = (ne + 8) % 10, E = (ne + 2) % 10, b = U[E], l = U[E + 1], p = S(b, l, 1) ^ U[K], m = R(b, l, 1) ^ U[K + 1]; + for (let w = 0; w < 50; w += 10) + B[ne + w] ^= p, B[ne + w + 1] ^= m; + } + let W = B[2], J = B[3]; + for (let ne = 0; ne < 24; ne++) { + const K = u[ne], E = S(W, J, K), b = R(W, J, K), l = f[ne]; + W = B[l], J = B[l + 1], B[l] = E, B[l + 1] = b; + } + for (let ne = 0; ne < 50; ne += 10) { + for (let K = 0; K < 10; K++) + U[K] = B[ne + K]; + for (let K = 0; K < 10; K++) + B[ne + K] ^= ~U[(K + 2) % 10] & U[(K + 4) % 10]; + } + B[0] ^= v[C], B[1] ^= x[C]; + } + (0, e.clean)(U); + } + class k extends e.Hash { + // NOTE: we accept arguments in bytes instead of bits here. + constructor($, U, C, W = !1, J = 24) { + if (super(), this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, this.enableXOF = !1, this.blockLen = $, this.suffix = U, this.outputLen = C, this.enableXOF = W, this.rounds = J, (0, e.anumber)(C), !(0 < $ && $ < 200)) + throw new Error("only keccak-f1600 function is supported"); + this.state = new Uint8Array(200), this.state32 = (0, e.u32)(this.state); + } + clone() { + return this._cloneInto(); + } + keccak() { + (0, e.swap32IfBE)(this.state32), D(this.state32, this.rounds), (0, e.swap32IfBE)(this.state32), this.posOut = 0, this.pos = 0; + } + update($) { + (0, e.aexists)(this), $ = (0, e.toBytes)($), (0, e.abytes)($); + const { blockLen: U, state: C } = this, W = $.length; + for (let J = 0; J < W; ) { + const ne = Math.min(U - this.pos, W - J); + for (let K = 0; K < ne; K++) + C[this.pos++] ^= $[J++]; + this.pos === U && this.keccak(); + } + return this; + } + finish() { + if (this.finished) + return; + this.finished = !0; + const { state: $, suffix: U, pos: C, blockLen: W } = this; + $[C] ^= U, (U & 128) !== 0 && C === W - 1 && this.keccak(), $[W - 1] ^= 128, this.keccak(); + } + writeInto($) { + (0, e.aexists)(this, !1), (0, e.abytes)($), this.finish(); + const U = this.state, { blockLen: C } = this; + for (let W = 0, J = $.length; W < J; ) { + this.posOut >= C && this.keccak(); + const ne = Math.min(C - this.posOut, J - W); + $.set(U.subarray(this.posOut, this.posOut + ne), W), this.posOut += ne, W += ne; + } + return $; + } + xofInto($) { + if (!this.enableXOF) + throw new Error("XOF is not possible for this instance"); + return this.writeInto($); + } + xof($) { + return (0, e.anumber)($), this.xofInto(new Uint8Array($)); + } + digestInto($) { + if ((0, e.aoutput)($, this), this.finished) + throw new Error("digest() was already called"); + return this.writeInto($), this.destroy(), $; + } + digest() { + return this.digestInto(new Uint8Array(this.outputLen)); + } + destroy() { + this.destroyed = !0, (0, e.clean)(this.state); + } + _cloneInto($) { + const { blockLen: U, suffix: C, outputLen: W, rounds: J, enableXOF: ne } = this; + return $ || ($ = new k(U, C, W, ne, J)), $.state32.set(this.state32), $.pos = this.pos, $.posOut = this.posOut, $.finished = this.finished, $.rounds = J, $.suffix = C, $.outputLen = W, $.enableXOF = ne, $.destroyed = this.destroyed, $; + } + } + Hr.Keccak = k; + const N = (B, $, U) => (0, e.createHasher)(() => new k($, B, U)); + Hr.sha3_224 = N(6, 144, 224 / 8), Hr.sha3_256 = N(6, 136, 256 / 8), Hr.sha3_384 = N(6, 104, 384 / 8), Hr.sha3_512 = N(6, 72, 512 / 8), Hr.keccak_224 = N(1, 144, 224 / 8), Hr.keccak_256 = N(1, 136, 256 / 8), Hr.keccak_384 = N(1, 104, 384 / 8), Hr.keccak_512 = N(1, 72, 512 / 8); + const z = (B, $, U) => (0, e.createXOFer)((C = {}) => new k($, B, C.dkLen === void 0 ? U : C.dkLen, !0)); + return Hr.shake128 = z(31, 168, 128 / 8), Hr.shake256 = z(31, 136, 256 / 8), Hr; +} +var um, M_; +function CE() { + if (M_) return um; + M_ = 1; + const { keccak_256: t } = /* @__PURE__ */ oK(); + function e(x) { + return Buffer.allocUnsafe(x).fill(0); + } + function r(x) { + return x.toString(2).length; + } + function n(x, S) { + let R = x.toString(16); + R.length % 2 !== 0 && (R = "0" + R); + const D = R.match(/.{1,2}/g).map((k) => parseInt(k, 16)); + for (; D.length < S; ) + D.unshift(0); + return Buffer.from(D); + } + function i(x, S) { + const R = x < 0n; + let D; + if (R) { + const k = (1n << BigInt(S)) - 1n; + D = (~x & k) + 1n; + } else + D = x; + return D &= (1n << BigInt(S)) - 1n, D; + } + function s(x, S, R) { + const D = e(S); + return x = a(x), R ? x.length < S ? (x.copy(D), D) : x.slice(0, S) : x.length < S ? (x.copy(D, S - x.length), D) : x.slice(-S); + } + function o(x, S) { + return s(x, S, !0); + } + function a(x) { + if (!Buffer.isBuffer(x)) + if (Array.isArray(x)) + x = Buffer.from(x); + else if (typeof x == "string") + g(x) ? x = Buffer.from(h(v(x)), "hex") : x = Buffer.from(x); + else if (typeof x == "number") + x = intToBuffer(x); + else if (x == null) + x = Buffer.allocUnsafe(0); + else if (typeof x == "bigint") + x = n(x); + else if (x.toArray) + x = Buffer.from(x.toArray()); + else + throw new Error("invalid type"); + return x; + } + function f(x) { + return x = a(x), "0x" + x.toString("hex"); + } + function u(x, S) { + if (x = a(x), S || (S = 256), S !== 256) + throw new Error("unsupported"); + return Buffer.from(t(new Uint8Array(x))); + } + function h(x) { + return x.length % 2 ? "0" + x : x; + } + function g(x) { + return typeof x == "string" && x.match(/^0x[0-9A-Fa-f]*$/); + } + function v(x) { + return typeof x == "string" && x.startsWith("0x") ? x.slice(2) : x; + } + return um = { + zeros: e, + setLength: s, + setLengthRight: o, + isHexString: g, + stripHexPrefix: v, + toBuffer: a, + bufferToHex: f, + keccak: u, + bitLengthFromBigInt: r, + bufferBEFromBigInt: n, + twosFromBigInt: i + }, um; +} +var fm, I_; +function aK() { + if (I_) return fm; + I_ = 1; + const t = /* @__PURE__ */ CE(); + function e(v) { + return v.startsWith("int[") ? "int256" + v.slice(3) : v === "int" ? "int256" : v.startsWith("uint[") ? "uint256" + v.slice(4) : v === "uint" ? "uint256" : v.startsWith("fixed[") ? "fixed128x128" + v.slice(5) : v === "fixed" ? "fixed128x128" : v.startsWith("ufixed[") ? "ufixed128x128" + v.slice(6) : v === "ufixed" ? "ufixed128x128" : v; + } + function r(v) { + return Number.parseInt(/^\D+(\d+)$/.exec(v)[1], 10); + } + function n(v) { + var x = /^\D+(\d+)x(\d+)$/.exec(v); + return [Number.parseInt(x[1], 10), Number.parseInt(x[2], 10)]; + } + function i(v) { + var x = v.match(/(.*)\[(.*?)\]$/); + return x ? x[2] === "" ? "dynamic" : Number.parseInt(x[2], 10) : null; + } + function s(v) { + var x = typeof v; + if (x === "string" || x === "number") + return BigInt(v); + if (x === "bigint") + return v; + throw new Error("Argument is not a number"); + } + function o(v, x) { + var S, R, D, k; + if (v === "address") + return o("uint160", s(x)); + if (v === "bool") + return o("uint8", x ? 1 : 0); + if (v === "string") + return o("bytes", new Buffer(x, "utf8")); + if (f(v)) { + if (typeof x.length > "u") + throw new Error("Not an array?"); + if (S = i(v), S !== "dynamic" && S !== 0 && x.length > S) + throw new Error("Elements exceed array size: " + S); + D = [], v = v.slice(0, v.lastIndexOf("[")), typeof x == "string" && (x = JSON.parse(x)); + for (k in x) + D.push(o(v, x[k])); + if (S === "dynamic") { + var N = o("uint256", x.length); + D.unshift(N); + } + return Buffer.concat(D); + } else { + if (v === "bytes") + return x = new Buffer(x), D = Buffer.concat([o("uint256", x.length), x]), x.length % 32 !== 0 && (D = Buffer.concat([D, t.zeros(32 - x.length % 32)])), D; + if (v.startsWith("bytes")) { + if (S = r(v), S < 1 || S > 32) + throw new Error("Invalid bytes width: " + S); + return t.setLengthRight(x, 32); + } else if (v.startsWith("uint")) { + if (S = r(v), S % 8 || S < 8 || S > 256) + throw new Error("Invalid uint width: " + S); + R = s(x); + const z = t.bitLengthFromBigInt(R); + if (z > S) + throw new Error("Supplied uint exceeds width: " + S + " vs " + z); + if (R < 0) + throw new Error("Supplied uint is negative"); + return t.bufferBEFromBigInt(R, 32); + } else if (v.startsWith("int")) { + if (S = r(v), S % 8 || S < 8 || S > 256) + throw new Error("Invalid int width: " + S); + R = s(x); + const z = t.bitLengthFromBigInt(R); + if (z > S) + throw new Error("Supplied int exceeds width: " + S + " vs " + z); + const B = t.twosFromBigInt(R, 256); + return t.bufferBEFromBigInt(B, 32); + } else if (v.startsWith("ufixed")) { + if (S = n(v), R = s(x), R < 0) + throw new Error("Supplied ufixed is negative"); + return o("uint256", R * BigInt(2) ** BigInt(S[1])); + } else if (v.startsWith("fixed")) + return S = n(v), o("int256", s(x) * BigInt(2) ** BigInt(S[1])); + } + throw new Error("Unsupported or invalid type: " + v); + } + function a(v) { + return v === "string" || v === "bytes" || i(v) === "dynamic"; + } + function f(v) { + return v.lastIndexOf("]") === v.length - 1; + } + function u(v, x) { + var S = [], R = [], D = 32 * v.length; + for (var k in v) { + var N = e(v[k]), z = x[k], B = o(N, z); + a(N) ? (S.push(o("uint256", D)), R.push(B), D += B.length) : S.push(B); + } + return Buffer.concat(S.concat(R)); + } + function h(v, x) { + if (v.length !== x.length) + throw new Error("Number of types are not matching the values"); + for (var S, R, D = [], k = 0; k < v.length; k++) { + var N = e(v[k]), z = x[k]; + if (N === "bytes") + D.push(z); + else if (N === "string") + D.push(new Buffer(z, "utf8")); + else if (N === "bool") + D.push(new Buffer(z ? "01" : "00", "hex")); + else if (N === "address") + D.push(t.setLength(z, 20)); + else if (N.startsWith("bytes")) { + if (S = r(N), S < 1 || S > 32) + throw new Error("Invalid bytes width: " + S); + D.push(t.setLengthRight(z, S)); + } else if (N.startsWith("uint")) { + if (S = r(N), S % 8 || S < 8 || S > 256) + throw new Error("Invalid uint width: " + S); + R = s(z); + const B = t.bitLengthFromBigInt(R); + if (B > S) + throw new Error("Supplied uint exceeds width: " + S + " vs " + B); + D.push(t.bufferBEFromBigInt(R, S / 8)); + } else if (N.startsWith("int")) { + if (S = r(N), S % 8 || S < 8 || S > 256) + throw new Error("Invalid int width: " + S); + R = s(z); + const B = t.bitLengthFromBigInt(R); + if (B > S) + throw new Error("Supplied int exceeds width: " + S + " vs " + B); + const $ = t.twosFromBigInt(R, S); + D.push(t.bufferBEFromBigInt($, S / 8)); + } else + throw new Error("Unsupported or invalid type: " + N); + } + return Buffer.concat(D); + } + function g(v, x) { + return t.keccak(h(v, x)); + } + return fm = { + rawEncode: u, + solidityPack: h, + soliditySHA3: g + }, fm; +} +var lm, C_; +function cK() { + if (C_) return lm; + C_ = 1; + const t = /* @__PURE__ */ CE(), e = /* @__PURE__ */ aK(), r = { + type: "object", + properties: { + types: { + type: "object", + additionalProperties: { + type: "array", + items: { + type: "object", + properties: { + name: { type: "string" }, + type: { type: "string" } + }, + required: ["name", "type"] + } + } + }, + primaryType: { type: "string" }, + domain: { type: "object" }, + message: { type: "object" } + }, + required: ["types", "primaryType", "domain", "message"] + }, n = { + /** + * Encodes an object by encoding and concatenating each of its members + * + * @param {string} primaryType - Root type + * @param {Object} data - Object to encode + * @param {Object} types - Type definitions + * @returns {string} - Encoded representation of an object + */ + encodeData(s, o, a, f = !0) { + const u = ["bytes32"], h = [this.hashType(s, a)]; + if (f) { + const g = (v, x, S) => { + if (a[x] !== void 0) + return ["bytes32", S == null ? "0x0000000000000000000000000000000000000000000000000000000000000000" : t.keccak(this.encodeData(x, S, a, f))]; + if (S === void 0) + throw new Error(`missing value for field ${v} of type ${x}`); + if (x === "bytes") + return ["bytes32", t.keccak(S)]; + if (x === "string") + return typeof S == "string" && (S = Buffer.from(S, "utf8")), ["bytes32", t.keccak(S)]; + if (x.lastIndexOf("]") === x.length - 1) { + const R = x.slice(0, x.lastIndexOf("[")), D = S.map((k) => g(v, R, k)); + return ["bytes32", t.keccak(e.rawEncode( + D.map(([k]) => k), + D.map(([, k]) => k) + ))]; + } + return [x, S]; + }; + for (const v of a[s]) { + const [x, S] = g(v.name, v.type, o[v.name]); + u.push(x), h.push(S); + } + } else + for (const g of a[s]) { + let v = o[g.name]; + if (v !== void 0) + if (g.type === "bytes") + u.push("bytes32"), v = t.keccak(v), h.push(v); + else if (g.type === "string") + u.push("bytes32"), typeof v == "string" && (v = Buffer.from(v, "utf8")), v = t.keccak(v), h.push(v); + else if (a[g.type] !== void 0) + u.push("bytes32"), v = t.keccak(this.encodeData(g.type, v, a, f)), h.push(v); + else { + if (g.type.lastIndexOf("]") === g.type.length - 1) + throw new Error("Arrays currently unimplemented in encodeData"); + u.push(g.type), h.push(v); + } + } + return e.rawEncode(u, h); + }, + /** + * Encodes the type of an object by encoding a comma delimited list of its members + * + * @param {string} primaryType - Root type to encode + * @param {Object} types - Type definitions + * @returns {string} - Encoded representation of the type of an object + */ + encodeType(s, o) { + let a = "", f = this.findTypeDependencies(s, o).filter((u) => u !== s); + f = [s].concat(f.sort()); + for (const u of f) { + if (!o[u]) + throw new Error("No type definition specified: " + u); + a += u + "(" + o[u].map(({ name: g, type: v }) => v + " " + g).join(",") + ")"; + } + return a; + }, + /** + * Finds all types within a type definition object + * + * @param {string} primaryType - Root type + * @param {Object} types - Type definitions + * @param {Array} results - current set of accumulated types + * @returns {Array} - Set of all types found in the type definition + */ + findTypeDependencies(s, o, a = []) { + if (s = s.match(/^\w*/)[0], a.includes(s) || o[s] === void 0) + return a; + a.push(s); + for (const f of o[s]) + for (const u of this.findTypeDependencies(f.type, o, a)) + !a.includes(u) && a.push(u); + return a; + }, + /** + * Hashes an object + * + * @param {string} primaryType - Root type + * @param {Object} data - Object to hash + * @param {Object} types - Type definitions + * @returns {Buffer} - Hash of an object + */ + hashStruct(s, o, a, f = !0) { + return t.keccak(this.encodeData(s, o, a, f)); + }, + /** + * Hashes the type of an object + * + * @param {string} primaryType - Root type to hash + * @param {Object} types - Type definitions + * @returns {string} - Hash of an object + */ + hashType(s, o) { + return t.keccak(this.encodeType(s, o)); + }, + /** + * Removes properties from a message object that are not defined per EIP-712 + * + * @param {Object} data - typed message object + * @returns {Object} - typed message object with only allowed fields + */ + sanitizeData(s) { + const o = {}; + for (const a in r.properties) + s[a] && (o[a] = s[a]); + return o.types && (o.types = Object.assign({ EIP712Domain: [] }, o.types)), o; + }, + /** + * Returns the hash of a typed message as per EIP-712 for signing + * + * @param {Object} typedData - Types message data to sign + * @returns {string} - sha3 hash for signing + */ + hash(s, o = !0) { + const a = this.sanitizeData(s), f = [Buffer.from("1901", "hex")]; + return f.push(this.hashStruct("EIP712Domain", a.domain, a.types, o)), a.primaryType !== "EIP712Domain" && f.push(this.hashStruct(a.primaryType, a.message, a.types, o)), t.keccak(Buffer.concat(f)); + } + }; + lm = { + TYPED_MESSAGE_SCHEMA: r, + TypedDataUtils: n, + hashForSignTypedDataLegacy: function(s) { + return i(s.data); + }, + hashForSignTypedData_v3: function(s) { + return n.hash(s.data, !1); + }, + hashForSignTypedData_v4: function(s) { + return n.hash(s.data); + } + }; + function i(s) { + const o = new Error("Expect argument to be non-empty array"); + if (typeof s != "object" || !s.length) throw o; + const a = s.map(function(h) { + return h.type === "bytes" ? t.toBuffer(h.value) : h.value; + }), f = s.map(function(h) { + return h.type; + }), u = s.map(function(h) { + if (!h.name) throw o; + return h.type + " " + h.name; + }); + return e.soliditySHA3( + ["bytes32", "bytes32"], + [ + e.soliditySHA3(new Array(s.length).fill("string"), u), + e.soliditySHA3(f, a) + ] + ); + } + return lm; +} +var uK = /* @__PURE__ */ cK(); +const Ph = /* @__PURE__ */ Hi(uK), fK = "walletUsername", pv = "Addresses", lK = "AppVersion"; +function Ln(t) { + return t.errorMessage !== void 0; +} +class hK { + // @param secret hex representation of 32-byte secret + constructor(e) { + this.secret = e; + } + /** + * + * @param plainText string to be encrypted + * returns hex string representation of bytes in the order: initialization vector (iv), + * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes. Remaining bytes are the + * encrypted plainText. + */ + async encrypt(e) { + const r = this.secret; + if (r.length !== 64) + throw Error("secret must be 256 bits"); + const n = crypto.getRandomValues(new Uint8Array(12)), i = await crypto.subtle.importKey("raw", Vh(r), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), s = new TextEncoder(), o = await window.crypto.subtle.encrypt({ + name: "AES-GCM", + iv: n + }, i, s.encode(e)), a = 16, f = o.slice(o.byteLength - a), u = o.slice(0, o.byteLength - a), h = new Uint8Array(f), g = new Uint8Array(u), v = new Uint8Array([...n, ...h, ...g]); + return N1(v); + } + /** + * + * @param cipherText hex string representation of bytes in the order: initialization vector (iv), + * auth tag, encrypted plaintext. IV is 12 bytes. Auth tag is 16 bytes. + */ + async decrypt(e) { + const r = this.secret; + if (r.length !== 64) + throw Error("secret must be 256 bits"); + return new Promise((n, i) => { + (async function() { + const s = await crypto.subtle.importKey("raw", Vh(r), { name: "aes-gcm" }, !1, ["encrypt", "decrypt"]), o = Vh(e), a = o.slice(0, 12), f = o.slice(12, 28), u = o.slice(28), h = new Uint8Array([...u, ...f]), g = { + name: "AES-GCM", + iv: new Uint8Array(a) + }; + try { + const v = await window.crypto.subtle.decrypt(g, s, h), x = new TextDecoder(); + n(x.decode(v)); + } catch (v) { + i(v); + } + })(); + }); + } +} +class dK { + constructor(e, r, n) { + this.linkAPIUrl = e, this.sessionId = r; + const i = `${r}:${n}`; + this.auth = `Basic ${btoa(i)}`; + } + // mark unseen events as seen + async markUnseenEventsAsSeen(e) { + return Promise.all(e.map((r) => fetch(`${this.linkAPIUrl}/events/${r.eventId}/seen`, { + method: "POST", + headers: { + Authorization: this.auth + } + }))).catch((r) => console.error("Unabled to mark event as failed:", r)); + } + async fetchUnseenEvents() { + var e; + const r = await fetch(`${this.linkAPIUrl}/events?unseen=true`, { + headers: { + Authorization: this.auth + } + }); + if (r.ok) { + const { events: n, error: i } = await r.json(); + if (i) + throw new Error(`Check unseen events failed: ${i}`); + const s = (e = n?.filter((o) => o.event === "Web3Response").map((o) => ({ + type: "Event", + sessionId: this.sessionId, + eventId: o.id, + event: o.event, + data: o.data + }))) !== null && e !== void 0 ? e : []; + return this.markUnseenEventsAsSeen(s), s; + } + throw new Error(`Check unseen events failed: ${r.status}`); + } +} +var ro; +(function(t) { + t[t.DISCONNECTED = 0] = "DISCONNECTED", t[t.CONNECTING = 1] = "CONNECTING", t[t.CONNECTED = 2] = "CONNECTED"; +})(ro || (ro = {})); +class pK { + setConnectionStateListener(e) { + this.connectionStateListener = e; + } + setIncomingDataListener(e) { + this.incomingDataListener = e; + } + /** + * Constructor + * @param url WebSocket server URL + * @param [WebSocketClass] Custom WebSocket implementation + */ + constructor(e, r = WebSocket) { + this.WebSocketClass = r, this.webSocket = null, this.pendingData = [], this.url = e.replace(/^http/, "ws"); + } + /** + * Make a websocket connection + * @returns a Promise that resolves when connected + */ + async connect() { + if (this.webSocket) + throw new Error("webSocket object is not null"); + return new Promise((e, r) => { + var n; + let i; + try { + this.webSocket = i = new this.WebSocketClass(this.url); + } catch (s) { + r(s); + return; + } + (n = this.connectionStateListener) === null || n === void 0 || n.call(this, ro.CONNECTING), i.onclose = (s) => { + var o; + this.clearWebSocket(), r(new Error(`websocket error ${s.code}: ${s.reason}`)), (o = this.connectionStateListener) === null || o === void 0 || o.call(this, ro.DISCONNECTED); + }, i.onopen = (s) => { + var o; + e(), (o = this.connectionStateListener) === null || o === void 0 || o.call(this, ro.CONNECTED), this.pendingData.length > 0 && ([...this.pendingData].forEach((f) => this.sendData(f)), this.pendingData = []); + }, i.onmessage = (s) => { + var o, a; + if (s.data === "h") + (o = this.incomingDataListener) === null || o === void 0 || o.call(this, { + type: "Heartbeat" + }); + else + try { + const f = JSON.parse(s.data); + (a = this.incomingDataListener) === null || a === void 0 || a.call(this, f); + } catch { + } + }; + }); + } + /** + * Disconnect from server + */ + disconnect() { + var e; + const { webSocket: r } = this; + if (r) { + this.clearWebSocket(), (e = this.connectionStateListener) === null || e === void 0 || e.call(this, ro.DISCONNECTED), this.connectionStateListener = void 0, this.incomingDataListener = void 0; + try { + r.close(); + } catch { + } + } + } + /** + * Send data to server + * @param data text to send + */ + sendData(e) { + const { webSocket: r } = this; + if (!r) { + this.pendingData.push(e), this.connect(); + return; + } + r.send(e); + } + clearWebSocket() { + const { webSocket: e } = this; + e && (this.webSocket = null, e.onclose = null, e.onerror = null, e.onmessage = null, e.onopen = null); + } +} +const R_ = 1e4, gK = 6e4; +class mK { + /** + * Constructor + * @param session Session + * @param linkAPIUrl Coinbase Wallet link server URL + * @param listener WalletLinkConnectionUpdateListener + * @param [WebSocketClass] Custom WebSocket implementation + */ + constructor({ session: e, linkAPIUrl: r, listener: n }) { + this.destroyed = !1, this.lastHeartbeatResponse = 0, this.nextReqId = eo(1), this._connected = !1, this._linked = !1, this.shouldFetchUnseenEventsOnConnect = !1, this.requestResolutions = /* @__PURE__ */ new Map(), this.handleSessionMetadataUpdated = (s) => { + if (!s) + return; + (/* @__PURE__ */ new Map([ + ["__destroyed", this.handleDestroyed], + ["EthereumAddress", this.handleAccountUpdated], + ["WalletUsername", this.handleWalletUsernameUpdated], + ["AppVersion", this.handleAppVersionUpdated], + [ + "ChainId", + // ChainId and JsonRpcUrl are always updated together + (a) => s.JsonRpcUrl && this.handleChainUpdated(a, s.JsonRpcUrl) + ] + ])).forEach((a, f) => { + const u = s[f]; + u !== void 0 && a(u); + }); + }, this.handleDestroyed = (s) => { + var o; + s === "1" && ((o = this.listener) === null || o === void 0 || o.resetAndReload()); + }, this.handleAccountUpdated = async (s) => { + var o; + const a = await this.cipher.decrypt(s); + (o = this.listener) === null || o === void 0 || o.accountUpdated(a); + }, this.handleMetadataUpdated = async (s, o) => { + var a; + const f = await this.cipher.decrypt(o); + (a = this.listener) === null || a === void 0 || a.metadataUpdated(s, f); + }, this.handleWalletUsernameUpdated = async (s) => { + this.handleMetadataUpdated(fK, s); + }, this.handleAppVersionUpdated = async (s) => { + this.handleMetadataUpdated(lK, s); + }, this.handleChainUpdated = async (s, o) => { + var a; + const f = await this.cipher.decrypt(s), u = await this.cipher.decrypt(o); + (a = this.listener) === null || a === void 0 || a.chainUpdated(f, u); + }, this.session = e, this.cipher = new hK(e.secret), this.listener = n; + const i = new pK(`${r}/rpc`, WebSocket); + i.setConnectionStateListener(async (s) => { + let o = !1; + switch (s) { + case ro.DISCONNECTED: + if (!this.destroyed) { + const a = async () => { + await new Promise((f) => setTimeout(f, 5e3)), this.destroyed || i.connect().catch(() => { + a(); + }); + }; + a(); + } + break; + case ro.CONNECTED: + o = await this.handleConnected(), this.updateLastHeartbeat(), setInterval(() => { + this.heartbeat(); + }, R_), this.shouldFetchUnseenEventsOnConnect && this.fetchUnseenEventsAPI(); + break; + case ro.CONNECTING: + break; + } + this.connected !== o && (this.connected = o); + }), i.setIncomingDataListener((s) => { + var o; + switch (s.type) { + // handle server's heartbeat responses + case "Heartbeat": + this.updateLastHeartbeat(); + return; + // handle link status updates + case "IsLinkedOK": + case "Linked": { + const a = s.type === "IsLinkedOK" ? s.linked : void 0; + this.linked = a || s.onlineGuests > 0; + break; + } + // handle session config updates + case "GetSessionConfigOK": + case "SessionConfigUpdated": { + this.handleSessionMetadataUpdated(s.metadata); + break; + } + case "Event": { + this.handleIncomingEvent(s); + break; + } + } + s.id !== void 0 && ((o = this.requestResolutions.get(s.id)) === null || o === void 0 || o(s)); + }), this.ws = i, this.http = new dK(r, e.id, e.key); + } + /** + * Make a connection to the server + */ + connect() { + if (this.destroyed) + throw new Error("instance is destroyed"); + this.ws.connect(); + } + /** + * Terminate connection, and mark as destroyed. To reconnect, create a new + * instance of WalletSDKConnection + */ + async destroy() { + this.destroyed || (await this.makeRequest({ + type: "SetSessionConfig", + id: eo(this.nextReqId++), + sessionId: this.session.id, + metadata: { __destroyed: "1" } + }, { timeout: 1e3 }), this.destroyed = !0, this.ws.disconnect(), this.listener = void 0); + } + get connected() { + return this._connected; + } + set connected(e) { + this._connected = e; + } + get linked() { + return this._linked; + } + set linked(e) { + var r, n; + this._linked = e, e && ((r = this.onceLinked) === null || r === void 0 || r.call(this)), (n = this.listener) === null || n === void 0 || n.linkedUpdated(e); + } + setOnceLinked(e) { + return new Promise((r) => { + this.linked ? e().then(r) : this.onceLinked = () => { + e().then(r), this.onceLinked = void 0; + }; + }); + } + async handleIncomingEvent(e) { + var r; + if (e.type !== "Event" || e.event !== "Web3Response") + return; + const n = await this.cipher.decrypt(e.data), i = JSON.parse(n); + if (i.type !== "WEB3_RESPONSE") + return; + const { id: s, response: o } = i; + (r = this.listener) === null || r === void 0 || r.handleWeb3ResponseMessage(s, o); + } + async checkUnseenEvents() { + if (!this.connected) { + this.shouldFetchUnseenEventsOnConnect = !0; + return; + } + await new Promise((e) => setTimeout(e, 250)); + try { + await this.fetchUnseenEventsAPI(); + } catch (e) { + console.error("Unable to check for unseen events", e); + } + } + async fetchUnseenEventsAPI() { + this.shouldFetchUnseenEventsOnConnect = !1, (await this.http.fetchUnseenEvents()).forEach((r) => this.handleIncomingEvent(r)); + } + /** + * Publish an event and emit event ID when successful + * @param event event name + * @param unencryptedData unencrypted event data + * @param callWebhook whether the webhook should be invoked + * @returns a Promise that emits event ID when successful + */ + async publishEvent(e, r, n = !1) { + const i = await this.cipher.encrypt(JSON.stringify(Object.assign(Object.assign({}, r), { origin: location.origin, location: location.href, relaySource: "coinbaseWalletExtension" in window && window.coinbaseWalletExtension ? "injected_sdk" : "sdk" }))), s = { + type: "PublishEvent", + id: eo(this.nextReqId++), + sessionId: this.session.id, + event: e, + data: i, + callWebhook: n + }; + return this.setOnceLinked(async () => { + const o = await this.makeRequest(s); + if (o.type === "Fail") + throw new Error(o.error || "failed to publish event"); + return o.eventId; + }); + } + sendData(e) { + this.ws.sendData(JSON.stringify(e)); + } + updateLastHeartbeat() { + this.lastHeartbeatResponse = Date.now(); + } + heartbeat() { + if (Date.now() - this.lastHeartbeatResponse > R_ * 2) { + this.ws.disconnect(); + return; + } + try { + this.ws.sendData("h"); + } catch { + } + } + async makeRequest(e, r = { timeout: gK }) { + const n = e.id; + this.sendData(e); + let i; + return Promise.race([ + new Promise((s, o) => { + i = window.setTimeout(() => { + o(new Error(`request ${n} timed out`)); + }, r.timeout); + }), + new Promise((s) => { + this.requestResolutions.set(n, (o) => { + clearTimeout(i), s(o), this.requestResolutions.delete(n); + }); + }) + ]); + } + async handleConnected() { + return (await this.makeRequest({ + type: "HostSession", + id: eo(this.nextReqId++), + sessionId: this.session.id, + sessionKey: this.session.key + })).type === "Fail" ? !1 : (this.sendData({ + type: "IsLinked", + id: eo(this.nextReqId++), + sessionId: this.session.id + }), this.sendData({ + type: "GetSessionConfig", + id: eo(this.nextReqId++), + sessionId: this.session.id + }), !0); + } +} +class vK { + constructor() { + this._nextRequestId = 0, this.callbacks = /* @__PURE__ */ new Map(); + } + makeRequestId() { + this._nextRequestId = (this._nextRequestId + 1) % 2147483647; + const e = this._nextRequestId, r = EE(e.toString(16)); + return this.callbacks.get(r) && this.callbacks.delete(r), e; + } +} +const T_ = "session:id", D_ = "session:secret", O_ = "session:linked"; +class kc { + constructor(e, r, n, i = !1) { + this.storage = e, this.id = r, this.secret = n, this.key = QT(O4(`${r}, ${n} WalletLink`)), this._linked = !!i; + } + static create(e) { + const r = Ea(16), n = Ea(32); + return new kc(e, r, n).save(); + } + static load(e) { + const r = e.getItem(T_), n = e.getItem(O_), i = e.getItem(D_); + return r && i ? new kc(e, r, i, n === "1") : null; + } + get linked() { + return this._linked; + } + set linked(e) { + this._linked = e, this.persistLinked(); + } + save() { + return this.storage.setItem(T_, this.id), this.storage.setItem(D_, this.secret), this.persistLinked(), this; + } + persistLinked() { + this.storage.setItem(O_, this._linked ? "1" : "0"); + } +} +function bK() { + try { + return window.frameElement !== null; + } catch { + return !1; + } +} +function yK() { + try { + return bK() && window.top ? window.top.location : window.location; + } catch { + return window.location; + } +} +function wK() { + var t; + return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test((t = window?.navigator) === null || t === void 0 ? void 0 : t.userAgent); +} +function RE() { + var t, e; + return (e = (t = window?.matchMedia) === null || t === void 0 ? void 0 : t.call(window, "(prefers-color-scheme: dark)").matches) !== null && e !== void 0 ? e : !1; +} +const xK = '@namespace svg "http://www.w3.org/2000/svg";.-cbwsdk-css-reset,.-cbwsdk-css-reset *{animation:none;animation-delay:0;animation-direction:normal;animation-duration:0;animation-fill-mode:none;animation-iteration-count:1;animation-name:none;animation-play-state:running;animation-timing-function:ease;backface-visibility:visible;background:0;background-attachment:scroll;background-clip:border-box;background-color:rgba(0,0,0,0);background-image:none;background-origin:padding-box;background-position:0 0;background-position-x:0;background-position-y:0;background-repeat:repeat;background-size:auto auto;border:0;border-style:none;border-width:medium;border-color:inherit;border-bottom:0;border-bottom-color:inherit;border-bottom-left-radius:0;border-bottom-right-radius:0;border-bottom-style:none;border-bottom-width:medium;border-collapse:separate;border-image:none;border-left:0;border-left-color:inherit;border-left-style:none;border-left-width:medium;border-radius:0;border-right:0;border-right-color:inherit;border-right-style:none;border-right-width:medium;border-spacing:0;border-top:0;border-top-color:inherit;border-top-left-radius:0;border-top-right-radius:0;border-top-style:none;border-top-width:medium;box-shadow:none;box-sizing:border-box;caption-side:top;clear:none;clip:auto;color:inherit;columns:auto;column-count:auto;column-fill:balance;column-gap:normal;column-rule:medium none currentColor;column-rule-color:currentColor;column-rule-style:none;column-rule-width:none;column-span:1;column-width:auto;counter-increment:none;counter-reset:none;direction:ltr;empty-cells:show;float:none;font:normal;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;height:auto;hyphens:none;letter-spacing:normal;line-height:normal;list-style:none;list-style-image:none;list-style-position:outside;list-style-type:disc;margin:0;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;opacity:1;orphans:0;outline:0;outline-color:invert;outline-style:none;outline-width:medium;overflow:visible;overflow-x:visible;overflow-y:visible;padding:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;page-break-after:auto;page-break-before:auto;page-break-inside:auto;perspective:none;perspective-origin:50% 50%;pointer-events:auto;position:static;quotes:"\\201C" "\\201D" "\\2018" "\\2019";tab-size:8;table-layout:auto;text-align:inherit;text-align-last:auto;text-decoration:none;text-decoration-color:inherit;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-shadow:none;text-transform:none;transform:none;transform-style:flat;transition:none;transition-delay:0s;transition-duration:0s;transition-property:none;transition-timing-function:ease;unicode-bidi:normal;vertical-align:baseline;visibility:visible;white-space:normal;widows:0;word-spacing:normal;z-index:auto}.-cbwsdk-css-reset strong{font-weight:bold}.-cbwsdk-css-reset *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;line-height:1}.-cbwsdk-css-reset [class*=container]{margin:0;padding:0}.-cbwsdk-css-reset style{display:none}'; +function TE() { + const t = document.createElement("style"); + t.type = "text/css", t.appendChild(document.createTextNode(xK)), document.documentElement.appendChild(t); +} +function DE(t) { + var e, r, n = ""; + if (typeof t == "string" || typeof t == "number") n += t; + else if (typeof t == "object") if (Array.isArray(t)) for (e = 0; e < t.length; e++) t[e] && (r = DE(t[e])) && (n && (n += " "), n += r); + else for (e in t) t[e] && (n && (n += " "), n += e); + return n; +} +function of() { + for (var t, e, r = 0, n = ""; r < arguments.length; ) (t = arguments[r++]) && (e = DE(t)) && (n && (n += " "), n += e); + return n; +} +var c0, Jr, OE, Sa, N_, NE, gv, LE, $1, mv, vv, Bf = {}, kE = [], _K = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, B1 = Array.isArray; +function Fo(t, e) { + for (var r in e) t[r] = e[r]; + return t; +} +function F1(t) { + t && t.parentNode && t.parentNode.removeChild(t); +} +function Lr(t, e, r) { + var n, i, s, o = {}; + for (s in e) s == "key" ? n = e[s] : s == "ref" ? i = e[s] : o[s] = e[s]; + if (arguments.length > 2 && (o.children = arguments.length > 3 ? c0.call(arguments, 2) : r), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) o[s] === void 0 && (o[s] = t.defaultProps[s]); + return Gh(t, o, n, i, null); +} +function Gh(t, e, r, n, i) { + var s = { type: t, props: e, key: r, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++OE, __i: -1, __u: 0 }; + return i == null && Jr.vnode != null && Jr.vnode(s), s; +} +function fl(t) { + return t.children; +} +function Yh(t, e) { + this.props = t, this.context = e; +} +function qc(t, e) { + if (e == null) return t.__ ? qc(t.__, t.__i + 1) : null; + for (var r; e < t.__k.length; e++) if ((r = t.__k[e]) != null && r.__e != null) return r.__e; + return typeof t.type == "function" ? qc(t) : null; +} +function $E(t) { + var e, r; + if ((t = t.__) != null && t.__c != null) { + for (t.__e = t.__c.base = null, e = 0; e < t.__k.length; e++) if ((r = t.__k[e]) != null && r.__e != null) { + t.__e = t.__c.base = r.__e; + break; + } + return $E(t); + } +} +function L_(t) { + (!t.__d && (t.__d = !0) && Sa.push(t) && !Sd.__r++ || N_ !== Jr.debounceRendering) && ((N_ = Jr.debounceRendering) || NE)(Sd); +} +function Sd() { + var t, e, r, n, i, s, o, a; + for (Sa.sort(gv); t = Sa.shift(); ) t.__d && (e = Sa.length, n = void 0, s = (i = (r = t).__v).__e, o = [], a = [], r.__P && ((n = Fo({}, i)).__v = i.__v + 1, Jr.vnode && Jr.vnode(n), j1(r.__P, n, i, r.__n, r.__P.namespaceURI, 32 & i.__u ? [s] : null, o, s ?? qc(i), !!(32 & i.__u), a), n.__v = i.__v, n.__.__k[n.__i] = n, jE(o, n, a), n.__e != s && $E(n)), Sa.length > e && Sa.sort(gv)); + Sd.__r = 0; +} +function BE(t, e, r, n, i, s, o, a, f, u, h) { + var g, v, x, S, R, D, k = n && n.__k || kE, N = e.length; + for (f = EK(r, e, k, f), g = 0; g < N; g++) (x = r.__k[g]) != null && (v = x.__i === -1 ? Bf : k[x.__i] || Bf, x.__i = g, D = j1(t, x, v, i, s, o, a, f, u, h), S = x.__e, x.ref && v.ref != x.ref && (v.ref && U1(v.ref, null, x), h.push(x.ref, x.__c || S, x)), R == null && S != null && (R = S), 4 & x.__u || v.__k === x.__k ? f = FE(x, f, t) : typeof x.type == "function" && D !== void 0 ? f = D : S && (f = S.nextSibling), x.__u &= -7); + return r.__e = R, f; +} +function EK(t, e, r, n) { + var i, s, o, a, f, u = e.length, h = r.length, g = h, v = 0; + for (t.__k = [], i = 0; i < u; i++) (s = e[i]) != null && typeof s != "boolean" && typeof s != "function" ? (a = i + v, (s = t.__k[i] = typeof s == "string" || typeof s == "number" || typeof s == "bigint" || s.constructor == String ? Gh(null, s, null, null, null) : B1(s) ? Gh(fl, { children: s }, null, null, null) : s.constructor === void 0 && s.__b > 0 ? Gh(s.type, s.props, s.key, s.ref ? s.ref : null, s.__v) : s).__ = t, s.__b = t.__b + 1, o = null, (f = s.__i = SK(s, r, a, g)) !== -1 && (g--, (o = r[f]) && (o.__u |= 2)), o == null || o.__v === null ? (f == -1 && v--, typeof s.type != "function" && (s.__u |= 4)) : f !== a && (f == a - 1 ? v-- : f == a + 1 ? v++ : (f > a ? v-- : v++, s.__u |= 4))) : s = t.__k[i] = null; + if (g) for (i = 0; i < h; i++) (o = r[i]) != null && (2 & o.__u) == 0 && (o.__e == n && (n = qc(o)), UE(o, o)); + return n; +} +function FE(t, e, r) { + var n, i; + if (typeof t.type == "function") { + for (n = t.__k, i = 0; n && i < n.length; i++) n[i] && (n[i].__ = t, e = FE(n[i], e, r)); + return e; + } + t.__e != e && (e && t.type && !r.contains(e) && (e = qc(t)), r.insertBefore(t.__e, e || null), e = t.__e); + do + e = e && e.nextSibling; + while (e != null && e.nodeType === 8); + return e; +} +function SK(t, e, r, n) { + var i = t.key, s = t.type, o = r - 1, a = r + 1, f = e[r]; + if (f === null || f && i == f.key && s === f.type && (2 & f.__u) == 0) return r; + if ((typeof s != "function" || s === fl || i) && n > (f != null && (2 & f.__u) == 0 ? 1 : 0)) for (; o >= 0 || a < e.length; ) { + if (o >= 0) { + if ((f = e[o]) && (2 & f.__u) == 0 && i == f.key && s === f.type) return o; + o--; + } + if (a < e.length) { + if ((f = e[a]) && (2 & f.__u) == 0 && i == f.key && s === f.type) return a; + a++; + } + } + return -1; +} +function k_(t, e, r) { + e[0] === "-" ? t.setProperty(e, r ?? "") : t[e] = r == null ? "" : typeof r != "number" || _K.test(e) ? r : r + "px"; +} +function Mh(t, e, r, n, i) { + var s; + e: if (e === "style") if (typeof r == "string") t.style.cssText = r; + else { + if (typeof n == "string" && (t.style.cssText = n = ""), n) for (e in n) r && e in r || k_(t.style, e, ""); + if (r) for (e in r) n && r[e] === n[e] || k_(t.style, e, r[e]); + } + else if (e[0] === "o" && e[1] === "n") s = e !== (e = e.replace(LE, "$1")), e = e.toLowerCase() in t || e === "onFocusOut" || e === "onFocusIn" ? e.toLowerCase().slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + s] = r, r ? n ? r.u = n.u : (r.u = $1, t.addEventListener(e, s ? vv : mv, s)) : t.removeEventListener(e, s ? vv : mv, s); + else { + if (i == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s"); + else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try { + t[e] = r ?? ""; + break e; + } catch { + } + typeof r == "function" || (r == null || r === !1 && e[4] !== "-" ? t.removeAttribute(e) : t.setAttribute(e, e == "popover" && r == 1 ? "" : r)); + } +} +function $_(t) { + return function(e) { + if (this.l) { + var r = this.l[e.type + t]; + if (e.t == null) e.t = $1++; + else if (e.t < r.u) return; + return r(Jr.event ? Jr.event(e) : e); + } + }; +} +function j1(t, e, r, n, i, s, o, a, f, u) { + var h, g, v, x, S, R, D, k, N, z, B, $, U, C, W, J, ne, K = e.type; + if (e.constructor !== void 0) return null; + 128 & r.__u && (f = !!(32 & r.__u), s = [a = e.__e = r.__e]), (h = Jr.__b) && h(e); + e: if (typeof K == "function") try { + if (k = e.props, N = "prototype" in K && K.prototype.render, z = (h = K.contextType) && n[h.__c], B = h ? z ? z.props.value : h.__ : n, r.__c ? D = (g = e.__c = r.__c).__ = g.__E : (N ? e.__c = g = new K(k, B) : (e.__c = g = new Yh(k, B), g.constructor = K, g.render = PK), z && z.sub(g), g.props = k, g.state || (g.state = {}), g.context = B, g.__n = n, v = g.__d = !0, g.__h = [], g._sb = []), N && g.__s == null && (g.__s = g.state), N && K.getDerivedStateFromProps != null && (g.__s == g.state && (g.__s = Fo({}, g.__s)), Fo(g.__s, K.getDerivedStateFromProps(k, g.__s))), x = g.props, S = g.state, g.__v = e, v) N && K.getDerivedStateFromProps == null && g.componentWillMount != null && g.componentWillMount(), N && g.componentDidMount != null && g.__h.push(g.componentDidMount); + else { + if (N && K.getDerivedStateFromProps == null && k !== x && g.componentWillReceiveProps != null && g.componentWillReceiveProps(k, B), !g.__e && (g.shouldComponentUpdate != null && g.shouldComponentUpdate(k, g.__s, B) === !1 || e.__v === r.__v)) { + for (e.__v !== r.__v && (g.props = k, g.state = g.__s, g.__d = !1), e.__e = r.__e, e.__k = r.__k, e.__k.some(function(E) { + E && (E.__ = e); + }), $ = 0; $ < g._sb.length; $++) g.__h.push(g._sb[$]); + g._sb = [], g.__h.length && o.push(g); + break e; + } + g.componentWillUpdate != null && g.componentWillUpdate(k, g.__s, B), N && g.componentDidUpdate != null && g.__h.push(function() { + g.componentDidUpdate(x, S, R); + }); + } + if (g.context = B, g.props = k, g.__P = t, g.__e = !1, U = Jr.__r, C = 0, N) { + for (g.state = g.__s, g.__d = !1, U && U(e), h = g.render(g.props, g.state, g.context), W = 0; W < g._sb.length; W++) g.__h.push(g._sb[W]); + g._sb = []; + } else do + g.__d = !1, U && U(e), h = g.render(g.props, g.state, g.context), g.state = g.__s; + while (g.__d && ++C < 25); + g.state = g.__s, g.getChildContext != null && (n = Fo(Fo({}, n), g.getChildContext())), N && !v && g.getSnapshotBeforeUpdate != null && (R = g.getSnapshotBeforeUpdate(x, S)), a = BE(t, B1(J = h != null && h.type === fl && h.key == null ? h.props.children : h) ? J : [J], e, r, n, i, s, o, a, f, u), g.base = e.__e, e.__u &= -161, g.__h.length && o.push(g), D && (g.__E = g.__ = null); + } catch (E) { + if (e.__v = null, f || s != null) if (E.then) { + for (e.__u |= f ? 160 : 128; a && a.nodeType === 8 && a.nextSibling; ) a = a.nextSibling; + s[s.indexOf(a)] = null, e.__e = a; + } else for (ne = s.length; ne--; ) F1(s[ne]); + else e.__e = r.__e, e.__k = r.__k; + Jr.__e(E, e, r); + } + else s == null && e.__v === r.__v ? (e.__k = r.__k, e.__e = r.__e) : a = e.__e = AK(r.__e, e, r, n, i, s, o, f, u); + return (h = Jr.diffed) && h(e), 128 & e.__u ? void 0 : a; +} +function jE(t, e, r) { + for (var n = 0; n < r.length; n++) U1(r[n], r[++n], r[++n]); + Jr.__c && Jr.__c(e, t), t.some(function(i) { + try { + t = i.__h, i.__h = [], t.some(function(s) { + s.call(i); + }); + } catch (s) { + Jr.__e(s, i.__v); + } + }); +} +function AK(t, e, r, n, i, s, o, a, f) { + var u, h, g, v, x, S, R, D = r.props, k = e.props, N = e.type; + if (N === "svg" ? i = "http://www.w3.org/2000/svg" : N === "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) { + for (u = 0; u < s.length; u++) if ((x = s[u]) && "setAttribute" in x == !!N && (N ? x.localName === N : x.nodeType === 3)) { + t = x, s[u] = null; + break; + } + } + if (t == null) { + if (N === null) return document.createTextNode(k); + t = document.createElementNS(i, N, k.is && k), a && (Jr.__m && Jr.__m(e, s), a = !1), s = null; + } + if (N === null) D === k || a && t.data === k || (t.data = k); + else { + if (s = s && c0.call(t.childNodes), D = r.props || Bf, !a && s != null) for (D = {}, u = 0; u < t.attributes.length; u++) D[(x = t.attributes[u]).name] = x.value; + for (u in D) if (x = D[u], u != "children") { + if (u == "dangerouslySetInnerHTML") g = x; + else if (!(u in k)) { + if (u == "value" && "defaultValue" in k || u == "checked" && "defaultChecked" in k) continue; + Mh(t, u, null, x, i); + } + } + for (u in k) x = k[u], u == "children" ? v = x : u == "dangerouslySetInnerHTML" ? h = x : u == "value" ? S = x : u == "checked" ? R = x : a && typeof x != "function" || D[u] === x || Mh(t, u, x, D[u], i); + if (h) a || g && (h.__html === g.__html || h.__html === t.innerHTML) || (t.innerHTML = h.__html), e.__k = []; + else if (g && (t.innerHTML = ""), BE(t, B1(v) ? v : [v], e, r, n, N === "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, o, s ? s[0] : r.__k && qc(r, 0), a, f), s != null) for (u = s.length; u--; ) F1(s[u]); + a || (u = "value", N === "progress" && S == null ? t.removeAttribute("value") : S !== void 0 && (S !== t[u] || N === "progress" && !S || N === "option" && S !== D[u]) && Mh(t, u, S, D[u], i), u = "checked", R !== void 0 && R !== t[u] && Mh(t, u, R, D[u], i)); + } + return t; +} +function U1(t, e, r) { + try { + if (typeof t == "function") { + var n = typeof t.__u == "function"; + n && t.__u(), n && e == null || (t.__u = t(e)); + } else t.current = e; + } catch (i) { + Jr.__e(i, r); + } +} +function UE(t, e, r) { + var n, i; + if (Jr.unmount && Jr.unmount(t), (n = t.ref) && (n.current && n.current !== t.__e || U1(n, null, e)), (n = t.__c) != null) { + if (n.componentWillUnmount) try { + n.componentWillUnmount(); + } catch (s) { + Jr.__e(s, e); + } + n.base = n.__P = null; + } + if (n = t.__k) for (i = 0; i < n.length; i++) n[i] && UE(n[i], e, r || typeof t.type != "function"); + r || F1(t.__e), t.__c = t.__ = t.__e = void 0; +} +function PK(t, e, r) { + return this.constructor(t, r); +} +function bv(t, e, r) { + var n, i, s, o; + e === document && (e = document.documentElement), Jr.__ && Jr.__(t, e), i = (n = !1) ? null : e.__k, s = [], o = [], j1(e, t = e.__k = Lr(fl, null, [t]), i || Bf, Bf, e.namespaceURI, i ? null : e.firstChild ? c0.call(e.childNodes) : null, s, i ? i.__e : e.firstChild, n, o), jE(s, t, o); +} +c0 = kE.slice, Jr = { __e: function(t, e, r, n) { + for (var i, s, o; e = e.__; ) if ((i = e.__c) && !i.__) try { + if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(t, n || {}), o = i.__d), o) return i.__E = i; + } catch (a) { + t = a; + } + throw t; +} }, OE = 0, Yh.prototype.setState = function(t, e) { + var r; + r = this.__s != null && this.__s !== this.state ? this.__s : this.__s = Fo({}, this.state), typeof t == "function" && (t = t(Fo({}, r), this.props)), t && Fo(r, t), t != null && this.__v && (e && this._sb.push(e), L_(this)); +}, Yh.prototype.forceUpdate = function(t) { + this.__v && (this.__e = !0, t && this.__h.push(t), L_(this)); +}, Yh.prototype.render = fl, Sa = [], NE = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, gv = function(t, e) { + return t.__v.__b - e.__v.__b; +}, Sd.__r = 0, LE = /(PointerCapture)$|Capture$/i, $1 = 0, mv = $_(!1), vv = $_(!0); +var Ad, dn, hm, B_, yv = 0, qE = [], vn = Jr, F_ = vn.__b, j_ = vn.__r, U_ = vn.diffed, q_ = vn.__c, z_ = vn.unmount, H_ = vn.__; +function zE(t, e) { + vn.__h && vn.__h(dn, t, yv || e), yv = 0; + var r = dn.__H || (dn.__H = { __: [], __h: [] }); + return t >= r.__.length && r.__.push({}), r.__[t]; +} +function W_(t) { + return yv = 1, MK(HE, t); +} +function MK(t, e, r) { + var n = zE(Ad++, 2); + if (n.t = t, !n.__c && (n.__ = [HE(void 0, e), function(a) { + var f = n.__N ? n.__N[0] : n.__[0], u = n.t(f, a); + f !== u && (n.__N = [u, n.__[1]], n.__c.setState({})); + }], n.__c = dn, !dn.u)) { + var i = function(a, f, u) { + if (!n.__c.__H) return !0; + var h = n.__c.__H.__.filter(function(v) { + return !!v.__c; + }); + if (h.every(function(v) { + return !v.__N; + })) return !s || s.call(this, a, f, u); + var g = n.__c.props !== a; + return h.forEach(function(v) { + if (v.__N) { + var x = v.__[0]; + v.__ = v.__N, v.__N = void 0, x !== v.__[0] && (g = !0); + } + }), s && s.call(this, a, f, u) || g; + }; + dn.u = !0; + var s = dn.shouldComponentUpdate, o = dn.componentWillUpdate; + dn.componentWillUpdate = function(a, f, u) { + if (this.__e) { + var h = s; + s = void 0, i(a, f, u), s = h; + } + o && o.call(this, a, f, u); + }, dn.shouldComponentUpdate = i; + } + return n.__N || n.__; +} +function IK(t, e) { + var r = zE(Ad++, 3); + !vn.__s && TK(r.__H, e) && (r.__ = t, r.i = e, dn.__H.__h.push(r)); +} +function CK() { + for (var t; t = qE.shift(); ) if (t.__P && t.__H) try { + t.__H.__h.forEach(Jh), t.__H.__h.forEach(wv), t.__H.__h = []; + } catch (e) { + t.__H.__h = [], vn.__e(e, t.__v); + } +} +vn.__b = function(t) { + dn = null, F_ && F_(t); +}, vn.__ = function(t, e) { + t && e.__k && e.__k.__m && (t.__m = e.__k.__m), H_ && H_(t, e); +}, vn.__r = function(t) { + j_ && j_(t), Ad = 0; + var e = (dn = t.__c).__H; + e && (hm === dn ? (e.__h = [], dn.__h = [], e.__.forEach(function(r) { + r.__N && (r.__ = r.__N), r.i = r.__N = void 0; + })) : (e.__h.forEach(Jh), e.__h.forEach(wv), e.__h = [], Ad = 0)), hm = dn; +}, vn.diffed = function(t) { + U_ && U_(t); + var e = t.__c; + e && e.__H && (e.__H.__h.length && (qE.push(e) !== 1 && B_ === vn.requestAnimationFrame || ((B_ = vn.requestAnimationFrame) || RK)(CK)), e.__H.__.forEach(function(r) { + r.i && (r.__H = r.i), r.i = void 0; + })), hm = dn = null; +}, vn.__c = function(t, e) { + e.some(function(r) { + try { + r.__h.forEach(Jh), r.__h = r.__h.filter(function(n) { + return !n.__ || wv(n); + }); + } catch (n) { + e.some(function(i) { + i.__h && (i.__h = []); + }), e = [], vn.__e(n, r.__v); + } + }), q_ && q_(t, e); +}, vn.unmount = function(t) { + z_ && z_(t); + var e, r = t.__c; + r && r.__H && (r.__H.__.forEach(function(n) { + try { + Jh(n); + } catch (i) { + e = i; + } + }), r.__H = void 0, e && vn.__e(e, r.__v)); +}; +var K_ = typeof requestAnimationFrame == "function"; +function RK(t) { + var e, r = function() { + clearTimeout(n), K_ && cancelAnimationFrame(e), setTimeout(t); + }, n = setTimeout(r, 100); + K_ && (e = requestAnimationFrame(r)); +} +function Jh(t) { + var e = dn, r = t.__c; + typeof r == "function" && (t.__c = void 0, r()), dn = e; +} +function wv(t) { + var e = dn; + t.__c = t.__(), dn = e; +} +function TK(t, e) { + return !t || t.length !== e.length || e.some(function(r, n) { + return r !== t[n]; + }); +} +function HE(t, e) { + return typeof e == "function" ? e(t) : e; +} +const DK = ".-cbwsdk-css-reset .-gear-container{margin-left:16px !important;margin-right:9px !important;display:flex;align-items:center;justify-content:center;width:24px;height:24px;transition:opacity .25s}.-cbwsdk-css-reset .-gear-container *{user-select:none}.-cbwsdk-css-reset .-gear-container svg{opacity:0;position:absolute}.-cbwsdk-css-reset .-gear-icon{height:12px;width:12px;z-index:10000}.-cbwsdk-css-reset .-cbwsdk-snackbar{align-items:flex-end;display:flex;flex-direction:column;position:fixed;right:0;top:0;z-index:2147483647}.-cbwsdk-css-reset .-cbwsdk-snackbar *{user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance{display:flex;flex-direction:column;margin:8px 16px 0 16px;overflow:visible;text-align:left;transform:translateX(0);transition:opacity .25s,transform .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header:hover .-gear-container svg{opacity:1}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header{display:flex;align-items:center;background:#fff;overflow:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-cblogo{margin:8px 8px 8px 8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-header-message{color:#000;font-size:13px;line-height:1.5;user-select:none}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu{background:#fff;transition:opacity .25s ease-in-out,transform .25s linear,visibility 0s;visibility:hidden;border:1px solid #e7ebee;box-sizing:border-box;border-radius:8px;opacity:0;flex-direction:column;padding-left:8px;padding-right:8px}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:last-child{margin-bottom:8px !important}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover{background:#f5f7f8;border-radius:6px;transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover span{color:#050f19;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item:hover svg path{fill:#000;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item{visibility:inherit;height:35px;margin-top:8px;margin-bottom:0;display:flex;flex-direction:row;align-items:center;padding:8px;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item *{visibility:inherit;cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover{background:rgba(223,95,103,.2);transition:background .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover *{cursor:pointer}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover svg path{fill:#df5f67;transition:fill .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-is-red:hover span{color:#df5f67;transition:color .25s}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-menu-item-info{color:#aaa;font-size:13px;margin:0 8px 0 32px;position:absolute}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-hidden{opacity:0;text-align:left;transform:translateX(25%);transition:opacity .5s linear}.-cbwsdk-css-reset .-cbwsdk-snackbar-instance-expanded .-cbwsdk-snackbar-instance-menu{opacity:1;display:flex;transform:translateY(8px);visibility:visible}", OK = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEuNDkyIDEwLjQxOWE4LjkzIDguOTMgMCAwMTguOTMtOC45M2gxMS4xNjNhOC45MyA4LjkzIDAgMDE4LjkzIDguOTN2MTEuMTYzYTguOTMgOC45MyAwIDAxLTguOTMgOC45M0gxMC40MjJhOC45MyA4LjkzIDAgMDEtOC45My04LjkzVjEwLjQxOXoiIGZpbGw9IiMxNjUyRjAiLz48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwLjQxOSAwSDIxLjU4QzI3LjMzNSAwIDMyIDQuNjY1IDMyIDEwLjQxOVYyMS41OEMzMiAyNy4zMzUgMjcuMzM1IDMyIDIxLjU4MSAzMkgxMC40MkM0LjY2NSAzMiAwIDI3LjMzNSAwIDIxLjU4MVYxMC40MkMwIDQuNjY1IDQuNjY1IDAgMTAuNDE5IDB6bTAgMS40ODhhOC45MyA4LjkzIDAgMDAtOC45MyA4LjkzdjExLjE2M2E4LjkzIDguOTMgMCAwMDguOTMgOC45M0gyMS41OGE4LjkzIDguOTMgMCAwMDguOTMtOC45M1YxMC40MmE4LjkzIDguOTMgMCAwMC04LjkzLTguOTNIMTAuNDJ6IiBmaWxsPSIjZmZmIi8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNS45OTggMjYuMDQ5Yy01LjU0OSAwLTEwLjA0Ny00LjQ5OC0xMC4wNDctMTAuMDQ3IDAtNS41NDggNC40OTgtMTAuMDQ2IDEwLjA0Ny0xMC4wNDYgNS41NDggMCAxMC4wNDYgNC40OTggMTAuMDQ2IDEwLjA0NiAwIDUuNTQ5LTQuNDk4IDEwLjA0Ny0xMC4wNDYgMTAuMDQ3eiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik0xMi43NjIgMTQuMjU0YzAtLjgyMi42NjctMS40ODkgMS40ODktMS40ODloMy40OTdjLjgyMiAwIDEuNDg4LjY2NiAxLjQ4OCAxLjQ4OXYzLjQ5N2MwIC44MjItLjY2NiAxLjQ4OC0xLjQ4OCAxLjQ4OGgtMy40OTdhMS40ODggMS40ODggMCAwMS0xLjQ4OS0xLjQ4OHYtMy40OTh6IiBmaWxsPSIjMTY1MkYwIi8+PC9zdmc+", NK = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTEyIDYuNzV2LTEuNWwtMS43Mi0uNTdjLS4wOC0uMjctLjE5LS41Mi0uMzItLjc3bC44MS0xLjYyLTEuMDYtMS4wNi0xLjYyLjgxYy0uMjQtLjEzLS41LS4yNC0uNzctLjMyTDYuNzUgMGgtMS41bC0uNTcgMS43MmMtLjI3LjA4LS41My4xOS0uNzcuMzJsLTEuNjItLjgxLTEuMDYgMS4wNi44MSAxLjYyYy0uMTMuMjQtLjI0LjUtLjMyLjc3TDAgNS4yNXYxLjVsMS43Mi41N2MuMDguMjcuMTkuNTMuMzIuNzdsLS44MSAxLjYyIDEuMDYgMS4wNiAxLjYyLS44MWMuMjQuMTMuNS4yMy43Ny4zMkw1LjI1IDEyaDEuNWwuNTctMS43MmMuMjctLjA4LjUyLS4xOS43Ny0uMzJsMS42Mi44MSAxLjA2LTEuMDYtLjgxLTEuNjJjLjEzLS4yNC4yMy0uNS4zMi0uNzdMMTIgNi43NXpNNiA4LjVhMi41IDIuNSAwIDAxMC01IDIuNSAyLjUgMCAwMTAgNXoiIGZpbGw9IiMwNTBGMTkiLz48L3N2Zz4="; +class LK { + constructor() { + this.items = /* @__PURE__ */ new Map(), this.nextItemKey = 0, this.root = null, this.darkMode = RE(); + } + attach(e) { + this.root = document.createElement("div"), this.root.className = "-cbwsdk-snackbar-root", e.appendChild(this.root), this.render(); + } + presentItem(e) { + const r = this.nextItemKey++; + return this.items.set(r, e), this.render(), () => { + this.items.delete(r), this.render(); + }; + } + clear() { + this.items.clear(), this.render(); + } + render() { + this.root && bv(Lr( + "div", + null, + Lr(WE, { darkMode: this.darkMode }, Array.from(this.items.entries()).map(([e, r]) => Lr(kK, Object.assign({}, r, { key: e })))) + ), this.root); + } +} +const WE = (t) => Lr( + "div", + { class: of("-cbwsdk-snackbar-container") }, + Lr("style", null, DK), + Lr("div", { class: "-cbwsdk-snackbar" }, t.children) +), kK = ({ autoExpand: t, message: e, menuItems: r }) => { + const [n, i] = W_(!0), [s, o] = W_(t ?? !1); + IK(() => { + const f = [ + window.setTimeout(() => { + i(!1); + }, 1), + window.setTimeout(() => { + o(!0); + }, 1e4) + ]; + return () => { + f.forEach(window.clearTimeout); + }; + }); + const a = () => { + o(!s); + }; + return Lr( + "div", + { class: of("-cbwsdk-snackbar-instance", n && "-cbwsdk-snackbar-instance-hidden", s && "-cbwsdk-snackbar-instance-expanded") }, + Lr( + "div", + { class: "-cbwsdk-snackbar-instance-header", onClick: a }, + Lr("img", { src: OK, class: "-cbwsdk-snackbar-instance-header-cblogo" }), + " ", + Lr("div", { class: "-cbwsdk-snackbar-instance-header-message" }, e), + Lr( + "div", + { class: "-gear-container" }, + !s && Lr( + "svg", + { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, + Lr("circle", { cx: "12", cy: "12", r: "12", fill: "#F5F7F8" }) + ), + Lr("img", { src: NK, class: "-gear-icon", title: "Expand" }) + ) + ), + r && r.length > 0 && Lr("div", { class: "-cbwsdk-snackbar-instance-menu" }, r.map((f, u) => Lr( + "div", + { class: of("-cbwsdk-snackbar-instance-menu-item", f.isRed && "-cbwsdk-snackbar-instance-menu-item-is-red"), onClick: f.onClick, key: u }, + Lr( + "svg", + { width: f.svgWidth, height: f.svgHeight, viewBox: "0 0 10 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, + Lr("path", { "fill-rule": f.defaultFillRule, "clip-rule": f.defaultClipRule, d: f.path, fill: "#AAAAAA" }) + ), + Lr("span", { class: of("-cbwsdk-snackbar-instance-menu-item-info", f.isRed && "-cbwsdk-snackbar-instance-menu-item-info-is-red") }, f.info) + ))) + ); +}; +class $K { + constructor() { + this.attached = !1, this.snackbar = new LK(); + } + attach() { + if (this.attached) + throw new Error("Coinbase Wallet SDK UI is already attached"); + const e = document.documentElement, r = document.createElement("div"); + r.className = "-cbwsdk-css-reset", e.appendChild(r), this.snackbar.attach(r), this.attached = !0, TE(); + } + showConnecting(e) { + let r; + return e.isUnlinkedErrorState ? r = { + autoExpand: !0, + message: "Connection lost", + menuItems: [ + { + isRed: !1, + info: "Reset connection", + svgWidth: "10", + svgHeight: "11", + path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z", + defaultFillRule: "evenodd", + defaultClipRule: "evenodd", + onClick: e.onResetConnection + } + ] + } : r = { + message: "Confirm on phone", + menuItems: [ + { + isRed: !0, + info: "Cancel transaction", + svgWidth: "11", + svgHeight: "11", + path: "M10.3711 1.52346L9.21775 0.370117L5.37109 4.21022L1.52444 0.370117L0.371094 1.52346L4.2112 5.37012L0.371094 9.21677L1.52444 10.3701L5.37109 6.53001L9.21775 10.3701L10.3711 9.21677L6.53099 5.37012L10.3711 1.52346Z", + defaultFillRule: "inherit", + defaultClipRule: "inherit", + onClick: e.onCancel + }, + { + isRed: !1, + info: "Reset connection", + svgWidth: "10", + svgHeight: "11", + path: "M5.00008 0.96875C6.73133 0.96875 8.23758 1.94375 9.00008 3.375L10.0001 2.375V5.5H9.53133H7.96883H6.87508L7.80633 4.56875C7.41258 3.3875 6.31258 2.53125 5.00008 2.53125C3.76258 2.53125 2.70633 3.2875 2.25633 4.36875L0.812576 3.76875C1.50008 2.125 3.11258 0.96875 5.00008 0.96875ZM2.19375 6.43125C2.5875 7.6125 3.6875 8.46875 5 8.46875C6.2375 8.46875 7.29375 7.7125 7.74375 6.63125L9.1875 7.23125C8.5 8.875 6.8875 10.0312 5 10.0312C3.26875 10.0312 1.7625 9.05625 1 7.625L0 8.625V5.5H0.46875H2.03125H3.125L2.19375 6.43125Z", + defaultFillRule: "evenodd", + defaultClipRule: "evenodd", + onClick: e.onResetConnection + } + ] + }, this.snackbar.presentItem(r); + } +} +const BK = ".-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;transition:opacity .25s;background-color:rgba(10,11,13,.5)}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-backdrop-hidden{opacity:0}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box{display:block;position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);padding:20px;border-radius:8px;background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box p{display:block;font-weight:400;font-size:14px;line-height:20px;padding-bottom:12px;color:#5b636e}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box button{appearance:none;border:none;background:none;color:#0052ff;padding:0;text-decoration:none;display:block;font-weight:600;font-size:16px;line-height:24px}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark{background-color:#0a0b0d;color:#fff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.dark button{color:#0052ff}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light{background-color:#fff;color:#0a0b0d}.-cbwsdk-css-reset .-cbwsdk-redirect-dialog-box.light button{color:#0052ff}"; +class FK { + constructor() { + this.root = null, this.darkMode = RE(); + } + attach() { + const e = document.documentElement; + this.root = document.createElement("div"), this.root.className = "-cbwsdk-css-reset", e.appendChild(this.root), TE(); + } + present(e) { + this.render(e); + } + clear() { + this.render(null); + } + render(e) { + this.root && (bv(null, this.root), e && bv(Lr(jK, Object.assign({}, e, { onDismiss: () => { + this.clear(); + }, darkMode: this.darkMode })), this.root)); + } +} +const jK = ({ title: t, buttonText: e, darkMode: r, onButtonClick: n, onDismiss: i }) => { + const s = r ? "dark" : "light"; + return Lr( + WE, + { darkMode: r }, + Lr( + "div", + { class: "-cbwsdk-redirect-dialog" }, + Lr("style", null, BK), + Lr("div", { class: "-cbwsdk-redirect-dialog-backdrop", onClick: i }), + Lr( + "div", + { class: of("-cbwsdk-redirect-dialog-box", s) }, + Lr("p", null, t), + Lr("button", { onClick: n }, e) + ) + ) + ); +}, UK = "https://keys.coinbase.com/connect", V_ = "https://www.walletlink.org", qK = "https://go.cb-w.com/walletlink"; +class G_ { + constructor() { + this.attached = !1, this.redirectDialog = new FK(); + } + attach() { + if (this.attached) + throw new Error("Coinbase Wallet SDK UI is already attached"); + this.redirectDialog.attach(), this.attached = !0; + } + redirectToCoinbaseWallet(e) { + const r = new URL(qK); + r.searchParams.append("redirect_url", yK().href), e && r.searchParams.append("wl_url", e); + const n = document.createElement("a"); + n.target = "cbw-opener", n.href = r.href, n.rel = "noreferrer noopener", n.click(); + } + openCoinbaseWalletDeeplink(e) { + this.redirectDialog.present({ + title: "Redirecting to Coinbase Wallet...", + buttonText: "Open", + onButtonClick: () => { + this.redirectToCoinbaseWallet(e); + } + }), setTimeout(() => { + this.redirectToCoinbaseWallet(e); + }, 99); + } + showConnecting(e) { + return () => { + this.redirectDialog.clear(); + }; + } +} +class to { + constructor(e) { + this.chainCallbackParams = { chainId: "", jsonRpcUrl: "" }, this.isMobileWeb = wK(), this.linkedUpdated = (s) => { + this.isLinked = s; + const o = this.storage.getItem(pv); + if (s && (this._session.linked = s), this.isUnlinkedErrorState = !1, o) { + const a = o.split(" "), f = this.storage.getItem("IsStandaloneSigning") === "true"; + a[0] !== "" && !s && this._session.linked && !f && (this.isUnlinkedErrorState = !0); + } + }, this.metadataUpdated = (s, o) => { + this.storage.setItem(s, o); + }, this.chainUpdated = (s, o) => { + this.chainCallbackParams.chainId === s && this.chainCallbackParams.jsonRpcUrl === o || (this.chainCallbackParams = { + chainId: s, + jsonRpcUrl: o + }, this.chainCallback && this.chainCallback(o, Number.parseInt(s, 10))); + }, this.accountUpdated = (s) => { + this.accountsCallback && this.accountsCallback([s]), to.accountRequestCallbackIds.size > 0 && (Array.from(to.accountRequestCallbackIds.values()).forEach((o) => { + this.invokeCallback(o, { + method: "requestEthereumAccounts", + result: [s] + }); + }), to.accountRequestCallbackIds.clear()); + }, this.resetAndReload = this.resetAndReload.bind(this), this.linkAPIUrl = e.linkAPIUrl, this.storage = e.storage, this.metadata = e.metadata, this.accountsCallback = e.accountsCallback, this.chainCallback = e.chainCallback; + const { session: r, ui: n, connection: i } = this.subscribe(); + this._session = r, this.connection = i, this.relayEventManager = new vK(), this.ui = n, this.ui.attach(); + } + subscribe() { + const e = kc.load(this.storage) || kc.create(this.storage), { linkAPIUrl: r } = this, n = new mK({ + session: e, + linkAPIUrl: r, + listener: this + }), i = this.isMobileWeb ? new G_() : new $K(); + return n.connect(), { session: e, ui: i, connection: n }; + } + resetAndReload() { + this.connection.destroy().then(() => { + const e = kc.load(this.storage); + e?.id === this._session.id && Os.clearAll(), document.location.reload(); + }).catch((e) => { + }); + } + signEthereumTransaction(e) { + return this.sendRequest({ + method: "signEthereumTransaction", + params: { + fromAddress: e.fromAddress, + toAddress: e.toAddress, + weiValue: Es(e.weiValue), + data: nf(e.data, !0), + nonce: e.nonce, + gasPriceInWei: e.gasPriceInWei ? Es(e.gasPriceInWei) : null, + maxFeePerGas: e.gasPriceInWei ? Es(e.gasPriceInWei) : null, + maxPriorityFeePerGas: e.gasPriceInWei ? Es(e.gasPriceInWei) : null, + gasLimit: e.gasLimit ? Es(e.gasLimit) : null, + chainId: e.chainId, + shouldSubmit: !1 + } + }); + } + signAndSubmitEthereumTransaction(e) { + return this.sendRequest({ + method: "signEthereumTransaction", + params: { + fromAddress: e.fromAddress, + toAddress: e.toAddress, + weiValue: Es(e.weiValue), + data: nf(e.data, !0), + nonce: e.nonce, + gasPriceInWei: e.gasPriceInWei ? Es(e.gasPriceInWei) : null, + maxFeePerGas: e.maxFeePerGas ? Es(e.maxFeePerGas) : null, + maxPriorityFeePerGas: e.maxPriorityFeePerGas ? Es(e.maxPriorityFeePerGas) : null, + gasLimit: e.gasLimit ? Es(e.gasLimit) : null, + chainId: e.chainId, + shouldSubmit: !0 + } + }); + } + submitEthereumTransaction(e, r) { + return this.sendRequest({ + method: "submitEthereumTransaction", + params: { + signedTransaction: nf(e, !0), + chainId: r + } + }); + } + getWalletLinkSession() { + return this._session; + } + sendRequest(e) { + let r = null; + const n = Ea(8), i = (s) => { + this.publishWeb3RequestCanceledEvent(n), this.handleErrorResponse(n, e.method, s), r?.(); + }; + return new Promise((s, o) => { + r = this.ui.showConnecting({ + isUnlinkedErrorState: this.isUnlinkedErrorState, + onCancel: i, + onResetConnection: this.resetAndReload + // eslint-disable-line @typescript-eslint/unbound-method + }), this.relayEventManager.callbacks.set(n, (a) => { + if (r?.(), Ln(a)) + return o(new Error(a.errorMessage)); + s(a); + }), this.publishWeb3RequestEvent(n, e); + }); + } + publishWeb3RequestEvent(e, r) { + const n = { type: "WEB3_REQUEST", id: e, request: r }; + this.publishEvent("Web3Request", n, !0).then((i) => { + }).catch((i) => { + this.handleWeb3ResponseMessage(n.id, { + method: r.method, + errorMessage: i.message + }); + }), this.isMobileWeb && this.openCoinbaseWalletDeeplink(r.method); + } + // copied from MobileRelay + openCoinbaseWalletDeeplink(e) { + if (this.ui instanceof G_) + switch (e) { + case "requestEthereumAccounts": + // requestEthereumAccounts is handled via popup + case "switchEthereumChain": + return; + default: + window.addEventListener("blur", () => { + window.addEventListener("focus", () => { + this.connection.checkUnseenEvents(); + }, { once: !0 }); + }, { once: !0 }), this.ui.openCoinbaseWalletDeeplink(); + break; + } + } + publishWeb3RequestCanceledEvent(e) { + const r = { + type: "WEB3_REQUEST_CANCELED", + id: e + }; + this.publishEvent("Web3RequestCanceled", r, !1).then(); + } + publishEvent(e, r, n) { + return this.connection.publishEvent(e, r, n); + } + handleWeb3ResponseMessage(e, r) { + if (r.method === "requestEthereumAccounts") { + to.accountRequestCallbackIds.forEach((n) => this.invokeCallback(n, r)), to.accountRequestCallbackIds.clear(); + return; + } + this.invokeCallback(e, r); + } + handleErrorResponse(e, r, n) { + var i; + const s = (i = n?.message) !== null && i !== void 0 ? i : "Unspecified error message."; + this.handleWeb3ResponseMessage(e, { + method: r, + errorMessage: s + }); + } + invokeCallback(e, r) { + const n = this.relayEventManager.callbacks.get(e); + n && (n(r), this.relayEventManager.callbacks.delete(e)); + } + requestEthereumAccounts() { + const { appName: e, appLogoUrl: r } = this.metadata, n = { + method: "requestEthereumAccounts", + params: { + appName: e, + appLogoUrl: r + } + }, i = Ea(8); + return new Promise((s, o) => { + this.relayEventManager.callbacks.set(i, (a) => { + if (Ln(a)) + return o(new Error(a.errorMessage)); + s(a); + }), to.accountRequestCallbackIds.add(i), this.publishWeb3RequestEvent(i, n); + }); + } + watchAsset(e, r, n, i, s, o) { + const a = { + method: "watchAsset", + params: { + type: e, + options: { + address: r, + symbol: n, + decimals: i, + image: s + }, + chainId: o + } + }; + let f = null; + const u = Ea(8), h = (g) => { + this.publishWeb3RequestCanceledEvent(u), this.handleErrorResponse(u, a.method, g), f?.(); + }; + return f = this.ui.showConnecting({ + isUnlinkedErrorState: this.isUnlinkedErrorState, + onCancel: h, + onResetConnection: this.resetAndReload + // eslint-disable-line @typescript-eslint/unbound-method + }), new Promise((g, v) => { + this.relayEventManager.callbacks.set(u, (x) => { + if (f?.(), Ln(x)) + return v(new Error(x.errorMessage)); + g(x); + }), this.publishWeb3RequestEvent(u, a); + }); + } + addEthereumChain(e, r, n, i, s, o) { + const a = { + method: "addEthereumChain", + params: { + chainId: e, + rpcUrls: r, + blockExplorerUrls: i, + chainName: s, + iconUrls: n, + nativeCurrency: o + } + }; + let f = null; + const u = Ea(8), h = (g) => { + this.publishWeb3RequestCanceledEvent(u), this.handleErrorResponse(u, a.method, g), f?.(); + }; + return f = this.ui.showConnecting({ + isUnlinkedErrorState: this.isUnlinkedErrorState, + onCancel: h, + onResetConnection: this.resetAndReload + // eslint-disable-line @typescript-eslint/unbound-method + }), new Promise((g, v) => { + this.relayEventManager.callbacks.set(u, (x) => { + if (f?.(), Ln(x)) + return v(new Error(x.errorMessage)); + g(x); + }), this.publishWeb3RequestEvent(u, a); + }); + } + switchEthereumChain(e, r) { + const n = { + method: "switchEthereumChain", + params: Object.assign({ chainId: e }, { address: r }) + }; + let i = null; + const s = Ea(8), o = (a) => { + this.publishWeb3RequestCanceledEvent(s), this.handleErrorResponse(s, n.method, a), i?.(); + }; + return i = this.ui.showConnecting({ + isUnlinkedErrorState: this.isUnlinkedErrorState, + onCancel: o, + onResetConnection: this.resetAndReload + // eslint-disable-line @typescript-eslint/unbound-method + }), new Promise((a, f) => { + this.relayEventManager.callbacks.set(s, (u) => { + if (i?.(), Ln(u) && u.errorCode) + return f(Ar.provider.custom({ + code: u.errorCode, + message: "Unrecognized chain ID. Try adding the chain using addEthereumChain first." + })); + if (Ln(u)) + return f(new Error(u.errorMessage)); + a(u); + }), this.publishWeb3RequestEvent(s, n); + }); + } +} +to.accountRequestCallbackIds = /* @__PURE__ */ new Set(); +const Y_ = "DefaultChainId", J_ = "DefaultJsonRpcUrl"; +class KE { + constructor(e) { + this._relay = null, this._addresses = [], this.metadata = e.metadata, this._storage = new Os("walletlink", V_), this.callback = e.callback || null; + const r = this._storage.getItem(pv); + if (r) { + const n = r.split(" "); + n[0] !== "" && (this._addresses = n.map((i) => Mo(i))); + } + this.initializeRelay(); + } + getSession() { + const e = this.initializeRelay(), { id: r, secret: n } = e.getWalletLinkSession(); + return { id: r, secret: n }; + } + async handshake() { + await this._eth_requestAccounts(); + } + get selectedAddress() { + return this._addresses[0] || void 0; + } + get jsonRpcUrl() { + var e; + return (e = this._storage.getItem(J_)) !== null && e !== void 0 ? e : void 0; + } + set jsonRpcUrl(e) { + this._storage.setItem(J_, e); + } + updateProviderInfo(e, r) { + var n; + this.jsonRpcUrl = e; + const i = this.getChainId(); + this._storage.setItem(Y_, r.toString(10)), sf(r) !== i && ((n = this.callback) === null || n === void 0 || n.call(this, "chainChanged", Bo(r))); + } + async watchAsset(e) { + const r = Array.isArray(e) ? e[0] : e; + if (!r.type) + throw Ar.rpc.invalidParams("Type is required"); + if (r?.type !== "ERC20") + throw Ar.rpc.invalidParams(`Asset of type '${r.type}' is not supported`); + if (!r?.options) + throw Ar.rpc.invalidParams("Options are required"); + if (!r?.options.address) + throw Ar.rpc.invalidParams("Address is required"); + const n = this.getChainId(), { address: i, symbol: s, image: o, decimals: a } = r.options, u = await this.initializeRelay().watchAsset(r.type, i, s, a, o, n?.toString()); + return Ln(u) ? !1 : !!u.result; + } + async addEthereumChain(e) { + var r, n; + const i = e[0]; + if (((r = i.rpcUrls) === null || r === void 0 ? void 0 : r.length) === 0) + throw Ar.rpc.invalidParams("please pass in at least 1 rpcUrl"); + if (!i.chainName || i.chainName.trim() === "") + throw Ar.rpc.invalidParams("chainName is a required field"); + if (!i.nativeCurrency) + throw Ar.rpc.invalidParams("nativeCurrency is a required field"); + const s = Number.parseInt(i.chainId, 16); + if (s === this.getChainId()) + return !1; + const o = this.initializeRelay(), { rpcUrls: a = [], blockExplorerUrls: f = [], chainName: u, iconUrls: h = [], nativeCurrency: g } = i, v = await o.addEthereumChain(s.toString(), a, h, f, u, g); + if (Ln(v)) + return !1; + if (((n = v.result) === null || n === void 0 ? void 0 : n.isApproved) === !0) + return this.updateProviderInfo(a[0], s), null; + throw Ar.rpc.internal("unable to add ethereum chain"); + } + async switchEthereumChain(e) { + const r = e[0], n = Number.parseInt(r.chainId, 16), s = await this.initializeRelay().switchEthereumChain(n.toString(10), this.selectedAddress || void 0); + if (Ln(s)) + throw s; + const o = s.result; + return o.isApproved && o.rpcUrl.length > 0 && this.updateProviderInfo(o.rpcUrl, n), null; + } + async cleanup() { + this.callback = null, this._relay && this._relay.resetAndReload(), this._storage.clear(); + } + _setAddresses(e, r) { + var n; + if (!Array.isArray(e)) + throw new Error("addresses is not an array"); + const i = e.map((s) => Mo(s)); + JSON.stringify(i) !== JSON.stringify(this._addresses) && (this._addresses = i, (n = this.callback) === null || n === void 0 || n.call(this, "accountsChanged", i), this._storage.setItem(pv, i.join(" "))); + } + async request(e) { + const r = e.params || []; + switch (e.method) { + case "eth_accounts": + return [...this._addresses]; + case "eth_coinbase": + return this.selectedAddress || null; + case "net_version": + return this.getChainId().toString(10); + case "eth_chainId": + return Bo(this.getChainId()); + case "eth_requestAccounts": + return this._eth_requestAccounts(); + case "eth_ecRecover": + case "personal_ecRecover": + return this.ecRecover(e); + case "personal_sign": + return this.personalSign(e); + case "eth_signTransaction": + return this._eth_signTransaction(r); + case "eth_sendRawTransaction": + return this._eth_sendRawTransaction(r); + case "eth_sendTransaction": + return this._eth_sendTransaction(r); + case "eth_signTypedData_v1": + case "eth_signTypedData_v3": + case "eth_signTypedData_v4": + case "eth_signTypedData": + return this.signTypedData(e); + case "wallet_addEthereumChain": + return this.addEthereumChain(r); + case "wallet_switchEthereumChain": + return this.switchEthereumChain(r); + case "wallet_watchAsset": + return this.watchAsset(r); + default: + if (!this.jsonRpcUrl) + throw Ar.rpc.internal("No RPC URL set for chain"); + return IE(e, this.jsonRpcUrl); + } + } + _ensureKnownAddress(e) { + const r = Mo(e); + if (!this._addresses.map((i) => Mo(i)).includes(r)) + throw new Error("Unknown Ethereum address"); + } + _prepareTransactionParams(e) { + const r = e.from ? Mo(e.from) : this.selectedAddress; + if (!r) + throw new Error("Ethereum address is unavailable"); + this._ensureKnownAddress(r); + const n = e.to ? Mo(e.to) : null, i = e.value != null ? Fu(e.value) : BigInt(0), s = e.data ? dv(e.data) : Buffer.alloc(0), o = e.nonce != null ? sf(e.nonce) : null, a = e.gasPrice != null ? Fu(e.gasPrice) : null, f = e.maxFeePerGas != null ? Fu(e.maxFeePerGas) : null, u = e.maxPriorityFeePerGas != null ? Fu(e.maxPriorityFeePerGas) : null, h = e.gas != null ? Fu(e.gas) : null, g = e.chainId ? sf(e.chainId) : this.getChainId(); + return { + fromAddress: r, + toAddress: n, + weiValue: i, + data: s, + nonce: o, + gasPriceInWei: a, + maxFeePerGas: f, + maxPriorityFeePerGas: u, + gasLimit: h, + chainId: g + }; + } + async ecRecover(e) { + const { method: r, params: n } = e; + if (!Array.isArray(n)) + throw Ar.rpc.invalidParams(); + const s = await this.initializeRelay().sendRequest({ + method: "ethereumAddressFromSignedMessage", + params: { + message: im(n[0]), + signature: im(n[1]), + addPrefix: r === "personal_ecRecover" + } + }); + if (Ln(s)) + throw s; + return s.result; + } + getChainId() { + var e; + return Number.parseInt((e = this._storage.getItem(Y_)) !== null && e !== void 0 ? e : "1", 10); + } + async _eth_requestAccounts() { + var e, r; + if (this._addresses.length > 0) + return (e = this.callback) === null || e === void 0 || e.call(this, "connect", { chainId: Bo(this.getChainId()) }), this._addresses; + const i = await this.initializeRelay().requestEthereumAccounts(); + if (Ln(i)) + throw i; + if (!i.result) + throw new Error("accounts received is empty"); + return this._setAddresses(i.result), (r = this.callback) === null || r === void 0 || r.call(this, "connect", { chainId: Bo(this.getChainId()) }), this._addresses; + } + async personalSign({ params: e }) { + if (!Array.isArray(e)) + throw Ar.rpc.invalidParams(); + const r = e[1], n = e[0]; + this._ensureKnownAddress(r); + const s = await this.initializeRelay().sendRequest({ + method: "signEthereumMessage", + params: { + address: Mo(r), + message: im(n), + addPrefix: !0, + typedDataJson: null + } + }); + if (Ln(s)) + throw s; + return s.result; + } + async _eth_signTransaction(e) { + const r = this._prepareTransactionParams(e[0] || {}), i = await this.initializeRelay().signEthereumTransaction(r); + if (Ln(i)) + throw i; + return i.result; + } + async _eth_sendRawTransaction(e) { + const r = dv(e[0]), i = await this.initializeRelay().submitEthereumTransaction(r, this.getChainId()); + if (Ln(i)) + throw i; + return i.result; + } + async _eth_sendTransaction(e) { + const r = this._prepareTransactionParams(e[0] || {}), i = await this.initializeRelay().signAndSubmitEthereumTransaction(r); + if (Ln(i)) + throw i; + return i.result; + } + async signTypedData(e) { + const { method: r, params: n } = e; + if (!Array.isArray(n)) + throw Ar.rpc.invalidParams(); + const i = (u) => { + const h = { + eth_signTypedData_v1: Ph.hashForSignTypedDataLegacy, + eth_signTypedData_v3: Ph.hashForSignTypedData_v3, + eth_signTypedData_v4: Ph.hashForSignTypedData_v4, + eth_signTypedData: Ph.hashForSignTypedData_v4 + }; + return nf(h[r]({ + data: zW(u) + }), !0); + }, s = n[r === "eth_signTypedData_v1" ? 1 : 0], o = n[r === "eth_signTypedData_v1" ? 0 : 1]; + this._ensureKnownAddress(s); + const f = await this.initializeRelay().sendRequest({ + method: "signEthereumMessage", + params: { + address: Mo(s), + message: i(o), + typedDataJson: JSON.stringify(o, null, 2), + addPrefix: !1 + } + }); + if (Ln(f)) + throw f; + return f.result; + } + initializeRelay() { + return this._relay || (this._relay = new to({ + linkAPIUrl: V_, + storage: this._storage, + metadata: this.metadata, + accountsCallback: this._setAddresses.bind(this), + chainCallback: this.updateProviderInfo.bind(this) + })), this._relay; + } +} +const VE = "SignerType", GE = new Os("CBWSDK", "SignerConfigurator"); +function zK() { + return GE.getItem(VE); +} +function HK(t) { + GE.setItem(VE, t); +} +async function WK(t) { + const { communicator: e, metadata: r, handshakeRequest: n, callback: i } = t; + VK(e, r, i).catch(() => { + }); + const s = { + id: crypto.randomUUID(), + event: "selectSignerType", + data: Object.assign(Object.assign({}, t.preference), { handshakeRequest: n }) + }, { data: o } = await e.postRequestAndWaitForResponse(s); + return o; +} +function KK(t) { + const { signerType: e, metadata: r, communicator: n, callback: i } = t; + switch (e) { + case "scw": + return new rK({ + metadata: r, + callback: i, + communicator: n + }); + case "walletlink": + return new KE({ + metadata: r, + callback: i + }); + } +} +async function VK(t, e, r) { + await t.onMessage(({ event: i }) => i === "WalletLinkSessionRequest"); + const n = new KE({ + metadata: e, + callback: r + }); + t.postMessage({ + event: "WalletLinkUpdate", + data: { session: n.getSession() } + }), await n.handshake(), t.postMessage({ + event: "WalletLinkUpdate", + data: { connected: !0 } + }); +} +const GK = `Coinbase Wallet SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Coinbase Smart Wallet app. + +Please see https://www.smartwallet.dev/guides/tips/popup-tips#cross-origin-opener-policy for more information.`, YK = () => { + let t; + return { + getCrossOriginOpenerPolicy: () => t === void 0 ? "undefined" : t, + checkCrossOriginOpenerPolicy: async () => { + if (typeof window > "u") { + t = "non-browser-env"; + return; + } + try { + const e = `${window.location.origin}${window.location.pathname}`, r = await fetch(e, { + method: "HEAD" + }); + if (!r.ok) + throw new Error(`HTTP error! status: ${r.status}`); + const n = r.headers.get("Cross-Origin-Opener-Policy"); + t = n ?? "null", t === "same-origin" && console.error(GK); + } catch (e) { + console.error("Error checking Cross-Origin-Opener-Policy:", e.message), t = "error"; + } + } + }; +}, { checkCrossOriginOpenerPolicy: JK, getCrossOriginOpenerPolicy: XK } = YK(), X_ = 420, Z_ = 540; +function ZK(t) { + const e = (window.innerWidth - X_) / 2 + window.screenX, r = (window.innerHeight - Z_) / 2 + window.screenY; + eV(t); + const n = window.open(t, "Smart Wallet", `width=${X_}, height=${Z_}, left=${e}, top=${r}`); + if (n?.focus(), !n) + throw Ar.rpc.internal("Pop up window failed to open"); + return n; +} +function QK(t) { + t && !t.closed && t.close(); +} +function eV(t) { + const e = { + sdkName: ME, + sdkVersion: ul, + origin: window.location.origin, + coop: XK() + }; + for (const [r, n] of Object.entries(e)) + t.searchParams.append(r, n.toString()); +} +class tV { + constructor({ url: e = UK, metadata: r, preference: n }) { + this.popup = null, this.listeners = /* @__PURE__ */ new Map(), this.postMessage = async (i) => { + (await this.waitForPopupLoaded()).postMessage(i, this.url.origin); + }, this.postRequestAndWaitForResponse = async (i) => { + const s = this.onMessage(({ requestId: o }) => o === i.id); + return this.postMessage(i), await s; + }, this.onMessage = async (i) => new Promise((s, o) => { + const a = (f) => { + if (f.origin !== this.url.origin) + return; + const u = f.data; + i(u) && (s(u), window.removeEventListener("message", a), this.listeners.delete(a)); + }; + window.addEventListener("message", a), this.listeners.set(a, { reject: o }); + }), this.disconnect = () => { + QK(this.popup), this.popup = null, this.listeners.forEach(({ reject: i }, s) => { + i(Ar.provider.userRejectedRequest("Request rejected")), window.removeEventListener("message", s); + }), this.listeners.clear(); + }, this.waitForPopupLoaded = async () => this.popup && !this.popup.closed ? (this.popup.focus(), this.popup) : (this.popup = ZK(this.url), this.onMessage(({ event: i }) => i === "PopupUnload").then(this.disconnect).catch(() => { + }), this.onMessage(({ event: i }) => i === "PopupLoaded").then((i) => { + this.postMessage({ + requestId: i.id, + data: { + version: ul, + metadata: this.metadata, + preference: this.preference, + location: window.location.toString() + } + }); + }).then(() => { + if (!this.popup) + throw Ar.rpc.internal(); + return this.popup; + })), this.url = new URL(e), this.metadata = r, this.preference = n; + } +} +function rV(t) { + const e = BW(nV(t), { + shouldIncludeStack: !0 + }), r = new URL("https://docs.cloud.coinbase.com/wallet-sdk/docs/errors"); + return r.searchParams.set("version", ul), r.searchParams.set("code", e.code.toString()), r.searchParams.set("message", e.message), Object.assign(Object.assign({}, e), { docUrl: r.href }); +} +function nV(t) { + var e; + if (typeof t == "string") + return { + message: t, + code: un.rpc.internal + }; + if (Ln(t)) { + const r = t.errorMessage, n = (e = t.errorCode) !== null && e !== void 0 ? e : r.match(/(denied|rejected)/i) ? un.provider.userRejectedRequest : void 0; + return Object.assign(Object.assign({}, t), { + message: r, + code: n, + data: { method: t.method } + }); + } + return t; +} +var dm = { exports: {} }, Q_; +function iV() { + return Q_ || (Q_ = 1, (function(t) { + var e = Object.prototype.hasOwnProperty, r = "~"; + function n() { + } + Object.create && (n.prototype = /* @__PURE__ */ Object.create(null), new n().__proto__ || (r = !1)); + function i(f, u, h) { + this.fn = f, this.context = u, this.once = h || !1; + } + function s(f, u, h, g, v) { + if (typeof h != "function") + throw new TypeError("The listener must be a function"); + var x = new i(h, g || f, v), S = r ? r + u : u; + return f._events[S] ? f._events[S].fn ? f._events[S] = [f._events[S], x] : f._events[S].push(x) : (f._events[S] = x, f._eventsCount++), f; + } + function o(f, u) { + --f._eventsCount === 0 ? f._events = new n() : delete f._events[u]; + } + function a() { + this._events = new n(), this._eventsCount = 0; + } + a.prototype.eventNames = function() { + var u = [], h, g; + if (this._eventsCount === 0) return u; + for (g in h = this._events) + e.call(h, g) && u.push(r ? g.slice(1) : g); + return Object.getOwnPropertySymbols ? u.concat(Object.getOwnPropertySymbols(h)) : u; + }, a.prototype.listeners = function(u) { + var h = r ? r + u : u, g = this._events[h]; + if (!g) return []; + if (g.fn) return [g.fn]; + for (var v = 0, x = g.length, S = new Array(x); v < x; v++) + S[v] = g[v].fn; + return S; + }, a.prototype.listenerCount = function(u) { + var h = r ? r + u : u, g = this._events[h]; + return g ? g.fn ? 1 : g.length : 0; + }, a.prototype.emit = function(u, h, g, v, x, S) { + var R = r ? r + u : u; + if (!this._events[R]) return !1; + var D = this._events[R], k = arguments.length, N, z; + if (D.fn) { + switch (D.once && this.removeListener(u, D.fn, void 0, !0), k) { + case 1: + return D.fn.call(D.context), !0; + case 2: + return D.fn.call(D.context, h), !0; + case 3: + return D.fn.call(D.context, h, g), !0; + case 4: + return D.fn.call(D.context, h, g, v), !0; + case 5: + return D.fn.call(D.context, h, g, v, x), !0; + case 6: + return D.fn.call(D.context, h, g, v, x, S), !0; + } + for (z = 1, N = new Array(k - 1); z < k; z++) + N[z - 1] = arguments[z]; + D.fn.apply(D.context, N); + } else { + var B = D.length, $; + for (z = 0; z < B; z++) + switch (D[z].once && this.removeListener(u, D[z].fn, void 0, !0), k) { + case 1: + D[z].fn.call(D[z].context); + break; + case 2: + D[z].fn.call(D[z].context, h); + break; + case 3: + D[z].fn.call(D[z].context, h, g); + break; + case 4: + D[z].fn.call(D[z].context, h, g, v); + break; + default: + if (!N) for ($ = 1, N = new Array(k - 1); $ < k; $++) + N[$ - 1] = arguments[$]; + D[z].fn.apply(D[z].context, N); + } + } + return !0; + }, a.prototype.on = function(u, h, g) { + return s(this, u, h, g, !1); + }, a.prototype.once = function(u, h, g) { + return s(this, u, h, g, !0); + }, a.prototype.removeListener = function(u, h, g, v) { + var x = r ? r + u : u; + if (!this._events[x]) return this; + if (!h) + return o(this, x), this; + var S = this._events[x]; + if (S.fn) + S.fn === h && (!v || S.once) && (!g || S.context === g) && o(this, x); + else { + for (var R = 0, D = [], k = S.length; R < k; R++) + (S[R].fn !== h || v && !S[R].once || g && S[R].context !== g) && D.push(S[R]); + D.length ? this._events[x] = D.length === 1 ? D[0] : D : o(this, x); + } + return this; + }, a.prototype.removeAllListeners = function(u) { + var h; + return u ? (h = r ? r + u : u, this._events[h] && o(this, h)) : (this._events = new n(), this._eventsCount = 0), this; + }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = r, a.EventEmitter = a, t.exports = a; + })(dm)), dm.exports; +} +var sV = iV(); +const oV = /* @__PURE__ */ Hi(sV); +class aV extends oV { +} +var cV = function(t, e) { + var r = {}; + for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); + if (t != null && typeof Object.getOwnPropertySymbols == "function") + for (var i = 0, n = Object.getOwnPropertySymbols(t); i < n.length; i++) + e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[i]) && (r[n[i]] = t[n[i]]); + return r; +}; +class uV extends aV { + constructor(e) { + var { metadata: r } = e, n = e.preference, { keysUrl: i } = n, s = cV(n, ["keysUrl"]); + super(), this.signer = null, this.isCoinbaseWallet = !0, this.metadata = r, this.preference = s, this.communicator = new tV({ + url: i, + metadata: r, + preference: s + }); + const o = zK(); + o && (this.signer = this.initSigner(o)); + } + async request(e) { + try { + if (tK(e), !this.signer) + switch (e.method) { + case "eth_requestAccounts": { + const r = await this.requestSignerSelection(e), n = this.initSigner(r); + await n.handshake(e), this.signer = n, HK(r); + break; + } + case "net_version": + return 1; + // default value + case "eth_chainId": + return Bo(1); + // default value + default: + throw Ar.provider.unauthorized("Must call 'eth_requestAccounts' before other methods"); + } + return this.signer.request(e); + } catch (r) { + const { code: n } = r; + return n === un.provider.unauthorized && this.disconnect(), Promise.reject(rV(r)); + } + } + /** @deprecated Use `.request({ method: 'eth_requestAccounts' })` instead. */ + async enable() { + return console.warn('.enable() has been deprecated. Please use .request({ method: "eth_requestAccounts" }) instead.'), await this.request({ + method: "eth_requestAccounts" + }); + } + async disconnect() { + var e; + await ((e = this.signer) === null || e === void 0 ? void 0 : e.cleanup()), this.signer = null, Os.clearAll(), this.emit("disconnect", Ar.provider.disconnected("User initiated disconnection")); + } + requestSignerSelection(e) { + return WK({ + communicator: this.communicator, + preference: this.preference, + metadata: this.metadata, + handshakeRequest: e, + callback: this.emit.bind(this) + }); + } + initSigner(e) { + return KK({ + signerType: e, + metadata: this.metadata, + communicator: this.communicator, + callback: this.emit.bind(this) + }); + } +} +function fV(t) { + if (t) { + if (!["all", "smartWalletOnly", "eoaOnly"].includes(t.options)) + throw new Error(`Invalid options: ${t.options}`); + if (t.attribution && t.attribution.auto !== void 0 && t.attribution.dataSuffix !== void 0) + throw new Error("Attribution cannot contain both auto and dataSuffix properties"); + } +} +function lV(t) { + var e; + const r = { + metadata: t.metadata, + preference: t.preference + }; + return (e = eK(r)) !== null && e !== void 0 ? e : new uV(r); +} +const hV = { + options: "all" +}; +function dV(t) { + var e; + new Os("CBWSDK").setItem("VERSION", ul), JK(); + const n = { + metadata: { + appName: t.appName || "Dapp", + appLogoUrl: t.appLogoUrl || "", + appChainIds: t.appChainIds || [] + }, + preference: Object.assign(hV, (e = t.preference) !== null && e !== void 0 ? e : {}) + }; + fV(n.preference); + let i = null; + return { + getProvider: () => (i || (i = lV(n)), i) + }; +} +function YE(t, e) { + return function() { + return t.apply(e, arguments); + }; +} +const { toString: pV } = Object.prototype, { getPrototypeOf: q1 } = Object, u0 = /* @__PURE__ */ ((t) => (e) => { + const r = pV.call(e); + return t[r] || (t[r] = r.slice(8, -1).toLowerCase()); +})(/* @__PURE__ */ Object.create(null)), ds = (t) => (t = t.toLowerCase(), (e) => u0(e) === t), f0 = (t) => (e) => typeof e === t, { isArray: Xc } = Array, Ff = f0("undefined"); +function gV(t) { + return t !== null && !Ff(t) && t.constructor !== null && !Ff(t.constructor) && Si(t.constructor.isBuffer) && t.constructor.isBuffer(t); +} +const JE = ds("ArrayBuffer"); +function mV(t) { + let e; + return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? e = ArrayBuffer.isView(t) : e = t && t.buffer && JE(t.buffer), e; +} +const vV = f0("string"), Si = f0("function"), XE = f0("number"), l0 = (t) => t !== null && typeof t == "object", bV = (t) => t === !0 || t === !1, Xh = (t) => { + if (u0(t) !== "object") + return !1; + const e = q1(t); + return (e === null || e === Object.prototype || Object.getPrototypeOf(e) === null) && !(Symbol.toStringTag in t) && !(Symbol.iterator in t); +}, yV = ds("Date"), wV = ds("File"), xV = ds("Blob"), _V = ds("FileList"), EV = (t) => l0(t) && Si(t.pipe), SV = (t) => { + let e; + return t && (typeof FormData == "function" && t instanceof FormData || Si(t.append) && ((e = u0(t)) === "formdata" || // detect form-data instance + e === "object" && Si(t.toString) && t.toString() === "[object FormData]")); +}, AV = ds("URLSearchParams"), [PV, MV, IV, CV] = ["ReadableStream", "Request", "Response", "Headers"].map(ds), RV = (t) => t.trim ? t.trim() : t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""); +function ll(t, e, { allOwnKeys: r = !1 } = {}) { + if (t === null || typeof t > "u") + return; + let n, i; + if (typeof t != "object" && (t = [t]), Xc(t)) + for (n = 0, i = t.length; n < i; n++) + e.call(null, t[n], n, t); + else { + const s = r ? Object.getOwnPropertyNames(t) : Object.keys(t), o = s.length; + let a; + for (n = 0; n < o; n++) + a = s[n], e.call(null, t[a], a, t); + } +} +function ZE(t, e) { + e = e.toLowerCase(); + const r = Object.keys(t); + let n = r.length, i; + for (; n-- > 0; ) + if (i = r[n], e === i.toLowerCase()) + return i; + return null; +} +const Ia = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, QE = (t) => !Ff(t) && t !== Ia; +function xv() { + const { caseless: t } = QE(this) && this || {}, e = {}, r = (n, i) => { + const s = t && ZE(e, i) || i; + Xh(e[s]) && Xh(n) ? e[s] = xv(e[s], n) : Xh(n) ? e[s] = xv({}, n) : Xc(n) ? e[s] = n.slice() : e[s] = n; + }; + for (let n = 0, i = arguments.length; n < i; n++) + arguments[n] && ll(arguments[n], r); + return e; +} +const TV = (t, e, r, { allOwnKeys: n } = {}) => (ll(e, (i, s) => { + r && Si(i) ? t[s] = YE(i, r) : t[s] = i; +}, { allOwnKeys: n }), t), DV = (t) => (t.charCodeAt(0) === 65279 && (t = t.slice(1)), t), OV = (t, e, r, n) => { + t.prototype = Object.create(e.prototype, n), t.prototype.constructor = t, Object.defineProperty(t, "super", { + value: e.prototype + }), r && Object.assign(t.prototype, r); +}, NV = (t, e, r, n) => { + let i, s, o; + const a = {}; + if (e = e || {}, t == null) return e; + do { + for (i = Object.getOwnPropertyNames(t), s = i.length; s-- > 0; ) + o = i[s], (!n || n(o, t, e)) && !a[o] && (e[o] = t[o], a[o] = !0); + t = r !== !1 && q1(t); + } while (t && (!r || r(t, e)) && t !== Object.prototype); + return e; +}, LV = (t, e, r) => { + t = String(t), (r === void 0 || r > t.length) && (r = t.length), r -= e.length; + const n = t.indexOf(e, r); + return n !== -1 && n === r; +}, kV = (t) => { + if (!t) return null; + if (Xc(t)) return t; + let e = t.length; + if (!XE(e)) return null; + const r = new Array(e); + for (; e-- > 0; ) + r[e] = t[e]; + return r; +}, $V = /* @__PURE__ */ ((t) => (e) => t && e instanceof t)(typeof Uint8Array < "u" && q1(Uint8Array)), BV = (t, e) => { + const n = (t && t[Symbol.iterator]).call(t); + let i; + for (; (i = n.next()) && !i.done; ) { + const s = i.value; + e.call(t, s[0], s[1]); + } +}, FV = (t, e) => { + let r; + const n = []; + for (; (r = t.exec(e)) !== null; ) + n.push(r); + return n; +}, jV = ds("HTMLFormElement"), UV = (t) => t.toLowerCase().replace( + /[-_\s]([a-z\d])(\w*)/g, + function(r, n, i) { + return n.toUpperCase() + i; + } +), e6 = (({ hasOwnProperty: t }) => (e, r) => t.call(e, r))(Object.prototype), qV = ds("RegExp"), eS = (t, e) => { + const r = Object.getOwnPropertyDescriptors(t), n = {}; + ll(r, (i, s) => { + let o; + (o = e(i, s, t)) !== !1 && (n[s] = o || i); + }), Object.defineProperties(t, n); +}, zV = (t) => { + eS(t, (e, r) => { + if (Si(t) && ["arguments", "caller", "callee"].indexOf(r) !== -1) + return !1; + const n = t[r]; + if (Si(n)) { + if (e.enumerable = !1, "writable" in e) { + e.writable = !1; + return; + } + e.set || (e.set = () => { + throw Error("Can not rewrite read-only method '" + r + "'"); + }); + } + }); +}, HV = (t, e) => { + const r = {}, n = (i) => { + i.forEach((s) => { + r[s] = !0; + }); + }; + return Xc(t) ? n(t) : n(String(t).split(e)), r; +}, WV = () => { +}, KV = (t, e) => t != null && Number.isFinite(t = +t) ? t : e, pm = "abcdefghijklmnopqrstuvwxyz", t6 = "0123456789", tS = { + DIGIT: t6, + ALPHA: pm, + ALPHA_DIGIT: pm + pm.toUpperCase() + t6 +}, VV = (t = 16, e = tS.ALPHA_DIGIT) => { + let r = ""; + const { length: n } = e; + for (; t--; ) + r += e[Math.random() * n | 0]; + return r; +}; +function GV(t) { + return !!(t && Si(t.append) && t[Symbol.toStringTag] === "FormData" && t[Symbol.iterator]); +} +const YV = (t) => { + const e = new Array(10), r = (n, i) => { + if (l0(n)) { + if (e.indexOf(n) >= 0) + return; + if (!("toJSON" in n)) { + e[i] = n; + const s = Xc(n) ? [] : {}; + return ll(n, (o, a) => { + const f = r(o, i + 1); + !Ff(f) && (s[a] = f); + }), e[i] = void 0, s; + } + } + return n; + }; + return r(t, 0); +}, JV = ds("AsyncFunction"), XV = (t) => t && (l0(t) || Si(t)) && Si(t.then) && Si(t.catch), rS = ((t, e) => t ? setImmediate : e ? ((r, n) => (Ia.addEventListener("message", ({ source: i, data: s }) => { + i === Ia && s === r && n.length && n.shift()(); +}, !1), (i) => { + n.push(i), Ia.postMessage(r, "*"); +}))(`axios@${Math.random()}`, []) : (r) => setTimeout(r))( + typeof setImmediate == "function", + Si(Ia.postMessage) +), ZV = typeof queueMicrotask < "u" ? queueMicrotask.bind(Ia) : typeof process < "u" && process.nextTick || rS, Ne = { + isArray: Xc, + isArrayBuffer: JE, + isBuffer: gV, + isFormData: SV, + isArrayBufferView: mV, + isString: vV, + isNumber: XE, + isBoolean: bV, + isObject: l0, + isPlainObject: Xh, + isReadableStream: PV, + isRequest: MV, + isResponse: IV, + isHeaders: CV, + isUndefined: Ff, + isDate: yV, + isFile: wV, + isBlob: xV, + isRegExp: qV, + isFunction: Si, + isStream: EV, + isURLSearchParams: AV, + isTypedArray: $V, + isFileList: _V, + forEach: ll, + merge: xv, + extend: TV, + trim: RV, + stripBOM: DV, + inherits: OV, + toFlatObject: NV, + kindOf: u0, + kindOfTest: ds, + endsWith: LV, + toArray: kV, + forEachEntry: BV, + matchAll: FV, + isHTMLForm: jV, + hasOwnProperty: e6, + hasOwnProp: e6, + // an alias to avoid ESLint no-prototype-builtins detection + reduceDescriptors: eS, + freezeMethods: zV, + toObjectSet: HV, + toCamelCase: UV, + noop: WV, + toFiniteNumber: KV, + findKey: ZE, + global: Ia, + isContextDefined: QE, + ALPHABET: tS, + generateString: VV, + isSpecCompliantForm: GV, + toJSONObject: YV, + isAsyncFn: JV, + isThenable: XV, + setImmediate: rS, + asap: ZV +}; +function ar(t, e, r, n, i) { + Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = t, this.name = "AxiosError", e && (this.code = e), r && (this.config = r), n && (this.request = n), i && (this.response = i, this.status = i.status ? i.status : null); +} +Ne.inherits(ar, Error, { + toJSON: function() { + return { + // Standard + message: this.message, + name: this.name, + // Microsoft + description: this.description, + number: this.number, + // Mozilla + fileName: this.fileName, + lineNumber: this.lineNumber, + columnNumber: this.columnNumber, + stack: this.stack, + // Axios + config: Ne.toJSONObject(this.config), + code: this.code, + status: this.status + }; + } +}); +const nS = ar.prototype, iS = {}; +[ + "ERR_BAD_OPTION_VALUE", + "ERR_BAD_OPTION", + "ECONNABORTED", + "ETIMEDOUT", + "ERR_NETWORK", + "ERR_FR_TOO_MANY_REDIRECTS", + "ERR_DEPRECATED", + "ERR_BAD_RESPONSE", + "ERR_BAD_REQUEST", + "ERR_CANCELED", + "ERR_NOT_SUPPORT", + "ERR_INVALID_URL" + // eslint-disable-next-line func-names +].forEach((t) => { + iS[t] = { value: t }; +}); +Object.defineProperties(ar, iS); +Object.defineProperty(nS, "isAxiosError", { value: !0 }); +ar.from = (t, e, r, n, i, s) => { + const o = Object.create(nS); + return Ne.toFlatObject(t, o, function(f) { + return f !== Error.prototype; + }, (a) => a !== "isAxiosError"), ar.call(o, t.message, e, r, n, i), o.cause = t, o.name = t.name, s && Object.assign(o, s), o; +}; +const QV = null; +function _v(t) { + return Ne.isPlainObject(t) || Ne.isArray(t); +} +function sS(t) { + return Ne.endsWith(t, "[]") ? t.slice(0, -2) : t; +} +function r6(t, e, r) { + return t ? t.concat(e).map(function(i, s) { + return i = sS(i), !r && s ? "[" + i + "]" : i; + }).join(r ? "." : "") : e; +} +function eG(t) { + return Ne.isArray(t) && !t.some(_v); +} +const tG = Ne.toFlatObject(Ne, {}, null, function(e) { + return /^is[A-Z]/.test(e); +}); +function h0(t, e, r) { + if (!Ne.isObject(t)) + throw new TypeError("target must be an object"); + e = e || new FormData(), r = Ne.toFlatObject(r, { + metaTokens: !0, + dots: !1, + indexes: !1 + }, !1, function(R, D) { + return !Ne.isUndefined(D[R]); + }); + const n = r.metaTokens, i = r.visitor || h, s = r.dots, o = r.indexes, f = (r.Blob || typeof Blob < "u" && Blob) && Ne.isSpecCompliantForm(e); + if (!Ne.isFunction(i)) + throw new TypeError("visitor must be a function"); + function u(S) { + if (S === null) return ""; + if (Ne.isDate(S)) + return S.toISOString(); + if (!f && Ne.isBlob(S)) + throw new ar("Blob is not supported. Use a Buffer instead."); + return Ne.isArrayBuffer(S) || Ne.isTypedArray(S) ? f && typeof Blob == "function" ? new Blob([S]) : Buffer.from(S) : S; + } + function h(S, R, D) { + let k = S; + if (S && !D && typeof S == "object") { + if (Ne.endsWith(R, "{}")) + R = n ? R : R.slice(0, -2), S = JSON.stringify(S); + else if (Ne.isArray(S) && eG(S) || (Ne.isFileList(S) || Ne.endsWith(R, "[]")) && (k = Ne.toArray(S))) + return R = sS(R), k.forEach(function(z, B) { + !(Ne.isUndefined(z) || z === null) && e.append( + // eslint-disable-next-line no-nested-ternary + o === !0 ? r6([R], B, s) : o === null ? R : R + "[]", + u(z) + ); + }), !1; + } + return _v(S) ? !0 : (e.append(r6(D, R, s), u(S)), !1); + } + const g = [], v = Object.assign(tG, { + defaultVisitor: h, + convertValue: u, + isVisitable: _v + }); + function x(S, R) { + if (!Ne.isUndefined(S)) { + if (g.indexOf(S) !== -1) + throw Error("Circular reference detected in " + R.join(".")); + g.push(S), Ne.forEach(S, function(k, N) { + (!(Ne.isUndefined(k) || k === null) && i.call( + e, + k, + Ne.isString(N) ? N.trim() : N, + R, + v + )) === !0 && x(k, R ? R.concat(N) : [N]); + }), g.pop(); + } + } + if (!Ne.isObject(t)) + throw new TypeError("data must be an object"); + return x(t), e; +} +function n6(t) { + const e = { + "!": "%21", + "'": "%27", + "(": "%28", + ")": "%29", + "~": "%7E", + "%20": "+", + "%00": "\0" + }; + return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g, function(n) { + return e[n]; + }); +} +function z1(t, e) { + this._pairs = [], t && h0(t, this, e); +} +const oS = z1.prototype; +oS.append = function(e, r) { + this._pairs.push([e, r]); +}; +oS.toString = function(e) { + const r = e ? function(n) { + return e.call(this, n, n6); + } : n6; + return this._pairs.map(function(i) { + return r(i[0]) + "=" + r(i[1]); + }, "").join("&"); +}; +function rG(t) { + return encodeURIComponent(t).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]"); +} +function aS(t, e, r) { + if (!e) + return t; + const n = r && r.encode || rG; + Ne.isFunction(r) && (r = { + serialize: r + }); + const i = r && r.serialize; + let s; + if (i ? s = i(e, r) : s = Ne.isURLSearchParams(e) ? e.toString() : new z1(e, r).toString(n), s) { + const o = t.indexOf("#"); + o !== -1 && (t = t.slice(0, o)), t += (t.indexOf("?") === -1 ? "?" : "&") + s; + } + return t; +} +class i6 { + constructor() { + this.handlers = []; + } + /** + * Add a new interceptor to the stack + * + * @param {Function} fulfilled The function to handle `then` for a `Promise` + * @param {Function} rejected The function to handle `reject` for a `Promise` + * + * @return {Number} An ID used to remove interceptor later + */ + use(e, r, n) { + return this.handlers.push({ + fulfilled: e, + rejected: r, + synchronous: n ? n.synchronous : !1, + runWhen: n ? n.runWhen : null + }), this.handlers.length - 1; + } + /** + * Remove an interceptor from the stack + * + * @param {Number} id The ID that was returned by `use` + * + * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise + */ + eject(e) { + this.handlers[e] && (this.handlers[e] = null); + } + /** + * Clear all interceptors from the stack + * + * @returns {void} + */ + clear() { + this.handlers && (this.handlers = []); + } + /** + * Iterate over all the registered interceptors + * + * This method is particularly useful for skipping over any + * interceptors that may have become `null` calling `eject`. + * + * @param {Function} fn The function to call for each interceptor + * + * @returns {void} + */ + forEach(e) { + Ne.forEach(this.handlers, function(n) { + n !== null && e(n); + }); + } +} +const cS = { + silentJSONParsing: !0, + forcedJSONParsing: !0, + clarifyTimeoutError: !1 +}, nG = typeof URLSearchParams < "u" ? URLSearchParams : z1, iG = typeof FormData < "u" ? FormData : null, sG = typeof Blob < "u" ? Blob : null, oG = { + isBrowser: !0, + classes: { + URLSearchParams: nG, + FormData: iG, + Blob: sG + }, + protocols: ["http", "https", "file", "blob", "url", "data"] +}, H1 = typeof window < "u" && typeof document < "u", Ev = typeof navigator == "object" && navigator || void 0, aG = H1 && (!Ev || ["ReactNative", "NativeScript", "NS"].indexOf(Ev.product) < 0), cG = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef +self instanceof WorkerGlobalScope && typeof self.importScripts == "function", uG = H1 && window.location.href || "http://localhost", fG = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ + __proto__: null, + hasBrowserEnv: H1, + hasStandardBrowserEnv: aG, + hasStandardBrowserWebWorkerEnv: cG, + navigator: Ev, + origin: uG +}, Symbol.toStringTag, { value: "Module" })), zn = { + ...fG, + ...oG +}; +function lG(t, e) { + return h0(t, new zn.classes.URLSearchParams(), Object.assign({ + visitor: function(r, n, i, s) { + return zn.isNode && Ne.isBuffer(r) ? (this.append(n, r.toString("base64")), !1) : s.defaultVisitor.apply(this, arguments); + } + }, e)); +} +function hG(t) { + return Ne.matchAll(/\w+|\[(\w*)]/g, t).map((e) => e[0] === "[]" ? "" : e[1] || e[0]); +} +function dG(t) { + const e = {}, r = Object.keys(t); + let n; + const i = r.length; + let s; + for (n = 0; n < i; n++) + s = r[n], e[s] = t[s]; + return e; +} +function uS(t) { + function e(r, n, i, s) { + let o = r[s++]; + if (o === "__proto__") return !0; + const a = Number.isFinite(+o), f = s >= r.length; + return o = !o && Ne.isArray(i) ? i.length : o, f ? (Ne.hasOwnProp(i, o) ? i[o] = [i[o], n] : i[o] = n, !a) : ((!i[o] || !Ne.isObject(i[o])) && (i[o] = []), e(r, n, i[o], s) && Ne.isArray(i[o]) && (i[o] = dG(i[o])), !a); + } + if (Ne.isFormData(t) && Ne.isFunction(t.entries)) { + const r = {}; + return Ne.forEachEntry(t, (n, i) => { + e(hG(n), i, r, 0); + }), r; + } + return null; +} +function pG(t, e, r) { + if (Ne.isString(t)) + try { + return (e || JSON.parse)(t), Ne.trim(t); + } catch (n) { + if (n.name !== "SyntaxError") + throw n; + } + return (r || JSON.stringify)(t); +} +const hl = { + transitional: cS, + adapter: ["xhr", "http", "fetch"], + transformRequest: [function(e, r) { + const n = r.getContentType() || "", i = n.indexOf("application/json") > -1, s = Ne.isObject(e); + if (s && Ne.isHTMLForm(e) && (e = new FormData(e)), Ne.isFormData(e)) + return i ? JSON.stringify(uS(e)) : e; + if (Ne.isArrayBuffer(e) || Ne.isBuffer(e) || Ne.isStream(e) || Ne.isFile(e) || Ne.isBlob(e) || Ne.isReadableStream(e)) + return e; + if (Ne.isArrayBufferView(e)) + return e.buffer; + if (Ne.isURLSearchParams(e)) + return r.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), e.toString(); + let a; + if (s) { + if (n.indexOf("application/x-www-form-urlencoded") > -1) + return lG(e, this.formSerializer).toString(); + if ((a = Ne.isFileList(e)) || n.indexOf("multipart/form-data") > -1) { + const f = this.env && this.env.FormData; + return h0( + a ? { "files[]": e } : e, + f && new f(), + this.formSerializer + ); + } + } + return s || i ? (r.setContentType("application/json", !1), pG(e)) : e; + }], + transformResponse: [function(e) { + const r = this.transitional || hl.transitional, n = r && r.forcedJSONParsing, i = this.responseType === "json"; + if (Ne.isResponse(e) || Ne.isReadableStream(e)) + return e; + if (e && Ne.isString(e) && (n && !this.responseType || i)) { + const o = !(r && r.silentJSONParsing) && i; + try { + return JSON.parse(e); + } catch (a) { + if (o) + throw a.name === "SyntaxError" ? ar.from(a, ar.ERR_BAD_RESPONSE, this, null, this.response) : a; + } + } + return e; + }], + /** + * A timeout in milliseconds to abort a request. If set to 0 (default) a + * timeout is not created. + */ + timeout: 0, + xsrfCookieName: "XSRF-TOKEN", + xsrfHeaderName: "X-XSRF-TOKEN", + maxContentLength: -1, + maxBodyLength: -1, + env: { + FormData: zn.classes.FormData, + Blob: zn.classes.Blob + }, + validateStatus: function(e) { + return e >= 200 && e < 300; + }, + headers: { + common: { + Accept: "application/json, text/plain, */*", + "Content-Type": void 0 + } + } +}; +Ne.forEach(["delete", "get", "head", "post", "put", "patch"], (t) => { + hl.headers[t] = {}; +}); +const gG = Ne.toObjectSet([ + "age", + "authorization", + "content-length", + "content-type", + "etag", + "expires", + "from", + "host", + "if-modified-since", + "if-unmodified-since", + "last-modified", + "location", + "max-forwards", + "proxy-authorization", + "referer", + "retry-after", + "user-agent" +]), mG = (t) => { + const e = {}; + let r, n, i; + return t && t.split(` +`).forEach(function(o) { + i = o.indexOf(":"), r = o.substring(0, i).trim().toLowerCase(), n = o.substring(i + 1).trim(), !(!r || e[r] && gG[r]) && (r === "set-cookie" ? e[r] ? e[r].push(n) : e[r] = [n] : e[r] = e[r] ? e[r] + ", " + n : n); + }), e; +}, s6 = Symbol("internals"); +function Uu(t) { + return t && String(t).trim().toLowerCase(); +} +function Zh(t) { + return t === !1 || t == null ? t : Ne.isArray(t) ? t.map(Zh) : String(t); +} +function vG(t) { + const e = /* @__PURE__ */ Object.create(null), r = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g; + let n; + for (; n = r.exec(t); ) + e[n[1]] = n[2]; + return e; +} +const bG = (t) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim()); +function gm(t, e, r, n, i) { + if (Ne.isFunction(n)) + return n.call(this, e, r); + if (i && (e = r), !!Ne.isString(e)) { + if (Ne.isString(n)) + return e.indexOf(n) !== -1; + if (Ne.isRegExp(n)) + return n.test(e); + } +} +function yG(t) { + return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (e, r, n) => r.toUpperCase() + n); +} +function wG(t, e) { + const r = Ne.toCamelCase(" " + e); + ["get", "set", "has"].forEach((n) => { + Object.defineProperty(t, n + r, { + value: function(i, s, o) { + return this[n].call(this, e, i, s, o); + }, + configurable: !0 + }); + }); +} +let li = class { + constructor(e) { + e && this.set(e); + } + set(e, r, n) { + const i = this; + function s(a, f, u) { + const h = Uu(f); + if (!h) + throw new Error("header name must be a non-empty string"); + const g = Ne.findKey(i, h); + (!g || i[g] === void 0 || u === !0 || u === void 0 && i[g] !== !1) && (i[g || f] = Zh(a)); + } + const o = (a, f) => Ne.forEach(a, (u, h) => s(u, h, f)); + if (Ne.isPlainObject(e) || e instanceof this.constructor) + o(e, r); + else if (Ne.isString(e) && (e = e.trim()) && !bG(e)) + o(mG(e), r); + else if (Ne.isHeaders(e)) + for (const [a, f] of e.entries()) + s(f, a, n); + else + e != null && s(r, e, n); + return this; + } + get(e, r) { + if (e = Uu(e), e) { + const n = Ne.findKey(this, e); + if (n) { + const i = this[n]; + if (!r) + return i; + if (r === !0) + return vG(i); + if (Ne.isFunction(r)) + return r.call(this, i, n); + if (Ne.isRegExp(r)) + return r.exec(i); + throw new TypeError("parser must be boolean|regexp|function"); + } + } + } + has(e, r) { + if (e = Uu(e), e) { + const n = Ne.findKey(this, e); + return !!(n && this[n] !== void 0 && (!r || gm(this, this[n], n, r))); + } + return !1; + } + delete(e, r) { + const n = this; + let i = !1; + function s(o) { + if (o = Uu(o), o) { + const a = Ne.findKey(n, o); + a && (!r || gm(n, n[a], a, r)) && (delete n[a], i = !0); + } + } + return Ne.isArray(e) ? e.forEach(s) : s(e), i; + } + clear(e) { + const r = Object.keys(this); + let n = r.length, i = !1; + for (; n--; ) { + const s = r[n]; + (!e || gm(this, this[s], s, e, !0)) && (delete this[s], i = !0); + } + return i; + } + normalize(e) { + const r = this, n = {}; + return Ne.forEach(this, (i, s) => { + const o = Ne.findKey(n, s); + if (o) { + r[o] = Zh(i), delete r[s]; + return; + } + const a = e ? yG(s) : String(s).trim(); + a !== s && delete r[s], r[a] = Zh(i), n[a] = !0; + }), this; + } + concat(...e) { + return this.constructor.concat(this, ...e); + } + toJSON(e) { + const r = /* @__PURE__ */ Object.create(null); + return Ne.forEach(this, (n, i) => { + n != null && n !== !1 && (r[i] = e && Ne.isArray(n) ? n.join(", ") : n); + }), r; + } + [Symbol.iterator]() { + return Object.entries(this.toJSON())[Symbol.iterator](); + } + toString() { + return Object.entries(this.toJSON()).map(([e, r]) => e + ": " + r).join(` +`); + } + get [Symbol.toStringTag]() { + return "AxiosHeaders"; + } + static from(e) { + return e instanceof this ? e : new this(e); + } + static concat(e, ...r) { + const n = new this(e); + return r.forEach((i) => n.set(i)), n; + } + static accessor(e) { + const n = (this[s6] = this[s6] = { + accessors: {} + }).accessors, i = this.prototype; + function s(o) { + const a = Uu(o); + n[a] || (wG(i, o), n[a] = !0); + } + return Ne.isArray(e) ? e.forEach(s) : s(e), this; + } +}; +li.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]); +Ne.reduceDescriptors(li.prototype, ({ value: t }, e) => { + let r = e[0].toUpperCase() + e.slice(1); + return { + get: () => t, + set(n) { + this[r] = n; + } + }; +}); +Ne.freezeMethods(li); +function mm(t, e) { + const r = this || hl, n = e || r, i = li.from(n.headers); + let s = n.data; + return Ne.forEach(t, function(a) { + s = a.call(r, s, i.normalize(), e ? e.status : void 0); + }), i.normalize(), s; +} +function fS(t) { + return !!(t && t.__CANCEL__); +} +function Zc(t, e, r) { + ar.call(this, t ?? "canceled", ar.ERR_CANCELED, e, r), this.name = "CanceledError"; +} +Ne.inherits(Zc, ar, { + __CANCEL__: !0 +}); +function lS(t, e, r) { + const n = r.config.validateStatus; + !r.status || !n || n(r.status) ? t(r) : e(new ar( + "Request failed with status code " + r.status, + [ar.ERR_BAD_REQUEST, ar.ERR_BAD_RESPONSE][Math.floor(r.status / 100) - 4], + r.config, + r.request, + r + )); +} +function xG(t) { + const e = /^([-+\w]{1,25})(:?\/\/|:)/.exec(t); + return e && e[1] || ""; +} +function _G(t, e) { + t = t || 10; + const r = new Array(t), n = new Array(t); + let i = 0, s = 0, o; + return e = e !== void 0 ? e : 1e3, function(f) { + const u = Date.now(), h = n[s]; + o || (o = u), r[i] = f, n[i] = u; + let g = s, v = 0; + for (; g !== i; ) + v += r[g++], g = g % t; + if (i = (i + 1) % t, i === s && (s = (s + 1) % t), u - o < e) + return; + const x = h && u - h; + return x ? Math.round(v * 1e3 / x) : void 0; + }; +} +function EG(t, e) { + let r = 0, n = 1e3 / e, i, s; + const o = (u, h = Date.now()) => { + r = h, i = null, s && (clearTimeout(s), s = null), t.apply(null, u); + }; + return [(...u) => { + const h = Date.now(), g = h - r; + g >= n ? o(u, h) : (i = u, s || (s = setTimeout(() => { + s = null, o(i); + }, n - g))); + }, () => i && o(i)]; +} +const Pd = (t, e, r = 3) => { + let n = 0; + const i = _G(50, 250); + return EG((s) => { + const o = s.loaded, a = s.lengthComputable ? s.total : void 0, f = o - n, u = i(f), h = o <= a; + n = o; + const g = { + loaded: o, + total: a, + progress: a ? o / a : void 0, + bytes: f, + rate: u || void 0, + estimated: u && a && h ? (a - o) / u : void 0, + event: s, + lengthComputable: a != null, + [e ? "download" : "upload"]: !0 + }; + t(g); + }, r); +}, o6 = (t, e) => { + const r = t != null; + return [(n) => e[0]({ + lengthComputable: r, + total: t, + loaded: n + }), e[1]]; +}, a6 = (t) => (...e) => Ne.asap(() => t(...e)), SG = zn.hasStandardBrowserEnv ? /* @__PURE__ */ ((t, e) => (r) => (r = new URL(r, zn.origin), t.protocol === r.protocol && t.host === r.host && (e || t.port === r.port)))( + new URL(zn.origin), + zn.navigator && /(msie|trident)/i.test(zn.navigator.userAgent) +) : () => !0, AG = zn.hasStandardBrowserEnv ? ( + // Standard browser envs support document.cookie + { + write(t, e, r, n, i, s) { + const o = [t + "=" + encodeURIComponent(e)]; + Ne.isNumber(r) && o.push("expires=" + new Date(r).toGMTString()), Ne.isString(n) && o.push("path=" + n), Ne.isString(i) && o.push("domain=" + i), s === !0 && o.push("secure"), document.cookie = o.join("; "); + }, + read(t) { + const e = document.cookie.match(new RegExp("(^|;\\s*)(" + t + ")=([^;]*)")); + return e ? decodeURIComponent(e[3]) : null; + }, + remove(t) { + this.write(t, "", Date.now() - 864e5); + } + } +) : ( + // Non-standard browser env (web workers, react-native) lack needed support. + { + write() { + }, + read() { + return null; + }, + remove() { + } + } +); +function PG(t) { + return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t); +} +function MG(t, e) { + return e ? t.replace(/\/?\/$/, "") + "/" + e.replace(/^\/+/, "") : t; +} +function hS(t, e) { + return t && !PG(e) ? MG(t, e) : e; +} +const c6 = (t) => t instanceof li ? { ...t } : t; +function Fa(t, e) { + e = e || {}; + const r = {}; + function n(u, h, g, v) { + return Ne.isPlainObject(u) && Ne.isPlainObject(h) ? Ne.merge.call({ caseless: v }, u, h) : Ne.isPlainObject(h) ? Ne.merge({}, h) : Ne.isArray(h) ? h.slice() : h; + } + function i(u, h, g, v) { + if (Ne.isUndefined(h)) { + if (!Ne.isUndefined(u)) + return n(void 0, u, g, v); + } else return n(u, h, g, v); + } + function s(u, h) { + if (!Ne.isUndefined(h)) + return n(void 0, h); + } + function o(u, h) { + if (Ne.isUndefined(h)) { + if (!Ne.isUndefined(u)) + return n(void 0, u); + } else return n(void 0, h); + } + function a(u, h, g) { + if (g in e) + return n(u, h); + if (g in t) + return n(void 0, u); + } + const f = { + url: s, + method: s, + data: s, + baseURL: o, + transformRequest: o, + transformResponse: o, + paramsSerializer: o, + timeout: o, + timeoutMessage: o, + withCredentials: o, + withXSRFToken: o, + adapter: o, + responseType: o, + xsrfCookieName: o, + xsrfHeaderName: o, + onUploadProgress: o, + onDownloadProgress: o, + decompress: o, + maxContentLength: o, + maxBodyLength: o, + beforeRedirect: o, + transport: o, + httpAgent: o, + httpsAgent: o, + cancelToken: o, + socketPath: o, + responseEncoding: o, + validateStatus: a, + headers: (u, h, g) => i(c6(u), c6(h), g, !0) + }; + return Ne.forEach(Object.keys(Object.assign({}, t, e)), function(h) { + const g = f[h] || i, v = g(t[h], e[h], h); + Ne.isUndefined(v) && g !== a || (r[h] = v); + }), r; +} +const dS = (t) => { + const e = Fa({}, t); + let { data: r, withXSRFToken: n, xsrfHeaderName: i, xsrfCookieName: s, headers: o, auth: a } = e; + e.headers = o = li.from(o), e.url = aS(hS(e.baseURL, e.url), t.params, t.paramsSerializer), a && o.set( + "Authorization", + "Basic " + btoa((a.username || "") + ":" + (a.password ? unescape(encodeURIComponent(a.password)) : "")) + ); + let f; + if (Ne.isFormData(r)) { + if (zn.hasStandardBrowserEnv || zn.hasStandardBrowserWebWorkerEnv) + o.setContentType(void 0); + else if ((f = o.getContentType()) !== !1) { + const [u, ...h] = f ? f.split(";").map((g) => g.trim()).filter(Boolean) : []; + o.setContentType([u || "multipart/form-data", ...h].join("; ")); + } + } + if (zn.hasStandardBrowserEnv && (n && Ne.isFunction(n) && (n = n(e)), n || n !== !1 && SG(e.url))) { + const u = i && s && AG.read(s); + u && o.set(i, u); + } + return e; +}, IG = typeof XMLHttpRequest < "u", CG = IG && function(t) { + return new Promise(function(r, n) { + const i = dS(t); + let s = i.data; + const o = li.from(i.headers).normalize(); + let { responseType: a, onUploadProgress: f, onDownloadProgress: u } = i, h, g, v, x, S; + function R() { + x && x(), S && S(), i.cancelToken && i.cancelToken.unsubscribe(h), i.signal && i.signal.removeEventListener("abort", h); + } + let D = new XMLHttpRequest(); + D.open(i.method.toUpperCase(), i.url, !0), D.timeout = i.timeout; + function k() { + if (!D) + return; + const z = li.from( + "getAllResponseHeaders" in D && D.getAllResponseHeaders() + ), $ = { + data: !a || a === "text" || a === "json" ? D.responseText : D.response, + status: D.status, + statusText: D.statusText, + headers: z, + config: t, + request: D + }; + lS(function(C) { + r(C), R(); + }, function(C) { + n(C), R(); + }, $), D = null; + } + "onloadend" in D ? D.onloadend = k : D.onreadystatechange = function() { + !D || D.readyState !== 4 || D.status === 0 && !(D.responseURL && D.responseURL.indexOf("file:") === 0) || setTimeout(k); + }, D.onabort = function() { + D && (n(new ar("Request aborted", ar.ECONNABORTED, t, D)), D = null); + }, D.onerror = function() { + n(new ar("Network Error", ar.ERR_NETWORK, t, D)), D = null; + }, D.ontimeout = function() { + let B = i.timeout ? "timeout of " + i.timeout + "ms exceeded" : "timeout exceeded"; + const $ = i.transitional || cS; + i.timeoutErrorMessage && (B = i.timeoutErrorMessage), n(new ar( + B, + $.clarifyTimeoutError ? ar.ETIMEDOUT : ar.ECONNABORTED, + t, + D + )), D = null; + }, s === void 0 && o.setContentType(null), "setRequestHeader" in D && Ne.forEach(o.toJSON(), function(B, $) { + D.setRequestHeader($, B); + }), Ne.isUndefined(i.withCredentials) || (D.withCredentials = !!i.withCredentials), a && a !== "json" && (D.responseType = i.responseType), u && ([v, S] = Pd(u, !0), D.addEventListener("progress", v)), f && D.upload && ([g, x] = Pd(f), D.upload.addEventListener("progress", g), D.upload.addEventListener("loadend", x)), (i.cancelToken || i.signal) && (h = (z) => { + D && (n(!z || z.type ? new Zc(null, t, D) : z), D.abort(), D = null); + }, i.cancelToken && i.cancelToken.subscribe(h), i.signal && (i.signal.aborted ? h() : i.signal.addEventListener("abort", h))); + const N = xG(i.url); + if (N && zn.protocols.indexOf(N) === -1) { + n(new ar("Unsupported protocol " + N + ":", ar.ERR_BAD_REQUEST, t)); + return; + } + D.send(s || null); + }); +}, RG = (t, e) => { + const { length: r } = t = t ? t.filter(Boolean) : []; + if (e || r) { + let n = new AbortController(), i; + const s = function(u) { + if (!i) { + i = !0, a(); + const h = u instanceof Error ? u : this.reason; + n.abort(h instanceof ar ? h : new Zc(h instanceof Error ? h.message : h)); + } + }; + let o = e && setTimeout(() => { + o = null, s(new ar(`timeout ${e} of ms exceeded`, ar.ETIMEDOUT)); + }, e); + const a = () => { + t && (o && clearTimeout(o), o = null, t.forEach((u) => { + u.unsubscribe ? u.unsubscribe(s) : u.removeEventListener("abort", s); + }), t = null); + }; + t.forEach((u) => u.addEventListener("abort", s)); + const { signal: f } = n; + return f.unsubscribe = () => Ne.asap(a), f; + } +}, TG = function* (t, e) { + let r = t.byteLength; + if (r < e) { + yield t; + return; + } + let n = 0, i; + for (; n < r; ) + i = n + e, yield t.slice(n, i), n = i; +}, DG = async function* (t, e) { + for await (const r of OG(t)) + yield* TG(r, e); +}, OG = async function* (t) { + if (t[Symbol.asyncIterator]) { + yield* t; + return; + } + const e = t.getReader(); + try { + for (; ; ) { + const { done: r, value: n } = await e.read(); + if (r) + break; + yield n; + } + } finally { + await e.cancel(); + } +}, u6 = (t, e, r, n) => { + const i = DG(t, e); + let s = 0, o, a = (f) => { + o || (o = !0, n && n(f)); + }; + return new ReadableStream({ + async pull(f) { + try { + const { done: u, value: h } = await i.next(); + if (u) { + a(), f.close(); + return; + } + let g = h.byteLength; + if (r) { + let v = s += g; + r(v); + } + f.enqueue(new Uint8Array(h)); + } catch (u) { + throw a(u), u; + } + }, + cancel(f) { + return a(f), i.return(); + } + }, { + highWaterMark: 2 + }); +}, d0 = typeof fetch == "function" && typeof Request == "function" && typeof Response == "function", pS = d0 && typeof ReadableStream == "function", NG = d0 && (typeof TextEncoder == "function" ? /* @__PURE__ */ ((t) => (e) => t.encode(e))(new TextEncoder()) : async (t) => new Uint8Array(await new Response(t).arrayBuffer())), gS = (t, ...e) => { + try { + return !!t(...e); + } catch { + return !1; + } +}, LG = pS && gS(() => { + let t = !1; + const e = new Request(zn.origin, { + body: new ReadableStream(), + method: "POST", + get duplex() { + return t = !0, "half"; + } + }).headers.has("Content-Type"); + return t && !e; +}), f6 = 64 * 1024, Sv = pS && gS(() => Ne.isReadableStream(new Response("").body)), Md = { + stream: Sv && ((t) => t.body) +}; +d0 && ((t) => { + ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((e) => { + !Md[e] && (Md[e] = Ne.isFunction(t[e]) ? (r) => r[e]() : (r, n) => { + throw new ar(`Response type '${e}' is not supported`, ar.ERR_NOT_SUPPORT, n); + }); + }); +})(new Response()); +const kG = async (t) => { + if (t == null) + return 0; + if (Ne.isBlob(t)) + return t.size; + if (Ne.isSpecCompliantForm(t)) + return (await new Request(zn.origin, { + method: "POST", + body: t + }).arrayBuffer()).byteLength; + if (Ne.isArrayBufferView(t) || Ne.isArrayBuffer(t)) + return t.byteLength; + if (Ne.isURLSearchParams(t) && (t = t + ""), Ne.isString(t)) + return (await NG(t)).byteLength; +}, $G = async (t, e) => { + const r = Ne.toFiniteNumber(t.getContentLength()); + return r ?? kG(e); +}, BG = d0 && (async (t) => { + let { + url: e, + method: r, + data: n, + signal: i, + cancelToken: s, + timeout: o, + onDownloadProgress: a, + onUploadProgress: f, + responseType: u, + headers: h, + withCredentials: g = "same-origin", + fetchOptions: v + } = dS(t); + u = u ? (u + "").toLowerCase() : "text"; + let x = RG([i, s && s.toAbortSignal()], o), S; + const R = x && x.unsubscribe && (() => { + x.unsubscribe(); + }); + let D; + try { + if (f && LG && r !== "get" && r !== "head" && (D = await $G(h, n)) !== 0) { + let $ = new Request(e, { + method: "POST", + body: n, + duplex: "half" + }), U; + if (Ne.isFormData(n) && (U = $.headers.get("content-type")) && h.setContentType(U), $.body) { + const [C, W] = o6( + D, + Pd(a6(f)) + ); + n = u6($.body, f6, C, W); + } + } + Ne.isString(g) || (g = g ? "include" : "omit"); + const k = "credentials" in Request.prototype; + S = new Request(e, { + ...v, + signal: x, + method: r.toUpperCase(), + headers: h.normalize().toJSON(), + body: n, + duplex: "half", + credentials: k ? g : void 0 + }); + let N = await fetch(S); + const z = Sv && (u === "stream" || u === "response"); + if (Sv && (a || z && R)) { + const $ = {}; + ["status", "statusText", "headers"].forEach((J) => { + $[J] = N[J]; + }); + const U = Ne.toFiniteNumber(N.headers.get("content-length")), [C, W] = a && o6( + U, + Pd(a6(a), !0) + ) || []; + N = new Response( + u6(N.body, f6, C, () => { + W && W(), R && R(); + }), + $ + ); + } + u = u || "text"; + let B = await Md[Ne.findKey(Md, u) || "text"](N, t); + return !z && R && R(), await new Promise(($, U) => { + lS($, U, { + data: B, + headers: li.from(N.headers), + status: N.status, + statusText: N.statusText, + config: t, + request: S + }); + }); + } catch (k) { + throw R && R(), k && k.name === "TypeError" && /fetch/i.test(k.message) ? Object.assign( + new ar("Network Error", ar.ERR_NETWORK, t, S), + { + cause: k.cause || k + } + ) : ar.from(k, k && k.code, t, S); + } +}), Av = { + http: QV, + xhr: CG, + fetch: BG +}; +Ne.forEach(Av, (t, e) => { + if (t) { + try { + Object.defineProperty(t, "name", { value: e }); + } catch { + } + Object.defineProperty(t, "adapterName", { value: e }); + } +}); +const l6 = (t) => `- ${t}`, FG = (t) => Ne.isFunction(t) || t === null || t === !1, mS = { + getAdapter: (t) => { + t = Ne.isArray(t) ? t : [t]; + const { length: e } = t; + let r, n; + const i = {}; + for (let s = 0; s < e; s++) { + r = t[s]; + let o; + if (n = r, !FG(r) && (n = Av[(o = String(r)).toLowerCase()], n === void 0)) + throw new ar(`Unknown adapter '${o}'`); + if (n) + break; + i[o || "#" + s] = n; + } + if (!n) { + const s = Object.entries(i).map( + ([a, f]) => `adapter ${a} ` + (f === !1 ? "is not supported by the environment" : "is not available in the build") + ); + let o = e ? s.length > 1 ? `since : +` + s.map(l6).join(` +`) : " " + l6(s[0]) : "as no adapter specified"; + throw new ar( + "There is no suitable adapter to dispatch the request " + o, + "ERR_NOT_SUPPORT" + ); + } + return n; + }, + adapters: Av +}; +function vm(t) { + if (t.cancelToken && t.cancelToken.throwIfRequested(), t.signal && t.signal.aborted) + throw new Zc(null, t); +} +function h6(t) { + return vm(t), t.headers = li.from(t.headers), t.data = mm.call( + t, + t.transformRequest + ), ["post", "put", "patch"].indexOf(t.method) !== -1 && t.headers.setContentType("application/x-www-form-urlencoded", !1), mS.getAdapter(t.adapter || hl.adapter)(t).then(function(n) { + return vm(t), n.data = mm.call( + t, + t.transformResponse, + n + ), n.headers = li.from(n.headers), n; + }, function(n) { + return fS(n) || (vm(t), n && n.response && (n.response.data = mm.call( + t, + t.transformResponse, + n.response + ), n.response.headers = li.from(n.response.headers))), Promise.reject(n); + }); +} +const vS = "1.7.8", p0 = {}; +["object", "boolean", "number", "function", "string", "symbol"].forEach((t, e) => { + p0[t] = function(n) { + return typeof n === t || "a" + (e < 1 ? "n " : " ") + t; + }; +}); +const d6 = {}; +p0.transitional = function(e, r, n) { + function i(s, o) { + return "[Axios v" + vS + "] Transitional option '" + s + "'" + o + (n ? ". " + n : ""); + } + return (s, o, a) => { + if (e === !1) + throw new ar( + i(o, " has been removed" + (r ? " in " + r : "")), + ar.ERR_DEPRECATED + ); + return r && !d6[o] && (d6[o] = !0, console.warn( + i( + o, + " has been deprecated since v" + r + " and will be removed in the near future" + ) + )), e ? e(s, o, a) : !0; + }; +}; +p0.spelling = function(e) { + return (r, n) => (console.warn(`${n} is likely a misspelling of ${e}`), !0); +}; +function jG(t, e, r) { + if (typeof t != "object") + throw new ar("options must be an object", ar.ERR_BAD_OPTION_VALUE); + const n = Object.keys(t); + let i = n.length; + for (; i-- > 0; ) { + const s = n[i], o = e[s]; + if (o) { + const a = t[s], f = a === void 0 || o(a, s, t); + if (f !== !0) + throw new ar("option " + s + " must be " + f, ar.ERR_BAD_OPTION_VALUE); + continue; + } + if (r !== !0) + throw new ar("Unknown option " + s, ar.ERR_BAD_OPTION); + } +} +const Qh = { + assertOptions: jG, + validators: p0 +}, Ss = Qh.validators; +let Ra = class { + constructor(e) { + this.defaults = e, this.interceptors = { + request: new i6(), + response: new i6() + }; + } + /** + * Dispatch a request + * + * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults) + * @param {?Object} config + * + * @returns {Promise} The Promise to be fulfilled + */ + async request(e, r) { + try { + return await this._request(e, r); + } catch (n) { + if (n instanceof Error) { + let i = {}; + Error.captureStackTrace ? Error.captureStackTrace(i) : i = new Error(); + const s = i.stack ? i.stack.replace(/^.+\n/, "") : ""; + try { + n.stack ? s && !String(n.stack).endsWith(s.replace(/^.+\n.+\n/, "")) && (n.stack += ` +` + s) : n.stack = s; + } catch { + } + } + throw n; + } + } + _request(e, r) { + typeof e == "string" ? (r = r || {}, r.url = e) : r = e || {}, r = Fa(this.defaults, r); + const { transitional: n, paramsSerializer: i, headers: s } = r; + n !== void 0 && Qh.assertOptions(n, { + silentJSONParsing: Ss.transitional(Ss.boolean), + forcedJSONParsing: Ss.transitional(Ss.boolean), + clarifyTimeoutError: Ss.transitional(Ss.boolean) + }, !1), i != null && (Ne.isFunction(i) ? r.paramsSerializer = { + serialize: i + } : Qh.assertOptions(i, { + encode: Ss.function, + serialize: Ss.function + }, !0)), Qh.assertOptions(r, { + baseUrl: Ss.spelling("baseURL"), + withXsrfToken: Ss.spelling("withXSRFToken") + }, !0), r.method = (r.method || this.defaults.method || "get").toLowerCase(); + let o = s && Ne.merge( + s.common, + s[r.method] + ); + s && Ne.forEach( + ["delete", "get", "head", "post", "put", "patch", "common"], + (S) => { + delete s[S]; + } + ), r.headers = li.concat(o, s); + const a = []; + let f = !0; + this.interceptors.request.forEach(function(R) { + typeof R.runWhen == "function" && R.runWhen(r) === !1 || (f = f && R.synchronous, a.unshift(R.fulfilled, R.rejected)); + }); + const u = []; + this.interceptors.response.forEach(function(R) { + u.push(R.fulfilled, R.rejected); + }); + let h, g = 0, v; + if (!f) { + const S = [h6.bind(this), void 0]; + for (S.unshift.apply(S, a), S.push.apply(S, u), v = S.length, h = Promise.resolve(r); g < v; ) + h = h.then(S[g++], S[g++]); + return h; + } + v = a.length; + let x = r; + for (g = 0; g < v; ) { + const S = a[g++], R = a[g++]; + try { + x = S(x); + } catch (D) { + R.call(this, D); + break; + } + } + try { + h = h6.call(this, x); + } catch (S) { + return Promise.reject(S); + } + for (g = 0, v = u.length; g < v; ) + h = h.then(u[g++], u[g++]); + return h; + } + getUri(e) { + e = Fa(this.defaults, e); + const r = hS(e.baseURL, e.url); + return aS(r, e.params, e.paramsSerializer); + } +}; +Ne.forEach(["delete", "get", "head", "options"], function(e) { + Ra.prototype[e] = function(r, n) { + return this.request(Fa(n || {}, { + method: e, + url: r, + data: (n || {}).data + })); + }; +}); +Ne.forEach(["post", "put", "patch"], function(e) { + function r(n) { + return function(s, o, a) { + return this.request(Fa(a || {}, { + method: e, + headers: n ? { + "Content-Type": "multipart/form-data" + } : {}, + url: s, + data: o + })); + }; + } + Ra.prototype[e] = r(), Ra.prototype[e + "Form"] = r(!0); +}); +let UG = class bS { + constructor(e) { + if (typeof e != "function") + throw new TypeError("executor must be a function."); + let r; + this.promise = new Promise(function(s) { + r = s; + }); + const n = this; + this.promise.then((i) => { + if (!n._listeners) return; + let s = n._listeners.length; + for (; s-- > 0; ) + n._listeners[s](i); + n._listeners = null; + }), this.promise.then = (i) => { + let s; + const o = new Promise((a) => { + n.subscribe(a), s = a; + }).then(i); + return o.cancel = function() { + n.unsubscribe(s); + }, o; + }, e(function(s, o, a) { + n.reason || (n.reason = new Zc(s, o, a), r(n.reason)); + }); + } + /** + * Throws a `CanceledError` if cancellation has been requested. + */ + throwIfRequested() { + if (this.reason) + throw this.reason; + } + /** + * Subscribe to the cancel signal + */ + subscribe(e) { + if (this.reason) { + e(this.reason); + return; + } + this._listeners ? this._listeners.push(e) : this._listeners = [e]; + } + /** + * Unsubscribe from the cancel signal + */ + unsubscribe(e) { + if (!this._listeners) + return; + const r = this._listeners.indexOf(e); + r !== -1 && this._listeners.splice(r, 1); + } + toAbortSignal() { + const e = new AbortController(), r = (n) => { + e.abort(n); + }; + return this.subscribe(r), e.signal.unsubscribe = () => this.unsubscribe(r), e.signal; + } + /** + * Returns an object that contains a new `CancelToken` and a function that, when called, + * cancels the `CancelToken`. + */ + static source() { + let e; + return { + token: new bS(function(i) { + e = i; + }), + cancel: e + }; + } +}; +function qG(t) { + return function(r) { + return t.apply(null, r); + }; +} +function zG(t) { + return Ne.isObject(t) && t.isAxiosError === !0; +} +const Pv = { + Continue: 100, + SwitchingProtocols: 101, + Processing: 102, + EarlyHints: 103, + Ok: 200, + Created: 201, + Accepted: 202, + NonAuthoritativeInformation: 203, + NoContent: 204, + ResetContent: 205, + PartialContent: 206, + MultiStatus: 207, + AlreadyReported: 208, + ImUsed: 226, + MultipleChoices: 300, + MovedPermanently: 301, + Found: 302, + SeeOther: 303, + NotModified: 304, + UseProxy: 305, + Unused: 306, + TemporaryRedirect: 307, + PermanentRedirect: 308, + BadRequest: 400, + Unauthorized: 401, + PaymentRequired: 402, + Forbidden: 403, + NotFound: 404, + MethodNotAllowed: 405, + NotAcceptable: 406, + ProxyAuthenticationRequired: 407, + RequestTimeout: 408, + Conflict: 409, + Gone: 410, + LengthRequired: 411, + PreconditionFailed: 412, + PayloadTooLarge: 413, + UriTooLong: 414, + UnsupportedMediaType: 415, + RangeNotSatisfiable: 416, + ExpectationFailed: 417, + ImATeapot: 418, + MisdirectedRequest: 421, + UnprocessableEntity: 422, + Locked: 423, + FailedDependency: 424, + TooEarly: 425, + UpgradeRequired: 426, + PreconditionRequired: 428, + TooManyRequests: 429, + RequestHeaderFieldsTooLarge: 431, + UnavailableForLegalReasons: 451, + InternalServerError: 500, + NotImplemented: 501, + BadGateway: 502, + ServiceUnavailable: 503, + GatewayTimeout: 504, + HttpVersionNotSupported: 505, + VariantAlsoNegotiates: 506, + InsufficientStorage: 507, + LoopDetected: 508, + NotExtended: 510, + NetworkAuthenticationRequired: 511 +}; +Object.entries(Pv).forEach(([t, e]) => { + Pv[e] = t; +}); +function yS(t) { + const e = new Ra(t), r = YE(Ra.prototype.request, e); + return Ne.extend(r, Ra.prototype, e, { allOwnKeys: !0 }), Ne.extend(r, e, null, { allOwnKeys: !0 }), r.create = function(i) { + return yS(Fa(t, i)); + }, r; +} +const pn = yS(hl); +pn.Axios = Ra; +pn.CanceledError = Zc; +pn.CancelToken = UG; +pn.isCancel = fS; +pn.VERSION = vS; +pn.toFormData = h0; +pn.AxiosError = ar; +pn.Cancel = pn.CanceledError; +pn.all = function(e) { + return Promise.all(e); +}; +pn.spread = qG; +pn.isAxiosError = zG; +pn.mergeConfig = Fa; +pn.AxiosHeaders = li; +pn.formToJSON = (t) => uS(Ne.isHTMLForm(t) ? new FormData(t) : t); +pn.getAdapter = mS.getAdapter; +pn.HttpStatusCode = Pv; +pn.default = pn; +const { + Axios: Jre, + AxiosError: wS, + CanceledError: Xre, + isCancel: Zre, + CancelToken: Qre, + VERSION: ene, + all: tne, + Cancel: rne, + isAxiosError: nne, + spread: ine, + toFormData: sne, + AxiosHeaders: one, + HttpStatusCode: ane, + formToJSON: cne, + getAdapter: une, + mergeConfig: fne +} = pn, xS = pn.create({ + timeout: 6e4, + headers: { + "Content-Type": "application/json", + token: localStorage.getItem("auth") + } +}); +function HG(t) { + if (t.data?.success !== !0) { + const e = new wS( + t.data?.errorMessage, + t.data?.errorCode, + t.config, + t.request, + t + ); + return Promise.reject(e); + } else + return t; +} +function WG(t) { + console.log(t); + const e = t.response?.data; + if (e) { + console.log(e, "responseData"); + const r = new wS( + e.errorMessage, + t.code, + t.config, + t.request, + t.response + ); + return Promise.reject(r); + } else + return Promise.reject(t); +} +xS.interceptors.response.use( + HG, + WG +); +class KG { + constructor(e) { + this.request = e; + } + _apiBase = ""; + setApiBase(e) { + this._apiBase = e || ""; + } + async getNonce(e) { + const { data: r } = await this.request.post(`${this._apiBase}/api/v2/user/nonce`, e); + return r.data; + } + async getEmailCode(e, r) { + const { data: n } = await this.request.post(`${this._apiBase}/api/v2/user/get_code`, e, { + headers: { "Captcha-Param": r } + }); + return n.data; + } + async emailLogin(e) { + return (await this.request.post(`${this._apiBase}/api/v2/user/login`, e)).data; + } + async walletLogin(e) { + return e.account_enum === "C" ? (await this.request.post(`${this._apiBase}/api/v2/user/login`, e)).data : (await this.request.post(`${this._apiBase}/api/v2/business/login`, e)).data; + } + async tonLogin(e) { + return (await this.request.post(`${this._apiBase}/api/v2/user/login`, e)).data; + } + async bindEmail(e) { + return (await this.request.post("/api/v2/user/account/bind", e)).data; + } + async bindTonWallet(e) { + return (await this.request.post("/api/v2/user/account/bind", e)).data; + } + async bindEvmWallet(e) { + return (await this.request.post("/api/v2/user/account/bind", e)).data; + } +} +const Qo = new KG(xS), VG = { + projectId: "7a4434fefbcc9af474fb5c995e47d286", + metadata: { + name: "codatta", + description: "codatta", + url: "https://codatta.io/", + icons: ["https://avatars.githubusercontent.com/u/171659315"] + } +}, GG = dV({ + appName: "codatta", + appLogoUrl: "https://avatars.githubusercontent.com/u/171659315" +}), _S = Xo({ + saveLastUsedWallet: () => { + }, + lastUsedWallet: null, + wallets: [], + initialized: !1, + featuredWallets: [], + chains: [] +}); +function g0() { + return In(_S); +} +function lne(t) { + const { apiBaseUrl: e } = t, [r, n] = Xt([]), [i, s] = Xt([]), [o, a] = Xt(null), [f, u] = Xt(!1), [h, g] = Xt([]), v = (R) => { + a(R); + const k = { + provider: R.provider instanceof fv ? "UniversalProvider" : "EIP1193Provider", + key: R.key, + timestamp: Date.now() + }; + localStorage.setItem("xn-last-used-info", JSON.stringify(k)); + }; + function x(R) { + const D = R.find((k) => k.config?.name === t.singleWalletName); + if (D) + s([D]); + else { + const k = R.filter((B) => B.featured || B.installed), N = R.filter((B) => !B.featured && !B.installed), z = [...k, ...N]; + n(z), s(k); + } + } + async function S() { + const R = [], D = /* @__PURE__ */ new Map(); + bT.forEach((N) => { + const z = new Tc(N); + N.name === "Coinbase Wallet" && z.EIP6963Detected({ + info: { name: "Coinbase Wallet", uuid: "coinbase", icon: N.image, rdns: "coinbase" }, + provider: GG.getProvider() + }), D.set(z.key, z), R.push(z); + }), (await LW()).forEach((N) => { + const z = D.get(N.info.name); + if (z) + z.EIP6963Detected(N); + else { + const B = new Tc(N); + D.set(B.key, B), R.push(B); + } + }); + try { + const N = JSON.parse(localStorage.getItem("xn-last-used-info") || "{}"), z = D.get(N.key); + if (z && N.provider === "EIP1193Provider" && z.installed) + a(z); + else if (N.provider === "UniversalProvider") { + const B = await fv.init(VG); + if (B.session) { + const $ = new Tc(B); + a($), console.log("Restored UniversalProvider for wallet:", $.key); + } + } + } catch (N) { + console.log(N); + } + t.chains && g(t.chains), x(R), u(!0); + } + return Rn(() => { + S(), Qo.setApiBase(e); + }, []), /* @__PURE__ */ pe.jsx( + _S.Provider, + { + value: { + saveLastUsedWallet: v, + wallets: r, + initialized: f, + lastUsedWallet: o, + featuredWallets: i, + chains: h + }, + children: t.children + } + ); +} +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const YG = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ES = (...t) => t.filter((e, r, n) => !!e && e.trim() !== "" && n.indexOf(e) === r).join(" ").trim(); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +var JG = { + xmlns: "http://www.w3.org/2000/svg", + width: 24, + height: 24, + viewBox: "0 0 24 24", + fill: "none", + stroke: "currentColor", + strokeWidth: 2, + strokeLinecap: "round", + strokeLinejoin: "round" +}; +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const XG = Kv( + ({ + color: t = "currentColor", + size: e = 24, + strokeWidth: r = 2, + absoluteStrokeWidth: n, + className: i = "", + children: s, + iconNode: o, + ...a + }, f) => sd( + "svg", + { + ref: f, + ...JG, + width: e, + height: e, + stroke: t, + strokeWidth: n ? Number(r) * 24 / Number(e) : r, + className: ES("lucide", i), + ...a + }, + [ + ...o.map(([u, h]) => sd(u, h)), + ...Array.isArray(s) ? s : [s] + ] + ) +); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const Xi = (t, e) => { + const r = Kv( + ({ className: n, ...i }, s) => sd(XG, { + ref: s, + iconNode: e, + className: ES(`lucide-${YG(t)}`, n), + ...i + }) + ); + return r.displayName = `${t}`, r; +}; +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const ZG = Xi("ArrowLeft", [ + ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }], + ["path", { d: "M19 12H5", key: "x3x0zl" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const SS = Xi("ArrowRight", [ + ["path", { d: "M5 12h14", key: "1ays0h" }], + ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const QG = Xi("ChevronRight", [ + ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const eY = Xi("CircleCheckBig", [ + ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }], + ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const tY = Xi("Download", [ + ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }], + ["polyline", { points: "7 10 12 15 17 10", key: "2ggqvy" }], + ["line", { x1: "12", x2: "12", y1: "15", y2: "3", key: "1vk2je" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const rY = Xi("Globe", [ + ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }], + ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }], + ["path", { d: "M2 12h20", key: "9i4pu4" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const AS = Xi("Laptop", [ + [ + "path", + { + d: "M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16", + key: "tarvll" + } + ] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const nY = Xi("Link2", [ + ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }], + ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }], + ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const ja = Xi("LoaderCircle", [ + ["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const iY = Xi("Mail", [ + ["rect", { width: "20", height: "16", x: "2", y: "4", rx: "2", key: "18n3k1" }], + ["path", { d: "m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7", key: "1ocrg3" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const PS = Xi("Search", [ + ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }], + ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }] +]); +/** + * @license lucide-react v0.460.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */ +const sY = Xi("UserRoundCheck", [ + ["path", { d: "M2 21a8 8 0 0 1 13.292-6", key: "bjp14o" }], + ["circle", { cx: "10", cy: "8", r: "5", key: "o932ke" }], + ["path", { d: "m16 19 2 2 4-4", key: "1b14m6" }] +]), p6 = /* @__PURE__ */ new Set(); +function m0(t, e, r) { + t || p6.has(e) || (console.warn(e), p6.add(e)); +} +function oY(t) { + if (typeof Proxy > "u") + return t; + const e = /* @__PURE__ */ new Map(), r = (...n) => (process.env.NODE_ENV !== "production" && m0(!1, "motion() is deprecated. Use motion.create() instead."), t(...n)); + return new Proxy(r, { + /** + * Called when `motion` is referenced with a prop: `motion.div`, `motion.input` etc. + * The prop name is passed through as `key` and we can use that to generate a `motion` + * DOM component with that name. + */ + get: (n, i) => i === "create" ? t : (e.has(i) || e.set(i, t(i)), e.get(i)) + }); +} +function v0(t) { + return t !== null && typeof t == "object" && typeof t.start == "function"; +} +const Mv = (t) => Array.isArray(t); +function MS(t, e) { + if (!Array.isArray(e)) + return !1; + const r = e.length; + if (r !== t.length) + return !1; + for (let n = 0; n < r; n++) + if (e[n] !== t[n]) + return !1; + return !0; +} +function jf(t) { + return typeof t == "string" || Array.isArray(t); +} +function g6(t) { + const e = [{}, {}]; + return t?.values.forEach((r, n) => { + e[0][n] = r.get(), e[1][n] = r.getVelocity(); + }), e; +} +function W1(t, e, r, n) { + if (typeof e == "function") { + const [i, s] = g6(n); + e = e(r !== void 0 ? r : t.custom, i, s); + } + if (typeof e == "string" && (e = t.variants && t.variants[e]), typeof e == "function") { + const [i, s] = g6(n); + e = e(r !== void 0 ? r : t.custom, i, s); + } + return e; +} +function b0(t, e, r) { + const n = t.getProps(); + return W1(n, e, r !== void 0 ? r : n.custom, t); +} +const K1 = [ + "animate", + "whileInView", + "whileFocus", + "whileHover", + "whileTap", + "whileDrag", + "exit" +], V1 = ["initial", ...K1], dl = [ + "transformPerspective", + "x", + "y", + "z", + "translateX", + "translateY", + "translateZ", + "scale", + "scaleX", + "scaleY", + "rotate", + "rotateX", + "rotateY", + "rotateZ", + "skew", + "skewX", + "skewY" +], Ya = new Set(dl), Cs = (t) => t * 1e3, oo = (t) => t / 1e3, aY = { + type: "spring", + stiffness: 500, + damping: 25, + restSpeed: 10 +}, cY = (t) => ({ + type: "spring", + stiffness: 550, + damping: t === 0 ? 2 * Math.sqrt(550) : 30, + restSpeed: 10 +}), uY = { + type: "keyframes", + duration: 0.8 +}, fY = { + type: "keyframes", + ease: [0.25, 0.1, 0.35, 1], + duration: 0.3 +}, lY = (t, { keyframes: e }) => e.length > 2 ? uY : Ya.has(t) ? t.startsWith("scale") ? cY(e[1]) : aY : fY; +function G1(t, e) { + return t ? t[e] || t.default || t : void 0; +} +const hY = { + useManualTiming: !1 +}, dY = (t) => t !== null; +function y0(t, { repeat: e, repeatType: r = "loop" }, n) { + const i = t.filter(dY), s = e && r !== "loop" && e % 2 === 1 ? 0 : i.length - 1; + return !s || n === void 0 ? i[s] : n; +} +const kn = (t) => t; +function pY(t) { + let e = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), n = !1, i = !1; + const s = /* @__PURE__ */ new WeakSet(); + let o = { + delta: 0, + timestamp: 0, + isProcessing: !1 + }; + function a(u) { + s.has(u) && (f.schedule(u), t()), u(o); + } + const f = { + /** + * Schedule a process to run on the next frame. + */ + schedule: (u, h = !1, g = !1) => { + const x = g && n ? e : r; + return h && s.add(u), x.has(u) || x.add(u), u; + }, + /** + * Cancel the provided callback from running on the next frame. + */ + cancel: (u) => { + r.delete(u), s.delete(u); + }, + /** + * Execute all schedule callbacks. + */ + process: (u) => { + if (o = u, n) { + i = !0; + return; + } + n = !0, [e, r] = [r, e], r.clear(), e.forEach(a), n = !1, i && (i = !1, f.process(u)); + } + }; + return f; +} +const Ih = [ + "read", + // Read + "resolveKeyframes", + // Write/Read/Write/Read + "update", + // Compute + "preRender", + // Compute + "render", + // Write + "postRender" + // Compute +], gY = 40; +function IS(t, e) { + let r = !1, n = !0; + const i = { + delta: 0, + timestamp: 0, + isProcessing: !1 + }, s = () => r = !0, o = Ih.reduce((k, N) => (k[N] = pY(s), k), {}), { read: a, resolveKeyframes: f, update: u, preRender: h, render: g, postRender: v } = o, x = () => { + const k = performance.now(); + r = !1, i.delta = n ? 1e3 / 60 : Math.max(Math.min(k - i.timestamp, gY), 1), i.timestamp = k, i.isProcessing = !0, a.process(i), f.process(i), u.process(i), h.process(i), g.process(i), v.process(i), i.isProcessing = !1, r && e && (n = !1, t(x)); + }, S = () => { + r = !0, n = !0, i.isProcessing || t(x); + }; + return { schedule: Ih.reduce((k, N) => { + const z = o[N]; + return k[N] = (B, $ = !1, U = !1) => (r || S(), z.schedule(B, $, U)), k; + }, {}), cancel: (k) => { + for (let N = 0; N < Ih.length; N++) + o[Ih[N]].cancel(k); + }, state: i, steps: o }; +} +const { schedule: kr, cancel: Vo, state: Nn, steps: bm } = IS(typeof requestAnimationFrame < "u" ? requestAnimationFrame : kn, !0), CS = (t, e, r) => (((1 - 3 * r + 3 * e) * t + (3 * r - 6 * e)) * t + 3 * e) * t, mY = 1e-7, vY = 12; +function bY(t, e, r, n, i) { + let s, o, a = 0; + do + o = e + (r - e) / 2, s = CS(o, n, i) - t, s > 0 ? r = o : e = o; + while (Math.abs(s) > mY && ++a < vY); + return o; +} +function pl(t, e, r, n) { + if (t === e && r === n) + return kn; + const i = (s) => bY(s, 0, 1, t, r); + return (s) => s === 0 || s === 1 ? s : CS(i(s), e, n); +} +const RS = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, TS = (t) => (e) => 1 - t(1 - e), DS = /* @__PURE__ */ pl(0.33, 1.53, 0.69, 0.99), Y1 = /* @__PURE__ */ TS(DS), OS = /* @__PURE__ */ RS(Y1), NS = (t) => (t *= 2) < 1 ? 0.5 * Y1(t) : 0.5 * (2 - Math.pow(2, -10 * (t - 1))), J1 = (t) => 1 - Math.sin(Math.acos(t)), LS = TS(J1), kS = RS(J1), $S = (t) => /^0[^.\s]+$/u.test(t); +function yY(t) { + return typeof t == "number" ? t === 0 : t !== null ? t === "none" || t === "0" || $S(t) : !0; +} +let Qc = kn, po = kn; +process.env.NODE_ENV !== "production" && (Qc = (t, e) => { + !t && typeof console < "u" && console.warn(e); +}, po = (t, e) => { + if (!t) + throw new Error(e); +}); +const BS = (t) => /^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t), FS = (t) => (e) => typeof e == "string" && e.startsWith(t), jS = /* @__PURE__ */ FS("--"), wY = /* @__PURE__ */ FS("var(--"), X1 = (t) => wY(t) ? xY.test(t.split("/*")[0].trim()) : !1, xY = /var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu, _Y = ( + // eslint-disable-next-line redos-detector/no-unsafe-regex -- false positive, as it can match a lot of words + /^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u +); +function EY(t) { + const e = _Y.exec(t); + if (!e) + return [,]; + const [, r, n, i] = e; + return [`--${r ?? n}`, i]; +} +const SY = 4; +function US(t, e, r = 1) { + po(r <= SY, `Max CSS variable fallback depth detected in property "${t}". This may indicate a circular fallback dependency.`); + const [n, i] = EY(t); + if (!n) + return; + const s = window.getComputedStyle(e).getPropertyValue(n); + if (s) { + const o = s.trim(); + return BS(o) ? parseFloat(o) : o; + } + return X1(i) ? US(i, e, r + 1) : i; +} +const Go = (t, e, r) => r > e ? e : r < t ? t : r, eu = { + test: (t) => typeof t == "number", + parse: parseFloat, + transform: (t) => t +}, Uf = { + ...eu, + transform: (t) => Go(0, 1, t) +}, Ch = { + ...eu, + default: 1 +}, gl = (t) => ({ + test: (e) => typeof e == "string" && e.endsWith(t) && e.split(" ").length === 1, + parse: parseFloat, + transform: (e) => `${e}${t}` +}), To = /* @__PURE__ */ gl("deg"), Rs = /* @__PURE__ */ gl("%"), Vt = /* @__PURE__ */ gl("px"), AY = /* @__PURE__ */ gl("vh"), PY = /* @__PURE__ */ gl("vw"), m6 = { + ...Rs, + parse: (t) => Rs.parse(t) / 100, + transform: (t) => Rs.transform(t * 100) +}, MY = /* @__PURE__ */ new Set([ + "width", + "height", + "top", + "left", + "right", + "bottom", + "x", + "y", + "translateX", + "translateY" +]), v6 = (t) => t === eu || t === Vt, b6 = (t, e) => parseFloat(t.split(", ")[e]), y6 = (t, e) => (r, { transform: n }) => { + if (n === "none" || !n) + return 0; + const i = n.match(/^matrix3d\((.+)\)$/u); + if (i) + return b6(i[1], e); + { + const s = n.match(/^matrix\((.+)\)$/u); + return s ? b6(s[1], t) : 0; + } +}, IY = /* @__PURE__ */ new Set(["x", "y", "z"]), CY = dl.filter((t) => !IY.has(t)); +function RY(t) { + const e = []; + return CY.forEach((r) => { + const n = t.getValue(r); + n !== void 0 && (e.push([r, n.get()]), n.set(r.startsWith("scale") ? 1 : 0)); + }), e; +} +const zc = { + // Dimensions + width: ({ x: t }, { paddingLeft: e = "0", paddingRight: r = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(r), + height: ({ y: t }, { paddingTop: e = "0", paddingBottom: r = "0" }) => t.max - t.min - parseFloat(e) - parseFloat(r), + top: (t, { top: e }) => parseFloat(e), + left: (t, { left: e }) => parseFloat(e), + bottom: ({ y: t }, { top: e }) => parseFloat(e) + (t.max - t.min), + right: ({ x: t }, { left: e }) => parseFloat(e) + (t.max - t.min), + // Transform + x: y6(4, 13), + y: y6(5, 14) +}; +zc.translateX = zc.x; +zc.translateY = zc.y; +const qS = (t) => (e) => e.test(t), TY = { + test: (t) => t === "auto", + parse: (t) => t +}, zS = [eu, Vt, Rs, To, PY, AY, TY], w6 = (t) => zS.find(qS(t)), Ta = /* @__PURE__ */ new Set(); +let Iv = !1, Cv = !1; +function HS() { + if (Cv) { + const t = Array.from(Ta).filter((n) => n.needsMeasurement), e = new Set(t.map((n) => n.element)), r = /* @__PURE__ */ new Map(); + e.forEach((n) => { + const i = RY(n); + i.length && (r.set(n, i), n.render()); + }), t.forEach((n) => n.measureInitialState()), e.forEach((n) => { + n.render(); + const i = r.get(n); + i && i.forEach(([s, o]) => { + var a; + (a = n.getValue(s)) === null || a === void 0 || a.set(o); + }); + }), t.forEach((n) => n.measureEndState()), t.forEach((n) => { + n.suspendedScrollY !== void 0 && window.scrollTo(0, n.suspendedScrollY); + }); + } + Cv = !1, Iv = !1, Ta.forEach((t) => t.complete()), Ta.clear(); +} +function WS() { + Ta.forEach((t) => { + t.readKeyframes(), t.needsMeasurement && (Cv = !0); + }); +} +function DY() { + WS(), HS(); +} +class Z1 { + constructor(e, r, n, i, s, o = !1) { + this.isComplete = !1, this.isAsync = !1, this.needsMeasurement = !1, this.isScheduled = !1, this.unresolvedKeyframes = [...e], this.onComplete = r, this.name = n, this.motionValue = i, this.element = s, this.isAsync = o; + } + scheduleResolve() { + this.isScheduled = !0, this.isAsync ? (Ta.add(this), Iv || (Iv = !0, kr.read(WS), kr.resolveKeyframes(HS))) : (this.readKeyframes(), this.complete()); + } + readKeyframes() { + const { unresolvedKeyframes: e, name: r, element: n, motionValue: i } = this; + for (let s = 0; s < e.length; s++) + if (e[s] === null) + if (s === 0) { + const o = i?.get(), a = e[e.length - 1]; + if (o !== void 0) + e[0] = o; + else if (n && r) { + const f = n.readValue(r, a); + f != null && (e[0] = f); + } + e[0] === void 0 && (e[0] = a), i && o === void 0 && i.set(e[0]); + } else + e[s] = e[s - 1]; + } + setFinalKeyframe() { + } + measureInitialState() { + } + renderEndStyles() { + } + measureEndState() { + } + complete() { + this.isComplete = !0, this.onComplete(this.unresolvedKeyframes, this.finalKeyframe), Ta.delete(this); + } + cancel() { + this.isComplete || (this.isScheduled = !1, Ta.delete(this)); + } + resume() { + this.isComplete || this.scheduleResolve(); + } +} +const af = (t) => Math.round(t * 1e5) / 1e5, Q1 = /-?(?:\d+(?:\.\d+)?|\.\d+)/gu; +function OY(t) { + return t == null; +} +const NY = /^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu, eb = (t, e) => (r) => !!(typeof r == "string" && NY.test(r) && r.startsWith(t) || e && !OY(r) && Object.prototype.hasOwnProperty.call(r, e)), KS = (t, e, r) => (n) => { + if (typeof n != "string") + return n; + const [i, s, o, a] = n.match(Q1); + return { + [t]: parseFloat(i), + [e]: parseFloat(s), + [r]: parseFloat(o), + alpha: a !== void 0 ? parseFloat(a) : 1 + }; +}, LY = (t) => Go(0, 255, t), ym = { + ...eu, + transform: (t) => Math.round(LY(t)) +}, Ca = { + test: /* @__PURE__ */ eb("rgb", "red"), + parse: /* @__PURE__ */ KS("red", "green", "blue"), + transform: ({ red: t, green: e, blue: r, alpha: n = 1 }) => "rgba(" + ym.transform(t) + ", " + ym.transform(e) + ", " + ym.transform(r) + ", " + af(Uf.transform(n)) + ")" +}; +function kY(t) { + let e = "", r = "", n = "", i = ""; + return t.length > 5 ? (e = t.substring(1, 3), r = t.substring(3, 5), n = t.substring(5, 7), i = t.substring(7, 9)) : (e = t.substring(1, 2), r = t.substring(2, 3), n = t.substring(3, 4), i = t.substring(4, 5), e += e, r += r, n += n, i += i), { + red: parseInt(e, 16), + green: parseInt(r, 16), + blue: parseInt(n, 16), + alpha: i ? parseInt(i, 16) / 255 : 1 + }; +} +const Rv = { + test: /* @__PURE__ */ eb("#"), + parse: kY, + transform: Ca.transform +}, _c = { + test: /* @__PURE__ */ eb("hsl", "hue"), + parse: /* @__PURE__ */ KS("hue", "saturation", "lightness"), + transform: ({ hue: t, saturation: e, lightness: r, alpha: n = 1 }) => "hsla(" + Math.round(t) + ", " + Rs.transform(af(e)) + ", " + Rs.transform(af(r)) + ", " + af(Uf.transform(n)) + ")" +}, qn = { + test: (t) => Ca.test(t) || Rv.test(t) || _c.test(t), + parse: (t) => Ca.test(t) ? Ca.parse(t) : _c.test(t) ? _c.parse(t) : Rv.parse(t), + transform: (t) => typeof t == "string" ? t : t.hasOwnProperty("red") ? Ca.transform(t) : _c.transform(t) +}, $Y = /(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu; +function BY(t) { + var e, r; + return isNaN(t) && typeof t == "string" && (((e = t.match(Q1)) === null || e === void 0 ? void 0 : e.length) || 0) + (((r = t.match($Y)) === null || r === void 0 ? void 0 : r.length) || 0) > 0; +} +const VS = "number", GS = "color", FY = "var", jY = "var(", x6 = "${}", UY = /var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu; +function qf(t) { + const e = t.toString(), r = [], n = { + color: [], + number: [], + var: [] + }, i = []; + let s = 0; + const a = e.replace(UY, (f) => (qn.test(f) ? (n.color.push(s), i.push(GS), r.push(qn.parse(f))) : f.startsWith(jY) ? (n.var.push(s), i.push(FY), r.push(f)) : (n.number.push(s), i.push(VS), r.push(parseFloat(f))), ++s, x6)).split(x6); + return { values: r, split: a, indexes: n, types: i }; +} +function YS(t) { + return qf(t).values; +} +function JS(t) { + const { split: e, types: r } = qf(t), n = e.length; + return (i) => { + let s = ""; + for (let o = 0; o < n; o++) + if (s += e[o], i[o] !== void 0) { + const a = r[o]; + a === VS ? s += af(i[o]) : a === GS ? s += qn.transform(i[o]) : s += i[o]; + } + return s; + }; +} +const qY = (t) => typeof t == "number" ? 0 : t; +function zY(t) { + const e = YS(t); + return JS(t)(e.map(qY)); +} +const Yo = { + test: BY, + parse: YS, + createTransformer: JS, + getAnimatableNone: zY +}, HY = /* @__PURE__ */ new Set(["brightness", "contrast", "saturate", "opacity"]); +function WY(t) { + const [e, r] = t.slice(0, -1).split("("); + if (e === "drop-shadow") + return t; + const [n] = r.match(Q1) || []; + if (!n) + return t; + const i = r.replace(n, ""); + let s = HY.has(e) ? 1 : 0; + return n !== r && (s *= 100), e + "(" + s + i + ")"; +} +const KY = /\b([a-z-]*)\(.*?\)/gu, Tv = { + ...Yo, + getAnimatableNone: (t) => { + const e = t.match(KY); + return e ? e.map(WY).join(" ") : t; + } +}, VY = { + // Border props + borderWidth: Vt, + borderTopWidth: Vt, + borderRightWidth: Vt, + borderBottomWidth: Vt, + borderLeftWidth: Vt, + borderRadius: Vt, + radius: Vt, + borderTopLeftRadius: Vt, + borderTopRightRadius: Vt, + borderBottomRightRadius: Vt, + borderBottomLeftRadius: Vt, + // Positioning props + width: Vt, + maxWidth: Vt, + height: Vt, + maxHeight: Vt, + top: Vt, + right: Vt, + bottom: Vt, + left: Vt, + // Spacing props + padding: Vt, + paddingTop: Vt, + paddingRight: Vt, + paddingBottom: Vt, + paddingLeft: Vt, + margin: Vt, + marginTop: Vt, + marginRight: Vt, + marginBottom: Vt, + marginLeft: Vt, + // Misc + backgroundPositionX: Vt, + backgroundPositionY: Vt +}, GY = { + rotate: To, + rotateX: To, + rotateY: To, + rotateZ: To, + scale: Ch, + scaleX: Ch, + scaleY: Ch, + scaleZ: Ch, + skew: To, + skewX: To, + skewY: To, + distance: Vt, + translateX: Vt, + translateY: Vt, + translateZ: Vt, + x: Vt, + y: Vt, + z: Vt, + perspective: Vt, + transformPerspective: Vt, + opacity: Uf, + originX: m6, + originY: m6, + originZ: Vt +}, _6 = { + ...eu, + transform: Math.round +}, tb = { + ...VY, + ...GY, + zIndex: _6, + size: Vt, + // SVG + fillOpacity: Uf, + strokeOpacity: Uf, + numOctaves: _6 +}, YY = { + ...tb, + // Color props + color: qn, + backgroundColor: qn, + outlineColor: qn, + fill: qn, + stroke: qn, + // Border props + borderColor: qn, + borderTopColor: qn, + borderRightColor: qn, + borderBottomColor: qn, + borderLeftColor: qn, + filter: Tv, + WebkitFilter: Tv +}, rb = (t) => YY[t]; +function XS(t, e) { + let r = rb(t); + return r !== Tv && (r = Yo), r.getAnimatableNone ? r.getAnimatableNone(e) : void 0; +} +const JY = /* @__PURE__ */ new Set(["auto", "none", "0"]); +function XY(t, e, r) { + let n = 0, i; + for (; n < t.length && !i; ) { + const s = t[n]; + typeof s == "string" && !JY.has(s) && qf(s).values.length && (i = t[n]), n++; + } + if (i && r) + for (const s of e) + t[s] = XS(r, i); +} +class ZS extends Z1 { + constructor(e, r, n, i, s) { + super(e, r, n, i, s, !0); + } + readKeyframes() { + const { unresolvedKeyframes: e, element: r, name: n } = this; + if (!r || !r.current) + return; + super.readKeyframes(); + for (let f = 0; f < e.length; f++) { + let u = e[f]; + if (typeof u == "string" && (u = u.trim(), X1(u))) { + const h = US(u, r.current); + h !== void 0 && (e[f] = h), f === e.length - 1 && (this.finalKeyframe = u); + } + } + if (this.resolveNoneKeyframes(), !MY.has(n) || e.length !== 2) + return; + const [i, s] = e, o = w6(i), a = w6(s); + if (o !== a) + if (v6(o) && v6(a)) + for (let f = 0; f < e.length; f++) { + const u = e[f]; + typeof u == "string" && (e[f] = parseFloat(u)); + } + else + this.needsMeasurement = !0; + } + resolveNoneKeyframes() { + const { unresolvedKeyframes: e, name: r } = this, n = []; + for (let i = 0; i < e.length; i++) + yY(e[i]) && n.push(i); + n.length && XY(e, n, r); + } + measureInitialState() { + const { element: e, unresolvedKeyframes: r, name: n } = this; + if (!e || !e.current) + return; + n === "height" && (this.suspendedScrollY = window.pageYOffset), this.measuredOrigin = zc[n](e.measureViewportBox(), window.getComputedStyle(e.current)), r[0] = this.measuredOrigin; + const i = r[r.length - 1]; + i !== void 0 && e.getValue(n, i).jump(i, !1); + } + measureEndState() { + var e; + const { element: r, name: n, unresolvedKeyframes: i } = this; + if (!r || !r.current) + return; + const s = r.getValue(n); + s && s.jump(this.measuredOrigin, !1); + const o = i.length - 1, a = i[o]; + i[o] = zc[n](r.measureViewportBox(), window.getComputedStyle(r.current)), a !== null && this.finalKeyframe === void 0 && (this.finalKeyframe = a), !((e = this.removedTransforms) === null || e === void 0) && e.length && this.removedTransforms.forEach(([f, u]) => { + r.getValue(f).set(u); + }), this.resolveNoneKeyframes(); + } +} +function nb(t) { + return typeof t == "function"; +} +let ed; +function ZY() { + ed = void 0; +} +const Ts = { + now: () => (ed === void 0 && Ts.set(Nn.isProcessing || hY.useManualTiming ? Nn.timestamp : performance.now()), ed), + set: (t) => { + ed = t, queueMicrotask(ZY); + } +}, E6 = (t, e) => e === "zIndex" ? !1 : !!(typeof t == "number" || Array.isArray(t) || typeof t == "string" && // It's animatable if we have a string +(Yo.test(t) || t === "0") && // And it contains numbers and/or colors +!t.startsWith("url(")); +function QY(t) { + const e = t[0]; + if (t.length === 1) + return !0; + for (let r = 0; r < t.length; r++) + if (t[r] !== e) + return !0; +} +function eJ(t, e, r, n) { + const i = t[0]; + if (i === null) + return !1; + if (e === "display" || e === "visibility") + return !0; + const s = t[t.length - 1], o = E6(i, e), a = E6(s, e); + return Qc(o === a, `You are trying to animate ${e} from "${i}" to "${s}". ${i} is not an animatable value - to enable this animation set ${i} to a value animatable to ${s} via the \`style\` property.`), !o || !a ? !1 : QY(t) || (r === "spring" || nb(r)) && n; +} +const tJ = 40; +class QS { + constructor({ autoplay: e = !0, delay: r = 0, type: n = "keyframes", repeat: i = 0, repeatDelay: s = 0, repeatType: o = "loop", ...a }) { + this.isStopped = !1, this.hasAttemptedResolve = !1, this.createdAt = Ts.now(), this.options = { + autoplay: e, + delay: r, + type: n, + repeat: i, + repeatDelay: s, + repeatType: o, + ...a + }, this.updateFinishedPromise(); + } + /** + * This method uses the createdAt and resolvedAt to calculate the + * animation startTime. *Ideally*, we would use the createdAt time as t=0 + * as the following frame would then be the first frame of the animation in + * progress, which would feel snappier. + * + * However, if there's a delay (main thread work) between the creation of + * the animation and the first commited frame, we prefer to use resolvedAt + * to avoid a sudden jump into the animation. + */ + calcStartTime() { + return this.resolvedAt ? this.resolvedAt - this.createdAt > tJ ? this.resolvedAt : this.createdAt : this.createdAt; + } + /** + * A getter for resolved data. If keyframes are not yet resolved, accessing + * this.resolved will synchronously flush all pending keyframe resolvers. + * This is a deoptimisation, but at its worst still batches read/writes. + */ + get resolved() { + return !this._resolved && !this.hasAttemptedResolve && DY(), this._resolved; + } + /** + * A method to be called when the keyframes resolver completes. This method + * will check if its possible to run the animation and, if not, skip it. + * Otherwise, it will call initPlayback on the implementing class. + */ + onKeyframesResolved(e, r) { + this.resolvedAt = Ts.now(), this.hasAttemptedResolve = !0; + const { name: n, type: i, velocity: s, delay: o, onComplete: a, onUpdate: f, isGenerator: u } = this.options; + if (!u && !eJ(e, n, i, s)) + if (o) + this.options.duration = 0; + else { + f?.(y0(e, this.options, r)), a?.(), this.resolveFinishedPromise(); + return; + } + const h = this.initPlayback(e, r); + h !== !1 && (this._resolved = { + keyframes: e, + finalKeyframe: r, + ...h + }, this.onPostResolved()); + } + onPostResolved() { + } + /** + * Allows the returned animation to be awaited or promise-chained. Currently + * resolves when the animation finishes at all but in a future update could/should + * reject if its cancels. + */ + then(e, r) { + return this.currentFinishedPromise.then(e, r); + } + flatten() { + this.options.type = "keyframes", this.options.ease = "linear"; + } + updateFinishedPromise() { + this.currentFinishedPromise = new Promise((e) => { + this.resolveFinishedPromise = e; + }); + } +} +function e7(t, e) { + return e ? t * (1e3 / e) : 0; +} +const rJ = 5; +function t7(t, e, r) { + const n = Math.max(e - rJ, 0); + return e7(r - t(n), e - n); +} +const wm = 1e-3, nJ = 0.01, S6 = 10, iJ = 0.05, sJ = 1; +function oJ({ duration: t = 800, bounce: e = 0.25, velocity: r = 0, mass: n = 1 }) { + let i, s; + Qc(t <= Cs(S6), "Spring duration must be 10 seconds or less"); + let o = 1 - e; + o = Go(iJ, sJ, o), t = Go(nJ, S6, oo(t)), o < 1 ? (i = (u) => { + const h = u * o, g = h * t, v = h - r, x = Dv(u, o), S = Math.exp(-g); + return wm - v / x * S; + }, s = (u) => { + const g = u * o * t, v = g * r + r, x = Math.pow(o, 2) * Math.pow(u, 2) * t, S = Math.exp(-g), R = Dv(Math.pow(u, 2), o); + return (-i(u) + wm > 0 ? -1 : 1) * ((v - x) * S) / R; + }) : (i = (u) => { + const h = Math.exp(-u * t), g = (u - r) * t + 1; + return -wm + h * g; + }, s = (u) => { + const h = Math.exp(-u * t), g = (r - u) * (t * t); + return h * g; + }); + const a = 5 / t, f = cJ(i, s, a); + if (t = Cs(t), isNaN(f)) + return { + stiffness: 100, + damping: 10, + duration: t + }; + { + const u = Math.pow(f, 2) * n; + return { + stiffness: u, + damping: o * 2 * Math.sqrt(n * u), + duration: t + }; + } +} +const aJ = 12; +function cJ(t, e, r) { + let n = r; + for (let i = 1; i < aJ; i++) + n = n - t(n) / e(n); + return n; +} +function Dv(t, e) { + return t * Math.sqrt(1 - e * e); +} +const uJ = ["duration", "bounce"], fJ = ["stiffness", "damping", "mass"]; +function A6(t, e) { + return e.some((r) => t[r] !== void 0); +} +function lJ(t) { + let e = { + velocity: 0, + stiffness: 100, + damping: 10, + mass: 1, + isResolvedFromDuration: !1, + ...t + }; + if (!A6(t, fJ) && A6(t, uJ)) { + const r = oJ(t); + e = { + ...e, + ...r, + mass: 1 + }, e.isResolvedFromDuration = !0; + } + return e; +} +function r7({ keyframes: t, restDelta: e, restSpeed: r, ...n }) { + const i = t[0], s = t[t.length - 1], o = { done: !1, value: i }, { stiffness: a, damping: f, mass: u, duration: h, velocity: g, isResolvedFromDuration: v } = lJ({ + ...n, + velocity: -oo(n.velocity || 0) + }), x = g || 0, S = f / (2 * Math.sqrt(a * u)), R = s - i, D = oo(Math.sqrt(a / u)), k = Math.abs(R) < 5; + r || (r = k ? 0.01 : 2), e || (e = k ? 5e-3 : 0.5); + let N; + if (S < 1) { + const z = Dv(D, S); + N = (B) => { + const $ = Math.exp(-S * D * B); + return s - $ * ((x + S * D * R) / z * Math.sin(z * B) + R * Math.cos(z * B)); + }; + } else if (S === 1) + N = (z) => s - Math.exp(-D * z) * (R + (x + D * R) * z); + else { + const z = D * Math.sqrt(S * S - 1); + N = (B) => { + const $ = Math.exp(-S * D * B), U = Math.min(z * B, 300); + return s - $ * ((x + S * D * R) * Math.sinh(U) + z * R * Math.cosh(U)) / z; + }; + } + return { + calculatedDuration: v && h || null, + next: (z) => { + const B = N(z); + if (v) + o.done = z >= h; + else { + let $ = 0; + S < 1 && ($ = z === 0 ? Cs(x) : t7(N, z, B)); + const U = Math.abs($) <= r, C = Math.abs(s - B) <= e; + o.done = U && C; + } + return o.value = o.done ? s : B, o; + } + }; +} +function P6({ keyframes: t, velocity: e = 0, power: r = 0.8, timeConstant: n = 325, bounceDamping: i = 10, bounceStiffness: s = 500, modifyTarget: o, min: a, max: f, restDelta: u = 0.5, restSpeed: h }) { + const g = t[0], v = { + done: !1, + value: g + }, x = (W) => a !== void 0 && W < a || f !== void 0 && W > f, S = (W) => a === void 0 ? f : f === void 0 || Math.abs(a - W) < Math.abs(f - W) ? a : f; + let R = r * e; + const D = g + R, k = o === void 0 ? D : o(D); + k !== D && (R = k - g); + const N = (W) => -R * Math.exp(-W / n), z = (W) => k + N(W), B = (W) => { + const J = N(W), ne = z(W); + v.done = Math.abs(J) <= u, v.value = v.done ? k : ne; + }; + let $, U; + const C = (W) => { + x(v.value) && ($ = W, U = r7({ + keyframes: [v.value, S(v.value)], + velocity: t7(z, W, v.value), + // TODO: This should be passing * 1000 + damping: i, + stiffness: s, + restDelta: u, + restSpeed: h + })); + }; + return C(0), { + calculatedDuration: null, + next: (W) => { + let J = !1; + return !U && $ === void 0 && (J = !0, B(W), C(W)), $ !== void 0 && W >= $ ? U.next(W - $) : (!J && B(W), v); + } + }; +} +const hJ = /* @__PURE__ */ pl(0.42, 0, 1, 1), dJ = /* @__PURE__ */ pl(0, 0, 0.58, 1), n7 = /* @__PURE__ */ pl(0.42, 0, 0.58, 1), pJ = (t) => Array.isArray(t) && typeof t[0] != "number", ib = (t) => Array.isArray(t) && typeof t[0] == "number", M6 = { + linear: kn, + easeIn: hJ, + easeInOut: n7, + easeOut: dJ, + circIn: J1, + circInOut: kS, + circOut: LS, + backIn: Y1, + backInOut: OS, + backOut: DS, + anticipate: NS +}, I6 = (t) => { + if (ib(t)) { + po(t.length === 4, "Cubic bezier arrays must contain four numerical values."); + const [e, r, n, i] = t; + return pl(e, r, n, i); + } else if (typeof t == "string") + return po(M6[t] !== void 0, `Invalid easing type '${t}'`), M6[t]; + return t; +}, gJ = (t, e) => (r) => e(t(r)), ao = (...t) => t.reduce(gJ), Hc = (t, e, r) => { + const n = e - t; + return n === 0 ? 1 : (r - t) / n; +}, Qr = (t, e, r) => t + (e - t) * r; +function xm(t, e, r) { + return r < 0 && (r += 1), r > 1 && (r -= 1), r < 1 / 6 ? t + (e - t) * 6 * r : r < 1 / 2 ? e : r < 2 / 3 ? t + (e - t) * (2 / 3 - r) * 6 : t; +} +function mJ({ hue: t, saturation: e, lightness: r, alpha: n }) { + t /= 360, e /= 100, r /= 100; + let i = 0, s = 0, o = 0; + if (!e) + i = s = o = r; + else { + const a = r < 0.5 ? r * (1 + e) : r + e - r * e, f = 2 * r - a; + i = xm(f, a, t + 1 / 3), s = xm(f, a, t), o = xm(f, a, t - 1 / 3); + } + return { + red: Math.round(i * 255), + green: Math.round(s * 255), + blue: Math.round(o * 255), + alpha: n + }; +} +function Id(t, e) { + return (r) => r > 0 ? e : t; +} +const _m = (t, e, r) => { + const n = t * t, i = r * (e * e - n) + n; + return i < 0 ? 0 : Math.sqrt(i); +}, vJ = [Rv, Ca, _c], bJ = (t) => vJ.find((e) => e.test(t)); +function C6(t) { + const e = bJ(t); + if (Qc(!!e, `'${t}' is not an animatable color. Use the equivalent color code instead.`), !e) + return !1; + let r = e.parse(t); + return e === _c && (r = mJ(r)), r; +} +const R6 = (t, e) => { + const r = C6(t), n = C6(e); + if (!r || !n) + return Id(t, e); + const i = { ...r }; + return (s) => (i.red = _m(r.red, n.red, s), i.green = _m(r.green, n.green, s), i.blue = _m(r.blue, n.blue, s), i.alpha = Qr(r.alpha, n.alpha, s), Ca.transform(i)); +}, Ov = /* @__PURE__ */ new Set(["none", "hidden"]); +function yJ(t, e) { + return Ov.has(t) ? (r) => r <= 0 ? t : e : (r) => r >= 1 ? e : t; +} +function wJ(t, e) { + return (r) => Qr(t, e, r); +} +function sb(t) { + return typeof t == "number" ? wJ : typeof t == "string" ? X1(t) ? Id : qn.test(t) ? R6 : EJ : Array.isArray(t) ? i7 : typeof t == "object" ? qn.test(t) ? R6 : xJ : Id; +} +function i7(t, e) { + const r = [...t], n = r.length, i = t.map((s, o) => sb(s)(s, e[o])); + return (s) => { + for (let o = 0; o < n; o++) + r[o] = i[o](s); + return r; + }; +} +function xJ(t, e) { + const r = { ...t, ...e }, n = {}; + for (const i in r) + t[i] !== void 0 && e[i] !== void 0 && (n[i] = sb(t[i])(t[i], e[i])); + return (i) => { + for (const s in n) + r[s] = n[s](i); + return r; + }; +} +function _J(t, e) { + var r; + const n = [], i = { color: 0, var: 0, number: 0 }; + for (let s = 0; s < e.values.length; s++) { + const o = e.types[s], a = t.indexes[o][i[o]], f = (r = t.values[a]) !== null && r !== void 0 ? r : 0; + n[s] = f, i[o]++; + } + return n; +} +const EJ = (t, e) => { + const r = Yo.createTransformer(e), n = qf(t), i = qf(e); + return n.indexes.var.length === i.indexes.var.length && n.indexes.color.length === i.indexes.color.length && n.indexes.number.length >= i.indexes.number.length ? Ov.has(t) && !i.values.length || Ov.has(e) && !n.values.length ? yJ(t, e) : ao(i7(_J(n, i), i.values), r) : (Qc(!0, `Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`), Id(t, e)); +}; +function s7(t, e, r) { + return typeof t == "number" && typeof e == "number" && typeof r == "number" ? Qr(t, e, r) : sb(t)(t, e); +} +function SJ(t, e, r) { + const n = [], i = r || s7, s = t.length - 1; + for (let o = 0; o < s; o++) { + let a = i(t[o], t[o + 1]); + if (e) { + const f = Array.isArray(e) ? e[o] || kn : e; + a = ao(f, a); + } + n.push(a); + } + return n; +} +function AJ(t, e, { clamp: r = !0, ease: n, mixer: i } = {}) { + const s = t.length; + if (po(s === e.length, "Both input and output ranges must be the same length"), s === 1) + return () => e[0]; + if (s === 2 && t[0] === t[1]) + return () => e[1]; + t[0] > t[s - 1] && (t = [...t].reverse(), e = [...e].reverse()); + const o = SJ(e, n, i), a = o.length, f = (u) => { + let h = 0; + if (a > 1) + for (; h < t.length - 2 && !(u < t[h + 1]); h++) + ; + const g = Hc(t[h], t[h + 1], u); + return o[h](g); + }; + return r ? (u) => f(Go(t[0], t[s - 1], u)) : f; +} +function PJ(t, e) { + const r = t[t.length - 1]; + for (let n = 1; n <= e; n++) { + const i = Hc(0, e, n); + t.push(Qr(r, 1, i)); + } +} +function MJ(t) { + const e = [0]; + return PJ(e, t.length - 1), e; +} +function IJ(t, e) { + return t.map((r) => r * e); +} +function CJ(t, e) { + return t.map(() => e || n7).splice(0, t.length - 1); +} +function Cd({ duration: t = 300, keyframes: e, times: r, ease: n = "easeInOut" }) { + const i = pJ(n) ? n.map(I6) : I6(n), s = { + done: !1, + value: e[0] + }, o = IJ( + // Only use the provided offsets if they're the correct length + // TODO Maybe we should warn here if there's a length mismatch + r && r.length === e.length ? r : MJ(e), + t + ), a = AJ(o, e, { + ease: Array.isArray(i) ? i : CJ(e, i) + }); + return { + calculatedDuration: t, + next: (f) => (s.value = a(f), s.done = f >= t, s) + }; +} +const T6 = 2e4; +function RJ(t) { + let e = 0; + const r = 50; + let n = t.next(e); + for (; !n.done && e < T6; ) + e += r, n = t.next(e); + return e >= T6 ? 1 / 0 : e; +} +const TJ = (t) => { + const e = ({ timestamp: r }) => t(r); + return { + start: () => kr.update(e, !0), + stop: () => Vo(e), + /** + * If we're processing this frame we can use the + * framelocked timestamp to keep things in sync. + */ + now: () => Nn.isProcessing ? Nn.timestamp : Ts.now() + }; +}, DJ = { + decay: P6, + inertia: P6, + tween: Cd, + keyframes: Cd, + spring: r7 +}, OJ = (t) => t / 100; +class ob extends QS { + constructor(e) { + super(e), this.holdTime = null, this.cancelTime = null, this.currentTime = 0, this.playbackSpeed = 1, this.pendingPlayState = "running", this.startTime = null, this.state = "idle", this.stop = () => { + if (this.resolver.cancel(), this.isStopped = !0, this.state === "idle") + return; + this.teardown(); + const { onStop: f } = this.options; + f && f(); + }; + const { name: r, motionValue: n, element: i, keyframes: s } = this.options, o = i?.KeyframeResolver || Z1, a = (f, u) => this.onKeyframesResolved(f, u); + this.resolver = new o(s, a, r, n, i), this.resolver.scheduleResolve(); + } + flatten() { + super.flatten(), this._resolved && Object.assign(this._resolved, this.initPlayback(this._resolved.keyframes)); + } + initPlayback(e) { + const { type: r = "keyframes", repeat: n = 0, repeatDelay: i = 0, repeatType: s, velocity: o = 0 } = this.options, a = nb(r) ? r : DJ[r] || Cd; + let f, u; + a !== Cd && typeof e[0] != "number" && (process.env.NODE_ENV !== "production" && po(e.length === 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${e}`), f = ao(OJ, s7(e[0], e[1])), e = [0, 100]); + const h = a({ ...this.options, keyframes: e }); + s === "mirror" && (u = a({ + ...this.options, + keyframes: [...e].reverse(), + velocity: -o + })), h.calculatedDuration === null && (h.calculatedDuration = RJ(h)); + const { calculatedDuration: g } = h, v = g + i, x = v * (n + 1) - i; + return { + generator: h, + mirroredGenerator: u, + mapPercentToKeyframes: f, + calculatedDuration: g, + resolvedDuration: v, + totalDuration: x + }; + } + onPostResolved() { + const { autoplay: e = !0 } = this.options; + this.play(), this.pendingPlayState === "paused" || !e ? this.pause() : this.state = this.pendingPlayState; + } + tick(e, r = !1) { + const { resolved: n } = this; + if (!n) { + const { keyframes: W } = this.options; + return { done: !0, value: W[W.length - 1] }; + } + const { finalKeyframe: i, generator: s, mirroredGenerator: o, mapPercentToKeyframes: a, keyframes: f, calculatedDuration: u, totalDuration: h, resolvedDuration: g } = n; + if (this.startTime === null) + return s.next(0); + const { delay: v, repeat: x, repeatType: S, repeatDelay: R, onUpdate: D } = this.options; + this.speed > 0 ? this.startTime = Math.min(this.startTime, e) : this.speed < 0 && (this.startTime = Math.min(e - h / this.speed, this.startTime)), r ? this.currentTime = e : this.holdTime !== null ? this.currentTime = this.holdTime : this.currentTime = Math.round(e - this.startTime) * this.speed; + const k = this.currentTime - v * (this.speed >= 0 ? 1 : -1), N = this.speed >= 0 ? k < 0 : k > h; + this.currentTime = Math.max(k, 0), this.state === "finished" && this.holdTime === null && (this.currentTime = h); + let z = this.currentTime, B = s; + if (x) { + const W = Math.min(this.currentTime, h) / g; + let J = Math.floor(W), ne = W % 1; + !ne && W >= 1 && (ne = 1), ne === 1 && J--, J = Math.min(J, x + 1), !!(J % 2) && (S === "reverse" ? (ne = 1 - ne, R && (ne -= R / g)) : S === "mirror" && (B = o)), z = Go(0, 1, ne) * g; + } + const $ = N ? { done: !1, value: f[0] } : B.next(z); + a && ($.value = a($.value)); + let { done: U } = $; + !N && u !== null && (U = this.speed >= 0 ? this.currentTime >= h : this.currentTime <= 0); + const C = this.holdTime === null && (this.state === "finished" || this.state === "running" && U); + return C && i !== void 0 && ($.value = y0(f, this.options, i)), D && D($.value), C && this.finish(), $; + } + get duration() { + const { resolved: e } = this; + return e ? oo(e.calculatedDuration) : 0; + } + get time() { + return oo(this.currentTime); + } + set time(e) { + e = Cs(e), this.currentTime = e, this.holdTime !== null || this.speed === 0 ? this.holdTime = e : this.driver && (this.startTime = this.driver.now() - e / this.speed); + } + get speed() { + return this.playbackSpeed; + } + set speed(e) { + const r = this.playbackSpeed !== e; + this.playbackSpeed = e, r && (this.time = oo(this.currentTime)); + } + play() { + if (this.resolver.isScheduled || this.resolver.resume(), !this._resolved) { + this.pendingPlayState = "running"; + return; + } + if (this.isStopped) + return; + const { driver: e = TJ, onPlay: r, startTime: n } = this.options; + this.driver || (this.driver = e((s) => this.tick(s))), r && r(); + const i = this.driver.now(); + this.holdTime !== null ? this.startTime = i - this.holdTime : this.startTime ? this.state === "finished" && (this.startTime = i) : this.startTime = n ?? this.calcStartTime(), this.state === "finished" && this.updateFinishedPromise(), this.cancelTime = this.startTime, this.holdTime = null, this.state = "running", this.driver.start(); + } + pause() { + var e; + if (!this._resolved) { + this.pendingPlayState = "paused"; + return; + } + this.state = "paused", this.holdTime = (e = this.currentTime) !== null && e !== void 0 ? e : 0; + } + complete() { + this.state !== "running" && this.play(), this.pendingPlayState = this.state = "finished", this.holdTime = null; + } + finish() { + this.teardown(), this.state = "finished"; + const { onComplete: e } = this.options; + e && e(); + } + cancel() { + this.cancelTime !== null && this.tick(this.cancelTime), this.teardown(), this.updateFinishedPromise(); + } + teardown() { + this.state = "idle", this.stopDriver(), this.resolveFinishedPromise(), this.updateFinishedPromise(), this.startTime = this.cancelTime = null, this.resolver.cancel(); + } + stopDriver() { + this.driver && (this.driver.stop(), this.driver = void 0); + } + sample(e) { + return this.startTime = 0, this.tick(e, !0); + } +} +const NJ = /* @__PURE__ */ new Set([ + "opacity", + "clipPath", + "filter", + "transform" + // TODO: Can be accelerated but currently disabled until https://issues.chromium.org/issues/41491098 is resolved + // or until we implement support for linear() easing. + // "background-color" +]), LJ = 10, kJ = (t, e) => { + let r = ""; + const n = Math.max(Math.round(e / LJ), 2); + for (let i = 0; i < n; i++) + r += t(Hc(0, n - 1, i)) + ", "; + return `linear(${r.substring(0, r.length - 2)})`; +}; +function ab(t) { + let e; + return () => (e === void 0 && (e = t()), e); +} +const $J = { + linearEasing: void 0 +}; +function BJ(t, e) { + const r = ab(t); + return () => { + var n; + return (n = $J[e]) !== null && n !== void 0 ? n : r(); + }; +} +const Rd = /* @__PURE__ */ BJ(() => { + try { + document.createElement("div").animate({ opacity: 0 }, { easing: "linear(0, 1)" }); + } catch { + return !1; + } + return !0; +}, "linearEasing"); +function o7(t) { + return !!(typeof t == "function" && Rd() || !t || typeof t == "string" && (t in Nv || Rd()) || ib(t) || Array.isArray(t) && t.every(o7)); +} +const Zu = ([t, e, r, n]) => `cubic-bezier(${t}, ${e}, ${r}, ${n})`, Nv = { + linear: "linear", + ease: "ease", + easeIn: "ease-in", + easeOut: "ease-out", + easeInOut: "ease-in-out", + circIn: /* @__PURE__ */ Zu([0, 0.65, 0.55, 1]), + circOut: /* @__PURE__ */ Zu([0.55, 0, 1, 0.45]), + backIn: /* @__PURE__ */ Zu([0.31, 0.01, 0.66, -0.59]), + backOut: /* @__PURE__ */ Zu([0.33, 1.53, 0.69, 0.99]) +}; +function a7(t, e) { + if (t) + return typeof t == "function" && Rd() ? kJ(t, e) : ib(t) ? Zu(t) : Array.isArray(t) ? t.map((r) => a7(r, e) || Nv.easeOut) : Nv[t]; +} +function FJ(t, e, r, { delay: n = 0, duration: i = 300, repeat: s = 0, repeatType: o = "loop", ease: a = "easeInOut", times: f } = {}) { + const u = { [e]: r }; + f && (u.offset = f); + const h = a7(a, i); + return Array.isArray(h) && (u.easing = h), t.animate(u, { + delay: n, + duration: i, + easing: Array.isArray(h) ? "linear" : h, + fill: "both", + iterations: s + 1, + direction: o === "reverse" ? "alternate" : "normal" + }); +} +function D6(t, e) { + t.timeline = e, t.onfinish = null; +} +const jJ = /* @__PURE__ */ ab(() => Object.hasOwnProperty.call(Element.prototype, "animate")), Td = 10, UJ = 2e4; +function qJ(t) { + return nb(t.type) || t.type === "spring" || !o7(t.ease); +} +function zJ(t, e) { + const r = new ob({ + ...e, + keyframes: t, + repeat: 0, + delay: 0, + isGenerator: !0 + }); + let n = { done: !1, value: t[0] }; + const i = []; + let s = 0; + for (; !n.done && s < UJ; ) + n = r.sample(s), i.push(n.value), s += Td; + return { + times: void 0, + keyframes: i, + duration: s - Td, + ease: "linear" + }; +} +const c7 = { + anticipate: NS, + backInOut: OS, + circInOut: kS +}; +function HJ(t) { + return t in c7; +} +class O6 extends QS { + constructor(e) { + super(e); + const { name: r, motionValue: n, element: i, keyframes: s } = this.options; + this.resolver = new ZS(s, (o, a) => this.onKeyframesResolved(o, a), r, n, i), this.resolver.scheduleResolve(); + } + initPlayback(e, r) { + var n; + let { duration: i = 300, times: s, ease: o, type: a, motionValue: f, name: u, startTime: h } = this.options; + if (!(!((n = f.owner) === null || n === void 0) && n.current)) + return !1; + if (typeof o == "string" && Rd() && HJ(o) && (o = c7[o]), qJ(this.options)) { + const { onComplete: v, onUpdate: x, motionValue: S, element: R, ...D } = this.options, k = zJ(e, D); + e = k.keyframes, e.length === 1 && (e[1] = e[0]), i = k.duration, s = k.times, o = k.ease, a = "keyframes"; + } + const g = FJ(f.owner.current, u, e, { ...this.options, duration: i, times: s, ease: o }); + return g.startTime = h ?? this.calcStartTime(), this.pendingTimeline ? (D6(g, this.pendingTimeline), this.pendingTimeline = void 0) : g.onfinish = () => { + const { onComplete: v } = this.options; + f.set(y0(e, this.options, r)), v && v(), this.cancel(), this.resolveFinishedPromise(); + }, { + animation: g, + duration: i, + times: s, + type: a, + ease: o, + keyframes: e + }; + } + get duration() { + const { resolved: e } = this; + if (!e) + return 0; + const { duration: r } = e; + return oo(r); + } + get time() { + const { resolved: e } = this; + if (!e) + return 0; + const { animation: r } = e; + return oo(r.currentTime || 0); + } + set time(e) { + const { resolved: r } = this; + if (!r) + return; + const { animation: n } = r; + n.currentTime = Cs(e); + } + get speed() { + const { resolved: e } = this; + if (!e) + return 1; + const { animation: r } = e; + return r.playbackRate; + } + set speed(e) { + const { resolved: r } = this; + if (!r) + return; + const { animation: n } = r; + n.playbackRate = e; + } + get state() { + const { resolved: e } = this; + if (!e) + return "idle"; + const { animation: r } = e; + return r.playState; + } + get startTime() { + const { resolved: e } = this; + if (!e) + return null; + const { animation: r } = e; + return r.startTime; + } + /** + * Replace the default DocumentTimeline with another AnimationTimeline. + * Currently used for scroll animations. + */ + attachTimeline(e) { + if (!this._resolved) + this.pendingTimeline = e; + else { + const { resolved: r } = this; + if (!r) + return kn; + const { animation: n } = r; + D6(n, e); + } + return kn; + } + play() { + if (this.isStopped) + return; + const { resolved: e } = this; + if (!e) + return; + const { animation: r } = e; + r.playState === "finished" && this.updateFinishedPromise(), r.play(); + } + pause() { + const { resolved: e } = this; + if (!e) + return; + const { animation: r } = e; + r.pause(); + } + stop() { + if (this.resolver.cancel(), this.isStopped = !0, this.state === "idle") + return; + this.resolveFinishedPromise(), this.updateFinishedPromise(); + const { resolved: e } = this; + if (!e) + return; + const { animation: r, keyframes: n, duration: i, type: s, ease: o, times: a } = e; + if (r.playState === "idle" || r.playState === "finished") + return; + if (this.time) { + const { motionValue: u, onUpdate: h, onComplete: g, element: v, ...x } = this.options, S = new ob({ + ...x, + keyframes: n, + duration: i, + type: s, + ease: o, + times: a, + isGenerator: !0 + }), R = Cs(this.time); + u.setWithVelocity(S.sample(R - Td).value, S.sample(R).value, Td); + } + const { onStop: f } = this.options; + f && f(), this.cancel(); + } + complete() { + const { resolved: e } = this; + e && e.animation.finish(); + } + cancel() { + const { resolved: e } = this; + e && e.animation.cancel(); + } + static supports(e) { + const { motionValue: r, name: n, repeatDelay: i, repeatType: s, damping: o, type: a } = e; + return jJ() && n && NJ.has(n) && r && r.owner && r.owner.current instanceof HTMLElement && /** + * If we're outputting values to onUpdate then we can't use WAAPI as there's + * no way to read the value from WAAPI every frame. + */ + !r.owner.getProps().onUpdate && !i && s !== "mirror" && o !== 0 && a !== "inertia"; + } +} +const WJ = ab(() => window.ScrollTimeline !== void 0); +class KJ { + constructor(e) { + this.stop = () => this.runAll("stop"), this.animations = e.filter(Boolean); + } + then(e, r) { + return Promise.all(this.animations).then(e).catch(r); + } + /** + * TODO: Filter out cancelled or stopped animations before returning + */ + getAll(e) { + return this.animations[0][e]; + } + setAll(e, r) { + for (let n = 0; n < this.animations.length; n++) + this.animations[n][e] = r; + } + attachTimeline(e, r) { + const n = this.animations.map((i) => WJ() && i.attachTimeline ? i.attachTimeline(e) : r(i)); + return () => { + n.forEach((i, s) => { + i && i(), this.animations[s].stop(); + }); + }; + } + get time() { + return this.getAll("time"); + } + set time(e) { + this.setAll("time", e); + } + get speed() { + return this.getAll("speed"); + } + set speed(e) { + this.setAll("speed", e); + } + get startTime() { + return this.getAll("startTime"); + } + get duration() { + let e = 0; + for (let r = 0; r < this.animations.length; r++) + e = Math.max(e, this.animations[r].duration); + return e; + } + runAll(e) { + this.animations.forEach((r) => r[e]()); + } + flatten() { + this.runAll("flatten"); + } + play() { + this.runAll("play"); + } + pause() { + this.runAll("pause"); + } + cancel() { + this.runAll("cancel"); + } + complete() { + this.runAll("complete"); + } +} +function VJ({ when: t, delay: e, delayChildren: r, staggerChildren: n, staggerDirection: i, repeat: s, repeatType: o, repeatDelay: a, from: f, elapsed: u, ...h }) { + return !!Object.keys(h).length; +} +const cb = (t, e, r, n = {}, i, s) => (o) => { + const a = G1(n, t) || {}, f = a.delay || n.delay || 0; + let { elapsed: u = 0 } = n; + u = u - Cs(f); + let h = { + keyframes: Array.isArray(r) ? r : [null, r], + ease: "easeOut", + velocity: e.getVelocity(), + ...a, + delay: -u, + onUpdate: (v) => { + e.set(v), a.onUpdate && a.onUpdate(v); + }, + onComplete: () => { + o(), a.onComplete && a.onComplete(); + }, + name: t, + motionValue: e, + element: s ? void 0 : i + }; + VJ(a) || (h = { + ...h, + ...lY(t, h) + }), h.duration && (h.duration = Cs(h.duration)), h.repeatDelay && (h.repeatDelay = Cs(h.repeatDelay)), h.from !== void 0 && (h.keyframes[0] = h.from); + let g = !1; + if ((h.type === !1 || h.duration === 0 && !h.repeatDelay) && (h.duration = 0, h.delay === 0 && (g = !0)), g && !s && e.get() !== void 0) { + const v = y0(h.keyframes, a); + if (v !== void 0) + return kr.update(() => { + h.onUpdate(v), h.onComplete(); + }), new KJ([]); + } + return !s && O6.supports(h) ? new O6(h) : new ob(h); +}, GJ = (t) => !!(t && typeof t == "object" && t.mix && t.toValue), YJ = (t) => Mv(t) ? t[t.length - 1] || 0 : t; +function ub(t, e) { + t.indexOf(e) === -1 && t.push(e); +} +function fb(t, e) { + const r = t.indexOf(e); + r > -1 && t.splice(r, 1); +} +class lb { + constructor() { + this.subscriptions = []; + } + add(e) { + return ub(this.subscriptions, e), () => fb(this.subscriptions, e); + } + notify(e, r, n) { + const i = this.subscriptions.length; + if (i) + if (i === 1) + this.subscriptions[0](e, r, n); + else + for (let s = 0; s < i; s++) { + const o = this.subscriptions[s]; + o && o(e, r, n); + } + } + getSize() { + return this.subscriptions.length; + } + clear() { + this.subscriptions.length = 0; + } +} +const N6 = 30, JJ = (t) => !isNaN(parseFloat(t)); +class XJ { + /** + * @param init - The initiating value + * @param config - Optional configuration options + * + * - `transformer`: A function to transform incoming values with. + * + * @internal + */ + constructor(e, r = {}) { + this.version = "11.11.17", this.canTrackVelocity = null, this.events = {}, this.updateAndNotify = (n, i = !0) => { + const s = Ts.now(); + this.updatedAt !== s && this.setPrevFrameValue(), this.prev = this.current, this.setCurrent(n), this.current !== this.prev && this.events.change && this.events.change.notify(this.current), i && this.events.renderRequest && this.events.renderRequest.notify(this.current); + }, this.hasAnimated = !1, this.setCurrent(e), this.owner = r.owner; + } + setCurrent(e) { + this.current = e, this.updatedAt = Ts.now(), this.canTrackVelocity === null && e !== void 0 && (this.canTrackVelocity = JJ(this.current)); + } + setPrevFrameValue(e = this.current) { + this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt; + } + /** + * Adds a function that will be notified when the `MotionValue` is updated. + * + * It returns a function that, when called, will cancel the subscription. + * + * When calling `onChange` inside a React component, it should be wrapped with the + * `useEffect` hook. As it returns an unsubscribe function, this should be returned + * from the `useEffect` function to ensure you don't add duplicate subscribers.. + * + * ```jsx + * export const MyComponent = () => { + * const x = useMotionValue(0) + * const y = useMotionValue(0) + * const opacity = useMotionValue(1) + * + * useEffect(() => { + * function updateOpacity() { + * const maxXY = Math.max(x.get(), y.get()) + * const newOpacity = transform(maxXY, [0, 100], [1, 0]) + * opacity.set(newOpacity) + * } + * + * const unsubscribeX = x.on("change", updateOpacity) + * const unsubscribeY = y.on("change", updateOpacity) + * + * return () => { + * unsubscribeX() + * unsubscribeY() + * } + * }, []) + * + * return + * } + * ``` + * + * @param subscriber - A function that receives the latest value. + * @returns A function that, when called, will cancel this subscription. + * + * @deprecated + */ + onChange(e) { + return process.env.NODE_ENV !== "production" && m0(!1, 'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'), this.on("change", e); + } + on(e, r) { + this.events[e] || (this.events[e] = new lb()); + const n = this.events[e].add(r); + return e === "change" ? () => { + n(), kr.read(() => { + this.events.change.getSize() || this.stop(); + }); + } : n; + } + clearListeners() { + for (const e in this.events) + this.events[e].clear(); + } + /** + * Attaches a passive effect to the `MotionValue`. + * + * @internal + */ + attach(e, r) { + this.passiveEffect = e, this.stopPassiveEffect = r; + } + /** + * Sets the state of the `MotionValue`. + * + * @remarks + * + * ```jsx + * const x = useMotionValue(0) + * x.set(10) + * ``` + * + * @param latest - Latest value to set. + * @param render - Whether to notify render subscribers. Defaults to `true` + * + * @public + */ + set(e, r = !0) { + !r || !this.passiveEffect ? this.updateAndNotify(e, r) : this.passiveEffect(e, this.updateAndNotify); + } + setWithVelocity(e, r, n) { + this.set(r), this.prev = void 0, this.prevFrameValue = e, this.prevUpdatedAt = this.updatedAt - n; + } + /** + * Set the state of the `MotionValue`, stopping any active animations, + * effects, and resets velocity to `0`. + */ + jump(e, r = !0) { + this.updateAndNotify(e), this.prev = e, this.prevUpdatedAt = this.prevFrameValue = void 0, r && this.stop(), this.stopPassiveEffect && this.stopPassiveEffect(); + } + /** + * Returns the latest state of `MotionValue` + * + * @returns - The latest state of `MotionValue` + * + * @public + */ + get() { + return this.current; + } + /** + * @public + */ + getPrevious() { + return this.prev; + } + /** + * Returns the latest velocity of `MotionValue` + * + * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical. + * + * @public + */ + getVelocity() { + const e = Ts.now(); + if (!this.canTrackVelocity || this.prevFrameValue === void 0 || e - this.updatedAt > N6) + return 0; + const r = Math.min(this.updatedAt - this.prevUpdatedAt, N6); + return e7(parseFloat(this.current) - parseFloat(this.prevFrameValue), r); + } + /** + * Registers a new animation to control this `MotionValue`. Only one + * animation can drive a `MotionValue` at one time. + * + * ```jsx + * value.start() + * ``` + * + * @param animation - A function that starts the provided animation + * + * @internal + */ + start(e) { + return this.stop(), new Promise((r) => { + this.hasAnimated = !0, this.animation = e(r), this.events.animationStart && this.events.animationStart.notify(); + }).then(() => { + this.events.animationComplete && this.events.animationComplete.notify(), this.clearAnimation(); + }); + } + /** + * Stop the currently active animation. + * + * @public + */ + stop() { + this.animation && (this.animation.stop(), this.events.animationCancel && this.events.animationCancel.notify()), this.clearAnimation(); + } + /** + * Returns `true` if this value is currently animating. + * + * @public + */ + isAnimating() { + return !!this.animation; + } + clearAnimation() { + delete this.animation; + } + /** + * Destroy and clean up subscribers to this `MotionValue`. + * + * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically + * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually + * created a `MotionValue` via the `motionValue` function. + * + * @public + */ + destroy() { + this.clearListeners(), this.stop(), this.stopPassiveEffect && this.stopPassiveEffect(); + } +} +function zf(t, e) { + return new XJ(t, e); +} +function ZJ(t, e, r) { + t.hasValue(e) ? t.getValue(e).set(r) : t.addValue(e, zf(r)); +} +function QJ(t, e) { + const r = b0(t, e); + let { transitionEnd: n = {}, transition: i = {}, ...s } = r || {}; + s = { ...s, ...n }; + for (const o in s) { + const a = YJ(s[o]); + ZJ(t, o, a); + } +} +const hb = (t) => t.replace(/([a-z])([A-Z])/gu, "$1-$2").toLowerCase(), eX = "framerAppearId", u7 = "data-" + hb(eX); +function f7(t) { + return t.props[u7]; +} +const Wn = (t) => !!(t && t.getVelocity); +function tX(t) { + return !!(Wn(t) && t.add); +} +function Lv(t, e) { + const r = t.getValue("willChange"); + if (tX(r)) + return r.add(e); +} +function rX({ protectedKeys: t, needsAnimating: e }, r) { + const n = t.hasOwnProperty(r) && e[r] !== !0; + return e[r] = !1, n; +} +function l7(t, e, { delay: r = 0, transitionOverride: n, type: i } = {}) { + var s; + let { transition: o = t.getDefaultTransition(), transitionEnd: a, ...f } = e; + n && (o = n); + const u = [], h = i && t.animationState && t.animationState.getState()[i]; + for (const g in f) { + const v = t.getValue(g, (s = t.latestValues[g]) !== null && s !== void 0 ? s : null), x = f[g]; + if (x === void 0 || h && rX(h, g)) + continue; + const S = { + delay: r, + ...G1(o || {}, g) + }; + let R = !1; + if (window.MotionHandoffAnimation) { + const k = f7(t); + if (k) { + const N = window.MotionHandoffAnimation(k, g, kr); + N !== null && (S.startTime = N, R = !0); + } + } + Lv(t, g), v.start(cb(g, v, x, t.shouldReduceMotion && Ya.has(g) ? { type: !1 } : S, t, R)); + const D = v.animation; + D && u.push(D); + } + return a && Promise.all(u).then(() => { + kr.update(() => { + a && QJ(t, a); + }); + }), u; +} +function kv(t, e, r = {}) { + var n; + const i = b0(t, e, r.type === "exit" ? (n = t.presenceContext) === null || n === void 0 ? void 0 : n.custom : void 0); + let { transition: s = t.getDefaultTransition() || {} } = i || {}; + r.transitionOverride && (s = r.transitionOverride); + const o = i ? () => Promise.all(l7(t, i, r)) : () => Promise.resolve(), a = t.variantChildren && t.variantChildren.size ? (u = 0) => { + const { delayChildren: h = 0, staggerChildren: g, staggerDirection: v } = s; + return nX(t, e, h + u, g, v, r); + } : () => Promise.resolve(), { when: f } = s; + if (f) { + const [u, h] = f === "beforeChildren" ? [o, a] : [a, o]; + return u().then(() => h()); + } else + return Promise.all([o(), a(r.delay)]); +} +function nX(t, e, r = 0, n = 0, i = 1, s) { + const o = [], a = (t.variantChildren.size - 1) * n, f = i === 1 ? (u = 0) => u * n : (u = 0) => a - u * n; + return Array.from(t.variantChildren).sort(iX).forEach((u, h) => { + u.notify("AnimationStart", e), o.push(kv(u, e, { + ...s, + delay: r + f(h) + }).then(() => u.notify("AnimationComplete", e))); + }), Promise.all(o); +} +function iX(t, e) { + return t.sortNodePosition(e); +} +function sX(t, e, r = {}) { + t.notify("AnimationStart", e); + let n; + if (Array.isArray(e)) { + const i = e.map((s) => kv(t, s, r)); + n = Promise.all(i); + } else if (typeof e == "string") + n = kv(t, e, r); + else { + const i = typeof e == "function" ? b0(t, e, r.custom) : e; + n = Promise.all(l7(t, i, r)); + } + return n.then(() => { + t.notify("AnimationComplete", e); + }); +} +const oX = V1.length; +function h7(t) { + if (!t) + return; + if (!t.isControllingVariants) { + const r = t.parent ? h7(t.parent) || {} : {}; + return t.props.initial !== void 0 && (r.initial = t.props.initial), r; + } + const e = {}; + for (let r = 0; r < oX; r++) { + const n = V1[r], i = t.props[n]; + (jf(i) || i === !1) && (e[n] = i); + } + return e; +} +const aX = [...K1].reverse(), cX = K1.length; +function uX(t) { + return (e) => Promise.all(e.map(({ animation: r, options: n }) => sX(t, r, n))); +} +function fX(t) { + let e = uX(t), r = L6(), n = !0; + const i = (f) => (u, h) => { + var g; + const v = b0(t, h, f === "exit" ? (g = t.presenceContext) === null || g === void 0 ? void 0 : g.custom : void 0); + if (v) { + const { transition: x, transitionEnd: S, ...R } = v; + u = { ...u, ...R, ...S }; + } + return u; + }; + function s(f) { + e = f(t); + } + function o(f) { + const { props: u } = t, h = h7(t.parent) || {}, g = [], v = /* @__PURE__ */ new Set(); + let x = {}, S = 1 / 0; + for (let D = 0; D < cX; D++) { + const k = aX[D], N = r[k], z = u[k] !== void 0 ? u[k] : h[k], B = jf(z), $ = k === f ? N.isActive : null; + $ === !1 && (S = D); + let U = z === h[k] && z !== u[k] && B; + if (U && n && t.manuallyAnimateOnMount && (U = !1), N.protectedKeys = { ...x }, // If it isn't active and hasn't *just* been set as inactive + !N.isActive && $ === null || // If we didn't and don't have any defined prop for this animation type + !z && !N.prevProp || // Or if the prop doesn't define an animation + v0(z) || typeof z == "boolean") + continue; + const C = lX(N.prevProp, z); + let W = C || // If we're making this variant active, we want to always make it active + k === f && N.isActive && !U && B || // If we removed a higher-priority variant (i is in reverse order) + D > S && B, J = !1; + const ne = Array.isArray(z) ? z : [z]; + let K = ne.reduce(i(k), {}); + $ === !1 && (K = {}); + const { prevResolvedValues: E = {} } = N, b = { + ...E, + ...K + }, l = (w) => { + W = !0, v.has(w) && (J = !0, v.delete(w)), N.needsAnimating[w] = !0; + const P = t.getValue(w); + P && (P.liveStyle = !1); + }; + for (const w in b) { + const P = K[w], _ = E[w]; + if (x.hasOwnProperty(w)) + continue; + let y = !1; + Mv(P) && Mv(_) ? y = !MS(P, _) : y = P !== _, y ? P != null ? l(w) : v.add(w) : P !== void 0 && v.has(w) ? l(w) : N.protectedKeys[w] = !0; + } + N.prevProp = z, N.prevResolvedValues = K, N.isActive && (x = { ...x, ...K }), n && t.blockInitialAnimation && (W = !1), W && (!(U && C) || J) && g.push(...ne.map((w) => ({ + animation: w, + options: { type: k } + }))); + } + if (v.size) { + const D = {}; + v.forEach((k) => { + const N = t.getBaseTarget(k), z = t.getValue(k); + z && (z.liveStyle = !0), D[k] = N ?? null; + }), g.push({ animation: D }); + } + let R = !!g.length; + return n && (u.initial === !1 || u.initial === u.animate) && !t.manuallyAnimateOnMount && (R = !1), n = !1, R ? e(g) : Promise.resolve(); + } + function a(f, u) { + var h; + if (r[f].isActive === u) + return Promise.resolve(); + (h = t.variantChildren) === null || h === void 0 || h.forEach((v) => { + var x; + return (x = v.animationState) === null || x === void 0 ? void 0 : x.setActive(f, u); + }), r[f].isActive = u; + const g = o(f); + for (const v in r) + r[v].protectedKeys = {}; + return g; + } + return { + animateChanges: o, + setActive: a, + setAnimateFunction: s, + getState: () => r, + reset: () => { + r = L6(), n = !0; + } + }; +} +function lX(t, e) { + return typeof e == "string" ? e !== t : Array.isArray(e) ? !MS(e, t) : !1; +} +function va(t = !1) { + return { + isActive: t, + protectedKeys: {}, + needsAnimating: {}, + prevResolvedValues: {} + }; +} +function L6() { + return { + animate: va(!0), + whileInView: va(), + whileHover: va(), + whileTap: va(), + whileDrag: va(), + whileFocus: va(), + exit: va() + }; +} +class ea { + constructor(e) { + this.isMounted = !1, this.node = e; + } + update() { + } +} +class hX extends ea { + /** + * We dynamically generate the AnimationState manager as it contains a reference + * to the underlying animation library. We only want to load that if we load this, + * so people can optionally code split it out using the `m` component. + */ + constructor(e) { + super(e), e.animationState || (e.animationState = fX(e)); + } + updateAnimationControlsSubscription() { + const { animate: e } = this.node.getProps(); + v0(e) && (this.unmountControls = e.subscribe(this.node)); + } + /** + * Subscribe any provided AnimationControls to the component's VisualElement + */ + mount() { + this.updateAnimationControlsSubscription(); + } + update() { + const { animate: e } = this.node.getProps(), { animate: r } = this.node.prevProps || {}; + e !== r && this.updateAnimationControlsSubscription(); + } + unmount() { + var e; + this.node.animationState.reset(), (e = this.unmountControls) === null || e === void 0 || e.call(this); + } +} +let dX = 0; +class pX extends ea { + constructor() { + super(...arguments), this.id = dX++; + } + update() { + if (!this.node.presenceContext) + return; + const { isPresent: e, onExitComplete: r } = this.node.presenceContext, { isPresent: n } = this.node.prevPresenceContext || {}; + if (!this.node.animationState || e === n) + return; + const i = this.node.animationState.setActive("exit", !e); + r && !e && i.then(() => r(this.id)); + } + mount() { + const { register: e } = this.node.presenceContext || {}; + e && (this.unmount = e(this.id)); + } + unmount() { + } +} +const gX = { + animation: { + Feature: hX + }, + exit: { + Feature: pX + } +}, d7 = (t) => t.pointerType === "mouse" ? typeof t.button != "number" || t.button <= 0 : t.isPrimary !== !1; +function w0(t, e = "page") { + return { + point: { + x: t[`${e}X`], + y: t[`${e}Y`] + } + }; +} +const mX = (t) => (e) => d7(e) && t(e, w0(e)); +function no(t, e, r, n = { passive: !0 }) { + return t.addEventListener(e, r, n), () => t.removeEventListener(e, r); +} +function co(t, e, r, n) { + return no(t, e, mX(r), n); +} +const k6 = (t, e) => Math.abs(t - e); +function vX(t, e) { + const r = k6(t.x, e.x), n = k6(t.y, e.y); + return Math.sqrt(r ** 2 + n ** 2); +} +class p7 { + constructor(e, r, { transformPagePoint: n, contextWindow: i, dragSnapToOrigin: s = !1 } = {}) { + if (this.startEvent = null, this.lastMoveEvent = null, this.lastMoveEventInfo = null, this.handlers = {}, this.contextWindow = window, this.updatePoint = () => { + if (!(this.lastMoveEvent && this.lastMoveEventInfo)) + return; + const g = Sm(this.lastMoveEventInfo, this.history), v = this.startEvent !== null, x = vX(g.offset, { x: 0, y: 0 }) >= 3; + if (!v && !x) + return; + const { point: S } = g, { timestamp: R } = Nn; + this.history.push({ ...S, timestamp: R }); + const { onStart: D, onMove: k } = this.handlers; + v || (D && D(this.lastMoveEvent, g), this.startEvent = this.lastMoveEvent), k && k(this.lastMoveEvent, g); + }, this.handlePointerMove = (g, v) => { + this.lastMoveEvent = g, this.lastMoveEventInfo = Em(v, this.transformPagePoint), kr.update(this.updatePoint, !0); + }, this.handlePointerUp = (g, v) => { + this.end(); + const { onEnd: x, onSessionEnd: S, resumeAnimation: R } = this.handlers; + if (this.dragSnapToOrigin && R && R(), !(this.lastMoveEvent && this.lastMoveEventInfo)) + return; + const D = Sm(g.type === "pointercancel" ? this.lastMoveEventInfo : Em(v, this.transformPagePoint), this.history); + this.startEvent && x && x(g, D), S && S(g, D); + }, !d7(e)) + return; + this.dragSnapToOrigin = s, this.handlers = r, this.transformPagePoint = n, this.contextWindow = i || window; + const o = w0(e), a = Em(o, this.transformPagePoint), { point: f } = a, { timestamp: u } = Nn; + this.history = [{ ...f, timestamp: u }]; + const { onSessionStart: h } = r; + h && h(e, Sm(a, this.history)), this.removeListeners = ao(co(this.contextWindow, "pointermove", this.handlePointerMove), co(this.contextWindow, "pointerup", this.handlePointerUp), co(this.contextWindow, "pointercancel", this.handlePointerUp)); + } + updateHandlers(e) { + this.handlers = e; + } + end() { + this.removeListeners && this.removeListeners(), Vo(this.updatePoint); + } +} +function Em(t, e) { + return e ? { point: e(t.point) } : t; +} +function $6(t, e) { + return { x: t.x - e.x, y: t.y - e.y }; +} +function Sm({ point: t }, e) { + return { + point: t, + delta: $6(t, g7(e)), + offset: $6(t, bX(e)), + velocity: yX(e, 0.1) + }; +} +function bX(t) { + return t[0]; +} +function g7(t) { + return t[t.length - 1]; +} +function yX(t, e) { + if (t.length < 2) + return { x: 0, y: 0 }; + let r = t.length - 1, n = null; + const i = g7(t); + for (; r >= 0 && (n = t[r], !(i.timestamp - n.timestamp > Cs(e))); ) + r--; + if (!n) + return { x: 0, y: 0 }; + const s = oo(i.timestamp - n.timestamp); + if (s === 0) + return { x: 0, y: 0 }; + const o = { + x: (i.x - n.x) / s, + y: (i.y - n.y) / s + }; + return o.x === 1 / 0 && (o.x = 0), o.y === 1 / 0 && (o.y = 0), o; +} +function m7(t) { + let e = null; + return () => { + const r = () => { + e = null; + }; + return e === null ? (e = t, r) : !1; + }; +} +const B6 = m7("dragHorizontal"), F6 = m7("dragVertical"); +function v7(t) { + let e = !1; + if (t === "y") + e = F6(); + else if (t === "x") + e = B6(); + else { + const r = B6(), n = F6(); + r && n ? e = () => { + r(), n(); + } : (r && r(), n && n()); + } + return e; +} +function b7() { + const t = v7(!0); + return t ? (t(), !1) : !0; +} +function Ec(t) { + return t && typeof t == "object" && Object.prototype.hasOwnProperty.call(t, "current"); +} +const y7 = 1e-4, wX = 1 - y7, xX = 1 + y7, w7 = 0.01, _X = 0 - w7, EX = 0 + w7; +function Pi(t) { + return t.max - t.min; +} +function SX(t, e, r) { + return Math.abs(t - e) <= r; +} +function j6(t, e, r, n = 0.5) { + t.origin = n, t.originPoint = Qr(e.min, e.max, t.origin), t.scale = Pi(r) / Pi(e), t.translate = Qr(r.min, r.max, t.origin) - t.originPoint, (t.scale >= wX && t.scale <= xX || isNaN(t.scale)) && (t.scale = 1), (t.translate >= _X && t.translate <= EX || isNaN(t.translate)) && (t.translate = 0); +} +function cf(t, e, r, n) { + j6(t.x, e.x, r.x, n ? n.originX : void 0), j6(t.y, e.y, r.y, n ? n.originY : void 0); +} +function U6(t, e, r) { + t.min = r.min + e.min, t.max = t.min + Pi(e); +} +function AX(t, e, r) { + U6(t.x, e.x, r.x), U6(t.y, e.y, r.y); +} +function q6(t, e, r) { + t.min = e.min - r.min, t.max = t.min + Pi(e); +} +function uf(t, e, r) { + q6(t.x, e.x, r.x), q6(t.y, e.y, r.y); +} +function PX(t, { min: e, max: r }, n) { + return e !== void 0 && t < e ? t = n ? Qr(e, t, n.min) : Math.max(t, e) : r !== void 0 && t > r && (t = n ? Qr(r, t, n.max) : Math.min(t, r)), t; +} +function z6(t, e, r) { + return { + min: e !== void 0 ? t.min + e : void 0, + max: r !== void 0 ? t.max + r - (t.max - t.min) : void 0 + }; +} +function MX(t, { top: e, left: r, bottom: n, right: i }) { + return { + x: z6(t.x, r, i), + y: z6(t.y, e, n) + }; +} +function H6(t, e) { + let r = e.min - t.min, n = e.max - t.max; + return e.max - e.min < t.max - t.min && ([r, n] = [n, r]), { min: r, max: n }; +} +function IX(t, e) { + return { + x: H6(t.x, e.x), + y: H6(t.y, e.y) + }; +} +function CX(t, e) { + let r = 0.5; + const n = Pi(t), i = Pi(e); + return i > n ? r = Hc(e.min, e.max - n, t.min) : n > i && (r = Hc(t.min, t.max - i, e.min)), Go(0, 1, r); +} +function RX(t, e) { + const r = {}; + return e.min !== void 0 && (r.min = e.min - t.min), e.max !== void 0 && (r.max = e.max - t.min), r; +} +const $v = 0.35; +function TX(t = $v) { + return t === !1 ? t = 0 : t === !0 && (t = $v), { + x: W6(t, "left", "right"), + y: W6(t, "top", "bottom") + }; +} +function W6(t, e, r) { + return { + min: K6(t, e), + max: K6(t, r) + }; +} +function K6(t, e) { + return typeof t == "number" ? t : t[e] || 0; +} +const V6 = () => ({ + translate: 0, + scale: 1, + origin: 0, + originPoint: 0 +}), Sc = () => ({ + x: V6(), + y: V6() +}), G6 = () => ({ min: 0, max: 0 }), fn = () => ({ + x: G6(), + y: G6() +}); +function Ui(t) { + return [t("x"), t("y")]; +} +function x7({ top: t, left: e, right: r, bottom: n }) { + return { + x: { min: e, max: r }, + y: { min: t, max: n } + }; +} +function DX({ x: t, y: e }) { + return { top: e.min, right: t.max, bottom: e.max, left: t.min }; +} +function OX(t, e) { + if (!e) + return t; + const r = e({ x: t.left, y: t.top }), n = e({ x: t.right, y: t.bottom }); + return { + top: r.y, + left: r.x, + bottom: n.y, + right: n.x + }; +} +function Am(t) { + return t === void 0 || t === 1; +} +function Bv({ scale: t, scaleX: e, scaleY: r }) { + return !Am(t) || !Am(e) || !Am(r); +} +function ya(t) { + return Bv(t) || _7(t) || t.z || t.rotate || t.rotateX || t.rotateY || t.skewX || t.skewY; +} +function _7(t) { + return Y6(t.x) || Y6(t.y); +} +function Y6(t) { + return t && t !== "0%"; +} +function Dd(t, e, r) { + const n = t - r, i = e * n; + return r + i; +} +function J6(t, e, r, n, i) { + return i !== void 0 && (t = Dd(t, i, n)), Dd(t, r, n) + e; +} +function Fv(t, e = 0, r = 1, n, i) { + t.min = J6(t.min, e, r, n, i), t.max = J6(t.max, e, r, n, i); +} +function E7(t, { x: e, y: r }) { + Fv(t.x, e.translate, e.scale, e.originPoint), Fv(t.y, r.translate, r.scale, r.originPoint); +} +const X6 = 0.999999999999, Z6 = 1.0000000000001; +function NX(t, e, r, n = !1) { + const i = r.length; + if (!i) + return; + e.x = e.y = 1; + let s, o; + for (let a = 0; a < i; a++) { + s = r[a], o = s.projectionDelta; + const { visualElement: f } = s.options; + f && f.props.style && f.props.style.display === "contents" || (n && s.options.layoutScroll && s.scroll && s !== s.root && Pc(t, { + x: -s.scroll.offset.x, + y: -s.scroll.offset.y + }), o && (e.x *= o.x.scale, e.y *= o.y.scale, E7(t, o)), n && ya(s.latestValues) && Pc(t, s.latestValues)); + } + e.x < Z6 && e.x > X6 && (e.x = 1), e.y < Z6 && e.y > X6 && (e.y = 1); +} +function Ac(t, e) { + t.min = t.min + e, t.max = t.max + e; +} +function Q6(t, e, r, n, i = 0.5) { + const s = Qr(t.min, t.max, i); + Fv(t, e, r, s, n); +} +function Pc(t, e) { + Q6(t.x, e.x, e.scaleX, e.scale, e.originX), Q6(t.y, e.y, e.scaleY, e.scale, e.originY); +} +function S7(t, e) { + return x7(OX(t.getBoundingClientRect(), e)); +} +function LX(t, e, r) { + const n = S7(t, r), { scroll: i } = e; + return i && (Ac(n.x, i.offset.x), Ac(n.y, i.offset.y)), n; +} +const A7 = ({ current: t }) => t ? t.ownerDocument.defaultView : null, kX = /* @__PURE__ */ new WeakMap(); +class $X { + constructor(e) { + this.openGlobalLock = null, this.isDragging = !1, this.currentDirection = null, this.originPoint = { x: 0, y: 0 }, this.constraints = !1, this.hasMutatedConstraints = !1, this.elastic = fn(), this.visualElement = e; + } + start(e, { snapToCursor: r = !1 } = {}) { + const { presenceContext: n } = this.visualElement; + if (n && n.isPresent === !1) + return; + const i = (h) => { + const { dragSnapToOrigin: g } = this.getProps(); + g ? this.pauseAnimation() : this.stopAnimation(), r && this.snapToCursor(w0(h, "page").point); + }, s = (h, g) => { + const { drag: v, dragPropagation: x, onDragStart: S } = this.getProps(); + if (v && !x && (this.openGlobalLock && this.openGlobalLock(), this.openGlobalLock = v7(v), !this.openGlobalLock)) + return; + this.isDragging = !0, this.currentDirection = null, this.resolveConstraints(), this.visualElement.projection && (this.visualElement.projection.isAnimationBlocked = !0, this.visualElement.projection.target = void 0), Ui((D) => { + let k = this.getAxisMotionValue(D).get() || 0; + if (Rs.test(k)) { + const { projection: N } = this.visualElement; + if (N && N.layout) { + const z = N.layout.layoutBox[D]; + z && (k = Pi(z) * (parseFloat(k) / 100)); + } + } + this.originPoint[D] = k; + }), S && kr.postRender(() => S(h, g)), Lv(this.visualElement, "transform"); + const { animationState: R } = this.visualElement; + R && R.setActive("whileDrag", !0); + }, o = (h, g) => { + const { dragPropagation: v, dragDirectionLock: x, onDirectionLock: S, onDrag: R } = this.getProps(); + if (!v && !this.openGlobalLock) + return; + const { offset: D } = g; + if (x && this.currentDirection === null) { + this.currentDirection = BX(D), this.currentDirection !== null && S && S(this.currentDirection); + return; + } + this.updateAxis("x", g.point, D), this.updateAxis("y", g.point, D), this.visualElement.render(), R && R(h, g); + }, a = (h, g) => this.stop(h, g), f = () => Ui((h) => { + var g; + return this.getAnimationState(h) === "paused" && ((g = this.getAxisMotionValue(h).animation) === null || g === void 0 ? void 0 : g.play()); + }), { dragSnapToOrigin: u } = this.getProps(); + this.panSession = new p7(e, { + onSessionStart: i, + onStart: s, + onMove: o, + onSessionEnd: a, + resumeAnimation: f + }, { + transformPagePoint: this.visualElement.getTransformPagePoint(), + dragSnapToOrigin: u, + contextWindow: A7(this.visualElement) + }); + } + stop(e, r) { + const n = this.isDragging; + if (this.cancel(), !n) + return; + const { velocity: i } = r; + this.startAnimation(i); + const { onDragEnd: s } = this.getProps(); + s && kr.postRender(() => s(e, r)); + } + cancel() { + this.isDragging = !1; + const { projection: e, animationState: r } = this.visualElement; + e && (e.isAnimationBlocked = !1), this.panSession && this.panSession.end(), this.panSession = void 0; + const { dragPropagation: n } = this.getProps(); + !n && this.openGlobalLock && (this.openGlobalLock(), this.openGlobalLock = null), r && r.setActive("whileDrag", !1); + } + updateAxis(e, r, n) { + const { drag: i } = this.getProps(); + if (!n || !Rh(e, i, this.currentDirection)) + return; + const s = this.getAxisMotionValue(e); + let o = this.originPoint[e] + n[e]; + this.constraints && this.constraints[e] && (o = PX(o, this.constraints[e], this.elastic[e])), s.set(o); + } + resolveConstraints() { + var e; + const { dragConstraints: r, dragElastic: n } = this.getProps(), i = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(!1) : (e = this.visualElement.projection) === null || e === void 0 ? void 0 : e.layout, s = this.constraints; + r && Ec(r) ? this.constraints || (this.constraints = this.resolveRefConstraints()) : r && i ? this.constraints = MX(i.layoutBox, r) : this.constraints = !1, this.elastic = TX(n), s !== this.constraints && i && this.constraints && !this.hasMutatedConstraints && Ui((o) => { + this.constraints !== !1 && this.getAxisMotionValue(o) && (this.constraints[o] = RX(i.layoutBox[o], this.constraints[o])); + }); + } + resolveRefConstraints() { + const { dragConstraints: e, onMeasureDragConstraints: r } = this.getProps(); + if (!e || !Ec(e)) + return !1; + const n = e.current; + po(n !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop."); + const { projection: i } = this.visualElement; + if (!i || !i.layout) + return !1; + const s = LX(n, i.root, this.visualElement.getTransformPagePoint()); + let o = IX(i.layout.layoutBox, s); + if (r) { + const a = r(DX(o)); + this.hasMutatedConstraints = !!a, a && (o = x7(a)); + } + return o; + } + startAnimation(e) { + const { drag: r, dragMomentum: n, dragElastic: i, dragTransition: s, dragSnapToOrigin: o, onDragTransitionEnd: a } = this.getProps(), f = this.constraints || {}, u = Ui((h) => { + if (!Rh(h, r, this.currentDirection)) + return; + let g = f && f[h] || {}; + o && (g = { min: 0, max: 0 }); + const v = i ? 200 : 1e6, x = i ? 40 : 1e7, S = { + type: "inertia", + velocity: n ? e[h] : 0, + bounceStiffness: v, + bounceDamping: x, + timeConstant: 750, + restDelta: 1, + restSpeed: 10, + ...s, + ...g + }; + return this.startAxisValueAnimation(h, S); + }); + return Promise.all(u).then(a); + } + startAxisValueAnimation(e, r) { + const n = this.getAxisMotionValue(e); + return Lv(this.visualElement, e), n.start(cb(e, n, 0, r, this.visualElement, !1)); + } + stopAnimation() { + Ui((e) => this.getAxisMotionValue(e).stop()); + } + pauseAnimation() { + Ui((e) => { + var r; + return (r = this.getAxisMotionValue(e).animation) === null || r === void 0 ? void 0 : r.pause(); + }); + } + getAnimationState(e) { + var r; + return (r = this.getAxisMotionValue(e).animation) === null || r === void 0 ? void 0 : r.state; + } + /** + * Drag works differently depending on which props are provided. + * + * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values. + * - Otherwise, we apply the delta to the x/y motion values. + */ + getAxisMotionValue(e) { + const r = `_drag${e.toUpperCase()}`, n = this.visualElement.getProps(), i = n[r]; + return i || this.visualElement.getValue(e, (n.initial ? n.initial[e] : void 0) || 0); + } + snapToCursor(e) { + Ui((r) => { + const { drag: n } = this.getProps(); + if (!Rh(r, n, this.currentDirection)) + return; + const { projection: i } = this.visualElement, s = this.getAxisMotionValue(r); + if (i && i.layout) { + const { min: o, max: a } = i.layout.layoutBox[r]; + s.set(e[r] - Qr(o, a, 0.5)); + } + }); + } + /** + * When the viewport resizes we want to check if the measured constraints + * have changed and, if so, reposition the element within those new constraints + * relative to where it was before the resize. + */ + scalePositionWithinConstraints() { + if (!this.visualElement.current) + return; + const { drag: e, dragConstraints: r } = this.getProps(), { projection: n } = this.visualElement; + if (!Ec(r) || !n || !this.constraints) + return; + this.stopAnimation(); + const i = { x: 0, y: 0 }; + Ui((o) => { + const a = this.getAxisMotionValue(o); + if (a && this.constraints !== !1) { + const f = a.get(); + i[o] = CX({ min: f, max: f }, this.constraints[o]); + } + }); + const { transformTemplate: s } = this.visualElement.getProps(); + this.visualElement.current.style.transform = s ? s({}, "") : "none", n.root && n.root.updateScroll(), n.updateLayout(), this.resolveConstraints(), Ui((o) => { + if (!Rh(o, e, null)) + return; + const a = this.getAxisMotionValue(o), { min: f, max: u } = this.constraints[o]; + a.set(Qr(f, u, i[o])); + }); + } + addListeners() { + if (!this.visualElement.current) + return; + kX.set(this.visualElement, this); + const e = this.visualElement.current, r = co(e, "pointerdown", (f) => { + const { drag: u, dragListener: h = !0 } = this.getProps(); + u && h && this.start(f); + }), n = () => { + const { dragConstraints: f } = this.getProps(); + Ec(f) && f.current && (this.constraints = this.resolveRefConstraints()); + }, { projection: i } = this.visualElement, s = i.addEventListener("measure", n); + i && !i.layout && (i.root && i.root.updateScroll(), i.updateLayout()), kr.read(n); + const o = no(window, "resize", () => this.scalePositionWithinConstraints()), a = i.addEventListener("didUpdate", (({ delta: f, hasLayoutChanged: u }) => { + this.isDragging && u && (Ui((h) => { + const g = this.getAxisMotionValue(h); + g && (this.originPoint[h] += f[h].translate, g.set(g.get() + f[h].translate)); + }), this.visualElement.render()); + })); + return () => { + o(), r(), s(), a && a(); + }; + } + getProps() { + const e = this.visualElement.getProps(), { drag: r = !1, dragDirectionLock: n = !1, dragPropagation: i = !1, dragConstraints: s = !1, dragElastic: o = $v, dragMomentum: a = !0 } = e; + return { + ...e, + drag: r, + dragDirectionLock: n, + dragPropagation: i, + dragConstraints: s, + dragElastic: o, + dragMomentum: a + }; + } +} +function Rh(t, e, r) { + return (e === !0 || e === t) && (r === null || r === t); +} +function BX(t, e = 10) { + let r = null; + return Math.abs(t.y) > e ? r = "y" : Math.abs(t.x) > e && (r = "x"), r; +} +class FX extends ea { + constructor(e) { + super(e), this.removeGroupControls = kn, this.removeListeners = kn, this.controls = new $X(e); + } + mount() { + const { dragControls: e } = this.node.getProps(); + e && (this.removeGroupControls = e.subscribe(this.controls)), this.removeListeners = this.controls.addListeners() || kn; + } + unmount() { + this.removeGroupControls(), this.removeListeners(); + } +} +const e5 = (t) => (e, r) => { + t && kr.postRender(() => t(e, r)); +}; +class jX extends ea { + constructor() { + super(...arguments), this.removePointerDownListener = kn; + } + onPointerDown(e) { + this.session = new p7(e, this.createPanHandlers(), { + transformPagePoint: this.node.getTransformPagePoint(), + contextWindow: A7(this.node) + }); + } + createPanHandlers() { + const { onPanSessionStart: e, onPanStart: r, onPan: n, onPanEnd: i } = this.node.getProps(); + return { + onSessionStart: e5(e), + onStart: e5(r), + onMove: n, + onEnd: (s, o) => { + delete this.session, i && kr.postRender(() => i(s, o)); + } + }; + } + mount() { + this.removePointerDownListener = co(this.node.current, "pointerdown", (e) => this.onPointerDown(e)); + } + update() { + this.session && this.session.updateHandlers(this.createPanHandlers()); + } + unmount() { + this.removePointerDownListener(), this.session && this.session.end(); + } +} +const x0 = Xo(null); +function UX() { + const t = In(x0); + if (t === null) + return [!0, null]; + const { isPresent: e, onExitComplete: r, register: n } = t, i = Vv(); + Rn(() => n(i), []); + const s = Gv(() => r && r(i), [i, r]); + return !e && r ? [!1, s] : [!0]; +} +const db = Xo({}), P7 = Xo({}), td = { + /** + * Global flag as to whether the tree has animated since the last time + * we resized the window + */ + hasAnimatedSinceResize: !0, + /** + * We set this to true once, on the first update. Any nodes added to the tree beyond that + * update will be given a `data-projection-id` attribute. + */ + hasEverUpdated: !1 +}; +function t5(t, e) { + return e.max === e.min ? 0 : t / (e.max - e.min) * 100; +} +const qu = { + correct: (t, e) => { + if (!e.target) + return t; + if (typeof t == "string") + if (Vt.test(t)) + t = parseFloat(t); + else + return t; + const r = t5(t, e.target.x), n = t5(t, e.target.y); + return `${r}% ${n}%`; + } +}, qX = { + correct: (t, { treeScale: e, projectionDelta: r }) => { + const n = t, i = Yo.parse(t); + if (i.length > 5) + return n; + const s = Yo.createTransformer(t), o = typeof i[0] != "number" ? 1 : 0, a = r.x.scale * e.x, f = r.y.scale * e.y; + i[0 + o] /= a, i[1 + o] /= f; + const u = Qr(a, f, 0.5); + return typeof i[2 + o] == "number" && (i[2 + o] /= u), typeof i[3 + o] == "number" && (i[3 + o] /= u), s(i); + } +}, Od = {}; +function zX(t) { + Object.assign(Od, t); +} +const { schedule: pb } = IS(queueMicrotask, !1); +class HX extends lT { + /** + * This only mounts projection nodes for components that + * need measuring, we might want to do it for all components + * in order to incorporate transforms + */ + componentDidMount() { + const { visualElement: e, layoutGroup: r, switchLayoutGroup: n, layoutId: i } = this.props, { projection: s } = e; + zX(WX), s && (r.group && r.group.add(s), n && n.register && i && n.register(s), s.root.didUpdate(), s.addEventListener("animationComplete", () => { + this.safeToRemove(); + }), s.setOptions({ + ...s.options, + onExitComplete: () => this.safeToRemove() + })), td.hasEverUpdated = !0; + } + getSnapshotBeforeUpdate(e) { + const { layoutDependency: r, visualElement: n, drag: i, isPresent: s } = this.props, o = n.projection; + return o && (o.isPresent = s, i || e.layoutDependency !== r || r === void 0 ? o.willUpdate() : this.safeToRemove(), e.isPresent !== s && (s ? o.promote() : o.relegate() || kr.postRender(() => { + const a = o.getStack(); + (!a || !a.members.length) && this.safeToRemove(); + }))), null; + } + componentDidUpdate() { + const { projection: e } = this.props.visualElement; + e && (e.root.didUpdate(), pb.postRender(() => { + !e.currentAnimation && e.isLead() && this.safeToRemove(); + })); + } + componentWillUnmount() { + const { visualElement: e, layoutGroup: r, switchLayoutGroup: n } = this.props, { projection: i } = e; + i && (i.scheduleCheckAfterUnmount(), r && r.group && r.group.remove(i), n && n.deregister && n.deregister(i)); + } + safeToRemove() { + const { safeToRemove: e } = this.props; + e && e(); + } + render() { + return null; + } +} +function M7(t) { + const [e, r] = UX(), n = In(db); + return pe.jsx(HX, { ...t, layoutGroup: n, switchLayoutGroup: In(P7), isPresent: e, safeToRemove: r }); +} +const WX = { + borderRadius: { + ...qu, + applyTo: [ + "borderTopLeftRadius", + "borderTopRightRadius", + "borderBottomLeftRadius", + "borderBottomRightRadius" + ] + }, + borderTopLeftRadius: qu, + borderTopRightRadius: qu, + borderBottomLeftRadius: qu, + borderBottomRightRadius: qu, + boxShadow: qX +}, I7 = ["TopLeft", "TopRight", "BottomLeft", "BottomRight"], KX = I7.length, r5 = (t) => typeof t == "string" ? parseFloat(t) : t, n5 = (t) => typeof t == "number" || Vt.test(t); +function VX(t, e, r, n, i, s) { + i ? (t.opacity = Qr( + 0, + // TODO Reinstate this if only child + r.opacity !== void 0 ? r.opacity : 1, + GX(n) + ), t.opacityExit = Qr(e.opacity !== void 0 ? e.opacity : 1, 0, YX(n))) : s && (t.opacity = Qr(e.opacity !== void 0 ? e.opacity : 1, r.opacity !== void 0 ? r.opacity : 1, n)); + for (let o = 0; o < KX; o++) { + const a = `border${I7[o]}Radius`; + let f = i5(e, a), u = i5(r, a); + if (f === void 0 && u === void 0) + continue; + f || (f = 0), u || (u = 0), f === 0 || u === 0 || n5(f) === n5(u) ? (t[a] = Math.max(Qr(r5(f), r5(u), n), 0), (Rs.test(u) || Rs.test(f)) && (t[a] += "%")) : t[a] = u; + } + (e.rotate || r.rotate) && (t.rotate = Qr(e.rotate || 0, r.rotate || 0, n)); +} +function i5(t, e) { + return t[e] !== void 0 ? t[e] : t.borderRadius; +} +const GX = /* @__PURE__ */ C7(0, 0.5, LS), YX = /* @__PURE__ */ C7(0.5, 0.95, kn); +function C7(t, e, r) { + return (n) => n < t ? 0 : n > e ? 1 : r(Hc(t, e, n)); +} +function s5(t, e) { + t.min = e.min, t.max = e.max; +} +function Fi(t, e) { + s5(t.x, e.x), s5(t.y, e.y); +} +function o5(t, e) { + t.translate = e.translate, t.scale = e.scale, t.originPoint = e.originPoint, t.origin = e.origin; +} +function a5(t, e, r, n, i) { + return t -= e, t = Dd(t, 1 / r, n), i !== void 0 && (t = Dd(t, 1 / i, n)), t; +} +function JX(t, e = 0, r = 1, n = 0.5, i, s = t, o = t) { + if (Rs.test(e) && (e = parseFloat(e), e = Qr(o.min, o.max, e / 100) - o.min), typeof e != "number") + return; + let a = Qr(s.min, s.max, n); + t === s && (a -= e), t.min = a5(t.min, e, r, a, i), t.max = a5(t.max, e, r, a, i); +} +function c5(t, e, [r, n, i], s, o) { + JX(t, e[r], e[n], e[i], e.scale, s, o); +} +const XX = ["x", "scaleX", "originX"], ZX = ["y", "scaleY", "originY"]; +function u5(t, e, r, n) { + c5(t.x, e, XX, r ? r.x : void 0, n ? n.x : void 0), c5(t.y, e, ZX, r ? r.y : void 0, n ? n.y : void 0); +} +function f5(t) { + return t.translate === 0 && t.scale === 1; +} +function R7(t) { + return f5(t.x) && f5(t.y); +} +function l5(t, e) { + return t.min === e.min && t.max === e.max; +} +function QX(t, e) { + return l5(t.x, e.x) && l5(t.y, e.y); +} +function h5(t, e) { + return Math.round(t.min) === Math.round(e.min) && Math.round(t.max) === Math.round(e.max); +} +function T7(t, e) { + return h5(t.x, e.x) && h5(t.y, e.y); +} +function d5(t) { + return Pi(t.x) / Pi(t.y); +} +function p5(t, e) { + return t.translate === e.translate && t.scale === e.scale && t.originPoint === e.originPoint; +} +class eZ { + constructor() { + this.members = []; + } + add(e) { + ub(this.members, e), e.scheduleRender(); + } + remove(e) { + if (fb(this.members, e), e === this.prevLead && (this.prevLead = void 0), e === this.lead) { + const r = this.members[this.members.length - 1]; + r && this.promote(r); + } + } + relegate(e) { + const r = this.members.findIndex((i) => e === i); + if (r === 0) + return !1; + let n; + for (let i = r; i >= 0; i--) { + const s = this.members[i]; + if (s.isPresent !== !1) { + n = s; + break; + } + } + return n ? (this.promote(n), !0) : !1; + } + promote(e, r) { + const n = this.lead; + if (e !== n && (this.prevLead = n, this.lead = e, e.show(), n)) { + n.instance && n.scheduleRender(), e.scheduleRender(), e.resumeFrom = n, r && (e.resumeFrom.preserveOpacity = !0), n.snapshot && (e.snapshot = n.snapshot, e.snapshot.latestValues = n.animationValues || n.latestValues), e.root && e.root.isUpdating && (e.isLayoutDirty = !0); + const { crossfade: i } = e.options; + i === !1 && n.hide(); + } + } + exitAnimationComplete() { + this.members.forEach((e) => { + const { options: r, resumingFrom: n } = e; + r.onExitComplete && r.onExitComplete(), n && n.options.onExitComplete && n.options.onExitComplete(); + }); + } + scheduleRender() { + this.members.forEach((e) => { + e.instance && e.scheduleRender(!1); + }); + } + /** + * Clear any leads that have been removed this render to prevent them from being + * used in future animations and to prevent memory leaks + */ + removeLeadSnapshot() { + this.lead && this.lead.snapshot && (this.lead.snapshot = void 0); + } +} +function tZ(t, e, r) { + let n = ""; + const i = t.x.translate / e.x, s = t.y.translate / e.y, o = r?.z || 0; + if ((i || s || o) && (n = `translate3d(${i}px, ${s}px, ${o}px) `), (e.x !== 1 || e.y !== 1) && (n += `scale(${1 / e.x}, ${1 / e.y}) `), r) { + const { transformPerspective: u, rotate: h, rotateX: g, rotateY: v, skewX: x, skewY: S } = r; + u && (n = `perspective(${u}px) ${n}`), h && (n += `rotate(${h}deg) `), g && (n += `rotateX(${g}deg) `), v && (n += `rotateY(${v}deg) `), x && (n += `skewX(${x}deg) `), S && (n += `skewY(${S}deg) `); + } + const a = t.x.scale * e.x, f = t.y.scale * e.y; + return (a !== 1 || f !== 1) && (n += `scale(${a}, ${f})`), n || "none"; +} +const rZ = (t, e) => t.depth - e.depth; +class nZ { + constructor() { + this.children = [], this.isDirty = !1; + } + add(e) { + ub(this.children, e), this.isDirty = !0; + } + remove(e) { + fb(this.children, e), this.isDirty = !0; + } + forEach(e) { + this.isDirty && this.children.sort(rZ), this.isDirty = !1, this.children.forEach(e); + } +} +function rd(t) { + const e = Wn(t) ? t.get() : t; + return GJ(e) ? e.toValue() : e; +} +function iZ(t, e) { + const r = Ts.now(), n = ({ timestamp: i }) => { + const s = i - r; + s >= e && (Vo(n), t(s - e)); + }; + return kr.read(n, !0), () => Vo(n); +} +function sZ(t) { + return t instanceof SVGElement && t.tagName !== "svg"; +} +function oZ(t, e, r) { + const n = Wn(t) ? t : zf(t); + return n.start(cb("", n, e, r)), n.animation; +} +const wa = { + type: "projectionFrame", + totalNodes: 0, + resolvedTargetDeltas: 0, + recalculatedProjection: 0 +}, Qu = typeof window < "u" && window.MotionDebug !== void 0, Pm = ["", "X", "Y", "Z"], aZ = { visibility: "hidden" }, g5 = 1e3; +let cZ = 0; +function Mm(t, e, r, n) { + const { latestValues: i } = e; + i[t] && (r[t] = i[t], e.setStaticValue(t, 0), n && (n[t] = 0)); +} +function D7(t) { + if (t.hasCheckedOptimisedAppear = !0, t.root === t) + return; + const { visualElement: e } = t.options; + if (!e) + return; + const r = f7(e); + if (window.MotionHasOptimisedAnimation(r, "transform")) { + const { layout: i, layoutId: s } = t.options; + window.MotionCancelOptimisedAnimation(r, "transform", kr, !(i || s)); + } + const { parent: n } = t; + n && !n.hasCheckedOptimisedAppear && D7(n); +} +function O7({ attachResizeListener: t, defaultParent: e, measureScroll: r, checkIsScrollRoot: n, resetTransform: i }) { + return class { + constructor(o = {}, a = e?.()) { + this.id = cZ++, this.animationId = 0, this.children = /* @__PURE__ */ new Set(), this.options = {}, this.isTreeAnimating = !1, this.isAnimationBlocked = !1, this.isLayoutDirty = !1, this.isProjectionDirty = !1, this.isSharedProjectionDirty = !1, this.isTransformDirty = !1, this.updateManuallyBlocked = !1, this.updateBlockedByResize = !1, this.isUpdating = !1, this.isSVG = !1, this.needsReset = !1, this.shouldResetTransform = !1, this.hasCheckedOptimisedAppear = !1, this.treeScale = { x: 1, y: 1 }, this.eventHandlers = /* @__PURE__ */ new Map(), this.hasTreeAnimated = !1, this.updateScheduled = !1, this.scheduleUpdate = () => this.update(), this.projectionUpdateScheduled = !1, this.checkUpdateFailed = () => { + this.isUpdating && (this.isUpdating = !1, this.clearAllSnapshots()); + }, this.updateProjection = () => { + this.projectionUpdateScheduled = !1, Qu && (wa.totalNodes = wa.resolvedTargetDeltas = wa.recalculatedProjection = 0), this.nodes.forEach(lZ), this.nodes.forEach(mZ), this.nodes.forEach(vZ), this.nodes.forEach(hZ), Qu && window.MotionDebug.record(wa); + }, this.resolvedRelativeTargetAt = 0, this.hasProjected = !1, this.isVisible = !0, this.animationProgress = 0, this.sharedNodes = /* @__PURE__ */ new Map(), this.latestValues = o, this.root = a ? a.root || a : this, this.path = a ? [...a.path, a] : [], this.parent = a, this.depth = a ? a.depth + 1 : 0; + for (let f = 0; f < this.path.length; f++) + this.path[f].shouldResetTransform = !0; + this.root === this && (this.nodes = new nZ()); + } + addEventListener(o, a) { + return this.eventHandlers.has(o) || this.eventHandlers.set(o, new lb()), this.eventHandlers.get(o).add(a); + } + notifyListeners(o, ...a) { + const f = this.eventHandlers.get(o); + f && f.notify(...a); + } + hasListeners(o) { + return this.eventHandlers.has(o); + } + /** + * Lifecycles + */ + mount(o, a = this.root.hasTreeAnimated) { + if (this.instance) + return; + this.isSVG = sZ(o), this.instance = o; + const { layoutId: f, layout: u, visualElement: h } = this.options; + if (h && !h.current && h.mount(o), this.root.nodes.add(this), this.parent && this.parent.children.add(this), a && (u || f) && (this.isLayoutDirty = !0), t) { + let g; + const v = () => this.root.updateBlockedByResize = !1; + t(o, () => { + this.root.updateBlockedByResize = !0, g && g(), g = iZ(v, 250), td.hasAnimatedSinceResize && (td.hasAnimatedSinceResize = !1, this.nodes.forEach(v5)); + }); + } + f && this.root.registerSharedNode(f, this), this.options.animate !== !1 && h && (f || u) && this.addEventListener("didUpdate", ({ delta: g, hasLayoutChanged: v, hasRelativeTargetChanged: x, layout: S }) => { + if (this.isTreeAnimationBlocked()) { + this.target = void 0, this.relativeTarget = void 0; + return; + } + const R = this.options.transition || h.getDefaultTransition() || _Z, { onLayoutAnimationStart: D, onLayoutAnimationComplete: k } = h.getProps(), N = !this.targetLayout || !T7(this.targetLayout, S) || x, z = !v && x; + if (this.options.layoutRoot || this.resumeFrom && this.resumeFrom.instance || z || v && (N || !this.currentAnimation)) { + this.resumeFrom && (this.resumingFrom = this.resumeFrom, this.resumingFrom.resumingFrom = void 0), this.setAnimationOrigin(g, z); + const B = { + ...G1(R, "layout"), + onPlay: D, + onComplete: k + }; + (h.shouldReduceMotion || this.options.layoutRoot) && (B.delay = 0, B.type = !1), this.startAnimation(B); + } else + v || v5(this), this.isLead() && this.options.onExitComplete && this.options.onExitComplete(); + this.targetLayout = S; + }); + } + unmount() { + this.options.layoutId && this.willUpdate(), this.root.nodes.remove(this); + const o = this.getStack(); + o && o.remove(this), this.parent && this.parent.children.delete(this), this.instance = void 0, Vo(this.updateProjection); + } + // only on the root + blockUpdate() { + this.updateManuallyBlocked = !0; + } + unblockUpdate() { + this.updateManuallyBlocked = !1; + } + isUpdateBlocked() { + return this.updateManuallyBlocked || this.updateBlockedByResize; + } + isTreeAnimationBlocked() { + return this.isAnimationBlocked || this.parent && this.parent.isTreeAnimationBlocked() || !1; + } + // Note: currently only running on root node + startUpdate() { + this.isUpdateBlocked() || (this.isUpdating = !0, this.nodes && this.nodes.forEach(bZ), this.animationId++); + } + getTransformTemplate() { + const { visualElement: o } = this.options; + return o && o.getProps().transformTemplate; + } + willUpdate(o = !0) { + if (this.root.hasTreeAnimated = !0, this.root.isUpdateBlocked()) { + this.options.onExitComplete && this.options.onExitComplete(); + return; + } + if (window.MotionCancelOptimisedAnimation && !this.hasCheckedOptimisedAppear && D7(this), !this.root.isUpdating && this.root.startUpdate(), this.isLayoutDirty) + return; + this.isLayoutDirty = !0; + for (let h = 0; h < this.path.length; h++) { + const g = this.path[h]; + g.shouldResetTransform = !0, g.updateScroll("snapshot"), g.options.layoutRoot && g.willUpdate(!1); + } + const { layoutId: a, layout: f } = this.options; + if (a === void 0 && !f) + return; + const u = this.getTransformTemplate(); + this.prevTransformTemplateValue = u ? u(this.latestValues, "") : void 0, this.updateSnapshot(), o && this.notifyListeners("willUpdate"); + } + update() { + if (this.updateScheduled = !1, this.isUpdateBlocked()) { + this.unblockUpdate(), this.clearAllSnapshots(), this.nodes.forEach(m5); + return; + } + this.isUpdating || this.nodes.forEach(pZ), this.isUpdating = !1, this.nodes.forEach(gZ), this.nodes.forEach(uZ), this.nodes.forEach(fZ), this.clearAllSnapshots(); + const a = Ts.now(); + Nn.delta = Go(0, 1e3 / 60, a - Nn.timestamp), Nn.timestamp = a, Nn.isProcessing = !0, bm.update.process(Nn), bm.preRender.process(Nn), bm.render.process(Nn), Nn.isProcessing = !1; + } + didUpdate() { + this.updateScheduled || (this.updateScheduled = !0, pb.read(this.scheduleUpdate)); + } + clearAllSnapshots() { + this.nodes.forEach(dZ), this.sharedNodes.forEach(yZ); + } + scheduleUpdateProjection() { + this.projectionUpdateScheduled || (this.projectionUpdateScheduled = !0, kr.preRender(this.updateProjection, !1, !0)); + } + scheduleCheckAfterUnmount() { + kr.postRender(() => { + this.isLayoutDirty ? this.root.didUpdate() : this.root.checkUpdateFailed(); + }); + } + /** + * Update measurements + */ + updateSnapshot() { + this.snapshot || !this.instance || (this.snapshot = this.measure()); + } + updateLayout() { + if (!this.instance || (this.updateScroll(), !(this.options.alwaysMeasureLayout && this.isLead()) && !this.isLayoutDirty)) + return; + if (this.resumeFrom && !this.resumeFrom.instance) + for (let f = 0; f < this.path.length; f++) + this.path[f].updateScroll(); + const o = this.layout; + this.layout = this.measure(!1), this.layoutCorrected = fn(), this.isLayoutDirty = !1, this.projectionDelta = void 0, this.notifyListeners("measure", this.layout.layoutBox); + const { visualElement: a } = this.options; + a && a.notify("LayoutMeasure", this.layout.layoutBox, o ? o.layoutBox : void 0); + } + updateScroll(o = "measure") { + let a = !!(this.options.layoutScroll && this.instance); + if (this.scroll && this.scroll.animationId === this.root.animationId && this.scroll.phase === o && (a = !1), a) { + const f = n(this.instance); + this.scroll = { + animationId: this.root.animationId, + phase: o, + isRoot: f, + offset: r(this.instance), + wasRoot: this.scroll ? this.scroll.isRoot : f + }; + } + } + resetTransform() { + if (!i) + return; + const o = this.isLayoutDirty || this.shouldResetTransform || this.options.alwaysMeasureLayout, a = this.projectionDelta && !R7(this.projectionDelta), f = this.getTransformTemplate(), u = f ? f(this.latestValues, "") : void 0, h = u !== this.prevTransformTemplateValue; + o && (a || ya(this.latestValues) || h) && (i(this.instance, u), this.shouldResetTransform = !1, this.scheduleRender()); + } + measure(o = !0) { + const a = this.measurePageBox(); + let f = this.removeElementScroll(a); + return o && (f = this.removeTransform(f)), EZ(f), { + animationId: this.root.animationId, + measuredBox: a, + layoutBox: f, + latestValues: {}, + source: this.id + }; + } + measurePageBox() { + var o; + const { visualElement: a } = this.options; + if (!a) + return fn(); + const f = a.measureViewportBox(); + if (!(((o = this.scroll) === null || o === void 0 ? void 0 : o.wasRoot) || this.path.some(SZ))) { + const { scroll: h } = this.root; + h && (Ac(f.x, h.offset.x), Ac(f.y, h.offset.y)); + } + return f; + } + removeElementScroll(o) { + var a; + const f = fn(); + if (Fi(f, o), !((a = this.scroll) === null || a === void 0) && a.wasRoot) + return f; + for (let u = 0; u < this.path.length; u++) { + const h = this.path[u], { scroll: g, options: v } = h; + h !== this.root && g && v.layoutScroll && (g.wasRoot && Fi(f, o), Ac(f.x, g.offset.x), Ac(f.y, g.offset.y)); + } + return f; + } + applyTransform(o, a = !1) { + const f = fn(); + Fi(f, o); + for (let u = 0; u < this.path.length; u++) { + const h = this.path[u]; + !a && h.options.layoutScroll && h.scroll && h !== h.root && Pc(f, { + x: -h.scroll.offset.x, + y: -h.scroll.offset.y + }), ya(h.latestValues) && Pc(f, h.latestValues); + } + return ya(this.latestValues) && Pc(f, this.latestValues), f; + } + removeTransform(o) { + const a = fn(); + Fi(a, o); + for (let f = 0; f < this.path.length; f++) { + const u = this.path[f]; + if (!u.instance || !ya(u.latestValues)) + continue; + Bv(u.latestValues) && u.updateSnapshot(); + const h = fn(), g = u.measurePageBox(); + Fi(h, g), u5(a, u.latestValues, u.snapshot ? u.snapshot.layoutBox : void 0, h); + } + return ya(this.latestValues) && u5(a, this.latestValues), a; + } + setTargetDelta(o) { + this.targetDelta = o, this.root.scheduleUpdateProjection(), this.isProjectionDirty = !0; + } + setOptions(o) { + this.options = { + ...this.options, + ...o, + crossfade: o.crossfade !== void 0 ? o.crossfade : !0 + }; + } + clearMeasurements() { + this.scroll = void 0, this.layout = void 0, this.snapshot = void 0, this.prevTransformTemplateValue = void 0, this.targetDelta = void 0, this.target = void 0, this.isLayoutDirty = !1; + } + forceRelativeParentToResolveTarget() { + this.relativeParent && this.relativeParent.resolvedRelativeTargetAt !== Nn.timestamp && this.relativeParent.resolveTargetDelta(!0); + } + resolveTargetDelta(o = !1) { + var a; + const f = this.getLead(); + this.isProjectionDirty || (this.isProjectionDirty = f.isProjectionDirty), this.isTransformDirty || (this.isTransformDirty = f.isTransformDirty), this.isSharedProjectionDirty || (this.isSharedProjectionDirty = f.isSharedProjectionDirty); + const u = !!this.resumingFrom || this !== f; + if (!(o || u && this.isSharedProjectionDirty || this.isProjectionDirty || !((a = this.parent) === null || a === void 0) && a.isProjectionDirty || this.attemptToResolveRelativeTarget || this.root.updateBlockedByResize)) + return; + const { layout: g, layoutId: v } = this.options; + if (!(!this.layout || !(g || v))) { + if (this.resolvedRelativeTargetAt = Nn.timestamp, !this.targetDelta && !this.relativeTarget) { + const x = this.getClosestProjectingParent(); + x && x.layout && this.animationProgress !== 1 ? (this.relativeParent = x, this.forceRelativeParentToResolveTarget(), this.relativeTarget = fn(), this.relativeTargetOrigin = fn(), uf(this.relativeTargetOrigin, this.layout.layoutBox, x.layout.layoutBox), Fi(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0; + } + if (!(!this.relativeTarget && !this.targetDelta)) { + if (this.target || (this.target = fn(), this.targetWithTransforms = fn()), this.relativeTarget && this.relativeTargetOrigin && this.relativeParent && this.relativeParent.target ? (this.forceRelativeParentToResolveTarget(), AX(this.target, this.relativeTarget, this.relativeParent.target)) : this.targetDelta ? (this.resumingFrom ? this.target = this.applyTransform(this.layout.layoutBox) : Fi(this.target, this.layout.layoutBox), E7(this.target, this.targetDelta)) : Fi(this.target, this.layout.layoutBox), this.attemptToResolveRelativeTarget) { + this.attemptToResolveRelativeTarget = !1; + const x = this.getClosestProjectingParent(); + x && !!x.resumingFrom == !!this.resumingFrom && !x.options.layoutScroll && x.target && this.animationProgress !== 1 ? (this.relativeParent = x, this.forceRelativeParentToResolveTarget(), this.relativeTarget = fn(), this.relativeTargetOrigin = fn(), uf(this.relativeTargetOrigin, this.target, x.target), Fi(this.relativeTarget, this.relativeTargetOrigin)) : this.relativeParent = this.relativeTarget = void 0; + } + Qu && wa.resolvedTargetDeltas++; + } + } + } + getClosestProjectingParent() { + if (!(!this.parent || Bv(this.parent.latestValues) || _7(this.parent.latestValues))) + return this.parent.isProjecting() ? this.parent : this.parent.getClosestProjectingParent(); + } + isProjecting() { + return !!((this.relativeTarget || this.targetDelta || this.options.layoutRoot) && this.layout); + } + calcProjection() { + var o; + const a = this.getLead(), f = !!this.resumingFrom || this !== a; + let u = !0; + if ((this.isProjectionDirty || !((o = this.parent) === null || o === void 0) && o.isProjectionDirty) && (u = !1), f && (this.isSharedProjectionDirty || this.isTransformDirty) && (u = !1), this.resolvedRelativeTargetAt === Nn.timestamp && (u = !1), u) + return; + const { layout: h, layoutId: g } = this.options; + if (this.isTreeAnimating = !!(this.parent && this.parent.isTreeAnimating || this.currentAnimation || this.pendingAnimation), this.isTreeAnimating || (this.targetDelta = this.relativeTarget = void 0), !this.layout || !(h || g)) + return; + Fi(this.layoutCorrected, this.layout.layoutBox); + const v = this.treeScale.x, x = this.treeScale.y; + NX(this.layoutCorrected, this.treeScale, this.path, f), a.layout && !a.target && (this.treeScale.x !== 1 || this.treeScale.y !== 1) && (a.target = a.layout.layoutBox, a.targetWithTransforms = fn()); + const { target: S } = a; + if (!S) { + this.prevProjectionDelta && (this.createProjectionDeltas(), this.scheduleRender()); + return; + } + !this.projectionDelta || !this.prevProjectionDelta ? this.createProjectionDeltas() : (o5(this.prevProjectionDelta.x, this.projectionDelta.x), o5(this.prevProjectionDelta.y, this.projectionDelta.y)), cf(this.projectionDelta, this.layoutCorrected, S, this.latestValues), (this.treeScale.x !== v || this.treeScale.y !== x || !p5(this.projectionDelta.x, this.prevProjectionDelta.x) || !p5(this.projectionDelta.y, this.prevProjectionDelta.y)) && (this.hasProjected = !0, this.scheduleRender(), this.notifyListeners("projectionUpdate", S)), Qu && wa.recalculatedProjection++; + } + hide() { + this.isVisible = !1; + } + show() { + this.isVisible = !0; + } + scheduleRender(o = !0) { + var a; + if ((a = this.options.visualElement) === null || a === void 0 || a.scheduleRender(), o) { + const f = this.getStack(); + f && f.scheduleRender(); + } + this.resumingFrom && !this.resumingFrom.instance && (this.resumingFrom = void 0); + } + createProjectionDeltas() { + this.prevProjectionDelta = Sc(), this.projectionDelta = Sc(), this.projectionDeltaWithTransform = Sc(); + } + setAnimationOrigin(o, a = !1) { + const f = this.snapshot, u = f ? f.latestValues : {}, h = { ...this.latestValues }, g = Sc(); + (!this.relativeParent || !this.relativeParent.options.layoutRoot) && (this.relativeTarget = this.relativeTargetOrigin = void 0), this.attemptToResolveRelativeTarget = !a; + const v = fn(), x = f ? f.source : void 0, S = this.layout ? this.layout.source : void 0, R = x !== S, D = this.getStack(), k = !D || D.members.length <= 1, N = !!(R && !k && this.options.crossfade === !0 && !this.path.some(xZ)); + this.animationProgress = 0; + let z; + this.mixTargetDelta = (B) => { + const $ = B / 1e3; + b5(g.x, o.x, $), b5(g.y, o.y, $), this.setTargetDelta(g), this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout && (uf(v, this.layout.layoutBox, this.relativeParent.layout.layoutBox), wZ(this.relativeTarget, this.relativeTargetOrigin, v, $), z && QX(this.relativeTarget, z) && (this.isProjectionDirty = !1), z || (z = fn()), Fi(z, this.relativeTarget)), R && (this.animationValues = h, VX(h, u, this.latestValues, $, N, k)), this.root.scheduleUpdateProjection(), this.scheduleRender(), this.animationProgress = $; + }, this.mixTargetDelta(this.options.layoutRoot ? 1e3 : 0); + } + startAnimation(o) { + this.notifyListeners("animationStart"), this.currentAnimation && this.currentAnimation.stop(), this.resumingFrom && this.resumingFrom.currentAnimation && this.resumingFrom.currentAnimation.stop(), this.pendingAnimation && (Vo(this.pendingAnimation), this.pendingAnimation = void 0), this.pendingAnimation = kr.update(() => { + td.hasAnimatedSinceResize = !0, this.currentAnimation = oZ(0, g5, { + ...o, + onUpdate: (a) => { + this.mixTargetDelta(a), o.onUpdate && o.onUpdate(a); + }, + onComplete: () => { + o.onComplete && o.onComplete(), this.completeAnimation(); + } + }), this.resumingFrom && (this.resumingFrom.currentAnimation = this.currentAnimation), this.pendingAnimation = void 0; + }); + } + completeAnimation() { + this.resumingFrom && (this.resumingFrom.currentAnimation = void 0, this.resumingFrom.preserveOpacity = void 0); + const o = this.getStack(); + o && o.exitAnimationComplete(), this.resumingFrom = this.currentAnimation = this.animationValues = void 0, this.notifyListeners("animationComplete"); + } + finishAnimation() { + this.currentAnimation && (this.mixTargetDelta && this.mixTargetDelta(g5), this.currentAnimation.stop()), this.completeAnimation(); + } + applyTransformsToTarget() { + const o = this.getLead(); + let { targetWithTransforms: a, target: f, layout: u, latestValues: h } = o; + if (!(!a || !f || !u)) { + if (this !== o && this.layout && u && N7(this.options.animationType, this.layout.layoutBox, u.layoutBox)) { + f = this.target || fn(); + const g = Pi(this.layout.layoutBox.x); + f.x.min = o.target.x.min, f.x.max = f.x.min + g; + const v = Pi(this.layout.layoutBox.y); + f.y.min = o.target.y.min, f.y.max = f.y.min + v; + } + Fi(a, f), Pc(a, h), cf(this.projectionDeltaWithTransform, this.layoutCorrected, a, h); + } + } + registerSharedNode(o, a) { + this.sharedNodes.has(o) || this.sharedNodes.set(o, new eZ()), this.sharedNodes.get(o).add(a); + const u = a.options.initialPromotionConfig; + a.promote({ + transition: u ? u.transition : void 0, + preserveFollowOpacity: u && u.shouldPreserveFollowOpacity ? u.shouldPreserveFollowOpacity(a) : void 0 + }); + } + isLead() { + const o = this.getStack(); + return o ? o.lead === this : !0; + } + getLead() { + var o; + const { layoutId: a } = this.options; + return a ? ((o = this.getStack()) === null || o === void 0 ? void 0 : o.lead) || this : this; + } + getPrevLead() { + var o; + const { layoutId: a } = this.options; + return a ? (o = this.getStack()) === null || o === void 0 ? void 0 : o.prevLead : void 0; + } + getStack() { + const { layoutId: o } = this.options; + if (o) + return this.root.sharedNodes.get(o); + } + promote({ needsReset: o, transition: a, preserveFollowOpacity: f } = {}) { + const u = this.getStack(); + u && u.promote(this, f), o && (this.projectionDelta = void 0, this.needsReset = !0), a && this.setOptions({ transition: a }); + } + relegate() { + const o = this.getStack(); + return o ? o.relegate(this) : !1; + } + resetSkewAndRotation() { + const { visualElement: o } = this.options; + if (!o) + return; + let a = !1; + const { latestValues: f } = o; + if ((f.z || f.rotate || f.rotateX || f.rotateY || f.rotateZ || f.skewX || f.skewY) && (a = !0), !a) + return; + const u = {}; + f.z && Mm("z", o, u, this.animationValues); + for (let h = 0; h < Pm.length; h++) + Mm(`rotate${Pm[h]}`, o, u, this.animationValues), Mm(`skew${Pm[h]}`, o, u, this.animationValues); + o.render(); + for (const h in u) + o.setStaticValue(h, u[h]), this.animationValues && (this.animationValues[h] = u[h]); + o.scheduleRender(); + } + getProjectionStyles(o) { + var a, f; + if (!this.instance || this.isSVG) + return; + if (!this.isVisible) + return aZ; + const u = { + visibility: "" + }, h = this.getTransformTemplate(); + if (this.needsReset) + return this.needsReset = !1, u.opacity = "", u.pointerEvents = rd(o?.pointerEvents) || "", u.transform = h ? h(this.latestValues, "") : "none", u; + const g = this.getLead(); + if (!this.projectionDelta || !this.layout || !g.target) { + const R = {}; + return this.options.layoutId && (R.opacity = this.latestValues.opacity !== void 0 ? this.latestValues.opacity : 1, R.pointerEvents = rd(o?.pointerEvents) || ""), this.hasProjected && !ya(this.latestValues) && (R.transform = h ? h({}, "") : "none", this.hasProjected = !1), R; + } + const v = g.animationValues || g.latestValues; + this.applyTransformsToTarget(), u.transform = tZ(this.projectionDeltaWithTransform, this.treeScale, v), h && (u.transform = h(v, u.transform)); + const { x, y: S } = this.projectionDelta; + u.transformOrigin = `${x.origin * 100}% ${S.origin * 100}% 0`, g.animationValues ? u.opacity = g === this ? (f = (a = v.opacity) !== null && a !== void 0 ? a : this.latestValues.opacity) !== null && f !== void 0 ? f : 1 : this.preserveOpacity ? this.latestValues.opacity : v.opacityExit : u.opacity = g === this ? v.opacity !== void 0 ? v.opacity : "" : v.opacityExit !== void 0 ? v.opacityExit : 0; + for (const R in Od) { + if (v[R] === void 0) + continue; + const { correct: D, applyTo: k } = Od[R], N = u.transform === "none" ? v[R] : D(v[R], g); + if (k) { + const z = k.length; + for (let B = 0; B < z; B++) + u[k[B]] = N; + } else + u[R] = N; + } + return this.options.layoutId && (u.pointerEvents = g === this ? rd(o?.pointerEvents) || "" : "none"), u; + } + clearSnapshot() { + this.resumeFrom = this.snapshot = void 0; + } + // Only run on root + resetTree() { + this.root.nodes.forEach((o) => { + var a; + return (a = o.currentAnimation) === null || a === void 0 ? void 0 : a.stop(); + }), this.root.nodes.forEach(m5), this.root.sharedNodes.clear(); + } + }; +} +function uZ(t) { + t.updateLayout(); +} +function fZ(t) { + var e; + const r = ((e = t.resumeFrom) === null || e === void 0 ? void 0 : e.snapshot) || t.snapshot; + if (t.isLead() && t.layout && r && t.hasListeners("didUpdate")) { + const { layoutBox: n, measuredBox: i } = t.layout, { animationType: s } = t.options, o = r.source !== t.layout.source; + s === "size" ? Ui((g) => { + const v = o ? r.measuredBox[g] : r.layoutBox[g], x = Pi(v); + v.min = n[g].min, v.max = v.min + x; + }) : N7(s, r.layoutBox, n) && Ui((g) => { + const v = o ? r.measuredBox[g] : r.layoutBox[g], x = Pi(n[g]); + v.max = v.min + x, t.relativeTarget && !t.currentAnimation && (t.isProjectionDirty = !0, t.relativeTarget[g].max = t.relativeTarget[g].min + x); + }); + const a = Sc(); + cf(a, n, r.layoutBox); + const f = Sc(); + o ? cf(f, t.applyTransform(i, !0), r.measuredBox) : cf(f, n, r.layoutBox); + const u = !R7(a); + let h = !1; + if (!t.resumeFrom) { + const g = t.getClosestProjectingParent(); + if (g && !g.resumeFrom) { + const { snapshot: v, layout: x } = g; + if (v && x) { + const S = fn(); + uf(S, r.layoutBox, v.layoutBox); + const R = fn(); + uf(R, n, x.layoutBox), T7(S, R) || (h = !0), g.options.layoutRoot && (t.relativeTarget = R, t.relativeTargetOrigin = S, t.relativeParent = g); + } + } + } + t.notifyListeners("didUpdate", { + layout: n, + snapshot: r, + delta: f, + layoutDelta: a, + hasLayoutChanged: u, + hasRelativeTargetChanged: h + }); + } else if (t.isLead()) { + const { onExitComplete: n } = t.options; + n && n(); + } + t.options.transition = void 0; +} +function lZ(t) { + Qu && wa.totalNodes++, t.parent && (t.isProjecting() || (t.isProjectionDirty = t.parent.isProjectionDirty), t.isSharedProjectionDirty || (t.isSharedProjectionDirty = !!(t.isProjectionDirty || t.parent.isProjectionDirty || t.parent.isSharedProjectionDirty)), t.isTransformDirty || (t.isTransformDirty = t.parent.isTransformDirty)); +} +function hZ(t) { + t.isProjectionDirty = t.isSharedProjectionDirty = t.isTransformDirty = !1; +} +function dZ(t) { + t.clearSnapshot(); +} +function m5(t) { + t.clearMeasurements(); +} +function pZ(t) { + t.isLayoutDirty = !1; +} +function gZ(t) { + const { visualElement: e } = t.options; + e && e.getProps().onBeforeLayoutMeasure && e.notify("BeforeLayoutMeasure"), t.resetTransform(); +} +function v5(t) { + t.finishAnimation(), t.targetDelta = t.relativeTarget = t.target = void 0, t.isProjectionDirty = !0; +} +function mZ(t) { + t.resolveTargetDelta(); +} +function vZ(t) { + t.calcProjection(); +} +function bZ(t) { + t.resetSkewAndRotation(); +} +function yZ(t) { + t.removeLeadSnapshot(); +} +function b5(t, e, r) { + t.translate = Qr(e.translate, 0, r), t.scale = Qr(e.scale, 1, r), t.origin = e.origin, t.originPoint = e.originPoint; +} +function y5(t, e, r, n) { + t.min = Qr(e.min, r.min, n), t.max = Qr(e.max, r.max, n); +} +function wZ(t, e, r, n) { + y5(t.x, e.x, r.x, n), y5(t.y, e.y, r.y, n); +} +function xZ(t) { + return t.animationValues && t.animationValues.opacityExit !== void 0; +} +const _Z = { + duration: 0.45, + ease: [0.4, 0, 0.1, 1] +}, w5 = (t) => typeof navigator < "u" && navigator.userAgent && navigator.userAgent.toLowerCase().includes(t), x5 = w5("applewebkit/") && !w5("chrome/") ? Math.round : kn; +function _5(t) { + t.min = x5(t.min), t.max = x5(t.max); +} +function EZ(t) { + _5(t.x), _5(t.y); +} +function N7(t, e, r) { + return t === "position" || t === "preserve-aspect" && !SX(d5(e), d5(r), 0.2); +} +function SZ(t) { + var e; + return t !== t.root && ((e = t.scroll) === null || e === void 0 ? void 0 : e.wasRoot); +} +const AZ = O7({ + attachResizeListener: (t, e) => no(t, "resize", e), + measureScroll: () => ({ + x: document.documentElement.scrollLeft || document.body.scrollLeft, + y: document.documentElement.scrollTop || document.body.scrollTop + }), + checkIsScrollRoot: () => !0 +}), Im = { + current: void 0 +}, L7 = O7({ + measureScroll: (t) => ({ + x: t.scrollLeft, + y: t.scrollTop + }), + defaultParent: () => { + if (!Im.current) { + const t = new AZ({}); + t.mount(window), t.setOptions({ layoutScroll: !0 }), Im.current = t; + } + return Im.current; + }, + resetTransform: (t, e) => { + t.style.transform = e !== void 0 ? e : "none"; + }, + checkIsScrollRoot: (t) => window.getComputedStyle(t).position === "fixed" +}), PZ = { + pan: { + Feature: jX + }, + drag: { + Feature: FX, + ProjectionNode: L7, + MeasureLayout: M7 + } +}; +function E5(t, e) { + const r = e ? "pointerenter" : "pointerleave", n = e ? "onHoverStart" : "onHoverEnd", i = (s, o) => { + if (s.pointerType === "touch" || b7()) + return; + const a = t.getProps(); + t.animationState && a.whileHover && t.animationState.setActive("whileHover", e); + const f = a[n]; + f && kr.postRender(() => f(s, o)); + }; + return co(t.current, r, i, { + passive: !t.getProps()[n] + }); +} +class MZ extends ea { + mount() { + this.unmount = ao(E5(this.node, !0), E5(this.node, !1)); + } + unmount() { + } +} +class IZ extends ea { + constructor() { + super(...arguments), this.isActive = !1; + } + onFocus() { + let e = !1; + try { + e = this.node.current.matches(":focus-visible"); + } catch { + e = !0; + } + !e || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !0), this.isActive = !0); + } + onBlur() { + !this.isActive || !this.node.animationState || (this.node.animationState.setActive("whileFocus", !1), this.isActive = !1); + } + mount() { + this.unmount = ao(no(this.node.current, "focus", () => this.onFocus()), no(this.node.current, "blur", () => this.onBlur())); + } + unmount() { + } +} +const k7 = (t, e) => e ? t === e ? !0 : k7(t, e.parentElement) : !1; +function Cm(t, e) { + if (!e) + return; + const r = new PointerEvent("pointer" + t); + e(r, w0(r)); +} +class CZ extends ea { + constructor() { + super(...arguments), this.removeStartListeners = kn, this.removeEndListeners = kn, this.removeAccessibleListeners = kn, this.startPointerPress = (e, r) => { + if (this.isPressing) + return; + this.removeEndListeners(); + const n = this.node.getProps(), s = co(window, "pointerup", (a, f) => { + if (!this.checkPressEnd()) + return; + const { onTap: u, onTapCancel: h, globalTapTarget: g } = this.node.getProps(), v = !g && !k7(this.node.current, a.target) ? h : u; + v && kr.update(() => v(a, f)); + }, { + passive: !(n.onTap || n.onPointerUp) + }), o = co(window, "pointercancel", (a, f) => this.cancelPress(a, f), { + passive: !(n.onTapCancel || n.onPointerCancel) + }); + this.removeEndListeners = ao(s, o), this.startPress(e, r); + }, this.startAccessiblePress = () => { + const e = (s) => { + if (s.key !== "Enter" || this.isPressing) + return; + const o = (a) => { + a.key !== "Enter" || !this.checkPressEnd() || Cm("up", (f, u) => { + const { onTap: h } = this.node.getProps(); + h && kr.postRender(() => h(f, u)); + }); + }; + this.removeEndListeners(), this.removeEndListeners = no(this.node.current, "keyup", o), Cm("down", (a, f) => { + this.startPress(a, f); + }); + }, r = no(this.node.current, "keydown", e), n = () => { + this.isPressing && Cm("cancel", (s, o) => this.cancelPress(s, o)); + }, i = no(this.node.current, "blur", n); + this.removeAccessibleListeners = ao(r, i); + }; + } + startPress(e, r) { + this.isPressing = !0; + const { onTapStart: n, whileTap: i } = this.node.getProps(); + i && this.node.animationState && this.node.animationState.setActive("whileTap", !0), n && kr.postRender(() => n(e, r)); + } + checkPressEnd() { + return this.removeEndListeners(), this.isPressing = !1, this.node.getProps().whileTap && this.node.animationState && this.node.animationState.setActive("whileTap", !1), !b7(); + } + cancelPress(e, r) { + if (!this.checkPressEnd()) + return; + const { onTapCancel: n } = this.node.getProps(); + n && kr.postRender(() => n(e, r)); + } + mount() { + const e = this.node.getProps(), r = co(e.globalTapTarget ? window : this.node.current, "pointerdown", this.startPointerPress, { + passive: !(e.onTapStart || e.onPointerStart) + }), n = no(this.node.current, "focus", this.startAccessiblePress); + this.removeStartListeners = ao(r, n); + } + unmount() { + this.removeStartListeners(), this.removeEndListeners(), this.removeAccessibleListeners(); + } +} +const jv = /* @__PURE__ */ new WeakMap(), Rm = /* @__PURE__ */ new WeakMap(), RZ = (t) => { + const e = jv.get(t.target); + e && e(t); +}, TZ = (t) => { + t.forEach(RZ); +}; +function DZ({ root: t, ...e }) { + const r = t || document; + Rm.has(r) || Rm.set(r, {}); + const n = Rm.get(r), i = JSON.stringify(e); + return n[i] || (n[i] = new IntersectionObserver(TZ, { root: t, ...e })), n[i]; +} +function OZ(t, e, r) { + const n = DZ(e); + return jv.set(t, r), n.observe(t), () => { + jv.delete(t), n.unobserve(t); + }; +} +const NZ = { + some: 0, + all: 1 +}; +class LZ extends ea { + constructor() { + super(...arguments), this.hasEnteredView = !1, this.isInView = !1; + } + startObserver() { + this.unmount(); + const { viewport: e = {} } = this.node.getProps(), { root: r, margin: n, amount: i = "some", once: s } = e, o = { + root: r ? r.current : void 0, + rootMargin: n, + threshold: typeof i == "number" ? i : NZ[i] + }, a = (f) => { + const { isIntersecting: u } = f; + if (this.isInView === u || (this.isInView = u, s && !u && this.hasEnteredView)) + return; + u && (this.hasEnteredView = !0), this.node.animationState && this.node.animationState.setActive("whileInView", u); + const { onViewportEnter: h, onViewportLeave: g } = this.node.getProps(), v = u ? h : g; + v && v(f); + }; + return OZ(this.node.current, o, a); + } + mount() { + this.startObserver(); + } + update() { + if (typeof IntersectionObserver > "u") + return; + const { props: e, prevProps: r } = this.node; + ["amount", "margin", "root"].some(kZ(e, r)) && this.startObserver(); + } + unmount() { + } +} +function kZ({ viewport: t = {} }, { viewport: e = {} } = {}) { + return (r) => t[r] !== e[r]; +} +const $Z = { + inView: { + Feature: LZ + }, + tap: { + Feature: CZ + }, + focus: { + Feature: IZ + }, + hover: { + Feature: MZ + } +}, BZ = { + layout: { + ProjectionNode: L7, + MeasureLayout: M7 + } +}, gb = Xo({ + transformPagePoint: (t) => t, + isStatic: !1, + reducedMotion: "never" +}), _0 = Xo({}), mb = typeof window < "u", $7 = mb ? hT : Rn, B7 = Xo({ strict: !1 }); +function FZ(t, e, r, n, i) { + var s, o; + const { visualElement: a } = In(_0), f = In(B7), u = In(x0), h = In(gb).reducedMotion, g = Kn(); + n = n || f.renderer, !g.current && n && (g.current = n(t, { + visualState: e, + parent: a, + props: r, + presenceContext: u, + blockInitialAnimation: u ? u.initial === !1 : !1, + reducedMotionConfig: h + })); + const v = g.current, x = In(P7); + v && !v.projection && i && (v.type === "html" || v.type === "svg") && jZ(g.current, r, i, x); + const S = Kn(!1); + H5(() => { + v && S.current && v.update(r, u); + }); + const R = r[u7], D = Kn(!!R && !(!((s = window.MotionHandoffIsComplete) === null || s === void 0) && s.call(window, R)) && ((o = window.MotionHasOptimisedAnimation) === null || o === void 0 ? void 0 : o.call(window, R))); + return $7(() => { + v && (S.current = !0, window.MotionIsMounted = !0, v.updateFeatures(), pb.render(v.render), D.current && v.animationState && v.animationState.animateChanges()); + }), Rn(() => { + v && (!D.current && v.animationState && v.animationState.animateChanges(), D.current && (queueMicrotask(() => { + var k; + (k = window.MotionHandoffMarkAsComplete) === null || k === void 0 || k.call(window, R); + }), D.current = !1)); + }), v; +} +function jZ(t, e, r, n) { + const { layoutId: i, layout: s, drag: o, dragConstraints: a, layoutScroll: f, layoutRoot: u } = e; + t.projection = new r(t.latestValues, e["data-framer-portal-id"] ? void 0 : F7(t.parent)), t.projection.setOptions({ + layoutId: i, + layout: s, + alwaysMeasureLayout: !!o || a && Ec(a), + visualElement: t, + /** + * TODO: Update options in an effect. This could be tricky as it'll be too late + * to update by the time layout animations run. + * We also need to fix this safeToRemove by linking it up to the one returned by usePresence, + * ensuring it gets called if there's no potential layout animations. + * + */ + animationType: typeof s == "string" ? s : "both", + initialPromotionConfig: n, + layoutScroll: f, + layoutRoot: u + }); +} +function F7(t) { + if (t) + return t.options.allowProjection !== !1 ? t.projection : F7(t.parent); +} +function UZ(t, e, r) { + return Gv( + (n) => { + n && t.mount && t.mount(n), e && (n ? e.mount(n) : e.unmount()), r && (typeof r == "function" ? r(n) : Ec(r) && (r.current = n)); + }, + /** + * Only pass a new ref callback to React if we've received a visual element + * factory. Otherwise we'll be mounting/remounting every time externalRef + * or other dependencies change. + */ + [e] + ); +} +function E0(t) { + return v0(t.animate) || V1.some((e) => jf(t[e])); +} +function j7(t) { + return !!(E0(t) || t.variants); +} +function qZ(t, e) { + if (E0(t)) { + const { initial: r, animate: n } = t; + return { + initial: r === !1 || jf(r) ? r : void 0, + animate: jf(n) ? n : void 0 + }; + } + return t.inherit !== !1 ? e : {}; +} +function zZ(t) { + const { initial: e, animate: r } = qZ(t, In(_0)); + return hi(() => ({ initial: e, animate: r }), [S5(e), S5(r)]); +} +function S5(t) { + return Array.isArray(t) ? t.join(" ") : t; +} +const A5 = { + animation: [ + "animate", + "variants", + "whileHover", + "whileTap", + "exit", + "whileInView", + "whileFocus", + "whileDrag" + ], + exit: ["exit"], + drag: ["drag", "dragControls"], + focus: ["whileFocus"], + hover: ["whileHover", "onHoverStart", "onHoverEnd"], + tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"], + pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"], + inView: ["whileInView", "onViewportEnter", "onViewportLeave"], + layout: ["layout", "layoutId"] +}, Wc = {}; +for (const t in A5) + Wc[t] = { + isEnabled: (e) => A5[t].some((r) => !!e[r]) + }; +function HZ(t) { + for (const e in t) + Wc[e] = { + ...Wc[e], + ...t[e] + }; +} +const WZ = Symbol.for("motionComponentSymbol"); +function KZ({ preloadedFeatures: t, createVisualElement: e, useRender: r, useVisualState: n, Component: i }) { + t && HZ(t); + function s(a, f) { + let u; + const h = { + ...In(gb), + ...a, + layoutId: VZ(a) + }, { isStatic: g } = h, v = zZ(a), x = n(a, g); + if (!g && mb) { + GZ(h, t); + const S = YZ(h); + u = S.MeasureLayout, v.visualElement = FZ(i, x, h, e, S.ProjectionNode); + } + return pe.jsxs(_0.Provider, { value: v, children: [u && v.visualElement ? pe.jsx(u, { visualElement: v.visualElement, ...h }) : null, r(i, a, UZ(x, v.visualElement, f), x, g, v.visualElement)] }); + } + const o = Kv(s); + return o[WZ] = i, o; +} +function VZ({ layoutId: t }) { + const e = In(db).id; + return e && t !== void 0 ? e + "-" + t : t; +} +function GZ(t, e) { + const r = In(B7).strict; + if (process.env.NODE_ENV !== "production" && e && r) { + const n = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead."; + t.ignoreStrict ? Qc(!1, n) : po(!1, n); + } +} +function YZ(t) { + const { drag: e, layout: r } = Wc; + if (!e && !r) + return {}; + const n = { ...e, ...r }; + return { + MeasureLayout: e?.isEnabled(t) || r?.isEnabled(t) ? n.MeasureLayout : void 0, + ProjectionNode: n.ProjectionNode + }; +} +const JZ = [ + "animate", + "circle", + "defs", + "desc", + "ellipse", + "g", + "image", + "line", + "filter", + "marker", + "mask", + "metadata", + "path", + "pattern", + "polygon", + "polyline", + "rect", + "stop", + "switch", + "symbol", + "svg", + "text", + "tspan", + "use", + "view" +]; +function vb(t) { + return ( + /** + * If it's not a string, it's a custom React component. Currently we only support + * HTML custom React components. + */ + typeof t != "string" || /** + * If it contains a dash, the element is a custom HTML webcomponent. + */ + t.includes("-") ? !1 : ( + /** + * If it's in our list of lowercase SVG tags, it's an SVG component + */ + !!(JZ.indexOf(t) > -1 || /** + * If it contains a capital letter, it's an SVG component + */ + /[A-Z]/u.test(t)) + ) + ); +} +function U7(t, { style: e, vars: r }, n, i) { + Object.assign(t.style, e, i && i.getProjectionStyles(n)); + for (const s in r) + t.style.setProperty(s, r[s]); +} +const q7 = /* @__PURE__ */ new Set([ + "baseFrequency", + "diffuseConstant", + "kernelMatrix", + "kernelUnitLength", + "keySplines", + "keyTimes", + "limitingConeAngle", + "markerHeight", + "markerWidth", + "numOctaves", + "targetX", + "targetY", + "surfaceScale", + "specularConstant", + "specularExponent", + "stdDeviation", + "tableValues", + "viewBox", + "gradientTransform", + "pathLength", + "startOffset", + "textLength", + "lengthAdjust" +]); +function z7(t, e, r, n) { + U7(t, e, void 0, n); + for (const i in e.attrs) + t.setAttribute(q7.has(i) ? i : hb(i), e.attrs[i]); +} +function H7(t, { layout: e, layoutId: r }) { + return Ya.has(t) || t.startsWith("origin") || (e || r !== void 0) && (!!Od[t] || t === "opacity"); +} +function bb(t, e, r) { + var n; + const { style: i } = t, s = {}; + for (const o in i) + (Wn(i[o]) || e.style && Wn(e.style[o]) || H7(o, t) || ((n = r?.getValue(o)) === null || n === void 0 ? void 0 : n.liveStyle) !== void 0) && (s[o] = i[o]); + return s; +} +function W7(t, e, r) { + const n = bb(t, e, r); + for (const i in t) + if (Wn(t[i]) || Wn(e[i])) { + const s = dl.indexOf(i) !== -1 ? "attr" + i.charAt(0).toUpperCase() + i.substring(1) : i; + n[s] = t[i]; + } + return n; +} +function yb(t) { + const e = Kn(null); + return e.current === null && (e.current = t()), e.current; +} +function XZ({ scrapeMotionValuesFromProps: t, createRenderState: e, onMount: r }, n, i, s) { + const o = { + latestValues: ZZ(n, i, s, t), + renderState: e() + }; + return r && (o.mount = (a) => r(n, a, o)), o; +} +const K7 = (t) => (e, r) => { + const n = In(_0), i = In(x0), s = () => XZ(t, e, n, i); + return r ? s() : yb(s); +}; +function ZZ(t, e, r, n) { + const i = {}, s = n(t, {}); + for (const v in s) + i[v] = rd(s[v]); + let { initial: o, animate: a } = t; + const f = E0(t), u = j7(t); + e && u && !f && t.inherit !== !1 && (o === void 0 && (o = e.initial), a === void 0 && (a = e.animate)); + let h = r ? r.initial === !1 : !1; + h = h || o === !1; + const g = h ? a : o; + if (g && typeof g != "boolean" && !v0(g)) { + const v = Array.isArray(g) ? g : [g]; + for (let x = 0; x < v.length; x++) { + const S = W1(t, v[x]); + if (S) { + const { transitionEnd: R, transition: D, ...k } = S; + for (const N in k) { + let z = k[N]; + if (Array.isArray(z)) { + const B = h ? z.length - 1 : 0; + z = z[B]; + } + z !== null && (i[N] = z); + } + for (const N in R) + i[N] = R[N]; + } + } + } + return i; +} +const wb = () => ({ + style: {}, + transform: {}, + transformOrigin: {}, + vars: {} +}), V7 = () => ({ + ...wb(), + attrs: {} +}), G7 = (t, e) => e && typeof t == "number" ? e.transform(t) : t, QZ = { + x: "translateX", + y: "translateY", + z: "translateZ", + transformPerspective: "perspective" +}, eQ = dl.length; +function tQ(t, e, r) { + let n = "", i = !0; + for (let s = 0; s < eQ; s++) { + const o = dl[s], a = t[o]; + if (a === void 0) + continue; + let f = !0; + if (typeof a == "number" ? f = a === (o.startsWith("scale") ? 1 : 0) : f = parseFloat(a) === 0, !f || r) { + const u = G7(a, tb[o]); + if (!f) { + i = !1; + const h = QZ[o] || o; + n += `${h}(${u}) `; + } + r && (e[o] = u); + } + } + return n = n.trim(), r ? n = r(e, i ? "" : n) : i && (n = "none"), n; +} +function xb(t, e, r) { + const { style: n, vars: i, transformOrigin: s } = t; + let o = !1, a = !1; + for (const f in e) { + const u = e[f]; + if (Ya.has(f)) { + o = !0; + continue; + } else if (jS(f)) { + i[f] = u; + continue; + } else { + const h = G7(u, tb[f]); + f.startsWith("origin") ? (a = !0, s[f] = h) : n[f] = h; + } + } + if (e.transform || (o || r ? n.transform = tQ(e, t.transform, r) : n.transform && (n.transform = "none")), a) { + const { originX: f = "50%", originY: u = "50%", originZ: h = 0 } = s; + n.transformOrigin = `${f} ${u} ${h}`; + } +} +function P5(t, e, r) { + return typeof t == "string" ? t : Vt.transform(e + r * t); +} +function rQ(t, e, r) { + const n = P5(e, t.x, t.width), i = P5(r, t.y, t.height); + return `${n} ${i}`; +} +const nQ = { + offset: "stroke-dashoffset", + array: "stroke-dasharray" +}, iQ = { + offset: "strokeDashoffset", + array: "strokeDasharray" +}; +function sQ(t, e, r = 1, n = 0, i = !0) { + t.pathLength = 1; + const s = i ? nQ : iQ; + t[s.offset] = Vt.transform(-n); + const o = Vt.transform(e), a = Vt.transform(r); + t[s.array] = `${o} ${a}`; +} +function _b(t, { + attrX: e, + attrY: r, + attrScale: n, + originX: i, + originY: s, + pathLength: o, + pathSpacing: a = 1, + pathOffset: f = 0, + // This is object creation, which we try to avoid per-frame. + ...u +}, h, g) { + if (xb(t, u, g), h) { + t.style.viewBox && (t.attrs.viewBox = t.style.viewBox); + return; + } + t.attrs = t.style, t.style = {}; + const { attrs: v, style: x, dimensions: S } = t; + v.transform && (S && (x.transform = v.transform), delete v.transform), S && (i !== void 0 || s !== void 0 || x.transform) && (x.transformOrigin = rQ(S, i !== void 0 ? i : 0.5, s !== void 0 ? s : 0.5)), e !== void 0 && (v.x = e), r !== void 0 && (v.y = r), n !== void 0 && (v.scale = n), o !== void 0 && sQ(v, o, a, f, !1); +} +const Eb = (t) => typeof t == "string" && t.toLowerCase() === "svg", oQ = { + useVisualState: K7({ + scrapeMotionValuesFromProps: W7, + createRenderState: V7, + onMount: (t, e, { renderState: r, latestValues: n }) => { + kr.read(() => { + try { + r.dimensions = typeof e.getBBox == "function" ? e.getBBox() : e.getBoundingClientRect(); + } catch { + r.dimensions = { + x: 0, + y: 0, + width: 0, + height: 0 + }; + } + }), kr.render(() => { + _b(r, n, Eb(e.tagName), t.transformTemplate), z7(e, r); + }); + } + }) +}, aQ = { + useVisualState: K7({ + scrapeMotionValuesFromProps: bb, + createRenderState: wb + }) +}; +function Y7(t, e, r) { + for (const n in e) + !Wn(e[n]) && !H7(n, r) && (t[n] = e[n]); +} +function cQ({ transformTemplate: t }, e) { + return hi(() => { + const r = wb(); + return xb(r, e, t), Object.assign({}, r.vars, r.style); + }, [e]); +} +function uQ(t, e) { + const r = t.style || {}, n = {}; + return Y7(n, r, t), Object.assign(n, cQ(t, e)), n; +} +function fQ(t, e) { + const r = {}, n = uQ(t, e); + return t.drag && t.dragListener !== !1 && (r.draggable = !1, n.userSelect = n.WebkitUserSelect = n.WebkitTouchCallout = "none", n.touchAction = t.drag === !0 ? "none" : `pan-${t.drag === "x" ? "y" : "x"}`), t.tabIndex === void 0 && (t.onTap || t.onTapStart || t.whileTap) && (r.tabIndex = 0), r.style = n, r; +} +const lQ = /* @__PURE__ */ new Set([ + "animate", + "exit", + "variants", + "initial", + "style", + "values", + "variants", + "transition", + "transformTemplate", + "custom", + "inherit", + "onBeforeLayoutMeasure", + "onAnimationStart", + "onAnimationComplete", + "onUpdate", + "onDragStart", + "onDrag", + "onDragEnd", + "onMeasureDragConstraints", + "onDirectionLock", + "onDragTransitionEnd", + "_dragX", + "_dragY", + "onHoverStart", + "onHoverEnd", + "onViewportEnter", + "onViewportLeave", + "globalTapTarget", + "ignoreStrict", + "viewport" +]); +function Nd(t) { + return t.startsWith("while") || t.startsWith("drag") && t !== "draggable" || t.startsWith("layout") || t.startsWith("onTap") || t.startsWith("onPan") || t.startsWith("onLayout") || lQ.has(t); +} +let J7 = (t) => !Nd(t); +function hQ(t) { + t && (J7 = (e) => e.startsWith("on") ? !Nd(e) : t(e)); +} +try { + hQ(require("@emotion/is-prop-valid").default); +} catch { +} +function dQ(t, e, r) { + const n = {}; + for (const i in t) + i === "values" && typeof t.values == "object" || (J7(i) || r === !0 && Nd(i) || !e && !Nd(i) || // If trying to use native HTML drag events, forward drag listeners + t.draggable && i.startsWith("onDrag")) && (n[i] = t[i]); + return n; +} +function pQ(t, e, r, n) { + const i = hi(() => { + const s = V7(); + return _b(s, e, Eb(n), t.transformTemplate), { + ...s.attrs, + style: { ...s.style } + }; + }, [e]); + if (t.style) { + const s = {}; + Y7(s, t.style, t), i.style = { ...s, ...i.style }; + } + return i; +} +function gQ(t = !1) { + return (r, n, i, { latestValues: s }, o) => { + const f = (vb(r) ? pQ : fQ)(n, s, o, r), u = dQ(n, typeof r == "string", t), h = r !== W5 ? { ...u, ...f, ref: i } : {}, { children: g } = n, v = hi(() => Wn(g) ? g.get() : g, [g]); + return sd(r, { + ...h, + children: v + }); + }; +} +function mQ(t, e) { + return function(n, { forwardMotionProps: i } = { forwardMotionProps: !1 }) { + const o = { + ...vb(n) ? oQ : aQ, + preloadedFeatures: t, + useRender: gQ(i), + createVisualElement: e, + Component: n + }; + return KZ(o); + }; +} +const Uv = { current: null }, X7 = { current: !1 }; +function vQ() { + if (X7.current = !0, !!mb) + if (window.matchMedia) { + const t = window.matchMedia("(prefers-reduced-motion)"), e = () => Uv.current = t.matches; + t.addListener(e), e(); + } else + Uv.current = !1; +} +function bQ(t, e, r) { + for (const n in e) { + const i = e[n], s = r[n]; + if (Wn(i)) + t.addValue(n, i), process.env.NODE_ENV === "development" && m0(i.version === "11.11.17", `Attempting to mix Motion versions ${i.version} with 11.11.17 may not work as expected.`); + else if (Wn(s)) + t.addValue(n, zf(i, { owner: t })); + else if (s !== i) + if (t.hasValue(n)) { + const o = t.getValue(n); + o.liveStyle === !0 ? o.jump(i) : o.hasAnimated || o.set(i); + } else { + const o = t.getStaticValue(n); + t.addValue(n, zf(o !== void 0 ? o : i, { owner: t })); + } + } + for (const n in r) + e[n] === void 0 && t.removeValue(n); + return e; +} +const M5 = /* @__PURE__ */ new WeakMap(), yQ = [...zS, qn, Yo], wQ = (t) => yQ.find(qS(t)), I5 = [ + "AnimationStart", + "AnimationComplete", + "Update", + "BeforeLayoutMeasure", + "LayoutMeasure", + "LayoutAnimationStart", + "LayoutAnimationComplete" +]; +class xQ { + /** + * This method takes React props and returns found MotionValues. For example, HTML + * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays. + * + * This isn't an abstract method as it needs calling in the constructor, but it is + * intended to be one. + */ + scrapeMotionValuesFromProps(e, r, n) { + return {}; + } + constructor({ parent: e, props: r, presenceContext: n, reducedMotionConfig: i, blockInitialAnimation: s, visualState: o }, a = {}) { + this.current = null, this.children = /* @__PURE__ */ new Set(), this.isVariantNode = !1, this.isControllingVariants = !1, this.shouldReduceMotion = null, this.values = /* @__PURE__ */ new Map(), this.KeyframeResolver = Z1, this.features = {}, this.valueSubscriptions = /* @__PURE__ */ new Map(), this.prevMotionValues = {}, this.events = {}, this.propEventSubscriptions = {}, this.notifyUpdate = () => this.notify("Update", this.latestValues), this.render = () => { + this.current && (this.triggerBuild(), this.renderInstance(this.current, this.renderState, this.props.style, this.projection)); + }, this.renderScheduledAt = 0, this.scheduleRender = () => { + const v = Ts.now(); + this.renderScheduledAt < v && (this.renderScheduledAt = v, kr.render(this.render, !1, !0)); + }; + const { latestValues: f, renderState: u } = o; + this.latestValues = f, this.baseTarget = { ...f }, this.initialValues = r.initial ? { ...f } : {}, this.renderState = u, this.parent = e, this.props = r, this.presenceContext = n, this.depth = e ? e.depth + 1 : 0, this.reducedMotionConfig = i, this.options = a, this.blockInitialAnimation = !!s, this.isControllingVariants = E0(r), this.isVariantNode = j7(r), this.isVariantNode && (this.variantChildren = /* @__PURE__ */ new Set()), this.manuallyAnimateOnMount = !!(e && e.current); + const { willChange: h, ...g } = this.scrapeMotionValuesFromProps(r, {}, this); + for (const v in g) { + const x = g[v]; + f[v] !== void 0 && Wn(x) && x.set(f[v], !1); + } + } + mount(e) { + this.current = e, M5.set(e, this), this.projection && !this.projection.instance && this.projection.mount(e), this.parent && this.isVariantNode && !this.isControllingVariants && (this.removeFromVariantTree = this.parent.addVariantChild(this)), this.values.forEach((r, n) => this.bindToMotionValue(n, r)), X7.current || vQ(), this.shouldReduceMotion = this.reducedMotionConfig === "never" ? !1 : this.reducedMotionConfig === "always" ? !0 : Uv.current, process.env.NODE_ENV !== "production" && m0(this.shouldReduceMotion !== !0, "You have Reduced Motion enabled on your device. Animations may not appear as expected."), this.parent && this.parent.children.add(this), this.update(this.props, this.presenceContext); + } + unmount() { + M5.delete(this.current), this.projection && this.projection.unmount(), Vo(this.notifyUpdate), Vo(this.render), this.valueSubscriptions.forEach((e) => e()), this.valueSubscriptions.clear(), this.removeFromVariantTree && this.removeFromVariantTree(), this.parent && this.parent.children.delete(this); + for (const e in this.events) + this.events[e].clear(); + for (const e in this.features) { + const r = this.features[e]; + r && (r.unmount(), r.isMounted = !1); + } + this.current = null; + } + bindToMotionValue(e, r) { + this.valueSubscriptions.has(e) && this.valueSubscriptions.get(e)(); + const n = Ya.has(e), i = r.on("change", (a) => { + this.latestValues[e] = a, this.props.onUpdate && kr.preRender(this.notifyUpdate), n && this.projection && (this.projection.isTransformDirty = !0); + }), s = r.on("renderRequest", this.scheduleRender); + let o; + window.MotionCheckAppearSync && (o = window.MotionCheckAppearSync(this, e, r)), this.valueSubscriptions.set(e, () => { + i(), s(), o && o(), r.owner && r.stop(); + }); + } + sortNodePosition(e) { + return !this.current || !this.sortInstanceNodePosition || this.type !== e.type ? 0 : this.sortInstanceNodePosition(this.current, e.current); + } + updateFeatures() { + let e = "animation"; + for (e in Wc) { + const r = Wc[e]; + if (!r) + continue; + const { isEnabled: n, Feature: i } = r; + if (!this.features[e] && i && n(this.props) && (this.features[e] = new i(this)), this.features[e]) { + const s = this.features[e]; + s.isMounted ? s.update() : (s.mount(), s.isMounted = !0); + } + } + } + triggerBuild() { + this.build(this.renderState, this.latestValues, this.props); + } + /** + * Measure the current viewport box with or without transforms. + * Only measures axis-aligned boxes, rotate and skew must be manually + * removed with a re-render to work. + */ + measureViewportBox() { + return this.current ? this.measureInstanceViewportBox(this.current, this.props) : fn(); + } + getStaticValue(e) { + return this.latestValues[e]; + } + setStaticValue(e, r) { + this.latestValues[e] = r; + } + /** + * Update the provided props. Ensure any newly-added motion values are + * added to our map, old ones removed, and listeners updated. + */ + update(e, r) { + (e.transformTemplate || this.props.transformTemplate) && this.scheduleRender(), this.prevProps = this.props, this.props = e, this.prevPresenceContext = this.presenceContext, this.presenceContext = r; + for (let n = 0; n < I5.length; n++) { + const i = I5[n]; + this.propEventSubscriptions[i] && (this.propEventSubscriptions[i](), delete this.propEventSubscriptions[i]); + const s = "on" + i, o = e[s]; + o && (this.propEventSubscriptions[i] = this.on(i, o)); + } + this.prevMotionValues = bQ(this, this.scrapeMotionValuesFromProps(e, this.prevProps, this), this.prevMotionValues), this.handleChildMotionValue && this.handleChildMotionValue(); + } + getProps() { + return this.props; + } + /** + * Returns the variant definition with a given name. + */ + getVariant(e) { + return this.props.variants ? this.props.variants[e] : void 0; + } + /** + * Returns the defined default transition on this component. + */ + getDefaultTransition() { + return this.props.transition; + } + getTransformPagePoint() { + return this.props.transformPagePoint; + } + getClosestVariantNode() { + return this.isVariantNode ? this : this.parent ? this.parent.getClosestVariantNode() : void 0; + } + /** + * Add a child visual element to our set of children. + */ + addVariantChild(e) { + const r = this.getClosestVariantNode(); + if (r) + return r.variantChildren && r.variantChildren.add(e), () => r.variantChildren.delete(e); + } + /** + * Add a motion value and bind it to this visual element. + */ + addValue(e, r) { + const n = this.values.get(e); + r !== n && (n && this.removeValue(e), this.bindToMotionValue(e, r), this.values.set(e, r), this.latestValues[e] = r.get()); + } + /** + * Remove a motion value and unbind any active subscriptions. + */ + removeValue(e) { + this.values.delete(e); + const r = this.valueSubscriptions.get(e); + r && (r(), this.valueSubscriptions.delete(e)), delete this.latestValues[e], this.removeValueFromRenderState(e, this.renderState); + } + /** + * Check whether we have a motion value for this key + */ + hasValue(e) { + return this.values.has(e); + } + getValue(e, r) { + if (this.props.values && this.props.values[e]) + return this.props.values[e]; + let n = this.values.get(e); + return n === void 0 && r !== void 0 && (n = zf(r === null ? void 0 : r, { owner: this }), this.addValue(e, n)), n; + } + /** + * If we're trying to animate to a previously unencountered value, + * we need to check for it in our state and as a last resort read it + * directly from the instance (which might have performance implications). + */ + readValue(e, r) { + var n; + let i = this.latestValues[e] !== void 0 || !this.current ? this.latestValues[e] : (n = this.getBaseTargetFromProps(this.props, e)) !== null && n !== void 0 ? n : this.readValueFromInstance(this.current, e, this.options); + return i != null && (typeof i == "string" && (BS(i) || $S(i)) ? i = parseFloat(i) : !wQ(i) && Yo.test(r) && (i = XS(e, r)), this.setBaseTarget(e, Wn(i) ? i.get() : i)), Wn(i) ? i.get() : i; + } + /** + * Set the base target to later animate back to. This is currently + * only hydrated on creation and when we first read a value. + */ + setBaseTarget(e, r) { + this.baseTarget[e] = r; + } + /** + * Find the base target for a value thats been removed from all animation + * props. + */ + getBaseTarget(e) { + var r; + const { initial: n } = this.props; + let i; + if (typeof n == "string" || typeof n == "object") { + const o = W1(this.props, n, (r = this.presenceContext) === null || r === void 0 ? void 0 : r.custom); + o && (i = o[e]); + } + if (n && i !== void 0) + return i; + const s = this.getBaseTargetFromProps(this.props, e); + return s !== void 0 && !Wn(s) ? s : this.initialValues[e] !== void 0 && i === void 0 ? void 0 : this.baseTarget[e]; + } + on(e, r) { + return this.events[e] || (this.events[e] = new lb()), this.events[e].add(r); + } + notify(e, ...r) { + this.events[e] && this.events[e].notify(...r); + } +} +class Z7 extends xQ { + constructor() { + super(...arguments), this.KeyframeResolver = ZS; + } + sortInstanceNodePosition(e, r) { + return e.compareDocumentPosition(r) & 2 ? 1 : -1; + } + getBaseTargetFromProps(e, r) { + return e.style ? e.style[r] : void 0; + } + removeValueFromRenderState(e, { vars: r, style: n }) { + delete r[e], delete n[e]; + } +} +function _Q(t) { + return window.getComputedStyle(t); +} +class EQ extends Z7 { + constructor() { + super(...arguments), this.type = "html", this.renderInstance = U7; + } + readValueFromInstance(e, r) { + if (Ya.has(r)) { + const n = rb(r); + return n && n.default || 0; + } else { + const n = _Q(e), i = (jS(r) ? n.getPropertyValue(r) : n[r]) || 0; + return typeof i == "string" ? i.trim() : i; + } + } + measureInstanceViewportBox(e, { transformPagePoint: r }) { + return S7(e, r); + } + build(e, r, n) { + xb(e, r, n.transformTemplate); + } + scrapeMotionValuesFromProps(e, r, n) { + return bb(e, r, n); + } + handleChildMotionValue() { + this.childSubscription && (this.childSubscription(), delete this.childSubscription); + const { children: e } = this.props; + Wn(e) && (this.childSubscription = e.on("change", (r) => { + this.current && (this.current.textContent = `${r}`); + })); + } +} +class SQ extends Z7 { + constructor() { + super(...arguments), this.type = "svg", this.isSVGTag = !1, this.measureInstanceViewportBox = fn; + } + getBaseTargetFromProps(e, r) { + return e[r]; + } + readValueFromInstance(e, r) { + if (Ya.has(r)) { + const n = rb(r); + return n && n.default || 0; + } + return r = q7.has(r) ? r : hb(r), e.getAttribute(r); + } + scrapeMotionValuesFromProps(e, r, n) { + return W7(e, r, n); + } + build(e, r, n) { + _b(e, r, this.isSVGTag, n.transformTemplate); + } + renderInstance(e, r, n, i) { + z7(e, r, n, i); + } + mount(e) { + this.isSVGTag = Eb(e.tagName), super.mount(e); + } +} +const AQ = (t, e) => vb(t) ? new SQ(e) : new EQ(e, { + allowProjection: t !== W5 +}), PQ = /* @__PURE__ */ mQ({ + ...gX, + ...$Z, + ...PZ, + ...BZ +}, AQ), MQ = /* @__PURE__ */ oY(PQ); +class IQ extends Jt.Component { + getSnapshotBeforeUpdate(e) { + const r = this.props.childRef.current; + if (r && e.isPresent && !this.props.isPresent) { + const n = this.props.sizeRef.current; + n.height = r.offsetHeight || 0, n.width = r.offsetWidth || 0, n.top = r.offsetTop, n.left = r.offsetLeft; + } + return null; + } + /** + * Required with getSnapshotBeforeUpdate to stop React complaining. + */ + componentDidUpdate() { + } + render() { + return this.props.children; + } +} +function CQ({ children: t, isPresent: e }) { + const r = Vv(), n = Kn(null), i = Kn({ + width: 0, + height: 0, + top: 0, + left: 0 + }), { nonce: s } = In(gb); + return H5(() => { + const { width: o, height: a, top: f, left: u } = i.current; + if (e || !n.current || !o || !a) + return; + n.current.dataset.motionPopId = r; + const h = document.createElement("style"); + return s && (h.nonce = s), document.head.appendChild(h), h.sheet && h.sheet.insertRule(` + [data-motion-pop-id="${r}"] { + position: absolute !important; + width: ${o}px !important; + height: ${a}px !important; + top: ${f}px !important; + left: ${u}px !important; + } + `), () => { + document.head.removeChild(h); + }; + }, [e]), pe.jsx(IQ, { isPresent: e, childRef: n, sizeRef: i, children: Jt.cloneElement(t, { ref: n }) }); +} +const RQ = ({ children: t, initial: e, isPresent: r, onExitComplete: n, custom: i, presenceAffectsLayout: s, mode: o }) => { + const a = yb(TQ), f = Vv(), u = Gv((g) => { + a.set(g, !0); + for (const v of a.values()) + if (!v) + return; + n && n(); + }, [a, n]), h = hi( + () => ({ + id: f, + initial: e, + isPresent: r, + custom: i, + onExitComplete: u, + register: (g) => (a.set(g, !1), () => a.delete(g)) + }), + /** + * If the presence of a child affects the layout of the components around it, + * we want to make a new context value to ensure they get re-rendered + * so they can detect that layout change. + */ + s ? [Math.random(), u] : [r, u] + ); + return hi(() => { + a.forEach((g, v) => a.set(v, !1)); + }, [r]), Jt.useEffect(() => { + !r && !a.size && n && n(); + }, [r]), o === "popLayout" && (t = pe.jsx(CQ, { isPresent: r, children: t })), pe.jsx(x0.Provider, { value: h, children: t }); +}; +function TQ() { + return /* @__PURE__ */ new Map(); +} +const Th = (t) => t.key || ""; +function C5(t) { + const e = []; + return dT.forEach(t, (r) => { + pT(r) && e.push(r); + }), e; +} +const DQ = ({ children: t, exitBeforeEnter: e, custom: r, initial: n = !0, onExitComplete: i, presenceAffectsLayout: s = !0, mode: o = "sync" }) => { + po(!e, "Replace exitBeforeEnter with mode='wait'"); + const a = hi(() => C5(t), [t]), f = a.map(Th), u = Kn(!0), h = Kn(a), g = yb(() => /* @__PURE__ */ new Map()), [v, x] = Xt(a), [S, R] = Xt(a); + $7(() => { + u.current = !1, h.current = a; + for (let N = 0; N < S.length; N++) { + const z = Th(S[N]); + f.includes(z) ? g.delete(z) : g.get(z) !== !0 && g.set(z, !1); + } + }, [S, f.length, f.join("-")]); + const D = []; + if (a !== v) { + let N = [...a]; + for (let z = 0; z < S.length; z++) { + const B = S[z], $ = Th(B); + f.includes($) || (N.splice(z, 0, B), D.push(B)); + } + o === "wait" && D.length && (N = D), R(C5(N)), x(a); + return; + } + process.env.NODE_ENV !== "production" && o === "wait" && S.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`); + const { forceRender: k } = In(db); + return pe.jsx(pe.Fragment, { children: S.map((N) => { + const z = Th(N), B = a === S || f.includes(z), $ = () => { + if (g.has(z)) + g.set(z, !0); + else + return; + let U = !0; + g.forEach((C) => { + C || (U = !1); + }), U && (k?.(), R(h.current), i && i()); + }; + return pe.jsx(RQ, { isPresent: B, initial: !u.current || n ? void 0 : !1, custom: B ? void 0 : r, presenceAffectsLayout: s, mode: o, onExitComplete: B ? void 0 : $, children: N }, z); + }) }); +}, ps = (t) => /* @__PURE__ */ pe.jsx(DQ, { children: /* @__PURE__ */ pe.jsx( + MQ.div, + { + initial: { x: 0, opacity: 0 }, + animate: { x: 0, opacity: 1 }, + exit: { x: 30, opacity: 0 }, + transition: { duration: 0.3 }, + className: t.className, + children: t.children + } +) }); +function Sb(t) { + const { icon: e, title: r, extra: n, onClick: i } = t; + function s() { + i && i(); + } + return /* @__PURE__ */ pe.jsxs( + "div", + { + className: "xc-rounded-lg xc-group xc-flex xc-cursor-pointer xc-items-center xc-gap-2 xc-border xc-border-white xc-border-opacity-15 xc-px-4 xc-py-2 xc-transition-all hover:xc-shadow-lg", + onClick: s, + children: [ + e, + r, + /* @__PURE__ */ pe.jsxs("div", { className: "xc-relative xc-ml-auto xc-h-6", children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-relative xc-left-0 xc-opacity-100 xc-transition-all group-hover:xc-left-2 group-hover:xc-opacity-0", children: n }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-absolute xc-right-2 xc-top-0 xc-text-gray-400 xc-opacity-0 xc-transition-all group-hover:xc-right-0 group-hover:xc-opacity-100", children: /* @__PURE__ */ pe.jsx(QG, {}) }) + ] }) + ] + } + ); +} +function OQ(t) { + return t.lastUsed ? /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-items-center xc-gap-2 xc-rounded-full xc-py-1 xc-text-xs xc-text-gray-500", children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-h-1 xc-w-1 xc-rounded-full xc-bg-[#009E8C]" }), + "Last Used" + ] }) : t.installed ? /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-items-center xc-gap-2 xc-rounded-full xc-py-1 xc-text-xs xc-text-gray-500", children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-h-1 xc-w-1 xc-rounded-full xc-bg-[#2596FF]" }), + "Installed" + ] }) : null; +} +function Q7(t) { + const { wallet: e, onClick: r } = t, n = /* @__PURE__ */ pe.jsx("img", { className: "xc-rounded-md xc-h-5 xc-w-5", src: e.config?.image }), i = e.config?.name || "", s = hi(() => OQ(e), [e]); + return /* @__PURE__ */ pe.jsx(Sb, { icon: n, title: i, extra: s, onClick: () => r(e) }); +} +function e9(t) { + var e, r, n = ""; + if (typeof t == "string" || typeof t == "number") n += t; + else if (typeof t == "object") if (Array.isArray(t)) { + var i = t.length; + for (e = 0; e < i; e++) t[e] && (r = e9(t[e])) && (n && (n += " "), n += r); + } else for (r in t) t[r] && (n && (n += " "), n += r); + return n; +} +function NQ() { + for (var t, e, r = 0, n = "", i = arguments.length; r < i; r++) (t = arguments[r]) && (e = e9(t)) && (n && (n += " "), n += e); + return n; +} +const LQ = NQ, Ab = "-", kQ = (t) => { + const e = BQ(t), { + conflictingClassGroups: r, + conflictingClassGroupModifiers: n + } = t; + return { + getClassGroupId: (o) => { + const a = o.split(Ab); + return a[0] === "" && a.length !== 1 && a.shift(), t9(a, e) || $Q(o); + }, + getConflictingClassGroupIds: (o, a) => { + const f = r[o] || []; + return a && n[o] ? [...f, ...n[o]] : f; + } + }; +}, t9 = (t, e) => { + if (t.length === 0) + return e.classGroupId; + const r = t[0], n = e.nextPart.get(r), i = n ? t9(t.slice(1), n) : void 0; + if (i) + return i; + if (e.validators.length === 0) + return; + const s = t.join(Ab); + return e.validators.find(({ + validator: o + }) => o(s))?.classGroupId; +}, R5 = /^\[(.+)\]$/, $Q = (t) => { + if (R5.test(t)) { + const e = R5.exec(t)[1], r = e?.substring(0, e.indexOf(":")); + if (r) + return "arbitrary.." + r; + } +}, BQ = (t) => { + const { + theme: e, + prefix: r + } = t, n = { + nextPart: /* @__PURE__ */ new Map(), + validators: [] + }; + return jQ(Object.entries(t.classGroups), r).forEach(([s, o]) => { + qv(o, n, s, e); + }), n; +}, qv = (t, e, r, n) => { + t.forEach((i) => { + if (typeof i == "string") { + const s = i === "" ? e : T5(e, i); + s.classGroupId = r; + return; + } + if (typeof i == "function") { + if (FQ(i)) { + qv(i(n), e, r, n); + return; + } + e.validators.push({ + validator: i, + classGroupId: r + }); + return; + } + Object.entries(i).forEach(([s, o]) => { + qv(o, T5(e, s), r, n); + }); + }); +}, T5 = (t, e) => { + let r = t; + return e.split(Ab).forEach((n) => { + r.nextPart.has(n) || r.nextPart.set(n, { + nextPart: /* @__PURE__ */ new Map(), + validators: [] + }), r = r.nextPart.get(n); + }), r; +}, FQ = (t) => t.isThemeGetter, jQ = (t, e) => e ? t.map(([r, n]) => { + const i = n.map((s) => typeof s == "string" ? e + s : typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([o, a]) => [e + o, a])) : s); + return [r, i]; +}) : t, UQ = (t) => { + if (t < 1) + return { + get: () => { + }, + set: () => { + } + }; + let e = 0, r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(); + const i = (s, o) => { + r.set(s, o), e++, e > t && (e = 0, n = r, r = /* @__PURE__ */ new Map()); + }; + return { + get(s) { + let o = r.get(s); + if (o !== void 0) + return o; + if ((o = n.get(s)) !== void 0) + return i(s, o), o; + }, + set(s, o) { + r.has(s) ? r.set(s, o) : i(s, o); + } + }; +}, r9 = "!", qQ = (t) => { + const { + separator: e, + experimentalParseClassName: r + } = t, n = e.length === 1, i = e[0], s = e.length, o = (a) => { + const f = []; + let u = 0, h = 0, g; + for (let D = 0; D < a.length; D++) { + let k = a[D]; + if (u === 0) { + if (k === i && (n || a.slice(D, D + s) === e)) { + f.push(a.slice(h, D)), h = D + s; + continue; + } + if (k === "/") { + g = D; + continue; + } + } + k === "[" ? u++ : k === "]" && u--; + } + const v = f.length === 0 ? a : a.substring(h), x = v.startsWith(r9), S = x ? v.substring(1) : v, R = g && g > h ? g - h : void 0; + return { + modifiers: f, + hasImportantModifier: x, + baseClassName: S, + maybePostfixModifierPosition: R + }; + }; + return r ? (a) => r({ + className: a, + parseClassName: o + }) : o; +}, zQ = (t) => { + if (t.length <= 1) + return t; + const e = []; + let r = []; + return t.forEach((n) => { + n[0] === "[" ? (e.push(...r.sort(), n), r = []) : r.push(n); + }), e.push(...r.sort()), e; +}, HQ = (t) => ({ + cache: UQ(t.cacheSize), + parseClassName: qQ(t), + ...kQ(t) +}), WQ = /\s+/, KQ = (t, e) => { + const { + parseClassName: r, + getClassGroupId: n, + getConflictingClassGroupIds: i + } = e, s = [], o = t.trim().split(WQ); + let a = ""; + for (let f = o.length - 1; f >= 0; f -= 1) { + const u = o[f], { + modifiers: h, + hasImportantModifier: g, + baseClassName: v, + maybePostfixModifierPosition: x + } = r(u); + let S = !!x, R = n(S ? v.substring(0, x) : v); + if (!R) { + if (!S) { + a = u + (a.length > 0 ? " " + a : a); + continue; + } + if (R = n(v), !R) { + a = u + (a.length > 0 ? " " + a : a); + continue; + } + S = !1; + } + const D = zQ(h).join(":"), k = g ? D + r9 : D, N = k + R; + if (s.includes(N)) + continue; + s.push(N); + const z = i(R, S); + for (let B = 0; B < z.length; ++B) { + const $ = z[B]; + s.push(k + $); + } + a = u + (a.length > 0 ? " " + a : a); + } + return a; +}; +function VQ() { + let t = 0, e, r, n = ""; + for (; t < arguments.length; ) + (e = arguments[t++]) && (r = n9(e)) && (n && (n += " "), n += r); + return n; +} +const n9 = (t) => { + if (typeof t == "string") + return t; + let e, r = ""; + for (let n = 0; n < t.length; n++) + t[n] && (e = n9(t[n])) && (r && (r += " "), r += e); + return r; +}; +function GQ(t, ...e) { + let r, n, i, s = o; + function o(f) { + const u = e.reduce((h, g) => g(h), t()); + return r = HQ(u), n = r.cache.get, i = r.cache.set, s = a, a(f); + } + function a(f) { + const u = n(f); + if (u) + return u; + const h = KQ(f, r); + return i(f, h), h; + } + return function() { + return s(VQ.apply(null, arguments)); + }; +} +const Gr = (t) => { + const e = (r) => r[t] || []; + return e.isThemeGetter = !0, e; +}, i9 = /^\[(?:([a-z-]+):)?(.+)\]$/i, YQ = /^\d+\/\d+$/, JQ = /* @__PURE__ */ new Set(["px", "full", "screen"]), XQ = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, ZQ = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, QQ = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, eee = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, tee = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, Js = (t) => $c(t) || JQ.has(t) || YQ.test(t), Io = (t) => tu(t, "length", uee), $c = (t) => !!t && !Number.isNaN(Number(t)), Tm = (t) => tu(t, "number", $c), zu = (t) => !!t && Number.isInteger(Number(t)), ree = (t) => t.endsWith("%") && $c(t.slice(0, -1)), ur = (t) => i9.test(t), Co = (t) => XQ.test(t), nee = /* @__PURE__ */ new Set(["length", "size", "percentage"]), iee = (t) => tu(t, nee, s9), see = (t) => tu(t, "position", s9), oee = /* @__PURE__ */ new Set(["image", "url"]), aee = (t) => tu(t, oee, lee), cee = (t) => tu(t, "", fee), Hu = () => !0, tu = (t, e, r) => { + const n = i9.exec(t); + return n ? n[1] ? typeof e == "string" ? n[1] === e : e.has(n[1]) : r(n[2]) : !1; +}, uee = (t) => ( + // `colorFunctionRegex` check is necessary because color functions can have percentages in them which which would be incorrectly classified as lengths. + // For example, `hsl(0 0% 0%)` would be classified as a length without this check. + // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough. + ZQ.test(t) && !QQ.test(t) +), s9 = () => !1, fee = (t) => eee.test(t), lee = (t) => tee.test(t), hee = () => { + const t = Gr("colors"), e = Gr("spacing"), r = Gr("blur"), n = Gr("brightness"), i = Gr("borderColor"), s = Gr("borderRadius"), o = Gr("borderSpacing"), a = Gr("borderWidth"), f = Gr("contrast"), u = Gr("grayscale"), h = Gr("hueRotate"), g = Gr("invert"), v = Gr("gap"), x = Gr("gradientColorStops"), S = Gr("gradientColorStopPositions"), R = Gr("inset"), D = Gr("margin"), k = Gr("opacity"), N = Gr("padding"), z = Gr("saturate"), B = Gr("scale"), $ = Gr("sepia"), U = Gr("skew"), C = Gr("space"), W = Gr("translate"), J = () => ["auto", "contain", "none"], ne = () => ["auto", "hidden", "clip", "visible", "scroll"], K = () => ["auto", ur, e], E = () => [ur, e], b = () => ["", Js, Io], l = () => ["auto", $c, ur], p = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], m = () => ["solid", "dashed", "dotted", "double", "none"], w = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], P = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], _ = () => ["", "0", ur], y = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], M = () => [$c, ur]; + return { + cacheSize: 500, + separator: ":", + theme: { + colors: [Hu], + spacing: [Js, Io], + blur: ["none", "", Co, ur], + brightness: M(), + borderColor: [t], + borderRadius: ["none", "", "full", Co, ur], + borderSpacing: E(), + borderWidth: b(), + contrast: M(), + grayscale: _(), + hueRotate: M(), + invert: _(), + gap: E(), + gradientColorStops: [t], + gradientColorStopPositions: [ree, Io], + inset: K(), + margin: K(), + opacity: M(), + padding: E(), + saturate: M(), + scale: M(), + sepia: _(), + skew: M(), + space: E(), + translate: E() + }, + classGroups: { + // Layout + /** + * Aspect Ratio + * @see https://tailwindcss.com/docs/aspect-ratio + */ + aspect: [{ + aspect: ["auto", "square", "video", ur] + }], + /** + * Container + * @see https://tailwindcss.com/docs/container + */ + container: ["container"], + /** + * Columns + * @see https://tailwindcss.com/docs/columns + */ + columns: [{ + columns: [Co] + }], + /** + * Break After + * @see https://tailwindcss.com/docs/break-after + */ + "break-after": [{ + "break-after": y() + }], + /** + * Break Before + * @see https://tailwindcss.com/docs/break-before + */ + "break-before": [{ + "break-before": y() + }], + /** + * Break Inside + * @see https://tailwindcss.com/docs/break-inside + */ + "break-inside": [{ + "break-inside": ["auto", "avoid", "avoid-page", "avoid-column"] + }], + /** + * Box Decoration Break + * @see https://tailwindcss.com/docs/box-decoration-break + */ + "box-decoration": [{ + "box-decoration": ["slice", "clone"] + }], + /** + * Box Sizing + * @see https://tailwindcss.com/docs/box-sizing + */ + box: [{ + box: ["border", "content"] + }], + /** + * Display + * @see https://tailwindcss.com/docs/display + */ + display: ["block", "inline-block", "inline", "flex", "inline-flex", "table", "inline-table", "table-caption", "table-cell", "table-column", "table-column-group", "table-footer-group", "table-header-group", "table-row-group", "table-row", "flow-root", "grid", "inline-grid", "contents", "list-item", "hidden"], + /** + * Floats + * @see https://tailwindcss.com/docs/float + */ + float: [{ + float: ["right", "left", "none", "start", "end"] + }], + /** + * Clear + * @see https://tailwindcss.com/docs/clear + */ + clear: [{ + clear: ["left", "right", "both", "none", "start", "end"] + }], + /** + * Isolation + * @see https://tailwindcss.com/docs/isolation + */ + isolation: ["isolate", "isolation-auto"], + /** + * Object Fit + * @see https://tailwindcss.com/docs/object-fit + */ + "object-fit": [{ + object: ["contain", "cover", "fill", "none", "scale-down"] + }], + /** + * Object Position + * @see https://tailwindcss.com/docs/object-position + */ + "object-position": [{ + object: [...p(), ur] + }], + /** + * Overflow + * @see https://tailwindcss.com/docs/overflow + */ + overflow: [{ + overflow: ne() + }], + /** + * Overflow X + * @see https://tailwindcss.com/docs/overflow + */ + "overflow-x": [{ + "overflow-x": ne() + }], + /** + * Overflow Y + * @see https://tailwindcss.com/docs/overflow + */ + "overflow-y": [{ + "overflow-y": ne() + }], + /** + * Overscroll Behavior + * @see https://tailwindcss.com/docs/overscroll-behavior + */ + overscroll: [{ + overscroll: J() + }], + /** + * Overscroll Behavior X + * @see https://tailwindcss.com/docs/overscroll-behavior + */ + "overscroll-x": [{ + "overscroll-x": J() + }], + /** + * Overscroll Behavior Y + * @see https://tailwindcss.com/docs/overscroll-behavior + */ + "overscroll-y": [{ + "overscroll-y": J() + }], + /** + * Position + * @see https://tailwindcss.com/docs/position + */ + position: ["static", "fixed", "absolute", "relative", "sticky"], + /** + * Top / Right / Bottom / Left + * @see https://tailwindcss.com/docs/top-right-bottom-left + */ + inset: [{ + inset: [R] + }], + /** + * Right / Left + * @see https://tailwindcss.com/docs/top-right-bottom-left + */ + "inset-x": [{ + "inset-x": [R] + }], + /** + * Top / Bottom + * @see https://tailwindcss.com/docs/top-right-bottom-left + */ + "inset-y": [{ + "inset-y": [R] + }], + /** + * Start + * @see https://tailwindcss.com/docs/top-right-bottom-left + */ + start: [{ + start: [R] + }], + /** + * End + * @see https://tailwindcss.com/docs/top-right-bottom-left + */ + end: [{ + end: [R] + }], + /** + * Top + * @see https://tailwindcss.com/docs/top-right-bottom-left + */ + top: [{ + top: [R] + }], + /** + * Right + * @see https://tailwindcss.com/docs/top-right-bottom-left + */ + right: [{ + right: [R] + }], + /** + * Bottom + * @see https://tailwindcss.com/docs/top-right-bottom-left + */ + bottom: [{ + bottom: [R] + }], + /** + * Left + * @see https://tailwindcss.com/docs/top-right-bottom-left + */ + left: [{ + left: [R] + }], + /** + * Visibility + * @see https://tailwindcss.com/docs/visibility + */ + visibility: ["visible", "invisible", "collapse"], + /** + * Z-Index + * @see https://tailwindcss.com/docs/z-index + */ + z: [{ + z: ["auto", zu, ur] + }], + // Flexbox and Grid + /** + * Flex Basis + * @see https://tailwindcss.com/docs/flex-basis + */ + basis: [{ + basis: K() + }], + /** + * Flex Direction + * @see https://tailwindcss.com/docs/flex-direction + */ + "flex-direction": [{ + flex: ["row", "row-reverse", "col", "col-reverse"] + }], + /** + * Flex Wrap + * @see https://tailwindcss.com/docs/flex-wrap + */ + "flex-wrap": [{ + flex: ["wrap", "wrap-reverse", "nowrap"] + }], + /** + * Flex + * @see https://tailwindcss.com/docs/flex + */ + flex: [{ + flex: ["1", "auto", "initial", "none", ur] + }], + /** + * Flex Grow + * @see https://tailwindcss.com/docs/flex-grow + */ + grow: [{ + grow: _() + }], + /** + * Flex Shrink + * @see https://tailwindcss.com/docs/flex-shrink + */ + shrink: [{ + shrink: _() + }], + /** + * Order + * @see https://tailwindcss.com/docs/order + */ + order: [{ + order: ["first", "last", "none", zu, ur] + }], + /** + * Grid Template Columns + * @see https://tailwindcss.com/docs/grid-template-columns + */ + "grid-cols": [{ + "grid-cols": [Hu] + }], + /** + * Grid Column Start / End + * @see https://tailwindcss.com/docs/grid-column + */ + "col-start-end": [{ + col: ["auto", { + span: ["full", zu, ur] + }, ur] + }], + /** + * Grid Column Start + * @see https://tailwindcss.com/docs/grid-column + */ + "col-start": [{ + "col-start": l() + }], + /** + * Grid Column End + * @see https://tailwindcss.com/docs/grid-column + */ + "col-end": [{ + "col-end": l() + }], + /** + * Grid Template Rows + * @see https://tailwindcss.com/docs/grid-template-rows + */ + "grid-rows": [{ + "grid-rows": [Hu] + }], + /** + * Grid Row Start / End + * @see https://tailwindcss.com/docs/grid-row + */ + "row-start-end": [{ + row: ["auto", { + span: [zu, ur] + }, ur] + }], + /** + * Grid Row Start + * @see https://tailwindcss.com/docs/grid-row + */ + "row-start": [{ + "row-start": l() + }], + /** + * Grid Row End + * @see https://tailwindcss.com/docs/grid-row + */ + "row-end": [{ + "row-end": l() + }], + /** + * Grid Auto Flow + * @see https://tailwindcss.com/docs/grid-auto-flow + */ + "grid-flow": [{ + "grid-flow": ["row", "col", "dense", "row-dense", "col-dense"] + }], + /** + * Grid Auto Columns + * @see https://tailwindcss.com/docs/grid-auto-columns + */ + "auto-cols": [{ + "auto-cols": ["auto", "min", "max", "fr", ur] + }], + /** + * Grid Auto Rows + * @see https://tailwindcss.com/docs/grid-auto-rows + */ + "auto-rows": [{ + "auto-rows": ["auto", "min", "max", "fr", ur] + }], + /** + * Gap + * @see https://tailwindcss.com/docs/gap + */ + gap: [{ + gap: [v] + }], + /** + * Gap X + * @see https://tailwindcss.com/docs/gap + */ + "gap-x": [{ + "gap-x": [v] + }], + /** + * Gap Y + * @see https://tailwindcss.com/docs/gap + */ + "gap-y": [{ + "gap-y": [v] + }], + /** + * Justify Content + * @see https://tailwindcss.com/docs/justify-content + */ + "justify-content": [{ + justify: ["normal", ...P()] + }], + /** + * Justify Items + * @see https://tailwindcss.com/docs/justify-items + */ + "justify-items": [{ + "justify-items": ["start", "end", "center", "stretch"] + }], + /** + * Justify Self + * @see https://tailwindcss.com/docs/justify-self + */ + "justify-self": [{ + "justify-self": ["auto", "start", "end", "center", "stretch"] + }], + /** + * Align Content + * @see https://tailwindcss.com/docs/align-content + */ + "align-content": [{ + content: ["normal", ...P(), "baseline"] + }], + /** + * Align Items + * @see https://tailwindcss.com/docs/align-items + */ + "align-items": [{ + items: ["start", "end", "center", "baseline", "stretch"] + }], + /** + * Align Self + * @see https://tailwindcss.com/docs/align-self + */ + "align-self": [{ + self: ["auto", "start", "end", "center", "stretch", "baseline"] + }], + /** + * Place Content + * @see https://tailwindcss.com/docs/place-content + */ + "place-content": [{ + "place-content": [...P(), "baseline"] + }], + /** + * Place Items + * @see https://tailwindcss.com/docs/place-items + */ + "place-items": [{ + "place-items": ["start", "end", "center", "baseline", "stretch"] + }], + /** + * Place Self + * @see https://tailwindcss.com/docs/place-self + */ + "place-self": [{ + "place-self": ["auto", "start", "end", "center", "stretch"] + }], + // Spacing + /** + * Padding + * @see https://tailwindcss.com/docs/padding + */ + p: [{ + p: [N] + }], + /** + * Padding X + * @see https://tailwindcss.com/docs/padding + */ + px: [{ + px: [N] + }], + /** + * Padding Y + * @see https://tailwindcss.com/docs/padding + */ + py: [{ + py: [N] + }], + /** + * Padding Start + * @see https://tailwindcss.com/docs/padding + */ + ps: [{ + ps: [N] + }], + /** + * Padding End + * @see https://tailwindcss.com/docs/padding + */ + pe: [{ + pe: [N] + }], + /** + * Padding Top + * @see https://tailwindcss.com/docs/padding + */ + pt: [{ + pt: [N] + }], + /** + * Padding Right + * @see https://tailwindcss.com/docs/padding + */ + pr: [{ + pr: [N] + }], + /** + * Padding Bottom + * @see https://tailwindcss.com/docs/padding + */ + pb: [{ + pb: [N] + }], + /** + * Padding Left + * @see https://tailwindcss.com/docs/padding + */ + pl: [{ + pl: [N] + }], + /** + * Margin + * @see https://tailwindcss.com/docs/margin + */ + m: [{ + m: [D] + }], + /** + * Margin X + * @see https://tailwindcss.com/docs/margin + */ + mx: [{ + mx: [D] + }], + /** + * Margin Y + * @see https://tailwindcss.com/docs/margin + */ + my: [{ + my: [D] + }], + /** + * Margin Start + * @see https://tailwindcss.com/docs/margin + */ + ms: [{ + ms: [D] + }], + /** + * Margin End + * @see https://tailwindcss.com/docs/margin + */ + me: [{ + me: [D] + }], + /** + * Margin Top + * @see https://tailwindcss.com/docs/margin + */ + mt: [{ + mt: [D] + }], + /** + * Margin Right + * @see https://tailwindcss.com/docs/margin + */ + mr: [{ + mr: [D] + }], + /** + * Margin Bottom + * @see https://tailwindcss.com/docs/margin + */ + mb: [{ + mb: [D] + }], + /** + * Margin Left + * @see https://tailwindcss.com/docs/margin + */ + ml: [{ + ml: [D] + }], + /** + * Space Between X + * @see https://tailwindcss.com/docs/space + */ + "space-x": [{ + "space-x": [C] + }], + /** + * Space Between X Reverse + * @see https://tailwindcss.com/docs/space + */ + "space-x-reverse": ["space-x-reverse"], + /** + * Space Between Y + * @see https://tailwindcss.com/docs/space + */ + "space-y": [{ + "space-y": [C] + }], + /** + * Space Between Y Reverse + * @see https://tailwindcss.com/docs/space + */ + "space-y-reverse": ["space-y-reverse"], + // Sizing + /** + * Width + * @see https://tailwindcss.com/docs/width + */ + w: [{ + w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", ur, e] + }], + /** + * Min-Width + * @see https://tailwindcss.com/docs/min-width + */ + "min-w": [{ + "min-w": [ur, e, "min", "max", "fit"] + }], + /** + * Max-Width + * @see https://tailwindcss.com/docs/max-width + */ + "max-w": [{ + "max-w": [ur, e, "none", "full", "min", "max", "fit", "prose", { + screen: [Co] + }, Co] + }], + /** + * Height + * @see https://tailwindcss.com/docs/height + */ + h: [{ + h: [ur, e, "auto", "min", "max", "fit", "svh", "lvh", "dvh"] + }], + /** + * Min-Height + * @see https://tailwindcss.com/docs/min-height + */ + "min-h": [{ + "min-h": [ur, e, "min", "max", "fit", "svh", "lvh", "dvh"] + }], + /** + * Max-Height + * @see https://tailwindcss.com/docs/max-height + */ + "max-h": [{ + "max-h": [ur, e, "min", "max", "fit", "svh", "lvh", "dvh"] + }], + /** + * Size + * @see https://tailwindcss.com/docs/size + */ + size: [{ + size: [ur, e, "auto", "min", "max", "fit"] + }], + // Typography + /** + * Font Size + * @see https://tailwindcss.com/docs/font-size + */ + "font-size": [{ + text: ["base", Co, Io] + }], + /** + * Font Smoothing + * @see https://tailwindcss.com/docs/font-smoothing + */ + "font-smoothing": ["antialiased", "subpixel-antialiased"], + /** + * Font Style + * @see https://tailwindcss.com/docs/font-style + */ + "font-style": ["italic", "not-italic"], + /** + * Font Weight + * @see https://tailwindcss.com/docs/font-weight + */ + "font-weight": [{ + font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black", Tm] + }], + /** + * Font Family + * @see https://tailwindcss.com/docs/font-family + */ + "font-family": [{ + font: [Hu] + }], + /** + * Font Variant Numeric + * @see https://tailwindcss.com/docs/font-variant-numeric + */ + "fvn-normal": ["normal-nums"], + /** + * Font Variant Numeric + * @see https://tailwindcss.com/docs/font-variant-numeric + */ + "fvn-ordinal": ["ordinal"], + /** + * Font Variant Numeric + * @see https://tailwindcss.com/docs/font-variant-numeric + */ + "fvn-slashed-zero": ["slashed-zero"], + /** + * Font Variant Numeric + * @see https://tailwindcss.com/docs/font-variant-numeric + */ + "fvn-figure": ["lining-nums", "oldstyle-nums"], + /** + * Font Variant Numeric + * @see https://tailwindcss.com/docs/font-variant-numeric + */ + "fvn-spacing": ["proportional-nums", "tabular-nums"], + /** + * Font Variant Numeric + * @see https://tailwindcss.com/docs/font-variant-numeric + */ + "fvn-fraction": ["diagonal-fractions", "stacked-fractions"], + /** + * Letter Spacing + * @see https://tailwindcss.com/docs/letter-spacing + */ + tracking: [{ + tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", ur] + }], + /** + * Line Clamp + * @see https://tailwindcss.com/docs/line-clamp + */ + "line-clamp": [{ + "line-clamp": ["none", $c, Tm] + }], + /** + * Line Height + * @see https://tailwindcss.com/docs/line-height + */ + leading: [{ + leading: ["none", "tight", "snug", "normal", "relaxed", "loose", Js, ur] + }], + /** + * List Style Image + * @see https://tailwindcss.com/docs/list-style-image + */ + "list-image": [{ + "list-image": ["none", ur] + }], + /** + * List Style Type + * @see https://tailwindcss.com/docs/list-style-type + */ + "list-style-type": [{ + list: ["none", "disc", "decimal", ur] + }], + /** + * List Style Position + * @see https://tailwindcss.com/docs/list-style-position + */ + "list-style-position": [{ + list: ["inside", "outside"] + }], + /** + * Placeholder Color + * @deprecated since Tailwind CSS v3.0.0 + * @see https://tailwindcss.com/docs/placeholder-color + */ + "placeholder-color": [{ + placeholder: [t] + }], + /** + * Placeholder Opacity + * @see https://tailwindcss.com/docs/placeholder-opacity + */ + "placeholder-opacity": [{ + "placeholder-opacity": [k] + }], + /** + * Text Alignment + * @see https://tailwindcss.com/docs/text-align + */ + "text-alignment": [{ + text: ["left", "center", "right", "justify", "start", "end"] + }], + /** + * Text Color + * @see https://tailwindcss.com/docs/text-color + */ + "text-color": [{ + text: [t] + }], + /** + * Text Opacity + * @see https://tailwindcss.com/docs/text-opacity + */ + "text-opacity": [{ + "text-opacity": [k] + }], + /** + * Text Decoration + * @see https://tailwindcss.com/docs/text-decoration + */ + "text-decoration": ["underline", "overline", "line-through", "no-underline"], + /** + * Text Decoration Style + * @see https://tailwindcss.com/docs/text-decoration-style + */ + "text-decoration-style": [{ + decoration: [...m(), "wavy"] + }], + /** + * Text Decoration Thickness + * @see https://tailwindcss.com/docs/text-decoration-thickness + */ + "text-decoration-thickness": [{ + decoration: ["auto", "from-font", Js, Io] + }], + /** + * Text Underline Offset + * @see https://tailwindcss.com/docs/text-underline-offset + */ + "underline-offset": [{ + "underline-offset": ["auto", Js, ur] + }], + /** + * Text Decoration Color + * @see https://tailwindcss.com/docs/text-decoration-color + */ + "text-decoration-color": [{ + decoration: [t] + }], + /** + * Text Transform + * @see https://tailwindcss.com/docs/text-transform + */ + "text-transform": ["uppercase", "lowercase", "capitalize", "normal-case"], + /** + * Text Overflow + * @see https://tailwindcss.com/docs/text-overflow + */ + "text-overflow": ["truncate", "text-ellipsis", "text-clip"], + /** + * Text Wrap + * @see https://tailwindcss.com/docs/text-wrap + */ + "text-wrap": [{ + text: ["wrap", "nowrap", "balance", "pretty"] + }], + /** + * Text Indent + * @see https://tailwindcss.com/docs/text-indent + */ + indent: [{ + indent: E() + }], + /** + * Vertical Alignment + * @see https://tailwindcss.com/docs/vertical-align + */ + "vertical-align": [{ + align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", ur] + }], + /** + * Whitespace + * @see https://tailwindcss.com/docs/whitespace + */ + whitespace: [{ + whitespace: ["normal", "nowrap", "pre", "pre-line", "pre-wrap", "break-spaces"] + }], + /** + * Word Break + * @see https://tailwindcss.com/docs/word-break + */ + break: [{ + break: ["normal", "words", "all", "keep"] + }], + /** + * Hyphens + * @see https://tailwindcss.com/docs/hyphens + */ + hyphens: [{ + hyphens: ["none", "manual", "auto"] + }], + /** + * Content + * @see https://tailwindcss.com/docs/content + */ + content: [{ + content: ["none", ur] + }], + // Backgrounds + /** + * Background Attachment + * @see https://tailwindcss.com/docs/background-attachment + */ + "bg-attachment": [{ + bg: ["fixed", "local", "scroll"] + }], + /** + * Background Clip + * @see https://tailwindcss.com/docs/background-clip + */ + "bg-clip": [{ + "bg-clip": ["border", "padding", "content", "text"] + }], + /** + * Background Opacity + * @deprecated since Tailwind CSS v3.0.0 + * @see https://tailwindcss.com/docs/background-opacity + */ + "bg-opacity": [{ + "bg-opacity": [k] + }], + /** + * Background Origin + * @see https://tailwindcss.com/docs/background-origin + */ + "bg-origin": [{ + "bg-origin": ["border", "padding", "content"] + }], + /** + * Background Position + * @see https://tailwindcss.com/docs/background-position + */ + "bg-position": [{ + bg: [...p(), see] + }], + /** + * Background Repeat + * @see https://tailwindcss.com/docs/background-repeat + */ + "bg-repeat": [{ + bg: ["no-repeat", { + repeat: ["", "x", "y", "round", "space"] + }] + }], + /** + * Background Size + * @see https://tailwindcss.com/docs/background-size + */ + "bg-size": [{ + bg: ["auto", "cover", "contain", iee] + }], + /** + * Background Image + * @see https://tailwindcss.com/docs/background-image + */ + "bg-image": [{ + bg: ["none", { + "gradient-to": ["t", "tr", "r", "br", "b", "bl", "l", "tl"] + }, aee] + }], + /** + * Background Color + * @see https://tailwindcss.com/docs/background-color + */ + "bg-color": [{ + bg: [t] + }], + /** + * Gradient Color Stops From Position + * @see https://tailwindcss.com/docs/gradient-color-stops + */ + "gradient-from-pos": [{ + from: [S] + }], + /** + * Gradient Color Stops Via Position + * @see https://tailwindcss.com/docs/gradient-color-stops + */ + "gradient-via-pos": [{ + via: [S] + }], + /** + * Gradient Color Stops To Position + * @see https://tailwindcss.com/docs/gradient-color-stops + */ + "gradient-to-pos": [{ + to: [S] + }], + /** + * Gradient Color Stops From + * @see https://tailwindcss.com/docs/gradient-color-stops + */ + "gradient-from": [{ + from: [x] + }], + /** + * Gradient Color Stops Via + * @see https://tailwindcss.com/docs/gradient-color-stops + */ + "gradient-via": [{ + via: [x] + }], + /** + * Gradient Color Stops To + * @see https://tailwindcss.com/docs/gradient-color-stops + */ + "gradient-to": [{ + to: [x] + }], + // Borders + /** + * Border Radius + * @see https://tailwindcss.com/docs/border-radius + */ + rounded: [{ + rounded: [s] + }], + /** + * Border Radius Start + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-s": [{ + "rounded-s": [s] + }], + /** + * Border Radius End + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-e": [{ + "rounded-e": [s] + }], + /** + * Border Radius Top + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-t": [{ + "rounded-t": [s] + }], + /** + * Border Radius Right + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-r": [{ + "rounded-r": [s] + }], + /** + * Border Radius Bottom + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-b": [{ + "rounded-b": [s] + }], + /** + * Border Radius Left + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-l": [{ + "rounded-l": [s] + }], + /** + * Border Radius Start Start + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-ss": [{ + "rounded-ss": [s] + }], + /** + * Border Radius Start End + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-se": [{ + "rounded-se": [s] + }], + /** + * Border Radius End End + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-ee": [{ + "rounded-ee": [s] + }], + /** + * Border Radius End Start + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-es": [{ + "rounded-es": [s] + }], + /** + * Border Radius Top Left + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-tl": [{ + "rounded-tl": [s] + }], + /** + * Border Radius Top Right + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-tr": [{ + "rounded-tr": [s] + }], + /** + * Border Radius Bottom Right + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-br": [{ + "rounded-br": [s] + }], + /** + * Border Radius Bottom Left + * @see https://tailwindcss.com/docs/border-radius + */ + "rounded-bl": [{ + "rounded-bl": [s] + }], + /** + * Border Width + * @see https://tailwindcss.com/docs/border-width + */ + "border-w": [{ + border: [a] + }], + /** + * Border Width X + * @see https://tailwindcss.com/docs/border-width + */ + "border-w-x": [{ + "border-x": [a] + }], + /** + * Border Width Y + * @see https://tailwindcss.com/docs/border-width + */ + "border-w-y": [{ + "border-y": [a] + }], + /** + * Border Width Start + * @see https://tailwindcss.com/docs/border-width + */ + "border-w-s": [{ + "border-s": [a] + }], + /** + * Border Width End + * @see https://tailwindcss.com/docs/border-width + */ + "border-w-e": [{ + "border-e": [a] + }], + /** + * Border Width Top + * @see https://tailwindcss.com/docs/border-width + */ + "border-w-t": [{ + "border-t": [a] + }], + /** + * Border Width Right + * @see https://tailwindcss.com/docs/border-width + */ + "border-w-r": [{ + "border-r": [a] + }], + /** + * Border Width Bottom + * @see https://tailwindcss.com/docs/border-width + */ + "border-w-b": [{ + "border-b": [a] + }], + /** + * Border Width Left + * @see https://tailwindcss.com/docs/border-width + */ + "border-w-l": [{ + "border-l": [a] + }], + /** + * Border Opacity + * @see https://tailwindcss.com/docs/border-opacity + */ + "border-opacity": [{ + "border-opacity": [k] + }], + /** + * Border Style + * @see https://tailwindcss.com/docs/border-style + */ + "border-style": [{ + border: [...m(), "hidden"] + }], + /** + * Divide Width X + * @see https://tailwindcss.com/docs/divide-width + */ + "divide-x": [{ + "divide-x": [a] + }], + /** + * Divide Width X Reverse + * @see https://tailwindcss.com/docs/divide-width + */ + "divide-x-reverse": ["divide-x-reverse"], + /** + * Divide Width Y + * @see https://tailwindcss.com/docs/divide-width + */ + "divide-y": [{ + "divide-y": [a] + }], + /** + * Divide Width Y Reverse + * @see https://tailwindcss.com/docs/divide-width + */ + "divide-y-reverse": ["divide-y-reverse"], + /** + * Divide Opacity + * @see https://tailwindcss.com/docs/divide-opacity + */ + "divide-opacity": [{ + "divide-opacity": [k] + }], + /** + * Divide Style + * @see https://tailwindcss.com/docs/divide-style + */ + "divide-style": [{ + divide: m() + }], + /** + * Border Color + * @see https://tailwindcss.com/docs/border-color + */ + "border-color": [{ + border: [i] + }], + /** + * Border Color X + * @see https://tailwindcss.com/docs/border-color + */ + "border-color-x": [{ + "border-x": [i] + }], + /** + * Border Color Y + * @see https://tailwindcss.com/docs/border-color + */ + "border-color-y": [{ + "border-y": [i] + }], + /** + * Border Color S + * @see https://tailwindcss.com/docs/border-color + */ + "border-color-s": [{ + "border-s": [i] + }], + /** + * Border Color E + * @see https://tailwindcss.com/docs/border-color + */ + "border-color-e": [{ + "border-e": [i] + }], + /** + * Border Color Top + * @see https://tailwindcss.com/docs/border-color + */ + "border-color-t": [{ + "border-t": [i] + }], + /** + * Border Color Right + * @see https://tailwindcss.com/docs/border-color + */ + "border-color-r": [{ + "border-r": [i] + }], + /** + * Border Color Bottom + * @see https://tailwindcss.com/docs/border-color + */ + "border-color-b": [{ + "border-b": [i] + }], + /** + * Border Color Left + * @see https://tailwindcss.com/docs/border-color + */ + "border-color-l": [{ + "border-l": [i] + }], + /** + * Divide Color + * @see https://tailwindcss.com/docs/divide-color + */ + "divide-color": [{ + divide: [i] + }], + /** + * Outline Style + * @see https://tailwindcss.com/docs/outline-style + */ + "outline-style": [{ + outline: ["", ...m()] + }], + /** + * Outline Offset + * @see https://tailwindcss.com/docs/outline-offset + */ + "outline-offset": [{ + "outline-offset": [Js, ur] + }], + /** + * Outline Width + * @see https://tailwindcss.com/docs/outline-width + */ + "outline-w": [{ + outline: [Js, Io] + }], + /** + * Outline Color + * @see https://tailwindcss.com/docs/outline-color + */ + "outline-color": [{ + outline: [t] + }], + /** + * Ring Width + * @see https://tailwindcss.com/docs/ring-width + */ + "ring-w": [{ + ring: b() + }], + /** + * Ring Width Inset + * @see https://tailwindcss.com/docs/ring-width + */ + "ring-w-inset": ["ring-inset"], + /** + * Ring Color + * @see https://tailwindcss.com/docs/ring-color + */ + "ring-color": [{ + ring: [t] + }], + /** + * Ring Opacity + * @see https://tailwindcss.com/docs/ring-opacity + */ + "ring-opacity": [{ + "ring-opacity": [k] + }], + /** + * Ring Offset Width + * @see https://tailwindcss.com/docs/ring-offset-width + */ + "ring-offset-w": [{ + "ring-offset": [Js, Io] + }], + /** + * Ring Offset Color + * @see https://tailwindcss.com/docs/ring-offset-color + */ + "ring-offset-color": [{ + "ring-offset": [t] + }], + // Effects + /** + * Box Shadow + * @see https://tailwindcss.com/docs/box-shadow + */ + shadow: [{ + shadow: ["", "inner", "none", Co, cee] + }], + /** + * Box Shadow Color + * @see https://tailwindcss.com/docs/box-shadow-color + */ + "shadow-color": [{ + shadow: [Hu] + }], + /** + * Opacity + * @see https://tailwindcss.com/docs/opacity + */ + opacity: [{ + opacity: [k] + }], + /** + * Mix Blend Mode + * @see https://tailwindcss.com/docs/mix-blend-mode + */ + "mix-blend": [{ + "mix-blend": [...w(), "plus-lighter", "plus-darker"] + }], + /** + * Background Blend Mode + * @see https://tailwindcss.com/docs/background-blend-mode + */ + "bg-blend": [{ + "bg-blend": w() + }], + // Filters + /** + * Filter + * @deprecated since Tailwind CSS v3.0.0 + * @see https://tailwindcss.com/docs/filter + */ + filter: [{ + filter: ["", "none"] + }], + /** + * Blur + * @see https://tailwindcss.com/docs/blur + */ + blur: [{ + blur: [r] + }], + /** + * Brightness + * @see https://tailwindcss.com/docs/brightness + */ + brightness: [{ + brightness: [n] + }], + /** + * Contrast + * @see https://tailwindcss.com/docs/contrast + */ + contrast: [{ + contrast: [f] + }], + /** + * Drop Shadow + * @see https://tailwindcss.com/docs/drop-shadow + */ + "drop-shadow": [{ + "drop-shadow": ["", "none", Co, ur] + }], + /** + * Grayscale + * @see https://tailwindcss.com/docs/grayscale + */ + grayscale: [{ + grayscale: [u] + }], + /** + * Hue Rotate + * @see https://tailwindcss.com/docs/hue-rotate + */ + "hue-rotate": [{ + "hue-rotate": [h] + }], + /** + * Invert + * @see https://tailwindcss.com/docs/invert + */ + invert: [{ + invert: [g] + }], + /** + * Saturate + * @see https://tailwindcss.com/docs/saturate + */ + saturate: [{ + saturate: [z] + }], + /** + * Sepia + * @see https://tailwindcss.com/docs/sepia + */ + sepia: [{ + sepia: [$] + }], + /** + * Backdrop Filter + * @deprecated since Tailwind CSS v3.0.0 + * @see https://tailwindcss.com/docs/backdrop-filter + */ + "backdrop-filter": [{ + "backdrop-filter": ["", "none"] + }], + /** + * Backdrop Blur + * @see https://tailwindcss.com/docs/backdrop-blur + */ + "backdrop-blur": [{ + "backdrop-blur": [r] + }], + /** + * Backdrop Brightness + * @see https://tailwindcss.com/docs/backdrop-brightness + */ + "backdrop-brightness": [{ + "backdrop-brightness": [n] + }], + /** + * Backdrop Contrast + * @see https://tailwindcss.com/docs/backdrop-contrast + */ + "backdrop-contrast": [{ + "backdrop-contrast": [f] + }], + /** + * Backdrop Grayscale + * @see https://tailwindcss.com/docs/backdrop-grayscale + */ + "backdrop-grayscale": [{ + "backdrop-grayscale": [u] + }], + /** + * Backdrop Hue Rotate + * @see https://tailwindcss.com/docs/backdrop-hue-rotate + */ + "backdrop-hue-rotate": [{ + "backdrop-hue-rotate": [h] + }], + /** + * Backdrop Invert + * @see https://tailwindcss.com/docs/backdrop-invert + */ + "backdrop-invert": [{ + "backdrop-invert": [g] + }], + /** + * Backdrop Opacity + * @see https://tailwindcss.com/docs/backdrop-opacity + */ + "backdrop-opacity": [{ + "backdrop-opacity": [k] + }], + /** + * Backdrop Saturate + * @see https://tailwindcss.com/docs/backdrop-saturate + */ + "backdrop-saturate": [{ + "backdrop-saturate": [z] + }], + /** + * Backdrop Sepia + * @see https://tailwindcss.com/docs/backdrop-sepia + */ + "backdrop-sepia": [{ + "backdrop-sepia": [$] + }], + // Tables + /** + * Border Collapse + * @see https://tailwindcss.com/docs/border-collapse + */ + "border-collapse": [{ + border: ["collapse", "separate"] + }], + /** + * Border Spacing + * @see https://tailwindcss.com/docs/border-spacing + */ + "border-spacing": [{ + "border-spacing": [o] + }], + /** + * Border Spacing X + * @see https://tailwindcss.com/docs/border-spacing + */ + "border-spacing-x": [{ + "border-spacing-x": [o] + }], + /** + * Border Spacing Y + * @see https://tailwindcss.com/docs/border-spacing + */ + "border-spacing-y": [{ + "border-spacing-y": [o] + }], + /** + * Table Layout + * @see https://tailwindcss.com/docs/table-layout + */ + "table-layout": [{ + table: ["auto", "fixed"] + }], + /** + * Caption Side + * @see https://tailwindcss.com/docs/caption-side + */ + caption: [{ + caption: ["top", "bottom"] + }], + // Transitions and Animation + /** + * Tranisition Property + * @see https://tailwindcss.com/docs/transition-property + */ + transition: [{ + transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", ur] + }], + /** + * Transition Duration + * @see https://tailwindcss.com/docs/transition-duration + */ + duration: [{ + duration: M() + }], + /** + * Transition Timing Function + * @see https://tailwindcss.com/docs/transition-timing-function + */ + ease: [{ + ease: ["linear", "in", "out", "in-out", ur] + }], + /** + * Transition Delay + * @see https://tailwindcss.com/docs/transition-delay + */ + delay: [{ + delay: M() + }], + /** + * Animation + * @see https://tailwindcss.com/docs/animation + */ + animate: [{ + animate: ["none", "spin", "ping", "pulse", "bounce", ur] + }], + // Transforms + /** + * Transform + * @see https://tailwindcss.com/docs/transform + */ + transform: [{ + transform: ["", "gpu", "none"] + }], + /** + * Scale + * @see https://tailwindcss.com/docs/scale + */ + scale: [{ + scale: [B] + }], + /** + * Scale X + * @see https://tailwindcss.com/docs/scale + */ + "scale-x": [{ + "scale-x": [B] + }], + /** + * Scale Y + * @see https://tailwindcss.com/docs/scale + */ + "scale-y": [{ + "scale-y": [B] + }], + /** + * Rotate + * @see https://tailwindcss.com/docs/rotate + */ + rotate: [{ + rotate: [zu, ur] + }], + /** + * Translate X + * @see https://tailwindcss.com/docs/translate + */ + "translate-x": [{ + "translate-x": [W] + }], + /** + * Translate Y + * @see https://tailwindcss.com/docs/translate + */ + "translate-y": [{ + "translate-y": [W] + }], + /** + * Skew X + * @see https://tailwindcss.com/docs/skew + */ + "skew-x": [{ + "skew-x": [U] + }], + /** + * Skew Y + * @see https://tailwindcss.com/docs/skew + */ + "skew-y": [{ + "skew-y": [U] + }], + /** + * Transform Origin + * @see https://tailwindcss.com/docs/transform-origin + */ + "transform-origin": [{ + origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", ur] + }], + // Interactivity + /** + * Accent Color + * @see https://tailwindcss.com/docs/accent-color + */ + accent: [{ + accent: ["auto", t] + }], + /** + * Appearance + * @see https://tailwindcss.com/docs/appearance + */ + appearance: [{ + appearance: ["none", "auto"] + }], + /** + * Cursor + * @see https://tailwindcss.com/docs/cursor + */ + cursor: [{ + cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", ur] + }], + /** + * Caret Color + * @see https://tailwindcss.com/docs/just-in-time-mode#caret-color-utilities + */ + "caret-color": [{ + caret: [t] + }], + /** + * Pointer Events + * @see https://tailwindcss.com/docs/pointer-events + */ + "pointer-events": [{ + "pointer-events": ["none", "auto"] + }], + /** + * Resize + * @see https://tailwindcss.com/docs/resize + */ + resize: [{ + resize: ["none", "y", "x", ""] + }], + /** + * Scroll Behavior + * @see https://tailwindcss.com/docs/scroll-behavior + */ + "scroll-behavior": [{ + scroll: ["auto", "smooth"] + }], + /** + * Scroll Margin + * @see https://tailwindcss.com/docs/scroll-margin + */ + "scroll-m": [{ + "scroll-m": E() + }], + /** + * Scroll Margin X + * @see https://tailwindcss.com/docs/scroll-margin + */ + "scroll-mx": [{ + "scroll-mx": E() + }], + /** + * Scroll Margin Y + * @see https://tailwindcss.com/docs/scroll-margin + */ + "scroll-my": [{ + "scroll-my": E() + }], + /** + * Scroll Margin Start + * @see https://tailwindcss.com/docs/scroll-margin + */ + "scroll-ms": [{ + "scroll-ms": E() + }], + /** + * Scroll Margin End + * @see https://tailwindcss.com/docs/scroll-margin + */ + "scroll-me": [{ + "scroll-me": E() + }], + /** + * Scroll Margin Top + * @see https://tailwindcss.com/docs/scroll-margin + */ + "scroll-mt": [{ + "scroll-mt": E() + }], + /** + * Scroll Margin Right + * @see https://tailwindcss.com/docs/scroll-margin + */ + "scroll-mr": [{ + "scroll-mr": E() + }], + /** + * Scroll Margin Bottom + * @see https://tailwindcss.com/docs/scroll-margin + */ + "scroll-mb": [{ + "scroll-mb": E() + }], + /** + * Scroll Margin Left + * @see https://tailwindcss.com/docs/scroll-margin + */ + "scroll-ml": [{ + "scroll-ml": E() + }], + /** + * Scroll Padding + * @see https://tailwindcss.com/docs/scroll-padding + */ + "scroll-p": [{ + "scroll-p": E() + }], + /** + * Scroll Padding X + * @see https://tailwindcss.com/docs/scroll-padding + */ + "scroll-px": [{ + "scroll-px": E() + }], + /** + * Scroll Padding Y + * @see https://tailwindcss.com/docs/scroll-padding + */ + "scroll-py": [{ + "scroll-py": E() + }], + /** + * Scroll Padding Start + * @see https://tailwindcss.com/docs/scroll-padding + */ + "scroll-ps": [{ + "scroll-ps": E() + }], + /** + * Scroll Padding End + * @see https://tailwindcss.com/docs/scroll-padding + */ + "scroll-pe": [{ + "scroll-pe": E() + }], + /** + * Scroll Padding Top + * @see https://tailwindcss.com/docs/scroll-padding + */ + "scroll-pt": [{ + "scroll-pt": E() + }], + /** + * Scroll Padding Right + * @see https://tailwindcss.com/docs/scroll-padding + */ + "scroll-pr": [{ + "scroll-pr": E() + }], + /** + * Scroll Padding Bottom + * @see https://tailwindcss.com/docs/scroll-padding + */ + "scroll-pb": [{ + "scroll-pb": E() + }], + /** + * Scroll Padding Left + * @see https://tailwindcss.com/docs/scroll-padding + */ + "scroll-pl": [{ + "scroll-pl": E() + }], + /** + * Scroll Snap Align + * @see https://tailwindcss.com/docs/scroll-snap-align + */ + "snap-align": [{ + snap: ["start", "end", "center", "align-none"] + }], + /** + * Scroll Snap Stop + * @see https://tailwindcss.com/docs/scroll-snap-stop + */ + "snap-stop": [{ + snap: ["normal", "always"] + }], + /** + * Scroll Snap Type + * @see https://tailwindcss.com/docs/scroll-snap-type + */ + "snap-type": [{ + snap: ["none", "x", "y", "both"] + }], + /** + * Scroll Snap Type Strictness + * @see https://tailwindcss.com/docs/scroll-snap-type + */ + "snap-strictness": [{ + snap: ["mandatory", "proximity"] + }], + /** + * Touch Action + * @see https://tailwindcss.com/docs/touch-action + */ + touch: [{ + touch: ["auto", "none", "manipulation"] + }], + /** + * Touch Action X + * @see https://tailwindcss.com/docs/touch-action + */ + "touch-x": [{ + "touch-pan": ["x", "left", "right"] + }], + /** + * Touch Action Y + * @see https://tailwindcss.com/docs/touch-action + */ + "touch-y": [{ + "touch-pan": ["y", "up", "down"] + }], + /** + * Touch Action Pinch Zoom + * @see https://tailwindcss.com/docs/touch-action + */ + "touch-pz": ["touch-pinch-zoom"], + /** + * User Select + * @see https://tailwindcss.com/docs/user-select + */ + select: [{ + select: ["none", "text", "all", "auto"] + }], + /** + * Will Change + * @see https://tailwindcss.com/docs/will-change + */ + "will-change": [{ + "will-change": ["auto", "scroll", "contents", "transform", ur] + }], + // SVG + /** + * Fill + * @see https://tailwindcss.com/docs/fill + */ + fill: [{ + fill: [t, "none"] + }], + /** + * Stroke Width + * @see https://tailwindcss.com/docs/stroke-width + */ + "stroke-w": [{ + stroke: [Js, Io, Tm] + }], + /** + * Stroke + * @see https://tailwindcss.com/docs/stroke + */ + stroke: [{ + stroke: [t, "none"] + }], + // Accessibility + /** + * Screen Readers + * @see https://tailwindcss.com/docs/screen-readers + */ + sr: ["sr-only", "not-sr-only"], + /** + * Forced Color Adjust + * @see https://tailwindcss.com/docs/forced-color-adjust + */ + "forced-color-adjust": [{ + "forced-color-adjust": ["auto", "none"] + }] + }, + conflictingClassGroups: { + overflow: ["overflow-x", "overflow-y"], + overscroll: ["overscroll-x", "overscroll-y"], + inset: ["inset-x", "inset-y", "start", "end", "top", "right", "bottom", "left"], + "inset-x": ["right", "left"], + "inset-y": ["top", "bottom"], + flex: ["basis", "grow", "shrink"], + gap: ["gap-x", "gap-y"], + p: ["px", "py", "ps", "pe", "pt", "pr", "pb", "pl"], + px: ["pr", "pl"], + py: ["pt", "pb"], + m: ["mx", "my", "ms", "me", "mt", "mr", "mb", "ml"], + mx: ["mr", "ml"], + my: ["mt", "mb"], + size: ["w", "h"], + "font-size": ["leading"], + "fvn-normal": ["fvn-ordinal", "fvn-slashed-zero", "fvn-figure", "fvn-spacing", "fvn-fraction"], + "fvn-ordinal": ["fvn-normal"], + "fvn-slashed-zero": ["fvn-normal"], + "fvn-figure": ["fvn-normal"], + "fvn-spacing": ["fvn-normal"], + "fvn-fraction": ["fvn-normal"], + "line-clamp": ["display", "overflow"], + rounded: ["rounded-s", "rounded-e", "rounded-t", "rounded-r", "rounded-b", "rounded-l", "rounded-ss", "rounded-se", "rounded-ee", "rounded-es", "rounded-tl", "rounded-tr", "rounded-br", "rounded-bl"], + "rounded-s": ["rounded-ss", "rounded-es"], + "rounded-e": ["rounded-se", "rounded-ee"], + "rounded-t": ["rounded-tl", "rounded-tr"], + "rounded-r": ["rounded-tr", "rounded-br"], + "rounded-b": ["rounded-br", "rounded-bl"], + "rounded-l": ["rounded-tl", "rounded-bl"], + "border-spacing": ["border-spacing-x", "border-spacing-y"], + "border-w": ["border-w-s", "border-w-e", "border-w-t", "border-w-r", "border-w-b", "border-w-l"], + "border-w-x": ["border-w-r", "border-w-l"], + "border-w-y": ["border-w-t", "border-w-b"], + "border-color": ["border-color-s", "border-color-e", "border-color-t", "border-color-r", "border-color-b", "border-color-l"], + "border-color-x": ["border-color-r", "border-color-l"], + "border-color-y": ["border-color-t", "border-color-b"], + "scroll-m": ["scroll-mx", "scroll-my", "scroll-ms", "scroll-me", "scroll-mt", "scroll-mr", "scroll-mb", "scroll-ml"], + "scroll-mx": ["scroll-mr", "scroll-ml"], + "scroll-my": ["scroll-mt", "scroll-mb"], + "scroll-p": ["scroll-px", "scroll-py", "scroll-ps", "scroll-pe", "scroll-pt", "scroll-pr", "scroll-pb", "scroll-pl"], + "scroll-px": ["scroll-pr", "scroll-pl"], + "scroll-py": ["scroll-pt", "scroll-pb"], + touch: ["touch-x", "touch-y", "touch-pz"], + "touch-x": ["touch"], + "touch-y": ["touch"], + "touch-pz": ["touch"] + }, + conflictingClassGroupModifiers: { + "font-size": ["leading"] + } + }; +}, dee = /* @__PURE__ */ GQ(hee); +function uo(...t) { + return dee(LQ(t)); +} +function o9(t) { + const { className: e } = t; + return /* @__PURE__ */ pe.jsxs("div", { className: uo("xc-flex xc-items-center xc-gap-2"), children: [ + /* @__PURE__ */ pe.jsx("hr", { className: uo("xc-flex-1 xc-border-gray-200", e) }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-shrink-0", children: t.children }), + /* @__PURE__ */ pe.jsx("hr", { className: uo("xc-flex-1 xc-border-gray-200", e) }) + ] }); +} +function pee(t) { + const { wallet: e, onClick: r } = t; + return /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center xc-justify-center xc-gap-4", children: [ + /* @__PURE__ */ pe.jsx("img", { className: "xc-rounded-md xc-h-16 xc-w-16", src: e.config?.image, alt: "" }), + /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center", children: [ + /* @__PURE__ */ pe.jsxs("p", { className: "xc-text-danger xc-mb-2 xc-text-center", children: [ + "Connect to ", + e.config?.name + ] }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-flex xc-gap-2", children: /* @__PURE__ */ pe.jsx("button", { className: "xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1", onClick: () => r(e), children: "Connect" }) }) + ] }) + ] }); +} +const gee = "https://static.codatta.io/codatta-connect/wallet-icons.svg?v=2#ton"; +function mee(t) { + const { onClick: e } = t; + function r() { + e && e(); + } + return /* @__PURE__ */ pe.jsx(o9, { className: "xc-opacity-20", children: /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-items-center xc-gap-2 xc-cursor-pointer", onClick: r, children: [ + /* @__PURE__ */ pe.jsx("span", { className: "xc-text-sm", children: "View more wallets" }), + /* @__PURE__ */ pe.jsx(SS, { size: 16 }) + ] }) }); +} +function a9(t) { + const [e, r] = Xt(""), { featuredWallets: n, initialized: i } = g0(), { onEmailConfirm: s, onSelectWallet: o, onSelectMoreWallets: a, onSelectTonConnect: f, config: u, useSingleWallet: h } = t, g = hi(() => { + const D = /[\u4e00-\u9fff]|[\u3400-\u4dbf]|[\u{20000}-\u{2a6df}]|[\u{2a700}-\u{2b73f}]|[\u{2b740}-\u{2b81f}]|[\u{2b820}-\u{2ceaf}]|[\uf900-\ufaff]|[\u3300-\u33ff]|[\ufe30-\ufe4f]/gu, k = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; + return !D.test(e) && k.test(e); + }, [e]); + function v(D) { + o(D); + } + function x(D) { + r(D.target.value); + } + async function S() { + s(e); + } + function R(D) { + D.key === "Enter" && g && S(); + } + return /* @__PURE__ */ pe.jsx(ps, { children: i && /* @__PURE__ */ pe.jsxs(pe.Fragment, { children: [ + t.header || /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-6 xc-text-xl xc-font-bold", children: "Log in or sign up" }), + n.length === 1 && h ? /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-4 xc-flex xc-max-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar", children: n.map((D) => /* @__PURE__ */ pe.jsx( + pee, + { + wallet: D, + onClick: v + }, + `feature-${D.key}` + )) }) : /* @__PURE__ */ pe.jsxs(pe.Fragment, { children: [ + /* @__PURE__ */ pe.jsxs("div", { children: [ + /* @__PURE__ */ pe.jsxs("div", { className: "xc-mb-4 xc-flex xc-max-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar", children: [ + u.showFeaturedWallets && n && n.map((D) => /* @__PURE__ */ pe.jsx( + Q7, + { + wallet: D, + onClick: v + }, + `feature-${D.key}` + )), + u.showTonConnect && /* @__PURE__ */ pe.jsx( + Sb, + { + icon: /* @__PURE__ */ pe.jsx("img", { className: "xc-h-5 xc-w-5", src: gee }), + title: "TON Connect", + onClick: f + } + ) + ] }), + u.showMoreWallets && /* @__PURE__ */ pe.jsx(mee, { onClick: a }) + ] }), + u.showEmailSignIn && (u.showFeaturedWallets || u.showTonConnect) && /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-4 xc-mt-4", children: /* @__PURE__ */ pe.jsxs(o9, { className: "xc-opacity-20", children: [ + " ", + /* @__PURE__ */ pe.jsx("span", { className: "xc-text-sm xc-opacity-20", children: "OR" }) + ] }) }), + u.showEmailSignIn && /* @__PURE__ */ pe.jsxs("div", { className: "xc-mb-4", children: [ + /* @__PURE__ */ pe.jsx("input", { className: "xc-w-full xc-bg-transparent xc-border-white xc-border xc-border-opacity-15 xc-h-10 xc-rounded-lg xc-px-3 xc-mb-3", placeholder: "Enter your email", type: "email", onChange: x, onKeyDown: R }), + /* @__PURE__ */ pe.jsx("button", { disabled: !g, className: "xc-bg-[rgb(135,93,255)] xc-text-white xc-w-full xc-rounded-lg xc-py-2 disabled:xc-bg-opacity-10 disabled:xc-text-opacity-50 disabled:xc-bg-white xc-transition-all", onClick: S, children: "Continue" }) + ] }) + ] }) + ] }) }); +} +function Ja(t) { + const { title: e } = t; + return /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-items-center xc-gap-2", children: [ + /* @__PURE__ */ pe.jsx(ZG, { onClick: t.onBack, size: 20, className: "xc-cursor-pointer" }), + /* @__PURE__ */ pe.jsx("span", { children: e }) + ] }); +} +const c9 = Xo({ + channel: "", + device: "WEB", + app: "", + inviterCode: "", + role: "C" +}); +function Pb() { + return In(c9); +} +function vee(t) { + const { config: e } = t, [r, n] = Xt(e.channel), [i, s] = Xt(e.device), [o, a] = Xt(e.app), [f, u] = Xt(e.role || "C"), [h, g] = Xt(e.inviterCode); + return Rn(() => { + n(e.channel), s(e.device), a(e.app), g(e.inviterCode), u(e.role || "C"); + }, [e]), /* @__PURE__ */ pe.jsx( + c9.Provider, + { + value: { + channel: r, + device: i, + app: o, + inviterCode: h, + role: f + }, + children: t.children + } + ); +} +var bee = Object.defineProperty, yee = Object.defineProperties, wee = Object.getOwnPropertyDescriptors, Ld = Object.getOwnPropertySymbols, u9 = Object.prototype.hasOwnProperty, f9 = Object.prototype.propertyIsEnumerable, D5 = (t, e, r) => e in t ? bee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, xee = (t, e) => { + for (var r in e || (e = {})) u9.call(e, r) && D5(t, r, e[r]); + if (Ld) for (var r of Ld(e)) f9.call(e, r) && D5(t, r, e[r]); + return t; +}, _ee = (t, e) => yee(t, wee(e)), Eee = (t, e) => { + var r = {}; + for (var n in t) u9.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); + if (t != null && Ld) for (var n of Ld(t)) e.indexOf(n) < 0 && f9.call(t, n) && (r[n] = t[n]); + return r; +}; +function See(t) { + let e = setTimeout(t, 0), r = setTimeout(t, 10), n = setTimeout(t, 50); + return [e, r, n]; +} +function Aee(t) { + let e = Jt.useRef(); + return Jt.useEffect(() => { + e.current = t; + }), e.current; +} +var Pee = 18, l9 = 40, Mee = `${l9}px`, Iee = ["[data-lastpass-icon-root]", "com-1password-button", "[data-dashlanecreated]", '[style$="2147483647 !important;"]'].join(","); +function Cee({ containerRef: t, inputRef: e, pushPasswordManagerStrategy: r, isFocused: n }) { + let [i, s] = Jt.useState(!1), [o, a] = Jt.useState(!1), [f, u] = Jt.useState(!1), h = Jt.useMemo(() => r === "none" ? !1 : (r === "increase-width" || r === "experimental-no-flickering") && i && o, [i, o, r]), g = Jt.useCallback(() => { + let v = t.current, x = e.current; + if (!v || !x || f || r === "none") return; + let S = v, R = S.getBoundingClientRect().left + S.offsetWidth, D = S.getBoundingClientRect().top + S.offsetHeight / 2, k = R - Pee, N = D; + document.querySelectorAll(Iee).length === 0 && document.elementFromPoint(k, N) === v || (s(!0), u(!0)); + }, [t, e, f, r]); + return Jt.useEffect(() => { + let v = t.current; + if (!v || r === "none") return; + function x() { + let R = window.innerWidth - v.getBoundingClientRect().right; + a(R >= l9); + } + x(); + let S = setInterval(x, 1e3); + return () => { + clearInterval(S); + }; + }, [t, r]), Jt.useEffect(() => { + let v = n || document.activeElement === e.current; + if (r === "none" || !v) return; + let x = setTimeout(g, 0), S = setTimeout(g, 2e3), R = setTimeout(g, 5e3), D = setTimeout(() => { + u(!0); + }, 6e3); + return () => { + clearTimeout(x), clearTimeout(S), clearTimeout(R), clearTimeout(D); + }; + }, [e, n, r, g]), { hasPWMBadge: i, willPushPWMBadge: h, PWM_BADGE_SPACE_WIDTH: Mee }; +} +var h9 = Jt.createContext({}), d9 = Jt.forwardRef((t, e) => { + var r = t, { value: n, onChange: i, maxLength: s, textAlign: o = "left", pattern: a, placeholder: f, inputMode: u = "numeric", onComplete: h, pushPasswordManagerStrategy: g = "increase-width", pasteTransformer: v, containerClassName: x, noScriptCSSFallback: S = Ree, render: R, children: D } = r, k = Eee(r, ["value", "onChange", "maxLength", "textAlign", "pattern", "placeholder", "inputMode", "onComplete", "pushPasswordManagerStrategy", "pasteTransformer", "containerClassName", "noScriptCSSFallback", "render", "children"]), N, z, B, $, U; + let [C, W] = Jt.useState(typeof k.defaultValue == "string" ? k.defaultValue : ""), J = n ?? C, ne = Aee(J), K = Jt.useCallback((ae) => { + i?.(ae), W(ae); + }, [i]), E = Jt.useMemo(() => a ? typeof a == "string" ? new RegExp(a) : a : null, [a]), b = Jt.useRef(null), l = Jt.useRef(null), p = Jt.useRef({ value: J, onChange: K, isIOS: typeof window < "u" && ((z = (N = window?.CSS) == null ? void 0 : N.supports) == null ? void 0 : z.call(N, "-webkit-touch-callout", "none")) }), m = Jt.useRef({ prev: [(B = b.current) == null ? void 0 : B.selectionStart, ($ = b.current) == null ? void 0 : $.selectionEnd, (U = b.current) == null ? void 0 : U.selectionDirection] }); + Jt.useImperativeHandle(e, () => b.current, []), Jt.useEffect(() => { + let ae = b.current, fe = l.current; + if (!ae || !fe) return; + p.current.value !== ae.value && p.current.onChange(ae.value), m.current.prev = [ae.selectionStart, ae.selectionEnd, ae.selectionDirection]; + function be() { + if (document.activeElement !== ae) { + I(null), ce(null); + return; + } + let Re = ae.selectionStart, $e = ae.selectionEnd, Me = ae.selectionDirection, Oe = ae.maxLength, ze = ae.value, De = m.current.prev, je = -1, Ue = -1, _e; + if (ze.length !== 0 && Re !== null && $e !== null) { + let rt = Re === $e, nt = Re === ze.length && ze.length < Oe; + if (rt && !nt) { + let Ge = Re; + if (Ge === 0) je = 0, Ue = 1, _e = "forward"; + else if (Ge === Oe) je = Ge - 1, Ue = Ge, _e = "backward"; + else if (Oe > 1 && ze.length > 1) { + let ht = 0; + if (De[0] !== null && De[1] !== null) { + _e = Ge < De[1] ? "backward" : "forward"; + let lt = De[0] === De[1] && De[0] < Oe; + _e === "backward" && !lt && (ht = -1); + } + je = ht + Ge, Ue = ht + Ge + 1; + } + } + je !== -1 && Ue !== -1 && je !== Ue && b.current.setSelectionRange(je, Ue, _e); + } + let Ze = je !== -1 ? je : Re, ot = Ue !== -1 ? Ue : $e, ke = _e ?? Me; + I(Ze), ce(ot), m.current.prev = [Ze, ot, ke]; + } + if (document.addEventListener("selectionchange", be, { capture: !0 }), be(), document.activeElement === ae && y(!0), !document.getElementById("input-otp-style")) { + let Re = document.createElement("style"); + if (Re.id = "input-otp-style", document.head.appendChild(Re), Re.sheet) { + let $e = "background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;"; + Wu(Re.sheet, "[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"), Wu(Re.sheet, `[data-input-otp]:autofill { ${$e} }`), Wu(Re.sheet, `[data-input-otp]:-webkit-autofill { ${$e} }`), Wu(Re.sheet, "@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"), Wu(Re.sheet, "[data-input-otp] + * { pointer-events: all !important; }"); + } + } + let Ae = () => { + fe && fe.style.setProperty("--root-height", `${ae.clientHeight}px`); + }; + Ae(); + let Te = new ResizeObserver(Ae); + return Te.observe(ae), () => { + document.removeEventListener("selectionchange", be, { capture: !0 }), Te.disconnect(); + }; + }, []); + let [w, P] = Jt.useState(!1), [_, y] = Jt.useState(!1), [M, I] = Jt.useState(null), [q, ce] = Jt.useState(null); + Jt.useEffect(() => { + See(() => { + var ae, fe, be, Ae; + (ae = b.current) == null || ae.dispatchEvent(new Event("input")); + let Te = (fe = b.current) == null ? void 0 : fe.selectionStart, Re = (be = b.current) == null ? void 0 : be.selectionEnd, $e = (Ae = b.current) == null ? void 0 : Ae.selectionDirection; + Te !== null && Re !== null && (I(Te), ce(Re), m.current.prev = [Te, Re, $e]); + }); + }, [J, _]), Jt.useEffect(() => { + ne !== void 0 && J !== ne && ne.length < s && J.length === s && h?.(J); + }, [s, h, ne, J]); + let L = Cee({ containerRef: l, inputRef: b, pushPasswordManagerStrategy: g, isFocused: _ }), oe = Jt.useCallback((ae) => { + let fe = ae.currentTarget.value.slice(0, s); + if (fe.length > 0 && E && !E.test(fe)) { + ae.preventDefault(); + return; + } + typeof ne == "string" && fe.length < ne.length && document.dispatchEvent(new Event("selectionchange")), K(fe); + }, [s, K, ne, E]), Q = Jt.useCallback(() => { + var ae; + if (b.current) { + let fe = Math.min(b.current.value.length, s - 1), be = b.current.value.length; + (ae = b.current) == null || ae.setSelectionRange(fe, be), I(fe), ce(be); + } + y(!0); + }, [s]), X = Jt.useCallback((ae) => { + var fe, be; + let Ae = b.current; + if (!v && (!p.current.isIOS || !ae.clipboardData || !Ae)) return; + let Te = ae.clipboardData.getData("text/plain"), Re = v ? v(Te) : Te; + console.log({ _content: Te, content: Re }), ae.preventDefault(); + let $e = (fe = b.current) == null ? void 0 : fe.selectionStart, Me = (be = b.current) == null ? void 0 : be.selectionEnd, Oe = ($e !== Me ? J.slice(0, $e) + Re + J.slice(Me) : J.slice(0, $e) + Re + J.slice($e)).slice(0, s); + if (Oe.length > 0 && E && !E.test(Oe)) return; + Ae.value = Oe, K(Oe); + let ze = Math.min(Oe.length, s - 1), De = Oe.length; + Ae.setSelectionRange(ze, De), I(ze), ce(De); + }, [s, K, E, J]), ee = Jt.useMemo(() => ({ position: "relative", cursor: k.disabled ? "default" : "text", userSelect: "none", WebkitUserSelect: "none", pointerEvents: "none" }), [k.disabled]), O = Jt.useMemo(() => ({ position: "absolute", inset: 0, width: L.willPushPWMBadge ? `calc(100% + ${L.PWM_BADGE_SPACE_WIDTH})` : "100%", clipPath: L.willPushPWMBadge ? `inset(0 ${L.PWM_BADGE_SPACE_WIDTH} 0 0)` : void 0, height: "100%", display: "flex", textAlign: o, opacity: "1", color: "transparent", pointerEvents: "all", background: "transparent", caretColor: "transparent", border: "0 solid transparent", outline: "0 solid transparent", boxShadow: "none", lineHeight: "1", letterSpacing: "-.5em", fontSize: "var(--root-height)", fontFamily: "monospace", fontVariantNumeric: "tabular-nums" }), [L.PWM_BADGE_SPACE_WIDTH, L.willPushPWMBadge, o]), Z = Jt.useMemo(() => Jt.createElement("input", _ee(xee({ autoComplete: k.autoComplete || "one-time-code" }, k), { "data-input-otp": !0, "data-input-otp-placeholder-shown": J.length === 0 || void 0, "data-input-otp-mss": M, "data-input-otp-mse": q, inputMode: u, pattern: E?.source, "aria-placeholder": f, style: O, maxLength: s, value: J, ref: b, onPaste: (ae) => { + var fe; + X(ae), (fe = k.onPaste) == null || fe.call(k, ae); + }, onChange: oe, onMouseOver: (ae) => { + var fe; + P(!0), (fe = k.onMouseOver) == null || fe.call(k, ae); + }, onMouseLeave: (ae) => { + var fe; + P(!1), (fe = k.onMouseLeave) == null || fe.call(k, ae); + }, onFocus: (ae) => { + var fe; + Q(), (fe = k.onFocus) == null || fe.call(k, ae); + }, onBlur: (ae) => { + var fe; + y(!1), (fe = k.onBlur) == null || fe.call(k, ae); + } })), [oe, Q, X, u, O, s, q, M, k, E?.source, J]), re = Jt.useMemo(() => ({ slots: Array.from({ length: s }).map((ae, fe) => { + var be; + let Ae = _ && M !== null && q !== null && (M === q && fe === M || fe >= M && fe < q), Te = J[fe] !== void 0 ? J[fe] : null, Re = J[0] !== void 0 ? null : (be = f?.[fe]) != null ? be : null; + return { char: Te, placeholderChar: Re, isActive: Ae, hasFakeCaret: Ae && Te === null }; + }), isFocused: _, isHovering: !k.disabled && w }), [_, w, s, q, M, k.disabled, J]), he = Jt.useMemo(() => R ? R(re) : Jt.createElement(h9.Provider, { value: re }, D), [D, re, R]); + return Jt.createElement(Jt.Fragment, null, S !== null && Jt.createElement("noscript", null, Jt.createElement("style", null, S)), Jt.createElement("div", { ref: l, "data-input-otp-container": !0, style: ee, className: x }, he, Jt.createElement("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" } }, Z))); +}); +d9.displayName = "Input"; +function Wu(t, e) { + try { + t.insertRule(e); + } catch { + console.error("input-otp could not insert CSS rule:", e); + } +} +var Ree = ` +[data-input-otp] { + --nojs-bg: white !important; + --nojs-fg: black !important; + + background-color: var(--nojs-bg) !important; + color: var(--nojs-fg) !important; + caret-color: var(--nojs-fg) !important; + letter-spacing: .25em !important; + text-align: center !important; + border: 1px solid var(--nojs-fg) !important; + border-radius: 4px !important; + width: 100% !important; +} +@media (prefers-color-scheme: dark) { + [data-input-otp] { + --nojs-bg: black !important; + --nojs-fg: white !important; + } +}`; +const p9 = Jt.forwardRef(({ className: t, containerClassName: e, ...r }, n) => /* @__PURE__ */ pe.jsx( + d9, + { + ref: n, + containerClassName: uo( + "xc-flex xc-items-center xc-gap-2 xc-has-[:disabled]:opacity-50", + e + ), + className: uo("disabled:xc-cursor-not-allowed", t), + ...r + } +)); +p9.displayName = "InputOTP"; +const g9 = Jt.forwardRef(({ className: t, ...e }, r) => /* @__PURE__ */ pe.jsx("div", { ref: r, className: uo("xc-flex xc-items-center", t), ...e })); +g9.displayName = "InputOTPGroup"; +const xa = Jt.forwardRef(({ index: t, className: e, ...r }, n) => { + const i = Jt.useContext(h9), { char: s, hasFakeCaret: o, isActive: a } = i.slots[t]; + return /* @__PURE__ */ pe.jsxs( + "div", + { + ref: n, + className: uo( + "xc-relative xc-rounded-xl xc-text-2xl xc-flex xc-h-12 xc-w-12 xc-items-center xc-justify-center xc-border xc-border-white xc-border-opacity-20 xc-transition-all", + a && "xc-z-10 xc-ring-2 xc-ring-ring xc-ring-[rgb(135,93,255)] xc-ring-offset-background", + e + ), + ...r, + children: [ + s, + o && /* @__PURE__ */ pe.jsx("div", { className: "xc-pointer-events-none xc-absolute xc-inset-0 xc-flex xc-items-center xc-justify-center", children: /* @__PURE__ */ pe.jsx("div", { className: "xc-h-4 xc-w-px xc-animate-caret-blink xc-bg-foreground xc-duration-1000" }) }) + ] + } + ); +}); +xa.displayName = "InputOTPSlot"; +function Tee(t) { + const { spinning: e, children: r, className: n } = t; + return /* @__PURE__ */ pe.jsxs("div", { className: "xc-inline-block xc-relative", children: [ + r, + e && /* @__PURE__ */ pe.jsx("div", { className: uo("xc-absolute xc-top-0 xc-left-0 xc-w-full xc-h-full xc-bg-black xc-bg-opacity-10 xc-flex xc-items-center xc-justify-center", n), children: /* @__PURE__ */ pe.jsx(ja, { className: "xc-animate-spin" }) }) + ] }); +} +function m9(t) { + const { email: e } = t, [r, n] = Xt(0), [i, s] = Xt(!1), [o, a] = Xt(""); + async function f() { + n(60); + const h = setInterval(() => { + n((g) => g === 0 ? (clearInterval(h), 0) : g - 1); + }, 1e3); + } + async function u(h) { + if (a(""), !(h.length < 6)) { + s(!0); + try { + await t.onInputCode(e, h); + } catch (g) { + a(g.message); + } + s(!1); + } + } + return Rn(() => { + f(); + }, []), /* @__PURE__ */ pe.jsxs(ps, { children: [ + /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-12", children: [ + /* @__PURE__ */ pe.jsx(iY, { className: "xc-mb-4", size: 60 }), + /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-8 xc-h-16", children: [ + /* @__PURE__ */ pe.jsx("p", { className: "xc-text-lg xc-mb-1", children: "We’ve sent a verification code to" }), + /* @__PURE__ */ pe.jsx("p", { className: "xc-font-bold xc-text-center", children: e }) + ] }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-2 xc-h-12", children: /* @__PURE__ */ pe.jsx(Tee, { spinning: i, className: "xc-rounded-xl", children: /* @__PURE__ */ pe.jsx(p9, { maxLength: 6, onChange: u, disabled: i, className: "disabled:xc-opacity-20", children: /* @__PURE__ */ pe.jsx(g9, { children: /* @__PURE__ */ pe.jsxs("div", { className: uo("xc-flex xc-gap-2", i ? "xc-opacity-20" : ""), children: [ + /* @__PURE__ */ pe.jsx(xa, { index: 0 }), + /* @__PURE__ */ pe.jsx(xa, { index: 1 }), + /* @__PURE__ */ pe.jsx(xa, { index: 2 }), + /* @__PURE__ */ pe.jsx(xa, { index: 3 }), + /* @__PURE__ */ pe.jsx(xa, { index: 4 }), + /* @__PURE__ */ pe.jsx(xa, { index: 5 }) + ] }) }) }) }) }), + o && /* @__PURE__ */ pe.jsx("div", { className: "xc-text-[#ff0000] xc-text-center", children: /* @__PURE__ */ pe.jsx("p", { children: o }) }) + ] }), + /* @__PURE__ */ pe.jsxs("div", { className: "xc-text-center xc-text-sm xc-text-gray-400", children: [ + "Not get it? ", + r ? `Resend in ${r}s` : /* @__PURE__ */ pe.jsx("button", { id: "sendCodeButton", onClick: t.onResendCode, children: "Send again" }) + ] }), + /* @__PURE__ */ pe.jsx("div", { id: "captcha-element" }) + ] }); +} +function v9(t) { + const { email: e } = t, [r, n] = Xt(!1), [i, s] = Xt(""), o = hi(() => `xn-btn-${(/* @__PURE__ */ new Date()).getTime()}`, [e]); + async function a(v, x) { + n(!0), s(""), await Qo.getEmailCode({ account_type: "email", email: v }, x), n(!1); + } + async function f(v) { + try { + return await a(e, JSON.stringify(v)), { captchaResult: !0, bizResult: !0 }; + } catch (x) { + return s(x.message), { captchaResult: !1, bizResult: !1 }; + } + } + async function u(v) { + v && t.onCodeSend(); + } + const h = Kn(); + function g(v) { + h.current = v; + } + return Rn(() => { + if (e) + return window.initAliyunCaptcha({ + SceneId: "tqyu8129d", + prefix: "1mfsn5f", + mode: "popup", + element: "#captcha-element", + button: `#${o}`, + captchaVerifyCallback: f, + onBizResultCallback: u, + getInstance: g, + slideStyle: { + width: 360, + height: 40 + }, + language: "en", + region: "cn" + }), () => { + document.getElementById("aliyunCaptcha-mask")?.remove(), document.getElementById("aliyunCaptcha-window-popup")?.remove(); + }; + }, [e]), /* @__PURE__ */ pe.jsxs(ps, { children: [ + /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center xc-justify-center xc-mb-12", children: [ + /* @__PURE__ */ pe.jsx(sY, { className: "xc-mb-4", size: 60 }), + /* @__PURE__ */ pe.jsx("button", { className: "xc-border xc-rounded-full xc-bg-white xc-text-black xc-px-8 xc-py-2", id: o, children: r ? /* @__PURE__ */ pe.jsx(ja, { className: "xc-animate-spin" }) : "I'm not a robot" }) + ] }), + i && /* @__PURE__ */ pe.jsx("div", { className: "xc-text-[#ff0000] xc-text-center", children: /* @__PURE__ */ pe.jsx("p", { children: i }) }) + ] }); +} +function Dee(t) { + const { email: e } = t, r = Pb(), [n, i] = Xt("captcha"); + async function s(o, a) { + const f = await Qo.emailLogin({ + account_type: "email", + connector: "codatta_email", + account_enum: "C", + email_code: a, + email: o, + inviter_code: r.inviterCode, + source: { + device: r.device, + channel: r.channel, + app: r.app + } + }); + t.onLogin(f.data); + } + return /* @__PURE__ */ pe.jsxs(ps, { children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-12", children: /* @__PURE__ */ pe.jsx(Ja, { title: "Sign in with email", onBack: t.onBack }) }), + n === "captcha" && /* @__PURE__ */ pe.jsx(v9, { email: e, onCodeSend: () => i("verify-email") }), + n === "verify-email" && /* @__PURE__ */ pe.jsx(m9, { email: e, onInputCode: s, onResendCode: () => i("captcha") }) + ] }); +} +var nd = { exports: {} }, Oee = nd.exports, O5; +function Nee() { + return O5 || (O5 = 1, (function(t, e) { + (function(r, n) { + t.exports = n(); + })(Oee, (() => (() => { + var r = { 873: (o, a) => { + var f, u, h = (function() { + var g = function(l, p) { + var m = l, w = k[p], P = null, _ = 0, y = null, M = [], I = {}, q = function(re, he) { + P = (function(ae) { + for (var fe = new Array(ae), be = 0; be < ae; be += 1) { + fe[be] = new Array(ae); + for (var Ae = 0; Ae < ae; Ae += 1) fe[be][Ae] = null; + } + return fe; + })(_ = 4 * m + 17), ce(0, 0), ce(_ - 7, 0), ce(0, _ - 7), oe(), L(), X(re, he), m >= 7 && Q(re), y == null && (y = O(m, w, M)), ee(y, he); + }, ce = function(re, he) { + for (var ae = -1; ae <= 7; ae += 1) if (!(re + ae <= -1 || _ <= re + ae)) for (var fe = -1; fe <= 7; fe += 1) he + fe <= -1 || _ <= he + fe || (P[re + ae][he + fe] = 0 <= ae && ae <= 6 && (fe == 0 || fe == 6) || 0 <= fe && fe <= 6 && (ae == 0 || ae == 6) || 2 <= ae && ae <= 4 && 2 <= fe && fe <= 4); + }, L = function() { + for (var re = 8; re < _ - 8; re += 1) P[re][6] == null && (P[re][6] = re % 2 == 0); + for (var he = 8; he < _ - 8; he += 1) P[6][he] == null && (P[6][he] = he % 2 == 0); + }, oe = function() { + for (var re = N.getPatternPosition(m), he = 0; he < re.length; he += 1) for (var ae = 0; ae < re.length; ae += 1) { + var fe = re[he], be = re[ae]; + if (P[fe][be] == null) for (var Ae = -2; Ae <= 2; Ae += 1) for (var Te = -2; Te <= 2; Te += 1) P[fe + Ae][be + Te] = Ae == -2 || Ae == 2 || Te == -2 || Te == 2 || Ae == 0 && Te == 0; + } + }, Q = function(re) { + for (var he = N.getBCHTypeNumber(m), ae = 0; ae < 18; ae += 1) { + var fe = !re && (he >> ae & 1) == 1; + P[Math.floor(ae / 3)][ae % 3 + _ - 8 - 3] = fe; + } + for (ae = 0; ae < 18; ae += 1) fe = !re && (he >> ae & 1) == 1, P[ae % 3 + _ - 8 - 3][Math.floor(ae / 3)] = fe; + }, X = function(re, he) { + for (var ae = w << 3 | he, fe = N.getBCHTypeInfo(ae), be = 0; be < 15; be += 1) { + var Ae = !re && (fe >> be & 1) == 1; + be < 6 ? P[be][8] = Ae : be < 8 ? P[be + 1][8] = Ae : P[_ - 15 + be][8] = Ae; + } + for (be = 0; be < 15; be += 1) Ae = !re && (fe >> be & 1) == 1, be < 8 ? P[8][_ - be - 1] = Ae : be < 9 ? P[8][15 - be - 1 + 1] = Ae : P[8][15 - be - 1] = Ae; + P[_ - 8][8] = !re; + }, ee = function(re, he) { + for (var ae = -1, fe = _ - 1, be = 7, Ae = 0, Te = N.getMaskFunction(he), Re = _ - 1; Re > 0; Re -= 2) for (Re == 6 && (Re -= 1); ; ) { + for (var $e = 0; $e < 2; $e += 1) if (P[fe][Re - $e] == null) { + var Me = !1; + Ae < re.length && (Me = (re[Ae] >>> be & 1) == 1), Te(fe, Re - $e) && (Me = !Me), P[fe][Re - $e] = Me, (be -= 1) == -1 && (Ae += 1, be = 7); + } + if ((fe += ae) < 0 || _ <= fe) { + fe -= ae, ae = -ae; + break; + } + } + }, O = function(re, he, ae) { + for (var fe = $.getRSBlocks(re, he), be = U(), Ae = 0; Ae < ae.length; Ae += 1) { + var Te = ae[Ae]; + be.put(Te.getMode(), 4), be.put(Te.getLength(), N.getLengthInBits(Te.getMode(), re)), Te.write(be); + } + var Re = 0; + for (Ae = 0; Ae < fe.length; Ae += 1) Re += fe[Ae].dataCount; + if (be.getLengthInBits() > 8 * Re) throw "code length overflow. (" + be.getLengthInBits() + ">" + 8 * Re + ")"; + for (be.getLengthInBits() + 4 <= 8 * Re && be.put(0, 4); be.getLengthInBits() % 8 != 0; ) be.putBit(!1); + for (; !(be.getLengthInBits() >= 8 * Re || (be.put(236, 8), be.getLengthInBits() >= 8 * Re)); ) be.put(17, 8); + return (function($e, Me) { + for (var Oe = 0, ze = 0, De = 0, je = new Array(Me.length), Ue = new Array(Me.length), _e = 0; _e < Me.length; _e += 1) { + var Ze = Me[_e].dataCount, ot = Me[_e].totalCount - Ze; + ze = Math.max(ze, Ze), De = Math.max(De, ot), je[_e] = new Array(Ze); + for (var ke = 0; ke < je[_e].length; ke += 1) je[_e][ke] = 255 & $e.getBuffer()[ke + Oe]; + Oe += Ze; + var rt = N.getErrorCorrectPolynomial(ot), nt = B(je[_e], rt.getLength() - 1).mod(rt); + for (Ue[_e] = new Array(rt.getLength() - 1), ke = 0; ke < Ue[_e].length; ke += 1) { + var Ge = ke + nt.getLength() - Ue[_e].length; + Ue[_e][ke] = Ge >= 0 ? nt.getAt(Ge) : 0; + } + } + var ht = 0; + for (ke = 0; ke < Me.length; ke += 1) ht += Me[ke].totalCount; + var lt = new Array(ht), ct = 0; + for (ke = 0; ke < ze; ke += 1) for (_e = 0; _e < Me.length; _e += 1) ke < je[_e].length && (lt[ct] = je[_e][ke], ct += 1); + for (ke = 0; ke < De; ke += 1) for (_e = 0; _e < Me.length; _e += 1) ke < Ue[_e].length && (lt[ct] = Ue[_e][ke], ct += 1); + return lt; + })(be, fe); + }; + I.addData = function(re, he) { + var ae = null; + switch (he = he || "Byte") { + case "Numeric": + ae = C(re); + break; + case "Alphanumeric": + ae = W(re); + break; + case "Byte": + ae = J(re); + break; + case "Kanji": + ae = ne(re); + break; + default: + throw "mode:" + he; + } + M.push(ae), y = null; + }, I.isDark = function(re, he) { + if (re < 0 || _ <= re || he < 0 || _ <= he) throw re + "," + he; + return P[re][he]; + }, I.getModuleCount = function() { + return _; + }, I.make = function() { + if (m < 1) { + for (var re = 1; re < 40; re++) { + for (var he = $.getRSBlocks(re, w), ae = U(), fe = 0; fe < M.length; fe++) { + var be = M[fe]; + ae.put(be.getMode(), 4), ae.put(be.getLength(), N.getLengthInBits(be.getMode(), re)), be.write(ae); + } + var Ae = 0; + for (fe = 0; fe < he.length; fe++) Ae += he[fe].dataCount; + if (ae.getLengthInBits() <= 8 * Ae) break; + } + m = re; + } + q(!1, (function() { + for (var Te = 0, Re = 0, $e = 0; $e < 8; $e += 1) { + q(!0, $e); + var Me = N.getLostPoint(I); + ($e == 0 || Te > Me) && (Te = Me, Re = $e); + } + return Re; + })()); + }, I.createTableTag = function(re, he) { + re = re || 2; + var ae = ""; + ae += '
"; + }, I.createSvgTag = function(re, he, ae, fe) { + var be = {}; + typeof arguments[0] == "object" && (re = (be = arguments[0]).cellSize, he = be.margin, ae = be.alt, fe = be.title), re = re || 2, he = he === void 0 ? 4 * re : he, (ae = typeof ae == "string" ? { text: ae } : ae || {}).text = ae.text || null, ae.id = ae.text ? ae.id || "qrcode-description" : null, (fe = typeof fe == "string" ? { text: fe } : fe || {}).text = fe.text || null, fe.id = fe.text ? fe.id || "qrcode-title" : null; + var Ae, Te, Re, $e, Me = I.getModuleCount() * re + 2 * he, Oe = ""; + for ($e = "l" + re + ",0 0," + re + " -" + re + ",0 0,-" + re + "z ", Oe += '' + Z(fe.text) + "" : "", Oe += ae.text ? '' + Z(ae.text) + "" : "", Oe += '', Oe += '"; + }, I.createDataURL = function(re, he) { + re = re || 2, he = he === void 0 ? 4 * re : he; + var ae = I.getModuleCount() * re + 2 * he, fe = he, be = ae - he; + return b(ae, ae, (function(Ae, Te) { + if (fe <= Ae && Ae < be && fe <= Te && Te < be) { + var Re = Math.floor((Ae - fe) / re), $e = Math.floor((Te - fe) / re); + return I.isDark($e, Re) ? 0 : 1; + } + return 1; + })); + }, I.createImgTag = function(re, he, ae) { + re = re || 2, he = he === void 0 ? 4 * re : he; + var fe = I.getModuleCount() * re + 2 * he, be = ""; + return be += ""; + }; + var Z = function(re) { + for (var he = "", ae = 0; ae < re.length; ae += 1) { + var fe = re.charAt(ae); + switch (fe) { + case "<": + he += "<"; + break; + case ">": + he += ">"; + break; + case "&": + he += "&"; + break; + case '"': + he += """; + break; + default: + he += fe; + } + } + return he; + }; + return I.createASCII = function(re, he) { + if ((re = re || 1) < 2) return (function(je) { + je = je === void 0 ? 2 : je; + var Ue, _e, Ze, ot, ke, rt = 1 * I.getModuleCount() + 2 * je, nt = je, Ge = rt - je, ht = { "██": "█", "█ ": "▀", " █": "▄", " ": " " }, lt = { "██": "▀", "█ ": "▀", " █": " ", " ": " " }, ct = ""; + for (Ue = 0; Ue < rt; Ue += 2) { + for (Ze = Math.floor((Ue - nt) / 1), ot = Math.floor((Ue + 1 - nt) / 1), _e = 0; _e < rt; _e += 1) ke = "█", nt <= _e && _e < Ge && nt <= Ue && Ue < Ge && I.isDark(Ze, Math.floor((_e - nt) / 1)) && (ke = " "), nt <= _e && _e < Ge && nt <= Ue + 1 && Ue + 1 < Ge && I.isDark(ot, Math.floor((_e - nt) / 1)) ? ke += " " : ke += "█", ct += je < 1 && Ue + 1 >= Ge ? lt[ke] : ht[ke]; + ct += ` +`; + } + return rt % 2 && je > 0 ? ct.substring(0, ct.length - rt - 1) + Array(rt + 1).join("▀") : ct.substring(0, ct.length - 1); + })(he); + re -= 1, he = he === void 0 ? 2 * re : he; + var ae, fe, be, Ae, Te = I.getModuleCount() * re + 2 * he, Re = he, $e = Te - he, Me = Array(re + 1).join("██"), Oe = Array(re + 1).join(" "), ze = "", De = ""; + for (ae = 0; ae < Te; ae += 1) { + for (be = Math.floor((ae - Re) / re), De = "", fe = 0; fe < Te; fe += 1) Ae = 1, Re <= fe && fe < $e && Re <= ae && ae < $e && I.isDark(be, Math.floor((fe - Re) / re)) && (Ae = 0), De += Ae ? Me : Oe; + for (be = 0; be < re; be += 1) ze += De + ` +`; + } + return ze.substring(0, ze.length - 1); + }, I.renderTo2dContext = function(re, he) { + he = he || 2; + for (var ae = I.getModuleCount(), fe = 0; fe < ae; fe++) for (var be = 0; be < ae; be++) re.fillStyle = I.isDark(fe, be) ? "black" : "white", re.fillRect(fe * he, be * he, he, he); + }, I; + }; + g.stringToBytes = (g.stringToBytesFuncs = { default: function(l) { + for (var p = [], m = 0; m < l.length; m += 1) { + var w = l.charCodeAt(m); + p.push(255 & w); + } + return p; + } }).default, g.createStringToBytes = function(l, p) { + var m = (function() { + for (var P = E(l), _ = function() { + var L = P.read(); + if (L == -1) throw "eof"; + return L; + }, y = 0, M = {}; ; ) { + var I = P.read(); + if (I == -1) break; + var q = _(), ce = _() << 8 | _(); + M[String.fromCharCode(I << 8 | q)] = ce, y += 1; + } + if (y != p) throw y + " != " + p; + return M; + })(), w = 63; + return function(P) { + for (var _ = [], y = 0; y < P.length; y += 1) { + var M = P.charCodeAt(y); + if (M < 128) _.push(M); + else { + var I = m[P.charAt(y)]; + typeof I == "number" ? (255 & I) == I ? _.push(I) : (_.push(I >>> 8), _.push(255 & I)) : _.push(w); + } + } + return _; + }; + }; + var v, x, S, R, D, k = { L: 1, M: 0, Q: 3, H: 2 }, N = (v = [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50], [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], [6, 26, 48, 70], [6, 26, 50, 74], [6, 30, 54, 78], [6, 30, 56, 82], [6, 30, 58, 86], [6, 34, 62, 90], [6, 28, 50, 72, 94], [6, 26, 50, 74, 98], [6, 30, 54, 78, 102], [6, 28, 54, 80, 106], [6, 32, 58, 84, 110], [6, 30, 58, 86, 114], [6, 34, 62, 90, 118], [6, 26, 50, 74, 98, 122], [6, 30, 54, 78, 102, 126], [6, 26, 52, 78, 104, 130], [6, 30, 56, 82, 108, 134], [6, 34, 60, 86, 112, 138], [6, 30, 58, 86, 114, 142], [6, 34, 62, 90, 118, 146], [6, 30, 54, 78, 102, 126, 150], [6, 24, 50, 76, 102, 128, 154], [6, 28, 54, 80, 106, 132, 158], [6, 32, 58, 84, 110, 136, 162], [6, 26, 54, 82, 110, 138, 166], [6, 30, 58, 86, 114, 142, 170]], x = 1335, S = 7973, D = function(l) { + for (var p = 0; l != 0; ) p += 1, l >>>= 1; + return p; + }, (R = {}).getBCHTypeInfo = function(l) { + for (var p = l << 10; D(p) - D(x) >= 0; ) p ^= x << D(p) - D(x); + return 21522 ^ (l << 10 | p); + }, R.getBCHTypeNumber = function(l) { + for (var p = l << 12; D(p) - D(S) >= 0; ) p ^= S << D(p) - D(S); + return l << 12 | p; + }, R.getPatternPosition = function(l) { + return v[l - 1]; + }, R.getMaskFunction = function(l) { + switch (l) { + case 0: + return function(p, m) { + return (p + m) % 2 == 0; + }; + case 1: + return function(p, m) { + return p % 2 == 0; + }; + case 2: + return function(p, m) { + return m % 3 == 0; + }; + case 3: + return function(p, m) { + return (p + m) % 3 == 0; + }; + case 4: + return function(p, m) { + return (Math.floor(p / 2) + Math.floor(m / 3)) % 2 == 0; + }; + case 5: + return function(p, m) { + return p * m % 2 + p * m % 3 == 0; + }; + case 6: + return function(p, m) { + return (p * m % 2 + p * m % 3) % 2 == 0; + }; + case 7: + return function(p, m) { + return (p * m % 3 + (p + m) % 2) % 2 == 0; + }; + default: + throw "bad maskPattern:" + l; + } + }, R.getErrorCorrectPolynomial = function(l) { + for (var p = B([1], 0), m = 0; m < l; m += 1) p = p.multiply(B([1, z.gexp(m)], 0)); + return p; + }, R.getLengthInBits = function(l, p) { + if (1 <= p && p < 10) switch (l) { + case 1: + return 10; + case 2: + return 9; + case 4: + case 8: + return 8; + default: + throw "mode:" + l; + } + else if (p < 27) switch (l) { + case 1: + return 12; + case 2: + return 11; + case 4: + return 16; + case 8: + return 10; + default: + throw "mode:" + l; + } + else { + if (!(p < 41)) throw "type:" + p; + switch (l) { + case 1: + return 14; + case 2: + return 13; + case 4: + return 16; + case 8: + return 12; + default: + throw "mode:" + l; + } + } + }, R.getLostPoint = function(l) { + for (var p = l.getModuleCount(), m = 0, w = 0; w < p; w += 1) for (var P = 0; P < p; P += 1) { + for (var _ = 0, y = l.isDark(w, P), M = -1; M <= 1; M += 1) if (!(w + M < 0 || p <= w + M)) for (var I = -1; I <= 1; I += 1) P + I < 0 || p <= P + I || M == 0 && I == 0 || y == l.isDark(w + M, P + I) && (_ += 1); + _ > 5 && (m += 3 + _ - 5); + } + for (w = 0; w < p - 1; w += 1) for (P = 0; P < p - 1; P += 1) { + var q = 0; + l.isDark(w, P) && (q += 1), l.isDark(w + 1, P) && (q += 1), l.isDark(w, P + 1) && (q += 1), l.isDark(w + 1, P + 1) && (q += 1), q != 0 && q != 4 || (m += 3); + } + for (w = 0; w < p; w += 1) for (P = 0; P < p - 6; P += 1) l.isDark(w, P) && !l.isDark(w, P + 1) && l.isDark(w, P + 2) && l.isDark(w, P + 3) && l.isDark(w, P + 4) && !l.isDark(w, P + 5) && l.isDark(w, P + 6) && (m += 40); + for (P = 0; P < p; P += 1) for (w = 0; w < p - 6; w += 1) l.isDark(w, P) && !l.isDark(w + 1, P) && l.isDark(w + 2, P) && l.isDark(w + 3, P) && l.isDark(w + 4, P) && !l.isDark(w + 5, P) && l.isDark(w + 6, P) && (m += 40); + var ce = 0; + for (P = 0; P < p; P += 1) for (w = 0; w < p; w += 1) l.isDark(w, P) && (ce += 1); + return m + Math.abs(100 * ce / p / p - 50) / 5 * 10; + }, R), z = (function() { + for (var l = new Array(256), p = new Array(256), m = 0; m < 8; m += 1) l[m] = 1 << m; + for (m = 8; m < 256; m += 1) l[m] = l[m - 4] ^ l[m - 5] ^ l[m - 6] ^ l[m - 8]; + for (m = 0; m < 255; m += 1) p[l[m]] = m; + return { glog: function(w) { + if (w < 1) throw "glog(" + w + ")"; + return p[w]; + }, gexp: function(w) { + for (; w < 0; ) w += 255; + for (; w >= 256; ) w -= 255; + return l[w]; + } }; + })(); + function B(l, p) { + if (l.length === void 0) throw l.length + "/" + p; + var m = (function() { + for (var P = 0; P < l.length && l[P] == 0; ) P += 1; + for (var _ = new Array(l.length - P + p), y = 0; y < l.length - P; y += 1) _[y] = l[y + P]; + return _; + })(), w = { getAt: function(P) { + return m[P]; + }, getLength: function() { + return m.length; + }, multiply: function(P) { + for (var _ = new Array(w.getLength() + P.getLength() - 1), y = 0; y < w.getLength(); y += 1) for (var M = 0; M < P.getLength(); M += 1) _[y + M] ^= z.gexp(z.glog(w.getAt(y)) + z.glog(P.getAt(M))); + return B(_, 0); + }, mod: function(P) { + if (w.getLength() - P.getLength() < 0) return w; + for (var _ = z.glog(w.getAt(0)) - z.glog(P.getAt(0)), y = new Array(w.getLength()), M = 0; M < w.getLength(); M += 1) y[M] = w.getAt(M); + for (M = 0; M < P.getLength(); M += 1) y[M] ^= z.gexp(z.glog(P.getAt(M)) + _); + return B(y, 0).mod(P); + } }; + return w; + } + var $ = /* @__PURE__ */ (function() { + var l = [[1, 26, 19], [1, 26, 16], [1, 26, 13], [1, 26, 9], [1, 44, 34], [1, 44, 28], [1, 44, 22], [1, 44, 16], [1, 70, 55], [1, 70, 44], [2, 35, 17], [2, 35, 13], [1, 100, 80], [2, 50, 32], [2, 50, 24], [4, 25, 9], [1, 134, 108], [2, 67, 43], [2, 33, 15, 2, 34, 16], [2, 33, 11, 2, 34, 12], [2, 86, 68], [4, 43, 27], [4, 43, 19], [4, 43, 15], [2, 98, 78], [4, 49, 31], [2, 32, 14, 4, 33, 15], [4, 39, 13, 1, 40, 14], [2, 121, 97], [2, 60, 38, 2, 61, 39], [4, 40, 18, 2, 41, 19], [4, 40, 14, 2, 41, 15], [2, 146, 116], [3, 58, 36, 2, 59, 37], [4, 36, 16, 4, 37, 17], [4, 36, 12, 4, 37, 13], [2, 86, 68, 2, 87, 69], [4, 69, 43, 1, 70, 44], [6, 43, 19, 2, 44, 20], [6, 43, 15, 2, 44, 16], [4, 101, 81], [1, 80, 50, 4, 81, 51], [4, 50, 22, 4, 51, 23], [3, 36, 12, 8, 37, 13], [2, 116, 92, 2, 117, 93], [6, 58, 36, 2, 59, 37], [4, 46, 20, 6, 47, 21], [7, 42, 14, 4, 43, 15], [4, 133, 107], [8, 59, 37, 1, 60, 38], [8, 44, 20, 4, 45, 21], [12, 33, 11, 4, 34, 12], [3, 145, 115, 1, 146, 116], [4, 64, 40, 5, 65, 41], [11, 36, 16, 5, 37, 17], [11, 36, 12, 5, 37, 13], [5, 109, 87, 1, 110, 88], [5, 65, 41, 5, 66, 42], [5, 54, 24, 7, 55, 25], [11, 36, 12, 7, 37, 13], [5, 122, 98, 1, 123, 99], [7, 73, 45, 3, 74, 46], [15, 43, 19, 2, 44, 20], [3, 45, 15, 13, 46, 16], [1, 135, 107, 5, 136, 108], [10, 74, 46, 1, 75, 47], [1, 50, 22, 15, 51, 23], [2, 42, 14, 17, 43, 15], [5, 150, 120, 1, 151, 121], [9, 69, 43, 4, 70, 44], [17, 50, 22, 1, 51, 23], [2, 42, 14, 19, 43, 15], [3, 141, 113, 4, 142, 114], [3, 70, 44, 11, 71, 45], [17, 47, 21, 4, 48, 22], [9, 39, 13, 16, 40, 14], [3, 135, 107, 5, 136, 108], [3, 67, 41, 13, 68, 42], [15, 54, 24, 5, 55, 25], [15, 43, 15, 10, 44, 16], [4, 144, 116, 4, 145, 117], [17, 68, 42], [17, 50, 22, 6, 51, 23], [19, 46, 16, 6, 47, 17], [2, 139, 111, 7, 140, 112], [17, 74, 46], [7, 54, 24, 16, 55, 25], [34, 37, 13], [4, 151, 121, 5, 152, 122], [4, 75, 47, 14, 76, 48], [11, 54, 24, 14, 55, 25], [16, 45, 15, 14, 46, 16], [6, 147, 117, 4, 148, 118], [6, 73, 45, 14, 74, 46], [11, 54, 24, 16, 55, 25], [30, 46, 16, 2, 47, 17], [8, 132, 106, 4, 133, 107], [8, 75, 47, 13, 76, 48], [7, 54, 24, 22, 55, 25], [22, 45, 15, 13, 46, 16], [10, 142, 114, 2, 143, 115], [19, 74, 46, 4, 75, 47], [28, 50, 22, 6, 51, 23], [33, 46, 16, 4, 47, 17], [8, 152, 122, 4, 153, 123], [22, 73, 45, 3, 74, 46], [8, 53, 23, 26, 54, 24], [12, 45, 15, 28, 46, 16], [3, 147, 117, 10, 148, 118], [3, 73, 45, 23, 74, 46], [4, 54, 24, 31, 55, 25], [11, 45, 15, 31, 46, 16], [7, 146, 116, 7, 147, 117], [21, 73, 45, 7, 74, 46], [1, 53, 23, 37, 54, 24], [19, 45, 15, 26, 46, 16], [5, 145, 115, 10, 146, 116], [19, 75, 47, 10, 76, 48], [15, 54, 24, 25, 55, 25], [23, 45, 15, 25, 46, 16], [13, 145, 115, 3, 146, 116], [2, 74, 46, 29, 75, 47], [42, 54, 24, 1, 55, 25], [23, 45, 15, 28, 46, 16], [17, 145, 115], [10, 74, 46, 23, 75, 47], [10, 54, 24, 35, 55, 25], [19, 45, 15, 35, 46, 16], [17, 145, 115, 1, 146, 116], [14, 74, 46, 21, 75, 47], [29, 54, 24, 19, 55, 25], [11, 45, 15, 46, 46, 16], [13, 145, 115, 6, 146, 116], [14, 74, 46, 23, 75, 47], [44, 54, 24, 7, 55, 25], [59, 46, 16, 1, 47, 17], [12, 151, 121, 7, 152, 122], [12, 75, 47, 26, 76, 48], [39, 54, 24, 14, 55, 25], [22, 45, 15, 41, 46, 16], [6, 151, 121, 14, 152, 122], [6, 75, 47, 34, 76, 48], [46, 54, 24, 10, 55, 25], [2, 45, 15, 64, 46, 16], [17, 152, 122, 4, 153, 123], [29, 74, 46, 14, 75, 47], [49, 54, 24, 10, 55, 25], [24, 45, 15, 46, 46, 16], [4, 152, 122, 18, 153, 123], [13, 74, 46, 32, 75, 47], [48, 54, 24, 14, 55, 25], [42, 45, 15, 32, 46, 16], [20, 147, 117, 4, 148, 118], [40, 75, 47, 7, 76, 48], [43, 54, 24, 22, 55, 25], [10, 45, 15, 67, 46, 16], [19, 148, 118, 6, 149, 119], [18, 75, 47, 31, 76, 48], [34, 54, 24, 34, 55, 25], [20, 45, 15, 61, 46, 16]], p = function(w, P) { + var _ = {}; + return _.totalCount = w, _.dataCount = P, _; + }, m = { getRSBlocks: function(w, P) { + var _ = (function(Q, X) { + switch (X) { + case k.L: + return l[4 * (Q - 1) + 0]; + case k.M: + return l[4 * (Q - 1) + 1]; + case k.Q: + return l[4 * (Q - 1) + 2]; + case k.H: + return l[4 * (Q - 1) + 3]; + default: + return; + } + })(w, P); + if (_ === void 0) throw "bad rs block @ typeNumber:" + w + "/errorCorrectionLevel:" + P; + for (var y = _.length / 3, M = [], I = 0; I < y; I += 1) for (var q = _[3 * I + 0], ce = _[3 * I + 1], L = _[3 * I + 2], oe = 0; oe < q; oe += 1) M.push(p(ce, L)); + return M; + } }; + return m; + })(), U = function() { + var l = [], p = 0, m = { getBuffer: function() { + return l; + }, getAt: function(w) { + var P = Math.floor(w / 8); + return (l[P] >>> 7 - w % 8 & 1) == 1; + }, put: function(w, P) { + for (var _ = 0; _ < P; _ += 1) m.putBit((w >>> P - _ - 1 & 1) == 1); + }, getLengthInBits: function() { + return p; + }, putBit: function(w) { + var P = Math.floor(p / 8); + l.length <= P && l.push(0), w && (l[P] |= 128 >>> p % 8), p += 1; + } }; + return m; + }, C = function(l) { + var p = l, m = { getMode: function() { + return 1; + }, getLength: function(_) { + return p.length; + }, write: function(_) { + for (var y = p, M = 0; M + 2 < y.length; ) _.put(w(y.substring(M, M + 3)), 10), M += 3; + M < y.length && (y.length - M == 1 ? _.put(w(y.substring(M, M + 1)), 4) : y.length - M == 2 && _.put(w(y.substring(M, M + 2)), 7)); + } }, w = function(_) { + for (var y = 0, M = 0; M < _.length; M += 1) y = 10 * y + P(_.charAt(M)); + return y; + }, P = function(_) { + if ("0" <= _ && _ <= "9") return _.charCodeAt(0) - 48; + throw "illegal char :" + _; + }; + return m; + }, W = function(l) { + var p = l, m = { getMode: function() { + return 2; + }, getLength: function(P) { + return p.length; + }, write: function(P) { + for (var _ = p, y = 0; y + 1 < _.length; ) P.put(45 * w(_.charAt(y)) + w(_.charAt(y + 1)), 11), y += 2; + y < _.length && P.put(w(_.charAt(y)), 6); + } }, w = function(P) { + if ("0" <= P && P <= "9") return P.charCodeAt(0) - 48; + if ("A" <= P && P <= "Z") return P.charCodeAt(0) - 65 + 10; + switch (P) { + case " ": + return 36; + case "$": + return 37; + case "%": + return 38; + case "*": + return 39; + case "+": + return 40; + case "-": + return 41; + case ".": + return 42; + case "/": + return 43; + case ":": + return 44; + default: + throw "illegal char :" + P; + } + }; + return m; + }, J = function(l) { + var p = g.stringToBytes(l); + return { getMode: function() { + return 4; + }, getLength: function(m) { + return p.length; + }, write: function(m) { + for (var w = 0; w < p.length; w += 1) m.put(p[w], 8); + } }; + }, ne = function(l) { + var p = g.stringToBytesFuncs.SJIS; + if (!p) throw "sjis not supported."; + (function() { + var P = p("友"); + if (P.length != 2 || (P[0] << 8 | P[1]) != 38726) throw "sjis not supported."; + })(); + var m = p(l), w = { getMode: function() { + return 8; + }, getLength: function(P) { + return ~~(m.length / 2); + }, write: function(P) { + for (var _ = m, y = 0; y + 1 < _.length; ) { + var M = (255 & _[y]) << 8 | 255 & _[y + 1]; + if (33088 <= M && M <= 40956) M -= 33088; + else { + if (!(57408 <= M && M <= 60351)) throw "illegal char at " + (y + 1) + "/" + M; + M -= 49472; + } + M = 192 * (M >>> 8 & 255) + (255 & M), P.put(M, 13), y += 2; + } + if (y < _.length) throw "illegal char at " + (y + 1); + } }; + return w; + }, K = function() { + var l = [], p = { writeByte: function(m) { + l.push(255 & m); + }, writeShort: function(m) { + p.writeByte(m), p.writeByte(m >>> 8); + }, writeBytes: function(m, w, P) { + w = w || 0, P = P || m.length; + for (var _ = 0; _ < P; _ += 1) p.writeByte(m[_ + w]); + }, writeString: function(m) { + for (var w = 0; w < m.length; w += 1) p.writeByte(m.charCodeAt(w)); + }, toByteArray: function() { + return l; + }, toString: function() { + var m = ""; + m += "["; + for (var w = 0; w < l.length; w += 1) w > 0 && (m += ","), m += l[w]; + return m + "]"; + } }; + return p; + }, E = function(l) { + var p = l, m = 0, w = 0, P = 0, _ = { read: function() { + for (; P < 8; ) { + if (m >= p.length) { + if (P == 0) return -1; + throw "unexpected end of file./" + P; + } + var M = p.charAt(m); + if (m += 1, M == "=") return P = 0, -1; + M.match(/^\s$/) || (w = w << 6 | y(M.charCodeAt(0)), P += 6); + } + var I = w >>> P - 8 & 255; + return P -= 8, I; + } }, y = function(M) { + if (65 <= M && M <= 90) return M - 65; + if (97 <= M && M <= 122) return M - 97 + 26; + if (48 <= M && M <= 57) return M - 48 + 52; + if (M == 43) return 62; + if (M == 47) return 63; + throw "c:" + M; + }; + return _; + }, b = function(l, p, m) { + for (var w = (function(ce, L) { + var oe = ce, Q = L, X = new Array(ce * L), ee = { setPixel: function(re, he, ae) { + X[he * oe + re] = ae; + }, write: function(re) { + re.writeString("GIF87a"), re.writeShort(oe), re.writeShort(Q), re.writeByte(128), re.writeByte(0), re.writeByte(0), re.writeByte(0), re.writeByte(0), re.writeByte(0), re.writeByte(255), re.writeByte(255), re.writeByte(255), re.writeString(","), re.writeShort(0), re.writeShort(0), re.writeShort(oe), re.writeShort(Q), re.writeByte(0); + var he = O(2); + re.writeByte(2); + for (var ae = 0; he.length - ae > 255; ) re.writeByte(255), re.writeBytes(he, ae, 255), ae += 255; + re.writeByte(he.length - ae), re.writeBytes(he, ae, he.length - ae), re.writeByte(0), re.writeString(";"); + } }, O = function(re) { + for (var he = 1 << re, ae = 1 + (1 << re), fe = re + 1, be = Z(), Ae = 0; Ae < he; Ae += 1) be.add(String.fromCharCode(Ae)); + be.add(String.fromCharCode(he)), be.add(String.fromCharCode(ae)); + var Te, Re, $e, Me = K(), Oe = (Te = Me, Re = 0, $e = 0, { write: function(Ue, _e) { + if (Ue >>> _e) throw "length over"; + for (; Re + _e >= 8; ) Te.writeByte(255 & (Ue << Re | $e)), _e -= 8 - Re, Ue >>>= 8 - Re, $e = 0, Re = 0; + $e |= Ue << Re, Re += _e; + }, flush: function() { + Re > 0 && Te.writeByte($e); + } }); + Oe.write(he, fe); + var ze = 0, De = String.fromCharCode(X[ze]); + for (ze += 1; ze < X.length; ) { + var je = String.fromCharCode(X[ze]); + ze += 1, be.contains(De + je) ? De += je : (Oe.write(be.indexOf(De), fe), be.size() < 4095 && (be.size() == 1 << fe && (fe += 1), be.add(De + je)), De = je); + } + return Oe.write(be.indexOf(De), fe), Oe.write(ae, fe), Oe.flush(), Me.toByteArray(); + }, Z = function() { + var re = {}, he = 0, ae = { add: function(fe) { + if (ae.contains(fe)) throw "dup key:" + fe; + re[fe] = he, he += 1; + }, size: function() { + return he; + }, indexOf: function(fe) { + return re[fe]; + }, contains: function(fe) { + return re[fe] !== void 0; + } }; + return ae; + }; + return ee; + })(l, p), P = 0; P < p; P += 1) for (var _ = 0; _ < l; _ += 1) w.setPixel(_, P, m(_, P)); + var y = K(); + w.write(y); + for (var M = (function() { + var ce = 0, L = 0, oe = 0, Q = "", X = {}, ee = function(Z) { + Q += String.fromCharCode(O(63 & Z)); + }, O = function(Z) { + if (!(Z < 0)) { + if (Z < 26) return 65 + Z; + if (Z < 52) return Z - 26 + 97; + if (Z < 62) return Z - 52 + 48; + if (Z == 62) return 43; + if (Z == 63) return 47; + } + throw "n:" + Z; + }; + return X.writeByte = function(Z) { + for (ce = ce << 8 | 255 & Z, L += 8, oe += 1; L >= 6; ) ee(ce >>> L - 6), L -= 6; + }, X.flush = function() { + if (L > 0 && (ee(ce << 6 - L), ce = 0, L = 0), oe % 3 != 0) for (var Z = 3 - oe % 3, re = 0; re < Z; re += 1) Q += "="; + }, X.toString = function() { + return Q; + }, X; + })(), I = y.toByteArray(), q = 0; q < I.length; q += 1) M.writeByte(I[q]); + return M.flush(), "data:image/gif;base64," + M; + }; + return g; + })(); + h.stringToBytesFuncs["UTF-8"] = function(g) { + return (function(v) { + for (var x = [], S = 0; S < v.length; S++) { + var R = v.charCodeAt(S); + R < 128 ? x.push(R) : R < 2048 ? x.push(192 | R >> 6, 128 | 63 & R) : R < 55296 || R >= 57344 ? x.push(224 | R >> 12, 128 | R >> 6 & 63, 128 | 63 & R) : (S++, R = 65536 + ((1023 & R) << 10 | 1023 & v.charCodeAt(S)), x.push(240 | R >> 18, 128 | R >> 12 & 63, 128 | R >> 6 & 63, 128 | 63 & R)); + } + return x; + })(g); + }, (u = typeof (f = function() { + return h; + }) == "function" ? f.apply(a, []) : f) === void 0 || (o.exports = u); + } }, n = {}; + function i(o) { + var a = n[o]; + if (a !== void 0) return a.exports; + var f = n[o] = { exports: {} }; + return r[o](f, f.exports, i), f.exports; + } + i.n = (o) => { + var a = o && o.__esModule ? () => o.default : () => o; + return i.d(a, { a }), a; + }, i.d = (o, a) => { + for (var f in a) i.o(a, f) && !i.o(o, f) && Object.defineProperty(o, f, { enumerable: !0, get: a[f] }); + }, i.o = (o, a) => Object.prototype.hasOwnProperty.call(o, a); + var s = {}; + return (() => { + i.d(s, { default: () => K }); + const o = (E) => !!E && typeof E == "object" && !Array.isArray(E); + function a(E, ...b) { + if (!b.length) return E; + const l = b.shift(); + return l !== void 0 && o(E) && o(l) ? (E = Object.assign({}, E), Object.keys(l).forEach(((p) => { + const m = E[p], w = l[p]; + Array.isArray(m) && Array.isArray(w) ? E[p] = w : o(m) && o(w) ? E[p] = a(Object.assign({}, m), w) : E[p] = w; + })), a(E, ...b)) : E; + } + function f(E, b) { + const l = document.createElement("a"); + l.download = b, l.href = E, document.body.appendChild(l), l.click(), document.body.removeChild(l); + } + const u = { L: 0.07, M: 0.15, Q: 0.25, H: 0.3 }; + class h { + constructor({ svg: b, type: l, window: p }) { + this._svg = b, this._type = l, this._window = p; + } + draw(b, l, p, m) { + let w; + switch (this._type) { + case "dots": + w = this._drawDot; + break; + case "classy": + w = this._drawClassy; + break; + case "classy-rounded": + w = this._drawClassyRounded; + break; + case "rounded": + w = this._drawRounded; + break; + case "extra-rounded": + w = this._drawExtraRounded; + break; + default: + w = this._drawSquare; + } + w.call(this, { x: b, y: l, size: p, getNeighbor: m }); + } + _rotateFigure({ x: b, y: l, size: p, rotation: m = 0, draw: w }) { + var P; + const _ = b + p / 2, y = l + p / 2; + w(), (P = this._element) === null || P === void 0 || P.setAttribute("transform", `rotate(${180 * m / Math.PI},${_},${y})`); + } + _basicDot(b) { + const { size: l, x: p, y: m } = b; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "circle"), this._element.setAttribute("cx", String(p + l / 2)), this._element.setAttribute("cy", String(m + l / 2)), this._element.setAttribute("r", String(l / 2)); + } })); + } + _basicSquare(b) { + const { size: l, x: p, y: m } = b; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"), this._element.setAttribute("x", String(p)), this._element.setAttribute("y", String(m)), this._element.setAttribute("width", String(l)), this._element.setAttribute("height", String(l)); + } })); + } + _basicSideRounded(b) { + const { size: l, x: p, y: m } = b; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${p} ${m}v ${l}h ` + l / 2 + `a ${l / 2} ${l / 2}, 0, 0, 0, 0 ${-l}`); + } })); + } + _basicCornerRounded(b) { + const { size: l, x: p, y: m } = b; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${p} ${m}v ${l}h ${l}v ` + -l / 2 + `a ${l / 2} ${l / 2}, 0, 0, 0, ${-l / 2} ${-l / 2}`); + } })); + } + _basicCornerExtraRounded(b) { + const { size: l, x: p, y: m } = b; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${p} ${m}v ${l}h ${l}a ${l} ${l}, 0, 0, 0, ${-l} ${-l}`); + } })); + } + _basicCornersRounded(b) { + const { size: l, x: p, y: m } = b; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${p} ${m}v ` + l / 2 + `a ${l / 2} ${l / 2}, 0, 0, 0, ${l / 2} ${l / 2}h ` + l / 2 + "v " + -l / 2 + `a ${l / 2} ${l / 2}, 0, 0, 0, ${-l / 2} ${-l / 2}`); + } })); + } + _drawDot({ x: b, y: l, size: p }) { + this._basicDot({ x: b, y: l, size: p, rotation: 0 }); + } + _drawSquare({ x: b, y: l, size: p }) { + this._basicSquare({ x: b, y: l, size: p, rotation: 0 }); + } + _drawRounded({ x: b, y: l, size: p, getNeighbor: m }) { + const w = m ? +m(-1, 0) : 0, P = m ? +m(1, 0) : 0, _ = m ? +m(0, -1) : 0, y = m ? +m(0, 1) : 0, M = w + P + _ + y; + if (M !== 0) if (M > 2 || w && P || _ && y) this._basicSquare({ x: b, y: l, size: p, rotation: 0 }); + else { + if (M === 2) { + let I = 0; + return w && _ ? I = Math.PI / 2 : _ && P ? I = Math.PI : P && y && (I = -Math.PI / 2), void this._basicCornerRounded({ x: b, y: l, size: p, rotation: I }); + } + if (M === 1) { + let I = 0; + return _ ? I = Math.PI / 2 : P ? I = Math.PI : y && (I = -Math.PI / 2), void this._basicSideRounded({ x: b, y: l, size: p, rotation: I }); + } + } + else this._basicDot({ x: b, y: l, size: p, rotation: 0 }); + } + _drawExtraRounded({ x: b, y: l, size: p, getNeighbor: m }) { + const w = m ? +m(-1, 0) : 0, P = m ? +m(1, 0) : 0, _ = m ? +m(0, -1) : 0, y = m ? +m(0, 1) : 0, M = w + P + _ + y; + if (M !== 0) if (M > 2 || w && P || _ && y) this._basicSquare({ x: b, y: l, size: p, rotation: 0 }); + else { + if (M === 2) { + let I = 0; + return w && _ ? I = Math.PI / 2 : _ && P ? I = Math.PI : P && y && (I = -Math.PI / 2), void this._basicCornerExtraRounded({ x: b, y: l, size: p, rotation: I }); + } + if (M === 1) { + let I = 0; + return _ ? I = Math.PI / 2 : P ? I = Math.PI : y && (I = -Math.PI / 2), void this._basicSideRounded({ x: b, y: l, size: p, rotation: I }); + } + } + else this._basicDot({ x: b, y: l, size: p, rotation: 0 }); + } + _drawClassy({ x: b, y: l, size: p, getNeighbor: m }) { + const w = m ? +m(-1, 0) : 0, P = m ? +m(1, 0) : 0, _ = m ? +m(0, -1) : 0, y = m ? +m(0, 1) : 0; + w + P + _ + y !== 0 ? w || _ ? P || y ? this._basicSquare({ x: b, y: l, size: p, rotation: 0 }) : this._basicCornerRounded({ x: b, y: l, size: p, rotation: Math.PI / 2 }) : this._basicCornerRounded({ x: b, y: l, size: p, rotation: -Math.PI / 2 }) : this._basicCornersRounded({ x: b, y: l, size: p, rotation: Math.PI / 2 }); + } + _drawClassyRounded({ x: b, y: l, size: p, getNeighbor: m }) { + const w = m ? +m(-1, 0) : 0, P = m ? +m(1, 0) : 0, _ = m ? +m(0, -1) : 0, y = m ? +m(0, 1) : 0; + w + P + _ + y !== 0 ? w || _ ? P || y ? this._basicSquare({ x: b, y: l, size: p, rotation: 0 }) : this._basicCornerExtraRounded({ x: b, y: l, size: p, rotation: Math.PI / 2 }) : this._basicCornerExtraRounded({ x: b, y: l, size: p, rotation: -Math.PI / 2 }) : this._basicCornersRounded({ x: b, y: l, size: p, rotation: Math.PI / 2 }); + } + } + class g { + constructor({ svg: b, type: l, window: p }) { + this._svg = b, this._type = l, this._window = p; + } + draw(b, l, p, m) { + let w; + switch (this._type) { + case "square": + w = this._drawSquare; + break; + case "extra-rounded": + w = this._drawExtraRounded; + break; + default: + w = this._drawDot; + } + w.call(this, { x: b, y: l, size: p, rotation: m }); + } + _rotateFigure({ x: b, y: l, size: p, rotation: m = 0, draw: w }) { + var P; + const _ = b + p / 2, y = l + p / 2; + w(), (P = this._element) === null || P === void 0 || P.setAttribute("transform", `rotate(${180 * m / Math.PI},${_},${y})`); + } + _basicDot(b) { + const { size: l, x: p, y: m } = b, w = l / 7; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${p + l / 2} ${m}a ${l / 2} ${l / 2} 0 1 0 0.1 0zm 0 ${w}a ${l / 2 - w} ${l / 2 - w} 0 1 1 -0.1 0Z`); + } })); + } + _basicSquare(b) { + const { size: l, x: p, y: m } = b, w = l / 7; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${p} ${m}v ${l}h ${l}v ` + -l + `zM ${p + w} ${m + w}h ` + (l - 2 * w) + "v " + (l - 2 * w) + "h " + (2 * w - l) + "z"); + } })); + } + _basicExtraRounded(b) { + const { size: l, x: p, y: m } = b, w = l / 7; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${p} ${m + 2.5 * w}v ` + 2 * w + `a ${2.5 * w} ${2.5 * w}, 0, 0, 0, ${2.5 * w} ${2.5 * w}h ` + 2 * w + `a ${2.5 * w} ${2.5 * w}, 0, 0, 0, ${2.5 * w} ${2.5 * -w}v ` + -2 * w + `a ${2.5 * w} ${2.5 * w}, 0, 0, 0, ${2.5 * -w} ${2.5 * -w}h ` + -2 * w + `a ${2.5 * w} ${2.5 * w}, 0, 0, 0, ${2.5 * -w} ${2.5 * w}M ${p + 2.5 * w} ${m + w}h ` + 2 * w + `a ${1.5 * w} ${1.5 * w}, 0, 0, 1, ${1.5 * w} ${1.5 * w}v ` + 2 * w + `a ${1.5 * w} ${1.5 * w}, 0, 0, 1, ${1.5 * -w} ${1.5 * w}h ` + -2 * w + `a ${1.5 * w} ${1.5 * w}, 0, 0, 1, ${1.5 * -w} ${1.5 * -w}v ` + -2 * w + `a ${1.5 * w} ${1.5 * w}, 0, 0, 1, ${1.5 * w} ${1.5 * -w}`); + } })); + } + _drawDot({ x: b, y: l, size: p, rotation: m }) { + this._basicDot({ x: b, y: l, size: p, rotation: m }); + } + _drawSquare({ x: b, y: l, size: p, rotation: m }) { + this._basicSquare({ x: b, y: l, size: p, rotation: m }); + } + _drawExtraRounded({ x: b, y: l, size: p, rotation: m }) { + this._basicExtraRounded({ x: b, y: l, size: p, rotation: m }); + } + } + class v { + constructor({ svg: b, type: l, window: p }) { + this._svg = b, this._type = l, this._window = p; + } + draw(b, l, p, m) { + let w; + w = this._type === "square" ? this._drawSquare : this._drawDot, w.call(this, { x: b, y: l, size: p, rotation: m }); + } + _rotateFigure({ x: b, y: l, size: p, rotation: m = 0, draw: w }) { + var P; + const _ = b + p / 2, y = l + p / 2; + w(), (P = this._element) === null || P === void 0 || P.setAttribute("transform", `rotate(${180 * m / Math.PI},${_},${y})`); + } + _basicDot(b) { + const { size: l, x: p, y: m } = b; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "circle"), this._element.setAttribute("cx", String(p + l / 2)), this._element.setAttribute("cy", String(m + l / 2)), this._element.setAttribute("r", String(l / 2)); + } })); + } + _basicSquare(b) { + const { size: l, x: p, y: m } = b; + this._rotateFigure(Object.assign(Object.assign({}, b), { draw: () => { + this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"), this._element.setAttribute("x", String(p)), this._element.setAttribute("y", String(m)), this._element.setAttribute("width", String(l)), this._element.setAttribute("height", String(l)); + } })); + } + _drawDot({ x: b, y: l, size: p, rotation: m }) { + this._basicDot({ x: b, y: l, size: p, rotation: m }); + } + _drawSquare({ x: b, y: l, size: p, rotation: m }) { + this._basicSquare({ x: b, y: l, size: p, rotation: m }); + } + } + const x = "circle", S = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]], R = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]; + class D { + constructor(b, l) { + this._roundSize = (p) => this._options.dotsOptions.roundSize ? Math.floor(p) : p, this._window = l, this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "svg"), this._element.setAttribute("width", String(b.width)), this._element.setAttribute("height", String(b.height)), this._element.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), b.dotsOptions.roundSize || this._element.setAttribute("shape-rendering", "crispEdges"), this._element.setAttribute("viewBox", `0 0 ${b.width} ${b.height}`), this._defs = this._window.document.createElementNS("http://www.w3.org/2000/svg", "defs"), this._element.appendChild(this._defs), this._imageUri = b.image, this._instanceId = D.instanceCount++, this._options = b; + } + get width() { + return this._options.width; + } + get height() { + return this._options.height; + } + getElement() { + return this._element; + } + async drawQR(b) { + const l = b.getModuleCount(), p = Math.min(this._options.width, this._options.height) - 2 * this._options.margin, m = this._options.shape === x ? p / Math.sqrt(2) : p, w = this._roundSize(m / l); + let P = { hideXDots: 0, hideYDots: 0, width: 0, height: 0 }; + if (this._qr = b, this._options.image) { + if (await this.loadImage(), !this._image) return; + const { imageOptions: _, qrOptions: y } = this._options, M = _.imageSize * u[y.errorCorrectionLevel], I = Math.floor(M * l * l); + P = (function({ originalHeight: q, originalWidth: ce, maxHiddenDots: L, maxHiddenAxisDots: oe, dotSize: Q }) { + const X = { x: 0, y: 0 }, ee = { x: 0, y: 0 }; + if (q <= 0 || ce <= 0 || L <= 0 || Q <= 0) return { height: 0, width: 0, hideYDots: 0, hideXDots: 0 }; + const O = q / ce; + return X.x = Math.floor(Math.sqrt(L / O)), X.x <= 0 && (X.x = 1), oe && oe < X.x && (X.x = oe), X.x % 2 == 0 && X.x--, ee.x = X.x * Q, X.y = 1 + 2 * Math.ceil((X.x * O - 1) / 2), ee.y = Math.round(ee.x * O), (X.y * X.x > L || oe && oe < X.y) && (oe && oe < X.y ? (X.y = oe, X.y % 2 == 0 && X.x--) : X.y -= 2, ee.y = X.y * Q, X.x = 1 + 2 * Math.ceil((X.y / O - 1) / 2), ee.x = Math.round(ee.y / O)), { height: ee.y, width: ee.x, hideYDots: X.y, hideXDots: X.x }; + })({ originalWidth: this._image.width, originalHeight: this._image.height, maxHiddenDots: I, maxHiddenAxisDots: l - 14, dotSize: w }); + } + this.drawBackground(), this.drawDots(((_, y) => { + var M, I, q, ce, L, oe; + return !(this._options.imageOptions.hideBackgroundDots && _ >= (l - P.hideYDots) / 2 && _ < (l + P.hideYDots) / 2 && y >= (l - P.hideXDots) / 2 && y < (l + P.hideXDots) / 2 || !((M = S[_]) === null || M === void 0) && M[y] || !((I = S[_ - l + 7]) === null || I === void 0) && I[y] || !((q = S[_]) === null || q === void 0) && q[y - l + 7] || !((ce = R[_]) === null || ce === void 0) && ce[y] || !((L = R[_ - l + 7]) === null || L === void 0) && L[y] || !((oe = R[_]) === null || oe === void 0) && oe[y - l + 7]); + })), this.drawCorners(), this._options.image && await this.drawImage({ width: P.width, height: P.height, count: l, dotSize: w }); + } + drawBackground() { + var b, l, p; + const m = this._element, w = this._options; + if (m) { + const P = (b = w.backgroundOptions) === null || b === void 0 ? void 0 : b.gradient, _ = (l = w.backgroundOptions) === null || l === void 0 ? void 0 : l.color; + let y = w.height, M = w.width; + if (P || _) { + const I = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"); + this._backgroundClipPath = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), this._backgroundClipPath.setAttribute("id", `clip-path-background-color-${this._instanceId}`), this._defs.appendChild(this._backgroundClipPath), !((p = w.backgroundOptions) === null || p === void 0) && p.round && (y = M = Math.min(w.width, w.height), I.setAttribute("rx", String(y / 2 * w.backgroundOptions.round))), I.setAttribute("x", String(this._roundSize((w.width - M) / 2))), I.setAttribute("y", String(this._roundSize((w.height - y) / 2))), I.setAttribute("width", String(M)), I.setAttribute("height", String(y)), this._backgroundClipPath.appendChild(I), this._createColor({ options: P, color: _, additionalRotation: 0, x: 0, y: 0, height: w.height, width: w.width, name: `background-color-${this._instanceId}` }); + } + } + } + drawDots(b) { + var l, p; + if (!this._qr) throw "QR code is not defined"; + const m = this._options, w = this._qr.getModuleCount(); + if (w > m.width || w > m.height) throw "The canvas is too small."; + const P = Math.min(m.width, m.height) - 2 * m.margin, _ = m.shape === x ? P / Math.sqrt(2) : P, y = this._roundSize(_ / w), M = this._roundSize((m.width - w * y) / 2), I = this._roundSize((m.height - w * y) / 2), q = new h({ svg: this._element, type: m.dotsOptions.type, window: this._window }); + this._dotsClipPath = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), this._dotsClipPath.setAttribute("id", `clip-path-dot-color-${this._instanceId}`), this._defs.appendChild(this._dotsClipPath), this._createColor({ options: (l = m.dotsOptions) === null || l === void 0 ? void 0 : l.gradient, color: m.dotsOptions.color, additionalRotation: 0, x: 0, y: 0, height: m.height, width: m.width, name: `dot-color-${this._instanceId}` }); + for (let ce = 0; ce < w; ce++) for (let L = 0; L < w; L++) b && !b(ce, L) || !((p = this._qr) === null || p === void 0) && p.isDark(ce, L) && (q.draw(M + L * y, I + ce * y, y, ((oe, Q) => !(L + oe < 0 || ce + Q < 0 || L + oe >= w || ce + Q >= w) && !(b && !b(ce + Q, L + oe)) && !!this._qr && this._qr.isDark(ce + Q, L + oe))), q._element && this._dotsClipPath && this._dotsClipPath.appendChild(q._element)); + if (m.shape === x) { + const ce = this._roundSize((P / y - w) / 2), L = w + 2 * ce, oe = M - ce * y, Q = I - ce * y, X = [], ee = this._roundSize(L / 2); + for (let O = 0; O < L; O++) { + X[O] = []; + for (let Z = 0; Z < L; Z++) O >= ce - 1 && O <= L - ce && Z >= ce - 1 && Z <= L - ce || Math.sqrt((O - ee) * (O - ee) + (Z - ee) * (Z - ee)) > ee ? X[O][Z] = 0 : X[O][Z] = this._qr.isDark(Z - 2 * ce < 0 ? Z : Z >= w ? Z - 2 * ce : Z - ce, O - 2 * ce < 0 ? O : O >= w ? O - 2 * ce : O - ce) ? 1 : 0; + } + for (let O = 0; O < L; O++) for (let Z = 0; Z < L; Z++) X[O][Z] && (q.draw(oe + Z * y, Q + O * y, y, ((re, he) => { + var ae; + return !!(!((ae = X[O + he]) === null || ae === void 0) && ae[Z + re]); + })), q._element && this._dotsClipPath && this._dotsClipPath.appendChild(q._element)); + } + } + drawCorners() { + if (!this._qr) throw "QR code is not defined"; + const b = this._element, l = this._options; + if (!b) throw "Element code is not defined"; + const p = this._qr.getModuleCount(), m = Math.min(l.width, l.height) - 2 * l.margin, w = l.shape === x ? m / Math.sqrt(2) : m, P = this._roundSize(w / p), _ = 7 * P, y = 3 * P, M = this._roundSize((l.width - p * P) / 2), I = this._roundSize((l.height - p * P) / 2); + [[0, 0, 0], [1, 0, Math.PI / 2], [0, 1, -Math.PI / 2]].forEach((([q, ce, L]) => { + var oe, Q, X, ee, O, Z, re, he, ae, fe, be, Ae; + const Te = M + q * P * (p - 7), Re = I + ce * P * (p - 7); + let $e = this._dotsClipPath, Me = this._dotsClipPath; + if ((!((oe = l.cornersSquareOptions) === null || oe === void 0) && oe.gradient || !((Q = l.cornersSquareOptions) === null || Q === void 0) && Q.color) && ($e = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), $e.setAttribute("id", `clip-path-corners-square-color-${q}-${ce}-${this._instanceId}`), this._defs.appendChild($e), this._cornersSquareClipPath = this._cornersDotClipPath = Me = $e, this._createColor({ options: (X = l.cornersSquareOptions) === null || X === void 0 ? void 0 : X.gradient, color: (ee = l.cornersSquareOptions) === null || ee === void 0 ? void 0 : ee.color, additionalRotation: L, x: Te, y: Re, height: _, width: _, name: `corners-square-color-${q}-${ce}-${this._instanceId}` })), (O = l.cornersSquareOptions) === null || O === void 0 ? void 0 : O.type) { + const Oe = new g({ svg: this._element, type: l.cornersSquareOptions.type, window: this._window }); + Oe.draw(Te, Re, _, L), Oe._element && $e && $e.appendChild(Oe._element); + } else { + const Oe = new h({ svg: this._element, type: l.dotsOptions.type, window: this._window }); + for (let ze = 0; ze < S.length; ze++) for (let De = 0; De < S[ze].length; De++) !((Z = S[ze]) === null || Z === void 0) && Z[De] && (Oe.draw(Te + De * P, Re + ze * P, P, ((je, Ue) => { + var _e; + return !!(!((_e = S[ze + Ue]) === null || _e === void 0) && _e[De + je]); + })), Oe._element && $e && $e.appendChild(Oe._element)); + } + if ((!((re = l.cornersDotOptions) === null || re === void 0) && re.gradient || !((he = l.cornersDotOptions) === null || he === void 0) && he.color) && (Me = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), Me.setAttribute("id", `clip-path-corners-dot-color-${q}-${ce}-${this._instanceId}`), this._defs.appendChild(Me), this._cornersDotClipPath = Me, this._createColor({ options: (ae = l.cornersDotOptions) === null || ae === void 0 ? void 0 : ae.gradient, color: (fe = l.cornersDotOptions) === null || fe === void 0 ? void 0 : fe.color, additionalRotation: L, x: Te + 2 * P, y: Re + 2 * P, height: y, width: y, name: `corners-dot-color-${q}-${ce}-${this._instanceId}` })), (be = l.cornersDotOptions) === null || be === void 0 ? void 0 : be.type) { + const Oe = new v({ svg: this._element, type: l.cornersDotOptions.type, window: this._window }); + Oe.draw(Te + 2 * P, Re + 2 * P, y, L), Oe._element && Me && Me.appendChild(Oe._element); + } else { + const Oe = new h({ svg: this._element, type: l.dotsOptions.type, window: this._window }); + for (let ze = 0; ze < R.length; ze++) for (let De = 0; De < R[ze].length; De++) !((Ae = R[ze]) === null || Ae === void 0) && Ae[De] && (Oe.draw(Te + De * P, Re + ze * P, P, ((je, Ue) => { + var _e; + return !!(!((_e = R[ze + Ue]) === null || _e === void 0) && _e[De + je]); + })), Oe._element && Me && Me.appendChild(Oe._element)); + } + })); + } + loadImage() { + return new Promise(((b, l) => { + var p; + const m = this._options; + if (!m.image) return l("Image is not defined"); + if (!((p = m.nodeCanvas) === null || p === void 0) && p.loadImage) m.nodeCanvas.loadImage(m.image).then(((w) => { + var P, _; + if (this._image = w, this._options.imageOptions.saveAsBlob) { + const y = (P = m.nodeCanvas) === null || P === void 0 ? void 0 : P.createCanvas(this._image.width, this._image.height); + (_ = y?.getContext("2d")) === null || _ === void 0 || _.drawImage(w, 0, 0), this._imageUri = y?.toDataURL(); + } + b(); + })).catch(l); + else { + const w = new this._window.Image(); + typeof m.imageOptions.crossOrigin == "string" && (w.crossOrigin = m.imageOptions.crossOrigin), this._image = w, w.onload = async () => { + this._options.imageOptions.saveAsBlob && (this._imageUri = await (async function(P, _) { + return new Promise(((y) => { + const M = new _.XMLHttpRequest(); + M.onload = function() { + const I = new _.FileReader(); + I.onloadend = function() { + y(I.result); + }, I.readAsDataURL(M.response); + }, M.open("GET", P), M.responseType = "blob", M.send(); + })); + })(m.image || "", this._window)), b(); + }, w.src = m.image; + } + })); + } + async drawImage({ width: b, height: l, count: p, dotSize: m }) { + const w = this._options, P = this._roundSize((w.width - p * m) / 2), _ = this._roundSize((w.height - p * m) / 2), y = P + this._roundSize(w.imageOptions.margin + (p * m - b) / 2), M = _ + this._roundSize(w.imageOptions.margin + (p * m - l) / 2), I = b - 2 * w.imageOptions.margin, q = l - 2 * w.imageOptions.margin, ce = this._window.document.createElementNS("http://www.w3.org/2000/svg", "image"); + ce.setAttribute("href", this._imageUri || ""), ce.setAttribute("x", String(y)), ce.setAttribute("y", String(M)), ce.setAttribute("width", `${I}px`), ce.setAttribute("height", `${q}px`), this._element.appendChild(ce); + } + _createColor({ options: b, color: l, additionalRotation: p, x: m, y: w, height: P, width: _, name: y }) { + const M = _ > P ? _ : P, I = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"); + if (I.setAttribute("x", String(m)), I.setAttribute("y", String(w)), I.setAttribute("height", String(P)), I.setAttribute("width", String(_)), I.setAttribute("clip-path", `url('#clip-path-${y}')`), b) { + let q; + if (b.type === "radial") q = this._window.document.createElementNS("http://www.w3.org/2000/svg", "radialGradient"), q.setAttribute("id", y), q.setAttribute("gradientUnits", "userSpaceOnUse"), q.setAttribute("fx", String(m + _ / 2)), q.setAttribute("fy", String(w + P / 2)), q.setAttribute("cx", String(m + _ / 2)), q.setAttribute("cy", String(w + P / 2)), q.setAttribute("r", String(M / 2)); + else { + const ce = ((b.rotation || 0) + p) % (2 * Math.PI), L = (ce + 2 * Math.PI) % (2 * Math.PI); + let oe = m + _ / 2, Q = w + P / 2, X = m + _ / 2, ee = w + P / 2; + L >= 0 && L <= 0.25 * Math.PI || L > 1.75 * Math.PI && L <= 2 * Math.PI ? (oe -= _ / 2, Q -= P / 2 * Math.tan(ce), X += _ / 2, ee += P / 2 * Math.tan(ce)) : L > 0.25 * Math.PI && L <= 0.75 * Math.PI ? (Q -= P / 2, oe -= _ / 2 / Math.tan(ce), ee += P / 2, X += _ / 2 / Math.tan(ce)) : L > 0.75 * Math.PI && L <= 1.25 * Math.PI ? (oe += _ / 2, Q += P / 2 * Math.tan(ce), X -= _ / 2, ee -= P / 2 * Math.tan(ce)) : L > 1.25 * Math.PI && L <= 1.75 * Math.PI && (Q += P / 2, oe += _ / 2 / Math.tan(ce), ee -= P / 2, X -= _ / 2 / Math.tan(ce)), q = this._window.document.createElementNS("http://www.w3.org/2000/svg", "linearGradient"), q.setAttribute("id", y), q.setAttribute("gradientUnits", "userSpaceOnUse"), q.setAttribute("x1", String(Math.round(oe))), q.setAttribute("y1", String(Math.round(Q))), q.setAttribute("x2", String(Math.round(X))), q.setAttribute("y2", String(Math.round(ee))); + } + b.colorStops.forEach((({ offset: ce, color: L }) => { + const oe = this._window.document.createElementNS("http://www.w3.org/2000/svg", "stop"); + oe.setAttribute("offset", 100 * ce + "%"), oe.setAttribute("stop-color", L), q.appendChild(oe); + })), I.setAttribute("fill", `url('#${y}')`), this._defs.appendChild(q); + } else l && I.setAttribute("fill", l); + this._element.appendChild(I); + } + } + D.instanceCount = 0; + const k = D, N = "canvas", z = {}; + for (let E = 0; E <= 40; E++) z[E] = E; + const B = { type: N, shape: "square", width: 300, height: 300, data: "", margin: 0, qrOptions: { typeNumber: z[0], mode: void 0, errorCorrectionLevel: "Q" }, imageOptions: { saveAsBlob: !0, hideBackgroundDots: !0, imageSize: 0.4, crossOrigin: void 0, margin: 0 }, dotsOptions: { type: "square", color: "#000", roundSize: !0 }, backgroundOptions: { round: 0, color: "#fff" } }; + function $(E) { + const b = Object.assign({}, E); + if (!b.colorStops || !b.colorStops.length) throw "Field 'colorStops' is required in gradient"; + return b.rotation ? b.rotation = Number(b.rotation) : b.rotation = 0, b.colorStops = b.colorStops.map(((l) => Object.assign(Object.assign({}, l), { offset: Number(l.offset) }))), b; + } + function U(E) { + const b = Object.assign({}, E); + return b.width = Number(b.width), b.height = Number(b.height), b.margin = Number(b.margin), b.imageOptions = Object.assign(Object.assign({}, b.imageOptions), { hideBackgroundDots: !!b.imageOptions.hideBackgroundDots, imageSize: Number(b.imageOptions.imageSize), margin: Number(b.imageOptions.margin) }), b.margin > Math.min(b.width, b.height) && (b.margin = Math.min(b.width, b.height)), b.dotsOptions = Object.assign({}, b.dotsOptions), b.dotsOptions.gradient && (b.dotsOptions.gradient = $(b.dotsOptions.gradient)), b.cornersSquareOptions && (b.cornersSquareOptions = Object.assign({}, b.cornersSquareOptions), b.cornersSquareOptions.gradient && (b.cornersSquareOptions.gradient = $(b.cornersSquareOptions.gradient))), b.cornersDotOptions && (b.cornersDotOptions = Object.assign({}, b.cornersDotOptions), b.cornersDotOptions.gradient && (b.cornersDotOptions.gradient = $(b.cornersDotOptions.gradient))), b.backgroundOptions && (b.backgroundOptions = Object.assign({}, b.backgroundOptions), b.backgroundOptions.gradient && (b.backgroundOptions.gradient = $(b.backgroundOptions.gradient))), b; + } + var C = i(873), W = i.n(C); + function J(E) { + if (!E) throw new Error("Extension must be defined"); + E[0] === "." && (E = E.substring(1)); + const b = { bmp: "image/bmp", gif: "image/gif", ico: "image/vnd.microsoft.icon", jpeg: "image/jpeg", jpg: "image/jpeg", png: "image/png", svg: "image/svg+xml", tif: "image/tiff", tiff: "image/tiff", webp: "image/webp", pdf: "application/pdf" }[E.toLowerCase()]; + if (!b) throw new Error(`Extension "${E}" is not supported`); + return b; + } + class ne { + constructor(b) { + b?.jsdom ? this._window = new b.jsdom("", { resources: "usable" }).window : this._window = window, this._options = b ? U(a(B, b)) : B, this.update(); + } + static _clearContainer(b) { + b && (b.innerHTML = ""); + } + _setupSvg() { + if (!this._qr) return; + const b = new k(this._options, this._window); + this._svg = b.getElement(), this._svgDrawingPromise = b.drawQR(this._qr).then((() => { + var l; + this._svg && ((l = this._extension) === null || l === void 0 || l.call(this, b.getElement(), this._options)); + })); + } + _setupCanvas() { + var b, l; + this._qr && (!((b = this._options.nodeCanvas) === null || b === void 0) && b.createCanvas ? (this._nodeCanvas = this._options.nodeCanvas.createCanvas(this._options.width, this._options.height), this._nodeCanvas.width = this._options.width, this._nodeCanvas.height = this._options.height) : (this._domCanvas = document.createElement("canvas"), this._domCanvas.width = this._options.width, this._domCanvas.height = this._options.height), this._setupSvg(), this._canvasDrawingPromise = (l = this._svgDrawingPromise) === null || l === void 0 ? void 0 : l.then((() => { + var p; + if (!this._svg) return; + const m = this._svg, w = new this._window.XMLSerializer().serializeToString(m), P = btoa(w), _ = `data:${J("svg")};base64,${P}`; + if (!((p = this._options.nodeCanvas) === null || p === void 0) && p.loadImage) return this._options.nodeCanvas.loadImage(_).then(((y) => { + var M, I; + y.width = this._options.width, y.height = this._options.height, (I = (M = this._nodeCanvas) === null || M === void 0 ? void 0 : M.getContext("2d")) === null || I === void 0 || I.drawImage(y, 0, 0); + })); + { + const y = new this._window.Image(); + return new Promise(((M) => { + y.onload = () => { + var I, q; + (q = (I = this._domCanvas) === null || I === void 0 ? void 0 : I.getContext("2d")) === null || q === void 0 || q.drawImage(y, 0, 0), M(); + }, y.src = _; + })); + } + }))); + } + async _getElement(b = "png") { + if (!this._qr) throw "QR code is empty"; + return b.toLowerCase() === "svg" ? (this._svg && this._svgDrawingPromise || this._setupSvg(), await this._svgDrawingPromise, this._svg) : ((this._domCanvas || this._nodeCanvas) && this._canvasDrawingPromise || this._setupCanvas(), await this._canvasDrawingPromise, this._domCanvas || this._nodeCanvas); + } + update(b) { + ne._clearContainer(this._container), this._options = b ? U(a(this._options, b)) : this._options, this._options.data && (this._qr = W()(this._options.qrOptions.typeNumber, this._options.qrOptions.errorCorrectionLevel), this._qr.addData(this._options.data, this._options.qrOptions.mode || (function(l) { + switch (!0) { + case /^[0-9]*$/.test(l): + return "Numeric"; + case /^[0-9A-Z $%*+\-./:]*$/.test(l): + return "Alphanumeric"; + default: + return "Byte"; + } + })(this._options.data)), this._qr.make(), this._options.type === N ? this._setupCanvas() : this._setupSvg(), this.append(this._container)); + } + append(b) { + if (b) { + if (typeof b.appendChild != "function") throw "Container should be a single DOM node"; + this._options.type === N ? this._domCanvas && b.appendChild(this._domCanvas) : this._svg && b.appendChild(this._svg), this._container = b; + } + } + applyExtension(b) { + if (!b) throw "Extension function should be defined."; + this._extension = b, this.update(); + } + deleteExtension() { + this._extension = void 0, this.update(); + } + async getRawData(b = "png") { + if (!this._qr) throw "QR code is empty"; + const l = await this._getElement(b), p = J(b); + if (!l) return null; + if (b.toLowerCase() === "svg") { + const m = `\r +${new this._window.XMLSerializer().serializeToString(l)}`; + return typeof Blob > "u" || this._options.jsdom ? Buffer.from(m) : new Blob([m], { type: p }); + } + return new Promise(((m) => { + const w = l; + if ("toBuffer" in w) if (p === "image/png") m(w.toBuffer(p)); + else if (p === "image/jpeg") m(w.toBuffer(p)); + else { + if (p !== "application/pdf") throw Error("Unsupported extension"); + m(w.toBuffer(p)); + } + else "toBlob" in w && w.toBlob(m, p, 1); + })); + } + async download(b) { + if (!this._qr) throw "QR code is empty"; + if (typeof Blob > "u") throw "Cannot download in Node.js, call getRawData instead."; + let l = "png", p = "qr"; + typeof b == "string" ? (l = b, console.warn("Extension is deprecated as argument for 'download' method, please pass object { name: '...', extension: '...' } as argument")) : typeof b == "object" && b !== null && (b.name && (p = b.name), b.extension && (l = b.extension)); + const m = await this._getElement(l); + if (m) if (l.toLowerCase() === "svg") { + let w = new XMLSerializer().serializeToString(m); + w = `\r +` + w, f(`data:${J(l)};charset=utf-8,${encodeURIComponent(w)}`, `${p}.svg`); + } else f(m.toDataURL(J(l)), `${p}.${l}`); + } + } + const K = ne; + })(), s.default; + })())); + })(nd)), nd.exports; +} +var Lee = Nee(); +const b9 = /* @__PURE__ */ Hi(Lee); +class Ro extends pt { + constructor(e) { + const { docsPath: r, field: n, metaMessages: i } = e; + super(`Invalid Sign-In with Ethereum message field "${n}".`, { + docsPath: r, + metaMessages: i, + name: "SiweInvalidMessageFieldError" + }); + } +} +function N5(t) { + if (/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(t) || /%[^0-9a-f]/i.test(t) || /%[0-9a-f](:?[^0-9a-f]|$)/i.test(t)) + return !1; + const e = kee(t), r = e[1], n = e[2], i = e[3], s = e[4], o = e[5]; + if (!(r?.length && i.length >= 0)) + return !1; + if (n?.length) { + if (!(i.length === 0 || /^\//.test(i))) + return !1; + } else if (/^\/\//.test(i)) + return !1; + if (!/^[a-z][a-z0-9\+\-\.]*$/.test(r.toLowerCase())) + return !1; + let a = ""; + return a += `${r}:`, n?.length && (a += `//${n}`), a += i, s?.length && (a += `?${s}`), o?.length && (a += `#${o}`), a; +} +function kee(t) { + return t.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/); +} +function y9(t) { + const { chainId: e, domain: r, expirationTime: n, issuedAt: i = /* @__PURE__ */ new Date(), nonce: s, notBefore: o, requestId: a, resources: f, scheme: u, uri: h, version: g } = t; + { + if (e !== Math.floor(e)) + throw new Ro({ + field: "chainId", + metaMessages: [ + "- Chain ID must be a EIP-155 chain ID.", + "- See https://eips.ethereum.org/EIPS/eip-155", + "", + `Provided value: ${e}` + ] + }); + if (!($ee.test(r) || Bee.test(r) || Fee.test(r))) + throw new Ro({ + field: "domain", + metaMessages: [ + "- Domain must be an RFC 3986 authority.", + "- See https://www.rfc-editor.org/rfc/rfc3986", + "", + `Provided value: ${r}` + ] + }); + if (!jee.test(s)) + throw new Ro({ + field: "nonce", + metaMessages: [ + "- Nonce must be at least 8 characters.", + "- Nonce must be alphanumeric.", + "", + `Provided value: ${s}` + ] + }); + if (!N5(h)) + throw new Ro({ + field: "uri", + metaMessages: [ + "- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.", + "- See https://www.rfc-editor.org/rfc/rfc3986", + "", + `Provided value: ${h}` + ] + }); + if (g !== "1") + throw new Ro({ + field: "version", + metaMessages: [ + "- Version must be '1'.", + "", + `Provided value: ${g}` + ] + }); + if (u && !Uee.test(u)) + throw new Ro({ + field: "scheme", + metaMessages: [ + "- Scheme must be an RFC 3986 URI scheme.", + "- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1", + "", + `Provided value: ${u}` + ] + }); + const k = t.statement; + if (k?.includes(` +`)) + throw new Ro({ + field: "statement", + metaMessages: [ + "- Statement must not include '\\n'.", + "", + `Provided value: ${k}` + ] + }); + } + const v = e1(t.address), x = u ? `${u}://${r}` : r, S = t.statement ? `${t.statement} +` : "", R = `${x} wants you to sign in with your Ethereum account: +${v} + +${S}`; + let D = `URI: ${h} +Version: ${g} +Chain ID: ${e} +Nonce: ${s} +Issued At: ${i.toISOString()}`; + if (n && (D += ` +Expiration Time: ${n.toISOString()}`), o && (D += ` +Not Before: ${o.toISOString()}`), a && (D += ` +Request ID: ${a}`), f) { + let k = ` +Resources:`; + for (const N of f) { + if (!N5(N)) + throw new Ro({ + field: "resources", + metaMessages: [ + "- Every resource must be a RFC 3986 URI.", + "- See https://www.rfc-editor.org/rfc/rfc3986", + "", + `Provided value: ${N}` + ] + }); + k += ` +- ${N}`; + } + D += k; + } + return `${R} +${D}`; +} +const $ee = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/, Bee = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/, Fee = /^localhost(:[0-9]{1,5})?$/, jee = /^[a-zA-Z0-9]{8,}$/, Uee = /^([a-zA-Z][a-zA-Z0-9+-.]*)$/, w9 = "7a4434fefbcc9af474fb5c995e47d286", qee = { + projectId: w9, + metadata: { + name: "codatta", + description: "codatta", + url: "https://codatta.io/", + icons: ["https://avatars.githubusercontent.com/u/171659315"] + } +}, zee = { + namespaces: { + eip155: { + methods: [ + "eth_sendTransaction", + "eth_signTransaction", + "eth_sign", + "personal_sign", + "eth_signTypedData" + ], + chains: ["eip155:56"], + events: ["chainChanged", "accountsChanged", "disconnect"], + rpcMap: { + 1: `https://rpc.walletconnect.com?chainId=eip155:56&projectId=${w9}` + } + } + }, + skipPairing: !1 +}; +function Hee(t, e) { + const r = window.location.host, n = window.location.href; + return y9({ + address: t, + chainId: 1, + domain: r, + nonce: e, + uri: n, + version: "1" + }); +} +function x9(t) { + const e = Kn(null), { wallet: r, onGetExtension: n, onSignFinish: i } = t, [s, o] = Xt(""), [a, f] = Xt(!1), [u, h] = Xt(""), [g, v] = Xt("scan"), x = Kn(), [S, R] = Xt(r.config?.image), [D, k] = Xt(!1), { saveLastUsedWallet: N } = g0(); + async function z(J) { + f(!0); + const ne = await NW.init(qee); + ne.session && await ne.disconnect(); + try { + if (v("scan"), ne.on("display_uri", (w) => { + o(w), f(!1), v("scan"); + }), ne.on("error", (w) => { + console.log(w); + }), ne.on("session_update", (w) => { + console.log("session_update", w); + }), !await ne.connect(zee)) throw new Error("Walletconnect init failed"); + const E = new Tc(ne); + R(E.config?.image || J.config?.image); + const b = await E.getAddress(), l = await Qo.getNonce({ account_type: "block_chain" }); + console.log("get nonce", l); + const p = Hee(b, l); + v("sign"); + const m = await E.signMessage(p, b); + v("waiting"), await i(E, { + message: p, + nonce: l, + signature: m, + address: b, + wallet_name: E.config?.name || J.config?.name || "" + }), console.log("save wallet connect wallet!"), N(E); + } catch (K) { + console.log("err", K), h(K.details || K.message); + } + } + function B() { + x.current = new b9({ + width: 264, + height: 264, + margin: 0, + type: "svg", + // image: wallet.config?.image, + qrOptions: { + errorCorrectionLevel: "M" + }, + dotsOptions: { + color: "black", + type: "rounded" + }, + backgroundOptions: { + color: "transparent" + } + }), x.current.append(e.current); + } + function $(J) { + console.log(x.current), x.current?.update({ + data: J + }); + } + Rn(() => { + s && $(s); + }, [s]), Rn(() => { + z(r); + }, [r]), Rn(() => { + B(); + }, []); + function U() { + h(""), $(""), z(r); + } + function C() { + k(!0), navigator.clipboard.writeText(s), setTimeout(() => { + k(!1); + }, 2500); + } + function W() { + const J = r.config?.desktop_link; + if (!J) return; + const ne = `${J}?uri=${encodeURIComponent(s)}`; + window.open(ne, "_blank"); + } + return /* @__PURE__ */ pe.jsxs("div", { children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-text-center", children: /* @__PURE__ */ pe.jsxs("div", { className: "xc-relative xc-mx-auto xc-mb-6 xc-block xc-max-h-[272px] xc-max-w-[272px] xc-rounded-xl xc-bg-white xc-p-1", children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-aspect-[1/1] xc-flex xc-h-full xc-w-full xc-justify-center", ref: e }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-absolute xc-left-0 xc-top-0 xc-flex xc-h-full xc-w-full xc-items-center xc-justify-center", children: a ? /* @__PURE__ */ pe.jsx(ja, { className: "xc-h-6 xc-w-6 xc-animate-spin xc-text-black", size: 20 }) : /* @__PURE__ */ pe.jsx("img", { className: "xc-h-10 xc-w-10", src: S }) }) + ] }) }), + /* @__PURE__ */ pe.jsxs("div", { className: "xc-m-auto xc-mb-6 xc-flex xc-max-w-[400px] xc-flex-wrap xc-items-center xc-justify-between xc-gap-3", children: [ + /* @__PURE__ */ pe.jsx( + "button", + { + disabled: !s, + onClick: C, + className: "xc-disabled:hover-text-white xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black xc-disabled:cursor-not-allowed xc-disabled:opacity-40 xc-disabled:hover:bg-transparent", + children: D ? /* @__PURE__ */ pe.jsxs(pe.Fragment, { children: [ + " ", + /* @__PURE__ */ pe.jsx(eY, {}), + " Copied!" + ] }) : /* @__PURE__ */ pe.jsxs(pe.Fragment, { children: [ + /* @__PURE__ */ pe.jsx(nY, {}), + "Copy QR URL" + ] }) + } + ), + r.config?.getWallet && /* @__PURE__ */ pe.jsxs( + "button", + { + className: "xc-rounded-2 xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black", + onClick: n, + children: [ + /* @__PURE__ */ pe.jsx(tY, {}), + "Get Extension" + ] + } + ), + r.config?.desktop_link && /* @__PURE__ */ pe.jsxs( + "button", + { + disabled: !s, + className: "xc-rounded-2 xc-flex xc-min-w-[160px] xc-flex-1 xc-shrink-0 xc-items-center xc-justify-center xc-gap-2 xc-rounded-full xc-border xc-py-2 xc-text-sm xc-transition-all xc-hover:bg-white xc-hover:text-black", + onClick: W, + children: [ + /* @__PURE__ */ pe.jsx(AS, {}), + "Desktop" + ] + } + ) + ] }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-text-center", children: u ? /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center", children: [ + /* @__PURE__ */ pe.jsx("p", { className: "xc-text-danger xc-mb-2 xc-text-center", children: u }), + /* @__PURE__ */ pe.jsx("button", { className: "xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1", onClick: U, children: "Retry" }) + ] }) : /* @__PURE__ */ pe.jsxs(pe.Fragment, { children: [ + g === "scan" && /* @__PURE__ */ pe.jsx("p", { children: "Scan this QR code from your mobile wallet or phone's camera to connect." }), + g === "connect" && /* @__PURE__ */ pe.jsx("p", { children: "Click connect in your wallet app" }), + g === "sign" && /* @__PURE__ */ pe.jsx("p", { children: "Click sign-in in your wallet to confirm you own this wallet." }), + g === "waiting" && /* @__PURE__ */ pe.jsx("div", { className: "xc-text-center", children: /* @__PURE__ */ pe.jsx(ja, { className: "xc-inline-block xc-animate-spin" }) }) + ] }) }) + ] }); +} +const Wee = /* @__PURE__ */ hN({ + id: 1, + name: "Ethereum", + nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, + rpcUrls: { + default: { + http: ["https://eth.merkle.io"] + } + }, + blockExplorers: { + default: { + name: "Etherscan", + url: "https://etherscan.io", + apiUrl: "https://api.etherscan.io/api" + } + }, + contracts: { + ensRegistry: { + address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" + }, + ensUniversalResolver: { + address: "0xce01f8eee7E479C928F8919abD53E553a36CeF67", + blockCreated: 19258213 + }, + multicall3: { + address: "0xca11bde05977b3631167028862be2a173976ca11", + blockCreated: 14353601 + } + } +}), Kee = "Accept connection request in the wallet", Vee = "Accept sign-in request in your wallet"; +function Gee(t, e, r) { + const n = window.location.host, i = window.location.href; + return y9({ + address: t, + chainId: r, + domain: n, + nonce: e, + uri: i, + version: "1" + }); +} +function _9(t) { + const [e, r] = Xt(), { wallet: n, onSignFinish: i } = t, s = Kn(), [o, a] = Xt("connect"), { saveLastUsedWallet: f, chains: u } = g0(); + async function h(v) { + try { + a("connect"); + const x = await n.connect(); + if (!x || x.length === 0) + throw new Error("Wallet connect error"); + const S = await n.getChain(), R = u.find((B) => B.id === S), D = R || u[0] || Wee; + !R && u.length > 0 && (a("switch-chain"), await n.switchChain(D)); + const k = e1(x[0]), N = Gee(k, v, D.id); + a("sign"); + const z = await n.signMessage(N, k); + if (!z || z.length === 0) + throw new Error("user sign error"); + a("waiting"), await i(n, { address: k, signature: z, message: N, nonce: v, wallet_name: n.config?.name || "" }), f(n); + } catch (x) { + console.log("walletSignin error", x.stack), console.log(x.details || x.message), r(x.details || x.message); + } + } + async function g() { + try { + r(""); + const v = await Qo.getNonce({ account_type: "block_chain" }); + s.current = v, h(s.current); + } catch (v) { + console.log(v.details), r(v.message); + } + } + return Rn(() => { + g(); + }, []), /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center xc-justify-center xc-gap-4", children: [ + /* @__PURE__ */ pe.jsx("img", { className: "xc-rounded-md xc-h-16 xc-w-16", src: n.config?.image, alt: "" }), + e && /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center", children: [ + /* @__PURE__ */ pe.jsx("p", { className: "xc-text-danger xc-mb-2 xc-text-center", children: e }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-flex xc-gap-2", children: /* @__PURE__ */ pe.jsx("button", { className: "xc-rounded-full xc-bg-white xc-bg-opacity-10 xc-px-6 xc-py-1", onClick: g, children: "Retry" }) }) + ] }), + !e && /* @__PURE__ */ pe.jsxs(pe.Fragment, { children: [ + o === "connect" && /* @__PURE__ */ pe.jsx("span", { className: "xc-text-center", children: Kee }), + o === "sign" && /* @__PURE__ */ pe.jsx("span", { className: "xc-text-center", children: Vee }), + o === "waiting" && /* @__PURE__ */ pe.jsx("span", { className: "xc-text-center", children: /* @__PURE__ */ pe.jsx(ja, { className: "xc-animate-spin" }) }), + o === "switch-chain" && /* @__PURE__ */ pe.jsxs("span", { className: "xc-text-center", children: [ + "Switch to ", + u[0].name + ] }) + ] }) + ] }); +} +const vc = "https://static.codatta.io/codatta-connect/wallet-icons.svg", Yee = "https://itunes.apple.com/app/", Jee = "https://play.google.com/store/apps/details?id=", Xee = "https://chromewebstore.google.com/detail/", Zee = "https://chromewebstore.google.com/detail/", Qee = "https://addons.mozilla.org/en-US/firefox/addon/", ete = "https://microsoftedge.microsoft.com/addons/detail/"; +function bc(t) { + const { icon: e, title: r, link: n } = t; + return /* @__PURE__ */ pe.jsxs( + "a", + { + href: n, + target: "_blank", + className: "xc-flex xc-w-full xc-cursor-pointer xc-items-center xc-gap-2 xc-rounded-full xc-border xc-border-white xc-border-opacity-15 xc-px-6 xc-py-3 xc-transition-all xc-hover:bg-white xc-hover:bg-opacity-5", + children: [ + /* @__PURE__ */ pe.jsx("img", { className: "xc-rounded-1 xc-h-6 xc-w-6", src: e, alt: "" }), + r, + /* @__PURE__ */ pe.jsx(SS, { className: "xc-ml-auto xc-text-gray-400" }) + ] + } + ); +} +function tte(t) { + const e = { + appStoreLink: "", + playStoreLink: "", + chromeStoreLink: "", + braveStoreLink: "", + firefoxStoreLink: "", + edgeStoreLink: "" + }; + return t?.app_store_id && (e.appStoreLink = `${Yee}${t.app_store_id}`), t?.play_store_id && (e.playStoreLink = `${Jee}${t.play_store_id}`), t?.chrome_store_id && (e.chromeStoreLink = `${Xee}${t.chrome_store_id}`), t?.brave_store_id && (e.braveStoreLink = `${Zee}${t.brave_store_id}`), t?.firefox_addon_id && (e.firefoxStoreLink = `${Qee}${t.firefox_addon_id}`), t?.edge_addon_id && (e.edgeStoreLink = `${ete}${t.edge_addon_id}`), e; +} +function E9(t) { + const { wallet: e } = t, r = e.config?.getWallet, n = tte(r); + return /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-flex-col xc-items-center", children: [ + /* @__PURE__ */ pe.jsx("img", { className: "xc-rounded-md xc-mb-2 xc-h-12 xc-w-12", src: e.config?.image, alt: "" }), + /* @__PURE__ */ pe.jsxs("p", { className: "xc-text-lg xc-font-bold", children: [ + "Install ", + e.config?.name, + " to connect" + ] }), + /* @__PURE__ */ pe.jsx("p", { className: "xc-mb-6 xc-text-sm xc-text-gray-500", children: "Select from your preferred options below:" }), + /* @__PURE__ */ pe.jsxs("div", { className: "xc-grid xc-w-full xc-grid-cols-1 xc-gap-3", children: [ + r?.chrome_store_id && /* @__PURE__ */ pe.jsx( + bc, + { + link: n.chromeStoreLink, + icon: `${vc}#chrome`, + title: "Chrome Web Store" + } + ), + r?.app_store_id && /* @__PURE__ */ pe.jsx( + bc, + { + link: n.appStoreLink, + icon: `${vc}#apple-dark`, + title: "Apple App Store" + } + ), + r?.play_store_id && /* @__PURE__ */ pe.jsx( + bc, + { + link: n.playStoreLink, + icon: `${vc}#android`, + title: "Google Play Store" + } + ), + r?.edge_addon_id && /* @__PURE__ */ pe.jsx( + bc, + { + link: n.edgeStoreLink, + icon: `${vc}#edge`, + title: "Microsoft Edge" + } + ), + r?.brave_store_id && /* @__PURE__ */ pe.jsx( + bc, + { + link: n.braveStoreLink, + icon: `${vc}#brave`, + title: "Brave extension" + } + ), + r?.firefox_addon_id && /* @__PURE__ */ pe.jsx( + bc, + { + link: n.firefoxStoreLink, + icon: `${vc}#firefox`, + title: "Mozilla Firefox" + } + ) + ] }) + ] }); +} +function rte(t) { + const { wallet: e } = t, [r, n] = Xt(e.installed ? "connect" : "qr"), i = Pb(); + async function s(o, a) { + const f = await Qo.walletLogin({ + account_type: "block_chain", + account_enum: i.role, + connector: "codatta_wallet", + inviter_code: i.inviterCode, + wallet_name: o.config?.name || o.key, + address: await o.getAddress(), + chain: (await o.getChain()).toString(), + nonce: a.nonce, + signature: a.signature, + message: a.message, + source: { + device: i.device, + channel: i.channel, + app: i.app + } + }); + await t.onLogin(f.data); + } + return /* @__PURE__ */ pe.jsxs(ps, { children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-6", children: /* @__PURE__ */ pe.jsx(Ja, { title: "Connect wallet", onBack: t.onBack }) }), + r === "qr" && /* @__PURE__ */ pe.jsx( + x9, + { + wallet: e, + onGetExtension: () => n("get-extension"), + onSignFinish: s + } + ), + r === "connect" && /* @__PURE__ */ pe.jsx( + _9, + { + onShowQrCode: () => n("qr"), + wallet: e, + onSignFinish: s + } + ), + r === "get-extension" && /* @__PURE__ */ pe.jsx(E9, { wallet: e }) + ] }); +} +function nte(t) { + const { wallet: e, onClick: r } = t, n = /* @__PURE__ */ pe.jsx("img", { className: "xc-rounded-md xc-h-5 xc-w-5", src: e.imageUrl }), i = e.name || ""; + return /* @__PURE__ */ pe.jsx(Sb, { icon: n, title: i, onClick: () => r(e) }); +} +function S9(t) { + const { connector: e } = t, [r, n] = Xt(), [i, s] = Xt([]), o = hi(() => r ? i.filter((h) => h.name.toLowerCase().includes(r.toLowerCase())) : i, [r, i]); + function a(h) { + n(h.target.value); + } + async function f() { + const h = await e.getWallets(); + s(h); + } + Rn(() => { + f(); + }, []); + function u(h) { + t.onSelect(h); + } + return /* @__PURE__ */ pe.jsxs(ps, { children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-6", children: /* @__PURE__ */ pe.jsx(Ja, { title: "Select wallet", onBack: t.onBack }) }), + /* @__PURE__ */ pe.jsxs("div", { className: "xc-mb-6 xc-flex xc-gap-3 xc-px-4 xc-py-2 xc-border xc-rounded-xl xc-w-full xc-overflow-hidden xc-items-center xc-border-opacity-15 xc-border-white focus-within:xc-border-opacity-40", children: [ + /* @__PURE__ */ pe.jsx(PS, { className: "xc-shrink-0 xc-opacity-50" }), + /* @__PURE__ */ pe.jsx("input", { type: "text", className: "xc-flex-1 xc-bg-transparent xc-appearance-none xc-outline-none", placeholder: "Search wallet", onInput: a }) + ] }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-4 xc-flex xc-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar", children: o?.map((h) => /* @__PURE__ */ pe.jsx(nte, { wallet: h, onClick: u }, h.name)) }) + ] }); +} +var id = { exports: {} }, ite = id.exports, L5; +function ste() { + return L5 || (L5 = 1, (function(t) { + (function(e, r) { + t.exports ? t.exports = r() : (e.nacl || (e.nacl = {}), e.nacl.util = r()); + })(ite, function() { + var e = {}; + function r(n) { + if (!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(n)) + throw new TypeError("invalid encoding"); + } + return e.decodeUTF8 = function(n) { + if (typeof n != "string") throw new TypeError("expected string"); + var i, s = unescape(encodeURIComponent(n)), o = new Uint8Array(s.length); + for (i = 0; i < s.length; i++) o[i] = s.charCodeAt(i); + return o; + }, e.encodeUTF8 = function(n) { + var i, s = []; + for (i = 0; i < n.length; i++) s.push(String.fromCharCode(n[i])); + return decodeURIComponent(escape(s.join(""))); + }, typeof atob > "u" ? typeof Buffer.from < "u" ? (e.encodeBase64 = function(n) { + return Buffer.from(n).toString("base64"); + }, e.decodeBase64 = function(n) { + return r(n), new Uint8Array(Array.prototype.slice.call(Buffer.from(n, "base64"), 0)); + }) : (e.encodeBase64 = function(n) { + return new Buffer(n).toString("base64"); + }, e.decodeBase64 = function(n) { + return r(n), new Uint8Array(Array.prototype.slice.call(new Buffer(n, "base64"), 0)); + }) : (e.encodeBase64 = function(n) { + var i, s = [], o = n.length; + for (i = 0; i < o; i++) s.push(String.fromCharCode(n[i])); + return btoa(s.join("")); + }, e.decodeBase64 = function(n) { + r(n); + var i, s = atob(n), o = new Uint8Array(s.length); + for (i = 0; i < s.length; i++) o[i] = s.charCodeAt(i); + return o; + }), e; + }); + })(id)), id.exports; +} +var ote = ste(); +const Hf = /* @__PURE__ */ Hi(ote); +var Dm = { exports: {} }, k5; +function ate() { + return k5 || (k5 = 1, (function(t) { + (function(e) { + var r = function(H) { + var V, Y = new Float64Array(16); + if (H) for (V = 0; V < H.length; V++) Y[V] = H[V]; + return Y; + }, n = function() { + throw new Error("no PRNG"); + }, i = new Uint8Array(16), s = new Uint8Array(32); + s[0] = 9; + var o = r(), a = r([1]), f = r([56129, 1]), u = r([30883, 4953, 19914, 30187, 55467, 16705, 2637, 112, 59544, 30585, 16505, 36039, 65139, 11119, 27886, 20995]), h = r([61785, 9906, 39828, 60374, 45398, 33411, 5274, 224, 53552, 61171, 33010, 6542, 64743, 22239, 55772, 9222]), g = r([54554, 36645, 11616, 51542, 42930, 38181, 51040, 26924, 56412, 64982, 57905, 49316, 21502, 52590, 14035, 8553]), v = r([26200, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214]), x = r([41136, 18958, 6951, 50414, 58488, 44335, 6150, 12099, 55207, 15867, 153, 11085, 57099, 20417, 9344, 11139]); + function S(H, V, Y, T) { + H[V] = Y >> 24 & 255, H[V + 1] = Y >> 16 & 255, H[V + 2] = Y >> 8 & 255, H[V + 3] = Y & 255, H[V + 4] = T >> 24 & 255, H[V + 5] = T >> 16 & 255, H[V + 6] = T >> 8 & 255, H[V + 7] = T & 255; + } + function R(H, V, Y, T, F) { + var ie, le = 0; + for (ie = 0; ie < F; ie++) le |= H[V + ie] ^ Y[T + ie]; + return (1 & le - 1 >>> 8) - 1; + } + function D(H, V, Y, T) { + return R(H, V, Y, T, 16); + } + function k(H, V, Y, T) { + return R(H, V, Y, T, 32); + } + function N(H, V, Y, T) { + for (var F = T[0] & 255 | (T[1] & 255) << 8 | (T[2] & 255) << 16 | (T[3] & 255) << 24, ie = Y[0] & 255 | (Y[1] & 255) << 8 | (Y[2] & 255) << 16 | (Y[3] & 255) << 24, le = Y[4] & 255 | (Y[5] & 255) << 8 | (Y[6] & 255) << 16 | (Y[7] & 255) << 24, me = Y[8] & 255 | (Y[9] & 255) << 8 | (Y[10] & 255) << 16 | (Y[11] & 255) << 24, Ee = Y[12] & 255 | (Y[13] & 255) << 8 | (Y[14] & 255) << 16 | (Y[15] & 255) << 24, Le = T[4] & 255 | (T[5] & 255) << 8 | (T[6] & 255) << 16 | (T[7] & 255) << 24, Ie = V[0] & 255 | (V[1] & 255) << 8 | (V[2] & 255) << 16 | (V[3] & 255) << 24, Qe = V[4] & 255 | (V[5] & 255) << 8 | (V[6] & 255) << 16 | (V[7] & 255) << 24, Xe = V[8] & 255 | (V[9] & 255) << 8 | (V[10] & 255) << 16 | (V[11] & 255) << 24, tt = V[12] & 255 | (V[13] & 255) << 8 | (V[14] & 255) << 16 | (V[15] & 255) << 24, st = T[8] & 255 | (T[9] & 255) << 8 | (T[10] & 255) << 16 | (T[11] & 255) << 24, vt = Y[16] & 255 | (Y[17] & 255) << 8 | (Y[18] & 255) << 16 | (Y[19] & 255) << 24, Ct = Y[20] & 255 | (Y[21] & 255) << 8 | (Y[22] & 255) << 16 | (Y[23] & 255) << 24, Mt = Y[24] & 255 | (Y[25] & 255) << 8 | (Y[26] & 255) << 16 | (Y[27] & 255) << 24, wt = Y[28] & 255 | (Y[29] & 255) << 8 | (Y[30] & 255) << 16 | (Y[31] & 255) << 24, Rt = T[12] & 255 | (T[13] & 255) << 8 | (T[14] & 255) << 16 | (T[15] & 255) << 24, gt = F, _t = ie, at = le, yt = me, ut = Ee, it = Le, Se = Ie, Pe = Qe, Ke = Xe, Fe = tt, qe = st, Ye = vt, Lt = Ct, zt = Mt, Zt = wt, Ht = Rt, ge, nr = 0; nr < 20; nr += 2) + ge = gt + Lt | 0, ut ^= ge << 7 | ge >>> 25, ge = ut + gt | 0, Ke ^= ge << 9 | ge >>> 23, ge = Ke + ut | 0, Lt ^= ge << 13 | ge >>> 19, ge = Lt + Ke | 0, gt ^= ge << 18 | ge >>> 14, ge = it + _t | 0, Fe ^= ge << 7 | ge >>> 25, ge = Fe + it | 0, zt ^= ge << 9 | ge >>> 23, ge = zt + Fe | 0, _t ^= ge << 13 | ge >>> 19, ge = _t + zt | 0, it ^= ge << 18 | ge >>> 14, ge = qe + Se | 0, Zt ^= ge << 7 | ge >>> 25, ge = Zt + qe | 0, at ^= ge << 9 | ge >>> 23, ge = at + Zt | 0, Se ^= ge << 13 | ge >>> 19, ge = Se + at | 0, qe ^= ge << 18 | ge >>> 14, ge = Ht + Ye | 0, yt ^= ge << 7 | ge >>> 25, ge = yt + Ht | 0, Pe ^= ge << 9 | ge >>> 23, ge = Pe + yt | 0, Ye ^= ge << 13 | ge >>> 19, ge = Ye + Pe | 0, Ht ^= ge << 18 | ge >>> 14, ge = gt + yt | 0, _t ^= ge << 7 | ge >>> 25, ge = _t + gt | 0, at ^= ge << 9 | ge >>> 23, ge = at + _t | 0, yt ^= ge << 13 | ge >>> 19, ge = yt + at | 0, gt ^= ge << 18 | ge >>> 14, ge = it + ut | 0, Se ^= ge << 7 | ge >>> 25, ge = Se + it | 0, Pe ^= ge << 9 | ge >>> 23, ge = Pe + Se | 0, ut ^= ge << 13 | ge >>> 19, ge = ut + Pe | 0, it ^= ge << 18 | ge >>> 14, ge = qe + Fe | 0, Ye ^= ge << 7 | ge >>> 25, ge = Ye + qe | 0, Ke ^= ge << 9 | ge >>> 23, ge = Ke + Ye | 0, Fe ^= ge << 13 | ge >>> 19, ge = Fe + Ke | 0, qe ^= ge << 18 | ge >>> 14, ge = Ht + Zt | 0, Lt ^= ge << 7 | ge >>> 25, ge = Lt + Ht | 0, zt ^= ge << 9 | ge >>> 23, ge = zt + Lt | 0, Zt ^= ge << 13 | ge >>> 19, ge = Zt + zt | 0, Ht ^= ge << 18 | ge >>> 14; + gt = gt + F | 0, _t = _t + ie | 0, at = at + le | 0, yt = yt + me | 0, ut = ut + Ee | 0, it = it + Le | 0, Se = Se + Ie | 0, Pe = Pe + Qe | 0, Ke = Ke + Xe | 0, Fe = Fe + tt | 0, qe = qe + st | 0, Ye = Ye + vt | 0, Lt = Lt + Ct | 0, zt = zt + Mt | 0, Zt = Zt + wt | 0, Ht = Ht + Rt | 0, H[0] = gt >>> 0 & 255, H[1] = gt >>> 8 & 255, H[2] = gt >>> 16 & 255, H[3] = gt >>> 24 & 255, H[4] = _t >>> 0 & 255, H[5] = _t >>> 8 & 255, H[6] = _t >>> 16 & 255, H[7] = _t >>> 24 & 255, H[8] = at >>> 0 & 255, H[9] = at >>> 8 & 255, H[10] = at >>> 16 & 255, H[11] = at >>> 24 & 255, H[12] = yt >>> 0 & 255, H[13] = yt >>> 8 & 255, H[14] = yt >>> 16 & 255, H[15] = yt >>> 24 & 255, H[16] = ut >>> 0 & 255, H[17] = ut >>> 8 & 255, H[18] = ut >>> 16 & 255, H[19] = ut >>> 24 & 255, H[20] = it >>> 0 & 255, H[21] = it >>> 8 & 255, H[22] = it >>> 16 & 255, H[23] = it >>> 24 & 255, H[24] = Se >>> 0 & 255, H[25] = Se >>> 8 & 255, H[26] = Se >>> 16 & 255, H[27] = Se >>> 24 & 255, H[28] = Pe >>> 0 & 255, H[29] = Pe >>> 8 & 255, H[30] = Pe >>> 16 & 255, H[31] = Pe >>> 24 & 255, H[32] = Ke >>> 0 & 255, H[33] = Ke >>> 8 & 255, H[34] = Ke >>> 16 & 255, H[35] = Ke >>> 24 & 255, H[36] = Fe >>> 0 & 255, H[37] = Fe >>> 8 & 255, H[38] = Fe >>> 16 & 255, H[39] = Fe >>> 24 & 255, H[40] = qe >>> 0 & 255, H[41] = qe >>> 8 & 255, H[42] = qe >>> 16 & 255, H[43] = qe >>> 24 & 255, H[44] = Ye >>> 0 & 255, H[45] = Ye >>> 8 & 255, H[46] = Ye >>> 16 & 255, H[47] = Ye >>> 24 & 255, H[48] = Lt >>> 0 & 255, H[49] = Lt >>> 8 & 255, H[50] = Lt >>> 16 & 255, H[51] = Lt >>> 24 & 255, H[52] = zt >>> 0 & 255, H[53] = zt >>> 8 & 255, H[54] = zt >>> 16 & 255, H[55] = zt >>> 24 & 255, H[56] = Zt >>> 0 & 255, H[57] = Zt >>> 8 & 255, H[58] = Zt >>> 16 & 255, H[59] = Zt >>> 24 & 255, H[60] = Ht >>> 0 & 255, H[61] = Ht >>> 8 & 255, H[62] = Ht >>> 16 & 255, H[63] = Ht >>> 24 & 255; + } + function z(H, V, Y, T) { + for (var F = T[0] & 255 | (T[1] & 255) << 8 | (T[2] & 255) << 16 | (T[3] & 255) << 24, ie = Y[0] & 255 | (Y[1] & 255) << 8 | (Y[2] & 255) << 16 | (Y[3] & 255) << 24, le = Y[4] & 255 | (Y[5] & 255) << 8 | (Y[6] & 255) << 16 | (Y[7] & 255) << 24, me = Y[8] & 255 | (Y[9] & 255) << 8 | (Y[10] & 255) << 16 | (Y[11] & 255) << 24, Ee = Y[12] & 255 | (Y[13] & 255) << 8 | (Y[14] & 255) << 16 | (Y[15] & 255) << 24, Le = T[4] & 255 | (T[5] & 255) << 8 | (T[6] & 255) << 16 | (T[7] & 255) << 24, Ie = V[0] & 255 | (V[1] & 255) << 8 | (V[2] & 255) << 16 | (V[3] & 255) << 24, Qe = V[4] & 255 | (V[5] & 255) << 8 | (V[6] & 255) << 16 | (V[7] & 255) << 24, Xe = V[8] & 255 | (V[9] & 255) << 8 | (V[10] & 255) << 16 | (V[11] & 255) << 24, tt = V[12] & 255 | (V[13] & 255) << 8 | (V[14] & 255) << 16 | (V[15] & 255) << 24, st = T[8] & 255 | (T[9] & 255) << 8 | (T[10] & 255) << 16 | (T[11] & 255) << 24, vt = Y[16] & 255 | (Y[17] & 255) << 8 | (Y[18] & 255) << 16 | (Y[19] & 255) << 24, Ct = Y[20] & 255 | (Y[21] & 255) << 8 | (Y[22] & 255) << 16 | (Y[23] & 255) << 24, Mt = Y[24] & 255 | (Y[25] & 255) << 8 | (Y[26] & 255) << 16 | (Y[27] & 255) << 24, wt = Y[28] & 255 | (Y[29] & 255) << 8 | (Y[30] & 255) << 16 | (Y[31] & 255) << 24, Rt = T[12] & 255 | (T[13] & 255) << 8 | (T[14] & 255) << 16 | (T[15] & 255) << 24, gt = F, _t = ie, at = le, yt = me, ut = Ee, it = Le, Se = Ie, Pe = Qe, Ke = Xe, Fe = tt, qe = st, Ye = vt, Lt = Ct, zt = Mt, Zt = wt, Ht = Rt, ge, nr = 0; nr < 20; nr += 2) + ge = gt + Lt | 0, ut ^= ge << 7 | ge >>> 25, ge = ut + gt | 0, Ke ^= ge << 9 | ge >>> 23, ge = Ke + ut | 0, Lt ^= ge << 13 | ge >>> 19, ge = Lt + Ke | 0, gt ^= ge << 18 | ge >>> 14, ge = it + _t | 0, Fe ^= ge << 7 | ge >>> 25, ge = Fe + it | 0, zt ^= ge << 9 | ge >>> 23, ge = zt + Fe | 0, _t ^= ge << 13 | ge >>> 19, ge = _t + zt | 0, it ^= ge << 18 | ge >>> 14, ge = qe + Se | 0, Zt ^= ge << 7 | ge >>> 25, ge = Zt + qe | 0, at ^= ge << 9 | ge >>> 23, ge = at + Zt | 0, Se ^= ge << 13 | ge >>> 19, ge = Se + at | 0, qe ^= ge << 18 | ge >>> 14, ge = Ht + Ye | 0, yt ^= ge << 7 | ge >>> 25, ge = yt + Ht | 0, Pe ^= ge << 9 | ge >>> 23, ge = Pe + yt | 0, Ye ^= ge << 13 | ge >>> 19, ge = Ye + Pe | 0, Ht ^= ge << 18 | ge >>> 14, ge = gt + yt | 0, _t ^= ge << 7 | ge >>> 25, ge = _t + gt | 0, at ^= ge << 9 | ge >>> 23, ge = at + _t | 0, yt ^= ge << 13 | ge >>> 19, ge = yt + at | 0, gt ^= ge << 18 | ge >>> 14, ge = it + ut | 0, Se ^= ge << 7 | ge >>> 25, ge = Se + it | 0, Pe ^= ge << 9 | ge >>> 23, ge = Pe + Se | 0, ut ^= ge << 13 | ge >>> 19, ge = ut + Pe | 0, it ^= ge << 18 | ge >>> 14, ge = qe + Fe | 0, Ye ^= ge << 7 | ge >>> 25, ge = Ye + qe | 0, Ke ^= ge << 9 | ge >>> 23, ge = Ke + Ye | 0, Fe ^= ge << 13 | ge >>> 19, ge = Fe + Ke | 0, qe ^= ge << 18 | ge >>> 14, ge = Ht + Zt | 0, Lt ^= ge << 7 | ge >>> 25, ge = Lt + Ht | 0, zt ^= ge << 9 | ge >>> 23, ge = zt + Lt | 0, Zt ^= ge << 13 | ge >>> 19, ge = Zt + zt | 0, Ht ^= ge << 18 | ge >>> 14; + H[0] = gt >>> 0 & 255, H[1] = gt >>> 8 & 255, H[2] = gt >>> 16 & 255, H[3] = gt >>> 24 & 255, H[4] = it >>> 0 & 255, H[5] = it >>> 8 & 255, H[6] = it >>> 16 & 255, H[7] = it >>> 24 & 255, H[8] = qe >>> 0 & 255, H[9] = qe >>> 8 & 255, H[10] = qe >>> 16 & 255, H[11] = qe >>> 24 & 255, H[12] = Ht >>> 0 & 255, H[13] = Ht >>> 8 & 255, H[14] = Ht >>> 16 & 255, H[15] = Ht >>> 24 & 255, H[16] = Se >>> 0 & 255, H[17] = Se >>> 8 & 255, H[18] = Se >>> 16 & 255, H[19] = Se >>> 24 & 255, H[20] = Pe >>> 0 & 255, H[21] = Pe >>> 8 & 255, H[22] = Pe >>> 16 & 255, H[23] = Pe >>> 24 & 255, H[24] = Ke >>> 0 & 255, H[25] = Ke >>> 8 & 255, H[26] = Ke >>> 16 & 255, H[27] = Ke >>> 24 & 255, H[28] = Fe >>> 0 & 255, H[29] = Fe >>> 8 & 255, H[30] = Fe >>> 16 & 255, H[31] = Fe >>> 24 & 255; + } + function B(H, V, Y, T) { + N(H, V, Y, T); + } + function $(H, V, Y, T) { + z(H, V, Y, T); + } + var U = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]); + function C(H, V, Y, T, F, ie, le) { + var me = new Uint8Array(16), Ee = new Uint8Array(64), Le, Ie; + for (Ie = 0; Ie < 16; Ie++) me[Ie] = 0; + for (Ie = 0; Ie < 8; Ie++) me[Ie] = ie[Ie]; + for (; F >= 64; ) { + for (B(Ee, me, le, U), Ie = 0; Ie < 64; Ie++) H[V + Ie] = Y[T + Ie] ^ Ee[Ie]; + for (Le = 1, Ie = 8; Ie < 16; Ie++) + Le = Le + (me[Ie] & 255) | 0, me[Ie] = Le & 255, Le >>>= 8; + F -= 64, V += 64, T += 64; + } + if (F > 0) + for (B(Ee, me, le, U), Ie = 0; Ie < F; Ie++) H[V + Ie] = Y[T + Ie] ^ Ee[Ie]; + return 0; + } + function W(H, V, Y, T, F) { + var ie = new Uint8Array(16), le = new Uint8Array(64), me, Ee; + for (Ee = 0; Ee < 16; Ee++) ie[Ee] = 0; + for (Ee = 0; Ee < 8; Ee++) ie[Ee] = T[Ee]; + for (; Y >= 64; ) { + for (B(le, ie, F, U), Ee = 0; Ee < 64; Ee++) H[V + Ee] = le[Ee]; + for (me = 1, Ee = 8; Ee < 16; Ee++) + me = me + (ie[Ee] & 255) | 0, ie[Ee] = me & 255, me >>>= 8; + Y -= 64, V += 64; + } + if (Y > 0) + for (B(le, ie, F, U), Ee = 0; Ee < Y; Ee++) H[V + Ee] = le[Ee]; + return 0; + } + function J(H, V, Y, T, F) { + var ie = new Uint8Array(32); + $(ie, T, F, U); + for (var le = new Uint8Array(8), me = 0; me < 8; me++) le[me] = T[me + 16]; + return W(H, V, Y, le, ie); + } + function ne(H, V, Y, T, F, ie, le) { + var me = new Uint8Array(32); + $(me, ie, le, U); + for (var Ee = new Uint8Array(8), Le = 0; Le < 8; Le++) Ee[Le] = ie[Le + 16]; + return C(H, V, Y, T, F, Ee, me); + } + var K = function(H) { + 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; + var V, Y, T, F, ie, le, me, Ee; + V = H[0] & 255 | (H[1] & 255) << 8, this.r[0] = V & 8191, Y = H[2] & 255 | (H[3] & 255) << 8, this.r[1] = (V >>> 13 | Y << 3) & 8191, T = H[4] & 255 | (H[5] & 255) << 8, this.r[2] = (Y >>> 10 | T << 6) & 7939, F = H[6] & 255 | (H[7] & 255) << 8, this.r[3] = (T >>> 7 | F << 9) & 8191, ie = H[8] & 255 | (H[9] & 255) << 8, this.r[4] = (F >>> 4 | ie << 12) & 255, this.r[5] = ie >>> 1 & 8190, le = H[10] & 255 | (H[11] & 255) << 8, this.r[6] = (ie >>> 14 | le << 2) & 8191, me = H[12] & 255 | (H[13] & 255) << 8, this.r[7] = (le >>> 11 | me << 5) & 8065, Ee = H[14] & 255 | (H[15] & 255) << 8, this.r[8] = (me >>> 8 | Ee << 8) & 8191, this.r[9] = Ee >>> 5 & 127, this.pad[0] = H[16] & 255 | (H[17] & 255) << 8, this.pad[1] = H[18] & 255 | (H[19] & 255) << 8, this.pad[2] = H[20] & 255 | (H[21] & 255) << 8, this.pad[3] = H[22] & 255 | (H[23] & 255) << 8, this.pad[4] = H[24] & 255 | (H[25] & 255) << 8, this.pad[5] = H[26] & 255 | (H[27] & 255) << 8, this.pad[6] = H[28] & 255 | (H[29] & 255) << 8, this.pad[7] = H[30] & 255 | (H[31] & 255) << 8; + }; + K.prototype.blocks = function(H, V, Y) { + for (var T = this.fin ? 0 : 2048, F, ie, le, me, Ee, Le, Ie, Qe, Xe, tt, st, vt, Ct, Mt, wt, Rt, gt, _t, at, yt = this.h[0], ut = this.h[1], it = this.h[2], Se = this.h[3], Pe = this.h[4], Ke = this.h[5], Fe = this.h[6], qe = this.h[7], Ye = this.h[8], Lt = this.h[9], zt = this.r[0], Zt = this.r[1], Ht = this.r[2], ge = this.r[3], nr = this.r[4], pr = this.r[5], gr = this.r[6], Qt = this.r[7], mr = this.r[8], lr = this.r[9]; Y >= 16; ) + F = H[V + 0] & 255 | (H[V + 1] & 255) << 8, yt += F & 8191, ie = H[V + 2] & 255 | (H[V + 3] & 255) << 8, ut += (F >>> 13 | ie << 3) & 8191, le = H[V + 4] & 255 | (H[V + 5] & 255) << 8, it += (ie >>> 10 | le << 6) & 8191, me = H[V + 6] & 255 | (H[V + 7] & 255) << 8, Se += (le >>> 7 | me << 9) & 8191, Ee = H[V + 8] & 255 | (H[V + 9] & 255) << 8, Pe += (me >>> 4 | Ee << 12) & 8191, Ke += Ee >>> 1 & 8191, Le = H[V + 10] & 255 | (H[V + 11] & 255) << 8, Fe += (Ee >>> 14 | Le << 2) & 8191, Ie = H[V + 12] & 255 | (H[V + 13] & 255) << 8, qe += (Le >>> 11 | Ie << 5) & 8191, Qe = H[V + 14] & 255 | (H[V + 15] & 255) << 8, Ye += (Ie >>> 8 | Qe << 8) & 8191, Lt += Qe >>> 5 | T, Xe = 0, tt = Xe, tt += yt * zt, tt += ut * (5 * lr), tt += it * (5 * mr), tt += Se * (5 * Qt), tt += Pe * (5 * gr), Xe = tt >>> 13, tt &= 8191, tt += Ke * (5 * pr), tt += Fe * (5 * nr), tt += qe * (5 * ge), tt += Ye * (5 * Ht), tt += Lt * (5 * Zt), Xe += tt >>> 13, tt &= 8191, st = Xe, st += yt * Zt, st += ut * zt, st += it * (5 * lr), st += Se * (5 * mr), st += Pe * (5 * Qt), Xe = st >>> 13, st &= 8191, st += Ke * (5 * gr), st += Fe * (5 * pr), st += qe * (5 * nr), st += Ye * (5 * ge), st += Lt * (5 * Ht), Xe += st >>> 13, st &= 8191, vt = Xe, vt += yt * Ht, vt += ut * Zt, vt += it * zt, vt += Se * (5 * lr), vt += Pe * (5 * mr), Xe = vt >>> 13, vt &= 8191, vt += Ke * (5 * Qt), vt += Fe * (5 * gr), vt += qe * (5 * pr), vt += Ye * (5 * nr), vt += Lt * (5 * ge), Xe += vt >>> 13, vt &= 8191, Ct = Xe, Ct += yt * ge, Ct += ut * Ht, Ct += it * Zt, Ct += Se * zt, Ct += Pe * (5 * lr), Xe = Ct >>> 13, Ct &= 8191, Ct += Ke * (5 * mr), Ct += Fe * (5 * Qt), Ct += qe * (5 * gr), Ct += Ye * (5 * pr), Ct += Lt * (5 * nr), Xe += Ct >>> 13, Ct &= 8191, Mt = Xe, Mt += yt * nr, Mt += ut * ge, Mt += it * Ht, Mt += Se * Zt, Mt += Pe * zt, Xe = Mt >>> 13, Mt &= 8191, Mt += Ke * (5 * lr), Mt += Fe * (5 * mr), Mt += qe * (5 * Qt), Mt += Ye * (5 * gr), Mt += Lt * (5 * pr), Xe += Mt >>> 13, Mt &= 8191, wt = Xe, wt += yt * pr, wt += ut * nr, wt += it * ge, wt += Se * Ht, wt += Pe * Zt, Xe = wt >>> 13, wt &= 8191, wt += Ke * zt, wt += Fe * (5 * lr), wt += qe * (5 * mr), wt += Ye * (5 * Qt), wt += Lt * (5 * gr), Xe += wt >>> 13, wt &= 8191, Rt = Xe, Rt += yt * gr, Rt += ut * pr, Rt += it * nr, Rt += Se * ge, Rt += Pe * Ht, Xe = Rt >>> 13, Rt &= 8191, Rt += Ke * Zt, Rt += Fe * zt, Rt += qe * (5 * lr), Rt += Ye * (5 * mr), Rt += Lt * (5 * Qt), Xe += Rt >>> 13, Rt &= 8191, gt = Xe, gt += yt * Qt, gt += ut * gr, gt += it * pr, gt += Se * nr, gt += Pe * ge, Xe = gt >>> 13, gt &= 8191, gt += Ke * Ht, gt += Fe * Zt, gt += qe * zt, gt += Ye * (5 * lr), gt += Lt * (5 * mr), Xe += gt >>> 13, gt &= 8191, _t = Xe, _t += yt * mr, _t += ut * Qt, _t += it * gr, _t += Se * pr, _t += Pe * nr, Xe = _t >>> 13, _t &= 8191, _t += Ke * ge, _t += Fe * Ht, _t += qe * Zt, _t += Ye * zt, _t += Lt * (5 * lr), Xe += _t >>> 13, _t &= 8191, at = Xe, at += yt * lr, at += ut * mr, at += it * Qt, at += Se * gr, at += Pe * pr, Xe = at >>> 13, at &= 8191, at += Ke * nr, at += Fe * ge, at += qe * Ht, at += Ye * Zt, at += Lt * zt, Xe += at >>> 13, at &= 8191, Xe = (Xe << 2) + Xe | 0, Xe = Xe + tt | 0, tt = Xe & 8191, Xe = Xe >>> 13, st += Xe, yt = tt, ut = st, it = vt, Se = Ct, Pe = Mt, Ke = wt, Fe = Rt, qe = gt, Ye = _t, Lt = at, V += 16, Y -= 16; + this.h[0] = yt, this.h[1] = ut, this.h[2] = it, this.h[3] = Se, this.h[4] = Pe, this.h[5] = Ke, this.h[6] = Fe, this.h[7] = qe, this.h[8] = Ye, this.h[9] = Lt; + }, K.prototype.finish = function(H, V) { + var Y = new Uint16Array(10), T, F, ie, le; + if (this.leftover) { + for (le = this.leftover, this.buffer[le++] = 1; le < 16; le++) this.buffer[le] = 0; + this.fin = 1, this.blocks(this.buffer, 0, 16); + } + for (T = this.h[1] >>> 13, this.h[1] &= 8191, le = 2; le < 10; le++) + this.h[le] += T, T = this.h[le] >>> 13, this.h[le] &= 8191; + for (this.h[0] += T * 5, T = this.h[0] >>> 13, this.h[0] &= 8191, this.h[1] += T, T = this.h[1] >>> 13, this.h[1] &= 8191, this.h[2] += T, Y[0] = this.h[0] + 5, T = Y[0] >>> 13, Y[0] &= 8191, le = 1; le < 10; le++) + Y[le] = this.h[le] + T, T = Y[le] >>> 13, Y[le] &= 8191; + for (Y[9] -= 8192, F = (T ^ 1) - 1, le = 0; le < 10; le++) Y[le] &= F; + for (F = ~F, le = 0; le < 10; le++) this.h[le] = this.h[le] & F | Y[le]; + 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, ie = this.h[0] + this.pad[0], this.h[0] = ie & 65535, le = 1; le < 8; le++) + ie = (this.h[le] + this.pad[le] | 0) + (ie >>> 16) | 0, this.h[le] = ie & 65535; + H[V + 0] = this.h[0] >>> 0 & 255, H[V + 1] = this.h[0] >>> 8 & 255, H[V + 2] = this.h[1] >>> 0 & 255, H[V + 3] = this.h[1] >>> 8 & 255, H[V + 4] = this.h[2] >>> 0 & 255, H[V + 5] = this.h[2] >>> 8 & 255, H[V + 6] = this.h[3] >>> 0 & 255, H[V + 7] = this.h[3] >>> 8 & 255, H[V + 8] = this.h[4] >>> 0 & 255, H[V + 9] = this.h[4] >>> 8 & 255, H[V + 10] = this.h[5] >>> 0 & 255, H[V + 11] = this.h[5] >>> 8 & 255, H[V + 12] = this.h[6] >>> 0 & 255, H[V + 13] = this.h[6] >>> 8 & 255, H[V + 14] = this.h[7] >>> 0 & 255, H[V + 15] = this.h[7] >>> 8 & 255; + }, K.prototype.update = function(H, V, Y) { + var T, F; + if (this.leftover) { + for (F = 16 - this.leftover, F > Y && (F = Y), T = 0; T < F; T++) + this.buffer[this.leftover + T] = H[V + T]; + if (Y -= F, V += F, this.leftover += F, this.leftover < 16) + return; + this.blocks(this.buffer, 0, 16), this.leftover = 0; + } + if (Y >= 16 && (F = Y - Y % 16, this.blocks(H, V, F), V += F, Y -= F), Y) { + for (T = 0; T < Y; T++) + this.buffer[this.leftover + T] = H[V + T]; + this.leftover += Y; + } + }; + function E(H, V, Y, T, F, ie) { + var le = new K(ie); + return le.update(Y, T, F), le.finish(H, V), 0; + } + function b(H, V, Y, T, F, ie) { + var le = new Uint8Array(16); + return E(le, 0, Y, T, F, ie), D(H, V, le, 0); + } + function l(H, V, Y, T, F) { + var ie; + if (Y < 32) return -1; + for (ne(H, 0, V, 0, Y, T, F), E(H, 16, H, 32, Y - 32, H), ie = 0; ie < 16; ie++) H[ie] = 0; + return 0; + } + function p(H, V, Y, T, F) { + var ie, le = new Uint8Array(32); + if (Y < 32 || (J(le, 0, 32, T, F), b(V, 16, V, 32, Y - 32, le) !== 0)) return -1; + for (ne(H, 0, V, 0, Y, T, F), ie = 0; ie < 32; ie++) H[ie] = 0; + return 0; + } + function m(H, V) { + var Y; + for (Y = 0; Y < 16; Y++) H[Y] = V[Y] | 0; + } + function w(H) { + var V, Y, T = 1; + for (V = 0; V < 16; V++) + Y = H[V] + T + 65535, T = Math.floor(Y / 65536), H[V] = Y - T * 65536; + H[0] += T - 1 + 37 * (T - 1); + } + function P(H, V, Y) { + for (var T, F = ~(Y - 1), ie = 0; ie < 16; ie++) + T = F & (H[ie] ^ V[ie]), H[ie] ^= T, V[ie] ^= T; + } + function _(H, V) { + var Y, T, F, ie = r(), le = r(); + for (Y = 0; Y < 16; Y++) le[Y] = V[Y]; + for (w(le), w(le), w(le), T = 0; T < 2; T++) { + for (ie[0] = le[0] - 65517, Y = 1; Y < 15; Y++) + ie[Y] = le[Y] - 65535 - (ie[Y - 1] >> 16 & 1), ie[Y - 1] &= 65535; + ie[15] = le[15] - 32767 - (ie[14] >> 16 & 1), F = ie[15] >> 16 & 1, ie[14] &= 65535, P(le, ie, 1 - F); + } + for (Y = 0; Y < 16; Y++) + H[2 * Y] = le[Y] & 255, H[2 * Y + 1] = le[Y] >> 8; + } + function y(H, V) { + var Y = new Uint8Array(32), T = new Uint8Array(32); + return _(Y, H), _(T, V), k(Y, 0, T, 0); + } + function M(H) { + var V = new Uint8Array(32); + return _(V, H), V[0] & 1; + } + function I(H, V) { + var Y; + for (Y = 0; Y < 16; Y++) H[Y] = V[2 * Y] + (V[2 * Y + 1] << 8); + H[15] &= 32767; + } + function q(H, V, Y) { + for (var T = 0; T < 16; T++) H[T] = V[T] + Y[T]; + } + function ce(H, V, Y) { + for (var T = 0; T < 16; T++) H[T] = V[T] - Y[T]; + } + function L(H, V, Y) { + var T, F, ie = 0, le = 0, me = 0, Ee = 0, Le = 0, Ie = 0, Qe = 0, Xe = 0, tt = 0, st = 0, vt = 0, Ct = 0, Mt = 0, wt = 0, Rt = 0, gt = 0, _t = 0, at = 0, yt = 0, ut = 0, it = 0, Se = 0, Pe = 0, Ke = 0, Fe = 0, qe = 0, Ye = 0, Lt = 0, zt = 0, Zt = 0, Ht = 0, ge = Y[0], nr = Y[1], pr = Y[2], gr = Y[3], Qt = Y[4], mr = Y[5], lr = Y[6], Tr = Y[7], vr = Y[8], xr = Y[9], $r = Y[10], Br = Y[11], Ir = Y[12], rn = Y[13], nn = Y[14], sn = Y[15]; + T = V[0], ie += T * ge, le += T * nr, me += T * pr, Ee += T * gr, Le += T * Qt, Ie += T * mr, Qe += T * lr, Xe += T * Tr, tt += T * vr, st += T * xr, vt += T * $r, Ct += T * Br, Mt += T * Ir, wt += T * rn, Rt += T * nn, gt += T * sn, T = V[1], le += T * ge, me += T * nr, Ee += T * pr, Le += T * gr, Ie += T * Qt, Qe += T * mr, Xe += T * lr, tt += T * Tr, st += T * vr, vt += T * xr, Ct += T * $r, Mt += T * Br, wt += T * Ir, Rt += T * rn, gt += T * nn, _t += T * sn, T = V[2], me += T * ge, Ee += T * nr, Le += T * pr, Ie += T * gr, Qe += T * Qt, Xe += T * mr, tt += T * lr, st += T * Tr, vt += T * vr, Ct += T * xr, Mt += T * $r, wt += T * Br, Rt += T * Ir, gt += T * rn, _t += T * nn, at += T * sn, T = V[3], Ee += T * ge, Le += T * nr, Ie += T * pr, Qe += T * gr, Xe += T * Qt, tt += T * mr, st += T * lr, vt += T * Tr, Ct += T * vr, Mt += T * xr, wt += T * $r, Rt += T * Br, gt += T * Ir, _t += T * rn, at += T * nn, yt += T * sn, T = V[4], Le += T * ge, Ie += T * nr, Qe += T * pr, Xe += T * gr, tt += T * Qt, st += T * mr, vt += T * lr, Ct += T * Tr, Mt += T * vr, wt += T * xr, Rt += T * $r, gt += T * Br, _t += T * Ir, at += T * rn, yt += T * nn, ut += T * sn, T = V[5], Ie += T * ge, Qe += T * nr, Xe += T * pr, tt += T * gr, st += T * Qt, vt += T * mr, Ct += T * lr, Mt += T * Tr, wt += T * vr, Rt += T * xr, gt += T * $r, _t += T * Br, at += T * Ir, yt += T * rn, ut += T * nn, it += T * sn, T = V[6], Qe += T * ge, Xe += T * nr, tt += T * pr, st += T * gr, vt += T * Qt, Ct += T * mr, Mt += T * lr, wt += T * Tr, Rt += T * vr, gt += T * xr, _t += T * $r, at += T * Br, yt += T * Ir, ut += T * rn, it += T * nn, Se += T * sn, T = V[7], Xe += T * ge, tt += T * nr, st += T * pr, vt += T * gr, Ct += T * Qt, Mt += T * mr, wt += T * lr, Rt += T * Tr, gt += T * vr, _t += T * xr, at += T * $r, yt += T * Br, ut += T * Ir, it += T * rn, Se += T * nn, Pe += T * sn, T = V[8], tt += T * ge, st += T * nr, vt += T * pr, Ct += T * gr, Mt += T * Qt, wt += T * mr, Rt += T * lr, gt += T * Tr, _t += T * vr, at += T * xr, yt += T * $r, ut += T * Br, it += T * Ir, Se += T * rn, Pe += T * nn, Ke += T * sn, T = V[9], st += T * ge, vt += T * nr, Ct += T * pr, Mt += T * gr, wt += T * Qt, Rt += T * mr, gt += T * lr, _t += T * Tr, at += T * vr, yt += T * xr, ut += T * $r, it += T * Br, Se += T * Ir, Pe += T * rn, Ke += T * nn, Fe += T * sn, T = V[10], vt += T * ge, Ct += T * nr, Mt += T * pr, wt += T * gr, Rt += T * Qt, gt += T * mr, _t += T * lr, at += T * Tr, yt += T * vr, ut += T * xr, it += T * $r, Se += T * Br, Pe += T * Ir, Ke += T * rn, Fe += T * nn, qe += T * sn, T = V[11], Ct += T * ge, Mt += T * nr, wt += T * pr, Rt += T * gr, gt += T * Qt, _t += T * mr, at += T * lr, yt += T * Tr, ut += T * vr, it += T * xr, Se += T * $r, Pe += T * Br, Ke += T * Ir, Fe += T * rn, qe += T * nn, Ye += T * sn, T = V[12], Mt += T * ge, wt += T * nr, Rt += T * pr, gt += T * gr, _t += T * Qt, at += T * mr, yt += T * lr, ut += T * Tr, it += T * vr, Se += T * xr, Pe += T * $r, Ke += T * Br, Fe += T * Ir, qe += T * rn, Ye += T * nn, Lt += T * sn, T = V[13], wt += T * ge, Rt += T * nr, gt += T * pr, _t += T * gr, at += T * Qt, yt += T * mr, ut += T * lr, it += T * Tr, Se += T * vr, Pe += T * xr, Ke += T * $r, Fe += T * Br, qe += T * Ir, Ye += T * rn, Lt += T * nn, zt += T * sn, T = V[14], Rt += T * ge, gt += T * nr, _t += T * pr, at += T * gr, yt += T * Qt, ut += T * mr, it += T * lr, Se += T * Tr, Pe += T * vr, Ke += T * xr, Fe += T * $r, qe += T * Br, Ye += T * Ir, Lt += T * rn, zt += T * nn, Zt += T * sn, T = V[15], gt += T * ge, _t += T * nr, at += T * pr, yt += T * gr, ut += T * Qt, it += T * mr, Se += T * lr, Pe += T * Tr, Ke += T * vr, Fe += T * xr, qe += T * $r, Ye += T * Br, Lt += T * Ir, zt += T * rn, Zt += T * nn, Ht += T * sn, ie += 38 * _t, le += 38 * at, me += 38 * yt, Ee += 38 * ut, Le += 38 * it, Ie += 38 * Se, Qe += 38 * Pe, Xe += 38 * Ke, tt += 38 * Fe, st += 38 * qe, vt += 38 * Ye, Ct += 38 * Lt, Mt += 38 * zt, wt += 38 * Zt, Rt += 38 * Ht, F = 1, T = ie + F + 65535, F = Math.floor(T / 65536), ie = T - F * 65536, T = le + F + 65535, F = Math.floor(T / 65536), le = T - F * 65536, T = me + F + 65535, F = Math.floor(T / 65536), me = T - F * 65536, T = Ee + F + 65535, F = Math.floor(T / 65536), Ee = T - F * 65536, T = Le + F + 65535, F = Math.floor(T / 65536), Le = T - F * 65536, T = Ie + F + 65535, F = Math.floor(T / 65536), Ie = T - F * 65536, T = Qe + F + 65535, F = Math.floor(T / 65536), Qe = T - F * 65536, T = Xe + F + 65535, F = Math.floor(T / 65536), Xe = T - F * 65536, T = tt + F + 65535, F = Math.floor(T / 65536), tt = T - F * 65536, T = st + F + 65535, F = Math.floor(T / 65536), st = T - F * 65536, T = vt + F + 65535, F = Math.floor(T / 65536), vt = T - F * 65536, T = Ct + F + 65535, F = Math.floor(T / 65536), Ct = T - F * 65536, T = Mt + F + 65535, F = Math.floor(T / 65536), Mt = T - F * 65536, T = wt + F + 65535, F = Math.floor(T / 65536), wt = T - F * 65536, T = Rt + F + 65535, F = Math.floor(T / 65536), Rt = T - F * 65536, T = gt + F + 65535, F = Math.floor(T / 65536), gt = T - F * 65536, ie += F - 1 + 37 * (F - 1), F = 1, T = ie + F + 65535, F = Math.floor(T / 65536), ie = T - F * 65536, T = le + F + 65535, F = Math.floor(T / 65536), le = T - F * 65536, T = me + F + 65535, F = Math.floor(T / 65536), me = T - F * 65536, T = Ee + F + 65535, F = Math.floor(T / 65536), Ee = T - F * 65536, T = Le + F + 65535, F = Math.floor(T / 65536), Le = T - F * 65536, T = Ie + F + 65535, F = Math.floor(T / 65536), Ie = T - F * 65536, T = Qe + F + 65535, F = Math.floor(T / 65536), Qe = T - F * 65536, T = Xe + F + 65535, F = Math.floor(T / 65536), Xe = T - F * 65536, T = tt + F + 65535, F = Math.floor(T / 65536), tt = T - F * 65536, T = st + F + 65535, F = Math.floor(T / 65536), st = T - F * 65536, T = vt + F + 65535, F = Math.floor(T / 65536), vt = T - F * 65536, T = Ct + F + 65535, F = Math.floor(T / 65536), Ct = T - F * 65536, T = Mt + F + 65535, F = Math.floor(T / 65536), Mt = T - F * 65536, T = wt + F + 65535, F = Math.floor(T / 65536), wt = T - F * 65536, T = Rt + F + 65535, F = Math.floor(T / 65536), Rt = T - F * 65536, T = gt + F + 65535, F = Math.floor(T / 65536), gt = T - F * 65536, ie += F - 1 + 37 * (F - 1), H[0] = ie, H[1] = le, H[2] = me, H[3] = Ee, H[4] = Le, H[5] = Ie, H[6] = Qe, H[7] = Xe, H[8] = tt, H[9] = st, H[10] = vt, H[11] = Ct, H[12] = Mt, H[13] = wt, H[14] = Rt, H[15] = gt; + } + function oe(H, V) { + L(H, V, V); + } + function Q(H, V) { + var Y = r(), T; + for (T = 0; T < 16; T++) Y[T] = V[T]; + for (T = 253; T >= 0; T--) + oe(Y, Y), T !== 2 && T !== 4 && L(Y, Y, V); + for (T = 0; T < 16; T++) H[T] = Y[T]; + } + function X(H, V) { + var Y = r(), T; + for (T = 0; T < 16; T++) Y[T] = V[T]; + for (T = 250; T >= 0; T--) + oe(Y, Y), T !== 1 && L(Y, Y, V); + for (T = 0; T < 16; T++) H[T] = Y[T]; + } + function ee(H, V, Y) { + var T = new Uint8Array(32), F = new Float64Array(80), ie, le, me = r(), Ee = r(), Le = r(), Ie = r(), Qe = r(), Xe = r(); + for (le = 0; le < 31; le++) T[le] = V[le]; + for (T[31] = V[31] & 127 | 64, T[0] &= 248, I(F, Y), le = 0; le < 16; le++) + Ee[le] = F[le], Ie[le] = me[le] = Le[le] = 0; + for (me[0] = Ie[0] = 1, le = 254; le >= 0; --le) + ie = T[le >>> 3] >>> (le & 7) & 1, P(me, Ee, ie), P(Le, Ie, ie), q(Qe, me, Le), ce(me, me, Le), q(Le, Ee, Ie), ce(Ee, Ee, Ie), oe(Ie, Qe), oe(Xe, me), L(me, Le, me), L(Le, Ee, Qe), q(Qe, me, Le), ce(me, me, Le), oe(Ee, me), ce(Le, Ie, Xe), L(me, Le, f), q(me, me, Ie), L(Le, Le, me), L(me, Ie, Xe), L(Ie, Ee, F), oe(Ee, Qe), P(me, Ee, ie), P(Le, Ie, ie); + for (le = 0; le < 16; le++) + F[le + 16] = me[le], F[le + 32] = Le[le], F[le + 48] = Ee[le], F[le + 64] = Ie[le]; + var tt = F.subarray(32), st = F.subarray(16); + return Q(tt, tt), L(st, st, tt), _(H, st), 0; + } + function O(H, V) { + return ee(H, V, s); + } + function Z(H, V) { + return n(V, 32), O(H, V); + } + function re(H, V, Y) { + var T = new Uint8Array(32); + return ee(T, Y, V), $(H, i, T, U); + } + var he = l, ae = p; + function fe(H, V, Y, T, F, ie) { + var le = new Uint8Array(32); + return re(le, F, ie), he(H, V, Y, T, le); + } + function be(H, V, Y, T, F, ie) { + var le = new Uint8Array(32); + return re(le, F, ie), ae(H, V, Y, T, le); + } + var Ae = [ + 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 Te(H, V, Y, T) { + for (var F = new Int32Array(16), ie = new Int32Array(16), le, me, Ee, Le, Ie, Qe, Xe, tt, st, vt, Ct, Mt, wt, Rt, gt, _t, at, yt, ut, it, Se, Pe, Ke, Fe, qe, Ye, Lt = H[0], zt = H[1], Zt = H[2], Ht = H[3], ge = H[4], nr = H[5], pr = H[6], gr = H[7], Qt = V[0], mr = V[1], lr = V[2], Tr = V[3], vr = V[4], xr = V[5], $r = V[6], Br = V[7], Ir = 0; T >= 128; ) { + for (ut = 0; ut < 16; ut++) + it = 8 * ut + Ir, F[ut] = Y[it + 0] << 24 | Y[it + 1] << 16 | Y[it + 2] << 8 | Y[it + 3], ie[ut] = Y[it + 4] << 24 | Y[it + 5] << 16 | Y[it + 6] << 8 | Y[it + 7]; + for (ut = 0; ut < 80; ut++) + if (le = Lt, me = zt, Ee = Zt, Le = Ht, Ie = ge, Qe = nr, Xe = pr, tt = gr, st = Qt, vt = mr, Ct = lr, Mt = Tr, wt = vr, Rt = xr, gt = $r, _t = Br, Se = gr, Pe = Br, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = (ge >>> 14 | vr << 18) ^ (ge >>> 18 | vr << 14) ^ (vr >>> 9 | ge << 23), Pe = (vr >>> 14 | ge << 18) ^ (vr >>> 18 | ge << 14) ^ (ge >>> 9 | vr << 23), Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Se = ge & nr ^ ~ge & pr, Pe = vr & xr ^ ~vr & $r, Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Se = Ae[ut * 2], Pe = Ae[ut * 2 + 1], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Se = F[ut % 16], Pe = ie[ut % 16], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, at = qe & 65535 | Ye << 16, yt = Ke & 65535 | Fe << 16, Se = at, Pe = yt, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = (Lt >>> 28 | Qt << 4) ^ (Qt >>> 2 | Lt << 30) ^ (Qt >>> 7 | Lt << 25), Pe = (Qt >>> 28 | Lt << 4) ^ (Lt >>> 2 | Qt << 30) ^ (Lt >>> 7 | Qt << 25), Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Se = Lt & zt ^ Lt & Zt ^ zt & Zt, Pe = Qt & mr ^ Qt & lr ^ mr & lr, Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, tt = qe & 65535 | Ye << 16, _t = Ke & 65535 | Fe << 16, Se = Le, Pe = Mt, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = at, Pe = yt, Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, Le = qe & 65535 | Ye << 16, Mt = Ke & 65535 | Fe << 16, zt = le, Zt = me, Ht = Ee, ge = Le, nr = Ie, pr = Qe, gr = Xe, Lt = tt, mr = st, lr = vt, Tr = Ct, vr = Mt, xr = wt, $r = Rt, Br = gt, Qt = _t, ut % 16 === 15) + for (it = 0; it < 16; it++) + Se = F[it], Pe = ie[it], Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = F[(it + 9) % 16], Pe = ie[(it + 9) % 16], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, at = F[(it + 1) % 16], yt = ie[(it + 1) % 16], Se = (at >>> 1 | yt << 31) ^ (at >>> 8 | yt << 24) ^ at >>> 7, Pe = (yt >>> 1 | at << 31) ^ (yt >>> 8 | at << 24) ^ (yt >>> 7 | at << 25), Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, at = F[(it + 14) % 16], yt = ie[(it + 14) % 16], Se = (at >>> 19 | yt << 13) ^ (yt >>> 29 | at << 3) ^ at >>> 6, Pe = (yt >>> 19 | at << 13) ^ (at >>> 29 | yt << 3) ^ (yt >>> 6 | at << 26), Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, F[it] = qe & 65535 | Ye << 16, ie[it] = Ke & 65535 | Fe << 16; + Se = Lt, Pe = Qt, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = H[0], Pe = V[0], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, H[0] = Lt = qe & 65535 | Ye << 16, V[0] = Qt = Ke & 65535 | Fe << 16, Se = zt, Pe = mr, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = H[1], Pe = V[1], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, H[1] = zt = qe & 65535 | Ye << 16, V[1] = mr = Ke & 65535 | Fe << 16, Se = Zt, Pe = lr, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = H[2], Pe = V[2], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, H[2] = Zt = qe & 65535 | Ye << 16, V[2] = lr = Ke & 65535 | Fe << 16, Se = Ht, Pe = Tr, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = H[3], Pe = V[3], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, H[3] = Ht = qe & 65535 | Ye << 16, V[3] = Tr = Ke & 65535 | Fe << 16, Se = ge, Pe = vr, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = H[4], Pe = V[4], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, H[4] = ge = qe & 65535 | Ye << 16, V[4] = vr = Ke & 65535 | Fe << 16, Se = nr, Pe = xr, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = H[5], Pe = V[5], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, H[5] = nr = qe & 65535 | Ye << 16, V[5] = xr = Ke & 65535 | Fe << 16, Se = pr, Pe = $r, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = H[6], Pe = V[6], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, H[6] = pr = qe & 65535 | Ye << 16, V[6] = $r = Ke & 65535 | Fe << 16, Se = gr, Pe = Br, Ke = Pe & 65535, Fe = Pe >>> 16, qe = Se & 65535, Ye = Se >>> 16, Se = H[7], Pe = V[7], Ke += Pe & 65535, Fe += Pe >>> 16, qe += Se & 65535, Ye += Se >>> 16, Fe += Ke >>> 16, qe += Fe >>> 16, Ye += qe >>> 16, H[7] = gr = qe & 65535 | Ye << 16, V[7] = Br = Ke & 65535 | Fe << 16, Ir += 128, T -= 128; + } + return T; + } + function Re(H, V, Y) { + var T = new Int32Array(8), F = new Int32Array(8), ie = new Uint8Array(256), le, me = Y; + for (T[0] = 1779033703, T[1] = 3144134277, T[2] = 1013904242, T[3] = 2773480762, T[4] = 1359893119, T[5] = 2600822924, T[6] = 528734635, T[7] = 1541459225, F[0] = 4089235720, F[1] = 2227873595, F[2] = 4271175723, F[3] = 1595750129, F[4] = 2917565137, F[5] = 725511199, F[6] = 4215389547, F[7] = 327033209, Te(T, F, V, Y), Y %= 128, le = 0; le < Y; le++) ie[le] = V[me - Y + le]; + for (ie[Y] = 128, Y = 256 - 128 * (Y < 112 ? 1 : 0), ie[Y - 9] = 0, S(ie, Y - 8, me / 536870912 | 0, me << 3), Te(T, F, ie, Y), le = 0; le < 8; le++) S(H, 8 * le, T[le], F[le]); + return 0; + } + function $e(H, V) { + var Y = r(), T = r(), F = r(), ie = r(), le = r(), me = r(), Ee = r(), Le = r(), Ie = r(); + ce(Y, H[1], H[0]), ce(Ie, V[1], V[0]), L(Y, Y, Ie), q(T, H[0], H[1]), q(Ie, V[0], V[1]), L(T, T, Ie), L(F, H[3], V[3]), L(F, F, h), L(ie, H[2], V[2]), q(ie, ie, ie), ce(le, T, Y), ce(me, ie, F), q(Ee, ie, F), q(Le, T, Y), L(H[0], le, me), L(H[1], Le, Ee), L(H[2], Ee, me), L(H[3], le, Le); + } + function Me(H, V, Y) { + var T; + for (T = 0; T < 4; T++) + P(H[T], V[T], Y); + } + function Oe(H, V) { + var Y = r(), T = r(), F = r(); + Q(F, V[2]), L(Y, V[0], F), L(T, V[1], F), _(H, T), H[31] ^= M(Y) << 7; + } + function ze(H, V, Y) { + var T, F; + for (m(H[0], o), m(H[1], a), m(H[2], a), m(H[3], o), F = 255; F >= 0; --F) + T = Y[F / 8 | 0] >> (F & 7) & 1, Me(H, V, T), $e(V, H), $e(H, H), Me(H, V, T); + } + function De(H, V) { + var Y = [r(), r(), r(), r()]; + m(Y[0], g), m(Y[1], v), m(Y[2], a), L(Y[3], g, v), ze(H, Y, V); + } + function je(H, V, Y) { + var T = new Uint8Array(64), F = [r(), r(), r(), r()], ie; + for (Y || n(V, 32), Re(T, V, 32), T[0] &= 248, T[31] &= 127, T[31] |= 64, De(F, T), Oe(H, F), ie = 0; ie < 32; ie++) V[ie + 32] = H[ie]; + return 0; + } + var Ue = 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 _e(H, V) { + var Y, T, F, ie; + for (T = 63; T >= 32; --T) { + for (Y = 0, F = T - 32, ie = T - 12; F < ie; ++F) + V[F] += Y - 16 * V[T] * Ue[F - (T - 32)], Y = Math.floor((V[F] + 128) / 256), V[F] -= Y * 256; + V[F] += Y, V[T] = 0; + } + for (Y = 0, F = 0; F < 32; F++) + V[F] += Y - (V[31] >> 4) * Ue[F], Y = V[F] >> 8, V[F] &= 255; + for (F = 0; F < 32; F++) V[F] -= Y * Ue[F]; + for (T = 0; T < 32; T++) + V[T + 1] += V[T] >> 8, H[T] = V[T] & 255; + } + function Ze(H) { + var V = new Float64Array(64), Y; + for (Y = 0; Y < 64; Y++) V[Y] = H[Y]; + for (Y = 0; Y < 64; Y++) H[Y] = 0; + _e(H, V); + } + function ot(H, V, Y, T) { + var F = new Uint8Array(64), ie = new Uint8Array(64), le = new Uint8Array(64), me, Ee, Le = new Float64Array(64), Ie = [r(), r(), r(), r()]; + Re(F, T, 32), F[0] &= 248, F[31] &= 127, F[31] |= 64; + var Qe = Y + 64; + for (me = 0; me < Y; me++) H[64 + me] = V[me]; + for (me = 0; me < 32; me++) H[32 + me] = F[32 + me]; + for (Re(le, H.subarray(32), Y + 32), Ze(le), De(Ie, le), Oe(H, Ie), me = 32; me < 64; me++) H[me] = T[me]; + for (Re(ie, H, Y + 64), Ze(ie), me = 0; me < 64; me++) Le[me] = 0; + for (me = 0; me < 32; me++) Le[me] = le[me]; + for (me = 0; me < 32; me++) + for (Ee = 0; Ee < 32; Ee++) + Le[me + Ee] += ie[me] * F[Ee]; + return _e(H.subarray(32), Le), Qe; + } + function ke(H, V) { + var Y = r(), T = r(), F = r(), ie = r(), le = r(), me = r(), Ee = r(); + return m(H[2], a), I(H[1], V), oe(F, H[1]), L(ie, F, u), ce(F, F, H[2]), q(ie, H[2], ie), oe(le, ie), oe(me, le), L(Ee, me, le), L(Y, Ee, F), L(Y, Y, ie), X(Y, Y), L(Y, Y, F), L(Y, Y, ie), L(Y, Y, ie), L(H[0], Y, ie), oe(T, H[0]), L(T, T, ie), y(T, F) && L(H[0], H[0], x), oe(T, H[0]), L(T, T, ie), y(T, F) ? -1 : (M(H[0]) === V[31] >> 7 && ce(H[0], o, H[0]), L(H[3], H[0], H[1]), 0); + } + function rt(H, V, Y, T) { + var F, ie = new Uint8Array(32), le = new Uint8Array(64), me = [r(), r(), r(), r()], Ee = [r(), r(), r(), r()]; + if (Y < 64 || ke(Ee, T)) return -1; + for (F = 0; F < Y; F++) H[F] = V[F]; + for (F = 0; F < 32; F++) H[F + 32] = T[F]; + if (Re(le, H, Y), Ze(le), ze(me, Ee, le), De(Ee, V.subarray(32)), $e(me, Ee), Oe(ie, me), Y -= 64, k(V, 0, ie, 0)) { + for (F = 0; F < Y; F++) H[F] = 0; + return -1; + } + for (F = 0; F < Y; F++) H[F] = V[F + 64]; + return Y; + } + var nt = 32, Ge = 24, ht = 32, lt = 16, ct = 32, qt = 32, Gt = 32, Et = 32, Yt = 32, tr = Ge, Tt = ht, kt = lt, It = 64, dt = 32, Dt = 64, Nt = 32, mt = 64; + e.lowlevel = { + crypto_core_hsalsa20: $, + crypto_stream_xor: ne, + crypto_stream: J, + crypto_stream_salsa20_xor: C, + crypto_stream_salsa20: W, + crypto_onetimeauth: E, + crypto_onetimeauth_verify: b, + crypto_verify_16: D, + crypto_verify_32: k, + crypto_secretbox: l, + crypto_secretbox_open: p, + crypto_scalarmult: ee, + crypto_scalarmult_base: O, + crypto_box_beforenm: re, + crypto_box_afternm: he, + crypto_box: fe, + crypto_box_open: be, + crypto_box_keypair: Z, + crypto_hash: Re, + crypto_sign: ot, + crypto_sign_keypair: je, + crypto_sign_open: rt, + crypto_secretbox_KEYBYTES: nt, + crypto_secretbox_NONCEBYTES: Ge, + crypto_secretbox_ZEROBYTES: ht, + crypto_secretbox_BOXZEROBYTES: lt, + crypto_scalarmult_BYTES: ct, + crypto_scalarmult_SCALARBYTES: qt, + crypto_box_PUBLICKEYBYTES: Gt, + crypto_box_SECRETKEYBYTES: Et, + crypto_box_BEFORENMBYTES: Yt, + crypto_box_NONCEBYTES: tr, + crypto_box_ZEROBYTES: Tt, + crypto_box_BOXZEROBYTES: kt, + crypto_sign_BYTES: It, + crypto_sign_PUBLICKEYBYTES: dt, + crypto_sign_SECRETKEYBYTES: Dt, + crypto_sign_SEEDBYTES: Nt, + crypto_hash_BYTES: mt, + gf: r, + D: u, + L: Ue, + pack25519: _, + unpack25519: I, + M: L, + A: q, + S: oe, + Z: ce, + pow2523: X, + add: $e, + set25519: m, + modL: _e, + scalarmult: ze, + scalarbase: De + }; + function Bt(H, V) { + if (H.length !== nt) throw new Error("bad key size"); + if (V.length !== Ge) throw new Error("bad nonce size"); + } + function Ft(H, V) { + if (H.length !== Gt) throw new Error("bad public key size"); + if (V.length !== Et) throw new Error("bad secret key size"); + } + function et() { + for (var H = 0; H < arguments.length; H++) + if (!(arguments[H] instanceof Uint8Array)) + throw new TypeError("unexpected type, use Uint8Array"); + } + function $t(H) { + for (var V = 0; V < H.length; V++) H[V] = 0; + } + e.randomBytes = function(H) { + var V = new Uint8Array(H); + return n(V, H), V; + }, e.secretbox = function(H, V, Y) { + et(H, V, Y), Bt(Y, V); + for (var T = new Uint8Array(ht + H.length), F = new Uint8Array(T.length), ie = 0; ie < H.length; ie++) T[ie + ht] = H[ie]; + return l(F, T, T.length, V, Y), F.subarray(lt); + }, e.secretbox.open = function(H, V, Y) { + et(H, V, Y), Bt(Y, V); + for (var T = new Uint8Array(lt + H.length), F = new Uint8Array(T.length), ie = 0; ie < H.length; ie++) T[ie + lt] = H[ie]; + return T.length < 32 || p(F, T, T.length, V, Y) !== 0 ? null : F.subarray(ht); + }, e.secretbox.keyLength = nt, e.secretbox.nonceLength = Ge, e.secretbox.overheadLength = lt, e.scalarMult = function(H, V) { + if (et(H, V), H.length !== qt) throw new Error("bad n size"); + if (V.length !== ct) throw new Error("bad p size"); + var Y = new Uint8Array(ct); + return ee(Y, H, V), Y; + }, e.scalarMult.base = function(H) { + if (et(H), H.length !== qt) throw new Error("bad n size"); + var V = new Uint8Array(ct); + return O(V, H), V; + }, e.scalarMult.scalarLength = qt, e.scalarMult.groupElementLength = ct, e.box = function(H, V, Y, T) { + var F = e.box.before(Y, T); + return e.secretbox(H, V, F); + }, e.box.before = function(H, V) { + et(H, V), Ft(H, V); + var Y = new Uint8Array(Yt); + return re(Y, H, V), Y; + }, e.box.after = e.secretbox, e.box.open = function(H, V, Y, T) { + var F = e.box.before(Y, T); + return e.secretbox.open(H, V, F); + }, e.box.open.after = e.secretbox.open, e.box.keyPair = function() { + var H = new Uint8Array(Gt), V = new Uint8Array(Et); + return Z(H, V), { publicKey: H, secretKey: V }; + }, e.box.keyPair.fromSecretKey = function(H) { + if (et(H), H.length !== Et) + throw new Error("bad secret key size"); + var V = new Uint8Array(Gt); + return O(V, H), { publicKey: V, secretKey: new Uint8Array(H) }; + }, e.box.publicKeyLength = Gt, e.box.secretKeyLength = Et, e.box.sharedKeyLength = Yt, e.box.nonceLength = tr, e.box.overheadLength = e.secretbox.overheadLength, e.sign = function(H, V) { + if (et(H, V), V.length !== Dt) + throw new Error("bad secret key size"); + var Y = new Uint8Array(It + H.length); + return ot(Y, H, H.length, V), Y; + }, e.sign.open = function(H, V) { + if (et(H, V), V.length !== dt) + throw new Error("bad public key size"); + var Y = new Uint8Array(H.length), T = rt(Y, H, H.length, V); + if (T < 0) return null; + for (var F = new Uint8Array(T), ie = 0; ie < F.length; ie++) F[ie] = Y[ie]; + return F; + }, e.sign.detached = function(H, V) { + for (var Y = e.sign(H, V), T = new Uint8Array(It), F = 0; F < T.length; F++) T[F] = Y[F]; + return T; + }, e.sign.detached.verify = function(H, V, Y) { + if (et(H, V, Y), V.length !== It) + throw new Error("bad signature size"); + if (Y.length !== dt) + throw new Error("bad public key size"); + var T = new Uint8Array(It + H.length), F = new Uint8Array(It + H.length), ie; + for (ie = 0; ie < It; ie++) T[ie] = V[ie]; + for (ie = 0; ie < H.length; ie++) T[ie + It] = H[ie]; + return rt(F, T, T.length, Y) >= 0; + }, e.sign.keyPair = function() { + var H = new Uint8Array(dt), V = new Uint8Array(Dt); + return je(H, V), { publicKey: H, secretKey: V }; + }, e.sign.keyPair.fromSecretKey = function(H) { + if (et(H), H.length !== Dt) + throw new Error("bad secret key size"); + for (var V = new Uint8Array(dt), Y = 0; Y < V.length; Y++) V[Y] = H[32 + Y]; + return { publicKey: V, secretKey: new Uint8Array(H) }; + }, e.sign.keyPair.fromSeed = function(H) { + if (et(H), H.length !== Nt) + throw new Error("bad seed size"); + for (var V = new Uint8Array(dt), Y = new Uint8Array(Dt), T = 0; T < 32; T++) Y[T] = H[T]; + return je(V, Y, !0), { publicKey: V, secretKey: Y }; + }, e.sign.publicKeyLength = dt, e.sign.secretKeyLength = Dt, e.sign.seedLength = Nt, e.sign.signatureLength = It, e.hash = function(H) { + et(H); + var V = new Uint8Array(mt); + return Re(V, H, H.length), V; + }, e.hash.hashLength = mt, e.verify = function(H, V) { + return et(H, V), H.length === 0 || V.length === 0 || H.length !== V.length ? !1 : R(H, 0, V, 0, H.length) === 0; + }, e.setPRNG = function(H) { + n = H; + }, (function() { + var H = typeof self < "u" ? self.crypto || self.msCrypto : null; + if (H && H.getRandomValues) { + var V = 65536; + e.setPRNG(function(Y, T) { + var F, ie = new Uint8Array(T); + for (F = 0; F < T; F += V) + H.getRandomValues(ie.subarray(F, F + Math.min(T - F, V))); + for (F = 0; F < T; F++) Y[F] = ie[F]; + $t(ie); + }); + } else typeof X4 < "u" && (H = Qf, H && H.randomBytes && e.setPRNG(function(Y, T) { + var F, ie = H.randomBytes(T); + for (F = 0; F < T; F++) Y[F] = ie[F]; + $t(ie); + })); + })(); + })(t.exports ? t.exports : self.nacl = self.nacl || {}); + })(Dm)), Dm.exports; +} +var cte = ate(); +const Dh = /* @__PURE__ */ Hi(cte); +var Lo; +(function(t) { + t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.BAD_REQUEST_ERROR = 1] = "BAD_REQUEST_ERROR", t[t.MANIFEST_NOT_FOUND_ERROR = 2] = "MANIFEST_NOT_FOUND_ERROR", t[t.MANIFEST_CONTENT_ERROR = 3] = "MANIFEST_CONTENT_ERROR", t[t.UNKNOWN_APP_ERROR = 100] = "UNKNOWN_APP_ERROR", t[t.USER_REJECTS_ERROR = 300] = "USER_REJECTS_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; +})(Lo || (Lo = {})); +var $5; +(function(t) { + t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; +})($5 || ($5 = {})); +var Mc; +(function(t) { + t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.BAD_REQUEST_ERROR = 1] = "BAD_REQUEST_ERROR", t[t.UNKNOWN_APP_ERROR = 100] = "UNKNOWN_APP_ERROR", t[t.USER_REJECTS_ERROR = 300] = "USER_REJECTS_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; +})(Mc || (Mc = {})); +var B5; +(function(t) { + t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.BAD_REQUEST_ERROR = 1] = "BAD_REQUEST_ERROR", t[t.UNKNOWN_APP_ERROR = 100] = "UNKNOWN_APP_ERROR", t[t.USER_REJECTS_ERROR = 300] = "USER_REJECTS_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; +})(B5 || (B5 = {})); +var F5; +(function(t) { + t[t.UNKNOWN_ERROR = 0] = "UNKNOWN_ERROR", t[t.BAD_REQUEST_ERROR = 1] = "BAD_REQUEST_ERROR", t[t.UNKNOWN_APP_ERROR = 100] = "UNKNOWN_APP_ERROR", t[t.METHOD_NOT_SUPPORTED = 400] = "METHOD_NOT_SUPPORTED"; +})(F5 || (F5 = {})); +var j5; +(function(t) { + t.MAINNET = "-239", t.TESTNET = "-3"; +})(j5 || (j5 = {})); +function ute(t, e) { + const r = Hf.encodeBase64(t); + return e ? encodeURIComponent(r) : r; +} +function fte(t, e) { + return e && (t = decodeURIComponent(t)), Hf.decodeBase64(t); +} +function lte(t, e = !1) { + let r; + return t instanceof Uint8Array ? r = t : (typeof t != "string" && (t = JSON.stringify(t)), r = Hf.decodeUTF8(t)), ute(r, e); +} +function hte(t, e = !1) { + const r = fte(t, e); + return { + toString() { + return Hf.encodeUTF8(r); + }, + toObject() { + try { + return JSON.parse(Hf.encodeUTF8(r)); + } catch { + return null; + } + }, + toUint8Array() { + return r; + } + }; +} +const A9 = { + encode: lte, + decode: hte +}; +function dte(t, e) { + const r = new Uint8Array(t.length + e.length); + return r.set(t), r.set(e, t.length), r; +} +function pte(t, e) { + if (e >= t.length) + throw new Error("Index is out of buffer"); + const r = t.slice(0, e), n = t.slice(e); + return [r, n]; +} +function Om(t) { + let e = ""; + return t.forEach((r) => { + e += ("0" + (r & 255).toString(16)).slice(-2); + }), e; +} +function kd(t) { + if (t.length % 2 !== 0) + throw new Error(`Cannot convert ${t} to bytesArray`); + const e = new Uint8Array(t.length / 2); + for (let r = 0; r < t.length; r += 2) + e[r / 2] = parseInt(t.slice(r, r + 2), 16); + return e; +} +class zv { + constructor(e) { + this.nonceLength = 24, this.keyPair = e ? this.createKeypairFromString(e) : this.createKeypair(), this.sessionId = Om(this.keyPair.publicKey); + } + createKeypair() { + return Dh.box.keyPair(); + } + createKeypairFromString(e) { + return { + publicKey: kd(e.publicKey), + secretKey: kd(e.secretKey) + }; + } + createNonce() { + return Dh.randomBytes(this.nonceLength); + } + encrypt(e, r) { + const n = new TextEncoder().encode(e), i = this.createNonce(), s = Dh.box(n, i, r, this.keyPair.secretKey); + return dte(i, s); + } + decrypt(e, r) { + const [n, i] = pte(e, this.nonceLength), s = Dh.box.open(i, n, r, this.keyPair.secretKey); + if (!s) + throw new Error(`Decryption error: + message: ${e.toString()} + sender pubkey: ${r.toString()} + keypair pubkey: ${this.keyPair.publicKey.toString()} + keypair secretkey: ${this.keyPair.secretKey.toString()}`); + return new TextDecoder().decode(s); + } + stringifyKeypair() { + return { + publicKey: Om(this.keyPair.publicKey), + secretKey: Om(this.keyPair.secretKey) + }; + } +} +/*! ***************************************************************************** +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. +***************************************************************************** */ +function gte(t, e) { + var r = {}; + for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && e.indexOf(n) < 0 && (r[n] = t[n]); + if (t != null && typeof Object.getOwnPropertySymbols == "function") + for (var i = 0, n = Object.getOwnPropertySymbols(t); i < n.length; i++) + e.indexOf(n[i]) < 0 && Object.prototype.propertyIsEnumerable.call(t, n[i]) && (r[n[i]] = t[n[i]]); + return r; +} +function At(t, e, r, n) { + function i(s) { + return s instanceof r ? s : new r(function(o) { + o(s); + }); + } + return new (r || (r = Promise))(function(s, o) { + function a(h) { + try { + u(n.next(h)); + } catch (g) { + o(g); + } + } + function f(h) { + try { + u(n.throw(h)); + } catch (g) { + o(g); + } + } + function u(h) { + h.done ? s(h.value) : i(h.value).then(a, f); + } + u((n = n.apply(t, [])).next()); + }); +} +class jt extends Error { + constructor(e, r) { + super(e, r), this.message = `${jt.prefix} ${this.constructor.name}${this.info ? ": " + this.info : ""}${e ? ` +` + e : ""}`, Object.setPrototypeOf(this, jt.prototype); + } + get info() { + return ""; + } +} +jt.prefix = "[TON_CONNECT_SDK_ERROR]"; +class Mb extends jt { + get info() { + return "Passed DappMetadata is in incorrect format."; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, Mb.prototype); + } +} +class S0 extends jt { + get info() { + return "Passed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, S0.prototype); + } +} +class A0 extends jt { + get info() { + return "Manifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, A0.prototype); + } +} +class Ib extends jt { + get info() { + return "Wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection."; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, Ib.prototype); + } +} +class $d extends jt { + get info() { + return "Send transaction or other protocol methods called while wallet is not connected."; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, $d.prototype); + } +} +function mte(t) { + return "jsBridgeKey" in t; +} +class P0 extends jt { + get info() { + return "User rejects the action in the wallet."; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, P0.prototype); + } +} +class M0 extends jt { + get info() { + return "Request to the wallet contains errors."; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, M0.prototype); + } +} +class I0 extends jt { + get info() { + return "App tries to send rpc request to the injected wallet while not connected."; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, I0.prototype); + } +} +class Cb extends jt { + get info() { + return "There is an attempt to connect to the injected wallet while it is not exists in the webpage."; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, Cb.prototype); + } +} +class Rb extends jt { + get info() { + return "An error occurred while fetching the wallets list."; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, Rb.prototype); + } +} +class Jo extends jt { + constructor(...e) { + super(...e), Object.setPrototypeOf(this, Jo.prototype); + } +} +const U5 = { + [Lo.UNKNOWN_ERROR]: Jo, + [Lo.USER_REJECTS_ERROR]: P0, + [Lo.BAD_REQUEST_ERROR]: M0, + [Lo.UNKNOWN_APP_ERROR]: I0, + [Lo.MANIFEST_NOT_FOUND_ERROR]: A0, + [Lo.MANIFEST_CONTENT_ERROR]: S0 +}; +class vte { + parseError(e) { + let r = Jo; + return e.code in U5 && (r = U5[e.code] || Jo), new r(e.message); + } +} +const bte = new vte(); +class yte { + isError(e) { + return "error" in e; + } +} +const q5 = { + [Mc.UNKNOWN_ERROR]: Jo, + [Mc.USER_REJECTS_ERROR]: P0, + [Mc.BAD_REQUEST_ERROR]: M0, + [Mc.UNKNOWN_APP_ERROR]: I0 +}; +class wte extends yte { + convertToRpcRequest(e) { + return { + method: "sendTransaction", + params: [JSON.stringify(e)] + }; + } + parseAndThrowError(e) { + let r = Jo; + throw e.error.code in q5 && (r = q5[e.error.code] || Jo), new r(e.error.message); + } + convertFromRpcResponse(e) { + return { + boc: e.result + }; + } +} +const Oh = new wte(); +class xte { + constructor(e, r) { + this.storage = e, this.storeKey = "ton-connect-storage_http-bridge-gateway::" + r; + } + storeLastEventId(e) { + return At(this, void 0, void 0, function* () { + return this.storage.setItem(this.storeKey, e); + }); + } + removeLastEventId() { + return At(this, void 0, void 0, function* () { + return this.storage.removeItem(this.storeKey); + }); + } + getLastEventId() { + return At(this, void 0, void 0, function* () { + const e = yield this.storage.getItem(this.storeKey); + return e || null; + }); + } +} +function _te(t) { + return t.slice(-1) === "/" ? t.slice(0, -1) : t; +} +function P9(t, e) { + return _te(t) + "/" + e; +} +function Ete(t) { + if (!t) + return !1; + const e = new URL(t); + return e.protocol === "tg:" || e.hostname === "t.me"; +} +function Ste(t) { + return t.replaceAll(".", "%2E").replaceAll("-", "%2D").replaceAll("_", "%5F").replaceAll("&", "-").replaceAll("=", "__").replaceAll("%", "--"); +} +function M9(t, e) { + return At(this, void 0, void 0, function* () { + return new Promise((r, n) => { + var i, s; + if (!((i = void 0) === null || i === void 0) && i.aborted) { + n(new jt("Delay aborted")); + return; + } + const o = setTimeout(() => r(), t); + (s = void 0) === null || s === void 0 || s.addEventListener("abort", () => { + clearTimeout(o), n(new jt("Delay aborted")); + }); + }); + }); +} +function cs(t) { + const e = new AbortController(); + return t?.aborted ? e.abort() : t?.addEventListener("abort", () => e.abort(), { once: !0 }), e; +} +function ff(t, e) { + var r, n; + return At(this, void 0, void 0, function* () { + const i = (r = e?.attempts) !== null && r !== void 0 ? r : 10, s = (n = e?.delayMs) !== null && n !== void 0 ? n : 200, o = cs(e?.signal); + if (typeof t != "function") + throw new jt(`Expected a function, got ${typeof t}`); + let a = 0, f; + for (; a < i; ) { + if (o.signal.aborted) + throw new jt(`Aborted after attempts ${a}`); + try { + return yield t({ signal: o.signal }); + } catch (u) { + f = u, a++, a < i && (yield M9(s)); + } + } + throw f; + }); +} +function En(...t) { + try { + console.debug("[TON_CONNECT_SDK]", ...t); + } catch { + } +} +function fo(...t) { + try { + console.error("[TON_CONNECT_SDK]", ...t); + } catch { + } +} +function Ate(...t) { + try { + console.warn("[TON_CONNECT_SDK]", ...t); + } catch { + } +} +function Pte(t, e) { + let r = null, n = null, i = null, s = null, o = null; + const a = (g, ...v) => At(this, void 0, void 0, function* () { + if (s = g ?? null, o?.abort(), o = cs(g), o.signal.aborted) + throw new jt("Resource creation was aborted"); + n = v ?? null; + const x = t(o.signal, ...v); + i = x; + const S = yield x; + if (i !== x && S !== r) + throw yield e(S), new jt("Resource creation was aborted by a new resource creation"); + return r = S, r; + }); + return { + create: a, + current: () => r ?? null, + dispose: () => At(this, void 0, void 0, function* () { + try { + const g = r; + r = null; + const v = i; + i = null; + try { + o?.abort(); + } catch { + } + yield Promise.allSettled([ + g ? e(g) : Promise.resolve(), + v ? e(yield v) : Promise.resolve() + ]); + } catch { + } + }), + recreate: (g) => At(this, void 0, void 0, function* () { + const v = r, x = i, S = n, R = s; + if (yield M9(g), v === r && x === i && S === n && R === s) + return yield a(s, ...S ?? []); + throw new jt("Resource recreation was aborted by a new resource creation"); + }) + }; +} +function Mte(t, e) { + const r = e?.timeout, n = e?.signal, i = cs(n); + return new Promise((s, o) => At(this, void 0, void 0, function* () { + if (i.signal.aborted) { + o(new jt("Operation aborted")); + return; + } + let a; + typeof r < "u" && (a = setTimeout(() => { + i.abort(), o(new jt(`Timeout after ${r}ms`)); + }, r)), i.signal.addEventListener("abort", () => { + clearTimeout(a), o(new jt("Operation aborted")); + }, { once: !0 }); + const f = { timeout: r, abort: i.signal }; + yield t((...u) => { + clearTimeout(a), s(...u); + }, () => { + clearTimeout(a), o(); + }, f); + })); +} +class Nm { + constructor(e, r, n, i, s) { + this.bridgeUrl = r, this.sessionId = n, this.listener = i, this.errorsListener = s, this.ssePath = "events", this.postPath = "message", this.heartbeatMessage = "heartbeat", this.defaultTtl = 300, this.defaultReconnectDelay = 2e3, this.defaultResendDelay = 5e3, this.eventSource = Pte((o, a) => At(this, void 0, void 0, function* () { + const f = { + bridgeUrl: this.bridgeUrl, + ssePath: this.ssePath, + sessionId: this.sessionId, + bridgeGatewayStorage: this.bridgeGatewayStorage, + errorHandler: this.errorsHandler.bind(this), + messageHandler: this.messagesHandler.bind(this), + signal: o, + openingDeadlineMS: a + }; + return yield Ite(f); + }), (o) => At(this, void 0, void 0, function* () { + o.close(); + })), this.bridgeGatewayStorage = new xte(e, r); + } + get isReady() { + const e = this.eventSource.current(); + return e?.readyState === EventSource.OPEN; + } + get isClosed() { + const e = this.eventSource.current(); + return e?.readyState !== EventSource.OPEN; + } + get isConnecting() { + const e = this.eventSource.current(); + return e?.readyState === EventSource.CONNECTING; + } + registerSession(e) { + return At(this, void 0, void 0, function* () { + yield this.eventSource.create(e?.signal, e?.openingDeadlineMS); + }); + } + send(e, r, n, i) { + var s; + return At(this, void 0, void 0, function* () { + const o = {}; + typeof i == "number" ? o.ttl = i : (o.ttl = i?.ttl, o.signal = i?.signal, o.attempts = i?.attempts); + const a = new URL(P9(this.bridgeUrl, this.postPath)); + a.searchParams.append("client_id", this.sessionId), a.searchParams.append("to", r), a.searchParams.append("ttl", (o?.ttl || this.defaultTtl).toString()), a.searchParams.append("topic", n); + const f = A9.encode(e); + yield ff((u) => At(this, void 0, void 0, function* () { + const h = yield this.post(a, f, u.signal); + if (!h.ok) + throw new jt(`Bridge send failed, status ${h.status}`); + }), { + attempts: (s = o?.attempts) !== null && s !== void 0 ? s : Number.MAX_SAFE_INTEGER, + delayMs: this.defaultResendDelay, + signal: o?.signal + }); + }); + } + pause() { + this.eventSource.dispose().catch((e) => fo(`Bridge pause failed, ${e}`)); + } + unPause() { + return At(this, void 0, void 0, function* () { + yield this.eventSource.recreate(0); + }); + } + close() { + return At(this, void 0, void 0, function* () { + yield this.eventSource.dispose().catch((e) => fo(`Bridge close failed, ${e}`)); + }); + } + setListener(e) { + this.listener = e; + } + setErrorsListener(e) { + this.errorsListener = e; + } + post(e, r, n) { + return At(this, void 0, void 0, function* () { + const i = yield fetch(e, { + method: "post", + body: r, + signal: n + }); + if (!i.ok) + throw new jt(`Bridge send failed, status ${i.status}`); + return i; + }); + } + errorsHandler(e, r) { + return At(this, void 0, void 0, function* () { + if (this.isConnecting) + throw e.close(), new jt("Bridge error, failed to connect"); + if (this.isReady) { + try { + this.errorsListener(r); + } catch { + } + return; + } + if (this.isClosed) + return e.close(), En(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`), yield this.eventSource.recreate(this.defaultReconnectDelay); + throw new jt("Bridge error, unknown state"); + }); + } + messagesHandler(e) { + return At(this, void 0, void 0, function* () { + if (e.data === this.heartbeatMessage || (yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId), this.isClosed)) + return; + let r; + try { + r = JSON.parse(e.data); + } catch (n) { + throw new jt(`Bridge message parse failed, message ${n.data}`); + } + this.listener(r); + }); + } +} +function Ite(t) { + return At(this, void 0, void 0, function* () { + return yield Mte((e, r, n) => At(this, void 0, void 0, function* () { + var i; + const o = cs(n.signal).signal; + if (o.aborted) { + r(new jt("Bridge connection aborted")); + return; + } + const a = new URL(P9(t.bridgeUrl, t.ssePath)); + a.searchParams.append("client_id", t.sessionId); + const f = yield t.bridgeGatewayStorage.getLastEventId(); + if (f && a.searchParams.append("last_event_id", f), o.aborted) { + r(new jt("Bridge connection aborted")); + return; + } + const u = new EventSource(a.toString()); + u.onerror = (h) => At(this, void 0, void 0, function* () { + if (o.aborted) { + u.close(), r(new jt("Bridge connection aborted")); + return; + } + try { + const g = yield t.errorHandler(u, h); + g !== u && u.close(), g && g !== u && e(g); + } catch (g) { + u.close(), r(g); + } + }), u.onopen = () => { + if (o.aborted) { + u.close(), r(new jt("Bridge connection aborted")); + return; + } + e(u); + }, u.onmessage = (h) => { + if (o.aborted) { + u.close(), r(new jt("Bridge connection aborted")); + return; + } + t.messageHandler(h); + }, (i = t.signal) === null || i === void 0 || i.addEventListener("abort", () => { + u.close(), r(new jt("Bridge connection aborted")); + }); + }), { timeout: t.openingDeadlineMS, signal: t.signal }); + }); +} +function lf(t) { + return !("connectEvent" in t); +} +class Wf { + constructor(e) { + this.storage = e, this.storeKey = "ton-connect-storage_bridge-connection"; + } + storeConnection(e) { + return At(this, void 0, void 0, function* () { + if (e.type === "injected") + return this.storage.setItem(this.storeKey, JSON.stringify(e)); + if (!lf(e)) { + const n = { + sessionKeyPair: e.session.sessionCrypto.stringifyKeypair(), + walletPublicKey: e.session.walletPublicKey, + bridgeUrl: e.session.bridgeUrl + }, i = { + type: "http", + connectEvent: e.connectEvent, + session: n, + lastWalletEventId: e.lastWalletEventId, + nextRpcRequestId: e.nextRpcRequestId + }; + return this.storage.setItem(this.storeKey, JSON.stringify(i)); + } + const r = { + type: "http", + connectionSource: e.connectionSource, + sessionCrypto: e.sessionCrypto.stringifyKeypair() + }; + return this.storage.setItem(this.storeKey, JSON.stringify(r)); + }); + } + removeConnection() { + return At(this, void 0, void 0, function* () { + return this.storage.removeItem(this.storeKey); + }); + } + getConnection() { + return At(this, void 0, void 0, function* () { + const e = yield this.storage.getItem(this.storeKey); + if (!e) + return null; + const r = JSON.parse(e); + if (r.type === "injected") + return r; + if ("connectEvent" in r) { + const n = new zv(r.session.sessionKeyPair); + return { + type: "http", + connectEvent: r.connectEvent, + lastWalletEventId: r.lastWalletEventId, + nextRpcRequestId: r.nextRpcRequestId, + session: { + sessionCrypto: n, + bridgeUrl: r.session.bridgeUrl, + walletPublicKey: r.session.walletPublicKey + } + }; + } + return { + type: "http", + sessionCrypto: new zv(r.sessionCrypto), + connectionSource: r.connectionSource + }; + }); + } + getHttpConnection() { + return At(this, void 0, void 0, function* () { + const e = yield this.getConnection(); + if (!e) + throw new jt("Trying to read HTTP connection source while nothing is stored"); + if (e.type === "injected") + throw new jt("Trying to read HTTP connection source while injected connection is stored"); + return e; + }); + } + getHttpPendingConnection() { + return At(this, void 0, void 0, function* () { + const e = yield this.getConnection(); + if (!e) + throw new jt("Trying to read HTTP connection source while nothing is stored"); + if (e.type === "injected") + throw new jt("Trying to read HTTP connection source while injected connection is stored"); + if (!lf(e)) + throw new jt("Trying to read HTTP-pending connection while http connection is stored"); + return e; + }); + } + getInjectedConnection() { + return At(this, void 0, void 0, function* () { + const e = yield this.getConnection(); + if (!e) + throw new jt("Trying to read Injected bridge connection source while nothing is stored"); + if (e?.type === "http") + throw new jt("Trying to read Injected bridge connection source while HTTP connection is stored"); + return e; + }); + } + storedConnectionType() { + return At(this, void 0, void 0, function* () { + const e = yield this.storage.getItem(this.storeKey); + return e ? JSON.parse(e).type : null; + }); + } + storeLastWalletEventId(e) { + return At(this, void 0, void 0, function* () { + const r = yield this.getConnection(); + if (r && r.type === "http" && !lf(r)) + return r.lastWalletEventId = e, this.storeConnection(r); + }); + } + getLastWalletEventId() { + return At(this, void 0, void 0, function* () { + const e = yield this.getConnection(); + if (e && "lastWalletEventId" in e) + return e.lastWalletEventId; + }); + } + increaseNextRpcRequestId() { + return At(this, void 0, void 0, function* () { + const e = yield this.getConnection(); + if (e && "nextRpcRequestId" in e) { + const r = e.nextRpcRequestId || 0; + return e.nextRpcRequestId = r + 1, this.storeConnection(e); + } + }); + } + getNextRpcRequestId() { + return At(this, void 0, void 0, function* () { + const e = yield this.getConnection(); + return e && "nextRpcRequestId" in e && e.nextRpcRequestId || 0; + }); + } +} +const I9 = 2; +class Kf { + constructor(e, r) { + this.storage = e, this.walletConnectionSource = r, this.type = "http", this.standardUniversalLink = "tc://", this.pendingRequests = /* @__PURE__ */ new Map(), this.session = null, this.gateway = null, this.pendingGateways = [], this.listeners = [], this.defaultOpeningDeadlineMS = 12e3, this.defaultRetryTimeoutMS = 2e3, this.connectionStorage = new Wf(e); + } + static fromStorage(e) { + return At(this, void 0, void 0, function* () { + const n = yield new Wf(e).getHttpConnection(); + return lf(n) ? new Kf(e, n.connectionSource) : new Kf(e, { bridgeUrl: n.session.bridgeUrl }); + }); + } + connect(e, r) { + var n; + const i = cs(r?.signal); + (n = this.abortController) === null || n === void 0 || n.abort(), this.abortController = i, this.closeGateways(); + const s = new zv(); + this.session = { + sessionCrypto: s, + bridgeUrl: "bridgeUrl" in this.walletConnectionSource ? this.walletConnectionSource.bridgeUrl : "" + }, this.connectionStorage.storeConnection({ + type: "http", + connectionSource: this.walletConnectionSource, + sessionCrypto: s + }).then(() => At(this, void 0, void 0, function* () { + i.signal.aborted || (yield ff((a) => { + var f; + return this.openGateways(s, { + openingDeadlineMS: (f = r?.openingDeadlineMS) !== null && f !== void 0 ? f : this.defaultOpeningDeadlineMS, + signal: a?.signal + }); + }, { + attempts: Number.MAX_SAFE_INTEGER, + delayMs: this.defaultRetryTimeoutMS, + signal: i.signal + })); + })); + const o = "universalLink" in this.walletConnectionSource && this.walletConnectionSource.universalLink ? this.walletConnectionSource.universalLink : this.standardUniversalLink; + return this.generateUniversalLink(o, e); + } + restoreConnection(e) { + var r, n; + return At(this, void 0, void 0, function* () { + const i = cs(e?.signal); + if ((r = this.abortController) === null || r === void 0 || r.abort(), this.abortController = i, i.signal.aborted) + return; + this.closeGateways(); + const s = yield this.connectionStorage.getHttpConnection(); + if (!s || i.signal.aborted) + return; + const o = (n = e?.openingDeadlineMS) !== null && n !== void 0 ? n : this.defaultOpeningDeadlineMS; + if (lf(s)) + return this.session = { + sessionCrypto: s.sessionCrypto, + bridgeUrl: "bridgeUrl" in this.walletConnectionSource ? this.walletConnectionSource.bridgeUrl : "" + }, yield this.openGateways(s.sessionCrypto, { + openingDeadlineMS: o, + signal: i?.signal + }); + if (Array.isArray(this.walletConnectionSource)) + throw new jt("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected."); + if (this.session = s.session, this.gateway && (En("Gateway is already opened, closing previous gateway"), yield this.gateway.close()), this.gateway = new Nm(this.storage, this.walletConnectionSource.bridgeUrl, s.session.sessionCrypto.sessionId, this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this)), !i.signal.aborted) { + this.listeners.forEach((a) => a(s.connectEvent)); + try { + yield ff((a) => this.gateway.registerSession({ + openingDeadlineMS: o, + signal: a.signal + }), { + attempts: Number.MAX_SAFE_INTEGER, + delayMs: this.defaultRetryTimeoutMS, + signal: i.signal + }); + } catch { + yield this.disconnect({ signal: i.signal }); + return; + } + } + }); + } + sendRequest(e, r) { + const n = {}; + return typeof r == "function" ? n.onRequestSent = r : (n.onRequestSent = r?.onRequestSent, n.signal = r?.signal, n.attempts = r?.attempts), new Promise((i, s) => At(this, void 0, void 0, function* () { + var o; + if (!this.gateway || !this.session || !("walletPublicKey" in this.session)) + throw new jt("Trying to send bridge request without session"); + const a = (yield this.connectionStorage.getNextRpcRequestId()).toString(); + yield this.connectionStorage.increaseNextRpcRequestId(), En("Send http-bridge request:", Object.assign(Object.assign({}, e), { id: a })); + const f = this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({}, e), { id: a })), kd(this.session.walletPublicKey)); + try { + yield this.gateway.send(f, this.session.walletPublicKey, e.method, { attempts: n?.attempts, signal: n?.signal }), (o = n?.onRequestSent) === null || o === void 0 || o.call(n), this.pendingRequests.set(a.toString(), i); + } catch (u) { + s(u); + } + })); + } + closeConnection() { + this.closeGateways(), this.listeners = [], this.session = null, this.gateway = null; + } + disconnect(e) { + return At(this, void 0, void 0, function* () { + return new Promise((r) => At(this, void 0, void 0, function* () { + let n = !1, i = null; + const s = () => { + n || (n = !0, this.removeBridgeAndSession().then(r)); + }; + try { + this.closeGateways(); + const o = cs(e?.signal); + i = setTimeout(() => { + o.abort(); + }, this.defaultOpeningDeadlineMS), yield this.sendRequest({ method: "disconnect", params: [] }, { + onRequestSent: s, + signal: o.signal, + attempts: 1 + }); + } catch (o) { + En("Disconnect error:", o), n || this.removeBridgeAndSession().then(r); + } finally { + i && clearTimeout(i), s(); + } + })); + }); + } + listen(e) { + return this.listeners.push(e), () => this.listeners = this.listeners.filter((r) => r !== e); + } + pause() { + var e; + (e = this.gateway) === null || e === void 0 || e.pause(), this.pendingGateways.forEach((r) => r.pause()); + } + unPause() { + return At(this, void 0, void 0, function* () { + const e = this.pendingGateways.map((r) => r.unPause()); + this.gateway && e.push(this.gateway.unPause()), yield Promise.all(e); + }); + } + pendingGatewaysListener(e, r, n) { + return At(this, void 0, void 0, function* () { + if (!this.pendingGateways.includes(e)) { + yield e.close(); + return; + } + return this.closeGateways({ except: e }), this.gateway && (En("Gateway is already opened, closing previous gateway"), yield this.gateway.close()), this.session.bridgeUrl = r, this.gateway = e, this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)), this.gateway.setListener(this.gatewayListener.bind(this)), this.gatewayListener(n); + }); + } + gatewayListener(e) { + return At(this, void 0, void 0, function* () { + const r = JSON.parse(this.session.sessionCrypto.decrypt(A9.decode(e.message).toUint8Array(), kd(e.from))); + if (En("Wallet message received:", r), !("event" in r)) { + const i = r.id.toString(), s = this.pendingRequests.get(i); + if (!s) { + En(`Response id ${i} doesn't match any request's id`); + return; + } + s(r), this.pendingRequests.delete(i); + return; + } + if (r.id !== void 0) { + const i = yield this.connectionStorage.getLastWalletEventId(); + if (i !== void 0 && r.id <= i) { + fo(`Received event id (=${r.id}) must be greater than stored last wallet event id (=${i}) `); + return; + } + r.event !== "connect" && (yield this.connectionStorage.storeLastWalletEventId(r.id)); + } + const n = this.listeners; + r.event === "connect" && (yield this.updateSession(r, e.from)), r.event === "disconnect" && (En("Removing bridge and session: received disconnect event"), yield this.removeBridgeAndSession()), n.forEach((i) => i(r)); + }); + } + gatewayErrorsListener(e) { + return At(this, void 0, void 0, function* () { + throw new jt(`Bridge error ${JSON.stringify(e)}`); + }); + } + updateSession(e, r) { + return At(this, void 0, void 0, function* () { + this.session = Object.assign(Object.assign({}, this.session), { walletPublicKey: r }); + const n = e.payload.items.find((s) => s.name === "ton_addr"), i = Object.assign(Object.assign({}, e), { payload: Object.assign(Object.assign({}, e.payload), { items: [n] }) }); + yield this.connectionStorage.storeConnection({ + type: "http", + session: this.session, + lastWalletEventId: e.id, + connectEvent: i, + nextRpcRequestId: 0 + }); + }); + } + removeBridgeAndSession() { + return At(this, void 0, void 0, function* () { + this.closeConnection(), yield this.connectionStorage.removeConnection(); + }); + } + generateUniversalLink(e, r) { + return Ete(e) ? this.generateTGUniversalLink(e, r) : this.generateRegularUniversalLink(e, r); + } + generateRegularUniversalLink(e, r) { + const n = new URL(e); + return n.searchParams.append("v", I9.toString()), n.searchParams.append("id", this.session.sessionCrypto.sessionId), n.searchParams.append("r", JSON.stringify(r)), n.toString(); + } + generateTGUniversalLink(e, r) { + const i = this.generateRegularUniversalLink("about:blank", r).split("?")[1], s = "tonconnect-" + Ste(i), o = this.convertToDirectLink(e), a = new URL(o); + return a.searchParams.append("startapp", s), a.toString(); + } + // TODO: Remove this method after all dApps and the wallets-list.json have been updated + convertToDirectLink(e) { + const r = new URL(e); + return r.searchParams.has("attach") && (r.searchParams.delete("attach"), r.pathname += "/start"), r.toString(); + } + openGateways(e, r) { + return At(this, void 0, void 0, function* () { + if (Array.isArray(this.walletConnectionSource)) { + this.pendingGateways.map((n) => n.close().catch()), this.pendingGateways = this.walletConnectionSource.map((n) => { + const i = new Nm(this.storage, n.bridgeUrl, e.sessionId, () => { + }, () => { + }); + return i.setListener((s) => this.pendingGatewaysListener(i, n.bridgeUrl, s)), i; + }), yield Promise.allSettled(this.pendingGateways.map((n) => ff((i) => { + var s; + return this.pendingGateways.some((o) => o === n) ? n.registerSession({ + openingDeadlineMS: (s = r?.openingDeadlineMS) !== null && s !== void 0 ? s : this.defaultOpeningDeadlineMS, + signal: i.signal + }) : n.close(); + }, { + attempts: Number.MAX_SAFE_INTEGER, + delayMs: this.defaultRetryTimeoutMS, + signal: r?.signal + }))); + return; + } else + return this.gateway && (En("Gateway is already opened, closing previous gateway"), yield this.gateway.close()), this.gateway = new Nm(this.storage, this.walletConnectionSource.bridgeUrl, e.sessionId, this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this)), yield this.gateway.registerSession({ + openingDeadlineMS: r?.openingDeadlineMS, + signal: r?.signal + }); + }); + } + closeGateways(e) { + var r; + (r = this.gateway) === null || r === void 0 || r.close(), this.pendingGateways.filter((n) => n !== e?.except).forEach((n) => n.close()), this.pendingGateways = []; + } +} +function z5(t, e) { + return C9(t, [e]); +} +function C9(t, e) { + return !t || typeof t != "object" ? !1 : e.every((r) => r in t); +} +function Cte(t) { + try { + return !z5(t, "tonconnect") || !z5(t.tonconnect, "walletInfo") ? !1 : C9(t.tonconnect.walletInfo, [ + "name", + "app_name", + "image", + "about_url", + "platforms" + ]); + } catch { + return !1; + } +} +class Ic { + constructor() { + this.storage = {}; + } + static getInstance() { + return Ic.instance || (Ic.instance = new Ic()), Ic.instance; + } + get length() { + return Object.keys(this.storage).length; + } + clear() { + this.storage = {}; + } + getItem(e) { + var r; + return (r = this.storage[e]) !== null && r !== void 0 ? r : null; + } + key(e) { + var r; + const n = Object.keys(this.storage); + return e < 0 || e >= n.length ? null : (r = n[e]) !== null && r !== void 0 ? r : null; + } + removeItem(e) { + delete this.storage[e]; + } + setItem(e, r) { + this.storage[e] = r; + } +} +function C0() { + if (!(typeof window > "u")) + return window; +} +function Rte() { + const t = C0(); + if (!t) + return []; + try { + return Object.keys(t); + } catch { + return []; + } +} +function Tte() { + if (!(typeof document > "u")) + return document; +} +function Dte() { + var t; + const e = (t = C0()) === null || t === void 0 ? void 0 : t.location.origin; + return e ? e + "/tonconnect-manifest.json" : ""; +} +function Ote() { + if (Nte()) + return localStorage; + if (Lte()) + throw new jt("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector"); + return Ic.getInstance(); +} +function Nte() { + try { + return typeof localStorage < "u"; + } catch { + return !1; + } +} +function Lte() { + return typeof process < "u" && process.versions != null && process.versions.node != null; +} +class fi { + constructor(e, r) { + this.injectedWalletKey = r, this.type = "injected", this.unsubscribeCallback = null, this.listenSubscriptions = !1, this.listeners = []; + const n = fi.window; + if (!fi.isWindowContainsWallet(n, r)) + throw new Cb(); + this.connectionStorage = new Wf(e), this.injectedWallet = n[r].tonconnect; + } + static fromStorage(e) { + return At(this, void 0, void 0, function* () { + const n = yield new Wf(e).getInjectedConnection(); + return new fi(e, n.jsBridgeKey); + }); + } + static isWalletInjected(e) { + return fi.isWindowContainsWallet(this.window, e); + } + static isInsideWalletBrowser(e) { + return fi.isWindowContainsWallet(this.window, e) ? this.window[e].tonconnect.isWalletBrowser : !1; + } + static getCurrentlyInjectedWallets() { + return this.window ? Rte().filter(([n, i]) => Cte(i)).map(([n, i]) => ({ + name: i.tonconnect.walletInfo.name, + appName: i.tonconnect.walletInfo.app_name, + aboutUrl: i.tonconnect.walletInfo.about_url, + imageUrl: i.tonconnect.walletInfo.image, + tondns: i.tonconnect.walletInfo.tondns, + jsBridgeKey: n, + injected: !0, + embedded: i.tonconnect.isWalletBrowser, + platforms: i.tonconnect.walletInfo.platforms + })) : []; + } + static isWindowContainsWallet(e, r) { + return !!e && r in e && typeof e[r] == "object" && "tonconnect" in e[r]; + } + connect(e) { + this._connect(I9, e); + } + restoreConnection() { + return At(this, void 0, void 0, function* () { + try { + En("Injected Provider restoring connection..."); + const e = yield this.injectedWallet.restoreConnection(); + En("Injected Provider restoring connection response", e), e.event === "connect" ? (this.makeSubscriptions(), this.listeners.forEach((r) => r(e))) : yield this.connectionStorage.removeConnection(); + } catch (e) { + yield this.connectionStorage.removeConnection(), console.error(e); + } + }); + } + closeConnection() { + this.listenSubscriptions && this.injectedWallet.disconnect(), this.closeAllListeners(); + } + disconnect() { + return At(this, void 0, void 0, function* () { + return new Promise((e) => { + const r = () => { + this.closeAllListeners(), this.connectionStorage.removeConnection().then(e); + }; + try { + this.injectedWallet.disconnect(), r(); + } catch (n) { + En(n), this.sendRequest({ + method: "disconnect", + params: [] + }, r); + } + }); + }); + } + closeAllListeners() { + var e; + this.listenSubscriptions = !1, this.listeners = [], (e = this.unsubscribeCallback) === null || e === void 0 || e.call(this); + } + listen(e) { + return this.listeners.push(e), () => this.listeners = this.listeners.filter((r) => r !== e); + } + sendRequest(e, r) { + var n; + return At(this, void 0, void 0, function* () { + const i = {}; + typeof r == "function" ? i.onRequestSent = r : (i.onRequestSent = r?.onRequestSent, i.signal = r?.signal); + const s = (yield this.connectionStorage.getNextRpcRequestId()).toString(); + yield this.connectionStorage.increaseNextRpcRequestId(), En("Send injected-bridge request:", Object.assign(Object.assign({}, e), { id: s })); + const o = this.injectedWallet.send(Object.assign(Object.assign({}, e), { id: s })); + return o.then((a) => En("Wallet message received:", a)), (n = i?.onRequestSent) === null || n === void 0 || n.call(i), o; + }); + } + _connect(e, r) { + return At(this, void 0, void 0, function* () { + try { + En(`Injected Provider connect request: protocolVersion: ${e}, message:`, r); + const n = yield this.injectedWallet.connect(e, r); + En("Injected Provider connect response:", n), n.event === "connect" && (yield this.updateSession(), this.makeSubscriptions()), this.listeners.forEach((i) => i(n)); + } catch (n) { + En("Injected Provider connect error:", n); + const i = { + event: "connect_error", + payload: { + code: 0, + message: n?.toString() + } + }; + this.listeners.forEach((s) => s(i)); + } + }); + } + makeSubscriptions() { + this.listenSubscriptions = !0, this.unsubscribeCallback = this.injectedWallet.listen((e) => { + En("Wallet message received:", e), this.listenSubscriptions && this.listeners.forEach((r) => r(e)), e.event === "disconnect" && this.disconnect(); + }); + } + updateSession() { + return this.connectionStorage.storeConnection({ + type: "injected", + jsBridgeKey: this.injectedWalletKey, + nextRpcRequestId: 0 + }); + } +} +fi.window = C0(); +class kte { + constructor() { + this.localStorage = Ote(); + } + getItem(e) { + return At(this, void 0, void 0, function* () { + return this.localStorage.getItem(e); + }); + } + removeItem(e) { + return At(this, void 0, void 0, function* () { + this.localStorage.removeItem(e); + }); + } + setItem(e, r) { + return At(this, void 0, void 0, function* () { + this.localStorage.setItem(e, r); + }); + } +} +function R9(t) { + return Bte(t) && t.injected; +} +function $te(t) { + return R9(t) && t.embedded; +} +function Bte(t) { + return "jsBridgeKey" in t; +} +const Fte = [ + { + app_name: "telegram-wallet", + name: "Wallet", + image: "https://wallet.tg/images/logo-288.png", + about_url: "https://wallet.tg/", + universal_url: "https://t.me/wallet?attach=wallet", + bridge: [ + { + type: "sse", + url: "https://bridge.ton.space/bridge" + } + ], + platforms: ["ios", "android", "macos", "windows", "linux"] + }, + { + app_name: "tonkeeper", + name: "Tonkeeper", + image: "https://tonkeeper.com/assets/tonconnect-icon.png", + tondns: "tonkeeper.ton", + about_url: "https://tonkeeper.com", + universal_url: "https://app.tonkeeper.com/ton-connect", + deepLink: "tonkeeper-tc://", + bridge: [ + { + type: "sse", + url: "https://bridge.tonapi.io/bridge" + }, + { + type: "js", + key: "tonkeeper" + } + ], + platforms: ["ios", "android", "chrome", "firefox", "macos"] + }, + { + app_name: "mytonwallet", + name: "MyTonWallet", + image: "https://static.mytonwallet.io/icon-256.png", + about_url: "https://mytonwallet.io", + universal_url: "https://connect.mytonwallet.org", + bridge: [ + { + type: "js", + key: "mytonwallet" + }, + { + type: "sse", + url: "https://tonconnectbridge.mytonwallet.org/bridge/" + } + ], + platforms: ["chrome", "windows", "macos", "linux", "ios", "android", "firefox"] + }, + { + app_name: "openmask", + name: "OpenMask", + image: "https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png", + about_url: "https://www.openmask.app/", + bridge: [ + { + type: "js", + key: "openmask" + } + ], + platforms: ["chrome"] + }, + { + app_name: "tonhub", + name: "Tonhub", + image: "https://tonhub.com/tonconnect_logo.png", + about_url: "https://tonhub.com", + universal_url: "https://tonhub.com/ton-connect", + bridge: [ + { + type: "js", + key: "tonhub" + }, + { + type: "sse", + url: "https://connect.tonhubapi.com/tonconnect" + } + ], + platforms: ["ios", "android"] + }, + { + app_name: "dewallet", + name: "DeWallet", + image: "https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png", + about_url: "https://delabwallet.com", + universal_url: "https://t.me/dewallet?attach=wallet", + bridge: [ + { + type: "sse", + url: "https://sse-bridge.delab.team/bridge" + } + ], + platforms: ["ios", "android"] + }, + { + app_name: "xtonwallet", + name: "XTONWallet", + image: "https://xtonwallet.com/assets/img/icon-256-back.png", + about_url: "https://xtonwallet.com", + bridge: [ + { + type: "js", + key: "xtonwallet" + } + ], + platforms: ["chrome", "firefox"] + }, + { + app_name: "tonwallet", + name: "TON Wallet", + image: "https://wallet.ton.org/assets/ui/qr-logo.png", + about_url: "https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd", + bridge: [ + { + type: "js", + key: "tonwallet" + } + ], + platforms: ["chrome"] + }, + { + app_name: "bitgetTonWallet", + name: "Bitget Wallet", + image: "https://raw.githubusercontent.com/bitkeepwallet/download/main/logo/png/bitget_wallet_logo_0_gas_fee.png", + about_url: "https://web3.bitget.com", + deepLink: "bitkeep://", + bridge: [ + { + type: "js", + key: "bitgetTonWallet" + }, + { + type: "sse", + url: "https://bridge.tonapi.io/bridge" + } + ], + platforms: ["ios", "android", "chrome"], + universal_url: "https://bkcode.vip/ton-connect" + }, + { + app_name: "safepalwallet", + name: "SafePal", + image: "https://s.pvcliping.com/web/public_image/SafePal_x288.png", + tondns: "", + about_url: "https://www.safepal.com", + universal_url: "https://link.safepal.io/ton-connect", + deepLink: "safepal-tc://", + bridge: [ + { + type: "sse", + url: "https://ton-bridge.safepal.com/tonbridge/v1/bridge" + }, + { + type: "js", + key: "safepalwallet" + } + ], + platforms: ["ios", "android", "chrome", "firefox"] + }, + { + app_name: "okxTonWallet", + name: "OKX Wallet", + image: "https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png", + about_url: "https://www.okx.com/web3", + universal_url: "https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect", + bridge: [ + { + type: "js", + key: "okxTonWallet" + }, + { + type: "sse", + url: "https://www.okx.com/tonbridge/discover/rpc/bridge" + } + ], + platforms: ["chrome", "safari", "firefox", "ios", "android"] + }, + { + app_name: "okxTonWalletTr", + name: "OKX TR Wallet", + image: "https://static.okx.com/cdn/assets/imgs/247/587A8296F0BB640F.png", + about_url: "https://tr.okx.com/web3", + universal_url: "https://tr.okx.com/download?appendQuery=true&deeplink=okxtr://web3/wallet/tonconnect", + bridge: [ + { + type: "js", + key: "okxTonWallet" + }, + { + type: "sse", + url: "https://www.okx.com/tonbridge/discover/rpc/bridge" + } + ], + platforms: ["chrome", "safari", "firefox", "ios", "android"] + } +]; +class Hv { + constructor(e) { + this.walletsListCache = null, this.walletsListCacheCreationTimestamp = null, this.walletsListSource = "https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json", e?.walletsListSource && (this.walletsListSource = e.walletsListSource), e?.cacheTTLMs && (this.cacheTTLMs = e.cacheTTLMs); + } + getWallets() { + return At(this, void 0, void 0, function* () { + return this.cacheTTLMs && this.walletsListCacheCreationTimestamp && Date.now() > this.walletsListCacheCreationTimestamp + this.cacheTTLMs && (this.walletsListCache = null), this.walletsListCache || (this.walletsListCache = this.fetchWalletsList(), this.walletsListCache.then(() => { + this.walletsListCacheCreationTimestamp = Date.now(); + }).catch(() => { + this.walletsListCache = null, this.walletsListCacheCreationTimestamp = null; + })), this.walletsListCache; + }); + } + getEmbeddedWallet() { + return At(this, void 0, void 0, function* () { + const r = (yield this.getWallets()).filter($te); + return r.length !== 1 ? null : r[0]; + }); + } + fetchWalletsList() { + return At(this, void 0, void 0, function* () { + let e = []; + try { + if (e = yield (yield fetch(this.walletsListSource)).json(), !Array.isArray(e)) + throw new Rb("Wrong wallets list format, wallets list must be an array."); + const i = e.filter((s) => !this.isCorrectWalletConfigDTO(s)); + i.length && (fo(`Wallet(s) ${i.map((s) => s.name).join(", ")} config format is wrong. They were removed from the wallets list.`), e = e.filter((s) => this.isCorrectWalletConfigDTO(s))); + } catch (n) { + fo(n), e = Fte; + } + let r = []; + try { + r = fi.getCurrentlyInjectedWallets(); + } catch (n) { + fo(n); + } + return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(e), r); + }); + } + walletConfigDTOListToWalletConfigList(e) { + return e.map((r) => { + const i = { + name: r.name, + appName: r.app_name, + imageUrl: r.image, + aboutUrl: r.about_url, + tondns: r.tondns, + platforms: r.platforms + }; + return r.bridge.forEach((s) => { + if (s.type === "sse" && (i.bridgeUrl = s.url, i.universalLink = r.universal_url, i.deepLink = r.deepLink), s.type === "js") { + const o = s.key; + i.jsBridgeKey = o, i.injected = fi.isWalletInjected(o), i.embedded = fi.isInsideWalletBrowser(o); + } + }), i; + }); + } + mergeWalletsLists(e, r) { + return [...new Set(e.concat(r).map((i) => i.name)).values()].map((i) => { + const s = e.find((a) => a.name === i), o = r.find((a) => a.name === i); + return Object.assign(Object.assign({}, s && Object.assign({}, s)), o && Object.assign({}, o)); + }); + } + // eslint-disable-next-line complexity + isCorrectWalletConfigDTO(e) { + if (!e || typeof e != "object") + return !1; + const r = "name" in e, n = "app_name" in e, i = "image" in e, s = "about_url" in e, o = "platforms" in e; + if (!r || !i || !s || !o || !n || !e.platforms || !Array.isArray(e.platforms) || !e.platforms.length || !("bridge" in e) || !Array.isArray(e.bridge) || !e.bridge.length) + return !1; + const a = e.bridge; + if (a.some((h) => !h || typeof h != "object" || !("type" in h))) + return !1; + const f = a.find((h) => h.type === "sse"); + if (f && (!("url" in f) || !f.url || !e.universal_url)) + return !1; + const u = a.find((h) => h.type === "js"); + return !(u && (!("key" in u) || !u.key)); + } +} +class Bd extends jt { + get info() { + return "Wallet doesn't support requested feature method."; + } + constructor(...e) { + super(...e), Object.setPrototypeOf(this, Bd.prototype); + } +} +function jte(t, e) { + const r = t.includes("SendTransaction"), n = t.find((i) => i && typeof i == "object" && i.name === "SendTransaction"); + if (!r && !n) + throw new Bd("Wallet doesn't support SendTransaction feature."); + if (n && n.maxMessages !== void 0) { + if (n.maxMessages < e.requiredMessagesNumber) + throw new Bd(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${n.maxMessages}, but ${e.requiredMessagesNumber} is required.`); + return; + } + Ate("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet."); +} +function Ute() { + return { + type: "request-version" + }; +} +function qte(t) { + return { + type: "response-version", + version: t + }; +} +function ru(t) { + return { + ton_connect_sdk_lib: t.ton_connect_sdk_lib, + ton_connect_ui_lib: t.ton_connect_ui_lib + }; +} +function nu(t, e) { + var r, n, i, s, o, a, f, u; + const g = ((r = e?.connectItems) === null || r === void 0 ? void 0 : r.tonProof) && "proof" in e.connectItems.tonProof ? "ton_proof" : "ton_addr"; + return { + wallet_address: (i = (n = e?.account) === null || n === void 0 ? void 0 : n.address) !== null && i !== void 0 ? i : null, + wallet_type: (s = e?.device.appName) !== null && s !== void 0 ? s : null, + wallet_version: (o = e?.device.appVersion) !== null && o !== void 0 ? o : null, + auth_type: g, + custom_data: Object.assign({ chain_id: (f = (a = e?.account) === null || a === void 0 ? void 0 : a.chain) !== null && f !== void 0 ? f : null, provider: (u = e?.provider) !== null && u !== void 0 ? u : null }, ru(t)) + }; +} +function zte(t) { + return { + type: "connection-started", + custom_data: ru(t) + }; +} +function Hte(t, e) { + return Object.assign({ type: "connection-completed", is_success: !0 }, nu(t, e)); +} +function Wte(t, e, r) { + return { + type: "connection-error", + is_success: !1, + error_message: e, + error_code: r ?? null, + custom_data: ru(t) + }; +} +function Kte(t) { + return { + type: "connection-restoring-started", + custom_data: ru(t) + }; +} +function Vte(t, e) { + return Object.assign({ type: "connection-restoring-completed", is_success: !0 }, nu(t, e)); +} +function Gte(t, e) { + return { + type: "connection-restoring-error", + is_success: !1, + error_message: e, + custom_data: ru(t) + }; +} +function Tb(t, e) { + var r, n, i, s; + return { + valid_until: (r = String(e.validUntil)) !== null && r !== void 0 ? r : null, + from: (s = (n = e.from) !== null && n !== void 0 ? n : (i = t?.account) === null || i === void 0 ? void 0 : i.address) !== null && s !== void 0 ? s : null, + messages: e.messages.map((o) => { + var a, f; + return { + address: (a = o.address) !== null && a !== void 0 ? a : null, + amount: (f = o.amount) !== null && f !== void 0 ? f : null + }; + }) + }; +} +function Yte(t, e, r) { + return Object.assign(Object.assign({ type: "transaction-sent-for-signature" }, nu(t, e)), Tb(e, r)); +} +function Jte(t, e, r, n) { + return Object.assign(Object.assign({ type: "transaction-signed", is_success: !0, signed_transaction: n.boc }, nu(t, e)), Tb(e, r)); +} +function Xte(t, e, r, n, i) { + return Object.assign(Object.assign({ type: "transaction-signing-failed", is_success: !1, error_message: n, error_code: i ?? null }, nu(t, e)), Tb(e, r)); +} +function Zte(t, e, r) { + return Object.assign({ type: "disconnection", scope: r }, nu(t, e)); +} +class Qte { + constructor() { + this.window = C0(); + } + /** + * Dispatches an event with the given name and details to the browser window. + * @param eventName - The name of the event to dispatch. + * @param eventDetails - The details of the event to dispatch. + * @returns A promise that resolves when the event has been dispatched. + */ + dispatchEvent(e, r) { + var n; + return At(this, void 0, void 0, function* () { + const i = new CustomEvent(e, { detail: r }); + (n = this.window) === null || n === void 0 || n.dispatchEvent(i); + }); + } + /** + * Adds an event listener to the browser window. + * @param eventName - The name of the event to listen for. + * @param listener - The listener to add. + * @param options - The options for the listener. + * @returns A function that removes the listener. + */ + addEventListener(e, r, n) { + var i; + return At(this, void 0, void 0, function* () { + return (i = this.window) === null || i === void 0 || i.addEventListener(e, r, n), () => { + var s; + return (s = this.window) === null || s === void 0 ? void 0 : s.removeEventListener(e, r); + }; + }); + } +} +class ere { + constructor(e) { + var r; + this.eventPrefix = "ton-connect-", this.tonConnectUiVersion = null, this.eventDispatcher = (r = e?.eventDispatcher) !== null && r !== void 0 ? r : new Qte(), this.tonConnectSdkVersion = e.tonConnectSdkVersion, this.init().catch(); + } + /** + * Version of the library. + */ + get version() { + return ru({ + ton_connect_sdk_lib: this.tonConnectSdkVersion, + ton_connect_ui_lib: this.tonConnectUiVersion + }); + } + /** + * Called once when the tracker is created and request version other libraries. + */ + init() { + return At(this, void 0, void 0, function* () { + try { + yield this.setRequestVersionHandler(), this.tonConnectUiVersion = yield this.requestTonConnectUiVersion(); + } catch { + } + }); + } + /** + * Set request version handler. + * @private + */ + setRequestVersionHandler() { + return At(this, void 0, void 0, function* () { + yield this.eventDispatcher.addEventListener("ton-connect-request-version", () => At(this, void 0, void 0, function* () { + yield this.eventDispatcher.dispatchEvent("ton-connect-response-version", qte(this.tonConnectSdkVersion)); + })); + }); + } + /** + * Request TonConnect UI version. + * @private + */ + requestTonConnectUiVersion() { + return At(this, void 0, void 0, function* () { + return new Promise((e, r) => At(this, void 0, void 0, function* () { + try { + yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version", (n) => { + e(n.detail.version); + }, { once: !0 }), yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version", Ute()); + } catch (n) { + r(n); + } + })); + }); + } + /** + * Emit user action event to the window. + * @param eventDetails + * @private + */ + dispatchUserActionEvent(e) { + try { + this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${e.type}`, e).catch(); + } catch { + } + } + /** + * Track connection init event. + * @param args + */ + trackConnectionStarted(...e) { + try { + const r = zte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } + /** + * Track connection success event. + * @param args + */ + trackConnectionCompleted(...e) { + try { + const r = Hte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } + /** + * Track connection error event. + * @param args + */ + trackConnectionError(...e) { + try { + const r = Wte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } + /** + * Track connection restoring init event. + * @param args + */ + trackConnectionRestoringStarted(...e) { + try { + const r = Kte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } + /** + * Track connection restoring success event. + * @param args + */ + trackConnectionRestoringCompleted(...e) { + try { + const r = Vte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } + /** + * Track connection restoring error event. + * @param args + */ + trackConnectionRestoringError(...e) { + try { + const r = Gte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } + /** + * Track disconnect event. + * @param args + */ + trackDisconnection(...e) { + try { + const r = Zte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } + /** + * Track transaction init event. + * @param args + */ + trackTransactionSentForSignature(...e) { + try { + const r = Yte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } + /** + * Track transaction signed event. + * @param args + */ + trackTransactionSigned(...e) { + try { + const r = Jte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } + /** + * Track transaction error event. + * @param args + */ + trackTransactionSigningFailed(...e) { + try { + const r = Xte(this.version, ...e); + this.dispatchUserActionEvent(r); + } catch { + } + } +} +const tre = "3.0.5"; +class ml { + constructor(e) { + if (this.walletsList = new Hv(), this._wallet = null, this.provider = null, this.statusChangeSubscriptions = [], this.statusChangeErrorSubscriptions = [], this.dappSettings = { + manifestUrl: e?.manifestUrl || Dte(), + storage: e?.storage || new kte() + }, this.walletsList = new Hv({ + walletsListSource: e?.walletsListSource, + cacheTTLMs: e?.walletsListCacheTTLMs + }), this.tracker = new ere({ + eventDispatcher: e?.eventDispatcher, + tonConnectSdkVersion: tre + }), !this.dappSettings.manifestUrl) + throw new Mb("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"); + this.bridgeConnectionStorage = new Wf(this.dappSettings.storage), e?.disableAutoPauseConnection || this.addWindowFocusAndBlurSubscriptions(); + } + /** + * Returns available wallets list. + */ + static getWallets() { + return this.walletsList.getWallets(); + } + /** + * Shows if the wallet is connected right now. + */ + get connected() { + return this._wallet !== null; + } + /** + * Current connected account or null if no account is connected. + */ + get account() { + var e; + return ((e = this._wallet) === null || e === void 0 ? void 0 : e.account) || null; + } + /** + * Current connected wallet or null if no account is connected. + */ + get wallet() { + return this._wallet; + } + set wallet(e) { + this._wallet = e, this.statusChangeSubscriptions.forEach((r) => r(this._wallet)); + } + /** + * Returns available wallets list. + */ + getWallets() { + return this.walletsList.getWallets(); + } + /** + * Allows to subscribe to connection status changes and handle connection errors. + * @param callback will be called after connections status changes with actual wallet or null. + * @param errorsHandler (optional) will be called with some instance of TonConnectError when connect error is received. + * @returns unsubscribe callback. + */ + onStatusChange(e, r) { + return this.statusChangeSubscriptions.push(e), r && this.statusChangeErrorSubscriptions.push(r), () => { + this.statusChangeSubscriptions = this.statusChangeSubscriptions.filter((n) => n !== e), r && (this.statusChangeErrorSubscriptions = this.statusChangeErrorSubscriptions.filter((n) => n !== r)); + }; + } + connect(e, r) { + var n, i; + const s = {}; + if (typeof r == "object" && "tonProof" in r && (s.request = r), typeof r == "object" && ("openingDeadlineMS" in r || "signal" in r || "request" in r) && (s.request = r?.request, s.openingDeadlineMS = r?.openingDeadlineMS, s.signal = r?.signal), this.connected) + throw new Ib(); + const o = cs(s?.signal); + if ((n = this.abortController) === null || n === void 0 || n.abort(), this.abortController = o, o.signal.aborted) + throw new jt("Connection was aborted"); + return (i = this.provider) === null || i === void 0 || i.closeConnection(), this.provider = this.createProvider(e), o.signal.addEventListener("abort", () => { + var a; + (a = this.provider) === null || a === void 0 || a.closeConnection(), this.provider = null; + }), this.tracker.trackConnectionStarted(), this.provider.connect(this.createConnectRequest(s?.request), { + openingDeadlineMS: s?.openingDeadlineMS, + signal: o.signal + }); + } + /** + * Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded. + */ + restoreConnection(e) { + var r, n; + return At(this, void 0, void 0, function* () { + this.tracker.trackConnectionRestoringStarted(); + const i = cs(e?.signal); + if ((r = this.abortController) === null || r === void 0 || r.abort(), this.abortController = i, i.signal.aborted) { + this.tracker.trackConnectionRestoringError("Connection restoring was aborted"); + return; + } + const [s, o] = yield Promise.all([ + this.bridgeConnectionStorage.storedConnectionType(), + this.walletsList.getEmbeddedWallet() + ]); + if (i.signal.aborted) { + this.tracker.trackConnectionRestoringError("Connection restoring was aborted"); + return; + } + let a = null; + try { + switch (s) { + case "http": + a = yield Kf.fromStorage(this.dappSettings.storage); + break; + case "injected": + a = yield fi.fromStorage(this.dappSettings.storage); + break; + default: + if (o) + a = this.createProvider(o); + else + return; + } + } catch { + this.tracker.trackConnectionRestoringError("Provider is not restored"), yield this.bridgeConnectionStorage.removeConnection(), a?.closeConnection(), a = null; + return; + } + if (i.signal.aborted) { + a?.closeConnection(), this.tracker.trackConnectionRestoringError("Connection restoring was aborted"); + return; + } + if (!a) { + fo("Provider is not restored"), this.tracker.trackConnectionRestoringError("Provider is not restored"); + return; + } + (n = this.provider) === null || n === void 0 || n.closeConnection(), this.provider = a, a.listen(this.walletEventsListener.bind(this)); + const f = () => { + this.tracker.trackConnectionRestoringError("Connection restoring was aborted"), a?.closeConnection(), a = null; + }; + i.signal.addEventListener("abort", f); + const u = ff((g) => At(this, void 0, void 0, function* () { + yield a?.restoreConnection({ + openingDeadlineMS: e?.openingDeadlineMS, + signal: g.signal + }), i.signal.removeEventListener("abort", f), this.connected ? this.tracker.trackConnectionRestoringCompleted(this.wallet) : this.tracker.trackConnectionRestoringError("Connection restoring failed"); + }), { + attempts: Number.MAX_SAFE_INTEGER, + delayMs: 2e3, + signal: e?.signal + }), h = new Promise( + (g) => setTimeout(() => g(), 12e3) + // connection deadline + ); + return Promise.race([u, h]); + }); + } + sendTransaction(e, r) { + return At(this, void 0, void 0, function* () { + const n = {}; + typeof r == "function" ? n.onRequestSent = r : (n.onRequestSent = r?.onRequestSent, n.signal = r?.signal); + const i = cs(n?.signal); + if (i.signal.aborted) + throw new jt("Transaction sending was aborted"); + this.checkConnection(), jte(this.wallet.device.features, { + requiredMessagesNumber: e.messages.length + }), this.tracker.trackTransactionSentForSignature(this.wallet, e); + const { validUntil: s } = e, o = gte(e, ["validUntil"]), a = e.from || this.account.address, f = e.network || this.account.chain, u = yield this.provider.sendRequest(Oh.convertToRpcRequest(Object.assign(Object.assign({}, o), { + valid_until: s, + from: a, + network: f + })), { onRequestSent: n.onRequestSent, signal: i.signal }); + if (Oh.isError(u)) + return this.tracker.trackTransactionSigningFailed(this.wallet, e, u.error.message, u.error.code), Oh.parseAndThrowError(u); + const h = Oh.convertFromRpcResponse(u); + return this.tracker.trackTransactionSigned(this.wallet, e, h), h; + }); + } + /** + * Disconnect form thw connected wallet and drop current session. + */ + disconnect(e) { + var r; + return At(this, void 0, void 0, function* () { + if (!this.connected) + throw new $d(); + const n = cs(e?.signal), i = this.abortController; + if (this.abortController = n, n.signal.aborted) + throw new jt("Disconnect was aborted"); + this.onWalletDisconnected("dapp"), yield (r = this.provider) === null || r === void 0 ? void 0 : r.disconnect({ + signal: n.signal + }), i?.abort(); + }); + } + /** + * Pause bridge HTTP connection. Might be helpful, if you want to pause connections while browser tab is unfocused, + * or if you use SDK with NodeJS and want to save server resources. + */ + pauseConnection() { + var e; + ((e = this.provider) === null || e === void 0 ? void 0 : e.type) === "http" && this.provider.pause(); + } + /** + * Unpause bridge HTTP connection if it is paused. + */ + unPauseConnection() { + var e; + return ((e = this.provider) === null || e === void 0 ? void 0 : e.type) !== "http" ? Promise.resolve() : this.provider.unPause(); + } + addWindowFocusAndBlurSubscriptions() { + const e = Tte(); + if (e) + try { + e.addEventListener("visibilitychange", () => { + e.hidden ? this.pauseConnection() : this.unPauseConnection().catch(); + }); + } catch (r) { + fo("Cannot subscribe to the document.visibilitychange: ", r); + } + } + createProvider(e) { + let r; + return !Array.isArray(e) && mte(e) ? r = new fi(this.dappSettings.storage, e.jsBridgeKey) : r = new Kf(this.dappSettings.storage, e), r.listen(this.walletEventsListener.bind(this)), r; + } + walletEventsListener(e) { + switch (e.event) { + case "connect": + this.onWalletConnected(e.payload); + break; + case "connect_error": + this.onWalletConnectError(e.payload); + break; + case "disconnect": + this.onWalletDisconnected("wallet"); + } + } + onWalletConnected(e) { + const r = e.items.find((s) => s.name === "ton_addr"), n = e.items.find((s) => s.name === "ton_proof"); + if (!r) + throw new jt("ton_addr connection item was not found"); + const i = { + device: e.device, + provider: this.provider.type, + account: { + address: r.address, + chain: r.network, + walletStateInit: r.walletStateInit, + publicKey: r.publicKey + } + }; + n && (i.connectItems = { + tonProof: n + }), this.wallet = i, this.tracker.trackConnectionCompleted(i); + } + onWalletConnectError(e) { + const r = bte.parseError(e); + if (this.statusChangeErrorSubscriptions.forEach((n) => n(r)), En(r), this.tracker.trackConnectionError(e.message, e.code), r instanceof A0 || r instanceof S0) + throw fo(r), r; + } + onWalletDisconnected(e) { + this.tracker.trackDisconnection(this.wallet, e), this.wallet = null; + } + checkConnection() { + if (!this.connected) + throw new $d(); + } + createConnectRequest(e) { + const r = [ + { + name: "ton_addr" + } + ]; + return e?.tonProof && r.push({ + name: "ton_proof", + payload: e.tonProof + }), { + manifestUrl: this.dappSettings.manifestUrl, + items: r + }; + } +} +ml.walletsList = new Hv(); +ml.isWalletInjected = (t) => fi.isWalletInjected(t); +ml.isInsideWalletBrowser = (t) => fi.isInsideWalletBrowser(t); +for (let t = 0; t <= 255; t++) { + let e = t.toString(16); + e.length < 2 && (e = "0" + e); +} +function Lm(t) { + const { children: e, onClick: r } = t; + return /* @__PURE__ */ pe.jsx("button", { onClick: r, className: "xc-border xc-px-4 xc-py-2 xc-rounded-full xc-text-sm xc-flex xc-gap-2 xc-items-center", children: e }); +} +function T9(t) { + const { wallet: e, connector: r, loading: n } = t, i = Kn(null), s = Kn(), [o, a] = Xt(), [f, u] = Xt(), [h, g] = Xt("connect"), [v, x] = Xt(!1), [S, R] = Xt(); + function D(W) { + s.current?.update({ + data: W + }); + } + async function k() { + x(!0); + try { + a(""); + const W = await Qo.getNonce({ account_type: "block_chain" }); + if ("universalLink" in e && e.universalLink) { + const J = r.connect({ + universalLink: e.universalLink, + bridgeUrl: e.bridgeUrl + }, { + request: { tonProof: W } + }); + if (!J) return; + R(J), D(J), u(W); + } + } catch (W) { + a(W.message); + } + x(!1); + } + function N() { + s.current = new b9({ + width: 264, + height: 264, + margin: 0, + type: "svg", + qrOptions: { + errorCorrectionLevel: "M" + }, + dotsOptions: { + color: "black", + type: "rounded" + }, + backgroundOptions: { + color: "transparent" + } + }), s.current.append(i.current); + } + function z() { + r.connect(e, { + request: { tonProof: f } + }); + } + function B() { + if ("deepLink" in e) { + if (!e.deepLink || !S) return; + const W = new URL(S), J = `${e.deepLink}${W.search}`; + window.open(J); + } + } + function $() { + "universalLink" in e && e.universalLink && /t.me/.test(e.universalLink) && window.open(S); + } + const U = hi(() => !!("deepLink" in e && e.deepLink), [e]), C = hi(() => !!("universalLink" in e && e.universalLink && /t.me/.test(e.universalLink)), [e]); + return Rn(() => { + N(), k(); + }, []), /* @__PURE__ */ pe.jsxs(ps, { children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-6", children: /* @__PURE__ */ pe.jsx(Ja, { title: "Connect wallet", onBack: t.onBack }) }), + /* @__PURE__ */ pe.jsxs("div", { className: "xc-text-center xc-mb-6", children: [ + /* @__PURE__ */ pe.jsxs("div", { className: "xc-relative xc-mx-auto xc-mb-6 xc-block xc-max-h-[272px] xc-max-w-[272px] xc-rounded-xl xc-bg-white xc-p-1", children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-aspect-[1/1] xc-flex xc-h-full xc-w-full xc-justify-center", ref: i }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-absolute xc-left-0 xc-top-0 xc-flex xc-h-full xc-w-full xc-items-center xc-justify-center", children: v ? /* @__PURE__ */ pe.jsx(ja, { className: "xc-h-6 xc-w-6 xc-animate-spin xc-text-black", size: 20 }) : /* @__PURE__ */ pe.jsx("img", { className: "xc-h-10 xc-w-10 xc-rounded-md", src: e.imageUrl }) }) + ] }), + /* @__PURE__ */ pe.jsx("p", { className: "xc-text-center", children: "Scan the QR code below with your phone's camera. " }) + ] }), + /* @__PURE__ */ pe.jsxs("div", { className: "xc-flex xc-justify-center xc-gap-2", children: [ + n && /* @__PURE__ */ pe.jsx(ja, { className: "xc-animate-spin" }), + !v && !n && /* @__PURE__ */ pe.jsxs(pe.Fragment, { children: [ + R9(e) && /* @__PURE__ */ pe.jsxs(Lm, { onClick: z, children: [ + /* @__PURE__ */ pe.jsx(rY, { className: "xc-opacity-80" }), + "Extension" + ] }), + U && /* @__PURE__ */ pe.jsxs(Lm, { onClick: B, children: [ + /* @__PURE__ */ pe.jsx(AS, { className: "xc-opacity-80" }), + "Desktop" + ] }), + C && /* @__PURE__ */ pe.jsx(Lm, { onClick: $, children: "Telegram Mini App" }) + ] }) + ] }) + ] }); +} +function rre(t) { + const [e, r] = Xt(""), [n, i] = Xt(), [s, o] = Xt(), a = Pb(), [f, u] = Xt(!1); + async function h(v) { + if (!v || !v.connectItems?.tonProof) return; + u(!0); + const x = await Qo.tonLogin({ + account_type: "block_chain", + connector: "codatta_ton", + account_enum: "C", + wallet_name: v?.device.appName, + inviter_code: a.inviterCode, + address: v.account.address, + chain: v.account.chain, + connect_info: [ + { name: "ton_addr", network: v.account.chain, ...v.account }, + v.connectItems?.tonProof + ], + source: { + device: a.device, + channel: a.channel, + app: a.app + } + }); + await t.onLogin(x.data), u(!1); + } + Rn(() => { + const v = new ml({ + manifestUrl: "https://static.codatta.io/static/tonconnect-manifest.json?v=2" + }), x = v.onStatusChange(h); + return o(v), r("select"), x; + }, []); + function g(v) { + r("connect"), i(v); + } + return /* @__PURE__ */ pe.jsxs(ps, { children: [ + e === "select" && /* @__PURE__ */ pe.jsx( + S9, + { + connector: s, + onSelect: g, + onBack: t.onBack + } + ), + e === "connect" && /* @__PURE__ */ pe.jsx( + T9, + { + connector: s, + wallet: n, + onBack: t.onBack, + loading: f + } + ) + ] }); +} +function D9(t) { + const { children: e, className: r } = t, n = Kn(null), [i, s] = Wv.useState(0); + function o() { + try { + const a = n.current?.children || []; + let f = 0; + for (let u = 0; u < a.length; u++) + f += a[u].offsetHeight; + s(f); + } catch (a) { + console.error(a); + } + } + return Rn(() => { + const a = new MutationObserver(o); + return a.observe(n.current, { childList: !0, subtree: !0 }), () => a.disconnect(); + }, []), Rn(() => { + console.log("maxHeight", i); + }, [i]), /* @__PURE__ */ pe.jsx( + "div", + { + ref: n, + className: r, + style: { + transition: "all 0.2s ease-in-out", + overflow: "hidden", + height: i + }, + children: e + } + ); +} +function nre() { + return /* @__PURE__ */ pe.jsxs("svg", { width: "121", height: "120", viewBox: "0 0 121 120", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [ + /* @__PURE__ */ pe.jsx("rect", { x: "0.5", width: "120", height: "120", rx: "60", fill: "#404049" }), + /* @__PURE__ */ pe.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M52.8709 61.106C52.8208 61.4482 52.7948 61.7979 52.7948 62.1535C52.7948 66.2529 56.2445 69.5761 60.5 69.5761C64.7554 69.5761 68.2052 66.2529 68.2052 62.1535C68.2052 61.7979 68.1792 61.4482 68.129 61.106H86.826V77.6174C86.826 78.6422 85.9636 79.473 84.8997 79.473H36.1002C35.0364 79.473 34.174 78.6422 34.174 77.6174V61.106H52.8709Z", fill: "#252532" }), + /* @__PURE__ */ pe.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M69.061 60.9416C69.061 65.6697 65.2281 69.5026 60.5 69.5026C55.7719 69.5026 51.939 65.6697 51.939 60.9416C51.939 60.7884 51.943 60.6362 51.951 60.485H33.5L39.7959 41.8696C40.0673 41.0671 40.8202 40.527 41.6674 40.527H79.3326C80.1798 40.527 80.9327 41.0671 81.2041 41.8696L87.5 60.485H69.049C69.057 60.6362 69.061 60.7884 69.061 60.9416Z", fill: "#252532" }), + /* @__PURE__ */ pe.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M67.8081 61.5708C67.8081 65.2243 64.5361 68.8446 60.4999 68.8446C56.4637 68.8446 53.1918 65.2243 53.1918 61.5708C53.1918 61.4524 53.1952 60.6762 53.202 60.5594H39.4268L44.8013 47.4919C45.033 46.8717 45.6757 46.4543 46.3989 46.4543H74.601C75.3242 46.4543 75.9669 46.8717 76.1986 47.4919L81.5731 60.5594H67.7979C67.8046 60.6762 67.8081 61.4524 67.8081 61.5708Z", fill: "#404049" }), + /* @__PURE__ */ pe.jsx("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M34.3232 60.6199V78.063C34.3232 78.6995 34.8392 79.2155 35.4757 79.2155H85.5245C86.1609 79.2155 86.6769 78.6995 86.6769 78.063V60.6199L80.4244 42.1328C80.2661 41.6647 79.8269 41.3496 79.3327 41.3496H41.6674C41.1733 41.3496 40.7341 41.6647 40.5758 42.1328L34.3232 60.6199Z", stroke: "#77777D", "stroke-width": "2" }), + /* @__PURE__ */ pe.jsx("path", { d: "M34.817 60.2823C37.4094 60.2823 48.1095 60.2823 51.1124 60.2823C52.348 60.2823 52.348 61.1507 52.348 61.5994C52.348 65.9638 55.9675 69.5019 60.4323 69.5019C64.8971 69.5019 68.5165 65.9638 68.5165 61.5994C68.5165 61.1507 68.5165 60.2823 69.7521 60.2823H86.1829", stroke: "#77777D", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }) + ] }); +} +function O9(t) { + const { wallets: e } = g0(), [r, n] = Xt(), i = hi(() => r ? e.filter((a) => a.key.toLowerCase().includes(r.toLowerCase())) : e, [r]); + function s(a) { + t.onSelectWallet(a); + } + function o(a) { + n(a.target.value); + } + return /* @__PURE__ */ pe.jsxs(ps, { children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-6", children: /* @__PURE__ */ pe.jsx(Ja, { title: "Select wallet", onBack: t.onBack }) }), + /* @__PURE__ */ pe.jsxs("div", { className: "xc-mb-6 xc-flex xc-gap-3 xc-px-4 xc-py-2 xc-border xc-rounded-xl xc-w-full xc-overflow-hidden xc-items-center xc-border-opacity-15 xc-border-white focus-within:xc-border-opacity-40", children: [ + /* @__PURE__ */ pe.jsx(PS, { className: "xc-shrink-0 xc-opacity-50" }), + /* @__PURE__ */ pe.jsx("input", { type: "text", className: "xc-flex-1 xc-bg-transparent xc-appearance-none xc-outline-none", placeholder: "Search wallet", onInput: o }) + ] }), + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-4 xc-flex xc-h-[309px] xc-flex-col xc-gap-4 xc-overflow-scroll no-scrollbar", children: i.length ? i.map((a) => /* @__PURE__ */ pe.jsx( + Q7, + { + wallet: a, + onClick: s + }, + `feature-${a.key}` + )) : /* @__PURE__ */ pe.jsx(nre, {}) }) + ] }); +} +function dne(t) { + const { onLogin: e, header: r, showEmailSignIn: n = !0, showMoreWallets: i = !0, showTonConnect: s = !0, showFeaturedWallets: o = !0 } = t, [a, f] = Xt(""), [u, h] = Xt(null), [g, v] = Xt(""); + function x(k) { + h(k), f("evm-wallet"); + } + function S(k) { + f("email"), v(k); + } + async function R(k) { + await e(k); + } + function D() { + f("ton-wallet"); + } + return Rn(() => { + f("index"); + }, []), /* @__PURE__ */ pe.jsx(vee, { config: t.config, children: /* @__PURE__ */ pe.jsxs(D9, { className: "xc-rounded-2xl xc-transition-height xc-box-content xc-w-full xc-min-w-[277px] xc-max-w-[420px] xc-p-6 xc-bg-[rgb(28,28,38)] xc-text-white", children: [ + a === "evm-wallet" && /* @__PURE__ */ pe.jsx( + rte, + { + onBack: () => f("index"), + onLogin: R, + wallet: u + } + ), + a === "ton-wallet" && /* @__PURE__ */ pe.jsx( + rre, + { + onBack: () => f("index"), + onLogin: R + } + ), + a === "email" && /* @__PURE__ */ pe.jsx(Dee, { email: g, onBack: () => f("index"), onLogin: R }), + a === "index" && /* @__PURE__ */ pe.jsx( + a9, + { + header: r, + useSingleWallet: !0, + onEmailConfirm: S, + onSelectWallet: x, + onSelectMoreWallets: () => { + f("all-wallet"); + }, + onSelectTonConnect: D, + config: { + showEmailSignIn: n, + showFeaturedWallets: o, + showMoreWallets: i, + showTonConnect: s + } + } + ), + a === "all-wallet" && /* @__PURE__ */ pe.jsx( + O9, + { + onBack: () => f("index"), + onSelectWallet: x + } + ) + ] }) }); +} +function ire(t) { + const { wallet: e, onConnect: r } = t, [n, i] = Xt(e.installed ? "connect" : "qr"); + async function s(o, a) { + await r(o, a); + } + return /* @__PURE__ */ pe.jsxs(ps, { children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-6", children: /* @__PURE__ */ pe.jsx(Ja, { title: "Connect wallet", onBack: t.onBack }) }), + n === "qr" && /* @__PURE__ */ pe.jsx( + x9, + { + wallet: e, + onGetExtension: () => i("get-extension"), + onSignFinish: s + } + ), + n === "connect" && /* @__PURE__ */ pe.jsx( + _9, + { + onShowQrCode: () => i("qr"), + wallet: e, + onSignFinish: s + } + ), + n === "get-extension" && /* @__PURE__ */ pe.jsx(E9, { wallet: e }) + ] }); +} +function sre(t) { + const { email: e } = t, [r, n] = Xt("captcha"); + return /* @__PURE__ */ pe.jsxs(ps, { children: [ + /* @__PURE__ */ pe.jsx("div", { className: "xc-mb-12", children: /* @__PURE__ */ pe.jsx(Ja, { title: "Connect with email", onBack: t.onBack }) }), + r === "captcha" && /* @__PURE__ */ pe.jsx(v9, { email: e, onCodeSend: () => n("verify-email") }), + r === "verify-email" && /* @__PURE__ */ pe.jsx(m9, { email: e, onInputCode: t.onInputCode, onResendCode: () => n("captcha") }) + ] }); +} +function pne(t) { + const { onEvmWalletConnect: e, onTonWalletConnect: r, onEmailConnect: n, header: i, config: s = { + showEmailSignIn: !1, + showFeaturedWallets: !0, + showMoreWallets: !0, + showTonConnect: !0 + } } = t, [o, a] = Xt(""), [f, u] = Xt(), [h, g] = Xt(), v = Kn(), [x, S] = Xt(""); + function R($) { + u($), a("evm-wallet-connect"); + } + function D($) { + S($), a("email-connect"); + } + async function k($, U) { + await e?.({ + chain_type: "eip155", + client: $.client, + connect_info: U, + wallet: $ + }), a("index"); + } + async function N($, U) { + await n?.($, U); + } + function z($) { + g($), a("ton-wallet-connect"); + } + async function B($) { + $ && await r?.({ + chain_type: "ton", + client: v.current, + connect_info: $, + wallet: $ + }); + } + return Rn(() => { + v.current = new ml({ + manifestUrl: "https://static.codatta.io/static/tonconnect-manifest.json?v=2" + }); + const $ = v.current.onStatusChange(B); + return a("index"), $; + }, []), /* @__PURE__ */ pe.jsxs(D9, { className: "xc-rounded-2xl xc-transition-height xc-box-content xc-w-full xc-min-w-[277px] xc-max-w-[420px] xc-p-6 xc-bg-[rgb(28,28,38)] xc-text-white", children: [ + o === "evm-wallet-select" && /* @__PURE__ */ pe.jsx( + O9, + { + onBack: () => a("index"), + onSelectWallet: R + } + ), + o === "evm-wallet-connect" && /* @__PURE__ */ pe.jsx( + ire, + { + onBack: () => a("index"), + onConnect: k, + wallet: f + } + ), + o === "ton-wallet-select" && /* @__PURE__ */ pe.jsx( + S9, + { + connector: v.current, + onSelect: z, + onBack: () => a("index") + } + ), + o === "ton-wallet-connect" && /* @__PURE__ */ pe.jsx( + T9, + { + connector: v.current, + wallet: h, + onBack: () => a("index") + } + ), + o === "email-connect" && /* @__PURE__ */ pe.jsx(sre, { email: x, onBack: () => a("index"), onInputCode: N }), + o === "index" && /* @__PURE__ */ pe.jsx( + a9, + { + header: i, + useSingleWallet: !1, + onEmailConfirm: D, + onSelectWallet: R, + onSelectMoreWallets: () => a("evm-wallet-select"), + onSelectTonConnect: () => a("ton-wallet-select"), + config: s + } + ) + ] }); +} +export { + lne as C, + n4 as H, + Tc as W, + Da as a, + QT as b, + fre as c, + cre as d, + hf as e, + cd as f, + ad as g, + ure as h, + VT as i, + GG as j, + dne as k, + pne as l, + lre as r, + kO as s, + Zv as t, + g0 as u +}; diff --git a/dist/main.d.ts b/dist/main.d.ts index 7393bcf..545843f 100644 --- a/dist/main.d.ts +++ b/dist/main.d.ts @@ -1,2 +1,4 @@ export * from './codatta-connect-context-provider'; export * from './codatta-signin'; +export * from './codatta-connect'; +export * from './types/wallet-item.class'; diff --git a/dist/providers/codatta-signin-context-provider.d.ts b/dist/providers/codatta-signin-context-provider.d.ts index 306a0cd..5a6133f 100644 --- a/dist/providers/codatta-signin-context-provider.d.ts +++ b/dist/providers/codatta-signin-context-provider.d.ts @@ -4,8 +4,11 @@ export interface CodattaSigninConfig { device: TDeviceType; app: string; inviterCode: string; + role?: "B" | "C"; } -export declare function useCodattaSigninContext(): CodattaSigninConfig; +export declare function useCodattaSigninContext(): CodattaSigninConfig & { + role: "B" | "C"; +}; interface CodattaConnectContextProviderProps { children: React.ReactNode; config: CodattaSigninConfig; diff --git a/dist/secp256k1-BZeczIQv.js b/dist/secp256k1-BZeczIQv.js deleted file mode 100644 index 6a90324..0000000 --- a/dist/secp256k1-BZeczIQv.js +++ /dev/null @@ -1,1286 +0,0 @@ -import { H as ee, h as ne, t as re, e as Zt, b as oe, r as ie, c as se, s as ce } from "./main-7Oj8aJZz.js"; -class Kt extends ee { - constructor(n, t) { - super(), this.finished = !1, this.destroyed = !1, ne(n); - const r = re(t); - if (this.iHash = n.create(), typeof this.iHash.update != "function") - throw new Error("Expected instance of class which extends utils.Hash"); - this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen; - const s = this.blockLen, o = new Uint8Array(s); - o.set(r.length > s ? n.create().update(r).digest() : r); - for (let a = 0; a < o.length; a++) - o[a] ^= 54; - this.iHash.update(o), this.oHash = n.create(); - for (let a = 0; a < o.length; a++) - o[a] ^= 106; - this.oHash.update(o), o.fill(0); - } - update(n) { - return Zt(this), this.iHash.update(n), this; - } - digestInto(n) { - Zt(this), oe(n, this.outputLen), this.finished = !0, this.iHash.digestInto(n), this.oHash.update(n), this.oHash.digestInto(n), this.destroy(); - } - digest() { - const n = new Uint8Array(this.oHash.outputLen); - return this.digestInto(n), n; - } - _cloneInto(n) { - n || (n = Object.create(Object.getPrototypeOf(this), {})); - const { oHash: t, iHash: r, finished: s, destroyed: o, blockLen: a, outputLen: f } = this; - return n = n, n.finished = s, n.destroyed = o, n.blockLen = a, n.outputLen = f, n.oHash = t._cloneInto(n.oHash), n.iHash = r._cloneInto(n.iHash), n; - } - destroy() { - this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy(); - } -} -const Pt = (e, n, t) => new Kt(e, n).update(t).digest(); -Pt.create = (e, n) => new Kt(e, n); -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const qt = /* @__PURE__ */ BigInt(0), wt = /* @__PURE__ */ BigInt(1), fe = /* @__PURE__ */ BigInt(2); -function nt(e) { - return e instanceof Uint8Array || e != null && typeof e == "object" && e.constructor.name === "Uint8Array"; -} -function ht(e) { - if (!nt(e)) - throw new Error("Uint8Array expected"); -} -function ct(e, n) { - if (typeof n != "boolean") - throw new Error(`${e} must be valid boolean, got "${n}".`); -} -const ae = /* @__PURE__ */ Array.from({ length: 256 }, (e, n) => n.toString(16).padStart(2, "0")); -function ft(e) { - ht(e); - let n = ""; - for (let t = 0; t < e.length; t++) - n += ae[e[t]]; - return n; -} -function st(e) { - const n = e.toString(16); - return n.length & 1 ? `0${n}` : n; -} -function Ot(e) { - if (typeof e != "string") - throw new Error("hex string expected, got " + typeof e); - return BigInt(e === "" ? "0" : `0x${e}`); -} -const P = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 }; -function Rt(e) { - if (e >= P._0 && e <= P._9) - return e - P._0; - if (e >= P._A && e <= P._F) - return e - (P._A - 10); - if (e >= P._a && e <= P._f) - return e - (P._a - 10); -} -function at(e) { - if (typeof e != "string") - throw new Error("hex string expected, got " + typeof e); - const n = e.length, t = n / 2; - if (n % 2) - throw new Error("padded hex string expected, got unpadded hex of length " + n); - const r = new Uint8Array(t); - for (let s = 0, o = 0; s < t; s++, o += 2) { - const a = Rt(e.charCodeAt(o)), f = Rt(e.charCodeAt(o + 1)); - if (a === void 0 || f === void 0) { - const i = e[o] + e[o + 1]; - throw new Error('hex string expected, got non-hex character "' + i + '" at index ' + o); - } - r[s] = a * 16 + f; - } - return r; -} -function tt(e) { - return Ot(ft(e)); -} -function Nt(e) { - return ht(e), Ot(ft(Uint8Array.from(e).reverse())); -} -function lt(e, n) { - return at(e.toString(16).padStart(n * 2, "0")); -} -function $t(e, n) { - return lt(e, n).reverse(); -} -function le(e) { - return at(st(e)); -} -function K(e, n, t) { - let r; - if (typeof n == "string") - try { - r = at(n); - } catch (o) { - throw new Error(`${e} must be valid hex string, got "${n}". Cause: ${o}`); - } - else if (nt(n)) - r = Uint8Array.from(n); - else - throw new Error(`${e} must be hex string or Uint8Array`); - const s = r.length; - if (typeof t == "number" && s !== t) - throw new Error(`${e} expected ${t} bytes, got ${s}`); - return r; -} -function dt(...e) { - let n = 0; - for (let r = 0; r < e.length; r++) { - const s = e[r]; - ht(s), n += s.length; - } - const t = new Uint8Array(n); - for (let r = 0, s = 0; r < e.length; r++) { - const o = e[r]; - t.set(o, s), s += o.length; - } - return t; -} -function ue(e, n) { - if (e.length !== n.length) - return !1; - let t = 0; - for (let r = 0; r < e.length; r++) - t |= e[r] ^ n[r]; - return t === 0; -} -function de(e) { - if (typeof e != "string") - throw new Error(`utf8ToBytes expected string, got ${typeof e}`); - return new Uint8Array(new TextEncoder().encode(e)); -} -const mt = (e) => typeof e == "bigint" && qt <= e; -function yt(e, n, t) { - return mt(e) && mt(n) && mt(t) && n <= e && e < t; -} -function et(e, n, t, r) { - if (!yt(n, t, r)) - throw new Error(`expected valid ${e}: ${t} <= n < ${r}, got ${typeof n} ${n}`); -} -function Ft(e) { - let n; - for (n = 0; e > qt; e >>= wt, n += 1) - ; - return n; -} -function he(e, n) { - return e >> BigInt(n) & wt; -} -function ge(e, n, t) { - return e | (t ? wt : qt) << BigInt(n); -} -const Lt = (e) => (fe << BigInt(e - 1)) - wt, bt = (e) => new Uint8Array(e), zt = (e) => Uint8Array.from(e); -function Gt(e, n, t) { - if (typeof e != "number" || e < 2) - throw new Error("hashLen must be a number"); - if (typeof n != "number" || n < 2) - throw new Error("qByteLen must be a number"); - if (typeof t != "function") - throw new Error("hmacFn must be a function"); - let r = bt(e), s = bt(e), o = 0; - const a = () => { - r.fill(1), s.fill(0), o = 0; - }, f = (...E) => t(s, r, ...E), i = (E = bt()) => { - s = f(zt([0]), E), r = f(), E.length !== 0 && (s = f(zt([1]), E), r = f()); - }, l = () => { - if (o++ >= 1e3) - throw new Error("drbg: tried 1000 values"); - let E = 0; - const u = []; - for (; E < n; ) { - r = f(); - const q = r.slice(); - u.push(q), E += r.length; - } - return dt(...u); - }; - return (E, u) => { - a(), i(E); - let q; - for (; !(q = u(l())); ) - i(); - return a(), q; - }; -} -const we = { - bigint: (e) => typeof e == "bigint", - function: (e) => typeof e == "function", - boolean: (e) => typeof e == "boolean", - string: (e) => typeof e == "string", - stringOrUint8Array: (e) => typeof e == "string" || nt(e), - isSafeInteger: (e) => Number.isSafeInteger(e), - array: (e) => Array.isArray(e), - field: (e, n) => n.Fp.isValid(e), - hash: (e) => typeof e == "function" && Number.isSafeInteger(e.outputLen) -}; -function gt(e, n, t = {}) { - const r = (s, o, a) => { - const f = we[o]; - if (typeof f != "function") - throw new Error(`Invalid validator "${o}", expected function`); - const i = e[s]; - if (!(a && i === void 0) && !f(i, e)) - throw new Error(`Invalid param ${String(s)}=${i} (${typeof i}), expected ${o}`); - }; - for (const [s, o] of Object.entries(n)) - r(s, o, !1); - for (const [s, o] of Object.entries(t)) - r(s, o, !0); - return e; -} -const ye = () => { - throw new Error("not implemented"); -}; -function vt(e) { - const n = /* @__PURE__ */ new WeakMap(); - return (t, ...r) => { - const s = n.get(t); - if (s !== void 0) - return s; - const o = e(t, ...r); - return n.set(t, o), o; - }; -} -const pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ - __proto__: null, - aInRange: et, - abool: ct, - abytes: ht, - bitGet: he, - bitLen: Ft, - bitMask: Lt, - bitSet: ge, - bytesToHex: ft, - bytesToNumberBE: tt, - bytesToNumberLE: Nt, - concatBytes: dt, - createHmacDrbg: Gt, - ensureBytes: K, - equalBytes: ue, - hexToBytes: at, - hexToNumber: Ot, - inRange: yt, - isBytes: nt, - memoized: vt, - notImplemented: ye, - numberToBytesBE: lt, - numberToBytesLE: $t, - numberToHexUnpadded: st, - numberToVarBytesBE: le, - utf8ToBytes: de, - validateObject: gt -}, Symbol.toStringTag, { value: "Module" })); -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const R = BigInt(0), _ = BigInt(1), J = BigInt(2), me = BigInt(3), xt = BigInt(4), kt = BigInt(5), Ut = BigInt(8); -BigInt(9); -BigInt(16); -function U(e, n) { - const t = e % n; - return t >= R ? t : n + t; -} -function be(e, n, t) { - if (t <= R || n < R) - throw new Error("Expected power/modulo > 0"); - if (t === _) - return R; - let r = _; - for (; n > R; ) - n & _ && (r = r * e % t), e = e * e % t, n >>= _; - return r; -} -function V(e, n, t) { - let r = e; - for (; n-- > R; ) - r *= r, r %= t; - return r; -} -function St(e, n) { - if (e === R || n <= R) - throw new Error(`invert: expected positive integers, got n=${e} mod=${n}`); - let t = U(e, n), r = n, s = R, o = _; - for (; t !== R; ) { - const f = r / t, i = r % t, l = s - o * f; - r = t, t = i, s = o, o = l; - } - if (r !== _) - throw new Error("invert: does not exist"); - return U(s, n); -} -function Ee(e) { - const n = (e - _) / J; - let t, r, s; - for (t = e - _, r = 0; t % J === R; t /= J, r++) - ; - for (s = J; s < e && be(s, n, e) !== e - _; s++) - ; - if (r === 1) { - const a = (e + _) / xt; - return function(i, l) { - const m = i.pow(l, a); - if (!i.eql(i.sqr(m), l)) - throw new Error("Cannot find square root"); - return m; - }; - } - const o = (t + _) / J; - return function(f, i) { - if (f.pow(i, n) === f.neg(f.ONE)) - throw new Error("Cannot find square root"); - let l = r, m = f.pow(f.mul(f.ONE, s), t), E = f.pow(i, o), u = f.pow(i, t); - for (; !f.eql(u, f.ONE); ) { - if (f.eql(u, f.ZERO)) - return f.ZERO; - let q = 1; - for (let p = f.sqr(u); q < l && !f.eql(p, f.ONE); q++) - p = f.sqr(p); - const T = f.pow(m, _ << BigInt(l - q - 1)); - m = f.sqr(T), E = f.mul(E, T), u = f.mul(u, m), l = q; - } - return E; - }; -} -function Be(e) { - if (e % xt === me) { - const n = (e + _) / xt; - return function(r, s) { - const o = r.pow(s, n); - if (!r.eql(r.sqr(o), s)) - throw new Error("Cannot find square root"); - return o; - }; - } - if (e % Ut === kt) { - const n = (e - kt) / Ut; - return function(r, s) { - const o = r.mul(s, J), a = r.pow(o, n), f = r.mul(s, a), i = r.mul(r.mul(f, J), a), l = r.mul(f, r.sub(i, r.ONE)); - if (!r.eql(r.sqr(l), s)) - throw new Error("Cannot find square root"); - return l; - }; - } - return Ee(e); -} -const ve = [ - "create", - "isValid", - "is0", - "neg", - "inv", - "sqrt", - "sqr", - "eql", - "add", - "sub", - "mul", - "pow", - "div", - "addN", - "subN", - "mulN", - "sqrN" -]; -function xe(e) { - const n = { - ORDER: "bigint", - MASK: "bigint", - BYTES: "isSafeInteger", - BITS: "isSafeInteger" - }, t = ve.reduce((r, s) => (r[s] = "function", r), n); - return gt(e, t); -} -function Se(e, n, t) { - if (t < R) - throw new Error("Expected power > 0"); - if (t === R) - return e.ONE; - if (t === _) - return n; - let r = e.ONE, s = n; - for (; t > R; ) - t & _ && (r = e.mul(r, s)), s = e.sqr(s), t >>= _; - return r; -} -function Ie(e, n) { - const t = new Array(n.length), r = n.reduce((o, a, f) => e.is0(a) ? o : (t[f] = o, e.mul(o, a)), e.ONE), s = e.inv(r); - return n.reduceRight((o, a, f) => e.is0(a) ? o : (t[f] = e.mul(o, t[f]), e.mul(o, a)), s), t; -} -function Wt(e, n) { - const t = n !== void 0 ? n : e.toString(2).length, r = Math.ceil(t / 8); - return { nBitLength: t, nByteLength: r }; -} -function Xt(e, n, t = !1, r = {}) { - if (e <= R) - throw new Error(`Expected Field ORDER > 0, got ${e}`); - const { nBitLength: s, nByteLength: o } = Wt(e, n); - if (o > 2048) - throw new Error("Field lengths over 2048 bytes are not supported"); - const a = Be(e), f = Object.freeze({ - ORDER: e, - BITS: s, - BYTES: o, - MASK: Lt(s), - ZERO: R, - ONE: _, - create: (i) => U(i, e), - isValid: (i) => { - if (typeof i != "bigint") - throw new Error(`Invalid field element: expected bigint, got ${typeof i}`); - return R <= i && i < e; - }, - is0: (i) => i === R, - isOdd: (i) => (i & _) === _, - neg: (i) => U(-i, e), - eql: (i, l) => i === l, - sqr: (i) => U(i * i, e), - add: (i, l) => U(i + l, e), - sub: (i, l) => U(i - l, e), - mul: (i, l) => U(i * l, e), - pow: (i, l) => Se(f, i, l), - div: (i, l) => U(i * St(l, e), e), - // Same as above, but doesn't normalize - sqrN: (i) => i * i, - addN: (i, l) => i + l, - subN: (i, l) => i - l, - mulN: (i, l) => i * l, - inv: (i) => St(i, e), - sqrt: r.sqrt || ((i) => a(f, i)), - invertBatch: (i) => Ie(f, i), - // TODO: do we really need constant cmov? - // We don't have const-time bigints anyway, so probably will be not very useful - cmov: (i, l, m) => m ? l : i, - toBytes: (i) => t ? $t(i, o) : lt(i, o), - fromBytes: (i) => { - if (i.length !== o) - throw new Error(`Fp.fromBytes: expected ${o}, got ${i.length}`); - return t ? Nt(i) : tt(i); - } - }); - return Object.freeze(f); -} -function Dt(e) { - if (typeof e != "bigint") - throw new Error("field order must be bigint"); - const n = e.toString(2).length; - return Math.ceil(n / 8); -} -function Qt(e) { - const n = Dt(e); - return n + Math.ceil(n / 2); -} -function Ae(e, n, t = !1) { - const r = e.length, s = Dt(n), o = Qt(n); - if (r < 16 || r < o || r > 1024) - throw new Error(`expected ${o}-1024 bytes of input, got ${r}`); - const a = t ? tt(e) : Nt(e), f = U(a, n - _) + _; - return t ? $t(f, s) : lt(f, s); -} -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const qe = BigInt(0), Et = BigInt(1), Bt = /* @__PURE__ */ new WeakMap(), Ct = /* @__PURE__ */ new WeakMap(); -function Oe(e, n) { - const t = (o, a) => { - const f = a.negate(); - return o ? f : a; - }, r = (o) => { - if (!Number.isSafeInteger(o) || o <= 0 || o > n) - throw new Error(`Wrong window size=${o}, should be [1..${n}]`); - }, s = (o) => { - r(o); - const a = Math.ceil(n / o) + 1, f = 2 ** (o - 1); - return { windows: a, windowSize: f }; - }; - return { - constTimeNegate: t, - // non-const time multiplication ladder - unsafeLadder(o, a) { - let f = e.ZERO, i = o; - for (; a > qe; ) - a & Et && (f = f.add(i)), i = i.double(), a >>= Et; - return f; - }, - /** - * Creates a wNAF precomputation window. Used for caching. - * Default window size is set by `utils.precompute()` and is equal to 8. - * Number of precomputed points depends on the curve size: - * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where: - * - 𝑊 is the window size - * - 𝑛 is the bitlength of the curve order. - * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. - * @returns precomputed point tables flattened to a single array - */ - precomputeWindow(o, a) { - const { windows: f, windowSize: i } = s(a), l = []; - let m = o, E = m; - for (let u = 0; u < f; u++) { - E = m, l.push(E); - for (let q = 1; q < i; q++) - E = E.add(m), l.push(E); - m = E.double(); - } - return l; - }, - /** - * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. - * @param W window size - * @param precomputes precomputed tables - * @param n scalar (we don't check here, but should be less than curve order) - * @returns real and fake (for const-time) points - */ - wNAF(o, a, f) { - const { windows: i, windowSize: l } = s(o); - let m = e.ZERO, E = e.BASE; - const u = BigInt(2 ** o - 1), q = 2 ** o, T = BigInt(o); - for (let p = 0; p < i; p++) { - const c = p * l; - let h = Number(f & u); - f >>= T, h > l && (h -= q, f += Et); - const y = c, B = c + Math.abs(h) - 1, x = p % 2 !== 0, O = h < 0; - h === 0 ? E = E.add(t(x, a[y])) : m = m.add(t(O, a[B])); - } - return { p: m, f: E }; - }, - wNAFCached(o, a, f) { - const i = Ct.get(o) || 1; - let l = Bt.get(o); - return l || (l = this.precomputeWindow(o, i), i !== 1 && Bt.set(o, f(l))), this.wNAF(i, l, a); - }, - // We calculate precomputes for elliptic curve point multiplication - // using windowed method. This specifies window size and - // stores precomputed values. Usually only base point would be precomputed. - setWindowSize(o, a) { - r(a), Ct.set(o, a), Bt.delete(o); - } - }; -} -function Ne(e, n, t, r) { - if (!Array.isArray(t) || !Array.isArray(r) || r.length !== t.length) - throw new Error("arrays of points and scalars must have equal length"); - r.forEach((m, E) => { - if (!n.isValid(m)) - throw new Error(`wrong scalar at index ${E}`); - }), t.forEach((m, E) => { - if (!(m instanceof e)) - throw new Error(`wrong point at index ${E}`); - }); - const s = Ft(BigInt(t.length)), o = s > 12 ? s - 3 : s > 4 ? s - 2 : s ? 2 : 1, a = (1 << o) - 1, f = new Array(a + 1).fill(e.ZERO), i = Math.floor((n.BITS - 1) / o) * o; - let l = e.ZERO; - for (let m = i; m >= 0; m -= o) { - f.fill(e.ZERO); - for (let u = 0; u < r.length; u++) { - const q = r[u], T = Number(q >> BigInt(m) & BigInt(a)); - f[T] = f[T].add(t[u]); - } - let E = e.ZERO; - for (let u = f.length - 1, q = e.ZERO; u > 0; u--) - q = q.add(f[u]), E = E.add(q); - if (l = l.add(E), m !== 0) - for (let u = 0; u < o; u++) - l = l.double(); - } - return l; -} -function Jt(e) { - return xe(e.Fp), gt(e, { - n: "bigint", - h: "bigint", - Gx: "field", - Gy: "field" - }, { - nBitLength: "isSafeInteger", - nByteLength: "isSafeInteger" - }), Object.freeze({ - ...Wt(e.n, e.nBitLength), - ...e, - p: e.Fp.ORDER - }); -} -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -function jt(e) { - e.lowS !== void 0 && ct("lowS", e.lowS), e.prehash !== void 0 && ct("prehash", e.prehash); -} -function $e(e) { - const n = Jt(e); - gt(n, { - a: "field", - b: "field" - }, { - allowedPrivateKeyLengths: "array", - wrapPrivateKey: "boolean", - isTorsionFree: "function", - clearCofactor: "function", - allowInfinityPoint: "boolean", - fromBytes: "function", - toBytes: "function" - }); - const { endo: t, Fp: r, a: s } = n; - if (t) { - if (!r.eql(s, r.ZERO)) - throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0"); - if (typeof t != "object" || typeof t.beta != "bigint" || typeof t.splitScalar != "function") - throw new Error("Expected endomorphism with beta: bigint and splitScalar: function"); - } - return Object.freeze({ ...n }); -} -const { bytesToNumberBE: Le, hexToBytes: _e } = pe, F = { - // asn.1 DER encoding utils - Err: class extends Error { - constructor(n = "") { - super(n); - } - }, - // Basic building block is TLV (Tag-Length-Value) - _tlv: { - encode: (e, n) => { - const { Err: t } = F; - if (e < 0 || e > 256) - throw new t("tlv.encode: wrong tag"); - if (n.length & 1) - throw new t("tlv.encode: unpadded data"); - const r = n.length / 2, s = st(r); - if (s.length / 2 & 128) - throw new t("tlv.encode: long form length too big"); - const o = r > 127 ? st(s.length / 2 | 128) : ""; - return `${st(e)}${o}${s}${n}`; - }, - // v - value, l - left bytes (unparsed) - decode(e, n) { - const { Err: t } = F; - let r = 0; - if (e < 0 || e > 256) - throw new t("tlv.encode: wrong tag"); - if (n.length < 2 || n[r++] !== e) - throw new t("tlv.decode: wrong tlv"); - const s = n[r++], o = !!(s & 128); - let a = 0; - if (!o) - a = s; - else { - const i = s & 127; - if (!i) - throw new t("tlv.decode(long): indefinite length not supported"); - if (i > 4) - throw new t("tlv.decode(long): byte length is too big"); - const l = n.subarray(r, r + i); - if (l.length !== i) - throw new t("tlv.decode: length bytes not complete"); - if (l[0] === 0) - throw new t("tlv.decode(long): zero leftmost byte"); - for (const m of l) - a = a << 8 | m; - if (r += i, a < 128) - throw new t("tlv.decode(long): not minimal encoding"); - } - const f = n.subarray(r, r + a); - if (f.length !== a) - throw new t("tlv.decode: wrong value length"); - return { v: f, l: n.subarray(r + a) }; - } - }, - // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag, - // since we always use positive integers here. It must always be empty: - // - add zero byte if exists - // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding) - _int: { - encode(e) { - const { Err: n } = F; - if (e < G) - throw new n("integer: negative integers are not allowed"); - let t = st(e); - if (Number.parseInt(t[0], 16) & 8 && (t = "00" + t), t.length & 1) - throw new n("unexpected assertion"); - return t; - }, - decode(e) { - const { Err: n } = F; - if (e[0] & 128) - throw new n("Invalid signature integer: negative"); - if (e[0] === 0 && !(e[1] & 128)) - throw new n("Invalid signature integer: unnecessary leading zero"); - return Le(e); - } - }, - toSig(e) { - const { Err: n, _int: t, _tlv: r } = F, s = typeof e == "string" ? _e(e) : e; - ht(s); - const { v: o, l: a } = r.decode(48, s); - if (a.length) - throw new n("Invalid signature: left bytes after parsing"); - const { v: f, l: i } = r.decode(2, o), { v: l, l: m } = r.decode(2, i); - if (m.length) - throw new n("Invalid signature: left bytes after parsing"); - return { r: t.decode(f), s: t.decode(l) }; - }, - hexFromSig(e) { - const { _tlv: n, _int: t } = F, r = `${n.encode(2, t.encode(e.r))}${n.encode(2, t.encode(e.s))}`; - return n.encode(48, r); - } -}, G = BigInt(0), Z = BigInt(1); -BigInt(2); -const Vt = BigInt(3); -BigInt(4); -function Te(e) { - const n = $e(e), { Fp: t } = n, r = Xt(n.n, n.nBitLength), s = n.toBytes || ((p, c, h) => { - const y = c.toAffine(); - return dt(Uint8Array.from([4]), t.toBytes(y.x), t.toBytes(y.y)); - }), o = n.fromBytes || ((p) => { - const c = p.subarray(1), h = t.fromBytes(c.subarray(0, t.BYTES)), y = t.fromBytes(c.subarray(t.BYTES, 2 * t.BYTES)); - return { x: h, y }; - }); - function a(p) { - const { a: c, b: h } = n, y = t.sqr(p), B = t.mul(y, p); - return t.add(t.add(B, t.mul(p, c)), h); - } - if (!t.eql(t.sqr(n.Gy), a(n.Gx))) - throw new Error("bad generator point: equation left != right"); - function f(p) { - return yt(p, Z, n.n); - } - function i(p) { - const { allowedPrivateKeyLengths: c, nByteLength: h, wrapPrivateKey: y, n: B } = n; - if (c && typeof p != "bigint") { - if (nt(p) && (p = ft(p)), typeof p != "string" || !c.includes(p.length)) - throw new Error("Invalid key"); - p = p.padStart(h * 2, "0"); - } - let x; - try { - x = typeof p == "bigint" ? p : tt(K("private key", p, h)); - } catch { - throw new Error(`private key must be ${h} bytes, hex or bigint, not ${typeof p}`); - } - return y && (x = U(x, B)), et("private key", x, Z, B), x; - } - function l(p) { - if (!(p instanceof u)) - throw new Error("ProjectivePoint expected"); - } - const m = vt((p, c) => { - const { px: h, py: y, pz: B } = p; - if (t.eql(B, t.ONE)) - return { x: h, y }; - const x = p.is0(); - c == null && (c = x ? t.ONE : t.inv(B)); - const O = t.mul(h, c), S = t.mul(y, c), b = t.mul(B, c); - if (x) - return { x: t.ZERO, y: t.ZERO }; - if (!t.eql(b, t.ONE)) - throw new Error("invZ was invalid"); - return { x: O, y: S }; - }), E = vt((p) => { - if (p.is0()) { - if (n.allowInfinityPoint && !t.is0(p.py)) - return; - throw new Error("bad point: ZERO"); - } - const { x: c, y: h } = p.toAffine(); - if (!t.isValid(c) || !t.isValid(h)) - throw new Error("bad point: x or y not FE"); - const y = t.sqr(h), B = a(c); - if (!t.eql(y, B)) - throw new Error("bad point: equation left != right"); - if (!p.isTorsionFree()) - throw new Error("bad point: not in prime-order subgroup"); - return !0; - }); - class u { - constructor(c, h, y) { - if (this.px = c, this.py = h, this.pz = y, c == null || !t.isValid(c)) - throw new Error("x required"); - if (h == null || !t.isValid(h)) - throw new Error("y required"); - if (y == null || !t.isValid(y)) - throw new Error("z required"); - Object.freeze(this); - } - // Does not validate if the point is on-curve. - // Use fromHex instead, or call assertValidity() later. - static fromAffine(c) { - const { x: h, y } = c || {}; - if (!c || !t.isValid(h) || !t.isValid(y)) - throw new Error("invalid affine point"); - if (c instanceof u) - throw new Error("projective point not allowed"); - const B = (x) => t.eql(x, t.ZERO); - return B(h) && B(y) ? u.ZERO : new u(h, y, t.ONE); - } - get x() { - return this.toAffine().x; - } - get y() { - return this.toAffine().y; - } - /** - * Takes a bunch of Projective Points but executes only one - * inversion on all of them. Inversion is very slow operation, - * so this improves performance massively. - * Optimization: converts a list of projective points to a list of identical points with Z=1. - */ - static normalizeZ(c) { - const h = t.invertBatch(c.map((y) => y.pz)); - return c.map((y, B) => y.toAffine(h[B])).map(u.fromAffine); - } - /** - * Converts hash string or Uint8Array to Point. - * @param hex short/long ECDSA hex - */ - static fromHex(c) { - const h = u.fromAffine(o(K("pointHex", c))); - return h.assertValidity(), h; - } - // Multiplies generator point by privateKey. - static fromPrivateKey(c) { - return u.BASE.multiply(i(c)); - } - // Multiscalar Multiplication - static msm(c, h) { - return Ne(u, r, c, h); - } - // "Private method", don't use it directly - _setWindowSize(c) { - T.setWindowSize(this, c); - } - // A point on curve is valid if it conforms to equation. - assertValidity() { - E(this); - } - hasEvenY() { - const { y: c } = this.toAffine(); - if (t.isOdd) - return !t.isOdd(c); - throw new Error("Field doesn't support isOdd"); - } - /** - * Compare one point to another. - */ - equals(c) { - l(c); - const { px: h, py: y, pz: B } = this, { px: x, py: O, pz: S } = c, b = t.eql(t.mul(h, S), t.mul(x, B)), v = t.eql(t.mul(y, S), t.mul(O, B)); - return b && v; - } - /** - * Flips point to one corresponding to (x, -y) in Affine coordinates. - */ - negate() { - return new u(this.px, t.neg(this.py), this.pz); - } - // Renes-Costello-Batina exception-free doubling formula. - // There is 30% faster Jacobian formula, but it is not complete. - // https://eprint.iacr.org/2015/1060, algorithm 3 - // Cost: 8M + 3S + 3*a + 2*b3 + 15add. - double() { - const { a: c, b: h } = n, y = t.mul(h, Vt), { px: B, py: x, pz: O } = this; - let S = t.ZERO, b = t.ZERO, v = t.ZERO, A = t.mul(B, B), j = t.mul(x, x), L = t.mul(O, O), N = t.mul(B, x); - return N = t.add(N, N), v = t.mul(B, O), v = t.add(v, v), S = t.mul(c, v), b = t.mul(y, L), b = t.add(S, b), S = t.sub(j, b), b = t.add(j, b), b = t.mul(S, b), S = t.mul(N, S), v = t.mul(y, v), L = t.mul(c, L), N = t.sub(A, L), N = t.mul(c, N), N = t.add(N, v), v = t.add(A, A), A = t.add(v, A), A = t.add(A, L), A = t.mul(A, N), b = t.add(b, A), L = t.mul(x, O), L = t.add(L, L), A = t.mul(L, N), S = t.sub(S, A), v = t.mul(L, j), v = t.add(v, v), v = t.add(v, v), new u(S, b, v); - } - // Renes-Costello-Batina exception-free addition formula. - // There is 30% faster Jacobian formula, but it is not complete. - // https://eprint.iacr.org/2015/1060, algorithm 1 - // Cost: 12M + 0S + 3*a + 3*b3 + 23add. - add(c) { - l(c); - const { px: h, py: y, pz: B } = this, { px: x, py: O, pz: S } = c; - let b = t.ZERO, v = t.ZERO, A = t.ZERO; - const j = n.a, L = t.mul(n.b, Vt); - let N = t.mul(h, x), C = t.mul(y, O), d = t.mul(B, S), g = t.add(h, y), w = t.add(x, O); - g = t.mul(g, w), w = t.add(N, C), g = t.sub(g, w), w = t.add(h, B); - let I = t.add(x, S); - return w = t.mul(w, I), I = t.add(N, d), w = t.sub(w, I), I = t.add(y, B), b = t.add(O, S), I = t.mul(I, b), b = t.add(C, d), I = t.sub(I, b), A = t.mul(j, w), b = t.mul(L, d), A = t.add(b, A), b = t.sub(C, A), A = t.add(C, A), v = t.mul(b, A), C = t.add(N, N), C = t.add(C, N), d = t.mul(j, d), w = t.mul(L, w), C = t.add(C, d), d = t.sub(N, d), d = t.mul(j, d), w = t.add(w, d), N = t.mul(C, w), v = t.add(v, N), N = t.mul(I, w), b = t.mul(g, b), b = t.sub(b, N), N = t.mul(g, C), A = t.mul(I, A), A = t.add(A, N), new u(b, v, A); - } - subtract(c) { - return this.add(c.negate()); - } - is0() { - return this.equals(u.ZERO); - } - wNAF(c) { - return T.wNAFCached(this, c, u.normalizeZ); - } - /** - * Non-constant-time multiplication. Uses double-and-add algorithm. - * It's faster, but should only be used when you don't care about - * an exposed private key e.g. sig verification, which works over *public* keys. - */ - multiplyUnsafe(c) { - et("scalar", c, G, n.n); - const h = u.ZERO; - if (c === G) - return h; - if (c === Z) - return this; - const { endo: y } = n; - if (!y) - return T.unsafeLadder(this, c); - let { k1neg: B, k1: x, k2neg: O, k2: S } = y.splitScalar(c), b = h, v = h, A = this; - for (; x > G || S > G; ) - x & Z && (b = b.add(A)), S & Z && (v = v.add(A)), A = A.double(), x >>= Z, S >>= Z; - return B && (b = b.negate()), O && (v = v.negate()), v = new u(t.mul(v.px, y.beta), v.py, v.pz), b.add(v); - } - /** - * Constant time multiplication. - * Uses wNAF method. Windowed method may be 10% faster, - * but takes 2x longer to generate and consumes 2x memory. - * Uses precomputes when available. - * Uses endomorphism for Koblitz curves. - * @param scalar by which the point would be multiplied - * @returns New point - */ - multiply(c) { - const { endo: h, n: y } = n; - et("scalar", c, Z, y); - let B, x; - if (h) { - const { k1neg: O, k1: S, k2neg: b, k2: v } = h.splitScalar(c); - let { p: A, f: j } = this.wNAF(S), { p: L, f: N } = this.wNAF(v); - A = T.constTimeNegate(O, A), L = T.constTimeNegate(b, L), L = new u(t.mul(L.px, h.beta), L.py, L.pz), B = A.add(L), x = j.add(N); - } else { - const { p: O, f: S } = this.wNAF(c); - B = O, x = S; - } - return u.normalizeZ([B, x])[0]; - } - /** - * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly. - * Not using Strauss-Shamir trick: precomputation tables are faster. - * The trick could be useful if both P and Q are not G (not in our case). - * @returns non-zero affine point - */ - multiplyAndAddUnsafe(c, h, y) { - const B = u.BASE, x = (S, b) => b === G || b === Z || !S.equals(B) ? S.multiplyUnsafe(b) : S.multiply(b), O = x(this, h).add(x(c, y)); - return O.is0() ? void 0 : O; - } - // Converts Projective point to affine (x, y) coordinates. - // Can accept precomputed Z^-1 - for example, from invertBatch. - // (x, y, z) ∋ (x=x/z, y=y/z) - toAffine(c) { - return m(this, c); - } - isTorsionFree() { - const { h: c, isTorsionFree: h } = n; - if (c === Z) - return !0; - if (h) - return h(u, this); - throw new Error("isTorsionFree() has not been declared for the elliptic curve"); - } - clearCofactor() { - const { h: c, clearCofactor: h } = n; - return c === Z ? this : h ? h(u, this) : this.multiplyUnsafe(n.h); - } - toRawBytes(c = !0) { - return ct("isCompressed", c), this.assertValidity(), s(u, this, c); - } - toHex(c = !0) { - return ct("isCompressed", c), ft(this.toRawBytes(c)); - } - } - u.BASE = new u(n.Gx, n.Gy, t.ONE), u.ZERO = new u(t.ZERO, t.ONE, t.ZERO); - const q = n.nBitLength, T = Oe(u, n.endo ? Math.ceil(q / 2) : q); - return { - CURVE: n, - ProjectivePoint: u, - normPrivateKeyToScalar: i, - weierstrassEquation: a, - isWithinCurveOrder: f - }; -} -function He(e) { - const n = Jt(e); - return gt(n, { - hash: "hash", - hmac: "function", - randomBytes: "function" - }, { - bits2int: "function", - bits2int_modN: "function", - lowS: "boolean" - }), Object.freeze({ lowS: !0, ...n }); -} -function Ze(e) { - const n = He(e), { Fp: t, n: r } = n, s = t.BYTES + 1, o = 2 * t.BYTES + 1; - function a(d) { - return U(d, r); - } - function f(d) { - return St(d, r); - } - const { ProjectivePoint: i, normPrivateKeyToScalar: l, weierstrassEquation: m, isWithinCurveOrder: E } = Te({ - ...n, - toBytes(d, g, w) { - const I = g.toAffine(), $ = t.toBytes(I.x), H = dt; - return ct("isCompressed", w), w ? H(Uint8Array.from([g.hasEvenY() ? 2 : 3]), $) : H(Uint8Array.from([4]), $, t.toBytes(I.y)); - }, - fromBytes(d) { - const g = d.length, w = d[0], I = d.subarray(1); - if (g === s && (w === 2 || w === 3)) { - const $ = tt(I); - if (!yt($, Z, t.ORDER)) - throw new Error("Point is not on curve"); - const H = m($); - let z; - try { - z = t.sqrt(H); - } catch (M) { - const X = M instanceof Error ? ": " + M.message : ""; - throw new Error("Point is not on curve" + X); - } - const k = (z & Z) === Z; - return (w & 1) === 1 !== k && (z = t.neg(z)), { x: $, y: z }; - } else if (g === o && w === 4) { - const $ = t.fromBytes(I.subarray(0, t.BYTES)), H = t.fromBytes(I.subarray(t.BYTES, 2 * t.BYTES)); - return { x: $, y: H }; - } else - throw new Error(`Point of length ${g} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`); - } - }), u = (d) => ft(lt(d, n.nByteLength)); - function q(d) { - const g = r >> Z; - return d > g; - } - function T(d) { - return q(d) ? a(-d) : d; - } - const p = (d, g, w) => tt(d.slice(g, w)); - class c { - constructor(g, w, I) { - this.r = g, this.s = w, this.recovery = I, this.assertValidity(); - } - // pair (bytes of r, bytes of s) - static fromCompact(g) { - const w = n.nByteLength; - return g = K("compactSignature", g, w * 2), new c(p(g, 0, w), p(g, w, 2 * w)); - } - // DER encoded ECDSA signature - // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script - static fromDER(g) { - const { r: w, s: I } = F.toSig(K("DER", g)); - return new c(w, I); - } - assertValidity() { - et("r", this.r, Z, r), et("s", this.s, Z, r); - } - addRecoveryBit(g) { - return new c(this.r, this.s, g); - } - recoverPublicKey(g) { - const { r: w, s: I, recovery: $ } = this, H = S(K("msgHash", g)); - if ($ == null || ![0, 1, 2, 3].includes($)) - throw new Error("recovery id invalid"); - const z = $ === 2 || $ === 3 ? w + n.n : w; - if (z >= t.ORDER) - throw new Error("recovery id 2 or 3 invalid"); - const k = $ & 1 ? "03" : "02", W = i.fromHex(k + u(z)), M = f(z), X = a(-H * M), ut = a(I * M), D = i.BASE.multiplyAndAddUnsafe(W, X, ut); - if (!D) - throw new Error("point at infinify"); - return D.assertValidity(), D; - } - // Signatures should be low-s, to prevent malleability. - hasHighS() { - return q(this.s); - } - normalizeS() { - return this.hasHighS() ? new c(this.r, a(-this.s), this.recovery) : this; - } - // DER-encoded - toDERRawBytes() { - return at(this.toDERHex()); - } - toDERHex() { - return F.hexFromSig({ r: this.r, s: this.s }); - } - // padded bytes of r, then padded bytes of s - toCompactRawBytes() { - return at(this.toCompactHex()); - } - toCompactHex() { - return u(this.r) + u(this.s); - } - } - const h = { - isValidPrivateKey(d) { - try { - return l(d), !0; - } catch { - return !1; - } - }, - normPrivateKeyToScalar: l, - /** - * Produces cryptographically secure private key from random of size - * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible. - */ - randomPrivateKey: () => { - const d = Qt(n.n); - return Ae(n.randomBytes(d), n.n); - }, - /** - * Creates precompute table for an arbitrary EC point. Makes point "cached". - * Allows to massively speed-up `point.multiply(scalar)`. - * @returns cached point - * @example - * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey)); - * fast.multiply(privKey); // much faster ECDH now - */ - precompute(d = 8, g = i.BASE) { - return g._setWindowSize(d), g.multiply(BigInt(3)), g; - } - }; - function y(d, g = !0) { - return i.fromPrivateKey(d).toRawBytes(g); - } - function B(d) { - const g = nt(d), w = typeof d == "string", I = (g || w) && d.length; - return g ? I === s || I === o : w ? I === 2 * s || I === 2 * o : d instanceof i; - } - function x(d, g, w = !0) { - if (B(d)) - throw new Error("first arg must be private key"); - if (!B(g)) - throw new Error("second arg must be public key"); - return i.fromHex(g).multiply(l(d)).toRawBytes(w); - } - const O = n.bits2int || function(d) { - const g = tt(d), w = d.length * 8 - n.nBitLength; - return w > 0 ? g >> BigInt(w) : g; - }, S = n.bits2int_modN || function(d) { - return a(O(d)); - }, b = Lt(n.nBitLength); - function v(d) { - return et(`num < 2^${n.nBitLength}`, d, G, b), lt(d, n.nByteLength); - } - function A(d, g, w = j) { - if (["recovered", "canonical"].some((Q) => Q in w)) - throw new Error("sign() legacy options not supported"); - const { hash: I, randomBytes: $ } = n; - let { lowS: H, prehash: z, extraEntropy: k } = w; - H == null && (H = !0), d = K("msgHash", d), jt(w), z && (d = K("prehashed msgHash", I(d))); - const W = S(d), M = l(g), X = [v(M), v(W)]; - if (k != null && k !== !1) { - const Q = k === !0 ? $(t.BYTES) : k; - X.push(K("extraEntropy", Q)); - } - const ut = dt(...X), D = W; - function pt(Q) { - const rt = O(Q); - if (!E(rt)) - return; - const _t = f(rt), ot = i.BASE.multiply(rt).toAffine(), Y = a(ot.x); - if (Y === G) - return; - const it = a(_t * a(D + Y * M)); - if (it === G) - return; - let Tt = (ot.x === Y ? 0 : 2) | Number(ot.y & Z), Ht = it; - return H && q(it) && (Ht = T(it), Tt ^= 1), new c(Y, Ht, Tt); - } - return { seed: ut, k2sig: pt }; - } - const j = { lowS: n.lowS, prehash: !1 }, L = { lowS: n.lowS, prehash: !1 }; - function N(d, g, w = j) { - const { seed: I, k2sig: $ } = A(d, g, w), H = n; - return Gt(H.hash.outputLen, H.nByteLength, H.hmac)(I, $); - } - i.BASE._setWindowSize(8); - function C(d, g, w, I = L) { - var ot; - const $ = d; - if (g = K("msgHash", g), w = K("publicKey", w), "strict" in I) - throw new Error("options.strict was renamed to lowS"); - jt(I); - const { lowS: H, prehash: z } = I; - let k, W; - try { - if (typeof $ == "string" || nt($)) - try { - k = c.fromDER($); - } catch (Y) { - if (!(Y instanceof F.Err)) - throw Y; - k = c.fromCompact($); - } - else if (typeof $ == "object" && typeof $.r == "bigint" && typeof $.s == "bigint") { - const { r: Y, s: it } = $; - k = new c(Y, it); - } else - throw new Error("PARSE"); - W = i.fromHex(w); - } catch (Y) { - if (Y.message === "PARSE") - throw new Error("signature must be Signature instance, Uint8Array or hex string"); - return !1; - } - if (H && k.hasHighS()) - return !1; - z && (g = n.hash(g)); - const { r: M, s: X } = k, ut = S(g), D = f(X), pt = a(ut * D), Q = a(M * D), rt = (ot = i.BASE.multiplyAndAddUnsafe(W, pt, Q)) == null ? void 0 : ot.toAffine(); - return rt ? a(rt.x) === M : !1; - } - return { - CURVE: n, - getPublicKey: y, - getSharedSecret: x, - sign: N, - verify: C, - ProjectivePoint: i, - Signature: c, - utils: h - }; -} -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -function Re(e) { - return { - hash: e, - hmac: (n, ...t) => Pt(e, n, se(...t)), - randomBytes: ie - }; -} -function ze(e, n) { - const t = (r) => Ze({ ...e, ...Re(r) }); - return Object.freeze({ ...t(n), create: t }); -} -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const te = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), Mt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), ke = BigInt(1), It = BigInt(2), Yt = (e, n) => (e + n / It) / n; -function Ue(e) { - const n = te, t = BigInt(3), r = BigInt(6), s = BigInt(11), o = BigInt(22), a = BigInt(23), f = BigInt(44), i = BigInt(88), l = e * e * e % n, m = l * l * e % n, E = V(m, t, n) * m % n, u = V(E, t, n) * m % n, q = V(u, It, n) * l % n, T = V(q, s, n) * q % n, p = V(T, o, n) * T % n, c = V(p, f, n) * p % n, h = V(c, i, n) * c % n, y = V(h, f, n) * p % n, B = V(y, t, n) * m % n, x = V(B, a, n) * T % n, O = V(x, r, n) * l % n, S = V(O, It, n); - if (!At.eql(At.sqr(S), e)) - throw new Error("Cannot find square root"); - return S; -} -const At = Xt(te, void 0, void 0, { sqrt: Ue }), Ce = ze({ - a: BigInt(0), - // equation params: a, b - b: BigInt(7), - // Seem to be rigid: bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975 - Fp: At, - // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n - n: Mt, - // Curve order, total count of valid points in the field - // Base point (x, y) aka generator point - Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"), - Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"), - h: BigInt(1), - // Cofactor - lowS: !0, - // Allow only low-S signatures by default in sign() and verify() - /** - * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism. - * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%. - * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit. - * Explanation: https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066 - */ - endo: { - beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"), - splitScalar: (e) => { - const n = Mt, t = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -ke * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), s = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), o = t, a = BigInt("0x100000000000000000000000000000000"), f = Yt(o * e, n), i = Yt(-r * e, n); - let l = U(e - f * t - i * s, n), m = U(-f * r - i * o, n); - const E = l > a, u = m > a; - if (E && (l = n - l), u && (m = n - m), l > a || m > a) - throw new Error("splitScalar: Endomorphism failed, k=" + e); - return { k1neg: E, k1: l, k2neg: u, k2: m }; - } - } -}, ce); -BigInt(0); -Ce.ProjectivePoint; -export { - Ce as secp256k1 -}; diff --git a/dist/secp256k1-C66jOJWb.js b/dist/secp256k1-C66jOJWb.js new file mode 100644 index 0000000..351456c --- /dev/null +++ b/dist/secp256k1-C66jOJWb.js @@ -0,0 +1,1290 @@ +import { h as xt, i as Tt, a as at, b as st, c as F, H as Jt, d as te, t as ee, e as ne, f as qt, g as re, r as oe, s as ie } from "./main-CtRNJ0s5.js"; +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const St = /* @__PURE__ */ BigInt(0), Et = /* @__PURE__ */ BigInt(1); +function lt(e, n) { + if (typeof n != "boolean") + throw new Error(e + " boolean expected, got " + n); +} +function ct(e) { + const n = e.toString(16); + return n.length & 1 ? "0" + n : n; +} +function kt(e) { + if (typeof e != "string") + throw new Error("hex string expected, got " + typeof e); + return e === "" ? St : BigInt("0x" + e); +} +function dt(e) { + return kt(st(e)); +} +function jt(e) { + return at(e), kt(st(Uint8Array.from(e).reverse())); +} +function It(e, n) { + return xt(e.toString(16).padStart(n * 2, "0")); +} +function Ut(e, n) { + return It(e, n).reverse(); +} +function $(e, n, t) { + let r; + if (typeof n == "string") + try { + r = xt(n); + } catch (i) { + throw new Error(e + " must be hex string or Uint8Array, cause: " + i); + } + else if (Tt(n)) + r = Uint8Array.from(n); + else + throw new Error(e + " must be hex string or Uint8Array"); + const s = r.length; + if (typeof t == "number" && s !== t) + throw new Error(e + " of length " + t + " expected, got " + s); + return r; +} +const mt = (e) => typeof e == "bigint" && St <= e; +function se(e, n, t) { + return mt(e) && mt(n) && mt(t) && n <= e && e < t; +} +function ce(e, n, t, r) { + if (!se(n, t, r)) + throw new Error("expected valid " + e + ": " + t + " <= n < " + r + ", got " + n); +} +function fe(e) { + let n; + for (n = 0; e > St; e >>= Et, n += 1) + ; + return n; +} +const ht = (e) => (Et << BigInt(e)) - Et; +function ae(e, n, t) { + if (typeof e != "number" || e < 2) + throw new Error("hashLen must be a number"); + if (typeof n != "number" || n < 2) + throw new Error("qByteLen must be a number"); + if (typeof t != "function") + throw new Error("hmacFn must be a function"); + const r = (S) => new Uint8Array(S), s = (S) => Uint8Array.of(S); + let i = r(e), o = r(e), a = 0; + const l = () => { + i.fill(1), o.fill(0), a = 0; + }, g = (...S) => t(o, i, ...S), c = (S = r(0)) => { + o = g(s(0), S), i = g(), S.length !== 0 && (o = g(s(1), S), i = g()); + }, E = () => { + if (a++ >= 1e3) + throw new Error("drbg: tried 1000 values"); + let S = 0; + const _ = []; + for (; S < n; ) { + i = g(); + const N = i.slice(); + _.push(N), S += i.length; + } + return F(..._); + }; + return (S, _) => { + l(), c(S); + let N; + for (; !(N = _(E())); ) + c(); + return l(), N; + }; +} +function Nt(e, n, t = {}) { + if (!e || typeof e != "object") + throw new Error("expected valid options object"); + function r(s, i, o) { + const a = e[s]; + if (o && a === void 0) + return; + const l = typeof a; + if (l !== i || a === null) + throw new Error(`param "${s}" is invalid: expected ${i}, got ${l}`); + } + Object.entries(n).forEach(([s, i]) => r(s, i, !1)), Object.entries(t).forEach(([s, i]) => r(s, i, !0)); +} +function At(e) { + const n = /* @__PURE__ */ new WeakMap(); + return (t, ...r) => { + const s = n.get(t); + if (s !== void 0) + return s; + const i = e(t, ...r); + return n.set(t, i), i; + }; +} +class Mt extends Jt { + constructor(n, t) { + super(), this.finished = !1, this.destroyed = !1, te(n); + const r = ee(t); + if (this.iHash = n.create(), typeof this.iHash.update != "function") + throw new Error("Expected instance of class which extends utils.Hash"); + this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen; + const s = this.blockLen, i = new Uint8Array(s); + i.set(r.length > s ? n.create().update(r).digest() : r); + for (let o = 0; o < i.length; o++) + i[o] ^= 54; + this.iHash.update(i), this.oHash = n.create(); + for (let o = 0; o < i.length; o++) + i[o] ^= 106; + this.oHash.update(i), ne(i); + } + update(n) { + return qt(this), this.iHash.update(n), this; + } + digestInto(n) { + qt(this), at(n, this.outputLen), this.finished = !0, this.iHash.digestInto(n), this.oHash.update(n), this.oHash.digestInto(n), this.destroy(); + } + digest() { + const n = new Uint8Array(this.oHash.outputLen); + return this.digestInto(n), n; + } + _cloneInto(n) { + n || (n = Object.create(Object.getPrototypeOf(this), {})); + const { oHash: t, iHash: r, finished: s, destroyed: i, blockLen: o, outputLen: a } = this; + return n = n, n.finished = s, n.destroyed = i, n.blockLen = o, n.outputLen = a, n.oHash = t._cloneInto(n.oHash), n.iHash = r._cloneInto(n.iHash), n; + } + clone() { + return this._cloneInto(); + } + destroy() { + this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy(); + } +} +const $t = (e, n, t) => new Mt(e, n).update(t).digest(); +$t.create = (e, n) => new Mt(e, n); +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const j = BigInt(0), k = BigInt(1), P = /* @__PURE__ */ BigInt(2), le = /* @__PURE__ */ BigInt(3), Ct = /* @__PURE__ */ BigInt(4), Vt = /* @__PURE__ */ BigInt(5), Kt = /* @__PURE__ */ BigInt(8); +function C(e, n) { + const t = e % n; + return t >= j ? t : n + t; +} +function M(e, n, t) { + let r = e; + for (; n-- > j; ) + r *= r, r %= t; + return r; +} +function _t(e, n) { + if (e === j) + throw new Error("invert: expected non-zero number"); + if (n <= j) + throw new Error("invert: expected positive modulus, got " + n); + let t = C(e, n), r = n, s = j, i = k; + for (; t !== j; ) { + const a = r / t, l = r % t, g = s - i * a; + r = t, t = l, s = i, i = g; + } + if (r !== k) + throw new Error("invert: does not exist"); + return C(s, n); +} +function Yt(e, n) { + const t = (e.ORDER + k) / Ct, r = e.pow(n, t); + if (!e.eql(e.sqr(r), n)) + throw new Error("Cannot find square root"); + return r; +} +function ue(e, n) { + const t = (e.ORDER - Vt) / Kt, r = e.mul(n, P), s = e.pow(r, t), i = e.mul(n, s), o = e.mul(e.mul(i, P), s), a = e.mul(i, e.sub(o, e.ONE)); + if (!e.eql(e.sqr(a), n)) + throw new Error("Cannot find square root"); + return a; +} +function de(e) { + if (e < BigInt(3)) + throw new Error("sqrt is not defined for small field"); + let n = e - k, t = 0; + for (; n % P === j; ) + n /= P, t++; + let r = P; + const s = wt(e); + for (; Ht(s, r) === 1; ) + if (r++ > 1e3) + throw new Error("Cannot find square root: probably non-prime P"); + if (t === 1) + return Yt; + let i = s.pow(r, n); + const o = (n + k) / P; + return function(l, g) { + if (l.is0(g)) + return g; + if (Ht(l, g) !== 1) + throw new Error("Cannot find square root"); + let c = t, E = l.mul(l.ONE, i), x = l.pow(g, n), S = l.pow(g, o); + for (; !l.eql(x, l.ONE); ) { + if (l.is0(x)) + return l.ZERO; + let _ = 1, N = l.sqr(x); + for (; !l.eql(N, l.ONE); ) + if (_++, N = l.sqr(N), _ === c) + throw new Error("Cannot find square root"); + const L = k << BigInt(c - _ - 1), U = l.pow(E, L); + c = _, E = l.sqr(U), x = l.mul(x, E), S = l.mul(S, U); + } + return S; + }; +} +function he(e) { + return e % Ct === le ? Yt : e % Kt === Vt ? ue : de(e); +} +const we = [ + "create", + "isValid", + "is0", + "neg", + "inv", + "sqrt", + "sqr", + "eql", + "add", + "sub", + "mul", + "pow", + "div", + "addN", + "subN", + "mulN", + "sqrN" +]; +function ge(e) { + const n = { + ORDER: "bigint", + MASK: "bigint", + BYTES: "number", + BITS: "number" + }, t = we.reduce((r, s) => (r[s] = "function", r), n); + return Nt(e, t), e; +} +function me(e, n, t) { + if (t < j) + throw new Error("invalid exponent, negatives unsupported"); + if (t === j) + return e.ONE; + if (t === k) + return n; + let r = e.ONE, s = n; + for (; t > j; ) + t & k && (r = e.mul(r, s)), s = e.sqr(s), t >>= k; + return r; +} +function Dt(e, n, t = !1) { + const r = new Array(n.length).fill(t ? e.ZERO : void 0), s = n.reduce((o, a, l) => e.is0(a) ? o : (r[l] = o, e.mul(o, a)), e.ONE), i = e.inv(s); + return n.reduceRight((o, a, l) => e.is0(a) ? o : (r[l] = e.mul(o, r[l]), e.mul(o, a)), i), r; +} +function Ht(e, n) { + const t = (e.ORDER - k) / P, r = e.pow(n, t), s = e.eql(r, e.ONE), i = e.eql(r, e.ZERO), o = e.eql(r, e.neg(e.ONE)); + if (!s && !i && !o) + throw new Error("invalid Legendre symbol result"); + return s ? 1 : i ? 0 : -1; +} +function ye(e, n) { + n !== void 0 && re(n); + const t = n !== void 0 ? n : e.toString(2).length, r = Math.ceil(t / 8); + return { nBitLength: t, nByteLength: r }; +} +function wt(e, n, t = !1, r = {}) { + if (e <= j) + throw new Error("invalid field: expected ORDER > 0, got " + e); + let s, i; + if (typeof n == "object" && n != null) { + if (r.sqrt || t) + throw new Error("cannot specify opts in two arguments"); + const c = n; + c.BITS && (s = c.BITS), c.sqrt && (i = c.sqrt), typeof c.isLE == "boolean" && (t = c.isLE); + } else + typeof n == "number" && (s = n), r.sqrt && (i = r.sqrt); + const { nBitLength: o, nByteLength: a } = ye(e, s); + if (a > 2048) + throw new Error("invalid field: expected ORDER of <= 2048 bytes"); + let l; + const g = Object.freeze({ + ORDER: e, + isLE: t, + BITS: o, + BYTES: a, + MASK: ht(o), + ZERO: j, + ONE: k, + create: (c) => C(c, e), + isValid: (c) => { + if (typeof c != "bigint") + throw new Error("invalid field element: expected bigint, got " + typeof c); + return j <= c && c < e; + }, + is0: (c) => c === j, + // is valid and invertible + isValidNot0: (c) => !g.is0(c) && g.isValid(c), + isOdd: (c) => (c & k) === k, + neg: (c) => C(-c, e), + eql: (c, E) => c === E, + sqr: (c) => C(c * c, e), + add: (c, E) => C(c + E, e), + sub: (c, E) => C(c - E, e), + mul: (c, E) => C(c * E, e), + pow: (c, E) => me(g, c, E), + div: (c, E) => C(c * _t(E, e), e), + // Same as above, but doesn't normalize + sqrN: (c) => c * c, + addN: (c, E) => c + E, + subN: (c, E) => c - E, + mulN: (c, E) => c * E, + inv: (c) => _t(c, e), + sqrt: i || ((c) => (l || (l = he(e)), l(g, c))), + toBytes: (c) => t ? Ut(c, a) : It(c, a), + fromBytes: (c) => { + if (c.length !== a) + throw new Error("Field.fromBytes: expected " + a + " bytes, got " + c.length); + return t ? jt(c) : dt(c); + }, + // TODO: we don't need it here, move out to separate fn + invertBatch: (c) => Dt(g, c), + // We can't move this out because Fp6, Fp12 implement it + // and it's unclear what to return in there. + cmov: (c, E, x) => x ? E : c + }); + return Object.freeze(g); +} +function Gt(e) { + if (typeof e != "bigint") + throw new Error("field order must be bigint"); + const n = e.toString(2).length; + return Math.ceil(n / 8); +} +function Ft(e) { + const n = Gt(e); + return n + Math.ceil(n / 2); +} +function pe(e, n, t = !1) { + const r = e.length, s = Gt(n), i = Ft(n); + if (r < 16 || r < i || r > 1024) + throw new Error("expected " + i + "-1024 bytes of input, got " + r); + const o = t ? jt(e) : dt(e), a = C(o, n - k) + k; + return t ? Ut(a, s) : It(a, s); +} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const et = BigInt(0), X = BigInt(1); +function rt(e, n) { + const t = n.negate(); + return e ? t : n; +} +function be(e, n, t) { + const r = (o) => o.pz, s = Dt(e.Fp, t.map(r)); + return t.map((o, a) => o.toAffine(s[a])).map(e.fromAffine); +} +function Pt(e, n) { + if (!Number.isSafeInteger(e) || e <= 0 || e > n) + throw new Error("invalid window size, expected [1.." + n + "], got W=" + e); +} +function yt(e, n) { + Pt(e, n); + const t = Math.ceil(n / e) + 1, r = 2 ** (e - 1), s = 2 ** e, i = ht(e), o = BigInt(e); + return { windows: t, windowSize: r, mask: i, maxNumber: s, shiftBy: o }; +} +function Ot(e, n, t) { + const { windowSize: r, mask: s, maxNumber: i, shiftBy: o } = t; + let a = Number(e & s), l = e >> o; + a > r && (a -= i, l += X); + const g = n * r, c = g + Math.abs(a) - 1, E = a === 0, x = a < 0, S = n % 2 !== 0; + return { nextN: l, offset: c, isZero: E, isNeg: x, isNegF: S, offsetF: g }; +} +function Ee(e, n) { + if (!Array.isArray(e)) + throw new Error("array expected"); + e.forEach((t, r) => { + if (!(t instanceof n)) + throw new Error("invalid point at index " + r); + }); +} +function Be(e, n) { + if (!Array.isArray(e)) + throw new Error("array of scalars expected"); + e.forEach((t, r) => { + if (!n.isValid(t)) + throw new Error("invalid scalar at index " + r); + }); +} +const pt = /* @__PURE__ */ new WeakMap(), Xt = /* @__PURE__ */ new WeakMap(); +function bt(e) { + return Xt.get(e) || 1; +} +function Zt(e) { + if (e !== et) + throw new Error("invalid wNAF"); +} +function ve(e, n) { + return { + constTimeNegate: rt, + hasPrecomputes(t) { + return bt(t) !== 1; + }, + // non-const time multiplication ladder + unsafeLadder(t, r, s = e.ZERO) { + let i = t; + for (; r > et; ) + r & X && (s = s.add(i)), i = i.double(), r >>= X; + return s; + }, + /** + * Creates a wNAF precomputation window. Used for caching. + * Default window size is set by `utils.precompute()` and is equal to 8. + * Number of precomputed points depends on the curve size: + * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where: + * - 𝑊 is the window size + * - 𝑛 is the bitlength of the curve order. + * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224. + * @param elm Point instance + * @param W window size + * @returns precomputed point tables flattened to a single array + */ + precomputeWindow(t, r) { + const { windows: s, windowSize: i } = yt(r, n), o = []; + let a = t, l = a; + for (let g = 0; g < s; g++) { + l = a, o.push(l); + for (let c = 1; c < i; c++) + l = l.add(a), o.push(l); + a = l.double(); + } + return o; + }, + /** + * Implements ec multiplication using precomputed tables and w-ary non-adjacent form. + * @param W window size + * @param precomputes precomputed tables + * @param n scalar (we don't check here, but should be less than curve order) + * @returns real and fake (for const-time) points + */ + wNAF(t, r, s) { + let i = e.ZERO, o = e.BASE; + const a = yt(t, n); + for (let l = 0; l < a.windows; l++) { + const { nextN: g, offset: c, isZero: E, isNeg: x, isNegF: S, offsetF: _ } = Ot(s, l, a); + s = g, E ? o = o.add(rt(S, r[_])) : i = i.add(rt(x, r[c])); + } + return Zt(s), { p: i, f: o }; + }, + /** + * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form. + * @param W window size + * @param precomputes precomputed tables + * @param n scalar (we don't check here, but should be less than curve order) + * @param acc accumulator point to add result of multiplication + * @returns point + */ + wNAFUnsafe(t, r, s, i = e.ZERO) { + const o = yt(t, n); + for (let a = 0; a < o.windows && s !== et; a++) { + const { nextN: l, offset: g, isZero: c, isNeg: E } = Ot(s, a, o); + if (s = l, !c) { + const x = r[g]; + i = i.add(E ? x.negate() : x); + } + } + return Zt(s), i; + }, + getPrecomputes(t, r, s) { + let i = pt.get(r); + return i || (i = this.precomputeWindow(r, t), t !== 1 && (typeof s == "function" && (i = s(i)), pt.set(r, i))), i; + }, + wNAFCached(t, r, s) { + const i = bt(t); + return this.wNAF(i, this.getPrecomputes(i, t, s), r); + }, + wNAFCachedUnsafe(t, r, s, i) { + const o = bt(t); + return o === 1 ? this.unsafeLadder(t, r, i) : this.wNAFUnsafe(o, this.getPrecomputes(o, t, s), r, i); + }, + // We calculate precomputes for elliptic curve point multiplication + // using windowed method. This specifies window size and + // stores precomputed values. Usually only base point would be precomputed. + setWindowSize(t, r) { + Pt(r, n), Xt.set(t, r), pt.delete(t); + } + }; +} +function xe(e, n, t, r) { + let s = n, i = e.ZERO, o = e.ZERO; + for (; t > et || r > et; ) + t & X && (i = i.add(s)), r & X && (o = o.add(s)), s = s.double(), t >>= X, r >>= X; + return { p1: i, p2: o }; +} +function Se(e, n, t, r) { + Ee(t, e), Be(r, n); + const s = t.length, i = r.length; + if (s !== i) + throw new Error("arrays of points and scalars must have equal length"); + const o = e.ZERO, a = fe(BigInt(s)); + let l = 1; + a > 12 ? l = a - 3 : a > 4 ? l = a - 2 : a > 0 && (l = 2); + const g = ht(l), c = new Array(Number(g) + 1).fill(o), E = Math.floor((n.BITS - 1) / l) * l; + let x = o; + for (let S = E; S >= 0; S -= l) { + c.fill(o); + for (let N = 0; N < i; N++) { + const L = r[N], U = Number(L >> BigInt(S) & g); + c[U] = c[U].add(t[N]); + } + let _ = o; + for (let N = c.length - 1, L = o; N > 0; N--) + L = L.add(c[N]), _ = _.add(L); + if (x = x.add(_), S !== 0) + for (let N = 0; N < l; N++) + x = x.double(); + } + return x; +} +function Rt(e, n) { + if (n) { + if (n.ORDER !== e) + throw new Error("Field.ORDER must match order: Fp == p, Fn == n"); + return ge(n), n; + } else + return wt(e); +} +function Ie(e, n, t = {}) { + if (!n || typeof n != "object") + throw new Error(`expected valid ${e} CURVE object`); + for (const a of ["p", "n", "h"]) { + const l = n[a]; + if (!(typeof l == "bigint" && l > et)) + throw new Error(`CURVE.${a} must be positive bigint`); + } + const r = Rt(n.p, t.Fp), s = Rt(n.n, t.Fn), o = ["Gx", "Gy", "a", "b"]; + for (const a of o) + if (!r.isValid(n[a])) + throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`); + return { Fp: r, Fn: s }; +} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +function Lt(e) { + e.lowS !== void 0 && lt("lowS", e.lowS), e.prehash !== void 0 && lt("prehash", e.prehash); +} +class Ne extends Error { + constructor(n = "") { + super(n); + } +} +const V = { + // asn.1 DER encoding utils + Err: Ne, + // Basic building block is TLV (Tag-Length-Value) + _tlv: { + encode: (e, n) => { + const { Err: t } = V; + if (e < 0 || e > 256) + throw new t("tlv.encode: wrong tag"); + if (n.length & 1) + throw new t("tlv.encode: unpadded data"); + const r = n.length / 2, s = ct(r); + if (s.length / 2 & 128) + throw new t("tlv.encode: long form length too big"); + const i = r > 127 ? ct(s.length / 2 | 128) : ""; + return ct(e) + i + s + n; + }, + // v - value, l - left bytes (unparsed) + decode(e, n) { + const { Err: t } = V; + let r = 0; + if (e < 0 || e > 256) + throw new t("tlv.encode: wrong tag"); + if (n.length < 2 || n[r++] !== e) + throw new t("tlv.decode: wrong tlv"); + const s = n[r++], i = !!(s & 128); + let o = 0; + if (!i) + o = s; + else { + const l = s & 127; + if (!l) + throw new t("tlv.decode(long): indefinite length not supported"); + if (l > 4) + throw new t("tlv.decode(long): byte length is too big"); + const g = n.subarray(r, r + l); + if (g.length !== l) + throw new t("tlv.decode: length bytes not complete"); + if (g[0] === 0) + throw new t("tlv.decode(long): zero leftmost byte"); + for (const c of g) + o = o << 8 | c; + if (r += l, o < 128) + throw new t("tlv.decode(long): not minimal encoding"); + } + const a = n.subarray(r, r + o); + if (a.length !== o) + throw new t("tlv.decode: wrong value length"); + return { v: a, l: n.subarray(r + o) }; + } + }, + // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag, + // since we always use positive integers here. It must always be empty: + // - add zero byte if exists + // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding) + _int: { + encode(e) { + const { Err: n } = V; + if (e < ot) + throw new n("integer: negative integers are not allowed"); + let t = ct(e); + if (Number.parseInt(t[0], 16) & 8 && (t = "00" + t), t.length & 1) + throw new n("unexpected DER parsing assertion: unpadded hex"); + return t; + }, + decode(e) { + const { Err: n } = V; + if (e[0] & 128) + throw new n("invalid signature integer: negative"); + if (e[0] === 0 && !(e[1] & 128)) + throw new n("invalid signature integer: unnecessary leading zero"); + return dt(e); + } + }, + toSig(e) { + const { Err: n, _int: t, _tlv: r } = V, s = $("signature", e), { v: i, l: o } = r.decode(48, s); + if (o.length) + throw new n("invalid signature: left bytes after parsing"); + const { v: a, l } = r.decode(2, i), { v: g, l: c } = r.decode(2, l); + if (c.length) + throw new n("invalid signature: left bytes after parsing"); + return { r: t.decode(a), s: t.decode(g) }; + }, + hexFromSig(e) { + const { _tlv: n, _int: t } = V, r = n.encode(2, t.encode(e.r)), s = n.encode(2, t.encode(e.s)), i = r + s; + return n.encode(48, i); + } +}, ot = BigInt(0), it = BigInt(1), qe = BigInt(2), ft = BigInt(3), Ae = BigInt(4); +function _e(e, n, t) { + function r(s) { + const i = e.sqr(s), o = e.mul(i, s); + return e.add(e.add(o, e.mul(s, n)), t); + } + return r; +} +function Wt(e, n, t) { + const { BYTES: r } = e; + function s(i) { + let o; + if (typeof i == "bigint") + o = i; + else { + let a = $("private key", i); + if (n) { + if (!n.includes(a.length * 2)) + throw new Error("invalid private key"); + const l = new Uint8Array(r); + l.set(a, l.length - a.length), a = l; + } + try { + o = e.fromBytes(a); + } catch { + throw new Error(`invalid private key: expected ui8a of size ${r}, got ${typeof i}`); + } + } + if (t && (o = e.create(o)), !e.isValidNot0(o)) + throw new Error("invalid private key: out of range [1..N-1]"); + return o; + } + return s; +} +function He(e, n = {}) { + const { Fp: t, Fn: r } = Ie("weierstrass", e, n), { h: s, n: i } = e; + Nt(n, {}, { + allowInfinityPoint: "boolean", + clearCofactor: "function", + isTorsionFree: "function", + fromBytes: "function", + toBytes: "function", + endo: "object", + wrapPrivateKey: "boolean" + }); + const { endo: o } = n; + if (o && (!t.is0(e.a) || typeof o.beta != "bigint" || typeof o.splitScalar != "function")) + throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function'); + function a() { + if (!t.isOdd) + throw new Error("compression is not supported: Field does not have .isOdd()"); + } + function l(H, f, h) { + const { x: u, y: d } = f.toAffine(), w = t.toBytes(u); + if (lt("isCompressed", h), h) { + a(); + const p = !t.isOdd(d); + return F(Qt(p), w); + } else + return F(Uint8Array.of(4), w, t.toBytes(d)); + } + function g(H) { + at(H); + const f = t.BYTES, h = f + 1, u = 2 * f + 1, d = H.length, w = H[0], p = H.subarray(1); + if (d === h && (w === 2 || w === 3)) { + const m = t.fromBytes(p); + if (!t.isValid(m)) + throw new Error("bad point: is not on curve, wrong x"); + const y = x(m); + let B; + try { + B = t.sqrt(y); + } catch (q) { + const v = q instanceof Error ? ": " + q.message : ""; + throw new Error("bad point: is not on curve, sqrt error" + v); + } + a(); + const b = t.isOdd(B); + return (w & 1) === 1 !== b && (B = t.neg(B)), { x: m, y: B }; + } else if (d === u && w === 4) { + const m = t.fromBytes(p.subarray(f * 0, f * 1)), y = t.fromBytes(p.subarray(f * 1, f * 2)); + if (!S(m, y)) + throw new Error("bad point: is not on curve"); + return { x: m, y }; + } else + throw new Error(`bad point: got length ${d}, expected compressed=${h} or uncompressed=${u}`); + } + const c = n.toBytes || l, E = n.fromBytes || g, x = _e(t, e.a, e.b); + function S(H, f) { + const h = t.sqr(f), u = x(H); + return t.eql(h, u); + } + if (!S(e.Gx, e.Gy)) + throw new Error("bad curve params: generator point"); + const _ = t.mul(t.pow(e.a, ft), Ae), N = t.mul(t.sqr(e.b), BigInt(27)); + if (t.is0(t.add(_, N))) + throw new Error("bad curve params: a or b"); + function L(H, f, h = !1) { + if (!t.isValid(f) || h && t.is0(f)) + throw new Error(`bad point coordinate ${H}`); + return f; + } + function U(H) { + if (!(H instanceof I)) + throw new Error("ProjectivePoint expected"); + } + const W = At((H, f) => { + const { px: h, py: u, pz: d } = H; + if (t.eql(d, t.ONE)) + return { x: h, y: u }; + const w = H.is0(); + f == null && (f = w ? t.ONE : t.inv(d)); + const p = t.mul(h, f), m = t.mul(u, f), y = t.mul(d, f); + if (w) + return { x: t.ZERO, y: t.ZERO }; + if (!t.eql(y, t.ONE)) + throw new Error("invZ was invalid"); + return { x: p, y: m }; + }), Y = At((H) => { + if (H.is0()) { + if (n.allowInfinityPoint && !t.is0(H.py)) + return; + throw new Error("bad point: ZERO"); + } + const { x: f, y: h } = H.toAffine(); + if (!t.isValid(f) || !t.isValid(h)) + throw new Error("bad point: x or y not field elements"); + if (!S(f, h)) + throw new Error("bad point: equation left != right"); + if (!H.isTorsionFree()) + throw new Error("bad point: not in prime-order subgroup"); + return !0; + }); + function Q(H, f, h, u, d) { + return h = new I(t.mul(h.px, H), h.py, h.pz), f = rt(u, f), h = rt(d, h), f.add(h); + } + class I { + /** Does NOT validate if the point is valid. Use `.assertValidity()`. */ + constructor(f, h, u) { + this.px = L("x", f), this.py = L("y", h, !0), this.pz = L("z", u), Object.freeze(this); + } + /** Does NOT validate if the point is valid. Use `.assertValidity()`. */ + static fromAffine(f) { + const { x: h, y: u } = f || {}; + if (!f || !t.isValid(h) || !t.isValid(u)) + throw new Error("invalid affine point"); + if (f instanceof I) + throw new Error("projective point not allowed"); + return t.is0(h) && t.is0(u) ? I.ZERO : new I(h, u, t.ONE); + } + get x() { + return this.toAffine().x; + } + get y() { + return this.toAffine().y; + } + static normalizeZ(f) { + return be(I, "pz", f); + } + static fromBytes(f) { + return at(f), I.fromHex(f); + } + /** Converts hash string or Uint8Array to Point. */ + static fromHex(f) { + const h = I.fromAffine(E($("pointHex", f))); + return h.assertValidity(), h; + } + /** Multiplies generator point by privateKey. */ + static fromPrivateKey(f) { + const h = Wt(r, n.allowedPrivateKeyLengths, n.wrapPrivateKey); + return I.BASE.multiply(h(f)); + } + /** Multiscalar Multiplication */ + static msm(f, h) { + return Se(I, r, f, h); + } + /** + * + * @param windowSize + * @param isLazy true will defer table computation until the first multiplication + * @returns + */ + precompute(f = 8, h = !0) { + return K.setWindowSize(this, f), h || this.multiply(ft), this; + } + /** "Private method", don't use it directly */ + _setWindowSize(f) { + this.precompute(f); + } + // TODO: return `this` + /** A point on curve is valid if it conforms to equation. */ + assertValidity() { + Y(this); + } + hasEvenY() { + const { y: f } = this.toAffine(); + if (!t.isOdd) + throw new Error("Field doesn't support isOdd"); + return !t.isOdd(f); + } + /** Compare one point to another. */ + equals(f) { + U(f); + const { px: h, py: u, pz: d } = this, { px: w, py: p, pz: m } = f, y = t.eql(t.mul(h, m), t.mul(w, d)), B = t.eql(t.mul(u, m), t.mul(p, d)); + return y && B; + } + /** Flips point to one corresponding to (x, -y) in Affine coordinates. */ + negate() { + return new I(this.px, t.neg(this.py), this.pz); + } + // Renes-Costello-Batina exception-free doubling formula. + // There is 30% faster Jacobian formula, but it is not complete. + // https://eprint.iacr.org/2015/1060, algorithm 3 + // Cost: 8M + 3S + 3*a + 2*b3 + 15add. + double() { + const { a: f, b: h } = e, u = t.mul(h, ft), { px: d, py: w, pz: p } = this; + let m = t.ZERO, y = t.ZERO, B = t.ZERO, b = t.mul(d, d), O = t.mul(w, w), q = t.mul(p, p), v = t.mul(d, w); + return v = t.add(v, v), B = t.mul(d, p), B = t.add(B, B), m = t.mul(f, B), y = t.mul(u, q), y = t.add(m, y), m = t.sub(O, y), y = t.add(O, y), y = t.mul(m, y), m = t.mul(v, m), B = t.mul(u, B), q = t.mul(f, q), v = t.sub(b, q), v = t.mul(f, v), v = t.add(v, B), B = t.add(b, b), b = t.add(B, b), b = t.add(b, q), b = t.mul(b, v), y = t.add(y, b), q = t.mul(w, p), q = t.add(q, q), b = t.mul(q, v), m = t.sub(m, b), B = t.mul(q, O), B = t.add(B, B), B = t.add(B, B), new I(m, y, B); + } + // Renes-Costello-Batina exception-free addition formula. + // There is 30% faster Jacobian formula, but it is not complete. + // https://eprint.iacr.org/2015/1060, algorithm 1 + // Cost: 12M + 0S + 3*a + 3*b3 + 23add. + add(f) { + U(f); + const { px: h, py: u, pz: d } = this, { px: w, py: p, pz: m } = f; + let y = t.ZERO, B = t.ZERO, b = t.ZERO; + const O = e.a, q = t.mul(e.b, ft); + let v = t.mul(h, w), Z = t.mul(u, p), R = t.mul(d, m), z = t.add(h, u), A = t.add(w, p); + z = t.mul(z, A), A = t.add(v, Z), z = t.sub(z, A), A = t.add(h, d); + let T = t.add(w, m); + return A = t.mul(A, T), T = t.add(v, R), A = t.sub(A, T), T = t.add(u, d), y = t.add(p, m), T = t.mul(T, y), y = t.add(Z, R), T = t.sub(T, y), b = t.mul(O, A), y = t.mul(q, R), b = t.add(y, b), y = t.sub(Z, b), b = t.add(Z, b), B = t.mul(y, b), Z = t.add(v, v), Z = t.add(Z, v), R = t.mul(O, R), A = t.mul(q, A), Z = t.add(Z, R), R = t.sub(v, R), R = t.mul(O, R), A = t.add(A, R), v = t.mul(Z, A), B = t.add(B, v), v = t.mul(T, A), y = t.mul(z, y), y = t.sub(y, v), v = t.mul(z, Z), b = t.mul(T, b), b = t.add(b, v), new I(y, B, b); + } + subtract(f) { + return this.add(f.negate()); + } + is0() { + return this.equals(I.ZERO); + } + /** + * Constant time multiplication. + * Uses wNAF method. Windowed method may be 10% faster, + * but takes 2x longer to generate and consumes 2x memory. + * Uses precomputes when available. + * Uses endomorphism for Koblitz curves. + * @param scalar by which the point would be multiplied + * @returns New point + */ + multiply(f) { + const { endo: h } = n; + if (!r.isValidNot0(f)) + throw new Error("invalid scalar: out of range"); + let u, d; + const w = (p) => K.wNAFCached(this, p, I.normalizeZ); + if (h) { + const { k1neg: p, k1: m, k2neg: y, k2: B } = h.splitScalar(f), { p: b, f: O } = w(m), { p: q, f: v } = w(B); + d = O.add(v), u = Q(h.beta, b, q, p, y); + } else { + const { p, f: m } = w(f); + u = p, d = m; + } + return I.normalizeZ([u, d])[0]; + } + /** + * Non-constant-time multiplication. Uses double-and-add algorithm. + * It's faster, but should only be used when you don't care about + * an exposed private key e.g. sig verification, which works over *public* keys. + */ + multiplyUnsafe(f) { + const { endo: h } = n, u = this; + if (!r.isValid(f)) + throw new Error("invalid scalar: out of range"); + if (f === ot || u.is0()) + return I.ZERO; + if (f === it) + return u; + if (K.hasPrecomputes(this)) + return this.multiply(f); + if (h) { + const { k1neg: d, k1: w, k2neg: p, k2: m } = h.splitScalar(f), { p1: y, p2: B } = xe(I, u, w, m); + return Q(h.beta, y, B, d, p); + } else + return K.wNAFCachedUnsafe(u, f); + } + multiplyAndAddUnsafe(f, h, u) { + const d = this.multiplyUnsafe(h).add(f.multiplyUnsafe(u)); + return d.is0() ? void 0 : d; + } + /** + * Converts Projective point to affine (x, y) coordinates. + * @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch + */ + toAffine(f) { + return W(this, f); + } + /** + * Checks whether Point is free of torsion elements (is in prime subgroup). + * Always torsion-free for cofactor=1 curves. + */ + isTorsionFree() { + const { isTorsionFree: f } = n; + return s === it ? !0 : f ? f(I, this) : K.wNAFCachedUnsafe(this, i).is0(); + } + clearCofactor() { + const { clearCofactor: f } = n; + return s === it ? this : f ? f(I, this) : this.multiplyUnsafe(s); + } + toBytes(f = !0) { + return lt("isCompressed", f), this.assertValidity(), c(I, this, f); + } + /** @deprecated use `toBytes` */ + toRawBytes(f = !0) { + return this.toBytes(f); + } + toHex(f = !0) { + return st(this.toBytes(f)); + } + toString() { + return ``; + } + } + I.BASE = new I(e.Gx, e.Gy, t.ONE), I.ZERO = new I(t.ZERO, t.ONE, t.ZERO), I.Fp = t, I.Fn = r; + const D = r.BITS, K = ve(I, n.endo ? Math.ceil(D / 2) : D); + return I; +} +function Qt(e) { + return Uint8Array.of(e ? 2 : 3); +} +function Oe(e, n, t = {}) { + Nt(n, { hash: "function" }, { + hmac: "function", + lowS: "boolean", + randomBytes: "function", + bits2int: "function", + bits2int_modN: "function" + }); + const r = n.randomBytes || oe, s = n.hmac || ((u, ...d) => $t(n.hash, u, F(...d))), { Fp: i, Fn: o } = e, { ORDER: a, BITS: l } = o; + function g(u) { + const d = a >> it; + return u > d; + } + function c(u) { + return g(u) ? o.neg(u) : u; + } + function E(u, d) { + if (!o.isValidNot0(d)) + throw new Error(`invalid signature ${u}: out of range 1..CURVE.n`); + } + class x { + constructor(d, w, p) { + E("r", d), E("s", w), this.r = d, this.s = w, p != null && (this.recovery = p), Object.freeze(this); + } + // pair (bytes of r, bytes of s) + static fromCompact(d) { + const w = o.BYTES, p = $("compactSignature", d, w * 2); + return new x(o.fromBytes(p.subarray(0, w)), o.fromBytes(p.subarray(w, w * 2))); + } + // DER encoded ECDSA signature + // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script + static fromDER(d) { + const { r: w, s: p } = V.toSig($("DER", d)); + return new x(w, p); + } + /** + * @todo remove + * @deprecated + */ + assertValidity() { + } + addRecoveryBit(d) { + return new x(this.r, this.s, d); + } + // ProjPointType + recoverPublicKey(d) { + const w = i.ORDER, { r: p, s: m, recovery: y } = this; + if (y == null || ![0, 1, 2, 3].includes(y)) + throw new Error("recovery id invalid"); + if (a * qe < w && y > 1) + throw new Error("recovery id is ambiguous for h>1 curve"); + const b = y === 2 || y === 3 ? p + a : p; + if (!i.isValid(b)) + throw new Error("recovery id 2 or 3 invalid"); + const O = i.toBytes(b), q = e.fromHex(F(Qt((y & 1) === 0), O)), v = o.inv(b), Z = Y($("msgHash", d)), R = o.create(-Z * v), z = o.create(m * v), A = e.BASE.multiplyUnsafe(R).add(q.multiplyUnsafe(z)); + if (A.is0()) + throw new Error("point at infinify"); + return A.assertValidity(), A; + } + // Signatures should be low-s, to prevent malleability. + hasHighS() { + return g(this.s); + } + normalizeS() { + return this.hasHighS() ? new x(this.r, o.neg(this.s), this.recovery) : this; + } + toBytes(d) { + if (d === "compact") + return F(o.toBytes(this.r), o.toBytes(this.s)); + if (d === "der") + return xt(V.hexFromSig(this)); + throw new Error("invalid format"); + } + // DER-encoded + toDERRawBytes() { + return this.toBytes("der"); + } + toDERHex() { + return st(this.toBytes("der")); + } + // padded bytes of r, then padded bytes of s + toCompactRawBytes() { + return this.toBytes("compact"); + } + toCompactHex() { + return st(this.toBytes("compact")); + } + } + const S = Wt(o, t.allowedPrivateKeyLengths, t.wrapPrivateKey), _ = { + isValidPrivateKey(u) { + try { + return S(u), !0; + } catch { + return !1; + } + }, + normPrivateKeyToScalar: S, + /** + * Produces cryptographically secure private key from random of size + * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible. + */ + randomPrivateKey: () => { + const u = a; + return pe(r(Ft(u)), u); + }, + precompute(u = 8, d = e.BASE) { + return d.precompute(u, !1); + } + }; + function N(u, d = !0) { + return e.fromPrivateKey(u).toBytes(d); + } + function L(u) { + if (typeof u == "bigint") + return !1; + if (u instanceof e) + return !0; + const w = $("key", u).length, p = i.BYTES, m = p + 1, y = 2 * p + 1; + if (!(t.allowedPrivateKeyLengths || o.BYTES === m)) + return w === m || w === y; + } + function U(u, d, w = !0) { + if (L(u) === !0) + throw new Error("first arg must be private key"); + if (L(d) === !1) + throw new Error("second arg must be public key"); + return e.fromHex(d).multiply(S(u)).toBytes(w); + } + const W = n.bits2int || function(u) { + if (u.length > 8192) + throw new Error("input is too large"); + const d = dt(u), w = u.length * 8 - l; + return w > 0 ? d >> BigInt(w) : d; + }, Y = n.bits2int_modN || function(u) { + return o.create(W(u)); + }, Q = ht(l); + function I(u) { + return ce("num < 2^" + l, u, ot, Q), o.toBytes(u); + } + function D(u, d, w = K) { + if (["recovered", "canonical"].some((z) => z in w)) + throw new Error("sign() legacy options not supported"); + const { hash: p } = n; + let { lowS: m, prehash: y, extraEntropy: B } = w; + m == null && (m = !0), u = $("msgHash", u), Lt(w), y && (u = $("prehashed msgHash", p(u))); + const b = Y(u), O = S(d), q = [I(O), I(b)]; + if (B != null && B !== !1) { + const z = B === !0 ? r(i.BYTES) : B; + q.push($("extraEntropy", z)); + } + const v = F(...q), Z = b; + function R(z) { + const A = W(z); + if (!o.isValidNot0(A)) + return; + const T = o.inv(A), nt = e.BASE.multiply(A).toAffine(), J = o.create(nt.x); + if (J === ot) + return; + const G = o.create(T * o.create(Z + J * O)); + if (G === ot) + return; + let gt = (nt.x === J ? 0 : 2) | Number(nt.y & it), tt = G; + return m && g(G) && (tt = c(G), gt ^= 1), new x(J, tt, gt); + } + return { seed: v, k2sig: R }; + } + const K = { lowS: n.lowS, prehash: !1 }, H = { lowS: n.lowS, prehash: !1 }; + function f(u, d, w = K) { + const { seed: p, k2sig: m } = D(u, d, w); + return ae(n.hash.outputLen, o.BYTES, s)(p, m); + } + e.BASE.precompute(8); + function h(u, d, w, p = H) { + const m = u; + d = $("msgHash", d), w = $("publicKey", w), Lt(p); + const { lowS: y, prehash: B, format: b } = p; + if ("strict" in p) + throw new Error("options.strict was renamed to lowS"); + if (b !== void 0 && !["compact", "der", "js"].includes(b)) + throw new Error('format must be "compact", "der" or "js"'); + const O = typeof m == "string" || Tt(m), q = !O && !b && typeof m == "object" && m !== null && typeof m.r == "bigint" && typeof m.s == "bigint"; + if (!O && !q) + throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance"); + let v, Z; + try { + if (q) + if (b === void 0 || b === "js") + v = new x(m.r, m.s); + else + throw new Error("invalid format"); + if (O) { + try { + b !== "compact" && (v = x.fromDER(m)); + } catch (tt) { + if (!(tt instanceof V.Err)) + throw tt; + } + !v && b !== "der" && (v = x.fromCompact(m)); + } + Z = e.fromHex(w); + } catch { + return !1; + } + if (!v || y && v.hasHighS()) + return !1; + B && (d = n.hash(d)); + const { r: R, s: z } = v, A = Y(d), T = o.inv(z), nt = o.create(A * T), J = o.create(R * T), G = e.BASE.multiplyUnsafe(nt).add(Z.multiplyUnsafe(J)); + return G.is0() ? !1 : o.create(G.x) === R; + } + return Object.freeze({ + getPublicKey: N, + getSharedSecret: U, + sign: f, + verify: h, + utils: _, + Point: e, + Signature: x + }); +} +function Ze(e) { + const n = { + a: e.a, + b: e.b, + p: e.Fp.ORDER, + n: e.n, + h: e.h, + Gx: e.Gx, + Gy: e.Gy + }, t = e.Fp, r = wt(n.n, e.nBitLength), s = { + Fp: t, + Fn: r, + allowedPrivateKeyLengths: e.allowedPrivateKeyLengths, + allowInfinityPoint: e.allowInfinityPoint, + endo: e.endo, + wrapPrivateKey: e.wrapPrivateKey, + isTorsionFree: e.isTorsionFree, + clearCofactor: e.clearCofactor, + fromBytes: e.fromBytes, + toBytes: e.toBytes + }; + return { CURVE: n, curveOpts: s }; +} +function Re(e) { + const { CURVE: n, curveOpts: t } = Ze(e), r = { + hash: e.hash, + hmac: e.hmac, + randomBytes: e.randomBytes, + lowS: e.lowS, + bits2int: e.bits2int, + bits2int_modN: e.bits2int_modN + }; + return { CURVE: n, curveOpts: t, ecdsaOpts: r }; +} +function Le(e, n) { + return Object.assign({}, n, { + ProjectivePoint: n.Point, + CURVE: e + }); +} +function ze(e) { + const { CURVE: n, curveOpts: t, ecdsaOpts: r } = Re(e), s = He(n, t), i = Oe(s, r, t); + return Le(e, i); +} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +function Te(e, n) { + const t = (r) => ze({ ...e, hash: r }); + return { ...t(n), create: t }; +} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +const ut = { + p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), + n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), + h: BigInt(1), + a: BigInt(0), + b: BigInt(7), + Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"), + Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8") +}; +BigInt(0); +const ke = BigInt(1), Bt = BigInt(2), zt = (e, n) => (e + n / Bt) / n; +function je(e) { + const n = ut.p, t = BigInt(3), r = BigInt(6), s = BigInt(11), i = BigInt(22), o = BigInt(23), a = BigInt(44), l = BigInt(88), g = e * e * e % n, c = g * g * e % n, E = M(c, t, n) * c % n, x = M(E, t, n) * c % n, S = M(x, Bt, n) * g % n, _ = M(S, s, n) * S % n, N = M(_, i, n) * _ % n, L = M(N, a, n) * N % n, U = M(L, l, n) * L % n, W = M(U, a, n) * N % n, Y = M(W, t, n) * c % n, Q = M(Y, o, n) * _ % n, I = M(Q, r, n) * g % n, D = M(I, Bt, n); + if (!vt.eql(vt.sqr(D), e)) + throw new Error("Cannot find square root"); + return D; +} +const vt = wt(ut.p, void 0, void 0, { sqrt: je }), Me = Te({ + ...ut, + Fp: vt, + lowS: !0, + // Allow only low-S signatures by default in sign() and verify() + endo: { + // Endomorphism, see above + beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"), + splitScalar: (e) => { + const n = ut.n, t = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -ke * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), s = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), i = t, o = BigInt("0x100000000000000000000000000000000"), a = zt(i * e, n), l = zt(-r * e, n); + let g = C(e - a * t - l * s, n), c = C(-a * r - l * i, n); + const E = g > o, x = c > o; + if (E && (g = n - g), x && (c = n - c), g > o || c > o) + throw new Error("splitScalar: Endomorphism failed, k=" + e); + return { k1neg: E, k1: g, k2neg: x, k2: c }; + } + } +}, ie); +export { + Me as secp256k1 +}; diff --git a/dist/style.css b/dist/style.css deleted file mode 100644 index 569940c..0000000 --- a/dist/style.css +++ /dev/null @@ -1 +0,0 @@ -*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.xc-pointer-events-none{pointer-events:none}.xc-absolute{position:absolute}.xc-relative{position:relative}.xc-inset-0{top:0;right:0;bottom:0;left:0}.xc-left-0{left:0}.xc-right-2{right:.5rem}.xc-top-0{top:0}.xc-z-10{z-index:10}.xc-m-auto{margin:auto}.xc-mx-auto{margin-left:auto;margin-right:auto}.xc-mb-1{margin-bottom:.25rem}.xc-mb-12{margin-bottom:3rem}.xc-mb-2{margin-bottom:.5rem}.xc-mb-3{margin-bottom:.75rem}.xc-mb-4{margin-bottom:1rem}.xc-mb-6{margin-bottom:1.5rem}.xc-mb-8{margin-bottom:2rem}.xc-ml-auto{margin-left:auto}.xc-box-content{box-sizing:content-box}.xc-block{display:block}.xc-inline-block{display:inline-block}.xc-flex{display:flex}.xc-grid{display:grid}.xc-aspect-\[1\/1\]{aspect-ratio:1/1}.xc-h-1{height:.25rem}.xc-h-10{height:2.5rem}.xc-h-12{height:3rem}.xc-h-16{height:4rem}.xc-h-4{height:1rem}.xc-h-5{height:1.25rem}.xc-h-6{height:1.5rem}.xc-h-\[309px\]{height:309px}.xc-h-full{height:100%}.xc-h-screen{height:100vh}.xc-max-h-\[272px\]{max-height:272px}.xc-max-h-\[309px\]{max-height:309px}.xc-w-1{width:.25rem}.xc-w-10{width:2.5rem}.xc-w-12{width:3rem}.xc-w-16{width:4rem}.xc-w-5{width:1.25rem}.xc-w-6{width:1.5rem}.xc-w-full{width:100%}.xc-w-px{width:1px}.xc-min-w-\[160px\]{min-width:160px}.xc-min-w-\[277px\]{min-width:277px}.xc-max-w-\[272px\]{max-width:272px}.xc-max-w-\[400px\]{max-width:400px}.xc-max-w-\[420px\]{max-width:420px}.xc-flex-1{flex:1 1 0%}.xc-shrink-0{flex-shrink:0}@keyframes xc-caret-blink{0%,70%,to{opacity:1}20%,50%{opacity:0}}.xc-animate-caret-blink{animation:xc-caret-blink 1.25s ease-out infinite}@keyframes xc-spin{to{transform:rotate(360deg)}}.xc-animate-spin{animation:xc-spin 1s linear infinite}.xc-cursor-pointer{cursor:pointer}.xc-appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.xc-grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.xc-flex-col{flex-direction:column}.xc-flex-wrap{flex-wrap:wrap}.xc-items-center{align-items:center}.xc-justify-center{justify-content:center}.xc-justify-between{justify-content:space-between}.xc-gap-2{gap:.5rem}.xc-gap-3{gap:.75rem}.xc-gap-4{gap:1rem}.xc-overflow-hidden{overflow:hidden}.xc-overflow-scroll{overflow:scroll}.xc-rounded-2xl{border-radius:1rem}.xc-rounded-full{border-radius:9999px}.xc-rounded-lg{border-radius:.5rem}.xc-rounded-md{border-radius:.375rem}.xc-rounded-xl{border-radius:.75rem}.xc-border{border-width:1px}.xc-border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.xc-border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.xc-border-opacity-15{--tw-border-opacity: .15}.xc-border-opacity-20{--tw-border-opacity: .2}.xc-bg-\[\#009E8C\]{--tw-bg-opacity: 1;background-color:rgb(0 158 140 / var(--tw-bg-opacity, 1))}.xc-bg-\[\#2596FF\]{--tw-bg-opacity: 1;background-color:rgb(37 150 255 / var(--tw-bg-opacity, 1))}.xc-bg-\[rgb\(135\,93\,255\)\]{--tw-bg-opacity: 1;background-color:rgb(135 93 255 / var(--tw-bg-opacity, 1))}.xc-bg-\[rgb\(28\,28\,38\)\]{--tw-bg-opacity: 1;background-color:rgb(28 28 38 / var(--tw-bg-opacity, 1))}.xc-bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.xc-bg-transparent{background-color:transparent}.xc-bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.xc-bg-opacity-10{--tw-bg-opacity: .1}.xc-p-1{padding:.25rem}.xc-p-6{padding:1.5rem}.xc-px-3{padding-left:.75rem;padding-right:.75rem}.xc-px-4{padding-left:1rem;padding-right:1rem}.xc-px-6{padding-left:1.5rem;padding-right:1.5rem}.xc-px-8{padding-left:2rem;padding-right:2rem}.xc-py-1{padding-top:.25rem;padding-bottom:.25rem}.xc-py-2{padding-top:.5rem;padding-bottom:.5rem}.xc-py-3{padding-top:.75rem;padding-bottom:.75rem}.xc-text-center{text-align:center}.xc-text-2xl{font-size:1.5rem;line-height:2rem}.xc-text-lg{font-size:1.125rem;line-height:1.75rem}.xc-text-sm{font-size:.875rem;line-height:1.25rem}.xc-text-xl{font-size:1.25rem;line-height:1.75rem}.xc-text-xs{font-size:.75rem;line-height:1rem}.xc-font-bold{font-weight:700}.xc-text-\[\#ff0000\]{--tw-text-opacity: 1;color:rgb(255 0 0 / var(--tw-text-opacity, 1))}.xc-text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.xc-text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.xc-text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.xc-text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.xc-opacity-0{opacity:0}.xc-opacity-100{opacity:1}.xc-opacity-20{opacity:.2}.xc-opacity-50{opacity:.5}.xc-opacity-80{opacity:.8}.xc-outline-none{outline:2px solid transparent;outline-offset:2px}.xc-ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.xc-ring-\[rgb\(135\,93\,255\)\]{--tw-ring-opacity: 1;--tw-ring-color: rgb(135 93 255 / var(--tw-ring-opacity, 1))}.xc-transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.xc-duration-1000{transition-duration:1s}.no-scrollbar::-webkit-scrollbar{display:none}.\[key\:string\]{key:string}.focus-within\:xc-border-opacity-40:focus-within{--tw-border-opacity: .4}.hover\:xc-shadow-lg:hover{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.disabled\:xc-cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:xc-bg-white:disabled{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.disabled\:xc-bg-opacity-10:disabled{--tw-bg-opacity: .1}.disabled\:xc-text-opacity-50:disabled{--tw-text-opacity: .5}.disabled\:xc-opacity-20:disabled{opacity:.2}.xc-group:hover .group-hover\:xc-left-2{left:.5rem}.xc-group:hover .group-hover\:xc-right-0{right:0}.xc-group:hover .group-hover\:xc-opacity-0{opacity:0}.xc-group:hover .group-hover\:xc-opacity-100{opacity:1} diff --git a/dist/types/wallet-item.class.d.ts b/dist/types/wallet-item.class.d.ts index 06ae5a0..01728c8 100644 --- a/dist/types/wallet-item.class.d.ts +++ b/dist/types/wallet-item.class.d.ts @@ -1,4 +1,4 @@ -import { WalletClient } from 'viem'; +import { Chain, WalletClient } from 'viem'; import { WalletConfig } from '../constant/wallet-book'; import { default as UniversalProvider } from '@walletconnect/universal-provider'; import { EIP6963ProviderDetail } from '../utils/eip6963-detect'; @@ -11,11 +11,17 @@ export declare class WalletItem { private _fatured; private _installed; lastUsed: boolean; + private _client; get address(): `0x${string}` | null; get connected(): boolean; get featured(): boolean; get key(): string; get installed(): boolean; + get provider(): { + on: (event: event, listener: import('viem').EIP1193EventMap[event]) => void; + removeListener: (event: event, listener: import('viem').EIP1193EventMap[event]) => void; + request: import('viem').EIP1193RequestFn; + } | UniversalProvider | null; get client(): WalletClient | null; get config(): WalletConfig | null; static fromWalletConfig(config: WalletConfig): WalletItem; @@ -24,8 +30,9 @@ export declare class WalletItem { constructor(params: UniversalProvider); EIP6963Detected(detail: EIP6963ProviderDetail): void; setUniversalProvider(provider: UniversalProvider): void; + switchChain(chain: Chain): Promise; private testConnect; - connect(): Promise<`0x${string}`[]>; + connect(): Promise; getAddress(): Promise<`0x${string}`>; getChain(): Promise; signMessage(message: string, address: `0x${string}`): Promise<`0x${string}` | undefined>; diff --git a/lib/api/account.api.ts b/lib/api/account.api.ts index c8597bf..376a1c3 100644 --- a/lib/api/account.api.ts +++ b/lib/api/account.api.ts @@ -1,5 +1,6 @@ import { AxiosInstance } from 'axios' import request from './request' +import { TonProofItemReply } from '@tonconnect/sdk' type TAccountType = 'email' | 'block_chain' export type TAccountRole = 'B' | 'C' @@ -7,7 +8,7 @@ export type TDeviceType = 'WEB' | 'TG' | 'PLUG' export interface ILoginResponse { token: string - old_token: string + old_token?: string user_id: string, new_user: boolean } @@ -28,6 +29,12 @@ interface ILoginParamsBase { } } +interface IConnectParamsBase { + account_type: string + connector: 'codatta_email' | 'codatta_wallet' | 'codatta_ton' + account_enum: TAccountRole, +} + interface IEmailLoginParams extends ILoginParamsBase { connector: 'codatta_email' account_type: 'email' @@ -35,6 +42,13 @@ interface IEmailLoginParams extends ILoginParamsBase { email_code: string } +interface IEmailConnectParams extends IConnectParamsBase { + connector: 'codatta_email' + account_type: 'email' + email:string, + email_code: string +} + interface IWalletLoginParams extends ILoginParamsBase { connector: 'codatta_wallet' account_type: 'block_chain' @@ -46,13 +60,33 @@ interface IWalletLoginParams extends ILoginParamsBase { message: string } +interface IWalletConnectParams extends IConnectParamsBase { + connector: 'codatta_wallet' + account_type: 'block_chain' + address: string + wallet_name: string + chain: string + nonce: string + signature: string + message: string +} + interface ITonLoginParams extends ILoginParamsBase { connector: 'codatta_ton' account_type: 'block_chain' wallet_name: string, address: string, chain: string, - connect_info: object[] + connect_info: [{[key:string]:string}, TonProofItemReply] +} + +interface ITonConnectParams extends IConnectParamsBase { + connector: 'codatta_ton' + account_type: 'block_chain' + wallet_name: string, + address: string, + chain: string, + connect_info: [{[key:string]:string}, TonProofItemReply] } class AccountApi { @@ -70,8 +104,10 @@ class AccountApi { return data.data } - public async getEmailCode(props: { account_type: TAccountType , email: string}) { - const { data } = await this.request.post<{ data: string }>(`${this._apiBase}/api/v2/user/get_code`, props) + public async getEmailCode(props: { account_type: TAccountType , email: string}, captcha:string) { + const { data } = await this.request.post<{ data: string }>(`${this._apiBase}/api/v2/user/get_code`, props, { + headers: {'Captcha-Param': captcha} + }) return data.data } @@ -81,14 +117,34 @@ class AccountApi { } public async walletLogin(props: IWalletLoginParams) { - const res = await this.request.post<{ data: ILoginResponse }>(`${this._apiBase}/api/v2/user/login`, props) - return res.data + if (props.account_enum === 'C') { + const res = await this.request.post<{ data: ILoginResponse }>(`${this._apiBase}/api/v2/user/login`, props) + return res.data + } else { + const res = await this.request.post<{ data: ILoginResponse }>(`${this._apiBase}/api/v2/business/login`, props) + return res.data + } } public async tonLogin(props: ITonLoginParams) { const res = await this.request.post<{ data: ILoginResponse }>(`${this._apiBase}/api/v2/user/login`, props) return res.data } + + public async bindEmail(props: IEmailConnectParams) { + const res = await this.request.post('/api/v2/user/account/bind', props) + return res.data + } + + public async bindTonWallet(props: ITonConnectParams) { + const res = await this.request.post('/api/v2/user/account/bind', props) + return res.data + } + + public async bindEvmWallet(props: IWalletConnectParams) { + const res = await this.request.post('/api/v2/user/account/bind', props) + return res.data + } } export default new AccountApi(request) diff --git a/lib/api/request.ts b/lib/api/request.ts index 4d32dc7..ff95236 100644 --- a/lib/api/request.ts +++ b/lib/api/request.ts @@ -3,7 +3,8 @@ import axios, { AxiosError, AxiosResponse } from 'axios' const request = axios.create({ timeout: 60000, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + 'token': localStorage.getItem('auth') } }) @@ -22,8 +23,27 @@ function responseBaseInterceptor(res: AxiosResponse) { } } +function responseErrorInterceptor(error: AxiosError<{errorMessage:string, errorCode:string | number}>) { + console.log(error) + const responseData = error.response?.data + if (responseData) { + console.log(responseData, 'responseData') + const err = new AxiosError( + responseData.errorMessage, + error.code, + error.config, + error.request, + error.response + ) + return Promise.reject(err) + } else { + return Promise.reject(error) + } +} + request.interceptors.response.use( responseBaseInterceptor, + responseErrorInterceptor ) export default request diff --git a/lib/codatta-connect-context-provider.tsx b/lib/codatta-connect-context-provider.tsx index d9aba6b..a58e00b 100644 --- a/lib/codatta-connect-context-provider.tsx +++ b/lib/codatta-connect-context-provider.tsx @@ -5,6 +5,7 @@ import UniversalProvider, { UniversalProviderOpts } from '@walletconnect/univers import { EIP6963Detect } from './utils/eip6963-detect' import { createCoinbaseWalletSDK } from '@coinbase/wallet-sdk' import accountApi from './api/account.api' +import { Chain } from 'viem' const walletConnectConfig: UniversalProviderOpts = { projectId: '7a4434fefbcc9af474fb5c995e47d286', @@ -36,6 +37,7 @@ interface CodattaConnectContext { featuredWallets: WalletItem[] lastUsedWallet: WalletItem | null saveLastUsedWallet: (wallet: WalletItem) => void + chains: Chain[] } const CodattaSigninContext = createContext({ @@ -43,7 +45,8 @@ const CodattaSigninContext = createContext({ lastUsedWallet: null, wallets: [], initialized: false, - featuredWallets: [] + featuredWallets: [], + chains: [] }) export function useCodattaConnectContext() { @@ -53,6 +56,14 @@ export function useCodattaConnectContext() { interface CodattaConnectContextProviderProps { children: React.ReactNode apiBaseUrl?: string + singleWalletName?: string + chains?: Chain[] +} + +interface LastUsedWalletInfo { + provider: 'UniversalProvider' | 'EIP1193Provider', + key: string, + timestamp: number } export function CodattaConnectContextProvider(props: CodattaConnectContextProviderProps) { @@ -61,20 +72,35 @@ export function CodattaConnectContextProvider(props: CodattaConnectContextProvid const [featuredWallets, setFeaturedWallets] = useState([]) const [lastUsedWallet, setLastUsedWallet] = useState(null) const [initialized, setInitialized] = useState(false) + const [chains, setChains] = useState([]) const saveLastUsedWallet = (wallet: WalletItem) => { - console.log('saveLastUsedWallet', wallet) + setLastUsedWallet(wallet) + + const providerType = wallet.provider instanceof UniversalProvider ? 'UniversalProvider' : 'EIP1193Provider' + const lastUsedInfo: LastUsedWalletInfo = { + provider: providerType, + key: wallet.key, + timestamp: Date.now() + } + localStorage.setItem('xn-last-used-info', JSON.stringify(lastUsedInfo)) } function sortWallet(wallets: WalletItem[]) { - const featuredWallets = wallets.filter((item) => item.featured || item.installed) - const restWallets = wallets.filter((item) => !item.featured && !item.installed) - const sortedWallets = [...featuredWallets, ...restWallets] - setWallets(sortedWallets) - setFeaturedWallets(featuredWallets) + + const singleWallet = wallets.find((item) => item.config?.name === props.singleWalletName) + if (singleWallet) { + setFeaturedWallets([singleWallet]) + } else { + const featuredWallets = wallets.filter((item) => item.featured || item.installed) + const restWallets = wallets.filter((item) => !item.featured && !item.installed) + const sortedWallets = [...featuredWallets, ...restWallets] + setWallets(sortedWallets) + setFeaturedWallets(featuredWallets) + } } - async function init() { + async function init() { const wallets: WalletItem[] = [] const walletMap = new Map() @@ -105,20 +131,25 @@ export function CodattaConnectContextProvider(props: CodattaConnectContextProvid // handle last used wallet info and restore walletconnect UniveralProvider try { - const lastUsedInfo = JSON.parse(localStorage.getItem('xn-last-used-info') || '{}') + const lastUsedInfo = JSON.parse(localStorage.getItem('xn-last-used-info') || '{}') as LastUsedWalletInfo const lastUsedWallet = walletMap.get(lastUsedInfo.key) - if (lastUsedWallet) { - lastUsedWallet.lastUsed = true - if (lastUsedInfo.provider === 'UniversalProvider') { - const provider = await UniversalProvider.init(walletConnectConfig) - if (provider.session) lastUsedWallet.setUniversalProvider(provider) - } + if (lastUsedWallet && lastUsedInfo.provider === 'EIP1193Provider' && lastUsedWallet.installed) { setLastUsedWallet(lastUsedWallet) + } else if (lastUsedInfo.provider === 'UniversalProvider') { + const provider = await UniversalProvider.init(walletConnectConfig) + if (provider.session) { + const universalWallet = new WalletItem(provider) + setLastUsedWallet(universalWallet) + console.log('Restored UniversalProvider for wallet:', universalWallet.key) + } } } catch (err) { console.log(err) } + // + if (props.chains) setChains(props.chains) + // sort wallets by featured, installed, and rest sortWallet(wallets) @@ -138,7 +169,8 @@ export function CodattaConnectContextProvider(props: CodattaConnectContextProvid wallets, initialized, lastUsedWallet, - featuredWallets + featuredWallets, + chains }} > {props.children} diff --git a/lib/codatta-connect.tsx b/lib/codatta-connect.tsx index 04badbc..ee61046 100644 --- a/lib/codatta-connect.tsx +++ b/lib/codatta-connect.tsx @@ -1,59 +1,145 @@ -import { useEffect, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import SigninIndex from './components/signin-index' import AnimateContainer from './components/animate-container' import { WalletItem } from './types/wallet-item.class' import WalletConnectWidget from './components/wallet-connect-widget' +import TonWalletSelect from './components/ton-wallet-select' +import TonConnect, { Wallet, WalletInfoInjectable, WalletInfoRemote } from '@tonconnect/sdk' +import EvmWalletSelect from './components/evm-wallet-select' +import TonWalletConnect from './components/ton-wallet-connect' +import EmailConnectWidget from './components/email-connect-widget' +import { WalletSignInfo } from './components/wallet-connect' +import { WalletClient } from 'viem' -export default function CodattaConnect(props: { - onSelectMoreWallets: () => void - onSelectTonConnect?: () => void - onConnect: (wallet: WalletItem) => Promise +export interface EmvWalletConnectInfo { + chain_type: 'eip155' + client: WalletClient, + connect_info: WalletSignInfo, + wallet: WalletItem +} + +export interface TonWalletConnectInfo { + chain_type: 'ton' + client: TonConnect, + connect_info: Wallet, + wallet: Wallet +} + +export function CodattaConnect(props: { + onEvmWalletConnect?: (connectInfo:EmvWalletConnectInfo) => Promise + onTonWalletConnect?: (connectInfo:TonWalletConnectInfo) => Promise + onEmailConnect?: (email:string, code:string) => Promise + header?: React.ReactNode + config?: { + showEmailSignIn?: boolean + showFeaturedWallets?: boolean + showMoreWallets?: boolean + showTonConnect?: boolean + } }) { - const { onSelectMoreWallets, onSelectTonConnect, onConnect } = props + const { onEvmWalletConnect, onTonWalletConnect, onEmailConnect, header, config = { + showEmailSignIn: false, + showFeaturedWallets: true, + showMoreWallets: true, + showTonConnect: true + } } = props const [step, setStep] = useState('') - const [wallet, setWallet] = useState(null) + const [evmWallet, setEvmWallet] = useState() + const [tonWallet, setTonWallet] = useState() + const connector = useRef() + const [email, setEmail] = useState('') function handleSelectWallet(wallet: WalletItem) { - setWallet(wallet) - setStep('wallet') + setEvmWallet(wallet) + setStep('evm-wallet-connect') } - function handleSelectEmail(email:string) { - console.log('handleSelectEmail', email) - setStep('email') + function handleSelectEmail(email: string) { + setEmail(email) + setStep('email-connect') } - async function handleConnect(wallet: WalletItem) { - await onConnect(wallet) - setWallet(null) + async function handleConnect(wallet: WalletItem, signInfo: WalletSignInfo) { + await onEvmWalletConnect?.({ + chain_type: 'eip155', + client: wallet.client!, + connect_info: signInfo, + wallet: wallet, + }) setStep('index') } + async function handleEmailConnect(email: string, code: string) { + await onEmailConnect?.(email, code) + } + + function handleSelectTonWallet(wallet: WalletInfoRemote | WalletInfoInjectable) { + setTonWallet(wallet) + setStep('ton-wallet-connect') + } + + async function handleStatusChange(wallet: Wallet | null) { + if (!wallet) return + await onTonWalletConnect?.({ + chain_type: 'ton', + client: connector.current!, + connect_info: wallet, + wallet: wallet, + }) + } + useEffect(() => { + connector.current = new TonConnect({ + manifestUrl: 'https://static.codatta.io/static/tonconnect-manifest.json?v=2' + }) + + const unsubscribe = connector.current.onStatusChange(handleStatusChange) setStep('index') + return unsubscribe }, []) return ( - - {step === 'wallet' && ( + + + {step === 'evm-wallet-select' && ( + setStep('index')} + onSelectWallet={handleSelectWallet} + > + )} + {step === 'evm-wallet-connect' && ( setStep('index')} onConnect={handleConnect} - wallet={wallet!} + wallet={evmWallet!} > )} + {step === 'ton-wallet-select' && ( + setStep('index')} + > + )} + {step === 'ton-wallet-connect' && ( + setStep('index')} + > + )} + {step === 'email-connect' && ( + setStep('index')} onInputCode={handleEmailConnect} /> + )} {step === 'index' && ( setStep('evm-wallet-select')} + onSelectTonConnect={() => setStep('ton-wallet-select')} + config={config} > )} diff --git a/lib/codatta-signin.tsx b/lib/codatta-signin.tsx index 3c3cf1f..0200605 100644 --- a/lib/codatta-signin.tsx +++ b/lib/codatta-signin.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react' import SigninIndex from './components/signin-index' -import EmailLoginWidget from './components/email-login' +import EmailLoginWidget from './components/email-login-widget' import EvmWalletLoginWidget from './components/evm-wallet-login-widget' import TonWalletLoginWidget from './components/ton-wallet-login-widget' import AnimateContainer from './components/animate-container' @@ -69,6 +69,7 @@ export function CodattaSignin(props: { {step === 'index' && ( { setStep('all-wallet') }} @@ -81,9 +82,10 @@ export function CodattaSignin(props: { }} > )} - {step === 'all-wallet' && ( setStep('index')} - onSelectWallet={handleSelectWallet} - > + {step === 'all-wallet' && ( + setStep('index')} + onSelectWallet={handleSelectWallet} + > )} diff --git a/lib/components/email-captcha.tsx b/lib/components/email-captcha.tsx new file mode 100644 index 0000000..a1175a8 --- /dev/null +++ b/lib/components/email-captcha.tsx @@ -0,0 +1,74 @@ +import { useEffect, useMemo, useRef, useState } from "react" +import TransitionEffect from "./transition-effect" +import accountApi from "@/api/account.api" +import { Loader2, UserCheck2Icon } from 'lucide-react' + +export default function EmailCaptcha(props: { email: string, onCodeSend: () => void }) { + const { email } = props + const [sendingCode, setSendingCode] = useState(false) + const [getCodeError, setGetCodeError] = useState('') + + const buttonId = useMemo(() => { + return `xn-btn-${new Date().getTime()}` + }, [email]) + + async function sendEmailCode(email: string, captcha: string) { + setSendingCode(true) + setGetCodeError('') + await accountApi.getEmailCode({ account_type: 'email', email }, captcha) + setSendingCode(false) + } + + async function captchaVerifyCallback(captchaVerifyParam: object) { + try { + await sendEmailCode(email, JSON.stringify(captchaVerifyParam)) + return { captchaResult: true, bizResult: true } + } catch (err: any) { + setGetCodeError(err.message) + return { captchaResult: false, bizResult: false } + } + } + + async function onBizResultCallback(result: boolean) { + if (result) { props.onCodeSend() } + } + + const captcha = useRef() + function getInstance(instance: unknown) { + captcha.current = instance; + } + + useEffect(() => { + if (!email) return + window.initAliyunCaptcha({ + SceneId: 'tqyu8129d', + prefix: '1mfsn5f', + mode: 'popup', + element: '#captcha-element', + button: `#${buttonId}`, + captchaVerifyCallback: captchaVerifyCallback, + onBizResultCallback: onBizResultCallback, + getInstance: getInstance, + slideStyle: { + width: 360, + height: 40, + }, + language: 'en', + region: 'cn' + }) + + return () => { + document.getElementById('aliyunCaptcha-mask')?.remove(); + document.getElementById('aliyunCaptcha-window-popup')?.remove(); + } + }, [email]) + + return +
+ + +
+ {getCodeError &&

{getCodeError}

} + + +} \ No newline at end of file diff --git a/lib/components/email-connect-widget.tsx b/lib/components/email-connect-widget.tsx new file mode 100644 index 0000000..7f799b0 --- /dev/null +++ b/lib/components/email-connect-widget.tsx @@ -0,0 +1,26 @@ + +import TransitionEffect from './transition-effect' +import ControlHead from './control-head' +import EmailConnect from './email-connect' +import { useState } from 'react' +import EmailCaptcha from './email-captcha' + +export default function EmailConnectWidget(props: { + email: string + onInputCode: (email: string, code: string) => Promise + onBack: () => void +}) { + const { email } = props + const [step, setStep] = useState<'captcha' | 'verify-email'>('captcha') + + + return ( + +
+ +
+ {step === 'captcha' && setStep('verify-email')} />} + {step === 'verify-email' && setStep('captcha')}>} +
+ ) +} diff --git a/lib/components/email-connect.tsx b/lib/components/email-connect.tsx new file mode 100644 index 0000000..0571084 --- /dev/null +++ b/lib/components/email-connect.tsx @@ -0,0 +1,83 @@ + +import TransitionEffect from './transition-effect' +import { useEffect, useState } from 'react' +import { InputOTP, InputOTPGroup, InputOTPSlot } from './ui/input-otp' +import { Mail } from 'lucide-react' +import Spin from './ui/spin' +import { cn } from '@udecode/cn' +import 'https://o.alicdn.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js' + +export default function EmailConnect(props: { + email: string + onInputCode: (email: string, code: string) => Promise + onResendCode: () => void +}) { + const { email } = props + const [count, setCount] = useState(0) + const [loading, setLoading] = useState(false) + const [connectError, setConnectError] = useState('') + + async function startCountDown() { + setCount(60) + const timer = setInterval(() => { + setCount((prev) => { + if (prev === 0) { + clearInterval(timer) + return 0 + } + return prev - 1 + }) + }, 1000) + } + + async function handleOTPChange(value: string) { + setConnectError('') + if (value.length < 6) return + setLoading(true) + try { + await props.onInputCode(email, value) + } catch (err: any) { + setConnectError(err.message) + } + setLoading(false) + } + + useEffect(() => { + startCountDown() + }, []) + + return ( + +
+ +
+

We’ve sent a verification code to

+

{email}

+
+ +
+ + + +
+ + + + + + +
+
+
+
+
+ {connectError &&

{connectError}

} +
+ +
+ Not get it? {count ? `Resend in ${count}s` : } +
+
+
+ ) +} diff --git a/lib/components/email-login-widget.tsx b/lib/components/email-login-widget.tsx new file mode 100644 index 0000000..50651e4 --- /dev/null +++ b/lib/components/email-login-widget.tsx @@ -0,0 +1,44 @@ +import ControlHead from './control-head' +import TransitionEffect from './transition-effect' +import accountApi, { ILoginResponse } from '@/api/account.api' +import { useCodattaSigninContext } from '@/providers/codatta-signin-context-provider' +import EmailConnect from './email-connect' +import EmailCaptcha from './email-captcha' +import { useState } from 'react' + +export default function EmailLoginWidget(props: { + email: string + onLogin: (res: ILoginResponse) => Promise + onBack: () => void +}) { + const { email } = props + const config = useCodattaSigninContext() + const [step, setStep] = useState<'captcha' | 'verify-email'>('captcha') + + async function handleOTPChange(email: string, value: string) { + const res = await accountApi.emailLogin({ + account_type: 'email', + connector: 'codatta_email', + account_enum: 'C', + email_code: value, + email: email, + inviter_code: config.inviterCode, + source: { + device: config.device, + channel: config.channel, + app: config.app + } + }) + props.onLogin(res.data) + } + + return ( + +
+ +
+ {step === 'captcha' && setStep('verify-email')} />} + {step === 'verify-email' && setStep('captcha')}>} +
+ ) +} diff --git a/lib/components/email-login.tsx b/lib/components/email-login.tsx deleted file mode 100644 index e29ca86..0000000 --- a/lib/components/email-login.tsx +++ /dev/null @@ -1,121 +0,0 @@ -import ControlHead from './control-head' -import TransitionEffect from './transition-effect' -import { useEffect, useState } from 'react' -import { InputOTP, InputOTPGroup, InputOTPSlot } from './ui/input-otp' -import accountApi, { ILoginResponse } from '@/api/account.api' -import { Loader2, Mail } from 'lucide-react' -import Spin from './ui/spin' -import { cn } from '@udecode/cn' -import { useCodattaSigninContext } from '@/providers/codatta-signin-context-provider' - -export default function EmailLoginWidget(props: { - email: string - onLogin: (res: ILoginResponse) => void - onBack: () => void -}) { - const { email } = props - const [count, setCount] = useState(0) - const [loading, setLoading] = useState(false) - const [sendingCode, setSendingCode] = useState(false) - const [getCodeError, setGetCodeError] = useState('') - const [signInError, setSignInError] = useState('') - const config = useCodattaSigninContext() - - async function startCountDown() { - setCount(60) - const timer = setInterval(() => { - setCount((prev) => { - if (prev === 0) { - clearInterval(timer) - return 0 - } - return prev - 1 - }) - }, 1000) - } - - async function sendEmailCode(email: string) { - setSendingCode(true) - try { - setGetCodeError('') - await accountApi.getEmailCode({ account_type: 'email', email }) - startCountDown() - } catch (err: any) { - setGetCodeError(err.message) - } - setSendingCode(false) - } - - useEffect(() => { - if (!email) return - sendEmailCode(email) - }, [email]) - - async function handleOTPChange(value: string) { - setSignInError('') - if (value.length < 6) return - setLoading(true) - try { - const res = await accountApi.emailLogin({ - account_type: 'email', - connector: 'codatta_email', - account_enum: 'C', - email_code: value, - email: email, - inviter_code: config.inviterCode, - source: { - device: config.device, - channel: config.channel, - app: config.app - } - }) - props.onLogin(res.data) - } catch (err: any) { - setSignInError(err.message) - } - setLoading(false) - } - - return ( - -
- -
- -
- -
- {getCodeError ?

{getCodeError}

: - sendingCode ? : <> -

We’ve sent a verification code to

-

{email}

- - } -
- -
- - - -
- - - - - - -
-
-
-
-
- {signInError &&

{signInError}

} -
- -
- Not get it? {count ? `Resend in ${count}s` : } -
- -
- ) -} diff --git a/lib/components/evm-wallet-login-widget.tsx b/lib/components/evm-wallet-login-widget.tsx index a851dd8..1b618fe 100644 --- a/lib/components/evm-wallet-login-widget.tsx +++ b/lib/components/evm-wallet-login-widget.tsx @@ -8,7 +8,7 @@ import { WalletItem } from '../types/wallet-item.class' import accountApi, { ILoginResponse } from '../api/account.api' import { useCodattaSigninContext } from '@/providers/codatta-signin-context-provider' -export default function WalletLogin(props: { +export default function EvmWalletLoginWidget(props: { wallet: WalletItem onLogin: (res: ILoginResponse) => void onBack: () => void @@ -26,7 +26,7 @@ export default function WalletLogin(props: { }) { const res = await accountApi.walletLogin({ account_type: 'block_chain', - account_enum: 'C', + account_enum: config.role, connector: 'codatta_wallet', inviter_code: config.inviterCode, wallet_name: wallet.config?.name || wallet.key, diff --git a/lib/components/get-wallet.tsx b/lib/components/get-wallet.tsx index dc75e54..2074f53 100644 --- a/lib/components/get-wallet.tsx +++ b/lib/components/get-wallet.tsx @@ -78,7 +78,7 @@ export default function GetWallet(props: { wallet: WalletItem }) { )} {config?.app_store_id && ( diff --git a/lib/components/signin-index.tsx b/lib/components/signin-index.tsx index 8100e5b..57e529b 100644 --- a/lib/components/signin-index.tsx +++ b/lib/components/signin-index.tsx @@ -5,6 +5,7 @@ import { WalletItem } from '../types/wallet-item.class' import TransitionEffect from './transition-effect' import { SignInOptionItem, WalletOption } from './wallet-option' import Spliter from './ui/spliter' +import SingleWalletOption from './single-wallet-option' const ImageTonIcon = 'https://static.codatta.io/codatta-connect/wallet-icons.svg?v=2#ton' @@ -31,6 +32,7 @@ export default function SingInIndex(props: { onSelectWallet: (walletOption: WalletItem) => void onSelectMoreWallets: () => void onSelectTonConnect: () => void + useSingleWallet: boolean config: { showEmailSignIn?: boolean showTonConnect?: boolean @@ -40,7 +42,7 @@ export default function SingInIndex(props: { }) { const [email, setEmail] = useState('') const { featuredWallets, initialized } = useCodattaConnectContext() - const { onEmailConfirm, onSelectWallet, onSelectMoreWallets, onSelectTonConnect, config } = props + const { onEmailConfirm, onSelectWallet, onSelectMoreWallets, onSelectTonConnect, config, useSingleWallet } = props const isEmail = useMemo(() => { const hasChinese = @@ -70,41 +72,52 @@ export default function SingInIndex(props: { return ( {initialized && <> - - {props.header ||
Log in or sign up
} - {config.showEmailSignIn && ( -
- - -
- )} + {props.header ||
Log in or sign up
} - {config.showEmailSignIn && (config.showFeaturedWallets || config.showTonConnect) &&
- OR -
- } + {(featuredWallets.length === 1 && useSingleWallet) ? ( +
+ {featuredWallets.map((wallet) => )} +
+ ) + : <> +
+
+ {config.showFeaturedWallets && featuredWallets && + featuredWallets.map((wallet) => ( + + ))} + {config.showTonConnect && ( + } + title="TON Connect" + onClick={onSelectTonConnect} + > + )} +
+ {config.showMoreWallets && } +
-
-
- {config.showFeaturedWallets && featuredWallets && - featuredWallets.map((wallet) => ( - - ))} - {config.showTonConnect && ( - } - title="TON Connect" - onClick={onSelectTonConnect} - > - )} -
- {config.showMoreWallets && } -
+ {config.showEmailSignIn && (config.showFeaturedWallets || config.showTonConnect) &&
+ OR +
+ } + + {config.showEmailSignIn && ( +
+ + +
+ )} + } }
) diff --git a/lib/components/single-wallet-option.tsx b/lib/components/single-wallet-option.tsx new file mode 100644 index 0000000..3252d82 --- /dev/null +++ b/lib/components/single-wallet-option.tsx @@ -0,0 +1,19 @@ +import { WalletItem } from "../types/wallet-item.class" + +export default function SingleWalletOption(props: { wallet: WalletItem; onClick: (wallet: WalletItem) => void }) { + + const { wallet, onClick } = props + + return
+ + +
+

Connect to {wallet.config?.name}

+
+ +
+
+
+} \ No newline at end of file diff --git a/lib/components/ton-wallet-connect.tsx b/lib/components/ton-wallet-connect.tsx index 0b2afe6..4e0c139 100644 --- a/lib/components/ton-wallet-connect.tsx +++ b/lib/components/ton-wallet-connect.tsx @@ -15,7 +15,7 @@ export default function TonWalletConnect(props: { connector: TonConnect wallet: WalletInfoRemote | WalletInfoInjectable onBack: () => void - loading: boolean + loading?: boolean }) { const { wallet, connector, loading } = props const qrCodeContainer = useRef(null) @@ -24,7 +24,6 @@ export default function TonWalletConnect(props: { const [nonce, setNonce] = useState() const [_guideType, _setGuideType] = useState<'connect' | 'sign' | 'waiting'>('connect') const [qrLoading, setQrLoading] = useState(false) - // const { saveLastUsedWallet } = useCodattaConnectContext() const [link, setLink] = useState() diff --git a/lib/components/ton-wallet-select.tsx b/lib/components/ton-wallet-select.tsx index 1299e35..38d0f04 100644 --- a/lib/components/ton-wallet-select.tsx +++ b/lib/components/ton-wallet-select.tsx @@ -1,6 +1,6 @@ import { useEffect, useMemo, useState } from 'react' import { SignInOptionItem } from './wallet-option' -import TonConnect, { WalletInfo } from '@tonconnect/sdk' +import TonConnect, { WalletInfo, WalletInfoInjectable, WalletInfoRemote } from '@tonconnect/sdk' import TransitionEffect from './transition-effect' import ControlHead from './control-head' import { Search } from 'lucide-react' @@ -16,7 +16,7 @@ function TonWalletOption(props: { wallet: WalletInfo, onClick: (wallet: WalletIn export default function TonWalletSelect(props: { connector: TonConnect - onSelect: (wallet: WalletInfo) => void + onSelect: (wallet: WalletInfoRemote | WalletInfoInjectable) => void onBack: () => void }) { const { connector } = props @@ -37,14 +37,13 @@ export default function TonWalletSelect(props: { async function init() { const wallets = await connector.getWallets() setWallets(wallets) - console.log(wallets) } useEffect(() => { init() }, []) - function handleSelectWallet(wallet: WalletInfo) { + function handleSelectWallet(wallet: WalletInfoRemote | WalletInfoInjectable) { props.onSelect(wallet) } diff --git a/lib/components/wallet-connect-widget.tsx b/lib/components/wallet-connect-widget.tsx index 518a24c..621ff4e 100644 --- a/lib/components/wallet-connect-widget.tsx +++ b/lib/components/wallet-connect-widget.tsx @@ -2,25 +2,25 @@ import { useState } from 'react' import ControlHead from './control-head' import TransitionEffect from './transition-effect' import WalletQr from './wallet-qr' -import WalletConnect from './wallet-connect' +import WalletConnect, { WalletSignInfo } from './wallet-connect' import GetWallet from './get-wallet' import { WalletItem } from '../types/wallet-item.class' export default function WalletConnectWidget(props: { wallet: WalletItem - onConnect: (wallet: WalletItem) => void + onConnect: (wallet: WalletItem, signInfo:WalletSignInfo) => void onBack: () => void }) { const { wallet, onConnect } = props const [step, setStep] = useState(wallet.installed ? 'connect' : 'qr') - async function handleSignFinish() { - onConnect(wallet) + async function handleSignFinish(wallet: WalletItem, signInfo: WalletSignInfo) { + await onConnect(wallet, signInfo) } return ( -
+
{step === 'qr' && ( diff --git a/lib/components/wallet-connect.tsx b/lib/components/wallet-connect.tsx index 892d5ea..1d88d83 100644 --- a/lib/components/wallet-connect.tsx +++ b/lib/components/wallet-connect.tsx @@ -4,16 +4,26 @@ import accountApi from '../api/account.api' import { Loader2 } from 'lucide-react' import { WalletItem } from '../types/wallet-item.class' import { useCodattaConnectContext } from '../codatta-connect-context-provider' +import { getAddress } from 'viem' +import { mainnet } from 'viem/chains' const CONNECT_GUIDE_MESSAGE = 'Accept connection request in the wallet' const MESSAGE_SIGN_GUIDE_MESSAGE = 'Accept sign-in request in your wallet' -function getSiweMessage(address: `0x${string}`, nonce: string) { +export interface WalletSignInfo { + message: string + nonce: string + signature: string + address: string + wallet_name: string +} + +function getSiweMessage(address: `0x${string}`, nonce: string, chainId: number) { const domain = window.location.host const uri = window.location.href const message = createSiweMessage({ address: address, - chainId: 1, + chainId: chainId, domain, nonce, uri, @@ -24,39 +34,49 @@ function getSiweMessage(address: `0x${string}`, nonce: string) { export default function WalletConnect(props: { wallet: WalletItem - onSignFinish: (wallet:WalletItem , params: { - message: string - nonce: string - signature: string - address: string - wallet_name: string - }) => Promise + onSignFinish: (wallet: WalletItem, params: WalletSignInfo) => Promise onShowQrCode: () => void }) { const [error, setError] = useState() const { wallet, onSignFinish } = props const nonce = useRef() - const [guideType, setGuideType] = useState<'connect' | 'sign' | 'waiting'>('connect') - const { saveLastUsedWallet } = useCodattaConnectContext() + const [guideType, setGuideType] = useState<'connect' | 'sign' | 'waiting' | 'switch-chain'>('connect') + const { saveLastUsedWallet, chains } = useCodattaConnectContext() async function walletSignin(nonce: string) { try { setGuideType('connect') - const address = await wallet.connect() - if (!address || address.length === 0) { + // get addresses + const addresses = await wallet.connect() + if (!addresses || addresses.length === 0) { throw new Error('Wallet connect error') } - const message = getSiweMessage(address[0], nonce) + + // check chain + const currentChain = await wallet.getChain() + const findChain = chains.find((c) => c.id === currentChain) + const targetChain = findChain || chains[0] || mainnet + + // chain check and switch + if (!findChain && chains.length > 0) { + setGuideType('switch-chain') + await wallet.switchChain(targetChain) + } + + const address = getAddress(addresses[0]) + const message = getSiweMessage(address, nonce, targetChain.id) + setGuideType('sign') - const signature = await wallet.signMessage(message, address[0]) + const signature = await wallet.signMessage(message, address) if (!signature || signature.length === 0) { throw new Error('user sign error') } setGuideType('waiting') - await onSignFinish(wallet, { address: address[0], signature, message, nonce, wallet_name: wallet.config?.name || '' }) + await onSignFinish(wallet, { address, signature, message, nonce, wallet_name: wallet.config?.name || '' }) saveLastUsedWallet(wallet) - } catch (err: any) { - console.log(err.details) + } catch (err:any) { + console.log('walletSignin error', err.stack) + console.log(err.details || err.message) setError(err.details || err.message) } } @@ -69,7 +89,7 @@ export default function WalletConnect(props: { async function initWalletConnect() { try { setError('') - const res = await accountApi.getNonce({account_type: 'block_chain'}) + const res = await accountApi.getNonce({ account_type: 'block_chain' }) nonce.current = res walletSignin(nonce.current) } catch (err: any) { @@ -105,6 +125,7 @@ export default function WalletConnect(props: { )} + {guideType === 'switch-chain' && Switch to {chains[0].name}} )}
diff --git a/lib/components/wallet-qr.tsx b/lib/components/wallet-qr.tsx index d0a74c3..9c22c90 100644 --- a/lib/components/wallet-qr.tsx +++ b/lib/components/wallet-qr.tsx @@ -29,10 +29,10 @@ const walletProviderConnectConfig = { 'personal_sign', 'eth_signTypedData', ], - chains: ['eip155:1'], + chains: ['eip155:56'], events: ['chainChanged', 'accountsChanged', 'disconnect'], rpcMap: { - 1: `https://rpc.walletconnect.com?chainId=eip155:1&projectId=${WALLETCONNECT_PROJECT_ID}`, + 1: `https://rpc.walletconnect.com?chainId=eip155:56&projectId=${WALLETCONNECT_PROJECT_ID}`, }, }, }, @@ -82,7 +82,6 @@ export default function WalletQr(props: { try { setGuideType('scan') provider.on('display_uri', (uri:string) => { - console.log('display_uri', uri) setWcUri(uri) setUriLoading(false) setGuideType('scan') @@ -112,11 +111,11 @@ export default function WalletQr(props: { address, wallet_name: newWallet.config?.name || wallet.config?.name || '' }) + console.log('save wallet connect wallet!') saveLastUsedWallet(newWallet) } catch (err: any) { console.log('err', err) setError(err.details || err.message) - } } diff --git a/lib/constant/wallet-book.ts b/lib/constant/wallet-book.ts index c25f902..61ac185 100644 --- a/lib/constant/wallet-book.ts +++ b/lib/constant/wallet-book.ts @@ -53,6 +53,16 @@ export const WalletBook: WalletConfig[] = [ deep_link: 'metamask://wc', universal_link: 'https://metamask.app.link/wc', }, + { + name: 'Binance Wallet', + featured: true, + image: `${walletIconsImage}#ebac7b39-688c-41e3-7912-a4fefba74600`, + getWallet: { + chrome_store_id: 'cadiboklkpojfamcoggejbbdjcoiljjk', + play_store_id: 'com.binance.dev', + app_store_id: 'id1436799971', + } + }, { featured: true, @@ -129,14 +139,6 @@ export const WalletBook: WalletConfig[] = [ play_store_id: "com.debank.rabbymobile", app_store_id: "id6474381673", } - },{ - name: 'Binance Web3 Wallet', - featured: false, - image: `${walletIconsImage}#ebac7b39-688c-41e3-7912-a4fefba74600`, - getWallet: { - play_store_id: 'com.binance.dev', - app_store_id: 'id1436799971', - } }, { name: 'Rainbow Wallet', diff --git a/lib/main.ts b/lib/main.ts index 0891ace..3b5bb35 100644 --- a/lib/main.ts +++ b/lib/main.ts @@ -1,3 +1,5 @@ import './index.css' export * from './codatta-connect-context-provider' -export * from './codatta-signin' \ No newline at end of file +export * from './codatta-signin' +export * from './codatta-connect' +export * from './types/wallet-item.class' \ No newline at end of file diff --git a/lib/providers/codatta-signin-context-provider.tsx b/lib/providers/codatta-signin-context-provider.tsx index 4f26e36..1f8801c 100644 --- a/lib/providers/codatta-signin-context-provider.tsx +++ b/lib/providers/codatta-signin-context-provider.tsx @@ -1,18 +1,21 @@ import { TDeviceType } from '@/api/account.api' import { createContext, useContext, useEffect, useState } from 'react' +import 'https://o.alicdn.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js' export interface CodattaSigninConfig { channel: string, device: TDeviceType app: string, inviterCode: string, + role?: "B" | "C" } -const CodattaSigninContext = createContext({ +const CodattaSigninContext = createContext({ channel: '', device: 'WEB', app: '', inviterCode: '', + role: 'C' }) export function useCodattaSigninContext() { @@ -29,6 +32,7 @@ export function CodattaSinginContextProvider(props: CodattaConnectContextProvide const [channel, setChannel] = useState(config.channel) const [device, setDevice] = useState(config.device) const [app, setApp] = useState(config.app) + const [role, setRole] = useState<("B" | "C")>(config.role || 'C') const [inviterCode, setInviderCode] = useState(config.inviterCode) useEffect(() => { @@ -36,6 +40,7 @@ export function CodattaSinginContextProvider(props: CodattaConnectContextProvide setDevice(config.device) setApp(config.app) setInviderCode(config.inviterCode) + setRole(config.role || 'C') }, [config]) return ( @@ -45,6 +50,7 @@ export function CodattaSinginContextProvider(props: CodattaConnectContextProvide device, app, inviterCode, + role }} > {props.children} diff --git a/lib/types/wallet-item.class.ts b/lib/types/wallet-item.class.ts index a52c1d1..610b70d 100644 --- a/lib/types/wallet-item.class.ts +++ b/lib/types/wallet-item.class.ts @@ -1,4 +1,4 @@ -import { EIP1193Provider, WalletClient, createWalletClient, custom } from 'viem' +import { Chain, EIP1193Provider, WalletClient, createWalletClient, custom } from 'viem' import { WalletConfig } from '../constant/wallet-book' import UniversalProvider from '@walletconnect/universal-provider' import { EIP6963ProviderDetail } from '../utils/eip6963-detect' @@ -13,6 +13,7 @@ export class WalletItem { private _fatured: boolean = false private _installed: boolean = false public lastUsed: boolean = false + private _client: WalletClient | null = null public get address() { return this._address @@ -34,10 +35,14 @@ export class WalletItem { return this._installed } + public get provider() { + return this._provider + } + public get client(): WalletClient | null { - if (!this._provider) return null - return createWalletClient({ transport: custom(this._provider) }) + if (!this._client) return null + return this._client } public get config() { @@ -62,17 +67,19 @@ export class WalletItem { if (!params.session) throw new Error('session is null') this._key = params.session?.peer.metadata.name this._provider = params + this._client = createWalletClient({ transport: custom(this._provider) }) this._config = { name: params.session.peer.metadata.name, image: params.session.peer.metadata.icons[0], featured: false, } + this.testConnect() } else if ('info' in params) { // eip6963 - console.log(params.info, 'installed') this._key = params.info.name this._provider = params.provider this._installed = true + this._client = createWalletClient({ transport: custom(this._provider) }) this._config = { name: params.info.name, image: params.info.icon, @@ -86,6 +93,7 @@ export class WalletItem { public EIP6963Detected(detail: EIP6963ProviderDetail) { this._provider = detail.provider + this._client = createWalletClient({ transport: custom(this._provider) }) this._installed = true this._provider.on('disconnect', this.disconnect) this._provider.on('accountsChanged', (addresses: `0x${string}`[]) => { @@ -97,9 +105,26 @@ export class WalletItem { public setUniversalProvider(provider: UniversalProvider) { this._provider = provider + this._client = createWalletClient({ transport: custom(this._provider) }) this.testConnect() } + public async switchChain(chain: Chain) { + try { + const currentChain = await this.client?.getChainId() + if (currentChain === chain.id) return true + await this.client?.switchChain(chain) + return true + } catch (error: any) { + if (error.code === 4902) { + await this.client?.addChain({chain}) + await this.client?.switchChain(chain) + return true + } + throw error + } + } + private async testConnect() { const address = await this.client?.getAddresses() if (address && address.length > 0) { @@ -112,7 +137,7 @@ export class WalletItem { } async connect() { - const addresses = await this.client?.request({ method: 'eth_requestAccounts', params: undefined }) + const addresses = await this.client?.requestAddresses() if (!addresses) throw new Error('connect failed') return addresses } @@ -129,7 +154,7 @@ export class WalletItem { return chain } - async signMessage(message: string, address:`0x${string}`) { + async signMessage(message: string, address: `0x${string}`) { const signature = await this.client?.signMessage({ message, account: address }) return signature } @@ -137,7 +162,7 @@ export class WalletItem { async disconnect() { if (this._provider && 'session' in this._provider) { await this._provider.disconnect() - } + } this._connected = false this._address = null } diff --git a/lib/vite-env.d.ts b/lib/vite-env.d.ts new file mode 100644 index 0000000..a623e08 --- /dev/null +++ b/lib/vite-env.d.ts @@ -0,0 +1,8 @@ +/// + +interface Window { + initAliyunCaptcha: any + ethereum?: { + isBinance: boolean + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6c5b34c..368d7d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,14 @@ { "name": "codatta-connect", - "version": "2.0.5", + "version": "2.5.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "codatta-connect", - "version": "2.0.5", + "version": "2.5.9", "dependencies": { + "@binance/w3w-utils": "^1.1.6", "@coinbase/wallet-sdk": "^4.2.4", "@tonconnect/sdk": "^3.0.5", "@types/node": "^22.9.0", @@ -27,15 +28,16 @@ "react-dom": "^18.3.1", "tailwindcss": "^3.4.15", "valtio": "^2.1.2", - "viem": "^2.21.45", - "vite": "^5.4.11", + "viem": "^2.31.3", + "vite": "^7.1.6", "vite-plugin-dts": "^4.3.0" } }, "node_modules/@adraffy/ens-normalize": { "version": "1.11.0", - "resolved": "https://registry.npmmirror.com/@adraffy/ens-normalize/-/ens-normalize-1.11.0.tgz", - "integrity": "sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==" + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.0.tgz", + "integrity": "sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==", + "license": "MIT" }, "node_modules/@alloc/quick-lru": { "version": "5.2.0", @@ -304,6 +306,27 @@ "node": ">=6.9.0" } }, + "node_modules/@binance/w3w-types": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@binance/w3w-types/-/w3w-types-1.1.4.tgz", + "integrity": "sha512-CCnneapNTVY1+RseZNIhExVp3ux8LihcXRkGwmvJtZTTJJIC7xQlTWy9olkAsz+opqWK+heAcyYGmt4RUt1M5g==", + "license": "Apache-2.0", + "dependencies": { + "eventemitter3": "^5.0.0" + } + }, + "node_modules/@binance/w3w-utils": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@binance/w3w-utils/-/w3w-utils-1.1.6.tgz", + "integrity": "sha512-NGT629vS9tRlbigtNn9wHtTYNB00oyDcsajO/kpAcDiQn4ktYs7+oTIr/qLvjP8Z3opTXpbooqMPITDY7DI0IA==", + "license": "ISC", + "dependencies": { + "@binance/w3w-types": "1.1.4", + "eventemitter3": "^5.0.0", + "hash.js": "^1.1.7", + "js-base64": "^3.7.5" + } + }, "node_modules/@coinbase/wallet-sdk": { "version": "4.2.4", "resolved": "https://registry.npmmirror.com/@coinbase/wallet-sdk/-/wallet-sdk-4.2.4.tgz", @@ -316,348 +339,419 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", - "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.10.tgz", + "integrity": "sha512-0NFWnA+7l41irNuaSVlLfgNT12caWJVLzp5eAVhZ0z1qpxbockccEt3s+149rE64VUI3Ml2zt8Nv5JVc4QXTsw==", "cpu": [ "ppc64" ], + "license": "MIT", "optional": true, "os": [ "aix" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/android-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz", - "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.10.tgz", + "integrity": "sha512-dQAxF1dW1C3zpeCDc5KqIYuZ1tgAdRXNoZP7vkBIRtKZPYe2xVr/d3SkirklCHudW1B45tGiUlz2pUWDfbDD4w==", "cpu": [ "arm" ], + "license": "MIT", "optional": true, "os": [ "android" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/android-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", - "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.10.tgz", + "integrity": "sha512-LSQa7eDahypv/VO6WKohZGPSJDq5OVOo3UoFR1E4t4Gj1W7zEQMUhI+lo81H+DtB+kP+tDgBp+M4oNCwp6kffg==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "android" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/android-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz", - "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.10.tgz", + "integrity": "sha512-MiC9CWdPrfhibcXwr39p9ha1x0lZJ9KaVfvzA0Wxwz9ETX4v5CHfF09bx935nHlhi+MxhA63dKRRQLiVgSUtEg==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "android" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", - "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.10.tgz", + "integrity": "sha512-JC74bdXcQEpW9KkV326WpZZjLguSZ3DfS8wrrvPMHgQOIEIG/sPXEN/V8IssoJhbefLRcRqw6RQH2NnpdprtMA==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "darwin" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", - "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.10.tgz", + "integrity": "sha512-tguWg1olF6DGqzws97pKZ8G2L7Ig1vjDmGTwcTuYHbuU6TTjJe5FXbgs5C1BBzHbJ2bo1m3WkQDbWO2PvamRcg==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "darwin" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", - "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.10.tgz", + "integrity": "sha512-3ZioSQSg1HT2N05YxeJWYR+Libe3bREVSdWhEEgExWaDtyFbbXWb49QgPvFH8u03vUPX10JhJPcz7s9t9+boWg==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "freebsd" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", - "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.10.tgz", + "integrity": "sha512-LLgJfHJk014Aa4anGDbh8bmI5Lk+QidDmGzuC2D+vP7mv/GeSN+H39zOf7pN5N8p059FcOfs2bVlrRr4SK9WxA==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "freebsd" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-arm": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", - "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.10.tgz", + "integrity": "sha512-oR31GtBTFYCqEBALI9r6WxoU/ZofZl962pouZRTEYECvNF/dtXKku8YXcJkhgK/beU+zedXfIzHijSRapJY3vg==", "cpu": [ "arm" ], + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", - "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.10.tgz", + "integrity": "sha512-5luJWN6YKBsawd5f9i4+c+geYiVEw20FVW5x0v1kEMWNq8UctFjDiMATBxLvmmHA4bf7F6hTRaJgtghFr9iziQ==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", - "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.10.tgz", + "integrity": "sha512-NrSCx2Kim3EnnWgS4Txn0QGt0Xipoumb6z6sUtl5bOEZIVKhzfyp/Lyw4C1DIYvzeW/5mWYPBFJU3a/8Yr75DQ==", "cpu": [ "ia32" ], + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", - "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.10.tgz", + "integrity": "sha512-xoSphrd4AZda8+rUDDfD9J6FUMjrkTz8itpTITM4/xgerAZZcFW7Dv+sun7333IfKxGG8gAq+3NbfEMJfiY+Eg==", "cpu": [ "loong64" ], + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", - "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.10.tgz", + "integrity": "sha512-ab6eiuCwoMmYDyTnyptoKkVS3k8fy/1Uvq7Dj5czXI6DF2GqD2ToInBI0SHOp5/X1BdZ26RKc5+qjQNGRBelRA==", "cpu": [ "mips64el" ], + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", - "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.10.tgz", + "integrity": "sha512-NLinzzOgZQsGpsTkEbdJTCanwA5/wozN9dSgEl12haXJBzMTpssebuXR42bthOF3z7zXFWH1AmvWunUCkBE4EA==", "cpu": [ "ppc64" ], + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", - "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.10.tgz", + "integrity": "sha512-FE557XdZDrtX8NMIeA8LBJX3dC2M8VGXwfrQWU7LB5SLOajfJIxmSdyL/gU1m64Zs9CBKvm4UAuBp5aJ8OgnrA==", "cpu": [ "riscv64" ], + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", - "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.10.tgz", + "integrity": "sha512-3BBSbgzuB9ajLoVZk0mGu+EHlBwkusRmeNYdqmznmMc9zGASFjSsxgkNsqmXugpPk00gJ0JNKh/97nxmjctdew==", "cpu": [ "s390x" ], + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/linux-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", - "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.10.tgz", + "integrity": "sha512-QSX81KhFoZGwenVyPoberggdW1nrQZSvfVDAIUXr3WqLRZGZqWk/P4T8p2SP+de2Sr5HPcvjhcJzEiulKgnxtA==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "linux" ], "engines": { - "node": ">=12" + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.10.tgz", + "integrity": "sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" } }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", - "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.10.tgz", + "integrity": "sha512-7RTytDPGU6fek/hWuN9qQpeGPBZFfB4zZgcz2VK2Z5VpdUxEI8JKYsg3JfO0n/Z1E/6l05n0unDCNc4HnhQGig==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "netbsd" ], "engines": { - "node": ">=12" + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.10.tgz", + "integrity": "sha512-5Se0VM9Wtq797YFn+dLimf2Zx6McttsH2olUBsDml+lm0GOCRVebRWUvDtkY4BWYv/3NgzS8b/UM3jQNh5hYyw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", - "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.10.tgz", + "integrity": "sha512-XkA4frq1TLj4bEMB+2HnI0+4RnjbuGZfet2gs/LNs5Hc7D89ZQBHQ0gL2ND6Lzu1+QVkjp3x1gIcPKzRNP8bXw==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "openbsd" ], "engines": { - "node": ">=12" + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.10.tgz", + "integrity": "sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", - "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.10.tgz", + "integrity": "sha512-fswk3XT0Uf2pGJmOpDB7yknqhVkJQkAQOcW/ccVOtfx05LkbWOaRAtn5SaqXypeKQra1QaEa841PgrSL9ubSPQ==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "sunos" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", - "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.10.tgz", + "integrity": "sha512-ah+9b59KDTSfpaCg6VdJoOQvKjI33nTaQr4UluQwW7aEwZQsbMCfTmfEO4VyewOxx4RaDT/xCy9ra2GPWmO7Kw==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "win32" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", - "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.10.tgz", + "integrity": "sha512-QHPDbKkrGO8/cz9LKVnJU22HOi4pxZnZhhA2HYHez5Pz4JeffhDjf85E57Oyco163GnzNCVkZK0b/n4Y0UHcSw==", "cpu": [ "ia32" ], + "license": "MIT", "optional": true, "os": [ "win32" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@esbuild/win32-x64": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", - "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.10.tgz", + "integrity": "sha512-9KpxSVFCu0iK1owoez6aC/s/EdUQLDN3adTxGCqxMVhrPDj6bt5dbrHDXUuq+Bs2vATFBBrQS5vdQ/Ed2P+nbw==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "win32" ], "engines": { - "node": ">=12" + "node": ">=18" } }, "node_modules/@ethersproject/abstract-provider": { @@ -1197,12 +1291,25 @@ "resolve": "~1.22.2" } }, + "node_modules/@noble/ciphers": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz", + "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@noble/curves": { - "version": "1.6.0", - "resolved": "https://registry.npmmirror.com/@noble/curves/-/curves-1.6.0.tgz", - "integrity": "sha512-TlaHRXDehJuRNR9TfZDNQ45mMEd5dwUwmicsafcIX4SsNiqnCHKjE/1alYPd/lDRVhxdhUAlv8uEhMCI5zjIJQ==", + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.2.tgz", + "integrity": "sha512-HxngEd2XUcg9xi20JkwlLCtYwfoFw4JGkuZpT+WlsPD4gB/cxkvTD8fSsoAnphGZhFdZYKeQIPCuFlWPm1uE0g==", + "license": "MIT", "dependencies": { - "@noble/hashes": "1.5.0" + "@noble/hashes": "1.8.0" }, "engines": { "node": "^14.21.3 || >=16" @@ -1212,9 +1319,10 @@ } }, "node_modules/@noble/hashes": { - "version": "1.5.0", - "resolved": "https://registry.npmmirror.com/@noble/hashes/-/hashes-1.5.0.tgz", - "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", "engines": { "node": "^14.21.3 || >=16" }, @@ -1633,216 +1741,273 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.27.2.tgz", - "integrity": "sha512-Tj+j7Pyzd15wAdSJswvs5CJzJNV+qqSUcr/aCD+jpQSBtXvGnV0pnrjoc8zFTe9fcKCatkpFpOO7yAzpO998HA==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.50.2.tgz", + "integrity": "sha512-uLN8NAiFVIRKX9ZQha8wy6UUs06UNSZ32xj6giK/rmMXAgKahwExvK6SsmgU5/brh4w/nSgj8e0k3c1HBQpa0A==", "cpu": [ "arm" ], + "license": "MIT", "optional": true, "os": [ "android" ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.27.2.tgz", - "integrity": "sha512-xsPeJgh2ThBpUqlLgRfiVYBEf/P1nWlWvReG+aBWfNv3XEBpa6ZCmxSVnxJgLgkNz4IbxpLy64h2gCmAAQLneQ==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.50.2.tgz", + "integrity": "sha512-oEouqQk2/zxxj22PNcGSskya+3kV0ZKH+nQxuCCOGJ4oTXBdNTbv+f/E3c74cNLeMO1S5wVWacSws10TTSB77g==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "android" ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.27.2.tgz", - "integrity": "sha512-KnXU4m9MywuZFedL35Z3PuwiTSn/yqRIhrEA9j+7OSkji39NzVkgxuxTYg5F8ryGysq4iFADaU5osSizMXhU2A==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.50.2.tgz", + "integrity": "sha512-OZuTVTpj3CDSIxmPgGH8en/XtirV5nfljHZ3wrNwvgkT5DQLhIKAeuFSiwtbMto6oVexV0k1F1zqURPKf5rI1Q==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "darwin" ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.27.2.tgz", - "integrity": "sha512-Hj77A3yTvUeCIx/Vi+4d4IbYhyTwtHj07lVzUgpUq9YpJSEiGJj4vXMKwzJ3w5zp5v3PFvpJNgc/J31smZey6g==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.50.2.tgz", + "integrity": "sha512-Wa/Wn8RFkIkr1vy1k1PB//VYhLnlnn5eaJkfTQKivirOvzu5uVd2It01ukeQstMursuz7S1bU+8WW+1UPXpa8A==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "darwin" ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.27.2.tgz", - "integrity": "sha512-RjgKf5C3xbn8gxvCm5VgKZ4nn0pRAIe90J0/fdHUsgztd3+Zesb2lm2+r6uX4prV2eUByuxJNdt647/1KPRq5g==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.50.2.tgz", + "integrity": "sha512-QkzxvH3kYN9J1w7D1A+yIMdI1pPekD+pWx7G5rXgnIlQ1TVYVC6hLl7SOV9pi5q9uIDF9AuIGkuzcbF7+fAhow==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "freebsd" ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.27.2.tgz", - "integrity": "sha512-duq21FoXwQtuws+V9H6UZ+eCBc7fxSpMK1GQINKn3fAyd9DFYKPJNcUhdIKOrMFjLEJgQskoMoiuizMt+dl20g==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.50.2.tgz", + "integrity": "sha512-dkYXB0c2XAS3a3jmyDkX4Jk0m7gWLFzq1C3qUnJJ38AyxIF5G/dyS4N9B30nvFseCfgtCEdbYFhk0ChoCGxPog==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "freebsd" ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.27.2.tgz", - "integrity": "sha512-6npqOKEPRZkLrMcvyC/32OzJ2srdPzCylJjiTJT2c0bwwSGm7nz2F9mNQ1WrAqCBZROcQn91Fno+khFhVijmFA==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.50.2.tgz", + "integrity": "sha512-9VlPY/BN3AgbukfVHAB8zNFWB/lKEuvzRo1NKev0Po8sYFKx0i+AQlCYftgEjcL43F2h9Ui1ZSdVBc4En/sP2w==", "cpu": [ "arm" ], + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.27.2.tgz", - "integrity": "sha512-V9Xg6eXtgBtHq2jnuQwM/jr2mwe2EycnopO8cbOvpzFuySCGtKlPCI3Hj9xup/pJK5Q0388qfZZy2DqV2J8ftw==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.50.2.tgz", + "integrity": "sha512-+GdKWOvsifaYNlIVf07QYan1J5F141+vGm5/Y8b9uCZnG/nxoGqgCmR24mv0koIWWuqvFYnbURRqw1lv7IBINw==", "cpu": [ "arm" ], + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.27.2.tgz", - "integrity": "sha512-uCFX9gtZJoQl2xDTpRdseYuNqyKkuMDtH6zSrBTA28yTfKyjN9hQ2B04N5ynR8ILCoSDOrG/Eg+J2TtJ1e/CSA==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.50.2.tgz", + "integrity": "sha512-df0Eou14ojtUdLQdPFnymEQteENwSJAdLf5KCDrmZNsy1c3YaCNaJvYsEUHnrg+/DLBH612/R0xd3dD03uz2dg==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.27.2.tgz", - "integrity": "sha512-/PU9P+7Rkz8JFYDHIi+xzHabOu9qEWR07L5nWLIUsvserrxegZExKCi2jhMZRd0ATdboKylu/K5yAXbp7fYFvA==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.50.2.tgz", + "integrity": "sha512-iPeouV0UIDtz8j1YFR4OJ/zf7evjauqv7jQ/EFs0ClIyL+by++hiaDAfFipjOgyz6y6xbDvJuiU4HwpVMpRFDQ==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "linux" ] }, - "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.27.2.tgz", - "integrity": "sha512-eCHmol/dT5odMYi/N0R0HC8V8QE40rEpkyje/ZAXJYNNoSfrObOvG/Mn+s1F/FJyB7co7UQZZf6FuWnN6a7f4g==", + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.50.2.tgz", + "integrity": "sha512-OL6KaNvBopLlj5fTa5D5bau4W82f+1TyTZRr2BdnfsrnQnmdxh4okMxR2DcDkJuh4KeoQZVuvHvzuD/lyLn2Kw==", + "cpu": [ + "loong64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.50.2.tgz", + "integrity": "sha512-I21VJl1w6z/K5OTRl6aS9DDsqezEZ/yKpbqlvfHbW0CEF5IL8ATBMuUx6/mp683rKTK8thjs/0BaNrZLXetLag==", "cpu": [ "ppc64" ], + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.27.2.tgz", - "integrity": "sha512-DEP3Njr9/ADDln3kNi76PXonLMSSMiCir0VHXxmGSHxCxDfQ70oWjHcJGfiBugzaqmYdTC7Y+8Int6qbnxPBIQ==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.50.2.tgz", + "integrity": "sha512-Hq6aQJT/qFFHrYMjS20nV+9SKrXL2lvFBENZoKfoTH2kKDOJqff5OSJr4x72ZaG/uUn+XmBnGhfr4lwMRrmqCQ==", "cpu": [ "riscv64" ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.50.2.tgz", + "integrity": "sha512-82rBSEXRv5qtKyr0xZ/YMF531oj2AIpLZkeNYxmKNN6I2sVE9PGegN99tYDLK2fYHJITL1P2Lgb4ZXnv0PjQvw==", + "cpu": [ + "riscv64" + ], + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.27.2.tgz", - "integrity": "sha512-NHGo5i6IE/PtEPh5m0yw5OmPMpesFnzMIS/lzvN5vknnC1sXM5Z/id5VgcNPgpD+wHmIcuYYgW+Q53v+9s96lQ==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.50.2.tgz", + "integrity": "sha512-4Q3S3Hy7pC6uaRo9gtXUTJ+EKo9AKs3BXKc2jYypEcMQ49gDPFU2P1ariX9SEtBzE5egIX6fSUmbmGazwBVF9w==", "cpu": [ "s390x" ], + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.27.2.tgz", - "integrity": "sha512-PaW2DY5Tan+IFvNJGHDmUrORadbe/Ceh8tQxi8cmdQVCCYsLoQo2cuaSj+AU+YRX8M4ivS2vJ9UGaxfuNN7gmg==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.50.2.tgz", + "integrity": "sha512-9Jie/At6qk70dNIcopcL4p+1UirusEtznpNtcq/u/C5cC4HBX7qSGsYIcG6bdxj15EYWhHiu02YvmdPzylIZlA==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "linux" ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.27.2.tgz", - "integrity": "sha512-dOlWEMg2gI91Qx5I/HYqOD6iqlJspxLcS4Zlg3vjk1srE67z5T2Uz91yg/qA8sY0XcwQrFzWWiZhMNERylLrpQ==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.50.2.tgz", + "integrity": "sha512-HPNJwxPL3EmhzeAnsWQCM3DcoqOz3/IC6de9rWfGR8ZCuEHETi9km66bH/wG3YH0V3nyzyFEGUZeL5PKyy4xvw==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "linux" ] }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.50.2.tgz", + "integrity": "sha512-nMKvq6FRHSzYfKLHZ+cChowlEkR2lj/V0jYj9JnGUVPL2/mIeFGmVM2mLaFeNa5Jev7W7TovXqXIG2d39y1KYA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.27.2.tgz", - "integrity": "sha512-euMIv/4x5Y2/ImlbGl88mwKNXDsvzbWUlT7DFky76z2keajCtcbAsN9LUdmk31hAoVmJJYSThgdA0EsPeTr1+w==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.50.2.tgz", + "integrity": "sha512-eFUvvnTYEKeTyHEijQKz81bLrUQOXKZqECeiWH6tb8eXXbZk+CXSG2aFrig2BQ/pjiVRj36zysjgILkqarS2YA==", "cpu": [ "arm64" ], + "license": "MIT", "optional": true, "os": [ "win32" ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.27.2.tgz", - "integrity": "sha512-RsnE6LQkUHlkC10RKngtHNLxb7scFykEbEwOFDjr3CeCMG+Rr+cKqlkKc2/wJ1u4u990urRHCbjz31x84PBrSQ==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.50.2.tgz", + "integrity": "sha512-cBaWmXqyfRhH8zmUxK3d3sAhEWLrtMjWBRwdMMHJIXSjvjLKvv49adxiEz+FJ8AP90apSDDBx2Tyd/WylV6ikA==", "cpu": [ "ia32" ], + "license": "MIT", "optional": true, "os": [ "win32" ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.27.2.tgz", - "integrity": "sha512-foJM5vv+z2KQmn7emYdDLyTbkoO5bkHZE1oth2tWbQNGW7mX32d46Hz6T0MqXdWS2vBZhaEtHqdy9WYwGfiliA==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.50.2.tgz", + "integrity": "sha512-APwKy6YUhvZaEoHyM+9xqmTpviEI+9eL7LoCH+aLcvWYHJ663qG5zx7WzWZY+a9qkg5JtzcMyJ9z0WtQBMDmgA==", "cpu": [ "x64" ], + "license": "MIT", "optional": true, "os": [ "win32" @@ -1954,33 +2119,36 @@ } }, "node_modules/@scure/base": { - "version": "1.1.9", - "resolved": "https://registry.npmmirror.com/@scure/base/-/base-1.1.9.tgz", - "integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", + "integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", + "license": "MIT", "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@scure/bip32": { - "version": "1.5.0", - "resolved": "https://registry.npmmirror.com/@scure/bip32/-/bip32-1.5.0.tgz", - "integrity": "sha512-8EnFYkqEQdnkuGBVpCzKxyIwDCBLDVj3oiX0EKUFre/tOjL/Hqba1D6n/8RcmaQy4f95qQFrO2A8Sr6ybh4NRw==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.7.0.tgz", + "integrity": "sha512-E4FFX/N3f4B80AKWp5dP6ow+flD1LQZo/w8UnLGYZO674jS6YnYeepycOOksv+vLPSpgN35wgKgy+ybfTb2SMw==", + "license": "MIT", "dependencies": { - "@noble/curves": "~1.6.0", - "@noble/hashes": "~1.5.0", - "@scure/base": "~1.1.7" + "@noble/curves": "~1.9.0", + "@noble/hashes": "~1.8.0", + "@scure/base": "~1.2.5" }, "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@scure/bip39": { - "version": "1.4.0", - "resolved": "https://registry.npmmirror.com/@scure/bip39/-/bip39-1.4.0.tgz", - "integrity": "sha512-BEEm6p8IueV/ZTfQLp/0vhw4NPnT9oWf5+28nvmeUICjP99f4vr2d+qc7AVGDDtwRep6ifR43Yed9ERVmiITzw==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.6.0.tgz", + "integrity": "sha512-+lF0BbLiJNwVlev4eKelw1WWLaiKXw7sSl8T6FvBlWkdX+94aGJ4o8XjUdlyhTCjd8c+B3KT3JfS8P0bLRNU6A==", + "license": "MIT", "dependencies": { - "@noble/hashes": "~1.5.0", - "@scure/base": "~1.1.8" + "@noble/hashes": "~1.8.0", + "@scure/base": "~1.2.5" }, "funding": { "url": "https://paulmillr.com/funding/" @@ -2210,16 +2378,18 @@ } }, "node_modules/@types/estree": { - "version": "1.0.6", - "resolved": "https://registry.npmmirror.com/@types/estree/-/estree-1.0.6.tgz", - "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==" + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", + "license": "MIT" }, "node_modules/@types/node": { - "version": "22.9.0", - "resolved": "https://registry.npmmirror.com/@types/node/-/node-22.9.0.tgz", - "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", + "version": "22.18.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.18.6.tgz", + "integrity": "sha512-r8uszLPpeIWbNKtvWRt/DbVi5zbqZyj1PTmhRMqBMvDnaz1QpmSKujUtJLrqGZeoM8v72MfYggDceY4K1itzWQ==", + "license": "MIT", "dependencies": { - "undici-types": "~6.19.8" + "undici-types": "~6.21.0" } }, "node_modules/@types/prop-types": { @@ -2666,9 +2836,10 @@ } }, "node_modules/abitype": { - "version": "1.0.6", - "resolved": "https://registry.npmmirror.com/abitype/-/abitype-1.0.6.tgz", - "integrity": "sha512-MMSqYh4+C/aVqI2RQaWqbvI4Kxo5cQV40WQ4QFtDnNzCkqChm8MuENhElmynZlO0qUy/ObkEUaXtKqYnx1Kp3A==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.8.tgz", + "integrity": "sha512-ZeiI6h3GnW06uYDLx0etQtX/p8E24UaHHBj57RSjK7YBFe7iuVn07EDpOeP451D06sF27VOz9JJPlIKJmXgkEg==", + "license": "MIT", "funding": { "url": "https://github.com/sponsors/wevm" }, @@ -3297,40 +3468,44 @@ } }, "node_modules/esbuild": { - "version": "0.21.5", - "resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.21.5.tgz", - "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", + "version": "0.25.10", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.10.tgz", + "integrity": "sha512-9RiGKvCwaqxO2owP61uQ4BgNborAQskMR6QusfWzQqv7AZOg5oGehdY2pRJMTKuwxd1IDBP4rSbI5lHzU7SMsQ==", "hasInstallScript": true, + "license": "MIT", "bin": { "esbuild": "bin/esbuild" }, "engines": { - "node": ">=12" + "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.21.5", - "@esbuild/android-arm": "0.21.5", - "@esbuild/android-arm64": "0.21.5", - "@esbuild/android-x64": "0.21.5", - "@esbuild/darwin-arm64": "0.21.5", - "@esbuild/darwin-x64": "0.21.5", - "@esbuild/freebsd-arm64": "0.21.5", - "@esbuild/freebsd-x64": "0.21.5", - "@esbuild/linux-arm": "0.21.5", - "@esbuild/linux-arm64": "0.21.5", - "@esbuild/linux-ia32": "0.21.5", - "@esbuild/linux-loong64": "0.21.5", - "@esbuild/linux-mips64el": "0.21.5", - "@esbuild/linux-ppc64": "0.21.5", - "@esbuild/linux-riscv64": "0.21.5", - "@esbuild/linux-s390x": "0.21.5", - "@esbuild/linux-x64": "0.21.5", - "@esbuild/netbsd-x64": "0.21.5", - "@esbuild/openbsd-x64": "0.21.5", - "@esbuild/sunos-x64": "0.21.5", - "@esbuild/win32-arm64": "0.21.5", - "@esbuild/win32-ia32": "0.21.5", - "@esbuild/win32-x64": "0.21.5" + "@esbuild/aix-ppc64": "0.25.10", + "@esbuild/android-arm": "0.25.10", + "@esbuild/android-arm64": "0.25.10", + "@esbuild/android-x64": "0.25.10", + "@esbuild/darwin-arm64": "0.25.10", + "@esbuild/darwin-x64": "0.25.10", + "@esbuild/freebsd-arm64": "0.25.10", + "@esbuild/freebsd-x64": "0.25.10", + "@esbuild/linux-arm": "0.25.10", + "@esbuild/linux-arm64": "0.25.10", + "@esbuild/linux-ia32": "0.25.10", + "@esbuild/linux-loong64": "0.25.10", + "@esbuild/linux-mips64el": "0.25.10", + "@esbuild/linux-ppc64": "0.25.10", + "@esbuild/linux-riscv64": "0.25.10", + "@esbuild/linux-s390x": "0.25.10", + "@esbuild/linux-x64": "0.25.10", + "@esbuild/netbsd-arm64": "0.25.10", + "@esbuild/netbsd-x64": "0.25.10", + "@esbuild/openbsd-arm64": "0.25.10", + "@esbuild/openbsd-x64": "0.25.10", + "@esbuild/openharmony-arm64": "0.25.10", + "@esbuild/sunos-x64": "0.25.10", + "@esbuild/win32-arm64": "0.25.10", + "@esbuild/win32-ia32": "0.25.10", + "@esbuild/win32-x64": "0.25.10" } }, "node_modules/escalade": { @@ -3895,15 +4070,16 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" }, "node_modules/isows": { - "version": "1.0.6", - "resolved": "https://registry.npmmirror.com/isows/-/isows-1.0.6.tgz", - "integrity": "sha512-lPHCayd40oW98/I0uvgaHKWCSvkzY27LjWLbtzOm64yQ+G3Q5npjjbdppU65iZXkK1Zt+kH9pfegli0AYfwYYw==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.7.tgz", + "integrity": "sha512-I1fSfDCZL5P0v33sVqeTDSpcstAg/N+wF5HS033mogOVIp4B+oHC7oOCsA3axAbBSGTJ8QubbNmnIRN/h8U7hg==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/wevm" } ], + "license": "MIT", "peerDependencies": { "ws": "*" } @@ -3935,6 +4111,12 @@ "resolved": "https://registry.npmmirror.com/jju/-/jju-1.4.0.tgz", "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==" }, + "node_modules/js-base64": { + "version": "3.7.7", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.7.tgz", + "integrity": "sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==", + "license": "BSD-3-Clause" + }, "node_modules/js-sha3": { "version": "0.8.0", "resolved": "https://registry.npmmirror.com/js-sha3/-/js-sha3-0.8.0.tgz", @@ -4232,15 +4414,16 @@ } }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -4390,22 +4573,24 @@ } }, "node_modules/ox": { - "version": "0.1.2", - "resolved": "https://registry.npmmirror.com/ox/-/ox-0.1.2.tgz", - "integrity": "sha512-ak/8K0Rtphg9vnRJlbOdaX9R7cmxD2MiSthjWGaQdMk3D7hrAlDoM+6Lxn7hN52Za3vrXfZ7enfke/5WjolDww==", + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/ox/-/ox-0.8.1.tgz", + "integrity": "sha512-e+z5epnzV+Zuz91YYujecW8cF01mzmrUtWotJ0oEPym/G82uccs7q0WDHTYL3eiONbTUEvcZrptAKLgTBD3u2A==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/wevm" } ], - "dependencies": { - "@adraffy/ens-normalize": "^1.10.1", - "@noble/curves": "^1.6.0", - "@noble/hashes": "^1.5.0", - "@scure/bip32": "^1.5.0", - "@scure/bip39": "^1.4.0", - "abitype": "^1.0.6", + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "^1.11.0", + "@noble/ciphers": "^1.3.0", + "@noble/curves": "^1.9.1", + "@noble/hashes": "^1.8.0", + "@scure/bip32": "^1.7.0", + "@scure/bip39": "^1.6.0", + "abitype": "^1.0.8", "eventemitter3": "5.0.1" }, "peerDependencies": { @@ -4538,9 +4723,9 @@ } }, "node_modules/postcss": { - "version": "8.4.49", - "resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.49.tgz", - "integrity": "sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==", + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", "funding": [ { "type": "opencollective", @@ -4555,8 +4740,9 @@ "url": "https://github.com/sponsors/ai" } ], + "license": "MIT", "dependencies": { - "nanoid": "^3.3.7", + "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" }, @@ -4883,11 +5069,12 @@ } }, "node_modules/rollup": { - "version": "4.27.2", - "resolved": "https://registry.npmmirror.com/rollup/-/rollup-4.27.2.tgz", - "integrity": "sha512-KreA+PzWmk2yaFmZVwe6GB2uBD86nXl86OsDkt1bJS9p3vqWuEQ6HnJJ+j/mZi/q0920P99/MVRlB4L3crpF5w==", + "version": "4.50.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.50.2.tgz", + "integrity": "sha512-BgLRGy7tNS9H66aIMASq1qSYbAAJV6Z6WR4QYTvj5FgF15rZ/ympT1uixHXwzbZUBDbkvqUI1KR0fH1FhMaQ9w==", + "license": "MIT", "dependencies": { - "@types/estree": "1.0.6" + "@types/estree": "1.0.8" }, "bin": { "rollup": "dist/bin/rollup" @@ -4897,24 +5084,27 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.27.2", - "@rollup/rollup-android-arm64": "4.27.2", - "@rollup/rollup-darwin-arm64": "4.27.2", - "@rollup/rollup-darwin-x64": "4.27.2", - "@rollup/rollup-freebsd-arm64": "4.27.2", - "@rollup/rollup-freebsd-x64": "4.27.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.27.2", - "@rollup/rollup-linux-arm-musleabihf": "4.27.2", - "@rollup/rollup-linux-arm64-gnu": "4.27.2", - "@rollup/rollup-linux-arm64-musl": "4.27.2", - "@rollup/rollup-linux-powerpc64le-gnu": "4.27.2", - "@rollup/rollup-linux-riscv64-gnu": "4.27.2", - "@rollup/rollup-linux-s390x-gnu": "4.27.2", - "@rollup/rollup-linux-x64-gnu": "4.27.2", - "@rollup/rollup-linux-x64-musl": "4.27.2", - "@rollup/rollup-win32-arm64-msvc": "4.27.2", - "@rollup/rollup-win32-ia32-msvc": "4.27.2", - "@rollup/rollup-win32-x64-msvc": "4.27.2", + "@rollup/rollup-android-arm-eabi": "4.50.2", + "@rollup/rollup-android-arm64": "4.50.2", + "@rollup/rollup-darwin-arm64": "4.50.2", + "@rollup/rollup-darwin-x64": "4.50.2", + "@rollup/rollup-freebsd-arm64": "4.50.2", + "@rollup/rollup-freebsd-x64": "4.50.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.50.2", + "@rollup/rollup-linux-arm-musleabihf": "4.50.2", + "@rollup/rollup-linux-arm64-gnu": "4.50.2", + "@rollup/rollup-linux-arm64-musl": "4.50.2", + "@rollup/rollup-linux-loong64-gnu": "4.50.2", + "@rollup/rollup-linux-ppc64-gnu": "4.50.2", + "@rollup/rollup-linux-riscv64-gnu": "4.50.2", + "@rollup/rollup-linux-riscv64-musl": "4.50.2", + "@rollup/rollup-linux-s390x-gnu": "4.50.2", + "@rollup/rollup-linux-x64-gnu": "4.50.2", + "@rollup/rollup-linux-x64-musl": "4.50.2", + "@rollup/rollup-openharmony-arm64": "4.50.2", + "@rollup/rollup-win32-arm64-msvc": "4.50.2", + "@rollup/rollup-win32-ia32-msvc": "4.50.2", + "@rollup/rollup-win32-x64-msvc": "4.50.2", "fsevents": "~2.3.2" } }, @@ -5332,6 +5522,51 @@ "real-require": "^0.1.0" } }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmmirror.com/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -5400,9 +5635,10 @@ "integrity": "sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==" }, "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "license": "MIT" }, "node_modules/unenv": { "version": "1.10.0", @@ -5581,25 +5817,25 @@ } }, "node_modules/viem": { - "version": "2.21.45", - "resolved": "https://registry.npmmirror.com/viem/-/viem-2.21.45.tgz", - "integrity": "sha512-I+On/IiaObQdhDKWU5Rurh6nf3G7reVkAODG5ECIfjsrGQ3EPJnxirUPT4FNV6bWER5iphoG62/TidwuTSOA1A==", + "version": "2.31.3", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.31.3.tgz", + "integrity": "sha512-q3JGI5QFB4LEiLfg9f2ZwjUygAn2W0wMLtj++7E/L2i8Y7zKAkR4TEEOhwBn7gyYXpuc7f1vfd26PJbkEKuj5w==", "funding": [ { "type": "github", "url": "https://github.com/sponsors/wevm" } ], + "license": "MIT", "dependencies": { - "@noble/curves": "1.6.0", - "@noble/hashes": "1.5.0", - "@scure/bip32": "1.5.0", - "@scure/bip39": "1.4.0", - "abitype": "1.0.6", - "isows": "1.0.6", - "ox": "0.1.2", - "webauthn-p256": "0.0.10", - "ws": "8.18.0" + "@noble/curves": "1.9.2", + "@noble/hashes": "1.8.0", + "@scure/bip32": "1.7.0", + "@scure/bip39": "1.6.0", + "abitype": "1.0.8", + "isows": "1.0.7", + "ox": "0.8.1", + "ws": "8.18.2" }, "peerDependencies": { "typescript": ">=5.0.4" @@ -5611,19 +5847,23 @@ } }, "node_modules/vite": { - "version": "5.4.11", - "resolved": "https://registry.npmmirror.com/vite/-/vite-5.4.11.tgz", - "integrity": "sha512-c7jFQRklXua0mTzneGW9QVyxFjUgwcihC4bXEtujIo2ouWCe1Ajt/amn2PCxYnhYfd5k09JX3SB7OYWFKYqj8Q==", - "dependencies": { - "esbuild": "^0.21.3", - "postcss": "^8.4.43", - "rollup": "^4.20.0" + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.6.tgz", + "integrity": "sha512-SRYIB8t/isTwNn8vMB3MR6E+EQZM/WG1aKmmIUCfDXfVvKfc20ZpamngWHKzAmmu9ppsgxsg4b2I7c90JZudIQ==", + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" }, "bin": { "vite": "bin/vite.js" }, "engines": { - "node": "^18.0.0 || >=20.0.0" + "node": "^20.19.0 || >=22.12.0" }, "funding": { "url": "https://github.com/vitejs/vite?sponsor=1" @@ -5632,19 +5872,25 @@ "fsevents": "~2.3.3" }, "peerDependencies": { - "@types/node": "^18.0.0 || >=20.0.0", - "less": "*", + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", "lightningcss": "^1.21.0", - "sass": "*", - "sass-embedded": "*", - "stylus": "*", - "sugarss": "*", - "terser": "^5.4.0" + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" }, "peerDependenciesMeta": { "@types/node": { "optional": true }, + "jiti": { + "optional": true + }, "less": { "optional": true }, @@ -5665,6 +5911,12 @@ }, "terser": { "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true } } }, @@ -5696,26 +5948,40 @@ } } }, + "node_modules/vite/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/vscode-uri": { "version": "3.0.8", "resolved": "https://registry.npmmirror.com/vscode-uri/-/vscode-uri-3.0.8.tgz", "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==" }, - "node_modules/webauthn-p256": { - "version": "0.0.10", - "resolved": "https://registry.npmmirror.com/webauthn-p256/-/webauthn-p256-0.0.10.tgz", - "integrity": "sha512-EeYD+gmIT80YkSIDb2iWq0lq2zbHo1CxHlQTeJ+KkCILWpVy3zASH3ByD4bopzfk0uCwXxLqKGLqp2W4O28VFA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/wevm" - } - ], - "dependencies": { - "@noble/curves": "^1.4.0", - "@noble/hashes": "^1.4.0" - } - }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmmirror.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -5834,9 +6100,10 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, "node_modules/ws": { - "version": "8.18.0", - "resolved": "https://registry.npmmirror.com/ws/-/ws-8.18.0.tgz", - "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "version": "8.18.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.2.tgz", + "integrity": "sha512-DMricUmwGZUVr++AEAe2uiVM7UoO9MAVZMDu05UQOaUII0lp+zOzLLU4Xqh/JvTqklB1T4uELaaPBKyjE1r4fQ==", + "license": "MIT", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index 6103958..a45e0ac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codatta-connect", - "version": "2.1.6", + "version": "2.8.1", "type": "module", "main": "./dist/index.umd.js", "module": "./dist/index.es.js", @@ -10,10 +10,11 @@ "url": "git+https://github.com/codatta/codatta-connect.git" }, "scripts": { - "dev": "vite dev -c vite.config.dev.ts", + "dev": "vite dev -c vite.config.dev.ts --host", "build": "vite build -c vite.config.build.ts" }, "dependencies": { + "@binance/w3w-utils": "^1.1.6", "@coinbase/wallet-sdk": "^4.2.4", "@tonconnect/sdk": "^3.0.5", "@types/node": "^22.9.0", @@ -33,8 +34,8 @@ "react-dom": "^18.3.1", "tailwindcss": "^3.4.15", "valtio": "^2.1.2", - "viem": "^2.21.45", - "vite": "^5.4.11", + "viem": "^2.31.3", + "vite": "^7.1.6", "vite-plugin-dts": "^4.3.0" } } diff --git a/src/layout/app-layout.tsx b/src/layout/app-layout.tsx index ed264c0..c38f8a1 100644 --- a/src/layout/app-layout.tsx +++ b/src/layout/app-layout.tsx @@ -1,8 +1,31 @@ import React from 'react' import { CodattaConnectContextProvider } from '../../lib/main' +import { bsc, mainnet } from 'viem/chains' +import { defineChain } from 'viem' + +const BSC_CHAIN = defineChain({ + id: 56, + name: 'BNB Smart Chain Mainnet', + nativeCurrency: { + name: 'BNB', + symbol: 'BNB', + decimals: 18, + }, + rpcUrls: { + default: { + http: ['https://bsc-dataseed1.bnbchain.org'], + }, + }, + blockExplorers: { + default: { + name: 'BSCScan', + url: 'https://bscscan.com/', + }, + }, +}) export default function AppLayout(props: { children: React.ReactNode }) { - return + return
{props.children}
diff --git a/src/views/login-view.tsx b/src/views/login-view.tsx index 61a53d7..dd33696 100644 --- a/src/views/login-view.tsx +++ b/src/views/login-view.tsx @@ -1,21 +1,92 @@ -import { ILoginResponse } from '../../lib/api/account.api' -import { CodattaSignin} from '../../lib/main' -import React from 'react' +import { defineChain } from "viem"; +import accountApi, { ILoginResponse } from "../../lib/api/account.api"; +import { + EmvWalletConnectInfo, + TonWalletConnectInfo, +} from "../../lib/codatta-connect"; +import { CodattaSignin, CodattaConnect, useCodattaConnectContext } from "../../lib/main"; +import React, { useEffect } from "react"; + + export default function LoginView() { + const { lastUsedWallet } = useCodattaConnectContext(); + const userAgent = navigator.userAgent; + + useEffect(() => { + console.log(lastUsedWallet, 'lastUsedWallet change') + }, [lastUsedWallet]) + + async function handleLogin(res: ILoginResponse) { + localStorage.setItem("auth", res.token); + } + async function handleEmailConnect(email: string, code: string) { + const data = await accountApi.bindEmail({ + account_type: "email", + connector: "codatta_email", + account_enum: "C", + email_code: code, + email: email, + }); + } + + async function handleTonWalletConnect(info: TonWalletConnectInfo) { + const account = info.connect_info.account; + const connectItems = info.connect_info.connectItems; + + if (!connectItems?.tonProof) return; + + const data = await accountApi.bindTonWallet({ + account_type: "block_chain", + connector: "codatta_ton", + account_enum: "C", + chain: info.connect_info.account.chain, + wallet_name: info.connect_info.device.appName, + address: info.connect_info.account.address, + connect_info: [ + { name: "ton_addr", network: account.chain, ...account }, + connectItems.tonProof, + ], + }); + } - async function handleLogin(res:ILoginResponse) { - console.log('this is out component') - console.log(res) + async function handleEvmWalletConnect(info: EmvWalletConnectInfo) { + const data = await accountApi.bindEvmWallet({ + account_type: "block_chain", + connector: "codatta_wallet", + account_enum: "C", + chain: (await info.client.getChainId()).toString(), + address: (await info.client.getAddresses())[0], + signature: info.connect_info.signature, + nonce: info.connect_info.nonce, + wallet_name: info.connect_info.wallet_name, + message: info.connect_info.message, + }); + console.log(data); } return ( +
+ {/* heiheiha
} + > */} - ) -} \ No newline at end of file + channel:'test', + device:'WEB', + app:'test', + inviterCode:'', + role: 'B', + }}> + + ); +} diff --git a/vite.config.dev.ts b/vite.config.dev.ts index ea18308..2f55d4e 100644 --- a/vite.config.dev.ts +++ b/vite.config.dev.ts @@ -1,7 +1,30 @@ -import { defineConfig } from 'vite' +import { defineConfig, HttpProxy, ProxyOptions } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from "tailwindcss" import path from 'path' +import { ClientRequest, IncomingMessage, ServerResponse } from 'http' +import { debug } from 'console' + +function proxyDebug(proxy: HttpProxy.Server, _options: ProxyOptions) { + proxy.on( + 'error', + (err: Error, _req: IncomingMessage, _res: ServerResponse, _target?: HttpProxy.ProxyTargetUrl) => { + console.log('proxy error', err) + } + ) + proxy.on('proxyReq', (proxyReq: ClientRequest, req: IncomingMessage, _res: ServerResponse) => { + console.log( + '[Request]:', + req.method, + req.url, + ' => ', + `${proxyReq.method} ${proxyReq.protocol}//${proxyReq.host}${proxyReq.path}` + ) + }) + proxy.on('proxyRes', (proxyRes: IncomingMessage, req: IncomingMessage, _res: ServerResponse) => { + console.log('[Response]:', proxyRes.statusCode, req.url) + }) +} export default defineConfig({ resolve: { @@ -12,12 +35,14 @@ export default defineConfig({ build: { emptyOutDir: true, }, - server: { + host: "0.0.0.0", + allowedHosts:["1064wf31dw492.vicp.fun"], proxy: { '/api': { - target: 'http://app-test.b18a.io', + target: 'https://app-test.b18a.io', changeOrigin: true, + configure: proxyDebug, }, } },