graz 0.2.0-alpha.0 → 0.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/index.js +205 -76
- package/dist/index.mjs +133 -4
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import Sy from 'path';
|
|
1
3
|
import { create } from 'zustand';
|
|
2
4
|
import { createJSONStorage, subscribeWithSelector, persist } from 'zustand/middleware';
|
|
3
5
|
import { encodeEd25519Pubkey, encodeSecp256k1Pubkey, pubkeyType, rawEd25519PubkeyToRawAddress, rawSecp256k1PubkeyToRawAddress } from '@cosmjs/amino';
|
|
4
6
|
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
|
5
7
|
import { Cosmiframe, isInIframe } from '@dao-dao/cosmiframe';
|
|
6
8
|
import { isSnapInstalled, installSnap, CosmosSnap } from '@cosmsnap/snapper';
|
|
7
|
-
import
|
|
9
|
+
import Bm from 'long';
|
|
8
10
|
import { SignClient } from '@walletconnect/sign-client';
|
|
9
|
-
import { getSdkError } from '@walletconnect/utils';
|
|
11
|
+
import { getSdkError, generateRandomBytes32, generateKeyPair, deriveSymKey, hashKey, validateEncoding, isTypeTwoEnvelope, encodeTypeTwoEnvelope, isTypeOneEnvelope, encrypt, validateDecoding, decodeTypeTwoEnvelope, decrypt, deserialize, decodeTypeByte, BASE64, getInternalError, isNode, getBundleId, createExpiringPromise, isOnline, calcExpiry, formatRelayRpcUrl, subscribeToNetworkChange, TYPE_1, formatUri, parseUri, createDelayedPromise, engineEvent, isExpired, isValidParams, isValidUrl, isValidString, parseExpirerTarget, formatTopicTarget, formatIdTarget, isBrowser, verifyP256Jwt, isTestRun, uuidv4, formatUA, getAppMetadata, mapToObj, objToMap, BASE16, hashMessage, getRelayProtocolName, getRelayProtocolApi, isUndefined, isValidArray, isProposalStruct, isSessionStruct } from '@walletconnect/utils';
|
|
12
|
+
import yI, { EventEmitter } from 'events';
|
|
13
|
+
import { ICore, IRelayer, IJsonRpcHistory, IExpirer, IVerify, IEchoClient, IEventClient, IMessageTracker, IPublisher, ISubscriber, IStore } from '@walletconnect/types';
|
|
14
|
+
import ld from 'crypto';
|
|
10
15
|
import { WalletConnectModal } from '@walletconnect/modal';
|
|
11
16
|
import { useQuery, useMutation } from '@tanstack/react-query';
|
|
12
17
|
import { useMemo, useEffect, useState } from 'react';
|
|
@@ -16,6 +21,130 @@ import { Tendermint37Client, Tendermint34Client } from '@cosmjs/tendermint-rpc';
|
|
|
16
21
|
import { shallow } from 'zustand/shallow';
|
|
17
22
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
18
23
|
|
|
19
|
-
var Bt=Object.defineProperty,Lt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var ze=Object.getOwnPropertySymbols;var Ft=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable;var Qe=(e,t,i)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,v=(e,t)=>{for(var i in t||(t={}))Ft.call(t,i)&&Qe(e,i,t[i]);if(ze)for(var i of ze(t))qt.call(t,i)&&Qe(e,i,t[i]);return e},$=(e,t)=>Lt(e,Ut(t));var l=(e,t,i)=>new Promise((o,r)=>{var n=c=>{try{s(i.next(c));}catch(f){r(f);}},a=c=>{try{s(i.throw(c));}catch(f){r(f);}},s=c=>c.done?o(c.value):Promise.resolve(c.value).then(n,a);s((i=i.apply(e,t)).next());});var J="graz-reconnect-session";var je=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.CAPSULE="capsule",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var zt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ie={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Qt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},jt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},g=create(subscribeWithSelector(persist(()=>ie,Qt))),u=create(subscribeWithSelector(persist(()=>zt,jt)));var ce=()=>{var C,y;if(!((C=u.getState().capsuleConfig)!=null&&C.apiKey)||!((y=u.getState().capsuleConfig)!=null&&y.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var h,M;let m=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,S=new m({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(M=u.getState().capsuleConfig)==null?void 0:M.env});return g.setState({capsuleClient:S}),S});return {init:e,enable:m=>l(void 0,null,function*(){let S=typeof m=="string"?[m]:m,h=g.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:S}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var p;let m=g.getState().capsuleClient,{chains:S}=u.getState();if(!m)throw new Error("Capsule client is not initialized");if(!S)throw new Error("Chains are not set");yield m.enable();let h=(p=u.getState().capsuleState)==null?void 0:p.chainId;if(!h)throw new Error("Chain ids are not set");let M=Object.fromEntries(yield Promise.all(h.map(I=>l(void 0,null,function*(){let b=yield m.getAccount(I);return [I,{address:fromBech32(b.address).data,bech32Address:b.address,algo:b.algo,name:b.username||"",pubKey:b.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));g.setState(I=>({accounts:v(v({},I.accounts||{}),M)})),u.setState(I=>({recentChainIds:[...I.recentChainIds||[],...h].filter((b,W,D)=>D.indexOf(b)===W)})),g.setState(I=>({activeChainIds:[...I.activeChainIds||[],...h].filter((b,W,D)=>D.indexOf(b)===W)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(J,"Active"),u.setState({capsuleState:null});}),getKey:m=>l(void 0,null,function*(){let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let h=yield S.getAccount(m);return {address:fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:m=>l(void 0,null,function*(){let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(m)}),getOfflineSignerDirect:m=>{let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(m)},signDirect:(...m)=>l(void 0,null,function*(){let[S,h,M]=m,p=g.getState().capsuleClient;if(!p)throw new Error("Capsule client is not initialized");return p.signDirect(S,h,{bodyBytes:M.bodyBytes,authInfoBytes:M.authInfoBytes,chainId:M.chainId,accountNumber:M.accountNumber})}),signAmino:(...m)=>l(void 0,null,function*(){let[S,h,M,p]=m,I=g.getState().capsuleClient;if(!I)throw new Error("Capsule client is not initialized");return I.signAmino(S,h,M,p)}),signArbitrary:(m,S,h)=>l(void 0,null,function*(){let M=g.getState().capsuleClient;if(!M)throw new Error("Capsule client is not initialized");let p=yield M.getAccount(m);if(!p)throw new Error(`Wallet not connected to account ${S}`);let I=(()=>{switch(p.algo){case"secp256k1":return encodeSecp256k1Pubkey(p.pubkey);case"ed25519":return encodeEd25519Pubkey(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield M.signArbitrary(m,S,h),pub_key:{type:p.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:I.value}}}),experimentalSuggestChain:(...m)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:m=>{let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSigner(m)},getOfflineSignerAmino:m=>{let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerAmino(m)}}};var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var w;let n=yield e.request({method:"web3_clientVersion"});if(!n.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let s=(w=n.split("MetaMask/v")[1])==null?void 0:w.split(".")[0];if(!(Number(s)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:n=>l(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:n=>t.getOfflineSigner(n),experimentalSuggestChain:n=>l(void 0,null,function*(){if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain($(v({},n),{stakeCurrency:n.stakeCurrency,bech32Config:n.bech32Config}));}),signAmino:(n,a,s)=>l(void 0,null,function*(){return t.signAmino(n,a,s)}),getKey:n=>l(void 0,null,function*(){return typeof tt[n]!="undefined"?tt[n]:t.getKey(n)}),getOfflineSignerAuto:n=>l(void 0,null,function*(){return (yield t.getKey(n)).isNanoLedger?t.getOfflineSignerOnlyAmino(n):t.getOfflineSigner(n)}),getOfflineSignerOnlyAmino:n=>t.getOfflineSignerOnlyAmino(n),signDirect:(n,a,s)=>l(void 0,null,function*(){return t.signDirect(n,a,s)}),signArbitrary:(n,a,s)=>l(void 0,null,function*(){return t.signArbitrary(n,a,s)}),disable:n=>l(void 0,null,function*(){n&&(yield t.deleteChain(n));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:n=>{let a=()=>{B(),n();};return window.addEventListener("cosmostation_keystorechange",a),()=>{window.removeEventListener("cosmostation_keystorechange",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var nn=e=>{let{bodyBytes:t,authInfoBytes:i,chainId:o,accountNumber:r}=e;if(!t||!i||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:i,chainId:o,accountNumber:r}},on=e=>`${e.slice(0,6)}...${e.slice(-6)}`,ot=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let C=e.getOfflineSigner(d),[y]=yield C.getAccounts();if(!y)throw new Error("Wallet connection failed");let m=(()=>{switch(y.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(y.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:on(y.address),algo:y.algo,pubKey:y.pubkey,bech32Address:y.address,address:m,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:d=>{let C=e.getOfflineSigner(d),y=e.getOfflineSignerOnlyAmino(d);return {getAccounts:C.getAccounts.bind(C),signDirect:C.signDirect.bind(C),signAmino:y.signAmino.bind(y)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(C=>{var y,m,S;return {denom:C.coinDenom,amount:C.coinMinimalDenom,low_gas_price:(y=C.gasPriceStep)==null?void 0:y.low,average_gas_price:(m=C.gasPriceStep)==null?void 0:m.average,high_gas_price:(S=C.gasPriceStep)==null?void 0:S.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[C,y,m]=d;return e.getOfflineSigner(C).signDirect(y,nn(m))},signAmino:(...d)=>{let[C,y,m]=d;return e.getOfflineSignerOnlyAmino(C).signAmino(y,m)},signArbitrary:(d,C,y)=>l(void 0,null,function*(){let h=(yield e.getOfflineSigner(d).getAccounts()).find(I=>I.address===C);if(!h)throw new Error(`Wallet not connected to account ${C}`);let M=(()=>{switch(h.algo){case"secp256k1":return encodeSecp256k1Pubkey(h.pubkey);case"ed25519":return encodeEd25519Pubkey(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(y),pub_key:{type:h.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:M.value}}}),subscription:d=>{let C=()=>{B(),d();};return window.addEventListener("initia_keystorechange",C),()=>{window.removeEventListener("initia_keystorechange",C);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var me=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},rt=e=>{let t=window.ethereum;if(t&&e){let i=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=p=>l(void 0,null,function*(){try{let I=yield i();return Object.values(I).find(b=>b.id===e.id&&(!p||b.version===p))}catch(I){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),n=()=>l(void 0,null,function*(){var N;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(N=p.split("MetaMask/v")[1])==null?void 0:N.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),a=p=>l(void 0,null,function*(){(yield o())||(yield r());}),s=(p,I,b)=>l(void 0,null,function*(){let W=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:I,signDoc:b}}}}),D=b.accountNumber,N=new lt(D.low,D.high,D.unsigned);return {signature:W.signature,signed:$(v({},W.signed),{accountNumber:`${N.toString()}`,authInfoBytes:new Uint8Array(Object.values(W.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(W.signed.bodyBytes))})}}),c=(p,I,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:I,signDoc:b}}}})}),f=p=>l(void 0,null,function*(){if(typeof fe[p]!="undefined")return fe[p];let I=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!I)throw new Error("No response from Metamask");return I.pubKey=Uint8Array.from(Object.values(I.pubkey)),delete I.pubkey,fe[p]=I,fe[p]}),w=p=>l(void 0,null,function*(){let I=yield f(p);return {address:I.bech32Address,algo:I.algo,pubkey:I.pubKey}}),d=(...p)=>l(void 0,null,function*(){let[I,b,W,D]=p;return yield c(I,b,W)}),C=(...p)=>l(void 0,null,function*(){let[I,b,W]=p;return yield s(I,b,W)}),m=p=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(p)]}),signAmino:(I,b)=>d(p,I,b)});return {enable:a,experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield n(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:f,getOfflineSigner:p=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(p)]}),signDirect:(I,b)=>C(p,I,b),signAmino:(I,b)=>d(p,I,b)}),getOfflineSignerAuto:p=>l(void 0,null,function*(){return m(p)}),getOfflineSignerOnlyAmino:m,init:n,signAmino:d,signDirect:C}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var st=()=>rt({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:n=>{var s;let a=()=>{B(),n();};return (s=window.okxwallet)==null||s.on("accountsChanged",a),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var ye=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:n=>{let a=()=>{B(),n();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:n=>l(void 0,null,function*(){let a=yield e.getKey(n);return v({isKeystone:!1},a)}),getOfflineSigner:n=>{try{let a=e.getOfflineSignerOnlyAmino(n);return Object.assign(a,{signDirect:(f,w)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:n=>l(void 0,null,function*(){try{if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");let a=Object.assign(n,{bech32Config:n.bech32Config,chainSymbolImageUrl:n.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:n.stakeCurrency.coinDecimals,coinDenom:n.stakeCurrency.coinDenom,coinImageUrl:n.stakeCurrency.coinImageUrl||"",coinMinimalDenom:n.stakeCurrency.coinMinimalDenom},currencies:n.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:n.feeCurrencies.map(s=>{var c,f,w;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((f=s.gasPriceStep)==null?void 0:f.high)||0,low:((w=s.gasPriceStep)==null?void 0:w.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:n=>e.enable(n),disable:n=>e.disable(n),getOfflineSignerAuto:n=>e.getOfflineSignerAuto(n),getOfflineSignerOnlyAmino:n=>e.getOfflineSignerOnlyAmino(n),signDirect:()=>e.signDirect(),signAmino:(n,a,s,c)=>e.signAmino(n,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Se=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:s=>e.enable(s),getOfflineSigner:s=>e.getOfflineSigner(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{B(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>{let c=s[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...s)=>l(void 0,null,function*(){var w;let[c]=s;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(w=c.bech32Config)==null?void 0:w.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...s)=>l(void 0,null,function*(){var w;let{1:c,2:f}=s;return e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:lt.fromString(((w=f.accountNumber)==null?void 0:w.toString())||"",!1),chainId:f.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:f}=s;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},at=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var ke=(e,t,i=new Error("Promise timed out"))=>{let o=new Promise((r,n)=>{setTimeout(()=>{n(i);},t);});return Promise.race([e,o])};var Q=e=>{var N,te,oe;if(!((oe=(te=(N=u.getState().walletConnect)==null?void 0:N.options)==null?void 0:te.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",i=(e==null?void 0:e.encoding)||"base64",o=A=>{if(!e)return;let{appUrl:O,formatNativeUrl:E}=e;if(z()){if(at()){let k=E(O.mobile.android,A,"android");window.open(k,"_self","noreferrer noopener");}if(ct()){let k=E(O.mobile.ios,A,"ios");window.open(k,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:A}=g.getState();if(!A.get(t))throw new Error("walletConnect.signClient is not defined");A.delete(t),g.setState({wcSignClients:A}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},n=A=>l(void 0,null,function*(){let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");if(!A)throw new Error("No wallet connect session");yield E.disconnect({topic:A,reason:getSdkError("USER_DISCONNECTED")}),yield c(E);}),a=A=>{try{let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let k=E.session.getAll(),R=k.at(-1);if(!R)return;if(!(R.expiry*1e3>Date.now()+1e3))throw n(R.topic),new Error("invalid session");try{let _=k.find(j=>{var X,Y;return (Y=(X=j.requiredNamespaces.cosmos)==null?void 0:X.chains)==null?void 0:Y.includes(`cosmos:${A}`)});if(!_)throw new Error("no session");return _}catch(_){if(!_.message.toLowerCase().includes("no matching key"))throw _}return R}catch(O){if(!O.message.toLowerCase().includes("no matching key"))throw O}},s=A=>{try{return a(A)}catch(O){return}},c=A=>l(void 0,null,function*(){try{let O=A.core.pairing.pairings.getAll({active:!1});if(!O.length)return;yield Promise.all(O.map(E=>l(void 0,null,function*(){yield A.core.pairing.pairings.delete(E.topic,{code:7001,message:"clear pairing"});})));}catch(O){if(!O.message.toLowerCase().includes("no matching key"))throw O}}),f=()=>l(void 0,null,function*(){let{walletConnect:A}=u.getState();if(!(A!=null&&A.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:O}=g.getState(),E=O.get(t);if(E)return E;let k=yield SignClient.init(A.options);return O.set(t,k),g.setState({wcSignClients:O}),k}),w=A=>{let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)return ()=>{};let k=R=>{let P=g.getState().accounts;if(R.params.event.name==="accountsChanged"&&P&&!Object.values(P).map(_=>_.bech32Address).includes(R.params.event.data[0])){let _=R.params.chainId.split(":")[1];_&&d([_]);}else A();};return E.events.on("session_delete",r),E.events.on("session_expire",r),E.events.on("session_event",k),()=>{E.events.off("session_delete",r),E.events.off("session_expire",r),E.events.off("session_event",k);}},d=A=>l(void 0,null,function*(){var Y;let O=typeof A=="string"?[A]:A,{wcSignClients:E,activeChainIds:k}=g.getState(),R=E.get(t);if(!R)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:_}=u.getState();if(!((Y=P==null?void 0:P.options)!=null&&Y.projectId))throw new Error("walletConnect.options.projectId is not defined");let j=new WalletConnectModal(v({projectId:P.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.walletConnectModal)),X=s(O);if(!X){let{uri:q,approval:se}=yield ke(R.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:O.map(V=>`cosmos:${V}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!q)throw new Error("No wallet connect uri");e?o(q):yield j.openModal({uri:q});let ae=V=>l(void 0,null,function*(){return V.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((xe,ne)=>{se().then(Fe=>{let qe=Fe.sessionProperties;if(!qe)return ne(new Error("No session properties"));let Me=JSON.parse(String(qe.keys));if(Me.length===0)return ne(new Error("No accounts"));if(!Me[0])return ne(new Error("No accounts"));let Ge={};return Me.forEach(H=>{Ge[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),g.setState(H=>({accounts:v(v({},H.accounts||{}),Ge)})),xe(Fe)}).catch(ne),V.addEventListener("abort",()=>{ne(new Error("User closed wallet connect"));},{once:!0});})});try{let V=new AbortController,xe=V.signal;j.subscribeModal(ne=>{ne.open||V.abort();}),yield ae(xe);}catch(V){if(j.closeModal(),!V.message.toLowerCase().includes("no matching key"))return Promise.reject(V)}return e||j.closeModal(),Promise.resolve()}try{yield ke((()=>l(void 0,null,function*(){var se;let q=Object.fromEntries(yield Promise.all((se=k||O)==null?void 0:se.map(ae=>l(void 0,null,function*(){return [ae,yield y(ae)]}))));g.setState({accounts:q});}))(),15e3,new Error("Connection timeout"));}catch(q){if(n(X.topic),!q.message.toLowerCase().includes("no matching key"))throw q}}),C=A=>l(void 0,null,function*(){let O=yield y(A);return {address:O.bech32Address,algo:O.algo,pubkey:O.pubKey}}),y=A=>l(void 0,null,function*(){let O=a([A]);if(!(O!=null&&O.topic))throw new Error("No wallet connect session");let E=O.sessionProperties&&JSON.parse(String(O.sessionProperties.keys));if(!E)throw new Error("No wallet connect key");if(E.length===0)throw new Error("No wallet connect session");let k=E.find(R=>R.chainId===A);if(!k)throw new Error(`No wallet connect key for chainId ${A}`);return $(v({},k),{pubKey:Buffer.from(String(k.pubKey),i)})}),m=(...A)=>l(void 0,null,function*(){var Y,q;let[O,E,k]=A,{accounts:R,wcSignClients:P}=g.getState(),_=P.get(t);if(!_)throw new Error("walletConnect.signClient is not defined");if(!R)throw new Error("account is not defined");let j=(Y=a([O]))==null?void 0:Y.topic;if(!j)throw new Error("No wallet connect session");if(!k.bodyBytes)throw new Error("No bodyBytes");if(!k.authInfoBytes)throw new Error("No authInfoBytes");return o(),yield _.request({topic:j,chainId:`cosmos:${O}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:{chainId:k.chainId,accountNumber:(q=k.accountNumber)==null?void 0:q.toString(),bodyBytes:k.bodyBytes?Buffer.from(k.bodyBytes).toString(i):null,authInfoBytes:k.authInfoBytes?Buffer.from(k.authInfoBytes).toString(i):null}}}})}),S=(...A)=>l(void 0,null,function*(){var _;let[O,E,k]=A,{signature:R,signed:P}=yield m(O,E,k);return {signed:{chainId:(_=P.chainId)!=null?_:"",accountNumber:P.accountNumber?lt.fromString(P.accountNumber):new lt(0),authInfoBytes:P.authInfoBytes?new Uint8Array(Buffer.from(P.authInfoBytes,i)):new Uint8Array([]),bodyBytes:P.bodyBytes?new Uint8Array(Buffer.from(P.bodyBytes,i)):new Uint8Array([])},signature:R}}),h=(...A)=>l(void 0,null,function*(){var q;let[O,E,k,R]=A,{wcSignClients:P}=g.getState(),_=P.get(t),{accounts:j}=g.getState();if(!_)throw new Error("walletConnect.signClient is not defined");if(!j)throw new Error("account is not defined");let X=(q=a([O]))==null?void 0:q.topic;if(!X)throw new Error("No wallet connect session");return o(),yield _.request({topic:X,chainId:`cosmos:${O}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:k}}})}),M=(...A)=>l(void 0,null,function*(){let[O,E,k,R]=A;return yield h(O,E,k)}),p=A=>({getAccounts:()=>l(void 0,null,function*(){return [yield C(A)]}),signDirect:(O,E)=>S(A,O,E)}),I=A=>({getAccounts:()=>l(void 0,null,function*(){return [yield C(A)]}),signAmino:(O,E)=>M(A,O,E)});return {enable:d,disable:A=>l(void 0,null,function*(){var k;let{wcSignClients:O}=g.getState(),E=O.get(t);if(A===void 0){let R=E==null?void 0:E.session.getAll();R!==void 0&&(yield Promise.all(R.map(P=>n(P.topic))));}else typeof A=="string"?yield n((k=a([A]))==null?void 0:k.topic):yield Promise.all(A.map(R=>{var P;return n((P=a([R]))==null?void 0:P.topic)}));(E==null?void 0:E.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...A)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:y,getOfflineSigner:A=>({getAccounts:()=>l(void 0,null,function*(){return [yield C(A)]}),signDirect:(O,E)=>S(A,O,E),signAmino:(O,E)=>M(A,O,E)}),getOfflineSignerAuto:A=>l(void 0,null,function*(){return (yield y(A)).isNanoLedger?I(A):p(A)}),getOfflineSignerOnlyAmino:I,signAmino:M,signDirect:S,subscription:w,init:f}};var ut=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return Q(e)};var pt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,n,a)=>{let s=r.replaceAll("/","").replaceAll(":","");return n?`${s}://wc?${n}`:`${s}://wc`}};return Q(e)};var mt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${s}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return Q(e)};var dt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${s}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return Q(e)};var Ce=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let n=()=>{B(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var L=(e=u.getState().walletType)=>{try{return K(e),!0}catch(t){return !1}},B=()=>{window.sessionStorage.removeItem(J),g.setState(ie);},K=(e=u.getState().walletType)=>{var o;let t=(()=>{switch(e){case"keplr":return me();case"leap":return de();case"cosmostation":return pe();case"vectis":return Se();case"walletconnect":return Q();case"wc_keplr_mobile":return mt();case"wc_leap_mobile":return dt();case"wc_cosmostation_mobile":return pt();case"wc_clot_mobile":return ut();case"metamask_snap_leap":return st();case"metamask_snap_cosmos":return nt();case"station":return ye();case"xdefi":return Ce();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();case"initia":return ot();case"okx":return ge();default:throw new Error("Unknown wallet type")}})(),i=u.getState().walletDefaultOptions;return i&&((o=t.setDefaultOptions)==null||o.call(t,i)),t},tr=()=>Object.fromEntries($e.map(e=>[e,L(e)])),ve=e=>e==="capsule",Pe=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Z=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:i,chains:o,walletType:r}=u.getState(),n=(e==null?void 0:e.walletType)||r;if(!L(n))throw new Error(`${n} is not available`);let s=K(n),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||i;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let f=o==null?void 0:o.map(y=>y.chainId);c.forEach(y=>{if(!(f!=null&&f.includes(y)))throw new Error(`Chain ${y} is not provided in GrazProvider`)}),g.setState(y=>{let m=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return y.activeChainIds&&c.filter(h=>{var M;return !((M=y.activeChainIds)!=null&&M.includes(h))}).length>0?{status:"connecting"}:m?{status:"reconnecting"}:{status:"connecting"}});let{accounts:w}=g.getState();if(yield (t=s.init)==null?void 0:t.call(s),ve(n)&&g.getState().capsuleClient&&Object.values(g.getState().accounts||[]).length>0){let y=c.map(h=>o.find(M=>M.chainId===h)),m=g.getState().accounts;g.setState({status:"connecting"});let S=Object.fromEntries(yield Promise.all(c.map(h=>l(void 0,null,function*(){return [h,yield s.getKey(h)]}))));return g.setState(h=>({accounts:v(v({},h.accounts||{}),S)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...c].filter((M,p,I)=>I.indexOf(M)===p)})),g.setState(h=>({activeChainIds:[...h.activeChainIds||[],...c].filter((M,p,I)=>I.indexOf(M)===p)})),g.setState({status:"connected"}),{accounts:m,walletType:n,chains:y}}if(yield s.enable(c),ve(n)){let y=c.map(S=>o.find(h=>h.chainId===S)),m=g.getState().accounts;return g.setState({status:"connecting"}),{accounts:m,walletType:n,chains:y}}if(!Pe(n)){let y=Object.fromEntries(yield Promise.all(c.map(m=>l(void 0,null,function*(){return [m,yield s.getKey(m)]}))));g.setState(m=>({accounts:v(v({},m.accounts||{}),y)}));}u.setState(y=>({recentChainIds:[...y.recentChainIds||[],...c].filter((m,S,h)=>h.indexOf(m)===S)})),g.setState(y=>({activeChainIds:[...y.activeChainIds||[],...c].filter((m,S,h)=>h.indexOf(m)===S)})),u.setState({walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(J,"Active");let d=c.map(y=>o.find(m=>m.chainId===y));return {accounts:g.getState().accounts,walletType:n,chains:d}}catch(i){throw console.error("connect ",i),g.getState().accounts===null&&g.setState({status:"disconnected"}),g.getState().accounts&&g.getState().activeChainIds&&g.setState({status:"connected"}),i}}),re=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(J);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let i=g.getState().accounts;t.forEach(r=>{i==null||delete i[r];}),Object.values(i||{}).length===0?(g.setState(ie),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(g.setState(r=>{var n;return {activeChainIds:(n=r.activeChainIds)==null?void 0:n.filter(a=>!t.includes(a)),accounts:i}}),u.setState(r=>{var n;return {recentChainIds:(n=r.recentChainIds)==null?void 0:n.filter(a=>!t.includes(a))}}));}else g.setState(ie),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},U=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:i,_reconnect:o}=u.getState();try{let n=L(i||void 0);if(t&&n&&i)return Pe(i)?void 0:yield Z({chainId:t,walletType:i,autoReconnect:o})}catch(n){(r=e==null?void 0:e.onError)==null||r.call(e,n),re();}}),ft=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),i=e.walletType||t;if(!L(i))throw new Error(`${i} is not available`);let r=K(i),n=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:n,offlineSignerAmino:a,offlineSignerAuto:s}});var We=()=>{u.setState({recentChainIds:null});},dr=()=>u.getState().recentChainIds,fr=()=>{var i;let{recentChainIds:e,chains:t}=u.getState();return (i=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?i:null},gr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(i=>i.chainId===e)},yr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},Re=i=>l(void 0,[i],function*({chainInfo:e,walletType:t}){let o=K(t);return t==="capsule"?yield Z({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),gt=e=>l(void 0,null,function*(){var o;let t=u.getState().walletType;return yield Re({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield Z({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var yt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var St=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:i,amount:o,fee:r,memo:n}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,i,o,r,n)}),Ct=w=>l(void 0,[w],function*({signingClient:e,senderAddress:t,recipientAddress:i,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,i,o,r,n,a,s,c,f)}),ht=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:o,options:r,label:n,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,i,n,o,r)}),wt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:o,contractAddress:r,funds:n,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,i,o,a,n)}),At=(e,t,i)=>l(void 0,null,function*(){if(!i)throw new Error("CosmWasm client is not ready");return yield i.queryContractSmart(e,t)}),It=(e,t,i)=>{if(!i)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return i.queryContractRaw(e,o)};var Tr=e=>e,xr=e=>e;var he=e=>e?Object.keys(e).length===0:!0;var Ke=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ot=e=>globalThis.DOMException===void 0?new Ke(e):new DOMException(e),Et=e=>{let t=e.reason===void 0?Ot("This operation was aborted."):e.reason;return t instanceof Error?t:Ot(t)};function De(n,a){return l(this,arguments,function*(e,t,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((s,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`);let f=[],w=[],d=new Map,C=!1,y=!1,m=!1,S=0,h=0,M=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=b=>{C=!0,y=!0,c(b);};r&&(r.aborted&&p(Et(r)),r.addEventListener("abort",()=>{p(Et(r));}));let I=()=>l(this,null,function*(){if(y)return;let b=yield M.next(),W=h;if(h++,b.done){if(m=!0,S===0&&!y){if(!o&&w.length>0){p(new AggregateError(w));return}if(y=!0,d.size===0){s(f);return}let D=[];for(let[N,te]of f.entries())d.get(N)!==bt&&D.push(te);s(D);}return}S++,l(this,null,function*(){try{let D=yield b.value;if(y)return;let N=yield t(D,W);N===bt&&d.set(W,N),f[W]=N,S--,yield I();}catch(D){if(o)p(D);else {w.push(D),S--;try{yield I();}catch(N){p(N);}}}});});l(this,null,function*(){for(let b=0;b<i;b++){try{yield I();}catch(W){p(W);break}if(m||C)break}});})})}var bt=Symbol("skip");var F=({chainId:e,multiChain:t})=>{let i=u(r=>r.chains);if(!i)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>i.find(n=>n.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>i.find(n=>n.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return i;default:return [i[0]]}},G=(e,t,i)=>l(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let n=yield De(t,i,{concurrency:o});return Object.fromEntries(n.map((a,s)=>[t[s].chainId,a]))}return yield i(t[0])}),Tt=(e,t,i)=>{if(e){let r=t.map(i);return Object.fromEntries(r.map((n,a)=>[t[a].chainId,n]))}return i(t[0])};var Be=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:i,queryFn:r=>l(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,a=>l(void 0,null,function*(){var w;let s=(w=u.getState().chainsConfig)==null?void 0:w[a.chainId],c={url:a.rpc,headers:v({},(s==null?void 0:s.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Le=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:i,queryFn:r=>l(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,a=>l(void 0,null,function*(){var w;let s=(w=u.getState().chainsConfig)==null?void 0:w[a.chainId],c={url:a.rpc,headers:v({},(s==null?void 0:s.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},we=({type:e,chainId:t,multiChain:i,enabled:o})=>{let r=F({chainId:t,multiChain:i}),n=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:n,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield G(!!i,s,w=>l(void 0,null,function*(){var S;let d=(S=u.getState().chainsConfig)==null?void 0:S[w.chainId],C={url:w.rpc,headers:v({},(d==null?void 0:d.rpcHeaders)||{})};return yield (a==="tm37"?Tendermint37Client:Tendermint34Client).connect(C)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var es=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow),Ae=e=>{let i=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery({queryKey:i,queryFn:({queryKey:[,r]})=>L(r)})};var ee=e=>{let t=u(s=>s.walletType),i=g(s=>s.activeChainIds),o=F({chainId:e!=null&&e.chainId?e.chainId:i||void 0,multiChain:e==null?void 0:e.multiChain}),r=g(s=>s.accounts),n=g(s=>s.status);return useEffect(()=>g.subscribe(s=>s.status,(s,c)=>{var f,w,d;if(s==="connected"){let{accounts:C,activeChainIds:y}=g.getState(),{chains:m}=u.getState(),{walletType:S}=u.getState();if(!C||!y||!m)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(w=e==null?void 0:e.onConnect)==null||w.call(e,{accounts:C,chains:y.map(h=>m.find(M=>M.chainId===h)),walletType:S,isReconnect:c==="reconnecting"});}s==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:useMemo(()=>r?Tt(!!(e!=null&&e.multiChain),o,s=>r[s.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:n==="connected",isConnecting:n==="connecting",isDisconnected:n==="disconnected",isReconnecting:n==="reconnecting",isLoading:n==="connecting"||n==="reconnecting",walletType:n==="connected"?t:void 0,reconnect:U,status:n}},Cn=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=ee(),o=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),{data:r}=Be({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),n=useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return useQuery({queryKey:n,queryFn:f=>l(void 0,[f],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var m;let C=a==null?void 0:a[d.chainId];if(!C)throw new Error(`Client is not ready ${d.chainId}`);if(!((m=d.bech32Config)!=null&&m.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield C.getAllBalances(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!o&&!!t&&t.length>0&&!he(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ds=e=>{let t=F({chainId:e.chainId}),{data:i}=ee({chainId:e.chainId}),o=e.bech32Address||(i==null?void 0:i.bech32Address),{data:r,refetch:n}=Cn({chainId:t.map(c=>c.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,o,e.chainId],s=useQuery({queryKey:a,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(w=>w.denom===c),enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return $(v({},s),{refetch:c=>l(void 0,null,function*(){return yield n(),s.refetch(c)})})},fs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation({mutationKey:["USE_CONNECT",e,t,i],mutationFn:Z,onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=Ae();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status}},gs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation({mutationKey:["USE_DISCONNECT",e,t,i],mutationFn:re,onError:n=>Promise.resolve(e==null?void 0:e(n,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(i==null?void 0:i(void 0))});return {disconnect:n=>r.mutate(n),disconnectAsync:n=>r.mutateAsync(n),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,status:r.status}},ys=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(r=>r.walletType),o=useMemo(()=>["USE_OFFLINE_SIGNERS",t,i],[t,i]);return useQuery({queryKey:o,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,n]}){if(r.length<1)throw new Error("No chain found");if(!L(n))throw new Error(`${n} is not available`);return yield G(!!(e!=null&&e.multiChain),r,f=>l(void 0,null,function*(){return yield ft({chainId:f.chainId,walletType:n})}))}),enabled:!!t&&t.length>0&&!!i,refetchOnWindowFocus:!1})},Ss=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=ee(),{data:o}=Be({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),n=useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return useQuery({queryKey:n,queryFn:f=>l(void 0,[f],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var y,m;if(!a)throw new Error("Client is not ready");if(!((y=d.bech32Config)!=null&&y.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (m=a[d.chainId])==null?void 0:m.getBalanceStaked(toBech32(d.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Es=()=>{let e=u(o=>o.capsuleState),t=g(o=>o.capsuleClient),i=ce();return {setModalState:o=>{u.setState(r=>{var n;return {capsuleState:{showModal:o,chainId:(n=r.capsuleState)==null?void 0:n.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:i.onAfterLoginSuccessful,onLoginFailure:()=>{re();}}};var Ps=()=>g(e=>e.activeChainIds),hn=()=>{var e;return (e=g(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let i=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(i)return i}).filter(Boolean)},Ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(i=>i.chainId===e)},Rs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},Ks=({denom:e})=>{let t=hn();return useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,r]})=>{var n;return (n=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:n.currencies.find(a=>a)}})},Ds=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",i=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery({queryKey:i,queryFn:s=>l(void 0,[s],function*({queryKey:[,n,a]}){if(!n)throw new Error("Query client is not defined");return yield n.staking.validators(a)}),enabled:typeof e.queryClient!="undefined"})},_s=()=>({data:u(t=>t.recentChainIds),clear:We}),Ns=()=>{var t;return {data:(t=u(i=>i.recentChainIds))==null?void 0:t.map(i=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(n=>n.chainId===i);if(o)return o}).filter(Boolean),clear:We}},Bs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,i],mutationFn:Re,onError:(n,a)=>Promise.resolve(e==null?void 0:e(n,a.chainInfo)),onMutate:n=>t==null?void 0:t(n.chainInfo),onSuccess:n=>Promise.resolve(i==null?void 0:i(n))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Ls=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,i],mutationFn:gt,onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=Ae();return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var $s=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:o}=ee(),r=o==null?void 0:o.bech32Address,n=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,i,r],mutationFn:a=>St(v({senderAddress:r},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendTokens:n.mutate,sendTokensAsync:n.mutateAsync,status:n.status}},Vs=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:o}=ee(),r=o==null?void 0:o.bech32Address,n=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,i,r],mutationFn:a=>Ct(v({senderAddress:r},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendIbcTokens:n.mutate,sendIbcTokensAsync:n.mutateAsync,status:n.status}},Hs=({codeId:e,onError:t,onLoading:i,onSuccess:o})=>{let{data:r}=ee(),n=r==null?void 0:r.bech32Address,s=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,i,o,e,n],mutationFn:c=>{var w;if(!n)throw new Error("senderAddress is undefined");let f=$(v({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:n,codeId:e});return ht(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:i,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Xs=({contractAddress:e,onError:t,onLoading:i,onSuccess:o})=>{let{data:r}=ee(),n=r==null?void 0:r.bech32Address,s=useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,i,o,e,n],mutationFn:c=>{var w,d,C;if(!n)throw new Error("senderAddress is undefined");let f=$(v({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:n,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(C=c.funds)!=null?C:[]});return wt(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:i,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Ys=e=>{let{data:t}=Le();return useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return At(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Js=e=>{let{data:t}=Le(),i=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:i,queryFn:({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return It(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function pa(e){let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(n=>n.walletType),o=g(n=>n.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),n,f=>l(this,null,function*(){var S,h;if(!(o!=null&&o.includes(f.chainId)))return null;if(!L(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return K(a).getOfflineSigner(f.chainId);case"offlineSignerAuto":return K(a).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return K(a).getOfflineSignerOnlyAmino(f.chainId);default:return K(a).getOfflineSignerAuto(f.chainId)}}))(),C=(S=u.getState().chainsConfig)==null?void 0:S[f.chainId],y={url:f.rpc,headers:v({},(C==null?void 0:C.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(y,d,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[f.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ma(e){let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(n=>n.walletType),o=g(n=>n.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]);return useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),n,f=>l(this,null,function*(){var h,M;if(!(o!=null&&o.includes(f.chainId)))return null;if(!L(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return K(a).getOfflineSigner(f.chainId);case"offlineSignerAuto":return K(a).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return K(a).getOfflineSignerOnlyAmino(f.chainId);default:return K(a).getOfflineSignerAuto(f.chainId)}}))(),C=(h=u.getState().chainsConfig)==null?void 0:h[f.chainId],y={url:f.rpc,headers:v({},(C==null?void 0:C.rpcHeaders)||{})},m=C!=null&&C.gas?GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(y,d,v({gasPrice:m},e!=null&&e.multiChain?(M=e.opts)==null?void 0:M[f.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function da(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),i=u(a=>a.walletType),o=g(a=>a.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]),{data:n}=we({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,w=>l(this,null,function*(){var S;if(!(o!=null&&o.includes(w.chainId)))return null;if(!L(s))throw new Error(`${s} is not available`);if(!n)throw new Error("No tendermint client found");let C=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return K(s).getOfflineSigner(w.chainId);case"offlineSignerAuto":return K(s).getOfflineSignerAuto(w.chainId);case"offlineSignerOnlyAmino":return K(s).getOfflineSignerOnlyAmino(w.chainId);default:return K(s).getOfflineSignerAuto(w.chainId)}}))(),y=e.multiChain?n[w.chainId]:n;return yield SigningStargateClient.createWithSigner(y,C,e.multiChain?(S=e.opts)==null?void 0:S[w.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&!!n&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function fa(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),i=u(s=>s.walletType),o=g(s=>s.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]),{data:n}=we({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=we({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:f=>l(this,[f],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,d=>l(this,null,function*(){var p,I;if(!(o!=null&&o.includes(d.chainId)))return null;if(!L(c))throw new Error(`${c} is not available`);let y=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return K(c).getOfflineSigner(d.chainId);case"offlineSignerAuto":return K(c).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return K(c).getOfflineSignerOnlyAmino(d.chainId);default:return K(c).getOfflineSignerAuto(d.chainId)}}))(),m=(p=u.getState().chainsConfig)==null?void 0:p[d.chainId],S=m!=null&&m.gas?GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0,h=e.multiChain?a==null?void 0:a[d.chainId]:n;if(!h)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(h,y,v({gasPrice:S},e.multiChain?(I=e.opts)==null?void 0:I[d.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!i&&(!!n||!he(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var _t=({children:e})=>{let[t,i]=useState(!1);return useEffect(()=>{i(!0);},[]),jsx(Fragment,{children:t?e:null})};var bn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(J)==="Active",{_reconnect:t,_onReconnectFailed:i,_reconnectConnector:o,iframeOptions:r,chains:n}=u(),{activeChainIds:a,wcSignClients:s}=g(),c=L(o||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!n)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(w=>{if(w)return Z({chainId:n.map(d=>d.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(o){if(!c)return;e&&a?U({onError:i}):!e&&t&&U({onError:i});}},[c]),useEffect(()=>{var f,w,d,C,y,m,S,h,M,p,I,b,W,D,N,te,oe,A,O,E;if(o){if(!c)return;o==="cosmostation"&&((w=(f=pe()).subscription)==null||w.call(f,()=>{U({onError:i});})),o==="keplr"&&((C=(d=me()).subscription)==null||C.call(d,()=>{U({onError:i});})),o==="leap"&&((m=(y=de()).subscription)==null||m.call(y,()=>{U({onError:i});})),o==="compass"&&((h=(S=le()).subscription)==null||h.call(S,()=>{U({onError:i});})),o==="vectis"&&((p=(M=Se()).subscription)==null||p.call(M,()=>{U({onError:i});})),o==="walletconnect"&&s.has("walletconnect")&&((b=(I=Q()).subscription)==null||b.call(I,()=>{U({onError:i});})),o==="station"&&((D=(W=ye()).subscription)==null||D.call(W,()=>{U({onError:i});})),o==="xdefi"&&((te=(N=Ce()).subscription)==null||te.call(N,()=>{U({onError:i});})),o==="cosmiframe"&&((A=(oe=ue()).subscription)==null||A.call(oe,()=>{U({onError:i});})),o==="okx"&&((E=(O=ge()).subscription)==null||E.call(O,()=>{U({onError:i});}));}},[o,s,c]),null},Nt=()=>(bn(),null);var za=({children:e,grazOptions:t})=>(useEffect(()=>{yt(t);},[t]),jsxs(_t,{children:[e,jsx(Nt,{})]}));
|
|
24
|
+
var hy=Object.create;var Ar=Object.defineProperty,dy=Object.defineProperties,py=Object.getOwnPropertyDescriptor,gy=Object.getOwnPropertyDescriptors,my=Object.getOwnPropertyNames,gl=Object.getOwnPropertySymbols,yy=Object.getPrototypeOf,yl=Object.prototype.hasOwnProperty,wy=Object.prototype.propertyIsEnumerable;var ml=(e,t,r)=>t in e?Ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,F=(e,t)=>{for(var r in t||(t={}))yl.call(t,r)&&ml(e,r,t[r]);if(gl)for(var r of gl(t))wy.call(t,r)&&ml(e,r,t[r]);return e},Q=(e,t)=>dy(e,gy(t));var $=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var wl=(e,t)=>()=>(e&&(t=e(e=0)),t);var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Oe=(e,t)=>{for(var r in t)Ar(e,r,{get:t[r],enumerable:!0});},Cn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of my(t))!yl.call(e,i)&&i!==r&&Ar(e,i,{get:()=>t[i],enumerable:!(n=py(t,i))||n.enumerable});return e},Te=(e,t,r)=>(Cn(e,t,"default"),r&&Cn(r,t,"default")),Ye=(e,t,r)=>(r=e!=null?hy(yy(e)):{},Cn(t||!e||!e.__esModule?Ar(r,"default",{value:e,enumerable:!0}):r,e)),Or=e=>Cn(Ar({},"__esModule",{value:!0}),e);var g=(e,t,r)=>new Promise((n,i)=>{var s=c=>{try{a(r.next(c));}catch(h){i(h);}},o=c=>{try{a(r.throw(c));}catch(h){i(h);}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,o);a((r=r.apply(e,t)).next());});var vy,_y,Ey,E,d=wl(()=>{vy={},_y=()=>fileURLToPath(vy.url),Ey=()=>Sy.dirname(_y()),E=Ey();});var Zt={};Oe(Zt,{__assign:()=>ms,__asyncDelegator:()=>ew,__asyncGenerator:()=>Zy,__asyncValues:()=>tw,__await:()=>Tr,__awaiter:()=>Vy,__classPrivateFieldGet:()=>sw,__classPrivateFieldSet:()=>ow,__createBinding:()=>Jy,__decorate:()=>$y,__exportStar:()=>Yy,__extends:()=>jy,__generator:()=>Hy,__importDefault:()=>iw,__importStar:()=>nw,__makeTemplateObject:()=>rw,__metadata:()=>Gy,__param:()=>qy,__read:()=>Ll,__rest:()=>zy,__spread:()=>Xy,__spreadArrays:()=>Qy,__values:()=>ys});function jy(e,t){gs(e,t);function r(){this.constructor=e;}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r);}function zy(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function $y(e,t,r,n){var i=arguments.length,s=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s}function qy(e,t){return function(r,n){t(r,n,e);}}function Gy(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Vy(e,t,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(l){try{h(n.next(l));}catch(f){o(f);}}function c(l){try{h(n.throw(l));}catch(f){o(f);}}function h(l){l.done?s(l.value):i(l.value).then(a,c);}h((n=n.apply(e,t||[])).next());})}function Hy(e,t){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(h){return function(l){return c([h,l])}}function c(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=t.call(e,r);}catch(l){h=[6,l],i=0;}finally{n=s=0;}if(h[0]&5)throw h[1];return {value:h[0]?h[1]:void 0,done:!0}}}function Jy(e,t,r,n){n===void 0&&(n=r),e[n]=t[r];}function Yy(e,t){for(var r in e)r!=="default"&&!t.hasOwnProperty(r)&&(t[r]=e[r]);}function ys(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ll(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,s=[],o;try{for(;(t===void 0||t-- >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 Xy(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ll(arguments[t]));return e}function Qy(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),i=0,t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function Tr(e){return this instanceof Tr?(this.v=e,this):new Tr(e)}function Zy(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(m){n[m]&&(i[m]=function(p){return new Promise(function(u,y){s.push([m,p,u,y])>1||a(m,p);})});}function a(m,p){try{c(n[m](p));}catch(u){f(s[0][3],u);}}function c(m){m.value instanceof Tr?Promise.resolve(m.value.v).then(h,l):f(s[0][2],m);}function h(m){a("next",m);}function l(m){a("throw",m);}function f(m,p){m(p),s.shift(),s.length&&a(s[0][0],s[0][1]);}}function ew(e){var t,r;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=e[i]?function(o){return (r=!r)?{value:Tr(e[i](o)),done:i==="return"}:s?s(o):o}:s;}}function tw(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof ys=="function"?ys(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=e[s]&&function(o){return new Promise(function(a,c){o=e[s](o),i(a,c,o.done,o.value);})};}function i(s,o,a,c){Promise.resolve(c).then(function(h){s({value:h,done:a});},o);}}function rw(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function nw(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function iw(e){return e&&e.__esModule?e:{default:e}}function sw(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function ow(e,t,r){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,r),r}var gs,ms,er=wl(()=>{d();gs=function(e,t){return gs=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]);},gs(e,t)};ms=function(){return ms=Object.assign||function(t){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)&&(t[s]=r[s]);}return t},ms.apply(this,arguments)};});var Ml=k(Fn=>{d();Object.defineProperty(Fn,"__esModule",{value:!0});Fn.delay=void 0;function aw(e){return new Promise(t=>{setTimeout(()=>{t(!0);},e);})}Fn.delay=aw;});var Fl=k(tr=>{d();Object.defineProperty(tr,"__esModule",{value:!0});tr.ONE_THOUSAND=tr.ONE_HUNDRED=void 0;tr.ONE_HUNDRED=100;tr.ONE_THOUSAND=1e3;});var Bl=k(W=>{d();Object.defineProperty(W,"__esModule",{value:!0});W.ONE_YEAR=W.FOUR_WEEKS=W.THREE_WEEKS=W.TWO_WEEKS=W.ONE_WEEK=W.THIRTY_DAYS=W.SEVEN_DAYS=W.FIVE_DAYS=W.THREE_DAYS=W.ONE_DAY=W.TWENTY_FOUR_HOURS=W.TWELVE_HOURS=W.SIX_HOURS=W.THREE_HOURS=W.ONE_HOUR=W.SIXTY_MINUTES=W.THIRTY_MINUTES=W.TEN_MINUTES=W.FIVE_MINUTES=W.ONE_MINUTE=W.SIXTY_SECONDS=W.THIRTY_SECONDS=W.TEN_SECONDS=W.FIVE_SECONDS=W.ONE_SECOND=void 0;W.ONE_SECOND=1;W.FIVE_SECONDS=5;W.TEN_SECONDS=10;W.THIRTY_SECONDS=30;W.SIXTY_SECONDS=60;W.ONE_MINUTE=W.SIXTY_SECONDS;W.FIVE_MINUTES=W.ONE_MINUTE*5;W.TEN_MINUTES=W.ONE_MINUTE*10;W.THIRTY_MINUTES=W.ONE_MINUTE*30;W.SIXTY_MINUTES=W.ONE_MINUTE*60;W.ONE_HOUR=W.SIXTY_MINUTES;W.THREE_HOURS=W.ONE_HOUR*3;W.SIX_HOURS=W.ONE_HOUR*6;W.TWELVE_HOURS=W.ONE_HOUR*12;W.TWENTY_FOUR_HOURS=W.ONE_HOUR*24;W.ONE_DAY=W.TWENTY_FOUR_HOURS;W.THREE_DAYS=W.ONE_DAY*3;W.FIVE_DAYS=W.ONE_DAY*5;W.SEVEN_DAYS=W.ONE_DAY*7;W.THIRTY_DAYS=W.ONE_DAY*30;W.ONE_WEEK=W.SEVEN_DAYS;W.TWO_WEEKS=W.ONE_WEEK*2;W.THREE_WEEKS=W.ONE_WEEK*3;W.FOUR_WEEKS=W.ONE_WEEK*4;W.ONE_YEAR=W.ONE_DAY*365;});var ws=k(Bn=>{d();Object.defineProperty(Bn,"__esModule",{value:!0});var kl=(er(),Or(Zt));kl.__exportStar(Fl(),Bn);kl.__exportStar(Bl(),Bn);});var Wl=k(rr=>{d();Object.defineProperty(rr,"__esModule",{value:!0});rr.fromMiliseconds=rr.toMiliseconds=void 0;var Ul=ws();function cw(e){return e*Ul.ONE_THOUSAND}rr.toMiliseconds=cw;function lw(e){return Math.floor(e/Ul.ONE_THOUSAND)}rr.fromMiliseconds=lw;});var jl=k(kn=>{d();Object.defineProperty(kn,"__esModule",{value:!0});var Kl=(er(),Or(Zt));Kl.__exportStar(Ml(),kn);Kl.__exportStar(Wl(),kn);});var zl=k(Rr=>{d();Object.defineProperty(Rr,"__esModule",{value:!0});Rr.Watch=void 0;var Un=class{constructor(){this.timestamps=new Map;}start(t){if(this.timestamps.has(t))throw new Error(`Watch already started for label: ${t}`);this.timestamps.set(t,{started:Date.now()});}stop(t){let r=this.get(t);if(typeof r.elapsed!="undefined")throw new Error(`Watch already stopped for label: ${t}`);let n=Date.now()-r.started;this.timestamps.set(t,{started:r.started,elapsed:n});}get(t){let r=this.timestamps.get(t);if(typeof r=="undefined")throw new Error(`No timestamp found for label: ${t}`);return r}elapsed(t){let r=this.get(t);return r.elapsed||Date.now()-r.started}};Rr.Watch=Un;Rr.default=Un;});var $l=k(Wn=>{d();Object.defineProperty(Wn,"__esModule",{value:!0});Wn.IWatch=void 0;var bs=class{};Wn.IWatch=bs;});var ql=k(Ss=>{d();Object.defineProperty(Ss,"__esModule",{value:!0});var uw=(er(),Or(Zt));uw.__exportStar($l(),Ss);});var jn=k(nr=>{d();Object.defineProperty(nr,"__esModule",{value:!0});var Kn=(er(),Or(Zt));Kn.__exportStar(jl(),nr);Kn.__exportStar(zl(),nr);Kn.__exportStar(ql(),nr);Kn.__exportStar(ws(),nr);});var cu=k((a2,au)=>{d();au.exports=ou;var{toString:Nw}=Object.prototype,Os=Symbol("circular-ref-tag"),Ts=Symbol("pino-raw-err-ref"),su=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[Ts]},set:function(e){this[Ts]=e;}}});Object.defineProperty(su,Ts,{writable:!0,value:{}});function ou(e){if(!(e instanceof Error))return e;e[Os]=void 0;let t=Object.create(su);t.type=Nw.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,t.message=e.message,t.stack=e.stack;for(let r in e)if(t[r]===void 0){let n=e[r];n instanceof Error?n.hasOwnProperty(Os)||(t[r]=ou(n)):t[r]=n;}return delete e[Os],t.raw=e,t}});var hu=k((l2,fu)=>{d();fu.exports={mapHttpRequest:Lw,reqSerializer:uu};var Rs=Symbol("pino-raw-req-ref"),lu=Object.create({},{id:{enumerable:!0,writable:!0,value:""},method:{enumerable:!0,writable:!0,value:""},url:{enumerable:!0,writable:!0,value:""},query:{enumerable:!0,writable:!0,value:""},params:{enumerable:!0,writable:!0,value:""},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:""},remotePort:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[Rs]},set:function(e){this[Rs]=e;}}});Object.defineProperty(lu,Rs,{writable:!0,value:{}});function uu(e){let t=e.info||e.socket,r=Object.create(lu);return r.id=typeof e.id=="function"?e.id():e.id||(e.info?e.info.id:void 0),r.method=e.method,e.originalUrl?(r.url=e.originalUrl,r.query=e.query,r.params=e.params):r.url=e.path||(e.url?e.url.path||e.url:void 0),r.headers=e.headers,r.remoteAddress=t&&t.remoteAddress,r.remotePort=t&&t.remotePort,r.raw=e.raw||e,r}function Lw(e){return {req:uu(e)}}});var mu=k((f2,gu)=>{d();gu.exports={mapHttpResponse:Mw,resSerializer:pu};var Ps=Symbol("pino-raw-res-ref"),du=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[Ps]},set:function(e){this[Ps]=e;}}});Object.defineProperty(du,Ps,{writable:!0,value:{}});function pu(e){let t=Object.create(du);return t.statusCode=e.statusCode,t.headers=e.getHeaders?e.getHeaders():e._headers,t.raw=e,t}function Mw(e){return {res:pu(e)}}});var Ls=k((d2,yu)=>{d();var Ns=cu(),Hn=hu(),Jn=mu();yu.exports={err:Ns,mapHttpRequest:Hn.mapHttpRequest,mapHttpResponse:Jn.mapHttpResponse,req:Hn.reqSerializer,res:Jn.resSerializer,wrapErrorSerializer:function(t){return t===Ns?t:function(n){return t(Ns(n))}},wrapRequestSerializer:function(t){return t===Hn.reqSerializer?t:function(n){return t(Hn.reqSerializer(n))}},wrapResponseSerializer:function(t){return t===Jn.resSerializer?t:function(n){return t(Jn.resSerializer(n))}}};});var Ms=k((g2,wu)=>{d();function Fw(e,t){return t}wu.exports=function(){let t=Error.prepareStackTrace;Error.prepareStackTrace=Fw;let r=new Error().stack;if(Error.prepareStackTrace=t,!Array.isArray(r))return;let n=r.slice(2),i=[];for(let s of n)s&&i.push(s.getFileName());return i};});var Su=k((y2,bu)=>{d();bu.exports=Bw;function Bw(e={}){let{ERR_PATHS_MUST_BE_STRINGS:t=()=>"fast-redact - Paths must be (non-empty) strings",ERR_INVALID_PATH:r=n=>`fast-redact \u2013 Invalid path (${n})`}=e;return function({paths:i}){i.forEach(s=>{if(typeof s!="string")throw Error(t());try{if(/〇/.test(s))throw Error();let o=(s[0]==="["?"":".")+s.replace(/^\*/,"\u3007").replace(/\.\*/g,".\u3007").replace(/\[\*\]/g,"[\u3007]");if(/\n|\r|;/.test(o)||/\/\*/.test(o))throw Error();Function(`
|
|
25
|
+
'use strict'
|
|
26
|
+
const o = new Proxy({}, { get: () => o, set: () => { throw Error() } });
|
|
27
|
+
const \u3007 = null;
|
|
28
|
+
o${o}
|
|
29
|
+
if ([o${o}].length !== 1) throw Error()`)();}catch(o){throw Error(r(s))}});}}});var Yn=k((b2,_u)=>{d();_u.exports=/[^.[\]]+|\[((?:.)*?)\]/g;});var vu=k((_2,Eu)=>{d();var kw=Yn();Eu.exports=Uw;function Uw({paths:e}){let t=[];var r=0;let n=e.reduce(function(i,s,o){var a=s.match(kw).map(l=>l.replace(/'|"|`/g,""));let c=s[0]==="[";a=a.map(l=>l[0]==="["?l.substr(1,l.length-2):l);let h=a.indexOf("*");if(h>-1){let l=a.slice(0,h),f=l.join("."),m=a.slice(h+1,a.length),p=m.length>0;r++,t.push({before:l,beforeStr:f,after:m,nested:p});}else i[s]={path:a,val:void 0,precensored:!1,circle:"",escPath:JSON.stringify(s),leadingBracket:c};return i},{});return {wildcards:t,wcLen:r,secret:n}}});var Cu=k((v2,xu)=>{d();var Ww=Yn();xu.exports=Kw;function Kw({secret:e,serialize:t,wcLen:r,strict:n,isCensorFct:i,censorFctTakesPath:s},o){let a=Function("o",`
|
|
30
|
+
if (typeof o !== 'object' || o == null) {
|
|
31
|
+
${qw(n,t)}
|
|
32
|
+
}
|
|
33
|
+
const { censor, secret } = this
|
|
34
|
+
const originalSecret = {}
|
|
35
|
+
const secretKeys = Object.keys(secret)
|
|
36
|
+
for (var i = 0; i < secretKeys.length; i++) {
|
|
37
|
+
originalSecret[secretKeys[i]] = secret[secretKeys[i]]
|
|
38
|
+
}
|
|
20
39
|
|
|
21
|
-
|
|
40
|
+
${jw(e,i,s)}
|
|
41
|
+
this.compileRestore()
|
|
42
|
+
${zw(r>0,i,s)}
|
|
43
|
+
this.secret = originalSecret
|
|
44
|
+
${$w(t)}
|
|
45
|
+
`).bind(o);return a.state=o,t===!1&&(a.restore=c=>o.restore(c)),a}function jw(e,t,r){return Object.keys(e).map(n=>{let{escPath:i,leadingBracket:s,path:o}=e[n],a=s?1:0,c=s?"":".",h=[];for(var l;(l=Ww.exec(n))!==null;){let[,u]=l,{index:y,input:w}=l;y>a&&h.push(w.substring(0,y-(u?0:1)));}var f=h.map(u=>`o${c}${u}`).join(" && ");f.length===0?f+=`o${c}${n} != null`:f+=` && o${c}${n} != null`;let m=`
|
|
46
|
+
switch (true) {
|
|
47
|
+
${h.reverse().map(u=>`
|
|
48
|
+
case o${c}${u} === censor:
|
|
49
|
+
secret[${i}].circle = ${JSON.stringify(u)}
|
|
50
|
+
break
|
|
51
|
+
`).join(`
|
|
52
|
+
`)}
|
|
53
|
+
}
|
|
54
|
+
`,p=r?`val, ${JSON.stringify(o)}`:"val";return `
|
|
55
|
+
if (${f}) {
|
|
56
|
+
const val = o${c}${n}
|
|
57
|
+
if (val === censor) {
|
|
58
|
+
secret[${i}].precensored = true
|
|
59
|
+
} else {
|
|
60
|
+
secret[${i}].val = val
|
|
61
|
+
o${c}${n} = ${t?`censor(${p})`:"censor"}
|
|
62
|
+
${m}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`}).join(`
|
|
66
|
+
`)}function zw(e,t,r){return e===!0?`
|
|
67
|
+
{
|
|
68
|
+
const { wildcards, wcLen, groupRedact, nestedRedact } = this
|
|
69
|
+
for (var i = 0; i < wcLen; i++) {
|
|
70
|
+
const { before, beforeStr, after, nested } = wildcards[i]
|
|
71
|
+
if (nested === true) {
|
|
72
|
+
secret[beforeStr] = secret[beforeStr] || []
|
|
73
|
+
nestedRedact(secret[beforeStr], o, before, after, censor, ${t}, ${r})
|
|
74
|
+
} else secret[beforeStr] = groupRedact(o, before, censor, ${t}, ${r})
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`:""}function $w(e){return e===!1?"return o":`
|
|
78
|
+
var s = this.serialize(o)
|
|
79
|
+
this.restore(o)
|
|
80
|
+
return s
|
|
81
|
+
`}function qw(e,t){return e===!0?"throw Error('fast-redact: primitives cannot be redacted')":t===!1?"return o":"return this.serialize(o)"}});var Bs=k((C2,Au)=>{d();Au.exports={groupRedact:Vw,groupRestore:Gw,nestedRedact:Jw,nestedRestore:Hw};function Gw({keys:e,values:t,target:r}){if(r==null||typeof r=="string")return;let n=e.length;for(var i=0;i<n;i++){let s=e[i];r[s]=t[i];}}function Vw(e,t,r,n,i){let s=Iu(e,t);if(s==null||typeof s=="string")return {keys:null,values:null,target:s,flat:!0};let o=Object.keys(s),a=o.length,c=t.length,h=i?[...t]:void 0,l=new Array(a);for(var f=0;f<a;f++){let m=o[f];l[f]=s[m],i?(h[c]=m,s[m]=r(s[m],h)):n?s[m]=r(s[m]):s[m]=r;}return {keys:o,values:l,target:s,flat:!0}}function Hw(e){for(let t=0;t<e.length;t++){let{target:r,path:n,value:i}=e[t],s=r;for(let o=n.length-1;o>0;o--)s=s[n[o]];s[n[0]]=i;}}function Jw(e,t,r,n,i,s,o){let a=Iu(t,r);if(a==null)return;let c=Object.keys(a),h=c.length;for(var l=0;l<h;l++){let f=c[l];Yw(e,a,f,r,n,i,s,o);}return e}function Fs(e,t){return e!=null?"hasOwn"in Object?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t):!1}function Yw(e,t,r,n,i,s,o,a){let c=i.length,h=c-1,l=r;var f=-1,m,p,u,w=null,S,b,_=!1,C=0,T=0,M=Xw();if(u=m=t[r],typeof m=="object"){for(;m!=null&&++f<c&&(T+=1,r=i[f],!(r!=="*"&&!w&&!(typeof m=="object"&&r in m)));)if(!(r==="*"&&(w==="*"&&(_=!0),w=r,f!==h))){if(w){let I=Object.keys(m);for(var v=0;v<I.length;v++){let B=I[v];if(b=m[B],S=r==="*",_)M=lt(M,B,T),C=f,u=Du(b,C-1,r,n,i,s,o,a,l,m,p,u,S,B,f,h,M,e,t[l],T+1);else if(S||typeof b=="object"&&b!==null&&r in b){if(S?u=b:u=b[r],p=f!==h?u:o?a?s(u,[...n,l,...i]):s(u):s,S){let R=Fr(lt(M,B,T),u,t[l]);e.push(R),m[B]=p;}else if(b[r]!==p)if(p===void 0&&s!==void 0||Fs(b,r)&&p===u)M=lt(M,B,T);else {M=lt(M,B,T);let R=Fr(lt(M,r,T+1),u,t[l]);e.push(R),b[r]=p;}}}w=null;}else {if(u=m[r],M=lt(M,r,T),p=f!==h?u:o?a?s(u,[...n,l,...i]):s(u):s,!(Fs(m,r)&&p===u||p===void 0&&s!==void 0)){let I=Fr(M,u,t[l]);e.push(I),m[r]=p;}m=m[r];}if(typeof m!="object")break}}}function Iu(e,t){for(var r=-1,n=t.length,i=e;i!=null&&++r<n;)i=i[t[r]];return i}function Du(e,t,r,n,i,s,o,a,c,h,l,f,m,p,u,y,w,S,b,_){if(t===0&&(m||typeof e=="object"&&e!==null&&r in e)){if(m?f=e:f=e[r],l=u!==y?f:o?a?s(f,[...n,c,...i]):s(f):s,m){let C=Fr(w,f,b);S.push(C),h[p]=l;}else if(e[r]!==l){if(!(l===void 0&&s!==void 0||Fs(e,r)&&l===f)){let C=Fr(lt(w,r,_+1),f,b);S.push(C),e[r]=l;}}}for(let C in e)typeof e[C]=="object"&&(w=lt(w,C,_),Du(e[C],t-1,r,n,i,s,o,a,c,h,l,f,m,p,u,y,w,S,b,_+1));}function Xw(){return {parent:null,key:null,children:[],depth:0}}function lt(e,t,r){if(e.depth===r)return lt(e.parent,t,r);var n={parent:e,key:t,depth:r,children:[]};return e.children.push(n),n}function Fr(e,t,r){let n=e,i=[];do i.push(n.key),n=n.parent;while(n.parent!=null);return {path:i,value:t,target:r}}});var Tu=k((D2,Ou)=>{d();var{groupRestore:Qw,nestedRestore:Zw}=Bs();Ou.exports=eb;function eb(){return function(){if(this.restore){this.restore.state.secret=this.secret;return}let{secret:t,wcLen:r}=this,n=Object.keys(t),i=tb(t,n),s=r>0,o=s?{secret:t,groupRestore:Qw,nestedRestore:Zw}:{secret:t};this.restore=Function("o",rb(i,n,s)).bind(o),this.restore.state=o;}}function tb(e,t){return t.map(r=>{let{circle:n,escPath:i,leadingBracket:s}=e[r],a=n?`o.${n} = secret[${i}].val`:`o${s?"":"."}${r} = secret[${i}].val`,c=`secret[${i}].val = undefined`;return `
|
|
82
|
+
if (secret[${i}].val !== undefined) {
|
|
83
|
+
try { ${a} } catch (e) {}
|
|
84
|
+
${c}
|
|
85
|
+
}
|
|
86
|
+
`}).join("")}function rb(e,t,r){return `
|
|
87
|
+
const secret = this.secret
|
|
88
|
+
${r===!0?`
|
|
89
|
+
const keys = Object.keys(secret)
|
|
90
|
+
const len = keys.length
|
|
91
|
+
for (var i = len - 1; i >= ${t.length}; i--) {
|
|
92
|
+
const k = keys[i]
|
|
93
|
+
const o = secret[k]
|
|
94
|
+
if (o) {
|
|
95
|
+
if (o.flat === true) this.groupRestore(o)
|
|
96
|
+
else this.nestedRestore(o)
|
|
97
|
+
secret[k] = null
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`:""}
|
|
101
|
+
${e}
|
|
102
|
+
return o
|
|
103
|
+
`}});var Pu=k((O2,Ru)=>{d();Ru.exports=nb;function nb(e){let{secret:t,censor:r,compileRestore:n,serialize:i,groupRedact:s,nestedRedact:o,wildcards:a,wcLen:c}=e,h=[{secret:t,censor:r,compileRestore:n}];return i!==!1&&h.push({serialize:i}),c>0&&h.push({groupRedact:s,nestedRedact:o,wildcards:a,wcLen:c}),Object.assign(...h)}});var Mu=k((R2,Lu)=>{d();var Nu=Su(),ib=vu(),sb=Cu(),ob=Tu(),{groupRedact:ab,nestedRedact:cb}=Bs(),lb=Pu(),ub=Yn(),fb=Nu(),ks=e=>e;ks.restore=ks;var hb="[REDACTED]";Us.rx=ub;Us.validator=Nu;Lu.exports=Us;function Us(e={}){let t=Array.from(new Set(e.paths||[])),r="serialize"in e&&(e.serialize===!1||typeof e.serialize=="function")?e.serialize:JSON.stringify,n=e.remove;if(n===!0&&r!==JSON.stringify)throw Error("fast-redact \u2013 remove option may only be set when serializer is JSON.stringify");let i=n===!0?void 0:"censor"in e?e.censor:hb,s=typeof i=="function",o=s&&i.length>1;if(t.length===0)return r||ks;fb({paths:t,serialize:r,censor:i});let{wildcards:a,wcLen:c,secret:h}=ib({paths:t,censor:i}),l=ob(),f="strict"in e?e.strict:!0;return sb({secret:h,wcLen:c,serialize:r,strict:f,isCensorFct:s,censorFctTakesPath:o},lb({secret:h,censor:i,compileRestore:l,serialize:r,groupRedact:ab,nestedRedact:cb,wildcards:a,wcLen:c}))}});var ir=k((N2,Fu)=>{d();var db=Symbol("pino.setLevel"),pb=Symbol("pino.getLevel"),gb=Symbol("pino.levelVal"),mb=Symbol("pino.useLevelLabels"),yb=Symbol("pino.useOnlyCustomLevels"),wb=Symbol("pino.mixin"),bb=Symbol("pino.lsCache"),Sb=Symbol("pino.chindings"),_b=Symbol("pino.parsedChindings"),Eb=Symbol("pino.asJson"),vb=Symbol("pino.write"),xb=Symbol("pino.redactFmt"),Cb=Symbol("pino.time"),Ib=Symbol("pino.timeSliceIndex"),Db=Symbol("pino.stream"),Ab=Symbol("pino.stringify"),Ob=Symbol("pino.stringifySafe"),Tb=Symbol("pino.stringifiers"),Rb=Symbol("pino.end"),Pb=Symbol("pino.formatOpts"),Nb=Symbol("pino.messageKey"),Lb=Symbol("pino.nestedKey"),Mb=Symbol("pino.nestedKeyStr"),Fb=Symbol("pino.mixinMergeStrategy"),Bb=Symbol("pino.wildcardFirst"),kb=Symbol.for("pino.serializers"),Ub=Symbol.for("pino.formatters"),Wb=Symbol.for("pino.hooks"),Kb=Symbol.for("pino.metadata");Fu.exports={setLevelSym:db,getLevelSym:pb,levelValSym:gb,useLevelLabelsSym:mb,mixinSym:wb,lsCacheSym:bb,chindingsSym:Sb,parsedChindingsSym:_b,asJsonSym:Eb,writeSym:vb,serializersSym:kb,redactFmtSym:xb,timeSym:Cb,timeSliceIndexSym:Ib,streamSym:Db,stringifySym:Ab,stringifySafeSym:Ob,stringifiersSym:Tb,endSym:Rb,formatOptsSym:Pb,messageKeySym:Nb,nestedKeySym:Lb,wildcardFirstSym:Bb,needsMetadataGsym:Kb,useOnlyCustomLevelsSym:yb,formattersSym:Ub,hooksSym:Wb,nestedKeyStrSym:Mb,mixinMergeStrategySym:Fb};});var js=k((M2,Wu)=>{d();var Ks=Mu(),{redactFmtSym:jb,wildcardFirstSym:Xn}=ir(),{rx:Ws,validator:zb}=Ks,Bu=zb({ERR_PATHS_MUST_BE_STRINGS:()=>"pino \u2013 redacted paths must be strings",ERR_INVALID_PATH:e=>`pino \u2013 redact paths array contains an invalid path (${e})`}),ku="[Redacted]",Uu=!1;function $b(e,t){let{paths:r,censor:n}=qb(e),i=r.reduce((a,c)=>{Ws.lastIndex=0;let h=Ws.exec(c),l=Ws.exec(c),f=h[1]!==void 0?h[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,"$1"):h[0];if(f==="*"&&(f=Xn),l===null)return a[f]=null,a;if(a[f]===null)return a;let{index:m}=l,p=`${c.substr(m,c.length-1)}`;return a[f]=a[f]||[],f!==Xn&&a[f].length===0&&a[f].push(...a[Xn]||[]),f===Xn&&Object.keys(a).forEach(function(u){a[u]&&a[u].push(p);}),a[f].push(p),a},{}),s={[jb]:Ks({paths:r,censor:n,serialize:t,strict:Uu})},o=(...a)=>t(typeof n=="function"?n(...a):n);return [...Object.keys(i),...Object.getOwnPropertySymbols(i)].reduce((a,c)=>{if(i[c]===null)a[c]=h=>o(h,[c]);else {let h=typeof n=="function"?(l,f)=>n(l,[c,...f]):n;a[c]=Ks({paths:i[c],censor:h,serialize:t,strict:Uu});}return a},s)}function qb(e){if(Array.isArray(e))return e={paths:e,censor:ku},Bu(e),e;let{paths:t,censor:r=ku,remove:n}=e;if(Array.isArray(t)===!1)throw Error("pino \u2013 redact must contain an array of strings");return n===!0&&(r=void 0),Bu({paths:t,censor:r}),{paths:t,censor:r}}Wu.exports=$b;});var ju=k((B2,Ku)=>{d();var Gb=()=>"",Vb=()=>`,"time":${Date.now()}`,Hb=()=>`,"time":${Math.round(Date.now()/1e3)}`,Jb=()=>`,"time":"${new Date(Date.now()).toISOString()}"`;Ku.exports={nullTime:Gb,epochTime:Vb,unixTime:Hb,isoTime:Jb};});var $u=k((U2,zu)=>{d();function Yb(e){try{return JSON.stringify(e)}catch(t){return '"[Circular]"'}}zu.exports=Xb;function Xb(e,t,r){var n=r&&r.stringify||Yb,i=1;if(typeof e=="object"&&e!==null){var s=t.length+i;if(s===1)return e;var o=new Array(s);o[0]=n(e);for(var a=1;a<s;a++)o[a]=n(t[a]);return o.join(" ")}if(typeof e!="string")return e;var c=t.length;if(c===0)return e;for(var h="",l=1-i,f=-1,m=e&&e.length||0,p=0;p<m;){if(e.charCodeAt(p)===37&&p+1<m){switch(f=f>-1?f:0,e.charCodeAt(p+1)){case 100:case 102:if(l>=c||t[l]==null)break;f<p&&(h+=e.slice(f,p)),h+=Number(t[l]),f=p+2,p++;break;case 105:if(l>=c||t[l]==null)break;f<p&&(h+=e.slice(f,p)),h+=Math.floor(Number(t[l])),f=p+2,p++;break;case 79:case 111:case 106:if(l>=c||t[l]===void 0)break;f<p&&(h+=e.slice(f,p));var u=typeof t[l];if(u==="string"){h+="'"+t[l]+"'",f=p+2,p++;break}if(u==="function"){h+=t[l].name||"<anonymous>",f=p+2,p++;break}h+=n(t[l]),f=p+2,p++;break;case 115:if(l>=c)break;f<p&&(h+=e.slice(f,p)),h+=String(t[l]),f=p+2,p++;break;case 37:f<p&&(h+=e.slice(f,p)),h+="%",f=p+2,p++,l--;break}++l;}++p;}return f===-1?e:(f<m&&(h+=e.slice(f)),h)}});var $s=k((K2,zs)=>{d();if(typeof SharedArrayBuffer!="undefined"&&typeof Atomics!="undefined"){let t=function(r){if((r>0&&r<1/0)===!1)throw typeof r!="number"&&typeof r!="bigint"?TypeError("sleep: ms must be a number"):RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");Atomics.wait(e,0,0,Number(r));},e=new Int32Array(new SharedArrayBuffer(4));zs.exports=t;}else {let e=function(t){if((t>0&&t<1/0)===!1)throw typeof t!="number"&&typeof t!="bigint"?TypeError("sleep: ms must be a number"):RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");};zs.exports=e;}});var Ju=k((z2,Hu)=>{d();var Ue=$("fs"),Qb=$("events"),Zb=$("util").inherits,qu=$("path"),Gu=$s(),qs=100,eS=16*1024;function Vu(e,t){t._opening=!0,t._writing=!0,t._asyncDrainScheduled=!1;function r(s,o){if(s){t._reopening=!1,t._writing=!1,t._opening=!1,t.sync?process.nextTick(()=>{t.listenerCount("error")>0&&t.emit("error",s);}):t.emit("error",s);return}t.fd=o,t.file=e,t._reopening=!1,t._opening=!1,t._writing=!1,t.sync?process.nextTick(()=>t.emit("ready")):t.emit("ready"),!t._reopening&&!t._writing&&t._len>t.minLength&&!t.destroyed&&sr(t);}let n=t.append?"a":"w",i=t.mode;if(t.sync)try{t.mkdir&&Ue.mkdirSync(qu.dirname(e),{recursive:!0});let s=Ue.openSync(e,n,i);r(null,s);}catch(s){throw r(s),s}else t.mkdir?Ue.mkdir(qu.dirname(e),{recursive:!0},s=>{if(s)return r(s);Ue.open(e,n,i,r);}):Ue.open(e,n,i,r);}function Fe(e){if(!(this instanceof Fe))return new Fe(e);let{fd:t,dest:r,minLength:n,maxLength:i,maxWrite:s,sync:o,append:a=!0,mode:c,mkdir:h,retryEAGAIN:l}=e||{};if(t=t||r,this._bufs=[],this._len=0,this.fd=-1,this._writing=!1,this._writingBuf="",this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._hwm=Math.max(n||0,16387),this.file=null,this.destroyed=!1,this.minLength=n||0,this.maxLength=i||0,this.maxWrite=s||eS,this.sync=o||!1,this.append=a||!1,this.mode=c,this.retryEAGAIN=l||(()=>!0),this.mkdir=h||!1,typeof t=="number")this.fd=t,process.nextTick(()=>this.emit("ready"));else if(typeof t=="string")Vu(t,this);else throw new Error("SonicBoom supports only file descriptors and files");if(this.minLength>=this.maxWrite)throw new Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(f,m)=>{if(f){if(f.code==="EAGAIN"&&this.retryEAGAIN(f,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{Gu(qs),this.release(void 0,0);}catch(u){this.release(u);}else setTimeout(()=>{Ue.write(this.fd,this._writingBuf,"utf8",this.release);},qs);else this._writing=!1,this.emit("error",f);return}if(this.emit("write",m),this._len-=m,this._writingBuf=this._writingBuf.slice(m),this._writingBuf.length){if(!this.sync){Ue.write(this.fd,this._writingBuf,"utf8",this.release);return}try{do{let u=Ue.writeSync(this.fd,this._writingBuf,"utf8");this._len-=u,this._writingBuf=this._writingBuf.slice(u);}while(this._writingBuf)}catch(u){this.release(u);return}}let p=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):p>this.minLength?sr(this):this._ending?p>0?sr(this):(this._writing=!1,Qn(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick(tS,this)):this.emit("drain"));},this.on("newListener",function(f){f==="drain"&&(this._asyncDrainScheduled=!1);});}function tS(e){e.listenerCount("drain")>0&&(e._asyncDrainScheduled=!1,e.emit("drain"));}Zb(Fe,Qb);Fe.prototype.write=function(e){if(this.destroyed)throw new Error("SonicBoom destroyed");let t=this._len+e.length,r=this._bufs;return this.maxLength&&t>this.maxLength?(this.emit("drop",e),this._len<this._hwm):(r.length===0||r[r.length-1].length+e.length>this.maxWrite?r.push(""+e):r[r.length-1]+=e,this._len=t,!this._writing&&this._len>=this.minLength&&sr(this),this._len<this._hwm)};Fe.prototype.flush=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");this._writing||this.minLength<=0||(this._bufs.length===0&&this._bufs.push(""),sr(this));};Fe.prototype.reopen=function(e){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.reopen(e);});return}if(this._ending)return;if(!this.file)throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");if(this._reopening=!0,this._writing)return;let t=this.fd;this.once("ready",()=>{t!==this.fd&&Ue.close(t,r=>{if(r)return this.emit("error",r)});}),Vu(e||this.file,this);};Fe.prototype.end=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.end();});return}this._ending||(this._ending=!0,!this._writing&&(this._len>0&&this.fd>=0?sr(this):Qn(this)));};Fe.prototype.flushSync=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this.fd<0)throw new Error("sonic boom is not ready yet");for(!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf="");this._bufs.length;){let e=this._bufs[0];try{this._len-=Ue.writeSync(this.fd,e,"utf8"),this._bufs.shift();}catch(t){if(t.code!=="EAGAIN"||!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;Gu(qs);}}};Fe.prototype.destroy=function(){this.destroyed||Qn(this);};function sr(e){let t=e.release;if(e._writing=!0,e._writingBuf=e._writingBuf||e._bufs.shift()||"",e.sync)try{let r=Ue.writeSync(e.fd,e._writingBuf,"utf8");t(null,r);}catch(r){t(r);}else Ue.write(e.fd,e._writingBuf,"utf8",t);}function Qn(e){if(e.fd===-1){e.once("ready",Qn.bind(null,e));return}e.destroyed=!0,e._bufs=[],e.fd!==1&&e.fd!==2?Ue.close(e.fd,t):setImmediate(t);function t(r){if(r){e.emit("error",r);return}e._ending&&!e._writing&&e.emit("finish"),e.emit("close");}}Fe.SonicBoom=Fe;Fe.default=Fe;Hu.exports=Fe;});var Xu=k((q2,Yu)=>{d();var{format:Gs}=$("util");function rS(){let e={},t=new Map;function r(i,s,o){if(!i)throw new Error("Warning name must not be empty");if(!s)throw new Error("Warning code must not be empty");if(!o)throw new Error("Warning message must not be empty");if(s=s.toUpperCase(),e[s]!==void 0)throw new Error(`The code '${s}' already exist`);function a(c,h,l){let f;return c&&h&&l?f=Gs(o,c,h,l):c&&h?f=Gs(o,c,h):c?f=Gs(o,c):f=o,{code:s,name:i,message:f}}return t.set(s,!1),e[s]=a,e[s]}function n(i,s,o,a){if(e[i]===void 0)throw new Error(`The code '${i}' does not exist`);if(t.get(i)===!0)return;t.set(i,!0);let c=e[i](s,o,a);process.emitWarning(c.message,c.name,c.code);}return {create:r,emit:n,emitted:t}}Yu.exports=rS;});var ef=k((V2,Zu)=>{d();var Vs=Xu()();Zu.exports=Vs;var Qu="PinoWarning";Vs.create(Qu,"PINODEP008","prettyPrint is deprecated, look at https://github.com/pinojs/pino-pretty for alternatives.");Vs.create(Qu,"PINODEP009","The use of pino.final is discouraged in Node.js v14+ and not required. It will be removed in the next major version");});var Js=k((J2,sf)=>{d();function tf(e,t,r,n){function i(){let s=t.deref();s!==void 0&&r(s,n);}e[n]=i,process.once(n,i);}var rf=new FinalizationRegistry(nf),Hs=new WeakMap;function nf(e){process.removeListener("exit",e.exit),process.removeListener("beforeExit",e.beforeExit);}function nS(e,t){if(e===void 0)throw new Error("the object can't be undefined");let r=new WeakRef(e),n={};Hs.set(e,n),rf.register(e,n),tf(n,r,t,"exit"),tf(n,r,t,"beforeExit");}function iS(e){let t=Hs.get(e);Hs.delete(e),t&&nf(t),rf.unregister(e);}sf.exports={register:nS,unregister:iS};});var af=k((X2,of)=>{d();function sS(e,t,r,n,i){let s=Date.now()+n,o=Atomics.load(e,t);if(o===r){i(null,"ok");return}let a=o,c=h=>{Date.now()>s?i(null,"timed-out"):setTimeout(()=>{a=o,o=Atomics.load(e,t),o===a?c(h>=1e3?1e3:h*2):o===r?i(null,"ok"):i(null,"not-equal");},h);};c(1);}function oS(e,t,r,n,i){let s=Date.now()+n,o=Atomics.load(e,t);if(o!==r){i(null,"ok");return}let a=c=>{Date.now()>s?i(null,"timed-out"):setTimeout(()=>{o=Atomics.load(e,t),o!==r?i(null,"ok"):a(c>=1e3?1e3:c*2);},c);};a(1);}of.exports={wait:sS,waitDiff:oS};});var lf=k((Z2,cf)=>{d();cf.exports={WRITE_INDEX:4,READ_INDEX:8};});var pf=k((rR,df)=>{d();var{EventEmitter:aS}=$("events"),{Worker:cS}=$("worker_threads"),{join:lS}=$("path"),{pathToFileURL:uS}=$("url"),{wait:fS}=af(),{WRITE_INDEX:Be,READ_INDEX:tt}=lf(),hS=$("buffer"),dS=$("assert"),P=Symbol("kImpl"),pS=hS.constants.MAX_STRING_LENGTH,ei=class{constructor(t){this._value=t;}deref(){return this._value}},gS=global.FinalizationRegistry||class{register(){}unregister(){}},mS=global.WeakRef||ei,uf=new gS(e=>{e.exited||e.terminate();});function yS(e,t){let{filename:r,workerData:n}=t,s=("__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{})["thread-stream-worker"]||lS(E,"lib","worker.js"),o=new cS(s,Q(F({},t.workerOpts),{workerData:{filename:r.indexOf("file://")===0?r:uS(r).href,dataBuf:e[P].dataBuf,stateBuf:e[P].stateBuf,workerData:n}}));return o.stream=new ei(e),o.on("message",wS),o.on("exit",hf),uf.register(e,o),o}function ff(e){dS(!e[P].sync),e[P].needDrain&&(e[P].needDrain=!1,e.emit("drain"));}function Zn(e){let t=Atomics.load(e[P].state,Be),r=e[P].data.length-t;if(r>0){if(e[P].buf.length===0){e[P].flushing=!1,e[P].ending?Zs(e):e[P].needDrain&&process.nextTick(ff,e);return}let n=e[P].buf.slice(0,r),i=Buffer.byteLength(n);i<=r?(e[P].buf=e[P].buf.slice(r),ti(e,n,Zn.bind(null,e))):e.flush(()=>{if(!e.destroyed){for(Atomics.store(e[P].state,tt,0),Atomics.store(e[P].state,Be,0);i>e[P].data.length;)r=r/2,n=e[P].buf.slice(0,r),i=Buffer.byteLength(n);e[P].buf=e[P].buf.slice(r),ti(e,n,Zn.bind(null,e));}});}else if(r===0){if(t===0&&e[P].buf.length===0)return;e.flush(()=>{Atomics.store(e[P].state,tt,0),Atomics.store(e[P].state,Be,0),Zn(e);});}else throw new Error("overwritten")}function wS(e){let t=this.stream.deref();if(t===void 0){this.exited=!0,this.terminate();return}switch(e.code){case"READY":this.stream=new mS(t),t.flush(()=>{t[P].ready=!0,t.emit("ready");});break;case"ERROR":or(t,e.err);break;default:throw new Error("this should not happen: "+e.code)}}function hf(e){let t=this.stream.deref();t!==void 0&&(uf.unregister(t),t.worker.exited=!0,t.worker.off("exit",hf),or(t,e!==0?new Error("The worker thread exited"):null));}var Xs=class extends aS{constructor(t={}){if(super(),t.bufferSize<4)throw new Error("bufferSize must at least fit a 4-byte utf-8 char");this[P]={},this[P].stateBuf=new SharedArrayBuffer(128),this[P].state=new Int32Array(this[P].stateBuf),this[P].dataBuf=new SharedArrayBuffer(t.bufferSize||4*1024*1024),this[P].data=Buffer.from(this[P].dataBuf),this[P].sync=t.sync||!1,this[P].ending=!1,this[P].ended=!1,this[P].needDrain=!1,this[P].destroyed=!1,this[P].flushing=!1,this[P].ready=!1,this[P].finished=!1,this[P].errored=null,this[P].closed=!1,this[P].buf="",this.worker=yS(this,t);}write(t){if(this[P].destroyed)throw new Error("the worker has exited");if(this[P].ending)throw new Error("the worker is ending");if(this[P].flushing&&this[P].buf.length+t.length>=pS)try{Ys(this),this[P].flushing=!0;}catch(r){return or(this,r),!1}if(this[P].buf+=t,this[P].sync)try{return Ys(this),!0}catch(r){return or(this,r),!1}return this[P].flushing||(this[P].flushing=!0,setImmediate(Zn,this)),this[P].needDrain=this[P].data.length-this[P].buf.length-Atomics.load(this[P].state,Be)<=0,!this[P].needDrain}end(){this[P].destroyed||(this[P].ending=!0,Zs(this));}flush(t){if(this[P].destroyed){typeof t=="function"&&process.nextTick(t,new Error("the worker has exited"));return}let r=Atomics.load(this[P].state,Be);fS(this[P].state,tt,r,1/0,(n,i)=>{if(n){or(this,n),process.nextTick(t,n);return}if(i==="not-equal"){this.flush(t);return}process.nextTick(t);});}flushSync(){this[P].destroyed||(Ys(this),Qs(this));}unref(){this.worker.unref();}ref(){this.worker.ref();}get ready(){return this[P].ready}get destroyed(){return this[P].destroyed}get closed(){return this[P].closed}get writable(){return !this[P].destroyed&&!this[P].ending}get writableEnded(){return this[P].ending}get writableFinished(){return this[P].finished}get writableNeedDrain(){return this[P].needDrain}get writableObjectMode(){return !1}get writableErrored(){return this[P].errored}};function or(e,t){e[P].destroyed||(e[P].destroyed=!0,t&&(e[P].errored=t,e.emit("error",t)),e.worker.exited?setImmediate(()=>{e[P].closed=!0,e.emit("close");}):e.worker.terminate().catch(()=>{}).then(()=>{e[P].closed=!0,e.emit("close");}));}function ti(e,t,r){let n=Atomics.load(e[P].state,Be),i=Buffer.byteLength(t);return e[P].data.write(t,n),Atomics.store(e[P].state,Be,n+i),Atomics.notify(e[P].state,Be),r(),!0}function Zs(e){if(!(e[P].ended||!e[P].ending||e[P].flushing)){e[P].ended=!0;try{e.flushSync();let t=Atomics.load(e[P].state,tt);Atomics.store(e[P].state,Be,-1),Atomics.notify(e[P].state,Be);let r=0;for(;t!==-1;){if(Atomics.wait(e[P].state,tt,t,1e3),t=Atomics.load(e[P].state,tt),t===-2)throw new Error("end() failed");if(++r===10)throw new Error("end() took too long (10s)")}process.nextTick(()=>{e[P].finished=!0,e.emit("finish");});}catch(t){or(e,t);}}}function Ys(e){let t=()=>{e[P].ending?Zs(e):e[P].needDrain&&process.nextTick(ff,e);};for(e[P].flushing=!1;e[P].buf.length!==0;){let r=Atomics.load(e[P].state,Be),n=e[P].data.length-r;if(n===0){Qs(e),Atomics.store(e[P].state,tt,0),Atomics.store(e[P].state,Be,0);continue}else if(n<0)throw new Error("overwritten");let i=e[P].buf.slice(0,n),s=Buffer.byteLength(i);if(s<=n)e[P].buf=e[P].buf.slice(n),ti(e,i,t);else {for(Qs(e),Atomics.store(e[P].state,tt,0),Atomics.store(e[P].state,Be,0);s>e[P].buf.length;)n=n/2,i=e[P].buf.slice(0,n),s=Buffer.byteLength(i);e[P].buf=e[P].buf.slice(n),ti(e,i,t);}}}function Qs(e){if(e[P].flushing)throw new Error("unable to flush while flushing");let t=Atomics.load(e[P].state,Be),r=0;for(;;){let n=Atomics.load(e[P].state,tt);if(n===-2)throw new Error("_flushSync failed");if(n!==t)Atomics.wait(e[P].state,tt,n,1e3);else break;if(++r===10)throw new Error("_flushSync took too long (10s)")}}df.exports=Xs;});var to=k((sR,mf)=>{d();var{createRequire:bS}=$("module"),SS=Ms(),{join:eo,isAbsolute:_S}=$("path"),ES=$s(),ri;global.WeakRef&&global.WeakMap&&global.FinalizationRegistry&&(ri=Js());var vS=pf();function xS(e){if(ri)ri.register(e,gf),e.on("close",function(){ri.unregister(e);});else {let t=gf.bind(null,e);process.once("beforeExit",t),process.once("exit",t),e.on("close",function(){process.removeListener("beforeExit",t),process.removeListener("exit",t);});}}function CS(e,t,r){let n=new vS({filename:e,workerData:t,workerOpts:r});n.on("ready",i),n.on("close",function(){process.removeListener("exit",s);}),process.on("exit",s);function i(){process.removeListener("exit",s),n.unref(),r.autoEnd!==!1&&xS(n);}function s(){n.closed||(n.flushSync(),ES(100),n.end());}return n}function gf(e){e.ref(),e.flushSync(),e.end(),e.once("close",function(){e.unref();});}function IS(e){let{pipeline:t,targets:r,levels:n,options:i={},worker:s={},caller:o=SS()}=e,a=typeof o=="string"?[o]:o,c="__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{},h=e.target;if(h&&r)throw new Error("only one of target or targets can be specified");return r?(h=c["pino-worker"]||eo(E,"worker.js"),i.targets=r.map(f=>Q(F({},f),{target:l(f.target)}))):t&&(h=c["pino-pipeline-worker"]||eo(E,"worker-pipeline.js"),i.targets=t.map(f=>Q(F({},f),{target:l(f.target)}))),n&&(i.levels=n),CS(l(h),i,s);function l(f){if(f=c[f]||f,_S(f)||f.indexOf("file://")===0)return f;if(f==="pino/file")return eo(E,"..","file.js");let m;for(let p of a)try{m=bS(p).resolve(f);break}catch(u){continue}if(!m)throw new Error(`unable to determine transport target for "${f}"`);return m}}mf.exports=IS;});var ii=k((cR,Af)=>{d();var yf=$u(),{mapHttpRequest:DS,mapHttpResponse:AS}=Ls(),io=Ju(),Ef=ef(),{lsCacheSym:OS,chindingsSym:so,parsedChindingsSym:ro,writeSym:wf,serializersSym:oo,formatOptsSym:bf,endSym:TS,stringifiersSym:ao,stringifySym:vf,stringifySafeSym:co,wildcardFirstSym:xf,needsMetadataGsym:Cf,redactFmtSym:RS,streamSym:PS,nestedKeySym:NS,formattersSym:lo,messageKeySym:If,nestedKeyStrSym:LS}=ir(),{isMainThread:MS}=$("worker_threads"),FS=to();function Br(){}function BS(e,t){if(!t)return r;return function(...i){t.call(this,i,r,e);};function r(n,...i){if(typeof n=="object"){let s=n;n!==null&&(n.method&&n.headers&&n.socket?n=DS(n):typeof n.setHeader=="function"&&(n=AS(n)));let o;s===null&&i.length===0?o=[null]:(s=i.shift(),o=i),this[wf](n,yf(s,o,this[bf]),e);}else this[wf](null,yf(n,i,this[bf]),e);}}function Sf(e){let t="",r=0,n=!1,i=255,s=e.length;if(s>100)return JSON.stringify(e);for(var o=0;o<s&&i>=32;o++)i=e.charCodeAt(o),(i===34||i===92)&&(t+=e.slice(r,o)+"\\",r=o,n=!0);return n?t+=e.slice(r):t=e,i<32?JSON.stringify(e):'"'+t+'"'}function kS(e,t,r,n){let i=this[vf],s=this[co],o=this[ao],a=this[TS],c=this[so],h=this[oo],l=this[lo],f=this[If],m=this[OS][r]+n;m=m+c;let p;l.log&&(e=l.log(e));let u=o[xf],y="";for(let S in e)if(p=e[S],Object.prototype.hasOwnProperty.call(e,S)&&p!==void 0){p=h[S]?h[S](p):p;let b=o[S]||u;switch(typeof p){case"undefined":case"function":continue;case"number":Number.isFinite(p)===!1&&(p=null);case"boolean":b&&(p=b(p));break;case"string":p=(b||Sf)(p);break;default:p=(b||i)(p,s);}if(p===void 0)continue;y+=',"'+S+'":'+p;}let w="";if(t!==void 0){p=h[f]?h[f](t):t;let S=o[f]||u;switch(typeof p){case"function":break;case"number":Number.isFinite(p)===!1&&(p=null);case"boolean":S&&(p=S(p)),w=',"'+f+'":'+p;break;case"string":p=(S||Sf)(p),w=',"'+f+'":'+p;break;default:p=(S||i)(p,s),w=',"'+f+'":'+p;}}return this[NS]&&y?m+this[LS]+y.slice(1)+"}"+w+a:m+y+w+a}function US(e,t){let r,n=e[so],i=e[vf],s=e[co],o=e[ao],a=o[xf],c=e[oo],h=e[lo].bindings;t=h(t);for(let l in t)if(r=t[l],(l!=="level"&&l!=="serializers"&&l!=="formatters"&&l!=="customLevels"&&t.hasOwnProperty(l)&&r!==void 0)===!0){if(r=c[l]?c[l](r):r,r=(o[l]||a||i)(r,s),r===void 0)continue;n+=',"'+l+'":'+r;}return n}function Df(e,t,r,n){if(t&&typeof t=="function")return t=t.bind(n),no(t(e),r,e);try{let i=$("pino-pretty").prettyFactory;return i.asMetaWrapper=no,no(i(e),r,e)}catch(i){throw i.message.startsWith("Cannot find module 'pino-pretty'")?Error("Missing `pino-pretty` module: `pino-pretty` must be installed separately"):i}}function no(e,t,r){r=Object.assign({suppressFlushSyncWarning:!1},r);let n=!1;return {[Cf]:!0,lastLevel:0,lastMsg:null,lastObj:null,lastLogger:null,flushSync(){r.suppressFlushSyncWarning||n||(n=!0,_f(t,this),t.write(e(Object.assign({level:40,msg:"pino.final with prettyPrint does not support flushing",time:Date.now()},this.chindings()))));},chindings(){let i=this.lastLogger,s=null;return i?(i.hasOwnProperty(ro)?s=i[ro]:(s=JSON.parse("{"+i[so].substr(1)+"}"),i[ro]=s),s):null},write(i){let s=this.lastLogger,o=this.chindings(),a=this.lastTime;typeof a=="number"||(a.match(/^\d+/)?a=parseInt(a):a=a.slice(1,-1));let c=this.lastObj,h=this.lastMsg,l=null,f=s[lo],m=f.log?f.log(c):c,p=s[If];h&&m&&!Object.prototype.hasOwnProperty.call(m,p)&&(m[p]=h);let u=Object.assign({level:this.lastLevel,time:a},m,l),y=s[oo],w=Object.keys(y);for(var S=0;S<w.length;S++){let T=w[S];u[T]!==void 0&&(u[T]=y[T](u[T]));}for(let T in o)u.hasOwnProperty(T)||(u[T]=o[T]);let _=s[ao][RS],C=e(typeof _=="function"?_(u):u);C!==void 0&&(_f(t,this),t.write(C));}}}function WS(e){return e.write!==e.constructor.prototype.write}function ni(e){let t=new io(e);return t.on("error",r),!e.sync&&MS&&KS(t),t;function r(n){if(n.code==="EPIPE"){t.write=Br,t.end=Br,t.flushSync=Br,t.destroy=Br;return}t.removeListener("error",r),t.emit("error",n);}}function KS(e){if(global.WeakRef&&global.WeakMap&&global.FinalizationRegistry){let t=Js();t.register(e,jS),e.on("close",function(){t.unregister(e);});}}function jS(e,t){e.destroyed||(t==="beforeExit"?(e.flush(),e.on("drain",function(){e.end();})):e.flushSync());}function zS(e){return function(r,n,i={},s){if(typeof i=="string")s=ni({dest:i,sync:!0}),i={};else if(typeof s=="string"){if(i&&i.transport)throw Error("only one of option.transport or stream can be specified");s=ni({dest:s,sync:!0});}else if(i instanceof io||i.writable||i._writableState)s=i,i={};else if(i.transport){if(i.transport instanceof io||i.transport.writable||i.transport._writableState)throw Error("option.transport do not allow stream, please pass to option directly. e.g. pino(transport)");if(i.transport.targets&&i.transport.targets.length&&i.formatters&&typeof i.formatters.level=="function")throw Error("option.transport.targets do not allow custom level formatters");let l;i.customLevels&&(l=i.useOnlyCustomLevels?i.customLevels:Object.assign({},i.levels,i.customLevels)),s=FS(Q(F({caller:n},i.transport),{levels:l}));}if(i=Object.assign({},e,i),i.serializers=Object.assign({},e.serializers,i.serializers),i.formatters=Object.assign({},e.formatters,i.formatters),"onTerminated"in i)throw Error("The onTerminated option has been removed, use pino.final instead");"changeLevelName"in i&&(process.emitWarning("The changeLevelName option is deprecated and will be removed in v7. Use levelKey instead.",{code:"changeLevelName_deprecation"}),i.levelKey=i.changeLevelName,delete i.changeLevelName);let{enabled:o,prettyPrint:a,prettifier:c,messageKey:h}=i;if(o===!1&&(i.level="silent"),s=s||process.stdout,s===process.stdout&&s.fd>=0&&!WS(s)&&(s=ni({fd:s.fd,sync:!0})),a){Ef.emit("PINODEP008");let l=Object.assign({messageKey:h},a);s=Df(l,c,s,r);}return {opts:i,stream:s}}}function $S(e,t){if(Number(process.versions.node.split(".")[0])>=14&&Ef.emit("PINODEP009"),typeof e=="undefined"||typeof e.child!="function")throw Error("expected a pino logger instance");let n=typeof t!="undefined";if(n&&typeof t!="function")throw Error("if supplied, the handler parameter should be a function");let i=e[PS];if(typeof i.flushSync!="function")throw Error("final requires a stream that has a flushSync method, such as pino.destination");let s=new Proxy(e,{get:(o,a)=>a in o.levels.values?(...c)=>{o[a](...c),i.flushSync();}:o[a]});if(!n){try{i.flushSync();}catch(o){}return s}return (o=null,...a)=>{try{i.flushSync();}catch(c){}return t(o,s,...a)}}function qS(e,t){try{return JSON.stringify(e)}catch(r){try{return (t||this[co])(e)}catch(n){return '"[unable to serialize, circular reference is too complex to analyze]"'}}}function GS(e,t,r){return {level:e,bindings:t,log:r}}function _f(e,t){e[Cf]===!0&&(e.lastLevel=t.lastLevel,e.lastMsg=t.lastMsg,e.lastObj=t.lastObj,e.lastTime=t.lastTime,e.lastLogger=t.lastLogger);}function VS(e){let t=Number(e);return typeof e=="string"&&Number.isFinite(t)?t:e}Af.exports={noop:Br,buildSafeSonicBoom:ni,getPrettyStream:Df,asChindings:US,asJson:kS,genLog:BS,createArgsNormalizer:zS,final:$S,stringify:qS,buildFormatters:GS,normalizeDestFileDescriptor:VS};});var si=k((fR,Tf)=>{d();var{lsCacheSym:HS,levelValSym:uo,useOnlyCustomLevelsSym:JS,streamSym:YS,formattersSym:XS,hooksSym:QS}=ir(),{noop:ZS,genLog:Lt}=ii(),Xe={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},Of={fatal:e=>{let t=Lt(Xe.fatal,e);return function(...r){let n=this[YS];if(t.call(this,...r),typeof n.flushSync=="function")try{n.flushSync();}catch(i){}}},error:e=>Lt(Xe.error,e),warn:e=>Lt(Xe.warn,e),info:e=>Lt(Xe.info,e),debug:e=>Lt(Xe.debug,e),trace:e=>Lt(Xe.trace,e)},fo=Object.keys(Xe).reduce((e,t)=>(e[Xe[t]]=t,e),{}),e0=Object.keys(fo).reduce((e,t)=>(e[t]='{"level":'+Number(t),e),{});function t0(e){let t=e[XS].level,{labels:r}=e.levels,n={};for(let i in r){let s=t(r[i],Number(i));n[i]=JSON.stringify(s).slice(0,-1);}return e[HS]=n,e}function r0(e,t){if(t)return !1;switch(e){case"fatal":case"error":case"warn":case"info":case"debug":case"trace":return !0;default:return !1}}function n0(e){let{labels:t,values:r}=this.levels;if(typeof e=="number"){if(t[e]===void 0)throw Error("unknown level value"+e);e=t[e];}if(r[e]===void 0)throw Error("unknown level "+e);let n=this[uo],i=this[uo]=r[e],s=this[JS],o=this[QS].logMethod;for(let a in r){if(i>r[a]){this[a]=ZS;continue}this[a]=r0(a,s)?Of[a](o):Lt(r[a],o);}this.emit("level-change",e,i,t[n],n);}function i0(e){let{levels:t,levelVal:r}=this;return t&&t.labels?t.labels[r]:""}function s0(e){let{values:t}=this.levels,r=t[e];return r!==void 0&&r>=this[uo]}function o0(e=null,t=!1){let r=e?Object.keys(e).reduce((s,o)=>(s[e[o]]=o,s),{}):null,n=Object.assign(Object.create(Object.prototype,{Infinity:{value:"silent"}}),t?null:fo,r),i=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),t?null:Xe,e);return {labels:n,values:i}}function a0(e,t,r){if(typeof e=="number"){if(![].concat(Object.keys(t||{}).map(s=>t[s]),r?[]:Object.keys(fo).map(s=>+s),1/0).includes(e))throw Error(`default level:${e} must be included in custom levels`);return}let n=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),r?null:Xe,t);if(!(e in n))throw Error(`default level:${e} must be included in custom levels`)}function c0(e,t){let{labels:r,values:n}=e;for(let i in t){if(i in n)throw Error("levels cannot be overridden");if(t[i]in r)throw Error("pre-existing level values cannot be used for new levels")}}Tf.exports={initialLsCache:e0,genLsCache:t0,levelMethods:Of,getLevel:i0,setLevel:n0,isLevelEnabled:s0,mappings:o0,levels:Xe,assertNoLevelCollisions:c0,assertDefaultLevelFound:a0};});var Rf=k((dR,l0)=>{l0.exports={name:"pino",version:"7.11.0",description:"super fast, all natural json logger",main:"pino.js",type:"commonjs",types:"pino.d.ts",browser:"./browser.js",files:["pino.js","file.js","pino.d.ts","bin.js","browser.js","pretty.js","usage.txt","test","docs","example.js","lib"],scripts:{docs:"docsify serve","browser-test":"airtap --local 8080 test/browser*test.js",lint:"eslint .",test:"npm run lint && npm run transpile && tap --ts && jest test/jest && npm run test-types","test-ci":"npm run lint && npm run transpile && tap --ts --no-check-coverage --coverage-report=lcovonly && npm run test-types","test-ci-pnpm":"pnpm run lint && npm run transpile && tap --ts --no-coverage --no-check-coverage && pnpm run test-types","test-ci-yarn-pnp":"yarn run lint && npm run transpile && tap --ts --no-check-coverage --coverage-report=lcovonly","test-types":"tsc && tsd && ts-node test/types/pino.ts",transpile:"node ./test/fixtures/ts/transpile.cjs","cov-ui":"tap --ts --coverage-report=html",bench:"node benchmarks/utils/runbench all","bench-basic":"node benchmarks/utils/runbench basic","bench-object":"node benchmarks/utils/runbench object","bench-deep-object":"node benchmarks/utils/runbench deep-object","bench-multi-arg":"node benchmarks/utils/runbench multi-arg","bench-longs-tring":"node benchmarks/utils/runbench long-string","bench-child":"node benchmarks/utils/runbench child","bench-child-child":"node benchmarks/utils/runbench child-child","bench-child-creation":"node benchmarks/utils/runbench child-creation","bench-formatters":"node benchmarks/utils/runbench formatters","update-bench-doc":"node benchmarks/utils/generate-benchmark-doc > docs/benchmarks.md"},bin:{pino:"./bin.js"},precommit:"test",repository:{type:"git",url:"git+https://github.com/pinojs/pino.git"},keywords:["fast","logger","stream","json"],author:"Matteo Collina <hello@matteocollina.com>",contributors:["David Mark Clements <huperekchuno@googlemail.com>","James Sumners <james.sumners@gmail.com>","Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)"],license:"MIT",bugs:{url:"https://github.com/pinojs/pino/issues"},homepage:"http://getpino.io",devDependencies:{"@types/flush-write-stream":"^1.0.0","@types/node":"^17.0.0","@types/tap":"^15.0.6",airtap:"4.0.4",benchmark:"^2.1.4",bole:"^4.0.0",bunyan:"^1.8.14","docsify-cli":"^4.4.1",eslint:"^7.17.0","eslint-config-standard":"^16.0.3","eslint-plugin-import":"^2.22.1","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^5.1.0",execa:"^5.0.0",fastbench:"^1.0.1","flush-write-stream":"^2.0.0","import-fresh":"^3.2.1",jest:"^27.3.1",log:"^6.0.0",loglevel:"^1.6.7","pino-pretty":"^v7.6.0","pre-commit":"^1.2.2",proxyquire:"^2.1.3",pump:"^3.0.0",rimraf:"^3.0.2",semver:"^7.0.0",split2:"^4.0.0",steed:"^1.1.3","strip-ansi":"^6.0.0",tap:"^16.0.0",tape:"^5.0.0",through2:"^4.0.0","ts-node":"^10.7.0",tsd:"^0.20.0",typescript:"^4.4.4",winston:"^3.3.3"},dependencies:{"atomic-sleep":"^1.0.0","fast-redact":"^3.0.0","on-exit-leak-free":"^0.2.0","pino-abstract-transport":"v0.5.0","pino-std-serializers":"^4.0.0","process-warning":"^1.0.0","quick-format-unescaped":"^4.0.3","real-require":"^0.1.0","safe-stable-stringify":"^2.1.0","sonic-boom":"^2.2.1","thread-stream":"^0.15.1"},tsd:{directory:"test/types"}};});var ho=k((pR,Pf)=>{d();var{version:u0}=Rf();Pf.exports={version:u0};});var jf=k((yR,Kf)=>{d();var{EventEmitter:f0}=$("events"),{lsCacheSym:h0,levelValSym:d0,setLevelSym:go,getLevelSym:Nf,chindingsSym:mo,parsedChindingsSym:p0,mixinSym:g0,asJsonSym:Bf,writeSym:m0,mixinMergeStrategySym:y0,timeSym:w0,timeSliceIndexSym:b0,streamSym:kf,serializersSym:Mt,formattersSym:po,useOnlyCustomLevelsSym:S0,needsMetadataGsym:_0,redactFmtSym:E0,stringifySym:v0,formatOptsSym:x0,stringifiersSym:C0}=ir(),{getLevel:I0,setLevel:D0,isLevelEnabled:A0,mappings:O0,initialLsCache:T0,genLsCache:R0,assertNoLevelCollisions:P0}=si(),{asChindings:Uf,asJson:N0,buildFormatters:Lf,stringify:Mf}=ii(),{version:L0}=ho(),M0=js(),F0=class{},Wf={constructor:F0,child:B0,bindings:k0,setBindings:U0,flush:z0,isLevelEnabled:A0,version:L0,get level(){return this[Nf]()},set level(e){this[go](e);},get levelVal(){return this[d0]},set levelVal(e){throw Error("levelVal is read-only")},[h0]:T0,[m0]:K0,[Bf]:N0,[Nf]:I0,[go]:D0};Object.setPrototypeOf(Wf,f0.prototype);Kf.exports=function(){return Object.create(Wf)};var Ff=e=>e;function B0(e,t){if(!e)throw Error("missing bindings for child Pino");t=t||{};let r=this[Mt],n=this[po],i=Object.create(this);if(t.hasOwnProperty("serializers")===!0){i[Mt]=Object.create(null);for(let l in r)i[Mt][l]=r[l];let c=Object.getOwnPropertySymbols(r);for(var s=0;s<c.length;s++){let l=c[s];i[Mt][l]=r[l];}for(let l in t.serializers)i[Mt][l]=t.serializers[l];let h=Object.getOwnPropertySymbols(t.serializers);for(var o=0;o<h.length;o++){let l=h[o];i[Mt][l]=t.serializers[l];}}else i[Mt]=r;if(t.hasOwnProperty("formatters")){let{level:c,bindings:h,log:l}=t.formatters;i[po]=Lf(c||n.level,h||Ff,l||n.log);}else i[po]=Lf(n.level,Ff,n.log);if(t.hasOwnProperty("customLevels")===!0&&(P0(this.levels,t.customLevels),i.levels=O0(t.customLevels,i[S0]),R0(i)),typeof t.redact=="object"&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;let c=M0(i.redact,Mf),h={stringify:c[E0]};i[v0]=Mf,i[C0]=c,i[x0]=h;}i[mo]=Uf(i,e);let a=t.level||this.level;return i[go](a),i}function k0(){let t=`{${this[mo].substr(1)}}`,r=JSON.parse(t);return delete r.pid,delete r.hostname,r}function U0(e){let t=Uf(this,e);this[mo]=t,delete this[p0];}function W0(e,t){return Object.assign(t,e)}function K0(e,t,r){let n=this[w0](),i=this[g0],s=this[y0]||W0,o;e==null?o={}:e instanceof Error?(o={err:e},t===void 0&&(t=e.message)):(o=e,t===void 0&&e.err&&(t=e.err.message)),i&&(o=s(o,i(o,r)));let a=this[Bf](o,t,r,n),c=this[kf];c[_0]===!0&&(c.lastLevel=r,c.lastObj=o,c.lastMsg=t,c.lastTime=n.slice(this[b0]),c.lastLogger=this),c.write(a);}function j0(){}function z0(){let e=this[kf];"flush"in e&&e.flush(j0);}});var Gf=k((So,qf)=>{d();var{hasOwnProperty:kr}=Object.prototype,Bt=bo();Bt.configure=bo;Bt.stringify=Bt;Bt.default=Bt;So.stringify=Bt;So.configure=bo;qf.exports=Bt;var $0=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function bt(e){return e.length<5e3&&!$0.test(e)?`"${e}"`:JSON.stringify(e)}function yo(e,t){if(e.length>200||t)return e.sort(t);for(let r=1;r<e.length;r++){let n=e[r],i=r;for(;i!==0&&e[i-1]>n;)e[i]=e[i-1],i--;e[i]=n;}return e}var q0=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function wo(e){return q0.call(e)!==void 0&&e.length!==0}function zf(e,t,r){e.length<r&&(r=e.length);let n=t===","?"":" ",i=`"0":${n}${e[0]}`;for(let s=1;s<r;s++)i+=`${t}"${s}":${n}${e[s]}`;return i}function G0(e){if(kr.call(e,"circularValue")){let t=e.circularValue;if(typeof t=="string")return `"${t}"`;if(t==null)return t;if(t===Error||t===TypeError)return {toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return '"[Circular]"'}function V0(e){let t;if(kr.call(e,"deterministic")&&(t=e.deterministic,typeof t!="boolean"&&typeof t!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return t===void 0?!0:t}function H0(e,t){let r;if(kr.call(e,t)&&(r=e[t],typeof r!="boolean"))throw new TypeError(`The "${t}" argument must be of type boolean`);return r===void 0?!0:r}function $f(e,t){let r;if(kr.call(e,t)){if(r=e[t],typeof r!="number")throw new TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw new TypeError(`The "${t}" argument must be an integer`);if(r<1)throw new RangeError(`The "${t}" argument must be >= 1`)}return r===void 0?1/0:r}function Ft(e){return e===1?"1 item":`${e} items`}function J0(e){let t=new Set;for(let r of e)(typeof r=="string"||typeof r=="number")&&t.add(String(r));return t}function Y0(e){if(kr.call(e,"strict")){let t=e.strict;if(typeof t!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(t)return r=>{let n=`Object can not safely be stringified. Received type ${typeof r}`;throw typeof r!="function"&&(n+=` (${r.toString()})`),new Error(n)}}}function bo(e){e=F({},e);let t=Y0(e);t&&(e.bigint===void 0&&(e.bigint=!1),"circularValue"in e||(e.circularValue=Error));let r=G0(e),n=H0(e,"bigint"),i=V0(e),s=typeof i=="function"?i:void 0,o=$f(e,"maximumDepth"),a=$f(e,"maximumBreadth");function c(p,u,y,w,S,b){let _=u[p];switch(typeof _=="object"&&_!==null&&typeof _.toJSON=="function"&&(_=_.toJSON(p)),_=w.call(u,p,_),typeof _){case"string":return bt(_);case"object":{if(_===null)return "null";if(y.indexOf(_)!==-1)return r;let C="",T=",",M=b;if(Array.isArray(_)){if(_.length===0)return "[]";if(o<y.length+1)return '"[Array]"';y.push(_),S!==""&&(b+=S,C+=`
|
|
104
|
+
${b}`,T=`,
|
|
105
|
+
${b}`);let D=Math.min(_.length,a),O=0;for(;O<D-1;O++){let K=c(String(O),_,y,w,S,b);C+=K!==void 0?K:"null",C+=T;}let L=c(String(O),_,y,w,S,b);if(C+=L!==void 0?L:"null",_.length-1>a){let K=_.length-a-1;C+=`${T}"... ${Ft(K)} not stringified"`;}return S!==""&&(C+=`
|
|
106
|
+
${M}`),y.pop(),`[${C}]`}let v=Object.keys(_),I=v.length;if(I===0)return "{}";if(o<y.length+1)return '"[Object]"';let B="",R="";S!==""&&(b+=S,T=`,
|
|
107
|
+
${b}`,B=" ");let A=Math.min(I,a);i&&!wo(_)&&(v=yo(v,s)),y.push(_);for(let D=0;D<A;D++){let O=v[D],L=c(O,_,y,w,S,b);L!==void 0&&(C+=`${R}${bt(O)}:${B}${L}`,R=T);}if(I>a){let D=I-a;C+=`${R}"...":${B}"${Ft(D)} not stringified"`,R=T;}return S!==""&&R.length>1&&(C=`
|
|
108
|
+
${b}${C}
|
|
109
|
+
${M}`),y.pop(),`{${C}}`}case"number":return isFinite(_)?String(_):t?t(_):"null";case"boolean":return _===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(_);default:return t?t(_):void 0}}function h(p,u,y,w,S,b){switch(typeof u=="object"&&u!==null&&typeof u.toJSON=="function"&&(u=u.toJSON(p)),typeof u){case"string":return bt(u);case"object":{if(u===null)return "null";if(y.indexOf(u)!==-1)return r;let _=b,C="",T=",";if(Array.isArray(u)){if(u.length===0)return "[]";if(o<y.length+1)return '"[Array]"';y.push(u),S!==""&&(b+=S,C+=`
|
|
110
|
+
${b}`,T=`,
|
|
111
|
+
${b}`);let I=Math.min(u.length,a),B=0;for(;B<I-1;B++){let A=h(String(B),u[B],y,w,S,b);C+=A!==void 0?A:"null",C+=T;}let R=h(String(B),u[B],y,w,S,b);if(C+=R!==void 0?R:"null",u.length-1>a){let A=u.length-a-1;C+=`${T}"... ${Ft(A)} not stringified"`;}return S!==""&&(C+=`
|
|
112
|
+
${_}`),y.pop(),`[${C}]`}y.push(u);let M="";S!==""&&(b+=S,T=`,
|
|
113
|
+
${b}`,M=" ");let v="";for(let I of w){let B=h(I,u[I],y,w,S,b);B!==void 0&&(C+=`${v}${bt(I)}:${M}${B}`,v=T);}return S!==""&&v.length>1&&(C=`
|
|
114
|
+
${b}${C}
|
|
115
|
+
${_}`),y.pop(),`{${C}}`}case"number":return isFinite(u)?String(u):t?t(u):"null";case"boolean":return u===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(u);default:return t?t(u):void 0}}function l(p,u,y,w,S){switch(typeof u){case"string":return bt(u);case"object":{if(u===null)return "null";if(typeof u.toJSON=="function"){if(u=u.toJSON(p),typeof u!="object")return l(p,u,y,w,S);if(u===null)return "null"}if(y.indexOf(u)!==-1)return r;let b=S;if(Array.isArray(u)){if(u.length===0)return "[]";if(o<y.length+1)return '"[Array]"';y.push(u),S+=w;let B=`
|
|
116
|
+
${S}`,R=`,
|
|
117
|
+
${S}`,A=Math.min(u.length,a),D=0;for(;D<A-1;D++){let L=l(String(D),u[D],y,w,S);B+=L!==void 0?L:"null",B+=R;}let O=l(String(D),u[D],y,w,S);if(B+=O!==void 0?O:"null",u.length-1>a){let L=u.length-a-1;B+=`${R}"... ${Ft(L)} not stringified"`;}return B+=`
|
|
118
|
+
${b}`,y.pop(),`[${B}]`}let _=Object.keys(u),C=_.length;if(C===0)return "{}";if(o<y.length+1)return '"[Object]"';S+=w;let T=`,
|
|
119
|
+
${S}`,M="",v="",I=Math.min(C,a);wo(u)&&(M+=zf(u,T,a),_=_.slice(u.length),I-=u.length,v=T),i&&(_=yo(_,s)),y.push(u);for(let B=0;B<I;B++){let R=_[B],A=l(R,u[R],y,w,S);A!==void 0&&(M+=`${v}${bt(R)}: ${A}`,v=T);}if(C>a){let B=C-a;M+=`${v}"...": "${Ft(B)} not stringified"`,v=T;}return v!==""&&(M=`
|
|
120
|
+
${S}${M}
|
|
121
|
+
${b}`),y.pop(),`{${M}}`}case"number":return isFinite(u)?String(u):t?t(u):"null";case"boolean":return u===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(u);default:return t?t(u):void 0}}function f(p,u,y){switch(typeof u){case"string":return bt(u);case"object":{if(u===null)return "null";if(typeof u.toJSON=="function"){if(u=u.toJSON(p),typeof u!="object")return f(p,u,y);if(u===null)return "null"}if(y.indexOf(u)!==-1)return r;let w="",S=u.length!==void 0;if(S&&Array.isArray(u)){if(u.length===0)return "[]";if(o<y.length+1)return '"[Array]"';y.push(u);let M=Math.min(u.length,a),v=0;for(;v<M-1;v++){let B=f(String(v),u[v],y);w+=B!==void 0?B:"null",w+=",";}let I=f(String(v),u[v],y);if(w+=I!==void 0?I:"null",u.length-1>a){let B=u.length-a-1;w+=`,"... ${Ft(B)} not stringified"`;}return y.pop(),`[${w}]`}let b=Object.keys(u),_=b.length;if(_===0)return "{}";if(o<y.length+1)return '"[Object]"';let C="",T=Math.min(_,a);S&&wo(u)&&(w+=zf(u,",",a),b=b.slice(u.length),T-=u.length,C=","),i&&(b=yo(b,s)),y.push(u);for(let M=0;M<T;M++){let v=b[M],I=f(v,u[v],y);I!==void 0&&(w+=`${C}${bt(v)}:${I}`,C=",");}if(_>a){let M=_-a;w+=`${C}"...":"${Ft(M)} not stringified"`;}return y.pop(),`{${w}}`}case"number":return isFinite(u)?String(u):t?t(u):"null";case"boolean":return u===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(u);default:return t?t(u):void 0}}function m(p,u,y){if(arguments.length>1){let w="";if(typeof y=="number"?w=" ".repeat(Math.min(y,10)):typeof y=="string"&&(w=y.slice(0,10)),u!=null){if(typeof u=="function")return c("",{"":p},[],u,w,"");if(Array.isArray(u))return h("",p,[],J0(u),w,"")}if(w.length!==0)return l("",p,[],w,"")}return f("",p,[])}return m}});var Yf=k((_R,Jf)=>{d();var _o=Symbol.for("pino.metadata"),{levels:Vf}=si(),Hf=Object.create(Vf);Hf.silent=1/0;var X0=Vf.info;function Q0(e,t){let r=0;e=e||[],t=t||{dedupe:!1};let n=Hf;t.levels&&typeof t.levels=="object"&&(n=t.levels);let i={write:s,add:a,flushSync:o,end:c,minLevel:0,streams:[],clone:h,[_o]:!0};return Array.isArray(e)?e.forEach(a,i):a.call(i,e),e=null,i;function s(l){let f,m=this.lastLevel,{streams:p}=this,u;for(let y=0;y<p.length&&(f=p[y],f.level<=m);y++){if(u=f.stream,u[_o]){let{lastTime:w,lastMsg:S,lastObj:b,lastLogger:_}=this;u.lastLevel=m,u.lastTime=w,u.lastMsg=S,u.lastObj=b,u.lastLogger=_;}(!t.dedupe||f.level===m)&&u.write(l);}}function o(){for(let{stream:l}of this.streams)typeof l.flushSync=="function"&&l.flushSync();}function a(l){if(!l)return i;let f=typeof l.write=="function"||l.stream,m=l.write?l:l.stream;if(!f)throw Error("stream object needs to implement either StreamEntry or DestinationStream interface");let{streams:p}=this,u;typeof l.levelVal=="number"?u=l.levelVal:typeof l.level=="string"?u=n[l.level]:typeof l.level=="number"?u=l.level:u=X0;let y={stream:m,level:u,levelVal:void 0,id:r++};return p.unshift(y),p.sort(Z0),this.minLevel=p[0].level,i}function c(){for(let{stream:l}of this.streams)typeof l.flushSync=="function"&&l.flushSync(),l.end();}function h(l){let f=new Array(this.streams.length);for(let m=0;m<f.length;m++)f[m]={level:l,stream:this.streams[m].stream};return {write:s,add:a,minLevel:l,streams:f,clone:h,flushSync:o,[_o]:!0}}}function Z0(e,t){return e.level-t.level}Jf.exports=Q0;});var xo=k((vR,We)=>{d();var e_=$("os"),ih=Ls(),t_=Ms(),r_=js(),sh=ju(),n_=jf(),oh=ir(),{configure:i_}=Gf(),{assertDefaultLevelFound:s_,mappings:ah,genLsCache:o_,levels:a_}=si(),{createArgsNormalizer:c_,asChindings:l_,final:u_,buildSafeSonicBoom:Xf,buildFormatters:f_,stringify:oi,normalizeDestFileDescriptor:Qf,noop:h_}=ii(),{version:d_}=ho(),{chindingsSym:Zf,redactFmtSym:p_,serializersSym:eh,timeSym:g_,timeSliceIndexSym:m_,streamSym:y_,stringifySym:th,stringifySafeSym:Eo,stringifiersSym:rh,setLevelSym:w_,endSym:b_,formatOptsSym:S_,messageKeySym:__,nestedKeySym:E_,mixinSym:v_,useOnlyCustomLevelsSym:x_,formattersSym:nh,hooksSym:C_,nestedKeyStrSym:I_,mixinMergeStrategySym:D_}=oh,{epochTime:ch,nullTime:A_}=sh,{pid:O_}=process,T_=e_.hostname(),R_=ih.err,P_={level:"info",levels:a_,messageKey:"msg",nestedKey:null,enabled:!0,prettyPrint:!1,base:{pid:O_,hostname:T_},serializers:Object.assign(Object.create(null),{err:R_}),formatters:Object.assign(Object.create(null),{bindings(e){return e},level(e,t){return {level:t}}}),hooks:{logMethod:void 0},timestamp:ch,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100},N_=c_(P_),L_=Object.assign(Object.create(null),ih);function vo(...e){let t={},{opts:r,stream:n}=N_(t,t_(),...e),{redact:i,crlf:s,serializers:o,timestamp:a,messageKey:c,nestedKey:h,base:l,name:f,level:m,customLevels:p,mixin:u,mixinMergeStrategy:y,useOnlyCustomLevels:w,formatters:S,hooks:b,depthLimit:_,edgeLimit:C}=r,T=i_({maximumDepth:_,maximumBreadth:C}),M=f_(S.level,S.bindings,S.log),v=i?r_(i,oi):{},I=oi.bind({[Eo]:T}),B=i?{stringify:v[p_]}:{stringify:I},R="}"+(s?`\r
|
|
122
|
+
`:`
|
|
123
|
+
`),A=l_.bind(null,{[Zf]:"",[eh]:o,[rh]:v,[th]:oi,[Eo]:T,[nh]:M}),D="";l!==null&&(f===void 0?D=A(l):D=A(Object.assign({},l,{name:f})));let O=a instanceof Function?a:a?ch:A_,L=O().indexOf(":")+1;if(w&&!p)throw Error("customLevels is required if useOnlyCustomLevels is set true");if(u&&typeof u!="function")throw Error(`Unknown mixin type "${typeof u}" - expected "function"`);s_(m,p,w);let K=ah(p,w);return Object.assign(t,{levels:K,[x_]:w,[y_]:n,[g_]:O,[m_]:L,[th]:oi,[Eo]:T,[rh]:v,[b_]:R,[S_]:B,[__]:c,[E_]:h,[I_]:h?`,${JSON.stringify(h)}:{`:"",[eh]:o,[v_]:u,[D_]:y,[Zf]:D,[nh]:M,[C_]:b,silent:h_}),Object.setPrototypeOf(t,n_()),o_(t),t[w_](m),t}We.exports=vo;We.exports.destination=(e=process.stdout.fd)=>typeof e=="object"?(e.dest=Qf(e.dest||process.stdout.fd),Xf(e)):Xf({dest:Qf(e),minLength:0,sync:!0});We.exports.transport=to();We.exports.multistream=Yf();We.exports.final=u_;We.exports.levels=ah();We.exports.stdSerializers=L_;We.exports.stdTimeFunctions=Object.assign({},sh);We.exports.symbols=oh;We.exports.version=d_;We.exports.default=vo;We.exports.pino=vo;});var dh=k(fi=>{d();Object.defineProperty(fi,"__esModule",{value:!0});fi.BrowserRandomSource=void 0;var hh=65536,Ro=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let t=typeof self!="undefined"?self.crypto||self.msCrypto:null;t&&t.getRandomValues!==void 0&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0);}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let r=new Uint8Array(t);for(let n=0;n<r.length;n+=hh)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,hh)));return r}};fi.BrowserRandomSource=Ro;});var Wr=k(Po=>{d();Object.defineProperty(Po,"__esModule",{value:!0});function G_(e){for(var t=0;t<e.length;t++)e[t]=0;return e}Po.wipe=G_;});var ph=k(hi=>{d();Object.defineProperty(hi,"__esModule",{value:!0});hi.NodeRandomSource=void 0;var V_=Wr(),No=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof $!="undefined"){let t=$("crypto");t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0);}}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(t);if(r.length!==t)throw new Error("NodeRandomSource: got fewer bytes than requested");let n=new Uint8Array(t);for(let i=0;i<n.length;i++)n[i]=r[i];return (0, V_.wipe)(r),n}};hi.NodeRandomSource=No;});var gh=k(di=>{d();Object.defineProperty(di,"__esModule",{value:!0});di.SystemRandomSource=void 0;var H_=dh(),J_=ph(),Lo=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new H_.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new J_.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}};di.SystemRandomSource=Lo;});var mh=k(Ke=>{d();Object.defineProperty(Ke,"__esModule",{value:!0});function Y_(e,t){var r=e>>>16&65535,n=e&65535,i=t>>>16&65535,s=t&65535;return n*s+(r*s+n*i<<16>>>0)|0}Ke.mul=Math.imul||Y_;function X_(e,t){return e+t|0}Ke.add=X_;function Q_(e,t){return e-t|0}Ke.sub=Q_;function Z_(e,t){return e<<t|e>>>32-t}Ke.rotl=Z_;function eE(e,t){return e<<32-t|e>>>t}Ke.rotr=eE;function tE(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e}Ke.isInteger=Number.isInteger||tE;Ke.MAX_SAFE_INTEGER=9007199254740991;Ke.isSafeInteger=function(e){return Ke.isInteger(e)&&e>=-Ke.MAX_SAFE_INTEGER&&e<=Ke.MAX_SAFE_INTEGER};});var Uo=k(G=>{d();Object.defineProperty(G,"__esModule",{value:!0});var yh=mh();function rE(e,t){return t===void 0&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16}G.readInt16BE=rE;function nE(e,t){return t===void 0&&(t=0),(e[t+0]<<8|e[t+1])>>>0}G.readUint16BE=nE;function iE(e,t){return t===void 0&&(t=0),(e[t+1]<<8|e[t])<<16>>16}G.readInt16LE=iE;function sE(e,t){return t===void 0&&(t=0),(e[t+1]<<8|e[t])>>>0}G.readUint16LE=sE;function wh(e,t,r){return t===void 0&&(t=new Uint8Array(2)),r===void 0&&(r=0),t[r+0]=e>>>8,t[r+1]=e>>>0,t}G.writeUint16BE=wh;G.writeInt16BE=wh;function bh(e,t,r){return t===void 0&&(t=new Uint8Array(2)),r===void 0&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t}G.writeUint16LE=bh;G.writeInt16LE=bh;function Mo(e,t){return t===void 0&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}G.readInt32BE=Mo;function Fo(e,t){return t===void 0&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}G.readUint32BE=Fo;function Bo(e,t){return t===void 0&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}G.readInt32LE=Bo;function ko(e,t){return t===void 0&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}G.readUint32LE=ko;function pi(e,t,r){return t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0),t[r+0]=e>>>24,t[r+1]=e>>>16,t[r+2]=e>>>8,t[r+3]=e>>>0,t}G.writeUint32BE=pi;G.writeInt32BE=pi;function gi(e,t,r){return t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24,t}G.writeUint32LE=gi;G.writeInt32LE=gi;function oE(e,t){t===void 0&&(t=0);var r=Mo(e,t),n=Mo(e,t+4);return r*4294967296+n-(n>>31)*4294967296}G.readInt64BE=oE;function aE(e,t){t===void 0&&(t=0);var r=Fo(e,t),n=Fo(e,t+4);return r*4294967296+n}G.readUint64BE=aE;function cE(e,t){t===void 0&&(t=0);var r=Bo(e,t),n=Bo(e,t+4);return n*4294967296+r-(r>>31)*4294967296}G.readInt64LE=cE;function lE(e,t){t===void 0&&(t=0);var r=ko(e,t),n=ko(e,t+4);return n*4294967296+r}G.readUint64LE=lE;function Sh(e,t,r){return t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0),pi(e/4294967296>>>0,t,r),pi(e>>>0,t,r+4),t}G.writeUint64BE=Sh;G.writeInt64BE=Sh;function _h(e,t,r){return t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0),gi(e>>>0,t,r),gi(e/4294967296>>>0,t,r+4),t}G.writeUint64LE=_h;G.writeInt64LE=_h;function uE(e,t,r){if(r===void 0&&(r=0),e%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=e/8+r-1;s>=r;s--)n+=t[s]*i,i*=256;return n}G.readUintBE=uE;function fE(e,t,r){if(r===void 0&&(r=0),e%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+e/8;s++)n+=t[s]*i,i*=256;return n}G.readUintLE=fE;function hE(e,t,r,n){if(r===void 0&&(r=new Uint8Array(e/8)),n===void 0&&(n=0),e%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!yh.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var i=1,s=e/8+n-1;s>=n;s--)r[s]=t/i&255,i*=256;return r}G.writeUintBE=hE;function dE(e,t,r,n){if(r===void 0&&(r=new Uint8Array(e/8)),n===void 0&&(n=0),e%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!yh.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+e/8;s++)r[s]=t/i&255,i*=256;return r}G.writeUintLE=dE;function pE(e,t){t===void 0&&(t=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getFloat32(t)}G.readFloat32BE=pE;function gE(e,t){t===void 0&&(t=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getFloat32(t,!0)}G.readFloat32LE=gE;function mE(e,t){t===void 0&&(t=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getFloat64(t)}G.readFloat64BE=mE;function yE(e,t){t===void 0&&(t=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getFloat64(t,!0)}G.readFloat64LE=yE;function wE(e,t,r){t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat32(r,e),t}G.writeFloat32BE=wE;function bE(e,t,r){t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat32(r,e,!0),t}G.writeFloat32LE=bE;function SE(e,t,r){t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat64(r,e),t}G.writeFloat64BE=SE;function _E(e,t,r){t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat64(r,e,!0),t}G.writeFloat64LE=_E;});var Ko=k(xe=>{d();Object.defineProperty(xe,"__esModule",{value:!0});xe.randomStringForEntropy=xe.randomString=xe.randomUint32=xe.randomBytes=xe.defaultRandomSource=void 0;var EE=gh(),vE=Uo(),Eh=Wr();xe.defaultRandomSource=new EE.SystemRandomSource;function Wo(e,t=xe.defaultRandomSource){return t.randomBytes(e)}xe.randomBytes=Wo;function xE(e=xe.defaultRandomSource){let t=Wo(4,e),r=(0, vE.readUint32LE)(t);return (0, Eh.wipe)(t),r}xe.randomUint32=xE;var vh="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function xh(e,t=vh,r=xe.defaultRandomSource){if(t.length<2)throw new Error("randomString charset is too short");if(t.length>256)throw new Error("randomString charset is too long");let n="",i=t.length,s=256-256%i;for(;e>0;){let o=Wo(Math.ceil(e*256/s),r);for(let a=0;a<o.length&&e>0;a++){let c=o[a];c<s&&(n+=t.charAt(c%i),e--);}(0, Eh.wipe)(o);}return n}xe.randomString=xh;function CE(e,t=vh,r=xe.defaultRandomSource){let n=Math.ceil(e/(Math.log(t.length)/Math.LN2));return xh(n,t,r)}xe.randomStringForEntropy=CE;});var Dh=k(ft=>{d();Object.defineProperty(ft,"__esModule",{value:!0});var cr=Uo(),ar=Wr();ft.DIGEST_LENGTH=64;ft.BLOCK_SIZE=128;var Ih=function(){function e(){this.digestLength=ft.DIGEST_LENGTH,this.blockSize=ft.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 e.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;},e.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},e.prototype.clean=function(){ar.wipe(this._buffer),ar.wipe(this._tempHi),ar.wipe(this._tempLo),this.reset();},e.prototype.update=function(t,r){if(r===void 0&&(r=t.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var n=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength<ft.BLOCK_SIZE&&r>0;)this._buffer[this._bufferLength++]=t[n++],r--;this._bufferLength===this.blockSize&&(jo(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0);}for(r>=this.blockSize&&(n=jo(this._tempHi,this._tempLo,this._stateHi,this._stateLo,t,n,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=t[n++],r--;return this},e.prototype.finish=function(t){if(!this._finished){var r=this._bytesHashed,n=this._bufferLength,i=r/536870912|0,s=r<<3,o=r%128<112?128:256;this._buffer[n]=128;for(var a=n+1;a<o-8;a++)this._buffer[a]=0;cr.writeUint32BE(i,this._buffer,o-8),cr.writeUint32BE(s,this._buffer,o-4),jo(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,o),this._finished=!0;}for(var a=0;a<this.digestLength/8;a++)cr.writeUint32BE(this._stateHi[a],t,a*8),cr.writeUint32BE(this._stateLo[a],t,a*8+4);return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.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}},e.prototype.restoreState=function(t){return this._stateHi.set(t.stateHi),this._stateLo.set(t.stateLo),this._bufferLength=t.bufferLength,t.buffer&&this._buffer.set(t.buffer),this._bytesHashed=t.bytesHashed,this._finished=!1,this},e.prototype.cleanSavedState=function(t){ar.wipe(t.stateHi),ar.wipe(t.stateLo),t.buffer&&ar.wipe(t.buffer),t.bufferLength=0,t.bytesHashed=0;},e}();ft.SHA512=Ih;var Ch=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 jo(e,t,r,n,i,s,o){for(var a=r[0],c=r[1],h=r[2],l=r[3],f=r[4],m=r[5],p=r[6],u=r[7],y=n[0],w=n[1],S=n[2],b=n[3],_=n[4],C=n[5],T=n[6],M=n[7],v,I,B,R,A,D,O,L;o>=128;){for(var K=0;K<16;K++){var q=8*K+s;e[K]=cr.readUint32BE(i,q),t[K]=cr.readUint32BE(i,q+4);}for(var K=0;K<80;K++){var ye=a,Ae=c,Me=h,V=l,ie=f,se=m,Y=p,oe=u,ee=y,le=w,ue=S,ne=b,de=_,fe=C,X=T,pe=M;if(v=u,I=M,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=(f>>>14|_<<32-14)^(f>>>18|_<<32-18)^(_>>>41-32|f<<32-(41-32)),I=(_>>>14|f<<32-14)^(_>>>18|f<<32-18)^(f>>>41-32|_<<32-(41-32)),A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,v=f&m^~f&p,I=_&C^~_&T,A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,v=Ch[K*2],I=Ch[K*2+1],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,v=e[K%16],I=t[K%16],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,B=O&65535|L<<16,R=A&65535|D<<16,v=B,I=R,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=(a>>>28|y<<32-28)^(y>>>34-32|a<<32-(34-32))^(y>>>39-32|a<<32-(39-32)),I=(y>>>28|a<<32-28)^(a>>>34-32|y<<32-(34-32))^(a>>>39-32|y<<32-(39-32)),A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,v=a&c^a&h^c&h,I=y&w^y&S^w&S,A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,oe=O&65535|L<<16,pe=A&65535|D<<16,v=V,I=ne,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=B,I=R,A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,V=O&65535|L<<16,ne=A&65535|D<<16,c=ye,h=Ae,l=Me,f=V,m=ie,p=se,u=Y,a=oe,w=ee,S=le,b=ue,_=ne,C=de,T=fe,M=X,y=pe,K%16===15)for(var q=0;q<16;q++)v=e[q],I=t[q],A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=e[(q+9)%16],I=t[(q+9)%16],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,B=e[(q+1)%16],R=t[(q+1)%16],v=(B>>>1|R<<32-1)^(B>>>8|R<<32-8)^B>>>7,I=(R>>>1|B<<32-1)^(R>>>8|B<<32-8)^(R>>>7|B<<32-7),A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,B=e[(q+14)%16],R=t[(q+14)%16],v=(B>>>19|R<<32-19)^(R>>>61-32|B<<32-(61-32))^B>>>6,I=(R>>>19|B<<32-19)^(B>>>61-32|R<<32-(61-32))^(R>>>6|B<<32-6),A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,e[q]=O&65535|L<<16,t[q]=A&65535|D<<16;}v=a,I=y,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=r[0],I=n[0],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,r[0]=a=O&65535|L<<16,n[0]=y=A&65535|D<<16,v=c,I=w,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=r[1],I=n[1],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,r[1]=c=O&65535|L<<16,n[1]=w=A&65535|D<<16,v=h,I=S,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=r[2],I=n[2],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,r[2]=h=O&65535|L<<16,n[2]=S=A&65535|D<<16,v=l,I=b,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=r[3],I=n[3],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,r[3]=l=O&65535|L<<16,n[3]=b=A&65535|D<<16,v=f,I=_,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=r[4],I=n[4],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,r[4]=f=O&65535|L<<16,n[4]=_=A&65535|D<<16,v=m,I=C,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=r[5],I=n[5],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,r[5]=m=O&65535|L<<16,n[5]=C=A&65535|D<<16,v=p,I=T,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=r[6],I=n[6],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,r[6]=p=O&65535|L<<16,n[6]=T=A&65535|D<<16,v=u,I=M,A=I&65535,D=I>>>16,O=v&65535,L=v>>>16,v=r[7],I=n[7],A+=I&65535,D+=I>>>16,O+=v&65535,L+=v>>>16,D+=A>>>16,O+=D>>>16,L+=O>>>16,r[7]=u=O&65535|L<<16,n[7]=M=A&65535|D<<16,s+=128,o-=128;}return s}function IE(e){var t=new Ih;t.update(e);var r=t.digest();return t.clean(),r}ft.hash=IE;});var Kh=k(H=>{d();Object.defineProperty(H,"__esModule",{value:!0});H.convertSecretKeyToX25519=H.convertPublicKeyToX25519=H.verify=H.sign=H.extractPublicKeyFromSecretKey=H.generateKeyPair=H.generateKeyPairFromSeed=H.SEED_LENGTH=H.SECRET_KEY_LENGTH=H.PUBLIC_KEY_LENGTH=H.SIGNATURE_LENGTH=void 0;var DE=Ko(),Kr=Dh(),Ph=Wr();H.SIGNATURE_LENGTH=64;H.PUBLIC_KEY_LENGTH=32;H.SECRET_KEY_LENGTH=64;H.SEED_LENGTH=32;function j(e){let t=new Float64Array(16);if(e)for(let r=0;r<e.length;r++)t[r]=e[r];return t}var AE=new Uint8Array(32);AE[0]=9;var qo=j(),lr=j([1]),OE=j([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),TE=j([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Ah=j([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Oh=j([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),RE=j([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function St(e,t){for(let r=0;r<16;r++)e[r]=t[r]|0;}function zo(e){let t=1;for(let r=0;r<16;r++){let n=e[r]+t+65535;t=Math.floor(n/65536),e[r]=n-t*65536;}e[0]+=t-1+37*(t-1);}function Nh(e,t,r){let n=~(r-1);for(let i=0;i<16;i++){let s=n&(e[i]^t[i]);e[i]^=s,t[i]^=s;}}function jr(e,t){let r=j(),n=j();for(let i=0;i<16;i++)n[i]=t[i];zo(n),zo(n),zo(n);for(let i=0;i<2;i++){r[0]=n[0]-65517;for(let o=1;o<15;o++)r[o]=n[o]-65535-(r[o-1]>>16&1),r[o-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);let s=r[15]>>16&1;r[14]&=65535,Nh(n,r,1-s);}for(let i=0;i<16;i++)e[2*i]=n[i]&255,e[2*i+1]=n[i]>>8;}function Lh(e,t){let r=0;for(let n=0;n<32;n++)r|=e[n]^t[n];return (1&r-1>>>8)-1}function Th(e,t){let r=new Uint8Array(32),n=new Uint8Array(32);return jr(r,e),jr(n,t),Lh(r,n)}function Mh(e){let t=new Uint8Array(32);return jr(t,e),t[0]&1}function PE(e,t){for(let r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767;}function kt(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]+r[n];}function Wt(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n];}function Z(e,t,r){let n,i,s=0,o=0,a=0,c=0,h=0,l=0,f=0,m=0,p=0,u=0,y=0,w=0,S=0,b=0,_=0,C=0,T=0,M=0,v=0,I=0,B=0,R=0,A=0,D=0,O=0,L=0,K=0,q=0,ye=0,Ae=0,Me=0,V=r[0],ie=r[1],se=r[2],Y=r[3],oe=r[4],ee=r[5],le=r[6],ue=r[7],ne=r[8],de=r[9],fe=r[10],X=r[11],pe=r[12],_e=r[13],Ee=r[14],ve=r[15];n=t[0],s+=n*V,o+=n*ie,a+=n*se,c+=n*Y,h+=n*oe,l+=n*ee,f+=n*le,m+=n*ue,p+=n*ne,u+=n*de,y+=n*fe,w+=n*X,S+=n*pe,b+=n*_e,_+=n*Ee,C+=n*ve,n=t[1],o+=n*V,a+=n*ie,c+=n*se,h+=n*Y,l+=n*oe,f+=n*ee,m+=n*le,p+=n*ue,u+=n*ne,y+=n*de,w+=n*fe,S+=n*X,b+=n*pe,_+=n*_e,C+=n*Ee,T+=n*ve,n=t[2],a+=n*V,c+=n*ie,h+=n*se,l+=n*Y,f+=n*oe,m+=n*ee,p+=n*le,u+=n*ue,y+=n*ne,w+=n*de,S+=n*fe,b+=n*X,_+=n*pe,C+=n*_e,T+=n*Ee,M+=n*ve,n=t[3],c+=n*V,h+=n*ie,l+=n*se,f+=n*Y,m+=n*oe,p+=n*ee,u+=n*le,y+=n*ue,w+=n*ne,S+=n*de,b+=n*fe,_+=n*X,C+=n*pe,T+=n*_e,M+=n*Ee,v+=n*ve,n=t[4],h+=n*V,l+=n*ie,f+=n*se,m+=n*Y,p+=n*oe,u+=n*ee,y+=n*le,w+=n*ue,S+=n*ne,b+=n*de,_+=n*fe,C+=n*X,T+=n*pe,M+=n*_e,v+=n*Ee,I+=n*ve,n=t[5],l+=n*V,f+=n*ie,m+=n*se,p+=n*Y,u+=n*oe,y+=n*ee,w+=n*le,S+=n*ue,b+=n*ne,_+=n*de,C+=n*fe,T+=n*X,M+=n*pe,v+=n*_e,I+=n*Ee,B+=n*ve,n=t[6],f+=n*V,m+=n*ie,p+=n*se,u+=n*Y,y+=n*oe,w+=n*ee,S+=n*le,b+=n*ue,_+=n*ne,C+=n*de,T+=n*fe,M+=n*X,v+=n*pe,I+=n*_e,B+=n*Ee,R+=n*ve,n=t[7],m+=n*V,p+=n*ie,u+=n*se,y+=n*Y,w+=n*oe,S+=n*ee,b+=n*le,_+=n*ue,C+=n*ne,T+=n*de,M+=n*fe,v+=n*X,I+=n*pe,B+=n*_e,R+=n*Ee,A+=n*ve,n=t[8],p+=n*V,u+=n*ie,y+=n*se,w+=n*Y,S+=n*oe,b+=n*ee,_+=n*le,C+=n*ue,T+=n*ne,M+=n*de,v+=n*fe,I+=n*X,B+=n*pe,R+=n*_e,A+=n*Ee,D+=n*ve,n=t[9],u+=n*V,y+=n*ie,w+=n*se,S+=n*Y,b+=n*oe,_+=n*ee,C+=n*le,T+=n*ue,M+=n*ne,v+=n*de,I+=n*fe,B+=n*X,R+=n*pe,A+=n*_e,D+=n*Ee,O+=n*ve,n=t[10],y+=n*V,w+=n*ie,S+=n*se,b+=n*Y,_+=n*oe,C+=n*ee,T+=n*le,M+=n*ue,v+=n*ne,I+=n*de,B+=n*fe,R+=n*X,A+=n*pe,D+=n*_e,O+=n*Ee,L+=n*ve,n=t[11],w+=n*V,S+=n*ie,b+=n*se,_+=n*Y,C+=n*oe,T+=n*ee,M+=n*le,v+=n*ue,I+=n*ne,B+=n*de,R+=n*fe,A+=n*X,D+=n*pe,O+=n*_e,L+=n*Ee,K+=n*ve,n=t[12],S+=n*V,b+=n*ie,_+=n*se,C+=n*Y,T+=n*oe,M+=n*ee,v+=n*le,I+=n*ue,B+=n*ne,R+=n*de,A+=n*fe,D+=n*X,O+=n*pe,L+=n*_e,K+=n*Ee,q+=n*ve,n=t[13],b+=n*V,_+=n*ie,C+=n*se,T+=n*Y,M+=n*oe,v+=n*ee,I+=n*le,B+=n*ue,R+=n*ne,A+=n*de,D+=n*fe,O+=n*X,L+=n*pe,K+=n*_e,q+=n*Ee,ye+=n*ve,n=t[14],_+=n*V,C+=n*ie,T+=n*se,M+=n*Y,v+=n*oe,I+=n*ee,B+=n*le,R+=n*ue,A+=n*ne,D+=n*de,O+=n*fe,L+=n*X,K+=n*pe,q+=n*_e,ye+=n*Ee,Ae+=n*ve,n=t[15],C+=n*V,T+=n*ie,M+=n*se,v+=n*Y,I+=n*oe,B+=n*ee,R+=n*le,A+=n*ue,D+=n*ne,O+=n*de,L+=n*fe,K+=n*X,q+=n*pe,ye+=n*_e,Ae+=n*Ee,Me+=n*ve,s+=38*T,o+=38*M,a+=38*v,c+=38*I,h+=38*B,l+=38*R,f+=38*A,m+=38*D,p+=38*O,u+=38*L,y+=38*K,w+=38*q,S+=38*ye,b+=38*Ae,_+=38*Me,i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-i*65536,n=o+i+65535,i=Math.floor(n/65536),o=n-i*65536,n=a+i+65535,i=Math.floor(n/65536),a=n-i*65536,n=c+i+65535,i=Math.floor(n/65536),c=n-i*65536,n=h+i+65535,i=Math.floor(n/65536),h=n-i*65536,n=l+i+65535,i=Math.floor(n/65536),l=n-i*65536,n=f+i+65535,i=Math.floor(n/65536),f=n-i*65536,n=m+i+65535,i=Math.floor(n/65536),m=n-i*65536,n=p+i+65535,i=Math.floor(n/65536),p=n-i*65536,n=u+i+65535,i=Math.floor(n/65536),u=n-i*65536,n=y+i+65535,i=Math.floor(n/65536),y=n-i*65536,n=w+i+65535,i=Math.floor(n/65536),w=n-i*65536,n=S+i+65535,i=Math.floor(n/65536),S=n-i*65536,n=b+i+65535,i=Math.floor(n/65536),b=n-i*65536,n=_+i+65535,i=Math.floor(n/65536),_=n-i*65536,n=C+i+65535,i=Math.floor(n/65536),C=n-i*65536,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-i*65536,n=o+i+65535,i=Math.floor(n/65536),o=n-i*65536,n=a+i+65535,i=Math.floor(n/65536),a=n-i*65536,n=c+i+65535,i=Math.floor(n/65536),c=n-i*65536,n=h+i+65535,i=Math.floor(n/65536),h=n-i*65536,n=l+i+65535,i=Math.floor(n/65536),l=n-i*65536,n=f+i+65535,i=Math.floor(n/65536),f=n-i*65536,n=m+i+65535,i=Math.floor(n/65536),m=n-i*65536,n=p+i+65535,i=Math.floor(n/65536),p=n-i*65536,n=u+i+65535,i=Math.floor(n/65536),u=n-i*65536,n=y+i+65535,i=Math.floor(n/65536),y=n-i*65536,n=w+i+65535,i=Math.floor(n/65536),w=n-i*65536,n=S+i+65535,i=Math.floor(n/65536),S=n-i*65536,n=b+i+65535,i=Math.floor(n/65536),b=n-i*65536,n=_+i+65535,i=Math.floor(n/65536),_=n-i*65536,n=C+i+65535,i=Math.floor(n/65536),C=n-i*65536,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=h,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=u,e[10]=y,e[11]=w,e[12]=S,e[13]=b,e[14]=_,e[15]=C;}function Ut(e,t){Z(e,t,t);}function Fh(e,t){let r=j(),n;for(n=0;n<16;n++)r[n]=t[n];for(n=253;n>=0;n--)Ut(r,r),n!==2&&n!==4&&Z(r,r,t);for(n=0;n<16;n++)e[n]=r[n];}function NE(e,t){let r=j(),n;for(n=0;n<16;n++)r[n]=t[n];for(n=250;n>=0;n--)Ut(r,r),n!==1&&Z(r,r,t);for(n=0;n<16;n++)e[n]=r[n];}function Go(e,t){let r=j(),n=j(),i=j(),s=j(),o=j(),a=j(),c=j(),h=j(),l=j();Wt(r,e[1],e[0]),Wt(l,t[1],t[0]),Z(r,r,l),kt(n,e[0],e[1]),kt(l,t[0],t[1]),Z(n,n,l),Z(i,e[3],t[3]),Z(i,i,TE),Z(s,e[2],t[2]),kt(s,s,s),Wt(o,n,r),Wt(a,s,i),kt(c,s,i),kt(h,n,r),Z(e[0],o,a),Z(e[1],h,c),Z(e[2],c,a),Z(e[3],o,h);}function Rh(e,t,r){for(let n=0;n<4;n++)Nh(e[n],t[n],r);}function Ho(e,t){let r=j(),n=j(),i=j();Fh(i,t[2]),Z(r,t[0],i),Z(n,t[1],i),jr(e,n),e[31]^=Mh(r)<<7;}function Bh(e,t,r){St(e[0],qo),St(e[1],lr),St(e[2],lr),St(e[3],qo);for(let n=255;n>=0;--n){let i=r[n/8|0]>>(n&7)&1;Rh(e,t,i),Go(t,e),Go(e,e),Rh(e,t,i);}}function Jo(e,t){let r=[j(),j(),j(),j()];St(r[0],Ah),St(r[1],Oh),St(r[2],lr),Z(r[3],Ah,Oh),Bh(e,r,t);}function kh(e){if(e.length!==H.SEED_LENGTH)throw new Error(`ed25519: seed must be ${H.SEED_LENGTH} bytes`);let t=(0, Kr.hash)(e);t[0]&=248,t[31]&=127,t[31]|=64;let r=new Uint8Array(32),n=[j(),j(),j(),j()];Jo(n,t),Ho(r,n);let i=new Uint8Array(64);return i.set(e),i.set(r,32),{publicKey:r,secretKey:i}}H.generateKeyPairFromSeed=kh;function LE(e){let t=(0, DE.randomBytes)(32,e),r=kh(t);return (0, Ph.wipe)(t),r}H.generateKeyPair=LE;function ME(e){if(e.length!==H.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${H.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(e.subarray(32))}H.extractPublicKeyFromSecretKey=ME;var $o=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 Uh(e,t){let r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i<s;++i)t[i]+=r-16*t[n]*$o[i-(n-32)],r=Math.floor((t[i]+128)/256),t[i]-=r*256;t[i]+=r,t[n]=0;}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*$o[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*$o[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=t[n]&255;}function Vo(e){let t=new Float64Array(64);for(let r=0;r<64;r++)t[r]=e[r];for(let r=0;r<64;r++)e[r]=0;Uh(e,t);}function FE(e,t){let r=new Float64Array(64),n=[j(),j(),j(),j()],i=(0, Kr.hash)(e.subarray(0,32));i[0]&=248,i[31]&=127,i[31]|=64;let s=new Uint8Array(64);s.set(i.subarray(32),32);let o=new Kr.SHA512;o.update(s.subarray(32)),o.update(t);let a=o.digest();o.clean(),Vo(a),Jo(n,a),Ho(s,n),o.reset(),o.update(s.subarray(0,32)),o.update(e.subarray(32)),o.update(t);let c=o.digest();Vo(c);for(let h=0;h<32;h++)r[h]=a[h];for(let h=0;h<32;h++)for(let l=0;l<32;l++)r[h+l]+=c[h]*i[l];return Uh(s.subarray(32),r),s}H.sign=FE;function Wh(e,t){let r=j(),n=j(),i=j(),s=j(),o=j(),a=j(),c=j();return St(e[2],lr),PE(e[1],t),Ut(i,e[1]),Z(s,i,OE),Wt(i,i,e[2]),kt(s,e[2],s),Ut(o,s),Ut(a,o),Z(c,a,o),Z(r,c,i),Z(r,r,s),NE(r,r),Z(r,r,i),Z(r,r,s),Z(r,r,s),Z(e[0],r,s),Ut(n,e[0]),Z(n,n,s),Th(n,i)&&Z(e[0],e[0],RE),Ut(n,e[0]),Z(n,n,s),Th(n,i)?-1:(Mh(e[0])===t[31]>>7&&Wt(e[0],qo,e[0]),Z(e[3],e[0],e[1]),0)}function BE(e,t,r){let n=new Uint8Array(32),i=[j(),j(),j(),j()],s=[j(),j(),j(),j()];if(r.length!==H.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${H.SIGNATURE_LENGTH} bytes`);if(Wh(s,e))return !1;let o=new Kr.SHA512;o.update(r.subarray(0,32)),o.update(e),o.update(t);let a=o.digest();return Vo(a),Bh(i,s,a),Jo(s,r.subarray(32)),Go(i,s),Ho(n,i),!Lh(r,n)}H.verify=BE;function kE(e){let t=[j(),j(),j(),j()];if(Wh(t,e))throw new Error("Ed25519: invalid public key");let r=j(),n=j(),i=t[1];kt(r,lr,i),Wt(n,lr,i),Fh(n,n),Z(r,r,n);let s=new Uint8Array(32);return jr(s,r),s}H.convertPublicKeyToX25519=kE;function UE(e){let t=(0, Kr.hash)(e.subarray(0,32));t[0]&=248,t[31]&=127,t[31]|=64;let r=new Uint8Array(t.subarray(0,32));return (0, Ph.wipe)(t),r}H.convertSecretKeyToX25519=UE;});var Td=k(vt=>{d();Object.defineProperty(vt,"__esModule",{value:!0});vt.isBrowserCryptoAvailable=vt.getSubtleCrypto=vt.getBrowerCrypto=void 0;function Ca(){return (global==null?void 0:global.crypto)||(global==null?void 0:global.msCrypto)||{}}vt.getBrowerCrypto=Ca;function Od(){let e=Ca();return e.subtle||e.webkitSubtle}vt.getSubtleCrypto=Od;function nx(){return !!Ca()&&!!Od()}vt.isBrowserCryptoAvailable=nx;});var Nd=k(xt=>{d();Object.defineProperty(xt,"__esModule",{value:!0});xt.isBrowser=xt.isNode=xt.isReactNative=void 0;function Rd(){return typeof document=="undefined"&&typeof navigator!="undefined"&&navigator.product==="ReactNative"}xt.isReactNative=Rd;function Pd(){return typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined"}xt.isNode=Pd;function ix(){return !Rd()&&!Pd()}xt.isBrowser=ix;});var Ia=k(Ri=>{d();Object.defineProperty(Ri,"__esModule",{value:!0});var Ld=(er(),Or(Zt));Ld.__exportStar(Td(),Ri);Ld.__exportStar(Nd(),Ri);});var $t=k((dL,Ud)=>{d();Ud.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),EMPTY_BUFFER:Buffer.alloc(0),NOOP:()=>{}};});var tp=k((gL,ep)=>{d();var zd=$("fs"),ht=$("path"),$d=$("os"),qd=typeof __webpack_require__=="function"?__non_webpack_require__:$,px=process.config&&process.config.variables||{},gx=!!process.env.PREBUILDS_ONLY,Wd=process.versions.modules,Ra=wx()?"electron":yx()?"node-webkit":"node",Pa=process.env.npm_config_arch||$d.arch(),Na=process.env.npm_config_platform||$d.platform(),Gd=process.env.LIBC||(bx(Na)?"musl":"glibc"),La=process.env.ARM_VERSION||(Pa==="arm64"?"8":px.arm_version)||"",Vd=(process.versions.uv||"").split(".")[0];ep.exports=nt;function nt(e){return qd(nt.resolve(e))}nt.resolve=nt.path=function(e){e=ht.resolve(e||".");try{var t=qd(ht.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[t+"_PREBUILD"]&&(e=process.env[t+"_PREBUILD"]);}catch(c){}if(!gx){var r=Kd(ht.join(e,"build/Release"),jd);if(r)return r;var n=Kd(ht.join(e,"build/Debug"),jd);if(n)return n}var i=a(e);if(i)return i;var s=a(ht.dirname(process.execPath));if(s)return s;var o=["platform="+Na,"arch="+Pa,"runtime="+Ra,"abi="+Wd,"uv="+Vd,La?"armv="+La:"","libc="+Gd,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+o+`
|
|
124
|
+
loaded from: `+e+`
|
|
125
|
+
`);function a(c){var h=Ma(ht.join(c,"prebuilds")).map(Hd),l=h.filter(Jd(Na,Pa)).sort(Yd)[0];if(l){var f=ht.join(c,"prebuilds",l.name),m=Ma(f).map(Xd),p=m.filter(Qd(Ra,Wd)),u=p.sort(Zd(Ra))[0];if(u)return ht.join(f,u.file)}}};function Ma(e){try{return zd.readdirSync(e)}catch(t){return []}}function Kd(e,t){var r=Ma(e).filter(t);return r[0]&&ht.join(e,r[0])}function jd(e){return /\.node$/.test(e)}function Hd(e){var t=e.split("-");if(t.length===2){var r=t[0],n=t[1].split("+");if(r&&n.length&&n.every(Boolean))return {name:e,platform:r,architectures:n}}}function Jd(e,t){return function(r){return r==null||r.platform!==e?!1:r.architectures.includes(t)}}function Yd(e,t){return e.architectures.length-t.architectures.length}function Xd(e){var t=e.split("."),r=t.pop(),n={file:e,specificity:0};if(r==="node"){for(var i=0;i<t.length;i++){var s=t[i];if(s==="node"||s==="electron"||s==="node-webkit")n.runtime=s;else if(s==="napi")n.napi=!0;else if(s.slice(0,3)==="abi")n.abi=s.slice(3);else if(s.slice(0,2)==="uv")n.uv=s.slice(2);else if(s.slice(0,4)==="armv")n.armv=s.slice(4);else if(s==="glibc"||s==="musl")n.libc=s;else continue;n.specificity++;}return n}}function Qd(e,t){return function(r){return !(r==null||r.runtime&&r.runtime!==e&&!mx(r)||r.abi&&r.abi!==t&&!r.napi||r.uv&&r.uv!==Vd||r.armv&&r.armv!==La||r.libc&&r.libc!==Gd)}}function mx(e){return e.runtime==="node"&&e.napi}function Zd(e){return function(t,r){return t.runtime!==r.runtime?t.runtime===e?-1:1:t.abi!==r.abi?t.abi?-1:1:t.specificity!==r.specificity?t.specificity>r.specificity?-1:1:0}}function yx(){return !!(process.versions&&process.versions.nw)}function wx(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window!="undefined"&&window.process&&window.process.type==="renderer"}function bx(e){return e==="linux"&&zd.existsSync("/etc/alpine-release")}nt.parseTags=Xd;nt.matchTags=Qd;nt.compareTags=Zd;nt.parseTuple=Hd;nt.matchTuple=Jd;nt.compareTuples=Yd;});var ka=k((wL,Ba)=>{d();var Fa=typeof __webpack_require__=="function"?__non_webpack_require__:$;typeof Fa.addon=="function"?Ba.exports=Fa.addon.bind(Fa):Ba.exports=tp();});var np=k((_L,rp)=>{d();var Sx=(e,t,r,n,i)=>{for(var s=0;s<i;s++)r[n+s]=e[s]^t[s&3];},_x=(e,t)=>{let r=e.length;for(var n=0;n<r;n++)e[n]^=t[n&3];};rp.exports={mask:Sx,unmask:_x};});var ip=k((vL,Ua)=>{d();try{Ua.exports=ka()(E);}catch(e){Ua.exports=np();}});var rn=k((CL,Wa)=>{d();var{EMPTY_BUFFER:Ex}=$t();function sp(e,t){if(e.length===0)return Ex;if(e.length===1)return e[0];let r=Buffer.allocUnsafe(t),n=0;for(let i=0;i<e.length;i++){let s=e[i];r.set(s,n),n+=s.length;}return n<t?r.slice(0,n):r}function op(e,t,r,n,i){for(let s=0;s<i;s++)r[n+s]=e[s]^t[s&3];}function ap(e,t){let r=e.length;for(let n=0;n<r;n++)e[n]^=t[n&3];}function cp(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function Wi(e){if(Wi.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=Buffer.from(e):ArrayBuffer.isView(e)?t=Buffer.from(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),Wi.readOnly=!1),t}try{let e=ip(),t=e.BufferUtil||e;Wa.exports={concat:sp,mask(r,n,i,s,o){o<48?op(r,n,i,s,o):t.mask(r,n,i,s,o);},toArrayBuffer:cp,toBuffer:Wi,unmask(r,n){r.length<32?ap(r,n):t.unmask(r,n);}};}catch(e){Wa.exports={concat:sp,mask:op,toArrayBuffer:cp,toBuffer:Wi,unmask:ap};}});var fp=k((DL,up)=>{d();var lp=Symbol("kDone"),Ka=Symbol("kRun"),ja=class{constructor(t){this[lp]=()=>{this.pending--,this[Ka]();},this.concurrency=t||1/0,this.jobs=[],this.pending=0;}add(t){this.jobs.push(t),this[Ka]();}[Ka](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[lp]);}}};up.exports=ja;});var on=k((OL,gp)=>{d();var nn=$("zlib"),hp=rn(),vx=fp(),{kStatusCode:dp,NOOP:xx}=$t(),Cx=Buffer.from([0,0,255,255]),zi=Symbol("permessage-deflate"),dt=Symbol("total-length"),sn=Symbol("callback"),Ct=Symbol("buffers"),ji=Symbol("error"),Ki,za=class{constructor(t,r,n){if(this._maxPayload=n|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!r,this._deflate=null,this._inflate=null,this.params=null,!Ki){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Ki=new vx(i);}}static get extensionName(){return "permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[sn];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"));}}acceptAsServer(t){let r=this._options,n=t.find(i=>!(r.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>i.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(t){let r=t[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(t){return t.forEach(r=>{Object.keys(r).forEach(n=>{let i=r[n];if(i.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(i=i[0],n==="client_max_window_bits"){if(i!==!0){let s=+i;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${n}": ${i}`);i=s;}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${i}`)}else if(n==="server_max_window_bits"){let s=+i;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${n}": ${i}`);i=s;}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${i}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=i;});}),t}decompress(t,r,n){Ki.add(i=>{this._decompress(t,r,(s,o)=>{i(),n(s,o);});});}compress(t,r,n){Ki.add(i=>{this._compress(t,r,(s,o)=>{i(),n(s,o);});});}_decompress(t,r,n){let i=this._isServer?"client":"server";if(!this._inflate){let s=`${i}_max_window_bits`,o=typeof this.params[s]!="number"?nn.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=nn.createInflateRaw(Q(F({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[zi]=this,this._inflate[dt]=0,this._inflate[Ct]=[],this._inflate.on("error",Dx),this._inflate.on("data",pp);}this._inflate[sn]=n,this._inflate.write(t),r&&this._inflate.write(Cx),this._inflate.flush(()=>{let s=this._inflate[ji];if(s){this._inflate.close(),this._inflate=null,n(s);return}let o=hp.concat(this._inflate[Ct],this._inflate[dt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[dt]=0,this._inflate[Ct]=[],r&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),n(null,o);});}_compress(t,r,n){let i=this._isServer?"server":"client";if(!this._deflate){let s=`${i}_max_window_bits`,o=typeof this.params[s]!="number"?nn.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=nn.createDeflateRaw(Q(F({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[dt]=0,this._deflate[Ct]=[],this._deflate.on("error",xx),this._deflate.on("data",Ix);}this._deflate[sn]=n,this._deflate.write(t),this._deflate.flush(nn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=hp.concat(this._deflate[Ct],this._deflate[dt]);r&&(s=s.slice(0,s.length-4)),this._deflate[sn]=null,this._deflate[dt]=0,this._deflate[Ct]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,s);});}};gp.exports=za;function Ix(e){this[Ct].push(e),this[dt]+=e.length;}function pp(e){if(this[dt]+=e.length,this[zi]._maxPayload<1||this[dt]<=this[zi]._maxPayload){this[Ct].push(e);return}this[ji]=new RangeError("Max payload size exceeded"),this[ji].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ji][dp]=1009,this.removeListener("data",pp),this.reset();}function Dx(e){this[zi]._inflate=null,e[dp]=1007,this[sn](e);}});var yp=k((PL,mp)=>{d();function Ax(e){let t=e.length,r=0;for(;r<t;)if(!(e[r]&128))r++;else if((e[r]&224)===192){if(r+1===t||(e[r+1]&192)!==128||(e[r]&254)===192)return !1;r+=2;}else if((e[r]&240)===224){if(r+2>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||e[r]===224&&(e[r+1]&224)===128||e[r]===237&&(e[r+1]&224)===160)return !1;r+=3;}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||(e[r+3]&192)!==128||e[r]===240&&(e[r+1]&240)===128||e[r]===244&&e[r+1]>143||e[r]>244)return !1;r+=4;}else return !1;return !0}mp.exports=Ax;});var wp=k((LL,$a)=>{d();try{$a.exports=ka()(E);}catch(e){$a.exports=yp();}});var Ga=k((FL,qa)=>{d();function bp(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function Sp(e){let t=e.length,r=0;for(;r<t;)if(!(e[r]&128))r++;else if((e[r]&224)===192){if(r+1===t||(e[r+1]&192)!==128||(e[r]&254)===192)return !1;r+=2;}else if((e[r]&240)===224){if(r+2>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||e[r]===224&&(e[r+1]&224)===128||e[r]===237&&(e[r+1]&224)===160)return !1;r+=3;}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||(e[r+3]&192)!==128||e[r]===240&&(e[r+1]&240)===128||e[r]===244&&e[r+1]>143||e[r]>244)return !1;r+=4;}else return !1;return !0}try{let e=wp();typeof e=="object"&&(e=e.Validation.isValidUTF8),qa.exports={isValidStatusCode:bp,isValidUTF8(t){return t.length<150?Sp(t):e(t)}};}catch(e){qa.exports={isValidStatusCode:bp,isValidUTF8:Sp};}});var Ya=k((kL,Ip)=>{d();var{Writable:Ox}=$("stream"),_p=on(),{BINARY_TYPES:Tx,EMPTY_BUFFER:Rx,kStatusCode:Px,kWebSocket:Nx}=$t(),{concat:Va,toArrayBuffer:Lx,unmask:Mx}=rn(),{isValidStatusCode:Fx,isValidUTF8:Ep}=Ga(),an=0,vp=1,xp=2,Cp=3,Ha=4,Bx=5,Ja=class extends Ox{constructor(t,r,n,i){super(),this._binaryType=t||Tx[0],this[Nx]=void 0,this._extensions=r||{},this._isServer=!!n,this._maxPayload=i|0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=an,this._loop=!1;}_write(t,r,n){if(this._opcode===8&&this._state==an)return n();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(n);}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=n.slice(t),n.slice(0,t)}let r=Buffer.allocUnsafe(t);do{let n=this._buffers[0],i=r.length-t;t>=n.length?r.set(this._buffers.shift(),i):(r.set(new Uint8Array(n.buffer,n.byteOffset,t),i),this._buffers[0]=n.slice(t)),t-=n.length;}while(t>0);return r}startLoop(t){let r;this._loop=!0;do switch(this._state){case an:r=this.getInfo();break;case vp:r=this.getPayloadLength16();break;case xp:r=this.getPayloadLength64();break;case Cp:this.getMask();break;case Ha:r=this.getData(t);break;default:this._loop=!1;return}while(this._loop);t(r);}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48)return this._loop=!1,me(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let r=(t[0]&64)===64;if(r&&!this._extensions[_p.extensionName])return this._loop=!1,me(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r)return this._loop=!1,me(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,me(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented;}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,me(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=r;}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,me(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(r)return this._loop=!1,me(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,me(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,me(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,me(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,me(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=vp;else if(this._payloadLength===127)this._state=xp;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);return r>Math.pow(2,53-32)-1?(this._loop=!1,me(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,me(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=Cp:this._state=Ha;}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Ha;}getData(t){let r=Rx;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&Mx(r,this._mask);}if(this._opcode>7)return this.controlMessage(r);if(this._compressed){this._state=Bx,this.decompress(r,t);return}return r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage()}decompress(t,r){this._extensions[_p.extensionName].decompress(t,this._fin,(i,s)=>{if(i)return r(i);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return r(me(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s);}let o=this.dataMessage();if(o)return r(o);this.startLoop(r);});}dataMessage(){if(this._fin){let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let n;this._binaryType==="nodebuffer"?n=Va(r,t):this._binaryType==="arraybuffer"?n=Lx(Va(r,t)):n=r,this.emit("message",n);}else {let n=Va(r,t);if(!Ep(n))return this._loop=!1,me(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",n.toString());}}this._state=an;}controlMessage(t){if(this._opcode===8)if(this._loop=!1,t.length===0)this.emit("conclude",1005,""),this.end();else {if(t.length===1)return me(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let r=t.readUInt16BE(0);if(!Fx(r))return me(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let n=t.slice(2);if(!Ep(n))return me(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",r,n.toString()),this.end();}}else this._opcode===9?this.emit("ping",t):this.emit("pong",t);this._state=an;}};Ip.exports=Ja;function me(e,t,r,n,i){let s=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(s,me),s.code=i,s[Px]=n,s}});var Qa=k((jL,Op)=>{d();$("net");$("tls");var {randomFillSync:kx}=$("crypto"),Dp=on(),{EMPTY_BUFFER:Ux}=$t(),{isValidStatusCode:Wx}=Ga(),{mask:Ap,toBuffer:pt}=rn(),qt=Buffer.alloc(4),Xa=class e{constructor(t,r){this._extensions=r||{},this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[];}static frame(t,r){let n=r.mask&&r.readOnly,i=r.mask?6:2,s=t.length;t.length>=65536?(i+=8,s=127):t.length>125&&(i+=2,s=126);let o=Buffer.allocUnsafe(n?t.length+i:i);return o[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(o[0]|=64),o[1]=s,s===126?o.writeUInt16BE(t.length,2):s===127&&(o.writeUInt32BE(0,2),o.writeUInt32BE(t.length,6)),r.mask?(kx(qt,0,4),o[1]|=128,o[i-4]=qt[0],o[i-3]=qt[1],o[i-2]=qt[2],o[i-1]=qt[3],n?(Ap(t,qt,o,i,t.length),[o]):(Ap(t,qt,t,0,t.length),[o,t])):[o,t]}close(t,r,n,i){let s;if(t===void 0)s=Ux;else {if(typeof t!="number"||!Wx(t))throw new TypeError("First argument must be a valid error code number");if(r===void 0||r==="")s=Buffer.allocUnsafe(2),s.writeUInt16BE(t,0);else {let o=Buffer.byteLength(r);if(o>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+o),s.writeUInt16BE(t,0),s.write(r,2);}}this._deflating?this.enqueue([this.doClose,s,n,i]):this.doClose(s,n,i);}doClose(t,r,n){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:8,mask:r,readOnly:!1}),n);}ping(t,r,n){let i=pt(t);if(i.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPing,i,r,pt.readOnly,n]):this.doPing(i,r,pt.readOnly,n);}doPing(t,r,n,i){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:9,mask:r,readOnly:n}),i);}pong(t,r,n){let i=pt(t);if(i.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPong,i,r,pt.readOnly,n]):this.doPong(i,r,pt.readOnly,n);}doPong(t,r,n,i){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:10,mask:r,readOnly:n}),i);}send(t,r,n){let i=pt(t),s=this._extensions[Dp.extensionName],o=r.binary?2:1,a=r.compress;if(this._firstFragment?(this._firstFragment=!1,a&&s&&(a=i.length>=s._threshold),this._compress=a):(a=!1,o=0),r.fin&&(this._firstFragment=!0),s){let c={fin:r.fin,rsv1:a,opcode:o,mask:r.mask,readOnly:pt.readOnly};this._deflating?this.enqueue([this.dispatch,i,this._compress,c,n]):this.dispatch(i,this._compress,c,n);}else this.sendFrame(e.frame(i,{fin:r.fin,rsv1:!1,opcode:o,mask:r.mask,readOnly:pt.readOnly}),n);}dispatch(t,r,n,i){if(!r){this.sendFrame(e.frame(t,n),i);return}let s=this._extensions[Dp.extensionName];this._bufferedBytes+=t.length,this._deflating=!0,s.compress(t,n.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");typeof i=="function"&&i(c);for(let h=0;h<this._queue.length;h++){let l=this._queue[h][4];typeof l=="function"&&l(c);}return}this._bufferedBytes-=t.length,this._deflating=!1,n.readOnly=!1,this.sendFrame(e.frame(a,n),i),this.dequeue();});}dequeue(){for(;!this._deflating&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[1].length,Reflect.apply(t[0],this,t.slice(1));}}enqueue(t){this._bufferedBytes+=t[1].length,this._queue.push(t);}sendFrame(t,r){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],r),this._socket.uncork()):this._socket.write(t[0],r);}};Op.exports=Xa;});var Rp=k(($L,Tp)=>{d();var Sr=class{constructor(t,r){this.target=r,this.type=t;}},Za=class extends Sr{constructor(t,r){super("message",r),this.data=t;}},ec=class extends Sr{constructor(t,r,n){super("close",n),this.wasClean=n._closeFrameReceived&&n._closeFrameSent,this.reason=r,this.code=t;}},tc=class extends Sr{constructor(t){super("open",t);}},rc=class extends Sr{constructor(t,r){super("error",r),this.message=t.message,this.error=t;}},Kx={addEventListener(e,t,r){if(typeof t!="function")return;function n(c){t.call(this,new Za(c,this));}function i(c,h){t.call(this,new ec(c,h,this));}function s(c){t.call(this,new rc(c,this));}function o(){t.call(this,new tc(this));}let a=r&&r.once?"once":"on";e==="message"?(n._listener=t,this[a](e,n)):e==="close"?(i._listener=t,this[a](e,i)):e==="error"?(s._listener=t,this[a](e,s)):e==="open"?(o._listener=t,this[a](e,o)):this[a](e,t);},removeEventListener(e,t){let r=this.listeners(e);for(let n=0;n<r.length;n++)(r[n]===t||r[n]._listener===t)&&this.removeListener(e,r[n]);}};Tp.exports=Kx;});var nc=k((GL,Pp)=>{d();var cn=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function it(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r);}function jx(e){let t=Object.create(null);if(e===void 0||e==="")return t;let r=Object.create(null),n=!1,i=!1,s=!1,o,a,c=-1,h=-1,l=0;for(;l<e.length;l++){let m=e.charCodeAt(l);if(o===void 0)if(h===-1&&cn[m]===1)c===-1&&(c=l);else if(m===32||m===9)h===-1&&c!==-1&&(h=l);else if(m===59||m===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);h===-1&&(h=l);let p=e.slice(c,h);m===44?(it(t,p,r),r=Object.create(null)):o=p,c=h=-1;}else throw new SyntaxError(`Unexpected character at index ${l}`);else if(a===void 0)if(h===-1&&cn[m]===1)c===-1&&(c=l);else if(m===32||m===9)h===-1&&c!==-1&&(h=l);else if(m===59||m===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);h===-1&&(h=l),it(r,e.slice(c,h),!0),m===44&&(it(t,o,r),r=Object.create(null),o=void 0),c=h=-1;}else if(m===61&&c!==-1&&h===-1)a=e.slice(c,l),c=h=-1;else throw new SyntaxError(`Unexpected character at index ${l}`);else if(i){if(cn[m]!==1)throw new SyntaxError(`Unexpected character at index ${l}`);c===-1?c=l:n||(n=!0),i=!1;}else if(s)if(cn[m]===1)c===-1&&(c=l);else if(m===34&&c!==-1)s=!1,h=l;else if(m===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${l}`);else if(m===34&&e.charCodeAt(l-1)===61)s=!0;else if(h===-1&&cn[m]===1)c===-1&&(c=l);else if(c!==-1&&(m===32||m===9))h===-1&&(h=l);else if(m===59||m===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);h===-1&&(h=l);let p=e.slice(c,h);n&&(p=p.replace(/\\/g,""),n=!1),it(r,a,p),m===44&&(it(t,o,r),r=Object.create(null),o=void 0),a=void 0,c=h=-1;}else throw new SyntaxError(`Unexpected character at index ${l}`)}if(c===-1||s)throw new SyntaxError("Unexpected end of input");h===-1&&(h=l);let f=e.slice(c,h);return o===void 0?it(t,f,r):(a===void 0?it(r,f,!0):n?it(r,a,f.replace(/\\/g,"")):it(r,a,f),it(t,o,r)),t}function zx(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(n=>[t].concat(Object.keys(n).map(i=>{let s=n[i];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Pp.exports={format:zx,parse:jx};});var lc=k((JL,jp)=>{d();var $x=$("events"),qx=$("https"),Gx=$("http"),Mp=$("net"),Vx=$("tls"),{randomBytes:Hx,createHash:Jx}=$("crypto");$("stream");var {URL:ic}=$("url"),It=on(),Yx=Ya(),Xx=Qa(),{BINARY_TYPES:Np,EMPTY_BUFFER:sc,GUID:Qx,kStatusCode:Zx,kWebSocket:Ie,NOOP:Fp}=$t(),{addEventListener:eC,removeEventListener:tC}=Rp(),{format:rC,parse:nC}=nc(),{toBuffer:iC}=rn(),gt=["CONNECTING","OPEN","CLOSING","CLOSED"],oc=[8,13],sC=30*1e3,he=class e extends $x{constructor(t,r,n){super(),this._binaryType=Np[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage="",this._closeTimer=null,this._extensions={},this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Array.isArray(r)?r=r.join(", "):typeof r=="object"&&r!==null&&(n=r,r=void 0),Bp(this,t,r,n)):this._isServer=!0;}get binaryType(){return this._binaryType}set binaryType(t){Np.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t));}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get onclose(){}set onclose(t){}get onerror(){}set onerror(t){}get onopen(){}set onopen(t){}get onmessage(){}set onmessage(t){}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,r,n){let i=new Yx(this.binaryType,this._extensions,this._isServer,n);this._sender=new Xx(t,this._extensions),this._receiver=i,this._socket=t,i[Ie]=this,t[Ie]=this,i.on("conclude",cC),i.on("drain",lC),i.on("error",uC),i.on("message",fC),i.on("ping",hC),i.on("pong",dC),t.setTimeout(0),t.setNoDelay(),r.length>0&&t.unshift(r),t.on("close",Up),t.on("data",$i),t.on("end",Wp),t.on("error",Kp),this._readyState=e.OPEN,this.emit("open");}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[It.extensionName]&&this._extensions[It.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);}close(t,r){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){let n="WebSocket was closed before the connection was established";return je(this,this._req,n)}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end());}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),sC);}}ping(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){cc(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(t||sc,r,n);}pong(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){cc(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(t||sc,r,n);}send(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){cc(this,t,n);return}let i=F({binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0},r);this._extensions[It.extensionName]||(i.compress=!1),this._sender.send(t||sc,i,n);}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){let t="WebSocket was closed before the connection was established";return je(this,this._req,t)}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy());}}};Object.defineProperty(he,"CONNECTING",{enumerable:!0,value:gt.indexOf("CONNECTING")});Object.defineProperty(he.prototype,"CONNECTING",{enumerable:!0,value:gt.indexOf("CONNECTING")});Object.defineProperty(he,"OPEN",{enumerable:!0,value:gt.indexOf("OPEN")});Object.defineProperty(he.prototype,"OPEN",{enumerable:!0,value:gt.indexOf("OPEN")});Object.defineProperty(he,"CLOSING",{enumerable:!0,value:gt.indexOf("CLOSING")});Object.defineProperty(he.prototype,"CLOSING",{enumerable:!0,value:gt.indexOf("CLOSING")});Object.defineProperty(he,"CLOSED",{enumerable:!0,value:gt.indexOf("CLOSED")});Object.defineProperty(he.prototype,"CLOSED",{enumerable:!0,value:gt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach(e=>{Object.defineProperty(he.prototype,e,{enumerable:!0});});["open","error","close","message"].forEach(e=>{Object.defineProperty(he.prototype,`on${e}`,{enumerable:!0,get(){let t=this.listeners(e);for(let r=0;r<t.length;r++)if(t[r]._listener)return t[r]._listener},set(t){let r=this.listeners(e);for(let n=0;n<r.length;n++)r[n]._listener&&this.removeListener(e,r[n]);this.addEventListener(e,t);}});});he.prototype.addEventListener=eC;he.prototype.removeEventListener=tC;jp.exports=he;function Bp(e,t,r,n){let i=Q(F({protocolVersion:oc[1],maxPayload:104857600,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},n),{createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,host:void 0,path:void 0,port:void 0});if(!oc.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${oc.join(", ")})`);let s;t instanceof ic?(s=t,e._url=t.href):(s=new ic(t),e._url=t);let o=s.protocol==="ws+unix:";if(!s.host&&(!o||!s.pathname)){let p=new Error(`Invalid URL: ${e.url}`);if(e._redirects===0)throw p;ac(e,p);return}let a=s.protocol==="wss:"||s.protocol==="https:",c=a?443:80,h=Hx(16).toString("base64"),l=a?qx.get:Gx.get,f;if(i.createConnection=a?aC:oC,i.defaultPort=i.defaultPort||c,i.port=s.port||c,i.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,i.headers=F({"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.headers),i.path=s.pathname+s.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(f=new It(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=rC({[It.extensionName]:f.offer()})),r&&(i.headers["Sec-WebSocket-Protocol"]=r),i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(s.username||s.password)&&(i.auth=`${s.username}:${s.password}`),o){let p=i.path.split(":");i.socketPath=p[0],i.path=p[1];}if(i.followRedirects){if(e._redirects===0){e._originalUnixSocket=o,e._originalSecure=a,e._originalHostOrSocketPath=o?i.socketPath:s.host;let p=n&&n.headers;if(n=Q(F({},n),{headers:{}}),p)for(let[u,y]of Object.entries(p))n.headers[u.toLowerCase()]=y;}else {let p=o?e._originalUnixSocket?i.socketPath===e._originalHostOrSocketPath:!1:e._originalUnixSocket?!1:s.host===e._originalHostOrSocketPath;(!p||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,p||delete i.headers.host,i.auth=void 0);}i.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64"));}let m=e._req=l(i);i.timeout&&m.on("timeout",()=>{je(e,m,"Opening handshake has timed out");}),m.on("error",p=>{m===null||m.aborted||(m=e._req=null,ac(e,p));}),m.on("response",p=>{let u=p.headers.location,y=p.statusCode;if(u&&i.followRedirects&&y>=300&&y<400){if(++e._redirects>i.maxRedirects){je(e,m,"Maximum redirects exceeded");return}m.abort();let w;try{w=new ic(u,t);}catch(S){ac(e,S);return}Bp(e,w,r,n);}else e.emit("unexpected-response",m,p)||je(e,m,`Unexpected server response: ${p.statusCode}`);}),m.on("upgrade",(p,u,y)=>{if(e.emit("upgrade",p),e.readyState!==he.CONNECTING)return;if(m=e._req=null,p.headers.upgrade.toLowerCase()!=="websocket"){je(e,u,"Invalid Upgrade header");return}let w=Jx("sha1").update(h+Qx).digest("base64");if(p.headers["sec-websocket-accept"]!==w){je(e,u,"Invalid Sec-WebSocket-Accept header");return}let S=p.headers["sec-websocket-protocol"],b=(r||"").split(/, */),_;if(!r&&S?_="Server sent a subprotocol but none was requested":r&&!S?_="Server sent no subprotocol":S&&!b.includes(S)&&(_="Server sent an invalid subprotocol"),_){je(e,u,_);return}S&&(e._protocol=S);let C=p.headers["sec-websocket-extensions"];if(C!==void 0){if(!f){je(e,u,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let T;try{T=nC(C);}catch(v){je(e,u,"Invalid Sec-WebSocket-Extensions header");return}let M=Object.keys(T);if(M.length){if(M.length!==1||M[0]!==It.extensionName){je(e,u,"Server indicated an extension that was not requested");return}try{f.accept(T[It.extensionName]);}catch(v){je(e,u,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[It.extensionName]=f;}}e.setSocket(u,y,i.maxPayload);});}function ac(e,t){e._readyState=he.CLOSING,e.emit("error",t),e.emitClose();}function oC(e){return e.path=e.socketPath,Mp.connect(e)}function aC(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Mp.isIP(e.host)?"":e.host),Vx.connect(e)}function je(e,t,r){e._readyState=he.CLOSING;let n=new Error(r);Error.captureStackTrace(n,je),t.setHeader?(t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),t.once("abort",e.emitClose.bind(e)),e.emit("error",n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)));}function cc(e,t,r){if(t){let n=iC(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n;}if(r){let n=new Error(`WebSocket is not open: readyState ${e.readyState} (${gt[e.readyState]})`);r(n);}}function cC(e,t){let r=this[Ie];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,r._socket[Ie]!==void 0&&(r._socket.removeListener("data",$i),process.nextTick(kp,r._socket),e===1005?r.close():r.close(e,t));}function lC(){this[Ie]._socket.resume();}function uC(e){let t=this[Ie];t._socket[Ie]!==void 0&&(t._socket.removeListener("data",$i),process.nextTick(kp,t._socket),t.close(e[Zx])),t.emit("error",e);}function Lp(){this[Ie].emitClose();}function fC(e){this[Ie].emit("message",e);}function hC(e){let t=this[Ie];t.pong(e,!t._isServer,Fp),t.emit("ping",e);}function dC(e){this[Ie].emit("pong",e);}function kp(e){e.resume();}function Up(){let e=this[Ie];this.removeListener("close",Up),this.removeListener("data",$i),this.removeListener("end",Wp),e._readyState=he.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[Ie]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Lp),e._receiver.on("finish",Lp));}function $i(e){this[Ie]._receiver.write(e)||this.pause();}function Wp(){let e=this[Ie];e._readyState=he.CLOSING,e._receiver.end(),this.end();}function Kp(){let e=this[Ie];this.removeListener("error",Kp),this.on("error",Fp),e&&(e._readyState=he.CLOSING,this.destroy());}});var Gp=k((QL,qp)=>{d();var{Duplex:pC}=$("stream");function zp(e){e.emit("close");}function gC(){!this.destroyed&&this._writableState.finished&&this.destroy();}function $p(e){this.removeListener("error",$p),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e);}function mC(e,t){let r=!0,n=!0;function i(){r&&e._socket.resume();}e.readyState===e.CONNECTING?e.once("open",function(){e._receiver.removeAllListeners("drain"),e._receiver.on("drain",i);}):(e._receiver.removeAllListeners("drain"),e._receiver.on("drain",i));let s=new pC(Q(F({},t),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return e.on("message",function(a){s.push(a)||(r=!1,e._socket.pause());}),e.once("error",function(a){s.destroyed||(n=!1,s.destroy(a));}),e.once("close",function(){s.destroyed||s.push(null);}),s._destroy=function(o,a){if(e.readyState===e.CLOSED){a(o),process.nextTick(zp,s);return}let c=!1;e.once("error",function(l){c=!0,a(l);}),e.once("close",function(){c||a(o),process.nextTick(zp,s);}),n&&e.terminate();},s._final=function(o){if(e.readyState===e.CONNECTING){e.once("open",function(){s._final(o);});return}e._socket!==null&&(e._socket._writableState.finished?(o(),s._readableState.endEmitted&&s.destroy()):(e._socket.once("finish",function(){o();}),e.close()));},s._read=function(){(e.readyState===e.OPEN||e.readyState===e.CLOSING)&&!r&&(r=!0,e._receiver._writableState.needDrain||e._socket.resume());},s._write=function(o,a,c){if(e.readyState===e.CONNECTING){e.once("open",function(){s._write(o,a,c);});return}e.send(o,c);},s.on("end",gC),s.on("error",$p),s}qp.exports=mC;});var Xp=k((i8,Yp)=>{d();var yC=$("events"),qi=$("http");$("https");$("net");$("tls");var {createHash:wC}=$("crypto"),Gt=on(),bC=lc(),{format:SC,parse:_C}=nc(),{GUID:EC,kWebSocket:vC}=$t(),xC=/^[+/0-9A-Za-z]{22}==$/,Vp=0,Hp=1,Jp=2,fc=class extends yC{constructor(t,r){if(super(),t=F({maxPayload:100*1024*1024,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null},t),t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=qi.createServer((n,i)=>{let s=qi.STATUS_CODES[426];i.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),i.end(s);}),this._server.listen(t.port,t.host,t.backlog,r)):t.server&&(this._server=t.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=CC(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,s,o)=>{this.handleUpgrade(i,s,o,n);}});}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set),this.options=t,this._state=Vp;}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(t&&this.once("close",t),this._state===Jp){process.nextTick(uc,this);return}if(this._state===Hp)return;if(this._state=Hp,this.clients)for(let n of this.clients)n.terminate();let r=this._server;if(r&&(this._removeListeners(),this._removeListeners=this._server=null,this.options.port!=null)){r.close(uc.bind(void 0,this));return}process.nextTick(uc,this);}shouldHandle(t){if(this.options.path){let r=t.url.indexOf("?");if((r!==-1?t.url.slice(0,r):t.url)!==this.options.path)return !1}return !0}handleUpgrade(t,r,n,i){r.on("error",hc);let s=t.headers["sec-websocket-key"]!==void 0?t.headers["sec-websocket-key"].trim():!1,o=+t.headers["sec-websocket-version"],a={};if(t.method!=="GET"||t.headers.upgrade.toLowerCase()!=="websocket"||!s||!xC.test(s)||o!==8&&o!==13||!this.shouldHandle(t))return ln(r,400);if(this.options.perMessageDeflate){let c=new Gt(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let h=_C(t.headers["sec-websocket-extensions"]);h[Gt.extensionName]&&(c.accept(h[Gt.extensionName]),a[Gt.extensionName]=c);}catch(h){return ln(r,400)}}if(this.options.verifyClient){let c={origin:t.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(c,(h,l,f,m)=>{if(!h)return ln(r,l||401,f,m);this.completeUpgrade(s,a,t,r,n,i);});return}if(!this.options.verifyClient(c))return ln(r,401)}this.completeUpgrade(s,a,t,r,n,i);}completeUpgrade(t,r,n,i,s,o){if(!i.readable||!i.writable)return i.destroy();if(i[vC])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Vp)return ln(i,503);let c=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${wC("sha1").update(t+EC).digest("base64")}`],h=new bC(null),l=n.headers["sec-websocket-protocol"];if(l&&(l=l.split(",").map(IC),this.options.handleProtocols?l=this.options.handleProtocols(l,n):l=l[0],l&&(c.push(`Sec-WebSocket-Protocol: ${l}`),h._protocol=l)),r[Gt.extensionName]){let f=r[Gt.extensionName].params,m=SC({[Gt.extensionName]:[f]});c.push(`Sec-WebSocket-Extensions: ${m}`),h._extensions=r;}this.emit("headers",c,n),i.write(c.concat(`\r
|
|
126
|
+
`).join(`\r
|
|
127
|
+
`)),i.removeListener("error",hc),h.setSocket(i,s,this.options.maxPayload),this.clients&&(this.clients.add(h),h.on("close",()=>this.clients.delete(h))),o(h,n);}};Yp.exports=fc;function CC(e,t){for(let r of Object.keys(t))e.on(r,t[r]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n]);}}function uc(e){e._state=Jp,e.emit("close");}function hc(){this.destroy();}function ln(e,t,r,n){e.writable&&(r=r||qi.STATUS_CODES[t],n=F({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r)},n),e.write(`HTTP/1.1 ${t} ${qi.STATUS_CODES[t]}\r
|
|
128
|
+
`+Object.keys(n).map(i=>`${i}: ${n[i]}`).join(`\r
|
|
129
|
+
`)+`\r
|
|
130
|
+
\r
|
|
131
|
+
`+r)),e.removeListener("error",hc),e.destroy();}function IC(e){return e.trim()}});var Zp=k((a8,Qp)=>{d();var un=lc();un.createWebSocketStream=Gp();un.Server=Xp();un.Receiver=Ya();un.Sender=Qa();Qp.exports=un;});var Fg=k((fn,Er)=>{d();var RC=200,vc="__lodash_hash_undefined__",es=1,dg=2,pg=9007199254740991,Vi="[object Arguments]",mc="[object Array]",PC="[object AsyncFunction]",gg="[object Boolean]",mg="[object Date]",yg="[object Error]",wg="[object Function]",NC="[object GeneratorFunction]",Hi="[object Map]",bg="[object Number]",LC="[object Null]",_r="[object Object]",rg="[object Promise]",MC="[object Proxy]",Sg="[object RegExp]",Ji="[object Set]",_g="[object String]",FC="[object Symbol]",BC="[object Undefined]",yc="[object WeakMap]",Eg="[object ArrayBuffer]",Yi="[object DataView]",kC="[object Float32Array]",UC="[object Float64Array]",WC="[object Int8Array]",KC="[object Int16Array]",jC="[object Int32Array]",zC="[object Uint8Array]",$C="[object Uint8ClampedArray]",qC="[object Uint16Array]",GC="[object Uint32Array]",VC=/[\\^$.*+?()[\]{}|]/g,HC=/^\[object .+?Constructor\]$/,JC=/^(?:0|[1-9]\d*)$/,re={};re[kC]=re[UC]=re[WC]=re[KC]=re[jC]=re[zC]=re[$C]=re[qC]=re[GC]=!0;re[Vi]=re[mc]=re[Eg]=re[gg]=re[Yi]=re[mg]=re[yg]=re[wg]=re[Hi]=re[bg]=re[_r]=re[Sg]=re[Ji]=re[_g]=re[yc]=!1;var vg=typeof global=="object"&&global&&global.Object===Object&&global,YC=typeof self=="object"&&self&&self.Object===Object&&self,mt=vg||YC||Function("return this")(),xg=typeof fn=="object"&&fn&&!fn.nodeType&&fn,ng=xg&&typeof Er=="object"&&Er&&!Er.nodeType&&Er,Cg=ng&&ng.exports===xg,dc=Cg&&vg.process,ig=function(){try{return dc&&dc.binding&&dc.binding("util")}catch(e){}}(),sg=ig&&ig.isTypedArray;function XC(e,t){for(var r=-1,n=e==null?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o);}return s}function QC(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function ZC(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return !0;return !1}function e1(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function t1(e){return function(t){return e(t)}}function r1(e,t){return e.has(t)}function n1(e,t){return e==null?void 0:e[t]}function i1(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n];}),r}function s1(e,t){return function(r){return e(t(r))}}function o1(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n;}),r}var a1=Array.prototype,c1=Function.prototype,ts=Object.prototype,pc=mt["__core-js_shared__"],Ig=c1.toString,st=ts.hasOwnProperty,og=function(){var e=/[^.]+$/.exec(pc&&pc.keys&&pc.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Dg=ts.toString,l1=RegExp("^"+Ig.call(st).replace(VC,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ag=Cg?mt.Buffer:void 0,Xi=mt.Symbol,cg=mt.Uint8Array,Ag=ts.propertyIsEnumerable,u1=a1.splice,Vt=Xi?Xi.toStringTag:void 0,lg=Object.getOwnPropertySymbols,f1=ag?ag.isBuffer:void 0,h1=s1(Object.keys,Object),wc=vr(mt,"DataView"),hn=vr(mt,"Map"),bc=vr(mt,"Promise"),Sc=vr(mt,"Set"),_c=vr(mt,"WeakMap"),dn=vr(Object,"create"),d1=Yt(wc),p1=Yt(hn),g1=Yt(bc),m1=Yt(Sc),y1=Yt(_c),ug=Xi?Xi.prototype:void 0,gc=ug?ug.valueOf:void 0;function Ht(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1]);}}function w1(){this.__data__=dn?dn(null):{},this.size=0;}function b1(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function S1(e){var t=this.__data__;if(dn){var r=t[e];return r===vc?void 0:r}return st.call(t,e)?t[e]:void 0}function _1(e){var t=this.__data__;return dn?t[e]!==void 0:st.call(t,e)}function E1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=dn&&t===void 0?vc:t,this}Ht.prototype.clear=w1;Ht.prototype.delete=b1;Ht.prototype.get=S1;Ht.prototype.has=_1;Ht.prototype.set=E1;function yt(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1]);}}function v1(){this.__data__=[],this.size=0;}function x1(e){var t=this.__data__,r=rs(t,e);if(r<0)return !1;var n=t.length-1;return r==n?t.pop():u1.call(t,r,1),--this.size,!0}function C1(e){var t=this.__data__,r=rs(t,e);return r<0?void 0:t[r][1]}function I1(e){return rs(this.__data__,e)>-1}function D1(e,t){var r=this.__data__,n=rs(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}yt.prototype.clear=v1;yt.prototype.delete=x1;yt.prototype.get=C1;yt.prototype.has=I1;yt.prototype.set=D1;function Jt(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1]);}}function A1(){this.size=0,this.__data__={hash:new Ht,map:new(hn||yt),string:new Ht};}function O1(e){var t=ns(this,e).delete(e);return this.size-=t?1:0,t}function T1(e){return ns(this,e).get(e)}function R1(e){return ns(this,e).has(e)}function P1(e,t){var r=ns(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}Jt.prototype.clear=A1;Jt.prototype.delete=O1;Jt.prototype.get=T1;Jt.prototype.has=R1;Jt.prototype.set=P1;function Qi(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Jt;++t<r;)this.add(e[t]);}function N1(e){return this.__data__.set(e,vc),this}function L1(e){return this.__data__.has(e)}Qi.prototype.add=Qi.prototype.push=N1;Qi.prototype.has=L1;function At(e){var t=this.__data__=new yt(e);this.size=t.size;}function M1(){this.__data__=new yt,this.size=0;}function F1(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}function B1(e){return this.__data__.get(e)}function k1(e){return this.__data__.has(e)}function U1(e,t){var r=this.__data__;if(r instanceof yt){var n=r.__data__;if(!hn||n.length<RC-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Jt(n);}return r.set(e,t),this.size=r.size,this}At.prototype.clear=M1;At.prototype.delete=F1;At.prototype.get=B1;At.prototype.has=k1;At.prototype.set=U1;function W1(e,t){var r=Zi(e),n=!r&&tI(e),i=!r&&!n&&Ec(e),s=!r&&!n&&!i&&Mg(e),o=r||n||i||s,a=o?e1(e.length,String):[],c=a.length;for(var h in e)(t||st.call(e,h))&&!(o&&(h=="length"||i&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||Y1(h,c)))&&a.push(h);return a}function rs(e,t){for(var r=e.length;r--;)if(Rg(e[r][0],t))return r;return -1}function K1(e,t,r){var n=t(e);return Zi(e)?n:QC(n,r(e))}function gn(e){return e==null?e===void 0?BC:LC:Vt&&Vt in Object(e)?H1(e):eI(e)}function fg(e){return pn(e)&&gn(e)==Vi}function Og(e,t,r,n,i){return e===t?!0:e==null||t==null||!pn(e)&&!pn(t)?e!==e&&t!==t:j1(e,t,r,n,Og,i)}function j1(e,t,r,n,i,s){var o=Zi(e),a=Zi(t),c=o?mc:Dt(e),h=a?mc:Dt(t);c=c==Vi?_r:c,h=h==Vi?_r:h;var l=c==_r,f=h==_r,m=c==h;if(m&&Ec(e)){if(!Ec(t))return !1;o=!0,l=!1;}if(m&&!l)return s||(s=new At),o||Mg(e)?Tg(e,t,r,n,i,s):G1(e,t,c,r,n,i,s);if(!(r&es)){var p=l&&st.call(e,"__wrapped__"),u=f&&st.call(t,"__wrapped__");if(p||u){var y=p?e.value():e,w=u?t.value():t;return s||(s=new At),i(y,w,r,n,s)}}return m?(s||(s=new At),V1(e,t,r,n,i,s)):!1}function z1(e){if(!Lg(e)||Q1(e))return !1;var t=Pg(e)?l1:HC;return t.test(Yt(e))}function $1(e){return pn(e)&&Ng(e.length)&&!!re[gn(e)]}function q1(e){if(!Z1(e))return h1(e);var t=[];for(var r in Object(e))st.call(e,r)&&r!="constructor"&&t.push(r);return t}function Tg(e,t,r,n,i,s){var o=r&es,a=e.length,c=t.length;if(a!=c&&!(o&&c>a))return !1;var h=s.get(e);if(h&&s.get(t))return h==t;var l=-1,f=!0,m=r&dg?new Qi:void 0;for(s.set(e,t),s.set(t,e);++l<a;){var p=e[l],u=t[l];if(n)var y=o?n(u,p,l,t,e,s):n(p,u,l,e,t,s);if(y!==void 0){if(y)continue;f=!1;break}if(m){if(!ZC(t,function(w,S){if(!r1(m,S)&&(p===w||i(p,w,r,n,s)))return m.push(S)})){f=!1;break}}else if(!(p===u||i(p,u,r,n,s))){f=!1;break}}return s.delete(e),s.delete(t),f}function G1(e,t,r,n,i,s,o){switch(r){case Yi:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return !1;e=e.buffer,t=t.buffer;case Eg:return !(e.byteLength!=t.byteLength||!s(new cg(e),new cg(t)));case gg:case mg:case bg:return Rg(+e,+t);case yg:return e.name==t.name&&e.message==t.message;case Sg:case _g:return e==t+"";case Hi:var a=i1;case Ji:var c=n&es;if(a||(a=o1),e.size!=t.size&&!c)return !1;var h=o.get(e);if(h)return h==t;n|=dg,o.set(e,t);var l=Tg(a(e),a(t),n,i,s,o);return o.delete(e),l;case FC:if(gc)return gc.call(e)==gc.call(t)}return !1}function V1(e,t,r,n,i,s){var o=r&es,a=hg(e),c=a.length,h=hg(t),l=h.length;if(c!=l&&!o)return !1;for(var f=c;f--;){var m=a[f];if(!(o?m in t:st.call(t,m)))return !1}var p=s.get(e);if(p&&s.get(t))return p==t;var u=!0;s.set(e,t),s.set(t,e);for(var y=o;++f<c;){m=a[f];var w=e[m],S=t[m];if(n)var b=o?n(S,w,m,t,e,s):n(w,S,m,e,t,s);if(!(b===void 0?w===S||i(w,S,r,n,s):b)){u=!1;break}y||(y=m=="constructor");}if(u&&!y){var _=e.constructor,C=t.constructor;_!=C&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof C=="function"&&C instanceof C)&&(u=!1);}return s.delete(e),s.delete(t),u}function hg(e){return K1(e,iI,J1)}function ns(e,t){var r=e.__data__;return X1(t)?r[typeof t=="string"?"string":"hash"]:r.map}function vr(e,t){var r=n1(e,t);return z1(r)?r:void 0}function H1(e){var t=st.call(e,Vt),r=e[Vt];try{e[Vt]=void 0;var n=!0;}catch(s){}var i=Dg.call(e);return n&&(t?e[Vt]=r:delete e[Vt]),i}var J1=lg?function(e){return e==null?[]:(e=Object(e),XC(lg(e),function(t){return Ag.call(e,t)}))}:sI,Dt=gn;(wc&&Dt(new wc(new ArrayBuffer(1)))!=Yi||hn&&Dt(new hn)!=Hi||bc&&Dt(bc.resolve())!=rg||Sc&&Dt(new Sc)!=Ji||_c&&Dt(new _c)!=yc)&&(Dt=function(e){var t=gn(e),r=t==_r?e.constructor:void 0,n=r?Yt(r):"";if(n)switch(n){case d1:return Yi;case p1:return Hi;case g1:return rg;case m1:return Ji;case y1:return yc}return t});function Y1(e,t){return t=t==null?pg:t,!!t&&(typeof e=="number"||JC.test(e))&&e>-1&&e%1==0&&e<t}function X1(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Q1(e){return !!og&&og in e}function Z1(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||ts;return e===r}function eI(e){return Dg.call(e)}function Yt(e){if(e!=null){try{return Ig.call(e)}catch(t){}try{return e+""}catch(t){}}return ""}function Rg(e,t){return e===t||e!==e&&t!==t}var tI=fg(function(){return arguments}())?fg:function(e){return pn(e)&&st.call(e,"callee")&&!Ag.call(e,"callee")},Zi=Array.isArray;function rI(e){return e!=null&&Ng(e.length)&&!Pg(e)}var Ec=f1||oI;function nI(e,t){return Og(e,t)}function Pg(e){if(!Lg(e))return !1;var t=gn(e);return t==wg||t==NC||t==PC||t==MC}function Ng(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=pg}function Lg(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function pn(e){return e!=null&&typeof e=="object"}var Mg=sg?t1(sg):$1;function iI(e){return rI(e)?W1(e):q1(e)}function sI(){return []}function oI(){return !1}Er.exports=nI;});var Bg=k(te=>{d();Object.defineProperty(te,"__esModule",{value:!0});te.getLocalStorage=te.getLocalStorageOrThrow=te.getCrypto=te.getCryptoOrThrow=te.getLocation=te.getLocationOrThrow=te.getNavigator=te.getNavigatorOrThrow=te.getDocument=te.getDocumentOrThrow=te.getFromWindowOrThrow=te.getFromWindow=void 0;function Xt(e){let t;return typeof window!="undefined"&&typeof window[e]!="undefined"&&(t=window[e]),t}te.getFromWindow=Xt;function xr(e){let t=Xt(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}te.getFromWindowOrThrow=xr;function aI(){return xr("document")}te.getDocumentOrThrow=aI;function cI(){return Xt("document")}te.getDocument=cI;function lI(){return xr("navigator")}te.getNavigatorOrThrow=lI;function uI(){return Xt("navigator")}te.getNavigator=uI;function fI(){return xr("location")}te.getLocationOrThrow=fI;function hI(){return Xt("location")}te.getLocation=hI;function dI(){return xr("crypto")}te.getCryptoOrThrow=dI;function pI(){return Xt("crypto")}te.getCrypto=pI;function gI(){return xr("localStorage")}te.getLocalStorageOrThrow=gI;function mI(){return Xt("localStorage")}te.getLocalStorage=mI;});d();d();d();var ct="graz-reconnect-session";d();d();var bl=(b=>(b.KEPLR="keplr",b.LEAP="leap",b.VECTIS="vectis",b.COSMOSTATION="cosmostation",b.WALLETCONNECT="walletconnect",b.WC_KEPLR_MOBILE="wc_keplr_mobile",b.WC_LEAP_MOBILE="wc_leap_mobile",b.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",b.WC_CLOT_MOBILE="wc_clot_mobile",b.METAMASK_SNAP_LEAP="metamask_snap_leap",b.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",b.STATION="station",b.XDEFI="xdefi",b.CAPSULE="capsule",b.COSMIFRAME="cosmiframe",b.COMPASS="compass",b.INITIA="initia",b.OKX="okx",b))(bl||{}),Sl=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var Cy={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Qt={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Iy={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Dy={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},U=create(subscribeWithSelector(persist(()=>Qt,Iy))),N=create(subscribeWithSelector(persist(()=>Cy,Dy)));d();d();var In=()=>{var m,p;if(!((m=N.getState().capsuleConfig)!=null&&m.apiKey)||!((p=N.getState().capsuleConfig)!=null&&p.env))throw new Error("Capsule configuration is not set");let e=()=>g(void 0,null,function*(){var w,S;let u=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,y=new u({apiKey:(w=N.getState().capsuleConfig)==null?void 0:w.apiKey,env:(S=N.getState().capsuleConfig)==null?void 0:S.env});return U.setState({capsuleClient:y}),y});return {init:e,enable:u=>g(void 0,null,function*(){let y=typeof u=="string"?[u]:u,w=U.getState().capsuleClient;w||(w=yield e()),N.setState({capsuleState:{showModal:!0,chainId:y}});}),onAfterLoginSuccessful:()=>g(void 0,null,function*(){var b;let u=U.getState().capsuleClient,{chains:y}=N.getState();if(!u)throw new Error("Capsule client is not initialized");if(!y)throw new Error("Chains are not set");yield u.enable();let w=(b=N.getState().capsuleState)==null?void 0:b.chainId;if(!w)throw new Error("Chain ids are not set");let S=Object.fromEntries(yield Promise.all(w.map(_=>g(void 0,null,function*(){let C=yield u.getAccount(_);return [_,{address:fromBech32(C.address).data,bech32Address:C.address,algo:C.algo,name:C.username||"",pubKey:C.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));U.setState(_=>({accounts:F(F({},_.accounts||{}),S)})),N.setState(_=>({recentChainIds:[..._.recentChainIds||[],...w].filter((C,T,M)=>M.indexOf(C)===T)})),U.setState(_=>({activeChainIds:[..._.activeChainIds||[],...w].filter((C,T,M)=>M.indexOf(C)===T)})),N.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),U.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(ct,"Active"),N.setState({capsuleState:null});}),getKey:u=>g(void 0,null,function*(){let y=U.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");let w=yield y.getAccount(u);return {address:fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:u=>g(void 0,null,function*(){let y=U.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerDirect(u)}),getOfflineSignerDirect:u=>{let y=U.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerDirect(u)},signDirect:(...u)=>g(void 0,null,function*(){let[y,w,S]=u,b=U.getState().capsuleClient;if(!b)throw new Error("Capsule client is not initialized");return b.signDirect(y,w,{bodyBytes:S.bodyBytes,authInfoBytes:S.authInfoBytes,chainId:S.chainId,accountNumber:S.accountNumber})}),signAmino:(...u)=>g(void 0,null,function*(){let[y,w,S,b]=u,_=U.getState().capsuleClient;if(!_)throw new Error("Capsule client is not initialized");return _.signAmino(y,w,S,b)}),signArbitrary:(u,y,w)=>g(void 0,null,function*(){let S=U.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let b=yield S.getAccount(u);if(!b)throw new Error(`Wallet not connected to account ${y}`);let _=(()=>{switch(b.algo){case"secp256k1":return encodeSecp256k1Pubkey(b.pubkey);case"ed25519":return encodeEd25519Pubkey(b.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield S.signArbitrary(u,y,w),pub_key:{type:b.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:_.value}}}),experimentalSuggestChain:(...u)=>g(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:u=>{let y=U.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSigner(u)},getOfflineSignerAmino:u=>{let y=U.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerAmino(u)}}};d();var Dn=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let s=()=>{we(),i();};return window.addEventListener("leap_keystorechange",s),()=>{window.removeEventListener("leap_keystorechange",s);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw N.getState()._notFoundFn(),new Error("window.leap is not defined")};d();var An=()=>{let e=N.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};d();var Al={},Ol=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>g(void 0,null,function*(){var l;let s=yield e.request({method:"web3_clientVersion"});if(!s.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let a=(l=s.split("MetaMask/v")[1])==null?void 0:l.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:s=>g(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:s=>t.getOfflineSigner(s),experimentalSuggestChain:s=>g(void 0,null,function*(){if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(Q(F({},s),{stakeCurrency:s.stakeCurrency,bech32Config:s.bech32Config}));}),signAmino:(s,o,a)=>g(void 0,null,function*(){return t.signAmino(s,o,a)}),getKey:s=>g(void 0,null,function*(){return typeof Al[s]!="undefined"?Al[s]:t.getKey(s)}),getOfflineSignerAuto:s=>g(void 0,null,function*(){return (yield t.getKey(s)).isNanoLedger?t.getOfflineSignerOnlyAmino(s):t.getOfflineSigner(s)}),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:(s,o,a)=>g(void 0,null,function*(){return t.signDirect(s,o,a)}),signArbitrary:(s,o,a)=>g(void 0,null,function*(){return t.signArbitrary(s,o,a)}),disable:s=>g(void 0,null,function*(){s&&(yield t.deleteChain(s));})};throw N.getState()._notFoundFn(),new Error("window.ethereum is not defined")};d();var On=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:s=>{let o=()=>{we(),s();};return window.addEventListener("cosmostation_keystorechange",o),()=>{window.removeEventListener("cosmostation_keystorechange",o);}},setDefaultOptions:s=>{t.defaultOptions=s;}})}throw N.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};d();var By=e=>{let{bodyBytes:t,authInfoBytes:r,chainId:n,accountNumber:i}=e;if(!t||!r||!n||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:r,chainId:n,accountNumber:i}},ky=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Rl=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>g(void 0,null,function*(){yield e.getAddress();}),getKey:f=>g(void 0,null,function*(){let m=e.getOfflineSigner(f),[p]=yield m.getAccounts();if(!p)throw new Error("Wallet connection failed");let u=(()=>{switch(p.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(p.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:ky(p.address),algo:p.algo,pubKey:p.pubkey,bech32Address:p.address,address:u,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:f=>{let m=e.getOfflineSigner(f),p=e.getOfflineSignerOnlyAmino(f);return {getAccounts:m.getAccounts.bind(m),signDirect:m.signDirect.bind(m),signAmino:p.signAmino.bind(p)}},getOfflineSignerAuto:f=>Promise.resolve(e.getOfflineSigner(f)),getOfflineSignerOnlyAmino:f=>e.getOfflineSignerOnlyAmino(f),experimentalSuggestChain:f=>e.requestAddInitiaLayer({chain_id:f.chainId,chain_name:f.chainName,bech32_prefix:"init",bech32_config:f.bech32Config,slip44:f.bip44.coinType,logo_URIs:{png:f.chainSymbolImageUrl},fees:{fee_tokens:f.feeCurrencies.map(m=>{var p,u,y;return {denom:m.coinDenom,amount:m.coinMinimalDenom,low_gas_price:(p=m.gasPriceStep)==null?void 0:p.low,average_gas_price:(u=m.gasPriceStep)==null?void 0:u.average,high_gas_price:(y=m.gasPriceStep)==null?void 0:y.high}})},apis:{rpc:[{address:f.rpc}],rest:[{address:f.rest}]}}),signDirect:(...f)=>{let[m,p,u]=f;return e.getOfflineSigner(m).signDirect(p,By(u))},signAmino:(...f)=>{let[m,p,u]=f;return e.getOfflineSignerOnlyAmino(m).signAmino(p,u)},signArbitrary:(f,m,p)=>g(void 0,null,function*(){let w=(yield e.getOfflineSigner(f).getAccounts()).find(_=>_.address===m);if(!w)throw new Error(`Wallet not connected to account ${m}`);let S=(()=>{switch(w.algo){case"secp256k1":return encodeSecp256k1Pubkey(w.pubkey);case"ed25519":return encodeEd25519Pubkey(w.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(p),pub_key:{type:w.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:S.value}}}),subscription:f=>{let m=()=>{we(),f();};return window.addEventListener("initia_keystorechange",m),()=>{window.removeEventListener("initia_keystorechange",m);}}}}throw N.getState()._notFoundFn(),new Error("window.initia is not defined")};d();var Tn=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let s=()=>{we(),i();};return window.addEventListener("keplr_keystorechange",s),()=>{window.removeEventListener("keplr_keystorechange",s);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw N.getState()._notFoundFn(),new Error("window.keplr is not defined")};d();var Rn=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let s=()=>{we(),i();};return window.addEventListener("leap_keystorechange",s),()=>{window.removeEventListener("leap_keystorechange",s);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw N.getState()._notFoundFn(),new Error("window.leap is not defined")};d();d();var Pn={},Pl=e=>{let t=window.ethereum;if(t&&e){let r=()=>g(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),n=b=>g(void 0,null,function*(){try{let _=yield r();return Object.values(_).find(C=>C.id===e.id&&(!b||C.version===b))}catch(_){return}}),i=()=>g(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),s=()=>g(void 0,null,function*(){var v;let b=yield t.request({method:"web3_clientVersion"});if(!b.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let C=(v=b.split("MetaMask/v")[1])==null?void 0:v.split(".")[0];if(!(Number(C)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield n())||(yield i()),!0}),o=b=>g(void 0,null,function*(){(yield n())||(yield i());}),a=(b,_,C)=>g(void 0,null,function*(){let T=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:b,signerAddress:_,signDoc:C}}}}),M=C.accountNumber,v=new Bm(M.low,M.high,M.unsigned);return {signature:T.signature,signed:Q(F({},T.signed),{accountNumber:`${v.toString()}`,authInfoBytes:new Uint8Array(Object.values(T.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(T.signed.bodyBytes))})}}),c=(b,_,C)=>g(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:b,signerAddress:_,signDoc:C}}}})}),h=b=>g(void 0,null,function*(){if(typeof Pn[b]!="undefined")return Pn[b];let _=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:b}}}});if(!_)throw new Error("No response from Metamask");return _.pubKey=Uint8Array.from(Object.values(_.pubkey)),delete _.pubkey,Pn[b]=_,Pn[b]}),l=b=>g(void 0,null,function*(){let _=yield h(b);return {address:_.bech32Address,algo:_.algo,pubkey:_.pubKey}}),f=(...b)=>g(void 0,null,function*(){let[_,C,T,M]=b;return yield c(_,C,T)}),m=(...b)=>g(void 0,null,function*(){let[_,C,T]=b;return yield a(_,C,T)}),u=b=>({getAccounts:()=>g(void 0,null,function*(){return [yield l(b)]}),signAmino:(_,C)=>f(b,_,C)});return {enable:o,experimentalSuggestChain:(...b)=>g(void 0,null,function*(){yield s(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:b[0]}}}});}),getKey:h,getOfflineSigner:b=>({getAccounts:()=>g(void 0,null,function*(){return [yield l(b)]}),signDirect:(_,C)=>m(b,_,C),signAmino:(_,C)=>f(b,_,C)}),getOfflineSignerAuto:b=>g(void 0,null,function*(){return u(b)}),getOfflineSignerOnlyAmino:u,init:s,signAmino:f,signDirect:m}}throw N.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Nl=()=>Pl({id:"npm:@leapwallet/metamask-cosmos-snap"});d();var Nn=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:s=>{var a;let o=()=>{we(),s();};return (a=window.okxwallet)==null||a.on("accountsChanged",o),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",o);}},setDefaultOptions:s=>{t.defaultOptions=s;}})}throw N.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};d();var Ln=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:s=>{let o=()=>{we(),s();};return window.addEventListener("station_wallet_change",o),()=>{window.removeEventListener("station_wallet_change",o);}},getKey:s=>g(void 0,null,function*(){let o=yield e.getKey(s);return F({isKeystone:!1},o)}),getOfflineSigner:s=>{try{let o=e.getOfflineSignerOnlyAmino(s);return Object.assign(o,{signDirect:(h,l)=>{throw new Error("signDirect not supported by Station")}})}catch(o){throw console.error(o),o}},experimentalSuggestChain:s=>g(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let o=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(a=>{var c,h,l;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((h=a.gasPriceStep)==null?void 0:h.high)||0,low:((l=a.gasPriceStep)==null?void 0:l.low)||0}}})});yield e.experimentalSuggestChain(o);}catch(o){throw console.error(o),o}}),enable:s=>e.enable(s),disable:s=>e.disable(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>e.getOfflineSignerOnlyAmino(s),signDirect:()=>e.signDirect(),signAmino:(s,o,a,c)=>e.signAmino(s,o,a)}}throw N.getState()._notFoundFn(),new Error("window.station is not defined")};d();var Mn=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>g(void 0,null,function*(){let c=yield e.getKey(a);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:a=>{let c=()=>{we(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>{let c=a[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...a)=>g(void 0,null,function*(){var l;let[c]=a;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let h={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(l=c.bech32Config)==null?void 0:l.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([h])}),signDirect:(...a)=>g(void 0,null,function*(){var l;let{1:c,2:h}=a;return e.signDirect(c,{bodyBytes:h.bodyBytes||Uint8Array.from([]),authInfoBytes:h.authInfoBytes||Uint8Array.from([]),accountNumber:Bm.fromString(((l=h.accountNumber)==null?void 0:l.toString())||"",!1),chainId:h.chainId||""})}),signAmino:(...a)=>g(void 0,null,function*(){let{1:c,2:h}=a;return e.signAmino(c,h)})}}throw N.getState()._notFoundFn(),new Error("window.vectis is not defined")};d();d();d();var qn=Ye(jn());d();d();var zn=class{};var _s=class extends zn{constructor(t){super();}},Gl=qn.FIVE_SECONDS,Pt={pulse:"heartbeat_pulse"},$n=class e extends _s{constructor(t){super(t),this.events=new EventEmitter,this.interval=Gl,this.interval=(t==null?void 0:t.interval)||Gl;}static init(t){return g(this,null,function*(){let r=new e(t);return yield r.init(),r})}init(){return g(this,null,function*(){yield this.initialize();})}stop(){clearInterval(this.intervalRef);}on(t,r){this.events.on(t,r);}once(t,r){this.events.once(t,r);}off(t,r){this.events.off(t,r);}removeListener(t,r){this.events.removeListener(t,r);}initialize(){return g(this,null,function*(){this.intervalRef=setInterval(()=>this.pulse(),(0, qn.toMiliseconds)(this.interval));})}pulse(){this.events.emit(Pt.pulse);}};d();d();d();var hw=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,dw=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,pw=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function gw(e,t){if(e==="__proto__"||e==="constructor"&&t&&typeof t=="object"&&"prototype"in t){mw(e);return}return t}function mw(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`);}function Pr(e,t={}){if(typeof e!="string")return e;let r=e.trim();if(e[0]==='"'&&e.endsWith('"')&&!e.includes("\\"))return r.slice(1,-1);if(r.length<=9){let 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(!pw.test(e)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return e}try{if(hw.test(e)||dw.test(e)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(e,gw)}return JSON.parse(e)}catch(n){if(t.strict)throw n;return e}}d();function yw(e){return !e||typeof e.then!="function"?Promise.resolve(e):e}function ge(e,...t){try{return yw(e(...t))}catch(r){return Promise.reject(r)}}function ww(e){let t=typeof e;return e===null||t!=="object"&&t!=="function"}function bw(e){let t=Object.getPrototypeOf(e);return !t||t.isPrototypeOf(Object)}function Nr(e){if(ww(e))return String(e);if(bw(e)||Array.isArray(e))return JSON.stringify(e);if(typeof e.toJSON=="function")return Nr(e.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Vl(){if(typeof Buffer=="undefined")throw new TypeError("[unstorage] Buffer is not supported!")}var Es="base64:";function Hl(e){if(typeof e=="string")return e;Vl();let t=Buffer.from(e).toString("base64");return Es+t}function Jl(e){return typeof e!="string"||!e.startsWith(Es)?e:(Vl(),Buffer.from(e.slice(Es.length),"base64"))}function Re(e){return e?e.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Yl(...e){return Re(e.join(":"))}function Lr(e){return e=Re(e),e?e+":":""}var Sw="memory",_w=()=>{let e=new Map;return {name:Sw,getInstance:()=>e,hasItem(t){return e.has(t)},getItem(t){var r;return (r=e.get(t))!=null?r:null},getItemRaw(t){var r;return (r=e.get(t))!=null?r:null},setItem(t,r){e.set(t,r);},setItemRaw(t,r){e.set(t,r);},removeItem(t){e.delete(t);},getKeys(){return [...e.keys()]},clear(){e.clear();},dispose(){e.clear();}}};function Zl(e={}){let t={mounts:{"":e.driver||_w()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=l=>{for(let f of t.mountpoints)if(l.startsWith(f))return {base:f,relativeKey:l.slice(f.length),driver:t.mounts[f]};return {base:"",relativeKey:l,driver:t.mounts[""]}},n=(l,f)=>t.mountpoints.filter(m=>m.startsWith(l)||f&&l.startsWith(m)).map(m=>({relativeBase:l.length>m.length?l.slice(m.length):void 0,mountpoint:m,driver:t.mounts[m]})),i=(l,f)=>{if(t.watching){f=Re(f);for(let m of t.watchListeners)m(l,f);}},s=()=>g(this,null,function*(){if(!t.watching){t.watching=!0;for(let l in t.mounts)t.unwatch[l]=yield Xl(t.mounts[l],i,l);}}),o=()=>g(this,null,function*(){if(t.watching){for(let l in t.unwatch)yield t.unwatch[l]();t.unwatch={},t.watching=!1;}}),a=(l,f,m)=>{let p=new Map,u=y=>{let w=p.get(y.base);return w||(w={driver:y.driver,base:y.base,items:[]},p.set(y.base,w)),w};for(let y of l){let w=typeof y=="string",S=Re(w?y:y.key),b=w?void 0:y.value,_=w||!y.options?f:F(F({},f),y.options),C=r(S);u(C).items.push({key:S,value:b,relativeKey:C.relativeKey,options:_});}return Promise.all([...p.values()].map(y=>m(y))).then(y=>y.flat())},c={hasItem(l,f={}){l=Re(l);let{relativeKey:m,driver:p}=r(l);return ge(p.hasItem,m,f)},getItem(l,f={}){l=Re(l);let{relativeKey:m,driver:p}=r(l);return ge(p.getItem,m,f).then(u=>Pr(u))},getItems(l,f){return a(l,f,m=>m.driver.getItems?ge(m.driver.getItems,m.items.map(p=>({key:p.relativeKey,options:p.options})),f).then(p=>p.map(u=>({key:Yl(m.base,u.key),value:Pr(u.value)}))):Promise.all(m.items.map(p=>ge(m.driver.getItem,p.relativeKey,p.options).then(u=>({key:p.key,value:Pr(u)})))))},getItemRaw(l,f={}){l=Re(l);let{relativeKey:m,driver:p}=r(l);return p.getItemRaw?ge(p.getItemRaw,m,f):ge(p.getItem,m,f).then(u=>Jl(u))},setItem(p,u){return g(this,arguments,function*(l,f,m={}){if(f===void 0)return c.removeItem(l);l=Re(l);let{relativeKey:y,driver:w}=r(l);w.setItem&&(yield ge(w.setItem,y,Nr(f),m),w.watch||i("update",l));})},setItems(l,f){return g(this,null,function*(){yield a(l,f,m=>g(this,null,function*(){if(m.driver.setItems)return ge(m.driver.setItems,m.items.map(p=>({key:p.relativeKey,value:Nr(p.value),options:p.options})),f);m.driver.setItem&&(yield Promise.all(m.items.map(p=>ge(m.driver.setItem,p.relativeKey,Nr(p.value),p.options))));}));})},setItemRaw(p,u){return g(this,arguments,function*(l,f,m={}){if(f===void 0)return c.removeItem(l,m);l=Re(l);let{relativeKey:y,driver:w}=r(l);if(w.setItemRaw)yield ge(w.setItemRaw,y,f,m);else if(w.setItem)yield ge(w.setItem,y,Hl(f),m);else return;w.watch||i("update",l);})},removeItem(m){return g(this,arguments,function*(l,f={}){typeof f=="boolean"&&(f={removeMeta:f}),l=Re(l);let{relativeKey:p,driver:u}=r(l);u.removeItem&&(yield ge(u.removeItem,p,f),(f.removeMeta||f.removeMata)&&(yield ge(u.removeItem,p+"$",f)),u.watch||i("remove",l));})},getMeta(m){return g(this,arguments,function*(l,f={}){typeof f=="boolean"&&(f={nativeOnly:f}),l=Re(l);let{relativeKey:p,driver:u}=r(l),y=Object.create(null);if(u.getMeta&&Object.assign(y,yield ge(u.getMeta,p,f)),!f.nativeOnly){let w=yield ge(u.getItem,p+"$",f).then(S=>Pr(S));w&&typeof w=="object"&&(typeof w.atime=="string"&&(w.atime=new Date(w.atime)),typeof w.mtime=="string"&&(w.mtime=new Date(w.mtime)),Object.assign(y,w));}return y})},setMeta(l,f,m={}){return this.setItem(l+"$",f,m)},removeMeta(l,f={}){return this.removeItem(l+"$",f)},getKeys(m){return g(this,arguments,function*(l,f={}){l=Lr(l);let p=n(l,!0),u=[],y=[];for(let w of p){let S=yield ge(w.driver.getKeys,w.relativeBase,f);for(let b of S){let _=w.mountpoint+Re(b);u.some(C=>_.startsWith(C))||y.push(_);}u=[w.mountpoint,...u.filter(b=>!b.startsWith(w.mountpoint))];}return l?y.filter(w=>w.startsWith(l)&&w[w.length-1]!=="$"):y.filter(w=>w[w.length-1]!=="$")})},clear(m){return g(this,arguments,function*(l,f={}){l=Lr(l),yield Promise.all(n(l,!1).map(p=>g(this,null,function*(){if(p.driver.clear)return ge(p.driver.clear,p.relativeBase,f);if(p.driver.removeItem){let u=yield p.driver.getKeys(p.relativeBase||"",f);return Promise.all(u.map(y=>p.driver.removeItem(y,f)))}})));})},dispose(){return g(this,null,function*(){yield Promise.all(Object.values(t.mounts).map(l=>Ql(l)));})},watch(l){return g(this,null,function*(){return yield s(),t.watchListeners.push(l),()=>g(this,null,function*(){t.watchListeners=t.watchListeners.filter(f=>f!==l),t.watchListeners.length===0&&(yield o());})})},unwatch(){return g(this,null,function*(){t.watchListeners=[],yield o();})},mount(l,f){if(l=Lr(l),l&&t.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(t.mountpoints.push(l),t.mountpoints.sort((m,p)=>p.length-m.length)),t.mounts[l]=f,t.watching&&Promise.resolve(Xl(f,i,l)).then(m=>{t.unwatch[l]=m;}).catch(console.error),c},unmount(l,f=!0){return g(this,null,function*(){l=Lr(l),!(!l||!t.mounts[l])&&(t.watching&&l in t.unwatch&&(t.unwatch[l](),delete t.unwatch[l]),f&&(yield Ql(t.mounts[l])),t.mountpoints=t.mountpoints.filter(m=>m!==l),delete t.mounts[l]);})},getMount(l=""){l=Re(l)+":";let f=r(l);return {driver:f.driver,base:f.base}},getMounts(l="",f={}){return l=Re(l),n(l,f.parents).map(p=>({driver:p.driver,base:p.mountpoint}))},keys:(l,f={})=>c.getKeys(l,f),get:(l,f={})=>c.getItem(l,f),set:(l,f,m={})=>c.setItem(l,f,m),has:(l,f={})=>c.hasItem(l,f),del:(l,f={})=>c.removeItem(l,f),remove:(l,f={})=>c.removeItem(l,f)};return c}function Xl(e,t,r){return e.watch?e.watch((n,i)=>t(n,r+i)):()=>{}}function Ql(e){return g(this,null,function*(){typeof e.dispose=="function"&&(yield ge(e.dispose));})}d();function Nt(e){return new Promise((t,r)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>r(e.error);})}function xs(e,t){let r=indexedDB.open(e);r.onupgradeneeded=()=>r.result.createObjectStore(t);let n=Nt(r);return (i,s)=>n.then(o=>s(o.transaction(t,i).objectStore(t)))}var vs;function Mr(){return vs||(vs=xs("keyval-store","keyval")),vs}function Cs(e,t=Mr()){return t("readonly",r=>Nt(r.get(e)))}function eu(e,t,r=Mr()){return r("readwrite",n=>(n.put(t,e),Nt(n.transaction)))}function tu(e,t=Mr()){return t("readwrite",r=>(r.delete(e),Nt(r.transaction)))}function ru(e=Mr()){return e("readwrite",t=>(t.clear(),Nt(t.transaction)))}function Ew(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue());},Nt(e.transaction)}function nu(e=Mr()){return e("readonly",t=>{if(t.getAllKeys)return Nt(t.getAllKeys());let r=[];return Ew(t,n=>r.push(n.key)).then(()=>r)})}d();var vw=e=>JSON.stringify(e,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),xw=e=>{let t=/([\[:])?(\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=e.replace(t,'$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 et(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return xw(e)}catch(t){return e}}function qe(e){return typeof e=="string"?e:vw(e)||""}var Cw="idb-keyval",Iw=(e={})=>{let t=e.base&&e.base.length>0?`${e.base}:`:"",r=s=>t+s,n;return e.dbName&&e.storeName&&(n=xs(e.dbName,e.storeName)),{name:Cw,options:e,hasItem(s){return g(this,null,function*(){return !(typeof(yield Cs(r(s),n))>"u")})},getItem(s){return g(this,null,function*(){var o;return (o=yield Cs(r(s),n))!=null?o:null})},setItem(s,o){return eu(r(s),o,n)},removeItem(s){return tu(r(s),n)},getKeys(){return nu(n)},clear(){return ru(n)}}},Dw="WALLET_CONNECT_V2_INDEXED_DB",Aw="keyvaluestorage",Ds=class{constructor(){this.indexedDb=Zl({driver:Iw({dbName:Dw,storeName:Aw})});}getKeys(){return g(this,null,function*(){return this.indexedDb.getKeys()})}getEntries(){return g(this,null,function*(){return (yield this.indexedDb.getItems(yield this.indexedDb.getKeys())).map(t=>[t.key,t.value])})}getItem(t){return g(this,null,function*(){let r=yield this.indexedDb.getItem(t);if(r!==null)return r})}setItem(t,r){return g(this,null,function*(){yield this.indexedDb.setItem(t,qe(r));})}removeItem(t){return g(this,null,function*(){yield this.indexedDb.removeItem(t);})}},Is=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Gn={exports:{}};(function(){let e;function t(){}e=t,e.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},e.prototype.setItem=function(r,n){this[r]=String(n);},e.prototype.removeItem=function(r){delete this[r];},e.prototype.clear=function(){let r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n];});},e.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},e.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Is<"u"&&Is.localStorage?Gn.exports=Is.localStorage:typeof window<"u"&&window.localStorage?Gn.exports=window.localStorage:Gn.exports=new t;})();function Ow(e){var t;return [e[0],et((t=e[1])!=null?t:"")]}var As=class{constructor(){this.localStorage=Gn.exports;}getKeys(){return g(this,null,function*(){return Object.keys(this.localStorage)})}getEntries(){return g(this,null,function*(){return Object.entries(this.localStorage).map(Ow)})}getItem(t){return g(this,null,function*(){let r=this.localStorage.getItem(t);if(r!==null)return et(r)})}setItem(t,r){return g(this,null,function*(){this.localStorage.setItem(t,qe(r));})}removeItem(t){return g(this,null,function*(){this.localStorage.removeItem(t);})}},Tw="wc_storage_version",iu=1,Rw=(e,t,r)=>g(void 0,null,function*(){let n=Tw,i=yield t.getItem(n);if(i&&i>=iu){r(t);return}let s=yield e.getKeys();if(!s.length){r(t);return}let o=[];for(;s.length;){let a=s.shift();if(!a)continue;let c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){let h=yield e.getItem(a);yield t.setItem(a,h),o.push(a);}}yield t.setItem(n,iu),r(t),Pw(e,o);}),Pw=(e,t)=>g(void 0,null,function*(){t.length&&t.forEach(r=>g(void 0,null,function*(){yield e.removeItem(r);}));}),Vn=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0;};let t=new As;this.storage=t;try{let r=new Ds;Rw(t,r,this.setInitialized);}catch(r){this.initialized=!0;}}getKeys(){return g(this,null,function*(){return yield this.initialize(),this.storage.getKeys()})}getEntries(){return g(this,null,function*(){return yield this.initialize(),this.storage.getEntries()})}getItem(t){return g(this,null,function*(){return yield this.initialize(),this.storage.getItem(t)})}setItem(t,r){return g(this,null,function*(){return yield this.initialize(),this.storage.setItem(t,r)})}removeItem(t){return g(this,null,function*(){return yield this.initialize(),this.storage.removeItem(t)})}initialize(){return g(this,null,function*(){this.initialized||(yield new Promise(t=>{let r=setInterval(()=>{this.initialized&&(clearInterval(r),t());},20);}));})}};d();var ut=Ye(xo()),Ao=Ye(xo());var M_={level:"info"},Ur="custom_context",Oo=1e3*1024,Co=class{constructor(t){this.nodeValue=t,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null;}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},ai=class{constructor(t){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=t,this.sizeInBytes=0;}append(t){let r=new Co(t);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${t} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size;}shift(){if(!this.head)return;let t=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=t.size;}toArray(){let t=[],r=this.head;for(;r!==null;)t.push(r.value),r=r.next;return t}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let t=this.head;return {next:()=>{if(!t)return {done:!0,value:null};let r=t.value;return t=t.next,{done:!1,value:r}}}}},ci=class{constructor(t,r=Oo){this.level=t!=null?t:"error",this.levelValue=ut.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new ai(this.MAX_LOG_SIZE_IN_BYTES);}forwardToConsole(t,r){r===ut.levels.values.error?console.error(t):r===ut.levels.values.warn?console.warn(t):r===ut.levels.values.debug?console.debug(t):r===ut.levels.values.trace?console.trace(t):console.log(t);}appendToLogs(t){this.logs.append(qe({timestamp:new Date().toISOString(),log:t}));let r=typeof t=="string"?JSON.parse(t).level:t.level;r>=this.levelValue&&this.forwardToConsole(t,r);}getLogs(){return this.logs}clearLogs(){this.logs=new ai(this.MAX_LOG_SIZE_IN_BYTES);}getLogArray(){return Array.from(this.logs)}logsToBlob(t){let r=this.getLogArray();return r.push(qe({extraMetadata:t})),new Blob(r,{type:"application/json"})}},Io=class{constructor(t,r=Oo){this.baseChunkLogger=new ci(t,r);}write(t){this.baseChunkLogger.appendToLogs(t);}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs();}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}downloadLogsBlobInBrowser(t){let r=URL.createObjectURL(this.logsToBlob(t)),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);}},Do=class{constructor(t,r=Oo){this.baseChunkLogger=new ci(t,r);}write(t){this.baseChunkLogger.appendToLogs(t);}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs();}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}},F_=Object.defineProperty,B_=Object.defineProperties,k_=Object.getOwnPropertyDescriptors,lh=Object.getOwnPropertySymbols,U_=Object.prototype.hasOwnProperty,W_=Object.prototype.propertyIsEnumerable,uh=(e,t,r)=>t in e?F_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,li=(e,t)=>{for(var r in t||(t={}))U_.call(t,r)&&uh(e,r,t[r]);if(lh)for(var r of lh(t))W_.call(t,r)&&uh(e,r,t[r]);return e},ui=(e,t)=>B_(e,k_(t));function To(e){return ui(li({},e),{level:(e==null?void 0:e.level)||M_.level})}function K_(e,t=Ur){return e[t]||""}function j_(e,t,r=Ur){return e[r]=t,e}function ke(e,t=Ur){let r="";return typeof e.bindings>"u"?r=K_(e,t):r=e.bindings().context||"",r}function z_(e,t,r=Ur){let n=ke(e,r);return n.trim()?`${n}/${t}`:t}function Pe(e,t,r=Ur){let n=z_(e,t,r),i=e.child({context:n});return j_(i,n,r)}function $_(e){var t,r;let n=new Io((t=e.opts)==null?void 0:t.level,e.maxSizeInBytes);return {logger:(0, ut.default)(ui(li({},e.opts),{level:"trace",browser:ui(li({},(r=e.opts)==null?void 0:r.browser),{write:i=>n.write(i)})})),chunkLoggerController:n}}function q_(e){var t;let r=new Do((t=e.opts)==null?void 0:t.level,e.maxSizeInBytes);return {logger:(0, ut.default)(ui(li({},e.opts),{level:"trace"}),r),chunkLoggerController:r}}function fh(e){return typeof e.loggerOverride<"u"&&typeof e.loggerOverride!="string"?{logger:e.loggerOverride,chunkLoggerController:null}:typeof window<"u"?$_(e):q_(e)}var z=Ye(jn());d();d();var Yr=Ye(Kh()),bd=Ye(Ko()),Sd=Ye(jn());d();var jh="EdDSA",zh="JWT",zr=".",$r="base64url",Yo="utf8",Xo="utf8",$h=":",qh="did",Gh="key",Qo="base58btc",Vh="z",Hh="K36";d();d();d();d();function ur(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function mi(e=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?ur(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Jh(e,t){t||(t=e.reduce((i,s)=>i+s.length,0));let r=mi(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return ur(r)}d();d();d();var na={};Oe(na,{identity:()=>qE});d();d();d();function WE(e,t){if(e.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<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i;}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var y=0,w=0,S=0,b=u.length;S!==b&&u[S]===0;)S++,y++;for(var _=(b-S)*l+1>>>0,C=new Uint8Array(_);S!==b;){for(var T=u[S],M=0,v=_-1;(T!==0||M<w)&&v!==-1;v--,M++)T+=256*C[v]>>>0,C[v]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");w=M,S++;}for(var I=_-w;I!==_&&C[I]===0;)I++;for(var B=c.repeat(y);I<_;++I)B+=e.charAt(C[I]);return B}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var y=0;if(u[y]!==" "){for(var w=0,S=0;u[y]===c;)w++,y++;for(var b=(u.length-y)*h+1>>>0,_=new Uint8Array(b);u[y];){var C=r[u.charCodeAt(y)];if(C===255)return;for(var T=0,M=b-1;(C!==0||T<S)&&M!==-1;M--,T++)C+=a*_[M]>>>0,_[M]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");S=T,y++;}if(u[y]!==" "){for(var v=b-S;v!==b&&_[v]===0;)v++;for(var I=new Uint8Array(w+(b-v)),B=w;v!==b;)I[B++]=_[v++];return I}}}function p(u){var y=m(u);if(y)return y;throw new Error(`Non-${t} character`)}return {encode:f,decodeUnsafe:m,decode:p}}var KE=WE,jE=KE,Yh=jE;d();var Ge=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var Qh=e=>new TextEncoder().encode(e),Zh=e=>new TextDecoder().decode(e);var Zo=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n;}encode(t){if(t instanceof Uint8Array)return `${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ea=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n;}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return td(this,t)}},ta=class{constructor(t){this.decoders=t;}or(t){return td(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},td=(e,t)=>new ta(F(F({},e.decoders||{[e.prefix]:e}),t.decoders||{[t.prefix]:t})),ra=class{constructor(t,r,n,i){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Zo(t,r,n),this.decoder=new ea(t,r,i);}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},fr=({name:e,prefix:t,encode:r,decode:n})=>new ra(e,t,r,n),_t=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:i}=Yh(r,t);return fr({prefix:e,name:t,encode:n,decode:s=>Ge(i(s))})},zE=(e,t,r,n)=>{let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;e[s-1]==="=";)--s;let o=new Uint8Array(s*r/8|0),a=0,c=0,h=0;for(let l=0;l<s;++l){let f=i[e[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a);}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},$E=(e,t,r)=>{let n=t[t.length-1]==="=",i=(1<<r)-1,s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},ce=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>fr({prefix:t,name:e,encode(i){return $E(i,n,r)},decode(i){return zE(i,n,r,e)}});var qE=fr({prefix:"\0",name:"identity",encode:e=>Zh(e),decode:e=>Qh(e)});var ia={};Oe(ia,{base2:()=>GE});d();var GE=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var sa={};Oe(sa,{base8:()=>VE});d();var VE=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var oa={};Oe(oa,{base10:()=>HE});d();var HE=_t({prefix:"9",name:"base10",alphabet:"0123456789"});var aa={};Oe(aa,{base16:()=>JE,base16upper:()=>YE});d();var JE=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),YE=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ca={};Oe(ca,{base32:()=>hr,base32hex:()=>ev,base32hexpad:()=>rv,base32hexpadupper:()=>nv,base32hexupper:()=>tv,base32pad:()=>QE,base32padupper:()=>ZE,base32upper:()=>XE,base32z:()=>iv});d();var hr=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),XE=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),QE=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ZE=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ev=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),tv=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rv=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),nv=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),iv=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var la={};Oe(la,{base36:()=>sv,base36upper:()=>ov});d();var sv=_t({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ov=_t({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ua={};Oe(ua,{base58btc:()=>rt,base58flickr:()=>av});d();var rt=_t({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),av=_t({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var fa={};Oe(fa,{base64:()=>cv,base64pad:()=>lv,base64url:()=>uv,base64urlpad:()=>fv});d();var cv=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),lv=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),uv=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fv=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ha={};Oe(ha,{base256emoji:()=>mv});d();var rd=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),hv=rd.reduce((e,t,r)=>(e[r]=t,e),[]),dv=rd.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function pv(e){return e.reduce((t,r)=>(t+=hv[r],t),"")}function gv(e){let t=[];for(let r of e){let n=dv[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n);}return new Uint8Array(t)}var mv=fr({prefix:"\u{1F680}",name:"base256emoji",encode:pv,decode:gv});var ma={};Oe(ma,{sha256:()=>Mv,sha512:()=>Fv});d();d();d();d();d();var yv=sd,nd=128,wv=127,bv=~wv,Sv=Math.pow(2,31);function sd(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Sv;)t[r++]=e&255|nd,e/=128;for(;e&bv;)t[r++]=e&255|nd,e>>>=7;return t[r]=e|0,sd.bytes=r-n+1,t}var _v=da,Ev=128,id=127;function da(e,n){var r=0,n=n||0,i=0,s=n,o,a=e.length;do{if(s>=a)throw da.bytes=0,new RangeError("Could not decode varint");o=e[s++],r+=i<28?(o&id)<<i:(o&id)*Math.pow(2,i),i+=7;}while(o>=Ev);return da.bytes=s-n,r}var vv=Math.pow(2,7),xv=Math.pow(2,14),Cv=Math.pow(2,21),Iv=Math.pow(2,28),Dv=Math.pow(2,35),Av=Math.pow(2,42),Ov=Math.pow(2,49),Tv=Math.pow(2,56),Rv=Math.pow(2,63),Pv=function(e){return e<vv?1:e<xv?2:e<Cv?3:e<Iv?4:e<Dv?5:e<Av?6:e<Ov?7:e<Tv?8:e<Rv?9:10},Nv={encode:yv,decode:_v,encodingLength:Pv},Lv=Nv,qr=Lv;var dr=(e,t,r=0)=>(qr.encode(e,t,r),t),pr=e=>qr.encodingLength(e);var Kt=(e,t)=>{let r=t.byteLength,n=pr(e),i=n+pr(r),s=new Uint8Array(i+r);return dr(e,s,0),dr(r,s,n),s.set(t,i),new gr(e,r,t,s)},gr=class{constructor(t,r,n,i){this.code=t,this.size=r,this.digest=n,this.bytes=i;}};var ga=({name:e,code:t,encode:r})=>new pa(e,t,r),pa=class{constructor(t,r,n){this.name=t,this.code=r,this.encode=n;}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Kt(this.code,r):r.then(n=>Kt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Mv=ga({name:"sha2-256",code:18,encode:e=>Ge(ld.createHash("sha256").update(e).digest())}),Fv=ga({name:"sha2-512",code:19,encode:e=>Ge(ld.createHash("sha512").update(e).digest())});var ya={};Oe(ya,{identity:()=>Uv});d();var ud=0,Bv="identity",fd=Ge,kv=e=>Kt(ud,fd(e)),Uv={code:ud,name:Bv,encode:fd,digest:kv};d();d();new TextEncoder;new TextDecoder;d();d();var mr=F(F(F(F(F(F(F(F(F(F({},na),ia),sa),oa),aa),ca),la),ua),fa),ha);F(F({},ma),ya);function gd(e,t,r,n){return {name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var pd=gd("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),wa=gd("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=mi(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Jv=F({utf8:pd,"utf-8":pd,hex:mr.base16,latin1:wa,ascii:wa,binary:wa},mr),_i=Jv;function Jr(e,t="utf8"){let r=_i[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return (t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}d();function jt(e,t="utf8"){let r=_i[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return (t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ur(globalThis.Buffer.from(e,"utf-8")):r.decoder.decode(`${r.prefix}${e}`)}function md(e){return et(Jr(jt(e,$r),Yo))}function Ei(e){return Jr(jt(qe(e),Yo),$r)}function vi(e){let t=jt(Hh,Qo),r=Vh+Jr(Jh([t,e]),Qo);return [qh,Gh,r].join($h)}function Yv(e){return Jr(e,$r)}function Xv(e){return jt(e,$r)}function yd(e){return jt([Ei(e.header),Ei(e.payload)].join(zr),Xo)}function wd(e){return [Ei(e.header),Ei(e.payload),Yv(e.signature)].join(zr)}function xi(e){let t=e.split(zr),r=md(t[0]),n=md(t[1]),i=Xv(t[2]),s=jt(t.slice(0,2).join(zr),Xo);return {header:r,payload:n,signature:i,data:s}}function ba(e=(0, bd.randomBytes)(32)){return Yr.generateKeyPairFromSeed(e)}function _d(s,o,a,c){return g(this,arguments,function*(e,t,r,n,i=(0, Sd.fromMiliseconds)(Date.now())){let h={alg:jh,typ:zh},l=vi(n.publicKey),f=i+r,m={iss:l,sub:e,aud:t,iat:i,exp:f},p=yd({header:h,payload:m}),u=Yr.sign(n.secretKey,p);return wd({header:h,payload:m,signature:u})})}d();d();d();d();d();function Ci(e=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}d();d();d();function vd(e,t,r,n){return {name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Ed=vd("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Sa=vd("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=Ci(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),ex=F({utf8:Ed,"utf-8":Ed,hex:mr.base16,latin1:Sa,ascii:Sa,binary:Sa},mr),_a=ex;d();function Ea(e,t="utf8"){let r=_a[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return (t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}d();d();var Ce={};Oe(Ce,{DEFAULT_ERROR:()=>Qr,IBaseJsonRpcProvider:()=>Mi,IEvents:()=>en,IJsonRpcConnection:()=>Aa,IJsonRpcProvider:()=>tn,INTERNAL_ERROR:()=>Ii,INVALID_PARAMS:()=>Dd,INVALID_REQUEST:()=>Cd,METHOD_NOT_FOUND:()=>Id,PARSE_ERROR:()=>xd,RESERVED_ERROR_CODES:()=>va,SERVER_ERROR:()=>Xr,SERVER_ERROR_CODE_RANGE:()=>Di,STANDARD_ERROR_MAP:()=>Et,formatErrorMessage:()=>Bd,formatJsonRpcError:()=>Zr,formatJsonRpcRequest:()=>wr,formatJsonRpcResult:()=>Pi,getBigIntRpcId:()=>yr,getError:()=>Oi,getErrorByCode:()=>Ti,isHttpUrl:()=>fx,isJsonRpcError:()=>zt,isJsonRpcPayload:()=>Ta,isJsonRpcRequest:()=>Bi,isJsonRpcResponse:()=>br,isJsonRpcResult:()=>ki,isJsonRpcValidationInvalid:()=>hx,isLocalhostUrl:()=>Oa,isNodeJs:()=>Fd,isReservedErrorCode:()=>Ai,isServerErrorCode:()=>tx,isValidDefaultRoute:()=>Ni,isValidErrorCode:()=>Ad,isValidLeadingWildcardRoute:()=>ox,isValidRoute:()=>sx,isValidTrailingWildcardRoute:()=>ax,isValidWildcardRoute:()=>Li,isWsUrl:()=>Fi,parseConnectionError:()=>xa,payloadId:()=>Da,validateJsonRpcError:()=>rx});d();d();var xd="PARSE_ERROR",Cd="INVALID_REQUEST",Id="METHOD_NOT_FOUND",Dd="INVALID_PARAMS",Ii="INTERNAL_ERROR",Xr="SERVER_ERROR",va=[-32700,-32600,-32601,-32602,-32603],Di=[-32e3,-32099],Et={[xd]:{code:-32700,message:"Parse error"},[Cd]:{code:-32600,message:"Invalid Request"},[Id]:{code:-32601,message:"Method not found"},[Dd]:{code:-32602,message:"Invalid params"},[Ii]:{code:-32603,message:"Internal error"},[Xr]:{code:-32e3,message:"Server error"}},Qr=Xr;d();function tx(e){return e<=Di[0]&&e>=Di[1]}function Ai(e){return va.includes(e)}function Ad(e){return typeof e=="number"}function Oi(e){return Object.keys(Et).includes(e)?Et[e]:Et[Qr]}function Ti(e){let t=Object.values(Et).find(r=>r.code===e);return t||Et[Qr]}function rx(e){if(typeof e.error.code=="undefined")return {valid:!1,error:"Missing code for JSON-RPC error"};if(typeof e.error.message=="undefined")return {valid:!1,error:"Missing message for JSON-RPC error"};if(!Ad(e.error.code))return {valid:!1,error:`Invalid error code type for JSON-RPC: ${e.error.code}`};if(Ai(e.error.code)){let t=Ti(e.error.code);if(t.message!==Et[Qr].message&&e.error.message===t.message)return {valid:!1,error:`Invalid error code message for JSON-RPC: ${e.error.code}`}}return {valid:!0}}function xa(e,t,r){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${t}`):e}var be={};Oe(be,{isNodeJs:()=>Fd});d();var Md=Ye(Ia());Te(be,Ye(Ia()));var Fd=Md.isNode;Te(Ce,be);d();function Da(e=3){let t=Date.now()*Math.pow(10,e),r=Math.floor(Math.random()*Math.pow(10,e));return t+r}function yr(e=6){return BigInt(Da(e))}function wr(e,t,r){return {id:r||Da(),jsonrpc:"2.0",method:e,params:t}}function Pi(e,t){return {id:e,jsonrpc:"2.0",result:t}}function Zr(e,t,r){return {id:e,jsonrpc:"2.0",error:Bd(t,r)}}function Bd(e,t){return typeof e=="undefined"?Oi(Ii):(typeof e=="string"&&(e=Object.assign(Object.assign({},Oi(Xr)),{message:e})),typeof t!="undefined"&&(e.data=t),Ai(e.code)&&(e=Ti(e.code)),e)}d();function sx(e){return e.includes("*")?Li(e):!/\W/g.test(e)}function Ni(e){return e==="*"}function Li(e){return Ni(e)?!0:!(!e.includes("*")||e.split("*").length!==2||e.split("*").filter(t=>t.trim()==="").length!==1)}function ox(e){return !Ni(e)&&Li(e)&&!e.split("*")[0].trim()}function ax(e){return !Ni(e)&&Li(e)&&!e.split("*")[1].trim()}d();d();var en=class{},Aa=class extends en{constructor(t){super();}},Mi=class extends en{constructor(){super();}},tn=class extends Mi{constructor(t){super();}};d();var cx="^https?:",lx="^wss?:";function ux(e){let t=e.match(new RegExp(/^\w+:/,"gi"));if(!(!t||!t.length))return t[0]}function kd(e,t){let r=ux(e);return typeof r=="undefined"?!1:new RegExp(t).test(r)}function fx(e){return kd(e,cx)}function Fi(e){return kd(e,lx)}function Oa(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}d();function Ta(e){return typeof e=="object"&&"id"in e&&"jsonrpc"in e&&e.jsonrpc==="2.0"}function Bi(e){return Ta(e)&&"method"in e}function br(e){return Ta(e)&&(ki(e)||zt(e))}function ki(e){return "result"in e}function zt(e){return "error"in e}function hx(e){return "error"in e&&e.valid===!1}var Ui=class extends tn{constructor(t){super(t),this.events=new EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners();}connect(){return g(this,arguments,function*(t=this.connection){yield this.open(t);})}disconnect(){return g(this,null,function*(){yield this.close();})}on(t,r){this.events.on(t,r);}once(t,r){this.events.once(t,r);}off(t,r){this.events.off(t,r);}removeListener(t,r){this.events.removeListener(t,r);}request(t,r){return g(this,null,function*(){return this.requestStrict(wr(t.method,t.params||[],t.id||yr().toString()),r)})}requestStrict(t,r){return g(this,null,function*(){return new Promise((n,i)=>g(this,null,function*(){if(!this.connection.connected)try{yield this.open();}catch(s){i(s);}this.events.on(`${t.id}`,s=>{zt(s)?i(s.error):n(s.result);});try{yield this.connection.send(t,r);}catch(s){i(s);}}))})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),br(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params});}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect");}open(){return g(this,arguments,function*(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(yield this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),yield this.connection.open(),this.registerEventListeners(),this.events.emit("connect"));})}close(){return g(this,null,function*(){yield this.connection.close();})}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0);}};d();var AC=()=>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:Zp(),OC=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",eg=e=>e.split("?")[0],tg=10,TC=AC(),Gi=class{constructor(t){if(this.url=t,this.events=new EventEmitter,this.registering=!1,!Fi(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t;}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,r){this.events.on(t,r);}once(t,r){this.events.once(t,r);}off(t,r){this.events.off(t,r);}removeListener(t,r){this.events.removeListener(t,r);}open(){return g(this,arguments,function*(t=this.url){yield this.register(t);})}close(){return g(this,null,function*(){return new Promise((t,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),t();},this.socket.close();})})}send(t){return g(this,null,function*(){typeof this.socket>"u"&&(this.socket=yield this.register());try{this.socket.send(qe(t));}catch(r){this.onError(t.id,r);}})}register(t=this.url){if(!Fi(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){let r=this.events.getMaxListeners();return (this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((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=t,this.registering=!0,new Promise((r,n)=>{let i=new URLSearchParams(t).get("origin"),s=(0, Ce.isReactNative)()?{headers:{origin:i}}:{rejectUnauthorized:!Oa(t)},o=new TC(t,[],s);OC()?o.onerror=a=>{let c=a;n(this.emitError(c.error));}:o.on("error",a=>{n(this.emitError(a));}),o.onopen=()=>{this.onOpen(o),r(o);};})}onOpen(t){t.onmessage=r=>this.onPayload(r),t.onclose=r=>this.onClose(r),this.socket=t,this.registering=!1,this.events.emit("open");}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t);}onPayload(t){if(typeof t.data>"u")return;let r=typeof t.data=="string"?et(t.data):t.data;this.events.emit("payload",r);}onError(t,r){let n=this.parseError(r),i=n.message||n.toString(),s=Zr(t,i);this.events.emit("payload",s);}parseError(t,r=this.url){return xa(t,eg(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>tg&&this.events.setMaxListeners(tg);}emitError(t){let r=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${eg(this.url)}`));return this.events.emit("register_error",r),r}};var wm=Ye(Fg()),bm=Ye(Bg());var Sm="wc",_m=2,rl="core",at=`${Sm}@2:${rl}:`,nD={name:rl,logger:"error"},iD={database:":memory:"},sD="crypto",Hg="client_ed25519_seed",oD=z.ONE_DAY,aD="keychain",cD="0.3",lD="messages",uD="0.3",fD=z.SIX_HOURS,hD="publisher",dD="irn",pD="error",Em="wss://relay.walletconnect.org",gD="relayer",ze={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"},mD="_subscription",Ve={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},yD=.1;var Pc="2.17.2";var Ir={link_mode:"link_mode",relay:"relay"},wD="0.3",bD="WALLETCONNECT_CLIENT_ID",Jg="WALLETCONNECT_LINK_MODE_APPS",ot={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var SD="subscription",_D="0.3",ED=z.FIVE_SECONDS*1e3,vD="pairing",xD="0.3";var mn={wc_pairingDelete:{req:{ttl:z.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:z.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:z.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:z.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:z.ONE_DAY,prompt:!1,tag:0},res:{ttl:z.ONE_DAY,prompt:!1,tag:0}}},yn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Qe={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},CD="history",ID="0.3",DD="expirer",Ze={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},AD="0.3";var OD="verify-api",TD="https://verify.walletconnect.com",vm="https://verify.walletconnect.org",is=vm,RD=`${is}/v3`,PD=[TD,vm],ND="echo",LD="https://echo.walletconnect.com";var wt={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"},Ot={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"};var MD=.1,FD="event-client",BD=86400,kD="https://pulse.walletconnect.org/batch";function UD(e,t){if(e.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<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i;}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var y=0,w=0,S=0,b=u.length;S!==b&&u[S]===0;)S++,y++;for(var _=(b-S)*l+1>>>0,C=new Uint8Array(_);S!==b;){for(var T=u[S],M=0,v=_-1;(T!==0||M<w)&&v!==-1;v--,M++)T+=256*C[v]>>>0,C[v]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");w=M,S++;}for(var I=_-w;I!==_&&C[I]===0;)I++;for(var B=c.repeat(y);I<_;++I)B+=e.charAt(C[I]);return B}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var y=0;if(u[y]!==" "){for(var w=0,S=0;u[y]===c;)w++,y++;for(var b=(u.length-y)*h+1>>>0,_=new Uint8Array(b);u[y];){var C=r[u.charCodeAt(y)];if(C===255)return;for(var T=0,M=b-1;(C!==0||T<S)&&M!==-1;M--,T++)C+=a*_[M]>>>0,_[M]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");S=T,y++;}if(u[y]!==" "){for(var v=b-S;v!==b&&_[v]===0;)v++;for(var I=new Uint8Array(w+(b-v)),B=w;v!==b;)I[B++]=_[v++];return I}}}function p(u){var y=m(u);if(y)return y;throw new Error(`Non-${t} character`)}return {encode:f,decodeUnsafe:m,decode:p}}var WD=UD,KD=WD,xm=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},jD=e=>new TextEncoder().encode(e),zD=e=>new TextDecoder().decode(e),Nc=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n;}encode(t){if(t instanceof Uint8Array)return `${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Lc=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n;}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Cm(this,t)}},Mc=class{constructor(t){this.decoders=t;}or(t){return Cm(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Cm=(e,t)=>new Mc(F(F({},e.decoders||{[e.prefix]:e}),t.decoders||{[t.prefix]:t})),Fc=class{constructor(t,r,n,i){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Nc(t,r,n),this.decoder=new Lc(t,r,i);}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},ss=({name:e,prefix:t,encode:r,decode:n})=>new Fc(e,t,r,n),vn=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:i}=KD(r,t);return ss({prefix:e,name:t,encode:n,decode:s=>xm(i(s))})},$D=(e,t,r,n)=>{let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;e[s-1]==="=";)--s;let o=new Uint8Array(s*r/8|0),a=0,c=0,h=0;for(let l=0;l<s;++l){let f=i[e[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a);}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},qD=(e,t,r)=>{let n=t[t.length-1]==="=",i=(1<<r)-1,s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},Se=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>ss({prefix:t,name:e,encode(i){return qD(i,n,r)},decode(i){return $D(i,n,r,e)}}),GD=ss({prefix:"\0",name:"identity",encode:e=>zD(e),decode:e=>jD(e)}),VD=Object.freeze({__proto__:null,identity:GD}),HD=Se({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),JD=Object.freeze({__proto__:null,base2:HD}),YD=Se({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),XD=Object.freeze({__proto__:null,base8:YD}),QD=vn({prefix:"9",name:"base10",alphabet:"0123456789"}),ZD=Object.freeze({__proto__:null,base10:QD}),eA=Se({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),tA=Se({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),rA=Object.freeze({__proto__:null,base16:eA,base16upper:tA}),nA=Se({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),iA=Se({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),sA=Se({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),oA=Se({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),aA=Se({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),cA=Se({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),lA=Se({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),uA=Se({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),fA=Se({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),hA=Object.freeze({__proto__:null,base32:nA,base32upper:iA,base32pad:sA,base32padupper:oA,base32hex:aA,base32hexupper:cA,base32hexpad:lA,base32hexpadupper:uA,base32z:fA}),dA=vn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),pA=vn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),gA=Object.freeze({__proto__:null,base36:dA,base36upper:pA}),mA=vn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),yA=vn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),wA=Object.freeze({__proto__:null,base58btc:mA,base58flickr:yA}),bA=Se({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),SA=Se({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_A=Se({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),EA=Se({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),vA=Object.freeze({__proto__:null,base64:bA,base64pad:SA,base64url:_A,base64urlpad:EA}),Im=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),xA=Im.reduce((e,t,r)=>(e[r]=t,e),[]),CA=Im.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function IA(e){return e.reduce((t,r)=>(t+=xA[r],t),"")}function DA(e){let t=[];for(let r of e){let n=CA[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n);}return new Uint8Array(t)}var AA=ss({prefix:"\u{1F680}",name:"base256emoji",encode:IA,decode:DA}),OA=Object.freeze({__proto__:null,base256emoji:AA}),TA=Dm,Yg=128,RA=127,PA=~RA,NA=Math.pow(2,31);function Dm(e,t,r){t=t||[],r=r||0;for(var n=r;e>=NA;)t[r++]=e&255|Yg,e/=128;for(;e&PA;)t[r++]=e&255|Yg,e>>>=7;return t[r]=e|0,Dm.bytes=r-n+1,t}var LA=Bc,MA=128,Xg=127;function Bc(e,n){var r=0,n=n||0,i=0,s=n,o,a=e.length;do{if(s>=a)throw Bc.bytes=0,new RangeError("Could not decode varint");o=e[s++],r+=i<28?(o&Xg)<<i:(o&Xg)*Math.pow(2,i),i+=7;}while(o>=MA);return Bc.bytes=s-n,r}var FA=Math.pow(2,7),BA=Math.pow(2,14),kA=Math.pow(2,21),UA=Math.pow(2,28),WA=Math.pow(2,35),KA=Math.pow(2,42),jA=Math.pow(2,49),zA=Math.pow(2,56),$A=Math.pow(2,63),qA=function(e){return e<FA?1:e<BA?2:e<kA?3:e<UA?4:e<WA?5:e<KA?6:e<jA?7:e<zA?8:e<$A?9:10},GA={encode:TA,decode:LA,encodingLength:qA},Am=GA,Qg=(e,t,r=0)=>(Am.encode(e,t,r),t),Zg=e=>Am.encodingLength(e),kc=(e,t)=>{let r=t.byteLength,n=Zg(e),i=n+Zg(r),s=new Uint8Array(i+r);return Qg(e,s,0),Qg(r,s,n),s.set(t,i),new Uc(e,r,t,s)},Uc=class{constructor(t,r,n,i){this.code=t,this.size=r,this.digest=n,this.bytes=i;}},Om=({name:e,code:t,encode:r})=>new Wc(e,t,r),Wc=class{constructor(t,r,n){this.name=t,this.code=r,this.encode=n;}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?kc(this.code,r):r.then(n=>kc(this.code,n))}else throw Error("Unknown type, must be binary type")}},Tm=e=>t=>g(void 0,null,function*(){return new Uint8Array(yield crypto.subtle.digest(e,t))}),VA=Om({name:"sha2-256",code:18,encode:Tm("SHA-256")}),HA=Om({name:"sha2-512",code:19,encode:Tm("SHA-512")}),JA=Object.freeze({__proto__:null,sha256:VA,sha512:HA}),Rm=0,YA="identity",Pm=xm,XA=e=>kc(Rm,Pm(e)),QA={code:Rm,name:YA,encode:Pm,digest:XA},ZA=Object.freeze({__proto__:null,identity:QA});new TextEncoder,new TextDecoder;var em=F(F(F(F(F(F(F(F(F(F({},VD),JD),XD),ZD),rA),hA),gA),wA),vA),OA);F(F({},JA),ZA);function eO(e=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}function Nm(e,t,r,n){return {name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var tm=Nm("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Ic=Nm("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=eO(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),tO=F({utf8:tm,"utf-8":tm,hex:em.base16,latin1:Ic,ascii:Ic,binary:Ic},em);function rO(e,t="utf8"){let r=tO[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return (t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e,"utf8"):r.decoder.decode(`${r.prefix}${e}`)}var Kc=class{constructor(t,r){this.core=t,this.logger=r,this.keychain=new Map,this.name=aD,this.version=cD,this.initialized=!1,this.storagePrefix=at,this.init=()=>g(this,null,function*(){if(!this.initialized){let n=yield this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0;}}),this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=(n,i)=>g(this,null,function*(){this.isInitialized(),this.keychain.set(n,i),yield this.persist();}),this.get=n=>{this.isInitialized();let i=this.keychain.get(n);if(typeof i>"u"){let{message:s}=getInternalError("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=n=>g(this,null,function*(){this.isInitialized(),this.keychain.delete(n),yield this.persist();}),this.core=t,this.logger=Pe(r,this.name);}get context(){return ke(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}setKeyChain(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,mapToObj(t));})}getKeyChain(){return g(this,null,function*(){let t=yield this.core.storage.getItem(this.storageKey);return typeof t<"u"?objToMap(t):void 0})}persist(){return g(this,null,function*(){yield this.setKeyChain(this.keychain);})}isInitialized(){if(!this.initialized){let{message:t}=getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},jc=class{constructor(t,r,n){this.core=t,this.logger=r,this.name=sD,this.randomSessionIdentifier=generateRandomBytes32(),this.initialized=!1,this.init=()=>g(this,null,function*(){this.initialized||(yield this.keychain.init(),this.initialized=!0);}),this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=()=>g(this,null,function*(){this.isInitialized();let i=yield this.getClientSeed(),s=ba(i);return vi(s.publicKey)}),this.generateKeyPair=()=>{this.isInitialized();let i=generateKeyPair();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=i=>g(this,null,function*(){this.isInitialized();let s=yield this.getClientSeed(),o=ba(s),a=this.randomSessionIdentifier;return yield _d(a,i,oD,o)}),this.generateSharedKey=(i,s,o)=>{this.isInitialized();let a=this.getPrivateKey(i),c=deriveSymKey(a,s);return this.setSymKey(c,o)},this.setSymKey=(i,s)=>g(this,null,function*(){this.isInitialized();let o=s||hashKey(i);return yield this.keychain.set(o,i),o}),this.deleteKeyPair=i=>g(this,null,function*(){this.isInitialized(),yield this.keychain.del(i);}),this.deleteSymKey=i=>g(this,null,function*(){this.isInitialized(),yield this.keychain.del(i);}),this.encode=(i,s,o)=>g(this,null,function*(){this.isInitialized();let a=validateEncoding(o),c=qe(s);if(isTypeTwoEnvelope(a))return encodeTypeTwoEnvelope(c,o==null?void 0:o.encoding);if(isTypeOneEnvelope(a)){let m=a.senderPublicKey,p=a.receiverPublicKey;i=yield this.generateSharedKey(m,p);}let h=this.getSymKey(i),{type:l,senderPublicKey:f}=a;return encrypt({type:l,symKey:h,message:c,senderPublicKey:f,encoding:o==null?void 0:o.encoding})}),this.decode=(i,s,o)=>g(this,null,function*(){this.isInitialized();let a=validateDecoding(s,o);if(isTypeTwoEnvelope(a)){let c=decodeTypeTwoEnvelope(s,o==null?void 0:o.encoding);return et(c)}if(isTypeOneEnvelope(a)){let c=a.receiverPublicKey,h=a.senderPublicKey;i=yield this.generateSharedKey(c,h);}try{let c=this.getSymKey(i),h=decrypt({symKey:c,encoded:s,encoding:o==null?void 0:o.encoding});return et(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${yield this.getClientId()}'`),this.logger.error(c);}}),this.getPayloadType=(i,s=BASE64)=>{let o=deserialize({encoded:i,encoding:s});return decodeTypeByte(o.type)},this.getPayloadSenderPublicKey=(i,s=BASE64)=>{let o=deserialize({encoded:i,encoding:s});return o.senderPublicKey?Ea(o.senderPublicKey,BASE16):void 0},this.core=t,this.logger=Pe(r,this.name),this.keychain=n||new Kc(this.core,this.logger);}get context(){return ke(this.logger)}setPrivateKey(t,r){return g(this,null,function*(){return yield this.keychain.set(t,r),t})}getPrivateKey(t){return this.keychain.get(t)}getClientSeed(){return g(this,null,function*(){let t="";try{t=this.keychain.get(Hg);}catch(r){t=generateRandomBytes32(),yield this.keychain.set(Hg,t);}return rO(t,"base16")})}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){let{message:t}=getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},zc=class extends IMessageTracker{constructor(t,r){super(t,r),this.logger=t,this.core=r,this.messages=new Map,this.name=lD,this.version=uD,this.initialized=!1,this.storagePrefix=at,this.init=()=>g(this,null,function*(){if(!this.initialized){this.logger.trace("Initialized");try{let n=yield 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=(n,i)=>g(this,null,function*(){this.isInitialized();let s=hashMessage(i),o=this.messages.get(n);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=i,this.messages.set(n,o),yield 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();let s=this.get(n),o=hashMessage(i);return typeof s[o]<"u"},this.del=n=>g(this,null,function*(){this.isInitialized(),this.messages.delete(n),yield this.persist();}),this.logger=Pe(t,this.name),this.core=r;}get context(){return ke(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}setRelayerMessages(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,mapToObj(t));})}getRelayerMessages(){return g(this,null,function*(){let t=yield this.core.storage.getItem(this.storageKey);return typeof t<"u"?objToMap(t):void 0})}persist(){return g(this,null,function*(){yield this.setRelayerMessages(this.messages);})}isInitialized(){if(!this.initialized){let{message:t}=getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},$c=class extends IPublisher{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new EventEmitter,this.name=hD,this.queue=new Map,this.publishTimeout=(0, z.toMiliseconds)(z.ONE_MINUTE),this.failedPublishTimeout=(0, z.toMiliseconds)(z.ONE_SECOND),this.needsTransportRestart=!1,this.publish=(n,i,s)=>g(this,null,function*(){var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});let a=(s==null?void 0:s.ttl)||fD,c=getRelayProtocolName(s),h=(s==null?void 0:s.prompt)||!1,l=(s==null?void 0:s.tag)||0,f=(s==null?void 0:s.id)||yr().toString(),m={topic:n,message:i,opts:{ttl:a,relay:c,prompt:h,tag:l,id:f,attestation:s==null?void 0:s.attestation}},p=`Failed to publish payload, please try again. id:${f} tag:${l}`,u=Date.now(),y,w=1;try{for(;y===void 0;){if(Date.now()-u>this.publishTimeout)throw new Error(p);this.logger.trace({id:f,attempts:w},`publisher.publish - attempt ${w}`),y=yield yield createExpiringPromise(this.rpcPublish(n,i,a,c,h,l,f,s==null?void 0:s.attestation).catch(S=>this.logger.warn(S)),this.publishTimeout,p),w++,y||(yield new Promise(S=>setTimeout(S,this.failedPublishTimeout)));}this.relayer.events.emit(ze.publish,m),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:f,topic:n,message:i,opts:s}});}catch(S){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(S),(o=s==null?void 0:s.internal)!=null&&o.throwOnFailedPublish)throw S;this.queue.set(f,m);}}),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=t,this.logger=Pe(r,this.name),this.registerEventListeners();}get context(){return ke(this.logger)}rpcPublish(t,r,n,i,s,o,a,c){var h,l,f,m;let p={method:getRelayProtocolApi(i.protocol).publish,params:{topic:t,message:r,ttl:n,prompt:s,tag:o,attestation:c},id:a};return isUndefined((h=p.params)==null?void 0:h.prompt)&&((l=p.params)==null||delete l.prompt),isUndefined((f=p.params)==null?void 0:f.tag)&&((m=p.params)==null||delete m.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:p}),this.relayer.request(p)}removeRequestFromQueue(t){this.queue.delete(t);}checkQueue(){this.queue.forEach(t=>g(this,null,function*(){let{topic:r,message:n,opts:i}=t;yield this.publish(r,n,i);}));}registerEventListeners(){this.relayer.core.heartbeat.on(Pt.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(ze.connection_stalled);return}this.checkQueue();}),this.relayer.on(ze.message_ack,t=>{this.removeRequestFromQueue(t.id.toString());});}},qc=class{constructor(){this.map=new Map,this.set=(t,r)=>{let n=this.get(t);this.exists(t,r)||this.map.set(t,[...n,r]);},this.get=t=>this.map.get(t)||[],this.exists=(t,r)=>this.get(t).includes(r),this.delete=(t,r)=>{if(typeof r>"u"){this.map.delete(t);return}if(!this.map.has(t))return;let n=this.get(t);if(!this.exists(t,r))return;let i=n.filter(s=>s!==r);if(!i.length){this.map.delete(t);return}this.map.set(t,i);},this.clear=()=>{this.map.clear();};}get topics(){return Array.from(this.map.keys())}},nO=Object.defineProperty,iO=Object.defineProperties,sO=Object.getOwnPropertyDescriptors,rm=Object.getOwnPropertySymbols,oO=Object.prototype.hasOwnProperty,aO=Object.prototype.propertyIsEnumerable,nm=(e,t,r)=>t in e?nO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wn=(e,t)=>{for(var r in t||(t={}))oO.call(t,r)&&nm(e,r,t[r]);if(rm)for(var r of rm(t))aO.call(t,r)&&nm(e,r,t[r]);return e},Dc=(e,t)=>iO(e,sO(t)),Gc=class extends ISubscriber{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new qc,this.events=new EventEmitter,this.name=SD,this.version=_D,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=at,this.subscribeTimeout=(0, z.toMiliseconds)(z.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=()=>g(this,null,function*(){this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=yield this.relayer.core.crypto.getClientId(),yield this.restore()),this.initialized=!0;}),this.subscribe=(n,i)=>g(this,null,function*(){this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{let s=getRelayProtocolName(i),o={topic:n,relay:s,transportType:i==null?void 0:i.transportType};this.pending.set(n,o);let a=yield 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=(n,i)=>g(this,null,function*(){yield this.restartToComplete(),this.isInitialized(),typeof(i==null?void 0:i.id)<"u"?yield this.unsubscribeById(n,i.id,i):yield this.unsubscribeByTopic(n,i);}),this.isSubscribed=n=>g(this,null,function*(){if(this.topics.includes(n))return !0;let i=`${this.pendingSubscriptionWatchLabel}_${n}`;return yield new Promise((s,o)=>{let a=new z.Watch;a.start(i);let c=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(c),a.stop(i),s(!0)),a.elapsed(i)>=ED&&(clearInterval(c),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=()=>g(this,null,function*(){yield this.onConnect();}),this.stop=()=>g(this,null,function*(){yield this.onDisconnect();}),this.restart=()=>g(this,null,function*(){this.restartInProgress=!0,yield this.restore(),yield this.reset(),this.restartInProgress=!1;}),this.relayer=t,this.logger=Pe(r,this.name),this.clientId="";}get context(){return ke(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(t,r){let n=!1;try{n=this.getSubscription(t).topic===r;}catch(i){}return n}onEnable(){this.cached=[],this.initialized=!0;}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear();}unsubscribeByTopic(t,r){return g(this,null,function*(){let n=this.topicMap.get(t);yield Promise.all(n.map(i=>g(this,null,function*(){return yield this.unsubscribeById(t,i,r)})));})}unsubscribeById(t,r,n){return g(this,null,function*(){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:n}});try{let i=getRelayProtocolName(n);yield this.rpcUnsubscribe(t,r,i);let s=getSdkError("USER_DISCONNECTED",`${this.name}, ${t}`);yield this.onUnsubscribe(t,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:n}});}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}})}rpcSubscribe(t,r,n){return g(this,null,function*(){var i;(n==null?void 0:n.transportType)===Ir.relay&&(yield this.restartToComplete());let s={method:getRelayProtocolApi(r.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(i=n==null?void 0:n.internal)==null?void 0:i.throwOnFailedPublish;try{let a=hashMessage(t+this.clientId);if((n==null?void 0:n.transportType)===Ir.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(h=>this.logger.warn(h));},(0,z.toMiliseconds)(z.ONE_SECOND)),a;let c=yield createExpiringPromise(this.relayer.request(s).catch(h=>this.logger.warn(h)),this.subscribeTimeout,`Subscribing to ${t} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${t} failed, please try again`);return c?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(ze.connection_stalled),o)throw a}return null})}rpcBatchSubscribe(t){return g(this,null,function*(){if(!t.length)return;let r=t[0].relay,n={method:getRelayProtocolApi(r.protocol).batchSubscribe,params:{topics:t.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return yield yield createExpiringPromise(this.relayer.request(n).catch(i=>this.logger.warn(i)),this.subscribeTimeout)}catch(i){this.relayer.events.emit(ze.connection_stalled);}})}rpcBatchFetchMessages(t){return g(this,null,function*(){if(!t.length)return;let r=t[0].relay,n={method:getRelayProtocolApi(r.protocol).batchFetchMessages,params:{topics:t.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=yield yield createExpiringPromise(this.relayer.request(n).catch(s=>this.logger.warn(s)),this.subscribeTimeout);}catch(s){this.relayer.events.emit(ze.connection_stalled);}return i})}rpcUnsubscribe(t,r,n){let i={method:getRelayProtocolApi(n.protocol).unsubscribe,params:{topic:t,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(t,r){this.setSubscription(t,Dc(wn({},r),{id:t})),this.pending.delete(r.topic);}onBatchSubscribe(t){t.length&&t.forEach(r=>{this.setSubscription(r.id,wn({},r)),this.pending.delete(r.topic);});}onUnsubscribe(t,r,n){return g(this,null,function*(){this.events.removeAllListeners(r),this.hasSubscription(r,t)&&this.deleteSubscription(r,n),yield this.relayer.messages.del(t);})}setRelayerSubscriptions(t){return g(this,null,function*(){yield this.relayer.core.storage.setItem(this.storageKey,t);})}getRelayerSubscriptions(){return g(this,null,function*(){return yield this.relayer.core.storage.getItem(this.storageKey)})}setSubscription(t,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:r}),this.addSubscription(t,r);}addSubscription(t,r){this.subscriptions.set(t,wn({},r)),this.topicMap.set(r.topic,t),this.events.emit(ot.created,r);}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});let r=this.subscriptions.get(t);if(!r){let{message:n}=getInternalError("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return r}deleteSubscription(t,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:r});let n=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(n.topic,t),this.events.emit(ot.deleted,Dc(wn({},n),{reason:r}));}persist(){return g(this,null,function*(){yield this.setRelayerSubscriptions(this.values),this.events.emit(ot.sync);})}reset(){return g(this,null,function*(){if(this.cached.length){let t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){let n=this.cached.splice(0,this.batchSubscribeTopicsLimit);yield this.batchFetchMessages(n),yield this.batchSubscribe(n);}}this.events.emit(ot.resubscribed);})}restore(){return g(this,null,function*(){try{let t=yield this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){let{message:r}=getInternalError("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values});}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t);}})}batchSubscribe(t){return g(this,null,function*(){if(!t.length)return;let r=yield this.rpcBatchSubscribe(t);isValidArray(r)&&this.onBatchSubscribe(r.map((n,i)=>Dc(wn({},t[i]),{id:n})));})}batchFetchMessages(t){return g(this,null,function*(){if(!t.length)return;this.logger.trace(`Fetching batch messages for ${t.length} subscriptions`);let r=yield this.rpcBatchFetchMessages(t);r&&r.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(r.messages));})}onConnect(){return g(this,null,function*(){yield this.restart(),this.onEnable();})}onDisconnect(){this.onDisable();}checkPending(){return g(this,null,function*(){if(!this.initialized||!this.relayer.connected)return;let t=[];this.pending.forEach(r=>{t.push(r);}),yield this.batchSubscribe(t),this.pendingBatchMessages.length&&(yield this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[]);})}registerEventListeners(){this.relayer.core.heartbeat.on(Pt.pulse,()=>g(this,null,function*(){yield this.checkPending();})),this.events.on(ot.created,t=>g(this,null,function*(){let r=ot.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),yield this.persist();})),this.events.on(ot.deleted,t=>g(this,null,function*(){let r=ot.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),yield this.persist();}));}isInitialized(){if(!this.initialized){let{message:t}=getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}restartToComplete(){return g(this,null,function*(){!this.relayer.connected&&!this.relayer.connecting&&(yield this.relayer.transportOpen()),this.restartInProgress&&(yield new Promise(t=>{let r=setInterval(()=>{this.restartInProgress||(clearInterval(r),t());},this.pollingInterval);}));})}},cO=Object.defineProperty,im=Object.getOwnPropertySymbols,lO=Object.prototype.hasOwnProperty,uO=Object.prototype.propertyIsEnumerable,sm=(e,t,r)=>t in e?cO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,om=(e,t)=>{for(var r in t||(t={}))lO.call(t,r)&&sm(e,r,t[r]);if(im)for(var r of im(t))uO.call(t,r)&&sm(e,r,t[r]);return e},Vc=class extends IRelayer{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new EventEmitter,this.name=gD,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0, z.toMiliseconds)(z.THIRTY_SECONDS+z.ONE_SECOND),this.request=r=>g(this,null,function*(){var n,i;this.logger.debug("Publishing Request Payload");let s=r.id||yr().toString();yield this.toEstablishConnection();try{let 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...");let a=yield new Promise((c,h)=>g(this,null,function*(){let l=()=>{h(new Error(`relayer.request - publish interrupted, id: ${s}`));};this.provider.on(Ve.disconnect,l);let f=yield o;this.provider.off(Ve.disconnect,l),c(f);}));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(isNode())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(ze.connect);},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect();},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(ze.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose();},this.registerProviderListeners=()=>{this.provider.on(Ve.payload,this.onPayloadHandler),this.provider.on(Ve.connect,this.onConnectHandler),this.provider.on(Ve.disconnect,this.onDisconnectHandler),this.provider.on(Ve.error,this.onProviderErrorHandler);},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?Pe(t.logger,this.name):(0, Ao.default)(To({level:t.logger||pD})),this.messages=new zc(this.logger,t.core),this.subscriber=new Gc(this,this.logger),this.publisher=new $c(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||Em,this.projectId=t.projectId,this.bundleId=getBundleId(),this.provider={};}init(){return g(this,null,function*(){if(this.logger.trace("Initialized"),this.registerEventListeners(),yield Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{yield this.transportOpen();}catch(t){this.logger.warn(t);}})}get context(){return ke(this.logger)}get connected(){var t,r,n;return ((n=(r=(t=this.provider)==null?void 0:t.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===1}get connecting(){var t,r,n;return ((n=(r=(t=this.provider)==null?void 0:t.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===0}publish(t,r,n){return g(this,null,function*(){this.isInitialized(),yield this.publisher.publish(t,r,n),yield this.recordMessageEvent({topic:t,message:r,publishedAt:Date.now(),transportType:Ir.relay});})}subscribe(t,r){return g(this,null,function*(){var n,i,s;this.isInitialized(),(r==null?void 0:r.transportType)==="relay"&&(yield this.toEstablishConnection());let 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,a=((s=this.subscriber.topicMap.get(t))==null?void 0:s[0])||"",c,h=l=>{l.topic===t&&(this.subscriber.off(ot.created,h),c());};return yield Promise.all([new Promise(l=>{c=l,this.subscriber.on(ot.created,h);}),new Promise((l,f)=>g(this,null,function*(){a=(yield this.subscriber.subscribe(t,om({internal:{throwOnFailedPublish:o}},r)).catch(m=>{o&&f(m);}))||a,l();}))]),a})}unsubscribe(t,r){return g(this,null,function*(){this.isInitialized(),yield this.subscriber.unsubscribe(t,r);})}on(t,r){this.events.on(t,r);}once(t,r){this.events.once(t,r);}off(t,r){this.events.off(t,r);}removeListener(t,r){this.events.removeListener(t,r);}transportDisconnect(){return g(this,null,function*(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{yield Promise.all(Array.from(this.requestsInFlight.values()).map(t=>t.promise));}catch(t){this.logger.warn(t);}this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?yield createExpiringPromise(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect();})}transportClose(){return g(this,null,function*(){this.transportExplicitlyClosed=!0,yield this.transportDisconnect();})}transportOpen(t){return g(this,null,function*(){yield this.confirmOnlineStateOrThrow(),t&&t!==this.relayUrl&&(this.relayUrl=t,yield this.transportDisconnect()),yield this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{yield new Promise((r,n)=>g(this,null,function*(){let i=()=>{this.provider.off(Ve.disconnect,i),n(new Error("Connection interrupted while trying to subscribe"));};this.provider.on(Ve.disconnect,i),yield createExpiringPromise(this.provider.connect(),(0,z.toMiliseconds)(z.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);let n=r;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(n.message))throw r}finally{this.connectionAttemptInProgress=!1;}})}restartTransport(t){return g(this,null,function*(){this.connectionAttemptInProgress||(this.relayUrl=t||this.relayUrl,yield this.confirmOnlineStateOrThrow(),yield this.transportClose(),yield this.transportOpen());})}confirmOnlineStateOrThrow(){return g(this,null,function*(){if(!(yield isOnline()))throw new Error("No internet connection detected. Please restart your network and try again.")})}handleBatchMessageEvents(t){return g(this,null,function*(){if((t==null?void 0:t.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let r=t.sort((n,i)=>n.publishedAt-i.publishedAt);this.logger.trace(`Batch of ${r.length} message events sorted`);for(let n of r)try{yield this.onMessageEvent(n);}catch(i){this.logger.warn(i);}this.logger.trace(`Batch of ${r.length} message events processed`);})}onLinkMessageEvent(t,r){return g(this,null,function*(){let{topic:n}=t;if(!r.sessionExists){let i=calcExpiry(z.FIVE_MINUTES),s={topic:n,expiry:i,relay:{protocol:"irn"},active:!1};yield this.core.pairing.pairings.set(n,s);}this.events.emit(ze.message,t),yield this.recordMessageEvent(t);})}startPingTimeout(){var t,r,n,i,s;if(isNode())try{(r=(t=this.provider)==null?void 0:t.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(t){return this.staleConnectionErrors.some(r=>t.includes(r))}createProvider(){return g(this,null,function*(){this.provider.connection&&this.unregisterProviderListeners();let t=yield this.core.crypto.signJWT(this.relayUrl);this.provider=new Ui(new Gi(formatRelayRpcUrl({sdkVersion:Pc,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners();})}recordMessageEvent(t){return g(this,null,function*(){let{topic:r,message:n}=t;yield this.messages.set(r,n);})}shouldIgnoreMessageEvent(t){return g(this,null,function*(){let{topic:r,message:n}=t;if(!n||n.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${n}`),!0;if(!(yield this.subscriber.isSubscribed(r)))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;let i=this.messages.has(r,n);return i&&this.logger.debug(`Ignoring duplicate message: ${n}`),i})}onProviderPayload(t){return g(this,null,function*(){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),Bi(t)){if(!t.method.endsWith(mD))return;let r=t.params,{topic:n,message:i,publishedAt:s,attestation:o}=r.data,a={topic:n,message:i,publishedAt:s,transportType:Ir.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(om({type:"event",event:r.id},a)),this.events.emit(r.id,a),yield this.acknowledgePayload(t),yield this.onMessageEvent(a);}else br(t)&&this.events.emit(ze.message_ack,t);})}onMessageEvent(t){return g(this,null,function*(){(yield this.shouldIgnoreMessageEvent(t))||(this.events.emit(ze.message,t),yield this.recordMessageEvent(t));})}acknowledgePayload(t){return g(this,null,function*(){let r=Pi(t.id,!0);yield this.provider.connection.send(r);})}unregisterProviderListeners(){this.provider.off(Ve.payload,this.onPayloadHandler),this.provider.off(Ve.connect,this.onConnectHandler),this.provider.off(Ve.disconnect,this.onDisconnectHandler),this.provider.off(Ve.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout);}registerEventListeners(){return g(this,null,function*(){let t=yield isOnline();subscribeToNetworkChange(r=>g(this,null,function*(){t!==r&&(t=r,r?yield this.restartTransport().catch(n=>this.logger.error(n)):(this.hasExperiencedNetworkDisruption=!0,yield this.transportDisconnect(),this.transportExplicitlyClosed=!1));}));})}onProviderDisconnect(){return g(this,null,function*(){yield this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(ze.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(()=>g(this,null,function*(){yield this.transportOpen().catch(t=>this.logger.error(t));}),(0, z.toMiliseconds)(yD))));})}isInitialized(){if(!this.initialized){let{message:t}=getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}toEstablishConnection(){return g(this,null,function*(){yield this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&(yield new Promise(t=>{let r=setInterval(()=>{this.connected&&(clearInterval(r),t());},this.connectionStatusPollingInterval);})),yield this.transportOpen());})}},fO=Object.defineProperty,am=Object.getOwnPropertySymbols,hO=Object.prototype.hasOwnProperty,dO=Object.prototype.propertyIsEnumerable,cm=(e,t,r)=>t in e?fO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,lm=(e,t)=>{for(var r in t||(t={}))hO.call(t,r)&&cm(e,r,t[r]);if(am)for(var r of am(t))dO.call(t,r)&&cm(e,r,t[r]);return e},Hc=class extends IStore{constructor(t,r,n,i=at,s=void 0){super(t,r,n,i),this.core=t,this.logger=r,this.name=n,this.map=new Map,this.version=wD,this.cached=[],this.initialized=!1,this.storagePrefix=at,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=()=>g(this,null,function*(){this.initialized||(this.logger.trace("Initialized"),yield this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!isUndefined(o)?this.map.set(this.getKey(o),o):isProposalStruct(o)?this.map.set(o.id,o):isSessionStruct(o)&&this.map.set(o.topic,o);}),this.cached=[],this.initialized=!0);}),this.set=(o,a)=>g(this,null,function*(){this.isInitialized(),this.map.has(o)?yield 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),yield this.persist());}),this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>(0, wm.default)(a[c],o[c]))):this.values),this.update=(o,a)=>g(this,null,function*(){this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});let c=lm(lm({},this.getData(o)),a);this.map.set(o,c),yield this.persist();}),this.delete=(o,a)=>g(this,null,function*(){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),yield this.persist());}),this.logger=Pe(r,this.name),this.storagePrefix=i,this.getKey=s;}get context(){return ke(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(t){this.recentlyDeleted.push(t),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2);}setDataStore(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,t);})}getDataStore(){return g(this,null,function*(){return yield this.core.storage.getItem(this.storageKey)})}getData(t){let r=this.map.get(t);if(!r){if(this.recentlyDeleted.includes(t)){let{message:i}=getInternalError("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${t}`);throw this.logger.error(i),new Error(i)}let{message:n}=getInternalError("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(n),new Error(n)}return r}persist(){return g(this,null,function*(){yield this.setDataStore(this.values);})}restore(){return g(this,null,function*(){try{let t=yield this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){let{message:r}=getInternalError("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values});}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t);}})}isInitialized(){if(!this.initialized){let{message:t}=getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},Jc=class{constructor(t,r){this.core=t,this.logger=r,this.name=vD,this.version=xD,this.events=new yI,this.initialized=!1,this.storagePrefix=at,this.ignoredPayloadTypes=[TYPE_1],this.registeredMethods=[],this.init=()=>g(this,null,function*(){this.initialized||(yield this.pairings.init(),yield 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=n=>g(this,null,function*(){this.isInitialized();let i=generateRandomBytes32(),s=yield this.core.crypto.setSymKey(i),o=calcExpiry(z.FIVE_MINUTES),a={protocol:dD},c={topic:s,expiry:o,relay:a,active:!1,methods:n==null?void 0:n.methods},h=formatUri({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(yn.create,c),this.core.expirer.set(s,o),yield this.pairings.set(s,c),yield this.core.relayer.subscribe(s,{transportType:n==null?void 0:n.transportType}),{topic:s,uri:h}}),this.pair=n=>g(this,null,function*(){this.isInitialized();let i=this.core.eventClient.createEvent({properties:{topic:n==null?void 0:n.uri,trace:[wt.pairing_started]}});this.isValidPair(n,i);let{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:h}=parseUri(n.uri);i.props.properties.topic=s,i.addTrace(wt.pairing_uri_validation_success),i.addTrace(wt.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(s)){if(l=this.pairings.get(s),i.addTrace(wt.existing_pairing),l.active)throw i.setError(Ot.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);i.addTrace(wt.pairing_not_expired);}let f=c||calcExpiry(z.FIVE_MINUTES),m={topic:s,relay:a,expiry:f,active:!1,methods:h};this.core.expirer.set(s,f),yield this.pairings.set(s,m),i.addTrace(wt.store_new_pairing),n.activatePairing&&(yield this.activate({topic:s})),this.events.emit(yn.create,m),i.addTrace(wt.emit_inactive_pairing),this.core.crypto.keychain.has(s)||(yield this.core.crypto.setSymKey(o,s)),i.addTrace(wt.subscribing_pairing_topic);try{yield this.core.relayer.confirmOnlineStateOrThrow();}catch(p){i.setError(Ot.no_internet_connection);}try{yield this.core.relayer.subscribe(s,{relay:a});}catch(p){throw i.setError(Ot.subscribe_pairing_topic_failure),p}return i.addTrace(wt.subscribe_pairing_topic_success),m}),this.activate=i=>g(this,[i],function*({topic:n}){this.isInitialized();let s=calcExpiry(z.THIRTY_DAYS);this.core.expirer.set(n,s),yield this.pairings.update(n,{active:!0,expiry:s});}),this.ping=n=>g(this,null,function*(){this.isInitialized(),yield this.isValidPing(n);let{topic:i}=n;if(this.pairings.keys.includes(i)){let s=yield this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=createDelayedPromise();this.events.once(engineEvent("pairing_ping",s),({error:h})=>{h?c(h):a();}),yield o();}}),this.updateExpiry=s=>g(this,[s],function*({topic:n,expiry:i}){this.isInitialized(),yield this.pairings.update(n,{expiry:i});}),this.updateMetadata=s=>g(this,[s],function*({topic:n,metadata:i}){this.isInitialized(),yield this.pairings.update(n,{peerMetadata:i});}),this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=n=>g(this,null,function*(){this.isInitialized(),yield this.isValidDisconnect(n);let{topic:i}=n;this.pairings.keys.includes(i)&&(yield this.sendRequest(i,"wc_pairingDelete",getSdkError("USER_DISCONNECTED")),yield this.deletePairing(i));}),this.formatUriFromPairing=n=>{this.isInitialized();let{topic:i,relay:s,expiry:o,methods:a}=n,c=this.core.crypto.keychain.get(i);return formatUri({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:c,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=(n,i,s)=>g(this,null,function*(){let o=wr(i,s),a=yield this.core.crypto.encode(n,o),c=mn[i].req;return this.core.history.set(n,o),this.core.relayer.publish(n,a,c),o.id}),this.sendResult=(n,i,s)=>g(this,null,function*(){let o=Pi(n,s),a=yield this.core.crypto.encode(i,o),c=yield this.core.history.get(i,n),h=mn[c.request.method].res;yield this.core.relayer.publish(i,a,h),yield this.core.history.resolve(o);}),this.sendError=(n,i,s)=>g(this,null,function*(){let o=Zr(n,s),a=yield this.core.crypto.encode(i,o),c=yield this.core.history.get(i,n),h=mn[c.request.method]?mn[c.request.method].res:mn.unregistered_method.res;yield this.core.relayer.publish(i,a,h),yield this.core.history.resolve(o);}),this.deletePairing=(n,i)=>g(this,null,function*(){yield this.core.relayer.unsubscribe(n),yield Promise.all([this.pairings.delete(n,getSdkError("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)]);}),this.cleanup=()=>g(this,null,function*(){let n=this.pairings.getAll().filter(i=>isExpired(i.expiry));yield Promise.all(n.map(i=>this.deletePairing(i.topic)));}),this.onRelayEventRequest=n=>{let{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=n=>g(this,null,function*(){let{topic:i,payload:s}=n,o=(yield 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=(n,i)=>g(this,null,function*(){let{id:s}=i;try{this.isValidPing({topic:n}),yield this.sendResult(s,n,!0),this.events.emit(yn.ping,{id:s,topic:n});}catch(o){yield this.sendError(s,n,o),this.logger.error(o);}}),this.onPairingPingResponse=(n,i)=>{let{id:s}=i;setTimeout(()=>{ki(i)?this.events.emit(engineEvent("pairing_ping",s),{}):zt(i)&&this.events.emit(engineEvent("pairing_ping",s),{error:i.error});},500);},this.onPairingDeleteRequest=(n,i)=>g(this,null,function*(){let{id:s}=i;try{this.isValidDisconnect({topic:n}),yield this.deletePairing(n),this.events.emit(yn.delete,{id:s,topic:n});}catch(o){yield this.sendError(s,n,o),this.logger.error(o);}}),this.onUnknownRpcMethodRequest=(n,i)=>g(this,null,function*(){let{id:s,method:o}=i;try{if(this.registeredMethods.includes(o))return;let a=getSdkError("WC_METHOD_UNSUPPORTED",o);yield this.sendError(s,n,a),this.logger.error(a);}catch(a){yield this.sendError(s,n,a),this.logger.error(a);}}),this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(getSdkError("WC_METHOD_UNSUPPORTED",n));},this.isValidPair=(n,i)=>{var s;if(!isValidParams(n)){let{message:a}=getInternalError("MISSING_OR_INVALID",`pair() params: ${n}`);throw i.setError(Ot.malformed_pairing_uri),new Error(a)}if(!isValidUrl(n.uri)){let{message:a}=getInternalError("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw i.setError(Ot.malformed_pairing_uri),new Error(a)}let o=parseUri(n==null?void 0:n.uri);if(!((s=o==null?void 0:o.relay)!=null&&s.protocol)){let{message:a}=getInternalError("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(Ot.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){let{message:a}=getInternalError("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(Ot.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&(0, z.toMiliseconds)(o==null?void 0:o.expiryTimestamp)<Date.now()){i.setError(Ot.pairing_expired);let{message:a}=getInternalError("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}},this.isValidPing=n=>g(this,null,function*(){if(!isValidParams(n)){let{message:s}=getInternalError("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}let{topic:i}=n;yield this.isValidPairingTopic(i);}),this.isValidDisconnect=n=>g(this,null,function*(){if(!isValidParams(n)){let{message:s}=getInternalError("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}let{topic:i}=n;yield this.isValidPairingTopic(i);}),this.isValidPairingTopic=n=>g(this,null,function*(){if(!isValidString(n,!1)){let{message:i}=getInternalError("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){let{message:i}=getInternalError("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(isExpired(this.pairings.get(n).expiry)){yield this.deletePairing(n);let{message:i}=getInternalError("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}}),this.core=t,this.logger=Pe(r,this.name),this.pairings=new Hc(this.core,this.logger,this.name,this.storagePrefix);}get context(){return ke(this.logger)}isInitialized(){if(!this.initialized){let{message:t}=getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(ze.message,t=>g(this,null,function*(){let{topic:r,message:n,transportType:i}=t;if(!this.pairings.keys.includes(r)||i===Ir.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;let s=yield this.core.crypto.decode(r,n);try{Bi(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):br(s)&&(yield this.core.history.resolve(s),yield this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id));}catch(o){this.logger.error(o);}}));}registerExpirerEvents(){this.core.expirer.on(Ze.expired,t=>g(this,null,function*(){let{topic:r}=parseExpirerTarget(t.target);r&&this.pairings.keys.includes(r)&&(yield this.deletePairing(r,!0),this.events.emit(yn.expire,{topic:r}));}));}},Yc=class extends IJsonRpcHistory{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new EventEmitter,this.name=CD,this.version=ID,this.cached=[],this.initialized=!1,this.storagePrefix=at,this.init=()=>g(this,null,function*(){this.initialized||(this.logger.trace("Initialized"),yield 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;let o={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s,expiry:calcExpiry(z.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Qe.created,o);},this.resolve=n=>g(this,null,function*(){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;let i=yield this.getRecord(n.id);typeof i.response>"u"&&(i.response=zt(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.persist(),this.events.emit(Qe.updated,i));}),this.get=(n,i)=>g(this,null,function*(){return this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i}),yield 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(Qe.deleted,s);}}),this.persist();},this.exists=(n,i)=>g(this,null,function*(){return this.isInitialized(),this.records.has(i)?(yield 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=Pe(r,this.name);}get context(){return ke(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let t=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;let n={topic:r.topic,request:wr(r.request.method,r.request.params,r.id),chainId:r.chainId};return t.push(n)}),t}setJsonRpcRecords(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,t);})}getJsonRpcRecords(){return g(this,null,function*(){return yield this.core.storage.getItem(this.storageKey)})}getRecord(t){this.isInitialized();let r=this.records.get(t);if(!r){let{message:n}=getInternalError("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return r}persist(){return g(this,null,function*(){yield this.setJsonRpcRecords(this.values),this.events.emit(Qe.sync);})}restore(){return g(this,null,function*(){try{let t=yield this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){let{message:r}=getInternalError("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values});}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t);}})}registerEventListeners(){this.events.on(Qe.created,t=>{let r=Qe.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t});}),this.events.on(Qe.updated,t=>{let r=Qe.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t});}),this.events.on(Qe.deleted,t=>{let r=Qe.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t});}),this.core.heartbeat.on(Pt.pulse,()=>{this.cleanup();});}cleanup(){try{this.isInitialized();let t=!1;this.records.forEach(r=>{(0,z.toMiliseconds)(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Qe.deleted,r,!1),t=!0);}),t&&this.persist();}catch(t){this.logger.warn(t);}}isInitialized(){if(!this.initialized){let{message:t}=getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},Xc=class extends IExpirer{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new EventEmitter,this.name=DD,this.version=AD,this.cached=[],this.initialized=!1,this.storagePrefix=at,this.init=()=>g(this,null,function*(){this.initialized||(this.logger.trace("Initialized"),yield this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0);}),this.has=n=>{try{let i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch(i){return !1}},this.set=(n,i)=>{this.isInitialized();let s=this.formatTarget(n),o={target:s,expiry:i};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Ze.created,{target:s,expiration:o});},this.get=n=>{this.isInitialized();let i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{if(this.isInitialized(),this.has(n)){let i=this.formatTarget(n),s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Ze.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=Pe(r,this.name);}get context(){return ke(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(t){if(typeof t=="string")return formatTopicTarget(t);if(typeof t=="number")return formatIdTarget(t);let{message:r}=getInternalError("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(r)}setExpirations(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,t);})}getExpirations(){return g(this,null,function*(){return yield this.core.storage.getItem(this.storageKey)})}persist(){return g(this,null,function*(){yield this.setExpirations(this.values),this.events.emit(Ze.sync);})}restore(){return g(this,null,function*(){try{let t=yield this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){let{message:r}=getInternalError("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values});}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t);}})}getExpiration(t){let r=this.expirations.get(t);if(!r){let{message:n}=getInternalError("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.warn(n),new Error(n)}return r}checkExpiry(t,r){let{expiry:n}=r;(0, z.toMiliseconds)(n)-Date.now()<=0&&this.expire(t,r);}expire(t,r){this.expirations.delete(t),this.events.emit(Ze.expired,{target:t,expiration:r});}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,r)=>this.checkExpiry(r,t));}registerEventListeners(){this.core.heartbeat.on(Pt.pulse,()=>this.checkExpirations()),this.events.on(Ze.created,t=>{let r=Ze.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist();}),this.events.on(Ze.expired,t=>{let r=Ze.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist();}),this.events.on(Ze.deleted,t=>{let r=Ze.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist();});}isInitialized(){if(!this.initialized){let{message:t}=getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},Qc=class extends IVerify{constructor(t,r,n){super(t,r,n),this.core=t,this.logger=r,this.store=n,this.name=OD,this.verifyUrlV3=RD,this.storagePrefix=at,this.version=_m,this.init=()=>g(this,null,function*(){var i;this.isDevEnv||(this.publicKey=yield this.store.getItem(this.storeKey),this.publicKey&&(0, z.toMiliseconds)((i=this.publicKey)==null?void 0:i.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),yield this.removePublicKey()));}),this.register=i=>g(this,null,function*(){if(!isBrowser()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:a}=i,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{let h=(0,bm.getDocument)(),l=this.startAbortTimer(z.ONE_SECOND*5),f=yield new Promise((m,p)=>{let u=()=>{window.removeEventListener("message",w),h.body.removeChild(y),p("attestation aborted");};this.abortController.signal.addEventListener("abort",u);let y=h.createElement("iframe");y.src=c,y.style.display="none",y.addEventListener("error",u,{signal:this.abortController.signal});let w=S=>{if(S.data&&typeof S.data=="string")try{let b=JSON.parse(S.data);if(b.type==="verify_attestation"){if(xi(b.attestation).payload.id!==o)return;clearInterval(l),h.body.removeChild(y),this.abortController.signal.removeEventListener("abort",u),window.removeEventListener("message",w),m(b.attestation===null?"":b.attestation);}}catch(b){this.logger.warn(b);}};h.body.appendChild(y),window.addEventListener("message",w,{signal:this.abortController.signal});});return this.logger.debug("jwt attestation",f),f}catch(h){this.logger.warn(h);}return ""}),this.resolve=i=>g(this,null,function*(){if(this.isDevEnv)return "";let{attestationId:s,hash:o,encryptedId:a}=i;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(xi(s).payload.id!==a)return;let h=yield this.isValidJwtAttestation(s);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;let c=this.getVerifyUrl(i==null?void 0:i.verifyUrl);return this.fetchAttestation(o,c)}),this.fetchAttestation=(i,s)=>g(this,null,function*(){this.logger.debug(`resolving attestation: ${i} from url: ${s}`);let o=this.startAbortTimer(z.ONE_SECOND*5),a=yield fetch(`${s}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?yield a.json():void 0}),this.getVerifyUrl=i=>{let s=i||is;return PD.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${is}`),s=is),s},this.fetchPublicKey=()=>g(this,null,function*(){try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let i=this.startAbortTimer(z.FIVE_SECONDS),s=yield fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),yield s.json()}catch(i){this.logger.warn(i);}}),this.persistPublicKey=i=>g(this,null,function*(){this.logger.debug("persisting public key to local storage",i),yield this.store.setItem(this.storeKey,i),this.publicKey=i;}),this.removePublicKey=()=>g(this,null,function*(){this.logger.debug("removing verify v2 public key from storage"),yield this.store.removeItem(this.storeKey),this.publicKey=void 0;}),this.isValidJwtAttestation=i=>g(this,null,function*(){let s=yield this.getPublicKey();try{if(s)return this.validateAttestation(i,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation");}let o=yield this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation");}}),this.getPublicKey=()=>g(this,null,function*(){return this.publicKey?this.publicKey:yield this.fetchAndPersistPublicKey()}),this.fetchAndPersistPublicKey=()=>g(this,null,function*(){if(this.fetchPromise)return yield this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(s=>g(this,null,function*(){let o=yield this.fetchPublicKey();o&&(yield this.persistPublicKey(o),s(o));}));let i=yield this.fetchPromise;return this.fetchPromise=void 0,i}),this.validateAttestation=(i,s)=>{let o=verifyP256Jwt(i,s.publicKey),a={hasExpired:(0, z.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=Pe(r,this.name),this.abortController=new AbortController,this.isDevEnv=isTestRun(),this.init();}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return ke(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0, z.toMiliseconds)(t))}},Zc=class extends IEchoClient{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.context=ND,this.registerDeviceToken=n=>g(this,null,function*(){let{clientId:i,token:s,notificationType:o,enableEncrypted:a=!1}=n,c=`${LD}/${this.projectId}/clients`;yield fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:s,always_raw:a})});}),this.logger=Pe(r,this.context);}},pO=Object.defineProperty,um=Object.getOwnPropertySymbols,gO=Object.prototype.hasOwnProperty,mO=Object.prototype.propertyIsEnumerable,fm=(e,t,r)=>t in e?pO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bn=(e,t)=>{for(var r in t||(t={}))gO.call(t,r)&&fm(e,r,t[r]);if(um)for(var r of um(t))mO.call(t,r)&&fm(e,r,t[r]);return e},el=class extends IEventClient{constructor(t,r,n=!0){super(t,r,n),this.core=t,this.logger=r,this.context=FD,this.storagePrefix=at,this.storageVersion=MD,this.events=new Map,this.shouldPersist=!1,this.init=()=>g(this,null,function*(){if(!isTestRun())try{let i={eventId:uuidv4(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:yield this.core.crypto.getClientId(),user_agent:formatUA(this.core.relayer.protocol,this.core.relayer.version,Pc)}}};yield this.sendEvent([i]);}catch(i){this.logger.warn(i);}}),this.createEvent=i=>{let{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=i,h=uuidv4(),l=this.core.projectId||"",f=Date.now(),m=bn({eventId:h,timestamp:f,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:l,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,m),this.shouldPersist=!0),m},this.getEvent=i=>{let{eventId:s,topic:o}=i;if(s)return this.events.get(s);let a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return bn(bn({},a),this.setMethods(a.eventId))},this.deleteEvent=i=>{let{eventId:s}=i;this.events.delete(s),this.shouldPersist=!0;},this.setEventListeners=()=>{this.core.heartbeat.on(Pt.pulse,()=>g(this,null,function*(){this.shouldPersist&&(yield this.persist()),this.events.forEach(i=>{(0, z.fromMiliseconds)(Date.now())-(0, z.fromMiliseconds)(i.timestamp)>BD&&(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)=>{let o=this.events.get(i);o&&(o.props.properties.trace.push(s),this.events.set(i,o),this.shouldPersist=!0);},this.setError=(i,s)=>{let o=this.events.get(i);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(i,o),this.shouldPersist=!0);},this.persist=()=>g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1;}),this.restore=()=>g(this,null,function*(){try{let i=(yield this.core.storage.getItem(this.storageKey))||[];if(!i.length)return;i.forEach(s=>{this.events.set(s.eventId,bn(bn({},s),this.setMethods(s.eventId)));});}catch(i){this.logger.warn(i);}}),this.submit=()=>g(this,null,function*(){if(!this.telemetryEnabled||this.events.size===0)return;let i=[];for(let[s,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((yield this.sendEvent(i)).ok)for(let s of i)this.events.delete(s.eventId),this.shouldPersist=!0;}catch(s){this.logger.warn(s);}}),this.sendEvent=i=>g(this,null,function*(){let s=this.getAppDomain()?"":"&sp=desktop";return yield fetch(`${kD}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Pc}${s}`,{method:"POST",body:JSON.stringify(i)})}),this.getAppDomain=()=>getAppMetadata().url,this.logger=Pe(r,this.context),this.telemetryEnabled=n,n?this.restore().then(()=>g(this,null,function*(){yield this.submit(),this.setEventListeners();})):this.persist();}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},yO=Object.defineProperty,hm=Object.getOwnPropertySymbols,wO=Object.prototype.hasOwnProperty,bO=Object.prototype.propertyIsEnumerable,dm=(e,t,r)=>t in e?yO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pm=(e,t)=>{for(var r in t||(t={}))wO.call(t,r)&&dm(e,r,t[r]);if(hm)for(var r of hm(t))bO.call(t,r)&&dm(e,r,t[r]);return e},tl=class e extends ICore{constructor(t){var r;super(t),this.protocol=Sm,this.version=_m,this.name=rl,this.events=new EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;let h={topic:o,message:a,publishedAt:Date.now(),transportType:Ir.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:c});},this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||Em,this.customStoragePrefix=t!=null&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";let n=To({level:typeof(t==null?void 0:t.logger)=="string"&&t.logger?t.logger:nD.logger}),{logger:i,chunkLoggerController:s}=fh({opts:n,maxSizeInBytes:t==null?void 0:t.maxLogBlobSizeInBytes,loggerOverride:t==null?void 0:t.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=()=>g(this,null,function*(){var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:yield this.crypto.getClientId()}));})),this.logger=Pe(i,this.name),this.heartbeat=new $n,this.crypto=new jc(this,this.logger,t==null?void 0:t.keychain),this.history=new Yc(this,this.logger),this.expirer=new Xc(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new Vn(pm(pm({},iD),t==null?void 0:t.storageOptions)),this.relayer=new Vc({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Jc(this,this.logger),this.verify=new Qc(this,this.logger,this.storage),this.echoClient=new Zc(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new el(this,this.logger,t==null?void 0:t.telemetryEnabled);}static init(t){return g(this,null,function*(){let r=new e(t);yield r.initialize();let n=yield r.crypto.getClientId();return yield r.storage.setItem(bD,n),r})}get context(){return ke(this.logger)}start(){return g(this,null,function*(){this.initialized||(yield this.initialize());})}getLogsBlob(){return g(this,null,function*(){var t;return (t=this.logChunkController)==null?void 0:t.logsToBlob({clientId:yield this.crypto.getClientId()})})}addLinkModeSupportedApp(t){return g(this,null,function*(){this.linkModeSupportedApps.includes(t)||(this.linkModeSupportedApps.push(t),yield this.storage.setItem(Jg,this.linkModeSupportedApps));})}initialize(){return g(this,null,function*(){this.logger.trace("Initialized");try{yield this.crypto.init(),yield this.history.init(),yield this.expirer.init(),yield this.relayer.init(),yield this.heartbeat.init(),yield this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=(yield this.storage.getItem(Jg))||[],this.initialized=!0,this.logger.info("Core Initialization Success");}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}})}},Lm=tl;d();var He=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},Mm=()=>He()&&navigator.userAgent.toLowerCase().includes("android"),Fm=()=>He()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));d();var nl=(e,t,r=new Error("Promise timed out"))=>{let n=new Promise((i,s)=>{setTimeout(()=>{s(r);},t);});return Promise.race([e,n])};var Je=e=>{var v,I,B;if(!((B=(I=(v=N.getState().walletConnect)==null?void 0:v.options)==null?void 0:I.projectId)!=null&&B.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",r=(e==null?void 0:e.encoding)||"base64",n=R=>{if(!e)return;let{appUrl:A,formatNativeUrl:D}=e;if(He()){if(Mm()){let O=D(A.mobile.android,R,"android");window.open(O,"_self","noreferrer noopener");}if(Fm()){let O=D(A.mobile.ios,R,"ios");window.open(O,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:R}=U.getState();if(!R.get(t))throw new Error("walletConnect.signClient is not defined");R.delete(t),U.setState({wcSignClients:R}),N.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},s=R=>g(void 0,null,function*(){let{wcSignClients:A}=U.getState(),D=A.get(t);if(!D)throw new Error("walletConnect.signClient is not defined");if(!R)throw new Error("No wallet connect session");yield D.disconnect({topic:R,reason:getSdkError("USER_DISCONNECTED")}),yield c(D);}),o=R=>{try{let{wcSignClients:A}=U.getState(),D=A.get(t);if(!D)throw new Error("walletConnect.signClient is not defined");let O=D.session.getAll(),L=O.at(-1);if(!L)return;if(!(L.expiry*1e3>Date.now()+1e3))throw s(L.topic),new Error("invalid session");try{let q=O.find(ye=>{var Ae,Me;return (Me=(Ae=ye.requiredNamespaces.cosmos)==null?void 0:Ae.chains)==null?void 0:Me.includes(`cosmos:${R}`)});if(!q)throw new Error("no session");return q}catch(q){if(!q.message.toLowerCase().includes("no matching key"))throw q}return L}catch(A){if(!A.message.toLowerCase().includes("no matching key"))throw A}},a=R=>{try{return o(R)}catch(A){return}},c=R=>g(void 0,null,function*(){try{let A=R.core.pairing.pairings.getAll({active:!1});if(!A.length)return;yield Promise.all(A.map(D=>g(void 0,null,function*(){yield R.core.pairing.pairings.delete(D.topic,{code:7001,message:"clear pairing"});})));}catch(A){if(!A.message.toLowerCase().includes("no matching key"))throw A}}),h=()=>g(void 0,null,function*(){let{walletConnect:R}=N.getState();if(!(R!=null&&R.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:A}=U.getState(),D=A.get(t);if(D)return D;let O=new Lm({projectId:R.options.projectId}),L=yield SignClient.init(Q(F({},R.options),{core:O}));return A.set(t,L),U.setState({wcSignClients:A}),L}),l=R=>{let{wcSignClients:A}=U.getState(),D=A.get(t);if(!D)return ()=>{};let O=L=>{let K=U.getState().accounts;if(L.params.event.name==="accountsChanged"&&K&&!Object.values(K).map(q=>q.bech32Address).includes(L.params.event.data[0])){let q=L.params.chainId.split(":")[1];q&&f([q]);}else R();};return D.events.on("session_delete",i),D.events.on("session_expire",i),D.events.on("session_event",O),()=>{D.events.off("session_delete",i),D.events.off("session_expire",i),D.events.off("session_event",O);}},f=R=>g(void 0,null,function*(){var Me;let A=typeof R=="string"?[R]:R,{wcSignClients:D,activeChainIds:O}=U.getState(),L=D.get(t);if(!L)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:K,chains:q}=N.getState();if(!((Me=K==null?void 0:K.options)!=null&&Me.projectId))throw new Error("walletConnect.options.projectId is not defined");let ye=new WalletConnectModal(F({projectId:K.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},K.walletConnectModal)),Ae=a(A);if(!Ae){let{uri:V,approval:ie}=yield nl(L.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:A.map(Y=>`cosmos:${Y}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!V)throw new Error("No wallet connect uri");e?n(V):yield ye.openModal({uri:V});let se=Y=>g(void 0,null,function*(){return Y.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((oe,ee)=>{ie().then(le=>{let ue=le.sessionProperties;if(!ue)return ee(new Error("No session properties"));let ne=JSON.parse(String(ue.keys));if(ne.length===0)return ee(new Error("No accounts"));if(!ne[0])return ee(new Error("No accounts"));let fe={};return ne.forEach(X=>{fe[X.chainId]={address:X.address,algo:X.algo,bech32Address:X.bech32Address,isNanoLedger:X.isNanoLedger,isKeystone:X.isKeystone,name:X.name,pubKey:X.pubKey};}),U.setState(X=>({accounts:F(F({},X.accounts||{}),fe)})),oe(le)}).catch(ee),Y.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:!0});})});try{let Y=new AbortController,oe=Y.signal;ye.subscribeModal(ee=>{ee.open||Y.abort();}),yield se(oe);}catch(Y){if(ye.closeModal(),!Y.message.toLowerCase().includes("no matching key"))return Promise.reject(Y)}return e||ye.closeModal(),Promise.resolve()}try{yield nl((()=>g(void 0,null,function*(){var ie;let V=Object.fromEntries(yield Promise.all((ie=O||A)==null?void 0:ie.map(se=>g(void 0,null,function*(){return [se,yield p(se)]}))));U.setState({accounts:V});}))(),15e3,new Error("Connection timeout"));}catch(V){if(s(Ae.topic),!V.message.toLowerCase().includes("no matching key"))throw V}}),m=R=>g(void 0,null,function*(){let A=yield p(R);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),p=R=>g(void 0,null,function*(){var L;let A=o([R]);if(!(A!=null&&A.topic))throw new Error("No wallet connect session");(L=A.sessionConfig)==null||L.disableDeepLink;let D=A.sessionProperties&&JSON.parse(String(A.sessionProperties.keys));if(!D)throw new Error("No wallet connect key");if(D.length===0)throw new Error("No wallet connect session");let O=D.find(K=>K.chainId===R);if(!O)throw new Error(`No wallet connect key for chainId ${R}`);return Q(F({},O),{pubKey:Buffer.from(String(O.pubKey),r)})}),u=(...R)=>g(void 0,null,function*(){var Me,V;let[A,D,O]=R,{accounts:L,wcSignClients:K}=U.getState(),q=K.get(t);if(!q)throw new Error("walletConnect.signClient is not defined");if(!L)throw new Error("account is not defined");let ye=(Me=o([A]))==null?void 0:Me.topic;if(!ye)throw new Error("No wallet connect session");if(!O.bodyBytes)throw new Error("No bodyBytes");if(!O.authInfoBytes)throw new Error("No authInfoBytes");return n(),yield q.request({topic:ye,chainId:`cosmos:${A}`,request:{method:"cosmos_signDirect",params:{signerAddress:D,signDoc:{chainId:O.chainId,accountNumber:(V=O.accountNumber)==null?void 0:V.toString(),bodyBytes:O.bodyBytes?Buffer.from(O.bodyBytes).toString(r):null,authInfoBytes:O.authInfoBytes?Buffer.from(O.authInfoBytes).toString(r):null}}}})}),y=(...R)=>g(void 0,null,function*(){var q;let[A,D,O]=R,{signature:L,signed:K}=yield u(A,D,O);return {signed:{chainId:(q=K.chainId)!=null?q:"",accountNumber:K.accountNumber?Bm.fromString(K.accountNumber):new Bm(0),authInfoBytes:K.authInfoBytes?new Uint8Array(Buffer.from(K.authInfoBytes,r)):new Uint8Array([]),bodyBytes:K.bodyBytes?new Uint8Array(Buffer.from(K.bodyBytes,r)):new Uint8Array([])},signature:L}}),w=(...R)=>g(void 0,null,function*(){var V;let[A,D,O,L]=R,{wcSignClients:K}=U.getState(),q=K.get(t),{accounts:ye}=U.getState();if(!q)throw new Error("walletConnect.signClient is not defined");if(!ye)throw new Error("account is not defined");let Ae=(V=o([A]))==null?void 0:V.topic;if(!Ae)throw new Error("No wallet connect session");return n(),yield q.request({topic:Ae,chainId:`cosmos:${A}`,request:{method:"cosmos_signDirect",params:{signerAddress:D,signDoc:O}}})}),S=(...R)=>g(void 0,null,function*(){let[A,D,O,L]=R;return yield w(A,D,O)}),b=R=>({getAccounts:()=>g(void 0,null,function*(){return [yield m(R)]}),signDirect:(A,D)=>y(R,A,D)}),_=R=>({getAccounts:()=>g(void 0,null,function*(){return [yield m(R)]}),signAmino:(A,D)=>S(R,A,D)});return {enable:f,disable:R=>g(void 0,null,function*(){var O;let{wcSignClients:A}=U.getState(),D=A.get(t);if(R===void 0){let L=D==null?void 0:D.session.getAll();L!==void 0&&(yield Promise.all(L.map(K=>s(K.topic))));}else typeof R=="string"?yield s((O=o([R]))==null?void 0:O.topic):yield Promise.all(R.map(L=>{var K;return s((K=o([L]))==null?void 0:K.topic)}));(D==null?void 0:D.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...R)=>g(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:p,getOfflineSigner:R=>({getAccounts:()=>g(void 0,null,function*(){return [yield m(R)]}),signDirect:(A,D)=>y(R,A,D),signAmino:(A,D)=>S(R,A,D)}),getOfflineSignerAuto:R=>g(void 0,null,function*(){return (yield p(R)).isNanoLedger?_(R):b(R)}),getOfflineSignerOnlyAmino:_,signAmino:S,signDirect:y,subscription:l,init:h}};d();var km=()=>{var t,r,n;if(!((n=(r=(t=N.getState().walletConnect)==null?void 0:t.options)==null?void 0:r.projectId)!=null&&n.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!He())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(i,s,o)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=s&&encodeURIComponent(s);switch(o){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return Je(e)};d();var Um=()=>{var t,r,n;if(!((n=(r=(t=N.getState().walletConnect)==null?void 0:t.options)==null?void 0:r.projectId)!=null&&n.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!He())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(i,s,o)=>{let a=i.replaceAll("/","").replaceAll(":","");return s?`${a}://wc?${s}`:`${a}://wc`}};return Je(e)};d();var Wm=()=>{var t,r,n;if(!((n=(r=(t=N.getState().walletConnect)==null?void 0:t.options)==null?void 0:r.projectId)!=null&&n.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!He())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(i,s,o)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=s&&encodeURIComponent(s);switch(o){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;case"android":return c?`${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${a}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return Je(e)};d();var Km=()=>{var t,r,n;if(!((n=(r=(t=N.getState().walletConnect)==null?void 0:t.options)==null?void 0:r.projectId)!=null&&n.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!He())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(i,s,o)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=s&&encodeURIComponent(s);switch(o){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;case"android":return c?`${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${a}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return Je(e)};d();var os=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:i=>{let s=()=>{we(),i();};return window.addEventListener("keplr_keystorechange",s),()=>{window.removeEventListener("keplr_keystorechange",s);}}})}throw N.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var De=(e=N.getState().walletType)=>{try{return ae(e),!0}catch(t){return !1}},we=()=>{window.sessionStorage.removeItem(ct),U.setState(Qt);},ae=(e=N.getState().walletType)=>{var n;let t=(()=>{switch(e){case"keplr":return Tn();case"leap":return Rn();case"cosmostation":return On();case"vectis":return Mn();case"walletconnect":return Je();case"wc_keplr_mobile":return Wm();case"wc_leap_mobile":return Km();case"wc_cosmostation_mobile":return Um();case"wc_clot_mobile":return km();case"metamask_snap_leap":return Nl();case"metamask_snap_cosmos":return Ol();case"station":return Ln();case"xdefi":return os();case"capsule":return In();case"cosmiframe":return An();case"compass":return Dn();case"initia":return Rl();case"okx":return Nn();default:throw new Error("Unknown wallet type")}})(),r=N.getState().walletDefaultOptions;return r&&((n=t.setDefaultOptions)==null||n.call(t,r)),t},UM=()=>Object.fromEntries(Sl.map(e=>[e,De(e)])),il=e=>e==="capsule",sl=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Tt=e=>g(void 0,null,function*(){var t;try{let{recentChainIds:r,chains:n,walletType:i}=N.getState(),s=(e==null?void 0:e.walletType)||i;if(!De(s))throw new Error(`${s} is not available`);let a=ae(s),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||r;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let h=n==null?void 0:n.map(p=>p.chainId);c.forEach(p=>{if(!(h!=null&&h.includes(p)))throw new Error(`Chain ${p} is not provided in GrazProvider`)}),U.setState(p=>{let u=N.getState()._reconnect||!!N.getState()._reconnectConnector||!!c;return p.activeChainIds&&c.filter(w=>{var S;return !((S=p.activeChainIds)!=null&&S.includes(w))}).length>0?{status:"connecting"}:u?{status:"reconnecting"}:{status:"connecting"}});let{accounts:l}=U.getState();if(yield (t=a.init)==null?void 0:t.call(a),il(s)&&U.getState().capsuleClient&&Object.values(U.getState().accounts||[]).length>0){let p=c.map(w=>n.find(S=>S.chainId===w)),u=U.getState().accounts;U.setState({status:"connecting"});let y=Object.fromEntries(yield Promise.all(c.map(w=>g(void 0,null,function*(){return [w,yield a.getKey(w)]}))));return U.setState(w=>({accounts:F(F({},w.accounts||{}),y)})),N.setState(w=>({recentChainIds:[...w.recentChainIds||[],...c].filter((S,b,_)=>_.indexOf(S)===b)})),U.setState(w=>({activeChainIds:[...w.activeChainIds||[],...c].filter((S,b,_)=>_.indexOf(S)===b)})),U.setState({status:"connected"}),{accounts:u,walletType:s,chains:p}}if(yield a.enable(c),il(s)){let p=c.map(y=>n.find(w=>w.chainId===y)),u=U.getState().accounts;return U.setState({status:"connecting"}),{accounts:u,walletType:s,chains:p}}if(!sl(s)){let p=Object.fromEntries(yield Promise.all(c.map(u=>g(void 0,null,function*(){return [u,yield a.getKey(u)]}))));U.setState(u=>({accounts:F(F({},u.accounts||{}),p)}));}N.setState(p=>({recentChainIds:[...p.recentChainIds||[],...c].filter((u,y,w)=>w.indexOf(u)===y)})),U.setState(p=>({activeChainIds:[...p.activeChainIds||[],...c].filter((u,y,w)=>w.indexOf(u)===y)})),N.setState({walletType:s,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:s}),U.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(ct,"Active");let f=c.map(p=>n.find(u=>u.chainId===p));return {accounts:U.getState().accounts,walletType:s,chains:f}}catch(r){throw console.error("connect ",r),U.getState().accounts===null&&U.setState({status:"disconnected"}),U.getState().accounts&&U.getState().activeChainIds&&U.setState({status:"connected"}),r}}),xn=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(ct);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let r=U.getState().accounts;t.forEach(i=>{r==null||delete r[i];}),Object.values(r||{}).length===0?(U.setState(Qt),N.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(U.setState(i=>{var s;return {activeChainIds:(s=i.activeChainIds)==null?void 0:s.filter(o=>!t.includes(o)),accounts:r}}),N.setState(i=>{var s;return {recentChainIds:(s=i.recentChainIds)==null?void 0:s.filter(o=>!t.includes(o))}}));}else U.setState(Qt),N.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},Ne=e=>g(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:r,_reconnect:n}=N.getState();try{let s=De(r||void 0);if(t&&s&&r)return sl(r)?void 0:yield Tt({chainId:t,walletType:r,autoReconnect:n})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),xn();}}),jm=e=>g(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=N.getState(),r=e.walletType||t;if(!De(r))throw new Error(`${r} is not available`);let i=ae(r),s=i.getOfflineSigner(e.chainId),o=i.getOfflineSignerOnlyAmino(e.chainId),a=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:s,offlineSignerAmino:o,offlineSignerAuto:a}});d();var ol=()=>{N.setState({recentChainIds:null});},XM=()=>N.getState().recentChainIds,QM=()=>{var r;let{recentChainIds:e,chains:t}=N.getState();return (r=e==null?void 0:e.map(n=>t.find(i=>i.chainId===n)))!=null?r:null},ZM=({chainId:e})=>{var t;return (t=N.getState().chains)==null?void 0:t.find(r=>r.chainId===e)},e5=({chainId:e})=>{var t;return (t=N.getState().chains)==null?void 0:t.filter(r=>e==null?void 0:e.includes(r.chainId))},al=r=>g(void 0,[r],function*({chainInfo:e,walletType:t}){let n=ae(t);return t==="capsule"?yield Tt({chainId:e.chainId,walletType:t}):yield n.experimentalSuggestChain(e),e}),zm=e=>g(void 0,null,function*(){var n;let t=N.getState().walletType;return yield al({chainInfo:e.chainInfo,walletType:(n=e.walletType)!=null?n:t}),yield Tt({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});d();var $m=e=>(N.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);d();var qm=o=>g(void 0,[o],function*({signingClient:e,senderAddress:t,recipientAddress:r,amount:n,fee:i,memo:s}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,r,n,i,s)}),Gm=l=>g(void 0,[l],function*({signingClient:e,senderAddress:t,recipientAddress:r,transferAmount:n,sourcePort:i,sourceChannel:s,timeoutHeight:o,timeoutTimestamp:a,fee:c,memo:h}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,r,n,i,s,o,a,c,h)}),Vm=a=>g(void 0,[a],function*({signingClient:e,senderAddress:t,msg:r,fee:n,options:i,label:s,codeId:o}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,o,r,s,n,i)}),Hm=a=>g(void 0,[a],function*({signingClient:e,senderAddress:t,msg:r,fee:n,contractAddress:i,funds:s,memo:o}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,r,n,o,s)}),Jm=(e,t,r)=>g(void 0,null,function*(){if(!r)throw new Error("CosmWasm client is not ready");return yield r.queryContractSmart(e,t)}),Ym=(e,t,r)=>{if(!r)throw new Error("CosmWasm client is not ready");let n=new TextEncoder().encode(t);return r.queryContractRaw(e,n)};d();var u5=e=>e,f5=e=>e;d();d();var as=e=>e?Object.keys(e).length===0:!0;d();d();var cl=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Xm=e=>globalThis.DOMException===void 0?new cl(e):new DOMException(e),Qm=e=>{let t=e.reason===void 0?Xm("This operation was aborted."):e.reason;return t instanceof Error?t:Xm(t)};function ll(s,o){return g(this,arguments,function*(e,t,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:i}={}){return new Promise((a,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(r)||r===Number.POSITIVE_INFINITY)&&r>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let h=[],l=[],f=new Map,m=!1,p=!1,u=!1,y=0,w=0,S=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),b=C=>{m=!0,p=!0,c(C);};i&&(i.aborted&&b(Qm(i)),i.addEventListener("abort",()=>{b(Qm(i));}));let _=()=>g(this,null,function*(){if(p)return;let C=yield S.next(),T=w;if(w++,C.done){if(u=!0,y===0&&!p){if(!n&&l.length>0){b(new AggregateError(l));return}if(p=!0,f.size===0){a(h);return}let M=[];for(let[v,I]of h.entries())f.get(v)!==Zm&&M.push(I);a(M);}return}y++,g(this,null,function*(){try{let M=yield C.value;if(p)return;let v=yield t(M,T);v===Zm&&f.set(T,v),h[T]=v,y--,yield _();}catch(M){if(n)b(M);else {l.push(M),y--;try{yield _();}catch(v){b(v);}}}});});g(this,null,function*(){for(let C=0;C<r;C++){try{yield _();}catch(T){b(T);break}if(u||m)break}});})})}var Zm=Symbol("skip");var Le=({chainId:e,multiChain:t})=>{let r=N(i=>i.chains);if(!r)throw new Error("No chains found in GrazProvider");let n=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!n):return n.map(i=>r.find(s=>s.chainId===i)).filter(Boolean);case(!t&&!!n):return [n.map(i=>r.find(s=>s.chainId===i)).filter(Boolean)[0]];case(!!t&&!n):return r;default:return [r[0]]}},$e=(e,t,r)=>g(void 0,null,function*(){let n=N.getState().multiChainFetchConcurrency;if(e){let s=yield ll(t,r,{concurrency:n});return Object.fromEntries(s.map((o,a)=>[t[a].chainId,o]))}return yield r(t[0])}),ey=(e,t,r)=>{if(e){let i=t.map(r);return Object.fromEntries(i.map((s,o)=>[t[o].chainId,s]))}return r(t[0])};d();var hl=e=>{let t=Le({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:r,queryFn:i=>g(void 0,[i],function*({queryKey:[,n]}){if(n.length<1)throw new Error("No chains found");return yield $e(!!(e!=null&&e.multiChain),n,o=>g(void 0,null,function*(){var l;let a=(l=N.getState().chainsConfig)==null?void 0:l[o.chainId],c={url:o.rpc,headers:F({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},dl=e=>{let t=Le({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:r,queryFn:i=>g(void 0,[i],function*({queryKey:[,n]}){if(n.length<1)throw new Error("No chains found");return yield $e(!!(e!=null&&e.multiChain),n,o=>g(void 0,null,function*(){var l;let a=(l=N.getState().chainsConfig)==null?void 0:l[o.chainId],c={url:o.rpc,headers:F({},(a==null?void 0:a.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},cs=({type:e,chainId:t,multiChain:r,enabled:n})=>{let i=Le({chainId:t,multiChain:r}),s=useMemo(()=>["USE_TENDERMINT_CLIENT",e,i],[e,i]);return useQuery({queryKey:s,queryFn:c=>g(void 0,[c],function*({queryKey:[,o,a]}){if(a.length<1)throw new Error("No chains found");return yield $e(!!r,a,l=>g(void 0,null,function*(){var y;let f=(y=N.getState().chainsConfig)==null?void 0:y[l.chainId],m={url:l.rpc,headers:F({},(f==null?void 0:f.rpcHeaders)||{})};return yield (o==="tm37"?Tendermint37Client:Tendermint34Client).connect(m)}))}),enabled:!!i&&i.length>0&&(n!==void 0?!!n:!0),refetchOnWindowFocus:!1})};d();var k5=()=>N(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow),ls=e=>{let r=["USE_CHECK_WALLET",N(i=>e||i.walletType)];return useQuery({queryKey:r,queryFn:({queryKey:[,i]})=>De(i)})};var Rt=e=>{let t=N(a=>a.walletType),r=U(a=>a.activeChainIds),n=Le({chainId:e!=null&&e.chainId?e.chainId:r||void 0,multiChain:e==null?void 0:e.multiChain}),i=U(a=>a.accounts),s=U(a=>a.status);return useEffect(()=>U.subscribe(a=>a.status,(a,c)=>{var h,l,f;if(a==="connected"){let{accounts:m,activeChainIds:p}=U.getState(),{chains:u}=N.getState(),{walletType:y}=N.getState();if(!m||!p||!u)return (h=e==null?void 0:e.onDisconnect)==null?void 0:h.call(e);(l=e==null?void 0:e.onConnect)==null||l.call(e,{accounts:m,chains:p.map(w=>u.find(S=>S.chainId===w)),walletType:y,isReconnect:c==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:useMemo(()=>i?ey(!!(e!=null&&e.multiChain),n,a=>i[a.chainId]):void 0,[i,n,e==null?void 0:e.multiChain]),isConnected:s==="connected",isConnecting:s==="connecting",isDisconnected:s==="disconnected",isReconnecting:s==="reconnecting",isLoading:s==="connecting"||s==="reconnecting",walletType:s==="connected"?t:void 0,reconnect:Ne,status:s}},TO=e=>{let t=Le({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:r}=Rt(),n=(e==null?void 0:e.bech32Address)||(r==null?void 0:r.bech32Address),{data:i}=hl({chainId:t.map(o=>o.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!n}),s=useMemo(()=>["USE_ALL_BALANCES",i,t,n,e==null?void 0:e.chainId],[n,e==null?void 0:e.chainId,t,i]);return useQuery({queryKey:s,queryFn:h=>g(void 0,[h],function*({queryKey:[,o,a,c]}){if(!c)throw new Error("address is not defined");return yield $e(!!(e!=null&&e.multiChain),a,f=>g(void 0,null,function*(){var u;let m=o==null?void 0:o[f.chainId];if(!m)throw new Error(`Client is not ready ${f.chainId}`);if(!((u=f.bech32Config)!=null&&u.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${f.chainId}`);return yield m.getAllBalances(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!n&&!!t&&t.length>0&&!as(i)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},X5=e=>{let t=Le({chainId:e.chainId}),{data:r}=Rt({chainId:e.chainId}),n=e.bech32Address||(r==null?void 0:r.bech32Address),{data:i,refetch:s}=TO({chainId:t.map(c=>c.chainId),bech32Address:n,enabled:!!n&&(e.enabled===void 0?!0:e.enabled)}),o=["USE_BALANCE",e.denom,i,t,n,e.chainId],a=useQuery({queryKey:o,queryFn:({queryKey:[,c,h]})=>h==null?void 0:h.find(l=>l.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?!0:e.enabled)});return Q(F({},a),{refetch:c=>g(void 0,null,function*(){return yield s(),a.refetch(c)})})},Q5=({onError:e,onLoading:t,onSuccess:r}={})=>{let i=useMutation({mutationKey:["USE_CONNECT",e,t,r],mutationFn:Tt,onError:(o,a)=>e==null?void 0:e(o,a),onMutate:t,onSuccess:o=>Promise.resolve(r==null?void 0:r(o))}),{data:s}=ls();return {connect:o=>i.mutate(o),connectAsync:o=>i.mutateAsync(o),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!s,status:i.status}},Z5=({onError:e,onLoading:t,onSuccess:r}={})=>{let i=useMutation({mutationKey:["USE_DISCONNECT",e,t,r],mutationFn:xn,onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(r==null?void 0:r(void 0))});return {disconnect:s=>i.mutate(s),disconnectAsync:s=>i.mutateAsync(s),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},eF=e=>{let t=Le({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=N(i=>i.walletType),n=useMemo(()=>["USE_OFFLINE_SIGNERS",t,r],[t,r]);return useQuery({queryKey:n,queryFn:o=>g(void 0,[o],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chain found");if(!De(s))throw new Error(`${s} is not available`);return yield $e(!!(e!=null&&e.multiChain),i,h=>g(void 0,null,function*(){return yield jm({chainId:h.chainId,walletType:s})}))}),enabled:!!t&&t.length>0&&!!r,refetchOnWindowFocus:!1})},tF=e=>{let t=Le({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:r}=Rt(),{data:n}=hl({chainId:t.map(o=>o.chainId),multiChain:!0}),i=(e==null?void 0:e.bech32Address)||(r==null?void 0:r.bech32Address),s=useMemo(()=>["USE_BALANCE_STAKED",n,t,i],[t,i,n]);return useQuery({queryKey:s,queryFn:h=>g(void 0,[h],function*({queryKey:[,o,a,c]}){if(!c)throw new Error("address is not defined");return yield $e(!!(e!=null&&e.multiChain),a,f=>g(void 0,null,function*(){var p,u;if(!o)throw new Error("Client is not ready");if(!((p=f.bech32Config)!=null&&p.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${f.chainId}`);return yield (u=o[f.chainId])==null?void 0:u.getBalanceStaked(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};d();var cF=()=>{let e=N(n=>n.capsuleState),t=U(n=>n.capsuleClient),r=In();return {setModalState:n=>{N.setState(i=>{var s;return {capsuleState:{showModal:n,chainId:(s=i.capsuleState)==null?void 0:s.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:r.onAfterLoginSuccessful,onLoginFailure:()=>{xn();}}};d();var gF=()=>U(e=>e.activeChainIds),RO=()=>{var e;return (e=U(t=>t.activeChainIds))==null?void 0:e.map(t=>{var n;let r=(n=N.getState().chains)==null?void 0:n.find(i=>i.chainId===t);if(r)return r}).filter(Boolean)},mF=({chainId:e})=>{var t;return (t=N().chains)==null?void 0:t.find(r=>r.chainId===e)},yF=({chainId:e})=>{var t;return (t=N().chains)==null?void 0:t.filter(r=>e==null?void 0:e.includes(r.chainId))},wF=({denom:e})=>{let t=RO();return useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var s;return (s=t==null?void 0:t.find(o=>o.currencies.find(a=>a.coinMinimalDenom===i)))==null?void 0:s.currencies.find(o=>o)}})},bF=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",r=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery({queryKey:r,queryFn:a=>g(void 0,[a],function*({queryKey:[,s,o]}){if(!s)throw new Error("Query client is not defined");return yield s.staking.validators(o)}),enabled:typeof e.queryClient!="undefined"})},SF=()=>({data:N(t=>t.recentChainIds),clear:ol}),_F=()=>{var t;return {data:(t=N(r=>r.recentChainIds))==null?void 0:t.map(r=>{var i;let n=(i=N.getState().chains)==null?void 0:i.find(s=>s.chainId===r);if(n)return n}).filter(Boolean),clear:ol}},EF=({onError:e,onLoading:t,onSuccess:r}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,r],mutationFn:al,onError:(s,o)=>Promise.resolve(e==null?void 0:e(s,o.chainInfo)),onMutate:s=>t==null?void 0:t(s.chainInfo),onSuccess:s=>Promise.resolve(r==null?void 0:r(s))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},vF=({onError:e,onLoading:t,onSuccess:r}={})=>{let i=useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,r],mutationFn:zm,onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a)),onMutate:o=>t==null?void 0:t(o),onSuccess:o=>Promise.resolve(r==null?void 0:r(o))}),{data:s}=ls();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!s,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};d();var RF=({onError:e,onLoading:t,onSuccess:r}={})=>{let{data:n}=Rt(),i=n==null?void 0:n.bech32Address,s=useMutation({mutationKey:["USE_SEND_TOKENS",e,t,r,i],mutationFn:o=>qm(F({senderAddress:i},o)),onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a)),onMutate:t,onSuccess:o=>Promise.resolve(r==null?void 0:r(o))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},PF=({onError:e,onLoading:t,onSuccess:r}={})=>{let{data:n}=Rt(),i=n==null?void 0:n.bech32Address,s=useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,r,i],mutationFn:o=>Gm(F({senderAddress:i},o)),onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a)),onMutate:t,onSuccess:o=>Promise.resolve(r==null?void 0:r(o))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},NF=({codeId:e,onError:t,onLoading:r,onSuccess:n})=>{let{data:i}=Rt(),s=i==null?void 0:i.bech32Address,a=useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,r,n,e,s],mutationFn:c=>{var l;if(!s)throw new Error("senderAddress is undefined");let h=Q(F({},c),{fee:(l=c.fee)!=null?l:"auto",senderAddress:s,codeId:e});return Vm(h)},onError:(c,h)=>Promise.resolve(t==null?void 0:t(c,h)),onMutate:r,onSuccess:c=>Promise.resolve(n==null?void 0:n(c))});return {error:a.error,isLoading:a.isPending,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},LF=({contractAddress:e,onError:t,onLoading:r,onSuccess:n})=>{let{data:i}=Rt(),s=i==null?void 0:i.bech32Address,a=useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,r,n,e,s],mutationFn:c=>{var l,f,m;if(!s)throw new Error("senderAddress is undefined");let h=Q(F({},c),{fee:(l=c.fee)!=null?l:"auto",senderAddress:s,contractAddress:e,memo:(f=c.memo)!=null?f:"",funds:(m=c.funds)!=null?m:[]});return Hm(h)},onError:(c,h)=>Promise.resolve(t==null?void 0:t(c,h)),onMutate:r,onSuccess:c=>Promise.resolve(n==null?void 0:n(c))});return {error:a.error,isLoading:a.isPending,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},MF=e=>{let{data:t}=dl();return useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,n]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return Jm(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},FF=e=>{let{data:t}=dl(),r=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery({queryKey:r,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return Ym(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};d();function JF(e){let t=Le({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=N(s=>s.walletType),n=U(s=>s.activeChainIds),i=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,r,e,n],[n,e,t,r]);return useQuery({queryKey:i,queryFn:a=>g(this,[a],function*({queryKey:[,s,o]}){if(s.length<1)throw new Error("No chains found");return yield $e(!!(e!=null&&e.multiChain),s,h=>g(this,null,function*(){var y,w;if(!(n!=null&&n.includes(h.chainId)))return null;if(!De(o))throw new Error(`${o} is not available`);let f=yield (()=>g(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return ae(o).getOfflineSigner(h.chainId);case"offlineSignerAuto":return ae(o).getOfflineSignerAuto(h.chainId);case"offlineSignerOnlyAmino":return ae(o).getOfflineSignerOnlyAmino(h.chainId);default:return ae(o).getOfflineSignerAuto(h.chainId)}}))(),m=(y=N.getState().chainsConfig)==null?void 0:y[h.chainId],p={url:h.rpc,headers:F({},(m==null?void 0:m.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(p,f,e!=null&&e.multiChain?(w=e.opts)==null?void 0:w[h.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!r&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function YF(e){let t=Le({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=N(s=>s.walletType),n=U(s=>s.activeChainIds),i=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,r,e,n],[n,e,t,r]);return useQuery({queryKey:i,queryFn:a=>g(this,[a],function*({queryKey:[,s,o]}){if(s.length<1)throw new Error("No chains found");return yield $e(!!(e!=null&&e.multiChain),s,h=>g(this,null,function*(){var w,S;if(!(n!=null&&n.includes(h.chainId)))return null;if(!De(o))throw new Error(`${o} is not available`);let f=yield (()=>g(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return ae(o).getOfflineSigner(h.chainId);case"offlineSignerAuto":return ae(o).getOfflineSignerAuto(h.chainId);case"offlineSignerOnlyAmino":return ae(o).getOfflineSignerOnlyAmino(h.chainId);default:return ae(o).getOfflineSignerAuto(h.chainId)}}))(),m=(w=N.getState().chainsConfig)==null?void 0:w[h.chainId],p={url:h.rpc,headers:F({},(m==null?void 0:m.rpcHeaders)||{})},u=m!=null&&m.gas?GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(p,f,F({gasPrice:u},e!=null&&e.multiChain?(S=e.opts)==null?void 0:S[h.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!r&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function XF(e){let t=Le({chainId:e.chainId,multiChain:e.multiChain}),r=N(o=>o.walletType),n=U(o=>o.activeChainIds),i=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,r,e,n],[n,e,t,r]),{data:s}=cs({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:i,queryFn:c=>g(this,[c],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield $e(!!e.multiChain,o,l=>g(this,null,function*(){var y;if(!(n!=null&&n.includes(l.chainId)))return null;if(!De(a))throw new Error(`${a} is not available`);if(!s)throw new Error("No tendermint client found");let m=yield (()=>g(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return ae(a).getOfflineSigner(l.chainId);case"offlineSignerAuto":return ae(a).getOfflineSignerAuto(l.chainId);case"offlineSignerOnlyAmino":return ae(a).getOfflineSignerOnlyAmino(l.chainId);default:return ae(a).getOfflineSignerAuto(l.chainId)}}))(),p=e.multiChain?s[l.chainId]:s;return yield SigningStargateClient.createWithSigner(p,m,e.multiChain?(y=e.opts)==null?void 0:y[l.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!r&&!!s&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function QF(e){let t=Le({chainId:e.chainId,multiChain:e.multiChain}),r=N(a=>a.walletType),n=U(a=>a.activeChainIds),i=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,r,e,n],[n,e,t,r]),{data:s}=cs({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:o}=cs({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:i,queryFn:h=>g(this,[h],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield $e(!!e.multiChain,a,f=>g(this,null,function*(){var b,_;if(!(n!=null&&n.includes(f.chainId)))return null;if(!De(c))throw new Error(`${c} is not available`);let p=yield (()=>g(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return ae(c).getOfflineSigner(f.chainId);case"offlineSignerAuto":return ae(c).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return ae(c).getOfflineSignerOnlyAmino(f.chainId);default:return ae(c).getOfflineSignerAuto(f.chainId)}}))(),u=(b=N.getState().chainsConfig)==null?void 0:b[f.chainId],y=u!=null&&u.gas?GasPrice.fromString(`${u.gas.price}${u.gas.denom}`):void 0,w=e.multiChain?o==null?void 0:o[f.chainId]:s;if(!w)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(w,p,F({gasPrice:y},e.multiChain?(_=e.opts)==null?void 0:_[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!r&&(!!s||!as(o))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}d();d();var uy=({children:e})=>{let[t,r]=useState(!1);return useEffect(()=>{r(!0);},[]),jsx(Fragment,{children:t?e:null})};d();var BO=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(ct)==="Active",{_reconnect:t,_onReconnectFailed:r,_reconnectConnector:n,iframeOptions:i,chains:s}=N(),{activeChainIds:o,wcSignClients:a}=U(),c=De(n||void 0);return useEffect(()=>{if(!i||i.autoConnect===!1||!i.allowedIframeParentOrigins.length||!s)return;new Cosmiframe(i.allowedIframeParentOrigins).isReady().then(l=>{if(l)return Tt({chainId:s.map(f=>f.chainId),walletType:"cosmiframe"})});},[i]),useEffect(()=>{if(n){if(!c)return;e&&o?Ne({onError:r}):!e&&t&&Ne({onError:r});}},[c]),useEffect(()=>{var h,l,f,m,p,u,y,w,S,b,_,C,T,M,v,I,B,R,A,D;if(n){if(!c)return;n==="cosmostation"&&((l=(h=On()).subscription)==null||l.call(h,()=>{Ne({onError:r});})),n==="keplr"&&((m=(f=Tn()).subscription)==null||m.call(f,()=>{Ne({onError:r});})),n==="leap"&&((u=(p=Rn()).subscription)==null||u.call(p,()=>{Ne({onError:r});})),n==="compass"&&((w=(y=Dn()).subscription)==null||w.call(y,()=>{Ne({onError:r});})),n==="vectis"&&((b=(S=Mn()).subscription)==null||b.call(S,()=>{Ne({onError:r});})),n==="walletconnect"&&a.has("walletconnect")&&((C=(_=Je()).subscription)==null||C.call(_,()=>{Ne({onError:r});})),n==="station"&&((M=(T=Ln()).subscription)==null||M.call(T,()=>{Ne({onError:r});})),n==="xdefi"&&((I=(v=os()).subscription)==null||I.call(v,()=>{Ne({onError:r});})),n==="cosmiframe"&&((R=(B=An()).subscription)==null||R.call(B,()=>{Ne({onError:r});})),n==="okx"&&((D=(A=Nn()).subscription)==null||D.call(A,()=>{Ne({onError:r});}));}},[n,a,c]),null},fy=()=>(BO(),null);var AB=({children:e,grazOptions:t})=>(useEffect(()=>{$m(t);},[t]),jsxs(uy,{children:[e,jsx(fy,{})]}));/*! Bundled license information:
|
|
132
|
+
|
|
133
|
+
tslib/tslib.es6.js:
|
|
134
|
+
(*! *****************************************************************************
|
|
135
|
+
Copyright (c) Microsoft Corporation.
|
|
136
|
+
|
|
137
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
138
|
+
purpose with or without fee is hereby granted.
|
|
139
|
+
|
|
140
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
141
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
142
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
143
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
144
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
145
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
146
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
147
|
+
***************************************************************************** *)
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
export { fy as GrazEvents, AB as GrazProvider, Sl as WALLET_TYPES, bl as WalletType, De as checkWallet, ol as clearRecentChain, we as clearSession, $m as configureGraz, Tt as connect, f5 as defineChainInfo, u5 as defineChains, xn as disconnect, Hm as executeContract, UM as getAvailableWallets, ZM as getChainInfo, e5 as getChainInfos, On as getCosmostation, Tn as getKeplr, Rn as getLeap, Nl as getMetamaskSnapLeap, jm as getOfflineSigners, Ym as getQueryRaw, Jm as getQuerySmart, XM as getRecentChainIds, QM as getRecentChains, Mn as getVectis, Um as getWCCosmostation, Wm as getWCKeplr, Km as getWCLeap, ae as getWallet, Je as getWalletConnect, Vm as instantiateContract, il as isCapsule, sl as isWalletConnect, Ne as reconnect, Gm as sendIbcTokens, qm as sendTokens, al as suggestChain, zm as suggestChainAndConnect, Rt as useAccount, wF as useActiveChainCurrency, gF as useActiveChainIds, RO as useActiveChains, k5 as useActiveWalletType, X5 as useBalance, tF as useBalanceStaked, TO as useBalances, cF as useCapsule, mF as useChainInfo, yF as useChainInfos, ls as useCheckWallet, Q5 as useConnect, dl as useCosmWasmClient, YF as useCosmWasmSigningClient, QF as useCosmWasmTmSigningClient, Z5 as useDisconnect, LF as useExecuteContract, BO as useGrazEvents, NF as useInstantiateContract, eF as useOfflineSigners, bF as useQueryClientValidators, FF as useQueryRaw, MF as useQuerySmart, SF as useRecentChainIds, _F as useRecentChains, PF as useSendIbcTokens, RF as useSendTokens, hl as useStargateClient, JF as useStargateSigningClient, XF as useStargateTmSigningClient, EF as useSuggestChain, vF as useSuggestChainAndConnect, cs as useTendermintClient };
|