@privy-io/react-auth 2.15.0 → 2.16.0
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/extended-chains.js +1 -1
- package/dist/cjs/farcaster.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{internal-context-CrTqNb_c.js → internal-context-vhWXhsPy.js} +1 -1
- package/dist/cjs/{privy-provider-BH0F7-54.js → privy-provider-BwT4_Q1p.js} +5 -5
- package/dist/cjs/{smart-wallets-DvmTShkt.js → smart-wallets-BBYteGIQ.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/{use-sign-with-user-signer-h5JGn1CY.js → use-sign-with-user-signer-Btd3Mi-j.js} +1 -1
- package/dist/cjs/{useActiveWallet-XehugIB6.js → useActiveWallet-geVurizV.js} +1 -1
- package/dist/cjs/{useFundWallet-hXyQXO7U.js → useFundWallet-Do4NJHE-.js} +1 -1
- package/dist/dts/extended-chains.d.mts +1 -1
- package/dist/dts/extended-chains.d.ts +1 -1
- package/dist/dts/farcaster.d.mts +1 -1
- package/dist/dts/farcaster.d.ts +1 -1
- package/dist/dts/index.d.mts +35 -5
- package/dist/dts/index.d.ts +35 -5
- package/dist/dts/smart-wallets.d.mts +1 -1
- package/dist/dts/smart-wallets.d.ts +1 -1
- package/dist/dts/solana.d.mts +4 -4
- package/dist/dts/solana.d.ts +4 -4
- package/dist/dts/{types-BVjRQyBr.d.mts → types-CH4HSSkH.d.mts} +7 -0
- package/dist/dts/{types-BVjRQyBr.d.ts → types-CH4HSSkH.d.ts} +7 -0
- package/dist/dts/ui.d.mts +2 -1
- package/dist/dts/ui.d.ts +2 -1
- package/dist/dts/{useSolanaWallets-B9ju3nTn.d.mts → useSolanaWallets-NCQrusNU.d.mts} +1 -1
- package/dist/dts/{useSolanaWallets-B9ju3nTn.d.ts → useSolanaWallets-NCQrusNU.d.ts} +1 -1
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/extended-chains.mjs +1 -1
- package/dist/esm/farcaster.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{internal-context-Bxhby7Hv.mjs → internal-context-De1jxnac.mjs} +1 -1
- package/dist/esm/{privy-provider-DyqReHyu.mjs → privy-provider-9dA1clzB.mjs} +5 -5
- package/dist/esm/{smart-wallets-BuJFWcoC.mjs → smart-wallets-BODPu_tJ.mjs} +1 -1
- package/dist/esm/smart-wallets.mjs +1 -1
- package/dist/esm/solana.mjs +1 -1
- package/dist/esm/ui.mjs +2 -2
- package/dist/esm/{use-sign-with-user-signer-CEyk1z8w.mjs → use-sign-with-user-signer-Yg0Gn-gB.mjs} +1 -1
- package/dist/esm/{useActiveWallet-CKb44UC5.mjs → useActiveWallet-jVmO0lCL.mjs} +1 -1
- package/dist/esm/{useFundWallet-BjWNYKHD.mjs → useFundWallet-CZq0dDAM.mjs} +1 -1
- package/package.json +4 -4
|
@@ -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 h,useReducer as p,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 C,isAddress as b,isHex as k}from"viem/utils";import T,{ProviderErrors as x,DEFAULT_SUPPORTED_CHAIN_IDS as A,rpc as I,dedupeSupportedChains as _,DEFAULT_SUPPORTED_CHAINS as E,mainnet as S,addToDefaultChains as N,create as M,countryCodesAndNumbers as P,validatePhoneNumber as W,phoneNumberTypingFormatter as U,getPlaceholderPhoneNumber as O,getCountryCallingCode as L,getPhoneCountryCodeAndNumber as R,formatPhoneNumber as F,toObjectKeys as D,arbitrum as B,avalanche as z,base as $,celo as j,linea as V,optimism as H,polygon as q,zora as K,SolanaUsdcAddressMap as Z,UsdcAddressMap as Y,formatWalletAddress as G,getCoinbaseOnRampUrl as J,chainToMoonpayCurrency as Q,isSupportedChainIdForMoonpay as X,isSupportedChainIdForCoinbaseOnramp as ee,sepolia as te,optimismSepolia as ne,polygonAmoy as re,baseSepolia as ae,avalancheFuji as ie,arbitrumSepolia as oe,formatTokenAmount as se,SolanaClient as le,formatWeiAmount as ce,lastFourDigits as de}from"@privy-io/js-sdk-core";import{P as he,p as pe,f as ue,b as me,c as ge,u as ye,d as fe,e as we,g as ve,h as Ce,i as be,o as ke,a as Te,j as xe,k as Ae,l as Ie,m as _e,n as Ee,q as Se,r as Ne,s as Me,t as Pe,v as We,w as Ue,x as Oe,y as Le,z as Re,A as Fe,B as De,C as Be,D as ze,E as $e,F as je,G as Ve,H as He,I as qe,J as Ke,K as Ze,L as Ye,M as Ge,N as Je,O as Qe,Q as Xe,R as et,S as tt,T as nt,U as rt,V as at,W as it,X as ot,Y as st,Z as lt,_ as ct,$ as dt,a0 as ht,a1 as pt,a2 as ut,a3 as mt,a4 as gt,a5 as yt,a6 as ft,a7 as wt,a8 as vt,a9 as Ct,aa as bt,ab as kt,ac as Tt,ad as xt,ae as At,af as It,ag as _t,ah as Et,ai as St}from"./paths-j39vuJt8.mjs";import{a as Nt,n as Mt,u as Pt,I as Wt}from"./internal-context-Bxhby7Hv.mjs";import{createPublicClient as Ut,http as Ot,formatEther as Lt,formatUnits as Rt,toHex as Ft,isHex as Dt,getAddress as Bt,parseEther as zt,createWalletClient as $t,custom as jt,publicActions as Vt,encodeFunctionData as Ht,isAddress as qt,hexToString as Kt,decodeFunctionData as Zt,decodeAbiParameters as Yt}from"viem";import{v4 as Gt}from"uuid";import*as Jt from"jose";import{base64url as Qt}from"jose";import{h as Xt,c as en,i as tn,u as nn,P as rn,j as an,g as on,b as sn,e as ln,k as cn,a as dn,d as hn,l as pn,m as un}from"./use-sign-with-user-signer-CEyk1z8w.mjs";import mn from"eventemitter3";import{createCoinbaseWalletSDK as gn}from"@coinbase/wallet-sdk";import{toViemTransactionSerializable as yn,STRING_TO_NUMBER_TXN_TYPE as fn}from"@privy-io/ethereum";import{Turnstile as wn}from"@marsidev/react-turnstile";import{styled as vn,css as Cn,createGlobalStyle as bn,keyframes as kn}from"styled-components";import Tn from"tinycolor2";import xn from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import An from"@heroicons/react/24/outline/FingerPrintIcon";import In from"@heroicons/react/24/outline/PhoneIcon";import _n from"@heroicons/react/24/outline/ShieldCheckIcon";import En from"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import Sn from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Nn from"@heroicons/react/24/outline/XMarkIcon";import Mn from"@heroicons/react/24/outline/ChevronDownIcon";import Pn from"@heroicons/react/24/outline/CalendarIcon";import Wn from"@heroicons/react/24/outline/ExclamationTriangleIcon";import{Transition as Un,Dialog as On,TransitionChild as Ln,DialogPanel as Rn,Menu as Fn,MenuButton as Dn,MenuItems as Bn,MenuItem as zn}from"@headlessui/react";import{EthereumProvider as $n,OPTIONAL_EVENTS as jn,OPTIONAL_METHODS as Vn}from"@walletconnect/ethereum-provider";import{create as Hn}from"zustand";import qn from"fast-password-entropy";import*as Kn from"secure-password-utilities";import{DEFAULT_WORDLIST as Zn}from"secure-password-utilities/wordlists";import Yn from"@heroicons/react/24/outline/UserCircleIcon";import Gn from"@heroicons/react/24/outline/EnvelopeIcon";import Jn from"@heroicons/react/20/solid/CheckIcon";import Qn from"@heroicons/react/24/outline/WalletIcon";import Xn from"@heroicons/react/24/outline/CheckIcon";import er from"@heroicons/react/24/outline/Square2StackIcon";import tr from"@heroicons/react/24/outline/ExclamationCircleIcon";import nr from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import rr from"@heroicons/react/24/solid/DocumentCheckIcon";import ar from"@heroicons/react/24/solid/XCircleIcon";import ir from"@heroicons/react/24/solid/CheckCircleIcon";import or from"qrcode";import sr from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import lr from"@heroicons/react/24/outline/ChevronRightIcon";import cr from"@heroicons/react/24/outline/LockClosedIcon";import dr from"@heroicons/react/24/outline/PencilSquareIcon";import hr from"@heroicons/react/24/outline/ArrowPathIcon";import pr from"@heroicons/react/24/outline/EyeIcon";import ur from"@heroicons/react/24/outline/EyeSlashIcon";import mr from"@heroicons/react/24/outline/KeyIcon";import gr from"@heroicons/react/24/outline/ArrowDownTrayIcon";import yr from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import fr from"@heroicons/react/24/outline/DocumentDuplicateIcon";import wr from"@heroicons/react/24/solid/LockClosedIcon";import vr from"@heroicons/react/24/outline/CheckCircleIcon";import Cr from"@heroicons/react/24/outline/InformationCircleIcon";import br from"@heroicons/react/24/outline/CreditCardIcon";import kr from"@heroicons/react/24/outline/QrCodeIcon";import Tr from"@heroicons/react/24/outline/GlobeAltIcon";import{ofetch as xr}from"ofetch";import{ChevronDownIcon as Ar,ArrowRightIcon as Ir}from"@heroicons/react/24/outline";import _r from"@heroicons/react/24/outline/ClipboardDocumentIcon";import Er from"@heroicons/react/24/outline/CloudArrowUpIcon";import Sr from"@heroicons/react/24/outline/NoSymbolIcon";import Nr from"@heroicons/react/24/outline/ClockIcon";import Mr from"@heroicons/react/24/outline/TrashIcon";import Pr from"@heroicons/react/24/solid/CheckBadgeIcon";import Wr from"@heroicons/react/24/solid/IdentificationIcon";import Ur from"@heroicons/react/24/outline/MinusCircleIcon";import Or from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import Lr from"@heroicons/react/24/solid/ShieldCheckIcon";import Rr from"js-cookie";function Fr(e){return e?{"privy-ui":"t"}:void 0}class Dr{async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new he("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(pe,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new he("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(me,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw ue(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new he("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new he("Email must be set when initialzing authentication.");let r=Fr(n);try{return await this.api.post(ge,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw ue(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class Br extends Dr{async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new he("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(ye,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw ue(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class zr{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 $r(){try{let e="privy:__session_storage__test",t=new zr;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var jr="undefined"!=typeof window&&window.localStorage?new zr: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 Vr=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,Hr=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==Vr(e))return!1;if(e.providers)for(let t of e.providers)if(!Hr(t))return!1;return!0},qr=()=>{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},Kr=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new fe(`Unsupported chainId ${e}`,4901);return Ut({transport:Ot(Zr(i,n,r.appId)),chain:i})},Zr=(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 fe(`No RPC url found for ${a}`);return r},Yr=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,}))$/),Gr=(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)}`},Jr=(e,t=3,n=4)=>Gr(e,t,n,"solana"),Qr=e=>new Promise((t=>setTimeout(t,e)));const Xr=(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 Qr(n)}o||i(Error("Exceeded max attempts before resolving function"))}))},ea=(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},ta=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),na=e=>"string"==typeof e?e:"0x"+e.toString(16);async function ra({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=Vr(e);if(!a.some((e=>e.info.name===t))){if(Hr(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?.config?.preference?.options))){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 aa(e){return`eip155:${String(Number(e))}`}const ia=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new fe(`Unsupported chainId ${e}`,4901);return Zr(i,n,r)},oa=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 sa=e=>e?.map((e=>({signer_id:e.signerId,override_policy_ids:e.policyIds}))),la=["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 ca(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let da="WALLETCONNECT_DEEPLINK_CHOICE";function ha(e){return e.startsWith("http://")||e.startsWith("https://")}function pa(e,t){if(ha(e))return ua(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 ua(e,t){if(!ha(e))return pa(e,t);let n=e;return n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function ma(e,t){window.open(e,t,"noreferrer noopener")}class ga{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 ya{get meta(){return this._meta}async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.channelToken)throw new he("Auth flow must be initialized first");try{let e=await this.api.post(we,{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 he("No response from authentication");return e}catch(e){throw ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(ve,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw ue(e)}}async _startChannelOnce(){if(!this.api)throw new he("Auth flow has no API instance");let e=await this.api.post(Ce,{token:this.captchaToken});g&&!y&&e.connect_uri&&ma(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new he("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.channelToken)throw new he("Auth flow must be initialized first");let e=await this.api.get(be,{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 ga(this._startChannelOnce.bind(this)),this.pollForReady=new ga(this._pollForReady.bind(this)),this._meta.disableSignup=t}}const fa="https://auth.privy.io",wa=1400,va=2500,Ca=4e3,ba="2.15.0",ka="privy:token",Ta="privy-token",xa="privy:refresh_token",Aa="privy:pat",Ia="privy:id_token",_a="privy-id-token",Ea="privy-session",Sa="privy:caid",Na=e=>`privy:guest:${e}`,Ma=e=>`privy:cross-app:${e}`,Pa="privy:state_code",Wa="privy:code_verifier",Ua="privy:headless_oauth",Oa="privy:oauth_disable_signup",La=e=>`privy:wallet:${e}`,Ra="privy:connectors",Fa="privy:connections",Da=12e4,Ba=3e4,za="https://api.moonpay.com/v1",$a="https://api.moonpay.com/v1",ja="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Va="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";function Ha(e){return crypto.getRandomValues(new Uint8Array(e))}function qa(){return Qt.encode(Ha(36))}function Ka(){return qa()}async function Za(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 Qt.encode(t)}}class Ya{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new he("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new he("User denied confirmation during OAuth flow");let e=function(){let e=jr.get(Wa);if(!e)throw new he("Authentication error.");return e}();try{let t=await this.api.post(ke,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return jr.del(Wa),jr.del(Ua),jr.del(Oa),t}catch(e){let t=ue(e);if(t.privyErrorCode)throw new he(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new he("Invalid code during oauth flow.",void 0,Te.OAUTH_USER_DENIED);throw new he("Invalid code during OAuth flow.",void 0,Te.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new he("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new he("User denied confirmation during OAuth flow");let e=jr.get(Wa);if(!e)throw new he("Authentication error.");try{let t=await this.api.post(xe,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return jr.del(Wa),t}catch(e){throw ue(e)}}async getAuthorizationUrl(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.provider)throw new he("Provider must be set when initializing OAuth authentication.");let e=qa();jr.put(Wa,e);let t=Ka();jr.put(Pa,t);let n=await Za(e);this.meta.withPrivyUi||jr.put(Ua,!0),this.meta.disableSignup?jr.put(Oa,!0):jr.del(Oa);let r=Fr(this.meta.withPrivyUi);try{return await this.api.post(Ae,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...r}})}catch(e){throw ue(e)}}constructor(e){this.meta=e}}function Ga(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Ja=({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"})]}),Qa=({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"})})})]}),Xa=({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"})}),ei=({style:e})=>/*#__PURE__*/t(Tr,{style:{color:"var(--privy-color-error)",...e}}),ti=({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 ni(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 ri({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 ai(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 ii(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 oi=({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 si={google:{name:"Google",component:ti},discord:{name:"Discord",component:Qa},github:{name:"Github",component:Xa},linkedin:{name:"LinkedIn",component:ri},twitter:{name:"Twitter",component:oi},spotify:{name:"Spotify",component:ai},instagram:{name:"Instagram",component:ni},tiktok:{name:"Tiktok",component:ii},apple:{name:"Apple",component:Ja}};const li=e=>e in si?si[e]:{name:"Unknown",component:ei};function ci(){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:!jr.get(Ua),popupFlow:null!==window.opener&&a,disableSignup:!!jr.get(Oa)}}function di(){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"),jr.del(Pa),window.history.replaceState({},"",e)}class hi{async initRegisterFlow(e){if(!this.api)throw new he("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 he("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new he("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 he("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new he("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(Ie,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new he("Passkey request timed out or rejected by user.",void 0,Te.PASSKEY_NOT_ALLOWED);throw ue(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new he("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new he("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(_e,{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 he("Passkey request timed out or rejected by user.",void 0,Te.PASSKEY_NOT_ALLOWED);throw ue(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new he("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new he("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(Ee,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new he("Passkey request timed out or rejected by user.",void 0,Te.PASSKEY_NOT_ALLOWED);throw ue(e)}}async _initRegisterOnce(e){if(!this.api)throw new he("Auth flow has no API instance");let t=Fr(e);return await this.api.post(Se,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new he("Auth flow has no API instance");let t=Fr(e);return await this.api.post(Ne,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new he("Auth flow has no API instance");return await this.api.post(Me,{})}_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 ga(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new ga(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new ga(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}const pi=({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 ui{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 he("SiweFlow has no client instance");try{if(this.preparedMessage&&this.signature)return await this.client.authenticateWithSiweInternal({message:this.preparedMessage,signature:this.signature,chainId:this.wallet?.chainId,walletClientType:this.wallet?.walletClientType,connectorType:this.wallet?.connectorType,mode:this._meta.disableSignup?"no-signup":"login-or-sign-up"});if(!this.wallet)throw new he("SiweFlow has no wallet instance");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 ue(e)}}async link(){if(!this.client)throw new he("SiweFlow has no client instance");try{if(!this.wallet)throw new he("SiweFlow has no wallet instance");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 ue(e)}}async sign(){if(!this.client)throw new he("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new he("Could not prepare SIWE message");if(!this.wallet)throw new he("SiweFlow has no wallet instance");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new he("SiweFlow has no client instance");if(!this.wallet)throw new he("UI SiweFlow has no wallet instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new he("SiweFlow has no client instance");if(!this.wallet)throw new he("SiweFlow has no wallet instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=pi({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1,a){this._meta={disableSignup:!1},this.getNonceOnce=new ga(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=n,this.client=e,this._meta.disableSignup=r,this.preparedMessage=a?.message,this.signature=a?.signature}}const mi=(...e)=>{if("undefined"==typeof Buffer)throw new he("Buffer is not defined.",void 0,Te.BUFFER_NOT_DEFINED);return Buffer.from(...e)},gi=({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\n${`You 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`;class yi{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup,messageType:this._meta.messageType}}set messageType(e){this._meta.messageType=e}async authenticate(){if(!this.client)throw new he("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",messageType:this.meta.messageType})}catch(e){throw ue(e)}}async link(){if(!this.client)throw new he("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,messageType:this.meta.messageType})}catch(e){throw ue(e)}}async sign(){let e,t;if(!this.client)throw new he("SiwsFlow has no client instance");await this.buildMessage();let n="transaction"===this.meta.messageType;if(!this.preparedMessage)throw new he("Could not prepare SIWS message");if(!n&&!this.wallet.signMessage||n&&!this.wallet.signTransaction)throw new he("Wallet does not support the necessary signing methods");if(n&&this._siwsTransactionMethods){let n=await this.wallet.signTransaction(this._siwsTransactionMethods.deserializeTransactionFromB64String(this.preparedMessage));e=n.serialize().toString("base64"),t=mi(n.signatures[0]?.signature??Buffer.from("missing signature")).toString("base64")}else e=this.preparedMessage,t=mi(await this.wallet.signMessage(mi(this.preparedMessage))).toString("base64");return{message:e,signature:t}}async _getNonceOnce(){if(!this.client)throw new he("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new he("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),"transaction"===this.meta.messageType&&this._siwsTransactionMethods?this.preparedMessage=this._siwsTransactionMethods.prepareSiwsTransactionWithMemo({address:e,nonce:this.nonce}):this.preparedMessage=gi({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1,a="plain",i){this._meta={disableSignup:!1,messageType:"plain"},this.getNonceOnce=new ga(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=n,this.client=t,this._meta.disableSignup=r,this._meta.messageType=a,this._siwsTransactionMethods=i}}class fi{async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new he("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Pe,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new he("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(We,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw ue(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new he("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new he("phone nNumber must be set when initialzing authentication.");let r=Fr(n);try{return await this.api.post(Ue,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw ue(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:n}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:n??!1}}}class wi extends fi{async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new he("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(Oe,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw ue(e)}}constructor(e,t,n){super({phoneNumber:t,captchaToken:n}),this.meta={phoneNumber:t,captchaToken:n,oldPhoneNumber:e,disableSignup:!1}}}const vi=/*#__PURE__*/c({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:Nt,setError:Nt,setExecuting:Nt,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:Nt,reset:Nt,execute:Nt});class Ci extends Le{constructor(e,t,n){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=n}}const bi=({children:e,id:n,captchaSiteKey:r,captchaEnabled:a})=>{let l=i(null),[c,d]=o(),[h,p]=o(),[u,m]=o(!1),g=s((()=>a?u||c||h?!u||c||h?c&&!h?{status:"success",token:c}:h?{status:"error",error:h}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[a,c,h,u]);/*#__PURE__*/return t(vi.Provider,{value:{...g,ref:l,enabled:a,siteKey:r,appId:n,setToken:d,setError:p,setExecuting:m,remove(){a&&(l.current?.remove(),m(!1),p(void 0),d(void 0))},reset(){a&&(l.current?.reset(),m(!1),p(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 Ci("Captcha failed",null,Te.CAPTCHA_TIMEOUT)}}},children:e})},ki=()=>l(vi);class Ti{async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(Re,{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 ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(Fe,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw ue(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function xi(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===Te.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===Te.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===Te.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===Te.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===Te.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===Te.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===Te.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof Ci&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function Ai(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function Ii(){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 _i{static parse(e){try{return new _i(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return Jt.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=Jt.decodeJwt(e)}}class Ei extends _i{static parse(e){try{return new Ei(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}let Si=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 Ni=(e,t)=>{if(t?.imported)return Si(t);let n=Xt(e);if(!n)throw Error("Failed to find primary wallet");return Si(n)},Mi=({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"})]});class Pi extends fe{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class Wi extends fe{constructor(){super("User rejected connection"),this.type="wallet_error"}}const Ui=e=>e instanceof fe?e:e?.code?new Li(e):new fe("Unknown connector error",e);class Oi extends Le{constructor(e,t,n){super(e),this.type="provider_error",this.code=t,this.data=n}}class Li extends Oi{constructor(e){super(e.message,e.code,e.data);let t=Object.values(x).find((t=>t.eipCode===e.code));this.details=t||x.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=x.E32002_CONNECTION_ALREADY_PENDING:this.details=x.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=x.E32002_WALLET_LOCKED))}}const Ri={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},...x};function Fi(e){return"ethereum"===e.type}function Di(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&&Fi(r)&&Fi(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 Bi extends mn{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const zi=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||Da;let $i;function ji(e){return"ethereum"===e.chainType}class Vi extends Bi{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 fe("Wallet is not currently connected.");let o=this.wallets.find((t=>v(t.address)===v(e)))?.chainId;if(!o)throw new fe("Unable to determine current chainId.");if("number"==typeof n?(r=`0x${n.toString(16)}`,i=n):(r=n,i=Number(n)),o===aa(r))return;let s=this.chains.find((e=>e.id===i));if(!s)throw new fe(`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 Qr(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 fe(`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 fe("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await a())throw new fe("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 Xr((()=>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=jr.get(La(a));this.chains.find((t=>t.id===Number(e)))||(jr.del(La(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 Xr((()=>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=aa(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))}Di(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:[C(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=aa(e),"privy"===this.walletClientType&&jr.put(La(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 Qr(500),this.syncAccounts()},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=n,this.rpcConfig=r,this.rpcTimeoutDuration=zi(r,e),this.connected=!1,this.initialized=!1}}class Hi{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 fe(`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 Ui(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 Pi,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||Da,this._subscriptions=[]}}let qi=[1,11155111,137,10,8453,84532,42161,7777777,43114,56];class Ki extends Vi{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 fe("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw Ui(e)}}updateConnectionPreference(e){this.coinbaseWalletConfig={...this.coinbaseWalletConfig,preference:{...this.coinbaseWalletConfig.preference,options:e}},this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",$i=gn({...this.coinbaseWalletConfig}),this.proxyProvider.setWalletProvider($i.getProvider())}constructor(e,t,n,r){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Hi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.coinbaseWalletConfig={...r,appChainIds:[t.id].concat(e.map((e=>e.id)))},this.walletClientType="smartWalletOnly"===this.coinbaseWalletConfig.preference?.options?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!$i){let e="eoaOnly"!==this.coinbaseWalletConfig.preference?.options?(this.coinbaseWalletConfig.appChainIds??[]).filter((e=>!qi.includes(e))):[];e.length>0&&!e.every((e=>A.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${e.join(", ")}`),$i=gn(this.coinbaseWalletConfig)}this.proxyProvider.setWalletProvider($i.getProvider())}}const Zi=({...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 Yi extends Vi{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:[na(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Zi,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 Gi=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];class Ji extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}class Qi extends mn{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Ji(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Sb()||!this.address)throw new Ji("Disconnected",4900);let{hash:n}=await Wb(t,{address:this.address});return n}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Ji(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Sb()||!this.address)throw new Ji("Disconnected",4900);let{signature:n}=await Pb(t,{address:this.address});return n}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new Ji(`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 Ji(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Kr(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 Nb({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 Mb(oa(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:na(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...yn(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 na(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=>Gi.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await Sb();if(await Ub({address:this.address}),!t||!this.address)throw new Ji("Disconnected",4900);try{let n={method:e.method,params:e.params},r=this.walletAccount;return r&&en(r)?this.handleWalletApiRequest(n,r,t):(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:n})).response.data}catch(e){throw console.error(e),new Ji("Disconnected",4900)}}}async handleWalletApiRequest(e,t,n){let r=this.privyClient;if(!r)throw new Ji("Disconnected",4900);if("secp256k1_sign"===e.method){let a=await I(r,(async({message:e})=>this.walletProxy.signWithUserSigner({accessToken:n,message:e})),{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:e.params[0]}});if("secp256k1_sign"!==a.method)throw new Ji(`Invalid params for ${e.method}`,4200);return a.data.signature}throw new Ji(`Method not supported: ${e.method}`,4200)}constructor({walletProxy:e,address:t,entropyId:n,entropyIdVerifier:r,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l,privyClient:c,walletAccount:d}){super(),this.walletProxy=e,this.address=t,this.entropyId=n,this.entropyIdVerifier=r,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Kr(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=zi(a,"privy"),this.appId=o,this.walletIndex=l,this.privyClient=c,this.walletAccount=d}}class Xi extends Vi{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 Hi(void 0,Da),this.id=e,this.name=t,this.icon=n,this.connectorType=r}}const eo=({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"})}),to=({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"})]}),no=({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 ro(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var ao=0;class io extends Vi{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 fe("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Ui(e)}}constructor(e,t,n,r,a){super(a||"unknown",e,t,n),this.connectorType="injected",this.proxyProvider=new Hi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=r;let i=r.provider;this.proxyProvider.setWalletProvider(i)}}var oo="__private_"+ao+++"__walletBranding";class so extends Vi{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 ro(this,oo)[oo]??{name:"Browser Extension",icon:eo,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 fe("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Ui(e)}}constructor(e,t,n,r,a){super(a??"unknown",e,t,n),Object.defineProperty(this,oo,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Hi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(r),"metamask"===a?ro(this,oo)[oo]={name:"MetaMask",icon:to,id:"io.metamask"}:"phantom"===a&&(ro(this,oo)[oo]={name:"Phantom",icon:no,id:"phantom"})}}class lo extends io{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 fe("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Ui(e)}}}const co=["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","binance","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"],ho=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=uo({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=uo({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=uo({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="+uo({client:this.client,isSolana:e,connectOnly:t}))}}});function po({connectorType:e,walletClientType:t}){for(let n of co)if(e===n||t===n)return ho[n]}function uo({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 mo=()=>{let e=jr.get(Fa);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 go=["phantom","glow","solflare","backpack","okx_wallet","walletconnect"];function yo(e){return"solana"===e.chainType}function fo(e){return"solana"===e.type}class wo extends Bi{get isInstalled(){return"Installed"===this.adapter.readyState}get wallet(){return this.adapter.wallet}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:Mt(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:n??Mt(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:r??Mt(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:a??Mt(`${this.walletClientType||""} wallet does not support 'signTransaction'`),signAllTransactions:i??Mt(`${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||!go.includes(this.walletClientType))&&("phantom"!==this.walletClientType||mo().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 Ui(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 vo extends wo{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 Hi(void 0,Da),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 Co=Hn((()=>({listings:[]}))),bo=Co.setState,ko=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return Co.getState().listings.find((({homepage:e})=>{let n;try{n=new URL(e).hostname}catch(e){return!1}return t.includes(n)}))},To=e=>Co((({listings:t})=>t.find((({slug:t})=>xo(t)===xo(e)))));function xo(e){return"cryptocom"===e?"cryptocom-defi":"binance"===e?"binance-defi":e.replace(/[-_]wallet$/,"")}function Ao({src:e,...n}){/*#__PURE__*/return t("img",{src:e,...n,style:{display:"none"}})}const Io={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 _o=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","binance"]),Eo=e=>_o.has(e),So=(e,t,n)=>n.indexOf(e)===t;const No=792703809,Mo="11111111111111111111111111111111";function Po(e){return e.includes("testnet")?"testnet":e.includes("devnet")?"devnet":"mainnet-beta"}function Wo(e,t){return`https://explorer.solana.com/account/${e}?cluster=${t}`}let Uo="#FFFFFF";function Oo(e,t){let n=Math.max(0,Math.min(1,e.toHsl().l+t));return Tn({...e.toHsl(),l:n})}function Lo({backgroundTheme:e,accentHex:t}){let n;switch(e){case"light":n=Uo;break;case"dark":n="#1E1E1D";break;default:n=e}let r=Tn(n),a=Tn(t),i=Tn("#51BA81"),o=Tn("#FFB74D"),s=Tn("#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=Oo(r,"light"===l?-.04:.11),d=Oo(r,"light"===l?-.08:.16),h=Oo(r,"light"===l?-.88:.87),p=Oo(r,"light"===l?-.7:.75),u=Oo(r,"light"===l?-.43:.45).desaturate("light"===l?60:20),m=Oo(r,"light"===l?-.08:.25).desaturate("light"===l?60:20),g=Oo(a,.15),y=Oo(a,.25),f=Oo(a,-.06),w=Oo(a,-.6),v=Oo(s,.3),C=Oo(o,.3),b=Tn(a.getLuminance()>.5?"#040217":Uo),k=Oo(i,-.16),T=Oo(i,.4);return{colorScheme:l,background:r.toHslString(),background2:c.toHslString(),background3:d.toHslString(),foreground:h.toHslString(),foreground2:p.toHslString(),foreground3:u.toHslString(),foreground4:m.toHslString(),accent:a.toHslString(),accentLight:g.toHslString(),accentLightest:y.toHslString(),accentDark:f.toHslString(),accentDarkest:w.toHslString(),foregroundAccent:b.toHslString(),success:i.toHslString(),successDark:k.toHslString(),successLight:T.toHslString(),error:s.toHslString(),errorLight:v.toHslString(),warn:o.toHslString(),warnLight:C.toHslString()}}function Ro(e,t,n,r){let a,i,o,s,l,c,d,h,p,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"),p=t.loginMethods.includes("spotify"),u=t.loginMethods.includes("instagram"),h=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.email_auth,i=e.sms_auth,s=e.wallet_auth||e.solana_wallet_auth,l=e.google_oauth,c=e.twitter_oauth,d=e.discord_oauth,g=e.github_oauth,p=e.spotify_oauth,u=e.instagram_oauth,h=e.tiktok_oauth,m=e.linkedin_oauth,y=e.apple_oauth,f=e.farcaster_auth,w=e.telegram_auth,o=e.passkey_auth),e.passkey_auth&&(o=!0),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(o=!1);let C=[a,i].filter(Boolean),b=[l,c,d,g,p,u,h,m,y,f,w].filter(Boolean),k=[s].filter(Boolean),T=t?.loginMethods?.includes("passkey")??!1,x=e.passkeys_for_signup_enabled??!1,A=[o&&(x||T)].filter(Boolean);if(C.length+b.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.show_wallet_login_first;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||b.length+C.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 N=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&v("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let M=(({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(Eo).filter(So):e?e.filter(Eo).filter(So):Io.appearance.walletList)({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),P=(({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}),W=t?.intl?.defaultCountry??"US",{chains:U,defaultChain:O}=function({supportedChains:e,defaultChainFromConfig:t}){let n;if(e){if(0===e.length)throw Error("`supportedChains` must contain at least one chain");n=_(e)}else n=[...E];let r=e?n[0]:S,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}),L=!!t?.defaultChain,R=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,F=t?.embeddedWallets?.requireUserPasswordOnCreate,D=t?.embeddedWallets?.createOnLogin,B=R?"all-users":e.embedded_wallet_config.ethereum.create_on_login,z=e.embedded_wallet_config.solana.create_on_login,$={"mainnet-beta":{rpcUrl:"https://api.mainnet-beta.solana.com",blockExplorerUrl:"https://explorer.solana.com"},testnet:{rpcUrl:"https://api.testnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=testnet"},devnet:{rpcUrl:"https://api.devnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=devnet"}};if(t?.solanaClusters)for(let e of t.solanaClusters){let{name:t,rpcUrl:n,blockExplorerUrl:r}=e;$[t]={rpcUrl:n??$[t].rpcUrl,blockExplorerUrl:r??$[t].blockExplorerUrl}}e.solana_wallet_auth&&!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`");let j=e.telegram_auth_config?{botId:e.telegram_auth_config.bot_id,botName:e.telegram_auth_config.bot_name,linkEnabled:e.telegram_auth_config.link_enabled,seamlessAuthEnabled:e.telegram_auth_config.seamless_auth_enabled}:void 0,V=e.funding_config?{methods:e.funding_config.methods,options:e.funding_config.options,defaultRecommendedAmount:e.funding_config.default_recommended_amount,defaultRecommendedCurrency:e.funding_config.default_recommended_currency,promptFundingOnWalletCreation:e.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:e.funding_config.cross_chain_bridging_enabled}:void 0;return{id:e.id,name:e.name,allowlistConfig:{errorTitle:e.allowlist_config.error_title,errorDetail:e.allowlist_config.error_detail,errorCtaText:e.allowlist_config.cta_text,errorCtaLink:e.allowlist_config.cta_link},legacyWalletUiConfig:e.legacy_wallet_ui_config,appearance:{logo:t?.appearance?.logo??e.logo_url??void 0,landingHeader:t?.appearance?.landingHeader??Io.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:Lo({backgroundTheme:t?.appearance?.theme??Io.appearance.theme,accentHex:t?.appearance?.accentColor??e.accent_color??Io.appearance.accentColor}),loginGroupPriority:I?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:M,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.wallet_auth??!1,solanaWalletAuth:e.solana_wallet_auth??!1})},loginMethods:{wallet:s,email:a,sms:i,passkey:o,google:l,twitter:c,discord:d,github:g,spotify:p,instagram:u,tiktok:h,linkedin:m,apple:y,farcaster:f,telegram:w},disablePlusEmails:e.disable_plus_emails,loginMethodsAndOrder:P,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.terms_and_conditions_url,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacy_policy_url,requireUsersAcceptTerms:e.require_users_accept_terms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.wallet_connect_cloud_project_id??Io.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:t?.externalWallets?.signatureRequestTimeouts??{}},chains:U,solanaClusters:$,defaultChain:O,intl:{defaultCountry:W},shouldEnforceDefaultChainOnConnect:L,captchaEnabled:e.captcha_enabled??Io.captchaEnabled,captchaSiteKey:e.captcha_site_key,externalWallets:{coinbaseWallet:{config:{appName:e.name,appLogoUrl:e.logo_url,preference:{options:t?.externalWallets?.coinbaseWallet?.connectionOptions??Io.externalWallets.coinbaseWallet.connectionOptions,...t?.externalWallets?.coinbaseWallet?.config?.preference},...t?.externalWallets?.coinbaseWallet?.config}},walletConnect:{enabled:N,appKit:t?.externalWallets?.walletConnect?.appKit},solana:{connectors:t?.externalWallets?.solana?.connectors},disableAllExternalWallets:t?.externalWallets?.disableAllExternalWallets??!1},embeddedWallets:{requireUserOwnedRecoveryOnCreate:F??(!R&&(e.embedded_wallet_config.require_user_owned_recovery_on_create??!1)),userOwnedRecoveryOptions:R?["user-passcode"]:e.embedded_wallet_config.user_owned_recovery_options,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:D??t?.embeddedWallets?.ethereum?.createOnLogin??B},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??z},mode:e.embedded_wallet_config.mode,showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforce_wallet_uis??!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.mfa_methods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink},customAuth:R?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:j,passkeysForSignupEnabled:e.passkeys_for_signup_enabled},headless:!!t?.headless,render:{standalone:t?._render?.standalone??Io._render.standalone},fundingConfig:V,fundingMethodConfig:{...t?.fundingMethodConfig??Io.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??Io.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??Io.fundingMethodConfig.moonpay.useSandbox}},whatsAppEnabled:!!e.whatsapp_enabled}}const Fo={show_wallet_login_first:!0,allowlist_config:{error_title:null,error_detail:null,cta_text:null,cta_link:null},wallet_auth:!0,email_auth:!0,sms_auth:!1,google_oauth:!1,twitter_oauth:!1,discord_oauth:!1,github_oauth:!1,linkedin_oauth:!1,apple_oauth:!1,disable_plus_emails:!1,terms_and_conditions_url:null,privacy_policy_url:null,embedded_wallet_config:{create_on_login:"off",ethereum:{create_on_login:"off"},solana:{create_on_login:"off"},require_user_owned_recovery_on_create:!1,user_owned_recovery_options:["user-passcode"],mode:"user-controlled-server-wallets-only"},fiat_on_ramp_enabled:!1,captcha_enabled:!1,captcha_site_key:"",enforce_wallet_uis:!1,legacy_wallet_ui_config:!1,id:"",name:"",passkeys_for_signup_enabled:!1,whatsapp_enabled:!1},Do=Ro(Fo,void 0,!1);let Bo=/*#__PURE__*/c({appConfig:Do,isServerConfigLoaded:!1});const zo=({children:e,client:n,legacyClient:r,clientConfig:a})=>{let[i,l]=o(null),c=s((()=>Ro(i??Fo,a,!!i,"undefined"!=typeof window?window.location.origin:void 0)),[i,a]);return d((()=>{if(!i)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?{enabled:a.walletConnect.enabled}:void 0,coinbaseWallet:a.coinbaseWallet,solana:{connectors:a.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0}}(a),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(),n=`privy:sent:${i.id}:${t}`;localStorage.getItem(n)||(r.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(n,"t"))}),[a,i]),d((()=>{i||(async()=>{try{await n.initialize();let e=n.app.getConfig();e.custom_api_url&&r.updateApiUrl(e.custom_api_url),l(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),/*#__PURE__*/t(Bo.Provider,{value:{appConfig:c,isServerConfigLoaded:!!i},children:e})},$o=()=>{let{appConfig:e}=l(Bo);return e},jo=()=>{let{isServerConfigLoaded:e}=l(Bo);return e},Vo=/*#__PURE__*/c({app:Do,currentScreen:null,lastScreen:null,navigate:Nt,navigateBack:Nt,resetNavigation:Nt,setModalData:Nt,onUserCloseViaDialogOrKeybindRef:void 0}),Ho=n=>{let r=$o(),a=n.authenticated,[s,l]=o(n.initialScreen);d((()=>{a||!n.initialScreen||n.initialScreen.isUnauthenticatedScreem||n.setInitialScreen(null)}),[a]);let c=i(null);d((()=>{n.open||(c.current=null)}),[n.open]),d((()=>{c.current=null}),[n.initialScreen]);let h={app:r,data:n.data,setModalData:n.setModalData,currentScreen:n.initialScreen,lastScreen:s,navigate:(e,t=!0)=>{n.setInitialScreen(e),t&&l(n.initialScreen)},navigateBack:()=>{n.setInitialScreen(s)},resetNavigation:()=>{n.setInitialScreen(null),l(null)},onUserCloseViaDialogOrKeybindRef:c};/*#__PURE__*/return e(Vo.Provider,{value:h,children:[("string"==typeof r.appearance.logo||"img"===r.appearance.logo?.type)&&/*#__PURE__*/t(Ao,{src:"string"==typeof r.appearance.logo?r.appearance.logo:r.appearance.logo.props.src}),n.children]})},qo=()=>l(Vo),Ko=({style:n,...r})=>{let{app:a}=qo();/*#__PURE__*/return e("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"28",height:"28",rx:"3",fill:"dark"===a?.appearance.palette.colorScheme?"#3396ff":"#141414"}),/*#__PURE__*/t("g",{clipPath:"url(#clip0_1765_9946)",children:/*#__PURE__*/t("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_1765_9946",children:/*#__PURE__*/t("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};class Zo extends Vi{async initialize(){let e=await this.createProvider();this.provider=e,this.proxyProvider.setWalletProvider(e),this.subscribeListeners(),e.session&&(this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=ko(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown"),this.connected=!0,await this.syncAccounts()),this.initialized=!0,this.emit("initialized");let{createAppKit:t}=await import("@reown/appkit");this.modal??=t({projectId:this.walletConnectCloudProjectId,themeVariables:{"--w3m-z-index":1e6},networks:this.chains,includeWalletIds:la,allowUnsupportedChain:!0}),this.modal.subscribeState((e=>{e.open||this.walletProvider?.session||!this.onQrModalClosed||this.onQrModalClosed()}))}async connect(e){return e.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){let e=this.walletProvider?.session?.peer.metadata.icons?.[0];return{name:ta(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:"string"==typeof e?e:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAHdElNRQfoDAIVODUC+w+GAAAGsUlEQVRYw6WXbYwWVxXHf+fOLAtCXYS2QJdIaClipGCTknXXNqBQMVHbfmhItH4Aral+IAEaG03UxJgYKQJGTUxtDWjaxDSNtcZqIGDwpRuW1oYiVqpdpZSlpC3qysu+PHPP3w/3mXnmeXZbPzjJZO7cefn/z/mfe865xlscq3dGDIguGiHLaMQVLja4s87FShcLo5jtApdddnHexUmHIy475JmdUkPRAQMu7gzT4ljnxJpdk0QPmMFkyAKN2OfOFpc2uuh1J3MZDrjAvXmVEQUuoosRxw642FcEG7IoDxiFxNiu8NYE+vcUYIFYRKKs113bXWx2Z34CoQZsVHOiCZ7mopdzdsFhv8NexEgRDHMxUSNREbh1bwNZwBsFblmfu/a4a6AEENYO5i3AOoEWeEUCF4MOOxBDMQAOk99OJALA2u80sBCwWGBZWG/yRwMaCAbBIAsQTJT3gea1OWfNeaPzvjoHEI85rA8ObtB1v7cIdJkIHgkh9AXpocy0LJjIKvB2wPpZB0v3wkrw5jdNEjeYeMhFX3BAyfn2ke9NUrgB9LrrcZcGJFCld4fWNddXbvbWfWzGR6xJFZsBGh0cBh3bBIxIEGTQ3W0h4NuDaSAzyAxCmGq11Vzf5uaa1aG8p+WFtrEYQGwvjICJkAEqvC+YNmcmMlMNvEaCdrcbyUvQAWDTjVuESHObM6cPGWHmzDwLaEtmzG9Z3qF1zUpXmuuZBb1z4bqeNC6f0WE1NtUTwHzEloiy3BvFisy0sYoLlQtT6XW15md2Qf9SY+2Ngfdca/TMSm/9ewz+/Boc/It45h/i4kSTsKw90SQJsPTvjSZbkWemDW7qTRZ0JEYJWSKxZJ7xmf6M224MzMzbX1s8F1YugjtvMg6eErt/4/z1jUrz1rXUKxnZC2zIg2mdBTK1mFUOKC1fOt/48kdzVixIz86Nij+eEacvpJWyZJ5xy7th8VzjjpuMJfMCW58QL73ekXPVlhsyE+vyzFiplJyauEIyrGIquruMq7qTxk+dcB495rzyTzFepCUWLIFv/kBg081Gd55WUk1IDGFTS89K++TDYxddzKnWcbluHd450xgdh7EGrOo1rr868PMTzqWJRGZ2d8oB/xpL33Xnxl2rjeNn4blXRXduzJ4B5y+28kWscAwXl+yeR654FFZPHoUb710YuPeDOUdPO48di1xptKpeEeHqOcYXNwQKGd88EDk3mqxtxPSfGRlsXRtYt8z4ytPOH/7eqpg1Aso7fYKgK4NPrMpYvsC4/poMA34yVJIQC3sCD9yecdsNyaV5yPj6ryJnR1PAvSNP4J+/1cgDfLbfePaMGGtM7Qdyl12WmKOmXgKKAp54vmBRTxfLrjE+tSYjBPjRM5FrrzIeuD2jf2lLzw8vN4JlfPVp581LsO1DgXv7jSzAiXPw/d+JiYLpjsu26Yfjf5O0rF5WoxsNT9G/bX0XKxakmPjlSee6HlizJJXSX7/oRDc+vjKR+f2wODcKd78/gR8/C9uedF44myJxmhh4OY/ipMQyqaWxmjn95TfEroMFOzbkvG+RceeqViPx1Aln1yEnOow1AnffHCpJAJ5/Vex4UvzptZRdY/O/1dJIS/NkcNmR6MTYah6qzseA4TfFtw4UvHBW1bc/O+7sPhwZHYf/jMODh5yfPudVbXj2TAJ/8XxrOZagNamj4Ei2/GNfuyRxh8t6BG2l15up+MIVODEiFr8rcPS0+O6RBF6mrrEGHHtFzOo2Lo7Dl37hvPQ6mNV6R9JYKgnYWcE37K5HlE2OT/5A0udaPUBHH+BQOMzuNsYLuDyZflTW+fTcmJFDHhJhaZqewMuewXDxcDR9IYyPN6Jj+6K4MF2vV8qBtZJScqVRNi6lpGONVJis5mpKi1WbgwsY+zIsBpcR8mzIZfuTRVZrtdu9odrptR/Xx5XONXJqBmCN0P6YMUQq9WJiwt0Je102WHdbpxSqydMObBWYdwDWLVcqcIMYe3NPjg0Ht84od0Ajju1w2XCr9e6QoqM9V23ZtnmI6cfAMMb9AY0YEHdb6oobEh4y3H3Ize6LsmGvN5IdUnhttdQ9UVrfLk/ljWEZ9wXsqAdQk1EA+O22GcgdZTke/bAs3OPY4HSdcB20HhvVtTMu0jmI8ekAhz2IICj2hKpNqI60NcuIRUHEej1quzubXa2tmZhenrfZmv3YYQ9ipDAIgvHptmblccuDjdRcmjFpWbDi/9ycZjZkRbk5jYztai/AUwiUx+qdEQB/m+25i9lxyvbcjrg45Lmd0uT/3p7/Fw6ODf+WO019AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTEyLTAyVDIxOjU2OjQ4KzAwOjAwMVpslgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0xMi0wMlQyMTo1Njo0OCswMDowMEAH1CoAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMTItMDJUMjE6NTY6NTMrMDA6MDDZv6GRAAAAAElFTkSuQmCC",id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(e){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletClientType=e,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,function(){try{localStorage.removeItem(da)}catch{}}(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise(((e,t)=>{this.onQrModalClosed=()=>{t(new Wi)},(async()=>{let t="",n=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(n?.length&&(t=n[0]),!t||""===t)throw new fe("Unable to retrieve address");this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=ko(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown",this.proxyProvider.rpcTimeoutDuration=zi(this.rpcConfig,this.walletClientType)),this.connected=!0,await this.syncAccounts(n),e()})().catch((e=>{t(e?Ui(e):new fe("Unknown error during connection"))})).finally((()=>this.modal?.close()))}))}disconnect(){this.walletProvider?.disconnect().then((()=>this.onDisconnect())).catch((()=>console.warn("Unable to disconnect Wallet Connect provider")))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(e){this.proxyProvider.setWalletProvider(e)}async createProvider(){let e={};for(let t of this.chains){let n=ia(t.id,this.chains,this.rpcConfig,this.privyAppId);n&&(e[t.id]=n)}let t=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],n=this.chains.map((e=>e.id)),r=await $n.init({projectId:this.walletConnectCloudProjectId,chains:t,optionalChains:n,optionalEvents:jn,optionalMethods:Vn,rpcMap:e,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.toString(),icons:[]}});return r.on("display_uri",(e=>{if(r.signer.abortPairingAttempt(),this.walletEntry){let{redirect:t,href:n}=function(e,t){let n=ca(t);if(n.deepLink)return pa(n.deepLink,e);if(n.universalLink)return ua(n.universalLink,e);throw new he(`Unsupported wallet ${t.id}`)}(e,this.walletEntry);(function({href:e,name:t}){try{localStorage.setItem(da,JSON.stringify({href:e,name:t}))}catch{}})({href:n,name:this.walletEntry.metadata?.shortName||this.walletEntry.name}),this.redirectUri=t;let r=function(e,t){let n=ca(t);if(n.universalLink)return ua(n.universalLink,e)}(e,this.walletEntry);r?.redirect&&(this.fallbackUniversalRedirectUri=r.redirect),g?(ma(t,"_self"),this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri})):this.showPrivyQrModal?this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri}):this.modal?.open({uri:e})}else this.modal?.open({uri:e})})),r.on("connect",(()=>{this.modal?.close(),r.session?.peer.metadata.url&&(this.walletEntry=ko(r.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown")})),r}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await(this.walletProvider?.enable())}setWalletEntry(e,t){this.walletEntry=e,this.showPrivyQrModal=t}constructor({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:r,shouldEnforceDefaultChainOnConnect:a,privyAppId:i,privyAppName:o,walletClientType:s,appKit:l}){super(s||"unknown",n,r,t),this.connectorType="wallet_connect_v2",this.privyAppId=i,this.privyAppName=o,this.walletConnectCloudProjectId=e,this.rpcConfig=t,this.shouldEnforceDefaultChainOnConnect=a,this.proxyProvider=new Hi(void 0,this.rpcTimeoutDuration),this.modal=l,s&&(this.walletEntry=(e=>Co.getState().listings.find((({slug:t})=>xo(t)===xo(e))))(s),this.walletClientType=s)}}class Yo extends mn{get wallets(){let e=new Set,t=this.walletConnectors.flatMap((e=>e.wallets)).sort(((e,t)=>e.connectedAt&&t.connectedAt?t.connectedAt-e.connectedAt:0)).filter((t=>{let n=`${t.address}${t.walletClientType}${t.connectorType}${t.meta.id}`;return!e.has(n)&&(e.add(n),!0)})),n=t.findIndex((e=>e.address===(this.activeWallet?this.activeWallet:"unknown")));return n>=0&&t.unshift(t.splice(n,1)[0]),t}async initialize(e){if(this.initialized&&!e||(e&&this.removeAllConnectors(),jr.get(Ra)&&(jr.getKeys().forEach((e=>{e.startsWith("walletconnect")&&jr.del(e)})),jr.del(Ra)),this.externalWalletConfig.disableAllExternalWallets))return;let t=ra({store:this.store,walletList:this.walletList,externalWalletConfig:this.externalWalletConfig,walletChainType:this.walletChainType}).then((e=>{e.forEach((({type:e,eip6963InjectedProvider:t,legacyInjectedProvider:n})=>{this.createEthereumWalletConnector({connectorType:"injected",walletClientType:e,providers:{eip6963InjectedProvider:t,legacyInjectedProvider:n}})}))}));for(let e of(this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector({connectorType:"coinbase_wallet",walletClientType:"coinbase_wallet"}),Object.values(ho)))!e.isInstalled&&this.walletList.includes(e.client)&&(["ethereum-only","ethereum-and-solana"].includes(this.walletChainType)&&e.chainTypes.includes("ethereum")&&this.createEthereumWalletConnector({connectorType:"null",walletClientType:e.client,walletConfig:e}),["ethereum-and-solana","solana-only"].includes(this.walletChainType)&&e.chainTypes.includes("solana")&&this.addSolanaWalletConnector(new vo({id:e.client,name:e.name})));this.externalWalletConfig.walletConnect.enabled&&this.createEthereumWalletConnector({connectorType:"wallet_connect_v2",walletClientType:"unknown"}),this.externalWalletConfig.solana.connectors?.get().forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.((e=>{e?.forEach(this.addSolanaWalletConnector)})),await t,this.initialized=!0}findWalletConnector(e,t){return"wallet_connect_v2"===e?this.walletConnectors.filter(ji).find((t=>t.connectorType===e))??null:this.walletConnectors.filter(ji).find((n=>n.connectorType===e&&n.walletClientType===t))??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(yo).find((t=>"unknown"===t.walletClientType?t.walletBranding.id===e:t.walletClientType===e))??null}findEmbeddedWalletConnectors(){return this.walletConnectors.filter((e=>"embedded"===e.connectorType))}onInitialized(e){e.wallets.forEach((e=>{let t=this.storedConnections.find((t=>t.address===e.address&&t.connectorType===e.connectorType&&("solana"===e.type&&"unknown"===t.walletClientType&&"unknown"===e.walletClientType?e.meta.id===t.id:t.walletClientType===e.walletClientType)));t&&(e.connectedAt=t.connectedAt)})),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&this.emit("walletsUpdated")}addEmbeddedWalletConnectors({walletProxy:e,user:t,embeddedWallets:n,defaultChain:r,appId:a,privyClient:i}){let{entropyId:o,entropyIdVerifier:s}=Ni(t);for(let t of n){let n=this.findEmbeddedWalletConnectors().find((e=>e.walletIndex===t.walletIndex));if(n&&ji(n))n.proxyProvider.walletProxy=e;else{let n=new Yi({provider:new Qi({walletProxy:e,address:t.address,entropyId:o,entropyIdVerifier:s,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:r.id,walletIndex:t.walletIndex,privyClient:i,walletAccount:t}),chains:this.chains,defaultChain:r,rpcConfig:this.rpcConfig,imported:!1,walletIndex:t.walletIndex});this.addWalletConnector(n)}}}addImportedWalletConnector(e,t,n,r){let a=this.findWalletConnector("embedded_imported","privy");if(a&&ji(a))a.proxyProvider.walletProxy=e;else{let a=new Yi({provider:new Qi({walletProxy:e,address:t,entropyId:t,entropyIdVerifier:"ethereum-address-verifier",walletIndex:0,rpcConfig:this.rpcConfig,chains:this.chains,appId:r,chainId:n.id}),chains:this.chains,walletIndex:0,defaultChain:n,rpcConfig:this.rpcConfig,imported:!0});this.addWalletConnector(a)}}removeEmbeddedWalletConnectors(){this.walletConnectors=this.walletConnectors.filter((e=>"embedded"!==e.connectorType)),this.storedConnections=mo(),this.emit("walletsUpdated")}removeImportedWalletConnector(){let e=this.findWalletConnector("embedded_imported","privy");if(e){let t=this.walletConnectors.indexOf(e);this.walletConnectors.splice(t,1),this.storedConnections=mo(),this.emit("walletsUpdated")}}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:n,walletConfig:r}){let a=this.findWalletConnector(e,t);if(a&&ji(a))return a instanceof Zo&&a.resetConnection(t),a;let i=(()=>"injected"!==e?"coinbase_wallet"===e?new Ki(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig.coinbaseWallet.config):"null"!==e?new Zo({walletConnectCloudProjectId:this.walletConnectCloudProjectId,rpcConfig:this.rpcConfig,chains:this.chains,defaultChain:this.defaultChain,shouldEnforceDefaultChainOnConnect:this.shouldEnforceDefaultChainOnConnect,privyAppId:this.privyAppId,privyAppName:this.privyAppName,walletClientType:t,appKit:this.appKit}):r?new Xi({id:r.client,name:r.name,defaultChain:this.defaultChain,walletClientType:r.client}):null:"metamask"===t&&n?.eip6963InjectedProvider?new lo(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask"):"metamask"===t&&n?.legacyInjectedProvider?new so(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask"):"phantom"===t&&n?.legacyInjectedProvider?new so(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom"):n?.legacyInjectedProvider&&"unknown_browser_extension"===t?new so(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider):n?.eip6963InjectedProvider?new io(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,t):void 0)();return i&&this.addWalletConnector(i),i||null}addWalletConnector(e){this.walletConnectors.push(e),e.on("initialized",(()=>this.onInitialized(e))),e.on("walletsUpdated",(()=>this.onWalletsUpdated(e))),e.initialize().catch((e=>{console.debug("Failed to initialize connector",e)}))}async activeWalletSign(e){let t=this.wallets,n=t.length>0?t[0]:null;return n&&Fi(n)?n.sign(e):null}setActiveWallet(e){this.activeWallet=v(e),this.emit("walletsUpdated")}setWalletList(e){this.walletList=e,this.initialized&&this.initialize(!0).catch(console.error)}removeAllConnectors(){for(let e of this.walletConnectors)e.removeAllListeners();this.walletConnectors=[]}constructor(e,t,n,r,a,i,o,s,l,c,d,h){super(),this.addSolanaWalletConnector=async e=>{let t=this.findSolanaWalletConnector(e.walletClientType);if(!t||"null"===t.connectorType){if("null"===t?.connectorType){let e=this.walletConnectors.indexOf(t);this.walletConnectors.splice(e,1)}this.addWalletConnector(e)}},this.getEthereumProvider=()=>{let e=this.wallets[0],t=this.walletConnectors.find((t=>t.wallets.find((t=>t.address===e?.address))));return e&&t?t.proxyProvider:new Hi},this.privyAppId=e,this.walletConnectCloudProjectId=t,this.rpcConfig=n,this.chains=r,this.defaultChain=a,this.walletConnectors=[],this.initialized=!1,this.store=i,this.walletList=o,this.shouldEnforceDefaultChainOnConnect=s,this.externalWalletConfig=l,this.privyAppName=c,this.walletChainType=d||"ethereum-only",this.appKit=h,this.storedConnections=mo()}}let Go=[Be,ze,$e];class Jo{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw ue(e)}}async post(e,t,n){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...n})}catch(e){throw ue(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw ue(e)}}constructor({appId:e,appClientId:t,client:n,defaults:r}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=n.clientAnalyticsId,this.sdkVersion=ba,this.client=n,this.defaults=r,this.fallbackApiUrl=n.fallbackApiUrl,this.baseFetch=xr.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:e,options:t})=>{let n=new Headers(t.headers);n.set("privy-app-id",this.appId),this.appClientId&&n.set("privy-client-id",this.appClientId),n.set("privy-ca-id",this.clientAnalyticsId||""),n.set("privy-client",`react-auth:${this.sdkVersion}`);let r=Go.includes(e.toString());if(!n.has("authorization")){let e=await this.client.getAccessToken({disableAutoRefresh:r});null!==e&&n.set("authorization",`Bearer ${e}`)}t.headers=n,t.retryDelay&&"number"==typeof t.retryDelay&&(t.retryDelay=3*t.retryDelay)},onRequestError:({error:e})=>{if(e instanceof DOMException&&"AbortError"===e.name)throw new De}})}}let Qo=/paymaster\.biconomy\.io\/api/i,Xo={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const es=(e,t)=>e&&Qo.test(e)?Xo:t&&t.policy_id?{policyId:t.policy_id}:void 0;class ts{async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(je,{token:this.meta.token})}catch(e){throw ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(Ve,{token:this.meta.token})}catch(e){throw ue(e)}}constructor(e){this.meta={token:e}}}class ns{getOrCreateGuestCredential(e){let t=Na(e);if($r()){if(jr.get(t))return jr.get(t);{let e=Qt.encode(Ha(32));return jr.put(t,e),e}}return Qt.encode(Ha(32))}async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(He,{guest_credential:this.meta.guestCredential})}catch(e){throw ue(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function rs(){return!(f&&window.location.origin.startsWith("http://localhost"))}const as=Hn((()=>({identityToken:null})));function is(){let{identityToken:e}=as();return{identityToken:e}}var os,ss=((os={}).PRIVY="privy_access_token",os.CUSTOMER="customer_access_token",os);class ls{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(ka)}get privyAccessToken(){return this._getToken(Aa)}_getToken(e){try{let t=jr.get(e);return"string"==typeof t?_i.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=jr.get(xa);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=jr.get(Ma(e));if("string"!=typeof t)return null;{let n=new _i(t);return n.isExpired()?(jr.del(Ma(e)),null):n.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=Rr.get(Ea);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e="privy_access_token"){let t="string"==typeof this.getToken(e),n="string"==typeof this.refreshToken&&"deprecated"!==this.refreshToken;return this.mightHaveServerCookies||t&&n}hasActiveAccessToken(e){let t=_i.parse(this.getToken(e));return null!==t&&!t.isExpired(30)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(e,t){"string"==typeof t?jr.put(Ma(e),t):jr.del(Ma(e))}updateIdentityToken(e){"string"==typeof e?this.storeIdentityToken(e):this.clearIdentityToken()}async _authenticate(e){try{let t=await e.authenticate(),{user:n,is_new_user:r,oauth_tokens:a}=t;this.handleTokenResponse(t);let i=a?{provider:a.provider,accessToken:a.access_token,accessTokenExpiresInSeconds:a.access_token_expires_in_seconds,refreshToken:a.refresh_token,refreshTokenExpiresInSeconds:a.refresh_token_expires_in_seconds,scopes:a.scopes}:void 0;return this._trackAuthenticateEvents(e,r),{user:tn(n),isNewUser:r,oAuthTokens:i}}catch(e){throw console.warn("Error authenticating session"),qe(e)}}_trackAuthenticateEvents(e,t){let n=function(e){return e instanceof Dr?"email":e instanceof fi?"sms":e instanceof ui?"siwe":e instanceof ns?"guest":e instanceof ts?"custom_auth":e instanceof Ya?e.meta.provider:null}(e);n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:n,isNewUser:t}}),"siwe"===n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:e.meta.connectorType,walletClientType:e.meta.walletClientType}})}async _link(e){try{let t=await e.link(),n=t.oauth_tokens,r=n?{provider:n.provider,accessToken:n.access_token,accessTokenExpiresInSeconds:n.access_token_expires_in_seconds,refreshToken:n.refresh_token,refreshTokenExpiresInSeconds:n.refresh_token_expires_in_seconds,scopes:n.scopes}:void 0;return{user:tn(t),oAuthTokens:r}}catch(e){throw console.warn("Error linking account"),qe(e)}}async _refresh(){if(!this.api)throw new he("Session has no API instance");if(!this.client)throw new he("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let e=this.token,t=this.refreshToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let n;if(!(e&&t||this.mightHaveServerCookies))return null;{let r={};e&&(r.authorization=`Bearer ${e}`),n=await this.api.post(Be,t?{refresh_token:t}:{},{headers:r})}return this.handleTokenResponse(n),tn(n.user)}catch(e){if(e instanceof Ke&&e.privyErrorCode===Te.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw qe(e)}}handleTokenResponse(e){e.session_update_action&&"set"!==e.session_update_action?"clear"===e.session_update_action?this.destroyLocalState():"ignore"===e.session_update_action&&(e.token&&(this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token)),e.identity_token&&this.storeIdentityToken(e.identity_token)):this._storeAllTokens(e)}_storeAllTokens(e){this.storeRefreshToken(e.refresh_token),this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),e.identity_token&&this.storeIdentityToken(e.identity_token)}async _destroy(){try{await(this.api?.post(ze,{refresh_token:this.refreshToken}))}catch(e){console.warn("Error destroying session")}this.destroyLocalState()}destroyLocalState(){this.storeRefreshToken(null),this.storeCustomerAccessToken(null),this.storePrivyAccessToken(null),this.clearIdentityToken()}storeCustomerAccessToken(e){if("string"==typeof e){let t=jr.get(ka);if(jr.put(ka,e),!this.client?.useServerCookies){let t=_i.parse(e)?.expiration;Rr.set(Ta,e,{sameSite:"Strict",secure:rs(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else jr.del(ka),Rr.remove(Ta),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(jr.put(xa,e),this.client?.useServerCookies||Rr.set(Ea,"t",{sameSite:"Strict",secure:rs(),expires:30})):(jr.del(xa),Rr.remove("privy-refresh-token"),Rr.remove(Ea))}storePrivyAccessToken(e){"string"==typeof e?jr.put(Aa,e):jr.del(Aa)}storeIdentityToken(e){if(as.setState({identityToken:e}),this.client?.useServerCookies)return;jr.put(Ia,e);let t=_i.parse(e)?.expiration;Rr.set(_a,e,{sameSite:"Strict",secure:rs(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){jr.del(Ia),as.setState({identityToken:null}),Rr.remove(_a)}constructor(){this.authenticateOnce=new ga((async e=>this._authenticate(e))),this.linkOnce=new ga((async e=>this._link(e))),this.refreshOnce=new ga(this._refresh.bind(this)),this.destroyOnce=new ga(this._destroy.bind(this))}}let cs;var ds=0,hs="__private_"+ds+++"__getOrGenerateClientAnalyticsId";class ps{getAppId(){return this.appId}initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:r,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:o,externalWalletConfig:s,appName:l,walletChainType:c,appKit:d}){this.connectors||(this.connectors=new Yo(this.appId,e,t,n,r,a,i,o,s,l,c,d))}generateApi(){let e=new Jo({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=e,e}updateApiUrl(e){this.apiUrl=e||this.fallbackApiUrl,this.api=this.generateApi(),e&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new he("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new he("No auth flow in progress.");let{oAuthTokens:e}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:e}}storeProviderAccessToken(e,t){this.session.storeProviderAccessToken(e,t)}getProviderAccessToken(e){return this.session.getProviderAccessToken(e)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(e){e.linkedAccounts.filter((e=>"cross_app"===e.type)).forEach((e=>{this.storeProviderAccessToken(e.providerApp.id,null)}))}startAuthFlow(e){return e.api=this.api,this.authFlow=e,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(Ze,{action:"verify"})}catch(e){throw ue(e)}}async initMfaPasskeyVerification(){try{return(e=>({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}))((await this.api.post(Ye,{})).options)}catch(e){throw ue(e)}}async getCrossAppProviderDetails(e){try{return this._cachedProviderAppDetails[e]||(this._cachedProviderAppDetails[e]=await this.api.get(`/api/v1/apps/${e}/cross-app/details`)),this._cachedProviderAppDetails[e]}catch(e){console.error("Error fetching cross app provider details",e)}}async acceptTerms(){try{let e=await this.api.post(Ge,{});return tn(e)}catch(e){throw qe(e)}}async unlinkEmail(e){try{let t=await this.api.post(Je,{address:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkPhone(e){try{let t=await this.api.post(Qe,{phoneNumber:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(Xe,{address:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(et,{address:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkOAuth(e,t){try{let n=await this.api.post(tt,{provider:e,subject:t});return await this.getAuthenticatedUser()??tn(n)}catch(e){throw qe(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(nt,{fid:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkTelegram(e){try{let t=await this.api.post(rt,{telegram_user_id:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async revokeDelegatedWallet(){try{await this.api.post(at,{})}catch(e){throw qe(e)}}async createAnalyticsEvent({eventName:e,payload:t,timestamp:n,options:r}){if("undefined"!=typeof window)try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post($e,{event_name:e,client_id:this.clientAnalyticsId,payload:{...t||{},clientTimestamp:n?n.toISOString():(new Date).toISOString()}},{retry:-1,keepalive:r?.keepAlive??!1})}catch(e){console.log("Unable to submit event. This is not an issue.")}}async signMoonpayOnRampUrl(e){try{return this.api.post(it,e)}catch(e){throw qe(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(ot,e)}catch(e){throw qe(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${st}?partnerUserId=${e}`)}catch(e){throw qe(e)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(e){return await this.getPrivyAccessToken(e)||await this.getCustomerAccessToken(e)}async getCustomerAccessToken(e){return await this._getToken(ss.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(ss.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?Ei.parse(this.session.getToken(e))?.appId!==this.appId?(await this.logout(),null):this.session.getToken(e):(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials(e)?(await this.session.refresh(),this.session.getToken(e)):null:null}async getSmartWalletsConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let n=await this.api.get(`/api/v1/apps/${this.appId}/smart_wallets`,{baseURL:this.fallbackApiUrl,headers:e});return n.enabled?{enabled:n.enabled,smartWalletType:n.smart_wallet_type,configuredNetworks:n.configured_networks.map((e=>({chainId:e.chain_id,bundlerUrl:e.bundler_url,paymasterUrl:e.paymaster_url,paymasterContext:es(e.paymaster_url,e.paymaster_context)})))}:{enabled:n.enabled}}catch(e){throw qe(e)}}async getUsdTokenPrice(e){try{return(await this.api.get(`/api/v1/token_price?chainId=${e.id}&tokenSymbol=${e.nativeCurrency.symbol}`)).usd}catch(t){return void console.error(`Unable to fetch token price for chain with id ${e.id}`)}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch(e){return void console.error("Unable to fetch token price for SOL")}}async getSplTokenMetadata({mintAddress:e,cluster:t}){try{return await this.api.get(`/api/v1/spl_token_info?mint_address=${e}&cluster=${t}`)}catch(n){return void console.error(`Unable to fetch token metadata for ${t}:${e}`)}}async requestFarcasterSignerStatus(e){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:e})}catch(e){throw console.error("Unable to fetch Farcaster signer status"),e}}async generateSiweNonce({address:e,captchaToken:t}){try{return(await this.api.post(lt,{address:e,token:t})).nonce}catch(e){throw qe(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i}){return await this.api.post(ct,{message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i})}async linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a}){return await this.api.post(dt,{message:e,signature:t,chainId:n,walletClientType:r,connectorType:a})}async linkSmartWallet({message:e,signature:t,smartWalletType:n}){try{let r=await this.api.post(ht,{message:e,signature:t,smart_wallet_type:n});return tn(r)}catch(e){throw qe(e)}}async linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a}){try{let i=await this.linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a});return tn(i)}catch(e){throw qe(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(pt,{address:e,token:t})).nonce}catch(e){throw qe(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,mode:a,messageType:i="plain"}){return await this.api.post(ut,{message:e,signature:t,walletClientType:n,connectorType:r,mode:a,message_type:i})}async sendAccountTransferRequest({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:s}){try{let l,c;switch(n){case"email":l=vt,c={nonce:e,email:t};break;case"sms":l=wt,c={nonce:e,phoneNumber:t};break;case"siwe":if(l=ft,!r)throw Error("Wallet parameters must be defined");c={nonce:e,address:t,...r};break;case"farcaster":l=yt,c={nonce:e,farcaster_id:t,farcaster_embedded_address:o};break;case"telegram":l=gt,c={nonce:e,telegram_auth_result:a,telegram_web_app_data:i};break;case"custom":case"guest":case"passkey":throw Error("Invalid transfer account type");default:l=mt,c={nonce:e,userInfo:s}}let d=await this.api.post(l,c);return await this.getAuthenticatedUser()??tn(d)}catch(e){throw qe(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,messageType:a="plain"}){return await this.api.post(Ct,{message:e,signature:t,walletClientType:n,connectorType:r,message_type:a})}async linkWithSiws({message:e,signature:t,walletClientType:n,connectorType:r,messageType:a="plain"}){try{let i=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,messageType:a});return tn(i)}catch(e){throw qe(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(bt);return this.session.updateIdentityToken(e.identity_token),tn(e.user)}catch(e){throw qe(e)}}async scanTransaction(e){try{return await this.api.post(kt,e)}catch(e){throw qe(e)}}constructor({apiUrl:e=fa,appId:t,appClientId:n,timeout:r=2e4}){Object.defineProperty(this,hs,{value:us}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==fa&&e.startsWith("https://privy."),this.timeout=r,this.appId=t,this.appClientId=n,this.clientAnalyticsId=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}(this,hs)[hs](),cs||(cs=new ls),this.session=cs,this.api=this.generateApi(),this.session.client=this}}function us(){if("undefined"==typeof window)return null;try{let e=jr.get(Sa);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=Gt();try{return jr.put(Sa,e),e}catch(t){return e}}const ms=({delayedExecution:e,...n})=>{let{enabled:r,siteKey:a,appId:i,setError:o,setToken:l,setExecuting:c,ref:h}=ki(),[,p]=s((()=>a?.split("t:")||[]),[a]);if(d((()=>h.current?.remove),[]),!r)return null;if(!p)throw Error("Unsupported captcha site key");/*#__PURE__*/return t("div",{className:"hidden h-0 w-0",children:/*#__PURE__*/t(wn,{...n,ref:h,siteKey:p,options:{action:i,size:"invisible",...e?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{n.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{n.onError?.(),o("Captcha failed"),c(!1)},onSuccess:e=>{n.onSuccess?.(e),l(e),c(!1)},onExpire:()=>{n.onExpire?.();try{h.current?.reset(),o(void 0),l(void 0)}catch(e){o("expired_and_failed_reset")}}})})},gs=e=>{let[t,n]=o("auto");return d((()=>{let t=new ResizeObserver((e=>{n(e[0]?.contentRect.height??"auto")}));return e.current&&t.observe(e.current),()=>{e.current&&t.unobserve(e.current)}}),[e.current]),t},ys={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:[]}},fs=/*#__PURE__*/c(void 0);let ws=()=>l(fs);function vs(e,t){if(!t)return;let n=ws().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 Cs(e,t,n,...r){for(let a of e.current[t][n])a(...r)}function bs(){let e=ws();return(t,n,...r)=>Cs(e,t,n,...r)}function ks(e){vs("configureMfa",e)}const Ts=/*#__PURE__*/vn.div.withConfig({displayName:"Grow",componentId:"sc-ddbf22b4-0"})(["text-align:left;flex-grow:1;"]),xs=/*#__PURE__*/vn.div.withConfig({displayName:"AlignBottom",componentId:"sc-ddbf22b4-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),As=/*#__PURE__*/vn.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;}"]),Is=/*#__PURE__*/vn(As).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 _s=/*#__PURE__*/Cn(["&&{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 Es=/*#__PURE__*/vn.div.withConfig({displayName:"Subtitle",componentId:"sc-ddbf22b4-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),Ss=/*#__PURE__*/vn.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-ddbf22b4-5"})(["",""],_s),Ns=/*#__PURE__*/vn.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-ddbf22b4-6"})(["",""],_s),Ms=/*#__PURE__*/vn.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;":"")),Ps=/*#__PURE__*/vn.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-ddbf22b4-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),Ws=/*#__PURE__*/vn.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;}"]),Us=({success:r,fail:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Os,{className:r?"success":a?"fail":""}),/*#__PURE__*/t(Ls,{className:r?"success":a?"fail":""})]}),Os=/*#__PURE__*/vn.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)")),Ls=/*#__PURE__*/vn(Os).withConfig({displayName:"LoaderFaint",componentId:"sc-ce7792e2-1"})(["&&{border-bottom-color:",";animation:none;opacity:0.5;}"],(e=>e.color??"var(--privy-color-accent)")),Rs=e=>/*#__PURE__*/t(Fs,{color:e.color||"var(--privy-color-foreground-3)"});let Fs=/*#__PURE__*/vn(Os).withConfig({displayName:"StyledButtonLoader",componentId:"sc-ce7792e2-2"})(["&&{height:1rem;width:1rem;margin:2px 0;border-width:1.5px;transition:border-color 200ms ease;}"]);const Ds=/*#__PURE__*/vn.button.withConfig({displayName:"Button",componentId:"sc-b2dfb420-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;}"]),Bs=({children:n,loading:r,disabled:a,success:i,loadingText:o="Loading...",...s})=>/*#__PURE__*/t(Vs,{disabled:r||a,$success:i,...s,children:r?/*#__PURE__*/e("span",{children:[/*#__PURE__*/t(Rs,{}),o?/*#__PURE__*/t("span",{children:o}):null]}):n}),zs=({children:e,loading:n,disabled:r,...a})=>/*#__PURE__*/t($s,{disabled:r,...a,children:n?/*#__PURE__*/t(Rs,{color:"var(--privy-color-foreground-accent)"}):e});let $s=/*#__PURE__*/vn(Ds).withConfig({displayName:"StyledPrimaryButtonWithoutGray",componentId:"sc-b2dfb420-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 js=({children:n,loading:r,disabled:a,loadingText:i="Loading...",...o})=>/*#__PURE__*/t(Vs,{as:"a",disabled:r||a,...o,children:r?/*#__PURE__*/e("span",{children:[/*#__PURE__*/t(Rs,{}),i?/*#__PURE__*/t("span",{children:i}):null]}):n});let Vs=/*#__PURE__*/vn(Ds).withConfig({displayName:"StyledPrimaryButton",componentId:"sc-b2dfb420-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__*/Cn(["&&&,&&&:hover,&&&:active{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;pointer-events:none;}"]):""));const Hs=({children:n,loading:r,disabled:a,loadingText:i="Loading...",...o})=>/*#__PURE__*/t(qs,{disabled:r||a,...o,children:r?/*#__PURE__*/e("span",{children:[/*#__PURE__*/t(Rs,{}),i?/*#__PURE__*/t("span",{children:i}):null]}):n});let qs=/*#__PURE__*/vn(Ds).withConfig({displayName:"StyledSecondaryButton",componentId:"sc-b2dfb420-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 Ks=/*#__PURE__*/vn.button.withConfig({displayName:"SoftCtaButton",componentId:"sc-b2dfb420-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__*/Cn(["pointer-events:none;"]))),Zs=({children:n,onClick:r,disabled:a,isSubmitting:i,...o})=>/*#__PURE__*/e(Ys,{$isSubmitting:i,onClick:r,disabled:a,...o,children:[/*#__PURE__*/t("span",{children: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 h,useReducer as p,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 C,isAddress as b,isHex as k}from"viem/utils";import T,{ProviderErrors as x,DEFAULT_SUPPORTED_CHAIN_IDS as A,rpc as I,dedupeSupportedChains as _,DEFAULT_SUPPORTED_CHAINS as E,mainnet as S,addToDefaultChains as N,create as M,countryCodesAndNumbers as P,validatePhoneNumber as W,phoneNumberTypingFormatter as U,getPlaceholderPhoneNumber as O,getCountryCallingCode as L,getPhoneCountryCodeAndNumber as R,formatPhoneNumber as F,toObjectKeys as D,arbitrum as B,avalanche as z,base as $,celo as j,linea as V,optimism as H,polygon as q,zora as K,SolanaUsdcAddressMap as Z,UsdcAddressMap as Y,formatWalletAddress as G,getCoinbaseOnRampUrl as J,chainToMoonpayCurrency as Q,isSupportedChainIdForMoonpay as X,isSupportedChainIdForCoinbaseOnramp as ee,sepolia as te,optimismSepolia as ne,polygonAmoy as re,baseSepolia as ae,avalancheFuji as ie,arbitrumSepolia as oe,formatTokenAmount as se,SolanaClient as le,formatWeiAmount as ce,lastFourDigits as de}from"@privy-io/js-sdk-core";import{P as he,p as pe,f as ue,b as me,c as ge,u as ye,d as fe,e as we,g as ve,h as Ce,i as be,o as ke,a as Te,j as xe,k as Ae,l as Ie,m as _e,n as Ee,q as Se,r as Ne,s as Me,t as Pe,v as We,w as Ue,x as Oe,y as Le,z as Re,A as Fe,B as De,C as Be,D as ze,E as $e,F as je,G as Ve,H as He,I as qe,J as Ke,K as Ze,L as Ye,M as Ge,N as Je,O as Qe,Q as Xe,R as et,S as tt,T as nt,U as rt,V as at,W as it,X as ot,Y as st,Z as lt,_ as ct,$ as dt,a0 as ht,a1 as pt,a2 as ut,a3 as mt,a4 as gt,a5 as yt,a6 as ft,a7 as wt,a8 as vt,a9 as Ct,aa as bt,ab as kt,ac as Tt,ad as xt,ae as At,af as It,ag as _t,ah as Et,ai as St}from"./paths-j39vuJt8.mjs";import{a as Nt,n as Mt,u as Pt,I as Wt}from"./internal-context-De1jxnac.mjs";import{createPublicClient as Ut,http as Ot,formatEther as Lt,formatUnits as Rt,toHex as Ft,isHex as Dt,getAddress as Bt,parseEther as zt,createWalletClient as $t,custom as jt,publicActions as Vt,encodeFunctionData as Ht,isAddress as qt,hexToString as Kt,decodeFunctionData as Zt,decodeAbiParameters as Yt}from"viem";import{v4 as Gt}from"uuid";import*as Jt from"jose";import{base64url as Qt}from"jose";import{h as Xt,c as en,i as tn,u as nn,P as rn,j as an,g as on,b as sn,e as ln,k as cn,a as dn,d as hn,l as pn,m as un}from"./use-sign-with-user-signer-Yg0Gn-gB.mjs";import mn from"eventemitter3";import{createCoinbaseWalletSDK as gn}from"@coinbase/wallet-sdk";import{toViemTransactionSerializable as yn,STRING_TO_NUMBER_TXN_TYPE as fn}from"@privy-io/ethereum";import{Turnstile as wn}from"@marsidev/react-turnstile";import{styled as vn,css as Cn,createGlobalStyle as bn,keyframes as kn}from"styled-components";import Tn from"tinycolor2";import xn from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import An from"@heroicons/react/24/outline/FingerPrintIcon";import In from"@heroicons/react/24/outline/PhoneIcon";import _n from"@heroicons/react/24/outline/ShieldCheckIcon";import En from"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import Sn from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Nn from"@heroicons/react/24/outline/XMarkIcon";import Mn from"@heroicons/react/24/outline/ChevronDownIcon";import Pn from"@heroicons/react/24/outline/CalendarIcon";import Wn from"@heroicons/react/24/outline/ExclamationTriangleIcon";import{Transition as Un,Dialog as On,TransitionChild as Ln,DialogPanel as Rn,Menu as Fn,MenuButton as Dn,MenuItems as Bn,MenuItem as zn}from"@headlessui/react";import{EthereumProvider as $n,OPTIONAL_EVENTS as jn,OPTIONAL_METHODS as Vn}from"@walletconnect/ethereum-provider";import{create as Hn}from"zustand";import qn from"fast-password-entropy";import*as Kn from"secure-password-utilities";import{DEFAULT_WORDLIST as Zn}from"secure-password-utilities/wordlists";import Yn from"@heroicons/react/24/outline/UserCircleIcon";import Gn from"@heroicons/react/24/outline/EnvelopeIcon";import Jn from"@heroicons/react/20/solid/CheckIcon";import Qn from"@heroicons/react/24/outline/WalletIcon";import Xn from"@heroicons/react/24/outline/CheckIcon";import er from"@heroicons/react/24/outline/Square2StackIcon";import tr from"@heroicons/react/24/outline/ExclamationCircleIcon";import nr from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import rr from"@heroicons/react/24/solid/DocumentCheckIcon";import ar from"@heroicons/react/24/solid/XCircleIcon";import ir from"@heroicons/react/24/solid/CheckCircleIcon";import or from"qrcode";import sr from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import lr from"@heroicons/react/24/outline/ChevronRightIcon";import cr from"@heroicons/react/24/outline/LockClosedIcon";import dr from"@heroicons/react/24/outline/PencilSquareIcon";import hr from"@heroicons/react/24/outline/ArrowPathIcon";import pr from"@heroicons/react/24/outline/EyeIcon";import ur from"@heroicons/react/24/outline/EyeSlashIcon";import mr from"@heroicons/react/24/outline/KeyIcon";import gr from"@heroicons/react/24/outline/ArrowDownTrayIcon";import yr from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import fr from"@heroicons/react/24/outline/DocumentDuplicateIcon";import wr from"@heroicons/react/24/solid/LockClosedIcon";import vr from"@heroicons/react/24/outline/CheckCircleIcon";import Cr from"@heroicons/react/24/outline/InformationCircleIcon";import br from"@heroicons/react/24/outline/CreditCardIcon";import kr from"@heroicons/react/24/outline/QrCodeIcon";import Tr from"@heroicons/react/24/outline/GlobeAltIcon";import{ofetch as xr}from"ofetch";import{ChevronDownIcon as Ar,ArrowRightIcon as Ir}from"@heroicons/react/24/outline";import _r from"@heroicons/react/24/outline/ClipboardDocumentIcon";import Er from"@heroicons/react/24/outline/CloudArrowUpIcon";import Sr from"@heroicons/react/24/outline/NoSymbolIcon";import Nr from"@heroicons/react/24/outline/ClockIcon";import Mr from"@heroicons/react/24/outline/TrashIcon";import Pr from"@heroicons/react/24/solid/CheckBadgeIcon";import Wr from"@heroicons/react/24/solid/IdentificationIcon";import Ur from"@heroicons/react/24/outline/MinusCircleIcon";import Or from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import Lr from"@heroicons/react/24/solid/ShieldCheckIcon";import Rr from"js-cookie";function Fr(e){return e?{"privy-ui":"t"}:void 0}class Dr{async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new he("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(pe,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new he("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(me,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw ue(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new he("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new he("Email must be set when initialzing authentication.");let r=Fr(n);try{return await this.api.post(ge,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw ue(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class Br extends Dr{async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new he("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(ye,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw ue(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class zr{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 $r(){try{let e="privy:__session_storage__test",t=new zr;return t.put(e,"blobby"),t.del(e),!0}catch(e){return!1}}var jr="undefined"!=typeof window&&window.localStorage?new zr: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 Vr=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,Hr=(e,t)=>{if(!e.isMetaMask)return!1;if(e.isMetaMask&&!t)return!0;if(e.isBraveWallet&&!e._events&&!e._state||"MetaMask"!==Vr(e))return!1;if(e.providers)for(let t of e.providers)if(!Hr(t))return!1;return!0},qr=()=>{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},Kr=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new fe(`Unsupported chainId ${e}`,4901);return Ut({transport:Ot(Zr(i,n,r.appId)),chain:i})},Zr=(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 fe(`No RPC url found for ${a}`);return r},Yr=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,}))$/),Gr=(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)}`},Jr=(e,t=3,n=4)=>Gr(e,t,n,"solana"),Qr=e=>new Promise((t=>setTimeout(t,e)));const Xr=(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 Qr(n)}o||i(Error("Exceeded max attempts before resolving function"))}))},ea=(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},ta=e=>e.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g,""),na=e=>"string"==typeof e?e:"0x"+e.toString(16);async function ra({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=Vr(e);if(!a.some((e=>e.info.name===t))){if(Hr(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?.config?.preference?.options))){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 aa(e){return`eip155:${String(Number(e))}`}const ia=(e,t,n,r)=>{let a=Number(e),i=t.find((e=>e.id===a));if(!i)throw new fe(`Unsupported chainId ${e}`,4901);return Zr(i,n,r)},oa=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 sa=e=>e?.map((e=>({signer_id:e.signerId,override_policy_ids:e.policyIds}))),la=["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 ca(e){return{name:e.metadata?.shortName||e.name||"",universalLink:e.mobile.universal,deepLink:e.mobile.native}}let da="WALLETCONNECT_DEEPLINK_CHOICE";function ha(e){return e.startsWith("http://")||e.startsWith("https://")}function pa(e,t){if(ha(e))return ua(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 ua(e,t){if(!ha(e))return pa(e,t);let n=e;return n.endsWith("/")||(n=`${n}/`),{redirect:`${n}wc?uri=${encodeURIComponent(t)}`,href:n}}function ma(e,t){window.open(e,t,"noreferrer noopener")}class ga{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 ya{get meta(){return this._meta}async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.channelToken)throw new he("Auth flow must be initialized first");try{let e=await this.api.post(we,{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 he("No response from authentication");return e}catch(e){throw ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(ve,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw ue(e)}}async _startChannelOnce(){if(!this.api)throw new he("Auth flow has no API instance");let e=await this.api.post(Ce,{token:this.captchaToken});g&&!y&&e.connect_uri&&ma(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new he("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.channelToken)throw new he("Auth flow must be initialized first");let e=await this.api.get(be,{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 ga(this._startChannelOnce.bind(this)),this.pollForReady=new ga(this._pollForReady.bind(this)),this._meta.disableSignup=t}}const fa="https://auth.privy.io",wa=1400,va=2500,Ca=4e3,ba="2.16.0",ka="privy:token",Ta="privy-token",xa="privy:refresh_token",Aa="privy:pat",Ia="privy:id_token",_a="privy-id-token",Ea="privy-session",Sa="privy:caid",Na=e=>`privy:guest:${e}`,Ma=e=>`privy:cross-app:${e}`,Pa="privy:state_code",Wa="privy:code_verifier",Ua="privy:headless_oauth",Oa="privy:oauth_disable_signup",La=e=>`privy:wallet:${e}`,Ra="privy:connectors",Fa="privy:connections",Da=12e4,Ba=3e4,za="https://api.moonpay.com/v1",$a="https://api.moonpay.com/v1",ja="pk_live_hirbpu0cVcLHrjktC9l7fbc9ctjv0SL",Va="pk_test_fqWjXZMSFwloh7orvJsRfjiUHXJqFzI";function Ha(e){return crypto.getRandomValues(new Uint8Array(e))}function qa(){return Qt.encode(Ha(36))}function Ka(){return qa()}async function Za(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 Qt.encode(t)}}class Ya{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new he("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new he("User denied confirmation during OAuth flow");let e=function(){let e=jr.get(Wa);if(!e)throw new he("Authentication error.");return e}();try{let t=await this.api.post(ke,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return jr.del(Wa),jr.del(Ua),jr.del(Oa),t}catch(e){let t=ue(e);if(t.privyErrorCode)throw new he(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new he("Invalid code during oauth flow.",void 0,Te.OAUTH_USER_DENIED);throw new he("Invalid code during OAuth flow.",void 0,Te.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new he("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new he("User denied confirmation during OAuth flow");let e=jr.get(Wa);if(!e)throw new he("Authentication error.");try{let t=await this.api.post(xe,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return jr.del(Wa),t}catch(e){throw ue(e)}}async getAuthorizationUrl(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.provider)throw new he("Provider must be set when initializing OAuth authentication.");let e=qa();jr.put(Wa,e);let t=Ka();jr.put(Pa,t);let n=await Za(e);this.meta.withPrivyUi||jr.put(Ua,!0),this.meta.disableSignup?jr.put(Oa,!0):jr.del(Oa);let r=Fr(this.meta.withPrivyUi);try{return await this.api.post(Ae,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...r}})}catch(e){throw ue(e)}}constructor(e){this.meta=e}}function Ga(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Ja=({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"})]}),Qa=({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"})})})]}),Xa=({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"})}),ei=({style:e})=>/*#__PURE__*/t(Tr,{style:{color:"var(--privy-color-error)",...e}}),ti=({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 ni(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 ri({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 ai(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 ii(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 oi=({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 si={google:{name:"Google",component:ti},discord:{name:"Discord",component:Qa},github:{name:"Github",component:Xa},linkedin:{name:"LinkedIn",component:ri},twitter:{name:"Twitter",component:oi},spotify:{name:"Spotify",component:ai},instagram:{name:"Instagram",component:ni},tiktok:{name:"Tiktok",component:ii},apple:{name:"Apple",component:Ja}};const li=e=>e in si?si[e]:{name:"Unknown",component:ei};function ci(){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:!jr.get(Ua),popupFlow:null!==window.opener&&a,disableSignup:!!jr.get(Oa)}}function di(){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"),jr.del(Pa),window.history.replaceState({},"",e)}class hi{async initRegisterFlow(e){if(!this.api)throw new he("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 he("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new he("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 he("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new he("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(Ie,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new he("Passkey request timed out or rejected by user.",void 0,Te.PASSKEY_NOT_ALLOWED);throw ue(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new he("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new he("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(_e,{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 he("Passkey request timed out or rejected by user.",void 0,Te.PASSKEY_NOT_ALLOWED);throw ue(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new he("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new he("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(Ee,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new he("Passkey request timed out or rejected by user.",void 0,Te.PASSKEY_NOT_ALLOWED);throw ue(e)}}async _initRegisterOnce(e){if(!this.api)throw new he("Auth flow has no API instance");let t=Fr(e);return await this.api.post(Se,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new he("Auth flow has no API instance");let t=Fr(e);return await this.api.post(Ne,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new he("Auth flow has no API instance");return await this.api.post(Me,{})}_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 ga(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new ga(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new ga(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}const pi=({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 ui{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 he("SiweFlow has no client instance");try{if(this.preparedMessage&&this.signature)return await this.client.authenticateWithSiweInternal({message:this.preparedMessage,signature:this.signature,chainId:this.wallet?.chainId,walletClientType:this.wallet?.walletClientType,connectorType:this.wallet?.connectorType,mode:this._meta.disableSignup?"no-signup":"login-or-sign-up"});if(!this.wallet)throw new he("SiweFlow has no wallet instance");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 ue(e)}}async link(){if(!this.client)throw new he("SiweFlow has no client instance");try{if(!this.wallet)throw new he("SiweFlow has no wallet instance");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 ue(e)}}async sign(){if(!this.client)throw new he("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new he("Could not prepare SIWE message");if(!this.wallet)throw new he("SiweFlow has no wallet instance");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new he("SiweFlow has no client instance");if(!this.wallet)throw new he("UI SiweFlow has no wallet instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new he("SiweFlow has no client instance");if(!this.wallet)throw new he("SiweFlow has no wallet instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=pi({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1,a){this._meta={disableSignup:!1},this.getNonceOnce=new ga(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=n,this.client=e,this._meta.disableSignup=r,this.preparedMessage=a?.message,this.signature=a?.signature}}const mi=(...e)=>{if("undefined"==typeof Buffer)throw new he("Buffer is not defined.",void 0,Te.BUFFER_NOT_DEFINED);return Buffer.from(...e)},gi=({address:e,nonce:t})=>`${window.location.host} wants you to sign in with your Solana account:\n${e}\n\n${`You 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`;class yi{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup,messageType:this._meta.messageType}}set messageType(e){this._meta.messageType=e}async authenticate(){if(!this.client)throw new he("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",messageType:this.meta.messageType})}catch(e){throw ue(e)}}async link(){if(!this.client)throw new he("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,messageType:this.meta.messageType})}catch(e){throw ue(e)}}async sign(){let e,t;if(!this.client)throw new he("SiwsFlow has no client instance");await this.buildMessage();let n="transaction"===this.meta.messageType;if(!this.preparedMessage)throw new he("Could not prepare SIWS message");if(!n&&!this.wallet.signMessage||n&&!this.wallet.signTransaction)throw new he("Wallet does not support the necessary signing methods");if(n&&this._siwsTransactionMethods){let n=await this.wallet.signTransaction(this._siwsTransactionMethods.deserializeTransactionFromB64String(this.preparedMessage));e=n.serialize().toString("base64"),t=mi(n.signatures[0]?.signature??Buffer.from("missing signature")).toString("base64")}else e=this.preparedMessage,t=mi(await this.wallet.signMessage(mi(this.preparedMessage))).toString("base64");return{message:e,signature:t}}async _getNonceOnce(){if(!this.client)throw new he("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new he("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),"transaction"===this.meta.messageType&&this._siwsTransactionMethods?this.preparedMessage=this._siwsTransactionMethods.prepareSiwsTransactionWithMemo({address:e,nonce:this.nonce}):this.preparedMessage=gi({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,n,r=!1,a="plain",i){this._meta={disableSignup:!1,messageType:"plain"},this.getNonceOnce=new ga(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=n,this.client=t,this._meta.disableSignup=r,this._meta.messageType=a,this._siwsTransactionMethods=i}}class fi{async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new he("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(Pe,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new he("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(We,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw ue(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new he("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new he("phone nNumber must be set when initialzing authentication.");let r=Fr(n);try{return await this.api.post(Ue,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw ue(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:n}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:n??!1}}}class wi extends fi{async link(){if(!this.api)throw new he("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new he("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(Oe,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw ue(e)}}constructor(e,t,n){super({phoneNumber:t,captchaToken:n}),this.meta={phoneNumber:t,captchaToken:n,oldPhoneNumber:e,disableSignup:!1}}}const vi=/*#__PURE__*/c({siteKey:"",enabled:!1,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:Nt,setError:Nt,setExecuting:Nt,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:Nt,reset:Nt,execute:Nt});class Ci extends Le{constructor(e,t,n){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=n}}const bi=({children:e,id:n,captchaSiteKey:r,captchaEnabled:a})=>{let l=i(null),[c,d]=o(),[h,p]=o(),[u,m]=o(!1),g=s((()=>a?u||c||h?!u||c||h?c&&!h?{status:"success",token:c}:h?{status:"error",error:h}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[a,c,h,u]);/*#__PURE__*/return t(vi.Provider,{value:{...g,ref:l,enabled:a,siteKey:r,appId:n,setToken:d,setError:p,setExecuting:m,remove(){a&&(l.current?.remove(),m(!1),p(void 0),d(void 0))},reset(){a&&(l.current?.reset(),m(!1),p(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 Ci("Captcha failed",null,Te.CAPTCHA_TIMEOUT)}}},children:e})},ki=()=>l(vi);class Ti{async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(Re,{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 ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(Fe,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw ue(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function xi(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===Te.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===Te.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===Te.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===Te.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===Te.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===Te.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===Te.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof Ci&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function Ai(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function Ii(){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 _i{static parse(e){try{return new _i(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return Jt.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=Jt.decodeJwt(e)}}class Ei extends _i{static parse(e){try{return new Ei(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}let Si=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 Ni=(e,t)=>{if(t?.imported)return Si(t);let n=Xt(e);if(!n)throw Error("Failed to find primary wallet");return Si(n)},Mi=({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"})]});class Pi extends fe{constructor(){super("Wallet timeout"),this.type="wallet_error"}}class Wi extends fe{constructor(){super("User rejected connection"),this.type="wallet_error"}}const Ui=e=>e instanceof fe?e:e?.code?new Li(e):new fe("Unknown connector error",e);class Oi extends Le{constructor(e,t,n){super(e),this.type="provider_error",this.code=t,this.data=n}}class Li extends Oi{constructor(e){super(e.message,e.code,e.data);let t=Object.values(x).find((t=>t.eipCode===e.code));this.details=t||x.UNKNOWN_ERROR,-32002===e.code&&(e.message?.includes("already pending for origin")?e.message?.includes("wallet_requestPermissions")?this.details=x.E32002_CONNECTION_ALREADY_PENDING:this.details=x.E32002_REQUEST_ALREADY_PENDING:e.message?.includes("Already processing")&&e.message.includes("eth_requestAccounts")&&(this.details=x.E32002_WALLET_LOCKED))}}const Ri={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},...x};function Fi(e){return"ethereum"===e.type}function Di(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&&Fi(r)&&Fi(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 Bi extends mn{constructor(e){super(),this.walletClientType=e,this.connected=!1,this.initialized=!1}}const zi=(e,t)=>e.rpcTimeouts&&e.rpcTimeouts[t]||Da;let $i;function ji(e){return"ethereum"===e.chainType}class Vi extends Bi{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 fe("Wallet is not currently connected.");let o=this.wallets.find((t=>v(t.address)===v(e)))?.chainId;if(!o)throw new fe("Unable to determine current chainId.");if("number"==typeof n?(r=`0x${n.toString(16)}`,i=n):(r=n,i=Number(n)),o===aa(r))return;let s=this.chains.find((e=>e.id===i));if(!s)throw new fe(`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 Qr(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 fe(`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 fe("Wallet is not currently connected.");return this.proxyProvider},sign:async e=>{if(!await a())throw new fe("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 Xr((()=>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=jr.get(La(a));this.chains.find((t=>t.id===Number(e)))||(jr.del(La(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 Xr((()=>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=aa(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))}Di(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:[C(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=aa(e),"privy"===this.walletClientType&&jr.put(La(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 Qr(500),this.syncAccounts()},this.wallets=[],this.walletClientType=e,this.chains=t,this.defaultChain=n,this.rpcConfig=r,this.rpcTimeoutDuration=zi(r,e),this.connected=!1,this.initialized=!1}}class Hi{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 fe(`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 Ui(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 Pi,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||Da,this._subscriptions=[]}}let qi=[1,11155111,137,10,8453,84532,42161,7777777,43114,56];class Ki extends Vi{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 fe("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw Ui(e)}}updateConnectionPreference(e){this.coinbaseWalletConfig={...this.coinbaseWalletConfig,preference:{...this.coinbaseWalletConfig.preference,options:e}},this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",$i=gn({...this.coinbaseWalletConfig}),this.proxyProvider.setWalletProvider($i.getProvider())}constructor(e,t,n,r){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Hi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.coinbaseWalletConfig={...r,appChainIds:[t.id].concat(e.map((e=>e.id)))},this.walletClientType="smartWalletOnly"===this.coinbaseWalletConfig.preference?.options?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!$i){let e="eoaOnly"!==this.coinbaseWalletConfig.preference?.options?(this.coinbaseWalletConfig.appChainIds??[]).filter((e=>!qi.includes(e))):[];e.length>0&&!e.every((e=>A.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${e.join(", ")}`),$i=gn(this.coinbaseWalletConfig)}this.proxyProvider.setWalletProvider($i.getProvider())}}const Zi=({...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 Yi extends Vi{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:[na(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:Zi,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 Gi=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];class Ji extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}class Qi extends mn{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Ji(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Sb()||!this.address)throw new Ji("Disconnected",4900);let{hash:n}=await Wb(t,{address:this.address});return n}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Ji(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await Sb()||!this.address)throw new Ji("Disconnected",4900);let{signature:n}=await Pb(t,{address:this.address});return n}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new Ji(`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 Ji(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Kr(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 Nb({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 Mb(oa(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:na(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...yn(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 na(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=>Gi.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await Sb();if(await Ub({address:this.address}),!t||!this.address)throw new Ji("Disconnected",4900);try{let n={method:e.method,params:e.params},r=this.walletAccount;return r&&en(r)?this.handleWalletApiRequest(n,r,t):(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:n})).response.data}catch(e){throw console.error(e),new Ji("Disconnected",4900)}}}async handleWalletApiRequest(e,t,n){let r=this.privyClient;if(!r)throw new Ji("Disconnected",4900);if("secp256k1_sign"===e.method){let a=await I(r,(async({message:e})=>this.walletProxy.signWithUserSigner({accessToken:n,message:e})),{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:e.params[0]}});if("secp256k1_sign"!==a.method)throw new Ji(`Invalid params for ${e.method}`,4200);return a.data.signature}throw new Ji(`Method not supported: ${e.method}`,4200)}constructor({walletProxy:e,address:t,entropyId:n,entropyIdVerifier:r,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l,privyClient:c,walletAccount:d}){super(),this.walletProxy=e,this.address=t,this.entropyId=n,this.entropyIdVerifier=r,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Kr(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=zi(a,"privy"),this.appId=o,this.walletIndex=l,this.privyClient=c,this.walletAccount=d}}class Xi extends Vi{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 Hi(void 0,Da),this.id=e,this.name=t,this.icon=n,this.connectorType=r}}const eo=({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"})}),to=({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"})]}),no=({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 ro(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var ao=0;class io extends Vi{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 fe("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Ui(e)}}constructor(e,t,n,r,a){super(a||"unknown",e,t,n),this.connectorType="injected",this.proxyProvider=new Hi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=r;let i=r.provider;this.proxyProvider.setWalletProvider(i)}}var oo="__private_"+ao+++"__walletBranding";class so extends Vi{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 ro(this,oo)[oo]??{name:"Browser Extension",icon:eo,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 fe("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Ui(e)}}constructor(e,t,n,r,a){super(a??"unknown",e,t,n),Object.defineProperty(this,oo,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Hi(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(r),"metamask"===a?ro(this,oo)[oo]={name:"MetaMask",icon:to,id:"io.metamask"}:"phantom"===a&&(ro(this,oo)[oo]={name:"Phantom",icon:no,id:"phantom"})}}class lo extends io{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 fe("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Ui(e)}}}const co=["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","binance","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"],ho=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=uo({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=uo({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=uo({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="+uo({client:this.client,isSolana:e,connectOnly:t}))}}});function po({connectorType:e,walletClientType:t}){for(let n of co)if(e===n||t===n)return ho[n]}function uo({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 mo=()=>{let e=jr.get(Fa);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 go=["phantom","glow","solflare","backpack","okx_wallet","walletconnect"];function yo(e){return"solana"===e.chainType}function fo(e){return"solana"===e.type}class wo extends Bi{get isInstalled(){return"Installed"===this.adapter.readyState}get wallet(){return this.adapter.wallet}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:Mt(`${this.walletClientType||""} wallet does not support 'getProvider'`),signMessage:n??Mt(`${this.walletClientType||""} wallet does not support 'signMessage'`),sendTransaction:r??Mt(`${this.walletClientType||""} wallet does not support 'sendTransaction'`),signTransaction:a??Mt(`${this.walletClientType||""} wallet does not support 'signTransaction'`),signAllTransactions:i??Mt(`${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||!go.includes(this.walletClientType))&&("phantom"!==this.walletClientType||mo().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 Ui(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 vo extends wo{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 Hi(void 0,Da),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 Co=Hn((()=>({listings:[]}))),bo=Co.setState,ko=e=>{let t;try{t=new URL(e).hostname}catch(e){return}return Co.getState().listings.find((({homepage:e})=>{let n;try{n=new URL(e).hostname}catch(e){return!1}return t.includes(n)}))},To=e=>Co((({listings:t})=>t.find((({slug:t})=>xo(t)===xo(e)))));function xo(e){return"cryptocom"===e?"cryptocom-defi":"binance"===e?"binance-defi":e.replace(/[-_]wallet$/,"")}function Ao({src:e,...n}){/*#__PURE__*/return t("img",{src:e,...n,style:{display:"none"}})}const Io={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 _o=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","binance"]),Eo=e=>_o.has(e),So=(e,t,n)=>n.indexOf(e)===t;const No=792703809,Mo="11111111111111111111111111111111";function Po(e){return e.includes("testnet")?"testnet":e.includes("devnet")?"devnet":"mainnet-beta"}function Wo(e,t){return`https://explorer.solana.com/account/${e}?cluster=${t}`}let Uo="#FFFFFF";function Oo(e,t){let n=Math.max(0,Math.min(1,e.toHsl().l+t));return Tn({...e.toHsl(),l:n})}function Lo({backgroundTheme:e,accentHex:t}){let n;switch(e){case"light":n=Uo;break;case"dark":n="#1E1E1D";break;default:n=e}let r=Tn(n),a=Tn(t),i=Tn("#51BA81"),o=Tn("#FFB74D"),s=Tn("#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=Oo(r,"light"===l?-.04:.11),d=Oo(r,"light"===l?-.08:.16),h=Oo(r,"light"===l?-.88:.87),p=Oo(r,"light"===l?-.7:.75),u=Oo(r,"light"===l?-.43:.45).desaturate("light"===l?60:20),m=Oo(r,"light"===l?-.08:.25).desaturate("light"===l?60:20),g=Oo(a,.15),y=Oo(a,.25),f=Oo(a,-.06),w=Oo(a,-.6),v=Oo(s,.3),C=Oo(o,.3),b=Tn(a.getLuminance()>.5?"#040217":Uo),k=Oo(i,-.16),T=Oo(i,.4);return{colorScheme:l,background:r.toHslString(),background2:c.toHslString(),background3:d.toHslString(),foreground:h.toHslString(),foreground2:p.toHslString(),foreground3:u.toHslString(),foreground4:m.toHslString(),accent:a.toHslString(),accentLight:g.toHslString(),accentLightest:y.toHslString(),accentDark:f.toHslString(),accentDarkest:w.toHslString(),foregroundAccent:b.toHslString(),success:i.toHslString(),successDark:k.toHslString(),successLight:T.toHslString(),error:s.toHslString(),errorLight:v.toHslString(),warn:o.toHslString(),warnLight:C.toHslString()}}function Ro(e,t,n,r){let a,i,o,s,l,c,d,h,p,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"),p=t.loginMethods.includes("spotify"),u=t.loginMethods.includes("instagram"),h=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.email_auth,i=e.sms_auth,s=e.wallet_auth||e.solana_wallet_auth,l=e.google_oauth,c=e.twitter_oauth,d=e.discord_oauth,g=e.github_oauth,p=e.spotify_oauth,u=e.instagram_oauth,h=e.tiktok_oauth,m=e.linkedin_oauth,y=e.apple_oauth,f=e.farcaster_auth,w=e.telegram_auth,o=e.passkey_auth),e.passkey_auth&&(o=!0),"undefined"!=typeof window&&"function"!=typeof window.PublicKeyCredential&&(o=!1);let C=[a,i].filter(Boolean),b=[l,c,d,g,p,u,h,m,y,f,w].filter(Boolean),k=[s].filter(Boolean),T=t?.loginMethods?.includes("passkey")??!1,x=e.passkeys_for_signup_enabled??!1,A=[o&&(x||T)].filter(Boolean);if(C.length+b.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.show_wallet_login_first;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||b.length+C.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 N=t?.externalWallets?.walletConnect?.enabled??!0;t?.loginMethods&&t.loginMethodsAndOrder&&v("You should only configure one of `loginMethods` or `loginMethodsAndOrder`");let M=(({input:e,overrides:t})=>t?t.primary.concat(t.overflow??[]).filter(Eo).filter(So):e?e.filter(Eo).filter(So):Io.appearance.walletList)({input:t?.appearance?.walletList,overrides:t?.loginMethodsAndOrder}),P=(({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}),W=t?.intl?.defaultCountry??"US",{chains:U,defaultChain:O}=function({supportedChains:e,defaultChainFromConfig:t}){let n;if(e){if(0===e.length)throw Error("`supportedChains` must contain at least one chain");n=_(e)}else n=[...E];let r=e?n[0]:S,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}),L=!!t?.defaultChain,R=t?.customAuth?.getCustomAccessToken&&!1!==t?.customAuth?.enabled,F=t?.embeddedWallets?.requireUserPasswordOnCreate,D=t?.embeddedWallets?.createOnLogin,B=R?"all-users":e.embedded_wallet_config.ethereum.create_on_login,z=e.embedded_wallet_config.solana.create_on_login,$={"mainnet-beta":{rpcUrl:"https://api.mainnet-beta.solana.com",blockExplorerUrl:"https://explorer.solana.com"},testnet:{rpcUrl:"https://api.testnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=testnet"},devnet:{rpcUrl:"https://api.devnet.solana.com",blockExplorerUrl:"https://explorer.solana.com/?cluster=devnet"}};if(t?.solanaClusters)for(let e of t.solanaClusters){let{name:t,rpcUrl:n,blockExplorerUrl:r}=e;$[t]={rpcUrl:n??$[t].rpcUrl,blockExplorerUrl:r??$[t].blockExplorerUrl}}e.solana_wallet_auth&&!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`");let j=e.telegram_auth_config?{botId:e.telegram_auth_config.bot_id,botName:e.telegram_auth_config.bot_name,linkEnabled:e.telegram_auth_config.link_enabled,seamlessAuthEnabled:e.telegram_auth_config.seamless_auth_enabled}:void 0,V=e.funding_config?{methods:e.funding_config.methods,options:e.funding_config.options,defaultRecommendedAmount:e.funding_config.default_recommended_amount,defaultRecommendedCurrency:e.funding_config.default_recommended_currency,promptFundingOnWalletCreation:e.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:e.funding_config.cross_chain_bridging_enabled}:void 0;return{id:e.id,name:e.name,allowlistConfig:{errorTitle:e.allowlist_config.error_title,errorDetail:e.allowlist_config.error_detail,errorCtaText:e.allowlist_config.cta_text,errorCtaLink:e.allowlist_config.cta_link},legacyWalletUiConfig:e.legacy_wallet_ui_config,appearance:{logo:t?.appearance?.logo??e.logo_url??void 0,landingHeader:t?.appearance?.landingHeader??Io.appearance.landingHeader,loginMessage:"string"==typeof t?.appearance?.loginMessage?t?.appearance?.loginMessage.slice(0,100):t?.appearance?.loginMessage,footerLogo:t?.appearance?.footerLogo,palette:Lo({backgroundTheme:t?.appearance?.theme??Io.appearance.theme,accentHex:t?.appearance?.accentColor??e.accent_color??Io.appearance.accentColor}),loginGroupPriority:I?"web3-first":"web2-first",hideDirectWeb2Inputs:!!t?.appearance?.hideDirectWeb2Inputs,walletList:M,walletChainType:t?.appearance?.walletChainType??(({evmWalletAuth:e,solanaWalletAuth:t})=>e&&t?"ethereum-and-solana":e?"ethereum-only":t?"solana-only":"ethereum-only")({evmWalletAuth:e.wallet_auth??!1,solanaWalletAuth:e.solana_wallet_auth??!1})},loginMethods:{wallet:s,email:a,sms:i,passkey:o,google:l,twitter:c,discord:d,github:g,spotify:p,instagram:u,tiktok:h,linkedin:m,apple:y,farcaster:f,telegram:w},disablePlusEmails:e.disable_plus_emails,loginMethodsAndOrder:P,legal:{termsAndConditionsUrl:t?.legal?.termsAndConditionsUrl??e.terms_and_conditions_url,privacyPolicyUrl:t?.legal?.privacyPolicyUrl??e.privacy_policy_url,requireUsersAcceptTerms:e.require_users_accept_terms??!1},walletConnectCloudProjectId:t?.walletConnectCloudProjectId??e.wallet_connect_cloud_project_id??Io.walletConnectCloudProjectId,rpcConfig:{rpcUrls:{},rpcTimeouts:t?.externalWallets?.signatureRequestTimeouts??{}},chains:U,solanaClusters:$,defaultChain:O,intl:{defaultCountry:W},shouldEnforceDefaultChainOnConnect:L,captchaEnabled:e.captcha_enabled??Io.captchaEnabled,captchaSiteKey:e.captcha_site_key,externalWallets:{coinbaseWallet:{config:{appName:e.name,appLogoUrl:e.logo_url,preference:{options:t?.externalWallets?.coinbaseWallet?.connectionOptions??Io.externalWallets.coinbaseWallet.connectionOptions,...t?.externalWallets?.coinbaseWallet?.config?.preference},...t?.externalWallets?.coinbaseWallet?.config}},walletConnect:{enabled:N,appKit:t?.externalWallets?.walletConnect?.appKit},solana:{connectors:t?.externalWallets?.solana?.connectors},disableAllExternalWallets:t?.externalWallets?.disableAllExternalWallets??!1},embeddedWallets:{requireUserOwnedRecoveryOnCreate:F??(!R&&(e.embedded_wallet_config.require_user_owned_recovery_on_create??!1)),userOwnedRecoveryOptions:R?["user-passcode"]:e.embedded_wallet_config.user_owned_recovery_options,priceDisplay:t?.embeddedWallets?.priceDisplay??{primary:"fiat-currency",secondary:"native-token"},ethereum:{createOnLogin:D??t?.embeddedWallets?.ethereum?.createOnLogin??B},solana:{createOnLogin:t?.embeddedWallets?.solana?.createOnLogin??z},mode:e.embedded_wallet_config.mode,showWalletUIs:t?.embeddedWallets?.showWalletUIs??e.enforce_wallet_uis??!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.mfa_methods??[],noPromptOnMfaRequired:t?.mfa?.noPromptOnMfaRequired??!1},passkeys:{shouldUnlinkOnUnenrollMfa:t?.passkeys?.shouldUnlinkOnUnenrollMfa,shouldUnenrollMfaOnUnlink:t?.passkeys?.shouldUnenrollMfaOnUnlink},customAuth:R?{enabled:!0,...t.customAuth}:void 0,loginConfig:{telegramAuthConfiguration:j,passkeysForSignupEnabled:e.passkeys_for_signup_enabled},headless:!!t?.headless,render:{standalone:t?._render?.standalone??Io._render.standalone},fundingConfig:V,fundingMethodConfig:{...t?.fundingMethodConfig??Io.fundingMethodConfig,moonpay:{...t?.fundingMethodConfig?.moonpay??Io.fundingMethodConfig.moonpay,useSandbox:t?.fundingMethodConfig?.moonpay.useSandbox??t?.fiatOnRamp?.useSandbox??Io.fundingMethodConfig.moonpay.useSandbox}},whatsAppEnabled:!!e.whatsapp_enabled}}const Fo={show_wallet_login_first:!0,allowlist_config:{error_title:null,error_detail:null,cta_text:null,cta_link:null},wallet_auth:!0,email_auth:!0,sms_auth:!1,google_oauth:!1,twitter_oauth:!1,discord_oauth:!1,github_oauth:!1,linkedin_oauth:!1,apple_oauth:!1,disable_plus_emails:!1,terms_and_conditions_url:null,privacy_policy_url:null,embedded_wallet_config:{create_on_login:"off",ethereum:{create_on_login:"off"},solana:{create_on_login:"off"},require_user_owned_recovery_on_create:!1,user_owned_recovery_options:["user-passcode"],mode:"user-controlled-server-wallets-only"},fiat_on_ramp_enabled:!1,captcha_enabled:!1,captcha_site_key:"",enforce_wallet_uis:!1,legacy_wallet_ui_config:!1,id:"",name:"",passkeys_for_signup_enabled:!1,whatsapp_enabled:!1},Do=Ro(Fo,void 0,!1);let Bo=/*#__PURE__*/c({appConfig:Do,isServerConfigLoaded:!1});const zo=({children:e,client:n,legacyClient:r,clientConfig:a})=>{let[i,l]=o(null),c=s((()=>Ro(i??Fo,a,!!i,"undefined"!=typeof window?window.location.origin:void 0)),[i,a]);return d((()=>{if(!i)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?{enabled:a.walletConnect.enabled}:void 0,coinbaseWallet:a.coinbaseWallet,solana:{connectors:a.solana?.connectors?.get().map((e=>e.walletClientType))}}:void 0}}(a),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(),n=`privy:sent:${i.id}:${t}`;localStorage.getItem(n)||(r.createAnalyticsEvent({eventName:"sdk_initialize",payload:e}),localStorage.setItem(n,"t"))}),[a,i]),d((()=>{i||(async()=>{try{await n.initialize();let e=n.app.getConfig();e.custom_api_url&&r.updateApiUrl(e.custom_api_url),l(e)}catch(e){console.warn("Error generating app config: ",e)}})()}),[]),/*#__PURE__*/t(Bo.Provider,{value:{appConfig:c,isServerConfigLoaded:!!i},children:e})},$o=()=>{let{appConfig:e}=l(Bo);return e},jo=()=>{let{isServerConfigLoaded:e}=l(Bo);return e},Vo=/*#__PURE__*/c({app:Do,currentScreen:null,lastScreen:null,navigate:Nt,navigateBack:Nt,resetNavigation:Nt,setModalData:Nt,onUserCloseViaDialogOrKeybindRef:void 0}),Ho=n=>{let r=$o(),a=n.authenticated,[s,l]=o(n.initialScreen);d((()=>{a||!n.initialScreen||n.initialScreen.isUnauthenticatedScreem||n.setInitialScreen(null)}),[a]);let c=i(null);d((()=>{n.open||(c.current=null)}),[n.open]),d((()=>{c.current=null}),[n.initialScreen]);let h={app:r,data:n.data,setModalData:n.setModalData,currentScreen:n.initialScreen,lastScreen:s,navigate:(e,t=!0)=>{n.setInitialScreen(e),t&&l(n.initialScreen)},navigateBack:()=>{n.setInitialScreen(s)},resetNavigation:()=>{n.setInitialScreen(null),l(null)},onUserCloseViaDialogOrKeybindRef:c};/*#__PURE__*/return e(Vo.Provider,{value:h,children:[("string"==typeof r.appearance.logo||"img"===r.appearance.logo?.type)&&/*#__PURE__*/t(Ao,{src:"string"==typeof r.appearance.logo?r.appearance.logo:r.appearance.logo.props.src}),n.children]})},qo=()=>l(Vo),Ko=({style:n,...r})=>{let{app:a}=qo();/*#__PURE__*/return e("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"28",height:"28",rx:"3",fill:"dark"===a?.appearance.palette.colorScheme?"#3396ff":"#141414"}),/*#__PURE__*/t("g",{clipPath:"url(#clip0_1765_9946)",children:/*#__PURE__*/t("path",{d:"M8.09448 10.3941C11.3558 7.20196 16.6442 7.20196 19.9055 10.3941L20.2982 10.7782C20.3369 10.8157 20.3677 10.8606 20.3887 10.9102C20.4097 10.9599 20.4206 11.0132 20.4206 11.0671C20.4206 11.121 20.4097 11.1744 20.3887 11.224C20.3677 11.2737 20.3369 11.3186 20.2982 11.3561L18.9554 12.6702C18.9158 12.7086 18.8628 12.7301 18.8077 12.7301C18.7526 12.7301 18.6996 12.7086 18.66 12.6702L18.1198 12.1415C15.8448 9.91503 12.1557 9.91503 9.88015 12.1415L9.30167 12.7075C9.26207 12.7459 9.20909 12.7673 9.15395 12.7673C9.0988 12.7673 9.04582 12.7459 9.00622 12.7075L7.66346 11.3934C7.62475 11.3559 7.59397 11.3109 7.57295 11.2613C7.55193 11.2117 7.5411 11.1583 7.5411 11.1044C7.5411 11.0505 7.55193 10.9971 7.57295 10.9475C7.59397 10.8979 7.62475 10.8529 7.66346 10.8154L8.09448 10.3941ZM22.6829 13.1115L23.8776 14.2814C23.9163 14.319 23.9471 14.3639 23.9681 14.4135C23.9892 14.4632 24 14.5165 24 14.5704C24 14.6243 23.9892 14.6777 23.9681 14.7273C23.9471 14.777 23.9163 14.8219 23.8776 14.8594L18.4893 20.1332C18.4102 20.2101 18.3042 20.2531 18.1938 20.2531C18.0835 20.2531 17.9775 20.2101 17.8984 20.1332L14.0743 16.3901C14.0545 16.3708 14.0279 16.36 14.0003 16.36C13.9726 16.36 13.9461 16.3708 13.9263 16.3901L10.1021 20.1332C10.023 20.2101 9.91703 20.2531 9.8067 20.2531C9.69636 20.2531 9.59038 20.2101 9.51124 20.1332L4.12236 14.8594C4.08365 14.8219 4.05287 14.777 4.03185 14.7273C4.01083 14.6777 4 14.6243 4 14.5704C4 14.5165 4.01083 14.4632 4.03185 14.4135C4.05287 14.3639 4.08365 14.319 4.12236 14.2814L5.31767 13.1115C5.39678 13.0348 5.50265 12.9919 5.61285 12.9919C5.72305 12.9919 5.82892 13.0348 5.90803 13.1115L9.73216 16.8546C9.75194 16.874 9.7785 16.8848 9.80616 16.8848C9.83381 16.8848 9.86037 16.874 9.88015 16.8546L13.7043 13.1115C13.7834 13.0346 13.8894 12.9916 13.9997 12.9916C14.1101 12.9916 14.216 13.0346 14.2952 13.1115L18.1198 16.8546C18.1396 16.874 18.1662 16.8848 18.1938 16.8848C18.2215 16.8848 18.2481 16.874 18.2678 16.8546L22.092 13.1115C22.1711 13.0346 22.2771 12.9916 22.3874 12.9916C22.4977 12.9916 22.6037 13.0346 22.6829 13.1115Z",fill:"white"})}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_1765_9946",children:/*#__PURE__*/t("rect",{width:"20",height:"12.2531",fill:"white",transform:"translate(4 8)"})})})]})};class Zo extends Vi{async initialize(){let e=await this.createProvider();this.provider=e,this.proxyProvider.setWalletProvider(e),this.subscribeListeners(),e.session&&(this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=ko(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown"),this.connected=!0,await this.syncAccounts()),this.initialized=!0,this.emit("initialized");let{createAppKit:t}=await import("@reown/appkit");this.modal??=t({projectId:this.walletConnectCloudProjectId,themeVariables:{"--w3m-z-index":1e6},networks:this.chains,includeWalletIds:la,allowUnsupportedChain:!0}),this.modal.subscribeState((e=>{e.open||this.walletProvider?.session||!this.onQrModalClosed||this.onQrModalClosed()}))}async connect(e){return e.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){let e=this.walletProvider?.session?.peer.metadata.icons?.[0];return{name:ta(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:"string"==typeof e?e:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAHdElNRQfoDAIVODUC+w+GAAAGsUlEQVRYw6WXbYwWVxXHf+fOLAtCXYS2QJdIaClipGCTknXXNqBQMVHbfmhItH4Aral+IAEaG03UxJgYKQJGTUxtDWjaxDSNtcZqIGDwpRuW1oYiVqpdpZSlpC3qysu+PHPP3w/3mXnmeXZbPzjJZO7cefn/z/mfe865xlscq3dGDIguGiHLaMQVLja4s87FShcLo5jtApdddnHexUmHIy475JmdUkPRAQMu7gzT4ljnxJpdk0QPmMFkyAKN2OfOFpc2uuh1J3MZDrjAvXmVEQUuoosRxw642FcEG7IoDxiFxNiu8NYE+vcUYIFYRKKs113bXWx2Z34CoQZsVHOiCZ7mopdzdsFhv8NexEgRDHMxUSNREbh1bwNZwBsFblmfu/a4a6AEENYO5i3AOoEWeEUCF4MOOxBDMQAOk99OJALA2u80sBCwWGBZWG/yRwMaCAbBIAsQTJT3gea1OWfNeaPzvjoHEI85rA8ObtB1v7cIdJkIHgkh9AXpocy0LJjIKvB2wPpZB0v3wkrw5jdNEjeYeMhFX3BAyfn2ke9NUrgB9LrrcZcGJFCld4fWNddXbvbWfWzGR6xJFZsBGh0cBh3bBIxIEGTQ3W0h4NuDaSAzyAxCmGq11Vzf5uaa1aG8p+WFtrEYQGwvjICJkAEqvC+YNmcmMlMNvEaCdrcbyUvQAWDTjVuESHObM6cPGWHmzDwLaEtmzG9Z3qF1zUpXmuuZBb1z4bqeNC6f0WE1NtUTwHzEloiy3BvFisy0sYoLlQtT6XW15md2Qf9SY+2Ngfdca/TMSm/9ewz+/Boc/It45h/i4kSTsKw90SQJsPTvjSZbkWemDW7qTRZ0JEYJWSKxZJ7xmf6M224MzMzbX1s8F1YugjtvMg6eErt/4/z1jUrz1rXUKxnZC2zIg2mdBTK1mFUOKC1fOt/48kdzVixIz86Nij+eEacvpJWyZJ5xy7th8VzjjpuMJfMCW58QL73ekXPVlhsyE+vyzFiplJyauEIyrGIquruMq7qTxk+dcB495rzyTzFepCUWLIFv/kBg081Gd55WUk1IDGFTS89K++TDYxddzKnWcbluHd450xgdh7EGrOo1rr868PMTzqWJRGZ2d8oB/xpL33Xnxl2rjeNn4blXRXduzJ4B5y+28kWscAwXl+yeR654FFZPHoUb710YuPeDOUdPO48di1xptKpeEeHqOcYXNwQKGd88EDk3mqxtxPSfGRlsXRtYt8z4ytPOH/7eqpg1Aso7fYKgK4NPrMpYvsC4/poMA34yVJIQC3sCD9yecdsNyaV5yPj6ryJnR1PAvSNP4J+/1cgDfLbfePaMGGtM7Qdyl12WmKOmXgKKAp54vmBRTxfLrjE+tSYjBPjRM5FrrzIeuD2jf2lLzw8vN4JlfPVp581LsO1DgXv7jSzAiXPw/d+JiYLpjsu26Yfjf5O0rF5WoxsNT9G/bX0XKxakmPjlSee6HlizJJXSX7/oRDc+vjKR+f2wODcKd78/gR8/C9uedF44myJxmhh4OY/ipMQyqaWxmjn95TfEroMFOzbkvG+RceeqViPx1Aln1yEnOow1AnffHCpJAJ5/Vex4UvzptZRdY/O/1dJIS/NkcNmR6MTYah6qzseA4TfFtw4UvHBW1bc/O+7sPhwZHYf/jMODh5yfPudVbXj2TAJ/8XxrOZagNamj4Ei2/GNfuyRxh8t6BG2l15up+MIVODEiFr8rcPS0+O6RBF6mrrEGHHtFzOo2Lo7Dl37hvPQ6mNV6R9JYKgnYWcE37K5HlE2OT/5A0udaPUBHH+BQOMzuNsYLuDyZflTW+fTcmJFDHhJhaZqewMuewXDxcDR9IYyPN6Jj+6K4MF2vV8qBtZJScqVRNi6lpGONVJis5mpKi1WbgwsY+zIsBpcR8mzIZfuTRVZrtdu9odrptR/Xx5XONXJqBmCN0P6YMUQq9WJiwt0Je102WHdbpxSqydMObBWYdwDWLVcqcIMYe3NPjg0Ht84od0Ajju1w2XCr9e6QoqM9V23ZtnmI6cfAMMb9AY0YEHdb6oobEh4y3H3Ize6LsmGvN5IdUnhttdQ9UVrfLk/ljWEZ9wXsqAdQk1EA+O22GcgdZTke/bAs3OPY4HSdcB20HhvVtTMu0jmI8ekAhz2IICj2hKpNqI60NcuIRUHEej1quzubXa2tmZhenrfZmv3YYQ9ipDAIgvHptmblccuDjdRcmjFpWbDi/9ycZjZkRbk5jYztai/AUwiUx+qdEQB/m+25i9lxyvbcjrg45Lmd0uT/3p7/Fw6ODf+WO019AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTEyLTAyVDIxOjU2OjQ4KzAwOjAwMVpslgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0xMi0wMlQyMTo1Njo0OCswMDowMEAH1CoAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMTItMDJUMjE6NTY6NTMrMDA6MDDZv6GRAAAAAElFTkSuQmCC",id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(e){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletClientType=e,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,function(){try{localStorage.removeItem(da)}catch{}}(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise(((e,t)=>{this.onQrModalClosed=()=>{t(new Wi)},(async()=>{let t="",n=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(n?.length&&(t=n[0]),!t||""===t)throw new fe("Unable to retrieve address");this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=ko(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown",this.proxyProvider.rpcTimeoutDuration=zi(this.rpcConfig,this.walletClientType)),this.connected=!0,await this.syncAccounts(n),e()})().catch((e=>{t(e?Ui(e):new fe("Unknown error during connection"))})).finally((()=>this.modal?.close()))}))}disconnect(){this.walletProvider?.disconnect().then((()=>this.onDisconnect())).catch((()=>console.warn("Unable to disconnect Wallet Connect provider")))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(e){this.proxyProvider.setWalletProvider(e)}async createProvider(){let e={};for(let t of this.chains){let n=ia(t.id,this.chains,this.rpcConfig,this.privyAppId);n&&(e[t.id]=n)}let t=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],n=this.chains.map((e=>e.id)),r=await $n.init({projectId:this.walletConnectCloudProjectId,chains:t,optionalChains:n,optionalEvents:jn,optionalMethods:Vn,rpcMap:e,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.toString(),icons:[]}});return r.on("display_uri",(e=>{if(r.signer.abortPairingAttempt(),this.walletEntry){let{redirect:t,href:n}=function(e,t){let n=ca(t);if(n.deepLink)return pa(n.deepLink,e);if(n.universalLink)return ua(n.universalLink,e);throw new he(`Unsupported wallet ${t.id}`)}(e,this.walletEntry);(function({href:e,name:t}){try{localStorage.setItem(da,JSON.stringify({href:e,name:t}))}catch{}})({href:n,name:this.walletEntry.metadata?.shortName||this.walletEntry.name}),this.redirectUri=t;let r=function(e,t){let n=ca(t);if(n.universalLink)return ua(n.universalLink,e)}(e,this.walletEntry);r?.redirect&&(this.fallbackUniversalRedirectUri=r.redirect),g?(ma(t,"_self"),this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri})):this.showPrivyQrModal?this.showPrivyQrModal?.({native:t,universal:this.fallbackUniversalRedirectUri}):this.modal?.open({uri:e})}else this.modal?.open({uri:e})})),r.on("connect",(()=>{this.modal?.close(),r.session?.peer.metadata.url&&(this.walletEntry=ko(r.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown")})),r}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await(this.walletProvider?.enable())}setWalletEntry(e,t){this.walletEntry=e,this.showPrivyQrModal=t}constructor({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:r,shouldEnforceDefaultChainOnConnect:a,privyAppId:i,privyAppName:o,walletClientType:s,appKit:l}){super(s||"unknown",n,r,t),this.connectorType="wallet_connect_v2",this.privyAppId=i,this.privyAppName=o,this.walletConnectCloudProjectId=e,this.rpcConfig=t,this.shouldEnforceDefaultChainOnConnect=a,this.proxyProvider=new Hi(void 0,this.rpcTimeoutDuration),this.modal=l,s&&(this.walletEntry=(e=>Co.getState().listings.find((({slug:t})=>xo(t)===xo(e))))(s),this.walletClientType=s)}}class Yo extends mn{get wallets(){let e=new Set,t=this.walletConnectors.flatMap((e=>e.wallets)).sort(((e,t)=>e.connectedAt&&t.connectedAt?t.connectedAt-e.connectedAt:0)).filter((t=>{let n=`${t.address}${t.walletClientType}${t.connectorType}${t.meta.id}`;return!e.has(n)&&(e.add(n),!0)})),n=t.findIndex((e=>e.address===(this.activeWallet?this.activeWallet:"unknown")));return n>=0&&t.unshift(t.splice(n,1)[0]),t}async initialize(e){if(this.initialized&&!e||(e&&this.removeAllConnectors(),jr.get(Ra)&&(jr.getKeys().forEach((e=>{e.startsWith("walletconnect")&&jr.del(e)})),jr.del(Ra)),this.externalWalletConfig.disableAllExternalWallets))return;let t=ra({store:this.store,walletList:this.walletList,externalWalletConfig:this.externalWalletConfig,walletChainType:this.walletChainType}).then((e=>{e.forEach((({type:e,eip6963InjectedProvider:t,legacyInjectedProvider:n})=>{this.createEthereumWalletConnector({connectorType:"injected",walletClientType:e,providers:{eip6963InjectedProvider:t,legacyInjectedProvider:n}})}))}));for(let e of(this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector({connectorType:"coinbase_wallet",walletClientType:"coinbase_wallet"}),Object.values(ho)))!e.isInstalled&&this.walletList.includes(e.client)&&(["ethereum-only","ethereum-and-solana"].includes(this.walletChainType)&&e.chainTypes.includes("ethereum")&&this.createEthereumWalletConnector({connectorType:"null",walletClientType:e.client,walletConfig:e}),["ethereum-and-solana","solana-only"].includes(this.walletChainType)&&e.chainTypes.includes("solana")&&this.addSolanaWalletConnector(new vo({id:e.client,name:e.name})));this.externalWalletConfig.walletConnect.enabled&&this.createEthereumWalletConnector({connectorType:"wallet_connect_v2",walletClientType:"unknown"}),this.externalWalletConfig.solana.connectors?.get().forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.((e=>{e?.forEach(this.addSolanaWalletConnector)})),await t,this.initialized=!0}findWalletConnector(e,t){return"wallet_connect_v2"===e?this.walletConnectors.filter(ji).find((t=>t.connectorType===e))??null:this.walletConnectors.filter(ji).find((n=>n.connectorType===e&&n.walletClientType===t))??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(yo).find((t=>"unknown"===t.walletClientType?t.walletBranding.id===e:t.walletClientType===e))??null}findEmbeddedWalletConnectors(){return this.walletConnectors.filter((e=>"embedded"===e.connectorType))}onInitialized(e){e.wallets.forEach((e=>{let t=this.storedConnections.find((t=>t.address===e.address&&t.connectorType===e.connectorType&&("solana"===e.type&&"unknown"===t.walletClientType&&"unknown"===e.walletClientType?e.meta.id===t.id:t.walletClientType===e.walletClientType)));t&&(e.connectedAt=t.connectedAt)})),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&this.emit("walletsUpdated")}addEmbeddedWalletConnectors({walletProxy:e,user:t,embeddedWallets:n,defaultChain:r,appId:a,privyClient:i}){let{entropyId:o,entropyIdVerifier:s}=Ni(t);for(let t of n){let n=this.findEmbeddedWalletConnectors().find((e=>e.walletIndex===t.walletIndex));if(n&&ji(n))n.proxyProvider.walletProxy=e;else{let n=new Yi({provider:new Qi({walletProxy:e,address:t.address,entropyId:o,entropyIdVerifier:s,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:r.id,walletIndex:t.walletIndex,privyClient:i,walletAccount:t}),chains:this.chains,defaultChain:r,rpcConfig:this.rpcConfig,imported:!1,walletIndex:t.walletIndex});this.addWalletConnector(n)}}}addImportedWalletConnector(e,t,n,r){let a=this.findWalletConnector("embedded_imported","privy");if(a&&ji(a))a.proxyProvider.walletProxy=e;else{let a=new Yi({provider:new Qi({walletProxy:e,address:t,entropyId:t,entropyIdVerifier:"ethereum-address-verifier",walletIndex:0,rpcConfig:this.rpcConfig,chains:this.chains,appId:r,chainId:n.id}),chains:this.chains,walletIndex:0,defaultChain:n,rpcConfig:this.rpcConfig,imported:!0});this.addWalletConnector(a)}}removeEmbeddedWalletConnectors(){this.walletConnectors=this.walletConnectors.filter((e=>"embedded"!==e.connectorType)),this.storedConnections=mo(),this.emit("walletsUpdated")}removeImportedWalletConnector(){let e=this.findWalletConnector("embedded_imported","privy");if(e){let t=this.walletConnectors.indexOf(e);this.walletConnectors.splice(t,1),this.storedConnections=mo(),this.emit("walletsUpdated")}}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:n,walletConfig:r}){let a=this.findWalletConnector(e,t);if(a&&ji(a))return a instanceof Zo&&a.resetConnection(t),a;let i=(()=>"injected"!==e?"coinbase_wallet"===e?new Ki(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig.coinbaseWallet.config):"null"!==e?new Zo({walletConnectCloudProjectId:this.walletConnectCloudProjectId,rpcConfig:this.rpcConfig,chains:this.chains,defaultChain:this.defaultChain,shouldEnforceDefaultChainOnConnect:this.shouldEnforceDefaultChainOnConnect,privyAppId:this.privyAppId,privyAppName:this.privyAppName,walletClientType:t,appKit:this.appKit}):r?new Xi({id:r.client,name:r.name,defaultChain:this.defaultChain,walletClientType:r.client}):null:"metamask"===t&&n?.eip6963InjectedProvider?new lo(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask"):"metamask"===t&&n?.legacyInjectedProvider?new so(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask"):"phantom"===t&&n?.legacyInjectedProvider?new so(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom"):n?.legacyInjectedProvider&&"unknown_browser_extension"===t?new so(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider):n?.eip6963InjectedProvider?new io(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,t):void 0)();return i&&this.addWalletConnector(i),i||null}addWalletConnector(e){this.walletConnectors.push(e),e.on("initialized",(()=>this.onInitialized(e))),e.on("walletsUpdated",(()=>this.onWalletsUpdated(e))),e.initialize().catch((e=>{console.debug("Failed to initialize connector",e)}))}async activeWalletSign(e){let t=this.wallets,n=t.length>0?t[0]:null;return n&&Fi(n)?n.sign(e):null}setActiveWallet(e){this.activeWallet=v(e),this.emit("walletsUpdated")}setWalletList(e){this.walletList=e,this.initialized&&this.initialize(!0).catch(console.error)}removeAllConnectors(){for(let e of this.walletConnectors)e.removeAllListeners();this.walletConnectors=[]}constructor(e,t,n,r,a,i,o,s,l,c,d,h){super(),this.addSolanaWalletConnector=async e=>{let t=this.findSolanaWalletConnector(e.walletClientType);if(!t||"null"===t.connectorType){if("null"===t?.connectorType){let e=this.walletConnectors.indexOf(t);this.walletConnectors.splice(e,1)}this.addWalletConnector(e)}},this.getEthereumProvider=()=>{let e=this.wallets[0],t=this.walletConnectors.find((t=>t.wallets.find((t=>t.address===e?.address))));return e&&t?t.proxyProvider:new Hi},this.privyAppId=e,this.walletConnectCloudProjectId=t,this.rpcConfig=n,this.chains=r,this.defaultChain=a,this.walletConnectors=[],this.initialized=!1,this.store=i,this.walletList=o,this.shouldEnforceDefaultChainOnConnect=s,this.externalWalletConfig=l,this.privyAppName=c,this.walletChainType=d||"ethereum-only",this.appKit=h,this.storedConnections=mo()}}let Go=[Be,ze,$e];class Jo{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw ue(e)}}async post(e,t,n){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...n})}catch(e){throw ue(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw ue(e)}}constructor({appId:e,appClientId:t,client:n,defaults:r}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=n.clientAnalyticsId,this.sdkVersion=ba,this.client=n,this.defaults=r,this.fallbackApiUrl=n.fallbackApiUrl,this.baseFetch=xr.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:e,options:t})=>{let n=new Headers(t.headers);n.set("privy-app-id",this.appId),this.appClientId&&n.set("privy-client-id",this.appClientId),n.set("privy-ca-id",this.clientAnalyticsId||""),n.set("privy-client",`react-auth:${this.sdkVersion}`);let r=Go.includes(e.toString());if(!n.has("authorization")){let e=await this.client.getAccessToken({disableAutoRefresh:r});null!==e&&n.set("authorization",`Bearer ${e}`)}t.headers=n,t.retryDelay&&"number"==typeof t.retryDelay&&(t.retryDelay=3*t.retryDelay)},onRequestError:({error:e})=>{if(e instanceof DOMException&&"AbortError"===e.name)throw new De}})}}let Qo=/paymaster\.biconomy\.io\/api/i,Xo={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const es=(e,t)=>e&&Qo.test(e)?Xo:t&&t.policy_id?{policyId:t.policy_id}:void 0;class ts{async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(je,{token:this.meta.token})}catch(e){throw ue(e)}}async link(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(Ve,{token:this.meta.token})}catch(e){throw ue(e)}}constructor(e){this.meta={token:e}}}class ns{getOrCreateGuestCredential(e){let t=Na(e);if($r()){if(jr.get(t))return jr.get(t);{let e=Qt.encode(Ha(32));return jr.put(t,e),e}}return Qt.encode(Ha(32))}async authenticate(){if(!this.api)throw new he("Auth flow has no API instance");try{return await this.api.post(He,{guest_credential:this.meta.guestCredential})}catch(e){throw ue(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function rs(){return!(f&&window.location.origin.startsWith("http://localhost"))}const as=Hn((()=>({identityToken:null})));function is(){let{identityToken:e}=as();return{identityToken:e}}var os,ss=((os={}).PRIVY="privy_access_token",os.CUSTOMER="customer_access_token",os);class ls{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(ka)}get privyAccessToken(){return this._getToken(Aa)}_getToken(e){try{let t=jr.get(e);return"string"==typeof t?_i.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=jr.get(xa);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=jr.get(Ma(e));if("string"!=typeof t)return null;{let n=new _i(t);return n.isExpired()?(jr.del(Ma(e)),null):n.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=Rr.get(Ea);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e="privy_access_token"){let t="string"==typeof this.getToken(e),n="string"==typeof this.refreshToken&&"deprecated"!==this.refreshToken;return this.mightHaveServerCookies||t&&n}hasActiveAccessToken(e){let t=_i.parse(this.getToken(e));return null!==t&&!t.isExpired(30)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(e,t){"string"==typeof t?jr.put(Ma(e),t):jr.del(Ma(e))}updateIdentityToken(e){"string"==typeof e?this.storeIdentityToken(e):this.clearIdentityToken()}async _authenticate(e){try{let t=await e.authenticate(),{user:n,is_new_user:r,oauth_tokens:a}=t;this.handleTokenResponse(t);let i=a?{provider:a.provider,accessToken:a.access_token,accessTokenExpiresInSeconds:a.access_token_expires_in_seconds,refreshToken:a.refresh_token,refreshTokenExpiresInSeconds:a.refresh_token_expires_in_seconds,scopes:a.scopes}:void 0;return this._trackAuthenticateEvents(e,r),{user:tn(n),isNewUser:r,oAuthTokens:i}}catch(e){throw console.warn("Error authenticating session"),qe(e)}}_trackAuthenticateEvents(e,t){let n=function(e){return e instanceof Dr?"email":e instanceof fi?"sms":e instanceof ui?"siwe":e instanceof ns?"guest":e instanceof ts?"custom_auth":e instanceof Ya?e.meta.provider:null}(e);n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:n,isNewUser:t}}),"siwe"===n&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:e.meta.connectorType,walletClientType:e.meta.walletClientType}})}async _link(e){try{let t=await e.link(),n=t.oauth_tokens,r=n?{provider:n.provider,accessToken:n.access_token,accessTokenExpiresInSeconds:n.access_token_expires_in_seconds,refreshToken:n.refresh_token,refreshTokenExpiresInSeconds:n.refresh_token_expires_in_seconds,scopes:n.scopes}:void 0;return{user:tn(t),oAuthTokens:r}}catch(e){throw console.warn("Error linking account"),qe(e)}}async _refresh(){if(!this.api)throw new he("Session has no API instance");if(!this.client)throw new he("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let e=this.token,t=this.refreshToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let n;if(!(e&&t||this.mightHaveServerCookies))return null;{let r={};e&&(r.authorization=`Bearer ${e}`),n=await this.api.post(Be,t?{refresh_token:t}:{},{headers:r})}return this.handleTokenResponse(n),tn(n.user)}catch(e){if(e instanceof Ke&&e.privyErrorCode===Te.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw qe(e)}}handleTokenResponse(e){e.session_update_action&&"set"!==e.session_update_action?"clear"===e.session_update_action?this.destroyLocalState():"ignore"===e.session_update_action&&(e.token&&(this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token)),e.identity_token&&this.storeIdentityToken(e.identity_token)):this._storeAllTokens(e)}_storeAllTokens(e){this.storeRefreshToken(e.refresh_token),this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),e.identity_token&&this.storeIdentityToken(e.identity_token)}async _destroy(){try{await(this.api?.post(ze,{refresh_token:this.refreshToken}))}catch(e){console.warn("Error destroying session")}this.destroyLocalState()}destroyLocalState(){this.storeRefreshToken(null),this.storeCustomerAccessToken(null),this.storePrivyAccessToken(null),this.clearIdentityToken()}storeCustomerAccessToken(e){if("string"==typeof e){let t=jr.get(ka);if(jr.put(ka,e),!this.client?.useServerCookies){let t=_i.parse(e)?.expiration;Rr.set(Ta,e,{sameSite:"Strict",secure:rs(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else jr.del(ka),Rr.remove(Ta),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(jr.put(xa,e),this.client?.useServerCookies||Rr.set(Ea,"t",{sameSite:"Strict",secure:rs(),expires:30})):(jr.del(xa),Rr.remove("privy-refresh-token"),Rr.remove(Ea))}storePrivyAccessToken(e){"string"==typeof e?jr.put(Aa,e):jr.del(Aa)}storeIdentityToken(e){if(as.setState({identityToken:e}),this.client?.useServerCookies)return;jr.put(Ia,e);let t=_i.parse(e)?.expiration;Rr.set(_a,e,{sameSite:"Strict",secure:rs(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){jr.del(Ia),as.setState({identityToken:null}),Rr.remove(_a)}constructor(){this.authenticateOnce=new ga((async e=>this._authenticate(e))),this.linkOnce=new ga((async e=>this._link(e))),this.refreshOnce=new ga(this._refresh.bind(this)),this.destroyOnce=new ga(this._destroy.bind(this))}}let cs;var ds=0,hs="__private_"+ds+++"__getOrGenerateClientAnalyticsId";class ps{getAppId(){return this.appId}initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:r,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:o,externalWalletConfig:s,appName:l,walletChainType:c,appKit:d}){this.connectors||(this.connectors=new Yo(this.appId,e,t,n,r,a,i,o,s,l,c,d))}generateApi(){let e=new Jo({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=e,e}updateApiUrl(e){this.apiUrl=e||this.fallbackApiUrl,this.api=this.generateApi(),e&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new he("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new he("No auth flow in progress.");let{oAuthTokens:e}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:e}}storeProviderAccessToken(e,t){this.session.storeProviderAccessToken(e,t)}getProviderAccessToken(e){return this.session.getProviderAccessToken(e)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(e){e.linkedAccounts.filter((e=>"cross_app"===e.type)).forEach((e=>{this.storeProviderAccessToken(e.providerApp.id,null)}))}startAuthFlow(e){return e.api=this.api,this.authFlow=e,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(Ze,{action:"verify"})}catch(e){throw ue(e)}}async initMfaPasskeyVerification(){try{return(e=>({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}))((await this.api.post(Ye,{})).options)}catch(e){throw ue(e)}}async getCrossAppProviderDetails(e){try{return this._cachedProviderAppDetails[e]||(this._cachedProviderAppDetails[e]=await this.api.get(`/api/v1/apps/${e}/cross-app/details`)),this._cachedProviderAppDetails[e]}catch(e){console.error("Error fetching cross app provider details",e)}}async acceptTerms(){try{let e=await this.api.post(Ge,{});return tn(e)}catch(e){throw qe(e)}}async unlinkEmail(e){try{let t=await this.api.post(Je,{address:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkPhone(e){try{let t=await this.api.post(Qe,{phoneNumber:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(Xe,{address:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(et,{address:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkOAuth(e,t){try{let n=await this.api.post(tt,{provider:e,subject:t});return await this.getAuthenticatedUser()??tn(n)}catch(e){throw qe(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(nt,{fid:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async unlinkTelegram(e){try{let t=await this.api.post(rt,{telegram_user_id:e});return await this.getAuthenticatedUser()??tn(t)}catch(e){throw qe(e)}}async revokeDelegatedWallet(){try{await this.api.post(at,{})}catch(e){throw qe(e)}}async createAnalyticsEvent({eventName:e,payload:t,timestamp:n,options:r}){if("undefined"!=typeof window)try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post($e,{event_name:e,client_id:this.clientAnalyticsId,payload:{...t||{},clientTimestamp:n?n.toISOString():(new Date).toISOString()}},{retry:-1,keepalive:r?.keepAlive??!1})}catch(e){console.log("Unable to submit event. This is not an issue.")}}async signMoonpayOnRampUrl(e){try{return this.api.post(it,e)}catch(e){throw qe(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(ot,e)}catch(e){throw qe(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${st}?partnerUserId=${e}`)}catch(e){throw qe(e)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(e){return await this.getPrivyAccessToken(e)||await this.getCustomerAccessToken(e)}async getCustomerAccessToken(e){return await this._getToken(ss.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(ss.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?Ei.parse(this.session.getToken(e))?.appId!==this.appId?(await this.logout(),null):this.session.getToken(e):(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials(e)?(await this.session.refresh(),this.session.getToken(e)):null:null}async getSmartWalletsConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let n=await this.api.get(`/api/v1/apps/${this.appId}/smart_wallets`,{baseURL:this.fallbackApiUrl,headers:e});return n.enabled?{enabled:n.enabled,smartWalletType:n.smart_wallet_type,configuredNetworks:n.configured_networks.map((e=>({chainId:e.chain_id,bundlerUrl:e.bundler_url,paymasterUrl:e.paymaster_url,paymasterContext:es(e.paymaster_url,e.paymaster_context)})))}:{enabled:n.enabled}}catch(e){throw qe(e)}}async getUsdTokenPrice(e){try{return(await this.api.get(`/api/v1/token_price?chainId=${e.id}&tokenSymbol=${e.nativeCurrency.symbol}`)).usd}catch(t){return void console.error(`Unable to fetch token price for chain with id ${e.id}`)}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch(e){return void console.error("Unable to fetch token price for SOL")}}async getSplTokenMetadata({mintAddress:e,cluster:t}){try{return await this.api.get(`/api/v1/spl_token_info?mint_address=${e}&cluster=${t}`)}catch(n){return void console.error(`Unable to fetch token metadata for ${t}:${e}`)}}async requestFarcasterSignerStatus(e){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:e})}catch(e){throw console.error("Unable to fetch Farcaster signer status"),e}}async generateSiweNonce({address:e,captchaToken:t}){try{return(await this.api.post(lt,{address:e,token:t})).nonce}catch(e){throw qe(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i}){return await this.api.post(ct,{message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i})}async linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a}){return await this.api.post(dt,{message:e,signature:t,chainId:n,walletClientType:r,connectorType:a})}async linkSmartWallet({message:e,signature:t,smartWalletType:n}){try{let r=await this.api.post(ht,{message:e,signature:t,smart_wallet_type:n});return tn(r)}catch(e){throw qe(e)}}async linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a}){try{let i=await this.linkWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a});return tn(i)}catch(e){throw qe(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(pt,{address:e,token:t})).nonce}catch(e){throw qe(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,mode:a,messageType:i="plain"}){return await this.api.post(ut,{message:e,signature:t,walletClientType:n,connectorType:r,mode:a,message_type:i})}async sendAccountTransferRequest({nonce:e,account:t,accountType:n,externalWalletMetadata:r,telegramAuthResult:a,telegramWebAppData:i,farcasterEmbeddedAddress:o,oAuthUserInfo:s}){try{let l,c;switch(n){case"email":l=vt,c={nonce:e,email:t};break;case"sms":l=wt,c={nonce:e,phoneNumber:t};break;case"siwe":if(l=ft,!r)throw Error("Wallet parameters must be defined");c={nonce:e,address:t,...r};break;case"farcaster":l=yt,c={nonce:e,farcaster_id:t,farcaster_embedded_address:o};break;case"telegram":l=gt,c={nonce:e,telegram_auth_result:a,telegram_web_app_data:i};break;case"custom":case"guest":case"passkey":throw Error("Invalid transfer account type");default:l=mt,c={nonce:e,userInfo:s}}let d=await this.api.post(l,c);return await this.getAuthenticatedUser()??tn(d)}catch(e){throw qe(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,messageType:a="plain"}){return await this.api.post(Ct,{message:e,signature:t,walletClientType:n,connectorType:r,message_type:a})}async linkWithSiws({message:e,signature:t,walletClientType:n,connectorType:r,messageType:a="plain"}){try{let i=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,messageType:a});return tn(i)}catch(e){throw qe(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(bt);return this.session.updateIdentityToken(e.identity_token),tn(e.user)}catch(e){throw qe(e)}}async scanTransaction(e){try{return await this.api.post(kt,e)}catch(e){throw qe(e)}}constructor({apiUrl:e=fa,appId:t,appClientId:n,timeout:r=2e4}){Object.defineProperty(this,hs,{value:us}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==fa&&e.startsWith("https://privy."),this.timeout=r,this.appId=t,this.appClientId=n,this.clientAnalyticsId=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}(this,hs)[hs](),cs||(cs=new ls),this.session=cs,this.api=this.generateApi(),this.session.client=this}}function us(){if("undefined"==typeof window)return null;try{let e=jr.get(Sa);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=Gt();try{return jr.put(Sa,e),e}catch(t){return e}}const ms=({delayedExecution:e,...n})=>{let{enabled:r,siteKey:a,appId:i,setError:o,setToken:l,setExecuting:c,ref:h}=ki(),[,p]=s((()=>a?.split("t:")||[]),[a]);if(d((()=>h.current?.remove),[]),!r)return null;if(!p)throw Error("Unsupported captcha site key");/*#__PURE__*/return t("div",{className:"hidden h-0 w-0",children:/*#__PURE__*/t(wn,{...n,ref:h,siteKey:p,options:{action:i,size:"invisible",...e?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{n.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{n.onError?.(),o("Captcha failed"),c(!1)},onSuccess:e=>{n.onSuccess?.(e),l(e),c(!1)},onExpire:()=>{n.onExpire?.();try{h.current?.reset(),o(void 0),l(void 0)}catch(e){o("expired_and_failed_reset")}}})})},gs=e=>{let[t,n]=o("auto");return d((()=>{let t=new ResizeObserver((e=>{n(e[0]?.contentRect.height??"auto")}));return e.current&&t.observe(e.current),()=>{e.current&&t.unobserve(e.current)}}),[e.current]),t},ys={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:[]}},fs=/*#__PURE__*/c(void 0);let ws=()=>l(fs);function vs(e,t){if(!t)return;let n=ws().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 Cs(e,t,n,...r){for(let a of e.current[t][n])a(...r)}function bs(){let e=ws();return(t,n,...r)=>Cs(e,t,n,...r)}function ks(e){vs("configureMfa",e)}const Ts=/*#__PURE__*/vn.div.withConfig({displayName:"Grow",componentId:"sc-ddbf22b4-0"})(["text-align:left;flex-grow:1;"]),xs=/*#__PURE__*/vn.div.withConfig({displayName:"AlignBottom",componentId:"sc-ddbf22b4-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),As=/*#__PURE__*/vn.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;}"]),Is=/*#__PURE__*/vn(As).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 _s=/*#__PURE__*/Cn(["&&{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 Es=/*#__PURE__*/vn.div.withConfig({displayName:"Subtitle",componentId:"sc-ddbf22b4-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),Ss=/*#__PURE__*/vn.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-ddbf22b4-5"})(["",""],_s),Ns=/*#__PURE__*/vn.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-ddbf22b4-6"})(["",""],_s),Ms=/*#__PURE__*/vn.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;":"")),Ps=/*#__PURE__*/vn.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-ddbf22b4-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),Ws=/*#__PURE__*/vn.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;}"]),Us=({success:r,fail:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Os,{className:r?"success":a?"fail":""}),/*#__PURE__*/t(Ls,{className:r?"success":a?"fail":""})]}),Os=/*#__PURE__*/vn.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)")),Ls=/*#__PURE__*/vn(Os).withConfig({displayName:"LoaderFaint",componentId:"sc-ce7792e2-1"})(["&&{border-bottom-color:",";animation:none;opacity:0.5;}"],(e=>e.color??"var(--privy-color-accent)")),Rs=e=>/*#__PURE__*/t(Fs,{color:e.color||"var(--privy-color-foreground-3)"});let Fs=/*#__PURE__*/vn(Os).withConfig({displayName:"StyledButtonLoader",componentId:"sc-ce7792e2-2"})(["&&{height:1rem;width:1rem;margin:2px 0;border-width:1.5px;transition:border-color 200ms ease;}"]);const Ds=/*#__PURE__*/vn.button.withConfig({displayName:"Button",componentId:"sc-b2dfb420-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;}"]),Bs=({children:n,loading:r,disabled:a,success:i,loadingText:o="Loading...",...s})=>/*#__PURE__*/t(Vs,{disabled:r||a,$success:i,...s,children:r?/*#__PURE__*/e("span",{children:[/*#__PURE__*/t(Rs,{}),o?/*#__PURE__*/t("span",{children:o}):null]}):n}),zs=({children:e,loading:n,disabled:r,...a})=>/*#__PURE__*/t($s,{disabled:r,...a,children:n?/*#__PURE__*/t(Rs,{color:"var(--privy-color-foreground-accent)"}):e});let $s=/*#__PURE__*/vn(Ds).withConfig({displayName:"StyledPrimaryButtonWithoutGray",componentId:"sc-b2dfb420-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 js=({children:n,loading:r,disabled:a,loadingText:i="Loading...",...o})=>/*#__PURE__*/t(Vs,{as:"a",disabled:r||a,...o,children:r?/*#__PURE__*/e("span",{children:[/*#__PURE__*/t(Rs,{}),i?/*#__PURE__*/t("span",{children:i}):null]}):n});let Vs=/*#__PURE__*/vn(Ds).withConfig({displayName:"StyledPrimaryButton",componentId:"sc-b2dfb420-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__*/Cn(["&&&,&&&:hover,&&&:active{background-color:var(--privy-color-background-2);color:var(--privy-color-foreground-3);cursor:not-allowed;pointer-events:none;}"]):""));const Hs=({children:n,loading:r,disabled:a,loadingText:i="Loading...",...o})=>/*#__PURE__*/t(qs,{disabled:r||a,...o,children:r?/*#__PURE__*/e("span",{children:[/*#__PURE__*/t(Rs,{}),i?/*#__PURE__*/t("span",{children:i}):null]}):n});let qs=/*#__PURE__*/vn(Ds).withConfig({displayName:"StyledSecondaryButton",componentId:"sc-b2dfb420-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 Ks=/*#__PURE__*/vn.button.withConfig({displayName:"SoftCtaButton",componentId:"sc-b2dfb420-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__*/Cn(["pointer-events:none;"]))),Zs=({children:n,onClick:r,disabled:a,isSubmitting:i,...o})=>/*#__PURE__*/e(Ys,{$isSubmitting:i,onClick:r,disabled:a,...o,children:[/*#__PURE__*/t("span",{children:n}),
|
|
2
2
|
/*#__PURE__*/t("span",{children:/*#__PURE__*/t(Rs,{})})]});let Ys=/*#__PURE__*/vn.button.withConfig({displayName:"StyledEmbeddedButton",componentId:"sc-b2dfb420-6"})(["&&{color:var(--privy-color-accent);font-size:16px;font-style:normal;font-weight:500;line-height:24px;cursor:pointer;border-radius:0px var(--privy-border-radius-mdlg) var(--privy-border-radius-mdlg) 0px;border:none;transition:color 200ms ease;@media (min-width:441px){font-size:14px;}:hover{color:var(--privy-color-accent-dark);}&& > :first-child{opacity:",";}&& > :last-child{position:absolute;display:flex;top:50%;left:50%;transform:translate3d(-50%,-50%,0);opacity:",";}:disabled,:hover:disabled{color:var(--privy-color-foreground-3);cursor:not-allowed;}}"],(e=>e.$isSubmitting?0:1),(e=>e.$isSubmitting?1:0));function Gs(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 Js=/*#__PURE__*/vn.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 Qs({app:{legal:{privacyPolicyUrl:n,termsAndConditionsUrl:r,requireUsersAcceptTerms:a}},alwaysShowImplicitConsent:i}){let o=!(!n||!r);return a&&!i||!r&&!n?
|
|
3
3
|
/*#__PURE__*/t(Js,{}):
|
|
4
4
|
/*#__PURE__*/ /*#__PURE__*/e(Js,{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 Xs=()=>{let{appearance:e}=$o();/*#__PURE__*/return t(el,{children:e.footerLogo??/*#__PURE__*/t("a",{href:"https://www.privy.io/",target:"_blank",id:"protected-by-privy",children:/*#__PURE__*/t(Gs,{height:13,width:150})})})},el=/*#__PURE__*/vn.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;}"]),tl=({backFn:e})=>/*#__PURE__*/t("div",{children:/*#__PURE__*/t(il,{onClick:e,children:/*#__PURE__*/t(En,{height:"16px",width:"16px",strokeWidth:2})})}),nl=({infoFn:e})=>/*#__PURE__*/t("div",{children:/*#__PURE__*/t(ol,{"aria-label":"info",onClick:e,children:/*#__PURE__*/t(Sn,{height:"22px",width:"22px",strokeWidth:2})})}),rl=e=>/*#__PURE__*/t("div",{children:/*#__PURE__*/t(il,{"aria-label":"close modal",onClick:e.onClose,children:/*#__PURE__*/t(Nn,{height:"16px",width:"16px",strokeWidth:2})})}),al=({backFn:n,infoFn:r,onClose:a,title:i,closeable:o=!0})=>{let{closePrivyModal:s}=Pt(),l=$o();/*#__PURE__*/return e(sl,{children:[/*#__PURE__*/e(ll,{children:[n&&/*#__PURE__*/t(tl,{backFn:n}),r&&/*#__PURE__*/t(nl,{infoFn:r})]}),i&&/*#__PURE__*/t(dl,{id:"privy-dialog-title",children:i}),/*#__PURE__*/t(cl,{children:!l.render.standalone&&o&&/*#__PURE__*/t(rl,{onClose:a||(()=>s())})})]})};let il=/*#__PURE__*/vn.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;}}"]),ol=/*#__PURE__*/vn(il).withConfig({displayName:"TransparentStyledButton",componentId:"sc-f295093d-1"})(["&&{background-color:transparent;}"]),sl=/*#__PURE__*/vn.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);}"]),ll=/*#__PURE__*/vn.div.withConfig({displayName:"LeftActionContainer",componentId:"sc-f295093d-3"})(["flex:1;align-items:center;display:flex;gap:8px;"]),cl=/*#__PURE__*/vn.div.withConfig({displayName:"RightActionContainer",componentId:"sc-f295093d-4"})(["flex:1;display:flex;justify-content:flex-end;"]),dl=/*#__PURE__*/vn.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);"]),hl=Array(6).fill("");var pl,ul=((pl=ul||{})[pl.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",pl[pl.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",pl);function ml(e){return/^[0-9]{1}$/.test(e)}function gl(e){return 6===e.length&&e.every(ml)}const yl=({onChange:r,disabled:a,errorReasonOverride:i,success:s})=>{let[l,c]=o(hl),[d,h]=o(null),[p,u]=o(null),m=async e=>{e.preventDefault();let t=e.currentTarget.value.replace(/\s+/g,"");if(""===t)return;let n=l.reduce(((e,t)=>e+Number(ml(t))),0),a=t.split(""),i=!a.every(ml),o=a.length+n>6;if(i)return h("Passcode can only be numbers"),void u(1);if(o)return h("Passcode must be exactly 6 numbers"),void u(1);h(null),u(null);let s=Number(e.currentTarget.name?.charAt(4)),d=[...t||[""]].slice(0,6-s),p=[...l.slice(0,s),...d,...l.slice(s+d.length)];c(p);let m=Math.min(Math.max(s+d.length,0),5),g=document.querySelector(`input[name=pin-${m}]`);if(g?.focus(),gl(p))try{await r(p.join(""));let e=document.querySelector(`input[name=pin-${m}]`);e?.blur()}catch(e){u(1),h(e.message)}else try{await r(null)}catch(e){u(1),h(e.message)}},y=s?"success":!(!i&&!d)?"fail":"";/*#__PURE__*/return t(n,{children:/*#__PURE__*/e(fl,{children:[/*#__PURE__*/t("div",{children:l.map(((e,n)=>/*#__PURE__*/t("input",{name:`pin-${n}`,type:"text",value:l[n],onChange:m,onKeyUp:e=>{"Backspace"===e.key&&(e=>{1===p&&(h(null),u(null));let t=[...l.slice(0,e),"",...l.slice(e+1)];if(c(t),e>0){let t=document.querySelector(`input[name=pin-${e-1}]`);t?.focus()}gl(t)?r(t.join("")):r(null)})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:y,autoComplete:g?"one-time-code":"off",disabled:a},n)))}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(wl,{$fail:!!i||!!d,children:i||d})})]})})};let fl=/*#__PURE__*/vn.div.withConfig({displayName:"PinInputContainer",componentId:"sc-7a171f6-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;@media (max-width:440px){margin-top:8px;margin-bottom:8px;}> div:nth-child(1){display:flex;justify-content:center;gap:0.5rem;width:100%;border-radius:var(--privy-border-radius-md);> input{border:1px solid var(--privy-color-foreground-4);background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);padding:8px 10px;height:58px;width:46px;text-align:center;font-size:18px;}> input:disabled{background:var(--privy-color-background-2);}> input:focus{border:1px solid var(--privy-color-accent);}> input:invalid{border:1px solid var(--privy-color-error);}> input.success{border:1px solid var(--privy-color-success);}> input.fail{border:1px solid var(--privy-color-error);animation:shake 180ms;animation-iteration-count:2;}}@keyframes shake{0%{transform:translate(1px,0px);}33%{transform:translate(-1px,0px);}67%{transform:translate(-1px,0px);}100%{transform:translate(1px,0px);}}"]),wl=/*#__PURE__*/vn.div.withConfig({displayName:"InputHelp",componentId:"sc-7a171f6-1"})(["line-height:20px;font-size:13px;display:flex;justify-content:flex-start;width:100%;color:",";"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)"));const vl=({label:n,children:r,valueStyles:a})=>/*#__PURE__*/e(Cl,{children:[/*#__PURE__*/t("div",{children:n}),/*#__PURE__*/t(bl,{style:{...a},children:r})]});let Cl=/*#__PURE__*/vn.div.withConfig({displayName:"StyledDetailsRow",componentId:"sc-4ebfdd45-0"})(["display:flex;align-items:center;justify-content:space-between;width:100%;> :first-child{color:var(--privy-color-foreground-3);text-align:left;}> :last-child{color:var(--privy-color-foreground-2);text-align:right;}"]),bl=/*#__PURE__*/vn.div.withConfig({displayName:"ValueWrapper",componentId:"sc-4ebfdd45-1"})(["font-size:14px;line-height:100%;display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-full);background-color:var(--privy-color-background-2);padding:4px 8px;"]),kl=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2}),Tl=e=>kl.format(e);const xl=(e,t)=>{let n=Tl(t*parseFloat(e));return"$0.00"!==n?n:"<$0.01"},Al=(e,t)=>{let n=Tl(t*parseFloat(Lt(e)));return"$0.00"===n?"<$0.01":n},Il=(e,t,n=6,r=!1)=>`${_l(e,n,r)} ${t}`,_l=(e,t=6,n=!1)=>{let r=parseFloat(Lt(e)).toFixed(t).replace(/0+$/,"").replace(/\.$/,"");return n?r:`${"0"===r?"<0.001":r}`},El=e=>e.reduce(((e,t)=>e+t),0n),Sl=(e,t)=>{let{chains:n}=Pt(),r=`https://etherscan.io/address/${t}`,a=`${((e,t)=>{let n=Number(e),r=t.find((e=>e.id===n));if(!r)throw new fe(`Unsupported chainId ${e}`,4901);return r.blockExplorers?.default.url})(e,n)}/address/${t}`;if(!a)return r;try{new URL(a)}catch{return r}return a};async function Nl(e,t){try{return await e}catch{return t}}const Ml="11111111111111111111111111111111",Pl=["CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C","CPMDWBwJDtYax9qW7AyRuVC19Cc4L4Vcy4n2BHAbHkCW"],Wl=["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"];let Ul=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2});function Ol(e,t=6,n=!1,r=!1){let a=(parseFloat(e.toString())/1e9).toFixed(t).replace(/0+$/,"").replace(/\.$/,""),i=r?"":" SOL";return n?`${a}${i}`:`${"0"===a?"<0.001":a}${i}`}function Ll(e,t){let n=parseFloat(e.toString())/1e9,r=Ul.format(t*n);return"$0.00"===r?"<$0.01":r}function Rl({amount:e,fee:t,tokenPrice:n,isUsdc:r}){let a=BigInt(Math.floor(parseFloat(e)*10**(r?6:9))),i=r?a:a+t;return{fundingAmountInBaseUnit:a,fundingAmountInUsd:n?Ll(a,n):void 0,totalPriceInUsd:n?Ll(i,n):void 0,totalPriceInNativeCurrency:Ol(i),feePriceInNativeCurrency:Ol(t),feePriceInUsd:n?Ll(t,n):void 0}}let Fl={"mainnet-beta":{EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:{symbol:"USDC",decimals:6,address:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"},Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:{symbol:"USDT",decimals:6,address:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"},So11111111111111111111111111111111111111112:{symbol:"SOL",decimals:9,address:"So11111111111111111111111111111111111111112"}},devnet:{"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU":{symbol:"USDC",decimals:6,address:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"},EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS:{symbol:"USDT",decimals:6,address:"EJwZgeZrdC8TXTQbQBoL6bfuAnFUUy1PVCMB4DYPzVaS"},So11111111111111111111111111111111111111112:{symbol:"SOL",decimals:9,address:"So11111111111111111111111111111111111111112"}},testnet:{}};async function Dl(e,t,n){let r=Fl[e];if(!r[n]){let a=await t.getSplTokenMetadata({mintAddress:n,cluster:e});a&&(r[n]={address:n,symbol:a.symbol,decimals:a.decimals})}return r[n]}function Bl(e){return"version"in e}function zl(e,t){let n=(Bl(e)?e.message:e.compileMessage()).staticAccountKeys.find((e=>e.toBase58()===t));if(!n)throw Error(`Transaction does not contain public key ${t}`);return n}function $l(e,t,n){return{signature:e,parsedTransaction:n??null,signedTransaction:t,fees:BigInt(n?.meta?.fee||0)}}async function jl(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)))}async function Vl({tx:e,connection:t,client:n,checkFunds:r}){let a=Bl(e)?e.message:e.compileMessage(),i=a.staticAccountKeys[0]?.toBase58()??"",o=await async function(e,t){return BigInt((Bl(e)?(await t.getFeeForMessage(e.message)).value:await e.getEstimatedFee(t))??0)}(e,t),s=!r||await Nl(jl(e,t),!0),l={},c=[],d=await async function(e,t){return[...e.staticAccountKeys.map((e=>e)),...(await Promise.all(e.addressTableLookups.map((async e=>t.getAddressLookupTable(e.accountKey).then((({value:e})=>e)))))).map(((t,n)=>[...e.addressTableLookups[n]?.writableIndexes.map((e=>{let r=t?.state.addresses[e];if(r)return{key:r,isWritable:!0,altIdx:n}}))??[],...e.addressTableLookups[n]?.readonlyIndexes.map((e=>{let r=t?.state.addresses[e];if(r)return{key:r,isWritable:!1,altIdx:n}}))??[]])).flat().filter((e=>!!e)).sort(((e,t)=>e.isWritable!==t.isWritable?e.isWritable?-1:1:e.altIdx-t.altIdx)).map((({key:e})=>e))]}(a,t);for(let e of a.compiledInstructions){let r=a.staticAccountKeys[e.programIdIndex]?.toBase58()||"";if("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"!==r&&"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"!==r)if(r!==Ml){if("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"===r){let t=await Nl(function(e,t,n){let[r,a,i,o]=e.accountKeyIndexes.map((e=>t[e]));return{type:"ata-creation",program:n,payer:r?.toBase58(),ata:a?.toBase58(),owner:i?.toBase58(),mint:o?.toBase58()}}(e,d,r));if(!t){c.push({type:"unknown",program:r,discriminator:e.data[0]});continue}if(c.push(t),t.ata&&t.owner&&t.mint){l[t.ata]={owner:t.owner,mint:t.mint};continue}}if(Pl.includes(r)){let a=await Nl(Zl(e,d,t,n,r));if(!a){c.push({type:"unknown",program:r,discriminator:e.data[0]});continue}c.push(a)}else if(Wl.includes(r)){let a=await Nl(Yl(e,d,t,n,r));if(!a){c.push({type:"unknown",program:r,discriminator:e.data[0]});continue}c.push(a)}else c.push({type:"unknown",program:r,discriminator:e.data[0]})}else{let t=await Nl(Kl(e,d));if(!t){c.push({type:"unknown",program:r,discriminator:e.data[0]});continue}c.push(t)}else{let a=await Nl(ql(e,d,t,n,l,r));if(!a){c.push({type:"unknown",program:r,discriminator:e.data[0]});continue}c.push(a),"spl-transfer"===a.type&&(a.fromAta&&a.fromAccount&&a.token.address&&(l[a.fromAta]??={owner:a.fromAccount,mint:a.token.address}),a.toAta&&a.toAccount&&a.token.address&&(l[a.toAta]??={owner:a.toAccount,mint:a.token.address}))}}return{spender:i,fee:o,instructions:c,hasFunds:!!s}}function Hl(e,t=0){try{return function(e,t=0){let n=0n;for(let r=0;r<8;r++)n|=BigInt(e[t+r])<<BigInt(8*r);return n}(e,t)}catch{}try{return e.readBigInt64LE(t)}catch{}let n=mi(e);try{return((e,t=0)=>{let n=e[t],r=e[t+7];if(!n||!r)throw Error(`Buffer offset out of range: first: ${n}, last: ${r}.`);return(BigInt(e[t+4]+256*e[t+5]+65536*e[t+6]+(r<<24))<<32n)+BigInt(n+256*e[++t]+65536*e[++t]+16777216*e[++t])})(n)}catch{}try{return n.subarray(t).readBigInt64LE()}catch{}try{return n.readBigInt64LE(t)}catch{}return 0n}async function ql(e,t,n,r,a,i){let o=e.data[0],s=e.accountKeyIndexes.map((e=>t[e]));if(1===o){let[e,t,n]=s;return{type:"spl-init-account",program:i,account:e?.toBase58(),mint:t?.toBase58(),owner:n?.toBase58()}}if(3===o){let t,o,[l,c,d]=s,h="",p=c?a[c.toBase58()]:void 0;if(p)t=p.owner,h=p.mint;else if(c){let e=await n.getParsedAccountInfo(c,"confirmed"),r=e.value?.data;t=r?.parsed?.info?.owner,h=r?.parsed?.info?.mint??"",o=r?.parsed?.info?.tokenAmount?.decimals}if(!h&&l){let e=await n.getParsedAccountInfo(l,"confirmed"),t=e.value?.data;h=t?.parsed?.info?.mint??""}let u=Po(n.rpcEndpoint),m=await Dl(u,r,h),g=m?.symbol??"";return o??=m?.decimals??9,{type:"spl-transfer",program:i,fromAta:l?.toBase58(),fromAccount:d?.toBase58(),toAta:c?.toBase58(),toAccount:t,value:Hl(e.data,1),token:{symbol:g,decimals:o,address:h}}}if(9===o){let[e,t,n]=s;return{type:"spl-close-account",program:i,source:e?.toBase58(),destination:t?.toBase58(),owner:n?.toBase58()}}if(17===o)return{type:"spl-sync-native",program:i};throw Error(`Token program instruction type ${o} not supported`)}async function Kl(e,t){let n=e.data[0],r=e.accountKeyIndexes.map((e=>t[e]));if(0===n){let[,t]=r;return{type:"create-account",program:Ml,account:t?.toBase58(),value:Hl(e.data,4),withSeed:!1}}if(2===n){let[t,n]=r;return{type:"sol-transfer",program:Ml,fromAccount:t?.toBase58(),toAccount:n?.toBase58(),token:{symbol:"SOL",decimals:9},value:Hl(e.data,4),withSeed:!1}}if(3===n){let[,t]=r,n=Hl(e.data.slice(e.data.length-32-8-8));return{type:"create-account",program:Ml,account:t?.toBase58(),withSeed:!0,value:n}}if(11===n){let[t,n]=r;return{type:"sol-transfer",program:Ml,fromAccount:t?.toBase58(),toAccount:n?.toBase58(),value:Hl(e.data,4),token:{symbol:"SOL",decimals:9},withSeed:!0}}throw Error(`System program instruction type ${n} not supported`)}async function Zl(e,t,n,r,a){let i=e.accountKeyIndexes.map((e=>t[e]?.toBase58())),o=e.data[0],s=Po(n.rpcEndpoint);if(143===o){let t=i[10],n=i[11];return{type:"raydium-swap-base-input",program:a,mintIn:t,mintOut:n,tokenIn:t?await Dl(s,r,t):void 0,tokenOut:n?await Dl(s,r,n):void 0,amountIn:Hl(e.data,8),minimumAmountOut:Hl(e.data,16)}}if(55===o){let t=i[10],n=i[11];return{type:"raydium-swap-base-output",program:a,mintIn:t,mintOut:n,tokenIn:t?await Dl(s,r,t):void 0,tokenOut:n?await Dl(s,r,n):void 0,maxAmountIn:Hl(e.data,8),amountOut:Hl(e.data,16)}}throw Error(`Raydium swap program instruction type ${o} not supported`)}async function Yl(e,t,n,r,a){let i=e.data[0],o=e.accountKeyIndexes.map((e=>t[e])),s=Po(n.rpcEndpoint);if([208,51,239,151,123,43,237,92].includes(i)){let t=o[5]?.toBase58(),n=o[6]?.toBase58();return{type:"jupiter-swap-exact-out-route",program:a,mintIn:t,mintOut:n,tokenIn:t?await Dl(s,r,t):void 0,tokenOut:n?await Dl(s,r,n):void 0,outAmount:Hl(e.data,e.data.length-1-2-8-8),quotedInAmount:Hl(e.data,e.data.length-1-2-8)}}if([176,209,105,168,154,125,69,62].includes(i)){let t=o[7]?.toBase58(),n=o[8]?.toBase58();return{type:"jupiter-swap-exact-out-route",program:a,mintIn:t,mintOut:n,tokenIn:t?await Dl(s,r,t):void 0,tokenOut:n?await Dl(s,r,n):void 0,outAmount:Hl(e.data,e.data.length-1-2-8-8),quotedInAmount:Hl(e.data,e.data.length-1-2-8)}}if([193,32,155,51,65,214,156,129].includes(i)){let t=o[7]?.toBase58(),n=o[8]?.toBase58();return{type:"jupiter-swap-shared-accounts-route",program:a,mintIn:t,mintOut:n,tokenIn:t?await Dl(s,r,t):void 0,tokenOut:n?await Dl(s,r,n):void 0,inAmount:Hl(e.data,e.data.length-1-2-8-8),quotedOutAmount:Hl(e.data,e.data.length-1-2-8)}}throw[62,198,214,193,213,159,108,210].includes(i)&&console.warn("Jupiter swap program instruction 'claim' not implemented"),[116,206,27,191,166,19,0,73].includes(i)&&console.warn("Jupiter swap program instruction 'claim_token' not implemented"),[26,74,236,151,104,64,183,249].includes(i)&&console.warn("Jupiter swap program instruction 'close_token' not implemented"),[229,194,212,172,8,10,134,147].includes(i)&&console.warn("Jupiter swap program instruction 'create_open_orders' not implemented"),[28,226,32,148,188,136,113,171].includes(i)&&console.warn("Jupiter swap program instruction 'create_program_open_orders' not implemented"),[232,242,197,253,240,143,129,52].includes(i)&&console.warn("Jupiter swap program instruction 'create_token_ledger' not implemented"),[147,241,123,100,244,132,174,118].includes(i)&&console.warn("Jupiter swap program instruction 'create_token_account' not implemented"),[229,23,203,151,122,227,173,42].includes(i)&&console.warn("Jupiter swap program instruction 'route' not implemented"),[150,86,71,116,167,93,14,104].includes(i)&&console.warn("Jupiter swap program instruction 'route_with_token_ledger' not implemented"),[228,85,185,112,78,79,77,2].includes(i)&&console.warn("Jupiter swap program instruction 'set_token_ledger' not implemented"),[230,121,143,80,119,159,106,170].includes(i)&&console.warn("Jupiter swap program instruction 'shared_accounts_route_with_token_ledger' not implemented"),Error(`Jupiter swap program instruction type ${i} not supported`)}const Gl=({weiQuantities:e,tokenPrice:n,tokenSymbol:r})=>{let a=El(e),i=n?Al(a,n):void 0,o=Il(a,r);/*#__PURE__*/return t(Xl,{children:i||o})},Jl=({weiQuantities:r,tokenPrice:a,tokenSymbol:i})=>{let o=El(r),s=a?Al(o,a):void 0,l=Il(o,i);/*#__PURE__*/return t(Xl,{children:s?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ec,{children:"USD"}),"<$0.01"===s?
|
|
@@ -22,7 +22,7 @@ return t(Tc,{...$o().render.standalone?{defaultValue:"details"}:{},children:/*#_
|
|
|
22
22
|
/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(CC,{}),/*#__PURE__*/t(af,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(Xs,{})]})}},pw={component:()=>{let{data:r,setModalData:a}=qo(),o=r?.funding,s="solana"===o.chainType,l=i(null),{tokenPrice:c}=$c(s?"solana":o.chain.id),d=s?void 0:o,h=!(!d?.erc20Address||d?.erc20ContractInfo),p=s?o.isUSDC?"USDC":"SOL":o.erc20Address?o.erc20ContractInfo?.symbol:o.chain.nativeCurrency.symbol||"ETH",u=parseFloat(o.amount),m=!isNaN(u)&&u>0,g=c?xl(o.amount,c):void 0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(CC,{}),/*#__PURE__*/t(by,{children:"Confirm or edit amount"}),/*#__PURE__*/e(lc,{style:{marginTop:"32px"},children:[/*#__PURE__*/t(tw,{children:h?/*#__PURE__*/t(af,{size:"50px"}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(nw,{onClick:()=>l.current?.focus(),children:[/*#__PURE__*/t(aw,{ref:l,value:o.amount,onChange:e=>{let t=e.target.value;/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1&&a({...r,funding:{...o,amount:t}})}}),/*#__PURE__*/t(iw,{children:p})]}),!d?.erc20Address&&/*#__PURE__*/t(ow,{children:g&&m?`${g} USD`:""})]})}),/*#__PURE__*/t(zs,{style:{marginTop:"1rem"},disabled:!m,onClick:o.onContinueWithExternalWallet,children:"Continue"})]}),/*#__PURE__*/t(Xs,{})]})}},uw={component:()=>{let r,{connectors:a}=Pt(),{app:i,setModalData:s,data:l,navigate:c}=qo(),{wallets:h}=Vc(),{wallets:p}=Zv(),[u,m]=o("default"),g="solana"===l?.funding?.chainType,y=!!l?.funding?.crossChainBridgingEnabled;r="ethereum"===l?.funding?.chainType?l.funding.erc20Address&&!l.funding.isUSDC?"ethereum-only":y&&!l.funding.chain.testnet?"ethereum-and-solana":"ethereum-only":y&&!l.funding?.isUSDC?"ethereum-and-solana":"solana-only";let f=h.filter((e=>"privy"!==e.walletClientType)),w=f.map((e=>e.walletClientType)),v=p.filter((e=>"privy"!==e.walletClientType)),C=v.map((e=>e.walletClientType)),b=[],k={...l.funding};k.usingDefaultFundingMethod&&(k.usingDefaultFundingMethod=!1);let T=({address:e,walletChainType:t})=>{s({...l,funding:{...k,connectedWalletAddress:e,onContinueWithExternalWallet:()=>c(A({destChainType:g?"solana":"ethereum",sourceChainType:t}))}}),c(pw)};"solana-only"!==r&&b.push(...f.map(((e,n)=>/*#__PURE__*/t(mw,{onClick:()=>T({address:e.address,walletChainType:"ethereum"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),"ethereum-only"!==r&&b.push(...v.map(((e,n)=>/*#__PURE__*/t(mw,{onClick:()=>T({address:e.address,walletChainType:"solana"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),b.push(...Sg({walletList:i.appearance.walletList.filter((e=>!f.some((t=>t.walletClientType===e))&&!v.some((t=>t.walletClientType===e)))),walletChainType:r,connectors:a,connectOnly:!0,ignore:[...i.appearance.walletList,...w,...C],walletConnectEnabled:i.externalWallets.walletConnect.enabled}));let x=/*#__PURE__*/t(Ng,{text:"More wallets",onClick:()=>m("overflow")}),A=({sourceChainType:e,destChainType:t})=>"ethereum"===e&&"solana"===t?bC:"ethereum"===e&&"ethereum"===t?dw:"solana"===e&&"ethereum"===t?hw:Cf;return d((()=>{s({...l,externalConnectWallet:{onCompleteNavigateTo:({walletChainType:e})=>(s({...l,funding:{...k,onContinueWithExternalWallet:()=>{c(A({destChainType:g?"solana":"ethereum",sourceChainType:e??"ethereum"}))}}}),pw)}})}),[]),/*#__PURE__*/e(n,"overflow"===u?{children:[/*#__PURE__*/t(al,{backFn:()=>m("default")},"header"),/*#__PURE__*/e(As,{children:[/*#__PURE__*/t(Cy,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),b]}),/*#__PURE__*/t(Xs,{})]}:{children:[/*#__PURE__*/t(CC,{}),/*#__PURE__*/t(gh,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),/*#__PURE__*/e(As,{children:[b.length>4?b.slice(0,3):b,b.length>4&&x]}),/*#__PURE__*/t(Xs,{})]})}};let mw=({onClick:n,icon:r,name:a,chainType:i})=>/*#__PURE__*/e(Ss,{onClick:n,children:[/*#__PURE__*/t(ew,{style:{width:20},children:/*#__PURE__*/t("img",{src:r})}),a,/*#__PURE__*/t(Bu,{color:"gray",style:{marginLeft:"auto"},children:"Connected"}),"solana"===i&&/*#__PURE__*/t(Bu,{color:"gray",children:"Solana"})]});const gw={component:()=>{let{data:r,setModalData:a,navigate:s,navigateBack:l}=qo(),{closePrivyModal:c,createAnalyticsEvent:h,client:p}=Pt(),[u,m]=o("pending-in-flow"),g=i(0),y={...r?.funding,showAlternateFundingMethod:!0};y.usingDefaultFundingMethod&&(y.usingDefaultFundingMethod=!1);let{partnerUserId:f,popup:w}=r?.coinbaseOnrampStatus??{};return d((()=>{if("pending-in-flow"===u||"pending-after-flow"===u){let e=setInterval((async()=>{if(f)try{let{status:e}=await p.getCoinbaseOnRampStatus({partnerUserId:f});if("success"===e)return void m("success");if("failure"===e)throw Error("There was an error completing Coinbase Onramp flow.");if(g.current>=3)return a({funding:y}),void s(Pw);w?.closed&&(g.current=g.current+1,m("pending-after-flow"))}catch(e){console.error(e),m("error"),h({eventName:Uy,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),a({funding:{...y,errorMessage:"Something went wrong adding funds. Please try again or use another method."}}),s(Pw)}}),1500);return()=>clearInterval(e)}}),[f,w,u]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{title:"Fund account",backFn:()=>{a({funding:y}),l()}},"header"),/*#__PURE__*/t(yw,{status:u,onClickCta:c}),/*#__PURE__*/t(Xs,{})]})}};let yw=({status:r,onClickCta:a})=>{let{title:i,body:o,cta:l}=s((()=>(e=>{switch(e){case"success":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"pending-after-flow":return{title:"In Progress",body:"Almost done. Retrieving transaction status from Coinbase",cta:""};case"error":case"pending-in-flow":return{title:"In Progress",body:"Go back to Coinbase Onramp to finish funding your account.",cta:""}}})(r)),[r]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(vw,{children:[/*#__PURE__*/t(fw,{isSucccess:"success"===r}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t("h3",{children:i}),/*#__PURE__*/t(ww,{children:o})]})]}),l&&/*#__PURE__*/t(Bs,{onClick:a,children:l})]})},fw=({isSucccess:n})=>{if(!n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t(Os,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(Ls,{color:n}),/*#__PURE__*/t(Mi,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let r=(e=>e?ir:()=>/*#__PURE__*/t(sr,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}}))(n),a=(e=>e?"var(--privy-color-success)":"var(--privy-color-foreground-4)")(n);/*#__PURE__*/return t("div",{style:{borderColor:a,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:r&&/*#__PURE__*/t(r,{width:"4rem",height:"4rem",color:a})})},ww=/*#__PURE__*/vn.p.withConfig({displayName:"StatusBody",componentId:"sc-ebf88779-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),vw=/*#__PURE__*/vn.div.withConfig({displayName:"ConnectContainer",componentId:"sc-ebf88779-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);let Cw={[S.id]:"ethereum",[$.id]:"base",[H.id]:"optimism",[q.id]:"polygon",[B.id]:"arbitrum"};const bw=(e,t,n,r,a,i)=>new Promise((async(o,s)=>{let l=lh();if(!l)return void s(Error("Unable to initialize flow"));let c="ethereum"===t.chainType?function(e){let t=Cw[e];if(!t)throw new he(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}(t.chain.id):"solana",d=t.isUSDC?"USDC":"ethereum"===t.chainType?"ETH":"SOL",h=await e.initCoinbaseOnRamp({addresses:[{address:t.address,blockchains:[c]}],assets:[d]}),{url:p}=J({appId:e.getAppId(),input:h,amount:t.amount,blockchain:c,asset:d,experience:i});l.location=p.toString();let u={...a?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(u.usingDefaultFundingMethod=!1),n({funding:u,coinbaseOnrampStatus:{popup:l}}),r(gw),e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),setTimeout((()=>{n({funding:u,coinbaseOnrampStatus:{partnerUserId:h.partner_user_id,popup:l}})}),5e3),o()})),kw=({size:n=61,...r})=>/*#__PURE__*/t("svg",{width:n,height:n,viewBox:"0 0 61 61",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:/*#__PURE__*/e("g",{id:"moonpay_symbol_wht 2",children:[/*#__PURE__*/t("rect",{x:"1.3374",y:"1",width:"59",height:"59",rx:"11.5",fill:"#7715F5"}),/*#__PURE__*/t("path",{id:"Vector",d:"M43.8884 23.3258C45.0203 23.3258 46.1268 22.9901 47.068 22.3613C48.0091 21.7324 48.7427 20.8386 49.1759 19.7928C49.6091 18.747 49.7224 17.5962 49.5016 16.4861C49.2807 15.3759 48.7357 14.3561 47.9353 13.5557C47.1349 12.7553 46.1151 12.2102 45.0049 11.9893C43.8947 11.7685 42.7439 11.8819 41.6982 12.3151C40.6524 12.7482 39.7585 13.4818 39.1297 14.423C38.5008 15.3641 38.1651 16.4707 38.1651 17.6026C38.165 18.3542 38.3131 19.0985 38.6007 19.7929C38.8883 20.4873 39.3098 21.1182 39.8413 21.6496C40.3728 22.1811 41.0037 22.6027 41.6981 22.8903C42.3925 23.1778 43.1367 23.3259 43.8884 23.3258ZM26.3395 49.1017C23.5804 49.1017 20.8832 48.2836 18.5891 46.7507C16.295 45.2178 14.5069 43.039 13.4511 40.49C12.3952 37.9409 12.1189 35.1359 12.6572 32.4298C13.1955 29.7237 14.5241 27.238 16.4751 25.287C18.4262 23.336 20.9118 22.0074 23.6179 21.4691C26.324 20.9308 29.129 21.2071 31.6781 22.2629C34.2272 23.3189 36.406 25.1069 37.9389 27.401C39.4717 29.6952 40.2899 32.3923 40.2899 35.1514C40.2899 36.9835 39.9291 38.7975 39.2281 40.49C38.527 42.1826 37.4994 43.7205 36.204 45.0159C34.9086 46.3113 33.3707 47.3389 31.6781 48.04C29.9856 48.741 28.1715 49.1018 26.3395 49.1017Z",fill:"white"})]})});const Tw={component:()=>{let{app:r,data:a,setModalData:s,navigateBack:l}=qo(),{closePrivyModal:c}=Pt(),{externalTransactionId:h}=a?.moonpayStatus,p=function(e,t=!1){let[n,r]=o(null),{createAnalyticsEvent:a}=Pt(),{data:s,navigate:l,setModalData:c}=qo(),h=s?.funding,p=i(0);return d((()=>{let n=setInterval((async()=>{if(e)try{let[i]=await async function(e,t){return xr(`${t?$a:za}/transactions/ext/${e}`,{query:{apiKey:t?Va:ja}})}(e,t),o="waitingAuthorization"===i.status&&"credit_debit_card"===i.paymentMethod?"pending":i.status;if(["failed","completed","awaitingAuthorization"].includes(o)&&(a({eventName:Uy,payload:{status:o,provider:Ww,paymentMethod:i.paymentMethod,cardPaymentType:i.cardPaymentType,currency:i.currency?.code,baseCurrencyAmount:i.baseCurrencyAmount,quoteCurrencyAmount:i.quoteCurrencyAmount,feeAmount:i.feeAmount,extraFeeAmount:i.extraFeeAmount,networkFeeAmount:i.networkFeeAmount,isSandbox:t}}),clearInterval(n)),"failed"===o||"serviceFailure"===o)return c({funding:{...h,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),void l(Pw);r(o)}catch(e){404!==e.response?.status&&(p.current+=1),p.current>=3&&(a({eventName:Uy,payload:{status:"serviceFailure",provider:Ww}}),clearInterval(n),c({funding:{...h,errorMessage:"Something went wrong adding funds from Moonpay. Please try again or use another method to fund your wallet."}}),l(Pw))}}),3e3);return()=>clearInterval(n)}),[e,p]),n}(h||null,r.fundingMethodConfig.moonpay.useSandbox??!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{title:"Fund account",backFn:()=>{let e={...a?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),s({funding:e}),l()}}),/*#__PURE__*/t(xw,{status:p,onClickCta:c}),/*#__PURE__*/t(Xs,{})]})}};let xw=({status:r,onClickCta:a})=>{let{title:i,body:o,cta:l}=s((()=>(e=>{switch(e){case"completed":return{title:"You've funded your account!",body:"It may take a few minutes for the assets to appear.",cta:"Continue"};case"waitingAuthorization":return{title:"Processing payment",body:"This may take up to a few hours. You will receive an email when the purchase is complete.",cta:"Continue"};default:return{title:"In Progress",body:"Go back to MoonPay to finish funding your account.",cta:""}}})(r)),[r]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(_w,{children:[/*#__PURE__*/t(Aw,{status:r}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t("h3",{children:i}),/*#__PURE__*/t(Iw,{children:o})]})]}),l&&/*#__PURE__*/t(Bs,{onClick:a,children:l})]})},Aw=({status:n})=>{if(!n||"pending"===n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t(Os,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(Ls,{color:n}),/*#__PURE__*/t(kw,{size:"3rem",style:{position:"absolute",top:"1rem",left:"1rem"}})]})}let r=(e=>{switch(e){case"completed":return ir;case"waitingAuthorization":return()=>/*#__PURE__*/t(sr,{width:"3rem",height:"3rem",style:{backgroundColor:"var(--privy-color-foreground-4)",color:"var(--privy-color-background)",borderRadius:"100%",padding:"0.5rem",margin:"0.5rem"}});default:return}})(n),a=(e=>e?{completed:"var(--privy-color-success)",failed:"var(--privy-color-error)",serviceFailure:"var(--privy-color-error)",waitingAuthorization:"var(--privy-color-accent)",pending:"var(--privy-color-foreground-4)"}[e]:"var(--privy-color-foreground-4)")(n);/*#__PURE__*/return t("div",{style:{borderColor:a,display:"flex",justifyContent:"center",alignItems:"center",borderRadius:"100%",borderWidth:2,padding:"0.5rem",marginBottom:"0.5rem"},children:r&&/*#__PURE__*/t(r,{width:"4rem",height:"4rem",color:a})})},Iw=/*#__PURE__*/vn.p.withConfig({displayName:"StatusBody",componentId:"sc-7f0a56e4-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),_w=/*#__PURE__*/vn.div.withConfig({displayName:"ConnectContainer",componentId:"sc-7f0a56e4-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const Ew=async(e,t,n,r,a,i,o,s)=>{let l=lh();if(!l)throw Error("Unable to initialize flow");let c="ethereum"===t.chainType?t.moonpayConfigOverride?.currencyCode??Q(t.chain.id,r):t.isUSDC?"USDC_SOL":"SOL",{signedUrl:d,externalTransactionId:h}=await e.signMoonpayOnRampUrl({address:t.address,useSandbox:n.fundingMethodConfig.moonpay.useSandbox??!1,config:{uiConfig:{accentColor:n.appearance.palette.accent,theme:n.appearance.palette.colorScheme},...t.moonpayConfigOverride,paymentMethod:s,currencyCode:c,quoteCurrencyAmount:t.moonpayConfigOverride?.quoteCurrencyAmount??Uw(t.amount)}});e.createAnalyticsEvent({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"moonpay",value:t.amount,chainType:t.chainType,chainId:"ethereum"===t.chainType?t.chain.id:t.cluster.name}}),l.location=d;let p={...o?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(p.usingDefaultFundingMethod=!1),a({moonpayStatus:{},funding:p}),i(Tw),setTimeout((()=>{a({moonpayStatus:{externalTransactionId:h},funding:p})}),8e3)};let Sw=async e=>"undefined"!=typeof window&&"PaymentRequest"in window&&await new window.PaymentRequest([{supportedMethods:e}],{id:"0",total:{label:"Item",amount:{currency:"USD",value:"1.00"}}}).canMakePayment();const Nw=()=>Sw("https://apple.com/apple-pay"),Mw=()=>Sw("https://google.com/pay"),Pw={component:()=>{let{wallets:r}=Vc(),{wallets:a}=Zv(),{navigate:i,data:o,setModalData:l}=qo(),{client:c}=Pt(),h=$o(),p=o?.funding,u=ef(Nw),m=ef(Mw),g="solana"===p.chainType,y=g?void 0:p,f=s((()=>((e,t,n,r,a,i)=>{let o,s,l="solana"===n.chainType,c=l?void 0:n,d=n.isUSDC?"USDC":c?.erc20Address?void 0:"native-currency",h=!!l||d&&X(Number(n.chain.id),d),p=!!l||d&&ee(Number(n.chain.id),d),u=[];for(let o of(n.preferredCardProvider&&n.supportedOptions.sort((e=>e.provider===n.preferredCardProvider?-1:1)),n.supportedOptions))"card"===o.method&&"coinbase"===o.provider&&p&&u.push((()=>bw(t,n,r,a,i,"buy"))),"card"===o.method&&"moonpay"===o.provider&&h&&d&&u.push((()=>Ew(t,n,e,d,r,a,i,"credit_debit_card")));for(let e of n.supportedOptions)"exchange"===e.method&&"coinbase"===e.provider&&p&&(o=()=>bw(t,n,r,a,i,"buy"));for(let e of i?.funding?.supportedOptions??[])"wallets"===e.method&&(s=()=>a(uw));return{onFundWithCard:u,onFundWithExchange:o,onFundWithWallet:s}})(h,c,p,l,i,o)),[h,c,p,o,l,i]);d((()=>{if(p?.defaultFundingMethod&&p.usingDefaultFundingMethod)switch(l({funding:{...p,usingDefaultFundingMethod:!1}}),p?.defaultFundingMethod){case"card":f.onFundWithCard[0]&&f.onFundWithCard[0]();break;case"exchange":f.onFundWithExchange&&f.onFundWithExchange();break;case"wallet":f.onFundWithWallet&&f.onFundWithWallet();break;case"manual":i(Yv)}}),[]),d((()=>{y?.erc20Address&&!y.erc20ContractInfo&&nf({address:y.erc20Address,chain:y.chain,rpcConfig:h.rpcConfig,privyAppId:h.id}).then((e=>{l({...o,funding:{...y,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}})})).catch(console.error)}),[y?.erc20Address,y?.chain]);let w=g?a.find((({address:e})=>e===p.address)):r.find((({address:e})=>v(e)===v(p.address))),C=To(w?.walletClientType||"unknown"),b=C?.name||"wallet",k=w&&"privy"!==w.walletClientType?b:h.name,T=!(!y?.erc20Address||y?.erc20ContractInfo);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(CC,{}),/*#__PURE__*/e("h3",{children:["Add funds to your"," ",k?.toLowerCase().endsWith("wallet")?k:k+" wallet"]}),/*#__PURE__*/e(Xf,{children:[p.errorMessage&&/*#__PURE__*/t(Gy,{theme:h.appearance.palette.colorScheme,children:p.errorMessage}),f.onFundWithCard?.[0]&&/*#__PURE__*/e(Ss,{disabled:T,onClick:f.onFundWithCard[0],children:[/*#__PURE__*/t(ew,{children:/*#__PURE__*/t(br,{style:{width:24}})}),"Pay with card",u?/*#__PURE__*/t(Qy,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):m?/*#__PURE__*/t(Xy,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):null]}),f.onFundWithExchange&&/*#__PURE__*/e(Ss,{disabled:T,onClick:f.onFundWithExchange,children:[/*#__PURE__*/t(ew,{children:/*#__PURE__*/t(sr,{style:{width:24}})}),"Transfer from an exchange"]}),f.onFundWithWallet&&/*#__PURE__*/e(Ss,{disabled:T,onClick:f.onFundWithWallet,children:[/*#__PURE__*/t(ew,{children:/*#__PURE__*/t(tf,{style:{width:24}})}),"Transfer from wallet"]}),/*#__PURE__*/e(Ss,{disabled:T,onClick:()=>i(Yv),children:[/*#__PURE__*/t(ew,{children:/*#__PURE__*/t(kr,{style:{width:24}})}),"Receive funds"]}),p?.showAlternateFundingMethod&&f.onFundWithCard?.[1]&&/*#__PURE__*/t(Iy,{theme:h.appearance.palette.colorScheme,children:/*#__PURE__*/e(sw,{children:["Having trouble or facing location restrictions?"," ",/*#__PURE__*/t(lw,{onClick:f.onFundWithCard[1],children:"Try a different provider."})]})})]}),/*#__PURE__*/t(Xs,{})]})}},Ww="moonpay";function Uw(e){return parseFloat(e)}function Ow(e){return!!e&&void 0!==e.config&&void 0!==e.provider}function Lw(e){return!!e&&(void 0!==e.chain||void 0!==e.amount)}const Rw={[S.id]:"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",[te.id]:"0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",[H.id]:"0x0b2c639c533813f4aa9d7837caf62653d097ff85",[ne.id]:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",[q.id]:"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",[re.id]:"0x41e94eb019c0762f9bfcf9fb1e58725bfb0e7582",[$.id]:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",[ae.id]:"0x036CbD53842c5426634e7929541eC2318f3dCF7e",[z.id]:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",[ie.id]:"0x5425890298aed601595a70ab815c96711a31bc65",[B.id]:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",[oe.id]:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"},Fw=({address:e,appConfig:t,fundWalletConfig:n,methodScreen:r,chainIdOverride:a,comingFromSendTransactionScreen:i=!1})=>{let o,s;if(!t.fundingConfig)throw Error("Wallet funding is not enabled");let l=Zy(t.fundingConfig.options);if(l.length<1)throw Error("Wallet funding is not enabled");o=a||(Lw(n)&&n.chain?n.chain.id:rh(t.fundingConfig.defaultRecommendedCurrency.chain));let c=t.chains.find((e=>e.id===o));if(!c)throw new he(`Funding chain ${o} is not in PrivyProvider chains list`);let d=Lw(n)&&n.amount?n.amount:t.fundingConfig.defaultRecommendedAmount,h=!1;function p(){if(!o)return;let e=Rw[o];l.find((e=>"wallets"===e.method))&&!e&&console.warn("Attempting to fund with USDC on chain where USDC address is not known. Funding via external wallet will be disabled."),s=e,h=!0}Lw(n)&&"asset"in n?"USDC"===n.asset?p():"string"!=typeof n.asset&&"erc20"in n.asset&&(h=((e,t)=>e===Rw[t.id])(s=n.asset.erc20,c)):"USDC"===t.fundingConfig.defaultRecommendedCurrency.asset&&p();let u=n?.defaultFundingMethod;return{chainType:"ethereum",address:e,amount:d,chain:c,erc20Address:s,erc20ContractInfo:h?{symbol:"USDC",decimals:6}:void 0,isUSDC:h,methodScreen:r,supportedOptions:l,comingFromSendTransactionScreen:i,defaultFundingMethod:u,usingDefaultFundingMethod:!!u,preferredCardProvider:n?.card?.preferredProvider,crossChainBridgingEnabled:t.fundingConfig.crossChainBridgingEnabled??!1,cluster:{name:"mainnet-beta",rpcUrl:t.solanaClusters["mainnet-beta"].rpcUrl},...Ow(n)?{moonpayConfigOverride:n.config}:{},uiConfig:n&&"uiConfig"in n?n.uiConfig:void 0}};function Dw({address:e,fundWalletConfig:t,appConfig:n,comingFromSendTransactionScreen:r,methodScreen:a}){if(!n.fundingConfig)throw Error("Wallet funding is not enabled");let i=Zy(n.fundingConfig.options);if(i.length<1)throw Error("Wallet funding is not enabled");if("USDC"===t?.asset&&"testnet"===t?.cluster?.name)throw Error("USDC funding is not supported on the Solana testnet");let o=t?.amount??n.fundingConfig.defaultRecommendedAmount,s=t?.defaultFundingMethod;return{chainType:"solana",address:e,supportedOptions:i,amount:o,isUSDC:"USDC"===t?.asset,methodScreen:a,comingFromSendTransactionScreen:r,cluster:{name:t?.cluster?.name??"mainnet-beta",rpcUrl:n.solanaClusters[t?.cluster?.name??"mainnet-beta"].rpcUrl},crossChainBridgingEnabled:n.fundingConfig.crossChainBridgingEnabled??!1,defaultFundingMethod:s,preferredCardProvider:t?.card?.preferredProvider,usingDefaultFundingMethod:!!s,uiConfig:t?.uiConfig}}const Bw=({children:n,theme:r})=>/*#__PURE__*/e(zw,{$theme:r,children:[/*#__PURE__*/t(Wn,{width:"1.25rem",color:"dark"===r?"#FDE68A":"var(--privy-color-warn)"}),n]});let zw=/*#__PURE__*/vn.div.withConfig({displayName:"Container",componentId:"sc-97f152b3-0"})(["display:flex;gap:0.5rem;background-color:",";"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);}"],(e=>"dark"===e.$theme?"var(--privy-color-background-2)":"var(--privy-color-warn-light)"),(e=>"dark"===e.$theme?"color: #FDE68A;":""));function $w(n){let[r,a]=o(n.dimensions.width),[s,l]=o(void 0),c=i(null);d((()=>{if(c.current&&void 0===r){let{width:e}=c.current.getBoundingClientRect();a(e)}let e=getComputedStyle(document.documentElement);l({background:e.getPropertyValue("--privy-color-background"),background2:e.getPropertyValue("--privy-color-background-2"),foreground3:e.getPropertyValue("--privy-color-foreground-3"),foregroundAccent:e.getPropertyValue("--privy-color-foreground-accent"),accent:e.getPropertyValue("--privy-color-accent"),accentDark:e.getPropertyValue("--privy-color-accent-dark"),success:e.getPropertyValue("--privy-color-success"),colorScheme:e.getPropertyValue("color-scheme")})}),[]);let h="ethereum"===n.chainType&&!n.imported&&!n.isUnifiedWallet;/*#__PURE__*/return t("div",{ref:c,children:r&&
|
|
23
23
|
/*#__PURE__*/e(Hw,{children:[/*#__PURE__*/t("iframe",{style:{position:"absolute",zIndex:1},width:r,height:n.dimensions.height,allow:"clipboard-write self *",src:ea(n.origin,`/apps/${n.appId}/embedded-wallets/export`,n.isUnifiedWallet?{v:"1-unified",wallet_id:n.walletId,client_id:n.appClientId,width:`${r}px`,caid:n.clientAnalyticsId,phrase_export:h,...s}:{v:"1",entropy_id:n.entropyId,entropy_id_verifier:n.entropyIdVerifier,hd_wallet_index:n.hdWalletIndex,chain_type:n.chainType,client_id:n.appClientId,width:`${r}px`,caid:n.clientAnalyticsId,phrase_export:h,...s},{token:n.accessToken})}),/*#__PURE__*/t(qw,{children:"Loading..."}),h&&/*#__PURE__*/t(qw,{children:"Loading..."})]})})}const jw={component:()=>{let[r,a]=o(null),{authenticated:i,user:s,getAccessToken:l}=nn(),{closePrivyModal:c,createAnalyticsEvent:h,clientAnalyticsId:p}=Pt(),u=$o(),{data:m,onUserCloseViaDialogOrKeybindRef:g}=qo(),{onFailure:y,onSuccess:f,origin:w,appId:v,appClientId:C,entropyId:b,entropyIdVerifier:k,walletId:T,hdWalletIndex:x,chainType:A,address:I,isUnifiedWallet:_,imported:E}=m.keyExport,S=e=>{c({shouldCallAuthOnSuccess:!1}),y("string"==typeof e?Error(e):e)},N=()=>{c({shouldCallAuthOnSuccess:!1}),f(),h({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:I}})};return d((()=>{if(!i)return S("User must be authenticated before exporting their wallet");l().then(a,S)}),[i,s]),g.current=N,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{onClose:N}),/*#__PURE__*/e(Vw,{children:[/*#__PURE__*/t(by,{children:"Export wallet"}),/*#__PURE__*/e(Cy,{children:["Copy either your private key or seed phrase to export 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(Bw,{theme:u.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),/*#__PURE__*/t(Py,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:I,showIcon:!0}),/*#__PURE__*/t("div",{style:{width:"100%"},children:r&&/*#__PURE__*/t($w,{origin:w,appId:v,appClientId:C,accessToken:r,clientAnalyticsId:p,entropyId:b,entropyIdVerifier:k,walletId:T,hdWalletIndex:x,isUnifiedWallet:_,imported:E,chainType:A,dimensions:{height:"44px"}})})]}),/*#__PURE__*/t(Xs,{})]})}};let Vw=/*#__PURE__*/vn.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-5f84798a-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),Hw=/*#__PURE__*/vn.div.withConfig({displayName:"ButtonContainer",componentId:"sc-5f84798a-1"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),qw=/*#__PURE__*/vn.div.withConfig({displayName:"LoadingButton",componentId:"sc-5f84798a-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 Kw={component:()=>{let{authenticated:r,user:a,getAccessToken:i}=nn(),{closePrivyModal:l,createAnalyticsEvent:c,walletProxy:h}=Pt(),{navigate:p,data:u,setModalData:m,onUserCloseViaDialogOrKeybindRef:g}=qo(),y=s((()=>Date.now()),[]),[f,w]=o(!1),{onCompleteNavigateTo:v,onFailure:C,shouldForceMFA:b,entropyId:k,entropyIdVerifier:T,recoveryMethod:x,connectingWalletAddress:A,isUnifiedWallet:I=!1}=u?.connectWallet,_=e=>{f||(w(!0),C("string"==typeof e?Error(e):e))};d((()=>{let e;return r?h?((async()=>{let t=await i();if(!t)return _("User must be authenticated and have a Privy wallet before it can be connected");try{I||await h.connect({accessToken:t,entropyId:k,entropyIdVerifier:T}),b&&await h.verifyMfa({accessToken:t});let n=(Date.now()-y)/1e3;v===jw&&n<1?e=setTimeout((()=>{p(v,!1)}),1e3*(1-n)):p(v,!1)}catch(e){if(Jc(e)&&"privy"===x){let e=await i();if(!e)return _("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(h?.recover({accessToken:e,entropyId:k,entropyIdVerifier:T}));t?.entropyId||_(Error("Unable to recover wallet")),v?p(v):l({shouldCallAuthOnSuccess:!1}),c({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:A}}),p(v)}catch(e){_("An error has occurred, please try again.")}}else Jc(e)&&"privy"!==x&&"privy-v2"!==x?(m({...u,recoverWallet:{entropyId:k,entropyIdVerifier:T,onCompleteNavigateTo:v,onFailure:C},recoveryOAuthStatus:{provider:x,action:"recover",isInAccountCreateFlow:!1,shouldCreateEth:!1,shouldCreateSol:!1}}),p(Ay(x))):_(e)}})(),()=>clearTimeout(e)):void 0:_("User must be authenticated and have a Privy wallet before it can be connected")}),[r,a,h]);let E=()=>{_("User exited before wallet could be connected"),l({shouldCallAuthOnSuccess:!1})};return g.current=E,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{onClose:E}),f?/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(sc,{children:[/*#__PURE__*/t(ar,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(gh,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),/*#__PURE__*/t(Bs,{onClick:()=>l({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):/*#__PURE__*/t(Iu,{}),/*#__PURE__*/t(Zw,{})]})}};let Zw=/*#__PURE__*/vn.div.withConfig({displayName:"BottomSpacing",componentId:"sc-1ec92f42-0"})(["height:44px;"]);const Yw=/*#__PURE__*/vn(pf).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 Gw=({iconUrl:n,value:r,symbol:a,usdValue:i,nftName:o,nftCount:s,$isLoading:l})=>l?/*#__PURE__*/t(Jw,{$isLoading:l}):/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(Jw,{$isLoading:l,children:[n&&/*#__PURE__*/t(Xw,{src:n,alt:"Token icon"}),s&&s>1?s+"x":void 0," ",o,r," ",a]}),i&&/*#__PURE__*/e(Qw,{$isLoading:l,children:["$",i]})]});let Jw=/*#__PURE__*/vn.span.withConfig({displayName:"Value",componentId:"sc-f3c0f2da-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;",""],Du);const Qw=/*#__PURE__*/vn.span.withConfig({displayName:"Subvalue",componentId:"sc-f3c0f2da-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;",""],Du);let Xw=/*#__PURE__*/vn.img.withConfig({displayName:"TokenIcon",componentId:"sc-f3c0f2da-2"})(["height:14px;width:14px;margin-right:4px;object-fit:contain;"]);const ev=r=>{let{chain:a,transactionDetails:i,isTokenContractInfoLoading:o,symbol:s}=r,{action:l,functionName:c}=i;/*#__PURE__*/return t(My,{children:/*#__PURE__*/e(df,{children:["transaction"!==l&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Action"}),/*#__PURE__*/t(mf,{children:c})]}),"mint"===c&&"args"in i&&i.args.filter((e=>e)).map(((n,r)=>/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:`Param ${r}`}),/*#__PURE__*/t(mf,{children:"string"==typeof n&&qt(n)?/*#__PURE__*/t(Zp,{address:n,url:a?.blockExplorers?.default?.url,showCopyIcon:!1}):n?.toString()})]},r))),"setApprovalForAll"===c&&i.operator&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Operator"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:i.operator,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===c&&void 0!==i.approved&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Set approval to"}),/*#__PURE__*/t(mf,{children:i.approved?"true":"false"})]}),"transfer"===c||"transferFrom"===c||"safeTransferFrom"===c||"approve"===c?/*#__PURE__*/e(n,{children:["formattedAmount"in i&&i.formattedAmount&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Amount"}),/*#__PURE__*/e(mf,{$isLoading:o,children:[i.formattedAmount," ",s]})]}),"tokenId"in i&&i.tokenId&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token ID"}),/*#__PURE__*/t(mf,{children:i.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===c&&/*#__PURE__*/e(n,{children:["amounts"in i&&i.amounts&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Amounts"}),/*#__PURE__*/t(mf,{children:i.amounts.join(", ")})]}),"tokenIds"in i&&i.tokenIds&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token IDs"}),/*#__PURE__*/t(mf,{children:i.tokenIds.join(", ")})]})]}),"approve"===c&&i.spender&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Spender"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:i.spender,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferFrom&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Transferring from"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:i.transferFrom,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferTo&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Transferring to"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:i.transferTo,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})};let tv={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 nv=/*#__PURE__*/vn.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=>tv[e.variant])),rv=({variant:n,setPreventMaliciousTransaction:r,preventMaliciousTransaction:a})=>"warn"===n?/*#__PURE__*/t(nv,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t(av,{$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(nv,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-col",children:[/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t(av,{$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(Xh,{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 av=/*#__PURE__*/vn(Wn).withConfig({displayName:"StyledExclamationTriangleIcon",componentId:"sc-91effb27-0"})(["width:20px;height:20px;stroke-width:2px;flex-shrink:0;display:inline-block;margin-right:8px;",";"],(({$variant:e})=>"error"===e?"color: var(--privy-color-error)":"color: var(--privy-color-warn)"));const iv=({transactionIndex:e,maxIndex:t})=>"number"!=typeof e||0===t?"":` (${e+1} / ${t+1})`,ov=({img:r,submitError:a,prepareError:i,onClose:s,action:l,title:c,subtitle:d,txValue:h,to:p,tokenAddress:u,network:m,missingFunds:g,fee:y,from:f,cta:w,disabled:v,chain:C,isSubmitting:b,isPreparing:k,isTokenPriceLoading:T,isTokenContractInfoLoading:x,isSponsored:A,symbol:I,balance:_,onClick:E,transactionDetails:S,transactionIndex:N,maxIndex:M,onBack:P,chainName:W,validation:U,hasScanDetails:O,setIsScanDetailsOpen:L,preventMaliciousTransaction:R,setPreventMaliciousTransaction:F,tokensSent:D,tokensReceived:B,isScanning:z,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&&x||k||T||z;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{onClose:s,backFn:P}),r&&/*#__PURE__*/t(hv,{children:r}),/*#__PURE__*/e(by,{style:{marginTop:r?"1.5rem":0},children:[c,/*#__PURE__*/t(iv,{maxIndex:M,transactionIndex:N})]}),/*#__PURE__*/t(Cy,{children:d}),/*#__PURE__*/e(df,{style:{marginTop:"2rem"},children:[(!!D[0]||K)&&/*#__PURE__*/e(hf,{children:[B.length>0?/*#__PURE__*/t(pf,{children:"Send"}):/*#__PURE__*/t(pf,{children:"Amount"}),/*#__PURE__*/t("div",{className:"flex flex-col",children:D.map(((e,n)=>/*#__PURE__*/t(Gw,{iconUrl:e.iconUrl,value:e.value,usdValue:e.usdValue,symbol:e.symbol,nftName:e.nftName,nftCount:e.nftCount},n)))})]}),B.length>0&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Receive"}),/*#__PURE__*/t("div",{className:"flex flex-col",children:B.map(((e,n)=>/*#__PURE__*/t(Gw,{iconUrl:e.iconUrl,value:e.value,usdValue:e.usdValue,symbol:e.symbol,nftName:e.nftName,nftCount:e.nftCount},n)))})]}),S&&"spender"in S&&S?.spender?/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Spender"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:S.spender,url:C?.blockExplorers?.default?.url})})]}):null,p&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"To"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:p,url:C?.blockExplorers?.default?.url})})]}),u&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token address"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:u,url:C?.blockExplorers?.default?.url})})]}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Network"}),/*#__PURE__*/t(mf,{children:m})]}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Estimated fee"}),/*#__PURE__*/t(mf,{$isLoading:k||T||void 0===A,children:A?"Sponsored":y})]}),H&&!O&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(hf,{className:"cursor-pointer",onClick:()=>V(!j),children:/*#__PURE__*/e(uf,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/t(Ar,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:j?"rotate(180deg)":void 0}})]})}),j&&S&&/*#__PURE__*/t(ev,{action:l,chain:C,transactionDetails:S,isTokenContractInfoLoading:x,symbol:I})]}),O&&/*#__PURE__*/t(hf,{children:/*#__PURE__*/e(Yw,{onClick:()=>L(!0),children:[/*#__PURE__*/t("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/t(Ir,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/t(Ts,{}),a?/*#__PURE__*/t(Qg,{style:{marginTop:"2rem"},children:a.message}):i&&0===N?
|
|
24
24
|
/*#__PURE__*/t(Qg,{style:{marginTop:"2rem"},children:i.shortMessage??dv}):null,/*#__PURE__*/t(rv,{variant:U,preventMaliciousTransaction:R,setPreventMaliciousTransaction:F}),/*#__PURE__*/t(lv,{$useSmallMargins:!(!i&&!a&&"warn"!==U&&"error"!==U),title:Number(h)>0?void 0:!1!==A?"Your wallet":void 0,address:f,balance:_,isLoading:k||T,errMsg:k||i||a||!g?void 0:`Add funds on ${C?.name??W} to complete transaction.`}),/*#__PURE__*/t(Bs,{style:{marginTop:"1rem"},loading:b,disabled:v||k,onClick:E,children:w}),$&&/*#__PURE__*/t(Zs,{style:{marginTop:"1rem"},onClick:s,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(Xs,{})]})},sv=({img:r,title:a,subtitle:i,cta:s,instructions:l,network:c,blockExplorerUrl:d,isMissingFunds:h,submitError:p,parseError:u,total:m,swap:g,transactingWalletAddress:y,fee:f,balance:w,disabled:v,isSubmitting:C,isPreparing:b,isTokenPriceLoading:k,onClick:T,onClose:x,onBack:A})=>{let I=b||k,[_,E]=o(!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{onClose:x,backFn:A}),r&&/*#__PURE__*/t(hv,{children:r}),/*#__PURE__*/t(by,{style:{marginTop:r?"1.5rem":0},children:a}),/*#__PURE__*/t(Cy,{children:i}),/*#__PURE__*/e(df,{style:{marginTop:"2rem",marginBottom:".5rem"},children:[(m||I)&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Amount"}),/*#__PURE__*/t(mf,{$isLoading:I,children:m})]}),g&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Swap"}),/*#__PURE__*/t(mf,{children:g})]}),c&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Network"}),/*#__PURE__*/t(mf,{children:c})]}),(f||I)&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Estimated fee"}),/*#__PURE__*/t(mf,{$isLoading:I,children:f})]})]}),/*#__PURE__*/t(hf,{children:/*#__PURE__*/e(Yw,{onClick:()=>E((e=>!e)),children:[/*#__PURE__*/t("span",{children:"Advanced"}),/*#__PURE__*/t(Ar,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:_?"rotate(180deg)":void 0}})]})}),_&&/*#__PURE__*/t(n,{children:l.map(((n,r)=>"sol-transfer"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/e(Sy,{children:["Transfer ",n.withSeed?"with seed":""]})}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Amount"}),/*#__PURE__*/e(mf,{children:[se({amount:n.value,decimals:n.token.decimals})," ",n.token.symbol]})]}),!!n.toAccount&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Destination"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.toAccount,url:d})})]})]},r):"spl-transfer"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/e(Sy,{children:["Transfer ",n.token.symbol]})}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Amount"}),/*#__PURE__*/t(mf,{children:n.value.toString()})]}),!!n.fromAta&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Source"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.fromAta,url:d})})]}),!!n.toAta&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Destination"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.toAta,url:d})})]}),!!n.token.address&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.token.address,url:d})})]})]},r):"ata-creation"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/t(Sy,{children:"Create token account"})}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Program ID"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.program,url:d})})]}),!!n.owner&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Owner"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.owner,url:d})})]})]},r):"create-account"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/e(Sy,{children:["Create account ",n.withSeed?"with seed":""]})}),!!n.account&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Account"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.account,url:d})})]}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Amount"}),/*#__PURE__*/e(mf,{children:[se({amount:n.value,decimals:9})," SOL"]})]})]},r):"spl-init-account"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/t(Sy,{children:"Initialize token account"})}),!!n.account&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Account"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.account,url:d})})]}),!!n.mint&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Mint"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.mint,url:d})})]}),!!n.owner&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Owner"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.owner,url:d})})]})]},r):"spl-close-account"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/t(Sy,{children:"Close token account"})}),!!n.source&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Source"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.source,url:d})})]}),!!n.destination&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Destination"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.destination,url:d})})]}),!!n.owner&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Owner"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.owner,url:d})})]})]},r):"spl-sync-native"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/t(Sy,{children:"Sync native"})}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Program ID"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.program,url:d})})]})]},r):"raydium-swap-base-input"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/e(Sy,{children:["Raydium swap"," ",n.tokenIn&&n.tokenOut?`${n.tokenIn.symbol} → ${n.tokenOut.symbol}`:""]})}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Amount in"}),/*#__PURE__*/t(mf,{children:n.amountIn.toString()})]}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Minimum amount out"}),/*#__PURE__*/t(mf,{children:n.minimumAmountOut.toString()})]}),n.mintIn&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token in"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.mintIn,url:d})})]}),n.mintOut&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token out"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.mintOut,url:d})})]})]},r):"raydium-swap-base-output"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/e(Sy,{children:["Raydium swap"," ",n.tokenIn&&n.tokenOut?`${n.tokenIn.symbol} → ${n.tokenOut.symbol}`:""]})}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Max amount in"}),/*#__PURE__*/t(mf,{children:n.maxAmountIn.toString()})]}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Amount out"}),/*#__PURE__*/t(mf,{children:n.amountOut.toString()})]}),n.mintIn&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token in"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.mintIn,url:d})})]}),n.mintOut&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token out"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.mintOut,url:d})})]})]},r):"jupiter-swap-shared-accounts-route"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/e(Sy,{children:["Jupiter swap"," ",n.tokenIn&&n.tokenOut?`${n.tokenIn.symbol} → ${n.tokenOut.symbol}`:""]})}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"In amount"}),/*#__PURE__*/t(mf,{children:n.inAmount.toString()})]}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Quoted out amount"}),/*#__PURE__*/t(mf,{children:n.quotedOutAmount.toString()})]}),n.mintIn&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token in"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.mintIn,url:d})})]}),n.mintOut&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token out"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.mintOut,url:d})})]})]},r):"jupiter-swap-exact-out-route"===n.type?/*#__PURE__*/e(cv,{children:[/*#__PURE__*/t(hf,{children:/*#__PURE__*/e(Sy,{children:["Jupiter swap"," ",n.tokenIn&&n.tokenOut?`${n.tokenIn.symbol} → ${n.tokenOut.symbol}`:""]})}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Quoted in amount"}),/*#__PURE__*/t(mf,{children:n.quotedInAmount.toString()})]}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Amount out"}),/*#__PURE__*/t(mf,{children:n.outAmount.toString()})]}),n.mintIn&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token in"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.mintIn,url:d})})]}),n.mintOut&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Token out"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.mintOut,url:d})})]})]},r):/*#__PURE__*/e(cv,{children:[/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Program ID"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Zp,{address:n.program,url:d})})]}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Data"}),/*#__PURE__*/t(mf,{children:n.discriminator})]})]},r)))}),/*#__PURE__*/t(Ts,{}),p?/*#__PURE__*/t(Qg,{style:{marginTop:"2rem"},children:p.message}):u?/*#__PURE__*/t(Qg,{style:{marginTop:"2rem"},children:dv}):null,/*#__PURE__*/t(lv,{$useSmallMargins:!(!u&&!p),title:"Your wallet",address:y,balance:w,isLoading:b||k,errMsg:b||u||p||!h?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/t(Bs,{style:{marginTop:"1rem"},loading:C,disabled:v||b,onClick:T,children:s}),/*#__PURE__*/t(Xs,{})]})};let lv=/*#__PURE__*/vn(Py).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-c5b70898-0"})(["",""],(e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;")),cv=/*#__PURE__*/vn(df).withConfig({displayName:"InstructionRows",componentId:"sc-c5b70898-1"})(["margin-top:0.5rem;border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-sm);padding:0.5rem;"]),dv="There was an error preparing your transaction. Your transaction request will likely fail.",hv=/*#__PURE__*/vn.div.withConfig({displayName:"ImageContainer",componentId:"sc-c5b70898-2"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),pv=()=>/*#__PURE__*/e(fv,{children:[/*#__PURE__*/t(vv,{}),/*#__PURE__*/t(wv,{})]});const uv=({transactionError:r,chainId:a,onClose:i,onRetry:s,network:l,connection:c,transactionHash:d})=>{let{chains:h}=Pt(),[p,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||"",Po(r?.rpcEndpoint||"")))({chains:h,chainId:a,network:l,connection:c,transactionHash:d});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{onClose:i}),/*#__PURE__*/e(mv,{children:[/*#__PURE__*/t(pv,{}),/*#__PURE__*/t(gv,{children:m}),/*#__PURE__*/t(yv,{children:"Please try again."}),/*#__PURE__*/e(kv,{children:[/*#__PURE__*/t(bv,{children:"Error message"}),/*#__PURE__*/t(xv,{$clickable:!1,children:g})]}),d&&/*#__PURE__*/e(kv,{children:[/*#__PURE__*/t(bv,{children:"Transaction hash"}),/*#__PURE__*/e(Tv,{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(xv,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(d),u(!0)},children:[d,/*#__PURE__*/t(_v,{clicked:p})]})]}),/*#__PURE__*/t(Cv,{onClick:()=>s({resetNonce:!!d}),children:"Retry transaction"})]}),/*#__PURE__*/t(el,{})]})};let mv=/*#__PURE__*/vn.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-92716bea-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),gv=/*#__PURE__*/vn.span.withConfig({displayName:"ErrorCode",componentId:"sc-92716bea-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;"]),yv=/*#__PURE__*/vn.span.withConfig({displayName:"Subtitle",componentId:"sc-92716bea-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;"]),fv=/*#__PURE__*/vn.div.withConfig({displayName:"CircleContainer",componentId:"sc-92716bea-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),wv=/*#__PURE__*/vn(tr).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-92716bea-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),vv=/*#__PURE__*/vn.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-92716bea-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),Cv=/*#__PURE__*/vn(Bs).withConfig({displayName:"RetryButton",componentId:"sc-92716bea-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),bv=/*#__PURE__*/vn.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-92716bea-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),kv=/*#__PURE__*/vn.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-92716bea-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),Tv=/*#__PURE__*/vn.text.withConfig({displayName:"HelperText",componentId:"sc-92716bea-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),xv=/*#__PURE__*/vn.span.withConfig({displayName:"TextBox",componentId:"sc-92716bea-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 }")),Av=/*#__PURE__*/vn(_r).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-92716bea-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),Iv=/*#__PURE__*/vn(yr).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-92716bea-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),_v=({clicked:e})=>/*#__PURE__*/t(e?Iv:Av,{});const Ev=({instruction:n,fees:r,transactionInfo:a,solPrice:i,rpcEndpoint:o})=>/*#__PURE__*/e(df,{children:[a?.action&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Action"}),/*#__PURE__*/t(mf,{children:a.action})]}),null!=n?.total&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Total"}),/*#__PURE__*/t(mf,{children:n.total})]}),!n?.total&&null!=n?.amount&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Total"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Ql,{quantities:[n.amount,r],tokenPrice:i})})]}),/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"Fees"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Ql,{quantities:[r],tokenPrice:i})})]}),n?.to&&/*#__PURE__*/e(hf,{children:[/*#__PURE__*/t(pf,{children:"To"}),/*#__PURE__*/t(mf,{children:/*#__PURE__*/t(Lc,{walletAddress:n.to,rpcEndpoint:o,network:"solana"})})]})]}),Sv=({fees:r,onClose:a,receiptHeader:i,receiptDescription:o,transactionInfo:s,solPrice:l,rpcEndpoint:c,signOnly:d,instruction:h})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{onClose:a}),/*#__PURE__*/t(kd,{style:{marginBottom:"16px"},children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(jp,{color:"var(--privy-color-success-light)"}),/*#__PURE__*/t(vr,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),/*#__PURE__*/t(gh,{title:i??`Transaction ${d?"signed":"complete"}!`,description:o??"You're all set."}),/*#__PURE__*/t(Ev,{solPrice:l,instruction:h,fees:r,transactionInfo:s,rpcEndpoint:c}),/*#__PURE__*/t(Ts,{}),/*#__PURE__*/t(Nv,{loading:!1,onClick:a,children:"Close"}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]});let Nv=/*#__PURE__*/vn(Bs).withConfig({displayName:"SubmitButton",componentId:"sc-df6d4eec-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const Mv={component:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=qo(),{client:i,closePrivyModal:l,walletProxy:c,showFiatPrices:h}=Pt(),p=$o(),{user:u}=nn(),[m,g]=o(e?.sendSolanaTransaction?.transactionRequest),[y,f]=o(),[w,v]=o(),[C,b]=o({value:0n,isLoading:!1}),[k,T]=o(!1),[x,A]=o(),[I,_]=o(),E=e?.sendSolanaTransaction?.connection,S=e?.sendSolanaTransaction?.transactingWallet,N=!!e?.sendSolanaTransaction?.signOnly,M=S?.imported?ln(u):Xt(u),P=Po(E?.rpcEndpoint||""),{solPrice:W,isSolPriceLoading:U}=zc({enabled:h}),O=s((()=>{if(!y)return;let e=y.spender,t=Ol(y.fee),n=Ol(C.value,3,!0),r=y.instructions.filter((e=>["sol-transfer","spl-transfer","raydium-swap-base-input","raydium-swap-base-output","jupiter-swap-shared-accounts-route","jupiter-swap-exact-out-route"].includes(e.type))),a=r.at(0);if(!a||r.length>1)return{fee:t,spender:e,balance:n};if("sol-transfer"===a.type)return{fee:t,spender:e,balance:n,total:Ol(a.value)};if("spl-transfer"===a.type)return{fee:t,spender:e,balance:n,total:`${se({amount:a.value,decimals:a.token.decimals})} ${a.token.symbol}`};if("raydium-swap-base-input"===a.type&&a.tokenIn&&a.tokenOut){return{fee:t,spender:e,balance:n,swap:`${`${se({amount:a.amountIn,decimals:a.tokenIn.decimals})} ${a.tokenIn.symbol}`} → ${`${se({amount:a.minimumAmountOut,decimals:a.tokenOut.decimals})} ${a.tokenOut.symbol}`}`}}if("raydium-swap-base-output"===a.type&&a.tokenIn&&a.tokenOut){return{fee:t,spender:e,balance:n,swap:`${`${se({amount:a.maxAmountIn,decimals:a.tokenIn.decimals})} ${a.tokenIn.symbol}`} → ${`${se({amount:a.amountOut,decimals:a.tokenOut.decimals})} ${a.tokenOut.symbol}`}`}}if("jupiter-swap-shared-accounts-route"===a.type&&a.tokenIn&&a.tokenOut){return{fee:t,spender:e,balance:n,swap:`${`${se({amount:a.inAmount,decimals:a.tokenIn.decimals})} ${a.tokenIn.symbol}`} → ${`${se({amount:a.quotedOutAmount,decimals:a.tokenOut.decimals})} ${a.tokenOut.symbol}`}`}}if("jupiter-swap-exact-out-route"===a.type&&a.tokenIn&&a.tokenOut){return{fee:t,spender:e,balance:n,swap:`${`${se({amount:a.quotedInAmount,decimals:a.tokenIn.decimals})} ${a.tokenIn.symbol}`} → ${`${se({amount:a.outAmount,decimals:a.tokenOut.decimals})} ${a.tokenOut.symbol}`}`}}return{fee:t,spender:e,balance:n}}),[y,S?.address,C]),L=s((()=>{let e;if(!y||!h||!W||U)return;function t(...e){return Ll(e.reduce(((e,t)=>e+t),0n),W??0)}S?.address===y.spender&&(e=t(y.fee));let n=t(C.value),r=y.instructions.filter((e=>"sol-transfer"===e.type||"spl-transfer"===e.type)).at(0);return!r||y.instructions.length>1?{fee:e,balance:n}:"sol-transfer"===r.type?{fee:e,balance:n,total:t(r.value,S?.address===y.spender?y.fee:0n)}:"spl-transfer"===r.type?{fee:e,balance:n,total:`${se({amount:r.value,decimals:r.token.decimals})} ${r.token.symbol}`}:{fee:e,balance:n}}),[y,h,W,U,S?.address,C]);if(d((()=>{!async function(){if(m&&E&&i)try{v(void 0);let e=await Vl({tx:m,connection:E,client:i,checkFunds:!N});f(e)}catch(e){console.error("Failed to prepare transaction",e),v(e)}}()}),[m,E,i,N]),d((()=>{(async function(){if(!S||!E)return;b({value:C.value,isLoading:!0});let e=new le({name:"mainnet-beta",rpcUrl:E.rpcEndpoint});b({value:await e.getBalance(S.address).catch((()=>0n))??0n,isLoading:!1})})().catch(console.error)}),[y,E]),!(m&&e?.sendSolanaTransaction&&S&&E)){let n=Error("Invalid transaction request");/*#__PURE__*/return t(lu,{error:n,onClick:()=>{e?.sendSolanaTransaction?.onFailure(n),l({shouldCallAuthOnSuccess:!1})}})}let R=()=>{if(!k)return x?e?.sendSolanaTransaction?.onSuccess(x):e?.sendSolanaTransaction?.onFailure(I??w??Error("User exited the modal before submitting the transaction")),l({shouldCallAuthOnSuccess:!1})};n.current=R;let F=e.sendSolanaTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/t("img",{src:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,D=!!(e.funding&&e.funding.supportedOptions.length>0),B=!y?.hasFunds&&D;if(x){let n=y?.instructions.filter((e=>"sol-transfer"===e.type||"spl-transfer"===e.type)),r=1===n?.length?n?.at(0):void 0;/*#__PURE__*/return t(Sv,{fees:x.fees,onClose:R,transactionInfo:e.sendSolanaTransaction?.uiOptions.transactionInfo,solPrice:W,receiptHeader:e.sendSolanaTransaction?.uiOptions.successHeader,receiptDescription:e.sendSolanaTransaction?.uiOptions.successDescription,rpcEndpoint:E.rpcEndpoint,signOnly:N,instruction:"sol-transfer"===r?.type?{to:r.toAccount,amount:r.value}:{to:r?.toAccount||r?.toAta,total:O?.total}})}return I?/*#__PURE__*/t(uv,{transactionError:I,connection:E,onClose:R,network:"solana",onRetry:async()=>{_(void 0);let{blockhash:e}=await E.getLatestBlockhash();Bl(m)?m.message.recentBlockhash=e:m.recentBlockhash=e,g(m)}}):/*#__PURE__*/t(sv,{img:F,title:e.sendSolanaTransaction?.uiOptions?.transactionInfo?.title||"Confirm transaction",subtitle:e.sendSolanaTransaction?.uiOptions?.description||`${p.name} wants your permission to approve the following transaction.`,cta:B?"Add funds":e.sendSolanaTransaction?.uiOptions?.buttonText||"Approve",instructions:y?.instructions??[],network:"mainnet-beta"==P?"Solana":P,blockExplorerUrl:p.solanaClusters[P].blockExplorerUrl,total:h?L?.total:O?.total,fee:h?L?.fee:O?.fee,balance:h?L?.balance:O?.balance,swap:O?.swap,transactingWalletAddress:S.address,disabled:!y?.hasFunds&&!D,isSubmitting:k,isPreparing:!y||C.isLoading,isTokenPriceLoading:h&&U,isMissingFunds:!y?.hasFunds,submitError:I??void 0,parseError:w,onClick:B?async()=>{if(S){if(!D)throw Error("Funding wallet is not enabled");r({...e,funding:{...e.funding,methodScreen:Pw}}),a(Pw)}}:async()=>{try{if(T(!0),k||!S||!c||!u||!M)return;let t=await e.sendSolanaTransaction.onConfirm();A(t)}catch(e){console.warn({transaction:m,error:e}),_(e)}finally{T(!1)}},onClose:R})}},Pv=({privy:e,appConfig:t,getAccessToken:n,isHeadlessSigning:r,emitPrivyEvent:a,setModalData:i,openModal:o,walletProxy:s,user:l,signWithUserSigner:c,recoverEmbeddedWallet:d},{transaction:h,connection:p,transactionOptions:u,fundWalletConfig:m,uiOptions:g,address:y,signOnly:f})=>new Promise((async(w,v)=>{let{requesterAppId:C}=g||{},b=f?"signSolanaTransaction":"sendSolanaTransaction";if(!l)return a(b,"onError",Te.MUST_BE_AUTHENTICATED),void v(new he("User must be authenticated before signing with a Privy wallet",Te.MUST_BE_AUTHENTICATED));let k=y?sn(l,y):an(l);if(!k)return a(b,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),void v(new he("Must have a Privy wallet before signing",Te.EMBEDDED_WALLET_NOT_FOUND));let T=en(k);if(!await d({address:k.address}).catch((()=>!1)))throw a(b,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),new he(`Cannot sendSolanaTransaction before embedded wallet ${k.address} is connected`,Te.EMBEDDED_WALLET_NOT_FOUND);let x=async()=>{let t=await n();if(!t||!s)throw a(b,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),v(new he("Must have valid access token and Privy wallet to send transaction",Te.EMBEDDED_WALLET_NOT_FOUND)),new he("Must have valid access token and Privy wallet to send transaction",Te.EMBEDDED_WALLET_NOT_FOUND);try{let n,i;if(!await d({address:k.address}))throw a(b,"onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),v(new he("Unable to connect to wallet",Te.UNKNOWN_CONNECT_WALLET_ERROR)),new he("Unable to connect to wallet",Te.UNKNOWN_CONNECT_WALLET_ERROR);if(r({showWalletUIs:g?.showWalletUIs})&&!f)try{if(!await jl(h,p))throw a(b,"onError",Te.INSUFFICIENT_BALANCE),v(new he("Solana wallet has insufficient funds for this transaction.",Te.INSUFFICIENT_BALANCE)),new he("Solana wallet has insufficient funds for this transaction.",Te.INSUFFICIENT_BALANCE)}catch(e){throw console.error(e),a(b,"onError",Te.TRANSACTION_FAILURE),v(new he(e instanceof Error?e.message:"Transaction failed.",Te.TRANSACTION_FAILURE)),new he(e instanceof Error?e.message:"Transaction failed.",Te.TRANSACTION_FAILURE)}let{entropyId:o,entropyIdVerifier:m}=Ni(l);if(T){let t=Bl(h)?mi(h.message.serialize()):h.serializeMessage(),r=await I(e,c,{chain_type:"solana",method:"signMessage",params:{message:t.toString("base64"),encoding:"base64"},wallet_id:k.id});if(!r.data||!("signature"in r.data))throw Error("Failed to sign transaction");h.addSignature(zl(h,k.address),mi(r.data.signature,"base64")),n=h}else n=await By({accessToken:t,tx:h,walletProxy:s,entropyId:o,entropyIdVerifier:m,transactingWalletAddress:k.address,transactingWalletIndex:k.walletIndex??0});if(f)return i=$l("",n,null),a("signSolanaTransaction","onSuccess",{signedTransaction:n}),i;{let{signature:e,receipt:t}=await async function({tx:e,connection:t,transactionOptions:n}){let r;try{let a=e.serialize();r=await t.sendRawTransaction(a,n);let i=await t.confirmTransaction(r);if(i.value.err||i.value.err){let e=i.value.err||i.value.err;if("string"==typeof e)throw Error(e);throw e}return{signature:r,signedTransaction:e,receipt:await t.getParsedTransaction(r,{maxSupportedTransactionVersion:0})}}catch(e){throw e.txSignature=r,e}}({tx:n,connection:p,transactionOptions:u});i=$l(e,h,t),a("sendSolanaTransaction","onSuccess",{response:i})}return w(i),i}catch(e){throw a(b,"onError",Te.TRANSACTION_FAILURE),v(e),e}};if(r({showWalletUIs:g?.showWalletUIs}))x();else{let{entropyId:e,entropyIdVerifier:n}=Ni(l,k),r={recoveryMethod:k.recoveryMethod,connectingWalletAddress:k.address,entropyId:e,entropyIdVerifier:n,isUnifiedWallet:T,onCompleteNavigateTo:Mv,onFailure:e=>{a(b,"onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),v(e)}},s=Yy(t)?Dw({address:k.address,appConfig:t,methodScreen:Pw,fundWalletConfig:m,comingFromSendTransactionScreen:!0}):void 0;i({connectWallet:r,sendSolanaTransaction:{transactionRequest:h,connection:p,transactionOptions:u,transactingWallet:k,onConfirm:x,onSuccess:e=>{f?a("signSolanaTransaction","onSuccess",{signedTransaction:e.signedTransaction}):a("sendSolanaTransaction","onSuccess",{response:e}),w(e)},onFailure:e=>{a(b,"onError",Te.TRANSACTION_FAILURE),v(e)},uiOptions:g||{},requesterAppId:C,signOnly:f},funding:s}),o(Kw)}}));function Wv(e){let t=$o(),{getAccessToken:n,user:r}=Ky(),{setModalData:a}=qo(),{isHeadlessSigning:i,openModal:o,walletProxy:s,recoverEmbeddedWallet:l,privy:c}=Pt(),d=bs(),{signWithUserSigner:h}=dn();return vs("sendSolanaTransaction",e),{sendTransaction:async({transaction:e,connection:p,uiOptions:u,transactionOptions:m,fundWalletConfig:g,address:y})=>await Pv({privy:c,appConfig:t,getAccessToken:n,isHeadlessSigning:i,emitPrivyEvent:d,setModalData:a,openModal:o,walletProxy:s,user:r,signWithUserSigner:h,recoverEmbeddedWallet:l},{transaction:e,connection:p,transactionOptions:m,uiOptions:u,fundWalletConfig:g,address:y,signOnly:!1})}}const Uv=/*#__PURE__*/vn.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 Ov=({data:n})=>{let r=n=>"object"==typeof n&&null!==n?/*#__PURE__*/t(Rv,{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 Lv=/*#__PURE__*/vn.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 Rv=/*#__PURE__*/vn.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 Fv=({data:e})=>/*#__PURE__*/t(Lv,{children:/*#__PURE__*/t(Ov,{data:e})});let Dv=e=>{if(!Dt(e))return e;try{let t=Kt(e);return t.includes("�")?e:t}catch{return e}},Bv=e=>JSON.stringify(e,null,2),zv=r=>{let{types:a,primaryType:i,...o}=r.typedData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Fv,{data:o}),/*#__PURE__*/t(Yu,{text:Bv(r.typedData),itemName:"full payload to clipboard"})," "]})};const $v={component:()=>{let{authenticated:r}=nn(),{initializeWalletProxy:a,closePrivyModal:i}=Pt(),{navigate:s,data:l,onUserCloseViaDialogOrKeybindRef:c}=qo(),[h,p]=o(!0),[u,m]=o(""),[g,y]=o(),[f,w]=o(null),[v,C]=o(!1),b=null!==f;d((()=>{r||s(dy)}),[r]),d((()=>{a(Ba).then((e=>{p(!1),e||(m("An error has occurred, please try again."),y(new Li(new Oi(u,x.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:k,data:T,confirmAndSign:A,onSuccess:I,onFailure:_,uiOptions:E}=l.signMessage,S={title:E?.title||"Sign message",description:E?.description||"Signing this message will not cost you any fees.",buttonText:E?.buttonText||"Sign and continue"},N=e=>{e?I(e):_(g||new Li(new Oi("The user rejected the request.",x.E4001_USER_REJECTED_REQUEST.eipCode))),i({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{w(null),m(""),y(void 0)}),200)};return c.current=()=>{N(f)},/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{onClose:()=>N(f)}),/*#__PURE__*/t(hc,{}),E?.iconUrl&&"string"==typeof E.iconUrl?/*#__PURE__*/t(Hv,{children:/*#__PURE__*/t(Uv,{size:"sm",src:E.iconUrl,alt:"app image"})}):null,/*#__PURE__*/t(by,{children:S.title}),/*#__PURE__*/t(Cy,{children:S.description}),"personal_sign"===k&&/*#__PURE__*/t(Lv,{children:Dv(T)}),"eth_signTypedData_v4"===k&&/*#__PURE__*/t(zv,{typedData:T}),"solana_signMessage"===k&&/*#__PURE__*/t(Lv,{children:T}),/*#__PURE__*/t(qv,{}),/*#__PURE__*/t(jv,{$fail:!0,children:u}),/*#__PURE__*/t(zs,{disabled:v||b||h,loading:v,onClick:async()=>{C(!0),m("");try{let e=await A();w(e),C(!1),setTimeout((()=>{N(e)}),wa)}catch(e){console.error(e),m("An error has occurred, please try again."),y(new Li(new Oi(u,x.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),C(!1)}},children:v?"Signing...":b?/*#__PURE__*/e(Vv,{children:[/*#__PURE__*/t(Ku,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",/*#__PURE__*/t("span",{children:"Success"})]}):S.buttonText}),E?.isCancellable&&/*#__PURE__*/t(Zs,{style:{marginTop:"1rem"},onClick:()=>N(null),isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}};let jv=/*#__PURE__*/vn.div.withConfig({displayName:"InputHelp",componentId:"sc-af56055-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__*/vn.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-af56055-1"})(["display:flex;align-items:center;gap:8px;"]),Hv=/*#__PURE__*/vn.div.withConfig({displayName:"IconContainer",componentId:"sc-af56055-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),qv=/*#__PURE__*/vn.div.withConfig({displayName:"Grow",componentId:"sc-af56055-3"})(["flex-grow:1;"]);function Kv(e){let{isHeadlessSigning:t,walletProxy:n,initializeWalletProxy:r,recoverEmbeddedWallet:a,openModal:i,privy:o}=Pt(),{user:s,getAccessToken:l}=Ky(),c=bs(),{setModalData:d}=qo(),{signWithUserSigner:h}=dn();return vs("signSolanaMessage",e),{signMessage:({message:e,options:p})=>new Promise((async(u,m)=>{if(!s)return c("signSolanaMessage","onError",Te.MUST_BE_AUTHENTICATED),void m(Error("User must be authenticated before signing with a Privy wallet"));let g=p?.address?sn(s,p.address):an(s);if(!g)return c("signSolanaMessage","onError",Te.EMBEDDED_WALLET_NOT_FOUND),void m(Error("Must have a Privy wallet before signing"));let{entropyId:y,entropyIdVerifier:f}=Ni(s,g),w=en(g),v=mi(e).toString("base64");if(v.length<1)return c("signMessage","onError",Te.INVALID_MESSAGE),void m(Error("Message must be a non-empty string"));let C=async()=>{let e;if(!s)throw Error("User must be authenticated before signing with a Privy wallet");let t=await l();if(!t)throw Error("User must be authenticated to use their embedded wallet.");let i=n??await r(15e3);if(!i)throw Error("Failed to initialize embedded wallet proxy.");if(!await a({address:g.address}))throw Error("Unable to connect to wallet");if(w){let t=await I(o,h,{chain_type:"solana",method:"signMessage",params:{message:v,encoding:"base64"},wallet_id:g.id});if(!t.data||!("signature"in t.data))throw Error("Failed to sign message");e=t.data.signature}else{let{response:n}=await i.rpc({accessToken:t,entropyId:y,entropyIdVerifier:f,chainType:"solana",hdWalletIndex:g.walletIndex??0,request:{method:"signMessage",params:{message:v}}});e=n.data.signature}return e};if(t({showWalletUIs:p?.uiOptions?.showWalletUIs}))try{let e=await C(),t=new Uint8Array(mi(e,"base64"));c("signSolanaMessage","onSuccess",{signature:t}),u(t)}catch(e){m(e)}else d({signMessage:{method:"solana_signMessage",data:v,confirmAndSign:C,onSuccess:e=>{let t=new Uint8Array(mi(e,"base64"));c("signSolanaMessage","onSuccess",{signature:t}),u(t)},onFailure:e=>{m(e)},uiOptions:p?.uiOptions},connectWallet:{recoveryMethod:g.recoveryMethod,connectingWalletAddress:g.address,entropyId:y,entropyIdVerifier:f,isUnifiedWallet:w,onCompleteNavigateTo:$v,onFailure:e=>{c("signSolanaMessage","onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),m(e)}}}),i(Kw)}))}}const Zv=()=>{let{exportSolanaWallet:e,solanaWallets:t,walletProxy:n,recoverEmbeddedWallet:r,privy:a}=Pt(),{sendTransaction:i}=Wv(),{signMessage:o}=Kv(),{create:l}=Vy(),{signWithUserSigner:c}=dn(),{user:d,getAccessToken:h}=Ky(),{ready:p}=Vc(),u=s((()=>{if(!n)return t;let e=[...hn(d),ln(d)].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 he("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:()=>{throw new he("Cannot unlink an embedded Solana wallet")},async getProvider(){return new Dy(n,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 i=await h();if(!i||!n)throw new he("Must have valid access token and Privy wallet to send transaction",Te.MUST_BE_AUTHENTICATED);if(!await r({address:e.address}).catch((()=>!1)))throw new he("Wallet couldn't be connected",Te.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:o,entropyIdVerifier:s}=Ni(d,e);if(en(e)){let n=Bl(t)?mi(t.message.serialize()):t.serializeMessage(),r=await I(a,c,{chain_type:"solana",method:"signMessage",params:{message:n.toString("base64"),encoding:"base64"},wallet_id:e.id});if(r.data&&"signature"in r.data)return t.addSignature(zl(t,e.address),mi(r.data.signature,"base64")),t;throw Error("Failed to sign transaction")}return await By({tx:t,accessToken:i,walletProxy:n,entropyId:o,entropyIdVerifier:s,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0})},async signAllTransactions(t){let i=await h();if(!i||!n)throw new he("Must have valid access token and Privy wallet to send transaction",Te.MUST_BE_AUTHENTICATED);if(!await r({address:e.address}).catch((()=>!1)))throw new he("Wallet couldn't be connected",Te.UNKNOWN_CONNECT_WALLET_ERROR);let{entropyId:o,entropyIdVerifier:s}=Ni(d,e);if(en(e))return await Promise.all(t.map((async t=>{let n=Bl(t)?mi(t.message.serialize()):t.serializeMessage(),r=await I(a,c,{chain_type:"solana",method:"signMessage",params:{message:n.toString("base64"),encoding:"base64"},wallet_id:e.id});if(r.data&&"signature"in r.data)return t.addSignature(zl(t,e.address),mi(r.data.signature,"base64")),t;throw Error("Failed to sign transaction")})));for(let r of t)await By({tx:r,accessToken:i,walletProxy:n,entropyId:o,entropyIdVerifier:s,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0});return t},loginOrLink:async()=>{throw new he("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{},isConnected:async()=>!0})));return t.concat(e)}),[d,n,h,t]);return{ready:!(!p||!n),createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let{account:t}=await l({chainType:"solana",options:e});return t},exportWallet:e,wallets:u}},Yv={component:()=>{let{wallets:r}=Vc(),{wallets:a}=Zv(),{data:i,setModalData:l,navigate:c,lastScreen:h}=qo(),{rpcConfig:p,appId:u,createAnalyticsEvent:m,closePrivyModal:g}=Pt(),y=$o(),[f,w]=o(void 0),[v,C]=o(!1),b=Ym(),k=i?.funding,{reloadBalance:T}=Wy({rpcConfig:p,appId:u,address:"ethereum"===k.chainType?k.address:void 0,chain:"ethereum"===k.chainType?k.chain:void 0}),x="solana"===k.chainType,A=x?k.isUSDC?"USDC":"SOL":k.erc20Address?k.erc20ContractInfo?.symbol:k.chain.nativeCurrency.symbol,I=x?a.find((({address:e})=>e===k.address)):r.find((({address:e})=>Gr(e)===Gr(k.address)));if(!k)return l({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:h||Pw},funding:i?.funding,sendTransaction:i?.sendTransaction}),c(su),/*#__PURE__*/t(n,{});d((()=>{let e=x?async function(){if("solana"!==k.chainType)return;let e=b(Ry);e?(k.isUSDC?e.getTokenBalance({address:k.address,cluster:k.cluster,mintAddress:Z[k.cluster.name]}).then((({amount:e})=>e)):e.getBalance({address:k.address,cluster:k.cluster})).then((e=>{let t=BigInt(e);f&&t>f&&(C(!0),m({eventName:Uy,payload:{provider:"manual",status:"success",chainType:"solana",address:I?.address,value:k.isUSDC?Rt(t-f,6):Rt(t-f,9),token:k.isUSDC?"USDC":"SOL"}})),w(t)})):console.warn("Unable to load solana plugin, skipping balance")}:async function(){"ethereum"===k.chainType&&(async()=>{if(!k.erc20Address)return await T()??BigInt(0);{let{balance:e}=await Oy({chain:k.chain,address:k.address,erc20Address:k.erc20Address,rpcConfig:p,appId:u});return e}})().then((e=>{f&&e>f&&(C(!0),m({eventName:Uy,payload:{provider:"manual",status:"success",chainType:"ethereum",address:I?.address,chainId:k.chain.id,value:Rt(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?se({amount:f,decimals:6}):x?Ol(f,3,!0,!0):null!=k.erc20ContractInfo?.decimals?se({amount:f,decimals:k.erc20ContractInfo.decimals}):ce({wei:f})),[f,x,k]),S="ethereum"===k.chainType?k.chain.name:Jv[k.cluster.name],N=s((()=>""===k.uiConfig?.receiveFundsTitle?null:/*#__PURE__*/t(by,{children:k.uiConfig?.receiveFundsTitle??`Receive ${k.amount} ${A??""}`.trim()})),[k.uiConfig?.receiveFundsTitle,k.amount,A]),M=s((()=>""===k.uiConfig?.receiveFundsSubtitle?null:/*#__PURE__*/t(Cy,{children:k.uiConfig?.receiveFundsSubtitle??`Scan this code or copy your wallet address to receive funds on ${S}.`})),[k.uiConfig?.receiveFundsSubtitle,S]),P="solana"===k.chainType&&k.isUSDC&&Z[k.cluster.name]?`?spl-token=${Z[k.cluster.name]}`:"";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(CC,{}),N,M,/*#__PURE__*/e(lc,{style:{gap:"1rem",margin:N||M?"1rem 0":"0"},children:[/*#__PURE__*/t(sm,{url:`${k.chainType}:${k.address}${P}`,size:200,squareLogoElement:Gv}),/*#__PURE__*/e(Iy,{theme:y.appearance.palette.colorScheme,children:["Make sure to send funds on ",S,"."]}),/*#__PURE__*/t(Py,{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(Bs,{onClick:()=>g({shouldCallAuthOnSuccess:!1,isSuccess:!0}),children:"Continue"})]}),/*#__PURE__*/t(Xs,{})]})}};let Gv=({...e})=>/*#__PURE__*/t(Zi,{color:"black",...e}),Jv={devnet:"Devnet","mainnet-beta":"Solana",testnet:"Testnet"},Qv=/*#__PURE__*/vn.div.withConfig({displayName:"Container",componentId:"sc-b3a607dd-0"})(["display:flex;flex-direction:column;min-height:72px;"]);var Xv=({onBack:n,details:r})=>/*#__PURE__*/e(Qv,{children:[/*#__PURE__*/t(al,{backFn:n}),/*#__PURE__*/t(Fv,{data:r}),/*#__PURE__*/t(Xs,{})]});let eC=({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return Ft(e*t)}catch(e){return}};const tC=({txn:r,receipt:a,transactionInfo:i,onClose:o,tokenPrice:s,tokenSymbol:l,receiptHeader:c,receiptDescription:d})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{onClose:o}),/*#__PURE__*/t(uh,{title:c??"Transaction complete!",description:d??"You're all set."}),/*#__PURE__*/t(Fc,{tokenPrice:s,from:a.from,to:a.to,gas:eC(a),txn:r,transactionInfo:i,tokenSymbol:l}),/*#__PURE__*/t(Ts,{}),/*#__PURE__*/t(nC,{loading:!1,onClick:o,children:"All Done"}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]});let nC=/*#__PURE__*/vn(Bs).withConfig({displayName:"SubmitButton",componentId:"sc-f70d0f7a-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const rC=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],aC=[{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"}]}],iC=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],oC=[{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"}],sC=[{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"}],lC=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],cC=[{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"}],dC=[{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"}],hC=[{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"}],pC=(e,t)=>{let n=uC(iC,e);if(n)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:n.args[0],amount:n.args[1]};let r=uC(bf,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=uC(rC,e);if(a&&"string"==typeof a.args[1]){let e=mC(a.args[1]);if(e&&e[4].encodedInitData)return pC(e[4].encodedInitData,t)}let i=uC(lC,e);if(i)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:i.args[0],approved:i.args[1]};let o=uC(cC,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=uC(sC,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=uC(hC,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=uC(dC,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=uC(oC,e);return d?{action:"mint",functionName:d.functionName,isNFTIsh:!0,isErc20Ish:!1,args:d.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}};let uC=(e,t)=>{try{let n=Zt({abi:e,data:t});return{functionName:n.functionName,args:n.args||[]}}catch(e){return null}},mC=e=>{try{if("string"==typeof e)return Yt(aC,`0x${e.slice(10)}`)}catch(e){return null}},gC=e=>`${parseFloat(e).toFixed(2)}`;const yC=(e,t,n,r)=>{let[a,i]=o(null),{getAccessToken:s}=nn(),{walletProxy:l}=Pt();return d((()=>{a&&i(null),(async()=>{if(!await s()||!l||!t)return null;let a=[],i=!0,o=await Hc(e,n,t,r).catch((t=>(t.message.includes("Insufficient balance for transaction")||t.details.includes("insufficient funds")?i=!1:a.push(t),e)));return{tx:o,totalGasEstimate:o.gas,hasFunds:i,errors:a}})().then(i)}),[e]),a};let fC=new Li(new Oi("There was an issue preparing your transaction",x.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),wC=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0;const vC={component:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=qo(),{rpcConfig:i,chains:l,closePrivyModal:c,walletProxy:h,showFiatPrices:p}=Pt(),{getAccessToken:u,user:m}=nn(),g=$o(),[y,f]=o(0),[w,v]=o(0),[C,b]=o(wC(e,y)),[k,T]=o(null),[A,I]=o(),[_,E]=o(!1),[S,N]=o(null),[M,P]=o(null),[W,U]=o(null),[O,L]=o(void 0),[R,F]=o(void 0),[D,B]=o(!1),[z,$]=o(!1),[j,V]=o([]),[H,q]=o([]),[K,Z]=o("uninitiated"),[Y,G]=o(void 0);if(!C||!e?.sendTransaction||!e?.sendTransaction)/*#__PURE__*/return t(lu,{error:Error("Invalid transaction request"),onClick:()=>{e?.sendTransaction?.onFailure(fC),c({shouldCallAuthOnSuccess:!1})}});let{entropyId:J,entropyIdVerifier:Q,transactingWalletIndex:X,transactingWalletAddress:ee}=e.sendTransaction,te=s((()=>l.find((e=>Number(e.id)===Number(C.chainId)))),[C.chainId]),ne=te?.nativeCurrency.symbol??"ETH",re=s((()=>pC(C.data,!!g.embeddedWallets.extendedCalldataDecoding)),[C.data]),{action:ae,isErc20Ish:ie,isNFTIsh:oe}=re,{toAddress:se,tokenAddress:le}=s((()=>({toAddress:re.isErc20Ish?re.transferTo:C.to??void 0,tokenAddress:re.isErc20Ish?C.to:void 0})),[re]);d((()=>{C.to&&te&&ie&&nf({address:C.to,chain:te,rpcConfig:g.rpcConfig,privyAppId:g.id}).then(T).catch(console.error)}),[C.to,te]);let{tokenPrice:ce,isTokenPriceLoading:de}=$c(C.chainId),{balance:he}=Wy({rpcConfig:g.rpcConfig,appId:g.id,address:ee,chain:te}),pe=s((()=>Kr(Number(C.chainId),l,i,{appId:g.id})),[C.chainId,i]),ue=yC(C,ee,pe,e?.sendTransaction?.prepareTransactionRequest);d((()=>{b(wC(e,y))}),[y]),d((()=>{e.sendTransaction?.getIsSponsored?e.sendTransaction.getIsSponsored().then(I).catch(console.error):I(!1)}),[e.sendTransaction.getIsSponsored]);let me=()=>{if(!_)return S?e?.sendTransaction?.onSuccess({hash:S}):W||ue?.errors[0]?e?.sendTransaction?.onFailure(W??ue?.errors[0]??fC):e?.sendTransaction?.onFailure(new Li(new Oi("The user rejected the request",x.E4001_USER_REJECTED_REQUEST.eipCode))),c({shouldCallAuthOnSuccess:!1})};n.current=me;let ge=!!(e.funding&&e.funding.supportedOptions.length>0),ye=Il(BigInt(ue?.totalGasEstimate??0n),ne),fe=p&&ce?Al(BigInt(ue?.totalGasEstimate??0n),ce):void 0,we=Il(he??0n,ne,void 0,!0),ve=p&&ce?Al(he??0n,ce):void 0,Ce=e.sendTransaction?.uiOptions?.transactionInfo?.title;Ce||(Ce="approve"===ae?ie?"Confirm address":"Confirm action":`Approve ${ae}`);let be=e.sendTransaction?.uiOptions?.description||(ie&&"approve"===ae?`${g.name} would like your permission for ${Gr(re.spender)} to spend tokens on your behalf.`:`${g.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,Te=!(!ue||ue.errors[0]||ue.hasFunds||!1!==A),xe=Te&&ge,Ae=xe?"Add funds":e.sendTransaction?.uiOptions?.buttonText||(y<w?"Continue":"Approve"),Ie=e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?F("safe"):"Warning"===e.validation.result_type?F("warn"):"Malicious"===e.validation.result_type&&(F("error"),$(!0))),"Success"!==e.simulation.status)throw Error("Simulation failed");{L(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,nftCount:t.in.length}:{iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price?gC(t.in[0].usd_price):void 0},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?gC(t.out[0].usd_price):void 0},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?gC(e.spenders[t]?.usd_price):void 0},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");V(n),q(t)}};if(d((()=>{e.sendTransaction?.scanTransaction&&g.embeddedWallets.transactionScanning.enabled&&"uninitiated"===K&&(Z("in progress"),e.sendTransaction.scanTransaction().then((e=>{Ie(e),Z("completed")})).catch((()=>Z("failed"))))}),[!!e.sendTransaction?.scanTransaction]),d((()=>{e.sendTransaction?.scanTransaction&&"failed"!==K||((t,n,r)=>{if(v((e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(e)),n.isErc20Ish&&n.amount&&r){let e=Tf({amount:n.amount,decimals:r.decimals});G(e),V([{value:e,symbol:r?.symbol}])}else if(t.value){let e=BigInt(t.value),n=ce&&Al(e,ce);V(p&&n?[{value:n}]:[{value:_l(e),symbol:ne}])}else V(p?[{value:"$0"}]:[{value:"0",symbol:ne}])})(ue?.tx??C,re,k)}),[C,ue?.tx,re,k,K]),M/*#__PURE__*/)return t(tC,{txn:ue?.tx??C,onClose:me,receipt:M,transactionInfo:e.sendTransaction?.uiOptions.transactionInfo,tokenPrice:ce,tokenSymbol:ne,receiptHeader:e.sendTransaction?.uiOptions.successHeader,receiptDescription:e.sendTransaction?.uiOptions.successDescription});if(W)/*#__PURE__*/return t(uv,{transactionError:W,transactionHash:S??void 0,network:"ethereum",chainId:ue?.tx.chainId??C.chainId,onClose:me,onRetry:({resetNonce:e})=>{U(null);let t={...ue?.tx??C};e&&(t.nonce=void 0),b(t)}});let _e=0!==w&&"number"==typeof y&&0!==y?()=>{f(y-1)}:void 0;return D&&O?/*#__PURE__*/t(Xv,{details:O,onBack:()=>B(!1)}):/*#__PURE__*/t(ov,{transactionIndex:y,onBack:_e,maxIndex:w,disabled:Te&&!ge||z,isSubmitting:_,submitError:W,isPreparing:!ue,isTokenPriceLoading:de,isTokenContractInfoLoading:!oe&&!k,prepareError:ue?.errors[0],symbol:k?.symbol,chain:te,img:ke,title:Ce,subtitle:be,txValue:C.value,fee:fe??ye,isSponsored:A,from:ee??"",to:se,tokenAddress:le??void 0,network:g.chains.find((e=>e.id===C.chainId))?.name??"",transactionDetails:{...re,formattedAmount:Y},cta:Ae,missingFunds:Te,action:ae,balance:ve??we,onClose:me,onClick:xe?async()=>{if(ee){if(!ge)throw Error("Funding wallet is not enabled");r({...e,funding:{...e.funding,methodScreen:Pw,chainType:"ethereum",amount:Lt(BigInt(ue?.tx.value??0)+BigInt(ue?.totalGasEstimate?.toString()??0)),chain:te}}),a(Pw)}}:async()=>{if(y<w)f(y+1);else{E(!0);try{let t=await u();if(_||!t||!h||!m)return;let n=e?.sendTransaction?.onConfirm?await e.sendTransaction.onConfirm():await async function({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWalletIndex:r,walletProxy:a,transactionRequest:i,publicClient:o,requesterAppId:s}){let l=await th({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWalletIndex:r,walletProxy:a,transactionRequest:i,requesterAppId:s});return await o.sendRawTransaction({serializedTransaction:l})}({accessToken:t,transactingWalletIndex:X,entropyId:J,entropyIdVerifier:Q,walletProxy:h,transactionRequest:ue?.tx??C,publicClient:pe,requesterAppId:e.sendTransaction?.requesterAppId});if(N(n),e.sendTransaction?.signOnly)return await new Promise((e=>setTimeout(e,wa))),e?.sendTransaction?.onSuccess({hash:n}),c({shouldCallAuthOnSuccess:!1});let r=await pe.waitForTransactionReceipt({hash:n});if("reverted"===r.status)throw Error("Transaction failed");P(r)}catch(e){console.warn({transaction:ue?.tx??C,error:e}),U(e)}finally{E(!1)}}},validation:R,hasScanDetails:!!O,setIsScanDetailsOpen:B,preventMaliciousTransaction:z,setPreventMaliciousTransaction:$,tokensSent:j,tokensReceived:H,isScanning:"in progress"===K,isCancellable:e.sendTransaction?.uiOptions?.isCancellable??!1})}};function CC({title:e}){let{currentScreen:n,navigateBack:r,navigate:a,data:i,setModalData:o}=qo();/*#__PURE__*/return t(al,{title:e,backFn:n===Yv?r:n===i?.funding?.methodScreen?i.funding.comingFromSendTransactionScreen?()=>a(vC):void 0:i?.funding?.methodScreen?()=>{let e=i.funding;e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),o({funding:e}),a(e.methodScreen)}:void 0})}const bC={component:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:s}=Pt(),{navigate:l,setModalData:c,app:h,data:p}=qo(),{wallets:u}=Vc(),m=Ym(),[g,y]=o(null),[f,w]=o(null),[v,C]=o([]),[b,k]=o(0),[T,x]=o(!1),[A,I]=o(!1),[_,E]=o(!1),[S,M]=o(!1),[P,W]=o(),[U,O]=o();if(!p?.funding||"solana"!==p.funding.chainType)throw Error("Invalid funding data");let{address:L,cluster:R,connectedWalletAddress:F}=p.funding,[D,B]=o(p.funding.amount),z=F?u.find((({address:e})=>e===F)):u[0],$=To(z?.walletClientType||"unknown"),j=$?.name||"wallet",[V,H]=o(null);d((()=>{(async()=>{if(!z)return;let e=await z.getEthereumProvider();H($t({account:z.address,transport:jt(e)}).extend(Vt))})().catch(console.error)}),[z]);let[q,K]=o(0n),Z=Ol(q);d((()=>{let e=m(Ry);e?e.getBalance({address:L,cluster:R}).then((e=>K(BigInt(e)))):console.warn("Unable to load solana plugin, skipping balance")}),[]);let[Y,G]=o(),{tokenPrice:J}=$c("solana"),{fundingAmountInBaseUnit:Q,fundingAmountInUsd:X}=Rl({amount:D,fee:0n,tokenPrice:J,isUsdc:p.funding.isUSDC});if(d((()=>{(async()=>{if(!V||!z)return;let e=["testnet","devnet"].includes(R.name);e&&console.warn("Solana testnets are not supported for bridging");let t=N(h.chains).filter((({testnet:t})=>!!t===e)),n=(await xf({chains:t,address:z.address,appId:a,rpcConfig:r})).filter((e=>e.balance>0n));if(n.length<1)return void y(new he(`Wallet ${Gr(z.address)} does not have enough funds.`,void 0,Te.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({...e,quote:await nu({isTestnet:!1,input:Xp({amount:Q.toString(),user:z.address,recipient:L,destinationChainId:No,destinationCurrency:Mo,originChainId:e.chain.id})})}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void y(new he(`Unable to fetch quotes for bridging. Wallet ${Gr(z.address)} does not have enough funds.`,void 0,Te.INSUFFICIENT_BALANCE));let o=i.map((({quote:e,balance:t,chain:n})=>({bridgeTx:ru(e),balance:t,chain:n,isErc20Quote:!1}))).filter((({bridgeTx:e})=>!!e));if(o.length>1)return void C(o);let s=o.at(0);s?(I(!0),G({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):y(new he(`Unable to select bridge option from quotes. Wallet ${Gr(z.address)} does not have enough funds.`,void 0,Te.INSUFFICIENT_BALANCE))})().catch(console.error)}),[V]),d((()=>{(async()=>{let e,t;if(!V||!z||T||_||!Y)return;x(!0);let n=Ut({chain:Y.chain,transport:Ot(Zr(Y.chain,r,a))});try{e=await n.prepareTransactionRequest({account:z.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){x(!1),E(!0);try{await V.switchChain({id:Y.chain.id})}catch(e){await V.addChain({chain:Y.chain}),await V.switchChain({id:Y.chain.id})}try{t=await V.sendTransaction(e)}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(v.length<1?y(new he(e.shortMessage,void 0,Te.TRANSACTION_FAILURE)):w(e.shortMessage??"Something went wrong"))}if(t)return await V.waitForTransactionReceipt({hash:t}),A?(O("pending"),void W(t)):(E(!1),M(!0),void s({eventName:Uy,payload:{provider:"external",status:"success",txHash:t,address:z.address,chainId:Y.chain.id,chainType:"ethereum",value:Y.value?Rt(BigInt(Y.value),18):void 0,token:"ETH",destination:L,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Rt(Q,9),destinationToken:"SOL"}}));E(!1)}else x(!1)})().catch(console.error)}),[V,Y]),au({transactionHash:P,wallet:z,isTestnet:!1,bridgingStatus:U,setBridgingStatus:O,onSuccess({transactionHash:e,wallet:t}){I(!1),M(!0),s({eventName:Uy,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:Y?.chain.id,chainType:"ethereum",value:Y?.value?Rt(BigInt(Y.value),18):void 0,token:"ETH",destination:L,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Rt(Q,9),destinationToken:"SOL"}})},onFailure({error:e}){I(!1),y(e)}}),d((()=>{g&&(c({funding:p?.funding,sendTransaction:p?.sendTransaction,errorModalData:{error:g,previousScreen:uw}}),l(su,!1))}),[g]),d((()=>{if(!S)return;let e=setTimeout(i,Ca);return()=>clearTimeout(e)}),[S]),S/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(CC,{}),/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(sc,{children:[/*#__PURE__*/t(vr,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(gh,{title:"Success!",description:`You’ve successfully added ${D} SOL to your ${h.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]});let ee=v[b];return v.length>1&&ee?/*#__PURE__*/t(cw,{displayName:j,configuredFundingChain:R,formattedBalance:Z,fundingAmount:D,fundingCurrency:"SOL",fundingAmountInUsd:X,options:v,selectedOption:ee,isPreparing:T,isSubmitting:_,addressToFund:L,fundingWalletAddress:z?.address||"",errorMessage:f,onSubmit:()=>{p.funding?.amount!==D?async function(){if(z&&ee)try{let e=await nu({isTestnet:!1,input:Xp({amount:Q.toString(),user:z.address,recipient:L,destinationChainId:No,destinationCurrency:Mo,originChainId:ee.chain.id})}),t=ru(e);if(!t)throw Error("Invalid transaction request");I(!0),G({data:t.data,to:t.to,value:t.value,chain:ee.chain})}catch(e){console.error(e),y(new he("Unable to fetch quotes for bridging",e,Te.INSUFFICIENT_BALANCE))}}().catch(console.error):G({to:ee.bridgeTx.to,data:ee.bridgeTx.data,value:ee.bridgeTx.value,chain:ee.chain})},onSelect:e=>{e!==b&&(w(null),k(e))},onAmountChange:B}):_&&z?/*#__PURE__*/t(wf,{wallet:z,displayName:j,addressToFund:L,isBridging:A,isErc20Flow:!1,chainId:"solana",chainName:R.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
|
|
25
|
-
/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(CC,{}),/*#__PURE__*/t(af,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(Xs,{})]})}},kC=new Map([[Pw,null],[uw,"external"],[dw,"external"],[Cf,"external"],[bC,"external"],[hw,"external"],[Yv,"manual"],[Tw,"moonpay"]]);const TC=()=>((()=>{let e=$o(),{user:t,getAccessToken:n}=nn(),{refreshSessionAndUser:r,walletProxy:a}=Pt();d((()=>{(async()=>{if("legacy-embedded-wallets-only"===e.embeddedWallets.mode||!t)return;let i=Xt(t);if(!i||en(i)||!Jd(i)||!a)return;let o=await n();if(!o)return;let s=i.imported?[i]:t.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported)).filter(Jd),{entropyId:l,entropyIdVerifier:c}=Ni(t,i);try{await a.connect({accessToken:o,entropyId:l,entropyIdVerifier:c})}catch(e){if(!Jc(e)||"privy"!==i.recoveryMethod)return void console.debug("Unable to migrate wallet: ",e);await a.recover({accessToken:o,entropyId:l,entropyIdVerifier:c})}try{await a.createDelegatedAction({accessToken:o,rootWallet:{address:i.address,chainType:i.chainType,imported:i.imported},delegatedWallets:s}),await r()}catch(i){console.debug("Unable to migrate wallet: ",i)}})()}),[t,a,e])})(),null),xC={component:()=>{let{app:r,data:a}=qo(),i=$o(),o=a?.externalConnectWallet?.suggestedAddress,s=o?`Connect the wallet with address ${Gr(o)} ${r?.name?`to ${r.name}.`:"."}`:`Connect a wallet to ${r?.name}`,{connectors:l}=Pt(),c=Sg({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(al,{},"header"),c.length>0&&/*#__PURE__*/t(mh,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(Is,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(Eg,{wallets:c})}),/*#__PURE__*/t(Xs,{})]})}},AC={component:()=>{let{app:r,data:a}=qo(),i=$o(),o=a?.externalConnectWallet?.suggestedAddress,s=o?/*#__PURE__*/e("span",{children:["Connect the wallet with address ",/*#__PURE__*/t(Zp,{showCopyIcon:!1,address:o})," ",r?.name?`to ${r.name}.`:"."]}):`Connect a wallet to your ${r?.name} account`,{connectors:l}=Pt(),c=Sg({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(al,{},"header"),c.length>0&&/*#__PURE__*/t(uh,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(Is,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(Eg,{wallets:c})}),r&&/*#__PURE__*/t(Qs,{app:r,alwaysShowImplicitConsent:!0}),/*#__PURE__*/t(Xs,{})]})},isUnauthenticatedScreem:!0};function IC(e){let{logout:t}=l(rn);return vs("logout",e),{logout:t}}const _C={component:()=>{let r=$o(),{data:a,navigate:i,setModalData:l,onUserCloseViaDialogOrKeybindRef:c}=qo(),{crossAppAuthFlow:h,updateWallets:p,closePrivyModal:u,createAnalyticsEvent:m}=Pt(),{logout:g}=IC(),[y,f]=o({}),w=a?.crossAppAuth,v={id:w.appId,name:w.name,logoUrl:w.logoUrl},C=new he(`There was an issue connecting your ${v.name} account. Please try again.`),b=new ga((async e=>{if(w.popup)try{let t=await h({appId:e,popup:w.popup,action:w.action});f({data:t})}catch(e){e instanceof he?f({error:e}):(e instanceof Ke&&w.popup&&w.popup.close(),f({error:C}))}else f({error:C})})),k=()=>{y.data&&(p(),w.onSuccess(y.data),u({shouldCallAuthOnSuccess:!0,isSuccess:!0})),w.onError(y.error??new he("User canceled flow")),u({shouldCallAuthOnSuccess:!1,isSuccess:!1})};c.current=k,d((()=>{v.id.length&&b.execute(v.id)}),[v.id]),d((()=>{if(!y.data)return;let e=y.data;if(r.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{i(Wu)}),wa);return()=>clearTimeout(e)}if($p(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(Mu)}),wa);return()=>clearTimeout(e)}let t=setTimeout(k,wa);return()=>clearTimeout(t)}),[y.data]);let{title:T,subtitle:x}=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(al,{onClose:k}),/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(EC,{children:[/*#__PURE__*/t(kd,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Us,{success:!!y.data,fail:!!y.error}),/*#__PURE__*/t(Lp,{name:v.name,logoUrl:v.logoUrl})]})}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t("h3",{children:T}),/*#__PURE__*/t("p",{children:x})]})]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(el,{})]})}};let EC=/*#__PURE__*/vn.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 SC={component:()=>{let{app:r,data:a}=qo(),{closePrivyModal:i}=Pt(),[s,l]=o(!1),[c,h]=o(),{address:p,onDelegate:u,onSuccess:m,onError:g}=a.delegatedActions.consent,y=async()=>{s?m():g(c??new he("User declined delegating actions.")),i({shouldCallAuthOnSuccess:!1})};return d((()=>{if(!s&&!c)return;let e=setTimeout(y,va);return()=>clearTimeout(e)}),[s,c]),/*#__PURE__*/e(n,s||c?{children:[/*#__PURE__*/t(al,{onClose:y}),/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(ic,{children:[c?/*#__PURE__*/t(tr,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(vr,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(mc,{height:20}),/*#__PURE__*/t(gh,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":`You’ve successfully granted delegated action permissions to ${r.name}.`})]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]}:{children:[/*#__PURE__*/t(al,{closeable:!0,onClose:y}),/*#__PURE__*/t(Er,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(id,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),/*#__PURE__*/e(od,{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(MC,{showIcon:!0,address:p,title:"Wallet",isLoading:!1}),/*#__PURE__*/e(NC,{style:{marginTop:24},children:[/*#__PURE__*/t(Hs,{onClick:y,children:"Not now"}),/*#__PURE__*/t(Bs,{onClick:async()=>{try{await u(),l(!0)}catch(e){h(e)}},children:"Accept"})]}),/*#__PURE__*/t(Xs,{})]})}};let NC=/*#__PURE__*/vn.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-bdb7bc51-0"})(["display:flex;gap:10px;"]),MC=/*#__PURE__*/vn(Py).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-bdb7bc51-1"})(["margin-top:1.5rem;"]);const PC={component:()=>{let{app:r,data:a}=qo(),{closePrivyModal:i}=Pt(),[s,l]=o(!1),[c,h]=o(),{onRevoke:p,onSuccess:u,onError:m}=a.delegatedActions.revoke,g=async()=>{s?u():m(c??new he("User declined revoking access to their delegated wallet.")),i({shouldCallAuthOnSuccess:!1})};return d((()=>{if(!s&&!c)return;let e=setTimeout(g,va);return()=>clearTimeout(e)}),[s,c]),/*#__PURE__*/e(n,s||c?{children:[/*#__PURE__*/t(al,{onClose:g}),/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(ic,{children:[c?/*#__PURE__*/t(tr,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(vr,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(mc,{height:20}),/*#__PURE__*/t(gh,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":"You've successfully revoked permissions."})]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]}:{children:[/*#__PURE__*/t(al,{closeable:!0,onClose:g}),/*#__PURE__*/t(Sr,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(id,{style:{marginTop:24},children:"Revoke offline access to wallet"}),/*#__PURE__*/e(od,{children:["By confirming, ",r.name," will no longer be able to use this wallet on your behalf when you are not online."]}),/*#__PURE__*/e(WC,{style:{marginTop:24},children:[/*#__PURE__*/t(Hs,{onClick:g,children:"Deny"}),/*#__PURE__*/t(Bs,{onClick:async()=>{try{await p(),l(!0)}catch(e){h(e)}},children:"Confirm"})]}),/*#__PURE__*/t(Xs,{})]})}};let WC=/*#__PURE__*/vn.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-993a839-0"})(["display:flex;gap:10px;"]),UC="#8a63d2";const OC={component:()=>{let{lastScreen:r,navigateBack:a,data:s,app:l}=qo(),{requestFarcasterSignerStatus:c,closePrivyModal:h}=Pt(),[p,u]=o(void 0),[m,f]=o(!1),[w,v]=o(!1),C=i([]),b=s?.farcasterSigner;d((()=>{let e=Date.now(),t=setInterval((async()=>{if(!b?.public_key)return clearInterval(t),void u({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===b.status&&(clearInterval(t),f(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),wa)));let n=await c(b?.public_key),r=Date.now()-e;"approved"===n.status?(clearInterval(t),f(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),wa))):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),C.current.forEach((e=>clearTimeout(e)))}}),[]);let k="pending_approval"===b?.status?b.signer_approval_url:void 0;/*#__PURE__*/return e(n,g||m?{children:[/*#__PURE__*/t(al,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(hc,{}),
|
|
26
|
-
/*#__PURE__*/t(n,y?{children:/*#__PURE__*/e(RC,{children:[/*#__PURE__*/t(kd,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Us,{success:w,fail:!!p}),/*#__PURE__*/t($u,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t(id,{children:p?p.message:"Add a signer to Farcaster"}),/*#__PURE__*/t(od,{children:p?p.detail:"This will allow "+l.name+" to add casts, likes, follows, and more on your behalf."})]}),k&&/*#__PURE__*/t(Bs,{onClick:e=>{e.preventDefault(),window.location.href=k},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(LC,{children:[/*#__PURE__*/t(kd,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Us,{success:w,fail:!!p}),/*#__PURE__*/t($u,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t(id,{children:p?p.message:"Requesting signer from Farcaster"}),/*#__PURE__*/t(od,{children:p?p.detail:"This should only take a moment"}),/*#__PURE__*/t(ac,{children:k&&g&&/*#__PURE__*/t(Ju,{text:"Take me to Warpcast",url:k,color:UC})})]})]})}),/*#__PURE__*/t(el,{})]}:{children:[/*#__PURE__*/t(al,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(LC,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(id,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e(od,{children:["This will allow ",l.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/t(oc,{children:"pending_approval"===b?.status?/*#__PURE__*/t(sm,{url:b.signer_approval_url,size:275,squareLogoElement:$u}):/*#__PURE__*/t(Os,{})}),/*#__PURE__*/e(ac,{children:[/*#__PURE__*/t(od,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===b?.status&&/*#__PURE__*/t(Yu,{text:b.signer_approval_url,itemName:"link",color:UC})]})]})}),/*#__PURE__*/t(el,{})]})}};let LC=/*#__PURE__*/vn.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;"]),RC=/*#__PURE__*/vn.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e8f76e5-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const FC={component:()=>{let{closePrivyModal:r}=Pt();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(DC,{children:/*#__PURE__*/t(nr,{style:{width:32,height:32}})}),/*#__PURE__*/t(mh,{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(rc,{children:/*#__PURE__*/t(Bs,{onClick:()=>r(),children:"Close"})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}};let DC=/*#__PURE__*/vn.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 BC={component:()=>{let{app:r}=qo();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(gh,{title:"Connect your email",description:`Add your email to your ${r?.name} account`,icon:/*#__PURE__*/t(Gn,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(rc,{children:/*#__PURE__*/t(ry,{stacked:!0})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}},zC={component:()=>{let{app:r,currentScreen:a,data:i,navigate:o,setModalData:s}=qo(),{initLoginWithSms:l}=Pt();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(gh,{title:"Connect your phone",description:`Add your number to your ${r?.name} account`,icon:/*#__PURE__*/t(In,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/t(rc,{children:/*#__PURE__*/t(Mm,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await l({phoneNumber:e,withPrivyUi:!0}),o(Vg)}catch(e){s({errorModalData:{error:e,previousScreen:i?.errorModalData?.previousScreen||a||zC}}),o(su)}},hideRecent:!0})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}},$C={component:()=>{let{app:r,data:a}=qo(),i=a?.externalConnectWallet?.suggestedAddress,o=i?/*#__PURE__*/e("span",{children:["Link the wallet with address ",/*#__PURE__*/t(Zp,{showCopyIcon:!1,address:i})," ",r?.name?`to ${r.name}.`:"."]}):`Link a wallet to your ${r?.name} account`,{connectors:s}=Pt(),l=Sg({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(al,{},"header"),l.length>0&&/*#__PURE__*/t(mh,{title:"Link your wallet",description:o}),/*#__PURE__*/t(As,{children:/*#__PURE__*/t(Eg,{wallets:l})}),/*#__PURE__*/t(Xs,{})]})}},jC=({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"})]}),VC={component:()=>{let{closePrivyModal:r}=Pt(),{navigate:a}=qo();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(jC,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/t(mh,{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(rc,{children:[/*#__PURE__*/t(Bs,{onClick:()=>a(dy),children:"Try again"}),/*#__PURE__*/t(Hs,{onClick:()=>r(),children:"Cancel"})]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}};function HC(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenroll:o,enrollInMfa:s}=l(rn);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 qC=n=>/*#__PURE__*/e(KC,{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 KC=/*#__PURE__*/vn.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 ZC=({showIntro:r,userMfaMethods:a,appMfaMethods:i,userHasAuthSms:o,isTotpLoading:s,isPasskeyLoading:l,error:c,onClose:d,onBackToIntro:h,handleSelectMethod:p,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(al,{backFn:r?h:void 0,onClose:d},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(_n,{})}),/*#__PURE__*/t(id,{children:"Choose a verification method"}),a.length>0?/*#__PURE__*/t(od,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/t(od,{children:"How would you like to verify your identity? You can change this later."}),c&&/*#__PURE__*/t(bd,{style:{marginTop:"1.25rem"},children:c.message}),/*#__PURE__*/e(pd,{children:[(g.totp||m.totp)&&/*#__PURE__*/e(ud,{children:[/*#__PURE__*/t(Ss,{style:{justifyContent:"center"},disabled:m.totp||s,onClick:()=>p("totp"),children:s?/*#__PURE__*/t(Os,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(fd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(xn,{}),"Authenticator app"]}),m.totp?/*#__PURE__*/t(YC,{color:"green",children:"Enabled"}):/*#__PURE__*/t(yd,{children:"Recommended"})]})}),m.totp&&/*#__PURE__*/t(md,{style:{position:"absolute",right:0},onClick:()=>u("totp"),children:/*#__PURE__*/t(Ur,{})})]},"totp"),(g.sms||m.sms)&&/*#__PURE__*/e(ud,{children:[/*#__PURE__*/t(Ss,{disabled:m.sms||o,onClick:()=>p("sms"),children:/*#__PURE__*/e(fd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(In,{}),"SMS"]}),m.sms&&/*#__PURE__*/t(YC,{color:"green",children:"Enabled"}),o&&/*#__PURE__*/t(yd,{children:"Disabled"})]})}),m.sms&&/*#__PURE__*/t(md,{style:{position:"absolute",right:0},onClick:()=>u("sms"),children:/*#__PURE__*/t(Ur,{})})]},"sms"),(g.passkey||m.passkey)&&/*#__PURE__*/e(ud,{children:[/*#__PURE__*/t(Ss,{style:{justifyContent:"center"},onClick:()=>p("passkey"),disabled:m.passkey||l,children:l?/*#__PURE__*/t(Os,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(fd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(An,{}),"Passkey"]}),m.passkey?/*#__PURE__*/t(YC,{color:"green",children:"Enabled"}):/*#__PURE__*/t(yd,{isAccent:!0,children:/*#__PURE__*/t(lr,{})})]})}),m.passkey&&/*#__PURE__*/t(md,{style:{position:"absolute",right:0},onClick:()=>u("passkey"),children:/*#__PURE__*/t(Ur,{})})]},"passkey")]}),/*#__PURE__*/t(el,{})]})};let YC=/*#__PURE__*/vn(Bu).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const GC=({appName:e,onComplete:n,onClose:r,onReset:a})=>{let{user:i}=nn(),{data:l}=qo(),{initLinkWithPasskey:c,linkWithPasskey:d}=Pt(),{initEnrollmentWithPasskey:h,submitEnrollmentWithPasskey:p}=HC(),[u,m]=o(!1),[g,y]=o(!1),[f,w]=o(!1),[v,C]=o(null),b=s((()=>i?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[i]),k=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},T=async e=>{m(!0);try{await h(),await p({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),w(!0)}catch(e){C(e)}finally{m(!1)}},x=async()=>{y(!0),C(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await T(t)}catch(e){C(e)}finally{y(!1)}};return 0===b.length||g?/*#__PURE__*/t(JC,{onReset:a,onClose:r,onClick:x,isCreating:g}):f?/*#__PURE__*/t(XC,{appName:e,onClick:k,onClose:k}):v?/*#__PURE__*/t(lu,{error:v,backFn:()=>C(null),onClick:()=>C(null)}):/*#__PURE__*/t(QC,{passkeys:b,isSubmitting:u,isCreating:g,onReset:a,onClose:r,onSubmitEnrollment:()=>T(b.map((e=>e.credentialId))),onAddPasskey:x})};let JC=({onReset:r,onClose:a,onClick:i,isCreating:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{backFn:r,onClose:a},"header"),/*#__PURE__*/t(ad,{children:/*#__PURE__*/e(Df,{children:[/*#__PURE__*/t(Td,{}),/*#__PURE__*/t(km,{})]})}),/*#__PURE__*/t(id,{children:"Set up passkey verification"}),/*#__PURE__*/e(ld,{children:[/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(_n,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(Nr,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(Or,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/t(Bs,{style:{marginTop:"2.25rem"},onClick:i,loading:o,children:"Add a new passkey"}),/*#__PURE__*/t(el,{})]}),QC=({onReset:r,onClose:a,onAddPasskey:i,onSubmitEnrollment:s,passkeys:l,isSubmitting:c,isCreating:d})=>{let[h,p]=o(!1),u=h?l.length:l.length>3?2:3;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{backFn:h?()=>p(!1):r,onClose:a},"header"),!h&&/*#__PURE__*/t(ad,{children:/*#__PURE__*/e(Df,{children:[/*#__PURE__*/t(Td,{}),/*#__PURE__*/t(km,{})]})}),/*#__PURE__*/t(id,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e(ld,{children:[l.slice(0,u).map((n=>/*#__PURE__*/e(eb,{children:[/*#__PURE__*/t(tb,{children:rb(n)}),/*#__PURE__*/e(nb,{children:["Last used: ",n.latestVerifiedAt?.toLocaleString()]})]},n.credentialId))),!h&&l.length>3&&/*#__PURE__*/t(ab,{onClick:()=>p(!0),children:"View All"})]}),/*#__PURE__*/t(Bs,{style:{marginTop:"1.5rem"},onClick:s,loading:c,children:"Enable passkeys"}),l.length<5&&/*#__PURE__*/t(ab,{style:{marginTop:"0.5rem"},onClick:i,disabled:d,children:d?/*#__PURE__*/t(Os,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/t(el,{})]})},XC=({appName:r,onClick:a,onClose:i})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{onClose:i},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(vr,{})}),/*#__PURE__*/t(id,{children:"Passkey verification added"}),/*#__PURE__*/e(od,{children:["From now on, you'll use the passkey whenever you use your ",r," wallet."]}),/*#__PURE__*/t(hd,{children:/*#__PURE__*/t(Bs,{onClick:a,children:"Done"})}),/*#__PURE__*/t(el,{})]}),eb=/*#__PURE__*/vn.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%;}"]),tb=/*#__PURE__*/vn.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);"]),nb=/*#__PURE__*/vn.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);"]),rb=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 ab=/*#__PURE__*/vn.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;}}"]),ib=({appName:r,onComplete:a,onReset:i,onClose:s})=>{let[l,c]=o(""),[d,h]=o(!1),[p,u]=o(null),[m,g]=o("enroll"),{initEnrollmentWithSms:y,submitEnrollmentWithSms:f}=HC(),{app:w,data:v}=qo();function C(){v?.mfaEnrollmentFlow?.onSuccess(),a()}return p?/*#__PURE__*/t(lu,{error:p,backFn:()=>u(null),onClick:()=>u(null)}):/*#__PURE__*/e(n,"enroll"===m?{children:[/*#__PURE__*/t(al,{backFn:i,onClose:s},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(In,{})}),/*#__PURE__*/t(id,{children:"Set up SMS verification"}),/*#__PURE__*/e(od,{children:["We'll text a verification code to this mobile device whenever you use your ",r," ","wallet."]}),/*#__PURE__*/e(sd,{children:[/*#__PURE__*/t(Mm,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await y({phoneNumber:e}),c(e),g("verify")}catch(e){u(e)}},hideRecent:!0}),/*#__PURE__*/e(wd,{children:["By providing your mobile number, you agree to receive text messages from ",w?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/t(el,{})]}:d?{children:[/*#__PURE__*/t(al,{onClose:C},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(vr,{})}),/*#__PURE__*/t(id,{children:"SMS verification added"}),/*#__PURE__*/e(od,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",r," wallet."]}),/*#__PURE__*/t(hd,{children:/*#__PURE__*/t(Bs,{onClick:C,children:"Done"})}),/*#__PURE__*/t(el,{})]}:{children:[/*#__PURE__*/t(al,{backFn:function(){"verify"===m?g("enroll"):i()},onClose:s},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(In,{})}),/*#__PURE__*/t(id,{children:"Enter enrollment code"}),/*#__PURE__*/e(sd,{children:[/*#__PURE__*/t(yl,{onChange:async function(e){try{if(!e)return;await f({phoneNumber:l,mfaCode:e}),h(!0)}catch(e){if(td(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Xc(e))throw Error("The code you entered is not valid");if(Qc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw nd(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e(od,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/t("strong",{children:de(l)})]})]}),/*#__PURE__*/t(el,{})]})},ob=({size:e,authUrl:n})=>/*#__PURE__*/t(sm,{url:n,squareLogoElement:Lr,size:e,fgColor:"#1F1F1F"}),sb=({onComplete:r,onClose:a,onReset:i,totpInfo:s})=>{let[l,c]=o("enroll"),[d,h]=o(!1),{submitEnrollmentWithTotp:p}=HC(),{data:u}=qo();function m(){u?.mfaEnrollmentFlow?.onSuccess(),r()}/*#__PURE__*/return e(n,"enroll"===l?{children:[/*#__PURE__*/t(al,{backFn:i,onClose:a},"header"),/*#__PURE__*/t(id,{children:"Scan QR code"}),/*#__PURE__*/t(od,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/t(oc,{children:/*#__PURE__*/t(ob,{authUrl:s.authUrl,size:200})}),/*#__PURE__*/e(hd,{children:[/*#__PURE__*/t(ac,{children:/*#__PURE__*/t(Yu,{itemName:"setup key",text:s.secret})}),/*#__PURE__*/t(Bs,{onClick:function(){c("verify")},children:"Continue"})]}),/*#__PURE__*/t(el,{})]}:d?{children:[/*#__PURE__*/t(al,{onClose:m},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(vr,{})}),/*#__PURE__*/t(id,{children:"Authenticator app verification added"}),/*#__PURE__*/e(od,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",s.appName," wallet."]}),/*#__PURE__*/t(hd,{children:/*#__PURE__*/t(Bs,{onClick:m,children:"Done"})}),/*#__PURE__*/t(el,{})]}:{children:[/*#__PURE__*/t(al,{backFn:function(){"verify"===l?c("enroll"):i()},onClose:a},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(xn,{})}),/*#__PURE__*/t(id,{children:"Enter enrollment code"}),/*#__PURE__*/t(sd,{children:/*#__PURE__*/t(yl,{onChange:async function(e){try{if(!e)return;await p({mfaCode:e}),h(!0)}catch(e){if(td(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Xc(e))throw Error("The code you entered is not valid");if(Qc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw nd(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e(od,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),/*#__PURE__*/t(el,{})]})},lb={component:()=>{let{user:r,enrollInMfa:a,ready:i}=nn(),[s,l]=o(null),{unenrollWithSms:c,unenrollWithTotp:h,unenrollWithPasskey:p}=HC(),{app:u,data:m,onUserCloseViaDialogOrKeybindRef:g}=qo(),{closePrivyModal:y}=Pt(),{promptMfa:f}=rd(),{initEnrollmentWithTotp:w}=HC(),[v,C]=o(!1),[b,k]=o(null),[T,x]=o(null),A=()=>{y({shouldCallAuthOnSuccess:!0}),a(!1),setTimeout((()=>{l(null),k(null)}),500)},{initEnrollmentWithPasskey:I,submitEnrollmentWithPasskey:_}=HC(),[E,S]=o(!1),[N,M]=o(null);g.current=A;let P=r?.mfaMethods.includes("sms"),W=!!r?.phone,U=r?.mfaMethods.includes("totp"),O=r?.mfaMethods.includes("passkey"),L=P||U||O,R=r?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function F(){l(null),k(null)}if(d((()=>{L&&C(!0)}),[L]),!i||!r||!u/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(al,{onClose:A},"header"),/*#__PURE__*/t(ad,{children:/*#__PURE__*/t(qC,{})}),/*#__PURE__*/t(sd,{children:/*#__PURE__*/t(Os,{})}),/*#__PURE__*/t(el,{})]});if("sms"===s)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{backFn:F,onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Sn,{})}),/*#__PURE__*/t(id,{children:"Remove SMS verification?"}),/*#__PURE__*/e(od,{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(hd,{children:/*#__PURE__*/t(Bs,{warn:!0,onClick:async function(){l(null);try{await c()}catch(e){l(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/t(el,{})]});if("totp"===s)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{backFn:F,onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Sn,{})}),/*#__PURE__*/t(id,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e(od,{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(hd,{children:/*#__PURE__*/t(Bs,{warn:!0,onClick:async function(){l(null);try{await h()}catch(e){l(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/t(el,{})]});if("passkey"===s){let r=m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{backFn:F,onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Sn,{})}),/*#__PURE__*/t(id,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/t(od,{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(hd,{children:/*#__PURE__*/t(Bs,{warn:!0,onClick:async function(){l(null);try{await p({removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){l(null)}},children:"Yes, remove"})}),/*#__PURE__*/t(el,{})]})}if(0===m.mfaEnrollmentFlow.mfaMethods.length&&!L)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(_n,{})}),/*#__PURE__*/t(id,{children:"Add more security"}),/*#__PURE__*/e(od,{children:[u?.name," does not have any verification methods enabled."]}),/*#__PURE__*/t(hd,{children:/*#__PURE__*/t(Bs,{onClick:A,children:"Close"})}),/*#__PURE__*/t(el,{})]});let D=!L&&!v;return D?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(_n,{})}),/*#__PURE__*/t(id,{children:"Transaction Protection"}),/*#__PURE__*/t(od,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e(ld,{children:[/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(Pr,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(Wr,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e(hd,{children:[/*#__PURE__*/t(Bs,{onClick:()=>C(!0),children:"Continue"}),/*#__PURE__*/t(Hs,{onClick:A,children:"Not now"})]}),/*#__PURE__*/t(el,{})]}):"sms"===b?/*#__PURE__*/t(ib,{appName:u?.name||"Privy",onComplete:A,onReset:F,onClose:A}):"totp"===b&&T?/*#__PURE__*/t(sb,{onComplete:A,onClose:A,onReset:F,totpInfo:{...T,appName:u?.name||"Privy"}}):"passkey"===b?/*#__PURE__*/t(GC,{appName:u?.name||"Privy",onComplete:A,onReset:F,onClose:A}):/*#__PURE__*/t(ZC,{showIntro:D,userMfaMethods:r.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:W,onBackToIntro:function(){C(!1)},handleSelectMethod:async function(e){return await f().catch(M),"totp"===e?(k(e),x(null),void w().then((e=>{x(e)})).catch((()=>{x(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"===b&&!T,isPasskeyLoading:E,error:N,onClose:A,setRemovingMfaMethod:async e=>{await f().catch(M),l(e)}})}},cb={component:()=>{let{authenticated:r,logout:a,ready:i,user:s}=nn(),{app:l,setModalData:c,navigate:h,resetNavigation:p}=qo(),{getAuthMeta:u,initLoginWithOAuth:m,loginWithOAuth:g,updateWallets:y,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v}=Pt(),[C,b]=o(!1),[k,T]=o(void 0),x=u()?.provider||"google",{name:A,component:I}=li(x);d((()=>{g(x).then((()=>{b(!0),f(!0)})).catch((e=>{if(f(!1),e?.privyErrorCode===Te.ALLOWLIST_REJECTED)return T(void 0),p(),void h(lm);if(e?.privyErrorCode===Te.USER_LIMIT_REACHED)return console.error(new _t(e).toString()),T(void 0),p(),void h(pm);if(e?.privyErrorCode===Te.USER_DOES_NOT_EXIST)return T(void 0),p(),void h(Vp);if(e?.privyErrorCode===Te.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return T(void 0),p(),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 h(Tu);let{retryable:t,detail:n}=function(e,t){let n={detail:"",retryable:!1},r=Ga(t);if(e?.privyErrorCode===Te.LINKED_TO_ANOTHER_USER&&(n.detail="This account has already been linked to another user."),e?.privyErrorCode===Te.INVALID_CREDENTIALS&&(n.retryable=!0,n.detail="Something went wrong. Try again."),e.privyErrorCode===Te.OAUTH_USER_DENIED&&(n.detail=`Retry and check ${r} to finish connecting your account.`,n.retryable=!0),e?.privyErrorCode===Te.TOO_MANY_REQUESTS&&(n.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===Te.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=li(t).name;n.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===Te.OAUTH_ACCOUNT_SUSPENDED){let e=li(t).name;n.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===Te.CANNOT_LINK_MORE_OF_TYPE&&(n.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===Te.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(n.detail="Something went wrong. Please try again."),n}(e,x);T({retryable:t,detail:n,message:"Authentication failed"})})).finally((()=>{di()}))}),[A,x]),d((()=>{if(i&&r&&C&&s){if(l?.legal.requireUsersAcceptTerms&&!s.hasAcceptedTerms){let e=setTimeout((()=>{h(Wu)}),wa);return()=>clearTimeout(e)}if($p(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:x,screen:"OAuthStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(Mu)}),wa);return()=>clearTimeout(e)}{let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),wa);return y(),()=>clearTimeout(e)}}}),[i,r,C,s]);let _=C?`Successfully connected with ${A}`:k?k.message:`Verifying connection to ${A}`,E="";return E=C?"You’re good to go!":k?k.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{}),/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(db,{children:[/*#__PURE__*/t(kd,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Us,{success:C,fail:!!k}),/*#__PURE__*/t(I,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t("h3",{children:_}),/*#__PURE__*/t("p",{children:E})]}),k&&k?.retryable?/*#__PURE__*/t(Ks,{onClick:()=>{di(),m(x),T(void 0)},disabled:!C&&!k?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(el,{})]})}};let db=/*#__PURE__*/vn.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 hb=/*#__PURE__*/u(((r,a)=>{let[i,s]=o(""),[l,c]=o(""),[d,h]=o(!1),{authenticated:p,user:u}=nn(),{initUpdateEmail:m}=Pt(),{navigate:g,setModalData:y,currentScreen:f}=qo(),{enabled:w,token:v}=ki(),C=$o(),b=Yr(i)&&(C.disablePlusEmails&&i.includes("+")?(l||c("Please enter a valid email address without a '+'."),!1):(l&&c(""),!0)),k=d||!b,T=()=>{!w||v||p?(async e=>{if(!u?.email)throw Error("User is required to have an email address to update it.");h(!0);try{await m(u.email.address,i,e),g(Vg)}catch(e){y({errorModalData:{error:e,previousScreen:f||dy}})}h(!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:Vg,onErrorNavigateTo:su}}),g(Hu))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(pb,{children:[l&&/*#__PURE__*/t(Qg,{style:{marginTop:"0.25rem",textAlign:"left"},children:l}),/*#__PURE__*/e(ub,{$error:!!l,children:[/*#__PURE__*/t(Gn,{}),/*#__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&&T()},value:i,autoComplete:"email"}),r.stacked?null:/*#__PURE__*/t(Zs,{isSubmitting:d,onClick:T,disabled:k,children:"Submit"})]})]}),r.stacked?/*#__PURE__*/t(Bs,{loadingText:null,loading:d,disabled:k,onClick:T,children:"Submit"}):null]})}));let pb=ny,ub=ey;const mb={component:()=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(gh,{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(Gn,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(rc,{children:/*#__PURE__*/t(hb,{stacked:!0})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})},gb={component:()=>{let{currentScreen:r,data:a,navigate:i,setModalData:o}=qo(),{user:s}=nn(),{initUpdatePhone:l}=Pt();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(gh,{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(In,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(rc,{children:/*#__PURE__*/t(Mm,{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(Vg)}catch(e){o({errorModalData:{error:e,previousScreen:a?.errorModalData?.previousScreen||r||zC}}),i(su)}},hideRecent:!0})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}};function yb({subscribe:e,getExternalJwt:t,enabled:n=!0,onAuthenticated:r,onUnauthenticated:a,onError:s}){let{client:l,onCustomAuthAuthenticated:c}=Pt(),{logout:h,authenticated:p,ready:u}=Ky();if(!l)throw new he("`useSyncJwtBasedAuthState` must be used within a `PrivyProvider`");let[m,g]=o({status:"initial"}),y=i(),f=i(!1),w=i(t);d((()=>{w.current=t}),[t]);let v=i(r);d((()=>{v.current=r}),[r]);let C=i(a);d((()=>{C.current=a}),[a]);let b=i(s);return d((()=>{b.current=s}),[s]),d((()=>{if(!n||!u)return;let t=async()=>{if(!f.current){f.current=!0;try{g({status:"loading"});let e=await w.current();if(void 0!==y.current&&y.current===e)return void g({status:"done"});if(!e)return p&&(await h(),C.current?.()),y.current=e,void g({status:"done"});l.startAuthFlow(new ts(e));let{user:t,isNewUser:n=!1}=await l.authenticate();if(!t)throw new he("Failed to sync with custom auth provider");v.current?.({user:t,isNewUser:n}),c(t,n),y.current=e,g({status:"done"})}catch(e){if(console.warn(e),await h().catch((()=>{})),C.current?.(),e instanceof Ke&&e.privyErrorCode===Te.LINKED_TO_ANOTHER_USER)return g({status:"initial"}),void setTimeout((()=>{t()}),0);b.current?.(e),g({status:"error",error:e})}finally{f.current=!1}}};return t(),e(t)}),[e,l,c,p,h,n,u]),n?{state:m}:{state:{status:"not-enabled"}}}let fb=Hn((()=>({jwtAuthFlowState:{status:"not-enabled"}})));const wb=()=>fb((e=>e.jwtAuthFlowState));function vb({customAuth:e}){let{jwtAuthFlowState:t}=function({customAuth:e}){let t=bs(),n=i(),r=h((e=>(n.current=e,()=>{n.current=void 0})),[]),a=e?.getCustomAccessToken??(()=>Promise.resolve(void 0)),{state:o}=yb({enabled:!0===e?.enabled,subscribe:r,getExternalJwt:a,onAuthenticated:({user:e,isNewUser:n})=>{t("login","onComplete",{user:e,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),t("customAuth","onAuthenticated",{user:e})},onUnauthenticated:()=>{t("customAuth","onUnauthenticated")},onError:e=>{t("login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR)}});return d((()=>{(async()=>{e&&!e.isLoading&&n.current?.()})()}),[e?.enabled,e?.getCustomAccessToken,e?.isLoading]),{jwtAuthFlowState:o}}({customAuth:e});return d((()=>{fb.setState({jwtAuthFlowState:t})}),[t]),null}const Cb=/*#__PURE__*/c(!1);let bb,kb,Tb,xb,Ab,Ib,_b;function Eb(){return bb?bb.getCustomerAccessToken():Promise.resolve(jr.get(ka)||null)}async function Sb(){return bb?bb.getAccessToken():Promise.resolve(jr.get(Aa)||jr.get(ka)||null)}const Nb=(e,t)=>kb(e,t),Mb=(e,t)=>Tb(e,t),Pb=(e,t)=>xb(e,t),Wb=(e,t)=>Ab(e,t),Ub=e=>Ib(e),Ob=e=>_b(e),Lb=({config:e,...n})=>{var r;if((()=>{if(l(Cb))throw new he("Multiple PrivyProvider instances found","Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree.")})(),"undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new he("Embedded wallet is only available over HTTPS");if("string"!=typeof(r=n.appId)||25!==r.length)throw new he("Cannot initialize the Privy provider with an invalid Privy app ID");bb||(bb=new ps({appId:n.appId,appClientId:n.clientId,apiUrl:n.apiUrl}));let a=Object.assign({},e),i=s((()=>new T({appId:n.appId,clientId:n.clientId,storage:jr,baseUrl:n.apiUrl,sdkVersion:"react-auth:2.15.0"})),[]);/*#__PURE__*/
|
|
27
|
-
return t(zo,{client:i,legacyClient:bb,clientConfig:a,children:/*#__PURE__*/t(Km,{children:/*#__PURE__*/t(Rb,{...n,client:bb,privy:i})})})};let Rb=n=>{let a=n.client,l=n.privy,c=Ym();nh();let[p,u]=o(!1),[m,g]=o(!1),[y,f]=o(!1),[T,x]=o(null),[A,_]=o([]),[E,S]=o([]),[N,M]=o(!1),[P,W]=o(null),[U,O]=o(!1),[L,R]=o({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:Nt}),[F,D]=o({status:"initial"}),[B,z]=o({status:"initial"}),[$,j]=o({status:"initial"}),[V,H]=o({status:"initial"}),[q,K]=o({status:"initial"}),[Z,Y]=o({status:"initial"}),[G,J]=o(null),Q=$o(),X=jo(),[ee,te]=o({}),[ne,re]=o(null),ae=i(null),[ie,oe]=o(!1),[se,le]=o(!1),ce=i(null),de=i(null),pe=i(ys),[me,ge]=o(!1);a.onStoreCustomerAccessToken=e=>{e&&Cs(pe,"accessToken","onAccessTokenGranted",{accessToken:e})},a.onDeleteCustomerAccessToken=()=>{x(null),f(!1),Cs(pe,"accessToken","onAccessTokenRemoved")};let ye=i(null),we=i(null),ve=i(!1),Ce=({showWalletUIs:e})=>ve.current?ve.current:void 0!==e?!e:!Q.embeddedWallets.showWalletUIs,be=e=>{W(e),setTimeout((()=>{u(!0)}),15)};d((()=>{if(!T)return void a.connectors?.removeEmbeddedWalletConnectors();let e=on(T),t=pn(T),r=cn(T);e&&t.length||a.connectors?.removeEmbeddedWalletConnectors(),r||a.connectors?.removeImportedWalletConnector(),a.connectors?G?(e&&a.connectors.addEmbeddedWalletConnectors({walletProxy:G,user:T,embeddedWallets:t,defaultChain:Q.defaultChain,appId:n.appId,privyClient:l}),r&&a.connectors.addImportedWalletConnector(G,r.address,Q.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")}),[G,T]),d((()=>{G&&ae.current?.(G)}),[G]);let ke=h(((e,t)=>{x(e),M(t),f(!0),le(!0)}),[]);d((()=>{se&&G&&T&&(async()=>{let e=Fp(T,Q.embeddedWallets.ethereum.createOnLogin),t=Bp(T,Q.embeddedWallets.solana.createOnLogin),n=await Sb();if(n){if(e&&t){let e=await G.create({accessToken:n});return await G.createSolana({accessToken:n,ethereumAddress:e?.address}),void le(!1)}if(t)return await G.createSolana({accessToken:n,ethereumAddress:on(T)?.address}),await Ve.refreshSessionAndUser(),void le(!1);if(e)return await G.create({accessToken:n}),void le(!1)}})().catch(console.error)}),[se&&G&&T]),d((()=>{if(Q.externalWallets.solana.connectors)return Q.externalWallets.solana.connectors.onMount(),()=>Q.externalWallets.solana.connectors?.onUnmount()}),[Q.externalWallets.solana.connectors]),d((()=>{!m&&X&&async function(){let e,t=xe(),n=Ie(),i=r();a.initializeConnectorManager({walletConnectCloudProjectId:Q.walletConnectCloudProjectId,rpcConfig:Q.rpcConfig,chains:Q.chains,defaultChain:Q.defaultChain,store:i,walletList:Q.appearance.walletList,shouldEnforceDefaultChainOnConnect:Q.shouldEnforceDefaultChainOnConnect,externalWalletConfig:Q.externalWallets,appName:Q.name??"Privy",walletChainType:Q.appearance.walletChainType,appKit:Q.externalWallets.walletConnect.appKit}),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?ge(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:n,expected:t}),ge(!0)}),1500)})),a.connectors?.initialize().then((()=>{Me()}));let o=await a.getAuthenticatedUser(),s=!!o;Q.legal.requireUsersAcceptTerms&&o&&!o.hasAcceptedTerms?(await a.logout(),Ve.setReadyToTrue(!0),Cs(pe,"logout","onSuccess")):(Q.customAuth?.enabled||(f(!!o),o&&Cs(pe,"login","onComplete",{user:o,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),x(o)),t?we.current=s?"link":"login":n&&!s?(we.current="login",te({telegramAuthModalData:{seamlessAuth:!0}}),be(Dm)):Ve.setReadyToTrue(!!o))}()}),[a,ne,m,X]),d((()=>{if(m){if(!T||!T.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType)))return void oe(!!G);if([...A].some((e=>"privy"===e.walletClientType)))return void oe(!0);oe(!!G)}}),[m,T,A,G]),d((()=>{a.connectors?.setWalletList(Q.appearance.walletList)}),[Q.appearance.walletList.join()]);let xe=()=>{let e=ci();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(ah).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(a.startAuthFlow(new Ya(e)),be(cb),!0))},Ie=()=>{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())}())?(Ii(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=Ai(e.replace("#tgWebAppData=","")),{user:n,auth_date:r,hash:a}=t;return n&&r&&a?t:void 0}())?(Ii(),{flowType:"web-app",authData:e}):void 0}();if(!e||!Q.loginMethods.telegram||!Q.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new Ti;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},_e=async(e,t,n,r)=>{if("solana_adapter"!==e)Ee(await(a.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,n,r);else{let e=a.connectors?.findSolanaWalletConnector(t);if(!e)return;Ee(e,t,n,r)}};async function Ee(e,t,n,r){if(!e)return R({status:"disconnected",connectedWallet:null,connectError:new fe("Unable to connect to wallet."),connector:null,connectRetry:Nt}),r?.(null,n);R({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:Nt}),e instanceof Zo&&t&&await e.resetConnection(t),R({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Ee(e,t,n,r)});try{let t=await e.connect({showPrompt:!0});if((!t||Fi(t))&&Q.shouldEnforceDefaultChainOnConnect&&!Q.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){R((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:Nt})));try{await(t?.switchChain(Q.defaultChain.id)),t&&(t.chainId=aa(C(Q.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${Q.defaultChain.id}`)}}return R((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:Nt}))),t&&Cs(pe,"connectWallet","onSuccess",{wallet:t}),r?.(t,n)}catch(e){return e instanceof Le?(console.warn(e.cause?e.cause:e.message),Cs(pe,"connectWallet","onError",e.privyErrorCode||Te.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),Cs(pe,"connectWallet","onError",Te.UNKNOWN_CONNECT_WALLET_ERROR)),R((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),r?.(null,n)}}let Se=async(e,t,n)=>{if(null===e||!Fi(e))return;let r=new ui(a,e,t,n);a.startAuthFlow(r)},Ne=async(e,t,n,r="plain")=>{let i=c(Gm);if("transaction"===r&&!i)throw new he("useSolanaLedger plugin hook must be mounted");if(null===e||!fo(e))return;let o=new yi(e,a,t,n,r,i?{deserializeTransactionFromB64String:i.deserializeTransactionFromB64String,prepareSiwsTransactionWithMemo:i.prepareSiwsTransactionWithMemo}:void 0);a.startAuthFlow(o)},Me=()=>{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=po({connectorType:t,walletClientType:n});if(!i||!i.isInstalled)return be(VC);if(!a.connectors)throw new he("Connector not initialized");be(r?dg:og);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),_e(t,n,void 0,r?void 0:"solana_adapter"===t?Ne:Se)};d((()=>{m&&y&&null===T&&a.getAuthenticatedUser().then(x)}),[m,y,T,a]);let Pe=e=>{if(!y)throw Cs(pe,"linkAccount","onError",Te.MUST_BE_AUTHENTICATED,{linkMethod:e}),new he("User must be authenticated before linking an account.")},We=e=>{if(!y||!T)return!1;if("privy"===e.walletClientType)return!0;for(let t of T.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 he("Connector not initialized");t="ethereum"===e.type?a.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:a.connectors.findSolanaWalletConnector(e.walletClientType)||null,R((n=>({...n,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:Nt}))),Q.captchaEnabled&&!y?(te({captchaModalData:{callback:t=>Fi(e)?Se(e,t):Ne(e,t),userIntentRequired:!1,onSuccessNavigateTo:og,onErrorNavigateTo:su}}),be(Hu)):(Fi(e)?await Se(e):await Ne(e),be(og))},Oe=()=>{_((e=>{let t=a.connectors?.wallets.filter(Fi).map((e=>({...e,linked:We(e),loginOrLink:async()=>{if(!await e.isConnected())throw new he("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new he("Cannot link or login with embedded wallet");Ue(e)},fund:async t=>{await Ve.fundWallet(e.address,t)},unlink:async()=>{if(!y)throw new he("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new he("Cannot unlink an embedded wallet");x(await a.unlinkEthereumWallet(e.address))}})))||[];return Di(e,t)?e:t})),S((e=>{let t=(a.connectors?.wallets??[]).filter(fo).map((e=>({...e,linked:We(e),loginOrLink:async()=>{if(!await e.isConnected())throw new he("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new he("Cannot link or login with embedded wallet");Ue(e)},fund:async()=>{throw new he("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!y)throw new he("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new he("Cannot unlink an embedded wallet");x(await a.unlinkSolanaWallet(e.address))}})));return Di(e,t)?e:t}))};d((()=>{Oe()}),[T?.linkedAccounts,y,m]),d((()=>{if(m){if(!a.connectors)throw new he("Connector not initialized");Oe(),a.connectors.on("walletsUpdated",Oe)}}),[m]),d((()=>{[...Q.loginMethodsAndOrder?.primary??[],...Q.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>a.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!a]);let Re=({transaction:e,uiOptions:t,fundWalletConfig:r,address:i,signOnly:o})=>new Promise((async(s,c)=>{let{requesterAppId:d}=t||{},h=o?"signTransaction":"sendTransaction",p=i?sn(T,i):on(T);if(!p&&i){let t=un(A,i);if(t)try{let n=await t.getEthereumProvider(),r={...e,from:i,chainId:e.chainId||Number(t.chainId.replace("eip155:","")),value:void 0!==e.value?C(e.value):void 0},a=await n.request({method:"sendTransaction"===h?"eth_sendTransaction":"eth_signTransaction",params:[r]});return Cs(pe,h,"onSuccess",{hash:a}),void s({hash:a})}catch(e){return Cs(pe,h,"onError",Te.TRANSACTION_FAILURE),void c(e??new Li("Unable to "+h+e))}}if(!p)return Cs(pe,h,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),void c(new he("No embedded or connected wallet found for address."));if(!y||!T)return Cs(pe,h,"onError",Te.MUST_BE_AUTHENTICATED),void c(Error("User must be authenticated before signing with a Privy wallet"));let u=p.address,m=p.walletIndex??0,{entropyId:g,entropyIdVerifier:f}=Ni(T,p),w=He.wallets.find((e=>"privy"===e.walletClientType&&v(e.address)===v(u)));if(!w)return Cs(pe,h,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have a Privy wallet before signing"));let b=await w.getEthereumProvider(),x=await b.request({method:"eth_chainId"}),_=e.chainId?Number(e.chainId):rh(x);(e=>{if(!Q.chains.map((e=>e.id)).includes(e))throw new fe(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,Te.UNSUPPORTED_CHAIN_ID)})(_);let E={...e,from:e.from??u,chainId:_},S=await Sb();if(!S||!G)return Cs(pe,h,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have valid access token and Privy wallet to send transaction"));let N=Kr(E.chainId,Q.chains,Q.rpcConfig,{appId:n.appId}),M=en(p),P=async()=>{try{let e;if(!await Ve.recoverEmbeddedWallet({address:u}))throw Cs(pe,h,"onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),c(Error("Unable to connect to wallet")),Error("Unable to connect to wallet");let t=o?E:await Hc(E,N,E.from);if(M){let n=e=>null==e?void 0:C(e),r=await I(l,(async({message:e})=>await G.signWithUserSigner({accessToken:S,requesterAppId:d,message:e})),{chain_type:"ethereum",method:"eth_signTransaction",params:{transaction:{from:t.from,to:t.to,nonce:n(t.nonce),chain_id:n(t.chainId),data:k(t.data)?t.data?t.data:C(Uint8Array.from(t.data)):void 0,value:n(t.value),type:t.type,gas_limit:n(t.gasLimit??t.gas),gas_price:n(t.gasPrice??t.gas),max_fee_per_gas:n(t.maxFeePerGas),max_priority_fee_per_gas:n(t.maxPriorityFeePerGas)}},wallet_id:p.id});if(!r.data||!("signed_transaction"in r.data))throw new Li("Unable to sign transaction");e=r.data.signed_transaction}else e=await th({accessToken:S,entropyId:g,entropyIdVerifier:f,transactingWalletIndex:m,walletProxy:G,transactionRequest:t,requesterAppId:d});if(o)return Cs(pe,"signTransaction","onSuccess",{signature:e}),e;{let t=await N.sendRawTransaction({serializedTransaction:e});return Cs(pe,"sendTransaction","onSuccess",{hash:t}),t}}catch(e){throw Cs(pe,h,"onError",Te.TRANSACTION_FAILURE),e}};if(Ce({showWalletUIs:t?.showWalletUIs}))P().then((e=>{o?Cs(pe,"signTransaction","onSuccess",{signature:e}):Cs(pe,"sendTransaction","onSuccess",{hash:e}),s({hash:e})})).catch((e=>{Cs(pe,h,"onError",Te.TRANSACTION_FAILURE),c(e)}));else{let e={connectingWalletAddress:u,recoveryMethod:p.recoveryMethod,entropyId:g,entropyIdVerifier:f,onCompleteNavigateTo:vC,isUnifiedWallet:M,onFailure:e=>{Cs(pe,h,"onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),c(e)}},n=Yy(Q)?Fw({address:u,appConfig:Q,fundWalletConfig:r,methodScreen:Pw,chainIdOverride:E.chainId,comingFromSendTransactionScreen:!0}):void 0;te({connectWallet:e,sendTransaction:{transactionRequest:E,transactingWalletIndex:m,transactingWalletAddress:u,entropyId:g,entropyIdVerifier:f,signOnly:o,scanTransaction:async()=>{let e=await Hc(E,N,E.from);return await a.scanTransaction({metadata:{domain:Q.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}]}})},onConfirm:()=>P(),onSuccess:e=>{o?Cs(pe,"signTransaction","onSuccess",{signature:e.hash}):Cs(pe,"sendTransaction","onSuccess",{hash:e.hash}),s(e)},onFailure:e=>{Cs(pe,h,"onError",Te.TRANSACTION_FAILURE),c(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:d},funding:n}),be(Kw)}}));function Fe(){return new Promise((async(e,t)=>{let n=await Sb();if(!n||!G)throw Error("Must have valid access token to enroll in MFA");try{await G.verifyMfa({accessToken:n}),e()}catch(e){t(e)}}))}let De=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],Be=e=>{let t=T?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:n,loginMethod:r}=Ip(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw Cs(pe,"linkAccount","onError",Te.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:r}),new he(`User already has an account of type ${n} linked.`)};async function ze({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){W(null);let n=t?"setWalletPassword":"setWalletRecovery";if(!y||!T)throw Cs(pe,n,"onError",Te.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let r=Xt(T);if(!r||!G)throw Cs(pe,n,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");let a=en(r);if(a)throw Cs(pe,n,"onError",Te.UNSUPPORTED_WALLET_TYPE),new he("User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");try{await Fe()}catch(e){throw Cs(pe,n,"onError",Te.MISSING_MFA_CREDENTIALS),e}return new Promise(((i,o)=>{let s="user-passcode"===r.recoveryMethod,l=xy({walletAction:"update",availableRecoveryMethods:Q.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:s,showAutomaticRecovery:e}),{entropyId:c,entropyIdVerifier:d}=Ni(T),h={recoveryMethod:r.recoveryMethod,connectingWalletAddress:r.address,onCompleteNavigateTo:l,shouldForceMFA:!1,entropyId:c,isUnifiedWallet:a,entropyIdVerifier:d,onFailure:e=>{Cs(pe,n,"onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),o(e)}};te({setWalletPassword:{onSuccess:e=>{Cs(pe,n,"onSuccess",{method:"user-passcode",wallet:e}),i(e)},onFailure:e=>{Cs(pe,n,"onError",Te.USER_EXITED_SET_PASSWORD_FLOW),o(e)},callAuthOnSuccessOnClose:!1},recoverWallet:{entropyId:c,entropyIdVerifier:d,onFailure:o},connectWallet:h,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:s,shouldCreateEth:!1,shouldCreateSol:!1}}),be(Kw)}))}async function $e({appId:e,action:t}){let n=await Sb();if("link"===t&&!n)throw Cs(pe,"linkAccount","onError",Te.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new he("User must be authenticated before linking an account.");if("login"===t&&n)throw Cs(pe,"login","onError",Te.UNKNOWN_AUTH_ERROR),new he("Attempted to log in, but user is already logged in. Use a `link` helper instead.");ye.current=`privy:${e}`,we.current=t;let r=lh();return a.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,i)=>{let{name:o,logoUrl:s}=await sh({api:a.api,providerAppId:e,requesterAppId:Q.id});te({crossAppAuth:{appId:e,name:o,logoUrl:s,action:t,popup:r,onSuccess:n,onError:i}}),be(_C)}))}let je={ready:m,authenticated:y,user:T,walletConnectors:a.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),te({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),be(y?xC:AC)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),Pe("siwe"),ye.current="siwe",we.current="link",te({...ee,externalConnectWallet:{...ee.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),be($C)},startCrossAppAuthFlow:$e,linkEmail:()=>{Pe("email"),Be("email"),ye.current="email",we.current="link",be(BC)},linkPhone:()=>{Pe("sms"),Be("phone"),ye.current="sms",we.current="link",be(zC)},linkGoogle:async()=>{Pe("google"),Be("google_oauth"),we.current="link",await Ve.initLoginWithOAuth("google")},linkTwitter:async()=>{Pe("twitter"),Be("twitter_oauth"),we.current="link",await Ve.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Pe("discord"),Be("discord_oauth"),we.current="link",await Ve.initLoginWithOAuth("discord")},linkGithub:async()=>{Pe("github"),Be("github_oauth"),we.current="link",await Ve.initLoginWithOAuth("github")},linkSpotify:async()=>{Pe("spotify"),Be("spotify_oauth"),we.current="link",await Ve.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Pe("instagram"),Be("instagram_oauth"),we.current="link",await Ve.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Pe("tiktok"),Be("tiktok_oauth"),we.current="link",await Ve.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Pe("linkedin"),Be("linkedin_oauth"),we.current="link",await Ve.initLoginWithOAuth("linkedin")},linkApple:async()=>{Pe("apple"),Be("apple_oauth"),we.current="link",await Ve.initLoginWithOAuth("apple")},linkPasskey:async()=>{Pe("passkey"),Be("passkey"),await Ve.initLinkWithPasskey(),be(Ff)},linkTelegram:async e=>{if(Pe("telegram"),Be("telegram"),we.current="link",ye.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new Ti;a.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=Ai(e.launchParams.initDataRaw),te({telegramAuthModalData:{seamlessAuth:!0}}),be(Dm)}else Cs(pe,"linkAccount","onError",Te.INVALID_DATA,{linkMethod:"telegram"});else await Ve.initLoginWithTelegram();be(Dm)},linkFarcaster:async()=>{Pe("farcaster"),Be("farcaster"),await Ve.initLoginWithFarcaster(),we.current="link",ye.current="farcaster",be(fm)},updateEmail:()=>{if(Pe("email"),!T?.email)throw new he("User does not have an email linked to their account.");we.current="update",ye.current="email",be(mb)},updatePhone:()=>{if(Pe("sms"),!T?.phone)throw new he("User does not have a phone number linked to their account.");we.current="update",ye.current="sms",be(gb)},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(!m){let e=await new Promise((e=>{re((t=>e.bind(t)))}));if(re(null),e)return void console.warn(t)}!T||T.isGuest?(we.current="login",te({login:e}),be(dy)):console.warn(t)},connectOrCreateWallet:async()=>{m||(await new Promise((e=>{re((()=>e))})),re(null)),y?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(we.current="connect-or-create",be(Fg))},logout:async()=>{if(we.current=null,ye.current=null,T&&a.clearProviderAcccessTokens(T),W(null),await a.logout(),T&&G)try{await G.clearMfa({userId:T.id})}catch(e){}x(null),f(!1),Cs(pe,"logout","onSuccess"),u(!1),jr.del(Sa),jr.del(Na(Q.id))},getAccessToken:h((()=>a.getCustomerAccessToken()),[a]),unlinkWallet:async e=>{let t;return x(t=e.startsWith("0x")?await a.unlinkEthereumWallet(e):await a.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await a.unlinkEmail(e);return x(t),t},unlinkPhone:async e=>{let t=await a.unlinkPhone(e);return x(t),t},unlinkGoogle:async e=>{let t=await a.unlinkOAuth("google",e);return x(t),t},unlinkTwitter:async e=>{let t=await a.unlinkOAuth("twitter",e);return x(t),t},unlinkDiscord:async e=>{let t=await a.unlinkOAuth("discord",e);return x(t),t},unlinkGithub:async e=>{let t=await a.unlinkOAuth("github",e);return x(t),t},unlinkSpotify:async e=>{let t=await a.unlinkOAuth("spotify",e);return x(t),t},unlinkInstagram:async e=>{let t=await a.unlinkOAuth("instagram",e);return x(t),t},unlinkTiktok:async e=>{let t=await a.unlinkOAuth("tiktok",e);return x(t),t},unlinkLinkedIn:async e=>{let t=await a.unlinkOAuth("linkedin",e);return x(t),t},unlinkApple:async e=>{let t=await a.unlinkOAuth("apple",e);return x(t),t},unlinkFarcaster:async e=>{let t=await a.unlinkFarcaster(e);return x(t),t},unlinkTelegram:async e=>{let t=await a.unlinkTelegram(e);return x(t),t},unlinkPasskey:async e=>{let t=await Sb();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!G)throw Error("Wallet proxy not initialized.");let n=Q.passkeys.shouldUnenrollMfaOnUnlink;await G.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:n});let r=await a.getAuthenticatedUser();return x(r),r},unlinkCrossAppAccount:async({subject:e})=>{let t=T?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new he("Invalid subject");a.storeProviderAccessToken(t.id,null);let n=await a.unlinkOAuth(`privy:${t.id}`,e);return x(n),n},setWalletRecovery:async e=>ze({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>ze({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=e.message,s=t?.address?sn(T,t.address):on(T);if(!s&&void 0!==t?.address){let e=un(A,t.address);if(e)try{let t=await e.getEthereumProvider(),r=await t.request({method:"personal_sign",params:[o,e.address]});return Cs(pe,"signMessage","onSuccess",{signature:r}),void n({signature:r})}catch(e){return Cs(pe,"signMessage","onError",Te.UNABLE_TO_SIGN),void r(e??new Li("Unable to sign message"))}}if(!s)throw new he("No embedded or connected wallet found for address.");if(!y||!T)return Cs(pe,"signMessage","onError",Te.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let c=s.address,d=s.walletIndex??0,{entropyId:h,entropyIdVerifier:p}=Ni(T,s),u=en(s);if("string"!=typeof o||o.length<1)return Cs(pe,"signMessage","onError",Te.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));let m=async()=>{let t;if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let n=await Sb();if(!G||!n||!await Ve.recoverEmbeddedWallet({address:c}))throw Error("Unable to connect to wallet");if(a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:c,requesterAppId:i}}),u){let r=k(e.message,{strict:!0}),a=await I(l,(async({message:e})=>await G.signWithUserSigner({accessToken:n,requesterAppId:i,message:e})),{chain_type:"ethereum",method:"personal_sign",params:r?{message:o.slice(2),encoding:"hex"}:{message:o,encoding:"utf-8"},wallet_id:s.id});if(!a.data||!("signature"in a.data))throw new Li("Unable to sign message");t=a.data.signature}else{let{response:e}=await G.rpc({accessToken:n,entropyId:h,entropyIdVerifier:p,chainType:"ethereum",hdWalletIndex:d,requesterAppId:i,request:{method:"personal_sign",params:[o,c]}});t=e.data}return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:c,requesterAppId:i}}),t};if(Ce({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await m();Cs(pe,"signMessage","onSuccess",{signature:e}),n({signature:e})}catch(e){Cs(pe,"signMessage","onError",Te.UNABLE_TO_SIGN),r(e??new Li("Unable to sign message"))}else te({signMessage:{method:"personal_sign",data:o,confirmAndSign:m,onSuccess:e=>{Cs(pe,"signMessage","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{Cs(pe,"signMessage","onError",Te.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:s.recoveryMethod,connectingWalletAddress:c,entropyId:h,entropyIdVerifier:p,onCompleteNavigateTo:$v,isUnifiedWallet:u,onFailure:e=>{Cs(pe,"signMessage","onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),be(Kw)})),signTypedData:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=t?.address?sn(T,t.address):on(T);if(!o&&t?.address){let a=un(A,t.address);if(a)try{let t=await a.getEthereumProvider(),r=oa(e),i=await t.request({method:"eth_signTypedData_v4",params:[a.address,r]});return Cs(pe,"signTypedData","onSuccess",{signature:i}),void n({signature:i})}catch(e){return Cs(pe,"signTypedData","onError",Te.UNABLE_TO_SIGN),void r(e??new Li("Unable to sign typed data "+e))}}if(!o)throw new he("No embedded or connected wallet found for address.");if(!y||!T)return Cs(pe,"signTypedData","onError",Te.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let s=o.address,c=o.walletIndex??0,{entropyId:d,entropyIdVerifier:h}=Ni(T,o),p=en(o),u=oa(e),m=async()=>{let e;if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let t=await Sb();if(!G||!t||!await Ve.recoverEmbeddedWallet({address:s}))throw Error("Unable to connect to wallet");if(a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:s,requesterAppId:i}}),p){let{domain:n,types:r,primaryType:a,message:s}=u,c=await I(l,(async({message:e})=>await G.signWithUserSigner({accessToken:t,requesterAppId:i,message:e})),{chain_type:"ethereum",method:"eth_signTypedData_v4",params:{typed_data:{domain:n,types:r,primary_type:a,message:s}},wallet_id:o.id});if(!c.data||!("signature"in c.data))throw new Li("Unable to sign message");e=c.data.signature}else{let{response:n}=await G.rpc({accessToken:t,entropyId:d,entropyIdVerifier:h,chainType:"ethereum",hdWalletIndex:c,requesterAppId:i,request:{method:"eth_signTypedData_v4",params:[s,u]}});e=n.data}return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:s,requesterAppId:i}}),e};if(Ce({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await m();Cs(pe,"signTypedData","onSuccess",{signature:e}),n({signature:e})}catch(e){Cs(pe,"signTypedData","onError",Te.UNABLE_TO_SIGN),r(e??new Li("Unable to sign message"))}else te({signMessage:{method:"eth_signTypedData_v4",data:u,confirmAndSign:m,onSuccess:e=>{Cs(pe,"signTypedData","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{Cs(pe,"signTypedData","onError",Te.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:d,isUnifiedWallet:p,entropyIdVerifier:h,onCompleteNavigateTo:$v,onFailure:e=>{Cs(pe,"signMessage","onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),be(Kw)})),sendTransaction:async(e,t)=>await Re({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await Re({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!y||!T)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?sn(T,e.address):on(T),o=Xt(T);if(!i||!o)return void r(new he("User must have an embedded wallet."));let s=i.address,{entropyId:l,entropyIdVerifier:c}=Ni(T,i),d=en(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(!b(s))return void r(Error("Must provide a valid Ethereum address."));let h={recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,isUnifiedWallet:d,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:jw,onFailure:r,shouldForceMFA:!0};te(ee),await Sb()&&G?G?Jd(i)?(te({keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,address:i.address,entropyId:l,entropyIdVerifier:c,hdWalletIndex:i.walletIndex,chainType:i.chainType,walletId:i.id,isUnifiedWallet:d,imported:i.imported,onSuccess:t,onFailure:r},connectWallet:h}),be(Kw)):r(Error(`Export is not supported for ${i.chainType} wallets`)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:Fe,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 he("Invalid MFA code");ce.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{de.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new he("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));ce.current?.resolve({mfaMethod:e,mfaCode:r,relyingParty:window.origin}),await new Promise(((e,t)=>{de.current={resolve:e,reject:t}}));break;default:throw ce.current?.reject(new he("Unsupported MFA method")),new he(`Unsupported MFA method: ${e}`)}},cancel(){ce.current?.reject(new he("MFA canceled"))},async initEnrollmentWithSms(e){let t=await Sb();if(!t||!G)throw Error("Must have valid access token to enroll in MFA");await G.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,n)=>{if(!e)return Ve.closePrivyModal(),void t();Q.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."),te({mfaEnrollmentFlow:{mfaMethods:Q.mfa.methods,shouldUnlinkOnUnenrollMfa:Q.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:n}}),be(lb)})),async initEnrollmentWithTotp(){let e=await Sb();if(!e||!G)throw Error("Must have valid access token to enroll in MFA");let t=await G.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await Sb();if(!t||!G)throw Error("Must have valid access token to enroll in MFA");await G.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),x(await a.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await Sb();if(!t||!G)throw Error("Must have valid access token to enroll in MFA");await G.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),x(await a.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let n=await Sb();if(!n||!G)throw Error("Must have valid access token to enroll in MFA");await G.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:e,removeForLogin:t.removeForLogin}),x(await a.getAuthenticatedUser())},async unenroll(e,t={}){let n=await Sb();if(!n||!G)throw Error("Must have valid access token to remove MFA");"passkey"===e?await G.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:[],removeForLogin:t.removeForLogin}):await G.unenrollMfa({method:e,accessToken:n}),x(await a.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await Sb(),t=T?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!G||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(en(t))throw new he("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!T?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Ve.recoverEmbeddedWallet({address:t.address}))throw Error("Unable to connect to wallet");let n=await G.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===n.status&&x(await a.getAuthenticatedUser()||T||null),te({farcasterSigner:n}),be(OC)},getFarcasterSignerPublicKey:async()=>{let e,t=await Sb(),n=T?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!G||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(en(n))throw new he("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!T?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Ve.recoverEmbeddedWallet({address:n.address}))throw Error("Unable to connect to wallet");if(!T.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=T.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await Sb(),n=T?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!G||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(en(n))throw new he("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!T?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Ve.recoverEmbeddedWallet({address:n.address}))throw Error("Unable to connect to wallet");if(!T.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let r=await import("@simplewebauthn/browser"),a=await G.signFarcasterMessage({address:n.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:r.bufferToBase64URLString(e)},fid:BigInt(T.farcaster.fid),relyingParty:window.origin});return new Uint8Array(r.base64URLStringToBuffer(a.signature))},signMessageWithCrossAppWallet(e,{address:t,chainId:n}){let r=T?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return dh({user:T,client:a,address:t,requesterAppId:Q.id,request:{method:r?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:n},reconnect:$e})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:n}){let r=T?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),i=oa(e);return dh({user:T,client:a,address:t,requesterAppId:Q.id,request:{method:r?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,i],chainId:n},reconnect:$e})},sendTransactionWithCrossAppWallet(e,{address:t}){let n=T?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return dh({user:T,client:a,address:t,requesterAppId:Q.id,request:{method:n?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:$e})},isModalOpen:p,mfaMethods:Q.mfa.methods};kb=je.signMessage,Tb=je.signTypedData,Ab=async(e,t)=>await Re({transaction:e,...t,signOnly:!1}),xb=async(e,t)=>({signature:(await Re({transaction:e,...t,signOnly:!0})).hash});let Ve={privy:l,setAuthenticated:f,setUser:x,setIsNewUser:M,isNewUserThisSession:N,pendingTransaction:null,walletConnectionStatus:L,connectors:a.connectors?.walletConnectors??[],solanaWallets:E,rpcConfig:Q.rpcConfig,chains:Q.chains,appId:n.appId,showFiatPrices:"native-token"!==Q.embeddedWallets.priceDisplay.primary,clientAnalyticsId:a.clientAnalyticsId,onCustomAuthAuthenticated:ke,hideWalletUIs:ve,isHeadlessSigning:h(Ce,[Q.embeddedWallets.showWalletUIs]),emailOtpState:B,setEmailOtpState:z,smsOtpState:$,setSmsOtpState:j,oAuthState:q,setOAuthState:K,telegramAuthState:Z,setTelegramAuthState:Y,siweState:V,setSiweState:H,isHeadlessOAuthLoading:U,nativeTokenSymbolForChainId:e=>Q.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(G)return G;let t=new Promise((e=>{ae.current=e})),n=new Promise((t=>setTimeout((()=>t(null)),e))),r=await Promise.race([t,n]);return ae.current=null,r},getAuthFlow:()=>a.authFlow,getAuthMeta:()=>a.authFlow?.meta,client:a,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=m&&y&&T;r&&ye.current&&(t=De(T)),"login"===we.current?e.shouldCallAuthOnSuccess&&r&&ye.current?Cs(pe,"login","onComplete",{user:T,isNewUser:N,wasAlreadyAuthenticated:!1,loginMethod:ye.current,loginAccount:t??null}):Cs(pe,"login","onError",Te.USER_EXITED_AUTH_FLOW):"link"===we.current&&t?e.isSuccess&&r&&ye.current?Cs(pe,"linkAccount","onSuccess",{user:T,linkMethod:ye.current,linkedAccount:t}):ye.current&&Cs(pe,"linkAccount","onError",Te.USER_EXITED_LINK_FLOW,{linkMethod:ye.current}):"update"===we.current&&t?e.isSuccess&&r&&ye.current?Cs(pe,"update","onSuccess",{user:T,updateMethod:ye.current,updatedAccount:t}):ye.current&&Cs(pe,"update","onError",Te.USER_EXITED_UPDATE_FLOW,{linkMethod:ye.current}):"connect-or-create"===we.current&&(A[0]?Cs(pe,"connectOrCreateWallet","onSuccess",{wallet:A[0]}):Cs(pe,"connectOrCreateWallet","onError",Te.USER_EXITED_AUTH_FLOW));let i=P&&kC.has(P),o=P===su&&ee.errorModalData&&kC.has(ee.errorModalData.previousScreen);if((i||o)&&ee.funding){let e,t=kC.get(P)??null;if("solana"===ee.funding.chainType){let n=c(Ry);if(n)try{e=BigInt(await n.getBalance({address:ee.funding.address,cluster:ee.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");Cs(pe,"fundSolanaWallet","onUserExited",{address:ee.funding.address,cluster:ee.funding.cluster,fundingMethod:t,balance:e})}else{let r=Kr(ee.funding.chain.id,Q.chains,Q.rpcConfig,{appId:n.appId});try{e=await r.getBalance({address:ee.funding.address})}catch{console.error("Unable to pull wallet balance")}Cs(pe,"fundWallet","onUserExited",{address:ee.funding.address,chain:ee.funding.chain,fundingMethod:t,balance:e})}}te({...ee,externalConnectWallet:{suggestedAddress:void 0}}),we.current=null,ye.current=null,M(!1),u(!1),setTimeout((()=>{a.authFlow=void 0}),200)},openPrivyModal:be,connectWallet:Ee,initLoginWithWallet:async(e,t,n,r)=>{Fi(e)?(ye.current="siwe",Se(e,t,n)):(ye.current="siws",Ne(e,t,n,r))},loginWithWallet:async()=>{let e,t,n;if(!m)throw new St;if(a.authFlow instanceof ui?e="siwe":a.authFlow instanceof yi&&(e="siws"),!e)throw new he("Must initialize SIWE/SIWS flow first.");if(null!==await a.getAccessToken())try{({user:t}=await a.link()),ye.current=e}catch(t){throw Cs(pe,"linkAccount","onError",t.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:n}=await a.authenticate()),ye.current=e}catch(e){throw Cs(pe,"login","onError",e.privyErrorCode||Te.GENERIC_CONNECT_WALLET_ERROR),e}x(t||T||null),M(n||!1),f(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:n})=>new Promise((async(r,a)=>{let i=await Sb();if(!y||!T||!i)throw new he("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new he("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=Ve.walletProxy??await Ve.initializeWalletProxy(15e3);if(!o)throw new he("Wallet proxy not initialized.");if((({address:e,user:t})=>!!eh(t).find((t=>t.address===e)))({address:e,user:T}))return r();let s=sn(T,e);if(!s)throw new he("Address to delegate is not associated with current user.");if(en(s))throw new he("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let l=Qd({address:e,user:T}),c=Xd({address:e,user:T}),d=async()=>{await o.createDelegatedAction({accessToken:i,rootWallet:c,delegatedWallets:[l]}),await Ve.refreshSessionAndUser()};if(await Ve.recoverEmbeddedWallet({address:e}),n)te({delegatedActions:{consent:{address:e,onDelegate:d,onSuccess:async()=>{r()},onError:async e=>{a(e)}}}}),be(SC);else try{await d(),r()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,n)=>{if(!y||!T)throw new he("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");let r=eh(T);if(0===r.length)throw new he("User has no delegated wallets to revoke.");if(r.some(en))throw new he("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let i=async()=>{await a.revokeDelegatedWallet(),await Ve.refreshSessionAndUser()};if(e)te({delegatedActions:{revoke:{onRevoke:i,onSuccess:async()=>{t()},onError:async e=>{n(e)}}}}),be(PC);else try{await i(),t()}catch(e){n(e)}})),initLoginWithFarcaster:async(e,t)=>{let n=new ya(e,t);a.startAuthFlow(n);try{ye.current="farcaster",await n.initializeFarcasterConnect()}catch(e){throw"login"===we.current?Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR):"link"===we.current&&Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!m)throw new St;if(!(a.authFlow instanceof ya))throw new he("Must initialize Farcaster flow first.");if(null!==await a.getAccessToken())try{({user:e}=await a.link()),ye.current="farcaster"}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await a.authenticate()),ye.current="farcaster"}catch(e){throw Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}x(e||null),M(t||!1),f(!0)},async crossAppAuthFlow({appId:e,popup:t,action:n}){let r=`privy:${e}`;ye.current=r;let{url:i,stateCode:o,codeVerifier:s}=await async function({api:e,appId:t}){let n=qa(),r=Ka(),a=await Za(n);try{let{url:i}=await e.post(Ae,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:r});return{url:i,stateCode:r,codeVerifier:n}}catch(e){throw ue(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 he("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 he("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 he("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 he(t.data.error)),i()),t.data.type===ih&&((r=new BroadcastChannel(ah)).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 he("Unexpected auth flow. This may be a phishing attempt.",void 0,Te.OAUTH_UNEXPECTED);let h=await async function({appId:e,stateCode:t,codeVerifier:n,authorizationCode:r,action:a,client:i}){if(!r||!t)throw new he("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===r)throw new he("User denied confirmation during cross-app auth flow");try{let o=new oh({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=ue(e);if(t.privyErrorCode)throw new he(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 he("Invalid code during cross-app auth flow.",void 0,Te.OAUTH_USER_DENIED);throw new he("Invalid code during cross-app auth flow.",void 0,Te.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:s,stateCode:c,authorizationCode:d,action:n,client:a});h&&a.storeProviderAccessToken(e,h);let p=await Ve.refreshSessionAndUser();if(!p)throw new he("Unable to update user");return a.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),p}catch(e){throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:r}}),e}},async initLoginWithOAuth(e,t,n){if(ye.current=e,!$r())return void be(FC);if("google"===e&&Vm(window.navigator.userAgent))return void be(FC);"twitter"===e&&window.opener&&window.opener.postMessage({type:ih},"*"),jr.del(Ua),jr.del(Oa);let r=new Ya({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(!m)throw new St;ye.current="telegram";let n=new Ti(e,t);a.startAuthFlow(n),Y({status:"loading"}),n.meta.telegramWebAppData=void 0,n.meta.telegramAuthResult=await new Promise(((e,t)=>Q.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:Q.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(n=>n?e(n):t(new he("Telegram auth failed or was canceled by the client")))):t(new he("Telegram was not initialized")):t(new he("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,n;if(!(a.authFlow instanceof Ti))throw new he("Must initialize Telegram flow before calling loginWithTelegram");a.authFlow.meta.captchaToken||=e?.captchaToken;let r=await Sb(),i=e?.intent||we.current;if("login"===i)try{let e=await a.authenticate();t=e.user,n=e.isNewUser,ye.current="telegram"}catch(e){throw Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}else{if("link"!==i)throw new he("Unknown auth intent");try{t=(await a.link()).user,ye.current="telegram"}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}x(t),M(n||!1),f(!0),Y({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:o}},async loginWithOAuth(e){let t,n,r;if(!(a.authFlow instanceof Ya))throw new he("Must initialize OAuth flow before calling loginWithOAuth");let i=jr.get(Pa),o=a.authFlow.meta.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:i??"",returnedStateCode:o??""}}),new he("Unexpected auth flow. This may be a phishing attempt.",void 0,Te.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{let n=await a.link();t=n.user,r=n.oAuthTokens,ye.current=e}catch(t){throw Cs(pe,"linkAccount","onError",t.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let i=await a.authenticate();t=i.user,n=i.isNewUser,r=i.oAuthTokens,ye.current=e}catch(t){throw"login"===we.current?Cs(pe,"login","onError",t.privyErrorCode||Te.UNKNOWN_AUTH_ERROR):"link"===we.current&&Cs(pe,"linkAccount","onError",t.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return x(t),M(n||!1),f(!0),r&&t&&Cs(pe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),r},passkeyAuthState:F,setPasskeyAuthState:D,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new hi({captchaToken:e,setPasskeyAuthState:D});a.startAuthFlow(n),we.current="login";try{ye.current="passkey",D({status:"generating-challenge"}),await n.initRegisterFlow(t),D({status:"awaiting-passkey"})}catch(e){throw D({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!m)throw new St;if(!(a.authFlow instanceof hi))throw new he("Must initialize Passkey flow first.");if("passkey"!==ye.current){let e=new he("Must init login with Passkey flow first.");throw D({status:"error",error:e}),e}let n=await Sb();try{ye.current="passkey",D({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await a.authenticate())}catch(e){throw D({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}x(e),M(t||!1),f(!0),D({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 hi({captchaToken:e,setPasskeyAuthState:D});a.startAuthFlow(n),we.current="login";try{ye.current="passkey",D({status:"generating-challenge"}),await n.initAuthenticationFlow(t),D({status:"awaiting-passkey"})}catch(e){throw D({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,n;if(!m)throw new St;if(!(a.authFlow instanceof hi))throw new he("Must initialize Passkey flow first.");if(e?.credentialIds&&(a.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==ye.current){let e=new he("Must init login with Passkey flow first.");throw D({status:"error",error:e}),e}let r=await Sb();try{ye.current="passkey",D({status:"awaiting-passkey"}),({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw D({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}x(t),M(n||!1),f(!0),D({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 hi({captchaToken:e});a.startAuthFlow(t),we.current="link",ye.current="passkey",D({status:"generating-challenge"});try{await t.initLinkFlow(),D({status:"awaiting-passkey"})}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),D({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!m)throw new St;if(!(a.authFlow instanceof hi))throw new he("Must initialize Passkey flow first.");if("passkey"!==ye.current)throw new he("Must init login with Passkey flow first.");try{ye.current="passkey",({user:e}=await a.link())}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return x(e||T||null),D({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,n){if(!$r())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&&Vm(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 Ya({provider:e,withPrivyUi:!1,disableSignup:n??!1});t&&r.addCaptchaToken(t),K({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),K({status:"loading"}),a.startAuthFlow(new Ya(e));let i=jr.get(Pa),o=e.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:i??"",returnedStateCode:o??""}}),O(!1),new he("Unexpected auth flow. This may be a phishing attempt.",void 0,Te.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{({user:t,oAuthTokens:r}=await a.link()),ye.current=e.provider;let n=De(t);t&&n&&Cs(pe,"linkAccount","onSuccess",{user:t,linkMethod:ye.current,linkedAccount:n})}catch(t){throw O(!1),Cs(pe,"linkAccount","onError",t.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:n,oAuthTokens:r}=await a.authenticate()),ye.current=e.provider;let i=De(t);t&&i&&void 0!==n&&Cs(pe,"login","onComplete",{user:t,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:ye.current,loginAccount:i})}catch(e){throw O(!1),K({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}return x(t),M(n||!1),f(!0),O(!1),K({status:"done"}),r&&t&&Cs(pe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{let i=new Dr({email:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ye.current="email",z({status:"sending-code"}),await i.sendCodeEmail({withPrivyUi:r}),z({status:"awaiting-code-input"})}catch(e){throw z({status:"error",error:e}),"login"===we.current?Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR):"link"===we.current&&Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,n)=>{let r=new Br(e,t,n);a.startAuthFlow(r);try{await r.sendCodeEmail({withPrivyUi:!0})}catch(e){Cs(pe,"update","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR,{linkMethod:ye.current})}},initUpdatePhone:async(e,t,n)=>{let r=new wi(e,t,n);a.startAuthFlow(r);try{await r.sendSmsCode({withPrivyUi:!0})}catch(e){Cs(pe,"update","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR,{linkMethod:ye.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{j({status:"sending-code"});let i=new fi({phoneNumber:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ye.current="sms",await i.sendSmsCode({withPrivyUi:r}),j({status:"awaiting-code-input"})}catch(e){throw j({status:"error",error:e}),"login"===we.current?Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR):"link"===we.current&&Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.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 Dr?z(e):a.authFlow instanceof fi&&j(e)}if(r({status:"submitting-code"}),!m){let e=new St;throw r({status:"error",error:e}),e}if(a.authFlow instanceof Dr)a.authFlow.meta.emailCode=e.trim();else{if(!(a.authFlow instanceof fi)){let e=new he("Must initialize a passwordless code flow first");throw r({status:"error",error:e}),e}a.authFlow.meta.smsCode=e.trim()}let i=await Sb();if("link"===we.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:ye.current}),e}else if("update"===we.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),Cs(pe,"update","onError",e.privyErrorCode||Te.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:ye.current}),e}else try{({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw r({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}let o=t||T;x(o||null),M(n||!1),f(!0),r({status:"done"});let s=null;return a.authFlow instanceof Dr?s=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:a.authFlow instanceof fi&&(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})=>{we.current=y?"link":"login",ye.current="siwe",H({status:"generating-message"});let r=await a.generateSiweNonce({address:e,captchaToken:n});return H({status:"awaiting-signature"}),pi({address:e,chainId:t.replace("eip155:",""),nonce:r})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let n=await a.generateSiweNonce({address:e});return pi({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}),x((r=await Ve.refreshSessionAndUser()??r)||T||null)},loginWithSiwe:async({message:e,signature:t,captchaToken:n,disableSignup:r})=>{let i,o=null;try{if(T)throw Error("User already authenticated");let s=new ui(a,void 0,n,r,{message:e,signature:t});a.startAuthFlow(s),ye.current="siwe",we.current="login",H({status:"submitting-signature"});let l=await a.authenticate();if(({user:o,isNewUser:i}=l),!o)throw Error("Authentication failed - no user returned")}catch(e){throw Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),H({status:"error",error:e}),e}return x(o),M(i||!1),f(!0),H({status:"done"}),we.current=null,ye.current=null,o},linkWithSiwe:async({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i})=>{let o;Pe("siwe");let s=null;try{H({status:"submitting-signature"}),o=await a.linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i}),o=await Ve.refreshSessionAndUser()??o,H({status:"done"}),(s=De(o)||null)&&Cs(pe,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:s})}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),we.current=null,ye.current=null,H({status:"error",error:e}),e}let l=o||T;return x(l||null),we.current=null,ye.current=null,{user:l,linkedAccount:s}},refreshSessionAndUser:async()=>{let e=await a.getAuthenticatedUser();return f(!!e),x(e),e},walletProxy:G,createAnalyticsEvent:({eventName:e,payload:t,timestamp:n})=>a.createAnalyticsEvent({eventName:e,payload:t,timestamp:n}),acceptTerms:async()=>{let e=await a.acceptTerms();return x(e),e},getUsdTokenPrice:e=>a.getUsdTokenPrice(e),getUsdPriceForSol:()=>a.getUsdPriceForSol(),getSplTokenMetadata:e=>a.getSplTokenMetadata(e),recoverEmbeddedWallet:async e=>new Promise((async(t,n)=>{if(!T)return void t(!0);let r=e?.address?sn(T,e.address):Xt(T)||cn(T)||ln(T);if(!r||en(r))return void t(!0);let i=await Sb();if(!i||!G||!r)return void n(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:o,entropyIdVerifier:s}=Ni(T,r);try{await G.connect({accessToken:i,entropyId:o,entropyIdVerifier:s}),t(!0)}catch(e){if(Jc(e)&&"privy"===r.recoveryMethod){let e;a.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:r.address}});try{e=await G.recover({entropyId:o,entropyIdVerifier:s,accessToken:i})}catch(e){return void n(e)}e.entropyId||n(Error("Unable to recover wallet")),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:r.address}}),t(!0)}else Jc(e)&&"privy"!==r.recoveryMethod&&"privy-v2"!==r.recoveryMethod?(te({recoverWallet:{entropyId:o,entropyIdVerifier:s,onFailure:n,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:r.recoveryMethod,action:"recover",shouldCreateEth:!1,shouldCreateSol:!1}}),be(Ay(r.recoveryMethod))):n(e)}})),exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!y||!T)return void r(Error("User must be authenticated before exporting their Privy wallet"));let i=e?.address?sn(T,e.address):an(T),o=Xt(T);if(!i||!o)return void r(new he("User must have an embedded wallet."));let{entropyId:s,entropyIdVerifier:l}=Ni(T,i);if(!i||!o)return void r(Error("Must have a Privy wallet before exporting"));let c=en(i);if(!await Sb()||!G)return void r(Error("Must have valid access token to enroll in MFA"));if(!G)return void r(Error("Must have a Privy wallet before exporting"));let d={recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,isUnifiedWallet:c,entropyId:s,entropyIdVerifier:l,onCompleteNavigateTo:jw,onFailure:r,shouldForceMFA:!0};Jd(i)?(te({connectWallet:d,keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,address:i.address,entropyId:s,entropyIdVerifier:l,hdWalletIndex:i.walletIndex,chainType:i.chainType,walletId:i.id,isUnifiedWallet:c,imported:i.imported,onSuccess:t,onFailure:r}}),be(Kw)):r(Error(`Export is not supported for ${i.chainType} wallets`))})),setReadyToTrue:e=>{g(!0),ne?.(e)},updateWallets:()=>Oe(),fundWallet:async(e,t)=>{te({funding:Fw({address:e,appConfig:Q,fundWalletConfig:t,methodScreen:Pw})}),be(Pw)},openModal:be,requestFarcasterSignerStatus:async e=>{let t=await Sb(),n=T?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!G||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!T?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let r=await a.requestFarcasterSignerStatus(e);return"approved"===r.status&&x(await a.getAuthenticatedUser()||T||null),r},connectCoinbaseSmartWallet:async()=>{Q.externalWallets.coinbaseWallet.config.preference={...Q.externalWallets.coinbaseWallet.config.preference,options:"smartWalletOnly"};let e=a.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||a.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Ee(e);await _e("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 x(c),c}};Ib=Ve.recoverEmbeddedWallet,_b=Ve.recoverEmbeddedWallet;let He=s((()=>({wallets:A,ready:ie&&me})),[A,ie,me]),qe=a.authFlow instanceof Ti,Ke=!Q.headless&&Q.captchaEnabled&&!y&&(m||qe);/*#__PURE__*/return t(Cb.Provider,{value:!0,children:/*#__PURE__*/t(rn.Provider,{value:je,children:/*#__PURE__*/t(fs.Provider,{value:pe,children:/*#__PURE__*/t(jc.Provider,{value:He,children:/*#__PURE__*/t(bi,{...Q,children:/*#__PURE__*/e(Wt.Provider,{value:Ve,children:[/*#__PURE__*/t(Ep,{children:/*#__PURE__*/e(Ho,{data:ee,setModalData:te,setInitialScreen:W,initialScreen:P,authenticated:y,open:p,children:[n.children,/*#__PURE__*/t(vb,{customAuth:Q.customAuth}),Ke&&/*#__PURE__*/t(ms,{delayedExecution:!1}),/*#__PURE__*/t(zd,{}),/*#__PURE__*/t(TC,{}),/*#__PURE__*/t(_d,{theme:{...Q.appearance.palette||{}}}),!Q.render.standalone&&/*#__PURE__*/t(Rd,{open:p})]})}),/*#__PURE__*/t(Gd,{appId:n.appId,appClientId:n.clientId,clientAnalyticsId:a.clientAnalyticsId,origin:a.apiUrl,mfaMethods:T?.mfaMethods,mfaPromise:ce,mfaSubmitPromise:de,onLoad:J,onLoadFailed:()=>null}),Q.loginConfig.telegramAuthConfiguration&&
|
|
28
|
-
/*#__PURE__*/t(Ms,{$if:!0,children:/*#__PURE__*/t(Bd,{scriptHost:n.apiUrl||fa,botUsername:Q.loginConfig.telegramAuthConfiguration.botName})})]})})})})})})};export{
|
|
25
|
+
/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(CC,{}),/*#__PURE__*/t(af,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(Xs,{})]})}},kC=new Map([[Pw,null],[uw,"external"],[dw,"external"],[Cf,"external"],[bC,"external"],[hw,"external"],[Yv,"manual"],[Tw,"moonpay"]]);const TC=()=>((()=>{let e=$o(),{user:t,getAccessToken:n}=nn(),{refreshSessionAndUser:r,walletProxy:a}=Pt();d((()=>{(async()=>{if("legacy-embedded-wallets-only"===e.embeddedWallets.mode||!t)return;let i=Xt(t);if(!i||en(i)||!Jd(i)||!a)return;let o=await n();if(!o)return;let s=i.imported?[i]:t.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&!e.imported)).filter(Jd),{entropyId:l,entropyIdVerifier:c}=Ni(t,i);try{await a.connect({accessToken:o,entropyId:l,entropyIdVerifier:c})}catch(e){if(!Jc(e)||"privy"!==i.recoveryMethod)return void console.debug("Unable to migrate wallet: ",e);await a.recover({accessToken:o,entropyId:l,entropyIdVerifier:c})}try{await a.createDelegatedAction({accessToken:o,rootWallet:{address:i.address,chainType:i.chainType,imported:i.imported},delegatedWallets:s}),await r()}catch(i){console.debug("Unable to migrate wallet: ",i)}})()}),[t,a,e])})(),null),xC={component:()=>{let{app:r,data:a}=qo(),i=$o(),o=a?.externalConnectWallet?.suggestedAddress,s=a?.externalConnectWallet?.description??(o?`Connect the wallet with address ${Gr(o)} ${r?.name?`to ${r.name}.`:"."}`:`Connect a wallet to ${r?.name}`),{connectors:l}=Pt(),c=Sg({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(al,{},"header"),c.length>0&&/*#__PURE__*/t(mh,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(Is,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(Eg,{wallets:c})}),/*#__PURE__*/t(Xs,{})]})}},AC={component:()=>{let{app:r,data:a}=qo(),i=$o(),o=a?.externalConnectWallet?.suggestedAddress,s=a?.externalConnectWallet?.description??(o?/*#__PURE__*/e("span",{children:["Connect the wallet with address ",/*#__PURE__*/t(Zp,{showCopyIcon:!1,address:o})," ",r?.name?`to ${r.name}.`:"."]}):`Connect a wallet to your ${r?.name} account`),{connectors:l}=Pt(),c=Sg({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(al,{},"header"),c.length>0&&/*#__PURE__*/t(uh,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(Is,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(Eg,{wallets:c})}),r&&/*#__PURE__*/t(Qs,{app:r,alwaysShowImplicitConsent:!0}),/*#__PURE__*/t(Xs,{})]})},isUnauthenticatedScreem:!0};function IC(e){let{logout:t}=l(rn);return vs("logout",e),{logout:t}}const _C={component:()=>{let r=$o(),{data:a,navigate:i,setModalData:l,onUserCloseViaDialogOrKeybindRef:c}=qo(),{crossAppAuthFlow:h,updateWallets:p,closePrivyModal:u,createAnalyticsEvent:m}=Pt(),{logout:g}=IC(),[y,f]=o({}),w=a?.crossAppAuth,v={id:w.appId,name:w.name,logoUrl:w.logoUrl},C=new he(`There was an issue connecting your ${v.name} account. Please try again.`),b=new ga((async e=>{if(w.popup)try{let t=await h({appId:e,popup:w.popup,action:w.action});f({data:t})}catch(e){e instanceof he?f({error:e}):(e instanceof Ke&&w.popup&&w.popup.close(),f({error:C}))}else f({error:C})})),k=()=>{y.data&&(p(),w.onSuccess(y.data),u({shouldCallAuthOnSuccess:!0,isSuccess:!0})),w.onError(y.error??new he("User canceled flow")),u({shouldCallAuthOnSuccess:!1,isSuccess:!1})};c.current=k,d((()=>{v.id.length&&b.execute(v.id)}),[v.id]),d((()=>{if(!y.data)return;let e=y.data;if(r.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{i(Wu)}),wa);return()=>clearTimeout(e)}if($p(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(Mu)}),wa);return()=>clearTimeout(e)}let t=setTimeout(k,wa);return()=>clearTimeout(t)}),[y.data]);let{title:T,subtitle:x}=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(al,{onClose:k}),/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(EC,{children:[/*#__PURE__*/t(kd,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Us,{success:!!y.data,fail:!!y.error}),/*#__PURE__*/t(Lp,{name:v.name,logoUrl:v.logoUrl})]})}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t("h3",{children:T}),/*#__PURE__*/t("p",{children:x})]})]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(el,{})]})}};let EC=/*#__PURE__*/vn.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 SC={component:()=>{let{app:r,data:a}=qo(),{closePrivyModal:i}=Pt(),[s,l]=o(!1),[c,h]=o(),{address:p,onDelegate:u,onSuccess:m,onError:g}=a.delegatedActions.consent,y=async()=>{s?m():g(c??new he("User declined delegating actions.")),i({shouldCallAuthOnSuccess:!1})};return d((()=>{if(!s&&!c)return;let e=setTimeout(y,va);return()=>clearTimeout(e)}),[s,c]),/*#__PURE__*/e(n,s||c?{children:[/*#__PURE__*/t(al,{onClose:y}),/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(ic,{children:[c?/*#__PURE__*/t(tr,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(vr,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(mc,{height:20}),/*#__PURE__*/t(gh,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":`You’ve successfully granted delegated action permissions to ${r.name}.`})]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]}:{children:[/*#__PURE__*/t(al,{closeable:!0,onClose:y}),/*#__PURE__*/t(Er,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(id,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),/*#__PURE__*/e(od,{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(MC,{showIcon:!0,address:p,title:"Wallet",isLoading:!1}),/*#__PURE__*/e(NC,{style:{marginTop:24},children:[/*#__PURE__*/t(Hs,{onClick:y,children:"Not now"}),/*#__PURE__*/t(Bs,{onClick:async()=>{try{await u(),l(!0)}catch(e){h(e)}},children:"Accept"})]}),/*#__PURE__*/t(Xs,{})]})}};let NC=/*#__PURE__*/vn.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-bdb7bc51-0"})(["display:flex;gap:10px;"]),MC=/*#__PURE__*/vn(Py).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-bdb7bc51-1"})(["margin-top:1.5rem;"]);const PC={component:()=>{let{app:r,data:a}=qo(),{closePrivyModal:i}=Pt(),[s,l]=o(!1),[c,h]=o(),{onRevoke:p,onSuccess:u,onError:m}=a.delegatedActions.revoke,g=async()=>{s?u():m(c??new he("User declined revoking access to their delegated wallet.")),i({shouldCallAuthOnSuccess:!1})};return d((()=>{if(!s&&!c)return;let e=setTimeout(g,va);return()=>clearTimeout(e)}),[s,c]),/*#__PURE__*/e(n,s||c?{children:[/*#__PURE__*/t(al,{onClose:g}),/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(ic,{children:[c?/*#__PURE__*/t(tr,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(vr,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(mc,{height:20}),/*#__PURE__*/t(gh,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":"You've successfully revoked permissions."})]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]}:{children:[/*#__PURE__*/t(al,{closeable:!0,onClose:g}),/*#__PURE__*/t(Sr,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(id,{style:{marginTop:24},children:"Revoke offline access to wallet"}),/*#__PURE__*/e(od,{children:["By confirming, ",r.name," will no longer be able to use this wallet on your behalf when you are not online."]}),/*#__PURE__*/e(WC,{style:{marginTop:24},children:[/*#__PURE__*/t(Hs,{onClick:g,children:"Deny"}),/*#__PURE__*/t(Bs,{onClick:async()=>{try{await p(),l(!0)}catch(e){h(e)}},children:"Confirm"})]}),/*#__PURE__*/t(Xs,{})]})}};let WC=/*#__PURE__*/vn.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-993a839-0"})(["display:flex;gap:10px;"]),UC="#8a63d2";const OC={component:()=>{let{lastScreen:r,navigateBack:a,data:s,app:l}=qo(),{requestFarcasterSignerStatus:c,closePrivyModal:h}=Pt(),[p,u]=o(void 0),[m,f]=o(!1),[w,v]=o(!1),C=i([]),b=s?.farcasterSigner;d((()=>{let e=Date.now(),t=setInterval((async()=>{if(!b?.public_key)return clearInterval(t),void u({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===b.status&&(clearInterval(t),f(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),wa)));let n=await c(b?.public_key),r=Date.now()-e;"approved"===n.status?(clearInterval(t),f(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),wa))):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),C.current.forEach((e=>clearTimeout(e)))}}),[]);let k="pending_approval"===b?.status?b.signer_approval_url:void 0;/*#__PURE__*/return e(n,g||m?{children:[/*#__PURE__*/t(al,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(hc,{}),
|
|
26
|
+
/*#__PURE__*/t(n,y?{children:/*#__PURE__*/e(RC,{children:[/*#__PURE__*/t(kd,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Us,{success:w,fail:!!p}),/*#__PURE__*/t($u,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t(id,{children:p?p.message:"Add a signer to Farcaster"}),/*#__PURE__*/t(od,{children:p?p.detail:"This will allow "+l.name+" to add casts, likes, follows, and more on your behalf."})]}),k&&/*#__PURE__*/t(Bs,{onClick:e=>{e.preventDefault(),window.location.href=k},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(LC,{children:[/*#__PURE__*/t(kd,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Us,{success:w,fail:!!p}),/*#__PURE__*/t($u,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t(id,{children:p?p.message:"Requesting signer from Farcaster"}),/*#__PURE__*/t(od,{children:p?p.detail:"This should only take a moment"}),/*#__PURE__*/t(ac,{children:k&&g&&/*#__PURE__*/t(Ju,{text:"Take me to Warpcast",url:k,color:UC})})]})]})}),/*#__PURE__*/t(el,{})]}:{children:[/*#__PURE__*/t(al,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(LC,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(id,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e(od,{children:["This will allow ",l.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/t(oc,{children:"pending_approval"===b?.status?/*#__PURE__*/t(sm,{url:b.signer_approval_url,size:275,squareLogoElement:$u}):/*#__PURE__*/t(Os,{})}),/*#__PURE__*/e(ac,{children:[/*#__PURE__*/t(od,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===b?.status&&/*#__PURE__*/t(Yu,{text:b.signer_approval_url,itemName:"link",color:UC})]})]})}),/*#__PURE__*/t(el,{})]})}};let LC=/*#__PURE__*/vn.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;"]),RC=/*#__PURE__*/vn.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e8f76e5-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const FC={component:()=>{let{closePrivyModal:r}=Pt();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(DC,{children:/*#__PURE__*/t(nr,{style:{width:32,height:32}})}),/*#__PURE__*/t(mh,{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(rc,{children:/*#__PURE__*/t(Bs,{onClick:()=>r(),children:"Close"})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}};let DC=/*#__PURE__*/vn.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 BC={component:()=>{let{app:r}=qo();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(gh,{title:"Connect your email",description:`Add your email to your ${r?.name} account`,icon:/*#__PURE__*/t(Gn,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(rc,{children:/*#__PURE__*/t(ry,{stacked:!0})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}},zC={component:()=>{let{app:r,currentScreen:a,data:i,navigate:o,setModalData:s}=qo(),{initLoginWithSms:l}=Pt();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(gh,{title:"Connect your phone",description:`Add your number to your ${r?.name} account`,icon:/*#__PURE__*/t(In,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/t(rc,{children:/*#__PURE__*/t(Mm,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await l({phoneNumber:e,withPrivyUi:!0}),o(Vg)}catch(e){s({errorModalData:{error:e,previousScreen:i?.errorModalData?.previousScreen||a||zC}}),o(su)}},hideRecent:!0})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}},$C={component:()=>{let{app:r,data:a}=qo(),i=a?.externalConnectWallet?.suggestedAddress,o=a?.externalConnectWallet?.description??(i?/*#__PURE__*/e("span",{children:["Link the wallet with address ",/*#__PURE__*/t(Zp,{showCopyIcon:!1,address:i})," ",r?.name?`to ${r.name}.`:"."]}):`Link a wallet to your ${r?.name} account`),{connectors:s}=Pt(),l=Sg({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(al,{},"header"),l.length>0&&/*#__PURE__*/t(mh,{title:"Link your wallet",description:o}),/*#__PURE__*/t(As,{children:/*#__PURE__*/t(Eg,{wallets:l})}),/*#__PURE__*/t(Xs,{})]})}},jC=({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"})]}),VC={component:()=>{let{closePrivyModal:r}=Pt(),{navigate:a}=qo();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(jC,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/t(mh,{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(rc,{children:[/*#__PURE__*/t(Bs,{onClick:()=>a(dy),children:"Try again"}),/*#__PURE__*/t(Hs,{onClick:()=>r(),children:"Cancel"})]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}};function HC(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenroll:o,enrollInMfa:s}=l(rn);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 qC=n=>/*#__PURE__*/e(KC,{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 KC=/*#__PURE__*/vn.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 ZC=({showIntro:r,userMfaMethods:a,appMfaMethods:i,userHasAuthSms:o,isTotpLoading:s,isPasskeyLoading:l,error:c,onClose:d,onBackToIntro:h,handleSelectMethod:p,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(al,{backFn:r?h:void 0,onClose:d},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(_n,{})}),/*#__PURE__*/t(id,{children:"Choose a verification method"}),a.length>0?/*#__PURE__*/t(od,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/t(od,{children:"How would you like to verify your identity? You can change this later."}),c&&/*#__PURE__*/t(bd,{style:{marginTop:"1.25rem"},children:c.message}),/*#__PURE__*/e(pd,{children:[(g.totp||m.totp)&&/*#__PURE__*/e(ud,{children:[/*#__PURE__*/t(Ss,{style:{justifyContent:"center"},disabled:m.totp||s,onClick:()=>p("totp"),children:s?/*#__PURE__*/t(Os,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(fd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(xn,{}),"Authenticator app"]}),m.totp?/*#__PURE__*/t(YC,{color:"green",children:"Enabled"}):/*#__PURE__*/t(yd,{children:"Recommended"})]})}),m.totp&&/*#__PURE__*/t(md,{style:{position:"absolute",right:0},onClick:()=>u("totp"),children:/*#__PURE__*/t(Ur,{})})]},"totp"),(g.sms||m.sms)&&/*#__PURE__*/e(ud,{children:[/*#__PURE__*/t(Ss,{disabled:m.sms||o,onClick:()=>p("sms"),children:/*#__PURE__*/e(fd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(In,{}),"SMS"]}),m.sms&&/*#__PURE__*/t(YC,{color:"green",children:"Enabled"}),o&&/*#__PURE__*/t(yd,{children:"Disabled"})]})}),m.sms&&/*#__PURE__*/t(md,{style:{position:"absolute",right:0},onClick:()=>u("sms"),children:/*#__PURE__*/t(Ur,{})})]},"sms"),(g.passkey||m.passkey)&&/*#__PURE__*/e(ud,{children:[/*#__PURE__*/t(Ss,{style:{justifyContent:"center"},onClick:()=>p("passkey"),disabled:m.passkey||l,children:l?/*#__PURE__*/t(Os,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(fd,{children:[/*#__PURE__*/e(gd,{children:[/*#__PURE__*/t(An,{}),"Passkey"]}),m.passkey?/*#__PURE__*/t(YC,{color:"green",children:"Enabled"}):/*#__PURE__*/t(yd,{isAccent:!0,children:/*#__PURE__*/t(lr,{})})]})}),m.passkey&&/*#__PURE__*/t(md,{style:{position:"absolute",right:0},onClick:()=>u("passkey"),children:/*#__PURE__*/t(Ur,{})})]},"passkey")]}),/*#__PURE__*/t(el,{})]})};let YC=/*#__PURE__*/vn(Bu).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const GC=({appName:e,onComplete:n,onClose:r,onReset:a})=>{let{user:i}=nn(),{data:l}=qo(),{initLinkWithPasskey:c,linkWithPasskey:d}=Pt(),{initEnrollmentWithPasskey:h,submitEnrollmentWithPasskey:p}=HC(),[u,m]=o(!1),[g,y]=o(!1),[f,w]=o(!1),[v,C]=o(null),b=s((()=>i?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[i]),k=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},T=async e=>{m(!0);try{await h(),await p({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),w(!0)}catch(e){C(e)}finally{m(!1)}},x=async()=>{y(!0),C(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await T(t)}catch(e){C(e)}finally{y(!1)}};return 0===b.length||g?/*#__PURE__*/t(JC,{onReset:a,onClose:r,onClick:x,isCreating:g}):f?/*#__PURE__*/t(XC,{appName:e,onClick:k,onClose:k}):v?/*#__PURE__*/t(lu,{error:v,backFn:()=>C(null),onClick:()=>C(null)}):/*#__PURE__*/t(QC,{passkeys:b,isSubmitting:u,isCreating:g,onReset:a,onClose:r,onSubmitEnrollment:()=>T(b.map((e=>e.credentialId))),onAddPasskey:x})};let JC=({onReset:r,onClose:a,onClick:i,isCreating:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{backFn:r,onClose:a},"header"),/*#__PURE__*/t(ad,{children:/*#__PURE__*/e(Df,{children:[/*#__PURE__*/t(Td,{}),/*#__PURE__*/t(km,{})]})}),/*#__PURE__*/t(id,{children:"Set up passkey verification"}),/*#__PURE__*/e(ld,{children:[/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(_n,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(Nr,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(Or,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/t(Bs,{style:{marginTop:"2.25rem"},onClick:i,loading:o,children:"Add a new passkey"}),/*#__PURE__*/t(el,{})]}),QC=({onReset:r,onClose:a,onAddPasskey:i,onSubmitEnrollment:s,passkeys:l,isSubmitting:c,isCreating:d})=>{let[h,p]=o(!1),u=h?l.length:l.length>3?2:3;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{backFn:h?()=>p(!1):r,onClose:a},"header"),!h&&/*#__PURE__*/t(ad,{children:/*#__PURE__*/e(Df,{children:[/*#__PURE__*/t(Td,{}),/*#__PURE__*/t(km,{})]})}),/*#__PURE__*/t(id,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e(ld,{children:[l.slice(0,u).map((n=>/*#__PURE__*/e(eb,{children:[/*#__PURE__*/t(tb,{children:rb(n)}),/*#__PURE__*/e(nb,{children:["Last used: ",n.latestVerifiedAt?.toLocaleString()]})]},n.credentialId))),!h&&l.length>3&&/*#__PURE__*/t(ab,{onClick:()=>p(!0),children:"View All"})]}),/*#__PURE__*/t(Bs,{style:{marginTop:"1.5rem"},onClick:s,loading:c,children:"Enable passkeys"}),l.length<5&&/*#__PURE__*/t(ab,{style:{marginTop:"0.5rem"},onClick:i,disabled:d,children:d?/*#__PURE__*/t(Os,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/t(el,{})]})},XC=({appName:r,onClick:a,onClose:i})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{onClose:i},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(vr,{})}),/*#__PURE__*/t(id,{children:"Passkey verification added"}),/*#__PURE__*/e(od,{children:["From now on, you'll use the passkey whenever you use your ",r," wallet."]}),/*#__PURE__*/t(hd,{children:/*#__PURE__*/t(Bs,{onClick:a,children:"Done"})}),/*#__PURE__*/t(el,{})]}),eb=/*#__PURE__*/vn.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%;}"]),tb=/*#__PURE__*/vn.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);"]),nb=/*#__PURE__*/vn.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);"]),rb=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 ab=/*#__PURE__*/vn.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;}}"]),ib=({appName:r,onComplete:a,onReset:i,onClose:s})=>{let[l,c]=o(""),[d,h]=o(!1),[p,u]=o(null),[m,g]=o("enroll"),{initEnrollmentWithSms:y,submitEnrollmentWithSms:f}=HC(),{app:w,data:v}=qo();function C(){v?.mfaEnrollmentFlow?.onSuccess(),a()}return p?/*#__PURE__*/t(lu,{error:p,backFn:()=>u(null),onClick:()=>u(null)}):/*#__PURE__*/e(n,"enroll"===m?{children:[/*#__PURE__*/t(al,{backFn:i,onClose:s},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(In,{})}),/*#__PURE__*/t(id,{children:"Set up SMS verification"}),/*#__PURE__*/e(od,{children:["We'll text a verification code to this mobile device whenever you use your ",r," ","wallet."]}),/*#__PURE__*/e(sd,{children:[/*#__PURE__*/t(Mm,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await y({phoneNumber:e}),c(e),g("verify")}catch(e){u(e)}},hideRecent:!0}),/*#__PURE__*/e(wd,{children:["By providing your mobile number, you agree to receive text messages from ",w?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/t(el,{})]}:d?{children:[/*#__PURE__*/t(al,{onClose:C},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(vr,{})}),/*#__PURE__*/t(id,{children:"SMS verification added"}),/*#__PURE__*/e(od,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",r," wallet."]}),/*#__PURE__*/t(hd,{children:/*#__PURE__*/t(Bs,{onClick:C,children:"Done"})}),/*#__PURE__*/t(el,{})]}:{children:[/*#__PURE__*/t(al,{backFn:function(){"verify"===m?g("enroll"):i()},onClose:s},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(In,{})}),/*#__PURE__*/t(id,{children:"Enter enrollment code"}),/*#__PURE__*/e(sd,{children:[/*#__PURE__*/t(yl,{onChange:async function(e){try{if(!e)return;await f({phoneNumber:l,mfaCode:e}),h(!0)}catch(e){if(td(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Xc(e))throw Error("The code you entered is not valid");if(Qc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw nd(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e(od,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/t("strong",{children:de(l)})]})]}),/*#__PURE__*/t(el,{})]})},ob=({size:e,authUrl:n})=>/*#__PURE__*/t(sm,{url:n,squareLogoElement:Lr,size:e,fgColor:"#1F1F1F"}),sb=({onComplete:r,onClose:a,onReset:i,totpInfo:s})=>{let[l,c]=o("enroll"),[d,h]=o(!1),{submitEnrollmentWithTotp:p}=HC(),{data:u}=qo();function m(){u?.mfaEnrollmentFlow?.onSuccess(),r()}/*#__PURE__*/return e(n,"enroll"===l?{children:[/*#__PURE__*/t(al,{backFn:i,onClose:a},"header"),/*#__PURE__*/t(id,{children:"Scan QR code"}),/*#__PURE__*/t(od,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/t(oc,{children:/*#__PURE__*/t(ob,{authUrl:s.authUrl,size:200})}),/*#__PURE__*/e(hd,{children:[/*#__PURE__*/t(ac,{children:/*#__PURE__*/t(Yu,{itemName:"setup key",text:s.secret})}),/*#__PURE__*/t(Bs,{onClick:function(){c("verify")},children:"Continue"})]}),/*#__PURE__*/t(el,{})]}:d?{children:[/*#__PURE__*/t(al,{onClose:m},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(vr,{})}),/*#__PURE__*/t(id,{children:"Authenticator app verification added"}),/*#__PURE__*/e(od,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",s.appName," wallet."]}),/*#__PURE__*/t(hd,{children:/*#__PURE__*/t(Bs,{onClick:m,children:"Done"})}),/*#__PURE__*/t(el,{})]}:{children:[/*#__PURE__*/t(al,{backFn:function(){"verify"===l?c("enroll"):i()},onClose:a},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(xn,{})}),/*#__PURE__*/t(id,{children:"Enter enrollment code"}),/*#__PURE__*/t(sd,{children:/*#__PURE__*/t(yl,{onChange:async function(e){try{if(!e)return;await p({mfaCode:e}),h(!0)}catch(e){if(td(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Xc(e))throw Error("The code you entered is not valid");if(Qc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw nd(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e(od,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),/*#__PURE__*/t(el,{})]})},lb={component:()=>{let{user:r,enrollInMfa:a,ready:i}=nn(),[s,l]=o(null),{unenrollWithSms:c,unenrollWithTotp:h,unenrollWithPasskey:p}=HC(),{app:u,data:m,onUserCloseViaDialogOrKeybindRef:g}=qo(),{closePrivyModal:y}=Pt(),{promptMfa:f}=rd(),{initEnrollmentWithTotp:w}=HC(),[v,C]=o(!1),[b,k]=o(null),[T,x]=o(null),A=()=>{y({shouldCallAuthOnSuccess:!0}),a(!1),setTimeout((()=>{l(null),k(null)}),500)},{initEnrollmentWithPasskey:I,submitEnrollmentWithPasskey:_}=HC(),[E,S]=o(!1),[N,M]=o(null);g.current=A;let P=r?.mfaMethods.includes("sms"),W=!!r?.phone,U=r?.mfaMethods.includes("totp"),O=r?.mfaMethods.includes("passkey"),L=P||U||O,R=r?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function F(){l(null),k(null)}if(d((()=>{L&&C(!0)}),[L]),!i||!r||!u/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(al,{onClose:A},"header"),/*#__PURE__*/t(ad,{children:/*#__PURE__*/t(qC,{})}),/*#__PURE__*/t(sd,{children:/*#__PURE__*/t(Os,{})}),/*#__PURE__*/t(el,{})]});if("sms"===s)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{backFn:F,onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Sn,{})}),/*#__PURE__*/t(id,{children:"Remove SMS verification?"}),/*#__PURE__*/e(od,{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(hd,{children:/*#__PURE__*/t(Bs,{warn:!0,onClick:async function(){l(null);try{await c()}catch(e){l(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/t(el,{})]});if("totp"===s)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{backFn:F,onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Sn,{})}),/*#__PURE__*/t(id,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e(od,{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(hd,{children:/*#__PURE__*/t(Bs,{warn:!0,onClick:async function(){l(null);try{await h()}catch(e){l(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/t(el,{})]});if("passkey"===s){let r=m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{backFn:F,onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Sn,{})}),/*#__PURE__*/t(id,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/t(od,{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(hd,{children:/*#__PURE__*/t(Bs,{warn:!0,onClick:async function(){l(null);try{await p({removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){l(null)}},children:"Yes, remove"})}),/*#__PURE__*/t(el,{})]})}if(0===m.mfaEnrollmentFlow.mfaMethods.length&&!L)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(_n,{})}),/*#__PURE__*/t(id,{children:"Add more security"}),/*#__PURE__*/e(od,{children:[u?.name," does not have any verification methods enabled."]}),/*#__PURE__*/t(hd,{children:/*#__PURE__*/t(Bs,{onClick:A,children:"Close"})}),/*#__PURE__*/t(el,{})]});let D=!L&&!v;return D?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{onClose:A},"header"),/*#__PURE__*/t(Cd,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(_n,{})}),/*#__PURE__*/t(id,{children:"Transaction Protection"}),/*#__PURE__*/t(od,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e(ld,{children:[/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(Pr,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),/*#__PURE__*/e(dd,{children:[/*#__PURE__*/t(cd,{children:/*#__PURE__*/t(Wr,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e(hd,{children:[/*#__PURE__*/t(Bs,{onClick:()=>C(!0),children:"Continue"}),/*#__PURE__*/t(Hs,{onClick:A,children:"Not now"})]}),/*#__PURE__*/t(el,{})]}):"sms"===b?/*#__PURE__*/t(ib,{appName:u?.name||"Privy",onComplete:A,onReset:F,onClose:A}):"totp"===b&&T?/*#__PURE__*/t(sb,{onComplete:A,onClose:A,onReset:F,totpInfo:{...T,appName:u?.name||"Privy"}}):"passkey"===b?/*#__PURE__*/t(GC,{appName:u?.name||"Privy",onComplete:A,onReset:F,onClose:A}):/*#__PURE__*/t(ZC,{showIntro:D,userMfaMethods:r.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:W,onBackToIntro:function(){C(!1)},handleSelectMethod:async function(e){return await f().catch(M),"totp"===e?(k(e),x(null),void w().then((e=>{x(e)})).catch((()=>{x(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"===b&&!T,isPasskeyLoading:E,error:N,onClose:A,setRemovingMfaMethod:async e=>{await f().catch(M),l(e)}})}},cb={component:()=>{let{authenticated:r,logout:a,ready:i,user:s}=nn(),{app:l,setModalData:c,navigate:h,resetNavigation:p}=qo(),{getAuthMeta:u,initLoginWithOAuth:m,loginWithOAuth:g,updateWallets:y,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v}=Pt(),[C,b]=o(!1),[k,T]=o(void 0),x=u()?.provider||"google",{name:A,component:I}=li(x);d((()=>{g(x).then((()=>{b(!0),f(!0)})).catch((e=>{if(f(!1),e?.privyErrorCode===Te.ALLOWLIST_REJECTED)return T(void 0),p(),void h(lm);if(e?.privyErrorCode===Te.USER_LIMIT_REACHED)return console.error(new _t(e).toString()),T(void 0),p(),void h(pm);if(e?.privyErrorCode===Te.USER_DOES_NOT_EXIST)return T(void 0),p(),void h(Vp);if(e?.privyErrorCode===Te.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return T(void 0),p(),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 h(Tu);let{retryable:t,detail:n}=function(e,t){let n={detail:"",retryable:!1},r=Ga(t);if(e?.privyErrorCode===Te.LINKED_TO_ANOTHER_USER&&(n.detail="This account has already been linked to another user."),e?.privyErrorCode===Te.INVALID_CREDENTIALS&&(n.retryable=!0,n.detail="Something went wrong. Try again."),e.privyErrorCode===Te.OAUTH_USER_DENIED&&(n.detail=`Retry and check ${r} to finish connecting your account.`,n.retryable=!0),e?.privyErrorCode===Te.TOO_MANY_REQUESTS&&(n.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===Te.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=li(t).name;n.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===Te.OAUTH_ACCOUNT_SUSPENDED){let e=li(t).name;n.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===Te.CANNOT_LINK_MORE_OF_TYPE&&(n.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===Te.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(n.detail="Something went wrong. Please try again."),n}(e,x);T({retryable:t,detail:n,message:"Authentication failed"})})).finally((()=>{di()}))}),[A,x]),d((()=>{if(i&&r&&C&&s){if(l?.legal.requireUsersAcceptTerms&&!s.hasAcceptedTerms){let e=setTimeout((()=>{h(Wu)}),wa);return()=>clearTimeout(e)}if($p(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:x,screen:"OAuthStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(Mu)}),wa);return()=>clearTimeout(e)}{let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),wa);return y(),()=>clearTimeout(e)}}}),[i,r,C,s]);let _=C?`Successfully connected with ${A}`:k?k.message:`Verifying connection to ${A}`,E="";return E=C?"You’re good to go!":k?k.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{}),/*#__PURE__*/t(hc,{}),/*#__PURE__*/e(db,{children:[/*#__PURE__*/t(kd,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Us,{success:C,fail:!!k}),/*#__PURE__*/t(I,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(cc,{children:[/*#__PURE__*/t("h3",{children:_}),/*#__PURE__*/t("p",{children:E})]}),k&&k?.retryable?/*#__PURE__*/t(Ks,{onClick:()=>{di(),m(x),T(void 0)},disabled:!C&&!k?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(el,{})]})}};let db=/*#__PURE__*/vn.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 hb=/*#__PURE__*/u(((r,a)=>{let[i,s]=o(""),[l,c]=o(""),[d,h]=o(!1),{authenticated:p,user:u}=nn(),{initUpdateEmail:m}=Pt(),{navigate:g,setModalData:y,currentScreen:f}=qo(),{enabled:w,token:v}=ki(),C=$o(),b=Yr(i)&&(C.disablePlusEmails&&i.includes("+")?(l||c("Please enter a valid email address without a '+'."),!1):(l&&c(""),!0)),k=d||!b,T=()=>{!w||v||p?(async e=>{if(!u?.email)throw Error("User is required to have an email address to update it.");h(!0);try{await m({oldAddress:u.email.address,newAddress:i,captchaToken:e}),g(Vg)}catch(e){y({errorModalData:{error:e,previousScreen:f||dy}})}h(!1)})(v):(y({captchaModalData:{callback:e=>{if(!u?.email)throw Error("User is required to have an email address to update it.");return m({oldAddress:u.email.address,newAddress:i,captchaToken:e})},userIntentRequired:!1,onSuccessNavigateTo:Vg,onErrorNavigateTo:su}}),g(Hu))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(pb,{children:[l&&/*#__PURE__*/t(Qg,{style:{marginTop:"0.25rem",textAlign:"left"},children:l}),/*#__PURE__*/e(ub,{$error:!!l,children:[/*#__PURE__*/t(Gn,{}),/*#__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&&T()},value:i,autoComplete:"email"}),r.stacked?null:/*#__PURE__*/t(Zs,{isSubmitting:d,onClick:T,disabled:k,children:"Submit"})]})]}),r.stacked?/*#__PURE__*/t(Bs,{loadingText:null,loading:d,disabled:k,onClick:T,children:"Submit"}):null]})}));let pb=ny,ub=ey;const mb={component:()=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(gh,{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(Gn,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(rc,{children:/*#__PURE__*/t(hb,{stacked:!0})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})},gb={component:()=>{let{currentScreen:r,data:a,navigate:i,setModalData:o}=qo(),{user:s}=nn(),{initUpdatePhone:l}=Pt();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(al,{},"header"),/*#__PURE__*/t(hc,{}),/*#__PURE__*/t(gh,{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(In,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(rc,{children:/*#__PURE__*/t(Mm,{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(Vg)}catch(e){o({errorModalData:{error:e,previousScreen:a?.errorModalData?.previousScreen||r||zC}}),i(su)}},hideRecent:!0})}),/*#__PURE__*/t(pc,{}),/*#__PURE__*/t(Xs,{})]})}};function yb({subscribe:e,getExternalJwt:t,enabled:n=!0,onAuthenticated:r,onUnauthenticated:a,onError:s}){let{client:l,onCustomAuthAuthenticated:c}=Pt(),{logout:h,authenticated:p,ready:u}=Ky();if(!l)throw new he("`useSyncJwtBasedAuthState` must be used within a `PrivyProvider`");let[m,g]=o({status:"initial"}),y=i(),f=i(!1),w=i(t);d((()=>{w.current=t}),[t]);let v=i(r);d((()=>{v.current=r}),[r]);let C=i(a);d((()=>{C.current=a}),[a]);let b=i(s);return d((()=>{b.current=s}),[s]),d((()=>{if(!n||!u)return;let t=async()=>{if(!f.current){f.current=!0;try{g({status:"loading"});let e=await w.current();if(void 0!==y.current&&y.current===e)return void g({status:"done"});if(!e)return p&&(await h(),C.current?.()),y.current=e,void g({status:"done"});l.startAuthFlow(new ts(e));let{user:t,isNewUser:n=!1}=await l.authenticate();if(!t)throw new he("Failed to sync with custom auth provider");v.current?.({user:t,isNewUser:n}),c(t,n),y.current=e,g({status:"done"})}catch(e){if(console.warn(e),await h().catch((()=>{})),C.current?.(),e instanceof Ke&&e.privyErrorCode===Te.LINKED_TO_ANOTHER_USER)return g({status:"initial"}),void setTimeout((()=>{t()}),0);b.current?.(e),g({status:"error",error:e})}finally{f.current=!1}}};return t(),e(t)}),[e,l,c,p,h,n,u]),n?{state:m}:{state:{status:"not-enabled"}}}let fb=Hn((()=>({jwtAuthFlowState:{status:"not-enabled"}})));const wb=()=>fb((e=>e.jwtAuthFlowState));function vb({customAuth:e}){let{jwtAuthFlowState:t}=function({customAuth:e}){let t=bs(),n=i(),r=h((e=>(n.current=e,()=>{n.current=void 0})),[]),a=e?.getCustomAccessToken??(()=>Promise.resolve(void 0)),{state:o}=yb({enabled:!0===e?.enabled,subscribe:r,getExternalJwt:a,onAuthenticated:({user:e,isNewUser:n})=>{t("login","onComplete",{user:e,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),t("customAuth","onAuthenticated",{user:e})},onUnauthenticated:()=>{t("customAuth","onUnauthenticated")},onError:e=>{t("login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR)}});return d((()=>{(async()=>{e&&!e.isLoading&&n.current?.()})()}),[e?.enabled,e?.getCustomAccessToken,e?.isLoading]),{jwtAuthFlowState:o}}({customAuth:e});return d((()=>{fb.setState({jwtAuthFlowState:t})}),[t]),null}const Cb=/*#__PURE__*/c(!1);let bb,kb,Tb,xb,Ab,Ib,_b;function Eb(){return bb?bb.getCustomerAccessToken():Promise.resolve(jr.get(ka)||null)}async function Sb(){return bb?bb.getAccessToken():Promise.resolve(jr.get(Aa)||jr.get(ka)||null)}const Nb=(e,t)=>kb(e,t),Mb=(e,t)=>Tb(e,t),Pb=(e,t)=>xb(e,t),Wb=(e,t)=>Ab(e,t),Ub=e=>Ib(e),Ob=e=>_b(e),Lb=({config:e,...n})=>{var r;if((()=>{if(l(Cb))throw new he("Multiple PrivyProvider instances found","Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree.")})(),"undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new he("Embedded wallet is only available over HTTPS");if("string"!=typeof(r=n.appId)||25!==r.length)throw new he("Cannot initialize the Privy provider with an invalid Privy app ID");bb||(bb=new ps({appId:n.appId,appClientId:n.clientId,apiUrl:n.apiUrl}));let a=Object.assign({},e),i=s((()=>new T({appId:n.appId,clientId:n.clientId,storage:jr,baseUrl:n.apiUrl,sdkVersion:"react-auth:2.16.0"})),[]);/*#__PURE__*/
|
|
27
|
+
return t(zo,{client:i,legacyClient:bb,clientConfig:a,children:/*#__PURE__*/t(Km,{children:/*#__PURE__*/t(Rb,{...n,client:bb,privy:i})})})};let Rb=n=>{let a=n.client,l=n.privy,c=Ym();nh();let[p,u]=o(!1),[m,g]=o(!1),[y,f]=o(!1),[T,x]=o(null),[A,_]=o([]),[E,S]=o([]),[N,M]=o(!1),[P,W]=o(null),[U,O]=o(!1),[L,R]=o({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:Nt}),[F,D]=o({status:"initial"}),[B,z]=o({status:"initial"}),[$,j]=o({status:"initial"}),[V,H]=o({status:"initial"}),[q,K]=o({status:"initial"}),[Z,Y]=o({status:"initial"}),[G,J]=o(null),Q=$o(),X=jo(),[ee,te]=o({}),[ne,re]=o(null),ae=i(null),[ie,oe]=o(!1),[se,le]=o(!1),ce=i(null),de=i(null),pe=i(ys),[me,ge]=o(!1);a.onStoreCustomerAccessToken=e=>{e&&Cs(pe,"accessToken","onAccessTokenGranted",{accessToken:e})},a.onDeleteCustomerAccessToken=()=>{x(null),f(!1),Cs(pe,"accessToken","onAccessTokenRemoved")};let ye=i(null),we=i(null),ve=i(!1),Ce=({showWalletUIs:e})=>ve.current?ve.current:void 0!==e?!e:!Q.embeddedWallets.showWalletUIs,be=e=>{W(e),setTimeout((()=>{u(!0)}),15)};d((()=>{if(!T)return void a.connectors?.removeEmbeddedWalletConnectors();let e=on(T),t=pn(T),r=cn(T);e&&t.length||a.connectors?.removeEmbeddedWalletConnectors(),r||a.connectors?.removeImportedWalletConnector(),a.connectors?G?(e&&a.connectors.addEmbeddedWalletConnectors({walletProxy:G,user:T,embeddedWallets:t,defaultChain:Q.defaultChain,appId:n.appId,privyClient:l}),r&&a.connectors.addImportedWalletConnector(G,r.address,Q.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")}),[G,T]),d((()=>{G&&ae.current?.(G)}),[G]);let ke=h(((e,t)=>{x(e),M(t),f(!0),le(!0)}),[]);d((()=>{se&&G&&T&&(async()=>{let e=Fp(T,Q.embeddedWallets.ethereum.createOnLogin),t=Bp(T,Q.embeddedWallets.solana.createOnLogin),n=await Sb();if(n){if(e&&t){let e=await G.create({accessToken:n});return await G.createSolana({accessToken:n,ethereumAddress:e?.address}),void le(!1)}if(t)return await G.createSolana({accessToken:n,ethereumAddress:on(T)?.address}),await Ve.refreshSessionAndUser(),void le(!1);if(e)return await G.create({accessToken:n}),void le(!1)}})().catch(console.error)}),[se&&G&&T]),d((()=>{if(Q.externalWallets.solana.connectors)return Q.externalWallets.solana.connectors.onMount(),()=>Q.externalWallets.solana.connectors?.onUnmount()}),[Q.externalWallets.solana.connectors]),d((()=>{!m&&X&&async function(){let e,t=xe(),n=Ie(),i=r();a.initializeConnectorManager({walletConnectCloudProjectId:Q.walletConnectCloudProjectId,rpcConfig:Q.rpcConfig,chains:Q.chains,defaultChain:Q.defaultChain,store:i,walletList:Q.appearance.walletList,shouldEnforceDefaultChainOnConnect:Q.shouldEnforceDefaultChainOnConnect,externalWalletConfig:Q.externalWallets,appName:Q.name??"Privy",walletChainType:Q.appearance.walletChainType,appKit:Q.externalWallets.walletConnect.appKit}),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?ge(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:n,expected:t}),ge(!0)}),1500)})),a.connectors?.initialize().then((()=>{Me()}));let o=await a.getAuthenticatedUser(),s=!!o;Q.legal.requireUsersAcceptTerms&&o&&!o.hasAcceptedTerms?(await a.logout(),Ve.setReadyToTrue(!0),Cs(pe,"logout","onSuccess")):(Q.customAuth?.enabled||(f(!!o),o&&Cs(pe,"login","onComplete",{user:o,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),x(o)),t?we.current=s?"link":"login":n&&!s?(we.current="login",te({telegramAuthModalData:{seamlessAuth:!0}}),be(Dm)):Ve.setReadyToTrue(!!o))}()}),[a,ne,m,X]),d((()=>{if(m){if(!T||!T.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType)))return void oe(!!G);if([...A].some((e=>"privy"===e.walletClientType)))return void oe(!0);oe(!!G)}}),[m,T,A,G]),d((()=>{a.connectors?.setWalletList(Q.appearance.walletList)}),[Q.appearance.walletList.join()]);let xe=()=>{let e=ci();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(ah).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(a.startAuthFlow(new Ya(e)),be(cb),!0))},Ie=()=>{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())}())?(Ii(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=Ai(e.replace("#tgWebAppData=","")),{user:n,auth_date:r,hash:a}=t;return n&&r&&a?t:void 0}())?(Ii(),{flowType:"web-app",authData:e}):void 0}();if(!e||!Q.loginMethods.telegram||!Q.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new Ti;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},_e=async(e,t,n,r)=>{if("solana_adapter"!==e)Ee(await(a.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,n,r);else{let e=a.connectors?.findSolanaWalletConnector(t);if(!e)return;Ee(e,t,n,r)}};async function Ee(e,t,n,r){if(!e)return R({status:"disconnected",connectedWallet:null,connectError:new fe("Unable to connect to wallet."),connector:null,connectRetry:Nt}),r?.(null,n);R({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:Nt}),e instanceof Zo&&t&&await e.resetConnection(t),R({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Ee(e,t,n,r)});try{let t=await e.connect({showPrompt:!0});if((!t||Fi(t))&&Q.shouldEnforceDefaultChainOnConnect&&!Q.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){R((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:Nt})));try{await(t?.switchChain(Q.defaultChain.id)),t&&(t.chainId=aa(C(Q.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${Q.defaultChain.id}`)}}return R((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:Nt}))),t&&Cs(pe,"connectWallet","onSuccess",{wallet:t}),r?.(t,n)}catch(e){return e instanceof Le?(console.warn(e.cause?e.cause:e.message),Cs(pe,"connectWallet","onError",e.privyErrorCode||Te.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),Cs(pe,"connectWallet","onError",Te.UNKNOWN_CONNECT_WALLET_ERROR)),R((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),r?.(null,n)}}let Se=async(e,t,n)=>{if(null===e||!Fi(e))return;let r=new ui(a,e,t,n);a.startAuthFlow(r)},Ne=async(e,t,n,r="plain")=>{let i=c(Gm);if("transaction"===r&&!i)throw new he("useSolanaLedger plugin hook must be mounted");if(null===e||!fo(e))return;let o=new yi(e,a,t,n,r,i?{deserializeTransactionFromB64String:i.deserializeTransactionFromB64String,prepareSiwsTransactionWithMemo:i.prepareSiwsTransactionWithMemo}:void 0);a.startAuthFlow(o)},Me=()=>{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=po({connectorType:t,walletClientType:n});if(!i||!i.isInstalled)return be(VC);if(!a.connectors)throw new he("Connector not initialized");be(r?dg:og);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),_e(t,n,void 0,r?void 0:"solana_adapter"===t?Ne:Se)};d((()=>{m&&y&&null===T&&a.getAuthenticatedUser().then(x)}),[m,y,T,a]);let Pe=e=>{if(!y)throw Cs(pe,"linkAccount","onError",Te.MUST_BE_AUTHENTICATED,{linkMethod:e}),new he("User must be authenticated before linking an account.")},We=e=>{if(!y||!T)return!1;if("privy"===e.walletClientType)return!0;for(let t of T.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 he("Connector not initialized");t="ethereum"===e.type?a.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:a.connectors.findSolanaWalletConnector(e.walletClientType)||null,R((n=>({...n,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:Nt}))),Q.captchaEnabled&&!y?(te({captchaModalData:{callback:t=>Fi(e)?Se(e,t):Ne(e,t),userIntentRequired:!1,onSuccessNavigateTo:og,onErrorNavigateTo:su}}),be(Hu)):(Fi(e)?await Se(e):await Ne(e),be(og))},Oe=()=>{_((e=>{let t=a.connectors?.wallets.filter(Fi).map((e=>({...e,linked:We(e),loginOrLink:async()=>{if(!await e.isConnected())throw new he("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new he("Cannot link or login with embedded wallet");Ue(e)},fund:async t=>{await Ve.fundWallet(e.address,t)},unlink:async()=>{if(!y)throw new he("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new he("Cannot unlink an embedded wallet");x(await a.unlinkEthereumWallet(e.address))}})))||[];return Di(e,t)?e:t})),S((e=>{let t=(a.connectors?.wallets??[]).filter(fo).map((e=>({...e,linked:We(e),loginOrLink:async()=>{if(!await e.isConnected())throw new he("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new he("Cannot link or login with embedded wallet");Ue(e)},fund:async()=>{throw new he("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!y)throw new he("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new he("Cannot unlink an embedded wallet");x(await a.unlinkSolanaWallet(e.address))}})));return Di(e,t)?e:t}))};d((()=>{Oe()}),[T?.linkedAccounts,y,m]),d((()=>{if(m){if(!a.connectors)throw new he("Connector not initialized");Oe(),a.connectors.on("walletsUpdated",Oe)}}),[m]),d((()=>{[...Q.loginMethodsAndOrder?.primary??[],...Q.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>a.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!a]);let Re=({transaction:e,uiOptions:t,fundWalletConfig:r,address:i,signOnly:o})=>new Promise((async(s,c)=>{let{requesterAppId:d}=t||{},h=o?"signTransaction":"sendTransaction",p=i?sn(T,i):on(T);if(!p&&i){let t=un(A,i);if(t)try{let n=await t.getEthereumProvider(),r={...e,from:i,chainId:e.chainId||Number(t.chainId.replace("eip155:","")),value:void 0!==e.value?C(e.value):void 0},a=await n.request({method:"sendTransaction"===h?"eth_sendTransaction":"eth_signTransaction",params:[r]});return Cs(pe,h,"onSuccess",{hash:a}),void s({hash:a})}catch(e){return Cs(pe,h,"onError",Te.TRANSACTION_FAILURE),void c(e??new Li("Unable to "+h+e))}}if(!p)return Cs(pe,h,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),void c(new he("No embedded or connected wallet found for address."));if(!y||!T)return Cs(pe,h,"onError",Te.MUST_BE_AUTHENTICATED),void c(Error("User must be authenticated before signing with a Privy wallet"));let u=p.address,m=p.walletIndex??0,{entropyId:g,entropyIdVerifier:f}=Ni(T,p),w=He.wallets.find((e=>"privy"===e.walletClientType&&v(e.address)===v(u)));if(!w)return Cs(pe,h,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have a Privy wallet before signing"));let b=await w.getEthereumProvider(),x=await b.request({method:"eth_chainId"}),_=e.chainId?Number(e.chainId):rh(x);(e=>{if(!Q.chains.map((e=>e.id)).includes(e))throw new fe(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,Te.UNSUPPORTED_CHAIN_ID)})(_);let E={...e,from:e.from??u,chainId:_},S=await Sb();if(!S||!G)return Cs(pe,h,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),void c(Error("Must have valid access token and Privy wallet to send transaction"));let N=Kr(E.chainId,Q.chains,Q.rpcConfig,{appId:n.appId}),M=en(p),P=async()=>{try{let e;if(!await Ve.recoverEmbeddedWallet({address:u}))throw Cs(pe,h,"onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),c(Error("Unable to connect to wallet")),Error("Unable to connect to wallet");let t=o?E:await Hc(E,N,E.from);if(M){let n=e=>null==e?void 0:C(e),r=await I(l,(async({message:e})=>await G.signWithUserSigner({accessToken:S,requesterAppId:d,message:e})),{chain_type:"ethereum",method:"eth_signTransaction",params:{transaction:{from:t.from,to:t.to,nonce:n(t.nonce),chain_id:n(t.chainId),data:k(t.data)?t.data?t.data:C(Uint8Array.from(t.data)):void 0,value:n(t.value),type:t.type,gas_limit:n(t.gasLimit??t.gas),gas_price:n(t.gasPrice??t.gas),max_fee_per_gas:n(t.maxFeePerGas),max_priority_fee_per_gas:n(t.maxPriorityFeePerGas)}},wallet_id:p.id});if(!r.data||!("signed_transaction"in r.data))throw new Li("Unable to sign transaction");e=r.data.signed_transaction}else e=await th({accessToken:S,entropyId:g,entropyIdVerifier:f,transactingWalletIndex:m,walletProxy:G,transactionRequest:t,requesterAppId:d});if(o)return Cs(pe,"signTransaction","onSuccess",{signature:e}),e;{let t=await N.sendRawTransaction({serializedTransaction:e});return Cs(pe,"sendTransaction","onSuccess",{hash:t}),t}}catch(e){throw Cs(pe,h,"onError",Te.TRANSACTION_FAILURE),e}};if(Ce({showWalletUIs:t?.showWalletUIs}))P().then((e=>{o?Cs(pe,"signTransaction","onSuccess",{signature:e}):Cs(pe,"sendTransaction","onSuccess",{hash:e}),s({hash:e})})).catch((e=>{Cs(pe,h,"onError",Te.TRANSACTION_FAILURE),c(e)}));else{let e={connectingWalletAddress:u,recoveryMethod:p.recoveryMethod,entropyId:g,entropyIdVerifier:f,onCompleteNavigateTo:vC,isUnifiedWallet:M,onFailure:e=>{Cs(pe,h,"onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),c(e)}},n=Yy(Q)?Fw({address:u,appConfig:Q,fundWalletConfig:r,methodScreen:Pw,chainIdOverride:E.chainId,comingFromSendTransactionScreen:!0}):void 0;te({connectWallet:e,sendTransaction:{transactionRequest:E,transactingWalletIndex:m,transactingWalletAddress:u,entropyId:g,entropyIdVerifier:f,signOnly:o,scanTransaction:async()=>{let e=await Hc(E,N,E.from);return await a.scanTransaction({metadata:{domain:Q.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}]}})},onConfirm:()=>P(),onSuccess:e=>{o?Cs(pe,"signTransaction","onSuccess",{signature:e.hash}):Cs(pe,"sendTransaction","onSuccess",{hash:e.hash}),s(e)},onFailure:e=>{Cs(pe,h,"onError",Te.TRANSACTION_FAILURE),c(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:d},funding:n}),be(Kw)}}));function Fe(){return new Promise((async(e,t)=>{let n=await Sb();if(!n||!G)throw Error("Must have valid access token to enroll in MFA");try{await G.verifyMfa({accessToken:n}),e()}catch(e){t(e)}}))}let De=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],Be=e=>{let t=T?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:n,loginMethod:r}=Ip(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw Cs(pe,"linkAccount","onError",Te.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:r}),new he(`User already has an account of type ${n} linked.`)};async function ze({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){W(null);let n=t?"setWalletPassword":"setWalletRecovery";if(!y||!T)throw Cs(pe,n,"onError",Te.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let r=Xt(T);if(!r||!G)throw Cs(pe,n,"onError",Te.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");let a=en(r);if(a)throw Cs(pe,n,"onError",Te.UNSUPPORTED_WALLET_TYPE),new he("User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");try{await Fe()}catch(e){throw Cs(pe,n,"onError",Te.MISSING_MFA_CREDENTIALS),e}return new Promise(((i,o)=>{let s="user-passcode"===r.recoveryMethod,l=xy({walletAction:"update",availableRecoveryMethods:Q.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:s,showAutomaticRecovery:e}),{entropyId:c,entropyIdVerifier:d}=Ni(T),h={recoveryMethod:r.recoveryMethod,connectingWalletAddress:r.address,onCompleteNavigateTo:l,shouldForceMFA:!1,entropyId:c,isUnifiedWallet:a,entropyIdVerifier:d,onFailure:e=>{Cs(pe,n,"onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),o(e)}};te({setWalletPassword:{onSuccess:e=>{Cs(pe,n,"onSuccess",{method:"user-passcode",wallet:e}),i(e)},onFailure:e=>{Cs(pe,n,"onError",Te.USER_EXITED_SET_PASSWORD_FLOW),o(e)},callAuthOnSuccessOnClose:!1},recoverWallet:{entropyId:c,entropyIdVerifier:d,onFailure:o},connectWallet:h,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:s,shouldCreateEth:!1,shouldCreateSol:!1}}),be(Kw)}))}async function $e({appId:e,action:t}){let n=await Sb();if("link"===t&&!n)throw Cs(pe,"linkAccount","onError",Te.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new he("User must be authenticated before linking an account.");if("login"===t&&n)throw Cs(pe,"login","onError",Te.UNKNOWN_AUTH_ERROR),new he("Attempted to log in, but user is already logged in. Use a `link` helper instead.");ye.current=`privy:${e}`,we.current=t;let r=lh();return a.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,i)=>{let{name:o,logoUrl:s}=await sh({api:a.api,providerAppId:e,requesterAppId:Q.id});te({crossAppAuth:{appId:e,name:o,logoUrl:s,action:t,popup:r,onSuccess:n,onError:i}}),be(_C)}))}let je={ready:m,authenticated:y,user:T,walletConnectors:a.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),te({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType,description:e?.description}}),be(y?xC:AC)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),Pe("siwe"),ye.current="siwe",we.current="link",te({...ee,externalConnectWallet:{...ee.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),be($C)},startCrossAppAuthFlow:$e,linkEmail:()=>{Pe("email"),Be("email"),ye.current="email",we.current="link",be(BC)},linkPhone:()=>{Pe("sms"),Be("phone"),ye.current="sms",we.current="link",be(zC)},linkGoogle:async()=>{Pe("google"),Be("google_oauth"),we.current="link",await Ve.initLoginWithOAuth("google")},linkTwitter:async()=>{Pe("twitter"),Be("twitter_oauth"),we.current="link",await Ve.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Pe("discord"),Be("discord_oauth"),we.current="link",await Ve.initLoginWithOAuth("discord")},linkGithub:async()=>{Pe("github"),Be("github_oauth"),we.current="link",await Ve.initLoginWithOAuth("github")},linkSpotify:async()=>{Pe("spotify"),Be("spotify_oauth"),we.current="link",await Ve.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Pe("instagram"),Be("instagram_oauth"),we.current="link",await Ve.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Pe("tiktok"),Be("tiktok_oauth"),we.current="link",await Ve.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Pe("linkedin"),Be("linkedin_oauth"),we.current="link",await Ve.initLoginWithOAuth("linkedin")},linkApple:async()=>{Pe("apple"),Be("apple_oauth"),we.current="link",await Ve.initLoginWithOAuth("apple")},linkPasskey:async()=>{Pe("passkey"),Be("passkey"),await Ve.initLinkWithPasskey(),be(Ff)},linkTelegram:async e=>{if(Pe("telegram"),Be("telegram"),we.current="link",ye.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new Ti;a.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=Ai(e.launchParams.initDataRaw),te({telegramAuthModalData:{seamlessAuth:!0}}),be(Dm)}else Cs(pe,"linkAccount","onError",Te.INVALID_DATA,{linkMethod:"telegram"});else await Ve.initLoginWithTelegram();be(Dm)},linkFarcaster:async()=>{Pe("farcaster"),Be("farcaster"),await Ve.initLoginWithFarcaster(),we.current="link",ye.current="farcaster",be(fm)},updateEmail:()=>{if(Pe("email"),!T?.email)throw new he("User does not have an email linked to their account.");we.current="update",ye.current="email",be(mb)},updatePhone:()=>{if(Pe("sms"),!T?.phone)throw new he("User does not have a phone number linked to their account.");we.current="update",ye.current="sms",be(gb)},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(!m){let e=await new Promise((e=>{re((t=>e.bind(t)))}));if(re(null),e)return void console.warn(t)}!T||T.isGuest?(we.current="login",te({login:e}),be(dy)):console.warn(t)},connectOrCreateWallet:async()=>{m||(await new Promise((e=>{re((()=>e))})),re(null)),y?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(we.current="connect-or-create",be(Fg))},logout:async()=>{if(we.current=null,ye.current=null,T&&a.clearProviderAcccessTokens(T),W(null),await a.logout(),T&&G)try{await G.clearMfa({userId:T.id})}catch(e){}x(null),f(!1),Cs(pe,"logout","onSuccess"),u(!1),jr.del(Sa),jr.del(Na(Q.id))},getAccessToken:h((()=>a.getCustomerAccessToken()),[a]),unlinkWallet:async e=>{let t;return x(t=e.startsWith("0x")?await a.unlinkEthereumWallet(e):await a.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await a.unlinkEmail(e);return x(t),t},unlinkPhone:async e=>{let t=await a.unlinkPhone(e);return x(t),t},unlinkGoogle:async e=>{let t=await a.unlinkOAuth("google",e);return x(t),t},unlinkTwitter:async e=>{let t=await a.unlinkOAuth("twitter",e);return x(t),t},unlinkDiscord:async e=>{let t=await a.unlinkOAuth("discord",e);return x(t),t},unlinkGithub:async e=>{let t=await a.unlinkOAuth("github",e);return x(t),t},unlinkSpotify:async e=>{let t=await a.unlinkOAuth("spotify",e);return x(t),t},unlinkInstagram:async e=>{let t=await a.unlinkOAuth("instagram",e);return x(t),t},unlinkTiktok:async e=>{let t=await a.unlinkOAuth("tiktok",e);return x(t),t},unlinkLinkedIn:async e=>{let t=await a.unlinkOAuth("linkedin",e);return x(t),t},unlinkApple:async e=>{let t=await a.unlinkOAuth("apple",e);return x(t),t},unlinkFarcaster:async e=>{let t=await a.unlinkFarcaster(e);return x(t),t},unlinkTelegram:async e=>{let t=await a.unlinkTelegram(e);return x(t),t},unlinkPasskey:async e=>{let t=await Sb();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!G)throw Error("Wallet proxy not initialized.");let n=Q.passkeys.shouldUnenrollMfaOnUnlink;await G.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:n});let r=await a.getAuthenticatedUser();return x(r),r},unlinkCrossAppAccount:async({subject:e})=>{let t=T?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new he("Invalid subject");a.storeProviderAccessToken(t.id,null);let n=await a.unlinkOAuth(`privy:${t.id}`,e);return x(n),n},setWalletRecovery:async e=>ze({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>ze({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=e.message,s=t?.address?sn(T,t.address):on(T);if(!s&&void 0!==t?.address){let e=un(A,t.address);if(e)try{let t=await e.getEthereumProvider(),r=await t.request({method:"personal_sign",params:[o,e.address]});return Cs(pe,"signMessage","onSuccess",{signature:r}),void n({signature:r})}catch(e){return Cs(pe,"signMessage","onError",Te.UNABLE_TO_SIGN),void r(e??new Li("Unable to sign message"))}}if(!s)throw new he("No embedded or connected wallet found for address.");if(!y||!T)return Cs(pe,"signMessage","onError",Te.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let c=s.address,d=s.walletIndex??0,{entropyId:h,entropyIdVerifier:p}=Ni(T,s),u=en(s);if("string"!=typeof o||o.length<1)return Cs(pe,"signMessage","onError",Te.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));let m=async()=>{let t;if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let n=await Sb();if(!G||!n||!await Ve.recoverEmbeddedWallet({address:c}))throw Error("Unable to connect to wallet");if(a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:c,requesterAppId:i}}),u){let r=k(e.message,{strict:!0}),a=await I(l,(async({message:e})=>await G.signWithUserSigner({accessToken:n,requesterAppId:i,message:e})),{chain_type:"ethereum",method:"personal_sign",params:r?{message:o.slice(2),encoding:"hex"}:{message:o,encoding:"utf-8"},wallet_id:s.id});if(!a.data||!("signature"in a.data))throw new Li("Unable to sign message");t=a.data.signature}else{let{response:e}=await G.rpc({accessToken:n,entropyId:h,entropyIdVerifier:p,chainType:"ethereum",hdWalletIndex:d,requesterAppId:i,request:{method:"personal_sign",params:[o,c]}});t=e.data}return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:c,requesterAppId:i}}),t};if(Ce({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await m();Cs(pe,"signMessage","onSuccess",{signature:e}),n({signature:e})}catch(e){Cs(pe,"signMessage","onError",Te.UNABLE_TO_SIGN),r(e??new Li("Unable to sign message"))}else te({signMessage:{method:"personal_sign",data:o,confirmAndSign:m,onSuccess:e=>{Cs(pe,"signMessage","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{Cs(pe,"signMessage","onError",Te.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:s.recoveryMethod,connectingWalletAddress:c,entropyId:h,entropyIdVerifier:p,onCompleteNavigateTo:$v,isUnifiedWallet:u,onFailure:e=>{Cs(pe,"signMessage","onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),be(Kw)})),signTypedData:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=t?.address?sn(T,t.address):on(T);if(!o&&t?.address){let a=un(A,t.address);if(a)try{let t=await a.getEthereumProvider(),r=oa(e),i=await t.request({method:"eth_signTypedData_v4",params:[a.address,r]});return Cs(pe,"signTypedData","onSuccess",{signature:i}),void n({signature:i})}catch(e){return Cs(pe,"signTypedData","onError",Te.UNABLE_TO_SIGN),void r(e??new Li("Unable to sign typed data "+e))}}if(!o)throw new he("No embedded or connected wallet found for address.");if(!y||!T)return Cs(pe,"signTypedData","onError",Te.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let s=o.address,c=o.walletIndex??0,{entropyId:d,entropyIdVerifier:h}=Ni(T,o),p=en(o),u=oa(e),m=async()=>{let e;if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let t=await Sb();if(!G||!t||!await Ve.recoverEmbeddedWallet({address:s}))throw Error("Unable to connect to wallet");if(a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:s,requesterAppId:i}}),p){let{domain:n,types:r,primaryType:a,message:s}=u,c=await I(l,(async({message:e})=>await G.signWithUserSigner({accessToken:t,requesterAppId:i,message:e})),{chain_type:"ethereum",method:"eth_signTypedData_v4",params:{typed_data:{domain:n,types:r,primary_type:a,message:s}},wallet_id:o.id});if(!c.data||!("signature"in c.data))throw new Li("Unable to sign message");e=c.data.signature}else{let{response:n}=await G.rpc({accessToken:t,entropyId:d,entropyIdVerifier:h,chainType:"ethereum",hdWalletIndex:c,requesterAppId:i,request:{method:"eth_signTypedData_v4",params:[s,u]}});e=n.data}return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:s,requesterAppId:i}}),e};if(Ce({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await m();Cs(pe,"signTypedData","onSuccess",{signature:e}),n({signature:e})}catch(e){Cs(pe,"signTypedData","onError",Te.UNABLE_TO_SIGN),r(e??new Li("Unable to sign message"))}else te({signMessage:{method:"eth_signTypedData_v4",data:u,confirmAndSign:m,onSuccess:e=>{Cs(pe,"signTypedData","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{Cs(pe,"signTypedData","onError",Te.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:o.recoveryMethod,connectingWalletAddress:o.address,entropyId:d,isUnifiedWallet:p,entropyIdVerifier:h,onCompleteNavigateTo:$v,onFailure:e=>{Cs(pe,"signMessage","onError",Te.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),be(Kw)})),sendTransaction:async(e,t)=>await Re({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await Re({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!y||!T)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?sn(T,e.address):on(T),o=Xt(T);if(!i||!o)return void r(new he("User must have an embedded wallet."));let s=i.address,{entropyId:l,entropyIdVerifier:c}=Ni(T,i),d=en(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(!b(s))return void r(Error("Must provide a valid Ethereum address."));let h={recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,isUnifiedWallet:d,entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:jw,onFailure:r,shouldForceMFA:!0};te(ee),await Sb()&&G?G?Jd(i)?(te({keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,address:i.address,entropyId:l,entropyIdVerifier:c,hdWalletIndex:i.walletIndex,chainType:i.chainType,walletId:i.id,isUnifiedWallet:d,imported:i.imported,onSuccess:t,onFailure:r},connectWallet:h}),be(Kw)):r(Error(`Export is not supported for ${i.chainType} wallets`)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:Fe,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 he("Invalid MFA code");ce.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{de.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new he("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));ce.current?.resolve({mfaMethod:e,mfaCode:r,relyingParty:window.origin}),await new Promise(((e,t)=>{de.current={resolve:e,reject:t}}));break;default:throw ce.current?.reject(new he("Unsupported MFA method")),new he(`Unsupported MFA method: ${e}`)}},cancel(){ce.current?.reject(new he("MFA canceled"))},async initEnrollmentWithSms(e){let t=await Sb();if(!t||!G)throw Error("Must have valid access token to enroll in MFA");await G.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,n)=>{if(!e)return Ve.closePrivyModal(),void t();Q.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."),te({mfaEnrollmentFlow:{mfaMethods:Q.mfa.methods,shouldUnlinkOnUnenrollMfa:Q.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:n}}),be(lb)})),async initEnrollmentWithTotp(){let e=await Sb();if(!e||!G)throw Error("Must have valid access token to enroll in MFA");let t=await G.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await Sb();if(!t||!G)throw Error("Must have valid access token to enroll in MFA");await G.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),x(await a.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await Sb();if(!t||!G)throw Error("Must have valid access token to enroll in MFA");await G.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),x(await a.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let n=await Sb();if(!n||!G)throw Error("Must have valid access token to enroll in MFA");await G.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:e,removeForLogin:t.removeForLogin}),x(await a.getAuthenticatedUser())},async unenroll(e,t={}){let n=await Sb();if(!n||!G)throw Error("Must have valid access token to remove MFA");"passkey"===e?await G.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:[],removeForLogin:t.removeForLogin}):await G.unenrollMfa({method:e,accessToken:n}),x(await a.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await Sb(),t=T?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!G||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(en(t))throw new he("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!T?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Ve.recoverEmbeddedWallet({address:t.address}))throw Error("Unable to connect to wallet");let n=await G.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===n.status&&x(await a.getAuthenticatedUser()||T||null),te({farcasterSigner:n}),be(OC)},getFarcasterSignerPublicKey:async()=>{let e,t=await Sb(),n=T?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!G||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(en(n))throw new he("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!T?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Ve.recoverEmbeddedWallet({address:n.address}))throw Error("Unable to connect to wallet");if(!T.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=T.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await Sb(),n=T?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!G||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(en(n))throw new he("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!T?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await Ve.recoverEmbeddedWallet({address:n.address}))throw Error("Unable to connect to wallet");if(!T.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let r=await import("@simplewebauthn/browser"),a=await G.signFarcasterMessage({address:n.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:r.bufferToBase64URLString(e)},fid:BigInt(T.farcaster.fid),relyingParty:window.origin});return new Uint8Array(r.base64URLStringToBuffer(a.signature))},signMessageWithCrossAppWallet(e,{address:t,chainId:n}){let r=T?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return dh({user:T,client:a,address:t,requesterAppId:Q.id,request:{method:r?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:n},reconnect:$e})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:n}){let r=T?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),i=oa(e);return dh({user:T,client:a,address:t,requesterAppId:Q.id,request:{method:r?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,i],chainId:n},reconnect:$e})},sendTransactionWithCrossAppWallet(e,{address:t}){let n=T?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return dh({user:T,client:a,address:t,requesterAppId:Q.id,request:{method:n?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:$e})},isModalOpen:p,mfaMethods:Q.mfa.methods};kb=je.signMessage,Tb=je.signTypedData,Ab=async(e,t)=>await Re({transaction:e,...t,signOnly:!1}),xb=async(e,t)=>({signature:(await Re({transaction:e,...t,signOnly:!0})).hash});let Ve={privy:l,setAuthenticated:f,setUser:x,setIsNewUser:M,isNewUserThisSession:N,pendingTransaction:null,walletConnectionStatus:L,connectors:a.connectors?.walletConnectors??[],solanaWallets:E,rpcConfig:Q.rpcConfig,chains:Q.chains,appId:n.appId,showFiatPrices:"native-token"!==Q.embeddedWallets.priceDisplay.primary,clientAnalyticsId:a.clientAnalyticsId,onCustomAuthAuthenticated:ke,hideWalletUIs:ve,isHeadlessSigning:h(Ce,[Q.embeddedWallets.showWalletUIs]),emailOtpState:B,setEmailOtpState:z,smsOtpState:$,setSmsOtpState:j,oAuthState:q,setOAuthState:K,telegramAuthState:Z,setTelegramAuthState:Y,siweState:V,setSiweState:H,isHeadlessOAuthLoading:U,nativeTokenSymbolForChainId:e=>Q.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(G)return G;let t=new Promise((e=>{ae.current=e})),n=new Promise((t=>setTimeout((()=>t(null)),e))),r=await Promise.race([t,n]);return ae.current=null,r},getAuthFlow:()=>a.authFlow,getAuthMeta:()=>a.authFlow?.meta,client:a,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=m&&y&&T;r&&ye.current&&(t=De(T)),"login"===we.current?e.shouldCallAuthOnSuccess&&r&&ye.current?Cs(pe,"login","onComplete",{user:T,isNewUser:N,wasAlreadyAuthenticated:!1,loginMethod:ye.current,loginAccount:t??null}):Cs(pe,"login","onError",Te.USER_EXITED_AUTH_FLOW):"link"===we.current&&t?e.isSuccess&&r&&ye.current?Cs(pe,"linkAccount","onSuccess",{user:T,linkMethod:ye.current,linkedAccount:t}):ye.current&&Cs(pe,"linkAccount","onError",Te.USER_EXITED_LINK_FLOW,{linkMethod:ye.current}):"update"===we.current&&t?e.isSuccess&&r&&ye.current?Cs(pe,"update","onSuccess",{user:T,updateMethod:ye.current,updatedAccount:t}):ye.current&&Cs(pe,"update","onError",Te.USER_EXITED_UPDATE_FLOW,{linkMethod:ye.current}):"connect-or-create"===we.current&&(A[0]?Cs(pe,"connectOrCreateWallet","onSuccess",{wallet:A[0]}):Cs(pe,"connectOrCreateWallet","onError",Te.USER_EXITED_AUTH_FLOW));let i=P&&kC.has(P),o=P===su&&ee.errorModalData&&kC.has(ee.errorModalData.previousScreen);if((i||o)&&ee.funding){let e,t=kC.get(P)??null;if("solana"===ee.funding.chainType){let n=c(Ry);if(n)try{e=BigInt(await n.getBalance({address:ee.funding.address,cluster:ee.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");Cs(pe,"fundSolanaWallet","onUserExited",{address:ee.funding.address,cluster:ee.funding.cluster,fundingMethod:t,balance:e})}else{let r=Kr(ee.funding.chain.id,Q.chains,Q.rpcConfig,{appId:n.appId});try{e=await r.getBalance({address:ee.funding.address})}catch{console.error("Unable to pull wallet balance")}Cs(pe,"fundWallet","onUserExited",{address:ee.funding.address,chain:ee.funding.chain,fundingMethod:t,balance:e})}}te({...ee,externalConnectWallet:{suggestedAddress:void 0}}),we.current=null,ye.current=null,M(!1),u(!1),setTimeout((()=>{a.authFlow=void 0}),200)},openPrivyModal:be,connectWallet:Ee,initLoginWithWallet:async(e,t,n,r)=>{Fi(e)?(ye.current="siwe",Se(e,t,n)):(ye.current="siws",Ne(e,t,n,r))},loginWithWallet:async()=>{let e,t,n;if(!m)throw new St;if(a.authFlow instanceof ui?e="siwe":a.authFlow instanceof yi&&(e="siws"),!e)throw new he("Must initialize SIWE/SIWS flow first.");if(null!==await a.getAccessToken())try{({user:t}=await a.link()),ye.current=e}catch(t){throw Cs(pe,"linkAccount","onError",t.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:n}=await a.authenticate()),ye.current=e}catch(e){throw Cs(pe,"login","onError",e.privyErrorCode||Te.GENERIC_CONNECT_WALLET_ERROR),e}x(t||T||null),M(n||!1),f(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:n})=>new Promise((async(r,a)=>{let i=await Sb();if(!y||!T||!i)throw new he("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new he("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=Ve.walletProxy??await Ve.initializeWalletProxy(15e3);if(!o)throw new he("Wallet proxy not initialized.");if((({address:e,user:t})=>!!eh(t).find((t=>t.address===e)))({address:e,user:T}))return r();let s=sn(T,e);if(!s)throw new he("Address to delegate is not associated with current user.");if(en(s))throw new he("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let l=Qd({address:e,user:T}),c=Xd({address:e,user:T}),d=async()=>{await o.createDelegatedAction({accessToken:i,rootWallet:c,delegatedWallets:[l]}),await Ve.refreshSessionAndUser()};if(await Ve.recoverEmbeddedWallet({address:e}),n)te({delegatedActions:{consent:{address:e,onDelegate:d,onSuccess:async()=>{r()},onError:async e=>{a(e)}}}}),be(SC);else try{await d(),r()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,n)=>{if(!y||!T)throw new he("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");let r=eh(T);if(0===r.length)throw new he("User has no delegated wallets to revoke.");if(r.some(en))throw new he("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let i=async()=>{await a.revokeDelegatedWallet(),await Ve.refreshSessionAndUser()};if(e)te({delegatedActions:{revoke:{onRevoke:i,onSuccess:async()=>{t()},onError:async e=>{n(e)}}}}),be(PC);else try{await i(),t()}catch(e){n(e)}})),initLoginWithFarcaster:async(e,t)=>{let n=new ya(e,t);a.startAuthFlow(n);try{ye.current="farcaster",await n.initializeFarcasterConnect()}catch(e){throw"login"===we.current?Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR):"link"===we.current&&Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!m)throw new St;if(!(a.authFlow instanceof ya))throw new he("Must initialize Farcaster flow first.");if(null!==await a.getAccessToken())try{({user:e}=await a.link()),ye.current="farcaster"}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await a.authenticate()),ye.current="farcaster"}catch(e){throw Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}x(e||null),M(t||!1),f(!0)},async crossAppAuthFlow({appId:e,popup:t,action:n}){let r=`privy:${e}`;ye.current=r;let{url:i,stateCode:o,codeVerifier:s}=await async function({api:e,appId:t}){let n=qa(),r=Ka(),a=await Za(n);try{let{url:i}=await e.post(Ae,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:r});return{url:i,stateCode:r,codeVerifier:n}}catch(e){throw ue(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 he("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 he("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 he("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 he(t.data.error)),i()),t.data.type===ih&&((r=new BroadcastChannel(ah)).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 he("Unexpected auth flow. This may be a phishing attempt.",void 0,Te.OAUTH_UNEXPECTED);let h=await async function({appId:e,stateCode:t,codeVerifier:n,authorizationCode:r,action:a,client:i}){if(!r||!t)throw new he("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===r)throw new he("User denied confirmation during cross-app auth flow");try{let o=new oh({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=ue(e);if(t.privyErrorCode)throw new he(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 he("Invalid code during cross-app auth flow.",void 0,Te.OAUTH_USER_DENIED);throw new he("Invalid code during cross-app auth flow.",void 0,Te.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:s,stateCode:c,authorizationCode:d,action:n,client:a});h&&a.storeProviderAccessToken(e,h);let p=await Ve.refreshSessionAndUser();if(!p)throw new he("Unable to update user");return a.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),p}catch(e){throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:r}}),e}},async initLoginWithOAuth(e,t,n){if(ye.current=e,!$r())return void be(FC);if("google"===e&&Vm(window.navigator.userAgent))return void be(FC);"twitter"===e&&window.opener&&window.opener.postMessage({type:ih},"*"),jr.del(Ua),jr.del(Oa);let r=new Ya({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(!m)throw new St;ye.current="telegram";let n=new Ti(e,t);a.startAuthFlow(n),Y({status:"loading"}),n.meta.telegramWebAppData=void 0,n.meta.telegramAuthResult=await new Promise(((e,t)=>Q.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:Q.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(n=>n?e(n):t(new he("Telegram auth failed or was canceled by the client")))):t(new he("Telegram was not initialized")):t(new he("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,n;if(!(a.authFlow instanceof Ti))throw new he("Must initialize Telegram flow before calling loginWithTelegram");a.authFlow.meta.captchaToken||=e?.captchaToken;let r=await Sb(),i=e?.intent||we.current;if("login"===i)try{let e=await a.authenticate();t=e.user,n=e.isNewUser,ye.current="telegram"}catch(e){throw Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}else{if("link"!==i)throw new he("Unknown auth intent");try{t=(await a.link()).user,ye.current="telegram"}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}x(t),M(n||!1),f(!0),Y({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:o}},async loginWithOAuth(e){let t,n,r;if(!(a.authFlow instanceof Ya))throw new he("Must initialize OAuth flow before calling loginWithOAuth");let i=jr.get(Pa),o=a.authFlow.meta.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:i??"",returnedStateCode:o??""}}),new he("Unexpected auth flow. This may be a phishing attempt.",void 0,Te.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{let n=await a.link();t=n.user,r=n.oAuthTokens,ye.current=e}catch(t){throw Cs(pe,"linkAccount","onError",t.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let i=await a.authenticate();t=i.user,n=i.isNewUser,r=i.oAuthTokens,ye.current=e}catch(t){throw"login"===we.current?Cs(pe,"login","onError",t.privyErrorCode||Te.UNKNOWN_AUTH_ERROR):"link"===we.current&&Cs(pe,"linkAccount","onError",t.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return x(t),M(n||!1),f(!0),r&&t&&Cs(pe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),r},passkeyAuthState:F,setPasskeyAuthState:D,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new hi({captchaToken:e,setPasskeyAuthState:D});a.startAuthFlow(n),we.current="login";try{ye.current="passkey",D({status:"generating-challenge"}),await n.initRegisterFlow(t),D({status:"awaiting-passkey"})}catch(e){throw D({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!m)throw new St;if(!(a.authFlow instanceof hi))throw new he("Must initialize Passkey flow first.");if("passkey"!==ye.current){let e=new he("Must init login with Passkey flow first.");throw D({status:"error",error:e}),e}let n=await Sb();try{ye.current="passkey",D({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await a.authenticate())}catch(e){throw D({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}x(e),M(t||!1),f(!0),D({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 hi({captchaToken:e,setPasskeyAuthState:D});a.startAuthFlow(n),we.current="login";try{ye.current="passkey",D({status:"generating-challenge"}),await n.initAuthenticationFlow(t),D({status:"awaiting-passkey"})}catch(e){throw D({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,n;if(!m)throw new St;if(!(a.authFlow instanceof hi))throw new he("Must initialize Passkey flow first.");if(e?.credentialIds&&(a.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==ye.current){let e=new he("Must init login with Passkey flow first.");throw D({status:"error",error:e}),e}let r=await Sb();try{ye.current="passkey",D({status:"awaiting-passkey"}),({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw D({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}x(t),M(n||!1),f(!0),D({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 hi({captchaToken:e});a.startAuthFlow(t),we.current="link",ye.current="passkey",D({status:"generating-challenge"});try{await t.initLinkFlow(),D({status:"awaiting-passkey"})}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),D({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!m)throw new St;if(!(a.authFlow instanceof hi))throw new he("Must initialize Passkey flow first.");if("passkey"!==ye.current)throw new he("Must init login with Passkey flow first.");try{ye.current="passkey",({user:e}=await a.link())}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return x(e||T||null),D({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,n){if(!$r())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&&Vm(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 Ya({provider:e,withPrivyUi:!1,disableSignup:n??!1});t&&r.addCaptchaToken(t),K({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),K({status:"loading"}),a.startAuthFlow(new Ya(e));let i=jr.get(Pa),o=e.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:i??"",returnedStateCode:o??""}}),O(!1),new he("Unexpected auth flow. This may be a phishing attempt.",void 0,Te.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{({user:t,oAuthTokens:r}=await a.link()),ye.current=e.provider;let n=De(t);t&&n&&Cs(pe,"linkAccount","onSuccess",{user:t,linkMethod:ye.current,linkedAccount:n})}catch(t){throw O(!1),Cs(pe,"linkAccount","onError",t.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:n,oAuthTokens:r}=await a.authenticate()),ye.current=e.provider;let i=De(t);t&&i&&void 0!==n&&Cs(pe,"login","onComplete",{user:t,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:ye.current,loginAccount:i})}catch(e){throw O(!1),K({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}return x(t),M(n||!1),f(!0),O(!1),K({status:"done"}),r&&t&&Cs(pe,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{let i=new Dr({email:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ye.current="email",z({status:"sending-code"}),await i.sendCodeEmail({withPrivyUi:r}),z({status:"awaiting-code-input"})}catch(e){throw z({status:"error",error:e}),"login"===we.current?Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR):"link"===we.current&&Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async({oldAddress:e,newAddress:t,captchaToken:n})=>{let r=new Br(e,t,n);a.startAuthFlow(r);try{await r.sendCodeEmail({withPrivyUi:!0})}catch(e){Cs(pe,"update","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR,{linkMethod:ye.current})}},initUpdatePhone:async(e,t,n)=>{let r=new wi(e,t,n);a.startAuthFlow(r);try{await r.sendSmsCode({withPrivyUi:!0})}catch(e){Cs(pe,"update","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR,{linkMethod:ye.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{j({status:"sending-code"});let i=new fi({phoneNumber:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ye.current="sms",await i.sendSmsCode({withPrivyUi:r}),j({status:"awaiting-code-input"})}catch(e){throw j({status:"error",error:e}),"login"===we.current?Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR):"link"===we.current&&Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.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 Dr?z(e):a.authFlow instanceof fi&&j(e)}if(r({status:"submitting-code"}),!m){let e=new St;throw r({status:"error",error:e}),e}if(a.authFlow instanceof Dr)a.authFlow.meta.emailCode=e.trim();else{if(!(a.authFlow instanceof fi)){let e=new he("Must initialize a passwordless code flow first");throw r({status:"error",error:e}),e}a.authFlow.meta.smsCode=e.trim()}let i=await Sb();if("link"===we.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:ye.current}),e}else if("update"===we.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),Cs(pe,"update","onError",e.privyErrorCode||Te.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:ye.current}),e}else try{({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw r({status:"error",error:e}),Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),e}let o=t||T;x(o||null),M(n||!1),f(!0),r({status:"done"});let s=null;return a.authFlow instanceof Dr?s=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:a.authFlow instanceof fi&&(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})=>{we.current=y?"link":"login",ye.current="siwe",H({status:"generating-message"});let r=await a.generateSiweNonce({address:e,captchaToken:n});return H({status:"awaiting-signature"}),pi({address:e,chainId:t.replace("eip155:",""),nonce:r})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let n=await a.generateSiweNonce({address:e});return pi({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}),x((r=await Ve.refreshSessionAndUser()??r)||T||null)},loginWithSiwe:async({message:e,signature:t,captchaToken:n,disableSignup:r})=>{let i,o=null;try{if(T)throw Error("User already authenticated");let s=new ui(a,void 0,n,r,{message:e,signature:t});a.startAuthFlow(s),ye.current="siwe",we.current="login",H({status:"submitting-signature"});let l=await a.authenticate();if(({user:o,isNewUser:i}=l),!o)throw Error("Authentication failed - no user returned")}catch(e){throw Cs(pe,"login","onError",e.privyErrorCode||Te.UNKNOWN_AUTH_ERROR),H({status:"error",error:e}),e}return x(o),M(i||!1),f(!0),H({status:"done"}),we.current=null,ye.current=null,o},linkWithSiwe:async({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i})=>{let o;Pe("siwe");let s=null;try{H({status:"submitting-signature"}),o=await a.linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i}),o=await Ve.refreshSessionAndUser()??o,H({status:"done"}),(s=De(o)||null)&&Cs(pe,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:s})}catch(e){throw Cs(pe,"linkAccount","onError",e.privyErrorCode||Te.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),we.current=null,ye.current=null,H({status:"error",error:e}),e}let l=o||T;return x(l||null),we.current=null,ye.current=null,{user:l,linkedAccount:s}},refreshSessionAndUser:async()=>{let e=await a.getAuthenticatedUser();return f(!!e),x(e),e},walletProxy:G,createAnalyticsEvent:({eventName:e,payload:t,timestamp:n})=>a.createAnalyticsEvent({eventName:e,payload:t,timestamp:n}),acceptTerms:async()=>{let e=await a.acceptTerms();return x(e),e},getUsdTokenPrice:e=>a.getUsdTokenPrice(e),getUsdPriceForSol:()=>a.getUsdPriceForSol(),getSplTokenMetadata:e=>a.getSplTokenMetadata(e),recoverEmbeddedWallet:async e=>new Promise((async(t,n)=>{if(!T)return void t(!0);let r=e?.address?sn(T,e.address):Xt(T)||cn(T)||ln(T);if(!r||en(r))return void t(!0);let i=await Sb();if(!i||!G||!r)return void n(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:o,entropyIdVerifier:s}=Ni(T,r);try{await G.connect({accessToken:i,entropyId:o,entropyIdVerifier:s}),t(!0)}catch(e){if(Jc(e)&&"privy"===r.recoveryMethod){let e;a.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:r.address}});try{e=await G.recover({entropyId:o,entropyIdVerifier:s,accessToken:i})}catch(e){return void n(e)}e.entropyId||n(Error("Unable to recover wallet")),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:r.address}}),t(!0)}else Jc(e)&&"privy"!==r.recoveryMethod&&"privy-v2"!==r.recoveryMethod?(te({recoverWallet:{entropyId:o,entropyIdVerifier:s,onFailure:n,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:r.recoveryMethod,action:"recover",shouldCreateEth:!1,shouldCreateSol:!1}}),be(Ay(r.recoveryMethod))):n(e)}})),exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!y||!T)return void r(Error("User must be authenticated before exporting their Privy wallet"));let i=e?.address?sn(T,e.address):an(T),o=Xt(T);if(!i||!o)return void r(new he("User must have an embedded wallet."));let{entropyId:s,entropyIdVerifier:l}=Ni(T,i);if(!i||!o)return void r(Error("Must have a Privy wallet before exporting"));let c=en(i);if(!await Sb()||!G)return void r(Error("Must have valid access token to enroll in MFA"));if(!G)return void r(Error("Must have a Privy wallet before exporting"));let d={recoveryMethod:i.recoveryMethod,connectingWalletAddress:i.address,isUnifiedWallet:c,entropyId:s,entropyIdVerifier:l,onCompleteNavigateTo:jw,onFailure:r,shouldForceMFA:!0};Jd(i)?(te({connectWallet:d,keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,address:i.address,entropyId:s,entropyIdVerifier:l,hdWalletIndex:i.walletIndex,chainType:i.chainType,walletId:i.id,isUnifiedWallet:c,imported:i.imported,onSuccess:t,onFailure:r}}),be(Kw)):r(Error(`Export is not supported for ${i.chainType} wallets`))})),setReadyToTrue:e=>{g(!0),ne?.(e)},updateWallets:()=>Oe(),fundWallet:async(e,t)=>{te({funding:Fw({address:e,appConfig:Q,fundWalletConfig:t,methodScreen:Pw})}),be(Pw)},openModal:be,requestFarcasterSignerStatus:async e=>{let t=await Sb(),n=T?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!G||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!T?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let r=await a.requestFarcasterSignerStatus(e);return"approved"===r.status&&x(await a.getAuthenticatedUser()||T||null),r},connectCoinbaseSmartWallet:async()=>{Q.externalWallets.coinbaseWallet.config.preference={...Q.externalWallets.coinbaseWallet.config.preference,options:"smartWalletOnly"};let e=a.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||a.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Ee(e);await _e("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 x(c),c},inProgressAuthFlowRef:we,inProgressLoginOrLinkMethodRef:ye};Ib=Ve.recoverEmbeddedWallet,_b=Ve.recoverEmbeddedWallet;let He=s((()=>({wallets:A,ready:ie&&me})),[A,ie,me]),qe=a.authFlow instanceof Ti,Ke=!Q.headless&&Q.captchaEnabled&&!y&&(m||qe);/*#__PURE__*/return t(Cb.Provider,{value:!0,children:/*#__PURE__*/t(rn.Provider,{value:je,children:/*#__PURE__*/t(fs.Provider,{value:pe,children:/*#__PURE__*/t(jc.Provider,{value:He,children:/*#__PURE__*/t(bi,{...Q,children:/*#__PURE__*/e(Wt.Provider,{value:Ve,children:[/*#__PURE__*/t(Ep,{children:/*#__PURE__*/e(Ho,{data:ee,setModalData:te,setInitialScreen:W,initialScreen:P,authenticated:y,open:p,children:[n.children,/*#__PURE__*/t(vb,{customAuth:Q.customAuth}),Ke&&/*#__PURE__*/t(ms,{delayedExecution:!1}),/*#__PURE__*/t(zd,{}),/*#__PURE__*/t(TC,{}),/*#__PURE__*/t(_d,{theme:{...Q.appearance.palette||{}}}),!Q.render.standalone&&/*#__PURE__*/t(Rd,{open:p})]})}),/*#__PURE__*/t(Gd,{appId:n.appId,appClientId:n.clientId,clientAnalyticsId:a.clientAnalyticsId,origin:a.apiUrl,mfaMethods:T?.mfaMethods,mfaPromise:ce,mfaSubmitPromise:de,onLoad:J,onLoadFailed:()=>null}),Q.loginConfig.telegramAuthConfiguration&&
|
|
28
|
+
/*#__PURE__*/t(Ms,{$if:!0,children:/*#__PURE__*/t(Bd,{scriptHost:n.apiUrl||fa,botUsername:Q.loginConfig.telegramAuthConfiguration.botName})})]})})})})})})};export{Xs as $,HC as A,Xc as B,Ci as C,ed as D,Vi as E,Qc as F,ns as G,ps as H,is as I,IC as J,ks as K,Hy as L,Zv as M,qy as N,Rd as O,Lb as P,Zu as Q,tf as R,Gr as S,Pp as T,Br as U,ba as V,Ba as W,Wy as X,Py as Y,Il as Z,gs as _,Ni as a,Rs as a0,Co as a1,by as a2,Cy as a3,ey as a4,cg as a5,sm as a6,Ko as a7,Bs as a8,wa as a9,$v as aA,Kw as aB,vC as aC,Fi as aa,fo as ab,rh as ac,nf as ad,Oy as ae,Tf as af,Ey as ag,hf as ah,ff as ai,Zp as aj,df as ak,jr as al,wo as am,Fy as an,Bl as ao,qo as ap,Pv as aq,Kv as ar,Wv as as,Zm as at,Gm as au,gi as av,mi as aw,Ry as ax,Dw as ay,Pw as az,ki as b,jo as c,ci as d,$o as e,bs as f,Sb as g,Vy as h,Fp as i,Bp as j,Vc as k,Zr as l,ts as m,wb as n,yb as o,sa as p,Qd as q,Xd as r,di as s,Eb as t,vs as u,ms as v,Yo as w,Bi as x,Ky as y,rd as z};
|