@privy-io/react-auth 1.76.3 → 1.76.4

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/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var ad=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var wu=(e,t,r)=>(ad(e,t,"read from private field"),r?r.call(e):t.get(e)),hs=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},sd=(e,t,r,o)=>(ad(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var bu=(e,t,r)=>(ad(e,t,"access private method"),r);import{getAddress as Oo}from"@ethersproject/address";import{Web3Provider as pu}from"@ethersproject/providers";import{createStore as m_}from"mipd";import{useEffect as Yr,useMemo as f_,useRef as ea,useState as lt}from"react";import{isAndroid as h_}from"react-device-detect";import{ProviderErrors as y_,calculateTotalGasEstimate as g_,populateTransactionRequest as v_}from"@privy-io/js-sdk-core";import{FetchError as NC}from"ofetch";var et=class extends Error{constructor(r,o,n){super(r);o instanceof Error&&(this.cause=o),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},Mt=class extends et{constructor(r,o,n,i,a){super(n,i,a);this.type=r;this.status=o}},w=class extends et{constructor(r,o,n){super(r,o,n);this.type="client_error"}},ys=class extends w{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var ce=class extends et{constructor(r,o,n){super(r,o,n);this.type="connector_error"}},le=e=>{if(e instanceof et)return e;if(!(e instanceof NC))return tt(e);if(!e.response)return new Mt("api_error",null,e.message,e);let{type:t,message:r,error:o,code:n}=e.data;return new Mt(t||"ApiError",e.response.status,r||o,e,n)},tt=e=>e instanceof et?e:e instanceof Error?new w(e.message,e):new w(`Internal error: ${e}`);var bo=class extends w{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},Wt=class extends w{constructor(t="Embedded wallet error",r){super(t,r,"unknown_embedded_wallet_error")}},gs=class extends w{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var Er=class extends w{constructor(t){super("This application is in development mode and must be upgraded to production to log in new users.",t,"max_accounts_reached")}};var vs="/api/v1/sessions",Cs="/api/v1/sessions/logout",Eu="/api/v1/sessions/fork",ws="/api/v1/sessions/fork/recover",Tu="/api/v1/siwe/init",Su="/api/v1/siwe/authenticate",_u="/api/v1/siwe/link",Pu="/api/v1/siwe/unlink",Au="/api/v1/farcaster/init",xu="/api/v1/farcaster/authenticate",ku="/api/v1/farcaster/link",Ru="/api/v1/farcaster/status",Iu="/api/v1/farcaster/unlink",Mu="/api/v1/passwordless/init",Wu="/api/v1/passwordless/authenticate",Ou="/api/v1/passwordless/link",Lu="/api/v1/passwordless/unlink",Nu="/api/v1/passwordless/update",Du="/api/v1/passwordless_sms/init",Uu="/api/v1/passwordless_sms/link",Fu="/api/v1/passwordless_sms/unlink",Bu="/api/v1/passwordless_sms/authenticate",Hu="/api/v1/passwordless_sms/update",bs="/api/v1/oauth/init",Gu="/api/v1/oauth/authenticate",Es="/api/v1/oauth/link",Vu="/api/v1/oauth/unlink",qu="/api/v1/recovery/oauth/init",zu="/api/v1/recovery/oauth/init_icloud",$u="/api/v1/recovery/oauth/authenticate",Ku="/api/v1/passkeys/link/init",ju="/api/v1/passkeys/authenticate/init",Yu="/api/v1/passkeys/link",Zu="/api/v1/passkeys/authenticate",Qu="/api/v1/passkeys/unlink",Ju="/api/v1/telegram/authenticate",Xu="/api/v1/telegram/link",em="/api/v1/telegram/unlink";var tm="/api/v1/mfa/passwordless_sms/init",rm="/api/v1/mfa/passkeys/init",om="/api/v1/users/me/accept_terms",Ts="/api/v1/analytics_events",nm="/api/v1/custom_jwt_account/authenticate",im="/api/v1/plugins/moonpay_on_ramp/sign",am="/api/v1/funding/coinbase_on_ramp/init",sm="/api/v1/funding/coinbase_on_ramp/status";var ri=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");try{let t=await this.api.post(nm,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){throw new Error("Unimplemented")}};var Lo=class{constructor(t,r){this.meta={email:t,captchaToken:r}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Wu,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Ou,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw le(t)}}async sendCodeEmail(t,r){if(!this.api)throw new w("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new w("Email must be set when initialzing authentication.");try{return await this.api.post(Mu,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw le(o)}}},Ss=class extends Lo{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new w("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(Nu,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw le(r)}}};import{isMobile as UC,isIOS as FC}from"react-device-detect";var ld=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,r){r!==void 0?this._cache[t]=r:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},_s=class{get(t){let r=localStorage.getItem(t);return r===null?void 0:JSON.parse(r)}put(t,r){r!==void 0?localStorage.setItem(t,JSON.stringify(r)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function cd(){try{let e="privy:__session_storage__test",t="blobby",r=new _s;return r.put(e,t),r.del(e),!0}catch{return!1}}function DC(){return typeof window<"u"&&window.localStorage?new _s:new ld}var Q=DC();import{StaticJsonRpcProvider as ra}from"@ethersproject/providers";function lm(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let o of t.providers)o&&r.push(o);return r.push(e.ethereum),r}var Ps=e=>{if(e.isApexWallet)return"Apex Wallet";if(e.isAvalanche)return"Core Wallet";if(e.isBackpack)return"Backpack";if(e.isBifrost)return"Bifrost Wallet";if(e.isBitKeep)return"BitKeep";if(e.isBitski)return"Bitski";if(e.isBlockWallet)return"BlockWallet";if(e.isBraveWallet)return"Brave Wallet";if(e.isClover)return"Clover";if(e.isCoin98)return"Coin98 Wallet";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isDawn)return"Dawn Wallet";if(e.isDefiant)return"Defiant";if(e.isDesig)return"Desig Wallet";if(e.isEnkrypt)return"Enkrypt";if(e.isExodus)return"Exodus";if(e.isFordefi)return"Fordefi";if(e.isFrame)return"Frame";if(e.isFrontier)return"Frontier Wallet";if(e.isGamestop)return"GameStop Wallet";if(e.isHaqqWallet)return"HAQQ Wallet";if(e.isHyperPay)return"HyperPay Wallet";if(e.isImToken)return"ImToken";if(e.isHaloWallet)return"Halo Wallet";if(e.isKuCoinWallet)return"KuCoin Wallet";if(e.isMathWallet)return"MathWallet";if(e.isNovaWallet)return"Nova Wallet";if(e.isOkxWallet||e.isOKExWallet)return"OKX Wallet";if(e.isOneInchIOSWallet||e.isOneInchAndroidWallet)return"1inch Wallet";if(e.isOneKey)return"OneKey Wallet";if(e.isOpera)return"Opera";if(e.isPhantom)return"Phantom";if(e.isPortal)return"Ripio Portal";if(e.isRabby)return"Rabby Wallet";if(e.isRainbow)return"Rainbow";if(e.isSafePal)return"SafePal Wallet";if(e.isStatus)return"Status";if(e.isSubWallet)return"SubWallet";if(e.isTalisman)return"Talisman";if(e.isTally||e.isTaho)return"Taho";if(e.isTokenPocket)return"TokenPocket";if(e.isTokenary)return"Tokenary";if(e.isTrust||e.isTrustWallet)return"Trust Wallet";if(e.isTTWallet)return"TTWallet";if(e.isXDEFI)return"XDEFI Wallet";if(e.isZeal)return"Zeal";if(e.isZerion)return"Zerion";if(e.isMetaMask)return"MetaMask"};var dd=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||Ps(e)!=="MetaMask")return!1;if(e.providers){for(let r of e.providers)if(!dd(r))return!1}return!0},No=()=>!!("phantom"in window&&window?.phantom?.ethereum?.isPhantom),As=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0}return!1};var cm=(e,t)=>{let r=[],o=[];for(let[n,i]of e.entries())n<t?r.push(i):o.push(i);return[r,o]},xs=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),dm=(e,t)=>{let r=e.slice(0),o=[];for(;r.length;)o.push(r.splice(0,t));return o},dt=(e,t=3,r=4)=>{if(!e)return"";let o=2,n=3;if(t+r+o+n>=e.length)return e;let i=e.slice(0,o+t),a=e.slice(e.length-r,e.length);return`${i}...${a}`},pd=e=>new Promise(t=>setTimeout(t,e));function pm(e,{interval:t=100,timeout:r=5e3}={}){return new Promise((o,n)=>{let i=0,a,l=()=>{if(i>=r){n("Max attempts reached without result");return}if(a=e(),i+=t,a!=null){o(a);return}setTimeout(l,t)};l()})}var oa=(e,t={})=>{let r=t.delayMs||150,o=t.maxAttempts||270;return new Promise(async(n,i)=>{let a=!1,l=0;for(;!a&&l<o;){if(t.abortSignal?.aborted)return;e().then(s=>{a=!0,n(s)},(...s)=>{a=!0,i(...s)}),l+=1,await pd(r)}a||i(new Error("Exceeded max attempts before resolving function"))})},ks=(e,t,r={},o={})=>{let n=new URL(t,e);for(let[a,l]of Object.entries(r))l!==void 0&&n.searchParams.set(a,l);let i=Object.entries(o);if(i.length>0){let a=new URLSearchParams;for(let[l,s]of i)a.append(l,s);n.hash=a.toString()}return n.href};var um=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),vn=e=>typeof e=="string"?e:"0x"+e.toString(16);async function mm(e,t,r,o=3e3){let n=!1,i=window;return new Promise(a=>{i.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout(()=>{l()},o));function l(){if(n)return;n=!0,window.removeEventListener("ethereum#initialized",l);let s=e.getProviders(),c=[];for(let m of s)t.includes("coinbase_wallet")&&m.info.rdns==="com.coinbase.wallet"||c.push({type:m.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:m});for(let m of lm()){let f=Ps(m);if(!s.some(u=>u.info.name===f)){if(dd(m,!0)&&!c.find(u=>u.type==="metamask")){c.push({type:"metamask",legacyInjectedProvider:m});continue}if(f==="Phantom"&&!c.find(u=>u.type==="phantom")){c.push({type:"phantom",legacyInjectedProvider:m});continue}if(f==="Coinbase Wallet"&&!c.find(u=>u.type==="coinbase_wallet"&&r?.coinbaseWallet?.connectionOptions!=="smartWalletOnly")){c.push({type:"coinbase_wallet",legacyInjectedProvider:m});continue}c.find(u=>u.type==="unknown_browser_extension")||c.push({type:"unknown_browser_extension",legacyInjectedProvider:m})}}a(c)}})}function oi(e){return`eip155:${String(Number(e))}`}var fm=(e,t,r,o)=>{let n=Number(e),i=t.find(a=>a.id===n);if(!i)throw new ce(`Unsupported chainId ${e}`,4901);return ud(i,r,o)},ud=(e,t,r)=>{let o=e.id,n=Number(e.id),i;if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])i=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[n])i=t.rpcUrls[n];else if(e.rpcUrls.privy?.http[0]){let a=new URL(e.rpcUrls.privy.http[0]);a.searchParams.append("privyAppId",r),i=a.toString()}else e.rpcUrls.public?.http[0]?i=e.rpcUrls.public.http[0]:i=e.rpcUrls.default?.http[0];if(!i)throw new ce(`No RPC url found for ${o}`);return i},hm=(e,t)=>{let r=Number(e),o=t.find(n=>n.id===r);if(!o)throw new ce(`Unsupported chainId ${e}`,4901);return o.blockExplorers?.default.url},Gt=(e,t,r,o)=>{let n=Number(e),i=t.find(l=>l.id===n);if(!i)throw new ce(`Unsupported chainId ${e}`,4901);let a;if(i.rpcUrls.privyWalletOverride&&i.rpcUrls.privyWalletOverride.http[0]?a=new ra(i.rpcUrls.privyWalletOverride.http[0]):r.rpcUrls&&r.rpcUrls[n]?a=new ra(r.rpcUrls[n]):i.rpcUrls.privy?.http[0]?a=new ra({url:i.rpcUrls.privy.http[0],headers:{"privy-app-id":o.appId}}):i.rpcUrls.public?.http[0]?a=new ra(i.rpcUrls.public.http[0]):a=new ra(i.rpcUrls.default?.http[0]),!a)throw new ce(`No RPC url found for ${e}`);return a},na=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map(([o,n])=>{if(n!=null&&typeof o=="string"&&o in t)return{name:o,type:t[o]}}).filter(o=>o!==void 0);return{...e,types:{...e.types,EIP712Domain:r}}};var Rs=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(Is))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var Is={metamask:{id:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",displayName:"MetaMask",hostname:"metamask.io",mobile:{native:"metamask://",universal:"https://metamask.app.link"}},trust:{id:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",displayName:"Trust",hostname:"trustwallet.com",mobile:{universal:"https://link.trustwallet.com"}},safe:{id:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",displayName:"Safe",hostname:"safe.global",mobile:{universal:"https://app.safe.global/"}},rainbow:{id:"1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",displayName:"Rainbow",hostname:"rainbow.me",mobile:{native:"rainbow://",universal:"https://rnbwapp.com"}},uniswap:{id:"c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a",displayName:"Uniswap",hostname:"uniswap.org",mobile:{universal:"https://uniswap.org/app",native:"uniswap://"}},zerion:{id:"ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18",displayName:"Zerion",hostname:"zerion.io",mobile:{native:"zerion://",universal:"https://wallet.zerion.io"}},argent:{id:"bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6",displayName:"Argent",hostname:"www.argent.xyz",mobile:{universal:"https://www.argent.xyz/app"}},spot:{id:"74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d",displayName:"Spot",hostname:"www.spot-wallet.com",mobile:{universal:"https://spot.so"}},omni:{id:"afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7",displayName:"Omni",hostname:"omni.app",mobile:{universal:"https://links.omni.app"}},cryptocom:{id:"f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d",displayName:"Crypto.com",hostname:"crypto.com",mobile:{universal:"https://wallet.crypto.com",native:"dfw://"}},blockchain:{id:"84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04",displayName:"Blockchain",hostname:"www.blockchain.com",mobile:{universal:"https://www.blockchain.com"}},safepal:{id:"0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150",displayName:"SafePal",hostname:"safepal.com",mobile:{universal:"https://link.safepal.io"}},bitkeep:{id:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",displayName:"BitKeep",hostname:"bitkeep.com",mobile:{universal:"https://bkapp.vip"}},zengo:{id:"9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0",displayName:"ZenGo",hostname:"zengo.com",mobile:{universal:"https://get.zengo.com/"}},"1inch":{id:"c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576",displayName:"1inch",hostname:"wallet.1inch.io",mobile:{universal:"https://wallet.1inch.io/wc/"}},binance:{id:"8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4",displayName:"Binance",hostname:"www.binance.com",mobile:{universal:"https://app.binance.com/cedefi"}},exodus:{id:"e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4",displayName:"Exodus",hostname:"exodus.com",mobile:{universal:"https://exodus.com/m"}},mew_wallet:{id:"f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2",displayName:"MEW wallet",hostname:"mewwallet.com",mobile:{universal:"https://mewwallet.com"}},alphawallet:{id:"138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98",displayName:"AlphaWallet",hostname:"alphawallet.com",mobile:{universal:"https://aw.app"}},keyring_pro:{id:"47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83",displayName:"KEYRING PRO",hostname:"keyring.app",mobile:{universal:"https://keyring.app/"}},mathwallet:{id:"7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26",displayName:"MathWallet",hostname:"mathwallet.org",mobile:{universal:"https://www.mathwallet.org"}},unstoppable:{id:"8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3",displayName:"Unstoppable",hostname:"unstoppabledomains.com",mobile:{universal:"https://unstoppabledomains.com/mobile"}},obvious:{id:"031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa",displayName:"Obvious",hostname:"obvious.technology",mobile:{universal:"https://wallet.obvious.technology"}},ambire:{id:"2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568",displayName:"Ambire",hostname:"www.ambire.com",mobile:{universal:"https://mobile.ambire.com"}},internet_money_wallet:{id:"dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd",displayName:"Internet Money Wallet",hostname:"internetmoney.io",mobile:{universal:"https://internetmoney.io"}},coin98:{id:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",displayName:"Coin98",hostname:"coin98.com",mobile:{universal:"https://coin98.services"}},abc_wallet:{id:"b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f",displayName:"ABC Wallet",hostname:"myabcwallet.io",mobile:{universal:"https://abcwalletconnect.page.link"}},arculus_wallet:{id:"0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92",displayName:"Arculus Wallet",hostname:"www.getarculus.com",mobile:{universal:"https://gw.arculus.co/app"}},haha:{id:"719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3",displayName:"HaHa",hostname:"www.haha.me",mobile:{universal:"https://haha.me"}},cling_wallet:{id:"942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef",displayName:"Cling Wallet",hostname:"clingon.io",mobile:{universal:"https://cling.carrieverse.com/apple-app-site-association"}},broearn:{id:"8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2",displayName:"Broearn",hostname:"www.broearn.com",mobile:{universal:"https://www.broearn.com/link/wallet/"}},copiosa:{id:"07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80",displayName:"Copiosa",hostname:"copiosa.io",mobile:{universal:"https://copiosa.io/action/"}},burrito_wallet:{id:"8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819",displayName:"Burrito Wallet",hostname:"burritowallet.com",mobile:{universal:"https://burritowallet.com/wc?uri="}},enjin_wallet:{id:"bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a",displayName:"Enjin Wallet",hostname:"enjin.io",mobile:{universal:"https://deeplink.wallet.enjin.io/"}},plasma_wallet:{id:"cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e",displayName:"Plasma Wallet",hostname:"plasma-wallet.com",mobile:{universal:"https://plasma-wallet.com"}},avacus:{id:"94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43",displayName:"Avacus",hostname:"avacus.cc",mobile:{universal:"https://avacus.app.link"}},bee:{id:"2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715",displayName:"Bee",hostname:"www.beewallet.app",mobile:{universal:"https://beewallet.app/wc"}},pitaka:{id:"14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc",displayName:"Pitaka",hostname:"pitaka.io",mobile:{universal:"https://app.pitaka.io"}},pltwallet:{id:"576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd",displayName:"PLTwallet",hostname:"pltwallet.io",mobile:{universal:"https://pltwallet.io/"}},minerva:{id:"49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd",displayName:"Minerva",hostname:"minerva.digital",mobile:{universal:"https://minerva.digital"}},kryptogo:{id:"19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b",displayName:"KryptoGO",hostname:"kryptogo.com",mobile:{universal:"https://kryptogo.page.link"}},prema:{id:"5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b",displayName:"PREMA",hostname:"premanft.com",mobile:{universal:"https://premanft.com"}},slingshot:{id:"d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b",displayName:"Slingshot",hostname:"slingshot.finance",mobile:{universal:"https://app.slingshot.finance"}},kriptonio:{id:"50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b",displayName:"Kriptonio",hostname:"kriptonio.com",mobile:{universal:"https://app.kriptonio.com/mobile"}},timeless:{id:"9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8",displayName:"Timeless",hostname:"timelesswallet.xyz",mobile:{universal:"https://timelesswallet.xyz"}},secux:{id:"6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa",displayName:"SecuX",hostname:"secuxtech.com",mobile:{universal:"https://wsweb.secuxtech.com"}},bitizen:{id:"41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071",displayName:"Bitizen",hostname:"bitizen.org",mobile:{universal:"https://bitizen.org/wallet"}},blocto:{id:"14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd",displayName:"Blocto",hostname:"blocto.io",mobile:{universal:"https://blocto.app"}},safemoon:{id:"a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1",displayName:"SafeMoon",hostname:"safemoon.com",mobile:{universal:"https://safemoon.com/wc"}},okx_wallet:{id:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",displayName:"OKX Wallet",hostname:"okx.com",mobile:{native:"okex://main"}},rabby_wallet:{id:"18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1",displayName:"Rabby Wallet",hostname:"rabby.io",mobile:{}}};function ym(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function gm(e,t){let r=ym(t);if(r.deepLink)return Tm(r.deepLink,e);if(r.universalLink)return md(r.universalLink,e);throw new w(`Unsupported wallet ${t.id}`)}function vm(e,t){let r=ym(t);if(r.universalLink)return md(r.universalLink,e)}var Cm="WALLETCONNECT_DEEPLINK_CHOICE";function wm(){try{localStorage.removeItem(Cm)}catch{}}function bm({href:e,name:t}){try{localStorage.setItem(Cm,JSON.stringify({href:e,name:t}))}catch{}}function Em(e){return e.startsWith("http://")||e.startsWith("https://")}function Tm(e,t){if(Em(e))return md(e,t);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function md(e,t){if(!Em(e))return Tm(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function Ms(e,t){window.open(e,t,"noreferrer noopener")}var Le=class{constructor(t){this.promise=null;this.fn=t}execute(t){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(t)}finally{this.promise=null}})()),this.promise}};var ia=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Le(this._startChannelOnce.bind(this)),this.pollForReady=new Le(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.channelToken)throw new w("Auth flow must be initialized first");try{let t=await this.api.post(xu,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new w("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");try{return await this.api.post(ku,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw le(t)}}async _startChannelOnce(){if(!this.api)throw new w("Auth flow has no API instance");let t=await this.api.post(Au,{token:this.captchaToken});UC&&!FC&&t.connect_uri&&Ms(t.connect_uri,"_blank"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new w("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.channelToken)throw new w("Auth flow must be initialized first");let t=await this.api.get(Ru,{headers:{"farcaster-channel-token":this.meta.channelToken}});return t.state==="completed"?(this.message=t.message,this.signature=t.signature,this.fid=t.fid,!0):!1}};var Sm="1.76.3";var _m="34357d3c125c2bcf2ce2bc3309d98715",Ws="https://auth.privy.io",Pm=2e4,Ne=1400,Os=2500,fd=Sm;var Cn="privy:token",hd="privy-token",Ls="privy:refresh_token",Am="privy-refresh-token",yd="privy:id_token",gd="privy-id-token",Ns="privy-session",aa="privy:session_transfer_token",HC="privy:wallet",sa="privy:caid",la=e=>`privy:cross-app:${e}`,wn="privy:state_code",bn="privy:code_verifier",En="privy:headless_oauth",Ds=e=>`${HC}:${e}`,vd="privy:connectors",Cd="privy:connections";var Tn=12e4,Eo=1,wd="0x1",ni=3e4,xm="https://api.moonpay.com/v1",km="https://api.moonpay.com/v1",Rm="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Im="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";var Mm="deprecated";import{base64url as Lm}from"jose";async function Wm(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function Om(e){return crypto.getRandomValues(new Uint8Array(e))}var GC="S256",VC="S256";function Sn(){return Lm.encode(Om(36))}function ii(){return Sn()}async function ai(e,t=GC){if(t==VC){let r=await Wm(e);return Lm.encode(r)}else return e}function Nm(){let e=Q.get(bn);if(!e)throw new w("Authentication error.");return e}function Us(){return!!Q.get(En)}var Jr=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:Us();this.meta={...t,headless:r}}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");let t=Nm();try{let r=await this.api.post(Gu,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Q.del(bn),this.meta.headless&&Q.del(En),{user:r.user,token:r.token,refresh_token:r.refresh_token,identity_token:r.identity_token,is_new_user:r.is_new_user,oauth_tokens:r.oauth_tokens}}catch(r){let o=le(r);throw o.privyErrorCode?new w(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new w("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new w("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");let t=Q.get(bn);if(!t)throw new w("Authentication error.");try{let r=await this.api.post(Es,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Q.del(bn),r}catch(r){throw le(r)}}async getAuthorizationUrl(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.provider)throw new w("Provider must be set when initializing OAuth authentication.");let t=Sn();Q.put(bn,t);let r=ii();Q.put(wn,r);let o=await ai(t);this.meta.headless&&Q.put(En,!0);try{return await this.api.post(bs,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw le(n)}}};function bd(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{jsx as Dm,jsxs as qC}from"react/jsx-runtime";var Fs=({style:e,...t})=>qC("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...e},...t,children:[Dm("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),Dm("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]});import{jsx as ca,jsxs as zC}from"react/jsx-runtime";var Bs=({style:e,...t})=>zC("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...e},...t,children:[ca("g",{clipPath:"url(#clip0)",children:ca("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),ca("defs",{children:ca("clipPath",{id:"clip0",children:ca("rect",{width:"71",height:"55",fill:"white"})})})]});import{jsx as Um}from"react/jsx-runtime";var Hs=({style:e,...t})=>Um("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...t,children:Um("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})});import{GlobeAltIcon as $C}from"@heroicons/react/24/outline";import{jsx as KC}from"react/jsx-runtime";var Fm=({style:e})=>KC($C,{style:{color:"var(--privy-color-error)",...e}});import{jsx as Gs,jsxs as jC}from"react/jsx-runtime";var Vs=({style:e,...t})=>jC("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...e},...t,children:[Gs("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),Gs("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),Gs("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),Gs("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});import{jsx as Tr,jsxs as qs}from"react/jsx-runtime";function zs(e){return qs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...e,children:[qs("defs",{children:[qs("linearGradient",{id:"b",children:[Tr("stop",{offset:"0",stopColor:"#3771c8"}),Tr("stop",{stopColor:"#3771c8",offset:".128"}),Tr("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),qs("linearGradient",{id:"a",children:[Tr("stop",{offset:"0",stopColor:"#fd5"}),Tr("stop",{offset:".1",stopColor:"#fd5"}),Tr("stop",{offset:".5",stopColor:"#ff543e"}),Tr("stop",{offset:"1",stopColor:"#c837ab"})]}),Tr("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),Tr("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),Tr("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),Tr("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),Tr("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}import{jsx as $s}from"react/jsx-runtime";function Ks({style:e,...t}){return $s("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...e},...t,children:$s("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:$s("g",{transform:"scale(5.12,5.12)",children:$s("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}import{jsx as Bm,jsxs as YC}from"react/jsx-runtime";function js(e){return YC("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...e,children:[Bm("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),Bm("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}import{jsx as Ed,jsxs as ZC}from"react/jsx-runtime";function Ys(e){return ZC("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...e,children:[Ed("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),Ed("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),Ed("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}import{jsx as Hm}from"react/jsx-runtime";var Zs=({style:e,...t})=>Hm("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...e},...t,children:Hm("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})});var Gm={google:{name:"Google",component:Vs},discord:{name:"Discord",component:Bs},github:{name:"Github",component:Hs},linkedin:{name:"LinkedIn",component:Ks},twitter:{name:"Twitter",component:Zs},spotify:{name:"Spotify",component:js},instagram:{name:"Instagram",component:zs},tiktok:{name:"Tiktok",component:Ys},apple:{name:"Apple",component:Fs}},da=e=>e in Gm?Gm[e]:{name:"Unknown",component:Fm};function Vm(e,t){let r={detail:"",retryable:!1},o=bd(t);if(e?.privyErrorCode==="linked_to_another_user"&&(r.detail="This account has already been linked to another user."),e?.privyErrorCode==="invalid_credentials"&&(r.retryable=!0,r.detail="Something went wrong. Try again."),e.privyErrorCode==="oauth_user_denied"&&(r.detail=`Retry and check ${o} to finish connecting your account.`,r.retryable=!0),e?.privyErrorCode==="too_many_requests"&&(r.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="too_many_requests"&&e.message.includes("provider rate limit")){let n=da(t).name;r.detail=`Request limit reached for ${n}. Please wait a moment and try again.`}if(e?.privyErrorCode==="oauth_account_suspended"){let n=da(t).name;r.detail=`Your ${n} account is suspended. Please try another login method.`}return e?.privyErrorCode==="cannot_link_more_of_type"&&(r.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode==="oauth_unexpected"&&t.startsWith("privy:")&&(r.detail="Something went wrong. Please try again."),r}function pa(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),o=e.get("privy_oauth_provider");if(!t||!r||!o)return{inProgress:!1};let n=!1;try{n=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:Us(),popupFlow:window.opener!==null&&n}}function _n(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Q.del(wn),window.history.replaceState({},"",e)}var Pn=class{constructor(t){this.initAuthenticateOnce=new Le(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Le(this._initLinkOnce.bind(this)),this.meta={captchaToken:t}}async initAuthenticationFlow(){if(!this.api)throw new w("Auth flow has no API instance");this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute()}async initLinkFlow(){if(!this.api)throw new w("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async authenticate(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new w("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new w("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());try{let r=await t.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase(this.meta.initAuthenticateResponse.options)),o=await this.api.post(Zu,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(r){throw r.name==="NotAllowedError"?new w("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):le(r)}}async link(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new w("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new w("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let r=this.meta.initLinkResponse.options,o=await t.startRegistration(this._transformInitLinkOptionsToCamelCase(r));return await this.api.post(Yu,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(o)})}catch(r){throw r.name==="NotAllowedError"?new w("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):le(r)}}async _initAuthenticateOnce(){if(!this.api)throw new w("Auth flow has no API instance");return await this.api.post(ju,{token:this.meta.captchaToken})}async _initLinkOnce(){if(!this.api)throw new w("Auth flow has no API instance");return await this.api.post(Ku,{})}_transformInitLinkOptionsToCamelCase(t){return{rp:t.rp,user:{id:t.user.id,name:t.user.name,displayName:t.user.display_name},challenge:t.challenge,pubKeyCredParams:t.pub_key_cred_params.map(r=>({type:r.type,alg:r.alg})),timeout:t.timeout,excludeCredentials:t.exclude_credentials?.map(r=>({id:r.id,type:r.type,transports:r.transports})),authenticatorSelection:{authenticatorAttachment:t.authenticator_selection?.authenticator_attachment,requireResidentKey:t.authenticator_selection?.require_resident_key,residentKey:t.authenticator_selection?.resident_key,userVerification:t.authenticator_selection?.user_verification},attestation:t.attestation,extensions:{appid:t.extensions?.app_id,credProps:t.extensions?.cred_props?.rk,hmacCreateSecret:t.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(t){return{id:t.id,raw_id:t.rawId,response:{client_data_json:t.response.clientDataJSON,attestation_object:t.response.attestationObject,authenticator_data:t.response.authenticatorData},authenticator_attachment:t.authenticatorAttachment,client_extension_results:{app_id:t.clientExtensionResults.appid,cred_props:t.clientExtensionResults.credProps,hmac_create_secret:t.clientExtensionResults.hmacCreateSecret},type:t.type}}_transformInitAuthenticateOptionsToCamelCase(t){return{challenge:t.challenge,allowCredentials:t.allow_credentials?.map(r=>({id:r.id,type:r.type,transports:r.transports}))||[],timeout:t.timeout,extensions:{appid:t.extensions?.app_id,credProps:t.extensions?.cred_props,hmacCreateSecret:t.extensions?.hmac_create_secret},userVerification:t.user_verification}}_transformAuthenticationResponseToSnakeCase(t){return{id:t.id,raw_id:t.rawId,response:{client_data_json:t.response.clientDataJSON,authenticator_data:t.response.authenticatorData,signature:t.response.signature,user_handle:t.response.userHandle},authenticator_attachment:t.authenticatorAttachment,client_extension_results:{app_id:t.clientExtensionResults.appid,cred_props:t.clientExtensionResults.credProps,hmac_create_secret:t.clientExtensionResults.hmacCreateSecret},type:t.type}}};var Qs=({address:e,chainId:t,nonce:r})=>{let o=window.location.host,n=window.location.origin,i="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",a=new Date().toISOString();return`${o} wants you to sign in with your Ethereum account:
1
+ var ad=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var wu=(e,t,r)=>(ad(e,t,"read from private field"),r?r.call(e):t.get(e)),hs=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},sd=(e,t,r,o)=>(ad(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var bu=(e,t,r)=>(ad(e,t,"access private method"),r);import{getAddress as Oo}from"@ethersproject/address";import{Web3Provider as pu}from"@ethersproject/providers";import{createStore as m_}from"mipd";import{useEffect as Yr,useMemo as f_,useRef as ea,useState as lt}from"react";import{isAndroid as h_}from"react-device-detect";import{ProviderErrors as y_,calculateTotalGasEstimate as g_,populateTransactionRequest as v_}from"@privy-io/js-sdk-core";import{FetchError as NC}from"ofetch";var et=class extends Error{constructor(r,o,n){super(r);o instanceof Error&&(this.cause=o),this.privyErrorCode=n}toString(){return`${this.type}${this.privyErrorCode?`-${this.privyErrorCode}`:""}: ${this.message}${this.cause?` [cause: ${this.cause}]`:""}`}},Mt=class extends et{constructor(r,o,n,i,a){super(n,i,a);this.type=r;this.status=o}},w=class extends et{constructor(r,o,n){super(r,o,n);this.type="client_error"}},ys=class extends w{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var ce=class extends et{constructor(r,o,n){super(r,o,n);this.type="connector_error"}},le=e=>{if(e instanceof et)return e;if(!(e instanceof NC))return tt(e);if(!e.response)return new Mt("api_error",null,e.message,e);let{type:t,message:r,error:o,code:n}=e.data;return new Mt(t||"ApiError",e.response.status,r||o,e,n)},tt=e=>e instanceof et?e:e instanceof Error?new w(e.message,e):new w(`Internal error: ${e}`);var bo=class extends w{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},Wt=class extends w{constructor(t="Embedded wallet error",r){super(t,r,"unknown_embedded_wallet_error")}},gs=class extends w{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var Er=class extends w{constructor(t){super("This application is in development mode and must be upgraded to production to log in new users.",t,"max_accounts_reached")}};var vs="/api/v1/sessions",Cs="/api/v1/sessions/logout",Eu="/api/v1/sessions/fork",ws="/api/v1/sessions/fork/recover",Tu="/api/v1/siwe/init",Su="/api/v1/siwe/authenticate",_u="/api/v1/siwe/link",Pu="/api/v1/siwe/unlink",Au="/api/v1/farcaster/init",xu="/api/v1/farcaster/authenticate",ku="/api/v1/farcaster/link",Ru="/api/v1/farcaster/status",Iu="/api/v1/farcaster/unlink",Mu="/api/v1/passwordless/init",Wu="/api/v1/passwordless/authenticate",Ou="/api/v1/passwordless/link",Lu="/api/v1/passwordless/unlink",Nu="/api/v1/passwordless/update",Du="/api/v1/passwordless_sms/init",Uu="/api/v1/passwordless_sms/link",Fu="/api/v1/passwordless_sms/unlink",Bu="/api/v1/passwordless_sms/authenticate",Hu="/api/v1/passwordless_sms/update",bs="/api/v1/oauth/init",Gu="/api/v1/oauth/authenticate",Es="/api/v1/oauth/link",Vu="/api/v1/oauth/unlink",qu="/api/v1/recovery/oauth/init",zu="/api/v1/recovery/oauth/init_icloud",$u="/api/v1/recovery/oauth/authenticate",Ku="/api/v1/passkeys/link/init",ju="/api/v1/passkeys/authenticate/init",Yu="/api/v1/passkeys/link",Zu="/api/v1/passkeys/authenticate",Qu="/api/v1/passkeys/unlink",Ju="/api/v1/telegram/authenticate",Xu="/api/v1/telegram/link",em="/api/v1/telegram/unlink";var tm="/api/v1/mfa/passwordless_sms/init",rm="/api/v1/mfa/passkeys/init",om="/api/v1/users/me/accept_terms",Ts="/api/v1/analytics_events",nm="/api/v1/custom_jwt_account/authenticate",im="/api/v1/plugins/moonpay_on_ramp/sign",am="/api/v1/funding/coinbase_on_ramp/init",sm="/api/v1/funding/coinbase_on_ramp/status";var ri=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");try{let t=await this.api.post(nm,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){throw new Error("Unimplemented")}};var Lo=class{constructor(t,r){this.meta={email:t,captchaToken:r}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Wu,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new w("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Ou,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw le(t)}}async sendCodeEmail(t,r){if(!this.api)throw new w("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new w("Email must be set when initialzing authentication.");try{return await this.api.post(Mu,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw le(o)}}},Ss=class extends Lo{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new w("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(Nu,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw le(r)}}};import{isMobile as UC,isIOS as FC}from"react-device-detect";var ld=class{constructor(){this._cache={}}get(t){return this._cache[t]}put(t,r){r!==void 0?this._cache[t]=r:this.del(t)}del(t){delete this._cache[t]}getKeys(){return Object.keys(this._cache)}},_s=class{get(t){let r=localStorage.getItem(t);return r===null?void 0:JSON.parse(r)}put(t,r){r!==void 0?localStorage.setItem(t,JSON.stringify(r)):this.del(t)}del(t){localStorage.removeItem(t)}getKeys(){return Object.entries(localStorage).map(([t])=>t)}};function cd(){try{let e="privy:__session_storage__test",t="blobby",r=new _s;return r.put(e,t),r.del(e),!0}catch{return!1}}function DC(){return typeof window<"u"&&window.localStorage?new _s:new ld}var Q=DC();import{StaticJsonRpcProvider as ra}from"@ethersproject/providers";function lm(){let e=window,t=e.ethereum;if(!t)return[];let r=[];if(t.providers?.length)for(let o of t.providers)o&&r.push(o);return r.push(e.ethereum),r}var Ps=e=>{if(e.isApexWallet)return"Apex Wallet";if(e.isAvalanche)return"Core Wallet";if(e.isBackpack)return"Backpack";if(e.isBifrost)return"Bifrost Wallet";if(e.isBitKeep)return"BitKeep";if(e.isBitski)return"Bitski";if(e.isBlockWallet)return"BlockWallet";if(e.isBraveWallet)return"Brave Wallet";if(e.isClover)return"Clover";if(e.isCoin98)return"Coin98 Wallet";if(e.isCoinbaseWallet)return"Coinbase Wallet";if(e.isDawn)return"Dawn Wallet";if(e.isDefiant)return"Defiant";if(e.isDesig)return"Desig Wallet";if(e.isEnkrypt)return"Enkrypt";if(e.isExodus)return"Exodus";if(e.isFordefi)return"Fordefi";if(e.isFrame)return"Frame";if(e.isFrontier)return"Frontier Wallet";if(e.isGamestop)return"GameStop Wallet";if(e.isHaqqWallet)return"HAQQ Wallet";if(e.isHyperPay)return"HyperPay Wallet";if(e.isImToken)return"ImToken";if(e.isHaloWallet)return"Halo Wallet";if(e.isKuCoinWallet)return"KuCoin Wallet";if(e.isMathWallet)return"MathWallet";if(e.isNovaWallet)return"Nova Wallet";if(e.isOkxWallet||e.isOKExWallet)return"OKX Wallet";if(e.isOneInchIOSWallet||e.isOneInchAndroidWallet)return"1inch Wallet";if(e.isOneKey)return"OneKey Wallet";if(e.isOpera)return"Opera";if(e.isPhantom)return"Phantom";if(e.isPortal)return"Ripio Portal";if(e.isRabby)return"Rabby Wallet";if(e.isRainbow)return"Rainbow";if(e.isSafePal)return"SafePal Wallet";if(e.isStatus)return"Status";if(e.isSubWallet)return"SubWallet";if(e.isTalisman)return"Talisman";if(e.isTally||e.isTaho)return"Taho";if(e.isTokenPocket)return"TokenPocket";if(e.isTokenary)return"Tokenary";if(e.isTrust||e.isTrustWallet)return"Trust Wallet";if(e.isTTWallet)return"TTWallet";if(e.isXDEFI)return"XDEFI Wallet";if(e.isZeal)return"Zeal";if(e.isZerion)return"Zerion";if(e.isMetaMask)return"MetaMask"};var dd=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||Ps(e)!=="MetaMask")return!1;if(e.providers){for(let r of e.providers)if(!dd(r))return!1}return!0},No=()=>!!("phantom"in window&&window?.phantom?.ethereum?.isPhantom),As=()=>{let e=window;if(!e.ethereum)return!1;if(e.ethereum.isCoinbaseWallet)return!0;if(e.ethereum.providers){for(let t of e.ethereum.providers)if(t&&t.isCoinbaseWallet)return!0}return!1};var cm=(e,t)=>{let r=[],o=[];for(let[n,i]of e.entries())n<t?r.push(i):o.push(i);return[r,o]},xs=e=>!!String(e).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),dm=(e,t)=>{let r=e.slice(0),o=[];for(;r.length;)o.push(r.splice(0,t));return o},dt=(e,t=3,r=4)=>{if(!e)return"";let o=2,n=3;if(t+r+o+n>=e.length)return e;let i=e.slice(0,o+t),a=e.slice(e.length-r,e.length);return`${i}...${a}`},pd=e=>new Promise(t=>setTimeout(t,e));function pm(e,{interval:t=100,timeout:r=5e3}={}){return new Promise((o,n)=>{let i=0,a,l=()=>{if(i>=r){n("Max attempts reached without result");return}if(a=e(),i+=t,a!=null){o(a);return}setTimeout(l,t)};l()})}var oa=(e,t={})=>{let r=t.delayMs||150,o=t.maxAttempts||270;return new Promise(async(n,i)=>{let a=!1,l=0;for(;!a&&l<o;){if(t.abortSignal?.aborted)return;e().then(s=>{a=!0,n(s)},(...s)=>{a=!0,i(...s)}),l+=1,await pd(r)}a||i(new Error("Exceeded max attempts before resolving function"))})},ks=(e,t,r={},o={})=>{let n=new URL(t,e);for(let[a,l]of Object.entries(r))l!==void 0&&n.searchParams.set(a,l);let i=Object.entries(o);if(i.length>0){let a=new URLSearchParams;for(let[l,s]of i)a.append(l,s);n.hash=a.toString()}return n.href};var um=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),vn=e=>typeof e=="string"?e:"0x"+e.toString(16);async function mm(e,t,r,o=3e3){let n=!1,i=window;return new Promise(a=>{i.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout(()=>{l()},o));function l(){if(n)return;n=!0,window.removeEventListener("ethereum#initialized",l);let s=e.getProviders(),c=[];for(let m of s)t.includes("coinbase_wallet")&&m.info.rdns==="com.coinbase.wallet"||c.push({type:m.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:m});for(let m of lm()){let f=Ps(m);if(!s.some(u=>u.info.name===f)){if(dd(m,!0)&&!c.find(u=>u.type==="metamask")){c.push({type:"metamask",legacyInjectedProvider:m});continue}if(f==="Phantom"&&!c.find(u=>u.type==="phantom")){c.push({type:"phantom",legacyInjectedProvider:m});continue}if(f==="Coinbase Wallet"&&!c.find(u=>u.type==="coinbase_wallet"&&r?.coinbaseWallet?.connectionOptions!=="smartWalletOnly")){c.push({type:"coinbase_wallet",legacyInjectedProvider:m});continue}c.find(u=>u.type==="unknown_browser_extension")||c.push({type:"unknown_browser_extension",legacyInjectedProvider:m})}}a(c)}})}function oi(e){return`eip155:${String(Number(e))}`}var fm=(e,t,r,o)=>{let n=Number(e),i=t.find(a=>a.id===n);if(!i)throw new ce(`Unsupported chainId ${e}`,4901);return ud(i,r,o)},ud=(e,t,r)=>{let o=e.id,n=Number(e.id),i;if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])i=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[n])i=t.rpcUrls[n];else if(e.rpcUrls.privy?.http[0]){let a=new URL(e.rpcUrls.privy.http[0]);a.searchParams.append("privyAppId",r),i=a.toString()}else e.rpcUrls.public?.http[0]?i=e.rpcUrls.public.http[0]:i=e.rpcUrls.default?.http[0];if(!i)throw new ce(`No RPC url found for ${o}`);return i},hm=(e,t)=>{let r=Number(e),o=t.find(n=>n.id===r);if(!o)throw new ce(`Unsupported chainId ${e}`,4901);return o.blockExplorers?.default.url},Gt=(e,t,r,o)=>{let n=Number(e),i=t.find(l=>l.id===n);if(!i)throw new ce(`Unsupported chainId ${e}`,4901);let a;if(i.rpcUrls.privyWalletOverride&&i.rpcUrls.privyWalletOverride.http[0]?a=new ra(i.rpcUrls.privyWalletOverride.http[0]):r.rpcUrls&&r.rpcUrls[n]?a=new ra(r.rpcUrls[n]):i.rpcUrls.privy?.http[0]?a=new ra({url:i.rpcUrls.privy.http[0],headers:{"privy-app-id":o.appId}}):i.rpcUrls.public?.http[0]?a=new ra(i.rpcUrls.public.http[0]):a=new ra(i.rpcUrls.default?.http[0]),!a)throw new ce(`No RPC url found for ${e}`);return a},na=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},r=e.types.EIP712Domain??Object.entries(e.domain).map(([o,n])=>{if(n!=null&&typeof o=="string"&&o in t)return{name:o,type:t[o]}}).filter(o=>o!==void 0);return{...e,types:{...e.types,EIP712Domain:r}}};var Rs=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(Is))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var Is={metamask:{id:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",displayName:"MetaMask",hostname:"metamask.io",mobile:{native:"metamask://",universal:"https://metamask.app.link"}},trust:{id:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",displayName:"Trust",hostname:"trustwallet.com",mobile:{universal:"https://link.trustwallet.com"}},safe:{id:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",displayName:"Safe",hostname:"safe.global",mobile:{universal:"https://app.safe.global/"}},rainbow:{id:"1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",displayName:"Rainbow",hostname:"rainbow.me",mobile:{native:"rainbow://",universal:"https://rnbwapp.com"}},uniswap:{id:"c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a",displayName:"Uniswap",hostname:"uniswap.org",mobile:{universal:"https://uniswap.org/app",native:"uniswap://"}},zerion:{id:"ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18",displayName:"Zerion",hostname:"zerion.io",mobile:{native:"zerion://",universal:"https://wallet.zerion.io"}},argent:{id:"bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6",displayName:"Argent",hostname:"www.argent.xyz",mobile:{universal:"https://www.argent.xyz/app"}},spot:{id:"74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d",displayName:"Spot",hostname:"www.spot-wallet.com",mobile:{universal:"https://spot.so"}},omni:{id:"afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7",displayName:"Omni",hostname:"omni.app",mobile:{universal:"https://links.omni.app"}},cryptocom:{id:"f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d",displayName:"Crypto.com",hostname:"crypto.com",mobile:{universal:"https://wallet.crypto.com",native:"dfw://"}},blockchain:{id:"84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04",displayName:"Blockchain",hostname:"www.blockchain.com",mobile:{universal:"https://www.blockchain.com"}},safepal:{id:"0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150",displayName:"SafePal",hostname:"safepal.com",mobile:{universal:"https://link.safepal.io"}},bitkeep:{id:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",displayName:"BitKeep",hostname:"bitkeep.com",mobile:{universal:"https://bkapp.vip"}},zengo:{id:"9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0",displayName:"ZenGo",hostname:"zengo.com",mobile:{universal:"https://get.zengo.com/"}},"1inch":{id:"c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576",displayName:"1inch",hostname:"wallet.1inch.io",mobile:{universal:"https://wallet.1inch.io/wc/"}},binance:{id:"8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4",displayName:"Binance",hostname:"www.binance.com",mobile:{universal:"https://app.binance.com/cedefi"}},exodus:{id:"e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4",displayName:"Exodus",hostname:"exodus.com",mobile:{universal:"https://exodus.com/m"}},mew_wallet:{id:"f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2",displayName:"MEW wallet",hostname:"mewwallet.com",mobile:{universal:"https://mewwallet.com"}},alphawallet:{id:"138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98",displayName:"AlphaWallet",hostname:"alphawallet.com",mobile:{universal:"https://aw.app"}},keyring_pro:{id:"47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83",displayName:"KEYRING PRO",hostname:"keyring.app",mobile:{universal:"https://keyring.app/"}},mathwallet:{id:"7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26",displayName:"MathWallet",hostname:"mathwallet.org",mobile:{universal:"https://www.mathwallet.org"}},unstoppable:{id:"8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3",displayName:"Unstoppable",hostname:"unstoppabledomains.com",mobile:{universal:"https://unstoppabledomains.com/mobile"}},obvious:{id:"031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa",displayName:"Obvious",hostname:"obvious.technology",mobile:{universal:"https://wallet.obvious.technology"}},ambire:{id:"2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568",displayName:"Ambire",hostname:"www.ambire.com",mobile:{universal:"https://mobile.ambire.com"}},internet_money_wallet:{id:"dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd",displayName:"Internet Money Wallet",hostname:"internetmoney.io",mobile:{universal:"https://internetmoney.io"}},coin98:{id:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",displayName:"Coin98",hostname:"coin98.com",mobile:{universal:"https://coin98.services"}},abc_wallet:{id:"b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f",displayName:"ABC Wallet",hostname:"myabcwallet.io",mobile:{universal:"https://abcwalletconnect.page.link"}},arculus_wallet:{id:"0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92",displayName:"Arculus Wallet",hostname:"www.getarculus.com",mobile:{universal:"https://gw.arculus.co/app"}},haha:{id:"719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3",displayName:"HaHa",hostname:"www.haha.me",mobile:{universal:"https://haha.me"}},cling_wallet:{id:"942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef",displayName:"Cling Wallet",hostname:"clingon.io",mobile:{universal:"https://cling.carrieverse.com/apple-app-site-association"}},broearn:{id:"8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2",displayName:"Broearn",hostname:"www.broearn.com",mobile:{universal:"https://www.broearn.com/link/wallet/"}},copiosa:{id:"07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80",displayName:"Copiosa",hostname:"copiosa.io",mobile:{universal:"https://copiosa.io/action/"}},burrito_wallet:{id:"8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819",displayName:"Burrito Wallet",hostname:"burritowallet.com",mobile:{universal:"https://burritowallet.com/wc?uri="}},enjin_wallet:{id:"bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a",displayName:"Enjin Wallet",hostname:"enjin.io",mobile:{universal:"https://deeplink.wallet.enjin.io/"}},plasma_wallet:{id:"cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e",displayName:"Plasma Wallet",hostname:"plasma-wallet.com",mobile:{universal:"https://plasma-wallet.com"}},avacus:{id:"94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43",displayName:"Avacus",hostname:"avacus.cc",mobile:{universal:"https://avacus.app.link"}},bee:{id:"2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715",displayName:"Bee",hostname:"www.beewallet.app",mobile:{universal:"https://beewallet.app/wc"}},pitaka:{id:"14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc",displayName:"Pitaka",hostname:"pitaka.io",mobile:{universal:"https://app.pitaka.io"}},pltwallet:{id:"576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd",displayName:"PLTwallet",hostname:"pltwallet.io",mobile:{universal:"https://pltwallet.io/"}},minerva:{id:"49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd",displayName:"Minerva",hostname:"minerva.digital",mobile:{universal:"https://minerva.digital"}},kryptogo:{id:"19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b",displayName:"KryptoGO",hostname:"kryptogo.com",mobile:{universal:"https://kryptogo.page.link"}},prema:{id:"5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b",displayName:"PREMA",hostname:"premanft.com",mobile:{universal:"https://premanft.com"}},slingshot:{id:"d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b",displayName:"Slingshot",hostname:"slingshot.finance",mobile:{universal:"https://app.slingshot.finance"}},kriptonio:{id:"50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b",displayName:"Kriptonio",hostname:"kriptonio.com",mobile:{universal:"https://app.kriptonio.com/mobile"}},timeless:{id:"9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8",displayName:"Timeless",hostname:"timelesswallet.xyz",mobile:{universal:"https://timelesswallet.xyz"}},secux:{id:"6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa",displayName:"SecuX",hostname:"secuxtech.com",mobile:{universal:"https://wsweb.secuxtech.com"}},bitizen:{id:"41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071",displayName:"Bitizen",hostname:"bitizen.org",mobile:{universal:"https://bitizen.org/wallet"}},blocto:{id:"14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd",displayName:"Blocto",hostname:"blocto.io",mobile:{universal:"https://blocto.app"}},safemoon:{id:"a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1",displayName:"SafeMoon",hostname:"safemoon.com",mobile:{universal:"https://safemoon.com/wc"}},okx_wallet:{id:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",displayName:"OKX Wallet",hostname:"okx.com",mobile:{native:"okex://main"}},rabby_wallet:{id:"18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1",displayName:"Rabby Wallet",hostname:"rabby.io",mobile:{}}};function ym(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function gm(e,t){let r=ym(t);if(r.deepLink)return Tm(r.deepLink,e);if(r.universalLink)return md(r.universalLink,e);throw new w(`Unsupported wallet ${t.id}`)}function vm(e,t){let r=ym(t);if(r.universalLink)return md(r.universalLink,e)}var Cm="WALLETCONNECT_DEEPLINK_CHOICE";function wm(){try{localStorage.removeItem(Cm)}catch{}}function bm({href:e,name:t}){try{localStorage.setItem(Cm,JSON.stringify({href:e,name:t}))}catch{}}function Em(e){return e.startsWith("http://")||e.startsWith("https://")}function Tm(e,t){if(Em(e))return md(e,t);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function md(e,t){if(!Em(e))return Tm(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function Ms(e,t){window.open(e,t,"noreferrer noopener")}var Le=class{constructor(t){this.promise=null;this.fn=t}execute(t){return this.promise===null&&(this.promise=(async()=>{try{return await this.fn(t)}finally{this.promise=null}})()),this.promise}};var ia=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Le(this._startChannelOnce.bind(this)),this.pollForReady=new Le(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.channelToken)throw new w("Auth flow must be initialized first");try{let t=await this.api.post(xu,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new w("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");try{return await this.api.post(ku,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw le(t)}}async _startChannelOnce(){if(!this.api)throw new w("Auth flow has no API instance");let t=await this.api.post(Au,{token:this.captchaToken});UC&&!FC&&t.connect_uri&&Ms(t.connect_uri,"_blank"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new w("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.channelToken)throw new w("Auth flow must be initialized first");let t=await this.api.get(Ru,{headers:{"farcaster-channel-token":this.meta.channelToken}});return t.state==="completed"?(this.message=t.message,this.signature=t.signature,this.fid=t.fid,!0):!1}};var Sm="1.76.4";var _m="34357d3c125c2bcf2ce2bc3309d98715",Ws="https://auth.privy.io",Pm=2e4,Ne=1400,Os=2500,fd=Sm;var Cn="privy:token",hd="privy-token",Ls="privy:refresh_token",Am="privy-refresh-token",yd="privy:id_token",gd="privy-id-token",Ns="privy-session",aa="privy:session_transfer_token",HC="privy:wallet",sa="privy:caid",la=e=>`privy:cross-app:${e}`,wn="privy:state_code",bn="privy:code_verifier",En="privy:headless_oauth",Ds=e=>`${HC}:${e}`,vd="privy:connectors",Cd="privy:connections";var Tn=12e4,Eo=1,wd="0x1",ni=3e4,xm="https://api.moonpay.com/v1",km="https://api.moonpay.com/v1",Rm="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Im="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";var Mm="deprecated";import{base64url as Lm}from"jose";async function Wm(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function Om(e){return crypto.getRandomValues(new Uint8Array(e))}var GC="S256",VC="S256";function Sn(){return Lm.encode(Om(36))}function ii(){return Sn()}async function ai(e,t=GC){if(t==VC){let r=await Wm(e);return Lm.encode(r)}else return e}function Nm(){let e=Q.get(bn);if(!e)throw new w("Authentication error.");return e}function Us(){return!!Q.get(En)}var Jr=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:Us();this.meta={...t,headless:r}}addCaptchaToken(t){this.meta.captchaToken=t}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");let t=Nm();try{let r=await this.api.post(Gu,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Q.del(bn),this.meta.headless&&Q.del(En),{user:r.user,token:r.token,refresh_token:r.refresh_token,identity_token:r.identity_token,is_new_user:r.is_new_user,oauth_tokens:r.oauth_tokens}}catch(r){let o=le(r);throw o.privyErrorCode?new w(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new w("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new w("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new w("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new w("User denied confirmation during OAuth flow");let t=Q.get(bn);if(!t)throw new w("Authentication error.");try{let r=await this.api.post(Es,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Q.del(bn),r}catch(r){throw le(r)}}async getAuthorizationUrl(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.provider)throw new w("Provider must be set when initializing OAuth authentication.");let t=Sn();Q.put(bn,t);let r=ii();Q.put(wn,r);let o=await ai(t);this.meta.headless&&Q.put(En,!0);try{return await this.api.post(bs,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw le(n)}}};function bd(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{jsx as Dm,jsxs as qC}from"react/jsx-runtime";var Fs=({style:e,...t})=>qC("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...e},...t,children:[Dm("path",{d:"M17.0722 11.6888C17.0471 8.90571 19.3263 7.56847 19.429 7.50274C18.1466 5.60938 16.153 5.35154 15.4417 5.3212C13.7461 5.14678 12.1306 6.32982 11.269 6.32982C10.4074 6.32982 9.08004 5.34648 7.67246 5.37429C5.82158 5.40209 4.11595 6.45874 3.16171 8.13218C1.24068 11.4942 2.6708 16.4817 4.54423 19.2143C5.46091 20.549 6.55041 22.0531 7.98554 21.9975C9.36803 21.9419 9.88905 21.095 11.5571 21.095C13.2251 21.095 13.696 21.9975 15.1537 21.9697C16.6389 21.9393 17.5806 20.6046 18.4897 19.2648C19.5392 17.7153 19.9725 16.2137 19.9975 16.1354C19.965 16.1228 17.1022 15.0155 17.0722 11.6888Z",fill:"currentColor"}),Dm("path",{d:"M14.3295 3.51373C15.0909 2.58347 15.6043 1.28921 15.4641 0C14.3671 0.0455014 13.0396 0.738135 12.2532 1.66838C11.5494 2.48994 10.9307 3.80695 11.0986 5.07089C12.3183 5.16694 13.5681 4.44145 14.3295 3.51373Z",fill:"currentColor"})]});import{jsx as ca,jsxs as zC}from"react/jsx-runtime";var Bs=({style:e,...t})=>zC("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...e},...t,children:[ca("g",{clipPath:"url(#clip0)",children:ca("path",{d:"M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z",fill:"#5865F2"})}),ca("defs",{children:ca("clipPath",{id:"clip0",children:ca("rect",{width:"71",height:"55",fill:"white"})})})]});import{jsx as Um}from"react/jsx-runtime";var Hs=({style:e,...t})=>Um("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...t,children:Um("path",{d:"M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z",fill:"currentColor"})});import{GlobeAltIcon as $C}from"@heroicons/react/24/outline";import{jsx as KC}from"react/jsx-runtime";var Fm=({style:e})=>KC($C,{style:{color:"var(--privy-color-error)",...e}});import{jsx as Gs,jsxs as jC}from"react/jsx-runtime";var Vs=({style:e,...t})=>jC("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...e},...t,children:[Gs("path",{d:"M22.56 12.25C22.56 11.47 22.49 10.72 22.36 10H12V14.255H17.92C17.665 15.63 16.89 16.795 15.725 17.575V20.335H19.28C21.36 18.42 22.56 15.6 22.56 12.25Z",fill:"#4285F4"}),Gs("path",{d:"M12 23C14.97 23 17.46 22.015 19.28 20.335L15.725 17.575C14.74 18.235 13.48 18.625 12 18.625C9.13504 18.625 6.71004 16.69 5.84504 14.09H2.17004V16.94C3.98004 20.535 7.70004 23 12 23Z",fill:"#34A853"}),Gs("path",{d:"M5.845 14.09C5.625 13.43 5.5 12.725 5.5 12C5.5 11.275 5.625 10.57 5.845 9.91V7.06H2.17C1.4 8.59286 0.999321 10.2846 1 12C1 13.775 1.425 15.455 2.17 16.94L5.845 14.09Z",fill:"#FBBC05"}),Gs("path",{d:"M12 5.375C13.615 5.375 15.065 5.93 16.205 7.02L19.36 3.865C17.455 2.09 14.965 1 12 1C7.70004 1 3.98004 3.465 2.17004 7.06L5.84504 9.91C6.71004 7.31 9.13504 5.375 12 5.375Z",fill:"#EA4335"})]});import{jsx as Tr,jsxs as qs}from"react/jsx-runtime";function zs(e){return qs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:26,height:26,viewBox:"0 0 140 140",x:"0px",y:"0px",fill:"none",...e,children:[qs("defs",{children:[qs("linearGradient",{id:"b",children:[Tr("stop",{offset:"0",stopColor:"#3771c8"}),Tr("stop",{stopColor:"#3771c8",offset:".128"}),Tr("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),qs("linearGradient",{id:"a",children:[Tr("stop",{offset:"0",stopColor:"#fd5"}),Tr("stop",{offset:".1",stopColor:"#fd5"}),Tr("stop",{offset:".5",stopColor:"#ff543e"}),Tr("stop",{offset:"1",stopColor:"#c837ab"})]}),Tr("radialGradient",{id:"c",cx:"158.429",cy:"578.088",r:"65",xlinkHref:"#a",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(0 -1.98198 1.8439 0 -1031.402 454.004)",fx:"158.429",fy:"578.088"}),Tr("radialGradient",{id:"d",cx:"147.694",cy:"473.455",r:"65",xlinkHref:"#b",gradientUnits:"userSpaceOnUse",gradientTransform:"matrix(.17394 .86872 -3.5818 .71718 1648.348 -458.493)",fx:"147.694",fy:"473.455"})]}),Tr("path",{fill:"url(#c)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),Tr("path",{fill:"url(#d)",d:"M65.03 0C37.888 0 29.95.028 28.407.156c-5.57.463-9.036 1.34-12.812 3.22-2.91 1.445-5.205 3.12-7.47 5.468C4 13.126 1.5 18.394.595 24.656c-.44 3.04-.568 3.66-.594 19.188-.01 5.176 0 11.988 0 21.125 0 27.12.03 35.05.16 36.59.45 5.42 1.3 8.83 3.1 12.56 3.44 7.14 10.01 12.5 17.75 14.5 2.68.69 5.64 1.07 9.44 1.25 1.61.07 18.02.12 34.44.12 16.42 0 32.84-.02 34.41-.1 4.4-.207 6.955-.55 9.78-1.28 7.79-2.01 14.24-7.29 17.75-14.53 1.765-3.64 2.66-7.18 3.065-12.317.088-1.12.125-18.977.125-36.81 0-17.836-.04-35.66-.128-36.78-.41-5.22-1.305-8.73-3.127-12.44-1.495-3.037-3.155-5.305-5.565-7.624C116.9 4 111.64 1.5 105.372.596 102.335.157 101.73.027 86.19 0H65.03z",transform:"translate(1.004 1)"}),Tr("path",{fill:"#fff",d:"M66.004 18c-13.036 0-14.672.057-19.792.29-5.11.234-8.598 1.043-11.65 2.23-3.157 1.226-5.835 2.866-8.503 5.535-2.67 2.668-4.31 5.346-5.54 8.502-1.19 3.053-2 6.542-2.23 11.65C18.06 51.327 18 52.964 18 66s.058 14.667.29 19.787c.235 5.11 1.044 8.598 2.23 11.65 1.227 3.157 2.867 5.835 5.536 8.503 2.667 2.67 5.345 4.314 8.5 5.54 3.054 1.187 6.543 1.996 11.652 2.23 5.12.233 6.755.29 19.79.29 13.037 0 14.668-.057 19.788-.29 5.11-.234 8.602-1.043 11.656-2.23 3.156-1.226 5.83-2.87 8.497-5.54 2.67-2.668 4.31-5.346 5.54-8.502 1.18-3.053 1.99-6.542 2.23-11.65.23-5.12.29-6.752.29-19.788 0-13.036-.06-14.672-.29-19.792-.24-5.11-1.05-8.598-2.23-11.65-1.23-3.157-2.87-5.835-5.54-8.503-2.67-2.67-5.34-4.31-8.5-5.535-3.06-1.187-6.55-1.996-11.66-2.23-5.12-.233-6.75-.29-19.79-.29zm-4.306 8.65c1.278-.002 2.704 0 4.306 0 12.816 0 14.335.046 19.396.276 4.68.214 7.22.996 8.912 1.653 2.24.87 3.837 1.91 5.516 3.59 1.68 1.68 2.72 3.28 3.592 5.52.657 1.69 1.44 4.23 1.653 8.91.23 5.06.28 6.58.28 19.39s-.05 14.33-.28 19.39c-.214 4.68-.996 7.22-1.653 8.91-.87 2.24-1.912 3.835-3.592 5.514-1.68 1.68-3.275 2.72-5.516 3.59-1.69.66-4.232 1.44-8.912 1.654-5.06.23-6.58.28-19.396.28-12.817 0-14.336-.05-19.396-.28-4.68-.216-7.22-.998-8.913-1.655-2.24-.87-3.84-1.91-5.52-3.59-1.68-1.68-2.72-3.276-3.592-5.517-.657-1.69-1.44-4.23-1.653-8.91-.23-5.06-.276-6.58-.276-19.398s.046-14.33.276-19.39c.214-4.68.996-7.22 1.653-8.912.87-2.24 1.912-3.84 3.592-5.52 1.68-1.68 3.28-2.72 5.52-3.592 1.692-.66 4.233-1.44 8.913-1.655 4.428-.2 6.144-.26 15.09-.27zm29.928 7.97c-3.18 0-5.76 2.577-5.76 5.758 0 3.18 2.58 5.76 5.76 5.76 3.18 0 5.76-2.58 5.76-5.76 0-3.18-2.58-5.76-5.76-5.76zm-25.622 6.73c-13.613 0-24.65 11.037-24.65 24.65 0 13.613 11.037 24.645 24.65 24.645C79.617 90.645 90.65 79.613 90.65 66S79.616 41.35 66.003 41.35zm0 8.65c8.836 0 16 7.163 16 16 0 8.836-7.164 16-16 16-8.837 0-16-7.164-16-16 0-8.837 7.163-16 16-16z"})]})}import{jsx as $s}from"react/jsx-runtime";function Ks({style:e,...t}){return $s("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0,0,256,256",style:{height:"26px",width:"26px",...e},...t,children:$s("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:$s("g",{transform:"scale(5.12,5.12)",children:$s("path",{d:"M41,4h-32c-2.76,0 -5,2.24 -5,5v32c0,2.76 2.24,5 5,5h32c2.76,0 5,-2.24 5,-5v-32c0,-2.76 -2.24,-5 -5,-5zM17,20v19h-6v-19zM11,14.47c0,-1.4 1.2,-2.47 3,-2.47c1.8,0 2.93,1.07 3,2.47c0,1.4 -1.12,2.53 -3,2.53c-1.8,0 -3,-1.13 -3,-2.53zM39,39h-6c0,0 0,-9.26 0,-10c0,-2 -1,-4 -3.5,-4.04h-0.08c-2.42,0 -3.42,2.06 -3.42,4.04c0,0.91 0,10 0,10h-6v-19h6v2.56c0,0 1.93,-2.56 5.81,-2.56c3.97,0 7.19,2.73 7.19,8.26z"})})})})}import{jsx as Bm,jsxs as YC}from"react/jsx-runtime";function js(e){return YC("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...e,children:[Bm("path",{fill:"#1ed760",d:"M248 8C111.1 8 0 119.1 0 256s111.1 248 248 248 248-111.1 248-248S384.9 8 248 8Z"}),Bm("path",{d:"M406.6 231.1c-5.2 0-8.4-1.3-12.9-3.9-71.2-42.5-198.5-52.7-280.9-29.7-3.6 1-8.1 2.6-12.9 2.6-13.2 0-23.3-10.3-23.3-23.6 0-13.6 8.4-21.3 17.4-23.9 35.2-10.3 74.6-15.2 117.5-15.2 73 0 149.5 15.2 205.4 47.8 7.8 4.5 12.9 10.7 12.9 22.6 0 13.6-11 23.3-23.2 23.3zm-31 76.2c-5.2 0-8.7-2.3-12.3-4.2-62.5-37-155.7-51.9-238.6-29.4-4.8 1.3-7.4 2.6-11.9 2.6-10.7 0-19.4-8.7-19.4-19.4s5.2-17.8 15.5-20.7c27.8-7.8 56.2-13.6 97.8-13.6 64.9 0 127.6 16.1 177 45.5 8.1 4.8 11.3 11 11.3 19.7-.1 10.8-8.5 19.5-19.4 19.5zm-26.9 65.6c-4.2 0-6.8-1.3-10.7-3.6-62.4-37.6-135-39.2-206.7-24.5-3.9 1-9 2.6-11.9 2.6-9.7 0-15.8-7.7-15.8-15.8 0-10.3 6.1-15.2 13.6-16.8 81.9-18.1 165.6-16.5 237 26.2 6.1 3.9 9.7 7.4 9.7 16.5s-7.1 15.4-15.2 15.4z"})]})}import{jsx as Ed,jsxs as ZC}from"react/jsx-runtime";function Ys(e){return ZC("svg",{xmlns:"http://www.w3.org/2000/svg",fillRule:"evenodd",clipRule:"evenodd",imageRendering:"optimizeQuality",shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",viewBox:"0 0 293768 333327",width:24,height:24,...e,children:[Ed("path",{fill:"#26f4ee",d:"M204958 0c5369 45832 32829 78170 77253 81022v43471l-287 27V87593c-44424-2850-69965-30183-75333-76015l-47060-1v192819c6791 86790-60835 89368-86703 56462 30342 18977 79608 6642 73766-68039V0h58365zM78515 319644c-26591-5471-50770-21358-64969-44588-34496-56437-3401-148418 96651-157884v54345l-164 27v-40773C17274 145544 7961 245185 33650 286633c9906 15984 26169 27227 44864 33011z"}),Ed("path",{fill:"#fb2c53",d:"M218434 11587c3505 29920 15609 55386 35948 70259-27522-10602-43651-34934-47791-70262l11843 3zm63489 82463c3786 804 7734 1348 11844 1611v51530c-25770 2537-48321-5946-74600-21749l4034 88251c0 28460 106 41467-15166 67648-34260 58734-95927 63376-137628 35401 54529 22502 137077-4810 136916-103049v-96320c26279 15803 48830 24286 74600 21748V94050zm-171890 37247c5390-1122 11048-1985 16998-2548v54345c-21666 3569-35427 10222-41862 22528-20267 38754 5827 69491 35017 74111-33931 5638-73721-28750-49999-74111 6434-12304 18180-18959 39846-22528v-51797zm64479-119719h1808-1808z"}),Ed("path",{d:"M206590 11578c5369 45832 30910 73164 75333 76015v51528c-25770 2539-48321-5945-74600-21748v96320c206 125717-135035 135283-173673 72939-25688-41449-16376-141089 76383-155862v52323c-21666 3569-33412 10224-39846 22528-39762 76035 98926 121273 89342-1225V11577l47060 1z",fill:"#000000"})]})}import{jsx as Hm}from"react/jsx-runtime";var Zs=({style:e,...t})=>Hm("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",width:"24px",...e},...t,children:Hm("path",{d:"M 14.285156 10.171875 L 23.222656 0 L 21.105469 0 L 13.34375 8.832031 L 7.148438 0 L 0 0 L 9.371094 13.355469 L 0 24.019531 L 2.117188 24.019531 L 10.308594 14.691406 L 16.851562 24.019531 L 24 24.019531 M 2.878906 1.5625 L 6.132812 1.5625 L 21.101562 22.535156 L 17.851562 22.535156",fill:"currentColor"})});var Gm={google:{name:"Google",component:Vs},discord:{name:"Discord",component:Bs},github:{name:"Github",component:Hs},linkedin:{name:"LinkedIn",component:Ks},twitter:{name:"Twitter",component:Zs},spotify:{name:"Spotify",component:js},instagram:{name:"Instagram",component:zs},tiktok:{name:"Tiktok",component:Ys},apple:{name:"Apple",component:Fs}},da=e=>e in Gm?Gm[e]:{name:"Unknown",component:Fm};function Vm(e,t){let r={detail:"",retryable:!1},o=bd(t);if(e?.privyErrorCode==="linked_to_another_user"&&(r.detail="This account has already been linked to another user."),e?.privyErrorCode==="invalid_credentials"&&(r.retryable=!0,r.detail="Something went wrong. Try again."),e.privyErrorCode==="oauth_user_denied"&&(r.detail=`Retry and check ${o} to finish connecting your account.`,r.retryable=!0),e?.privyErrorCode==="too_many_requests"&&(r.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="too_many_requests"&&e.message.includes("provider rate limit")){let n=da(t).name;r.detail=`Request limit reached for ${n}. Please wait a moment and try again.`}if(e?.privyErrorCode==="oauth_account_suspended"){let n=da(t).name;r.detail=`Your ${n} account is suspended. Please try another login method.`}return e?.privyErrorCode==="cannot_link_more_of_type"&&(r.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode==="oauth_unexpected"&&t.startsWith("privy:")&&(r.detail="Something went wrong. Please try again."),r}function pa(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),o=e.get("privy_oauth_provider");if(!t||!r||!o)return{inProgress:!1};let n=!1;try{n=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:Us(),popupFlow:window.opener!==null&&n}}function _n(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),Q.del(wn),window.history.replaceState({},"",e)}var Pn=class{constructor(t){this.initAuthenticateOnce=new Le(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Le(this._initLinkOnce.bind(this)),this.meta={captchaToken:t}}async initAuthenticationFlow(){if(!this.api)throw new w("Auth flow has no API instance");this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute()}async initLinkFlow(){if(!this.api)throw new w("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async authenticate(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new w("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new w("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());try{let r=await t.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase(this.meta.initAuthenticateResponse.options)),o=await this.api.post(Zu,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)});return{user:o.user,token:o.token,refresh_token:o.refresh_token,is_new_user:o.is_new_user}}catch(r){throw r.name==="NotAllowedError"?new w("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):le(r)}}async link(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new w("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new w("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let r=this.meta.initLinkResponse.options,o=await t.startRegistration(this._transformInitLinkOptionsToCamelCase(r));return await this.api.post(Yu,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(o)})}catch(r){throw r.name==="NotAllowedError"?new w("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):le(r)}}async _initAuthenticateOnce(){if(!this.api)throw new w("Auth flow has no API instance");return await this.api.post(ju,{token:this.meta.captchaToken})}async _initLinkOnce(){if(!this.api)throw new w("Auth flow has no API instance");return await this.api.post(Ku,{})}_transformInitLinkOptionsToCamelCase(t){return{rp:t.rp,user:{id:t.user.id,name:t.user.name,displayName:t.user.display_name},challenge:t.challenge,pubKeyCredParams:t.pub_key_cred_params.map(r=>({type:r.type,alg:r.alg})),timeout:t.timeout,excludeCredentials:t.exclude_credentials?.map(r=>({id:r.id,type:r.type,transports:r.transports})),authenticatorSelection:{authenticatorAttachment:t.authenticator_selection?.authenticator_attachment,requireResidentKey:t.authenticator_selection?.require_resident_key,residentKey:t.authenticator_selection?.resident_key,userVerification:t.authenticator_selection?.user_verification},attestation:t.attestation,extensions:{appid:t.extensions?.app_id,credProps:t.extensions?.cred_props?.rk,hmacCreateSecret:t.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(t){return{id:t.id,raw_id:t.rawId,response:{client_data_json:t.response.clientDataJSON,attestation_object:t.response.attestationObject,authenticator_data:t.response.authenticatorData},authenticator_attachment:t.authenticatorAttachment,client_extension_results:{app_id:t.clientExtensionResults.appid,cred_props:t.clientExtensionResults.credProps,hmac_create_secret:t.clientExtensionResults.hmacCreateSecret},type:t.type}}_transformInitAuthenticateOptionsToCamelCase(t){return{challenge:t.challenge,allowCredentials:t.allow_credentials?.map(r=>({id:r.id,type:r.type,transports:r.transports}))||[],timeout:t.timeout,extensions:{appid:t.extensions?.app_id,credProps:t.extensions?.cred_props,hmacCreateSecret:t.extensions?.hmac_create_secret},userVerification:t.user_verification}}_transformAuthenticationResponseToSnakeCase(t){return{id:t.id,raw_id:t.rawId,response:{client_data_json:t.response.clientDataJSON,authenticator_data:t.response.authenticatorData,signature:t.response.signature,user_handle:t.response.userHandle},authenticator_attachment:t.authenticatorAttachment,client_extension_results:{app_id:t.clientExtensionResults.appid,cred_props:t.clientExtensionResults.credProps,hmac_create_secret:t.clientExtensionResults.hmacCreateSecret},type:t.type}}};var Qs=({address:e,chainId:t,nonce:r})=>{let o=window.location.host,n=window.location.origin,i="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",a=new Date().toISOString();return`${o} wants you to sign in with your Ethereum account:
2
2
  ${e}
3
3
 
4
4
  ${i}
@@ -9,7 +9,7 @@ Chain ID: ${t}
9
9
  Nonce: ${r}
10
10
  Issued At: ${a}
11
11
  Resources:
12
- - https://privy.io`};var To=class{constructor(t,r,o){this.getNonceOnce=new Le(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=o,this.client=r}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType}}async authenticate(){if(!this.client)throw new w("SiweFlow has no client instance");try{let{message:t,signature:r}=await this.sign(),o=await this.client.authenticateWithSiweInternal({message:t,signature:r,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType});return{user:o.user,token:o.token,refresh_token:o.refresh_token,identity_token:o.identity_token,is_new_user:o.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.client)throw new w("SiweFlow has no client instance");try{let{message:t,signature:r}=await this.sign();return await this.client.linkWithSiweInternal({message:t,signature:r,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw le(t)}}async sign(){if(!this.client)throw new w("SiweFlow has no client instance");if(await this.buildSiweMessage(),!this.preparedMessage)throw new w("Could not prepare SIWE message");let t=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async _getNonceOnce(){if(!this.client)throw new w("SiweFlow has no client instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildSiweMessage(){if(!this.client)throw new w("SiweFlow has no client instance");let t=this.wallet.address,r=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=Qs({address:t,chainId:r,nonce:this.nonce}),this.preparedMessage}};var Do=class{constructor(t,r){this.meta={phoneNumber:t,captchaToken:r}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let t=await this.api.post(Bu,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Uu,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw le(t)}}async sendSmsCode(t,r){if(!this.api)throw new w("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),r&&(this.meta.captchaToken=r),!this.meta.phoneNumber)throw new w("phone nNumber must be set when initialzing authentication.");try{return await this.api.post(Du,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(o){throw le(o)}}},Js=class extends Do{constructor(r,o,n){super(o,n);this.meta={phoneNumber:o,captchaToken:n,oldPhoneNumber:r}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new w("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(Hu,{oldPhoneNumber:this.meta.oldPhoneNumber,newPhoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(r){throw le(r)}}};var si=class{constructor(t){this.meta={captchaToken:t}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");try{let t=await this.api.post(Ju,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");try{return await this.api.post(Xu,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(t){throw le(t)}}};function Td(e){let t={detail:"",retryable:!1};return e?.privyErrorCode==="linked_to_another_user"&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode==="disallowed_login_method"&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode==="invalid_data"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="cannot_link_more_of_type"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="invalid_credentials"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="too_many_requests"&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="too_many_requests"&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),t}function zm(){let e;if(e=QC(),e)return qm(),{...e,flowType:"login-url"};if(e=JC(),e)return qm(),{...e,flowType:"web-app"}}function QC(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),r=e.get("hash"),o=Number(e.get("auth_date")||""),n=e.get("first_name"),i=e.get("last_name")||void 0,a=e.get("username")||void 0,l=e.get("photo_url")||void 0;if(!(!t||!n||!o||!r))return{id:t,first_name:n,last_name:i,username:a,photo_url:l,auth_date:o,hash:r}}function JC(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=new URLSearchParams(decodeURIComponent(e.replace("#tgWebAppData=",""))),r=t.get("query_id"),o=t.get("user"),n=Number(t.get("auth_date")||""),i=t.get("hash");if(!(!r||!o||!n||!i))return{query_id:r,user:o,auth_date:n,hash:i}}function qm(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),window.history.replaceState({},"",e)}import{v4 as j3}from"uuid";function ee(e){return e?new Date(e*1e3):null}function XC(e){let t=[];for(let r of e){let o=r.type;switch(r.type){case"wallet":let n={address:r.address,type:r.type,imported:r.imported,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at),chainType:r.chain_type,chainId:r.chain_id,walletClient:r.wallet_client_type==="privy"?"privy":"unknown",walletClientType:r.wallet_client_type,connectorType:r.connector_type,recoveryMethod:r.recovery_method};t.push(n);break;case"cross_app":let i={type:r.type,subject:r.subject,embeddedWallets:r.embedded_wallets,smartWallets:r.smart_wallets,providerApp:{id:r.provider_app_id},verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(i);break;case"email":let a={address:r.address,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(a);break;case"phone":let l={number:r.phoneNumber,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(l);break;case"google_oauth":let s={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(s);break;case"spotify_oauth":let c={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(c);break;case"instagram_oauth":let m={subject:r.subject,username:r.username,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(m);break;case"twitter_oauth":let f={subject:r.subject,username:r.username,name:r.name,type:r.type,profilePictureUrl:r.profile_picture_url,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(f);break;case"discord_oauth":let u={subject:r.subject,username:r.username,email:r.email,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(u);break;case"github_oauth":let C={subject:r.subject,username:r.username,name:r.name,email:r.email,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(C);break;case"tiktok_oauth":let g={subject:r.subject,username:r.username,name:r.name,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(g);break;case"linkedin_oauth":let y={subject:r.subject,name:r.name,email:r.email,vanityName:r.vanity_name,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(y);break;case"apple_oauth":let b={subject:r.subject,email:r.email,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(b);break;case"custom_auth":t.push({type:r.type,customUserId:r.custom_user_id,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)});break;case"farcaster":let T={type:r.type,fid:r.fid,ownerAddress:r.owner_address,displayName:r.display_name,username:r.username,bio:r.bio,pfp:r.profile_picture_url,url:r.homepage_url,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at),signerPublicKey:r.signer_public_key};t.push(T);break;case"passkey":let k={type:r.type,enrolledInMfa:r.enrolled_in_mfa,credentialId:r.credential_id,authenticatorName:r.authenticator_name,createdWithDevice:r.created_with_device,createdWithOs:r.created_with_os,createdWithBrowser:r.created_with_browser,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(k);break;case"telegram":let S={type:r.type,telegramUserId:r.telegram_user_id,firstName:r.first_name,lastName:r.last_name,username:r.username,photoUrl:r.photo_url,verifiedAt:ee(r.first_verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(S);break;default:console.warn(`Unrecognized account type: ${o}. Please consider upgrading the Privy SDK.`)}}return t}function Vt(e,t){return e.slice().sort((r,o)=>(o.firstVerifiedAt??o.verifiedAt).getTime()-(r.firstVerifiedAt??r.verifiedAt).getTime()).find(r=>r.type===t)}var ge=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&!t.imported&&t.chainType==="ethereum")||null,An=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&!t.imported&&t.chainType==="solana")||null,Xs=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&t.imported&&t.chainType==="ethereum")||null,e3=e=>e.linkedAccounts.filter(t=>t.type==="wallet"),qt=(e,t)=>ge(e)||An(e)?!1:t==="all-users"||t==="users-without-wallets"&&!e3(e)?.length;function zt(e){if(!e)return null;let t=XC(e.linked_accounts),r=Vt(t,"wallet"),o=Vt(t,"email"),n=Vt(t,"phone"),i=Vt(t,"google_oauth"),a=Vt(t,"twitter_oauth"),l=Vt(t,"discord_oauth"),s=Vt(t,"github_oauth"),c=Vt(t,"spotify_oauth"),m=Vt(t,"instagram_oauth"),f=Vt(t,"tiktok_oauth"),u=Vt(t,"linkedin_oauth"),C=Vt(t,"apple_oauth"),g=Vt(t,"farcaster"),y=Vt(t,"telegram"),b=e.mfa_methods.map(({type:k,verified_at:S})=>({type:k,verifiedAt:ee(S)}));return{id:e.id,createdAt:ee(e.created_at),linkedAccounts:t,email:o&&{address:o?.address},phone:n&&{number:n?.number},wallet:r&&{address:r.address,chainType:r.chainType,chainId:r.chainId,walletClient:r.walletClient,walletClientType:r.walletClientType,connectorType:r.connectorType,recoveryMethod:r.recoveryMethod,imported:r.imported},google:i&&{subject:i.subject,email:i.email,name:i.name},twitter:a&&{subject:a.subject,username:a.username,name:a.name,profilePictureUrl:a.profilePictureUrl},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:s&&{subject:s.subject,username:s.username,name:s.name,email:s.email},spotify:c&&{subject:c.subject,email:c.email,name:c.name},instagram:m&&{subject:m.subject,username:m.username},tiktok:f&&{subject:f.subject,username:f.username,name:f.name},linkedin:u&&{subject:u.subject,name:u.name,email:u.email,vanityName:u.vanityName},apple:C&&{subject:C.subject,email:C.email},farcaster:g&&{fid:g.fid,ownerAddress:g.ownerAddress,displayName:g.displayName,username:g.username,bio:g.bio,pfp:g.pfp,url:g.url,signerPublicKey:g.signerPublicKey},telegram:y&&{telegramUserId:y.telegramUserId,firstName:y.firstName,lastName:y.lastName,username:y.username,photoUrl:y.photoUrl},mfaMethods:b.map(k=>k.type),hasAcceptedTerms:e.has_accepted_terms??!1}}import{getAddress as jf}from"@ethersproject/address";import{isHexString as G3}from"@ethersproject/bytes";import V3 from"eventemitter3";import l3 from"@coinbase/wallet-sdk";import{jsx as $m,jsxs as t3}from"react/jsx-runtime";var So=({style:e,...t})=>t3("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[$m("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),$m("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});import{getAddress as eo}from"@ethersproject/address";import{Web3Provider as Jm}from"@ethersproject/providers";import{default as a3}from"eventemitter3";import i3 from"eventemitter3";var r3=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4"],Km=e=>r3.includes(e);import{ErrorCode as o3}from"@ethersproject/logger";import{ProviderErrors as xn}from"@privy-io/js-sdk-core";var li=class extends ce{constructor(){super("Wallet timeout");this.type="wallet_error"}},ci=class extends ce{constructor(){super("User rejected connection");this.type="wallet_error"}},Lr=e=>{if(e instanceof ce)return e;if(e?.code&&e?.reason){let t=new Ct(e);return e.code===o3.ACTION_REJECTED&&(t.details=xn.E4001_USER_REJECTED_REQUEST),t}return e?.code?new Ct(e):new ce("Unknown connector error",e)},Sr=class extends et{constructor(r,o,n){super(r);this.type="provider_error";this.code=o,this.data=n}},Ct=class extends Sr{constructor(r){let o=r;super(o.message,o.code,o.data);let n=Object.values(xn).find(i=>i.eipCode===o.code);this.details=n||xn.UNKNOWN_ERROR,o.code===-32002&&(o.message?.includes("already pending for origin")?o.message?.includes("wallet_requestPermissions")?this.details=xn.E32002_CONNECTION_ALREADY_PENDING:this.details=xn.E32002_REQUEST_ALREADY_PENDING:o.message?.includes("Already processing")&&o.message.includes("eth_requestAccounts")&&(this.details=xn.E32002_WALLET_LOCKED))}},n3={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},_o={...n3,...xn};var je=class{constructor(t,r){this.removeListener=(t,r)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(t,r)}catch{console.warn("Unable to remove wallet provider listener")}};this.walletTimeout=(t=new li,r=this.rpcTimeoutDuration)=>new Promise((o,n)=>setTimeout(()=>{n(t)},r));this.setWalletProvider=t=>{this.walletProvider&&this._subscriptions.forEach(r=>{this.removeListener(r.eventName,r.listener)}),this.walletProvider=t,this._subscriptions.forEach(r=>{this.walletProvider?.on(r.eventName,r.listener)})};this.walletProvider=t,this.rpcTimeoutDuration=r||Tn,this._subscriptions=[]}on(t,r){if(this.walletProvider)return this.walletProvider.on(t,r);this._subscriptions.push({eventName:t,listener:r})}async request(t){if(!this.walletProvider)throw new ce(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),this.walletTimeout()]).catch(r=>{throw Lr(r)})}},Uo=class extends Error{constructor(r,o,n){super(r);this.code=o,this.data=n}},ua=class extends i3{constructor(r,o,n,i,a,l=1){super();this.walletProxy=r,this.address=o,this.chainId=l,this.rpcConfig=n,this.chains=i,this.provider=Gt(l,this.chains,n,{appId:a}),this.rpcTimeoutDuration=di(n,"privy"),this.appId=a}async handleSendTransaction(r){if(!r.params||!Array.isArray(r.params))throw new Uo(`Invalid params for ${r.method}`,4200);let o=r.params[0];if(!await we()||!this.address)throw new Uo("Disconnected",4900);return(await Zm(o)).hash}handleSwitchEthereumChain(r){if(!r.params||!Array.isArray(r.params))throw new Uo(`Invalid params for ${r.method}`,4200);let o;if(typeof r.params[0]=="string")o=r.params[0];else if("chainId"in r.params[0]&&typeof r.params[0].chainId=="string")o=r.params[0].chainId;else throw new Uo(`Invalid params for ${r.method}`,4200);this.chainId=Number(o),this.provider=Gt(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",o)}async handlePersonalSign(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for personal_sign");let o=r.params[0],n=r.params[1];return await jm(o,void 0,n)}async handleSignedTypedData(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for eth_signTypedData_v4");let o=typeof r.params[1]=="string"?JSON.parse(r.params[1]):r.params[1];return await Ym(na(o))}async handleEstimateGas(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for eth_estimateGas");delete r.params[0].gasPrice,delete r.params[0].maxFeePerGas,delete r.params[0].maxPriorityFeePerGas;let o={...r.params[0],chainId:vn(this.chainId)};try{return await this.provider.send("eth_estimateGas",[o])}catch(n){console.warn(`Gas estimation failed with error: ${n}. Retrying gas estimation by omitting the 'from' address`);try{return delete o.from,await this.provider.send("eth_estimateGas",[o])}catch(i){throw console.warn(`Gas estimation failed with error: ${i} when omitting the 'from' address`),n}}}async request(r){switch(console.debug("Embedded1193Provider.request() called with args",r),r.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return vn(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(r);case"eth_sendTransaction":return this.handleSendTransaction(r);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(r);case"personal_sign":return this.handlePersonalSign(r);case"eth_signTypedData_v4":return this.handleSignedTypedData(r);default:break}if(Km(r.method)){let o=await we();if(await Qm(),!o||!this.address)throw new Uo("Disconnected",4900);try{return(await this.walletProxy.rpc({address:this.address,accessToken:o,request:{method:r.method,params:r.params}})).response.data}catch(n){throw console.error(n),new Uo("Disconnected",4900)}}else return this.provider.send(r.method,r.params)}async connect(){let r=await we();if(!r||!this.address)return null;try{return(await this.walletProxy.connect({address:this.address,accessToken:r})).address}catch(o){return console.error(o),null}}},Xr=class extends je{constructor(r){super(r,r.rpcTimeoutDuration)}},Fo=class extends je{constructor(t){super(t,t.rpcTimeoutDuration)}sendAsync(t,r){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var s3=(e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");default:return e.code===4902||e.message?.includes("4902")}},$t=class extends a3{constructor(r,o,n,i){super();this.onAccountsChanged=r=>{r.length===0?this.onDisconnect():this.syncAccounts(r)};this.onChainChanged=r=>{this.wallets.forEach(o=>{o.chainId=oi(r),this.walletClientType==="privy"&&Q.put(Ds(o.address),r)}),this.emit("walletsUpdated")};this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")};this.onConnect=()=>{this.connected=!0,this.syncAccounts()};this.wallets=[],this.walletClientType=r,this.chains=o,this.defaultChain=n,this.rpcConfig=i,this.rpcTimeoutDuration=di(i,r),this.connected=!1,this.initialized=!1}buildConnectedWallet(r,o,n,i){let a=async()=>!!this.wallets.find(l=>eo(l.address)===eo(r));return{address:eo(r),chainId:o,meta:n,imported:i,switchChain:async l=>{if(!a)throw new ce("Wallet is not currently connected.");let s=this.wallets.find(C=>eo(C.address)===eo(r))?.chainId;if(!s)throw new ce("Unable to determine current chainId.");let c,m;if(typeof l=="number"?(c=`0x${l.toString(16)}`,m=l):(c=l,m=Number(l)),s===oi(c))return;let f=this.chains.find(C=>C.id===m);if(!f)throw new ce(`Unsupported chainId: ${l}`);let u=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:c}]})};try{return await u()}catch(C){if(s3(C,this.walletClientType))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:c,chainName:f.name,nativeCurrency:f.nativeCurrency,rpcUrls:[f.rpcUrls.default?.http[0]??""],blockExplorerUrls:[f.blockExplorers?.default.url??""]}]}),u();throw this.walletClientType==="rainbow"&&C.message?.includes("wallet_switchEthereumChain")?new ce(`Rainbow does not support the chainId ${o}`):C}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:a,getEthereumProvider:async()=>{if(!await a())throw new ce("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await a())throw new ce("Wallet is not currently connected.");return new Jm(new Xr(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await a())throw new ce("Wallet is not currently connected.");return new Fo(this.proxyProvider)},sign:async l=>{if(!await a())throw new ce("Wallet is not currently connected.");return await this.sign(l)},disconnect:()=>{this.disconnect()}}}async syncAccounts(r){let o=r;try{if(o===void 0){let c=await oa(()=>this.proxyProvider.request({method:"eth_accounts"}),{maxAttempts:10,delayMs:500});Array.isArray(c)&&(o=c)}}catch(c){console.warn("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",c)}if(!o||!Array.isArray(o)||o.length<=0||!o[0])return;let n=o[0],i=eo(n),a=[],l;if(this.walletClientType==="privy"){let c=Q.get(Ds(i));this.chains.find(m=>m.id===Number(c))||(Q.del(Ds(i)),c=null),l=c||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:l}]})}catch{console.warn(`Unable to switch embedded wallet to chain ID ${l} on initialization`)}}else try{let c=await oa(()=>this.proxyProvider.request({method:"eth_chainId"}),{maxAttempts:10,delayMs:500});if(typeof c=="string")l=c;else if(typeof c=="number")l=`0x${c.toString(16)}`;else throw new Error("Invalid chainId returned from provider")}catch(c){console.warn(`Failed to get chainId from provider, defaulting to ${wd}`,c),l=wd}let s=oi(l);if(!a.find(c=>eo(c.address)===i)){let c={name:this.walletBranding.name,icon:typeof this.walletBranding.icon=="string"?this.walletBranding.icon:void 0,id:this.walletBranding.id};a.push(this.buildConnectedWallet(eo(n),s,c,this.connectorType==="embedded_imported"))}el(a,this.wallets)||(this.wallets=a,this.emit("walletsUpdated"))}async getConnectedWallet(){let r=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort((o,n)=>n.connectedAt-o.connectedAt).find(o=>r.find(n=>eo(n)===eo(o.address)))||null}async isConnected(){let r=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(r)&&r.length>0}async sign(r){return await this.connect({showPrompt:!1}),new Jm(new Xr(this.proxyProvider)).getSigner().signMessage(r)}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}};var c3=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],d3=(e,t)=>e.makeWeb3Provider({options:t}),Sd,tl=class extends $t{constructor(r,o,n,i,a,l){super("coinbase_wallet",r,o,n);this.connectorType="coinbase_wallet";this.displayName="Coinbase Wallet";if(this.proxyProvider=new je(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=i.coinbaseWallet.connectionOptions??"all",this.walletClientType=this.connectionOptions==="smartWalletOnly"?"coinbase_smart_wallet":"coinbase_wallet",this.walletClientType==="coinbase_smart_wallet"&&(this.displayName="Coinbase Smart Wallet"),!Sd){let s=[o.id].concat(r.map(m=>m.id)),c=this.connectionOptions!=="eoaOnly"?s.filter(m=>!c3.includes(m)):[];c.length>0&&console.warn(`The following configured chains are not supported by the Coinbase Smart Wallet: ${c.join(", ")}`),Sd=new l3({appName:a,appLogoUrl:l,appChainIds:s})}this.proxyProvider.setWalletProvider(d3(Sd,this.connectionOptions))}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:So,id:"com.coinbase.wallet"}}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new ce("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([r[0]])}catch(r){throw Lr(r)}}};import{jsx as Xm}from"react/jsx-runtime";var Bo=({...e})=>Xm("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:Xm("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:e.color||"var(--privy-color-foreground-3)"})});var ma=class extends $t{constructor(r,o,n,i,a=!1){super("privy",o,n,i);this.connectorType="embedded";this.proxyProvider=r,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[vn(r?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Bo,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}};import{jsx as ef}from"react/jsx-runtime";var pi=({style:e,...t})=>ef("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...e},...t,children:ef("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})});import{jsx as nr,jsxs as p3}from"react/jsx-runtime";var ui=({style:e,...t})=>p3("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...e},...t,children:[nr("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),nr("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),nr("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),nr("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),nr("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),nr("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),nr("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),nr("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),nr("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),nr("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),nr("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),nr("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),nr("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]});import{jsx as tf,jsxs as u3}from"react/jsx-runtime";var to=({style:e,...t})=>u3("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...e},...t,children:[tf("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),tf("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});var fi=class extends $t{constructor(r,o,n,i,a){super(a||"unknown",r,o,n);this.connectorType="injected";this.proxyProvider=new je(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=i;let l=i.provider;this.proxyProvider.setWalletProvider(l)}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new ce("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw Lr(r)}}},mi,hi=class extends $t{constructor(r,o,n,i,a){super(a??"unknown",r,o,n);this.connectorType="injected";hs(this,mi,void 0);this.proxyProvider=new je(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(i),a==="metamask"?sd(this,mi,{name:"MetaMask",icon:ui,id:"io.metamask"}):a==="phantom"&&sd(this,mi,{name:"Phantom",icon:to,id:"phantom"})}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return wu(this,mi)??{name:"Browser Extension",icon:pi,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new ce("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw Lr(r)}}};mi=new WeakMap;import{getAddress as ak}from"@ethersproject/address";import{Web3Provider as lk}from"@ethersproject/providers";import{isMobile as m3}from"react-device-detect";var rl=class extends fi{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{m3||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let t=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!t||t.length===0||!t[0])throw new ce("Unable to retrieve accounts");await this.syncAccounts([t[0]])}catch(t){throw Lr(t)}}};var ol=class extends $t{constructor(r,o){super(r,[],o,{});this.connectorType="null";this.proxyProvider=new je(void 0,Tn);this.connectorType=r}get walletBranding(){return{name:"Wallet",id:""}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw new Error("connect called for an uninstalled wallet via the NullConnector")}disconnect(){throw new Error("disconnect called for an uninstalled wallet via the NullConnector")}promptConnection(r){throw new Error(`promptConnection called for an uninstalled wallet via the NullConnector for ${r}`)}};var nl=class extends ol{constructor(t){super("phantom",t)}get walletBranding(){return{name:"Phantom",icon:to,id:"phantom"}}};import{EthereumProvider as U3,OPTIONAL_EVENTS as F3,OPTIONAL_METHODS as B3}from"@walletconnect/ethereum-provider";import{isMobile as H3}from"react-device-detect";import{createContext as R3,useContext as I3,useEffect as xd,useRef as M3,useState as W3}from"react";import{jsx as f3}from"react/jsx-runtime";function rf({src:e,...t}){return f3("img",{src:e,...t,style:{display:"none"}})}import{useContext as Vf,useEffect as Gf,useMemo as P3,useState as A3}from"react";import{createContext as x3}from"react";var Ot={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:_m,rpcConfig:{rpcUrls:{},rpcTimeouts:{}},externalWallets:{coinbaseWallet:{connectionOptions:"all"}},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};var of=({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],r=[];e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`");for(let o of e.primary.slice(1))t.includes(o)?console.warn(`Duplicated login method: ${o}`):t.push(o);for(let o of e.overflow??[])!t.includes(o)&&!r.includes(o)?r.push(o):console.warn(`Duplicated login method: ${o}`);return{primary:t,overflow:r}};var h3=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","wallet_connect","detected_wallets","rabby_wallet"]),nf=e=>h3.has(e),af=(e,t,r)=>r.indexOf(e)===t,sf=({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(nf).filter(af):e?e.filter(nf).filter(af):Ot.appearance.walletList;var lf={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-mainnet.rpc.privy.systems"]},alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var cf={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{default:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var df={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0};var pf={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}};var uf={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0};var mf={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-mainnet.rpc.privy.systems"]},blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var ff={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://goerli.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var hf={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0};var yf={id:80085,network:"berachain-artio",name:"Berachain Artio",nativeCurrency:{name:"BERA",symbol:"BERA",decimals:18},rpcUrls:{default:{http:["https://berachain-artio.rpc.privy.systems"]},public:{http:["https://berachain-artio.rpc.privy.systems"]}},blockExplorers:{default:{name:"Beratrail",url:"https://artio.beratrail.io"}},testnet:!0};var gf={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1};var vf={id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0};var Cf={id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}};var wf={id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}};var bf={id:17069,name:"Garnet Holesky",network:"garnet-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.garnetchain.com"]},public:{http:["https://rpc.garnetchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.garnetchain.com"}}};var Ef={id:5,network:"goerli",name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.etherscan.io"}},testnet:!0};var Tf={id:17e3,name:"Holesky",network:"holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://ethereum-holesky.publicnode.com"]},public:{http:["https://ethereum-holesky.publicnode.com"]}},blockExplorers:{etherscan:{name:"EtherScan",url:"https://holesky.etherscan.io"},default:{name:"EtherScan",url:"https://holesky.etherscan.io"}}};var Sf={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1};var _f={id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0};var Pf={id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network"}}};var il={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://mainnet.rpc.privy.systems"]},alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}};var Af={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-mainnet.rpc.privy.systems"]},alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var xf={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://goerli.optimism.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var kf={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0};var Rf={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{privy:{http:["https://polygon-mainnet.rpc.privy.systems"]},alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var If={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{default:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var Mf={id:690,name:"Redstone",network:"redstone",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.redstonechain.com"]},public:{http:["https://rpc.redstonechain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.redstone.xyz/"}}};var Wf={id:17001,name:"Redstone Holesky",network:"redstone-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.holesky.redstone.xyz"]},public:{http:["https://rpc.holesky.redstone.xyz"]}},blockExplorers:{etherscan:{name:"EtherScan",url:"https://explorer.holesky.redstone.xyz"},default:{name:"EtherScan",url:"https://explorer.holesky.redstone.xyz"}}};var Of={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{privy:{http:["https://sepolia.rpc.privy.systems"]},alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0};var Lf={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}};var Nf={id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0};var Df={id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0};var fa=[lf,cf,df,Ef,Of,il,Af,xf,kf,Rf,If,gf,vf,Cf,wf,mf,ff,hf,yf,Pf,Sf,_f,pf,uf,Lf,Df,Nf,Tf,Mf,bf,Wf],NR=new Set(fa.map(e=>e.id));import kn from"tinycolor2";var Uf="#FFFFFF",y3="#040217",g3=Uf,v3="#1E1E1D";function C3(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function Nr(e,t){let r=Math.max(0,Math.min(1,e.toHsl().l+t));return kn({...e.toHsl(),l:r})}var w3="#51BA81",b3="#FFB74D",E3="#EC6351",T3=Uf,S3=y3;function Ff({backgroundTheme:e,accentHex:t}){let r;switch(e){case"light":r=g3;break;case"dark":r=v3;break;default:r=e;break}let o=kn(r),n=kn(t),i=kn(w3),a=kn(b3),l=kn(E3),s=C3(o.getLuminance()),c=Nr(o,s==="light"?-.04:.11),m=Nr(o,s==="light"?-.88:.87),f=Nr(o,s==="light"?-.7:.75),u=Nr(o,s==="light"?-.43:.45).desaturate(s==="light"?60:20),C=Nr(o,s==="light"?-.08:.25).desaturate(s==="light"?60:20),g=Nr(n,.15),y=Nr(n,-.06),b=Nr(l,.3),T=Nr(a,.3),k=kn(n.getLuminance()>.5?S3:T3),S=Nr(i,-.16),x=Nr(i,.4);return{colorScheme:s,background:o.toHslString(),background2:c.toHslString(),foreground:m.toHslString(),foreground2:f.toHslString(),foreground3:u.toHslString(),foreground4:C.toHslString(),accent:n.toHslString(),accentLight:g.toHslString(),accentDark:y.toHslString(),foregroundAccent:k.toHslString(),success:i.toHslString(),successDark:S.toHslString(),successLight:x.toHslString(),error:l.toHslString(),errorLight:b.toHslString(),warn:a.toHslString(),warnLight:T.toHslString()}}function _d(e,t,r){let o=r?console.warn:()=>{},n,i,a,l,s,c,m,f,u,C,g,y,b,T,k;t?.loginMethods?(n=t.loginMethods.includes("email"),i=t.loginMethods.includes("sms"),l=t.loginMethods.includes("wallet"),s=t.loginMethods.includes("google"),c=t.loginMethods.includes("twitter"),m=t.loginMethods.includes("discord"),u=t.loginMethods.includes("spotify"),C=t.loginMethods.includes("instagram"),f=t.loginMethods.includes("tiktok"),y=t.loginMethods.includes("github"),g=t.loginMethods.includes("linkedin"),b=t.loginMethods.includes("apple"),T=t.loginMethods.includes("farcaster"),k=t.loginMethods.includes("telegram")):(n=e.emailAuth,i=e.smsAuth,l=e.walletAuth,s=e.googleOAuth,c=e.twitterOAuth,m=e.discordOAuth,y=e.githubOAuth,u=e.spotifyOAuth,C=e.instagramOAuth,f=e.tiktokOAuth,g=e.linkedinOAuth,b=e.appleOAuth,T=e.farcasterAuth,k=e.telegramAuth),typeof window<"u"&&typeof window.PublicKeyCredential!="function"?a=!1:e.passkeyAuth&&(a=!0);let S=[n,i].filter(Boolean),x=[s,c,m,y,u,C,f,g,b,T,k].filter(Boolean),R=[l].filter(Boolean);if(S.length+x.length+R.length===0)throw new Error("You must enable at least one login method");let I=t?.appearance?.showWalletLoginFirst!==void 0?t?.appearance?.showWalletLoginFirst:e.showWalletLoginFirst;I&&R.length===0?(o("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),I=!1):!I&&x.length+S.length===0&&(o("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),I=!0);let D=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&o("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let H=sf({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),K=of({input:t?.loginMethodsAndOrder}),j=t?.intl?.defaultCountry??"US",{chains:O,defaultChain:U}=_3({additionalChains:t?.additionalChains,supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain,hasRpcConfigDefined:Object.keys(t?.rpcConfig?.rpcUrls??{}).length>0}),W=!!t?.defaultChain,Ce=t?.customAuth?.getCustomAccessToken&&t?.customAuth?.enabled!==!1,Ie,Y=!(e.enforceWalletUis??!0);if(e.legacyWalletUiConfig??!0?Ce?Ie=t?.embeddedWallets?.noPromptOnSignature??!0:Ie=t?.embeddedWallets?.noPromptOnSignature??Y:Ie=Y,t?.embeddedWallets?.waitForTransactionConfirmation===!1&&Ie!==!0)throw new Error("Overriding `config.embeddedWallets.waitForTransactionConfirmation` requires that you disable wallet UIs in the dashboard.");let{requireUserPasswordOnCreate:X,...te}=t?.embeddedWallets??{};return{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,legacyWalletUiConfig:e.legacyWalletUiConfig,appearance:{logo:t?.appearance?.logo??e.logoUrl,landingHeader:t?.appearance?.landingHeader??Ot.appearance.landingHeader,loginMessage:typeof t?.appearance?.loginMessage=="string"?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,palette:Ff({backgroundTheme:t?.appearance?.theme??Ot.appearance.theme,accentHex:t?.appearance?.accentColor??e.accentColor??Ot.appearance.accentColor}),loginGroupPriority:I?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:H},loginMethods:{wallet:l,email:n,sms:i,passkey:a,google:s,twitter:c,discord:m,github:y,spotify:u,instagram:C,tiktok:f,linkedin:g,apple:b,farcaster:T,telegram:k},loginMethodsAndOrder:K,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.termsAndConditionsUrl,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacyPolicyUrl,requireUsersAcceptTerms:e.requireUsersAcceptTerms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.walletConnectCloudProjectId??Ot.walletConnectCloudProjectId,rpcConfig:{rpcUrls:t?.rpcConfig?.rpcUrls??Ot.rpcConfig.rpcUrls,rpcTimeouts:t?.rpcConfig?.rpcTimeouts??Ot.rpcConfig.rpcTimeouts},chains:O,defaultChain:U,intl:{defaultCountry:j},shouldEnforceDefaultChainOnConnect:W,captchaEnabled:e.captchaEnabled??Ot.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??Ot.externalWallets.coinbaseWallet.connectionOptions},walletConnect:{enabled:D}},embeddedWallets:{...e.embeddedWalletConfig,...typeof X=="boolean"?{requireUserOwnedRecoveryOnCreate:X}:{},...Ce?{createOnLogin:"all-users",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]}:{},waitForTransactionConfirmation:!0,priceDisplay:{primary:"fiat-currency",secondary:"native-token"},...te,noPromptOnSignature:Ie},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},customAuth:Ce?{enabled:!0,...t.customAuth}:void 0,loginConfig:{twitterOAuthOnMobileEnabled:e.twitterOAuthOnMobileEnabled??!1,telegramAuthConfiguration:e.telegramAuthConfiguration},headless:!!t?.headless,render:{standalone:t?._render?.standalone??Ot._render.standalone},fundingConfig:e.fundingConfig,fundingMethodConfig:{...t?.fundingMethodConfig??Ot.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??Ot.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??Ot.fundingMethodConfig.moonpay.useSandbox}}}}function Bf(e,t){if(!e)return{legacyCreateEmbeddedWalletFlag:t};let{appearance:r,additionalChains:o,supportedChains:n,defaultChain:i,...a}=e;return{...a,...o?{additionalChains:o.map(s=>s.id)}:void 0,...n?{supportedChains:n.map(s=>s.id)}:void 0,...i?{defaultChain:i.id}:void 0,legacyCreateEmbeddedWalletFlag:t}}function _3({additionalChains:e,supportedChains:t,defaultChainFromConfig:r,hasRpcConfigDefined:o}){let n;if(e&&t&&console.warn("You should only specify one of `additionalChains` or `supportedChains`. Using `supportedChains`."),t){if(t.length===0)throw new Error("`supportedChains` must contain at least one chain");t.filter(s=>s.rpcUrls.privyWalletOverride).length>0&&o&&console.warn("You have specified at least one `supportedChain` with `privyWalletOverride` but also have `rpcConfig` defined. The `rpcConfig` will be ignored. `rpcConfig` is deprecated and you should use `privyWalletOverride` in a `supportedChain`."),n=t.map(s=>s.rpcUrls.privyWalletOverride?s:fa.find(m=>m.id===s.id)??s)}else n=fa.concat(e??[]);let i=t?n[0]:il,a=r??i;if(!n.find(l=>l.id===a.id))throw new Error("`defaultChain` must be included in `supportedChains`");return{chains:n,defaultChain:a}}var Hf=function(e,t=0){let r=3735928559^t,o=1103547991^t;for(let n=0,i;n<e.length;n++)i=e.charCodeAt(n),r=Math.imul(r^i,2654435761),o=Math.imul(o^i,1597334677);return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(o^o>>>13,3266489909),o=Math.imul(o^o>>>16,2246822507),o^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&o)+(r>>>0)};import{jsx as k3}from"react/jsx-runtime";var qf={showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,linkedinOAuth:!1,appleOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]},fiatOnRampEnabled:!1,captchaEnabled:!1,captchaSiteKey:""},Pd=_d(qf,void 0,!1),Ad=x3({appConfig:Pd,isServerConfigLoaded:!1}),zf=({children:e,legacyCreateEmbeddedWalletFlag:t,client:r,clientConfig:o})=>{let[n,i]=A3(null),a=P3(()=>_d(n??qf,o,!!n),[n,o]);return Gf(()=>{if(!n)return;let l=Bf(o,t),s=Hf(JSON.stringify(l)).toString(),c=`privy:sent:${n.id}:${s}`;localStorage.getItem(c)||(r.createAnalyticsEvent({eventName:"sdk_initialize",payload:l}),localStorage.setItem(c,"t"))},[o,t,n]),Gf(()=>{n||(async()=>{try{let s=await r.getServerConfig();s.customApiUrl&&r.updateApiUrl(s.customApiUrl),i(s)}catch(s){console.warn("Error generating app config: ",s)}})()},[]),k3(Ad.Provider,{value:{appConfig:a,isServerConfigLoaded:!!n},children:e})},Ve=()=>{let{appConfig:e}=Vf(Ad);return e},al=()=>{let{isServerConfigLoaded:e}=Vf(Ad);return e};var E=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import{jsx as L3,jsxs as N3}from"react/jsx-runtime";var $f=R3({ready:!1,app:Pd,currentScreen:null,lastScreen:null,navigate:E,navigateBack:E,resetNavigation:E,setModalData:E,onUserCloseViaDialogOrKeybindRef:void 0}),O3=["LANDING","CONNECT_ONLY_LANDING_SCREEN",null],Kf=e=>{let t=Ve(),r=e.authenticated,[o,n]=W3(e.initialScreen);xd(()=>{!r&&!O3.includes(e.initialScreen)&&e.setInitialScreen(null)},[r]);let i=M3(null);xd(()=>{e.open||(i.current=null)},[e.open]),xd(()=>{i.current=null},[e.initialScreen]);let a={ready:!!t.id,app:t,data:e.data,setModalData:e.setModalData,currentScreen:e.initialScreen,lastScreen:o,navigate:(l,s=!0)=>{e.setInitialScreen(l),s&&n(e.initialScreen)},navigateBack:()=>{e.setInitialScreen(o)},resetNavigation:()=>{e.setInitialScreen(null),n(null)},onUserCloseViaDialogOrKeybindRef:i};return N3($f.Provider,{value:a,children:[(typeof t.appearance.logo=="string"||t.appearance.logo?.type==="img")&&L3(rf,{src:typeof t.appearance.logo=="string"?t.appearance.logo:t.appearance.logo.props.src}),e.children]})},_=()=>I3($f);import{jsx as yi,jsxs as D3}from"react/jsx-runtime";var ha=({style:e,...t})=>{let{app:r}=_();return D3("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[yi("rect",{width:"28",height:"28",rx:"3",fill:r?.appearance.palette.colorScheme==="dark"?"#3396ff":"#141414"}),yi("g",{clipPath:"url(#clip0_1765_9946)",children:yi("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),yi("defs",{children:yi("clipPath",{id:"clip0_1765_9946",children:yi("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};var Dr=class extends $t{constructor(r,o,n,i,a,l,s,c){super(c||"unknown",n,i,o);this.connectorType="wallet_connect_v2";this.privyAppId=l,this.privyAppName=s,this.walletConnectCloudProjectId=r,this.rpcConfig=o,this.shouldEnforceDefaultChainOnConnect=a,this.proxyProvider=new je(void 0,this.rpcTimeoutDuration),c&&(this.walletEntry=Is[c],this.walletClientType=c)}async initialize(){let r=await this.createProvider();if(this.provider=r,this.proxyProvider.setWalletProvider(r),this.subscribeListeners(),r.session){if(this.walletProvider?.session?.peer.metadata.url){let n=Rs(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=n?.entry,this.walletClientType=n?.walletClientType||"unknown"}this.connected=!0,await this.syncAccounts()}this.initialized=!0,this.emit("initialized");let{WalletConnectModal:o}=await import("@walletconnect/modal");this.modal=new o({projectId:this.walletConnectCloudProjectId,themeVariables:{"--wcm-z-index":"1000000"}}),this.modal.subscribeModal(n=>{!n.open&&!this.walletProvider?.session&&this.onQrModalClosed&&this.onQrModalClosed()})}async connect(r){return r.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){return this.walletClientType==="metamask"?{name:"MetaMask",icon:ui,id:"io.metamask"}:{name:um(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:this.walletProvider?.session?.peer.metadata.icons?.[0]||ha,id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(r){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletEntry=Is[r],this.walletClientType=r,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,wm(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise((r,o)=>{let n=()=>{o(new ci)};this.onQrModalClosed=n,(async()=>{let a="",l=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(l?.length&&(a=l[0]),!a||a==="")throw new ce("Unable to retrieve address");if(this.walletProvider?.session?.peer.metadata.url){let s=Rs(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=s?.entry,this.walletClientType=s?.walletClientType||"unknown",this.proxyProvider.rpcTimeoutDuration=di(this.rpcConfig,this.walletClientType)}this.connected=!0,await this.syncAccounts(l),r()})().catch(a=>{if(a){o(Lr(a));return}o(new ce("Unknown error during connection"))}).finally(()=>this.modal?.closeModal())})}disconnect(){this.walletProvider?.disconnect().then(()=>this.onDisconnect()).catch(()=>console.warn("Unable to disconnect Wallet Connect provider"))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(r){this.proxyProvider.setWalletProvider(r)}async createProvider(){let r={};for(let a of this.chains){let l=fm(a.id,this.chains,this.rpcConfig,this.privyAppId);l&&(r[a.id]=l)}let o=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],n=this.chains.map(a=>a.id),i=await U3.init({projectId:this.walletConnectCloudProjectId,chains:o,optionalChains:n,optionalEvents:F3,optionalMethods:B3,rpcMap:r,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.toString(),icons:[]}});return i.on("display_uri",a=>{if(i.signer.abortPairingAttempt(),H3&&this.walletEntry){let{redirect:l,href:s}=gm(a,this.walletEntry);bm({href:s,name:this.walletEntry.displayName}),this.redirectUri=l;let c=vm(a,this.walletEntry);c?.redirect&&(this.fallbackUniversalRedirectUri=c.redirect),Ms(l,"_self")}else this.modal?.openModal({uri:a,chains:[this.defaultChain.id]})}),i.on("connect",()=>{if(this.modal?.closeModal(),i.session?.peer.metadata.url){let a=Rs(i.session?.peer.metadata.url);this.walletEntry=a?.entry,this.walletClientType=a?.walletClientType||"unknown"}}),i}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider?.enable()}};var Rd=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses")?.split(" ").filter(o=>G3(o)).map(o=>jf(o));return t?.length?!!e?.linkedAccounts.filter(o=>o.type=="wallet"&&t.includes(o.address)).length:!1},di=(e,t)=>e.rpcTimeouts?e.rpcTimeouts[t]||Tn:Tn,ya=class extends V3{constructor(r,o,n,i,a,l,s,c,m,f,u){super();this.getEthereumProvider=()=>{let r=this.wallets[0],o=this.walletConnectors.find(n=>n.wallets.find(i=>i.address===r?.address));return!r||!o?new je:o.proxyProvider};this.privyAppId=r,this.walletConnectCloudProjectId=o,this.rpcConfig=n,this.chains=i,this.defaultChain=a,this.walletConnectors=[],this.initialized=!1,this.store=l,this.walletList=s,this.shouldEnforceDefaultChainOnConnect=c,this.externalWalletConfig=m,this.privyAppName=f,this.privyAppLogo=u,this.storedConnections=kd()}get wallets(){let r=new Set,o=this.walletConnectors.flatMap(i=>i.wallets).sort((i,a)=>i.connectedAt&&a.connectedAt?a.connectedAt-i.connectedAt:0).filter(i=>{let a=`${i.address}${i.walletClientType}${i.connectorType}`;return r.has(a)?!1:(r.add(a),!0)}),n=o.findIndex(i=>i.address===(this.activeWallet?this.activeWallet:"unknown"));return n>=0&&o.unshift(o.splice(n,1)[0]),o}async initialize(){if(this.initialized)return;Q.get(vd)&&(Q.getKeys().forEach(o=>{o.startsWith("walletconnect")&&Q.del(o)}),Q.del(vd));let r=mm(this.store,this.walletList,this.externalWalletConfig).then(o=>{o.forEach(({type:n,eip6963InjectedProvider:i,legacyInjectedProvider:a})=>{this.createWalletConnector("injected",n,{eip6963InjectedProvider:i,legacyInjectedProvider:a})})});this.walletList.includes("coinbase_wallet")&&this.createWalletConnector("coinbase_wallet","coinbase_wallet"),!No()&&this.walletList.includes("phantom")&&this.createWalletConnector("phantom","phantom"),this.externalWalletConfig.walletConnect.enabled&&this.createWalletConnector("wallet_connect_v2","unknown"),await r,this.initialized=!0}findWalletConnector(r,o){return r==="wallet_connect_v2"?this.walletConnectors.find(n=>n.connectorType===r)??null:this.walletConnectors.find(n=>n.connectorType===r&&n.walletClientType===o)??null}onInitialized(r){r.wallets.forEach(o=>{let n=this.storedConnections.find(i=>i.address===o.address&&i.connectorType===o.connectorType&&i.walletClientType===o.walletClientType);n&&(o.connectedAt=n.connectedAt)}),this.saveConnectionHistory(),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(r){r.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnector(r,o,n,i){let a=this.findWalletConnector("embedded","privy");if(a)a.proxyProvider.walletProxy=r;else{let l=new ua(r,o,this.rpcConfig,this.chains,i,n.id),s=new ma(l,this.chains,n,this.rpcConfig);this.addWalletConnector(s)}}addImportedWalletConnector(r,o,n,i){let a=this.findWalletConnector("embedded_imported","privy");if(a)a.proxyProvider.walletProxy=r;else{let l=new ua(r,o,this.rpcConfig,this.chains,i,n.id),s=!0,c=new ma(l,this.chains,n,this.rpcConfig,s);this.addWalletConnector(c)}}removeEmbeddedWalletConnector(){let r=this.findWalletConnector("embedded","privy");if(r){let o=this.walletConnectors.indexOf(r);this.walletConnectors.splice(o,1),this.saveConnectionHistory(),this.storedConnections=kd(),this.emit("walletsUpdated")}}removeImportedWalletConnector(){let r=this.findWalletConnector("embedded_imported","privy");if(r){let o=this.walletConnectors.indexOf(r);this.walletConnectors.splice(o,1),this.saveConnectionHistory(),this.storedConnections=kd(),this.emit("walletsUpdated")}}async createWalletConnector(r,o,n){let i=this.findWalletConnector(r,o);if(i)return i instanceof Dr&&i.resetConnection(o),i;let l=(()=>{if(r==="injected"){if(o==="metamask"&&n?.eip6963InjectedProvider)return new rl(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask");if(o==="metamask"&&n?.legacyInjectedProvider)return new hi(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask");if(o==="phantom"&&n?.legacyInjectedProvider)return new hi(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom");if(n?.legacyInjectedProvider&&o==="unknown_browser_extension")return new hi(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider);if(n?.eip6963InjectedProvider)return new fi(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,o)}else return r==="coinbase_wallet"?new tl(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):r==="phantom"?new nl(this.defaultChain):new Dr(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,this.privyAppName,o)})();return l&&this.addWalletConnector(l),l||null}addWalletConnector(r){this.walletConnectors.push(r),r.on("initialized",()=>this.onInitialized(r)),r.on("walletsUpdated",()=>this.onWalletsUpdated(r)),r.initialize().catch(o=>{console.debug("Failed to initialize connector",o)})}saveConnectionHistory(){let r=this.wallets.map(o=>({address:o.address,connectorType:o.connectorType,walletClientType:o.walletClientType,connectedAt:o.connectedAt}));Q.put(Cd,r)}async activeWalletSign(r){let o=this.wallets,n=o.length>0?o[0]:null;return n?n.sign(r):null}setActiveWallet(r){this.activeWallet=jf(r),this.emit("walletsUpdated")}};function el(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let o=e[r],n=t[r];if(o?.address!==n?.address||o?.chainId!==n?.chainId||o?.connectorType!==n?.connectorType||o?.connectedAt!==n?.connectedAt||o?.walletClientType!==n?.walletClientType||o?.isConnected!==n?.isConnected||o?.linked!==n?.linked)return!1}return!0}var q3=e=>e&&typeof e.address=="string"&&typeof e.connectorType=="string"&&typeof e.walletClientType=="string"&&typeof e.connectedAt=="number",kd=()=>{let e=Q.get(Cd);return e&&Array.isArray(e)&&e.map(o=>q3(o)).every(Boolean)?e:[]};import{ofetch as z3}from"ofetch";var $3=[vs,ws,Cs,Ts],sl=class{constructor({appId:t,appClientId:r,client:o,defaults:n}){this.appId=t,this.appClientId=r,this.clientAnalyticsId=o.clientAnalyticsId,this.sdkVersion=fd,this.client=o,this.defaults=n,this.fallbackApiUrl=o.fallbackApiUrl,this.baseFetch=z3.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:i,options:a})=>{let l=new Headers(a.headers);l.set("privy-app-id",this.appId),this.appClientId&&l.set("privy-client-id",this.appClientId),l.set("privy-ca-id",this.clientAnalyticsId||""),l.set("privy-client",`react-auth:${this.sdkVersion}`);let s=$3.includes(i.toString());if(!l.has("authorization")){let c=await this.client.getAccessToken({disableAutoRefresh:s});c!==null&&l.set("authorization",`Bearer ${c}`)}a.headers=l,a.retryDelay&&(a.retryDelay=a.retryDelay*3)},onRequestError:({error:i})=>{if(i instanceof DOMException&&i.name==="AbortError")throw new ys}})}async get(t,r){try{return await this.baseFetch(t,r)}catch(o){throw le(o)}}async post(t,r,o){try{return await this.baseFetch(t,{method:"POST",...r?{body:r}:{},...o})}catch(n){throw le(n)}}async delete(t,r){try{return await this.baseFetch(t,{method:"DELETE",...r})}catch(o){throw le(o)}}};var Yf=e=>({challenge:e.challenge,allowCredentials:e.allow_credentials?.map(t=>({id:t.id,type:t.type,transports:t.transports}))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification});import Ho from"js-cookie";function Zf(e){return e instanceof Lo?"email":e instanceof Do?"sms":e instanceof To?"siwe":e instanceof ri?"custom_auth":e instanceof Jr?e.meta.provider:null}import*as Qf from"jose";var _r=class{static parse(t){try{return new _r(t)}catch{return null}}constructor(t){this.value=t,this._decoded=Qf.decodeJwt(t)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(t=0){let r=Date.now(),o=(this.expiration-t)*1e3;return r>=o}};var K3=30,ll=class{constructor(){this.authenticateOnce=new Le(async t=>this._authenticate(t)),this.linkOnce=new Le(async t=>this._link(t)),this.refreshOnce=new Le(this._refresh.bind(this)),this.destroyOnce=new Le(this._destroy.bind(this)),this.forkSessionOnce=new Le(this._forkSession.bind(this))}get token(){try{let t=Q.get(Cn);return typeof t=="string"?new _r(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=Q.get(Ls);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=Q.get(aa);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}getProviderAccessToken(t){try{let r=Q.get(la(t));if(typeof r=="string"){let o=new _r(r);return o.isExpired()?(Q.del(la(t)),null):o.value}else return null}catch(r){return console.error(r),null}}get mightHaveServerCookies(){try{let t=Ho.get(Ns);return t!==void 0&&t.length>0}catch(t){console.error(t)}return!1}hasRefreshCredentials(){return this.mightHaveServerCookies||typeof this.token=="string"&&typeof this.refreshToken=="string"&&this.refreshToken!==Mm}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=_r.parse(this.token);return t!==null&&!t.isExpired(K3)}authenticate(t){return this.authenticateOnce.execute(t)}link(t){return this.linkOnce.execute(t)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(t,r){typeof r=="string"?Q.put(la(t),r):Q.del(la(t))}async _authenticate(t){try{let r=await t.authenticate(),{user:o,is_new_user:n,oauth_tokens:i}=r;this.handleTokenResponse(r);let a=i,l=a?{provider:a.provider,accessToken:a.access_token,accessTokenExpiresInSeconds:a.access_token_expires_in_seconds,refreshToken:a.refresh_token,refreshTokenExpiresInSeconds:i.refresh_token_expires_in_seconds,scopes:a.scopes}:void 0,s=Zf(t);return s&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:s,isNewUser:n}}),s==="siwe"&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}}),{user:zt(o),isNewUser:n,oAuthTokens:l}}catch(r){throw console.warn("Error authenticating session"),tt(r)}}async _link(t){try{let r=await t.link(),o=r.oauth_tokens,n=o?{provider:o.provider,accessToken:o.access_token,accessTokenExpiresInSeconds:o.access_token_expires_in_seconds,refreshToken:o.refresh_token,refreshTokenExpiresInSeconds:o.refresh_token_expires_in_seconds,scopes:o.scopes}:void 0;return{user:zt(r),oAuthTokens:n}}catch(r){throw console.warn("Error linking account"),tt(r)}}async _refresh(){if(!this.api)throw new w("Session has no API instance");if(!this.client)throw new w("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,r=this.refreshToken,o=this.forkedToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let n;if(t&&r||this.mightHaveServerCookies){let i={};t&&(i.authorization=`Bearer ${t}`);let a=r?{refresh_token:r}:{};n=await this.api.post(vs,a,{headers:i}),o&&this.clearForkedToken()}else if(o)n=await this.api.post(ws,{refresh_token:o}),this.clearForkedToken();else return null;return this.handleTokenResponse(n),zt(n.user)}catch(n){if(n instanceof Mt&&n.privyErrorCode==="missing_or_invalid_token")return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw tt(n)}}handleTokenResponse(t){t.session_update_action?t.session_update_action==="set"?(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token)):t.session_update_action==="clear"?this.destroyLocalState():t.session_update_action==="ignore"&&t.token&&(this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token)):(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token))}async _destroy(){try{await this.api?.post(Cs,{refresh_token:this.refreshToken})}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new w("Session has no API instance");let t=this.refreshToken;try{let r=await this.api.post(Eu,{refresh_token:t});return this.storeRefreshToken(r.refresh_token),this.storeToken(r.token),r.new_session_refresh_token}catch(r){throw tt(r)}}destroyLocalState(){this.storeRefreshToken(null),this.storeToken(null),this.clearIdentityToken(),this.clearForkedToken()}storeToken(t){if(typeof t=="string"){let r=Q.get(Cn);if(Q.put(Cn,t),!this.client?.useServerCookies){let o=_r.parse(t)?.expiration;Ho.set(hd,t,{sameSite:"Strict",secure:!0,expires:o?new Date(o*1e3):void 0})}r!==t&&this.client?.onStoreToken?.(t)}else Q.del(Cn),Ho.remove(hd),this.client?.onDeleteToken?.()}storeRefreshToken(t){typeof t=="string"?(Q.put(Ls,t),this.client?.useServerCookies||Ho.set(Ns,"t",{sameSite:"Strict",secure:!0,expires:30})):(Q.del(Ls),Ho.remove(Am),Ho.remove(Ns))}storeIdentityToken(t){if(this.client?.useServerCookies)return;Q.put(yd,t);let r=_r.parse(t)?.expiration;Ho.set(gd,t,{sameSite:"Strict",secure:!0,expires:r?new Date(r*1e3):void 0})}clearIdentityToken(){Q.del(yd),Ho.remove(gd)}clearForkedToken(){Q.del(aa)}};var Id,cl,Jf,ga=class{constructor(t){hs(this,cl);this.apiUrl=t.apiUrl||Ws,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!!t.apiUrl&&t.apiUrl.startsWith("https://privy."),this.timeout=t.timeout||Pm,this.appId=t.appId,this.appClientId=t.appClientId,this.clientAnalyticsId=bu(this,cl,Jf).call(this),Id||(Id=new ll),this.session=Id,this.api=this.generateApi(),this.session.client=this}initializeConnectorManager({walletConnectCloudProjectId:t,rpcConfig:r,chains:o,defaultChain:n,store:i,walletList:a,shouldEnforceDefaultChainOnConnect:l,externalWalletConfig:s,appName:c}){this.connectors||(this.connectors=new ya(this.appId,t,r,o,n,i,a,l,s,c))}sessionHasActiveToken(){return this.session.hasActiveToken()}generateApi(){let t=new sl({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=t,t}updateApiUrl(t){this.apiUrl=t||this.fallbackApiUrl,this.api=this.generateApi(),t&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new w("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new w("No auth flow in progress.");let{oAuthTokens:t}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:t}}storeProviderAccessToken(t,r){this.session.storeProviderAccessToken(t,r)}getProviderAccessToken(t){return this.session.getProviderAccessToken(t)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(t){t.linkedAccounts.filter(o=>o.type==="cross_app").forEach(o=>{this.storeProviderAccessToken(o.providerApp.id,null)})}startAuthFlow(t){return t.api=this.api,this.authFlow=t,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(tm,{action:"verify"})}catch(t){throw le(t)}}async initMfaPasskeyVerification(){try{let t=await this.api.post(rm,{});return Yf(t.options)}catch(t){throw le(t)}}async acceptTerms(){try{let t=await this.api.post(om,{});return zt(t)}catch(t){throw tt(t)}}async unlinkEmail(t){try{let r=await this.api.post(Lu,{address:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkPhone(t){try{let r=await this.api.post(Fu,{phoneNumber:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkWallet(t){try{let r=await this.api.post(Pu,{address:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkOAuth(t,r){try{let o=await this.api.post(Vu,{provider:t,subject:r});return await this.getAuthenticatedUser()??zt(o)}catch(o){throw tt(o)}}async unlinkFarcaster(t){try{let r=await this.api.post(Iu,{fid:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkTelegram(t){try{let r=await this.api.post(em,{telegram_user_id:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkPasskey(t){try{let r=await this.api.post(Qu,{credential_id:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async createAnalyticsEvent({eventName:t,payload:r,timestamp:o,options:n}){if(!(typeof window>"u"))try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(Ts,{event_name:t,client_id:this.clientAnalyticsId,payload:{...r||{},clientTimestamp:o?o.toISOString():new Date().toISOString()}},{retry:-1,keepalive:n?.keepAlive??!1})}catch{}}async signMoonpayOnRampUrl(t){try{return this.api.post(im,t)}catch(r){throw tt(r)}}async initCoinbaseOnRamp(t){try{return this.api.post(am,t)}catch(r){throw tt(r)}}async getCoinbaseOnRampStatus({partnerUserId:t}){try{return this.api.get(`${sm}?partnerUserId=${t}`)}catch(r){throw tt(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){return this.session.hasActiveToken()?_r.parse(this.session.token)?.audience!==this.appId?(await this.logout(),null):this.session.token:!t?.disableAutoRefresh&&this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getServerConfig(){try{let t={},r=this.session.token;r&&(t.authorization=`Bearer ${r}`);let o=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl,headers:t}),n=o.telegram_auth_config?{botId:o.telegram_auth_config.bot_id,botName:o.telegram_auth_config.bot_name,linkEnabled:o.telegram_auth_config.link_enabled,seamlessAuthEnabled:o.telegram_auth_config.seamless_auth_enabled}:void 0,i=o.funding_config?{methods:o.funding_config.methods,defaultRecommendedAmount:o.funding_config.default_recommended_amount,defaultRecommendedCurrency:o.funding_config.default_recommended_currency,promptFundingOnWalletCreation:o.funding_config.prompt_funding_on_wallet_creation}:void 0;return{id:o.id,name:o.name,verificationKey:o.verification_key,logoUrl:o.logo_url||void 0,accentColor:o.accent_color||void 0,showWalletLoginFirst:o.show_wallet_login_first,allowlistConfig:{errorTitle:o.allowlist_config.error_title,errorDetail:o.allowlist_config.error_detail,errorCtaText:o.allowlist_config.cta_text,errorCtaLink:o.allowlist_config.cta_link},walletAuth:o.wallet_auth,emailAuth:o.email_auth,smsAuth:o.sms_auth,googleOAuth:o.google_oauth,twitterOAuth:o.twitter_oauth,discordOAuth:o.discord_oauth,githubOAuth:o.github_oauth,spotifyOAuth:o.spotify_oauth,instagramOAuth:o.instagram_oauth,tiktokOAuth:o.tiktok_oauth,linkedinOAuth:o.linkedin_oauth,appleOAuth:o.apple_oauth,farcasterAuth:o.farcaster_auth,passkeyAuth:o.passkey_auth,telegramAuth:o.telegram_auth,termsAndConditionsUrl:o.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:o.embedded_wallet_config?.create_on_login,userOwnedRecoveryOptions:o.embedded_wallet_config.user_owned_recovery_options,requireUserOwnedRecoveryOnCreate:o.embedded_wallet_config.require_user_owned_recovery_on_create},privacyPolicyUrl:o.privacy_policy_url,requireUsersAcceptTerms:o.require_users_accept_terms,customApiUrl:o.custom_api_url,walletConnectCloudProjectId:o.wallet_connect_cloud_project_id,fiatOnRampEnabled:o.fiat_on_ramp_enabled,captchaEnabled:o.captcha_enabled,captchaSiteKey:o.captcha_site_key,twitterOAuthOnMobileEnabled:o.twitter_oauth_on_mobile_enabled,createdAt:new Date(o.created_at*1e3),updatedAt:new Date(o.updated_at*1e3),mfaMethods:o.mfa_methods,enforceWalletUis:o.enforce_wallet_uis,legacyWalletUiConfig:o.legacy_wallet_ui_config,telegramAuthConfiguration:n,fundingConfig:i}}catch(t){throw tt(t)}}async getUsdTokenPrice(t){try{return(await this.api.get(`/api/v1/token_price?chainId=${t.id}&tokenSymbol=${t.nativeCurrency.symbol}`)).usd}catch{console.error(`Unable to fetch token price for chain with id ${t.id}`);return}}async requestFarcasterSignerStatus(t){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:t})}catch(r){throw console.error("Unable to fetch Farcaster signer status"),r}}async forkSession(){return await this.session.forkSession()}async generateSiweNonce({address:t,captchaToken:r}){try{return(await this.api.post(Tu,{address:t,token:r})).nonce}catch(o){throw tt(o)}}async authenticateWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:i}){return await this.api.post(Su,{message:t,signature:r,chainId:o,walletClientType:n,connectorType:i})}async linkWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:i}){return await this.api.post(_u,{message:t,signature:r,chainId:o,walletClientType:n,connectorType:i})}async linkWithSiwe({message:t,signature:r,chainId:o,walletClientType:n,connectorType:i}){try{let a=await this.linkWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:i});return zt(a)}catch(a){throw tt(a)}}};cl=new WeakSet,Jf=function(){if(typeof window>"u")return null;try{let r=Q.get(sa);if(typeof r=="string"&&r.length>0)return r}catch{}let t=j3();try{return Q.put(sa,t),t}catch{return t}};import{Turnstile as e0}from"@marsidev/react-turnstile";import{useEffect as t0,useMemo as r0}from"react";import{useMemo as Y3,useRef as Z3,useContext as Q3,useState as Md,createContext as J3}from"react";import{jsx as X3}from"react/jsx-runtime";var Xf=J3({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:E,setError:E,setExecuting:E,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:E,reset:E,execute:E}),ir=class extends et{constructor(r,o,n){super(r||"Captcha failed");this.type="Captcha";o instanceof Error&&(this.cause=o),this.privyErrorCode=n}},eh=({children:e,id:t,captchaSiteKey:r,captchaEnabled:o})=>{let n=Z3(null),[i,a]=Md(),[l,s]=Md(),[c,m]=Md(!1),f=Y3(()=>o?!c&&!i&&!l?{status:"ready"}:c&&!i&&!l?{status:"loading"}:i&&!l?{status:"success",token:i}:l?{status:"error",error:l}:{status:"ready"}:{status:"disabled"},[o,i,l,c]);return X3(Xf.Provider,{value:{...f,ref:n,enabled:o,siteKey:r,appId:t,setToken:a,setError:s,setExecuting:m,remove(){o&&(n.current?.remove(),m(!1),s(void 0),a(void 0))},reset(){o&&(n.current?.reset(),m(!1),s(void 0),a(void 0))},execute(){o&&(m(!0),n.current?.execute())},async waitForResult(){if(!o)return"";try{return await pm(()=>n.current?.getResponse(),{interval:200,timeout:2e4})}catch{throw new ir("Captcha failed",null,"captcha_timeout")}}},children:e})},be=()=>Q3(Xf);import{jsx as th}from"react/jsx-runtime";var Wd=e=>{let{enabled:t,siteKey:r,appId:o,setError:n,setToken:i,setExecuting:a,ref:l}=be(),[,s]=r0(()=>r?.split("t:")||[],[r]);if(t0(()=>l.current?.remove,[]),!t)return null;if(!s)throw new Error("Unsupported captcha site key");return th("div",{className:"hidden h-0 w-0",children:th(e0,{...e,ref:l,siteKey:s,options:{action:o,size:"invisible",...e.delayedExecution?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{e.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{e.onError?.(),n("Captcha failed"),a(!1)},onSuccess:c=>{e.onSuccess?.(c),i(c),a(!1)},onExpire:()=>{e.onExpire?.();try{l.current?.reset(),n(void 0),i(void 0)}catch{n("expired_and_failed_reset")}}})})};import{useCallback as jS,useEffect as Jv,useRef as YS,useState as ZS}from"react";import tC from"styled-components";import{createContext as o0,useContext as n0}from"react";var Od=o0({isNewUserThisSession:!1,linkingOrConnectingHint:null,walletConnectionStatus:null,connectors:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,appId:"notAdded",nativeTokenSymbolForChainId:E,initializeWalletProxy:E,getAuthMeta:E,getAuthFlow:E,closePrivyModal:E,openPrivyModal:E,connectWallet:E,initLoginWithWallet:E,loginWithWallet:E,initLoginWithFarcaster:E,loginWithFarcaster:E,loginWithCode:E,initLoginWithEmail:E,initLoginWithSms:E,initUpdateEmail:E,initUpdatePhone:E,resendEmailCode:E,resendSmsCode:E,initLoginWithHeadlessOAuth:E,loginWithHeadlessOAuth:E,crossAppAuthFlow:E,initLoginWithOAuth:E,recoveryOAuthFlow:E,loginWithOAuth:E,initLoginWithPasskey:E,loginWithPasskey:E,initLinkWithPasskey:E,linkWithPasskey:E,refreshUser:E,walletProxy:null,createAnalyticsEvent:E,acceptTerms:E,getUsdTokenPrice:E,recoverEmbeddedEthereumWallet:E,getMoonpaySignedUrl:E,initCoinbaseOnRamp:E,getCoinbaseOnRampStatus:E,updateWallets:E,fundWallet:E,setReadyToTrue:E,requestFarcasterSignerStatus:E,initLoginWithTelegram:E,loginWithTelegram:E,generateSiweMessage:E,linkWithSiwe:E,embeddedSolanaWallet:null,createEmbeddedSolanaWallet:E,recoverEmbeddedSolanaWallet:E,solanaSignMessage:E}),M=()=>n0(Od);import{createContext as i0,useContext as a0}from"react";var Se=i0({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:E,login:E,connectOrCreateWallet:E,linkEmail:E,linkPhone:E,linkFarcaster:E,linkWallet:E,linkCrossAppAccount:E,linkGoogle:E,linkTwitter:E,linkDiscord:E,linkGithub:E,linkSpotify:E,linkInstagram:E,linkTelegram:E,linkTiktok:E,linkLinkedIn:E,linkApple:E,linkPasskey:E,updateEmail:E,updatePhone:E,logout:E,getAccessToken:E,getEthereumProvider:E,getEthersProvider:E,getWeb3jsProvider:E,unlinkEmail:E,unlinkPhone:E,unlinkWallet:E,unlinkGoogle:E,unlinkTwitter:E,unlinkDiscord:E,unlinkGithub:E,unlinkSpotify:E,unlinkInstagram:E,unlinkTiktok:E,unlinkLinkedIn:E,unlinkApple:E,unlinkCrossAppAccount:E,unlinkFarcaster:E,unlinkTelegram:E,unlinkPasskey:E,setActiveWallet:E,forkSession:E,createWallet:E,importWallet:E,signMessage:E,signTypedData:E,enrollInMfa:E,initEnrollmentWithSms:E,initEnrollmentWithTotp:E,initEnrollmentWithPasskey:E,promptMfa:E,init:E,submitEnrollmentWithSms:E,submitEnrollmentWithTotp:E,submitEnrollmentWithPasskey:E,unenroll:E,submit:E,cancel:E,sendTransaction:E,exportWallet:E,setWalletPassword:E,setWalletRecovery:E,requestFarcasterSignerFromWarpcast:E,getFarcasterSignerPublicKey:E,signFarcasterMessage:E,initLoginWithEmail:E,initLoginWithSms:E,otpState:{status:"initial"},loginWithCode:E,fundWallet:E,initLoginWithHeadlessOAuth:E,loginWithHeadlessOAuth:E,generateSiweMessage:E,linkWithSiwe:E,signMessageWithCrossAppWallet:E,signTypedDataWithCrossAppWallet:E,sendTransactionWithCrossAppWallet:E,isHeadlessOAuthLoading:!1,isModalOpen:!1,mfaMethods:[]}),q=()=>a0(Se);import{useEffect as s0,useState as l0}from"react";var rh=e=>{let[t,r]=l0("auto");return s0(()=>{let o=new ResizeObserver(n=>{r(n[0]?.contentRect.height??"auto")});return e.current&&o.observe(e.current),()=>{e.current&&o.unobserve(e.current)}},[e.current]),t};import{createContext as c0,useContext as d0,useEffect as p0}from"react";var oh={login:{onComplete:[],onError:[],onOAuthLoginComplete:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},setWalletRecovery:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]}},Ld=c0(void 0),nh=()=>d0(Ld);function Ae(e,t){if(!t)return;let o=nh().current[e];return p0(()=>{for(let[n,i]of Object.entries(t))o.hasOwnProperty(n)||console.warn(`Invalid event type "${n}" for action "${e}"`),o[n]?.push(i);return()=>{for(let[n,i]of Object.entries(t))o.hasOwnProperty(n)||console.warn(`Invalid event type "${n}" for action "${e}"`),o[n]=o[n]?.filter(a=>a!==i)}},[t])}function F(e,t,r,...o){for(let n of e.current[t][r])n(...o)}function gi(){let e=nh();return(t,r,...o)=>F(e,t,r,...o)}function Nd(e){Ae("configureMfa",e)}import{QuestionMarkCircleIcon as W0}from"@heroicons/react/24/outline";import ph from"styled-components";import Rn,{css as ih}from"styled-components";import Ud from"styled-components";import{Fragment as m0,jsx as Dd,jsxs as f0}from"react/jsx-runtime";var nt=({success:e,fail:t})=>f0(m0,{children:[Dd(it,{className:e?"success":t?"fail":""}),Dd(va,{className:e?"success":t?"fail":""})]}),it=Ud.span`
12
+ - https://privy.io`};var To=class{constructor(t,r,o){this.getNonceOnce=new Le(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=o,this.client=r}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType}}async authenticate(){if(!this.client)throw new w("SiweFlow has no client instance");try{let{message:t,signature:r}=await this.sign(),o=await this.client.authenticateWithSiweInternal({message:t,signature:r,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType});return{user:o.user,token:o.token,refresh_token:o.refresh_token,identity_token:o.identity_token,is_new_user:o.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.client)throw new w("SiweFlow has no client instance");try{let{message:t,signature:r}=await this.sign();return await this.client.linkWithSiweInternal({message:t,signature:r,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw le(t)}}async sign(){if(!this.client)throw new w("SiweFlow has no client instance");if(await this.buildSiweMessage(),!this.preparedMessage)throw new w("Could not prepare SIWE message");let t=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async _getNonceOnce(){if(!this.client)throw new w("SiweFlow has no client instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildSiweMessage(){if(!this.client)throw new w("SiweFlow has no client instance");let t=this.wallet.address,r=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=Qs({address:t,chainId:r,nonce:this.nonce}),this.preparedMessage}};var Do=class{constructor(t,r){this.meta={phoneNumber:t,captchaToken:r}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{let t=await this.api.post(Bu,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new w("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Uu,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw le(t)}}async sendSmsCode(t,r){if(!this.api)throw new w("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),r&&(this.meta.captchaToken=r),!this.meta.phoneNumber)throw new w("phone nNumber must be set when initialzing authentication.");try{return await this.api.post(Du,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(o){throw le(o)}}},Js=class extends Do{constructor(r,o,n){super(o,n);this.meta={phoneNumber:o,captchaToken:n,oldPhoneNumber:r}}async link(){if(!this.api)throw new w("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new w("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(Hu,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(r){throw le(r)}}};var si=class{constructor(t){this.meta={captchaToken:t}}async authenticate(){if(!this.api)throw new w("Auth flow has no API instance");try{let t=await this.api.post(Ju,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData});return{user:t.user,token:t.token,refresh_token:t.refresh_token,identity_token:t.identity_token,is_new_user:t.is_new_user}}catch(t){throw le(t)}}async link(){if(!this.api)throw new w("Auth flow has no API instance");try{return await this.api.post(Xu,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(t){throw le(t)}}};function Td(e){let t={detail:"",retryable:!1};return e?.privyErrorCode==="linked_to_another_user"&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode==="disallowed_login_method"&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode==="invalid_data"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="cannot_link_more_of_type"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="invalid_credentials"&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode==="too_many_requests"&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode==="too_many_requests"&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),t}function zm(){let e;if(e=QC(),e)return qm(),{...e,flowType:"login-url"};if(e=JC(),e)return qm(),{...e,flowType:"web-app"}}function QC(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),r=e.get("hash"),o=Number(e.get("auth_date")||""),n=e.get("first_name"),i=e.get("last_name")||void 0,a=e.get("username")||void 0,l=e.get("photo_url")||void 0;if(!(!t||!n||!o||!r))return{id:t,first_name:n,last_name:i,username:a,photo_url:l,auth_date:o,hash:r}}function JC(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=new URLSearchParams(decodeURIComponent(e.replace("#tgWebAppData=",""))),r=t.get("query_id"),o=t.get("user"),n=Number(t.get("auth_date")||""),i=t.get("hash");if(!(!r||!o||!n||!i))return{query_id:r,user:o,auth_date:n,hash:i}}function qm(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),window.history.replaceState({},"",e)}import{v4 as j3}from"uuid";function ee(e){return e?new Date(e*1e3):null}function XC(e){let t=[];for(let r of e){let o=r.type;switch(r.type){case"wallet":let n={address:r.address,type:r.type,imported:r.imported,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at),chainType:r.chain_type,chainId:r.chain_id,walletClient:r.wallet_client_type==="privy"?"privy":"unknown",walletClientType:r.wallet_client_type,connectorType:r.connector_type,recoveryMethod:r.recovery_method};t.push(n);break;case"cross_app":let i={type:r.type,subject:r.subject,embeddedWallets:r.embedded_wallets,smartWallets:r.smart_wallets,providerApp:{id:r.provider_app_id},verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(i);break;case"email":let a={address:r.address,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(a);break;case"phone":let l={number:r.phoneNumber,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(l);break;case"google_oauth":let s={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(s);break;case"spotify_oauth":let c={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(c);break;case"instagram_oauth":let m={subject:r.subject,username:r.username,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(m);break;case"twitter_oauth":let f={subject:r.subject,username:r.username,name:r.name,type:r.type,profilePictureUrl:r.profile_picture_url,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(f);break;case"discord_oauth":let u={subject:r.subject,username:r.username,email:r.email,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(u);break;case"github_oauth":let C={subject:r.subject,username:r.username,name:r.name,email:r.email,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(C);break;case"tiktok_oauth":let g={subject:r.subject,username:r.username,name:r.name,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(g);break;case"linkedin_oauth":let y={subject:r.subject,name:r.name,email:r.email,vanityName:r.vanity_name,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(y);break;case"apple_oauth":let b={subject:r.subject,email:r.email,type:r.type,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(b);break;case"custom_auth":t.push({type:r.type,customUserId:r.custom_user_id,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)});break;case"farcaster":let T={type:r.type,fid:r.fid,ownerAddress:r.owner_address,displayName:r.display_name,username:r.username,bio:r.bio,pfp:r.profile_picture_url,url:r.homepage_url,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at),signerPublicKey:r.signer_public_key};t.push(T);break;case"passkey":let k={type:r.type,enrolledInMfa:r.enrolled_in_mfa,credentialId:r.credential_id,authenticatorName:r.authenticator_name,createdWithDevice:r.created_with_device,createdWithOs:r.created_with_os,createdWithBrowser:r.created_with_browser,verifiedAt:ee(r.verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(k);break;case"telegram":let S={type:r.type,telegramUserId:r.telegram_user_id,firstName:r.first_name,lastName:r.last_name,username:r.username,photoUrl:r.photo_url,verifiedAt:ee(r.first_verified_at),firstVerifiedAt:ee(r.first_verified_at),latestVerifiedAt:ee(r.latest_verified_at)};t.push(S);break;default:console.warn(`Unrecognized account type: ${o}. Please consider upgrading the Privy SDK.`)}}return t}function Vt(e,t){return e.slice().sort((r,o)=>(o.firstVerifiedAt??o.verifiedAt).getTime()-(r.firstVerifiedAt??r.verifiedAt).getTime()).find(r=>r.type===t)}var ge=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&!t.imported&&t.chainType==="ethereum")||null,An=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&!t.imported&&t.chainType==="solana")||null,Xs=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&t.imported&&t.chainType==="ethereum")||null,e3=e=>e.linkedAccounts.filter(t=>t.type==="wallet"),qt=(e,t)=>ge(e)||An(e)?!1:t==="all-users"||t==="users-without-wallets"&&!e3(e)?.length;function zt(e){if(!e)return null;let t=XC(e.linked_accounts),r=Vt(t,"wallet"),o=Vt(t,"email"),n=Vt(t,"phone"),i=Vt(t,"google_oauth"),a=Vt(t,"twitter_oauth"),l=Vt(t,"discord_oauth"),s=Vt(t,"github_oauth"),c=Vt(t,"spotify_oauth"),m=Vt(t,"instagram_oauth"),f=Vt(t,"tiktok_oauth"),u=Vt(t,"linkedin_oauth"),C=Vt(t,"apple_oauth"),g=Vt(t,"farcaster"),y=Vt(t,"telegram"),b=e.mfa_methods.map(({type:k,verified_at:S})=>({type:k,verifiedAt:ee(S)}));return{id:e.id,createdAt:ee(e.created_at),linkedAccounts:t,email:o&&{address:o?.address},phone:n&&{number:n?.number},wallet:r&&{address:r.address,chainType:r.chainType,chainId:r.chainId,walletClient:r.walletClient,walletClientType:r.walletClientType,connectorType:r.connectorType,recoveryMethod:r.recoveryMethod,imported:r.imported},google:i&&{subject:i.subject,email:i.email,name:i.name},twitter:a&&{subject:a.subject,username:a.username,name:a.name,profilePictureUrl:a.profilePictureUrl},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:s&&{subject:s.subject,username:s.username,name:s.name,email:s.email},spotify:c&&{subject:c.subject,email:c.email,name:c.name},instagram:m&&{subject:m.subject,username:m.username},tiktok:f&&{subject:f.subject,username:f.username,name:f.name},linkedin:u&&{subject:u.subject,name:u.name,email:u.email,vanityName:u.vanityName},apple:C&&{subject:C.subject,email:C.email},farcaster:g&&{fid:g.fid,ownerAddress:g.ownerAddress,displayName:g.displayName,username:g.username,bio:g.bio,pfp:g.pfp,url:g.url,signerPublicKey:g.signerPublicKey},telegram:y&&{telegramUserId:y.telegramUserId,firstName:y.firstName,lastName:y.lastName,username:y.username,photoUrl:y.photoUrl},mfaMethods:b.map(k=>k.type),hasAcceptedTerms:e.has_accepted_terms??!1}}import{getAddress as jf}from"@ethersproject/address";import{isHexString as G3}from"@ethersproject/bytes";import V3 from"eventemitter3";import l3 from"@coinbase/wallet-sdk";import{jsx as $m,jsxs as t3}from"react/jsx-runtime";var So=({style:e,...t})=>t3("svg",{width:"1024",height:"1024",viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[$m("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),$m("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]});import{getAddress as eo}from"@ethersproject/address";import{Web3Provider as Jm}from"@ethersproject/providers";import{default as a3}from"eventemitter3";import i3 from"eventemitter3";var r3=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4"],Km=e=>r3.includes(e);import{ErrorCode as o3}from"@ethersproject/logger";import{ProviderErrors as xn}from"@privy-io/js-sdk-core";var li=class extends ce{constructor(){super("Wallet timeout");this.type="wallet_error"}},ci=class extends ce{constructor(){super("User rejected connection");this.type="wallet_error"}},Lr=e=>{if(e instanceof ce)return e;if(e?.code&&e?.reason){let t=new Ct(e);return e.code===o3.ACTION_REJECTED&&(t.details=xn.E4001_USER_REJECTED_REQUEST),t}return e?.code?new Ct(e):new ce("Unknown connector error",e)},Sr=class extends et{constructor(r,o,n){super(r);this.type="provider_error";this.code=o,this.data=n}},Ct=class extends Sr{constructor(r){let o=r;super(o.message,o.code,o.data);let n=Object.values(xn).find(i=>i.eipCode===o.code);this.details=n||xn.UNKNOWN_ERROR,o.code===-32002&&(o.message?.includes("already pending for origin")?o.message?.includes("wallet_requestPermissions")?this.details=xn.E32002_CONNECTION_ALREADY_PENDING:this.details=xn.E32002_REQUEST_ALREADY_PENDING:o.message?.includes("Already processing")&&o.message.includes("eth_requestAccounts")&&(this.details=xn.E32002_WALLET_LOCKED))}},n3={ERROR_USER_EXISTS:{message:"User already exists for this address",detail:"Try another address!",retryable:!1},ERROR_TIMED_OUT:{message:"Wallet request timed out",detail:"Please try connecting again.",retryable:!0},ERROR_WALLET_CONNECTION:{message:"Could not log in with wallet",detail:"Please try connecting again.",retryable:!0},ERROR_USER_REJECTED_CONNECTION:{message:"You rejected the request",detail:"Please try connecting again.",retryable:!0}},_o={...n3,...xn};var je=class{constructor(t,r){this.removeListener=(t,r)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(t,r)}catch{console.warn("Unable to remove wallet provider listener")}};this.walletTimeout=(t=new li,r=this.rpcTimeoutDuration)=>new Promise((o,n)=>setTimeout(()=>{n(t)},r));this.setWalletProvider=t=>{this.walletProvider&&this._subscriptions.forEach(r=>{this.removeListener(r.eventName,r.listener)}),this.walletProvider=t,this._subscriptions.forEach(r=>{this.walletProvider?.on(r.eventName,r.listener)})};this.walletProvider=t,this.rpcTimeoutDuration=r||Tn,this._subscriptions=[]}on(t,r){if(this.walletProvider)return this.walletProvider.on(t,r);this._subscriptions.push({eventName:t,listener:r})}async request(t){if(!this.walletProvider)throw new ce(`A wallet request of type ${t.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(t),this.walletTimeout()]).catch(r=>{throw Lr(r)})}},Uo=class extends Error{constructor(r,o,n){super(r);this.code=o,this.data=n}},ua=class extends i3{constructor(r,o,n,i,a,l=1){super();this.walletProxy=r,this.address=o,this.chainId=l,this.rpcConfig=n,this.chains=i,this.provider=Gt(l,this.chains,n,{appId:a}),this.rpcTimeoutDuration=di(n,"privy"),this.appId=a}async handleSendTransaction(r){if(!r.params||!Array.isArray(r.params))throw new Uo(`Invalid params for ${r.method}`,4200);let o=r.params[0];if(!await we()||!this.address)throw new Uo("Disconnected",4900);return(await Zm(o)).hash}handleSwitchEthereumChain(r){if(!r.params||!Array.isArray(r.params))throw new Uo(`Invalid params for ${r.method}`,4200);let o;if(typeof r.params[0]=="string")o=r.params[0];else if("chainId"in r.params[0]&&typeof r.params[0].chainId=="string")o=r.params[0].chainId;else throw new Uo(`Invalid params for ${r.method}`,4200);this.chainId=Number(o),this.provider=Gt(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",o)}async handlePersonalSign(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for personal_sign");let o=r.params[0],n=r.params[1];return await jm(o,void 0,n)}async handleSignedTypedData(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for eth_signTypedData_v4");let o=typeof r.params[1]=="string"?JSON.parse(r.params[1]):r.params[1];return await Ym(na(o))}async handleEstimateGas(r){if(!r.params||!Array.isArray(r.params))throw new Error("Invalid params for eth_estimateGas");delete r.params[0].gasPrice,delete r.params[0].maxFeePerGas,delete r.params[0].maxPriorityFeePerGas;let o={...r.params[0],chainId:vn(this.chainId)};try{return await this.provider.send("eth_estimateGas",[o])}catch(n){console.warn(`Gas estimation failed with error: ${n}. Retrying gas estimation by omitting the 'from' address`);try{return delete o.from,await this.provider.send("eth_estimateGas",[o])}catch(i){throw console.warn(`Gas estimation failed with error: ${i} when omitting the 'from' address`),n}}}async request(r){switch(console.debug("Embedded1193Provider.request() called with args",r),r.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return vn(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(r);case"eth_sendTransaction":return this.handleSendTransaction(r);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(r);case"personal_sign":return this.handlePersonalSign(r);case"eth_signTypedData_v4":return this.handleSignedTypedData(r);default:break}if(Km(r.method)){let o=await we();if(await Qm(),!o||!this.address)throw new Uo("Disconnected",4900);try{return(await this.walletProxy.rpc({address:this.address,accessToken:o,request:{method:r.method,params:r.params}})).response.data}catch(n){throw console.error(n),new Uo("Disconnected",4900)}}else return this.provider.send(r.method,r.params)}async connect(){let r=await we();if(!r||!this.address)return null;try{return(await this.walletProxy.connect({address:this.address,accessToken:r})).address}catch(o){return console.error(o),null}}},Xr=class extends je{constructor(r){super(r,r.rpcTimeoutDuration)}},Fo=class extends je{constructor(t){super(t,t.rpcTimeoutDuration)}sendAsync(t,r){throw new Error("sendAsync is no longer supported by EIP-1193. Use the request method instead.")}};var s3=(e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");default:return e.code===4902||e.message?.includes("4902")}},$t=class extends a3{constructor(r,o,n,i){super();this.onAccountsChanged=r=>{r.length===0?this.onDisconnect():this.syncAccounts(r)};this.onChainChanged=r=>{this.wallets.forEach(o=>{o.chainId=oi(r),this.walletClientType==="privy"&&Q.put(Ds(o.address),r)}),this.emit("walletsUpdated")};this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")};this.onConnect=()=>{this.connected=!0,this.syncAccounts()};this.wallets=[],this.walletClientType=r,this.chains=o,this.defaultChain=n,this.rpcConfig=i,this.rpcTimeoutDuration=di(i,r),this.connected=!1,this.initialized=!1}buildConnectedWallet(r,o,n,i){let a=async()=>!!this.wallets.find(l=>eo(l.address)===eo(r));return{address:eo(r),chainId:o,meta:n,imported:i,switchChain:async l=>{if(!a)throw new ce("Wallet is not currently connected.");let s=this.wallets.find(C=>eo(C.address)===eo(r))?.chainId;if(!s)throw new ce("Unable to determine current chainId.");let c,m;if(typeof l=="number"?(c=`0x${l.toString(16)}`,m=l):(c=l,m=Number(l)),s===oi(c))return;let f=this.chains.find(C=>C.id===m);if(!f)throw new ce(`Unsupported chainId: ${l}`);let u=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:c}]})};try{return await u()}catch(C){if(s3(C,this.walletClientType))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:c,chainName:f.name,nativeCurrency:f.nativeCurrency,rpcUrls:[f.rpcUrls.default?.http[0]??""],blockExplorerUrls:[f.blockExplorers?.default.url??""]}]}),u();throw this.walletClientType==="rainbow"&&C.message?.includes("wallet_switchEthereumChain")?new ce(`Rainbow does not support the chainId ${o}`):C}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:a,getEthereumProvider:async()=>{if(!await a())throw new ce("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await a())throw new ce("Wallet is not currently connected.");return new Jm(new Xr(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await a())throw new ce("Wallet is not currently connected.");return new Fo(this.proxyProvider)},sign:async l=>{if(!await a())throw new ce("Wallet is not currently connected.");return await this.sign(l)},disconnect:()=>{this.disconnect()}}}async syncAccounts(r){let o=r;try{if(o===void 0){let c=await oa(()=>this.proxyProvider.request({method:"eth_accounts"}),{maxAttempts:10,delayMs:500});Array.isArray(c)&&(o=c)}}catch(c){console.warn("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",c)}if(!o||!Array.isArray(o)||o.length<=0||!o[0])return;let n=o[0],i=eo(n),a=[],l;if(this.walletClientType==="privy"){let c=Q.get(Ds(i));this.chains.find(m=>m.id===Number(c))||(Q.del(Ds(i)),c=null),l=c||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:l}]})}catch{console.warn(`Unable to switch embedded wallet to chain ID ${l} on initialization`)}}else try{let c=await oa(()=>this.proxyProvider.request({method:"eth_chainId"}),{maxAttempts:10,delayMs:500});if(typeof c=="string")l=c;else if(typeof c=="number")l=`0x${c.toString(16)}`;else throw new Error("Invalid chainId returned from provider")}catch(c){console.warn(`Failed to get chainId from provider, defaulting to ${wd}`,c),l=wd}let s=oi(l);if(!a.find(c=>eo(c.address)===i)){let c={name:this.walletBranding.name,icon:typeof this.walletBranding.icon=="string"?this.walletBranding.icon:void 0,id:this.walletBranding.id};a.push(this.buildConnectedWallet(eo(n),s,c,this.connectorType==="embedded_imported"))}el(a,this.wallets)||(this.wallets=a,this.emit("walletsUpdated"))}async getConnectedWallet(){let r=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort((o,n)=>n.connectedAt-o.connectedAt).find(o=>r.find(n=>eo(n)===eo(o.address)))||null}async isConnected(){let r=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(r)&&r.length>0}async sign(r){return await this.connect({showPrompt:!1}),new Jm(new Xr(this.proxyProvider)).getSigner().signMessage(r)}subscribeListeners(){this.proxyProvider.on("accountsChanged",this.onAccountsChanged),this.proxyProvider.on("chainChanged",this.onChainChanged),this.proxyProvider.on("disconnect",this.onDisconnect),this.proxyProvider.on("connect",this.onConnect)}unsubscribeListeners(){this.proxyProvider.removeListener("accountsChanged",this.onAccountsChanged),this.proxyProvider.removeListener("chainChanged",this.onChainChanged),this.proxyProvider.removeListener("disconnect",this.onDisconnect),this.proxyProvider.removeListener("connect",this.onConnect)}};var c3=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],d3=(e,t)=>e.makeWeb3Provider({options:t}),Sd,tl=class extends $t{constructor(r,o,n,i,a,l){super("coinbase_wallet",r,o,n);this.connectorType="coinbase_wallet";this.displayName="Coinbase Wallet";if(this.proxyProvider=new je(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=i.coinbaseWallet.connectionOptions??"all",this.walletClientType=this.connectionOptions==="smartWalletOnly"?"coinbase_smart_wallet":"coinbase_wallet",this.walletClientType==="coinbase_smart_wallet"&&(this.displayName="Coinbase Smart Wallet"),!Sd){let s=[o.id].concat(r.map(m=>m.id)),c=this.connectionOptions!=="eoaOnly"?s.filter(m=>!c3.includes(m)):[];c.length>0&&console.warn(`The following configured chains are not supported by the Coinbase Smart Wallet: ${c.join(", ")}`),Sd=new l3({appName:a,appLogoUrl:l,appChainIds:s})}this.proxyProvider.setWalletProvider(d3(Sd,this.connectionOptions))}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:So,id:"com.coinbase.wallet"}}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new ce("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([r[0]])}catch(r){throw Lr(r)}}};import{jsx as Xm}from"react/jsx-runtime";var Bo=({...e})=>Xm("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:Xm("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:e.color||"var(--privy-color-foreground-3)"})});var ma=class extends $t{constructor(r,o,n,i,a=!1){super("privy",o,n,i);this.connectorType="embedded";this.proxyProvider=r,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[vn(r?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Bo,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}};import{jsx as ef}from"react/jsx-runtime";var pi=({style:e,...t})=>ef("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...e},...t,children:ef("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})});import{jsx as nr,jsxs as p3}from"react/jsx-runtime";var ui=({style:e,...t})=>p3("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",x:0,y:0,viewBox:"0 0 318.6 318.6",width:"28",height:"28",style:{height:"28px",width:"28px",...e},...t,children:[nr("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),nr("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),nr("path",{d:"m44.4 35.5 98.7 74.6-17.5-44.3zm193.9 171.3-26.5 40.6 56.7 15.6 16.3-55.3zm-204.4.9L50.1 263l56.7-15.6-26.5-40.6z",className:"s1 s2"}),nr("path",{d:"m103.6 138.2-15.8 23.9 56.3 2.5-2-60.5zm111.3 0-39-34.8-1.3 61.2 56.2-2.5zM106.8 247.4l33.8-16.5-29.2-22.8zm71.1-16.5 33.9 16.5-4.7-39.3z",className:"s1 s2"}),nr("path",{fill:"#d7c1b3",stroke:"#d7c1b3",className:"s1",d:"m211.8 247.4-33.9-16.5 2.7 22.1-.3 9.3zm-105 0 31.5 14.9-.2-9.3 2.5-22.1z"}),nr("path",{fill:"#233447",stroke:"#233447",className:"s1",d:"m138.8 193.5-28.2-8.3 19.9-9.1zm40.9 0 8.3-17.4 20 9.1z"}),nr("path",{fill:"#cd6116",stroke:"#cd6116",className:"s1",d:"m106.8 247.4 4.8-40.6-31.3.9zM207 206.8l4.8 40.6 26.5-39.7zm23.8-44.7-56.2 2.5 5.2 28.9 8.3-17.4 20 9.1zm-120.2 23.1 20-9.1 8.2 17.4 5.3-28.9-56.3-2.5z"}),nr("path",{fill:"#e4751f",stroke:"#e4751f",className:"s1",d:"m87.8 162.1 23.6 46-.8-22.9zm120.3 23.1-1 22.9 23.7-46zm-64-20.6-5.3 28.9 6.6 34.1 1.5-44.9zm30.5 0-2.7 18 1.2 45 6.7-34.1z"}),nr("path",{d:"m179.8 193.5-6.7 34.1 4.8 3.3 29.2-22.8 1-22.9zm-69.2-8.3.8 22.9 29.2 22.8 4.8-3.3-6.6-34.1z",className:"s3"}),nr("path",{fill:"#c0ad9e",stroke:"#c0ad9e",className:"s1",d:"m180.3 262.3.3-9.3-2.5-2.2h-37.7l-2.3 2.2.2 9.3-31.5-14.9 11 9 22.3 15.5h38.3l22.4-15.5 11-9z"}),nr("path",{fill:"#161616",stroke:"#161616",className:"s1",d:"m177.9 230.9-4.8-3.3h-27.7l-4.8 3.3-2.5 22.1 2.3-2.2h37.7l2.5 2.2z"}),nr("path",{fill:"#763d16",stroke:"#763d16",className:"s1",d:"m278.3 114.2 8.5-40.8-12.7-37.9-96.2 71.4 37 31.3 52.3 15.3 11.6-13.5-5-3.6 8-7.3-6.2-4.8 8-6.1zM31.8 73.4l8.5 40.8-5.4 4 8 6.1-6.1 4.8 8 7.3-5 3.6 11.5 13.5 52.3-15.3 37-31.3-96.2-71.4z"}),nr("path",{d:"m267.2 153.5-52.3-15.3 15.9 23.9-23.7 46 31.2-.4h46.5zm-163.6-15.3-52.3 15.3-17.4 54.2h46.4l31.1.4-23.6-46zm71 26.4 3.3-57.7 15.2-41.1h-67.5l15 41.1 3.5 57.7 1.2 18.2.1 44.8h27.7l.2-44.8z",className:"s3"})]});import{jsx as tf,jsxs as u3}from"react/jsx-runtime";var to=({style:e,...t})=>u3("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...e},...t,children:[tf("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),tf("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});var fi=class extends $t{constructor(r,o,n,i,a){super(a||"unknown",r,o,n);this.connectorType="injected";this.proxyProvider=new je(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=i;let l=i.provider;this.proxyProvider.setWalletProvider(l)}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new ce("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw Lr(r)}}},mi,hi=class extends $t{constructor(r,o,n,i,a){super(a??"unknown",r,o,n);this.connectorType="injected";hs(this,mi,void 0);this.proxyProvider=new je(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(i),a==="metamask"?sd(this,mi,{name:"MetaMask",icon:ui,id:"io.metamask"}):a==="phantom"&&sd(this,mi,{name:"Phantom",icon:to,id:"phantom"})}async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(r){return r.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return wu(this,mi)??{name:"Browser Extension",icon:pi,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let r=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!r||r.length===0||!r[0])throw new ce("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw Lr(r)}}};mi=new WeakMap;import{getAddress as ak}from"@ethersproject/address";import{Web3Provider as lk}from"@ethersproject/providers";import{isMobile as m3}from"react-device-detect";var rl=class extends fi{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{m3||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let t=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!t||t.length===0||!t[0])throw new ce("Unable to retrieve accounts");await this.syncAccounts([t[0]])}catch(t){throw Lr(t)}}};var ol=class extends $t{constructor(r,o){super(r,[],o,{});this.connectorType="null";this.proxyProvider=new je(void 0,Tn);this.connectorType=r}get walletBranding(){return{name:"Wallet",id:""}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw new Error("connect called for an uninstalled wallet via the NullConnector")}disconnect(){throw new Error("disconnect called for an uninstalled wallet via the NullConnector")}promptConnection(r){throw new Error(`promptConnection called for an uninstalled wallet via the NullConnector for ${r}`)}};var nl=class extends ol{constructor(t){super("phantom",t)}get walletBranding(){return{name:"Phantom",icon:to,id:"phantom"}}};import{EthereumProvider as U3,OPTIONAL_EVENTS as F3,OPTIONAL_METHODS as B3}from"@walletconnect/ethereum-provider";import{isMobile as H3}from"react-device-detect";import{createContext as R3,useContext as I3,useEffect as xd,useRef as M3,useState as W3}from"react";import{jsx as f3}from"react/jsx-runtime";function rf({src:e,...t}){return f3("img",{src:e,...t,style:{display:"none"}})}import{useContext as Vf,useEffect as Gf,useMemo as P3,useState as A3}from"react";import{createContext as x3}from"react";var Ot={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:_m,rpcConfig:{rpcUrls:{},rpcTimeouts:{}},externalWallets:{coinbaseWallet:{connectionOptions:"all"}},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};var of=({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],r=[];e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`");for(let o of e.primary.slice(1))t.includes(o)?console.warn(`Duplicated login method: ${o}`):t.push(o);for(let o of e.overflow??[])!t.includes(o)&&!r.includes(o)?r.push(o):console.warn(`Duplicated login method: ${o}`);return{primary:t,overflow:r}};var h3=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","wallet_connect","detected_wallets","rabby_wallet"]),nf=e=>h3.has(e),af=(e,t,r)=>r.indexOf(e)===t,sf=({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(nf).filter(af):e?e.filter(nf).filter(af):Ot.appearance.walletList;var lf={id:42161,name:"Arbitrum One",network:"arbitrum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-mainnet.rpc.privy.systems"]},alchemy:{http:["https://arb-mainnet.g.alchemy.com/v2"],webSocket:["wss://arb-mainnet.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-mainnet.infura.io/v3"],webSocket:["wss://arbitrum-mainnet.infura.io/ws/v3"]},default:{http:["https://arb1.arbitrum.io/rpc"]},public:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://arbiscan.io"},default:{name:"Arbiscan",url:"https://arbiscan.io"}}};var cf={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{default:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var df={id:421614,name:"Arbitrum Sepolia",network:"arbitrum-sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://arbitrum-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]},public:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Blockscout",url:"https://sepolia-explorer.arbitrum.io"}},testnet:!0};var pf={id:43114,name:"Avalanche",network:"avalanche",nativeCurrency:{decimals:18,name:"Avalanche",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax.network/ext/bc/C/rpc"]},public:{http:["https://api.avax.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://snowtrace.io"},default:{name:"SnowTrace",url:"https://snowtrace.io"}}};var uf={id:43113,name:"Avalanche Fuji",network:"avalanche-fuji",nativeCurrency:{decimals:18,name:"Avalanche Fuji",symbol:"AVAX"},rpcUrls:{default:{http:["https://api.avax-test.network/ext/bc/C/rpc"]},public:{http:["https://api.avax-test.network/ext/bc/C/rpc"]}},blockExplorers:{etherscan:{name:"SnowTrace",url:"https://testnet.snowtrace.io"},default:{name:"SnowTrace",url:"https://testnet.snowtrace.io"}},testnet:!0};var mf={id:8453,network:"base",name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-mainnet.rpc.privy.systems"]},blast:{http:["https://base-mainnet.blastapi.io"],webSocket:["wss://base-mainnet.blastapi.io"]},default:{http:["https://mainnet.base.org"]},public:{http:["https://mainnet.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://basescan.org"},default:{name:"Basescan",url:"https://basescan.org"}},testnet:!0};var ff={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://goerli.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var hf={id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://base-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.base.org"]},public:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Blockscout",url:"https://base-sepolia.blockscout.com"}},testnet:!0};var yf={id:80085,network:"berachain-artio",name:"Berachain Artio",nativeCurrency:{name:"BERA",symbol:"BERA",decimals:18},rpcUrls:{default:{http:["https://berachain-artio.rpc.privy.systems"]},public:{http:["https://berachain-artio.rpc.privy.systems"]}},blockExplorers:{default:{name:"Beratrail",url:"https://artio.beratrail.io"}},testnet:!0};var gf={id:42220,name:"Celo Mainnet",network:"celo",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://forno.celo.org"]},infura:{http:["https://celo-mainnet.infura.io/v3"]},public:{http:["https://forno.celo.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/mainnet"},etherscan:{name:"CeloScan",url:"https://celoscan.io"}},testnet:!1};var vf={id:44787,name:"Celo Alfajores Testnet",network:"celo-alfajores",nativeCurrency:{decimals:18,name:"CELO",symbol:"CELO"},rpcUrls:{default:{http:["https://alfajores-forno.celo-testnet.org"]},infura:{http:["https://celo-alfajores.infura.io/v3"]},public:{http:["https://alfajores-forno.celo-testnet.org"]}},blockExplorers:{default:{name:"Celo Explorer",url:"https://explorer.celo.org/alfajores"},etherscan:{name:"CeloScan",url:"https://alfajores.celoscan.io/"}},testnet:!0};var Cf={id:314,name:"Filecoin - Mainnet",network:"filecoin-mainnet",nativeCurrency:{decimals:18,name:"filecoin",symbol:"FIL"},rpcUrls:{default:{http:["https://api.node.glif.io/rpc/v1"]},public:{http:["https://api.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filfox",url:"https://filfox.info/en"},filscan:{name:"Filscan",url:"https://filscan.io"},filscout:{name:"Filscout",url:"https://filscout.io/en"},glif:{name:"Glif",url:"https://explorer.glif.io"}}};var wf={id:314159,name:"Filecoin - Calibration testnet",network:"filecoin-calibration",nativeCurrency:{decimals:18,name:"testnet filecoin",symbol:"tFIL"},rpcUrls:{default:{http:["https://api.calibration.node.glif.io/rpc/v1"]},public:{http:["https://api.calibration.node.glif.io/rpc/v1"]}},blockExplorers:{default:{name:"Filscan",url:"https://calibration.filscan.io"}}};var bf={id:17069,name:"Garnet Holesky",network:"garnet-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.garnetchain.com"]},public:{http:["https://rpc.garnetchain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.garnetchain.com"}}};var Ef={id:5,network:"goerli",name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.etherscan.io"}},testnet:!0};var Tf={id:17e3,name:"Holesky",network:"holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://ethereum-holesky.publicnode.com"]},public:{http:["https://ethereum-holesky.publicnode.com"]}},blockExplorers:{etherscan:{name:"EtherScan",url:"https://holesky.etherscan.io"},default:{name:"EtherScan",url:"https://holesky.etherscan.io"}}};var Sf={id:59144,network:"linea-mainnet",name:"Linea Mainnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]},public:{http:["https://rpc.linea.build"],webSocket:["wss://rpc.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://lineascan.build"},etherscan:{name:"Etherscan",url:"https://lineascan.build"}},testnet:!1};var _f={id:59140,network:"linea-testnet",name:"Linea Goerli Testnet",nativeCurrency:{name:"Linea Ether",symbol:"ETH",decimals:18},rpcUrls:{infura:{http:["https://linea-goerli.infura.io/v3"],webSocket:["wss://linea-goerli.infura.io/ws/v3"]},default:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]},public:{http:["https://rpc.goerli.linea.build"],webSocket:["wss://rpc.goerli.linea.build"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli.lineascan.build"},etherscan:{name:"Etherscan",url:"https://goerli.lineascan.build"}},testnet:!0};var Pf={id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network"}}};var il={id:1,network:"homestead",name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://mainnet.rpc.privy.systems"]},alchemy:{http:["https://eth-mainnet.g.alchemy.com/v2"],webSocket:["wss://eth-mainnet.g.alchemy.com/v2"]},infura:{http:["https://mainnet.infura.io/v3"],webSocket:["wss://mainnet.infura.io/ws/v3"]},default:{http:["https://cloudflare-eth.com"]},public:{http:["https://cloudflare-eth.com"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://etherscan.io"},default:{name:"Etherscan",url:"https://etherscan.io"}}};var Af={id:10,name:"OP Mainnet",network:"optimism",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-mainnet.rpc.privy.systems"]},alchemy:{http:["https://opt-mainnet.g.alchemy.com/v2"],webSocket:["wss://opt-mainnet.g.alchemy.com/v2"]},infura:{http:["https://optimism-mainnet.infura.io/v3"],webSocket:["wss://optimism-mainnet.infura.io/ws/v3"]},default:{http:["https://mainnet.optimism.io"]},public:{http:["https://mainnet.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://optimistic.etherscan.io"},default:{name:"Optimism Explorer",url:"https://explorer.optimism.io"}}};var xf={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://goerli.optimism.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var kf={id:11155420,name:"Optimism Sepolia",network:"optimism-sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://optimism-sepolia.rpc.privy.systems"]},default:{http:["https://sepolia.optimism.io"]},public:{http:["https://sepolia.optimism.io"]},infura:{http:["https://optimism-sepolia.infura.io/v3"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com"}},testnet:!0};var Rf={id:137,name:"Polygon Mainnet",network:"matic",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{privy:{http:["https://polygon-mainnet.rpc.privy.systems"]},alchemy:{http:["https://polygon-mainnet.g.alchemy.com/v2"],webSocket:["wss://polygon-mainnet.g.alchemy.com/v2"]},infura:{http:["https://polygon-mainnet.infura.io/v3"],webSocket:["wss://polygon-mainnet.infura.io/ws/v3"]},default:{http:["https://polygon-rpc.com"]},public:{http:["https://polygon-rpc.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://polygonscan.com"},default:{name:"PolygonScan",url:"https://polygonscan.com"}}};var If={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{default:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var Mf={id:690,name:"Redstone",network:"redstone",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.redstonechain.com"]},public:{http:["https://rpc.redstonechain.com"]}},blockExplorers:{default:{name:"Blockscout",url:"https://explorer.redstone.xyz/"}}};var Wf={id:17001,name:"Redstone Holesky",network:"redstone-holesky",nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc.holesky.redstone.xyz"]},public:{http:["https://rpc.holesky.redstone.xyz"]}},blockExplorers:{etherscan:{name:"EtherScan",url:"https://explorer.holesky.redstone.xyz"},default:{name:"EtherScan",url:"https://explorer.holesky.redstone.xyz"}}};var Of={id:11155111,network:"sepolia",name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"SEP",decimals:18},rpcUrls:{privy:{http:["https://sepolia.rpc.privy.systems"]},alchemy:{http:["https://eth-sepolia.g.alchemy.com/v2"],webSocket:["wss://eth-sepolia.g.alchemy.com/v2"]},infura:{http:["https://sepolia.infura.io/v3"],webSocket:["wss://sepolia.infura.io/ws/v3"]},default:{http:["https://rpc.sepolia.org"]},public:{http:["https://rpc.sepolia.org"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://sepolia.etherscan.io"},default:{name:"Etherscan",url:"https://sepolia.etherscan.io"}},testnet:!0};var Lf={id:7777777,name:"Zora",network:"zora",nativeCurrency:{decimals:18,name:"Ether",symbol:"ETH"},rpcUrls:{default:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]},public:{http:["https://rpc.zora.energy"],webSocket:["wss://rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://explorer.zora.energy"}}};var Nf={id:999999999,name:"Zora Sepolia",network:"zora-sepolia",nativeCurrency:{decimals:18,name:"Zora Sepolia",symbol:"ETH"},rpcUrls:{default:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]},public:{http:["https://sepolia.rpc.zora.energy"],webSocket:["wss://sepolia.rpc.zora.energy"]}},blockExplorers:{default:{name:"Zora Sepolia Explorer",url:"https://sepolia.explorer.zora.energy/"}},testnet:!0};var Df={id:999,name:"Zora Goerli Testnet",network:"zora-testnet",nativeCurrency:{decimals:18,name:"Zora Goerli",symbol:"ETH"},rpcUrls:{default:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]},public:{http:["https://testnet.rpc.zora.energy"],webSocket:["wss://testnet.rpc.zora.energy"]}},blockExplorers:{default:{name:"Explorer",url:"https://testnet.explorer.zora.energy"}},testnet:!0};var fa=[lf,cf,df,Ef,Of,il,Af,xf,kf,Rf,If,gf,vf,Cf,wf,mf,ff,hf,yf,Pf,Sf,_f,pf,uf,Lf,Df,Nf,Tf,Mf,bf,Wf],NR=new Set(fa.map(e=>e.id));import kn from"tinycolor2";var Uf="#FFFFFF",y3="#040217",g3=Uf,v3="#1E1E1D";function C3(e){return e<.8&&e>.2&&console.warn("Background color is not light or dark enough, which could lead to accessibility issues."),e>.5?"light":"dark"}function Nr(e,t){let r=Math.max(0,Math.min(1,e.toHsl().l+t));return kn({...e.toHsl(),l:r})}var w3="#51BA81",b3="#FFB74D",E3="#EC6351",T3=Uf,S3=y3;function Ff({backgroundTheme:e,accentHex:t}){let r;switch(e){case"light":r=g3;break;case"dark":r=v3;break;default:r=e;break}let o=kn(r),n=kn(t),i=kn(w3),a=kn(b3),l=kn(E3),s=C3(o.getLuminance()),c=Nr(o,s==="light"?-.04:.11),m=Nr(o,s==="light"?-.88:.87),f=Nr(o,s==="light"?-.7:.75),u=Nr(o,s==="light"?-.43:.45).desaturate(s==="light"?60:20),C=Nr(o,s==="light"?-.08:.25).desaturate(s==="light"?60:20),g=Nr(n,.15),y=Nr(n,-.06),b=Nr(l,.3),T=Nr(a,.3),k=kn(n.getLuminance()>.5?S3:T3),S=Nr(i,-.16),x=Nr(i,.4);return{colorScheme:s,background:o.toHslString(),background2:c.toHslString(),foreground:m.toHslString(),foreground2:f.toHslString(),foreground3:u.toHslString(),foreground4:C.toHslString(),accent:n.toHslString(),accentLight:g.toHslString(),accentDark:y.toHslString(),foregroundAccent:k.toHslString(),success:i.toHslString(),successDark:S.toHslString(),successLight:x.toHslString(),error:l.toHslString(),errorLight:b.toHslString(),warn:a.toHslString(),warnLight:T.toHslString()}}function _d(e,t,r){let o=r?console.warn:()=>{},n,i,a,l,s,c,m,f,u,C,g,y,b,T,k;t?.loginMethods?(n=t.loginMethods.includes("email"),i=t.loginMethods.includes("sms"),l=t.loginMethods.includes("wallet"),s=t.loginMethods.includes("google"),c=t.loginMethods.includes("twitter"),m=t.loginMethods.includes("discord"),u=t.loginMethods.includes("spotify"),C=t.loginMethods.includes("instagram"),f=t.loginMethods.includes("tiktok"),y=t.loginMethods.includes("github"),g=t.loginMethods.includes("linkedin"),b=t.loginMethods.includes("apple"),T=t.loginMethods.includes("farcaster"),k=t.loginMethods.includes("telegram")):(n=e.emailAuth,i=e.smsAuth,l=e.walletAuth,s=e.googleOAuth,c=e.twitterOAuth,m=e.discordOAuth,y=e.githubOAuth,u=e.spotifyOAuth,C=e.instagramOAuth,f=e.tiktokOAuth,g=e.linkedinOAuth,b=e.appleOAuth,T=e.farcasterAuth,k=e.telegramAuth),typeof window<"u"&&typeof window.PublicKeyCredential!="function"?a=!1:e.passkeyAuth&&(a=!0);let S=[n,i].filter(Boolean),x=[s,c,m,y,u,C,f,g,b,T,k].filter(Boolean),R=[l].filter(Boolean);if(S.length+x.length+R.length===0)throw new Error("You must enable at least one login method");let I=t?.appearance?.showWalletLoginFirst!==void 0?t?.appearance?.showWalletLoginFirst:e.showWalletLoginFirst;I&&R.length===0?(o("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),I=!1):!I&&x.length+S.length===0&&(o("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),I=!0);let D=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&o("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let H=sf({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),K=of({input:t?.loginMethodsAndOrder}),j=t?.intl?.defaultCountry??"US",{chains:O,defaultChain:U}=_3({additionalChains:t?.additionalChains,supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain,hasRpcConfigDefined:Object.keys(t?.rpcConfig?.rpcUrls??{}).length>0}),W=!!t?.defaultChain,Ce=t?.customAuth?.getCustomAccessToken&&t?.customAuth?.enabled!==!1,Ie,Y=!(e.enforceWalletUis??!0);if(e.legacyWalletUiConfig??!0?Ce?Ie=t?.embeddedWallets?.noPromptOnSignature??!0:Ie=t?.embeddedWallets?.noPromptOnSignature??Y:Ie=Y,t?.embeddedWallets?.waitForTransactionConfirmation===!1&&Ie!==!0)throw new Error("Overriding `config.embeddedWallets.waitForTransactionConfirmation` requires that you disable wallet UIs in the dashboard.");let{requireUserPasswordOnCreate:X,...te}=t?.embeddedWallets??{};return{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,legacyWalletUiConfig:e.legacyWalletUiConfig,appearance:{logo:t?.appearance?.logo??e.logoUrl,landingHeader:t?.appearance?.landingHeader??Ot.appearance.landingHeader,loginMessage:typeof t?.appearance?.loginMessage=="string"?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,palette:Ff({backgroundTheme:t?.appearance?.theme??Ot.appearance.theme,accentHex:t?.appearance?.accentColor??e.accentColor??Ot.appearance.accentColor}),loginGroupPriority:I?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:H},loginMethods:{wallet:l,email:n,sms:i,passkey:a,google:s,twitter:c,discord:m,github:y,spotify:u,instagram:C,tiktok:f,linkedin:g,apple:b,farcaster:T,telegram:k},loginMethodsAndOrder:K,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.termsAndConditionsUrl,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacyPolicyUrl,requireUsersAcceptTerms:e.requireUsersAcceptTerms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.walletConnectCloudProjectId??Ot.walletConnectCloudProjectId,rpcConfig:{rpcUrls:t?.rpcConfig?.rpcUrls??Ot.rpcConfig.rpcUrls,rpcTimeouts:t?.rpcConfig?.rpcTimeouts??Ot.rpcConfig.rpcTimeouts},chains:O,defaultChain:U,intl:{defaultCountry:j},shouldEnforceDefaultChainOnConnect:W,captchaEnabled:e.captchaEnabled??Ot.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??Ot.externalWallets.coinbaseWallet.connectionOptions},walletConnect:{enabled:D}},embeddedWallets:{...e.embeddedWalletConfig,...typeof X=="boolean"?{requireUserOwnedRecoveryOnCreate:X}:{},...Ce?{createOnLogin:"all-users",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]}:{},waitForTransactionConfirmation:!0,priceDisplay:{primary:"fiat-currency",secondary:"native-token"},...te,noPromptOnSignature:Ie},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},customAuth:Ce?{enabled:!0,...t.customAuth}:void 0,loginConfig:{twitterOAuthOnMobileEnabled:e.twitterOAuthOnMobileEnabled??!1,telegramAuthConfiguration:e.telegramAuthConfiguration},headless:!!t?.headless,render:{standalone:t?._render?.standalone??Ot._render.standalone},fundingConfig:e.fundingConfig,fundingMethodConfig:{...t?.fundingMethodConfig??Ot.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??Ot.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??Ot.fundingMethodConfig.moonpay.useSandbox}}}}function Bf(e,t){if(!e)return{legacyCreateEmbeddedWalletFlag:t};let{appearance:r,additionalChains:o,supportedChains:n,defaultChain:i,...a}=e;return{...a,...o?{additionalChains:o.map(s=>s.id)}:void 0,...n?{supportedChains:n.map(s=>s.id)}:void 0,...i?{defaultChain:i.id}:void 0,legacyCreateEmbeddedWalletFlag:t}}function _3({additionalChains:e,supportedChains:t,defaultChainFromConfig:r,hasRpcConfigDefined:o}){let n;if(e&&t&&console.warn("You should only specify one of `additionalChains` or `supportedChains`. Using `supportedChains`."),t){if(t.length===0)throw new Error("`supportedChains` must contain at least one chain");t.filter(s=>s.rpcUrls.privyWalletOverride).length>0&&o&&console.warn("You have specified at least one `supportedChain` with `privyWalletOverride` but also have `rpcConfig` defined. The `rpcConfig` will be ignored. `rpcConfig` is deprecated and you should use `privyWalletOverride` in a `supportedChain`."),n=t.map(s=>s.rpcUrls.privyWalletOverride?s:fa.find(m=>m.id===s.id)??s)}else n=fa.concat(e??[]);let i=t?n[0]:il,a=r??i;if(!n.find(l=>l.id===a.id))throw new Error("`defaultChain` must be included in `supportedChains`");return{chains:n,defaultChain:a}}var Hf=function(e,t=0){let r=3735928559^t,o=1103547991^t;for(let n=0,i;n<e.length;n++)i=e.charCodeAt(n),r=Math.imul(r^i,2654435761),o=Math.imul(o^i,1597334677);return r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(o^o>>>13,3266489909),o=Math.imul(o^o>>>16,2246822507),o^=Math.imul(r^r>>>13,3266489909),4294967296*(2097151&o)+(r>>>0)};import{jsx as k3}from"react/jsx-runtime";var qf={showWalletLoginFirst:!0,allowlistConfig:{errorTitle:null,errorDetail:null,errorCtaText:null,errorCtaLink:null},walletAuth:!0,emailAuth:!0,smsAuth:!1,googleOAuth:!1,twitterOAuth:!1,discordOAuth:!1,githubOAuth:!1,linkedinOAuth:!1,appleOAuth:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{createOnLogin:"off",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]},fiatOnRampEnabled:!1,captchaEnabled:!1,captchaSiteKey:""},Pd=_d(qf,void 0,!1),Ad=x3({appConfig:Pd,isServerConfigLoaded:!1}),zf=({children:e,legacyCreateEmbeddedWalletFlag:t,client:r,clientConfig:o})=>{let[n,i]=A3(null),a=P3(()=>_d(n??qf,o,!!n),[n,o]);return Gf(()=>{if(!n)return;let l=Bf(o,t),s=Hf(JSON.stringify(l)).toString(),c=`privy:sent:${n.id}:${s}`;localStorage.getItem(c)||(r.createAnalyticsEvent({eventName:"sdk_initialize",payload:l}),localStorage.setItem(c,"t"))},[o,t,n]),Gf(()=>{n||(async()=>{try{let s=await r.getServerConfig();s.customApiUrl&&r.updateApiUrl(s.customApiUrl),i(s)}catch(s){console.warn("Error generating app config: ",s)}})()},[]),k3(Ad.Provider,{value:{appConfig:a,isServerConfigLoaded:!!n},children:e})},Ve=()=>{let{appConfig:e}=Vf(Ad);return e},al=()=>{let{isServerConfigLoaded:e}=Vf(Ad);return e};var E=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import{jsx as L3,jsxs as N3}from"react/jsx-runtime";var $f=R3({ready:!1,app:Pd,currentScreen:null,lastScreen:null,navigate:E,navigateBack:E,resetNavigation:E,setModalData:E,onUserCloseViaDialogOrKeybindRef:void 0}),O3=["LANDING","CONNECT_ONLY_LANDING_SCREEN",null],Kf=e=>{let t=Ve(),r=e.authenticated,[o,n]=W3(e.initialScreen);xd(()=>{!r&&!O3.includes(e.initialScreen)&&e.setInitialScreen(null)},[r]);let i=M3(null);xd(()=>{e.open||(i.current=null)},[e.open]),xd(()=>{i.current=null},[e.initialScreen]);let a={ready:!!t.id,app:t,data:e.data,setModalData:e.setModalData,currentScreen:e.initialScreen,lastScreen:o,navigate:(l,s=!0)=>{e.setInitialScreen(l),s&&n(e.initialScreen)},navigateBack:()=>{e.setInitialScreen(o)},resetNavigation:()=>{e.setInitialScreen(null),n(null)},onUserCloseViaDialogOrKeybindRef:i};return N3($f.Provider,{value:a,children:[(typeof t.appearance.logo=="string"||t.appearance.logo?.type==="img")&&L3(rf,{src:typeof t.appearance.logo=="string"?t.appearance.logo:t.appearance.logo.props.src}),e.children]})},_=()=>I3($f);import{jsx as yi,jsxs as D3}from"react/jsx-runtime";var ha=({style:e,...t})=>{let{app:r}=_();return D3("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...e},...t,children:[yi("rect",{width:"28",height:"28",rx:"3",fill:r?.appearance.palette.colorScheme==="dark"?"#3396ff":"#141414"}),yi("g",{clipPath:"url(#clip0_1765_9946)",children:yi("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),yi("defs",{children:yi("clipPath",{id:"clip0_1765_9946",children:yi("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};var Dr=class extends $t{constructor(r,o,n,i,a,l,s,c){super(c||"unknown",n,i,o);this.connectorType="wallet_connect_v2";this.privyAppId=l,this.privyAppName=s,this.walletConnectCloudProjectId=r,this.rpcConfig=o,this.shouldEnforceDefaultChainOnConnect=a,this.proxyProvider=new je(void 0,this.rpcTimeoutDuration),c&&(this.walletEntry=Is[c],this.walletClientType=c)}async initialize(){let r=await this.createProvider();if(this.provider=r,this.proxyProvider.setWalletProvider(r),this.subscribeListeners(),r.session){if(this.walletProvider?.session?.peer.metadata.url){let n=Rs(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=n?.entry,this.walletClientType=n?.walletClientType||"unknown"}this.connected=!0,await this.syncAccounts()}this.initialized=!0,this.emit("initialized");let{WalletConnectModal:o}=await import("@walletconnect/modal");this.modal=new o({projectId:this.walletConnectCloudProjectId,themeVariables:{"--wcm-z-index":"1000000"}}),this.modal.subscribeModal(n=>{!n.open&&!this.walletProvider?.session&&this.onQrModalClosed&&this.onQrModalClosed()})}async connect(r){return r.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){return this.walletClientType==="metamask"?{name:"MetaMask",icon:ui,id:"io.metamask"}:{name:um(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:this.walletProvider?.session?.peer.metadata.icons?.[0]||ha,id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(r){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletEntry=Is[r],this.walletClientType=r,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,wm(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise((r,o)=>{let n=()=>{o(new ci)};this.onQrModalClosed=n,(async()=>{let a="",l=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(l?.length&&(a=l[0]),!a||a==="")throw new ce("Unable to retrieve address");if(this.walletProvider?.session?.peer.metadata.url){let s=Rs(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=s?.entry,this.walletClientType=s?.walletClientType||"unknown",this.proxyProvider.rpcTimeoutDuration=di(this.rpcConfig,this.walletClientType)}this.connected=!0,await this.syncAccounts(l),r()})().catch(a=>{if(a){o(Lr(a));return}o(new ce("Unknown error during connection"))}).finally(()=>this.modal?.closeModal())})}disconnect(){this.walletProvider?.disconnect().then(()=>this.onDisconnect()).catch(()=>console.warn("Unable to disconnect Wallet Connect provider"))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(r){this.proxyProvider.setWalletProvider(r)}async createProvider(){let r={};for(let a of this.chains){let l=fm(a.id,this.chains,this.rpcConfig,this.privyAppId);l&&(r[a.id]=l)}let o=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],n=this.chains.map(a=>a.id),i=await U3.init({projectId:this.walletConnectCloudProjectId,chains:o,optionalChains:n,optionalEvents:F3,optionalMethods:B3,rpcMap:r,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.toString(),icons:[]}});return i.on("display_uri",a=>{if(i.signer.abortPairingAttempt(),H3&&this.walletEntry){let{redirect:l,href:s}=gm(a,this.walletEntry);bm({href:s,name:this.walletEntry.displayName}),this.redirectUri=l;let c=vm(a,this.walletEntry);c?.redirect&&(this.fallbackUniversalRedirectUri=c.redirect),Ms(l,"_self")}else this.modal?.openModal({uri:a,chains:[this.defaultChain.id]})}),i.on("connect",()=>{if(this.modal?.closeModal(),i.session?.peer.metadata.url){let a=Rs(i.session?.peer.metadata.url);this.walletEntry=a?.entry,this.walletClientType=a?.walletClientType||"unknown"}}),i}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await this.walletProvider?.enable()}};var Rd=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses")?.split(" ").filter(o=>G3(o)).map(o=>jf(o));return t?.length?!!e?.linkedAccounts.filter(o=>o.type=="wallet"&&t.includes(o.address)).length:!1},di=(e,t)=>e.rpcTimeouts?e.rpcTimeouts[t]||Tn:Tn,ya=class extends V3{constructor(r,o,n,i,a,l,s,c,m,f,u){super();this.getEthereumProvider=()=>{let r=this.wallets[0],o=this.walletConnectors.find(n=>n.wallets.find(i=>i.address===r?.address));return!r||!o?new je:o.proxyProvider};this.privyAppId=r,this.walletConnectCloudProjectId=o,this.rpcConfig=n,this.chains=i,this.defaultChain=a,this.walletConnectors=[],this.initialized=!1,this.store=l,this.walletList=s,this.shouldEnforceDefaultChainOnConnect=c,this.externalWalletConfig=m,this.privyAppName=f,this.privyAppLogo=u,this.storedConnections=kd()}get wallets(){let r=new Set,o=this.walletConnectors.flatMap(i=>i.wallets).sort((i,a)=>i.connectedAt&&a.connectedAt?a.connectedAt-i.connectedAt:0).filter(i=>{let a=`${i.address}${i.walletClientType}${i.connectorType}`;return r.has(a)?!1:(r.add(a),!0)}),n=o.findIndex(i=>i.address===(this.activeWallet?this.activeWallet:"unknown"));return n>=0&&o.unshift(o.splice(n,1)[0]),o}async initialize(){if(this.initialized)return;Q.get(vd)&&(Q.getKeys().forEach(o=>{o.startsWith("walletconnect")&&Q.del(o)}),Q.del(vd));let r=mm(this.store,this.walletList,this.externalWalletConfig).then(o=>{o.forEach(({type:n,eip6963InjectedProvider:i,legacyInjectedProvider:a})=>{this.createWalletConnector("injected",n,{eip6963InjectedProvider:i,legacyInjectedProvider:a})})});this.walletList.includes("coinbase_wallet")&&this.createWalletConnector("coinbase_wallet","coinbase_wallet"),!No()&&this.walletList.includes("phantom")&&this.createWalletConnector("phantom","phantom"),this.externalWalletConfig.walletConnect.enabled&&this.createWalletConnector("wallet_connect_v2","unknown"),await r,this.initialized=!0}findWalletConnector(r,o){return r==="wallet_connect_v2"?this.walletConnectors.find(n=>n.connectorType===r)??null:this.walletConnectors.find(n=>n.connectorType===r&&n.walletClientType===o)??null}onInitialized(r){r.wallets.forEach(o=>{let n=this.storedConnections.find(i=>i.address===o.address&&i.connectorType===o.connectorType&&i.walletClientType===o.walletClientType);n&&(o.connectedAt=n.connectedAt)}),this.saveConnectionHistory(),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(r){r.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnector(r,o,n,i){let a=this.findWalletConnector("embedded","privy");if(a)a.proxyProvider.walletProxy=r;else{let l=new ua(r,o,this.rpcConfig,this.chains,i,n.id),s=new ma(l,this.chains,n,this.rpcConfig);this.addWalletConnector(s)}}addImportedWalletConnector(r,o,n,i){let a=this.findWalletConnector("embedded_imported","privy");if(a)a.proxyProvider.walletProxy=r;else{let l=new ua(r,o,this.rpcConfig,this.chains,i,n.id),s=!0,c=new ma(l,this.chains,n,this.rpcConfig,s);this.addWalletConnector(c)}}removeEmbeddedWalletConnector(){let r=this.findWalletConnector("embedded","privy");if(r){let o=this.walletConnectors.indexOf(r);this.walletConnectors.splice(o,1),this.saveConnectionHistory(),this.storedConnections=kd(),this.emit("walletsUpdated")}}removeImportedWalletConnector(){let r=this.findWalletConnector("embedded_imported","privy");if(r){let o=this.walletConnectors.indexOf(r);this.walletConnectors.splice(o,1),this.saveConnectionHistory(),this.storedConnections=kd(),this.emit("walletsUpdated")}}async createWalletConnector(r,o,n){let i=this.findWalletConnector(r,o);if(i)return i instanceof Dr&&i.resetConnection(o),i;let l=(()=>{if(r==="injected"){if(o==="metamask"&&n?.eip6963InjectedProvider)return new rl(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask");if(o==="metamask"&&n?.legacyInjectedProvider)return new hi(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask");if(o==="phantom"&&n?.legacyInjectedProvider)return new hi(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom");if(n?.legacyInjectedProvider&&o==="unknown_browser_extension")return new hi(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider);if(n?.eip6963InjectedProvider)return new fi(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,o)}else return r==="coinbase_wallet"?new tl(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):r==="phantom"?new nl(this.defaultChain):new Dr(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,this.privyAppName,o)})();return l&&this.addWalletConnector(l),l||null}addWalletConnector(r){this.walletConnectors.push(r),r.on("initialized",()=>this.onInitialized(r)),r.on("walletsUpdated",()=>this.onWalletsUpdated(r)),r.initialize().catch(o=>{console.debug("Failed to initialize connector",o)})}saveConnectionHistory(){let r=this.wallets.map(o=>({address:o.address,connectorType:o.connectorType,walletClientType:o.walletClientType,connectedAt:o.connectedAt}));Q.put(Cd,r)}async activeWalletSign(r){let o=this.wallets,n=o.length>0?o[0]:null;return n?n.sign(r):null}setActiveWallet(r){this.activeWallet=jf(r),this.emit("walletsUpdated")}};function el(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){let o=e[r],n=t[r];if(o?.address!==n?.address||o?.chainId!==n?.chainId||o?.connectorType!==n?.connectorType||o?.connectedAt!==n?.connectedAt||o?.walletClientType!==n?.walletClientType||o?.isConnected!==n?.isConnected||o?.linked!==n?.linked)return!1}return!0}var q3=e=>e&&typeof e.address=="string"&&typeof e.connectorType=="string"&&typeof e.walletClientType=="string"&&typeof e.connectedAt=="number",kd=()=>{let e=Q.get(Cd);return e&&Array.isArray(e)&&e.map(o=>q3(o)).every(Boolean)?e:[]};import{ofetch as z3}from"ofetch";var $3=[vs,ws,Cs,Ts],sl=class{constructor({appId:t,appClientId:r,client:o,defaults:n}){this.appId=t,this.appClientId=r,this.clientAnalyticsId=o.clientAnalyticsId,this.sdkVersion=fd,this.client=o,this.defaults=n,this.fallbackApiUrl=o.fallbackApiUrl,this.baseFetch=z3.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:i,options:a})=>{let l=new Headers(a.headers);l.set("privy-app-id",this.appId),this.appClientId&&l.set("privy-client-id",this.appClientId),l.set("privy-ca-id",this.clientAnalyticsId||""),l.set("privy-client",`react-auth:${this.sdkVersion}`);let s=$3.includes(i.toString());if(!l.has("authorization")){let c=await this.client.getAccessToken({disableAutoRefresh:s});c!==null&&l.set("authorization",`Bearer ${c}`)}a.headers=l,a.retryDelay&&(a.retryDelay=a.retryDelay*3)},onRequestError:({error:i})=>{if(i instanceof DOMException&&i.name==="AbortError")throw new ys}})}async get(t,r){try{return await this.baseFetch(t,r)}catch(o){throw le(o)}}async post(t,r,o){try{return await this.baseFetch(t,{method:"POST",...r?{body:r}:{},...o})}catch(n){throw le(n)}}async delete(t,r){try{return await this.baseFetch(t,{method:"DELETE",...r})}catch(o){throw le(o)}}};var Yf=e=>({challenge:e.challenge,allowCredentials:e.allow_credentials?.map(t=>({id:t.id,type:t.type,transports:t.transports}))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification});import Ho from"js-cookie";function Zf(e){return e instanceof Lo?"email":e instanceof Do?"sms":e instanceof To?"siwe":e instanceof ri?"custom_auth":e instanceof Jr?e.meta.provider:null}import*as Qf from"jose";var _r=class{static parse(t){try{return new _r(t)}catch{return null}}constructor(t){this.value=t,this._decoded=Qf.decodeJwt(t)}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(t=0){let r=Date.now(),o=(this.expiration-t)*1e3;return r>=o}};var K3=30,ll=class{constructor(){this.authenticateOnce=new Le(async t=>this._authenticate(t)),this.linkOnce=new Le(async t=>this._link(t)),this.refreshOnce=new Le(this._refresh.bind(this)),this.destroyOnce=new Le(this._destroy.bind(this)),this.forkSessionOnce=new Le(this._forkSession.bind(this))}get token(){try{let t=Q.get(Cn);return typeof t=="string"?new _r(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=Q.get(Ls);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=Q.get(aa);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}getProviderAccessToken(t){try{let r=Q.get(la(t));if(typeof r=="string"){let o=new _r(r);return o.isExpired()?(Q.del(la(t)),null):o.value}else return null}catch(r){return console.error(r),null}}get mightHaveServerCookies(){try{let t=Ho.get(Ns);return t!==void 0&&t.length>0}catch(t){console.error(t)}return!1}hasRefreshCredentials(){return this.mightHaveServerCookies||typeof this.token=="string"&&typeof this.refreshToken=="string"&&this.refreshToken!==Mm}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=_r.parse(this.token);return t!==null&&!t.isExpired(K3)}authenticate(t){return this.authenticateOnce.execute(t)}link(t){return this.linkOnce.execute(t)}refresh(){return this.refreshOnce.execute()}forkSession(){return this.forkSessionOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(t,r){typeof r=="string"?Q.put(la(t),r):Q.del(la(t))}async _authenticate(t){try{let r=await t.authenticate(),{user:o,is_new_user:n,oauth_tokens:i}=r;this.handleTokenResponse(r);let a=i,l=a?{provider:a.provider,accessToken:a.access_token,accessTokenExpiresInSeconds:a.access_token_expires_in_seconds,refreshToken:a.refresh_token,refreshTokenExpiresInSeconds:i.refresh_token_expires_in_seconds,scopes:a.scopes}:void 0,s=Zf(t);return s&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:s,isNewUser:n}}),s==="siwe"&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}}),{user:zt(o),isNewUser:n,oAuthTokens:l}}catch(r){throw console.warn("Error authenticating session"),tt(r)}}async _link(t){try{let r=await t.link(),o=r.oauth_tokens,n=o?{provider:o.provider,accessToken:o.access_token,accessTokenExpiresInSeconds:o.access_token_expires_in_seconds,refreshToken:o.refresh_token,refreshTokenExpiresInSeconds:o.refresh_token_expires_in_seconds,scopes:o.scopes}:void 0;return{user:zt(r),oAuthTokens:n}}catch(r){throw console.warn("Error linking account"),tt(r)}}async _refresh(){if(!this.api)throw new w("Session has no API instance");if(!this.client)throw new w("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,r=this.refreshToken,o=this.forkedToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let n;if(t&&r||this.mightHaveServerCookies){let i={};t&&(i.authorization=`Bearer ${t}`);let a=r?{refresh_token:r}:{};n=await this.api.post(vs,a,{headers:i}),o&&this.clearForkedToken()}else if(o)n=await this.api.post(ws,{refresh_token:o}),this.clearForkedToken();else return null;return this.handleTokenResponse(n),zt(n.user)}catch(n){if(n instanceof Mt&&n.privyErrorCode==="missing_or_invalid_token")return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw tt(n)}}handleTokenResponse(t){t.session_update_action?t.session_update_action==="set"?(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token)):t.session_update_action==="clear"?this.destroyLocalState():t.session_update_action==="ignore"&&t.token&&(this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token)):(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token),t.identity_token&&this.storeIdentityToken(t.identity_token))}async _destroy(){try{await this.api?.post(Cs,{refresh_token:this.refreshToken})}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new w("Session has no API instance");let t=this.refreshToken;try{let r=await this.api.post(Eu,{refresh_token:t});return this.storeRefreshToken(r.refresh_token),this.storeToken(r.token),r.new_session_refresh_token}catch(r){throw tt(r)}}destroyLocalState(){this.storeRefreshToken(null),this.storeToken(null),this.clearIdentityToken(),this.clearForkedToken()}storeToken(t){if(typeof t=="string"){let r=Q.get(Cn);if(Q.put(Cn,t),!this.client?.useServerCookies){let o=_r.parse(t)?.expiration;Ho.set(hd,t,{sameSite:"Strict",secure:!0,expires:o?new Date(o*1e3):void 0})}r!==t&&this.client?.onStoreToken?.(t)}else Q.del(Cn),Ho.remove(hd),this.client?.onDeleteToken?.()}storeRefreshToken(t){typeof t=="string"?(Q.put(Ls,t),this.client?.useServerCookies||Ho.set(Ns,"t",{sameSite:"Strict",secure:!0,expires:30})):(Q.del(Ls),Ho.remove(Am),Ho.remove(Ns))}storeIdentityToken(t){if(this.client?.useServerCookies)return;Q.put(yd,t);let r=_r.parse(t)?.expiration;Ho.set(gd,t,{sameSite:"Strict",secure:!0,expires:r?new Date(r*1e3):void 0})}clearIdentityToken(){Q.del(yd),Ho.remove(gd)}clearForkedToken(){Q.del(aa)}};var Id,cl,Jf,ga=class{constructor(t){hs(this,cl);this.apiUrl=t.apiUrl||Ws,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!!t.apiUrl&&t.apiUrl.startsWith("https://privy."),this.timeout=t.timeout||Pm,this.appId=t.appId,this.appClientId=t.appClientId,this.clientAnalyticsId=bu(this,cl,Jf).call(this),Id||(Id=new ll),this.session=Id,this.api=this.generateApi(),this.session.client=this}initializeConnectorManager({walletConnectCloudProjectId:t,rpcConfig:r,chains:o,defaultChain:n,store:i,walletList:a,shouldEnforceDefaultChainOnConnect:l,externalWalletConfig:s,appName:c}){this.connectors||(this.connectors=new ya(this.appId,t,r,o,n,i,a,l,s,c))}sessionHasActiveToken(){return this.session.hasActiveToken()}generateApi(){let t=new sl({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=t,t}updateApiUrl(t){this.apiUrl=t||this.fallbackApiUrl,this.api=this.generateApi(),t&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new w("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new w("No auth flow in progress.");let{oAuthTokens:t}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:t}}storeProviderAccessToken(t,r){this.session.storeProviderAccessToken(t,r)}getProviderAccessToken(t){return this.session.getProviderAccessToken(t)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(t){t.linkedAccounts.filter(o=>o.type==="cross_app").forEach(o=>{this.storeProviderAccessToken(o.providerApp.id,null)})}startAuthFlow(t){return t.api=this.api,this.authFlow=t,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(tm,{action:"verify"})}catch(t){throw le(t)}}async initMfaPasskeyVerification(){try{let t=await this.api.post(rm,{});return Yf(t.options)}catch(t){throw le(t)}}async acceptTerms(){try{let t=await this.api.post(om,{});return zt(t)}catch(t){throw tt(t)}}async unlinkEmail(t){try{let r=await this.api.post(Lu,{address:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkPhone(t){try{let r=await this.api.post(Fu,{phoneNumber:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkWallet(t){try{let r=await this.api.post(Pu,{address:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkOAuth(t,r){try{let o=await this.api.post(Vu,{provider:t,subject:r});return await this.getAuthenticatedUser()??zt(o)}catch(o){throw tt(o)}}async unlinkFarcaster(t){try{let r=await this.api.post(Iu,{fid:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkTelegram(t){try{let r=await this.api.post(em,{telegram_user_id:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async unlinkPasskey(t){try{let r=await this.api.post(Qu,{credential_id:t});return await this.getAuthenticatedUser()??zt(r)}catch(r){throw tt(r)}}async createAnalyticsEvent({eventName:t,payload:r,timestamp:o,options:n}){if(!(typeof window>"u"))try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(Ts,{event_name:t,client_id:this.clientAnalyticsId,payload:{...r||{},clientTimestamp:o?o.toISOString():new Date().toISOString()}},{retry:-1,keepalive:n?.keepAlive??!1})}catch{}}async signMoonpayOnRampUrl(t){try{return this.api.post(im,t)}catch(r){throw tt(r)}}async initCoinbaseOnRamp(t){try{return this.api.post(am,t)}catch(r){throw tt(r)}}async getCoinbaseOnRampStatus({partnerUserId:t}){try{return this.api.get(`${sm}?partnerUserId=${t}`)}catch(r){throw tt(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){return this.session.hasActiveToken()?_r.parse(this.session.token)?.audience!==this.appId?(await this.logout(),null):this.session.token:!t?.disableAutoRefresh&&this.session.hasRefreshCredentials()?(await this.session.refresh(),this.session.token):null}async getServerConfig(){try{let t={},r=this.session.token;r&&(t.authorization=`Bearer ${r}`);let o=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl,headers:t}),n=o.telegram_auth_config?{botId:o.telegram_auth_config.bot_id,botName:o.telegram_auth_config.bot_name,linkEnabled:o.telegram_auth_config.link_enabled,seamlessAuthEnabled:o.telegram_auth_config.seamless_auth_enabled}:void 0,i=o.funding_config?{methods:o.funding_config.methods,defaultRecommendedAmount:o.funding_config.default_recommended_amount,defaultRecommendedCurrency:o.funding_config.default_recommended_currency,promptFundingOnWalletCreation:o.funding_config.prompt_funding_on_wallet_creation}:void 0;return{id:o.id,name:o.name,verificationKey:o.verification_key,logoUrl:o.logo_url||void 0,accentColor:o.accent_color||void 0,showWalletLoginFirst:o.show_wallet_login_first,allowlistConfig:{errorTitle:o.allowlist_config.error_title,errorDetail:o.allowlist_config.error_detail,errorCtaText:o.allowlist_config.cta_text,errorCtaLink:o.allowlist_config.cta_link},walletAuth:o.wallet_auth,emailAuth:o.email_auth,smsAuth:o.sms_auth,googleOAuth:o.google_oauth,twitterOAuth:o.twitter_oauth,discordOAuth:o.discord_oauth,githubOAuth:o.github_oauth,spotifyOAuth:o.spotify_oauth,instagramOAuth:o.instagram_oauth,tiktokOAuth:o.tiktok_oauth,linkedinOAuth:o.linkedin_oauth,appleOAuth:o.apple_oauth,farcasterAuth:o.farcaster_auth,passkeyAuth:o.passkey_auth,telegramAuth:o.telegram_auth,termsAndConditionsUrl:o.terms_and_conditions_url,embeddedWalletConfig:{createOnLogin:o.embedded_wallet_config?.create_on_login,userOwnedRecoveryOptions:o.embedded_wallet_config.user_owned_recovery_options,requireUserOwnedRecoveryOnCreate:o.embedded_wallet_config.require_user_owned_recovery_on_create},privacyPolicyUrl:o.privacy_policy_url,requireUsersAcceptTerms:o.require_users_accept_terms,customApiUrl:o.custom_api_url,walletConnectCloudProjectId:o.wallet_connect_cloud_project_id,fiatOnRampEnabled:o.fiat_on_ramp_enabled,captchaEnabled:o.captcha_enabled,captchaSiteKey:o.captcha_site_key,twitterOAuthOnMobileEnabled:o.twitter_oauth_on_mobile_enabled,createdAt:new Date(o.created_at*1e3),updatedAt:new Date(o.updated_at*1e3),mfaMethods:o.mfa_methods,enforceWalletUis:o.enforce_wallet_uis,legacyWalletUiConfig:o.legacy_wallet_ui_config,telegramAuthConfiguration:n,fundingConfig:i}}catch(t){throw tt(t)}}async getUsdTokenPrice(t){try{return(await this.api.get(`/api/v1/token_price?chainId=${t.id}&tokenSymbol=${t.nativeCurrency.symbol}`)).usd}catch{console.error(`Unable to fetch token price for chain with id ${t.id}`);return}}async requestFarcasterSignerStatus(t){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:t})}catch(r){throw console.error("Unable to fetch Farcaster signer status"),r}}async forkSession(){return await this.session.forkSession()}async generateSiweNonce({address:t,captchaToken:r}){try{return(await this.api.post(Tu,{address:t,token:r})).nonce}catch(o){throw tt(o)}}async authenticateWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:i}){return await this.api.post(Su,{message:t,signature:r,chainId:o,walletClientType:n,connectorType:i})}async linkWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:i}){return await this.api.post(_u,{message:t,signature:r,chainId:o,walletClientType:n,connectorType:i})}async linkWithSiwe({message:t,signature:r,chainId:o,walletClientType:n,connectorType:i}){try{let a=await this.linkWithSiweInternal({message:t,signature:r,chainId:o,walletClientType:n,connectorType:i});return zt(a)}catch(a){throw tt(a)}}};cl=new WeakSet,Jf=function(){if(typeof window>"u")return null;try{let r=Q.get(sa);if(typeof r=="string"&&r.length>0)return r}catch{}let t=j3();try{return Q.put(sa,t),t}catch{return t}};import{Turnstile as e0}from"@marsidev/react-turnstile";import{useEffect as t0,useMemo as r0}from"react";import{useMemo as Y3,useRef as Z3,useContext as Q3,useState as Md,createContext as J3}from"react";import{jsx as X3}from"react/jsx-runtime";var Xf=J3({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:E,setError:E,setExecuting:E,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:E,reset:E,execute:E}),ir=class extends et{constructor(r,o,n){super(r||"Captcha failed");this.type="Captcha";o instanceof Error&&(this.cause=o),this.privyErrorCode=n}},eh=({children:e,id:t,captchaSiteKey:r,captchaEnabled:o})=>{let n=Z3(null),[i,a]=Md(),[l,s]=Md(),[c,m]=Md(!1),f=Y3(()=>o?!c&&!i&&!l?{status:"ready"}:c&&!i&&!l?{status:"loading"}:i&&!l?{status:"success",token:i}:l?{status:"error",error:l}:{status:"ready"}:{status:"disabled"},[o,i,l,c]);return X3(Xf.Provider,{value:{...f,ref:n,enabled:o,siteKey:r,appId:t,setToken:a,setError:s,setExecuting:m,remove(){o&&(n.current?.remove(),m(!1),s(void 0),a(void 0))},reset(){o&&(n.current?.reset(),m(!1),s(void 0),a(void 0))},execute(){o&&(m(!0),n.current?.execute())},async waitForResult(){if(!o)return"";try{return await pm(()=>n.current?.getResponse(),{interval:200,timeout:2e4})}catch{throw new ir("Captcha failed",null,"captcha_timeout")}}},children:e})},be=()=>Q3(Xf);import{jsx as th}from"react/jsx-runtime";var Wd=e=>{let{enabled:t,siteKey:r,appId:o,setError:n,setToken:i,setExecuting:a,ref:l}=be(),[,s]=r0(()=>r?.split("t:")||[],[r]);if(t0(()=>l.current?.remove,[]),!t)return null;if(!s)throw new Error("Unsupported captcha site key");return th("div",{className:"hidden h-0 w-0",children:th(e0,{...e,ref:l,siteKey:s,options:{action:o,size:"invisible",...e.delayedExecution?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{e.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{e.onError?.(),n("Captcha failed"),a(!1)},onSuccess:c=>{e.onSuccess?.(c),i(c),a(!1)},onExpire:()=>{e.onExpire?.();try{l.current?.reset(),n(void 0),i(void 0)}catch{n("expired_and_failed_reset")}}})})};import{useCallback as jS,useEffect as Jv,useRef as YS,useState as ZS}from"react";import tC from"styled-components";import{createContext as o0,useContext as n0}from"react";var Od=o0({isNewUserThisSession:!1,linkingOrConnectingHint:null,walletConnectionStatus:null,connectors:[],rpcConfig:{rpcUrls:{}},showFiatPrices:!0,chains:[],clientAnalyticsId:null,pendingTransaction:null,appId:"notAdded",nativeTokenSymbolForChainId:E,initializeWalletProxy:E,getAuthMeta:E,getAuthFlow:E,closePrivyModal:E,openPrivyModal:E,connectWallet:E,initLoginWithWallet:E,loginWithWallet:E,initLoginWithFarcaster:E,loginWithFarcaster:E,loginWithCode:E,initLoginWithEmail:E,initLoginWithSms:E,initUpdateEmail:E,initUpdatePhone:E,resendEmailCode:E,resendSmsCode:E,initLoginWithHeadlessOAuth:E,loginWithHeadlessOAuth:E,crossAppAuthFlow:E,initLoginWithOAuth:E,recoveryOAuthFlow:E,loginWithOAuth:E,initLoginWithPasskey:E,loginWithPasskey:E,initLinkWithPasskey:E,linkWithPasskey:E,refreshUser:E,walletProxy:null,createAnalyticsEvent:E,acceptTerms:E,getUsdTokenPrice:E,recoverEmbeddedEthereumWallet:E,getMoonpaySignedUrl:E,initCoinbaseOnRamp:E,getCoinbaseOnRampStatus:E,updateWallets:E,fundWallet:E,setReadyToTrue:E,requestFarcasterSignerStatus:E,initLoginWithTelegram:E,loginWithTelegram:E,generateSiweMessage:E,linkWithSiwe:E,embeddedSolanaWallet:null,createEmbeddedSolanaWallet:E,recoverEmbeddedSolanaWallet:E,solanaSignMessage:E}),M=()=>n0(Od);import{createContext as i0,useContext as a0}from"react";var Se=i0({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:E,login:E,connectOrCreateWallet:E,linkEmail:E,linkPhone:E,linkFarcaster:E,linkWallet:E,linkCrossAppAccount:E,linkGoogle:E,linkTwitter:E,linkDiscord:E,linkGithub:E,linkSpotify:E,linkInstagram:E,linkTelegram:E,linkTiktok:E,linkLinkedIn:E,linkApple:E,linkPasskey:E,updateEmail:E,updatePhone:E,logout:E,getAccessToken:E,getEthereumProvider:E,getEthersProvider:E,getWeb3jsProvider:E,unlinkEmail:E,unlinkPhone:E,unlinkWallet:E,unlinkGoogle:E,unlinkTwitter:E,unlinkDiscord:E,unlinkGithub:E,unlinkSpotify:E,unlinkInstagram:E,unlinkTiktok:E,unlinkLinkedIn:E,unlinkApple:E,unlinkCrossAppAccount:E,unlinkFarcaster:E,unlinkTelegram:E,unlinkPasskey:E,setActiveWallet:E,forkSession:E,createWallet:E,importWallet:E,signMessage:E,signTypedData:E,enrollInMfa:E,initEnrollmentWithSms:E,initEnrollmentWithTotp:E,initEnrollmentWithPasskey:E,promptMfa:E,init:E,submitEnrollmentWithSms:E,submitEnrollmentWithTotp:E,submitEnrollmentWithPasskey:E,unenroll:E,submit:E,cancel:E,sendTransaction:E,exportWallet:E,setWalletPassword:E,setWalletRecovery:E,requestFarcasterSignerFromWarpcast:E,getFarcasterSignerPublicKey:E,signFarcasterMessage:E,initLoginWithEmail:E,initLoginWithSms:E,otpState:{status:"initial"},loginWithCode:E,fundWallet:E,initLoginWithHeadlessOAuth:E,loginWithHeadlessOAuth:E,generateSiweMessage:E,linkWithSiwe:E,signMessageWithCrossAppWallet:E,signTypedDataWithCrossAppWallet:E,sendTransactionWithCrossAppWallet:E,isHeadlessOAuthLoading:!1,isModalOpen:!1,mfaMethods:[]}),q=()=>a0(Se);import{useEffect as s0,useState as l0}from"react";var rh=e=>{let[t,r]=l0("auto");return s0(()=>{let o=new ResizeObserver(n=>{r(n[0]?.contentRect.height??"auto")});return e.current&&o.observe(e.current),()=>{e.current&&o.unobserve(e.current)}},[e.current]),t};import{createContext as c0,useContext as d0,useEffect as p0}from"react";var oh={login:{onComplete:[],onError:[],onOAuthLoginComplete:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},setWalletRecovery:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]}},Ld=c0(void 0),nh=()=>d0(Ld);function Ae(e,t){if(!t)return;let o=nh().current[e];return p0(()=>{for(let[n,i]of Object.entries(t))o.hasOwnProperty(n)||console.warn(`Invalid event type "${n}" for action "${e}"`),o[n]?.push(i);return()=>{for(let[n,i]of Object.entries(t))o.hasOwnProperty(n)||console.warn(`Invalid event type "${n}" for action "${e}"`),o[n]=o[n]?.filter(a=>a!==i)}},[t])}function F(e,t,r,...o){for(let n of e.current[t][r])n(...o)}function gi(){let e=nh();return(t,r,...o)=>F(e,t,r,...o)}function Nd(e){Ae("configureMfa",e)}import{QuestionMarkCircleIcon as W0}from"@heroicons/react/24/outline";import ph from"styled-components";import Rn,{css as ih}from"styled-components";import Ud from"styled-components";import{Fragment as m0,jsx as Dd,jsxs as f0}from"react/jsx-runtime";var nt=({success:e,fail:t})=>f0(m0,{children:[Dd(it,{className:e?"success":t?"fail":""}),Dd(va,{className:e?"success":t?"fail":""})]}),it=Ud.span`
13
13
  && {
14
14
  width: 82px;
15
15
  height: 82px;