@privy-io/react-auth 1.67.0 → 1.67.1-beta-20240530203122
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 +47 -47
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var vc=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var Sp=(e,t,r)=>(vc(e,t,"read from private field"),r?r.call(e):t.get(e)),Fa=(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)},Cc=(e,t,r,o)=>(vc(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var _p=(e,t,r)=>(vc(e,t,"access private method"),r);import{getAddress as Si}from"@ethersproject/address";import{Web3Provider as bp}from"@ethersproject/providers";import{createStore as Z8}from"mipd";import{useEffect as Nr,useMemo as J8,useRef as _i,useState as je}from"react";import{FetchError as g2}from"ofetch";var ze=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}]`:""}`}},br=class extends ze{constructor(r,o,n,i,a){super(n,i,a);this.type=r;this.status=o}},P=class extends ze{constructor(r,o,n){super(r,o,n);this.type="client_error"}},Ba=class extends P{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var te=class extends ze{constructor(r,o,n){super(r,o,n);this.type="connector_error"}},ne=e=>{if(e instanceof ze)return e;if(!(e instanceof g2))return at(e);if(!e.response)return new br("api_error",null,e.message,e);let{type:t,message:r,error:o,code:n}=e.data;return new br(t||"ApiError",e.response.status,r||o,e,n)},at=e=>e instanceof ze?e:e instanceof Error?new P(e.message,e):new P(`Internal error: ${e}`);var Dr=class extends P{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},Et=class extends P{constructor(t="Embedded wallet error",r){super(t,r,"unknown_embedded_wallet_error")}},Ha=class extends P{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var lr=class extends P{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 Ga="/api/v1/sessions",Va="/api/v1/sessions/logout",xp="/api/v1/sessions/fork",za="/api/v1/sessions/fork/recover",kp="/api/v1/siwe/init",Ap="/api/v1/siwe/authenticate",Rp="/api/v1/siwe/link",Ip="/api/v1/siwe/unlink",Mp="/api/v1/farcaster/init",Wp="/api/v1/farcaster/authenticate",Lp="/api/v1/farcaster/link",Op="/api/v1/farcaster/status",Np="/api/v1/farcaster/unlink",Dp="/api/v1/passwordless/init",Up="/api/v1/passwordless/authenticate",Fp="/api/v1/passwordless/link",Bp="/api/v1/passwordless/unlink",Hp="/api/v1/passwordless/update",Gp="/api/v1/passwordless_sms/init",Vp="/api/v1/passwordless_sms/link",zp="/api/v1/passwordless_sms/unlink",qp="/api/v1/passwordless_sms/authenticate",$p="/api/v1/oauth/init",Kp="/api/v1/oauth/authenticate",jp="/api/v1/oauth/link",Yp="/api/v1/oauth/unlink",Zp="/api/v1/recovery/oauth/init",Jp="/api/v1/recovery/oauth/init_icloud",Qp="/api/v1/recovery/oauth/authenticate",Xp="/api/v1/passkeys/link/init",eu="/api/v1/passkeys/authenticate/init",tu="/api/v1/passkeys/link",ru="/api/v1/passkeys/authenticate",ou="/api/v1/passkeys/unlink",nu="/api/v1/telegram/authenticate",iu="/api/v1/telegram/link",au="/api/v1/telegram/unlink";var su="/api/v1/mfa/passwordless_sms/init",lu="/api/v1/mfa/passkeys/init",cu="/api/v1/users/me/accept_terms",qa="/api/v1/analytics_events",du="/api/v1/plugins/moonpay_on_ramp/sign",pu="/api/v1/custom_jwt_account/authenticate";var Sn=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");try{let t=await this.api.post(pu,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){throw new Error("Unimplemented")}};var go=class{constructor(t,r){this.meta={email:t,captchaToken:r}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new P("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Up,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new P("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Fp,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ne(t)}}async sendCodeEmail(t,r){if(!this.api)throw new P("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new P("Email must be set when initialzing authentication.");try{return await this.api.post(Dp,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw ne(o)}}},$a=class extends go{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new P("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(Hp,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw ne(r)}}};import{isMobile as w2,isIOS as b2}from"react-device-detect";var wc=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)}},Ka=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 bc(){try{let e="privy:__session_storage__test",t="blobby",r=new Ka;return r.put(e,t),r.del(e),!0}catch{return!1}}function v2(){return typeof window<"u"&&window.localStorage?new Ka:new wc}var Z=v2();import{StaticJsonRpcProvider as xi}from"@ethersproject/providers";function uu(){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 ja=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 Ec=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||ja(e)!=="MetaMask")return!1;if(e.providers){for(let r of e.providers)if(!Ec(r))return!1}return!0},vo=()=>!!("phantom"in window&&window?.phantom?.ethereum?.isPhantom),Ya=()=>{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 mu=(e,t)=>{let r=[],o=[];for(let[n,i]of e.entries())n<t?r.push(i):o.push(i);return[r,o]},Za=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,}))$/),fu=(e,t)=>{let r=e.slice(0),o=[];for(;r.length;)o.push(r.splice(0,t));return o},Co=(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}`},Tc=e=>new Promise(t=>setTimeout(t,e));function hu(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 ki=(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 Tc(r)}a||i(new Error("Exceeded max attempts before resolving function"))})},Ja=(e,t,r={})=>{let o=new URL(t,e);for(let[n,i]of Object.entries(r))o.searchParams.set(n,i);return o.href};var yu=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),zo=e=>typeof e=="string"?e:"0x"+e.toString(16);async function gu(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 u of s)t.includes("coinbase_wallet")&&u.info.rdns==="com.coinbase.wallet"||c.push({type:u.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:u});for(let u of uu()){let h=ja(u);if(!s.some(f=>f.info.name===h)){if(Ec(u,!0)&&!c.find(f=>f.type==="metamask")){c.push({type:"metamask",legacyInjectedProvider:u});continue}if(h==="Phantom"&&!c.find(f=>f.type==="phantom")){c.push({type:"phantom",legacyInjectedProvider:u});continue}if(h==="Coinbase Wallet"&&!c.find(f=>f.type==="coinbase_wallet"&&r?.coinbaseWallet?.connectionOptions!=="smartWalletOnly")){c.push({type:"coinbase_wallet",legacyInjectedProvider:u});continue}c.find(f=>f.type==="unknown_browser_extension")||c.push({type:"unknown_browser_extension",legacyInjectedProvider:u})}}a(c)}})}function _n(e){return`eip155:${String(Number(e))}`}var vu=(e,t,r,o)=>{let n=Number(e),i=t.find(l=>l.id===n);if(!i)throw new te(`Unsupported chainId ${e}`,4901);let a;if(i.rpcUrls.privyWalletOverride&&i.rpcUrls.privyWalletOverride.http[0])a=i.rpcUrls.privyWalletOverride.http[0];else if(r.rpcUrls&&r.rpcUrls[n])a=r.rpcUrls[n];else if(i.rpcUrls.privy?.http[0]){let l=new URL(i.rpcUrls.privy.http[0]);l.searchParams.append("privyAppId",o),a=l.toString()}else i.rpcUrls.public?.http[0]?a=i.rpcUrls.public.http[0]:a=i.rpcUrls.default?.http[0];if(!a)throw new te(`No RPC url found for ${e}`);return a},Cu=(e,t)=>{let r=Number(e),o=t.find(n=>n.id===r);if(!o)throw new te(`Unsupported chainId ${e}`,4901);return o.blockExplorers?.default.url},ro=(e,t,r,o)=>{let n=Number(e),i=t.find(l=>l.id===n);if(!i)throw new te(`Unsupported chainId ${e}`,4901);let a;if(i.rpcUrls.privyWalletOverride&&i.rpcUrls.privyWalletOverride.http[0]?a=new xi(i.rpcUrls.privyWalletOverride.http[0]):r.rpcUrls&&r.rpcUrls[n]?a=new xi(r.rpcUrls[n]):i.rpcUrls.privy?.http[0]?a=new xi({url:i.rpcUrls.privy.http[0],headers:{"privy-app-id":o.appId}}):i.rpcUrls.public?.http[0]?a=new xi(i.rpcUrls.public.http[0]):a=new xi(i.rpcUrls.default?.http[0]),!a)throw new te(`No RPC url found for ${e}`);return a},Qa=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 Xa=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(es))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var es={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 C2(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function wu(e,t){let r=C2(t);if(r.deepLink)return Su(r.deepLink,e);if(r.universalLink)return _u(r.universalLink,e);throw new P(`Unsupported wallet ${t.id}`)}var bu="WALLETCONNECT_DEEPLINK_CHOICE";function Eu(){try{localStorage.removeItem(bu)}catch{}}function Tu({href:e,name:t}){try{localStorage.setItem(bu,JSON.stringify({href:e,name:t}))}catch{}}function Pu(e){return e.startsWith("http://")||e.startsWith("https://")}function Su(e,t){if(Pu(e))return _u(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 _u(e,t){if(!Pu(e))return Su(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function ts(e,t){window.open(e,t,"noreferrer noopener")}var Fe=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 Ai=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Fe(this._startChannelOnce.bind(this)),this.pollForReady=new Fe(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.channelToken)throw new P("Auth flow must be initialized first");try{let t=await this.api.post(Wp,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new P("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");try{return await this.api.post(Lp,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw ne(t)}}async _startChannelOnce(){if(!this.api)throw new P("Auth flow has no API instance");let t=await this.api.post(Mp,{token:this.captchaToken});w2&&!b2&&t.connect_uri&&ts(t.connect_uri,"_blank"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new P("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.channelToken)throw new P("Auth flow must be initialized first");let t=await this.api.get(Op,{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 xu="1.67.0";var ku="34357d3c125c2bcf2ce2bc3309d98715",Ri="https://auth.privy.io",Au=2e4,Le=1400,Ru=2500,Pc=xu;var qo="privy:token",Sc="privy-token",rs="privy:refresh_token",Iu="privy-refresh-token",os="privy-session",Ii="privy:session_transfer_token",T2="privy:wallet",Mi="privy:caid",$o="privy:state_code",Ko="privy:code_verifier",jo="privy:headless_oauth",ns=e=>`${T2}:${e}`,_c="privy:connectors",xc="privy:connections";var Yo=12e4,oo=1,kc="0x1",xn=3e4,Mu="https://api.moonpay.com/v1",Wu="https://api.moonpay.com/v1",Lu="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Ou="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",Nu="0x420000000000000000000000000000000000000F",Du=["function getL1Fee(bytes memory _data) external view returns (uint256)"],Uu="deprecated";import{base64url as Hu}from"jose";async function Fu(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function Bu(e){return crypto.getRandomValues(new Uint8Array(e))}var P2="S256",S2="S256";function Wi(){return Hu.encode(Bu(36))}function is(){return Wi()}async function as(e,t=P2){if(t==S2){let r=await Fu(e);return Hu.encode(r)}else return e}function Gu(){let e=Z.get(Ko);if(!e)throw new P("Authentication error.");return e}function ss(){return!!Z.get(jo)}var Ur=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:ss();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 P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new P("User denied confirmation during OAuth flow");let t=Gu();try{let r=await this.api.post(Kp,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Z.del(Ko),this.meta.headless&&Z.del(jo),{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user,oauth_provider_tokens:r.oauth_provider_tokens}}catch(r){let o=ne(r);throw o.privyErrorCode?new P(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new P("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new P("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new P("User denied confirmation during OAuth flow");let t=Z.get(Ko);if(!t)throw new P("Authentication error.");try{let r=await this.api.post(jp,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Z.del(Ko),r}catch(r){throw ne(r)}}async getAuthorizationUrl(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.provider)throw new P("Provider must be set when initializing OAuth authentication.");let t=Wi();Z.put(Ko,t);let r=is();Z.put($o,r);let o=await as(t);this.meta.headless&&Z.put(jo,!0);try{return await this.api.post($p,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw ne(n)}}};function Ac(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{jsx as Vu,jsxs as _2}from"react/jsx-runtime";var ls=({style:e,...t})=>_2("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:[Vu("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"}),Vu("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 Li,jsxs as x2}from"react/jsx-runtime";var cs=({style:e,...t})=>x2("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:[Li("g",{clipPath:"url(#clip0)",children:Li("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"})}),Li("defs",{children:Li("clipPath",{id:"clip0",children:Li("rect",{width:"71",height:"55",fill:"white"})})})]});import{jsx as zu}from"react/jsx-runtime";var ds=({style:e,...t})=>zu("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:zu("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{jsx as ps,jsxs as k2}from"react/jsx-runtime";var us=({style:e,...t})=>k2("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:[ps("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"}),ps("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"}),ps("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"}),ps("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 cr,jsxs as ms}from"react/jsx-runtime";function fs(e){return ms("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:[ms("defs",{children:[ms("linearGradient",{id:"b",children:[cr("stop",{offset:"0",stopColor:"#3771c8"}),cr("stop",{stopColor:"#3771c8",offset:".128"}),cr("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),ms("linearGradient",{id:"a",children:[cr("stop",{offset:"0",stopColor:"#fd5"}),cr("stop",{offset:".1",stopColor:"#fd5"}),cr("stop",{offset:".5",stopColor:"#ff543e"}),cr("stop",{offset:"1",stopColor:"#c837ab"})]}),cr("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"}),cr("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"})]}),cr("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)"}),cr("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)"}),cr("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 hs}from"react/jsx-runtime";function ys({style:e,...t}){return hs("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:hs("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:hs("g",{transform:"scale(5.12,5.12)",children:hs("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 qu,jsxs as A2}from"react/jsx-runtime";function gs(e){return A2("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...e,children:[qu("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"}),qu("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 Rc,jsxs as R2}from"react/jsx-runtime";function vs(e){return R2("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:[Rc("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"}),Rc("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"}),Rc("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 $u}from"react/jsx-runtime";var Cs=({style:e,...t})=>$u("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:$u("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 I2={google:{name:"Google",component:us},discord:{name:"Discord",component:cs},github:{name:"Github",component:ds},linkedin:{name:"LinkedIn",component:ys},twitter:{name:"Twitter",component:Cs},spotify:{name:"Spotify",component:gs},instagram:{name:"Instagram",component:fs},tiktok:{name:"Tiktok",component:vs},apple:{name:"Apple",component:ls}},Oi=e=>I2[e];function Ku(e,t){let r={detail:"",retryable:!1},o=Ac(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=Oi(t).name;r.detail=`Request limit reached for ${n}. Please wait a moment and try again.`}if(e?.privyErrorCode==="oauth_account_suspended"){let n=Oi(t).name;r.detail=`Your ${n} account is suspended. Please try another login method.`}return r}function Ni(){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");return!t||!r||!o?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:ss(),popupFlow:window.opener!==null}}function Zo(){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"),Z.del($o),window.history.replaceState({},"",e)}var Jo=class{constructor(t){this.initAuthenticateOnce=new Fe(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Fe(this._initLinkOnce.bind(this)),this.meta={captchaToken:t}}async initAuthenticationFlow(){if(!this.api)throw new P("Auth flow has no API instance");this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute()}async initLinkFlow(){if(!this.api)throw new P("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 P("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new P("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(ru,{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 P("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):ne(r)}}async link(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new P("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new P("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(tu,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(o)})}catch(r){throw r.name==="NotAllowedError"?new P("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):ne(r)}}async _initAuthenticateOnce(){if(!this.api)throw new P("Auth flow has no API instance");return await this.api.post(eu,{token:this.meta.captchaToken})}async _initLinkOnce(){if(!this.api)throw new P("Auth flow has no API instance");return await this.api.post(Xp,{})}_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 Qo=class{constructor(t,r){this.createSiweMessage=(t,r,o,n,i,a,l)=>`${o} wants you to sign in with your Ethereum account:
|
|
1
|
+
var vc=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var Sp=(e,t,r)=>(vc(e,t,"read from private field"),r?r.call(e):t.get(e)),Fa=(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)},Cc=(e,t,r,o)=>(vc(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r);var _p=(e,t,r)=>(vc(e,t,"access private method"),r);import{getAddress as Si}from"@ethersproject/address";import{Web3Provider as bp}from"@ethersproject/providers";import{createStore as Zb}from"mipd";import{useEffect as Nr,useMemo as Jb,useRef as _i,useState as je}from"react";import{FetchError as g2}from"ofetch";var ze=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}]`:""}`}},br=class extends ze{constructor(r,o,n,i,a){super(n,i,a);this.type=r;this.status=o}},P=class extends ze{constructor(r,o,n){super(r,o,n);this.type="client_error"}},Ba=class extends P{constructor(){super("Request timed out",void 0,"client_request_timeout")}};var te=class extends ze{constructor(r,o,n){super(r,o,n);this.type="connector_error"}},ne=e=>{if(e instanceof ze)return e;if(!(e instanceof g2))return at(e);if(!e.response)return new br("api_error",null,e.message,e);let{type:t,message:r,error:o,code:n}=e.data;return new br(t||"ApiError",e.response.status,r||o,e,n)},at=e=>e instanceof ze?e:e instanceof Error?new P(e.message,e):new P(`Internal error: ${e}`);var Dr=class extends P{constructor(){super("Method called before `ready`. Ensure you wait until `ready` is true before calling.")}},Et=class extends P{constructor(t="Embedded wallet error",r){super(t,r,"unknown_embedded_wallet_error")}},Ha=class extends P{constructor(t="User must be authenticated"){super(t,void 0,"must_be_authenticated")}};var lr=class extends P{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 Ga="/api/v1/sessions",Va="/api/v1/sessions/logout",xp="/api/v1/sessions/fork",za="/api/v1/sessions/fork/recover",kp="/api/v1/siwe/init",Ap="/api/v1/siwe/authenticate",Rp="/api/v1/siwe/link",Ip="/api/v1/siwe/unlink",Mp="/api/v1/farcaster/init",Wp="/api/v1/farcaster/authenticate",Lp="/api/v1/farcaster/link",Op="/api/v1/farcaster/status",Np="/api/v1/farcaster/unlink",Dp="/api/v1/passwordless/init",Up="/api/v1/passwordless/authenticate",Fp="/api/v1/passwordless/link",Bp="/api/v1/passwordless/unlink",Hp="/api/v1/passwordless/update",Gp="/api/v1/passwordless_sms/init",Vp="/api/v1/passwordless_sms/link",zp="/api/v1/passwordless_sms/unlink",qp="/api/v1/passwordless_sms/authenticate",$p="/api/v1/oauth/init",Kp="/api/v1/oauth/authenticate",jp="/api/v1/oauth/link",Yp="/api/v1/oauth/unlink",Zp="/api/v1/recovery/oauth/init",Jp="/api/v1/recovery/oauth/init_icloud",Qp="/api/v1/recovery/oauth/authenticate",Xp="/api/v1/passkeys/link/init",eu="/api/v1/passkeys/authenticate/init",tu="/api/v1/passkeys/link",ru="/api/v1/passkeys/authenticate",ou="/api/v1/passkeys/unlink",nu="/api/v1/telegram/authenticate",iu="/api/v1/telegram/link",au="/api/v1/telegram/unlink";var su="/api/v1/mfa/passwordless_sms/init",lu="/api/v1/mfa/passkeys/init",cu="/api/v1/users/me/accept_terms",qa="/api/v1/analytics_events",du="/api/v1/plugins/moonpay_on_ramp/sign",pu="/api/v1/custom_jwt_account/authenticate";var Sn=class{constructor(t){this.meta={token:t}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");try{let t=await this.api.post(pu,{token:this.meta.token});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){throw new Error("Unimplemented")}};var go=class{constructor(t,r){this.meta={email:t,captchaToken:r}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new P("Email and email code must be set prior to calling authenticate.");try{let t=await this.api.post(Up,{email:this.meta.email,code:this.meta.emailCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new P("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(Fp,{email:this.meta.email,code:this.meta.emailCode})}catch(t){throw ne(t)}}async sendCodeEmail(t,r){if(!this.api)throw new P("Auth flow has no API instance");if(t&&(this.meta.email=t),r&&(this.meta.captchaToken=r),!this.meta.email)throw new P("Email must be set when initialzing authentication.");try{return await this.api.post(Dp,{email:this.meta.email,token:this.meta.captchaToken})}catch(o){throw ne(o)}}},$a=class extends go{constructor(r,o,n){super(o,n);this.meta={email:o,captchaToken:n,oldAddress:r}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new P("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(Hp,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(r){throw ne(r)}}};import{isMobile as w2,isIOS as b2}from"react-device-detect";var wc=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)}},Ka=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 bc(){try{let e="privy:__session_storage__test",t="blobby",r=new Ka;return r.put(e,t),r.del(e),!0}catch{return!1}}function v2(){return typeof window<"u"&&window.localStorage?new Ka:new wc}var Z=v2();import{StaticJsonRpcProvider as xi}from"@ethersproject/providers";function uu(){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 ja=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 Ec=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||ja(e)!=="MetaMask")return!1;if(e.providers){for(let r of e.providers)if(!Ec(r))return!1}return!0},vo=()=>!!("phantom"in window&&window?.phantom?.ethereum?.isPhantom),Ya=()=>{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 mu=(e,t)=>{let r=[],o=[];for(let[n,i]of e.entries())n<t?r.push(i):o.push(i);return[r,o]},Za=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,}))$/),fu=(e,t)=>{let r=e.slice(0),o=[];for(;r.length;)o.push(r.splice(0,t));return o},Co=(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}`},Tc=e=>new Promise(t=>setTimeout(t,e));function hu(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 ki=(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 Tc(r)}a||i(new Error("Exceeded max attempts before resolving function"))})},Ja=(e,t,r={})=>{let o=new URL(t,e);for(let[n,i]of Object.entries(r))o.searchParams.set(n,i);return o.href};var yu=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),zo=e=>typeof e=="string"?e:"0x"+e.toString(16);async function gu(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 u of s)t.includes("coinbase_wallet")&&u.info.rdns==="com.coinbase.wallet"||c.push({type:u.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:u});for(let u of uu()){let h=ja(u);if(!s.some(f=>f.info.name===h)){if(Ec(u,!0)&&!c.find(f=>f.type==="metamask")){c.push({type:"metamask",legacyInjectedProvider:u});continue}if(h==="Phantom"&&!c.find(f=>f.type==="phantom")){c.push({type:"phantom",legacyInjectedProvider:u});continue}if(h==="Coinbase Wallet"&&!c.find(f=>f.type==="coinbase_wallet"&&r?.coinbaseWallet?.connectionOptions!=="smartWalletOnly")){c.push({type:"coinbase_wallet",legacyInjectedProvider:u});continue}c.find(f=>f.type==="unknown_browser_extension")||c.push({type:"unknown_browser_extension",legacyInjectedProvider:u})}}a(c)}})}function _n(e){return`eip155:${String(Number(e))}`}var vu=(e,t,r,o)=>{let n=Number(e),i=t.find(l=>l.id===n);if(!i)throw new te(`Unsupported chainId ${e}`,4901);let a;if(i.rpcUrls.privyWalletOverride&&i.rpcUrls.privyWalletOverride.http[0])a=i.rpcUrls.privyWalletOverride.http[0];else if(r.rpcUrls&&r.rpcUrls[n])a=r.rpcUrls[n];else if(i.rpcUrls.privy?.http[0]){let l=new URL(i.rpcUrls.privy.http[0]);l.searchParams.append("privyAppId",o),a=l.toString()}else i.rpcUrls.public?.http[0]?a=i.rpcUrls.public.http[0]:a=i.rpcUrls.default?.http[0];if(!a)throw new te(`No RPC url found for ${e}`);return a},Cu=(e,t)=>{let r=Number(e),o=t.find(n=>n.id===r);if(!o)throw new te(`Unsupported chainId ${e}`,4901);return o.blockExplorers?.default.url},ro=(e,t,r,o)=>{let n=Number(e),i=t.find(l=>l.id===n);if(!i)throw new te(`Unsupported chainId ${e}`,4901);let a;if(i.rpcUrls.privyWalletOverride&&i.rpcUrls.privyWalletOverride.http[0]?a=new xi(i.rpcUrls.privyWalletOverride.http[0]):r.rpcUrls&&r.rpcUrls[n]?a=new xi(r.rpcUrls[n]):i.rpcUrls.privy?.http[0]?a=new xi({url:i.rpcUrls.privy.http[0],headers:{"privy-app-id":o.appId}}):i.rpcUrls.public?.http[0]?a=new xi(i.rpcUrls.public.http[0]):a=new xi(i.rpcUrls.default?.http[0]),!a)throw new te(`No RPC url found for ${e}`);return a},Qa=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 Xa=e=>{let t;try{t=new URL(e).hostname}catch{return}for(let[r,o]of Object.entries(es))if(t.includes(o.hostname))return{walletClientType:r,entry:o}};var es={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 C2(e){return{name:e.displayName||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}function wu(e,t){let r=C2(t);if(r.deepLink)return Su(r.deepLink,e);if(r.universalLink)return _u(r.universalLink,e);throw new P(`Unsupported wallet ${t.id}`)}var bu="WALLETCONNECT_DEEPLINK_CHOICE";function Eu(){try{localStorage.removeItem(bu)}catch{}}function Tu({href:e,name:t}){try{localStorage.setItem(bu,JSON.stringify({href:e,name:t}))}catch{}}function Pu(e){return e.startsWith("http://")||e.startsWith("https://")}function Su(e,t){if(Pu(e))return _u(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 _u(e,t){if(!Pu(e))return Su(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);let o=encodeURIComponent(t);return{redirect:`${r}wc?uri=${o}`,href:r}}function ts(e,t){window.open(e,t,"noreferrer noopener")}var Fe=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 Ai=class{constructor(t){this._meta={};this.captchaToken=t,this.startChannelOnce=new Fe(this._startChannelOnce.bind(this)),this.pollForReady=new Fe(this._pollForReady.bind(this))}get meta(){return this._meta}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.channelToken)throw new P("Auth flow must be initialized first");try{let t=await this.api.post(Wp,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid});if(!t)throw new P("No response from authentication");return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");try{return await this.api.post(Lp,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(t){throw ne(t)}}async _startChannelOnce(){if(!this.api)throw new P("Auth flow has no API instance");let t=await this.api.post(Mp,{token:this.captchaToken});w2&&!b2&&t.connect_uri&&ts(t.connect_uri,"_blank"),this._meta={connectUri:t.connect_uri,channelToken:t.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new P("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.channelToken)throw new P("Auth flow must be initialized first");let t=await this.api.get(Op,{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 xu="1.67.1-beta-20240530203122";var ku="34357d3c125c2bcf2ce2bc3309d98715",Ri="https://auth.privy.io",Au=2e4,Le=1400,Ru=2500,Pc=xu;var qo="privy:token",Sc="privy-token",rs="privy:refresh_token",Iu="privy-refresh-token",os="privy-session",Ii="privy:session_transfer_token",T2="privy:wallet",Mi="privy:caid",$o="privy:state_code",Ko="privy:code_verifier",jo="privy:headless_oauth",ns=e=>`${T2}:${e}`,_c="privy:connectors",xc="privy:connections";var Yo=12e4,oo=1,kc="0x1",xn=3e4,Mu="https://api.moonpay.com/v1",Wu="https://api.moonpay.com/v1",Lu="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Ou="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI",Nu="0x420000000000000000000000000000000000000F",Du=["function getL1Fee(bytes memory _data) external view returns (uint256)"],Uu="deprecated";import{base64url as Hu}from"jose";async function Fu(e){let t=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(r)}function Bu(e){return crypto.getRandomValues(new Uint8Array(e))}var P2="S256",S2="S256";function Wi(){return Hu.encode(Bu(36))}function is(){return Wi()}async function as(e,t=P2){if(t==S2){let r=await Fu(e);return Hu.encode(r)}else return e}function Gu(){let e=Z.get(Ko);if(!e)throw new P("Authentication error.");return e}function ss(){return!!Z.get(jo)}var Ur=class{constructor(t){let r=typeof t.headless=="boolean"?t.headless:ss();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 P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if(this.meta.authorizationCode==="undefined")throw new P("User denied confirmation during OAuth flow");let t=Gu();try{let r=await this.api.post(Kp,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Z.del(Ko),this.meta.headless&&Z.del(jo),{user:r.user,token:r.token,refresh_token:r.refresh_token,is_new_user:r.is_new_user,oauth_provider_tokens:r.oauth_provider_tokens}}catch(r){let o=ne(r);throw o.privyErrorCode?new P(o.message||"Invalid code during OAuth flow.",void 0,o.privyErrorCode):o.message==="User denied confirmation during OAuth flow"?new P("Invalid code during oauth flow.",void 0,"oauth_user_denied"):new P("Invalid code during OAuth flow.",void 0,"unknown_auth_error")}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new P("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if(this.meta.authorizationCode==="undefined")throw new P("User denied confirmation during OAuth flow");let t=Z.get(Ko);if(!t)throw new P("Authentication error.");try{let r=await this.api.post(jp,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:t});return Z.del(Ko),r}catch(r){throw ne(r)}}async getAuthorizationUrl(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.provider)throw new P("Provider must be set when initializing OAuth authentication.");let t=Wi();Z.put(Ko,t);let r=is();Z.put($o,r);let o=await as(t);this.meta.headless&&Z.put(jo,!0);try{return await this.api.post($p,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:o,state_code:r})}catch(n){throw ne(n)}}};function Ac(e){return e.charAt(0).toUpperCase()+e.slice(1)}import{jsx as Vu,jsxs as _2}from"react/jsx-runtime";var ls=({style:e,...t})=>_2("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:[Vu("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"}),Vu("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 Li,jsxs as x2}from"react/jsx-runtime";var cs=({style:e,...t})=>x2("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:[Li("g",{clipPath:"url(#clip0)",children:Li("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"})}),Li("defs",{children:Li("clipPath",{id:"clip0",children:Li("rect",{width:"71",height:"55",fill:"white"})})})]});import{jsx as zu}from"react/jsx-runtime";var ds=({style:e,...t})=>zu("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:zu("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{jsx as ps,jsxs as k2}from"react/jsx-runtime";var us=({style:e,...t})=>k2("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:[ps("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"}),ps("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"}),ps("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"}),ps("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 cr,jsxs as ms}from"react/jsx-runtime";function fs(e){return ms("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:[ms("defs",{children:[ms("linearGradient",{id:"b",children:[cr("stop",{offset:"0",stopColor:"#3771c8"}),cr("stop",{stopColor:"#3771c8",offset:".128"}),cr("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),ms("linearGradient",{id:"a",children:[cr("stop",{offset:"0",stopColor:"#fd5"}),cr("stop",{offset:".1",stopColor:"#fd5"}),cr("stop",{offset:".5",stopColor:"#ff543e"}),cr("stop",{offset:"1",stopColor:"#c837ab"})]}),cr("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"}),cr("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"})]}),cr("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)"}),cr("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)"}),cr("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 hs}from"react/jsx-runtime";function ys({style:e,...t}){return hs("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:hs("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:hs("g",{transform:"scale(5.12,5.12)",children:hs("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 qu,jsxs as A2}from"react/jsx-runtime";function gs(e){return A2("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...e,children:[qu("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"}),qu("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 Rc,jsxs as R2}from"react/jsx-runtime";function vs(e){return R2("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:[Rc("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"}),Rc("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"}),Rc("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 $u}from"react/jsx-runtime";var Cs=({style:e,...t})=>$u("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:$u("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 I2={google:{name:"Google",component:us},discord:{name:"Discord",component:cs},github:{name:"Github",component:ds},linkedin:{name:"LinkedIn",component:ys},twitter:{name:"Twitter",component:Cs},spotify:{name:"Spotify",component:gs},instagram:{name:"Instagram",component:fs},tiktok:{name:"Tiktok",component:vs},apple:{name:"Apple",component:ls}},Oi=e=>I2[e];function Ku(e,t){let r={detail:"",retryable:!1},o=Ac(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=Oi(t).name;r.detail=`Request limit reached for ${n}. Please wait a moment and try again.`}if(e?.privyErrorCode==="oauth_account_suspended"){let n=Oi(t).name;r.detail=`Your ${n} account is suspended. Please try another login method.`}return r}function Ni(){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");return!t||!r||!o?{inProgress:!1}:{inProgress:!0,authorizationCode:t,stateCode:r,provider:o,headless:ss(),popupFlow:window.opener!==null}}function Zo(){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"),Z.del($o),window.history.replaceState({},"",e)}var Jo=class{constructor(t){this.initAuthenticateOnce=new Fe(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Fe(this._initLinkOnce.bind(this)),this.meta={captchaToken:t}}async initAuthenticationFlow(){if(!this.api)throw new P("Auth flow has no API instance");this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute()}async initLinkFlow(){if(!this.api)throw new P("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 P("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new P("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(ru,{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 P("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):ne(r)}}async link(){let t=await import("@simplewebauthn/browser");if(!this.api)throw new P("Auth flow has no API instance");if(!t.browserSupportsWebAuthn())throw new P("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(tu,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(o)})}catch(r){throw r.name==="NotAllowedError"?new P("Passkey request timed out or rejected by user.",void 0,"passkey_not_allowed"):ne(r)}}async _initAuthenticateOnce(){if(!this.api)throw new P("Auth flow has no API instance");return await this.api.post(eu,{token:this.meta.captchaToken})}async _initLinkOnce(){if(!this.api)throw new P("Auth flow has no API instance");return await this.api.post(Xp,{})}_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 Qo=class{constructor(t,r){this.createSiweMessage=(t,r,o,n,i,a,l)=>`${o} wants you to sign in with your Ethereum account:
|
|
2
2
|
${r}
|
|
3
3
|
|
|
4
4
|
${l}
|
|
@@ -9,7 +9,7 @@ Chain ID: ${t}
|
|
|
9
9
|
Nonce: ${a}
|
|
10
10
|
Issued At: ${i}
|
|
11
11
|
Resources:
|
|
12
|
-
- https://privy.io`;this.getNonceOnce=new Fe(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=r}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");try{let{message:t,signature:r}=await this.sign(),o=await this.api.post(Ap,{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,is_new_user:o.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");try{let{message:t,signature:r}=await this.sign();return await this.api.post(Rp,{message:t,signature:r,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw ne(t)}}async sign(){if(!this.api)throw new P("Auth flow has no API instance");if(await this.buildSiweMessage(),!this.preparedMessage)throw new P("Could not prepare SIWE message");let t=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async _getNonceOnce(){if(!this.api)throw new P("Auth flow has no API instance");let t=this.wallet.address;return(await this.api.post(kp,{address:t,token:this.captchaToken})).nonce}async buildSiweMessage(){if(!this.api)throw new P("Auth flow has no API instance");let t=this.wallet.address,r=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=this.prepareMessage(r,t,this.nonce),this.preparedMessage}prepareMessage(t,r,o){let n=window.location.host,i=window.location.origin,a="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",l=new Date().toISOString();return this.createSiweMessage(t,r,n,i,l,o,a)}};var Xo=class{constructor(t,r){this.meta={phoneNumber:t,captchaToken:r}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new P("phone number and sms code must be set prior to calling authenticate.");try{let t=await this.api.post(qp,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new P("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Vp,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw ne(t)}}async sendSmsCode(t,r){if(!this.api)throw new P("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),r&&(this.meta.captchaToken=r),!this.meta.phoneNumber)throw new P("phone nNumber must be set when initialzing authentication.");try{return await this.api.post(Gp,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(o){throw ne(o)}}};var Di=class{constructor(t){this.meta={captchaToken:t}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");try{let t=await this.api.post(nu,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");try{return await this.api.post(iu,{telegram_auth_result:this.meta.telegramAuthResult})}catch(t){throw ne(t)}}};function Ic(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}import{v4 as P3}from"uuid";function j(e){return e?new Date(e*1e3):null}function M2(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:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at),chainType:"ethereum",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"email":let i={address:r.address,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(i);break;case"phone":let a={number:r.phoneNumber,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(a);break;case"google_oauth":let l={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(l);break;case"spotify_oauth":let s={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(s);break;case"instagram_oauth":let c={subject:r.subject,username:r.username,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(c);break;case"twitter_oauth":let u={subject:r.subject,username:r.username,name:r.name,type:r.type,profilePictureUrl:r.profile_picture_url,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(u);break;case"discord_oauth":let h={subject:r.subject,username:r.username,email:r.email,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(h);break;case"github_oauth":let f={subject:r.subject,username:r.username,name:r.name,email:r.email,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(f);break;case"tiktok_oauth":let y={subject:r.subject,username:r.username,name:r.name,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(y);break;case"linkedin_oauth":let v={subject:r.subject,name:r.name,email:r.email,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(v);break;case"apple_oauth":let g={subject:r.subject,email:r.email,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(g);break;case"custom_auth":t.push({type:r.type,customUserId:r.custom_user_id,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)});break;case"farcaster":let k={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:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at),signerPublicKey:r.signer_public_key};t.push(k);break;case"passkey":let w={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:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(w);break;case"telegram":let b={type:r.type,telegramUserId:r.telegram_user_id,firstName:r.first_name,lastName:r.last_name,username:r.username,photoUrl:r.photo_url,verifiedAt:j(r.first_verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(b);break;default:console.warn(`Unrecognized account type: ${o}. Please consider upgrading the Privy SDK.`)}}return t}function Mt(e,t){return e.slice().sort((r,o)=>(o.firstVerifiedAt??o.verifiedAt).getTime()-(r.firstVerifiedAt??r.verifiedAt).getTime()).find(r=>r.type===t)}var Ie=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&!t.imported)||null,Mc=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&t.imported)||null,W2=e=>e.linkedAccounts.filter(t=>t.type==="wallet"),Wt=(e,t)=>t==="all-users"&&!Ie(e)||t==="users-without-wallets"&&!W2(e)?.length;function Kt(e){if(!e)return null;let t=M2(e.linked_accounts),r=Mt(t,"wallet"),o=Mt(t,"email"),n=Mt(t,"phone"),i=Mt(t,"google_oauth"),a=Mt(t,"twitter_oauth"),l=Mt(t,"discord_oauth"),s=Mt(t,"github_oauth"),c=Mt(t,"spotify_oauth"),u=Mt(t,"instagram_oauth"),h=Mt(t,"tiktok_oauth"),f=Mt(t,"linkedin_oauth"),y=Mt(t,"apple_oauth"),v=Mt(t,"farcaster"),g=Mt(t,"telegram"),k=e.mfa_methods.map(({type:b,verified_at:_})=>({type:b,verifiedAt:j(_)}));return{id:e.id,createdAt:j(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:u&&{subject:u.subject,username:u.username},tiktok:h&&{subject:h.subject,username:h.username,name:h.name},linkedin:f&&{subject:f.subject,name:f.name,email:f.email},apple:y&&{subject:y.subject,email:y.email},farcaster:v&&{fid:v.fid,ownerAddress:v.ownerAddress,displayName:v.displayName,username:v.username,bio:v.bio,pfp:v.pfp,url:v.url,signerPublicKey:v.signerPublicKey},telegram:g&&{telegramUserId:g.telegramUserId,firstName:g.firstName,lastName:g.lastName,username:g.username,photoUrl:g.photoUrl},mfaMethods:k.map(b=>b.type),hasAcceptedTerms:e.has_accepted_terms??!1}}import{getAddress as Wm}from"@ethersproject/address";import{isHexString as v3}from"@ethersproject/bytes";import C3 from"eventemitter3";import V2 from"@coinbase/wallet-sdk";import{jsx as ju,jsxs as L2}from"react/jsx-runtime";var Ui=({style:e,...t})=>L2("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:[ju("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),ju("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 Br}from"@ethersproject/address";import{Web3Provider as em}from"@ethersproject/providers";import{default as H2}from"eventemitter3";import B2 from"eventemitter3";var O2=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4"],Yu=e=>O2.includes(e);import{ErrorCode as N2}from"@ethersproject/logger";var kn=class extends te{constructor(){super("Wallet timeout");this.type="wallet_error"}},An=class extends te{constructor(){super("User rejected connection");this.type="wallet_error"}},Er=e=>{if(e instanceof te)return e;if(e?.code&&e?.reason){let t=new Be(e);return e.code===N2.ACTION_REJECTED&&(t.details=st.E4001_USER_REJECTED_REQUEST),t}return e?.code?new Be(e):new te("Unknown connector error",e)},jt=class extends ze{constructor(r,o,n){super(r);this.type="provider_error";this.code=o,this.data=n}},Be=class extends jt{constructor(r){let o=r;super(o.message,o.code,o.data);let n=Object.values(st).find(i=>i.eipCode===o.code);this.details=n||st.UNKNOWN_ERROR,o.code===-32002&&(o.message?.includes("already pending for origin")?o.message?.includes("wallet_requestPermissions")?this.details=st.E32002_CONNECTION_ALREADY_PENDING:this.details=st.E32002_REQUEST_ALREADY_PENDING:o.message?.includes("Already processing")&&o.message.includes("eth_requestAccounts")&&(this.details=st.E32002_WALLET_LOCKED))}},D2={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}},U2={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},F2={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},st={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...F2,...U2},no={...D2,...st};var Oe=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 kn,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||Yo,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 te(`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 Er(r)})}},wo=class extends Error{constructor(r,o,n){super(r);this.code=o,this.data=n}},Fi=class extends B2{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=ro(l,this.chains,n,{appId:a}),this.rpcTimeoutDuration=Rn(n,"privy"),this.appId=a}async handleSendTransaction(r){if(!r.params||!Array.isArray(r.params))throw new wo(`Invalid params for ${r.method}`,4200);let o=r.params[0];if(!await Ee()||!this.address)throw new wo("Disconnected",4900);return(await Qu(o)).hash}handleSwitchEthereumChain(r){if(!r.params||!Array.isArray(r.params))throw new wo(`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 wo(`Invalid params for ${r.method}`,4200);this.chainId=Number(o),this.provider=ro(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 Zu(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 Ju(Qa(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:zo(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 zo(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(Yu(r.method)){let o=await Ee();if(await Xu(),!o||!this.address)throw new wo("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 wo("Disconnected",4900)}}else return this.provider.send(r.method,r.params)}async connect(){let r=await Ee();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}}},Fr=class extends Oe{constructor(r){super(r,r.rpcTimeoutDuration)}},bo=class extends Oe{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 G2=(e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");default:return e.code===4902||e.message?.includes("4902")}},Lt=class extends H2{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=_n(r),this.walletClientType==="privy"&&Z.put(ns(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=Rn(i,r),this.connected=!1,this.initialized=!1}buildConnectedWallet(r,o,n,i){let a=async()=>!!this.wallets.find(l=>Br(l.address)===Br(r));return{address:Br(r),chainId:o,meta:n,imported:i,switchChain:async l=>{if(!a)throw new te("Wallet is not currently connected.");let s=this.wallets.find(y=>Br(y.address)===Br(r))?.chainId;if(!s)throw new te("Unable to determine current chainId.");let c,u;if(typeof l=="number"?(c=`0x${l.toString(16)}`,u=l):(c=l,u=Number(l)),s===_n(c))return;let h=this.chains.find(y=>y.id===u);if(!h)throw new te(`Unsupported chainId: ${l}`);let f=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:c}]})};try{return await f()}catch(y){if(G2(y,this.walletClientType))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:c,chainName:h.name,nativeCurrency:h.nativeCurrency,rpcUrls:[h.rpcUrls.default?.http[0]??""],blockExplorerUrls:[h.blockExplorers?.default.url??""]}]}),f();throw this.walletClientType==="rainbow"&&y.message?.includes("wallet_switchEthereumChain")?new te(`Rainbow does not support the chainId ${o}`):y}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:a,getEthereumProvider:async()=>{if(!await a())throw new te("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await a())throw new te("Wallet is not currently connected.");return new em(new Fr(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await a())throw new te("Wallet is not currently connected.");return new bo(this.proxyProvider)},sign:async l=>{if(!await a())throw new te("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 ki(()=>this.proxyProvider.request({method:"eth_accounts"}),{maxAttempts:10,delayMs:500});Array.isArray(c)&&(o=c)}}catch{console.warn("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.")}if(!o||!Array.isArray(o)||o.length<=0||!o[0])return;let n=o[0],i=Br(n),a=[],l;if(this.walletClientType==="privy"){let c=Z.get(ns(i));this.chains.find(u=>u.id===Number(c))||(Z.del(ns(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 ki(()=>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 ${kc}`,c),l=kc}let s=_n(l);if(!a.find(c=>Br(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(Br(n),s,c,this.connectorType==="embedded_imported"))}ws(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=>Br(n)===Br(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 em(new Fr(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 z2=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],q2=(e,t)=>e.makeWeb3Provider({options:t}),Wc,bs=class extends Lt{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 Oe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=i.coinbaseWallet.connectionOptions??"eoaOnly",this.walletClientType=this.connectionOptions==="smartWalletOnly"?"coinbase_smart_wallet":"coinbase_wallet",this.walletClientType==="coinbase_smart_wallet"&&(this.displayName="Coinbase Smart Wallet"),!Wc){let s=[o.id].concat(r.map(u=>u.id)),c=this.connectionOptions!=="eoaOnly"?s.filter(u=>!z2.includes(u)):[];c.length>0&&console.warn(`The following configured chains are not supported by the Coinbase Smart Wallet: ${c.join(", ")}`),Wc=new V2({appName:a,appLogoUrl:l,appChainIds:s})}this.proxyProvider.setWalletProvider(q2(Wc,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:Ui,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 te("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([r[0]])}catch(r){throw Er(r)}}};import{jsx as tm}from"react/jsx-runtime";var Es=({...e})=>tm("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:tm("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 Bi=class extends Lt{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:[zo(r?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Es,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}};import{jsx as rm}from"react/jsx-runtime";var In=({style:e,...t})=>rm("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...e},...t,children:rm("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 Yt,jsxs as $2}from"react/jsx-runtime";var Mn=({style:e,...t})=>$2("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:[Yt("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),Yt("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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 om,jsxs as K2}from"react/jsx-runtime";var Hr=({style:e,...t})=>K2("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:[om("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),om("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 Ln=class extends Lt{constructor(r,o,n,i,a){super(a||"unknown",r,o,n);this.connectorType="injected";this.proxyProvider=new Oe(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 te("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw Er(r)}}},Wn,On=class extends Lt{constructor(r,o,n,i,a){super(a??"unknown",r,o,n);this.connectorType="injected";Fa(this,Wn,void 0);this.proxyProvider=new Oe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(i),a==="metamask"?Cc(this,Wn,{name:"MetaMask",icon:Mn,id:"io.metamask"}):a==="phantom"&&Cc(this,Wn,{name:"Phantom",icon:Hr,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 Sp(this,Wn)??{name:"Browser Extension",icon:In,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 te("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw Er(r)}}};Wn=new WeakMap;import{getAddress as SP}from"@ethersproject/address";import{Web3Provider as xP}from"@ethersproject/providers";import{isMobile as j2}from"react-device-detect";var Ts=class extends Ln{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{j2||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 te("Unable to retrieve accounts");await this.syncAccounts([t[0]])}catch(t){throw Er(t)}}};var Ps=class extends Lt{constructor(r,o){super(r,[],o,{});this.connectorType="null";this.proxyProvider=new Oe(void 0,Yo);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 Ss=class extends Ps{constructor(t){super("phantom",t)}get walletBranding(){return{name:"Phantom",icon:Hr,id:"phantom"}}};import{EthereumProvider as f3,OPTIONAL_EVENTS as h3,OPTIONAL_METHODS as y3}from"@walletconnect/ethereum-provider";import{isMobile as g3}from"react-device-detect";import{createContext as a3,useContext as s3,useEffect as Dc,useRef as l3,useState as c3}from"react";import{jsx as Y2}from"react/jsx-runtime";function _s({src:e,...t}){return Y2("img",{src:e,...t,style:{display:"none"}})}import{useContext as km,useEffect as xm,useMemo as r3,useState as o3}from"react";import{createContext as n3}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:ku,rpcConfig:{rpcUrls:{},rpcTimeouts:{}},externalWallets:{coinbaseWallet:{connectionOptions:"eoaOnly"}},captchaEnabled:!1,_render:{inDialog:!0,inParentNodeId:null},fiatOnRamp:{useSandbox:!1}};var nm=({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 Z2=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","wallet_connect","detected_wallets","rabby_wallet"]),im=e=>Z2.has(e),am=(e,t,r)=>r.indexOf(e)===t,sm=({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(im).filter(am):e?e.filter(im).filter(am):Ot.appearance.walletList;var xs={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 ks={id:421613,name:"Arbitrum Goerli",network:"arbitrum-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"AGOR",decimals:18},rpcUrls:{alchemy:{http:["https://arb-goerli.g.alchemy.com/v2"],webSocket:["wss://arb-goerli.g.alchemy.com/v2"]},infura:{http:["https://arbitrum-goerli.infura.io/v3"],webSocket:["wss://arbitrum-goerli.infura.io/ws/v3"]},default:{http:["https://goerli-rollup.arbitrum.io/rpc"]},public:{http:["https://goerli-rollup.arbitrum.io/rpc"]}},blockExplorers:{etherscan:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"},default:{name:"Arbiscan",url:"https://goerli.arbiscan.io/"}},testnet:!0};var As={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 lm={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 cm={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 Rs={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 Is={id:84531,network:"base-goerli",name:"Base Goerli Testnet",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{blast:{http:["https://base-goerli.blastapi.io"],webSocket:["wss://base-goerli.blastapi.io"]},default:{http:["https://goerli.base.org"]},public:{http:["https://goerli.base.org"]}},blockExplorers:{etherscan:{name:"Basescan",url:"https://goerli.basescan.org"},default:{name:"Basescan",url:"https://goerli.basescan.org"}},testnet:!0};var Ms={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 dm={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 pm={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 um={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 mm={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 fm={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 hm={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 ym={id:5,network:"goerli",name:"Goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{privy:{http:["https://goerli.rpc.privy.systems"]},alchemy:{http:["https://eth-goerli.g.alchemy.com/v2"],webSocket:["wss://eth-goerli.g.alchemy.com/v2"]},infura:{http:["https://goerli.infura.io/v3"],webSocket:["wss://goerli.infura.io/ws/v3"]},default:{http:["https://rpc.ankr.com/eth_goerli"]},public:{http:["https://rpc.ankr.com/eth_goerli"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli.etherscan.io"},default:{name:"Etherscan",url:"https://goerli.etherscan.io"}},testnet:!0};var gm={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 vm={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 Cm={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 Ws={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 Ls={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 Os={id:420,name:"Optimism Goerli Testnet",network:"optimism-goerli",nativeCurrency:{name:"Goerli Ether",symbol:"ETH",decimals:18},rpcUrls:{alchemy:{http:["https://opt-goerli.g.alchemy.com/v2"],webSocket:["wss://opt-goerli.g.alchemy.com/v2"]},infura:{http:["https://optimism-goerli.infura.io/v3"],webSocket:["wss://optimism-goerli.infura.io/ws/v3"]},default:{http:["https://goerli.optimism.io"]},public:{http:["https://goerli.optimism.io"]}},blockExplorers:{etherscan:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"},default:{name:"Etherscan",url:"https://goerli-optimism.etherscan.io"}},testnet:!0};var Ns={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 Hi={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 Gi={id:80001,name:"Mumbai",network:"maticmum",nativeCurrency:{name:"MATIC",symbol:"MATIC",decimals:18},rpcUrls:{privy:{http:["https://polygon-mumbai.rpc.privy.systems"]},alchemy:{http:["https://polygon-mumbai.g.alchemy.com/v2"],webSocket:["wss://polygon-mumbai.g.alchemy.com/v2"]},infura:{http:["https://polygon-mumbai.infura.io/v3"],webSocket:["wss://polygon-mumbai.infura.io/ws/v3"]},default:{http:["https://matic-mumbai.chainstacklabs.com"]},public:{http:["https://matic-mumbai.chainstacklabs.com"]}},blockExplorers:{etherscan:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"},default:{name:"PolygonScan",url:"https://mumbai.polygonscan.com"}},testnet:!0};var wm={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 bm={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 Em={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 Ds={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 Us={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 Fs={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 Vi=[xs,ks,As,ym,Em,Ws,Ls,Os,Ns,Hi,Gi,pm,um,mm,fm,Rs,Is,Ms,dm,vm,Cm,lm,cm,Ds,Fs,Us,gm,wm,hm,bm],XS=new Set(Vi.map(e=>e.id));import en from"tinycolor2";var Tm="#FFFFFF",J2="#000000",Q2=Tm,X2="#1E1E1D";function e3(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 io(e,t){let r=Math.max(0,Math.min(1,e.toHsl().l+t));return en({...e.toHsl(),l:r})}function Pm({backgroundTheme:e,accentHex:t,successHex:r="#51BA81",warnHex:o="#FFB74D",errorHex:n="#EC6351",whiteHex:i=Tm,blackHex:a=J2}){let l;switch(e){case"light":l=Q2;break;case"dark":l=X2;break;default:l=e;break}let s=en(l),c=en(t),u=en(r),h=en(o),f=en(n),y=e3(s.getLuminance()),v=io(s,y==="light"?-.04:.11),g=io(s,y==="light"?-.88:.87),k=io(s,y==="light"?-.77:.75),w=io(s,y==="light"?-.43:.45).desaturate(y==="light"?60:20),b=io(s,y==="light"?-.08:.25).desaturate(y==="light"?60:20),_=io(c,.15),A=io(c,-.06),N=io(f,.3),I=en(c.getLuminance()>.5?a:i),R=io(u,-.16);return{colorScheme:y,background:s.toHslString(),background2:v.toHslString(),foreground:g.toHslString(),foreground2:k.toHslString(),foreground3:w.toHslString(),foreground4:b.toHslString(),accent:c.toHslString(),accentLight:_.toHslString(),accentDark:A.toHslString(),foregroundAccent:I.toHslString(),success:u.toHslString(),successDark:R.toHslString(),error:f.toHslString(),errorLight:N.toHslString(),warn:h.toHslString()}}function Lc(e,t,r){let o=r?console.warn:()=>{},n,i,a,l,s,c,u,h,f,y,v,g,k,w,b;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"),u=t.loginMethods.includes("discord"),f=t.loginMethods.includes("spotify"),y=t.loginMethods.includes("instagram"),h=t.loginMethods.includes("tiktok"),g=t.loginMethods.includes("github"),v=t.loginMethods.includes("linkedin"),k=t.loginMethods.includes("apple"),w=t.loginMethods.includes("farcaster"),b=t.loginMethods.includes("telegram")):(n=e.emailAuth,i=e.smsAuth,l=e.walletAuth,s=e.googleOAuth,c=e.twitterOAuth,u=e.discordOAuth,g=e.githubOAuth,f=e.spotifyOAuth,y=e.instagramOAuth,h=e.tiktokOAuth,v=e.linkedinOAuth,k=e.appleOAuth,w=e.farcasterAuth,b=e.telegramAuth),typeof window<"u"&&typeof window.PublicKeyCredential!="function"?a=!1:e.passkeyAuth&&(a=!0);let _=[n,i].filter(Boolean),A=[s,c,u,g,f,y,h,v,k,w,b].filter(Boolean),N=[l].filter(Boolean);if(_.length+A.length+N.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&&N.length===0?(o("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),I=!1):!I&&A.length+_.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),t?.loginMethods&&t.loginMethodsAndOrder&&o("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let R=sm({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),B=nm({input:t?.loginMethodsAndOrder}),K=t?.intl?.defaultCountry??"US",{chains:Y,defaultChain:W}=t3({additionalChains:t?.additionalChains,supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain,hasRpcConfigDefined:Object.keys(t?.rpcConfig?.rpcUrls??{}).length>0}),V=!!t?.defaultChain,L=t?.customAuth?.getCustomAccessToken&&t?.customAuth?.enabled!==!1,ae,de=!(e.enforceWalletUis??!0);if(e.legacyWalletUiConfig??!0?L?ae=t?.embeddedWallets?.noPromptOnSignature??!0:ae=t?.embeddedWallets?.noPromptOnSignature??de:ae=de,t?.embeddedWallets?.waitForTransactionConfirmation===!1&&ae!==!0)throw new Error("Overriding `config.embeddedWallets.waitForTransactionConfirmation` requires that you disable wallet UIs in the dashboard.");let{requireUserPasswordOnCreate:pe,...we}=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,palette:Pm({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:R},loginMethods:{wallet:l,email:n,sms:i,passkey:a,google:s,twitter:c,discord:u,github:g,spotify:f,instagram:y,tiktok:h,linkedin:v,apple:k,farcaster:w,telegram:b},loginMethodsAndOrder:B,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:Y,defaultChain:W,intl:{defaultCountry:K},shouldEnforceDefaultChainOnConnect:V,captchaEnabled:e.captchaEnabled??Ot.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??Ot.externalWallets.coinbaseWallet.connectionOptions}},embeddedWallets:{...e.embeddedWalletConfig,...typeof pe=="boolean"?{requireUserOwnedRecoveryOnCreate:pe}:{},...L?{createOnLogin:"all-users",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]}:{},waitForTransactionConfirmation:!0,priceDisplay:{primary:"fiat-currency",secondary:"native-token"},...we,noPromptOnSignature:ae},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},customAuth:L?{enabled:!0,...t.customAuth}:void 0,fiatOnRamp:{enabled:e.fiatOnRampEnabled,useSandbox:t?.fiatOnRamp?.useSandbox??Ot.fiatOnRamp.useSandbox},loginConfig:{twitterOAuthOnMobileEnabled:e.twitterOAuthOnMobileEnabled??!1,telegramAuthConfiguration:e.telegramAuthConfiguration},headless:!!t?.headless,render:{inDialog:t?._render?.inDialog??Ot._render.inDialog,inParentNodeId:t?._render?.inParentNodeId??Ot._render.inParentNodeId}}}function Sm(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,...r?{...r,...r.logo&&typeof r.logo?{logo:"component"}:void 0}:void 0,legacyCreateEmbeddedWalletFlag:t}}function t3({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:Vi.find(u=>u.id===s.id)??s)}else n=Vi.concat(e??[]);let i=t?n[0]:Ws,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 _m=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 i3}from"react/jsx-runtime";var Am={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:""},Oc=Lc(Am,void 0,!1),Nc=n3({appConfig:Oc,isServerConfigLoaded:!1}),Rm=({children:e,legacyCreateEmbeddedWalletFlag:t,client:r,clientConfig:o})=>{let[n,i]=o3(null),a=r3(()=>Lc(n??Am,o,!!n),[n,o]);return xm(()=>{if(!n)return;let l=Sm(o,t),s=_m(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]),xm(()=>{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)}})()},[]),i3(Nc.Provider,{value:{appConfig:a,isServerConfigLoaded:!!n},children:e})},Nt=()=>{let{appConfig:e}=km(Nc);return e},Bs=()=>{let{isServerConfigLoaded:e}=km(Nc);return e};var E=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import{jsx as p3,jsxs as u3}from"react/jsx-runtime";var Im=a3({ready:!1,app:Oc,currentScreen:null,lastScreen:null,navigate:E,navigateBack:E,resetNavigation:E,setModalData:E,onUserCloseViaDialogOrKeybindRef:void 0}),d3=["LANDING","CONNECT_ONLY_LANDING_SCREEN",null],Mm=e=>{let t=Nt(),r=e.authenticated,[o,n]=c3(e.initialScreen);Dc(()=>{!r&&!d3.includes(e.initialScreen)&&e.setInitialScreen(null)},[r]);let i=l3(null);Dc(()=>{e.open||(i.current=null)},[e.open]),Dc(()=>{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 u3(Im.Provider,{value:a,children:[(typeof t.appearance.logo=="string"||t.appearance.logo?.type==="img")&&p3(_s,{src:typeof t.appearance.logo=="string"?t.appearance.logo:t.appearance.logo.props.src}),e.children]})},x=()=>s3(Im);import{jsx as Nn,jsxs as m3}from"react/jsx-runtime";var zi=({style:e,...t})=>{let{app:r}=x();return m3("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:[Nn("rect",{width:"28",height:"28",rx:"3",fill:r?.appearance.palette.colorScheme==="dark"?"#3396ff":"#141414"}),Nn("g",{clipPath:"url(#clip0_1765_9946)",children:Nn("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"})}),Nn("defs",{children:Nn("clipPath",{id:"clip0_1765_9946",children:Nn("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};var Gr=class extends Lt{constructor(r,o,n,i,a,l,s){super(s||"unknown",n,i,o);this.connectorType="wallet_connect_v2";this.privyAppId=l,this.walletConnectCloudProjectId=r,this.rpcConfig=o,this.shouldEnforceDefaultChainOnConnect=a,this.proxyProvider=new Oe(void 0,this.rpcTimeoutDuration),s&&(this.walletEntry=es[s],this.walletClientType=s)}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=Xa(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:Mn,id:"io.metamask"}:{name:yu(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:this.walletProvider?.session?.peer.metadata.icons?.[0]||zi,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=es[r],this.walletClientType=r,this.redirectUri=void 0,Eu(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise((r,o)=>{let n=()=>{o(new An)};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 te("Unable to retrieve address");if(this.walletProvider?.session?.peer.metadata.url){let s=Xa(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=s?.entry,this.walletClientType=s?.walletClientType||"unknown",this.proxyProvider.rpcTimeoutDuration=Rn(this.rpcConfig,this.walletClientType)}this.connected=!0,await this.syncAccounts(l),r()})().catch(a=>{if(a){o(Er(a));return}o(new te("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=vu(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 f3.init({projectId:this.walletConnectCloudProjectId,chains:o,optionalChains:n,optionalEvents:h3,optionalMethods:y3,rpcMap:r,showQrModal:!1});return i.on("display_uri",a=>{if(i.signer.abortPairingAttempt(),g3&&this.walletEntry){let{redirect:l,href:s}=wu(a,this.walletEntry);Tu({href:s,name:this.walletEntry.displayName}),this.redirectUri=l,ts(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=Xa(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 Fc=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses")?.split(" ").filter(o=>v3(o)).map(o=>Wm(o));return t?.length?!!e?.linkedAccounts.filter(o=>o.type=="wallet"&&t.includes(o.address)).length:!1},Rn=(e,t)=>e.rpcTimeouts?e.rpcTimeouts[t]||Yo:Yo,qi=class extends C3{constructor(r,o,n,i,a,l,s,c,u,h,f){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 Oe: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=u,this.privyAppName=h,this.privyAppLogo=f,this.storedConnections=Uc()}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;Z.get(_c)&&(Z.getKeys().forEach(o=>{o.startsWith("walletconnect")&&Z.del(o)}),Z.del(_c));let r=gu(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"),!vo()&&this.walletList.includes("phantom")&&this.createWalletConnector("phantom","phantom"),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 Fi(r,o,this.rpcConfig,this.chains,i,n.id),s=new Bi(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 Fi(r,o,this.rpcConfig,this.chains,i,n.id),s=!0,c=new Bi(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=Uc(),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=Uc(),this.emit("walletsUpdated")}}async createWalletConnector(r,o,n){let i=this.findWalletConnector(r,o);if(i)return i instanceof Gr&&i.resetConnection(o),i;let l=(()=>{if(r==="injected"){if(o==="metamask"&&n?.eip6963InjectedProvider)return new Ts(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask");if(o==="metamask"&&n?.legacyInjectedProvider)return new On(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask");if(o==="phantom"&&n?.legacyInjectedProvider)return new On(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom");if(n?.legacyInjectedProvider&&o==="unknown_browser_extension")return new On(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider);if(n?.eip6963InjectedProvider)return new Ln(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,o)}else return r==="coinbase_wallet"?new bs(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):r==="phantom"?new Ss(this.defaultChain):new Gr(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,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()}saveConnectionHistory(){let r=this.wallets.map(o=>({address:o.address,connectorType:o.connectorType,walletClientType:o.walletClientType,connectedAt:o.connectedAt}));Z.put(xc,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=Wm(r),this.emit("walletsUpdated")}};function ws(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 w3=e=>e&&typeof e.address=="string"&&typeof e.connectorType=="string"&&typeof e.walletClientType=="string"&&typeof e.connectedAt=="number",Uc=()=>{let e=Z.get(xc);return e&&Array.isArray(e)&&e.map(o=>w3(o)).every(Boolean)?e:[]};import{ofetch as b3}from"ofetch";var E3=[Ga,za,Va,qa],Hs=class{constructor(t,r,o){this.appId=t,this.clientAnalyticsId=r.clientAnalyticsId,this.sdkVersion=Pc,this.client=r,this.defaults=o,this.fallbackApiUrl=r.fallbackApiUrl,this.baseFetch=b3.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:n,options:i})=>{let a=new Headers(i.headers);a.set("privy-app-id",this.appId),a.set("privy-ca-id",this.clientAnalyticsId||""),a.set("privy-client",`react-auth:${this.sdkVersion}`);let l=E3.includes(n.toString());if(!a.has("authorization")){let s=await this.client.getAccessToken({disableAutoRefresh:l});s!==null&&a.set("authorization",`Bearer ${s}`)}i.headers=a,i.retryDelay&&(i.retryDelay=i.retryDelay*3)},onRequestError:({error:n})=>{if(n instanceof DOMException&&n.name==="AbortError")throw new Ba}})}async get(t,r){try{return await this.baseFetch(t,r)}catch(o){throw ne(o)}}async post(t,r,o){try{return await this.baseFetch(t,{method:"POST",...r?{body:r}:{},...o})}catch(n){throw ne(n)}}async delete(t,r){try{return await this.baseFetch(t,{method:"DELETE",...r})}catch(o){throw ne(o)}}};var Lm=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 Dn from"js-cookie";function Om(e){return e instanceof go?"email":e instanceof Xo?"sms":e instanceof Qo?"siwe":e instanceof Sn?"custom_auth":e instanceof Ur?e.meta.provider:null}import*as Nm from"jose";var Vr=class{static parse(t){try{return new Vr(t)}catch{return null}}constructor(t){this.value=t,this._decoded=Nm.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 T3=30,Gs=class{constructor(){this.authenticateOnce=new Fe(async t=>this._authenticate(t)),this.linkOnce=new Fe(async t=>this._link(t)),this.refreshOnce=new Fe(this._refresh.bind(this)),this.destroyOnce=new Fe(this._destroy.bind(this)),this.forkSessionOnce=new Fe(this._forkSession.bind(this))}get token(){try{let t=Z.get(qo);return typeof t=="string"?new Vr(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=Z.get(rs);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=Z.get(Ii);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get mightHaveServerCookies(){try{let t=Dn.get(os);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!==Uu}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=Vr.parse(this.token);return t!==null&&!t.isExpired(T3)}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()}async _authenticate(t){try{let r=await t.authenticate(),{user:o,is_new_user:n,oauth_provider_tokens:i}=r;this.handleTokenResponse(r);let a=i?{provider:i.provider,accessToken:i.access_token,accessTokenExpiresInSeconds:i.access_token_expires_in_seconds,refreshToken:i.refresh_token,scopes:i.scopes}:void 0,l=Om(t);return l&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:l,isNewUser:n}}),l==="siwe"&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}}),{user:Kt(o),isNewUser:n,oAuthProviderTokens:a}}catch(r){throw console.warn("Error authenticating session"),at(r)}}async _link(t){try{let r=await t.link(),o=r.oauth_provider_tokens,n=o?{provider:o.provider,accessToken:o.access_token,accessTokenExpiresInSeconds:o.access_token_expires_in_seconds,refreshToken:o.refresh_token,scopes:o.scopes}:void 0;return{user:Kt(r),oAuthProviderTokens:n}}catch(r){throw console.warn("Error linking account"),at(r)}}async _refresh(){if(!this.api)throw new P("Session has no API instance");if(!this.client)throw new P("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,r=this.refreshToken,o=this.forkedToken;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(Ga,a,{headers:i}),o&&this.clearForkedToken()}else if(o)n=await this.api.post(za,{refresh_token:o}),this.clearForkedToken();else return null;return this.handleTokenResponse(n),Kt(n.user)}catch(n){if(n instanceof br&&n.privyErrorCode==="missing_or_invalid_token")return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw at(n)}}handleTokenResponse(t){t.session_update_action?t.session_update_action==="set"?(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token)):t.session_update_action==="clear"?this.destroyLocalState():t.session_update_action==="ignore"&&t.token&&this.storeToken(t.token):(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token))}async _destroy(){try{await this.api?.post(Va,{refresh_token:this.refreshToken})}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new P("Session has no API instance");let t=this.refreshToken;try{let r=await this.api.post(xp,{refresh_token:t});return this.storeRefreshToken(r.refresh_token),this.storeToken(r.token),r.new_session_refresh_token}catch(r){throw at(r)}}destroyLocalState(){this.storeRefreshToken(null),this.storeToken(null),this.clearForkedToken()}storeToken(t){if(typeof t=="string"){let r=Z.get(qo);if(Z.put(qo,t),!this.client?.useServerCookies){let o=Vr.parse(t)?.expiration;Dn.set(Sc,t,{sameSite:"Strict",secure:!0,expires:o?new Date(o*1e3):void 0})}r!==t&&this.client?.onStoreToken?.(t)}else Z.del(qo),Dn.remove(Sc),this.client?.onDeleteToken?.()}storeRefreshToken(t){typeof t=="string"?(Z.put(rs,t),this.client?.useServerCookies||Dn.set(os,"t",{sameSite:"Strict",secure:!0,expires:30})):(Z.del(rs),Dn.remove(Iu),Dn.remove(os))}clearForkedToken(){Z.del(Ii)}};var Bc,Vs,Dm,$i=class{constructor(t){Fa(this,Vs);this.apiUrl=t.apiUrl||Ri,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!1,this.timeout=t.timeout||Au,this.appId=t.appId,this.clientAnalyticsId=_p(this,Vs,Dm).call(this),Bc||(Bc=new Gs),this.session=Bc,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 qi(this.appId,t,r,o,n,i,a,l,s,c))}sessionHasActiveToken(){return this.session.hasActiveToken()}generateApi(){let t=new Hs(this.appId,this,{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 P("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new P("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.authFlow=void 0}startAuthFlow(t){return t.api=this.api,this.authFlow=t,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(su,{action:"verify"})}catch(t){throw ne(t)}}async initMfaPasskeyVerification(){try{let t=await this.api.post(lu,{});return Lm(t.options)}catch(t){throw ne(t)}}async unlinkEmail(t){try{let r=await this.api.post(Bp,{address:t});return Kt(r)}catch(r){throw at(r)}}async acceptTerms(){try{let t=await this.api.post(cu,{});return Kt(t)}catch(t){throw at(t)}}async unlinkPhone(t){try{let r=await this.api.post(zp,{phoneNumber:t});return Kt(r)}catch(r){throw at(r)}}async unlinkWallet(t){try{let r=await this.api.post(Ip,{address:t});return Kt(r)}catch(r){throw at(r)}}async unlinkOAuth(t,r){try{let o=await this.api.post(Yp,{provider:t,subject:r});return Kt(o)}catch(o){throw at(o)}}async unlinkFarcaster(t){try{let r=await this.api.post(Np,{fid:t});return Kt(r)}catch(r){throw at(r)}}async unlinkTelegram(t){try{let r=await this.api.post(au,{telegram_user_id:t});return Kt(r)}catch(r){throw at(r)}}async unlinkPasskey(t){try{let r=await this.api.post(ou,{credential_id:t});return Kt(r)}catch(r){throw at(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(qa,{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(du,t)}catch(r){throw at(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){return this.session.hasActiveToken()?Vr.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}: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}}catch(t){throw at(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()}};Vs=new WeakSet,Dm=function(){if(typeof window>"u")return null;try{let r=Z.get(Mi);if(typeof r=="string"&&r.length>0)return r}catch{}let t=P3();try{return Z.put(Mi,t),t}catch{return t}};import{Turnstile as R3}from"@marsidev/react-turnstile";import{useEffect as I3,useMemo as M3}from"react";import{useMemo as S3,useRef as _3,useContext as x3,useState as Hc,createContext as k3}from"react";import{jsx as A3}from"react/jsx-runtime";var Um=k3({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}),Tr=class extends ze{constructor(r,o,n){super(r||"Captcha failed");this.type="Captcha";o instanceof Error&&(this.cause=o),this.privyErrorCode=n}},Fm=({children:e,id:t,captchaSiteKey:r,captchaEnabled:o})=>{let n=_3(null),[i,a]=Hc(),[l,s]=Hc(),[c,u]=Hc(!1),h=S3(()=>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 A3(Um.Provider,{value:{...h,ref:n,enabled:o,siteKey:r,appId:t,setToken:a,setError:s,setExecuting:u,remove(){o&&(n.current?.remove(),u(!1),s(void 0),a(void 0))},reset(){o&&(n.current?.reset(),u(!1),s(void 0),a(void 0))},execute(){o&&(u(!0),n.current?.execute())},async waitForResult(){if(!o)return"";try{return await hu(()=>n.current?.getResponse(),{interval:200,timeout:2e4})}catch{throw new Tr("Captcha failed",null,"captcha_timeout")}}},children:e})},he=()=>x3(Um);import{jsx as Bm}from"react/jsx-runtime";var Gc=e=>{let{enabled:t,siteKey:r,appId:o,setError:n,setToken:i,setExecuting:a,ref:l}=he(),[,s]=M3(()=>r?.split("t:")||[],[r]);if(I3(()=>l.current?.remove,[]),!t)return null;if(!s)throw new Error("Unsupported captcha site key");return Bm("div",{className:"hidden h-0 w-0",children:Bm(R3,{...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 I8,useEffect as Zg,useRef as M8,useState as W8}from"react";import L8 from"react-dom";import{createContext as W3,useContext as L3}from"react";var Vc=W3({isNewUserThisSession:!1,linkingHint:null,walletConnectionStatus:null,mipdStore: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,resendEmailCode:E,resendSmsCode:E,initLoginWithHeadlessOAuth:E,loginWithHeadlessOAuth: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,recoverEmbeddedWallet:E,getFiatOnRampConfig:E,updateWallets:E,fundWallet:E,setReadyToTrue:E,requestFarcasterSignerStatus:E,initLoginWithTelegram:E,loginWithTelegram:E}),M=()=>L3(Vc);import{createContext as O3,useContext as N3}from"react";var ve=O3({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:E,login:E,connectOrCreateWallet:E,linkEmail:E,linkPhone:E,linkFarcaster:E,linkWallet: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,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,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,requestFarcasterSignerFromWarpcast:E,getFarcasterSignerPublicKey:E,signFarcasterMessage:E,initLoginWithEmail:E,initLoginWithSms:E,otpState:{status:"initial"},loginWithCode:E,fundWallet:E,initLoginWithHeadlessOAuth:E,loginWithHeadlessOAuth:E,isHeadlessOAuthLoading:!1,isModalOpen:!1,mfaMethods:[]}),F=()=>N3(ve);import{useEffect as D3,useState as U3}from"react";var Hm=e=>{let[t,r]=U3("auto");return D3(()=>{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 F3,useContext as B3,useEffect as H3}from"react";var Gm={login:{onComplete:[],onError:[],onOAuthLoginComplete:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]}},zc=F3(void 0),Vm=()=>B3(zc);function He(e,t){if(!t)return;let o=Vm().current[e];return H3(()=>{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 U(e,t,r,...o){for(let n of e.current[t][r])n(...o)}function zs(){let e=Vm();return(t,r,...o)=>U(e,t,r,...o)}function qc(e){He("configureMfa",e)}import Jm from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import a0 from"@heroicons/react/24/solid/DocumentCheckIcon";import s0 from"styled-components";import tn,{css as Yc}from"styled-components";import Kc from"styled-components";import{Fragment as V3,jsx as $c,jsxs as z3}from"react/jsx-runtime";var et=({success:e,fail:t})=>z3(V3,{children:[$c(tt,{className:e?"success":t?"fail":""}),$c(jc,{className:e?"success":t?"fail":""})]}),tt=Kc.span`
|
|
12
|
+
- https://privy.io`;this.getNonceOnce=new Fe(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=r}get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");try{let{message:t,signature:r}=await this.sign(),o=await this.api.post(Ap,{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,is_new_user:o.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");try{let{message:t,signature:r}=await this.sign();return await this.api.post(Rp,{message:t,signature:r,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(t){throw ne(t)}}async sign(){if(!this.api)throw new P("Auth flow has no API instance");if(await this.buildSiweMessage(),!this.preparedMessage)throw new P("Could not prepare SIWE message");let t=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:t}}async _getNonceOnce(){if(!this.api)throw new P("Auth flow has no API instance");let t=this.wallet.address;return(await this.api.post(kp,{address:t,token:this.captchaToken})).nonce}async buildSiweMessage(){if(!this.api)throw new P("Auth flow has no API instance");let t=this.wallet.address,r=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=this.prepareMessage(r,t,this.nonce),this.preparedMessage}prepareMessage(t,r,o){let n=window.location.host,i=window.location.origin,a="By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",l=new Date().toISOString();return this.createSiweMessage(t,r,n,i,l,o,a)}};var Xo=class{constructor(t,r){this.meta={phoneNumber:t,captchaToken:r}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new P("phone number and sms code must be set prior to calling authenticate.");try{let t=await this.api.post(qp,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new P("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Vp,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(t){throw ne(t)}}async sendSmsCode(t,r){if(!this.api)throw new P("Auth flow has no API instance");if(t&&(this.meta.phoneNumber=t),r&&(this.meta.captchaToken=r),!this.meta.phoneNumber)throw new P("phone nNumber must be set when initialzing authentication.");try{return await this.api.post(Gp,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken})}catch(o){throw ne(o)}}};var Di=class{constructor(t){this.meta={captchaToken:t}}async authenticate(){if(!this.api)throw new P("Auth flow has no API instance");try{let t=await this.api.post(nu,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult});return{user:t.user,token:t.token,refresh_token:t.refresh_token,is_new_user:t.is_new_user}}catch(t){throw ne(t)}}async link(){if(!this.api)throw new P("Auth flow has no API instance");try{return await this.api.post(iu,{telegram_auth_result:this.meta.telegramAuthResult})}catch(t){throw ne(t)}}};function Ic(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}import{v4 as P3}from"uuid";function j(e){return e?new Date(e*1e3):null}function M2(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:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at),chainType:"ethereum",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"email":let i={address:r.address,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(i);break;case"phone":let a={number:r.phoneNumber,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(a);break;case"google_oauth":let l={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(l);break;case"spotify_oauth":let s={subject:r.subject,email:r.email,name:r.name,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(s);break;case"instagram_oauth":let c={subject:r.subject,username:r.username,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(c);break;case"twitter_oauth":let u={subject:r.subject,username:r.username,name:r.name,type:r.type,profilePictureUrl:r.profile_picture_url,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(u);break;case"discord_oauth":let h={subject:r.subject,username:r.username,email:r.email,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(h);break;case"github_oauth":let f={subject:r.subject,username:r.username,name:r.name,email:r.email,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(f);break;case"tiktok_oauth":let y={subject:r.subject,username:r.username,name:r.name,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(y);break;case"linkedin_oauth":let v={subject:r.subject,name:r.name,email:r.email,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(v);break;case"apple_oauth":let g={subject:r.subject,email:r.email,type:r.type,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(g);break;case"custom_auth":t.push({type:r.type,customUserId:r.custom_user_id,verifiedAt:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)});break;case"farcaster":let k={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:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at),signerPublicKey:r.signer_public_key};t.push(k);break;case"passkey":let w={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:j(r.verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(w);break;case"telegram":let b={type:r.type,telegramUserId:r.telegram_user_id,firstName:r.first_name,lastName:r.last_name,username:r.username,photoUrl:r.photo_url,verifiedAt:j(r.first_verified_at),firstVerifiedAt:j(r.first_verified_at),latestVerifiedAt:j(r.latest_verified_at)};t.push(b);break;default:console.warn(`Unrecognized account type: ${o}. Please consider upgrading the Privy SDK.`)}}return t}function Mt(e,t){return e.slice().sort((r,o)=>(o.firstVerifiedAt??o.verifiedAt).getTime()-(r.firstVerifiedAt??r.verifiedAt).getTime()).find(r=>r.type===t)}var Ie=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&!t.imported)||null,Mc=e=>e?.linkedAccounts.find(t=>t.type==="wallet"&&t.walletClientType==="privy"&&t.imported)||null,W2=e=>e.linkedAccounts.filter(t=>t.type==="wallet"),Wt=(e,t)=>t==="all-users"&&!Ie(e)||t==="users-without-wallets"&&!W2(e)?.length;function Kt(e){if(!e)return null;let t=M2(e.linked_accounts),r=Mt(t,"wallet"),o=Mt(t,"email"),n=Mt(t,"phone"),i=Mt(t,"google_oauth"),a=Mt(t,"twitter_oauth"),l=Mt(t,"discord_oauth"),s=Mt(t,"github_oauth"),c=Mt(t,"spotify_oauth"),u=Mt(t,"instagram_oauth"),h=Mt(t,"tiktok_oauth"),f=Mt(t,"linkedin_oauth"),y=Mt(t,"apple_oauth"),v=Mt(t,"farcaster"),g=Mt(t,"telegram"),k=e.mfa_methods.map(({type:b,verified_at:_})=>({type:b,verifiedAt:j(_)}));return{id:e.id,createdAt:j(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:u&&{subject:u.subject,username:u.username},tiktok:h&&{subject:h.subject,username:h.username,name:h.name},linkedin:f&&{subject:f.subject,name:f.name,email:f.email},apple:y&&{subject:y.subject,email:y.email},farcaster:v&&{fid:v.fid,ownerAddress:v.ownerAddress,displayName:v.displayName,username:v.username,bio:v.bio,pfp:v.pfp,url:v.url,signerPublicKey:v.signerPublicKey},telegram:g&&{telegramUserId:g.telegramUserId,firstName:g.firstName,lastName:g.lastName,username:g.username,photoUrl:g.photoUrl},mfaMethods:k.map(b=>b.type),hasAcceptedTerms:e.has_accepted_terms??!1}}import{getAddress as Wm}from"@ethersproject/address";import{isHexString as v3}from"@ethersproject/bytes";import C3 from"eventemitter3";import V2 from"@coinbase/wallet-sdk";import{jsx as ju,jsxs as L2}from"react/jsx-runtime";var Ui=({style:e,...t})=>L2("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:[ju("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),ju("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 Br}from"@ethersproject/address";import{Web3Provider as em}from"@ethersproject/providers";import{default as H2}from"eventemitter3";import B2 from"eventemitter3";var O2=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4"],Yu=e=>O2.includes(e);import{ErrorCode as N2}from"@ethersproject/logger";var kn=class extends te{constructor(){super("Wallet timeout");this.type="wallet_error"}},An=class extends te{constructor(){super("User rejected connection");this.type="wallet_error"}},Er=e=>{if(e instanceof te)return e;if(e?.code&&e?.reason){let t=new Be(e);return e.code===N2.ACTION_REJECTED&&(t.details=st.E4001_USER_REJECTED_REQUEST),t}return e?.code?new Be(e):new te("Unknown connector error",e)},jt=class extends ze{constructor(r,o,n){super(r);this.type="provider_error";this.code=o,this.data=n}},Be=class extends jt{constructor(r){let o=r;super(o.message,o.code,o.data);let n=Object.values(st).find(i=>i.eipCode===o.code);this.details=n||st.UNKNOWN_ERROR,o.code===-32002&&(o.message?.includes("already pending for origin")?o.message?.includes("wallet_requestPermissions")?this.details=st.E32002_CONNECTION_ALREADY_PENDING:this.details=st.E32002_REQUEST_ALREADY_PENDING:o.message?.includes("Already processing")&&o.message.includes("eth_requestAccounts")&&(this.details=st.E32002_WALLET_LOCKED))}},D2={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}},U2={E32002_CONNECTION_ALREADY_PENDING:{eipCode:-32002,message:"Connection request already pending",detail:"Don\u2019t see your wallet? Check your other browser windows.",retryable:!1},E32002_REQUEST_ALREADY_PENDING:{eipCode:-32002,message:"Resource request already pending",detail:"Don\u2019t see your wallet? Check your other browser windows.",retryable:!1},E32002_WALLET_LOCKED:{eipCode:-32002,message:"Wallet might be locked",detail:"Don\u2019t see your wallet? Check your other browser windows.",retryable:!1},E4001_USER_REJECTED_REQUEST:{eipCode:4001,message:"Signature rejected",detail:"Please try signing again.",retryable:!0}},F2={E4001_DEFAULT_USER_REJECTED_REQUEST:{eipCode:4001,message:"User Rejected Request",detail:"The user rejected the request.",default:!0,retryable:!0},E4100_DEFAULT_UNAUTHORIZED:{eipCode:4100,message:"Unauthorized",detail:"The requested method and/or account has not been authorized by the user.",default:!0,retryable:!1},E4200_DEFAULT_UNSUPPORTED_METHOD:{eipCode:4200,message:"Unsupported Method",detail:"The Provider does not support the requested method.",default:!0,retryable:!1},E4900_DEFAULT_DISCONNECTED:{eipCode:4900,message:"Disconnected",detail:"The Provider is disconnected from all chains.",default:!0,retryable:!0},E4901_DEFAULT_CHAIN_DISCONNECTED:{eipCode:4901,message:"Chain Disconnected",detail:"The Provider is not connected to the requested chain.",default:!0,retryable:!0},E32700_DEFAULT_PARSE_ERROR:{eipCode:-32700,message:"Parse error",detail:"Invalid JSON",default:!0,retryable:!1},E32600_DEFAULT_INVALID_REQUEST:{eipCode:-32600,message:"Invalid request",detail:"JSON is not a valid request object",default:!0,retryable:!1},E32601_DEFAULT_METHOD_NOT_FOUND:{eipCode:-32601,message:"Method not found",detail:"Method does not exist",default:!0,retryable:!1},E32602_DEFAULT_INVALID_PARAMS:{eipCode:-32602,message:"Invalid params",detail:"Invalid method parameters",default:!0,retryable:!1},E32603_DEFAULT_INTERNAL_ERROR:{eipCode:-32603,message:"Internal error",detail:"Internal JSON-RPC error",default:!0,retryable:!0},E32000_DEFAULT_INVALID_INPUT:{eipCode:-32e3,message:"Invalid input",detail:"Missing or invalid parameters",default:!0,retryable:!1},E32001_DEFAULT_RESOURCE_NOT_FOUND:{eipCode:-32001,message:"Resource not found",detail:"Requested resource not found",default:!0,retryable:!1},E32002_DEFAULT_RESOURCE_UNAVAILABLE:{eipCode:-32002,message:"Resource unavailable",detail:"Requested resource not available",default:!0,retryable:!0},E32003_DEFAULT_TRANSACTION_REJECTED:{eipCode:-32003,message:"Transaction rejected",detail:"Transaction creation failed",default:!0,retryable:!0},E32004_DEFAULT_METHOD_NOT_SUPPORTED:{eipCode:-32004,message:"Method not supported",detail:"Method is not implemented",default:!0,retryable:!1},E32005_DEFAULT_LIMIT_EXCEEDED:{eipCode:-32005,message:"Limit exceeded",detail:"Request exceeds defined limit",default:!0,retryable:!1},E32006_DEFAULT_JSON_RPC_VERSION_NOT_SUPPORTED:{eipCode:-32006,message:"JSON-RPC version not supported",detail:"Version of JSON-RPC protocol is not supported",default:!0,retryable:!1}},st={UNKNOWN_ERROR:{eipCode:0,message:"Unknown error",detail:"Unknown error",retryable:!0},...F2,...U2},no={...D2,...st};var Oe=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 kn,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||Yo,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 te(`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 Er(r)})}},wo=class extends Error{constructor(r,o,n){super(r);this.code=o,this.data=n}},Fi=class extends B2{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=ro(l,this.chains,n,{appId:a}),this.rpcTimeoutDuration=Rn(n,"privy"),this.appId=a}async handleSendTransaction(r){if(!r.params||!Array.isArray(r.params))throw new wo(`Invalid params for ${r.method}`,4200);let o=r.params[0];if(!await Ee()||!this.address)throw new wo("Disconnected",4900);return(await Qu(o)).hash}handleSwitchEthereumChain(r){if(!r.params||!Array.isArray(r.params))throw new wo(`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 wo(`Invalid params for ${r.method}`,4200);this.chainId=Number(o),this.provider=ro(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 Zu(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 Ju(Qa(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:zo(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 zo(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(Yu(r.method)){let o=await Ee();if(await Xu(),!o||!this.address)throw new wo("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 wo("Disconnected",4900)}}else return this.provider.send(r.method,r.params)}async connect(){let r=await Ee();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}}},Fr=class extends Oe{constructor(r){super(r,r.rpcTimeoutDuration)}},bo=class extends Oe{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 G2=(e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");default:return e.code===4902||e.message?.includes("4902")}},Lt=class extends H2{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=_n(r),this.walletClientType==="privy"&&Z.put(ns(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=Rn(i,r),this.connected=!1,this.initialized=!1}buildConnectedWallet(r,o,n,i){let a=async()=>!!this.wallets.find(l=>Br(l.address)===Br(r));return{address:Br(r),chainId:o,meta:n,imported:i,switchChain:async l=>{if(!a)throw new te("Wallet is not currently connected.");let s=this.wallets.find(y=>Br(y.address)===Br(r))?.chainId;if(!s)throw new te("Unable to determine current chainId.");let c,u;if(typeof l=="number"?(c=`0x${l.toString(16)}`,u=l):(c=l,u=Number(l)),s===_n(c))return;let h=this.chains.find(y=>y.id===u);if(!h)throw new te(`Unsupported chainId: ${l}`);let f=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:c}]})};try{return await f()}catch(y){if(G2(y,this.walletClientType))return await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:c,chainName:h.name,nativeCurrency:h.nativeCurrency,rpcUrls:[h.rpcUrls.default?.http[0]??""],blockExplorerUrls:[h.blockExplorers?.default.url??""]}]}),f();throw this.walletClientType==="rainbow"&&y.message?.includes("wallet_switchEthereumChain")?new te(`Rainbow does not support the chainId ${o}`):y}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:a,getEthereumProvider:async()=>{if(!await a())throw new te("Wallet is not currently connected.");return this.proxyProvider},getEthersProvider:async()=>{if(!await a())throw new te("Wallet is not currently connected.");return new em(new Fr(this.proxyProvider))},getWeb3jsProvider:async()=>{if(!await a())throw new te("Wallet is not currently connected.");return new bo(this.proxyProvider)},sign:async l=>{if(!await a())throw new te("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 ki(()=>this.proxyProvider.request({method:"eth_accounts"}),{maxAttempts:10,delayMs:500});Array.isArray(c)&&(o=c)}}catch{console.warn("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.")}if(!o||!Array.isArray(o)||o.length<=0||!o[0])return;let n=o[0],i=Br(n),a=[],l;if(this.walletClientType==="privy"){let c=Z.get(ns(i));this.chains.find(u=>u.id===Number(c))||(Z.del(ns(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 ki(()=>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 ${kc}`,c),l=kc}let s=_n(l);if(!a.find(c=>Br(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(Br(n),s,c,this.connectorType==="embedded_imported"))}ws(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=>Br(n)===Br(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 em(new Fr(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 z2=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],q2=(e,t)=>e.makeWeb3Provider({options:t}),Wc,bs=class extends Lt{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 Oe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=i.coinbaseWallet.connectionOptions??"eoaOnly",this.walletClientType=this.connectionOptions==="smartWalletOnly"?"coinbase_smart_wallet":"coinbase_wallet",this.walletClientType==="coinbase_smart_wallet"&&(this.displayName="Coinbase Smart Wallet"),!Wc){let s=[o.id].concat(r.map(u=>u.id)),c=this.connectionOptions!=="eoaOnly"?s.filter(u=>!z2.includes(u)):[];c.length>0&&console.warn(`The following configured chains are not supported by the Coinbase Smart Wallet: ${c.join(", ")}`),Wc=new V2({appName:a,appLogoUrl:l,appChainIds:s})}this.proxyProvider.setWalletProvider(q2(Wc,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:Ui,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 te("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([r[0]])}catch(r){throw Er(r)}}};import{jsx as tm}from"react/jsx-runtime";var Es=({...e})=>tm("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:tm("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 Bi=class extends Lt{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:[zo(r?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Es,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}};import{jsx as rm}from"react/jsx-runtime";var In=({style:e,...t})=>rm("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...e},...t,children:rm("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 Yt,jsxs as $2}from"react/jsx-runtime";var Mn=({style:e,...t})=>$2("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:[Yt("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),Yt("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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"}),Yt("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 om,jsxs as K2}from"react/jsx-runtime";var Hr=({style:e,...t})=>K2("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:[om("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),om("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 Ln=class extends Lt{constructor(r,o,n,i,a){super(a||"unknown",r,o,n);this.connectorType="injected";this.proxyProvider=new Oe(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 te("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw Er(r)}}},Wn,On=class extends Lt{constructor(r,o,n,i,a){super(a??"unknown",r,o,n);this.connectorType="injected";Fa(this,Wn,void 0);this.proxyProvider=new Oe(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(i),a==="metamask"?Cc(this,Wn,{name:"MetaMask",icon:Mn,id:"io.metamask"}):a==="phantom"&&Cc(this,Wn,{name:"Phantom",icon:Hr,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 Sp(this,Wn)??{name:"Browser Extension",icon:In,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 te("Unable to retrieve accounts");await this.syncAccounts([r[0]])}catch(r){throw Er(r)}}};Wn=new WeakMap;import{getAddress as SP}from"@ethersproject/address";import{Web3Provider as xP}from"@ethersproject/providers";import{isMobile as j2}from"react-device-detect";var Ts=class extends Ln{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{j2||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 te("Unable to retrieve accounts");await this.syncAccounts([t[0]])}catch(t){throw Er(t)}}};var Ps=class extends Lt{constructor(r,o){super(r,[],o,{});this.connectorType="null";this.proxyProvider=new Oe(void 0,Yo);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 Ss=class extends Ps{constructor(t){super("phantom",t)}get walletBranding(){return{name:"Phantom",icon:Hr,id:"phantom"}}};import{EthereumProvider as f3,OPTIONAL_EVENTS as h3,OPTIONAL_METHODS as y3}from"@walletconnect/ethereum-provider";import{isMobile as g3}from"react-device-detect";import{createContext as a3,useContext as s3,useEffect as Dc,useRef as l3,useState as c3}from"react";import{jsx as Y2}from"react/jsx-runtime";function _s({src:e,...t}){return Y2("img",{src:e,...t,style:{display:"none"}})}import{useContext as km,useEffect as xm,useMemo as r3,useState as o3}from"react";import{createContext as n3}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:ku,rpcConfig:{rpcUrls:{},rpcTimeouts:{}},externalWallets:{coinbaseWallet:{connectionOptions:"eoaOnly"}},captchaEnabled:!1,_render:{inDialog:!0,inParentNodeId:null},fiatOnRamp:{useSandbox:!1}};var nm=({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 Z2=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","wallet_connect","detected_wallets","rabby_wallet"]),im=e=>Z2.has(e),am=(e,t,r)=>r.indexOf(e)===t,sm=({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(im).filter(am):e?e.filter(im).filter(am):Ot.appearance.walletList;var xs={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 ks={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 As={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 lm={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 cm={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 Rs={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 Is={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 Ms={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 dm={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 pm={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 um={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 mm={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 fm={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 hm={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 ym={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 gm={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 vm={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 Cm={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 Ws={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 Ls={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 Os={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 Ns={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 Hi={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 Gi={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 wm={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 bm={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 Em={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 Ds={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 Us={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 Fs={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 Vi=[xs,ks,As,ym,Em,Ws,Ls,Os,Ns,Hi,Gi,pm,um,mm,fm,Rs,Is,Ms,dm,vm,Cm,lm,cm,Ds,Fs,Us,gm,wm,hm,bm],XS=new Set(Vi.map(e=>e.id));import en from"tinycolor2";var Tm="#FFFFFF",J2="#000000",Q2=Tm,X2="#1E1E1D";function e3(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 io(e,t){let r=Math.max(0,Math.min(1,e.toHsl().l+t));return en({...e.toHsl(),l:r})}function Pm({backgroundTheme:e,accentHex:t,successHex:r="#51BA81",warnHex:o="#FFB74D",errorHex:n="#EC6351",whiteHex:i=Tm,blackHex:a=J2}){let l;switch(e){case"light":l=Q2;break;case"dark":l=X2;break;default:l=e;break}let s=en(l),c=en(t),u=en(r),h=en(o),f=en(n),y=e3(s.getLuminance()),v=io(s,y==="light"?-.04:.11),g=io(s,y==="light"?-.88:.87),k=io(s,y==="light"?-.77:.75),w=io(s,y==="light"?-.43:.45).desaturate(y==="light"?60:20),b=io(s,y==="light"?-.08:.25).desaturate(y==="light"?60:20),_=io(c,.15),A=io(c,-.06),N=io(f,.3),I=en(c.getLuminance()>.5?a:i),R=io(u,-.16);return{colorScheme:y,background:s.toHslString(),background2:v.toHslString(),foreground:g.toHslString(),foreground2:k.toHslString(),foreground3:w.toHslString(),foreground4:b.toHslString(),accent:c.toHslString(),accentLight:_.toHslString(),accentDark:A.toHslString(),foregroundAccent:I.toHslString(),success:u.toHslString(),successDark:R.toHslString(),error:f.toHslString(),errorLight:N.toHslString(),warn:h.toHslString()}}function Lc(e,t,r){let o=r?console.warn:()=>{},n,i,a,l,s,c,u,h,f,y,v,g,k,w,b;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"),u=t.loginMethods.includes("discord"),f=t.loginMethods.includes("spotify"),y=t.loginMethods.includes("instagram"),h=t.loginMethods.includes("tiktok"),g=t.loginMethods.includes("github"),v=t.loginMethods.includes("linkedin"),k=t.loginMethods.includes("apple"),w=t.loginMethods.includes("farcaster"),b=t.loginMethods.includes("telegram")):(n=e.emailAuth,i=e.smsAuth,l=e.walletAuth,s=e.googleOAuth,c=e.twitterOAuth,u=e.discordOAuth,g=e.githubOAuth,f=e.spotifyOAuth,y=e.instagramOAuth,h=e.tiktokOAuth,v=e.linkedinOAuth,k=e.appleOAuth,w=e.farcasterAuth,b=e.telegramAuth),typeof window<"u"&&typeof window.PublicKeyCredential!="function"?a=!1:e.passkeyAuth&&(a=!0);let _=[n,i].filter(Boolean),A=[s,c,u,g,f,y,h,v,k,w,b].filter(Boolean),N=[l].filter(Boolean);if(_.length+A.length+N.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&&N.length===0?(o("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),I=!1):!I&&A.length+_.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),t?.loginMethods&&t.loginMethodsAndOrder&&o("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let R=sm({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),B=nm({input:t?.loginMethodsAndOrder}),K=t?.intl?.defaultCountry??"US",{chains:Y,defaultChain:W}=t3({additionalChains:t?.additionalChains,supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain,hasRpcConfigDefined:Object.keys(t?.rpcConfig?.rpcUrls??{}).length>0}),V=!!t?.defaultChain,L=t?.customAuth?.getCustomAccessToken&&t?.customAuth?.enabled!==!1,ae,de=!(e.enforceWalletUis??!0);if(e.legacyWalletUiConfig??!0?L?ae=t?.embeddedWallets?.noPromptOnSignature??!0:ae=t?.embeddedWallets?.noPromptOnSignature??de:ae=de,t?.embeddedWallets?.waitForTransactionConfirmation===!1&&ae!==!0)throw new Error("Overriding `config.embeddedWallets.waitForTransactionConfirmation` requires that you disable wallet UIs in the dashboard.");let{requireUserPasswordOnCreate:pe,...we}=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,palette:Pm({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:R},loginMethods:{wallet:l,email:n,sms:i,passkey:a,google:s,twitter:c,discord:u,github:g,spotify:f,instagram:y,tiktok:h,linkedin:v,apple:k,farcaster:w,telegram:b},loginMethodsAndOrder:B,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:Y,defaultChain:W,intl:{defaultCountry:K},shouldEnforceDefaultChainOnConnect:V,captchaEnabled:e.captchaEnabled??Ot.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??Ot.externalWallets.coinbaseWallet.connectionOptions}},embeddedWallets:{...e.embeddedWalletConfig,...typeof pe=="boolean"?{requireUserOwnedRecoveryOnCreate:pe}:{},...L?{createOnLogin:"all-users",requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]}:{},waitForTransactionConfirmation:!0,priceDisplay:{primary:"fiat-currency",secondary:"native-token"},...we,noPromptOnSignature:ae},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},customAuth:L?{enabled:!0,...t.customAuth}:void 0,fiatOnRamp:{enabled:e.fiatOnRampEnabled,useSandbox:t?.fiatOnRamp?.useSandbox??Ot.fiatOnRamp.useSandbox},loginConfig:{twitterOAuthOnMobileEnabled:e.twitterOAuthOnMobileEnabled??!1,telegramAuthConfiguration:e.telegramAuthConfiguration},headless:!!t?.headless,render:{inDialog:t?._render?.inDialog??Ot._render.inDialog,inParentNodeId:t?._render?.inParentNodeId??Ot._render.inParentNodeId}}}function Sm(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,...r?{...r,...r.logo&&typeof r.logo?{logo:"component"}:void 0}:void 0,legacyCreateEmbeddedWalletFlag:t}}function t3({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:Vi.find(u=>u.id===s.id)??s)}else n=Vi.concat(e??[]);let i=t?n[0]:Ws,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 _m=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 i3}from"react/jsx-runtime";var Am={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:""},Oc=Lc(Am,void 0,!1),Nc=n3({appConfig:Oc,isServerConfigLoaded:!1}),Rm=({children:e,legacyCreateEmbeddedWalletFlag:t,client:r,clientConfig:o})=>{let[n,i]=o3(null),a=r3(()=>Lc(n??Am,o,!!n),[n,o]);return xm(()=>{if(!n)return;let l=Sm(o,t),s=_m(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]),xm(()=>{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)}})()},[]),i3(Nc.Provider,{value:{appConfig:a,isServerConfigLoaded:!!n},children:e})},Nt=()=>{let{appConfig:e}=km(Nc);return e},Bs=()=>{let{isServerConfigLoaded:e}=km(Nc);return e};var E=()=>{throw new Error("You need to wrap your application with the <PrivyProvider> initialized with your app id.")};import{jsx as p3,jsxs as u3}from"react/jsx-runtime";var Im=a3({ready:!1,app:Oc,currentScreen:null,lastScreen:null,navigate:E,navigateBack:E,resetNavigation:E,setModalData:E,onUserCloseViaDialogOrKeybindRef:void 0}),d3=["LANDING","CONNECT_ONLY_LANDING_SCREEN",null],Mm=e=>{let t=Nt(),r=e.authenticated,[o,n]=c3(e.initialScreen);Dc(()=>{!r&&!d3.includes(e.initialScreen)&&e.setInitialScreen(null)},[r]);let i=l3(null);Dc(()=>{e.open||(i.current=null)},[e.open]),Dc(()=>{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 u3(Im.Provider,{value:a,children:[(typeof t.appearance.logo=="string"||t.appearance.logo?.type==="img")&&p3(_s,{src:typeof t.appearance.logo=="string"?t.appearance.logo:t.appearance.logo.props.src}),e.children]})},x=()=>s3(Im);import{jsx as Nn,jsxs as m3}from"react/jsx-runtime";var zi=({style:e,...t})=>{let{app:r}=x();return m3("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:[Nn("rect",{width:"28",height:"28",rx:"3",fill:r?.appearance.palette.colorScheme==="dark"?"#3396ff":"#141414"}),Nn("g",{clipPath:"url(#clip0_1765_9946)",children:Nn("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"})}),Nn("defs",{children:Nn("clipPath",{id:"clip0_1765_9946",children:Nn("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};var Gr=class extends Lt{constructor(r,o,n,i,a,l,s){super(s||"unknown",n,i,o);this.connectorType="wallet_connect_v2";this.privyAppId=l,this.walletConnectCloudProjectId=r,this.rpcConfig=o,this.shouldEnforceDefaultChainOnConnect=a,this.proxyProvider=new Oe(void 0,this.rpcTimeoutDuration),s&&(this.walletEntry=es[s],this.walletClientType=s)}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=Xa(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:Mn,id:"io.metamask"}:{name:yu(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:this.walletProvider?.session?.peer.metadata.icons?.[0]||zi,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=es[r],this.walletClientType=r,this.redirectUri=void 0,Eu(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise((r,o)=>{let n=()=>{o(new An)};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 te("Unable to retrieve address");if(this.walletProvider?.session?.peer.metadata.url){let s=Xa(this.walletProvider?.session?.peer.metadata.url);this.walletEntry=s?.entry,this.walletClientType=s?.walletClientType||"unknown",this.proxyProvider.rpcTimeoutDuration=Rn(this.rpcConfig,this.walletClientType)}this.connected=!0,await this.syncAccounts(l),r()})().catch(a=>{if(a){o(Er(a));return}o(new te("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=vu(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 f3.init({projectId:this.walletConnectCloudProjectId,chains:o,optionalChains:n,optionalEvents:h3,optionalMethods:y3,rpcMap:r,showQrModal:!1});return i.on("display_uri",a=>{if(i.signer.abortPairingAttempt(),g3&&this.walletEntry){let{redirect:l,href:s}=wu(a,this.walletEntry);Tu({href:s,name:this.walletEntry.displayName}),this.redirectUri=l,ts(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=Xa(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 Fc=e=>{let t=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses")?.split(" ").filter(o=>v3(o)).map(o=>Wm(o));return t?.length?!!e?.linkedAccounts.filter(o=>o.type=="wallet"&&t.includes(o.address)).length:!1},Rn=(e,t)=>e.rpcTimeouts?e.rpcTimeouts[t]||Yo:Yo,qi=class extends C3{constructor(r,o,n,i,a,l,s,c,u,h,f){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 Oe: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=u,this.privyAppName=h,this.privyAppLogo=f,this.storedConnections=Uc()}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;Z.get(_c)&&(Z.getKeys().forEach(o=>{o.startsWith("walletconnect")&&Z.del(o)}),Z.del(_c));let r=gu(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"),!vo()&&this.walletList.includes("phantom")&&this.createWalletConnector("phantom","phantom"),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 Fi(r,o,this.rpcConfig,this.chains,i,n.id),s=new Bi(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 Fi(r,o,this.rpcConfig,this.chains,i,n.id),s=!0,c=new Bi(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=Uc(),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=Uc(),this.emit("walletsUpdated")}}async createWalletConnector(r,o,n){let i=this.findWalletConnector(r,o);if(i)return i instanceof Gr&&i.resetConnection(o),i;let l=(()=>{if(r==="injected"){if(o==="metamask"&&n?.eip6963InjectedProvider)return new Ts(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask");if(o==="metamask"&&n?.legacyInjectedProvider)return new On(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask");if(o==="phantom"&&n?.legacyInjectedProvider)return new On(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom");if(n?.legacyInjectedProvider&&o==="unknown_browser_extension")return new On(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider);if(n?.eip6963InjectedProvider)return new Ln(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,o)}else return r==="coinbase_wallet"?new bs(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):r==="phantom"?new Ss(this.defaultChain):new Gr(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,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}));Z.put(xc,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=Wm(r),this.emit("walletsUpdated")}};function ws(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 w3=e=>e&&typeof e.address=="string"&&typeof e.connectorType=="string"&&typeof e.walletClientType=="string"&&typeof e.connectedAt=="number",Uc=()=>{let e=Z.get(xc);return e&&Array.isArray(e)&&e.map(o=>w3(o)).every(Boolean)?e:[]};import{ofetch as b3}from"ofetch";var E3=[Ga,za,Va,qa],Hs=class{constructor(t,r,o){this.appId=t,this.clientAnalyticsId=r.clientAnalyticsId,this.sdkVersion=Pc,this.client=r,this.defaults=o,this.fallbackApiUrl=r.fallbackApiUrl,this.baseFetch=b3.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:n,options:i})=>{let a=new Headers(i.headers);a.set("privy-app-id",this.appId),a.set("privy-ca-id",this.clientAnalyticsId||""),a.set("privy-client",`react-auth:${this.sdkVersion}`);let l=E3.includes(n.toString());if(!a.has("authorization")){let s=await this.client.getAccessToken({disableAutoRefresh:l});s!==null&&a.set("authorization",`Bearer ${s}`)}i.headers=a,i.retryDelay&&(i.retryDelay=i.retryDelay*3)},onRequestError:({error:n})=>{if(n instanceof DOMException&&n.name==="AbortError")throw new Ba}})}async get(t,r){try{return await this.baseFetch(t,r)}catch(o){throw ne(o)}}async post(t,r,o){try{return await this.baseFetch(t,{method:"POST",...r?{body:r}:{},...o})}catch(n){throw ne(n)}}async delete(t,r){try{return await this.baseFetch(t,{method:"DELETE",...r})}catch(o){throw ne(o)}}};var Lm=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 Dn from"js-cookie";function Om(e){return e instanceof go?"email":e instanceof Xo?"sms":e instanceof Qo?"siwe":e instanceof Sn?"custom_auth":e instanceof Ur?e.meta.provider:null}import*as Nm from"jose";var Vr=class{static parse(t){try{return new Vr(t)}catch{return null}}constructor(t){this.value=t,this._decoded=Nm.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 T3=30,Gs=class{constructor(){this.authenticateOnce=new Fe(async t=>this._authenticate(t)),this.linkOnce=new Fe(async t=>this._link(t)),this.refreshOnce=new Fe(this._refresh.bind(this)),this.destroyOnce=new Fe(this._destroy.bind(this)),this.forkSessionOnce=new Fe(this._forkSession.bind(this))}get token(){try{let t=Z.get(qo);return typeof t=="string"?new Vr(t).value:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get refreshToken(){try{let t=Z.get(rs);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get forkedToken(){try{let t=Z.get(Ii);return typeof t=="string"?t:null}catch(t){return console.error(t),this.destroyLocalState(),null}}get mightHaveServerCookies(){try{let t=Dn.get(os);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!==Uu}hasRecoveryCredentials(){return typeof this.forkedToken=="string"}hasActiveToken(){let t=Vr.parse(this.token);return t!==null&&!t.isExpired(T3)}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()}async _authenticate(t){try{let r=await t.authenticate(),{user:o,is_new_user:n,oauth_provider_tokens:i}=r;this.handleTokenResponse(r);let a=i?{provider:i.provider,accessToken:i.access_token,accessTokenExpiresInSeconds:i.access_token_expires_in_seconds,refreshToken:i.refresh_token,scopes:i.scopes}:void 0,l=Om(t);return l&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:l,isNewUser:n}}),l==="siwe"&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:t.meta.connectorType,walletClientType:t.meta.walletClientType}}),{user:Kt(o),isNewUser:n,oAuthProviderTokens:a}}catch(r){throw console.warn("Error authenticating session"),at(r)}}async _link(t){try{let r=await t.link(),o=r.oauth_provider_tokens,n=o?{provider:o.provider,accessToken:o.access_token,accessTokenExpiresInSeconds:o.access_token_expires_in_seconds,refreshToken:o.refresh_token,scopes:o.scopes}:void 0;return{user:Kt(r),oAuthProviderTokens:n}}catch(r){throw console.warn("Error linking account"),at(r)}}async _refresh(){if(!this.api)throw new P("Session has no API instance");if(!this.client)throw new P("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let t=this.token,r=this.refreshToken,o=this.forkedToken;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(Ga,a,{headers:i}),o&&this.clearForkedToken()}else if(o)n=await this.api.post(za,{refresh_token:o}),this.clearForkedToken();else return null;return this.handleTokenResponse(n),Kt(n.user)}catch(n){if(n instanceof br&&n.privyErrorCode==="missing_or_invalid_token")return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw at(n)}}handleTokenResponse(t){t.session_update_action?t.session_update_action==="set"?(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token)):t.session_update_action==="clear"?this.destroyLocalState():t.session_update_action==="ignore"&&t.token&&this.storeToken(t.token):(this.storeRefreshToken(t.refresh_token),this.storeToken(t.token))}async _destroy(){try{await this.api?.post(Va,{refresh_token:this.refreshToken})}catch{console.warn("Error destroying session")}this.destroyLocalState()}async _forkSession(){if(!this.api)throw new P("Session has no API instance");let t=this.refreshToken;try{let r=await this.api.post(xp,{refresh_token:t});return this.storeRefreshToken(r.refresh_token),this.storeToken(r.token),r.new_session_refresh_token}catch(r){throw at(r)}}destroyLocalState(){this.storeRefreshToken(null),this.storeToken(null),this.clearForkedToken()}storeToken(t){if(typeof t=="string"){let r=Z.get(qo);if(Z.put(qo,t),!this.client?.useServerCookies){let o=Vr.parse(t)?.expiration;Dn.set(Sc,t,{sameSite:"Strict",secure:!0,expires:o?new Date(o*1e3):void 0})}r!==t&&this.client?.onStoreToken?.(t)}else Z.del(qo),Dn.remove(Sc),this.client?.onDeleteToken?.()}storeRefreshToken(t){typeof t=="string"?(Z.put(rs,t),this.client?.useServerCookies||Dn.set(os,"t",{sameSite:"Strict",secure:!0,expires:30})):(Z.del(rs),Dn.remove(Iu),Dn.remove(os))}clearForkedToken(){Z.del(Ii)}};var Bc,Vs,Dm,$i=class{constructor(t){Fa(this,Vs);this.apiUrl=t.apiUrl||Ri,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=!1,this.timeout=t.timeout||Au,this.appId=t.appId,this.clientAnalyticsId=_p(this,Vs,Dm).call(this),Bc||(Bc=new Gs),this.session=Bc,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 qi(this.appId,t,r,o,n,i,a,l,s,c))}sessionHasActiveToken(){return this.session.hasActiveToken()}generateApi(){let t=new Hs(this.appId,this,{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 P("No auth flow in progress.");return this.session.authenticate(this.authFlow)}link(){if(!this.authFlow)throw new P("No auth flow in progress.");return this.session.link(this.authFlow)}async logout(){await this.session.destroy(),this.authFlow=void 0}startAuthFlow(t){return t.api=this.api,this.authFlow=t,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(su,{action:"verify"})}catch(t){throw ne(t)}}async initMfaPasskeyVerification(){try{let t=await this.api.post(lu,{});return Lm(t.options)}catch(t){throw ne(t)}}async unlinkEmail(t){try{let r=await this.api.post(Bp,{address:t});return Kt(r)}catch(r){throw at(r)}}async acceptTerms(){try{let t=await this.api.post(cu,{});return Kt(t)}catch(t){throw at(t)}}async unlinkPhone(t){try{let r=await this.api.post(zp,{phoneNumber:t});return Kt(r)}catch(r){throw at(r)}}async unlinkWallet(t){try{let r=await this.api.post(Ip,{address:t});return Kt(r)}catch(r){throw at(r)}}async unlinkOAuth(t,r){try{let o=await this.api.post(Yp,{provider:t,subject:r});return Kt(o)}catch(o){throw at(o)}}async unlinkFarcaster(t){try{let r=await this.api.post(Np,{fid:t});return Kt(r)}catch(r){throw at(r)}}async unlinkTelegram(t){try{let r=await this.api.post(au,{telegram_user_id:t});return Kt(r)}catch(r){throw at(r)}}async unlinkPasskey(t){try{let r=await this.api.post(ou,{credential_id:t});return Kt(r)}catch(r){throw at(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(qa,{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(du,t)}catch(r){throw at(r)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()||this.session.hasRecoveryCredentials()?this.session.refresh():null}async getAccessToken(t){return this.session.hasActiveToken()?Vr.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}: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}}catch(t){throw at(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()}};Vs=new WeakSet,Dm=function(){if(typeof window>"u")return null;try{let r=Z.get(Mi);if(typeof r=="string"&&r.length>0)return r}catch{}let t=P3();try{return Z.put(Mi,t),t}catch{return t}};import{Turnstile as R3}from"@marsidev/react-turnstile";import{useEffect as I3,useMemo as M3}from"react";import{useMemo as S3,useRef as _3,useContext as x3,useState as Hc,createContext as k3}from"react";import{jsx as A3}from"react/jsx-runtime";var Um=k3({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}),Tr=class extends ze{constructor(r,o,n){super(r||"Captcha failed");this.type="Captcha";o instanceof Error&&(this.cause=o),this.privyErrorCode=n}},Fm=({children:e,id:t,captchaSiteKey:r,captchaEnabled:o})=>{let n=_3(null),[i,a]=Hc(),[l,s]=Hc(),[c,u]=Hc(!1),h=S3(()=>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 A3(Um.Provider,{value:{...h,ref:n,enabled:o,siteKey:r,appId:t,setToken:a,setError:s,setExecuting:u,remove(){o&&(n.current?.remove(),u(!1),s(void 0),a(void 0))},reset(){o&&(n.current?.reset(),u(!1),s(void 0),a(void 0))},execute(){o&&(u(!0),n.current?.execute())},async waitForResult(){if(!o)return"";try{return await hu(()=>n.current?.getResponse(),{interval:200,timeout:2e4})}catch{throw new Tr("Captcha failed",null,"captcha_timeout")}}},children:e})},he=()=>x3(Um);import{jsx as Bm}from"react/jsx-runtime";var Gc=e=>{let{enabled:t,siteKey:r,appId:o,setError:n,setToken:i,setExecuting:a,ref:l}=he(),[,s]=M3(()=>r?.split("t:")||[],[r]);if(I3(()=>l.current?.remove,[]),!t)return null;if(!s)throw new Error("Unsupported captcha site key");return Bm("div",{className:"hidden h-0 w-0",children:Bm(R3,{...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 Ib,useEffect as Zg,useRef as Mb,useState as Wb}from"react";import Lb from"react-dom";import{createContext as W3,useContext as L3}from"react";var Vc=W3({isNewUserThisSession:!1,linkingHint:null,walletConnectionStatus:null,mipdStore: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,resendEmailCode:E,resendSmsCode:E,initLoginWithHeadlessOAuth:E,loginWithHeadlessOAuth: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,recoverEmbeddedWallet:E,getFiatOnRampConfig:E,updateWallets:E,fundWallet:E,setReadyToTrue:E,requestFarcasterSignerStatus:E,initLoginWithTelegram:E,loginWithTelegram:E}),M=()=>L3(Vc);import{createContext as O3,useContext as N3}from"react";var ve=O3({ready:!1,authenticated:!1,user:null,walletConnectors:null,connectWallet:E,login:E,connectOrCreateWallet:E,linkEmail:E,linkPhone:E,linkFarcaster:E,linkWallet: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,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,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,requestFarcasterSignerFromWarpcast:E,getFarcasterSignerPublicKey:E,signFarcasterMessage:E,initLoginWithEmail:E,initLoginWithSms:E,otpState:{status:"initial"},loginWithCode:E,fundWallet:E,initLoginWithHeadlessOAuth:E,loginWithHeadlessOAuth:E,isHeadlessOAuthLoading:!1,isModalOpen:!1,mfaMethods:[]}),F=()=>N3(ve);import{useEffect as D3,useState as U3}from"react";var Hm=e=>{let[t,r]=U3("auto");return D3(()=>{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 F3,useContext as B3,useEffect as H3}from"react";var Gm={login:{onComplete:[],onError:[],onOAuthLoginComplete:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]}},zc=F3(void 0),Vm=()=>B3(zc);function He(e,t){if(!t)return;let o=Vm().current[e];return H3(()=>{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 U(e,t,r,...o){for(let n of e.current[t][r])n(...o)}function zs(){let e=Vm();return(t,r,...o)=>U(e,t,r,...o)}function qc(e){He("configureMfa",e)}import Jm from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import a0 from"@heroicons/react/24/solid/DocumentCheckIcon";import s0 from"styled-components";import tn,{css as Yc}from"styled-components";import Kc from"styled-components";import{Fragment as V3,jsx as $c,jsxs as z3}from"react/jsx-runtime";var et=({success:e,fail:t})=>z3(V3,{children:[$c(tt,{className:e?"success":t?"fail":""}),$c(jc,{className:e?"success":t?"fail":""})]}),tt=Kc.span`
|
|
13
13
|
&& {
|
|
14
14
|
width: 82px;
|
|
15
15
|
height: 82px;
|
|
@@ -2324,10 +2324,10 @@ You will need this password to access your ${e} wallet on a new device. Please k
|
|
|
2324
2324
|
margin-left: 27px;
|
|
2325
2325
|
margin-right: 27px;
|
|
2326
2326
|
gap: 24px;
|
|
2327
|
-
`;import{useEffect as pp,useRef as Q7,useState as tg}from"react";import rg from"styled-components";import{Fragment as
|
|
2327
|
+
`;import{useEffect as pp,useRef as Q7,useState as tg}from"react";import rg from"styled-components";import{Fragment as e8,jsx as uo,jsxs as oc}from"react/jsx-runtime";var og=()=>{let{app:e,lastScreen:t,currentScreen:r,navigateBack:o}=x(),{loginWithPasskey:n,closePrivyModal:i}=M(),a=e?.render.inDialog?Le:0,[l,s]=tg("loading"),[c,u]=tg(null),h=Q7([]),f=w=>{h.current=[w,...h.current]};pp(()=>()=>{h.current.forEach(w=>clearTimeout(w)),h.current=[]},[]);let y=()=>{switch(l){case"loading":return"Waiting for passkey";case"success":return"Success";case"error":return"Something went wrong"}},v=()=>{switch(l){case"loading":return`Please follow prompts to verify your passkey.
|
|
2328
2328
|
You will have to sign up with another method first to register a passkey for your account.`;case"success":return"You've successfully logged in with your passkey.";case"error":if(c instanceof ze){if(c.privyErrorCode==="cannot_link_more_of_type")return"Cannot link more passkeys to account.";if(c.privyErrorCode==="passkey_not_allowed")return`Passkey request timed out or rejected by user.
|
|
2329
2329
|
You will have to sign up with another method first to register a passkey for your account.`}return`An unknown error occurred.
|
|
2330
|
-
You will have to sign up with another method first to register a passkey for your account.`}},g=()=>{switch(l){case"loading":case"success":return uo(O,{onClick:()=>{},disabled:!0,children:"Continue"});case"error":return uo(O,{onClick:k,disabled:!1,children:"Retry"})}},k=async()=>{s("loading");try{await n(),s("success")}catch(w){u(w),s("error")}};return pp(()=>{l==="success"&&f(setTimeout(()=>{i({shouldCallAuthOnSuccess:!0,isSuccess:!0})},a))},[l]),pp(()=>{k()},[]),oc(
|
|
2330
|
+
You will have to sign up with another method first to register a passkey for your account.`}},g=()=>{switch(l){case"loading":case"success":return uo(O,{onClick:()=>{},disabled:!0,children:"Continue"});case"error":return uo(O,{onClick:k,disabled:!1,children:"Retry"})}},k=async()=>{s("loading");try{await n(),s("success")}catch(w){u(w),s("error")}};return pp(()=>{l==="success"&&f(setTimeout(()=>{i({shouldCallAuthOnSuccess:!0,isSuccess:!0})},a))},[l]),pp(()=>{k()},[]),oc(e8,{children:[uo(S,{backFn:!t||r===t?void 0:o}),oc(X7,{children:[uo(ot,{children:oc("div",{children:[uo(et,{success:l==="success",fail:l==="error"}),uo(fn,{style:{width:"38px",height:"38px"}})]})}),oc(Ke,{children:[uo("h3",{children:y()}),uo("p",{style:{whiteSpace:"pre-wrap"},children:v()})]}),g()]}),uo(z,{})]})},X7=rg.div`
|
|
2331
2331
|
display: flex;
|
|
2332
2332
|
flex-direction: column;
|
|
2333
2333
|
align-items: center;
|
|
@@ -2350,9 +2350,9 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2350
2350
|
stroke: var(--privy-color-accent) !important;
|
|
2351
2351
|
fill: var(--privy-color-accent) !important;
|
|
2352
2352
|
}
|
|
2353
|
-
`;import{useEffect as
|
|
2353
|
+
`;import{useEffect as r8,useState as ig}from"react";import o8 from"styled-components";import{isMobile as t8}from"react-device-detect";var ng=(e,t)=>{let r=new URL(window.location.href),o=encodeURIComponent(r.href.replace(/\/$/g,"")+`?privy_token=${e}&privy_connector=injected&privy_wallet_client=phantom`);if(!vo()&&t8)return`${t?"phantom://":"https://phantom.app/ul/"}browse/${o}?ref=${o}`};import{Fragment as i8,jsx as mo,jsxs as ag}from"react/jsx-runtime";var sg=()=>{let{forkSession:e,ready:t,authenticated:r}=F(),[o,n]=ig(""),[i,a]=ig(!1);r8(()=>{t&&r&&e().then(n)},[t,r]);let l=ng(o,!i),s={title:"Redirecting to Phantom Mobile Wallet",description:"We'll take you to the Phantom Mobile Wallet app to continue your login experience.",footnote:""};return t&&(s.description="For the best experience, we'll automatically log you into the Phantom Mobile Wallet in-app browser.",s.footnote="Once you're done, you can always return here and refresh to view your updated account."),i&&(s.title="Still here?",s.description="You may need to install the Phantom mobile app.",s.footnote="Once you're done, you can return here or connect via Phantom's in-app browser."),ag(i8,{children:[mo(S,{},"header"),mo(Q,{}),mo($r,{title:s.title,description:s.description}),ag(ur,{children:[mo(n8,{children:mo(Hr,{style:{width:"72px",height:"72px"}})}),mo($s,{href:l,onClick:()=>{setTimeout(()=>a(!0),1e3)},loading:t&&!l,children:i?"Go to App Store":"Continue"}),s.footnote?mo("p",{children:s.footnote}):null]}),mo(re,{}),mo(q,{protectedByPrivy:!0})]})},n8=o8(Tt)`
|
|
2354
2354
|
margin: 16px auto;
|
|
2355
|
-
`;import
|
|
2355
|
+
`;import a8 from"@heroicons/react/24/outline/ShieldCheckIcon";import{useEffect as s8,useState as nc}from"react";import ic,{css as l8}from"styled-components";import{Fragment as m8,jsx as xt,jsxs as vn}from"react/jsx-runtime";var lg=()=>{let[e,t]=nc(!0),{authenticated:r,getAccessToken:o}=F(),{walletProxy:n,closePrivyModal:i,createAnalyticsEvent:a}=M(),{navigate:l,data:s,onUserCloseViaDialogOrKeybindRef:c}=x(),[u,h]=nc(void 0),[f,y]=nc(""),[v,g]=nc(!1),{privyWallet:k,onCompleteNavigateTo:w,onSuccess:b,onFailure:_}=s.recoverWallet,A=(R="User exited before their wallet could be recovered")=>{i({shouldCallAuthOnSuccess:!1}),_(typeof R=="string"?new Et(R):R)};c.current=A,s8(()=>{if(!r||!k)return A("User must be authenticated and have a Privy wallet before it can be recovered")},[r]);let N=R=>{R&&h(R)};return vn(m8,{children:[xt(S,{onClose:A}),xt(Q,{}),vn(d8,{children:[vn(c8,{children:[xt(a8,{height:48,width:48,stroke:"var(--privy-color-accent)"}),xt("h3",{style:{color:"var(--privy-color-foreground)"},children:"Enter your password"}),xt("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),vn("div",{children:[vn(xo,{children:[xt(oi,{type:e?"password":"text",onChange:R=>N(R.target.value),disabled:v,style:{paddingRight:"2.3rem"}}),xt(ni,{style:{right:"0.75rem"},children:e?xt(ii,{onClick:()=>t(!1)}):xt(ai,{onClick:()=>t(!0)})})]}),!!f&&xt(p8,{children:f})]}),vn("div",{children:[vn(of,{children:[xt("h4",{children:"Why is this necessary?"}),xt("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),xt(u8,{loading:v||!n,disabled:!u,onClick:async()=>{g(!0);let R=await o();if(R&&k&&u!==null)try{a({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:k.address}}),await n?.recover({address:k.address,accessToken:R,recoveryPin:u}),y(""),w?l(w):i({shouldCallAuthOnSuccess:!1}),b?.(k),a({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:k.address}})}catch(B){Hf(B)?y("Invalid recovery password, please try again."):y("An error has occurred, please try again.")}finally{g(!1)}else return A("User must be authenticated and have a Privy wallet before it can be recovered")},warn:!1,hideAnimations:!k&&v,children:"Recover your account"})]})]}),xt(re,{}),xt(q,{protectedByPrivy:!0})]})},c8=ic.div`
|
|
2356
2356
|
display: flex;
|
|
2357
2357
|
flex-direction: column;
|
|
2358
2358
|
align-items: center;
|
|
@@ -2374,26 +2374,26 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2374
2374
|
font-weight: 400;
|
|
2375
2375
|
line-height: 20px;
|
|
2376
2376
|
}
|
|
2377
|
-
`,
|
|
2377
|
+
`,d8=ic.div`
|
|
2378
2378
|
display: flex;
|
|
2379
2379
|
flex-direction: column;
|
|
2380
2380
|
justify-content: space-between;
|
|
2381
|
-
`,
|
|
2381
|
+
`,p8=ic.div`
|
|
2382
2382
|
line-height: 20px;
|
|
2383
2383
|
height: 20px;
|
|
2384
2384
|
font-size: 13px;
|
|
2385
2385
|
color: var(--privy-color-error);
|
|
2386
2386
|
text-align: left;
|
|
2387
2387
|
margin-top: 0.5rem;
|
|
2388
|
-
`,
|
|
2389
|
-
${e=>e.hideAnimations&&
|
|
2388
|
+
`,u8=ic(O)`
|
|
2389
|
+
${e=>e.hideAnimations&&l8`
|
|
2390
2390
|
&& {
|
|
2391
2391
|
// Remove animations because the recoverWallet task on the iframe partially
|
|
2392
2392
|
// blocks the renderer, so the animation stutters and doesn't look good
|
|
2393
2393
|
transition: none;
|
|
2394
2394
|
}
|
|
2395
2395
|
`}
|
|
2396
|
-
`;import{useCallback as
|
|
2396
|
+
`;import{useCallback as f8,useEffect as mg,useState as up}from"react";import{jsx as ac,jsxs as cg}from"react/jsx-runtime";var sc=e=>cg("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 21 20",...e,children:[ac("path",{fill:"url(#icloud-gradient)",d:"M12.34 7.315a4.26 4.26 0 0 0-3.707 2.18 2.336 2.336 0 0 0-1.02-.236 2.336 2.336 0 0 0-2.3 1.963 3.217 3.217 0 0 0 1.244 6.181c.135-.001.27-.01.404-.029h8.943c.047.004.094.006.141.007.045-.001.09-.004.135-.007h.214v-.016a2.99 2.99 0 0 0 1.887-.988c.487-.55.757-1.261.757-1.998v-.006a3.017 3.017 0 0 0-.69-1.915 2.992 2.992 0 0 0-1.748-1.034 4.26 4.26 0 0 0-4.26-4.102Z"}),ac("defs",{children:cg("linearGradient",{id:"icloud-gradient",x1:19.086,x2:3.333,y1:14.38,y2:14.163,gradientUnits:"userSpaceOnUse",children:[ac("stop",{stopColor:"#3E82F4"}),ac("stop",{offset:1,stopColor:"#93DCF7"})]})})]});import{jsx as fo,jsxs as dg}from"react/jsx-runtime";var lc=({style:e,...t})=>dg("svg",{width:"16",height:"14",style:e,viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[dg("g",{clipPath:"url(#clip0_2115_829)",children:[fo("path",{d:"M2.34709 12.9404L2.3471 12.9404L2.34565 12.938L1.64031 11.7448L1.64004 11.7444L0.651257 10.0677C0.640723 10.0496 0.630746 10.0314 0.621325 10.0129H4.16461L2.39424 13.0139C2.3775 12.9901 2.36178 12.9656 2.34709 12.9404Z",fill:"#0066DA",stroke:"#6366F1"}),fo("path",{d:"M8 4.48713L5.47995 0.215332C5.23253 0.358922 5.02176 0.556358 4.87514 0.80764L0.219931 8.70508C0.076007 8.95094 0.000191627 9.22937 0 9.51277H5.04009L8 4.48713Z",fill:"#00AC47"}),fo("path",{d:"M13.48 13.7847C13.7274 13.6411 13.9382 13.4437 14.0848 13.1924L14.3781 12.6988L15.7801 10.3206C15.9267 10.0693 16.0001 9.79114 16.0001 9.51294H10.9596L12.0321 11.577L13.48 13.7847Z",fill:"#EA4335"}),fo("path",{d:"M8.00003 4.48718L10.5201 0.215385C10.2726 0.0717949 9.98857 0 9.69533 0H6.30472C6.01148 0 5.7274 0.0807692 5.47998 0.215385L8.00003 4.48718Z",fill:"#00832D"}),fo("path",{d:"M10.9599 9.51294H5.04007L2.52002 13.7847C2.76744 13.9283 3.05152 14.0001 3.34476 14.0001H12.6552C12.9484 14.0001 13.2325 13.9194 13.4799 13.7847L10.9599 9.51294Z",fill:"#2684FC"}),fo("path",{d:"M13.4525 4.75636L11.1249 0.80764C10.9782 0.556358 10.7675 0.358922 10.52 0.215332L8 4.48713L10.9599 9.51277H15.9908C15.9908 9.23456 15.9175 8.95636 15.7709 8.70508L13.4525 4.75636Z",fill:"#FFBA00"})]}),fo("defs",{children:fo("clipPath",{id:"clip0_2115_829",children:fo("rect",{width:"16",height:"14",fill:"white"})})})]});import pg from"styled-components";var Wa=pg.div`
|
|
2397
2397
|
display: flex;
|
|
2398
2398
|
flex-direction: column;
|
|
2399
2399
|
gap: 12px;
|
|
@@ -2401,18 +2401,18 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2401
2401
|
padding-bottom: 24px;
|
|
2402
2402
|
`,ug=pg.div`
|
|
2403
2403
|
padding-bottom: 24px;
|
|
2404
|
-
`;import{Fragment as hg,jsx as Do,jsxs as cc}from"react/jsx-runtime";var fg={"google-drive":{name:"Google Drive",component:lc},icloud:{name:"iCloud",component:sc}},yg=()=>{let{logout:e}=F(),{navigate:t,setModalData:r,data:o}=x(),{recoveryOAuthFlow:n,closePrivyModal:i,createAnalyticsEvent:a}=M(),[l,s]=up(!1),{provider:c,action:u,isInAccountCreateFlow:h}=o?.recoveryOAuthStatus,[f,y]=up(void 0),[v,g]=up(u==="create-wallet");if(c==="user-passcode")throw new Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let k=fg[c].name,w=fg[c].component,b=o?.recoverWallet?.onCompleteNavigateTo,_=new Fe(async(Y="create-wallet")=>(g(!0),new Promise((W,V)=>{setTimeout(async()=>{try{let L=window.open();await n(c,Y,L),s(!0),W()}catch{y({message:`${Y==="recover"?"Recovery":"Back up"} with ${k} unsuccessful`,detail:u==="recover"?`Please verify that you are selecting the ${k} account associated with your backup.`:"",retryable:!0}),V()}},0)})));mg(()=>{u==="create-wallet"&&_.execute("create-wallet")},[]),mg(()=>{if(!l)return;let Y=setTimeout(()=>{h?(r({createWallet:{onSuccess:()=>{},onFailure:W=>{a({eventName:"embedded_wallet_creation_failure_logout",payload:{error:W,screen:"RecoveryOAuthScreen"}}),e()},callAuthOnSuccessOnClose:!0}}),t("EMBEDDED_WALLET_CREATED_SCREEN")):i({shouldCallAuthOnSuccess:!1})},Le);return()=>clearTimeout(Y)},[l]);let A=
|
|
2404
|
+
`;import{Fragment as hg,jsx as Do,jsxs as cc}from"react/jsx-runtime";var fg={"google-drive":{name:"Google Drive",component:lc},icloud:{name:"iCloud",component:sc}},yg=()=>{let{logout:e}=F(),{navigate:t,setModalData:r,data:o}=x(),{recoveryOAuthFlow:n,closePrivyModal:i,createAnalyticsEvent:a}=M(),[l,s]=up(!1),{provider:c,action:u,isInAccountCreateFlow:h}=o?.recoveryOAuthStatus,[f,y]=up(void 0),[v,g]=up(u==="create-wallet");if(c==="user-passcode")throw new Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let k=fg[c].name,w=fg[c].component,b=o?.recoverWallet?.onCompleteNavigateTo,_=new Fe(async(Y="create-wallet")=>(g(!0),new Promise((W,V)=>{setTimeout(async()=>{try{let L=window.open();await n(c,Y,L),s(!0),W()}catch{y({message:`${Y==="recover"?"Recovery":"Back up"} with ${k} unsuccessful`,detail:u==="recover"?`Please verify that you are selecting the ${k} account associated with your backup.`:"",retryable:!0}),V()}},0)})));mg(()=>{u==="create-wallet"&&_.execute("create-wallet")},[]),mg(()=>{if(!l)return;let Y=setTimeout(()=>{h?(r({createWallet:{onSuccess:()=>{},onFailure:W=>{a({eventName:"embedded_wallet_creation_failure_logout",payload:{error:W,screen:"RecoveryOAuthScreen"}}),e()},callAuthOnSuccessOnClose:!0}}),t("EMBEDDED_WALLET_CREATED_SCREEN")):i({shouldCallAuthOnSuccess:!1})},Le);return()=>clearTimeout(Y)},[l]);let A=f8(async()=>{await _.execute("recover"),b?t(b):s(!0)},[]),N=c==="google-drive"?"Google Drive":"Apple iCloud",I=u==="recover"?"recovered":"backed up",R=u==="recover"?"Recovering":"Backing up",B=l&&`Successfully ${I} with ${N}.`||f&&f.message||`${R} with ${N}...`,K=f?f.detail:"";return cc(hg,{children:[Do(S,{}),v?Do(hg,{children:cc(Wa,{children:[Do(xe,{title:B,icon:Do(w,{style:{width:"38px",height:"38px"}}),description:K}),f&&f?.retryable?Do(O,{onClick:()=>{Zo(),y(void 0),u==="create-wallet"?_.execute("create-wallet"):A()},disabled:!l&&!f?.retryable,children:"Try again"}):null]})}):cc(Wa,{children:[Do(xe,{title:"Confirm it's really you",icon:Do(w,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${N} where your account is backed up.`}),cc(O,{onClick:A,children:["Confirm with ",N]})]}),Do(q,{protectedByPrivy:!0})]})};import{useEffect as gg,useState as La}from"react";import{jsx as h8}from"react/jsx-runtime";var vg=()=>{let{app:e,navigate:t,data:r,onUserCloseViaDialogOrKeybindRef:o}=x(),[n,i]=La(""),[a,l]=La(!1),[s,c]=La(),[u,h]=La(null),{authenticated:f}=F(),{closePrivyModal:y,isNewUserThisSession:v,initializeWalletProxy:g}=M(),{onSuccess:k,onFailure:w,callAuthOnSuccessOnClose:b}=r.createWallet,{createWallet:_}=ul(),[A,N]=La(null),I=new Fe(async()=>{try{let K=await _(s);if(!K)return;N(K),v?t("EMBEDDED_WALLET_CREATED_SCREEN"):(k(K),y({shouldCallAuthOnSuccess:b}))}catch(K){i(K.message)}});gg(()=>{u||g(3e4).then(K=>h(K))},[u]),gg(()=>{if(!f){t("LANDING"),w(new Error("User must be authenticated before creating a Privy wallet"));return}},[f]);let R=()=>{A&&A?.recoveryMethod!=="user-passcode"?(w(new Et("User created a wallet but failed to set a password for it")),y({shouldCallAuthOnSuccess:!1})):A?(k(A),y({shouldCallAuthOnSuccess:b})):(w(new Et("User wallet creation failed")),y({shouldCallAuthOnSuccess:!1}))};o.current=()=>null;let B=async()=>{l(!0);let K=250;return I.execute().then(()=>new Promise(Y=>setTimeout(Y,K))).finally(()=>l(!1))};return h8(yl,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:!u,buttonLoading:a,buttonHideAnimations:!A&&a,isResettingPassword:!1,error:n,password:s||"",onClose:R,onPasswordChange:c,onPasswordGenerate:()=>c(hl()),onSubmit:B})};import y8 from"@heroicons/react/24/outline/LockClosedIcon";import g8 from"@heroicons/react/24/outline/PencilSquareIcon";import v8 from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import{useState as C8}from"react";import w8 from"styled-components";import{Fragment as fp,jsx as dt,jsxs as Cn}from"react/jsx-runtime";var mp=w8.div`
|
|
2405
2405
|
width: 24px;
|
|
2406
2406
|
height: 24px;
|
|
2407
2407
|
display: flex;
|
|
2408
2408
|
justify-content: center;
|
|
2409
2409
|
align-items: center;
|
|
2410
|
-
`,
|
|
2410
|
+
`,b8=({onClose:e})=>Cn(ug,{children:[dt(xe,{title:"Why do I need to secure my account?",icon:dt(v8,{width:48}),description:Cn(fp,{children:[dt("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),dt("p",{children:"To use this app on new devices, secure account secrets using a password, your Google or your Apple account. It\u2019s important you don\u2019t lose access to the method you choose."})]})}),dt(O,{onClick:e,children:"Select backup method"})]}),Cg=()=>{let[e,t]=C8(!1),{navigate:r,setModalData:o,data:n}=x(),{user:i}=F(),{embeddedWallets:a}=Nt(),s=Ie(i)===null;function c(u){o({recoveryOAuthStatus:{provider:u,action:s?"create-wallet":"set-recovery",isInAccountCreateFlow:!!n?.recoverySelection?.isInAccountCreateFlow}}),r("EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN")}return Cn(fp,{children:[dt(S,{backFn:e?()=>t(!1):void 0,infoFn:e?void 0:()=>t(!0)},"header"),e?dt(b8,{onClose:()=>t(!1)}):Cn(fp,{children:[dt(xe,{title:"Secure your account",icon:dt(y8,{width:48}),description:"Select a method for logging in on new devices and recovering your account."}),dt(Wa,{children:a.userOwnedRecoveryOptions.sort().map(u=>{switch(u){case"google-drive":return Cn(Te,{onClick:()=>c("google-drive"),children:[dt(mp,{children:dt(lc,{style:{width:18}})}),"Back up to Google Drive"]},u);case"icloud":return Cn(Te,{onClick:()=>c("icloud"),children:[dt(mp,{children:dt(sc,{style:{width:24}})}),"Back up to Apple iCloud"]},u);case"user-passcode":return Cn(Te,{onClick:()=>{r(s?"EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN":"EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN")},children:[dt(mp,{children:dt(g8,{style:{width:18}})}),"Set a password"]},u);default:return null}})})]}),dt(q,{protectedByPrivy:!0})]})};import{BigNumber as kg}from"@ethersproject/bignumber";import{useMemo as $8,useEffect as Ag,useState as nr}from"react";import Ti from"styled-components";function wg(e){return e.to&&e.data?"CONTRACT_CALL":e.to&&e.value?"SEND":"UNKNOWN"}import{ExclamationCircleIcon as T8,ClipboardDocumentIcon as P8,ClipboardDocumentCheckIcon as S8}from"@heroicons/react/24/outline";import{useState as _8}from"react";import or from"styled-components";import{ErrorCode as dc}from"@ethersproject/logger";var E8=new Set([dc.CALL_EXCEPTION,dc.NONCE_EXPIRED,dc.REPLACEMENT_UNDERPRICED,dc.TRANSACTION_REPLACED]),bg=e=>{let t;return e.code&&e.code!==-32e3&&E8.has(e.code)&&(t=e.transactionHash),t},Eg=e=>e.code==="SERVER_ERROR"?e.error?.message??e.reason??e.message??"unknown error":e.error?.code==="SERVER_ERROR"?e.error?.error?.message??e.reason??e.message??"unknown error":e.reason??e.message??"unknown error";import{Fragment as B8,jsx as wt,jsxs as wn}from"react/jsx-runtime";var x8=e=>{let t=e.code?e.code?.toString().charAt(0)+e.code?.toString().slice(1).replace("_"," ").toLowerCase():"Something went wrong.",r=bg(e),o=Eg(e);return{errorCode:t,transactionHash:r,errorMessage:o}},k8=()=>wn(M8,{children:[wt(L8,{}),wt(W8,{})]}),_g=({transactionError:e,chainId:t,onClose:r,onRetry:o})=>{let{chains:n}=M(),[i,a]=_8(!1),{errorCode:l,transactionHash:s,errorMessage:c}=x8(e),u=n.find(h=>h.id===t)?.blockExplorers?.default.url??"https://etherscan.io";return wn(B8,{children:[wt(S,{onClose:r}),wn(A8,{children:[wt(k8,{}),wt(R8,{children:l}),wt(I8,{children:"Please try again."}),wn(Pg,{children:[wt(Tg,{children:"Error message"}),wt(Sg,{clickable:!1,children:c})]}),s&&wn(Pg,{children:[wt(Tg,{children:"Transaction hash"}),wn(N8,{children:["Copy this hash to view details about the transaction on a"," ",wt("u",{children:wt("a",{href:u,children:"block explorer"})}),"."]}),wn(Sg,{clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(s),a(!0)},children:[s,wt(F8,{clicked:i})]})]}),wt(O8,{onClick:o,children:"Retry transaction"})]}),wt(z,{})]})},A8=or.div`
|
|
2411
2411
|
display: flex;
|
|
2412
2412
|
flex-direction: column;
|
|
2413
2413
|
align-items: center;
|
|
2414
2414
|
justify-content: center;
|
|
2415
|
-
`,
|
|
2415
|
+
`,R8=or.span`
|
|
2416
2416
|
color: var(--privy-color-foreground);
|
|
2417
2417
|
text-align: center;
|
|
2418
2418
|
font-size: 1.125rem;
|
|
@@ -2420,7 +2420,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2420
2420
|
line-height: 1.25rem; /* 111.111% */
|
|
2421
2421
|
text-align: center;
|
|
2422
2422
|
margin: 10px;
|
|
2423
|
-
`,
|
|
2423
|
+
`,I8=or.span`
|
|
2424
2424
|
margin-top: 4px;
|
|
2425
2425
|
margin-bottom: 10px;
|
|
2426
2426
|
color: var(--privy-color-foreground-3);
|
|
@@ -2431,7 +2431,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2431
2431
|
font-weight: 400;
|
|
2432
2432
|
line-height: 20px; /* 142.857% */
|
|
2433
2433
|
letter-spacing: -0.008px;
|
|
2434
|
-
`,
|
|
2434
|
+
`,M8=or.div`
|
|
2435
2435
|
position: relative;
|
|
2436
2436
|
width: 60px;
|
|
2437
2437
|
height: 60px;
|
|
@@ -2439,19 +2439,19 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2439
2439
|
display: flex;
|
|
2440
2440
|
justify-content: center;
|
|
2441
2441
|
align-items: center;
|
|
2442
|
-
`,
|
|
2442
|
+
`,W8=or(T8)`
|
|
2443
2443
|
position: absolute;
|
|
2444
2444
|
width: 35px;
|
|
2445
2445
|
height: 35px;
|
|
2446
2446
|
color: var(--privy-color-error);
|
|
2447
|
-
`,
|
|
2447
|
+
`,L8=or.div`
|
|
2448
2448
|
position: absolute;
|
|
2449
2449
|
width: 60px;
|
|
2450
2450
|
height: 60px;
|
|
2451
2451
|
border-radius: 50%;
|
|
2452
2452
|
background-color: var(--privy-color-error);
|
|
2453
2453
|
opacity: 0.1;
|
|
2454
|
-
`,
|
|
2454
|
+
`,O8=or(O)`
|
|
2455
2455
|
&& {
|
|
2456
2456
|
margin-top: 24px;
|
|
2457
2457
|
}
|
|
@@ -2469,7 +2469,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2469
2469
|
flex-direction: column;
|
|
2470
2470
|
justify-content: center;
|
|
2471
2471
|
align-items: center;
|
|
2472
|
-
`,
|
|
2472
|
+
`,N8=or.text`
|
|
2473
2473
|
position: relative;
|
|
2474
2474
|
width: 100%;
|
|
2475
2475
|
padding: 5px;
|
|
@@ -2495,65 +2495,65 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2495
2495
|
&:hover {
|
|
2496
2496
|
background-color: var(--privy-color-foreground-4);
|
|
2497
2497
|
}`}
|
|
2498
|
-
`,
|
|
2498
|
+
`,D8=or(P8)`
|
|
2499
2499
|
position: absolute;
|
|
2500
2500
|
top: 13px;
|
|
2501
2501
|
right: 13px;
|
|
2502
2502
|
width: 24px;
|
|
2503
2503
|
height: 24px;
|
|
2504
|
-
`,
|
|
2504
|
+
`,U8=or(S8)`
|
|
2505
2505
|
position: absolute;
|
|
2506
2506
|
top: 13px;
|
|
2507
2507
|
right: 13px;
|
|
2508
2508
|
width: 24px;
|
|
2509
2509
|
height: 24px;
|
|
2510
|
-
`,
|
|
2510
|
+
`,F8=({clicked:e})=>e?wt(U8,{}):wt(D8,{});import{BigNumber as hp}from"@ethersproject/bignumber";import H8 from"styled-components";import{Fragment as z8,jsx as Oa,jsxs as q8}from"react/jsx-runtime";var G8=(e,t)=>{if(e.gasUsed&&e.effectiveGasPrice)try{let r=hp.from(e.gasUsed),o=hp.from(e.effectiveGasPrice),n=r.mul(o);if(t){let i=hp.from(t);n=n.add(i)}return n.toString()}catch{return}else return},xg=({txn:e,receipt:t,transactionInfo:r,onClose:o,tokenPrice:n,tokenSymbol:i,l1GasEstimate:a,receiptHeader:l,receiptDescription:s})=>q8(z8,{children:[Oa(S,{onClose:o}),Oa(Zi,{title:l??"Transaction complete!",description:s??"You're all set."}),Oa(yi,{tokenPrice:n,from:t.from,to:t.to,gas:G8(t,a),txn:e,transactionInfo:r,tokenSymbol:i}),Oa(V8,{loading:!1,onClick:o,children:"All Done"}),Oa(z,{})]}),V8=H8(O)`
|
|
2511
2511
|
&& {
|
|
2512
2512
|
margin-top: 24px;
|
|
2513
2513
|
}
|
|
2514
2514
|
transition: color 350ms ease, background-color 350ms ease;
|
|
2515
|
-
`;import{Fragment as yp,jsx as pt,jsxs as Ei}from"react/jsx-runtime";var
|
|
2515
|
+
`;import{Fragment as yp,jsx as pt,jsxs as Ei}from"react/jsx-runtime";var K8=({txn:e,txnFamily:t,uiOptions:r,tokenSymbol:o,tokenPrice:n})=>{if(t==="CONTRACT_CALL"){if(r.transactionInfo?.contractInfo)return pt(Qd,{contractInfo:r.transactionInfo.contractInfo,description:r.description});if(r.senderInfo)return pt(Qd,{contractInfo:r.senderInfo,description:r.description||r.senderInfo.actionText})}return pt(yp,{children:pt(O1,{description:r.description||r.transactionInfo?.description||"",txn:e,tokenSymbol:o,tokenPrice:n})})},Ig=()=>{let{authenticated:e,getAccessToken:t}=F(),{wallets:r}=Ra(),{walletProxy:o,closePrivyModal:n,getFiatOnRampConfig:i,rpcConfig:a,chains:l,nativeTokenSymbolForChainId:s,appId:c}=M(),{app:u,navigate:h,data:f,onUserCloseViaDialogOrKeybindRef:y,setModalData:v}=x(),{transactionRequest:g,onSuccess:k,onFailure:w,uiOptions:b,fundWalletConfig:_}=f.sendTransaction,[A,N]=nr(null),[I,R]=nr(null),[B,K]=nr(""),[Y,W]=nr(),[V,L]=nr(),[ae,de]=nr(!1),pe=()=>{K(""),W(void 0),L(void 0)},we=(Ze,qt,Cr)=>{K(Ze),W(new Be(new jt(qt??Ze,Cr??st.E32603_DEFAULT_INTERNAL_ERROR.eipCode)))},[X,bt]=nr(!1),[Ye,At]=nr(!0),[Xe,ir]=nr(null),[Re,qe]=nr(g),{tokenPrice:ar,isTokenPriceLoading:Rt}=tc(Re),Ge=s(g.chainId)||"ETH",[D,Ho]=nr(null),[be,J]=nr(null),[ee,ge]=nr(!0);Ag(()=>{e||(h("LANDING"),w(new Error("User must be authenticated before transacting with a Privy wallet")))},[e]);let Ue=g.from?r.find(Ze=>Ze.address===g.from):r.find(Ze=>Ze.walletClientType==="privy"&&!Ze.imported),hc=async()=>{if(!Ue)return console.warn("No privy wallet found, cannot fund wallet.");let{signedUrl:Ze,externalTransactionId:qt}=await i(Ue.address,{config:_?.config||{}});v({fiatOnRampPrompt:{signedUrl:Ze},fiatOnRampStatus:{externalTransactionId:qt}}),h("FIAT_ON_RAMP_PROMPT_SCREEN")},En=$8(()=>ro(Re.chainId,l,a,{appId:c}),[Re.chainId,a]);async function Tn(){let Ze=Re;if(!await t()||!o||!Ue)return;try{Ze=await wi(Ue.address,Re,En),qe(Ze)}catch(to){console.error(to),we("There was an error preparing your transaction. Your transaction request will likely fail.",to.reason)}let Cr=kg.from(0),Vo=kg.from(0);try{({totalGasEstimate:Cr,l1ExecutionFeeEstimate:Vo}=await Ci(Ze,En)),Ho(Cr.toHexString()),J(Vo.toHexString())}catch{Ho(null)}try{let{balance:to,hasSufficientFunds:Da}=await Xl(Ue.address,Ze,Cr,En);ir(to.toHexString()),Da||(At(!1),we("Wallet has insufficient funds for this transaction."),u?.fiatOnRamp.enabled&&de(!0))}catch(to){console.warn(`Failed to fetch wallet balance with error: ${to}`)}ge(!1)}Ag(()=>{Tn()},[o]);let Go=wg(Re),yc=Go==="SEND"?`Send ${Ge}`:"Review transaction",Ve={modalTitle:b.header||b.modalTitle||yc,buttonText:b.buttonText||"Submit"},yo=()=>{X||(I?k(I):w(Y||new Be(new jt("The user rejected the request",st.E4001_USER_REJECTED_REQUEST.eipCode))),n({shouldCallAuthOnSuccess:!1}))};return y.current=yo,ar===void 0&&Rt||ee?Ei(yp,{children:[b.transactionInfo?.contractInfo?.imgUrl&&pt(_s,{src:b.transactionInfo?.contractInfo?.imgUrl}),pt(S,{title:Ve.modalTitle,onClose:yo}),pt(Rg,{children:pt(Jn,{})})]}):A!==null?pt(xg,{txn:Re,onClose:yo,receipt:A,transactionInfo:b.transactionInfo,tokenPrice:ar,tokenSymbol:Ge,l1GasEstimate:be,receiptHeader:b.successHeader,receiptDescription:b.successDescription}):V?pt(_g,{transactionError:V,chainId:Re.chainId,onClose:yo,onRetry:()=>{pe(),Tn()}}):Ei(yp,{children:[pt(S,{title:Ve.modalTitle,onClose:yo}),Ei(Rg,{children:[Ei(J8,{children:[pt(K8,{txn:Re,txnFamily:Go,uiOptions:b,tokenSymbol:Ge,tokenPrice:ar}),Ue?pt(yi,{from:Ue.address,to:Re.to,txn:Re,transactionInfo:b.transactionInfo,gas:D||void 0,tokenPrice:ar,tokenSymbol:Ge}):null]}),Ei(Q8,{children:[pt(j8,{children:B}),pt(I1,{txn:Re,address:Ue?.address??"",hasFunds:Ye,balance:Xe}),Ei(Y8,{children:[ae&&pt(O,{onClick:hc,children:"Add Funds"}),pt(Z8,{disabled:X||!Ye,loading:!o||X,loadingText:X?"Submitting (may take a few moments)...":"Loading...",onClick:async()=>{bt(!0);let Ze=await t();if(Ze&&!X&&Ue)try{let qt=await Ql(Ze,Ue.address,o,Re,En);R(qt);let Cr=await qt.wait();N(ec(Cr)),pe()}catch(qt){console.warn({transaction:Re,error:qt}),L(qt),W(new Be(new jt(qt.reason??"Error processing transaction",st.E32603_DEFAULT_INTERNAL_ERROR.eipCode)))}finally{bt(!1)}},children:Ve.buttonText})]})]})]})]})},Rg=Ti.div`
|
|
2516
2516
|
display: flex;
|
|
2517
2517
|
flex-direction: column;
|
|
2518
2518
|
justify-content: space-between;
|
|
2519
2519
|
flex-grow: 1;
|
|
2520
2520
|
padding-bottom: 16px;
|
|
2521
|
-
`,
|
|
2521
|
+
`,j8=Ti.div`
|
|
2522
2522
|
font-size: 13px;
|
|
2523
2523
|
color: var(--privy-color-error);
|
|
2524
2524
|
width: 100%;
|
|
2525
2525
|
margin-top: 16px;
|
|
2526
|
-
`,
|
|
2526
|
+
`,Y8=Ti.div`
|
|
2527
2527
|
display: flex;
|
|
2528
2528
|
direction: row;
|
|
2529
2529
|
justify-content: space-between;
|
|
2530
2530
|
align-items: center;
|
|
2531
2531
|
gap: 8px;
|
|
2532
|
-
`,
|
|
2532
|
+
`,Z8=Ti(O)`
|
|
2533
2533
|
transition: color 350ms ease, background-color 350ms ease;
|
|
2534
|
-
`,
|
|
2534
|
+
`,J8=Ti.div`
|
|
2535
2535
|
height: 100%;
|
|
2536
2536
|
display: flex;
|
|
2537
2537
|
flex-direction: column;
|
|
2538
2538
|
justify-content: space-evenly;
|
|
2539
2539
|
flex-grow: 1;
|
|
2540
|
-
`,
|
|
2540
|
+
`,Q8=Ti.div`
|
|
2541
2541
|
display: flex;
|
|
2542
2542
|
flex-direction: column;
|
|
2543
2543
|
gap: 8px;
|
|
2544
|
-
`;import{isHexString as
|
|
2544
|
+
`;import{isHexString as X8}from"@ethersproject/bytes";import{toUtf8String as eb}from"@ethersproject/strings";import{useEffect as Mg,useState as pc}from"react";import Uo,{css as tb}from"styled-components";import{Fragment as Og,jsx as it,jsxs as Pi}from"react/jsx-runtime";var rb=e=>{if(!X8(e))return e;try{return eb(e)}catch{return e}},ob=e=>JSON.stringify(e,null,2),nb=({data:e})=>{let t=r=>typeof r=="object"&&r!==null?it(cb,{children:Object.entries(r).map(([o,n])=>Pi("li",{children:[Pi("strong",{children:[o,":"]})," ",t(n)]},o))}):it("span",{children:String(r)});return it("div",{children:t(e)})},ib=e=>{let{types:t,primaryType:r,...o}=e.typedData;return Pi(Og,{children:[it(Lg,{children:it(nb,{data:o})}),it(Ao,{text:ob(e.typedData),itemName:"full payload to clipboard"})," "]})},Wg=()=>{let{authenticated:e}=F(),{initializeWalletProxy:t,closePrivyModal:r}=M(),{navigate:o,data:n,onUserCloseViaDialogOrKeybindRef:i}=x(),[a,l]=pc(!0),[s,c]=pc(""),[u,h]=pc(),[f,y]=pc(null),v=f!==null;Mg(()=>{e||o("LANDING")},[e]),Mg(()=>{t(xn).then(R=>{l(!1),R||(c("An error has occurred, please try again."),h(new Be(new jt(s,st.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))})},[]);let{method:g,data:k,confirmAndSign:w,onSuccess:b,onFailure:_,uiOptions:A}=n.signMessage,N={title:A.title||"Sign message",description:A.description||"Signing this message will not cost you any fees.",buttonText:A.buttonText||"Sign and continue"},I=R=>{R?b(R):_(u||new Be(new jt("The user rejected the request.",st.E4001_USER_REJECTED_REQUEST.eipCode))),r({shouldCallAuthOnSuccess:!1}),y(null),c(""),h(void 0)};return i.current=()=>{I(f)},Pi(Og,{children:[it(S,{onClose:()=>I(f)}),it(Q,{}),Pi(ab,{children:[it(sb,{children:N.title}),it(lb,{children:N.description}),g==="personal_sign"&&it(Lg,{children:rb(k)}),g==="eth_signTypedData_v4"&&it(ib,{typedData:k}),it(db,{fail:!0,children:s}),it(ub,{success:v,loading:a,disabled:v,onClick:async()=>{try{let R=await w();y(R),c(""),setTimeout(()=>{I(R)},Le)}catch(R){console.error(R),c("An error has occurred, please try again."),h(new Be(new jt(s,st.E32603_DEFAULT_INTERNAL_ERROR.eipCode)))}},children:v?Pi(pb,{children:[it(wl,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",it("span",{children:"Success"})]}):N.buttonText})]}),it(re,{}),it(q,{protectedByPrivy:!0})]})},ab=Uo.div`
|
|
2545
2545
|
display: flex;
|
|
2546
2546
|
flex-direction: column;
|
|
2547
2547
|
align-items: center;
|
|
2548
2548
|
justify-content: center;
|
|
2549
|
-
`,
|
|
2549
|
+
`,sb=Uo.span`
|
|
2550
2550
|
color: var(--privy-color-foreground);
|
|
2551
2551
|
text-align: center;
|
|
2552
2552
|
font-size: 1.125rem;
|
|
2553
2553
|
font-weight: 500;
|
|
2554
2554
|
line-height: 1.25rem; /* 111.111% */
|
|
2555
2555
|
text-align: center;
|
|
2556
|
-
`,
|
|
2556
|
+
`,lb=Uo.span`
|
|
2557
2557
|
margin-top: 4px;
|
|
2558
2558
|
color: var(--privy-color-foreground);
|
|
2559
2559
|
text-align: center;
|
|
@@ -2582,7 +2582,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2582
2582
|
display: none; /* Safari and Chrome */
|
|
2583
2583
|
}
|
|
2584
2584
|
}
|
|
2585
|
-
`,
|
|
2585
|
+
`,cb=Uo.ul`
|
|
2586
2586
|
margin-left: 12px !important;
|
|
2587
2587
|
white-space: nowrap;
|
|
2588
2588
|
|
|
@@ -2594,7 +2594,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2594
2594
|
font-weight: 500 !important;
|
|
2595
2595
|
}
|
|
2596
2596
|
}
|
|
2597
|
-
`,
|
|
2597
|
+
`,db=Uo.div`
|
|
2598
2598
|
line-height: 20px;
|
|
2599
2599
|
height: 20px;
|
|
2600
2600
|
font-size: 13px;
|
|
@@ -2604,20 +2604,20 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2604
2604
|
width: 100%;
|
|
2605
2605
|
margin-top: 16px;
|
|
2606
2606
|
margin-bottom: 4px;
|
|
2607
|
-
`,
|
|
2607
|
+
`,pb=Uo.span`
|
|
2608
2608
|
display: flex;
|
|
2609
2609
|
align-items: center;
|
|
2610
2610
|
gap: 8px;
|
|
2611
|
-
`,
|
|
2611
|
+
`,ub=Uo(O)`
|
|
2612
2612
|
transition: color 350ms ease, background-color 350ms ease;
|
|
2613
2613
|
|
|
2614
|
-
${e=>e.success&&
|
|
2614
|
+
${e=>e.success&&tb`
|
|
2615
2615
|
&&&& {
|
|
2616
2616
|
background-color: var(--privy-color-success);
|
|
2617
2617
|
color: #ffffff;
|
|
2618
2618
|
}
|
|
2619
2619
|
`}
|
|
2620
|
-
`;import{useEffect as Ng,useState as Dg}from"react";import
|
|
2620
|
+
`;import{useEffect as Ng,useState as Dg}from"react";import mb from"styled-components";import{Fragment as hb,jsx as eo,jsxs as uc}from"react/jsx-runtime";var Ug=()=>{let{authenticated:e,logout:t,ready:r,user:o}=F(),{app:n,setModalData:i,navigate:a,resetNavigation:l}=x(),{initLoginWithTelegram:s,loginWithTelegram:c,updateWallets:u,setReadyToTrue:h,closePrivyModal:f,createAnalyticsEvent:y}=M(),[v,g]=Dg(!1),[k,w]=Dg(void 0),b=n?.render.inDialog?Le:0;async function _(){try{await c(),g(!0),h(!0)}catch(I){if(I?.privyErrorCode==="allowlist_rejected"){w(void 0),l(),a("ALLOWLIST_REJECTION_SCREEN");return}if(I?.privyErrorCode==="max_accounts_reached"){console.error(new lr(I).toString()),w(void 0),l(),a("USER_LIMIT_REACHED_SCREEN");return}let{retryable:R,detail:B}=Ic(I);w({retryable:R,detail:B,message:"Authentication failed"})}}Ng(()=>{_()},[]),Ng(()=>{if(!(r&&e&&v&&o))return;if(n?.legal.requireUsersAcceptTerms&&!o.hasAcceptedTerms){let B=setTimeout(()=>{a("AFFIRMATIVE_CONSENT_SCREEN")},b);return()=>clearTimeout(B)}if(Wt(o,n?.embeddedWallets?.createOnLogin)){let B=setTimeout(()=>{i({createWallet:{onSuccess:()=>{},onFailure:K=>{console.error(K),y({eventName:"embedded_wallet_creation_failure_logout",payload:{error:K,provider:"telegram",screen:"TelegramAuthScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),a("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")},b);return()=>clearTimeout(B)}u();let R=setTimeout(()=>f({shouldCallAuthOnSuccess:!0,isSuccess:!0}),b);return()=>clearTimeout(R)},[r,e,v,o]);let A=v?"Successfully connected with Telegram":k?k.message:"Verifying connection to Telegram",N="";return v?N="You\u2019re good to go!":k?N=k.detail:N="Just a few moments more",uc(hb,{children:[eo(S,{}),eo(Q,{}),uc(fb,{children:[eo(ot,{children:uc("div",{children:[eo(et,{success:v,fail:!!k}),eo(Dl,{style:{width:"38px",height:"38px"}})]})}),uc(Ke,{children:[eo("h3",{children:A}),eo("p",{children:N})]}),k&&k?.retryable?eo(Un,{onClick:()=>{s().then(async()=>_()).catch(I=>{let{retryable:R,detail:B}=Ic(I);w({retryable:R,detail:B,message:"Authentication failed"})}),w(void 0)},disabled:!v&&!k?.retryable,children:"Retry"}):null]}),eo(re,{}),eo(z,{})]})},fb=mb.div`
|
|
2621
2621
|
display: flex;
|
|
2622
2622
|
flex-direction: column;
|
|
2623
2623
|
align-items: center;
|
|
@@ -2625,9 +2625,9 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2625
2625
|
margin-left: 27px;
|
|
2626
2626
|
margin-right: 27px;
|
|
2627
2627
|
gap: 24px;
|
|
2628
|
-
`;import
|
|
2628
|
+
`;import bb from"@heroicons/react/24/outline/EnvelopeIcon";import yb from"@heroicons/react/24/outline/EnvelopeIcon";import{forwardRef as gb,useState as Fg}from"react";import Hg from"styled-components";import{Fragment as wb,jsx as Na,jsxs as Bg}from"react/jsx-runtime";var Gg=gb((e,t)=>{let[r,o]=Fg(""),[n,i]=Fg(!1),{authenticated:a,user:l}=F(),{initUpdateEmail:s}=M(),{navigate:c,setModalData:u,currentScreen:h}=x(),{enabled:f,token:y}=he(),v=Za(r),g=n,k=n||!v,w=async _=>{if(!l?.email)throw new Error("User is required to have an email address to update it.");i(!0);try{await s(l.email.address,r,_),c("AWAITING_PASSWORDLESS_CODE")}catch(A){u({errorModalData:{error:A,previousScreen:h||"LANDING"}})}i(!1)},b=()=>{f&&!y&&!a?(u({captchaModalData:{callback:_=>{if(!l?.email)throw new Error("User is required to have an email address to update it.");return s(l.email.address,r,_)},userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_PASSWORDLESS_CODE",onErrorNavigateTo:"ERROR_SCREEN"}}),c("CAPTCHA_SCREEN")):w(y)};return Bg(wb,{children:[Na(vb,{children:Bg(Cb,{children:[Na(yb,{}),Na("input",{ref:t,id:"email-input",type:"email",placeholder:"your@email.com",onChange:_=>o(_.target.value),onKeyUp:_=>{_.key==="Enter"&&b()},value:r,autoComplete:"email"}),e.stacked?null:Na(Fn,{isSubmitting:g,onClick:b,disabled:k,children:"Submit"})]})}),e.stacked?Na(O,{loadingText:null,loading:g,disabled:k,onClick:b,children:"Submit"}):null]})}),vb=Hg.div`
|
|
2629
2629
|
width: 100%;
|
|
2630
|
-
`,
|
|
2630
|
+
`,Cb=Hg.label`
|
|
2631
2631
|
display: block;
|
|
2632
2632
|
position: relative;
|
|
2633
2633
|
width: 100%;
|
|
@@ -2685,7 +2685,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2685
2685
|
&& > input::placeholder {
|
|
2686
2686
|
color: var(--privy-color-foreground-3);
|
|
2687
2687
|
}
|
|
2688
|
-
`;import{Fragment as
|
|
2688
|
+
`;import{Fragment as Eb,jsx as Fo,jsxs as Tb}from"react/jsx-runtime";var Vg=()=>Tb(Eb,{children:[Fo(S,{},"header"),Fo(Q,{}),Fo(xe,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:Fo(bb,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),Fo(ur,{children:Fo(Gg,{stacked:!0})}),Fo(re,{}),Fo(q,{protectedByPrivy:!0})]});import vp from"styled-components";import{jsx as zg}from"react/jsx-runtime";var qg=({style:e,...t})=>zg("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"38px",width:"38px",...e},...t,children:zg("path",{d:"M20 13.6V20M20 26.4H20.016M36 20C36 28.8365 28.8366 36 20 36C11.1635 36 4.00001 28.8365 4.00001 20C4.00001 11.1634 11.1635 3.99999 20 3.99999C28.8366 3.99999 36 11.1634 36 20Z",stroke:"currentColor",strokeWidth:"3.2",strokeLinecap:"round",strokeLinejoin:"round"})});import{Fragment as xb,jsx as bn,jsxs as gp}from"react/jsx-runtime";var $g=()=>{let{navigate:e}=x();return gp(xb,{children:[bn(S,{}),gp(Pb,{children:[bn(Sb,{children:bn(qg,{})}),gp(_b,{children:[bn("h3",{children:"Unable to sign in"}),bn("p",{children:"This application has reached its user limit and cannot sign in new users."})]}),bn(O,{onClick:()=>{e("LANDING")},children:"Go back"})]}),bn(q,{protectedByPrivy:!0})]})},Pb=vp.div`
|
|
2689
2689
|
display: flex;
|
|
2690
2690
|
flex-direction: column;
|
|
2691
2691
|
align-items: center;
|
|
@@ -2694,7 +2694,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2694
2694
|
width: 100%;
|
|
2695
2695
|
padding-top: 8px;
|
|
2696
2696
|
padding-bottom: 32px;
|
|
2697
|
-
`,
|
|
2697
|
+
`,Sb=vp.div`
|
|
2698
2698
|
display: flex;
|
|
2699
2699
|
align-items: center;
|
|
2700
2700
|
justify-content: center;
|
|
@@ -2703,11 +2703,11 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2703
2703
|
color: var(--privy-color-error);
|
|
2704
2704
|
background-color: var(--privy-color-error-light);
|
|
2705
2705
|
border-radius: 50%;
|
|
2706
|
-
`,
|
|
2706
|
+
`,_b=vp.div`
|
|
2707
2707
|
display: flex;
|
|
2708
2708
|
flex-direction: column;
|
|
2709
2709
|
gap: 8px;
|
|
2710
|
-
`;import
|
|
2710
|
+
`;import Ab,{createGlobalStyle as Rb}from"styled-components";var kb=`
|
|
2711
2711
|
*,
|
|
2712
2712
|
::before,
|
|
2713
2713
|
::after {
|
|
@@ -2937,7 +2937,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2937
2937
|
[hidden] {
|
|
2938
2938
|
display: none;
|
|
2939
2939
|
}
|
|
2940
|
-
`,Kg=
|
|
2940
|
+
`,Kg=kb;var jg=Rb`
|
|
2941
2941
|
:root {
|
|
2942
2942
|
// Borders
|
|
2943
2943
|
--privy-border-radius-sm: 6px;
|
|
@@ -2970,7 +2970,7 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
2970
2970
|
--privy-height-modal-full: 620px;
|
|
2971
2971
|
--privy-height-modal-compact: 480px;
|
|
2972
2972
|
};
|
|
2973
|
-
`,Yg=
|
|
2973
|
+
`,Yg=Ab.div`
|
|
2974
2974
|
// css normalize only the privy application to avoid conflicts
|
|
2975
2975
|
// with consuming application
|
|
2976
2976
|
${Kg}
|
|
@@ -3032,4 +3032,4 @@ You will have to sign up with another method first to register a passkey for you
|
|
|
3032
3032
|
opacity: 1;
|
|
3033
3033
|
}
|
|
3034
3034
|
}
|
|
3035
|
-
`;import{jsx as ut,jsxs as Jg}from"react/jsx-runtime";var O8={["LANDING"]:Ry,["CONNECT_OR_CREATE"]:ky,["AWAITING_PASSWORDLESS_CODE"]:uf,["AWAITING_CONNECTION"]:Of,["AWAITING_CONNECT_ONLY_CONNECTION"]:Ff,["AWAITING_FARCASTER_CONNECTION"]:Gh,["AWAITING_FARCASTER_SIGNER"]:jh,["AWAITING_PASSKEY_SYSTEM_DIALOGUE"]:og,["PHANTOM_INTERSTITIAL_SCREEN"]:sg,["LOGIN_FAILED_SCREEN"]:zy,["AWAITING_OAUTH_SCREEN"]:eg,["ALLOWLIST_REJECTION_SCREEN"]:tf,["USER_LIMIT_REACHED_SCREEN"]:$g,["INSTALL_PHANTOM_SCREEN"]:ly,["LINK_EMAIL_SCREEN"]:Iy,["LINK_PHONE_SCREEN"]:Fy,["LINK_WALLET_SCREEN"]:By,["LINK_PASSKEY_SCREEN"]:Dy,["UPDATE_EMAIL_SCREEN"]:Vg,["CONNECT_ONLY_LANDING_SCREEN"]:Rf,["CONNECT_ONLY_AUTHENTICATED_SCREEN"]:xf,["EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN"]:th,["EMBEDDED_WALLET_CREATED_SCREEN"]:jf,["EMBEDDED_WALLET_CONNECTING_SCREEN"]:$f,["EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN"]:lg,["EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN"]:Cg,["EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN"]:yg,["EMBEDDED_WALLET_KEY_EXPORT_SCREEN"]:Qf,["EMBEDDED_WALLET_SIGN_REQUEST_SCREEN"]:Wg,["EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN"]:Ig,["FIAT_ON_RAMP_PROMPT_SCREEN"]:ey,["FIAT_ON_RAMP_STATUS_SCREEN"]:ry,["EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN"]:xh,["EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN"]:_h,["EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN"]:vg,["MFA_ENROLLMENT_FLOW_SCREEN"]:s1,["CAPTCHA_SCREEN"]:yf,["ERROR_SCREEN"]:Ah,["IN_APP_BROWSER_LOGIN_NOT_POSSIBLE"]:oy,["AFFIRMATIVE_CONSENT_SCREEN"]:Qm,["TELEGRAM_AUTH_SCREEN"]:Ug},N8=["LANDING","AWAITING_CONNECTION"],D8=({isMfaVerifying:e,onMfaVerificationComplete:t})=>{let{ready:r,isModalOpen:o}=F(),{headless:n}=Nt(),{ready:i,currentScreen:a}=x(),{status:l,execute:s,reset:c,enabled:u}=he(),h=M8(null),f=Hm(h),y=o&&a&&N8.includes(a)&&!n&&l==="ready";if(Zg(()=>{y&&s()},[y]),Zg(()=>{!o&&u&&c()},[o,u]),(!r||!i)&&a!=="AWAITING_OAUTH_SCREEN")return Jg(ui,{id:"privy-modal-content",children:[ut(S,{}),ut(Q,{}),ut(Qy,{children:ut(tt,{})}),ut(re,{}),ut(z,{})]});if(!a&&e)return ut(ui,{style:{height:f},id:"privy-modal-conent",children:ut("div",{ref:h,children:ut(dp,{open:e,onClose:t})})});if(!a)return null;let v=O8[a];return ut(ui,{style:{height:f},id:"privy-modal-content",children:Jg("div",{ref:h,children:[ut(_r,{if:!!e,children:ut(v,{})}),ut(_r,{if:!e,children:ut(dp,{open:e,onClose:t})})]})})},U8=()=>{let{closePrivyModal:e}=M(),{onUserCloseViaDialogOrKeybindRef:t}=x();return{gracefulClosePrivyModal:I8(()=>{if(t?.current)t.current();else return e({shouldCallAuthOnSuccess:!1})},[e])}},Qg=({open:e})=>{let{app:t}=x(),{gracefulClosePrivyModal:r}=U8(),[o,n]=W8(!1);qc({onMfaRequired:()=>{t?.mfa.noPromptOnMfaRequired||n(!0)}});let i=ut(Yg,{children:ut(D8,{isMfaVerifying:o,onMfaVerificationComplete:()=>n(!1)})}),a=e||o,l=t?.render.inDialog?ut(Jy,{open:a,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:i}):i;if(typeof window<"u"&&t?.render.inParentNodeId){let s=document.getElementById(t.render.inParentNodeId);if(s)return L8.createPortal(l,s)}return l};import{useRef as Xg,useEffect as F8}from"react";import{jsx as H8}from"react/jsx-runtime";function B8({botUsername:e,scriptHost:t}){let r=document.createElement("script"),{origin:o}=new URL(t);return r.async=!0,r.src=`${o}/js/telegram-login.js`,r.setAttribute("data-telegram-login",e),r.setAttribute("data-request-access","write"),r.setAttribute("data-lang","en"),r}function e2(e){let t=Xg(null),r=Xg();return F8(()=>{r.current?.remove(),r.current=B8(e),t.current?.after(r.current)},[e]),H8("div",{ref:t,hidden:!0})}import{useState as G8}from"react";import{useEffect as t2,useRef as r2}from"react";var mc=class{constructor(){this.callbacks={}}enqueue(t,r){this.callbacks[t]=r}dequeue(t,r){let o=this.callbacks[r];if(!o)throw new Error(`cannot dequeue ${t} event: no event found for id ${r}`);switch(delete this.callbacks[r],t){case"privy:iframe:ready":return o;case"privy:wallet:create":return o;case"privy:wallet:import":return o;case"privy:wallet:connect":return o;case"privy:wallet:recover":return o;case"privy:wallet:rpc":return o;case"privy:wallet:set-recovery-password":return o;case"privy:mfa:verify":return o;case"privy:mfa:init-enrollment":return o;case"privy:mfa:submit-enrollment":return o;case"privy:mfa:unenroll":return o;case"privy:mfa:clear":return o;case"privy:farcaster:init-signer":return o;case"privy:farcaster:sign":return o;default:throw new Error(`invalid wallet event type ${t}`)}}};async function Bo(e,t,r,o,n,i=!1){let a=i,l=async u=>{if(a&&t&&t.length>0){u===(i?0:1)?n("configureMfa","onMfaRequired",t):o.current?.reject(new De("missing_or_invalid_mfa","MFA verification failed, retry."));let h=await new Promise((f,y)=>{r.current={resolve:f,reject:y};let v=1e3*60*5;setTimeout(()=>{let g=new De("mfa_timeout","Timed out waiting for MFA code");o.current?.reject(g),y(g)},v)});return await e(h)}return await e()},s=4,c=null;for(let u=0;u<s;u++)try{c=await l(u),o.current?.resolve(void 0);break}catch(h){if(h.type==="missing_or_invalid_mfa")a=!0;else throw o.current?.resolve(void 0),h}if(c===null){let u=new De("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw o.current?.reject(u),u}return c}import{jsx as j8}from"react/jsx-runtime";var V8=function(e){return()=>`id-${e++}`}(0);function z8(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Vt(e){return e.error!==void 0}var kt=new mc,Cp=new Map,q8=(e,t)=>typeof t=="bigint"?t.toString():t,$8=(e,t)=>`${e}${JSON.stringify(t,q8)}`;function zt(e,t,r,o){let n=r.contentWindow;if(!n)throw new Error("iframe not initialized");let i=$8(e,t);if(e==="privy:wallet:create"){let l=Cp.get(i);if(l)return l}let a=new Promise((l,s)=>{let c=V8();kt.enqueue(c,{resolve:l,reject:s}),n.postMessage({id:c,event:e,data:t},o)}).finally(()=>{Cp.delete(i)});return Cp.set(i,a),a}function K8(e){switch(e.event){case"privy:iframe:ready":let t=kt.dequeue(e.event,e.id);return Vt(e)?t.reject(new De(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let r=kt.dequeue(e.event,e.id);return Vt(e)?r.reject(new De(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:import":let o=kt.dequeue(e.event,e.id);return Vt(e)?o.reject(new De(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let n=kt.dequeue(e.event,e.id);return Vt(e)?n.reject(new De(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:recover":let i=kt.dequeue(e.event,e.id);return Vt(e)?i.reject(new De(e.error.type,e.error.message)):i.resolve(e.data);case"privy:wallet:rpc":let a=kt.dequeue(e.event,e.id);return Vt(e)?a.reject(new De(e.error.type,e.error.message)):a.resolve(e.data);case"privy:wallet:set-recovery-password":let l=kt.dequeue(e.event,e.id);return Vt(e)?l.reject(new De(e.error.type,e.error.message)):l.resolve(e.data);case"privy:mfa:verify":let s=kt.dequeue(e.event,e.id);return Vt(e)?s.reject(new De(e.error.type,e.error.message)):s.resolve(e.data);case"privy:mfa:init-enrollment":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:mfa:submit-enrollment":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:mfa:unenroll":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:mfa:clear":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:farcaster:init-signer":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:farcaster:sign":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}function o2(e){let t=r2(null),r=r2(e.mfaMethods),o=zs(),[n,i]=G8(!1);return t2(()=>{r.current=e.mfaMethods},[e.mfaMethods]),t2(()=>{if(!n)return;let a=t.current;if(!a)return;function l(f){f&&f.origin===e.origin&&z8(f.data)&&K8(f.data)}let s={create(f){return zt("privy:wallet:create",f,a,e.origin)},import(f){return zt("privy:wallet:import",f,a,e.origin)},connect(f){return zt("privy:wallet:connect",f,a,e.origin)},recover(f){return Bo(y=>zt("privy:wallet:recover",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},rpc(f){return Bo(y=>zt("privy:wallet:rpc",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},setRecoveryPassword(f){return Bo(y=>zt("privy:wallet:set-recovery-password",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},verifyMfa(f){return Bo(y=>zt("privy:mfa:verify",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},initEnrollMfa(f){return Bo(y=>zt("privy:mfa:init-enrollment",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},submitEnrollMfa(f){return Bo(y=>zt("privy:mfa:submit-enrollment",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},unenrollMfa(f){return Bo(y=>zt("privy:mfa:unenroll",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},clearMfa(f){return zt("privy:mfa:clear",f,a,e.origin)},initFarcasterSigner(f){return zt("privy:farcaster:init-signer",f,a,e.origin)},signFarcasterMessage(f){return zt("privy:farcaster:sign",f,a,e.origin)}};window.addEventListener("message",l);let c=()=>e.onLoad(s),u=(...f)=>{console.warn("Privy iframe failed to load: ",...f),e.onLoadFailed()},h=new AbortController;return ki(()=>zt("privy:iframe:ready",{},a,e.origin),{abortSignal:h.signal}).then(c,u),()=>{window.removeEventListener("message",l),h.abort()}},[n]),j8("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>i(!0),src:Ja(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId})})}function fc(e){let t=e.toLowerCase();return["fbav","fban","instagram","snapchat"].some(o=>t.includes(o))}var Y8="https://cdn.apple-cloudkit.com";async function wp({url:e,popup:t,provider:r}){return t.location=e,new Promise((n,i)=>{function a(){t?.close(),window.removeEventListener("message",l)}function l(s){s.data&&(s.data.type==="PRIVY_OAUTH_RESPONSE"&&s.data.stateCode&&s.data.authorizationCode&&(n(s.data),a()),s.origin===Y8&&s.data.ckSession&&(n({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:s.data.ckSession}),a()),s.data.type==="PRIVY_OAUTH_ERROR"&&(i(s.data.error),a()))}window.addEventListener("message",l)})}var n2=e=>({id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type});import{jsx as vr,jsxs as i2}from"react/jsx-runtime";var ho;function Q8(e){return typeof e=="string"&&e.length===25}function Ee(){if(!ho){let e=Z.get(qo);return Promise.resolve(e||null)}return ho.getAccessToken()}var a2,Zu=(e,t,r)=>a2(e,t,r),s2,Ju=(e,t)=>s2(e,t),l2,Qu=(e,t)=>l2(e,t),c2,Xu=()=>c2(),X8=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;Z.put(Ii,t);let r=new URL(window.location.href);r.searchParams.delete("privy_token"),window.history.pushState({},"",r)},eE=({config:e,...t})=>{if(!Q8(t.appId))throw new P("Cannot initialize the Privy provider with an invalid Privy app ID");ho||(ho=new $i({appId:t.appId,apiUrl:t.apiUrl||Ri}));let r=Object.assign({},e);return t.createPrivyWalletOnLogin!==void 0&&r.embeddedWallets?.createOnLogin===void 0&&(r.embeddedWallets||(r.embeddedWallets={}),r.embeddedWallets.createOnLogin=t.createPrivyWalletOnLogin?"users-without-wallets":"off"),t.createPrivyWalletOnLogin!==void 0&&e?.embeddedWallets?.createOnLogin&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),vr(Rm,{client:ho,clientConfig:r,legacyCreateEmbeddedWalletFlag:t.createPrivyWalletOnLogin,children:vr(tE,{...t,client:ho})})},tE=e=>{let t=e.client,[r,o]=je(!1),[n,i]=je(!1),[a,l]=je(!1),[s,c]=je(null),[u,h]=je([]),f=_i(u),[y,v]=je(!1),[g,k]=je(null),[w,b]=je(!1),[_,A]=je({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:E}),[N,I]=je({status:"initial"}),[R,B]=je(null),[K,Y]=je(null),[W,V]=je(null),L=Nt(),ae=Bs(),[de,pe]=je(!0),[we,X]=je({}),[bt,Ye]=je(null),[At,Xe]=je(null),[ir,Re]=je(!1),[qe,ar]=je(!1),Rt=_i(null),Ge=_i(null),D=_i(Gm),[Ho,be]=je(!1);t.onStoreToken=d=>{d&&U(D,"accessToken","onAccessTokenGranted",d)},t.onDeleteToken=()=>{c(null),l(!1),U(D,"accessToken","onAccessTokenRemoved")};let J=_i(null),ee=_i(null),ge=d=>{k(d),setTimeout(()=>{o(!0)},15),t.createAnalyticsEvent({eventName:"modal_open",payload:{initialScreen:d}})},Ue=d=>{L.embeddedWallets.createOnLogin!=="off"&&pe(!0),ge(d)};Nr(()=>{let d=()=>{document.visibilityState==="hidden"&&t.createAnalyticsEvent({eventName:"page_hidden",options:{keepAlive:!0}})};return document.addEventListener("visibilitychange",d),()=>{document.removeEventListener("visibilitychange",d)}},[]),Nr(()=>{if(!s){t.connectors?.removeEmbeddedWalletConnector();return}let d=Ie(s),p=Mc(s);if(d||t.connectors?.removeEmbeddedWalletConnector(),p||t.connectors?.removeImportedWalletConnector(),!t.connectors){console.debug("Failed to add embedded wallet connector: Client connectors not initialized");return}if(!W){console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized");return}d&&t.connectors.addEmbeddedWalletConnector(W,d.address,L.defaultChain,e.appId),p&&t.connectors.addImportedWalletConnector(W,p.address,L.defaultChain,e.appId)},[W,s]),Nr(()=>{W&&At?.(W)},[W]),Nr(()=>{(async()=>{if(!L.customAuth?.enabled)return;pe(!0);let{getCustomAccessToken:p,isLoading:m}=L.customAuth;if(!(!n||m))try{let C=await p();if(!C&&a){await Pn.logout();return}if(!C||a)return;t.startAuthFlow(new Sn(C));let{user:T,isNewUser:H}=await t.authenticate();if(!T){await Pn.logout();return}c(T||null),v(H||!1),l(!0),ar(!0)}catch(C){console.warn(C),a&&await Pn.logout()}})()},[L.customAuth?.enabled,L.customAuth?.getCustomAccessToken,L.customAuth?.isLoading,n,a]),Nr(()=>{qe&&W&&s&&Wt(s,L.embeddedWallets.createOnLogin)&&(ar(!1),Da(s,xn).catch(console.error))},[qe&&W&&s]),Nr(()=>{async function d(){let p=hc();X8();let m=Z8();B(m),t.initializeConnectorManager({walletConnectCloudProjectId:L.walletConnectCloudProjectId,rpcConfig:L.rpcConfig,chains:L.chains,defaultChain:L.defaultChain,store:m,walletList:L.appearance.walletList,shouldEnforceDefaultChainOnConnect:L.shouldEnforceDefaultChainOnConnect,externalWalletConfig:L.externalWallets,appName:L.name??"Privy"});let C;t.connectors?.on("connectorInitialized",()=>{C&&clearTimeout(C);let H=t.connectors.walletConnectors.length,G=t.connectors.walletConnectors.reduce((fe,$e)=>fe+($e.initialized?1:0),0);G===H?be(!0):C=setTimeout(()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:G,expected:H}),be(!0)},1500)}),t.connectors?.initialize().then(()=>{yc()});let T=await t.getAuthenticatedUser();L.customAuth?.enabled||(l(!!T),T&&U(D,"login","onComplete",T,!1,!0,null,null),c(T)),p||me.setReadyToTrue(!!T),p&&(T?ee.current="link":ee.current="login")}!n&&ae&&d()},[t,bt,n,ae]),Nr(()=>{if(!n)return;if(!s){Re(!0);return}if(!!!s.linkedAccounts.find(m=>m.type==="wallet"&&m.walletClientType==="privy")){Re(!0);return}let p=!!u.find(m=>m.walletClientType==="privy");Re(p)},[n,s,u]);let hc=()=>{let d=Ni();if(d.inProgress&&d.popupFlow){if(window.opener.location.origin!==window.location.origin){window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."});return}window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:d.stateCode,authorizationCode:d.authorizationCode});return}return!d.inProgress||d.headless?!1:(t.startAuthFlow(new Ur(d)),Ue("AWAITING_OAUTH_SCREEN"),!0)},En=async(d,p,m,C)=>{let T=await t.connectors?.createWalletConnector(d,p)||null;Tn(T,p,m,C)};async function Tn(d,p,m,C){if(d)A({status:"disconnected",connectedWallet:null,connectError:null,connector:d,connectRetry:E});else return A({status:"disconnected",connectedWallet:null,connectError:new te("Unable to connect to wallet."),connector:null,connectRetry:E}),C?.(null,m);d instanceof Gr&&p&&await d.resetConnection(p),A({connector:d,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Tn(d,p,m,C)});try{let T=await d.connect({showPrompt:!0});if(L.shouldEnforceDefaultChainOnConnect&&!L.chains.find(H=>H.id===Number(T?.chainId))&&!(T?.connectorType==="wallet_connect_v2"&&T?.walletClientType==="metamask")&&!(T?.connectorType==="coinbase_wallet"&&L.externalWallets.coinbaseWallet.connectionOptions!=="eoaOnly")){A(H=>({...H,connector:d,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:E}));try{await T?.switchChain(L.defaultChain.id),T&&(T.chainId=_n(zo(L.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${L.defaultChain.id}`)}}return A(H=>({...H,status:"connected",connectedWallet:T,connectError:null,connectRetry:E})),T&&U(D,"connectWallet","onSuccess",T),C?.(T,m)}catch(T){return T instanceof ze?(console.warn(T.cause?T.cause:T.message),U(D,"connectWallet","onError",T.privyErrorCode||"generic_connect_wallet_error")):(console.warn(T),U(D,"connectWallet","onError","unknown_connect_wallet_error")),A(H=>({...H,status:"disconnected",connectedWallet:null,connectError:T})),C?.(null,m)}}let Go=async(d,p)=>{if(d===null)return;let m=new Qo(d,p);t.startAuthFlow(m)},yc=()=>{let d=new URLSearchParams(window.location.search),p=d.get("privy_connector"),m=d.get("privy_wallet_client");if(!p||!m)return;if(m==="phantom"&&!vo()&&Ue("LOGIN_FAILED_SCREEN"),!t.connectors)throw new P("Connector not initialized");ge("AWAITING_CONNECTION");let C=new URL(window.location.href);C.searchParams.delete("privy_connector"),C.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",C),En(p,m,void 0,Go)};Nr(()=>{n&&a&&s===null&&t.getAuthenticatedUser().then(c)},[n,a,s,t]);let Ve=()=>{if(!a)throw U(D,"linkAccount","onError","must_be_authenticated"),new P("User must be authenticated before linking an account.")},yo=()=>{Ve(),J.current="siwe",ee.current="link",ge("LINK_WALLET_SCREEN")},Ze=d=>{if(!a||!s)return!1;if(d.walletClientType==="privy")return!0;for(let p of s.linkedAccounts)if(p.type==="wallet"&&p.address===d.address&&p.walletClientType!=="privy")return!0;return!1},qt=async d=>{if(!t.connectors)throw new P("Connector not initialized");let p=t.connectors.findWalletConnector(d.connectorType,d.walletClientType)||null;if(A(m=>({...m,connector:p,status:"connected",connectedWallet:d,connectError:null,connectRetry:E})),L.captchaEnabled&&!a){let m={callback:C=>Go(d,C),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"};X({captchaModalData:m}),Ue("CAPTCHA_SCREEN")}else await Go(d),Ue("AWAITING_CONNECTION")},Cr=async(d,p)=>{if(!L.fiatOnRamp.enabled)throw new P("Fiat on-ramp is not enabled");if(!p||!p.provider||p.provider==="moonpay"){let{signedUrl:m,externalTransactionId:C}=await Qh(t,d,p?.config??{},L.appearance.palette,L.fiatOnRamp.useSandbox);return{signedUrl:m,externalTransactionId:C}}else throw new P("Unsupported fund provider. Currently supported option is `moonpay`.")},Vo=()=>{h(d=>{let p=t.connectors?.wallets.map(m=>({...m,linked:Ze(m),loginOrLink:async()=>{if(!await m.isConnected())throw new P("Wallet is not connected");if(m.connectorType==="embedded"&&m.walletClientType==="privy")throw new P("Cannot link or login with embedded wallet");qt(m)},fund:async C=>{let{signedUrl:T,externalTransactionId:H}=await Cr(m.address,C);X({fiatOnRampPrompt:{signedUrl:T},fiatOnRampStatus:{externalTransactionId:H}}),ge("FIAT_ON_RAMP_PROMPT_SCREEN")},unlink:async()=>{if(!a)throw new P("User is not authenticated.");if(m.connectorType==="embedded"&&m.walletClientType==="privy")throw new P("Cannot unlink an embedded wallet");let C=await t.unlinkWallet(m.address);c(C)}}))||[];return ws(d,p)?d:p})};Nr(()=>{Vo()},[s?.linkedAccounts,a,n]),Nr(()=>{if(n){if(!t.connectors)throw new P("Connector not initialized");Vo(),t.connectors.on("walletsUpdated",Vo)}},[n]);let to=()=>{ge(a?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};Nr(()=>{if(!u[0])return;let d=u[0],p=f.current.find(C=>C.address===d.address),m;if(d.walletClientType==="privy"?m=s?.linkedAccounts.find(C=>C.type==="wallet"&&C.address===d.address&&C.walletClientType==="privy"):m=s?.linkedAccounts.find(C=>C.type==="wallet"&&C.address===d.address&&C.walletClientType!=="privy"),!p&&m){let C=Object.assign({},s);C.wallet=m&&{address:m.address,chainType:m.chainType,chainId:m.chainId,walletClient:m.walletClient,walletClientType:m.walletClientType,connectorType:m.connectorType,imported:m.imported},c(C)}f.current=u},[u]);let Da=async(d,p)=>{if(Ie(d))throw U(D,"createWallet","onError","embedded_wallet_already_exists"),new Error("Only one Privy wallet per user is currently allowed");let[C,T]=await Promise.all([me.initializeWalletProxy(p),Ee()]);if(!C&&L.customAuth?.enabled)throw U(D,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!C||!T||L.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return new Promise((H,G)=>{pe(!0),X({createWallet:{onSuccess:$e=>{U(D,"createWallet","onSuccess",$e),H($e)},onFailure:$e=>{U(D,"createWallet","onError","unknown_embedded_wallet_error"),G($e)},callAuthOnSuccessOnClose:!1}}),ge("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{await C.create({accessToken:T});let H=await me.refreshUser(),G=Ie(H);if(!G)throw U(D,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return U(D,"createWallet","onSuccess",G),G}},m2=d=>{if(!L.chains.map(p=>p.id).includes(d))throw new te(`Chain ID ${d} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},Ep=(d,p,m)=>new Promise(async(C,T)=>{if(!a||!s){U(D,"sendTransaction","onError","must_be_authenticated"),T(new Error("User must be authenticated before signing with a Privy wallet"));return}let H=d.from,G=H?s?.linkedAccounts.find(Se=>Se.type==="wallet"&&Se.walletClientType==="privy"&&Se.address===H):Ie(s);if(!G){U(D,"sendTransaction","onError","embedded_wallet_not_found"),T(new Error("Must have a Privy wallet before signing"));return}pe(!0);let fe=t.connectors?.findWalletConnector("embedded","privy")?.proxyProvider,$e=d.chainId?Number(d.chainId):fe.chainId;m2($e);let mt=Object.assign({},d,{chainId:$e}),sr=async()=>{let Se=await Ee();if(!Se||!W){U(D,"sendTransaction","onError","embedded_wallet_not_found"),T(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await me.recoverEmbeddedWallet()){U(D,"sendTransaction","onError","unknown_connect_wallet_error"),T(new Error("Unable to connect to wallet"));return}let wr=ro(mt.chainId,L.chains,L.rpcConfig,{appId:e.appId}),gc=await wi(G.address,mt,wr);if(L.embeddedWallets.noPromptOnSignature){let{totalGasEstimate:h2}=await Ci(gc,wr),{hasSufficientFunds:y2}=await Xl(G.address,gc,h2,wr);if(!y2)throw new Be(new jt("Wallet has insufficient funds for this transaction.",st.E32603_DEFAULT_INTERNAL_ERROR.eipCode))}let Pp=await Ql(Se,G.address,W,gc,wr);U(D,"sendTransaction","onSuccess",Pp),C(Pp)}catch(Ua){U(D,"sendTransaction","onError","transaction_failure"),T(Ua)}};if(L.embeddedWallets.noPromptOnSignature)p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),sr();else{let Se={transactionRequest:mt,onSuccess:wr=>{U(D,"sendTransaction","onSuccess",wr),C(wr)},onFailure:wr=>{U(D,"sendTransaction","onError","transaction_failure"),T(wr)},uiOptions:p||{},fundWalletConfig:m},Ua={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:wr=>{U(D,"sendTransaction","onError","unknown_connect_wallet_error"),T(wr)}};X({connectWallet:Ua,sendTransaction:Se}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}});function Tp(){return new Promise(async(d,p)=>{let m=await Ee();if(!m||!W)throw new Error("Must have valid access token to enroll in MFA");try{await W.verifyMfa({accessToken:m}),d()}catch(C){p(C)}})}let It=d=>{if(d==="passkey"){if(s&&s.linkedAccounts.filter(p=>p.type==="passkey").length>=5)throw U(D,"linkAccount","onError","cannot_link_more_of_type"),new P(`User already has an account of type ${d} linked.`)}else if(s?.[d])throw U(D,"linkAccount","onError","cannot_link_more_of_type"),new P(`User already has an account of type ${d} linked.`)},Pn={ready:n,authenticated:a,user:s,walletConnectors:t.connectors||null,connectWallet:to,importWallet:async({privateKey:d})=>{Ve();let[p,m]=await Promise.all([me.initializeWalletProxy(15e3),Ee()]);if(p&&m){await p.import({privateKey:d,accessToken:m});let C=await me.refreshUser(),T=Mc(C);if(!T)throw U(D,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to import wallet");return U(D,"createWallet","onSuccess",T),T}else throw new P("User is not authenticated")},linkWallet:yo,linkEmail:()=>{Ve(),It("email"),J.current="email",ee.current="link",ge("LINK_EMAIL_SCREEN")},linkPhone:()=>{Ve(),It("phone"),J.current="sms",ee.current="link",ge("LINK_PHONE_SCREEN")},linkGoogle:async()=>{Ve(),It("google"),ee.current="link",await me.initLoginWithOAuth("google")},linkTwitter:async()=>{Ve(),It("twitter"),ee.current="link",await me.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Ve(),It("discord"),ee.current="link",await me.initLoginWithOAuth("discord")},linkGithub:async()=>{Ve(),It("github"),ee.current="link",await me.initLoginWithOAuth("github")},linkSpotify:async()=>{Ve(),It("spotify"),ee.current="link",await me.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Ve(),It("instagram"),ee.current="link",await me.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Ve(),It("tiktok"),ee.current="link",await me.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Ve(),It("linkedin"),ee.current="link",await me.initLoginWithOAuth("linkedin")},linkApple:async()=>{Ve(),It("apple"),ee.current="link",await me.initLoginWithOAuth("apple")},linkPasskey:async()=>{Ve(),It("passkey"),await me.initLinkWithPasskey(),ge("LINK_PASSKEY_SCREEN")},linkTelegram:async()=>{Ve(),It("telegram"),ee.current="link",J.current="telegram",await me.initLoginWithTelegram(),ge("TELEGRAM_AUTH_SCREEN")},linkFarcaster:async()=>{Ve(),It("farcaster"),await me.initLoginWithFarcaster(),ee.current="link",J.current="farcaster",ge("AWAITING_FARCASTER_CONNECTION")},updateEmail:()=>{if(Ve(),!s?.email)throw new P("User does not have an email linked to their account.");ee.current="link",J.current="email",ge("UPDATE_EMAIL_SCREEN")},login:async()=>{let d="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!n){let p=await new Promise(m=>{Ye(C=>m.bind(C))});if(Ye(null),p){console.warn(d);return}}if(a){console.warn(d);return}ee.current="login",Ue("LANDING")},connectOrCreateWallet:async()=>{if(n||(await new Promise(d=>{Ye(()=>d)}),Ye(null)),a){console.warn("User must be unauthenticated to `connectOrCreateWallet`");return}if(u[0]){console.warn("User must have no connected wallets to `connectOrCreateWallet`");return}Ue("CONNECT_OR_CREATE")},logout:async()=>{if(await t.logout(),s&&W)try{await W.clearMfa({userId:s.id})}catch{}c(null),l(!1),k(null),U(D,"logout","onSuccess"),ee.current=null,J.current=null,o(!1),Z.del(Mi)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{if(!s||!s.wallet)return new Oe;let d=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(C=>C.address===d?.address));return!d||!p?new Oe:p.proxyProvider},getEthersProvider:()=>{if(!s||!s.wallet)return new bp(new Fr(new Oe));let d=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(C=>C.address===d?.address));return!d||!p?new bp(new Fr(new Oe)):new bp(new Fr(p.proxyProvider))},getWeb3jsProvider:()=>{if(!s||!s.wallet)return new bo(new Oe);let d=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(C=>C.address===d?.address));return!d||!p?new bo(new Oe):new bo(p.proxyProvider)},unlinkWallet:async d=>{let p=await t.unlinkWallet(d);return c(p),p},unlinkEmail:async d=>{let p=await t.unlinkEmail(d);return c(p),p},unlinkPhone:async d=>{let p=await t.unlinkPhone(d);return c(p),p},unlinkGoogle:async d=>{let p=await t.unlinkOAuth("google",d);return c(p),p},unlinkTwitter:async d=>{let p=await t.unlinkOAuth("twitter",d);return c(p),p},unlinkDiscord:async d=>{let p=await t.unlinkOAuth("discord",d);return c(p),p},unlinkGithub:async d=>{let p=await t.unlinkOAuth("github",d);return c(p),p},unlinkSpotify:async d=>{let p=await t.unlinkOAuth("spotify",d);return c(p),p},unlinkInstagram:async d=>{let p=await t.unlinkOAuth("instagram",d);return c(p),p},unlinkTiktok:async d=>{let p=await t.unlinkOAuth("tiktok",d);return c(p),p},unlinkLinkedIn:async d=>{let p=await t.unlinkOAuth("linkedin",d);return c(p),p},unlinkApple:async d=>{let p=await t.unlinkOAuth("apple",d);return c(p),p},unlinkFarcaster:async d=>{let p=await t.unlinkFarcaster(d);return c(p),p},unlinkTelegram:async d=>{let p=await t.unlinkTelegram(d);return c(p),p},unlinkPasskey:async d=>{let p=await t.unlinkPasskey(d);return c(p),p},setActiveWallet:async d=>{let p=u.find(C=>Si(C.address)===Si(d)),m=s?.linkedAccounts.find(C=>C.type==="wallet"&&Si(C.address)===Si(d));if(!p||!await p.isConnected())Y(d),yo();else if(!p.linked)p.loginOrLink();else{let C=Object.assign({},s);C.wallet=m&&{address:m.address,chainType:m.chainType,chainId:m.chainId,walletClient:m.walletClient,walletClientType:m.walletClientType,connectorType:m.connectorType,imported:m.imported},c(C)}},forkSession:()=>t.forkSession(),createWallet:async()=>{if(!a||!s)throw U(D,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return Da(s,15e3)},setWalletPassword:async()=>{if(!a||!s)throw U(D,"setWalletPassword","onError","must_be_authenticated"),new Error("User must be authenticated before adding password to Privy wallet");let d=Ie(s);if(!d||!W)throw U(D,"setWalletPassword","onError","embedded_wallet_not_found"),new Error("Must have a Privy wallet to add a password");if(["google-drive","icloud"].includes(d.recoveryMethod))throw U(D,"setWalletPassword","onError","embedded_wallet_recovery_already_exists"),new Error("Cannot set password. Embedded wallet is set to recover using a cloud provider.");try{await Tp()}catch(p){throw U(D,"setWalletPassword","onError","missing_or_invalid_mfa"),p}return new Promise((p,m)=>{pe(!0);let C={onSuccess:G=>{U(D,"setWalletPassword","onSuccess",G),p(G)},onFailure:G=>{U(D,"setWalletPassword","onError","user_exited_set_password_flow"),m(G)},callAuthOnSuccessOnClose:!1},H={onCompleteNavigateTo:d.recoveryMethod==="user-passcode"?"EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN":"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",onFailure:G=>{U(D,"setWalletPassword","onError","unknown_connect_wallet_error"),m(G)}};X({setWalletPassword:C,createWallet:C,connectWallet:H}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")})},signMessage:(d,p,m)=>new Promise(async(C,T)=>{if(!a||!s){U(D,"signMessage","onError","must_be_authenticated"),T(new Error("User must be authenticated before signing with a Privy wallet"));return}let H=m?s?.linkedAccounts.find(fe=>fe.type==="wallet"&&fe.walletClientType==="privy"&&Si(fe.address)===Si(m)):Ie(s);if(!H){U(D,"signMessage","onError","embedded_wallet_not_found"),T(new Error("Must have a Privy wallet before signing"));return}if(typeof d!="string"||d.length<1){U(D,"signMessage","onError","invalid_message"),T(new Error("Message must be a non-empty string"));return}pe(!0);let G=async()=>{if(!a)throw new Error("User must be authenticated before signing with a Privy wallet");let fe=await Ee();if(!W||!fe)throw new Error("Unable to connect to wallet");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:H.address}});let{response:mt}=await W.rpc({accessToken:fe,address:H.address,request:{method:"personal_sign",params:[d,H.address]}}),sr=mt.data;return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:H.address}}),sr};if(L.embeddedWallets.noPromptOnSignature){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let fe=await G();U(D,"signMessage","onSuccess",fe),C(fe)}catch(fe){U(D,"signMessage","onError","unable_to_sign"),T(fe??new Be("Unable to sign message"))}}else{let mt={method:"personal_sign",data:d,confirmAndSign:G,onSuccess:Se=>{U(D,"signMessage","onSuccess",Se),C(Se)},onFailure:Se=>{U(D,"signMessage","onError","unable_to_sign"),T(Se)},uiOptions:p||{}},sr={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Se=>{U(D,"signMessage","onError","unknown_connect_wallet_error"),T(Se)},address:H.address};X({signMessage:mt,connectWallet:sr}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),signTypedData:(d,p)=>new Promise(async(m,C)=>{if(!a||!s){U(D,"signTypedData","onError","must_be_authenticated"),C(new Error("User must be authenticated before signing with a Privy wallet"));return}let T=Ie(s);if(!T){U(D,"signTypedData","onError","embedded_wallet_not_found"),C(new Error("Must have a Privy wallet before signing"));return}pe(!0);let H=Qa(d),G=async()=>{if(!a)throw new Error("User must be authenticated before signing with a Privy wallet");let fe=await Ee();if(!W||!fe)throw new Error("Unable to connect to wallet");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:T.address}});let{response:mt}=await W.rpc({accessToken:fe,address:T.address,request:{method:"eth_signTypedData_v4",params:[T.address,H]}}),sr=mt.data;return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:T.address}}),sr};if(L.embeddedWallets.noPromptOnSignature||(L.legacyWalletUiConfig??!1)){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let fe=await G();U(D,"signTypedData","onSuccess",fe),m(fe)}catch(fe){U(D,"signTypedData","onError","unable_to_sign"),C(fe??new Be("Unable to sign message"))}}else{let mt={method:"eth_signTypedData_v4",data:H,confirmAndSign:G,onSuccess:Se=>{U(D,"signTypedData","onSuccess",Se),m(Se)},onFailure:Se=>{U(D,"signTypedData","onError","unable_to_sign"),C(Se)},uiOptions:p||{}},sr={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Se=>{U(D,"signMessage","onError","unknown_connect_wallet_error"),C(Se)}};X({signMessage:mt,connectWallet:sr}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:async(d,p,m)=>{let T=await(await Ep(d,p,m)).wait();return ec(T)},exportWallet:()=>new Promise(async(d,p)=>{if(!a||!s){p(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!Ie(s)){p(new Error("Must have a Privy wallet before exporting"));return}pe(!0);let C={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:p,shouldForceMFA:!0};if(X(we),!await Ee()||!W){p(new Error("Must have valid access token to enroll in MFA"));return}if(!W){p(new Error("Must have a Privy wallet before exporting"));return}let H={appId:e.appId,origin:t.apiUrl,onSuccess:d,onFailure:p};X({keyExport:H,connectWallet:C}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}),promptMfa:Tp,async init(d){switch(d){case"sms":await t.initMfaSmsVerification();return;case"passkey":return await t.initMfaPasskeyVerification();case"totp":return;default:throw new Error(`Unsupported MFA method: ${d}`)}},async submit(d,p){switch(d){case"totp":case"sms":if(typeof p!="string")throw new P("Invalid MFA code");Rt.current?.resolve({mfaMethod:d,mfaCode:p,relyingParty:window.origin}),await new Promise((H,G)=>{Ge.current={resolve:H,reject:G}});break;case"passkey":if(typeof p=="string")throw new P("Invalid authenticator response");let C=await(await import("@simplewebauthn/browser")).startAuthentication(p),T=n2(C);Rt.current?.resolve({mfaMethod:d,mfaCode:T,relyingParty:window.origin}),await new Promise((H,G)=>{Ge.current={resolve:H,reject:G}});break;default:throw Rt.current?.reject(new P("Unsupported MFA method")),new P(`Unsupported MFA method: ${d}`)}},cancel(){Rt.current?.reject(new P("MFA canceled"))},async initEnrollmentWithSms(d){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to enroll in MFA");await W.initEnrollMfa({method:"sms",accessToken:p,phoneNumber:d.phoneNumber})},enrollInMfa(d){return new Promise((p,m)=>{if(!d){me.closePrivyModal(),p();return}L.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),X({mfaEnrollmentFlow:{mfaMethods:L.mfa.methods,onSuccess:p,onFailure:m}}),ge("MFA_ENROLLMENT_FLOW_SCREEN")})},async initEnrollmentWithTotp(){let d=await Ee();if(!d||!W)throw new Error("Must have valid access token to enroll in MFA");let p=await W.initEnrollMfa({method:"totp",accessToken:d});return{secret:p.secret,authUrl:p.authUrl}},async submitEnrollmentWithSms(d){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to enroll in MFA");await W.submitEnrollMfa({method:"sms",accessToken:p,phoneNumber:d.phoneNumber,code:d.mfaCode});let m=await t.getAuthenticatedUser();c(m)},async submitEnrollmentWithTotp(d){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to enroll in MFA");await W.submitEnrollMfa({method:"totp",accessToken:p,code:d.mfaCode});let m=await t.getAuthenticatedUser();c(m)},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:d}){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to enroll in MFA");await W.submitEnrollMfa({method:"passkey",accessToken:p,credentialIds:d});let m=await t.getAuthenticatedUser();c(m)},async unenroll(d){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to remove MFA");d==="passkey"?await W.submitEnrollMfa({method:"passkey",accessToken:p,credentialIds:[]}):await W.unenrollMfa({method:d,accessToken:p});let m=await t.getAuthenticatedUser();c(m)},requestFarcasterSignerFromWarpcast:async()=>{let d=await Ee(),p=s?.linkedAccounts.find(T=>T.type==="wallet"&&T.walletClientType==="privy");if(!d)throw new Error("Must have valid access token to connect with Farcaster");if(!W||!p)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");let C=await W.initFarcasterSigner({address:p.address,hdWalletIndex:null,accessToken:d,mfaCode:null,mfaMethod:null,relyingParty:window.origin});if(C.status==="approved"){let T=await t.getAuthenticatedUser();c(T||s||null)}X({farcasterSigner:C}),ge("AWAITING_FARCASTER_SIGNER")},getFarcasterSignerPublicKey:async()=>{let d=await Ee(),p=s?.linkedAccounts.find(T=>T.type==="wallet"&&T.walletClientType==="privy");if(!d)throw new Error("Must have valid access token to connect with Farcaster");if(!W||!p)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");if(!s.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster signer public key to sign");return(T=>Uint8Array.from(T.match(/.{1,2}/g).map(H=>parseInt(H,16))))(s.farcaster.signerPublicKey.slice(2))},signFarcasterMessage:async d=>{let p=await Ee(),m=s?.linkedAccounts.find(G=>G.type==="wallet"&&G.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!W||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");if(!s.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster signer public key to sign");let T=await import("@simplewebauthn/browser"),H=await W.signFarcasterMessage({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{hash:T.bufferToBase64URLString(d)},fid:BigInt(s.farcaster.fid),relyingParty:window.origin});return new Uint8Array(T.base64URLStringToBuffer(H.signature))},isHeadlessOAuthLoading:w,loginWithCode(d){return me.loginWithCode(d)},initLoginWithEmail(d){return me.initLoginWithEmail(d)},initLoginWithSms(d){return me.initLoginWithSms(d)},otpState:N,fundWallet(d,p){return me.fundWallet(d,p)},initLoginWithHeadlessOAuth(d,p){return me.initLoginWithHeadlessOAuth(d,p)},loginWithHeadlessOAuth(d){return me.loginWithHeadlessOAuth(d)},isModalOpen:r,mfaMethods:L.mfa.methods};a2=Pn.signMessage,s2=Pn.signTypedData,l2=async(...d)=>{let p=await Ep(...d);return L.embeddedWallets.waitForTransactionConfirmation&&await p.wait(),p};let me=(()=>({isNewUserThisSession:y,linkingHint:K,pendingTransaction:null,walletConnectionStatus:_,mipdStore:R,connectors:t.connectors?.walletConnectors??[],rpcConfig:L.rpcConfig,chains:L.chains,appId:e.appId,showFiatPrices:L.embeddedWallets.priceDisplay.primary!=="native-token",clientAnalyticsId:t.clientAnalyticsId,nativeTokenSymbolForChainId:d=>L.chains.find(p=>p.id===Number(d))?.nativeCurrency.symbol,initializeWalletProxy:async d=>{if(W)return W;let p=new Promise(T=>{Xe(()=>H=>T(H))}),m=new Promise(T=>setTimeout(()=>T(null),d)),C=await Promise.race([p,m]);return Xe(null),C},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>t.authFlow?.meta,closePrivyModal:(d={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let p=n&&a&&s,m;p&&J.current&&(m=s?.linkedAccounts.filter(C=>C.latestVerifiedAt!==null&&!(C.type==="wallet"&&C.walletClientType==="privy")).sort((C,T)=>T.latestVerifiedAt.getTime()-C.latestVerifiedAt.getTime())[0]),ee.current==="login"&&J.current?d.shouldCallAuthOnSuccess&&p?(U(D,"login","onComplete",s,y,!1,J.current,m??null),e.onSuccess?.(s,y)):U(D,"login","onError","exited_auth_flow"):ee.current==="link"&&J.current&&m&&(d.isSuccess&&p?U(D,"linkAccount","onSuccess",s,J.current,m):U(D,"linkAccount","onError","exited_link_flow")),Y(null),ee.current=null,J.current=null,v(!1),o(!1),setTimeout(()=>{t.authFlow=void 0},200),t.createAnalyticsEvent({eventName:"modal_closed"})},openPrivyModal:ge,connectWallet:Tn,initLoginWithWallet:async(d,p)=>{J.current="siwe",Go(d,p)},loginWithWallet:async()=>{if(!n)throw new Dr;if(!(t.authFlow instanceof Qo))throw new P("Must initialize SIWE flow first.");let d,p;if(a)try{({user:d}=await t.link()),J.current="siwe"}catch(m){throw U(D,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{({user:d,isNewUser:p}=await t.authenticate()),J.current="siwe"}catch(m){throw U(D,"login","onError",m.privyErrorCode||"generic_connect_wallet_error"),m}c(d||s||null),v(p||!1),l(!0)},initLoginWithFarcaster:async d=>{let p=new Ai(d);t.startAuthFlow(p);try{J.current="farcaster",await p.initializeFarcasterConnect()}catch(m){throw ee.current==="login"?U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",m.privyErrorCode||"unknown_auth_error"),m}},loginWithFarcaster:async()=>{if(!n)throw new Dr;if(!(t.authFlow instanceof Ai))throw new P("Must initialize Farcaster flow first.");let d,p;if(a)try{({user:d}=await t.link()),J.current="farcaster"}catch(m){throw U(D,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{({user:d,isNewUser:p}=await t.authenticate()),J.current="farcaster"}catch(m){throw U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}c(d||null),v(p||!1),l(!0)},async initLoginWithOAuth(d,p){if(J.current=d,bc()){if(d==="google"&&fc(window.navigator.userAgent)){Ue("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}}else{Ue("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}Z.del(jo);let m=new Ur({provider:d});p&&m.addCaptchaToken(p),t.startAuthFlow(m);let C=await t.authFlow.getAuthorizationUrl();C&&C.url&&window.location.assign(C.url)},async initLoginWithTelegram(d){if(!n)throw new Dr;J.current="telegram";let p=new Di(d);t.startAuthFlow(p),t.authFlow.meta.telegramAuthResult=await new Promise((m,C)=>{if(!L.loginConfig.telegramAuthConfiguration)return C("Telegram Auth configuration is not loaded");if(!window.Telegram)return C("Telegram was not initialized");window.Telegram.Login.auth({bot_id:L.loginConfig.telegramAuthConfiguration.botId,request_access:!0},T=>T?m(T):C("Telegram auth failed or was canceled by the client"))})},async loginWithTelegram(){if(!n)throw new Dr;if(!(t.authFlow instanceof Di))throw new P("Must initialize Telegram flow before calling loginWithTelegram");let d,p;if(a)try{({user:d}=await t.link()),J.current="telegram"}catch(m){throw U(D,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{let m=await t.authenticate();d=m.user,p=m.isNewUser,J.current="telegram"}catch(m){throw ee.current==="login"?U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}c(d),v(p||!1),l(!0)},async recoveryOAuthFlow(d,p,m){let C,T;function H(G){if(!G)throw t.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:d}}),new P("Recovery OAuth failed")}switch(d){case"google-drive":{let{url:G,codeVerifier:fe,stateCode:$e}=await md({api:ho.api,provider:d});H(G);let mt,sr;try{let Se=await wp({url:G,popup:m,provider:d});if(mt=Se.stateCode,sr=Se.authorizationCode,mt!==$e)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:d,storedStateCode:$e??"",returnedStateCode:mt??""}}),new P("Unexpected auth flow. This may be a phishing attempt.")}catch(Se){throw t.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:Se.toString(),provider:d}}),new P("Recovery OAuth failed")}[C,T]=await Promise.all([Ee(),Vf({api:ho.api,provider:d,codeVerifier:fe,stateCode:mt,authorizationCode:sr})]);break}case"icloud":{let{url:G}=await md({api:ho.api,provider:d});H(G);let{ckWebAuthToken:fe}=await wp({url:G,popup:m,provider:d});T=fe,C=await Ee();break}}if(!W)throw new P("Cannot connect to wallet proxy");switch(p){case"recover":let G=we.recoverWallet?.privyWallet?.address;if(!G)throw new P("Recovery OAuth failed");t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:G,recoveryMethod:d}}),await W.recover({address:G,accessToken:C,recoveryAccessToken:T,recoveryMethod:d}),t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:G,recoveryMethod:d}});break;case"create-wallet":t.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await W.create({accessToken:C,recoveryAccessToken:T,recoveryMethod:d});let fe=await me.refreshUser(),$e=Ie(fe);if(!$e)throw U(D,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:$e.address}}),U(D,"createWallet","onSuccess",$e);break;default:throw new P("Unsupported recovery action")}},async loginWithOAuth(d){if(!(t.authFlow instanceof Ur))throw new P("Must initialize OAuth flow before calling loginWithOAuth");let p=Z.get($o),m=t.authFlow.meta.stateCode;if(p!==m)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:d,storedStateCode:p??"",returnedStateCode:m??""}}),new P("Unexpected auth flow. This may be a phishing attempt.");let C,T,H;if(a)try{let G=await t.link();C=G.user,H=G.oAuthProviderTokens,J.current=d}catch(G){throw U(D,"linkAccount","onError",G.privyErrorCode||"failed_to_link_account"),G}else try{let G=await t.authenticate();C=G.user,T=G.isNewUser,H=G.oAuthProviderTokens,J.current=d}catch(G){throw ee.current==="login"?U(D,"login","onError",G.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",G.privyErrorCode||"failed_to_link_account"),G}return c(C),v(T||!1),l(!0),H},async initLoginWithPasskey(d){let p=new Jo(d);t.startAuthFlow(p),ee.current="login";try{J.current="passkey",await p.initAuthenticationFlow()}catch(m){throw U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}},async loginWithPasskey(){if(!n)throw new Dr;if(!(t.authFlow instanceof Jo))throw new P("Must initialize Passkey flow first.");if(J.current!=="passkey")throw new P("Must init login with Passkey flow first.");let d,p;try{J.current="passkey",{user:d,isNewUser:p}=await t.authenticate()}catch(m){throw U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}c(d),v(p||!1),l(!0)},async initLinkWithPasskey(d){let p=new Jo(d);t.startAuthFlow(p),ee.current="link",J.current="passkey";try{await p.initLinkFlow()}catch(m){throw U(D,"linkAccount","onError",m.privyErrorCode||"unknown_auth_error"),m}},async linkWithPasskey(){if(!n)throw new Dr;if(!(t.authFlow instanceof Jo))throw new P("Must initialize Passkey flow first.");if(J.current!=="passkey")throw new P("Must init login with Passkey flow first.");let d;try{J.current="passkey",{user:d}=await t.link()}catch(p){throw U(D,"linkAccount","onError",p.privyErrorCode||"failed_to_link_account"),p}return c(d||s||null),d},async initLoginWithHeadlessOAuth(d,p){if(bc()){if(d==="google"&&fc(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.")}else throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let m=new Ur({provider:d,headless:!0});p&&m.addCaptchaToken(p);let C=await t.startAuthFlow(m).getAuthorizationUrl();C?.url&&window.location.assign(C.url)},async loginWithHeadlessOAuth(d){b(!0),t.startAuthFlow(new Ur(d));let p=Z.get($o),m=d.stateCode;if(p!==m)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:d.provider,storedStateCode:p??"",returnedStateCode:m??""}}),b(!1),new P("Unexpected auth flow. This may be a phishing attempt.");let C,T;if(a)try{({user:C}=await t.link()),J.current=d.provider}catch(H){throw U(D,"linkAccount","onError",H.privyErrorCode||"failed_to_link_account"),H}else try{({user:C,isNewUser:T}=await t.authenticate()),J.current=d.provider}catch(H){throw ee.current==="login"?U(D,"login","onError",H.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",H.privyErrorCode||"failed_to_link_account"),H}return c(C),v(T||!1),l(!0),b(!1),C??void 0},initLoginWithEmail:async(d,p)=>{let m=new go(d,p);t.startAuthFlow(m);try{J.current="email",await m.sendCodeEmail()}catch(C){throw ee.current==="login"?U(D,"login","onError",C.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",C.privyErrorCode||"failed_to_link_account"),C}},initUpdateEmail:async(d,p,m)=>{let C=new $a(d,p,m);t.startAuthFlow(C),await C.sendCodeEmail()},initLoginWithSms:async(d,p)=>{I({status:"sending-code"});let m=new Xo(d,p);t.startAuthFlow(m);try{J.current="sms",await m.sendSmsCode(),I({status:"awaiting-code-input"})}catch(C){throw I({status:"error",error:C}),ee.current==="login"?U(D,"login","onError",C.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",C.privyErrorCode||"failed_to_link_account"),C}},resendEmailCode:async()=>{await t.authFlow?.sendCodeEmail()},resendSmsCode:async()=>{await t.authFlow?.sendSmsCode()},loginWithCode:async d=>{if(I({status:"submitting-code"}),!n){let T=new Dr;throw I({status:"error",error:T}),T}if(t.authFlow instanceof go)t.authFlow.meta.emailCode=d.trim();else if(t.authFlow instanceof Xo)t.authFlow.meta.smsCode=d.trim();else{let T=new P("Must initialize a passwordless code flow first");throw I({status:"error",error:T}),T}let p=await Ee(),m,C;if(p&&t.sessionHasActiveToken())try{({user:m}=await t.link())}catch(T){throw I({status:"error",error:T}),U(D,"linkAccount","onError",T.privyErrorCode||"failed_to_link_account"),T}else try{({user:m,isNewUser:C}=await t.authenticate())}catch(T){throw I({status:"error",error:T}),U(D,"login","onError",T.privyErrorCode||"unknown_auth_error"),T}c(m||s||null),v(C||!1),l(!0),I({status:"done"})},refreshUser:async()=>{let d=await t.getAuthenticatedUser();return c(d),d},walletProxy:W,createAnalyticsEvent:({eventName:d,payload:p,timestamp:m})=>t.createAnalyticsEvent({eventName:d,payload:p,timestamp:m}),acceptTerms:async()=>{let d=await t.acceptTerms();return c(d),d},getUsdTokenPrice:d=>t.getUsdTokenPrice(d),recoverEmbeddedWallet:async()=>new Promise(async(d,p)=>{let m=s?.linkedAccounts.find(T=>T.type==="wallet"&&T.walletClientType==="privy"),C=await Ee();if(!C||!W||!m){p(new Error("Must have valid access token and Privy wallet to recover wallet"));return}pe(!0);try{await W.connect({accessToken:C,address:m.address}),d(!0)}catch(T){if(Xn(T)&&m.recoveryMethod==="privy")t.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:m.address}}),(await W.recover({address:m.address,accessToken:C})).address||p(new Error("Unable to recover wallet")),t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:m.address}}),d(!0);else if(Xn(T)&&m.recoveryMethod!=="privy"){X({recoverWallet:{privyWallet:m,onFailure:p,onSuccess:()=>d(!0)},recoveryOAuthStatus:{provider:m.recoveryMethod,action:"recover"}});let H=pl(m.recoveryMethod);ge(H)}else p(T)}}),getFiatOnRampConfig:Cr,setReadyToTrue:d=>{i(!0),bt?.(d)},updateWallets:()=>Vo(),fundWallet:async(d,p)=>{let{signedUrl:m,externalTransactionId:C}=await Cr(d,p);X({fiatOnRampPrompt:{signedUrl:m},fiatOnRampStatus:{externalTransactionId:C}}),ge("FIAT_ON_RAMP_PROMPT_SCREEN")},requestFarcasterSignerStatus:async d=>{let p=await Ee(),m=s?.linkedAccounts.find(T=>T.type==="wallet"&&T.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!W||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");let C=await t.requestFarcasterSignerStatus(d);if(C.status==="approved"){let T=await t.getAuthenticatedUser();c(T||s||null)}return C}}))();c2=me.recoverEmbeddedWallet;let f2=J8(()=>({wallets:u,ready:ir&&Ho}),[u,ir,Ho]);return vr(ve.Provider,{value:Pn,children:vr(zc.Provider,{value:D,children:vr(lp.Provider,{value:f2,children:i2(Fm,{...L,children:[e.children,i2(Vc.Provider,{value:me,children:[!L.headless&&L.captchaEnabled&&n&&!a&&vr(Gc,{delayedExecution:!1}),vr(jg,{theme:{...L.appearance.palette||{}}}),vr(Mm,{data:we,setModalData:X,setInitialScreen:k,initialScreen:g,authenticated:a,open:r,children:vr(Qg,{open:r})}),de&&ae?vr(o2,{appId:e.appId,clientAnalyticsId:t.clientAnalyticsId,origin:t.apiUrl,mfaMethods:s?.mfaMethods,mfaPromise:Rt,mfaSubmitPromise:Ge,onLoad:V,onLoadFailed:()=>null}):null,L.loginMethods.telegram&&L.loginConfig.telegramAuthConfiguration&&vr(_r,{if:!0,children:vr(e2,{scriptHost:e.apiUrl||Ri,botUsername:L.loginConfig.telegramAuthConfiguration.botName})})]})]})})})})};import{useContext as rE}from"react";function oE(e){let{login:t}=rE(ve);return He("login",e),{login:t}}import{useContext as nE}from"react";function iE(e){let{logout:t}=nE(ve);return He("logout",e),{logout:t}}import{useCallback as d2,useEffect as aE}from"react";function sE(){let e=he(),t=Bs(),{initLoginWithHeadlessOAuth:r,loginWithHeadlessOAuth:o,isHeadlessOAuthLoading:n,ready:i,user:a}=F(),l=d2(async c=>{if(e.enabled&&e.status!=="success")throw new Tr(e.error,null,"captcha_failure");return r(c.provider,e.token)},[r,e]),s=d2(async()=>{let c=Ni();if(a)return console.warn("Cannot login with OAuth when already logged in"),a;if(!c.inProgress)throw new Error("Cannot login with OAuth because no OAuth flow is in progress");if(!c.popupFlow)try{return await o(c)}catch(u){throw u}finally{Zo()}},[o]);return aE(()=>{let c=Ni();i&&t&&c.inProgress&&c.headless&&!c.popupFlow&&s()},[i,t]),{initOAuth:l,loginWithOAuth:s,loading:n}}import{useCallback as p2}from"react";var lE=()=>{let e=he(),{initLoginWithEmail:t,loginWithCode:r}=F(),o=p2(async({email:i})=>{if(!i)throw new Error("Email required to send OTP code");return t(i)},[t]),n=p2(async({code:i})=>{if(e.enabled&&e.status==="error")throw new Tr(e.error,null,"captcha_failure");return r(i)},[r,e.status]);return{sendCode:o,loginWithCode:n}};import{useCallback as u2}from"react";var cE=()=>{let e=he(),{initLoginWithSms:t,loginWithCode:r,otpState:o}=F(),n=u2(async({phoneNumber:a})=>{if(!a)throw new Error("SMS required to send OTP code");return t(a)},[t]),i=u2(async({code:a})=>{if(e.enabled&&e.status!=="success")throw new Tr(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:n,loginWithCode:i,state:o}};import{useContext as dE}from"react";function pE(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:i,linkTwitter:a,linkDiscord:l,linkGithub:s,linkLinkedIn:c,linkTiktok:u,linkSpotify:h,linkInstagram:f,linkTelegram:y,linkFarcaster:v}=dE(ve);return He("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:i,linkTwitter:a,linkDiscord:l,linkGithub:s,linkLinkedIn:c,linkTiktok:u,linkSpotify:h,linkInstagram:f,linkFarcaster:v,linkTelegram:y}}import{useContext as uE}from"react";function mE(e){let{connectWallet:t}=uE(ve);return He("connectWallet",e),{connectWallet:t}}import{useContext as fE}from"react";function hE(e){let{createWallet:t}=fE(ve);return He("createWallet",e),{createWallet:t}}var yE=()=>{let{fundWallet:e}=F();return{fundWallet:e}};import{useContext as gE}from"react";function vE(e){let{sendTransaction:t}=gE(ve);return He("sendTransaction",e),{sendTransaction:t}}import{useContext as CE}from"react";function wE(e){let{setWalletPassword:t}=CE(ve);return He("setWalletPassword",e),{setWalletPassword:t}}import{useContext as bE}from"react";function EE(e){let{signMessage:t}=bE(ve);return He("signMessage",e),{signMessage:t}}import{useContext as TE}from"react";function PE(e){let{signTypedData:t}=TE(ve);return He("signTypedData",e),{signTypedData:t}}import{useContext as SE}from"react";var _E=()=>{let{isModalOpen:e}=SE(ve);return{isOpen:e}};import{useContext as xE}from"react";function kE(e){let{getAccessToken:t}=xE(ve);return He("accessToken",e),{getAccessToken:t}}function AE(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=F();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}}function RE(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}export{Fr as AsExternalProvider,Gc as Captcha,qi as ConnectorManager,$i as PrivyClient,eE as PrivyProvider,Oe as PrivyProxyProvider,Vi as SUPPORTED_CHAINS,Pc as VERSION,Lt as WalletConnector,RE as addRpcUrlOverrideToChain,ud as errorIndicatesMaxMfaRetries,ln as errorIndicatesMfaTimeout,cn as errorIndicatesMfaVerificationFailed,Ee as getAccessToken,mE as useConnectWallet,hE as useCreateWallet,AE as useExperimentalFarcasterSigner,yE as useFundWallet,pE as useLinkAccount,oE as useLogin,lE as useLoginWithEmail,sE as useLoginWithOAuth,cE as useLoginWithSms,iE as useLogout,Ca as useMfa,Wr as useMfaEnrollment,_E as useModalStatus,F as usePrivy,qc as useRegisterMfaListener,vE as useSendTransaction,wE as useSetWalletPassword,EE as useSignMessage,PE as useSignTypedData,kE as useToken,Ra as useWallets};
|
|
3035
|
+
`;import{jsx as ut,jsxs as Jg}from"react/jsx-runtime";var Ob={["LANDING"]:Ry,["CONNECT_OR_CREATE"]:ky,["AWAITING_PASSWORDLESS_CODE"]:uf,["AWAITING_CONNECTION"]:Of,["AWAITING_CONNECT_ONLY_CONNECTION"]:Ff,["AWAITING_FARCASTER_CONNECTION"]:Gh,["AWAITING_FARCASTER_SIGNER"]:jh,["AWAITING_PASSKEY_SYSTEM_DIALOGUE"]:og,["PHANTOM_INTERSTITIAL_SCREEN"]:sg,["LOGIN_FAILED_SCREEN"]:zy,["AWAITING_OAUTH_SCREEN"]:eg,["ALLOWLIST_REJECTION_SCREEN"]:tf,["USER_LIMIT_REACHED_SCREEN"]:$g,["INSTALL_PHANTOM_SCREEN"]:ly,["LINK_EMAIL_SCREEN"]:Iy,["LINK_PHONE_SCREEN"]:Fy,["LINK_WALLET_SCREEN"]:By,["LINK_PASSKEY_SCREEN"]:Dy,["UPDATE_EMAIL_SCREEN"]:Vg,["CONNECT_ONLY_LANDING_SCREEN"]:Rf,["CONNECT_ONLY_AUTHENTICATED_SCREEN"]:xf,["EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN"]:th,["EMBEDDED_WALLET_CREATED_SCREEN"]:jf,["EMBEDDED_WALLET_CONNECTING_SCREEN"]:$f,["EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN"]:lg,["EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN"]:Cg,["EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN"]:yg,["EMBEDDED_WALLET_KEY_EXPORT_SCREEN"]:Qf,["EMBEDDED_WALLET_SIGN_REQUEST_SCREEN"]:Wg,["EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN"]:Ig,["FIAT_ON_RAMP_PROMPT_SCREEN"]:ey,["FIAT_ON_RAMP_STATUS_SCREEN"]:ry,["EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN"]:xh,["EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN"]:_h,["EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN"]:vg,["MFA_ENROLLMENT_FLOW_SCREEN"]:s1,["CAPTCHA_SCREEN"]:yf,["ERROR_SCREEN"]:Ah,["IN_APP_BROWSER_LOGIN_NOT_POSSIBLE"]:oy,["AFFIRMATIVE_CONSENT_SCREEN"]:Qm,["TELEGRAM_AUTH_SCREEN"]:Ug},Nb=["LANDING","AWAITING_CONNECTION"],Db=({isMfaVerifying:e,onMfaVerificationComplete:t})=>{let{ready:r,isModalOpen:o}=F(),{headless:n}=Nt(),{ready:i,currentScreen:a}=x(),{status:l,execute:s,reset:c,enabled:u}=he(),h=Mb(null),f=Hm(h),y=o&&a&&Nb.includes(a)&&!n&&l==="ready";if(Zg(()=>{y&&s()},[y]),Zg(()=>{!o&&u&&c()},[o,u]),(!r||!i)&&a!=="AWAITING_OAUTH_SCREEN")return Jg(ui,{id:"privy-modal-content",children:[ut(S,{}),ut(Q,{}),ut(Qy,{children:ut(tt,{})}),ut(re,{}),ut(z,{})]});if(!a&&e)return ut(ui,{style:{height:f},id:"privy-modal-conent",children:ut("div",{ref:h,children:ut(dp,{open:e,onClose:t})})});if(!a)return null;let v=Ob[a];return ut(ui,{style:{height:f},id:"privy-modal-content",children:Jg("div",{ref:h,children:[ut(_r,{if:!!e,children:ut(v,{})}),ut(_r,{if:!e,children:ut(dp,{open:e,onClose:t})})]})})},Ub=()=>{let{closePrivyModal:e}=M(),{onUserCloseViaDialogOrKeybindRef:t}=x();return{gracefulClosePrivyModal:Ib(()=>{if(t?.current)t.current();else return e({shouldCallAuthOnSuccess:!1})},[e])}},Qg=({open:e})=>{let{app:t}=x(),{gracefulClosePrivyModal:r}=Ub(),[o,n]=Wb(!1);qc({onMfaRequired:()=>{t?.mfa.noPromptOnMfaRequired||n(!0)}});let i=ut(Yg,{children:ut(Db,{isMfaVerifying:o,onMfaVerificationComplete:()=>n(!1)})}),a=e||o,l=t?.render.inDialog?ut(Jy,{open:a,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:i}):i;if(typeof window<"u"&&t?.render.inParentNodeId){let s=document.getElementById(t.render.inParentNodeId);if(s)return Lb.createPortal(l,s)}return l};import{useRef as Xg,useEffect as Fb}from"react";import{jsx as Hb}from"react/jsx-runtime";function Bb({botUsername:e,scriptHost:t}){let r=document.createElement("script"),{origin:o}=new URL(t);return r.async=!0,r.src=`${o}/js/telegram-login.js`,r.setAttribute("data-telegram-login",e),r.setAttribute("data-request-access","write"),r.setAttribute("data-lang","en"),r}function e2(e){let t=Xg(null),r=Xg();return Fb(()=>{r.current?.remove(),r.current=Bb(e),t.current?.after(r.current)},[e]),Hb("div",{ref:t,hidden:!0})}import{useState as Gb}from"react";import{useEffect as t2,useRef as r2}from"react";var mc=class{constructor(){this.callbacks={}}enqueue(t,r){this.callbacks[t]=r}dequeue(t,r){let o=this.callbacks[r];if(!o)throw new Error(`cannot dequeue ${t} event: no event found for id ${r}`);switch(delete this.callbacks[r],t){case"privy:iframe:ready":return o;case"privy:wallet:create":return o;case"privy:wallet:import":return o;case"privy:wallet:connect":return o;case"privy:wallet:recover":return o;case"privy:wallet:rpc":return o;case"privy:wallet:set-recovery-password":return o;case"privy:mfa:verify":return o;case"privy:mfa:init-enrollment":return o;case"privy:mfa:submit-enrollment":return o;case"privy:mfa:unenroll":return o;case"privy:mfa:clear":return o;case"privy:farcaster:init-signer":return o;case"privy:farcaster:sign":return o;default:throw new Error(`invalid wallet event type ${t}`)}}};async function Bo(e,t,r,o,n,i=!1){let a=i,l=async u=>{if(a&&t&&t.length>0){u===(i?0:1)?n("configureMfa","onMfaRequired",t):o.current?.reject(new De("missing_or_invalid_mfa","MFA verification failed, retry."));let h=await new Promise((f,y)=>{r.current={resolve:f,reject:y};let v=1e3*60*5;setTimeout(()=>{let g=new De("mfa_timeout","Timed out waiting for MFA code");o.current?.reject(g),y(g)},v)});return await e(h)}return await e()},s=4,c=null;for(let u=0;u<s;u++)try{c=await l(u),o.current?.resolve(void 0);break}catch(h){if(h.type==="missing_or_invalid_mfa")a=!0;else throw o.current?.resolve(void 0),h}if(c===null){let u=new De("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw o.current?.reject(u),u}return c}import{jsx as jb}from"react/jsx-runtime";var Vb=function(e){return()=>`id-${e++}`}(0);function zb(e){return typeof e.event=="string"&&/^privy:.+/.test(e.event)}function Vt(e){return e.error!==void 0}var kt=new mc,Cp=new Map,qb=(e,t)=>typeof t=="bigint"?t.toString():t,$b=(e,t)=>`${e}${JSON.stringify(t,qb)}`;function zt(e,t,r,o){let n=r.contentWindow;if(!n)throw new Error("iframe not initialized");let i=$b(e,t);if(e==="privy:wallet:create"){let l=Cp.get(i);if(l)return l}let a=new Promise((l,s)=>{let c=Vb();kt.enqueue(c,{resolve:l,reject:s}),n.postMessage({id:c,event:e,data:t},o)}).finally(()=>{Cp.delete(i)});return Cp.set(i,a),a}function Kb(e){switch(e.event){case"privy:iframe:ready":let t=kt.dequeue(e.event,e.id);return Vt(e)?t.reject(new De(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallet:create":let r=kt.dequeue(e.event,e.id);return Vt(e)?r.reject(new De(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallet:import":let o=kt.dequeue(e.event,e.id);return Vt(e)?o.reject(new De(e.error.type,e.error.message)):o.resolve(e.data);case"privy:wallet:connect":let n=kt.dequeue(e.event,e.id);return Vt(e)?n.reject(new De(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallet:recover":let i=kt.dequeue(e.event,e.id);return Vt(e)?i.reject(new De(e.error.type,e.error.message)):i.resolve(e.data);case"privy:wallet:rpc":let a=kt.dequeue(e.event,e.id);return Vt(e)?a.reject(new De(e.error.type,e.error.message)):a.resolve(e.data);case"privy:wallet:set-recovery-password":let l=kt.dequeue(e.event,e.id);return Vt(e)?l.reject(new De(e.error.type,e.error.message)):l.resolve(e.data);case"privy:mfa:verify":let s=kt.dequeue(e.event,e.id);return Vt(e)?s.reject(new De(e.error.type,e.error.message)):s.resolve(e.data);case"privy:mfa:init-enrollment":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:mfa:submit-enrollment":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:mfa:unenroll":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:mfa:clear":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:farcaster:init-signer":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}case"privy:farcaster:sign":{let c=kt.dequeue(e.event,e.id);return Vt(e)?c.reject(new De(e.error.type,e.error.message)):c.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}function o2(e){let t=r2(null),r=r2(e.mfaMethods),o=zs(),[n,i]=Gb(!1);return t2(()=>{r.current=e.mfaMethods},[e.mfaMethods]),t2(()=>{if(!n)return;let a=t.current;if(!a)return;function l(f){f&&f.origin===e.origin&&zb(f.data)&&Kb(f.data)}let s={create(f){return zt("privy:wallet:create",f,a,e.origin)},import(f){return zt("privy:wallet:import",f,a,e.origin)},connect(f){return zt("privy:wallet:connect",f,a,e.origin)},recover(f){return Bo(y=>zt("privy:wallet:recover",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},rpc(f){return Bo(y=>zt("privy:wallet:rpc",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},setRecoveryPassword(f){return Bo(y=>zt("privy:wallet:set-recovery-password",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},verifyMfa(f){return Bo(y=>zt("privy:mfa:verify",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},initEnrollMfa(f){return Bo(y=>zt("privy:mfa:init-enrollment",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},submitEnrollMfa(f){return Bo(y=>zt("privy:mfa:submit-enrollment",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o)},unenrollMfa(f){return Bo(y=>zt("privy:mfa:unenroll",{...f,...y},a,e.origin),r.current,e.mfaPromise,e.mfaSubmitPromise,o,!0)},clearMfa(f){return zt("privy:mfa:clear",f,a,e.origin)},initFarcasterSigner(f){return zt("privy:farcaster:init-signer",f,a,e.origin)},signFarcasterMessage(f){return zt("privy:farcaster:sign",f,a,e.origin)}};window.addEventListener("message",l);let c=()=>e.onLoad(s),u=(...f)=>{console.warn("Privy iframe failed to load: ",...f),e.onLoadFailed()},h=new AbortController;return ki(()=>zt("privy:iframe:ready",{},a,e.origin),{abortSignal:h.signal}).then(c,u),()=>{window.removeEventListener("message",l),h.abort()}},[n]),jb("iframe",{ref:t,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>i(!0),src:Ja(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId})})}function fc(e){let t=e.toLowerCase();return["fbav","fban","instagram","snapchat"].some(o=>t.includes(o))}var Yb="https://cdn.apple-cloudkit.com";async function wp({url:e,popup:t,provider:r}){return t.location=e,new Promise((n,i)=>{function a(){t?.close(),window.removeEventListener("message",l)}function l(s){s.data&&(s.data.type==="PRIVY_OAUTH_RESPONSE"&&s.data.stateCode&&s.data.authorizationCode&&(n(s.data),a()),s.origin===Yb&&s.data.ckSession&&(n({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:s.data.ckSession}),a()),s.data.type==="PRIVY_OAUTH_ERROR"&&(i(s.data.error),a()))}window.addEventListener("message",l)})}var n2=e=>({id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type});import{jsx as vr,jsxs as i2}from"react/jsx-runtime";var ho;function Qb(e){return typeof e=="string"&&e.length===25}function Ee(){if(!ho){let e=Z.get(qo);return Promise.resolve(e||null)}return ho.getAccessToken()}var a2,Zu=(e,t,r)=>a2(e,t,r),s2,Ju=(e,t)=>s2(e,t),l2,Qu=(e,t)=>l2(e,t),c2,Xu=()=>c2(),Xb=()=>{let t=new URLSearchParams(window.location.search).get("privy_token");if(!t)return;Z.put(Ii,t);let r=new URL(window.location.href);r.searchParams.delete("privy_token"),window.history.pushState({},"",r)},eE=({config:e,...t})=>{if(!Qb(t.appId))throw new P("Cannot initialize the Privy provider with an invalid Privy app ID");ho||(ho=new $i({appId:t.appId,apiUrl:t.apiUrl||Ri}));let r=Object.assign({},e);return t.createPrivyWalletOnLogin!==void 0&&r.embeddedWallets?.createOnLogin===void 0&&(r.embeddedWallets||(r.embeddedWallets={}),r.embeddedWallets.createOnLogin=t.createPrivyWalletOnLogin?"users-without-wallets":"off"),t.createPrivyWalletOnLogin!==void 0&&e?.embeddedWallets?.createOnLogin&&console.warn("Both `createPrivyWalletOnLogin` and `config.embeddedWallets.createOnLogin` are set. `createPrivyWalletOnLogin` is deprecated and should be removed."),vr(Rm,{client:ho,clientConfig:r,legacyCreateEmbeddedWalletFlag:t.createPrivyWalletOnLogin,children:vr(tE,{...t,client:ho})})},tE=e=>{let t=e.client,[r,o]=je(!1),[n,i]=je(!1),[a,l]=je(!1),[s,c]=je(null),[u,h]=je([]),f=_i(u),[y,v]=je(!1),[g,k]=je(null),[w,b]=je(!1),[_,A]=je({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:E}),[N,I]=je({status:"initial"}),[R,B]=je(null),[K,Y]=je(null),[W,V]=je(null),L=Nt(),ae=Bs(),[de,pe]=je(!0),[we,X]=je({}),[bt,Ye]=je(null),[At,Xe]=je(null),[ir,Re]=je(!1),[qe,ar]=je(!1),Rt=_i(null),Ge=_i(null),D=_i(Gm),[Ho,be]=je(!1);t.onStoreToken=d=>{d&&U(D,"accessToken","onAccessTokenGranted",d)},t.onDeleteToken=()=>{c(null),l(!1),U(D,"accessToken","onAccessTokenRemoved")};let J=_i(null),ee=_i(null),ge=d=>{k(d),setTimeout(()=>{o(!0)},15),t.createAnalyticsEvent({eventName:"modal_open",payload:{initialScreen:d}})},Ue=d=>{L.embeddedWallets.createOnLogin!=="off"&&pe(!0),ge(d)};Nr(()=>{let d=()=>{document.visibilityState==="hidden"&&t.createAnalyticsEvent({eventName:"page_hidden",options:{keepAlive:!0}})};return document.addEventListener("visibilitychange",d),()=>{document.removeEventListener("visibilitychange",d)}},[]),Nr(()=>{if(!s){t.connectors?.removeEmbeddedWalletConnector();return}let d=Ie(s),p=Mc(s);if(d||t.connectors?.removeEmbeddedWalletConnector(),p||t.connectors?.removeImportedWalletConnector(),!t.connectors){console.debug("Failed to add embedded wallet connector: Client connectors not initialized");return}if(!W){console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized");return}d&&t.connectors.addEmbeddedWalletConnector(W,d.address,L.defaultChain,e.appId),p&&t.connectors.addImportedWalletConnector(W,p.address,L.defaultChain,e.appId)},[W,s]),Nr(()=>{W&&At?.(W)},[W]),Nr(()=>{(async()=>{if(!L.customAuth?.enabled)return;pe(!0);let{getCustomAccessToken:p,isLoading:m}=L.customAuth;if(!(!n||m))try{let C=await p();if(!C&&a){await Pn.logout();return}if(!C||a)return;t.startAuthFlow(new Sn(C));let{user:T,isNewUser:H}=await t.authenticate();if(!T){await Pn.logout();return}c(T||null),v(H||!1),l(!0),ar(!0)}catch(C){console.warn(C),a&&await Pn.logout()}})()},[L.customAuth?.enabled,L.customAuth?.getCustomAccessToken,L.customAuth?.isLoading,n,a]),Nr(()=>{qe&&W&&s&&Wt(s,L.embeddedWallets.createOnLogin)&&(ar(!1),Da(s,xn).catch(console.error))},[qe&&W&&s]),Nr(()=>{async function d(){let p=hc();Xb();let m=Zb();B(m),t.initializeConnectorManager({walletConnectCloudProjectId:L.walletConnectCloudProjectId,rpcConfig:L.rpcConfig,chains:L.chains,defaultChain:L.defaultChain,store:m,walletList:L.appearance.walletList,shouldEnforceDefaultChainOnConnect:L.shouldEnforceDefaultChainOnConnect,externalWalletConfig:L.externalWallets,appName:L.name??"Privy"});let C;t.connectors?.on("connectorInitialized",()=>{C&&clearTimeout(C);let H=t.connectors.walletConnectors.length,G=t.connectors.walletConnectors.reduce((fe,$e)=>fe+($e.initialized?1:0),0);G===H?be(!0):C=setTimeout(()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:G,expected:H}),be(!0)},1500)}),t.connectors?.initialize().then(()=>{yc()});let T=await t.getAuthenticatedUser();L.customAuth?.enabled||(l(!!T),T&&U(D,"login","onComplete",T,!1,!0,null,null),c(T)),p||me.setReadyToTrue(!!T),p&&(T?ee.current="link":ee.current="login")}!n&&ae&&d()},[t,bt,n,ae]),Nr(()=>{if(!n)return;if(!s){Re(!0);return}if(!!!s.linkedAccounts.find(m=>m.type==="wallet"&&m.walletClientType==="privy")){Re(!0);return}let p=!!u.find(m=>m.walletClientType==="privy");Re(p)},[n,s,u]);let hc=()=>{let d=Ni();if(d.inProgress&&d.popupFlow){if(window.opener.location.origin!==window.location.origin){window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."});return}window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:d.stateCode,authorizationCode:d.authorizationCode});return}return!d.inProgress||d.headless?!1:(t.startAuthFlow(new Ur(d)),Ue("AWAITING_OAUTH_SCREEN"),!0)},En=async(d,p,m,C)=>{let T=await t.connectors?.createWalletConnector(d,p)||null;Tn(T,p,m,C)};async function Tn(d,p,m,C){if(d)A({status:"disconnected",connectedWallet:null,connectError:null,connector:d,connectRetry:E});else return A({status:"disconnected",connectedWallet:null,connectError:new te("Unable to connect to wallet."),connector:null,connectRetry:E}),C?.(null,m);d instanceof Gr&&p&&await d.resetConnection(p),A({connector:d,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Tn(d,p,m,C)});try{let T=await d.connect({showPrompt:!0});if(L.shouldEnforceDefaultChainOnConnect&&!L.chains.find(H=>H.id===Number(T?.chainId))&&!(T?.connectorType==="wallet_connect_v2"&&T?.walletClientType==="metamask")&&!(T?.connectorType==="coinbase_wallet"&&L.externalWallets.coinbaseWallet.connectionOptions!=="eoaOnly")){A(H=>({...H,connector:d,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:E}));try{await T?.switchChain(L.defaultChain.id),T&&(T.chainId=_n(zo(L.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${L.defaultChain.id}`)}}return A(H=>({...H,status:"connected",connectedWallet:T,connectError:null,connectRetry:E})),T&&U(D,"connectWallet","onSuccess",T),C?.(T,m)}catch(T){return T instanceof ze?(console.warn(T.cause?T.cause:T.message),U(D,"connectWallet","onError",T.privyErrorCode||"generic_connect_wallet_error")):(console.warn(T),U(D,"connectWallet","onError","unknown_connect_wallet_error")),A(H=>({...H,status:"disconnected",connectedWallet:null,connectError:T})),C?.(null,m)}}let Go=async(d,p)=>{if(d===null)return;let m=new Qo(d,p);t.startAuthFlow(m)},yc=()=>{let d=new URLSearchParams(window.location.search),p=d.get("privy_connector"),m=d.get("privy_wallet_client");if(!p||!m)return;if(m==="phantom"&&!vo()&&Ue("LOGIN_FAILED_SCREEN"),!t.connectors)throw new P("Connector not initialized");ge("AWAITING_CONNECTION");let C=new URL(window.location.href);C.searchParams.delete("privy_connector"),C.searchParams.delete("privy_wallet_client"),window.history.pushState({},"",C),En(p,m,void 0,Go)};Nr(()=>{n&&a&&s===null&&t.getAuthenticatedUser().then(c)},[n,a,s,t]);let Ve=()=>{if(!a)throw U(D,"linkAccount","onError","must_be_authenticated"),new P("User must be authenticated before linking an account.")},yo=()=>{Ve(),J.current="siwe",ee.current="link",ge("LINK_WALLET_SCREEN")},Ze=d=>{if(!a||!s)return!1;if(d.walletClientType==="privy")return!0;for(let p of s.linkedAccounts)if(p.type==="wallet"&&p.address===d.address&&p.walletClientType!=="privy")return!0;return!1},qt=async d=>{if(!t.connectors)throw new P("Connector not initialized");let p=t.connectors.findWalletConnector(d.connectorType,d.walletClientType)||null;if(A(m=>({...m,connector:p,status:"connected",connectedWallet:d,connectError:null,connectRetry:E})),L.captchaEnabled&&!a){let m={callback:C=>Go(d,C),userIntentRequired:!1,onSuccessNavigateTo:"AWAITING_CONNECTION",onErrorNavigateTo:"ERROR_SCREEN"};X({captchaModalData:m}),Ue("CAPTCHA_SCREEN")}else await Go(d),Ue("AWAITING_CONNECTION")},Cr=async(d,p)=>{if(!L.fiatOnRamp.enabled)throw new P("Fiat on-ramp is not enabled");if(!p||!p.provider||p.provider==="moonpay"){let{signedUrl:m,externalTransactionId:C}=await Qh(t,d,p?.config??{},L.appearance.palette,L.fiatOnRamp.useSandbox);return{signedUrl:m,externalTransactionId:C}}else throw new P("Unsupported fund provider. Currently supported option is `moonpay`.")},Vo=()=>{h(d=>{let p=t.connectors?.wallets.map(m=>({...m,linked:Ze(m),loginOrLink:async()=>{if(!await m.isConnected())throw new P("Wallet is not connected");if(m.connectorType==="embedded"&&m.walletClientType==="privy")throw new P("Cannot link or login with embedded wallet");qt(m)},fund:async C=>{let{signedUrl:T,externalTransactionId:H}=await Cr(m.address,C);X({fiatOnRampPrompt:{signedUrl:T},fiatOnRampStatus:{externalTransactionId:H}}),ge("FIAT_ON_RAMP_PROMPT_SCREEN")},unlink:async()=>{if(!a)throw new P("User is not authenticated.");if(m.connectorType==="embedded"&&m.walletClientType==="privy")throw new P("Cannot unlink an embedded wallet");let C=await t.unlinkWallet(m.address);c(C)}}))||[];return ws(d,p)?d:p})};Nr(()=>{Vo()},[s?.linkedAccounts,a,n]),Nr(()=>{if(n){if(!t.connectors)throw new P("Connector not initialized");Vo(),t.connectors.on("walletsUpdated",Vo)}},[n]);let to=()=>{ge(a?"CONNECT_ONLY_AUTHENTICATED_SCREEN":"CONNECT_ONLY_LANDING_SCREEN")};Nr(()=>{if(!u[0])return;let d=u[0],p=f.current.find(C=>C.address===d.address),m;if(d.walletClientType==="privy"?m=s?.linkedAccounts.find(C=>C.type==="wallet"&&C.address===d.address&&C.walletClientType==="privy"):m=s?.linkedAccounts.find(C=>C.type==="wallet"&&C.address===d.address&&C.walletClientType!=="privy"),!p&&m){let C=Object.assign({},s);C.wallet=m&&{address:m.address,chainType:m.chainType,chainId:m.chainId,walletClient:m.walletClient,walletClientType:m.walletClientType,connectorType:m.connectorType,imported:m.imported},c(C)}f.current=u},[u]);let Da=async(d,p)=>{if(Ie(d))throw U(D,"createWallet","onError","embedded_wallet_already_exists"),new Error("Only one Privy wallet per user is currently allowed");let[C,T]=await Promise.all([me.initializeWalletProxy(p),Ee()]);if(!C&&L.customAuth?.enabled)throw U(D,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to connect to wallet proxy");if(!C||!T||L.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return new Promise((H,G)=>{pe(!0),X({createWallet:{onSuccess:$e=>{U(D,"createWallet","onSuccess",$e),H($e)},onFailure:$e=>{U(D,"createWallet","onError","unknown_embedded_wallet_error"),G($e)},callAuthOnSuccessOnClose:!1}}),ge("EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN")});{await C.create({accessToken:T});let H=await me.refreshUser(),G=Ie(H);if(!G)throw U(D,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");return U(D,"createWallet","onSuccess",G),G}},m2=d=>{if(!L.chains.map(p=>p.id).includes(d))throw new te(`Chain ID ${d} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,"unsupported_chain_id")},Ep=(d,p,m)=>new Promise(async(C,T)=>{if(!a||!s){U(D,"sendTransaction","onError","must_be_authenticated"),T(new Error("User must be authenticated before signing with a Privy wallet"));return}let H=d.from,G=H?s?.linkedAccounts.find(Se=>Se.type==="wallet"&&Se.walletClientType==="privy"&&Se.address===H):Ie(s);if(!G){U(D,"sendTransaction","onError","embedded_wallet_not_found"),T(new Error("Must have a Privy wallet before signing"));return}pe(!0);let fe=t.connectors?.findWalletConnector("embedded","privy")?.proxyProvider,$e=d.chainId?Number(d.chainId):fe.chainId;m2($e);let mt=Object.assign({},d,{chainId:$e}),sr=async()=>{let Se=await Ee();if(!Se||!W){U(D,"sendTransaction","onError","embedded_wallet_not_found"),T(new Error("Must have valid access token and Privy wallet to send transaction"));return}try{if(!await me.recoverEmbeddedWallet()){U(D,"sendTransaction","onError","unknown_connect_wallet_error"),T(new Error("Unable to connect to wallet"));return}let wr=ro(mt.chainId,L.chains,L.rpcConfig,{appId:e.appId}),gc=await wi(G.address,mt,wr);if(L.embeddedWallets.noPromptOnSignature){let{totalGasEstimate:h2}=await Ci(gc,wr),{hasSufficientFunds:y2}=await Xl(G.address,gc,h2,wr);if(!y2)throw new Be(new jt("Wallet has insufficient funds for this transaction.",st.E32603_DEFAULT_INTERNAL_ERROR.eipCode))}let Pp=await Ql(Se,G.address,W,gc,wr);U(D,"sendTransaction","onSuccess",Pp),C(Pp)}catch(Ua){U(D,"sendTransaction","onError","transaction_failure"),T(Ua)}};if(L.embeddedWallets.noPromptOnSignature)p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config"),sr();else{let Se={transactionRequest:mt,onSuccess:wr=>{U(D,"sendTransaction","onSuccess",wr),C(wr)},onFailure:wr=>{U(D,"sendTransaction","onError","transaction_failure"),T(wr)},uiOptions:p||{},fundWalletConfig:m},Ua={onCompleteNavigateTo:"EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN",onFailure:wr=>{U(D,"sendTransaction","onError","unknown_connect_wallet_error"),T(wr)}};X({connectWallet:Ua,sendTransaction:Se}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}});function Tp(){return new Promise(async(d,p)=>{let m=await Ee();if(!m||!W)throw new Error("Must have valid access token to enroll in MFA");try{await W.verifyMfa({accessToken:m}),d()}catch(C){p(C)}})}let It=d=>{if(d==="passkey"){if(s&&s.linkedAccounts.filter(p=>p.type==="passkey").length>=5)throw U(D,"linkAccount","onError","cannot_link_more_of_type"),new P(`User already has an account of type ${d} linked.`)}else if(s?.[d])throw U(D,"linkAccount","onError","cannot_link_more_of_type"),new P(`User already has an account of type ${d} linked.`)},Pn={ready:n,authenticated:a,user:s,walletConnectors:t.connectors||null,connectWallet:to,importWallet:async({privateKey:d})=>{Ve();let[p,m]=await Promise.all([me.initializeWalletProxy(15e3),Ee()]);if(p&&m){await p.import({privateKey:d,accessToken:m});let C=await me.refreshUser(),T=Mc(C);if(!T)throw U(D,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to import wallet");return U(D,"createWallet","onSuccess",T),T}else throw new P("User is not authenticated")},linkWallet:yo,linkEmail:()=>{Ve(),It("email"),J.current="email",ee.current="link",ge("LINK_EMAIL_SCREEN")},linkPhone:()=>{Ve(),It("phone"),J.current="sms",ee.current="link",ge("LINK_PHONE_SCREEN")},linkGoogle:async()=>{Ve(),It("google"),ee.current="link",await me.initLoginWithOAuth("google")},linkTwitter:async()=>{Ve(),It("twitter"),ee.current="link",await me.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Ve(),It("discord"),ee.current="link",await me.initLoginWithOAuth("discord")},linkGithub:async()=>{Ve(),It("github"),ee.current="link",await me.initLoginWithOAuth("github")},linkSpotify:async()=>{Ve(),It("spotify"),ee.current="link",await me.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Ve(),It("instagram"),ee.current="link",await me.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Ve(),It("tiktok"),ee.current="link",await me.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Ve(),It("linkedin"),ee.current="link",await me.initLoginWithOAuth("linkedin")},linkApple:async()=>{Ve(),It("apple"),ee.current="link",await me.initLoginWithOAuth("apple")},linkPasskey:async()=>{Ve(),It("passkey"),await me.initLinkWithPasskey(),ge("LINK_PASSKEY_SCREEN")},linkTelegram:async()=>{Ve(),It("telegram"),ee.current="link",J.current="telegram",await me.initLoginWithTelegram(),ge("TELEGRAM_AUTH_SCREEN")},linkFarcaster:async()=>{Ve(),It("farcaster"),await me.initLoginWithFarcaster(),ee.current="link",J.current="farcaster",ge("AWAITING_FARCASTER_CONNECTION")},updateEmail:()=>{if(Ve(),!s?.email)throw new P("User does not have an email linked to their account.");ee.current="link",J.current="email",ge("UPDATE_EMAIL_SCREEN")},login:async()=>{let d="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!n){let p=await new Promise(m=>{Ye(C=>m.bind(C))});if(Ye(null),p){console.warn(d);return}}if(a){console.warn(d);return}ee.current="login",Ue("LANDING")},connectOrCreateWallet:async()=>{if(n||(await new Promise(d=>{Ye(()=>d)}),Ye(null)),a){console.warn("User must be unauthenticated to `connectOrCreateWallet`");return}if(u[0]){console.warn("User must have no connected wallets to `connectOrCreateWallet`");return}Ue("CONNECT_OR_CREATE")},logout:async()=>{if(await t.logout(),s&&W)try{await W.clearMfa({userId:s.id})}catch{}c(null),l(!1),k(null),U(D,"logout","onSuccess"),ee.current=null,J.current=null,o(!1),Z.del(Mi)},getAccessToken:()=>t.getAccessToken(),getEthereumProvider:()=>{if(!s||!s.wallet)return new Oe;let d=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(C=>C.address===d?.address));return!d||!p?new Oe:p.proxyProvider},getEthersProvider:()=>{if(!s||!s.wallet)return new bp(new Fr(new Oe));let d=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(C=>C.address===d?.address));return!d||!p?new bp(new Fr(new Oe)):new bp(new Fr(p.proxyProvider))},getWeb3jsProvider:()=>{if(!s||!s.wallet)return new bo(new Oe);let d=u.find(m=>s.wallet&&m.address===s.wallet.address),p=t.connectors?.walletConnectors.find(m=>m.wallets.find(C=>C.address===d?.address));return!d||!p?new bo(new Oe):new bo(p.proxyProvider)},unlinkWallet:async d=>{let p=await t.unlinkWallet(d);return c(p),p},unlinkEmail:async d=>{let p=await t.unlinkEmail(d);return c(p),p},unlinkPhone:async d=>{let p=await t.unlinkPhone(d);return c(p),p},unlinkGoogle:async d=>{let p=await t.unlinkOAuth("google",d);return c(p),p},unlinkTwitter:async d=>{let p=await t.unlinkOAuth("twitter",d);return c(p),p},unlinkDiscord:async d=>{let p=await t.unlinkOAuth("discord",d);return c(p),p},unlinkGithub:async d=>{let p=await t.unlinkOAuth("github",d);return c(p),p},unlinkSpotify:async d=>{let p=await t.unlinkOAuth("spotify",d);return c(p),p},unlinkInstagram:async d=>{let p=await t.unlinkOAuth("instagram",d);return c(p),p},unlinkTiktok:async d=>{let p=await t.unlinkOAuth("tiktok",d);return c(p),p},unlinkLinkedIn:async d=>{let p=await t.unlinkOAuth("linkedin",d);return c(p),p},unlinkApple:async d=>{let p=await t.unlinkOAuth("apple",d);return c(p),p},unlinkFarcaster:async d=>{let p=await t.unlinkFarcaster(d);return c(p),p},unlinkTelegram:async d=>{let p=await t.unlinkTelegram(d);return c(p),p},unlinkPasskey:async d=>{let p=await t.unlinkPasskey(d);return c(p),p},setActiveWallet:async d=>{let p=u.find(C=>Si(C.address)===Si(d)),m=s?.linkedAccounts.find(C=>C.type==="wallet"&&Si(C.address)===Si(d));if(!p||!await p.isConnected())Y(d),yo();else if(!p.linked)p.loginOrLink();else{let C=Object.assign({},s);C.wallet=m&&{address:m.address,chainType:m.chainType,chainId:m.chainId,walletClient:m.walletClient,walletClientType:m.walletClientType,connectorType:m.connectorType,imported:m.imported},c(C)}},forkSession:()=>t.forkSession(),createWallet:async()=>{if(!a||!s)throw U(D,"createWallet","onError","must_be_authenticated"),new Error("User must be authenticated before creating a Privy wallet");return Da(s,15e3)},setWalletPassword:async()=>{if(!a||!s)throw U(D,"setWalletPassword","onError","must_be_authenticated"),new Error("User must be authenticated before adding password to Privy wallet");let d=Ie(s);if(!d||!W)throw U(D,"setWalletPassword","onError","embedded_wallet_not_found"),new Error("Must have a Privy wallet to add a password");if(["google-drive","icloud"].includes(d.recoveryMethod))throw U(D,"setWalletPassword","onError","embedded_wallet_recovery_already_exists"),new Error("Cannot set password. Embedded wallet is set to recover using a cloud provider.");try{await Tp()}catch(p){throw U(D,"setWalletPassword","onError","missing_or_invalid_mfa"),p}return new Promise((p,m)=>{pe(!0);let C={onSuccess:G=>{U(D,"setWalletPassword","onSuccess",G),p(G)},onFailure:G=>{U(D,"setWalletPassword","onError","user_exited_set_password_flow"),m(G)},callAuthOnSuccessOnClose:!1},H={onCompleteNavigateTo:d.recoveryMethod==="user-passcode"?"EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN":"EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN",onFailure:G=>{U(D,"setWalletPassword","onError","unknown_connect_wallet_error"),m(G)}};X({setWalletPassword:C,createWallet:C,connectWallet:H}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")})},signMessage:(d,p,m)=>new Promise(async(C,T)=>{if(!a||!s){U(D,"signMessage","onError","must_be_authenticated"),T(new Error("User must be authenticated before signing with a Privy wallet"));return}let H=m?s?.linkedAccounts.find(fe=>fe.type==="wallet"&&fe.walletClientType==="privy"&&Si(fe.address)===Si(m)):Ie(s);if(!H){U(D,"signMessage","onError","embedded_wallet_not_found"),T(new Error("Must have a Privy wallet before signing"));return}if(typeof d!="string"||d.length<1){U(D,"signMessage","onError","invalid_message"),T(new Error("Message must be a non-empty string"));return}pe(!0);let G=async()=>{if(!a)throw new Error("User must be authenticated before signing with a Privy wallet");let fe=await Ee();if(!W||!fe)throw new Error("Unable to connect to wallet");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:H.address}});let{response:mt}=await W.rpc({accessToken:fe,address:H.address,request:{method:"personal_sign",params:[d,H.address]}}),sr=mt.data;return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:H.address}}),sr};if(L.embeddedWallets.noPromptOnSignature){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let fe=await G();U(D,"signMessage","onSuccess",fe),C(fe)}catch(fe){U(D,"signMessage","onError","unable_to_sign"),T(fe??new Be("Unable to sign message"))}}else{let mt={method:"personal_sign",data:d,confirmAndSign:G,onSuccess:Se=>{U(D,"signMessage","onSuccess",Se),C(Se)},onFailure:Se=>{U(D,"signMessage","onError","unable_to_sign"),T(Se)},uiOptions:p||{}},sr={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Se=>{U(D,"signMessage","onError","unknown_connect_wallet_error"),T(Se)},address:H.address};X({signMessage:mt,connectWallet:sr}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),signTypedData:(d,p)=>new Promise(async(m,C)=>{if(!a||!s){U(D,"signTypedData","onError","must_be_authenticated"),C(new Error("User must be authenticated before signing with a Privy wallet"));return}let T=Ie(s);if(!T){U(D,"signTypedData","onError","embedded_wallet_not_found"),C(new Error("Must have a Privy wallet before signing"));return}pe(!0);let H=Qa(d),G=async()=>{if(!a)throw new Error("User must be authenticated before signing with a Privy wallet");let fe=await Ee();if(!W||!fe)throw new Error("Unable to connect to wallet");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:T.address}});let{response:mt}=await W.rpc({accessToken:fe,address:T.address,request:{method:"eth_signTypedData_v4",params:[T.address,H]}}),sr=mt.data;return t.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:T.address}}),sr};if(L.embeddedWallets.noPromptOnSignature||(L.legacyWalletUiConfig??!1)){p&&console.warn("uiOptions defined with `noPromptOnSignature` set to true in app config");try{let fe=await G();U(D,"signTypedData","onSuccess",fe),m(fe)}catch(fe){U(D,"signTypedData","onError","unable_to_sign"),C(fe??new Be("Unable to sign message"))}}else{let mt={method:"eth_signTypedData_v4",data:H,confirmAndSign:G,onSuccess:Se=>{U(D,"signTypedData","onSuccess",Se),m(Se)},onFailure:Se=>{U(D,"signTypedData","onError","unable_to_sign"),C(Se)},uiOptions:p||{}},sr={onCompleteNavigateTo:"EMBEDDED_WALLET_SIGN_REQUEST_SCREEN",onFailure:Se=>{U(D,"signMessage","onError","unknown_connect_wallet_error"),C(Se)}};X({signMessage:mt,connectWallet:sr}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}}),sendTransaction:async(d,p,m)=>{let T=await(await Ep(d,p,m)).wait();return ec(T)},exportWallet:()=>new Promise(async(d,p)=>{if(!a||!s){p(new Error("User must be authenticated before exporting their Privy wallet"));return}if(!Ie(s)){p(new Error("Must have a Privy wallet before exporting"));return}pe(!0);let C={onCompleteNavigateTo:"EMBEDDED_WALLET_KEY_EXPORT_SCREEN",onFailure:p,shouldForceMFA:!0};if(X(we),!await Ee()||!W){p(new Error("Must have valid access token to enroll in MFA"));return}if(!W){p(new Error("Must have a Privy wallet before exporting"));return}let H={appId:e.appId,origin:t.apiUrl,onSuccess:d,onFailure:p};X({keyExport:H,connectWallet:C}),ge("EMBEDDED_WALLET_CONNECTING_SCREEN")}),promptMfa:Tp,async init(d){switch(d){case"sms":await t.initMfaSmsVerification();return;case"passkey":return await t.initMfaPasskeyVerification();case"totp":return;default:throw new Error(`Unsupported MFA method: ${d}`)}},async submit(d,p){switch(d){case"totp":case"sms":if(typeof p!="string")throw new P("Invalid MFA code");Rt.current?.resolve({mfaMethod:d,mfaCode:p,relyingParty:window.origin}),await new Promise((H,G)=>{Ge.current={resolve:H,reject:G}});break;case"passkey":if(typeof p=="string")throw new P("Invalid authenticator response");let C=await(await import("@simplewebauthn/browser")).startAuthentication(p),T=n2(C);Rt.current?.resolve({mfaMethod:d,mfaCode:T,relyingParty:window.origin}),await new Promise((H,G)=>{Ge.current={resolve:H,reject:G}});break;default:throw Rt.current?.reject(new P("Unsupported MFA method")),new P(`Unsupported MFA method: ${d}`)}},cancel(){Rt.current?.reject(new P("MFA canceled"))},async initEnrollmentWithSms(d){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to enroll in MFA");await W.initEnrollMfa({method:"sms",accessToken:p,phoneNumber:d.phoneNumber})},enrollInMfa(d){return new Promise((p,m)=>{if(!d){me.closePrivyModal(),p();return}L.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),X({mfaEnrollmentFlow:{mfaMethods:L.mfa.methods,onSuccess:p,onFailure:m}}),ge("MFA_ENROLLMENT_FLOW_SCREEN")})},async initEnrollmentWithTotp(){let d=await Ee();if(!d||!W)throw new Error("Must have valid access token to enroll in MFA");let p=await W.initEnrollMfa({method:"totp",accessToken:d});return{secret:p.secret,authUrl:p.authUrl}},async submitEnrollmentWithSms(d){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to enroll in MFA");await W.submitEnrollMfa({method:"sms",accessToken:p,phoneNumber:d.phoneNumber,code:d.mfaCode});let m=await t.getAuthenticatedUser();c(m)},async submitEnrollmentWithTotp(d){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to enroll in MFA");await W.submitEnrollMfa({method:"totp",accessToken:p,code:d.mfaCode});let m=await t.getAuthenticatedUser();c(m)},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:d}){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to enroll in MFA");await W.submitEnrollMfa({method:"passkey",accessToken:p,credentialIds:d});let m=await t.getAuthenticatedUser();c(m)},async unenroll(d){let p=await Ee();if(!p||!W)throw new Error("Must have valid access token to remove MFA");d==="passkey"?await W.submitEnrollMfa({method:"passkey",accessToken:p,credentialIds:[]}):await W.unenrollMfa({method:d,accessToken:p});let m=await t.getAuthenticatedUser();c(m)},requestFarcasterSignerFromWarpcast:async()=>{let d=await Ee(),p=s?.linkedAccounts.find(T=>T.type==="wallet"&&T.walletClientType==="privy");if(!d)throw new Error("Must have valid access token to connect with Farcaster");if(!W||!p)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");let C=await W.initFarcasterSigner({address:p.address,hdWalletIndex:null,accessToken:d,mfaCode:null,mfaMethod:null,relyingParty:window.origin});if(C.status==="approved"){let T=await t.getAuthenticatedUser();c(T||s||null)}X({farcasterSigner:C}),ge("AWAITING_FARCASTER_SIGNER")},getFarcasterSignerPublicKey:async()=>{let d=await Ee(),p=s?.linkedAccounts.find(T=>T.type==="wallet"&&T.walletClientType==="privy");if(!d)throw new Error("Must have valid access token to connect with Farcaster");if(!W||!p)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");if(!s.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster signer public key to sign");return(T=>Uint8Array.from(T.match(/.{1,2}/g).map(H=>parseInt(H,16))))(s.farcaster.signerPublicKey.slice(2))},signFarcasterMessage:async d=>{let p=await Ee(),m=s?.linkedAccounts.find(G=>G.type==="wallet"&&G.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!W||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");if(!await me.recoverEmbeddedWallet())throw new Error("Unable to connect to wallet");if(!s.farcaster?.signerPublicKey)throw new Error("Must have a Farcaster signer public key to sign");let T=await import("@simplewebauthn/browser"),H=await W.signFarcasterMessage({address:m.address,hdWalletIndex:null,accessToken:p,mfaCode:null,mfaMethod:null,payload:{hash:T.bufferToBase64URLString(d)},fid:BigInt(s.farcaster.fid),relyingParty:window.origin});return new Uint8Array(T.base64URLStringToBuffer(H.signature))},isHeadlessOAuthLoading:w,loginWithCode(d){return me.loginWithCode(d)},initLoginWithEmail(d){return me.initLoginWithEmail(d)},initLoginWithSms(d){return me.initLoginWithSms(d)},otpState:N,fundWallet(d,p){return me.fundWallet(d,p)},initLoginWithHeadlessOAuth(d,p){return me.initLoginWithHeadlessOAuth(d,p)},loginWithHeadlessOAuth(d){return me.loginWithHeadlessOAuth(d)},isModalOpen:r,mfaMethods:L.mfa.methods};a2=Pn.signMessage,s2=Pn.signTypedData,l2=async(...d)=>{let p=await Ep(...d);return L.embeddedWallets.waitForTransactionConfirmation&&await p.wait(),p};let me=(()=>({isNewUserThisSession:y,linkingHint:K,pendingTransaction:null,walletConnectionStatus:_,mipdStore:R,connectors:t.connectors?.walletConnectors??[],rpcConfig:L.rpcConfig,chains:L.chains,appId:e.appId,showFiatPrices:L.embeddedWallets.priceDisplay.primary!=="native-token",clientAnalyticsId:t.clientAnalyticsId,nativeTokenSymbolForChainId:d=>L.chains.find(p=>p.id===Number(d))?.nativeCurrency.symbol,initializeWalletProxy:async d=>{if(W)return W;let p=new Promise(T=>{Xe(()=>H=>T(H))}),m=new Promise(T=>setTimeout(()=>T(null),d)),C=await Promise.race([p,m]);return Xe(null),C},getAuthFlow:()=>t.authFlow,getAuthMeta:()=>t.authFlow?.meta,closePrivyModal:(d={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let p=n&&a&&s,m;p&&J.current&&(m=s?.linkedAccounts.filter(C=>C.latestVerifiedAt!==null&&!(C.type==="wallet"&&C.walletClientType==="privy")).sort((C,T)=>T.latestVerifiedAt.getTime()-C.latestVerifiedAt.getTime())[0]),ee.current==="login"&&J.current?d.shouldCallAuthOnSuccess&&p?(U(D,"login","onComplete",s,y,!1,J.current,m??null),e.onSuccess?.(s,y)):U(D,"login","onError","exited_auth_flow"):ee.current==="link"&&J.current&&m&&(d.isSuccess&&p?U(D,"linkAccount","onSuccess",s,J.current,m):U(D,"linkAccount","onError","exited_link_flow")),Y(null),ee.current=null,J.current=null,v(!1),o(!1),setTimeout(()=>{t.authFlow=void 0},200),t.createAnalyticsEvent({eventName:"modal_closed"})},openPrivyModal:ge,connectWallet:Tn,initLoginWithWallet:async(d,p)=>{J.current="siwe",Go(d,p)},loginWithWallet:async()=>{if(!n)throw new Dr;if(!(t.authFlow instanceof Qo))throw new P("Must initialize SIWE flow first.");let d,p;if(a)try{({user:d}=await t.link()),J.current="siwe"}catch(m){throw U(D,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{({user:d,isNewUser:p}=await t.authenticate()),J.current="siwe"}catch(m){throw U(D,"login","onError",m.privyErrorCode||"generic_connect_wallet_error"),m}c(d||s||null),v(p||!1),l(!0)},initLoginWithFarcaster:async d=>{let p=new Ai(d);t.startAuthFlow(p);try{J.current="farcaster",await p.initializeFarcasterConnect()}catch(m){throw ee.current==="login"?U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",m.privyErrorCode||"unknown_auth_error"),m}},loginWithFarcaster:async()=>{if(!n)throw new Dr;if(!(t.authFlow instanceof Ai))throw new P("Must initialize Farcaster flow first.");let d,p;if(a)try{({user:d}=await t.link()),J.current="farcaster"}catch(m){throw U(D,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{({user:d,isNewUser:p}=await t.authenticate()),J.current="farcaster"}catch(m){throw U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}c(d||null),v(p||!1),l(!0)},async initLoginWithOAuth(d,p){if(J.current=d,bc()){if(d==="google"&&fc(window.navigator.userAgent)){Ue("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}}else{Ue("IN_APP_BROWSER_LOGIN_NOT_POSSIBLE");return}Z.del(jo);let m=new Ur({provider:d});p&&m.addCaptchaToken(p),t.startAuthFlow(m);let C=await t.authFlow.getAuthorizationUrl();C&&C.url&&window.location.assign(C.url)},async initLoginWithTelegram(d){if(!n)throw new Dr;J.current="telegram";let p=new Di(d);t.startAuthFlow(p),t.authFlow.meta.telegramAuthResult=await new Promise((m,C)=>{if(!L.loginConfig.telegramAuthConfiguration)return C("Telegram Auth configuration is not loaded");if(!window.Telegram)return C("Telegram was not initialized");window.Telegram.Login.auth({bot_id:L.loginConfig.telegramAuthConfiguration.botId,request_access:!0},T=>T?m(T):C("Telegram auth failed or was canceled by the client"))})},async loginWithTelegram(){if(!n)throw new Dr;if(!(t.authFlow instanceof Di))throw new P("Must initialize Telegram flow before calling loginWithTelegram");let d,p;if(a)try{({user:d}=await t.link()),J.current="telegram"}catch(m){throw U(D,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}else try{let m=await t.authenticate();d=m.user,p=m.isNewUser,J.current="telegram"}catch(m){throw ee.current==="login"?U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",m.privyErrorCode||"failed_to_link_account"),m}c(d),v(p||!1),l(!0)},async recoveryOAuthFlow(d,p,m){let C,T;function H(G){if(!G)throw t.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:d}}),new P("Recovery OAuth failed")}switch(d){case"google-drive":{let{url:G,codeVerifier:fe,stateCode:$e}=await md({api:ho.api,provider:d});H(G);let mt,sr;try{let Se=await wp({url:G,popup:m,provider:d});if(mt=Se.stateCode,sr=Se.authorizationCode,mt!==$e)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:d,storedStateCode:$e??"",returnedStateCode:mt??""}}),new P("Unexpected auth flow. This may be a phishing attempt.")}catch(Se){throw t.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:Se.toString(),provider:d}}),new P("Recovery OAuth failed")}[C,T]=await Promise.all([Ee(),Vf({api:ho.api,provider:d,codeVerifier:fe,stateCode:mt,authorizationCode:sr})]);break}case"icloud":{let{url:G}=await md({api:ho.api,provider:d});H(G);let{ckWebAuthToken:fe}=await wp({url:G,popup:m,provider:d});T=fe,C=await Ee();break}}if(!W)throw new P("Cannot connect to wallet proxy");switch(p){case"recover":let G=we.recoverWallet?.privyWallet?.address;if(!G)throw new P("Recovery OAuth failed");t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:G,recoveryMethod:d}}),await W.recover({address:G,accessToken:C,recoveryAccessToken:T,recoveryMethod:d}),t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:G,recoveryMethod:d}});break;case"create-wallet":t.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await W.create({accessToken:C,recoveryAccessToken:T,recoveryMethod:d});let fe=await me.refreshUser(),$e=Ie(fe);if(!$e)throw U(D,"createWallet","onError","unknown_embedded_wallet_error"),new Error("Failed to create wallet");t.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:$e.address}}),U(D,"createWallet","onSuccess",$e);break;default:throw new P("Unsupported recovery action")}},async loginWithOAuth(d){if(!(t.authFlow instanceof Ur))throw new P("Must initialize OAuth flow before calling loginWithOAuth");let p=Z.get($o),m=t.authFlow.meta.stateCode;if(p!==m)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:d,storedStateCode:p??"",returnedStateCode:m??""}}),new P("Unexpected auth flow. This may be a phishing attempt.");let C,T,H;if(a)try{let G=await t.link();C=G.user,H=G.oAuthProviderTokens,J.current=d}catch(G){throw U(D,"linkAccount","onError",G.privyErrorCode||"failed_to_link_account"),G}else try{let G=await t.authenticate();C=G.user,T=G.isNewUser,H=G.oAuthProviderTokens,J.current=d}catch(G){throw ee.current==="login"?U(D,"login","onError",G.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",G.privyErrorCode||"failed_to_link_account"),G}return c(C),v(T||!1),l(!0),H},async initLoginWithPasskey(d){let p=new Jo(d);t.startAuthFlow(p),ee.current="login";try{J.current="passkey",await p.initAuthenticationFlow()}catch(m){throw U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}},async loginWithPasskey(){if(!n)throw new Dr;if(!(t.authFlow instanceof Jo))throw new P("Must initialize Passkey flow first.");if(J.current!=="passkey")throw new P("Must init login with Passkey flow first.");let d,p;try{J.current="passkey",{user:d,isNewUser:p}=await t.authenticate()}catch(m){throw U(D,"login","onError",m.privyErrorCode||"unknown_auth_error"),m}c(d),v(p||!1),l(!0)},async initLinkWithPasskey(d){let p=new Jo(d);t.startAuthFlow(p),ee.current="link",J.current="passkey";try{await p.initLinkFlow()}catch(m){throw U(D,"linkAccount","onError",m.privyErrorCode||"unknown_auth_error"),m}},async linkWithPasskey(){if(!n)throw new Dr;if(!(t.authFlow instanceof Jo))throw new P("Must initialize Passkey flow first.");if(J.current!=="passkey")throw new P("Must init login with Passkey flow first.");let d;try{J.current="passkey",{user:d}=await t.link()}catch(p){throw U(D,"linkAccount","onError",p.privyErrorCode||"failed_to_link_account"),p}return c(d||s||null),d},async initLoginWithHeadlessOAuth(d,p){if(bc()){if(d==="google"&&fc(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.")}else throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let m=new Ur({provider:d,headless:!0});p&&m.addCaptchaToken(p);let C=await t.startAuthFlow(m).getAuthorizationUrl();C?.url&&window.location.assign(C.url)},async loginWithHeadlessOAuth(d){b(!0),t.startAuthFlow(new Ur(d));let p=Z.get($o),m=d.stateCode;if(p!==m)throw t.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:d.provider,storedStateCode:p??"",returnedStateCode:m??""}}),b(!1),new P("Unexpected auth flow. This may be a phishing attempt.");let C,T;if(a)try{({user:C}=await t.link()),J.current=d.provider}catch(H){throw U(D,"linkAccount","onError",H.privyErrorCode||"failed_to_link_account"),H}else try{({user:C,isNewUser:T}=await t.authenticate()),J.current=d.provider}catch(H){throw ee.current==="login"?U(D,"login","onError",H.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",H.privyErrorCode||"failed_to_link_account"),H}return c(C),v(T||!1),l(!0),b(!1),C??void 0},initLoginWithEmail:async(d,p)=>{let m=new go(d,p);t.startAuthFlow(m);try{J.current="email",await m.sendCodeEmail()}catch(C){throw ee.current==="login"?U(D,"login","onError",C.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",C.privyErrorCode||"failed_to_link_account"),C}},initUpdateEmail:async(d,p,m)=>{let C=new $a(d,p,m);t.startAuthFlow(C),await C.sendCodeEmail()},initLoginWithSms:async(d,p)=>{I({status:"sending-code"});let m=new Xo(d,p);t.startAuthFlow(m);try{J.current="sms",await m.sendSmsCode(),I({status:"awaiting-code-input"})}catch(C){throw I({status:"error",error:C}),ee.current==="login"?U(D,"login","onError",C.privyErrorCode||"unknown_auth_error"):ee.current==="link"&&U(D,"linkAccount","onError",C.privyErrorCode||"failed_to_link_account"),C}},resendEmailCode:async()=>{await t.authFlow?.sendCodeEmail()},resendSmsCode:async()=>{await t.authFlow?.sendSmsCode()},loginWithCode:async d=>{if(I({status:"submitting-code"}),!n){let T=new Dr;throw I({status:"error",error:T}),T}if(t.authFlow instanceof go)t.authFlow.meta.emailCode=d.trim();else if(t.authFlow instanceof Xo)t.authFlow.meta.smsCode=d.trim();else{let T=new P("Must initialize a passwordless code flow first");throw I({status:"error",error:T}),T}let p=await Ee(),m,C;if(p&&t.sessionHasActiveToken())try{({user:m}=await t.link())}catch(T){throw I({status:"error",error:T}),U(D,"linkAccount","onError",T.privyErrorCode||"failed_to_link_account"),T}else try{({user:m,isNewUser:C}=await t.authenticate())}catch(T){throw I({status:"error",error:T}),U(D,"login","onError",T.privyErrorCode||"unknown_auth_error"),T}c(m||s||null),v(C||!1),l(!0),I({status:"done"})},refreshUser:async()=>{let d=await t.getAuthenticatedUser();return c(d),d},walletProxy:W,createAnalyticsEvent:({eventName:d,payload:p,timestamp:m})=>t.createAnalyticsEvent({eventName:d,payload:p,timestamp:m}),acceptTerms:async()=>{let d=await t.acceptTerms();return c(d),d},getUsdTokenPrice:d=>t.getUsdTokenPrice(d),recoverEmbeddedWallet:async()=>new Promise(async(d,p)=>{let m=s?.linkedAccounts.find(T=>T.type==="wallet"&&T.walletClientType==="privy"),C=await Ee();if(!C||!W||!m){p(new Error("Must have valid access token and Privy wallet to recover wallet"));return}pe(!0);try{await W.connect({accessToken:C,address:m.address}),d(!0)}catch(T){if(Xn(T)&&m.recoveryMethod==="privy")t.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:m.address}}),(await W.recover({address:m.address,accessToken:C})).address||p(new Error("Unable to recover wallet")),t.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:m.address}}),d(!0);else if(Xn(T)&&m.recoveryMethod!=="privy"){X({recoverWallet:{privyWallet:m,onFailure:p,onSuccess:()=>d(!0)},recoveryOAuthStatus:{provider:m.recoveryMethod,action:"recover"}});let H=pl(m.recoveryMethod);ge(H)}else p(T)}}),getFiatOnRampConfig:Cr,setReadyToTrue:d=>{i(!0),bt?.(d)},updateWallets:()=>Vo(),fundWallet:async(d,p)=>{let{signedUrl:m,externalTransactionId:C}=await Cr(d,p);X({fiatOnRampPrompt:{signedUrl:m},fiatOnRampStatus:{externalTransactionId:C}}),ge("FIAT_ON_RAMP_PROMPT_SCREEN")},requestFarcasterSignerStatus:async d=>{let p=await Ee(),m=s?.linkedAccounts.find(T=>T.type==="wallet"&&T.walletClientType==="privy");if(!p)throw new Error("Must have valid access token to connect with Farcaster");if(!W||!m)throw new Error("Must have an embedded wallet to use Farcaster signers");if(!s?.farcaster?.fid)throw new Error("Must have Farcaster account to use Farcaster signers");let C=await t.requestFarcasterSignerStatus(d);if(C.status==="approved"){let T=await t.getAuthenticatedUser();c(T||s||null)}return C}}))();c2=me.recoverEmbeddedWallet;let f2=Jb(()=>({wallets:u,ready:ir&&Ho}),[u,ir,Ho]);return vr(ve.Provider,{value:Pn,children:vr(zc.Provider,{value:D,children:vr(lp.Provider,{value:f2,children:i2(Fm,{...L,children:[e.children,i2(Vc.Provider,{value:me,children:[!L.headless&&L.captchaEnabled&&n&&!a&&vr(Gc,{delayedExecution:!1}),vr(jg,{theme:{...L.appearance.palette||{}}}),vr(Mm,{data:we,setModalData:X,setInitialScreen:k,initialScreen:g,authenticated:a,open:r,children:vr(Qg,{open:r})}),de&&ae?vr(o2,{appId:e.appId,clientAnalyticsId:t.clientAnalyticsId,origin:t.apiUrl,mfaMethods:s?.mfaMethods,mfaPromise:Rt,mfaSubmitPromise:Ge,onLoad:V,onLoadFailed:()=>null}):null,L.loginMethods.telegram&&L.loginConfig.telegramAuthConfiguration&&vr(_r,{if:!0,children:vr(e2,{scriptHost:e.apiUrl||Ri,botUsername:L.loginConfig.telegramAuthConfiguration.botName})})]})]})})})})};import{useContext as rE}from"react";function oE(e){let{login:t}=rE(ve);return He("login",e),{login:t}}import{useContext as nE}from"react";function iE(e){let{logout:t}=nE(ve);return He("logout",e),{logout:t}}import{useCallback as d2,useEffect as aE}from"react";function sE(){let e=he(),t=Bs(),{initLoginWithHeadlessOAuth:r,loginWithHeadlessOAuth:o,isHeadlessOAuthLoading:n,ready:i,user:a}=F(),l=d2(async c=>{if(e.enabled&&e.status!=="success")throw new Tr(e.error,null,"captcha_failure");return r(c.provider,e.token)},[r,e]),s=d2(async()=>{let c=Ni();if(a)return console.warn("Cannot login with OAuth when already logged in"),a;if(!c.inProgress)throw new Error("Cannot login with OAuth because no OAuth flow is in progress");if(!c.popupFlow)try{return await o(c)}catch(u){throw u}finally{Zo()}},[o]);return aE(()=>{let c=Ni();i&&t&&c.inProgress&&c.headless&&!c.popupFlow&&s()},[i,t]),{initOAuth:l,loginWithOAuth:s,loading:n}}import{useCallback as p2}from"react";var lE=()=>{let e=he(),{initLoginWithEmail:t,loginWithCode:r}=F(),o=p2(async({email:i})=>{if(!i)throw new Error("Email required to send OTP code");return t(i)},[t]),n=p2(async({code:i})=>{if(e.enabled&&e.status==="error")throw new Tr(e.error,null,"captcha_failure");return r(i)},[r,e.status]);return{sendCode:o,loginWithCode:n}};import{useCallback as u2}from"react";var cE=()=>{let e=he(),{initLoginWithSms:t,loginWithCode:r,otpState:o}=F(),n=u2(async({phoneNumber:a})=>{if(!a)throw new Error("SMS required to send OTP code");return t(a)},[t]),i=u2(async({code:a})=>{if(e.enabled&&e.status!=="success")throw new Tr(e.error,null,"captcha_failure");return r(a)},[r,e.status]);return{sendCode:n,loginWithCode:i,state:o}};import{useContext as dE}from"react";function pE(e){let{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:i,linkTwitter:a,linkDiscord:l,linkGithub:s,linkLinkedIn:c,linkTiktok:u,linkSpotify:h,linkInstagram:f,linkTelegram:y,linkFarcaster:v}=dE(ve);return He("linkAccount",e),{linkEmail:t,linkPhone:r,linkWallet:o,linkGoogle:n,linkApple:i,linkTwitter:a,linkDiscord:l,linkGithub:s,linkLinkedIn:c,linkTiktok:u,linkSpotify:h,linkInstagram:f,linkFarcaster:v,linkTelegram:y}}import{useContext as uE}from"react";function mE(e){let{connectWallet:t}=uE(ve);return He("connectWallet",e),{connectWallet:t}}import{useContext as fE}from"react";function hE(e){let{createWallet:t}=fE(ve);return He("createWallet",e),{createWallet:t}}var yE=()=>{let{fundWallet:e}=F();return{fundWallet:e}};import{useContext as gE}from"react";function vE(e){let{sendTransaction:t}=gE(ve);return He("sendTransaction",e),{sendTransaction:t}}import{useContext as CE}from"react";function wE(e){let{setWalletPassword:t}=CE(ve);return He("setWalletPassword",e),{setWalletPassword:t}}import{useContext as bE}from"react";function EE(e){let{signMessage:t}=bE(ve);return He("signMessage",e),{signMessage:t}}import{useContext as TE}from"react";function PE(e){let{signTypedData:t}=TE(ve);return He("signTypedData",e),{signTypedData:t}}import{useContext as SE}from"react";var _E=()=>{let{isModalOpen:e}=SE(ve);return{isOpen:e}};import{useContext as xE}from"react";function kE(e){let{getAccessToken:t}=xE(ve);return He("accessToken",e),{getAccessToken:t}}function AE(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=F();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}}function RE(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}export{Fr as AsExternalProvider,Gc as Captcha,qi as ConnectorManager,$i as PrivyClient,eE as PrivyProvider,Oe as PrivyProxyProvider,Vi as SUPPORTED_CHAINS,Pc as VERSION,Lt as WalletConnector,RE as addRpcUrlOverrideToChain,ud as errorIndicatesMaxMfaRetries,ln as errorIndicatesMfaTimeout,cn as errorIndicatesMfaVerificationFailed,Ee as getAccessToken,mE as useConnectWallet,hE as useCreateWallet,AE as useExperimentalFarcasterSigner,yE as useFundWallet,pE as useLinkAccount,oE as useLogin,lE as useLoginWithEmail,sE as useLoginWithOAuth,cE as useLoginWithSms,iE as useLogout,Ca as useMfa,Wr as useMfaEnrollment,_E as useModalStatus,F as usePrivy,qc as useRegisterMfaListener,vE as useSendTransaction,wE as useSetWalletPassword,EE as useSignMessage,PE as useSignTypedData,kE as useToken,Ra as useWallets};
|