UNPKG

@web3auth/web3auth-wagmi-connector

Version:
1 lines 37.8 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Web3authWagmiConnector=t():e.Web3authWagmiConnector=t()}(self,(()=>(()=>{var e={358:(e,t,r)=>{"use strict";r.d(t,{T:()=>et});var n={};r.r(n),r.d(n,{bK:()=>I,lJ:()=>u,Db:()=>y,Rm:()=>d});var o,i,s=function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};class a extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return"@wagmi/core@2.13.5"}constructor(e,t={}){super(),o.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const r=t.cause instanceof a?t.cause.details:t.cause?.message?t.cause.message:t.details,n=t.cause instanceof a&&t.cause.docsPath||t.docsPath;this.message=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...n?[`Docs: ${this.docsBaseUrl}${n}.html${t.docsSlug?`#${t.docsSlug}`:""}`]:[],...r?[`Details: ${r}`]:[],`Version: ${this.version}`].join("\n"),t.cause&&(this.cause=t.cause),this.details=r,this.docsPath=n,this.metaMessages=t.metaMessages,this.shortMessage=e}walk(e){return s(this,o,"m",i).call(this,this,e)}}o=new WeakSet,i=function e(t,r){return r?.(t)?t:t.cause?s(this,o,"m",e).call(this,t.cause,r):t};class c extends a{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}const u={EIP155:"eip155",SOLANA:"solana",CASPER:"casper",XRPL:"xrpl",OTHER:"other"};var l=r(65),d=r.n(l)().getLogger("web3auth-logger");function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function h(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=f(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==f(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?p(Object(r),!0).forEach((function(t){h(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}const g={AUTH:"auth",WALLET_CONNECT_V2:"wallet-connect-v2",SFA:"sfa"},v=m({TORUS_SOLANA:"torus-solana"},g),b=m({TORUS_EVM:"torus-evm",COINBASE:"coinbase"},g),y=m(m({},b),v);v.TORUS_SOLANA,b.TORUS_EVM,b.COINBASE,r(7).EventEmitter;const w={MAINNET:"mainnet",TESTNET:"testnet",CYAN:"cyan",AQUA:"aqua",CELESTE:"celeste"};m(m({},{SAPPHIRE_DEVNET:"sapphire_devnet",SAPPHIRE_MAINNET:"sapphire_mainnet"}),w);var E,C=(E=function(e,t){return E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},E(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}E(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),O=function(e){function t(t,r){var n,o,i,s=this.constructor,a=e.call(this,t,r)||this;return Object.defineProperty(a,"name",{value:s.name,enumerable:!1,configurable:!0}),n=a,o=s.prototype,(i=Object.setPrototypeOf)?i(n,o):n.__proto__=o,function(e,t){void 0===t&&(t=e.constructor);var r=Error.captureStackTrace;r&&r(e,t)}(a),a}return C(t,e),t}(Error);function P(e){const t=e.findIndex((e=>e instanceof Error)),r=e.findIndex((e=>"string"==typeof e)),n=e.findIndex((e=>e&&"object"==typeof e&&"status"in e&&"type"in e));let o;if(-1!==n){const t=e[n];o=new Error(`${t.status} ${t.type.toString()} ${t.statusText}`)}else o=-1!==t?e.splice(t,1)[0]:-1!==r?new Error(e.splice(r,1)[0]):new Error("Unknown error");return[o,e]}class x extends O{constructor(e,t,r){super(t),h(this,"code",void 0),h(this,"message",void 0),h(this,"cause",void 0),this.code=e,this.message=t||"",this.cause=r,Object.defineProperty(this,"name",{value:"Web3AuthError"})}toJSON(){return{name:this.name,code:this.code,message:this.message,cause:P([this.cause])}}toString(){return JSON.stringify(this.toJSON())}}class A extends x{constructor(e,t,r){super(e,t,r),Object.defineProperty(this,"name",{value:"WalletInitializationError"})}static fromCode(e,t="",r){return new A(e,`${A.messages[e]}, ${t}`,r)}static notFound(e="",t){return A.fromCode(5001,e,t)}static notInstalled(e="",t){return A.fromCode(5002,e,t)}static notReady(e="",t){return A.fromCode(5003,e,t)}static windowBlocked(e="",t){return A.fromCode(5004,e,t)}static windowClosed(e="",t){return A.fromCode(5005,e,t)}static incompatibleChainNameSpace(e="",t){return A.fromCode(5006,e,t)}static duplicateAdapterError(e="",t){return A.fromCode(5007,e,t)}static invalidProviderConfigError(e="",t){return A.fromCode(5008,e,t)}static providerNotReadyError(e="",t){return A.fromCode(5009,e,t)}static rpcConnectionError(e="",t){return A.fromCode(5010,e,t)}static invalidParams(e="",t){return A.fromCode(5011,e,t)}static invalidNetwork(e="",t){return A.fromCode(5013,e,t)}}h(A,"messages",{5e3:"Custom",5001:"Wallet is not found",5002:"Wallet is not installed",5003:"Wallet is not ready yet",5004:"Wallet window is blocked",5005:"Wallet window has been closed by the user",5006:"Incompatible chain namespace provided",5007:"Adapter has already been included",5008:"Invalid provider Config",5009:"Provider is not ready yet",5010:"Failed to connect with rpc url",5011:"Invalid params passed in",5013:"Invalid network provided"});class L extends x{constructor(e,t,r){super(e,t,r),Object.defineProperty(this,"name",{value:"WalletLoginError"})}static fromCode(e,t="",r){return new L(e,`${L.messages[e]}. ${t}`,r)}static connectionError(e="",t){return L.fromCode(5111,e,t)}static disconnectionError(e="",t){return L.fromCode(5112,e,t)}static notConnectedError(e="",t){return L.fromCode(5113,e,t)}static popupClosed(e="",t){return L.fromCode(5114,e,t)}static mfaEnabled(e="",t){return L.fromCode(5115,e,t)}static chainConfigNotAdded(e="",t){return L.fromCode(5116,e,t)}static unsupportedOperation(e="",t){return L.fromCode(5117,e,t)}static coreKitKeyNotFound(e="",t){return L.fromCode(5118,e,t)}static userNotLoggedIn(e="",t){return L.fromCode(5119,e,t)}}h(L,"messages",{5e3:"Custom",5111:"Failed to connect with wallet",5112:"Failed to disconnect from wallet",5113:"Wallet is not connected",5114:"Wallet popup has been closed by the user",5115:"User has already enabled mfa, please use the @web3auth/web3auth-web sdk for login with mfa",5116:"Chain config has not been added. Please add the chain config before calling switchChain",5117:"Unsupported operation",5118:"useCoreKitKey flag is enabled but coreKitKey is not available",5119:"User not logged in."});class j extends x{constructor(e,t,r){super(e,t,r),Object.defineProperty(this,"name",{value:"WalletOperationsError"})}static fromCode(e,t="",r){return new j(e,`${j.messages[e]}, ${t}`,r)}static chainIDNotAllowed(e="",t){return j.fromCode(5201,e,t)}static operationNotAllowed(e="",t){return j.fromCode(5202,e,t)}static chainNamespaceNotAllowed(e="",t){return j.fromCode(5203,e,t)}}h(j,"messages",{5e3:"Custom",5201:"Provided chainId is not allowed",5202:"This operation is not allowed"});class S extends x{constructor(e,t,r){super(e,t,r),Object.defineProperty(this,"name",{value:"WalletProviderError"})}static fromCode(e,t="",r){return new j(e,`${S.messages[e]}, ${t}`,r)}static invalidRequestArgs(e="",t){return j.fromCode(5301,e,t)}static invalidRequestMethod(e="",t){return j.fromCode(5302,e,t)}static invalidRequestParams(e="",t){return j.fromCode(5303,e,t)}}h(S,"messages",{5e3:"Custom",5301:"Expected a single, non-array, object argument.",5302:"'args.method' must be a non-empty string.",5303:"'args.params' must be an object or array if provided."});const I={NOT_READY:"not_ready",READY:"ready",CONNECTING:"connecting",CONNECTED:"connected",DISCONNECTED:"disconnected",ERRORED:"errored"};m(m({},I),{},{ADAPTER_DATA_UPDATED:"adapter_data_updated",CACHE_CLEAR:"cache_clear"});const $="2.21.9";let R=({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,N=$;class _ extends Error{constructor(e,t={}){const r=t.cause instanceof _?t.cause.details:t.cause?.message?t.cause.message:t.details,n=t.cause instanceof _&&t.cause.docsPath||t.docsPath,o=R?.({...t,docsPath:n});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...o?[`Docs: ${o}`]:[],...r?[`Details: ${r}`]:[],...N?[`Version: ${N}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=n,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=$}walk(e){return M(this,e)}}function M(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e?M(e.cause,t):t?null:e}class T extends _{constructor({body:e,error:t,url:r}){var n,o,i;super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${r}`,`Request body: ${n=e,JSON.stringify(n,((e,t)=>{const r="bigint"==typeof t?t.toString():t;return"function"==typeof o?o(e,r):r}),i)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t.code}}class z extends _{constructor(e,{code:t,docsPath:r,metaMessages:n,name:o,shortMessage:i}){super(i,{cause:e,docsPath:r,metaMessages:n||e?.metaMessages,name:o||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=o||e.name,this.code=e instanceof T?e.code:t??-1}}class U extends z{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class k extends z{constructor(e){super(e,{code:k.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(k,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class D extends z{constructor(e){super(e,{code:D.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(D,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class F extends z{constructor(e,{method:t}={}){super(e,{code:F.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(F,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class W extends z{constructor(e){super(e,{code:W.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(W,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class B extends z{constructor(e){super(e,{code:B.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(B,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class q extends z{constructor(e){super(e,{code:q.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(q,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class J extends z{constructor(e){super(e,{code:J.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(J,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class K extends z{constructor(e){super(e,{code:K.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(K,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class H extends z{constructor(e){super(e,{code:H.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(H,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class V extends z{constructor(e,{method:t}={}){super(e,{code:V.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not implemented.`})}}Object.defineProperty(V,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class X extends z{constructor(e){super(e,{code:X.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(X,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Y extends z{constructor(e){super(e,{code:Y.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(Y,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class G extends U{constructor(e){super(e,{code:G.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(G,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Q extends U{constructor(e){super(e,{code:Q.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(Q,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Z extends U{constructor(e,{method:t}={}){super(e,{code:Z.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(Z,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class ee extends U{constructor(e){super(e,{code:ee.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(ee,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class te extends U{constructor(e){super(e,{code:te.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(te,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class re extends U{constructor(e){super(e,{code:re.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(re,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class ne extends _{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}function oe(e,{strict:t=!0}={}){return!!e&&"string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x"))}class ie extends _{constructor({size:e,targetSize:t,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function se(e,{dir:t,size:r=32}={}){return"string"==typeof e?function(e,{dir:t,size:r=32}={}){if(null===r)return e;const n=e.replace("0x","");if(n.length>2*r)throw new ie({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n["right"===t?"padEnd":"padStart"](2*r,"0")}`}(e,{dir:t,size:r}):function(e,{dir:t,size:r=32}={}){if(null===r)return e;if(e.length>r)throw new ie({size:e.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let o=0;o<r;o++){const i="right"===t;n[i?o:r-o-1]=e[i?o:e.length-o-1]}return n}(e,{dir:t,size:r})}class ae extends _{constructor({max:e,min:t,signed:r,size:n,value:o}){super(`Number "${o}" is not in safe ${n?`${8*n}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class ce extends _{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function ue(e){return oe(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function le(e,{size:t}){if(ue(e)>t)throw new ce({givenSize:ue(e),maxSize:t})}function de(e,t={}){const{signed:r,size:n}=t,o=BigInt(e);let i;n?i=r?(1n<<8n*BigInt(n)-1n)-1n:2n**(8n*BigInt(n))-1n:"number"==typeof e&&(i=BigInt(Number.MAX_SAFE_INTEGER));const s="bigint"==typeof i&&r?-i-1n:0;if(i&&o>i||o<s){const t="bigint"==typeof e?"n":"";throw new ae({max:i?`${i}${t}`:void 0,min:`${s}${t}`,signed:r,size:n,value:`${e}${t}`})}const a=`0x${(r&&o<0?(1n<<BigInt(8*n))+BigInt(o):o).toString(16)}`;return n?se(a,{size:n}):a}const fe=new TextEncoder;const he={zero:48,nine:57,A:65,F:70,a:97,f:102};function pe(e){return e>=he.zero&&e<=he.nine?e-he.zero:e>=he.A&&e<=he.F?e-(he.A-10):e>=he.a&&e<=he.f?e-(he.a-10):void 0}function me(e,t={}){let r=e;t.size&&(le(r,{size:t.size}),r=se(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const o=n.length/2,i=new Uint8Array(o);for(let e=0,t=0;e<o;e++){const r=pe(n.charCodeAt(t++)),o=pe(n.charCodeAt(t++));if(void 0===r||void 0===o)throw new _(`Invalid byte sequence ("${n[t-2]}${n[t-1]}" in "${n}").`);i[e]=16*r+o}return i}function ge(e,t={}){const r=fe.encode(e);return"number"==typeof t.size?(le(r,{size:t.size}),se(r,{dir:"right",size:t.size})):r}function ve(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function be(e,...t){if(!((r=e)instanceof Uint8Array||null!=r&&"object"==typeof r&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function ye(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}const we=BigInt(2**32-1),Ee=BigInt(32);function Ce(e,t=!1){return t?{h:Number(e&we),l:Number(e>>Ee&we)}:{h:0|Number(e>>Ee&we),l:0|Number(e&we)}}function Oe(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=Ce(e[o],t);[r[o],n[o]]=[i,s]}return[r,n]}const Pe=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function xe(e){for(let r=0;r<e.length;r++)e[r]=(t=e[r])<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;var t}function Ae(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),be(e),e}class Le{clone(){return this._cloneInto()}}const je=[],Se=[],Ie=[],$e=BigInt(0),Re=BigInt(1),Ne=BigInt(2),_e=BigInt(7),Me=BigInt(256),Te=BigInt(113);for(let e=0,t=Re,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],je.push(2*(5*n+r)),Se.push((e+1)*(e+2)/2%64);let o=$e;for(let e=0;e<7;e++)t=(t<<Re^(t>>_e)*Te)%Me,t&Ne&&(o^=Re<<(Re<<BigInt(e))-Re);Ie.push(o)}const[ze,Ue]=Oe(Ie,!0),ke=(e,t,r)=>r>32?((e,t,r)=>t<<r-32|e>>>64-r)(e,t,r):((e,t,r)=>e<<r|t>>>32-r)(e,t,r),De=(e,t,r)=>r>32?((e,t,r)=>e<<r-32|t>>>64-r)(e,t,r):((e,t,r)=>t<<r|e>>>32-r)(e,t,r);class Fe extends Le{constructor(e,t,r,n=!1,o=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,ve(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var i;this.state=new Uint8Array(200),this.state32=(i=this.state,new Uint32Array(i.buffer,i.byteOffset,Math.floor(i.byteLength/4)))}keccak(){Pe||xe(this.state32),function(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const n=(t+8)%10,o=(t+2)%10,i=r[o],s=r[o+1],a=ke(i,s,1)^r[n],c=De(i,s,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],o=e[3];for(let r=0;r<24;r++){const n=Se[r],i=ke(t,o,n),s=De(t,o,n),a=je[r];t=e[a],o=e[a+1],e[a]=i,e[a+1]=s}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=ze[n],e[1]^=Ue[n]}r.fill(0)}(this.state32,this.rounds),Pe||xe(this.state32),this.posOut=0,this.pos=0}update(e){ye(this);const{blockLen:t,state:r}=this,n=(e=Ae(e)).length;for(let o=0;o<n;){const i=Math.min(t-this.pos,n-o);for(let t=0;t<i;t++)r[this.pos++]^=e[o++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:n}=this;e[r]^=t,0!=(128&t)&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){ye(this,!1),be(e),this.finish();const t=this.state,{blockLen:r}=this;for(let n=0,o=e.length;n<o;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,o-n);e.set(t.subarray(this.posOut,this.posOut+i),n),this.posOut+=i,n+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ve(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(function(e,t){be(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:o,enableXOF:i}=this;return e||(e=new Fe(t,r,n,i,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=r,e.outputLen=n,e.enableXOF=i,e.destroyed=this.destroyed,e}}const We=((e,t,r)=>function(e){const t=t=>e().update(Ae(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}((()=>new Fe(t,e,r))))(1,136,32);class Be extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const qe=/^0x[a-fA-F0-9]{40}$/,Je=new Be(8192),Ke=new Be(8192);function He(e,t){if(Ke.has(`${e}.${t}`))return Ke.get(`${e}.${t}`);const r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),n=function(e,t){const r=We(oe(e,{strict:!1})?function(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){return me(de(e,t))}(e,t):"boolean"==typeof e?function(e,t={}){const r=new Uint8Array(1);return r[0]=Number(e),"number"==typeof t.size?(le(r,{size:t.size}),se(r,{size:t.size})):r}(e,t):oe(e)?me(e,t):ge(e,t)}(e):e);return r}(ge(r)),o=(t?r.substring(`${t}0x`.length):r).split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&o[e]&&(o[e]=o[e].toUpperCase()),(15&n[e>>1])>=8&&o[e+1]&&(o[e+1]=o[e+1].toUpperCase());const i=`0x${o.join("")}`;return Ke.set(`${e}.${t}`,i),i}function Ve(e,t){if(!function(e,t){const{strict:r=!0}={strict:!1}??{},n=`${e}.${r}`;if(Je.has(n))return Je.get(n);const o=!(!qe.test(e)||e.toLowerCase()!==e&&r&&He(e)!==e);return Je.set(n,o),o}(e))throw new ne({address:e});return He(e,t)}const{bK:Xe,lJ:Ye,Db:Ge,Rm:Qe}=n;function Ze(e){return void 0!==e.initModal}function et(e){let t=null;const{web3AuthInstance:r,loginParams:n,modalConfig:o,id:i,name:s,type:a}=e;return e=>({id:i||"web3auth",name:s||"Web3Auth",type:a||"Web3Auth",async connect({chainId:t}={}){try{e.emitter.emit("message",{type:"connecting"});const i=await this.getProvider();if(i.on("accountsChanged",this.onAccountsChanged),i.on("chainChanged",this.onChainChanged),i.on("disconnect",this.onDisconnect.bind(this)),!r.connected)if(Ze(r))await r.connect();else{if(!n)throw Qe.error("please provide valid loginParams when using @web3auth/no-modal"),new G("please provide valid loginParams when using @web3auth/no-modal");await r.connectTo(Ge.AUTH,n)}let s=await this.getChainId();if(t&&s!==t){var o;const e=await this.switchChain({chainId:t}).catch((e=>{if(e.code===G.code)throw e;return{id:s}}));s=null!==(o=null==e?void 0:e.id)&&void 0!==o?o:s}return{accounts:await this.getAccounts(),chainId:s}}catch(e){throw Qe.error("error while connecting",e),this.onDisconnect(),new G("Something went wrong")}},async getAccounts(){const e=await this.getProvider();return(await e.request({method:"eth_accounts"})).map((e=>Ve(e)))},async getChainId(){const e=await this.getProvider(),t=await e.request({method:"eth_chainId"});return Number(t)},async getProvider(){if(t)return t;if(r.status===Xe.NOT_READY)if(Ze(r))await r.initModal({modalConfig:o});else{if(!n)throw Qe.error("please provide valid loginParams when using @web3auth/no-modal"),new G("please provide valid loginParams when using @web3auth/no-modal");await r.init()}return t=r.provider,t},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({chainId:t}){try{var n,o,i,s,a,u;const l=e.chains.find((e=>e.id===t));if(!l)throw new re(new c);return await r.addChain({chainNamespace:Ye.EIP155,chainId:`0x${l.id.toString(16)}`,rpcTarget:l.rpcUrls.default.http[0],displayName:l.name,blockExplorerUrl:(null===(n=l.blockExplorers)||void 0===n?void 0:n.default.url)||"",ticker:(null===(o=l.nativeCurrency)||void 0===o?void 0:o.symbol)||"ETH",tickerName:(null===(i=l.nativeCurrency)||void 0===i?void 0:i.name)||"Ethereum",decimals:(null===(s=l.nativeCurrency)||void 0===s?void 0:s.decimals)||18,logo:null!==(a=l.nativeCurrency)&&void 0!==a&&a.symbol?`https://images.toruswallet.io/${null===(u=l.nativeCurrency)||void 0===u?void 0:u.symbol.toLowerCase()}.svg`:"https://images.toruswallet.io/eth.svg"}),Qe.info("Chain Added: ",l.name),await r.switchChain({chainId:`0x${l.id.toString(16)}`}),Qe.info("Chain Switched to ",l.name),e.emitter.emit("change",{chainId:t}),l}catch(e){throw Qe.error("Error: Cannot change chain",e),new re(e)}},async disconnect(){await r.logout();const e=await this.getProvider();e.removeListener("accountsChanged",this.onAccountsChanged),e.removeListener("chainChanged",this.onChainChanged)},onAccountsChanged(t){0===t.length?e.emitter.emit("disconnect"):e.emitter.emit("change",{accounts:t.map((e=>Ve(e)))})},onChainChanged(t){const r=Number(t);e.emitter.emit("change",{chainId:r})},onDisconnect(){e.emitter.emit("disconnect")}})}},282:()=>{},7:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(r,n){function o(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}m(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&m(e,"error",t,{once:!0})}(e,o)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var o,i,s,u;if(a(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]),void 0===s)s=i[t]=r,++e._eventsCount;else if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=c(e))>0&&s.length>o&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=l.bind(n);return o.listener=r,n.wrapFn=o,o}function f(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(o):p(o,o.length)}function h(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function m(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){n.once&&e.removeEventListener(t,o),r(i)}))}}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),i.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},i.prototype.getMaxListeners=function(){return c(this)},i.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var o="error"===e,i=this._events;if(void 0!==i)o=o&&void 0===i.error;else if(!o)return!1;if(o){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)n(l[r],this,t)}return!0},i.prototype.addListener=function(e,t){return u(this,e,t,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(e,t){return u(this,e,t,!0)},i.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},i.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},i.prototype.removeListener=function(e,t){var r,n,o,i,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===t||r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,o),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return f(this,e,!0)},i.prototype.rawListeners=function(e){return f(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},i.prototype.listenerCount=h,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},65:function(e,t,r){var n,o;!function(i,s){"use strict";n=function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"],o={},i=null;function s(e,t){var r=e[t];if("function"==typeof r.bind)return r.bind(e);try{return Function.prototype.bind.call(r,e)}catch(t){return function(){return Function.prototype.apply.apply(r,[e,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(){for(var r=this.getLevel(),o=0;o<n.length;o++){var i=n[o];this[i]=o<r?e:this.methodFactory(i,r,this.name)}if(this.log=this.debug,typeof console===t&&r<this.levels.SILENT)return"No console available for logging"}function u(e){return function(){typeof console!==t&&(c.call(this),this[e].apply(this,arguments))}}function l(n,o,i){return function(n){return"debug"===n&&(n="log"),typeof console!==t&&("trace"===n&&r?a:void 0!==console[n]?s(console,n):void 0!==console.log?s(console,"log"):e)}(n)||u.apply(this,arguments)}function d(e,r){var s,a,u,d=this,f="loglevel";function h(){var e;if(typeof window!==t&&f){try{e=window.localStorage[f]}catch(e){}if(typeof e===t)try{var r=window.document.cookie,n=encodeURIComponent(f),o=r.indexOf(n+"=");-1!==o&&(e=/^([^;]+)/.exec(r.slice(o+n.length+1))[1])}catch(e){}return void 0===d.levels[e]&&(e=void 0),e}}function p(e){var t=e;if("string"==typeof t&&void 0!==d.levels[t.toUpperCase()]&&(t=d.levels[t.toUpperCase()]),"number"==typeof t&&t>=0&&t<=d.levels.SILENT)return t;throw new TypeError("log.setLevel() called with invalid level: "+e)}"string"==typeof e?f+=":"+e:"symbol"==typeof e&&(f=void 0),d.name=e,d.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},d.methodFactory=r||l,d.getLevel=function(){return null!=u?u:null!=a?a:s},d.setLevel=function(e,r){return u=p(e),!1!==r&&function(e){var r=(n[e]||"silent").toUpperCase();if(typeof window!==t&&f){try{return void(window.localStorage[f]=r)}catch(e){}try{window.document.cookie=encodeURIComponent(f)+"="+r+";"}catch(e){}}}(u),c.call(d)},d.setDefaultLevel=function(e){a=p(e),h()||d.setLevel(e,!1)},d.resetLevel=function(){u=null,function(){if(typeof window!==t&&f){try{window.localStorage.removeItem(f)}catch(e){}try{window.document.cookie=encodeURIComponent(f)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}(),c.call(d)},d.enableAll=function(e){d.setLevel(d.levels.TRACE,e)},d.disableAll=function(e){d.setLevel(d.levels.SILENT,e)},d.rebuild=function(){if(i!==d&&(s=p(i.getLevel())),c.call(d),i===d)for(var e in o)o[e].rebuild()},s=p(i?i.getLevel():"WARN");var m=h();null!=m&&(u=p(m)),c.call(d)}(i=new d).getLogger=function(e){if("symbol"!=typeof e&&"string"!=typeof e||""===e)throw new TypeError("You must supply a name when creating a logger.");var t=o[e];return t||(t=o[e]=new d(e,i.methodFactory)),t};var f=typeof window!==t?window.log:void 0;return i.noConflict=function(){return typeof window!==t&&window.log===i&&(window.log=f),i},i.getLoggers=function(){return o},i.default=i,i},void 0===(o=n.call(t,r,t,e))||(e.exports=o)}()}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{Web3AuthConnector:()=>e.T});var e=r(358),t=r(282),o={};for(const e in t)["default","Web3AuthConnector"].indexOf(e)<0&&(o[e]=()=>t[e]);r.d(n,o)})(),n})()));