@privy-io/react-auth 2.6.3 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/abstract-smart-wallets.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{privy-provider-CWADob3g.js → privy-provider-B-yAVEso.js} +2 -2
- package/dist/cjs/{smart-wallets-Dsq1trqs.js → smart-wallets-BUp0Opq4.js} +1 -1
- package/dist/cjs/smart-wallets.js +1 -1
- package/dist/cjs/solana.js +1 -1
- package/dist/cjs/ui.js +1 -1
- package/dist/cjs/{useActiveWallet-D5FyaqZJ.js → useActiveWallet-CsKkB2nL.js} +1 -1
- package/dist/cjs/{useFundWallet-BsBuslJV.js → useFundWallet-C-vF194x.js} +1 -1
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{privy-provider-u_cmfixS.mjs → privy-provider-DSQ8FU83.mjs} +2 -2
- package/dist/esm/{smart-wallets-vK26EMrU.mjs → smart-wallets-CjIUBWJS.mjs} +1 -1
- package/dist/esm/smart-wallets.mjs +1 -1
- package/dist/esm/solana.mjs +1 -1
- package/dist/esm/ui.mjs +1 -1
- package/dist/esm/{useActiveWallet-Cwj5v4eK.mjs → useActiveWallet-D0FziaS7.mjs} +1 -1
- package/dist/esm/{useFundWallet-BPk4tVPS.mjs → useFundWallet-DGsbN-n3.mjs} +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createStore as r}from"mipd";import a,{useRef as i,useState as o,useMemo as s,useContext as l,createContext as c,useEffect as d,useCallback as p,useReducer as h,forwardRef as u}from"react";import*as m from"react-device-detect";import{isMobile as g,isIOS as y,isSafari as f,isAndroid as w}from"react-device-detect";import{getAddress as v,toHex as b,isAddress as C}from"viem/utils";import{a as k,c as x,f as T,p as A,b as I,d as _,e as E,g as S,h as N,i as M,j as P,k as W,o as O,P as U,l as L,m as R,q as F,r as D,s as z,t as B,v as $,w as j,x as V,y as H,z as q,A as K,B as Z,n as G,C as Y,D as J,E as X,u as Q,F as ee,G as te,H as ne,J as re,K as ae,L as ie,M as oe,N as se,O as le,Q as ce,R as de,S as pe,T as he,U as ue,V as me,W as ge,X as ye,Y as fe,Z as we,_ as ve,$ as be,a0 as Ce,a1 as ke,a2 as xe,a3 as Te,a4 as Ae,a5 as Ie,a6 as _e,a7 as Ee,a8 as Se,a9 as Ne,aa as Me,ab as Pe,ac as We,ad as Oe,ae as Ue,af as Le,ag as Re,ah as Fe,ai as De,aj as ze,ak as Be,al as $e,I as je}from"./internal-context-O3TPYUku.mjs";import{createPublicClient as Ve,http as He,isHex as qe,toHex as Ke,getAddress as Ze,formatEther as Ge,formatUnits as Ye,parseEther as Je,createWalletClient as Xe,custom as Qe,publicActions as et,encodeFunctionData as tt,isAddress as nt,hexToString as rt,decodeFunctionData as at,decodeAbiParameters as it}from"viem";import{v4 as ot}from"uuid";import*as st from"jose";import{base64url as lt}from"jose";import ct from"eventemitter3";import{CoinbaseWalletSDK as dt}from"@coinbase/wallet-sdk";import{ProviderErrors as pt,countryCodesAndNumbers as ht,validatePhoneNumber as ut,phoneNumberTypingFormatter as mt,getPlaceholderPhoneNumber as gt,getCountryCallingCode as yt,getPhoneCountryCodeAndNumber as ft,formatPhoneNumber as wt,toObjectKeys as vt,formatWalletAddress as bt,getCoinbaseOnRampUrl as Ct,chainToMoonpayCurrency as kt,isSupportedChainIdForMoonpay as xt,isSupportedChainIdForCoinbaseOnramp as Tt,SolanaClient as At,formatTokenAmount as It,formatWeiAmount as _t,lastFourDigits as Et}from"@privy-io/js-sdk-core";import{Turnstile as St}from"@marsidev/react-turnstile";import{styled as Nt,css as Mt,keyframes as Pt,createGlobalStyle as Wt}from"styled-components";import Ot from"tinycolor2";import Ut from"@heroicons/react/24/outline/ArrowLeftIcon";import Lt from"@heroicons/react/24/outline/ArrowRightIcon";import Rt from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Ft from"@heroicons/react/24/outline/XMarkIcon";import Dt from"@heroicons/react/24/outline/CheckIcon";import zt from"@heroicons/react/24/outline/Square2StackIcon";import Bt from"@heroicons/react/24/outline/WalletIcon";import{create as $t}from"zustand";import{EthereumProvider as jt,OPTIONAL_EVENTS as Vt,OPTIONAL_METHODS as Ht}from"@walletconnect/ethereum-provider";import qt from"@heroicons/react/24/outline/UserCircleIcon";import Kt from"@heroicons/react/24/outline/EnvelopeIcon";import Zt from"@heroicons/react/20/solid/CheckIcon";import Gt from"@heroicons/react/24/outline/PhoneIcon";import Yt from"@heroicons/react/24/outline/ExclamationTriangleIcon";import Jt from"@heroicons/react/24/outline/ExclamationCircleIcon";import Xt from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import Qt from"@heroicons/react/24/solid/DocumentCheckIcon";import en from"@heroicons/react/24/solid/XCircleIcon";import tn from"fast-password-entropy";import*as nn from"secure-password-utilities";import{DEFAULT_WORDLIST as rn}from"secure-password-utilities/wordlists";import an from"@heroicons/react/24/outline/LockClosedIcon";import on from"@heroicons/react/24/outline/PencilSquareIcon";import sn from"@heroicons/react/24/solid/CheckCircleIcon";import ln from"@heroicons/react/24/outline/ArrowPathIcon";import cn from"@heroicons/react/24/outline/EyeIcon";import dn from"@heroicons/react/24/outline/EyeSlashIcon";import pn from"@heroicons/react/24/outline/KeyIcon";import hn from"@heroicons/react/24/outline/ArrowDownTrayIcon";import un from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import mn from"@heroicons/react/24/outline/DocumentDuplicateIcon";import gn from"@heroicons/react/24/solid/LockClosedIcon";import yn from"@heroicons/react/24/outline/ShieldCheckIcon";import fn from"qrcode";import wn from"@heroicons/react/24/outline/FingerPrintIcon";import vn from"@heroicons/react/24/outline/ChevronRightIcon";import bn from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import Cn from"@heroicons/react/24/outline/ChevronDownIcon";import kn from"@heroicons/react/24/outline/CalendarIcon";import{Transition as xn,Dialog as Tn,TransitionChild as An,DialogPanel as In,Menu as _n,MenuButton as En,MenuItems as Sn,MenuItem as Nn}from"@headlessui/react";import Mn from"@heroicons/react/24/outline/CheckCircleIcon";import Pn from"@heroicons/react/24/outline/InformationCircleIcon";import Wn from"@heroicons/react/24/outline/CreditCardIcon";import On from"@heroicons/react/24/outline/QrCodeIcon";import Un from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import Ln from"@heroicons/react/24/outline/GlobeAltIcon";import{ofetch as Rn}from"ofetch";import{ChevronDownIcon as Fn,ArrowRightIcon as Dn}from"@heroicons/react/24/outline";import zn from"@heroicons/react/24/outline/ClipboardDocumentIcon";import Bn from"@heroicons/react/24/outline/CloudArrowUpIcon";import $n from"@heroicons/react/24/outline/NoSymbolIcon";import jn from"@heroicons/react/24/outline/ClockIcon";import Vn from"@heroicons/react/24/outline/TrashIcon";import Hn from"@heroicons/react/24/solid/CheckBadgeIcon";import qn from"@heroicons/react/24/solid/IdentificationIcon";import Kn from"@heroicons/react/24/outline/MinusCircleIcon";import Zn from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import Gn from"@heroicons/react/24/solid/ShieldCheckIcon";import Yn from"js-cookie";class Jn{async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");try{return await this.api.post(x,{token:this.meta.token})}catch(e){throw T(e)}}async link(){throw Error("Unimplemented")}constructor(e){this.meta={token:e}}}function Xn(e){return e?{"privy-ui":"t"}:void 0}class Qn{async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new k("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(A,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new k("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(I,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw T(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new k("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new k("Email must be set when initialzing authentication.");let r=Xn(n);try{return await this.api.post(_,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw T(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class er extends Qn{async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new k("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(E,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw T(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class tr{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e)}del(e){localStorage.removeItem(e)}getKeys(){return Object.entries(localStorage).map((([e])=>e))}}function nr(){try{let e="privy:__session_storage__test",t=new tr;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var rr="undefined"!=typeof window&&window.localStorage?new tr:new class{get(e){return this._cache[e]}put(e,t){void 0!==t?this._cache[e]=t:this.del(e)}del(e){delete this._cache[e]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};const ar=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom||"isPhantom"in e?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,ir=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==ar(e))return!1;if(e.providers)for(let t of e.providers)if(!ir(t))return!1;return!0},or=()=>{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},sr=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new S(`Unsupported chainId ${e}`,4901);return Ve({transport:He(lr(i,n,r.appId)),chain:i})},lr=(e,t,n)=>{let r,a=e.id,i=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])r=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[i])r=t.rpcUrls[i];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",n),r=t.toString()}else r=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!r)throw new S(`No RPC url found for ${a}`);return r},cr=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,}))$/),dr=(e,t=3,n=4,r="ethereum")=>{if(!e)return"";let a="ethereum"===r?2:0;return t+n+a+3>=e.length?e:`${e.slice(0,a+t)}...${e.slice(e.length-n,e.length)}`},pr=(e,t=3,n=4)=>dr(e,t,n,"solana"),hr=e=>new Promise((t=>setTimeout(t,e)));const ur=(e,t={})=>{let n=t.delayMs||150,r=t.maxAttempts||270;return new Promise((async(a,i)=>{let o=!1,s=0;for(;!o&&s<r;){if(t.abortSignal?.aborted)return;e().then((e=>{o=!0,a(e)}),((...e)=>{o=!0,i(...e)})),s+=1,await hr(n)}o||i(Error("Exceeded max attempts before resolving function"))}))},mr=(e,t,n={},r={})=>{let a=new URL(t,e);for(let[e,t]of Object.entries(n))void 0!==t&&a.searchParams.set(e,t);let i=Object.entries(r);if(i.length>0){let e=new URLSearchParams;for(let[t,n]of i)e.append(t,n);a.hash=e.toString()}return a.href},gr=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),yr=e=>"string"==typeof e?e:"0x"+e.toString(16);async function fr({store:e,walletList:t,externalWalletConfig:n,walletChainType:r,timeout:a=3e3}){let i=!1,o=window;return new Promise((s=>{function l(){if(i)return;i=!0,window.removeEventListener("ethereum#initialized",l);let a=e.getProviders();console.debug("Detected injected providers:",a.map((e=>e.info)));let o=[];for(let e of a)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===r&&"app.phantom"===e.info.rdns||o.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==r)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let n=[];if(t.providers?.length)for(let e of t.providers)e&&n.push(e);return n.push(e.ethereum),n}()){let t=ar(e);if(!a.some((e=>e.info.name===t))){if(ir(e,!0)&&!o.find((e=>"metamask"===e.type))){o.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!o.find((e=>"phantom"===e.type))){o.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!o.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==n.coinbaseWallet?.connectionOptions))){o.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}o.find((e=>"unknown_browser_extension"===e.type))||o.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}s(o)}o.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout((()=>{l()}),a))}))}function wr(e){return`eip155:${String(Number(e))}`}const vr=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new S(`Unsupported chainId ${e}`,4901);return lr(i,n,r)},br=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},n=e.types.EIP712Domain??Object.entries(e.domain).map((([e,n])=>{if(null!=n&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:n}}};const Cr=["c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96","4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0","225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f","1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369","c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a","ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18","bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6","74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d","afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7","f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d","84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04","0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150","38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662","9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0","c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576","8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4","e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4","f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2","138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98","47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83","7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26","8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3","031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa","2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568","dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd","2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01","b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f","0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92","719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3","942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef","8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2","07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80","8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819","bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a","cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e","94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43","2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715","14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc","576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd","49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd","19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b","5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b","d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b","50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b","9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8","6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa","41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071","14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd","a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1","971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709","18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1","15c8b91ade1a4e58f3ce4e7a0dd7f42b47db0c8df7e0d84f63eb39bcb96c4e0f","541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf"];function kr(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let xr="WALLETCONNECT_DEEPLINK_CHOICE";function Tr(e){return e.startsWith("http://")||e.startsWith("https://")}function Ar(e,t){if(Tr(e))return Ir(e,t);let n=e;return n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function Ir(e,t){if(!Tr(e))return Ar(e,t);let n=e;return n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function _r(e,t){window.open(e,t,"noreferrer noopener")}class Er{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}class Sr{get meta(){return this._meta}async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.channelToken)throw new k("Auth flow must be initialized first");try{let e=await this.api.post(N,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new k("No response from authentication");return e}catch(e){throw T(e)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");try{return await this.api.post(M,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw T(e)}}async _startChannelOnce(){if(!this.api)throw new k("Auth flow has no API instance");let e=await this.api.post(P,{token:this.captchaToken});g&&!y&&e.connect_uri&&_r(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new k("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.channelToken)throw new k("Auth flow must be initialized first");let e=await this.api.get(W,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new Er(this._startChannelOnce.bind(this)),this.pollForReady=new Er(this._pollForReady.bind(this)),this._meta.disableSignup=t}}const Nr="https://auth.privy.io",Mr=1400,Pr=2500,Wr=4e3,Or="2.6.3",Ur="privy:token",Lr="privy-token",Rr="privy:refresh_token",Fr="privy:pat",Dr="privy:id_token",zr="privy-id-token",Br="privy-session",$r="privy:caid",jr=e=>`privy:guest:${e}`,Vr=e=>`privy:cross-app:${e}`,Hr="privy:state_code",qr="privy:code_verifier",Kr="privy:headless_oauth",Zr="privy:oauth_disable_signup",Gr=e=>`privy:wallet:${e}`,Yr="privy:connectors",Jr="privy:connections",Xr=12e4,Qr=3e4,ea="https://api.moonpay.com/v1",ta="https://api.moonpay.com/v1",na="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",ra="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";function aa(e){return crypto.getRandomValues(new Uint8Array(e))}function ia(){return lt.encode(aa(36))}function oa(){return ia()}async function sa(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return lt.encode(t)}}class la{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new k("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new k("User denied confirmation during OAuth flow");let e=function(){let e=rr.get(qr);if(!e)throw new k("Authentication error.");return e}();try{let t=await this.api.post(O,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return rr.del(qr),rr.del(Kr),rr.del(Zr),t}catch(e){let t=T(e);if(t.privyErrorCode)throw new k(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new k("Invalid code during oauth flow.",void 0,U.OAUTH_USER_DENIED);throw new k("Invalid code during OAuth flow.",void 0,U.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new k("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new k("User denied confirmation during OAuth flow");let e=rr.get(qr);if(!e)throw new k("Authentication error.");try{let t=await this.api.post(L,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return rr.del(qr),t}catch(e){throw T(e)}}async getAuthorizationUrl(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.provider)throw new k("Provider must be set when initializing OAuth authentication.");let e=ia();rr.put(qr,e);let t=oa();rr.put(Hr,t);let n=await sa(e);this.meta.withPrivyUi||rr.put(Kr,!0),this.meta.disableSignup&&rr.put(Zr,!0);let r=Xn(this.meta.withPrivyUi);try{return await this.api.post(R,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...r}})}catch(e){throw T(e)}}constructor(e){this.meta=e}}function ca(e){return e.charAt(0).toUpperCase()+e.slice(1)}const da=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]}),pa=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("g",{clipPath:"url(#clip0)",children:/*#__PURE__*/t("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"})}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0",children:/*#__PURE__*/t("rect",{width:"71",height:"55",fill:"white"})})})]}),ha=({style:e,...n})=>/*#__PURE__*/t("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...n,children:/*#__PURE__*/t("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"})}),ua=({style:e})=>/*#__PURE__*/t(Ln,{style:{color:"var(--privy-color-error)",...e}}),ma=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...n},...r,children:[/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]});function ga(n){/*#__PURE__*/return e("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",...n,children:[/*#__PURE__*/e("defs",{children:[/*#__PURE__*/e("linearGradient",{id:"b",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#3771c8"}),/*#__PURE__*/t("stop",{stopColor:"#3771c8",offset:".128"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),/*#__PURE__*/e("linearGradient",{id:"a",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".1",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".5",stopColor:"#ff543e"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#c837ab"})]}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]}),/*#__PURE__*/t("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)"}),/*#__PURE__*/t("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)"}),/*#__PURE__*/t("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"})]})}function ya({style:e,...n}){/*#__PURE__*/return t("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},...n,children:/*#__PURE__*/t("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:/*#__PURE__*/t("g",{transform:"scale(5.12,5.12)",children:/*#__PURE__*/t("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"})})})})}function fa(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...n,children:[/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]})}function wa(n){/*#__PURE__*/return e("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,...n,children:[/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]})}const va=({style:e,...n})=>/*#__PURE__*/t("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},...n,children:/*#__PURE__*/t("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"})});let ba={google:{name:"Google",component:ma},discord:{name:"Discord",component:pa},github:{name:"Github",component:ha},linkedin:{name:"LinkedIn",component:ya},twitter:{name:"Twitter",component:va},spotify:{name:"Spotify",component:fa},instagram:{name:"Instagram",component:ga},tiktok:{name:"Tiktok",component:wa},apple:{name:"Apple",component:da}};const Ca=e=>e in ba?ba[e]:{name:"Unknown",component:ua};function ka(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),n=e.get("privy_oauth_state"),r=e.get("privy_oauth_provider");if(!t||!n||!r)return{inProgress:!1};let a=!1;try{a=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:n,provider:r,withPrivyUi:!rr.get(Kr),popupFlow:null!==window.opener&&a,disableSignup:!!rr.get(Zr)}}function xa(){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"),rr.del(Hr),window.history.replaceState({},"",e)}class Ta{async initRegisterFlow(e){if(!this.api)throw new k("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new k("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new k("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new k("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new k("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(F,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new k("Passkey request timed out or rejected by user.",void 0,U.PASSKEY_NOT_ALLOWED);throw T(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new k("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new k("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let n=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(D,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new k("Passkey request timed out or rejected by user.",void 0,U.PASSKEY_NOT_ALLOWED);throw T(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new k("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new k("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(z,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new k("Passkey request timed out or rejected by user.",void 0,U.PASSKEY_NOT_ALLOWED);throw T(e)}}async _initRegisterOnce(e){if(!this.api)throw new k("Auth flow has no API instance");let t=Xn(e);return await this.api.post(B,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new k("Auth flow has no API instance");let t=Xn(e);return await this.api.post($,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new k("Auth flow has no API instance");return await this.api.post(j,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},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}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.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}}_transformAuthenticationResponseToSnakeCase(e){return{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}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new Er(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new Er(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Er(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}const Aa=({address:e,chainId:t,nonce:n})=>`${window.location.host} wants you to sign in with your Ethereum account:\n${e}\n\nBy signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: ${t}\nNonce: ${n}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class Ia{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,chainId:this.wallet.chainId,address:this.wallet.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new k("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.client)throw new k("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw T(e)}}async sign(){if(!this.client)throw new k("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new k("Could not prepare SIWE message");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new k("SiweFlow has no client instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new k("SiweFlow has no client instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=Aa({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1){this._meta={disableSignup:!1},this.getNonceOnce=new Er(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=n,this.client=t,this._meta.disableSignup=r}}class _a{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new k("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.client)throw new k("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw T(e)}}async sign(){if(!this.client)throw new k("SiwsFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new k("Could not prepare SIWS message");if(!this.wallet.signMessage)throw new k("Wallet does not support signMessage");let e=await this.wallet.signMessage(Buffer.from(this.preparedMessage));return{message:this.preparedMessage,signature:Buffer.from(e).toString("base64")}}async _getNonceOnce(){if(!this.client)throw new k("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new k("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=(({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\nYou are proving you own ${e}.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: mainnet\nNonce: ${t}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`)({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1){this._meta={disableSignup:!1},this.getNonceOnce=new Er(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=n,this.client=t,this._meta.disableSignup=r}}class Ea{async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new k("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(V,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new k("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(H,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw T(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new k("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new k("phone nNumber must be set when initialzing authentication.");let r=Xn(n);try{return await this.api.post(q,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw T(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:n}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:n??!1}}}class Sa extends Ea{async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new k("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(K,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw T(e)}}constructor(e,t,n){super({phoneNumber:t,captchaToken:n}),this.meta={phoneNumber:t,captchaToken:n,oldPhoneNumber:e,disableSignup:!1}}}const Na=/*#__PURE__*/c({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:G,setError:G,setExecuting:G,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:G,reset:G,execute:G});class Ma extends Z{constructor(e,t,n){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=n}}const Pa=({children:e,id:n,captchaSiteKey:r,captchaEnabled:a})=>{let l=i(null),[c,d]=o(),[p,h]=o(),[u,m]=o(!1),g=s((()=>a?u||c||p?!u||c||p?c&&!p?{status:"success",token:c}:p?{status:"error",error:p}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[a,c,p,u]);/*#__PURE__*/return t(Na.Provider,{value:{...g,ref:l,enabled:a,siteKey:r,appId:n,setToken:d,setError:h,setExecuting:m,remove(){a&&(l.current?.remove(),m(!1),h(void 0),d(void 0))},reset(){a&&(l.current?.reset(),m(!1),h(void 0),d(void 0))},execute(){a&&(m(!0),l.current?.execute())},async waitForResult(){if(!a)return"";try{return await function(e,{interval:t=100,timeout:n=5e3}={}){return new Promise(((r,a)=>{let i,o=0,s=()=>{o>=n?a("Max attempts reached without result"):(i=e(),o+=t,null==i?setTimeout(s,t):r(i))};s()}))}((()=>l.current?.getResponse()),{interval:200,timeout:2e4})}catch(e){throw new Ma("Captcha failed",null,U.CAPTCHA_TIMEOUT)}}},children:e})},Wa=()=>l(Na);class Oa{async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");try{return await this.api.post(Y,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");try{return await this.api.post(J,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw T(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function Ua(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===U.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===U.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===U.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===U.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===U.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===U.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===U.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof Ma&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function La(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function Ra(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}class Fa{static parse(e){try{return new Fa(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return st.decodeJwt(e),e}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(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=st.decodeJwt(e)}}class Da extends Fa{static parse(e){try{return new Da(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}function za(e){return e?new Date(1e3*e):null}function Ba(e,t){return e.slice().sort(((e,t)=>(e.firstVerifiedAt??e.verifiedAt).getTime()-(t.firstVerifiedAt??t.verifiedAt).getTime())).find((e=>e.type===t))}const $a=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType&&0===e.walletIndex))||null,ja=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType)),Va=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType)),Ha=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType&&0===e.walletIndex))||null,qa=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType))||null,Ka=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType))||null,Za=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.address===t))||null,Ga=e=>$a(e)??Ha(e);function Ya(e){if(!e)return null;let t=function(e){let t=[];for(let n of e){let e=n.type;switch(n.type){case"wallet":let r={id:n.id,address:n.address,type:n.type,imported:n.imported,delegated:n.delegated,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at),chainType:n.chain_type,walletClientType:n.wallet_client_type,connectorType:n.connector_type,recoveryMethod:n.recovery_method,walletIndex:n.wallet_index};t.push(r);break;case"smart_wallet":let a={address:n.address,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at),smartWalletType:n.smart_wallet_type};t.push(a);break;case"cross_app":let i={type:n.type,subject:n.subject,embeddedWallets:n.embedded_wallets,smartWallets:n.smart_wallets,providerApp:{id:n.provider_app_id},verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(i);break;case"email":let o={address:n.address,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(o);break;case"phone":let s={number:n.phoneNumber,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(s);break;case"google_oauth":let l={subject:n.subject,email:n.email,name:n.name,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(l);break;case"spotify_oauth":let c={subject:n.subject,email:n.email,name:n.name,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(c);break;case"instagram_oauth":let d={subject:n.subject,username:n.username,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(d);break;case"twitter_oauth":let p={subject:n.subject,username:n.username,name:n.name,type:n.type,profilePictureUrl:n.profile_picture_url,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(p);break;case"discord_oauth":let h={subject:n.subject,username:n.username,email:n.email,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(h);break;case"github_oauth":let u={subject:n.subject,username:n.username,name:n.name,email:n.email,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(u);break;case"tiktok_oauth":let m={subject:n.subject,username:n.username,name:n.name,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(m);break;case"linkedin_oauth":let g={subject:n.subject,name:n.name,email:n.email,vanityName:n.vanity_name,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(g);break;case"apple_oauth":let y={subject:n.subject,email:n.email,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(y);break;case"custom_auth":t.push({type:n.type,customUserId:n.custom_user_id,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)});break;case"farcaster":let f={type:n.type,fid:n.fid,ownerAddress:n.owner_address,displayName:n.display_name,username:n.username,bio:n.bio,pfp:n.profile_picture_url,url:n.homepage_url,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at),signerPublicKey:n.signer_public_key};t.push(f);break;case"passkey":let w={type:n.type,enrolledInMfa:n.enrolled_in_mfa,credentialId:n.credential_id,authenticatorName:n.authenticator_name,createdWithDevice:n.created_with_device,createdWithOs:n.created_with_os,createdWithBrowser:n.created_with_browser,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(w);break;case"telegram":let v={type:n.type,telegramUserId:n.telegram_user_id,firstName:n.first_name,lastName:n.last_name,username:n.username,photoUrl:n.photo_url,verifiedAt:za(n.first_verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(v);break;case"authorization_key":let b={type:n.type,publicKey:n.public_key,verifiedAt:za(n.first_verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(b);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),n=Ba(t,"wallet"),r=Ba(t,"smart_wallet"),a=Ba(t,"email"),i=Ba(t,"phone"),o=Ba(t,"google_oauth"),s=Ba(t,"twitter_oauth"),l=Ba(t,"discord_oauth"),c=Ba(t,"github_oauth"),d=Ba(t,"spotify_oauth"),p=Ba(t,"instagram_oauth"),h=Ba(t,"tiktok_oauth"),u=Ba(t,"linkedin_oauth"),m=Ba(t,"apple_oauth"),g=Ba(t,"farcaster"),y=Ba(t,"telegram"),f=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:za(t)})));return{id:e.id,createdAt:za(e.created_at),linkedAccounts:t,email:a&&{address:a?.address},phone:i&&{number:i?.number},wallet:n&&{id:n.id,address:n.address,chainType:n.chainType,walletClientType:n.walletClientType,connectorType:n.connectorType,recoveryMethod:n.recoveryMethod,imported:n.imported,delegated:n.delegated,walletIndex:n.walletIndex},smartWallet:r&&{address:r.address,smartWalletType:r.smartWalletType},google:o&&{subject:o.subject,email:o.email,name:o.name},twitter:s&&{subject:s.subject,username:s.username,name:s.name,profilePictureUrl:s.profilePictureUrl},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:c&&{subject:c.subject,username:c.username,name:c.name,email:c.email},spotify:d&&{subject:d.subject,email:d.email,name:d.name},instagram:p&&{subject:p.subject,username:p.username},tiktok:h&&{subject:h.subject,username:h.username,name:h.name},linkedin:u&&{subject:u.subject,name:u.name,email:u.email,vanityName:u.vanityName},apple:m&&{subject:m.subject,email:m.email},farcaster:g&&{fid:g.fid,ownerAddress:g.ownerAddress,displayName:g.displayName,username:g.username,bio:g.bio,pfp:g.pfp,url:g.url,signerPublicKey:g.signerPublicKey},telegram:y&&{telegramUserId:y.telegramUserId,firstName:y.firstName,lastName:y.lastName,username:y.username,photoUrl:y.photoUrl},delegatedWallets:[],mfaMethods:f.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}const Ja=e=>e?.linkedAccounts.find((e=>"authorization_key"===e.type));let Xa=e=>{if("ethereum"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier"};if("solana"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"solana-address-verifier"};throw Error("Failed to get account entropy details")};const Qa=(e,t)=>{let n=Ja(e);if(n)return{entropyId:n.publicKey,entropyIdVerifier:"p256"};if(t?.imported)return Xa(t);let r=Ga(e);if(!r)throw Error("Failed to find primary wallet");return Xa(r)},ei=({style:n,...r})=>/*#__PURE__*/e("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),/*#__PURE__*/t("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"})]}),ti={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"}}},ni={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},ri={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"}}},ai={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},ii={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"}}},oi={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},si={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},li={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},ci={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"}}},di={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"}}},pi={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},hi={id:137,name:"Polygon Mainnet",network:"polygon",nativeCurrency:{name:"POL",symbol:"POL",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"}}},ui={id:80002,name:"Polygon Amoy",network:"polygon-amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-amoy.rpc.privy.systems"]},infura:{http:["https://polygon-amoy.infura.io/v3"],webSocket:["wss://polygon-amoy.infura.io/ws/v3"]},default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"OK LINK",url:"https://www.oklink.com/amoy"}},testnet:!0},mi={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},gi={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"}}},yi=[ti,ni,mi,ci,di,pi,hi,ui,si,{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},{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"}}},{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"}}},ii,oi,{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},{id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network"}}},li,{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},ri,ai,gi,{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},{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},{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"}}},{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/"}}},{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"}}}],fi=new Set(yi.map((e=>e.id)));class wi extends S{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class vi extends S{constructor(){super("User rejected connection"),this.type="wallet_error"}}const bi=e=>e instanceof S?e:e?.code?new ki(e):new S("Unknown connector error",e);class Ci extends Z{constructor(e,t,n){super(e),this.type="provider_error",this.code=t,this.data=n}}class ki extends Ci{constructor(e){super(e.message,e.code,e.data);let t=Object.values(pt).find((t=>t.eipCode===e.code));this.details=t||pt.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=pt.E32002_CONNECTION_ALREADY_PENDING:this.details=pt.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=pt.E32002_WALLET_LOCKED))}}const xi={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},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...pt};function Ti(e){return"ethereum"===e.type}function Ai(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],a=t[n];if(r?.address!==a?.address||r&&a&&Ti(r)&&Ti(a)&&r?.chainId!==a?.chainId||r?.connectorType!==a?.connectorType||r?.connectedAt!==a?.connectedAt||r?.walletClientType!==a?.walletClientType||r?.isConnected!==a?.isConnected||r?.linked!==a?.linked)return!1}return!0}class Ii extends ct{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const _i=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||Xr;let Ei;function Si(e){return"ethereum"===e.chainType}class Ni extends Ii{buildConnectedWallet(e,t,n,r){let a=async()=>!!this.wallets.find((t=>v(t.address)===v(e)));return{type:"ethereum",address:v(e),chainId:t,meta:n,imported:r,switchChain:async n=>{let r,i;if(!a)throw new S("Wallet is not currently connected.");let o=this.wallets.find((t=>v(t.address)===v(e)))?.chainId;if(!o)throw new S("Unable to determine current chainId.");if("number"==typeof n?(r=`0x${n.toString(16)}`,i=n):(r=n,i=Number(n)),o===wr(r))return;let s=this.chains.find((e=>e.id===i));if(!s)throw new S(`Unsupported chainId: ${n}`);let l=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:r}]})};try{return await l()}catch(e){if(((e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");case"rabby_wallet":return e.message.includes("Unrecognized chain ID");default:return 4902===e.code||e.message?.includes("4902")}})(e,this.walletClientType))return"rabby_wallet"===this.walletClientType&&await hr(300),await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:r,chainName:s.name,nativeCurrency:s.nativeCurrency,rpcUrls:[s.rpcUrls.default?.http[0]??""],blockExplorerUrls:[s.blockExplorers?.default.url??""]}]}),l();if("rainbow"===this.walletClientType&&e.message?.includes("wallet_switchEthereumChain"))throw new S(`Rainbow does not support the chainId ${t}`);throw e}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:a,getEthereumProvider:async()=>{if(!await a())throw new S("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await a())throw new S("Wallet is not currently connected.");return await this.sign(e)},disconnect:()=>{this.disconnect()}}}async syncAccounts(e){let t,n=e;try{if(void 0===n){let e=await ur((()=>this.proxyProvider.request({method:"eth_accounts"})),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,e),Array.isArray(e)&&(n=e)}}catch(e){console.debug("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",e)}if(!n||!Array.isArray(n)||n.length<=0||!n[0])return;let r=n[0],a=v(r),i=[];if("privy"===this.walletClientType){let e=rr.get(Gr(a));this.chains.find((t=>t.id===Number(e)))||(rr.del(Gr(a)),e=null),t=e||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}catch(e){console.warn(`Unable to switch embedded wallet to chain ID ${t} on initialization`)}}else try{let e=await ur((()=>this.proxyProvider.request({method:"eth_chainId"})),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,e),"string"==typeof e)t=e;else{if("number"!=typeof e)throw Error("Invalid chainId returned from provider");t=`0x${e.toString(16)}`}}catch(e){console.warn("Failed to get chainId from provider, defaulting to 0x1",e),t="0x1"}let o=wr(t);if(!i.find((e=>v(e.address)===a))){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};i.push(this.buildConnectedWallet(v(r),o,e,"embedded_imported"===this.connectorType))}Ai(i,this.wallets)||(this.wallets=i,this.emit("walletsUpdated"))}async getConnectedWallet(){let e=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt)).find((t=>e.find((e=>v(e)===v(t.address)))))||null}async isConnected(){let e=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0}async sign(e){return await this.connect({showPrompt:!1}),this.proxyProvider.request({method:"personal_sign",params:[b(e),this.wallets[0]?.address]})}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)}constructor(e,t,n,r){super(e),this.chainType="ethereum",this.onAccountsChanged=e=>{0===e.length?this.onDisconnect():this.syncAccounts(e)},this.onChainChanged=e=>{this.wallets.forEach((t=>{t.chainId=wr(e),"privy"===this.walletClientType&&rr.put(Gr(t.address),e)})),this.emit("walletsUpdated")},this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")},this.onConnect=async()=>{this.connected=!0,"coinbase_wallet"===this.connectorType&&await hr(300),this.syncAccounts()},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=n,this.rpcConfig=r,this.rpcTimeoutDuration=_i(r,e),this.connected=!1,this.initialized=!1}}class Mi{on(e,t){if(this.walletProvider)return this.walletProvider.on(e,t);this._subscriptions.push({eventName:e,listener:t})}async request(e){if(!this.walletProvider)throw new S(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),this.walletTimeout()]).catch((e=>{throw bi(e)}))}constructor(e,t){this.removeListener=(e,t)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(e,t)}catch(e){console.warn("Unable to remove wallet provider listener")}},this.walletTimeout=(e=new wi,t=this.rpcTimeoutDuration)=>new Promise(((n,r)=>setTimeout((()=>{r(e)}),t))),this.setWalletProvider=e=>{this.walletProvider&&this._subscriptions.forEach((e=>{this.removeListener(e.eventName,e.listener)})),this.walletProvider=e,this._subscriptions.forEach((e=>{this.walletProvider?.on(e.eventName,e.listener)}))},this.walletProvider=e,this.rpcTimeoutDuration=t||Xr,this._subscriptions=[]}}let Pi=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],Wi=(e,t)=>e.makeWeb3Provider({options:t});class Oi extends Ni{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new S("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw bi(e)}}updateConnectionPreference(e){this.connectionOptions=e,this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(Wi(Ei,this.connectionOptions))}constructor(e,t,n,r,a,i){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Mi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=r.coinbaseWallet.connectionOptions??"all",this.walletClientType="smartWalletOnly"===this.connectionOptions?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!Ei){let n=[t.id].concat(e.map((e=>e.id))),r="eoaOnly"!==this.connectionOptions?n.filter((e=>!Pi.includes(e))):[];r.length>0&&!r.every((e=>fi.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${r.join(", ")}`),Ei=new dt({appName:a,appLogoUrl:i,appChainIds:n})}this.proxyProvider.setWalletProvider(Wi(Ei,this.connectionOptions))}}const Ui=({...e})=>/*#__PURE__*/t("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:/*#__PURE__*/t("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)"})});class Li extends Ni{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[yr(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Ui,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}constructor({provider:e,chains:t,defaultChain:n,rpcConfig:r,imported:a,walletIndex:i}){super("privy",t,n,r),this.connectorType="embedded",this.proxyProvider=e,this.walletIndex=i,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}}const Ri=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];let Fi={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844"};const Di={legacy:0,eip2930:1,eip1559:2,eip4844:3};let zi=e=>void 0!==e?BigInt(e):void 0;function Bi(e){let t,{type:n=2,...r}=e;r.accessList&&Array.isArray(r.accessList)?t=r.accessList.map((e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e)):r.accessList&&(t=Object.entries(r.accessList).map((e=>({address:e[0],storageKeys:e[1]}))));let a=Number(r.chainId??1),i=qe(r.data)?r.data:r.data?Ke(Uint8Array.from(r.data)):void 0,o=r.nonce?Number(r.nonce):void 0,s={chainId:a,data:i,nonce:o,value:zi(r.value),gas:zi(r.gas??r.gasLimit)},l=Number(n);if(0===l)return{...r,type:Fi[l],...s,gasPrice:zi(r.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===l)return{...r,type:Fi[l],...s,gasPrice:zi(r.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===l)return{...r,type:Fi[l],...s,nonce:o,accessList:t,maxFeePerGas:zi(r.maxFeePerGas),maxPriorityFeePerGas:zi(r.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw new k(`Unsupported transaction type: ${n}`)}class $i extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}class ji extends ct{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new $i(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Jb()||!this.address)throw new $i("Disconnected",4900);let{hash:n}=await tC(t,{address:this.address});return n}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new $i(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Jb()||!this.address)throw new $i("Disconnected",4900);let{signature:n}=await eC(t,{address:this.address});return n}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new $i(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new $i(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=sr(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],n=e.params[1],{signature:r}=await Xb({message:t},{address:n});return r}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],n="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:r}=await Qb(br(n),{address:t});return r}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:yr(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...Bi(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return yr(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>Ri.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await Jb();if(await nC(),!t||!this.address)throw new $i("Disconnected",4900);try{return(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:{method:e.method,params:e.params}})).response.data}catch(e){throw console.error(e),new $i("Disconnected",4900)}}}constructor({walletProxy:e,address:t,entropyId:n,entropyIdVerifier:r,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l}){super(),this.walletProxy=e,this.address=t,this.entropyId=n,this.entropyIdVerifier=r,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=sr(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=_i(a,"privy"),this.appId=o,this.walletIndex=l}}class Vi extends Ni{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:n,walletClientType:r,defaultChain:a}){super(r,[],a,{}),this.connectorType="null",this.proxyProvider=new Mi(void 0,Xr),this.id=e,this.name=t,this.icon=n,this.connectorType=r}}const Hi=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...e},...n,children:/*#__PURE__*/t("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"})}),qi=({style:n,...r})=>/*#__PURE__*/e("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",...n},...r,children:[/*#__PURE__*/t("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),/*#__PURE__*/t("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]}),Ki=({style:n,...r})=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),/*#__PURE__*/t("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"})]});function Zi(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Gi=0;class Yi extends Ni{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.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 e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new S("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw bi(e)}}constructor(e,t,n,r,a){super(a||"unknown",e,t,n),this.connectorType="injected",this.proxyProvider=new Mi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=r;let i=r.provider;this.proxyProvider.setWalletProvider(i)}}var Ji="__private_"+Gi+++"__walletBranding";class Xi extends Ni{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return Zi(this,Ji)[Ji]??{name:"Browser Extension",icon:Hi,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new S("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw bi(e)}}constructor(e,t,n,r,a){super(a??"unknown",e,t,n),Object.defineProperty(this,Ji,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Mi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(r),"metamask"===a?Zi(this,Ji)[Ji]={name:"MetaMask",icon:qi,id:"io.metamask"}:"phantom"===a&&(Zi(this,Ji)[Ji]={name:"Phantom",icon:Ki,id:"phantom"})}}class Qi extends Yi{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{g||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new S("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw bi(e)}}}const eo=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","crypto.com_wallet_extension","crypto.com_onchain","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","privy","unknown","phantom","solflare","glow","backpack"],to=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:m.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=ro({client:this.client,isSolana:t,connectOnly:n});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${r}?ref=${r}`}},solflare:{client:"solflare",name:"Solflare",installLink:m.isFirefox?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=ro({client:this.client,isSolana:t,connectOnly:n});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${r}?ref=${r}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcbcmnbpgliof",chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=ro({client:this.client,isSolana:t,connectOnly:n});return`${e?"backpack://ul/v1/":"https://backpack.com/ul/v1/"}browse/${r}?ref=${r}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",chainTypes:["solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return"https://www.okx.com/download?deeplink="+encodeURIComponent("okx://wallet/dapp/url?dappUrl="+ro({client:this.client,isSolana:e,connectOnly:t}))}}});function no({connectorType:e,walletClientType:t}){for(let n of eo)if(e===n||t===n)return to[n]}function ro({client:e,isSolana:t,connectOnly:n}){let r=new URL(window.location.href);return r.searchParams.set("privy_connector",t?"solana_adapter":"injected"),r.searchParams.set("privy_wallet_client",e),r.searchParams.set("privy_connect_only",String(n)),encodeURIComponent(r.href.replace(/\/$/g,""))}const ao=()=>{let e=rr.get(Jr);return e&&Array.isArray(e)&&e.map((e=>(e=>e&&"string"==typeof e.address&&"string"==typeof e.connectorType&&"string"==typeof e.walletClientType&&"number"==typeof e.connectedAt)(e))).every(Boolean)?e:[]};let io=["phantom","glow","solflare","backpack","okx_wallet"];function oo(e){return"solana"===e.chainType}function so(e){return"solana"===e.type}class lo extends Ii{get isInstalled(){return"Installed"===this.adapter.readyState}buildConnectedWallet(e,t){let n,r,a,i;if("Installed"!==e.readyState||!e.publicKey)throw Error("Wallet is not connected.");return"signMessage"in e&&(n=async(...t)=>{if(!e.connected)throw Error("Wallet is not connected.");return await e.signMessage(t[0])}),"sendTransaction"in e&&(r=async(...t)=>await e.sendTransaction(t[0],t[1],t[2])),"signTransaction"in e&&(a=async t=>await e.signTransaction(t)),"signAllTransactions"in e&&(i=async t=>await e.signAllTransactions(t)),{type:"solana",address:e.publicKey.toBase58(),meta:t,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>e.connected,disconnect:()=>{try{e.disconnect()}catch(e){console.error("Wallet does not support programmatic disconnect")}},getProvider:X(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:n??X(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:r??X(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:a??X(`${this.walletClientType||""} wallet does not support 'signTransaction'`),signAllTransactions:i??X(`${this.walletClientType||""} wallet does not support 'signAllTransactions'`)}}async syncAccounts(){if("Installed"===this.adapter.readyState&&this.adapter.publicKey){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find((e=>this.adapter.publicKey&&e.address===this.adapter.publicKey.toBase58()))||(this.wallets=[this.buildConnectedWallet(this.adapter,e)],this.emit("walletsUpdated"))}else this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"))}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAttemptAutoConnect()&&await this.adapter.autoConnect().catch((()=>{})),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}shouldAttemptAutoConnect(){return!(!this.autoConnectEnabled||!io.includes(this.walletClientType))&&("phantom"!==this.walletClientType||ao().some((({walletClientType:e})=>"phantom"===e)))}constructor(e,t){super(function(e){return e.name.toLowerCase().split(" ").join("_")}(e)),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=()=>{this.adapter.disconnect().then((()=>this.onDisconnect())).catch((e=>console.error("Error disconnecting",e)))},this.promptConnection=async()=>{try{await this.adapter.connect()}catch(e){throw bi(e)}},this.onDisconnect=()=>{this.syncAccounts()},this.onConnect=e=>{this.syncAccounts()},this.onError=e=>{this.syncAccounts()},this.onReadyStateChange=e=>{"Installed"!==e&&(this.connected=!1),this.syncAccounts()},this.adapter=e,this.autoConnectEnabled=t,this.wallets=[]}}class co extends lo{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:n}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new Mi(void 0,Xr),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=n}}const po=$t((()=>({listings:[]}))),ho=po.setState,uo=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return po.getState().listings.find((({homepage:e})=>{let n;try{n=new URL(e).hostname}catch(e){return!1}return t.includes(n)}))},mo=e=>po((({listings:t})=>t.find((({slug:t})=>go(t)===go(e)))));function go(e){return"cryptocom"===e?"cryptocom-defi":e.replace(/[-_]wallet$/,"")}function yo({src:e,...n}){/*#__PURE__*/return t("img",{src:e,...n,style:{display:"none"}})}const fo={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",externalWallets:{coinbaseWallet:{connectionOptions:"all"}},embeddedWallets:{extendedCalldataDecoding:!1},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};let wo=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","ronin_wallet","haha_wallet","wallet_connect","detected_wallets","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe","solflare","backpack"]),vo=e=>wo.has(e),bo=(e,t,n)=>n.indexOf(e)===t;function Co(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}function ko(e){let t=e.filter((e=>!fi.has(e.id)));return yi.concat(t)}function xo(e,t){return{...e,rpcUrls:{...e.rpcUrls,privy:{http:[t]}}}}const To=792703809,Ao="11111111111111111111111111111111";function Io(e){return e.includes("testnet")?"testnet":e.includes("devnet")?"devnet":"mainnet-beta"}function _o(e,t){return`https://explorer.solana.com/account/${e}?cluster=${t}`}let Eo="#FFFFFF";function So(e,t){let n=Math.max(0,Math.min(1,e.toHsl().l+t));return Ot({...e.toHsl(),l:n})}function No({backgroundTheme:e,accentHex:t}){let n;switch(e){case"light":n=Eo;break;case"dark":n="#1E1E1D";break;default:n=e}let r=Ot(n),a=Ot(t),i=Ot("#51BA81"),o=Ot("#FFB74D"),s=Ot("#EC6351"),l=function(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"}(r.getLuminance()),c=So(r,"light"===l?-.04:.11),d=So(r,"light"===l?-.08:.16),p=So(r,"light"===l?-.88:.87),h=So(r,"light"===l?-.7:.75),u=So(r,"light"===l?-.43:.45).desaturate("light"===l?60:20),m=So(r,"light"===l?-.08:.25).desaturate("light"===l?60:20),g=So(a,.15),y=So(a,.25),f=So(a,-.06),w=So(a,-.6),v=So(s,.3),b=So(o,.3),C=Ot(a.getLuminance()>.5?"#040217":Eo),k=So(i,-.16),x=So(i,.4);return{colorScheme:l,background:r.toHslString(),background2:c.toHslString(),background3:d.toHslString(),foreground:p.toHslString(),foreground2:h.toHslString(),foreground3:u.toHslString(),foreground4:m.toHslString(),accent:a.toHslString(),accentLight:g.toHslString(),accentLightest:y.toHslString(),accentDark:f.toHslString(),accentDarkest:w.toHslString(),foregroundAccent:C.toHslString(),success:i.toHslString(),successDark:k.toHslString(),successLight:x.toHslString(),error:s.toHslString(),errorLight:v.toHslString(),warn:o.toHslString(),warnLight:b.toHslString()}}function Mo(e,t,n,r){let a,i,o,s,l,c,d,p,h,u,m,g,y,f,w,v=n?console.warn:()=>{};t?.loginMethods?(a=t.loginMethods.includes("email"),i=t.loginMethods.includes("sms"),s=t.loginMethods.includes("wallet"),l=t.loginMethods.includes("google"),c=t.loginMethods.includes("twitter"),d=t.loginMethods.includes("discord"),h=t.loginMethods.includes("spotify"),u=t.loginMethods.includes("instagram"),p=t.loginMethods.includes("tiktok"),g=t.loginMethods.includes("github"),m=t.loginMethods.includes("linkedin"),y=t.loginMethods.includes("apple"),f=t.loginMethods.includes("farcaster"),w=t.loginMethods.includes("telegram"),o=t.loginMethods.includes("passkey")):(a=e.emailAuth,i=e.smsAuth,s=e.walletAuth||e.solanaWalletAuth,l=e.googleOAuth,c=e.twitterOAuth,d=e.discordOAuth,g=e.githubOAuth,h=e.spotifyOAuth,u=e.instagramOAuth,p=e.tiktokOAuth,m=e.linkedinOAuth,y=e.appleOAuth,f=e.farcasterAuth,w=e.telegramAuth,o=e.passkeyAuth),e.passkeyAuth&&(o=!0),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(o=!1);let b=[a,i].filter(Boolean),C=[l,c,d,g,h,u,p,m,y,f,w].filter(Boolean),k=[s].filter(Boolean),x=t?.loginMethods?.includes("passkey")??!1,T=e.passkeysForSignupEnabled??!1,A=[o&&(T||x)].filter(Boolean);if(b.length+C.length+k.length+A.length===0)throw Error("You must enable at least one login method");let I=void 0!==t?.appearance?.showWalletLoginFirst?t?.appearance?.showWalletLoginFirst:e.showWalletLoginFirst;I&&0===k.length?(v("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),I=!1):I||C.length+b.length!==0||(v("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),I=!0);let _=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&v("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let E=(({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(vo).filter(bo):e?e.filter(vo).filter(bo):fo.appearance.walletList)({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),S=(({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],n=[];for(let n of(e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`"),e.primary.slice(1)))t.includes(n)?console.warn(`Duplicated login method: ${n}`):t.push(n);for(let r of e.overflow??[])t.includes(r)||n.includes(r)?console.warn(`Duplicated login method: ${r}`):n.push(r);return{primary:t,overflow:n}})({input:t?.loginMethodsAndOrder}),N=t?.intl?.defaultCountry??"US",{chains:M,defaultChain:P}=function({supportedChains:e,defaultChainFromConfig:t}){let n;if(e){if(0===e.length)throw Error("`supportedChains` must contain at least one chain");n=e.map((e=>{if(e.rpcUrls.privyWalletOverride)return e;let t=yi.find((t=>t.id===e.id)),n=t?.rpcUrls.privy?.http[0];return n?xo(e,n):e}))}else n=[...yi];let r=e?n[0]:ci,a=t??r;if(!n.find((e=>e.id===a.id)))throw Error("`defaultChain` must be included in `supportedChains`");return{chains:n,defaultChain:a}}({supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain}),W=!!t?.defaultChain,O=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,U=t?.embeddedWallets?.requireUserPasswordOnCreate,L=t?.embeddedWallets?.createOnLogin,R=O?"all-users":e.embeddedWalletConfig.ethereum.createOnLogin,F=e.embeddedWalletConfig.solana.createOnLogin,D=t?.solanaClusters??[];return e.solanaWalletAuth&&!t?.externalWallets?.solana?.connectors&&console.warn("App configuration has Solana wallet login enabled, but no Solana wallet connectors have been passed to Privy. Make sure to pass Solana connectors to the `config.externalWallets.solana.connectors` field of the `PrivyProvider`"),{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,legacyWalletUiConfig:e.legacyWalletUiConfig,appearance:{logo:t?.appearance?.logo??e.logoUrl,landingHeader:t?.appearance?.landingHeader??fo.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:No({backgroundTheme:t?.appearance?.theme??fo.appearance.theme,accentHex:t?.appearance?.accentColor??e.accentColor??fo.appearance.accentColor}),loginGroupPriority:I?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:E,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.walletAuth??!1,solanaWalletAuth:e.solanaWalletAuth??!1})},loginMethods:{wallet:s,email:a,sms:i,passkey:o,google:l,twitter:c,discord:d,github:g,spotify:h,instagram:u,tiktok:p,linkedin:m,apple:y,farcaster:f,telegram:w},disablePlusEmails:e.disablePlusEmails,loginMethodsAndOrder:S,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.termsAndConditionsUrl,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacyPolicyUrl,requireUsersAcceptTerms:e.requireUsersAcceptTerms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.walletConnectCloudProjectId??fo.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:{}},chains:M,solanaClusters:{"mainnet-beta":D.find((e=>"mainnet-beta"===e.name))?.rpcUrl||"https://api.mainnet-beta.solana.com",testnet:D.find((e=>"testnet"===e.name))?.rpcUrl||"https://api.testnet.solana.com",devnet:D.find((e=>"devnet"===e.name))?.rpcUrl||"https://api.devnet.solana.com"},defaultChain:P,intl:{defaultCountry:N},shouldEnforceDefaultChainOnConnect:W,captchaEnabled:e.captchaEnabled??fo.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??fo.externalWallets.coinbaseWallet.connectionOptions},walletConnect:{enabled:_},solana:{connectors:t?.externalWallets?.solana?.connectors}},embeddedWallets:{requireUserOwnedRecoveryOnCreate:U??(!O&&e.embeddedWalletConfig.requireUserOwnedRecoveryOnCreate),userOwnedRecoveryOptions:O?["user-passcode"]:e.embeddedWalletConfig.userOwnedRecoveryOptions,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:L??t?.embeddedWallets?.ethereum?.createOnLogin??R},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??F},showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforceWalletUis??!0,extendedCalldataDecoding:t?.embeddedWallets?.extendedCalldataDecoding??!1,transactionScanning:{enabled:t?.embeddedWallets?.transactionScanning?.enabled??!1,domain:t?.embeddedWallets?.transactionScanning?.domain??r??"https://auth.privy.io"}},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink},customAuth:O?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:e.telegramAuthConfiguration,passkeysForSignupEnabled:e.passkeysForSignupEnabled},headless:!!t?.headless,render:{standalone:t?._render?.standalone??fo._render.standalone},fundingConfig:e.fundingConfig,fundingMethodConfig:{...t?.fundingMethodConfig??fo.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??fo.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??fo.fundingMethodConfig.moonpay.useSandbox}}}}let Po={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,disablePlusEmails:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{ethereum:{createOnLogin:"off"},solana:{createOnLogin:"off"},requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]},fiatOnRampEnabled:!1,captchaEnabled:!1,captchaSiteKey:"",enforceWalletUis:!1,legacyWalletUiConfig:!1};const Wo=Mo(Po,void 0,!1);let Oo=/*#__PURE__*/c({appConfig:Wo,isServerConfigLoaded:!1});const Uo=({children:e,client:n,clientConfig:r})=>{let[a,i]=o(null),l=s((()=>Mo(a??Po,r,!!a,"undefined"!=typeof window?window.location.origin:void 0)),[a,r]);return d((()=>{if(!a)return;let e=function(e){if(!e)return{};let{appearance:t,supportedChains:n,defaultChain:r,externalWallets:a,...i}=e;return{...i,...n?{supportedChains:n.map((e=>e.id))}:void 0,...r?{defaultChain:r.id}:void 0,...a?{walletConnect:a.walletConnect,coinbaseWallet:a.coinbaseWallet,solana:{connectors:a.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0}}(r),t=function(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t,a=0;a<e.length;a++)n=Math.imul(n^(t=e.charCodeAt(a)),2654435761),r=Math.imul(r^t,1597334677);return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&(r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909)))+(n>>>0)}(JSON.stringify(e)).toString(),i=`privy:sent:${a.id}:${t}`;localStorage.getItem(i)||(n.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(i,"t"))}),[r,a]),d((()=>{a||(async()=>{try{let e=await n.getServerConfig();e.customApiUrl&&n.updateApiUrl(e.customApiUrl),i(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),/*#__PURE__*/t(Oo.Provider,{value:{appConfig:l,isServerConfigLoaded:!!a},children:e})},Lo=()=>{let{appConfig:e}=l(Oo);return e},Ro=()=>{let{isServerConfigLoaded:e}=l(Oo);return e};function Fo(e){/*#__PURE__*/return t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 460 40",...e,children:/*#__PURE__*/t("g",{fill:e.color||"var(--privy-color-foreground)",children:/*#__PURE__*/t("path",{d:"M0 15.4v15.38h4.64V19.96h3.58c2.47 0 3.63-.01 3.77-.02 1-.08 1.49-.15 2.18-.3a9.45 9.45 0 0 0 4.6-2.37c1.66-1.57 2.64-3.87 2.81-6.56.02-.3.02-1.19 0-1.49-.1-1.77-.56-3.35-1.36-4.72A8.84 8.84 0 0 0 15.14.57c-.93-.3-1.75-.43-3.09-.54C11.9.02 10.2 0 5.93 0H0ZM10.85 4c1.85.05 3.1.45 4.16 1.3.22.17.54.49.69.68a5.97 5.97 0 0 1 1.19 3.13c.04.35.04 1.36 0 1.71-.08.68-.23 1.3-.44 1.85a4.8 4.8 0 0 1-1.09 1.68A5.63 5.63 0 0 1 12 15.92c-.6.08-.4.08-4.01.09H4.64V3.98h2.9c1.6 0 3.08 0 3.31.02ZM187.65 5.71v5.72h-.27l-.09-.14a15.9 15.9 0 0 0-1.21-1.73c-.43-.5-1-.95-1.7-1.36-.54-.3-1.05-.5-1.73-.63a8.98 8.98 0 0 0-1.7-.17 8.84 8.84 0 0 0-7.8 4.03 12.95 12.95 0 0 0-2.03 6.39c-.07.98-.06 2.15.02 3.13.2 2.47.87 4.53 2.02 6.25a8.98 8.98 0 0 0 10.22 3.65 6.5 6.5 0 0 0 2.8-1.93c.41-.51.84-1.1 1.1-1.55l.1-.17h.37v3.58h4.38V0h-4.48Zm-5.24 5.54c1.3.14 2.3.6 3.17 1.48.9.9 1.5 2.09 1.85 3.64.36 1.6.39 3.72.06 5.43a8.13 8.13 0 0 1-1.54 3.62 5.1 5.1 0 0 1-3.93 1.96 6.13 6.13 0 0 1-2.32-.31 5.87 5.87 0 0 1-3.33-3.5c-.39-1-.62-2.05-.72-3.32-.03-.32-.04-1.35-.02-1.73.08-1.56.4-2.91.96-4.05a6.2 6.2 0 0 1 1.06-1.58 5.08 5.08 0 0 1 3.6-1.66c.25-.02.9 0 1.16.02ZM210.07 15.39l.01 15.38h4.38l.01-3.57h.37l.09.15c.24.44.84 1.26 1.21 1.7a6.79 6.79 0 0 0 2.57 1.75 9.3 9.3 0 0 0 6.86-.49 9.28 9.28 0 0 0 4.05-4.07A13.05 13.05 0 0 0 231 21.6c.21-1.73.18-3.7-.09-5.32a13.03 13.03 0 0 0-1.5-4.3 9.1 9.1 0 0 0-3.75-3.63 9.15 9.15 0 0 0-4.43-.96 7.46 7.46 0 0 0-2.8.5A7.07 7.07 0 0 0 216 9.7c-.4.52-.82 1.12-1.1 1.59l-.07.14h-.27V0h-4.5Zm11.13-4.14c1.07.1 1.94.44 2.7 1.04a6.1 6.1 0 0 1 1.64 1.98c.43.84.78 2 .94 3.11.15 1.16.16 2.4.02 3.54a9.34 9.34 0 0 1-1.39 4.03 5.33 5.33 0 0 1-2.69 2.15c-.9.3-2.04.38-3.06.2a5.14 5.14 0 0 1-3.45-2.37 6.03 6.03 0 0 1-.45-.8c-.5-1.03-.8-2.2-.92-3.58-.04-.49-.06-.89-.05-1.53.01-.76.05-1.23.13-1.85.38-2.53 1.47-4.38 3.15-5.31a5.46 5.46 0 0 1 2.3-.63 10 10 0 0 1 1.13.02ZM69.05 2.17l-.01 2.77V7.7h-3.36v3.6h3.36v6.8l.01 7.15c.06 1.4.4 2.44 1.1 3.37a5.8 5.8 0 0 0 2.97 2.07c.91.3 1.83.42 2.9.38a8.71 8.71 0 0 0 2.66-.48l-.8-3.7-.38.06a4.96 4.96 0 0 1-2.43-.06c-.33-.1-.56-.25-.8-.49-.4-.41-.6-.88-.7-1.67-.02-.2-.02-.62-.03-6.82v-6.6h4.73V7.7h-4.73V2.16h-4.49ZM133.34 2.17V7.7h-3.39v3.6h3.38v6.9l.01 7.17a5.66 5.66 0 0 0 2.36 4.49c.85.6 2.03 1.03 3.26 1.17.85.1 2.03.05 2.81-.1.3-.06.75-.18 1-.26l.2-.06v-.05l-.81-3.67-.37.06a4.99 4.99 0 0 1-1.8.09c-.85-.13-1.32-.4-1.7-.97a2.63 2.63 0 0 1-.39-1.04c-.06-.4-.06 0-.06-7.1V11.3h4.7V7.7h-4.7l-.01-2.77V2.16h-4.49ZM293.41 2.36a14.56 14.56 0 0 0-13.7 16.07 14.59 14.59 0 0 0 21.86 11.08 14.5 14.5 0 0 0 7.11-14.07 14.61 14.61 0 0 0-6.53-10.73 14.49 14.49 0 0 0-8.74-2.35ZM350.8 2.36a10.17 10.17 0 0 0-7.56 4.2c-.16.2-.45.63-.58.83l-.05.1h-.47l-.01-4.36h-7.36v36.4h7.82V27.27h.49l.05.07a11.3 11.3 0 0 0 7.49 4.15 10.52 10.52 0 0 0 9.38-4.1c1.66-2.1 2.73-4.9 3.07-8.06.1-.87.13-1.4.13-2.37 0-.8 0-1.1-.07-1.76a15.95 15.95 0 0 0-3.23-8.72 12.8 12.8 0 0 0-1.85-1.84 10.49 10.49 0 0 0-7.26-2.28Zm-.94 6.05c1.27.15 2.33.65 3.2 1.5.98.96 1.67 2.31 2.03 4 .34 1.57.38 3.68.12 5.39a9.78 9.78 0 0 1-1.04 3.25c-.14.25-.44.69-.6.89a5.35 5.35 0 0 1-4.31 2.07 5.25 5.25 0 0 1-4.41-1.9 7.35 7.35 0 0 1-1.26-2.32 14.09 14.09 0 0 1-.62-4.83c.05-1.98.38-3.53 1.02-4.85a5.63 5.63 0 0 1 2.5-2.65c.66-.34 1.3-.5 2.14-.58.18-.02 1.04 0 1.23.03ZM363.63 3.1l-.01 3.2v3.16h1.43c1.26.01 1.44.02 1.54.04.42.09.66.28.79.62.08.23.08.08.08 2.96a911.57 911.57 0 0 1 .03 10.18v7.54h7.82v-7.4l.01-7.83c.03-.94.11-1.63.27-2.28.46-1.9 1.54-2.93 3.35-3.23.52-.08.2-.08 5-.08h4.4V3.08h-3.1c-3.48 0-3.91.01-4.67.1-1.83.2-3.04.79-3.96 1.88-.5.6-.9 1.32-1.26 2.26l-.06.17h-.46V3.09h-5.6c-4.46 0-5.6 0-5.6.02ZM390.8 16.95V30.8h3.87l3.86-.01V3.09h-7.73ZM400.6 3.1l-.01.4v.38l4.66 13.4 4.69 13.47.02.05h10.3l.03-.05 4.67-13.45 4.67-13.4V3.1h-7.43l-6.7 19.26h-.5l-3.28-9.5-3.31-9.64-.05-.12h-3.88l-3.88.01ZM430.98 3.1c-.01 0-.02.19-.02.4v.39l5.08 14.59c2.8 8.02 5.08 14.6 5.08 14.61.01.02-.22.02-4.8.02h-4.82v6.42h4.95c5.09 0 5.23 0 5.87-.06 3.15-.28 5.29-1.63 6.63-4.15.28-.55.44-.95.87-2.16L459 6.78l1-2.89v-.8h-7.43l-6.69 19.26h-.5l-3.27-9.46-3.31-9.64-.06-.16h-3.88l-3.88.01ZM36.57 7.36c-1.36.1-2.6.6-3.62 1.45a5.65 5.65 0 0 0-1.67 2.42l-.05.13H31V7.7h-4.35v23.08h4.5v-7.3c0-8 0-7.34.08-7.82a4.89 4.89 0 0 1 2.06-3.18c.83-.58 1.74-.89 2.87-.98a11.87 11.87 0 0 1 2.8.25H39v-4.3l-.21-.02c-.61-.07-1.74-.1-2.22-.07ZM51.08 7.41c-2.33.12-4.3.84-5.95 2.16a9.89 9.89 0 0 0-2.03 2.2 12.5 12.5 0 0 0-2 5.78 18.04 18.04 0 0 0 0 3.65 12.13 12.13 0 0 0 2.26 6.05 9.74 9.74 0 0 0 5 3.52c2.11.64 4.7.64 6.8 0a9.78 9.78 0 0 0 4.88-3.37c1.38-1.78 2.19-4 2.4-6.58.13-1.46.06-3.06-.18-4.42a11.24 11.24 0 0 0-3.58-6.6 10 10 0 0 0-5.75-2.35c-.56-.06-1.31-.07-1.85-.04Zm1.42 3.78c.88.1 1.62.34 2.28.75a6.13 6.13 0 0 1 1.99 2.15 10.31 10.31 0 0 1 1.2 5c.02 1.23-.12 2.44-.42 3.51a7.14 7.14 0 0 1-1.81 3.32c-.61.6-1.2.98-1.95 1.24a6 6 0 0 1-2 .3 5.7 5.7 0 0 1-2.72-.6 5 5 0 0 1-1.28-.94A7.1 7.1 0 0 1 46 22.73c-.57-1.99-.6-4.46-.08-6.5a7.24 7.24 0 0 1 2.03-3.67 5.13 5.13 0 0 1 3.35-1.4 11 11 0 0 1 1.2.03ZM92.05 7.4c-.96.06-1.56.15-2.3.33a9.62 9.62 0 0 0-6.09 4.66 13.5 13.5 0 0 0-1.71 7c0 .83 0 1.04.06 1.6.16 1.77.58 3.32 1.29 4.7A9.72 9.72 0 0 0 90.28 31c1.84.37 4.08.32 5.85-.13a9.07 9.07 0 0 0 5.02-3.1A7.64 7.64 0 0 0 102.5 25l-2.11-.39-2.11-.38-.08.13a4.72 4.72 0 0 1-2.35 2.55 6.3 6.3 0 0 1-2.23.58c-.29.03-1.13.03-1.44 0a6.35 6.35 0 0 1-3.02-1.04 5.93 5.93 0 0 1-2.02-2.43 8.44 8.44 0 0 1-.72-3.18v-.26h16.38v-.81c0-1.83-.06-2.76-.25-3.87-.2-1.22-.53-2.24-1.05-3.28a8.9 8.9 0 0 0-2.66-3.26 10.1 10.1 0 0 0-5.34-1.94 18.3 18.3 0 0 0-1.46-.03Zm1.3 3.75c1.2.13 2.19.55 3.05 1.3a5.8 5.8 0 0 1 1.78 2.96c.13.51.21 1.17.21 1.66v.15H86.43v-.12c.08-.97.3-1.78.72-2.61.5-1 1.2-1.8 2.14-2.42a5.32 5.32 0 0 1 2.9-.95c.2-.01.97 0 1.17.03ZM116.79 7.41c-2 .1-3.73.65-5.22 1.65a10.7 10.7 0 0 0-4.25 6.06 16.1 16.1 0 0 0-.5 5.8c.2 2.17.84 4.13 1.88 5.76.58.9 1.32 1.73 2.15 2.4a9.37 9.37 0 0 0 3.6 1.8 12.06 12.06 0 0 0 3.92.34 10.2 10.2 0 0 0 3.84-.95 8.31 8.31 0 0 0 4.76-6.75l.01-.04h-4.37l-.05.16a4.87 4.87 0 0 1-4.24 3.75c-.59.07-1.32.06-1.93-.05a5.47 5.47 0 0 1-3.5-2.27c-.56-.75-1-1.73-1.26-2.79a13.8 13.8 0 0 1-.16-5.24 7.77 7.77 0 0 1 2.1-4.3 5.48 5.48 0 0 1 2.15-1.3 6.4 6.4 0 0 1 3.89.1c.59.21 1.03.5 1.5.96a5.32 5.32 0 0 1 1.46 2.5l.04.15h4.37v-.06a8.22 8.22 0 0 0-5.31-6.94 10.98 10.98 0 0 0-4.88-.74ZM156.2 7.41a9.87 9.87 0 0 0-6 2.29 11.02 11.02 0 0 0-3.41 5.43c-.52 1.78-.68 3.9-.48 5.97.17 1.8.63 3.38 1.37 4.8a9.68 9.68 0 0 0 5.91 4.86c1.65.48 3.63.61 5.53.36 3.72-.49 6.55-2.62 7.56-5.69.12-.39.13-.42.1-.43-.02 0-4.13-.75-4.19-.75-.03 0-.04 0-.1.16-.18.42-.45.9-.72 1.22-.16.2-.49.53-.7.7-.67.54-1.5.9-2.43 1.08-.48.08-.83.11-1.41.11-.64 0-1.07-.04-1.6-.15a5.76 5.76 0 0 1-3.93-2.83 8 8 0 0 1-.99-3.79v-.16h16.38v-1.11l-.02-1.43c-.1-2.25-.53-4-1.35-5.59a9.24 9.24 0 0 0-6.18-4.75c-1.04-.26-2.2-.36-3.33-.3Zm1.45 3.74a5.35 5.35 0 0 1 3.66 1.94 6.1 6.1 0 0 1 1.38 4.01v.12h-11.97v-.06c0-.02 0-.14.02-.25a6.6 6.6 0 0 1 2.15-4.32 5.73 5.73 0 0 1 3.5-1.46c.25-.02 1 0 1.26.02ZM233.58 7.82l8.37 23.22a49.22 49.22 0 0 1-.67 1.9 5.36 5.36 0 0 1-1.14 1.8c-.41.4-.82.58-1.48.69-.27.04-1.03.03-1.35 0a8.05 8.05 0 0 1-1.1-.23l-1.08 3.67c0 .02.32.14.66.22.83.21 1.57.29 2.56.28.56-.01.8-.03 1.24-.1 2.71-.4 4.66-2.09 5.86-5.08l9.64-26.44c0-.02-4.82-.06-4.83-.05l-2.93 8.96-2.91 8.94h-.24l-.22-.65-2.91-8.95-2.7-8.3H233.53ZM293.05 35.8c-1.18.04-1.93.09-2.8.16-2.52.24-4.53.69-5.43 1.23-.7.41-.76.86-.2 1.28.88.66 3.29 1.19 6.36 1.4a48.55 48.55 0 0 0 5.75.05c3.47-.19 6.24-.78 7.11-1.5.22-.19.3-.34.3-.53 0-.1 0-.12-.04-.22-.35-.69-2.32-1.3-5.25-1.63a41.09 41.09 0 0 0-5.8-.24Zm0 0"})})})}let Do=/*#__PURE__*/Nt.div.withConfig({displayName:"TermsAndConditionsContainer",componentId:"sc-bdb69ecc-0"})(["margin-top:16px;font-size:13px;text-align:center;color:var(--privy-color-foreground-3);&& > a{color:var(--privy-color-accent);}"]);function zo({app:{legal:{privacyPolicyUrl:n,termsAndConditionsUrl:r,requireUsersAcceptTerms:a}},alwaysShowImplicitConsent:i}){let o=!(!n||!r);return a&&!i||!r&&!n?
|
|
1
|
+
import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createStore as r}from"mipd";import a,{useRef as i,useState as o,useMemo as s,useContext as l,createContext as c,useEffect as d,useCallback as p,useReducer as h,forwardRef as u}from"react";import*as m from"react-device-detect";import{isMobile as g,isIOS as y,isSafari as f,isAndroid as w}from"react-device-detect";import{getAddress as v,toHex as b,isAddress as C}from"viem/utils";import{a as k,c as x,f as T,p as A,b as I,d as _,e as E,g as S,h as N,i as M,j as P,k as W,o as O,P as U,l as L,m as R,q as F,r as D,s as z,t as B,v as $,w as j,x as V,y as H,z as q,A as K,B as Z,n as G,C as Y,D as J,E as X,u as Q,F as ee,G as te,H as ne,J as re,K as ae,L as ie,M as oe,N as se,O as le,Q as ce,R as de,S as pe,T as he,U as ue,V as me,W as ge,X as ye,Y as fe,Z as we,_ as ve,$ as be,a0 as Ce,a1 as ke,a2 as xe,a3 as Te,a4 as Ae,a5 as Ie,a6 as _e,a7 as Ee,a8 as Se,a9 as Ne,aa as Me,ab as Pe,ac as We,ad as Oe,ae as Ue,af as Le,ag as Re,ah as Fe,ai as De,aj as ze,ak as Be,al as $e,I as je}from"./internal-context-O3TPYUku.mjs";import{createPublicClient as Ve,http as He,isHex as qe,toHex as Ke,getAddress as Ze,formatEther as Ge,formatUnits as Ye,parseEther as Je,createWalletClient as Xe,custom as Qe,publicActions as et,encodeFunctionData as tt,isAddress as nt,hexToString as rt,decodeFunctionData as at,decodeAbiParameters as it}from"viem";import{v4 as ot}from"uuid";import*as st from"jose";import{base64url as lt}from"jose";import ct from"eventemitter3";import{CoinbaseWalletSDK as dt}from"@coinbase/wallet-sdk";import{ProviderErrors as pt,countryCodesAndNumbers as ht,validatePhoneNumber as ut,phoneNumberTypingFormatter as mt,getPlaceholderPhoneNumber as gt,getCountryCallingCode as yt,getPhoneCountryCodeAndNumber as ft,formatPhoneNumber as wt,toObjectKeys as vt,formatWalletAddress as bt,getCoinbaseOnRampUrl as Ct,chainToMoonpayCurrency as kt,isSupportedChainIdForMoonpay as xt,isSupportedChainIdForCoinbaseOnramp as Tt,SolanaClient as At,formatTokenAmount as It,formatWeiAmount as _t,lastFourDigits as Et}from"@privy-io/js-sdk-core";import{Turnstile as St}from"@marsidev/react-turnstile";import{styled as Nt,css as Mt,keyframes as Pt,createGlobalStyle as Wt}from"styled-components";import Ot from"tinycolor2";import Ut from"@heroicons/react/24/outline/ArrowLeftIcon";import Lt from"@heroicons/react/24/outline/ArrowRightIcon";import Rt from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Ft from"@heroicons/react/24/outline/XMarkIcon";import Dt from"@heroicons/react/24/outline/CheckIcon";import zt from"@heroicons/react/24/outline/Square2StackIcon";import Bt from"@heroicons/react/24/outline/WalletIcon";import{create as $t}from"zustand";import{EthereumProvider as jt,OPTIONAL_EVENTS as Vt,OPTIONAL_METHODS as Ht}from"@walletconnect/ethereum-provider";import qt from"@heroicons/react/24/outline/UserCircleIcon";import Kt from"@heroicons/react/24/outline/EnvelopeIcon";import Zt from"@heroicons/react/20/solid/CheckIcon";import Gt from"@heroicons/react/24/outline/PhoneIcon";import Yt from"@heroicons/react/24/outline/ExclamationTriangleIcon";import Jt from"@heroicons/react/24/outline/ExclamationCircleIcon";import Xt from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import Qt from"@heroicons/react/24/solid/DocumentCheckIcon";import en from"@heroicons/react/24/solid/XCircleIcon";import tn from"fast-password-entropy";import*as nn from"secure-password-utilities";import{DEFAULT_WORDLIST as rn}from"secure-password-utilities/wordlists";import an from"@heroicons/react/24/outline/LockClosedIcon";import on from"@heroicons/react/24/outline/PencilSquareIcon";import sn from"@heroicons/react/24/solid/CheckCircleIcon";import ln from"@heroicons/react/24/outline/ArrowPathIcon";import cn from"@heroicons/react/24/outline/EyeIcon";import dn from"@heroicons/react/24/outline/EyeSlashIcon";import pn from"@heroicons/react/24/outline/KeyIcon";import hn from"@heroicons/react/24/outline/ArrowDownTrayIcon";import un from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import mn from"@heroicons/react/24/outline/DocumentDuplicateIcon";import gn from"@heroicons/react/24/solid/LockClosedIcon";import yn from"@heroicons/react/24/outline/ShieldCheckIcon";import fn from"qrcode";import wn from"@heroicons/react/24/outline/FingerPrintIcon";import vn from"@heroicons/react/24/outline/ChevronRightIcon";import bn from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import Cn from"@heroicons/react/24/outline/ChevronDownIcon";import kn from"@heroicons/react/24/outline/CalendarIcon";import{Transition as xn,Dialog as Tn,TransitionChild as An,DialogPanel as In,Menu as _n,MenuButton as En,MenuItems as Sn,MenuItem as Nn}from"@headlessui/react";import Mn from"@heroicons/react/24/outline/CheckCircleIcon";import Pn from"@heroicons/react/24/outline/InformationCircleIcon";import Wn from"@heroicons/react/24/outline/CreditCardIcon";import On from"@heroicons/react/24/outline/QrCodeIcon";import Un from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import Ln from"@heroicons/react/24/outline/GlobeAltIcon";import{ofetch as Rn}from"ofetch";import{ChevronDownIcon as Fn,ArrowRightIcon as Dn}from"@heroicons/react/24/outline";import zn from"@heroicons/react/24/outline/ClipboardDocumentIcon";import Bn from"@heroicons/react/24/outline/CloudArrowUpIcon";import $n from"@heroicons/react/24/outline/NoSymbolIcon";import jn from"@heroicons/react/24/outline/ClockIcon";import Vn from"@heroicons/react/24/outline/TrashIcon";import Hn from"@heroicons/react/24/solid/CheckBadgeIcon";import qn from"@heroicons/react/24/solid/IdentificationIcon";import Kn from"@heroicons/react/24/outline/MinusCircleIcon";import Zn from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import Gn from"@heroicons/react/24/solid/ShieldCheckIcon";import Yn from"js-cookie";class Jn{async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");try{return await this.api.post(x,{token:this.meta.token})}catch(e){throw T(e)}}async link(){throw Error("Unimplemented")}constructor(e){this.meta={token:e}}}function Xn(e){return e?{"privy-ui":"t"}:void 0}class Qn{async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new k("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(A,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new k("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(I,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw T(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new k("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new k("Email must be set when initialzing authentication.");let r=Xn(n);try{return await this.api.post(_,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw T(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class er extends Qn{async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new k("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(E,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw T(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class tr{get(e){let t=localStorage.getItem(e);return null===t?void 0:JSON.parse(t)}put(e,t){void 0!==t?localStorage.setItem(e,JSON.stringify(t)):this.del(e)}del(e){localStorage.removeItem(e)}getKeys(){return Object.entries(localStorage).map((([e])=>e))}}function nr(){try{let e="privy:__session_storage__test",t=new tr;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var rr="undefined"!=typeof window&&window.localStorage?new tr:new class{get(e){return this._cache[e]}put(e,t){void 0!==t?this._cache[e]=t:this.del(e)}del(e){delete this._cache[e]}getKeys(){return Object.keys(this._cache)}constructor(){this._cache={}}};const ar=e=>e.isApexWallet?"Apex Wallet":e.isAvalanche?"Core Wallet":e.isBackpack?"Backpack":e.isBifrost?"Bifrost Wallet":e.isBitKeep?"BitKeep":e.isBitski?"Bitski":e.isBlockWallet?"BlockWallet":e.isBraveWallet?"Brave Wallet":e.isClover?"Clover":e.isCoin98?"Coin98 Wallet":e.isCoinbaseWallet?"Coinbase Wallet":e.isDawn?"Dawn Wallet":e.isDefiant?"Defiant":e.isDesig?"Desig Wallet":e.isEnkrypt?"Enkrypt":e.isExodus?"Exodus":e.isFordefi?"Fordefi":e.isFrame?"Frame":e.isFrontier?"Frontier Wallet":e.isGamestop?"GameStop Wallet":e.isHaqqWallet?"HAQQ Wallet":e.isHyperPay?"HyperPay Wallet":e.isImToken?"ImToken":e.isHaloWallet?"Halo Wallet":e.isKuCoinWallet?"KuCoin Wallet":e.isMathWallet?"MathWallet":e.isNovaWallet?"Nova Wallet":e.isOkxWallet||e.isOKExWallet?"OKX Wallet":e.isOneInchIOSWallet||e.isOneInchAndroidWallet?"1inch Wallet":e.isOneKey?"OneKey Wallet":e.isOpera?"Opera":e.isPhantom||"isPhantom"in e?"Phantom":e.isPortal?"Ripio Portal":e.isRabby?"Rabby Wallet":e.isRainbow?"Rainbow":e.isSafePal?"SafePal Wallet":e.isStatus?"Status":e.isSubWallet?"SubWallet":e.isTalisman?"Talisman":e.isTally||e.isTaho?"Taho":e.isTokenPocket?"TokenPocket":e.isTokenary?"Tokenary":e.isTrust||e.isTrustWallet?"Trust Wallet":e.isTTWallet?"TTWallet":e.isXDEFI?"XDEFI Wallet":e.isZeal?"Zeal":e.isZerion?"Zerion":e.isMetaMask?"MetaMask":void 0,ir=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==ar(e))return!1;if(e.providers)for(let t of e.providers)if(!ir(t))return!1;return!0},or=()=>{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},sr=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new S(`Unsupported chainId ${e}`,4901);return Ve({transport:He(lr(i,n,r.appId)),chain:i})},lr=(e,t,n)=>{let r,a=e.id,i=Number(e.id);if(e.rpcUrls.privyWalletOverride&&e.rpcUrls.privyWalletOverride.http[0])r=e.rpcUrls.privyWalletOverride.http[0];else if(t.rpcUrls&&t.rpcUrls[i])r=t.rpcUrls[i];else if(e.rpcUrls.privy?.http[0]){let t=new URL(e.rpcUrls.privy.http[0]);t.searchParams.append("privyAppId",n),r=t.toString()}else r=e.rpcUrls.public?.http[0]?e.rpcUrls.public.http[0]:e.rpcUrls.default?.http[0];if(!r)throw new S(`No RPC url found for ${a}`);return r},cr=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,}))$/),dr=(e,t=3,n=4,r="ethereum")=>{if(!e)return"";let a="ethereum"===r?2:0;return t+n+a+3>=e.length?e:`${e.slice(0,a+t)}...${e.slice(e.length-n,e.length)}`},pr=(e,t=3,n=4)=>dr(e,t,n,"solana"),hr=e=>new Promise((t=>setTimeout(t,e)));const ur=(e,t={})=>{let n=t.delayMs||150,r=t.maxAttempts||270;return new Promise((async(a,i)=>{let o=!1,s=0;for(;!o&&s<r;){if(t.abortSignal?.aborted)return;e().then((e=>{o=!0,a(e)}),((...e)=>{o=!0,i(...e)})),s+=1,await hr(n)}o||i(Error("Exceeded max attempts before resolving function"))}))},mr=(e,t,n={},r={})=>{let a=new URL(t,e);for(let[e,t]of Object.entries(n))void 0!==t&&a.searchParams.set(e,t);let i=Object.entries(r);if(i.length>0){let e=new URLSearchParams;for(let[t,n]of i)e.append(t,n);a.hash=e.toString()}return a.href},gr=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),yr=e=>"string"==typeof e?e:"0x"+e.toString(16);async function fr({store:e,walletList:t,externalWalletConfig:n,walletChainType:r,timeout:a=3e3}){let i=!1,o=window;return new Promise((s=>{function l(){if(i)return;i=!0,window.removeEventListener("ethereum#initialized",l);let a=e.getProviders();console.debug("Detected injected providers:",a.map((e=>e.info)));let o=[];for(let e of a)t.includes("coinbase_wallet")&&"com.coinbase.wallet"===e.info.rdns||"solana-only"===r&&"app.phantom"===e.info.rdns||o.push({type:e.info.name.toLowerCase().replace(/\s/g,"_"),eip6963InjectedProvider:e});if("solana-only"!==r)for(let e of function(){let e=window,t=e.ethereum;if(!t)return[];let n=[];if(t.providers?.length)for(let e of t.providers)e&&n.push(e);return n.push(e.ethereum),n}()){let t=ar(e);if(!a.some((e=>e.info.name===t))){if(ir(e,!0)&&!o.find((e=>"metamask"===e.type))){o.push({type:"metamask",legacyInjectedProvider:e});continue}if("Phantom"===t&&!o.find((e=>"phantom"===e.type))){o.push({type:"phantom",legacyInjectedProvider:e});continue}if("Coinbase Wallet"===t&&!o.find((e=>"coinbase_wallet"===e.type&&"smartWalletOnly"!==n.coinbaseWallet?.connectionOptions))){o.push({type:"coinbase_wallet",legacyInjectedProvider:e});continue}o.find((e=>"unknown_browser_extension"===e.type))||o.push({type:"unknown_browser_extension",legacyInjectedProvider:e})}}s(o)}o.ethereum?l():(window.addEventListener("ethereum#initialized",l,{once:!0}),setTimeout((()=>{l()}),a))}))}function wr(e){return`eip155:${String(Number(e))}`}const vr=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new S(`Unsupported chainId ${e}`,4901);return lr(i,n,r)},br=e=>{let t={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},n=e.types.EIP712Domain??Object.entries(e.domain).map((([e,n])=>{if(null!=n&&"string"==typeof e&&e in t)return{name:e,type:t[e]}})).filter((e=>void 0!==e));return{...e,types:{...e.types,EIP712Domain:n}}};const Cr=["c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96","4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0","225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f","1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369","c03dfee351b6fcc421b4494ea33b9d4b92a984f87aa76d1663bb28705e95034a","ecc4036f814562b41a5268adc86270fba1365471402006302e70169465b7ac18","bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6","74f8092562bd79675e276d8b2062a83601a4106d30202f2d509195e30e19673d","afbd95522f4041c71dd4f1a065f971fd32372865b416f95a0b1db759ae33f2a7","f2436c67184f158d1beda5df53298ee84abfc367581e4505134b5bcf5f46697d","84b43e8ddfcd18e5fcb5d21e7277733f9cccef76f7d92c836d0e481db0c70c04","0b415a746fb9ee99cce155c2ceca0c6f6061b1dbca2d722b3ba16381d0562150","38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662","9414d5a85c8f4eabc1b5b15ebe0cd399e1a2a9d35643ab0ad22a6e4a32f596f0","c286eebc742a537cd1d6818363e9dc53b21759a1e8e5d9b263d0c03ec7703576","8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4","e9ff15be73584489ca4a66f64d32c4537711797e30b6660dbcb71ea72a42b1f4","f5b4eeb6015d66be3f5940a895cbaa49ef3439e518cd771270e6b553b48f31d2","138f51c8d00ac7b9ac9d8dc75344d096a7dfe370a568aa167eabc0a21830ed98","47bb07617af518642f3413a201ec5859faa63acb1dd175ca95085d35d38afb83","7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26","8308656f4548bb81b3508afe355cfbb7f0cb6253d1cc7f998080601f838ecee3","031f0187049b7f96c6f039d1c9c8138ff7a17fd75d38b34350c7182232cc29aa","2c81da3add65899baeac53758a07e652eea46dbb5195b8074772c62a77bbf568","dd43441a6368ec9046540c46c5fdc58f79926d17ce61a176444568ca7c970dcd","2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01","b956da9052132e3dabdcd78feb596d5194c99b7345d8c4bd7a47cabdcb69a25f","0e4915107da5b3408b38e248f7a710f4529d54cd30e9d12ff0eb886d45c18e92","719bd888109f5e8dd23419b20e749900ce4d2fc6858cf588395f19c82fd036b3","942d0e22a7e6b520b0a03abcafc4dbe156a1fc151876e3c4a842f914277278ef","8ff6eccefefa7506339201bc33346f92a43118d6ff7d6e71d499d8187a1c56a2","07f99a5d9849bb049d74830012b286f8b238e72b0337933ef22b84947409db80","8821748c25de9dbc4f72a691b25a6ddad9d7df12fa23333fd9c8b5fdc14cc819","bdc9433ffdaee55d31737d83b931caa1f17e30666f5b8e03eea794bac960eb4a","cbe13eb482c76f1fa401ff4c84d9acd0b8bc9af311ca0620a0b192fb28359b4e","94f785c0c8fb8c4f38cd9cd704416430bcaa2137f27e1468782d624bcd155a43","2cca8c1b0bea04ba37dee4017991d348cdb7b826804ab2bd31073254f345b715","14e5d957c6eb62d3ee8fc6239703ac2d537d7e3552154836ca0beef775f630bc","576c90ceaea34f29ff0104837cf2b2e23d201be43be1433feeb18d375430e1fd","49bb9d698dbdf2c3d4627d66f99dd9fe90bba1eec84b143f56c64a51473c60bd","19418ecfd44963883e4d6abca1adeb2036f3b5ffb9bee0ec61f267a9641f878b","5b8e33346dfb2a532748c247876db8d596734da8977905a27b947ba1e2cf465b","d23de318f0f56038c5edb730a083216ff0cce00c1514e619ab32231cc9ec484b","50df7da345f84e5a79aaf617df5167335a4b6751626df2e8a38f07029b3dde7b","9751385960bca290c13b443155288f892f62ee920337eda8c5a8874135daaea8","6464873279d46030c0b6b005b33da6be5ed57a752be3ef1f857dc10eaf8028aa","41f20106359ff63cf732adf1f7dc1a157176c9b02fd266b50da6dcc1e9b86071","14e7176536cb3706e221daaa3cfd7b88b7da8c7dfb64d1d241044164802c6bdd","a0e04f1086aac204d4ebdd5f985c12ed226cd0006323fd8143715f9324da58d1","971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709","18388be9ac2d02726dbac9777c96efaac06d744b2f6d580fccdd4127a6d01fd1","15c8b91ade1a4e58f3ce4e7a0dd7f42b47db0c8df7e0d84f63eb39bcb96c4e0f","541d5dcd4ede02f3afaf75bf8e3e4c4f1fb09edb5fa6c4377ebf31c2785d9adf"];function kr(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let xr="WALLETCONNECT_DEEPLINK_CHOICE";function Tr(e){return e.startsWith("http://")||e.startsWith("https://")}function Ar(e,t){if(Tr(e))return Ir(e,t);let n=e;return n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function Ir(e,t){if(!Tr(e))return Ar(e,t);let n=e;return n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function _r(e,t){window.open(e,t,"noreferrer noopener")}class Er{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}class Sr{get meta(){return this._meta}async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.channelToken)throw new k("Auth flow must be initialized first");try{let e=await this.api.post(N,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new k("No response from authentication");return e}catch(e){throw T(e)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");try{return await this.api.post(M,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw T(e)}}async _startChannelOnce(){if(!this.api)throw new k("Auth flow has no API instance");let e=await this.api.post(P,{token:this.captchaToken});g&&!y&&e.connect_uri&&_r(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new k("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.channelToken)throw new k("Auth flow must be initialized first");let e=await this.api.get(W,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new Er(this._startChannelOnce.bind(this)),this.pollForReady=new Er(this._pollForReady.bind(this)),this._meta.disableSignup=t}}const Nr="https://auth.privy.io",Mr=1400,Pr=2500,Wr=4e3,Or="2.6.4",Ur="privy:token",Lr="privy-token",Rr="privy:refresh_token",Fr="privy:pat",Dr="privy:id_token",zr="privy-id-token",Br="privy-session",$r="privy:caid",jr=e=>`privy:guest:${e}`,Vr=e=>`privy:cross-app:${e}`,Hr="privy:state_code",qr="privy:code_verifier",Kr="privy:headless_oauth",Zr="privy:oauth_disable_signup",Gr=e=>`privy:wallet:${e}`,Yr="privy:connectors",Jr="privy:connections",Xr=12e4,Qr=3e4,ea="https://api.moonpay.com/v1",ta="https://api.moonpay.com/v1",na="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",ra="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";function aa(e){return crypto.getRandomValues(new Uint8Array(e))}function ia(){return lt.encode(aa(36))}function oa(){return ia()}async function sa(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return lt.encode(t)}}class la{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new k("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new k("User denied confirmation during OAuth flow");let e=function(){let e=rr.get(qr);if(!e)throw new k("Authentication error.");return e}();try{let t=await this.api.post(O,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return rr.del(qr),rr.del(Kr),rr.del(Zr),t}catch(e){let t=T(e);if(t.privyErrorCode)throw new k(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new k("Invalid code during oauth flow.",void 0,U.OAUTH_USER_DENIED);throw new k("Invalid code during OAuth flow.",void 0,U.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new k("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new k("User denied confirmation during OAuth flow");let e=rr.get(qr);if(!e)throw new k("Authentication error.");try{let t=await this.api.post(L,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return rr.del(qr),t}catch(e){throw T(e)}}async getAuthorizationUrl(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.provider)throw new k("Provider must be set when initializing OAuth authentication.");let e=ia();rr.put(qr,e);let t=oa();rr.put(Hr,t);let n=await sa(e);this.meta.withPrivyUi||rr.put(Kr,!0),this.meta.disableSignup&&rr.put(Zr,!0);let r=Xn(this.meta.withPrivyUi);try{return await this.api.post(R,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...r}})}catch(e){throw T(e)}}constructor(e){this.meta=e}}function ca(e){return e.charAt(0).toUpperCase()+e.slice(1)}const da=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 24 24",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]}),pa=({style:n,...r})=>/*#__PURE__*/e("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 71 55",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("g",{clipPath:"url(#clip0)",children:/*#__PURE__*/t("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"})}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0",children:/*#__PURE__*/t("rect",{width:"71",height:"55",fill:"white"})})})]}),ha=({style:e,...n})=>/*#__PURE__*/t("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"24",y:"24",viewBox:"0 0 98 96",style:{height:"24px",...e},...n,children:/*#__PURE__*/t("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"})}),ua=({style:e})=>/*#__PURE__*/t(Ln,{style:{color:"var(--privy-color-error)",...e}}),ma=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...n},...r,children:[/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]});function ga(n){/*#__PURE__*/return e("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",...n,children:[/*#__PURE__*/e("defs",{children:[/*#__PURE__*/e("linearGradient",{id:"b",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#3771c8"}),/*#__PURE__*/t("stop",{stopColor:"#3771c8",offset:".128"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#60f",stopOpacity:"0"})]}),/*#__PURE__*/e("linearGradient",{id:"a",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".1",stopColor:"#fd5"}),/*#__PURE__*/t("stop",{offset:".5",stopColor:"#ff543e"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#c837ab"})]}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]}),/*#__PURE__*/t("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)"}),/*#__PURE__*/t("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)"}),/*#__PURE__*/t("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"})]})}function ya({style:e,...n}){/*#__PURE__*/return t("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},...n,children:/*#__PURE__*/t("g",{fill:"#0077b5",strokeWidth:"1",strokeLinecap:"butt",strokeLinejoin:"miter",strokeMiterlimit:"10",style:{mixBlendMode:"normal"},children:/*#__PURE__*/t("g",{transform:"scale(5.12,5.12)",children:/*#__PURE__*/t("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"})})})})}function fa(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 496 512",...n,children:[/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]})}function wa(n){/*#__PURE__*/return e("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,...n,children:[/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]})}const va=({style:e,...n})=>/*#__PURE__*/t("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},...n,children:/*#__PURE__*/t("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"})});let ba={google:{name:"Google",component:ma},discord:{name:"Discord",component:pa},github:{name:"Github",component:ha},linkedin:{name:"LinkedIn",component:ya},twitter:{name:"Twitter",component:va},spotify:{name:"Spotify",component:fa},instagram:{name:"Instagram",component:ga},tiktok:{name:"Tiktok",component:wa},apple:{name:"Apple",component:da}};const Ca=e=>e in ba?ba[e]:{name:"Unknown",component:ua};function ka(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),n=e.get("privy_oauth_state"),r=e.get("privy_oauth_provider");if(!t||!n||!r)return{inProgress:!1};let a=!1;try{a=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:n,provider:r,withPrivyUi:!rr.get(Kr),popupFlow:null!==window.opener&&a,disableSignup:!!rr.get(Zr)}}function xa(){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"),rr.del(Hr),window.history.replaceState({},"",e)}class Ta{async initRegisterFlow(e){if(!this.api)throw new k("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new k("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new k("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new k("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new k("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(F,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new k("Passkey request timed out or rejected by user.",void 0,U.PASSKEY_NOT_ALLOWED);throw T(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new k("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new k("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let n=await e.startAuthentication(this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t}));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(D,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new k("Passkey request timed out or rejected by user.",void 0,U.PASSKEY_NOT_ALLOWED);throw T(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new k("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new k("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,n=await e.startRegistration(this._transformInitLinkOptionsToCamelCase(t));return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(z,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new k("Passkey request timed out or rejected by user.",void 0,U.PASSKEY_NOT_ALLOWED);throw T(e)}}async _initRegisterOnce(e){if(!this.api)throw new k("Auth flow has no API instance");let t=Xn(e);return await this.api.post(B,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new k("Auth flow has no API instance");let t=Xn(e);return await this.api.post($,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new k("Auth flow has no API instance");return await this.api.post(j,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret}}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},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}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.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}}_transformAuthenticationResponseToSnakeCase(e){return{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}}constructor({captchaToken:e,setPasskeyAuthState:t}){this.authenticateForRegistration=!1,this.initRegisterOnce=new Er(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new Er(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Er(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}const Aa=({address:e,chainId:t,nonce:n})=>`${window.location.host} wants you to sign in with your Ethereum account:\n${e}\n\nBy signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: ${t}\nNonce: ${n}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class Ia{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,chainId:this.wallet.chainId,address:this.wallet.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new k("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.client)throw new k("SiweFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw T(e)}}async sign(){if(!this.client)throw new k("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new k("Could not prepare SIWE message");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new k("SiweFlow has no client instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new k("SiweFlow has no client instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=Aa({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1){this._meta={disableSignup:!1},this.getNonceOnce=new Er(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=n,this.client=t,this._meta.disableSignup=r}}class _a{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new k("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.client)throw new k("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw T(e)}}async sign(){if(!this.client)throw new k("SiwsFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new k("Could not prepare SIWS message");if(!this.wallet.signMessage)throw new k("Wallet does not support signMessage");let e=await this.wallet.signMessage(Buffer.from(this.preparedMessage));return{message:this.preparedMessage,signature:Buffer.from(e).toString("base64")}}async _getNonceOnce(){if(!this.client)throw new k("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new k("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=(({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\nYou are proving you own ${e}.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: mainnet\nNonce: ${t}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`)({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1){this._meta={disableSignup:!1},this.getNonceOnce=new Er(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=n,this.client=t,this._meta.disableSignup=r}}class Ea{async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new k("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(V,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new k("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(H,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw T(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new k("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new k("phone nNumber must be set when initialzing authentication.");let r=Xn(n);try{return await this.api.post(q,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw T(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:n}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:n??!1}}}class Sa extends Ea{async link(){if(!this.api)throw new k("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new k("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(K,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw T(e)}}constructor(e,t,n){super({phoneNumber:t,captchaToken:n}),this.meta={phoneNumber:t,captchaToken:n,oldPhoneNumber:e,disableSignup:!1}}}const Na=/*#__PURE__*/c({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:G,setError:G,setExecuting:G,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:G,reset:G,execute:G});class Ma extends Z{constructor(e,t,n){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=n}}const Pa=({children:e,id:n,captchaSiteKey:r,captchaEnabled:a})=>{let l=i(null),[c,d]=o(),[p,h]=o(),[u,m]=o(!1),g=s((()=>a?u||c||p?!u||c||p?c&&!p?{status:"success",token:c}:p?{status:"error",error:p}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[a,c,p,u]);/*#__PURE__*/return t(Na.Provider,{value:{...g,ref:l,enabled:a,siteKey:r,appId:n,setToken:d,setError:h,setExecuting:m,remove(){a&&(l.current?.remove(),m(!1),h(void 0),d(void 0))},reset(){a&&(l.current?.reset(),m(!1),h(void 0),d(void 0))},execute(){a&&(m(!0),l.current?.execute())},async waitForResult(){if(!a)return"";try{return await function(e,{interval:t=100,timeout:n=5e3}={}){return new Promise(((r,a)=>{let i,o=0,s=()=>{o>=n?a("Max attempts reached without result"):(i=e(),o+=t,null==i?setTimeout(s,t):r(i))};s()}))}((()=>l.current?.getResponse()),{interval:200,timeout:2e4})}catch(e){throw new Ma("Captcha failed",null,U.CAPTCHA_TIMEOUT)}}},children:e})},Wa=()=>l(Na);class Oa{async authenticate(){if(!this.api)throw new k("Auth flow has no API instance");try{return await this.api.post(Y,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw T(e)}}async link(){if(!this.api)throw new k("Auth flow has no API instance");try{return await this.api.post(J,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw T(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function Ua(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===U.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===U.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===U.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===U.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===U.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===U.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===U.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof Ma&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function La(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function Ra(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}class Fa{static parse(e){try{return new Fa(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return st.decodeJwt(e),e}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(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=st.decodeJwt(e)}}class Da extends Fa{static parse(e){try{return new Da(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}function za(e){return e?new Date(1e3*e):null}function Ba(e,t){return e.slice().sort(((e,t)=>(e.firstVerifiedAt??e.verifiedAt).getTime()-(t.firstVerifiedAt??t.verifiedAt).getTime())).find((e=>e.type===t))}const $a=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType&&0===e.walletIndex))||null,ja=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"ethereum"===e.chainType)),Va=e=>(e?.linkedAccounts??[]).filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType)),Ha=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported&&"solana"===e.chainType&&0===e.walletIndex))||null,qa=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.imported&&"ethereum"===e.chainType))||null,Ka=e=>e?.linkedAccounts.find((e=>"wallet"===e.type&&e.imported&&"privy"===e.walletClientType&&"solana"===e.chainType))||null,Za=(e,t)=>e?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.address===t))||null,Ga=e=>$a(e)??Ha(e);function Ya(e){if(!e)return null;let t=function(e){let t=[];for(let n of e){let e=n.type;switch(n.type){case"wallet":let r={id:n.id,address:n.address,type:n.type,imported:n.imported,delegated:n.delegated,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at),chainType:n.chain_type,walletClientType:n.wallet_client_type,connectorType:n.connector_type,recoveryMethod:n.recovery_method,walletIndex:n.wallet_index};t.push(r);break;case"smart_wallet":let a={address:n.address,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at),smartWalletType:n.smart_wallet_type};t.push(a);break;case"cross_app":let i={type:n.type,subject:n.subject,embeddedWallets:n.embedded_wallets,smartWallets:n.smart_wallets,providerApp:{id:n.provider_app_id},verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(i);break;case"email":let o={address:n.address,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(o);break;case"phone":let s={number:n.phoneNumber,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(s);break;case"google_oauth":let l={subject:n.subject,email:n.email,name:n.name,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(l);break;case"spotify_oauth":let c={subject:n.subject,email:n.email,name:n.name,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(c);break;case"instagram_oauth":let d={subject:n.subject,username:n.username,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(d);break;case"twitter_oauth":let p={subject:n.subject,username:n.username,name:n.name,type:n.type,profilePictureUrl:n.profile_picture_url,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(p);break;case"discord_oauth":let h={subject:n.subject,username:n.username,email:n.email,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(h);break;case"github_oauth":let u={subject:n.subject,username:n.username,name:n.name,email:n.email,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(u);break;case"tiktok_oauth":let m={subject:n.subject,username:n.username,name:n.name,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(m);break;case"linkedin_oauth":let g={subject:n.subject,name:n.name,email:n.email,vanityName:n.vanity_name,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(g);break;case"apple_oauth":let y={subject:n.subject,email:n.email,type:n.type,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(y);break;case"custom_auth":t.push({type:n.type,customUserId:n.custom_user_id,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)});break;case"farcaster":let f={type:n.type,fid:n.fid,ownerAddress:n.owner_address,displayName:n.display_name,username:n.username,bio:n.bio,pfp:n.profile_picture_url,url:n.homepage_url,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at),signerPublicKey:n.signer_public_key};t.push(f);break;case"passkey":let w={type:n.type,enrolledInMfa:n.enrolled_in_mfa,credentialId:n.credential_id,authenticatorName:n.authenticator_name,createdWithDevice:n.created_with_device,createdWithOs:n.created_with_os,createdWithBrowser:n.created_with_browser,verifiedAt:za(n.verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(w);break;case"telegram":let v={type:n.type,telegramUserId:n.telegram_user_id,firstName:n.first_name,lastName:n.last_name,username:n.username,photoUrl:n.photo_url,verifiedAt:za(n.first_verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(v);break;case"authorization_key":let b={type:n.type,publicKey:n.public_key,verifiedAt:za(n.first_verified_at),firstVerifiedAt:za(n.first_verified_at),latestVerifiedAt:za(n.latest_verified_at)};t.push(b);break;default:console.warn(`Unrecognized account type: ${e}. Please consider upgrading the Privy SDK.`)}}return t}(e.linked_accounts),n=Ba(t,"wallet"),r=Ba(t,"smart_wallet"),a=Ba(t,"email"),i=Ba(t,"phone"),o=Ba(t,"google_oauth"),s=Ba(t,"twitter_oauth"),l=Ba(t,"discord_oauth"),c=Ba(t,"github_oauth"),d=Ba(t,"spotify_oauth"),p=Ba(t,"instagram_oauth"),h=Ba(t,"tiktok_oauth"),u=Ba(t,"linkedin_oauth"),m=Ba(t,"apple_oauth"),g=Ba(t,"farcaster"),y=Ba(t,"telegram"),f=e.mfa_methods.map((({type:e,verified_at:t})=>({type:e,verifiedAt:za(t)})));return{id:e.id,createdAt:za(e.created_at),linkedAccounts:t,email:a&&{address:a?.address},phone:i&&{number:i?.number},wallet:n&&{id:n.id,address:n.address,chainType:n.chainType,walletClientType:n.walletClientType,connectorType:n.connectorType,recoveryMethod:n.recoveryMethod,imported:n.imported,delegated:n.delegated,walletIndex:n.walletIndex},smartWallet:r&&{address:r.address,smartWalletType:r.smartWalletType},google:o&&{subject:o.subject,email:o.email,name:o.name},twitter:s&&{subject:s.subject,username:s.username,name:s.name,profilePictureUrl:s.profilePictureUrl},discord:l&&{subject:l.subject,username:l.username,email:l.email},github:c&&{subject:c.subject,username:c.username,name:c.name,email:c.email},spotify:d&&{subject:d.subject,email:d.email,name:d.name},instagram:p&&{subject:p.subject,username:p.username},tiktok:h&&{subject:h.subject,username:h.username,name:h.name},linkedin:u&&{subject:u.subject,name:u.name,email:u.email,vanityName:u.vanityName},apple:m&&{subject:m.subject,email:m.email},farcaster:g&&{fid:g.fid,ownerAddress:g.ownerAddress,displayName:g.displayName,username:g.username,bio:g.bio,pfp:g.pfp,url:g.url,signerPublicKey:g.signerPublicKey},telegram:y&&{telegramUserId:y.telegramUserId,firstName:y.firstName,lastName:y.lastName,username:y.username,photoUrl:y.photoUrl},delegatedWallets:[],mfaMethods:f.map((e=>e.type)),hasAcceptedTerms:e.has_accepted_terms??!1,isGuest:e.is_guest,customMetadata:e.custom_metadata}}const Ja=e=>e?.linkedAccounts.find((e=>"authorization_key"===e.type));let Xa=e=>{if("ethereum"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"ethereum-address-verifier"};if("solana"===e.chainType)return{entropyId:e.address,entropyIdVerifier:"solana-address-verifier"};throw Error("Failed to get account entropy details")};const Qa=(e,t)=>{let n=Ja(e);if(n)return{entropyId:n.publicKey,entropyIdVerifier:"p256"};if(t?.imported)return Xa(t);let r=Ga(e);if(!r)throw Error("Failed to find primary wallet");return Xa(r)},ei=({style:n,...r})=>/*#__PURE__*/e("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),/*#__PURE__*/t("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"})]}),ti={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"}}},ni={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},ri={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"}}},ai={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},ii={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"}}},oi={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},si={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},li={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},ci={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"}}},di={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"}}},pi={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},hi={id:137,name:"Polygon Mainnet",network:"polygon",nativeCurrency:{name:"POL",symbol:"POL",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"}}},ui={id:80002,name:"Polygon Amoy",network:"polygon-amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{privy:{http:["https://polygon-amoy.rpc.privy.systems"]},infura:{http:["https://polygon-amoy.infura.io/v3"],webSocket:["wss://polygon-amoy.infura.io/ws/v3"]},default:{http:["https://rpc-amoy.polygon.technology"]}},blockExplorers:{default:{name:"OK LINK",url:"https://www.oklink.com/amoy"}},testnet:!0},mi={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},gi={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"}}},yi=[ti,ni,mi,ci,di,pi,hi,ui,si,{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},{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"}}},{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"}}},ii,oi,{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},{id:42,network:"lukso",name:"LUKSO",nativeCurrency:{name:"LUKSO",symbol:"LYX",decimals:18},rpcUrls:{default:{http:["https://rpc.mainnet.lukso.network"],webSocket:["wss://ws-rpc.mainnet.lukso.network"]}},blockExplorers:{default:{name:"LUKSO Mainnet Explorer",url:"https://explorer.execution.mainnet.lukso.network"}}},li,{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},ri,ai,gi,{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},{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},{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"}}},{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/"}}},{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"}}}],fi=new Set(yi.map((e=>e.id)));class wi extends S{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class vi extends S{constructor(){super("User rejected connection"),this.type="wallet_error"}}const bi=e=>e instanceof S?e:e?.code?new ki(e):new S("Unknown connector error",e);class Ci extends Z{constructor(e,t,n){super(e),this.type="provider_error",this.code=t,this.data=n}}class ki extends Ci{constructor(e){super(e.message,e.code,e.data);let t=Object.values(pt).find((t=>t.eipCode===e.code));this.details=t||pt.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=pt.E32002_CONNECTION_ALREADY_PENDING:this.details=pt.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=pt.E32002_WALLET_LOCKED))}}const xi={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},ERROR_USER_LIMIT_REACHED:{message:"Unable to link",detail:"You've reached the maximum number of linked wallets.",retryable:!1},...pt};function Ti(e){return"ethereum"===e.type}function Ai(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],a=t[n];if(r?.address!==a?.address||r&&a&&Ti(r)&&Ti(a)&&r?.chainId!==a?.chainId||r?.connectorType!==a?.connectorType||r?.connectedAt!==a?.connectedAt||r?.walletClientType!==a?.walletClientType||r?.isConnected!==a?.isConnected||r?.linked!==a?.linked)return!1}return!0}class Ii extends ct{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const _i=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||Xr;let Ei;function Si(e){return"ethereum"===e.chainType}class Ni extends Ii{buildConnectedWallet(e,t,n,r){let a=async()=>!!this.wallets.find((t=>v(t.address)===v(e)));return{type:"ethereum",address:v(e),chainId:t,meta:n,imported:r,switchChain:async n=>{let r,i;if(!a)throw new S("Wallet is not currently connected.");let o=this.wallets.find((t=>v(t.address)===v(e)))?.chainId;if(!o)throw new S("Unable to determine current chainId.");if("number"==typeof n?(r=`0x${n.toString(16)}`,i=n):(r=n,i=Number(n)),o===wr(r))return;let s=this.chains.find((e=>e.id===i));if(!s)throw new S(`Unsupported chainId: ${n}`);let l=async()=>{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:r}]})};try{return await l()}catch(e){if(((e,t)=>{switch(t){case"coinbase_wallet":return e.message.includes("addEthereumChain");case"rabby_wallet":return e.message.includes("Unrecognized chain ID");default:return 4902===e.code||e.message?.includes("4902")}})(e,this.walletClientType))return"rabby_wallet"===this.walletClientType&&await hr(300),await this.proxyProvider.request({method:"wallet_addEthereumChain",params:[{chainId:r,chainName:s.name,nativeCurrency:s.nativeCurrency,rpcUrls:[s.rpcUrls.default?.http[0]??""],blockExplorerUrls:[s.blockExplorers?.default.url??""]}]}),l();if("rainbow"===this.walletClientType&&e.message?.includes("wallet_switchEthereumChain"))throw new S(`Rainbow does not support the chainId ${t}`);throw e}},connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:a,getEthereumProvider:async()=>{if(!await a())throw new S("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await a())throw new S("Wallet is not currently connected.");return await this.sign(e)},disconnect:()=>{this.disconnect()}}}async syncAccounts(e){let t,n=e;try{if(void 0===n){let e=await ur((()=>this.proxyProvider.request({method:"eth_accounts"})),{maxAttempts:10,delayMs:500});console.debug(`eth_accounts for ${this.walletClientType}:`,e),Array.isArray(e)&&(n=e)}}catch(e){console.debug("Wallet did not respond to eth_accounts. Defaulting to prefetched accounts.",e)}if(!n||!Array.isArray(n)||n.length<=0||!n[0])return;let r=n[0],a=v(r),i=[];if("privy"===this.walletClientType){let e=rr.get(Gr(a));this.chains.find((t=>t.id===Number(e)))||(rr.del(Gr(a)),e=null),t=e||`0x${this.defaultChain.id.toString(16)}`;try{await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[{chainId:t}]})}catch(e){console.warn(`Unable to switch embedded wallet to chain ID ${t} on initialization`)}}else try{let e=await ur((()=>this.proxyProvider.request({method:"eth_chainId"})),{maxAttempts:10,delayMs:500});if(console.debug(`eth_chainId for ${this.walletClientType}:`,e),"string"==typeof e)t=e;else{if("number"!=typeof e)throw Error("Invalid chainId returned from provider");t=`0x${e.toString(16)}`}}catch(e){console.warn("Failed to get chainId from provider, defaulting to 0x1",e),t="0x1"}let o=wr(t);if(!i.find((e=>v(e.address)===a))){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};i.push(this.buildConnectedWallet(v(r),o,e,"embedded_imported"===this.connectorType))}Ai(i,this.wallets)||(this.wallets=i,this.emit("walletsUpdated"))}async getConnectedWallet(){let e=await this.proxyProvider.request({method:"eth_accounts"});return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt)).find((t=>e.find((e=>v(e)===v(t.address)))))||null}async isConnected(){let e=await this.proxyProvider.request({method:"eth_accounts"});return Array.isArray(e)&&e.length>0}async sign(e){return await this.connect({showPrompt:!1}),this.proxyProvider.request({method:"personal_sign",params:[b(e),this.wallets[0]?.address]})}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)}constructor(e,t,n,r){super(e),this.chainType="ethereum",this.onAccountsChanged=e=>{0===e.length?this.onDisconnect():this.syncAccounts(e)},this.onChainChanged=e=>{this.wallets.forEach((t=>{t.chainId=wr(e),"privy"===this.walletClientType&&rr.put(Gr(t.address),e)})),this.emit("walletsUpdated")},this.onDisconnect=()=>{this.connected=!1,this.wallets=[],this.emit("walletsUpdated")},this.onConnect=async()=>{this.connected=!0,"coinbase_wallet"===this.connectorType&&await hr(300),this.syncAccounts()},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=n,this.rpcConfig=r,this.rpcTimeoutDuration=_i(r,e),this.connected=!1,this.initialized=!1}}class Mi{on(e,t){if(this.walletProvider)return this.walletProvider.on(e,t);this._subscriptions.push({eventName:e,listener:t})}async request(e){if(!this.walletProvider)throw new S(`A wallet request of type ${e.method} was made before setting a wallet provider.`);return Promise.race([this.walletProvider.request(e),this.walletTimeout()]).catch((e=>{throw bi(e)}))}constructor(e,t){this.removeListener=(e,t)=>{if(this.walletProvider)try{return this.walletProvider.removeListener(e,t)}catch(e){console.warn("Unable to remove wallet provider listener")}},this.walletTimeout=(e=new wi,t=this.rpcTimeoutDuration)=>new Promise(((n,r)=>setTimeout((()=>{r(e)}),t))),this.setWalletProvider=e=>{this.walletProvider&&this._subscriptions.forEach((e=>{this.removeListener(e.eventName,e.listener)})),this.walletProvider=e,this._subscriptions.forEach((e=>{this.walletProvider?.on(e.eventName,e.listener)}))},this.walletProvider=e,this.rpcTimeoutDuration=t||Xr,this._subscriptions=[]}}let Pi=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],Wi=(e,t)=>e.makeWeb3Provider({options:t});class Oi extends Ni{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:"data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new S("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw bi(e)}}updateConnectionPreference(e){this.connectionOptions=e,this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(Wi(Ei,this.connectionOptions))}constructor(e,t,n,r,a,i){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Mi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=r.coinbaseWallet.connectionOptions??"all",this.walletClientType="smartWalletOnly"===this.connectionOptions?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!Ei){let n=[t.id].concat(e.map((e=>e.id))),r="eoaOnly"!==this.connectionOptions?n.filter((e=>!Pi.includes(e))):[];r.length>0&&!r.every((e=>fi.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${r.join(", ")}`),Ei=new dt({appName:a,appLogoUrl:i,appChainIds:n})}this.proxyProvider.setWalletProvider(Wi(Ei,this.connectionOptions))}}const Ui=({...e})=>/*#__PURE__*/t("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:/*#__PURE__*/t("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)"})});class Li extends Ni{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return await this.isConnected()?(await this.proxyProvider.request({method:"wallet_switchEthereumChain",params:[yr(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Ui,id:"io.privy.wallet"}}disconnect(){this.connected=!1}async promptConnection(){}constructor({provider:e,chains:t,defaultChain:n,rpcConfig:r,imported:a,walletIndex:i}){super("privy",t,n,r),this.connectorType="embedded",this.proxyProvider=e,this.walletIndex=i,a&&(this.connectorType="embedded_imported"),this.subscribeListeners()}}const Ri=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];let Fi={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844"};const Di={legacy:0,eip2930:1,eip1559:2,eip4844:3};let zi=e=>void 0!==e?BigInt(e):void 0;function Bi(e){let t,{type:n=2,...r}=e;r.accessList&&Array.isArray(r.accessList)?t=r.accessList.map((e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e)):r.accessList&&(t=Object.entries(r.accessList).map((e=>({address:e[0],storageKeys:e[1]}))));let a=Number(r.chainId??1),i=qe(r.data)?r.data:r.data?Ke(Uint8Array.from(r.data)):void 0,o=r.nonce?Number(r.nonce):void 0,s={chainId:a,data:i,nonce:o,value:zi(r.value),gas:zi(r.gas??r.gasLimit)},l=Number(n);if(0===l)return{...r,type:Fi[l],...s,gasPrice:zi(r.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===l)return{...r,type:Fi[l],...s,gasPrice:zi(r.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===l)return{...r,type:Fi[l],...s,nonce:o,accessList:t,maxFeePerGas:zi(r.maxFeePerGas),maxPriorityFeePerGas:zi(r.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw new k(`Unsupported transaction type: ${n}`)}class $i extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}class ji extends ct{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new $i(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Jb()||!this.address)throw new $i("Disconnected",4900);let{hash:n}=await tC(t,{address:this.address});return n}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new $i(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Jb()||!this.address)throw new $i("Disconnected",4900);let{signature:n}=await eC(t,{address:this.address});return n}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new $i(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new $i(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=sr(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],n=e.params[1],{signature:r}=await Xb({message:t},{address:n});return r}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],n="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:r}=await Qb(br(n),{address:t});return r}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:yr(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...Bi(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return yr(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>Ri.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await Jb();if(await nC(),!t||!this.address)throw new $i("Disconnected",4900);try{return(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:{method:e.method,params:e.params}})).response.data}catch(e){throw console.error(e),new $i("Disconnected",4900)}}}constructor({walletProxy:e,address:t,entropyId:n,entropyIdVerifier:r,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l}){super(),this.walletProxy=e,this.address=t,this.entropyId=n,this.entropyIdVerifier=r,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=sr(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=_i(a,"privy"),this.appId=o,this.walletIndex=l}}class Vi extends Ni{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the EthereumNullConnector")}disconnect(){throw Error("disconnect called for an uninstalled wallet via the EthereumNullConnector")}promptConnection(e){throw Error(`promptConnection called for an uninstalled wallet via the EthereumNullConnector for ${e}`)}constructor({id:e,name:t,icon:n,walletClientType:r,defaultChain:a}){super(r,[],a,{}),this.connectorType="null",this.proxyProvider=new Mi(void 0,Xr),this.id=e,this.name=t,this.icon=n,this.connectorType=r}}const Hi=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...e},...n,children:/*#__PURE__*/t("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"})}),qi=({style:n,...r})=>/*#__PURE__*/e("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",...n},...r,children:[/*#__PURE__*/t("style",{children:".s1{stroke-linecap:round;stroke-linejoin:round}.s2{fill:#e4761b;stroke:#e4761b}.s3{fill:#f6851b;stroke:#f6851b}"}),/*#__PURE__*/t("path",{fill:"#e2761b",stroke:"#e2761b",className:"s1",d:"m274.1 35.5-99.5 73.9L193 65.8z"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"}),/*#__PURE__*/t("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"})]}),Ki=({style:n,...r})=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),/*#__PURE__*/t("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"})]});function Zi(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Gi=0;class Yi extends Ni{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.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 e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new S("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw bi(e)}}constructor(e,t,n,r,a){super(a||"unknown",e,t,n),this.connectorType="injected",this.proxyProvider=new Mi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=r;let i=r.provider;this.proxyProvider.setWalletProvider(i)}}var Ji="__private_"+Gi+++"__walletBranding";class Xi extends Ni{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return Zi(this,Ji)[Ji]??{name:"Browser Extension",icon:Hi,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new S("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw bi(e)}}constructor(e,t,n,r,a){super(a??"unknown",e,t,n),Object.defineProperty(this,Ji,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Mi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(r),"metamask"===a?Zi(this,Ji)[Ji]={name:"MetaMask",icon:qi,id:"io.metamask"}:"phantom"===a&&(Zi(this,Ji)[Ji]={name:"Phantom",icon:Ki,id:"phantom"})}}class Qi extends Yi{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{g||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new S("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw bi(e)}}}const eo=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","crypto.com_wallet_extension","crypto.com_onchain","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","haha_wallet","privy","unknown","phantom","solflare","glow","backpack"],to=Object.freeze({phantom:{client:"phantom",name:"Phantom",installLink:m.isFirefox?"https://addons.mozilla.org/en-US/firefox/addon/phantom-app/":"https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa?hl=en",chainTypes:["ethereum","solana"],get isInstalled(){if("phantom"in window){let e=window;if(e?.phantom?.ethereum?.isPhantom&&e?.phantom?.ethereum?.chainId||e?.phantom?.solana?.isPhantom)return!0}return!1},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=ro({client:this.client,isSolana:t,connectOnly:n});return`${e?"phantom://":"https://phantom.app/ul/"}browse/${r}?ref=${r}`}},solflare:{client:"solflare",name:"Solflare",installLink:m.isFirefox?"https://addons.mozilla.org/es/firefox/addon/solflare-wallet/":"https://chromewebstore.google.com/detail/solflare-wallet/bhhhlbepdkbapadjdnnojkbgioiodbic",chainTypes:["solana"],get isInstalled(){return"solflare"in window&&!!window?.solflare?.isSolflare},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=ro({client:this.client,isSolana:t,connectOnly:n});return`${e?"solflare://ul/v1/":"https://solflare.com/ul/v1/"}browse/${r}?ref=${r}`}},backpack:{client:"backpack",name:"Backpack",installLink:"https://chromewebstore.google.com/detail/backpack/aflkmfhebedbjioipglgcbcmnbpgliof",chainTypes:["ethereum","solana"],get isInstalled(){return!(!("backpack"in window)||!window?.backpack?.ethereum?.isBackpack&&!window?.backpack?.solana?.isBackpack)},getMobileRedirect({useUniversalLink:e,isSolana:t,connectOnly:n}){let r=ro({client:this.client,isSolana:t,connectOnly:n});return`${e?"backpack://ul/v1/":"https://backpack.com/ul/v1/"}browse/${r}?ref=${r}`}},okx_wallet:{client:"okx_wallet",name:"OKX Wallet",installLink:"https://chromewebstore.google.com/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",chainTypes:["solana"],get isInstalled(){return"okxwallet"in window&&!!window?.okxwallet?.isOkxWallet},getMobileRedirect({isSolana:e,connectOnly:t}){return"https://www.okx.com/download?deeplink="+encodeURIComponent("okx://wallet/dapp/url?dappUrl="+ro({client:this.client,isSolana:e,connectOnly:t}))}}});function no({connectorType:e,walletClientType:t}){for(let n of eo)if(e===n||t===n)return to[n]}function ro({client:e,isSolana:t,connectOnly:n}){let r=new URL(window.location.href);return r.searchParams.set("privy_connector",t?"solana_adapter":"injected"),r.searchParams.set("privy_wallet_client",e),r.searchParams.set("privy_connect_only",String(n)),encodeURIComponent(r.href.replace(/\/$/g,""))}const ao=()=>{let e=rr.get(Jr);return e&&Array.isArray(e)&&e.map((e=>(e=>e&&"string"==typeof e.address&&"string"==typeof e.connectorType&&"string"==typeof e.walletClientType&&"number"==typeof e.connectedAt)(e))).every(Boolean)?e:[]};let io=["phantom","glow","solflare","backpack","okx_wallet"];function oo(e){return"solana"===e.chainType}function so(e){return"solana"===e.type}class lo extends Ii{get isInstalled(){return"Installed"===this.adapter.readyState}buildConnectedWallet(e,t){let n,r,a,i;if("Installed"!==e.readyState||!e.publicKey)throw Error("Wallet is not connected.");return"signMessage"in e&&(n=async(...t)=>{if(!e.connected)throw Error("Wallet is not connected.");return await e.signMessage(t[0])}),"sendTransaction"in e&&(r=async(...t)=>await e.sendTransaction(t[0],t[1],t[2])),"signTransaction"in e&&(a=async t=>await e.signTransaction(t)),"signAllTransactions"in e&&(i=async t=>await e.signAllTransactions(t)),{type:"solana",address:e.publicKey.toBase58(),meta:t,imported:!1,connectedAt:Date.now(),walletClientType:this.walletClientType,connectorType:this.connectorType,isConnected:async()=>e.connected,disconnect:()=>{try{e.disconnect()}catch(e){console.error("Wallet does not support programmatic disconnect")}},getProvider:X(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:n??X(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:r??X(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:a??X(`${this.walletClientType||""} wallet does not support 'signTransaction'`),signAllTransactions:i??X(`${this.walletClientType||""} wallet does not support 'signAllTransactions'`)}}async syncAccounts(){if("Installed"===this.adapter.readyState&&this.adapter.publicKey){let e={name:this.walletBranding.name,icon:"string"==typeof this.walletBranding.icon?this.walletBranding.icon:void 0,id:this.walletBranding.id};this.wallets.find((e=>this.adapter.publicKey&&e.address===this.adapter.publicKey.toBase58()))||(this.wallets=[this.buildConnectedWallet(this.adapter,e)],this.emit("walletsUpdated"))}else this.wallets.length>0&&(this.wallets=[],this.emit("walletsUpdated"))}get walletBranding(){return{id:this.adapter.name,name:this.adapter.name,icon:this.adapter.icon}}async initialize(){this.subscribeListeners(),await this.syncAccounts(),this.shouldAttemptAutoConnect()&&await this.adapter.autoConnect().catch((()=>{})),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}async getConnectedWallet(){return this.wallets.sort(((e,t)=>t.connectedAt-e.connectedAt))[0]||null}async isConnected(){return this.adapter.connected&&["Installed"].includes(this.adapter.readyState)}subscribeListeners(){this.adapter.addListener("disconnect",this.onDisconnect),this.adapter.addListener("connect",this.onConnect),this.adapter.addListener("error",this.onError),this.adapter.addListener("readyStateChange",this.onReadyStateChange)}unsubscribeListeners(){this.adapter.removeAllListeners()}shouldAttemptAutoConnect(){return!(!this.autoConnectEnabled||!io.includes(this.walletClientType))&&("phantom"!==this.walletClientType||ao().some((({walletClientType:e})=>"phantom"===e)))}constructor(e,t){super(function(e){return e.name.toLowerCase().split(" ").join("_")}(e)),this.chainType="solana",this.connectorType="solana_adapter",this.disconnect=()=>{this.adapter.disconnect().then((()=>this.onDisconnect())).catch((e=>console.error("Error disconnecting",e)))},this.promptConnection=async()=>{try{await this.adapter.connect()}catch(e){throw bi(e)}},this.onDisconnect=()=>{this.syncAccounts()},this.onConnect=e=>{this.syncAccounts()},this.onError=e=>{this.syncAccounts()},this.onReadyStateChange=e=>{"Installed"!==e&&(this.connected=!1),this.syncAccounts()},this.adapter=e,this.autoConnectEnabled=t,this.wallets=[]}}class co extends lo{get walletBranding(){return{id:this.id,name:this.name,icon:this.icon}}async initialize(){this.initialized=!0,this.emit("initialized")}async connect(){throw Error("connect called for an uninstalled wallet via the SolanaNullConnector")}constructor({id:e,name:t,icon:n}){super({name:t},!1),this.connectorType="null",this.proxyProvider=new Mi(void 0,Xr),this.disconnect=async()=>{throw Error("disconnect called for an uninstalled wallet via the SolanaNullConnector")},this.promptConnection=async()=>{throw Error("promptConnection called for an uninstalled wallet via the SolanaNullConnector")},this.id=e,this.name=t,this.icon=n}}const po=$t((()=>({listings:[]}))),ho=po.setState,uo=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return po.getState().listings.find((({homepage:e})=>{let n;try{n=new URL(e).hostname}catch(e){return!1}return t.includes(n)}))},mo=e=>po((({listings:t})=>t.find((({slug:t})=>go(t)===go(e)))));function go(e){return"cryptocom"===e?"cryptocom-defi":e.replace(/[-_]wallet$/,"")}function yo({src:e,...n}){/*#__PURE__*/return t("img",{src:e,...n,style:{display:"none"}})}const fo={appearance:{landingHeader:"Log in or sign up",theme:"light",accentColor:"#676FFF",walletList:["detected_wallets","metamask","coinbase_wallet","rainbow","wallet_connect"]},walletConnectCloudProjectId:"34357d3c125c2bcf2ce2bc3309d98715",externalWallets:{coinbaseWallet:{connectionOptions:"all"}},embeddedWallets:{extendedCalldataDecoding:!1},captchaEnabled:!1,_render:{standalone:!1},fundingMethodConfig:{moonpay:{useSandbox:!1}}};let wo=new Set(["coinbase_wallet","cryptocom","metamask","okx_wallet","phantom","rainbow","uniswap","zerion","universal_profile","bybit_wallet","ronin_wallet","haha_wallet","wallet_connect","detected_wallets","detected_solana_wallets","detected_ethereum_wallets","rabby_wallet","safe","solflare","backpack"]),vo=e=>wo.has(e),bo=(e,t,n)=>n.indexOf(e)===t;function Co(e,t){return{...e,rpcUrls:{...e.rpcUrls,privyWalletOverride:{http:[t]}}}}function ko(e){let t=e.filter((e=>!fi.has(e.id)));return yi.concat(t)}function xo(e,t){return{...e,rpcUrls:{...e.rpcUrls,privy:{http:[t]}}}}const To=792703809,Ao="11111111111111111111111111111111";function Io(e){return e.includes("testnet")?"testnet":e.includes("devnet")?"devnet":"mainnet-beta"}function _o(e,t){return`https://explorer.solana.com/account/${e}?cluster=${t}`}let Eo="#FFFFFF";function So(e,t){let n=Math.max(0,Math.min(1,e.toHsl().l+t));return Ot({...e.toHsl(),l:n})}function No({backgroundTheme:e,accentHex:t}){let n;switch(e){case"light":n=Eo;break;case"dark":n="#1E1E1D";break;default:n=e}let r=Ot(n),a=Ot(t),i=Ot("#51BA81"),o=Ot("#FFB74D"),s=Ot("#EC6351"),l=function(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"}(r.getLuminance()),c=So(r,"light"===l?-.04:.11),d=So(r,"light"===l?-.08:.16),p=So(r,"light"===l?-.88:.87),h=So(r,"light"===l?-.7:.75),u=So(r,"light"===l?-.43:.45).desaturate("light"===l?60:20),m=So(r,"light"===l?-.08:.25).desaturate("light"===l?60:20),g=So(a,.15),y=So(a,.25),f=So(a,-.06),w=So(a,-.6),v=So(s,.3),b=So(o,.3),C=Ot(a.getLuminance()>.5?"#040217":Eo),k=So(i,-.16),x=So(i,.4);return{colorScheme:l,background:r.toHslString(),background2:c.toHslString(),background3:d.toHslString(),foreground:p.toHslString(),foreground2:h.toHslString(),foreground3:u.toHslString(),foreground4:m.toHslString(),accent:a.toHslString(),accentLight:g.toHslString(),accentLightest:y.toHslString(),accentDark:f.toHslString(),accentDarkest:w.toHslString(),foregroundAccent:C.toHslString(),success:i.toHslString(),successDark:k.toHslString(),successLight:x.toHslString(),error:s.toHslString(),errorLight:v.toHslString(),warn:o.toHslString(),warnLight:b.toHslString()}}function Mo(e,t,n,r){let a,i,o,s,l,c,d,p,h,u,m,g,y,f,w,v=n?console.warn:()=>{};t?.loginMethods?(a=t.loginMethods.includes("email"),i=t.loginMethods.includes("sms"),s=t.loginMethods.includes("wallet"),l=t.loginMethods.includes("google"),c=t.loginMethods.includes("twitter"),d=t.loginMethods.includes("discord"),h=t.loginMethods.includes("spotify"),u=t.loginMethods.includes("instagram"),p=t.loginMethods.includes("tiktok"),g=t.loginMethods.includes("github"),m=t.loginMethods.includes("linkedin"),y=t.loginMethods.includes("apple"),f=t.loginMethods.includes("farcaster"),w=t.loginMethods.includes("telegram"),o=t.loginMethods.includes("passkey")):(a=e.emailAuth,i=e.smsAuth,s=e.walletAuth||e.solanaWalletAuth,l=e.googleOAuth,c=e.twitterOAuth,d=e.discordOAuth,g=e.githubOAuth,h=e.spotifyOAuth,u=e.instagramOAuth,p=e.tiktokOAuth,m=e.linkedinOAuth,y=e.appleOAuth,f=e.farcasterAuth,w=e.telegramAuth,o=e.passkeyAuth),e.passkeyAuth&&(o=!0),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(o=!1);let b=[a,i].filter(Boolean),C=[l,c,d,g,h,u,p,m,y,f,w].filter(Boolean),k=[s].filter(Boolean),x=t?.loginMethods?.includes("passkey")??!1,T=e.passkeysForSignupEnabled??!1,A=[o&&(T||x)].filter(Boolean);if(b.length+C.length+k.length+A.length===0)throw Error("You must enable at least one login method");let I=void 0!==t?.appearance?.showWalletLoginFirst?t?.appearance?.showWalletLoginFirst:e.showWalletLoginFirst;I&&0===k.length?(v("You should only enable `showWalletLoginFirst` when `wallet` logins are also enabled. `showWalletLoginFirst` has been set to false"),I=!1):I||C.length+b.length!==0||(v("You should only disable `showWalletLoginFirst` when `email`, `sms`, or social logins are also enabled. `showWalletLoginFirst` has been set to true"),I=!0);let _=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&v("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let E=(({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(vo).filter(bo):e?e.filter(vo).filter(bo):fo.appearance.walletList)({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),S=(({input:e})=>{if(!e||!e.primary[0])return;let t=[e.primary[0]],n=[];for(let n of(e.primary.length>4&&console.warn("You should not specify greater than 4 login methods in `loginMethodsAndOrder.primary`"),e.primary.slice(1)))t.includes(n)?console.warn(`Duplicated login method: ${n}`):t.push(n);for(let r of e.overflow??[])t.includes(r)||n.includes(r)?console.warn(`Duplicated login method: ${r}`):n.push(r);return{primary:t,overflow:n}})({input:t?.loginMethodsAndOrder}),N=t?.intl?.defaultCountry??"US",{chains:M,defaultChain:P}=function({supportedChains:e,defaultChainFromConfig:t}){let n;if(e){if(0===e.length)throw Error("`supportedChains` must contain at least one chain");n=e.map((e=>{if(e.rpcUrls.privyWalletOverride)return e;let t=yi.find((t=>t.id===e.id)),n=t?.rpcUrls.privy?.http[0];return n?xo(e,n):e}))}else n=[...yi];let r=e?n[0]:ci,a=t??r;if(!n.find((e=>e.id===a.id)))throw Error("`defaultChain` must be included in `supportedChains`");return{chains:n,defaultChain:a}}({supportedChains:t?.supportedChains,defaultChainFromConfig:t?.defaultChain}),W=!!t?.defaultChain,O=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,U=t?.embeddedWallets?.requireUserPasswordOnCreate,L=t?.embeddedWallets?.createOnLogin,R=O?"all-users":e.embeddedWalletConfig.ethereum.createOnLogin,F=e.embeddedWalletConfig.solana.createOnLogin,D=t?.solanaClusters??[];return e.solanaWalletAuth&&!t?.externalWallets?.solana?.connectors&&console.warn("App configuration has Solana wallet login enabled, but no Solana wallet connectors have been passed to Privy. Make sure to pass Solana connectors to the `config.externalWallets.solana.connectors` field of the `PrivyProvider`"),{id:e.id,name:e.name,allowlistConfig:e.allowlistConfig,legacyWalletUiConfig:e.legacyWalletUiConfig,appearance:{logo:t?.appearance?.logo??e.logoUrl,landingHeader:t?.appearance?.landingHeader??fo.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:No({backgroundTheme:t?.appearance?.theme??fo.appearance.theme,accentHex:t?.appearance?.accentColor??e.accentColor??fo.appearance.accentColor}),loginGroupPriority:I?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:E,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.walletAuth??!1,solanaWalletAuth:e.solanaWalletAuth??!1})},loginMethods:{wallet:s,email:a,sms:i,passkey:o,google:l,twitter:c,discord:d,github:g,spotify:h,instagram:u,tiktok:p,linkedin:m,apple:y,farcaster:f,telegram:w},disablePlusEmails:e.disablePlusEmails,loginMethodsAndOrder:S,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.termsAndConditionsUrl,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacyPolicyUrl,requireUsersAcceptTerms:e.requireUsersAcceptTerms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.walletConnectCloudProjectId??fo.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:{}},chains:M,solanaClusters:{"mainnet-beta":D.find((e=>"mainnet-beta"===e.name))?.rpcUrl||"https://api.mainnet-beta.solana.com",testnet:D.find((e=>"testnet"===e.name))?.rpcUrl||"https://api.testnet.solana.com",devnet:D.find((e=>"devnet"===e.name))?.rpcUrl||"https://api.devnet.solana.com"},defaultChain:P,intl:{defaultCountry:N},shouldEnforceDefaultChainOnConnect:W,captchaEnabled:e.captchaEnabled??fo.captchaEnabled,captchaSiteKey:e.captchaSiteKey,externalWallets:{coinbaseWallet:{connectionOptions:t?.externalWallets?.coinbaseWallet?.connectionOptions??fo.externalWallets.coinbaseWallet.connectionOptions},walletConnect:{enabled:_},solana:{connectors:t?.externalWallets?.solana?.connectors}},embeddedWallets:{requireUserOwnedRecoveryOnCreate:U??(!O&&e.embeddedWalletConfig.requireUserOwnedRecoveryOnCreate),userOwnedRecoveryOptions:O?["user-passcode"]:e.embeddedWalletConfig.userOwnedRecoveryOptions,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:L??t?.embeddedWallets?.ethereum?.createOnLogin??R},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??F},showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforceWalletUis??!0,extendedCalldataDecoding:t?.embeddedWallets?.extendedCalldataDecoding??!1,transactionScanning:{enabled:t?.embeddedWallets?.transactionScanning?.enabled??!1,domain:t?.embeddedWallets?.transactionScanning?.domain??r??"https://auth.privy.io"}},mfa:{methods:e.mfaMethods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink},customAuth:O?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:e.telegramAuthConfiguration,passkeysForSignupEnabled:e.passkeysForSignupEnabled},headless:!!t?.headless,render:{standalone:t?._render?.standalone??fo._render.standalone},fundingConfig:e.fundingConfig,fundingMethodConfig:{...t?.fundingMethodConfig??fo.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??fo.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??fo.fundingMethodConfig.moonpay.useSandbox}}}}let Po={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,disablePlusEmails:!1,termsAndConditionsUrl:null,privacyPolicyUrl:null,embeddedWalletConfig:{ethereum:{createOnLogin:"off"},solana:{createOnLogin:"off"},requireUserOwnedRecoveryOnCreate:!1,userOwnedRecoveryOptions:["user-passcode"]},fiatOnRampEnabled:!1,captchaEnabled:!1,captchaSiteKey:"",enforceWalletUis:!1,legacyWalletUiConfig:!1};const Wo=Mo(Po,void 0,!1);let Oo=/*#__PURE__*/c({appConfig:Wo,isServerConfigLoaded:!1});const Uo=({children:e,client:n,clientConfig:r})=>{let[a,i]=o(null),l=s((()=>Mo(a??Po,r,!!a,"undefined"!=typeof window?window.location.origin:void 0)),[a,r]);return d((()=>{if(!a)return;let e=function(e){if(!e)return{};let{appearance:t,supportedChains:n,defaultChain:r,externalWallets:a,...i}=e;return{...i,...n?{supportedChains:n.map((e=>e.id))}:void 0,...r?{defaultChain:r.id}:void 0,...a?{walletConnect:a.walletConnect,coinbaseWallet:a.coinbaseWallet,solana:{connectors:a.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0}}(r),t=function(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t,a=0;a<e.length;a++)n=Math.imul(n^(t=e.charCodeAt(a)),2654435761),r=Math.imul(r^t,1597334677);return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),4294967296*(2097151&(r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909)))+(n>>>0)}(JSON.stringify(e)).toString(),i=`privy:sent:${a.id}:${t}`;localStorage.getItem(i)||(n.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(i,"t"))}),[r,a]),d((()=>{a||(async()=>{try{let e=await n.getServerConfig();e.customApiUrl&&n.updateApiUrl(e.customApiUrl),i(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),/*#__PURE__*/t(Oo.Provider,{value:{appConfig:l,isServerConfigLoaded:!!a},children:e})},Lo=()=>{let{appConfig:e}=l(Oo);return e},Ro=()=>{let{isServerConfigLoaded:e}=l(Oo);return e};function Fo(e){/*#__PURE__*/return t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 460 40",...e,children:/*#__PURE__*/t("g",{fill:e.color||"var(--privy-color-foreground)",children:/*#__PURE__*/t("path",{d:"M0 15.4v15.38h4.64V19.96h3.58c2.47 0 3.63-.01 3.77-.02 1-.08 1.49-.15 2.18-.3a9.45 9.45 0 0 0 4.6-2.37c1.66-1.57 2.64-3.87 2.81-6.56.02-.3.02-1.19 0-1.49-.1-1.77-.56-3.35-1.36-4.72A8.84 8.84 0 0 0 15.14.57c-.93-.3-1.75-.43-3.09-.54C11.9.02 10.2 0 5.93 0H0ZM10.85 4c1.85.05 3.1.45 4.16 1.3.22.17.54.49.69.68a5.97 5.97 0 0 1 1.19 3.13c.04.35.04 1.36 0 1.71-.08.68-.23 1.3-.44 1.85a4.8 4.8 0 0 1-1.09 1.68A5.63 5.63 0 0 1 12 15.92c-.6.08-.4.08-4.01.09H4.64V3.98h2.9c1.6 0 3.08 0 3.31.02ZM187.65 5.71v5.72h-.27l-.09-.14a15.9 15.9 0 0 0-1.21-1.73c-.43-.5-1-.95-1.7-1.36-.54-.3-1.05-.5-1.73-.63a8.98 8.98 0 0 0-1.7-.17 8.84 8.84 0 0 0-7.8 4.03 12.95 12.95 0 0 0-2.03 6.39c-.07.98-.06 2.15.02 3.13.2 2.47.87 4.53 2.02 6.25a8.98 8.98 0 0 0 10.22 3.65 6.5 6.5 0 0 0 2.8-1.93c.41-.51.84-1.1 1.1-1.55l.1-.17h.37v3.58h4.38V0h-4.48Zm-5.24 5.54c1.3.14 2.3.6 3.17 1.48.9.9 1.5 2.09 1.85 3.64.36 1.6.39 3.72.06 5.43a8.13 8.13 0 0 1-1.54 3.62 5.1 5.1 0 0 1-3.93 1.96 6.13 6.13 0 0 1-2.32-.31 5.87 5.87 0 0 1-3.33-3.5c-.39-1-.62-2.05-.72-3.32-.03-.32-.04-1.35-.02-1.73.08-1.56.4-2.91.96-4.05a6.2 6.2 0 0 1 1.06-1.58 5.08 5.08 0 0 1 3.6-1.66c.25-.02.9 0 1.16.02ZM210.07 15.39l.01 15.38h4.38l.01-3.57h.37l.09.15c.24.44.84 1.26 1.21 1.7a6.79 6.79 0 0 0 2.57 1.75 9.3 9.3 0 0 0 6.86-.49 9.28 9.28 0 0 0 4.05-4.07A13.05 13.05 0 0 0 231 21.6c.21-1.73.18-3.7-.09-5.32a13.03 13.03 0 0 0-1.5-4.3 9.1 9.1 0 0 0-3.75-3.63 9.15 9.15 0 0 0-4.43-.96 7.46 7.46 0 0 0-2.8.5A7.07 7.07 0 0 0 216 9.7c-.4.52-.82 1.12-1.1 1.59l-.07.14h-.27V0h-4.5Zm11.13-4.14c1.07.1 1.94.44 2.7 1.04a6.1 6.1 0 0 1 1.64 1.98c.43.84.78 2 .94 3.11.15 1.16.16 2.4.02 3.54a9.34 9.34 0 0 1-1.39 4.03 5.33 5.33 0 0 1-2.69 2.15c-.9.3-2.04.38-3.06.2a5.14 5.14 0 0 1-3.45-2.37 6.03 6.03 0 0 1-.45-.8c-.5-1.03-.8-2.2-.92-3.58-.04-.49-.06-.89-.05-1.53.01-.76.05-1.23.13-1.85.38-2.53 1.47-4.38 3.15-5.31a5.46 5.46 0 0 1 2.3-.63 10 10 0 0 1 1.13.02ZM69.05 2.17l-.01 2.77V7.7h-3.36v3.6h3.36v6.8l.01 7.15c.06 1.4.4 2.44 1.1 3.37a5.8 5.8 0 0 0 2.97 2.07c.91.3 1.83.42 2.9.38a8.71 8.71 0 0 0 2.66-.48l-.8-3.7-.38.06a4.96 4.96 0 0 1-2.43-.06c-.33-.1-.56-.25-.8-.49-.4-.41-.6-.88-.7-1.67-.02-.2-.02-.62-.03-6.82v-6.6h4.73V7.7h-4.73V2.16h-4.49ZM133.34 2.17V7.7h-3.39v3.6h3.38v6.9l.01 7.17a5.66 5.66 0 0 0 2.36 4.49c.85.6 2.03 1.03 3.26 1.17.85.1 2.03.05 2.81-.1.3-.06.75-.18 1-.26l.2-.06v-.05l-.81-3.67-.37.06a4.99 4.99 0 0 1-1.8.09c-.85-.13-1.32-.4-1.7-.97a2.63 2.63 0 0 1-.39-1.04c-.06-.4-.06 0-.06-7.1V11.3h4.7V7.7h-4.7l-.01-2.77V2.16h-4.49ZM293.41 2.36a14.56 14.56 0 0 0-13.7 16.07 14.59 14.59 0 0 0 21.86 11.08 14.5 14.5 0 0 0 7.11-14.07 14.61 14.61 0 0 0-6.53-10.73 14.49 14.49 0 0 0-8.74-2.35ZM350.8 2.36a10.17 10.17 0 0 0-7.56 4.2c-.16.2-.45.63-.58.83l-.05.1h-.47l-.01-4.36h-7.36v36.4h7.82V27.27h.49l.05.07a11.3 11.3 0 0 0 7.49 4.15 10.52 10.52 0 0 0 9.38-4.1c1.66-2.1 2.73-4.9 3.07-8.06.1-.87.13-1.4.13-2.37 0-.8 0-1.1-.07-1.76a15.95 15.95 0 0 0-3.23-8.72 12.8 12.8 0 0 0-1.85-1.84 10.49 10.49 0 0 0-7.26-2.28Zm-.94 6.05c1.27.15 2.33.65 3.2 1.5.98.96 1.67 2.31 2.03 4 .34 1.57.38 3.68.12 5.39a9.78 9.78 0 0 1-1.04 3.25c-.14.25-.44.69-.6.89a5.35 5.35 0 0 1-4.31 2.07 5.25 5.25 0 0 1-4.41-1.9 7.35 7.35 0 0 1-1.26-2.32 14.09 14.09 0 0 1-.62-4.83c.05-1.98.38-3.53 1.02-4.85a5.63 5.63 0 0 1 2.5-2.65c.66-.34 1.3-.5 2.14-.58.18-.02 1.04 0 1.23.03ZM363.63 3.1l-.01 3.2v3.16h1.43c1.26.01 1.44.02 1.54.04.42.09.66.28.79.62.08.23.08.08.08 2.96a911.57 911.57 0 0 1 .03 10.18v7.54h7.82v-7.4l.01-7.83c.03-.94.11-1.63.27-2.28.46-1.9 1.54-2.93 3.35-3.23.52-.08.2-.08 5-.08h4.4V3.08h-3.1c-3.48 0-3.91.01-4.67.1-1.83.2-3.04.79-3.96 1.88-.5.6-.9 1.32-1.26 2.26l-.06.17h-.46V3.09h-5.6c-4.46 0-5.6 0-5.6.02ZM390.8 16.95V30.8h3.87l3.86-.01V3.09h-7.73ZM400.6 3.1l-.01.4v.38l4.66 13.4 4.69 13.47.02.05h10.3l.03-.05 4.67-13.45 4.67-13.4V3.1h-7.43l-6.7 19.26h-.5l-3.28-9.5-3.31-9.64-.05-.12h-3.88l-3.88.01ZM430.98 3.1c-.01 0-.02.19-.02.4v.39l5.08 14.59c2.8 8.02 5.08 14.6 5.08 14.61.01.02-.22.02-4.8.02h-4.82v6.42h4.95c5.09 0 5.23 0 5.87-.06 3.15-.28 5.29-1.63 6.63-4.15.28-.55.44-.95.87-2.16L459 6.78l1-2.89v-.8h-7.43l-6.69 19.26h-.5l-3.27-9.46-3.31-9.64-.06-.16h-3.88l-3.88.01ZM36.57 7.36c-1.36.1-2.6.6-3.62 1.45a5.65 5.65 0 0 0-1.67 2.42l-.05.13H31V7.7h-4.35v23.08h4.5v-7.3c0-8 0-7.34.08-7.82a4.89 4.89 0 0 1 2.06-3.18c.83-.58 1.74-.89 2.87-.98a11.87 11.87 0 0 1 2.8.25H39v-4.3l-.21-.02c-.61-.07-1.74-.1-2.22-.07ZM51.08 7.41c-2.33.12-4.3.84-5.95 2.16a9.89 9.89 0 0 0-2.03 2.2 12.5 12.5 0 0 0-2 5.78 18.04 18.04 0 0 0 0 3.65 12.13 12.13 0 0 0 2.26 6.05 9.74 9.74 0 0 0 5 3.52c2.11.64 4.7.64 6.8 0a9.78 9.78 0 0 0 4.88-3.37c1.38-1.78 2.19-4 2.4-6.58.13-1.46.06-3.06-.18-4.42a11.24 11.24 0 0 0-3.58-6.6 10 10 0 0 0-5.75-2.35c-.56-.06-1.31-.07-1.85-.04Zm1.42 3.78c.88.1 1.62.34 2.28.75a6.13 6.13 0 0 1 1.99 2.15 10.31 10.31 0 0 1 1.2 5c.02 1.23-.12 2.44-.42 3.51a7.14 7.14 0 0 1-1.81 3.32c-.61.6-1.2.98-1.95 1.24a6 6 0 0 1-2 .3 5.7 5.7 0 0 1-2.72-.6 5 5 0 0 1-1.28-.94A7.1 7.1 0 0 1 46 22.73c-.57-1.99-.6-4.46-.08-6.5a7.24 7.24 0 0 1 2.03-3.67 5.13 5.13 0 0 1 3.35-1.4 11 11 0 0 1 1.2.03ZM92.05 7.4c-.96.06-1.56.15-2.3.33a9.62 9.62 0 0 0-6.09 4.66 13.5 13.5 0 0 0-1.71 7c0 .83 0 1.04.06 1.6.16 1.77.58 3.32 1.29 4.7A9.72 9.72 0 0 0 90.28 31c1.84.37 4.08.32 5.85-.13a9.07 9.07 0 0 0 5.02-3.1A7.64 7.64 0 0 0 102.5 25l-2.11-.39-2.11-.38-.08.13a4.72 4.72 0 0 1-2.35 2.55 6.3 6.3 0 0 1-2.23.58c-.29.03-1.13.03-1.44 0a6.35 6.35 0 0 1-3.02-1.04 5.93 5.93 0 0 1-2.02-2.43 8.44 8.44 0 0 1-.72-3.18v-.26h16.38v-.81c0-1.83-.06-2.76-.25-3.87-.2-1.22-.53-2.24-1.05-3.28a8.9 8.9 0 0 0-2.66-3.26 10.1 10.1 0 0 0-5.34-1.94 18.3 18.3 0 0 0-1.46-.03Zm1.3 3.75c1.2.13 2.19.55 3.05 1.3a5.8 5.8 0 0 1 1.78 2.96c.13.51.21 1.17.21 1.66v.15H86.43v-.12c.08-.97.3-1.78.72-2.61.5-1 1.2-1.8 2.14-2.42a5.32 5.32 0 0 1 2.9-.95c.2-.01.97 0 1.17.03ZM116.79 7.41c-2 .1-3.73.65-5.22 1.65a10.7 10.7 0 0 0-4.25 6.06 16.1 16.1 0 0 0-.5 5.8c.2 2.17.84 4.13 1.88 5.76.58.9 1.32 1.73 2.15 2.4a9.37 9.37 0 0 0 3.6 1.8 12.06 12.06 0 0 0 3.92.34 10.2 10.2 0 0 0 3.84-.95 8.31 8.31 0 0 0 4.76-6.75l.01-.04h-4.37l-.05.16a4.87 4.87 0 0 1-4.24 3.75c-.59.07-1.32.06-1.93-.05a5.47 5.47 0 0 1-3.5-2.27c-.56-.75-1-1.73-1.26-2.79a13.8 13.8 0 0 1-.16-5.24 7.77 7.77 0 0 1 2.1-4.3 5.48 5.48 0 0 1 2.15-1.3 6.4 6.4 0 0 1 3.89.1c.59.21 1.03.5 1.5.96a5.32 5.32 0 0 1 1.46 2.5l.04.15h4.37v-.06a8.22 8.22 0 0 0-5.31-6.94 10.98 10.98 0 0 0-4.88-.74ZM156.2 7.41a9.87 9.87 0 0 0-6 2.29 11.02 11.02 0 0 0-3.41 5.43c-.52 1.78-.68 3.9-.48 5.97.17 1.8.63 3.38 1.37 4.8a9.68 9.68 0 0 0 5.91 4.86c1.65.48 3.63.61 5.53.36 3.72-.49 6.55-2.62 7.56-5.69.12-.39.13-.42.1-.43-.02 0-4.13-.75-4.19-.75-.03 0-.04 0-.1.16-.18.42-.45.9-.72 1.22-.16.2-.49.53-.7.7-.67.54-1.5.9-2.43 1.08-.48.08-.83.11-1.41.11-.64 0-1.07-.04-1.6-.15a5.76 5.76 0 0 1-3.93-2.83 8 8 0 0 1-.99-3.79v-.16h16.38v-1.11l-.02-1.43c-.1-2.25-.53-4-1.35-5.59a9.24 9.24 0 0 0-6.18-4.75c-1.04-.26-2.2-.36-3.33-.3Zm1.45 3.74a5.35 5.35 0 0 1 3.66 1.94 6.1 6.1 0 0 1 1.38 4.01v.12h-11.97v-.06c0-.02 0-.14.02-.25a6.6 6.6 0 0 1 2.15-4.32 5.73 5.73 0 0 1 3.5-1.46c.25-.02 1 0 1.26.02ZM233.58 7.82l8.37 23.22a49.22 49.22 0 0 1-.67 1.9 5.36 5.36 0 0 1-1.14 1.8c-.41.4-.82.58-1.48.69-.27.04-1.03.03-1.35 0a8.05 8.05 0 0 1-1.1-.23l-1.08 3.67c0 .02.32.14.66.22.83.21 1.57.29 2.56.28.56-.01.8-.03 1.24-.1 2.71-.4 4.66-2.09 5.86-5.08l9.64-26.44c0-.02-4.82-.06-4.83-.05l-2.93 8.96-2.91 8.94h-.24l-.22-.65-2.91-8.95-2.7-8.3H233.53ZM293.05 35.8c-1.18.04-1.93.09-2.8.16-2.52.24-4.53.69-5.43 1.23-.7.41-.76.86-.2 1.28.88.66 3.29 1.19 6.36 1.4a48.55 48.55 0 0 0 5.75.05c3.47-.19 6.24-.78 7.11-1.5.22-.19.3-.34.3-.53 0-.1 0-.12-.04-.22-.35-.69-2.32-1.3-5.25-1.63a41.09 41.09 0 0 0-5.8-.24Zm0 0"})})})}let Do=/*#__PURE__*/Nt.div.withConfig({displayName:"TermsAndConditionsContainer",componentId:"sc-bdb69ecc-0"})(["margin-top:16px;font-size:13px;text-align:center;color:var(--privy-color-foreground-3);&& > a{color:var(--privy-color-accent);}"]);function zo({app:{legal:{privacyPolicyUrl:n,termsAndConditionsUrl:r,requireUsersAcceptTerms:a}},alwaysShowImplicitConsent:i}){let o=!(!n||!r);return a&&!i||!r&&!n?
|
|
2
2
|
/*#__PURE__*/t(Do,{}):
|
|
3
3
|
/*#__PURE__*/ /*#__PURE__*/e(Do,{children:["By logging in I agree to the"," ",r&&/*#__PURE__*/t("a",{href:r,target:"_blank",children:o?"Terms":"Terms of Service"}),o&&" & ",n&&/*#__PURE__*/t("a",{href:n,target:"_blank",children:"Privacy Policy"})]})}const Bo=()=>{let{appearance:e}=Lo();/*#__PURE__*/return t($o,{children:e.footerLogo??/*#__PURE__*/t("a",{href:"https://www.privy.io/",target:"_blank",id:"protected-by-privy",children:/*#__PURE__*/t(Fo,{height:13,width:150})})})},$o=/*#__PURE__*/Nt.div.withConfig({displayName:"ModalFooter",componentId:"sc-bdb69ecc-1"})(["display:flex;align-items:center;justify-content:center;padding-top:8px;padding-bottom:12px;gap:8px;font-size:13px;&& a{padding:0.5rem 0;&:hover{text-decoration:none;}}@media all and (display-mode:standalone){padding-bottom:30px;}"]),jo=({backFn:e})=>/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Zo,{onClick:e,children:/*#__PURE__*/t(Ut,{height:"16px",width:"16px",strokeWidth:2})})}),Vo=({nextFn:e})=>/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Zo,{onClick:e,children:/*#__PURE__*/t(Lt,{height:"16px",width:"16px",strokeWidth:2})})}),Ho=({infoFn:e})=>/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Go,{"aria-label":"info",onClick:e,children:/*#__PURE__*/t(Rt,{height:"22px",width:"22px",strokeWidth:2})})}),qo=e=>/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Zo,{"aria-label":"close modal",onClick:e.onClose,children:/*#__PURE__*/t(Ft,{height:"16px",width:"16px",strokeWidth:2})})}),Ko=({backFn:n,infoFn:r,onClose:a,title:i,closeable:o=!0})=>{let{closePrivyModal:s}=Q(),l=Lo();/*#__PURE__*/return e(Yo,{children:[/*#__PURE__*/e(Jo,{children:[n&&/*#__PURE__*/t(jo,{backFn:n}),r&&/*#__PURE__*/t(Ho,{infoFn:r})]}),i&&/*#__PURE__*/t(Qo,{id:"privy-dialog-title",children:i}),/*#__PURE__*/t(Xo,{children:!l.render.standalone&&o&&/*#__PURE__*/t(qo,{onClose:a||(()=>s())})})]})};let Zo=/*#__PURE__*/Nt.button.withConfig({displayName:"StyledButton",componentId:"sc-f295093d-0"})(["&&{cursor:pointer;display:flex;opacity:0.6;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-full);padding:4px;> svg{margin:auto;color:var(--privy-color-foreground);}:hover{opacity:1;}}"]),Go=/*#__PURE__*/Nt(Zo).withConfig({displayName:"TransparentStyledButton",componentId:"sc-f295093d-1"})(["&&{background-color:transparent;}"]),Yo=/*#__PURE__*/Nt.div.withConfig({displayName:"StyledHeader",componentId:"sc-f295093d-2"})(["padding:16px 0;display:flex;align-items:center;justify-content:space-between;h2{font-size:16px;line-height:24px;font-weight:600;color:var(--privy-color-foreground);}"]),Jo=/*#__PURE__*/Nt.div.withConfig({displayName:"LeftActionContainer",componentId:"sc-f295093d-3"})(["flex:1;align-items:center;display:flex;gap:8px;"]),Xo=/*#__PURE__*/Nt.div.withConfig({displayName:"RightActionContainer",componentId:"sc-f295093d-4"})(["flex:1;display:flex;justify-content:flex-end;"]),Qo=/*#__PURE__*/Nt.div.withConfig({displayName:"TitleContainer",componentId:"sc-f295093d-5"})(["overflow:hidden;white-space:nowrap;max-width:100%;text-overflow:ellipsis;text-align:center;color:var(--privy-color-foreground-2);"]);const es=({title:r,description:a,children:i,...o})=>
|
|
4
4
|
/*#__PURE__*/t(rs,{...o,children:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("h3",{children:r}),"string"==typeof a?/*#__PURE__*/t("p",{children:a}):a,i]})}),ts=/*#__PURE__*/Nt(es).withConfig({displayName:"PaddedScreenHeader",componentId:"sc-523a75d6-0"})(["margin-bottom:24px;"]),ns=({title:n,description:r,icon:a,children:i,...o})=>/*#__PURE__*/e(as,{...o,children:[a||null,/*#__PURE__*/t("h3",{children:n}),r&&"string"==typeof r?/*#__PURE__*/t("p",{children:r}):r,i]});let rs=/*#__PURE__*/Nt.div.withConfig({displayName:"StyledSection",componentId:"sc-523a75d6-1"})(["display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;text-align:left;gap:8px;width:100%;margin-bottom:24px;&& h3{font-size:17px;color:var(--privy-color-foreground);}&& p{color:var(--privy-color-foreground-2);font-size:14px;}"]),as=/*#__PURE__*/Nt(rs).withConfig({displayName:"CenteredStyledSection",componentId:"sc-523a75d6-2"})(["align-items:center;text-align:center;gap:16px;h3{margin-bottom:24px;}"]);const is=({address:n,showCopyIcon:r,url:a,className:i})=>{let[s,l]=o(!1);return d((()=>{if(s){let e=setTimeout((()=>l(!1)),2e3);return()=>clearTimeout(e)}}),[s]),a?/*#__PURE__*/t("a",{title:n,className:i,href:`${a}/address/${n}`,target:"_blank",children:dr(n)}):/*#__PURE__*/e("button",{title:n,className:i,onClick:e=>(e.stopPropagation(),navigator.clipboard.writeText(n).then((()=>l(!0))).catch(console.error)),children:[dr(n),r&&/*#__PURE__*/t(s?ss:os,{})]})};let os=/*#__PURE__*/Nt(zt).withConfig({displayName:"StyledSquare2StackIcon",componentId:"sc-6eaa0c94-0"})(["&&{display:inline;}stroke-width:2;height:0.875rem;width:0.875rem;margin-left:0.125rem;color:var(--privy-color-foreground-3);"]),ss=/*#__PURE__*/Nt(Dt).withConfig({displayName:"StyledCheckIcon",componentId:"sc-6eaa0c94-1"})(["&&{display:inline;}stroke-width:2;height:0.875rem;width:0.875rem;margin-left:0.125rem;color:var(--privy-color-success);"]);const ls=/*#__PURE__*/Nt.div.withConfig({displayName:"Grow",componentId:"sc-ddbf22b4-0"})(["text-align:left;flex-grow:1;"]),cs=/*#__PURE__*/Nt.div.withConfig({displayName:"AlignBottom",componentId:"sc-ddbf22b4-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),ds=/*#__PURE__*/Nt.div.withConfig({displayName:"LoginMethodContainer",componentId:"sc-ddbf22b4-2"})(["display:flex;flex-direction:column;gap:12px;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]),ps=/*#__PURE__*/Nt(ds).withConfig({displayName:"LoginMethodContainerWithScrollShadows",componentId:"sc-ddbf22b4-3"})([""," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;max-height:400px;overflow-y:auto;scrollbar-width:none;padding:2px;"],(e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0));let hs=/*#__PURE__*/Mt(["&&{width:100%;font-size:16px;line-height:24px;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-mdlg);transition:background-color 200ms ease;cursor:pointer;&:hover{background-color:var(--privy-color-background-2);}&:disabled{cursor:pointer;background-color:var(--privy-color-background-2);}svg{height:24px;max-height:24px;max-width:24px;}}"]);const us=/*#__PURE__*/Nt.div.withConfig({displayName:"Subtitle",componentId:"sc-ddbf22b4-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),ms=/*#__PURE__*/Nt.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-ddbf22b4-5"})(["",""],hs),gs=/*#__PURE__*/Nt.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-ddbf22b4-6"})(["",""],hs),ys=/*#__PURE__*/Nt.div.withConfig({displayName:"Hide",componentId:"sc-ddbf22b4-7"})(["width:100%;height:100%;min-height:inherit;display:flex;flex-direction:column;",""],(e=>e.$if?"display: none;":"")),fs=/*#__PURE__*/Nt.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-ddbf22b4-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),ws=/*#__PURE__*/Nt.div.withConfig({displayName:"Header",componentId:"sc-ddbf22b4-9"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-bottom:32px;gap:12px;& h3{font-size:18px;font-style:normal;font-weight:600;line-height:24px;}& p{max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;}"]),vs=({chainType:n,withPadding:r})=>{let a="";return a="ethereum-only"===n||"ethereum-and-solana"===n?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/t(fs,{$withPadding:r,children:/*#__PURE__*/e(ws,{children:[/*#__PURE__*/t(Rt,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/t("h3",{children:"No wallets available"}),/*#__PURE__*/e("p",{children:["Please download an external wallet provider, like ",a,"."]})]})},"empty-wallet-state")},bs=({icon:e,name:n})=>"string"==typeof e?/*#__PURE__*/t("img",{alt:`${n||"wallet"} logo`,src:e,style:{height:24,width:24,borderRadius:4}}):void 0===e?/*#__PURE__*/t(Bt,{}):e?/*#__PURE__*/t(e,{}):null;let Cs=/*#__PURE__*/Pt(["from,to{background:var(--privy-color-foreground-4);color:var(--privy-color-foreground-4);}50%{background:var(--privy-color-foreground-accent);color:var(--privy-color-foreground-accent);}"]);const ks=/*#__PURE__*/Mt(["",""],(e=>e.$isLoading?/*#__PURE__*/Mt(["width:35%;animation:"," 2s linear infinite;border-radius:var(--privy-border-radius-sm);"],Cs):"")),xs=({children:e,color:n,isLoading:r,isPulsing:a,...i})=>/*#__PURE__*/t(Ts,{$color:n,$isLoading:r,$isPulsing:a,...i,children:e});let Ts=/*#__PURE__*/Nt.span.withConfig({displayName:"StyledSpan",componentId:"sc-eba15c9-0"})(["padding:0.125rem 0.5rem;font-size:0.75rem;font-weight:500;line-height:1.125rem;border-radius:var(--privy-border-radius-sm);display:flex;align-items:center;"," ",""],(e=>{let t,n;"green"===e.$color&&(t="var(--privy-color-success-dark)",n="var(--privy-color-success-light)"),"red"===e.$color&&(t="var(--privy-color-error)",n="var(--privy-color-error-light)"),"gray"===e.$color&&(t="var(--privy-color-foreground-2)",n="var(--privy-color-background-2)");let r=/*#__PURE__*/Pt(["from,to{background-color:",";}50%{background-color:rgba(",",0.8);}"],n,n);/*#__PURE__*/return Mt(["color:",";background-color:",";",";"],t,n,e.$isPulsing&&/*#__PURE__*/Mt(["animation:"," 3s linear infinite;"],r))}),ks);function As(e){let t=e.toLowerCase();return!!window?.webkit?.messageHandlers?.ReactNativeWebView||!!window?.ReactNativeWebView||["fbav","fban","instagram","snapchat","linkedinapp"].some((e=>t.includes(e)))}const Is={login:{onComplete:[],onError:[]},logout:{onSuccess:[]},connectWallet:{onSuccess:[],onError:[]},connectOrCreateWallet:{onSuccess:[],onError:[]},createWallet:{onSuccess:[],onError:[]},linkAccount:{onSuccess:[],onError:[]},update:{onSuccess:[],onError:[]},configureMfa:{onMfaRequired:[]},setWalletPassword:{onSuccess:[],onError:[]},setWalletRecovery:{onSuccess:[],onError:[]},signMessage:{onSuccess:[],onError:[]},signTypedData:{onSuccess:[],onError:[]},sendTransaction:{onSuccess:[],onError:[]},signTransaction:{onSuccess:[],onError:[]},signSolanaTransaction:{onSuccess:[],onError:[]},signSolanaMessage:{onSuccess:[],onError:[]},sendSolanaTransaction:{onSuccess:[],onError:[]},accessToken:{onAccessTokenGranted:[],onAccessTokenRemoved:[]},oAuthAuthorization:{onOAuthTokenGrant:[]},fundWallet:{onUserExited:[]},fundSolanaWallet:{onUserExited:[]},customAuth:{onAuthenticated:[],onUnauthenticated:[]}},_s=/*#__PURE__*/c(void 0);let Es=()=>l(_s);function Ss(e,t){if(!t)return;let n=Es().current[e];return d((()=>{for(let[r,a]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,r)||console.warn(`Invalid event type "${r}" for action "${e}"`),n[r]?.push(a);return()=>{for(let[r,a]of Object.entries(t))Object.prototype.hasOwnProperty.call(n,r)||console.warn(`Invalid event type "${r}" for action "${e}"`),n[r]=n[r]?.filter((e=>e!==a))}}),[t])}function Ns(e,t,n,...r){for(let a of e.current[t][n])a(...r)}function Ms(){let e=Es();return(t,n,...r)=>Ns(e,t,n,...r)}let Ps=/*#__PURE__*/c({});const Ws=({children:e})=>{let n=Lo(),[r,a]=o({});return Ss("login",{onComplete:({loginAccount:e})=>{e&&"passkey"!==e.type&&"cross_app"!==e.type&&("wallet"!==e.type||"privy"!==e.walletClientType)&&(rr.put(Os(n.id),e.type),"wallet"===e.type?(rr.put(Us(n.id),e.walletClientType),rr.put(Ls(n.id),e.chainType),a({accountType:e.type,walletClientType:e.walletClientType,chainType:e.chainType})):(rr.del(Us(n.id)),rr.del(Ls(n.id)),a({accountType:e.type})))}}),d((()=>{if(!n.id)return;let e=rr.get(Os(n.id)),t=rr.get(Us(n.id)),r=rr.get(Ls(n.id));e&&a("wallet"===e?{accountType:e,walletClientType:t,chainType:r}:{accountType:e})}),[n.id]),/*#__PURE__*/t(Ps.Provider,{value:r,children:e})};let Os=e=>`privy:${e}:recent-login-method`,Us=e=>`privy:${e}:recent-login-wallet-client`,Ls=e=>`privy:${e}:recent-login-chain-type`;const Rs=()=>l(Ps),Fs=({success:r,fail:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ds,{className:r?"success":a?"fail":""}),/*#__PURE__*/t(zs,{className:r?"success":a?"fail":""})]}),Ds=/*#__PURE__*/Nt.span.withConfig({displayName:"Loader",componentId:"sc-ce7792e2-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";border-bottom-color:transparent;border-radius:50%;display:inline-block;box-sizing:border-box;animation:rotation 1.2s linear infinite;transition:border-color 800ms;}@keyframes rotation{0%{transform:rotate(0deg);}100%{transform:rotate(360deg);}}&&&.success{border-color:var(--privy-color-success);border-bottom-color:var(--privy-color-success);}&&&.fail{border-color:var(--privy-color-error);border-bottom-color:var(--privy-color-error);}"],(e=>e.color??"var(--privy-color-accent)")),zs=/*#__PURE__*/Nt(Ds).withConfig({displayName:"LoaderFaint",componentId:"sc-ce7792e2-1"})(["&&{border-bottom-color:",";animation:none;opacity:0.5;}"],(e=>e.color??"var(--privy-color-accent)")),Bs=e=>/*#__PURE__*/t($s,{color:e.color||"var(--privy-color-foreground-3)"});let $s=/*#__PURE__*/Nt(Ds).withConfig({displayName:"StyledButtonLoader",componentId:"sc-ce7792e2-2"})(["&&{height:1rem;width:1rem;margin:2px 0;border-width:1.5px;transition:border-color 200ms ease;}"]);const js=/*#__PURE__*/Nt.button.withConfig({displayName:"Button",componentId:"sc-3253171f-0"})(["display:flex;flex-direction:row;align-items:center;justify-content:center;user-select:none;&{width:100%;cursor:pointer;border-radius:var(--privy-border-radius-md);font-size:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{padding:12px 16px;}"]),Vs=({children:n,loading:r,disabled:a,success:i,loadingText:o="Loading...",...s})=>/*#__PURE__*/t(Zs,{disabled:r||a,success:i,...s,children:r?/*#__PURE__*/e("span",{children:[/*#__PURE__*/t(Bs,{}),o?/*#__PURE__*/t("span",{children:o}):null]}):n}),Hs=({children:e,loading:n,disabled:r,...a})=>/*#__PURE__*/t(qs,{disabled:r,...a,children:n?/*#__PURE__*/t(Bs,{color:"var(--privy-color-foreground-accent)"}):e});let qs=/*#__PURE__*/Nt(js).withConfig({displayName:"StyledPrimaryButtonWithoutGray",componentId:"sc-3253171f-1"})(["position:relative;&&{background-color:var(--privy-color-accent);color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:disabled,&:hover:disabled,&:active:disabled{cursor:not-allowed;pointer-events:none;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent-dark);}"]);const Ks=({children:n,loading:r,disabled:a,loadingText:i="Loading...",...o})=>/*#__PURE__*/t(Zs,{as:"a",disabled:r||a,...o,children:r?/*#__PURE__*/e("span",{children:[/*#__PURE__*/t(Bs,{}),i?/*#__PURE__*/t("span",{children:i}):null]}):n});let Zs=/*#__PURE__*/Nt(js).withConfig({displayName:"StyledPrimaryButton",componentId:"sc-3253171f-2"})(["position:relative;&&{background-color:",";color:var(--privy-color-foreground-accent);transition:background-color 200ms ease;}&:hover{background-color:",";}&:active{background-color:",";}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}"," > span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],(e=>e.warn?"var(--privy-color-error)":e.success?"var(--privy-color-success)":"var(--privy-color-accent)"),(e=>e.warn?"var(--privy-color-error)":e.success?"var(--privy-color-success)":"var(--privy-color-accent-dark)"),(e=>e.warn?"var(--privy-color-error)":e.success?"var(--privy-color-success)":"var(--privy-color-accent-dark)"),(e=>e.disabled?/*#__PURE__*/Mt(["&&&,&&&:hover,&&&:active{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;pointer-events:none;}"]):""));const Gs=({children:n,loading:r,disabled:a,loadingText:i="Loading...",...o})=>/*#__PURE__*/t(Ys,{disabled:r||a,...o,children:r?/*#__PURE__*/e("span",{children:[/*#__PURE__*/t(Bs,{}),i?/*#__PURE__*/t("span",{children:i}):null]}):n});let Ys=/*#__PURE__*/Nt(js).withConfig({displayName:"StyledSecondaryButton",componentId:"sc-3253171f-3"})(["&&{border-width:1px;border-color:",";color:var(--privy-color-foreground);transition:border-color 200ms ease;}&:hover,&:active{border-color:",";}&:hover:disabled,&:active:disabled{border-color:var(--privy-color-foreground-accent);color:var(--privy-color-foreground-3);cursor:not-allowed;}> span{display:flex;align-items:center;gap:8px;opacity:1;animation:fadein 200ms ease;}"],(e=>e.warn?"var(--privy-color-error)":"var(--privy-color-foreground-4)"),(e=>e.warn?"var(--privy-color-error)":"var(--privy-color-foreground-3)"));const Js=/*#__PURE__*/Nt.button.withConfig({displayName:"SoftCtaButton",componentId:"sc-3253171f-4"})(["&&{padding:12px 16px;font-weight:500;text-align:center;color:var(--privy-color-foreground-accent);background-color:var(--privy-color-accent);border-radius:var(--privy-border-radius-sm);min-width:144px;opacity:",";transition:opacity 200ms ease,background-color 200ms ease,color 200ms ease;user-select:none;"," &:hover{background-color:var(--privy-color-accent-dark);}&:active{background-color:var(--privy-color-accent-dark);}&:hover:disabled,&:active:disabled{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;}}"],(e=>e.invisible?"0":"1"),(e=>e.invisible&&/*#__PURE__*/Mt(["pointer-events:none;"]))),Xs=({children:n,onClick:r,disabled:a,isSubmitting:i,...o})=>/*#__PURE__*/e(Qs,{$isSubmitting:i,onClick:r,disabled:a,...o,children:[/*#__PURE__*/t("span",{children:n}),
|
|
@@ -23,5 +23,5 @@ return t(Fm,{...Lo().render.standalone?{defaultValue:"details"}:{},children:/*#_
|
|
|
23
23
|
/*#__PURE__*/e(gw,{children:[/*#__PURE__*/t("iframe",{style:{position:"absolute",zIndex:1},width:r,height:n.dimensions.height,allow:"clipboard-write self *",src:mr(n.origin,`/apps/${n.appId}/embedded-wallets/export`,{client_id:n.appClientId,primaryAddress:n.primaryWallet.address,address:n.walletToExport.address,walletIndex:n.walletToExport.walletIndex,width:`${r}px`,caid:n.clientAnalyticsId,phrase_export:p,...s},{token:n.accessToken})}),/*#__PURE__*/t(yw,{children:"Loading..."}),p&&/*#__PURE__*/t(yw,{children:"Loading..."})]})})}const uw={component:()=>{let[r,a]=o(null),{authenticated:i,user:s,getAccessToken:l}=gl(),{closePrivyModal:c,createAnalyticsEvent:p,clientAnalyticsId:h}=Q(),u=Lo(),{data:m,onUserCloseViaDialogOrKeybindRef:g}=Tu(),{onFailure:y,onSuccess:f,origin:w,appId:v,appClientId:b,walletToExport:C,primaryWallet:k}=m.keyExport,x=e=>{c({shouldCallAuthOnSuccess:!1}),y("string"==typeof e?Error(e):e)},T=()=>{c({shouldCallAuthOnSuccess:!1}),f(),p({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:C.address}})};return d((()=>{if(!i||!C)return x("User must be authenticated before exporting their wallet");l().then(a,x)}),[i,s]),g.current=T,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{onClose:T}),/*#__PURE__*/e(mw,{children:[/*#__PURE__*/t(Pd,{children:"Transfer wallet"}),/*#__PURE__*/e(Md,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",/*#__PURE__*/t("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),/*#__PURE__*/t(dw,{theme:u.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),/*#__PURE__*/t(ny,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:C.address,showIcon:!0}),/*#__PURE__*/t("div",{style:{width:"100%"},children:r&&/*#__PURE__*/t(hw,{origin:w,appId:v,appClientId:b,accessToken:r,clientAnalyticsId:h,walletToExport:C,primaryWallet:k,dimensions:{height:"44px"}})})]}),/*#__PURE__*/t(Bo,{})]})}};let mw=/*#__PURE__*/Nt.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-f9e8f1f7-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),gw=/*#__PURE__*/Nt.div.withConfig({displayName:"ButtonContainer",componentId:"sc-f9e8f1f7-1"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),yw=/*#__PURE__*/Nt.div.withConfig({displayName:"LoadingButton",componentId:"sc-f9e8f1f7-2"})(["display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:16px;font-weight:500;border-radius:var(--privy-border-radius-md);background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);"]);const fw={component:()=>{let{authenticated:r,user:a,getAccessToken:i}=gl(),{closePrivyModal:l,createAnalyticsEvent:c,walletProxy:p}=Q(),{navigate:h,data:u,setModalData:m,onUserCloseViaDialogOrKeybindRef:g}=Tu(),y=s((()=>Date.now()),[]),[f,w]=o(!1),{onCompleteNavigateTo:v,onFailure:b,shouldForceMFA:C,entropyId:k,entropyIdVerifier:x,recoveryMethod:T,connectingWalletAddress:A}=u?.connectWallet,I=e=>{f||(w(!0),b("string"==typeof e?Error(e):e))};d((()=>{let e;return r?p?((async()=>{let t=await i();if(!t)return I("User must be authenticated and have a Privy wallet before it can be connected");try{await p.connect({accessToken:t,entropyId:k,entropyIdVerifier:x}),C&&await p.verifyMfa({accessToken:t});let n=(Date.now()-y)/1e3;v===uw&&n<1?e=setTimeout((()=>{h(v,!1)}),1e3*(1-n)):h(v,!1)}catch(e){if(Ul(e)&&"privy"===T){let e=await i();if(!e)return I("User must be authenticated and have a Privy wallet before it can be recovered");try{c({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:A}});let t=await(p?.recover({accessToken:e,entropyId:k,entropyIdVerifier:x}));t?.entropyId||I(Error("Unable to recover wallet")),v?h(v):l({shouldCallAuthOnSuccess:!1}),c({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:A}}),h(v)}catch(e){I("An error has occurred, please try again.")}}else Ul(e)&&"privy"!==T?(m({...u,recoverWallet:{entropyId:k,entropyIdVerifier:x,onCompleteNavigateTo:v,onFailure:b},recoveryOAuthStatus:{provider:T,action:"recover",isInAccountCreateFlow:!1}}),h(Ld(T))):I(e)}})(),()=>clearTimeout(e)):void 0:I("User must be authenticated and have a Privy wallet before it can be connected")}),[r,a,p]);let _=()=>{I("User exited before wallet could be connected"),l({shouldCallAuthOnSuccess:!1})};return g.current=_,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{onClose:_}),f?/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(al,{children:[/*#__PURE__*/t(en,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(ns,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),/*#__PURE__*/t(Vs,{onClick:()=>l({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):/*#__PURE__*/t(gc,{}),/*#__PURE__*/t(ww,{})]})}};let ww=/*#__PURE__*/Nt.div.withConfig({displayName:"BottomSpacing",componentId:"sc-dfa076bb-0"})(["height:44px;"]);const vw=/*#__PURE__*/Nt(Uy).withConfig({displayName:"InteractiveLabel",componentId:"sc-b57d0824-0"})(["cursor:pointer;display:inline-flex;gap:8px;align-items:center;color:var(--privy-color-accent);svg{fill:var(--privy-color-accent);}"]);var bw=({iconUrl:n,value:r,symbol:a,usdValue:i,nftName:o,$isLoading:s})=>s?/*#__PURE__*/t(Cw,{$isLoading:s}):/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(Cw,{$isLoading:s,children:[n&&/*#__PURE__*/t(xw,{src:n,alt:"Token icon"}),o,r," ",a]}),i&&/*#__PURE__*/e(kw,{$isLoading:s,children:["$",i]})]});let Cw=/*#__PURE__*/Nt.span.withConfig({displayName:"Value",componentId:"sc-d8e62921-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],ks);const kw=/*#__PURE__*/Nt.span.withConfig({displayName:"Subvalue",componentId:"sc-d8e62921-1"})(["color:var(--privy-color-foreground-2);font-size:12px;font-weight:400;line-height:18px;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],ks);let xw=/*#__PURE__*/Nt.img.withConfig({displayName:"TokenIcon",componentId:"sc-d8e62921-2"})(["height:14px;width:14px;margin-right:4px;object-fit:contain;"]);const Tw=r=>{let{chain:a,transactionDetails:i,isTokenContractInfoLoading:o,symbol:s}=r,{action:l,functionName:c}=i;/*#__PURE__*/return t(ty,{children:/*#__PURE__*/e(Wy,{children:["transaction"!==l&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Action"}),/*#__PURE__*/t(Ry,{children:c})]}),"mint"===c&&"args"in i&&i.args.filter((e=>e)).map(((n,r)=>/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:`Param ${r}`}),/*#__PURE__*/t(Ry,{children:"string"==typeof n&&nt(n)?/*#__PURE__*/t(is,{address:n,url:a?.blockExplorers?.default?.url,showCopyIcon:!1}):n?.toString()})]},r))),"setApprovalForAll"===c&&i.operator&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Operator"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:i.operator,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===c&&void 0!==i.approved&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Set approval to"}),/*#__PURE__*/t(Ry,{children:i.approved?"true":"false"})]}),"transfer"===c||"transferFrom"===c||"safeTransferFrom"===c||"approve"===c?/*#__PURE__*/e(n,{children:["formattedAmount"in i&&i.formattedAmount&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Amount"}),/*#__PURE__*/e(Ry,{$isLoading:o,children:[i.formattedAmount," ",s]})]}),"tokenId"in i&&i.tokenId&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Token ID"}),/*#__PURE__*/t(Ry,{children:i.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===c&&/*#__PURE__*/e(n,{children:["amounts"in i&&i.amounts&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Amounts"}),/*#__PURE__*/t(Ry,{children:i.amounts.join(", ")})]}),"tokenIds"in i&&i.tokenIds&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Token IDs"}),/*#__PURE__*/t(Ry,{children:i.tokenIds.join(", ")})]})]}),"approve"===c&&i.spender&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Spender"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:i.spender,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferFrom&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Transferring from"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:i.transferFrom,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferTo&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Transferring to"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:i.transferTo,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})};let Aw={success:"background: var(--privy-color-success-lightest, #dcfce7);",warn:"background: var(--privy-color-warn-lightest, #fff7e6);",error:"background: var(--privy-color-error-lightest, #fde8e8);"};const Iw=/*#__PURE__*/Nt.div.withConfig({displayName:"Pill",componentId:"sc-8c138024-0"})(["border-radius:var(--privy-border-radius-md,8px);padding:12px;text-align:left;margin-top:23px;",""],(e=>Aw[e.variant])),_w=({variant:n,setPreventMaliciousTransaction:r,preventMaliciousTransaction:a})=>"warn"===n?/*#__PURE__*/t(Iw,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t(Ew,{variant:n}),/*#__PURE__*/e("p",{children:[/*#__PURE__*/t("b",{children:"Warning: Suspicious transaction"}),/*#__PURE__*/t("br",{}),"This has been flagged as a potentially deceptive request. Approving could put your assets or funds at risk."]})]})}):"error"===n?/*#__PURE__*/t(Iw,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-col",children:[/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t(Ew,{variant:n}),/*#__PURE__*/e("p",{children:[/*#__PURE__*/t("b",{children:"This is a malicious transaction"}),/*#__PURE__*/t("br",{}),"This transaction transfers tokens to a known malicious address. Proceeding may result in the loss of valuable assets."]})]}),/*#__PURE__*/e("div",{className:"mt-3 flex flex-row gap-2",children:[/*#__PURE__*/t(Yc,{color:"var(--privy-color-error)",checked:!a,readOnly:!0,onClick:()=>r(!a)}),/*#__PURE__*/t("p",{children:"I understand and want to proceed anyways."})]})]})}):void 0;let Ew=/*#__PURE__*/Nt(Yt).withConfig({displayName:"StyledExclamationTriangleIcon",componentId:"sc-e6305f32-0"})(["width:20px;height:20px;stroke-width:2px;flex-shrink:0;display:inline-block;margin-right:8px;",";"],(e=>"error"===e.variant?"color: var(--privy-color-error)":"color: var(--privy-color-warn)"));const Sw=({transactionIndex:e,maxIndex:t})=>"number"!=typeof e||0===t?"":` (${e+1} / ${t+1})`,Nw=({img:r,submitError:a,prepareError:i,onClose:s,action:l,title:c,subtitle:d,txValue:p,to:h,tokenAddress:u,network:m,missingFunds:g,fee:y,from:f,cta:w,disabled:v,chain:b,isSubmitting:C,isPreparing:k,isTokenPriceLoading:x,isTokenContractInfoLoading:T,isSponsored:A,symbol:I,balance:_,onClick:E,transactionDetails:S,transactionIndex:N,maxIndex:M,onBack:P,chainName:W,validation:O,hasScanDetails:U,setIsScanDetailsOpen:L,preventMaliciousTransaction:R,setPreventMaliciousTransaction:F,tokensSent:D,tokensReceived:z,isScanning:B,isCancellable:$})=>{let{showTransactionDetails:j,setShowTransactionDetails:V,hasMoreDetails:H,isErc20Ish:q}=(e=>{let[t,n]=o(!1),r=!0,a=!1;return(!e||e.isErc20Ish||"transaction"===e.action)&&(r=!1),r&&(a=Object.entries(e||{}).some((([e,t])=>t&&!["action","isErc20Ish","isNFTIsh"].includes(e)))),{showTransactionDetails:t,setShowTransactionDetails:n,hasMoreDetails:r&&a,isErc20Ish:e?.isErc20Ish}})(S),K=q&&T||k||x||B;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{onClose:s,backFn:P}),r&&/*#__PURE__*/t(Ow,{children:r}),/*#__PURE__*/e(Pd,{style:{marginTop:r?"1.5rem":0},children:[c,/*#__PURE__*/t(Sw,{maxIndex:M,transactionIndex:N})]}),/*#__PURE__*/t(Md,{children:d}),/*#__PURE__*/e(Wy,{style:{marginTop:"2rem"},children:[(!!D[0]||K)&&/*#__PURE__*/e(Oy,{children:[z.length>0?/*#__PURE__*/t(Uy,{children:"Send"}):/*#__PURE__*/t(Uy,{children:"Amount"}),/*#__PURE__*/t(bw,{iconUrl:D[0]?.iconUrl,value:D[0]?.value,usdValue:D[0]?.usdValue,symbol:D[0]?.symbol,nftName:D[0]?.nftName,$isLoading:K})]}),z.length>0&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Receive"}),/*#__PURE__*/t("div",{className:"flex flex-col",children:z.map(((e,n)=>/*#__PURE__*/t(bw,{iconUrl:e.iconUrl,value:e.value,usdValue:e.usdValue,symbol:e.symbol,nftName:e.nftName},n)))})]}),S&&"spender"in S&&S?.spender?/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Spender"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:S.spender,url:b?.blockExplorers?.default?.url,showCopyIcon:!1})})]}):null,h&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"To"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:h,url:b?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),u&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Token address"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:u,url:b?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Network"}),/*#__PURE__*/t(Ry,{children:m})]}),/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Estimated fee"}),/*#__PURE__*/t(Ry,{$isLoading:k||x||void 0===A,children:A?"Sponsored":y})]}),H&&!U&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Oy,{className:"cursor-pointer",onClick:()=>V(!j),children:/*#__PURE__*/e(Ly,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/t(Fn,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:j?"rotate(180deg)":void 0}})]})}),j&&S&&/*#__PURE__*/t(Tw,{action:l,chain:b,transactionDetails:S,isTokenContractInfoLoading:T,symbol:I})]}),U&&/*#__PURE__*/t(Oy,{children:/*#__PURE__*/e(vw,{onClick:()=>L(!0),children:[/*#__PURE__*/t("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/t(Dn,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/t(ls,{}),a?/*#__PURE__*/t(Wh,{style:{marginTop:"2rem"},children:a.message}):i?/*#__PURE__*/t(Wh,{style:{marginTop:"2rem"},children:i.shortMessage??Ww}):null,/*#__PURE__*/t(_w,{variant:O,preventMaliciousTransaction:R,setPreventMaliciousTransaction:F}),/*#__PURE__*/t(Pw,{$useSmallMargins:!(!i&&!a&&"warn"!==O&&"error"!==O),title:Number(p)>0?void 0:!1!==A?"Your wallet":void 0,address:f,balance:_,isLoading:k||x,errMsg:k||i||a||!g?void 0:`Add funds on ${b?.name??W} to complete transaction.`}),/*#__PURE__*/t(Vs,{style:{marginTop:"1rem"},loading:C,disabled:v||k,onClick:E,children:w}),$&&/*#__PURE__*/t(Xs,{style:{marginTop:"1rem"},onClick:s,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(Bo,{})]})},Mw=({img:r,title:a,subtitle:i,cta:o,network:s,blockExplorerUrl:l,transactionIndex:c,maxIndex:d,isMissingFunds:p,submitError:h,parseError:u,total:m,amount:g,fee:y,balance:f,from:w,to:v,tokenAddress:b,tokenAccount:C,tokenAccountOwner:k,programAddress:x,transactingWalletAddress:T,disabled:A,isSubmitting:I,isPreparing:_,isTokenPriceLoading:E,onClick:S,onClose:N,onBack:M})=>{let P=_||E;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{onClose:N,backFn:M}),r&&/*#__PURE__*/t(Ow,{children:r}),/*#__PURE__*/e(Pd,{style:{marginTop:r?"1.5rem":0},children:[a,/*#__PURE__*/t(Sw,{maxIndex:d,transactionIndex:c})]}),/*#__PURE__*/t(Md,{children:i}),/*#__PURE__*/e(Wy,{style:{marginTop:"2rem"},children:[(m||P)&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Total"}),/*#__PURE__*/t(Ry,{$isLoading:P,children:m})]}),w&&w!==T&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"From"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:w,url:l,showCopyIcon:!1})})]}),v&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"To"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:v,url:l,showCopyIcon:!1})})]}),k&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Token account owner"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:k,url:l,showCopyIcon:!1})})]}),C&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Token account"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:C,url:l,showCopyIcon:!1})})]}),b&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Token address"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:b,url:l,showCopyIcon:!1})})]}),x&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Program address"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(is,{address:x,url:l,showCopyIcon:!1})})]}),s&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Network"}),/*#__PURE__*/t(Ry,{children:s})]}),(g||P)&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Amount"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(Ry,{$isLoading:P,children:g})})]}),(y||P)&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Estimated fee"}),/*#__PURE__*/t(Ry,{$isLoading:P,children:y})]})]}),/*#__PURE__*/t(ls,{}),h?/*#__PURE__*/t(Wh,{style:{marginTop:"2rem"},children:h.message}):u?/*#__PURE__*/t(Wh,{style:{marginTop:"2rem"},children:Ww}):null,/*#__PURE__*/t(Pw,{$useSmallMargins:!(!u&&!h),title:"Your wallet",address:T,balance:f,isLoading:_||E,errMsg:_||u||h||!p?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/t(Vs,{style:{marginTop:"1rem"},loading:I,disabled:A||_,onClick:S,children:o}),/*#__PURE__*/t(Bo,{})]})};let Pw=/*#__PURE__*/Nt(ny).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-4bd3bb7d-0"})(["",""],(e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;")),Ww="There was an error preparing your transaction. Your transaction request will likely fail.",Ow=/*#__PURE__*/Nt.div.withConfig({displayName:"ImageContainer",componentId:"sc-4bd3bb7d-1"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),Uw=()=>/*#__PURE__*/e(zw,{children:[/*#__PURE__*/t($w,{}),/*#__PURE__*/t(Bw,{})]});const Lw=({transactionError:r,chainId:a,onClose:i,onRetry:s,network:l,connection:c,transactionHash:d})=>{let{chains:p}=Q(),[h,u]=o(!1),{errorCode:m,errorMessage:g}=((e,t)=>{if("ethereum"===t)return{errorCode:e.details??e.message,errorMessage:e.shortMessage};let n=e.txSignature,r=e?.transactionMessage||"Something went wrong.";if(Array.isArray(e.logs)){let t=e.logs.find((e=>/insufficient (lamports|funds)/gi.test(e)));t&&(r=t)}return{transactionHash:n,errorMessage:r}})(r,l),y=(({chains:e,chainId:t,network:n,connection:r,transactionHash:a})=>"ethereum"===n?e.find((e=>e.id===t))?.blockExplorers?.default.url??"https://etherscan.io":function(e,t){return`https://explorer.solana.com/tx/${e}?cluster=${t}`}(a||"",Io(r?.rpcEndpoint||"")))({chains:p,chainId:a,network:l,connection:c,transactionHash:d});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{onClose:i}),/*#__PURE__*/e(Rw,{children:[/*#__PURE__*/t(Uw,{}),/*#__PURE__*/t(Fw,{children:m}),/*#__PURE__*/t(Dw,{children:"Please try again."}),/*#__PURE__*/e(Hw,{children:[/*#__PURE__*/t(Vw,{children:"Error message"}),/*#__PURE__*/t(Kw,{$clickable:!1,children:g})]}),d&&/*#__PURE__*/e(Hw,{children:[/*#__PURE__*/t(Vw,{children:"Transaction hash"}),/*#__PURE__*/e(qw,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/t("u",{children:/*#__PURE__*/t("a",{href:y,children:"block explorer"})}),"."]}),/*#__PURE__*/e(Kw,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(d),u(!0)},children:[d,/*#__PURE__*/t(Yw,{clicked:h})]})]}),/*#__PURE__*/t(jw,{onClick:()=>s({resetNonce:!!d}),children:"Retry transaction"})]}),/*#__PURE__*/t($o,{})]})};let Rw=/*#__PURE__*/Nt.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-6e9001c5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),Fw=/*#__PURE__*/Nt.span.withConfig({displayName:"ErrorCode",componentId:"sc-6e9001c5-1"})(["color:var(--privy-color-foreground);text-align:center;font-size:1.125rem;font-weight:500;line-height:1.25rem;text-align:center;margin:10px;"]),Dw=/*#__PURE__*/Nt.span.withConfig({displayName:"Subtitle",componentId:"sc-6e9001c5-2"})(["margin-top:4px;margin-bottom:10px;color:var(--privy-color-foreground-3);text-align:center;font-size:0.875rem;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;"]),zw=/*#__PURE__*/Nt.div.withConfig({displayName:"CircleContainer",componentId:"sc-6e9001c5-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),Bw=/*#__PURE__*/Nt(Jt).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-6e9001c5-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),$w=/*#__PURE__*/Nt.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-6e9001c5-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),jw=/*#__PURE__*/Nt(Vs).withConfig({displayName:"RetryButton",componentId:"sc-6e9001c5-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),Vw=/*#__PURE__*/Nt.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-6e9001c5-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),Hw=/*#__PURE__*/Nt.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-6e9001c5-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),qw=/*#__PURE__*/Nt.text.withConfig({displayName:"HelperText",componentId:"sc-6e9001c5-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),Kw=/*#__PURE__*/Nt.span.withConfig({displayName:"TextBox",componentId:"sc-6e9001c5-10"})(["position:relative;width:100%;background-color:var(--privy-color-background-2);padding:8px 12px;border-radius:10px;margin-top:5px;font-size:14px;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;",""],(e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }")),Zw=/*#__PURE__*/Nt(zn).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-6e9001c5-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),Gw=/*#__PURE__*/Nt(un).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-6e9001c5-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),Yw=({clicked:e})=>/*#__PURE__*/t(e?Gw:Zw,{});const Jw=({instructions:r,fees:a,transactionInfo:i,solPrice:s,rpcEndpoint:l})=>{let c=r.reduce(((e,{amount:t,token:n})=>t&&"SOL"===n?.symbol?e+t:e),0n),[d,p]=o(0),[h,u]=o(!1),m=r[d];/*#__PURE__*/return e(Wy,{children:[/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Total"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(Im,{quantities:[c,a],tokenPrice:s})})]}),i&&i.action&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Action"}),/*#__PURE__*/t(Ry,{children:i.action})]}),/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Fees"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(Im,{quantities:[a||0n],tokenPrice:s})})]}),r.length>1?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Oy,{children:/*#__PURE__*/e(vw,{onClick:()=>u((e=>!e)),children:[/*#__PURE__*/t("span",{children:"Details"}),/*#__PURE__*/t(Cn,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:h?"rotate(180deg)":void 0}})]})}),h&&/*#__PURE__*/t(Oy,{children:/*#__PURE__*/e(Qw,{children:[/*#__PURE__*/e(ev,{children:[/*#__PURE__*/e(tv,{children:[d+1," of ",r.length," instructions"]}),/*#__PURE__*/e(rv,{children:[d>0&&/*#__PURE__*/t(jo,{backFn:()=>p((e=>e-1))}),d<r.length-1&&/*#__PURE__*/t(Vo,{nextFn:()=>p((e=>e+1))})]})]}),/*#__PURE__*/t(nv,{children:/*#__PURE__*/t(Xw,{instruction:m,rpcEndpoint:l,solPrice:s})})]})})]}):/*#__PURE__*/t(Xw,{instruction:m,rpcEndpoint:l,solPrice:s,hideAmount:!0})]})};function Xw({instruction:n,rpcEndpoint:r,solPrice:a,hideAmount:i}){return n?/*#__PURE__*/e(Wy,{children:[!i&&!!n.amount&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Amount"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(Im,{quantities:[n.amount],tokenPrice:a,tokenSymbol:n.token?.symbol??"SOL",tokenDecimals:n.token?.decimals??9})})]}),n.to&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"To"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(Jm,{walletAddress:n.to,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccount&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Token account"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(Jm,{walletAddress:n.tokenAccount,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccountOwner&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"Token account owner"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(Jm,{walletAddress:n.tokenAccountOwner,rpcEndpoint:r,network:"solana"})})]}),n.from&&/*#__PURE__*/e(Oy,{children:[/*#__PURE__*/t(Uy,{children:"From"}),/*#__PURE__*/t(Ry,{children:/*#__PURE__*/t(Jm,{walletAddress:n.from,rpcEndpoint:r,network:"solana"})})]})]}):null}let Qw=/*#__PURE__*/Nt.div.withConfig({displayName:"InstructionsBox",componentId:"sc-5a140027-0"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),ev=/*#__PURE__*/Nt.header.withConfig({displayName:"InstructionsBoxHeader",componentId:"sc-5a140027-1"})(["display:flex;justify-content:space-between;align-items:center;padding:12px;background-color:var(--privy-color-background-2);"]),tv=/*#__PURE__*/Nt.h4.withConfig({displayName:"HeaderTitle",componentId:"sc-5a140027-2"})(["font-size:14px;font-weight:500;line-height:19.6px;"]),nv=/*#__PURE__*/Nt.div.withConfig({displayName:"InstructionsBoxContent",componentId:"sc-5a140027-3"})(["padding:12px;"]),rv=/*#__PURE__*/Nt.div.withConfig({displayName:"NavigationButtonsConatiner",componentId:"sc-5a140027-4"})(["display:flex;gap:8px;align-items:center;"]);const av=({instructions:r,fees:a,onClose:i,receiptHeader:o,receiptDescription:s,transactionInfo:l,solPrice:c,rpcEndpoint:d,signOnly:p})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{onClose:i}),/*#__PURE__*/t(kl,{style:{marginBottom:"16px"},children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Cl,{color:"var(--privy-color-success-light)"}),/*#__PURE__*/t(Mn,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),/*#__PURE__*/t(ns,{title:o??`Transaction ${p?"signed":"complete"}!`,description:s??"You're all set."}),/*#__PURE__*/t(Jw,{solPrice:c,instructions:r,fees:a,transactionInfo:l,rpcEndpoint:d}),/*#__PURE__*/t(ls,{}),/*#__PURE__*/t(iv,{loading:!1,onClick:i,children:"Close"}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]});let iv=/*#__PURE__*/Nt(Vs).withConfig({displayName:"SubmitButton",componentId:"sc-6f95cdcf-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const ov={component:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=Tu(),{client:i,closePrivyModal:l,walletProxy:c,showFiatPrices:p}=Q(),h=Lo(),{user:u,getAccessToken:m}=gl(),[g,y]=o(e?.sendSolanaTransaction?.transactionRequest),[f,w]=o(),[v,b]=o(),[C,k]=o(0),[x,T]=o({value:0n,isLoading:!1}),[A,I]=o(!1),[_,E]=o(),[S,N]=o(),M=e?.sendSolanaTransaction?.connection,P=e?.sendSolanaTransaction?.transactingWallet,W=e?.sendSolanaTransaction?.signOnly??!1,O=f?.instructions.length??1,U=P?.imported?Ka(u):Ga(u),L=Io(M?.rpcEndpoint||""),{solPrice:R,isSolPriceLoading:F}=ng({enabled:p}),D=s((()=>{let e,t;if(!f)return;let n=f.spender;0===C&&P?.address===n&&(e=gm(f.fee));let r=gm(x.value,3,!0),a=f.instructions[C];if(!a)return{fee:e,spender:n,balance:r};if("unknown"===a.type)return{fee:e,spender:n,program:a.program,balance:r};if("ata-creation"===a.type)return{fee:e,spender:n,balance:r,tokenAccountOwner:a.owner,tokenAccount:a.ata,tokenAddress:a.mint};let i=a.fromAccount,o="sol-transfer"===a.type?a.toAccount:a.toAccount||a.toAta,s="spl-transfer"===a.type?a.token.address:void 0;return null!=e&&"SOL"===a.token.symbol&&(t=gm(a.value+f.fee)),{fee:e,spender:n,from:i,to:o,tokenAddress:s,amount:`${Ye(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}}),[f,C,P?.address,x]),z=s((()=>{let e,t;if(!f||!p||!R||F)return;function n(...e){return ym(e.reduce(((e,t)=>e+t),0n),R??0)}0===C&&P?.address===f.spender&&(e=n(f.fee));let r=n(x.value),a=f.instructions[C];return a&&"unknown"!==a.type&&"ata-creation"!==a.type?(null!=e&&"SOL"===a.token.symbol&&(t=n(a.value,f.fee)),{fee:e,amount:"SOL"===a.token.symbol?n(a.value):`${Ye(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}):{fee:e,balance:r}}),[f,p,R,F,P?.address,C,x]),B=s((()=>{if(W||!f||x.isLoading||C>0)return!1;let e=f.instructions[C];if(!e)return!1;let t=0n;return P?.address===f.spender&&(t+=f.fee),"value"in e&&P?.address===e.fromAccount&&"SOL"===e.token.symbol&&(t+=e.value),x.value<t}),[f,x,C,W]);if(d((()=>{!async function(){if(g&&M&&i)try{b(void 0);let e=await bm({tx:g,connection:M,client:i});w(e),k(0)}catch(e){console.error("Failed to prepare transaction",e),b(e)}}()}),[g,M,i]),d((()=>{(async function(){if(!P||!M)return;T({value:x.value,isLoading:!0});let e=new At({name:"mainnet-beta",rpcUrl:M.rpcEndpoint});T({value:await e.getBalance(P.address).catch((()=>0n))??0n,isLoading:!1})})().catch(console.error)}),[f,M]),!(g&&e?.sendSolanaTransaction&&P&&M)){let n=Error("Invalid transaction request");/*#__PURE__*/return t(Jl,{error:n,onClick:()=>{e?.sendSolanaTransaction?.onFailure(n),l({shouldCallAuthOnSuccess:!1})}})}let $=()=>{if(!A)return _?e?.sendSolanaTransaction?.onSuccess(_):(e?.sendSolanaTransaction?.onFailure(S??v??Error("User exited the modal before submitting the transaction")),k(0)),l({shouldCallAuthOnSuccess:!1})};n.current=$;let j=e.sendSolanaTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/t("img",{src:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,V=!!(e.funding&&e.funding.supportedOptions.length>0),H=B&&V;return _?/*#__PURE__*/t(av,{instructions:f?.instructions.reduce(((e,t)=>("ata-creation"===t.type&&e.push({tokenAccountOwner:t.owner,tokenAccount:t.ata}),"spl-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount||t.toAta,amount:t.value,token:t.token}),"sol-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount,amount:t.value,token:t.token}),e)),[])??[],fees:0===C?_.fees:0n,onClose:$,transactionInfo:e.sendSolanaTransaction?.uiOptions.transactionInfo,solPrice:R,receiptHeader:e.sendSolanaTransaction?.uiOptions.successHeader,receiptDescription:e.sendSolanaTransaction?.uiOptions.successDescription,rpcEndpoint:M.rpcEndpoint,signOnly:W}):S?/*#__PURE__*/t(Lw,{transactionError:S,connection:M,onClose:$,network:"solana",onRetry:async()=>{N(void 0);let{blockhash:e}=await M.getLatestBlockhash();wm(g)?g.message.recentBlockhash=e:g.recentBlockhash=e,y(g)}}):/*#__PURE__*/t(Mw,{img:j,title:e.sendSolanaTransaction?.uiOptions?.transactionInfo?.title||"Confirm transaction",subtitle:e.sendSolanaTransaction?.uiOptions?.description||`${h.name} wants your permission to approve the following transaction.`,cta:H?"Add funds":e.sendSolanaTransaction?.uiOptions?.buttonText||"Approve",transactionIndex:C,maxIndex:O-1,network:"mainnet-beta"==L?"Solana":L,blockExplorerUrl:"https://explorer.solana.com",total:p?z?.total:D?.total,amount:p?z?.amount:D?.amount,fee:p?z?.fee:D?.fee,balance:p?z?.balance:D?.balance,from:D?.from,to:D?.to,tokenAccount:D?.tokenAccount,tokenAccountOwner:D?.tokenAccountOwner,tokenAddress:D?.tokenAddress,transactingWalletAddress:P.address,programAddress:D?.program,disabled:B&&!V,isSubmitting:A,isPreparing:!f||x.isLoading,isTokenPriceLoading:p&&F,isMissingFunds:B,submitError:S??void 0,parseError:v,onClick:H?async()=>{if(P){if(!V)throw Error("Funding wallet is not enabled");r({...e,funding:{...e.funding,methodScreen:nw}}),a(nw)}}:async()=>{if(C<(f?.instructions.length??1)-1)k(C+1);else try{I(!0);let t=await m();if(A||!t||!P||!c||!u||!U)return;let n=Za(u,P.address);if(!n)throw Error("No root wallet for transacting wallet found");let{entropyId:r,entropyIdVerifier:a}=Qa(u,n);if(W)await my({tx:g,accessToken:t,walletProxy:c,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:P.address,transactingWalletIndex:P.walletIndex??0}),E(vm("",g,null));else{let{signature:n,receipt:i}=await gy({tx:g,accessToken:t,connection:M,walletProxy:c,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:P.address,transactingWalletIndex:P.walletIndex??0,transactionOptions:e.sendSolanaTransaction?.transactionOptions});E(vm(n,g,i))}}catch(e){console.warn({transaction:g,error:e}),N(e)}finally{I(!1)}},onClose:$,onBack:C>0&&O>1?()=>k(C-1):void 0})}},sv=({appConfig:e,getAccessToken:t,isHeadlessSigning:n,emitPrivyEvent:r,setModalData:a,openModal:i,walletProxy:o,user:s,recoverPrimaryWallet:l},{transaction:c,connection:d,transactionOptions:p,fundWalletConfig:h,uiOptions:u,address:m,signOnly:g})=>new Promise((async(y,f)=>{let{requesterAppId:w}=u||{},v=g?"signSolanaTransaction":"sendSolanaTransaction";if(!s)return r(v,"onError",U.MUST_BE_AUTHENTICATED),void f(new k("User must be authenticated before signing with a Privy wallet",U.MUST_BE_AUTHENTICATED));let b=m?Za(s,m):Ha(s);if(!b)return r(v,"onError",U.EMBEDDED_WALLET_NOT_FOUND),void f(new k("Must have a Privy wallet before signing",U.EMBEDDED_WALLET_NOT_FOUND));if(!await l().catch((()=>!1)))throw r(v,"onError",U.EMBEDDED_WALLET_NOT_FOUND),new k(`Cannot sendSolanaTransaction before embedded wallet ${b.address} is connected`,U.EMBEDDED_WALLET_NOT_FOUND);if(n({showWalletUIs:u?.showWalletUIs}))(async()=>{let e=await t();if(!e||!o)return r(v,"onError",U.EMBEDDED_WALLET_NOT_FOUND),void f(new k("Must have valid access token and Privy wallet to send transaction",U.EMBEDDED_WALLET_NOT_FOUND));try{let t;if(!await l())return r(v,"onError",U.UNKNOWN_CONNECT_WALLET_ERROR),void f(new k("Unable to connect to wallet",U.UNKNOWN_CONNECT_WALLET_ERROR));if(n({showWalletUIs:u?.showWalletUIs})&&!g)try{if(!await async function(e,t){let{value:n}=await t.simulateTransaction(e);if("BlockhashNotFound"===n.err)throw Error("Simulation failed: Blockhash not found");return null==n.err&&n.logs?.every((e=>!/insufficient funds/gi.test(e)))}(c,d))return r(v,"onError",U.INSUFFICIENT_BALANCE),void f(new k("Solana wallet has insufficient funds for this transaction.",U.INSUFFICIENT_BALANCE))}catch(e){return console.error(e),r(v,"onError",U.TRANSACTION_FAILURE),void f(new k(e instanceof Error?e.message:"Transaction failed.",U.TRANSACTION_FAILURE))}let{entropyId:a,entropyIdVerifier:i}=Qa(s);if(g)await my({accessToken:e,tx:c,walletProxy:o,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:b.address,transactingWalletIndex:b.walletIndex??0}),t=vm("",c,null),r("signSolanaTransaction","onSuccess",{signedTransaction:c});else{let{signature:n,receipt:s}=await gy({accessToken:e,tx:c,connection:d,walletProxy:o,transactionOptions:p,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:b.address,transactingWalletIndex:b.walletIndex??0});t=vm(n,c,s),r("sendSolanaTransaction","onSuccess",{response:t})}y(t)}catch(e){r(v,"onError",U.TRANSACTION_FAILURE),f(e)}})();else{let{entropyId:t,entropyIdVerifier:n}=Qa(s,b),o={recoveryMethod:b.recoveryMethod,connectingWalletAddress:b.address,entropyId:t,entropyIdVerifier:n,onCompleteNavigateTo:ov,onFailure:e=>{r(v,"onError",U.UNKNOWN_CONNECT_WALLET_ERROR),f(e)}},l=vy(e)?cw({address:b.address,appConfig:e,methodScreen:nw,fundWalletConfig:h,comingFromSendTransactionScreen:!0}):void 0;a({connectWallet:o,sendSolanaTransaction:{transactionRequest:c,connection:d,transactionOptions:p,transactingWallet:b,onSuccess:e=>{g?r("signSolanaTransaction","onSuccess",{signedTransaction:e.signedTransaction}):r("sendSolanaTransaction","onSuccess",{response:e}),y(e)},onFailure:e=>{r(v,"onError",U.TRANSACTION_FAILURE),f(e)},uiOptions:u||{},requesterAppId:w,signOnly:g},funding:l}),i(fw)}}));function lv(e){let t=Lo(),{getAccessToken:n,user:r}=fy(),{setModalData:a}=Tu(),{isHeadlessSigning:i,openModal:o,walletProxy:s,recoverPrimaryWallet:l}=Q(),c=Ms();return Ss("sendSolanaTransaction",e),{sendTransaction:async({transaction:e,connection:d,uiOptions:p,transactionOptions:h,fundWalletConfig:u,address:m})=>await sv({appConfig:t,getAccessToken:n,isHeadlessSigning:i,emitPrivyEvent:c,setModalData:a,openModal:o,walletProxy:s,user:r,recoverPrimaryWallet:l},{transaction:e,connection:d,transactionOptions:h,uiOptions:p,fundWalletConfig:u,address:m,signOnly:!1})}}const cv=/*#__PURE__*/Nt.img.withConfig({displayName:"StyledLogo",componentId:"sc-68c1b1ea-0"})(["&&{height:",";width:",";border-radius:16px;margin-bottom:12px;}"],(e=>"sm"===e.size?"65px":"140px"),(e=>"sm"===e.size?"65px":"140px"));let dv=({data:n})=>{let r=n=>"object"==typeof n&&null!==n?/*#__PURE__*/t(hv,{children:Object.entries(n).map((([t,n])=>/*#__PURE__*/e("li",{children:[/*#__PURE__*/e("strong",{children:[t,":"]})," ",r(n)]},t)))}):/*#__PURE__*/t("span",{children:String(n)});/*#__PURE__*/return t("div",{children:r(n)})};const pv=/*#__PURE__*/Nt.div.withConfig({displayName:"Message",componentId:"sc-ccf49562-0"})(["margin-top:1.5rem;background-color:var(--privy-color-background-2);border-radius:var(--privy-border-radius-md);padding:12px;text-align:left;max-height:310px;overflow:scroll;white-space:pre-wrap;width:100%;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}"]);let hv=/*#__PURE__*/Nt.ul.withConfig({displayName:"MessageList",componentId:"sc-ccf49562-1"})(["margin-left:12px !important;white-space:nowrap;&:first-child{margin-left:0 !important;}strong{font-weight:500 !important;}"]);const uv=({data:e})=>/*#__PURE__*/t(pv,{children:/*#__PURE__*/t(dv,{data:e})});let mv=e=>{if(!qe(e))return e;try{return rt(e)}catch{return e}},gv=e=>JSON.stringify(e,null,2),yv=r=>{let{types:a,primaryType:i,...o}=r.typedData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(uv,{data:o}),/*#__PURE__*/t(yp,{text:gv(r.typedData),itemName:"full payload to clipboard"})," "]})};const fv={component:()=>{let{authenticated:r}=gl(),{initializeWalletProxy:a,closePrivyModal:i}=Q(),{navigate:s,data:l,onUserCloseViaDialogOrKeybindRef:c}=Tu(),[p,h]=o(!0),[u,m]=o(""),[g,y]=o(),[f,w]=o(null),[v,b]=o(!1),C=null!==f;d((()=>{r||s(Hh)}),[r]),d((()=>{a(Qr).then((e=>{h(!1),e||(m("An error has occurred, please try again."),y(new ki(new Ci(u,pt.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:k,data:x,confirmAndSign:T,onSuccess:A,onFailure:I,uiOptions:_}=l.signMessage,E={title:_?.title||"Sign message",description:_?.description||"Signing this message will not cost you any fees.",buttonText:_?.buttonText||"Sign and continue"},S=e=>{e?A(e):I(g||new ki(new Ci("The user rejected the request.",pt.E4001_USER_REJECTED_REQUEST.eipCode))),i({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{w(null),m(""),y(void 0)}),200)};return c.current=()=>{S(f)},/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{onClose:()=>S(f)}),/*#__PURE__*/t(ll,{}),_?.iconUrl&&"string"==typeof _.iconUrl?/*#__PURE__*/t(bv,{children:/*#__PURE__*/t(cv,{size:"sm",src:_.iconUrl,alt:"app image"})}):null,/*#__PURE__*/t(Pd,{children:E.title}),/*#__PURE__*/t(Md,{children:E.description}),"personal_sign"===k&&/*#__PURE__*/t(pv,{children:mv(x)}),"eth_signTypedData_v4"===k&&/*#__PURE__*/t(yv,{typedData:x}),"solana_signMessage"===k&&/*#__PURE__*/t(pv,{children:x}),/*#__PURE__*/t(Cv,{}),/*#__PURE__*/t(wv,{$fail:!0,children:u}),/*#__PURE__*/t(Hs,{disabled:v||C||p,loading:v,onClick:async()=>{b(!0),m("");try{let e=await T();w(e),b(!1),setTimeout((()=>{S(e)}),Mr)}catch(e){console.error(e),m("An error has occurred, please try again."),y(new ki(new Ci(u,pt.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),b(!1)}},children:v?"Signing...":C?/*#__PURE__*/e(vv,{children:[/*#__PURE__*/t(mp,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",/*#__PURE__*/t("span",{children:"Success"})]}):E.buttonText}),_?.isCancellable&&/*#__PURE__*/t(Xs,{style:{marginTop:"1rem"},onClick:()=>S(null),isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]})}};let wv=/*#__PURE__*/Nt.div.withConfig({displayName:"InputHelp",componentId:"sc-1a9f17a4-0"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-start;width:100%;margin-top:16px;margin-bottom:4px;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),vv=/*#__PURE__*/Nt.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-1a9f17a4-1"})(["display:flex;align-items:center;gap:8px;"]),bv=/*#__PURE__*/Nt.div.withConfig({displayName:"IconContainer",componentId:"sc-1a9f17a4-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),Cv=/*#__PURE__*/Nt.div.withConfig({displayName:"Grow",componentId:"sc-1a9f17a4-3"})(["flex-grow:1;"]);function kv(e){let{isHeadlessSigning:t,walletProxy:n,initializeWalletProxy:r,recoverPrimaryWallet:a,openModal:i}=Q(),{user:o,getAccessToken:s}=fy(),l=Ms(),{setModalData:c}=Tu();return Ss("signSolanaMessage",e),{signMessage:({message:e,options:d})=>new Promise((async(p,h)=>{if(!o)return l("signSolanaMessage","onError",U.MUST_BE_AUTHENTICATED),void h(Error("User must be authenticated before signing with a Privy wallet"));let u=d?.address?Za(o,d.address):Ha(o);if(!u)return l("signSolanaMessage","onError",U.EMBEDDED_WALLET_NOT_FOUND),void h(Error("Must have a Privy wallet before signing"));let{entropyId:m,entropyIdVerifier:g}=Qa(o,u),y=Buffer.from(e).toString("base64");if(y.length<1)return l("signMessage","onError",U.INVALID_MESSAGE),void h(Error("Message must be a non-empty string"));let f=async()=>{if(!o)throw Error("User must be authenticated before signing with a Privy wallet");let e=await s();if(!e)throw Error("User must be authenticated to use their embedded wallet.");let t=n??await r(15e3);if(!t)throw Error("Failed to initialize embedded wallet proxy.");if(!await a())throw Error("Unable to connect to wallet");let{response:i}=await t.rpc({accessToken:e,entropyId:m,entropyIdVerifier:g,chainType:"solana",hdWalletIndex:u.walletIndex??0,request:{method:"signMessage",params:{message:y}}});return i.data.signature};if(t({showWalletUIs:d?.uiOptions?.showWalletUIs}))try{let e=await f(),t=new Uint8Array(Buffer.from(e,"base64"));l("signSolanaMessage","onSuccess",{signature:t}),p(t)}catch(e){h(e)}else c({signMessage:{method:"solana_signMessage",data:y,confirmAndSign:f,onSuccess:e=>{let t=new Uint8Array(Buffer.from(e,"base64"));l("signSolanaMessage","onSuccess",{signature:t}),p(t)},onFailure:e=>{h(e)},uiOptions:d?.uiOptions},connectWallet:{recoveryMethod:u.recoveryMethod,connectingWalletAddress:u.address,entropyId:m,entropyIdVerifier:g,onCompleteNavigateTo:fv,onFailure:e=>{l("signSolanaMessage","onError",U.UNKNOWN_CONNECT_WALLET_ERROR),h(e)}}}),i(fw)}))}}const xv=()=>{let{exportSolanaWallet:e,createEmbeddedSolanaWallet:t,solanaWallets:n,walletProxy:r,recoverPrimaryWallet:a}=Q(),{sendTransaction:i}=lv(),{signMessage:o}=kv(),{user:s,getAccessToken:l}=fy(),{ready:c}=ig(),d=r?[...Va(s),Ka(s)].filter((e=>!!e)).map((e=>({type:"solana",imported:e.imported,address:e.address,connectedAt:Date.now(),walletClientType:"privy",connectorType:"embedded",walletIndex:e.walletIndex??void 0,meta:{name:"Privy Wallet",icon:void 0,id:"io.privy.solana.wallet"},linked:!0,fund(){throw new k("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:()=>{throw new k("Cannot unlink an embedded Solana wallet")},async getProvider(){return new uy(r,e.address,this.signMessage)},signMessage:async t=>await o({message:t,options:{address:e.address,uiOptions:{showWalletUIs:!1}}}),async sendTransaction(t,n,r){let{signature:a}=await i({transaction:t,connection:n,transactionOptions:r,address:e.address});return a},async signTransaction(t){let n=await l();if(!n||!r)throw new k("Must have valid access token and Privy wallet to send transaction",U.MUST_BE_AUTHENTICATED);if(!await a().catch((()=>!1)))throw new k("Wallet couldn't be connected",U.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:i,entropyIdVerifier:o}=Qa(s,e);return await my({tx:t,accessToken:n,walletProxy:r,entropyId:i,entropyIdVerifier:o,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0}),t},async signAllTransactions(t){let n=await l();if(!n||!r)throw new k("Must have valid access token and Privy wallet to send transaction",U.MUST_BE_AUTHENTICATED);if(!await a().catch((()=>!1)))throw new k("Wallet couldn't be connected",U.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:i,entropyIdVerifier:o}=Qa(s,e);for(let a of t)await my({tx:a,accessToken:n,walletProxy:r,entropyId:i,entropyIdVerifier:o,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0});return t},loginOrLink:async()=>{throw new k("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{},isConnected:async()=>!0}))):[];return{ready:!(!c||!r),createWallet:t,exportWallet:e,wallets:n.concat(d)}},Tv={component:()=>{let{wallets:r}=ig(),{wallets:a}=xv(),{data:i,setModalData:l,navigate:c,lastScreen:p}=Tu(),{rpcConfig:h,appId:u,createAnalyticsEvent:m,closePrivyModal:g}=Q(),y=Lo(),[f,w]=o(void 0),[v,b]=o(!1),C=dy(),k=i?.funding,{reloadBalance:x}=ry({rpcConfig:h,appId:u,address:"ethereum"===k.chainType?k.address:void 0,chain:"ethereum"===k.chainType?k.chain:void 0}),T="solana"===k.chainType,A=T?"SOL":k.erc20Address?k.erc20ContractInfo?.symbol:k.chain.nativeCurrency.symbol,I=T?a.find((({address:e})=>e===k.address)):r.find((({address:e})=>dr(e)===dr(k.address)));if(!k)return l({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:p||nw},funding:i?.funding,sendTransaction:i?.sendTransaction}),c(Yl),/*#__PURE__*/t(n,{});d((()=>{let e=T?async function(){if("solana"!==k.chainType)return;let e=C(py);e?e.getBalance({address:k.address,cluster:k.cluster}).then((e=>{let t=BigInt(e);f&&t>f&&(b(!0),m({eventName:ay,payload:{provider:"manual",status:"success",chainType:"solana",address:I?.address,value:Ye(t-f,9),token:"SOL"}})),w(t)})):console.warn("Unable to load solana plugin, skipping balance")}:async function(){"ethereum"===k.chainType&&(async()=>{if(!k.erc20Address)return await x()??BigInt(0);{let{balance:e}=await iy({chain:k.chain,address:k.address,erc20Address:k.erc20Address,rpcConfig:h,appId:u});return e}})().then((e=>{f&&e>f&&(b(!0),m({eventName:ay,payload:{provider:"manual",status:"success",chainType:"ethereum",address:I?.address,chainId:k.chain.id,value:Ye(e-f,k.erc20ContractInfo?.decimals??18),token:k.erc20ContractInfo?.symbol??k.erc20Address??"ETH"}})),w(e)})).catch((()=>w(void 0)))},t=setInterval(e,2e3);return e(),()=>clearInterval(t)}),[f]);let _=s((()=>void 0!==f&&f>=parseFloat(k.amount)),[f,k.amount]),E=s((()=>null==f?"":k.isUSDC?It({amount:f,decimals:6}):T?gm(f,3,!0,!0):null!=k.erc20ContractInfo?.decimals?It({amount:f,decimals:k.erc20ContractInfo.decimals}):_t({wei:f})),[f,T,k]),S="ethereum"===k.chainType?k.chain.name:Iv[k.cluster.name],N=s((()=>""===k.uiConfig?.receiveFundsTitle?null:/*#__PURE__*/t(Pd,{children:k.uiConfig?.receiveFundsTitle??`Receive ${k.amount} ${A??""}`.trim()})),[k.uiConfig?.receiveFundsTitle,k.amount,A]),M=s((()=>""===k.uiConfig?.receiveFundsSubtitle?null:/*#__PURE__*/t(Md,{children:k.uiConfig?.receiveFundsSubtitle??`Scan this code or copy your wallet address to receive funds on ${S}.`})),[k.uiConfig?.receiveFundsSubtitle,S]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Zv,{}),N,M,/*#__PURE__*/e(il,{style:{gap:"1rem",margin:N||M?"1rem 0":"0"},children:[/*#__PURE__*/t(Ep,{url:`${k.chainType}:${k.address}`,size:200,squareLogoElement:Av}),/*#__PURE__*/e(Yg,{theme:y.appearance.palette.colorScheme,children:["Make sure to send funds on ",S,"."]}),/*#__PURE__*/t(ny,{title:"Your wallet",errMsg:void 0,showIcon:!0,isLoading:!k||void 0===f,isPulsing:!_,balance:`${E} ${A}`,address:k.address,statusColor:_?"green":"gray"}),v&&/*#__PURE__*/t(Vs,{onClick:()=>g({shouldCallAuthOnSuccess:!1,isSuccess:!0}),children:"Continue"})]}),/*#__PURE__*/t(Bo,{})]})}};let Av=({...e})=>/*#__PURE__*/t(Ui,{color:"black",...e}),Iv={devnet:"Devnet","mainnet-beta":"Solana",testnet:"Testnet"},_v=/*#__PURE__*/Nt.div.withConfig({displayName:"Container",componentId:"sc-b3a607dd-0"})(["display:flex;flex-direction:column;min-height:72px;"]);var Ev=({onBack:n,details:r})=>/*#__PURE__*/e(_v,{children:[/*#__PURE__*/t(Ko,{backFn:n}),/*#__PURE__*/t(uv,{data:r}),/*#__PURE__*/t(Bo,{})]});let Sv=({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return Ke(e*t)}catch(e){return}};const Nv=({txn:r,receipt:a,transactionInfo:i,onClose:o,tokenPrice:s,tokenSymbol:l,receiptHeader:c,receiptDescription:d})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{onClose:o}),/*#__PURE__*/t(es,{title:c??"Transaction complete!",description:d??"You're all set."}),/*#__PURE__*/t(Qm,{tokenPrice:s,from:a.from,to:a.to,gas:Sv(a),txn:r,transactionInfo:i,tokenSymbol:l}),/*#__PURE__*/t(ls,{}),/*#__PURE__*/t(Mv,{loading:!1,onClick:o,children:"All Done"}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]});let Mv=/*#__PURE__*/Nt(Vs).withConfig({displayName:"SubmitButton",componentId:"sc-f857236b-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const Pv=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Wv=[{name:"from",type:"address"},{name:"param2",type:"address"},{name:"param3",type:"bytes"},{name:"param4",type:"tuple",components:[]},{type:"tuple",components:[{name:"param5",type:"address"},{name:"param6",type:"uint256"},{name:"param7",type:"uint256"},{name:"encodedInitData",type:"bytes"}]}],Ov=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Uv=[{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"mint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"quantity",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"},{internalType:"uint256[]",name:"quantities",type:"uint256[]"},{internalType:"bytes",name:"data",type:"bytes"}],name:"mintBatch",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"quantity",type:"uint256"}],name:"mint",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"uri",type:"string"}],name:"safeMint",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"batchMint",outputs:[],stateMutability:"payable",type:"function"}],Lv=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Rv=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Fv=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Dv=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenIds",type:"uint256[]"},{name:"_amounts",type:"uint256[]"},{name:"_data",type:"bytes"}],name:"safeBatchTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],zv=[{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_tokenId",type:"uint256"},{name:"_amount",type:"uint256"},{name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Bv=(e,t)=>{let n=$v(Ov,e);if(n)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:n.args[0],amount:n.args[1]};let r=$v(Vy,e);if(r)return{action:"transfer",functionName:"transfer",isErc20Ish:!0,isNFTIsh:!1,transferTo:r.args[0],amount:r.args[1]};if(!t)return{action:"transaction",functionName:"",isErc20Ish:!1,isNFTIsh:!1};let a=$v(Pv,e);if(a&&"string"==typeof a.args[1]){let e=jv(a.args[1]);if(e&&e[4].encodedInitData)return Bv(e[4].encodedInitData,t)}let i=$v(Rv,e);if(i)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:i.args[0],approved:i.args[1]};let o=$v(Fv,e);if(o)return{action:"transfer",functionName:"transferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:o.args[0],transferTo:o.args[1],tokenId:o.args[2]};let s=$v(Lv,e);if(s)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:s.args[0],transferTo:s.args[1],tokenId:s.args[2]};let l=$v(zv,e);if(l)return{action:"transfer",functionName:"safeTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:l.args[0],transferTo:l.args[1],tokenId:l.args[2],amount:l.args[3]};let c=$v(Dv,e);if(c)return{action:"batch transfer",functionName:"safeBatchTransferFrom",isNFTIsh:!0,isErc20Ish:!1,transferFrom:c.args[0],transferTo:c.args[1],tokenIds:c.args[2],amounts:c.args[3]};let d=$v(Uv,e);return d?{action:"mint",functionName:d.functionName,isNFTIsh:!0,isErc20Ish:!1,args:d.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}};let $v=(e,t)=>{try{let n=at({abi:e,data:t});return{functionName:n.functionName,args:n.args||[]}}catch(e){return null}},jv=e=>{try{if("string"==typeof e)return it(Wv,`0x${e.slice(10)}`)}catch(e){return null}};const Vv=(e,t,n)=>{let[r,a]=o(null),{getAccessToken:i}=gl(),{walletProxy:s}=Q();return d((()=>{r&&a(null),(async()=>{if(!await i()||!s||!t)return null;let r=[],a=!0,o=await og(e,n,t).catch((t=>(t.details.includes("insufficient funds")?a=!1:r.push(t),e)));return{tx:o,totalGasEstimate:o.gas,hasFunds:a,errors:r}})().then(a)}),[e]),r};let Hv=new ki(new Ci("There was an issue preparing your transaction",pt.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),qv=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0;const Kv={component:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=Tu(),{rpcConfig:i,chains:l,closePrivyModal:c,walletProxy:p,client:h,showFiatPrices:u}=Q(),{getAccessToken:m,user:g}=gl(),y=Lo(),[f,w]=o(0),v=(e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(e),[b,C]=o(qv(e,f)),[k,x]=o(null),[T,A]=o(),[I,_]=o(!1),[E,S]=o(null),[N,M]=o(null),[P,W]=o(null),[O,U]=o(void 0),[L,R]=o(void 0),[F,D]=o(!1),[z,B]=o(!1),[$,j]=o([]),[V,H]=o([]),[q,K]=o(!1),[Z,G]=o(void 0);if(!b||!e?.sendTransaction||!e?.sendTransaction)/*#__PURE__*/return t(Jl,{error:Error("Invalid transaction request"),onClick:()=>{e?.sendTransaction?.onFailure(Hv),c({shouldCallAuthOnSuccess:!1})}});let{entropyId:Y,entropyIdVerifier:J,transactingWalletIndex:X,transactingWalletAddress:ee}=e.sendTransaction,te=s((()=>l.find((e=>Number(e.id)===Number(b.chainId)))),[b.chainId]),ne=te?.nativeCurrency.symbol??"ETH",re=s((()=>Bv(b.data,!!y.embeddedWallets.extendedCalldataDecoding)),[b.data]),{action:ae,isErc20Ish:ie,isNFTIsh:oe}=re,{toAddress:se,tokenAddress:le}=s((()=>({toAddress:re.isErc20Ish?re.transferTo:b.to??void 0,tokenAddress:re.isErc20Ish?b.to:void 0})),[re]);d((()=>{b.to&&te&&ie&&Iy({address:b.to,chain:te,rpcConfig:y.rpcConfig,privyAppId:y.id}).then(x).catch(console.error)}),[b.to,te]);let{tokenPrice:ce,isTokenPriceLoading:de}=rg(b.chainId),{balance:pe}=ry({rpcConfig:y.rpcConfig,appId:y.id,address:ee,chain:te}),he=s((()=>sr(Number(b.chainId),l,i,{appId:y.id})),[b.chainId,i]),ue=Vv(b,ee,he);d((()=>{C(qv(e,f))}),[f]),d((()=>{e.sendTransaction?.getIsSponsored?e.sendTransaction.getIsSponsored().then(A).catch(console.error):A(!1)}),[e.sendTransaction.getIsSponsored]);let me=()=>{if(!I)return E?e?.sendTransaction?.onSuccess({hash:E}):P||ue?.errors[0]?e?.sendTransaction?.onFailure(P??ue?.errors[0]??Hv):e?.sendTransaction?.onFailure(new ki(new Ci("The user rejected the request",pt.E4001_USER_REJECTED_REQUEST.eipCode))),c({shouldCallAuthOnSuccess:!1})};n.current=me;let ge=!!(e.funding&&e.funding.supportedOptions.length>0),ye=cm(BigInt(ue?.totalGasEstimate??0n),ne),fe=u&&ce?lm(BigInt(ue?.totalGasEstimate??0n),ce):void 0,we=cm(pe??0n,ne,void 0,!0),ve=u&&ce?lm(pe??0n,ce):void 0,be=e.sendTransaction?.uiOptions?.transactionInfo?.title;be||(be="approve"===ae?ie?"Confirm address":"Confirm action":`Approve ${ae}`);let Ce=e.sendTransaction?.uiOptions?.description||(ie&&"approve"===ae?`${y.name} would like your permission for ${dr(re.spender)} to spend tokens on your behalf.`:`${y.name} wants your permission to approve the following transaction.`),ke=e.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/t("img",{src:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,xe=!(!ue||ue.errors[0]||ue.hasFunds||!1!==T),Te=xe&&ge,Ae=Te?"Add funds":e.sendTransaction?.uiOptions?.buttonText||(f<v?"Continue":"Approve");if(d((()=>{let e=(e,t,n)=>{if(t.isErc20Ish&&t.amount&&n)G(qy({amount:t.amount,decimals:n.decimals})),j([{value:Z,symbol:n?.symbol}]);else if(e.value){let t=BigInt(e.value),n=ce&&lm(t,ce);j(u&&n?[{value:n}]:[{value:dm(t),symbol:ne}])}else j(u?[{value:"$0"}]:[{value:"0",symbol:ne}])},t=ue?.tx??b;y.embeddedWallets.transactionScanning.enabled&&t?(K(!0),(async e=>{if(h)return await h.scanTransaction({metadata:{domain:y.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})})(t).then((e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?R("safe"):"Warning"===e.validation.result_type?R("warn"):"Malicious"===e.validation.result_type&&(R("error"),B(!0))),"Success"!==e.simulation.status)throw Error("Simulation failed");{U(e.simulation.params);let{assetsIn:t,assetsOut:n}=function(e,t){let n=[],r=[];if(e)for(let t of e)if(t.in[0]){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.in[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price},n.push(e)}else if(t.out[0]?.value){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.out[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.out[0].value,symbol:t.asset.symbol,usdValue:t.out[0].usd_price},r.push(e)}for(let e of t)for(let t of Object.keys(e.spenders)){let n;n="ERC721"===e.asset.type||"approve_for_all"===e.spenders[t]?.value?{nftName:e.asset.name}:{iconUrl:e.asset.logo_url,value:e.spenders[t]?.value,symbol:e.asset.symbol,usdValue:e.spenders[t]?.usd_price},r.push(n)}return{assetsIn:n,assetsOut:r}}(e.simulation.assets_diffs,e.simulation.exposures);if(0===n.length&&0===t.length)throw Error("No tokens found");j(n),H(t)}K(!1)})).catch((()=>{K(!1),e(t,re,k)}))):e(t,re,k)}),[b,ue?.tx,re,k]),N/*#__PURE__*/)return t(Nv,{txn:ue?.tx??b,onClose:me,receipt:N,transactionInfo:e.sendTransaction?.uiOptions.transactionInfo,tokenPrice:ce,tokenSymbol:ne,receiptHeader:e.sendTransaction?.uiOptions.successHeader,receiptDescription:e.sendTransaction?.uiOptions.successDescription});if(P)/*#__PURE__*/return t(Lw,{transactionError:P,transactionHash:E??void 0,network:"ethereum",chainId:ue?.tx.chainId??b.chainId,onClose:me,onRetry:({resetNonce:e})=>{W(null);let t={...ue?.tx??b};e&&(t.nonce=void 0),C(t)}});let Ie=0!==v&&"number"==typeof f&&0!==f?()=>{w(f-1)}:void 0;return F&&O?/*#__PURE__*/t(Ev,{details:O,onBack:()=>D(!1)}):/*#__PURE__*/t(Nw,{transactionIndex:f,onBack:Ie,maxIndex:v,disabled:xe&&!ge||z,isSubmitting:I,submitError:P,isPreparing:!ue,isTokenPriceLoading:de,isTokenContractInfoLoading:!oe&&!k,prepareError:ue?.errors[0],symbol:k?.symbol,chain:te,img:ke,title:be,subtitle:Ce,txValue:b.value,fee:fe??ye,isSponsored:T,from:ee??"",to:se,tokenAddress:le??void 0,network:y.chains.find((e=>e.id===b.chainId))?.name??"",transactionDetails:{...re,formattedAmount:Z},cta:Ae,missingFunds:xe,action:ae,balance:ve??we,onClose:me,onClick:Te?async()=>{if(ee){if(!ge)throw Error("Funding wallet is not enabled");r({...e,funding:{...e.funding,methodScreen:nw,chainType:"ethereum",amount:Ge(BigInt(ue?.tx.value??0)+BigInt(ue?.totalGasEstimate?.toString()??0)),chain:te}}),a(nw)}}:async()=>{if(f<v)w(f+1);else{_(!0);try{let t=await m();if(I||!t||!p||!g)return;let n=e?.sendTransaction?.onConfirm?await e.sendTransaction.onConfirm():await Rg({accessToken:t,transactingWalletIndex:X,entropyId:Y,entropyIdVerifier:J,walletProxy:p,transactionRequest:ue?.tx??b,publicClient:he,requesterAppId:e.sendTransaction?.requesterAppId});if(S(n),e.sendTransaction?.signOnly)return await new Promise((e=>setTimeout(e,Mr))),e?.sendTransaction?.onSuccess({hash:n}),c({shouldCallAuthOnSuccess:!1});let r=await he.waitForTransactionReceipt({hash:n});if("reverted"===r.status)throw Error("Transaction failed");M(r)}catch(e){console.warn({transaction:ue?.tx??b,error:e}),W(e)}finally{_(!1)}}},validation:L,hasScanDetails:!!O,setIsScanDetailsOpen:D,preventMaliciousTransaction:z,setPreventMaliciousTransaction:B,tokensSent:$,tokensReceived:V,isScanning:q,isCancellable:e.sendTransaction?.uiOptions?.isCancellable??!1})}};function Zv({title:e}){let{currentScreen:n,navigateBack:r,navigate:a,data:i,setModalData:o}=Tu();/*#__PURE__*/return t(Ko,{title:e,backFn:n===Tv?r:n===i?.funding?.methodScreen?i.funding.comingFromSendTransactionScreen?()=>a(Kv):void 0:i?.funding?.methodScreen?()=>{let e=i.funding;e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),o({funding:e}),a(e.methodScreen)}:void 0})}const Gv={component:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:s}=Q(),{navigate:l,setModalData:c,app:p,data:h}=Tu(),{wallets:u}=ig(),m=dy(),[g,y]=o(null),[f,w]=o(null),[v,b]=o([]),[C,x]=o(0),[T,A]=o(!1),[I,_]=o(!1),[E,S]=o(!1),[N,M]=o(!1),[P,W]=o(),[O,L]=o();if(!h?.funding||"solana"!==h.funding.chainType)throw Error("Invalid funding data");let{address:R,cluster:F,connectedWalletAddress:D}=h.funding,[z,B]=o(h.funding.amount),$=D?u.find((({address:e})=>e===D)):u[0],j=mo($?.walletClientType||"unknown"),V=j?.name||"wallet",[H,q]=o(null);d((()=>{(async()=>{if(!$)return;let e=await $.getEthereumProvider();q(Xe({account:$.address,transport:Qe(e)}).extend(et))})().catch(console.error)}),[$]);let[K,Z]=o(0n),G=gm(K);d((()=>{let e=m(py);e?e.getBalance({address:R,cluster:F}).then((e=>Z(BigInt(e)))):console.warn("Unable to load solana plugin, skipping balance")}),[]);let[Y,J]=o(),{tokenPrice:X}=rg("solana"),{fundingAmountInBaseUnit:ee,fundingAmountInUsd:te}=fm({amount:z,fee:0n,tokenPrice:X});if(d((()=>{(async()=>{if(!H||!$)return;let e=["testnet","devnet"].includes(F.name);e&&console.warn("Solana testnets are not supported for bridging");let t=ko(p.chains).filter((({testnet:t})=>!!t===e)),n=(await Ky({chains:t,address:$.address,appId:a,rpcConfig:r})).filter((e=>e.balance>0n));if(n.length<1)return void y(new k(`Wallet ${dr($.address)} does not have enough funds.`,void 0,U.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({...e,quote:await Hl({isTestnet:!1,input:$l({amount:ee.toString(),user:$.address,recipient:R,destinationChainId:To,destinationCurrency:Ao,originChainId:e.chain.id})})}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void y(new k(`Unable to fetch quotes for bridging. Wallet ${dr($.address)} does not have enough funds.`,void 0,U.INSUFFICIENT_BALANCE));let o=i.map((({quote:e,balance:t,chain:n})=>({bridgeTx:ql(e),balance:t,chain:n}))).filter((({bridgeTx:e})=>!!e));if(o.length>1)return void b(o);let s=o.at(0);s?(_(!0),J({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):y(new k(`Unable to select bridge option from quotes. Wallet ${dr($.address)} does not have enough funds.`,void 0,U.INSUFFICIENT_BALANCE))})().catch(console.error)}),[H]),d((()=>{(async()=>{let e,t;if(!H||!$||T||E||!Y)return;A(!0);let n=Ve({chain:Y.chain,transport:He(lr(Y.chain,r,a))});try{e=await n.prepareTransactionRequest({account:$.address,to:Y.to,chain:Y.chain,data:Y.data,value:BigInt(Y.value??0)})}catch(e){console.error(e),v.length>1&&w(e.shortMessage??"Something went wrong")}if(e){A(!1),S(!0);try{await H.switchChain({id:Y.chain.id})}catch(e){await H.addChain({chain:Y.chain}),await H.switchChain({id:Y.chain.id})}try{t=await H.sendTransaction(e)}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(v.length<1?y(new k(e.shortMessage,void 0,U.TRANSACTION_FAILURE)):w(e.shortMessage??"Something went wrong"))}if(t)return await H.waitForTransactionReceipt({hash:t}),I?(L("pending"),void W(t)):(S(!1),M(!0),void s({eventName:ay,payload:{provider:"external",status:"success",txHash:t,address:$.address,chainId:Y.chain.id,chainType:"ethereum",value:Y.value?Ye(BigInt(Y.value),18):void 0,token:"ETH",destination:R,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ye(ee,9),destinationToken:"SOL"}}));S(!1)}else A(!1)})().catch(console.error)}),[H,Y]),Kl({transactionHash:P,wallet:$,isTestnet:!1,bridgingStatus:O,setBridgingStatus:L,onSuccess({transactionHash:e,wallet:t}){_(!1),M(!0),s({eventName:ay,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:Y?.chain.id,chainType:"ethereum",value:Y?.value?Ye(BigInt(Y.value),18):void 0,token:"ETH",destination:R,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ye(ee,9),destinationToken:"SOL"}})},onFailure({error:e}){_(!1),y(e)}}),d((()=>{g&&(c({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:{error:g,previousScreen:Rf}}),l(Yl,!1))}),[g]),d((()=>{if(!N)return;let e=setTimeout(i,Wr);return()=>clearTimeout(e)}),[N]),N/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(Zv,{}),/*#__PURE__*/t(ll,{}),/*#__PURE__*/e(al,{children:[/*#__PURE__*/t(Mn,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(ns,{title:"Success!",description:`You’ve successfully added ${z} SOL to your ${p.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]});let ne=v[C];return v.length>1&&ne?/*#__PURE__*/t(Wf,{displayName:V,configuredFundingChain:F,formattedBalance:G,fundingAmount:z,fundingCurrency:"SOL",fundingAmountInUsd:te,options:v,selectedOption:ne,isPreparing:T,isSubmitting:E,addressToFund:R,fundingWalletAddress:$?.address||"",errorMessage:f,onSubmit:()=>{h.funding?.amount!==z?async function(){if($&&ne)try{let e=await Hl({isTestnet:!1,input:$l({amount:ee.toString(),user:$.address,recipient:R,destinationChainId:To,destinationCurrency:Ao,originChainId:ne.chain.id})}),t=ql(e);if(!t)throw Error("Invalid transaction request");_(!0),J({data:t.data,to:t.to,value:t.value,chain:ne.chain})}catch(e){console.error(e),y(new k("Unable to fetch quotes for bridging",e,U.INSUFFICIENT_BALANCE))}}().catch(console.error):J({to:ne.bridgeTx.to,data:ne.bridgeTx.data,value:ne.bridgeTx.value,chain:ne.chain})},onSelect:e=>{e!==C&&(w(null),x(e))},onAmountChange:B}):E&&$?/*#__PURE__*/t(By,{wallet:$,displayName:V,addressToFund:R,isBridging:I,isErc20Flow:!1,chainId:"solana",chainName:F.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
|
|
24
24
|
/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Zv,{}),/*#__PURE__*/t(Ey,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(Bo,{})]})}},Yv=new Map([[nw,null],[Rf,"external"],[Of,"external"],[jy,"external"],[Gv,"external"],[Uf,"external"],[Tv,"manual"],[Kf,"moonpay"]]);async function Jv({url:e,popup:t,provider:n}){return t.location=e,new Promise(((e,n)=>{function r(){t?.close(),window.removeEventListener("message",a)}function a(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(e(t.data),r()),"https://cdn.apple-cloudkit.com"===t.origin&&t.data.ckSession&&(e({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:t.data.ckSession}),r()),"PRIVY_OAUTH_ERROR"===t.data.type&&(n(t.data.error),r()))}window.addEventListener("message",a)}))}const Xv={component:()=>{let{app:r,data:a}=Tu(),i=Lo(),o=a?.externalConnectWallet?.suggestedAddress,s=o?`Connect the wallet with address ${dr(o)} ${r?.name?`to ${r.name}.`:"."}`:`Connect a wallet to ${r?.name}`,{connectors:l}=Q(),c=vu({walletList:a?.externalConnectWallet?.walletList??r.appearance.walletList,walletChainType:a?.externalConnectWallet?.walletChainType??r.appearance.walletChainType,connectors:l,connectOnly:!0,ignore:r.appearance.walletList,walletConnectEnabled:r.externalWallets.walletConnect.enabled});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{},"header"),c.length>0&&/*#__PURE__*/t(ts,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(ps,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(wu,{wallets:c})}),/*#__PURE__*/t(Bo,{})]})}};function Qv(e){let{logout:t}=l(ml);return Ss("logout",e),{logout:t}}const eb={component:()=>{let r=Lo(),{data:a,navigate:i,setModalData:l,onUserCloseViaDialogOrKeybindRef:c}=Tu(),{crossAppAuthFlow:p,updateWallets:h,closePrivyModal:u,createAnalyticsEvent:m}=Q(),{logout:g}=Qv(),[y,f]=o({}),w=a?.crossAppAuth,v={id:w.appId,name:w.name,logoUrl:w.logoUrl},b=new k(`There was an issue connecting your ${v.name} account. Please try again.`),C=new Er((async e=>{if(w.popup)try{let t=await p({appId:e,popup:w.popup,action:w.action});f({data:t})}catch(e){e instanceof k?f({error:e}):(e instanceof ee&&w.popup&&w.popup.close(),f({error:b}))}else f({error:b})})),x=()=>{y.data&&(h(),w.onSuccess(y.data),u({shouldCallAuthOnSuccess:!0,isSuccess:!0})),w.onError(y.error??new k("User canceled flow")),u({shouldCallAuthOnSuccess:!1,isSuccess:!1})};c.current=x,d((()=>{v.id.length&&C.execute(v.id)}),[v.id]),d((()=>{if(!y.data)return;let e=y.data;if(r.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{i(ip)}),Mr);return()=>clearTimeout(e)}if(bl(e,r.embeddedWallets)){let e=setTimeout((()=>{l({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),m({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${v.id}`,screen:"CrossAppAuthScreen"}}),g()},callAuthOnSuccessOnClose:!0}}),i(Dd)}),Mr);return()=>clearTimeout(e)}let t=setTimeout(x,Mr);return()=>clearTimeout(t)}),[y.data]);let{title:T,subtitle:A}=s((()=>y.data?{title:`Successfully connected with ${v.name}`,subtitle:"You're good to go!"}:y.error?{title:"Authentication failed",subtitle:y.error.message}:{title:`Connecting to ${v.name}`,subtitle:`Please check the pop-up from ${v.name} to continue`}),[y,v.name]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{onClose:x}),/*#__PURE__*/t(ll,{}),/*#__PURE__*/e(tb,{children:[/*#__PURE__*/t(kl,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Fs,{success:!!y.data,fail:!!y.error}),/*#__PURE__*/t(El,{name:v.name,logoUrl:v.logoUrl})]})}),/*#__PURE__*/e(ol,{children:[/*#__PURE__*/t("h3",{children:T}),/*#__PURE__*/t("p",{children:A})]})]}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t($o,{})]})}};let tb=/*#__PURE__*/Nt.div.withConfig({displayName:"ConnectContainer",componentId:"sc-33c02367-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const nb={component:()=>{let{app:r,data:a}=Tu(),{closePrivyModal:i}=Q(),[s,l]=o(!1),[c,p]=o(),{address:h,onDelegate:u,onSuccess:m,onError:g}=a.delegatedActions.consent,y=async()=>{s?m():g(c??new k("User declined delegating actions.")),i({shouldCallAuthOnSuccess:!1})};return d((()=>{if(!s&&!c)return;let e=setTimeout(y,Pr);return()=>clearTimeout(e)}),[s,c]),/*#__PURE__*/e(n,s||c?{children:[/*#__PURE__*/t(Ko,{onClose:y}),/*#__PURE__*/t(ll,{}),/*#__PURE__*/e(nl,{children:[c?/*#__PURE__*/t(Jt,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(Mn,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(pl,{height:20}),/*#__PURE__*/t(ns,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":`You’ve successfully granted delegated action permissions to ${r.name}.`})]}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]}:{children:[/*#__PURE__*/t(Ko,{closeable:!0,onClose:y}),/*#__PURE__*/t(Bn,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t($d,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),/*#__PURE__*/e(jd,{style:{marginBottom:24,textWrap:"pretty"},children:["By confirming, ",r.name," will be able to use your wallet for you even when you're not around. You can revoke this later."]}),/*#__PURE__*/t(ab,{showIcon:!0,address:h,title:"Wallet",isLoading:!1}),/*#__PURE__*/e(rb,{style:{marginTop:24},children:[/*#__PURE__*/t(Gs,{onClick:y,children:"Not now"}),/*#__PURE__*/t(Vs,{onClick:async()=>{try{await u(),l(!0)}catch(e){p(e)}},children:"Accept"})]}),/*#__PURE__*/t(Bo,{})]})}};let rb=/*#__PURE__*/Nt.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-bdb7bc51-0"})(["display:flex;gap:10px;"]),ab=/*#__PURE__*/Nt(ny).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-bdb7bc51-1"})(["margin-top:1.5rem;"]);const ib={component:()=>{let{app:r,data:a}=Tu(),{closePrivyModal:i}=Q(),[s,l]=o(!1),[c,p]=o(),{onRevoke:h,onSuccess:u,onError:m}=a.delegatedActions.revoke,g=async()=>{s?u():m(c??new k("User declined revoking access to their delegated wallet.")),i({shouldCallAuthOnSuccess:!1})};return d((()=>{if(!s&&!c)return;let e=setTimeout(g,Pr);return()=>clearTimeout(e)}),[s,c]),/*#__PURE__*/e(n,s||c?{children:[/*#__PURE__*/t(Ko,{onClose:g}),/*#__PURE__*/t(ll,{}),/*#__PURE__*/e(nl,{children:[c?/*#__PURE__*/t(Jt,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(Mn,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(pl,{height:20}),/*#__PURE__*/t(ns,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":"You've successfully revoked permissions."})]}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]}:{children:[/*#__PURE__*/t(Ko,{closeable:!0,onClose:g}),/*#__PURE__*/t($n,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t($d,{style:{marginTop:24},children:"Revoke offline access to wallet"}),/*#__PURE__*/e(jd,{children:["By confirming, ",r.name," will no longer be able to use this wallet on your behalf when you are not online."]}),/*#__PURE__*/e(ob,{style:{marginTop:24},children:[/*#__PURE__*/t(Gs,{onClick:g,children:"Deny"}),/*#__PURE__*/t(Vs,{onClick:async()=>{try{await h(),l(!0)}catch(e){p(e)}},children:"Confirm"})]}),/*#__PURE__*/t(Bo,{})]})}};let ob=/*#__PURE__*/Nt.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-993a839-0"})(["display:flex;gap:10px;"]),sb="#8a63d2";const lb={component:()=>{let{lastScreen:r,navigateBack:a,data:s,app:l}=Tu(),{requestFarcasterSignerStatus:c,closePrivyModal:p}=Q(),[h,u]=o(void 0),[m,f]=o(!1),[w,v]=o(!1),b=i([]),C=s?.farcasterSigner;d((()=>{let e=Date.now(),t=setInterval((async()=>{if(!C?.public_key)return clearInterval(t),void u({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===C.status&&(clearInterval(t),f(!1),v(!0),b.current.push(setTimeout((()=>p({shouldCallAuthOnSuccess:!1,isSuccess:!0})),Mr)));let n=await c(C?.public_key),r=Date.now()-e;"approved"===n.status?(clearInterval(t),f(!1),v(!0),b.current.push(setTimeout((()=>p({shouldCallAuthOnSuccess:!1,isSuccess:!0})),Mr))):r>3e5?(clearInterval(t),u({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===n.status&&(clearInterval(t),u({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),b.current.forEach((e=>clearTimeout(e)))}}),[]);let k="pending_approval"===C?.status?C.signer_approval_url:void 0;/*#__PURE__*/return e(n,g||m?{children:[/*#__PURE__*/t(Ko,{backFn:r?a:void 0,onClose:p},"header"),/*#__PURE__*/t(ll,{}),
|
|
25
25
|
/*#__PURE__*/t(n,y?{children:/*#__PURE__*/e(db,{children:[/*#__PURE__*/t(kl,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Fs,{success:w,fail:!!h}),/*#__PURE__*/t(cp,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(ol,{children:[/*#__PURE__*/t($d,{children:h?h.message:"Add a signer to Farcaster"}),/*#__PURE__*/t(jd,{children:h?h.detail:"This will allow "+l.name+" to add casts, likes, follows, and more on your behalf."})]}),k&&/*#__PURE__*/t(Vs,{onClick:e=>{e.preventDefault(),window.location.href=k},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(cb,{children:[/*#__PURE__*/t(kl,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Fs,{success:w,fail:!!h}),/*#__PURE__*/t(cp,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(ol,{children:[/*#__PURE__*/t($d,{children:h?h.message:"Requesting signer from Farcaster"}),/*#__PURE__*/t(jd,{children:h?h.detail:"This should only take a moment"}),/*#__PURE__*/t(tl,{children:k&&g&&/*#__PURE__*/t(wp,{text:"Take me to Warpcast",url:k,color:sb})})]})]})}),/*#__PURE__*/t($o,{})]}:{children:[/*#__PURE__*/t(Ko,{backFn:r?a:void 0,onClose:p},"header"),/*#__PURE__*/t(ll,{}),/*#__PURE__*/t(cb,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t($d,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e(jd,{children:["This will allow ",l.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/t(rl,{children:"pending_approval"===C?.status?/*#__PURE__*/t(Ep,{url:C.signer_approval_url,size:275,squareLogoElement:cp}):/*#__PURE__*/t(Ds,{})}),/*#__PURE__*/e(tl,{children:[/*#__PURE__*/t(jd,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===C?.status&&/*#__PURE__*/t(yp,{text:C.signer_approval_url,itemName:"link",color:sb})]})]})}),/*#__PURE__*/t($o,{})]})}};let cb=/*#__PURE__*/Nt.div.withConfig({displayName:"ConnectContainer",componentId:"sc-6e8f76e5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),db=/*#__PURE__*/Nt.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e8f76e5-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const pb={component:()=>{let{closePrivyModal:r}=Q();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{},"header"),/*#__PURE__*/t(hb,{children:/*#__PURE__*/t(Xt,{style:{width:32,height:32}})}),/*#__PURE__*/t(ts,{title:"Could not log in with provider",description:"It looks like you're using an in-app browser. To log in, please try again using an external browser.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/t(el,{children:/*#__PURE__*/t(Vs,{onClick:()=>r(),children:"Close"})}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]})}};let hb=/*#__PURE__*/Nt.div.withConfig({displayName:"StyledCircle",componentId:"sc-7bde5742-0"})(["border-radius:50%;height:68px;width:68px;display:flex;align-items:center;justify-content:center;background-color:var(--privy-color-accent);color:white;margin:0 auto 24px auto;"]);const ub={component:()=>{let{app:r}=Tu();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{},"header"),/*#__PURE__*/t(ll,{}),/*#__PURE__*/t(ns,{title:"Connect your email",description:`Add your email to your ${r?.name} account`,icon:/*#__PURE__*/t(Kt,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(el,{children:/*#__PURE__*/t(Fh,{stacked:!0})}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]})}},mb={component:()=>{let{app:r,currentScreen:a,data:i,navigate:o,setModalData:s}=Tu(),{initLoginWithSms:l}=Q();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{},"header"),/*#__PURE__*/t(ll,{}),/*#__PURE__*/t(ns,{title:"Connect your phone",description:`Add your number to your ${r?.name} account`,icon:/*#__PURE__*/t(Gt,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/t(el,{children:/*#__PURE__*/t(Qp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await l({phoneNumber:e,withPrivyUi:!0}),o(Ah)}catch(e){s({errorModalData:{error:e,previousScreen:i?.errorModalData?.previousScreen||a||mb}}),o(Yl)}},hideRecent:!0})}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]})}},gb={component:()=>{let{app:r,data:a}=Tu(),i=a?.externalConnectWallet?.suggestedAddress,o=i?/*#__PURE__*/e("span",{children:["Link the wallet with address ",/*#__PURE__*/t(is,{showCopyIcon:!1,address:i})," ",r?.name?`to ${r.name}.`:"."]}):`Link a wallet to your ${r?.name} account`,{connectors:s}=Q(),l=vu({walletList:a?.externalConnectWallet?.walletList??r.appearance.walletList,walletChainType:a?.externalConnectWallet?.walletChainType??r.appearance.walletChainType,connectors:s,connectOnly:!1,ignore:r.appearance.walletList,walletConnectEnabled:r.externalWallets.walletConnect.enabled});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{},"header"),l.length>0&&/*#__PURE__*/t(ts,{title:"Link your wallet",description:o}),/*#__PURE__*/t(ds,{children:/*#__PURE__*/t(wu,{wallets:l})}),/*#__PURE__*/t(Bo,{})]})}},yb=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"164",height:"164",viewBox:"0 0 164 164",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"26px",width:"26px",...n},...r,children:[/*#__PURE__*/t("circle",{cx:"82",cy:"82",r:"80",stroke:"#EC6351","stroke-width":"4","stroke-linecap":"round"}),/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M81.9999 100.788C93.3288 100.788 102.513 91.6043 102.513 80.2754C102.513 68.9465 93.3288 59.7626 81.9999 59.7626C70.671 59.7626 61.4871 68.9465 61.4871 80.2754C61.4871 91.6043 70.671 100.788 81.9999 100.788ZM88.3236 71.8304C88.9093 71.2446 89.8591 71.2446 90.4449 71.8304C91.0307 72.4161 91.0307 73.3659 90.4449 73.9517L84.121 80.2756L90.445 86.5996C91.0308 87.1854 91.0308 88.1351 90.445 88.7209C89.8592 89.3067 88.9095 89.3067 88.3237 88.7209L81.9997 82.3969L75.6756 88.7209C75.0899 89.3067 74.1401 89.3067 73.5543 88.7209C72.9685 88.1351 72.9685 87.1854 73.5543 86.5996L79.8783 80.2756L73.5544 73.9517C72.9686 73.3659 72.9686 72.4161 73.5544 71.8304C74.1402 71.2446 75.09 71.2446 75.6758 71.8304L81.9997 78.1543L88.3236 71.8304Z",fill:"#EC6351"})]}),fb={component:()=>{let{closePrivyModal:r}=Q(),{navigate:a}=Tu();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{},"header"),/*#__PURE__*/t(ll,{}),/*#__PURE__*/t(yb,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/t(ts,{title:"Could not connect with wallet",description:"Please check that Phantom multichain is enabled and try again.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),/*#__PURE__*/e(el,{children:[/*#__PURE__*/t(Vs,{onClick:()=>a(Hh),children:"Try again"}),/*#__PURE__*/t(Gs,{onClick:()=>r(),children:"Cancel"})]}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]})}};function wb(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenroll:o,enrollInMfa:s}=l(ml);return{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenrollWithSms:()=>o("sms"),unenrollWithTotp:()=>o("totp"),unenrollWithPasskey:e=>o("passkey",e),showMfaEnrollmentModal:()=>s(!0),closeMfaEnrollmentModal:()=>s(!1)}}const vb=n=>/*#__PURE__*/e(bb,{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"88",height:"89",viewBox:"0 0 88 89",...n,children:[/*#__PURE__*/t("rect",{y:"0.666016",width:"88",height:"88",rx:"44"}),/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M45.2463 20.9106C44.5473 20.2486 43.4527 20.2486 42.7537 20.9106C37.8798 25.5263 31.3034 28.3546 24.0625 28.3546C23.9473 28.3546 23.8323 28.3539 23.7174 28.3525C22.9263 28.3427 22.2202 28.8471 21.9731 29.5987C20.9761 32.6311 20.4375 35.8693 20.4375 39.2297C20.4375 53.5896 30.259 65.651 43.5482 69.0714C43.8446 69.1477 44.1554 69.1477 44.4518 69.0714C57.741 65.651 67.5625 53.5896 67.5625 39.2297C67.5625 35.8693 67.0239 32.6311 66.0269 29.5987C65.7798 28.8471 65.0737 28.3427 64.2826 28.3525C64.1677 28.3539 64.0527 28.3546 63.9375 28.3546C56.6966 28.3546 50.1202 25.5263 45.2463 20.9106ZM52.7249 40.2829C53.3067 39.4683 53.1181 38.3363 52.3035 37.7545C51.4889 37.1726 50.3569 37.3613 49.7751 38.1759L41.9562 49.1223L38.0316 45.1977C37.3238 44.4899 36.1762 44.4899 35.4684 45.1977C34.7605 45.9056 34.7605 47.0532 35.4684 47.761L40.9059 53.1985C41.2826 53.5752 41.806 53.7671 42.337 53.7232C42.868 53.6792 43.3527 53.4039 43.6624 52.9704L52.7249 40.2829Z"})]});let bb=/*#__PURE__*/Nt.svg.withConfig({displayName:"StyledSvg",componentId:"sc-59fa943f-0"})(["height:90px;width:90px;> rect{","}> path{fill:white;}"],(e=>"success"===e.color?"fill: var(--privy-color-success);":"fill: var(--privy-color-accent);"));const Cb=({showIntro:r,userMfaMethods:a,appMfaMethods:i,userHasAuthSms:o,isTotpLoading:s,isPasskeyLoading:l,error:c,onClose:d,onBackToIntro:p,handleSelectMethod:h,setRemovingMfaMethod:u})=>{let m=a.reduce(((e,t)=>({...e,[t]:!0})),{}),g=i.reduce(((e,t)=>({...e,[t]:!0})),{});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{backFn:r?p:void 0,onClose:d},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(yn,{})}),/*#__PURE__*/t($d,{children:"Choose a verification method"}),a.length>0?/*#__PURE__*/t(jd,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/t(jd,{children:"How would you like to verify your identity? You can change this later."}),c&&/*#__PURE__*/t(ap,{style:{marginTop:"1.25rem"},children:c.message}),/*#__PURE__*/e(Gd,{children:[(g.totp||m.totp)&&/*#__PURE__*/e(Yd,{children:[/*#__PURE__*/t(ms,{style:{justifyContent:"center"},disabled:m.totp||s,onClick:()=>h("totp"),children:s?/*#__PURE__*/t(Ds,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(ep,{children:[/*#__PURE__*/e(Xd,{children:[/*#__PURE__*/t(bn,{}),"Authenticator app"]}),m.totp?/*#__PURE__*/t(kb,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Qd,{children:"Recommended"})]})}),m.totp&&/*#__PURE__*/t(Jd,{style:{position:"absolute",right:0},onClick:()=>u("totp"),children:/*#__PURE__*/t(Kn,{})})]},"totp"),(g.sms||m.sms)&&/*#__PURE__*/e(Yd,{children:[/*#__PURE__*/t(ms,{disabled:m.sms||o,onClick:()=>h("sms"),children:/*#__PURE__*/e(ep,{children:[/*#__PURE__*/e(Xd,{children:[/*#__PURE__*/t(Gt,{}),"SMS"]}),m.sms&&/*#__PURE__*/t(kb,{color:"green",children:"Enabled"}),o&&/*#__PURE__*/t(Qd,{children:"Disabled"})]})}),m.sms&&/*#__PURE__*/t(Jd,{style:{position:"absolute",right:0},onClick:()=>u("sms"),children:/*#__PURE__*/t(Kn,{})})]},"sms"),(g.passkey||m.passkey)&&/*#__PURE__*/e(Yd,{children:[/*#__PURE__*/t(ms,{style:{justifyContent:"center"},onClick:()=>h("passkey"),disabled:m.passkey||l,children:l?/*#__PURE__*/t(Ds,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(ep,{children:[/*#__PURE__*/e(Xd,{children:[/*#__PURE__*/t(wn,{}),"Passkey"]}),m.passkey?/*#__PURE__*/t(kb,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Qd,{isAccent:!0,children:/*#__PURE__*/t(vn,{})})]})}),m.passkey&&/*#__PURE__*/t(Jd,{style:{position:"absolute",right:0},onClick:()=>u("passkey"),children:/*#__PURE__*/t(Kn,{})})]},"passkey")]}),/*#__PURE__*/t($o,{})]})};let kb=/*#__PURE__*/Nt(xs).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const xb=({appName:e,onComplete:n,onClose:r,onReset:a})=>{let{user:i}=gl(),{data:l}=Tu(),{initLinkWithPasskey:c,linkWithPasskey:d}=Q(),{initEnrollmentWithPasskey:p,submitEnrollmentWithPasskey:h}=wb(),[u,m]=o(!1),[g,y]=o(!1),[f,w]=o(!1),[v,b]=o(null),C=s((()=>i?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[i]),k=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},x=async e=>{m(!0);try{await p(),await h({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),w(!0)}catch(e){b(e)}finally{m(!1)}},T=async()=>{y(!0),b(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await x(t)}catch(e){b(e)}finally{y(!1)}};return 0===C.length||g?/*#__PURE__*/t(Tb,{onReset:a,onClose:r,onClick:T,isCreating:g}):f?/*#__PURE__*/t(Ib,{appName:e,onClick:k,onClose:k}):v?/*#__PURE__*/t(Jl,{error:v,backFn:()=>b(null),onClick:()=>b(null)}):/*#__PURE__*/t(Ab,{passkeys:C,isSubmitting:u,isCreating:g,onReset:a,onClose:r,onSubmitEnrollment:()=>x(C.map((e=>e.credentialId))),onAddPasskey:T})};let Tb=({onReset:r,onClose:a,onClick:i,isCreating:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{backFn:r,onClose:a},"header"),/*#__PURE__*/t(Bd,{children:/*#__PURE__*/e(cf,{children:[/*#__PURE__*/t(jp,{}),/*#__PURE__*/t(Vp,{})]})}),/*#__PURE__*/t($d,{children:"Set up passkey verification"}),/*#__PURE__*/e(Hd,{children:[/*#__PURE__*/e(Kd,{children:[/*#__PURE__*/t(qd,{children:/*#__PURE__*/t(yn,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e(Kd,{children:[/*#__PURE__*/t(qd,{children:/*#__PURE__*/t(jn,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e(Kd,{children:[/*#__PURE__*/t(qd,{children:/*#__PURE__*/t(Zn,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/t(Vs,{style:{marginTop:"2.25rem"},onClick:i,loading:o,children:"Add a new passkey"}),/*#__PURE__*/t($o,{})]}),Ab=({onReset:r,onClose:a,onAddPasskey:i,onSubmitEnrollment:s,passkeys:l,isSubmitting:c,isCreating:d})=>{let[p,h]=o(!1),u=p?l.length:l.length>3?2:3;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{backFn:p?()=>h(!1):r,onClose:a},"header"),!p&&/*#__PURE__*/t(Bd,{children:/*#__PURE__*/e(cf,{children:[/*#__PURE__*/t(jp,{}),/*#__PURE__*/t(Vp,{})]})}),/*#__PURE__*/t($d,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e(Hd,{children:[l.slice(0,u).map((n=>/*#__PURE__*/e(_b,{children:[/*#__PURE__*/t(Eb,{children:Nb(n)}),/*#__PURE__*/e(Sb,{children:["Last used: ",n.latestVerifiedAt?.toLocaleString()]})]},n.credentialId))),!p&&l.length>3&&/*#__PURE__*/t(Mb,{onClick:()=>h(!0),children:"View All"})]}),/*#__PURE__*/t(Vs,{style:{marginTop:"1.5rem"},onClick:s,loading:c,children:"Enable passkeys"}),l.length<5&&/*#__PURE__*/t(Mb,{style:{marginTop:"0.5rem"},onClick:i,disabled:d,children:d?/*#__PURE__*/t(Ds,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/t($o,{})]})},Ib=({appName:r,onClick:a,onClose:i})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{onClose:i},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Mn,{})}),/*#__PURE__*/t($d,{children:"Passkey verification added"}),/*#__PURE__*/e(jd,{children:["From now on, you'll use the passkey whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Zd,{children:/*#__PURE__*/t(Vs,{onClick:a,children:"Done"})}),/*#__PURE__*/t($o,{})]}),_b=/*#__PURE__*/Nt.div.withConfig({displayName:"PasskeyItem",componentId:"sc-d5b2bf9c-0"})(["&&{padding:0.75rem 1rem;text-align:left;border-radius:0.5rem;border:1px solid var(--privy-color-foreground-4);width:100%;}"]),Eb=/*#__PURE__*/Nt.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-d5b2bf9c-1"})(["font-size:0.875rem;line-height:1.375rem;font-weight:500;color:var(--privy-color-foreground-1);"]),Sb=/*#__PURE__*/Nt.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-d5b2bf9c-2"})(["font-size:0.75rem;font-weight:400;line-height:1.125rem;color:var(--privy-color-foreground-2);"]),Nb=e=>e.authenticatorName?e.createdWithBrowser?`${e.authenticatorName} on ${e.createdWithBrowser}`:e.authenticatorName:e.createdWithBrowser?e.createdWithOs?`${e.createdWithBrowser} on ${e.createdWithOs}`:`${e.createdWithBrowser}`:"Unknown device";const Mb=/*#__PURE__*/Nt.button.withConfig({displayName:"StyledLink",componentId:"sc-d5b2bf9c-3"})(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:0.75rem 1rem;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent);:focus{outline:none;box-shadow:none;}}"]),Pb=({appName:r,onComplete:a,onReset:i,onClose:s})=>{let[l,c]=o(""),[d,p]=o(!1),[h,u]=o(null),[m,g]=o("enroll"),{initEnrollmentWithSms:y,submitEnrollmentWithSms:f}=wb(),{app:w,data:v}=Tu();function b(){v?.mfaEnrollmentFlow?.onSuccess(),a()}return h?/*#__PURE__*/t(Jl,{error:h,backFn:()=>u(null),onClick:()=>u(null)}):/*#__PURE__*/e(n,"enroll"===m?{children:[/*#__PURE__*/t(Ko,{backFn:i,onClose:s},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Gt,{})}),/*#__PURE__*/t($d,{children:"Set up SMS verification"}),/*#__PURE__*/e(jd,{children:["We'll text a verification code to this mobile device whenever you use your ",r," ","wallet."]}),/*#__PURE__*/e(Vd,{children:[/*#__PURE__*/t(Qp,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await y({phoneNumber:e}),c(e),g("verify")}catch(e){u(e)}},hideRecent:!0}),/*#__PURE__*/e(tp,{children:["By providing your mobile number, you agree to receive text messages from ",w?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/t($o,{})]}:d?{children:[/*#__PURE__*/t(Ko,{onClose:b},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Mn,{})}),/*#__PURE__*/t($d,{children:"SMS verification added"}),/*#__PURE__*/e(jd,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Zd,{children:/*#__PURE__*/t(Vs,{onClick:b,children:"Done"})}),/*#__PURE__*/t($o,{})]}:{children:[/*#__PURE__*/t(Ko,{backFn:function(){"verify"===m?g("enroll"):i()},onClose:s},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Gt,{})}),/*#__PURE__*/t($d,{children:"Enter enrollment code"}),/*#__PURE__*/e(Vd,{children:[/*#__PURE__*/t(Qu,{onChange:async function(e){try{if(!e)return;await f({phoneNumber:l,mfaCode:e}),p(!0)}catch(e){if(Dl(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Rl(e))throw Error("The code you entered is not valid");if(Ll(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw zl(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e(jd,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/t("strong",{children:Et(l)})]})]}),/*#__PURE__*/t($o,{})]})},Wb=({size:e,authUrl:n})=>/*#__PURE__*/t(Ep,{url:n,squareLogoElement:Gn,size:e,fgColor:"#1F1F1F"}),Ob=({onComplete:r,onClose:a,onReset:i,totpInfo:s})=>{let[l,c]=o("enroll"),[d,p]=o(!1),{submitEnrollmentWithTotp:h}=wb(),{data:u}=Tu();function m(){u?.mfaEnrollmentFlow?.onSuccess(),r()}/*#__PURE__*/return e(n,"enroll"===l?{children:[/*#__PURE__*/t(Ko,{backFn:i,onClose:a},"header"),/*#__PURE__*/t($d,{children:"Scan QR code"}),/*#__PURE__*/t(jd,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/t(rl,{children:/*#__PURE__*/t(Wb,{authUrl:s.authUrl,size:200})}),/*#__PURE__*/e(Zd,{children:[/*#__PURE__*/t(tl,{children:/*#__PURE__*/t(yp,{itemName:"setup key",text:s.secret})}),/*#__PURE__*/t(Vs,{onClick:function(){c("verify")},children:"Continue"})]}),/*#__PURE__*/t($o,{})]}:d?{children:[/*#__PURE__*/t(Ko,{onClose:m},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Mn,{})}),/*#__PURE__*/t($d,{children:"Authenticator app verification added"}),/*#__PURE__*/e(jd,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",s.appName," wallet."]}),/*#__PURE__*/t(Zd,{children:/*#__PURE__*/t(Vs,{onClick:m,children:"Done"})}),/*#__PURE__*/t($o,{})]}:{children:[/*#__PURE__*/t(Ko,{backFn:function(){"verify"===l?c("enroll"):i()},onClose:a},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(bn,{})}),/*#__PURE__*/t($d,{children:"Enter enrollment code"}),/*#__PURE__*/t(Vd,{children:/*#__PURE__*/t(Qu,{onChange:async function(e){try{if(!e)return;await h({mfaCode:e}),p(!0)}catch(e){if(Dl(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Rl(e))throw Error("The code you entered is not valid");if(Ll(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw zl(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e(jd,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),/*#__PURE__*/t($o,{})]})},Ub={component:()=>{let{user:r,enrollInMfa:a,ready:i}=gl(),[s,l]=o(null),{unenrollWithSms:c,unenrollWithTotp:p,unenrollWithPasskey:h}=wb(),{app:u,data:m,onUserCloseViaDialogOrKeybindRef:g}=Tu(),{closePrivyModal:y}=Q(),{promptMfa:f}=cg(),{initEnrollmentWithTotp:w}=wb(),[v,b]=o(!1),[C,k]=o(null),[x,T]=o(null),A=()=>{y({shouldCallAuthOnSuccess:!0}),a(!1),setTimeout((()=>{l(null),k(null)}),500)},{initEnrollmentWithPasskey:I,submitEnrollmentWithPasskey:_}=wb(),[E,S]=o(!1),[N,M]=o(null);g.current=A;let P=r?.mfaMethods.includes("sms"),W=!!r?.phone,O=r?.mfaMethods.includes("totp"),U=r?.mfaMethods.includes("passkey"),L=P||O||U,R=r?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function F(){l(null),k(null)}if(d((()=>{L&&b(!0)}),[L]),!i||!r||!u/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(Ko,{onClose:A},"header"),/*#__PURE__*/t(Bd,{children:/*#__PURE__*/t(vb,{})}),/*#__PURE__*/t(Vd,{children:/*#__PURE__*/t(Ds,{})}),/*#__PURE__*/t($o,{})]});if("sms"===s)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{backFn:F,onClose:A},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Rt,{})}),/*#__PURE__*/t($d,{children:"Remove SMS verification?"}),/*#__PURE__*/e(jd,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/t(Zd,{children:/*#__PURE__*/t(Vs,{warn:!0,onClick:async function(){l(null);try{await c()}catch(e){l(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/t($o,{})]});if("totp"===s)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{backFn:F,onClose:A},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Rt,{})}),/*#__PURE__*/t($d,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e(jd,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/t(Zd,{children:/*#__PURE__*/t(Vs,{warn:!0,onClick:async function(){l(null);try{await p()}catch(e){l(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/t($o,{})]});if("passkey"===s){let r=m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{backFn:F,onClose:A},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Rt,{})}),/*#__PURE__*/t($d,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/t(jd,{children:r?"Removing your passkey will remove as both a verification method and a login method.":"Removing your passkey will remove as a verification method."}),/*#__PURE__*/t(Zd,{children:/*#__PURE__*/t(Vs,{warn:!0,onClick:async function(){l(null);try{await h({removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){l(null)}},children:"Yes, remove"})}),/*#__PURE__*/t($o,{})]})}if(0===m.mfaEnrollmentFlow.mfaMethods.length&&!L)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{onClose:A},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(yn,{})}),/*#__PURE__*/t($d,{children:"Add more security"}),/*#__PURE__*/e(jd,{children:[u?.name," does not have any verification methods enabled."]}),/*#__PURE__*/t(Zd,{children:/*#__PURE__*/t(Vs,{onClick:A,children:"Close"})}),/*#__PURE__*/t($o,{})]});let D=!L&&!v;return D?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{onClose:A},"header"),/*#__PURE__*/t(rp,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(yn,{})}),/*#__PURE__*/t($d,{children:"Transaction Protection"}),/*#__PURE__*/t(jd,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e(Hd,{children:[/*#__PURE__*/e(Kd,{children:[/*#__PURE__*/t(qd,{children:/*#__PURE__*/t(Hn,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),/*#__PURE__*/e(Kd,{children:[/*#__PURE__*/t(qd,{children:/*#__PURE__*/t(qn,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e(Zd,{children:[/*#__PURE__*/t(Vs,{onClick:()=>b(!0),children:"Continue"}),/*#__PURE__*/t(Gs,{onClick:A,children:"Not now"})]}),/*#__PURE__*/t($o,{})]}):"sms"===C?/*#__PURE__*/t(Pb,{appName:u?.name||"Privy",onComplete:A,onReset:F,onClose:A}):"totp"===C&&x?/*#__PURE__*/t(Ob,{onComplete:A,onClose:A,onReset:F,totpInfo:{...x,appName:u?.name||"Privy"}}):"passkey"===C?/*#__PURE__*/t(xb,{appName:u?.name||"Privy",onComplete:A,onReset:F,onClose:A}):/*#__PURE__*/t(Cb,{showIntro:D,userMfaMethods:r.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:W,onBackToIntro:function(){b(!1)},handleSelectMethod:async function(e){return await f().catch(M),"totp"===e?(k(e),T(null),void w().then((e=>{T(e)})).catch((()=>{T(null),F()}))):"passkey"===e&&1===R.length?await async function(){S(!0);try{await I(),await _({credentialIds:R},{removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){M(e)}finally{S(!1)}}():void k(e)},isTotpLoading:"totp"===C&&!x,isPasskeyLoading:E,error:N,onClose:A,setRemovingMfaMethod:async e=>{await f().catch(M),l(e)}})}},Lb={component:()=>{let{authenticated:r,logout:a,ready:i,user:s}=gl(),{app:l,setModalData:c,navigate:p,resetNavigation:h}=Tu(),{getAuthMeta:u,initLoginWithOAuth:m,loginWithOAuth:g,updateWallets:y,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v}=Q(),[b,C]=o(!1),[k,x]=o(void 0),T=u()?.provider||"google",{name:A,component:I}=Ca(T);d((()=>{g(T).then((()=>{C(!0),f(!0)})).catch((e=>{if(f(!1),e?.privyErrorCode===U.ALLOWLIST_REJECTED)return x(void 0),h(),void p(Sp);if(e?.privyErrorCode===U.USER_LIMIT_REACHED)return console.error(new oe(e).toString()),x(void 0),h(),void p(Wp);if(e?.privyErrorCode===U.USER_DOES_NOT_EXIST)return x(void 0),h(),void p(qh);if(e?.privyErrorCode===U.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return x(void 0),h(),c({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:u()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void p(hc);let{retryable:t,detail:n}=function(e,t){let n={detail:"",retryable:!1},r=ca(t);if(e?.privyErrorCode===U.LINKED_TO_ANOTHER_USER&&(n.detail="This account has already been linked to another user."),e?.privyErrorCode===U.INVALID_CREDENTIALS&&(n.retryable=!0,n.detail="Something went wrong. Try again."),e.privyErrorCode===U.OAUTH_USER_DENIED&&(n.detail=`Retry and check ${r} to finish connecting your account.`,n.retryable=!0),e?.privyErrorCode===U.TOO_MANY_REQUESTS&&(n.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===U.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=Ca(t).name;n.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===U.OAUTH_ACCOUNT_SUSPENDED){let e=Ca(t).name;n.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===U.CANNOT_LINK_MORE_OF_TYPE&&(n.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===U.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(n.detail="Something went wrong. Please try again."),n}(e,T);x({retryable:t,detail:n,message:"Authentication failed"})})).finally((()=>{xa()}))}),[A,T]),d((()=>{if(i&&r&&b&&s){if(l?.legal.requireUsersAcceptTerms&&!s.hasAcceptedTerms){let e=setTimeout((()=>{p(ip)}),Mr);return()=>clearTimeout(e)}if(bl(s,l.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:T,screen:"OAuthStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),p(Dd)}),Mr);return()=>clearTimeout(e)}{let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),Mr);return y(),()=>clearTimeout(e)}}}),[i,r,b,s]);let _=b?`Successfully connected with ${A}`:k?k.message:`Verifying connection to ${A}`,E="";return E=b?"You’re good to go!":k?k.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{}),/*#__PURE__*/t(ll,{}),/*#__PURE__*/e(Rb,{children:[/*#__PURE__*/t(kl,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Fs,{success:b,fail:!!k}),/*#__PURE__*/t(I,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(ol,{children:[/*#__PURE__*/t("h3",{children:_}),/*#__PURE__*/t("p",{children:E})]}),k&&k?.retryable?/*#__PURE__*/t(Js,{onClick:()=>{xa(),m(T),x(void 0)},disabled:!b&&!k?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t($o,{})]})}};let Rb=/*#__PURE__*/Nt.div.withConfig({displayName:"ConnectContainer",componentId:"sc-89bb91a9-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const Fb=/*#__PURE__*/u(((r,a)=>{let[i,s]=o(""),[l,c]=o(""),[d,p]=o(!1),{authenticated:h,user:u}=gl(),{initUpdateEmail:m}=Q(),{navigate:g,setModalData:y,currentScreen:f}=Tu(),{enabled:w,token:v}=Wa(),b=Lo(),C=cr(i)&&(b.disablePlusEmails&&i.includes("+")?(l||c("Please enter a valid email address without a '+'."),!1):(l&&c(""),!0)),k=d||!C,x=()=>{!w||v||h?(async e=>{if(!u?.email)throw Error("User is required to have an email address to update it.");p(!0);try{await m(u.email.address,i,e),g(Ah)}catch(e){y({errorModalData:{error:e,previousScreen:f||Hh}})}p(!1)})(v):(y({captchaModalData:{callback:e=>{if(!u?.email)throw Error("User is required to have an email address to update it.");return m(u.email.address,i,e)},userIntentRequired:!1,onSuccessNavigateTo:Ah,onErrorNavigateTo:Yl}}),g(hp))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(Db,{children:[l&&/*#__PURE__*/t(Wh,{style:{marginTop:"0.25rem",textAlign:"left"},children:l}),/*#__PURE__*/e(zb,{$error:!!l,children:[/*#__PURE__*/t(Kt,{}),/*#__PURE__*/t("input",{ref:a,id:"email-input",type:"email",placeholder:"your@email.com",onChange:e=>s(e.target.value),onKeyUp:e=>{"Enter"===e.key&&x()},value:i,autoComplete:"email"}),r.stacked?null:/*#__PURE__*/t(Xs,{isSubmitting:d,onClick:x,disabled:k,children:"Submit"})]})]}),r.stacked?/*#__PURE__*/t(Vs,{loadingText:null,loading:d,disabled:k,onClick:x,children:"Submit"}):null]})}));let Db=Rh,zb=Uh;const Bb={component:()=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ko,{},"header"),/*#__PURE__*/t(ll,{}),/*#__PURE__*/t(ns,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/t(Kt,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(el,{children:/*#__PURE__*/t(Fb,{stacked:!0})}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]})},$b={component:()=>{let{currentScreen:r,data:a,navigate:i,setModalData:o}=Tu(),{user:s}=gl(),{initUpdatePhone:l}=Q();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ko,{},"header"),/*#__PURE__*/t(ll,{}),/*#__PURE__*/t(ns,{title:"Update your phone number",description:"Add the phone number you'd like to use going forward. We'll send you a confirmation code",icon:/*#__PURE__*/t(Gt,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(el,{children:/*#__PURE__*/t(Qp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{if(!s?.phone?.number)throw Error("User is required to have an phone number to update it.");await l(s?.phone?.number,e),i(Ah)}catch(e){o({errorModalData:{error:e,previousScreen:a?.errorModalData?.previousScreen||r||mb}}),i(Yl)}},hideRecent:!0})}),/*#__PURE__*/t(cl,{}),/*#__PURE__*/t(Bo,{})]})}};let jb,Vb,Hb,qb,Kb,Zb,Gb;function Yb(){return jb?jb.getCustomerAccessToken():Promise.resolve(rr.get(Ur)||null)}async function Jb(){return jb?jb.getAccessToken():Promise.resolve(rr.get(Fr)||rr.get(Ur)||null)}const Xb=(e,t)=>Vb(e,t),Qb=(e,t)=>Hb(e,t),eC=(e,t)=>qb(e,t),tC=(e,t)=>Kb(e,t),nC=()=>Zb(),rC=()=>Gb(),aC=({config:e,...n})=>{var r;if("undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new k("Embedded wallet is only available over HTTPS");if("string"!=typeof(r=n.appId)||25!==r.length)throw new k("Cannot initialize the Privy provider with an invalid Privy app ID");jb||(jb=new ju({appId:n.appId,appClientId:n.clientId,apiUrl:n.apiUrl}));let a=Object.assign({},e);/*#__PURE__*/
|
|
26
|
-
return t(Uo,{client:jb,clientConfig:a,children:/*#__PURE__*/t(ly,{children:/*#__PURE__*/t(iC,{...n,client:jb})})})};let iC=n=>{let a=n.client,l=dy();Dg();let[c,h]=o(!1),[u,m]=o(!1),[g,y]=o(!1),[f,b]=o(null),[x,A]=o([]),[I,_]=o([]),[E,N]=o(!1),[M,P]=o(null),[W,O]=o(!1),[L,F]=o({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:G}),[D,z]=o({status:"initial"}),[B,$]=o({status:"initial"}),[j,V]=o({status:"initial"}),[H,q]=o({status:"initial"}),[K,Y]=o({status:"initial"}),[J,X]=o({status:"initial"}),[Q,ee]=o(null),te=Lo(),ne=Ro(),[re,ae]=o({}),[ie,oe]=o(null),[se,le]=o(null),[ce,de]=o(!1),[pe,he]=o(!1),[ue,me]=o(te.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),ge=i(null),ye=i(null),fe=i(Is),[we,ve]=o(!1);a.onStoreCustomerAccessToken=e=>{e&&Ns(fe,"accessToken","onAccessTokenGranted",{accessToken:e})},a.onDeleteCustomerAccessToken=()=>{b(null),y(!1),Ns(fe,"accessToken","onAccessTokenRemoved")};let be=i(null),Ce=i(null),ke=i(!1),xe=({showWalletUIs:e})=>ke.current?ke.current:void 0!==e?!e:!te.embeddedWallets.showWalletUIs,Te=e=>{P(e),setTimeout((()=>{h(!0)}),15)};d((()=>{if(!f)return void a.connectors?.removeEmbeddedWalletConnectors();let e=$a(f),t=ja(f),r=qa(f);e&&t.length||a.connectors?.removeEmbeddedWalletConnectors(),r||a.connectors?.removeImportedWalletConnector(),a.connectors?Q?(e&&a.connectors.addEmbeddedWalletConnectors({walletProxy:Q,user:f,embeddedWallets:t,defaultChain:te.defaultChain,appId:n.appId}),r&&a.connectors.addImportedWalletConnector(Q,r.address,te.defaultChain,n.appId)):console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized"):console.debug("Failed to add embedded wallet connector: Client connectors not initialized")}),[Q,f]),d((()=>{Q&&se?.(Q)}),[Q]);let Ae=i();d((()=>{(async()=>{if(!te.customAuth?.enabled)return void me({status:"not-enabled"});let{getCustomAccessToken:e,isLoading:t}=te.customAuth;if(u&&!t&&"loading"!==ue.status){me({status:"loading"});try{let t=await e();if(t===Ae.current)return void me({status:"done"});if(!t&&g)return Ae.current=t,await Je.logout(),me({status:"done"}),void Ns(fe,"customAuth","onUnauthenticated");if(!t)return Ae.current=t,void me({status:"done"});a.startAuthFlow(new Jn(t));let{user:n,isNewUser:r}=await a.authenticate();if(!n)return await Je.logout(),me({status:"error",error:new k("Failed to sync with custom auth provider")}),void Ns(fe,"customAuth","onUnauthenticated");void 0!==r&&Ns(fe,"login","onComplete",{user:n,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),Ae.current=t,Ns(fe,"customAuth","onAuthenticated",{user:n}),me({status:"done"}),b(n||null),N(r||!1),y(!0),he(!0)}catch(e){if(console.warn(e),await Je.logout(),Ns(fe,"customAuth","onUnauthenticated"),"User already exists with provided custom JWT account."===e.message)return void me({status:"initial"});Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),me({status:"error",error:e})}}})()}),["initial"===ue.status,te.customAuth?.enabled,te.customAuth?.getCustomAccessToken,te.customAuth?.isLoading,u,g]),d((()=>{pe&&Q&&f&&(async()=>{let e=yl(f,te.embeddedWallets.ethereum.createOnLogin),t=wl(f,te.embeddedWallets.solana.createOnLogin),n=await Jb();if(n){if(e&&t){let e=await Re(f,Qr);return await Q.createSolana({accessToken:n,ethereumAddress:e?.address}),void he(!1)}if(t)return await Q.createSolana({accessToken:n,ethereumAddress:$a(f)?.address}),await Xe.refreshSessionAndUser(),void he(!1);if(e)return await Re(f,Qr),void he(!1)}})().catch(console.error)}),[pe&&Q&&f]),d((()=>{if(te.externalWallets.solana.connectors)return te.externalWallets.solana.connectors.onMount(),()=>te.externalWallets.solana.connectors?.onUnmount()}),[te.externalWallets.solana.connectors]),d((()=>{!u&&ne&&async function(){let e,t=Ie(),n=_e(),i=r();a.initializeConnectorManager({walletConnectCloudProjectId:te.walletConnectCloudProjectId,rpcConfig:te.rpcConfig,chains:te.chains,defaultChain:te.defaultChain,store:i,walletList:te.appearance.walletList,shouldEnforceDefaultChainOnConnect:te.shouldEnforceDefaultChainOnConnect,externalWalletConfig:te.externalWallets,appName:te.name??"Privy",walletChainType:te.appearance.walletChainType}),a.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=a.connectors.walletConnectors.length,n=a.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);n===t?ve(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:n,expected:t}),ve(!0)}),1500)})),a.connectors?.initialize().then((()=>{Pe()}));let o=await a.getAuthenticatedUser(),s=!!o;te.legal.requireUsersAcceptTerms&&o&&!o.hasAcceptedTerms?(await a.logout(),Xe.setReadyToTrue(!0),Ns(fe,"logout","onSuccess")):(te.customAuth?.enabled||(y(!!o),o&&Ns(fe,"login","onComplete",{user:o,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),b(o)),t?Ce.current=s?"link":"login":n&&!s?(Ce.current="login",ae({telegramAuthModalData:{seamlessAuth:!0}}),Te(sh)):Xe.setReadyToTrue(!!o))}()}),[a,ie,u,ne]),d((()=>{if(u){if(!f||!f.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType))||[...x].some((e=>"privy"===e.walletClientType)))return void de(!0);de(!!Q)}}),[u,f,x]),d((()=>{a.connectors?.setWalletList(te.appearance.walletList)}),[te.appearance.walletList.join()]);let Ie=()=>{let e=ka();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&function(e){return e.startsWith("privy:")}(e.provider)&&!e.popupFlow&&(new BroadcastChannel(Bg).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(a.startAuthFlow(new la(e)),Te(Lb),!0))},_e=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),n=e.get("hash"),r=Number(e.get("auth_date")||""),a=e.get("first_name");if(t&&a&&r&&n)return Object.fromEntries(e.entries())}())?(Ra(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=La(e.replace("#tgWebAppData=","")),{user:n,auth_date:r,hash:a}=t;return n&&r&&a?t:void 0}())?(Ra(),{flowType:"web-app",authData:e}):void 0}();if(!e||!te.loginMethods.telegram||!te.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new Oa;return a.startAuthFlow(t),"login-url"===e.flowType&&(t.meta.telegramWebAppData=void 0,t.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=e.authData),!0},Ee=async(e,t,n,r)=>{if("solana_adapter"!==e)Se(await(a.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,n,r);else{let e=a.connectors?.findSolanaWalletConnector(t);if(!e)return;Se(e,t,n,r)}};async function Se(e,t,n,r){if(!e)return F({status:"disconnected",connectedWallet:null,connectError:new S("Unable to connect to wallet."),connector:null,connectRetry:G}),r?.(null,n);F({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:G}),e instanceof Iu&&t&&await e.resetConnection(t),F({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Se(e,t,n,r)});try{let t=await e.connect({showPrompt:!0});if((!t||Ti(t))&&te.shouldEnforceDefaultChainOnConnect&&!te.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){F((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:G})));try{await(t?.switchChain(te.defaultChain.id)),t&&(t.chainId=wr(yr(te.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${te.defaultChain.id}`)}}return F((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:G}))),t&&Ns(fe,"connectWallet","onSuccess",{wallet:t}),r?.(t,n)}catch(e){return e instanceof Z?(console.warn(e.cause?e.cause:e.message),Ns(fe,"connectWallet","onError",e.privyErrorCode||U.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),Ns(fe,"connectWallet","onError",U.UNKNOWN_CONNECT_WALLET_ERROR)),F((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),r?.(null,n)}}let Ne=async(e,t,n)=>{if(null===e||!Ti(e))return;let r=new Ia(e,a,t,n);a.startAuthFlow(r)},Me=async(e,t,n)=>{if(null===e||!so(e))return;let r=new _a(e,a,t,n);a.startAuthFlow(r)},Pe=()=>{let e=new URLSearchParams(window.location.search),t=e.get("privy_connector"),n=e.get("privy_wallet_client"),r="true"===e.get("privy_connect_only");if(!t||!n)return;let i=no({connectorType:t,walletClientType:n});if(!i||!i.isInstalled)return Te(fb);if(!a.connectors)throw new k("Connector not initialized");Te(r?eu:Yh);let o=new URL(window.location.href);o.searchParams.delete("privy_connector"),o.searchParams.delete("privy_wallet_client"),o.searchParams.delete("privy_connect_only"),window.history.pushState({},"",o),Ee(t,n,void 0,r?void 0:"solana_adapter"===t?Me:Ne)};d((()=>{u&&g&&null===f&&a.getAuthenticatedUser().then(b)}),[u,g,f,a]);let We=e=>{if(!g)throw Ns(fe,"linkAccount","onError",U.MUST_BE_AUTHENTICATED,{linkMethod:e}),new k("User must be authenticated before linking an account.")},Oe=e=>{if(!g||!f)return!1;if("privy"===e.walletClientType)return!0;for(let t of f.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},Ue=async e=>{let t;if(!a.connectors)throw new k("Connector not initialized");t="ethereum"===e.type?a.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:a.connectors.findSolanaWalletConnector(e.walletClientType)||null,F((n=>({...n,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:G}))),te.captchaEnabled&&!g?(ae({captchaModalData:{callback:t=>Ti(e)?Ne(e,t):Me(e,t),userIntentRequired:!1,onSuccessNavigateTo:Yh,onErrorNavigateTo:Yl}}),Te(hp)):(Ti(e)?await Ne(e):await Me(e),Te(Yh))},Le=()=>{A((e=>{let t=a.connectors?.wallets.filter(Ti).map((e=>({...e,linked:Oe(e),loginOrLink:async()=>{if(!await e.isConnected())throw new k("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new k("Cannot link or login with embedded wallet");Ue(e)},fund:async t=>{await Xe.fundWallet(e.address,t)},unlink:async()=>{if(!g)throw new k("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new k("Cannot unlink an embedded wallet");b(await a.unlinkEthereumWallet(e.address))}})))||[];return Ai(e,t)?e:t})),_((e=>{let t=(a.connectors?.wallets??[]).filter(so).map((e=>({...e,linked:Oe(e),loginOrLink:async()=>{if(!await e.isConnected())throw new k("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new k("Cannot link or login with embedded wallet");Ue(e)},fund:async()=>{throw new k("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!g)throw new k("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new k("Cannot unlink an embedded wallet");b(await a.unlinkSolanaWallet(e.address))}})));return Ai(e,t)?e:t}))};d((()=>{Le()}),[f?.linkedAccounts,g,u]),d((()=>{if(u){if(!a.connectors)throw new k("Connector not initialized");Le(),a.connectors.on("walletsUpdated",Le)}}),[u]),d((()=>{[...te.loginMethodsAndOrder?.primary??[],...te.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>a.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!a]);let Re=async(e,t,n)=>{let r=$a(e),a=Ha(e);if(n&&"walletIndex"in n&&"number"==typeof n.walletIndex)return ze(e,t,n.walletIndex,r,a);let i=n&&"createAdditional"in n&&n.createAdditional;if(r&&!i)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");let[o,s]=await Promise.all([Xe.initializeWalletProxy(t),Jb()]);if(!o&&te.customAuth?.enabled)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!o||!s||te.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return De();if(!r)return a&&await Xe.recoverPrimaryWallet(),await o.create({accessToken:s,solanaAddress:a?.address}),Ve(0,"ethereum");{let t=((e=>ja(e).reduce(((e,t)=>!e||e.walletIndex<t.walletIndex?t:e),null))(e)?.walletIndex??0)+1,{entropyId:n,entropyIdVerifier:r}=Qa(e);return await Xe.recoverPrimaryWallet(),await o.addWallet({accessToken:s,entropyId:n,entropyIdVerifier:r,chainType:"ethereum",hdWalletIndex:t}),Ve(t,"ethereum")}},Fe=async(e,t,n)=>{let r=$a(e),a=Ha(e),i=n&&"createAdditional"in n&&n.createAdditional,o=n&&"walletIndex"in n?n.walletIndex:void 0,s=((e=>Va(e).reduce(((e,t)=>!e||e.walletIndex<t.walletIndex?t:e),null))(e)?.walletIndex??-1)+1;if(a&&!i&&"number"!=typeof o)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");if("number"==typeof o&&o<0)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${o}) is invalid.`);let[l,c]=await Promise.all([Xe.initializeWalletProxy(t),Jb()]);if(!l||!c)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return await Be({user:e,wp:l,accessToken:c,walletIndex:o??s,ethereumWallet:r})},De=async()=>new Promise(((e,t)=>{ae({createWallet:{onSuccess:t=>{Ns(fe,"createWallet","onSuccess",{wallet:t}),e(t)},onFailure:e=>{Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),t(e)},callAuthOnSuccessOnClose:!1}}),Te(Dd)})),ze=async(e,t,n,r,a)=>{if(n<0)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${n}) is invalid.`);let[i,o]=await Promise.all([Xe.initializeWalletProxy(t),Jb()]);if(!i&&te.customAuth?.enabled)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!i||!o||te.embeddedWallets?.requireUserOwnedRecoveryOnCreate){if(0==n)return De();throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Create wallet UI can only be displayed when walletIndex is 0.")}if(0===n){if(r)return r;await i.create({accessToken:o,solanaAddress:a?.address})}else{if(!r)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_CREATE_ERROR),Error("A user must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let t=ja(e).find((e=>e.walletIndex===n));if(t)return t;let{entropyId:a,entropyIdVerifier:s}=Qa(e);await Xe.recoverPrimaryWallet(),await i.addWallet({accessToken:o,entropyId:a,entropyIdVerifier:s,chainType:"ethereum",hdWalletIndex:n})}return Ve(n,"ethereum")},Be=async({user:e,wp:t,accessToken:n,walletIndex:r,ethereumWallet:a})=>{let i=Va(e).find((e=>e.walletIndex===r));if(i)return i;if(0===r)a&&await Xe.recoverPrimaryWallet(),await t.createSolana({accessToken:n,ethereumAddress:a?.address});else{if(!Ga(e))throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_CREATE_ERROR),Error("User must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let{entropyId:a,entropyIdVerifier:i}=Qa(e);await Xe.recoverPrimaryWallet(),await t.addWallet({accessToken:n,entropyId:a,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:r})}return Ve(r,"solana")},Ve=async(e,t)=>{let n=await Xe.refreshSessionAndUser(),r=("ethereum"===t?ja(n):Va(n)).find((t=>t.walletIndex===e));if(!r)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");return Ns(fe,"createWallet","onSuccess",{wallet:r}),r},He=({transaction:e,uiOptions:t,fundWalletConfig:r,address:a,signOnly:i})=>new Promise((async(o,s)=>{let{requesterAppId:l}=t||{},c=i?"signTransaction":"sendTransaction";if(!g||!f)return Ns(fe,c,"onError",U.MUST_BE_AUTHENTICATED),void s(Error("User must be authenticated before signing with a Privy wallet"));let d=a?Za(f,a):$a(f);if(!d)return Ns(fe,c,"onError",U.EMBEDDED_WALLET_NOT_FOUND),void s(new k("User must have an embedded wallet to send a transaction."));let p=d.address,h=d.walletIndex??0,{entropyId:u,entropyIdVerifier:m}=Qa(f,d),y=Qe.wallets.find((e=>"privy"===e.walletClientType&&v(e.address)===v(p)));if(!y)return Ns(fe,c,"onError",U.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have a Privy wallet before signing"));let w=await y.getEthereumProvider(),b=await w.request({method:"eth_chainId"}),C=e.chainId?Number(e.chainId):zg(b);(e=>{if(!te.chains.map((e=>e.id)).includes(e))throw new S(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,U.UNSUPPORTED_CHAIN_ID)})(C);let x={...e,from:e.from??p,chainId:C},T=await Jb();if(!T||!Q)return Ns(fe,c,"onError",U.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have valid access token and Privy wallet to send transaction"));let A=sr(x.chainId,te.chains,te.rpcConfig,{appId:n.appId});if(xe({showWalletUIs:t?.showWalletUIs}))(async()=>{try{if(!await Xe.recoverPrimaryWallet())return Ns(fe,c,"onError",U.UNKNOWN_CONNECT_WALLET_ERROR),void s(Error("Unable to connect to wallet"));let e=await og(x,A,x.from),t=i?await Fg({accessToken:T,entropyId:u,entropyIdVerifier:m,transactingWalletIndex:h,walletProxy:Q,transactionRequest:x,requesterAppId:l}):await Rg({accessToken:T,entropyId:u,entropyIdVerifier:m,transactingWalletIndex:h,walletProxy:Q,transactionRequest:e,publicClient:A,requesterAppId:l});i?Ns(fe,"signTransaction","onSuccess",{signature:t}):Ns(fe,"sendTransaction","onSuccess",{hash:t}),o({hash:t})}catch(e){Ns(fe,c,"onError",U.TRANSACTION_FAILURE),s(e)}})();else{let e={connectingWalletAddress:p,recoveryMethod:d.recoveryMethod,entropyId:u,entropyIdVerifier:m,onCompleteNavigateTo:Kv,onFailure:e=>{Ns(fe,c,"onError",U.UNKNOWN_CONNECT_WALLET_ERROR),s(e)}},n=vy(te)?lw({address:p,appConfig:te,fundWalletConfig:r,methodScreen:nw,chainIdOverride:x.chainId,comingFromSendTransactionScreen:!0}):void 0;ae({connectWallet:e,sendTransaction:{transactionRequest:x,transactingWalletIndex:h,transactingWalletAddress:p,entropyId:u,entropyIdVerifier:m,signOnly:i,onConfirm:i?async()=>await Fg({accessToken:T,entropyId:u,entropyIdVerifier:m,transactingWalletIndex:h,walletProxy:Q,transactionRequest:x,requesterAppId:l}):void 0,onSuccess:e=>{i?Ns(fe,"signTransaction","onSuccess",{signature:e.hash}):Ns(fe,"sendTransaction","onSuccess",{hash:e.hash}),o(e)},onFailure:e=>{Ns(fe,c,"onError",U.TRANSACTION_FAILURE),s(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:l},funding:n}),Te(fw)}}));function qe(){return new Promise((async(e,t)=>{let n=await Jb();if(!n||!Q)throw Error("Must have valid access token to enroll in MFA");try{await Q.verifyMfa({accessToken:n}),e()}catch(e){t(e)}}))}let Ke=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],Ze=e=>{let t=f?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:n,loginMethod:r}=Tl(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw Ns(fe,"linkAccount","onError",U.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:r}),new k(`User already has an account of type ${n} linked.`)};async function Ge({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){P(null);let n=t?"setWalletPassword":"setWalletRecovery";if(!g||!f)throw Ns(fe,n,"onError",U.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let r=Ga(f);if(!r||!Q)throw Ns(fe,n,"onError",U.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");try{await qe()}catch(e){throw Ns(fe,n,"onError",U.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,i)=>{let o={onSuccess:e=>{Ns(fe,n,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{Ns(fe,n,"onError",U.USER_EXITED_SET_PASSWORD_FLOW),i(e)},callAuthOnSuccessOnClose:!1},s="user-passcode"===r.recoveryMethod,l=Ud({walletAction:"update",availableRecoveryMethods:te.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:s,showAutomaticRecovery:e}),{entropyId:c,entropyIdVerifier:d}=Qa(f),p={recoveryMethod:r.recoveryMethod,connectingWalletAddress:r.address,onCompleteNavigateTo:l,shouldForceMFA:!1,entropyId:c,entropyIdVerifier:d,onFailure:e=>{Ns(fe,n,"onError",U.UNKNOWN_CONNECT_WALLET_ERROR),i(e)}};ae({setWalletPassword:o,recoverWallet:{entropyId:c,entropyIdVerifier:d,onFailure:i},createWallet:o,connectWallet:p,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:s}}),Te(fw)}))}async function Ye({appId:e,action:t}){let n=await Jb();if("link"===t&&!n)throw Ns(fe,"linkAccount","onError",U.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new k("User must be authenticated before linking an account.");if("login"===t&&n)throw Ns(fe,"login","onError",U.UNKNOWN_AUTH_ERROR),new k("Attempted to log in, but user is already logged in. Use a `link` helper instead.");be.current=`privy:${e}`,Ce.current=t;let r=Hg();return a.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,i)=>{let{name:o,logoUrl:s}=await Vg({api:a.api,providerAppId:e,requesterAppId:te.id});ae({crossAppAuth:{appId:e,name:o,logoUrl:s,action:t,popup:r,onSuccess:n,onError:i}}),Te(eb)}))}let Je={ready:u,authenticated:g,user:f,walletConnectors:a.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),ae({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),Te(g?Xv:bu)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),We("siwe"),be.current="siwe",Ce.current="link",ae({...re,externalConnectWallet:{...re.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),Te(gb)},startCrossAppAuthFlow:Ye,linkEmail:()=>{We("email"),Ze("email"),be.current="email",Ce.current="link",Te(ub)},linkPhone:()=>{We("sms"),Ze("phone"),be.current="sms",Ce.current="link",Te(mb)},linkGoogle:async()=>{We("google"),Ze("google_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("google")},linkTwitter:async()=>{We("twitter"),Ze("twitter_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("twitter")},linkDiscord:async()=>{We("discord"),Ze("discord_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("discord")},linkGithub:async()=>{We("github"),Ze("github_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("github")},linkSpotify:async()=>{We("spotify"),Ze("spotify_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("spotify")},linkInstagram:async()=>{We("instagram"),Ze("instagram_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("instagram")},linkTiktok:async()=>{We("tiktok"),Ze("tiktok_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{We("linkedin"),Ze("linkedin_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("linkedin")},linkApple:async()=>{We("apple"),Ze("apple_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("apple")},linkPasskey:async()=>{We("passkey"),Ze("passkey"),await Xe.initLinkWithPasskey(),Te(lf)},linkTelegram:async e=>{if(We("telegram"),Ze("telegram"),Ce.current="link",be.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new Oa;a.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=La(e.launchParams.initDataRaw),ae({telegramAuthModalData:{seamlessAuth:!0}}),Te(sh)}else Ns(fe,"linkAccount","onError",U.INVALID_DATA,{linkMethod:"telegram"});else await Xe.initLoginWithTelegram();Te(sh)},linkFarcaster:async()=>{We("farcaster"),Ze("farcaster"),await Xe.initLoginWithFarcaster(),Ce.current="link",be.current="farcaster",Te(Fp)},updateEmail:()=>{if(We("email"),!f?.email)throw new k("User does not have an email linked to their account.");Ce.current="update",be.current="email",Te(Bb)},updatePhone:()=>{if(We("sms"),!f?.phone)throw new k("User does not have a phone number linked to their account.");Ce.current="update",be.current="sms",Te($b)},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!u){let e=await new Promise((e=>{oe((t=>e.bind(t)))}));if(oe(null),e)return void console.warn(t)}!f||f.isGuest?(Ce.current="login",ae({login:e}),Te(Hh)):console.warn(t)},connectOrCreateWallet:async()=>{u||(await new Promise((e=>{oe((()=>e))})),oe(null)),g?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(Ce.current="connect-or-create",Te(vh))},logout:async()=>{if(Ce.current=null,be.current=null,f&&a.clearProviderAcccessTokens(f),P(null),await a.logout(),f&&Q)try{await Q.clearMfa({userId:f.id})}catch(e){}b(null),y(!1),Ns(fe,"logout","onSuccess"),h(!1),rr.del($r),rr.del(jr(te.id))},getAccessToken:p((()=>a.getCustomerAccessToken()),[a]),unlinkWallet:async e=>{let t;return b(t=e.startsWith("0x")?await a.unlinkEthereumWallet(e):await a.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await a.unlinkEmail(e);return b(t),t},unlinkPhone:async e=>{let t=await a.unlinkPhone(e);return b(t),t},unlinkGoogle:async e=>{let t=await a.unlinkOAuth("google",e);return b(t),t},unlinkTwitter:async e=>{let t=await a.unlinkOAuth("twitter",e);return b(t),t},unlinkDiscord:async e=>{let t=await a.unlinkOAuth("discord",e);return b(t),t},unlinkGithub:async e=>{let t=await a.unlinkOAuth("github",e);return b(t),t},unlinkSpotify:async e=>{let t=await a.unlinkOAuth("spotify",e);return b(t),t},unlinkInstagram:async e=>{let t=await a.unlinkOAuth("instagram",e);return b(t),t},unlinkTiktok:async e=>{let t=await a.unlinkOAuth("tiktok",e);return b(t),t},unlinkLinkedIn:async e=>{let t=await a.unlinkOAuth("linkedin",e);return b(t),t},unlinkApple:async e=>{let t=await a.unlinkOAuth("apple",e);return b(t),t},unlinkFarcaster:async e=>{let t=await a.unlinkFarcaster(e);return b(t),t},unlinkTelegram:async e=>{let t=await a.unlinkTelegram(e);return b(t),t},unlinkPasskey:async e=>{let t=await Jb();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!Q)throw Error("Wallet proxy not initialized.");let n=te.passkeys.shouldUnenrollMfaOnUnlink;await Q.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:n});let r=await a.getAuthenticatedUser();return b(r),r},unlinkCrossAppAccount:async({subject:e})=>{let t=f?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new k("Invalid subject");a.storeProviderAccessToken(t.id,null);let n=await a.unlinkOAuth(`privy:${t.id}`,e);return b(n),n},createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let t=await Xe.refreshSessionAndUser();if(!t)throw Ns(fe,"createWallet","onError",U.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return Re(t,15e3,e)},setWalletRecovery:async e=>Ge({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>Ge({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=e.message;if(!g||!f)return Ns(fe,"signMessage","onError",U.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let s=t?.address?Za(f,t.address):$a(f);if(!s)throw new k("User must have an embedded wallet to send a transaction.");let l=s.address,c=s.walletIndex??0,{entropyId:d,entropyIdVerifier:p}=Qa(f,s);if("string"!=typeof o||o.length<1)return Ns(fe,"signMessage","onError",U.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));let h=async()=>{if(!g)throw Error("User must be authenticated before signing with a Privy wallet");let e=await Jb();if(!Q||!e||!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:l,requesterAppId:i}});let{response:t}=await Q.rpc({accessToken:e,entropyId:d,entropyIdVerifier:p,chainType:"ethereum",hdWalletIndex:c,requesterAppId:i,request:{method:"personal_sign",params:[o,l]}}),n=t.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:l,requesterAppId:i}}),n};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await h();Ns(fe,"signMessage","onSuccess",{signature:e}),n({signature:e})}catch(e){Ns(fe,"signMessage","onError",U.UNABLE_TO_SIGN),r(e??new ki("Unable to sign message"))}else ae({signMessage:{method:"personal_sign",data:o,confirmAndSign:h,onSuccess:e=>{Ns(fe,"signMessage","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{Ns(fe,"signMessage","onError",U.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:s.recoveryMethod,connectingWalletAddress:l,entropyId:d,entropyIdVerifier:p,onCompleteNavigateTo:fv,onFailure:e=>{Ns(fe,"signMessage","onError",U.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Te(fw)})),signTypedData:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{};if(!g||!f)return Ns(fe,"signTypedData","onError",U.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let o=t?.address?Za(f,t.address):$a(f);if(!o)throw new k("User must have an embedded wallet to send a transaction.");let s=o.address,l=o.walletIndex??0,{entropyId:c,entropyIdVerifier:d}=Qa(f,o),p=br(e),h=async()=>{if(!g)throw Error("User must be authenticated before signing with a Privy wallet");let e=await Jb();if(!Q||!e||!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:s,requesterAppId:i}});let{response:t}=await Q.rpc({accessToken:e,entropyId:c,entropyIdVerifier:d,chainType:"ethereum",hdWalletIndex:l,requesterAppId:i,request:{method:"eth_signTypedData_v4",params:[s,p]}}),n=t.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:s,requesterAppId:i}}),n};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await h();Ns(fe,"signTypedData","onSuccess",{signature:e}),n({signature:e})}catch(e){Ns(fe,"signTypedData","onError",U.UNABLE_TO_SIGN),r(e??new ki("Unable to sign message"))}else ae({signMessage:{method:"eth_signTypedData_v4",data:p,confirmAndSign:h,onSuccess:e=>{Ns(fe,"signTypedData","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{Ns(fe,"signTypedData","onError",U.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:c,entropyIdVerifier:d,onCompleteNavigateTo:fv,onFailure:e=>{Ns(fe,"signMessage","onError",U.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Te(fw)})),sendTransaction:async(e,t)=>await He({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await He({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!g||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let i=e?.address?Za(f,e.address):$a(f),o=Ga(f);if(!i||!o)return void r(new k("User must have an embedded wallet to send a transaction."));let s=i.address,{entropyId:l,entropyIdVerifier:c}=Qa(f,i);if(!s)return void r(Error("User does not have an HD Ethereum wallet. To export an imported wallet, pass the `address` of the wallet to `exportWallet`."));if(!C(s))return void r(Error("Must provide a valid Ethereum address."));let d={recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:uw,onFailure:r,shouldForceMFA:!0};ae(re),await Jb()&&Q?Q?(ae({keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:i,primaryWallet:o,onSuccess:t,onFailure:r},connectWallet:d}),Te(fw)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:qe,async init(e){switch(e){case"sms":return void await a.initMfaSmsVerification();case"passkey":return await a.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new k("Invalid MFA code");ge.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{ye.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new k("Invalid authenticator response");let n=await import("@simplewebauthn/browser"),r=(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}))(await n.startAuthentication(t));ge.current?.resolve({mfaMethod:e,mfaCode:r,relyingParty:window.origin}),await new Promise(((e,t)=>{ye.current={resolve:e,reject:t}}));break;default:throw ge.current?.reject(new k("Unsupported MFA method")),new k(`Unsupported MFA method: ${e}`)}},cancel(){ge.current?.reject(new k("MFA canceled"))},async initEnrollmentWithSms(e){let t=await Jb();if(!t||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,n)=>{if(!e)return Xe.closePrivyModal(),void t();te.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."),ae({mfaEnrollmentFlow:{mfaMethods:te.mfa.methods,shouldUnlinkOnUnenrollMfa:te.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:n}}),Te(Ub)})),async initEnrollmentWithTotp(){let e=await Jb();if(!e||!Q)throw Error("Must have valid access token to enroll in MFA");let t=await Q.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await Jb();if(!t||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),b(await a.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await Jb();if(!t||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),b(await a.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let n=await Jb();if(!n||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:e,removeForLogin:t.removeForLogin}),b(await a.getAuthenticatedUser())},async unenroll(e,t={}){let n=await Jb();if(!n||!Q)throw Error("Must have valid access token to remove MFA");"passkey"===e?await Q.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:[],removeForLogin:t.removeForLogin}):await Q.unenrollMfa({method:e,accessToken:n}),b(await a.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await Jb(),t=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");let n=await Q.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===n.status&&b(await a.getAuthenticatedUser()||f||null),ae({farcasterSigner:n}),Te(lb)},getFarcasterSignerPublicKey:async()=>{let e,t=await Jb(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=f.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await Jb(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let r=await import("@simplewebauthn/browser"),a=await Q.signFarcasterMessage({address:n.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:r.bufferToBase64URLString(e)},fid:BigInt(f.farcaster.fid),relyingParty:window.origin});return new Uint8Array(r.base64URLStringToBuffer(a.signature))},signMessageWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Kg({user:f,client:a,address:t,requesterAppId:te.id,request:{method:r?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:n},reconnect:Ye})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),i=br(e);return Kg({user:f,client:a,address:t,requesterAppId:te.id,request:{method:r?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,i],chainId:n},reconnect:Ye})},sendTransactionWithCrossAppWallet(e,{address:t}){let n=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Kg({user:f,client:a,address:t,requesterAppId:te.id,request:{method:n?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:Ye})},isModalOpen:c,mfaMethods:te.mfa.methods};Vb=Je.signMessage,Hb=Je.signTypedData,Kb=async(e,t)=>await He({transaction:e,...t,signOnly:!1}),qb=async(e,t)=>({signature:(await He({transaction:e,...t,signOnly:!0})).hash});let Xe={setAuthenticated:y,setUser:b,setIsNewUser:N,isNewUserThisSession:E,pendingTransaction:null,walletConnectionStatus:L,connectors:a.connectors?.walletConnectors??[],solanaWallets:I,rpcConfig:te.rpcConfig,chains:te.chains,appId:n.appId,showFiatPrices:"native-token"!==te.embeddedWallets.priceDisplay.primary,clientAnalyticsId:a.clientAnalyticsId,customAuthStatus:ue,hideWalletUIs:ke,isHeadlessSigning:p(xe,[te.embeddedWallets.showWalletUIs]),emailOtpState:B,setEmailOtpState:$,smsOtpState:j,setSmsOtpState:V,oAuthState:K,setOAuthState:Y,telegramAuthState:J,setTelegramAuthState:X,siweState:H,setSiweState:q,isHeadlessOAuthLoading:W,nativeTokenSymbolForChainId:e=>te.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(Q)return Q;let t=new Promise((e=>{le((()=>t=>e(t)))})),n=new Promise((t=>setTimeout((()=>t(null)),e))),r=await Promise.race([t,n]);return le(null),r},getAuthFlow:()=>a.authFlow,getAuthMeta:()=>a.authFlow?.meta,client:a,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=u&&g&&f;r&&be.current&&(t=Ke(f)),"login"===Ce.current?e.shouldCallAuthOnSuccess&&r&&be.current?Ns(fe,"login","onComplete",{user:f,isNewUser:E,wasAlreadyAuthenticated:!1,loginMethod:be.current,loginAccount:t??null}):Ns(fe,"login","onError",U.USER_EXITED_AUTH_FLOW):"link"===Ce.current&&t?e.isSuccess&&r&&be.current?Ns(fe,"linkAccount","onSuccess",{user:f,linkMethod:be.current,linkedAccount:t}):be.current&&Ns(fe,"linkAccount","onError",U.USER_EXITED_LINK_FLOW,{linkMethod:be.current}):"update"===Ce.current&&t?e.isSuccess&&r&&be.current?Ns(fe,"update","onSuccess",{user:f,updateMethod:be.current,updatedAccount:t}):be.current&&Ns(fe,"update","onError",U.USER_EXITED_UPDATE_FLOW,{linkMethod:be.current}):"connect-or-create"===Ce.current&&(x[0]?Ns(fe,"connectOrCreateWallet","onSuccess",{wallet:x[0]}):Ns(fe,"connectOrCreateWallet","onError",U.USER_EXITED_AUTH_FLOW));let i=M&&Yv.has(M),o=M===Yl&&re.errorModalData&&Yv.has(re.errorModalData.previousScreen);if((i||o)&&re.funding){let e,t=Yv.get(M)??null;if("solana"===re.funding.chainType){let n=l(py);if(n)try{e=BigInt(await n.getBalance({address:re.funding.address,cluster:re.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");Ns(fe,"fundSolanaWallet","onUserExited",{address:re.funding.address,cluster:re.funding.cluster,fundingMethod:t,balance:e})}else{let r=sr(re.funding.chain.id,te.chains,te.rpcConfig,{appId:n.appId});try{e=await r.getBalance({address:re.funding.address})}catch{console.error("Unable to pull wallet balance")}Ns(fe,"fundWallet","onUserExited",{address:re.funding.address,chain:re.funding.chain,fundingMethod:t,balance:e})}}ae({...re,externalConnectWallet:{suggestedAddress:void 0}}),Ce.current=null,be.current=null,N(!1),h(!1),setTimeout((()=>{a.authFlow=void 0}),200)},openPrivyModal:Te,connectWallet:Se,initLoginWithWallet:async(e,t,n)=>{Ti(e)?(be.current="siwe",Ne(e,t,n)):(be.current="siws",Me(e,t,n))},loginWithWallet:async()=>{let e,t,n;if(!u)throw new $e;if(a.authFlow instanceof Ia?e="siwe":a.authFlow instanceof _a&&(e="siws"),!e)throw new k("Must initialize SIWE/SIWS flow first.");if(null!==await a.getAccessToken())try{({user:t}=await a.link()),be.current=e}catch(t){throw Ns(fe,"linkAccount","onError",t.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:n}=await a.authenticate()),be.current=e}catch(e){throw Ns(fe,"login","onError",e.privyErrorCode||U.GENERIC_CONNECT_WALLET_ERROR),e}b(t||f||null),N(n||!1),y(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:n})=>new Promise((async(r,a)=>{let i=await Jb();if(!g||!f||!i)throw new k("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new k("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=Xe.walletProxy??await Xe.initializeWalletProxy(15e3);if(!o)throw new k("Wallet proxy not initialized.");if((({address:e,chainType:t,user:n})=>!!Lg(n).find((n=>n.address===e&&n.chainType===t)))({address:e,chainType:t,user:f}))return r();let s=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new k("Address to delegate is not associated with current user.");return{address:n.address,chainType:n.chainType,walletIndex:n.walletIndex??0}})({address:e,user:f}),l=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new k("Address to delegate is not associated with current user.");let r=n.imported?n:Ga(t);if(!r)throw new k("Unable to determine root address for delegated address.");return{address:r.address,chainType:r.chainType,imported:r.imported}})({address:e,user:f}),c=async()=>{await o.createDelegatedAction({accessToken:i,rootWallet:l,delegatedWallets:[s]}),await Xe.refreshSessionAndUser()};if(await Xe.recoverPrimaryWallet(),n)ae({delegatedActions:{consent:{address:e,onDelegate:c,onSuccess:async()=>{r()},onError:async e=>{a(e)}}}}),Te(nb);else try{await c(),r()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,n)=>{if(!g||!f)throw new k("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");if(0===Lg(f).length)throw new k("User has no delegated wallets to revoke.");let r=async()=>{await a.revokeDelegatedWallet(),await Xe.refreshSessionAndUser()};if(e)ae({delegatedActions:{revoke:{onRevoke:r,onSuccess:async()=>{t()},onError:async e=>{n(e)}}}}),Te(ib);else try{await r(),t()}catch(e){n(e)}})),initLoginWithFarcaster:async(e,t)=>{let n=new Sr(e,t);a.startAuthFlow(n);try{be.current="farcaster",await n.initializeFarcasterConnect()}catch(e){throw"login"===Ce.current?Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR):"link"===Ce.current&&Ns(fe,"linkAccount","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!u)throw new $e;if(!(a.authFlow instanceof Sr))throw new k("Must initialize Farcaster flow first.");if(null!==await a.getAccessToken())try{({user:e}=await a.link()),be.current="farcaster"}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await a.authenticate()),be.current="farcaster"}catch(e){throw Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}b(e||null),N(t||!1),y(!0)},async crossAppAuthFlow({appId:e,popup:t,action:n}){let r=`privy:${e}`;be.current=r;let{url:i,stateCode:o,codeVerifier:s}=await async function({api:e,appId:t}){let n=ia(),r=oa(),a=await sa(n);try{let{url:i}=await e.post(R,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:r});return{url:i,stateCode:r,codeVerifier:n}}catch(e){throw T(e)}}({api:a.api,appId:e});if(!i)throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new k("No authorization URL returned for cross-app auth.");try{let l=await async function({url:e,popup:t}){return t.location=e,new Promise(((e,n)=>{let r,a=setTimeout((()=>{n(new k("Authorization request timed out after 2 minutes.")),i()}),12e4);function i(){t?.close(),window.removeEventListener("message",s)}let o=setInterval((()=>{t?.closed&&!r&&(i(),clearInterval(o),clearTimeout(a),n(new k("User rejected request")))}),300);function s(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(a),e(t.data),i()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(a),n(new k(t.data.error)),i()),t.data.type===$g&&((r=new BroadcastChannel(Bg)).onmessage=s))}window.addEventListener("message",s)}))}({url:i,popup:t,provider:r}),c=l.stateCode,d=l.authorizationCode;if(c!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:r,storedStateCode:o??"",returnedStateCode:c??""}}),new k("Unexpected auth flow. This may be a phishing attempt.",void 0,U.OAUTH_UNEXPECTED);let p=await async function({appId:e,stateCode:t,codeVerifier:n,authorizationCode:r,action:a,client:i}){if(!r||!t)throw new k("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===r)throw new k("User denied confirmation during cross-app auth flow");try{let o=new jg({authorizationCode:r,stateCode:t,codeVerifier:n,provider:`privy:${e}`});i.startAuthFlow(o);let s="link"===a?await i.link():await i.authenticate(),l=s.oAuthTokens?.accessToken;return console.debug(),l}catch(e){let t=T(e);if(t.privyErrorCode)throw new k(t.message||"Invalid code during cross-app auth flow.",void 0,t.privyErrorCode);if("User denied confirmation during cross-app auth flow"===t.message)throw new k("Invalid code during cross-app auth flow.",void 0,U.OAUTH_USER_DENIED);throw new k("Invalid code during cross-app auth flow.",void 0,U.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:s,stateCode:c,authorizationCode:d,action:n,client:a});p&&a.storeProviderAccessToken(e,p);let h=await Xe.refreshSessionAndUser();if(!h)throw new k("Unable to update user");return a.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),h}catch(e){throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:r}}),e}},async initLoginWithOAuth(e,t,n){if(be.current=e,!nr())return void Te(pb);if("google"===e&&As(window.navigator.userAgent))return void Te(pb);"twitter"===e&&window.opener&&window.opener.postMessage({type:$g},"*"),rr.del(Kr),rr.del(Zr);let r=new la({provider:e,disableSignup:!!n,withPrivyUi:!0});t&&r.addCaptchaToken(t),a.startAuthFlow(r);let i=await a.authFlow.getAuthorizationUrl();i&&i.url&&("twitter"===e&&w&&(i.url=i.url.replace("x.com","twitter.com")),window.location.assign(i.url))},async initLoginWithTelegram(e,t){if(!u)throw new $e;be.current="telegram";let n=new Oa(e,t);a.startAuthFlow(n),X({status:"loading"}),n.meta.telegramWebAppData=void 0,n.meta.telegramAuthResult=await new Promise(((e,t)=>te.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:te.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(n=>n?e(n):t(new k("Telegram auth failed or was canceled by the client")))):t(new k("Telegram was not initialized")):t(new k("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,n;if(!(a.authFlow instanceof Oa))throw new k("Must initialize Telegram flow before calling loginWithTelegram");a.authFlow.meta.captchaToken||=e?.captchaToken;let r=await Jb(),i=e?.intent||Ce.current;if("login"===i)try{let e=await a.authenticate();t=e.user,n=e.isNewUser,be.current="telegram"}catch(e){throw Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}else{if("link"!==i)throw new k("Unknown auth intent");try{t=(await a.link()).user,be.current="telegram"}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}b(t),N(n||!1),y(!0),X({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:o}},async recoveryOAuthFlow(e,t,n){let r,i;function o(t){if(!t)throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:e}}),new k("Recovery OAuth failed")}switch(e){case"google-drive":{let t,s,{url:l,codeVerifier:c,stateCode:d}=await Rd({api:jb.api,provider:e});o(l);try{let r=await Jv({url:l,popup:n,provider:e});if(t=r.stateCode,s=r.authorizationCode,t!==d)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:d??"",returnedStateCode:t??""}}),new k("Unexpected auth flow. This may be a phishing attempt.",void 0,U.OAUTH_UNEXPECTED)}catch(t){throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:e}}),new k("Recovery OAuth failed")}[r,i]=await Promise.all([Jb(),Fd({api:jb.api,provider:e,codeVerifier:c,stateCode:t,authorizationCode:s})]);break}case"icloud":{let{url:t}=await Rd({api:jb.api,provider:e});o(t);let{ckWebAuthToken:a}=await Jv({url:t,popup:n,provider:e});i=a,r=await Jb()}}if(!Q)throw new k("Cannot connect to wallet proxy");if(!r)throw new k("Unable to authorize user");switch(t){case"recover":{let t=re.recoverWallet?.entropyId,n=re.recoverWallet?.entropyIdVerifier;if(!t||!n)throw new k("Recovery OAuth failed");a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t,recoveryMethod:e}}),await Q.recover({accessToken:r,entropyId:t,entropyIdVerifier:n,recoveryAccessToken:i}),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t,recoveryMethod:e}});break}case"create-wallet":{a.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await Q.create({accessToken:r,recoveryAccessToken:i,recoveryMethod:e});let t=$a(await Xe.refreshSessionAndUser());if(!t)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.address}}),Ns(fe,"createWallet","onSuccess",{wallet:t});break}case"set-recovery":{let t=Ga(f);if(!t)throw Ns(fe,"setWalletRecovery","onError",U.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}});let{entropyId:n,entropyIdVerifier:o}=Qa(f);await Q.setRecovery({accessToken:r,entropyId:n,entropyIdVerifier:o,recoveryMethod:e,recoveryAccessToken:i});let s=Ga(await Xe.refreshSessionAndUser());if(!s)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}}),Ns(fe,"setWalletRecovery","onSuccess",{method:e,wallet:s});break}default:throw new k("Unsupported recovery action")}},async loginWithOAuth(e){let t,n,r;if(!(a.authFlow instanceof la))throw new k("Must initialize OAuth flow before calling loginWithOAuth");let i=rr.get(Hr),o=a.authFlow.meta.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:i??"",returnedStateCode:o??""}}),new k("Unexpected auth flow. This may be a phishing attempt.",void 0,U.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{let n=await a.link();t=n.user,r=n.oAuthTokens,be.current=e}catch(t){throw Ns(fe,"linkAccount","onError",t.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let i=await a.authenticate();t=i.user,n=i.isNewUser,r=i.oAuthTokens,be.current=e}catch(t){throw"login"===Ce.current?Ns(fe,"login","onError",t.privyErrorCode||U.UNKNOWN_AUTH_ERROR):"link"===Ce.current&&Ns(fe,"linkAccount","onError",t.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return b(t),N(n||!1),y(!0),r&&t&&Ns(fe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),r},passkeyAuthState:D,setPasskeyAuthState:z,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new Ta({captchaToken:e,setPasskeyAuthState:z});a.startAuthFlow(n),Ce.current="login";try{be.current="passkey",z({status:"generating-challenge"}),await n.initRegisterFlow(t),z({status:"awaiting-passkey"})}catch(e){throw z({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!u)throw new $e;if(!(a.authFlow instanceof Ta))throw new k("Must initialize Passkey flow first.");if("passkey"!==be.current){let e=new k("Must init login with Passkey flow first.");throw z({status:"error",error:e}),e}let n=await Jb();try{be.current="passkey",z({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await a.authenticate())}catch(e){throw z({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}b(e),N(t||!1),y(!0),z({status:"done"});let r=e?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:e,isNewUser:t||!1,wasAlreadyAuthenticated:!!n,loginAccount:r}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new Ta({captchaToken:e,setPasskeyAuthState:z});a.startAuthFlow(n),Ce.current="login";try{be.current="passkey",z({status:"generating-challenge"}),await n.initAuthenticationFlow(t),z({status:"awaiting-passkey"})}catch(e){throw z({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,n;if(!u)throw new $e;if(!(a.authFlow instanceof Ta))throw new k("Must initialize Passkey flow first.");if(e?.credentialIds&&(a.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==be.current){let e=new k("Must init login with Passkey flow first.");throw z({status:"error",error:e}),e}let r=await Jb();try{be.current="passkey",z({status:"awaiting-passkey"}),({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw z({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}b(t),N(n||!1),y(!0),z({status:"done"});let i=t?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:i}},async initLinkWithPasskey(e){let t=new Ta({captchaToken:e});a.startAuthFlow(t),Ce.current="link",be.current="passkey",z({status:"generating-challenge"});try{await t.initLinkFlow(),z({status:"awaiting-passkey"})}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),z({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!u)throw new $e;if(!(a.authFlow instanceof Ta))throw new k("Must initialize Passkey flow first.");if("passkey"!==be.current)throw new k("Must init login with Passkey flow first.");try{be.current="passkey",({user:e}=await a.link())}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return b(e||f||null),z({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,n){if(!nr())throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");if("google"===e&&As(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.");let r=new la({provider:e,withPrivyUi:!1,disableSignup:n??!1});t&&r.addCaptchaToken(t),Y({status:"loading"});let i=await a.startAuthFlow(r).getAuthorizationUrl();i?.url&&window.location.assign(i.url)},async loginWithHeadlessOAuth(e){let t,n,r;O(!0),Y({status:"loading"}),a.startAuthFlow(new la(e));let i=rr.get(Hr),o=e.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:i??"",returnedStateCode:o??""}}),O(!1),new k("Unexpected auth flow. This may be a phishing attempt.",void 0,U.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{({user:t,oAuthTokens:r}=await a.link()),be.current=e.provider;let n=Ke(t);t&&n&&Ns(fe,"linkAccount","onSuccess",{user:t,linkMethod:be.current,linkedAccount:n})}catch(t){throw O(!1),Ns(fe,"linkAccount","onError",t.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:n,oAuthTokens:r}=await a.authenticate()),be.current=e.provider;let i=Ke(t);t&&i&&void 0!==n&&Ns(fe,"login","onComplete",{user:t,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:be.current,loginAccount:i})}catch(e){throw O(!1),Y({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}return b(t),N(n||!1),y(!0),O(!1),Y({status:"done"}),r&&t&&Ns(fe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{let i=new Qn({email:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{be.current="email",$({status:"sending-code"}),await i.sendCodeEmail({withPrivyUi:r}),$({status:"awaiting-code-input"})}catch(e){throw $({status:"error",error:e}),"login"===Ce.current?Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR):"link"===Ce.current&&Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,n)=>{let r=new er(e,t,n);a.startAuthFlow(r);try{await r.sendCodeEmail({withPrivyUi:!0})}catch(e){Ns(fe,"update","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR,{linkMethod:be.current})}},initUpdatePhone:async(e,t,n)=>{let r=new Sa(e,t,n);a.startAuthFlow(r);try{await r.sendSmsCode({withPrivyUi:!0})}catch(e){Ns(fe,"update","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR,{linkMethod:be.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{V({status:"sending-code"});let i=new Ea({phoneNumber:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{be.current="sms",await i.sendSmsCode({withPrivyUi:r}),V({status:"awaiting-code-input"})}catch(e){throw V({status:"error",error:e}),"login"===Ce.current?Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR):"link"===Ce.current&&Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await(a.authFlow?.sendCodeEmail({withPrivyUi:!0}))},resendSmsCode:async()=>{await(a.authFlow?.sendSmsCode({withPrivyUi:!0}))},loginWithCode:async e=>{let t,n;function r(e){a.authFlow instanceof Qn?$(e):a.authFlow instanceof Ea&&V(e)}if(r({status:"submitting-code"}),!u){let e=new $e;throw r({status:"error",error:e}),e}if(a.authFlow instanceof Qn)a.authFlow.meta.emailCode=e.trim();else{if(!(a.authFlow instanceof Ea)){let e=new k("Must initialize a passwordless code flow first");throw r({status:"error",error:e}),e}a.authFlow.meta.smsCode=e.trim()}let i=await Jb();if("link"===Ce.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:be.current}),e}else if("update"===Ce.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),Ns(fe,"update","onError",e.privyErrorCode||U.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:be.current}),e}else try{({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw r({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}let o=t||f;b(o||null),N(n||!1),y(!0),r({status:"done"});let s=null;return a.authFlow instanceof Qn?s=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:a.authFlow instanceof Ea&&(s=o?.linkedAccounts.find((({type:e})=>"phone"===e))||null),{user:o,isNewUser:n||!1,wasAlreadyAuthenticated:!!i,linkedAccount:s}},generateSiweMessage:async({address:e,chainId:t,captchaToken:n})=>{Ce.current="link",be.current="siwe",q({status:"generating-message"});let r=await a.generateSiweNonce({address:e,captchaToken:n});return q({status:"awaiting-signature"}),Aa({address:e,chainId:t.replace("eip155:",""),nonce:r})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let n=await a.generateSiweNonce({address:e});return Aa({address:e,chainId:t.replace("eip155:",""),nonce:n})},linkSmartWallet:async({message:e,signature:t,smartWalletType:n})=>{let r;r=await a.linkSmartWallet({message:e,signature:t,smartWalletType:n}),b((r=await Xe.refreshSessionAndUser()??r)||f||null)},linkWithSiwe:async({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i})=>{let o;We("siwe");let s=null;try{q({status:"submitting-signature"}),o=await a.linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i}),o=await Xe.refreshSessionAndUser()??o,q({status:"done"}),(s=Ke(o)||null)&&Ns(fe,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:s})}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),Ce.current=null,be.current=null,q({status:"error",error:e}),e}let l=o||f;return b(l||null),Ce.current=null,be.current=null,{user:l,linkedAccount:s}},refreshSessionAndUser:async()=>{let e=await a.getAuthenticatedUser();return y(!!e),b(e),e},walletProxy:Q,createAnalyticsEvent:({eventName:e,payload:t,timestamp:n})=>a.createAnalyticsEvent({eventName:e,payload:t,timestamp:n}),acceptTerms:async()=>{let e=await a.acceptTerms();return b(e),e},getUsdTokenPrice:e=>a.getUsdTokenPrice(e),getUsdPriceForSol:()=>a.getUsdPriceForSol(),getSplTokenMetadata:e=>a.getSplTokenMetadata(e),recoverPrimaryWallet:async e=>new Promise((async(t,n)=>{if(!f)return void t(!0);let r=Ja(e?.user??f),i=Ga(e?.user??f)||qa(e?.user??f)||Ka(e?.user??f);if(!r&&!i)return void t(!0);let o=await Jb();if(!o||!Q||!i)return void n(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:s,entropyIdVerifier:l}=Qa(f,i);try{await Q.connect({accessToken:o,entropyId:s,entropyIdVerifier:l}),t(!0)}catch(e){Ul(e)&&"privy"===i.recoveryMethod?(a.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:i.address}}),(await Q.recover({entropyId:s,entropyIdVerifier:l,accessToken:o})).entropyId||n(Error("Unable to recover wallet")),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:i.address}}),t(!0)):Ul(e)&&"privy"!==i.recoveryMethod?(ae({recoverWallet:{entropyId:s,entropyIdVerifier:l,onFailure:n,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:i.recoveryMethod,action:"recover"}}),Te(Ld(i.recoveryMethod))):n(e)}})),createEmbeddedSolanaWallet:async e=>{e&&"target"in e&&(e=void 0);let t=await Xe.refreshSessionAndUser();if(!t)throw Ns(fe,"createWallet","onError",U.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return Fe(t,15e3,e)},exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!g||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));let i=e?.address?Za(f,e.address):Ha(f),o=Ga(f);if(!i||!o)return void r(Error("Must have a Privy wallet before exporting"));let{entropyId:s,entropyIdVerifier:l}=Qa(f,i);await Jb()&&Q?Q?(ae({connectWallet:{recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,entropyId:s,entropyIdVerifier:l,onCompleteNavigateTo:uw,onFailure:r,shouldForceMFA:!0},keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:i,primaryWallet:o,onSuccess:t,onFailure:r}}),Te(fw)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),setReadyToTrue:e=>{m(!0),ie?.(e)},updateWallets:()=>Le(),fundWallet:async(e,t)=>{ae({funding:lw({address:e,appConfig:te,fundWalletConfig:t,methodScreen:nw})}),Te(nw)},openModal:Te,requestFarcasterSignerStatus:async e=>{let t=await Jb(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let r=await a.requestFarcasterSignerStatus(e);return"approved"===r.status&&b(await a.getAuthenticatedUser()||f||null),r},connectCoinbaseSmartWallet:async()=>{te.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let e=a.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||a.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Se(e);await Ee("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:i,telegramWebAppData:o,farcasterEmbeddedAddress:s,oAuthUserInfo:l})=>{let c=await a.sendAccountTransferRequest({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:i,telegramWebAppData:o,farcasterEmbeddedAddress:s,oAuthUserInfo:l});return b(c),c}};Zb=Xe.recoverPrimaryWallet,Gb=Xe.recoverPrimaryWallet;let Qe=s((()=>({wallets:x,ready:ce&&we})),[x,ce,we]),et=a.authFlow instanceof Oa,tt=!te.headless&&te.captchaEnabled&&!g&&(u||et);/*#__PURE__*/return t(ml.Provider,{value:Je,children:/*#__PURE__*/t(_s.Provider,{value:fe,children:/*#__PURE__*/t(ag.Provider,{value:Qe,children:/*#__PURE__*/t(Pa,{...te,children:/*#__PURE__*/e(je.Provider,{value:Xe,children:[/*#__PURE__*/t(Ws,{children:/*#__PURE__*/e(xu,{data:re,setModalData:ae,setInitialScreen:P,initialScreen:M,authenticated:g,open:c,children:[n.children,tt&&/*#__PURE__*/t(Hu,{delayedExecution:!1}),/*#__PURE__*/t(ug,{theme:{...te.appearance.palette||{}}}),!te.render.standalone&&/*#__PURE__*/t(xg,{open:c})]})}),/*#__PURE__*/t(Ug,{appId:n.appId,appClientId:n.clientId,clientAnalyticsId:a.clientAnalyticsId,origin:a.apiUrl,mfaMethods:f?.mfaMethods,mfaPromise:ge,mfaSubmitPromise:ye,onLoad:ee,onLoadFailed:()=>null}),te.loginConfig.telegramAuthConfiguration&&
|
|
26
|
+
return t(Uo,{client:jb,clientConfig:a,children:/*#__PURE__*/t(ly,{children:/*#__PURE__*/t(iC,{...n,client:jb})})})};let iC=n=>{let a=n.client,l=dy();Dg();let[c,h]=o(!1),[u,m]=o(!1),[g,y]=o(!1),[f,b]=o(null),[x,A]=o([]),[I,_]=o([]),[E,N]=o(!1),[M,P]=o(null),[W,O]=o(!1),[L,F]=o({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:G}),[D,z]=o({status:"initial"}),[B,$]=o({status:"initial"}),[j,V]=o({status:"initial"}),[H,q]=o({status:"initial"}),[K,Y]=o({status:"initial"}),[J,X]=o({status:"initial"}),[Q,ee]=o(null),te=Lo(),ne=Ro(),[re,ae]=o({}),[ie,oe]=o(null),[se,le]=o(null),[ce,de]=o(!1),[pe,he]=o(!1),[ue,me]=o(te.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),ge=i(null),ye=i(null),fe=i(Is),[we,ve]=o(!1);a.onStoreCustomerAccessToken=e=>{e&&Ns(fe,"accessToken","onAccessTokenGranted",{accessToken:e})},a.onDeleteCustomerAccessToken=()=>{b(null),y(!1),Ns(fe,"accessToken","onAccessTokenRemoved")};let be=i(null),Ce=i(null),ke=i(!1),xe=({showWalletUIs:e})=>ke.current?ke.current:void 0!==e?!e:!te.embeddedWallets.showWalletUIs,Te=e=>{P(e),setTimeout((()=>{h(!0)}),15)};d((()=>{if(!f)return void a.connectors?.removeEmbeddedWalletConnectors();let e=$a(f),t=ja(f),r=qa(f);e&&t.length||a.connectors?.removeEmbeddedWalletConnectors(),r||a.connectors?.removeImportedWalletConnector(),a.connectors?Q?(e&&a.connectors.addEmbeddedWalletConnectors({walletProxy:Q,user:f,embeddedWallets:t,defaultChain:te.defaultChain,appId:n.appId}),r&&a.connectors.addImportedWalletConnector(Q,r.address,te.defaultChain,n.appId)):console.debug("Failed to add embedded wallet connector: Wallet proxy not initialized"):console.debug("Failed to add embedded wallet connector: Client connectors not initialized")}),[Q,f]),d((()=>{Q&&se?.(Q)}),[Q]);let Ae=i();d((()=>{(async()=>{if(!te.customAuth?.enabled)return void me({status:"not-enabled"});let{getCustomAccessToken:e,isLoading:t}=te.customAuth;if(u&&!t&&"loading"!==ue.status){me({status:"loading"});try{let t=await e();if(t===Ae.current)return void me({status:"done"});if(!t&&g)return Ae.current=t,await Je.logout(),me({status:"done"}),void Ns(fe,"customAuth","onUnauthenticated");if(!t)return Ae.current=t,void me({status:"done"});a.startAuthFlow(new Jn(t));let{user:n,isNewUser:r}=await a.authenticate();if(!n)return await Je.logout(),me({status:"error",error:new k("Failed to sync with custom auth provider")}),void Ns(fe,"customAuth","onUnauthenticated");void 0!==r&&Ns(fe,"login","onComplete",{user:n,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),Ae.current=t,Ns(fe,"customAuth","onAuthenticated",{user:n}),me({status:"done"}),b(n||null),N(r||!1),y(!0),he(!0)}catch(e){if(console.warn(e),await Je.logout(),Ns(fe,"customAuth","onUnauthenticated"),"User already exists with provided custom JWT account."===e.message)return void me({status:"initial"});Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),me({status:"error",error:e})}}})()}),["initial"===ue.status,te.customAuth?.enabled,te.customAuth?.getCustomAccessToken,te.customAuth?.isLoading,u,g]),d((()=>{pe&&Q&&f&&(async()=>{let e=yl(f,te.embeddedWallets.ethereum.createOnLogin),t=wl(f,te.embeddedWallets.solana.createOnLogin),n=await Jb();if(n){if(e&&t){let e=await Re(f,Qr);return await Q.createSolana({accessToken:n,ethereumAddress:e?.address}),void he(!1)}if(t)return await Q.createSolana({accessToken:n,ethereumAddress:$a(f)?.address}),await Xe.refreshSessionAndUser(),void he(!1);if(e)return await Re(f,Qr),void he(!1)}})().catch(console.error)}),[pe&&Q&&f]),d((()=>{if(te.externalWallets.solana.connectors)return te.externalWallets.solana.connectors.onMount(),()=>te.externalWallets.solana.connectors?.onUnmount()}),[te.externalWallets.solana.connectors]),d((()=>{!u&&ne&&async function(){let e,t=Ie(),n=_e(),i=r();a.initializeConnectorManager({walletConnectCloudProjectId:te.walletConnectCloudProjectId,rpcConfig:te.rpcConfig,chains:te.chains,defaultChain:te.defaultChain,store:i,walletList:te.appearance.walletList,shouldEnforceDefaultChainOnConnect:te.shouldEnforceDefaultChainOnConnect,externalWalletConfig:te.externalWallets,appName:te.name??"Privy",walletChainType:te.appearance.walletChainType}),a.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=a.connectors.walletConnectors.length,n=a.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);n===t?ve(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:n,expected:t}),ve(!0)}),1500)})),a.connectors?.initialize().then((()=>{Pe()}));let o=await a.getAuthenticatedUser(),s=!!o;te.legal.requireUsersAcceptTerms&&o&&!o.hasAcceptedTerms?(await a.logout(),Xe.setReadyToTrue(!0),Ns(fe,"logout","onSuccess")):(te.customAuth?.enabled||(y(!!o),o&&Ns(fe,"login","onComplete",{user:o,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),b(o)),t?Ce.current=s?"link":"login":n&&!s?(Ce.current="login",ae({telegramAuthModalData:{seamlessAuth:!0}}),Te(sh)):Xe.setReadyToTrue(!!o))}()}),[a,ie,u,ne]),d((()=>{if(u){if(!f||!f.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType))||[...x].some((e=>"privy"===e.walletClientType)))return void de(!0);de(!!Q)}}),[u,f,x,Q]),d((()=>{a.connectors?.setWalletList(te.appearance.walletList)}),[te.appearance.walletList.join()]);let Ie=()=>{let e=ka();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&function(e){return e.startsWith("privy:")}(e.provider)&&!e.popupFlow&&(new BroadcastChannel(Bg).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(a.startAuthFlow(new la(e)),Te(Lb),!0))},_e=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),n=e.get("hash"),r=Number(e.get("auth_date")||""),a=e.get("first_name");if(t&&a&&r&&n)return Object.fromEntries(e.entries())}())?(Ra(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=La(e.replace("#tgWebAppData=","")),{user:n,auth_date:r,hash:a}=t;return n&&r&&a?t:void 0}())?(Ra(),{flowType:"web-app",authData:e}):void 0}();if(!e||!te.loginMethods.telegram||!te.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new Oa;return a.startAuthFlow(t),"login-url"===e.flowType&&(t.meta.telegramWebAppData=void 0,t.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=e.authData),!0},Ee=async(e,t,n,r)=>{if("solana_adapter"!==e)Se(await(a.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,n,r);else{let e=a.connectors?.findSolanaWalletConnector(t);if(!e)return;Se(e,t,n,r)}};async function Se(e,t,n,r){if(!e)return F({status:"disconnected",connectedWallet:null,connectError:new S("Unable to connect to wallet."),connector:null,connectRetry:G}),r?.(null,n);F({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:G}),e instanceof Iu&&t&&await e.resetConnection(t),F({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Se(e,t,n,r)});try{let t=await e.connect({showPrompt:!0});if((!t||Ti(t))&&te.shouldEnforceDefaultChainOnConnect&&!te.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){F((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:G})));try{await(t?.switchChain(te.defaultChain.id)),t&&(t.chainId=wr(yr(te.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${te.defaultChain.id}`)}}return F((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:G}))),t&&Ns(fe,"connectWallet","onSuccess",{wallet:t}),r?.(t,n)}catch(e){return e instanceof Z?(console.warn(e.cause?e.cause:e.message),Ns(fe,"connectWallet","onError",e.privyErrorCode||U.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),Ns(fe,"connectWallet","onError",U.UNKNOWN_CONNECT_WALLET_ERROR)),F((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),r?.(null,n)}}let Ne=async(e,t,n)=>{if(null===e||!Ti(e))return;let r=new Ia(e,a,t,n);a.startAuthFlow(r)},Me=async(e,t,n)=>{if(null===e||!so(e))return;let r=new _a(e,a,t,n);a.startAuthFlow(r)},Pe=()=>{let e=new URLSearchParams(window.location.search),t=e.get("privy_connector"),n=e.get("privy_wallet_client"),r="true"===e.get("privy_connect_only");if(!t||!n)return;let i=no({connectorType:t,walletClientType:n});if(!i||!i.isInstalled)return Te(fb);if(!a.connectors)throw new k("Connector not initialized");Te(r?eu:Yh);let o=new URL(window.location.href);o.searchParams.delete("privy_connector"),o.searchParams.delete("privy_wallet_client"),o.searchParams.delete("privy_connect_only"),window.history.pushState({},"",o),Ee(t,n,void 0,r?void 0:"solana_adapter"===t?Me:Ne)};d((()=>{u&&g&&null===f&&a.getAuthenticatedUser().then(b)}),[u,g,f,a]);let We=e=>{if(!g)throw Ns(fe,"linkAccount","onError",U.MUST_BE_AUTHENTICATED,{linkMethod:e}),new k("User must be authenticated before linking an account.")},Oe=e=>{if(!g||!f)return!1;if("privy"===e.walletClientType)return!0;for(let t of f.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},Ue=async e=>{let t;if(!a.connectors)throw new k("Connector not initialized");t="ethereum"===e.type?a.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:a.connectors.findSolanaWalletConnector(e.walletClientType)||null,F((n=>({...n,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:G}))),te.captchaEnabled&&!g?(ae({captchaModalData:{callback:t=>Ti(e)?Ne(e,t):Me(e,t),userIntentRequired:!1,onSuccessNavigateTo:Yh,onErrorNavigateTo:Yl}}),Te(hp)):(Ti(e)?await Ne(e):await Me(e),Te(Yh))},Le=()=>{A((e=>{let t=a.connectors?.wallets.filter(Ti).map((e=>({...e,linked:Oe(e),loginOrLink:async()=>{if(!await e.isConnected())throw new k("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new k("Cannot link or login with embedded wallet");Ue(e)},fund:async t=>{await Xe.fundWallet(e.address,t)},unlink:async()=>{if(!g)throw new k("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new k("Cannot unlink an embedded wallet");b(await a.unlinkEthereumWallet(e.address))}})))||[];return Ai(e,t)?e:t})),_((e=>{let t=(a.connectors?.wallets??[]).filter(so).map((e=>({...e,linked:Oe(e),loginOrLink:async()=>{if(!await e.isConnected())throw new k("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new k("Cannot link or login with embedded wallet");Ue(e)},fund:async()=>{throw new k("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!g)throw new k("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new k("Cannot unlink an embedded wallet");b(await a.unlinkSolanaWallet(e.address))}})));return Ai(e,t)?e:t}))};d((()=>{Le()}),[f?.linkedAccounts,g,u]),d((()=>{if(u){if(!a.connectors)throw new k("Connector not initialized");Le(),a.connectors.on("walletsUpdated",Le)}}),[u]),d((()=>{[...te.loginMethodsAndOrder?.primary??[],...te.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>a.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!a]);let Re=async(e,t,n)=>{let r=$a(e),a=Ha(e);if(n&&"walletIndex"in n&&"number"==typeof n.walletIndex)return ze(e,t,n.walletIndex,r,a);let i=n&&"createAdditional"in n&&n.createAdditional;if(r&&!i)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");let[o,s]=await Promise.all([Xe.initializeWalletProxy(t),Jb()]);if(!o&&te.customAuth?.enabled)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!o||!s||te.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return De();if(!r)return a&&await Xe.recoverPrimaryWallet(),await o.create({accessToken:s,solanaAddress:a?.address}),Ve(0,"ethereum");{let t=((e=>ja(e).reduce(((e,t)=>!e||e.walletIndex<t.walletIndex?t:e),null))(e)?.walletIndex??0)+1,{entropyId:n,entropyIdVerifier:r}=Qa(e);return await Xe.recoverPrimaryWallet(),await o.addWallet({accessToken:s,entropyId:n,entropyIdVerifier:r,chainType:"ethereum",hdWalletIndex:t}),Ve(t,"ethereum")}},Fe=async(e,t,n)=>{let r=$a(e),a=Ha(e),i=n&&"createAdditional"in n&&n.createAdditional,o=n&&"walletIndex"in n?n.walletIndex:void 0,s=((e=>Va(e).reduce(((e,t)=>!e||e.walletIndex<t.walletIndex?t:e),null))(e)?.walletIndex??-1)+1;if(a&&!i&&"number"!=typeof o)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");if("number"==typeof o&&o<0)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${o}) is invalid.`);let[l,c]=await Promise.all([Xe.initializeWalletProxy(t),Jb()]);if(!l||!c)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return await Be({user:e,wp:l,accessToken:c,walletIndex:o??s,ethereumWallet:r})},De=async()=>new Promise(((e,t)=>{ae({createWallet:{onSuccess:t=>{Ns(fe,"createWallet","onSuccess",{wallet:t}),e(t)},onFailure:e=>{Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),t(e)},callAuthOnSuccessOnClose:!1}}),Te(Dd)})),ze=async(e,t,n,r,a)=>{if(n<0)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${n}) is invalid.`);let[i,o]=await Promise.all([Xe.initializeWalletProxy(t),Jb()]);if(!i&&te.customAuth?.enabled)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!i||!o||te.embeddedWallets?.requireUserOwnedRecoveryOnCreate){if(0==n)return De();throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Create wallet UI can only be displayed when walletIndex is 0.")}if(0===n){if(r)return r;await i.create({accessToken:o,solanaAddress:a?.address})}else{if(!r)throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_CREATE_ERROR),Error("A user must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let t=ja(e).find((e=>e.walletIndex===n));if(t)return t;let{entropyId:a,entropyIdVerifier:s}=Qa(e);await Xe.recoverPrimaryWallet(),await i.addWallet({accessToken:o,entropyId:a,entropyIdVerifier:s,chainType:"ethereum",hdWalletIndex:n})}return Ve(n,"ethereum")},Be=async({user:e,wp:t,accessToken:n,walletIndex:r,ethereumWallet:a})=>{let i=Va(e).find((e=>e.walletIndex===r));if(i)return i;if(0===r)a&&await Xe.recoverPrimaryWallet(),await t.createSolana({accessToken:n,ethereumAddress:a?.address});else{if(!Ga(e))throw Ns(fe,"createWallet","onError",U.EMBEDDED_WALLET_CREATE_ERROR),Error("User must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let{entropyId:a,entropyIdVerifier:i}=Qa(e);await Xe.recoverPrimaryWallet(),await t.addWallet({accessToken:n,entropyId:a,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:r})}return Ve(r,"solana")},Ve=async(e,t)=>{let n=await Xe.refreshSessionAndUser(),r=("ethereum"===t?ja(n):Va(n)).find((t=>t.walletIndex===e));if(!r)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");return Ns(fe,"createWallet","onSuccess",{wallet:r}),r},He=({transaction:e,uiOptions:t,fundWalletConfig:r,address:a,signOnly:i})=>new Promise((async(o,s)=>{let{requesterAppId:l}=t||{},c=i?"signTransaction":"sendTransaction";if(!g||!f)return Ns(fe,c,"onError",U.MUST_BE_AUTHENTICATED),void s(Error("User must be authenticated before signing with a Privy wallet"));let d=a?Za(f,a):$a(f);if(!d)return Ns(fe,c,"onError",U.EMBEDDED_WALLET_NOT_FOUND),void s(new k("User must have an embedded wallet to send a transaction."));let p=d.address,h=d.walletIndex??0,{entropyId:u,entropyIdVerifier:m}=Qa(f,d),y=Qe.wallets.find((e=>"privy"===e.walletClientType&&v(e.address)===v(p)));if(!y)return Ns(fe,c,"onError",U.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have a Privy wallet before signing"));let w=await y.getEthereumProvider(),b=await w.request({method:"eth_chainId"}),C=e.chainId?Number(e.chainId):zg(b);(e=>{if(!te.chains.map((e=>e.id)).includes(e))throw new S(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,U.UNSUPPORTED_CHAIN_ID)})(C);let x={...e,from:e.from??p,chainId:C},T=await Jb();if(!T||!Q)return Ns(fe,c,"onError",U.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have valid access token and Privy wallet to send transaction"));let A=sr(x.chainId,te.chains,te.rpcConfig,{appId:n.appId});if(xe({showWalletUIs:t?.showWalletUIs}))(async()=>{try{if(!await Xe.recoverPrimaryWallet())return Ns(fe,c,"onError",U.UNKNOWN_CONNECT_WALLET_ERROR),void s(Error("Unable to connect to wallet"));let e=await og(x,A,x.from),t=i?await Fg({accessToken:T,entropyId:u,entropyIdVerifier:m,transactingWalletIndex:h,walletProxy:Q,transactionRequest:x,requesterAppId:l}):await Rg({accessToken:T,entropyId:u,entropyIdVerifier:m,transactingWalletIndex:h,walletProxy:Q,transactionRequest:e,publicClient:A,requesterAppId:l});i?Ns(fe,"signTransaction","onSuccess",{signature:t}):Ns(fe,"sendTransaction","onSuccess",{hash:t}),o({hash:t})}catch(e){Ns(fe,c,"onError",U.TRANSACTION_FAILURE),s(e)}})();else{let e={connectingWalletAddress:p,recoveryMethod:d.recoveryMethod,entropyId:u,entropyIdVerifier:m,onCompleteNavigateTo:Kv,onFailure:e=>{Ns(fe,c,"onError",U.UNKNOWN_CONNECT_WALLET_ERROR),s(e)}},n=vy(te)?lw({address:p,appConfig:te,fundWalletConfig:r,methodScreen:nw,chainIdOverride:x.chainId,comingFromSendTransactionScreen:!0}):void 0;ae({connectWallet:e,sendTransaction:{transactionRequest:x,transactingWalletIndex:h,transactingWalletAddress:p,entropyId:u,entropyIdVerifier:m,signOnly:i,onConfirm:i?async()=>await Fg({accessToken:T,entropyId:u,entropyIdVerifier:m,transactingWalletIndex:h,walletProxy:Q,transactionRequest:x,requesterAppId:l}):void 0,onSuccess:e=>{i?Ns(fe,"signTransaction","onSuccess",{signature:e.hash}):Ns(fe,"sendTransaction","onSuccess",{hash:e.hash}),o(e)},onFailure:e=>{Ns(fe,c,"onError",U.TRANSACTION_FAILURE),s(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:l},funding:n}),Te(fw)}}));function qe(){return new Promise((async(e,t)=>{let n=await Jb();if(!n||!Q)throw Error("Must have valid access token to enroll in MFA");try{await Q.verifyMfa({accessToken:n}),e()}catch(e){t(e)}}))}let Ke=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],Ze=e=>{let t=f?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:n,loginMethod:r}=Tl(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw Ns(fe,"linkAccount","onError",U.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:r}),new k(`User already has an account of type ${n} linked.`)};async function Ge({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){P(null);let n=t?"setWalletPassword":"setWalletRecovery";if(!g||!f)throw Ns(fe,n,"onError",U.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let r=Ga(f);if(!r||!Q)throw Ns(fe,n,"onError",U.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");try{await qe()}catch(e){throw Ns(fe,n,"onError",U.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,i)=>{let o={onSuccess:e=>{Ns(fe,n,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{Ns(fe,n,"onError",U.USER_EXITED_SET_PASSWORD_FLOW),i(e)},callAuthOnSuccessOnClose:!1},s="user-passcode"===r.recoveryMethod,l=Ud({walletAction:"update",availableRecoveryMethods:te.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:s,showAutomaticRecovery:e}),{entropyId:c,entropyIdVerifier:d}=Qa(f),p={recoveryMethod:r.recoveryMethod,connectingWalletAddress:r.address,onCompleteNavigateTo:l,shouldForceMFA:!1,entropyId:c,entropyIdVerifier:d,onFailure:e=>{Ns(fe,n,"onError",U.UNKNOWN_CONNECT_WALLET_ERROR),i(e)}};ae({setWalletPassword:o,recoverWallet:{entropyId:c,entropyIdVerifier:d,onFailure:i},createWallet:o,connectWallet:p,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:s}}),Te(fw)}))}async function Ye({appId:e,action:t}){let n=await Jb();if("link"===t&&!n)throw Ns(fe,"linkAccount","onError",U.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new k("User must be authenticated before linking an account.");if("login"===t&&n)throw Ns(fe,"login","onError",U.UNKNOWN_AUTH_ERROR),new k("Attempted to log in, but user is already logged in. Use a `link` helper instead.");be.current=`privy:${e}`,Ce.current=t;let r=Hg();return a.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,i)=>{let{name:o,logoUrl:s}=await Vg({api:a.api,providerAppId:e,requesterAppId:te.id});ae({crossAppAuth:{appId:e,name:o,logoUrl:s,action:t,popup:r,onSuccess:n,onError:i}}),Te(eb)}))}let Je={ready:u,authenticated:g,user:f,walletConnectors:a.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),ae({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),Te(g?Xv:bu)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),We("siwe"),be.current="siwe",Ce.current="link",ae({...re,externalConnectWallet:{...re.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),Te(gb)},startCrossAppAuthFlow:Ye,linkEmail:()=>{We("email"),Ze("email"),be.current="email",Ce.current="link",Te(ub)},linkPhone:()=>{We("sms"),Ze("phone"),be.current="sms",Ce.current="link",Te(mb)},linkGoogle:async()=>{We("google"),Ze("google_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("google")},linkTwitter:async()=>{We("twitter"),Ze("twitter_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("twitter")},linkDiscord:async()=>{We("discord"),Ze("discord_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("discord")},linkGithub:async()=>{We("github"),Ze("github_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("github")},linkSpotify:async()=>{We("spotify"),Ze("spotify_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("spotify")},linkInstagram:async()=>{We("instagram"),Ze("instagram_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("instagram")},linkTiktok:async()=>{We("tiktok"),Ze("tiktok_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{We("linkedin"),Ze("linkedin_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("linkedin")},linkApple:async()=>{We("apple"),Ze("apple_oauth"),Ce.current="link",await Xe.initLoginWithOAuth("apple")},linkPasskey:async()=>{We("passkey"),Ze("passkey"),await Xe.initLinkWithPasskey(),Te(lf)},linkTelegram:async e=>{if(We("telegram"),Ze("telegram"),Ce.current="link",be.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new Oa;a.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=La(e.launchParams.initDataRaw),ae({telegramAuthModalData:{seamlessAuth:!0}}),Te(sh)}else Ns(fe,"linkAccount","onError",U.INVALID_DATA,{linkMethod:"telegram"});else await Xe.initLoginWithTelegram();Te(sh)},linkFarcaster:async()=>{We("farcaster"),Ze("farcaster"),await Xe.initLoginWithFarcaster(),Ce.current="link",be.current="farcaster",Te(Fp)},updateEmail:()=>{if(We("email"),!f?.email)throw new k("User does not have an email linked to their account.");Ce.current="update",be.current="email",Te(Bb)},updatePhone:()=>{if(We("sms"),!f?.phone)throw new k("User does not have a phone number linked to their account.");Ce.current="update",be.current="sms",Te($b)},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!u){let e=await new Promise((e=>{oe((t=>e.bind(t)))}));if(oe(null),e)return void console.warn(t)}!f||f.isGuest?(Ce.current="login",ae({login:e}),Te(Hh)):console.warn(t)},connectOrCreateWallet:async()=>{u||(await new Promise((e=>{oe((()=>e))})),oe(null)),g?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(Ce.current="connect-or-create",Te(vh))},logout:async()=>{if(Ce.current=null,be.current=null,f&&a.clearProviderAcccessTokens(f),P(null),await a.logout(),f&&Q)try{await Q.clearMfa({userId:f.id})}catch(e){}b(null),y(!1),Ns(fe,"logout","onSuccess"),h(!1),rr.del($r),rr.del(jr(te.id))},getAccessToken:p((()=>a.getCustomerAccessToken()),[a]),unlinkWallet:async e=>{let t;return b(t=e.startsWith("0x")?await a.unlinkEthereumWallet(e):await a.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await a.unlinkEmail(e);return b(t),t},unlinkPhone:async e=>{let t=await a.unlinkPhone(e);return b(t),t},unlinkGoogle:async e=>{let t=await a.unlinkOAuth("google",e);return b(t),t},unlinkTwitter:async e=>{let t=await a.unlinkOAuth("twitter",e);return b(t),t},unlinkDiscord:async e=>{let t=await a.unlinkOAuth("discord",e);return b(t),t},unlinkGithub:async e=>{let t=await a.unlinkOAuth("github",e);return b(t),t},unlinkSpotify:async e=>{let t=await a.unlinkOAuth("spotify",e);return b(t),t},unlinkInstagram:async e=>{let t=await a.unlinkOAuth("instagram",e);return b(t),t},unlinkTiktok:async e=>{let t=await a.unlinkOAuth("tiktok",e);return b(t),t},unlinkLinkedIn:async e=>{let t=await a.unlinkOAuth("linkedin",e);return b(t),t},unlinkApple:async e=>{let t=await a.unlinkOAuth("apple",e);return b(t),t},unlinkFarcaster:async e=>{let t=await a.unlinkFarcaster(e);return b(t),t},unlinkTelegram:async e=>{let t=await a.unlinkTelegram(e);return b(t),t},unlinkPasskey:async e=>{let t=await Jb();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!Q)throw Error("Wallet proxy not initialized.");let n=te.passkeys.shouldUnenrollMfaOnUnlink;await Q.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:n});let r=await a.getAuthenticatedUser();return b(r),r},unlinkCrossAppAccount:async({subject:e})=>{let t=f?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new k("Invalid subject");a.storeProviderAccessToken(t.id,null);let n=await a.unlinkOAuth(`privy:${t.id}`,e);return b(n),n},createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let t=await Xe.refreshSessionAndUser();if(!t)throw Ns(fe,"createWallet","onError",U.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return Re(t,15e3,e)},setWalletRecovery:async e=>Ge({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>Ge({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=e.message;if(!g||!f)return Ns(fe,"signMessage","onError",U.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let s=t?.address?Za(f,t.address):$a(f);if(!s)throw new k("User must have an embedded wallet to send a transaction.");let l=s.address,c=s.walletIndex??0,{entropyId:d,entropyIdVerifier:p}=Qa(f,s);if("string"!=typeof o||o.length<1)return Ns(fe,"signMessage","onError",U.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));let h=async()=>{if(!g)throw Error("User must be authenticated before signing with a Privy wallet");let e=await Jb();if(!Q||!e||!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:l,requesterAppId:i}});let{response:t}=await Q.rpc({accessToken:e,entropyId:d,entropyIdVerifier:p,chainType:"ethereum",hdWalletIndex:c,requesterAppId:i,request:{method:"personal_sign",params:[o,l]}}),n=t.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:l,requesterAppId:i}}),n};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await h();Ns(fe,"signMessage","onSuccess",{signature:e}),n({signature:e})}catch(e){Ns(fe,"signMessage","onError",U.UNABLE_TO_SIGN),r(e??new ki("Unable to sign message"))}else ae({signMessage:{method:"personal_sign",data:o,confirmAndSign:h,onSuccess:e=>{Ns(fe,"signMessage","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{Ns(fe,"signMessage","onError",U.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:s.recoveryMethod,connectingWalletAddress:l,entropyId:d,entropyIdVerifier:p,onCompleteNavigateTo:fv,onFailure:e=>{Ns(fe,"signMessage","onError",U.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Te(fw)})),signTypedData:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{};if(!g||!f)return Ns(fe,"signTypedData","onError",U.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let o=t?.address?Za(f,t.address):$a(f);if(!o)throw new k("User must have an embedded wallet to send a transaction.");let s=o.address,l=o.walletIndex??0,{entropyId:c,entropyIdVerifier:d}=Qa(f,o),p=br(e),h=async()=>{if(!g)throw Error("User must be authenticated before signing with a Privy wallet");let e=await Jb();if(!Q||!e||!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:s,requesterAppId:i}});let{response:t}=await Q.rpc({accessToken:e,entropyId:c,entropyIdVerifier:d,chainType:"ethereum",hdWalletIndex:l,requesterAppId:i,request:{method:"eth_signTypedData_v4",params:[s,p]}}),n=t.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:s,requesterAppId:i}}),n};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await h();Ns(fe,"signTypedData","onSuccess",{signature:e}),n({signature:e})}catch(e){Ns(fe,"signTypedData","onError",U.UNABLE_TO_SIGN),r(e??new ki("Unable to sign message"))}else ae({signMessage:{method:"eth_signTypedData_v4",data:p,confirmAndSign:h,onSuccess:e=>{Ns(fe,"signTypedData","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{Ns(fe,"signTypedData","onError",U.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:c,entropyIdVerifier:d,onCompleteNavigateTo:fv,onFailure:e=>{Ns(fe,"signMessage","onError",U.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Te(fw)})),sendTransaction:async(e,t)=>await He({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await He({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!g||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let i=e?.address?Za(f,e.address):$a(f),o=Ga(f);if(!i||!o)return void r(new k("User must have an embedded wallet to send a transaction."));let s=i.address,{entropyId:l,entropyIdVerifier:c}=Qa(f,i);if(!s)return void r(Error("User does not have an HD Ethereum wallet. To export an imported wallet, pass the `address` of the wallet to `exportWallet`."));if(!C(s))return void r(Error("Must provide a valid Ethereum address."));let d={recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:uw,onFailure:r,shouldForceMFA:!0};ae(re),await Jb()&&Q?Q?(ae({keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:i,primaryWallet:o,onSuccess:t,onFailure:r},connectWallet:d}),Te(fw)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:qe,async init(e){switch(e){case"sms":return void await a.initMfaSmsVerification();case"passkey":return await a.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new k("Invalid MFA code");ge.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{ye.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new k("Invalid authenticator response");let n=await import("@simplewebauthn/browser"),r=(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}))(await n.startAuthentication(t));ge.current?.resolve({mfaMethod:e,mfaCode:r,relyingParty:window.origin}),await new Promise(((e,t)=>{ye.current={resolve:e,reject:t}}));break;default:throw ge.current?.reject(new k("Unsupported MFA method")),new k(`Unsupported MFA method: ${e}`)}},cancel(){ge.current?.reject(new k("MFA canceled"))},async initEnrollmentWithSms(e){let t=await Jb();if(!t||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,n)=>{if(!e)return Xe.closePrivyModal(),void t();te.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."),ae({mfaEnrollmentFlow:{mfaMethods:te.mfa.methods,shouldUnlinkOnUnenrollMfa:te.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:n}}),Te(Ub)})),async initEnrollmentWithTotp(){let e=await Jb();if(!e||!Q)throw Error("Must have valid access token to enroll in MFA");let t=await Q.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await Jb();if(!t||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),b(await a.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await Jb();if(!t||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),b(await a.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let n=await Jb();if(!n||!Q)throw Error("Must have valid access token to enroll in MFA");await Q.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:e,removeForLogin:t.removeForLogin}),b(await a.getAuthenticatedUser())},async unenroll(e,t={}){let n=await Jb();if(!n||!Q)throw Error("Must have valid access token to remove MFA");"passkey"===e?await Q.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:[],removeForLogin:t.removeForLogin}):await Q.unenrollMfa({method:e,accessToken:n}),b(await a.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await Jb(),t=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");let n=await Q.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===n.status&&b(await a.getAuthenticatedUser()||f||null),ae({farcasterSigner:n}),Te(lb)},getFarcasterSignerPublicKey:async()=>{let e,t=await Jb(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=f.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await Jb(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Xe.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let r=await import("@simplewebauthn/browser"),a=await Q.signFarcasterMessage({address:n.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:r.bufferToBase64URLString(e)},fid:BigInt(f.farcaster.fid),relyingParty:window.origin});return new Uint8Array(r.base64URLStringToBuffer(a.signature))},signMessageWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Kg({user:f,client:a,address:t,requesterAppId:te.id,request:{method:r?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:n},reconnect:Ye})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),i=br(e);return Kg({user:f,client:a,address:t,requesterAppId:te.id,request:{method:r?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,i],chainId:n},reconnect:Ye})},sendTransactionWithCrossAppWallet(e,{address:t}){let n=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Kg({user:f,client:a,address:t,requesterAppId:te.id,request:{method:n?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:Ye})},isModalOpen:c,mfaMethods:te.mfa.methods};Vb=Je.signMessage,Hb=Je.signTypedData,Kb=async(e,t)=>await He({transaction:e,...t,signOnly:!1}),qb=async(e,t)=>({signature:(await He({transaction:e,...t,signOnly:!0})).hash});let Xe={setAuthenticated:y,setUser:b,setIsNewUser:N,isNewUserThisSession:E,pendingTransaction:null,walletConnectionStatus:L,connectors:a.connectors?.walletConnectors??[],solanaWallets:I,rpcConfig:te.rpcConfig,chains:te.chains,appId:n.appId,showFiatPrices:"native-token"!==te.embeddedWallets.priceDisplay.primary,clientAnalyticsId:a.clientAnalyticsId,customAuthStatus:ue,hideWalletUIs:ke,isHeadlessSigning:p(xe,[te.embeddedWallets.showWalletUIs]),emailOtpState:B,setEmailOtpState:$,smsOtpState:j,setSmsOtpState:V,oAuthState:K,setOAuthState:Y,telegramAuthState:J,setTelegramAuthState:X,siweState:H,setSiweState:q,isHeadlessOAuthLoading:W,nativeTokenSymbolForChainId:e=>te.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(Q)return Q;let t=new Promise((e=>{le((()=>t=>e(t)))})),n=new Promise((t=>setTimeout((()=>t(null)),e))),r=await Promise.race([t,n]);return le(null),r},getAuthFlow:()=>a.authFlow,getAuthMeta:()=>a.authFlow?.meta,client:a,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=u&&g&&f;r&&be.current&&(t=Ke(f)),"login"===Ce.current?e.shouldCallAuthOnSuccess&&r&&be.current?Ns(fe,"login","onComplete",{user:f,isNewUser:E,wasAlreadyAuthenticated:!1,loginMethod:be.current,loginAccount:t??null}):Ns(fe,"login","onError",U.USER_EXITED_AUTH_FLOW):"link"===Ce.current&&t?e.isSuccess&&r&&be.current?Ns(fe,"linkAccount","onSuccess",{user:f,linkMethod:be.current,linkedAccount:t}):be.current&&Ns(fe,"linkAccount","onError",U.USER_EXITED_LINK_FLOW,{linkMethod:be.current}):"update"===Ce.current&&t?e.isSuccess&&r&&be.current?Ns(fe,"update","onSuccess",{user:f,updateMethod:be.current,updatedAccount:t}):be.current&&Ns(fe,"update","onError",U.USER_EXITED_UPDATE_FLOW,{linkMethod:be.current}):"connect-or-create"===Ce.current&&(x[0]?Ns(fe,"connectOrCreateWallet","onSuccess",{wallet:x[0]}):Ns(fe,"connectOrCreateWallet","onError",U.USER_EXITED_AUTH_FLOW));let i=M&&Yv.has(M),o=M===Yl&&re.errorModalData&&Yv.has(re.errorModalData.previousScreen);if((i||o)&&re.funding){let e,t=Yv.get(M)??null;if("solana"===re.funding.chainType){let n=l(py);if(n)try{e=BigInt(await n.getBalance({address:re.funding.address,cluster:re.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");Ns(fe,"fundSolanaWallet","onUserExited",{address:re.funding.address,cluster:re.funding.cluster,fundingMethod:t,balance:e})}else{let r=sr(re.funding.chain.id,te.chains,te.rpcConfig,{appId:n.appId});try{e=await r.getBalance({address:re.funding.address})}catch{console.error("Unable to pull wallet balance")}Ns(fe,"fundWallet","onUserExited",{address:re.funding.address,chain:re.funding.chain,fundingMethod:t,balance:e})}}ae({...re,externalConnectWallet:{suggestedAddress:void 0}}),Ce.current=null,be.current=null,N(!1),h(!1),setTimeout((()=>{a.authFlow=void 0}),200)},openPrivyModal:Te,connectWallet:Se,initLoginWithWallet:async(e,t,n)=>{Ti(e)?(be.current="siwe",Ne(e,t,n)):(be.current="siws",Me(e,t,n))},loginWithWallet:async()=>{let e,t,n;if(!u)throw new $e;if(a.authFlow instanceof Ia?e="siwe":a.authFlow instanceof _a&&(e="siws"),!e)throw new k("Must initialize SIWE/SIWS flow first.");if(null!==await a.getAccessToken())try{({user:t}=await a.link()),be.current=e}catch(t){throw Ns(fe,"linkAccount","onError",t.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:n}=await a.authenticate()),be.current=e}catch(e){throw Ns(fe,"login","onError",e.privyErrorCode||U.GENERIC_CONNECT_WALLET_ERROR),e}b(t||f||null),N(n||!1),y(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:n})=>new Promise((async(r,a)=>{let i=await Jb();if(!g||!f||!i)throw new k("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new k("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=Xe.walletProxy??await Xe.initializeWalletProxy(15e3);if(!o)throw new k("Wallet proxy not initialized.");if((({address:e,chainType:t,user:n})=>!!Lg(n).find((n=>n.address===e&&n.chainType===t)))({address:e,chainType:t,user:f}))return r();let s=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new k("Address to delegate is not associated with current user.");return{address:n.address,chainType:n.chainType,walletIndex:n.walletIndex??0}})({address:e,user:f}),l=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new k("Address to delegate is not associated with current user.");let r=n.imported?n:Ga(t);if(!r)throw new k("Unable to determine root address for delegated address.");return{address:r.address,chainType:r.chainType,imported:r.imported}})({address:e,user:f}),c=async()=>{await o.createDelegatedAction({accessToken:i,rootWallet:l,delegatedWallets:[s]}),await Xe.refreshSessionAndUser()};if(await Xe.recoverPrimaryWallet(),n)ae({delegatedActions:{consent:{address:e,onDelegate:c,onSuccess:async()=>{r()},onError:async e=>{a(e)}}}}),Te(nb);else try{await c(),r()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,n)=>{if(!g||!f)throw new k("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");if(0===Lg(f).length)throw new k("User has no delegated wallets to revoke.");let r=async()=>{await a.revokeDelegatedWallet(),await Xe.refreshSessionAndUser()};if(e)ae({delegatedActions:{revoke:{onRevoke:r,onSuccess:async()=>{t()},onError:async e=>{n(e)}}}}),Te(ib);else try{await r(),t()}catch(e){n(e)}})),initLoginWithFarcaster:async(e,t)=>{let n=new Sr(e,t);a.startAuthFlow(n);try{be.current="farcaster",await n.initializeFarcasterConnect()}catch(e){throw"login"===Ce.current?Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR):"link"===Ce.current&&Ns(fe,"linkAccount","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!u)throw new $e;if(!(a.authFlow instanceof Sr))throw new k("Must initialize Farcaster flow first.");if(null!==await a.getAccessToken())try{({user:e}=await a.link()),be.current="farcaster"}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await a.authenticate()),be.current="farcaster"}catch(e){throw Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}b(e||null),N(t||!1),y(!0)},async crossAppAuthFlow({appId:e,popup:t,action:n}){let r=`privy:${e}`;be.current=r;let{url:i,stateCode:o,codeVerifier:s}=await async function({api:e,appId:t}){let n=ia(),r=oa(),a=await sa(n);try{let{url:i}=await e.post(R,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:r});return{url:i,stateCode:r,codeVerifier:n}}catch(e){throw T(e)}}({api:a.api,appId:e});if(!i)throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new k("No authorization URL returned for cross-app auth.");try{let l=await async function({url:e,popup:t}){return t.location=e,new Promise(((e,n)=>{let r,a=setTimeout((()=>{n(new k("Authorization request timed out after 2 minutes.")),i()}),12e4);function i(){t?.close(),window.removeEventListener("message",s)}let o=setInterval((()=>{t?.closed&&!r&&(i(),clearInterval(o),clearTimeout(a),n(new k("User rejected request")))}),300);function s(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(a),e(t.data),i()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(a),n(new k(t.data.error)),i()),t.data.type===$g&&((r=new BroadcastChannel(Bg)).onmessage=s))}window.addEventListener("message",s)}))}({url:i,popup:t,provider:r}),c=l.stateCode,d=l.authorizationCode;if(c!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:r,storedStateCode:o??"",returnedStateCode:c??""}}),new k("Unexpected auth flow. This may be a phishing attempt.",void 0,U.OAUTH_UNEXPECTED);let p=await async function({appId:e,stateCode:t,codeVerifier:n,authorizationCode:r,action:a,client:i}){if(!r||!t)throw new k("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===r)throw new k("User denied confirmation during cross-app auth flow");try{let o=new jg({authorizationCode:r,stateCode:t,codeVerifier:n,provider:`privy:${e}`});i.startAuthFlow(o);let s="link"===a?await i.link():await i.authenticate(),l=s.oAuthTokens?.accessToken;return console.debug(),l}catch(e){let t=T(e);if(t.privyErrorCode)throw new k(t.message||"Invalid code during cross-app auth flow.",void 0,t.privyErrorCode);if("User denied confirmation during cross-app auth flow"===t.message)throw new k("Invalid code during cross-app auth flow.",void 0,U.OAUTH_USER_DENIED);throw new k("Invalid code during cross-app auth flow.",void 0,U.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:s,stateCode:c,authorizationCode:d,action:n,client:a});p&&a.storeProviderAccessToken(e,p);let h=await Xe.refreshSessionAndUser();if(!h)throw new k("Unable to update user");return a.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),h}catch(e){throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:r}}),e}},async initLoginWithOAuth(e,t,n){if(be.current=e,!nr())return void Te(pb);if("google"===e&&As(window.navigator.userAgent))return void Te(pb);"twitter"===e&&window.opener&&window.opener.postMessage({type:$g},"*"),rr.del(Kr),rr.del(Zr);let r=new la({provider:e,disableSignup:!!n,withPrivyUi:!0});t&&r.addCaptchaToken(t),a.startAuthFlow(r);let i=await a.authFlow.getAuthorizationUrl();i&&i.url&&("twitter"===e&&w&&(i.url=i.url.replace("x.com","twitter.com")),window.location.assign(i.url))},async initLoginWithTelegram(e,t){if(!u)throw new $e;be.current="telegram";let n=new Oa(e,t);a.startAuthFlow(n),X({status:"loading"}),n.meta.telegramWebAppData=void 0,n.meta.telegramAuthResult=await new Promise(((e,t)=>te.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:te.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(n=>n?e(n):t(new k("Telegram auth failed or was canceled by the client")))):t(new k("Telegram was not initialized")):t(new k("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,n;if(!(a.authFlow instanceof Oa))throw new k("Must initialize Telegram flow before calling loginWithTelegram");a.authFlow.meta.captchaToken||=e?.captchaToken;let r=await Jb(),i=e?.intent||Ce.current;if("login"===i)try{let e=await a.authenticate();t=e.user,n=e.isNewUser,be.current="telegram"}catch(e){throw Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}else{if("link"!==i)throw new k("Unknown auth intent");try{t=(await a.link()).user,be.current="telegram"}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}b(t),N(n||!1),y(!0),X({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:o}},async recoveryOAuthFlow(e,t,n){let r,i;function o(t){if(!t)throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:e}}),new k("Recovery OAuth failed")}switch(e){case"google-drive":{let t,s,{url:l,codeVerifier:c,stateCode:d}=await Rd({api:jb.api,provider:e});o(l);try{let r=await Jv({url:l,popup:n,provider:e});if(t=r.stateCode,s=r.authorizationCode,t!==d)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:d??"",returnedStateCode:t??""}}),new k("Unexpected auth flow. This may be a phishing attempt.",void 0,U.OAUTH_UNEXPECTED)}catch(t){throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:e}}),new k("Recovery OAuth failed")}[r,i]=await Promise.all([Jb(),Fd({api:jb.api,provider:e,codeVerifier:c,stateCode:t,authorizationCode:s})]);break}case"icloud":{let{url:t}=await Rd({api:jb.api,provider:e});o(t);let{ckWebAuthToken:a}=await Jv({url:t,popup:n,provider:e});i=a,r=await Jb()}}if(!Q)throw new k("Cannot connect to wallet proxy");if(!r)throw new k("Unable to authorize user");switch(t){case"recover":{let t=re.recoverWallet?.entropyId,n=re.recoverWallet?.entropyIdVerifier;if(!t||!n)throw new k("Recovery OAuth failed");a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t,recoveryMethod:e}}),await Q.recover({accessToken:r,entropyId:t,entropyIdVerifier:n,recoveryAccessToken:i}),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t,recoveryMethod:e}});break}case"create-wallet":{a.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await Q.create({accessToken:r,recoveryAccessToken:i,recoveryMethod:e});let t=$a(await Xe.refreshSessionAndUser());if(!t)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.address}}),Ns(fe,"createWallet","onSuccess",{wallet:t});break}case"set-recovery":{let t=Ga(f);if(!t)throw Ns(fe,"setWalletRecovery","onError",U.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}});let{entropyId:n,entropyIdVerifier:o}=Qa(f);await Q.setRecovery({accessToken:r,entropyId:n,entropyIdVerifier:o,recoveryMethod:e,recoveryAccessToken:i});let s=Ga(await Xe.refreshSessionAndUser());if(!s)throw Ns(fe,"createWallet","onError",U.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}}),Ns(fe,"setWalletRecovery","onSuccess",{method:e,wallet:s});break}default:throw new k("Unsupported recovery action")}},async loginWithOAuth(e){let t,n,r;if(!(a.authFlow instanceof la))throw new k("Must initialize OAuth flow before calling loginWithOAuth");let i=rr.get(Hr),o=a.authFlow.meta.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:i??"",returnedStateCode:o??""}}),new k("Unexpected auth flow. This may be a phishing attempt.",void 0,U.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{let n=await a.link();t=n.user,r=n.oAuthTokens,be.current=e}catch(t){throw Ns(fe,"linkAccount","onError",t.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let i=await a.authenticate();t=i.user,n=i.isNewUser,r=i.oAuthTokens,be.current=e}catch(t){throw"login"===Ce.current?Ns(fe,"login","onError",t.privyErrorCode||U.UNKNOWN_AUTH_ERROR):"link"===Ce.current&&Ns(fe,"linkAccount","onError",t.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return b(t),N(n||!1),y(!0),r&&t&&Ns(fe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),r},passkeyAuthState:D,setPasskeyAuthState:z,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new Ta({captchaToken:e,setPasskeyAuthState:z});a.startAuthFlow(n),Ce.current="login";try{be.current="passkey",z({status:"generating-challenge"}),await n.initRegisterFlow(t),z({status:"awaiting-passkey"})}catch(e){throw z({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!u)throw new $e;if(!(a.authFlow instanceof Ta))throw new k("Must initialize Passkey flow first.");if("passkey"!==be.current){let e=new k("Must init login with Passkey flow first.");throw z({status:"error",error:e}),e}let n=await Jb();try{be.current="passkey",z({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await a.authenticate())}catch(e){throw z({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}b(e),N(t||!1),y(!0),z({status:"done"});let r=e?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:e,isNewUser:t||!1,wasAlreadyAuthenticated:!!n,loginAccount:r}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new Ta({captchaToken:e,setPasskeyAuthState:z});a.startAuthFlow(n),Ce.current="login";try{be.current="passkey",z({status:"generating-challenge"}),await n.initAuthenticationFlow(t),z({status:"awaiting-passkey"})}catch(e){throw z({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,n;if(!u)throw new $e;if(!(a.authFlow instanceof Ta))throw new k("Must initialize Passkey flow first.");if(e?.credentialIds&&(a.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==be.current){let e=new k("Must init login with Passkey flow first.");throw z({status:"error",error:e}),e}let r=await Jb();try{be.current="passkey",z({status:"awaiting-passkey"}),({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw z({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}b(t),N(n||!1),y(!0),z({status:"done"});let i=t?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:i}},async initLinkWithPasskey(e){let t=new Ta({captchaToken:e});a.startAuthFlow(t),Ce.current="link",be.current="passkey",z({status:"generating-challenge"});try{await t.initLinkFlow(),z({status:"awaiting-passkey"})}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),z({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!u)throw new $e;if(!(a.authFlow instanceof Ta))throw new k("Must initialize Passkey flow first.");if("passkey"!==be.current)throw new k("Must init login with Passkey flow first.");try{be.current="passkey",({user:e}=await a.link())}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return b(e||f||null),z({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,n){if(!nr())throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");if("google"===e&&As(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.");let r=new la({provider:e,withPrivyUi:!1,disableSignup:n??!1});t&&r.addCaptchaToken(t),Y({status:"loading"});let i=await a.startAuthFlow(r).getAuthorizationUrl();i?.url&&window.location.assign(i.url)},async loginWithHeadlessOAuth(e){let t,n,r;O(!0),Y({status:"loading"}),a.startAuthFlow(new la(e));let i=rr.get(Hr),o=e.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:i??"",returnedStateCode:o??""}}),O(!1),new k("Unexpected auth flow. This may be a phishing attempt.",void 0,U.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{({user:t,oAuthTokens:r}=await a.link()),be.current=e.provider;let n=Ke(t);t&&n&&Ns(fe,"linkAccount","onSuccess",{user:t,linkMethod:be.current,linkedAccount:n})}catch(t){throw O(!1),Ns(fe,"linkAccount","onError",t.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:n,oAuthTokens:r}=await a.authenticate()),be.current=e.provider;let i=Ke(t);t&&i&&void 0!==n&&Ns(fe,"login","onComplete",{user:t,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:be.current,loginAccount:i})}catch(e){throw O(!1),Y({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}return b(t),N(n||!1),y(!0),O(!1),Y({status:"done"}),r&&t&&Ns(fe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{let i=new Qn({email:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{be.current="email",$({status:"sending-code"}),await i.sendCodeEmail({withPrivyUi:r}),$({status:"awaiting-code-input"})}catch(e){throw $({status:"error",error:e}),"login"===Ce.current?Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR):"link"===Ce.current&&Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,n)=>{let r=new er(e,t,n);a.startAuthFlow(r);try{await r.sendCodeEmail({withPrivyUi:!0})}catch(e){Ns(fe,"update","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR,{linkMethod:be.current})}},initUpdatePhone:async(e,t,n)=>{let r=new Sa(e,t,n);a.startAuthFlow(r);try{await r.sendSmsCode({withPrivyUi:!0})}catch(e){Ns(fe,"update","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR,{linkMethod:be.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{V({status:"sending-code"});let i=new Ea({phoneNumber:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{be.current="sms",await i.sendSmsCode({withPrivyUi:r}),V({status:"awaiting-code-input"})}catch(e){throw V({status:"error",error:e}),"login"===Ce.current?Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR):"link"===Ce.current&&Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await(a.authFlow?.sendCodeEmail({withPrivyUi:!0}))},resendSmsCode:async()=>{await(a.authFlow?.sendSmsCode({withPrivyUi:!0}))},loginWithCode:async e=>{let t,n;function r(e){a.authFlow instanceof Qn?$(e):a.authFlow instanceof Ea&&V(e)}if(r({status:"submitting-code"}),!u){let e=new $e;throw r({status:"error",error:e}),e}if(a.authFlow instanceof Qn)a.authFlow.meta.emailCode=e.trim();else{if(!(a.authFlow instanceof Ea)){let e=new k("Must initialize a passwordless code flow first");throw r({status:"error",error:e}),e}a.authFlow.meta.smsCode=e.trim()}let i=await Jb();if("link"===Ce.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:be.current}),e}else if("update"===Ce.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),Ns(fe,"update","onError",e.privyErrorCode||U.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:be.current}),e}else try{({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw r({status:"error",error:e}),Ns(fe,"login","onError",e.privyErrorCode||U.UNKNOWN_AUTH_ERROR),e}let o=t||f;b(o||null),N(n||!1),y(!0),r({status:"done"});let s=null;return a.authFlow instanceof Qn?s=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:a.authFlow instanceof Ea&&(s=o?.linkedAccounts.find((({type:e})=>"phone"===e))||null),{user:o,isNewUser:n||!1,wasAlreadyAuthenticated:!!i,linkedAccount:s}},generateSiweMessage:async({address:e,chainId:t,captchaToken:n})=>{Ce.current="link",be.current="siwe",q({status:"generating-message"});let r=await a.generateSiweNonce({address:e,captchaToken:n});return q({status:"awaiting-signature"}),Aa({address:e,chainId:t.replace("eip155:",""),nonce:r})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let n=await a.generateSiweNonce({address:e});return Aa({address:e,chainId:t.replace("eip155:",""),nonce:n})},linkSmartWallet:async({message:e,signature:t,smartWalletType:n})=>{let r;r=await a.linkSmartWallet({message:e,signature:t,smartWalletType:n}),b((r=await Xe.refreshSessionAndUser()??r)||f||null)},linkWithSiwe:async({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i})=>{let o;We("siwe");let s=null;try{q({status:"submitting-signature"}),o=await a.linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i}),o=await Xe.refreshSessionAndUser()??o,q({status:"done"}),(s=Ke(o)||null)&&Ns(fe,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:s})}catch(e){throw Ns(fe,"linkAccount","onError",e.privyErrorCode||U.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),Ce.current=null,be.current=null,q({status:"error",error:e}),e}let l=o||f;return b(l||null),Ce.current=null,be.current=null,{user:l,linkedAccount:s}},refreshSessionAndUser:async()=>{let e=await a.getAuthenticatedUser();return y(!!e),b(e),e},walletProxy:Q,createAnalyticsEvent:({eventName:e,payload:t,timestamp:n})=>a.createAnalyticsEvent({eventName:e,payload:t,timestamp:n}),acceptTerms:async()=>{let e=await a.acceptTerms();return b(e),e},getUsdTokenPrice:e=>a.getUsdTokenPrice(e),getUsdPriceForSol:()=>a.getUsdPriceForSol(),getSplTokenMetadata:e=>a.getSplTokenMetadata(e),recoverPrimaryWallet:async e=>new Promise((async(t,n)=>{if(!f)return void t(!0);let r=Ja(e?.user??f),i=Ga(e?.user??f)||qa(e?.user??f)||Ka(e?.user??f);if(!r&&!i)return void t(!0);let o=await Jb();if(!o||!Q||!i)return void n(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:s,entropyIdVerifier:l}=Qa(f,i);try{await Q.connect({accessToken:o,entropyId:s,entropyIdVerifier:l}),t(!0)}catch(e){Ul(e)&&"privy"===i.recoveryMethod?(a.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:i.address}}),(await Q.recover({entropyId:s,entropyIdVerifier:l,accessToken:o})).entropyId||n(Error("Unable to recover wallet")),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:i.address}}),t(!0)):Ul(e)&&"privy"!==i.recoveryMethod?(ae({recoverWallet:{entropyId:s,entropyIdVerifier:l,onFailure:n,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:i.recoveryMethod,action:"recover"}}),Te(Ld(i.recoveryMethod))):n(e)}})),createEmbeddedSolanaWallet:async e=>{e&&"target"in e&&(e=void 0);let t=await Xe.refreshSessionAndUser();if(!t)throw Ns(fe,"createWallet","onError",U.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return Fe(t,15e3,e)},exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!g||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));let i=e?.address?Za(f,e.address):Ha(f),o=Ga(f);if(!i||!o)return void r(Error("Must have a Privy wallet before exporting"));let{entropyId:s,entropyIdVerifier:l}=Qa(f,i);await Jb()&&Q?Q?(ae({connectWallet:{recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,entropyId:s,entropyIdVerifier:l,onCompleteNavigateTo:uw,onFailure:r,shouldForceMFA:!0},keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:i,primaryWallet:o,onSuccess:t,onFailure:r}}),Te(fw)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),setReadyToTrue:e=>{m(!0),ie?.(e)},updateWallets:()=>Le(),fundWallet:async(e,t)=>{ae({funding:lw({address:e,appConfig:te,fundWalletConfig:t,methodScreen:nw})}),Te(nw)},openModal:Te,requestFarcasterSignerStatus:async e=>{let t=await Jb(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Q||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let r=await a.requestFarcasterSignerStatus(e);return"approved"===r.status&&b(await a.getAuthenticatedUser()||f||null),r},connectCoinbaseSmartWallet:async()=>{te.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let e=a.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||a.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Se(e);await Ee("coinbase_wallet","coinbase_smart_wallet")},initiateAccountTransfer:async({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:i,telegramWebAppData:o,farcasterEmbeddedAddress:s,oAuthUserInfo:l})=>{let c=await a.sendAccountTransferRequest({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:i,telegramWebAppData:o,farcasterEmbeddedAddress:s,oAuthUserInfo:l});return b(c),c}};Zb=Xe.recoverPrimaryWallet,Gb=Xe.recoverPrimaryWallet;let Qe=s((()=>({wallets:x,ready:ce&&we})),[x,ce,we]),et=a.authFlow instanceof Oa,tt=!te.headless&&te.captchaEnabled&&!g&&(u||et);/*#__PURE__*/return t(ml.Provider,{value:Je,children:/*#__PURE__*/t(_s.Provider,{value:fe,children:/*#__PURE__*/t(ag.Provider,{value:Qe,children:/*#__PURE__*/t(Pa,{...te,children:/*#__PURE__*/e(je.Provider,{value:Xe,children:[/*#__PURE__*/t(Ws,{children:/*#__PURE__*/e(xu,{data:re,setModalData:ae,setInitialScreen:P,initialScreen:M,authenticated:g,open:c,children:[n.children,tt&&/*#__PURE__*/t(Hu,{delayedExecution:!1}),/*#__PURE__*/t(ug,{theme:{...te.appearance.palette||{}}}),!te.render.standalone&&/*#__PURE__*/t(xg,{open:c})]})}),/*#__PURE__*/t(Ug,{appId:n.appId,appClientId:n.clientId,clientAnalyticsId:a.clientAnalyticsId,origin:a.apiUrl,mfaMethods:f?.mfaMethods,mfaPromise:ge,mfaSubmitPromise:ye,onLoad:ee,onLoadFailed:()=>null}),te.loginConfig.telegramAuthConfiguration&&
|
|
27
27
|
/*#__PURE__*/t(ys,{$if:!0,children:/*#__PURE__*/t(Ig,{scriptHost:n.apiUrl||Nr,botUsername:te.loginConfig.telegramAuthConfiguration.botName})})]})})})})})};export{Uh as $,Qv as A,Ku as B,Ma as C,xv as D,Ni as E,yy as F,Wu as G,yi as H,Co as I,xo as J,gp as K,xg as L,Ay as M,dr as N,Rs as O,ml as P,ry as Q,ny as R,cm as S,qu as T,Bo as U,Or as V,Qr as W,Bs as X,po as Y,Pd as Z,Md as _,Wa as a,Qh as a0,Ep as a1,Au as a2,Vs as a3,Mr as a4,Ti as a5,so as a6,zg as a7,Iy as a8,iy as a9,qy as aa,Xg as ab,Oy as ac,zy as ad,is as ae,Wy as af,rr as ag,lo as ah,hy as ai,cy as aj,Tu as ak,sv as al,lv as am,kv as an,py as ao,cw as ap,nw as aq,Qa as ar,fv as as,fw as at,Kv as au,Ro as b,gl as c,ka as d,Lo as e,fy as f,Ms as g,yl as h,wl as i,$a as j,ig as k,lr as l,aC as m,Yb as n,Hu as o,_u as p,Ii as q,cg as r,xa as s,wb as t,Ss as u,Rl as v,Fl as w,Ll as x,ju as y,Lu as z};
|