1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5465],{82857:function(e,t,i){i.d(t,{d:function(){return n}});var s=i(53248);class n extends s.J5{async init(e){this.chainConfig||(this.chainConfig=(0,s.h2)(s.EN.EIP155,1))}async authenticateUser(){if(!this.provider||this.status!==s.MP.CONNECTED)throw s.RM.notConnectedError();let{chainNamespace:e,chainId:t}=this.chainConfig,i=await this.provider.request({method:"eth_accounts"});if(i&&i.length>0){let n=(0,s.Cb)(i[0],this.name);if(n&&!(0,s.$E)(n))return{idToken:n};let r={domain:window.location.origin,uri:window.location.href,address:i[0],chainId:parseInt(t,16),version:"1",nonce:Math.random().toString(36).slice(2),issuedAt:new Date().toISOString()},a=await (0,s.tV)(r,e),o=await this.provider.request({method:"personal_sign",params:[a,i[0]]}),l=await (0,s.rn)(e,o,a,this.name,this.sessionTime,this.clientId,this.web3AuthNetwork);return(0,s.Fr)(i[0],this.name,l),{idToken:l}}throw s.RM.notConnectedError("Not connected with wallet, Please login/connect first")}async disconnectSession(){super.checkDisconnectionRequirements();let e=await this.provider.request({method:"eth_accounts"});e&&e.length>0&&(0,s.qz)(e[0],this.name)}async disconnect(){this.rehydrated=!1,this.emit(s.n2.DISCONNECTED)}}},75465:function(e,t,i){i.d(t,{TorusWalletAdapter:function(){return er}});var s=i(31686),n=i(56127),r=i(75114),a=i(91785),o=i(97928),l=i.n(o),d=i(5845),h=i(76508),u=i.n(h),c=i(33697),p=i.n(c),m=i(86005),y=i.n(m),g=i(82957).Buffer;let v={GOOGLE:"google",FACEBOOK:"facebook",TWITCH:"twitch",REDDIT:"reddit",DISCORD:"discord",EMAIL_PASSWORDLESS:"torus-auth0-email-passwordless"},C={[v.GOOGLE]:"tkey-google",[v.FACEBOOK]:"tkey-facebook",[v.TWITCH]:"tkey-twitch",[v.REDDIT]:"tkey-reddit",[v.DISCORD]:"tkey-discord",[v.EMAIL_PASSWORDLESS]:"tkey-auth0-email-passwordless"},w={MOONPAY:"moonpay",RAMPNETWORK:"rampnetwork",MERCURYO:"mercuryo",TRANSAK:"transak",BANXA:"banxa"},f="mainnet",A="matic",S="bsc_mainnet",_="avalanche_mainnet",T="arbitrum_mainnet",D="optimism_mainnet",b={BOTTOM_LEFT:"bottom-left",TOP_LEFT:"top-left",BOTTOM_RIGHT:"bottom-right",TOP_RIGHT:"top-right"},I={[w.MOONPAY]:["AUD","BGN","BRL","CAD","CHF","CNY","COP","CZK","DKK","DOP","EGP","EUR","GBP","HKD","HRK","IDR","ILS","JPY","JOD","KES","KRW","KWD","LKR","MAD","MXN","MYR","NGN","NOK","NZD","OMR","PEN","PKR","PLN","RON","RUB","SEK","SGD","THB","TRY","TWD","USD","VND","ZAR"],[w.RAMPNETWORK]:["USD","EUR","GBP","BMD","BAM","BWP","BRL","BGN","COP","CRC","CZK","DKK","DOP","GEL","GTQ","HNL","HUF","ISK","INR","ILS","KZT","KES","KWD","LAK","MKD","MYR","MXN","MDL","MZN","NZD","NGN","PYG","PEN","PLN","RON","RSD","SGD","ZAR","LKR","SEK","CHF","TJS","THB","UYU"],[w.MERCURYO]:["EUR","USD","GBP","TRY","JPY","BRL","NGN","VND","MXN","KRW","PLN","SEK","CHF","CAD","CZK","DKK","BGN","HKD","AUD","INR"],[w.TRANSAK]:["ARS","AUD","BBD","BGN","BMD","BRL","CAD","CHF","CLP","CRC","CZK","DKK","DOP","EUR","FJD","FKP","GBP","GIP","HRK","HUF","IDR","ILS","ISK","JMD","JPY","KES","KRW","MDL","MXN","MYR","NOK","NZD","PEN","PHP","PLN","PYG","RON","SEK","SGD","THB","TRY","TZS","USD","ZAR"],[w.BANXA]:["AUD","CAD","CZK","DKK","EUR","GBP","HKD","JPY","NOK","NZD","NZD","PLN","RUB","SEK","SGD","TRY","USD"]},R=new Set(["ETH","USDT","USDC","TUSD","EOSDT","USD","DAI","GUSD","DKKT","PAX","ILS","RUB","BYN","EUR","GBP","JPY","KRW","PLN","MXN","AUD","BRL","CAD","CHF","KPW","LAK","LBP","LKR","XOF","CNHT","DOGE","UAH","TRY","HKD","XJP","SGD","USC","NZD","NGN","RUR","COP","GHS","EGP","IDR","BHD","CRC","PEN","AED","DOP","PKR","HUF","VND","XAR","LTC","RON","OMR","MYR","DKK","UGX","ZMW","SAR","SEK","GEL","RWF","IRR","TZS","CNY","VEF","BDT","HRK","CLP","THB","XAF","ARS","UYU","SZL","KZT","NOK","KES","PAB","INR","CZK","MAD","TWD","PHP","ZAR","BOB","CDF","DASH","VES","ISK","MWK","BAM","TTD","XRP","JOD","RSD","HNL","BGN","GTQ","BWP","XMR","MMK","QAR","AOA","KWD","MUR","WUSD","WEUR","WAVES","WTRY","LRD","LSL","LYD","AWG","MDL","BTO","EURS","CHFT","MKD","MNT","MOP","MRO","MVR","VOLLAR","CKUSD","KHR","VUV","BITCNY","QC","BBD","NAD","NPR","PGK","PYG","BIF","BMD","BND","XLM","BNB","SCR","BAT","CRO","HT","KCS","LEO","LINK","MKR","NPXS","OMG","REP","ZB","ZIL","ZRX","BCH","BZD","CUP","CVE","DJF","DZD","ERN","ETB","FJD","FKP","BUSD","ANCT","ALL","AMD","ANG","CNYX","IQD","UZS","TND","GGP","XAU","KGS","GIP","JMD","ZEC","USDP","BSV","EMC2","SNT","GTO","POWR","EUSD","EURT","BCY","BTS","ATM","BLOCKPAY","ARDR","AMP","B2X","BITGOLD","BITEUR","ATB","BITUSD","AGRS","DFXT","HIKEN","BIX","KNC","EOS","COB","COSS","BMH","NANO","BDG","BNT","XVG","LKK1Y","LKK","USDK","EURN","NZDT","JSE","GMD","GNF","GYD","YER","XPF","HTG","SLL","SOS","WST","SVC","SYP","NEO","KMF","JUMP","AYA","BLAST","WGR","BCN","BTG","URALS","INN","USDQ","CNH","HUSD","BKRW","NZ
1DX","EURX","CADX","USDEX","JPYX","AUDX","VNDC","EON","GBPX","CHFX","USDJ","IDRT","USDS","USDN","BIDR","IDK","BSD","BTN","KYD","NIO","SBD","SDG","SHP","TOP","XCD","XCHF","CNYT","GYEN","ZUSD","GOLD","TRX","TRYB","PLATC","STRAX","UST","GLM","VAI","BRZ","DDRST","XAUT","MIM"]);function P(e){return I[e].filter(e=>R.has(e))}let E={[w.MOONPAY]:{line1:"Credit/ Debit Card/ Apple Pay",line2:"4.5% or 5 USD",line3:"2,000â¬/day, 10,000â¬/mo",supportPage:"https://help.moonpay.io/en/",minOrderValue:24.99,maxOrderValue:5e4,validCurrencies:P(w.MOONPAY),validCryptoCurrenciesByChain:{[f]:[{value:"aave",display:"AAVE"},{value:"bat",display:"BAT"},{value:"dai",display:"DAI"},{value:"eth",display:"ETH"},{value:"mkr",display:"MKR"},{value:"matic",display:"MATIC"},{value:"usdt",display:"USDT"},{value:"uni",display:"UNI"},{value:"usdc",display:"USDC"},{value:"weth",display:"WETH"}],[A]:[{value:"eth_polygon",display:"ETH"},{value:"matic_polygon",display:"MATIC"},{value:"usdc_polygon",display:"USDC"},{value:"usdt_polygon",display:"USDT"}],[S]:[{value:"bnb_bsc",display:"BNB"},{value:"busd_bsc",display:"BUSD"}],[_]:[{value:"avax_cchain",display:"AVAX"},{value:"usdc_cchain",display:"USDC"}],[T]:[{value:"eth_arbitrum",display:"ETH"},{value:"usdc_arbitrum",display:"USDC"}],[D]:[{value:"eth_optimism",display:"ETH"},{value:"usdc_optimism",display:"USDC"}]},includeFees:!0,api:!0,enforceMax:!1},[w.RAMPNETWORK]:{line1:"Debit Card/ <br>Apple Pay/ Bank transfer",line2:"0.49% - 2.9%",line3:"5,000â¬/purchase, 20,000â¬/mo",supportPage:"https://instant.ramp.network/",minOrderValue:50,maxOrderValue:2e4,validCurrencies:P(w.RAMPNETWORK),validCryptoCurrenciesByChain:{[f]:[{value:"ETH",display:"ETH"},{value:"DAI",display:"DAI"},{value:"BAT",display:"BAT"},{value:"USDC",display:"USDC"},{value:"USDT",display:"USDT"}],[A]:[{value:"MATIC_BAT",display:"BAT"},{value:"MATIC_DAI",display:"DAI"},{value:"MATIC_MATIC",display:"MATIC"},{value:"MATIC_USDC",display:"USDC"},{value:"MATIC_USDT",display:"USDT"}],[_]:[{value:"AVAX_AVAX",display:"AVAX"},{value:"AVAX_USDC",display:"USDC"},{value:"AVAX_USDT",display:"USDT"}],[T]:[{value:"ARBITRUM_ETH",display:"ETH"},{value:"ARBITRUM_USDC.e ",display:"USDC"},{value:"ARBITRUM_USDT",display:"USDT"}],[D]:[{value:"OPTIMISM_DAI",display:"DAI"},{value:"OPTIMISM_OPTIMISM",display:"OPTIMISM"},{value:"OPTIMISM_USDC",display:"USDC"},{value:"OPTIMISM_USDT",display:"USDT"}],[S]:[{value:"BSC_BNB",display:"BNB"},{value:"BSC_BUSD",display:"BUSD"}]},includeFees:!0,api:!0,receiveHint:"walletTopUp.receiveHintRamp",enforceMax:!1},[w.MERCURYO]:{line1:"Credit/ Debit Card/ Apple Pay",line2:"3.95% or 4 USD",line3:"10,000â¬/day, 25,000â¬/mo",supportPage:"mailto:[email protected]",minOrderValue:30,maxOrderValue:5e3,validCurrencies:P(w.MERCURYO),validCryptoCurrenciesByChain:{[f]:[{value:"ETH",display:"ETH"},{value:"BAT",display:"BAT"},{value:"USDT",display:"USDT"},{value:"DAI",display:"DAI"}],[S]:[{value:"BNB",display:"BNB"},{value:"BUSD",display:"BUSD"},{value:"1INCH",display:"1INCH"}],[_]:[{value:"AVAX",display:"AVAX"}],[A]:[{value:"MATIC",display:"MATIC"}]},includeFees:!0,api:!0,enforceMax:!1},[w.TRANSAK]:{line1:"Apple & Google Pay / Credit/Debit Card<br/>Bangkok Bank Mobile & iPay<br/>Bank Transfer (sepa/gbp) / SCB Mobile & Easy",line2:"0.99% - 5.5% or 5 USD",line3:"$5,000/day, $28,000/mo",supportPage:"https://support.transak.com/hc/en-US",minOrderValue:30,maxOrderValue:500,validCurrencies:P(w.TRANSAK),validCryptoCurrenciesByChain:{[f]:[{value:"1INCH",display:"1INCH"},{value:"BAT",display:"BAT"},{value:"AAVE",display:"AAVE"},{value:"DAI",display:"DAI"},{value:"ETH",display:"ETH"},{value:"USDC",display:"USDC"},{value:"USDT",display:"USDT"}],[A]:[{value:"BAT",display:"BAT"},{value:"AAVE",display:"AAVE"},{value:"DAI",display:"DAI"},{value:"MATIC",display:"MATIC"},{value:"USDC",display:"USDC"},{value:"USDT",display:"USDT"},{value:"WETH",display:"WETH"}],[S]:[{value:"BAT",display:"BAT"},{value:"BNB",display:"BNB"},{value:"BUSD",display:"BUSD"}],[_]:[{value:"AVAX",display:"AVAX"}],[D]:[{value:"ETH",display:"ETH"},{value:"USDC",display:"USDC"}],[T]:[{value:"USDC",display:"USDC"},{value:"ETH",display:"ETH"}]},includeFees:!0,enforceMax:!0},[w.BANXA]:{line1:"Debit Card/ <br>Apple Pay/ Bank transfer",line2:"0.49% - 2.9%",line3:"5,000â¬/purchase, 20,000â¬/mo",supp
1ortPage:"https://support.banxa.com",minOrderValue:20,maxOrderValue:15e3,validCurrencies:P(w.BANXA),validCryptoCurrenciesByChain:{[f]:[{value:"ETH",display:"ETH"},{value:"DAI",display:"DAI"},{value:"MKR",display:"MKR"},{value:"USDT",display:"USDT"},{value:"BUSD",display:"BUSD"},{value:"USDC",display:"USDC"},{value:"BAT",display:"BAT"},{value:"AAVE",display:"AAVE"},{value:"COMP",display:"COMP"},{value:"UNI",display:"UNI"}],[A]:[{value:"MATIC",display:"MATIC"}]},includeFees:!0,enforceMax:!0}};var M={supportedVerifierList:Object.values(v),paymentProviders:E,api:"https://api.tor.us",translations:{en:{embed:{continue:"Continue",actionRequired:"Authorization required",pendingAction:"Click continue to proceed with your request in a popup",cookiesRequired:"Cookies Required",enableCookies:"Please enable cookies in your browser preferences to access Torus",clickHere:"More Info"}},de:{embed:{continue:"Fortsetzen",actionRequired:"Autorisierung erforderlich",pendingAction:"Klicken Sie in einem Popup auf Weiter, um mit Ihrer Anfrage fortzufahren",cookiesRequired:"Cookies ben\xf6tigt",enableCookies:"Bitte aktivieren Sie Cookies in Ihren Browsereinstellungen, um auf Torus zuzugreifen",clickHere:"Mehr Info"}},ja:{embed:{continue:"ç¶ç¶ãã",actionRequired:"èªè¨¼ãå¿
è¦ã§ã",pendingAction:"ç¶è¡ãã¯ãªãã¯ãã¦ããããã¢ããã§ãªã¯ã¨ã¹ããç¶è¡ãã¾ã",cookiesRequired:"å¿
è¦ãªã¯ããã¼",enableCookies:"Torusã«ã¢ã¯ã»ã¹ããã«ã¯ããã©ã¦ã¶ã®è¨å®ã§Cookieãæå¹ã«ãã¦ãã ããã",clickHere:"詳ããã¯"}},ko:{embed:{continue:"ê³ìíë¤",actionRequired:"ì¹ì¸ íì",pendingAction:"íì
ìì ìì²ì ì§ííë ¤ë©´ ê³ìì í´ë¦íììì¤.",cookiesRequired:"ì¿ í¤ íì",enableCookies:"ë¸ë¼ì°ì íê²½ ì¤ì ìì ì¿ í¤ë¥¼ íì±ííì¬ Torusì ì¡ì¸ì¤íììì¤.",clickHere:"ë ë§ì ì ë³´"}},zh:{embed:{continue:"ç»§ç»",actionRequired:"éè¦ææ",pendingAction:"åå»ç»§ç»ä»¥å¨å¼¹åºçªå£ä¸ç»§ç»æ¨ç请æ±",cookiesRequired:"å¿
å¡«Cookie",enableCookies:"è¯·å¨æ¨çæµè§å¨é¦é项ä¸å¯ç¨cookie以访é®Torusã",clickHere:"æ´å¤ä¿¡æ¯"}}},prodTorusUrl:"",localStorageKeyPrefix:"torus-"};let U=e=>{let t=window.document.createElement("template"),i=e.trim();return t.innerHTML=i,t.content.firstChild},N=(e,t,i)=>{let s=n=>{i(n),e.removeListener(t,s)};e.on(t,s)};function O(e){return null!==e&&"object"==typeof e&&"function"==typeof e.pipe}var k=y().getLogger("torus-embed"),B={errors:{disconnected:()=>"Torus: Lost connection to Torus.",permanentlyDisconnected:()=>"Torus: Disconnected from iframe. Page reload required.",sendSiteMetadata:()=>"Torus: Failed to send site metadata. This is an internal error, please report this bug.",unsupportedSync:e=>`Torus: The Torus Ethereum provider does not support synchronous methods like ${e} without a callback parameter.`,invalidDuplexStream:()=>"Must provide a Node.js-style duplex stream.",invalidOptions:(e,t)=>`Invalid options. Received: { maxEventListeners: ${e}, shouldSendMetadata: ${t} }`,invalidRequestArgs:()=>"Expected a single, non-array, object argument.",invalidRequestMethod:()=>"'args.method' must be a non-empty string.",invalidRequestParams:()=>"'args.params' must be an object or array if provided.",invalidLoggerObject:()=>"'args.logger' must be an object if provided.",invalidLoggerMethod:e=>`'args.logger' must include required method '${e}'.`},info:{connected:e=>`Torus: Connected to chain with ID "${e}".`}};let{paymentProviders:L}=M,K=(e,t)=>{let i={};if(!e)return{errors:i,isValid:!0};if(e&&!L[e])return i.provider="Invalid Provider",{errors:i,isValid:0===Object.keys(i).length};let s=L[e],n=t||{};if(n.fiatValue){let e=+parseFloat(n.fiatValue.toString())||0;e<s.minOrderValue&&(i.fiatValue="Requested amount is lower than supported"),e>s.maxOrderValue&&s.enforceMax&&(i.fiatValue="Requested amount is higher than supported")}if(n.selectedCurrency&&!s.validCurrencies.includes(n.selectedCurrency)&&(i.selectedCurrency="Unsupported currency"),n.selectedCryptoCurrency){let t=Object.values(s.validCryptoCurrenciesByChain).flat().map(e=>e.value),r=e===w.MOONPAY?n.selectedCryptoCurrency.toLowerCase():n.selectedCryptoCurrency;t&&!t.includes(r)&&(i.selectedCryptoCurrency="Unsupported cryptoCurrency")}return{errors:i,isValid:0===Object.keys(i).length}},Z=()=>Math.random().toString(36).slice(2),H=async(e,t)=>{let i,s;let n="4.1.3",a=t.version||n;try{if(("binance"===e||"production"===e)&&!t.version){let e;a=(e=M.prodTorusUrl?{data:M.prodTorusUrl}:await (0,r.U2)(`${M.api}/latestversion?name=@toruslabs/torus-embed&version=${n}`,{},{useAPIKey:!0})).data,M.prodTorusUrl=e.data}}catch(e){k.error(e,"unable to fetch latest version")}switch(k.info("version used: ",a),e){case"binance":i=`https://binance.tor.us/v${a}`,s="info";break;case"testing":i="https://testing.tor.us",s="debug";break;case"bnb":i="https://bnb.tor.us",s="error";break;case"polygon":i="https://polygon.tor.us",s="error";break;case"lrc":i="https://lrc.tor.us",s="debug";break;case"beta":i="https://beta.tor.us",s="debug";break;case"development":i="http://localhost:4050",s="debug";break;case"alpha":i="https://alpha.tor.us",s="debug";break;default:i=`https://app.tor.us/v${a}`,s="error"}return{torusUrl:i,logLevel:s}},V=()=>{let e=(window.navigator.language||"en-US").split("-");return Object.prototype.hasOwnProperty.call(M.translations,e[0])?e[0]:"en"},W=["eth_subscription"],q=()=>{},x="directories=0,titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=660,width=375",G="directories=0,titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=700,width=450";a.Ue.defaultMaxListeners=100;let Y=function(e,t){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return(s,n)=>s||n.error?t(s||n.error):!i||Array.isArray(n)?e(n):e(n.result)};class X extends a.Ue{constructor(e){var t;
1let{maxEventListeners:i=100,shouldSendMetadata:r=!0,jsonRpcStreamName:o="provider"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(super(),(0,n.Z)(this,"chainId",void 0),(0,n.Z)(this,"selectedAddress",void 0),(0,n.Z)(this,"_rpcEngine",void 0),(0,n.Z)(this,"networkVersion",void 0),(0,n.Z)(this,"shouldSendMetadata",void 0),(0,n.Z)(this,"isTorus",void 0),(0,n.Z)(this,"tryPreopenHandle",void 0),(0,n.Z)(this,"enable",void 0),(0,n.Z)(this,"_state",void 0),(0,n.Z)(this,"_jsonRpcConnection",void 0),!(O(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState&&O(t=e)&&!1!==t.readable&&"function"==typeof t._read&&"object"==typeof t._readableState))throw Error(B.errors.invalidDuplexStream());this.isTorus=!0,this.setMaxListeners(i),this._state=(0,s.Z)({},X._defaultState),this.selectedAddress=null,this.networkVersion=null,this.chainId=null,this.shouldSendMetadata=r,this._handleAccountsChanged=this._handleAccountsChanged.bind(this),this._handleChainChanged=this._handleChainChanged.bind(this),this._handleUnlockStateChanged=this._handleUnlockStateChanged.bind(this),this._handleConnect=this._handleConnect.bind(this),this._handleDisconnect=this._handleDisconnect.bind(this),this._handleStreamDisconnect=this._handleStreamDisconnect.bind(this),this._sendSync=this._sendSync.bind(this),this._rpcRequest=this._rpcRequest.bind(this),this._initializeState=this._initializeState.bind(this),this.request=this.request.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this);let l=new a.O4;p()(e,l,e,this._handleStreamDisconnect.bind(this,"MetaMask")),l.ignoreStream("phishing"),this.on("connect",()=>{this._state.isConnected=!0});let h=(0,a.AP)();p()(h.stream,l.createStream(o),h.stream,this._handleStreamDisconnect.bind(this,"MetaMask RpcProvider"));let u=new a.eI;u.push((0,a.Rq)()),u.push((e,t,i)=>{"string"==typeof e.method&&e.method||(t.error=d.PY.invalidRequest({message:"The request 'method' must be a non-empty string.",data:(0,s.Z)((0,s.Z)({},e||{}),{},{cause:"The request 'method' must be a non-empty string."})})),i(e=>{let{error:i}=t;return i&&k.error(`MetaMask - RPC Error: ${i.message}`,i),e()})}),u.push(h.middleware),this._rpcEngine=u,h.events.on("notification",e=>{let{method:t,params:i}=e;"wallet_accountsChanged"===t?this._handleAccountsChanged(i):"wallet_unlockStateChanged"===t?this._handleUnlockStateChanged(i):"wallet_chainChanged"===t?this._handleChainChanged(i):W.includes(e.method)&&(this.emit("data",e),this.emit("notification",i.result),this.emit("message",{type:t,data:i}))})}isConnected(){return this._state.isConnected}async request(e){if(!e||"object"!=typeof e||Array.isArray(e))throw d.PY.invalidRequest({message:B.errors.invalidRequestArgs(),data:(0,s.Z)((0,s.Z)({},e||{}),{},{cause:B.errors.invalidRequestArgs()})});let{method:t,params:i}=e;if("string"!=typeof t||0===t.length)throw d.PY.invalidRequest({message:B.errors.invalidRequestMethod(),data:(0,s.Z)((0,s.Z)({},e||{}),{},{cause:B.errors.invalidRequestArgs()})});if(void 0!==i&&!Array.isArray(i)&&("object"!=typeof i||null===i))throw d.PY.invalidRequest({message:B.errors.invalidRequestParams(),data:(0,s.Z)((0,s.Z)({},e||{}),{},{cause:B.errors.invalidRequestArgs()})});return new Promise((e,s)=>{this._rpcRequest({method:t,params:i}
1,Y(e,s))})}sendAsync(e,t){this._rpcRequest(e,t)}async _initializeState(){try{let{accounts:e,chainId:t,isUnlocked:i,networkVersion:s}=await this.request({method:"wallet_getProviderState"});this.emit("connect",{chainId:t}),this._handleChainChanged({chainId:t,networkVersion:s}),this._handleUnlockStateChanged({accounts:e,isUnlocked:i}),this._handleAccountsChanged(e)}catch(e){k.error("MetaMask: Failed to get initial state. Please report this bug.",e)}finally{k.info("initialized state"),this._state.initialized=!0,this.emit("_initialized")}}_rpcRequest(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=t;if(!Array.isArray(e)){if(e.jsonrpc||(e.jsonrpc="2.0"),"eth_accounts"===e.method||"eth_requestAccounts"===e.method)s=(s,n)=>{this._handleAccountsChanged(n.result||[],"eth_accounts"===e.method,i),t(s,n)};else if("wallet_getProviderState"===e.method){this._rpcEngine.handle(e,s);return}}this.tryPreopenHandle(e,s)}send(e,t){return"string"==typeof e&&(!t||Array.isArray(t))?new Promise((i,s)=>{try{this._rpcRequest({method:e,params:t},Y(i,s,!1))}catch(e){s(e)}}):e&&"object"==typeof e&&"function"==typeof t?this._rpcRequest(e,t):this._sendSync(e)}_sendSync(e){let t;switch(e.method){case"eth_accounts":t=this.selectedAddress?[this.selectedAddress]:[];break;case"eth_coinbase":t=this.selectedAddress||null;break;case"eth_uninstallFilter":this._rpcRequest(e,q),t=!0;break;case"net_version":t=this.networkVersion||null;break;default:throw Error(B.errors.unsupportedSync(e.method))}return{id:e.id,jsonrpc:e.jsonrpc,result:t}}_handleConnect(e){this._state.isConnected||(this._state.isConnected=!0,this.emit("connect",{chainId:e}),k.debug(B.info.connected(e)))}_handleDisconnect(e,t){if(this._state.isConnected||!this._state.isPermanentlyDisconnected&&!e){let i;this._state.isConnected=!1,e?(i=new d.yd(1013,t||B.errors.disconnected()),k.debug(i)):(i=new d.yd(1011,t||B.errors.permanentlyDisconnected()),k.error(i),this.chainId=null,this._state.accounts=null,this.selectedAddress=null,this._state.isUnlocked=!1,this._state.isPermanentlyDisconnected=!0),this.emit("disconnect",i)}}_handleStreamDisconnect(e,t){let i;i=`MetaMask: Lost connection to "${e}".`,null!=t&&t.stack&&(i+=` 2${t.stack}`),k.warn(i),this&&this.listenerCount("error")>0&&this.emit("error",i),this._handleDisconnect(!1,t?t.message:void 0)}_handleAccountsChanged(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=e;for(let t of(Array.isArray(s)||(k.error("MetaMask: Received non-array accounts parameter. Please report this bug.",s),s=[]),e))if("string"!=typeof t){k.error("MetaMask: Received non-string account. Please report this bug.",e),s=[];break}u()(this._state.accounts,s)||(t&&Array.isArray(this._state.accounts)&&this._state.accounts.length>0&&!i&&k.error('MetaMask: "eth_accounts" unexpectedly updated accounts. Please report this bug.',s),this._state.accounts=s,this.emit("accountsChanged",s)),this.selectedAddress!==s[0]&&(this.selectedAddress=s[0]||null)}_handleChainChanged(){let{chainId:e,networkVersion:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e||!t){k.error("MetaMask: Received invalid network parameters. Please report this bug.",{chainId:e,networkVersion:t});return}"loading"===t?this._handleDisconnect(!0):(this._handleConnect(e),e!==this.chainId&&(this.chainId=e,this._state.initialized&&this.emit("chainChanged",this.chainId)))}_handleUnlockStateChanged(){let{accounts:e,isUnlocked:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("boolean"!=typeof t){k.error("MetaMask: Received invalid isUnlocked parameter. Please report this bug.",{isUnlocked:t});return}t!==this._state.isUnlocked&&(this._state.isUnlocked=t,this._handleAccountsChanged(e||[]))}}(0,n.Z)(X,"_defaultState",{accounts:null,isConnected:!1,isUnlocked:!1,initialized:!1,isPermanentlyDisconnected:!1,hasEmittedConnection:!1});class F extends a.Ue{constructor(e){let{url:t,target:i,features:s,timeout:r=3e4}=e;super(),(0,n.Z)(this,"url",void 0),(0,n.Z)(this,"target",void 0),(0,n.Z)(this,"features",void 0),(0,n.Z)(this,"window",void 0),(0,n.Z)(this,"windowTimer",void 0),(0,n.Z)(this,"iClosedWindow",void 0),(0,n.Z)(this,"timeout",void 0),this.url=t,this.target=i||"_blank",this.features=s||function(){let e=void 0!==window.screenLeft?window.screenLeft:window.screenX,t=void 0!==window.screenTop?window.screenTop:window.screenY,i=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,s=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height;return`titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=700,width=1200,top=${Math.abs((s-700)/2/1+t)},left=${Math.abs((i-1200)/2/1+e)}`}(),this.window=void 0,this.windowTimer=void 0,this.iClosedWindow=!1,this.timeout=r,this._setupTimer()}_setupTimer(){this.windowTimer=Number(setInterval(()=>{this.window&&this.window.closed&&(clearInterval(this.windowTimer),setTimeout(()=>
2{this.iClosedWindow||this.emit("close"),this.iClosedWindow=!1,this.window=void 0},this.timeout)),void 0===this.window&&clearInterval(this.windowTimer)},500))}open(){var e;this.window=window.open(this.url.href,this.target,this.features),null!==(e=this.window)&&void 0!==e&&e.focus&&this.window.focus()}close(){this.iClosedWindow=!0,this.window&&this.window.close()}redirect(e){e?window.location.replace(this.url.href):window.location.href=this.url.href}}function j(e){return new Promise((t,i)=>{try{let i=document.createElement("img");i.onload=()=>t(!0),i.onerror=()=>t(!1),i.src=e}catch(e){i(e)}})}let z=e=>{let{document:t}=e,i=t.querySelector('head > meta[property="og:site_name"]');if(i)return i.content;let s=t.querySelector('head > meta[name="title"]');return s?s.content:t.title&&t.title.length>0?t.title:e.location.hostname};async function $(e){let{document:t}=e,i=t.querySelector('head > link[rel="shortcut icon"]');return i&&await j(i.href)||(i=Array.from(t.querySelectorAll('head > link[rel="icon"]')).find(e=>!!e.href))&&await j(i.href)?i.href:null}let J=async()=>({name:z(window),icon:await $(window)});async function Q(e){try{let t=await J();e.handle({jsonrpc:"2.0",id:Z(),method:"wallet_sendDomainMetadata",params:t},q)}catch(e){k.error({message:B.errors.sendSiteMetadata(),originalError:e})}}let ee=["host","chainId","networkName"],et=["eth_sendTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","personal_sign","eth_getEncryptionPublicKey","eth_decrypt","wallet_addEthereumChain","wallet_switchEthereumChain"];!async function(){try{if("undefined"==typeof document)return;let e=document.createElement("link"),{torusUrl:t}=await H("production",{version:""});e.href=`${t}/popup`,e.crossOrigin="anonymous",e.type="text/html",e.rel="prefetch",e.relList&&e.relList.supports&&e.relList.supports("prefetch")&&document.head.appendChild(e)}catch(e){k.warn(e)}}();class ei{constructor(){let{buttonPosition:e=b.BOTTOM_LEFT,buttonSize:t=56,modalZIndex:i=99999,apiKey:s="torus-default"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,n.Z)(this,"buttonPosition",b.BOTTOM_LEFT),(0,n.Z)(this,"buttonSize",void 0),(0,n.Z)(this,"torusUrl",void 0),(0,n.Z)(this,"torusIframe",void 0),(0,n.Z)(this,"styleLink",void 0),(0,n.Z)(this,"isLoggedIn",void 0),(0,n.Z)(this,"isInitialized",void 0),(0,n.Z)(this,"torusWidgetVisibility",void 0),(0,n.Z)(this,"torusAlert",void 0),(0,n.Z)(this,"apiKey",void 0),(0,n.Z)(this,"modalZIndex",void 0),(0,n.Z)(this,"alertZIndex",void 0),(0,n.Z)(this,"torusAlertContainer",void 0),(0,n.Z)(this,"isIframeFullScreen",void 0),(0,n.Z)(this,"whiteLabel",void 0),(0,n.Z)(this,"requestedVerifier",void 0),(0,n.Z)(this,"currentVerifier",void 0),(0,n.Z)(this,"embedTranslations",void 0),(0,n.Z)(this,"ethereum",void 0),(0,n.Z)(this,"provider",void 0),(0,n.Z)(this,"communicationMux",void 0),(0,n.Z)(this,"isLoginCallback",void 0),(0,n.Z)(this,"paymentProviders",M.paymentProviders),(0,n.Z)(this,"loginHint",""),(0,n.Z)(this,"useWalletConnect",void 0),(0,n.Z)(this,"isCustomLogin",!1),this.buttonPosition=e,this.buttonSize=t,this.torusUrl="",this.isLoggedIn=!1,this.isInitialized=!1,this.torusWidgetVisibility=!0,this.requestedVerifier="",this.currentVerifier="",this.apiKey=s,(0,r.ut)(s),this.modalZIndex=i,this.alertZIndex=i+1e3,this.isIframeFullScreen=!1}
2async init(){let{buildEnv:e="production",enableLogging:t=!1,network:i={host:"mainnet",chainId:null,networkName:"",blockExplorer:"",ticker:"",tickerName:""},loginConfig:s={},showTorusButton:n=!0,integrity:r={version:""},whiteLabel:a,useWalletConnect:o=!1,mfaLevel:d="default"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.isInitialized)throw Error("Already initialized");let{torusUrl:h,logLevel:u}=await H(e,r);k.info(h,"url loaded"),this.torusUrl=h,this.whiteLabel=a,this.useWalletConnect=o,this.isCustomLogin=!!(s&&Object.keys(s).length>0)||!!(a&&Object.keys(a).length>0),k.setDefaultLevel(u),t?k.enableAll():k.disableAll(),this.torusWidgetVisibility=n;let c=new URL(h);c.pathname.endsWith("/")?c.pathname+="popup":c.pathname+="/popup",c.hash=`#isCustomLogin=${this.isCustomLogin}`,this.torusIframe=U(`<iframe 3 id="torusIframe" 4 allow=${o?"camera":""} 5 class="torusIframe" 6 src="${c.href}" 7 style="display: none; position: fixed; top: 0; right: 0; width: 100%; color-scheme: none; 8 height: 100%; border: none; border-radius: 0; z-index: ${this.modalZIndex}" 9 ></iframe>`),this.torusAlertContainer=U('<div id="torusAlertContainer"></div>'),this.torusAlertContainer.style.display="none",this.torusAlertContainer.style.setProperty("z-index",this.alertZIndex.toString());let p=window.document.createElement("link");p.setAttribute("rel","stylesheet"),p.setAttribute("type","text/css"),p.setAttribute("href",`${h}/css/widget.css`),this.styleLink=p;let{defaultLanguage:m=V(),customTranslations:y={}}=this.whiteLabel||{},g=l()(M.translations,y)[m]||M.translations[V()];return this.embedTranslations=g.embed,new Promise((e,t)=>{this.torusIframe.onload=async()=>{this._setupWeb3();let n=this.communicationMux.getStream("init_stream");n.on("data",i=>{let{name:s,data:n,error:r}=i;"init_complete"===s&&n.success?(this.isInitialized=!0,this._displayIframe(this.isIframeFullScreen),e(void 0)):r&&t(Error(r))}),n.write({name:"init_stream",data:{loginConfig:s,whiteLabel:this.whiteLabel,buttonPosition:this.buttonPosition,buttonSize:this.buttonSize,torusWidgetVisibility:this.torusWidgetVisibility,apiKey:this.apiKey,network:i,mfaLevel:d}})},window.document.head.appendChild(this.styleLink),window.document.body.appendChild(this.torusIframe),window.document.body.appendChild(this.torusAlertContainer)})}login(){let{verifier:e="",login_hint:t=""}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.isInitialized)throw Error("Call init() first");return this.requestedVerifier=e,this.loginHint=t,this.ethereum.enable()}logout(){return new Promise((e,t)=>{if(!this.isLoggedIn){t(Error("User has not logged in yet"));return}this.communicationMux.getStream("logout").write({name:"logOut"}),N(this.communicationMux.getStream("status"),"data",i=>{i.loggedIn?t(Error("Some Error Occured")):(this.isLoggedIn=!1,this.currentVerifier="",this.requestedVerifier="",e())})})}async cleanUp(){this.isLoggedIn&&await this.logout(),this.clearInit()}clearInit(){function e(e){return e instanceof Element||e instanceof HTMLDocument}e(this.styleLink)&&window.document.body.contains(this.styleLink)&&(this.styleLink.remove(),this.styleLink=void 0),e(this.torusIframe)&&window.document.body.contains(this.torusIframe)&&(this.torusIframe.remove(),this.torusIframe=void 0),e(this.torusAlertContainer)&&window.document.body.contains(this.torusAlertContainer)&&(this.torusAlert=void 0,this.torusAlertContainer.remove(),this.torusAlertContainer=void 0),this.isInitialized=!1}hideTorusButton(){this.torusWidgetVisibility=!1,this._sendWidgetVisibilityStatus(!1),this._displayIframe()}showTorusButton(){this.torusWidgetVisibility=!0,this._sendWidgetVisibilityStatus(!0),this._displayIframe()}setProvider(e){let{host:t="mainnet",chainId:i=null,networkName:n=""}=e,r=function(e,t){if(null==e)return{};var i,s,n=function(e,t){if(null==e)return{};var i={};for(var s in e)if(({}).hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;i[s]=e[s]}return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(s=0;s<r.length;s++)i=r[s],t.indexOf(i)>=0||({}).propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}(e,ee);return new Promise((e,a)=>
9{let o=this.communicationMux.getStream("provider_change");N(o,"data",t=>{let{err:i,success:s}=t.data;k.info(t),i?a(i):s?e():a(Error("some error occurred"))});let l=Z();this._handleWindow(l,{target:"_blank",features:x}),o.write({name:"show_provider_change",data:{network:(0,s.Z)({host:t,chainId:i,networkName:n},r),preopenInstanceId:l,override:!1}})})}showWallet(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.communicationMux.getStream("show_wallet"),s=e?`/${e}`:"";i.write({name:"show_wallet",data:{path:s}}),N(i,"data",e=>{if("show_wallet_instance"===e.name){let{instanceId:i}=e.data,n=new URL(`${this.torusUrl}/wallet${s}`);n.searchParams.append("integrity","true"),n.searchParams.append("instanceId",i),Object.keys(t).forEach(e=>{n.searchParams.append(e,t[e])}),n.hash=`#isCustomLogin=${this.isCustomLogin}`,new F({url:n,features:"directories=0,titlebar=0,toolbar=0,status=0,location=0,menubar=0,height=740,width=1315"}).open()}})}async getPublicAddress(e){let{verifier:t,verifierId:i,isExtended:s=!1}=e;if(!M.supportedVerifierList.includes(t)||!C[t])throw Error("Unsupported verifier");let n=C[t],a=new URL("https://api.tor.us/lookup/torus");return a.searchParams.append("verifier",n),a.searchParams.append("verifierId",i),a.searchParams.append("walletVerifier",t),a.searchParams.append("network","mainnet"),a.searchParams.append("isExtended",s.toString()),(0,r.U2)(a.href,{headers:{"Content-Type":"application/json; charset=utf-8"}},{useAPIKey:!0})}getUserInfo(e){return new Promise((t,i)=>{if(this.isLoggedIn){let s=this.communicationMux.getStream("user_info_access");s.write({name:"user_info_access_request"}),N(s,"data",s=>{let{name:n,data:{approved:r,payload:a,rejected:o,newRequest:l}}=s;if("user_info_access_response"===n){if(r)t(a);else if(o)i(Error("User rejected the request"));else if(l){let s=this.communicationMux.getStream("user_info");N(s,"data",e=>{"user_info_response"===e.name&&(e.data.approved?t(e.data.payload):i(Error("User rejected the request")))});let n=Z();this._handleWindow(n,{target:"_blank",features:x}),s.write({name:"user_info_request",data:{message:e,preopenInstanceId:n}})}}})}else i(Error("User has not logged in yet"))})}initiateTopup(e,t){return new Promise((i,s)=>{if(this.isInitialized){let{errors:n,isValid:r}=K(e,t);if(!r){s(Error(JSON.stringify(n)));return}let a=this.communicationMux.getStream("topup");N(a,"data",e=>{"topup_response"===e.name&&(e.data.success?i(e.data.success):s(Error(e.data.error)))});let o=Z();this._handleWindow(o),a.write({name:"topup_request",data:{provider:e,params:t,preopenInstanceId:o}})}else s(Error("Torus is not initialized yet"))})}async loginWithPrivateKey(e){let{privateKey:t,userInfo:i}=e;return new Promise((e,s)=>{if(this.isInitialized){if(32!==g.from(t,"hex").length){s(Error("Invalid private key, Please provide a 32 byte valid secp25k1 private key"));return}let n=this.communicationMux.getStream("login_with_private_key");N(n,"data",t=>{"login_with_private_key_response"===t.name&&(t.data.success?e(t.data.success):s(Error(t.data.error)))}),n.write({name:"login_with_private_key_request",data:{privateKey:t,userInfo:i}})}else s(Error("Torus is not initialized yet"))})}async showWalletConnectScanner(){if(!this.useWalletConnect)throw Error("Set `useWalletConnect` as true in init function options to use wallet connect scanner");return new Promise((e,t)=>{if(this.isLoggedIn){let i=this.communicationMux.getStream("wallet_connect_stream");N(i,"data",i=>{"wallet_connect_stream_res"===i.name&&(i.data.success?e(i.data.success):t(Error(i.data.error)),this._displayIframe())}),i.write({name:"wallet_connect_stream_req"}),this._displayIframe(!0)}else t(Error("User has not logged in yet"))})}_handleWindow(e){let{url:t,target:i,features:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e){let n=this.communicationMux.getStream("window"),r=new URL(t||`${this.torusUrl}/redirect?preopenInstanceId=${e}`);r.hash?r.hash+=`&isCustomLogin=${this.isCustomLogin}`:r.hash=`#isCustomLogin=${this.isCustomLogin}`;let a=new F({url:r,target:i,features:s});if(a.open(),!a.window){this._createPopupBlockAlert(e,r.href);return}n.write({name:"opened_window",data:{preopenInstanceId:e}});let o=t=>{let{preopenInstanceId:i,close:s}=t;i===e&&s&&(a.close(),n.removeListener("data",o))};n.on("data",o),a.once("close",()=>{n.write({data:{preopenInstanceId:e,closed:!0}}),n.removeListener("data",o)})}}_setEmbedWhiteLabel(e){let{theme:t}=this.whiteLabel||{};if(t){let{isDark:i=!1,colors:s={}}=t;i&&e.classList.add("torus-dark"),s.torusBrand1&&e.style.setProperty("--torus-brand-1",s.torusBrand1),s.torusGray2&&e.style.setProperty("--torus-gray-2",s.torusGray2)}}_getLogoUrl(){var e,t,i;let s=`${this.torusUrl}/images/torus_icon-blue.svg`;return null!==(e=this.whiteLabel)&&void 0!==e&&null!==(e=e.theme)&&void 0!==e&&e.isDark?(null===(t=this.whiteLabel)||void 0===t?void 0:t.logoLight)||s:(null===(i=this.whiteLabel)||void 0===i?void 0:i.logoDark)||s}
9_sendWidgetVisibilityStatus(e){this.communicationMux.getStream("torus-widget-visibility").write({data:e})}_displayIframe(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t={},i=this.buttonSize+14;if(e)t.display="block",t.width="100%",t.height="100%",t.top="0px",t.right="0px",t.left="0px",t.bottom="0px";else switch(t.display=this.torusWidgetVisibility?"block":"none",t.height=`${i}px`,t.width=`${i}px`,this.buttonPosition){case b.TOP_LEFT:t.top="0px",t.left="0px",t.right="auto",t.bottom="auto";break;case b.TOP_RIGHT:t.top="0px",t.right="0px",t.left="auto",t.bottom="auto";break;case b.BOTTOM_RIGHT:t.bottom="0px",t.right="0px",t.top="auto",t.left="auto";break;case b.BOTTOM_LEFT:default:t.bottom="0px",t.left="0px",t.top="auto",t.right="auto"}Object.assign(this.torusIframe.style,t),this.isIframeFullScreen=e}_setupWeb3(){k.info("setupWeb3 running");let e=new a.XR({name:"embed_metamask",target:"iframe_metamask",targetWindow:this.torusIframe.contentWindow,targetOrigin:new URL(this.torusUrl).origin}),t=new a.XR({name:"embed_comm",target:"iframe_comm",targetWindow:this.torusIframe.contentWindow,targetOrigin:new URL(this.torusUrl).origin}),i=new X(e),s=e=>{let t=i[e];i[e]=function(e){if(e&&"eth_requestAccounts"===e)return i.enable();for(var s=arguments.length,n=Array(s>1?s-1:0),r=1;r<s;r++)n[r-1]=arguments[r];return t.apply(this,[e,...n])}};s("send"),s("sendAsync"),i.enable=()=>new Promise((e,t)=>{i.sendAsync({jsonrpc:"2.0",id:Z(),method:"eth_requestAccounts",params:[]},(i,s)=>{let{result:n}=s||{};if(i)setTimeout(()=>{t(i)},50);else if(Array.isArray(n)&&n.length>0){let i=()=>{if(""!==this.requestedVerifier&&this.currentVerifier!==this.requestedVerifier){let{requestedVerifier:i}=this;this.logout().then(s=>{this.requestedVerifier=i,this._showLoginPopup(!0,e,t)}).catch(e=>t(e))}else e(n)};this.isLoggedIn?i():this.isLoginCallback=i}else this._showLoginPopup(!0,e,t)})}),i.tryPreopenHandle=(e,t)=>{if(!Array.isArray(e)&&et.includes(e.method)){let t=Z();this._handleWindow(t,{target:"_blank",features:G}),e.preopenInstanceId=t}i._rpcEngine.handle(e,t)};let n=new Proxy(i,{deleteProperty:()=>!0});this.ethereum=n;let r=(0,a.V2)(t);this.communicationMux=r,r.getStream("window").on("data",e=>{"create_window"===e.name&&this._createPopupBlockAlert(e.data.preopenInstanceId,e.data.url)}),r.getStream("widget").on("data",e=>{let{data:t}=e;this._displayIframe(t)}),r.getStream("status").on("data",e=>{e.loggedIn?(this.isLoggedIn=e.loggedIn,this.currentVerifier=e.verifier):this._displayIframe(),this.isLoginCallback&&(this.isLoginCallback(),delete this.isLoginCallback)}),this.provider=n,this.provider.shouldSendMetadata&&Q(this.provider._rpcEngine),i._initializeState(),k.debug("Torus - injected provider")}_showLoginPopup(e,t,i){let s=e=>{let{err:s,selectedAddress:n}=e;s?(k.error(s),i&&i(s)):t&&t([n]),this.isIframeFullScreen&&this._displayIframe()},n=this.communicationMux.getStream("oauth");if(this.requestedVerifier){N(n,"data",s);let t=Z();this._handleWindow(t),n.write({name:"oauth",data:{calledFromEmbed:e,verifier:this.requestedVerifier,preopenInstanceId:t,login_hint:this.loginHint}})}else this._displayIframe(!0),N(n,"data",s),n.write({name:"oauth_modal",data:{calledFromEmbed:e}})}_createPopupBlockAlert(e,t){let i=this._getLogoUrl(),s=U(`<div id="torusAlert" class="torus-alert--v2"><div id="torusAlert__logo"><img src="${i}" /></div><div><h1 id="torusAlert__title">${this.embedTranslations.actionRequired}</h1><p id="torusAlert__desc">${this.embedTranslations.pendingAction}</p></div></div>`),n=U(`<div><a id="torusAlert__btn">${this.embedTranslations.continue}</a></div>`),r=U('<div id="torusAlert__btn-container"></div>');r.appendChild(n),s.appendChild(r),this._setEmbedWhiteLabel(s),this.torusAlertContainer.style.display="block",this.torusAlertContainer.appendChild(s),n.addEventListener("click",()=>{this._handleWindow(e,{url:t,target:"_blank",features:G}),s.remove(),0===this.torusAlertContainer.children.length&&(this.torusAlertContainer.style.display="none")})}}var es=i(53248),en=i(82857);class er extends en.d{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),(0,n.Z)(this,"name",es.rW.TORUS_EVM),(0,n.Z)(this,"adapterNamespace",es.yk.EIP155),(0,n.Z)(this,"currentChainNamespace",es.EN.EIP155),(0,n.Z)(this,"type",es.hN.EXTERNAL),(0,n.Z)(this,"status",es.MP.NOT_READY),(0,n.Z)(this,"torusInstance",null),(0,n.Z)(this,"torusWalletOptions",void 0),(0,n.Z)(this,"initParams",void 0),(0,n.Z)(this,"loginSettings",{}),this.torusWalletOptions=e.adapterSettings||{},this.initParams=e.initParams||{},this.loginSettings=e.loginSettings||{}}get provider(){return this.status!==es.MP.NOT_READY&&this.torusInstance?this.torusInstance.provider:null}set provider(e){throw Error("Not implemented")}
9async init(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};await super.init(e),super.checkInitializationRequirements();let{chainId:t,blockExplorer:i,displayName:n,rpcTarget:r,ticker:a,tickerName:o}=this.chainConfig,l={chainId:Number.parseInt(t,16),host:r,blockExplorer:i,networkName:n,ticker:a,tickerName:o};this.torusInstance=new ei(this.torusWalletOptions),es.cM.debug("initializing torus evm adapter init"),await this.torusInstance.init((0,s.Z)((0,s.Z)({showTorusButton:!1},this.initParams),{},{network:l})),this.status=es.MP.READY,this.emit(es.n2.READY,es.rW.TORUS_EVM);try{es.cM.debug("initializing torus evm adapter"),e.autoConnect&&(this.rehydrated=!0,await this.connect())}catch(e){es.cM.error("Failed to connect with torus evm provider",e),this.emit(es.n2.ERRORED,e)}}async connect(){if(super.checkConnectionRequirements(),!this.torusInstance)throw es.Ty.notReady("Torus wallet is not initialized");this.status=es.MP.CONNECTING,this.emit(es.n2.CONNECTING,{adapter:es.rW.TORUS_EVM});try{await this.torusInstance.login(this.loginSettings);let e=await this.torusInstance.provider.request({method:"eth_chainId"});if(e&&parseInt(e)!==parseInt(this.chainConfig.chainId,16)){let{chainId:e,blockExplorer:t,displayName:i,rpcTarget:n,ticker:r,tickerName:a}=this.chainConfig,o={chainId:Number.parseInt(e,16),host:n,blockExplorer:t,networkName:i,tickerName:a,ticker:r};await this.torusInstance.setProvider((0,s.Z)({},o));let l=await this.torusInstance.ethereum.request({method:"eth_chainId"});if(l&&parseInt(l)!==parseInt(this.chainConfig.chainId,16))throw es.Ty.fromCode(5e3,`Not connected to correct chainId. Expected: ${this.chainConfig.chainId}, Current: ${l}`)}return this.status=es.MP.CONNECTED,this.torusInstance.showTorusButton(),this.emit(es.MP.CONNECTED,{adapter:es.rW.TORUS_EVM,reconnected:this.rehydrated}),this.provider}catch(e){throw this.status=es.MP.READY,this.rehydrated=!1,this.emit(es.MP.ERRORED,e),e instanceof es.up?e:es.RM.connectionError("Failed to login with torus wallet")}}async disconnect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{cleanup:!1};if(await super.disconnectSession(),!this.torusInstance)throw es.Ty.notReady("Torus wallet is not initialized");await this.torusInstance.logout(),this.torusInstance.hideTorusButton(),e.cleanup?(this.status=es.MP.NOT_READY,this.torusInstance=null):this.status=es.MP.READY,await super.disconnect()}async getUserInfo(){if(this.status!==es.MP.CONNECTED)throw es.RM.notConnectedError("Not connected with wallet");if(!this.torusInstance)throw es.Ty.notReady("Torus wallet is not initialized");return await this.torusInstance.getUserInfo("")}async addChain(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.checkAddChainRequirements(e,t),this.addChainConfig(e)}async switchChain(e){var t;let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];super.checkSwitchChainRequirements(e,i);let s=this.getChainConfig(e.chainId);await (null===(t=this.torusInstance)||void 0===t?void 0:t.setProvider({host:s.rpcTarget,chainId:parseInt(s.chainId,16),networkName:s.displayName,blockExplorer:s.blockExplorer,ticker:s.ticker,tickerName:s.tickerName})),this.setAdapterSettings({chainConfig:this.getChainConfig(e.chainId)})}}},76508:function(e){e.exports=function e(t,i){if(t===i)return!0;if(t&&i&&"object"==typeof t&&"object"==typeof i){if(t.constructor!==i.constructor)return!1;if(Array.isArray(t)){if((s=t.length)!=i.length)return!1;for(n=s;0!=n--;)if(!e(t[n],i[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===i.source&&t.flags===i.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===i.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===i.toString();if((s=(r=Object.keys(t)).length)!==Object.keys(i).length)return!1;for(n=s;0!=n--;)if(!Object.prototype.hasOwnProperty.call(i,r[n]))return!1;for(n=s;0!=n--;){var s,n,r,a=r[n];if(!e(t[a],i[a]))return!1}return!0}return t!=t&&i!=i}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.