@privy-io/react-auth 2.6.0 → 2.6.1

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.
Files changed (25) hide show
  1. package/dist/cjs/abstract-smart-wallets.js +1 -1
  2. package/dist/cjs/{importWallet-D3s13-Ir.js → importWallet-CqIkwxB-.js} +1 -1
  3. package/dist/cjs/index.js +4 -4
  4. package/dist/cjs/{prepareFundingModalData-CT2XWfw3.js → prepareFundingModalData-BCNQSbXb.js} +1 -1
  5. package/dist/cjs/{smart-wallets-BggeovZV.js → smart-wallets-BJE1oUqH.js} +1 -1
  6. package/dist/cjs/smart-wallets.js +1 -1
  7. package/dist/cjs/solana.js +1 -1
  8. package/dist/cjs/ui.js +1 -1
  9. package/dist/cjs/{useActiveWallet-mT7IempW.js → useActiveWallet-CLPPplpC.js} +4 -4
  10. package/dist/cjs/{useFundWallet-C1OiqVXT.js → useFundWallet-BLEO3WzQ.js} +1 -1
  11. package/dist/cjs/{useWallets-qEcpULZl.js → useWallets-Dmyb5a0t.js} +1 -1
  12. package/dist/dts/index.d.mts +2 -1
  13. package/dist/dts/index.d.ts +2 -1
  14. package/dist/esm/abstract-smart-wallets.mjs +1 -1
  15. package/dist/esm/{importWallet-Db-TmI57.mjs → importWallet-CJLTGjPg.mjs} +1 -1
  16. package/dist/esm/index.mjs +21 -21
  17. package/dist/esm/{prepareFundingModalData-kNpmfOTp.mjs → prepareFundingModalData-due26ueW.mjs} +1 -1
  18. package/dist/esm/{smart-wallets-BF48FIHR.mjs → smart-wallets-dP5AzE1-.mjs} +1 -1
  19. package/dist/esm/smart-wallets.mjs +1 -1
  20. package/dist/esm/solana.mjs +1 -1
  21. package/dist/esm/ui.mjs +1 -1
  22. package/dist/esm/{useActiveWallet-C89-c9e3.mjs → useActiveWallet-C8nSK6cE.mjs} +3 -3
  23. package/dist/esm/{useFundWallet-DYXHQOzn.mjs → useFundWallet-DR5oafbj.mjs} +1 -1
  24. package/dist/esm/{useWallets-DhD2VeRF.mjs → useWallets-DTpjk5Rk.mjs} +1 -1
  25. package/package.json +2 -2
@@ -1,22 +1,22 @@
1
- import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createStore as r}from"mipd";import a,{useMemo as i,useEffect as o,useState as s,useRef as l,useCallback as c,useReducer as d,forwardRef as u,useContext as h,createContext as p}from"react";import*as m from"react-device-detect";import{isMobile as y,isIOS as f,isSafari as w,isAndroid as v}from"react-device-detect";import{getAddress as C,isAddress as E}from"viem/utils";import{P as T,f as b,a as A,b as _,c as k,d as I,e as N,u as x,g as S,h as R,i as O,j as M,n as P,k as L,I as D}from"./internal-context-mSHyF0Gq.mjs";import{c as U,p as F,a as B,b as z,u as H,f as V,d as $,e as j,g as G,h as q,o as K,i as Y,j as Z,k as J,l as Q,m as X,n as ee,q as te,r as ne,s as re,t as ie,v as oe,w as se,x as le,y as ce,z as de,A as ue,B as he,C as pe,D as me,E as ye,F as ge,G as fe,H as we,I as ve,J as Ce,K as Ee,L as Te,M as be,N as Ae,O as _e,P as ke,Q as Ie,R as Ne,S as xe,T as Se,U as Re,V as Oe,W as We,X as Me,Y as Pe,Z as Le,_ as De,$ as Ue,a0 as Fe,a1 as Be,a2 as ze,a3 as He,a4 as Ve,a5 as $e}from"./paths-Q47X90aK.mjs";import{o as je,R as Ge,C as qe,E as Ke,P as Ye,t as Ze,g as Je,a as Qe,B as Xe,d as et,i as tt,W as nt,b as rt,S as at,u as it,M as ot,c as st,A as lt,e as ct,f as dt,s as ut,H as ht,h as pt,F as mt,j as yt,k as gt,l as ft,m as wt,n as vt,p as Ct,T as Et,q as Tt,r as bt,v as At,w as _t,x as kt,y as It,z as Nt,D as xt,G as St,I as Rt,J as Ot,K as Wt,L as Mt,N as Pt,O as Lt,Q as Dt,U as Ut,V as Ft,X as Bt,Y as zt,Z as Ht,_ as Vt,$ as $t,a0 as jt,a1 as Gt,a2 as qt,a3 as Kt,a4 as Yt,a5 as Zt,a6 as Jt,a7 as Qt,a8 as Xt,a9 as en,aa as tn,ab as nn,ac as rn,ad as an,ae as on,af as sn,ag as ln,ah as cn,ai as dn,aj as un,ak as hn,al as pn,am as mn,an as yn,ao as gn,ap as fn,aq as wn,ar as vn,as as Cn,at as En,au as Tn,av as bn,aw as An,ax as _n,ay as kn,az as In,aA as Nn,aB as xn,aC as Sn,aD as Rn,aE as On,aF as Wn,aG as Mn}from"./useActiveWallet-C89-c9e3.mjs";export{aK as useActiveWallet,aI as useConnectWallet,aJ as useFundWallet,aH as useLogin}from"./useActiveWallet-C89-c9e3.mjs";import*as Pn from"jose";import{base64url as Ln}from"jose";import{g as Dn,C as Un,H as Fn,O as Bn,S as zn,D as Hn,a as Vn,b as $n,c as jn,d as Gn,V as qn,e as Kn,P as Yn,R as Zn,f as Jn,h as Qn,i as Xn,j as er,k as tr,l as nr,I as rr,m as ar,n as ir,o as or,p as sr,u as lr,M as cr,q as dr,r as ur,s as hr,t as pr,v as mr,w as yr,x as gr,W as fr,y as wr,z as vr,A as Cr,B as Er,E as Tr,F as br,G as Ar,J as _r,K as kr,L as Ir,N as Nr,Q as xr,T as Sr,U as Rr,X as Or,Y as Wr,Z as Mr,_ as Pr,$ as Lr,a0 as Dr,a1 as Ur,a2 as Fr,a3 as Br,a4 as zr,a5 as Hr,a6 as Vr,a7 as $r,a8 as jr,a9 as Gr,aa as qr,ab as Kr}from"./useWallets-DhD2VeRF.mjs";export{ac as SUPPORTED_CHAINS,ae as addPrivyRpcToChain,ad as addRpcUrlOverrideToChain}from"./useWallets-DhD2VeRF.mjs";import{e as Yr,i as Zr,f as Jr,S as Qr,a as Xr,l as ea,u as ta,C as na,b as ra,c as aa,O as ia,d as oa,g as sa,h as la,P as ca,j as da,k as ua,m as ha,n as pa,p as ma,o as ya,q as ga,r as fa,s as wa,t as va,v as Ca}from"./prepareFundingModalData-kNpmfOTp.mjs";export{W as WalletConnector}from"./prepareFundingModalData-kNpmfOTp.mjs";import{v4 as Ea}from"uuid";import Ta from"eventemitter3";import{CoinbaseWalletSDK as ba}from"@coinbase/wallet-sdk";import{isHex as Aa,toHex as _a,createPublicClient as ka,http as Ia,createWalletClient as Na,custom as xa,publicActions as Sa,formatUnits as Ra,parseEther as Oa,encodeFunctionData as Wa,isAddress as Ma,decodeFunctionData as Pa,decodeAbiParameters as La,formatEther as Da,hexToString as Ua,zeroAddress as Fa,getAddress as Ba,parseSignature as za}from"viem";import{g as Ha,a as Va}from"./getPublicClient-wHgCncHx.mjs";import{ofetch as $a}from"ofetch";import ja from"js-cookie";import{create as Ga}from"zustand";import{Turnstile as qa}from"@marsidev/react-turnstile";import{styled as Ka,css as Ya,createGlobalStyle as Za}from"styled-components";import Ja from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Qa from"@heroicons/react/24/outline/ExclamationTriangleIcon";import Xa from"@heroicons/react/24/outline/WalletIcon";import ei from"@heroicons/react/24/outline/ExclamationCircleIcon";import ti from"@heroicons/react/24/outline/Square2StackIcon";import ni from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import ri from"@heroicons/react/24/solid/DocumentCheckIcon";import ai from"@heroicons/react/20/solid/CheckIcon";import ii from"@heroicons/react/24/outline/EnvelopeIcon";import oi from"@heroicons/react/24/outline/PhoneIcon";import si from"@heroicons/react/24/solid/CheckCircleIcon";import li from"@heroicons/react/24/solid/XCircleIcon";import ci from"@heroicons/react/24/outline/CheckCircleIcon";import di from"@heroicons/react/24/outline/CloudArrowUpIcon";import ui from"@heroicons/react/24/outline/NoSymbolIcon";import hi from"fast-password-entropy";import*as pi from"secure-password-utilities";import{DEFAULT_WORDLIST as mi}from"secure-password-utilities/wordlists";import yi from"@heroicons/react/24/outline/ArrowPathIcon";import gi from"@heroicons/react/24/outline/EyeIcon";import fi from"@heroicons/react/24/outline/EyeSlashIcon";import wi from"@heroicons/react/24/outline/KeyIcon";import vi from"@heroicons/react/24/outline/ArrowDownTrayIcon";import Ci from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import Ei from"@heroicons/react/24/outline/DocumentDuplicateIcon";import Ti from"@heroicons/react/24/outline/UserCircleIcon";import bi from"@heroicons/react/24/solid/LockClosedIcon";import{formatWalletAddress as Ai,getCoinbaseOnRampUrl as _i,chainToMoonpayCurrency as ki,isSupportedChainIdForMoonpay as Ii,isSupportedChainIdForCoinbaseOnramp as Ni,formatTokenAmount as xi,formatWeiAmount as Si,countryCodesAndNumbers as Ri,validatePhoneNumber as Oi,phoneNumberTypingFormatter as Wi,getPlaceholderPhoneNumber as Mi,getCountryCallingCode as Pi,getPhoneCountryCodeAndNumber as Li,formatPhoneNumber as Di,toObjectKeys as Ui,lastFourDigits as Fi,SolanaClient as Bi,ProviderErrors as zi}from"@privy-io/js-sdk-core";import{Menu as Hi,MenuButton as Vi,MenuItems as $i,MenuItem as ji,Transition as Gi,Dialog as qi,TransitionChild as Ki,DialogPanel as Yi}from"@headlessui/react";import Zi from"@heroicons/react/24/outline/ChevronDownIcon";import Ji from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import Qi from"@heroicons/react/24/outline/CreditCardIcon";import Xi from"@heroicons/react/24/outline/QrCodeIcon";import eo from"@heroicons/react/24/outline/InformationCircleIcon";import to from"@heroicons/react/24/outline/ChevronRightIcon";import no from"@heroicons/react/24/outline/FingerPrintIcon";import ro from"@heroicons/react/24/outline/ClockIcon";import ao from"@heroicons/react/24/outline/TrashIcon";import io from"@heroicons/react/24/solid/CheckBadgeIcon";import oo from"@heroicons/react/24/outline/ShieldCheckIcon";import so from"@heroicons/react/24/solid/IdentificationIcon";import lo from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import co from"@heroicons/react/24/outline/MinusCircleIcon";import uo from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import ho from"@heroicons/react/24/solid/ShieldCheckIcon";import po from"@heroicons/react/24/outline/CalendarIcon";import mo from"@heroicons/react/24/outline/GlobeAltIcon";import yo from"@heroicons/react/24/outline/LockClosedIcon";import go from"@heroicons/react/24/outline/PencilSquareIcon";import{ChevronDownIcon as fo,ArrowRightIcon as wo}from"@heroicons/react/24/outline";import vo from"@heroicons/react/24/outline/ClipboardDocumentIcon";import{i as Co}from"./importWallet-Db-TmI57.mjs";import{eip7702Actions as Eo,hashAuthorization as To}from"viem/experimental";export{g as getEmbeddedConnectedWallet}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"zustand/shallow";import"zustand/traditional";import"tinycolor2";class bo{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(U,{token:this.meta.token})}catch(e){throw b(e)}}async link(){throw Error("Unimplemented")}constructor(e){this.meta={token:e}}}function Ao(e){return e?{"privy-ui":"t"}:void 0}class _o{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(F,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(B,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw b(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new T("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new T("Email must be set when initialzing authentication.");let r=Ao(n);try{return await this.api.post(z,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw b(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class ko extends _o{async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new T("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(H,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw b(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class Io{get meta(){return this._meta}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");try{let e=await this.api.post(V,{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 T("No response from authentication");return e}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post($,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw b(e)}}async _startChannelOnce(){if(!this.api)throw new T("Auth flow has no API instance");let e=await this.api.post(j,{token:this.captchaToken});y&&!f&&e.connect_uri&&je(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new T("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");let e=await this.api.get(G,{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 Ge(this._startChannelOnce.bind(this)),this.pollForReady=new Ge(this._pollForReady.bind(this)),this._meta.disableSignup=t}}function No(e){return crypto.getRandomValues(new Uint8Array(e))}class xo{getOrCreateGuestCredential(e){let t=Dn(e);if(Yr()){if(Zr.get(t))return Zr.get(t);{let e=Ln.encode(No(32));return Zr.put(t,e),e}}return Ln.encode(No(32))}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(q,{guest_credential:this.meta.guestCredential})}catch(e){throw b(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function So(){return Ln.encode(No(36))}function Ro(){return So()}async function Oo(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 Ln.encode(t)}}class Wo{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new T("User denied confirmation during OAuth flow");let e=function(){let e=Zr.get(Un);if(!e)throw new T("Authentication error.");return e}();try{let t=await this.api.post(K,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Zr.del(Un),Zr.del(Fn),Zr.del(Bn),t}catch(e){let t=b(e);if(t.privyErrorCode)throw new T(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new T("Invalid code during oauth flow.",void 0,A.OAUTH_USER_DENIED);throw new T("Invalid code during OAuth flow.",void 0,A.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new T("User denied confirmation during OAuth flow");let e=Zr.get(Un);if(!e)throw new T("Authentication error.");try{let t=await this.api.post(Y,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return Zr.del(Un),t}catch(e){throw b(e)}}async getAuthorizationUrl(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.provider)throw new T("Provider must be set when initializing OAuth authentication.");let e=So();Zr.put(Un,e);let t=Ro();Zr.put(zn,t);let n=await Oo(e);this.meta.withPrivyUi||Zr.put(Fn,!0),this.meta.disableSignup&&Zr.put(Bn,!0);let r=Ao(this.meta.withPrivyUi);try{return await this.api.post(Z,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...r}})}catch(e){throw b(e)}}constructor(e){this.meta=e}}function Mo(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Po=({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"})]}),Lo=({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"})})})]}),Do=({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"})}),Uo=({style:e})=>/*#__PURE__*/t(mo,{style:{color:"var(--privy-color-error)",...e}}),Fo=({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 Bo(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 zo({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 Ho(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 Vo(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 $o=({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 jo={google:{name:"Google",component:Fo},discord:{name:"Discord",component:Lo},github:{name:"Github",component:Do},linkedin:{name:"LinkedIn",component:zo},twitter:{name:"Twitter",component:$o},spotify:{name:"Spotify",component:Ho},instagram:{name:"Instagram",component:Bo},tiktok:{name:"Tiktok",component:Vo},apple:{name:"Apple",component:Po}};const Go=e=>e in jo?jo[e]:{name:"Unknown",component:Uo};function qo(){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:!Zr.get(Fn),popupFlow:null!==window.opener&&a,disableSignup:!!Zr.get(Bn)}}function Ko(){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"),Zr.del(zn),window.history.replaceState({},"",e)}class Yo{async initRegisterFlow(e){if(!this.api)throw new T("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 T("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new T("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 T("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new T("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(J,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new T("Passkey request timed out or rejected by user.",void 0,A.PASSKEY_NOT_ALLOWED);throw b(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new T("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new T("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(Q,{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 T("Passkey request timed out or rejected by user.",void 0,A.PASSKEY_NOT_ALLOWED);throw b(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new T("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new T("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(X,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new T("Passkey request timed out or rejected by user.",void 0,A.PASSKEY_NOT_ALLOWED);throw b(e)}}async _initRegisterOnce(e){if(!this.api)throw new T("Auth flow has no API instance");let t=Ao(e);return await this.api.post(ee,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new T("Auth flow has no API instance");let t=Ao(e);return await this.api.post(te,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new T("Auth flow has no API instance");return await this.api.post(ne,{})}_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 Ge(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new Ge(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Ge(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}class Zo{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(re,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(ie,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw b(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new T("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new T("phone nNumber must be set when initialzing authentication.");let r=Ao(n);try{return await this.api.post(oe,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw b(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:n}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:n??!1}}}class Jo extends Zo{async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new T("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(se,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw b(e)}}constructor(e,t,n){super({phoneNumber:t,captchaToken:n}),this.meta={phoneNumber:t,captchaToken:n,oldPhoneNumber:e,disableSignup:!1}}}class Qo{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(le,{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 b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(ce,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw b(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function Xo(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===A.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===A.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===A.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===A.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof qe&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function es(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function ts(){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 ns{static parse(e){try{return new ns(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return Pn.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=Pn.decodeJwt(e)}}class rs extends ns{static parse(e){try{return new rs(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}const as=({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"})]});let is,os=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],ss=(e,t)=>e.makeWeb3Provider({options:t});class ls extends Ke{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 _("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw Jr(e)}}updateConnectionPreference(e){this.connectionOptions=e,this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(ss(is,this.connectionOptions))}constructor(e,t,n,r,a,i){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Ye(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=r.coinbaseWallet.connectionOptions??"all",this.walletClientType="smartWalletOnly"===this.connectionOptions?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!is){let n=[t.id].concat(e.map((e=>e.id))),r="eoaOnly"!==this.connectionOptions?n.filter((e=>!os.includes(e))):[];r.length>0&&!r.every((e=>Hn.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${r.join(", ")}`),is=new ba({appName:a,appLogoUrl:i,appChainIds:n})}this.proxyProvider.setWalletProvider(ss(is,this.connectionOptions))}}const cs=({...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 ds extends Ke{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:[Ze(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:cs,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 us=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];let hs={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844"};const ps={legacy:0,eip2930:1,eip1559:2,eip4844:3};let ms=e=>void 0!==e?BigInt(e):void 0;function ys(e){let t,{type:n=2,...r}=e;r.accessList&&Array.isArray(r.accessList)?t=r.accessList.map((e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e)):r.accessList&&(t=Object.entries(r.accessList).map((e=>({address:e[0],storageKeys:e[1]}))));let a=Number(r.chainId??1),i=Aa(r.data)?r.data:r.data?_a(Uint8Array.from(r.data)):void 0,o=r.nonce?Number(r.nonce):void 0,s={chainId:a,data:i,nonce:o,value:ms(r.value),gas:ms(r.gas??r.gasLimit)},l=Number(n);if(0===l)return{...r,type:hs[l],...s,gasPrice:ms(r.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===l)return{...r,type:hs[l],...s,gasPrice:ms(r.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===l)return{...r,type:hs[l],...s,nonce:o,accessList:t,maxFeePerGas:ms(r.maxFeePerGas),maxPriorityFeePerGas:ms(r.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw new T(`Unsupported transaction type: ${n}`)}class gs extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}class fs extends Ta{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new gs(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await rw()||!this.address)throw new gs("Disconnected",4900);let{hash:n}=await sw(t,{address:this.address});return n}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new gs(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await rw()||!this.address)throw new gs("Disconnected",4900);let{signature:n}=await ow(t,{address:this.address});return n}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new gs(`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 gs(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Ha(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 aw({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 iw(Je(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:Ze(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...ys(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 Ze(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=>us.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await rw();if(await lw(),!t||!this.address)throw new gs("Disconnected",4900);try{return(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:{method:e.method,params:e.params}})).response.data}catch(e){throw console.error(e),new gs("Disconnected",4900)}}}constructor({walletProxy:e,address:t,entropyId:n,entropyIdVerifier:r,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l}){super(),this.walletProxy=e,this.address=t,this.entropyId=n,this.entropyIdVerifier=r,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Ha(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=Qe(a,"privy"),this.appId=o,this.walletIndex=l}}class ws extends Ke{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 Ye(void 0,Vn),this.id=e,this.name=t,this.icon=n,this.connectorType=r}}const vs=({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"})]}),Cs=({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 Es(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Ts=0;class bs extends Ke{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 _("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Jr(e)}}constructor(e,t,n,r,a){super(a||"unknown",e,t,n),this.connectorType="injected",this.proxyProvider=new Ye(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=r;let i=r.provider;this.proxyProvider.setWalletProvider(i)}}var As="__private_"+Ts+++"__walletBranding";class _s extends Ke{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 Es(this,As)[As]??{name:"Browser Extension",icon:Xe,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 _("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Jr(e)}}constructor(e,t,n,r,a){super(a??"unknown",e,t,n),Object.defineProperty(this,As,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Ye(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(r),"metamask"===a?Es(this,As)[As]={name:"MetaMask",icon:vs,id:"io.metamask"}:"phantom"===a&&(Es(this,As)[As]={name:"Phantom",icon:Cs,id:"phantom"})}}class ks extends bs{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{y||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 _("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Jr(e)}}}const Is=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","crypto.com_wallet_extension","crypto.com_onchain","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","privy","unknown","phantom","solflare","glow","backpack"],Ns=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=Ss({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=Ss({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=Ss({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="+Ss({client:this.client,isSolana:e,connectOnly:t}))}}});function xs({connectorType:e,walletClientType:t}){for(let n of Is)if(e===n||t===n)return Ns[n]}function Ss({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,""))}class Rs extends Qr{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 Ye(void 0,Vn),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}}class Os extends Ta{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)return;e&&this.removeAllConnectors(),Zr.get($n)&&(Zr.getKeys().forEach((e=>{e.startsWith("walletconnect")&&Zr.del(e)})),Zr.del($n));let t=et({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(Ns)))!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 Rs({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(tt).find((t=>t.connectorType===e))??null:this.walletConnectors.filter(tt).find((n=>n.connectorType===e&&n.walletClientType===t))??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(Xr).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.saveConnectionHistory(),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnectors({walletProxy:e,rootWallet:t,embeddedWallets:n,defaultChain:r,appId:a}){for(let i of n){let n=this.findEmbeddedWalletConnectors().find((e=>e.walletIndex===i.walletIndex));if(n&&tt(n))n.proxyProvider.walletProxy=e;else{let{entropyId:n,entropyIdVerifier:o}=jn(t),s=new ds({provider:new fs({walletProxy:e,address:i.address,entropyId:n,entropyIdVerifier:o,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:r.id,walletIndex:i.walletIndex}),chains:this.chains,defaultChain:r,rpcConfig:this.rpcConfig,imported:!1,walletIndex:i.walletIndex});this.addWalletConnector(s)}}}addImportedWalletConnector(e,t,n,r){let a=this.findWalletConnector("embedded_imported","privy");if(a&&tt(a))a.proxyProvider.walletProxy=e;else{let a=new ds({provider:new fs({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.saveConnectionHistory(),this.storedConnections=ea(),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.saveConnectionHistory(),this.storedConnections=ea(),this.emit("walletsUpdated")}}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:n,walletConfig:r}){let a=this.findWalletConnector(e,t);if(a&&tt(a))return a instanceof nt&&a.resetConnection(t),a;let i=(()=>"injected"!==e?"coinbase_wallet"===e?new ls(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):"null"!==e?new nt(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,this.privyAppName,t):r?new ws({id:r.client,name:r.name,defaultChain:this.defaultChain,walletClientType:r.client}):null:"metamask"===t&&n?.eip6963InjectedProvider?new ks(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask"):"metamask"===t&&n?.legacyInjectedProvider?new _s(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask"):"phantom"===t&&n?.legacyInjectedProvider?new _s(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom"):n?.legacyInjectedProvider&&"unknown_browser_extension"===t?new _s(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider):n?.eip6963InjectedProvider?new bs(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)}))}saveConnectionHistory(){let e=this.wallets.map((e=>({address:e.address,connectorType:e.connectorType,walletClientType:e.walletClientType,connectedAt:e.connectedAt,id:e.meta.id})));Zr.put(Gn,e)}async activeWalletSign(e){let t=this.wallets,n=t.length>0?t[0]:null;return n&&rt(n)?n.sign(e):null}setActiveWallet(e){this.activeWallet=C(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,u){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 Ye},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.privyAppLogo=d,this.walletChainType=u||"ethereum-only",this.storedConnections=ea()}}let Ws=[de,ue,he];class Ms{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw b(e)}}async post(e,t,n){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...n})}catch(e){throw b(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw b(e)}}constructor({appId:e,appClientId:t,client:n,defaults:r}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=n.clientAnalyticsId,this.sdkVersion=qn,this.client=n,this.defaults=r,this.fallbackApiUrl=n.fallbackApiUrl,this.baseFetch=$a.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=Ws.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 k}})}}let Ps=/paymaster\.biconomy\.io\/api/i,Ls={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const Ds=(e,t)=>e&&Ps.test(e)?Ls:t&&t.policy_id?{policyId:t.policy_id}:void 0;function Us(){return!(w&&window.location.origin.startsWith("http://localhost"))}const Fs=Ga((()=>({identityToken:null})));function Bs(){let{identityToken:e}=Fs();return{identityToken:e}}var zs,Hs=((zs={}).PRIVY="privy_access_token",zs.CUSTOMER="customer_access_token",zs);class Vs{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(Kn)}get privyAccessToken(){return this._getToken(Yn)}_getToken(e){try{let t=Zr.get(e);return"string"==typeof t?ns.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=Zr.get(Zn);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=Zr.get(Jn(e));if("string"!=typeof t)return null;{let n=new ns(t);return n.isExpired()?(Zr.del(Jn(e)),null):n.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=ja.get(Qn);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&&this.refreshToken!==Xn;return this.mightHaveServerCookies||t&&n}hasActiveAccessToken(e){let t=ns.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?Zr.put(Jn(e),t):Zr.del(Jn(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:er(n),isNewUser:r,oAuthTokens:i}}catch(e){throw console.warn("Error authenticating session"),I(e)}}_trackAuthenticateEvents(e,t){let n=function(e){return e instanceof _o?"email":e instanceof Zo?"sms":e instanceof at?"siwe":e instanceof xo?"guest":e instanceof bo?"custom_auth":e instanceof Wo?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:er(t),oAuthTokens:r}}catch(e){throw console.warn("Error linking account"),I(e)}}async _refresh(){if(!this.api)throw new T("Session has no API instance");if(!this.client)throw new T("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(de,t?{refresh_token:t}:{},{headers:r})}return this.handleTokenResponse(n),er(n.user)}catch(e){if(e instanceof N&&e.privyErrorCode===A.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw I(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(ue,{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=Zr.get(Kn);if(Zr.put(Kn,e),!this.client?.useServerCookies){let t=ns.parse(e)?.expiration;ja.set(tr,e,{sameSite:"Strict",secure:Us(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else Zr.del(Kn),ja.remove(tr),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(Zr.put(Zn,e),this.client?.useServerCookies||ja.set(Qn,"t",{sameSite:"Strict",secure:Us(),expires:30})):(Zr.del(Zn),ja.remove(nr),ja.remove(Qn))}storePrivyAccessToken(e){"string"==typeof e?Zr.put(Yn,e):Zr.del(Yn)}storeIdentityToken(e){if(Fs.setState({identityToken:e}),this.client?.useServerCookies)return;Zr.put(rr,e);let t=ns.parse(e)?.expiration;ja.set(ar,e,{sameSite:"Strict",secure:Us(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){Zr.del(rr),Fs.setState({identityToken:null}),ja.remove(ar)}constructor(){this.authenticateOnce=new Ge((async e=>this._authenticate(e))),this.linkOnce=new Ge((async e=>this._link(e))),this.refreshOnce=new Ge(this._refresh.bind(this)),this.destroyOnce=new Ge(this._destroy.bind(this))}}let $s;var js=0,Gs="__private_"+js+++"__getOrGenerateClientAnalyticsId";class qs{initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:r,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:o,externalWalletConfig:s,appName:l,walletChainType:c}){this.connectors||(this.connectors=new Os(this.appId,e,t,n,r,a,i,o,s,l,void 0,c))}generateApi(){let e=new Ms({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 T("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new T("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(pe,{action:"verify"})}catch(e){throw b(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(me,{})).options)}catch(e){throw b(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(ye,{});return er(e)}catch(e){throw I(e)}}async unlinkEmail(e){try{let t=await this.api.post(ge,{address:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkPhone(e){try{let t=await this.api.post(fe,{phoneNumber:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(we,{address:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(ve,{address:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkOAuth(e,t){try{let n=await this.api.post(Ce,{provider:e,subject:t});return await this.getAuthenticatedUser()??er(n)}catch(e){throw I(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(Ee,{fid:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkTelegram(e){try{let t=await this.api.post(Te,{telegram_user_id:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async revokeDelegatedWallet(){try{await this.api.post(be,{})}catch(e){throw I(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(he,{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(Ae,e)}catch(e){throw I(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(_e,e)}catch(e){throw I(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${ke}?partnerUserId=${e}`)}catch(e){throw I(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(Hs.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(Hs.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?rs.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:Ds(e.paymaster_url,e.paymaster_context)})))}:{enabled:n.enabled}}catch(e){throw I(e)}}async getServerConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let n=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl,headers:e}),r=n.telegram_auth_config?{botId:n.telegram_auth_config.bot_id,botName:n.telegram_auth_config.bot_name,linkEnabled:n.telegram_auth_config.link_enabled,seamlessAuthEnabled:n.telegram_auth_config.seamless_auth_enabled}:void 0,a=n.funding_config?{methods:n.funding_config.methods,options:n.funding_config.options,defaultRecommendedAmount:n.funding_config.default_recommended_amount,defaultRecommendedCurrency:n.funding_config.default_recommended_currency,promptFundingOnWalletCreation:n.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:n.funding_config.cross_chain_bridging_enabled}:void 0;return{id:n.id,name:n.name,verificationKey:n.verification_key,logoUrl:n.logo_url||void 0,accentColor:n.accent_color||void 0,showWalletLoginFirst:n.show_wallet_login_first,allowlistConfig:{errorTitle:n.allowlist_config.error_title,errorDetail:n.allowlist_config.error_detail,errorCtaText:n.allowlist_config.cta_text,errorCtaLink:n.allowlist_config.cta_link},walletAuth:n.wallet_auth,solanaWalletAuth:n.solana_wallet_auth,emailAuth:n.email_auth,smsAuth:n.sms_auth,googleOAuth:n.google_oauth,twitterOAuth:n.twitter_oauth,discordOAuth:n.discord_oauth,githubOAuth:n.github_oauth,spotifyOAuth:n.spotify_oauth,instagramOAuth:n.instagram_oauth,tiktokOAuth:n.tiktok_oauth,linkedinOAuth:n.linkedin_oauth,appleOAuth:n.apple_oauth,farcasterAuth:n.farcaster_auth,passkeyAuth:n.passkey_auth,passkeysForSignupEnabled:n.passkeys_for_signup_enabled,telegramAuth:n.telegram_auth,disablePlusEmails:n.disable_plus_emails,termsAndConditionsUrl:n.terms_and_conditions_url,embeddedWalletConfig:{ethereum:{createOnLogin:n.embedded_wallet_config.ethereum?.create_on_login??n.embedded_wallet_config.create_on_login},solana:{createOnLogin:n.embedded_wallet_config.solana?.create_on_login??"off"},userOwnedRecoveryOptions:n.embedded_wallet_config.user_owned_recovery_options,requireUserOwnedRecoveryOnCreate:n.embedded_wallet_config.require_user_owned_recovery_on_create},privacyPolicyUrl:n.privacy_policy_url,requireUsersAcceptTerms:n.require_users_accept_terms,customApiUrl:n.custom_api_url,walletConnectCloudProjectId:n.wallet_connect_cloud_project_id,fiatOnRampEnabled:n.fiat_on_ramp_enabled,captchaEnabled:n.captcha_enabled,captchaSiteKey:n.captcha_site_key,createdAt:new Date(1e3*n.created_at),updatedAt:new Date(1e3*n.updated_at),mfaMethods:n.mfa_methods,enforceWalletUis:n.enforce_wallet_uis,legacyWalletUiConfig:n.legacy_wallet_ui_config,telegramAuthConfiguration:r,fundingConfig:a}}catch(e){throw I(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(Ie,{address:e,token:t})).nonce}catch(e){throw I(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i}){return await this.api.post(Ne,{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(xe,{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(Se,{message:e,signature:t,smart_wallet_type:n});return er(r)}catch(e){throw I(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 er(i)}catch(e){throw I(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(Re,{address:e,token:t})).nonce}catch(e){throw I(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,mode:a}){return await this.api.post(Oe,{message:e,signature:t,walletClientType:n,connectorType:r,mode:a})}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=Ue,c={nonce:e,email:t};break;case"sms":l=De,c={nonce:e,phoneNumber:t};break;case"siwe":if(l=Le,!r)throw Error("Wallet parameters must be defined");c={nonce:e,address:t,...r};break;case"farcaster":l=Pe,c={nonce:e,farcaster_id:t,farcaster_embedded_address:o};break;case"telegram":l=Me,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=We,c={nonce:e,userInfo:s}}let d=await this.api.post(l,c);return await this.getAuthenticatedUser()??er(d)}catch(e){throw I(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r}){return await this.api.post(Fe,{message:e,signature:t,walletClientType:n,connectorType:r})}async linkWithSiws({message:e,signature:t,walletClientType:n,connectorType:r}){try{let a=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r});return er(a)}catch(e){throw I(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(Be);return this.session.updateIdentityToken(e.identity_token),er(e.user)}catch(e){throw I(e)}}async scanTransaction(e){try{return await this.api.post(ze,e)}catch(e){throw I(e)}}constructor({apiUrl:e=ir,appId:t,appClientId:n,timeout:r=or}){Object.defineProperty(this,Gs,{value:Ks}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==ir&&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,Gs)[Gs](),$s||($s=new Vs),this.session=$s,this.api=this.generateApi(),this.session.client=this}}function Ks(){if("undefined"==typeof window)return null;try{let e=Zr.get(sr);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=Ea();try{return Zr.put(sr,e),e}catch(t){return e}}const Ys=e=>{let{enabled:n,siteKey:r,appId:a,setError:s,setToken:l,setExecuting:c,ref:d}=it(),[,u]=i((()=>r?.split("t:")||[]),[r]);if(o((()=>d.current?.remove),[]),!n)return null;if(!u)throw Error("Unsupported captcha site key");/*#__PURE__*/return t("div",{className:"hidden h-0 w-0",children:/*#__PURE__*/t(qa,{...e,ref:d,siteKey:u,options:{action:a,size:"invisible",...e.delayedExecution?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{e.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{e.onError?.(),s("Captcha failed"),c(!1)},onSuccess:t=>{e.onSuccess?.(t),l(t),c(!1)},onExpire:()=>{e.onExpire?.();try{d.current?.reset(),s(void 0),l(void 0)}catch(e){s("expired_and_failed_reset")}}})})};function Zs(e){ta("configureMfa",e)}const Js=/*#__PURE__*/Ka.span.withConfig({displayName:"CircleBackground",componentId:"sc-c9f33cd-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";background-color:",";border-radius:50%;display:inline-block;box-sizing:border-box;}"],(e=>e.color??"var(--privy-color-accent)"),(e=>e.color??"var(--privy-color-accent)"));let Qs=/*#__PURE__*/Ka.div.withConfig({displayName:"StackedContainer",componentId:"sc-f7e7d474-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]);const Xs=/*#__PURE__*/Ka.div.withConfig({displayName:"Grow",componentId:"sc-ddbf22b4-0"})(["text-align:left;flex-grow:1;"]),el=/*#__PURE__*/Ka.div.withConfig({displayName:"AlignBottom",componentId:"sc-ddbf22b4-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),tl=/*#__PURE__*/Ka.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;}"]),nl=/*#__PURE__*/Ka(tl).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 rl=/*#__PURE__*/Ya(["&&{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 al=/*#__PURE__*/Ka.div.withConfig({displayName:"Subtitle",componentId:"sc-ddbf22b4-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),il=/*#__PURE__*/Ka.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-ddbf22b4-5"})(["",""],rl),ol=/*#__PURE__*/Ka.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-ddbf22b4-6"})(["",""],rl),sl=/*#__PURE__*/Ka.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;":"")),ll=/*#__PURE__*/Ka.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-ddbf22b4-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),cl=/*#__PURE__*/Ka.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;}"]);let dl=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-a3e74b9e-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;margin-top:24px;"]),ul=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-a3e74b9e-1"})(["display:flex;flex-direction:column;gap:8px;"]);const hl=/*#__PURE__*/Ka.span.withConfig({displayName:"CircleBorder",componentId:"sc-9056b8b8-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;border-bottom-color:",";}"],(e=>e.color??"var(--privy-color-accent)"),(e=>e.color??"var(--privy-color-accent)"));function pl(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...n,children:[/*#__PURE__*/t("circle",{cx:"12",cy:"12",r:"10"}),/*#__PURE__*/t("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),/*#__PURE__*/t("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})}const ml=({onTransfer:e,isTransferring:n,transferSuccess:r})=>/*#__PURE__*/t(st,{...r?{success:!0,children:"Success!"}:{warn:!0,loading:n,onClick:e,children:"Transfer and delete account"}}),yl=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-aa2e65ff-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;width:100%;padding-bottom:16px;"]),gl=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-aa2e65ff-1"})(["display:flex;flex-direction:column;&& p{font-size:14px;}width:100%;gap:16px;"]),fl=/*#__PURE__*/Ka.div.withConfig({displayName:"DisclosedAccountContainer",componentId:"sc-aa2e65ff-2"})(["display:flex;cursor:pointer;align-items:center;width:100%;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-md);padding:8px 10px;font-size:14px;font-weight:500;gap:8px;"]),wl=/*#__PURE__*/Ka(ei).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-aa2e65ff-3"})(["position:relative;width:",";height:",";color:var(--privy-color-foreground-3);margin-left:auto;"],(e=>`${e.iconSize}px`),(e=>`${e.iconSize}px`)),vl=/*#__PURE__*/Ka(ti).withConfig({displayName:"StyledCopyIcon",componentId:"sc-aa2e65ff-4"})(["position:relative;width:15px;height:15px;color:var(--privy-color-foreground-3);margin-left:auto;"]),Cl=/*#__PURE__*/Ka.ol.withConfig({displayName:"ListContainer",componentId:"sc-aa2e65ff-5"})(["display:flex;flex-direction:column;font-size:14px;width:100%;text-align:left;"]),El=/*#__PURE__*/Ka.li.withConfig({displayName:"ListItem",componentId:"sc-aa2e65ff-6"})(["font-size:14px;list-style-type:auto;list-style-position:outside;margin-left:1rem;margin-bottom:0.5rem;&:last-child{margin-bottom:0;}"]),Tl=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleContainer",componentId:"sc-aa2e65ff-7"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]);let bl=()=>/*#__PURE__*/t(Tl,{children:/*#__PURE__*/t(wl,{iconSize:60})});const Al=({address:r,onClose:a,onRetry:i,onTransfer:o,isTransferring:s,transferSuccess:l})=>{let{defaultChain:c}=dr(),d=c.blockExplorers?.default.url??"https://etherscan.io";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:a,backFn:i}),/*#__PURE__*/e(yl,{children:[/*#__PURE__*/t(bl,{}),/*#__PURE__*/e(gl,{children:[/*#__PURE__*/t("h3",{children:"Check account assets before transferring"}),/*#__PURE__*/t("p",{children:"Before transferring, ensure there are no assets in the other account. Assets in that account will not transfer automatically and may be lost."}),/*#__PURE__*/e(Cl,{children:[/*#__PURE__*/t("p",{children:" To check your balance, you can:"}),/*#__PURE__*/t(El,{children:"Log out and log back into the other account, or "}),/*#__PURE__*/e(El,{children:["Copy your wallet address and use a"," ",/*#__PURE__*/t("u",{children:/*#__PURE__*/t("a",{target:"_blank",href:d,children:"block explorer"})})," ","to see if the account holds any assets."]})]}),/*#__PURE__*/e(fl,{onClick:()=>navigator.clipboard.writeText(r).catch(console.error),children:[/*#__PURE__*/t(Xa,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),/*#__PURE__*/t(lt,{address:r,showCopyIcon:!1}),/*#__PURE__*/t(vl,{})]}),/*#__PURE__*/t(ml,{onTransfer:o,isTransferring:s,transferSuccess:l})]})]}),/*#__PURE__*/t(ct,{})]})},_l=({onClose:r,onContinue:a,onInfo:i,onTransfer:o,transferSuccess:s,isTransferring:l,data:c})=>{if(!c?.accountTransfer?.linkMethod||!c?.accountTransfer?.displayName)return;let d={method:c?.accountTransfer?.linkMethod,handle:c?.accountTransfer?.displayName,disclosedAccount:c?.accountTransfer?.embeddedWalletAddress?{type:"wallet",handle:c?.accountTransfer?.embeddedWalletAddress}:void 0};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{closeable:!0}),/*#__PURE__*/e(yl,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(hl,{color:"var(--privy-color-error)"}),/*#__PURE__*/t(Qa,{height:38,width:38,stroke:"var(--privy-color-error)"})]})}),/*#__PURE__*/e(gl,{children:[/*#__PURE__*/e("h3",{children:[function(e){switch(e){case"sms":return"Phone number";case"email":return"Email address";case"siwe":return"Wallet address";case"linkedin":return"LinkedIn profile";case"google":case"apple":case"discord":case"github":case"instagram":case"spotify":case"tiktok":case"twitter":case"telegram":case"farcaster":return`${Mo(e.replace("_oauth",""))} profile`;default:return e}}(d.method)," is associated with another account"]}),/*#__PURE__*/e("p",{children:["Do you want to transfer",/*#__PURE__*/t("b",{children:d.handle?` ${d.handle}`:""})," to this account instead? This will delete your other account."]}),/*#__PURE__*/t(kl,{onClick:i,disclosedAccount:d.disclosedAccount})]}),/*#__PURE__*/e(gl,{style:{gap:12,marginTop:12},children:[c?.accountTransfer?.embeddedWalletAddress?/*#__PURE__*/t(st,{onClick:a,children:"Continue"}):/*#__PURE__*/t(ml,{onTransfer:o,transferSuccess:s,isTransferring:l}),/*#__PURE__*/t(dt,{onClick:r,children:"No thanks"})]})]}),/*#__PURE__*/t(ct,{})]})};function kl({disclosedAccount:n,onClick:r}){return n?/*#__PURE__*/e(fl,{onClick:r,children:[/*#__PURE__*/t(Xa,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),/*#__PURE__*/t(lt,{address:n.handle,showCopyIcon:!1}),/*#__PURE__*/t(pl,{width:15,height:15,color:"var(--privy-color-foreground-3)",style:{marginLeft:"auto"}})]}):null}const Il=/*#__PURE__*/Ka.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a63b1990-0"})(["display:flex;flex-direction:column;align-items:center;padding:0px 0px 30px;@media (max-width:440px){padding:10px 10px 20px;}"]),Nl=/*#__PURE__*/Ka.div.withConfig({displayName:"Title",componentId:"sc-a63b1990-1"})(["font-size:18px;line-height:30px;text-align:center;font-weight:600;margin-bottom:10px;"]),xl=/*#__PURE__*/Ka.div.withConfig({displayName:"SubTitle",componentId:"sc-a63b1990-2"})(["font-size:0.875rem;text-align:center;"]),Sl=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-a63b1990-3"})(["display:flex;flex-direction:column;align-items:center;gap:10px;flex-grow:1;padding:20px 0;@media (max-width:440px){padding:10px 10px 20px;}"]),Rl=/*#__PURE__*/Ka.div.withConfig({displayName:"List",componentId:"sc-a63b1990-4"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.75rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),Ol=/*#__PURE__*/Ka.div.withConfig({displayName:"ListItemIcon",componentId:"sc-a63b1990-5"})(["width:25px;display:flex;align-items:center;justify-content:flex-start;> svg{z-index:2;height:25px !important;width:25px !important;color:var(--privy-color-accent);}"]),Wl=/*#__PURE__*/Ka.div.withConfig({displayName:"ListItem",componentId:"sc-a63b1990-6"})(["display:flex;align-items:center;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;"]),Ml=/*#__PURE__*/Ka.div.withConfig({displayName:"BottomSection",componentId:"sc-a63b1990-7"})(["display:flex;flex-direction:column;gap:10px;padding-top:20px;"]),Pl=/*#__PURE__*/Ka.div.withConfig({displayName:"MethodList",componentId:"sc-a63b1990-8"})(["display:flex;flex-direction:column;align-items:stretch;gap:1rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),Ll=/*#__PURE__*/Ka.div.withConfig({displayName:"MethodListItem",componentId:"sc-a63b1990-9"})(["display:flex;gap:5px;width:100%;position:relative;"]),Dl=/*#__PURE__*/Ka.button.withConfig({displayName:"RemoveMethodButton",componentId:"sc-a63b1990-10"})(["&&{background-color:transparent;color:var(--privy-color-foreground-3);padding:0 0.75rem;display:flex;align-items:center;height:100%;> svg{z-index:2;height:20px !important;width:20px !important;}}&&:hover{color:var(--privy-color-error);}"]),Ul=/*#__PURE__*/Ka.div.withConfig({displayName:"MethodText",componentId:"sc-a63b1990-11"})(["display:flex;align-items:center;gap:0.5rem;> svg{z-index:2;height:20px !important;width:20px !important;}"]),Fl=/*#__PURE__*/Ka.div.withConfig({displayName:"ExtraText",componentId:"sc-a63b1990-12"})(["display:flex;align-items:center;gap:6px;font-weight:400 !important;color:",";> svg{z-index:2;height:18px !important;width:18px !important;display:flex !important;align-items:flex-end;}"],(e=>e.isAccent?"var(--privy-color-accent)":"var(--privy-color-foreground-3)")),Bl=/*#__PURE__*/Ka.div.withConfig({displayName:"SmsInsecureText",componentId:"sc-a63b1990-13"})(["width:100%;display:flex;justify-content:space-between;"]),zl=/*#__PURE__*/Ka.p.withConfig({displayName:"TermsText",componentId:"sc-a63b1990-14"})(["text-align:left;width:100%;color:var(--privy-color-foreground-3) !important;"]),Hl=/*#__PURE__*/Ka.button.withConfig({displayName:"PrimaryTextButton",componentId:"sc-a63b1990-15"})(["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:0.875rem;line-height:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{color:",";background-color:transparent;padding:0.5rem 0px;}&:hover{text-decoration:underline;}"],(e=>"dark"===e.theme?"var(--privy-color-foreground-2)":"var(--privy-color-accent)")),Vl=/*#__PURE__*/Ka.div.withConfig({displayName:"IconWrapper",componentId:"sc-a63b1990-16"})(["display:flex;align-items:center;justify-content:center;color:var(--privy-color-accent);width:100%;> svg{z-index:2;width:3rem;height:3rem;}"]),$l=/*#__PURE__*/Ka.div.withConfig({displayName:"ErrorMessage",componentId:"sc-a63b1990-17"})(["color:var(--privy-color-error);"]),jl=({termsAndConditionsUrl:r,privacyPolicyUrl:a,onAccept:i,onDecline:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1}),/*#__PURE__*/t(ri,{width:56,height:56,fill:"var(--privy-color-accent)",style:{margin:"auto"}}),/*#__PURE__*/t(Nl,{style:{marginTop:24},children:"One last step"}),/*#__PURE__*/t(xl,{children:"By signing up, you agree to our terms and privacy policy."}),/*#__PURE__*/e(tl,{style:{marginTop:24},children:[r&&/*#__PURE__*/e(ol,{target:"_blank",href:r,children:["View Terms ",/*#__PURE__*/t(ni,{style:{marginLeft:"auto"}})]}),a&&/*#__PURE__*/e(ol,{target:"_blank",href:a,children:["View Privacy Policy ",/*#__PURE__*/t(ni,{style:{marginLeft:"auto"}})]})]}),/*#__PURE__*/e(Gl,{style:{marginTop:24},children:[/*#__PURE__*/t(dt,{onClick:o,children:"No thanks"}),/*#__PURE__*/t(st,{onClick:i,children:"Accept"})]}),/*#__PURE__*/t(ct,{})]});let Gl=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-d601b243-0"})(["display:flex;gap:10px;"]);const ql=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...n,children:/*#__PURE__*/t("path",{fillRule:"evenodd",d:"M12 1.5a5.25 5.25 0 00-5.25 5.25v3a3 3 0 00-3 3v6.75a3 3 0 003 3h10.5a3 3 0 003-3v-6.75a3 3 0 00-3-3v-3c0-2.9-2.35-5.25-5.25-5.25zm3.75 8.25v-3a3.75 3.75 0 10-7.5 0v3h7.5z",clipRule:"evenodd"})});let Kl=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-ed4ecf-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),Yl=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-ed4ecf-1"})(["display:flex;flex-direction:column;gap:8px;"]);const Zl=({title:r,description:a,children:i,...o})=>
2
- /*#__PURE__*/t(Xl,{...o,children:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("h3",{children:r}),"string"==typeof a?/*#__PURE__*/t("p",{children:a}):a,i]})}),Jl=/*#__PURE__*/Ka(Zl).withConfig({displayName:"PaddedScreenHeader",componentId:"sc-523a75d6-0"})(["margin-bottom:24px;"]),Ql=({title:n,description:r,icon:a,children:i,...o})=>/*#__PURE__*/e(ec,{...o,children:[a||null,/*#__PURE__*/t("h3",{children:n}),r&&"string"==typeof r?/*#__PURE__*/t("p",{children:r}):r,i]});let Xl=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledSection",componentId:"sc-523a75d6-1"})(["display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;text-align:left;gap:8px;width:100%;margin-bottom:24px;&& h3{font-size:17px;color:var(--privy-color-foreground);}&& p{color:var(--privy-color-foreground-2);font-size:14px;}"]),ec=/*#__PURE__*/Ka(Xl).withConfig({displayName:"CenteredStyledSection",componentId:"sc-523a75d6-2"})(["align-items:center;text-align:center;gap:16px;h3{margin-bottom:24px;}"]),tc=Array(6).fill("");var nc,rc,ic=((nc=ic||{})[nc.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",nc[nc.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",nc),oc=((rc=oc||{})[rc.EMAIL=0]="EMAIL",rc[rc.SMS=1]="SMS",rc);let sc=/*#__PURE__*/Ka.div.withConfig({displayName:"PasswordlessCodeContainer",componentId:"sc-bf1e04a-0"})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:center;margin:auto;gap:16px;flex-grow:1;"]),lc=/*#__PURE__*/Ka.div.withConfig({displayName:"CodeInput",componentId:"sc-bf1e04a-1"})(["display:flex;flex-direction:column;width:100%;gap:8px;> div:last-child{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: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);}}"]),cc=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-bf1e04a-2"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-end;width:100%;"],(e=>e.$success?"var(--privy-color-success)":e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),dc=/*#__PURE__*/Ka.div.withConfig({displayName:"HelpText",componentId:"sc-bf1e04a-3"})(["font-size:13px;color:var(--privy-color-foreground);display:flex;gap:8px;align-items:center;width:100%;margin-top:16px;padding-bottom:32px;"]),uc=/*#__PURE__*/Ka.div.withConfig({displayName:"ResendButtonContainer",componentId:"sc-bf1e04a-4"})(["color:var(--privy-color-accent);padding:2px 0;> button{text-decoration:underline;}"]),hc=/*#__PURE__*/Ka.div.withConfig({displayName:"Badge",componentId:"sc-bf1e04a-5"})(["display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-sm);padding:2px 8px;gap:4px;background:var(--privy-color-background-2);color:var(--privy-color-foreground-2);"]),pc=/*#__PURE__*/Ka.span.withConfig({displayName:"BoldWrappingSpan",componentId:"sc-bf1e04a-6"})(["font-weight:500;word-break:break-all;"]);const mc=({icon:r})=>/*#__PURE__*/t(n,{children:/*#__PURE__*/t(yc,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{}),"string"==typeof r?
1
+ import{jsxs as e,jsx as t,Fragment as n}from"react/jsx-runtime";import{createStore as r}from"mipd";import a,{useMemo as i,useEffect as o,useState as s,useRef as l,useCallback as c,useReducer as d,forwardRef as h,useContext as u,createContext as p}from"react";import*as m from"react-device-detect";import{isMobile as y,isIOS as f,isSafari as w,isAndroid as v}from"react-device-detect";import{getAddress as C,isAddress as E}from"viem/utils";import{P as T,f as b,a as A,b as _,c as k,d as I,e as N,u as x,g as S,h as R,i as O,j as M,n as P,k as L,I as D}from"./internal-context-mSHyF0Gq.mjs";import{c as U,p as F,a as B,b as z,u as H,f as V,d as $,e as j,g as G,h as q,o as K,i as Y,j as Z,k as J,l as Q,m as X,n as ee,q as te,r as ne,s as re,t as ie,v as oe,w as se,x as le,y as ce,z as de,A as he,B as ue,C as pe,D as me,E as ye,F as ge,G as fe,H as we,I as ve,J as Ce,K as Ee,L as Te,M as be,N as Ae,O as _e,P as ke,Q as Ie,R as Ne,S as xe,T as Se,U as Re,V as Oe,W as We,X as Me,Y as Pe,Z as Le,_ as De,$ as Ue,a0 as Fe,a1 as Be,a2 as ze,a3 as He,a4 as Ve,a5 as $e}from"./paths-Q47X90aK.mjs";import{o as je,R as Ge,C as qe,E as Ke,P as Ye,t as Ze,g as Je,a as Qe,B as Xe,d as et,i as tt,W as nt,b as rt,S as at,u as it,M as ot,c as st,A as lt,e as ct,f as dt,s as ht,H as ut,h as pt,F as mt,j as yt,k as gt,l as ft,m as wt,n as vt,p as Ct,T as Et,q as Tt,r as bt,v as At,w as _t,x as kt,y as It,z as Nt,D as xt,G as St,I as Rt,J as Ot,K as Wt,L as Mt,N as Pt,O as Lt,Q as Dt,U as Ut,V as Ft,X as Bt,Y as zt,Z as Ht,_ as Vt,$ as $t,a0 as jt,a1 as Gt,a2 as qt,a3 as Kt,a4 as Yt,a5 as Zt,a6 as Jt,a7 as Qt,a8 as Xt,a9 as en,aa as tn,ab as nn,ac as rn,ad as an,ae as on,af as sn,ag as ln,ah as cn,ai as dn,aj as hn,ak as un,al as pn,am as mn,an as yn,ao as gn,ap as fn,aq as wn,ar as vn,as as Cn,at as En,au as Tn,av as bn,aw as An,ax as _n,ay as kn,az as In,aA as Nn,aB as xn,aC as Sn,aD as Rn,aE as On,aF as Wn,aG as Mn}from"./useActiveWallet-C8nSK6cE.mjs";export{aK as useActiveWallet,aI as useConnectWallet,aJ as useFundWallet,aH as useLogin}from"./useActiveWallet-C8nSK6cE.mjs";import*as Pn from"jose";import{base64url as Ln}from"jose";import{g as Dn,C as Un,H as Fn,O as Bn,S as zn,D as Hn,a as Vn,b as $n,c as jn,d as Gn,V as qn,e as Kn,P as Yn,R as Zn,f as Jn,h as Qn,i as Xn,j as er,k as tr,l as nr,I as rr,m as ar,n as ir,o as or,p as sr,u as lr,M as cr,q as dr,r as hr,s as ur,t as pr,v as mr,w as yr,x as gr,W as fr,y as wr,z as vr,A as Cr,B as Er,E as Tr,F as br,G as Ar,J as _r,K as kr,L as Ir,N as Nr,Q as xr,T as Sr,U as Rr,X as Or,Y as Wr,Z as Mr,_ as Pr,$ as Lr,a0 as Dr,a1 as Ur,a2 as Fr,a3 as Br,a4 as zr,a5 as Hr,a6 as Vr,a7 as $r,a8 as jr,a9 as Gr,aa as qr,ab as Kr}from"./useWallets-DTpjk5Rk.mjs";export{ac as SUPPORTED_CHAINS,ae as addPrivyRpcToChain,ad as addRpcUrlOverrideToChain}from"./useWallets-DTpjk5Rk.mjs";import{e as Yr,s as Zr,f as Jr,S as Qr,i as Xr,l as ea,u as ta,C as na,a as ra,b as aa,O as ia,c as oa,d as sa,g as la,P as ca,h as da,j as ha,k as ua,m as pa,p as ma,n as ya,o as ga,q as fa,r as wa,t as va,v as Ca}from"./prepareFundingModalData-due26ueW.mjs";export{W as WalletConnector}from"./prepareFundingModalData-due26ueW.mjs";import{v4 as Ea}from"uuid";import Ta from"eventemitter3";import{CoinbaseWalletSDK as ba}from"@coinbase/wallet-sdk";import{isHex as Aa,toHex as _a,createPublicClient as ka,http as Ia,createWalletClient as Na,custom as xa,publicActions as Sa,formatUnits as Ra,parseEther as Oa,encodeFunctionData as Wa,isAddress as Ma,decodeFunctionData as Pa,decodeAbiParameters as La,formatEther as Da,hexToString as Ua,zeroAddress as Fa,getAddress as Ba,parseSignature as za}from"viem";import{g as Ha,a as Va}from"./getPublicClient-wHgCncHx.mjs";import{ofetch as $a}from"ofetch";import ja from"js-cookie";import{create as Ga}from"zustand";import{Turnstile as qa}from"@marsidev/react-turnstile";import{styled as Ka,css as Ya,createGlobalStyle as Za}from"styled-components";import Ja from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import Qa from"@heroicons/react/24/outline/ExclamationTriangleIcon";import Xa from"@heroicons/react/24/outline/WalletIcon";import ei from"@heroicons/react/24/outline/ExclamationCircleIcon";import ti from"@heroicons/react/24/outline/Square2StackIcon";import ni from"@heroicons/react/24/outline/ArrowTopRightOnSquareIcon";import ri from"@heroicons/react/24/solid/DocumentCheckIcon";import ai from"@heroicons/react/20/solid/CheckIcon";import ii from"@heroicons/react/24/outline/EnvelopeIcon";import oi from"@heroicons/react/24/outline/PhoneIcon";import si from"@heroicons/react/24/solid/CheckCircleIcon";import li from"@heroicons/react/24/solid/XCircleIcon";import ci from"@heroicons/react/24/outline/CheckCircleIcon";import di from"@heroicons/react/24/outline/CloudArrowUpIcon";import hi from"@heroicons/react/24/outline/NoSymbolIcon";import ui from"fast-password-entropy";import*as pi from"secure-password-utilities";import{DEFAULT_WORDLIST as mi}from"secure-password-utilities/wordlists";import yi from"@heroicons/react/24/outline/ArrowPathIcon";import gi from"@heroicons/react/24/outline/EyeIcon";import fi from"@heroicons/react/24/outline/EyeSlashIcon";import wi from"@heroicons/react/24/outline/KeyIcon";import vi from"@heroicons/react/24/outline/ArrowDownTrayIcon";import Ci from"@heroicons/react/24/outline/ClipboardDocumentCheckIcon";import Ei from"@heroicons/react/24/outline/DocumentDuplicateIcon";import Ti from"@heroicons/react/24/outline/UserCircleIcon";import bi from"@heroicons/react/24/solid/LockClosedIcon";import{formatWalletAddress as Ai,getCoinbaseOnRampUrl as _i,chainToMoonpayCurrency as ki,isSupportedChainIdForMoonpay as Ii,isSupportedChainIdForCoinbaseOnramp as Ni,formatTokenAmount as xi,formatWeiAmount as Si,countryCodesAndNumbers as Ri,validatePhoneNumber as Oi,phoneNumberTypingFormatter as Wi,getPlaceholderPhoneNumber as Mi,getCountryCallingCode as Pi,getPhoneCountryCodeAndNumber as Li,formatPhoneNumber as Di,toObjectKeys as Ui,lastFourDigits as Fi,SolanaClient as Bi,ProviderErrors as zi}from"@privy-io/js-sdk-core";import{Menu as Hi,MenuButton as Vi,MenuItems as $i,MenuItem as ji,Transition as Gi,Dialog as qi,TransitionChild as Ki,DialogPanel as Yi}from"@headlessui/react";import Zi from"@heroicons/react/24/outline/ChevronDownIcon";import Ji from"@heroicons/react/24/solid/ArrowsRightLeftIcon";import Qi from"@heroicons/react/24/outline/CreditCardIcon";import Xi from"@heroicons/react/24/outline/QrCodeIcon";import eo from"@heroicons/react/24/outline/InformationCircleIcon";import to from"@heroicons/react/24/outline/ChevronRightIcon";import no from"@heroicons/react/24/outline/FingerPrintIcon";import ro from"@heroicons/react/24/outline/ClockIcon";import ao from"@heroicons/react/24/outline/TrashIcon";import io from"@heroicons/react/24/solid/CheckBadgeIcon";import oo from"@heroicons/react/24/outline/ShieldCheckIcon";import so from"@heroicons/react/24/solid/IdentificationIcon";import lo from"@heroicons/react/24/outline/DevicePhoneMobileIcon";import co from"@heroicons/react/24/outline/MinusCircleIcon";import ho from"@heroicons/react/24/outline/ArrowRightEndOnRectangleIcon";import uo from"@heroicons/react/24/solid/ShieldCheckIcon";import po from"@heroicons/react/24/outline/CalendarIcon";import mo from"@heroicons/react/24/outline/GlobeAltIcon";import yo from"@heroicons/react/24/outline/LockClosedIcon";import go from"@heroicons/react/24/outline/PencilSquareIcon";import{ChevronDownIcon as fo,ArrowRightIcon as wo}from"@heroicons/react/24/outline";import vo from"@heroicons/react/24/outline/ClipboardDocumentIcon";import{i as Co}from"./importWallet-CJLTGjPg.mjs";import{eip7702Actions as Eo,hashAuthorization as To}from"viem/experimental";export{g as getEmbeddedConnectedWallet}from"./getEmbeddedConnectedWallet-CSSBWE2p.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/XMarkIcon";import"@walletconnect/ethereum-provider";import"@heroicons/react/24/outline/CheckIcon";import"qrcode";import"zustand/shallow";import"zustand/traditional";import"tinycolor2";class bo{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(U,{token:this.meta.token})}catch(e){throw b(e)}}async link(){throw Error("Unimplemented")}constructor(e){this.meta={token:e}}}function Ao(e){return e?{"privy-ui":"t"}:void 0}class _o{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(F,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new T("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(B,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw b(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new T("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new T("Email must be set when initialzing authentication.");let r=Ao(n);try{return await this.api.post(z,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw b(e)}}constructor({email:e,captchaToken:t,disableSignup:n}){this.meta={email:e,captchaToken:t,disableSignup:n??!1}}}class ko extends _o{async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new T("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(H,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw b(e)}}constructor(e,t,n){super({email:t,captchaToken:n}),this.meta={email:t,captchaToken:n,oldAddress:e,disableSignup:!1}}}class Io{get meta(){return this._meta}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");try{let e=await this.api.post(V,{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 T("No response from authentication");return e}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post($,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw b(e)}}async _startChannelOnce(){if(!this.api)throw new T("Auth flow has no API instance");let e=await this.api.post(j,{token:this.captchaToken});y&&!f&&e.connect_uri&&je(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new T("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.channelToken)throw new T("Auth flow must be initialized first");let e=await this.api.get(G,{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 Ge(this._startChannelOnce.bind(this)),this.pollForReady=new Ge(this._pollForReady.bind(this)),this._meta.disableSignup=t}}function No(e){return crypto.getRandomValues(new Uint8Array(e))}class xo{getOrCreateGuestCredential(e){let t=Dn(e);if(Yr()){if(Zr.get(t))return Zr.get(t);{let e=Ln.encode(No(32));return Zr.put(t,e),e}}return Ln.encode(No(32))}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(q,{guest_credential:this.meta.guestCredential})}catch(e){throw b(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function So(){return Ln.encode(No(36))}function Ro(){return So()}async function Oo(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 Ln.encode(t)}}class Wo{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new T("User denied confirmation during OAuth flow");let e=function(){let e=Zr.get(Un);if(!e)throw new T("Authentication error.");return e}();try{let t=await this.api.post(K,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return Zr.del(Un),Zr.del(Fn),Zr.del(Bn),t}catch(e){let t=b(e);if(t.privyErrorCode)throw new T(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new T("Invalid code during oauth flow.",void 0,A.OAUTH_USER_DENIED);throw new T("Invalid code during OAuth flow.",void 0,A.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new T("User denied confirmation during OAuth flow");let e=Zr.get(Un);if(!e)throw new T("Authentication error.");try{let t=await this.api.post(Y,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return Zr.del(Un),t}catch(e){throw b(e)}}async getAuthorizationUrl(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.provider)throw new T("Provider must be set when initializing OAuth authentication.");let e=So();Zr.put(Un,e);let t=Ro();Zr.put(zn,t);let n=await Oo(e);this.meta.withPrivyUi||Zr.put(Fn,!0),this.meta.disableSignup&&Zr.put(Bn,!0);let r=Ao(this.meta.withPrivyUi);try{return await this.api.post(Z,{provider:this.meta.provider,redirect_to:window.location.href,token:this.meta.captchaToken,code_challenge:n,state_code:t},{headers:{...r}})}catch(e){throw b(e)}}constructor(e){this.meta=e}}function Mo(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Po=({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"})]}),Lo=({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"})})})]}),Do=({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"})}),Uo=({style:e})=>/*#__PURE__*/t(mo,{style:{color:"var(--privy-color-error)",...e}}),Fo=({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 Bo(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 zo({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 Ho(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 Vo(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 $o=({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 jo={google:{name:"Google",component:Fo},discord:{name:"Discord",component:Lo},github:{name:"Github",component:Do},linkedin:{name:"LinkedIn",component:zo},twitter:{name:"Twitter",component:$o},spotify:{name:"Spotify",component:Ho},instagram:{name:"Instagram",component:Bo},tiktok:{name:"Tiktok",component:Vo},apple:{name:"Apple",component:Po}};const Go=e=>e in jo?jo[e]:{name:"Unknown",component:Uo};function qo(){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:!Zr.get(Fn),popupFlow:null!==window.opener&&a,disableSignup:!!Zr.get(Bn)}}function Ko(){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"),Zr.del(zn),window.history.replaceState({},"",e)}class Yo{async initRegisterFlow(e){if(!this.api)throw new T("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 T("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new T("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 T("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new T("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(J,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new T("Passkey request timed out or rejected by user.",void 0,A.PASSKEY_NOT_ALLOWED);throw b(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new T("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new T("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(Q,{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 T("Passkey request timed out or rejected by user.",void 0,A.PASSKEY_NOT_ALLOWED);throw b(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new T("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new T("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(X,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(n)})}catch(e){if("NotAllowedError"===e.name)throw new T("Passkey request timed out or rejected by user.",void 0,A.PASSKEY_NOT_ALLOWED);throw b(e)}}async _initRegisterOnce(e){if(!this.api)throw new T("Auth flow has no API instance");let t=Ao(e);return await this.api.post(ee,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new T("Auth flow has no API instance");let t=Ao(e);return await this.api.post(te,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new T("Auth flow has no API instance");return await this.api.post(ne,{})}_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 Ge(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new Ge(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Ge(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t}}}class Zo{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(re,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new T("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(ie,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw b(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:n}){if(!this.api)throw new T("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new T("phone nNumber must be set when initialzing authentication.");let r=Ao(n);try{return await this.api.post(oe,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...r}})}catch(e){throw b(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:n}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:n??!1}}}class Jo extends Zo{async link(){if(!this.api)throw new T("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new T("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(se,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw b(e)}}constructor(e,t,n){super({phoneNumber:t,captchaToken:n}),this.meta={phoneNumber:t,captchaToken:n,oldPhoneNumber:e,disableSignup:!1}}}class Qo{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(le,{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 b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(ce,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw b(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function Xo(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===A.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===A.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===A.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===A.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof qe&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t}function es(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function ts(){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 ns{static parse(e){try{return new ns(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return Pn.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=Pn.decodeJwt(e)}}class rs extends ns{static parse(e){try{return new rs(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}const as=({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"})]});let is,os=[1,11155111,137,10,8453,84532,42161,7777777,43114,56],ss=(e,t)=>e.makeWeb3Provider({options:t});class ls extends Ke{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 _("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw Jr(e)}}updateConnectionPreference(e){this.connectionOptions=e,this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",this.proxyProvider.setWalletProvider(ss(is,this.connectionOptions))}constructor(e,t,n,r,a,i){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new Ye(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.connectionOptions=r.coinbaseWallet.connectionOptions??"all",this.walletClientType="smartWalletOnly"===this.connectionOptions?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!is){let n=[t.id].concat(e.map((e=>e.id))),r="eoaOnly"!==this.connectionOptions?n.filter((e=>!os.includes(e))):[];r.length>0&&!r.every((e=>Hn.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${r.join(", ")}`),is=new ba({appName:a,appLogoUrl:i,appChainIds:n})}this.proxyProvider.setWalletProvider(ss(is,this.connectionOptions))}}const cs=({...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 ds extends Ke{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:[Ze(e?.chainId||"0x1")]}),this.getConnectedWallet()):null}get walletBranding(){return{name:"Privy Wallet",icon:cs,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 hs=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];let us={0:"legacy",1:"eip2930",2:"eip1559",3:"eip4844"};const ps={legacy:0,eip2930:1,eip1559:2,eip4844:3};let ms=e=>void 0!==e?BigInt(e):void 0;function ys(e){let t,{type:n=2,...r}=e;r.accessList&&Array.isArray(r.accessList)?t=r.accessList.map((e=>Array.isArray(e)?{address:e[0],storageKeys:e[1]}:e)):r.accessList&&(t=Object.entries(r.accessList).map((e=>({address:e[0],storageKeys:e[1]}))));let a=Number(r.chainId??1),i=Aa(r.data)?r.data:r.data?_a(Uint8Array.from(r.data)):void 0,o=r.nonce?Number(r.nonce):void 0,s={chainId:a,data:i,nonce:o,value:ms(r.value),gas:ms(r.gas??r.gasLimit)},l=Number(n);if(0===l)return{...r,type:us[l],...s,gasPrice:ms(r.gasPrice),accessList:void 0,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(1===l)return{...r,type:us[l],...s,gasPrice:ms(r.gasPrice),accessList:t,maxFeePerGas:void 0,maxPriorityFeePerGas:void 0};if(2===l)return{...r,type:us[l],...s,nonce:o,accessList:t,maxFeePerGas:ms(r.maxFeePerGas),maxPriorityFeePerGas:ms(r.maxPriorityFeePerGas),gasPrice:void 0,maxFeePerBlobGas:void 0};throw new T(`Unsupported transaction type: ${n}`)}class gs extends Error{constructor(e,t,n){super(e),this.code=t,this.data=n}}class fs extends Ta{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new gs(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await rw()||!this.address)throw new gs("Disconnected",4900);let{hash:n}=await sw(t,{address:this.address});return n}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new gs(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await rw()||!this.address)throw new gs("Disconnected",4900);let{signature:n}=await ow(t,{address:this.address});return n}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new gs(`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 gs(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=Ha(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 aw({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 iw(Je(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:Ze(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...ys(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 Ze(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=>hs.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await rw();if(await lw(),!t||!this.address)throw new gs("Disconnected",4900);try{return(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:{method:e.method,params:e.params}})).response.data}catch(e){throw console.error(e),new gs("Disconnected",4900)}}}constructor({walletProxy:e,address:t,entropyId:n,entropyIdVerifier:r,rpcConfig:a,chains:i,appId:o,chainId:s=1,walletIndex:l}){super(),this.walletProxy=e,this.address=t,this.entropyId=n,this.entropyIdVerifier=r,this.chainId=s,this.rpcConfig=a,this.chains=i,this.publicClient=Ha(s,this.chains,a,{appId:o}),this.rpcTimeoutDuration=Qe(a,"privy"),this.appId=o,this.walletIndex=l}}class ws extends Ke{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 Ye(void 0,Vn),this.id=e,this.name=t,this.icon=n,this.connectorType=r}}const vs=({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"})]}),Cs=({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 Es(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var Ts=0;class bs extends Ke{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 _("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Jr(e)}}constructor(e,t,n,r,a){super(a||"unknown",e,t,n),this.connectorType="injected",this.proxyProvider=new Ye(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=r;let i=r.provider;this.proxyProvider.setWalletProvider(i)}}var As="__private_"+Ts+++"__walletBranding";class _s extends Ke{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 Es(this,As)[As]??{name:"Browser Extension",icon:Xe,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 _("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Jr(e)}}constructor(e,t,n,r,a){super(a??"unknown",e,t,n),Object.defineProperty(this,As,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new Ye(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(r),"metamask"===a?Es(this,As)[As]={name:"MetaMask",icon:vs,id:"io.metamask"}:"phantom"===a&&(Es(this,As)[As]={name:"Phantom",icon:Cs,id:"phantom"})}}class ks extends bs{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{y||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 _("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw Jr(e)}}}const Is=["metamask","phantom","brave_wallet","rainbow","uniswap_wallet_extension","uniswap_extension","rabby_wallet","bybit_wallet","ronin_wallet","crypto.com_wallet_extension","crypto.com_onchain","coinbase_wallet","coinbase_smart_wallet","metamask","trust","safe","rainbow","uniswap","zerion","argent","spot","omni","cryptocom","blockchain","safepal","bitkeep","zengo","1inch","binance","exodus","mew_wallet","alphawallet","keyring_pro","mathwallet","unstoppable","obvious","ambire","internet_money_wallet","coin98","abc_wallet","arculus_wallet","haha","cling_wallet","broearn","copiosa","burrito_wallet","enjin_wallet","plasma_wallet","avacus","bee","pitaka","pltwallet","minerva","kryptogo","prema","slingshot","kriptonio","timeless","secux","bitizen","blocto","okx_wallet","safemoon","rabby_wallet","bybit_wallet","ronin_wallet","privy","unknown","phantom","solflare","glow","backpack"],Ns=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=Ss({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=Ss({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=Ss({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="+Ss({client:this.client,isSolana:e,connectOnly:t}))}}});function xs({connectorType:e,walletClientType:t}){for(let n of Is)if(e===n||t===n)return Ns[n]}function Ss({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,""))}class Rs extends Qr{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 Ye(void 0,Vn),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}}class Os extends Ta{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)return;e&&this.removeAllConnectors(),Zr.get($n)&&(Zr.getKeys().forEach((e=>{e.startsWith("walletconnect")&&Zr.del(e)})),Zr.del($n));let t=et({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(Ns)))!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 Rs({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(tt).find((t=>t.connectorType===e))??null:this.walletConnectors.filter(tt).find((n=>n.connectorType===e&&n.walletClientType===t))??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(Xr).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.saveConnectionHistory(),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&(this.saveConnectionHistory(),this.emit("walletsUpdated"))}addEmbeddedWalletConnectors({walletProxy:e,rootWallet:t,embeddedWallets:n,defaultChain:r,appId:a}){for(let i of n){let n=this.findEmbeddedWalletConnectors().find((e=>e.walletIndex===i.walletIndex));if(n&&tt(n))n.proxyProvider.walletProxy=e;else{let{entropyId:n,entropyIdVerifier:o}=jn(t),s=new ds({provider:new fs({walletProxy:e,address:i.address,entropyId:n,entropyIdVerifier:o,rpcConfig:this.rpcConfig,chains:this.chains,appId:a,chainId:r.id,walletIndex:i.walletIndex}),chains:this.chains,defaultChain:r,rpcConfig:this.rpcConfig,imported:!1,walletIndex:i.walletIndex});this.addWalletConnector(s)}}}addImportedWalletConnector(e,t,n,r){let a=this.findWalletConnector("embedded_imported","privy");if(a&&tt(a))a.proxyProvider.walletProxy=e;else{let a=new ds({provider:new fs({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.saveConnectionHistory(),this.storedConnections=ea(),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.saveConnectionHistory(),this.storedConnections=ea(),this.emit("walletsUpdated")}}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:n,walletConfig:r}){let a=this.findWalletConnector(e,t);if(a&&tt(a))return a instanceof nt&&a.resetConnection(t),a;let i=(()=>"injected"!==e?"coinbase_wallet"===e?new ls(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig,this.privyAppName,this.privyAppLogo):"null"!==e?new nt(this.walletConnectCloudProjectId,this.rpcConfig,this.chains,this.defaultChain,this.shouldEnforceDefaultChainOnConnect,this.privyAppId,this.privyAppName,t):r?new ws({id:r.client,name:r.name,defaultChain:this.defaultChain,walletClientType:r.client}):null:"metamask"===t&&n?.eip6963InjectedProvider?new ks(this.chains,this.defaultChain,this.rpcConfig,n?.eip6963InjectedProvider,"metamask"):"metamask"===t&&n?.legacyInjectedProvider?new _s(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"metamask"):"phantom"===t&&n?.legacyInjectedProvider?new _s(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider,"phantom"):n?.legacyInjectedProvider&&"unknown_browser_extension"===t?new _s(this.chains,this.defaultChain,this.rpcConfig,n?.legacyInjectedProvider):n?.eip6963InjectedProvider?new bs(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)}))}saveConnectionHistory(){let e=this.wallets.map((e=>({address:e.address,connectorType:e.connectorType,walletClientType:e.walletClientType,connectedAt:e.connectedAt,id:e.meta.id})));Zr.put(Gn,e)}async activeWalletSign(e){let t=this.wallets,n=t.length>0?t[0]:null;return n&&rt(n)?n.sign(e):null}setActiveWallet(e){this.activeWallet=C(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 Ye},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.privyAppLogo=d,this.walletChainType=h||"ethereum-only",this.storedConnections=ea()}}let Ws=[de,he,ue];class Ms{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw b(e)}}async post(e,t,n){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...n})}catch(e){throw b(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw b(e)}}constructor({appId:e,appClientId:t,client:n,defaults:r}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=n.clientAnalyticsId,this.sdkVersion=qn,this.client=n,this.defaults=r,this.fallbackApiUrl=n.fallbackApiUrl,this.baseFetch=$a.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=Ws.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 k}})}}let Ps=/paymaster\.biconomy\.io\/api/i,Ls={mode:"SPONSORED",calculateGasLimits:!0,expiryDuration:300,sponsorshipInfo:{webhookData:{},smartAccountInfo:{name:"BICONOMY",version:"2.0.0"}}};const Ds=(e,t)=>e&&Ps.test(e)?Ls:t&&t.policy_id?{policyId:t.policy_id}:void 0;function Us(){return!(w&&window.location.origin.startsWith("http://localhost"))}const Fs=Ga((()=>({identityToken:null})));function Bs(){let{identityToken:e}=Fs();return{identityToken:e}}var zs,Hs=((zs={}).PRIVY="privy_access_token",zs.CUSTOMER="customer_access_token",zs);class Vs{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(Kn)}get privyAccessToken(){return this._getToken(Yn)}_getToken(e){try{let t=Zr.get(e);return"string"==typeof t?ns.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=Zr.get(Zn);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=Zr.get(Jn(e));if("string"!=typeof t)return null;{let n=new ns(t);return n.isExpired()?(Zr.del(Jn(e)),null):n.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=ja.get(Qn);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&&this.refreshToken!==Xn;return this.mightHaveServerCookies||t&&n}hasActiveAccessToken(e){let t=ns.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?Zr.put(Jn(e),t):Zr.del(Jn(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:er(n),isNewUser:r,oAuthTokens:i}}catch(e){throw console.warn("Error authenticating session"),I(e)}}_trackAuthenticateEvents(e,t){let n=function(e){return e instanceof _o?"email":e instanceof Zo?"sms":e instanceof at?"siwe":e instanceof xo?"guest":e instanceof bo?"custom_auth":e instanceof Wo?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:er(t),oAuthTokens:r}}catch(e){throw console.warn("Error linking account"),I(e)}}async _refresh(){if(!this.api)throw new T("Session has no API instance");if(!this.client)throw new T("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(de,t?{refresh_token:t}:{},{headers:r})}return this.handleTokenResponse(n),er(n.user)}catch(e){if(e instanceof N&&e.privyErrorCode===A.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw I(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(he,{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=Zr.get(Kn);if(Zr.put(Kn,e),!this.client?.useServerCookies){let t=ns.parse(e)?.expiration;ja.set(tr,e,{sameSite:"Strict",secure:Us(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else Zr.del(Kn),ja.remove(tr),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(Zr.put(Zn,e),this.client?.useServerCookies||ja.set(Qn,"t",{sameSite:"Strict",secure:Us(),expires:30})):(Zr.del(Zn),ja.remove(nr),ja.remove(Qn))}storePrivyAccessToken(e){"string"==typeof e?Zr.put(Yn,e):Zr.del(Yn)}storeIdentityToken(e){if(Fs.setState({identityToken:e}),this.client?.useServerCookies)return;Zr.put(rr,e);let t=ns.parse(e)?.expiration;ja.set(ar,e,{sameSite:"Strict",secure:Us(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){Zr.del(rr),Fs.setState({identityToken:null}),ja.remove(ar)}constructor(){this.authenticateOnce=new Ge((async e=>this._authenticate(e))),this.linkOnce=new Ge((async e=>this._link(e))),this.refreshOnce=new Ge(this._refresh.bind(this)),this.destroyOnce=new Ge(this._destroy.bind(this))}}let $s;var js=0,Gs="__private_"+js+++"__getOrGenerateClientAnalyticsId";class qs{initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:n,defaultChain:r,store:a,walletList:i,shouldEnforceDefaultChainOnConnect:o,externalWalletConfig:s,appName:l,walletChainType:c}){this.connectors||(this.connectors=new Os(this.appId,e,t,n,r,a,i,o,s,l,void 0,c))}generateApi(){let e=new Ms({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 T("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new T("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(pe,{action:"verify"})}catch(e){throw b(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(me,{})).options)}catch(e){throw b(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(ye,{});return er(e)}catch(e){throw I(e)}}async unlinkEmail(e){try{let t=await this.api.post(ge,{address:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkPhone(e){try{let t=await this.api.post(fe,{phoneNumber:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(we,{address:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(ve,{address:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkOAuth(e,t){try{let n=await this.api.post(Ce,{provider:e,subject:t});return await this.getAuthenticatedUser()??er(n)}catch(e){throw I(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(Ee,{fid:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async unlinkTelegram(e){try{let t=await this.api.post(Te,{telegram_user_id:e});return await this.getAuthenticatedUser()??er(t)}catch(e){throw I(e)}}async revokeDelegatedWallet(){try{await this.api.post(be,{})}catch(e){throw I(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(ue,{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(Ae,e)}catch(e){throw I(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(_e,e)}catch(e){throw I(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${ke}?partnerUserId=${e}`)}catch(e){throw I(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(Hs.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(Hs.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?rs.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:Ds(e.paymaster_url,e.paymaster_context)})))}:{enabled:n.enabled}}catch(e){throw I(e)}}async getServerConfig(){try{let e={},t=this.session.token;t&&(e.authorization=`Bearer ${t}`);let n=await this.api.get(`/api/v1/apps/${this.appId}`,{baseURL:this.fallbackApiUrl,headers:e}),r=n.telegram_auth_config?{botId:n.telegram_auth_config.bot_id,botName:n.telegram_auth_config.bot_name,linkEnabled:n.telegram_auth_config.link_enabled,seamlessAuthEnabled:n.telegram_auth_config.seamless_auth_enabled}:void 0,a=n.funding_config?{methods:n.funding_config.methods,options:n.funding_config.options,defaultRecommendedAmount:n.funding_config.default_recommended_amount,defaultRecommendedCurrency:n.funding_config.default_recommended_currency,promptFundingOnWalletCreation:n.funding_config.prompt_funding_on_wallet_creation,crossChainBridgingEnabled:n.funding_config.cross_chain_bridging_enabled}:void 0;return{id:n.id,name:n.name,verificationKey:n.verification_key,logoUrl:n.logo_url||void 0,accentColor:n.accent_color||void 0,showWalletLoginFirst:n.show_wallet_login_first,allowlistConfig:{errorTitle:n.allowlist_config.error_title,errorDetail:n.allowlist_config.error_detail,errorCtaText:n.allowlist_config.cta_text,errorCtaLink:n.allowlist_config.cta_link},walletAuth:n.wallet_auth,solanaWalletAuth:n.solana_wallet_auth,emailAuth:n.email_auth,smsAuth:n.sms_auth,googleOAuth:n.google_oauth,twitterOAuth:n.twitter_oauth,discordOAuth:n.discord_oauth,githubOAuth:n.github_oauth,spotifyOAuth:n.spotify_oauth,instagramOAuth:n.instagram_oauth,tiktokOAuth:n.tiktok_oauth,linkedinOAuth:n.linkedin_oauth,appleOAuth:n.apple_oauth,farcasterAuth:n.farcaster_auth,passkeyAuth:n.passkey_auth,passkeysForSignupEnabled:n.passkeys_for_signup_enabled,telegramAuth:n.telegram_auth,disablePlusEmails:n.disable_plus_emails,termsAndConditionsUrl:n.terms_and_conditions_url,embeddedWalletConfig:{ethereum:{createOnLogin:n.embedded_wallet_config.ethereum?.create_on_login??n.embedded_wallet_config.create_on_login},solana:{createOnLogin:n.embedded_wallet_config.solana?.create_on_login??"off"},userOwnedRecoveryOptions:n.embedded_wallet_config.user_owned_recovery_options,requireUserOwnedRecoveryOnCreate:n.embedded_wallet_config.require_user_owned_recovery_on_create},privacyPolicyUrl:n.privacy_policy_url,requireUsersAcceptTerms:n.require_users_accept_terms,customApiUrl:n.custom_api_url,walletConnectCloudProjectId:n.wallet_connect_cloud_project_id,fiatOnRampEnabled:n.fiat_on_ramp_enabled,captchaEnabled:n.captcha_enabled,captchaSiteKey:n.captcha_site_key,createdAt:new Date(1e3*n.created_at),updatedAt:new Date(1e3*n.updated_at),mfaMethods:n.mfa_methods,enforceWalletUis:n.enforce_wallet_uis,legacyWalletUiConfig:n.legacy_wallet_ui_config,telegramAuthConfiguration:r,fundingConfig:a}}catch(e){throw I(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(Ie,{address:e,token:t})).nonce}catch(e){throw I(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:n,walletClientType:r,connectorType:a,mode:i}){return await this.api.post(Ne,{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(xe,{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(Se,{message:e,signature:t,smart_wallet_type:n});return er(r)}catch(e){throw I(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 er(i)}catch(e){throw I(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(Re,{address:e,token:t})).nonce}catch(e){throw I(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r,mode:a}){return await this.api.post(Oe,{message:e,signature:t,walletClientType:n,connectorType:r,mode:a})}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=Ue,c={nonce:e,email:t};break;case"sms":l=De,c={nonce:e,phoneNumber:t};break;case"siwe":if(l=Le,!r)throw Error("Wallet parameters must be defined");c={nonce:e,address:t,...r};break;case"farcaster":l=Pe,c={nonce:e,farcaster_id:t,farcaster_embedded_address:o};break;case"telegram":l=Me,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=We,c={nonce:e,userInfo:s}}let d=await this.api.post(l,c);return await this.getAuthenticatedUser()??er(d)}catch(e){throw I(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r}){return await this.api.post(Fe,{message:e,signature:t,walletClientType:n,connectorType:r})}async linkWithSiws({message:e,signature:t,walletClientType:n,connectorType:r}){try{let a=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:n,connectorType:r});return er(a)}catch(e){throw I(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(Be);return this.session.updateIdentityToken(e.identity_token),er(e.user)}catch(e){throw I(e)}}async scanTransaction(e){try{return await this.api.post(ze,e)}catch(e){throw I(e)}}constructor({apiUrl:e=ir,appId:t,appClientId:n,timeout:r=or}){Object.defineProperty(this,Gs,{value:Ks}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==ir&&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,Gs)[Gs](),$s||($s=new Vs),this.session=$s,this.api=this.generateApi(),this.session.client=this}}function Ks(){if("undefined"==typeof window)return null;try{let e=Zr.get(sr);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=Ea();try{return Zr.put(sr,e),e}catch(t){return e}}const Ys=e=>{let{enabled:n,siteKey:r,appId:a,setError:s,setToken:l,setExecuting:c,ref:d}=it(),[,h]=i((()=>r?.split("t:")||[]),[r]);if(o((()=>d.current?.remove),[]),!n)return null;if(!h)throw Error("Unsupported captcha site key");/*#__PURE__*/return t("div",{className:"hidden h-0 w-0",children:/*#__PURE__*/t(qa,{...e,ref:d,siteKey:h,options:{action:a,size:"invisible",...e.delayedExecution?{appearance:"execute",execution:"execute"}:{appearance:"always",execution:"render"}},onUnsupported:()=>{e.onUnsupported?.(),console.warn("Browser does not support Turnstile.")},onError:()=>{e.onError?.(),s("Captcha failed"),c(!1)},onSuccess:t=>{e.onSuccess?.(t),l(t),c(!1)},onExpire:()=>{e.onExpire?.();try{d.current?.reset(),s(void 0),l(void 0)}catch(e){s("expired_and_failed_reset")}}})})};function Zs(e){ta("configureMfa",e)}const Js=/*#__PURE__*/Ka.span.withConfig({displayName:"CircleBackground",componentId:"sc-c9f33cd-0"})(["&&{width:82px;height:82px;border-width:4px;border-style:solid;border-color:",";background-color:",";border-radius:50%;display:inline-block;box-sizing:border-box;}"],(e=>e.color??"var(--privy-color-accent)"),(e=>e.color??"var(--privy-color-accent)"));let Qs=/*#__PURE__*/Ka.div.withConfig({displayName:"StackedContainer",componentId:"sc-f7e7d474-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]);const Xs=/*#__PURE__*/Ka.div.withConfig({displayName:"Grow",componentId:"sc-ddbf22b4-0"})(["text-align:left;flex-grow:1;"]),el=/*#__PURE__*/Ka.div.withConfig({displayName:"AlignBottom",componentId:"sc-ddbf22b4-1"})(["display:flex;flex-direction:column;justify-content:flex-end;flex-grow:1;"]),tl=/*#__PURE__*/Ka.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;}"]),nl=/*#__PURE__*/Ka(tl).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 rl=/*#__PURE__*/Ya(["&&{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 al=/*#__PURE__*/Ka.div.withConfig({displayName:"Subtitle",componentId:"sc-ddbf22b4-4"})(["text-align:center;font-size:14px;margin-bottom:24px;"]),il=/*#__PURE__*/Ka.button.attrs({className:"login-method-button"}).withConfig({displayName:"LoginMethodButton",componentId:"sc-ddbf22b4-5"})(["",""],rl),ol=/*#__PURE__*/Ka.a.withConfig({displayName:"LoginMethodButtonLink",componentId:"sc-ddbf22b4-6"})(["",""],rl),sl=/*#__PURE__*/Ka.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;":"")),ll=/*#__PURE__*/Ka.div.withConfig({displayName:"EmptyWalletState",componentId:"sc-ddbf22b4-8"})(["width:100%;height:100%;padding:",";"],(e=>e.$withPadding?"64px 0px":"0px")),cl=/*#__PURE__*/Ka.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;}"]);let dl=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-a3e74b9e-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;margin-top:24px;"]),hl=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-a3e74b9e-1"})(["display:flex;flex-direction:column;gap:8px;"]);const ul=/*#__PURE__*/Ka.span.withConfig({displayName:"CircleBorder",componentId:"sc-9056b8b8-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;border-bottom-color:",";}"],(e=>e.color??"var(--privy-color-accent)"),(e=>e.color??"var(--privy-color-accent)"));function pl(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...n,children:[/*#__PURE__*/t("circle",{cx:"12",cy:"12",r:"10"}),/*#__PURE__*/t("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),/*#__PURE__*/t("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})}const ml=({onTransfer:e,isTransferring:n,transferSuccess:r})=>/*#__PURE__*/t(st,{...r?{success:!0,children:"Success!"}:{warn:!0,loading:n,onClick:e,children:"Transfer and delete account"}}),yl=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-aa2e65ff-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;width:100%;padding-bottom:16px;"]),gl=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-aa2e65ff-1"})(["display:flex;flex-direction:column;&& p{font-size:14px;}width:100%;gap:16px;"]),fl=/*#__PURE__*/Ka.div.withConfig({displayName:"DisclosedAccountContainer",componentId:"sc-aa2e65ff-2"})(["display:flex;cursor:pointer;align-items:center;width:100%;border:1px solid var(--privy-color-foreground-4) !important;border-radius:var(--privy-border-radius-md);padding:8px 10px;font-size:14px;font-weight:500;gap:8px;"]),wl=/*#__PURE__*/Ka(ei).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-aa2e65ff-3"})(["position:relative;width:",";height:",";color:var(--privy-color-foreground-3);margin-left:auto;"],(e=>`${e.iconSize}px`),(e=>`${e.iconSize}px`)),vl=/*#__PURE__*/Ka(ti).withConfig({displayName:"StyledCopyIcon",componentId:"sc-aa2e65ff-4"})(["position:relative;width:15px;height:15px;color:var(--privy-color-foreground-3);margin-left:auto;"]),Cl=/*#__PURE__*/Ka.ol.withConfig({displayName:"ListContainer",componentId:"sc-aa2e65ff-5"})(["display:flex;flex-direction:column;font-size:14px;width:100%;text-align:left;"]),El=/*#__PURE__*/Ka.li.withConfig({displayName:"ListItem",componentId:"sc-aa2e65ff-6"})(["font-size:14px;list-style-type:auto;list-style-position:outside;margin-left:1rem;margin-bottom:0.5rem;&:last-child{margin-bottom:0;}"]),Tl=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleContainer",componentId:"sc-aa2e65ff-7"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]);let bl=()=>/*#__PURE__*/t(Tl,{children:/*#__PURE__*/t(wl,{iconSize:60})});const Al=({address:r,onClose:a,onRetry:i,onTransfer:o,isTransferring:s,transferSuccess:l})=>{let{defaultChain:c}=dr(),d=c.blockExplorers?.default.url??"https://etherscan.io";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:a,backFn:i}),/*#__PURE__*/e(yl,{children:[/*#__PURE__*/t(bl,{}),/*#__PURE__*/e(gl,{children:[/*#__PURE__*/t("h3",{children:"Check account assets before transferring"}),/*#__PURE__*/t("p",{children:"Before transferring, ensure there are no assets in the other account. Assets in that account will not transfer automatically and may be lost."}),/*#__PURE__*/e(Cl,{children:[/*#__PURE__*/t("p",{children:" To check your balance, you can:"}),/*#__PURE__*/t(El,{children:"Log out and log back into the other account, or "}),/*#__PURE__*/e(El,{children:["Copy your wallet address and use a"," ",/*#__PURE__*/t("u",{children:/*#__PURE__*/t("a",{target:"_blank",href:d,children:"block explorer"})})," ","to see if the account holds any assets."]})]}),/*#__PURE__*/e(fl,{onClick:()=>navigator.clipboard.writeText(r).catch(console.error),children:[/*#__PURE__*/t(Xa,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),/*#__PURE__*/t(lt,{address:r,showCopyIcon:!1}),/*#__PURE__*/t(vl,{})]}),/*#__PURE__*/t(ml,{onTransfer:o,isTransferring:s,transferSuccess:l})]})]}),/*#__PURE__*/t(ct,{})]})},_l=({onClose:r,onContinue:a,onInfo:i,onTransfer:o,transferSuccess:s,isTransferring:l,data:c})=>{if(!c?.accountTransfer?.linkMethod||!c?.accountTransfer?.displayName)return;let d={method:c?.accountTransfer?.linkMethod,handle:c?.accountTransfer?.displayName,disclosedAccount:c?.accountTransfer?.embeddedWalletAddress?{type:"wallet",handle:c?.accountTransfer?.embeddedWalletAddress}:void 0};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{closeable:!0}),/*#__PURE__*/e(yl,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(ul,{color:"var(--privy-color-error)"}),/*#__PURE__*/t(Qa,{height:38,width:38,stroke:"var(--privy-color-error)"})]})}),/*#__PURE__*/e(gl,{children:[/*#__PURE__*/e("h3",{children:[function(e){switch(e){case"sms":return"Phone number";case"email":return"Email address";case"siwe":return"Wallet address";case"linkedin":return"LinkedIn profile";case"google":case"apple":case"discord":case"github":case"instagram":case"spotify":case"tiktok":case"twitter":case"telegram":case"farcaster":return`${Mo(e.replace("_oauth",""))} profile`;default:return e}}(d.method)," is associated with another account"]}),/*#__PURE__*/e("p",{children:["Do you want to transfer",/*#__PURE__*/t("b",{children:d.handle?` ${d.handle}`:""})," to this account instead? This will delete your other account."]}),/*#__PURE__*/t(kl,{onClick:i,disclosedAccount:d.disclosedAccount})]}),/*#__PURE__*/e(gl,{style:{gap:12,marginTop:12},children:[c?.accountTransfer?.embeddedWalletAddress?/*#__PURE__*/t(st,{onClick:a,children:"Continue"}):/*#__PURE__*/t(ml,{onTransfer:o,transferSuccess:s,isTransferring:l}),/*#__PURE__*/t(dt,{onClick:r,children:"No thanks"})]})]}),/*#__PURE__*/t(ct,{})]})};function kl({disclosedAccount:n,onClick:r}){return n?/*#__PURE__*/e(fl,{onClick:r,children:[/*#__PURE__*/t(Xa,{color:"var(--privy-color-foreground-1)",strokeWidth:2,height:"28px",width:"28px"}),/*#__PURE__*/t(lt,{address:n.handle,showCopyIcon:!1}),/*#__PURE__*/t(pl,{width:15,height:15,color:"var(--privy-color-foreground-3)",style:{marginLeft:"auto"}})]}):null}const Il=/*#__PURE__*/Ka.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a63b1990-0"})(["display:flex;flex-direction:column;align-items:center;padding:0px 0px 30px;@media (max-width:440px){padding:10px 10px 20px;}"]),Nl=/*#__PURE__*/Ka.div.withConfig({displayName:"Title",componentId:"sc-a63b1990-1"})(["font-size:18px;line-height:30px;text-align:center;font-weight:600;margin-bottom:10px;"]),xl=/*#__PURE__*/Ka.div.withConfig({displayName:"SubTitle",componentId:"sc-a63b1990-2"})(["font-size:0.875rem;text-align:center;"]),Sl=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-a63b1990-3"})(["display:flex;flex-direction:column;align-items:center;gap:10px;flex-grow:1;padding:20px 0;@media (max-width:440px){padding:10px 10px 20px;}"]),Rl=/*#__PURE__*/Ka.div.withConfig({displayName:"List",componentId:"sc-a63b1990-4"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.75rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),Ol=/*#__PURE__*/Ka.div.withConfig({displayName:"ListItemIcon",componentId:"sc-a63b1990-5"})(["width:25px;display:flex;align-items:center;justify-content:flex-start;> svg{z-index:2;height:25px !important;width:25px !important;color:var(--privy-color-accent);}"]),Wl=/*#__PURE__*/Ka.div.withConfig({displayName:"ListItem",componentId:"sc-a63b1990-6"})(["display:flex;align-items:center;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;"]),Ml=/*#__PURE__*/Ka.div.withConfig({displayName:"BottomSection",componentId:"sc-a63b1990-7"})(["display:flex;flex-direction:column;gap:10px;padding-top:20px;"]),Pl=/*#__PURE__*/Ka.div.withConfig({displayName:"MethodList",componentId:"sc-a63b1990-8"})(["display:flex;flex-direction:column;align-items:stretch;gap:1rem;padding:1rem 0rem 0rem;flex-grow:1;width:100%;"]),Ll=/*#__PURE__*/Ka.div.withConfig({displayName:"MethodListItem",componentId:"sc-a63b1990-9"})(["display:flex;gap:5px;width:100%;position:relative;"]),Dl=/*#__PURE__*/Ka.button.withConfig({displayName:"RemoveMethodButton",componentId:"sc-a63b1990-10"})(["&&{background-color:transparent;color:var(--privy-color-foreground-3);padding:0 0.75rem;display:flex;align-items:center;height:100%;> svg{z-index:2;height:20px !important;width:20px !important;}}&&:hover{color:var(--privy-color-error);}"]),Ul=/*#__PURE__*/Ka.div.withConfig({displayName:"MethodText",componentId:"sc-a63b1990-11"})(["display:flex;align-items:center;gap:0.5rem;> svg{z-index:2;height:20px !important;width:20px !important;}"]),Fl=/*#__PURE__*/Ka.div.withConfig({displayName:"ExtraText",componentId:"sc-a63b1990-12"})(["display:flex;align-items:center;gap:6px;font-weight:400 !important;color:",";> svg{z-index:2;height:18px !important;width:18px !important;display:flex !important;align-items:flex-end;}"],(e=>e.isAccent?"var(--privy-color-accent)":"var(--privy-color-foreground-3)")),Bl=/*#__PURE__*/Ka.div.withConfig({displayName:"SmsInsecureText",componentId:"sc-a63b1990-13"})(["width:100%;display:flex;justify-content:space-between;"]),zl=/*#__PURE__*/Ka.p.withConfig({displayName:"TermsText",componentId:"sc-a63b1990-14"})(["text-align:left;width:100%;color:var(--privy-color-foreground-3) !important;"]),Hl=/*#__PURE__*/Ka.button.withConfig({displayName:"PrimaryTextButton",componentId:"sc-a63b1990-15"})(["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:0.875rem;line-height:1rem;font-style:normal;font-weight:500;line-height:22px;letter-spacing:-0.016px;}&&{color:",";background-color:transparent;padding:0.5rem 0px;}&:hover{text-decoration:underline;}"],(e=>"dark"===e.theme?"var(--privy-color-foreground-2)":"var(--privy-color-accent)")),Vl=/*#__PURE__*/Ka.div.withConfig({displayName:"IconWrapper",componentId:"sc-a63b1990-16"})(["display:flex;align-items:center;justify-content:center;color:var(--privy-color-accent);width:100%;> svg{z-index:2;width:3rem;height:3rem;}"]),$l=/*#__PURE__*/Ka.div.withConfig({displayName:"ErrorMessage",componentId:"sc-a63b1990-17"})(["color:var(--privy-color-error);"]),jl=({termsAndConditionsUrl:r,privacyPolicyUrl:a,onAccept:i,onDecline:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1}),/*#__PURE__*/t(ri,{width:56,height:56,fill:"var(--privy-color-accent)",style:{margin:"auto"}}),/*#__PURE__*/t(Nl,{style:{marginTop:24},children:"One last step"}),/*#__PURE__*/t(xl,{children:"By signing up, you agree to our terms and privacy policy."}),/*#__PURE__*/e(tl,{style:{marginTop:24},children:[r&&/*#__PURE__*/e(ol,{target:"_blank",href:r,children:["View Terms ",/*#__PURE__*/t(ni,{style:{marginLeft:"auto"}})]}),a&&/*#__PURE__*/e(ol,{target:"_blank",href:a,children:["View Privacy Policy ",/*#__PURE__*/t(ni,{style:{marginLeft:"auto"}})]})]}),/*#__PURE__*/e(Gl,{style:{marginTop:24},children:[/*#__PURE__*/t(dt,{onClick:o,children:"No thanks"}),/*#__PURE__*/t(st,{onClick:i,children:"Accept"})]}),/*#__PURE__*/t(ct,{})]});let Gl=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-d601b243-0"})(["display:flex;gap:10px;"]);const ql=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...n,children:/*#__PURE__*/t("path",{fillRule:"evenodd",d:"M12 1.5a5.25 5.25 0 00-5.25 5.25v3a3 3 0 00-3 3v6.75a3 3 0 003 3h10.5a3 3 0 003-3v-6.75a3 3 0 00-3-3v-3c0-2.9-2.35-5.25-5.25-5.25zm3.75 8.25v-3a3.75 3.75 0 10-7.5 0v3h7.5z",clipRule:"evenodd"})});let Kl=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-ed4ecf-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),Yl=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-ed4ecf-1"})(["display:flex;flex-direction:column;gap:8px;"]);const Zl=({title:r,description:a,children:i,...o})=>
2
+ /*#__PURE__*/t(Xl,{...o,children:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("h3",{children:r}),"string"==typeof a?/*#__PURE__*/t("p",{children:a}):a,i]})}),Jl=/*#__PURE__*/Ka(Zl).withConfig({displayName:"PaddedScreenHeader",componentId:"sc-523a75d6-0"})(["margin-bottom:24px;"]),Ql=({title:n,description:r,icon:a,children:i,...o})=>/*#__PURE__*/e(ec,{...o,children:[a||null,/*#__PURE__*/t("h3",{children:n}),r&&"string"==typeof r?/*#__PURE__*/t("p",{children:r}):r,i]});let Xl=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledSection",componentId:"sc-523a75d6-1"})(["display:flex;flex-direction:column;justify-content:flex-start;align-items:flex-start;text-align:left;gap:8px;width:100%;margin-bottom:24px;&& h3{font-size:17px;color:var(--privy-color-foreground);}&& p{color:var(--privy-color-foreground-2);font-size:14px;}"]),ec=/*#__PURE__*/Ka(Xl).withConfig({displayName:"CenteredStyledSection",componentId:"sc-523a75d6-2"})(["align-items:center;text-align:center;gap:16px;h3{margin-bottom:24px;}"]),tc=Array(6).fill("");var nc,rc,ic=((nc=ic||{})[nc.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",nc[nc.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",nc),oc=((rc=oc||{})[rc.EMAIL=0]="EMAIL",rc[rc.SMS=1]="SMS",rc);let sc=/*#__PURE__*/Ka.div.withConfig({displayName:"PasswordlessCodeContainer",componentId:"sc-bf1e04a-0"})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:center;margin:auto;gap:16px;flex-grow:1;"]),lc=/*#__PURE__*/Ka.div.withConfig({displayName:"CodeInput",componentId:"sc-bf1e04a-1"})(["display:flex;flex-direction:column;width:100%;gap:8px;> div:last-child{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: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);}}"]),cc=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-bf1e04a-2"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-end;width:100%;"],(e=>e.$success?"var(--privy-color-success)":e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),dc=/*#__PURE__*/Ka.div.withConfig({displayName:"HelpText",componentId:"sc-bf1e04a-3"})(["font-size:13px;color:var(--privy-color-foreground);display:flex;gap:8px;align-items:center;width:100%;margin-top:16px;padding-bottom:32px;"]),hc=/*#__PURE__*/Ka.div.withConfig({displayName:"ResendButtonContainer",componentId:"sc-bf1e04a-4"})(["color:var(--privy-color-accent);padding:2px 0;> button{text-decoration:underline;}"]),uc=/*#__PURE__*/Ka.div.withConfig({displayName:"Badge",componentId:"sc-bf1e04a-5"})(["display:flex;align-items:center;justify-content:center;border-radius:var(--privy-border-radius-sm);padding:2px 8px;gap:4px;background:var(--privy-color-background-2);color:var(--privy-color-foreground-2);"]),pc=/*#__PURE__*/Ka.span.withConfig({displayName:"BoldWrappingSpan",componentId:"sc-bf1e04a-6"})(["font-weight:500;word-break:break-all;"]);const mc=({icon:r})=>/*#__PURE__*/t(n,{children:/*#__PURE__*/t(yc,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{}),"string"==typeof r?
3
3
  /*#__PURE__*/t("span",{style:{background:`url('${r}')`,height:"38px",width:"38px",borderRadius:"6px",margin:"auto",backgroundSize:"cover"}}):r?/*#__PURE__*/t(r,{style:{width:"38px",height:"38px"}}):
4
- /*#__PURE__*/t("span",{})]})})});let yc=/*#__PURE__*/Ka.div.withConfig({displayName:"StackedContainer",componentId:"sc-26c1d9b9-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]);let gc=/*#__PURE__*/Ka.div.withConfig({displayName:"CaptchaContainer",componentId:"sc-9afcf974-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const fc=({chainType:n,withPadding:r})=>{let a="";return a="ethereum-only"===n||"ethereum-and-solana"===n?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/t(ll,{$withPadding:r,children:/*#__PURE__*/e(cl,{children:[/*#__PURE__*/t(Ja,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/t("h3",{children:"No wallets available"}),/*#__PURE__*/e("p",{children:["Please download an external wallet provider, like ",a,"."]})]})},"empty-wallet-state")},wc=({icon:e,name:n})=>"string"==typeof e?/*#__PURE__*/t("img",{alt:`${n||"wallet"} logo`,src:e,style:{height:24,width:24,borderRadius:4}}):void 0===e?/*#__PURE__*/t(Xa,{}):e?/*#__PURE__*/t(e,{}):null;function vc(e){let t=e.toLowerCase();return!!window?.webkit?.messageHandlers?.ReactNativeWebView||!!window?.ReactNativeWebView||["fbav","fban","instagram","snapchat","linkedinapp"].some((e=>t.includes(e)))}const Cc=({provider:n,displayName:r,logo:a,connectOnly:i,connector:o})=>{let s,{navigate:l,setModalData:c}=lr(),{connectWallet:d}=x(),u=gt(),h=ft(n),p="wallet_connect_v2"===o.connectorType?n:o.walletClientType,m=window.matchMedia("(display-mode: standalone)").matches,g=xs({connectorType:o.connectorType,walletClientType:p});s=g&&g.chainTypes.includes(o.chainType)?()=>{g.isInstalled||"solana"===o.chainType&&"isInstalled"in o&&o.isInstalled?(d(o,p),l(i?cr.AWAITING_CONNECT_ONLY_CONNECTION:cr.AWAITING_CONNECTION)):y?(c({installWalletModalData:{walletConfig:g,chainType:o.chainType,connectOnly:i}}),l(cr.WALLET_INTERSTITIAL_SCREEN)):(c({installWalletModalData:{walletConfig:g,chainType:o.chainType,connectOnly:i}}),l(cr.INSTALL_WALLET_SCREEN))}:"coinbase_wallet"!==o.connectorType||"eoaOnly"!==o.connectionOptions||!y||m||wt()?()=>{(!vc(window.navigator.userAgent)||event?.isTrusted)&&(d(o,p),l(i?cr.AWAITING_CONNECT_ONLY_CONNECTION:cr.AWAITING_CONNECTION))}:()=>{window.location.href=`https://go.cb-w.com/dapp?cb_url=${encodeURI(window.location.href)}`};let f=r||h?.metadata?.shortName||h?.name||o.walletClientType;/*#__PURE__*/return e(Ec,{onClick:s,children:[/*#__PURE__*/t(wc,{icon:a||h?.image_url?.md,name:f}),/*#__PURE__*/t("span",{children:f}),/*#__PURE__*/e(bc,{id:"chip-container",children:[u?.walletClientType===p&&u?.chainType===o.chainType?/*#__PURE__*/t(Tc,{color:"gray",children:"Recent"}):/*#__PURE__*/t("span",{id:"connect-text",children:"Connect"}),"solana"===o.chainType&&/*#__PURE__*/t(Tc,{color:"gray",children:"Solana"})]})]})};let Ec=/*#__PURE__*/Ka(il).withConfig({displayName:"ConnectWalletButton",componentId:"sc-c6a554d4-0"})(["> #chip-container > #connect-text{font-weight:500;color:var(--privy-color-accent);opacity:0;transition:opacity 0.1s ease-out;}:hover > #chip-container > #connect-text{opacity:1;}@media (max-width:440px){> #chip-container > #connect-text{display:none;}}"]),Tc=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-c6a554d4-1"})(["margin-left:auto;"]),bc=/*#__PURE__*/Ka.div.withConfig({displayName:"ChipContainer",componentId:"sc-c6a554d4-2"})(["display:flex;flex-wrap:wrap;gap:8px;margin-left:auto;"]);const Ac=["coinbase_wallet"];let _c=["metamask","okx_wallet","rainbow","uniswap","bybit_wallet","ronin_wallet","uniswap_extension","zerion","rabby_wallet","cryptocom"];const kc=["safe"],Ic=["phantom","backpack","solflare","universal_profile"],Nc=({wallets:e})=>{let{app:r}=lr();return 0===e.length?/*#__PURE__*/t(fc,{chainType:r.appearance.walletChainType,withPadding:!0}):/*#__PURE__*/t(n,{children:e})},xc=({walletList:e,walletChainType:n,connectors:r,connectOnly:a,ignore:i,walletConnectEnabled:o,forceWallet:s})=>{let l=[],c=[],d=[],u=r.filter((e=>"ethereum-only"===n?"ethereum"===e.chainType:"solana-only"!==n||"solana"===e.chainType)),h=u.find((e=>"wallet_connect_v2"===e.connectorType));for(let[r,p]of(s?[s.wallet]:e).entries()){if("detected_ethereum_wallets"===p||"detected_wallets"===p)for(let[e,n]of u.filter((({chainType:e,connectorType:t,walletClientType:n})=>"solana"!==e&&("uniswap_wallet_extension"===n||"uniswap_extension"===n?!i.includes("uniswap"):"crypto.com_wallet_extension"===n||"crypto.com_onchain"===n?!i.includes("cryptocom"):"injected"===t&&!i.includes(n)))).entries()){let{walletClientType:i,walletBranding:o,chainType:s}=n;("unknown"===i?c:l).push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:i,logo:o.icon,displayName:o.name,connector:n},`${r}-${p}-${i}-${s}-${e}`))}if("detected_solana_wallets"===p||"detected_wallets"===p)for(let[e,o]of u.filter((({chainType:e,walletClientType:t})=>{if("solana"===e)return"ethereum-only"!==n&&!i.includes(t)})).entries()){let{walletClientType:n,walletBranding:i,chainType:s}=o;("unknown"===n?c:l).push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:n,logo:i.icon,displayName:i.name,connector:o},`${r}-${p}-${n}-${s}-${e}`))}if(Ic.includes(p)){let e=u.find((e=>"injected"===e.connectorType&&e.walletClientType===p||e.connectorType===p));if(e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e},`${r}-${p}`)),"solana-only"===n||"ethereum-and-solana"===n){let e=u.find((({chainType:e,walletClientType:t})=>"solana"===e&&t===p));e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e},`${p}-solana`))}}else if(_c.includes(p)){let e=u.find((e=>"uniswap"===p?"uniswap_wallet_extension"===e.walletClientType||"uniswap_extension"===e.walletClientType:"cryptocom"===p?"crypto.com_wallet_extension"===e.walletClientType||"crypto.com_onchain"===e.walletClientType:"injected"===e.connectorType&&e.walletClientType===p));if(o&&!e&&(e=h),e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e,logo:"injected"===e.connectorType?e.walletBranding.icon:void 0,displayName:"injected"===e.connectorType?e.walletBranding.name:void 0},`${r}-${p}`)),"solana-only"===n||"ethereum-and-solana"===n){let e=u.find((({chainType:e,walletClientType:t})=>"solana"===e&&t===p));e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e},`${p}-solana`))}}else if(Ac.includes(p)){let e=u.find((({connectorType:e})=>e===p));e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e},`${r}-${p}`))}else if(kc.includes(p))h&&d.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:h},`${r}-${p}`));else if("wallet_connect"===p)h&&d.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:h,logo:h.walletBranding.icon,displayName:"Wallet Connect"},`${r}-${p}`));else if(p===s?.wallet){let n="ethereum"===s.chainType&&e.includes("detected_ethereum_wallets"),i="solana"===s.chainType&&e.includes("detected_solana_wallets");if(e.includes("detected_wallets")||n||i){let e=u.find((({walletClientType:e})=>e===p));e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,displayName:e.walletBranding?.name,logo:e.walletBranding?.icon,connector:e},`${r}-${p}`))}}}return[...c,...l,...d]};let Sc=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-4475d7d5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Rc=({name:e,logoUrl:n,size:r="38px"})=>"string"==typeof n?/*#__PURE__*/t("img",{src:n,alt:`${e??"Provider app"} logo`,style:{width:r,height:r,maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):
5
- /*#__PURE__*/t("span",{});let Oc=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-128f2a0d-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);let Wc=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-b99bc0c0-0"})(["display:flex;gap:10px;"]),Mc=/*#__PURE__*/Ka(Nt).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-b99bc0c0-1"})(["margin-top:1.5rem;"]);let Pc=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-8ff214d7-0"})(["display:flex;gap:10px;"]);const Lc=()=>/*#__PURE__*/t(Dc,{children:/*#__PURE__*/e(Uc,{children:[/*#__PURE__*/t(Fc,{}),/*#__PURE__*/t(Bc,{})]})});let Dc=/*#__PURE__*/Ka.div.withConfig({displayName:"LoadingContainer",componentId:"sc-85b54ede-0"})(["display:flex;justify-content:center;align-items:center;flex-grow:1;margin:12px;padding:16px;@media all and (display-mode:standalone){margin-bottom:30px;}"]),Uc=/*#__PURE__*/Ka.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-85b54ede-1"})(["position:relative;height:140px;width:140px;opacity:1;animation:fadein 200ms ease;"]),Fc=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleFixed",componentId:"sc-85b54ede-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;&&{border:4px solid var(--privy-color-accent-light);border-radius:50%;}"]),Bc=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleRotate",componentId:"sc-85b54ede-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:var(--privy-color-accent) transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]);const zc=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];class Hc extends Error{constructor(e,t){super(t),this.type=e}}function Vc(e){let t=e.type;return"string"==typeof t&&zc.includes(t)}function $c(e){return Vc(e)&&"wallet_not_on_device"===e.type}function jc(e){return!!Vc(e)&&"mfa_timeout"===e.type}function Gc(e){return!!Vc(e)&&"missing_or_invalid_mfa"===e.type}function qc(e){return!!Vc(e)&&"mfa_verification_max_attempts_reached"===e.type}function Kc(e){return!(!Vc(e)||!e.message.includes("code 429"))}function Yc(e){return!!function(e){let t=e.type;return"string"==typeof t&&"client_error"===t}(e)&&"MFA canceled"===e.message}function Zc({isCreatingWallet:e,skipSplashScreen:t}){return e?cr.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN:t?cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN:cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN}function Jc({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:n,isResettingPassword:r,showAutomaticRecovery:a}){return a?cr.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN:n||1===t.length?Zc({isCreatingWallet:"create"===e,skipSplashScreen:r}):cr.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN}function Qc(e){switch(e){case"user-passcode":return cr.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN;case"google-drive":case"icloud":return cr.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN;default:throw Error("Recovery method not supported")}}async function Xc({api:e,provider:t}){let n=So(),r=Ro(),a=await Oo(n);try{return"icloud"===t?{url:(await e.post(He,{client_type:"web"})).url}:{url:(await e.post(Ve,{redirect_to:window.location.href,code_challenge:a,state_code:r})).url,codeVerifier:n,stateCode:r,provider:t}}catch(e){throw b(e)}}async function ed({api:e,provider:t,stateCode:n,codeVerifier:r,authorizationCode:a}){if(!a||!n)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===a)throw new T("User denied confirmation during OAuth flow");try{return(await e.post($e,{authorization_code:a,state_code:n,code_verifier:r,provider:t})).access_token}catch(e){let t=b(e);if(t.privyErrorCode)throw new T(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new T("Invalid code during oauth flow.",void 0,A.OAUTH_USER_DENIED);throw new T("Invalid code during OAuth flow.",void 0,A.UNKNOWN_AUTH_ERROR)}}let td=/*#__PURE__*/Ka.div.withConfig({displayName:"BottomSpacing",componentId:"sc-55d2f85e-0"})(["height:44px;"]);const nd=({children:n,theme:r})=>/*#__PURE__*/e(rd,{$theme:r,children:[/*#__PURE__*/t(Qa,{width:"1.25rem",color:"dark"===r?"#FDE68A":"var(--privy-color-warn)"}),n]});let rd=/*#__PURE__*/Ka.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 id(n){let[r,a]=s(n.dimensions.width),[i,c]=s(void 0),d=l(null);o((()=>{if(d.current&&void 0===r){let{width:e}=d.current.getBoundingClientRect();a(e)}let e=getComputedStyle(document.documentElement);c({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")})}),[]);let u="ethereum"===n.walletToExport.chainType&&!n.walletToExport.imported;/*#__PURE__*/return t("div",{ref:d,children:r&&
6
- /*#__PURE__*/e(sd,{children:[/*#__PURE__*/t("iframe",{style:{position:"absolute",zIndex:1},width:r,height:n.dimensions.height,allow:"clipboard-write self *",src:Ot(n.origin,`/apps/${n.appId}/embedded-wallets/export`,{client_id:n.appClientId,primaryAddress:n.primaryWallet.address,address:n.walletToExport.address,walletIndex:n.walletToExport.walletIndex,width:`${r}px`,caid:n.clientAnalyticsId,phrase_export:u,...i},{token:n.accessToken})}),/*#__PURE__*/t(ld,{children:"Loading..."}),u&&/*#__PURE__*/t(ld,{children:"Loading..."})]})})}let od=/*#__PURE__*/Ka.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-eaab13a9-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),sd=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonContainer",componentId:"sc-eaab13a9-1"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),ld=/*#__PURE__*/Ka.div.withConfig({displayName:"LoadingButton",componentId:"sc-eaab13a9-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);"]);function cd(){let{getAccessToken:e}=ur(),{refreshSessionAndUser:t,createAnalyticsEvent:n,initializeWalletProxy:r}=x(),a=l(!1);return{createWallet:c((async({user:i,recoveryPassword:o})=>{let s=await e();if(!s)throw n({eventName:"embedded_wallet_creation_failed",payload:{error:"Missing access token for user."}}),Error("An error has occured, please login again.");try{n({eventName:"embedded_wallet_creation_started"});let e=await r(fr);if(!e)throw Error("walletProxy does not exist.");let l=new Promise(((e,t)=>{setTimeout((()=>{t(Error("walletProxy.create timed out."))}),2e4)})),c=gr(i);if(!await Promise.race([e.create({accessToken:s,recoveryPassword:o,recoveryMethod:o?"user-passcode":void 0,solanaAddress:c?.address}),l]))throw Error("walletProxy.create did not send a response.");let d=await t();if(!d)throw Error("Failed to refresh user.");let u=yr(d);if(!u)throw Error("Updated user is missing embedded wallet.");return n({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:u.address}}),a.current=!0,u}catch(i){if(a.current)return;throw n({eventName:"embedded_wallet_creation_failed",payload:{error:i.toString()}}),console.warn(i),i}}),[])}}let dd=/*#__PURE__*/Ka.div.withConfig({displayName:"BottomSpacing",componentId:"sc-e97c5a7e-0"})(["height:44px;"]),ud=/*#__PURE__*/Ya(["font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;text-align:left;transition:color 0.1s ease-in;"]);const hd=/*#__PURE__*/Ka.span.withConfig({displayName:"StatusText",componentId:"sc-3f6866a9-0"})([""," transition:color 0.1s ease-in;color:",";text-transform:",";&[aria-hidden='true']{visibility:hidden;}"],ud,(({error:e})=>e?"var(--privy-color-error)":"var(--privy-color-foreground-3)"),(({error:e})=>e?"":"capitalize")),pd=/*#__PURE__*/Ka.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-3f6866a9-1"})(["display:flex;flex-direction:column;justify-content:center;flex-grow:1;"]),md=/*#__PURE__*/Ka(st).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-3f6866a9-2"})(["",""],(e=>e.hideAnimations&&/*#__PURE__*/Ya(["&&{transition:none;}"])));let yd=/*#__PURE__*/Ya(["&&{width:100%;border-width:1px;border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);background:var(--privy-color-background);color:var(--privy-color-foreground);padding:12px;font-size:16px;font-style:normal;font-weight:300;line-height:22px;}"]);const gd=/*#__PURE__*/Ka.input.withConfig({displayName:"PasswordInput",componentId:"sc-3f6866a9-3"})([""," &::placeholder{color:var(--privy-color-foreground-3);font-style:italic;font-size:14px;}overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"],yd),fd=/*#__PURE__*/Ka.div.withConfig({displayName:"PasswordDisplay",componentId:"sc-3f6866a9-4"})(["",""],yd),wd=/*#__PURE__*/Ka.div.withConfig({displayName:"PasswordContainer",componentId:"sc-3f6866a9-5"})(["position:relative;width:100%;display:flex;align-items:center;justify-content:",";"],(({centered:e})=>e?"center":"space-between")),vd=/*#__PURE__*/Ka.div.withConfig({displayName:"Header",componentId:"sc-3f6866a9-6"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:32px 0;gap:4px;& 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;}"]),Cd=/*#__PURE__*/Ka.div.withConfig({displayName:"Details",componentId:"sc-3f6866a9-7"})(["display:flex;flex-direction:column;gap:10px;padding-bottom:1rem;"]),Ed=/*#__PURE__*/Ka.div.withConfig({displayName:"DetailItem",componentId:"sc-3f6866a9-8"})(["display:flex;text-align:left;align-items:center;gap:8px;max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;margin:0 8px;color:var(--privy-color-foreground-2);> :first-child{min-width:24px;}"]),Td=/*#__PURE__*/Ka(Pt).withConfig({displayName:"ExportButton",componentId:"sc-3f6866a9-10"})(["display:flex;flex:1;gap:4px;justify-content:center;&&{background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);border-width:1px;}"]),bd=/*#__PURE__*/Ka.div.withConfig({displayName:"InputRightIcons",componentId:"sc-3f6866a9-11"})(["position:absolute;right:0.5rem;display:flex;flex-direction:row;justify-content:space-around;align-items:center;"]),Ad=/*#__PURE__*/Ka(yi).withConfig({displayName:"RegenerateIcon",componentId:"sc-3f6866a9-12"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),_d=/*#__PURE__*/Ka(fi).withConfig({displayName:"HiddenIcon",componentId:"sc-3f6866a9-13"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),kd=/*#__PURE__*/Ka(gi).withConfig({displayName:"ShownIcon",componentId:"sc-3f6866a9-14"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),Id=/*#__PURE__*/Ka.progress.withConfig({displayName:"StrengthMeter",componentId:"sc-3f6866a9-15"})(["height:4px;width:100%;margin:8px 0;::-webkit-progress-bar{border-radius:8px;background:var(--privy-color-foreground-4);}::-webkit-progress-value{border-radius:8px;transition:all 0.1s ease-out;background:",";}"],(({label:e})=>("Strong"===e?"#78dca6":"Medium"===e&&"var(--privy-color-warn)")||"var(--privy-color-error)")),Nd=({buttonHideAnimations:r,buttonLoading:a,password:i,onSubmit:l,onBack:c})=>{let[d,u]=s(!0),[h,p]=s(!1),[m,y]=s(""),g=i===m;return o((()=>{m&&!h&&p(!0)}),[m]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1,backFn:c}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(pd,{children:[/*#__PURE__*/e(vd,{children:[/*#__PURE__*/t(Qa,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please re-enter your password below to continue."})]}),/*#__PURE__*/e(wd,{children:[/*#__PURE__*/t(gd,{value:m,onChange:e=>y(e.target.value),onKeyUp:e=>{"Enter"===e.key&&l()},onBlur:()=>p(!0),placeholder:"confirm your password",type:d?"password":"text",style:{paddingRight:"2.3rem"}}),/*#__PURE__*/t(bd,{style:{right:"0.75rem"},children:d?/*#__PURE__*/t(_d,{onClick:()=>u(!1)}):/*#__PURE__*/t(kd,{onClick:()=>u(!0)})})]}),
7
- /*#__PURE__*/t(hd,{"aria-hidden":!h||g,error:!0,children:"Passwords do not match"})]}),/*#__PURE__*/t(md,{onClick:l,loading:a,disabled:!g,hideAnimations:r,children:"Continue"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},xd=({className:n,checked:r,color:a="var(--privy-color-accent)",...i})=>/*#__PURE__*/t("label",{children:/*#__PURE__*/e(Sd,{className:n,children:[/*#__PURE__*/t(Od,{checked:r,...i}),/*#__PURE__*/t(Wd,{color:a,checked:r,children:/*#__PURE__*/t(Rd,{viewBox:"0 0 24 24",children:/*#__PURE__*/t("polyline",{points:"20 6 9 17 4 12"})})})]})});let Sd=/*#__PURE__*/Ka.div.withConfig({displayName:"CheckboxContainer",componentId:"sc-db51b935-1"})(["display:inline-block;vertical-align:middle;"]),Rd=/*#__PURE__*/Ka.svg.withConfig({displayName:"Icon",componentId:"sc-db51b935-2"})(["fill:none;stroke:white;stroke-width:3px;"]),Od=/*#__PURE__*/Ka.input.attrs({type:"checkbox"}).withConfig({displayName:"HiddenCheckbox",componentId:"sc-db51b935-3"})(["border:0;clip:rect(0 0 0 0);clippath:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px;"]),Wd=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledCheckbox",componentId:"sc-db51b935-4"})(["display:inline-block;width:18px;height:18px;transition:all 150ms;cursor:pointer;border-color:",";border-radius:3px;background:",";&&{border-width:1px;}",":focus + &{box-shadow:0 0 0 1px ",";}","{visibility:",";}"],(e=>e.color),(e=>e.checked?e.color:"var(--privy-color-background)"),Od,(e=>e.color),Rd,(e=>e.checked?"visible":"hidden"));const Md=({buttonHideAnimations:r,buttonLoading:a,onSubmit:i,onBack:o,config:l})=>{let[c,d]=s(!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1,backFn:o}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(pd,{children:[/*#__PURE__*/e(vd,{children:[/*#__PURE__*/t(Qa,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-error)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm you have saved"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Losing access to your password means you will lose access to your account."})]}),/*#__PURE__*/t(Cd,{children:/*#__PURE__*/e(Ed,{style:{color:"var(--privy-color-error)",cursor:"pointer"},onClick:e=>{e.preventDefault(),d((e=>!e))},children:[/*#__PURE__*/t(xd,{color:"var(--privy-color-error)",readOnly:!0,checked:c}),/*#__PURE__*/t(n,{children:"I understand that if I lose my password and device, I will lose access to my account and my assets."})]})})]}),/*#__PURE__*/e(Pd,{children:["user"===l.initiatedBy&&/*#__PURE__*/t(dt,{onClick:l.onCancel,disabled:a,children:"Cancel"}),/*#__PURE__*/t(md,{onClick:i,loading:a,hideAnimations:r,disabled:!c,children:"Set Password"})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})};let Pd=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-eb601350-0"})(["display:flex;gap:10px;"]),Ld=/[a-z]/,Dd=/[A-Z]/,Ud=/[0-9]/,Fd="!@#$%^&*()\\-_+.",Bd=`a-zA-Z0-9${Fd}`,zd=RegExp(`[${Fd}]`),Hd=RegExp(`[${Bd}]`);const Vd=RegExp(`^[${Bd}]{6,}$`),$d=()=>pi.generatePassphrase(4,mi);function jd(e){return e>.9?"Strong":e>.5?"Medium":"Weak"}function Gd(e=""){return(.3*function(e){if(e.length<8)return 0;let t=0;return Ld.test(e)&&(t+=1),Dd.test(e)&&(t+=1),Ud.test(e)&&(t+=1),zd.test(e)&&(t+=1),Math.max(0,Math.min(1,t/3))}(e)+hi(e)/95)/2}const qd=({buttonHideAnimations:r,buttonLoading:a,password:l="",config:c,isResettingPassword:d,onSubmit:u,onClose:h,onBack:p,onPasswordChange:m,onPasswordGenerate:y})=>{let[g,f]=s(!1),[w,v]=s(!1);o((()=>{l&&!w&&v(!0)}),[l]);let C=i((()=>w?6>(l?.length||0)?"Password must be at least 6 characters":Vd.test(l||"")?null:`Invalid characters used ( ${((e="")=>[...new Set(e.split("").filter((e=>!Hd.test(e))).map((e=>e.replace(" ","SPACE"))))])(l).join(" ")} )`:null),[l,w]),E=i((()=>C?{value:0,label:"Weak"}:function(e=""){let t=Gd(e);return{value:t,label:jd(t)}}(l)),[l,C]),T=i((()=>!l?.length||!!C),[C,l]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:h,closeable:"user"===c.initiatedBy,backFn:p}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(pd,{children:[/*#__PURE__*/e(vd,{children:[/*#__PURE__*/t(wi,{height:48,width:48,stroke:"var(--privy-color-accent)"}),/*#__PURE__*/e("h3",{style:{color:"var(--privy-color-foreground)"},children:[d?"Reset":"Set"," your password"]}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Select a strong, memorable password to secure your account."})]}),/*#__PURE__*/e(wd,{children:[/*#__PURE__*/t(gd,{value:l,onChange:e=>m(e.target.value),onKeyUp:e=>{"Enter"===e.key&&u()},placeholder:"enter or generate a strong password",type:g?"password":"text",style:{paddingRight:"3.8rem"}}),/*#__PURE__*/e(bd,{style:{width:"3.5rem"},children:[g?/*#__PURE__*/t(_d,{onClick:()=>f(!1)}):/*#__PURE__*/t(kd,{onClick:()=>f(!0)}),/*#__PURE__*/t(Ad,{onClick:y})]})]}),/*#__PURE__*/t(Id,{value:0===E.value?.01:E.value,label:E.label}),/*#__PURE__*/t(hd,{error:!!C,children:C||`Password Strength: ${w?E.label:"--"}`}),/*#__PURE__*/e(Yd,{children:[/*#__PURE__*/t(Kd,{children:/*#__PURE__*/e(Cd,{children:[/*#__PURE__*/e(Ed,{children:[/*#__PURE__*/t(si,{width:24,height:24,fill:"var(--privy-color-accent)"}),"This password is used to secure your account."]}),/*#__PURE__*/e(Ed,{children:[/*#__PURE__*/t(si,{width:24,height:24,fill:"var(--privy-color-accent)"}),"Use it to log in on a new environment, like another browser or device."]})]})}),/*#__PURE__*/t(md,{onClick:u,loading:a,disabled:T,hideAnimations:r,children:"Continue"})]})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})};let Kd=/*#__PURE__*/Ka(Cd).withConfig({displayName:"DetailsContainer",componentId:"sc-7b3b7727-0"})(["flex:1;padding-top:1rem;"]),Yd=/*#__PURE__*/Ka.div.withConfig({displayName:"LowerContainer",componentId:"sc-7b3b7727-1"})(["display:flex;flex-direction:column;height:100%;"]);const Zd=({buttonHideAnimations:r,buttonLoading:a,appName:i,password:o,onSubmit:l,onBack:d})=>{let[u,h]=s(!1),[p,m]=s(!0),y=c((()=>{h(!0),o&&navigator.clipboard.writeText(o)}),[o]),g=c((()=>{let e=document.createElement("a"),t=i.toLowerCase().replace(/[^a-z\s]/g,"").replace(/\s/g,"-"),n=new Blob([Jd(i,o)],{type:"text/plain"}),r=URL.createObjectURL(n);e.href=r,e.target="_blank",e.download=`${t}-privy-wallet-recovery.txt`,document.body.appendChild(e),e.click(),setTimeout((()=>{e.remove(),URL.revokeObjectURL(r)}),5e3)}),[o]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:d,closeable:!1}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(pd,{children:[/*#__PURE__*/e(vd,{children:[/*#__PURE__*/t(Qa,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Save your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"For your security, this password cannot be reset, so keep it somewhere safe."})]}),/*#__PURE__*/e(wd,{centered:!0,children:[/*#__PURE__*/t(fd,{children:p?"•".repeat(o.length):o}),/*#__PURE__*/t(bd,{style:{right:"0.75rem"},children:p?/*#__PURE__*/t(_d,{onClick:()=>m(!1)}):/*#__PURE__*/t(kd,{onClick:()=>m(!0)})})]}),/*#__PURE__*/e("div",{style:{display:"flex",margin:"12px 0",gap:"12px"},children:[/*#__PURE__*/t(Td,{onClick:y,children:/*#__PURE__*/e(n,u?{children:[/*#__PURE__*/t(Ci,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copied"]}:{children:[/*#__PURE__*/t(Ei,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copy"]})}),/*#__PURE__*/e(Td,{onClick:g,children:[/*#__PURE__*/t(vi,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Download"]})]})]}),/*#__PURE__*/t(md,{onClick:l,loading:a,hideAnimations:r,children:"Continue"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})};let Jd=(e,t)=>`Your wallet recovery password for ${e} is\n\n${t}\n\nYou will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;const Qd=({error:r,onClose:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,r?{children:[/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Something went wrong",description:r})]}:{children:[/*#__PURE__*/t(si,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success"})]}),/*#__PURE__*/t(st,{onClick:a,children:"Close"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let Xd=(e,t)=>{switch(e){case"creating":return"back"===t?e:"saving";case"saving":return"back"===t?"creating":"confirming";case"confirming":return"back"===t?"saving":"finalizing";case"finalizing":return"back"===t?"confirming":"done";default:return e}};const eu=({onSubmit:e,...n})=>{let{lastScreen:r,navigate:a}=lr(),{send:i,state:s}=(()=>{let[e,t]=d(Xd,"creating");return{send:t,state:e}})(),l=c((async()=>{"finalizing"===s&&await e(),i("next")}),[s,i,e]);o((()=>{let e;return"done"===s&&"automatic"===n.config.initiatedBy&&(e=setTimeout((()=>n.onClose?.()),hr)),()=>{e&&clearTimeout(e)}}),[s,n.config.initiatedBy,n.onClose]);let u=c((()=>{i("back")}),[i]),h=c((()=>{a(cr.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN)}),[r,a]);return"creating"===s?/*#__PURE__*/t(qd,{...n,onSubmit:l,onBack:r===cr.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN?h:void 0}):"saving"===s?/*#__PURE__*/t(Zd,{...n,onSubmit:l,onBack:u}):"confirming"===s?/*#__PURE__*/t(Nd,{...n,onSubmit:l,onBack:u}):"finalizing"===s?/*#__PURE__*/t(Md,{...n,onSubmit:l,onBack:u}):"done"===s?/*#__PURE__*/t(Qd,{...n,onSubmit:l}):null};let tu="0x0000000000000000000000000000000000000000";const nu=({destinationCurrency:e,...t})=>({tradeType:"EXPECTED_OUTPUT",originCurrency:tu,destinationCurrency:e??tu,...t});let ru="https://api.relay.link",au="https://api.testnets.relay.link";const iu=async({input:e,isTestnet:t})=>{let n=await fetch((t?au:ru)+"/quote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await n.json();if(!(n.ok||"string"==typeof r.message&&r.message.startsWith("Invalid address")))throw console.error("Relay error:",r),Error(r.message??"Error fetching quote from relay");return r},ou=e=>{let t=e.steps[0]?.items?.[0];if(t)return{from:t.data.from,to:t.data.to,value:Number(t.data.value),chainId:Number(t.data.chainId),data:t.data.data}};function su({transactionHash:e,wallet:t,isTestnet:n,bridgingStatus:r,setBridgingStatus:a,onSuccess:i,onFailure:s}){o((()=>{if(e&&t&&r){if(["delayed","waiting","pending"].includes(r)){let t=setInterval((async()=>{try{let t=await async function({transactionHash:e,isTestnet:t}){let n=await fetch((t?au:ru)+"/requests/v2?hash="+e),r=await n.json();if(!n.ok){if("message"in r&&"string"==typeof r.message)throw Error(r.message);throw Error("Error fetching request from relay")}return r.requests.at(0)?.status??"pending"}({transactionHash:e,isTestnet:n});a(t)}catch(e){console.error(e)}}),1e3);return()=>clearInterval(t)}"success"===r?i({transactionHash:e,wallet:t}):["refund","failure"].includes(r)&&s({error:new lu(e,n)})}}),[r,e,n,t])}class lu extends T{constructor(e,t){super("We were unable to complete the bridging transaction. Funds will be refunded on your wallet.",void 0,A.TRANSACTION_FAILURE),this.relayLink=t?`https://testnets.relay.link/transaction/${e}`:`https://relay.link/transaction/${e}`}}const cu=({error:r,backFn:a,onClick:i})=>{let{reset:o}=it(),{app:s}=lr(),l=((r,a)=>{let i=/*#__PURE__*/t(Qa,{height:38,width:38,stroke:"var(--privy-color-error)"});if(r instanceof lu)return{title:"Transaction failed",detail:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("p",{children:r.message}),/*#__PURE__*/e("p",{children:["Check the"," ",/*#__PURE__*/t(hu,{href:r.relayLink,target:"_blank",children:"refund status"}),"."]})]}),ctaText:"Try again",icon:i};if(r instanceof T)switch(r.privyErrorCode){case A.CLIENT_REQUEST_TIMEOUT:return{title:"Timed out",detail:r.message,ctaText:"Try again",icon:i};case A.INSUFFICIENT_BALANCE:return{title:"Insufficient balance",detail:r.message,ctaText:"Try again",icon:i};case A.TRANSACTION_FAILURE:return{title:"Transaction failure",detail:r.message,ctaText:"Try again",icon:i};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i}}else{if(r instanceof Hc&&"twilio_verification_failed"===r.type)return{title:"Something went wrong",detail:r.message,ctaText:"Try again",icon:/*#__PURE__*/t(oi,{height:38,width:38,stroke:"var(--privy-color-error)"})};if(!(r instanceof M))return r instanceof N&&r.status&&[400,422].includes(r.status)?{title:"Something went wrong",detail:r.message,ctaText:"Try again",icon:i}:{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i};switch(r.privyErrorCode){case A.INVALID_CAPTCHA:return{title:"Something went wrong",detail:"Please try again.",ctaText:"Try again",icon:i};case A.DISALLOWED_LOGIN_METHOD:return{title:"Not allowed",detail:r.message,ctaText:"Try another method",icon:i};case A.ALLOWLIST_REJECTED:return{title:a.errorTitle||"You don't have access to this app",detail:a.errorDetail||"Have you been invited?",ctaText:a.errorCtaText||"Try another account",icon:/*#__PURE__*/t(ql,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})};case A.CAPTCHA_FAILURE:return{title:"Something went wrong",detail:"You did not pass CAPTCHA. Please try again.",ctaText:"Try again",icon:/*#__PURE__*/t("span",{})};case A.CAPTCHA_TIMEOUT:return{title:"Something went wrong",detail:"Something went wrong! Please try again later.",ctaText:"Try again",icon:/*#__PURE__*/t("span",{})};case A.LINKED_TO_ANOTHER_USER:return{title:"Authentication failed",detail:"This account has already been linked to another user.",ctaText:"Try again",icon:i};case A.NOT_SUPPORTED:return{title:"This region is not supported",detail:"SMS authentication from this region is not available",ctaText:"Try another method",icon:i};case A.TOO_MANY_REQUESTS:return{title:"Request failed",detail:"Too many attempts.",ctaText:"Try again later",icon:i};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i}}}})(r,s.allowlistConfig);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:a}),/*#__PURE__*/e(du,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(hl,{color:"var(--privy-color-error)"}),l.icon]})}),/*#__PURE__*/e(uu,{children:[/*#__PURE__*/t("h3",{children:l.title}),"string"==typeof l.detail?/*#__PURE__*/t("p",{children:l.detail}):l.detail]}),/*#__PURE__*/t(st,{color:"var(--privy-color-error)",onClick:()=>{r instanceof M&&(r.privyErrorCode===A.INVALID_CAPTCHA&&o(),r.privyErrorCode===A.ALLOWLIST_REJECTED&&s.allowlistConfig.errorCtaLink)?window.location.href=s.allowlistConfig.errorCtaLink:i?.()},children:l.ctaText})]})]})};let du=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-f1b9e2cb-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),uu=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-f1b9e2cb-1"})(["display:flex;flex-direction:column;gap:8px;"]),hu=/*#__PURE__*/Ka.a.withConfig({displayName:"Link",componentId:"sc-f1b9e2cb-2"})(["color:var(--privy-color-accent) !important;font-weight:600;"]);const pu=({style:e,color:n,...r})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:n||"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...r,children:/*#__PURE__*/t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}),mu=n=>{let[r,a]=s(!1);/*#__PURE__*/return e(yu,{color:n.color,onClick:()=>{a(!0),navigator.clipboard.writeText(n.text),setTimeout((()=>a(!1)),1500)},$justCopied:r,children:[r?/*#__PURE__*/t(pu,{style:{height:"14px",width:"14px"},strokeWidth:"2"}):/*#__PURE__*/t(Ut,{style:{height:"14px",width:"14px"}}),r?"Copied":"Copy"," ",n.itemName?n.itemName:"to Clipboard"]})};let yu=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledCopytoClipboardButton",componentId:"sc-46f4187f-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.$justCopied?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.$justCopied?"medium":"normal"),(e=>e.$justCopied?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"));const gu=e=>{let[n,r]=s(!1);/*#__PURE__*/return t(fu,{color:e.color,href:e.url,target:"_blank",rel:"noreferrer noopener",onClick:()=>{r(!0),setTimeout((()=>r(!1)),1500)},justOpened:n,children:e.text})};let fu=/*#__PURE__*/Ka.a.withConfig({displayName:"StyledOpenLinkButton",componentId:"sc-4e695c83-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.justOpened?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.justOpened?"medium":"normal"),(e=>e.justOpened?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"));const wu=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"1000",height:"1000",viewBox:"0 0 1000 1000",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"1000",height:"1000",rx:"200",fill:"#855DCD"}),/*#__PURE__*/t("path",{d:"M257.778 155.556H742.222V844.444H671.111V528.889H670.414C662.554 441.677 589.258 373.333 500 373.333C410.742 373.333 337.446 441.677 329.586 528.889H328.889V844.444H257.778V155.556Z",fill:"white"}),/*#__PURE__*/t("path",{d:"M128.889 253.333L157.778 351.111H182.222V746.667C169.949 746.667 160 756.616 160 768.889V795.556H155.556C143.283 795.556 133.333 805.505 133.333 817.778V844.444H382.222V817.778C382.222 805.505 372.273 795.556 360 795.556H355.556V768.889C355.556 756.616 345.606 746.667 333.333 746.667H306.667V253.333H128.889Z",fill:"white"}),/*#__PURE__*/t("path",{d:"M675.556 746.667C663.283 746.667 653.333 756.616 653.333 768.889V795.556H648.889C636.616 795.556 626.667 805.505 626.667 817.778V844.444H875.556V817.778C875.556 805.505 865.606 795.556 853.333 795.556H848.889V768.889C848.889 756.616 838.94 746.667 826.667 746.667V351.111H851.111L880 253.333H702.222V746.667H675.556Z",fill:"white"})]});let vu="#8a63d2";let Cu=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-d15a94a3-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),Eu=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-d15a94a3-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),Tu="#8a63d2";let bu=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-6e2c96cd-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),Au=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e2c96cd-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);function _u({title:e}){let{currentScreen:n,navigateBack:r,navigate:a,data:i,setModalData:o}=lr();/*#__PURE__*/return t(ot,{title:e,backFn:n===cr.FUNDING_MANUAL_TRANSFER_SCREEN?r:n===i?.funding?.methodScreen?i.funding.comingFromSendTransactionScreen?()=>a(cr.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN):void 0:i?.funding?.methodScreen?()=>{let e=i.funding;e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),o({funding:e}),a(e.methodScreen)}:void 0})}const ku=({size:n})=>/*#__PURE__*/t(Iu,{$size:n,children:/*#__PURE__*/e(Nu,{children:[/*#__PURE__*/t(xu,{}),/*#__PURE__*/t(Su,{})]})});let Iu=/*#__PURE__*/Ka.div.withConfig({displayName:"LoadingContainer",componentId:"sc-3ddaba1c-0"})(["--spinner-size:",";display:flex;justify-content:center;align-items:center;flex-grow:1;@media all and (display-mode:standalone){margin-bottom:30px;}"],(e=>e.$size?e.$size:"96px")),Nu=/*#__PURE__*/Ka.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-3ddaba1c-1"})(["position:relative;height:var(--spinner-size);width:var(--spinner-size);opacity:1;animation:fadein 200ms ease;"]),xu=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleFixed",componentId:"sc-3ddaba1c-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);&&{border:4px solid #f1f2f9;border-radius:50%;}"]),Su=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleRotate",componentId:"sc-3ddaba1c-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:#cbcde1 transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]);const Ru=({enabled:e=!0}={})=>{let{showFiatPrices:t,getUsdPriceForSol:n}=x(),[r,a]=s(!0),[i,l]=s(void 0),[c,d]=s(void 0);return o((()=>{(async()=>{if(t&&e)try{a(!0);let e=await n();e?d(e):l(Error("Unable to fetch SOL price"))}catch(e){l(e)}finally{a(!1)}else a(!1)})()}),[]),{solPrice:c,isSolPriceLoading:r,solPriceError:i}};function Ou(e){let{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:r}=(e=>{let{showFiatPrices:t,getUsdTokenPrice:n,chains:r}=x(),[a,i]=s(!0),[l,c]=s(void 0),[d,u]=s(void 0);return o((()=>{e||=Cr;let a=vr(r).find((t=>t.id===Number(e)));(async()=>{if(t){if(!a)return i(!1),void c(Error(`Unable to fetch token price on chain id ${e}`));try{i(!0);let e=await n(a);e?u(e):c(Error(`Unable to fetch token price on chain id ${a.id}`))}catch(e){c(e)}finally{i(!1)}}else i(!1)})()}),[e]),{tokenPrice:d,isTokenPriceLoading:a,tokenPriceError:l}})("solana"===e?-1:e),{solPrice:a,isSolPriceLoading:i,solPriceError:l}=Ru({enabled:"solana"===e});return"solana"===e?{tokenPrice:a,isTokenPriceLoading:i,tokenPriceError:l}:{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:r}}async function Wu(e){try{return await e}catch{}}let Mu=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2});function Pu(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 Lu(e,t){let n=parseFloat(e.toString())/1e9,r=Mu.format(t*n);return"$0.00"===r?"<$0.01":r}function Du({amount:e,fee:t,tokenPrice:n}){let r=BigInt(1e9*parseFloat(e)),a=r+t;return{fundingAmountInBaseUnit:r,fundingAmountInUsd:n?Lu(r,n):void 0,totalPriceInUsd:n?Lu(a,n):void 0,totalPriceInNativeCurrency:Pu(a),feePriceInNativeCurrency:Pu(t),feePriceInUsd:n?Lu(t,n):void 0}}function Uu(e){return"version"in e}function Fu(e,t,n){return{signature:e,parsedTransaction:n??null,signedTransaction:t,fees:BigInt(n?.meta?.fee||0)}}async function Bu({tx:e,connection:t,client:n}){let r=Uu(e)?e.message:e.compileMessage(),a=r.staticAccountKeys[0]?.toBase58()??"",i=await async function(e,t){return BigInt((Uu(e)?(await t.getFeeForMessage(e.message)).value:await e.getEstimatedFee(t))??0)}(e,t),o={},s={},l=[];for(let e of r.compiledInstructions){let a=r.staticAccountKeys[e.programIdIndex]?.toBase58()||"";if("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"!==a&&"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"!==a)if("11111111111111111111111111111111"!==a)if("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"!==a)l.push({type:"unknown",program:a});else{let t=await Wu(function(e,t){let[n,r,a,i]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!(n&&r&&a&&i))throw Error("Failed to parse ATA creation instruction");return{type:"ata-creation",payer:n.toBase58(),ata:r.toBase58(),owner:a.toBase58(),mint:i.toBase58()}}(e,r));if(!t)continue;l.push(t),s[t.ata]={owner:t.owner,mint:t.mint}}else{let t=await Wu(Vu(e,r));if(!t)continue;l.push(t)}else{let a=await Wu(Hu(e,r,t,n,o,s));if(!a)continue;l.push(a),o[a.token.address]=a.token,s[a.fromAta]??={owner:a.fromAccount,mint:a.token.address},a.toAccount&&(s[a.toAta]??={owner:a.toAccount,mint:a.token.address})}}let c=l.filter((({type:e})=>["spl-transfer","sol-transfer"].includes(e)));return{spender:a,fee:i,instructions:c.length?c:l}}function zu(e,t){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=Buffer.from(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 Hu(e,t,n,r,a,i){let o,s,[l,c,d]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!l||!c||!d)throw Error("Failed to parse SPL transfer instruction");let u="",h=i[c.toBase58()];if(h)o=h.owner,u=h.mint;else{let e=await n.getParsedAccountInfo(c,"confirmed"),t=e.value?.data;o=t?.parsed?.info?.owner,u=t?.parsed?.info?.mint??"",s=t?.parsed?.info?.tokenAmount?.decimals}if(!u){let e=await n.getParsedAccountInfo(l,"confirmed"),t=e.value?.data;u=t?.parsed?.info?.mint??""}let p=a[u];if(u&&!p){let e=await r.getSplTokenMetadata({mintAddress:u,cluster:Er(n.rpcEndpoint)});e&&(p={address:u,symbol:e.symbol,decimals:e.decimals})}let m=p?.symbol??"";s??=p?.decimals??9;let y=zu(e.data,1);return{type:"spl-transfer",fromAta:l.toBase58(),fromAccount:d.toBase58(),toAta:c.toBase58(),toAccount:o,value:y,token:{symbol:m,decimals:s,address:u}}}async function Vu(e,t){let[n,r]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!n||!r)throw Error("Failed to parse SOL transfer instruction");let a=zu(e.data,4);return{type:"sol-transfer",fromAccount:n.toBase58(),toAccount:r.toBase58(),value:a,token:{symbol:"SOL",decimals:9}}}const $u=({chains:e,appId:t,address:n,rpcConfig:r})=>Promise.all(e.map((async e=>{let a=ka({chain:e,transport:Ia(Va(e,r,t))});return{balance:await a.getBalance({address:n}).catch((()=>0n)),chain:e}}))),ju=/*#__PURE__*/Ka.span.withConfig({displayName:"LabelSm",componentId:"sc-6c002d6-0"})(["color:var(--privy-color-foreground-3);font-size:0.875rem;font-weight:400;line-height:1.375rem;"]),Gu=/*#__PURE__*/Ka(ju).withConfig({displayName:"LabelSmPrimary",componentId:"sc-6c002d6-1"})(["color:var(--privy-color-accent);"]),qu=/*#__PURE__*/Ka.span.withConfig({displayName:"Value",componentId:"sc-72aa026-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;",""],Vt),Ku=({balance:e,className:n,chain:r})=>/*#__PURE__*/t($t,{className:n,$state:void 0,children:/*#__PURE__*/t(Yu,{balance:e,chain:r})}),Yu=({balance:r,chain:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(Zu,{children:[/*#__PURE__*/t(Qu,{chainId:"id"in a?a.id:"solana"}),/*#__PURE__*/t(qu,{children:a.name})]}),/*#__PURE__*/e(vt,{isLoading:!1,isPulsing:!1,color:"gray",children:[/*#__PURE__*/t(Ju,{children:/*#__PURE__*/t(Xa,{})}),r]})]});let Zu=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-6d3c340d-0"})(["display:flex;align-items:center;"]),Ju=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-6d3c340d-1"})(["height:0.75rem;width:0.75rem;margin-right:0.2rem;"]),Qu=/*#__PURE__*/Ka(jt).withConfig({displayName:"StyledNetworkIcon",componentId:"sc-6d3c340d-2"})(["height:1.25rem;width:1.25rem;display:inline-block;margin-right:0.5rem;border-radius:4px;"]);const Xu=({options:n,onSelect:r,selected:a,className:i})=>/*#__PURE__*/e(Hi,{as:eh,children:[/*#__PURE__*/e(Vi,{as:ah,children:[/*#__PURE__*/t(Yu,{balance:a.balance,chain:a.chain}),/*#__PURE__*/t(rh,{height:16})]}),/*#__PURE__*/t($i,{as:th,className:i,children:n.map(((e,n)=>/*#__PURE__*/t(ji,{as:nh,onClick:()=>r(n),children:/*#__PURE__*/t(Yu,{balance:e.balance,chain:e.chain})},n)))})]});let eh=/*#__PURE__*/Ka.div.withConfig({displayName:"Wrapper",componentId:"sc-7924b61-0"})(["width:100%;position:relative;"]),th=/*#__PURE__*/Ka.div.withConfig({displayName:"Popover",componentId:"sc-7924b61-1"})(["width:100%;margin-top:0.5rem;position:absolute;background-color:var(--privy-color-background);border-radius:var(--privy-border-radius-md);overflow-x:hidden;overflow-y:auto;box-shadow:0px 1px 2px 0px rgba(16,24,40,0.05);max-height:11.75rem;&&{border:solid 1px var(--privy-color-foreground-4);}z-index:1;"]),nh=/*#__PURE__*/Ka.button.withConfig({displayName:"Button",componentId:"sc-7924b61-2"})(["width:100%;display:flex;justify-content:space-between;&&{padding:1rem;}:not(:last-child){border-bottom:solid 1px var(--privy-color-foreground-4);}:hover{background:var(--privy-color-background-2);}"]),rh=/*#__PURE__*/Ka(Zi).withConfig({displayName:"StyledChevronIcon",componentId:"sc-7924b61-3"})(["height:1rem;margin-left:0.5rem;"]),ah=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledMenuButton",componentId:"sc-7924b61-4"})([""," span{margin-left:auto;}","{transition:rotate 100ms ease-in;}&[aria-expanded='true']{","{rotate:-180deg;}}"],Gt,rh,rh);const ih=({style:e,...n})=>/*#__PURE__*/t("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...e},fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.71369 17.5625V10.375C3.71369 6.44625 6.85845 3.25 10.7238 3.25H17.7953C18.6783 3.25 19.3941 2.52244 19.3941 1.625C19.3941 0.727562 18.6783 0 17.7953 0H10.7238C5.09529 0 0.516113 4.65419 0.516113 10.375V17.5625C0.516113 18.4599 1.23194 19.1875 2.1149 19.1875C2.99787 19.1875 3.71369 18.4599 3.71369 17.5625ZM17.7953 60.7501C18.6783 60.7501 19.3941 61.4777 19.3941 62.3751C19.3941 63.2726 18.6783 64.0001 17.7953 64.0001H10.7238C5.09529 64.0001 0.516113 59.3459 0.516113 53.6251V46.4376C0.516113 45.5402 1.23194 44.8126 2.1149 44.8126C2.99787 44.8126 3.71369 45.5402 3.71369 46.4376V53.6251C3.71369 57.5538 6.85845 60.7501 10.7238 60.7501H17.7953ZM63.4839 46.4376V53.6251C63.4839 59.3459 58.9048 64.0001 53.2763 64.0001H46.2047C45.3217 64.0001 44.6059 63.2726 44.6059 62.3751C44.6059 61.4777 45.3217 60.7501 46.2047 60.7501H53.2763C57.1416 60.7501 60.2864 57.5538 60.2864 53.6251V46.4376C60.2864 45.5402 61.0022 44.8126 61.8851 44.8126C62.7681 44.8126 63.4839 45.5402 63.4839 46.4376ZM63.4839 10.375V17.5625C63.4839 18.4599 62.7681 19.1875 61.8851 19.1875C61.0022 19.1875 60.2864 18.4599 60.2864 17.5625V10.375C60.2864 6.44625 57.1416 3.25 53.2763 3.25H46.2047C45.3217 3.25 44.6059 2.52244 44.6059 1.625C44.6059 0.727562 45.3217 0 46.2047 0H53.2763C58.9048 0 63.4839 4.65419 63.4839 10.375ZM43.0331 47.3022C43.7067 46.6698 43.7483 45.6022 43.1262 44.9176C42.5039 44.233 41.4536 44.1906 40.78 44.823C38.3832 47.0732 35.265 48.3125 31.9997 48.3125C28.7344 48.3125 25.6162 47.0732 23.2194 44.823C22.5457 44.1906 21.4955 44.233 20.8732 44.9176C20.251 45.6022 20.2927 46.6698 20.9663 47.3022C23.9784 50.1301 27.8968 51.6875 31.9997 51.6875C36.1026 51.6875 40.021 50.1301 43.0331 47.3022ZM35.3207 24.1249V36.1249C35.3207 38.5029 33.4173 40.4374 31.0777 40.4374H29.7249C28.8079 40.4374 28.0646 39.6819 28.0646 38.7499C28.0646 37.8179 28.8079 37.0624 29.7249 37.0624H31.0777C31.5863 37.0624 32.0001 36.6419 32.0001 36.1249V24.1249C32.0001 23.1929 32.7434 22.4374 33.6604 22.4374C34.5774 22.4374 35.3207 23.1929 35.3207 24.1249ZM46.7581 28.8437V24.0312C46.7581 23.151 46.056 22.4374 45.19 22.4374C44.324 22.4374 43.622 23.151 43.622 24.0312V28.8437C43.622 29.7239 44.324 30.4374 45.19 30.4374C46.056 30.4374 46.7581 29.7239 46.7581 28.8437ZM17.6109 28.8437C17.6109 29.7239 18.313 30.4374 19.1789 30.4374C20.0449 30.4374 20.747 29.7239 20.747 28.8437V24.0312C20.747 23.151 20.0449 22.4374 19.1789 22.4374C18.313 22.4374 17.6109 23.151 17.6109 24.0312V28.8437Z"})}),oh=({style:n,...r})=>/*#__PURE__*/e("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...n},xmlns:"http://www.w3.org/2000/svg",...r,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_113_33841)",children:[/*#__PURE__*/t("path",{d:"M39.1193 0.943398C34.636 -0.174912 29.9185 -0.334713 25.328 0.656273C24.9732 0.732859 24.7477 1.08253 24.8243 1.43729C24.9009 1.79205 25.2506 2.01756 25.6053 1.94097C30.0015 0.991934 34.53 1.14842 38.8375 2.22802C49.1385 4.80983 57.7129 12.5548 60.9786 22.6718C62.2416 26.5843 62.7781 30.7505 62.8855 35.1167C62.8945 35.4795 63.1958 35.7664 63.5586 35.7575C63.9215 35.7485 64.2083 35.4472 64.1994 35.0843C64.0905 30.6582 63.5477 26.3849 62.2536 22.3432C58.8621 11.7515 49.9005 3.63265 39.1193 0.943398Z"}),/*#__PURE__*/t("path",{d:"M21.9931 2.93163C22.343 2.83511 22.5484 2.47325 22.4518 2.12339C22.3553 1.77352 21.9935 1.56815 21.6436 1.66466C16.8429 2.98903 10.0898 7.56519 5.91628 13.6786C5.91465 13.681 5.91304 13.6834 5.91145 13.6858C2.24684 19.2083 -0.0503572 26.1484 0.591012 32.8828C0.591623 32.8892 0.592328 32.8956 0.593127 32.902C0.746837 34.1317 1.00488 35.3591 1.26323 36.5879C1.80735 39.1761 2.35282 41.7706 1.92765 44.4064C1.86986 44.7647 2.11347 45.102 2.47177 45.1598C2.83007 45.2176 3.16738 44.974 3.22518 44.6157C3.66961 41.8605 3.11776 39.173 2.56581 36.4851C2.31054 35.2419 2.05525 33.9987 1.89847 32.7486C1.29525 26.3851 3.46802 19.7466 7.00418 14.416C11.0189 8.5373 17.5201 4.16562 21.9931 2.93163Z"}),/*#__PURE__*/t("path",{d:"M30.6166 4.39985C38.8671 3.89603 47.1159 7.26314 52.6556 13.7139C52.8921 13.9893 52.8605 14.4042 52.5852 14.6406C52.3099 14.8771 51.895 14.8455 51.6585 14.5702C46.3904 8.43576 38.541 5.23144 30.6927 5.71195C30.6899 5.71212 30.6871 5.71227 30.6843 5.71241C20.7592 6.19265 11.4643 12.9257 8.04547 22.3603C7.92183 22.7016 7.54498 22.8779 7.20375 22.7543C6.86253 22.6306 6.68616 22.2538 6.80981 21.9126C10.4114 11.9735 20.1717 4.90702 30.6166 4.39985Z"}),/*#__PURE__*/t("path",{d:"M54.6576 16.5848C54.4553 16.2836 54.047 16.2033 53.7457 16.4057C53.4444 16.608 53.3642 17.0163 53.5665 17.3176C56.6376 21.8904 57.9074 26.8665 58.4094 32.7717C58.4401 33.1333 58.7582 33.4016 59.1199 33.3708C59.4815 33.3401 59.7497 33.022 59.719 32.6604C59.206 26.6261 57.8965 21.4076 54.6576 16.5848Z"}),/*#__PURE__*/t("path",{d:"M59.2796 35.4504C59.6419 35.4277 59.9539 35.703 59.9765 36.0653C60.2242 40.0279 60.2265 44.5112 59.7881 47.8243C59.7405 48.1841 59.4102 48.4372 59.0504 48.3896C58.6906 48.342 58.4376 48.0117 58.4852 47.6519C58.9077 44.4586 58.91 40.0704 58.6648 36.1473C58.6421 35.785 58.9174 35.473 59.2796 35.4504Z"}),/*#__PURE__*/t("path",{d:"M7.05311 25.5432C7.13829 25.1904 6.92135 24.8354 6.56855 24.7502C6.21576 24.665 5.86071 24.882 5.77553 25.2348C5.2932 27.2325 5.0428 29.2847 5.03288 31.3388C5.02266 33.4559 5.41742 35.5225 5.81234 37.5899C6.1354 39.2811 6.45855 40.9728 6.5602 42.6932C6.69373 44.9531 6.21839 47.2163 5.39698 49.3703C5.26766 49.7094 5.43774 50.0891 5.77685 50.2184C6.11596 50.3477 6.4957 50.1777 6.62502 49.8386C7.49325 47.5617 8.01954 45.1092 7.87221 42.6157C7.77126 40.9071 7.44813 39.2252 7.12512 37.5439C6.73099 35.4925 6.33704 33.442 6.34716 31.3451C6.35659 29.3933 6.59455 27.4425 7.05311 25.5432Z"}),/*#__PURE__*/t("path",{d:"M24.2964 10.94C24.4317 11.2768 24.2683 11.6595 23.9315 11.7947C17.1187 14.5307 12.0027 20.7047 10.959 27.9852C10.523 31.0269 10.9941 34.0398 11.465 37.052C11.7303 38.7483 11.9954 40.4443 12.0985 42.1451C12.3221 45.833 11.902 49.8839 9.50192 53.5696C9.30387 53.8737 8.89677 53.9597 8.59264 53.7617C8.28851 53.5636 8.20251 53.1565 8.40056 52.8524C10.5873 49.4944 11.0012 45.7644 10.7867 42.2246C10.6821 40.499 10.4185 38.7833 10.1552 37.0686C9.68265 33.9923 9.21067 30.9195 9.65804 27.7987C10.7724 20.025 16.221 13.4748 23.4417 10.5751C23.7785 10.4399 24.1612 10.6032 24.2964 10.94Z"}),/*#__PURE__*/t("path",{d:"M47.3662 14.6814C41.9915 9.64741 34.2017 7.89046 27.122 9.4433C26.7675 9.52105 26.5432 9.87147 26.6209 10.226C26.6987 10.5805 27.0491 10.8048 27.4036 10.7271C34.1075 9.25665 41.4426 10.934 46.4677 15.6406C50.7033 19.6077 53.1628 25.38 53.8066 31.6779C53.8435 32.0389 54.1661 32.3017 54.5272 32.2648C54.8883 32.2279 55.151 31.9053 55.1141 31.5442C54.4456 25.0047 51.8822 18.9111 47.3662 14.6814Z"}),/*#__PURE__*/t("path",{d:"M54.9766 34.6738C55.3376 34.6368 55.6604 34.8994 55.6975 35.2604C56.3216 41.337 56.0526 47.9003 55.1104 54.2496C55.0571 54.6086 54.7229 54.8565 54.3639 54.8032C54.0049 54.7499 53.7571 54.4157 53.8103 54.0567C54.7394 47.7957 55.001 41.3439 54.39 35.3947C54.353 35.0336 54.6156 34.7109 54.9766 34.6738Z"}),/*#__PURE__*/t("path",{d:"M32.0659 13.3553C21.9959 13.3553 13.814 21.3892 13.814 31.3219C13.814 32.3829 13.9081 33.4225 14.0876 34.4334C14.1511 34.7907 14.4922 35.029 14.8495 34.9655C15.2069 34.9021 15.4451 34.561 15.3817 34.2036C15.2155 33.2677 15.1283 32.305 15.1283 31.3219C15.1283 22.1352 22.7014 14.6696 32.0659 14.6696C36.2978 14.6696 40.1642 16.1949 43.1319 18.7152C43.4086 18.9501 43.8233 18.9163 44.0582 18.6396C44.2931 18.363 44.2593 17.9483 43.9827 17.7134C40.7847 14.9975 36.6188 13.3553 32.0659 13.3553Z"}),/*#__PURE__*/t("path",{d:"M45.455 20.1635C45.717 19.9123 46.133 19.921 46.3842 20.183C49.2843 23.2072 50.2126 27.9605 50.8269 31.9494C51.5188 36.4426 51.6244 40.826 51.6244 42.8585C51.6244 43.2214 51.3302 43.5156 50.9673 43.5156C50.6044 43.5156 50.3101 43.2214 50.3101 42.8585C50.3101 40.8589 50.2055 36.5497 49.5279 32.1494C48.9577 28.4462 48.1356 23.9082 45.4356 21.0927C45.1844 20.8307 45.1931 20.4147 45.455 20.1635Z"}),/*#__PURE__*/t("path",{d:"M51.4576 46.6219C51.4864 46.2601 51.2165 45.9435 50.8547 45.9146C50.493 45.8858 50.1763 46.1557 50.1474 46.5175C49.8247 50.5654 49.403 54.6088 48.5474 58.3439C48.4663 58.6977 48.6874 59.0502 49.0412 59.1312C49.3949 59.2123 49.7474 58.9912 49.8285 58.6374C50.7067 54.8039 51.134 50.6806 51.4576 46.6219Z"}),/*#__PURE__*/t("path",{d:"M15.1454 36.852C15.5015 36.7819 15.847 37.0137 15.9171 37.3698C17.3066 44.4257 16.3467 50.8355 12.6672 56.4502C12.4682 56.7537 12.0609 56.8385 11.7573 56.6396C11.4538 56.4407 11.369 56.0333 11.5679 55.7298C15.0299 50.4469 15.9617 44.3985 14.6276 37.6238C14.5575 37.2677 14.7893 36.9221 15.1454 36.852Z"}),/*#__PURE__*/t("path",{d:"M32.0659 17.631C25.5291 17.631 19.1165 22.691 18.462 29.0504C18.1754 31.8345 18.578 34.5769 18.9807 37.3204C19.3323 39.7159 19.684 42.1124 19.5772 44.5381C19.3328 50.0898 17.7039 54.6726 14.905 58.4471C14.6888 58.7386 14.7499 59.1502 15.0414 59.3663C15.333 59.5825 15.7445 59.5214 15.9607 59.2299C18.9293 55.2266 20.6354 50.386 20.8903 44.5959C20.9966 42.1811 20.6438 39.7923 20.2912 37.4051C19.888 34.6752 19.4851 31.9473 19.7694 29.1849C20.3444 23.5983 26.0946 18.9453 32.0659 18.9453C34.851 18.9453 42.057 20.4534 44.3492 27.9205C45.7856 32.5998 46.1774 38.9326 45.8295 45.0849C45.4816 51.2364 44.3994 57.12 42.9442 60.8928C42.8136 61.2314 42.9822 61.6118 43.3208 61.7424C43.6594 61.873 44.0398 61.7044 44.1704 61.3658C45.6929 57.4186 46.7895 51.386 47.1417 45.1591C47.4938 38.9329 47.1068 32.4249 45.6056 27.5348C43.0612 19.2461 35.0851 17.631 32.0659 17.631Z"}),/*#__PURE__*/t("path",{d:"M21.9529 56.4512C22.2569 56.6494 22.3426 57.0566 22.1444 57.3606C21.7369 57.9854 21.3784 58.6391 21.0199 59.2928C20.6614 59.9465 20.3028 60.6004 19.8953 61.2253C19.697 61.5293 19.2898 61.615 18.9858 61.4167C18.6819 61.2184 18.5962 60.8113 18.7944 60.5073C19.2019 59.8825 19.5604 59.2288 19.9189 58.5751C20.2774 57.9213 20.636 57.2675 21.0435 56.6426C21.2418 56.3386 21.649 56.2529 21.9529 56.4512Z"}),/*#__PURE__*/t("path",{d:"M27.5799 24.4525C27.8816 24.2508 27.9625 23.8426 27.7608 23.541C27.559 23.2393 27.1509 23.1583 26.8492 23.3601C24.247 25.1006 22.6505 27.494 22.6505 31.0002C22.6505 33.088 23.0203 34.7946 23.3997 36.5449C23.9674 39.1641 24.3524 41.7777 24.2832 44.468C24.1992 47.7349 23.56 50.7201 22.3313 53.564C22.1873 53.8971 22.3407 54.2839 22.6739 54.4278C23.0071 54.5718 23.3938 54.4184 23.5378 54.0852C24.8369 51.0784 25.509 47.9266 25.5971 44.5018C25.6689 41.7062 25.2732 38.9892 24.6845 36.267C24.3042 34.509 23.9648 32.9394 23.9648 31.0002C23.9648 27.9961 25.2863 25.9866 27.5799 24.4525Z"}),/*#__PURE__*/t("path",{d:"M30.1447 22.1436C32.8717 21.5877 35.8061 22.2746 37.966 24.0228C41.8241 27.1455 42.3372 32.8403 42.753 37.4549L42.7742 37.69C43.3115 43.6385 42.6964 49.4163 41.4575 55.2186C41.3817 55.5736 41.0326 55.7999 40.6776 55.7241C40.3227 55.6483 40.0964 55.2991 40.1722 54.9442C41.3926 49.2288 41.9873 43.5885 41.4652 37.8082C41.4479 37.6169 41.4307 37.4228 41.4133 37.2264L41.4131 37.2235C41.0438 33.0534 40.5812 27.8304 37.1392 25.0444C35.2926 23.5498 32.7599 22.9518 30.4073 23.4314C30.0517 23.5039 29.7046 23.2744 29.6321 22.9188C29.5596 22.5632 29.7891 22.2161 30.1447 22.1436Z"}),/*#__PURE__*/t("path",{d:"M40.5287 58.4885C40.6183 58.1368 40.4057 57.7791 40.054 57.6896C39.7023 57.6 39.3446 57.8126 39.2551 58.1643C38.8578 59.7247 38.2456 61.1333 37.4695 62.4301C37.2831 62.7415 37.3844 63.145 37.6958 63.3314C38.0072 63.5178 38.4108 63.4165 38.5972 63.1051C39.4336 61.7075 40.0977 60.1816 40.5287 58.4885Z"}),/*#__PURE__*/t("path",{d:"M37.3152 48.9521C37.6756 48.9948 37.9332 49.3215 37.8906 49.682C37.2699 54.9267 35.8688 59.6042 33.6205 63.6613C33.4446 63.9787 33.0446 64.0934 32.7272 63.9175C32.4097 63.7416 32.295 63.3417 32.4709 63.0242C34.6226 59.1416 35.9811 54.6339 36.5854 49.5275C36.6281 49.1671 36.9548 48.9095 37.3152 48.9521Z"}),/*#__PURE__*/t("path",{d:"M37.1798 30.6556C36.7242 28.2212 34.6349 26.3591 32.0985 26.3591C28.6638 26.3591 26.254 29.8212 27.1032 33.0422C28.54 38.7279 28.7759 44.2077 27.8032 49.4855L27.8025 49.4893C26.9584 54.228 25.3374 58.4908 23.1263 62.1031C22.9368 62.4127 23.0342 62.8172 23.3437 63.0067C23.6533 63.1962 24.0578 63.0988 24.2473 62.7893C26.5488 59.0292 28.2249 54.6109 29.0961 49.7218C30.106 44.2403 29.8558 38.5684 28.3765 32.7168L28.3748 32.7099C27.7378 30.3005 29.5133 27.6734 32.0985 27.6734C33.9641 27.6734 35.5393 29.0459 35.8871 30.8929C36.8436 36.4411 37.3418 41.5862 36.9871 46.016C36.9581 46.3778 37.2279 46.6945 37.5897 46.7235C37.9515 46.7525 38.2682 46.4827 38.2972 46.1209C38.6649 41.5294 38.1459 36.2576 37.1815 30.6648C37.1809 30.6617 37.1804 30.6586 37.1798 30.6556Z"}),/*#__PURE__*/t("path",{d:"M30.1376 59.1171C30.4604 59.283 30.5876 59.6792 30.4217 60.002L28.6804 63.3906C28.5145 63.7134 28.1184 63.8406 27.7956 63.6747C27.4728 63.5088 27.3456 63.1127 27.5114 62.7899L29.2527 59.4013C29.4186 59.0785 29.8147 58.9513 30.1376 59.1171Z"}),/*#__PURE__*/t("path",{d:"M32.5872 31.2892C32.5042 30.9359 32.1505 30.7168 31.7972 30.7998C31.4439 30.8828 31.2247 31.2365 31.3077 31.5898C33.5238 41.0232 33.2194 49.3066 30.5201 56.363C30.3905 56.702 30.5602 57.0819 30.8991 57.2115C31.2381 57.3412 31.618 57.1715 31.7477 56.8326C34.5622 49.475 34.8483 40.9141 32.5872 31.2892Z"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_113_33841",children:/*#__PURE__*/t("rect",{width:"64",height:"64",fill:"white",transform:"translate(0.483887)"})})})]});let sh=({passkeys:n,expanded:r,onUnlink:a,onExpand:i})=>{let[o,l]=s([]),c=r?n.length:2,d=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";/*#__PURE__*/return e("div",{children:[/*#__PURE__*/t(fh,{children:"Your passkeys"}),/*#__PURE__*/e(ph,{children:[n.slice(0,c).map((n=>/*#__PURE__*/e(Ch,{children:[/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(wh,{children:d(n)}),/*#__PURE__*/e(vh,{children:["Last used: ",(n.latestVerifiedAt??n.verifiedAt).toLocaleString()]})]}),/*#__PURE__*/t(Th,{disabled:o.includes(n.credentialId),onClick:()=>(async e=>{l((t=>t.concat([e]))),await a(e),l((t=>t.filter((t=>t!==e))))})(n.credentialId),children:o.includes(n.credentialId)?/*#__PURE__*/t(qt,{}):/*#__PURE__*/t(ao,{height:"1.6em"})})]},n.credentialId))),n.length>2&&!r&&/*#__PURE__*/t(hh,{onClick:i,children:"View all"})]})]})},lh=()=>/*#__PURE__*/e(ph,{children:[/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(io,{})}),"Log in with Touch ID, Face ID, or a security key."]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(bi,{})}),"More secure than a password."]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ro,{})}),"Takes seconds to set up and use."]})]});const ch=/*#__PURE__*/Ka.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-302702bc-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent) !important;stroke:var(--privy-color-accent) !important;fill:var(--privy-color-accent) !important;}"]);let dh=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-302702bc-1"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-beginngin;width:100%;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),uh=/*#__PURE__*/Ya(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]);const hh=/*#__PURE__*/Ka.button.withConfig({displayName:"LinkButton",componentId:"sc-302702bc-2"})(["",""],uh);let ph=/*#__PURE__*/Ka.div.withConfig({displayName:"List",componentId:"sc-302702bc-3"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.8rem;padding:0.5rem 0rem 0rem;flex-grow:1;width:100%;"]),mh=/*#__PURE__*/Ka.div.withConfig({displayName:"ModalTitle",componentId:"sc-302702bc-4"})(["font-size:18px;line-height:18px;text-align:center;font-weight:600;"]),yh=/*#__PURE__*/Ka.div.withConfig({displayName:"ModalSubTitle",componentId:"sc-302702bc-5"})(["font-size:0.875rem;text-align:center;margin-top:10px;"]),gh=/*#__PURE__*/Ka.div.withConfig({displayName:"SectionSpacer",componentId:"sc-302702bc-6"})(["height:32px;"]),fh=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyListTitle",componentId:"sc-302702bc-7"})(["line-height:20px;height:20px;font-size:1em;font-weight:450;display:flex;justify-content:flex-beginning;width:100%;"]),wh=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-302702bc-8"})(["font-size:1em;line-height:1.3em;font-weight:500;color:var(--privy-color-foreground-2);padding:0.2em 0;"]),vh=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-302702bc-9"})(["font-size:0.875rem;line-height:1rem;color:#64668b;padding:0.2em 0;"]),Ch=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyListItem",componentId:"sc-302702bc-10"})(["display:flex;align-items:center;justify-content:space-between;padding:1em;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;border-radius:8px;border:1px solid #e2e3f0 !important;width:100%;height:5em;"]),Eh=/*#__PURE__*/Ya([":focus,:hover,:active{outline:none;}display:flex;width:2em;height:2em;justify-content:center;align-items:center;svg{color:var(--privy-color-error);}svg:hover{color:var(--privy-color-foreground-3);}"]),Th=/*#__PURE__*/Ka.button.withConfig({displayName:"PasskeyItemUnlinkButton",componentId:"sc-302702bc-11"})(["",""],Eh);const bh=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingMethodContainer",componentId:"sc-eaaa12a-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),Ah=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-eaaa12a-1"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;svg{border-radius:var(--privy-border-radius-sm);}"]),_h=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingQuantityWrapper",componentId:"sc-eaaa12a-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:8px;"]),kh=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingQuantity",componentId:"sc-eaaa12a-3"})(["display:flex;align-items:center;gap:4px;width:100%;padding:0 16px;border-width:1px !important;border-radius:12px;cursor:text;&:focus-within{border-color:var(--privy-color-accent);}"]),Ih=/*#__PURE__*/Ka.input.withConfig({displayName:"FundingAmountInput",componentId:"sc-eaaa12a-5"})(["background-color:var(--privy-color-background);width:100%;&:focus{outline:none !important;border:none !important;box-shadow:none !important;}&&{font-size:26px;}"]),Nh=/*#__PURE__*/Ka(Ih).withConfig({displayName:"FundingAmountInputLarge",componentId:"sc-eaaa12a-6"})(["&&{font-size:42px;}"]),xh=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingCurrency",componentId:"sc-eaaa12a-8"})(["font-size:18px;"]),Sh=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingDollars",componentId:"sc-eaaa12a-9"})(["font-size:12px;color:var(--privy-color-foreground-3);height:20px;"]),Rh=/*#__PURE__*/Ka.div.withConfig({displayName:"InfoButtonText",componentId:"sc-eaaa12a-13"})([""]),Oh=/*#__PURE__*/Ka.a.withConfig({displayName:"InfoButtonLink",componentId:"sc-eaaa12a-14"})(["&&{color:var(--privy-color-accent);}cursor:pointer;"]),Wh=({displayName:r,errorMessage:a,configuredFundingChain:i,formattedBalance:o,fundingAmount:s,fundingCurrency:c,fundingAmountInUsd:d,options:u,selectedOption:h,isPreparing:p,isSubmitting:m,addressToFund:y,fundingWalletAddress:g,onSubmit:f,onSelect:w,onAmountChange:v})=>{let C=l(null);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(St,{children:"Transfer from another network"}),/*#__PURE__*/e(Rt,{children:["You need more funds on the ",i.name," network. Bridge from another blockchain network."]}),/*#__PURE__*/e(_h,{style:{marginTop:"2rem"},children:[/*#__PURE__*/e(kh,{onClick:()=>C.current?.focus(),children:[/*#__PURE__*/t(Ih,{ref:C,value:s,onChange:e=>{let t=e.target.value;if(/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1){let e=/\.$/.test(t)?".":"",n=Number(t.replace(/\.$/,"")||"0");if(Number.isNaN(n))return void v("0");v(n.toString()+e)}}}),/*#__PURE__*/t(xh,{children:c})]}),d&&/*#__PURE__*/t(Sh,{children:d})]}),/*#__PURE__*/e(Kt,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/t(ju,{children:"From"}),/*#__PURE__*/t(ju,{children:Ai(g)})]}),/*#__PURE__*/t(Xu,{selected:{chain:h.chain,balance:Yt(h.balance,h.chain.nativeCurrency.symbol,3,!0)},options:u.map((({chain:e,balance:t})=>({chain:e,balance:Yt(t,e.nativeCurrency.symbol,3,!0)}))),onSelect:w}),/*#__PURE__*/e(Kt,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/t(ju,{children:"To"}),/*#__PURE__*/t(ju,{children:Ai(y)})]}),/*#__PURE__*/t(Ku,{chain:i,balance:o}),/*#__PURE__*/t(Zt,{style:{marginTop:"1rem"},children:a}),/*#__PURE__*/e(Jt,{style:{marginTop:"1rem"},loading:m||p,disabled:p||m,onClick:f,children:["Confirm with ",r]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},Mh=({wallet:r,displayName:a,addressToFund:i,chainId:o,chainName:s,isBridging:l,isErc20Flow:c,totalPriceInNativeCurrency:d,totalPriceInUsd:u,gasPriceInNativeCurrency:h,gasPriceInUsd:p})=>{let m=ft(r.walletClientType);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(ku,{}),/*#__PURE__*/t(Ft,{style:{marginTop:"16px"},children:/*#__PURE__*/t(wc,{icon:m?.image_url?.md,name:r.walletClientType})}),/*#__PURE__*/t(Ql,{style:{marginTop:"8px",marginBottom:"12px"},title:`${l?"Bridging":"Confirming"} with ${a}`}),!l&&!c&&/*#__PURE__*/e(Qt,{children:[/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Total"}),/*#__PURE__*/t(qu,{children:u||d})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"To"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:i,showCopyIcon:!1})})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Network"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/e(Ph,{children:[/*#__PURE__*/t(jt,{chainId:o,height:16,width:16})," ",s]})})]}),h&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Estimated fee"}),/*#__PURE__*/t(qu,{children:p||h})]})]}),/*#__PURE__*/t(It,{height:24}),/*#__PURE__*/t(ct,{})]})};let Ph=/*#__PURE__*/Ka.div.withConfig({displayName:"NetworkColumn",componentId:"sc-ec6320ce-0"})(["display:flex;flex-direction:row;align-items:center;gap:4px;"]);const Lh=[cr.FUNDING_METHOD_SELECTION_SCREEN,cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN,cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN,cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN,cr.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN,cr.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN,cr.FUNDING_MANUAL_TRANSFER_SCREEN,cr.MOONPAY_STATUS_SCREEN],Dh={[cr.FUNDING_METHOD_SELECTION_SCREEN]:null,[cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:"external",[cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:"external",[cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN]:"external",[cr.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN]:"external",[cr.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN]:"external",[cr.FUNDING_MANUAL_TRANSFER_SCREEN]:"manual",[cr.MOONPAY_STATUS_SCREEN]:"moonpay"},Uh=[{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}];let Fh=({status:r,onClickCta:a})=>{let{title:o,body:s,cta:l}=i((()=>(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(Hh,{children:[/*#__PURE__*/t(Bh,{isSucccess:"success"===r}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:o}),/*#__PURE__*/t(zh,{children:s})]})]}),l&&/*#__PURE__*/t(st,{onClick:a,children:l})]})},Bh=({isSucccess:n})=>{if(!n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t(Ht,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(on,{color:n}),/*#__PURE__*/t(as,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let r=(e=>e?si:()=>/*#__PURE__*/t(Ji,{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})})},zh=/*#__PURE__*/Ka.p.withConfig({displayName:"StatusBody",componentId:"sc-96ef1540-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),Hh=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-96ef1540-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const Vh=({children:n,theme:r})=>/*#__PURE__*/e($h,{$theme:r,children:[/*#__PURE__*/t(Qa,{width:"3rem",color:"var(--privy-color-error)"}),n]});let $h=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-5400b18f-0"})(["display:flex;gap:0.5rem;"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.75rem;font-weight:400;line-height:1.125rem;padding:0.5rem 0.75rem;&&{border:1px solid var(--privy-color-error);border-radius:var(--privy-border-radius-sm);}"],(e=>"dark"===e.$theme?"color: var(--privy-color-error);":"background-color: var(--privy-color-error-light);"));const jh=({children:n,theme:r})=>/*#__PURE__*/e(Gh,{$theme:r,children:[/*#__PURE__*/t(eo,{width:"1.25rem",color:"dark"===r?"var(--privy-color-accent-light)":"var(--privy-color-accent-dark)",style:{minWidth:"1.25rem"}}),n]});let Gh=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-dc8a0871-0"})(["display:flex;gap:0.5rem;background-color:",";color:var(--privy-color-foreground);align-items:flex-start;text-align:left;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);border:1px solid var(--privy-color-accent);}"],(e=>"dark"===e.$theme?"var(--privy-color-accent-darkest)":"var(--privy-color-accent-lightest)"));const qh=e=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 210.2",xmlSpace:"preserve",...e,children:/*#__PURE__*/t("path",{d:"M93.6,27.1C87.6,34.2,78,39.8,68.4,39c-1.2-9.6,3.5-19.8,9-26.1c6-7.3,16.5-12.5,25-12.9 C103.4,10,99.5,19.8,93.6,27.1 M102.3,40.9c-13.9-0.8-25.8,7.9-32.4,7.9c-6.7,0-16.8-7.5-27.8-7.3c-14.3,0.2-27.6,8.3-34.9,21.2 c-15,25.8-3.9,64,10.6,85c7.1,10.4,15.6,21.8,26.8,21.4c10.6-0.4,14.8-6.9,27.6-6.9c12.9,0,16.6,6.9,27.8,6.7 c11.6-0.2,18.9-10.4,26-20.8c8.1-11.8,11.4-23.3,11.6-23.9c-0.2-0.2-22.4-8.7-22.6-34.3c-0.2-21.4,17.5-31.6,18.3-32.2 C123.3,42.9,107.7,41.3,102.3,40.9 M182.6,11.9v155.9h24.2v-53.3h33.5c30.6,0,52.1-21,52.1-51.4c0-30.4-21.1-51.2-51.3-51.2H182.6z M206.8,32.3h27.9c21,0,33,11.2,33,30.9c0,19.7-12,31-33.1,31h-27.8V32.3z M336.6,169c15.2,0,29.3-7.7,35.7-19.9h0.5v18.7h22.4V90.2 c0-22.5-18-37-45.7-37c-25.7,0-44.7,14.7-45.4,34.9h21.8c1.8-9.6,10.7-15.9,22.9-15.9c14.8,0,23.1,6.9,23.1,19.6v8.6l-30.2,1.8 c-28.1,1.7-43.3,13.2-43.3,33.2C298.4,155.6,314.1,169,336.6,169z M343.1,150.5c-12.9,0-21.1-6.2-21.1-15.7c0-9.8,7.9-15.5,23-16.4 l26.9-1.7v8.8C371.9,140.1,359.5,150.5,343.1,150.5z M425.1,210.2c23.6,0,34.7-9,44.4-36.3L512,54.7h-24.6l-28.5,92.1h-0.5 l-28.5-92.1h-25.3l41,113.5l-2.2,6.9c-3.7,11.7-9.7,16.2-20.4,16.2c-1.9,0-5.6-0.2-7.1-0.4v18.7C417.3,210,423.3,210.2,425.1,210.2z"})}),Kh=n=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 38.1",xmlSpace:"preserve",...n,children:[/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M37.8,19.7V29h-3V6h7.8c1.9,0,3.7,0.7,5.1,2c1.4,1.2,2.1,3,2.1,4.9c0,1.9-0.7,3.6-2.1,4.9c-1.4,1.3-3.1,2-5.1,2 L37.8,19.7L37.8,19.7z M37.8,8.8v8h5c1.1,0,2.2-0.4,2.9-1.2c1.6-1.5,1.6-4,0.1-5.5c0,0-0.1-0.1-0.1-0.1c-0.8-0.8-1.8-1.3-2.9-1.2 L37.8,8.8L37.8,8.8z"}),/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M56.7,12.8c2.2,0,3.9,0.6,5.2,1.8s1.9,2.8,1.9,4.8V29H61v-2.2h-0.1c-1.2,1.8-2.9,2.7-4.9,2.7 c-1.7,0-3.2-0.5-4.4-1.5c-1.1-1-1.8-2.4-1.8-3.9c0-1.6,0.6-2.9,1.8-3.9c1.2-1,2.9-1.4,4.9-1.4c1.8,0,3.2,0.3,4.3,1v-0.7 c0-1-0.4-2-1.2-2.6c-0.8-0.7-1.8-1.1-2.9-1.1c-1.7,0-3,0.7-3.9,2.1l-2.6-1.6C51.8,13.8,53.9,12.8,56.7,12.8z M52.9,24.2 c0,0.8,0.4,1.5,1,1.9c0.7,0.5,1.5,0.8,2.3,0.8c1.2,0,2.4-0.5,3.3-1.4c1-0.9,1.5-2,1.5-3.2c-0.9-0.7-2.2-1.1-3.9-1.1 c-1.2,0-2.2,0.3-3,0.9C53.3,22.6,52.9,23.3,52.9,24.2z"}),/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M80,13.3l-9.9,22.7h-3l3.7-7.9l-6.5-14.7h3.2l4.7,11.3h0.1l4.6-11.3H80z"}),/*#__PURE__*/t("path",{style:{fill:"#4285F4"},d:"M25.9,17.7c0-0.9-0.1-1.8-0.2-2.7H13.2v5.1h7.1c-0.3,1.6-1.2,3.1-2.6,4v3.3H22C24.5,25.1,25.9,21.7,25.9,17.7z"}),/*#__PURE__*/t("path",{style:{fill:"#34A853"},d:"M13.2,30.6c3.6,0,6.6-1.2,8.8-3.2l-4.3-3.3c-1.2,0.8-2.7,1.3-4.5,1.3c-3.4,0-6.4-2.3-7.4-5.5H1.4v3.4 C3.7,27.8,8.2,30.6,13.2,30.6z"}),/*#__PURE__*/t("path",{style:{fill:"#FBBC04"},d:"M5.8,19.9c-0.6-1.6-0.6-3.4,0-5.1v-3.4H1.4c-1.9,3.7-1.9,8.1,0,11.9L5.8,19.9z"}),/*#__PURE__*/t("path",{style:{fill:"#EA4335"},d:"M13.2,9.4c1.9,0,3.7,0.7,5.1,2l0,0l3.8-3.8c-2.4-2.2-5.6-3.5-8.8-3.4c-5,0-9.6,2.8-11.8,7.3l4.4,3.4 C6.8,11.7,9.8,9.4,13.2,9.4z"})]}),Yh=e=>{let[t,n]=s();return o((()=>{e().then((e=>{n(e)})).catch((()=>{}))}),[]),t},Zh=()=>window.open(void 0,void 0,Jh({w:440,h:680}));let Jh=({w:e,h:t})=>{let n=void 0!==window.screenLeft?window.screenLeft:window.screenX,r=void 0!==window.screenTop?window.screenTop:window.screenY,a=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,i=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;return`toolbar=0,location=0,menubar=0,height=${t},width=${e},popup=1,left=${(a-e)/2/(a/window.screen.availWidth)+n},top=${(i-t)/2/(i/window.screen.availHeight)+r}`};let Qh={[Nr.id]:"ethereum",[xr.id]:"base",[Sr.id]:"optimism",[Rr.id]:"polygon",[Or.id]:"arbitrum"};const Xh=(e,t,n,r,a,i)=>new Promise((async(o,s)=>{let l=Zh();if(!l)return void s(Error("Unable to initialize flow"));let c="ethereum"===t.chainType?function(e){let t=Qh[e];if(!t)throw new T(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}(t.chain.id):"solana",d=t.isUSDC?"USDC":"ethereum"===t.chainType?"ETH":"SOL",u=await e.initCoinbaseOnRamp({addresses:[{address:t.address,blockchains:[c]}],assets:[d]}),{url:h}=_i({input:u,amount:t.amount,blockchain:c,asset:d,experience:i});l.location=h.toString();let p={...a?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(p.usingDefaultFundingMethod=!1),n({funding:p,coinbaseOnrampStatus:{popup:l}}),r(cr.COINBASE_ONRAMP_STATUS_SCREEN),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:p,coinbaseOnrampStatus:{partnerUserId:u.partner_user_id,popup:l}})}),5e3),o()})),ep=async(e,t,n,r,a,i,o,s)=>{let l=Zh();if(!l)throw Error("Unable to initialize flow");let c="ethereum"===t.chainType?t.moonpayConfigOverride?.currencyCode??ki(t.chain.id,r):"SOL",{signedUrl:d,externalTransactionId:u}=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??sa(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 h={...o?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(h.usingDefaultFundingMethod=!1),a({moonpayStatus:{},funding:h}),i(cr.MOONPAY_STATUS_SCREEN),setTimeout((()=>{a({moonpayStatus:{externalTransactionId:u},funding:h})}),8e3)};let tp=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 np=()=>tp("https://apple.com/apple-pay"),rp=()=>tp("https://google.com/pay");let ap=({...e})=>/*#__PURE__*/t(cs,{color:"black",...e}),ip={devnet:"Devnet","mainnet-beta":"Solana",testnet:"Testnet"};const op=({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"})]})});let sp=({status:r,onClickCta:a})=>{let{title:o,body:s,cta:l}=i((()=>(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(dp,{children:[/*#__PURE__*/t(lp,{status:r}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:o}),/*#__PURE__*/t(cp,{children:s})]})]}),l&&/*#__PURE__*/t(st,{onClick:a,children:l})]})},lp=({status:n})=>{if(!n||"pending"===n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t(Ht,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(on,{color:n}),/*#__PURE__*/t(op,{size:"3rem",style:{position:"absolute",top:"1rem",left:"1rem"}})]})}let r=(e=>{switch(e){case"completed":return si;case"waitingAuthorization":return()=>/*#__PURE__*/t(Ji,{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})})},cp=/*#__PURE__*/Ka.p.withConfig({displayName:"StatusBody",componentId:"sc-56bea42a-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),dp=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-56bea42a-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const up=({onClick:n,text:r})=>/*#__PURE__*/e(il,{onClick:n,children:[/*#__PURE__*/t(Xa,{}),/*#__PURE__*/t(Xs,{children:r}),/*#__PURE__*/t(to,{})]});let hp=({onClick:n,icon:r,name:a,chainType:i})=>/*#__PURE__*/e(il,{onClick:n,children:[/*#__PURE__*/t(Ah,{style:{width:20},children:/*#__PURE__*/t("img",{src:r})}),a,/*#__PURE__*/t(vt,{color:"gray",style:{marginLeft:"auto"},children:"Connected"}),"solana"===i&&/*#__PURE__*/t(vt,{color:"gray",children:"Solana"})]});let pp=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledCircle",componentId:"sc-30eca48b-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 mp=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"17",height:"17",viewBox:"0 0 17 17",style:{height:"1.25rem",width:"1.25rem",...e},...n,children:/*#__PURE__*/t("path",{strokeLinecap:"round",strokeLinejoin:"round",fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 8.67993C16.5 9.82986 15.853 10.8287 14.9032 11.3322C15.2188 12.3599 14.97 13.5237 14.1569 14.3368C13.3437 15.1499 12.18 15.3987 11.1523 15.0831C10.6488 16.0329 9.64993 16.6799 8.5 16.6799C7.35007 16.6799 6.35126 16.0329 5.84771 15.0831C4.82003 15.3987 3.65627 15.1499 2.84314 14.3368C2.03001 13.5237 1.78124 12.3599 2.09681 11.3322C1.14699 10.8287 0.5 9.82986 0.5 8.67993C0.5 7.53 1.14699 6.53119 2.0968 6.02764C1.78125 4.99996 2.03003 3.83621 2.84315 3.02309C3.65627 2.20997 4.82002 1.96119 5.8477 2.27675C6.35125 1.32692 7.35007 0.679932 8.5 0.679932C9.64992 0.679932 10.6487 1.32691 11.1523 2.27672C12.18 1.96115 13.3437 2.20993 14.1569 3.02305C14.97 3.83618 15.2188 4.99996 14.9032 6.02764C15.853 6.53119 16.5 7.53 16.5 8.67993ZM12.2659 6.68856C12.5654 6.40238 12.5761 5.92763 12.29 5.62818C12.0038 5.32873 11.529 5.31797 11.2296 5.60416C9.73022 7.03711 8.40877 8.65489 7.3018 10.4211L5.78033 8.89963C5.48744 8.60673 5.01256 8.60673 4.71967 8.89963C4.42678 9.19252 4.42678 9.66739 4.71967 9.96029L6.92031 12.1609C7.08544 12.3261 7.31807 12.4048 7.54957 12.374C7.78106 12.3432 7.98499 12.2064 8.1012 12.0038C9.23027 10.0356 10.6362 8.24613 12.2659 6.68856Z",fill:"var(--privy-color-accent)"})}),yp=/*#__PURE__*/Ka.div.withConfig({displayName:"TodoList",componentId:"sc-491785d-0"})(["display:flex;flex-direction:column;justify-content:flex-start;gap:4px;"]),gp=/*#__PURE__*/Ka.div.withConfig({displayName:"TodoSpacer",componentId:"sc-491785d-1"})(["&&&{margin-left:7px;border-left:2px solid var(--privy-color-foreground-4);height:12px;}"]),fp=({children:n})=>/*#__PURE__*/e(wp,{children:[/*#__PURE__*/t(mp,{style:{width:"16px",height:"16px"}}),n]});let wp=/*#__PURE__*/Ka.div.withConfig({displayName:"TodoItemWrapper",componentId:"sc-491785d-2"})(["display:flex;justify-content:flex-start;justify-items:center;text-align:left;gap:8px;&&{a{text-decoration:underline;color:var(--privy-color-accent);}svg{margin-top:auto;margin-bottom:auto;}}"]),vp=({name:n,installLink:r})=>/*#__PURE__*/e(Ft,{children:[/*#__PURE__*/t(Zl,{title:`Create a ${n} wallet`.replace(/wallet wallet/gi,"wallet"),description:"Follow the instructions below to get started."}),/*#__PURE__*/e(yp,{children:[/*#__PURE__*/t(fp,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t("span",{children:"Install the "})," ",/*#__PURE__*/e("a",{href:r,target:"_blank",children:[n," browser extension"]})]})}),/*#__PURE__*/t(gp,{}),/*#__PURE__*/t(fp,{children:"Set up your first wallet"}),/*#__PURE__*/t(gp,{}),/*#__PURE__*/t(fp,{children:"Store your recovery phrase in a safe place!"})]}),/*#__PURE__*/t(hn,{onClick:()=>window.location.reload(),style:{marginTop:"20px"},children:"Reload the page to use your wallet"})]});let Cp={apple_oauth:"apple",custom_auth:"custom",discord_oauth:"discord",email:"email",farcaster:"farcaster",github_oauth:"github",google_oauth:"google",instagram_oauth:"instagram",linkedin_oauth:"linkedin",passkey:"passkey",phone:"sms",spotify_oauth:"spotify",telegram:"telegram",tiktok_oauth:"tiktok",twitter_oauth:"twitter",wallet:"siwe",smart_wallet:"siwe",cross_app:"privy:"};const Ep=e=>{let t=Cp[e];return"wallet"===e||"phone"===e?{displayName:e,loginMethod:t}:{displayName:t,loginMethod:t}},Tp=()=>{let{app:e}=lr(),n=e?.appearance?.logo,r=`${e?.name} logo`,i={maxHeight:"90px",maxWidth:"180px"};return n?"string"==typeof n?/*#__PURE__*/t("img",{src:n,alt:r,style:i}):"svg"===n.type||"img"===n.type?/*#__PURE__*/a.cloneElement(n,{alt:r,style:i}):(console.warn("`config.appearance.logo` must be a string, or an SVG / IMG element. Nothing will be rendered."),null):null},bp=e=>{let{app:n}=lr();return n?.appearance.logo?/*#__PURE__*/t(Ap,{...e,children:/*#__PURE__*/t(Tp,{})}):null},Ap=/*#__PURE__*/Ka.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a206bd44-0"})(["display:flex;flex-direction:column;align-items:center;padding:24px 0;flex-grow:1;justify-content:center;"]),_p=({appId:r})=>{let[a,i]=s(void 0),{startCrossAppAuthFlow:l,authenticated:c}=ur(),{client:d}=x();return o((()=>{(async()=>{d&&i(await d.getCrossAppProviderDetails(r))})()}),[d]),/*#__PURE__*/t(il,{onClick:()=>l({appId:r,action:c?"link":"login"}),disabled:!a,children:a?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Rc,{name:a.name,logoUrl:a.icon_url||void 0,size:"24px"})," ",a.name]}):/*#__PURE__*/t(qt,{})})},kp=/*#__PURE__*/u(((r,a)=>{let[i,l]=s(r.defaultValue||""),[c,d]=s(""),[u,h]=s(!1),{authenticated:p}=ur(),{initLoginWithEmail:m}=x(),{navigate:y,setModalData:g,currentScreen:f,data:w}=lr(),{enabled:v,token:C}=it(),[E,T]=s(!1),{accountType:b}=gt(),_=dr();o((()=>{!i&&_.disablePlusEmails&&w?.inlineError?.error instanceof M&&w?.inlineError?.error.privyErrorCode===A.DISALLOWED_PLUS_EMAIL&&!c&&d("Please enter a valid email address without a '+'."),c&&d("")}),[i]);let k=pn(i),I=u||!k,N=()=>{g({inlineError:void 0}),!v||C||p?(e=>{h(!0),m({email:i,captchaToken:e,disableSignup:w?.login?.disableSignup,withPrivyUi:!0}).then((()=>{y(cr.AWAITING_PASSWORDLESS_CODE)})).catch((e=>{g({errorModalData:{error:e,previousScreen:f||cr.LANDING}}),y(cr.ERROR_SCREEN)})).finally((()=>{h(!1)}))})(C):(g({captchaModalData:{callback:e=>m({email:i,captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:cr.ERROR_SCREEN}}),y(cr.CAPTCHA_SCREEN))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(Ip,{children:[c&&/*#__PURE__*/t(Zt,{style:{display:"block",marginTop:"0.25rem",textAlign:"left"},children:c}),/*#__PURE__*/e(Np,{stacked:r.stacked,$error:!!c,children:[/*#__PURE__*/t(ii,{}),/*#__PURE__*/t("input",{ref:a,id:"email-input",className:"login-method-button",type:"email",placeholder:"your@email.com",onFocus:()=>T(!0),onChange:e=>l(e.target.value),onKeyUp:e=>{"Enter"===e.key&&N()},value:i,autoComplete:"email"}),"email"!==b||E?r.stacked?/*#__PURE__*/t("span",{}):/*#__PURE__*/t(mn,{isSubmitting:u,onClick:N,disabled:I,children:"Submit"}):/*#__PURE__*/t(vt,{color:"gray",children:"Recent"})]})]}),r.stacked?/*#__PURE__*/t(st,{loadingText:null,loading:u,disabled:I,onClick:N,children:"Submit"}):null]})}));let Ip=yn,Np=gn;const xp=({isEditable:r,setIsEditable:a,defaultValue:i})=>{let o=l(null);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(sl,{$if:!r,children:/*#__PURE__*/t(kp,{ref:o,defaultValue:i})}),/*#__PURE__*/t(sl,{$if:r,children:/*#__PURE__*/e(il,{onClick:()=>{a(),setTimeout((()=>{o.current?.focus()}),0)},children:[/*#__PURE__*/t(ii,{})," Continue with Email"]})})]})},Sp=()=>{let[n,r]=s(!1),{currentScreen:a,navigate:i,setModalData:o,data:l}=lr(),{enabled:c,token:d}=it(),{initLoginWithFarcaster:u}=x(),{accountType:h}=gt();/*#__PURE__*/return e(il,{onClick:async()=>{r(!0);try{c&&!d?(o({captchaModalData:{callback:e=>u(e,l?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:cr.AWAITING_FARCASTER_CONNECTION,onErrorNavigateTo:cr.ERROR_SCREEN}}),i(cr.CAPTCHA_SCREEN)):(await u(d,l?.login?.disableSignup),i(cr.AWAITING_FARCASTER_CONNECTION))}catch(e){o({errorModalData:{error:e,previousScreen:a||cr.LANDING}}),i(cr.ERROR_SCREEN)}finally{r(!1)}},disabled:!1,children:[/*#__PURE__*/t(wu,{})," Farcaster",n&&/*#__PURE__*/t(qt,{}),"farcaster"===h&&/*#__PURE__*/t(Rp,{color:"gray",children:"Recent"})]})};let Rp=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-19f52850-0"})(["margin-left:auto;"]);const Op=({...n})=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...n,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_2856_1743)",children:[/*#__PURE__*/t("path",{d:"M22.1673 8.24075V16.3642C22.1673 17.3256 21.3421 18.105 20.3241 18.105H17.0028M22.1673 8.24075C22.1673 7.27936 21.3421 6.5 20.3241 6.5H11.5302M22.1673 8.24075V8.42852C22.1673 9.03302 21.8352 9.59423 21.2901 9.91105L15.1463 13.4818C14.5539 13.8261 13.8067 13.8261 13.2143 13.4818L10.1621 11.5401",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),/*#__PURE__*/t("path",{d:"M3.12913 6.64816C0.508085 12.9507 3.49251 20.1847 9.79504 22.8057L11.5068 23.5176C12.4522 23.9108 13.7783 23.2222 14.1714 22.2768L14.6054 21.2333C14.7687 20.8406 14.6438 20.3871 14.3024 20.1334L11.2872 17.8927C10.9878 17.6702 10.5843 17.6488 10.2632 17.8384L9.11575 18.5156C8.78274 18.7121 8.3597 18.6844 8.07552 18.4221C5.94293 16.4542 4.77629 13.6264 4.90096 10.7273C4.91757 10.3409 5.19796 10.023 5.57269 9.92753L6.86381 9.59869C7.22522 9.50664 7.49627 9.20696 7.55169 8.83815L8.10986 5.12321C8.17306 4.70259 7.94188 4.29293 7.54915 4.1296L6.50564 3.69564C5.56026 3.30248 4.23416 3.99103 3.84101 4.9364L3.12913 6.64816Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_2856_1743",children:/*#__PURE__*/t("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]}),Wp=()=>{let{enabled:n,token:r}=it(),{navigate:a,setModalData:o,app:s,data:l}=lr(),{initLoginWithPasskey:c}=x(),d=()=>{s.loginConfig.passkeysForSignupEnabled?a(cr.SELECT_PASSKEY_SIGNUP_OR_LOGIN):(async()=>{n&&!r?(o({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>c({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:cr.ERROR_SCREEN}}),a(cr.CAPTCHA_SCREEN)):(await c({withPrivyUi:!0}),o({passkeyAuthModalData:{passkeySignupFlow:!1}}),a(cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE))})()};return 0===i((()=>{let e=l?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(s.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[s.loginMethods,l?.login])?/*#__PURE__*/e(il,{onClick:d,children:[/*#__PURE__*/t(no,{})," Continue with passkey"]}):/*#__PURE__*/t(Pp,{onClick:d,children:"I have a passkey"})};let Mp=/*#__PURE__*/Ya(["&&{width:100%;font-size:0.875rem;line-height:1rem;display:flex;gap:0.5rem;justify-content:center;align-items:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]);const Pp=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledLink",componentId:"sc-48dad958-0"})(["",""],Mp),Lp=({value:n,onChange:r})=>/*#__PURE__*/t("select",{value:n,onChange:r,children:Ri.map((t=>/*#__PURE__*/e("option",{value:t.code,children:[t.code," +",t.callCode]},t.code)))}),Dp=/*#__PURE__*/u(((r,a)=>{let{app:i}=lr(),[l,c]=s(!1),{accountType:d}=gt(),[u,h]=s(""),[p,m]=s(i?.intl.defaultCountry??"US"),y=Oi(u,p),g=Wi(p),f=Mi(p),w=Pi(p),v=!y,[C,E]=s(!1),T=w.length,b=e=>{let t=e.target.value;m(t),h(""),r.onChange&&r.onChange({rawPhoneNumber:u,qualifiedPhoneNumber:Di(u,t),countryCode:t,isValid:Oi(u,p)})},A=(e,t)=>{try{let n=e.replace(/\D/g,"")===u.replace(/\D/g,"")?e:g.input(e);h(n),r.onChange&&r.onChange({rawPhoneNumber:n,qualifiedPhoneNumber:Di(e,t),countryCode:t,isValid:Oi(e,t)})}catch(e){console.error("Error processing phone number:",e)}},_=()=>{E(!0);let e=Di(u,p);r.onSubmit({rawPhoneNumber:u,qualifiedPhoneNumber:e,countryCode:p,isValid:Oi(u,p)}).finally((()=>E(!1)))};return o((()=>{if(r.defaultValue){let e=Li(r.defaultValue);g.reset(),b({target:{value:e.countryCode}}),A(e.phone,e.countryCode)}}),[r.defaultValue]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Up,{children:/*#__PURE__*/e(Fp,{$callingCodeLength:T,$stacked:r.stacked,children:[/*#__PURE__*/t(Lp,{value:p,onChange:b}),/*#__PURE__*/t("input",{ref:a,id:"phone-number-input",className:"login-method-button",type:"tel",placeholder:f,onFocus:()=>c(!0),onChange:e=>{A(e.target.value,p)},onKeyUp:e=>{"Enter"===e.key&&_()},value:u,autoComplete:"tel"}),"phone"!==d||l||r.hideRecent?r.stacked||r.noIncludeSubmitButton?/*#__PURE__*/t("span",{}):/*#__PURE__*/t(mn,{isSubmitting:C,onClick:_,disabled:v,children:"Submit"}):/*#__PURE__*/t(vt,{color:"gray",children:"Recent"})]})}),r.stacked&&!r.noIncludeSubmitButton?/*#__PURE__*/t(st,{loading:C,loadingText:null,onClick:_,disabled:v,children:"Submit"}):null]})}));let Up=/*#__PURE__*/Ka.div.withConfig({displayName:"InputContainer",componentId:"sc-2a729487-0"})(["width:100%;"]),Fp=/*#__PURE__*/Ka.label.withConfig({displayName:"PhoneNumberInput",componentId:"sc-2a729487-1"})(["--country-code-dropdown-width:calc(54px + calc(12 * ","px));--phone-input-extra-padding-left:calc(12px + calc(3 * ","px));display:block;position:relative;width:100%;@media (min-width:441px){--country-code-dropdown-width:calc(52px + calc(10 * ","px));}&& > select{font-size:16px;height:24px;position:absolute;margin:13px calc(var(--country-code-dropdown-width) / 4);line-height:24px;width:var(--country-code-dropdown-width);background-color:var(--privy-color-background);background-size:auto;background-position-x:right;cursor:pointer;@media (min-width:441px){font-size:14px;width:var(--country-code-dropdown-width);}:focus{outline:none;box-shadow:none;}}&& > input{font-size:16px;line-height:24px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width:calc(100% - var(--country-code-dropdown-width));padding:12px 88px 12px calc(var(--country-code-dropdown-width) + var(--phone-input-extra-padding-left));padding-right:",";flex-grow:1;background:var(--privy-color-background);border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-mdlg);width:100%;:focus{outline:none;border-color:var(--privy-color-accent);}:autofill,:-webkit-autofill{background:var(--privy-color-background);}@media (min-width:441px){font-size:14px;padding-right:78px;}}&& > :last-child{right:16px;position:absolute;top:50%;transform:translate(0,-50%);}&& > button:last-child{right:0px;line-height:24px;padding:13px 17px;:focus{outline:none;border-color:var(--privy-color-accent);}}&& > input::placeholder{color:var(--privy-color-foreground-3);}"],(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$stacked?"16px":"88px"));const Bp=({isEditable:r,setIsEditable:a,defaultValue:i})=>{let o=l(null),{authenticated:s}=ur(),{navigate:c,setModalData:d,currentScreen:u,data:h}=lr(),{initLoginWithSms:p}=x(),{enabled:m,token:y}=it();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(sl,{$if:!r,children:/*#__PURE__*/t(Dp,{ref:o,onSubmit:async function({qualifiedPhoneNumber:e}){if(!m||y||s)try{await p({phoneNumber:e,captchaToken:y,withPrivyUi:!0,disableSignup:h?.login?.disableSignup}),c(cr.AWAITING_PASSWORDLESS_CODE)}catch(e){d({errorModalData:{error:e,previousScreen:u||cr.LANDING}}),c(cr.ERROR_SCREEN)}else d({captchaModalData:{callback:t=>p({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:h?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:cr.ERROR_SCREEN}}),c(cr.CAPTCHA_SCREEN)},defaultValue:i})}),/*#__PURE__*/t(sl,{$if:r,children:/*#__PURE__*/e(il,{onClick:()=>{a(),setTimeout((()=>{o.current?.focus()}),0)},children:[/*#__PURE__*/t(oi,{})," Continue with SMS"]})})]})};let zp={apple:{logo:/*#__PURE__*/t(Po,{}),displayName:"Apple"},discord:{logo:/*#__PURE__*/t(Lo,{}),displayName:"Discord"},github:{logo:/*#__PURE__*/t(Do,{}),displayName:"GitHub"},google:{logo:/*#__PURE__*/t(Fo,{}),displayName:"Google"},linkedin:{logo:/*#__PURE__*/t(zo,{}),displayName:"LinkedIn"},spotify:{logo:/*#__PURE__*/t(Ho,{}),displayName:"Spotify"},instagram:{logo:/*#__PURE__*/t(Bo,{}),displayName:"Instagram"},twitter:{logo:/*#__PURE__*/t($o,{}),displayName:"Twitter"},tiktok:{logo:/*#__PURE__*/t(Vo,{}),displayName:"TikTok"}};const Hp=({provider:n})=>{let{enabled:r,token:a}=it(),{navigate:o,setModalData:l,data:c}=lr(),[d,u]=s(!1),{initLoginWithOAuth:h}=x(),{accountType:p}=gt(),m=i((()=>p&&"guest"!==p&&"signer"!==p&&"cross_app"!==p?Ep(p):null),[p]),{displayName:y,logo:g}=zp[n];/*#__PURE__*/return e(il,{onClick:()=>{u(!0),r&&!a?(l({captchaModalData:{callback:e=>h(n,e,c?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:cr.ERROR_SCREEN}}),o(cr.CAPTCHA_SCREEN)):h(n,void 0,c?.login?.disableSignup)},disabled:d,children:[g," ",y,m?.loginMethod===n&&/*#__PURE__*/t(Vp,{color:"gray",children:"Recent"})]})};let Vp=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-c2aa414-0"})(["margin-left:auto;"]);function $p(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 240 240",...n,children:[/*#__PURE__*/t("defs",{children:/*#__PURE__*/e("linearGradient",{x1:"120",y1:"240",x2:"120",gradientUnits:"userSpaceOnUse",id:"telegram-linear-gradient",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#1d93d2"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#38b0e3"})]})}),/*#__PURE__*/t("title",{children:"Telegram_logo"}),/*#__PURE__*/t("circle",{cx:"120",cy:"120",r:"120",fill:"url(#telegram-linear-gradient)"}),/*#__PURE__*/t("path",{d:"M81.229,128.772l14.237,39.406s1.78,3.687,3.686,3.687,30.255-29.492,30.255-29.492l31.525-60.89L81.737,118.6Z",fill:"#c8daea"}),/*#__PURE__*/t("path",{d:"M100.106,138.878l-2.733,29.046s-1.144,8.9,7.754,0,17.415-15.763,17.415-15.763",fill:"#a9c6d8"}),/*#__PURE__*/t("path",{d:"M81.486,130.178,52.2,120.636s-3.5-1.42-2.373-4.64c.232-.664.7-1.229,2.1-2.2,6.489-4.523,120.106-45.36,120.106-45.36s3.208-1.081,5.1-.362a2.766,2.766,0,0,1,1.885,2.055,9.357,9.357,0,0,1,.254,2.585c-.009.752-.1,1.449-.169,2.542-.692,11.165-21.4,94.493-21.4,94.493s-1.239,4.876-5.678,5.043A8.13,8.13,0,0,1,146.1,172.5c-8.711-7.493-38.819-27.727-45.472-32.177a1.27,1.27,0,0,1-.546-.9c-.093-.469.417-1.05.417-1.05s52.426-46.6,53.821-51.492c.108-.379-.3-.566-.848-.4-3.482,1.281-63.844,39.4-70.506,43.607A3.21,3.21,0,0,1,81.486,130.178Z",fill:"#fff"})]})}const jp=()=>{let{enabled:n,token:r}=it(),{navigate:a,setModalData:i,data:o}=lr(),[l,c]=s(!1),{initLoginWithTelegram:d}=x(),{accountType:u}=gt();async function h(e){try{await d(e,o?.login?.disableSignup),i({telegramAuthModalData:{seamlessAuth:!1}}),a(cr.TELEGRAM_AUTH_SCREEN)}catch(e){console.error(e),c(!1)}}/*#__PURE__*/return e(il,{onClick:async function(){if(c(!0),n&&!r)return i({captchaModalData:{callback:h,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:cr.ERROR_SCREEN}}),void a(cr.CAPTCHA_SCREEN);await h(r)},disabled:l,children:[/*#__PURE__*/t($p,{}),"Telegram","telegram"===u&&/*#__PURE__*/t(Gp,{color:"gray",children:"Recent"})]})};let Gp=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-f716a3a1-0"})(["margin-left:auto;"]);const qp=({onClick:n,text:r,icon:a})=>/*#__PURE__*/e(il,{onClick:n,children:[a,/*#__PURE__*/t(Xs,{children:r}),/*#__PURE__*/t(to,{})]}),Kp=({connectOnly:r})=>{let{closePrivyModal:a,connectors:l}=x(),{data:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),u=dr(),{accountType:h,walletClientType:p,chainType:m}=gt(),y=i((()=>h&&"guest"!==h&&"signer"!==h&&"cross_app"!==h?Ep(h):null),[h]),g=c?.login,{email:f,sms:w,google:v,twitter:C,discord:E,github:T,spotify:b,instagram:A,tiktok:_,linkedin:k,apple:I,wallet:N,farcaster:S,telegram:R}=i((()=>g?.loginMethods?Ui(g.loginMethods,!0):null),[g])??u.loginMethods,{passkey:O}=u.loginMethods,W=[f&&"email",w&&"sms",v&&"google",C&&"twitter",E&&"discord",T&&"github",b&&"spotify",A&&"instagram",_&&"tiktok",k&&"linkedin",I&&"apple",S&&"farcaster",R&&"telegram"].filter((e=>!!e)),M=W.length>0,P=i((()=>N&&!M?"web3-first":N&&u?.appearance.loginGroupPriority||"web2-first"),[N,M,u?.appearance.loginGroupPriority]),L=u?.appearance.hideDirectWeb2Inputs,[D,U]=s("default"),[F,B]=s(Xp({mostRecentlyUsedAccountType:h,smsAvailable:w,emailAvailable:f,prefilledType:g?.prefill?.type}));o((()=>{B(Xp({mostRecentlyUsedAccountType:h,smsAvailable:w,emailAvailable:f,prefilledType:g?.prefill?.type}))}),[f,w,h]);let z=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{U("default")}),150)};d.current=z;let H=[];p&&N?H.push(p):y?.loginMethod&&W.includes(y.loginMethod)&&H.push(y.loginMethod);let V=e=>"email"===e?/*#__PURE__*/t(xp,{isEditable:"email"===F,setIsEditable:()=>{B("email")},defaultValue:"email"===g?.prefill?.type?g.prefill.value:void 0},e):"sms"===e?/*#__PURE__*/t(Bp,{isEditable:"sms"===F,setIsEditable:()=>{B("sms")},defaultValue:"phone"===g?.prefill?.type?g.prefill.value:void 0},e):"apple"===e?/*#__PURE__*/t(Hp,{provider:"apple"},e):"discord"===e?/*#__PURE__*/t(Hp,{provider:"discord"},e):"farcaster"===e?/*#__PURE__*/t(Sp,{},e):"github"===e?/*#__PURE__*/t(Hp,{provider:"github"},e):"google"===e?/*#__PURE__*/t(Hp,{provider:"google"},e):"linkedin"===e?/*#__PURE__*/t(Hp,{provider:"linkedin"},e):"tiktok"===e?/*#__PURE__*/t(Hp,{provider:"tiktok"},e):"spotify"===e?/*#__PURE__*/t(Hp,{provider:"spotify"},e):"instagram"===e?/*#__PURE__*/t(Hp,{provider:"instagram"},e):"twitter"===e?/*#__PURE__*/t(Hp,{provider:"twitter"},e):"telegram"===e?/*#__PURE__*/t(jp,{},e):xc({walletList:u.appearance.walletList,walletChainType:g?.walletChainType??u.appearance.walletChainType,connectors:l,connectOnly:r,ignore:[],walletConnectEnabled:u.externalWallets.walletConnect.enabled,forceWallet:{wallet:e,chainType:m??"ethereum"}}),$=xc({walletList:u.appearance.walletList.filter((e=>e!==p)),walletChainType:g?.walletChainType??u.appearance.walletChainType,connectors:l,connectOnly:r,ignore:[...u.appearance.walletList,p],walletConnectEnabled:u.externalWallets.walletConnect.enabled}),j=W.filter((e=>e!==y?.loginMethod)).flatMap(V),G=H.flatMap(V);"web3-first"===P&&"default"===D?$.unshift(...G):"web2-first"===P&&j.unshift(...G);let q=W.filter((e=>"email"!==e&&"sms"!==e)),K=Zp({priority:P,email:f,sms:w,social:q}),Y=Jp({priority:P,email:f,sms:w,social:q}),Z=/*#__PURE__*/t(up,{text:Qp({priority:P}),onClick:()=>U("web3-overflow")}),J=/*#__PURE__*/t(qp,{text:K,icon:Y,onClick:()=>U("web2-overflow")}),Q=L?0:1,X=N&&$.length>0,ee=0===j.length&&N&&0===$.length,te=5-(X?1:0),ne=$.length>0?$:/*#__PURE__*/t(fc,{chainType:u.appearance.walletChainType,withPadding:!0});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{title:u.appearance.landingHeader,onClose:z,backFn:"default"===D?void 0:()=>{U("default")}}),"default"===D&&/*#__PURE__*/t(Yp,{}),"default"===D&&("string"==typeof u.appearance.loginMessage?/*#__PURE__*/t(al,{children:u.appearance.loginMessage}):u.appearance.loginMessage),/*#__PURE__*/t(el,{style:{overflow:"hidden",padding:2},children:/*#__PURE__*/e(tl,{children:["default"===D&&"web2-first"===P&&/*#__PURE__*/e(n,{children:[j.length>te?j.slice(0,te-1):j,j.length>te&&J,X&&Z,ee&&/*#__PURE__*/t(fc,{chainType:u.appearance.walletChainType})]}),"default"===D&&"web3-first"===P&&/*#__PURE__*/e(n,{children:[N&&/*#__PURE__*/e(n,{children:[$.length>te?$.slice(0,te-1):$,$.length>te&&Z]}),j.length>Q&&J,j.length===Q&&j[0],ee&&/*#__PURE__*/t(fc,{chainType:u.appearance.walletChainType})]}),"web2-overflow"===D&&/*#__PURE__*/t(n,{children:"web3-first"===P?j:j.slice(3)}),"web3-overflow"===D?ne:[],O&&"default"===D&&/*#__PURE__*/t(Wp,{})]})}),u&&/*#__PURE__*/t(Et,{app:u}),/*#__PURE__*/t(ct,{})]})};let Yp=/*#__PURE__*/Ka(bp).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-2678dfdf-0"})(["margin-bottom:16px;"]),Zp=({priority:e,email:t,sms:n,social:r})=>"web2-first"===e?"Other socials":t&&n&&r.length>0||t&&r.length>0?"Log in with email or socials":n&&r.length>0?"Log in with sms or socials":t&&n?"Continue with email or sms":t?"Continue with email":n?"Continue with sms":"Log in with a social account",Jp=({priority:e,email:n,sms:r,social:a})=>"web2-first"===e||a.length>0?/*#__PURE__*/t(Ti,{}):n&&r?/*#__PURE__*/t(Op,{}):n?/*#__PURE__*/t(ii,{}):r?/*#__PURE__*/t(oi,{}):null,Qp=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const Xp=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:n,prefilledType:r})=>n&&("email"===e&&"phone"!==r||"email"===r)||!t||"phone"!==e&&"phone"!==r?"email":"sms",em=({connectOnly:r})=>{let{closePrivyModal:a,connectors:l}=x(),{app:c,onUserCloseViaDialogOrKeybindRef:d,data:u}=lr(),{appearance:{palette:{colorScheme:h}}}=dr(),{accountType:p,walletClientType:m,chainType:y}=gt(),g=i((()=>p&&"guest"!==p&&"signer"!==p&&"cross_app"!==p?Ep(p):null),[p]),f=c.loginMethodsAndOrder?.primary??[],w=c.loginMethodsAndOrder?.overflow??[],v=i((()=>[...f,...w]),[f,w]),C=c.loginMethods.passkey,E=u?.login,T=[];m&&v.includes(m)?T.push(m):p&&v.includes(g?.loginMethod)&&T.push(g?.loginMethod);let[b,A]=s("default"),[_,k]=s(Xp({mostRecentlyUsedAccountType:p,smsAvailable:v.includes("sms"),emailAvailable:v.includes("email"),prefilledType:E?.prefill?.type}));o((()=>{k(Xp({mostRecentlyUsedAccountType:p,smsAvailable:v.includes("sms"),emailAvailable:v.includes("email"),prefilledType:E?.prefill?.type}))}),[v,p]),o((()=>{"phone"===p&&k("sms");let e=v.indexOf("sms"),t=v.indexOf("email");e>-1&&e<t&&k("sms")}),[p,f,w]);let I=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{A("default")}),150)};d.current=I;let N=e=>"email"===e?/*#__PURE__*/t(xp,{isEditable:"email"===_,setIsEditable:()=>{k("email")},defaultValue:"email"===E?.prefill?.type?E.prefill.value:void 0},e):"sms"===e?/*#__PURE__*/t(Bp,{isEditable:"sms"===_,setIsEditable:()=>{k("sms")},defaultValue:"phone"===E?.prefill?.type?E.prefill.value:void 0},e):"apple"===e?/*#__PURE__*/t(Hp,{provider:"apple"},e):"discord"===e?/*#__PURE__*/t(Hp,{provider:"discord"},e):"farcaster"===e?/*#__PURE__*/t(Sp,{},e):"github"===e?/*#__PURE__*/t(Hp,{provider:"github"},e):"google"===e?/*#__PURE__*/t(Hp,{provider:"google"},e):"linkedin"===e?/*#__PURE__*/t(Hp,{provider:"linkedin"},e):"spotify"===e?/*#__PURE__*/t(Hp,{provider:"spotify"},e):"instagram"===e?/*#__PURE__*/t(Hp,{provider:"instagram"},e):"tiktok"===e?/*#__PURE__*/t(Hp,{provider:"tiktok"},e):"twitter"===e?/*#__PURE__*/t(Hp,{provider:"twitter"},e):"telegram"===e?/*#__PURE__*/t(jp,{},e):e.startsWith("privy:")?/*#__PURE__*/t(_p,{appId:e.replace("privy:","")},e):xc({walletList:c.appearance.walletList,walletChainType:E?.walletChainType??c.appearance.walletChainType,connectors:l,connectOnly:r,ignore:v,walletConnectEnabled:c.externalWallets.walletConnect.enabled,forceWallet:{wallet:e,chainType:y??"ethereum"}}),S=T.flatMap(N),R=f.filter((e=>e!==m&&e!==g?.loginMethod)).flatMap(N),O=w.filter((e=>e!==m&&e!==g?.loginMethod)).flatMap(N),[W,M]=fn([...S,...R,...O],tm({primary:R.length+S.length,overflow:O.length}));/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{title:c.appearance.landingHeader,onClose:I,backFn:"default"===b?void 0:()=>{A("default")}}),"default"===b&&/*#__PURE__*/t(nm,{}),"default"===b&&("string"==typeof c.appearance.loginMessage?/*#__PURE__*/t(al,{children:c.appearance.loginMessage}):c.appearance.loginMessage),/*#__PURE__*/t(el,{style:{overflow:"hidden"},children:/*#__PURE__*/e(nl,{$colorScheme:h,children:["default"===b&&/*#__PURE__*/e(n,{children:[W,M.length>0&&/*#__PURE__*/t(qp,{text:"More options",icon:/*#__PURE__*/t(Ti,{}),onClick:()=>A("overflow")})]}),"overflow"===b&&/*#__PURE__*/t(n,{children:M}),C&&"default"===b&&/*#__PURE__*/t(Wp,{})]})}),c&&/*#__PURE__*/t(Et,{app:c}),/*#__PURE__*/t(ct,{})]})};let tm=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,nm=/*#__PURE__*/Ka(bp).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-85b7f7ea-0"})(["margin-bottom:16px;"]);const rm=({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"})]});function am(){let{promptMfa:e,init:t,submit:n,cancel:r,mfaMethods:a}=h(Wr);return{promptMfa:e,init:t,submit:n,cancel:r,mfaMethods:a}}function im(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenroll:o,enrollInMfa:s}=h(Wr);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 om=n=>/*#__PURE__*/e(sm,{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 sm=/*#__PURE__*/Ka.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 lm=({showIntro:r,userMfaMethods:a,appMfaMethods:i,userHasAuthSms:o,isTotpLoading:s,isPasskeyLoading:l,error:c,onClose:d,onBackToIntro:u,handleSelectMethod:h,setRemovingMfaMethod:p})=>{let m=a.reduce(((e,t)=>({...e,[t]:!0})),{}),y=i.reduce(((e,t)=>({...e,[t]:!0})),{});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:r?u:void 0,onClose:d},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(Nl,{children:"Choose a verification method"}),a.length>0?/*#__PURE__*/t(xl,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/t(xl,{children:"How would you like to verify your identity? You can change this later."}),c&&/*#__PURE__*/t($l,{style:{marginTop:"1.25rem"},children:c.message}),/*#__PURE__*/e(Pl,{children:[(y.totp||m.totp)&&/*#__PURE__*/e(Ll,{children:[/*#__PURE__*/t(il,{style:{justifyContent:"center"},disabled:m.totp||s,onClick:()=>h("totp"),children:s?/*#__PURE__*/t(Ht,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(Bl,{children:[/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/t(lo,{}),"Authenticator app"]}),m.totp?/*#__PURE__*/t(cm,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Fl,{children:"Recommended"})]})}),m.totp&&/*#__PURE__*/t(Dl,{style:{position:"absolute",right:0},onClick:()=>p("totp"),children:/*#__PURE__*/t(co,{})})]},"totp"),(y.sms||m.sms)&&/*#__PURE__*/e(Ll,{children:[/*#__PURE__*/t(il,{disabled:m.sms||o,onClick:()=>h("sms"),children:/*#__PURE__*/e(Bl,{children:[/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/t(oi,{}),"SMS"]}),m.sms&&/*#__PURE__*/t(cm,{color:"green",children:"Enabled"}),o&&/*#__PURE__*/t(Fl,{children:"Disabled"})]})}),m.sms&&/*#__PURE__*/t(Dl,{style:{position:"absolute",right:0},onClick:()=>p("sms"),children:/*#__PURE__*/t(co,{})})]},"sms"),(y.passkey||m.passkey)&&/*#__PURE__*/e(Ll,{children:[/*#__PURE__*/t(il,{style:{justifyContent:"center"},onClick:()=>h("passkey"),disabled:m.passkey||l,children:l?/*#__PURE__*/t(Ht,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(Bl,{children:[/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/t(no,{}),"Passkey"]}),m.passkey?/*#__PURE__*/t(cm,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Fl,{isAccent:!0,children:/*#__PURE__*/t(to,{})})]})}),m.passkey&&/*#__PURE__*/t(Dl,{style:{position:"absolute",right:0},onClick:()=>p("passkey"),children:/*#__PURE__*/t(co,{})})]},"passkey")]}),/*#__PURE__*/t(yt,{})]})};let cm=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const dm=({appName:e,onComplete:n,onClose:r,onReset:a})=>{let{user:o}=ur(),{data:l}=lr(),{initLinkWithPasskey:c,linkWithPasskey:d}=x(),{initEnrollmentWithPasskey:u,submitEnrollmentWithPasskey:h}=im(),[p,m]=s(!1),[y,g]=s(!1),[f,w]=s(!1),[v,C]=s(null),E=i((()=>o?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[o]),T=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},b=async e=>{m(!0);try{await u(),await h({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),w(!0)}catch(e){C(e)}finally{m(!1)}},A=async()=>{g(!0),C(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await b(t)}catch(e){C(e)}finally{g(!1)}};return 0===E.length||y?/*#__PURE__*/t(um,{onReset:a,onClose:r,onClick:A,isCreating:y}):f?/*#__PURE__*/t(pm,{appName:e,onClick:T,onClose:T}):v?/*#__PURE__*/t(cu,{error:v,backFn:()=>C(null),onClick:()=>C(null)}):/*#__PURE__*/t(hm,{passkeys:E,isSubmitting:p,isCreating:y,onReset:a,onClose:r,onSubmitEnrollment:()=>b(E.map((e=>e.credentialId))),onAddPasskey:A})};let um=({onReset:r,onClose:a,onClick:i,isCreating:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{backFn:r,onClose:a},"header"),/*#__PURE__*/t(Il,{children:/*#__PURE__*/e(ch,{children:[/*#__PURE__*/t(ih,{}),/*#__PURE__*/t(oh,{})]})}),/*#__PURE__*/t(Nl,{children:"Set up passkey verification"}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(oo,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ro,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(uo,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/t(st,{style:{marginTop:"2.25rem"},onClick:i,loading:o,children:"Add a new passkey"}),/*#__PURE__*/t(yt,{})]}),hm=({onReset:r,onClose:a,onAddPasskey:i,onSubmitEnrollment:o,passkeys:l,isSubmitting:c,isCreating:d})=>{let[u,h]=s(!1),p=u?l.length:l.length>3?2:3;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:u?()=>h(!1):r,onClose:a},"header"),!u&&/*#__PURE__*/t(Il,{children:/*#__PURE__*/e(ch,{children:[/*#__PURE__*/t(ih,{}),/*#__PURE__*/t(oh,{})]})}),/*#__PURE__*/t(Nl,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e(Rl,{children:[l.slice(0,p).map((n=>/*#__PURE__*/e(mm,{children:[/*#__PURE__*/t(ym,{children:fm(n)}),/*#__PURE__*/e(gm,{children:["Last used: ",n.latestVerifiedAt?.toLocaleString()]})]},n.credentialId))),!u&&l.length>3&&/*#__PURE__*/t(wm,{onClick:()=>h(!0),children:"View All"})]}),/*#__PURE__*/t(st,{style:{marginTop:"1.5rem"},onClick:o,loading:c,children:"Enable passkeys"}),l.length<5&&/*#__PURE__*/t(wm,{style:{marginTop:"0.5rem"},onClick:i,disabled:d,children:d?/*#__PURE__*/t(Ht,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/t(yt,{})]})},pm=({appName:r,onClick:a,onClose:i})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:i},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(Nl,{children:"Passkey verification added"}),/*#__PURE__*/e(xl,{children:["From now on, you'll use the passkey whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:a,children:"Done"})}),/*#__PURE__*/t(yt,{})]}),mm=/*#__PURE__*/Ka.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%;}"]),ym=/*#__PURE__*/Ka.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);"]),gm=/*#__PURE__*/Ka.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);"]),fm=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 wm=/*#__PURE__*/Ka.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;}}"]);let vm=Array(6).fill("");var Cm,Em=((Cm=Em||{})[Cm.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",Cm[Cm.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",Cm);function Tm(e){return/^[0-9]{1}$/.test(e)}function bm(e){return 6===e.length&&e.every(Tm)}const Am=({onChange:r,disabled:a,errorReasonOverride:i,success:o})=>{let[l,c]=s(vm),[d,u]=s(null),[h,p]=s(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(Tm(t))),0),a=t.split(""),i=!a.every(Tm),o=a.length+n>6;if(i)return u("Passcode can only be numbers"),void p(1);if(o)return u("Passcode must be exactly 6 numbers"),void p(1);u(null),p(null);let s=Number(e.currentTarget.name?.charAt(4)),d=[...t||[""]].slice(0,6-s),h=[...l.slice(0,s),...d,...l.slice(s+d.length)];c(h);let m=Math.min(Math.max(s+d.length,0),5),y=document.querySelector(`input[name=pin-${m}]`);if(y?.focus(),bm(h))try{await r(h.join(""));let e=document.querySelector(`input[name=pin-${m}]`);e?.blur()}catch(e){p(1),u(e.message)}else try{await r(null)}catch(e){p(1),u(e.message)}},g=o?"success":!(!i&&!d)?"fail":"";/*#__PURE__*/return t(n,{children:/*#__PURE__*/e(_m,{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===h&&(u(null),p(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()}bm(t)?r(t.join("")):r(null)})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:g,autoComplete:y?"one-time-code":"off",disabled:a},n)))}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(km,{$fail:!!i||!!d,children:i||d})})]})})};let _m=/*#__PURE__*/Ka.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);}}"]),km=/*#__PURE__*/Ka.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 Im=({appName:r,onComplete:a,onReset:i,onClose:o})=>{let[l,c]=s(""),[d,u]=s(!1),[h,p]=s(null),[m,y]=s("enroll"),{initEnrollmentWithSms:g,submitEnrollmentWithSms:f}=im(),{app:w,data:v}=lr();function C(){v?.mfaEnrollmentFlow?.onSuccess(),a()}return h?/*#__PURE__*/t(cu,{error:h,backFn:()=>p(null),onClick:()=>p(null)}):/*#__PURE__*/e(n,"enroll"===m?{children:[/*#__PURE__*/t(ot,{backFn:i,onClose:o},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oi,{})}),/*#__PURE__*/t(Nl,{children:"Set up SMS verification"}),/*#__PURE__*/e(xl,{children:["We'll text a verification code to this mobile device whenever you use your ",r," ","wallet."]}),/*#__PURE__*/e(Sl,{children:[/*#__PURE__*/t(Dp,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await g({phoneNumber:e}),c(e),y("verify")}catch(e){p(e)}},hideRecent:!0}),/*#__PURE__*/e(zl,{children:["By providing your mobile number, you agree to receive text messages from ",w?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/t(yt,{})]}:d?{children:[/*#__PURE__*/t(ot,{onClose:C},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(Nl,{children:"SMS verification added"}),/*#__PURE__*/e(xl,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:C,children:"Done"})}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{backFn:function(){"verify"===m?y("enroll"):i()},onClose:o},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oi,{})}),/*#__PURE__*/t(Nl,{children:"Enter enrollment code"}),/*#__PURE__*/e(Sl,{children:[/*#__PURE__*/t(Am,{onChange:async function(e){try{if(!e)return;await f({phoneNumber:l,mfaCode:e}),u(!0)}catch(e){if(Kc(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Gc(e))throw Error("The code you entered is not valid");if(jc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw Yc(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e(xl,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/t("strong",{children:Fi(l)})]})]}),/*#__PURE__*/t(yt,{})]})},Nm=({size:e,authUrl:n})=>/*#__PURE__*/t(zt,{url:n,squareLogoElement:ho,size:e,fgColor:"#1F1F1F"}),xm=({onComplete:r,onClose:a,onReset:i,totpInfo:o})=>{let[l,c]=s("enroll"),[d,u]=s(!1),{submitEnrollmentWithTotp:h}=im(),{data:p}=lr();function m(){p?.mfaEnrollmentFlow?.onSuccess(),r()}/*#__PURE__*/return e(n,"enroll"===l?{children:[/*#__PURE__*/t(ot,{backFn:i,onClose:a},"header"),/*#__PURE__*/t(Nl,{children:"Scan QR code"}),/*#__PURE__*/t(xl,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/t(Bt,{children:/*#__PURE__*/t(Nm,{authUrl:o.authUrl,size:200})}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(Ft,{children:/*#__PURE__*/t(mu,{itemName:"setup key",text:o.secret})}),/*#__PURE__*/t(st,{onClick:function(){c("verify")},children:"Continue"})]}),/*#__PURE__*/t(yt,{})]}:d?{children:[/*#__PURE__*/t(ot,{onClose:m},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(Nl,{children:"Authenticator app verification added"}),/*#__PURE__*/e(xl,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",o.appName," wallet."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:m,children:"Done"})}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{backFn:function(){"verify"===l?c("enroll"):i()},onClose:a},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(lo,{})}),/*#__PURE__*/t(Nl,{children:"Enter enrollment code"}),/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(Am,{onChange:async function(e){try{if(!e)return;await h({mfaCode:e}),u(!0)}catch(e){if(Kc(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Gc(e))throw Error("The code you entered is not valid");if(jc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw Yc(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e(xl,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),/*#__PURE__*/t(yt,{})]})},Sm=({label:n,children:r,valueStyles:a})=>/*#__PURE__*/e(Rm,{children:[/*#__PURE__*/t("div",{children:n}),/*#__PURE__*/t(Om,{style:{...a},children:r})]});let Rm=/*#__PURE__*/Ka.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;}"]),Om=/*#__PURE__*/Ka.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;"]);const Wm=({weiQuantities:e,tokenPrice:n,tokenSymbol:r})=>{let a=rn(e),i=n?tn(a,n):void 0,o=Yt(a,r);/*#__PURE__*/return t(Lm,{children:i||o})},Mm=({weiQuantities:r,tokenPrice:a,tokenSymbol:i})=>{let o=rn(r),s=a?tn(o,a):void 0,l=Yt(o,i);/*#__PURE__*/return t(Lm,{children:s?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Dm,{children:"USD"}),"<$0.01"===s?
8
- /*#__PURE__*/e(Fm,{children:[/*#__PURE__*/t(Um,{children:"<"}),"$0.01"]}):s]}):l})},Pm=({quantities:r,tokenPrice:a,tokenSymbol:i="SOL",tokenDecimals:o=9})=>{let s=r.reduce(((e,t)=>e+t),0n),l=a&&"SOL"===i&&9===o?Lu(s,a):void 0,c="SOL"===i&&9===o?Pu(s):`${Ra(s,o)} ${i}`;/*#__PURE__*/return t(Lm,{children:l?/*#__PURE__*/t(n,{children:"<$0.01"===l?
9
- /*#__PURE__*/e(Fm,{children:[/*#__PURE__*/t(Um,{children:"<"}),"$0.01"]}):l}):c})};let Lm=/*#__PURE__*/Ka.span.withConfig({displayName:"StyledPriceDisplay",componentId:"sc-596cd423-0"})(["font-size:14px;line-height:140%;display:flex;gap:4px;align-items:center;"]),Dm=/*#__PURE__*/Ka.span.withConfig({displayName:"StyledPriceUnit",componentId:"sc-596cd423-1"})(["font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);"]),Um=/*#__PURE__*/Ka.span.withConfig({displayName:"TinyLessThan",componentId:"sc-596cd423-2"})(["font-size:10px;"]),Fm=/*#__PURE__*/Ka.span.withConfig({displayName:"FlexCenter",componentId:"sc-596cd423-3"})(["display:flex;align-items:center;"]);const Bm=({gas:n,tokenPrice:r,tokenSymbol:a})=>/*#__PURE__*/e(sn,{style:{paddingBottom:"12px"},children:[/*#__PURE__*/e(Hm,{children:[/*#__PURE__*/t($m,{children:"Est. Fees"}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Mm,{weiQuantities:[BigInt(n)],tokenPrice:r,tokenSymbol:a})})]}),r&&/*#__PURE__*/t(Vm,{children:`${Yt(BigInt(n),a)}`})]}),zm=({value:n,gas:r,tokenPrice:a,tokenSymbol:i})=>{let o=BigInt(n??0)+BigInt(r);/*#__PURE__*/return e(sn,{children:[/*#__PURE__*/e(Hm,{children:[/*#__PURE__*/t($m,{children:"Total (including fees)"}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Mm,{weiQuantities:[BigInt(n||0),BigInt(r)],tokenPrice:a,tokenSymbol:i})})]}),a&&/*#__PURE__*/t(Vm,{children:Yt(o,i)})]})};let Hm=/*#__PURE__*/Ka.div.withConfig({displayName:"TransactionTotalRow",componentId:"sc-f8ef9b74-0"})(["display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-top:4px;"]),Vm=/*#__PURE__*/Ka.div.withConfig({displayName:"ValueConversionRow",componentId:"sc-f8ef9b74-1"})(["display:flex;flex-direction:row;height:12px;font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);font-weight:400;"]),$m=/*#__PURE__*/Ka.div.withConfig({displayName:"TotalText",componentId:"sc-f8ef9b74-2"})(["font-size:14px;line-height:22.4px;font-weight:400;"]);const jm=/*#__PURE__*/p(void 0),Gm=/*#__PURE__*/p(void 0),qm=({defaultValue:e,children:n})=>{let[r,a]=s(e||null);/*#__PURE__*/return t(jm.Provider,{value:{activePanel:r,togglePanel:e=>{a(r===e?null:e)}},children:/*#__PURE__*/t(Qm,{children:n})})},Km=({value:e,children:n})=>{let{activePanel:r,togglePanel:a}=h(jm),i=r===e;/*#__PURE__*/return t(Gm.Provider,{value:{onToggle:()=>a(e),value:e},children:/*#__PURE__*/t(ny,{isActive:i,"data-open":i,children:n})})},Ym=({children:r})=>{let{activePanel:a}=h(jm),{onToggle:i,value:o}=h(Gm),s=a===o;/*#__PURE__*/
10
- return e(n,{children:[/*#__PURE__*/e(Xm,{onClick:i,"data-open":s,children:[/*#__PURE__*/t(ty,{children:r}),/*#__PURE__*/t(iy,{isactive:s,children:/*#__PURE__*/t(Zi,{height:"16px",width:"16px",strokeWidth:"2"})})]}),/*#__PURE__*/t(ey,{})]})},Zm=({children:e})=>{let{activePanel:n}=h(jm),{value:r}=h(Gm);/*#__PURE__*/return t(ry,{"data-open":n===r,children:/*#__PURE__*/t(ay,{children:e})})},Jm=({children:e})=>{let{activePanel:n}=h(jm),{value:r}=h(Gm);/*#__PURE__*/return t(ay,{children:"function"==typeof e?e({isActive:n===r}):e})};let Qm=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionRoot",componentId:"sc-281bf545-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;"]),Xm=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionTriggerContainer",componentId:"sc-281bf545-1"})(["display:flex;justify-content:space-between;align-items:center;width:100%;cursor:pointer;padding-bottom:8px;"]),ey=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionDivider",componentId:"sc-281bf545-2"})(["width:100%;&&{border-top:1px solid;border-color:var(--privy-color-foreground-4);}padding-bottom:12px;"]),ty=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-281bf545-3"})(["font-size:14px;font-weight:500;line-height:19.6px;width:100%;padding-right:8px;"]),ny=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionPanelContainer",componentId:"sc-281bf545-4"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;padding:12px;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),ry=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionContentContainer",componentId:"sc-281bf545-5"})(["position:relative;overflow:hidden;transition:max-height 25ms ease-out;&[data-open='true']{max-height:700px;}&[data-open='false']{max-height:0;}"]),ay=/*#__PURE__*/Ka.div.withConfig({displayName:"ContentWrapper",componentId:"sc-281bf545-6"})(["display:flex;flex-direction:column;gap:12px;flex:1 1 auto;min-height:1px;"]),iy=/*#__PURE__*/Ka.div.withConfig({displayName:"IconWrapper",componentId:"sc-281bf545-7"})(["transform:",";"],(e=>e.isactive?"rotate(180deg)":"rotate(0deg)"));const oy=({walletAddress:e,chainId:n=Cr,network:r,rpcEndpoint:a})=>/*#__PURE__*/t(sy,{href:"ethereum"===r?wn(n,e):Mr(e,Er(a||"")),target:"_blank",children:Ct(e)});let sy=/*#__PURE__*/Ka.a.withConfig({displayName:"StyledLink",componentId:"sc-adda23e5-0"})(["&:hover{text-decoration:underline;}"]);const ly=({from:n,to:r,txn:a,transactionInfo:i,tokenPrice:o,gas:s,tokenSymbol:l})=>{let c=BigInt(a?.value||0);/*#__PURE__*/
11
- return t(qm,{...dr().render.standalone?{defaultValue:"details"}:{},children:/*#__PURE__*/e(Km,{value:"details",children:[/*#__PURE__*/t(Ym,{children:/*#__PURE__*/e(cy,{children:[/*#__PURE__*/t("div",{children:i?.title||"Details"}),/*#__PURE__*/t(dy,{children:/*#__PURE__*/t(Wm,{weiQuantities:[c],tokenPrice:o,tokenSymbol:l})})]})}),/*#__PURE__*/e(Zm,{children:[/*#__PURE__*/t(Sm,{label:"From",children:/*#__PURE__*/t(oy,{walletAddress:n,chainId:a.chainId||Cr,network:"ethereum"})}),/*#__PURE__*/t(Sm,{label:"To",children:/*#__PURE__*/t(oy,{walletAddress:r,chainId:a.chainId||Cr,network:"ethereum"})}),i&&i.action&&/*#__PURE__*/t(Sm,{label:"Action",children:i.action}),s&&/*#__PURE__*/t(Bm,{value:a.value,gas:s,tokenPrice:o,tokenSymbol:l})]}),/*#__PURE__*/t(Jm,{children:({isActive:e})=>/*#__PURE__*/t(zm,{value:a.value,displayFee:e,gas:s||"0x0",tokenPrice:o,tokenSymbol:l})})]})})};let cy=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-29499c17-0"})(["display:flex;flex-direction:row;justify-content:space-between;"]),dy=/*#__PURE__*/Ka.div.withConfig({displayName:"TotalText",componentId:"sc-29499c17-1"})(["flex-shrink:0;padding-left:8px;"]);async function uy(e,t,n){let r=ys(e),a=await t.prepareTransactionRequest({...r,account:{address:n,type:"json-rpc"}});return{...a,type:ps[a.type]}}const hy=({pendingTransaction:e})=>{let{getAccessToken:n}=ur(),{wallets:r}=Tr(),{walletProxy:a,rpcConfig:l,chains:c,appId:d,nativeTokenSymbolForChainId:u}=x(),[h,p]=s(null),[m,y]=s(e),{tokenPrice:g}=Ou(m.chainId),f=u(e.chainId)||"ETH",w=i((()=>r.find((e=>"privy"===e.walletClientType))),[r]);return o((()=>{(async function(){if(!await n()||!a||!w)return m;let e=Ha(m.chainId,c,l,{appId:d}),t=await uy(m,e,w.address);return p(_a(BigInt(t.gas??0))),t})().then(y).catch(console.error)}),[a]),w?/*#__PURE__*/t(py,{children:/*#__PURE__*/t(ly,{from:w.address,to:m.to,txn:m,gas:h??void 0,tokenPrice:g,tokenSymbol:f})}):null};let py=/*#__PURE__*/Ka.div.withConfig({displayName:"TransactionInfoWrapper",componentId:"sc-731f1950-0"})(["width:100%;padding:1rem 0;"]);const my=({hasBlockingError:r,error:a,onClose:i,onBack:o,handleSubmit:s,account:l,submitSuccess:c})=>{let{pendingTransaction:d}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:i},"header"),/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:c,fail:!!a}),/*#__PURE__*/t(a?Qa:ih,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/t(Nl,{style:{marginTop:"1rem"},children:"Verifying with passkey"}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(oo,{})}),"Approve this action using your touch, face, PIN, or hardware key."]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(po,{})}),"You last added a passkey on"," ",l?.firstVerifiedAt?.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),"."]})]}),d&&/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(hy,{pendingTransaction:d})}),a&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t($l,{style:{marginTop:"1.25rem"},children:a.message}),/*#__PURE__*/t(st,{disabled:r,onClick:s,style:{marginTop:"1.25rem"},children:"Try again"})]}),o&&/*#__PURE__*/t(Hl,{style:{marginTop:"1rem"},onClick:o,children:"Choose another method"}),/*#__PURE__*/t(yt,{})]})},yy=({open:r,onClose:a})=>{let{user:i}=ur(),[c,d]=s(i?.mfaMethods[0]??null),{init:u,cancel:h,submit:p}=am(),[m,y]=s(!1),[g,f]=s(!1),[w,v]=s(null),[C,E]=s(null);o((()=>{d(i?.mfaMethods[0]??null)}),[i?.mfaMethods]);let T=l(!1);o((()=>{!T.current&&c&&r&&(T.current=!0,_(c).finally((()=>{T.current=!1})))}),[r]);let b=e=>qc(e)?(y(!0),Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")):Gc(e)?(y(!1),Error("The code you entered is not valid")):jc(e)?(y(!0),Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")):(console.error(e),y(!1),Error("Something went wrong."));async function A(e){E(null);try{if(!e||!c)return;await p(c,e),f(!0),y(!1),a()}catch(e){throw b(e)}}async function _(e){if("passkey"!==e)try{d(e),await u(e)}catch(e){console.error(e)}else try{d(e);let t=await u(e);if(!t)throw Error("something went wrong");v(t),await p(e,t),f(!0),y(!1),a()}catch(e){E(b(e))}}let k=()=>{d(null),E(null),h(),a()};return r&&i?"passkey"===c?/*#__PURE__*/t(my,{account:i.linkedAccounts.filter((e=>"passkey"===e.type&&e.enrolledInMfa)).sort(((e,t)=>t.firstVerifiedAt.valueOf()-e.firstVerifiedAt.valueOf()))[0],selectedMethod:c,submitSuccess:g,hasBlockingError:m,error:C,onClose:k,onBack:()=>{d(null),E(null)},handleSubmit:()=>A(w).catch(E)}):c?/*#__PURE__*/t(gy,{submitSuccess:g,hasBlockingError:m,handleSubmitCode:A,selectedMethod:c,onClose:k,onBack:i.mfaMethods.length>1?()=>d(null):void 0}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:k},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(Nl,{children:"Verify your identity"}),/*#__PURE__*/t(xl,{children:"Choose a verification method"}),/*#__PURE__*/e(Pl,{children:[i.mfaMethods.includes("totp")&&/*#__PURE__*/e(il,{onClick:()=>_("totp"),children:[/*#__PURE__*/t(lo,{}),"Authenticator App"]},"totp"),i.mfaMethods.includes("sms")&&/*#__PURE__*/e(il,{onClick:()=>_("sms"),children:[/*#__PURE__*/t(oi,{}),"SMS"]},"sms"),i.mfaMethods.includes("passkey")&&/*#__PURE__*/e(il,{onClick:()=>_("passkey"),children:[/*#__PURE__*/t(no,{}),"Passkey"]},"passkey")]}),/*#__PURE__*/t(yt,{})]}):null};let gy=({selectedMethod:r,submitSuccess:a,hasBlockingError:i,onClose:o,onBack:s,handleSubmitCode:l})=>{let{app:c}=lr(),{pendingTransaction:d}=x();switch(r){case"sms":/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:o},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oi,{})}),/*#__PURE__*/t(Nl,{children:"Enter verification code"}),/*#__PURE__*/e(Sl,{children:[/*#__PURE__*/t(Am,{success:a,disabled:i,onChange:l}),/*#__PURE__*/e(xl,{children:["To continue, please enter the 6-digit code sent to your ",/*#__PURE__*/t("strong",{children:"mobile device"})]}),d&&/*#__PURE__*/t(hy,{pendingTransaction:d})]}),s&&/*#__PURE__*/t(Hl,{theme:c?.appearance.palette.colorScheme,onClick:s,children:"Choose another method"}),/*#__PURE__*/t(dt,{onClick:o,children:"Not now"}),/*#__PURE__*/t(yt,{})]});case"totp":/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:o},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(lo,{})}),/*#__PURE__*/t(Nl,{children:"Enter verification code"}),/*#__PURE__*/e(Sl,{children:[/*#__PURE__*/t(Am,{success:a,disabled:i,onChange:l}),/*#__PURE__*/e(xl,{children:["To continue, please enter the 6-digit code generated from your"," ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),d&&/*#__PURE__*/t(hy,{pendingTransaction:d})]}),s&&/*#__PURE__*/t(Hl,{theme:c?.appearance.palette.colorScheme,onClick:s,children:"Choose another method"}),/*#__PURE__*/t(dt,{onClick:o,children:"Not now"}),/*#__PURE__*/t(yt,{})]});default:return null}};let fy=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-f0dc8bc7-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const wy=/*#__PURE__*/Ka.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-fd7f30b7-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent);stroke:var(--privy-color-accent);fill:var(--privy-color-accent);}"]);let vy=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-d3724da1-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Cy=/*#__PURE__*/Ka.div.withConfig({displayName:"Header",componentId:"sc-858d1103-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:20px 0;gap:4px;& 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;}"]);let Ey=/*#__PURE__*/Ka.div.withConfig({displayName:"Content",componentId:"sc-858d1103-1"})(["display:flex;flex-direction:column;justify-content:space-between;"]),Ty=/*#__PURE__*/Ka.div.withConfig({displayName:"ErrorMessage",componentId:"sc-858d1103-2"})(["line-height:20px;height:20px;font-size:13px;color:var(--privy-color-error);text-align:left;margin-top:0.5rem;"]),by=/*#__PURE__*/Ka(st).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-858d1103-3"})(["",""],(e=>e.hideAnimations&&/*#__PURE__*/Ya(["&&{transition:none;}"])));const Ay=n=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 21 20",...n,children:[/*#__PURE__*/t("path",{fill:"url(#icloud-gradient)",d:"M12.34 7.315a4.26 4.26 0 0 0-3.707 2.18 2.336 2.336 0 0 0-1.02-.236 2.336 2.336 0 0 0-2.3 1.963 3.217 3.217 0 0 0 1.244 6.181c.135-.001.27-.01.404-.029h8.943c.047.004.094.006.141.007.045-.001.09-.004.135-.007h.214v-.016a2.99 2.99 0 0 0 1.887-.988c.487-.55.757-1.261.757-1.998v-.006a3.017 3.017 0 0 0-.69-1.915 2.992 2.992 0 0 0-1.748-1.034 4.26 4.26 0 0 0-4.26-4.102Z"}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/e("linearGradient",{id:"icloud-gradient",x1:19.086,x2:3.333,y1:14.38,y2:14.163,gradientUnits:"userSpaceOnUse",children:[/*#__PURE__*/t("stop",{stopColor:"#3E82F4"}),/*#__PURE__*/t("stop",{offset:1,stopColor:"#93DCF7"})]})})]}),_y=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"16",height:"14",style:n,viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_2115_829)",children:[/*#__PURE__*/t("path",{d:"M2.34709 12.9404L2.3471 12.9404L2.34565 12.938L1.64031 11.7448L1.64004 11.7444L0.651257 10.0677C0.640723 10.0496 0.630746 10.0314 0.621325 10.0129H4.16461L2.39424 13.0139C2.3775 12.9901 2.36178 12.9656 2.34709 12.9404Z",fill:"#0066DA",stroke:"#6366F1"}),/*#__PURE__*/t("path",{d:"M8 4.48713L5.47995 0.215332C5.23253 0.358922 5.02176 0.556358 4.87514 0.80764L0.219931 8.70508C0.076007 8.95094 0.000191627 9.22937 0 9.51277H5.04009L8 4.48713Z",fill:"#00AC47"}),/*#__PURE__*/t("path",{d:"M13.48 13.7847C13.7274 13.6411 13.9382 13.4437 14.0848 13.1924L14.3781 12.6988L15.7801 10.3206C15.9267 10.0693 16.0001 9.79114 16.0001 9.51294H10.9596L12.0321 11.577L13.48 13.7847Z",fill:"#EA4335"}),/*#__PURE__*/t("path",{d:"M8.00003 4.48718L10.5201 0.215385C10.2726 0.0717949 9.98857 0 9.69533 0H6.30472C6.01148 0 5.7274 0.0807692 5.47998 0.215385L8.00003 4.48718Z",fill:"#00832D"}),/*#__PURE__*/t("path",{d:"M10.9599 9.51294H5.04007L2.52002 13.7847C2.76744 13.9283 3.05152 14.0001 3.34476 14.0001H12.6552C12.9484 14.0001 13.2325 13.9194 13.4799 13.7847L10.9599 9.51294Z",fill:"#2684FC"}),/*#__PURE__*/t("path",{d:"M13.4525 4.75636L11.1249 0.80764C10.9782 0.556358 10.7675 0.358922 10.52 0.215332L8 4.48713L10.9599 9.51277H15.9908C15.9908 9.23456 15.9175 8.95636 15.7709 8.70508L13.4525 4.75636Z",fill:"#FFBA00"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_2115_829",children:/*#__PURE__*/t("rect",{width:"16",height:"14",fill:"white"})})})]}),ky=/*#__PURE__*/Ka.div.withConfig({displayName:"RecoveryContainer",componentId:"sc-12b46968-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),Iy=/*#__PURE__*/Ka.div.withConfig({displayName:"RecoveryExplainerContainer",componentId:"sc-12b46968-1"})(["padding-bottom:24px;"]);let Ny={"google-drive":{name:"Google Drive",component:_y},icloud:{name:"iCloud",component:Ay}};let xy=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-6716a2fa-0"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;"]),Sy={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy"},Ry=({onClose:r})=>/*#__PURE__*/e(Iy,{children:[/*#__PURE__*/t(Ql,{title:"Why do I need to secure my account?",icon:/*#__PURE__*/t(Ja,{width:48}),description:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),/*#__PURE__*/t("p",{children:"To use this app on new devices, secure account secrets using a password, your Google or your Apple account. It’s important you don’t lose access to the method you choose."})]})}),/*#__PURE__*/t(st,{onClick:r,children:"Select backup method"})]});const Oy=/*#__PURE__*/Ka.div.withConfig({displayName:"WithCircleBorder",componentId:"sc-e4fc5563-0"})(["&&{border-width:4px;}display:flex;justify-content:center;align-items:center;padding:1rem;aspect-ratio:1;border-style:solid;border-color:",";border-radius:50%;"],(e=>e.$color??"var(--privy-color-accent)"));async function Wy({tx:e,accessToken:t,walletProxy:n,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:i,transactingWalletIndex:o}){let s=function(e,t){let n=(Uu(e)?e.message:e.compileMessage()).staticAccountKeys.find((e=>e.toBase58()===t));if(!n)throw Error(`Transaction does not contain public key ${t}`);return n}(e,i),l=Uu(e)?Buffer.from(e.message.serialize()):e.serializeMessage(),{response:c}=await n.rpc({accessToken:t,entropyId:r,entropyIdVerifier:a,chainType:"solana",hdWalletIndex:o,request:{method:"signMessage",params:{message:l.toString("base64")}}}),d=c.data.signature,u=Buffer.from(d,"base64");e.addSignature(s,u)}async function My({tx:e,connection:t,accessToken:n,walletProxy:r,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:o,transactingWalletIndex:s,transactionOptions:l}){let c;try{await Wy({tx:e,accessToken:n,walletProxy:r,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:o,transactingWalletIndex:s});let d=e.serialize();c=await t.sendRawTransaction(d,l);let u=await t.confirmTransaction(c);if(u.value.err||u.value.err){let e=u.value.err||u.value.err;if("string"==typeof e)throw Error(e);throw e}return{signature:c,signedTransaction:e,receipt:await t.getParsedTransaction(c,{maxSupportedTransactionVersion:0})}}catch(e){throw e.txSignature=c,e}}const Py=/*#__PURE__*/Ka(ju).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 Ly=({iconUrl:n,value:r,symbol:a,usdValue:i,nftName:o,$isLoading:s})=>s?/*#__PURE__*/t(Dy,{$isLoading:s}):/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(Dy,{$isLoading:s,children:[n&&/*#__PURE__*/t(Fy,{src:n,alt:"Token icon"}),o,r," ",a]}),i&&/*#__PURE__*/e(Uy,{$isLoading:s,children:["$",i]})]});let Dy=/*#__PURE__*/Ka.span.withConfig({displayName:"Value",componentId:"sc-d8e62921-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],Vt);const Uy=/*#__PURE__*/Ka.span.withConfig({displayName:"Subvalue",componentId:"sc-d8e62921-1"})(["color:var(--privy-color-foreground-2);font-size:12px;font-weight:400;line-height:18px;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],Vt);let Fy=/*#__PURE__*/Ka.img.withConfig({displayName:"TokenIcon",componentId:"sc-d8e62921-2"})(["height:14px;width:14px;margin-right:4px;object-fit:contain;"]);const By=r=>{let{chain:a,transactionDetails:i,isTokenContractInfoLoading:o,symbol:s}=r,{action:l,functionName:c}=i;/*#__PURE__*/return t($t,{children:/*#__PURE__*/e(Qt,{children:["transaction"!==l&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Action"}),/*#__PURE__*/t(qu,{children:c})]}),"mint"===c&&"args"in i&&i.args.filter((e=>e)).map(((n,r)=>/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:`Param ${r}`}),/*#__PURE__*/t(qu,{children:"string"==typeof n&&Ma(n)?/*#__PURE__*/t(lt,{address:n,url:a?.blockExplorers?.default?.url,showCopyIcon:!1}):n?.toString()})]},r))),"setApprovalForAll"===c&&i.operator&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Operator"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:i.operator,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===c&&void 0!==i.approved&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Set approval to"}),/*#__PURE__*/t(qu,{children:i.approved?"true":"false"})]}),"transfer"===c||"transferFrom"===c||"safeTransferFrom"===c||"approve"===c?/*#__PURE__*/e(n,{children:["formattedAmount"in i&&i.formattedAmount&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Amount"}),/*#__PURE__*/e(qu,{$isLoading:o,children:[i.formattedAmount," ",s]})]}),"tokenId"in i&&i.tokenId&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Token ID"}),/*#__PURE__*/t(qu,{children:i.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===c&&/*#__PURE__*/e(n,{children:["amounts"in i&&i.amounts&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Amounts"}),/*#__PURE__*/t(qu,{children:i.amounts.join(", ")})]}),"tokenIds"in i&&i.tokenIds&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Token IDs"}),/*#__PURE__*/t(qu,{children:i.tokenIds.join(", ")})]})]}),"approve"===c&&i.spender&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Spender"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:i.spender,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferFrom&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Transferring from"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:i.transferFrom,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferTo&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Transferring to"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:i.transferTo,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})};let zy={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 Hy=/*#__PURE__*/Ka.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=>zy[e.variant])),Vy=({variant:n,setPreventMaliciousTransaction:r,preventMaliciousTransaction:a})=>"warn"===n?/*#__PURE__*/t(Hy,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t($y,{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(Hy,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-col",children:[/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t($y,{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(xd,{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 $y=/*#__PURE__*/Ka(Qa).withConfig({displayName:"StyledExclamationTriangleIcon",componentId:"sc-e6305f32-0"})(["width:20px;height:20px;stroke-width:2px;flex-shrink:0;display:inline-block;margin-right:8px;",";"],(e=>"error"===e.variant?"color: var(--privy-color-error)":"color: var(--privy-color-warn)"));const jy=({transactionIndex:e,maxIndex:t})=>"number"!=typeof e||0===t?"":` (${e+1} / ${t+1})`,Gy=({img:r,submitError:a,prepareError:i,onClose:o,action:l,title:c,subtitle:d,txValue:u,to:h,tokenAddress:p,network:m,missingFunds:y,fee:g,from:f,cta:w,disabled:v,chain:C,isSubmitting:E,isPreparing:T,isTokenPriceLoading:b,isTokenContractInfoLoading:A,isSponsored:_,symbol:k,balance:I,onClick:N,transactionDetails:x,transactionIndex:S,maxIndex:R,onBack:O,chainName:W,validation:M,hasScanDetails:P,setIsScanDetailsOpen:L,preventMaliciousTransaction:D,setPreventMaliciousTransaction:U,tokensSent:F,tokensReceived:B,isScanning:z,isCancellable:H})=>{let{showTransactionDetails:V,setShowTransactionDetails:$,hasMoreDetails:j,isErc20Ish:G}=(e=>{let[t,n]=s(!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}})(x),q=G&&A||T||b||z;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:o,backFn:O}),r&&/*#__PURE__*/t(Zy,{children:r}),/*#__PURE__*/e(St,{style:{marginTop:r?"1.5rem":0},children:[c,/*#__PURE__*/t(jy,{maxIndex:R,transactionIndex:S})]}),/*#__PURE__*/t(Rt,{children:d}),/*#__PURE__*/e(Qt,{style:{marginTop:"2rem"},children:[(!!F[0]||q)&&/*#__PURE__*/e(Kt,{children:[B.length>0?/*#__PURE__*/t(ju,{children:"Send"}):/*#__PURE__*/t(ju,{children:"Amount"}),/*#__PURE__*/t(Ly,{iconUrl:F[0]?.iconUrl,value:F[0]?.value,usdValue:F[0]?.usdValue,symbol:F[0]?.symbol,nftName:F[0]?.nftName,$isLoading:q})]}),B.length>0&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Receive"}),/*#__PURE__*/t("div",{className:"flex flex-col",children:B.map(((e,n)=>/*#__PURE__*/t(Ly,{iconUrl:e.iconUrl,value:e.value,usdValue:e.usdValue,symbol:e.symbol,nftName:e.nftName},n)))})]}),x&&"spender"in x&&x?.spender?/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Spender"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:x.spender,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}):null,h&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"To"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:h,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),p&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Token address"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:p,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Network"}),/*#__PURE__*/t(qu,{children:m})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Estimated fee"}),/*#__PURE__*/t(qu,{$isLoading:T||b||void 0===_,children:_?"Sponsored":g})]}),j&&!P&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Kt,{className:"cursor-pointer",onClick:()=>$(!V),children:/*#__PURE__*/e(Gu,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/t(fo,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:V?"rotate(180deg)":void 0}})]})}),V&&x&&/*#__PURE__*/t(By,{action:l,chain:C,transactionDetails:x,isTokenContractInfoLoading:A,symbol:k})]}),P&&/*#__PURE__*/t(Kt,{children:/*#__PURE__*/e(Py,{onClick:()=>L(!0),children:[/*#__PURE__*/t("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/t(wo,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/t(Xs,{}),a?/*#__PURE__*/t(Zt,{style:{marginTop:"2rem"},children:a.message}):i?/*#__PURE__*/t(Zt,{style:{marginTop:"2rem"},children:i.shortMessage??Yy}):null,/*#__PURE__*/t(Vy,{variant:M,preventMaliciousTransaction:D,setPreventMaliciousTransaction:U}),/*#__PURE__*/t(Ky,{$useSmallMargins:!(!i&&!a&&"warn"!==M&&"error"!==M),title:Number(u)>0?void 0:!1!==_?"Your wallet":void 0,address:f,balance:I,isLoading:T||b,errMsg:T||i||a||!y?void 0:`Add funds on ${C?.name??W} to complete transaction.`}),/*#__PURE__*/t(st,{style:{marginTop:"1rem"},loading:E,disabled:v||T,onClick:N,children:w}),H&&/*#__PURE__*/t(mn,{style:{marginTop:"1rem"},onClick:o,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(ct,{})]})},qy=({img:r,title:a,subtitle:i,cta:o,network:s,blockExplorerUrl:l,transactionIndex:c,maxIndex:d,isMissingFunds:u,submitError:h,parseError:p,total:m,amount:y,fee:g,balance:f,from:w,to:v,tokenAddress:C,tokenAccount:E,tokenAccountOwner:T,programAddress:b,transactingWalletAddress:A,disabled:_,isSubmitting:k,isPreparing:I,isTokenPriceLoading:N,onClick:x,onClose:S,onBack:R})=>{let O=I||N;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:S,backFn:R}),r&&/*#__PURE__*/t(Zy,{children:r}),/*#__PURE__*/e(St,{style:{marginTop:r?"1.5rem":0},children:[a,/*#__PURE__*/t(jy,{maxIndex:d,transactionIndex:c})]}),/*#__PURE__*/t(Rt,{children:i}),/*#__PURE__*/e(Qt,{style:{marginTop:"2rem"},children:[(m||O)&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Total"}),/*#__PURE__*/t(qu,{$isLoading:O,children:m})]}),w&&w!==A&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"From"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:w,url:l,showCopyIcon:!1})})]}),v&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"To"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:v,url:l,showCopyIcon:!1})})]}),T&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Token account owner"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:T,url:l,showCopyIcon:!1})})]}),E&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Token account"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:E,url:l,showCopyIcon:!1})})]}),C&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Token address"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:C,url:l,showCopyIcon:!1})})]}),b&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Program address"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(lt,{address:b,url:l,showCopyIcon:!1})})]}),s&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Network"}),/*#__PURE__*/t(qu,{children:s})]}),(y||O)&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Amount"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(qu,{$isLoading:O,children:y})})]}),(g||O)&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Estimated fee"}),/*#__PURE__*/t(qu,{$isLoading:O,children:g})]})]}),/*#__PURE__*/t(Xs,{}),h?/*#__PURE__*/t(Zt,{style:{marginTop:"2rem"},children:h.message}):p?/*#__PURE__*/t(Zt,{style:{marginTop:"2rem"},children:Yy}):null,/*#__PURE__*/t(Ky,{$useSmallMargins:!(!p&&!h),title:"Your wallet",address:A,balance:f,isLoading:I||N,errMsg:I||p||h||!u?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/t(st,{style:{marginTop:"1rem"},loading:k,disabled:_||I,onClick:x,children:o}),/*#__PURE__*/t(ct,{})]})};let Ky=/*#__PURE__*/Ka(Nt).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-4bd3bb7d-0"})(["",""],(e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;")),Yy="There was an error preparing your transaction. Your transaction request will likely fail.",Zy=/*#__PURE__*/Ka.div.withConfig({displayName:"ImageContainer",componentId:"sc-4bd3bb7d-1"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),Jy=()=>/*#__PURE__*/e(ng,{children:[/*#__PURE__*/t(ag,{}),/*#__PURE__*/t(rg,{})]});const Qy=({transactionError:r,chainId:a,onClose:i,onRetry:o,network:l,connection:c,transactionHash:d})=>{let{chains:u}=x(),[h,p]=s(!1),{errorCode:m,errorMessage:y}=((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),g=(({chains:e,chainId:t,network:n,connection:r,transactionHash:a})=>"ethereum"===n?e.find((e=>e.id===t))?.blockExplorers?.default.url??"https://etherscan.io":Pr(a||"",Er(r?.rpcEndpoint||"")))({chains:u,chainId:a,network:l,connection:c,transactionHash:d});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:i}),/*#__PURE__*/e(Xy,{children:[/*#__PURE__*/t(Jy,{}),/*#__PURE__*/t(eg,{children:m}),/*#__PURE__*/t(tg,{children:"Please try again."}),/*#__PURE__*/e(sg,{children:[/*#__PURE__*/t(og,{children:"Error message"}),/*#__PURE__*/t(cg,{$clickable:!1,children:y})]}),d&&/*#__PURE__*/e(sg,{children:[/*#__PURE__*/t(og,{children:"Transaction hash"}),/*#__PURE__*/e(lg,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/t("u",{children:/*#__PURE__*/t("a",{href:g,children:"block explorer"})}),"."]}),/*#__PURE__*/e(cg,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(d),p(!0)},children:[d,/*#__PURE__*/t(hg,{clicked:h})]})]}),/*#__PURE__*/t(ig,{onClick:()=>o({resetNonce:!!d}),children:"Retry transaction"})]}),/*#__PURE__*/t(yt,{})]})};let Xy=/*#__PURE__*/Ka.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-6e9001c5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),eg=/*#__PURE__*/Ka.span.withConfig({displayName:"ErrorCode",componentId:"sc-6e9001c5-1"})(["color:var(--privy-color-foreground);text-align:center;font-size:1.125rem;font-weight:500;line-height:1.25rem;text-align:center;margin:10px;"]),tg=/*#__PURE__*/Ka.span.withConfig({displayName:"Subtitle",componentId:"sc-6e9001c5-2"})(["margin-top:4px;margin-bottom:10px;color:var(--privy-color-foreground-3);text-align:center;font-size:0.875rem;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;"]),ng=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleContainer",componentId:"sc-6e9001c5-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),rg=/*#__PURE__*/Ka(ei).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-6e9001c5-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),ag=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-6e9001c5-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),ig=/*#__PURE__*/Ka(st).withConfig({displayName:"RetryButton",componentId:"sc-6e9001c5-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),og=/*#__PURE__*/Ka.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-6e9001c5-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),sg=/*#__PURE__*/Ka.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-6e9001c5-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),lg=/*#__PURE__*/Ka.text.withConfig({displayName:"HelperText",componentId:"sc-6e9001c5-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),cg=/*#__PURE__*/Ka.span.withConfig({displayName:"TextBox",componentId:"sc-6e9001c5-10"})(["position:relative;width:100%;background-color:var(--privy-color-background-2);padding:8px 12px;border-radius:10px;margin-top:5px;font-size:14px;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;",""],(e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }")),dg=/*#__PURE__*/Ka(vo).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-6e9001c5-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),ug=/*#__PURE__*/Ka(Ci).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-6e9001c5-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),hg=({clicked:e})=>/*#__PURE__*/t(e?ug:dg,{});const pg=({instructions:r,fees:a,transactionInfo:i,solPrice:o,rpcEndpoint:l})=>{let c=r.reduce(((e,{amount:t,token:n})=>t&&"SOL"===n?.symbol?e+t:e),0n),[d,u]=s(0),[h,p]=s(!1),m=r[d];/*#__PURE__*/return e(Qt,{children:[/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Total"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(Pm,{quantities:[c,a],tokenPrice:o})})]}),i&&i.action&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Action"}),/*#__PURE__*/t(qu,{children:i.action})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Fees"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(Pm,{quantities:[a||0n],tokenPrice:o})})]}),r.length>1?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Kt,{children:/*#__PURE__*/e(Py,{onClick:()=>p((e=>!e)),children:[/*#__PURE__*/t("span",{children:"Details"}),/*#__PURE__*/t(Zi,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:h?"rotate(180deg)":void 0}})]})}),h&&/*#__PURE__*/t(Kt,{children:/*#__PURE__*/e(yg,{children:[/*#__PURE__*/e(gg,{children:[/*#__PURE__*/e(fg,{children:[d+1," of ",r.length," instructions"]}),/*#__PURE__*/e(vg,{children:[d>0&&/*#__PURE__*/t(Cn,{backFn:()=>u((e=>e-1))}),d<r.length-1&&/*#__PURE__*/t(En,{nextFn:()=>u((e=>e+1))})]})]}),/*#__PURE__*/t(wg,{children:/*#__PURE__*/t(mg,{instruction:m,rpcEndpoint:l,solPrice:o})})]})})]}):/*#__PURE__*/t(mg,{instruction:m,rpcEndpoint:l,solPrice:o,hideAmount:!0})]})};function mg({instruction:n,rpcEndpoint:r,solPrice:a,hideAmount:i}){return n?/*#__PURE__*/e(Qt,{children:[!i&&!!n.amount&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Amount"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(Pm,{quantities:[n.amount],tokenPrice:a,tokenSymbol:n.token?.symbol??"SOL",tokenDecimals:n.token?.decimals??9})})]}),n.to&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"To"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(oy,{walletAddress:n.to,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccount&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Token account"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(oy,{walletAddress:n.tokenAccount,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccountOwner&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"Token account owner"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(oy,{walletAddress:n.tokenAccountOwner,rpcEndpoint:r,network:"solana"})})]}),n.from&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(ju,{children:"From"}),/*#__PURE__*/t(qu,{children:/*#__PURE__*/t(oy,{walletAddress:n.from,rpcEndpoint:r,network:"solana"})})]})]}):null}let yg=/*#__PURE__*/Ka.div.withConfig({displayName:"InstructionsBox",componentId:"sc-5a140027-0"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),gg=/*#__PURE__*/Ka.header.withConfig({displayName:"InstructionsBoxHeader",componentId:"sc-5a140027-1"})(["display:flex;justify-content:space-between;align-items:center;padding:12px;background-color:var(--privy-color-background-2);"]),fg=/*#__PURE__*/Ka.h4.withConfig({displayName:"HeaderTitle",componentId:"sc-5a140027-2"})(["font-size:14px;font-weight:500;line-height:19.6px;"]),wg=/*#__PURE__*/Ka.div.withConfig({displayName:"InstructionsBoxContent",componentId:"sc-5a140027-3"})(["padding:12px;"]),vg=/*#__PURE__*/Ka.div.withConfig({displayName:"NavigationButtonsConatiner",componentId:"sc-5a140027-4"})(["display:flex;gap:8px;align-items:center;"]);const Cg=({instructions:r,fees:a,onClose:i,receiptHeader:o,receiptDescription:s,transactionInfo:l,solPrice:c,rpcEndpoint:d,signOnly:u})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:i}),/*#__PURE__*/t(Qs,{style:{marginBottom:"16px"},children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Js,{color:"var(--privy-color-success-light)"}),/*#__PURE__*/t(ci,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),/*#__PURE__*/t(Ql,{title:o??`Transaction ${u?"signed":"complete"}!`,description:s??"You're all set."}),/*#__PURE__*/t(pg,{solPrice:c,instructions:r,fees:a,transactionInfo:l,rpcEndpoint:d}),/*#__PURE__*/t(Xs,{}),/*#__PURE__*/t(Eg,{loading:!1,onClick:i,children:"Close"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let Eg=/*#__PURE__*/Ka(st).withConfig({displayName:"SubmitButton",componentId:"sc-6f95cdcf-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);async function Tg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,publicClient:o,requesterAppId:s}){let l=await bg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,requesterAppId:s});return await o.sendRawTransaction({serializedTransaction:l})}async function bg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,requesterAppId:o}){return(await a.rpc({entropyId:t,entropyIdVerifier:n,hdWalletIndex:r.walletIndex??0,chainType:"ethereum",accessToken:e,requesterAppId:o,request:{method:"eth_signTransaction",params:[i]}})).response.data}let Ag=({data:n})=>{let r=n=>"object"==typeof n&&null!==n?/*#__PURE__*/t(kg,{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 _g=/*#__PURE__*/Ka.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 kg=/*#__PURE__*/Ka.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 Ig=({data:e})=>/*#__PURE__*/t(_g,{children:/*#__PURE__*/t(Ag,{data:e})});let Ng=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-b3a607dd-0"})(["display:flex;flex-direction:column;min-height:72px;"]);var xg=({onBack:n,details:r})=>/*#__PURE__*/e(Ng,{children:[/*#__PURE__*/t(ot,{backFn:n}),/*#__PURE__*/t(Ig,{data:r}),/*#__PURE__*/t(ct,{})]});let Sg=({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return _a(e*t)}catch(e){return}};const Rg=({txn:r,receipt:a,transactionInfo:i,onClose:o,tokenPrice:s,tokenSymbol:l,receiptHeader:c,receiptDescription:d})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:o}),/*#__PURE__*/t(Zl,{title:c??"Transaction complete!",description:d??"You're all set."}),/*#__PURE__*/t(ly,{tokenPrice:s,from:a.from,to:a.to,gas:Sg(a),txn:r,transactionInfo:i,tokenSymbol:l}),/*#__PURE__*/t(Xs,{}),/*#__PURE__*/t(Og,{loading:!1,onClick:o,children:"All Done"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let Og=/*#__PURE__*/Ka(st).withConfig({displayName:"SubmitButton",componentId:"sc-f857236b-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const Wg=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Mg=[{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"}]}],Pg=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Lg=[{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"}],Dg=[{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"}],Ug=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Fg=[{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"}],Bg=[{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"}],zg=[{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"}],Hg=(e,t)=>{let n=Vg(Pg,e);if(n)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:n.args[0],amount:n.args[1]};let r=Vg(Uh,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=Vg(Wg,e);if(a&&"string"==typeof a.args[1]){let e=$g(a.args[1]);if(e&&e[4].encodedInitData)return Hg(e[4].encodedInitData,t)}let i=Vg(Ug,e);if(i)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:i.args[0],approved:i.args[1]};let o=Vg(Fg,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=Vg(Dg,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=Vg(zg,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=Vg(Bg,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=Vg(Lg,e);return d?{action:"mint",functionName:d.functionName,isNFTIsh:!0,isErc20Ish:!1,args:d.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}};let Vg=(e,t)=>{try{let n=Pa({abi:e,data:t});return{functionName:n.functionName,args:n.args||[]}}catch(e){return null}},$g=e=>{try{if("string"==typeof e)return La(Mg,`0x${e.slice(10)}`)}catch(e){return null}};const jg=(e,t,n)=>{let[r,a]=s(null),{getAccessToken:i}=ur(),{walletProxy:l}=x();return o((()=>{r&&a(null),(async()=>{if(!await i()||!l||!t)return null;let r=[],a=!0,o=await uy(e,n,t.address).catch((t=>(t.details.includes("insufficient funds")?a=!1:r.push(t),e)));return{tx:o,totalGasEstimate:o.gas,hasFunds:a,errors:r}})().then(a)}),[e]),r};let Gg=new ca(new da("There was an issue preparing your transaction",zi.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),qg=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0;const Kg=/*#__PURE__*/Ka.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 Yg=e=>{if(!Aa(e))return e;try{return Ua(e)}catch{return e}},Zg=e=>JSON.stringify(e,null,2),Jg=r=>{let{types:a,primaryType:i,...o}=r.typedData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ig,{data:o}),/*#__PURE__*/t(mu,{text:Zg(r.typedData),itemName:"full payload to clipboard"})," "]})};let Qg=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-84af275e-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)")),Xg=/*#__PURE__*/Ka.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-84af275e-1"})(["display:flex;align-items:center;gap:8px;"]),ef=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-84af275e-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),tf=/*#__PURE__*/Ka.div.withConfig({displayName:"Grow",componentId:"sc-84af275e-3"})(["flex-grow:1;"]);let nf=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-a512957a-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const rf=/*#__PURE__*/u(((r,a)=>{let[i,o]=s(""),[l,c]=s(""),[d,u]=s(!1),{authenticated:h,user:p}=ur(),{initUpdateEmail:m}=x(),{navigate:y,setModalData:g,currentScreen:f}=lr(),{enabled:w,token:v}=it(),C=dr(),E=pn(i)&&(C.disablePlusEmails&&i.includes("+")?(l||c("Please enter a valid email address without a '+'."),!1):(l&&c(""),!0)),T=d||!E,b=()=>{!w||v||h?(async e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");u(!0);try{await m(p.email.address,i,e),y(cr.AWAITING_PASSWORDLESS_CODE)}catch(e){g({errorModalData:{error:e,previousScreen:f||cr.LANDING}})}u(!1)})(v):(g({captchaModalData:{callback:e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");return m(p.email.address,i,e)},userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:cr.ERROR_SCREEN}}),y(cr.CAPTCHA_SCREEN))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(af,{children:[l&&/*#__PURE__*/t(Zt,{style:{marginTop:"0.25rem",textAlign:"left"},children:l}),/*#__PURE__*/e(of,{$error:!!l,children:[/*#__PURE__*/t(ii,{}),/*#__PURE__*/t("input",{ref:a,id:"email-input",type:"email",placeholder:"your@email.com",onChange:e=>o(e.target.value),onKeyUp:e=>{"Enter"===e.key&&b()},value:i,autoComplete:"email"}),r.stacked?null:/*#__PURE__*/t(mn,{isSubmitting:d,onClick:b,disabled:T,children:"Submit"})]})]}),r.stacked?/*#__PURE__*/t(st,{loadingText:null,loading:d,disabled:T,onClick:b,children:"Submit"}):null]})}));let af=yn,of=bn;const sf=({style:e,...n})=>/*#__PURE__*/t("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"38px",width:"38px",...e},...n,children:/*#__PURE__*/t("path",{d:"M20 13.6V20M20 26.4H20.016M36 20C36 28.8365 28.8366 36 20 36C11.1635 36 4.00001 28.8365 4.00001 20C4.00001 11.1634 11.1635 3.99999 20 3.99999C28.8366 3.99999 36 11.1634 36 20Z",stroke:"currentColor",strokeWidth:"3.2",strokeLinecap:"round",strokeLinejoin:"round"})});let lf=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-fc448c87-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-top:8px;padding-bottom:32px;"]),cf=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-fc448c87-1"})(["display:flex;align-items:center;justify-content:center;height:72px;aspect-ratio:1;color:var(--privy-color-error);background-color:var(--privy-color-error-light);border-radius:50%;"]),df=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-fc448c87-2"})(["display:flex;flex-direction:column;gap:8px;"]);const uf=/*#__PURE__*/Za([":root{--privy-border-radius-sm:6px;--privy-border-radius-md:12px;--privy-border-radius-mdlg:16px;--privy-border-radius-lg:24px;--privy-border-radius-full:9999px;--privy-color-background:",";--privy-color-background-2:",";--privy-color-background-3:",";--privy-color-foreground:",";--privy-color-foreground-2:",";--privy-color-foreground-3:",";--privy-color-foreground-4:",";--privy-color-foreground-accent:",";--privy-color-accent:",";--privy-color-accent-light:",";--privy-color-accent-lightest:",";--privy-color-accent-dark:",";--privy-color-accent-darkest:",";--privy-color-success:",";--privy-color-success-dark:",";--privy-color-success-light:",";--privy-color-error:",";--privy-color-error-light:",";--privy-color-warn:",";--privy-color-warn-light:",";--privy-height-modal-full:620px;--privy-height-modal-compact:480px;};"],(e=>e.theme.background),(e=>e.theme.background2),(e=>e.theme.background3),(e=>e.theme.foreground),(e=>e.theme.foreground2),(e=>e.theme.foreground3),(e=>e.theme.foreground4),(e=>e.theme.foregroundAccent),(e=>e.theme.accent),(e=>e.theme.accentLight),(e=>e.theme.accentLightest),(e=>e.theme.accentDark),(e=>e.theme.accentDarkest),(e=>e.theme.success),(e=>e.theme.successDark),(e=>e.theme.successLight),(e=>e.theme.error),(e=>e.theme.errorLight),(e=>e.theme.warn),(e=>e.theme.warnLight)),hf=/*#__PURE__*/Ka.div.withConfig({displayName:"StylesWrapper",componentId:"sc-bc1e45b4-0"})([""," color:var(--privy-color-foreground-2);h3{font-size:16px;line-height:24px;font-weight:500;color:var(--privy-color-foreground-2);}h4{font-size:14px;line-height:20px;font-weight:500;color:var(--privy-color-foreground);}p{font-size:13px;line-height:20px;color:var(--privy-color-foreground-2);}button:focus,input:focus,optgroup:focus,select:focus,textarea:focus{outline:none;border-color:var(--privy-color-accent-light);box-shadow:0 0 0 1px var(--privy-color-accent-light);}.mobile-only{@media (min-width:441px){display:none;}}@keyframes fadein{0%{opacity:0;}100%{opacity:1;}}"],"\n *,\n ::before,\n ::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n }\n\n line-height: 1.15;\n -webkit-text-size-adjust: 100%;\n -moz-tab-size: 4;\n tab-size: 4;\n font-feature-settings: normal;\n\n margin: 0;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n display: inline;\n }\n\n a {\n color: inherit;\n text-decoration: inherit;\n }\n\n b,\n strong {\n font-weight: bolder;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n font-family: inherit;\n font-size: 100%;\n font-weight: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n }\n\n button,\n select {\n text-transform: none;\n }\n\n button,\n [type='button'],\n [type='reset'],\n [type='submit'] {\n -webkit-appearance: button;\n background-color: transparent;\n background-image: none;\n }\n\n ::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n :-moz-focusring {\n outline: 1px dotted ButtonText;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n legend {\n padding: 0;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [type='search'] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n }\n\n summary {\n display: list-item;\n }\n\n blockquote,\n dl,\n dd,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n hr,\n figure,\n p,\n pre {\n margin: 0;\n }\n\n fieldset {\n margin: 0;\n padding: 0;\n }\n\n legend {\n padding: 0;\n }\n\n ol,\n ul,\n menu {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n textarea {\n resize: vertical;\n }\n\n input::placeholder,\n textarea::placeholder {\n opacity: 1;\n color: #9ca3af;\n }\n\n button,\n [role='button'] {\n cursor: pointer;\n }\n\n :disabled {\n cursor: default;\n }\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n }\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n [hidden] {\n display: none;\n }\n"),pf=({children:n,open:r,onClick:i,...o})=>/*#__PURE__*/t(Gi,{show:r,as:a.Fragment,children:/*#__PURE__*/e(qi,{onClose:i,...o,as:yf,children:[/*#__PURE__*/t(Ki,{as:a.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/t(mf,{id:"privy-dialog-backdrop","aria-hidden":"true"})}),/*#__PURE__*/t(gf,{children:/*#__PURE__*/t(Ki,{as:a.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/t(Yi,{as:ff,children:n})})})]})});let mf=/*#__PURE__*/Ka.div.withConfig({displayName:"Backdrop",componentId:"sc-3cfde0b5-0"})(["position:fixed;inset:0;transition:backdrop-filter 100ms ease;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);&.entering,&.leaving{backdrop-filter:unset;-webkit-backdrop-filter:unset;}"]),yf=/*#__PURE__*/Ka.div.withConfig({displayName:"DialogWrapper",componentId:"sc-3cfde0b5-1"})(["position:relative;z-index:999999;"]),gf=/*#__PURE__*/Ka.div.withConfig({displayName:"DialogContainer",componentId:"sc-3cfde0b5-2"})(["position:fixed;inset:0;display:flex;align-items:center;justify-content:center;width:100vw;min-height:100vh;"]);const ff=/*#__PURE__*/Ka.div.withConfig({displayName:"Panel",componentId:"sc-3cfde0b5-3"})(["padding:0;background:transparent;border:none;width:100%;pointer-events:auto;outline:none;display:block;@media (max-width:440px){opacity:1;transform:translate3d(0,0,0);transition:transform 200ms ease-in;position:fixed;bottom:0;&.entering,&.leaving{opacity:0;transform:translate3d(0,100%,0);transition:transform 150ms ease-in 0ms,opacity 0ms ease 150ms;}}@media (min-width:441px){opacity:1;transition:opacity 100ms ease-in;&.entering,&.leaving{opacity:0;transition-delay:5ms;}margin:auto;width:360px;box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]),wf=/*#__PURE__*/Ka.div.withConfig({displayName:"CenterItem",componentId:"sc-3cfde0b5-4"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;"]);let vf={[cr.LANDING]:()=>{let{app:e}=lr();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/t(em,{connectOnly:!1}):/*#__PURE__*/t(Kp,{connectOnly:!1})},[cr.CONNECT_OR_CREATE]:()=>{let{app:e}=lr();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/t(em,{connectOnly:!0}):/*#__PURE__*/t(Kp,{connectOnly:!0})},[cr.AWAITING_PASSWORDLESS_CODE]:()=>{let{app:r,navigate:a,lastScreen:i,navigateBack:l,setModalData:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),{closePrivyModal:u,resendEmailCode:h,resendSmsCode:p,getAuthMeta:m,loginWithCode:g,updateWallets:f,createAnalyticsEvent:w}=x(),{authenticated:v,logout:C,user:E}=ur(),[T,b]=s(tc),[_,k]=s(!1),[I,R]=s(null),[O,W]=s(null),[M,P]=s(0);d.current=()=>null;let L=m()?.email?0:1,D=hr-500;o((()=>{if(M){let e=setTimeout((()=>{P(M-1)}),1e3);return()=>clearTimeout(e)}}),[M]),o((()=>{if(v&&_&&E){if(r?.legal.requireUsersAcceptTerms&&!E.hasAcceptedTerms){let e=setTimeout((()=>{a(cr.AFFIRMATIVE_CONSENT_SCREEN)}),D);return()=>clearTimeout(e)}if(ut(E,r.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),w({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AwaitingPasswordlessCodeScreen"}}),C()},callAuthOnSuccessOnClose:!0}}),a(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),D);return()=>clearTimeout(e)}{f();let e=setTimeout((()=>u({shouldCallAuthOnSuccess:!0,isSuccess:!0})),hr);return()=>clearTimeout(e)}}}),[v,_,E]),o((()=>{if(I&&0===O){let e=setTimeout((()=>{b(tc),R(null);let e=document.querySelector("input[name=code-0]");e?.focus()}),1400);return()=>clearTimeout(e)}}),[I]);let U=e=>{e.preventDefault();let t=e.currentTarget.value.replace(" ","");if(""===t)return;if(isNaN(Number(t)))return R("Code should be numeric"),void W(1);R(null),W(null);let n=Number(e.currentTarget.name?.charAt(5)),r=[...t||[""]].slice(0,6-n),o=[...T.slice(0,n),...r,...T.slice(n+r.length)];b(o);let s=Math.min(Math.max(n+r.length,0),5);if(!isNaN(Number(e.currentTarget.value))){let e=document.querySelector(`input[name=code-${s}]`);e?.focus()}if(o.every((e=>e&&!isNaN(+e)))){let e=document.querySelector(`input[name=code-${s}]`);e?.blur(),g(o.join("")).then((()=>k(!0))).catch((e=>{if(e instanceof N&&e.privyErrorCode===A.INVALID_CREDENTIALS)R("Invalid or expired verification code");else if(e instanceof N&&e.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE)R(e.message);else{if(e instanceof N&&e.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),void a(cr.USER_LIMIT_REACHED_SCREEN);if(e instanceof N&&e.privyErrorCode===A.USER_DOES_NOT_EXIST)return void a(cr.ACCOUNT_NOT_FOUND_SCREEN);if(e instanceof N&&e.privyErrorCode===A.LINKED_TO_ANOTHER_USER)return c({errorModalData:{error:e,previousScreen:i??cr.AWAITING_PASSWORDLESS_CODE}}),void a(cr.ERROR_SCREEN,!1);if(e instanceof N&&e.privyErrorCode===A.DISALLOWED_PLUS_EMAIL)return c({inlineError:{error:e}}),void a(cr.CONNECT_OR_CREATE,!1);if(e instanceof N&&e.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return c({accountTransfer:{nonce:e.data?.data?.nonce,account:0===L?m()?.email:m()?.phoneNumber,displayName:e.data?.data?.account?.displayName,linkMethod:0===L?"email":"sms",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void a(cr.LINK_CONFLICT_SCREEN);R("Issue verifying code")}W(0)}))}},F=0==L?/*#__PURE__*/t(ii,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"}):
12
- /*#__PURE__*/t(oi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),B=/*#__PURE__*/e("p",0==L?{children:["Please check ",/*#__PURE__*/t(pc,{children:m()?.email})," for an email from privy.io and enter your code below."]}:{children:["Please check ",/*#__PURE__*/t(pc,{children:m()?.phoneNumber})," for a message from ",r?.name||"Privy"," and enter your code below."]});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:()=>l()},"header"),/*#__PURE__*/e(sc,{children:[/*#__PURE__*/t(Ql,{title:"Enter confirmation code",description:B,icon:F}),/*#__PURE__*/e(ht,{children:[/*#__PURE__*/e(lc,{children:[/*#__PURE__*/t(cc,{$fail:!!I,$success:_,children:/*#__PURE__*/t("span",{children:I||(_?"Success!":"")})}),/*#__PURE__*/t("div",{children:T.map(((e,n)=>/*#__PURE__*/t("input",{name:`code-${n}`,type:"text",value:T[n],onChange:U,onKeyUp:e=>{"Backspace"===e.key&&(e=>{if(1===O&&(R(null),W(null)),b([...T.slice(0,e),"",...T.slice(e+1)]),e>0){let t=document.querySelector(`input[name=code-${e-1}]`);t?.focus()}})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:`${_?"success":""} ${I?"fail":""}`,autoComplete:y?"one-time-code":"off"},n)))})]}),/*#__PURE__*/e(dc,{children:[/*#__PURE__*/e("span",{children:["Didn't get ",0==L?"an email":"a message","?"]}),M?/*#__PURE__*/e(hc,{children:[/*#__PURE__*/t(ai,{color:"var(--privy-color-foreground)",strokeWidth:1.33,height:"12px",width:"12px"}),/*#__PURE__*/t("span",{children:"Code sent"})]}):/*#__PURE__*/t(uc,{children:/*#__PURE__*/t("button",{onClick:async()=>{P(30),0==L?await h():await p()},children:"Resend code"})})]})]})]}),/*#__PURE__*/t(ct,{})]})},[cr.AWAITING_CONNECTION]:_n,[cr.AWAITING_CONNECT_ONLY_CONNECTION]:()=>{let r,{navigateBack:a,navigate:i,lastScreen:l,currentScreen:c,data:d,setModalData:u}=lr(),{walletConnectionStatus:h,closePrivyModal:p}=x(),[m,g]=s(void 0),[f,w]=s(0),v=ft(h?.connector?.walletClientType||"unknown"),C="connected"===h?.status,E="switching_to_supported_chain"===h?.status;o((()=>{if(C){let e;if(d?.externalConnectWallet?.onCompleteNavigateTo){let t=d.externalConnectWallet.onCompleteNavigateTo,n=h.connectedWallet?.address;e=setTimeout((()=>{d.funding&&u({...d,funding:{...d.funding,connectedWalletAddress:n}}),i(t({walletChainType:h.connector?.chainType}))}),hr)}else e=setTimeout(p,hr);return()=>clearTimeout(e)}}),[C]);o((()=>{h?.connectError&&(e=>{g(bt(e))})(h?.connectError)}),[h]);let T=h?.connector?.connectorType||"injected",b=h?.connector?.walletClientType||"unknown",A=v?.metadata?.shortName||v?.name||h?.connector?.walletBranding.name||"Browser Extension",_=v?.image_url?.md||h?.connector?.walletBranding.icon||(e=>/*#__PURE__*/t(Xe,{...e})),k="Browser Extension"===A?A.toLowerCase():A;r=C?`Successfully connected with ${k}`:m?m.message:E?"Switching networks":`Waiting for ${k}`;let I="Don’t see your wallet? Check your other browser windows.";return C?I="You’re good to go!":f>=2&&m?I="Unable to connect wallet":m?I=m.detail:E?I="Switch your wallet to the requested network.":"metamask"===b&&y?I="Click to continue to open and connect MetaMask.":"metamask"===b?I="For the best experience, connect only one wallet at a time.":"wallet_connect_v2"===T?I="Open your mobile wallet app to continue":"coinbase_wallet"===T&&(I="Open the Coinbase app on your phone to continue."),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{backFn:c===l?void 0:a}),/*#__PURE__*/e(Sc,{children:[/*#__PURE__*/t(Tt,{walletLogo:_,success:C,fail:!!m}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:r}),/*#__PURE__*/t("p",{children:I})]}),m==na.ERROR_USER_EXISTS?/*#__PURE__*/t(st,{onClick:a,children:"Use a different wallet"}):!C&&m?.retryable&&f<2?/*#__PURE__*/t(st,{onClick:()=>{w(f+1),g(void 0),h?.connectRetry()},disabled:!C&&(!m?.retryable||f>=2),children:"Retry"}):!C&&m&&f>=2?/*#__PURE__*/t(st,{onClick:a,children:"Use a different wallet"}):null]}),/*#__PURE__*/t(yt,{})]})},[cr.AWAITING_FARCASTER_CONNECTION]:()=>{let{authenticated:r,logout:a,ready:i,user:c}=ur(),{lastScreen:d,navigate:u,navigateBack:h,setModalData:p,app:m}=lr(),{getAuthFlow:g,loginWithFarcaster:w,closePrivyModal:v,createAnalyticsEvent:C}=x(),[E,T]=s(void 0),[b,_]=s(!1),[k,I]=s(!1),N=l([]),R=g(),O=R?.meta.connectUri;return o((()=>{let e=Date.now(),t=setInterval((async()=>{let n=await R.pollForReady.execute(),r=Date.now()-e;if(n){clearInterval(t),_(!0);try{await w(),I(!0)}catch(e){let t={retryable:!1,message:"Authentication failed"};if(e?.privyErrorCode===A.ALLOWLIST_REJECTED)return void u(cr.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),void u(cr.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===A.USER_DOES_NOT_EXIST)return void u(cr.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===A.LINKED_TO_ANOTHER_USER)t.detail=e.message??"This account has already been linked to another user.";else{if(e?.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return p({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:"farcaster",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,farcasterEmbeddedAddress:e.data?.data?.otherUser?.farcasterEmbeddedAddress}}),void u(cr.LINK_CONFLICT_SCREEN);e?.privyErrorCode===A.INVALID_CREDENTIALS?(t.retryable=!0,t.detail="Something went wrong. Try again."):e?.privyErrorCode===A.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again.")}T(t)}}else r>12e4&&(clearInterval(t),T({retryable:!0,message:"Authentication failed",detail:"The request timed out. Try again."}))}),2e3);return()=>{clearInterval(t),N.current.forEach((e=>clearTimeout(e)))}}),[]),o((()=>{if(i&&r&&k&&c){if(m?.legal.requireUsersAcceptTerms&&!c.hasAcceptedTerms){let e=setTimeout((()=>{u(cr.AFFIRMATIVE_CONSENT_SCREEN)}),hr);return()=>clearTimeout(e)}k&&(ut(c,m.embeddedWallets)?N.current.push(setTimeout((()=>{p({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),C({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"FarcasterConnectStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),u(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),hr)):N.current.push(setTimeout((()=>v({shouldCallAuthOnSuccess:!0,isSuccess:!0})),hr)))}}),[k,i,r,c]),/*#__PURE__*/e(n,y||b?{children:[/*#__PURE__*/t(ot,{backFn:d?h:void 0,onClose:v},"header"),/*#__PURE__*/t(_t,{}),
13
- /*#__PURE__*/t(n,f?{children:/*#__PURE__*/e(Eu,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:k,fail:!!E}),/*#__PURE__*/t(wu,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t(Nl,{children:E?E.message:"Sign in with Farcaster"}),/*#__PURE__*/t(xl,{children:E?E.detail:"To sign in with Farcaster, please open the Warpcast app."})]}),O&&/*#__PURE__*/t(st,{onClick:e=>{e.preventDefault(),window.location.href=O},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(Cu,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:k,fail:!!E}),/*#__PURE__*/t(wu,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t(Nl,{children:E?E.message:"Signing in with Farcaster"}),/*#__PURE__*/t(xl,{children:E?E.detail:"This should only take a moment"}),/*#__PURE__*/t(Ft,{children:O&&y&&/*#__PURE__*/t(gu,{text:"Take me to Warpcast",url:O,color:vu})})]})]})}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{backFn:d?h:void 0,onClose:v},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Cu,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Nl,{children:"Sign in with Farcaster"}),/*#__PURE__*/t(xl,{children:"Scan with your phone's camera to continue."}),/*#__PURE__*/t(Bt,{children:O?/*#__PURE__*/t(zt,{url:O,size:275,squareLogoElement:wu}):/*#__PURE__*/t(Ht,{})}),/*#__PURE__*/e(Ft,{children:[/*#__PURE__*/t(xl,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),O&&/*#__PURE__*/t(mu,{text:O,itemName:"link",color:vu})]})]})}),/*#__PURE__*/t(yt,{})]})},[cr.AWAITING_FARCASTER_SIGNER]:()=>{let{lastScreen:r,navigateBack:a,data:i,app:c}=lr(),{requestFarcasterSignerStatus:d,closePrivyModal:u}=x(),[h,p]=s(void 0),[m,g]=s(!1),[w,v]=s(!1),C=l([]),E=i?.farcasterSigner;o((()=>{let e=Date.now(),t=setInterval((async()=>{if(!E?.public_key)return clearInterval(t),void p({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===E.status&&(clearInterval(t),g(!1),v(!0),C.current.push(setTimeout((()=>u({shouldCallAuthOnSuccess:!1,isSuccess:!0})),hr)));let n=await d(E?.public_key),r=Date.now()-e;"approved"===n.status?(clearInterval(t),g(!1),v(!0),C.current.push(setTimeout((()=>u({shouldCallAuthOnSuccess:!1,isSuccess:!0})),hr))):r>3e5?(clearInterval(t),p({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===n.status&&(clearInterval(t),p({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),C.current.forEach((e=>clearTimeout(e)))}}),[]);let T="pending_approval"===E?.status?E.signer_approval_url:void 0;/*#__PURE__*/return e(n,y||m?{children:[/*#__PURE__*/t(ot,{backFn:r?a:void 0,onClose:u},"header"),/*#__PURE__*/t(_t,{}),
14
- /*#__PURE__*/t(n,f?{children:/*#__PURE__*/e(Au,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:w,fail:!!h}),/*#__PURE__*/t(wu,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t(Nl,{children:h?h.message:"Add a signer to Farcaster"}),/*#__PURE__*/t(xl,{children:h?h.detail:"This will allow "+c.name+" to add casts, likes, follows, and more on your behalf."})]}),T&&/*#__PURE__*/t(st,{onClick:e=>{e.preventDefault(),window.location.href=T},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(bu,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:w,fail:!!h}),/*#__PURE__*/t(wu,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t(Nl,{children:h?h.message:"Requesting signer from Farcaster"}),/*#__PURE__*/t(xl,{children:h?h.detail:"This should only take a moment"}),/*#__PURE__*/t(Ft,{children:T&&y&&/*#__PURE__*/t(gu,{text:"Take me to Warpcast",url:T,color:Tu})})]})]})}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{backFn:r?a:void 0,onClose:u},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(bu,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Nl,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e(xl,{children:["This will allow ",c.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/t(Bt,{children:"pending_approval"===E?.status?/*#__PURE__*/t(zt,{url:E.signer_approval_url,size:275,squareLogoElement:wu}):/*#__PURE__*/t(Ht,{})}),/*#__PURE__*/e(Ft,{children:[/*#__PURE__*/t(xl,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===E?.status&&/*#__PURE__*/t(mu,{text:E.signer_approval_url,itemName:"link",color:Tu})]})]})}),/*#__PURE__*/t(yt,{})]})},[cr.SELECT_PASSKEY_SIGNUP_OR_LOGIN]:()=>{let{enabled:r,token:a}=it(),{lastScreen:i,currentScreen:o,navigateBack:s,navigate:l,setModalData:c}=lr(),{initSignupWithPasskey:d,initLoginWithPasskey:u}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:i&&o!==i?s:void 0}),/*#__PURE__*/t(Il,{children:/*#__PURE__*/e(wy,{children:[/*#__PURE__*/t(ih,{}),/*#__PURE__*/t(oh,{})]})}),/*#__PURE__*/t(Nl,{children:"Log in or create a new account?"}),/*#__PURE__*/t(xl,{children:"Create a new account with a passkey or use a passkey to log in to an existing account."}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(st,{onClick:async()=>{r&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!0},captchaModalData:{callback:e=>d({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:cr.ERROR_SCREEN}}),l(cr.CAPTCHA_SCREEN)):(await d({withPrivyUi:!0}),c({passkeyAuthModalData:{passkeySignupFlow:!0}}),l(cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE))},children:"Create new account"}),/*#__PURE__*/t(Hl,{onClick:async()=>{r&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>u({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:cr.ERROR_SCREEN}}),l(cr.CAPTCHA_SCREEN)):(await u({withPrivyUi:!0}),c({passkeyAuthModalData:{passkeySignupFlow:!1}}),l(cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE))},children:"Log in with a passkey"})]}),/*#__PURE__*/t(ct,{})]})},[cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE]:()=>{let{app:r,lastScreen:a,currentScreen:i,navigateBack:c,data:d,setModalData:u,navigate:h}=lr(),{loginWithPasskey:p,signupWithPasskey:m,closePrivyModal:y,createAnalyticsEvent:g}=x(),{user:f,logout:w}=ur(),{passkeySignupFlow:v}=d?.passkeyAuthModalData??{},C=hr-500,[E,T]=s("loading"),[b,_]=s(null),k=l([]),I=e=>{k.current=[e,...k.current]};o((()=>()=>{k.current.forEach((e=>clearTimeout(e))),k.current=[]}),[]);let N=async()=>{T("loading");try{v?await m():await p(),T("success")}catch(e){_(e),T("error")}};return o((()=>{if("success"===E&&f){if(r?.legal.requireUsersAcceptTerms&&!f.hasAcceptedTerms)return void I(setTimeout((()=>{h(cr.AFFIRMATIVE_CONSENT_SCREEN)}),C));if(!ut(f,r?.embeddedWallets))return void I(setTimeout((()=>{y({shouldCallAuthOnSuccess:!0,isSuccess:!0})}),hr));I(setTimeout((()=>{u({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),g({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"PasskeyStatusScreen"}}),w()},callAuthOnSuccessOnClose:!0}}),h(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),C))}}),[f,E]),o((()=>{N()}),[]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{backFn:a&&i!==a?c:void 0}),/*#__PURE__*/e(vy,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:"success"===E,fail:"error"===E}),/*#__PURE__*/t(oh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:(()=>{switch(E){case"loading":return"Waiting for passkey";case"success":return"Success";case"error":return"Something went wrong"}})()}),/*#__PURE__*/t("p",{style:{whiteSpace:"pre-wrap"},children:(()=>{switch(E){case"loading":return v?"Please follow prompts to register your passkey.":"Please follow prompts to verify your passkey.\nYou will have to sign up with another method first to register a passkey for your account.";case"success":return"You've successfully logged in with your passkey.";case"error":if(b instanceof M){if(b.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE)return"Cannot link more passkeys to account.";if(b.privyErrorCode===A.PASSKEY_NOT_ALLOWED)return"Passkey request timed out or rejected by user.\nYou will have to sign up with another method first to register a passkey for your account."}return"An unknown error occurred.\nYou will have to sign up with another method first to register a passkey for your account."}})()})]}),(()=>{switch(E){case"loading":case"success":/*#__PURE__*/return t(st,{onClick:()=>{},disabled:!0,children:"Continue"});case"error":/*#__PURE__*/return t(st,{onClick:N,disabled:!1,children:"Retry"})}})()]}),/*#__PURE__*/t(yt,{})]})},[cr.WALLET_INTERSTITIAL_SCREEN]:()=>{let{ready:r}=ur(),{data:a}=lr(),[i,o]=s(!1);if(!a?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:l,connectOnly:c,chainType:d}=a.installWalletModalData,u=l.getMobileRedirect({useUniversalLink:!i,isSolana:"solana"===d,connectOnly:c}),h=l.name.replace(/ wallet/gi,""),p={title:`Redirecting to ${h} Mobile Wallet`,description:`We'll take you to the ${h} Mobile Wallet app to continue your login experience.`,footnote:""};return r&&(p.description=`For the best experience, we'll automatically log you into the ${h} Mobile Wallet in-app browser.`,p.footnote="Once you're done, you can always return here and refresh to view your updated account."),i&&(p.title="Still here?",p.description=`You may need to install the ${l.name} mobile app.`,p.footnote=`Once you're done, you can return here or connect via ${l.name}'s in-app browser.`),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Jl,{title:p.title,description:p.description}),/*#__PURE__*/e(un,{children:[/*#__PURE__*/t(An,{href:u,onClick:()=>setTimeout((()=>o(!0)),1e3),loading:r&&!u,children:i?"Go to App Store":"Continue"}),p.footnote?/*#__PURE__*/t("p",{children:p.footnote}):null]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.LOGIN_FAILED_SCREEN]:()=>{let{closePrivyModal:r}=x(),{navigate:a}=lr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(rm,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/t(Jl,{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(un,{children:[/*#__PURE__*/t(st,{onClick:()=>a(cr.LANDING),children:"Try again"}),/*#__PURE__*/t(dt,{onClick:()=>r(),children:"Cancel"})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.AWAITING_OAUTH_SCREEN]:()=>{let{authenticated:r,logout:a,ready:i,user:l}=ur(),{app:c,setModalData:d,navigate:u,resetNavigation:h}=lr(),{getAuthMeta:p,initLoginWithOAuth:m,loginWithOAuth:y,updateWallets:g,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v}=x(),[C,E]=s(!1),[T,b]=s(void 0),_=p()?.provider||"google",{name:k,component:I}=Go(_);o((()=>{y(_).then((()=>{E(!0),f(!0)})).catch((e=>{if(f(!1),e?.privyErrorCode===A.ALLOWLIST_REJECTED)return b(void 0),h(),void u(cr.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),b(void 0),h(),void u(cr.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===A.USER_DOES_NOT_EXIST)return b(void 0),h(),void u(cr.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return b(void 0),h(),d({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:p()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void u(cr.LINK_CONFLICT_SCREEN);let{retryable:t,detail:n}=function(e,t){let n={detail:"",retryable:!1},r=Mo(t);if(e?.privyErrorCode===A.LINKED_TO_ANOTHER_USER&&(n.detail="This account has already been linked to another user."),e?.privyErrorCode===A.INVALID_CREDENTIALS&&(n.retryable=!0,n.detail="Something went wrong. Try again."),e.privyErrorCode===A.OAUTH_USER_DENIED&&(n.detail=`Retry and check ${r} to finish connecting your account.`,n.retryable=!0),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&(n.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=Go(t).name;n.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===A.OAUTH_ACCOUNT_SUSPENDED){let e=Go(t).name;n.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE&&(n.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===A.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(n.detail="Something went wrong. Please try again."),n}(e,_);b({retryable:t,detail:n,message:"Authentication failed"})})).finally((()=>{Ko()}))}),[k,_]),o((()=>{if(i&&r&&C&&l){if(c?.legal.requireUsersAcceptTerms&&!l.hasAcceptedTerms){let e=setTimeout((()=>{u(cr.AFFIRMATIVE_CONSENT_SCREEN)}),hr);return()=>clearTimeout(e)}if(ut(l,c.embeddedWallets)){let e=setTimeout((()=>{d({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:_,screen:"OAuthStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),u(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),hr);return()=>clearTimeout(e)}{let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),hr);return g(),()=>clearTimeout(e)}}}),[i,r,C,l]);let N=C?`Successfully connected with ${k}`:T?T.message:`Verifying connection to ${k}`,R="";return R=C?"You’re good to go!":T?T.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(fy,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:C,fail:!!T}),/*#__PURE__*/t(I,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:N}),/*#__PURE__*/t("p",{children:R})]}),T&&T?.retryable?/*#__PURE__*/t(hn,{onClick:()=>{Ko(),m(_),b(void 0)},disabled:!C&&!T?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(yt,{})]})},[cr.CROSS_APP_AUTH_SCREEN]:()=>{let r=dr(),{data:a,navigate:l,setModalData:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),{crossAppAuthFlow:u,updateWallets:h,closePrivyModal:p,createAnalyticsEvent:m}=x(),{logout:y}=At(),[g,f]=s({}),w=a?.crossAppAuth,v={id:w.appId,name:w.name,logoUrl:w.logoUrl},C=new T(`There was an issue connecting your ${v.name} account. Please try again.`),E=new Ge((async e=>{if(w.popup)try{let t=await u({appId:e,popup:w.popup,action:w.action});f({data:t})}catch(e){e instanceof T?f({error:e}):(e instanceof N&&w.popup&&w.popup.close(),f({error:C}))}else f({error:C})})),b=()=>{g.data&&(h(),w.onSuccess(g.data),p({shouldCallAuthOnSuccess:!0,isSuccess:!0})),w.onError(g.error??new T("User canceled flow")),p({shouldCallAuthOnSuccess:!1,isSuccess:!1})};d.current=b,o((()=>{v.id.length&&E.execute(v.id)}),[v.id]),o((()=>{if(!g.data)return;let e=g.data;if(r.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{l(cr.AFFIRMATIVE_CONSENT_SCREEN)}),hr);return()=>clearTimeout(e)}if(ut(e,r.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),m({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${v.id}`,screen:"CrossAppAuthScreen"}}),y()},callAuthOnSuccessOnClose:!0}}),l(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),hr);return()=>clearTimeout(e)}let t=setTimeout(b,hr);return()=>clearTimeout(t)}),[g.data]);let{title:A,subtitle:_}=i((()=>g.data?{title:`Successfully connected with ${v.name}`,subtitle:"You're good to go!"}:g.error?{title:"Authentication failed",subtitle:g.error.message}:{title:`Connecting to ${v.name}`,subtitle:`Please check the pop-up from ${v.name} to continue`}),[g,v.name]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:b}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(Oc,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:!!g.data,fail:!!g.error}),/*#__PURE__*/t(Rc,{name:v.name,logoUrl:v.logoUrl})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:A}),/*#__PURE__*/t("p",{children:_})]})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(yt,{})]})},[cr.ALLOWLIST_REJECTION_SCREEN]:()=>{let{navigate:r,app:a}=lr(),i=a?.allowlistConfig.errorTitle||"You don't have access to this app",o=a?.allowlistConfig.errorDetail||"Have you been invited?",s=a?.allowlistConfig.errorCtaText||"Try another account";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/e(Kl,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(hl,{}),/*#__PURE__*/t(ql,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})]})}),/*#__PURE__*/e(Yl,{children:[/*#__PURE__*/t("string"==typeof i?"h3":n,{children:i}),/*#__PURE__*/t("string"==typeof o?"p":n,{children:o})]}),a?.allowlistConfig.errorCtaLink?
15
- /*#__PURE__*/t(st,{as:"a",href:a.allowlistConfig.errorCtaLink,children:s}):/*#__PURE__*/t(st,{onClick:()=>{r(cr.LANDING)},children:s})]})]})},[cr.ACCOUNT_NOT_FOUND_SCREEN]:()=>{let{navigate:r,app:a,setModalData:i,data:o}=lr(),{getAuthMeta:s,client:l}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/e(dl,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Js,{color:"var(--privy-color-warn-light)"}),/*#__PURE__*/t(Ja,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-warn)"})]})}),/*#__PURE__*/e(ul,{children:[/*#__PURE__*/t("h3",{children:"Account not found"}),/*#__PURE__*/e("p",{children:["Please try logging in again or go to ",a.name," to create an account."]})]}),/*#__PURE__*/t(Xs,{}),/*#__PURE__*/t(st,{onClick:()=>{let e=s();i({...o,login:{...o?.login,...e?.disableSignup?{disableSignup:!0}:{}}}),l?.authFlow&&(l.authFlow=void 0),r(cr.LANDING)},children:"Try logging in again"})]})]})},[cr.USER_LIMIT_REACHED_SCREEN]:()=>{let{navigate:r}=lr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/e(lf,{children:[/*#__PURE__*/t(cf,{children:/*#__PURE__*/t(sf,{})}),/*#__PURE__*/e(df,{children:[/*#__PURE__*/t("h3",{children:"Unable to sign in"}),/*#__PURE__*/t("p",{children:"This application has reached its user limit and cannot sign in new users."})]}),/*#__PURE__*/t(st,{onClick:()=>{r(cr.LANDING)},children:"Go back"})]}),/*#__PURE__*/t(ct,{})]})},[cr.INSTALL_WALLET_SCREEN]:()=>{let{navigateBack:r,data:a}=lr();if(!a?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:i}=a.installWalletModalData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:r},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(vp,{...i}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/e(yt,{children:[/*#__PURE__*/t("span",{children:"Still not sure? "}),/*#__PURE__*/t("a",{target:"_blank",href:"https://solana.com/docs/intro/wallets",children:"Learn more"})]})]})},[cr.LINK_EMAIL_SCREEN]:()=>{let{app:r}=lr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Ql,{title:"Connect your email",description:`Add your email to your ${r?.name} account`,icon:/*#__PURE__*/t(ii,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(un,{children:/*#__PURE__*/t(kp,{stacked:!0})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.LINK_PHONE_SCREEN]:()=>{let{app:r,currentScreen:a,data:i,navigate:o,setModalData:s}=lr(),{initLoginWithSms:l}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Ql,{title:"Connect your phone",description:`Add your number to your ${r?.name} account`,icon:/*#__PURE__*/t(oi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/t(un,{children:/*#__PURE__*/t(Dp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await l({phoneNumber:e,withPrivyUi:!0}),o(cr.AWAITING_PASSWORDLESS_CODE)}catch(e){s({errorModalData:{error:e,previousScreen:i?.errorModalData?.previousScreen||a||cr.LINK_PHONE_SCREEN}}),o(cr.ERROR_SCREEN)}},hideRecent:!0})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.LINK_WALLET_SCREEN]:()=>{let{app:r,data:a}=lr(),i=a?.externalConnectWallet?.suggestedAddress,o=i?/*#__PURE__*/e("span",{children:["Link the wallet with address ",/*#__PURE__*/t(lt,{showCopyIcon:!1,address:i})," ",r?.name?`to ${r.name}.`:"."]}):`Link a wallet to your ${r?.name} account`,{connectors:s}=x(),l=xc({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(ot,{},"header"),l.length>0&&/*#__PURE__*/t(Jl,{title:"Link your wallet",description:o}),/*#__PURE__*/t(tl,{children:/*#__PURE__*/t(Nc,{wallets:l})}),/*#__PURE__*/t(ct,{})]})},[cr.LINK_PASSKEY_SCREEN]:()=>{let{user:r,unlinkPasskey:a}=ur(),{linkWithPasskey:i,closePrivyModal:l}=x(),c=r?.linkedAccounts.filter((e=>"passkey"===e.type)),[d,u]=s(!1),[h,p]=s(""),[m,y]=s(!1),[g,f]=s(!1);o((()=>{0===c.length&&f(!1)}),[c.length]);let w=async e=>(u(!0),await a(e).then((()=>y(!0))).catch((e=>{e instanceof M&&e.privyErrorCode===A.MISSING_MFA_CREDENTIALS?p("Cannot unlink a passkey enrolled in MFA"):p("Unknown error occurred.")})).finally((()=>{u(!1)})));/*#__PURE__*/return e(n,m?{children:[/*#__PURE__*/t(ot,{onClose:()=>l()},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(mh,{style:{marginBottom:"1.5rem"},children:"Passkeys updated"}),/*#__PURE__*/t(yh,{children:" "}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:()=>l(),children:"Done"})}),/*#__PURE__*/t(yt,{})]}:g?{children:[/*#__PURE__*/t(ot,{backFn:()=>f(!1),onClose:()=>l()},"header"),/*#__PURE__*/t(sh,{passkeys:c,expanded:g,onUnlink:w,onExpand:()=>f(!0)}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{onClose:()=>l()},"header"),/*#__PURE__*/t(Il,{children:/*#__PURE__*/e(ch,{children:[/*#__PURE__*/t(ih,{}),/*#__PURE__*/t(oh,{})]})}),/*#__PURE__*/t(mh,{children:"Secure your account with a passkey"}),/*#__PURE__*/t(gh,{}),0===c.length?/*#__PURE__*/t(lh,{}):/*#__PURE__*/t(sh,{passkeys:c,expanded:g,onUnlink:w,onExpand:()=>f(!0)}),/*#__PURE__*/e(Ml,{style:{marginTop:"12px"},children:[h&&/*#__PURE__*/t(dh,{$fail:!0,children:h}),/*#__PURE__*/t(st,{onClick:()=>{u(!0),i().then((()=>y(!0))).catch((e=>{if(e instanceof M){if(e.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE)return void p("Cannot link more passkeys to account.");if(e.privyErrorCode===A.PASSKEY_NOT_ALLOWED)return void p("Passkey request timed out or rejected by user.")}p("Unknown error occurred.")})).finally((()=>{u(!1)}))},loading:d,children:"Add new passkey"})]}),/*#__PURE__*/t(yt,{})]})},[cr.UPDATE_EMAIL_SCREEN]:()=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Ql,{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(ii,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(un,{children:/*#__PURE__*/t(rf,{stacked:!0})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}),[cr.UPDATE_PHONE_SCREEN]:()=>{let{currentScreen:r,data:a,navigate:i,setModalData:o}=lr(),{user:s}=ur(),{initUpdatePhone:l}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Ql,{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(oi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(un,{children:/*#__PURE__*/t(Dp,{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(cr.AWAITING_PASSWORDLESS_CODE)}catch(e){o({errorModalData:{error:e,previousScreen:a?.errorModalData?.previousScreen||r||cr.LINK_PHONE_SCREEN}}),i(cr.ERROR_SCREEN)}},hideRecent:!0})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.CONNECT_ONLY_LANDING_SCREEN]:()=>{let{app:r,data:a}=lr(),i=dr(),o=a?.externalConnectWallet?.suggestedAddress,s=o?/*#__PURE__*/e("span",{children:["Connect the wallet with address ",/*#__PURE__*/t(lt,{showCopyIcon:!1,address:o})," ",r?.name?`to ${r.name}.`:"."]}):`Connect a wallet to your ${r?.name} account`,{connectors:l}=x(),c=xc({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(ot,{},"header"),c.length>0&&/*#__PURE__*/t(Zl,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(nl,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(Nc,{wallets:c})}),r&&/*#__PURE__*/t(Et,{app:r,alwaysShowImplicitConsent:!0}),/*#__PURE__*/t(ct,{})]})},[cr.CONNECT_ONLY_AUTHENTICATED_SCREEN]:()=>{let{app:r,data:a}=lr(),i=dr(),o=a?.externalConnectWallet?.suggestedAddress,s=o?`Connect the wallet with address ${Ct(o)} ${r?.name?`to ${r.name}.`:"."}`:`Connect a wallet to ${r?.name}`,{connectors:l}=x(),c=xc({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(ot,{},"header"),c.length>0&&/*#__PURE__*/t(Jl,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(nl,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(Nc,{wallets:c})}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN]:()=>{let{app:r,setModalData:a,navigate:i,data:l,onUserCloseViaDialogOrKeybindRef:c}=lr(),[d,u]=s(""),{embeddedWallets:h}=dr(),{authenticated:p,user:m,getAccessToken:y}=ur(),{closePrivyModal:g,walletProxy:f,refreshSessionAndUser:w,recoverPrimaryWallet:v}=x(),{onSuccess:C,onFailure:E,callAuthOnSuccessOnClose:b}=l.createWallet,A=!0===r?.embeddedWallets.requireUserOwnedRecoveryOnCreate,{createWallet:_}=cd(),[k,I]=s(null),N=new Ge((async()=>{let e=await y();if(m&&e&&f)try{let t=wr(m);if(t&&"privy"===t.recoveryMethod)await v();else if(t){let{entropyId:n,entropyIdVerifier:r}=jn(t);try{if(!await f.connect({accessToken:e,entropyId:n,entropyIdVerifier:r}))throw new T("Primary wallet not connected.")}catch(e){return I(t),void i(cr.EMBEDDED_WALLET_CREATED_SCREEN)}}let n=Wt(m,r.embeddedWallets.ethereum.createOnLogin),a=Mt(m,r.embeddedWallets.solana.createOnLogin);if(n&&a){let t=await _({user:m});if(await f.createSolana({accessToken:e,ethereumAddress:t?.address}),!t)return;return I(t),void i(cr.EMBEDDED_WALLET_CREATED_SCREEN)}if(a){await f.createSolana({accessToken:e,ethereumAddress:yr(m)?.address});let t=await w();return I(gr(t)),void i(cr.EMBEDDED_WALLET_CREATED_SCREEN)}if(n){let e=await _({user:m});if(!e)return;I(e),i(cr.EMBEDDED_WALLET_CREATED_SCREEN)}}catch(e){u(e.message)}}));return o((()=>p&&m?A?(a({...l,recoverySelection:{...l?.recoverySelection,isInAccountCreateFlow:!0}}),i(Jc({walletAction:"create",showAutomaticRecovery:!1,availableRecoveryMethods:h.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:!1,isResettingPassword:!1}))):void N.execute():(i(cr.LANDING),void E(Error("User must be authenticated before creating a Privy wallet")))),[A,p]),c.current=()=>null,d?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Something went wrong",description:d})]}),/*#__PURE__*/t(st,{onClick:()=>{k?(C(k),g({shouldCallAuthOnSuccess:b})):(E(new R("User wallet creation failed")),g({shouldCallAuthOnSuccess:!1}))},children:"Close"}),/*#__PURE__*/t(dd,{})]}):/*#__PURE__*/t(Lc,{})},[cr.EMBEDDED_WALLET_CREATED_SCREEN]:()=>{let{user:r}=ur(),{closePrivyModal:a,isNewUserThisSession:i,updateWallets:s}=x(),{app:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),{onSuccess:u,onFailure:h,callAuthOnSuccessOnClose:p}=c.createWallet,m=()=>{let e=yr(r)??gr(r);e?(s(),u(e)):h(Error("Failed to create wallet")),a({shouldCallAuthOnSuccess:p})};return o((()=>{let e=setTimeout(m,pr);return()=>clearTimeout(e)}),[]),d.current=m,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:m}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(si,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:i?"Welcome"+(l?.name?` to ${l?.name}`:""):"All set!",description:i?"You’ve successfully created an account.":"Your account is secured."})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_CONNECTING_SCREEN]:()=>{let{authenticated:r,user:a,getAccessToken:l}=ur(),{closePrivyModal:c,createAnalyticsEvent:d,walletProxy:u}=x(),{navigate:h,data:p,setModalData:m,onUserCloseViaDialogOrKeybindRef:y}=lr(),g=i((()=>Date.now()),[]),[f,w]=s(!1),{onCompleteNavigateTo:v,onFailure:C,shouldForceMFA:E,entropyId:T,entropyIdVerifier:b}=p?.connectWallet,A=e=>{f||(w(!0),C("string"==typeof e?Error(e):e))};o((()=>{let e,t=mr(a,T);return r&&t?u?((async()=>{let n=await l();if(!n)return A("User must be authenticated and have a Privy wallet before it can be connected");try{await u.connect({accessToken:n,entropyId:T,entropyIdVerifier:b}),E&&await u.verifyMfa({accessToken:n});let t=(Date.now()-g)/1e3;v===cr.EMBEDDED_WALLET_KEY_EXPORT_SCREEN&&t<1?e=setTimeout((()=>{h(v,!1)}),1e3*(1-t)):h(v,!1)}catch(e){if($c(e)&&"privy"===t.recoveryMethod){let e=await l();if(!e)return A("User must be authenticated and have a Privy wallet before it can be recovered");try{d({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:t.address}});let n=await(u?.recover({accessToken:e,entropyId:T,entropyIdVerifier:b}));n?.entropyId||A(Error("Unable to recover wallet")),v?h(v):c({shouldCallAuthOnSuccess:!1}),d({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}}),h(v)}catch(e){A("An error has occurred, please try again.")}}else $c(e)&&"privy"!==t.recoveryMethod?(m({...p,recoverWallet:{entropyId:T,entropyIdVerifier:b,onCompleteNavigateTo:v,onFailure:C},recoveryOAuthStatus:{provider:t.recoveryMethod,action:"recover",isInAccountCreateFlow:!1}}),h(Qc(t.recoveryMethod))):A(e)}})(),()=>clearTimeout(e)):void 0:A("User must be authenticated and have a Privy wallet before it can be connected")}),[r,a,u]);let _=()=>{A("User exited before wallet could be connected"),c({shouldCallAuthOnSuccess:!1})};return y.current=_,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:_}),f?/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),/*#__PURE__*/t(st,{onClick:()=>c({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):/*#__PURE__*/t(Lc,{}),/*#__PURE__*/t(td,{})]})},[cr.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN]:()=>{let[r,a]=s(!0),{authenticated:i,getAccessToken:l,user:c}=ur(),{walletProxy:d,closePrivyModal:u,createAnalyticsEvent:h}=x(),{navigate:p,data:m,onUserCloseViaDialogOrKeybindRef:y}=lr(),[g,f]=s(void 0),[w,v]=s(""),[C,E]=s(!1),{entropyId:T,entropyIdVerifier:b,onCompleteNavigateTo:A,onSuccess:_,onFailure:k}=m.recoverWallet,I=(e="User exited before their wallet could be recovered")=>{u({shouldCallAuthOnSuccess:!1}),k("string"==typeof e?new R(e):e)};y.current=I,o((()=>{if(!i)return I("User must be authenticated and have a Privy wallet before it can be recovered")}),[i]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:I}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(Ey,{children:[/*#__PURE__*/e(Cy,{children:[/*#__PURE__*/t(oo,{height:48,width:48,stroke:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Enter your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(wd,{children:[/*#__PURE__*/t(gd,{type:r?"password":"text",onChange:e=>(e=>{e&&f(e)})(e.target.value),disabled:C,style:{paddingRight:"2.3rem"}}),/*#__PURE__*/t(bd,{style:{right:"0.75rem"},children:r?/*#__PURE__*/t(_d,{onClick:()=>a(!1)}):/*#__PURE__*/t(kd,{onClick:()=>a(!0)})})]}),!!w&&/*#__PURE__*/t(Ty,{children:w})]}),/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(vn,{children:[/*#__PURE__*/t("h4",{children:"Why is this necessary?"}),/*#__PURE__*/t("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),/*#__PURE__*/t(by,{loading:C||!d,disabled:!g,onClick:async()=>{E(!0);let e=await l(),t=mr(c,T);if(!e||!t||null===g)return I("User must be authenticated and have a Privy wallet before it can be recovered");try{h({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t.address}}),await(d?.recover({accessToken:e,entropyId:T,entropyIdVerifier:b,recoveryPassword:g})),v(""),A?p(A):u({shouldCallAuthOnSuccess:!1}),_?.(t),h({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}})}catch(e){!function(e){return Vc(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)}(e)?v("An error has occurred, please try again."):v("Invalid recovery password, please try again.")}finally{E(!1)}},warn:!1,hideAnimations:!T&&C,children:"Recover your account"})]})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN]:()=>{let[r,a]=s(!1),{navigate:i,lastScreen:o,navigateBack:l,setModalData:c,data:d,onUserCloseViaDialogOrKeybindRef:u}=lr(),{user:h}=ur(),{embeddedWallets:p}=dr(),{closePrivyModal:m}=x(),y=wr(h),g=null===y,{isInAccountCreateFlow:f,isResettingPassword:w}=d.recoverySelection,v=y&&"privy"!==y.recoveryMethod,C=v?/*#__PURE__*/e("span",{children:["Your account is currently secured using"," ",/*#__PURE__*/t("strong",{children:Sy[y?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function E(e){c({recoveryOAuthStatus:{provider:e,action:g?"create-wallet":"set-recovery",isInAccountCreateFlow:f}}),i(cr.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN)}function T(){d?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),m({shouldCallAuthOnSuccess:d?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return u.current=T,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:T,backFn:r?()=>a(!1):o?l:void 0,infoFn:o||r?void 0:()=>a(!0)},"header"),r?/*#__PURE__*/t(Ry,{onClose:()=>a(!1)}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ql,{title:v?"Update backup method":"Secure your account",icon:/*#__PURE__*/t(yo,{width:48}),description:C}),/*#__PURE__*/t(ky,{children:p.userOwnedRecoveryOptions.filter((e=>!["icloud","google-drive"].includes(y?.recoveryMethod||"")||e!==y?.recoveryMethod)).sort().map((n=>{switch(n){case"google-drive":/*#__PURE__*/return e(il,{onClick:()=>E("google-drive"),children:[/*#__PURE__*/t(xy,{children:/*#__PURE__*/t(_y,{style:{width:18}})}),"Back up to Google Drive"]},n);case"icloud":/*#__PURE__*/return e(il,{onClick:()=>E("icloud"),children:[/*#__PURE__*/t(xy,{children:/*#__PURE__*/t(Ay,{style:{width:24}})}),"Back up to Apple iCloud"]},n);case"user-passcode":/*#__PURE__*/return e(il,{onClick:()=>{i(Zc({isCreatingWallet:g,skipSplashScreen:!0}))},children:[/*#__PURE__*/t(xy,{children:/*#__PURE__*/t(go,{style:{width:18}})}),w?"Reset your":"Set a"," password"]},n);default:return null}}))})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN]:()=>{let{user:r,getAccessToken:a}=ur(),{walletProxy:i,refreshSessionAndUser:o,closePrivyModal:l}=x(),c=lr(),{entropyId:d,entropyIdVerifier:u}=c.data?.recoverWallet,[h,p]=s(!1),[m,y]=s(null),[g,f]=s(null);function w(){if(!h){if(g)return c.data?.setWalletPassword?.onFailure(g),void l();if(!m)return c.data?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),void l()}}c.onUserCloseViaDialogOrKeybindRef.current=w;let v=!(!h&&!m);/*#__PURE__*/return e(n,g?{children:[/*#__PURE__*/t(ot,{onClose:w},"header"),/*#__PURE__*/t(Oy,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:/*#__PURE__*/t(Qa,{height:38,width:38,stroke:"var(--privy-color-error)"})}),/*#__PURE__*/t(St,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),/*#__PURE__*/t(Xs,{style:{minHeight:"2rem"}}),/*#__PURE__*/t(Jt,{onClick:()=>f(null),children:"Try again"}),/*#__PURE__*/t(ct,{})]}:{children:[/*#__PURE__*/t(ot,{onClose:w},"header"),/*#__PURE__*/t(yo,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),/*#__PURE__*/t(St,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),/*#__PURE__*/t(Rt,{style:{marginTop:"1rem"},children:"When you log into a new device, you’ll only need to authenticate to access your account. Never get logged out if you forget your password."}),/*#__PURE__*/t(Xs,{style:{minHeight:"2rem"}}),/*#__PURE__*/t(Jt,{loading:h,disabled:v,onClick:()=>async function(){p(!0);try{let e=await a(),t=mr(r,d);if(!e||!i||!t)return;if(!(await i.setRecovery({accessToken:e,entropyId:d,entropyIdVerifier:u,existingRecoveryMethod:t.recoveryMethod,recoveryMethod:"privy"})).entropyId)throw Error("Unable to set recovery on wallet");let n=await o();if(!n)throw Error("Unable to set recovery on wallet");let s=mr(n,t.address);if(!s)throw Error("Unabled to set recovery on wallet");y(!!n),setTimeout((()=>{c.data?.setWalletPassword?.onSuccess(s),l()}),hr)}catch(e){f(e)}finally{p(!1)}}(),children:m?"Success":"Confirm"}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN]:()=>{let{logout:r}=ur(),{navigate:a,setModalData:i,data:l}=lr(),{recoveryOAuthFlow:d,closePrivyModal:u,createAnalyticsEvent:h}=x(),[p,m]=s(!1),{provider:y,action:g,isInAccountCreateFlow:f}=l?.recoveryOAuthStatus,[w,v]=s(void 0),[C,E]=s("create-wallet"===g);if("user-passcode"===y)throw Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let T=Ny[y].name,b=Ny[y].component,A=l?.recoverWallet?.onCompleteNavigateTo,_=new Ge((async(e="create-wallet")=>(E(!0),new Promise(((t,n)=>{setTimeout((async()=>{try{let n=window.open();await d(y,e,n),m(!0),t()}catch(t){v({message:`${"recover"===e?"Recovery":"Back up"} with ${T} unsuccessful`,detail:"recover"===g?`Please verify that you are selecting the ${T} account associated with your backup.`:"",retryable:!0}),n()}}),0)})))));o((()=>{"recover"!==g&&_.execute(f?"create-wallet":"set-recovery")}),[]),o((()=>{if(!p)return;let e=setTimeout((()=>{f?(i({createWallet:{onSuccess:()=>{},onFailure:e=>{h({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"RecoveryOAuthScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),a(cr.EMBEDDED_WALLET_CREATED_SCREEN)):u({shouldCallAuthOnSuccess:!1})}),hr);return()=>clearTimeout(e)}),[p]);let k=c((async()=>{await _.execute("recover"),A?a(A):m(!0)}),[]),I="google-drive"===y?"Google Drive":"Apple iCloud",N=p&&`Successfully ${"recover"===g?"recovered":"backed up"} with ${I}.`||w&&w.message||`${"recover"===g?"Recovering":"Backing up"} with ${I}...`,S=w?w.detail:"";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{}),C?/*#__PURE__*/t(n,{children:/*#__PURE__*/e(ky,{children:[/*#__PURE__*/t(Ql,{title:N,icon:/*#__PURE__*/t(b,{style:{width:"38px",height:"38px"}}),description:S}),w&&w?.retryable?/*#__PURE__*/t(st,{onClick:()=>{Ko(),v(void 0),"create-wallet"===g?_.execute("create-wallet"):k()},disabled:!p&&!w?.retryable,children:"Try again"}):null]})}):/*#__PURE__*/e(ky,{children:[/*#__PURE__*/t(Ql,{title:"Confirm it's really you",icon:/*#__PURE__*/t(b,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${I} where your account is backed up.`}),/*#__PURE__*/e(st,{onClick:k,children:["Confirm with ",I]})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_KEY_EXPORT_SCREEN]:()=>{let[r,a]=s(null),{authenticated:i,user:l,getAccessToken:c}=ur(),{closePrivyModal:d,createAnalyticsEvent:u,clientAnalyticsId:h}=x(),p=dr(),{data:m,onUserCloseViaDialogOrKeybindRef:y}=lr(),{onFailure:g,onSuccess:f,origin:w,appId:v,appClientId:C,walletToExport:E,primaryWallet:T}=m.keyExport,b=e=>{d({shouldCallAuthOnSuccess:!1}),g("string"==typeof e?Error(e):e)},A=()=>{d({shouldCallAuthOnSuccess:!1}),f(),u({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:E.address}})};return o((()=>{if(!i||!E)return b("User must be authenticated before exporting their wallet");c().then(a,b)}),[i,l]),y.current=A,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:A}),/*#__PURE__*/e(od,{children:[/*#__PURE__*/t(St,{children:"Transfer wallet"}),/*#__PURE__*/e(Rt,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",/*#__PURE__*/t("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),/*#__PURE__*/t(nd,{theme:p.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),/*#__PURE__*/t(Nt,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:E.address,showIcon:!0}),/*#__PURE__*/t("div",{style:{width:"100%"},children:r&&/*#__PURE__*/t(id,{origin:w,appId:v,appClientId:C,accessToken:r,clientAnalyticsId:h,walletToExport:E,primaryWallet:T,dimensions:{height:"44px"}})})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN]:()=>{let{authenticated:r}=ur(),{initializeWalletProxy:a,closePrivyModal:i}=x(),{navigate:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),[u,h]=s(!0),[p,m]=s(""),[y,g]=s(),[f,w]=s(null),[v,C]=s(!1),E=null!==f;o((()=>{r||l(cr.LANDING)}),[r]),o((()=>{a(fr).then((e=>{h(!1),e||(m("An error has occurred, please try again."),g(new ca(new da(p,zi.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:T,data:b,confirmAndSign:A,onSuccess:_,onFailure:k,uiOptions:I}=c.signMessage,N={title:I?.title||"Sign message",description:I?.description||"Signing this message will not cost you any fees.",buttonText:I?.buttonText||"Sign and continue"},S=e=>{e?_(e):k(y||new ca(new da("The user rejected the request.",zi.E4001_USER_REJECTED_REQUEST.eipCode))),i({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{w(null),m(""),g(void 0)}),200)};return d.current=()=>{S(f)},/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:()=>S(f)}),/*#__PURE__*/t(_t,{}),I?.iconUrl&&"string"==typeof I.iconUrl?/*#__PURE__*/t(ef,{children:/*#__PURE__*/t(Kg,{size:"sm",src:I.iconUrl,alt:"app image"})}):null,/*#__PURE__*/t(St,{children:N.title}),/*#__PURE__*/t(Rt,{children:N.description}),"personal_sign"===T&&/*#__PURE__*/t(_g,{children:Yg(b)}),"eth_signTypedData_v4"===T&&/*#__PURE__*/t(Jg,{typedData:b}),"solana_signMessage"===T&&/*#__PURE__*/t(_g,{children:b}),/*#__PURE__*/t(tf,{}),/*#__PURE__*/t(Qg,{$fail:!0,children:p}),/*#__PURE__*/t(Jt,{disabled:v||E||u,loading:v,onClick:async()=>{C(!0),m("");try{let e=await A();w(e),C(!1),setTimeout((()=>{S(e)}),hr)}catch(e){console.error(e),m("An error has occurred, please try again."),g(new ca(new da(p,zi.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),C(!1)}},children:v?"Signing...":E?/*#__PURE__*/e(Xg,{children:[/*#__PURE__*/t(pu,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",/*#__PURE__*/t("span",{children:"Success"})]}):N.buttonText}),I?.isCancellable&&/*#__PURE__*/t(mn,{style:{marginTop:"1rem"},onClick:()=>S(null),isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN]:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=lr(),{rpcConfig:l,chains:c,closePrivyModal:d,walletProxy:u,client:h,showFiatPrices:p}=x(),{getAccessToken:m,user:y}=ur(),g=dr(),[f,w]=s(0),v=(e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(e),[C,E]=s(qg(e,f)),[T,b]=s(null),[A,_]=s(),[k,I]=s(!1),[N,S]=s(null),[R,O]=s(null),[W,M]=s(null),[P,L]=s(void 0),[D,U]=s(void 0),[F,B]=s(!1),[z,H]=s(!1),[V,$]=s([]),[j,G]=s([]),[q,K]=s(!1),[Y,Z]=s(void 0);if(!C||!e?.sendTransaction||!e?.sendTransaction.transactingWallet)/*#__PURE__*/return t(cu,{error:Error("Invalid transaction request"),onClick:()=>{e?.sendTransaction?.onFailure(Gg),d({shouldCallAuthOnSuccess:!1})}});let{entropyId:J,entropyIdVerifier:Q,transactingWallet:X}=e.sendTransaction,ee=i((()=>c.find((e=>Number(e.id)===Number(C.chainId)))),[C.chainId]),te=ee?.nativeCurrency.symbol??"ETH",ne=i((()=>Hg(C.data,!!g.embeddedWallets.extendedCalldataDecoding)),[C.data]),{action:re,isErc20Ish:ae,isNFTIsh:ie}=ne,{toAddress:oe,tokenAddress:se}=i((()=>({toAddress:ne.isErc20Ish?ne.transferTo:C.to??void 0,tokenAddress:ne.isErc20Ish?C.to:void 0})),[ne]);o((()=>{C.to&&ee&&ae&&ln({address:C.to,chain:ee,rpcConfig:g.rpcConfig,privyAppId:g.id}).then(b).catch(console.error)}),[C.to,ee]);let{tokenPrice:le,isTokenPriceLoading:ce}=Ou(C.chainId),{balance:de}=dn({rpcConfig:g.rpcConfig,appId:g.id,address:X.address,chain:ee}),ue=i((()=>Ha(Number(C.chainId),c,l,{appId:g.id})),[C.chainId,l]),he=jg(C,X,ue);o((()=>{E(qg(e,f))}),[f]),o((()=>{e.sendTransaction?.getIsSponsored?e.sendTransaction.getIsSponsored().then(_).catch(console.error):_(!1)}),[e.sendTransaction.getIsSponsored]);let pe=()=>{if(!k)return N?e?.sendTransaction?.onSuccess({hash:N}):W||he?.errors[0]?e?.sendTransaction?.onFailure(W??he?.errors[0]??Gg):e?.sendTransaction?.onFailure(new ca(new da("The user rejected the request",zi.E4001_USER_REJECTED_REQUEST.eipCode))),d({shouldCallAuthOnSuccess:!1})};n.current=pe;let me=!!(e.funding&&e.funding.supportedOptions.length>0),ye=Yt(BigInt(he?.totalGasEstimate??0n),te),ge=p&&le?tn(BigInt(he?.totalGasEstimate??0n),le):void 0,fe=Yt(de??0n,te,void 0,!0),we=p&&le?tn(de??0n,le):void 0,ve=e.sendTransaction?.uiOptions?.transactionInfo?.title;ve||(ve="approve"===re?ae?"Confirm address":"Confirm action":`Approve ${re}`);let Ce=e.sendTransaction?.uiOptions?.description||(ae&&"approve"===re?`${g.name} would like your permission for ${Ct(ne.spender)} to spend tokens on your behalf.`:`${g.name} wants your permission to approve the following transaction.`),Ee=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=!(!he||he.errors[0]||he.hasFunds||!1!==A),be=Te&&me,Ae=be?"Add funds":e.sendTransaction?.uiOptions?.buttonText||(f<v?"Continue":"Approve");if(o((()=>{let e=(e,t,n)=>{if(t.isErc20Ish&&t.amount&&n)Z(nn({amount:t.amount,decimals:n.decimals})),$([{value:Y,symbol:n?.symbol}]);else if(e.value){let t=BigInt(e.value),n=le&&tn(t,le);$(p&&n?[{value:n}]:[{value:Tn(t),symbol:te}])}else $(p?[{value:"$0"}]:[{value:"0",symbol:te}])},t=he?.tx??C;g.embeddedWallets.transactionScanning.enabled&&t?(K(!0),(async e=>{if(h)return await h.scanTransaction({metadata:{domain:g.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})})(t).then((e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?U("safe"):"Warning"===e.validation.result_type?U("warn"):"Malicious"===e.validation.result_type&&(U("error"),H(!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}:{iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price},n.push(e)}else if(t.out[0]?.value){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.out[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.out[0].value,symbol:t.asset.symbol,usdValue:t.out[0].usd_price},r.push(e)}for(let e of t)for(let t of Object.keys(e.spenders)){let n;n="ERC721"===e.asset.type||"approve_for_all"===e.spenders[t]?.value?{nftName:e.asset.name}:{iconUrl:e.asset.logo_url,value:e.spenders[t]?.value,symbol:e.asset.symbol,usdValue:e.spenders[t]?.usd_price},r.push(n)}return{assetsIn:n,assetsOut:r}}(e.simulation.assets_diffs,e.simulation.exposures);if(0===n.length&&0===t.length)throw Error("No tokens found");$(n),G(t)}K(!1)})).catch((()=>{K(!1),e(t,ne,T)}))):e(t,ne,T)}),[C,he?.tx,ne,T]),R/*#__PURE__*/)return t(Rg,{txn:he?.tx??C,onClose:pe,receipt:R,transactionInfo:e.sendTransaction?.uiOptions.transactionInfo,tokenPrice:le,tokenSymbol:te,receiptHeader:e.sendTransaction?.uiOptions.successHeader,receiptDescription:e.sendTransaction?.uiOptions.successDescription});if(W)/*#__PURE__*/return t(Qy,{transactionError:W,transactionHash:N??void 0,network:"ethereum",chainId:he?.tx.chainId??C.chainId,onClose:pe,onRetry:({resetNonce:e})=>{M(null);let t={...he?.tx??C};e&&(t.nonce=void 0),E(t)}});let _e=0!==v&&"number"==typeof f&&0!==f?()=>{w(f-1)}:void 0;return F&&P?/*#__PURE__*/t(xg,{details:P,onBack:()=>B(!1)}):/*#__PURE__*/t(Gy,{transactionIndex:f,onBack:_e,maxIndex:v,disabled:Te&&!me||z,isSubmitting:k,submitError:W,isPreparing:!he,isTokenPriceLoading:ce,isTokenContractInfoLoading:!ie&&!T,prepareError:he?.errors[0],symbol:T?.symbol,chain:ee,img:Ee,title:ve,subtitle:Ce,txValue:C.value,fee:ge??ye,isSponsored:A,from:X?.address??"",to:oe,tokenAddress:se??void 0,network:g.chains.find((e=>e.id===C.chainId))?.name??"",transactionDetails:{...ne,formattedAmount:Y},cta:Ae,missingFunds:Te,action:re,balance:we??fe,onClose:pe,onClick:be?async()=>{if(!X)return;if(!me)throw Error("Funding wallet is not enabled");let t=cr.FUNDING_METHOD_SELECTION_SCREEN;r({...e,funding:{...e.funding,methodScreen:t,chainType:"ethereum",amount:Da(BigInt(he?.tx.value??0)+BigInt(he?.totalGasEstimate?.toString()??0)),chain:ee}}),a(t)}:async()=>{if(f<v)w(f+1);else{I(!0);try{let t=await m();if(k||!t||!X||!u||!y)return;let n=e?.sendTransaction?.onConfirm?await e.sendTransaction.onConfirm():await Tg({accessToken:t,transactingWallet:X,entropyId:J,entropyIdVerifier:Q,walletProxy:u,transactionRequest:he?.tx??C,publicClient:ue,requesterAppId:e.sendTransaction?.requesterAppId});if(S(n),e.sendTransaction?.signOnly)return await new Promise((e=>setTimeout(e,hr))),e?.sendTransaction?.onSuccess({hash:n}),d({shouldCallAuthOnSuccess:!1});let r=await ue.waitForTransactionReceipt({hash:n});if("reverted"===r.status)throw Error("Transaction failed");O(r)}catch(e){console.warn({transaction:he?.tx??C,error:e}),M(e)}finally{I(!1)}}},validation:D,hasScanDetails:!!P,setIsScanDetailsOpen:B,preventMaliciousTransaction:z,setPreventMaliciousTransaction:H,tokensSent:V,tokensReceived:j,isScanning:q,isCancellable:e.sendTransaction?.uiOptions?.isCancellable??!1})},[cr.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN]:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=lr(),{client:l,closePrivyModal:c,walletProxy:d,showFiatPrices:u}=x(),h=dr(),{user:p,getAccessToken:m}=ur(),[y,g]=s(e?.sendSolanaTransaction?.transactionRequest),[f,w]=s(),[v,C]=s(),[E,T]=s(0),[b,A]=s({value:0n,isLoading:!1}),[_,k]=s(!1),[I,N]=s(),[S,R]=s(),O=e?.sendSolanaTransaction?.connection,W=e?.sendSolanaTransaction?.transactingWallet,M=e?.sendSolanaTransaction?.signOnly??!1,P=f?.instructions.length??1,L=W?.imported?Lr(p):wr(p),D=Er(O?.rpcEndpoint||""),{solPrice:U,isSolPriceLoading:F}=Ru({enabled:u}),B=i((()=>{let e,t;if(!f)return;let n=f.spender;0===E&&W?.address===n&&(e=Pu(f.fee));let r=Pu(b.value,3,!0),a=f.instructions[E];if(!a)return{fee:e,spender:n,balance:r};if("unknown"===a.type)return{fee:e,spender:n,program:a.program,balance:r};if("ata-creation"===a.type)return{fee:e,spender:n,balance:r,tokenAccountOwner:a.owner,tokenAccount:a.ata,tokenAddress:a.mint};let i=a.fromAccount,o="sol-transfer"===a.type?a.toAccount:a.toAccount||a.toAta,s="spl-transfer"===a.type?a.token.address:void 0;return null!=e&&"SOL"===a.token.symbol&&(t=Pu(a.value+f.fee)),{fee:e,spender:n,from:i,to:o,tokenAddress:s,amount:`${Ra(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}}),[f,E,W?.address,b]),z=i((()=>{let e,t;if(!f||!u||!U||F)return;function n(...e){return Lu(e.reduce(((e,t)=>e+t),0n),U??0)}0===E&&W?.address===f.spender&&(e=n(f.fee));let r=n(b.value),a=f.instructions[E];return a&&"unknown"!==a.type&&"ata-creation"!==a.type?(null!=e&&"SOL"===a.token.symbol&&(t=n(a.value,f.fee)),{fee:e,amount:"SOL"===a.token.symbol?n(a.value):`${Ra(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}):{fee:e,balance:r}}),[f,u,U,F,W?.address,E,b]),H=i((()=>{if(M||!f||b.isLoading||E>0)return!1;let e=f.instructions[E];if(!e)return!1;let t=0n;return W?.address===f.spender&&(t+=f.fee),"value"in e&&W?.address===e.fromAccount&&"SOL"===e.token.symbol&&(t+=e.value),b.value<t}),[f,b,E,M]);if(o((()=>{!async function(){if(y&&O&&l)try{C(void 0);let e=await Bu({tx:y,connection:O,client:l});w(e),T(0)}catch(e){console.error("Failed to prepare transaction",e),C(e)}}()}),[y,O,l]),o((()=>{(async function(){if(!W||!O)return;A({value:b.value,isLoading:!0});let e=new Bi({name:"mainnet-beta",rpcUrl:O.rpcEndpoint});A({value:await e.getBalance(W.address).catch((()=>0n))??0n,isLoading:!1})})().catch(console.error)}),[f,O]),!(y&&e?.sendSolanaTransaction&&W&&O)){let n=Error("Invalid transaction request");/*#__PURE__*/return t(cu,{error:n,onClick:()=>{e?.sendSolanaTransaction?.onFailure(n),c({shouldCallAuthOnSuccess:!1})}})}let V=()=>{if(!_)return I?e?.sendSolanaTransaction?.onSuccess(I):(e?.sendSolanaTransaction?.onFailure(S??v??Error("User exited the modal before submitting the transaction")),T(0)),c({shouldCallAuthOnSuccess:!1})};n.current=V;let $=e.sendSolanaTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/t("img",{src:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,j=!!(e.funding&&e.funding.supportedOptions.length>0),G=H&&j;return I?/*#__PURE__*/t(Cg,{instructions:f?.instructions.reduce(((e,t)=>("ata-creation"===t.type&&e.push({tokenAccountOwner:t.owner,tokenAccount:t.ata}),"spl-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount||t.toAta,amount:t.value,token:t.token}),"sol-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount,amount:t.value,token:t.token}),e)),[])??[],fees:0===E?I.fees:0n,onClose:V,transactionInfo:e.sendSolanaTransaction?.uiOptions.transactionInfo,solPrice:U,receiptHeader:e.sendSolanaTransaction?.uiOptions.successHeader,receiptDescription:e.sendSolanaTransaction?.uiOptions.successDescription,rpcEndpoint:O.rpcEndpoint,signOnly:M}):S?/*#__PURE__*/t(Qy,{transactionError:S,connection:O,onClose:V,network:"solana",onRetry:async()=>{R(void 0);let{blockhash:e}=await O.getLatestBlockhash();Uu(y)?y.message.recentBlockhash=e:y.recentBlockhash=e,g(y)}}):/*#__PURE__*/t(qy,{img:$,title:e.sendSolanaTransaction?.uiOptions?.transactionInfo?.title||"Confirm transaction",subtitle:e.sendSolanaTransaction?.uiOptions?.description||`${h.name} wants your permission to approve the following transaction.`,cta:G?"Add funds":e.sendSolanaTransaction?.uiOptions?.buttonText||"Approve",transactionIndex:E,maxIndex:P-1,network:"mainnet-beta"==D?"Solana":D,blockExplorerUrl:"https://explorer.solana.com",total:u?z?.total:B?.total,amount:u?z?.amount:B?.amount,fee:u?z?.fee:B?.fee,balance:u?z?.balance:B?.balance,from:B?.from,to:B?.to,tokenAccount:B?.tokenAccount,tokenAccountOwner:B?.tokenAccountOwner,tokenAddress:B?.tokenAddress,transactingWalletAddress:W.address,programAddress:B?.program,disabled:H&&!j,isSubmitting:_,isPreparing:!f||b.isLoading,isTokenPriceLoading:u&&F,isMissingFunds:H,submitError:S??void 0,parseError:v,onClick:G?async()=>{if(!W)return;if(!j)throw Error("Funding wallet is not enabled");let t=cr.FUNDING_METHOD_SELECTION_SCREEN;r({...e,funding:{...e.funding,methodScreen:t}}),a(t)}:async()=>{if(E<(f?.instructions.length??1)-1)T(E+1);else try{k(!0);let t=await m();if(_||!t||!W||!d||!p||!L)return;let{rootWallet:n}=Dr(p,W.address);if(!n)throw Error("No root wallet for transacting wallet found");let{entropyId:r,entropyIdVerifier:a}=jn(n);if(M)await Wy({tx:y,accessToken:t,walletProxy:d,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:W.address,transactingWalletIndex:W.walletIndex??0}),N(Fu("",y,null));else{let{signature:n,receipt:i}=await My({tx:y,accessToken:t,connection:O,walletProxy:d,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:W.address,transactingWalletIndex:W.walletIndex??0,transactionOptions:e.sendSolanaTransaction?.transactionOptions});N(Fu(n,y,i))}}catch(e){console.warn({transaction:y,error:e}),R(e)}finally{k(!1)}},onClose:V,onBack:E>0&&P>1?()=>T(E-1):void 0})},[cr.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN]:()=>{let{app:r,data:a}=lr(),{closePrivyModal:i}=x(),[l,c]=s(!1),[d,u]=s(),{address:h,onDelegate:p,onSuccess:m,onError:y}=a.delegatedActions.consent,g=async()=>{l?m():y(d??new T("User declined delegating actions.")),i({shouldCallAuthOnSuccess:!1})};return o((()=>{if(!l&&!d)return;let e=setTimeout(g,pr);return()=>clearTimeout(e)}),[l,d]),/*#__PURE__*/e(n,l||d?{children:[/*#__PURE__*/t(ot,{onClose:g}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(ht,{children:[d?/*#__PURE__*/t(ei,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(ci,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(It,{height:20}),/*#__PURE__*/t(Ql,{title:d?"Something went wrong":"Success!",description:d?"Please try again.":`You’ve successfully granted delegated action permissions to ${r.name}.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}:{children:[/*#__PURE__*/t(ot,{closeable:!0,onClose:g}),/*#__PURE__*/t(di,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(Nl,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),/*#__PURE__*/e(xl,{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:h,title:"Wallet",isLoading:!1}),/*#__PURE__*/e(Wc,{style:{marginTop:24},children:[/*#__PURE__*/t(dt,{onClick:g,children:"Not now"}),/*#__PURE__*/t(st,{onClick:async()=>{try{await p(),c(!0)}catch(e){u(e)}},children:"Accept"})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_DELEGATED_ACTIONS_REVOKE_SCREEN]:()=>{let{app:r,data:a}=lr(),{closePrivyModal:i}=x(),[l,c]=s(!1),[d,u]=s(),{onRevoke:h,onSuccess:p,onError:m}=a.delegatedActions.revoke,y=async()=>{l?p():m(d??new T("User declined revoking access to their delegated wallet.")),i({shouldCallAuthOnSuccess:!1})};return o((()=>{if(!l&&!d)return;let e=setTimeout(y,pr);return()=>clearTimeout(e)}),[l,d]),/*#__PURE__*/e(n,l||d?{children:[/*#__PURE__*/t(ot,{onClose:y}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(ht,{children:[d?/*#__PURE__*/t(ei,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(ci,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(It,{height:20}),/*#__PURE__*/t(Ql,{title:d?"Something went wrong":"Success!",description:d?"Please try again.":"You've successfully revoked permissions."})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}:{children:[/*#__PURE__*/t(ot,{closeable:!0,onClose:y}),/*#__PURE__*/t(ui,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(Nl,{style:{marginTop:24},children:"Revoke offline access to wallet"}),/*#__PURE__*/e(xl,{children:["By confirming, ",r.name," will no longer be able to use this wallet on your behalf when you are not online."]}),/*#__PURE__*/e(Pc,{style:{marginTop:24},children:[/*#__PURE__*/t(dt,{onClick:y,children:"Deny"}),/*#__PURE__*/t(st,{onClick:async()=>{try{await h(),c(!0)}catch(e){u(e)}},children:"Confirm"})]}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_METHOD_SELECTION_SCREEN]:()=>{let{wallets:r}=Tr(),{wallets:a}=oa(),{navigate:s,data:l,setModalData:c}=lr(),{client:d}=x(),u=dr(),h=l?.funding,p=Yh(np),m=Yh(rp),y="solana"===h.chainType,g=y?void 0:h,f=i((()=>((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",u=!!l||d&&Ii(Number(n.chain.id),d),h=!!l||d&&Ni(Number(n.chain.id),d),p=[];for(let o of(n.preferredCardProvider&&n.supportedOptions.sort((e=>e.provider===n.preferredCardProvider?-1:1)),n.supportedOptions))"card"===o.method&&"coinbase"===o.provider&&h&&p.push((()=>Xh(t,n,r,a,i,"buy"))),"card"===o.method&&"moonpay"===o.provider&&u&&d&&p.push((()=>ep(t,n,e,d,r,a,i,"credit_debit_card")));for(let e of n.supportedOptions)"exchange"===e.method&&"coinbase"===e.provider&&h&&(o=()=>Xh(t,n,r,a,i,"buy"));for(let e of i?.funding?.supportedOptions??[])"wallets"===e.method&&(s=()=>a(cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN));return{onFundWithCard:p,onFundWithExchange:o,onFundWithWallet:s}})(u,d,h,c,s,l)),[u,d,h,l,c,s]);o((()=>{if(h?.defaultFundingMethod&&h.usingDefaultFundingMethod)switch(c({funding:{...h,usingDefaultFundingMethod:!1}}),h?.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":s(cr.FUNDING_MANUAL_TRANSFER_SCREEN)}}),[]),o((()=>{g?.erc20Address&&!g.erc20ContractInfo&&ln({address:g.erc20Address,chain:g.chain,rpcConfig:u.rpcConfig,privyAppId:u.id}).then((e=>{c({...l,funding:{...g,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}})})).catch(console.error)}),[g?.erc20Address,g?.chain]);let w=y?a.find((({address:e})=>e===h.address)):r.find((({address:e})=>C(e)===C(h.address))),v=ft(w?.walletClientType||"unknown"),E=v?.name||"wallet",T=w&&"privy"!==w.walletClientType?E:u.name,b=!(!g?.erc20Address||g?.erc20ContractInfo);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/e("h3",{children:["Add funds to your"," ",T?.toLowerCase().endsWith("wallet")?T:T+" wallet"]}),/*#__PURE__*/e(bh,{children:[h.errorMessage&&/*#__PURE__*/t(Vh,{theme:u.appearance.palette.colorScheme,children:h.errorMessage}),f.onFundWithCard?.[0]&&/*#__PURE__*/e(il,{disabled:b,onClick:f.onFundWithCard[0],children:[/*#__PURE__*/t(Ah,{children:/*#__PURE__*/t(Qi,{style:{width:24}})}),"Pay with card",p?/*#__PURE__*/t(qh,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):m?/*#__PURE__*/t(Kh,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):null]}),f.onFundWithExchange&&/*#__PURE__*/e(il,{disabled:b,onClick:f.onFundWithExchange,children:[/*#__PURE__*/t(Ah,{children:/*#__PURE__*/t(Ji,{style:{width:24}})}),"Transfer from an exchange"]}),f.onFundWithWallet&&/*#__PURE__*/e(il,{disabled:b,onClick:f.onFundWithWallet,children:[/*#__PURE__*/t(Ah,{children:/*#__PURE__*/t(cn,{style:{width:24}})}),"Transfer from wallet"]}),/*#__PURE__*/e(il,{disabled:b,onClick:()=>s(cr.FUNDING_MANUAL_TRANSFER_SCREEN),children:[/*#__PURE__*/t(Ah,{children:/*#__PURE__*/t(Xi,{style:{width:24}})}),"Receive funds"]}),h?.showAlternateFundingMethod&&f.onFundWithCard?.[1]&&/*#__PURE__*/t(jh,{theme:u.appearance.palette.colorScheme,children:/*#__PURE__*/e(Rh,{children:["Having trouble or facing location restrictions?"," ",/*#__PURE__*/t(Oh,{onClick:f.onFundWithCard[1],children:"Try a different provider."})]})})]}),/*#__PURE__*/t(ct,{})]})},[cr.MOONPAY_STATUS_SCREEN]:()=>{let{app:r,data:a,setModalData:i,navigateBack:o}=lr(),{closePrivyModal:s}=x(),{externalTransactionId:l}=a?.moonpayStatus,c=la(l||null,r.fundingMethodConfig.moonpay.useSandbox??!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{title:"Fund account",backFn:()=>{let e={...a?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),i({funding:e}),o()}}),/*#__PURE__*/t(sp,{status:c,onClickCta:s}),/*#__PURE__*/t(ct,{})]})},[cr.COINBASE_ONRAMP_STATUS_SCREEN]:()=>{let{data:r,setModalData:a,navigate:i,navigateBack:c}=lr(),{closePrivyModal:d,createAnalyticsEvent:u,client:h}=x(),[p,m]=s("pending-in-flow"),y=l(0),g={...r?.funding,showAlternateFundingMethod:!0};g.usingDefaultFundingMethod&&(g.usingDefaultFundingMethod=!1);let{partnerUserId:f,popup:w}=r?.coinbaseOnrampStatus??{};return o((()=>{if("pending-in-flow"===p||"pending-after-flow"===p){let e=setInterval((async()=>{if(f)try{let{status:e}=await h.getCoinbaseOnRampStatus({partnerUserId:f});if("success"===e)return void m("success");if("failure"===e)throw Error("There was an error completing Coinbase Onramp flow.");if(y.current>=3)return a({funding:g}),void i(cr.FUNDING_METHOD_SELECTION_SCREEN);w?.closed&&(y.current=y.current+1,m("pending-after-flow"))}catch(e){console.error(e),m("error"),u({eventName:ia,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),a({funding:{...g,errorMessage:"Something went wrong adding funds. Please try again or use another method."}}),i(cr.FUNDING_METHOD_SELECTION_SCREEN)}}),1500);return()=>clearInterval(e)}}),[f,w,p]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{title:"Fund account",backFn:()=>{a({funding:g}),c()}},"header"),/*#__PURE__*/t(Fh,{status:p,onClickCta:d}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:()=>{let r,{connectors:a}=x(),{app:i,setModalData:l,data:c,navigate:d}=lr(),{wallets:u}=Tr(),{wallets:h}=oa(),[p,m]=s("default"),y="solana"===c?.funding?.chainType,g=!!c?.funding?.crossChainBridgingEnabled;r="ethereum"===c?.funding?.chainType?c.funding.erc20Address&&!c.funding.isUSDC?"ethereum-only":g&&!c.funding.chain.testnet?"ethereum-and-solana":"ethereum-only":g?"ethereum-and-solana":"solana-only";let f=u.filter((e=>"privy"!==e.walletClientType)),w=f.map((e=>e.walletClientType)),v=h.filter((e=>"privy"!==e.walletClientType)),C=v.map((e=>e.walletClientType)),E=[],T={...c.funding};T.usingDefaultFundingMethod&&(T.usingDefaultFundingMethod=!1);let b=({address:e,walletChainType:t})=>{l({...c,funding:{...T,connectedWalletAddress:e,onContinueWithExternalWallet:()=>d(_({destChainType:y?"solana":"ethereum",sourceChainType:t}))}}),d(cr.FUNDING_EDIT_AMOUNT_SCREEN)};"solana-only"!==r&&E.push(...f.map(((e,n)=>/*#__PURE__*/t(hp,{onClick:()=>b({address:e.address,walletChainType:"ethereum"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),"ethereum-only"!==r&&E.push(...v.map(((e,n)=>/*#__PURE__*/t(hp,{onClick:()=>b({address:e.address,walletChainType:"solana"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),E.push(...xc({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 A=/*#__PURE__*/t(up,{text:"More wallets",onClick:()=>m("overflow")}),_=({sourceChainType:e,destChainType:t})=>"ethereum"===e&&"solana"===t?cr.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN:"ethereum"===e&&"ethereum"===t?cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN:"solana"===e&&"ethereum"===t?cr.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN:cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN;return o((()=>{l({...c,externalConnectWallet:{onCompleteNavigateTo:({walletChainType:e})=>(l({...c,funding:{...T,onContinueWithExternalWallet:()=>{d(_({destChainType:y?"solana":"ethereum",sourceChainType:e??"ethereum"}))}}}),cr.FUNDING_EDIT_AMOUNT_SCREEN)}})}),[]),/*#__PURE__*/e(n,"overflow"===p?{children:[/*#__PURE__*/t(ot,{backFn:()=>m("default")},"header"),/*#__PURE__*/e(tl,{children:[/*#__PURE__*/t(Rt,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),E]}),/*#__PURE__*/t(ct,{})]}:{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(Ql,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),/*#__PURE__*/e(tl,{children:[E.length>4?E.slice(0,3):E,E.length>4&&A]}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_EDIT_AMOUNT_SCREEN]:()=>{let{data:r,setModalData:a}=lr(),i=r?.funding,o="solana"===i.chainType,s=l(null),{tokenPrice:c}=Ou(o?"solana":i.chain.id),d=o?void 0:i,u=!(!d?.erc20Address||d?.erc20ContractInfo),h=o?"SOL":i.erc20Address?i.erc20ContractInfo?.symbol:i.chain.nativeCurrency.symbol||"ETH",p=parseFloat(i.amount),m=!isNaN(p)&&p>0,y=c?en(i.amount,c):void 0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(St,{children:"Confirm or edit amount"}),/*#__PURE__*/e(sn,{style:{marginTop:"32px"},children:[/*#__PURE__*/t(_h,{children:u?/*#__PURE__*/t(ku,{size:"50px"}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(kh,{onClick:()=>s.current?.focus(),children:[/*#__PURE__*/t(Nh,{ref:s,value:i.amount,onChange:e=>{let t=e.target.value;/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1&&a({...r,funding:{...i,amount:t}})}}),/*#__PURE__*/t(xh,{children:h})]}),!d?.erc20Address&&/*#__PURE__*/t(Sh,{children:y&&m?`${y} USD`:""})]})}),/*#__PURE__*/t(Jt,{style:{marginTop:"1rem"},disabled:!m,onClick:i.onContinueWithExternalWallet,children:"Continue"})]}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:l}=x(),{navigate:c,setModalData:d,app:u,data:h}=lr(),{wallets:p}=Tr(),[m,y]=s(!1),[g,f]=s(0n),[w,v]=s(!1),[C,E]=s(null),[b,_]=s(null),[k,I]=s([]),[N,S]=s(0),[R,O]=s(!1),[W,M]=s(!1),[P,L]=s(!1),[D,U]=s(!1),[F,B]=s(),[z,H]=s();if(!h?.funding||"ethereum"!==h.funding.chainType)throw Error("Invalid funding data");let{erc20ContractInfo:V,chain:$,connectedWalletAddress:j}=h.funding,G=h.funding.address,q=h.funding.erc20Address,[K,Y]=s(h.funding.amount);o((()=>{q&&!V&&E(Error("Unable to fetch token details"))}),[]);let Z=!!q&&!!V,J=Z?BigInt(parseFloat(K)*10**V.decimals):Oa(K),Q=j?p.find((({address:e})=>e===j)):p[0],X=ft(Q?.walletClientType||"unknown"),ee=X?.name||"wallet",[te,ne]=s(null);o((()=>{(async()=>{if(!Q)return;let e=await Q.getEthereumProvider();ne(Na({account:Q.address,transport:xa(e)}).extend(Sa))})().catch(console.error)}),[Q]);let[re,ae]=s(0n);o((()=>{ka({chain:$,transport:Ia(Va($,r,a))}).getBalance({address:G}).then(ae).catch(console.error)}),[]);let[ie,oe]=s(0n);o((()=>{Z&&Xt({chain:$,address:G,appId:a,rpcConfig:r,erc20Address:q}).then((e=>oe(e.balance))).catch(console.error)}),[]);let{tokenPrice:se}=Ou($.id),[le,ce]=s({to:G,chain:$,value:J,data:void 0});o((()=>{(async()=>{let e,t;if(!te||!Q||R||P)return;O(!0);let n=ka({chain:le.chain,transport:Ia(Va(le.chain,r,a))});if(Z&&!le.data)return await n.simulateContract({address:q,chain:le.chain,abi:Uh,functionName:"transfer",args:[G,J],account:Q.address}).catch((e=>{console.warn("Simulated token transfer failed with error, fetching bridge options.",e)}))?(O(!1),void ce({to:q,chain:le.chain,data:Wa({abi:Uh,functionName:"transfer",args:[G,J]}),value:"0x0"})):(O(!1),void v(!0));try{e=await n.prepareTransactionRequest({account:Q.address,to:le.to,chain:le.chain,data:le.data,value:BigInt(le.value??0)})}catch(e){if(console.error(e),k.length>1)_(e.shortMessage??"Something went wrong");else if(W&&0===k.length)return void E(new T(`Wallet ${Ct(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))}if(!e)return O(!1),void v(!0);O(!1),L(!0),y(!0),f(e.gas);try{await te.switchChain({id:le.chain.id})}catch(e){await te.addChain({chain:le.chain}),await te.switchChain({id:le.chain.id})}try{t=await te.sendTransaction(e)}catch(e){if(console.error(e),"TransactionExecutionError"===e.name)if(k.length<1){let t=e.shortMessage;(e.shortMessage.includes("rejected the request")||e.details.includes("rejected the request"))&&(t="User rejected the request."),E(new T(t,void 0,A.TRANSACTION_FAILURE))}else _(e.shortMessage??"Something went wrong")}if(t)return await te.waitForTransactionReceipt({hash:t}),L(!1),W?(B(t),void H("pending")):(U(!0),void l({eventName:ia,payload:{provider:"external",status:"success",txHash:t,address:Q.address,chainId:le.chain.id,chainType:"ethereum",value:le.value?Ra(BigInt(le.value),V?.decimals??18):void 0,token:V?.symbol??q??"ETH",destinationAddress:G,destinationChainId:$.id,destinationChainType:"ethereum",destinationValue:J?Ra(J,V?.decimals??18):void 0,destinationToken:V?.symbol??q??$.nativeCurrency.name}}));L(!1)})().catch(console.error)}),[te,le]),o((()=>{(async()=>{if(!w||!te||!Q)return;let e=vr(u.chains).filter((e=>e.id!==$.id&&!!e.testnet==!!$.testnet));Z&&e.unshift($);let t=await $u({chains:e,address:Q.address,appId:a,rpcConfig:r}),n=Z?t.filter((e=>e.balance>0n)):t.filter((e=>e.balance>J));if(n.length<1)return void E(new T(`Wallet ${Ct(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({quote:await iu({isTestnet:!!$.testnet,input:nu({amount:J.toString(),user:Q.address,recipient:G,destinationChainId:$.id,destinationCurrency:q,originChainId:e.chain.id})}),...e}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void E(new T(`Wallet ${Ct(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));let o=i.map((e=>({bridgeTx:ou(e.quote),balance:e.balance,chain:e.chain}))).filter((e=>!!e.bridgeTx));if(o.length>1)return void I(o);let s=o[0];s?(M(!0),ce({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):E(new T(`Wallet ${Ct(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))})().catch(console.error)}),[w]),su({transactionHash:F,wallet:Q,isTestnet:!!$.testnet,bridgingStatus:z,setBridgingStatus:H,onSuccess({transactionHash:e,wallet:t}){M(!1),U(!0),l({eventName:ia,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:le.chain.id,chainType:"ethereum",value:le.value?Ra(BigInt(le.value),V?.decimals??18):void 0,token:V?.symbol??q??"ETH",destinationAddress:G,destinationChainId:$.id,destinationChainType:"ethereum",destinationValue:J?Ra(J,V?.decimals??18):void 0,destinationToken:V?.symbol??q??$.nativeCurrency.name}})},onFailure({error:e}){M(!1),E(e)}}),o((()=>{if(!C)return;let e={error:C,previousScreen:cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN};d({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),c(cr.ERROR_SCREEN,!1)}),[C]);let de=!Z&&se?en(K??"0",se):void 0,ue=Z?g:rn([g,J]),he=ue&&se?tn(ue,se):void 0,pe=ue?Yt(ue,"ETH"):void 0,me=g&&se?tn(g,se):void 0,ye=g?Yt(g,"ETH"):void 0;if(o((()=>{if(!D)return;let e=setTimeout(i,_r);return()=>clearTimeout(e)}),[D]),D/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success!",description:`You’ve successfully added ${K} ${Z?V.symbol:$.nativeCurrency.symbol} to your ${u.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let ge=Z?`${nn({amount:ie,decimals:V.decimals})} ${V.symbol}`:Yt(re,$.nativeCurrency.symbol,3,!0),fe=k[N];return k.length>1&&fe?/*#__PURE__*/t(Wh,{displayName:ee,configuredFundingChain:$,formattedBalance:ge,fundingAmount:K,fundingCurrency:Z?V.symbol:$.nativeCurrency.symbol,fundingAmountInUsd:de,options:k,selectedOption:fe,isPreparing:R,isSubmitting:P,addressToFund:G,fundingWalletAddress:Q?.address||"",errorMessage:b,onSubmit:()=>{h.funding?.amount!==K?async function(){if(Q&&fe)try{let e=await iu({isTestnet:!!$.testnet,input:nu({amount:J.toString(),user:Q.address,recipient:G,destinationChainId:$.id,destinationCurrency:q,originChainId:fe.chain.id})}),t=ou(e);if(!t)throw Error("Invalid transaction request");M(!0),ce({data:t.data,to:t.to,value:t.value,chain:fe.chain})}catch(e){console.error(e),E(new T("Unable to fetch quotes for bridging",e,A.INSUFFICIENT_BALANCE))}}().catch(console.error):ce({to:fe.bridgeTx.to,data:fe.bridgeTx.data,value:fe.bridgeTx.value,chain:fe.chain})},onSelect:e=>{e!==N&&(_(null),S(e))},onAmountChange:Y}):m&&g&&Q&&h?.funding?/*#__PURE__*/t(Mh,{wallet:Q,displayName:ee,addressToFund:G,isBridging:W,isErc20Flow:Z,totalPriceInUsd:he,totalPriceInNativeCurrency:pe,gasPriceInUsd:me,gasPriceInNativeCurrency:ye,chainId:$.id,chainName:$.name}):
16
- /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(ku,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN]:()=>{let{closePrivyModal:r,createAnalyticsEvent:a}=x(),{navigate:i,setModalData:c,app:d,data:u}=lr(),{wallets:h}=oa(),p=ra(),[m,y]=s(0n),[g,f]=s(null),[w,v]=s(!1),[C,E]=s(!1),b=l(!1);if(!u?.funding||"solana"!==u.funding.chainType)throw Error("Invalid funding data");let{address:_,amount:k,cluster:I,connectedWalletAddress:N}=u.funding,S=kr(I),{tokenPrice:R}=Ou("solana"),{fundingAmountInBaseUnit:O,totalPriceInUsd:W,totalPriceInNativeCurrency:M,feePriceInNativeCurrency:P,feePriceInUsd:L}=Du({amount:k,fee:m,tokenPrice:R}),D=N?h.find((({address:e})=>e===N)):h[0],U=ft(D?.walletClientType||"unknown"),F=U?.name||"wallet";return o((()=>{(async()=>{if("solana"===D?.type&&D.sendTransaction&&!w&&!b.current){b.current=!0;try{let e=p(aa);if(!e)throw new T("Unable to load solana plugin");let{connection:t,transaction:n}=await e.createTransferTransaction({from:D.address,to:_,amount:O,cluster:I}),r=await n.getEstimatedFee(t);null!=r&&y(BigInt(r)),v(!0);let i=await t.simulateTransaction(n);if(i.value.err)return i.value.logs?.find((e=>/insufficient (lamports|funds)/gi.test(e)))?void f(new T(`Wallet ${Ct(D.address,void 0,void 0,"solana")} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",i.value.err),void f(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE)));let o=await D.sendTransaction(n,t);a({eventName:ia,payload:{provider:"external",status:"success",txHash:o,rpcEndpoint:S,address:D.address,value:Ra(O,9),chainType:"solana",clusterName:I.name,token:"SOL",destinationAddress:_,destinationValue:Ra(O,9),destinationChainType:"solana",destinationClusterName:I.name,destinationToken:"SOL"}}),v(!1),E(!0)}catch(e){if(console.error(e),v(!1),/user rejected the request/gi.test(e.message||""))return void f(new T("Transaction was rejected by the user",void 0,A.TRANSACTION_FAILURE));f(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE))}}})().catch(console.error).finally((()=>b.current=!1))}),[]),o((()=>{if(!g)return;let e={error:g,previousScreen:cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:u?.funding,sendTransaction:u?.sendTransaction,errorModalData:e}),i(cr.ERROR_SCREEN,!1)}),[g]),o((()=>{if(!C)return;let e=setTimeout(r,_r);return()=>clearTimeout(e)}),[C]),C?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success!",description:`You’ve successfully added ${k} SOL to your ${d.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}):D&&w?/*#__PURE__*/t(Mh,{wallet:D,displayName:F,addressToFund:_,isBridging:!1,isErc20Flow:!1,totalPriceInUsd:W,totalPriceInNativeCurrency:M,gasPriceInUsd:L,gasPriceInNativeCurrency:P,chainId:"solana",chainName:I.name}):
17
- /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(ku,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN]:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:l}=x(),{navigate:c,setModalData:d,app:u,data:h}=lr(),{wallets:p}=Tr(),m=ra(),[y,g]=s(null),[f,w]=s(null),[v,C]=s([]),[E,b]=s(0),[_,k]=s(!1),[I,N]=s(!1),[S,R]=s(!1),[O,W]=s(!1),[M,P]=s(),[L,D]=s();if(!h?.funding||"solana"!==h.funding.chainType)throw Error("Invalid funding data");let{address:U,cluster:F,connectedWalletAddress:B}=h.funding,[z,H]=s(h.funding.amount),V=B?p.find((({address:e})=>e===B)):p[0],$=ft(V?.walletClientType||"unknown"),j=$?.name||"wallet",[G,q]=s(null);o((()=>{(async()=>{if(!V)return;let e=await V.getEthereumProvider();q(Na({account:V.address,transport:xa(e)}).extend(Sa))})().catch(console.error)}),[V]);let[K,Y]=s(0n),Z=Pu(K);o((()=>{let e=m(aa);e?e.getBalance({address:U,cluster:F}).then((e=>Y(BigInt(e)))):console.warn("Unable to load solana plugin, skipping balance")}),[]);let[J,Q]=s(),{tokenPrice:X}=Ou("solana"),{fundingAmountInBaseUnit:ee,fundingAmountInUsd:te}=Du({amount:z,fee:0n,tokenPrice:X});if(o((()=>{(async()=>{if(!G||!V)return;let e=["testnet","devnet"].includes(F.name);e&&console.warn("Solana testnets are not supported for bridging");let t=vr(u.chains).filter((({testnet:t})=>!!t===e)),n=(await $u({chains:t,address:V.address,appId:a,rpcConfig:r})).filter((e=>e.balance>0n));if(n.length<1)return void g(new T(`Wallet ${Ct(V.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({...e,quote:await iu({isTestnet:!1,input:nu({amount:ee.toString(),user:V.address,recipient:U,destinationChainId:br,destinationCurrency:Ar,originChainId:e.chain.id})})}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void g(new T(`Unable to fetch quotes for bridging. Wallet ${Ct(V.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));let o=i.map((({quote:e,balance:t,chain:n})=>({bridgeTx:ou(e),balance:t,chain:n}))).filter((({bridgeTx:e})=>!!e));if(o.length>1)return void C(o);let s=o.at(0);s?(N(!0),Q({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):g(new T(`Unable to select bridge option from quotes. Wallet ${Ct(V.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))})().catch(console.error)}),[G]),o((()=>{(async()=>{let e,t;if(!G||!V||_||S||!J)return;k(!0);let n=ka({chain:J.chain,transport:Ia(Va(J.chain,r,a))});try{e=await n.prepareTransactionRequest({account:V.address,to:J.to,chain:J.chain,data:J.data,value:BigInt(J.value??0)})}catch(e){console.error(e),v.length>1&&w(e.shortMessage??"Something went wrong")}if(e){k(!1),R(!0);try{await G.switchChain({id:J.chain.id})}catch(e){await G.addChain({chain:J.chain}),await G.switchChain({id:J.chain.id})}try{t=await G.sendTransaction(e)}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(v.length<1?g(new T(e.shortMessage,void 0,A.TRANSACTION_FAILURE)):w(e.shortMessage??"Something went wrong"))}if(t)return await G.waitForTransactionReceipt({hash:t}),I?(D("pending"),void P(t)):(R(!1),W(!0),void l({eventName:ia,payload:{provider:"external",status:"success",txHash:t,address:V.address,chainId:J.chain.id,chainType:"ethereum",value:J.value?Ra(BigInt(J.value),18):void 0,token:"ETH",destination:U,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ra(ee,9),destinationToken:"SOL"}}));R(!1)}else k(!1)})().catch(console.error)}),[G,J]),su({transactionHash:M,wallet:V,isTestnet:!1,bridgingStatus:L,setBridgingStatus:D,onSuccess({transactionHash:e,wallet:t}){N(!1),W(!0),l({eventName:ia,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:J?.chain.id,chainType:"ethereum",value:J?.value?Ra(BigInt(J.value),18):void 0,token:"ETH",destination:U,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ra(ee,9),destinationToken:"SOL"}})},onFailure({error:e}){N(!1),g(e)}}),o((()=>{if(!y)return;let e={error:y,previousScreen:cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN};d({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),c(cr.ERROR_SCREEN,!1)}),[y]),o((()=>{if(!O)return;let e=setTimeout(i,_r);return()=>clearTimeout(e)}),[O]),O/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success!",description:`You’ve successfully added ${z} SOL to your ${u.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let ne=v[E];return v.length>1&&ne?/*#__PURE__*/t(Wh,{displayName:j,configuredFundingChain:F,formattedBalance:Z,fundingAmount:z,fundingCurrency:"SOL",fundingAmountInUsd:te,options:v,selectedOption:ne,isPreparing:_,isSubmitting:S,addressToFund:U,fundingWalletAddress:V?.address||"",errorMessage:f,onSubmit:()=>{h.funding?.amount!==z?async function(){if(V&&ne)try{let e=await iu({isTestnet:!1,input:nu({amount:ee.toString(),user:V.address,recipient:U,destinationChainId:br,destinationCurrency:Ar,originChainId:ne.chain.id})}),t=ou(e);if(!t)throw Error("Invalid transaction request");N(!0),Q({data:t.data,to:t.to,value:t.value,chain:ne.chain})}catch(e){console.error(e),g(new T("Unable to fetch quotes for bridging",e,A.INSUFFICIENT_BALANCE))}}().catch(console.error):Q({to:ne.bridgeTx.to,data:ne.bridgeTx.data,value:ne.bridgeTx.value,chain:ne.chain})},onSelect:e=>{e!==E&&(w(null),b(e))},onAmountChange:H}):S&&V?/*#__PURE__*/t(Mh,{wallet:V,displayName:j,addressToFund:U,isBridging:I,isErc20Flow:!1,chainId:"solana",chainName:F.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
18
- /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(ku,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN]:function(){let{closePrivyModal:r,createAnalyticsEvent:a}=x(),{navigate:i,setModalData:c,app:d,data:u}=lr(),{wallets:h}=oa(),p=l(!1),m=ra(),[y,g]=s(!1),[f,w]=s(!1),[v,C]=s(null),[E,b]=s(),[_,k]=s();if(!u?.funding||"ethereum"!==u.funding.chainType)throw Error("Invalid funding data");let{amount:I,connectedWalletAddress:N,chain:S,cluster:R,isUSDC:O}=u.funding,W=u.funding.address,M=u.funding.erc20Address,P=u.funding.isUSDC?"USDC":S.nativeCurrency.symbol,L=R??{name:"mainnet-beta"},D=N?h.find((({address:e})=>e===N)):h[0],U=ft(D?.walletClientType||"unknown"),F=U?.name||"wallet";return o((()=>{(async function(){if(!D||!S||p.current)return;let e=m(aa);if(!e)return void C(new T("Unable to solana plugin"));p.current=!0,S?.testnet&&console.warn("Solana testnets are not supported for bridging");let t=O?1e6*parseFloat(I):Oa(I),n=await iu({isTestnet:!!S.testnet,input:nu({amount:t.toString(),user:D.address,recipient:W,destinationChainId:S.id,originChainId:br,originCurrency:O?Ir:Ar,destinationCurrency:O?M:void 0})}).catch(console.error);if(!n)return void C(new T(`Unable to fetch quotes for bridging. Wallet ${an(D.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));let r=await e.createBridgeTransactionFromRelayQuote({quote:n,from:D.address,cluster:L});if(r)try{g(!0);let{connection:e,transaction:t}=r,a=await e.simulateTransaction(t);if(a.value.err)return a.value.logs?.find((e=>/insufficient (lamports|funds)/gi.test(e)))?void C(new T(`Wallet ${an(D?.address)} does not have enough funds. ${n.details.currencyIn.amountFormatted} ${P} are needed to complete the transaction.`,void 0,A.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",a.value.err),void C(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE)));let i=await D.sendTransaction(t,e),o=await e.confirmTransaction(i);if(o.value.err)return console.error("Transaction failed:",o.value.err),void C(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE));b(i),k("pending")}catch(e){if(console.error(e),/user rejected the request/gi.test(e.message||""))return void C(new T("Transaction was rejected by the user",void 0,A.TRANSACTION_FAILURE));C(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE))}else C(new T(`Unable to select bridge option from quotes. Wallet ${an(D.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))})().catch(console.error)}),[]),su({transactionHash:E,wallet:D,isTestnet:!1,bridgingStatus:_,setBridgingStatus:k,onSuccess({transactionHash:e,wallet:t}){g(!1),w(!0),a({eventName:ia,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainType:"solana",clusterName:L.name,token:"SOL",destinationAddress:W,destinationChainId:S.id,destinationChainType:"ethereum",destinationValue:I,destinationToken:O?"USDC":"ETH"}})},onFailure({error:e}){g(!1),C(e)}}),o((()=>{if(!f)return;let e=setTimeout(r,_r);return()=>clearTimeout(e)}),[f]),o((()=>{if(!v)return;let e={error:v,previousScreen:cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:u?.funding,sendTransaction:u?.sendTransaction,errorModalData:e}),i(cr.ERROR_SCREEN,!1)}),[v]),f?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success!",description:`You’ve successfully added ${I} ${P} to your ${d.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}):y&&D?/*#__PURE__*/t(Mh,{wallet:D,displayName:F,addressToFund:W,isBridging:y,isErc20Flow:!1,chainId:S.id,chainName:S.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
19
- /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_u,{}),/*#__PURE__*/t(ku,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_MANUAL_TRANSFER_SCREEN]:()=>{let{wallets:r}=Tr(),{wallets:a}=oa(),{data:l,setModalData:c,navigate:d,lastScreen:u}=lr(),{rpcConfig:h,appId:p,createAnalyticsEvent:m,closePrivyModal:y}=x(),g=dr(),[f,w]=s(void 0),[v,C]=s(!1),E=ra(),T=l?.funding,{reloadBalance:b}=dn({rpcConfig:h,appId:p,address:"ethereum"===T.chainType?T.address:void 0,chain:"ethereum"===T.chainType?T.chain:void 0}),A="solana"===T.chainType,_=A?"SOL":T.erc20Address?T.erc20ContractInfo?.symbol:T.chain.nativeCurrency.symbol,k=A?a.find((({address:e})=>e===T.address)):r.find((({address:e})=>Ct(e)===Ct(T.address)));if(!T)return c({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:u||cr.FUNDING_METHOD_SELECTION_SCREEN},funding:l?.funding,sendTransaction:l?.sendTransaction}),d(cr.ERROR_SCREEN),/*#__PURE__*/t(n,{});o((()=>{let e=A?async function(){if("solana"!==T.chainType)return;let e=E(aa);e?e.getBalance({address:T.address,cluster:T.cluster}).then((e=>{let t=BigInt(e);f&&t>f&&(C(!0),m({eventName:ia,payload:{provider:"manual",status:"success",chainType:"solana",address:k?.address,value:Ra(t-f,9),token:"SOL"}})),w(t)})):console.warn("Unable to load solana plugin, skipping balance")}:async function(){"ethereum"===T.chainType&&(async()=>{if(!T.erc20Address)return await b()??BigInt(0);{let{balance:e}=await Xt({chain:T.chain,address:T.address,erc20Address:T.erc20Address,rpcConfig:h,appId:p});return e}})().then((e=>{f&&e>f&&(C(!0),m({eventName:ia,payload:{provider:"manual",status:"success",chainType:"ethereum",address:k?.address,chainId:T.chain.id,value:Ra(e-f,T.erc20ContractInfo?.decimals??18),token:T.erc20ContractInfo?.symbol??T.erc20Address??"ETH"}})),w(e)})).catch((()=>w(void 0)))},t=setInterval(e,2e3);return e(),()=>clearInterval(t)}),[f]);let I=i((()=>void 0!==f&&f>=parseFloat(T.amount)),[f,T.amount]),N=i((()=>null==f?"":T.isUSDC?xi({amount:f,decimals:6}):A?Pu(f,3,!0,!0):null!=T.erc20ContractInfo?.decimals?xi({amount:f,decimals:T.erc20ContractInfo.decimals}):Si({wei:f})),[f,A,T]),S="ethereum"===T.chainType?T.chain.name:ip[T.cluster.name],R=i((()=>""===T.uiConfig?.receiveFundsTitle?null:/*#__PURE__*/t(St,{children:T.uiConfig?.receiveFundsTitle??`Receive ${T.amount} ${_??""}`.trim()})),[T.uiConfig?.receiveFundsTitle,T.amount,_]),O=i((()=>""===T.uiConfig?.receiveFundsSubtitle?null:/*#__PURE__*/t(Rt,{children:T.uiConfig?.receiveFundsSubtitle??`Scan this code or copy your wallet address to receive funds on ${S}.`})),[T.uiConfig?.receiveFundsSubtitle,S]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_u,{}),R,O,/*#__PURE__*/e(sn,{style:{gap:"1rem",margin:R||O?"1rem 0":"0"},children:[/*#__PURE__*/t(zt,{url:`${T.chainType}:${T.address}`,size:200,squareLogoElement:ap}),/*#__PURE__*/e(jh,{theme:g.appearance.palette.colorScheme,children:["Make sure to send funds on ",S,"."]}),/*#__PURE__*/t(Nt,{title:"Your wallet",errMsg:void 0,showIcon:!0,isLoading:!T||void 0===f,isPulsing:!I,balance:`${N} ${_}`,address:T.address,statusColor:I?"green":"gray"}),v&&/*#__PURE__*/t(st,{onClick:()=>y({shouldCallAuthOnSuccess:!1,isSuccess:!0}),children:"Continue"})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN]:()=>{let{closePrivyModal:r}=x(),{data:a,setModalData:i,navigate:o,onUserCloseViaDialogOrKeybindRef:s}=lr(),{onSuccess:l,onFailure:c}=a.setWalletPassword,d=()=>{c(new R("Exited before password was added to wallet")),r({shouldCallAuthOnSuccess:!1})};return s.current=d,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:d}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/e(Lt,{children:[/*#__PURE__*/t(Ti,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),/*#__PURE__*/t(Dt,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:/*#__PURE__*/t(bi,{width:"12px",height:"12px",fill:"white"})})]}),/*#__PURE__*/e(Ql,{title:"Secure Your Account",children:["Please set a password to secure your account.",/*#__PURE__*/t("p",{children:"Losing access to this password and this device will make your account inaccessible."})]})]}),/*#__PURE__*/t(st,{onClick:()=>{i({createWallet:{onFailure:c,onSuccess:l,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),o(cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN)},children:"Add password"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN]:()=>{let[e,n]=s(null),[r,a]=s(!1),[i,l]=s(null),[c,d]=s(""),{authenticated:u,getAccessToken:h,user:p}=ur(),{walletProxy:m,refreshSessionAndUser:y,closePrivyModal:g,createAnalyticsEvent:f}=x(),{app:w,navigate:v,data:C,onUserCloseViaDialogOrKeybindRef:E}=lr(),{onSuccess:T,onFailure:b}=C.createWallet,A=wr(p),_="user-passcode"===e?.recoveryMethod,k="user-passcode"===A?.recoveryMethod;o((()=>{u||(v(cr.LANDING),b(new O("User must be authenticated before setting a password on a Privy wallet")))}),[u]);let I=()=>i?(b(i),void g({shouldCallAuthOnSuccess:!1})):_?(T(e),void g({shouldCallAuthOnSuccess:!1})):(b(new R("Exited before password was added to wallet")),void g({shouldCallAuthOnSuccess:!1}));E.current=I;/*#__PURE__*/return t(eu,{appName:w?.name||"privy",config:{initiatedBy:"user",onCancel:I},error:i?"An error has occurred, please try again.":void 0,buttonLoading:r,buttonHideAnimations:!1,password:c,isResettingPassword:k,onPasswordGenerate:()=>d($d()),onPasswordChange:d,onSubmit:async()=>{_?(T(e),g({shouldCallAuthOnSuccess:!1})):(a(!0),l(null),await(async()=>{let e=await h();if(e&&A?.address&&c&&m)try{f({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k}});let{entropyId:t,entropyIdVerifier:r}=jn(A);if(!(await m.setRecovery({accessToken:e,entropyId:t,entropyIdVerifier:r,recoveryPassword:c,recoveryMethod:"user-passcode"})).entropyId)return l(new R("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k,reason:"error setting password"}});let a=await y(),i=wr(a);if(!i)return l(new R("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k,reason:"wallet disconnected"}});n(i),f({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k}})}catch(e){console.warn(e),l(e instanceof Error?e:Error("Error setting password on privy wallet")),f({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:A.address,reason:e}})}})(),a(!1))},onClose:I})},[cr.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN]:()=>{let{app:e,navigate:n,data:r,onUserCloseViaDialogOrKeybindRef:a}=lr(),[i,l]=s(""),[c,d]=s(!1),[u,h]=s(),[p,m]=s(null),{authenticated:y,user:g}=ur(),{closePrivyModal:f,isNewUserThisSession:w,initializeWalletProxy:v}=x(),{onSuccess:C,onFailure:E,callAuthOnSuccessOnClose:T}=r.createWallet,{createWallet:b}=cd(),[A,_]=s(null),k=new Ge((async()=>{try{let e=await b({recoveryPassword:u,user:g});if(!e)return;_(e),w?n(cr.EMBEDDED_WALLET_CREATED_SCREEN):(C(e),f({shouldCallAuthOnSuccess:T}))}catch(e){l(e.message)}}));o((()=>{p||v(3e4).then((e=>m(e)))}),[p]),o((()=>{if(!y||!g)return n(cr.LANDING),void E(Error("User must be authenticated before creating a Privy wallet"))}),[y]),a.current=()=>null;/*#__PURE__*/return t(eu,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:!p,buttonLoading:c,buttonHideAnimations:!A&&c,isResettingPassword:!1,error:i,password:u||"",onClose:()=>{A&&"user-passcode"!==A?.recoveryMethod?(E(new R("User created a wallet but failed to set a password for it")),f({shouldCallAuthOnSuccess:!1})):A?(C(A),f({shouldCallAuthOnSuccess:T})):(E(new R("User wallet creation failed")),f({shouldCallAuthOnSuccess:!1}))},onPasswordChange:h,onPasswordGenerate:()=>h($d()),onSubmit:async()=>(d(!0),k.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>d(!1))))})},[cr.MFA_ENROLLMENT_FLOW_SCREEN]:()=>{let{user:r,enrollInMfa:a}=ur(),[i,l]=s(null),{unenrollWithSms:c,unenrollWithTotp:d,unenrollWithPasskey:u}=im(),{app:h,ready:p,data:m,onUserCloseViaDialogOrKeybindRef:y}=lr(),{closePrivyModal:g}=x(),{promptMfa:f}=am(),{initEnrollmentWithTotp:w}=im(),[v,C]=s(!1),[E,T]=s(null),[b,A]=s(null),_=()=>{g({shouldCallAuthOnSuccess:!0}),a(!1),setTimeout((()=>{l(null),T(null)}),500)},{initEnrollmentWithPasskey:k,submitEnrollmentWithPasskey:I}=im(),[N,S]=s(!1),[R,O]=s(null);y.current=_;let W=r?.mfaMethods.includes("sms"),M=!!r?.phone,P=r?.mfaMethods.includes("totp"),L=r?.mfaMethods.includes("passkey"),D=W||P||L,U=r?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function F(){l(null),T(null)}if(o((()=>{D&&C(!0)}),[D]),!p||!r||!h/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(ot,{onClose:_},"header"),/*#__PURE__*/t(Il,{children:/*#__PURE__*/t(om,{})}),/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(Ht,{})}),/*#__PURE__*/t(yt,{})]});if("sms"===i)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ja,{})}),/*#__PURE__*/t(Nl,{children:"Remove SMS verification?"}),/*#__PURE__*/e(xl,{children:["MFA adds an extra layer of security to your ",h?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{warn:!0,onClick:async function(){l(null);try{await c()}catch(e){l(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/t(yt,{})]});if("totp"===i)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ja,{})}),/*#__PURE__*/t(Nl,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e(xl,{children:["MFA adds an extra layer of security to your ",h?.name," account. Make sure you have other methods to secure your account."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{warn:!0,onClick:async function(){l(null);try{await d()}catch(e){l(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/t(yt,{})]});if("passkey"===i){let r=m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ja,{})}),/*#__PURE__*/t(Nl,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/t(xl,{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(Ml,{children:/*#__PURE__*/t(st,{warn:!0,onClick:async function(){l(null);try{await u({removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){l(null)}},children:"Yes, remove"})}),/*#__PURE__*/t(yt,{})]})}if(0===m.mfaEnrollmentFlow.mfaMethods.length&&!D)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(Nl,{children:"Add more security"}),/*#__PURE__*/e(xl,{children:[h?.name," does not have any verification methods enabled."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:_,children:"Close"})}),/*#__PURE__*/t(yt,{})]});let B=!D&&!v;return B?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(Nl,{children:"Transaction Protection"}),/*#__PURE__*/t(xl,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(io,{})}),"Enable 2-Step verification for your ",h?.name," wallet."]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(so,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(st,{onClick:()=>C(!0),children:"Continue"}),/*#__PURE__*/t(dt,{onClick:_,children:"Not now"})]}),/*#__PURE__*/t(yt,{})]}):"sms"===E?/*#__PURE__*/t(Im,{appName:h?.name||"Privy",onComplete:_,onReset:F,onClose:_}):"totp"===E&&b?/*#__PURE__*/t(xm,{onComplete:_,onClose:_,onReset:F,totpInfo:{...b,appName:h?.name||"Privy"}}):"passkey"===E?/*#__PURE__*/t(dm,{appName:h?.name||"Privy",onComplete:_,onReset:F,onClose:_}):/*#__PURE__*/t(lm,{showIntro:B,userMfaMethods:r.mfaMethods,appMfaMethods:h.mfa.methods,userHasAuthSms:M,onBackToIntro:function(){C(!1)},handleSelectMethod:async function(e){return await f().catch(O),"totp"===e?(T(e),A(null),void w().then((e=>{A(e)})).catch((()=>{A(null),F()}))):"passkey"===e&&1===U.length?await async function(){S(!0);try{await k(),await I({credentialIds:U},{removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){O(e)}finally{S(!1)}}():void T(e)},isTotpLoading:"totp"===E&&!b,isPasskeyLoading:N,error:R,onClose:_,setRemovingMfaMethod:async e=>{await f().catch(O),l(e)}})},[cr.CAPTCHA_SCREEN]:()=>{let{lastScreen:r,currentScreen:a,data:i,navigateBack:c,navigate:d,setModalData:u}=lr(),{status:h,token:p,waitForResult:m,reset:y,execute:g}=it(),f=l([]),w=e=>{f.current=[e,...f.current]},[v,C]=s(!0);o((()=>(w(setTimeout(C,1e3,!1)),()=>{f.current.forEach((e=>clearTimeout(e))),f.current=[]})),[]);let[E,T]=s(""),[b,A]=s("Checking that you are a human..."),[_,k]=s(/*#__PURE__*/t(st,{onClick:()=>{},disabled:!0,children:"Continue"})),[I,N]=s(!1),[x,S]=s(3),R=i?.captchaModalData,O=async e=>{try{await(R?.callback(e)),R?.onSuccessNavigateTo&&d(R?.onSuccessNavigateTo,!1)}catch(e){if(e instanceof qe)return;u({errorModalData:{error:e,previousScreen:r||cr.LANDING}}),d(R?.onErrorNavigateTo||cr.ERROR_SCREEN,!1)}};o((()=>{"success"===h?w(setTimeout((async()=>{let e=await m();!e||R?.userIntentRequired||O(e)}),1e3)):"ready"===h&&w(setTimeout((()=>{"ready"===h&&g()}),500))}),[h]),o((()=>{if(!v)switch(h){case"success":T("Success!"),A("CAPTCHA passed successfully."),k(/*#__PURE__*/t(st,{onClick:()=>{N(!0),O(p)},disabled:!R?.userIntentRequired,loading:I,children:R?.userIntentRequired?"Continue":"Continuing..."}));break;case"loading":T(""),A("Checking that you are a human..."),k(/*#__PURE__*/t(st,{onClick:()=>{},disabled:!0,children:"Continue"}));break;case"error":T("Something went wrong"),x<=0?(A("If you use an adblocker or VPN, try disabling and re-attempting."),k(null)):(A("You did not pass CAPTCHA. Please try again."),k(/*#__PURE__*/t(st,{onClick:W,children:"Retry"})))}}),[h,v,I]);let W=async()=>{if(x<=0)return;S((e=>e-1)),y(),g();let e=await m();!e||R?.userIntentRequired||O(e)};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:r&&a!==r?c:void 0}),/*#__PURE__*/e(gc,{children:["success"===h?/*#__PURE__*/t(si,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}):"error"===h?/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(mc,{}),/*#__PURE__*/e(mt,{children:[E?/*#__PURE__*/t("h3",{children:E}):null,/*#__PURE__*/t("p",{children:b})]}),_]}),/*#__PURE__*/t(yt,{})]})},[cr.ERROR_SCREEN]:()=>{let{navigate:e,navigateBack:n,data:r,lastScreen:a,currentScreen:i}=lr(),o=r?.errorModalData?.previousScreen||(a===i?void 0:a);/*#__PURE__*/return t(cu,{error:r?.errorModalData?.error||Error(),backFn:()=>o?e(o,!1):n(),onClick:()=>e(o||cr.LANDING,!1)})},[cr.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE]:()=>{let{closePrivyModal:r}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(pp,{children:/*#__PURE__*/t(ni,{style:{width:32,height:32}})}),/*#__PURE__*/t(Jl,{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(un,{children:/*#__PURE__*/t(st,{onClick:()=>r(),children:"Close"})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.AFFIRMATIVE_CONSENT_SCREEN]:()=>{let{user:e,logout:n}=ur(),{app:r,onUserCloseViaDialogOrKeybindRef:a,setModalData:i,navigate:o}=lr(),{acceptTerms:s,closePrivyModal:l,createAnalyticsEvent:c}=x(),d=e=>{e?.preventDefault(),l({shouldCallAuthOnSuccess:!1}),n()};a.current=d;/*#__PURE__*/return t(jl,{termsAndConditionsUrl:r?.legal.termsAndConditionsUrl,privacyPolicyUrl:r?.legal.privacyPolicyUrl,onAccept:async t=>{t.preventDefault(),await s(),e&&ut(e,r.embeddedWallets)?(i({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),c({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AffirmativeConsentScreen"}}),n()},callAuthOnSuccessOnClose:!0}}),o(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)):l()},onDecline:d})},[cr.TELEGRAM_AUTH_SCREEN]:()=>{let{authenticated:r,logout:a,ready:i,user:l}=ur(),{app:c,setModalData:d,navigate:u,resetNavigation:h,data:p}=lr(),{initLoginWithTelegram:m,loginWithTelegram:y,updateWallets:g,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v,getAuthMeta:C}=x(),[E,T]=s(!1),[b,_]=s(void 0),k=it();async function I(){try{let e=await async function(){let e;if(!r){if(k.enabled&&"error"===k.status)throw new qe(k.error,null,A.CAPTCHA_FAILURE);return k.enabled&&"success"!==k.status&&(k.execute(),e=await k.waitForResult()),e}}();await y({captchaToken:e}),T(!0),f(!0)}catch(e){if(e?.privyErrorCode===A.ALLOWLIST_REJECTED)return _(void 0),h(),void u(cr.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),_(void 0),h(),void u(cr.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===A.USER_DOES_NOT_EXIST)return _(void 0),h(),void u(cr.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return _(void 0),h(),d({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,telegramAuthResult:C()?.telegramAuthResult,telegramWebAppData:C()?.telegramWebAppData,displayName:e.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void u(cr.LINK_CONFLICT_SCREEN);let{retryable:t,detail:n}=Xo(e);_({retryable:t,detail:n,message:"Authentication failed"})}}o((()=>{I()}),[]),o((()=>{if(!(i&&r&&E&&l))return;if(c?.legal.requireUsersAcceptTerms&&!l.hasAcceptedTerms){let e=setTimeout((()=>{u(cr.AFFIRMATIVE_CONSENT_SCREEN)}),hr);return()=>clearTimeout(e)}if(ut(l,c.embeddedWallets)){let e=setTimeout((()=>{d({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:"telegram",screen:"TelegramAuthScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),u(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),hr);return()=>clearTimeout(e)}g();let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),hr);return()=>clearTimeout(e)}),[i,r,E,l]);let N=E?"Successfully connected with Telegram":b?b.message:"Verifying connection to Telegram",R="";return R=E?"You’re good to go!":b?b.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(nf,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:E,fail:!!b}),/*#__PURE__*/t($p,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:N}),/*#__PURE__*/t("p",{children:R})]}),b&&b?.retryable?/*#__PURE__*/t(hn,{onClick:async()=>{try{_(void 0),p?.telegramAuthModalData?.seamlessAuth||await m(void 0,p?.login?.disableSignup),await I()}catch(e){let{retryable:t,detail:n}=Xo(e);_({retryable:t,detail:n,message:"Authentication failed"})}},disabled:!E&&!b?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(yt,{})]})},[cr.LINK_CONFLICT_SCREEN]:()=>{let{initiateAccountTransfer:e,closePrivyModal:n}=x(),{data:r,navigate:a,lastScreen:i,setModalData:o}=lr(),[l,c]=s(void 0),[d,u]=s(!1),[h,p]=s(!1),m=async()=>{try{if(!r?.accountTransfer?.nonce||!r?.accountTransfer?.account)throw Error("missing account transfer inputs");p(!0),await e({nonce:r?.accountTransfer?.nonce,account:r?.accountTransfer?.account,accountType:r?.accountTransfer?.linkMethod,externalWalletMetadata:r?.accountTransfer?.externalWalletMetadata,telegramWebAppData:r?.accountTransfer?.telegramWebAppData,telegramAuthResult:r?.accountTransfer?.telegramAuthResult,farcasterEmbeddedAddress:r?.accountTransfer?.farcasterEmbeddedAddress,oAuthUserInfo:r?.accountTransfer?.oAuthUserInfo}),u(!0),p(!1),setTimeout(n,1e3)}catch(e){o({errorModalData:{error:e,previousScreen:i||cr.LINK_CONFLICT_SCREEN}}),a(cr.ERROR_SCREEN,!0)}};return l?/*#__PURE__*/t(Al,{address:l,onClose:n,onRetry:()=>c(void 0),onTransfer:m,isTransferring:h,transferSuccess:d}):/*#__PURE__*/t(_l,{onClose:n,onInfo:()=>c(r?.accountTransfer?.embeddedWalletAddress),onContinue:()=>c(r?.accountTransfer?.embeddedWalletAddress),onTransfer:m,isTransferring:h,transferSuccess:d,data:r})}},Cf=[cr.LANDING,cr.AWAITING_CONNECTION],Ef=({isMfaVerifying:r,onMfaVerificationComplete:a})=>{let{ready:i,isModalOpen:s}=ur(),{headless:l}=dr(),{ready:c,currentScreen:d}=lr(),{status:u,execute:h,reset:p,enabled:m}=it(),y=s&&d&&Cf.includes(d)&&!l&&"ready"===u;return o((()=>{y&&h()}),[y]),o((()=>{!s&&m&&p()}),[s,m]),i&&c||d===cr.AWAITING_OAUTH_SCREEN||d===cr.CROSS_APP_AUTH_SCREEN||d===cr.TELEGRAM_AUTH_SCREEN?!d&&r?/*#__PURE__*/t(yy,{open:r,onClose:a}):d?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(sl,{$if:!!r,children:/*#__PURE__*/t(vf[d],{})}),/*#__PURE__*/t(sl,{$if:!r,children:/*#__PURE__*/t(yy,{open:r,onClose:a})})]}):null:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(wf,{children:/*#__PURE__*/t(Ht,{})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(yt,{})]})},Tf=({isMfaVerifying:e,onMfaVerificationComplete:n})=>{let r=l(null);/*#__PURE__*/return t(_f,{style:{height:kn(r)},id:"privy-modal-content",children:/*#__PURE__*/t("div",{ref:r,children:/*#__PURE__*/t(Ef,{isMfaVerifying:e,onMfaVerificationComplete:n})})})};const bf=({open:e})=>{let{app:n}=lr(),{gracefulClosePrivyModal:r}=(()=>{let{closePrivyModal:e}=x(),{onUserCloseViaDialogOrKeybindRef:t}=lr();return{gracefulClosePrivyModal:c((()=>{if(!t?.current)return e({shouldCallAuthOnSuccess:!1});t.current()}),[e])}})(),[a,i]=s(!1);Zs({onMfaRequired:()=>{n?.mfa.noPromptOnMfaRequired||i(!0)}});let o=e||a;return n.render.standalone?/*#__PURE__*/t(hf,{children:/*#__PURE__*/t(Af,{id:"privy-modal-content",children:/*#__PURE__*/t(Ef,{isMfaVerifying:a,onMfaVerificationComplete:()=>i(!1)})})}):/*#__PURE__*/t(pf,{open:o,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:/*#__PURE__*/t(hf,{children:/*#__PURE__*/t(Tf,{isMfaVerifying:a,onMfaVerificationComplete:()=>i(!1)})})})};let Af=/*#__PURE__*/Ka.div.withConfig({displayName:"ContentWrapper",componentId:"sc-ca7fbebb-0"})(["display:flex;flex-direction:column;text-align:center;font-size:14px;line-height:20px;width:100%;background:var(--privy-color-background);padding:0 16px;"]),_f=/*#__PURE__*/Ka(Af).withConfig({displayName:"BaseModal",componentId:"sc-ca7fbebb-1"})(["transition:height 150ms ease-out;overflow-x:hidden;overflow-y:auto;scrollbar-width:none;max-height:calc(100svh - 32px);border-radius:var(--privy-border-radius-lg) var(--privy-border-radius-lg) 0 0;box-shadow:0px 0px 36px rgba(55,65,81,0.15);@media (min-width:441px){box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]);function kf(e){let n=l(null),r=l();return o((()=>{r.current?.remove(),r.current=function({botUsername:e,scriptHost:t}){let n=document.createElement("script"),{origin:r}=new URL(t);return n.async=!0,n.src=`${r}/js/telegram-login.js`,n.setAttribute("data-telegram-login",e),n.setAttribute("data-request-access","write"),n.setAttribute("data-lang","en"),n}(e),n.current?.after(r.current)}),[e]),/*#__PURE__*/t("div",{ref:n,hidden:!0})}async function If(e,t,n,r,a,i=!1){let o=i,s=async s=>{if(o&&t&&t.length>0){s===(i?0:1)?a("configureMfa","onMfaRequired",{mfaMethods:t}):r.current?.reject(new Hc("missing_or_invalid_mfa","MFA verification failed, retry."));let o=await new Promise(((e,t)=>{n.current={resolve:e,reject:t},setTimeout((()=>{let e=new Hc("mfa_timeout","Timed out waiting for MFA code");r.current?.reject(e),t(e)}),3e5)}));return await e(o)}return await e()},l=null;for(let e=0;e<4;e++)try{l=await s(e),r.current?.resolve(void 0);break}catch(e){if("missing_or_invalid_mfa"!==e.type)throw r.current?.resolve(void 0),e;o=!0}if(null===l){let e=new Hc("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw r.current?.reject(e),e}return l}var Nf;let xf=(Nf=0,()=>"id-"+Nf++);function Sf(e){return void 0!==e.error}let Rf=new class{enqueue(e,t){this.callbacks[e]=t}dequeue(e,t){let n=this.callbacks[t];if(!n)throw Error(`cannot dequeue ${e} event: no event found for id ${t}`);switch(delete this.callbacks[t],e){case"privy:iframe:ready":case"privy:wallets:create":case"privy:wallets:add":case"privy:wallets:import":case"privy:wallets:set-recovery":case"privy:wallets:connect":case"privy:wallets:recover":case"privy:wallets:rpc":case"privy:wallet:create":case"privy:mfa:verify":case"privy:mfa:init-enrollment":case"privy:mfa:submit-enrollment":case"privy:mfa:unenroll":case"privy:mfa:clear":case"privy:auth:unlink-passkey":case"privy:farcaster:init-signer":case"privy:farcaster:sign":case"privy:solana-wallet:create":case"privy:delegated-actions:consent":return n;default:throw Error(`invalid wallet event type ${e}`)}}constructor(){this.callbacks={}}},Of=new Map,Wf=(e,t)=>"bigint"==typeof t?t.toString():t;function Mf(e,t,n,r){let a=n.contentWindow;if(!a)throw Error("iframe not initialized");let i=((e,t)=>`${e}${JSON.stringify(t,Wf)}`)(e,t);if("privy:wallet:create"===e){let e=Of.get(i);if(e)return e}let o=new Promise(((n,i)=>{let o=xf();Rf.enqueue(o,{resolve:n,reject:i}),a.postMessage({id:o,event:e,data:t},r)})).finally((()=>{Of.delete(i)}));return Of.set(i,o),o}function Pf(e){let n=l(null),r=l(e.mfaMethods),a=ua(),[i,c]=s(!1);return o((()=>{r.current=e.mfaMethods}),[e.mfaMethods]),o((()=>{if(!i)return;let t=n.current;if(!t)return;function o(t){var n;t&&t.origin===e.origin&&"string"==typeof(n=t.data).event&&/^privy:.+/.test(n.event)&&function(e){switch(e.event){case"privy:iframe:ready":let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallets:create":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:add":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:set-recovery":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:connect":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:recover":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:rpc":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallet:create":let n=Rf.dequeue(e.event,e.id);return Sf(e)?n.reject(new Hc(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallets:import":let r=Rf.dequeue(e.event,e.id);return Sf(e)?r.reject(new Hc(e.error.type,e.error.message)):r.resolve(e.data);case"privy:mfa:verify":let a=Rf.dequeue(e.event,e.id);return Sf(e)?a.reject(new Hc(e.error.type,e.error.message)):a.resolve(e.data);case"privy:mfa:init-enrollment":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:submit-enrollment":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:unenroll":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:clear":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:auth:unlink-passkey":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:solana-wallet:create":let i=Rf.dequeue(e.event,e.id);return Sf(e)?i.reject(new Hc(e.error.type,e.error.message)):i.resolve(e.data);case"privy:farcaster:init-signer":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:farcaster:sign":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:delegated-actions:consent":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}(t.data)}let s={createWallet:n=>If((r=>Mf("privy:wallets:create",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),addWallet:n=>If((r=>Mf("privy:wallets:add",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),setRecovery:n=>If((r=>Mf("privy:wallets:set-recovery",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),connect:n=>If((r=>Mf("privy:wallets:connect",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),recover:n=>If((r=>Mf("privy:wallets:recover",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a,!n.recoveryAccessToken&&!n.recoveryPassword&&!n.recoverySecretOverride),rpc:n=>If((r=>Mf("privy:wallets:rpc",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),create:n=>Mf("privy:wallet:create",n,t,e.origin),importWallet:n=>Mf("privy:wallets:import",n,t,e.origin),createSolana:n=>If((r=>Mf("privy:solana-wallet:create",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),createDelegatedAction:n=>Mf("privy:delegated-actions:consent",n,t,e.origin),verifyMfa:n=>If((r=>Mf("privy:mfa:verify",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a,!0),initEnrollMfa:n=>If((r=>Mf("privy:mfa:init-enrollment",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),submitEnrollMfa:n=>If((r=>Mf("privy:mfa:submit-enrollment",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),unenrollMfa:n=>If((r=>Mf("privy:mfa:unenroll",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),clearMfa:n=>Mf("privy:mfa:clear",n,t,e.origin),unlinkPasskeyAccount:n=>If((r=>Mf("privy:auth:unlink-passkey",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),initFarcasterSigner:n=>Mf("privy:farcaster:init-signer",n,t,e.origin),signFarcasterMessage:n=>Mf("privy:farcaster:sign",n,t,e.origin)};window.addEventListener("message",o);let l=new AbortController;return In((()=>Mf("privy:iframe:ready",{},t,e.origin)),{abortSignal:l.signal}).then((()=>e.onLoad(s)),((...t)=>{console.warn("Privy iframe failed to load: ",...t),e.onLoadFailed()})),()=>{window.removeEventListener("message",o),l.abort()}}),[i]),
20
- /*#__PURE__*/t("iframe",{ref:n,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>c(!0),src:Ot(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId,client_id:e.appClientId})})}const Lf=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.delegated));class Df{async handleSignMessage(e){if(!e.params||"string"!=typeof e.params.message)throw Error("Message must be provided as a string for Solana signMessage RPC");return await dw({message:e.params.message,options:{address:this.address,uiOptions:{}}})}async request(e){if(console.debug("EmbeddedSolanaProvider.request() called with args",e),!await rw())throw Error("User must be authenticated to use embedded Solana wallet");if(!await cw())throw new T("Unable to connect to Solana embedded wallet");if("signMessage"===e.method)return await this.handleSignMessage(e);throw Error("Embedded Solana provider does not yet support this RPC method.")}constructor(e,t){this.walletProxy=e,this.address=t}}const Uf=()=>{let e=dr();o((()=>{(async e=>{let t=new URL("v3/wallets","https://explorer-api.walletconnect.com");t.searchParams.append("projectId",e);let n=await fetch(t);return n.ok?Object.values((await n.json()).listings).sort((({slug:e},{slug:t})=>"rainbow"===e&&"metamask"===t?1:"metamask"===e||"rainbow"===e?-1:1)):(console.debug(`Failed to fetch WalletConnect listings: ${await n.text().catch((()=>"No response."))}`),[])})(e.walletConnectCloudProjectId).then((e=>Nn({listings:e}))).catch(console.error)}),[e.walletConnectCloudProjectId])},Ff="popup-privy-oauth",Bf="PRIVY_OAUTH_USE_BROADCAST_CHANNEL";class zf{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(K,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(Y,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw b(e)}}constructor({authorizationCode:e,stateCode:t,codeVerifier:n,provider:r}){this.meta={authorizationCode:e,stateCode:t,codeVerifier:n,provider:r}}}async function Hf({api:e,requesterAppId:t,providerAppId:n}){let r=(await e.get(`/api/v1/apps/${t}/cross-app/connections`)).connections.find((e=>e.provider_app_id===n));if(!r)throw new T("Invalid connected app");return{name:r.provider_app_name,logoUrl:r.provider_app_icon_url||void 0,apiUrl:r.provider_app_custom_api_url,readOnly:r.read_only}}const Vf=async({user:e,address:t,client:n,request:r,requesterAppId:a,reconnect:i})=>{n.createAnalyticsEvent({eventName:"cross_app_request_started",payload:{address:t,method:r.method}});let o=e?.linkedAccounts.find((e=>"cross_app"===e.type&&(e.embeddedWallets.some((e=>e.address===t))||e.smartWallets.some((e=>e.address===t)))));if(!e||!o)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Cannot request a signature with this wallet address",address:t}}),new T("Cannot request a signature with this wallet address");let s=n.getProviderAccessToken(o.providerApp.id),l=await Hf({api:n.api,requesterAppId:a,providerAppId:o.providerApp.id});if(!s){if(l.readOnly)throw console.error("cannot transact against a read-only provider app"),new T("Cannot transact against a read-only provider app");await i({appId:o.providerApp.id,action:"link"})&&(s=n.getProviderAccessToken(o.providerApp.id))}if(!s)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Transactions require a valid token",address:t}}),new T("Transactions require a valid token");let c=Zh();if(!c)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Missing token",address:t}}),new T("Failed to initialize signature request");let d=new URL(`${l.apiUrl}/oauth/transact`);return d.searchParams.set("token",s||""),d.searchParams.set("request",$f(r)),c.location=d.href,new Promise(((e,a)=>{let i=setTimeout((()=>{d(),a(new T("Request timeout")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Request timeout",address:t}})}),12e4),s=setInterval((()=>{c.closed&&(d(),a(new T("User rejected request")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"User rejected request",address:t}}))}),300),l=i=>{i.data&&("set"===i.data.token?.action&&void 0!==i.data.token?.value?n.storeProviderAccessToken(o.providerApp.id,i.data.token.value):"clear"===i.data.token?.action&&n.storeProviderAccessToken(o.providerApp.id,null),"PRIVY_CROSS_APP_ACTION_RESPONSE"===i.data.type&&i.data.result&&(d(),e(i.data.result),n.createAnalyticsEvent({eventName:"cross_app_request_success",payload:{address:t,method:r.method}})),"PRIVY_CROSS_APP_ACTION_ERROR"===i.data.type&&i.data.error&&(d(),a(i.data.error),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:i.data.error,address:t}})))};window.addEventListener("message",l);let d=()=>{c.close(),clearInterval(s),clearTimeout(i),window.removeEventListener("message",l)}}))};let $f=e=>JSON.stringify({content:{request:{request:jf(e,_a)}},timestamp:Date.now(),callbackUrl:window.origin});const jf=(e,t)=>"bigint"==typeof e?t(e):Array.isArray(e)?e.map((e=>jf(e,t))):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,jf(n,t)]))):e,Gf=e=>!!e.fundingConfig&&ha(e.fundingConfig.options).length>=1;async function qf({url:e,popup:t,provider:n}){return t.location=e,new Promise(((e,n)=>{function r(){t?.close(),window.removeEventListener("message",a)}function a(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(e(t.data),r()),"https://cdn.apple-cloudkit.com"===t.origin&&t.data.ckSession&&(e({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:t.data.ckSession}),r()),"PRIVY_OAUTH_ERROR"===t.data.type&&(n(t.data.error),r()))}window.addEventListener("message",a)}))}let Kf,Yf,Zf,Jf,Qf,Xf,ew,tw;function nw(){return Kf?Kf.getCustomerAccessToken():Promise.resolve(Zr.get(Kn)||null)}async function rw(){return Kf?Kf.getAccessToken():Promise.resolve(Zr.get(Yn)||Zr.get(Kn)||null)}const aw=(e,t)=>Yf(e,t),iw=(e,t)=>Zf(e,t),ow=(e,t)=>Jf(e,t),sw=(e,t)=>Qf(e,t),lw=()=>Xf(),cw=()=>ew(),dw=({message:e,options:t})=>tw({message:e,options:t}),uw=({config:e,...n})=>{var r;if("undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new T("Embedded wallet is only available over HTTPS");if("string"!=typeof(r=n.appId)||25!==r.length)throw new T("Cannot initialize the Privy provider with an invalid Privy app ID");Kf||(Kf=new qs({appId:n.appId,appClientId:n.clientId,apiUrl:n.apiUrl}));let a=Object.assign({},e);/*#__PURE__*/
21
- return t(Ur,{client:Kf,clientConfig:a,children:/*#__PURE__*/t(pa,{children:/*#__PURE__*/t(hw,{...n,client:Kf})})})};let hw=n=>{let a=n.client,d=ra();Uf();let[u,h]=s(!1),[p,m]=s(!1),[y,g]=s(!1),[f,w]=s(null),[k,I]=s([]),[N,x]=s([]),[S,R]=s([]),[O,W]=s(!1),[U,F]=s(null),[B,z]=s(!1),[H,V]=s({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:P}),[$,j]=s({status:"initial"}),[G,q]=s({status:"initial"}),[K,Y]=s({status:"initial"}),[J,Q]=s({status:"initial"}),[X,ee]=s({status:"initial"}),[te,ne]=s({status:"initial"}),[re,ae]=s(null),ie=dr(),oe=Fr(),[se,le]=s(!0),[ce,de]=s({}),[ue,he]=s(null),[pe,me]=s(null),[ye,ge]=s(!1),[fe,we]=s(!1),[ve,Ce]=s(ie.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),Ee=l(null),Te=l(null),be=l(ma),[Ae,_e]=s(!1);a.onStoreCustomerAccessToken=e=>{e&&ya(be,"accessToken","onAccessTokenGranted",{accessToken:e})},a.onDeleteCustomerAccessToken=()=>{w(null),g(!1),ya(be,"accessToken","onAccessTokenRemoved")};let ke=l(null),Ie=l(null),Ne=l(!1),xe=({showWalletUIs:e})=>Ne.current?Ne.current:void 0!==e?!e:!ie.embeddedWallets.showWalletUIs,Se=e=>{F(e),setTimeout((()=>{h(!0)}),15)},Re=e=>{("off"!==ie.embeddedWallets.ethereum.createOnLogin||"off"!==ie.embeddedWallets.solana.createOnLogin)&&le(!0),Se(e)};o((()=>{let e=[...Br(f),Lr(f)].filter((e=>!!e));re&&R(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 T("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:()=>{throw new T("Cannot unlink an embedded Solana wallet")},getProvider:async()=>new Df(re,e.address),async signMessage(t){let n=await rw();if(!n||!re)throw new T("Must have valid access token and Privy wallet to send transaction",A.MUST_BE_AUTHENTICATED);let r=e.imported?Lr(f):wr(f);if(!r)throw new T("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=jn(r);if(!await lt.recoverPrimaryWallet().catch((()=>!1)))throw new T("Wallet couldn't be connected",A.UNKNOWN_CONNECT_WALLET_ERROR);if(!f)throw new T("Attempting to sign a transaction with no user initialized");let{response:o}=await re.rpc({accessToken:n,entropyId:a,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:e.walletIndex??0,request:{method:"signMessage",params:{message:Buffer.from(t).toString("base64")}}});return Buffer.from(o.data.signature,"base64")},async sendTransaction(e,t,n){let{signature:r}=await Qe({transaction:e,connection:t,transactionOptions:n,wallet:this,signOnly:!1});return r},async signTransaction(t){let n=await rw();if(!n||!re)throw new T("Must have valid access token and Privy wallet to send transaction",A.MUST_BE_AUTHENTICATED);if(!await lt.recoverPrimaryWallet().catch((()=>!1)))throw new T("Wallet couldn't be connected",A.UNKNOWN_CONNECT_WALLET_ERROR);let r=e.imported?e:wr(f);if(!r)throw new T("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=jn(r);return await Wy({tx:t,accessToken:n,walletProxy:re,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0}),t},async signAllTransactions(t){let n=await rw();if(!n||!re)throw new T("Must have valid access token and Privy wallet to send transaction",A.MUST_BE_AUTHENTICATED);if(!await lt.recoverPrimaryWallet().catch((()=>!1)))throw new T("Wallet couldn't be connected",A.UNKNOWN_CONNECT_WALLET_ERROR);let r=e.imported?e:wr(f);if(!r)throw new T("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=jn(r);for(let r of t)await Wy({tx:r,accessToken:n,walletProxy:re,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0});return t},loginOrLink:async()=>{throw new T("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{},isConnected:async()=>!0}))))}),[re,f]),o((()=>{if(!f)return void a.connectors?.removeEmbeddedWalletConnectors();let e=yr(f),t=zr(f),r=Hr(f);e&&t.length||a.connectors?.removeEmbeddedWalletConnectors(),r||a.connectors?.removeImportedWalletConnector(),a.connectors?re?(e&&a.connectors.addEmbeddedWalletConnectors({walletProxy:re,rootWallet:e,embeddedWallets:t,defaultChain:ie.defaultChain,appId:n.appId}),r&&a.connectors.addImportedWalletConnector(re,r.address,ie.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")}),[re,f]),o((()=>{re&&pe?.(re)}),[re]);let Oe=l();o((()=>{(async()=>{if(!ie.customAuth?.enabled)return void Ce({status:"not-enabled"});le(!0);let{getCustomAccessToken:e,isLoading:t}=ie.customAuth;if(p&&!t&&"loading"!==ve.status){Ce({status:"loading"});try{let t=await e();if(t===Oe.current)return void Ce({status:"done"});if(!t&&y)return Oe.current=t,await st.logout(),Ce({status:"done"}),void ya(be,"customAuth","onUnauthenticated");if(!t)return Oe.current=t,void Ce({status:"done"});a.startAuthFlow(new bo(t));let{user:n,isNewUser:r}=await a.authenticate();if(!n)return await st.logout(),Ce({status:"error",error:new T("Failed to sync with custom auth provider")}),void ya(be,"customAuth","onUnauthenticated");void 0!==r&&ya(be,"login","onComplete",{user:n,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),Oe.current=t,ya(be,"customAuth","onAuthenticated",{user:n}),Ce({status:"done"}),w(n||null),W(r||!1),g(!0),we(!0)}catch(e){if(console.warn(e),await st.logout(),ya(be,"customAuth","onUnauthenticated"),"User already exists with provided custom JWT account."===e.message)return void Ce({status:"initial"});ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),Ce({status:"error",error:e})}}})()}),["initial"===ve.status,ie.customAuth?.enabled,ie.customAuth?.getCustomAccessToken,ie.customAuth?.isLoading,p,y]),o((()=>{fe&&re&&f&&(async()=>{let e=Wt(f,ie.embeddedWallets.ethereum.createOnLogin),t=Mt(f,ie.embeddedWallets.solana.createOnLogin),n=await rw();if(n){if(e&&t){let e=await $e(f,fr);return await re.createSolana({accessToken:n,ethereumAddress:e?.address}),void we(!1)}if(t)return await re.createSolana({accessToken:n,ethereumAddress:yr(f)?.address}),await lt.refreshSessionAndUser(),void we(!1);if(e)return await $e(f,fr),void we(!1)}})().catch(console.error)}),[fe&&re&&f]),o((()=>{if(ie.externalWallets.solana.connectors)return ie.externalWallets.solana.connectors.onMount(),()=>ie.externalWallets.solana.connectors?.onUnmount()}),[ie.externalWallets.solana.connectors]),o((()=>{!p&&oe&&async function(){let e,t=We(),n=Me(),i=r();a.initializeConnectorManager({walletConnectCloudProjectId:ie.walletConnectCloudProjectId,rpcConfig:ie.rpcConfig,chains:ie.chains,defaultChain:ie.defaultChain,store:i,walletList:ie.appearance.walletList,shouldEnforceDefaultChainOnConnect:ie.shouldEnforceDefaultChainOnConnect,externalWalletConfig:ie.externalWallets,appName:ie.name??"Privy",walletChainType:ie.appearance.walletChainType}),a.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=a.connectors.walletConnectors.length,n=a.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);n===t?_e(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:n,expected:t}),_e(!0)}),1500)})),a.connectors?.initialize().then((()=>{Fe()}));let o=await a.getAuthenticatedUser(),s=!!o;ie.legal.requireUsersAcceptTerms&&o&&!o.hasAcceptedTerms?(await a.logout(),lt.setReadyToTrue(!0),ya(be,"logout","onSuccess")):(ie.customAuth?.enabled||(g(!!o),o&&ya(be,"login","onComplete",{user:o,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),w(o)),t?Ie.current=s?"link":"login":n&&!s?(Ie.current="login",de({telegramAuthModalData:{seamlessAuth:!0}}),Re(cr.TELEGRAM_AUTH_SCREEN)):lt.setReadyToTrue(!!o))}()}),[a,ue,p,oe]),o((()=>{if(p){if(!f||!f.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType)))return void ge(!0);ge([...k,...S].some((e=>"privy"===e.walletClientType)))}}),[p,f,k,S]),o((()=>{a.connectors?.setWalletList(ie.appearance.walletList)}),[ie.appearance.walletList.join()]);let We=()=>{let e=qo();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(Ff).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(a.startAuthFlow(new Wo(e)),Re(cr.AWAITING_OAUTH_SCREEN),!0))},Me=()=>{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())}())?(ts(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=es(e.replace("#tgWebAppData=","")),{user:n,auth_date:r,hash:a}=t;return n&&r&&a?t:void 0}())?(ts(),{flowType:"web-app",authData:e}):void 0}();if(!e||!ie.loginMethods.telegram||!ie.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new Qo;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},Pe=async(e,t,n,r)=>{if("solana_adapter"!==e)Le(await(a.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,n,r);else{let e=a.connectors?.findSolanaWalletConnector(t);if(!e)return;Le(e,t,n,r)}};async function Le(e,t,n,r){if(!e)return V({status:"disconnected",connectedWallet:null,connectError:new _("Unable to connect to wallet."),connector:null,connectRetry:P}),r?.(null,n);V({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:P}),e instanceof nt&&t&&await e.resetConnection(t),V({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Le(e,t,n,r)});try{let t=await e.connect({showPrompt:!0});if((!t||rt(t))&&ie.shouldEnforceDefaultChainOnConnect&&!ie.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){V((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:P})));try{await(t?.switchChain(ie.defaultChain.id)),t&&(t.chainId=Wn(Ze(ie.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${ie.defaultChain.id}`)}}return V((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:P}))),t&&ya(be,"connectWallet","onSuccess",{wallet:t}),r?.(t,n)}catch(e){return e instanceof M?(console.warn(e.cause?e.cause:e.message),ya(be,"connectWallet","onError",e.privyErrorCode||A.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),ya(be,"connectWallet","onError",A.UNKNOWN_CONNECT_WALLET_ERROR)),V((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),r?.(null,n)}}let De=async(e,t,n)=>{if(null===e||!rt(e))return;let r=new at(e,a,t,n);a.startAuthFlow(r)},Ue=async(e,t,n)=>{if(null===e||!va(e))return;let r=new xn(e,a,t,n);a.startAuthFlow(r)},Fe=()=>{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=xs({connectorType:t,walletClientType:n});if(!i||!i.isInstalled)return Re(cr.LOGIN_FAILED_SCREEN);if(!a.connectors)throw new T("Connector not initialized");Se(r?cr.AWAITING_CONNECT_ONLY_CONNECTION:cr.AWAITING_CONNECTION);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),Pe(t,n,void 0,r?void 0:"solana_adapter"===t?Ue:De)};o((()=>{p&&y&&null===f&&a.getAuthenticatedUser().then(w)}),[p,y,f,a]);let Be=e=>{if(!y)throw ya(be,"linkAccount","onError",A.MUST_BE_AUTHENTICATED,{linkMethod:e}),new T("User must be authenticated before linking an account.")},ze=e=>{if(!y||!f)return!1;if("privy"===e.walletClientType)return!0;for(let t of f.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},He=async e=>{let t;if(!a.connectors)throw new T("Connector not initialized");t="ethereum"===e.type?a.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:a.connectors.findSolanaWalletConnector(e.walletClientType)||null,V((n=>({...n,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:P}))),ie.captchaEnabled&&!y?(de({captchaModalData:{callback:t=>rt(e)?De(e,t):Ue(e,t),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_CONNECTION,onErrorNavigateTo:cr.ERROR_SCREEN}}),Re(cr.CAPTCHA_SCREEN)):(rt(e)?await De(e):await Ue(e),Re(cr.AWAITING_CONNECTION))},Ve=()=>{I((e=>{let t=a.connectors?.wallets.filter(rt).map((e=>({...e,linked:ze(e),loginOrLink:async()=>{if(!await e.isConnected())throw new T("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot link or login with embedded wallet");He(e)},fund:async t=>{await lt.fundWallet(e.address,t)},unlink:async()=>{if(!y)throw new T("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot unlink an embedded wallet");w(await a.unlinkEthereumWallet(e.address))}})))||[];return Mn(e,t)?e:t})),x((e=>{let t=(a.connectors?.wallets??[]).filter(va).map((e=>({...e,linked:ze(e),loginOrLink:async()=>{if(!await e.isConnected())throw new T("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot link or login with embedded wallet");He(e)},fund:async()=>{throw new T("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!y)throw new T("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot unlink an embedded wallet");w(await a.unlinkSolanaWallet(e.address))}})));return Mn(e,t)?e:t}))};o((()=>{Ve()}),[f?.linkedAccounts,y,p]),o((()=>{if(p){if(!a.connectors)throw new T("Connector not initialized");Ve(),a.connectors.on("walletsUpdated",Ve)}}),[p]),o((()=>{[...ie.loginMethodsAndOrder?.primary??[],...ie.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>a.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!a]);let $e=async(e,t,n)=>{let r=yr(e),a=gr(e);if(n&&"walletIndex"in n&&"number"==typeof n.walletIndex)return Ge(e,t,n.walletIndex,r,a);let i=n&&"createAdditional"in n&&n.createAdditional;if(r&&!i)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");let[o,s]=await Promise.all([lt.initializeWalletProxy(t),rw()]);if(!o&&ie.customAuth?.enabled)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!o||!s||ie.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return je();if(!r)return a&&await lt.recoverPrimaryWallet(),await o.create({accessToken:s,solanaAddress:a?.address}),Ke(0,"ethereum");{let t=(Vr(e)?.walletIndex??0)+1,{entropyId:n,entropyIdVerifier:r}=jn(wr(e));return await lt.recoverPrimaryWallet(),await o.addWallet({accessToken:s,entropyId:n,entropyIdVerifier:r,chainType:"ethereum",hdWalletIndex:t}),Ke(t,"ethereum")}},je=async()=>new Promise(((e,t)=>{le(!0),de({createWallet:{onSuccess:t=>{ya(be,"createWallet","onSuccess",{wallet:t}),e(t)},onFailure:e=>{ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),t(e)},callAuthOnSuccessOnClose:!1}}),Se(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)})),Ge=async(e,t,n,r,a)=>{if(n<0)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${n}) is invalid.`);let[i,o]=await Promise.all([lt.initializeWalletProxy(t),rw()]);if(!i&&ie.customAuth?.enabled)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!i||!o||ie.embeddedWallets?.requireUserOwnedRecoveryOnCreate){if(0==n)return je();throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Create wallet UI can only be displayed when walletIndex is 0.")}if(0==n){if(r)return r;await i.create({accessToken:o,solanaAddress:a?.address})}else{if(!r)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error("A user must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let t=zr(e).find((e=>e.walletIndex===n));if(t)return t;let{entropyId:a,entropyIdVerifier:s}=jn(wr(e));await lt.recoverPrimaryWallet(),await i.addWallet({accessToken:o,entropyId:a,entropyIdVerifier:s,chainType:"ethereum",hdWalletIndex:n})}return Ke(n,"ethereum")},qe=async({user:e,wp:t,accessToken:n,walletIndex:r,ethereumWallet:a})=>{let i=Br(e).find((e=>e.walletIndex===r));if(i)return i;if(0===r)a&&await lt.recoverPrimaryWallet(),await t.createSolana({accessToken:n,ethereumAddress:a?.address});else{let a=wr(e);if(!a)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error("User must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let{entropyId:i,entropyIdVerifier:o}=jn(a);await lt.recoverPrimaryWallet(),await t.addWallet({accessToken:n,entropyId:i,entropyIdVerifier:o,chainType:"solana",hdWalletIndex:r})}return Ke(r,"solana")},Ke=async(e,t)=>{let n=await lt.refreshSessionAndUser(),r=("ethereum"===t?zr(n):Br(n)).find((t=>t.walletIndex===e));if(!r)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");return ya(be,"createWallet","onSuccess",{wallet:r}),r},Ye=({transaction:e,uiOptions:t,fundWalletConfig:r,address:a,signOnly:i})=>new Promise((async(o,s)=>{let{requesterAppId:l}=t||{},c=i?"signTransaction":"sendTransaction";if(!y||!f)return ya(be,c,"onError",A.MUST_BE_AUTHENTICATED),void s(Error("User must be authenticated before signing with a Privy wallet"));let d=a??yr(f)?.address;if(!d)throw new T("User must have an embedded wallet to send a transaction.");let{signingWallet:u,rootWallet:h}=$r(f,d);if(!h||!u)return ya(be,c,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have a Privy wallet before signing"));le(!0);let p=ct.wallets.find((e=>"privy"===e.walletClientType&&C(e.address)===C(u.address))),m=await(p?.getEthereumProvider());if(!p||!m)throw new T(`Cannot sendTransaction before embedded wallet ${u.address} is connected`);let g=e.chainId?Number(e.chainId):Ca(p.chainId);(e=>{if(!ie.chains.map((e=>e.id)).includes(e))throw new _(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,A.UNSUPPORTED_CHAIN_ID)})(g);let w={...e,from:e.from??u.address,chainId:g},v=await rw();if(!v||!re)return ya(be,c,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have valid access token and Privy wallet to send transaction"));let E=Ha(w.chainId,ie.chains,ie.rpcConfig,{appId:n.appId});if(xe({showWalletUIs:t?.showWalletUIs}))(async()=>{try{if(!await lt.recoverPrimaryWallet())return ya(be,c,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),void s(Error("Unable to connect to wallet"));let e=await uy(w,E,w.from),{entropyId:t,entropyIdVerifier:n}=jn(h),r=i?await bg({accessToken:v,entropyId:t,entropyIdVerifier:n,transactingWallet:u,walletProxy:re,transactionRequest:w,requesterAppId:l}):await Tg({accessToken:v,entropyId:t,entropyIdVerifier:n,transactingWallet:u,walletProxy:re,transactionRequest:e,publicClient:E,requesterAppId:l});i?ya(be,"signTransaction","onSuccess",{signature:r}):ya(be,"sendTransaction","onSuccess",{hash:r}),o({hash:r})}catch(e){ya(be,c,"onError",A.TRANSACTION_FAILURE),s(e)}})();else{let{entropyId:e,entropyIdVerifier:n}=jn(h),a={entropyId:e,entropyIdVerifier:n,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:e=>{ya(be,c,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),s(e)}},d=Gf(ie)?fa({address:u.address,appConfig:ie,fundWalletConfig:r,methodScreen:cr.FUNDING_METHOD_SELECTION_SCREEN,chainIdOverride:w.chainId,comingFromSendTransactionScreen:!0}):void 0;de({connectWallet:a,sendTransaction:{transactionRequest:w,transactingWallet:u,entropyId:e,entropyIdVerifier:n,signOnly:i,onConfirm:i?async()=>await bg({accessToken:v,entropyId:e,entropyIdVerifier:n,transactingWallet:u,walletProxy:re,transactionRequest:w,requesterAppId:l}):void 0,onSuccess:e=>{i?ya(be,"signTransaction","onSuccess",{signature:e.hash}):ya(be,"sendTransaction","onSuccess",{hash:e.hash}),o(e)},onFailure:e=>{ya(be,c,"onError",A.TRANSACTION_FAILURE),s(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:l},funding:d}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),Qe=({transaction:e,connection:t,transactionOptions:n,fundWalletConfig:r,uiOptions:a,wallet:i,signOnly:o})=>new Promise((async(s,l)=>{let{requesterAppId:c}=a||{},d=o?"signSolanaTransaction":"sendSolanaTransaction";if(!y||!f)return ya(be,d,"onError",A.MUST_BE_AUTHENTICATED),void l(new T("User must be authenticated before signing with a Privy wallet",A.MUST_BE_AUTHENTICATED));let u=i?f.linkedAccounts.find((e=>"wallet"===e.type&&e.address===i.address)):gr(f);if(!u)return ya(be,d,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void l(new T("Must have a Privy wallet before signing",A.EMBEDDED_WALLET_NOT_FOUND));le(!0);let{rootWallet:h}=Dr(f,u.address);if(!await lt.recoverPrimaryWallet().catch((()=>!1))||!h)throw ya(be,d,"onError",A.EMBEDDED_WALLET_NOT_FOUND),new T(`Cannot sendSolanaTransaction before embedded wallet ${u.address} is connected`,A.EMBEDDED_WALLET_NOT_FOUND);if(xe({showWalletUIs:a?.showWalletUIs}))(async()=>{let r=await rw();if(!r||!re)return ya(be,d,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void l(new T("Must have valid access token and Privy wallet to send transaction",A.EMBEDDED_WALLET_NOT_FOUND));try{let i;if(!await lt.recoverPrimaryWallet())return ya(be,d,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),void l(new T("Unable to connect to wallet",A.UNKNOWN_CONNECT_WALLET_ERROR));if(xe({showWalletUIs:a?.showWalletUIs})&&!o)try{if(!await async function(e,t){let{value:n}=await t.simulateTransaction(e);if("BlockhashNotFound"===n.err)throw Error("Simulation failed: Blockhash not found");return null==n.err&&n.logs?.every((e=>!/insufficient funds/gi.test(e)))}(e,t))return ya(be,d,"onError",A.INSUFFICIENT_BALANCE),void l(new T("Solana wallet has insufficient funds for this transaction.",A.INSUFFICIENT_BALANCE))}catch(e){return console.error(e),ya(be,d,"onError",A.TRANSACTION_FAILURE),void l(new T(e instanceof Error?e.message:"Transaction failed.",A.TRANSACTION_FAILURE))}let{entropyId:c,entropyIdVerifier:h}=Kr(f);if(o)await Wy({accessToken:r,tx:e,walletProxy:re,entropyId:c,entropyIdVerifier:h,transactingWalletAddress:u.address,transactingWalletIndex:u.walletIndex??0}),i=Fu("",e,null),ya(be,"signSolanaTransaction","onSuccess",{signedTransaction:e});else{let{signature:a,receipt:o}=await My({accessToken:r,tx:e,connection:t,walletProxy:re,transactionOptions:n,entropyId:c,entropyIdVerifier:h,transactingWalletAddress:u.address,transactingWalletIndex:u.walletIndex??0});i=Fu(a,e,o),ya(be,"sendSolanaTransaction","onSuccess",{response:i})}s(i)}catch(e){ya(be,d,"onError",A.TRANSACTION_FAILURE),l(e)}})();else{let{entropyId:i,entropyIdVerifier:p}=jn(h),m={entropyId:i,entropyIdVerifier:p,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN,onFailure:e=>{ya(be,d,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),l(e)}},y=Gf(ie)?ga({address:u.address,appConfig:ie,methodScreen:cr.FUNDING_METHOD_SELECTION_SCREEN,fundWalletConfig:r,comingFromSendTransactionScreen:!0}):void 0;de({connectWallet:m,sendSolanaTransaction:{transactionRequest:e,connection:t,transactionOptions:n,transactingWallet:u,onSuccess:e=>{o?ya(be,"signSolanaTransaction","onSuccess",{signedTransaction:e.signedTransaction}):ya(be,"sendSolanaTransaction","onSuccess",{response:e}),s(e)},onFailure:e=>{ya(be,d,"onError",A.TRANSACTION_FAILURE),l(e)},uiOptions:a||{},requesterAppId:c,signOnly:o},funding:y}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}}));function Xe(){return new Promise((async(e,t)=>{let n=await rw();if(!n||!re)throw Error("Must have valid access token to enroll in MFA");try{await re.verifyMfa({accessToken:n}),e()}catch(e){t(e)}}))}let et=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],tt=e=>{let t=f?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:n,loginMethod:r}=Ep(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw ya(be,"linkAccount","onError",A.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:r}),new T(`User already has an account of type ${n} linked.`)};async function it({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){F(null);let n=t?"setWalletPassword":"setWalletRecovery";if(!y||!f)throw ya(be,n,"onError",A.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let r=wr(f);if(!r||!re)throw ya(be,n,"onError",A.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");try{await Xe()}catch(e){throw ya(be,n,"onError",A.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,i)=>{le(!0);let o={onSuccess:e=>{ya(be,n,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{ya(be,n,"onError",A.USER_EXITED_SET_PASSWORD_FLOW),i(e)},callAuthOnSuccessOnClose:!1},s="user-passcode"===r.recoveryMethod,l=Jc({walletAction:"update",availableRecoveryMethods:ie.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:s,showAutomaticRecovery:e}),{entropyId:c,entropyIdVerifier:d}=jn(r);de({setWalletPassword:o,recoverWallet:{entropyId:c,entropyIdVerifier:d,onFailure:i},createWallet:o,connectWallet:{onCompleteNavigateTo:l,shouldForceMFA:!1,entropyId:c,entropyIdVerifier:d,onFailure:e=>{ya(be,n,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),i(e)}},recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:s}}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}))}async function ot({appId:e,action:t}){let n=await rw();if("link"===t&&!n)throw ya(be,"linkAccount","onError",A.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new T("User must be authenticated before linking an account.");if("login"===t&&n)throw ya(be,"login","onError",A.UNKNOWN_AUTH_ERROR),new T("Attempted to log in, but user is already logged in. Use a `link` helper instead.");ke.current=`privy:${e}`,Ie.current=t;let r=Zh();return a.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,i)=>{let{name:o,logoUrl:s}=await Hf({api:a.api,providerAppId:e,requesterAppId:ie.id});de({crossAppAuth:{appId:e,name:o,logoUrl:s,action:t,popup:r,onSuccess:n,onError:i}}),Re(cr.CROSS_APP_AUTH_SCREEN)}))}let st={ready:p,authenticated:y,user:f,walletConnectors:a.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),de({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),Se(y?cr.CONNECT_ONLY_AUTHENTICATED_SCREEN:cr.CONNECT_ONLY_LANDING_SCREEN)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),Be("siwe"),ke.current="siwe",Ie.current="link",de({...ce,externalConnectWallet:{...ce.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),Se(cr.LINK_WALLET_SCREEN)},startCrossAppAuthFlow:ot,linkEmail:()=>{Be("email"),tt("email"),ke.current="email",Ie.current="link",Se(cr.LINK_EMAIL_SCREEN)},linkPhone:()=>{Be("sms"),tt("phone"),ke.current="sms",Ie.current="link",Se(cr.LINK_PHONE_SCREEN)},linkGoogle:async()=>{Be("google"),tt("google_oauth"),Ie.current="link",await lt.initLoginWithOAuth("google")},linkTwitter:async()=>{Be("twitter"),tt("twitter_oauth"),Ie.current="link",await lt.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Be("discord"),tt("discord_oauth"),Ie.current="link",await lt.initLoginWithOAuth("discord")},linkGithub:async()=>{Be("github"),tt("github_oauth"),Ie.current="link",await lt.initLoginWithOAuth("github")},linkSpotify:async()=>{Be("spotify"),tt("spotify_oauth"),Ie.current="link",await lt.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Be("instagram"),tt("instagram_oauth"),Ie.current="link",await lt.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Be("tiktok"),tt("tiktok_oauth"),Ie.current="link",await lt.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Be("linkedin"),tt("linkedin_oauth"),Ie.current="link",await lt.initLoginWithOAuth("linkedin")},linkApple:async()=>{Be("apple"),tt("apple_oauth"),Ie.current="link",await lt.initLoginWithOAuth("apple")},linkPasskey:async()=>{Be("passkey"),tt("passkey"),await lt.initLinkWithPasskey(),Se(cr.LINK_PASSKEY_SCREEN)},linkTelegram:async e=>{if(Be("telegram"),tt("telegram"),Ie.current="link",ke.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new Qo;a.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=es(e.launchParams.initDataRaw),de({telegramAuthModalData:{seamlessAuth:!0}}),Re(cr.TELEGRAM_AUTH_SCREEN)}else ya(be,"linkAccount","onError",A.INVALID_DATA,{linkMethod:"telegram"});else await lt.initLoginWithTelegram();Se(cr.TELEGRAM_AUTH_SCREEN)},linkFarcaster:async()=>{Be("farcaster"),tt("farcaster"),await lt.initLoginWithFarcaster(),Ie.current="link",ke.current="farcaster",Se(cr.AWAITING_FARCASTER_CONNECTION)},updateEmail:()=>{if(Be("email"),!f?.email)throw new T("User does not have an email linked to their account.");Ie.current="update",ke.current="email",Se(cr.UPDATE_EMAIL_SCREEN)},updatePhone:()=>{if(Be("sms"),!f?.phone)throw new T("User does not have a phone number linked to their account.");Ie.current="update",ke.current="sms",Se(cr.UPDATE_PHONE_SCREEN)},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(!p){let e=await new Promise((e=>{he((t=>e.bind(t)))}));if(he(null),e)return void console.warn(t)}!f||f.isGuest?(Ie.current="login",de({login:e}),Re(cr.LANDING)):console.warn(t)},connectOrCreateWallet:async()=>{p||(await new Promise((e=>{he((()=>e))})),he(null)),y?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(Ie.current="login",Re(cr.CONNECT_OR_CREATE))},logout:async()=>{if(Ie.current=null,ke.current=null,f&&a.clearProviderAcccessTokens(f),F(null),await a.logout(),f&&re)try{await re.clearMfa({userId:f.id})}catch(e){}w(null),g(!1),ya(be,"logout","onSuccess"),h(!1),Zr.del(sr),Zr.del(Dn(ie.id))},getAccessToken:c((()=>a.getCustomerAccessToken()),[a]),unlinkWallet:async e=>{let t;return w(t=e.startsWith("0x")?await a.unlinkEthereumWallet(e):await a.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await a.unlinkEmail(e);return w(t),t},unlinkPhone:async e=>{let t=await a.unlinkPhone(e);return w(t),t},unlinkGoogle:async e=>{let t=await a.unlinkOAuth("google",e);return w(t),t},unlinkTwitter:async e=>{let t=await a.unlinkOAuth("twitter",e);return w(t),t},unlinkDiscord:async e=>{let t=await a.unlinkOAuth("discord",e);return w(t),t},unlinkGithub:async e=>{let t=await a.unlinkOAuth("github",e);return w(t),t},unlinkSpotify:async e=>{let t=await a.unlinkOAuth("spotify",e);return w(t),t},unlinkInstagram:async e=>{let t=await a.unlinkOAuth("instagram",e);return w(t),t},unlinkTiktok:async e=>{let t=await a.unlinkOAuth("tiktok",e);return w(t),t},unlinkLinkedIn:async e=>{let t=await a.unlinkOAuth("linkedin",e);return w(t),t},unlinkApple:async e=>{let t=await a.unlinkOAuth("apple",e);return w(t),t},unlinkFarcaster:async e=>{let t=await a.unlinkFarcaster(e);return w(t),t},unlinkTelegram:async e=>{let t=await a.unlinkTelegram(e);return w(t),t},unlinkPasskey:async e=>{let t=await rw();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!re)throw Error("Wallet proxy not initialized.");let n=ie.passkeys.shouldUnenrollMfaOnUnlink;await re.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:n});let r=await a.getAuthenticatedUser();return w(r),r},unlinkCrossAppAccount:async({subject:e})=>{let t=f?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new T("Invalid subject");a.storeProviderAccessToken(t.id,null);let n=await a.unlinkOAuth(`privy:${t.id}`,e);return w(n),n},createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let t=await lt.refreshSessionAndUser();if(!t)throw ya(be,"createWallet","onError",A.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return $e(t,15e3,e)},setWalletRecovery:async e=>it({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>it({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=e.message;if(!y||!f)return ya(be,"signMessage","onError",A.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let s=t?.address??yr(f)?.address;if(!s)throw new T("User must have an embedded wallet to sign a message.");let{signingWallet:l,rootWallet:c}=$r(f,s);if(!l||!c)return ya(be,"signMessage","onError",A.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));if("string"!=typeof o||o.length<1)return ya(be,"signMessage","onError",A.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));le(!0);let d=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let e=await rw();if(!re||!e||!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:l.address,requesterAppId:i}});let{entropyId:t,entropyIdVerifier:n}=jn(c),{response:r}=await re.rpc({accessToken:e,entropyId:t,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:l.walletIndex??0,requesterAppId:i,request:{method:"personal_sign",params:[o,l.address]}}),s=r.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:l.address,requesterAppId:i}}),s};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await d();ya(be,"signMessage","onSuccess",{signature:e}),n({signature:e})}catch(e){ya(be,"signMessage","onError",A.UNABLE_TO_SIGN),r(e??new ca("Unable to sign message"))}else{let e={method:"personal_sign",data:o,confirmAndSign:d,onSuccess:e=>{ya(be,"signMessage","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{ya(be,"signMessage","onError",A.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},{entropyId:a,entropyIdVerifier:i}=jn(c);de({signMessage:e,connectWallet:{entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{ya(be,"signMessage","onError",A.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),signTypedData:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{};if(!y||!f)return ya(be,"signTypedData","onError",A.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let o=t?.address??yr(f)?.address;if(!o)throw new T("User must have an embedded wallet to sign a message.");let{signingWallet:s,rootWallet:l}=$r(f,o);if(!l||!s)return ya(be,"signTypedData","onError",A.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));le(!0);let c=Je(e),d=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let e=await rw();if(!re||!e||!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:s.address,requesterAppId:i}});let{entropyId:t,entropyIdVerifier:n}=jn(l),{response:r}=await re.rpc({accessToken:e,entropyId:t,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:s.walletIndex??0,requesterAppId:i,request:{method:"eth_signTypedData_v4",params:[s.address,c]}}),o=r.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:s.address,requesterAppId:i}}),o};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await d();ya(be,"signTypedData","onSuccess",{signature:e}),n({signature:e})}catch(e){ya(be,"signTypedData","onError",A.UNABLE_TO_SIGN),r(e??new ca("Unable to sign message"))}else{let e={method:"eth_signTypedData_v4",data:c,confirmAndSign:d,onSuccess:e=>{ya(be,"signTypedData","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{ya(be,"signTypedData","onError",A.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},{entropyId:a,entropyIdVerifier:i}=jn(l);de({signMessage:e,connectWallet:{entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{ya(be,"signMessage","onError",A.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),sendTransaction:async(e,t)=>await Ye({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await Ye({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!y||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let i=e?.address??yr(f)?.address;if(!i)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(!E(i))return void r(Error("Must provide a valid Ethereum address."));let{signingWallet:o,rootWallet:s}=$r(f,i);if(!o||!s)return void r(Error("Must have a Privy wallet before exporting"));le(!0);let{entropyId:l,entropyIdVerifier:c}=jn(s),d={entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:cr.EMBEDDED_WALLET_KEY_EXPORT_SCREEN,onFailure:r,shouldForceMFA:!0};de(ce),await rw()&&re?re?(de({keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:o,primaryWallet:s,onSuccess:t,onFailure:r},connectWallet:d}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:Xe,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 T("Invalid MFA code");Ee.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{Te.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new T("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));Ee.current?.resolve({mfaMethod:e,mfaCode:r,relyingParty:window.origin}),await new Promise(((e,t)=>{Te.current={resolve:e,reject:t}}));break;default:throw Ee.current?.reject(new T("Unsupported MFA method")),new T(`Unsupported MFA method: ${e}`)}},cancel(){Ee.current?.reject(new T("MFA canceled"))},async initEnrollmentWithSms(e){let t=await rw();if(!t||!re)throw Error("Must have valid access token to enroll in MFA");await re.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,n)=>{if(!e)return lt.closePrivyModal(),void t();ie.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."),de({mfaEnrollmentFlow:{mfaMethods:ie.mfa.methods,shouldUnlinkOnUnenrollMfa:ie.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:n}}),Se(cr.MFA_ENROLLMENT_FLOW_SCREEN)})),async initEnrollmentWithTotp(){let e=await rw();if(!e||!re)throw Error("Must have valid access token to enroll in MFA");let t=await re.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await rw();if(!t||!re)throw Error("Must have valid access token to enroll in MFA");await re.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),w(await a.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await rw();if(!t||!re)throw Error("Must have valid access token to enroll in MFA");await re.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),w(await a.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let n=await rw();if(!n||!re)throw Error("Must have valid access token to enroll in MFA");await re.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:e,removeForLogin:t.removeForLogin}),w(await a.getAuthenticatedUser())},async unenroll(e,t={}){let n=await rw();if(!n||!re)throw Error("Must have valid access token to remove MFA");"passkey"===e?await re.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:[],removeForLogin:t.removeForLogin}):await re.unenrollMfa({method:e,accessToken:n}),w(await a.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await rw(),t=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!re||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");let n=await re.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===n.status&&w(await a.getAuthenticatedUser()||f||null),de({farcasterSigner:n}),Se(cr.AWAITING_FARCASTER_SIGNER)},getFarcasterSignerPublicKey:async()=>{let e,t=await rw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!re||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=f.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await rw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!re||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let r=await import("@simplewebauthn/browser"),a=await re.signFarcasterMessage({address:n.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:r.bufferToBase64URLString(e)},fid:BigInt(f.farcaster.fid),relyingParty:window.origin});return new Uint8Array(r.base64URLStringToBuffer(a.signature))},createGuestAccount:async()=>{if(f&&!f.isGuest)throw Error("User cannot already be authenticated to create a guest account");return f?.isGuest?f:lt.loginWithGuestAccountFlow()},signMessageWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Vf({user:f,client:a,address:t,requesterAppId:ie.id,request:{method:r?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:n},reconnect:ot})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),i=Je(e);return Vf({user:f,client:a,address:t,requesterAppId:ie.id,request:{method:r?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,i],chainId:n},reconnect:ot})},sendTransactionWithCrossAppWallet(e,{address:t}){let n=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Vf({user:f,client:a,address:t,requesterAppId:ie.id,request:{method:n?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:ot})},isModalOpen:u,mfaMethods:ie.mfa.methods};Yf=st.signMessage,Zf=st.signTypedData,Qf=async(e,t)=>await Ye({transaction:e,...t,signOnly:!1}),Jf=async(e,t)=>({signature:(await Ye({transaction:e,...t,signOnly:!0})).hash});let lt={setAuthenticated:g,setUser:w,isNewUserThisSession:O,pendingTransaction:null,walletConnectionStatus:H,connectors:a.connectors?.walletConnectors??[],solanaWallets:N,rpcConfig:ie.rpcConfig,chains:ie.chains,appId:n.appId,showFiatPrices:"native-token"!==ie.embeddedWallets.priceDisplay.primary,clientAnalyticsId:a.clientAnalyticsId,customAuthStatus:ve,hideWalletUIs:Ne,isHeadlessSigning:c(xe,[ie.embeddedWallets.showWalletUIs]),emailOtpState:G,setEmailOtpState:q,smsOtpState:K,setSmsOtpState:Y,oAuthState:X,setOAuthState:ee,telegramAuthState:te,setTelegramAuthState:ne,siweState:J,setSiweState:Q,isHeadlessOAuthLoading:B,nativeTokenSymbolForChainId:e=>ie.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(re)return re;let t=new Promise((e=>{me((()=>t=>e(t)))})),n=new Promise((t=>setTimeout((()=>t(null)),e))),r=await Promise.race([t,n]);return me(null),r},getAuthFlow:()=>a.authFlow,getAuthMeta:()=>a.authFlow?.meta,client:a,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=p&&y&&f;r&&ke.current&&(t=et(f)),"login"===Ie.current?e.shouldCallAuthOnSuccess&&r&&ke.current?ya(be,"login","onComplete",{user:f,isNewUser:O,wasAlreadyAuthenticated:!1,loginMethod:ke.current,loginAccount:t??null}):ya(be,"login","onError",A.USER_EXITED_AUTH_FLOW):"link"===Ie.current&&t?e.isSuccess&&r&&ke.current?ya(be,"linkAccount","onSuccess",{user:f,linkMethod:ke.current,linkedAccount:t}):ke.current&&ya(be,"linkAccount","onError",A.USER_EXITED_LINK_FLOW,{linkMethod:ke.current}):"update"===Ie.current&&t&&(e.isSuccess&&r&&ke.current?ya(be,"update","onSuccess",{user:f,updateMethod:ke.current,updatedAccount:t}):ke.current&&ya(be,"update","onError",A.USER_EXITED_UPDATE_FLOW,{linkMethod:ke.current}));let i=U&&Lh.includes(U),o=U===cr.ERROR_SCREEN&&ce.errorModalData&&Lh.includes(ce.errorModalData.previousScreen);if((i||o)&&ce.funding){let e,t=Dh[U]??null;if("solana"===ce.funding.chainType){let n=d(aa);if(!n)return void console.warn("Unable to load solana plugin, skipping balance");try{e=BigInt(await n.getBalance({address:ce.funding.address,cluster:ce.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}ya(be,"fundSolanaWallet","onUserExited",{address:ce.funding.address,cluster:ce.funding.cluster,fundingMethod:t,balance:e})}else{let r=Ha(ce.funding.chain.id,ie.chains,ie.rpcConfig,{appId:n.appId});try{e=await r.getBalance({address:ce.funding.address})}catch{console.error("Unable to pull wallet balance")}ya(be,"fundWallet","onUserExited",{address:ce.funding.address,chain:ce.funding.chain,fundingMethod:t,balance:e})}}de({...ce,externalConnectWallet:{suggestedAddress:void 0}}),Ie.current=null,ke.current=null,W(!1),h(!1),setTimeout((()=>{a.authFlow=void 0}),200)},solanaSignMessage:({message:e,options:t})=>new Promise((async(n,r)=>{if(!y||!f)return ya(be,"signSolanaMessage","onError",A.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let i=t?.address??gr(f)?.address;if(!i)throw new T("User must have an embedded wallet to sign a message.");let{signingWallet:o,rootWallet:s}=Dr(f,i);if(!o||!s)return ya(be,"signSolanaMessage","onError",A.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));if("string"!=typeof e||e.length<1)return ya(be,"signMessage","onError",A.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));le(!0);let l=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let t=await a.getAccessToken();if(!t)throw Error("User must be authenticated to use their embedded wallet.");let n=lt.walletProxy??await lt.initializeWalletProxy(15e3);if(!n)throw Error("Failed to initialize embedded wallet proxy.");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!s)throw Error("No root wallet for signing wallet found");let{entropyId:r,entropyIdVerifier:i}=Kr(f),{response:l}=await n.rpc({accessToken:t,entropyId:r,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:o.walletIndex??0,request:{method:"signMessage",params:{message:e}}});return l.data.signature};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await l();ya(be,"signSolanaMessage","onSuccess",{signature:new Uint8Array(Buffer.from(e,"base64"))}),n({signature:e})}catch(e){r(e)}else{let a={method:"solana_signMessage",data:e,confirmAndSign:l,onSuccess:e=>{ya(be,"signSolanaMessage","onSuccess",{signature:new Uint8Array(Buffer.from(e,"base64"))}),n({signature:e})},onFailure:e=>{r(e)},uiOptions:t?.uiOptions},{entropyId:i,entropyIdVerifier:o}=jn(s);de({signMessage:a,connectWallet:{entropyId:i,entropyIdVerifier:o,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{ya(be,"signSolanaMessage","onError",A.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Re(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),signSolanaTransaction:async({transaction:e,connection:t,uiOptions:n,transactionOptions:r,address:a})=>{let i=a?S.find((e=>e.address===a)):S.slice().sort(((e,t)=>(e.walletIndex??0)-(t.walletIndex??0)))[0];if(!i)throw ya(be,"signSolanaTransaction","onError",A.EMBEDDED_WALLET_NOT_FOUND),new T("Embedded wallet not found",A.EMBEDDED_WALLET_NOT_FOUND);let{signedTransaction:o}=await Qe({transaction:e,connection:t,transactionOptions:r,uiOptions:n,wallet:i,signOnly:!0});return o},sendSolanaTransaction:async({transaction:e,connection:t,uiOptions:n,transactionOptions:r,fundWalletConfig:a,address:i})=>{let o=i?S.find((e=>e.address===i)):S.slice().sort(((e,t)=>(e.walletIndex??0)-(t.walletIndex??0)))[0];if(!o)throw ya(be,"sendSolanaTransaction","onError",A.EMBEDDED_WALLET_NOT_FOUND),new T("Embedded wallet not found",A.EMBEDDED_WALLET_NOT_FOUND);return await Qe({transaction:e,connection:t,transactionOptions:r,uiOptions:n,fundWalletConfig:a,wallet:o,signOnly:!1})},openPrivyModal:Se,connectWallet:Le,initLoginWithWallet:async(e,t,n)=>{rt(e)?(ke.current="siwe",De(e,t,n)):(ke.current="siws",Ue(e,t,n))},loginWithWallet:async()=>{let e,t,n;if(!p)throw new L;if(a.authFlow instanceof at?e="siwe":a.authFlow instanceof xn&&(e="siws"),!e)throw new T("Must initialize SIWE/SIWS flow first.");if(null!==await a.getAccessToken())try{({user:t}=await a.link()),ke.current=e}catch(t){throw ya(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:n}=await a.authenticate()),ke.current=e}catch(e){throw ya(be,"login","onError",e.privyErrorCode||A.GENERIC_CONNECT_WALLET_ERROR),e}w(t||f||null),W(n||!1),g(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:n})=>new Promise((async(r,a)=>{let i=await rw();if(!y||!f||!i)throw new T("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new T("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=lt.walletProxy??await lt.initializeWalletProxy(15e3);if(!o)throw new T("Wallet proxy not initialized.");if((({address:e,chainType:t,user:n})=>!!Lf(n).find((n=>n.address===e&&n.chainType===t)))({address:e,chainType:t,user:f}))return r();let s=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new T("Address to delegate is not associated with current user.");return{address:n.address,chainType:n.chainType,walletIndex:n.walletIndex??0}})({address:e,user:f}),l=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new T("Address to delegate is not associated with current user.");let r=n.imported?n:wr(t);if(!r)throw new T("Unable to determine root address for delegated address.");return{address:r.address,chainType:r.chainType,imported:r.imported}})({address:e,user:f}),c=async()=>{await o.createDelegatedAction({accessToken:i,rootWallet:l,delegatedWallets:[s]}),await lt.refreshSessionAndUser()};if(await lt.recoverPrimaryWallet(),n)de({delegatedActions:{consent:{address:e,onDelegate:c,onSuccess:async()=>{r()},onError:async e=>{a(e)}}}}),Se(cr.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN);else try{await c(),r()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,n)=>{if(!y||!f)throw new T("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");if(0===Lf(f).length)throw new T("User has no delegated wallets to revoke.");let r=async()=>{await a.revokeDelegatedWallet(),await lt.refreshSessionAndUser()};if(e)de({delegatedActions:{revoke:{onRevoke:r,onSuccess:async()=>{t()},onError:async e=>{n(e)}}}}),Se(cr.EMBEDDED_WALLET_DELEGATED_ACTIONS_REVOKE_SCREEN);else try{await r(),t()}catch(e){n(e)}})),initLoginWithFarcaster:async(e,t)=>{let n=new Io(e,t);a.startAuthFlow(n);try{ke.current="farcaster",await n.initializeFarcasterConnect()}catch(e){throw"login"===Ie.current?ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&ya(be,"linkAccount","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!p)throw new L;if(!(a.authFlow instanceof Io))throw new T("Must initialize Farcaster flow first.");if(null!==await a.getAccessToken())try{({user:e}=await a.link()),ke.current="farcaster"}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await a.authenticate()),ke.current="farcaster"}catch(e){throw ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}w(e||null),W(t||!1),g(!0)},async loginWithGuestAccountFlow(){let e=new xo(this.appId);a.startAuthFlow(e);try{Ie.current="login",ke.current="guest";let{user:e,isNewUser:t}=await a.authenticate();if(t=t||!1,!e)throw new T("Unable to authenticate guest account");let n=await rw(),r=await lt.initializeWalletProxy(fr);if(n&&r)try{let t=Wt(e,ie.embeddedWallets.ethereum.createOnLogin),a=Mt(e,ie.embeddedWallets.solana.createOnLogin);if(t&&a){let t=await $e(e,fr);await r.createSolana({accessToken:n,ethereumAddress:t?.address}),e=await lt.refreshSessionAndUser()}else a?(await r.createSolana({accessToken:n,ethereumAddress:yr(e)?.address}),e=await lt.refreshSessionAndUser()):t?(await $e(e,fr),e=await lt.refreshSessionAndUser()):w(e)}catch(t){w(e),console.warn("Unable to create embedded wallet for guest account")}return W(t),g(!0),ya(be,"login","onComplete",{user:e,isNewUser:t,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),e}catch(e){throw ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}},async crossAppAuthFlow({appId:e,popup:t,action:n}){let r=`privy:${e}`;ke.current=r;let{url:i,stateCode:o,codeVerifier:s}=await async function({api:e,appId:t}){let n=So(),r=Ro(),a=await Oo(n);try{let{url:i}=await e.post(Z,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:r});return{url:i,stateCode:r,codeVerifier:n}}catch(e){throw b(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 T("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 T("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 T("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 T(t.data.error)),i()),t.data.type===Bf&&((r=new BroadcastChannel(Ff)).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 T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED);let u=await async function({appId:e,stateCode:t,codeVerifier:n,authorizationCode:r,action:a,client:i}){if(!r||!t)throw new T("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===r)throw new T("User denied confirmation during cross-app auth flow");try{let o=new zf({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=b(e);if(t.privyErrorCode)throw new T(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 T("Invalid code during cross-app auth flow.",void 0,A.OAUTH_USER_DENIED);throw new T("Invalid code during cross-app auth flow.",void 0,A.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:s,stateCode:c,authorizationCode:d,action:n,client:a});u&&a.storeProviderAccessToken(e,u);let h=await lt.refreshSessionAndUser();if(!h)throw new T("Unable to update user");return a.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),h}catch(e){throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:r}}),e}},async initLoginWithOAuth(e,t,n){if(ke.current=e,!Yr())return void Re(cr.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE);if("google"===e&&vc(window.navigator.userAgent))return void Re(cr.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE);"twitter"===e&&window.opener&&window.opener.postMessage({type:Bf},"*"),Zr.del(Fn),Zr.del(Bn);let r=new Wo({provider:e,disableSignup:!!n,withPrivyUi:!0});t&&r.addCaptchaToken(t),a.startAuthFlow(r);let i=await a.authFlow.getAuthorizationUrl();i&&i.url&&("twitter"===e&&v&&(i.url=i.url.replace("x.com","twitter.com")),window.location.assign(i.url))},async initLoginWithTelegram(e,t){if(!p)throw new L;ke.current="telegram";let n=new Qo(e,t);a.startAuthFlow(n),ne({status:"loading"}),n.meta.telegramWebAppData=void 0,n.meta.telegramAuthResult=await new Promise(((e,t)=>ie.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:ie.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(n=>n?e(n):t(new T("Telegram auth failed or was canceled by the client")))):t(new T("Telegram was not initialized")):t(new T("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,n;if(!(a.authFlow instanceof Qo))throw new T("Must initialize Telegram flow before calling loginWithTelegram");a.authFlow.meta.captchaToken||=e?.captchaToken;let r=await rw(),i=e?.intent||Ie.current;if("login"===i)try{let e=await a.authenticate();t=e.user,n=e.isNewUser,ke.current="telegram"}catch(e){throw ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}else{if("link"!==i)throw new T("Unknown auth intent");try{t=(await a.link()).user,ke.current="telegram"}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}w(t),W(n||!1),g(!0),ne({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:o}},async recoveryOAuthFlow(e,t,n){let r,i;function o(t){if(!t)throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:e}}),new T("Recovery OAuth failed")}switch(e){case"google-drive":{let t,s,{url:l,codeVerifier:c,stateCode:d}=await Xc({api:Kf.api,provider:e});o(l);try{let r=await qf({url:l,popup:n,provider:e});if(t=r.stateCode,s=r.authorizationCode,t!==d)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:d??"",returnedStateCode:t??""}}),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED)}catch(t){throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:e}}),new T("Recovery OAuth failed")}[r,i]=await Promise.all([rw(),ed({api:Kf.api,provider:e,codeVerifier:c,stateCode:t,authorizationCode:s})]);break}case"icloud":{let{url:t}=await Xc({api:Kf.api,provider:e});o(t);let{ckWebAuthToken:a}=await qf({url:t,popup:n,provider:e});i=a,r=await rw()}}if(!re)throw new T("Cannot connect to wallet proxy");if(!r)throw new T("Unable to authorize user");switch(t){case"recover":{let t=ce.recoverWallet?.entropyId,n=ce.recoverWallet?.entropyIdVerifier;if(!t||!n)throw new T("Recovery OAuth failed");a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t,recoveryMethod:e}}),await re.recover({accessToken:r,entropyId:t,entropyIdVerifier:n,recoveryAccessToken:i}),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t,recoveryMethod:e}});break}case"create-wallet":{a.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await re.create({accessToken:r,recoveryAccessToken:i,recoveryMethod:e});let t=yr(await lt.refreshSessionAndUser());if(!t)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.address}}),ya(be,"createWallet","onSuccess",{wallet:t});break}case"set-recovery":{let t=wr(f);if(!t)throw ya(be,"setWalletRecovery","onError",A.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}});let{entropyId:n,entropyIdVerifier:o}=jn(t);await re.setRecovery({accessToken:r,entropyId:n,entropyIdVerifier:o,recoveryMethod:e,recoveryAccessToken:i});let s=wr(await lt.refreshSessionAndUser());if(!s)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}}),ya(be,"setWalletRecovery","onSuccess",{method:e,wallet:s});break}default:throw new T("Unsupported recovery action")}},async loginWithOAuth(e){let t,n,r;if(!(a.authFlow instanceof Wo))throw new T("Must initialize OAuth flow before calling loginWithOAuth");let i=Zr.get(zn),o=a.authFlow.meta.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:i??"",returnedStateCode:o??""}}),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{let n=await a.link();t=n.user,r=n.oAuthTokens,ke.current=e}catch(t){throw ya(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let i=await a.authenticate();t=i.user,n=i.isNewUser,r=i.oAuthTokens,ke.current=e}catch(t){throw"login"===Ie.current?ya(be,"login","onError",t.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&ya(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return w(t),W(n||!1),g(!0),r&&t&&ya(be,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),r},passkeyAuthState:$,setPasskeyAuthState:j,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new Yo({captchaToken:e,setPasskeyAuthState:j});a.startAuthFlow(n),Ie.current="login";try{ke.current="passkey",j({status:"generating-challenge"}),await n.initRegisterFlow(t),j({status:"awaiting-passkey"})}catch(e){throw j({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!p)throw new L;if(!(a.authFlow instanceof Yo))throw new T("Must initialize Passkey flow first.");if("passkey"!==ke.current){let e=new T("Must init login with Passkey flow first.");throw j({status:"error",error:e}),e}let n=await rw();try{ke.current="passkey",j({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await a.authenticate())}catch(e){throw j({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}w(e),W(t||!1),g(!0),j({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 Yo({captchaToken:e,setPasskeyAuthState:j});a.startAuthFlow(n),Ie.current="login";try{ke.current="passkey",j({status:"generating-challenge"}),await n.initAuthenticationFlow(t),j({status:"awaiting-passkey"})}catch(e){throw j({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,n;if(!p)throw new L;if(!(a.authFlow instanceof Yo))throw new T("Must initialize Passkey flow first.");if(e?.credentialIds&&(a.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==ke.current){let e=new T("Must init login with Passkey flow first.");throw j({status:"error",error:e}),e}let r=await rw();try{ke.current="passkey",j({status:"awaiting-passkey"}),({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw j({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}w(t),W(n||!1),g(!0),j({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 Yo({captchaToken:e});a.startAuthFlow(t),Ie.current="link",ke.current="passkey",j({status:"generating-challenge"});try{await t.initLinkFlow(),j({status:"awaiting-passkey"})}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),j({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!p)throw new L;if(!(a.authFlow instanceof Yo))throw new T("Must initialize Passkey flow first.");if("passkey"!==ke.current)throw new T("Must init login with Passkey flow first.");try{ke.current="passkey",({user:e}=await a.link())}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return w(e||f||null),j({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,n){if(!Yr())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&&vc(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 Wo({provider:e,withPrivyUi:!1,disableSignup:n??!1});t&&r.addCaptchaToken(t),ee({status:"loading"});let i=await a.startAuthFlow(r).getAuthorizationUrl();i?.url&&window.location.assign(i.url)},async loginWithHeadlessOAuth(e){let t,n,r;z(!0),ee({status:"loading"}),a.startAuthFlow(new Wo(e));let i=Zr.get(zn),o=e.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:i??"",returnedStateCode:o??""}}),z(!1),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{({user:t,oAuthTokens:r}=await a.link()),ke.current=e.provider;let n=et(t);t&&n&&ya(be,"linkAccount","onSuccess",{user:t,linkMethod:ke.current,linkedAccount:n})}catch(t){throw z(!1),ya(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:n,oAuthTokens:r}=await a.authenticate()),ke.current=e.provider;let i=et(t);t&&i&&void 0!==n&&ya(be,"login","onComplete",{user:t,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:ke.current,loginAccount:i})}catch(e){throw z(!1),ee({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}return w(t),W(n||!1),g(!0),z(!1),ee({status:"done"}),r&&t&&ya(be,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{let i=new _o({email:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ke.current="email",q({status:"sending-code"}),await i.sendCodeEmail({withPrivyUi:r}),q({status:"awaiting-code-input"})}catch(e){throw q({status:"error",error:e}),"login"===Ie.current?ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,n)=>{let r=new ko(e,t,n);a.startAuthFlow(r);try{await r.sendCodeEmail({withPrivyUi:!0})}catch(e){ya(be,"update","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:ke.current})}},initUpdatePhone:async(e,t,n)=>{let r=new Jo(e,t,n);a.startAuthFlow(r);try{await r.sendSmsCode({withPrivyUi:!0})}catch(e){ya(be,"update","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:ke.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{Y({status:"sending-code"});let i=new Zo({phoneNumber:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ke.current="sms",await i.sendSmsCode({withPrivyUi:r}),Y({status:"awaiting-code-input"})}catch(e){throw Y({status:"error",error:e}),"login"===Ie.current?ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&ya(be,"linkAccount","onError",e.privyErrorCode||A.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 _o?q(e):a.authFlow instanceof Zo&&Y(e)}if(r({status:"submitting-code"}),!p){let e=new L;throw r({status:"error",error:e}),e}if(a.authFlow instanceof _o)a.authFlow.meta.emailCode=e.trim();else{if(!(a.authFlow instanceof Zo)){let e=new T("Must initialize a passwordless code flow first");throw r({status:"error",error:e}),e}a.authFlow.meta.smsCode=e.trim()}let i=await rw();if("link"===Ie.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:ke.current}),e}else if("update"===Ie.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),ya(be,"update","onError",e.privyErrorCode||A.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:ke.current}),e}else try{({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw r({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}let o=t||f;w(o||null),W(n||!1),g(!0),r({status:"done"});let s=null;return a.authFlow instanceof _o?s=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:a.authFlow instanceof Zo&&(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})=>{Ie.current="link",ke.current="siwe",Q({status:"generating-message"});let r=await a.generateSiweNonce({address:e,captchaToken:n});return Q({status:"awaiting-signature"}),Sn({address:e,chainId:t.replace("eip155:",""),nonce:r})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let n=await a.generateSiweNonce({address:e});return Sn({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}),w((r=await lt.refreshSessionAndUser()??r)||f||null)},linkWithSiwe:async({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i})=>{let o;Be("siwe");let s=null;try{Q({status:"submitting-signature"}),o=await a.linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i}),o=await lt.refreshSessionAndUser()??o,Q({status:"done"}),(s=et(o)||null)&&ya(be,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:s})}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),Ie.current=null,ke.current=null,Q({status:"error",error:e}),e}let l=o||f;return w(l||null),Ie.current=null,ke.current=null,{user:l,linkedAccount:s}},refreshSessionAndUser:async()=>{let e=await a.getAuthenticatedUser();return g(!!e),w(e),e},walletProxy:re,createAnalyticsEvent:({eventName:e,payload:t,timestamp:n})=>a.createAnalyticsEvent({eventName:e,payload:t,timestamp:n}),acceptTerms:async()=>{let e=await a.acceptTerms();return w(e),e},getUsdTokenPrice:e=>a.getUsdTokenPrice(e),getUsdPriceForSol:()=>a.getUsdPriceForSol(),getSplTokenMetadata:e=>a.getSplTokenMetadata(e),recoverPrimaryWallet:async e=>new Promise((async(t,n)=>{let r=wr(e?.user??f)||Hr(e?.user??f)||Lr(e?.user??f);r||t(!0);let i=await rw();if(!i||!re||!r)return void n(Error("Must have valid access token and Privy wallet to recover wallet"));le(!0);let{entropyId:o,entropyIdVerifier:s}=jn(r);try{await re.connect({accessToken:i,entropyId:o,entropyIdVerifier:s}),t(!0)}catch(e){$c(e)&&"privy"===r.recoveryMethod?(a.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:r.address}}),(await re.recover({entropyId:o,entropyIdVerifier:s,accessToken:i})).entropyId||n(Error("Unable to recover wallet")),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:r.address}}),t(!0)):$c(e)&&"privy"!==r.recoveryMethod?(de({recoverWallet:{entropyId:o,entropyIdVerifier:s,onFailure:n,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:r.recoveryMethod,action:"recover"}}),Se(Qc(r.recoveryMethod))):n(e)}})),embeddedSolanaWallets:S,createEmbeddedSolanaWallet:async e=>{e&&"target"in e&&(e=void 0);let t=await lt.refreshSessionAndUser();if(!t)throw ya(be,"createWallet","onError",A.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return(async(e,t,n)=>{let r=yr(e),a=gr(e),i=n&&"createAdditional"in n&&n.createAdditional,o=n&&"walletIndex"in n?n.walletIndex:void 0,s=(qr(e)?.walletIndex??-1)+1;if(a&&!i&&"number"!=typeof o)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");if("number"==typeof o&&o<0)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${o}) is invalid.`);let[l,c]=await Promise.all([lt.initializeWalletProxy(t),rw()]);if(!l||!c)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return await qe({user:e,wp:l,accessToken:c,walletIndex:o??s,ethereumWallet:r})})(t,15e3,e)},exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!y||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));let i=e?.address??gr(f)?.address;if(!i)return void r(Error("User does not have an HD Solana wallet."));let{signingWallet:o,rootWallet:s}=Dr(f,i);if(!o||!s)return void r(Error("Must have a Privy wallet before exporting"));if(le(!0),!await rw()||!re)return void r(Error("Must have valid access token to enroll in MFA"));if(!re)return void r(Error("Must have a Privy wallet before exporting"));let{entropyId:l,entropyIdVerifier:c}=jn(s);de({connectWallet:{entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:cr.EMBEDDED_WALLET_KEY_EXPORT_SCREEN,onFailure:r,shouldForceMFA:!0},keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:o,primaryWallet:s,onSuccess:t,onFailure:r}}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)})),setReadyToTrue:e=>{m(!0),ue?.(e)},updateWallets:()=>Ve(),fundWallet:async(e,t)=>{let n=cr.FUNDING_METHOD_SELECTION_SCREEN;de({funding:fa({address:e,appConfig:ie,fundWalletConfig:t,methodScreen:n})}),Se(n)},openModal:Se,requestFarcasterSignerStatus:async e=>{let t=await rw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!re||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let r=await a.requestFarcasterSignerStatus(e);return"approved"===r.status&&w(await a.getAuthenticatedUser()||f||null),r},connectCoinbaseSmartWallet:async()=>{ie.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let e=a.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||a.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Le(e);await Pe("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 w(c),c}};Xf=lt.recoverPrimaryWallet,ew=lt.recoverPrimaryWallet,tw=lt.solanaSignMessage;let ct=i((()=>({wallets:k,ready:ye&&Ae})),[k,ye,Ae]),dt=a.authFlow instanceof Qo,ut=!ie.headless&&ie.captchaEnabled&&!y&&(p||dt);/*#__PURE__*/return t(Wr.Provider,{value:st,children:/*#__PURE__*/t(wa.Provider,{value:be,children:/*#__PURE__*/t(jr.Provider,{value:ct,children:/*#__PURE__*/t(Rn,{...ie,children:/*#__PURE__*/e(D.Provider,{value:lt,children:[/*#__PURE__*/t(On,{children:/*#__PURE__*/e(Gr,{data:ce,setModalData:de,setInitialScreen:F,initialScreen:U,authenticated:y,open:u,children:[n.children,ut&&/*#__PURE__*/t(Ys,{delayedExecution:!1}),/*#__PURE__*/t(uf,{theme:{...ie.appearance.palette||{}}}),!ie.render.standalone&&/*#__PURE__*/t(bf,{open:u})]})}),se&&oe?/*#__PURE__*/t(Pf,{appId:n.appId,appClientId:n.clientId,clientAnalyticsId:a.clientAnalyticsId,origin:a.apiUrl,mfaMethods:f?.mfaMethods,mfaPromise:Ee,mfaSubmitPromise:Te,onLoad:ae,onLoadFailed:()=>null}):null,ie.loginConfig.telegramAuthConfiguration&&
22
- /*#__PURE__*/t(sl,{$if:!0,children:/*#__PURE__*/t(kf,{scriptHost:n.apiUrl||ir,botUsername:ie.loginConfig.telegramAuthConfiguration.botName})})]})})})})})};const pw=()=>{let{getAccessToken:e,user:t}=ur(),{refreshSessionAndUser:n,initializeWalletProxy:r}=x(),a=ua();return{importWallet:c((({privateKey:i})=>Co({getAccessToken:e,user:t,initializeWalletProxy:r,refreshSessionAndUser:n,emitPrivyEvent:a},{privateKey:i,chainType:"ethereum"})),[t,e,n,r,a])}},mw=()=>{let{importWallet:e}=pw();return{...h(Wr),importWallet:e}},yw=e=>{ta("login",e);let t=it(),n=Fr(),{ready:r,user:a}=ur(),{initLoginWithHeadlessOAuth:i,loginWithHeadlessOAuth:s,oAuthState:l,setOAuthState:d,isHeadlessOAuthLoading:u}=x(),h=c((async e=>{try{if(t.enabled&&"success"!==t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);return await i(e.provider,t.token,e.disableSignup)}catch(e){throw d({status:"error",error:e}),e}}),[i,t]),p=c((async()=>{let e=qo();try{if(a)return console.warn("Cannot login with OAuth when already logged in"),a;if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(e.popupFlow)return}catch(e){throw d({status:"error",error:e}),e}try{return await s(e)}catch(e){throw d({status:"error",error:e}),e}finally{Ko()}}),[s]);return o((()=>{let e=qo();r&&n&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&p().catch((()=>{}))}),[r,n]),{initOAuth:h,loading:u,state:l}},gw=e=>{let t=it(),{emailOtpState:n,setEmailOtpState:r,initLoginWithEmail:a,loginWithCode:i}=x();return{sendCode:c((async({email:n,disableSignup:i})=>{try{let e;if(!n)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({email:n,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[a]),loginWithCode:c((async({code:n})=>{try{if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);let{user:r,isNewUser:a,wasAlreadyAuthenticated:o,linkedAccount:s}=await i(n);e?.onComplete?.({user:r,isNewUser:a,wasAlreadyAuthenticated:o,loginMethod:"email",loginAccount:s})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[i,t.status]),state:n}},fw=e=>{let t=it(),{initSignupWithPasskey:n,signupWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:i}=x();return{signupWithPasskey:c((async()=>{try{let a;if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult()),await n({captchaToken:a,withPrivyUi:!1});let{user:i,isNewUser:o,wasAlreadyAuthenticated:s,loginAccount:l}=await r();e?.onComplete?.({user:i,isNewUser:o,wasAlreadyAuthenticated:s,loginMethod:"passkey",loginAccount:l})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||A.UNKNOWN_AUTH_ERROR),t}}),[r,t.status]),state:a}},ww=e=>{let t=it(),{initLoginWithPasskey:n,loginWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:i}=x();return{loginWithPasskey:c((async a=>{try{let i;if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await n({captchaToken:i,withPrivyUi:!1});let{user:o,isNewUser:s,wasAlreadyAuthenticated:l,loginAccount:c}=await r(a);e?.onComplete?.({user:o,isNewUser:s,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(a){throw i({status:"error",error:a}),e?.onError?.(a.privyErrorCode||A.UNKNOWN_AUTH_ERROR),a}}),[r,t.status]),state:a}},vw=e=>{let{initLinkWithPasskey:t,linkWithPasskey:n,passkeyAuthState:r,setPasskeyAuthState:a}=x();return{linkWithPasskey:c((async()=>{try{await t();let r=await n();if(!r)throw Error("Error, user not found");let a=r.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:r,linkMethod:"passkey",linkedAccount:a})}catch(t){throw a({status:"error",error:t}),e?.onError?.(t.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[n]),state:r}},Cw=e=>{let t=it(),{smsOtpState:n,setSmsOtpState:r,initLoginWithSms:a,loginWithCode:i}=x();return{sendCode:c((async({phoneNumber:n,disableSignup:i})=>{try{let e;if(!n)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({phoneNumber:n,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[a]),loginWithCode:c((async({code:n})=>{try{if(t.enabled&&"success"!==t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);let{user:r,isNewUser:a,wasAlreadyAuthenticated:o,linkedAccount:s}=await i(n);e?.onComplete?.({user:r,isNewUser:a,wasAlreadyAuthenticated:o,loginMethod:"sms",loginAccount:s})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[i,t.status]),state:n}},Ew=e=>{let t=it(),{siweState:n,setSiweState:r,linkWithSiwe:a,generateSiweMessage:i}=x();return{generateSiweMessage:c((async({address:t,chainId:n})=>{try{if(!t||!n)throw Error("wallet address and chainId required to generate nonce");return await i({address:t,chainId:n}).then((e=>e))}catch(t){throw r({status:"error",error:t}),e?.onError?.(t.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[i]),linkWithSiwe:c((async({signature:n,message:i,chainId:o,walletClientType:s,connectorType:l})=>{try{if(t.enabled&&"success"!==t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);let{user:r,linkedAccount:c}=await a({message:i,signature:n,chainId:o,walletClientType:s,connectorType:l});c&&e?.onSuccess?.({user:r,linkMethod:"siwe",linkedAccount:c})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),n}}),[a,t.status]),state:n}};function Tw(){let{signTransaction:e}=h(Wr);return{signTransaction:e}}function bw(e){let{linkEmail:t,linkPhone:n,linkWallet:r,linkGoogle:a,linkApple:i,linkTwitter:o,linkDiscord:s,linkGithub:l,linkLinkedIn:c,linkTiktok:d,linkSpotify:u,linkInstagram:p,linkTelegram:m,linkFarcaster:y}=h(Wr);return ta("linkAccount",e),{linkEmail:t,linkPhone:n,linkWallet:r,linkGoogle:a,linkApple:i,linkTwitter:o,linkDiscord:s,linkGithub:l,linkLinkedIn:c,linkTiktok:d,linkSpotify:u,linkInstagram:p,linkFarcaster:y,linkTelegram:m}}function Aw(e){let{updateEmail:t,updatePhone:n}=h(Wr);return ta("update",e),{updateEmail:t,updatePhone:n}}function _w(e){let{createWallet:t}=h(Wr);return ta("createWallet",e),{createWallet:t}}const kw=()=>{let{connectCoinbaseSmartWallet:e}=x();return{connectCoinbaseSmartWallet:e}},Iw=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:n,signTypedDataWithCrossAppWallet:r,sendTransactionWithCrossAppWallet:a}=ur();return{loginWithCrossAppAccount:({appId:t})=>e({appId:t,action:"login"}),linkCrossAppAccount:({appId:t})=>e({appId:t,action:"link"}),unlinkCrossAppAccount:t,signMessage:n,signTypedData:r,sendTransaction:a}};function Nw(e){let{sendTransaction:t}=h(Wr);return ta("sendTransaction",e),{sendTransaction:t}}function xw(e){let{setWalletPassword:t}=h(Wr);return ta("setWalletPassword",e),{setWalletPassword:t}}function Sw(){let{createGuestAccount:e}=h(Wr);return{createGuestAccount:e}}function Rw(e){let{setWalletRecovery:t}=h(Wr);return ta("setWalletRecovery",e),{setWalletRecovery:t}}function Ow(e){let{signMessage:t}=h(Wr);return ta("signMessage",e),{signMessage:t}}const Ww=()=>{let{ready:e,wallets:t}=Tr(),{user:n}=ur(),{rpcConfig:r,chains:a,appId:i}=x();return{signAuthorization:c((async(o,s)=>{if(!n)throw Error("User must be authenticated before signing with a Privy wallet");if(!e)throw Error("Wallets are not ready");let l=s?.address??yr(n)?.address??Fa,c=t.find((e=>Ba(e.address)===Ba(l)));if(!c)throw Error("Signing wallet not found.");let d=o.chainId??Number(c.chainId.split(":")[1]),u=a.find((e=>e.id===d));if(!u)throw Error("Error, chain not configured in PrivyProvider config");let h=Na({account:l,chain:u,transport:Ia(Va(u,r,i))}).extend(Eo()),p=await h.prepareAuthorization({...o,sponsor:o.sponsor||void 0}),m=await c.getEthereumProvider(),y=await m.request({method:"secp256k1_sign",params:[To(p)]});return{...p,...za(y)}}),[e,t,n,a])}};function Mw(e){let{signTypedData:t}=h(Wr);return ta("signTypedData",e),{signTypedData:t}}const Pw=()=>{let{isModalOpen:e}=h(Wr);return{isOpen:e}};function Lw(e){let{getAccessToken:t}=h(Wr);return ta("accessToken",e),{getAccessToken:t}}function Dw(e){let{authenticated:t,user:n}=ur(),{initLoginWithOAuth:r}=x(),a=ua();return ta("oAuthAuthorization",e),{reauthorize:e=>Uw(t,n,r,a,e.provider)}}let Uw=async(e,t,n,r,a)=>{if(!e)throw r("linkAccount","onError",A.MUST_BE_AUTHENTICATED,{linkMethod:a}),new T("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(a))))throw new T(`OAuth account of type ${a} not linked to the account.`);await n(a)};const Fw=e=>{let{customAuthStatus:t}=x();return ta("customAuth",e),{status:t}};function Bw(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:n}=ur();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:n}}const zw=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=x();return{delegateWallet:async({address:e,chainType:n})=>await t({address:e,chainType:n,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Hw=()=>{let{setUser:e,client:t}=h(D),{user:n}=h(Wr);return{user:n,refreshUser:c((async()=>{let n=await(t?.updateUserAndIdToken());return e(n??null),n}),[t,e])}},Vw=e=>{let t=it(),{initLoginWithTelegram:n,loginWithTelegram:r,telegramAuthState:a,setTelegramAuthState:i}=x();return{login:c((async a=>{try{if(t.enabled&&"success"!==t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);await n(t.token,a?.disableSignup);let{user:i,isNewUser:o,loginAccount:s,wasAlreadyAuthenticated:l}=await r({intent:"login"});e?.onComplete?.({user:i,isNewUser:o,wasAlreadyAuthenticated:l,loginMethod:"telegram",loginAccount:s})}catch(a){throw i({status:"error",error:a}),e?.onError?.(a.privyErrorCode||A.UNKNOWN_AUTH_ERROR),a}}),[n,r,t]),state:a}},$w=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=x();return{delegateWallet:async({address:e,chainType:n})=>await t({address:e,chainType:n,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{Ys as Captcha,Os as ConnectorManager,Ke as EthereumWalletConnector,bf as LoginModal,qs as PrivyClient,uw as PrivyProvider,qn as VERSION,qc as errorIndicatesMaxMfaRetries,jc as errorIndicatesMfaTimeout,Gc as errorIndicatesMfaVerificationFailed,nw as getAccessToken,kw as useConnectCoinbaseSmartWallet,_w as useCreateWallet,Iw as useCrossAppAccounts,Fw as useCustomAuth,zw as useDelegatedActions,Bw as useFarcasterSigner,Sw as useGuestAccounts,$w as useHeadlessDelegatedActions,Bs as useIdentityToken,pw as useImportWallet,bw as useLinkAccount,vw as useLinkWithPasskey,Ew as useLinkWithSiwe,gw as useLoginWithEmail,yw as useLoginWithOAuth,ww as useLoginWithPasskey,Cw as useLoginWithSms,Vw as useLoginWithTelegram,At as useLogout,am as useMfa,im as useMfaEnrollment,Pw as useModalStatus,Dw as useOAuthTokens,mw as usePrivy,Zs as useRegisterMfaListener,Nw as useSendTransaction,xw as useSetWalletPassword,Rw as useSetWalletRecovery,Ww as useSignAuthorization,Ow as useSignMessage,Tw as useSignTransaction,Mw as useSignTypedData,fw as useSignupWithPasskey,oa as useSolanaWallets,Lw as useToken,Aw as useUpdateAccount,Hw as useUser,Tr as useWallets};
4
+ /*#__PURE__*/t("span",{})]})})});let yc=/*#__PURE__*/Ka.div.withConfig({displayName:"StackedContainer",componentId:"sc-26c1d9b9-0"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;> div{position:relative;}> div > span{position:absolute;left:-41px;top:-41px;}> div > :last-child{position:absolute;left:-19px;top:-19px;}"]);let gc=/*#__PURE__*/Ka.div.withConfig({displayName:"CaptchaContainer",componentId:"sc-9afcf974-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const fc=({chainType:n,withPadding:r})=>{let a="";return a="ethereum-only"===n||"ethereum-and-solana"===n?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/t(ll,{$withPadding:r,children:/*#__PURE__*/e(cl,{children:[/*#__PURE__*/t(Ja,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/t("h3",{children:"No wallets available"}),/*#__PURE__*/e("p",{children:["Please download an external wallet provider, like ",a,"."]})]})},"empty-wallet-state")},wc=({icon:e,name:n})=>"string"==typeof e?/*#__PURE__*/t("img",{alt:`${n||"wallet"} logo`,src:e,style:{height:24,width:24,borderRadius:4}}):void 0===e?/*#__PURE__*/t(Xa,{}):e?/*#__PURE__*/t(e,{}):null;function vc(e){let t=e.toLowerCase();return!!window?.webkit?.messageHandlers?.ReactNativeWebView||!!window?.ReactNativeWebView||["fbav","fban","instagram","snapchat","linkedinapp"].some((e=>t.includes(e)))}const Cc=({provider:n,displayName:r,logo:a,connectOnly:i,connector:o})=>{let s,{navigate:l,setModalData:c}=lr(),{connectWallet:d}=x(),h=gt(),u=ft(n),p="wallet_connect_v2"===o.connectorType?n:o.walletClientType,m=window.matchMedia("(display-mode: standalone)").matches,g=xs({connectorType:o.connectorType,walletClientType:p});s=g&&g.chainTypes.includes(o.chainType)?()=>{g.isInstalled||"solana"===o.chainType&&"isInstalled"in o&&o.isInstalled?(d(o,p),l(i?cr.AWAITING_CONNECT_ONLY_CONNECTION:cr.AWAITING_CONNECTION)):y?(c({installWalletModalData:{walletConfig:g,chainType:o.chainType,connectOnly:i}}),l(cr.WALLET_INTERSTITIAL_SCREEN)):(c({installWalletModalData:{walletConfig:g,chainType:o.chainType,connectOnly:i}}),l(cr.INSTALL_WALLET_SCREEN))}:"coinbase_wallet"!==o.connectorType||"eoaOnly"!==o.connectionOptions||!y||m||wt()?()=>{(!vc(window.navigator.userAgent)||event?.isTrusted)&&(d(o,p),l(i?cr.AWAITING_CONNECT_ONLY_CONNECTION:cr.AWAITING_CONNECTION))}:()=>{window.location.href=`https://go.cb-w.com/dapp?cb_url=${encodeURI(window.location.href)}`};let f=r||u?.metadata?.shortName||u?.name||o.walletClientType;/*#__PURE__*/return e(Ec,{onClick:s,children:[/*#__PURE__*/t(wc,{icon:a||u?.image_url?.md,name:f}),/*#__PURE__*/t("span",{children:f}),/*#__PURE__*/e(bc,{id:"chip-container",children:[h?.walletClientType===p&&h?.chainType===o.chainType?/*#__PURE__*/t(Tc,{color:"gray",children:"Recent"}):/*#__PURE__*/t("span",{id:"connect-text",children:"Connect"}),"solana"===o.chainType&&/*#__PURE__*/t(Tc,{color:"gray",children:"Solana"})]})]})};let Ec=/*#__PURE__*/Ka(il).withConfig({displayName:"ConnectWalletButton",componentId:"sc-c6a554d4-0"})(["> #chip-container > #connect-text{font-weight:500;color:var(--privy-color-accent);opacity:0;transition:opacity 0.1s ease-out;}:hover > #chip-container > #connect-text{opacity:1;}@media (max-width:440px){> #chip-container > #connect-text{display:none;}}"]),Tc=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-c6a554d4-1"})(["margin-left:auto;"]),bc=/*#__PURE__*/Ka.div.withConfig({displayName:"ChipContainer",componentId:"sc-c6a554d4-2"})(["display:flex;flex-wrap:wrap;gap:8px;margin-left:auto;"]);const Ac=["coinbase_wallet"];let _c=["metamask","okx_wallet","rainbow","uniswap","bybit_wallet","ronin_wallet","uniswap_extension","zerion","rabby_wallet","cryptocom"];const kc=["safe"],Ic=["phantom","backpack","solflare","universal_profile"],Nc=({wallets:e})=>{let{app:r}=lr();return 0===e.length?/*#__PURE__*/t(fc,{chainType:r.appearance.walletChainType,withPadding:!0}):/*#__PURE__*/t(n,{children:e})},xc=({walletList:e,walletChainType:n,connectors:r,connectOnly:a,ignore:i,walletConnectEnabled:o,forceWallet:s})=>{let l=[],c=[],d=[],h=r.filter((e=>"ethereum-only"===n?"ethereum"===e.chainType:"solana-only"!==n||"solana"===e.chainType)),u=h.find((e=>"wallet_connect_v2"===e.connectorType));for(let[r,p]of(s?[s.wallet]:e).entries()){if("detected_ethereum_wallets"===p||"detected_wallets"===p)for(let[e,n]of h.filter((({chainType:e,connectorType:t,walletClientType:n})=>"solana"!==e&&("uniswap_wallet_extension"===n||"uniswap_extension"===n?!i.includes("uniswap"):"crypto.com_wallet_extension"===n||"crypto.com_onchain"===n?!i.includes("cryptocom"):"injected"===t&&!i.includes(n)))).entries()){let{walletClientType:i,walletBranding:o,chainType:s}=n;("unknown"===i?c:l).push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:i,logo:o.icon,displayName:o.name,connector:n},`${r}-${p}-${i}-${s}-${e}`))}if("detected_solana_wallets"===p||"detected_wallets"===p)for(let[e,o]of h.filter((({chainType:e,walletClientType:t})=>{if("solana"===e)return"ethereum-only"!==n&&!i.includes(t)})).entries()){let{walletClientType:n,walletBranding:i,chainType:s}=o;("unknown"===n?c:l).push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:n,logo:i.icon,displayName:i.name,connector:o},`${r}-${p}-${n}-${s}-${e}`))}if(Ic.includes(p)){let e=h.find((e=>"injected"===e.connectorType&&e.walletClientType===p||e.connectorType===p));if(e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e},`${r}-${p}`)),"solana-only"===n||"ethereum-and-solana"===n){let e=h.find((({chainType:e,walletClientType:t})=>"solana"===e&&t===p));e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e},`${p}-solana`))}}else if(_c.includes(p)){let e=h.find((e=>"uniswap"===p?"uniswap_wallet_extension"===e.walletClientType||"uniswap_extension"===e.walletClientType:"cryptocom"===p?"crypto.com_wallet_extension"===e.walletClientType||"crypto.com_onchain"===e.walletClientType:"injected"===e.connectorType&&e.walletClientType===p));if(o&&!e&&(e=u),e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e,logo:"injected"===e.connectorType?e.walletBranding.icon:void 0,displayName:"injected"===e.connectorType?e.walletBranding.name:void 0},`${r}-${p}`)),"solana-only"===n||"ethereum-and-solana"===n){let e=h.find((({chainType:e,walletClientType:t})=>"solana"===e&&t===p));e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e},`${p}-solana`))}}else if(Ac.includes(p)){let e=h.find((({connectorType:e})=>e===p));e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:e},`${r}-${p}`))}else if(kc.includes(p))u&&d.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:u},`${r}-${p}`));else if("wallet_connect"===p)u&&d.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,connector:u,logo:u.walletBranding.icon,displayName:"Wallet Connect"},`${r}-${p}`));else if(p===s?.wallet){let n="ethereum"===s.chainType&&e.includes("detected_ethereum_wallets"),i="solana"===s.chainType&&e.includes("detected_solana_wallets");if(e.includes("detected_wallets")||n||i){let e=h.find((({walletClientType:e})=>e===p));e&&l.push(/*#__PURE__*/t(Cc,{connectOnly:a,provider:p,displayName:e.walletBranding?.name,logo:e.walletBranding?.icon,connector:e},`${r}-${p}`))}}}return[...c,...l,...d]};let Sc=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-4475d7d5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Rc=({name:e,logoUrl:n,size:r="38px"})=>"string"==typeof n?/*#__PURE__*/t("img",{src:n,alt:`${e??"Provider app"} logo`,style:{width:r,height:r,maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):
5
+ /*#__PURE__*/t("span",{});let Oc=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-128f2a0d-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);let Wc=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-b99bc0c0-0"})(["display:flex;gap:10px;"]),Mc=/*#__PURE__*/Ka(Nt).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-b99bc0c0-1"})(["margin-top:1.5rem;"]);let Pc=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-8ff214d7-0"})(["display:flex;gap:10px;"]);const Lc=()=>/*#__PURE__*/t(Dc,{children:/*#__PURE__*/e(Uc,{children:[/*#__PURE__*/t(Fc,{}),/*#__PURE__*/t(Bc,{})]})});let Dc=/*#__PURE__*/Ka.div.withConfig({displayName:"LoadingContainer",componentId:"sc-85b54ede-0"})(["display:flex;justify-content:center;align-items:center;flex-grow:1;margin:12px;padding:16px;@media all and (display-mode:standalone){margin-bottom:30px;}"]),Uc=/*#__PURE__*/Ka.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-85b54ede-1"})(["position:relative;height:140px;width:140px;opacity:1;animation:fadein 200ms ease;"]),Fc=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleFixed",componentId:"sc-85b54ede-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;&&{border:4px solid var(--privy-color-accent-light);border-radius:50%;}"]),Bc=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleRotate",componentId:"sc-85b54ede-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:140px;height:140px;animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:var(--privy-color-accent) transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]);const zc=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];class Hc extends Error{constructor(e,t){super(t),this.type=e}}function Vc(e){let t=e.type;return"string"==typeof t&&zc.includes(t)}function $c(e){return Vc(e)&&"wallet_not_on_device"===e.type}function jc(e){return!!Vc(e)&&"mfa_timeout"===e.type}function Gc(e){return!!Vc(e)&&"missing_or_invalid_mfa"===e.type}function qc(e){return!!Vc(e)&&"mfa_verification_max_attempts_reached"===e.type}function Kc(e){return!(!Vc(e)||!e.message.includes("code 429"))}function Yc(e){return!!function(e){let t=e.type;return"string"==typeof t&&"client_error"===t}(e)&&"MFA canceled"===e.message}function Zc({isCreatingWallet:e,skipSplashScreen:t}){return e?cr.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN:t?cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN:cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN}function Jc({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:n,isResettingPassword:r,showAutomaticRecovery:a}){return a?cr.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN:n||1===t.length?Zc({isCreatingWallet:"create"===e,skipSplashScreen:r}):cr.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN}function Qc(e){switch(e){case"user-passcode":return cr.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN;case"google-drive":case"icloud":return cr.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN;default:throw Error("Recovery method not supported")}}async function Xc({api:e,provider:t}){let n=So(),r=Ro(),a=await Oo(n);try{return"icloud"===t?{url:(await e.post(He,{client_type:"web"})).url}:{url:(await e.post(Ve,{redirect_to:window.location.href,code_challenge:a,state_code:r})).url,codeVerifier:n,stateCode:r,provider:t}}catch(e){throw b(e)}}async function ed({api:e,provider:t,stateCode:n,codeVerifier:r,authorizationCode:a}){if(!a||!n)throw new T("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===a)throw new T("User denied confirmation during OAuth flow");try{return(await e.post($e,{authorization_code:a,state_code:n,code_verifier:r,provider:t})).access_token}catch(e){let t=b(e);if(t.privyErrorCode)throw new T(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new T("Invalid code during oauth flow.",void 0,A.OAUTH_USER_DENIED);throw new T("Invalid code during OAuth flow.",void 0,A.UNKNOWN_AUTH_ERROR)}}let td=/*#__PURE__*/Ka.div.withConfig({displayName:"BottomSpacing",componentId:"sc-55d2f85e-0"})(["height:44px;"]);const nd=({children:n,theme:r})=>/*#__PURE__*/e(rd,{$theme:r,children:[/*#__PURE__*/t(Qa,{width:"1.25rem",color:"dark"===r?"#FDE68A":"var(--privy-color-warn)"}),n]});let rd=/*#__PURE__*/Ka.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 id(n){let[r,a]=s(n.dimensions.width),[i,c]=s(void 0),d=l(null);o((()=>{if(d.current&&void 0===r){let{width:e}=d.current.getBoundingClientRect();a(e)}let e=getComputedStyle(document.documentElement);c({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")})}),[]);let h="ethereum"===n.walletToExport.chainType&&!n.walletToExport.imported;/*#__PURE__*/return t("div",{ref:d,children:r&&
6
+ /*#__PURE__*/e(sd,{children:[/*#__PURE__*/t("iframe",{style:{position:"absolute",zIndex:1},width:r,height:n.dimensions.height,allow:"clipboard-write self *",src:Ot(n.origin,`/apps/${n.appId}/embedded-wallets/export`,{client_id:n.appClientId,primaryAddress:n.primaryWallet.address,address:n.walletToExport.address,walletIndex:n.walletToExport.walletIndex,width:`${r}px`,caid:n.clientAnalyticsId,phrase_export:h,...i},{token:n.accessToken})}),/*#__PURE__*/t(ld,{children:"Loading..."}),h&&/*#__PURE__*/t(ld,{children:"Loading..."})]})})}let od=/*#__PURE__*/Ka.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-eaab13a9-0"})(["display:flex;flex-direction:column;gap:1.25rem;text-align:left;"]),sd=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonContainer",componentId:"sc-eaab13a9-1"})(["overflow:visible;position:relative;overflow:none;height:44px;display:flex;gap:12px;"]),ld=/*#__PURE__*/Ka.div.withConfig({displayName:"LoadingButton",componentId:"sc-eaab13a9-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);"]);function cd(){let{getAccessToken:e}=hr(),{refreshSessionAndUser:t,createAnalyticsEvent:n,initializeWalletProxy:r}=x(),a=l(!1);return{createWallet:c((async({user:i,recoveryPassword:o})=>{let s=await e();if(!s)throw n({eventName:"embedded_wallet_creation_failed",payload:{error:"Missing access token for user."}}),Error("An error has occured, please login again.");try{n({eventName:"embedded_wallet_creation_started"});let e=await r(fr);if(!e)throw Error("walletProxy does not exist.");let l=new Promise(((e,t)=>{setTimeout((()=>{t(Error("walletProxy.create timed out."))}),2e4)})),c=gr(i);if(!await Promise.race([e.create({accessToken:s,recoveryPassword:o,recoveryMethod:o?"user-passcode":void 0,solanaAddress:c?.address}),l]))throw Error("walletProxy.create did not send a response.");let d=await t();if(!d)throw Error("Failed to refresh user.");let h=yr(d);if(!h)throw Error("Updated user is missing embedded wallet.");return n({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:h.address}}),a.current=!0,h}catch(i){if(a.current)return;throw n({eventName:"embedded_wallet_creation_failed",payload:{error:i.toString()}}),console.warn(i),i}}),[])}}let dd=/*#__PURE__*/Ka.div.withConfig({displayName:"BottomSpacing",componentId:"sc-e97c5a7e-0"})(["height:44px;"]),hd=/*#__PURE__*/Ya(["font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;text-align:left;transition:color 0.1s ease-in;"]);const ud=/*#__PURE__*/Ka.span.withConfig({displayName:"StatusText",componentId:"sc-3f6866a9-0"})([""," transition:color 0.1s ease-in;color:",";text-transform:",";&[aria-hidden='true']{visibility:hidden;}"],hd,(({error:e})=>e?"var(--privy-color-error)":"var(--privy-color-foreground-3)"),(({error:e})=>e?"":"capitalize")),pd=/*#__PURE__*/Ka.div.withConfig({displayName:"EmbeddedWalletScreenContainer",componentId:"sc-3f6866a9-1"})(["display:flex;flex-direction:column;justify-content:center;flex-grow:1;"]),md=/*#__PURE__*/Ka(st).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-3f6866a9-2"})(["",""],(e=>e.hideAnimations&&/*#__PURE__*/Ya(["&&{transition:none;}"])));let yd=/*#__PURE__*/Ya(["&&{width:100%;border-width:1px;border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);background:var(--privy-color-background);color:var(--privy-color-foreground);padding:12px;font-size:16px;font-style:normal;font-weight:300;line-height:22px;}"]);const gd=/*#__PURE__*/Ka.input.withConfig({displayName:"PasswordInput",componentId:"sc-3f6866a9-3"})([""," &::placeholder{color:var(--privy-color-foreground-3);font-style:italic;font-size:14px;}overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"],yd),fd=/*#__PURE__*/Ka.div.withConfig({displayName:"PasswordDisplay",componentId:"sc-3f6866a9-4"})(["",""],yd),wd=/*#__PURE__*/Ka.div.withConfig({displayName:"PasswordContainer",componentId:"sc-3f6866a9-5"})(["position:relative;width:100%;display:flex;align-items:center;justify-content:",";"],(({centered:e})=>e?"center":"space-between")),vd=/*#__PURE__*/Ka.div.withConfig({displayName:"Header",componentId:"sc-3f6866a9-6"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:32px 0;gap:4px;& 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;}"]),Cd=/*#__PURE__*/Ka.div.withConfig({displayName:"Details",componentId:"sc-3f6866a9-7"})(["display:flex;flex-direction:column;gap:10px;padding-bottom:1rem;"]),Ed=/*#__PURE__*/Ka.div.withConfig({displayName:"DetailItem",componentId:"sc-3f6866a9-8"})(["display:flex;text-align:left;align-items:center;gap:8px;max-width:300px;font-size:14px;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;margin:0 8px;color:var(--privy-color-foreground-2);> :first-child{min-width:24px;}"]),Td=/*#__PURE__*/Ka(Pt).withConfig({displayName:"ExportButton",componentId:"sc-3f6866a9-10"})(["display:flex;flex:1;gap:4px;justify-content:center;&&{background:var(--privy-color-background);border-radius:var(--privy-border-radius-md);border-color:var(--privy-color-foreground-3);border-width:1px;}"]),bd=/*#__PURE__*/Ka.div.withConfig({displayName:"InputRightIcons",componentId:"sc-3f6866a9-11"})(["position:absolute;right:0.5rem;display:flex;flex-direction:row;justify-content:space-around;align-items:center;"]),Ad=/*#__PURE__*/Ka(yi).withConfig({displayName:"RegenerateIcon",componentId:"sc-3f6866a9-12"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),_d=/*#__PURE__*/Ka(fi).withConfig({displayName:"HiddenIcon",componentId:"sc-3f6866a9-13"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),kd=/*#__PURE__*/Ka(gi).withConfig({displayName:"ShownIcon",componentId:"sc-3f6866a9-14"})(["height:1.25rem;width:1.25rem;stroke:var(--privy-color-accent);cursor:pointer;:active{stroke:var(--privy-color-accent-light);}"]),Id=/*#__PURE__*/Ka.progress.withConfig({displayName:"StrengthMeter",componentId:"sc-3f6866a9-15"})(["height:4px;width:100%;margin:8px 0;::-webkit-progress-bar{border-radius:8px;background:var(--privy-color-foreground-4);}::-webkit-progress-value{border-radius:8px;transition:all 0.1s ease-out;background:",";}"],(({label:e})=>("Strong"===e?"#78dca6":"Medium"===e&&"var(--privy-color-warn)")||"var(--privy-color-error)")),Nd=({buttonHideAnimations:r,buttonLoading:a,password:i,onSubmit:l,onBack:c})=>{let[d,h]=s(!0),[u,p]=s(!1),[m,y]=s(""),g=i===m;return o((()=>{m&&!u&&p(!0)}),[m]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1,backFn:c}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(pd,{children:[/*#__PURE__*/e(vd,{children:[/*#__PURE__*/t(Qa,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please re-enter your password below to continue."})]}),/*#__PURE__*/e(wd,{children:[/*#__PURE__*/t(gd,{value:m,onChange:e=>y(e.target.value),onKeyUp:e=>{"Enter"===e.key&&l()},onBlur:()=>p(!0),placeholder:"confirm your password",type:d?"password":"text",style:{paddingRight:"2.3rem"}}),/*#__PURE__*/t(bd,{style:{right:"0.75rem"},children:d?/*#__PURE__*/t(_d,{onClick:()=>h(!1)}):/*#__PURE__*/t(kd,{onClick:()=>h(!0)})})]}),
7
+ /*#__PURE__*/t(ud,{"aria-hidden":!u||g,error:!0,children:"Passwords do not match"})]}),/*#__PURE__*/t(md,{onClick:l,loading:a,disabled:!g,hideAnimations:r,children:"Continue"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},xd=({className:n,checked:r,color:a="var(--privy-color-accent)",...i})=>/*#__PURE__*/t("label",{children:/*#__PURE__*/e(Sd,{className:n,children:[/*#__PURE__*/t(Od,{checked:r,...i}),/*#__PURE__*/t(Wd,{color:a,checked:r,children:/*#__PURE__*/t(Rd,{viewBox:"0 0 24 24",children:/*#__PURE__*/t("polyline",{points:"20 6 9 17 4 12"})})})]})});let Sd=/*#__PURE__*/Ka.div.withConfig({displayName:"CheckboxContainer",componentId:"sc-db51b935-1"})(["display:inline-block;vertical-align:middle;"]),Rd=/*#__PURE__*/Ka.svg.withConfig({displayName:"Icon",componentId:"sc-db51b935-2"})(["fill:none;stroke:white;stroke-width:3px;"]),Od=/*#__PURE__*/Ka.input.attrs({type:"checkbox"}).withConfig({displayName:"HiddenCheckbox",componentId:"sc-db51b935-3"})(["border:0;clip:rect(0 0 0 0);clippath:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px;"]),Wd=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledCheckbox",componentId:"sc-db51b935-4"})(["display:inline-block;width:18px;height:18px;transition:all 150ms;cursor:pointer;border-color:",";border-radius:3px;background:",";&&{border-width:1px;}",":focus + &{box-shadow:0 0 0 1px ",";}","{visibility:",";}"],(e=>e.color),(e=>e.checked?e.color:"var(--privy-color-background)"),Od,(e=>e.color),Rd,(e=>e.checked?"visible":"hidden"));const Md=({buttonHideAnimations:r,buttonLoading:a,onSubmit:i,onBack:o,config:l})=>{let[c,d]=s(!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1,backFn:o}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(pd,{children:[/*#__PURE__*/e(vd,{children:[/*#__PURE__*/t(Qa,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-error)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Confirm you have saved"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Losing access to your password means you will lose access to your account."})]}),/*#__PURE__*/t(Cd,{children:/*#__PURE__*/e(Ed,{style:{color:"var(--privy-color-error)",cursor:"pointer"},onClick:e=>{e.preventDefault(),d((e=>!e))},children:[/*#__PURE__*/t(xd,{color:"var(--privy-color-error)",readOnly:!0,checked:c}),/*#__PURE__*/t(n,{children:"I understand that if I lose my password and device, I will lose access to my account and my assets."})]})})]}),/*#__PURE__*/e(Pd,{children:["user"===l.initiatedBy&&/*#__PURE__*/t(dt,{onClick:l.onCancel,disabled:a,children:"Cancel"}),/*#__PURE__*/t(md,{onClick:i,loading:a,hideAnimations:r,disabled:!c,children:"Set Password"})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})};let Pd=/*#__PURE__*/Ka.div.withConfig({displayName:"ButtonsContainer",componentId:"sc-eb601350-0"})(["display:flex;gap:10px;"]),Ld=/[a-z]/,Dd=/[A-Z]/,Ud=/[0-9]/,Fd="!@#$%^&*()\\-_+.",Bd=`a-zA-Z0-9${Fd}`,zd=RegExp(`[${Fd}]`),Hd=RegExp(`[${Bd}]`);const Vd=RegExp(`^[${Bd}]{6,}$`),$d=()=>pi.generatePassphrase(4,mi);function jd(e){return e>.9?"Strong":e>.5?"Medium":"Weak"}function Gd(e=""){return(.3*function(e){if(e.length<8)return 0;let t=0;return Ld.test(e)&&(t+=1),Dd.test(e)&&(t+=1),Ud.test(e)&&(t+=1),zd.test(e)&&(t+=1),Math.max(0,Math.min(1,t/3))}(e)+ui(e)/95)/2}const qd=({buttonHideAnimations:r,buttonLoading:a,password:l="",config:c,isResettingPassword:d,onSubmit:h,onClose:u,onBack:p,onPasswordChange:m,onPasswordGenerate:y})=>{let[g,f]=s(!1),[w,v]=s(!1);o((()=>{l&&!w&&v(!0)}),[l]);let C=i((()=>w?6>(l?.length||0)?"Password must be at least 6 characters":Vd.test(l||"")?null:`Invalid characters used ( ${((e="")=>[...new Set(e.split("").filter((e=>!Hd.test(e))).map((e=>e.replace(" ","SPACE"))))])(l).join(" ")} )`:null),[l,w]),E=i((()=>C?{value:0,label:"Weak"}:function(e=""){let t=Gd(e);return{value:t,label:jd(t)}}(l)),[l,C]),T=i((()=>!l?.length||!!C),[C,l]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:u,closeable:"user"===c.initiatedBy,backFn:p}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(pd,{children:[/*#__PURE__*/e(vd,{children:[/*#__PURE__*/t(wi,{height:48,width:48,stroke:"var(--privy-color-accent)"}),/*#__PURE__*/e("h3",{style:{color:"var(--privy-color-foreground)"},children:[d?"Reset":"Set"," your password"]}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Select a strong, memorable password to secure your account."})]}),/*#__PURE__*/e(wd,{children:[/*#__PURE__*/t(gd,{value:l,onChange:e=>m(e.target.value),onKeyUp:e=>{"Enter"===e.key&&h()},placeholder:"enter or generate a strong password",type:g?"password":"text",style:{paddingRight:"3.8rem"}}),/*#__PURE__*/e(bd,{style:{width:"3.5rem"},children:[g?/*#__PURE__*/t(_d,{onClick:()=>f(!1)}):/*#__PURE__*/t(kd,{onClick:()=>f(!0)}),/*#__PURE__*/t(Ad,{onClick:y})]})]}),/*#__PURE__*/t(Id,{value:0===E.value?.01:E.value,label:E.label}),/*#__PURE__*/t(ud,{error:!!C,children:C||`Password Strength: ${w?E.label:"--"}`}),/*#__PURE__*/e(Yd,{children:[/*#__PURE__*/t(Kd,{children:/*#__PURE__*/e(Cd,{children:[/*#__PURE__*/e(Ed,{children:[/*#__PURE__*/t(si,{width:24,height:24,fill:"var(--privy-color-accent)"}),"This password is used to secure your account."]}),/*#__PURE__*/e(Ed,{children:[/*#__PURE__*/t(si,{width:24,height:24,fill:"var(--privy-color-accent)"}),"Use it to log in on a new environment, like another browser or device."]})]})}),/*#__PURE__*/t(md,{onClick:h,loading:a,disabled:T,hideAnimations:r,children:"Continue"})]})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})};let Kd=/*#__PURE__*/Ka(Cd).withConfig({displayName:"DetailsContainer",componentId:"sc-7b3b7727-0"})(["flex:1;padding-top:1rem;"]),Yd=/*#__PURE__*/Ka.div.withConfig({displayName:"LowerContainer",componentId:"sc-7b3b7727-1"})(["display:flex;flex-direction:column;height:100%;"]);const Zd=({buttonHideAnimations:r,buttonLoading:a,appName:i,password:o,onSubmit:l,onBack:d})=>{let[h,u]=s(!1),[p,m]=s(!0),y=c((()=>{u(!0),o&&navigator.clipboard.writeText(o)}),[o]),g=c((()=>{let e=document.createElement("a"),t=i.toLowerCase().replace(/[^a-z\s]/g,"").replace(/\s/g,"-"),n=new Blob([Jd(i,o)],{type:"text/plain"}),r=URL.createObjectURL(n);e.href=r,e.target="_blank",e.download=`${t}-privy-wallet-recovery.txt`,document.body.appendChild(e),e.click(),setTimeout((()=>{e.remove(),URL.revokeObjectURL(r)}),5e3)}),[o]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:d,closeable:!1}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(pd,{children:[/*#__PURE__*/e(vd,{children:[/*#__PURE__*/t(Qa,{height:48,width:48,stroke:"var(--privy-color-background)",fill:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Save your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"For your security, this password cannot be reset, so keep it somewhere safe."})]}),/*#__PURE__*/e(wd,{centered:!0,children:[/*#__PURE__*/t(fd,{children:p?"•".repeat(o.length):o}),/*#__PURE__*/t(bd,{style:{right:"0.75rem"},children:p?/*#__PURE__*/t(_d,{onClick:()=>m(!1)}):/*#__PURE__*/t(kd,{onClick:()=>m(!0)})})]}),/*#__PURE__*/e("div",{style:{display:"flex",margin:"12px 0",gap:"12px"},children:[/*#__PURE__*/t(Td,{onClick:y,children:/*#__PURE__*/e(n,h?{children:[/*#__PURE__*/t(Ci,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copied"]}:{children:[/*#__PURE__*/t(Ei,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Copy"]})}),/*#__PURE__*/e(Td,{onClick:g,children:[/*#__PURE__*/t(vi,{style:{width:24,height:24},stroke:"var(--privy-color-accent)"}),"Download"]})]})]}),/*#__PURE__*/t(md,{onClick:l,loading:a,hideAnimations:r,children:"Continue"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})};let Jd=(e,t)=>`Your wallet recovery password for ${e} is\n\n${t}\n\nYou will need this password to access your ${e} wallet on a new device. Please keep it somewhere safe.`;const Qd=({error:r,onClose:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,r?{children:[/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Something went wrong",description:r})]}:{children:[/*#__PURE__*/t(si,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success"})]}),/*#__PURE__*/t(st,{onClick:a,children:"Close"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let Xd=(e,t)=>{switch(e){case"creating":return"back"===t?e:"saving";case"saving":return"back"===t?"creating":"confirming";case"confirming":return"back"===t?"saving":"finalizing";case"finalizing":return"back"===t?"confirming":"done";default:return e}};const eh=({onSubmit:e,...n})=>{let{lastScreen:r,navigate:a}=lr(),{send:i,state:s}=(()=>{let[e,t]=d(Xd,"creating");return{send:t,state:e}})(),l=c((async()=>{"finalizing"===s&&await e(),i("next")}),[s,i,e]);o((()=>{let e;return"done"===s&&"automatic"===n.config.initiatedBy&&(e=setTimeout((()=>n.onClose?.()),ur)),()=>{e&&clearTimeout(e)}}),[s,n.config.initiatedBy,n.onClose]);let h=c((()=>{i("back")}),[i]),u=c((()=>{a(cr.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN)}),[r,a]);return"creating"===s?/*#__PURE__*/t(qd,{...n,onSubmit:l,onBack:r===cr.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN?u:void 0}):"saving"===s?/*#__PURE__*/t(Zd,{...n,onSubmit:l,onBack:h}):"confirming"===s?/*#__PURE__*/t(Nd,{...n,onSubmit:l,onBack:h}):"finalizing"===s?/*#__PURE__*/t(Md,{...n,onSubmit:l,onBack:h}):"done"===s?/*#__PURE__*/t(Qd,{...n,onSubmit:l}):null};let th="0x0000000000000000000000000000000000000000";const nh=({destinationCurrency:e,...t})=>({tradeType:"EXPECTED_OUTPUT",originCurrency:th,destinationCurrency:e??th,...t});let rh="https://api.relay.link",ah="https://api.testnets.relay.link";const ih=async({input:e,isTestnet:t})=>{let n=await fetch((t?ah:rh)+"/quote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),r=await n.json();if(!(n.ok||"string"==typeof r.message&&r.message.startsWith("Invalid address")))throw console.error("Relay error:",r),Error(r.message??"Error fetching quote from relay");return r},oh=e=>{let t=e.steps[0]?.items?.[0];if(t)return{from:t.data.from,to:t.data.to,value:Number(t.data.value),chainId:Number(t.data.chainId),data:t.data.data}};function sh({transactionHash:e,wallet:t,isTestnet:n,bridgingStatus:r,setBridgingStatus:a,onSuccess:i,onFailure:s}){o((()=>{if(e&&t&&r){if(["delayed","waiting","pending"].includes(r)){let t=setInterval((async()=>{try{let t=await async function({transactionHash:e,isTestnet:t}){let n=await fetch((t?ah:rh)+"/requests/v2?hash="+e),r=await n.json();if(!n.ok){if("message"in r&&"string"==typeof r.message)throw Error(r.message);throw Error("Error fetching request from relay")}return r.requests.at(0)?.status??"pending"}({transactionHash:e,isTestnet:n});a(t)}catch(e){console.error(e)}}),1e3);return()=>clearInterval(t)}"success"===r?i({transactionHash:e,wallet:t}):["refund","failure"].includes(r)&&s({error:new lh(e,n)})}}),[r,e,n,t])}class lh extends T{constructor(e,t){super("We were unable to complete the bridging transaction. Funds will be refunded on your wallet.",void 0,A.TRANSACTION_FAILURE),this.relayLink=t?`https://testnets.relay.link/transaction/${e}`:`https://relay.link/transaction/${e}`}}const ch=({error:r,backFn:a,onClick:i})=>{let{reset:o}=it(),{app:s}=lr(),l=((r,a)=>{let i=/*#__PURE__*/t(Qa,{height:38,width:38,stroke:"var(--privy-color-error)"});if(r instanceof lh)return{title:"Transaction failed",detail:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("p",{children:r.message}),/*#__PURE__*/e("p",{children:["Check the"," ",/*#__PURE__*/t(uh,{href:r.relayLink,target:"_blank",children:"refund status"}),"."]})]}),ctaText:"Try again",icon:i};if(r instanceof T)switch(r.privyErrorCode){case A.CLIENT_REQUEST_TIMEOUT:return{title:"Timed out",detail:r.message,ctaText:"Try again",icon:i};case A.INSUFFICIENT_BALANCE:return{title:"Insufficient balance",detail:r.message,ctaText:"Try again",icon:i};case A.TRANSACTION_FAILURE:return{title:"Transaction failure",detail:r.message,ctaText:"Try again",icon:i};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i}}else{if(r instanceof Hc&&"twilio_verification_failed"===r.type)return{title:"Something went wrong",detail:r.message,ctaText:"Try again",icon:/*#__PURE__*/t(oi,{height:38,width:38,stroke:"var(--privy-color-error)"})};if(!(r instanceof M))return r instanceof N&&r.status&&[400,422].includes(r.status)?{title:"Something went wrong",detail:r.message,ctaText:"Try again",icon:i}:{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i};switch(r.privyErrorCode){case A.INVALID_CAPTCHA:return{title:"Something went wrong",detail:"Please try again.",ctaText:"Try again",icon:i};case A.DISALLOWED_LOGIN_METHOD:return{title:"Not allowed",detail:r.message,ctaText:"Try another method",icon:i};case A.ALLOWLIST_REJECTED:return{title:a.errorTitle||"You don't have access to this app",detail:a.errorDetail||"Have you been invited?",ctaText:a.errorCtaText||"Try another account",icon:/*#__PURE__*/t(ql,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})};case A.CAPTCHA_FAILURE:return{title:"Something went wrong",detail:"You did not pass CAPTCHA. Please try again.",ctaText:"Try again",icon:/*#__PURE__*/t("span",{})};case A.CAPTCHA_TIMEOUT:return{title:"Something went wrong",detail:"Something went wrong! Please try again later.",ctaText:"Try again",icon:/*#__PURE__*/t("span",{})};case A.LINKED_TO_ANOTHER_USER:return{title:"Authentication failed",detail:"This account has already been linked to another user.",ctaText:"Try again",icon:i};case A.NOT_SUPPORTED:return{title:"This region is not supported",detail:"SMS authentication from this region is not available",ctaText:"Try another method",icon:i};case A.TOO_MANY_REQUESTS:return{title:"Request failed",detail:"Too many attempts.",ctaText:"Try again later",icon:i};default:return{title:"Something went wrong",detail:"Try again later",ctaText:"Try again",icon:i}}}})(r,s.allowlistConfig);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:a}),/*#__PURE__*/e(dh,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(ul,{color:"var(--privy-color-error)"}),l.icon]})}),/*#__PURE__*/e(hh,{children:[/*#__PURE__*/t("h3",{children:l.title}),"string"==typeof l.detail?/*#__PURE__*/t("p",{children:l.detail}):l.detail]}),/*#__PURE__*/t(st,{color:"var(--privy-color-error)",onClick:()=>{r instanceof M&&(r.privyErrorCode===A.INVALID_CAPTCHA&&o(),r.privyErrorCode===A.ALLOWLIST_REJECTED&&s.allowlistConfig.errorCtaLink)?window.location.href=s.allowlistConfig.errorCtaLink:i?.()},children:l.ctaText})]})]})};let dh=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-f1b9e2cb-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-bottom:16px;"]),hh=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-f1b9e2cb-1"})(["display:flex;flex-direction:column;gap:8px;"]),uh=/*#__PURE__*/Ka.a.withConfig({displayName:"Link",componentId:"sc-f1b9e2cb-2"})(["color:var(--privy-color-accent) !important;font-weight:600;"]);const ph=({style:e,color:n,...r})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:n||"currentColor",style:{height:"1.5rem",width:"1.5rem",...e},...r,children:/*#__PURE__*/t("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})}),mh=n=>{let[r,a]=s(!1);/*#__PURE__*/return e(yh,{color:n.color,onClick:()=>{a(!0),navigator.clipboard.writeText(n.text),setTimeout((()=>a(!1)),1500)},$justCopied:r,children:[r?/*#__PURE__*/t(ph,{style:{height:"14px",width:"14px"},strokeWidth:"2"}):/*#__PURE__*/t(Ut,{style:{height:"14px",width:"14px"}}),r?"Copied":"Copy"," ",n.itemName?n.itemName:"to Clipboard"]})};let yh=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledCopytoClipboardButton",componentId:"sc-46f4187f-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.$justCopied?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.$justCopied?"medium":"normal"),(e=>e.$justCopied?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"));const gh=e=>{let[n,r]=s(!1);/*#__PURE__*/return t(fh,{color:e.color,href:e.url,target:"_blank",rel:"noreferrer noopener",onClick:()=>{r(!0),setTimeout((()=>r(!1)),1500)},justOpened:n,children:e.text})};let fh=/*#__PURE__*/Ka.a.withConfig({displayName:"StyledOpenLinkButton",componentId:"sc-4e695c83-0"})(["display:flex;align-items:center;gap:6px;&&{margin:8px 2px;font-size:14px;color:",";font-weight:",";transition:color 350ms ease;:focus,:active{background-color:transparent;border:none;outline:none;box-shadow:none;}:hover{color:",";}:active{color:'var(--privy-color-foreground)';font-weight:medium;}@media (max-width:440px){margin:12px 2px;}}svg{width:14px;height:14px;}"],(e=>e.justOpened?"var(--privy-color-foreground)":e.color||"var(--privy-color-foreground-3)"),(e=>e.justOpened?"medium":"normal"),(e=>e.justOpened?"var(--privy-color-foreground)":"var(--privy-color-foreground-2)"));const wh=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"1000",height:"1000",viewBox:"0 0 1000 1000",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"24px",...n},...r,children:[/*#__PURE__*/t("rect",{width:"1000",height:"1000",rx:"200",fill:"#855DCD"}),/*#__PURE__*/t("path",{d:"M257.778 155.556H742.222V844.444H671.111V528.889H670.414C662.554 441.677 589.258 373.333 500 373.333C410.742 373.333 337.446 441.677 329.586 528.889H328.889V844.444H257.778V155.556Z",fill:"white"}),/*#__PURE__*/t("path",{d:"M128.889 253.333L157.778 351.111H182.222V746.667C169.949 746.667 160 756.616 160 768.889V795.556H155.556C143.283 795.556 133.333 805.505 133.333 817.778V844.444H382.222V817.778C382.222 805.505 372.273 795.556 360 795.556H355.556V768.889C355.556 756.616 345.606 746.667 333.333 746.667H306.667V253.333H128.889Z",fill:"white"}),/*#__PURE__*/t("path",{d:"M675.556 746.667C663.283 746.667 653.333 756.616 653.333 768.889V795.556H648.889C636.616 795.556 626.667 805.505 626.667 817.778V844.444H875.556V817.778C875.556 805.505 865.606 795.556 853.333 795.556H848.889V768.889C848.889 756.616 838.94 746.667 826.667 746.667V351.111H851.111L880 253.333H702.222V746.667H675.556Z",fill:"white"})]});let vh="#8a63d2";let Ch=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-d15a94a3-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),Eh=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-d15a94a3-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]),Th="#8a63d2";let bh=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-6e2c96cd-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]),Ah=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainerButton",componentId:"sc-6e2c96cd-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);function _h({title:e}){let{currentScreen:n,navigateBack:r,navigate:a,data:i,setModalData:o}=lr();/*#__PURE__*/return t(ot,{title:e,backFn:n===cr.FUNDING_MANUAL_TRANSFER_SCREEN?r:n===i?.funding?.methodScreen?i.funding.comingFromSendTransactionScreen?()=>a(cr.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN):void 0:i?.funding?.methodScreen?()=>{let e=i.funding;e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),o({funding:e}),a(e.methodScreen)}:void 0})}const kh=({size:n})=>/*#__PURE__*/t(Ih,{$size:n,children:/*#__PURE__*/e(Nh,{children:[/*#__PURE__*/t(xh,{}),/*#__PURE__*/t(Sh,{})]})});let Ih=/*#__PURE__*/Ka.div.withConfig({displayName:"LoadingContainer",componentId:"sc-3ddaba1c-0"})(["--spinner-size:",";display:flex;justify-content:center;align-items:center;flex-grow:1;@media all and (display-mode:standalone){margin-bottom:30px;}"],(e=>e.$size?e.$size:"96px")),Nh=/*#__PURE__*/Ka.div.withConfig({displayName:"SpinnerContainer",componentId:"sc-3ddaba1c-1"})(["position:relative;height:var(--spinner-size);width:var(--spinner-size);opacity:1;animation:fadein 200ms ease;"]),xh=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleFixed",componentId:"sc-3ddaba1c-2"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);&&{border:4px solid #f1f2f9;border-radius:50%;}"]),Sh=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleRotate",componentId:"sc-3ddaba1c-3"})(["position:absolute;top:0;right:0;bottom:0;left:0;width:var(--spinner-size);height:var(--spinner-size);animation:spin 1200ms linear infinite;&&{border:4px solid;border-color:#cbcde1 transparent transparent transparent;border-radius:50%;}@keyframes spin{from{transform:rotate(0deg);}to{transform:rotate(360deg);}}"]);const Rh=({enabled:e=!0}={})=>{let{showFiatPrices:t,getUsdPriceForSol:n}=x(),[r,a]=s(!0),[i,l]=s(void 0),[c,d]=s(void 0);return o((()=>{(async()=>{if(t&&e)try{a(!0);let e=await n();e?d(e):l(Error("Unable to fetch SOL price"))}catch(e){l(e)}finally{a(!1)}else a(!1)})()}),[]),{solPrice:c,isSolPriceLoading:r,solPriceError:i}};function Oh(e){let{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:r}=(e=>{let{showFiatPrices:t,getUsdTokenPrice:n,chains:r}=x(),[a,i]=s(!0),[l,c]=s(void 0),[d,h]=s(void 0);return o((()=>{e||=Cr;let a=vr(r).find((t=>t.id===Number(e)));(async()=>{if(t){if(!a)return i(!1),void c(Error(`Unable to fetch token price on chain id ${e}`));try{i(!0);let e=await n(a);e?h(e):c(Error(`Unable to fetch token price on chain id ${a.id}`))}catch(e){c(e)}finally{i(!1)}}else i(!1)})()}),[e]),{tokenPrice:d,isTokenPriceLoading:a,tokenPriceError:l}})("solana"===e?-1:e),{solPrice:a,isSolPriceLoading:i,solPriceError:l}=Rh({enabled:"solana"===e});return"solana"===e?{tokenPrice:a,isTokenPriceLoading:i,tokenPriceError:l}:{tokenPrice:t,isTokenPriceLoading:n,tokenPriceError:r}}async function Wh(e){try{return await e}catch{}}let Mh=new Intl.NumberFormat(void 0,{style:"currency",currency:"USD",maximumFractionDigits:2});function Ph(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 Lh(e,t){let n=parseFloat(e.toString())/1e9,r=Mh.format(t*n);return"$0.00"===r?"<$0.01":r}function Dh({amount:e,fee:t,tokenPrice:n}){let r=BigInt(1e9*parseFloat(e)),a=r+t;return{fundingAmountInBaseUnit:r,fundingAmountInUsd:n?Lh(r,n):void 0,totalPriceInUsd:n?Lh(a,n):void 0,totalPriceInNativeCurrency:Ph(a),feePriceInNativeCurrency:Ph(t),feePriceInUsd:n?Lh(t,n):void 0}}function Uh(e){return"version"in e}function Fh(e,t,n){return{signature:e,parsedTransaction:n??null,signedTransaction:t,fees:BigInt(n?.meta?.fee||0)}}async function Bh({tx:e,connection:t,client:n}){let r=Uh(e)?e.message:e.compileMessage(),a=r.staticAccountKeys[0]?.toBase58()??"",i=await async function(e,t){return BigInt((Uh(e)?(await t.getFeeForMessage(e.message)).value:await e.getEstimatedFee(t))??0)}(e,t),o={},s={},l=[];for(let e of r.compiledInstructions){let a=r.staticAccountKeys[e.programIdIndex]?.toBase58()||"";if("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"!==a&&"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"!==a)if("11111111111111111111111111111111"!==a)if("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"!==a)l.push({type:"unknown",program:a});else{let t=await Wh(function(e,t){let[n,r,a,i]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!(n&&r&&a&&i))throw Error("Failed to parse ATA creation instruction");return{type:"ata-creation",payer:n.toBase58(),ata:r.toBase58(),owner:a.toBase58(),mint:i.toBase58()}}(e,r));if(!t)continue;l.push(t),s[t.ata]={owner:t.owner,mint:t.mint}}else{let t=await Wh(Vh(e,r));if(!t)continue;l.push(t)}else{let a=await Wh(Hh(e,r,t,n,o,s));if(!a)continue;l.push(a),o[a.token.address]=a.token,s[a.fromAta]??={owner:a.fromAccount,mint:a.token.address},a.toAccount&&(s[a.toAta]??={owner:a.toAccount,mint:a.token.address})}}let c=l.filter((({type:e})=>["spl-transfer","sol-transfer"].includes(e)));return{spender:a,fee:i,instructions:c.length?c:l}}function zh(e,t){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=Buffer.from(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 Hh(e,t,n,r,a,i){let o,s,[l,c,d]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!l||!c||!d)throw Error("Failed to parse SPL transfer instruction");let h="",u=i[c.toBase58()];if(u)o=u.owner,h=u.mint;else{let e=await n.getParsedAccountInfo(c,"confirmed"),t=e.value?.data;o=t?.parsed?.info?.owner,h=t?.parsed?.info?.mint??"",s=t?.parsed?.info?.tokenAmount?.decimals}if(!h){let e=await n.getParsedAccountInfo(l,"confirmed"),t=e.value?.data;h=t?.parsed?.info?.mint??""}let p=a[h];if(h&&!p){let e=await r.getSplTokenMetadata({mintAddress:h,cluster:Er(n.rpcEndpoint)});e&&(p={address:h,symbol:e.symbol,decimals:e.decimals})}let m=p?.symbol??"";s??=p?.decimals??9;let y=zh(e.data,1);return{type:"spl-transfer",fromAta:l.toBase58(),fromAccount:d.toBase58(),toAta:c.toBase58(),toAccount:o,value:y,token:{symbol:m,decimals:s,address:h}}}async function Vh(e,t){let[n,r]=e.accountKeyIndexes.map((e=>t.staticAccountKeys[e]));if(!n||!r)throw Error("Failed to parse SOL transfer instruction");let a=zh(e.data,4);return{type:"sol-transfer",fromAccount:n.toBase58(),toAccount:r.toBase58(),value:a,token:{symbol:"SOL",decimals:9}}}const $h=({chains:e,appId:t,address:n,rpcConfig:r})=>Promise.all(e.map((async e=>{let a=ka({chain:e,transport:Ia(Va(e,r,t))});return{balance:await a.getBalance({address:n}).catch((()=>0n)),chain:e}}))),jh=/*#__PURE__*/Ka.span.withConfig({displayName:"LabelSm",componentId:"sc-6c002d6-0"})(["color:var(--privy-color-foreground-3);font-size:0.875rem;font-weight:400;line-height:1.375rem;"]),Gh=/*#__PURE__*/Ka(jh).withConfig({displayName:"LabelSmPrimary",componentId:"sc-6c002d6-1"})(["color:var(--privy-color-accent);"]),qh=/*#__PURE__*/Ka.span.withConfig({displayName:"Value",componentId:"sc-72aa026-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;",""],Vt),Kh=({balance:e,className:n,chain:r})=>/*#__PURE__*/t($t,{className:n,$state:void 0,children:/*#__PURE__*/t(Yh,{balance:e,chain:r})}),Yh=({balance:r,chain:a})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(Zh,{children:[/*#__PURE__*/t(Qh,{chainId:"id"in a?a.id:"solana"}),/*#__PURE__*/t(qh,{children:a.name})]}),/*#__PURE__*/e(vt,{isLoading:!1,isPulsing:!1,color:"gray",children:[/*#__PURE__*/t(Jh,{children:/*#__PURE__*/t(Xa,{})}),r]})]});let Zh=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-6d3c340d-0"})(["display:flex;align-items:center;"]),Jh=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-6d3c340d-1"})(["height:0.75rem;width:0.75rem;margin-right:0.2rem;"]),Qh=/*#__PURE__*/Ka(jt).withConfig({displayName:"StyledNetworkIcon",componentId:"sc-6d3c340d-2"})(["height:1.25rem;width:1.25rem;display:inline-block;margin-right:0.5rem;border-radius:4px;"]);const Xh=({options:n,onSelect:r,selected:a,className:i})=>/*#__PURE__*/e(Hi,{as:eu,children:[/*#__PURE__*/e(Vi,{as:au,children:[/*#__PURE__*/t(Yh,{balance:a.balance,chain:a.chain}),/*#__PURE__*/t(ru,{height:16})]}),/*#__PURE__*/t($i,{as:tu,className:i,children:n.map(((e,n)=>/*#__PURE__*/t(ji,{as:nu,onClick:()=>r(n),children:/*#__PURE__*/t(Yh,{balance:e.balance,chain:e.chain})},n)))})]});let eu=/*#__PURE__*/Ka.div.withConfig({displayName:"Wrapper",componentId:"sc-7924b61-0"})(["width:100%;position:relative;"]),tu=/*#__PURE__*/Ka.div.withConfig({displayName:"Popover",componentId:"sc-7924b61-1"})(["width:100%;margin-top:0.5rem;position:absolute;background-color:var(--privy-color-background);border-radius:var(--privy-border-radius-md);overflow-x:hidden;overflow-y:auto;box-shadow:0px 1px 2px 0px rgba(16,24,40,0.05);max-height:11.75rem;&&{border:solid 1px var(--privy-color-foreground-4);}z-index:1;"]),nu=/*#__PURE__*/Ka.button.withConfig({displayName:"Button",componentId:"sc-7924b61-2"})(["width:100%;display:flex;justify-content:space-between;&&{padding:1rem;}:not(:last-child){border-bottom:solid 1px var(--privy-color-foreground-4);}:hover{background:var(--privy-color-background-2);}"]),ru=/*#__PURE__*/Ka(Zi).withConfig({displayName:"StyledChevronIcon",componentId:"sc-7924b61-3"})(["height:1rem;margin-left:0.5rem;"]),au=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledMenuButton",componentId:"sc-7924b61-4"})([""," span{margin-left:auto;}","{transition:rotate 100ms ease-in;}&[aria-expanded='true']{","{rotate:-180deg;}}"],Gt,ru,ru);const iu=({style:e,...n})=>/*#__PURE__*/t("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...e},fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...n,children:/*#__PURE__*/t("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.71369 17.5625V10.375C3.71369 6.44625 6.85845 3.25 10.7238 3.25H17.7953C18.6783 3.25 19.3941 2.52244 19.3941 1.625C19.3941 0.727562 18.6783 0 17.7953 0H10.7238C5.09529 0 0.516113 4.65419 0.516113 10.375V17.5625C0.516113 18.4599 1.23194 19.1875 2.1149 19.1875C2.99787 19.1875 3.71369 18.4599 3.71369 17.5625ZM17.7953 60.7501C18.6783 60.7501 19.3941 61.4777 19.3941 62.3751C19.3941 63.2726 18.6783 64.0001 17.7953 64.0001H10.7238C5.09529 64.0001 0.516113 59.3459 0.516113 53.6251V46.4376C0.516113 45.5402 1.23194 44.8126 2.1149 44.8126C2.99787 44.8126 3.71369 45.5402 3.71369 46.4376V53.6251C3.71369 57.5538 6.85845 60.7501 10.7238 60.7501H17.7953ZM63.4839 46.4376V53.6251C63.4839 59.3459 58.9048 64.0001 53.2763 64.0001H46.2047C45.3217 64.0001 44.6059 63.2726 44.6059 62.3751C44.6059 61.4777 45.3217 60.7501 46.2047 60.7501H53.2763C57.1416 60.7501 60.2864 57.5538 60.2864 53.6251V46.4376C60.2864 45.5402 61.0022 44.8126 61.8851 44.8126C62.7681 44.8126 63.4839 45.5402 63.4839 46.4376ZM63.4839 10.375V17.5625C63.4839 18.4599 62.7681 19.1875 61.8851 19.1875C61.0022 19.1875 60.2864 18.4599 60.2864 17.5625V10.375C60.2864 6.44625 57.1416 3.25 53.2763 3.25H46.2047C45.3217 3.25 44.6059 2.52244 44.6059 1.625C44.6059 0.727562 45.3217 0 46.2047 0H53.2763C58.9048 0 63.4839 4.65419 63.4839 10.375ZM43.0331 47.3022C43.7067 46.6698 43.7483 45.6022 43.1262 44.9176C42.5039 44.233 41.4536 44.1906 40.78 44.823C38.3832 47.0732 35.265 48.3125 31.9997 48.3125C28.7344 48.3125 25.6162 47.0732 23.2194 44.823C22.5457 44.1906 21.4955 44.233 20.8732 44.9176C20.251 45.6022 20.2927 46.6698 20.9663 47.3022C23.9784 50.1301 27.8968 51.6875 31.9997 51.6875C36.1026 51.6875 40.021 50.1301 43.0331 47.3022ZM35.3207 24.1249V36.1249C35.3207 38.5029 33.4173 40.4374 31.0777 40.4374H29.7249C28.8079 40.4374 28.0646 39.6819 28.0646 38.7499C28.0646 37.8179 28.8079 37.0624 29.7249 37.0624H31.0777C31.5863 37.0624 32.0001 36.6419 32.0001 36.1249V24.1249C32.0001 23.1929 32.7434 22.4374 33.6604 22.4374C34.5774 22.4374 35.3207 23.1929 35.3207 24.1249ZM46.7581 28.8437V24.0312C46.7581 23.151 46.056 22.4374 45.19 22.4374C44.324 22.4374 43.622 23.151 43.622 24.0312V28.8437C43.622 29.7239 44.324 30.4374 45.19 30.4374C46.056 30.4374 46.7581 29.7239 46.7581 28.8437ZM17.6109 28.8437C17.6109 29.7239 18.313 30.4374 19.1789 30.4374C20.0449 30.4374 20.747 29.7239 20.747 28.8437V24.0312C20.747 23.151 20.0449 22.4374 19.1789 22.4374C18.313 22.4374 17.6109 23.151 17.6109 24.0312V28.8437Z"})}),ou=({style:n,...r})=>/*#__PURE__*/e("svg",{x:0,y:0,width:"65",height:"64",viewBox:"0 0 65 64",style:{height:"64px",width:"65px",...n},xmlns:"http://www.w3.org/2000/svg",...r,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_113_33841)",children:[/*#__PURE__*/t("path",{d:"M39.1193 0.943398C34.636 -0.174912 29.9185 -0.334713 25.328 0.656273C24.9732 0.732859 24.7477 1.08253 24.8243 1.43729C24.9009 1.79205 25.2506 2.01756 25.6053 1.94097C30.0015 0.991934 34.53 1.14842 38.8375 2.22802C49.1385 4.80983 57.7129 12.5548 60.9786 22.6718C62.2416 26.5843 62.7781 30.7505 62.8855 35.1167C62.8945 35.4795 63.1958 35.7664 63.5586 35.7575C63.9215 35.7485 64.2083 35.4472 64.1994 35.0843C64.0905 30.6582 63.5477 26.3849 62.2536 22.3432C58.8621 11.7515 49.9005 3.63265 39.1193 0.943398Z"}),/*#__PURE__*/t("path",{d:"M21.9931 2.93163C22.343 2.83511 22.5484 2.47325 22.4518 2.12339C22.3553 1.77352 21.9935 1.56815 21.6436 1.66466C16.8429 2.98903 10.0898 7.56519 5.91628 13.6786C5.91465 13.681 5.91304 13.6834 5.91145 13.6858C2.24684 19.2083 -0.0503572 26.1484 0.591012 32.8828C0.591623 32.8892 0.592328 32.8956 0.593127 32.902C0.746837 34.1317 1.00488 35.3591 1.26323 36.5879C1.80735 39.1761 2.35282 41.7706 1.92765 44.4064C1.86986 44.7647 2.11347 45.102 2.47177 45.1598C2.83007 45.2176 3.16738 44.974 3.22518 44.6157C3.66961 41.8605 3.11776 39.173 2.56581 36.4851C2.31054 35.2419 2.05525 33.9987 1.89847 32.7486C1.29525 26.3851 3.46802 19.7466 7.00418 14.416C11.0189 8.5373 17.5201 4.16562 21.9931 2.93163Z"}),/*#__PURE__*/t("path",{d:"M30.6166 4.39985C38.8671 3.89603 47.1159 7.26314 52.6556 13.7139C52.8921 13.9893 52.8605 14.4042 52.5852 14.6406C52.3099 14.8771 51.895 14.8455 51.6585 14.5702C46.3904 8.43576 38.541 5.23144 30.6927 5.71195C30.6899 5.71212 30.6871 5.71227 30.6843 5.71241C20.7592 6.19265 11.4643 12.9257 8.04547 22.3603C7.92183 22.7016 7.54498 22.8779 7.20375 22.7543C6.86253 22.6306 6.68616 22.2538 6.80981 21.9126C10.4114 11.9735 20.1717 4.90702 30.6166 4.39985Z"}),/*#__PURE__*/t("path",{d:"M54.6576 16.5848C54.4553 16.2836 54.047 16.2033 53.7457 16.4057C53.4444 16.608 53.3642 17.0163 53.5665 17.3176C56.6376 21.8904 57.9074 26.8665 58.4094 32.7717C58.4401 33.1333 58.7582 33.4016 59.1199 33.3708C59.4815 33.3401 59.7497 33.022 59.719 32.6604C59.206 26.6261 57.8965 21.4076 54.6576 16.5848Z"}),/*#__PURE__*/t("path",{d:"M59.2796 35.4504C59.6419 35.4277 59.9539 35.703 59.9765 36.0653C60.2242 40.0279 60.2265 44.5112 59.7881 47.8243C59.7405 48.1841 59.4102 48.4372 59.0504 48.3896C58.6906 48.342 58.4376 48.0117 58.4852 47.6519C58.9077 44.4586 58.91 40.0704 58.6648 36.1473C58.6421 35.785 58.9174 35.473 59.2796 35.4504Z"}),/*#__PURE__*/t("path",{d:"M7.05311 25.5432C7.13829 25.1904 6.92135 24.8354 6.56855 24.7502C6.21576 24.665 5.86071 24.882 5.77553 25.2348C5.2932 27.2325 5.0428 29.2847 5.03288 31.3388C5.02266 33.4559 5.41742 35.5225 5.81234 37.5899C6.1354 39.2811 6.45855 40.9728 6.5602 42.6932C6.69373 44.9531 6.21839 47.2163 5.39698 49.3703C5.26766 49.7094 5.43774 50.0891 5.77685 50.2184C6.11596 50.3477 6.4957 50.1777 6.62502 49.8386C7.49325 47.5617 8.01954 45.1092 7.87221 42.6157C7.77126 40.9071 7.44813 39.2252 7.12512 37.5439C6.73099 35.4925 6.33704 33.442 6.34716 31.3451C6.35659 29.3933 6.59455 27.4425 7.05311 25.5432Z"}),/*#__PURE__*/t("path",{d:"M24.2964 10.94C24.4317 11.2768 24.2683 11.6595 23.9315 11.7947C17.1187 14.5307 12.0027 20.7047 10.959 27.9852C10.523 31.0269 10.9941 34.0398 11.465 37.052C11.7303 38.7483 11.9954 40.4443 12.0985 42.1451C12.3221 45.833 11.902 49.8839 9.50192 53.5696C9.30387 53.8737 8.89677 53.9597 8.59264 53.7617C8.28851 53.5636 8.20251 53.1565 8.40056 52.8524C10.5873 49.4944 11.0012 45.7644 10.7867 42.2246C10.6821 40.499 10.4185 38.7833 10.1552 37.0686C9.68265 33.9923 9.21067 30.9195 9.65804 27.7987C10.7724 20.025 16.221 13.4748 23.4417 10.5751C23.7785 10.4399 24.1612 10.6032 24.2964 10.94Z"}),/*#__PURE__*/t("path",{d:"M47.3662 14.6814C41.9915 9.64741 34.2017 7.89046 27.122 9.4433C26.7675 9.52105 26.5432 9.87147 26.6209 10.226C26.6987 10.5805 27.0491 10.8048 27.4036 10.7271C34.1075 9.25665 41.4426 10.934 46.4677 15.6406C50.7033 19.6077 53.1628 25.38 53.8066 31.6779C53.8435 32.0389 54.1661 32.3017 54.5272 32.2648C54.8883 32.2279 55.151 31.9053 55.1141 31.5442C54.4456 25.0047 51.8822 18.9111 47.3662 14.6814Z"}),/*#__PURE__*/t("path",{d:"M54.9766 34.6738C55.3376 34.6368 55.6604 34.8994 55.6975 35.2604C56.3216 41.337 56.0526 47.9003 55.1104 54.2496C55.0571 54.6086 54.7229 54.8565 54.3639 54.8032C54.0049 54.7499 53.7571 54.4157 53.8103 54.0567C54.7394 47.7957 55.001 41.3439 54.39 35.3947C54.353 35.0336 54.6156 34.7109 54.9766 34.6738Z"}),/*#__PURE__*/t("path",{d:"M32.0659 13.3553C21.9959 13.3553 13.814 21.3892 13.814 31.3219C13.814 32.3829 13.9081 33.4225 14.0876 34.4334C14.1511 34.7907 14.4922 35.029 14.8495 34.9655C15.2069 34.9021 15.4451 34.561 15.3817 34.2036C15.2155 33.2677 15.1283 32.305 15.1283 31.3219C15.1283 22.1352 22.7014 14.6696 32.0659 14.6696C36.2978 14.6696 40.1642 16.1949 43.1319 18.7152C43.4086 18.9501 43.8233 18.9163 44.0582 18.6396C44.2931 18.363 44.2593 17.9483 43.9827 17.7134C40.7847 14.9975 36.6188 13.3553 32.0659 13.3553Z"}),/*#__PURE__*/t("path",{d:"M45.455 20.1635C45.717 19.9123 46.133 19.921 46.3842 20.183C49.2843 23.2072 50.2126 27.9605 50.8269 31.9494C51.5188 36.4426 51.6244 40.826 51.6244 42.8585C51.6244 43.2214 51.3302 43.5156 50.9673 43.5156C50.6044 43.5156 50.3101 43.2214 50.3101 42.8585C50.3101 40.8589 50.2055 36.5497 49.5279 32.1494C48.9577 28.4462 48.1356 23.9082 45.4356 21.0927C45.1844 20.8307 45.1931 20.4147 45.455 20.1635Z"}),/*#__PURE__*/t("path",{d:"M51.4576 46.6219C51.4864 46.2601 51.2165 45.9435 50.8547 45.9146C50.493 45.8858 50.1763 46.1557 50.1474 46.5175C49.8247 50.5654 49.403 54.6088 48.5474 58.3439C48.4663 58.6977 48.6874 59.0502 49.0412 59.1312C49.3949 59.2123 49.7474 58.9912 49.8285 58.6374C50.7067 54.8039 51.134 50.6806 51.4576 46.6219Z"}),/*#__PURE__*/t("path",{d:"M15.1454 36.852C15.5015 36.7819 15.847 37.0137 15.9171 37.3698C17.3066 44.4257 16.3467 50.8355 12.6672 56.4502C12.4682 56.7537 12.0609 56.8385 11.7573 56.6396C11.4538 56.4407 11.369 56.0333 11.5679 55.7298C15.0299 50.4469 15.9617 44.3985 14.6276 37.6238C14.5575 37.2677 14.7893 36.9221 15.1454 36.852Z"}),/*#__PURE__*/t("path",{d:"M32.0659 17.631C25.5291 17.631 19.1165 22.691 18.462 29.0504C18.1754 31.8345 18.578 34.5769 18.9807 37.3204C19.3323 39.7159 19.684 42.1124 19.5772 44.5381C19.3328 50.0898 17.7039 54.6726 14.905 58.4471C14.6888 58.7386 14.7499 59.1502 15.0414 59.3663C15.333 59.5825 15.7445 59.5214 15.9607 59.2299C18.9293 55.2266 20.6354 50.386 20.8903 44.5959C20.9966 42.1811 20.6438 39.7923 20.2912 37.4051C19.888 34.6752 19.4851 31.9473 19.7694 29.1849C20.3444 23.5983 26.0946 18.9453 32.0659 18.9453C34.851 18.9453 42.057 20.4534 44.3492 27.9205C45.7856 32.5998 46.1774 38.9326 45.8295 45.0849C45.4816 51.2364 44.3994 57.12 42.9442 60.8928C42.8136 61.2314 42.9822 61.6118 43.3208 61.7424C43.6594 61.873 44.0398 61.7044 44.1704 61.3658C45.6929 57.4186 46.7895 51.386 47.1417 45.1591C47.4938 38.9329 47.1068 32.4249 45.6056 27.5348C43.0612 19.2461 35.0851 17.631 32.0659 17.631Z"}),/*#__PURE__*/t("path",{d:"M21.9529 56.4512C22.2569 56.6494 22.3426 57.0566 22.1444 57.3606C21.7369 57.9854 21.3784 58.6391 21.0199 59.2928C20.6614 59.9465 20.3028 60.6004 19.8953 61.2253C19.697 61.5293 19.2898 61.615 18.9858 61.4167C18.6819 61.2184 18.5962 60.8113 18.7944 60.5073C19.2019 59.8825 19.5604 59.2288 19.9189 58.5751C20.2774 57.9213 20.636 57.2675 21.0435 56.6426C21.2418 56.3386 21.649 56.2529 21.9529 56.4512Z"}),/*#__PURE__*/t("path",{d:"M27.5799 24.4525C27.8816 24.2508 27.9625 23.8426 27.7608 23.541C27.559 23.2393 27.1509 23.1583 26.8492 23.3601C24.247 25.1006 22.6505 27.494 22.6505 31.0002C22.6505 33.088 23.0203 34.7946 23.3997 36.5449C23.9674 39.1641 24.3524 41.7777 24.2832 44.468C24.1992 47.7349 23.56 50.7201 22.3313 53.564C22.1873 53.8971 22.3407 54.2839 22.6739 54.4278C23.0071 54.5718 23.3938 54.4184 23.5378 54.0852C24.8369 51.0784 25.509 47.9266 25.5971 44.5018C25.6689 41.7062 25.2732 38.9892 24.6845 36.267C24.3042 34.509 23.9648 32.9394 23.9648 31.0002C23.9648 27.9961 25.2863 25.9866 27.5799 24.4525Z"}),/*#__PURE__*/t("path",{d:"M30.1447 22.1436C32.8717 21.5877 35.8061 22.2746 37.966 24.0228C41.8241 27.1455 42.3372 32.8403 42.753 37.4549L42.7742 37.69C43.3115 43.6385 42.6964 49.4163 41.4575 55.2186C41.3817 55.5736 41.0326 55.7999 40.6776 55.7241C40.3227 55.6483 40.0964 55.2991 40.1722 54.9442C41.3926 49.2288 41.9873 43.5885 41.4652 37.8082C41.4479 37.6169 41.4307 37.4228 41.4133 37.2264L41.4131 37.2235C41.0438 33.0534 40.5812 27.8304 37.1392 25.0444C35.2926 23.5498 32.7599 22.9518 30.4073 23.4314C30.0517 23.5039 29.7046 23.2744 29.6321 22.9188C29.5596 22.5632 29.7891 22.2161 30.1447 22.1436Z"}),/*#__PURE__*/t("path",{d:"M40.5287 58.4885C40.6183 58.1368 40.4057 57.7791 40.054 57.6896C39.7023 57.6 39.3446 57.8126 39.2551 58.1643C38.8578 59.7247 38.2456 61.1333 37.4695 62.4301C37.2831 62.7415 37.3844 63.145 37.6958 63.3314C38.0072 63.5178 38.4108 63.4165 38.5972 63.1051C39.4336 61.7075 40.0977 60.1816 40.5287 58.4885Z"}),/*#__PURE__*/t("path",{d:"M37.3152 48.9521C37.6756 48.9948 37.9332 49.3215 37.8906 49.682C37.2699 54.9267 35.8688 59.6042 33.6205 63.6613C33.4446 63.9787 33.0446 64.0934 32.7272 63.9175C32.4097 63.7416 32.295 63.3417 32.4709 63.0242C34.6226 59.1416 35.9811 54.6339 36.5854 49.5275C36.6281 49.1671 36.9548 48.9095 37.3152 48.9521Z"}),/*#__PURE__*/t("path",{d:"M37.1798 30.6556C36.7242 28.2212 34.6349 26.3591 32.0985 26.3591C28.6638 26.3591 26.254 29.8212 27.1032 33.0422C28.54 38.7279 28.7759 44.2077 27.8032 49.4855L27.8025 49.4893C26.9584 54.228 25.3374 58.4908 23.1263 62.1031C22.9368 62.4127 23.0342 62.8172 23.3437 63.0067C23.6533 63.1962 24.0578 63.0988 24.2473 62.7893C26.5488 59.0292 28.2249 54.6109 29.0961 49.7218C30.106 44.2403 29.8558 38.5684 28.3765 32.7168L28.3748 32.7099C27.7378 30.3005 29.5133 27.6734 32.0985 27.6734C33.9641 27.6734 35.5393 29.0459 35.8871 30.8929C36.8436 36.4411 37.3418 41.5862 36.9871 46.016C36.9581 46.3778 37.2279 46.6945 37.5897 46.7235C37.9515 46.7525 38.2682 46.4827 38.2972 46.1209C38.6649 41.5294 38.1459 36.2576 37.1815 30.6648C37.1809 30.6617 37.1804 30.6586 37.1798 30.6556Z"}),/*#__PURE__*/t("path",{d:"M30.1376 59.1171C30.4604 59.283 30.5876 59.6792 30.4217 60.002L28.6804 63.3906C28.5145 63.7134 28.1184 63.8406 27.7956 63.6747C27.4728 63.5088 27.3456 63.1127 27.5114 62.7899L29.2527 59.4013C29.4186 59.0785 29.8147 58.9513 30.1376 59.1171Z"}),/*#__PURE__*/t("path",{d:"M32.5872 31.2892C32.5042 30.9359 32.1505 30.7168 31.7972 30.7998C31.4439 30.8828 31.2247 31.2365 31.3077 31.5898C33.5238 41.0232 33.2194 49.3066 30.5201 56.363C30.3905 56.702 30.5602 57.0819 30.8991 57.2115C31.2381 57.3412 31.618 57.1715 31.7477 56.8326C34.5622 49.475 34.8483 40.9141 32.5872 31.2892Z"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_113_33841",children:/*#__PURE__*/t("rect",{width:"64",height:"64",fill:"white",transform:"translate(0.483887)"})})})]});let su=({passkeys:n,expanded:r,onUnlink:a,onExpand:i})=>{let[o,l]=s([]),c=r?n.length:2,d=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";/*#__PURE__*/return e("div",{children:[/*#__PURE__*/t(fu,{children:"Your passkeys"}),/*#__PURE__*/e(pu,{children:[n.slice(0,c).map((n=>/*#__PURE__*/e(Cu,{children:[/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(wu,{children:d(n)}),/*#__PURE__*/e(vu,{children:["Last used: ",(n.latestVerifiedAt??n.verifiedAt).toLocaleString()]})]}),/*#__PURE__*/t(Tu,{disabled:o.includes(n.credentialId),onClick:()=>(async e=>{l((t=>t.concat([e]))),await a(e),l((t=>t.filter((t=>t!==e))))})(n.credentialId),children:o.includes(n.credentialId)?/*#__PURE__*/t(qt,{}):/*#__PURE__*/t(ao,{height:"1.6em"})})]},n.credentialId))),n.length>2&&!r&&/*#__PURE__*/t(uu,{onClick:i,children:"View all"})]})]})},lu=()=>/*#__PURE__*/e(pu,{children:[/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(io,{})}),"Log in with Touch ID, Face ID, or a security key."]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(bi,{})}),"More secure than a password."]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ro,{})}),"Takes seconds to set up and use."]})]});const cu=/*#__PURE__*/Ka.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-302702bc-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent) !important;stroke:var(--privy-color-accent) !important;fill:var(--privy-color-accent) !important;}"]);let du=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-302702bc-1"})(["line-height:20px;height:20px;font-size:13px;color:",";display:flex;justify-content:flex-beginngin;width:100%;"],(e=>e.$fail?"var(--privy-color-error)":"var(--privy-color-foreground-3)")),hu=/*#__PURE__*/Ya(["&&{width:100%;font-size:0.875rem;line-height:1rem;@media (min-width:440px){font-size:14px;}display:flex;gap:12px;justify-content:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]);const uu=/*#__PURE__*/Ka.button.withConfig({displayName:"LinkButton",componentId:"sc-302702bc-2"})(["",""],hu);let pu=/*#__PURE__*/Ka.div.withConfig({displayName:"List",componentId:"sc-302702bc-3"})(["display:flex;flex-direction:column;align-items:stretch;gap:0.8rem;padding:0.5rem 0rem 0rem;flex-grow:1;width:100%;"]),mu=/*#__PURE__*/Ka.div.withConfig({displayName:"ModalTitle",componentId:"sc-302702bc-4"})(["font-size:18px;line-height:18px;text-align:center;font-weight:600;"]),yu=/*#__PURE__*/Ka.div.withConfig({displayName:"ModalSubTitle",componentId:"sc-302702bc-5"})(["font-size:0.875rem;text-align:center;margin-top:10px;"]),gu=/*#__PURE__*/Ka.div.withConfig({displayName:"SectionSpacer",componentId:"sc-302702bc-6"})(["height:32px;"]),fu=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyListTitle",componentId:"sc-302702bc-7"})(["line-height:20px;height:20px;font-size:1em;font-weight:450;display:flex;justify-content:flex-beginning;width:100%;"]),wu=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyItemTitle",componentId:"sc-302702bc-8"})(["font-size:1em;line-height:1.3em;font-weight:500;color:var(--privy-color-foreground-2);padding:0.2em 0;"]),vu=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyItemSubtitle",componentId:"sc-302702bc-9"})(["font-size:0.875rem;line-height:1rem;color:#64668b;padding:0.2em 0;"]),Cu=/*#__PURE__*/Ka.div.withConfig({displayName:"PasskeyListItem",componentId:"sc-302702bc-10"})(["display:flex;align-items:center;justify-content:space-between;padding:1em;gap:10px;font-size:0.875rem;line-height:1rem;text-align:left;border-radius:8px;border:1px solid #e2e3f0 !important;width:100%;height:5em;"]),Eu=/*#__PURE__*/Ya([":focus,:hover,:active{outline:none;}display:flex;width:2em;height:2em;justify-content:center;align-items:center;svg{color:var(--privy-color-error);}svg:hover{color:var(--privy-color-foreground-3);}"]),Tu=/*#__PURE__*/Ka.button.withConfig({displayName:"PasskeyItemUnlinkButton",componentId:"sc-302702bc-11"})(["",""],Eu);const bu=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingMethodContainer",componentId:"sc-eaaa12a-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),Au=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-eaaa12a-1"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;svg{border-radius:var(--privy-border-radius-sm);}"]),_u=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingQuantityWrapper",componentId:"sc-eaaa12a-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:8px;"]),ku=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingQuantity",componentId:"sc-eaaa12a-3"})(["display:flex;align-items:center;gap:4px;width:100%;padding:0 16px;border-width:1px !important;border-radius:12px;cursor:text;&:focus-within{border-color:var(--privy-color-accent);}"]),Iu=/*#__PURE__*/Ka.input.withConfig({displayName:"FundingAmountInput",componentId:"sc-eaaa12a-5"})(["background-color:var(--privy-color-background);width:100%;&:focus{outline:none !important;border:none !important;box-shadow:none !important;}&&{font-size:26px;}"]),Nu=/*#__PURE__*/Ka(Iu).withConfig({displayName:"FundingAmountInputLarge",componentId:"sc-eaaa12a-6"})(["&&{font-size:42px;}"]),xu=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingCurrency",componentId:"sc-eaaa12a-8"})(["font-size:18px;"]),Su=/*#__PURE__*/Ka.div.withConfig({displayName:"FundingDollars",componentId:"sc-eaaa12a-9"})(["font-size:12px;color:var(--privy-color-foreground-3);height:20px;"]),Ru=/*#__PURE__*/Ka.div.withConfig({displayName:"InfoButtonText",componentId:"sc-eaaa12a-13"})([""]),Ou=/*#__PURE__*/Ka.a.withConfig({displayName:"InfoButtonLink",componentId:"sc-eaaa12a-14"})(["&&{color:var(--privy-color-accent);}cursor:pointer;"]),Wu=({displayName:r,errorMessage:a,configuredFundingChain:i,formattedBalance:o,fundingAmount:s,fundingCurrency:c,fundingAmountInUsd:d,options:h,selectedOption:u,isPreparing:p,isSubmitting:m,addressToFund:y,fundingWalletAddress:g,onSubmit:f,onSelect:w,onAmountChange:v})=>{let C=l(null);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(St,{children:"Transfer from another network"}),/*#__PURE__*/e(Rt,{children:["You need more funds on the ",i.name," network. Bridge from another blockchain network."]}),/*#__PURE__*/e(_u,{style:{marginTop:"2rem"},children:[/*#__PURE__*/e(ku,{onClick:()=>C.current?.focus(),children:[/*#__PURE__*/t(Iu,{ref:C,value:s,onChange:e=>{let t=e.target.value;if(/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1){let e=/\.$/.test(t)?".":"",n=Number(t.replace(/\.$/,"")||"0");if(Number.isNaN(n))return void v("0");v(n.toString()+e)}}}),/*#__PURE__*/t(xu,{children:c})]}),d&&/*#__PURE__*/t(Su,{children:d})]}),/*#__PURE__*/e(Kt,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/t(jh,{children:"From"}),/*#__PURE__*/t(jh,{children:Ai(g)})]}),/*#__PURE__*/t(Xh,{selected:{chain:u.chain,balance:Yt(u.balance,u.chain.nativeCurrency.symbol,3,!0)},options:h.map((({chain:e,balance:t})=>({chain:e,balance:Yt(t,e.nativeCurrency.symbol,3,!0)}))),onSelect:w}),/*#__PURE__*/e(Kt,{style:{marginTop:"1.5rem"},children:[/*#__PURE__*/t(jh,{children:"To"}),/*#__PURE__*/t(jh,{children:Ai(y)})]}),/*#__PURE__*/t(Kh,{chain:i,balance:o}),/*#__PURE__*/t(Zt,{style:{marginTop:"1rem"},children:a}),/*#__PURE__*/e(Jt,{style:{marginTop:"1rem"},loading:m||p,disabled:p||m,onClick:f,children:["Confirm with ",r]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},Mu=({wallet:r,displayName:a,addressToFund:i,chainId:o,chainName:s,isBridging:l,isErc20Flow:c,totalPriceInNativeCurrency:d,totalPriceInUsd:h,gasPriceInNativeCurrency:u,gasPriceInUsd:p})=>{let m=ft(r.walletClientType);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(kh,{}),/*#__PURE__*/t(Ft,{style:{marginTop:"16px"},children:/*#__PURE__*/t(wc,{icon:m?.image_url?.md,name:r.walletClientType})}),/*#__PURE__*/t(Ql,{style:{marginTop:"8px",marginBottom:"12px"},title:`${l?"Bridging":"Confirming"} with ${a}`}),!l&&!c&&/*#__PURE__*/e(Qt,{children:[/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Total"}),/*#__PURE__*/t(qh,{children:h||d})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"To"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:i,showCopyIcon:!1})})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Network"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/e(Pu,{children:[/*#__PURE__*/t(jt,{chainId:o,height:16,width:16})," ",s]})})]}),u&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Estimated fee"}),/*#__PURE__*/t(qh,{children:p||u})]})]}),/*#__PURE__*/t(It,{height:24}),/*#__PURE__*/t(ct,{})]})};let Pu=/*#__PURE__*/Ka.div.withConfig({displayName:"NetworkColumn",componentId:"sc-ec6320ce-0"})(["display:flex;flex-direction:row;align-items:center;gap:4px;"]);const Lu=[cr.FUNDING_METHOD_SELECTION_SCREEN,cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN,cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN,cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN,cr.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN,cr.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN,cr.FUNDING_MANUAL_TRANSFER_SCREEN,cr.MOONPAY_STATUS_SCREEN],Du={[cr.FUNDING_METHOD_SELECTION_SCREEN]:null,[cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:"external",[cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:"external",[cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN]:"external",[cr.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN]:"external",[cr.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN]:"external",[cr.FUNDING_MANUAL_TRANSFER_SCREEN]:"manual",[cr.MOONPAY_STATUS_SCREEN]:"moonpay"},Uu=[{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}];let Fu=({status:r,onClickCta:a})=>{let{title:o,body:s,cta:l}=i((()=>(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(Hu,{children:[/*#__PURE__*/t(Bu,{isSucccess:"success"===r}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:o}),/*#__PURE__*/t(zu,{children:s})]})]}),l&&/*#__PURE__*/t(st,{onClick:a,children:l})]})},Bu=({isSucccess:n})=>{if(!n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t(Ht,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(on,{color:n}),/*#__PURE__*/t(as,{style:{position:"absolute",width:"2.8rem",height:"2.8rem",top:"1.2rem",left:"1.2rem"}})]})}let r=(e=>e?si:()=>/*#__PURE__*/t(Ji,{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})})},zu=/*#__PURE__*/Ka.p.withConfig({displayName:"StatusBody",componentId:"sc-96ef1540-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),Hu=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-96ef1540-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const Vu=({children:n,theme:r})=>/*#__PURE__*/e($u,{$theme:r,children:[/*#__PURE__*/t(Qa,{width:"3rem",color:"var(--privy-color-error)"}),n]});let $u=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-5400b18f-0"})(["display:flex;gap:0.5rem;"," align-items:flex-start;text-align:left;padding:0.5rem 0.75rem;font-size:0.75rem;font-weight:400;line-height:1.125rem;padding:0.5rem 0.75rem;&&{border:1px solid var(--privy-color-error);border-radius:var(--privy-border-radius-sm);}"],(e=>"dark"===e.$theme?"color: var(--privy-color-error);":"background-color: var(--privy-color-error-light);"));const ju=({children:n,theme:r})=>/*#__PURE__*/e(Gu,{$theme:r,children:[/*#__PURE__*/t(eo,{width:"1.25rem",color:"dark"===r?"var(--privy-color-accent-light)":"var(--privy-color-accent-dark)",style:{minWidth:"1.25rem"}}),n]});let Gu=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-dc8a0871-0"})(["display:flex;gap:0.5rem;background-color:",";color:var(--privy-color-foreground);align-items:flex-start;text-align:left;font-size:0.8125rem;font-weight:400;line-height:1.125rem;padding:0.75rem;&&{border-radius:var(--privy-border-radius-sm);border:1px solid var(--privy-color-accent);}"],(e=>"dark"===e.$theme?"var(--privy-color-accent-darkest)":"var(--privy-color-accent-lightest)"));const qu=e=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 210.2",xmlSpace:"preserve",...e,children:/*#__PURE__*/t("path",{d:"M93.6,27.1C87.6,34.2,78,39.8,68.4,39c-1.2-9.6,3.5-19.8,9-26.1c6-7.3,16.5-12.5,25-12.9 C103.4,10,99.5,19.8,93.6,27.1 M102.3,40.9c-13.9-0.8-25.8,7.9-32.4,7.9c-6.7,0-16.8-7.5-27.8-7.3c-14.3,0.2-27.6,8.3-34.9,21.2 c-15,25.8-3.9,64,10.6,85c7.1,10.4,15.6,21.8,26.8,21.4c10.6-0.4,14.8-6.9,27.6-6.9c12.9,0,16.6,6.9,27.8,6.7 c11.6-0.2,18.9-10.4,26-20.8c8.1-11.8,11.4-23.3,11.6-23.9c-0.2-0.2-22.4-8.7-22.6-34.3c-0.2-21.4,17.5-31.6,18.3-32.2 C123.3,42.9,107.7,41.3,102.3,40.9 M182.6,11.9v155.9h24.2v-53.3h33.5c30.6,0,52.1-21,52.1-51.4c0-30.4-21.1-51.2-51.3-51.2H182.6z M206.8,32.3h27.9c21,0,33,11.2,33,30.9c0,19.7-12,31-33.1,31h-27.8V32.3z M336.6,169c15.2,0,29.3-7.7,35.7-19.9h0.5v18.7h22.4V90.2 c0-22.5-18-37-45.7-37c-25.7,0-44.7,14.7-45.4,34.9h21.8c1.8-9.6,10.7-15.9,22.9-15.9c14.8,0,23.1,6.9,23.1,19.6v8.6l-30.2,1.8 c-28.1,1.7-43.3,13.2-43.3,33.2C298.4,155.6,314.1,169,336.6,169z M343.1,150.5c-12.9,0-21.1-6.2-21.1-15.7c0-9.8,7.9-15.5,23-16.4 l26.9-1.7v8.8C371.9,140.1,359.5,150.5,343.1,150.5z M425.1,210.2c23.6,0,34.7-9,44.4-36.3L512,54.7h-24.6l-28.5,92.1h-0.5 l-28.5-92.1h-25.3l41,113.5l-2.2,6.9c-3.7,11.7-9.7,16.2-20.4,16.2c-1.9,0-5.6-0.2-7.1-0.4v18.7C417.3,210,423.3,210.2,425.1,210.2z"})}),Ku=n=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 80 38.1",xmlSpace:"preserve",...n,children:[/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M37.8,19.7V29h-3V6h7.8c1.9,0,3.7,0.7,5.1,2c1.4,1.2,2.1,3,2.1,4.9c0,1.9-0.7,3.6-2.1,4.9c-1.4,1.3-3.1,2-5.1,2 L37.8,19.7L37.8,19.7z M37.8,8.8v8h5c1.1,0,2.2-0.4,2.9-1.2c1.6-1.5,1.6-4,0.1-5.5c0,0-0.1-0.1-0.1-0.1c-0.8-0.8-1.8-1.3-2.9-1.2 L37.8,8.8L37.8,8.8z"}),/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M56.7,12.8c2.2,0,3.9,0.6,5.2,1.8s1.9,2.8,1.9,4.8V29H61v-2.2h-0.1c-1.2,1.8-2.9,2.7-4.9,2.7 c-1.7,0-3.2-0.5-4.4-1.5c-1.1-1-1.8-2.4-1.8-3.9c0-1.6,0.6-2.9,1.8-3.9c1.2-1,2.9-1.4,4.9-1.4c1.8,0,3.2,0.3,4.3,1v-0.7 c0-1-0.4-2-1.2-2.6c-0.8-0.7-1.8-1.1-2.9-1.1c-1.7,0-3,0.7-3.9,2.1l-2.6-1.6C51.8,13.8,53.9,12.8,56.7,12.8z M52.9,24.2 c0,0.8,0.4,1.5,1,1.9c0.7,0.5,1.5,0.8,2.3,0.8c1.2,0,2.4-0.5,3.3-1.4c1-0.9,1.5-2,1.5-3.2c-0.9-0.7-2.2-1.1-3.9-1.1 c-1.2,0-2.2,0.3-3,0.9C53.3,22.6,52.9,23.3,52.9,24.2z"}),/*#__PURE__*/t("path",{style:{fill:"#5F6368"},d:"M80,13.3l-9.9,22.7h-3l3.7-7.9l-6.5-14.7h3.2l4.7,11.3h0.1l4.6-11.3H80z"}),/*#__PURE__*/t("path",{style:{fill:"#4285F4"},d:"M25.9,17.7c0-0.9-0.1-1.8-0.2-2.7H13.2v5.1h7.1c-0.3,1.6-1.2,3.1-2.6,4v3.3H22C24.5,25.1,25.9,21.7,25.9,17.7z"}),/*#__PURE__*/t("path",{style:{fill:"#34A853"},d:"M13.2,30.6c3.6,0,6.6-1.2,8.8-3.2l-4.3-3.3c-1.2,0.8-2.7,1.3-4.5,1.3c-3.4,0-6.4-2.3-7.4-5.5H1.4v3.4 C3.7,27.8,8.2,30.6,13.2,30.6z"}),/*#__PURE__*/t("path",{style:{fill:"#FBBC04"},d:"M5.8,19.9c-0.6-1.6-0.6-3.4,0-5.1v-3.4H1.4c-1.9,3.7-1.9,8.1,0,11.9L5.8,19.9z"}),/*#__PURE__*/t("path",{style:{fill:"#EA4335"},d:"M13.2,9.4c1.9,0,3.7,0.7,5.1,2l0,0l3.8-3.8c-2.4-2.2-5.6-3.5-8.8-3.4c-5,0-9.6,2.8-11.8,7.3l4.4,3.4 C6.8,11.7,9.8,9.4,13.2,9.4z"})]}),Yu=e=>{let[t,n]=s();return o((()=>{e().then((e=>{n(e)})).catch((()=>{}))}),[]),t},Zu=()=>window.open(void 0,void 0,Ju({w:440,h:680}));let Ju=({w:e,h:t})=>{let n=void 0!==window.screenLeft?window.screenLeft:window.screenX,r=void 0!==window.screenTop?window.screenTop:window.screenY,a=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,i=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height;return`toolbar=0,location=0,menubar=0,height=${t},width=${e},popup=1,left=${(a-e)/2/(a/window.screen.availWidth)+n},top=${(i-t)/2/(i/window.screen.availHeight)+r}`};let Qu={[Nr.id]:"ethereum",[xr.id]:"base",[Sr.id]:"optimism",[Rr.id]:"polygon",[Or.id]:"arbitrum"};const Xu=(e,t,n,r,a,i)=>new Promise((async(o,s)=>{let l=Zu();if(!l)return void s(Error("Unable to initialize flow"));let c="ethereum"===t.chainType?function(e){let t=Qu[e];if(!t)throw new T(`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:u}=_i({input:h,amount:t.amount,blockchain:c,asset:d,experience:i});l.location=u.toString();let p={...a?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(p.usingDefaultFundingMethod=!1),n({funding:p,coinbaseOnrampStatus:{popup:l}}),r(cr.COINBASE_ONRAMP_STATUS_SCREEN),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:p,coinbaseOnrampStatus:{partnerUserId:h.partner_user_id,popup:l}})}),5e3),o()})),ep=async(e,t,n,r,a,i,o,s)=>{let l=Zu();if(!l)throw Error("Unable to initialize flow");let c="ethereum"===t.chainType?t.moonpayConfigOverride?.currencyCode??ki(t.chain.id,r):"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??sa(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 u={...o?.funding,showAlternateFundingMethod:!0};t.usingDefaultFundingMethod&&(u.usingDefaultFundingMethod=!1),a({moonpayStatus:{},funding:u}),i(cr.MOONPAY_STATUS_SCREEN),setTimeout((()=>{a({moonpayStatus:{externalTransactionId:h},funding:u})}),8e3)};let tp=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 np=()=>tp("https://apple.com/apple-pay"),rp=()=>tp("https://google.com/pay");let ap=({...e})=>/*#__PURE__*/t(cs,{color:"black",...e}),ip={devnet:"Devnet","mainnet-beta":"Solana",testnet:"Testnet"};const op=({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"})]})});let sp=({status:r,onClickCta:a})=>{let{title:o,body:s,cta:l}=i((()=>(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(dp,{children:[/*#__PURE__*/t(lp,{status:r}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:o}),/*#__PURE__*/t(cp,{children:s})]})]}),l&&/*#__PURE__*/t(st,{onClick:a,children:l})]})},lp=({status:n})=>{if(!n||"pending"===n){let n="var(--privy-color-foreground-4)";/*#__PURE__*/return e("div",{style:{position:"relative"},children:[/*#__PURE__*/t(Ht,{color:n,style:{position:"absolute"}}),/*#__PURE__*/t(on,{color:n}),/*#__PURE__*/t(op,{size:"3rem",style:{position:"absolute",top:"1rem",left:"1rem"}})]})}let r=(e=>{switch(e){case"completed":return si;case"waitingAuthorization":return()=>/*#__PURE__*/t(Ji,{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})})},cp=/*#__PURE__*/Ka.p.withConfig({displayName:"StatusBody",componentId:"sc-56bea42a-0"})(["font-size:1rem;color:var(--privy-color-foreground-3);margin-bottom:1rem;display:flex;flex-direction:column;gap:1rem;"]),dp=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-56bea42a-1"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:1.75rem;margin-right:1.75rem;padding:2rem 0;"]);const hp=({onClick:n,text:r})=>/*#__PURE__*/e(il,{onClick:n,children:[/*#__PURE__*/t(Xa,{}),/*#__PURE__*/t(Xs,{children:r}),/*#__PURE__*/t(to,{})]});let up=({onClick:n,icon:r,name:a,chainType:i})=>/*#__PURE__*/e(il,{onClick:n,children:[/*#__PURE__*/t(Au,{style:{width:20},children:/*#__PURE__*/t("img",{src:r})}),a,/*#__PURE__*/t(vt,{color:"gray",style:{marginLeft:"auto"},children:"Connected"}),"solana"===i&&/*#__PURE__*/t(vt,{color:"gray",children:"Solana"})]});let pp=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledCircle",componentId:"sc-30eca48b-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 mp=({style:e,...n})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",width:"17",height:"17",viewBox:"0 0 17 17",style:{height:"1.25rem",width:"1.25rem",...e},...n,children:/*#__PURE__*/t("path",{strokeLinecap:"round",strokeLinejoin:"round",fillRule:"evenodd",clipRule:"evenodd",d:"M16.5 8.67993C16.5 9.82986 15.853 10.8287 14.9032 11.3322C15.2188 12.3599 14.97 13.5237 14.1569 14.3368C13.3437 15.1499 12.18 15.3987 11.1523 15.0831C10.6488 16.0329 9.64993 16.6799 8.5 16.6799C7.35007 16.6799 6.35126 16.0329 5.84771 15.0831C4.82003 15.3987 3.65627 15.1499 2.84314 14.3368C2.03001 13.5237 1.78124 12.3599 2.09681 11.3322C1.14699 10.8287 0.5 9.82986 0.5 8.67993C0.5 7.53 1.14699 6.53119 2.0968 6.02764C1.78125 4.99996 2.03003 3.83621 2.84315 3.02309C3.65627 2.20997 4.82002 1.96119 5.8477 2.27675C6.35125 1.32692 7.35007 0.679932 8.5 0.679932C9.64992 0.679932 10.6487 1.32691 11.1523 2.27672C12.18 1.96115 13.3437 2.20993 14.1569 3.02305C14.97 3.83618 15.2188 4.99996 14.9032 6.02764C15.853 6.53119 16.5 7.53 16.5 8.67993ZM12.2659 6.68856C12.5654 6.40238 12.5761 5.92763 12.29 5.62818C12.0038 5.32873 11.529 5.31797 11.2296 5.60416C9.73022 7.03711 8.40877 8.65489 7.3018 10.4211L5.78033 8.89963C5.48744 8.60673 5.01256 8.60673 4.71967 8.89963C4.42678 9.19252 4.42678 9.66739 4.71967 9.96029L6.92031 12.1609C7.08544 12.3261 7.31807 12.4048 7.54957 12.374C7.78106 12.3432 7.98499 12.2064 8.1012 12.0038C9.23027 10.0356 10.6362 8.24613 12.2659 6.68856Z",fill:"var(--privy-color-accent)"})}),yp=/*#__PURE__*/Ka.div.withConfig({displayName:"TodoList",componentId:"sc-491785d-0"})(["display:flex;flex-direction:column;justify-content:flex-start;gap:4px;"]),gp=/*#__PURE__*/Ka.div.withConfig({displayName:"TodoSpacer",componentId:"sc-491785d-1"})(["&&&{margin-left:7px;border-left:2px solid var(--privy-color-foreground-4);height:12px;}"]),fp=({children:n})=>/*#__PURE__*/e(wp,{children:[/*#__PURE__*/t(mp,{style:{width:"16px",height:"16px"}}),n]});let wp=/*#__PURE__*/Ka.div.withConfig({displayName:"TodoItemWrapper",componentId:"sc-491785d-2"})(["display:flex;justify-content:flex-start;justify-items:center;text-align:left;gap:8px;&&{a{text-decoration:underline;color:var(--privy-color-accent);}svg{margin-top:auto;margin-bottom:auto;}}"]),vp=({name:n,installLink:r})=>/*#__PURE__*/e(Ft,{children:[/*#__PURE__*/t(Zl,{title:`Create a ${n} wallet`.replace(/wallet wallet/gi,"wallet"),description:"Follow the instructions below to get started."}),/*#__PURE__*/e(yp,{children:[/*#__PURE__*/t(fp,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t("span",{children:"Install the "})," ",/*#__PURE__*/e("a",{href:r,target:"_blank",children:[n," browser extension"]})]})}),/*#__PURE__*/t(gp,{}),/*#__PURE__*/t(fp,{children:"Set up your first wallet"}),/*#__PURE__*/t(gp,{}),/*#__PURE__*/t(fp,{children:"Store your recovery phrase in a safe place!"})]}),/*#__PURE__*/t(un,{onClick:()=>window.location.reload(),style:{marginTop:"20px"},children:"Reload the page to use your wallet"})]});let Cp={apple_oauth:"apple",custom_auth:"custom",discord_oauth:"discord",email:"email",farcaster:"farcaster",github_oauth:"github",google_oauth:"google",instagram_oauth:"instagram",linkedin_oauth:"linkedin",passkey:"passkey",phone:"sms",spotify_oauth:"spotify",telegram:"telegram",tiktok_oauth:"tiktok",twitter_oauth:"twitter",wallet:"siwe",smart_wallet:"siwe",cross_app:"privy:"};const Ep=e=>{let t=Cp[e];return"wallet"===e||"phone"===e?{displayName:e,loginMethod:t}:{displayName:t,loginMethod:t}},Tp=()=>{let{app:e}=lr(),n=e?.appearance?.logo,r=`${e?.name} logo`,i={maxHeight:"90px",maxWidth:"180px"};return n?"string"==typeof n?/*#__PURE__*/t("img",{src:n,alt:r,style:i}):"svg"===n.type||"img"===n.type?/*#__PURE__*/a.cloneElement(n,{alt:r,style:i}):(console.warn("`config.appearance.logo` must be a string, or an SVG / IMG element. Nothing will be rendered."),null):null},bp=e=>{let{app:n}=lr();return n?.appearance.logo?/*#__PURE__*/t(Ap,{...e,children:/*#__PURE__*/t(Tp,{})}):null},Ap=/*#__PURE__*/Ka.div.withConfig({displayName:"AppLogoContainer",componentId:"sc-a206bd44-0"})(["display:flex;flex-direction:column;align-items:center;padding:24px 0;flex-grow:1;justify-content:center;"]),_p=({appId:r})=>{let[a,i]=s(void 0),{startCrossAppAuthFlow:l,authenticated:c}=hr(),{client:d}=x();return o((()=>{(async()=>{d&&i(await d.getCrossAppProviderDetails(r))})()}),[d]),/*#__PURE__*/t(il,{onClick:()=>l({appId:r,action:c?"link":"login"}),disabled:!a,children:a?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Rc,{name:a.name,logoUrl:a.icon_url||void 0,size:"24px"})," ",a.name]}):/*#__PURE__*/t(qt,{})})},kp=/*#__PURE__*/h(((r,a)=>{let[i,l]=s(r.defaultValue||""),[c,d]=s(""),[h,u]=s(!1),{authenticated:p}=hr(),{initLoginWithEmail:m}=x(),{navigate:y,setModalData:g,currentScreen:f,data:w}=lr(),{enabled:v,token:C}=it(),[E,T]=s(!1),{accountType:b}=gt(),_=dr();o((()=>{!i&&_.disablePlusEmails&&w?.inlineError?.error instanceof M&&w?.inlineError?.error.privyErrorCode===A.DISALLOWED_PLUS_EMAIL&&!c&&d("Please enter a valid email address without a '+'."),c&&d("")}),[i]);let k=pn(i),I=h||!k,N=()=>{g({inlineError:void 0}),!v||C||p?(e=>{u(!0),m({email:i,captchaToken:e,disableSignup:w?.login?.disableSignup,withPrivyUi:!0}).then((()=>{y(cr.AWAITING_PASSWORDLESS_CODE)})).catch((e=>{g({errorModalData:{error:e,previousScreen:f||cr.LANDING}}),y(cr.ERROR_SCREEN)})).finally((()=>{u(!1)}))})(C):(g({captchaModalData:{callback:e=>m({email:i,captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:cr.ERROR_SCREEN}}),y(cr.CAPTCHA_SCREEN))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(Ip,{children:[c&&/*#__PURE__*/t(Zt,{style:{display:"block",marginTop:"0.25rem",textAlign:"left"},children:c}),/*#__PURE__*/e(Np,{stacked:r.stacked,$error:!!c,children:[/*#__PURE__*/t(ii,{}),/*#__PURE__*/t("input",{ref:a,id:"email-input",className:"login-method-button",type:"email",placeholder:"your@email.com",onFocus:()=>T(!0),onChange:e=>l(e.target.value),onKeyUp:e=>{"Enter"===e.key&&N()},value:i,autoComplete:"email"}),"email"!==b||E?r.stacked?/*#__PURE__*/t("span",{}):/*#__PURE__*/t(mn,{isSubmitting:h,onClick:N,disabled:I,children:"Submit"}):/*#__PURE__*/t(vt,{color:"gray",children:"Recent"})]})]}),r.stacked?/*#__PURE__*/t(st,{loadingText:null,loading:h,disabled:I,onClick:N,children:"Submit"}):null]})}));let Ip=yn,Np=gn;const xp=({isEditable:r,setIsEditable:a,defaultValue:i})=>{let o=l(null);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(sl,{$if:!r,children:/*#__PURE__*/t(kp,{ref:o,defaultValue:i})}),/*#__PURE__*/t(sl,{$if:r,children:/*#__PURE__*/e(il,{onClick:()=>{a(),setTimeout((()=>{o.current?.focus()}),0)},children:[/*#__PURE__*/t(ii,{})," Continue with Email"]})})]})},Sp=()=>{let[n,r]=s(!1),{currentScreen:a,navigate:i,setModalData:o,data:l}=lr(),{enabled:c,token:d}=it(),{initLoginWithFarcaster:h}=x(),{accountType:u}=gt();/*#__PURE__*/return e(il,{onClick:async()=>{r(!0);try{c&&!d?(o({captchaModalData:{callback:e=>h(e,l?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:cr.AWAITING_FARCASTER_CONNECTION,onErrorNavigateTo:cr.ERROR_SCREEN}}),i(cr.CAPTCHA_SCREEN)):(await h(d,l?.login?.disableSignup),i(cr.AWAITING_FARCASTER_CONNECTION))}catch(e){o({errorModalData:{error:e,previousScreen:a||cr.LANDING}}),i(cr.ERROR_SCREEN)}finally{r(!1)}},disabled:!1,children:[/*#__PURE__*/t(wh,{})," Farcaster",n&&/*#__PURE__*/t(qt,{}),"farcaster"===u&&/*#__PURE__*/t(Rp,{color:"gray",children:"Recent"})]})};let Rp=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-19f52850-0"})(["margin-left:auto;"]);const Op=({...n})=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...n,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_2856_1743)",children:[/*#__PURE__*/t("path",{d:"M22.1673 8.24075V16.3642C22.1673 17.3256 21.3421 18.105 20.3241 18.105H17.0028M22.1673 8.24075C22.1673 7.27936 21.3421 6.5 20.3241 6.5H11.5302M22.1673 8.24075V8.42852C22.1673 9.03302 21.8352 9.59423 21.2901 9.91105L15.1463 13.4818C14.5539 13.8261 13.8067 13.8261 13.2143 13.4818L10.1621 11.5401",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),/*#__PURE__*/t("path",{d:"M3.12913 6.64816C0.508085 12.9507 3.49251 20.1847 9.79504 22.8057L11.5068 23.5176C12.4522 23.9108 13.7783 23.2222 14.1714 22.2768L14.6054 21.2333C14.7687 20.8406 14.6438 20.3871 14.3024 20.1334L11.2872 17.8927C10.9878 17.6702 10.5843 17.6488 10.2632 17.8384L9.11575 18.5156C8.78274 18.7121 8.3597 18.6844 8.07552 18.4221C5.94293 16.4542 4.77629 13.6264 4.90096 10.7273C4.91757 10.3409 5.19796 10.023 5.57269 9.92753L6.86381 9.59869C7.22522 9.50664 7.49627 9.20696 7.55169 8.83815L8.10986 5.12321C8.17306 4.70259 7.94188 4.29293 7.54915 4.1296L6.50564 3.69564C5.56026 3.30248 4.23416 3.99103 3.84101 4.9364L3.12913 6.64816Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_2856_1743",children:/*#__PURE__*/t("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]}),Wp=()=>{let{enabled:n,token:r}=it(),{navigate:a,setModalData:o,app:s,data:l}=lr(),{initLoginWithPasskey:c}=x(),d=()=>{s.loginConfig.passkeysForSignupEnabled?a(cr.SELECT_PASSKEY_SIGNUP_OR_LOGIN):(async()=>{n&&!r?(o({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>c({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:cr.ERROR_SCREEN}}),a(cr.CAPTCHA_SCREEN)):(await c({withPrivyUi:!0}),o({passkeyAuthModalData:{passkeySignupFlow:!1}}),a(cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE))})()};return 0===i((()=>{let e=l?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(s.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[s.loginMethods,l?.login])?/*#__PURE__*/e(il,{onClick:d,children:[/*#__PURE__*/t(no,{})," Continue with passkey"]}):/*#__PURE__*/t(Pp,{onClick:d,children:"I have a passkey"})};let Mp=/*#__PURE__*/Ya(["&&{width:100%;font-size:0.875rem;line-height:1rem;display:flex;gap:0.5rem;justify-content:center;align-items:center;padding:6px 8px;background-color:var(--privy-color-background);transition:background-color 200ms ease;color:var(--privy-color-accent) !important;:focus{outline:none;box-shadow:none;}}"]);const Pp=/*#__PURE__*/Ka.button.withConfig({displayName:"StyledLink",componentId:"sc-48dad958-0"})(["",""],Mp),Lp=({value:n,onChange:r})=>/*#__PURE__*/t("select",{value:n,onChange:r,children:Ri.map((t=>/*#__PURE__*/e("option",{value:t.code,children:[t.code," +",t.callCode]},t.code)))}),Dp=/*#__PURE__*/h(((r,a)=>{let{app:i}=lr(),[l,c]=s(!1),{accountType:d}=gt(),[h,u]=s(""),[p,m]=s(i?.intl.defaultCountry??"US"),y=Oi(h,p),g=Wi(p),f=Mi(p),w=Pi(p),v=!y,[C,E]=s(!1),T=w.length,b=e=>{let t=e.target.value;m(t),u(""),r.onChange&&r.onChange({rawPhoneNumber:h,qualifiedPhoneNumber:Di(h,t),countryCode:t,isValid:Oi(h,p)})},A=(e,t)=>{try{let n=e.replace(/\D/g,"")===h.replace(/\D/g,"")?e:g.input(e);u(n),r.onChange&&r.onChange({rawPhoneNumber:n,qualifiedPhoneNumber:Di(e,t),countryCode:t,isValid:Oi(e,t)})}catch(e){console.error("Error processing phone number:",e)}},_=()=>{E(!0);let e=Di(h,p);r.onSubmit({rawPhoneNumber:h,qualifiedPhoneNumber:e,countryCode:p,isValid:Oi(h,p)}).finally((()=>E(!1)))};return o((()=>{if(r.defaultValue){let e=Li(r.defaultValue);g.reset(),b({target:{value:e.countryCode}}),A(e.phone,e.countryCode)}}),[r.defaultValue]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Up,{children:/*#__PURE__*/e(Fp,{$callingCodeLength:T,$stacked:r.stacked,children:[/*#__PURE__*/t(Lp,{value:p,onChange:b}),/*#__PURE__*/t("input",{ref:a,id:"phone-number-input",className:"login-method-button",type:"tel",placeholder:f,onFocus:()=>c(!0),onChange:e=>{A(e.target.value,p)},onKeyUp:e=>{"Enter"===e.key&&_()},value:h,autoComplete:"tel"}),"phone"!==d||l||r.hideRecent?r.stacked||r.noIncludeSubmitButton?/*#__PURE__*/t("span",{}):/*#__PURE__*/t(mn,{isSubmitting:C,onClick:_,disabled:v,children:"Submit"}):/*#__PURE__*/t(vt,{color:"gray",children:"Recent"})]})}),r.stacked&&!r.noIncludeSubmitButton?/*#__PURE__*/t(st,{loading:C,loadingText:null,onClick:_,disabled:v,children:"Submit"}):null]})}));let Up=/*#__PURE__*/Ka.div.withConfig({displayName:"InputContainer",componentId:"sc-2a729487-0"})(["width:100%;"]),Fp=/*#__PURE__*/Ka.label.withConfig({displayName:"PhoneNumberInput",componentId:"sc-2a729487-1"})(["--country-code-dropdown-width:calc(54px + calc(12 * ","px));--phone-input-extra-padding-left:calc(12px + calc(3 * ","px));display:block;position:relative;width:100%;@media (min-width:441px){--country-code-dropdown-width:calc(52px + calc(10 * ","px));}&& > select{font-size:16px;height:24px;position:absolute;margin:13px calc(var(--country-code-dropdown-width) / 4);line-height:24px;width:var(--country-code-dropdown-width);background-color:var(--privy-color-background);background-size:auto;background-position-x:right;cursor:pointer;@media (min-width:441px){font-size:14px;width:var(--country-code-dropdown-width);}:focus{outline:none;box-shadow:none;}}&& > input{font-size:16px;line-height:24px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width:calc(100% - var(--country-code-dropdown-width));padding:12px 88px 12px calc(var(--country-code-dropdown-width) + var(--phone-input-extra-padding-left));padding-right:",";flex-grow:1;background:var(--privy-color-background);border:1px solid var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-mdlg);width:100%;:focus{outline:none;border-color:var(--privy-color-accent);}:autofill,:-webkit-autofill{background:var(--privy-color-background);}@media (min-width:441px){font-size:14px;padding-right:78px;}}&& > :last-child{right:16px;position:absolute;top:50%;transform:translate(0,-50%);}&& > button:last-child{right:0px;line-height:24px;padding:13px 17px;:focus{outline:none;border-color:var(--privy-color-accent);}}&& > input::placeholder{color:var(--privy-color-foreground-3);}"],(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$callingCodeLength),(e=>e.$stacked?"16px":"88px"));const Bp=({isEditable:r,setIsEditable:a,defaultValue:i})=>{let o=l(null),{authenticated:s}=hr(),{navigate:c,setModalData:d,currentScreen:h,data:u}=lr(),{initLoginWithSms:p}=x(),{enabled:m,token:y}=it();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(sl,{$if:!r,children:/*#__PURE__*/t(Dp,{ref:o,onSubmit:async function({qualifiedPhoneNumber:e}){if(!m||y||s)try{await p({phoneNumber:e,captchaToken:y,withPrivyUi:!0,disableSignup:u?.login?.disableSignup}),c(cr.AWAITING_PASSWORDLESS_CODE)}catch(e){d({errorModalData:{error:e,previousScreen:h||cr.LANDING}}),c(cr.ERROR_SCREEN)}else d({captchaModalData:{callback:t=>p({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:u?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:cr.ERROR_SCREEN}}),c(cr.CAPTCHA_SCREEN)},defaultValue:i})}),/*#__PURE__*/t(sl,{$if:r,children:/*#__PURE__*/e(il,{onClick:()=>{a(),setTimeout((()=>{o.current?.focus()}),0)},children:[/*#__PURE__*/t(oi,{})," Continue with SMS"]})})]})};let zp={apple:{logo:/*#__PURE__*/t(Po,{}),displayName:"Apple"},discord:{logo:/*#__PURE__*/t(Lo,{}),displayName:"Discord"},github:{logo:/*#__PURE__*/t(Do,{}),displayName:"GitHub"},google:{logo:/*#__PURE__*/t(Fo,{}),displayName:"Google"},linkedin:{logo:/*#__PURE__*/t(zo,{}),displayName:"LinkedIn"},spotify:{logo:/*#__PURE__*/t(Ho,{}),displayName:"Spotify"},instagram:{logo:/*#__PURE__*/t(Bo,{}),displayName:"Instagram"},twitter:{logo:/*#__PURE__*/t($o,{}),displayName:"Twitter"},tiktok:{logo:/*#__PURE__*/t(Vo,{}),displayName:"TikTok"}};const Hp=({provider:n})=>{let{enabled:r,token:a}=it(),{navigate:o,setModalData:l,data:c}=lr(),[d,h]=s(!1),{initLoginWithOAuth:u}=x(),{accountType:p}=gt(),m=i((()=>p&&"guest"!==p&&"signer"!==p&&"cross_app"!==p?Ep(p):null),[p]),{displayName:y,logo:g}=zp[n];/*#__PURE__*/return e(il,{onClick:()=>{h(!0),r&&!a?(l({captchaModalData:{callback:e=>u(n,e,c?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:cr.ERROR_SCREEN}}),o(cr.CAPTCHA_SCREEN)):u(n,void 0,c?.login?.disableSignup)},disabled:d,children:[g," ",y,m?.loginMethod===n&&/*#__PURE__*/t(Vp,{color:"gray",children:"Recent"})]})};let Vp=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-c2aa414-0"})(["margin-left:auto;"]);function $p(n){/*#__PURE__*/return e("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 240 240",...n,children:[/*#__PURE__*/t("defs",{children:/*#__PURE__*/e("linearGradient",{x1:"120",y1:"240",x2:"120",gradientUnits:"userSpaceOnUse",id:"telegram-linear-gradient",children:[/*#__PURE__*/t("stop",{offset:"0",stopColor:"#1d93d2"}),/*#__PURE__*/t("stop",{offset:"1",stopColor:"#38b0e3"})]})}),/*#__PURE__*/t("title",{children:"Telegram_logo"}),/*#__PURE__*/t("circle",{cx:"120",cy:"120",r:"120",fill:"url(#telegram-linear-gradient)"}),/*#__PURE__*/t("path",{d:"M81.229,128.772l14.237,39.406s1.78,3.687,3.686,3.687,30.255-29.492,30.255-29.492l31.525-60.89L81.737,118.6Z",fill:"#c8daea"}),/*#__PURE__*/t("path",{d:"M100.106,138.878l-2.733,29.046s-1.144,8.9,7.754,0,17.415-15.763,17.415-15.763",fill:"#a9c6d8"}),/*#__PURE__*/t("path",{d:"M81.486,130.178,52.2,120.636s-3.5-1.42-2.373-4.64c.232-.664.7-1.229,2.1-2.2,6.489-4.523,120.106-45.36,120.106-45.36s3.208-1.081,5.1-.362a2.766,2.766,0,0,1,1.885,2.055,9.357,9.357,0,0,1,.254,2.585c-.009.752-.1,1.449-.169,2.542-.692,11.165-21.4,94.493-21.4,94.493s-1.239,4.876-5.678,5.043A8.13,8.13,0,0,1,146.1,172.5c-8.711-7.493-38.819-27.727-45.472-32.177a1.27,1.27,0,0,1-.546-.9c-.093-.469.417-1.05.417-1.05s52.426-46.6,53.821-51.492c.108-.379-.3-.566-.848-.4-3.482,1.281-63.844,39.4-70.506,43.607A3.21,3.21,0,0,1,81.486,130.178Z",fill:"#fff"})]})}const jp=()=>{let{enabled:n,token:r}=it(),{navigate:a,setModalData:i,data:o}=lr(),[l,c]=s(!1),{initLoginWithTelegram:d}=x(),{accountType:h}=gt();async function u(e){try{await d(e,o?.login?.disableSignup),i({telegramAuthModalData:{seamlessAuth:!1}}),a(cr.TELEGRAM_AUTH_SCREEN)}catch(e){console.error(e),c(!1)}}/*#__PURE__*/return e(il,{onClick:async function(){if(c(!0),n&&!r)return i({captchaModalData:{callback:u,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:cr.ERROR_SCREEN}}),void a(cr.CAPTCHA_SCREEN);await u(r)},disabled:l,children:[/*#__PURE__*/t($p,{}),"Telegram","telegram"===h&&/*#__PURE__*/t(Gp,{color:"gray",children:"Recent"})]})};let Gp=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-f716a3a1-0"})(["margin-left:auto;"]);const qp=({onClick:n,text:r,icon:a})=>/*#__PURE__*/e(il,{onClick:n,children:[a,/*#__PURE__*/t(Xs,{children:r}),/*#__PURE__*/t(to,{})]}),Kp=({connectOnly:r})=>{let{closePrivyModal:a,connectors:l}=x(),{data:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),h=dr(),{accountType:u,walletClientType:p,chainType:m}=gt(),y=i((()=>u&&"guest"!==u&&"signer"!==u&&"cross_app"!==u?Ep(u):null),[u]),g=c?.login,{email:f,sms:w,google:v,twitter:C,discord:E,github:T,spotify:b,instagram:A,tiktok:_,linkedin:k,apple:I,wallet:N,farcaster:S,telegram:R}=i((()=>g?.loginMethods?Ui(g.loginMethods,!0):null),[g])??h.loginMethods,{passkey:O}=h.loginMethods,W=[f&&"email",w&&"sms",v&&"google",C&&"twitter",E&&"discord",T&&"github",b&&"spotify",A&&"instagram",_&&"tiktok",k&&"linkedin",I&&"apple",S&&"farcaster",R&&"telegram"].filter((e=>!!e)),M=W.length>0,P=i((()=>N&&!M?"web3-first":N&&h?.appearance.loginGroupPriority||"web2-first"),[N,M,h?.appearance.loginGroupPriority]),L=h?.appearance.hideDirectWeb2Inputs,[D,U]=s("default"),[F,B]=s(Xp({mostRecentlyUsedAccountType:u,smsAvailable:w,emailAvailable:f,prefilledType:g?.prefill?.type}));o((()=>{B(Xp({mostRecentlyUsedAccountType:u,smsAvailable:w,emailAvailable:f,prefilledType:g?.prefill?.type}))}),[f,w,u]);let z=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{U("default")}),150)};d.current=z;let H=[];p&&N?H.push(p):y?.loginMethod&&W.includes(y.loginMethod)&&H.push(y.loginMethod);let V=e=>"email"===e?/*#__PURE__*/t(xp,{isEditable:"email"===F,setIsEditable:()=>{B("email")},defaultValue:"email"===g?.prefill?.type?g.prefill.value:void 0},e):"sms"===e?/*#__PURE__*/t(Bp,{isEditable:"sms"===F,setIsEditable:()=>{B("sms")},defaultValue:"phone"===g?.prefill?.type?g.prefill.value:void 0},e):"apple"===e?/*#__PURE__*/t(Hp,{provider:"apple"},e):"discord"===e?/*#__PURE__*/t(Hp,{provider:"discord"},e):"farcaster"===e?/*#__PURE__*/t(Sp,{},e):"github"===e?/*#__PURE__*/t(Hp,{provider:"github"},e):"google"===e?/*#__PURE__*/t(Hp,{provider:"google"},e):"linkedin"===e?/*#__PURE__*/t(Hp,{provider:"linkedin"},e):"tiktok"===e?/*#__PURE__*/t(Hp,{provider:"tiktok"},e):"spotify"===e?/*#__PURE__*/t(Hp,{provider:"spotify"},e):"instagram"===e?/*#__PURE__*/t(Hp,{provider:"instagram"},e):"twitter"===e?/*#__PURE__*/t(Hp,{provider:"twitter"},e):"telegram"===e?/*#__PURE__*/t(jp,{},e):xc({walletList:h.appearance.walletList,walletChainType:g?.walletChainType??h.appearance.walletChainType,connectors:l,connectOnly:r,ignore:[],walletConnectEnabled:h.externalWallets.walletConnect.enabled,forceWallet:{wallet:e,chainType:m??"ethereum"}}),$=xc({walletList:h.appearance.walletList.filter((e=>e!==p)),walletChainType:g?.walletChainType??h.appearance.walletChainType,connectors:l,connectOnly:r,ignore:[...h.appearance.walletList,p],walletConnectEnabled:h.externalWallets.walletConnect.enabled}),j=W.filter((e=>e!==y?.loginMethod)).flatMap(V),G=H.flatMap(V);"web3-first"===P&&"default"===D?$.unshift(...G):"web2-first"===P&&j.unshift(...G);let q=W.filter((e=>"email"!==e&&"sms"!==e)),K=Zp({priority:P,email:f,sms:w,social:q}),Y=Jp({priority:P,email:f,sms:w,social:q}),Z=/*#__PURE__*/t(hp,{text:Qp({priority:P}),onClick:()=>U("web3-overflow")}),J=/*#__PURE__*/t(qp,{text:K,icon:Y,onClick:()=>U("web2-overflow")}),Q=L?0:1,X=N&&$.length>0,ee=0===j.length&&N&&0===$.length,te=5-(X?1:0),ne=$.length>0?$:/*#__PURE__*/t(fc,{chainType:h.appearance.walletChainType,withPadding:!0});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{title:h.appearance.landingHeader,onClose:z,backFn:"default"===D?void 0:()=>{U("default")}}),"default"===D&&/*#__PURE__*/t(Yp,{}),"default"===D&&("string"==typeof h.appearance.loginMessage?/*#__PURE__*/t(al,{children:h.appearance.loginMessage}):h.appearance.loginMessage),/*#__PURE__*/t(el,{style:{overflow:"hidden",padding:2},children:/*#__PURE__*/e(tl,{children:["default"===D&&"web2-first"===P&&/*#__PURE__*/e(n,{children:[j.length>te?j.slice(0,te-1):j,j.length>te&&J,X&&Z,ee&&/*#__PURE__*/t(fc,{chainType:h.appearance.walletChainType})]}),"default"===D&&"web3-first"===P&&/*#__PURE__*/e(n,{children:[N&&/*#__PURE__*/e(n,{children:[$.length>te?$.slice(0,te-1):$,$.length>te&&Z]}),j.length>Q&&J,j.length===Q&&j[0],ee&&/*#__PURE__*/t(fc,{chainType:h.appearance.walletChainType})]}),"web2-overflow"===D&&/*#__PURE__*/t(n,{children:"web3-first"===P?j:j.slice(3)}),"web3-overflow"===D?ne:[],O&&"default"===D&&/*#__PURE__*/t(Wp,{})]})}),h&&/*#__PURE__*/t(Et,{app:h}),/*#__PURE__*/t(ct,{})]})};let Yp=/*#__PURE__*/Ka(bp).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-2678dfdf-0"})(["margin-bottom:16px;"]),Zp=({priority:e,email:t,sms:n,social:r})=>"web2-first"===e?"Other socials":t&&n&&r.length>0||t&&r.length>0?"Log in with email or socials":n&&r.length>0?"Log in with sms or socials":t&&n?"Continue with email or sms":t?"Continue with email":n?"Continue with sms":"Log in with a social account",Jp=({priority:e,email:n,sms:r,social:a})=>"web2-first"===e||a.length>0?/*#__PURE__*/t(Ti,{}):n&&r?/*#__PURE__*/t(Op,{}):n?/*#__PURE__*/t(ii,{}):r?/*#__PURE__*/t(oi,{}):null,Qp=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const Xp=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:n,prefilledType:r})=>n&&("email"===e&&"phone"!==r||"email"===r)||!t||"phone"!==e&&"phone"!==r?"email":"sms",em=({connectOnly:r})=>{let{closePrivyModal:a,connectors:l}=x(),{app:c,onUserCloseViaDialogOrKeybindRef:d,data:h}=lr(),{appearance:{palette:{colorScheme:u}}}=dr(),{accountType:p,walletClientType:m,chainType:y}=gt(),g=i((()=>p&&"guest"!==p&&"signer"!==p&&"cross_app"!==p?Ep(p):null),[p]),f=c.loginMethodsAndOrder?.primary??[],w=c.loginMethodsAndOrder?.overflow??[],v=i((()=>[...f,...w]),[f,w]),C=c.loginMethods.passkey,E=h?.login,T=[];m&&v.includes(m)?T.push(m):p&&v.includes(g?.loginMethod)&&T.push(g?.loginMethod);let[b,A]=s("default"),[_,k]=s(Xp({mostRecentlyUsedAccountType:p,smsAvailable:v.includes("sms"),emailAvailable:v.includes("email"),prefilledType:E?.prefill?.type}));o((()=>{k(Xp({mostRecentlyUsedAccountType:p,smsAvailable:v.includes("sms"),emailAvailable:v.includes("email"),prefilledType:E?.prefill?.type}))}),[v,p]),o((()=>{"phone"===p&&k("sms");let e=v.indexOf("sms"),t=v.indexOf("email");e>-1&&e<t&&k("sms")}),[p,f,w]);let I=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{A("default")}),150)};d.current=I;let N=e=>"email"===e?/*#__PURE__*/t(xp,{isEditable:"email"===_,setIsEditable:()=>{k("email")},defaultValue:"email"===E?.prefill?.type?E.prefill.value:void 0},e):"sms"===e?/*#__PURE__*/t(Bp,{isEditable:"sms"===_,setIsEditable:()=>{k("sms")},defaultValue:"phone"===E?.prefill?.type?E.prefill.value:void 0},e):"apple"===e?/*#__PURE__*/t(Hp,{provider:"apple"},e):"discord"===e?/*#__PURE__*/t(Hp,{provider:"discord"},e):"farcaster"===e?/*#__PURE__*/t(Sp,{},e):"github"===e?/*#__PURE__*/t(Hp,{provider:"github"},e):"google"===e?/*#__PURE__*/t(Hp,{provider:"google"},e):"linkedin"===e?/*#__PURE__*/t(Hp,{provider:"linkedin"},e):"spotify"===e?/*#__PURE__*/t(Hp,{provider:"spotify"},e):"instagram"===e?/*#__PURE__*/t(Hp,{provider:"instagram"},e):"tiktok"===e?/*#__PURE__*/t(Hp,{provider:"tiktok"},e):"twitter"===e?/*#__PURE__*/t(Hp,{provider:"twitter"},e):"telegram"===e?/*#__PURE__*/t(jp,{},e):e.startsWith("privy:")?/*#__PURE__*/t(_p,{appId:e.replace("privy:","")},e):xc({walletList:c.appearance.walletList,walletChainType:E?.walletChainType??c.appearance.walletChainType,connectors:l,connectOnly:r,ignore:v,walletConnectEnabled:c.externalWallets.walletConnect.enabled,forceWallet:{wallet:e,chainType:y??"ethereum"}}),S=T.flatMap(N),R=f.filter((e=>e!==m&&e!==g?.loginMethod)).flatMap(N),O=w.filter((e=>e!==m&&e!==g?.loginMethod)).flatMap(N),[W,M]=fn([...S,...R,...O],tm({primary:R.length+S.length,overflow:O.length}));/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{title:c.appearance.landingHeader,onClose:I,backFn:"default"===b?void 0:()=>{A("default")}}),"default"===b&&/*#__PURE__*/t(nm,{}),"default"===b&&("string"==typeof c.appearance.loginMessage?/*#__PURE__*/t(al,{children:c.appearance.loginMessage}):c.appearance.loginMessage),/*#__PURE__*/t(el,{style:{overflow:"hidden"},children:/*#__PURE__*/e(nl,{$colorScheme:u,children:["default"===b&&/*#__PURE__*/e(n,{children:[W,M.length>0&&/*#__PURE__*/t(qp,{text:"More options",icon:/*#__PURE__*/t(Ti,{}),onClick:()=>A("overflow")})]}),"overflow"===b&&/*#__PURE__*/t(n,{children:M}),C&&"default"===b&&/*#__PURE__*/t(Wp,{})]})}),c&&/*#__PURE__*/t(Et,{app:c}),/*#__PURE__*/t(ct,{})]})};let tm=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,nm=/*#__PURE__*/Ka(bp).withConfig({displayName:"StyledAppLogoHeader",componentId:"sc-85b7f7ea-0"})(["margin-bottom:16px;"]);const rm=({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"})]});function am(){let{promptMfa:e,init:t,submit:n,cancel:r,mfaMethods:a}=u(Wr);return{promptMfa:e,init:t,submit:n,cancel:r,mfaMethods:a}}function im(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:t,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:r,submitEnrollmentWithTotp:a,submitEnrollmentWithPasskey:i,unenroll:o,enrollInMfa:s}=u(Wr);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 om=n=>/*#__PURE__*/e(sm,{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 sm=/*#__PURE__*/Ka.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 lm=({showIntro:r,userMfaMethods:a,appMfaMethods:i,userHasAuthSms:o,isTotpLoading:s,isPasskeyLoading:l,error:c,onClose:d,onBackToIntro:h,handleSelectMethod:u,setRemovingMfaMethod:p})=>{let m=a.reduce(((e,t)=>({...e,[t]:!0})),{}),y=i.reduce(((e,t)=>({...e,[t]:!0})),{});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:r?h:void 0,onClose:d},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(Nl,{children:"Choose a verification method"}),a.length>0?/*#__PURE__*/t(xl,{children:"To add or delete verification methods, verification is required."}):/*#__PURE__*/t(xl,{children:"How would you like to verify your identity? You can change this later."}),c&&/*#__PURE__*/t($l,{style:{marginTop:"1.25rem"},children:c.message}),/*#__PURE__*/e(Pl,{children:[(y.totp||m.totp)&&/*#__PURE__*/e(Ll,{children:[/*#__PURE__*/t(il,{style:{justifyContent:"center"},disabled:m.totp||s,onClick:()=>u("totp"),children:s?/*#__PURE__*/t(Ht,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(Bl,{children:[/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/t(lo,{}),"Authenticator app"]}),m.totp?/*#__PURE__*/t(cm,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Fl,{children:"Recommended"})]})}),m.totp&&/*#__PURE__*/t(Dl,{style:{position:"absolute",right:0},onClick:()=>p("totp"),children:/*#__PURE__*/t(co,{})})]},"totp"),(y.sms||m.sms)&&/*#__PURE__*/e(Ll,{children:[/*#__PURE__*/t(il,{disabled:m.sms||o,onClick:()=>u("sms"),children:/*#__PURE__*/e(Bl,{children:[/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/t(oi,{}),"SMS"]}),m.sms&&/*#__PURE__*/t(cm,{color:"green",children:"Enabled"}),o&&/*#__PURE__*/t(Fl,{children:"Disabled"})]})}),m.sms&&/*#__PURE__*/t(Dl,{style:{position:"absolute",right:0},onClick:()=>p("sms"),children:/*#__PURE__*/t(co,{})})]},"sms"),(y.passkey||m.passkey)&&/*#__PURE__*/e(Ll,{children:[/*#__PURE__*/t(il,{style:{justifyContent:"center"},onClick:()=>u("passkey"),disabled:m.passkey||l,children:l?/*#__PURE__*/t(Ht,{style:{height:24,width:24,borderWidth:2},color:"var(--privy-color-foreground-3)"}):/*#__PURE__*/e(Bl,{children:[/*#__PURE__*/e(Ul,{children:[/*#__PURE__*/t(no,{}),"Passkey"]}),m.passkey?/*#__PURE__*/t(cm,{color:"green",children:"Enabled"}):/*#__PURE__*/t(Fl,{isAccent:!0,children:/*#__PURE__*/t(to,{})})]})}),m.passkey&&/*#__PURE__*/t(Dl,{style:{position:"absolute",right:0},onClick:()=>p("passkey"),children:/*#__PURE__*/t(co,{})})]},"passkey")]}),/*#__PURE__*/t(yt,{})]})};let cm=/*#__PURE__*/Ka(vt).withConfig({displayName:"StyledChip",componentId:"sc-998ca5bc-0"})(["margin-right:1.5rem;"]);const dm=({appName:e,onComplete:n,onClose:r,onReset:a})=>{let{user:o}=hr(),{data:l}=lr(),{initLinkWithPasskey:c,linkWithPasskey:d}=x(),{initEnrollmentWithPasskey:h,submitEnrollmentWithPasskey:u}=im(),[p,m]=s(!1),[y,g]=s(!1),[f,w]=s(!1),[v,C]=s(null),E=i((()=>o?.linkedAccounts.filter((e=>"passkey"===e.type))??[]),[o]),T=()=>{l?.mfaEnrollmentFlow?.onSuccess(),n()},b=async e=>{m(!0);try{await h(),await u({credentialIds:e},{removeForLogin:l?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa}),w(!0)}catch(e){C(e)}finally{m(!1)}},A=async()=>{g(!0),C(null);try{await c();let e=await d(),t=e?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];await b(t)}catch(e){C(e)}finally{g(!1)}};return 0===E.length||y?/*#__PURE__*/t(hm,{onReset:a,onClose:r,onClick:A,isCreating:y}):f?/*#__PURE__*/t(pm,{appName:e,onClick:T,onClose:T}):v?/*#__PURE__*/t(ch,{error:v,backFn:()=>C(null),onClick:()=>C(null)}):/*#__PURE__*/t(um,{passkeys:E,isSubmitting:p,isCreating:y,onReset:a,onClose:r,onSubmitEnrollment:()=>b(E.map((e=>e.credentialId))),onAddPasskey:A})};let hm=({onReset:r,onClose:a,onClick:i,isCreating:o})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{backFn:r,onClose:a},"header"),/*#__PURE__*/t(Il,{children:/*#__PURE__*/e(cu,{children:[/*#__PURE__*/t(iu,{}),/*#__PURE__*/t(ou,{})]})}),/*#__PURE__*/t(Nl,{children:"Set up passkey verification"}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(oo,{})}),"Verify with Touch ID, Face ID, PIN, or hardware key"]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ro,{})}),"Takes seconds to set up and use"]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(ho,{})}),"Use your passkey to verify transactions and login to your account"]})]}),/*#__PURE__*/t(st,{style:{marginTop:"2.25rem"},onClick:i,loading:o,children:"Add a new passkey"}),/*#__PURE__*/t(yt,{})]}),um=({onReset:r,onClose:a,onAddPasskey:i,onSubmitEnrollment:o,passkeys:l,isSubmitting:c,isCreating:d})=>{let[h,u]=s(!1),p=h?l.length:l.length>3?2:3;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:h?()=>u(!1):r,onClose:a},"header"),!h&&/*#__PURE__*/t(Il,{children:/*#__PURE__*/e(cu,{children:[/*#__PURE__*/t(iu,{}),/*#__PURE__*/t(ou,{})]})}),/*#__PURE__*/t(Nl,{children:"Enable your passkeys for verification"}),/*#__PURE__*/e(Rl,{children:[l.slice(0,p).map((n=>/*#__PURE__*/e(mm,{children:[/*#__PURE__*/t(ym,{children:fm(n)}),/*#__PURE__*/e(gm,{children:["Last used: ",n.latestVerifiedAt?.toLocaleString()]})]},n.credentialId))),!h&&l.length>3&&/*#__PURE__*/t(wm,{onClick:()=>u(!0),children:"View All"})]}),/*#__PURE__*/t(st,{style:{marginTop:"1.5rem"},onClick:o,loading:c,children:"Enable passkeys"}),l.length<5&&/*#__PURE__*/t(wm,{style:{marginTop:"0.5rem"},onClick:i,disabled:d,children:d?/*#__PURE__*/t(Ht,{style:{height:"1rem",width:"1rem",borderWidth:2}}):"Add new passkey"}),/*#__PURE__*/t(yt,{})]})},pm=({appName:r,onClick:a,onClose:i})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:i},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(Nl,{children:"Passkey verification added"}),/*#__PURE__*/e(xl,{children:["From now on, you'll use the passkey whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:a,children:"Done"})}),/*#__PURE__*/t(yt,{})]}),mm=/*#__PURE__*/Ka.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%;}"]),ym=/*#__PURE__*/Ka.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);"]),gm=/*#__PURE__*/Ka.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);"]),fm=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 wm=/*#__PURE__*/Ka.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;}}"]);let vm=Array(6).fill("");var Cm,Em=((Cm=Em||{})[Cm.RESET_AFTER_DELAY=0]="RESET_AFTER_DELAY",Cm[Cm.CLEAR_ON_NEXT_VALID_INPUT=1]="CLEAR_ON_NEXT_VALID_INPUT",Cm);function Tm(e){return/^[0-9]{1}$/.test(e)}function bm(e){return 6===e.length&&e.every(Tm)}const Am=({onChange:r,disabled:a,errorReasonOverride:i,success:o})=>{let[l,c]=s(vm),[d,h]=s(null),[u,p]=s(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(Tm(t))),0),a=t.split(""),i=!a.every(Tm),o=a.length+n>6;if(i)return h("Passcode can only be numbers"),void p(1);if(o)return h("Passcode must be exactly 6 numbers"),void p(1);h(null),p(null);let s=Number(e.currentTarget.name?.charAt(4)),d=[...t||[""]].slice(0,6-s),u=[...l.slice(0,s),...d,...l.slice(s+d.length)];c(u);let m=Math.min(Math.max(s+d.length,0),5),y=document.querySelector(`input[name=pin-${m}]`);if(y?.focus(),bm(u))try{await r(u.join(""));let e=document.querySelector(`input[name=pin-${m}]`);e?.blur()}catch(e){p(1),h(e.message)}else try{await r(null)}catch(e){p(1),h(e.message)}},g=o?"success":!(!i&&!d)?"fail":"";/*#__PURE__*/return t(n,{children:/*#__PURE__*/e(_m,{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===u&&(h(null),p(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()}bm(t)?r(t.join("")):r(null)})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:g,autoComplete:y?"one-time-code":"off",disabled:a},n)))}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(km,{$fail:!!i||!!d,children:i||d})})]})})};let _m=/*#__PURE__*/Ka.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);}}"]),km=/*#__PURE__*/Ka.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 Im=({appName:r,onComplete:a,onReset:i,onClose:o})=>{let[l,c]=s(""),[d,h]=s(!1),[u,p]=s(null),[m,y]=s("enroll"),{initEnrollmentWithSms:g,submitEnrollmentWithSms:f}=im(),{app:w,data:v}=lr();function C(){v?.mfaEnrollmentFlow?.onSuccess(),a()}return u?/*#__PURE__*/t(ch,{error:u,backFn:()=>p(null),onClick:()=>p(null)}):/*#__PURE__*/e(n,"enroll"===m?{children:[/*#__PURE__*/t(ot,{backFn:i,onClose:o},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oi,{})}),/*#__PURE__*/t(Nl,{children:"Set up SMS verification"}),/*#__PURE__*/e(xl,{children:["We'll text a verification code to this mobile device whenever you use your ",r," ","wallet."]}),/*#__PURE__*/e(Sl,{children:[/*#__PURE__*/t(Dp,{onSubmit:async function({qualifiedPhoneNumber:e}){try{await g({phoneNumber:e}),c(e),y("verify")}catch(e){p(e)}},hideRecent:!0}),/*#__PURE__*/e(zl,{children:["By providing your mobile number, you agree to receive text messages from ",w?.name,". Some carrier charges may apply"]})]}),/*#__PURE__*/t(yt,{})]}:d?{children:[/*#__PURE__*/t(ot,{onClose:C},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(Nl,{children:"SMS verification added"}),/*#__PURE__*/e(xl,{children:["From now on, you'll enter the verification code sent to your mobile device whenever you use your ",r," wallet."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:C,children:"Done"})}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{backFn:function(){"verify"===m?y("enroll"):i()},onClose:o},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oi,{})}),/*#__PURE__*/t(Nl,{children:"Enter enrollment code"}),/*#__PURE__*/e(Sl,{children:[/*#__PURE__*/t(Am,{onChange:async function(e){try{if(!e)return;await f({phoneNumber:l,mfaCode:e}),h(!0)}catch(e){if(Kc(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Gc(e))throw Error("The code you entered is not valid");if(jc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw Yc(e)?Error("Verification canceled"):Error("Unknown error")}}}),/*#__PURE__*/e(xl,{children:["To continue, enter the 6-digit code sent to ",/*#__PURE__*/t("strong",{children:Fi(l)})]})]}),/*#__PURE__*/t(yt,{})]})},Nm=({size:e,authUrl:n})=>/*#__PURE__*/t(zt,{url:n,squareLogoElement:uo,size:e,fgColor:"#1F1F1F"}),xm=({onComplete:r,onClose:a,onReset:i,totpInfo:o})=>{let[l,c]=s("enroll"),[d,h]=s(!1),{submitEnrollmentWithTotp:u}=im(),{data:p}=lr();function m(){p?.mfaEnrollmentFlow?.onSuccess(),r()}/*#__PURE__*/return e(n,"enroll"===l?{children:[/*#__PURE__*/t(ot,{backFn:i,onClose:a},"header"),/*#__PURE__*/t(Nl,{children:"Scan QR code"}),/*#__PURE__*/t(xl,{children:"Open your authenticator app and scan the QR code to continue."}),/*#__PURE__*/t(Bt,{children:/*#__PURE__*/t(Nm,{authUrl:o.authUrl,size:200})}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(Ft,{children:/*#__PURE__*/t(mh,{itemName:"setup key",text:o.secret})}),/*#__PURE__*/t(st,{onClick:function(){c("verify")},children:"Continue"})]}),/*#__PURE__*/t(yt,{})]}:d?{children:[/*#__PURE__*/t(ot,{onClose:m},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(Nl,{children:"Authenticator app verification added"}),/*#__PURE__*/e(xl,{children:["From now on, you'll enter the verification code generated by your authenticator app whenever you use your ",o.appName," wallet."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:m,children:"Done"})}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{backFn:function(){"verify"===l?c("enroll"):i()},onClose:a},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(lo,{})}),/*#__PURE__*/t(Nl,{children:"Enter enrollment code"}),/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(Am,{onChange:async function(e){try{if(!e)return;await u({mfaCode:e}),h(!0)}catch(e){if(Kc(e))throw Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.");if(Gc(e))throw Error("The code you entered is not valid");if(jc(e))throw Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.");throw Yc(e)?Error("Verification canceled"):Error("Unknown error")}}})}),/*#__PURE__*/e(xl,{children:["To continue, enter the 6-digit code generated from your ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),/*#__PURE__*/t(yt,{})]})},Sm=({label:n,children:r,valueStyles:a})=>/*#__PURE__*/e(Rm,{children:[/*#__PURE__*/t("div",{children:n}),/*#__PURE__*/t(Om,{style:{...a},children:r})]});let Rm=/*#__PURE__*/Ka.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;}"]),Om=/*#__PURE__*/Ka.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;"]);const Wm=({weiQuantities:e,tokenPrice:n,tokenSymbol:r})=>{let a=rn(e),i=n?tn(a,n):void 0,o=Yt(a,r);/*#__PURE__*/return t(Lm,{children:i||o})},Mm=({weiQuantities:r,tokenPrice:a,tokenSymbol:i})=>{let o=rn(r),s=a?tn(o,a):void 0,l=Yt(o,i);/*#__PURE__*/return t(Lm,{children:s?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Dm,{children:"USD"}),"<$0.01"===s?
8
+ /*#__PURE__*/e(Fm,{children:[/*#__PURE__*/t(Um,{children:"<"}),"$0.01"]}):s]}):l})},Pm=({quantities:r,tokenPrice:a,tokenSymbol:i="SOL",tokenDecimals:o=9})=>{let s=r.reduce(((e,t)=>e+t),0n),l=a&&"SOL"===i&&9===o?Lh(s,a):void 0,c="SOL"===i&&9===o?Ph(s):`${Ra(s,o)} ${i}`;/*#__PURE__*/return t(Lm,{children:l?/*#__PURE__*/t(n,{children:"<$0.01"===l?
9
+ /*#__PURE__*/e(Fm,{children:[/*#__PURE__*/t(Um,{children:"<"}),"$0.01"]}):l}):c})};let Lm=/*#__PURE__*/Ka.span.withConfig({displayName:"StyledPriceDisplay",componentId:"sc-596cd423-0"})(["font-size:14px;line-height:140%;display:flex;gap:4px;align-items:center;"]),Dm=/*#__PURE__*/Ka.span.withConfig({displayName:"StyledPriceUnit",componentId:"sc-596cd423-1"})(["font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);"]),Um=/*#__PURE__*/Ka.span.withConfig({displayName:"TinyLessThan",componentId:"sc-596cd423-2"})(["font-size:10px;"]),Fm=/*#__PURE__*/Ka.span.withConfig({displayName:"FlexCenter",componentId:"sc-596cd423-3"})(["display:flex;align-items:center;"]);const Bm=({gas:n,tokenPrice:r,tokenSymbol:a})=>/*#__PURE__*/e(sn,{style:{paddingBottom:"12px"},children:[/*#__PURE__*/e(Hm,{children:[/*#__PURE__*/t($m,{children:"Est. Fees"}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Mm,{weiQuantities:[BigInt(n)],tokenPrice:r,tokenSymbol:a})})]}),r&&/*#__PURE__*/t(Vm,{children:`${Yt(BigInt(n),a)}`})]}),zm=({value:n,gas:r,tokenPrice:a,tokenSymbol:i})=>{let o=BigInt(n??0)+BigInt(r);/*#__PURE__*/return e(sn,{children:[/*#__PURE__*/e(Hm,{children:[/*#__PURE__*/t($m,{children:"Total (including fees)"}),/*#__PURE__*/t("div",{children:/*#__PURE__*/t(Mm,{weiQuantities:[BigInt(n||0),BigInt(r)],tokenPrice:a,tokenSymbol:i})})]}),a&&/*#__PURE__*/t(Vm,{children:Yt(o,i)})]})};let Hm=/*#__PURE__*/Ka.div.withConfig({displayName:"TransactionTotalRow",componentId:"sc-f8ef9b74-0"})(["display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding-top:4px;"]),Vm=/*#__PURE__*/Ka.div.withConfig({displayName:"ValueConversionRow",componentId:"sc-f8ef9b74-1"})(["display:flex;flex-direction:row;height:12px;font-size:12px;line-height:12px;color:var(--privy-color-foreground-3);font-weight:400;"]),$m=/*#__PURE__*/Ka.div.withConfig({displayName:"TotalText",componentId:"sc-f8ef9b74-2"})(["font-size:14px;line-height:22.4px;font-weight:400;"]);const jm=/*#__PURE__*/p(void 0),Gm=/*#__PURE__*/p(void 0),qm=({defaultValue:e,children:n})=>{let[r,a]=s(e||null);/*#__PURE__*/return t(jm.Provider,{value:{activePanel:r,togglePanel:e=>{a(r===e?null:e)}},children:/*#__PURE__*/t(Qm,{children:n})})},Km=({value:e,children:n})=>{let{activePanel:r,togglePanel:a}=u(jm),i=r===e;/*#__PURE__*/return t(Gm.Provider,{value:{onToggle:()=>a(e),value:e},children:/*#__PURE__*/t(ny,{isActive:i,"data-open":i,children:n})})},Ym=({children:r})=>{let{activePanel:a}=u(jm),{onToggle:i,value:o}=u(Gm),s=a===o;/*#__PURE__*/
10
+ return e(n,{children:[/*#__PURE__*/e(Xm,{onClick:i,"data-open":s,children:[/*#__PURE__*/t(ty,{children:r}),/*#__PURE__*/t(iy,{isactive:s,children:/*#__PURE__*/t(Zi,{height:"16px",width:"16px",strokeWidth:"2"})})]}),/*#__PURE__*/t(ey,{})]})},Zm=({children:e})=>{let{activePanel:n}=u(jm),{value:r}=u(Gm);/*#__PURE__*/return t(ry,{"data-open":n===r,children:/*#__PURE__*/t(ay,{children:e})})},Jm=({children:e})=>{let{activePanel:n}=u(jm),{value:r}=u(Gm);/*#__PURE__*/return t(ay,{children:"function"==typeof e?e({isActive:n===r}):e})};let Qm=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionRoot",componentId:"sc-281bf545-0"})(["display:flex;flex-direction:column;width:100%;gap:8px;"]),Xm=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionTriggerContainer",componentId:"sc-281bf545-1"})(["display:flex;justify-content:space-between;align-items:center;width:100%;cursor:pointer;padding-bottom:8px;"]),ey=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionDivider",componentId:"sc-281bf545-2"})(["width:100%;&&{border-top:1px solid;border-color:var(--privy-color-foreground-4);}padding-bottom:12px;"]),ty=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-281bf545-3"})(["font-size:14px;font-weight:500;line-height:19.6px;width:100%;padding-right:8px;"]),ny=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionPanelContainer",componentId:"sc-281bf545-4"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;padding:12px;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),ry=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionContentContainer",componentId:"sc-281bf545-5"})(["position:relative;overflow:hidden;transition:max-height 25ms ease-out;&[data-open='true']{max-height:700px;}&[data-open='false']{max-height:0;}"]),ay=/*#__PURE__*/Ka.div.withConfig({displayName:"ContentWrapper",componentId:"sc-281bf545-6"})(["display:flex;flex-direction:column;gap:12px;flex:1 1 auto;min-height:1px;"]),iy=/*#__PURE__*/Ka.div.withConfig({displayName:"IconWrapper",componentId:"sc-281bf545-7"})(["transform:",";"],(e=>e.isactive?"rotate(180deg)":"rotate(0deg)"));const oy=({walletAddress:e,chainId:n=Cr,network:r,rpcEndpoint:a})=>/*#__PURE__*/t(sy,{href:"ethereum"===r?wn(n,e):Mr(e,Er(a||"")),target:"_blank",children:Ct(e)});let sy=/*#__PURE__*/Ka.a.withConfig({displayName:"StyledLink",componentId:"sc-adda23e5-0"})(["&:hover{text-decoration:underline;}"]);const ly=({from:n,to:r,txn:a,transactionInfo:i,tokenPrice:o,gas:s,tokenSymbol:l})=>{let c=BigInt(a?.value||0);/*#__PURE__*/
11
+ return t(qm,{...dr().render.standalone?{defaultValue:"details"}:{},children:/*#__PURE__*/e(Km,{value:"details",children:[/*#__PURE__*/t(Ym,{children:/*#__PURE__*/e(cy,{children:[/*#__PURE__*/t("div",{children:i?.title||"Details"}),/*#__PURE__*/t(dy,{children:/*#__PURE__*/t(Wm,{weiQuantities:[c],tokenPrice:o,tokenSymbol:l})})]})}),/*#__PURE__*/e(Zm,{children:[/*#__PURE__*/t(Sm,{label:"From",children:/*#__PURE__*/t(oy,{walletAddress:n,chainId:a.chainId||Cr,network:"ethereum"})}),/*#__PURE__*/t(Sm,{label:"To",children:/*#__PURE__*/t(oy,{walletAddress:r,chainId:a.chainId||Cr,network:"ethereum"})}),i&&i.action&&/*#__PURE__*/t(Sm,{label:"Action",children:i.action}),s&&/*#__PURE__*/t(Bm,{value:a.value,gas:s,tokenPrice:o,tokenSymbol:l})]}),/*#__PURE__*/t(Jm,{children:({isActive:e})=>/*#__PURE__*/t(zm,{value:a.value,displayFee:e,gas:s||"0x0",tokenPrice:o,tokenSymbol:l})})]})})};let cy=/*#__PURE__*/Ka.div.withConfig({displayName:"AccordionTriggerContent",componentId:"sc-29499c17-0"})(["display:flex;flex-direction:row;justify-content:space-between;"]),dy=/*#__PURE__*/Ka.div.withConfig({displayName:"TotalText",componentId:"sc-29499c17-1"})(["flex-shrink:0;padding-left:8px;"]);async function hy(e,t,n){let r=ys(e),a=await t.prepareTransactionRequest({...r,account:{address:n,type:"json-rpc"}});return{...a,type:ps[a.type]}}const uy=({pendingTransaction:e})=>{let{getAccessToken:n}=hr(),{wallets:r}=Tr(),{walletProxy:a,rpcConfig:l,chains:c,appId:d,nativeTokenSymbolForChainId:h}=x(),[u,p]=s(null),[m,y]=s(e),{tokenPrice:g}=Oh(m.chainId),f=h(e.chainId)||"ETH",w=i((()=>r.find((e=>"privy"===e.walletClientType))),[r]);return o((()=>{(async function(){if(!await n()||!a||!w)return m;let e=Ha(m.chainId,c,l,{appId:d}),t=await hy(m,e,w.address);return p(_a(BigInt(t.gas??0))),t})().then(y).catch(console.error)}),[a]),w?/*#__PURE__*/t(py,{children:/*#__PURE__*/t(ly,{from:w.address,to:m.to,txn:m,gas:u??void 0,tokenPrice:g,tokenSymbol:f})}):null};let py=/*#__PURE__*/Ka.div.withConfig({displayName:"TransactionInfoWrapper",componentId:"sc-731f1950-0"})(["width:100%;padding:1rem 0;"]);const my=({hasBlockingError:r,error:a,onClose:i,onBack:o,handleSubmit:s,account:l,submitSuccess:c})=>{let{pendingTransaction:d}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:i},"header"),/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:c,fail:!!a}),/*#__PURE__*/t(a?Qa:iu,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/t(Nl,{style:{marginTop:"1rem"},children:"Verifying with passkey"}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(oo,{})}),"Approve this action using your touch, face, PIN, or hardware key."]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(po,{})}),"You last added a passkey on"," ",l?.firstVerifiedAt?.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}),"."]})]}),d&&/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(uy,{pendingTransaction:d})}),a&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t($l,{style:{marginTop:"1.25rem"},children:a.message}),/*#__PURE__*/t(st,{disabled:r,onClick:s,style:{marginTop:"1.25rem"},children:"Try again"})]}),o&&/*#__PURE__*/t(Hl,{style:{marginTop:"1rem"},onClick:o,children:"Choose another method"}),/*#__PURE__*/t(yt,{})]})},yy=({open:r,onClose:a})=>{let{user:i}=hr(),[c,d]=s(i?.mfaMethods[0]??null),{init:h,cancel:u,submit:p}=am(),[m,y]=s(!1),[g,f]=s(!1),[w,v]=s(null),[C,E]=s(null);o((()=>{d(i?.mfaMethods[0]??null)}),[i?.mfaMethods]);let T=l(!1);o((()=>{!T.current&&c&&r&&(T.current=!0,_(c).finally((()=>{T.current=!1})))}),[r]);let b=e=>qc(e)?(y(!0),Error("You have exceeded the maximum number of attempts. Please close this window and try again in 10 seconds.")):Gc(e)?(y(!1),Error("The code you entered is not valid")):jc(e)?(y(!0),Error("You have exceeded the time limit for code entry. Please try again in 30 seconds.")):(console.error(e),y(!1),Error("Something went wrong."));async function A(e){E(null);try{if(!e||!c)return;await p(c,e),f(!0),y(!1),a()}catch(e){throw b(e)}}async function _(e){if("passkey"!==e)try{d(e),await h(e)}catch(e){console.error(e)}else try{d(e);let t=await h(e);if(!t)throw Error("something went wrong");v(t),await p(e,t),f(!0),y(!1),a()}catch(e){E(b(e))}}let k=()=>{d(null),E(null),u(),a()};return r&&i?"passkey"===c?/*#__PURE__*/t(my,{account:i.linkedAccounts.filter((e=>"passkey"===e.type&&e.enrolledInMfa)).sort(((e,t)=>t.firstVerifiedAt.valueOf()-e.firstVerifiedAt.valueOf()))[0],selectedMethod:c,submitSuccess:g,hasBlockingError:m,error:C,onClose:k,onBack:()=>{d(null),E(null)},handleSubmit:()=>A(w).catch(E)}):c?/*#__PURE__*/t(gy,{submitSuccess:g,hasBlockingError:m,handleSubmitCode:A,selectedMethod:c,onClose:k,onBack:i.mfaMethods.length>1?()=>d(null):void 0}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:k},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(Nl,{children:"Verify your identity"}),/*#__PURE__*/t(xl,{children:"Choose a verification method"}),/*#__PURE__*/e(Pl,{children:[i.mfaMethods.includes("totp")&&/*#__PURE__*/e(il,{onClick:()=>_("totp"),children:[/*#__PURE__*/t(lo,{}),"Authenticator App"]},"totp"),i.mfaMethods.includes("sms")&&/*#__PURE__*/e(il,{onClick:()=>_("sms"),children:[/*#__PURE__*/t(oi,{}),"SMS"]},"sms"),i.mfaMethods.includes("passkey")&&/*#__PURE__*/e(il,{onClick:()=>_("passkey"),children:[/*#__PURE__*/t(no,{}),"Passkey"]},"passkey")]}),/*#__PURE__*/t(yt,{})]}):null};let gy=({selectedMethod:r,submitSuccess:a,hasBlockingError:i,onClose:o,onBack:s,handleSubmitCode:l})=>{let{app:c}=lr(),{pendingTransaction:d}=x();switch(r){case"sms":/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:o},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oi,{})}),/*#__PURE__*/t(Nl,{children:"Enter verification code"}),/*#__PURE__*/e(Sl,{children:[/*#__PURE__*/t(Am,{success:a,disabled:i,onChange:l}),/*#__PURE__*/e(xl,{children:["To continue, please enter the 6-digit code sent to your ",/*#__PURE__*/t("strong",{children:"mobile device"})]}),d&&/*#__PURE__*/t(uy,{pendingTransaction:d})]}),s&&/*#__PURE__*/t(Hl,{theme:c?.appearance.palette.colorScheme,onClick:s,children:"Choose another method"}),/*#__PURE__*/t(dt,{onClick:o,children:"Not now"}),/*#__PURE__*/t(yt,{})]});case"totp":/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:o},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(lo,{})}),/*#__PURE__*/t(Nl,{children:"Enter verification code"}),/*#__PURE__*/e(Sl,{children:[/*#__PURE__*/t(Am,{success:a,disabled:i,onChange:l}),/*#__PURE__*/e(xl,{children:["To continue, please enter the 6-digit code generated from your"," ",/*#__PURE__*/t("strong",{children:"authenticator app"})]}),d&&/*#__PURE__*/t(uy,{pendingTransaction:d})]}),s&&/*#__PURE__*/t(Hl,{theme:c?.appearance.palette.colorScheme,onClick:s,children:"Choose another method"}),/*#__PURE__*/t(dt,{onClick:o,children:"Not now"}),/*#__PURE__*/t(yt,{})]});default:return null}};let fy=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-f0dc8bc7-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const wy=/*#__PURE__*/Ka.div.withConfig({displayName:"DoubleIconWrapper",componentId:"sc-fd7f30b7-0"})(["display:flex;align-items:center;justify-content:center;width:180px;height:90px;border-radius:50%;svg + svg{margin-left:12px;}> svg{z-index:2;color:var(--privy-color-accent);stroke:var(--privy-color-accent);fill:var(--privy-color-accent);}"]);let vy=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-d3724da1-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;"]);const Cy=/*#__PURE__*/Ka.div.withConfig({displayName:"Header",componentId:"sc-858d1103-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin:20px 0;gap:4px;& 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;}"]);let Ey=/*#__PURE__*/Ka.div.withConfig({displayName:"Content",componentId:"sc-858d1103-1"})(["display:flex;flex-direction:column;justify-content:space-between;"]),Ty=/*#__PURE__*/Ka.div.withConfig({displayName:"ErrorMessage",componentId:"sc-858d1103-2"})(["line-height:20px;height:20px;font-size:13px;color:var(--privy-color-error);text-align:left;margin-top:0.5rem;"]),by=/*#__PURE__*/Ka(st).withConfig({displayName:"NoAnimationPrimaryButton",componentId:"sc-858d1103-3"})(["",""],(e=>e.hideAnimations&&/*#__PURE__*/Ya(["&&{transition:none;}"])));const Ay=n=>/*#__PURE__*/e("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 21 20",...n,children:[/*#__PURE__*/t("path",{fill:"url(#icloud-gradient)",d:"M12.34 7.315a4.26 4.26 0 0 0-3.707 2.18 2.336 2.336 0 0 0-1.02-.236 2.336 2.336 0 0 0-2.3 1.963 3.217 3.217 0 0 0 1.244 6.181c.135-.001.27-.01.404-.029h8.943c.047.004.094.006.141.007.045-.001.09-.004.135-.007h.214v-.016a2.99 2.99 0 0 0 1.887-.988c.487-.55.757-1.261.757-1.998v-.006a3.017 3.017 0 0 0-.69-1.915 2.992 2.992 0 0 0-1.748-1.034 4.26 4.26 0 0 0-4.26-4.102Z"}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/e("linearGradient",{id:"icloud-gradient",x1:19.086,x2:3.333,y1:14.38,y2:14.163,gradientUnits:"userSpaceOnUse",children:[/*#__PURE__*/t("stop",{stopColor:"#3E82F4"}),/*#__PURE__*/t("stop",{offset:1,stopColor:"#93DCF7"})]})})]}),_y=({style:n,...r})=>/*#__PURE__*/e("svg",{width:"16",height:"14",style:n,viewBox:"0 0 16 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:[/*#__PURE__*/e("g",{clipPath:"url(#clip0_2115_829)",children:[/*#__PURE__*/t("path",{d:"M2.34709 12.9404L2.3471 12.9404L2.34565 12.938L1.64031 11.7448L1.64004 11.7444L0.651257 10.0677C0.640723 10.0496 0.630746 10.0314 0.621325 10.0129H4.16461L2.39424 13.0139C2.3775 12.9901 2.36178 12.9656 2.34709 12.9404Z",fill:"#0066DA",stroke:"#6366F1"}),/*#__PURE__*/t("path",{d:"M8 4.48713L5.47995 0.215332C5.23253 0.358922 5.02176 0.556358 4.87514 0.80764L0.219931 8.70508C0.076007 8.95094 0.000191627 9.22937 0 9.51277H5.04009L8 4.48713Z",fill:"#00AC47"}),/*#__PURE__*/t("path",{d:"M13.48 13.7847C13.7274 13.6411 13.9382 13.4437 14.0848 13.1924L14.3781 12.6988L15.7801 10.3206C15.9267 10.0693 16.0001 9.79114 16.0001 9.51294H10.9596L12.0321 11.577L13.48 13.7847Z",fill:"#EA4335"}),/*#__PURE__*/t("path",{d:"M8.00003 4.48718L10.5201 0.215385C10.2726 0.0717949 9.98857 0 9.69533 0H6.30472C6.01148 0 5.7274 0.0807692 5.47998 0.215385L8.00003 4.48718Z",fill:"#00832D"}),/*#__PURE__*/t("path",{d:"M10.9599 9.51294H5.04007L2.52002 13.7847C2.76744 13.9283 3.05152 14.0001 3.34476 14.0001H12.6552C12.9484 14.0001 13.2325 13.9194 13.4799 13.7847L10.9599 9.51294Z",fill:"#2684FC"}),/*#__PURE__*/t("path",{d:"M13.4525 4.75636L11.1249 0.80764C10.9782 0.556358 10.7675 0.358922 10.52 0.215332L8 4.48713L10.9599 9.51277H15.9908C15.9908 9.23456 15.9175 8.95636 15.7709 8.70508L13.4525 4.75636Z",fill:"#FFBA00"})]}),/*#__PURE__*/t("defs",{children:/*#__PURE__*/t("clipPath",{id:"clip0_2115_829",children:/*#__PURE__*/t("rect",{width:"16",height:"14",fill:"white"})})})]}),ky=/*#__PURE__*/Ka.div.withConfig({displayName:"RecoveryContainer",componentId:"sc-12b46968-0"})(["display:flex;flex-direction:column;gap:12px;padding-top:24px;padding-bottom:24px;"]),Iy=/*#__PURE__*/Ka.div.withConfig({displayName:"RecoveryExplainerContainer",componentId:"sc-12b46968-1"})(["padding-bottom:24px;"]);let Ny={"google-drive":{name:"Google Drive",component:_y},icloud:{name:"iCloud",component:Ay}};let xy=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-6716a2fa-0"})(["width:24px;height:24px;display:flex;justify-content:center;align-items:center;"]),Sy={"google-drive":"Google Drive",icloud:"iCloud","user-passcode":"password",privy:"Privy"},Ry=({onClose:r})=>/*#__PURE__*/e(Iy,{children:[/*#__PURE__*/t(Ql,{title:"Why do I need to secure my account?",icon:/*#__PURE__*/t(Ja,{width:48}),description:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t("p",{children:"Your app uses cryptography to secure your account. App secrets are split and encrypted so only you can access them."}),/*#__PURE__*/t("p",{children:"To use this app on new devices, secure account secrets using a password, your Google or your Apple account. It’s important you don’t lose access to the method you choose."})]})}),/*#__PURE__*/t(st,{onClick:r,children:"Select backup method"})]});const Oy=/*#__PURE__*/Ka.div.withConfig({displayName:"WithCircleBorder",componentId:"sc-e4fc5563-0"})(["&&{border-width:4px;}display:flex;justify-content:center;align-items:center;padding:1rem;aspect-ratio:1;border-style:solid;border-color:",";border-radius:50%;"],(e=>e.$color??"var(--privy-color-accent)"));async function Wy({tx:e,accessToken:t,walletProxy:n,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:i,transactingWalletIndex:o}){let s=function(e,t){let n=(Uh(e)?e.message:e.compileMessage()).staticAccountKeys.find((e=>e.toBase58()===t));if(!n)throw Error(`Transaction does not contain public key ${t}`);return n}(e,i),l=Uh(e)?Buffer.from(e.message.serialize()):e.serializeMessage(),{response:c}=await n.rpc({accessToken:t,entropyId:r,entropyIdVerifier:a,chainType:"solana",hdWalletIndex:o,request:{method:"signMessage",params:{message:l.toString("base64")}}}),d=c.data.signature,h=Buffer.from(d,"base64");e.addSignature(s,h)}async function My({tx:e,connection:t,accessToken:n,walletProxy:r,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:o,transactingWalletIndex:s,transactionOptions:l}){let c;try{await Wy({tx:e,accessToken:n,walletProxy:r,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:o,transactingWalletIndex:s});let d=e.serialize();c=await t.sendRawTransaction(d,l);let h=await t.confirmTransaction(c);if(h.value.err||h.value.err){let e=h.value.err||h.value.err;if("string"==typeof e)throw Error(e);throw e}return{signature:c,signedTransaction:e,receipt:await t.getParsedTransaction(c,{maxSupportedTransactionVersion:0})}}catch(e){throw e.txSignature=c,e}}const Py=/*#__PURE__*/Ka(jh).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 Ly=({iconUrl:n,value:r,symbol:a,usdValue:i,nftName:o,$isLoading:s})=>s?/*#__PURE__*/t(Dy,{$isLoading:s}):/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(Dy,{$isLoading:s,children:[n&&/*#__PURE__*/t(Fy,{src:n,alt:"Token icon"}),o,r," ",a]}),i&&/*#__PURE__*/e(Uy,{$isLoading:s,children:["$",i]})]});let Dy=/*#__PURE__*/Ka.span.withConfig({displayName:"Value",componentId:"sc-d8e62921-0"})(["color:var(--privy-color-foreground);font-size:0.875rem;font-weight:500;line-height:1.375rem;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],Vt);const Uy=/*#__PURE__*/Ka.span.withConfig({displayName:"Subvalue",componentId:"sc-d8e62921-1"})(["color:var(--privy-color-foreground-2);font-size:12px;font-weight:400;line-height:18px;word-break:break-all;text-align:right;display:flex;justify-content:flex-end;",""],Vt);let Fy=/*#__PURE__*/Ka.img.withConfig({displayName:"TokenIcon",componentId:"sc-d8e62921-2"})(["height:14px;width:14px;margin-right:4px;object-fit:contain;"]);const By=r=>{let{chain:a,transactionDetails:i,isTokenContractInfoLoading:o,symbol:s}=r,{action:l,functionName:c}=i;/*#__PURE__*/return t($t,{children:/*#__PURE__*/e(Qt,{children:["transaction"!==l&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Action"}),/*#__PURE__*/t(qh,{children:c})]}),"mint"===c&&"args"in i&&i.args.filter((e=>e)).map(((n,r)=>/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:`Param ${r}`}),/*#__PURE__*/t(qh,{children:"string"==typeof n&&Ma(n)?/*#__PURE__*/t(lt,{address:n,url:a?.blockExplorers?.default?.url,showCopyIcon:!1}):n?.toString()})]},r))),"setApprovalForAll"===c&&i.operator&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Operator"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:i.operator,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),"setApprovalForAll"===c&&void 0!==i.approved&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Set approval to"}),/*#__PURE__*/t(qh,{children:i.approved?"true":"false"})]}),"transfer"===c||"transferFrom"===c||"safeTransferFrom"===c||"approve"===c?/*#__PURE__*/e(n,{children:["formattedAmount"in i&&i.formattedAmount&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Amount"}),/*#__PURE__*/e(qh,{$isLoading:o,children:[i.formattedAmount," ",s]})]}),"tokenId"in i&&i.tokenId&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Token ID"}),/*#__PURE__*/t(qh,{children:i.tokenId.toString()})]})]}):null,"safeBatchTransferFrom"===c&&/*#__PURE__*/e(n,{children:["amounts"in i&&i.amounts&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Amounts"}),/*#__PURE__*/t(qh,{children:i.amounts.join(", ")})]}),"tokenIds"in i&&i.tokenIds&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Token IDs"}),/*#__PURE__*/t(qh,{children:i.tokenIds.join(", ")})]})]}),"approve"===c&&i.spender&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Spender"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:i.spender,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferFrom&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Transferring from"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:i.transferFrom,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),("transferFrom"===c||"safeTransferFrom"===c||"safeBatchTransferFrom"===c)&&i.transferTo&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Transferring to"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:i.transferTo,url:a?.blockExplorers?.default?.url,showCopyIcon:!1})})]})]})})};let zy={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 Hy=/*#__PURE__*/Ka.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=>zy[e.variant])),Vy=({variant:n,setPreventMaliciousTransaction:r,preventMaliciousTransaction:a})=>"warn"===n?/*#__PURE__*/t(Hy,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t($y,{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(Hy,{variant:n,children:/*#__PURE__*/e("div",{className:"flex flex-col",children:[/*#__PURE__*/e("div",{className:"flex flex-row",children:[/*#__PURE__*/t($y,{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(xd,{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 $y=/*#__PURE__*/Ka(Qa).withConfig({displayName:"StyledExclamationTriangleIcon",componentId:"sc-e6305f32-0"})(["width:20px;height:20px;stroke-width:2px;flex-shrink:0;display:inline-block;margin-right:8px;",";"],(e=>"error"===e.variant?"color: var(--privy-color-error)":"color: var(--privy-color-warn)"));const jy=({transactionIndex:e,maxIndex:t})=>"number"!=typeof e||0===t?"":` (${e+1} / ${t+1})`,Gy=({img:r,submitError:a,prepareError:i,onClose:o,action:l,title:c,subtitle:d,txValue:h,to:u,tokenAddress:p,network:m,missingFunds:y,fee:g,from:f,cta:w,disabled:v,chain:C,isSubmitting:E,isPreparing:T,isTokenPriceLoading:b,isTokenContractInfoLoading:A,isSponsored:_,symbol:k,balance:I,onClick:N,transactionDetails:x,transactionIndex:S,maxIndex:R,onBack:O,chainName:W,validation:M,hasScanDetails:P,setIsScanDetailsOpen:L,preventMaliciousTransaction:D,setPreventMaliciousTransaction:U,tokensSent:F,tokensReceived:B,isScanning:z,isCancellable:H})=>{let{showTransactionDetails:V,setShowTransactionDetails:$,hasMoreDetails:j,isErc20Ish:G}=(e=>{let[t,n]=s(!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}})(x),q=G&&A||T||b||z;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:o,backFn:O}),r&&/*#__PURE__*/t(Zy,{children:r}),/*#__PURE__*/e(St,{style:{marginTop:r?"1.5rem":0},children:[c,/*#__PURE__*/t(jy,{maxIndex:R,transactionIndex:S})]}),/*#__PURE__*/t(Rt,{children:d}),/*#__PURE__*/e(Qt,{style:{marginTop:"2rem"},children:[(!!F[0]||q)&&/*#__PURE__*/e(Kt,{children:[B.length>0?/*#__PURE__*/t(jh,{children:"Send"}):/*#__PURE__*/t(jh,{children:"Amount"}),/*#__PURE__*/t(Ly,{iconUrl:F[0]?.iconUrl,value:F[0]?.value,usdValue:F[0]?.usdValue,symbol:F[0]?.symbol,nftName:F[0]?.nftName,$isLoading:q})]}),B.length>0&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Receive"}),/*#__PURE__*/t("div",{className:"flex flex-col",children:B.map(((e,n)=>/*#__PURE__*/t(Ly,{iconUrl:e.iconUrl,value:e.value,usdValue:e.usdValue,symbol:e.symbol,nftName:e.nftName},n)))})]}),x&&"spender"in x&&x?.spender?/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Spender"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:x.spender,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}):null,u&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"To"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:u,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),p&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Token address"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:p,url:C?.blockExplorers?.default?.url,showCopyIcon:!1})})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Network"}),/*#__PURE__*/t(qh,{children:m})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Estimated fee"}),/*#__PURE__*/t(qh,{$isLoading:T||b||void 0===_,children:_?"Sponsored":g})]}),j&&!P&&/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Kt,{className:"cursor-pointer",onClick:()=>$(!V),children:/*#__PURE__*/e(Gh,{className:"flex items-center gap-x-1",children:["Details"," ",/*#__PURE__*/t(fo,{style:{width:"0.75rem",marginLeft:"0.25rem",transform:V?"rotate(180deg)":void 0}})]})}),V&&x&&/*#__PURE__*/t(By,{action:l,chain:C,transactionDetails:x,isTokenContractInfoLoading:A,symbol:k})]}),P&&/*#__PURE__*/t(Kt,{children:/*#__PURE__*/e(Py,{onClick:()=>L(!0),children:[/*#__PURE__*/t("span",{className:"text-color-primary",children:"Details"}),/*#__PURE__*/t(wo,{height:"14px",width:"14px",strokeWidth:"2"})]})})]}),/*#__PURE__*/t(Xs,{}),a?/*#__PURE__*/t(Zt,{style:{marginTop:"2rem"},children:a.message}):i?/*#__PURE__*/t(Zt,{style:{marginTop:"2rem"},children:i.shortMessage??Yy}):null,/*#__PURE__*/t(Vy,{variant:M,preventMaliciousTransaction:D,setPreventMaliciousTransaction:U}),/*#__PURE__*/t(Ky,{$useSmallMargins:!(!i&&!a&&"warn"!==M&&"error"!==M),title:Number(h)>0?void 0:!1!==_?"Your wallet":void 0,address:f,balance:I,isLoading:T||b,errMsg:T||i||a||!y?void 0:`Add funds on ${C?.name??W} to complete transaction.`}),/*#__PURE__*/t(st,{style:{marginTop:"1rem"},loading:E,disabled:v||T,onClick:N,children:w}),H&&/*#__PURE__*/t(mn,{style:{marginTop:"1rem"},onClick:o,isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(ct,{})]})},qy=({img:r,title:a,subtitle:i,cta:o,network:s,blockExplorerUrl:l,transactionIndex:c,maxIndex:d,isMissingFunds:h,submitError:u,parseError:p,total:m,amount:y,fee:g,balance:f,from:w,to:v,tokenAddress:C,tokenAccount:E,tokenAccountOwner:T,programAddress:b,transactingWalletAddress:A,disabled:_,isSubmitting:k,isPreparing:I,isTokenPriceLoading:N,onClick:x,onClose:S,onBack:R})=>{let O=I||N;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:S,backFn:R}),r&&/*#__PURE__*/t(Zy,{children:r}),/*#__PURE__*/e(St,{style:{marginTop:r?"1.5rem":0},children:[a,/*#__PURE__*/t(jy,{maxIndex:d,transactionIndex:c})]}),/*#__PURE__*/t(Rt,{children:i}),/*#__PURE__*/e(Qt,{style:{marginTop:"2rem"},children:[(m||O)&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Total"}),/*#__PURE__*/t(qh,{$isLoading:O,children:m})]}),w&&w!==A&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"From"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:w,url:l,showCopyIcon:!1})})]}),v&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"To"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:v,url:l,showCopyIcon:!1})})]}),T&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Token account owner"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:T,url:l,showCopyIcon:!1})})]}),E&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Token account"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:E,url:l,showCopyIcon:!1})})]}),C&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Token address"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:C,url:l,showCopyIcon:!1})})]}),b&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Program address"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(lt,{address:b,url:l,showCopyIcon:!1})})]}),s&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Network"}),/*#__PURE__*/t(qh,{children:s})]}),(y||O)&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Amount"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(qh,{$isLoading:O,children:y})})]}),(g||O)&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Estimated fee"}),/*#__PURE__*/t(qh,{$isLoading:O,children:g})]})]}),/*#__PURE__*/t(Xs,{}),u?/*#__PURE__*/t(Zt,{style:{marginTop:"2rem"},children:u.message}):p?/*#__PURE__*/t(Zt,{style:{marginTop:"2rem"},children:Yy}):null,/*#__PURE__*/t(Ky,{$useSmallMargins:!(!p&&!u),title:"Your wallet",address:A,balance:f,isLoading:I||N,errMsg:I||p||u||!h?void 0:"Add funds on Solana to complete transaction."}),/*#__PURE__*/t(st,{style:{marginTop:"1rem"},loading:k,disabled:_||I,onClick:x,children:o}),/*#__PURE__*/t(ct,{})]})};let Ky=/*#__PURE__*/Ka(Nt).withConfig({displayName:"StyledWalletInfoCard",componentId:"sc-4bd3bb7d-0"})(["",""],(e=>e.$useSmallMargins?"margin-top: 0.5rem;":"margin-top: 2rem;")),Yy="There was an error preparing your transaction. Your transaction request will likely fail.",Zy=/*#__PURE__*/Ka.div.withConfig({displayName:"ImageContainer",componentId:"sc-4bd3bb7d-1"})(["display:flex;width:100%;justify-content:center;max-height:40px;> img{object-fit:contain;border-radius:var(--privy-border-radius-sm);}"]),Jy=()=>/*#__PURE__*/e(ng,{children:[/*#__PURE__*/t(ag,{}),/*#__PURE__*/t(rg,{})]});const Qy=({transactionError:r,chainId:a,onClose:i,onRetry:o,network:l,connection:c,transactionHash:d})=>{let{chains:h}=x(),[u,p]=s(!1),{errorCode:m,errorMessage:y}=((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),g=(({chains:e,chainId:t,network:n,connection:r,transactionHash:a})=>"ethereum"===n?e.find((e=>e.id===t))?.blockExplorers?.default.url??"https://etherscan.io":Pr(a||"",Er(r?.rpcEndpoint||"")))({chains:h,chainId:a,network:l,connection:c,transactionHash:d});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:i}),/*#__PURE__*/e(Xy,{children:[/*#__PURE__*/t(Jy,{}),/*#__PURE__*/t(eg,{children:m}),/*#__PURE__*/t(tg,{children:"Please try again."}),/*#__PURE__*/e(sg,{children:[/*#__PURE__*/t(og,{children:"Error message"}),/*#__PURE__*/t(cg,{$clickable:!1,children:y})]}),d&&/*#__PURE__*/e(sg,{children:[/*#__PURE__*/t(og,{children:"Transaction hash"}),/*#__PURE__*/e(lg,{children:["Copy this hash to view details about the transaction on a"," ",/*#__PURE__*/t("u",{children:/*#__PURE__*/t("a",{href:g,children:"block explorer"})}),"."]}),/*#__PURE__*/e(cg,{$clickable:!0,onClick:async()=>{await navigator.clipboard.writeText(d),p(!0)},children:[d,/*#__PURE__*/t(ug,{clicked:u})]})]}),/*#__PURE__*/t(ig,{onClick:()=>o({resetNonce:!!d}),children:"Retry transaction"})]}),/*#__PURE__*/t(yt,{})]})};let Xy=/*#__PURE__*/Ka.div.withConfig({displayName:"TransactionErrorScreenContainer",componentId:"sc-6e9001c5-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;"]),eg=/*#__PURE__*/Ka.span.withConfig({displayName:"ErrorCode",componentId:"sc-6e9001c5-1"})(["color:var(--privy-color-foreground);text-align:center;font-size:1.125rem;font-weight:500;line-height:1.25rem;text-align:center;margin:10px;"]),tg=/*#__PURE__*/Ka.span.withConfig({displayName:"Subtitle",componentId:"sc-6e9001c5-2"})(["margin-top:4px;margin-bottom:10px;color:var(--privy-color-foreground-3);text-align:center;font-size:0.875rem;font-style:normal;font-weight:400;line-height:20px;letter-spacing:-0.008px;"]),ng=/*#__PURE__*/Ka.div.withConfig({displayName:"CircleContainer",componentId:"sc-6e9001c5-3"})(["position:relative;width:60px;height:60px;margin:10px;display:flex;justify-content:center;align-items:center;"]),rg=/*#__PURE__*/Ka(ei).withConfig({displayName:"StyledExclamationCircleIcon",componentId:"sc-6e9001c5-4"})(["position:absolute;width:35px;height:35px;color:var(--privy-color-error);"]),ag=/*#__PURE__*/Ka.div.withConfig({displayName:"StyledRedCircle",componentId:"sc-6e9001c5-5"})(["position:absolute;width:60px;height:60px;border-radius:50%;background-color:var(--privy-color-error);opacity:0.1;"]),ig=/*#__PURE__*/Ka(st).withConfig({displayName:"RetryButton",componentId:"sc-6e9001c5-6"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]),og=/*#__PURE__*/Ka.span.withConfig({displayName:"TextBoxTitle",componentId:"sc-6e9001c5-7"})(["width:100%;text-align:left;font-size:0.825rem;color:var(--privy-color-foreground);padding:4px;"]),sg=/*#__PURE__*/Ka.div.withConfig({displayName:"TextBoxContainer",componentId:"sc-6e9001c5-8"})(["width:100%;margin:5px;display:flex;flex-direction:column;justify-content:center;align-items:center;"]),lg=/*#__PURE__*/Ka.text.withConfig({displayName:"HelperText",componentId:"sc-6e9001c5-9"})(["position:relative;width:100%;padding:5px;font-size:0.8rem;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;"]),cg=/*#__PURE__*/Ka.span.withConfig({displayName:"TextBox",componentId:"sc-6e9001c5-10"})(["position:relative;width:100%;background-color:var(--privy-color-background-2);padding:8px 12px;border-radius:10px;margin-top:5px;font-size:14px;color:var(--privy-color-foreground-3);text-align:left;word-wrap:break-word;",""],(e=>e.$clickable&&"cursor: pointer;\n transition: background-color 0.3s;\n padding-right: 45px;\n\n &:hover {\n background-color: var(--privy-color-foreground-4);\n }")),dg=/*#__PURE__*/Ka(vo).withConfig({displayName:"StyledClipboardIcon",componentId:"sc-6e9001c5-11"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),hg=/*#__PURE__*/Ka(Ci).withConfig({displayName:"StyledClipboardCheckIcon",componentId:"sc-6e9001c5-12"})(["position:absolute;top:13px;right:13px;width:24px;height:24px;"]),ug=({clicked:e})=>/*#__PURE__*/t(e?hg:dg,{});const pg=({instructions:r,fees:a,transactionInfo:i,solPrice:o,rpcEndpoint:l})=>{let c=r.reduce(((e,{amount:t,token:n})=>t&&"SOL"===n?.symbol?e+t:e),0n),[d,h]=s(0),[u,p]=s(!1),m=r[d];/*#__PURE__*/return e(Qt,{children:[/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Total"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(Pm,{quantities:[c,a],tokenPrice:o})})]}),i&&i.action&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Action"}),/*#__PURE__*/t(qh,{children:i.action})]}),/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Fees"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(Pm,{quantities:[a||0n],tokenPrice:o})})]}),r.length>1?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Kt,{children:/*#__PURE__*/e(Py,{onClick:()=>p((e=>!e)),children:[/*#__PURE__*/t("span",{children:"Details"}),/*#__PURE__*/t(Zi,{height:"16px",width:"16px",strokeWidth:"2",style:{transition:"all 300ms",transform:u?"rotate(180deg)":void 0}})]})}),u&&/*#__PURE__*/t(Kt,{children:/*#__PURE__*/e(yg,{children:[/*#__PURE__*/e(gg,{children:[/*#__PURE__*/e(fg,{children:[d+1," of ",r.length," instructions"]}),/*#__PURE__*/e(vg,{children:[d>0&&/*#__PURE__*/t(Cn,{backFn:()=>h((e=>e-1))}),d<r.length-1&&/*#__PURE__*/t(En,{nextFn:()=>h((e=>e+1))})]})]}),/*#__PURE__*/t(wg,{children:/*#__PURE__*/t(mg,{instruction:m,rpcEndpoint:l,solPrice:o})})]})})]}):/*#__PURE__*/t(mg,{instruction:m,rpcEndpoint:l,solPrice:o,hideAmount:!0})]})};function mg({instruction:n,rpcEndpoint:r,solPrice:a,hideAmount:i}){return n?/*#__PURE__*/e(Qt,{children:[!i&&!!n.amount&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Amount"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(Pm,{quantities:[n.amount],tokenPrice:a,tokenSymbol:n.token?.symbol??"SOL",tokenDecimals:n.token?.decimals??9})})]}),n.to&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"To"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(oy,{walletAddress:n.to,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccount&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Token account"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(oy,{walletAddress:n.tokenAccount,rpcEndpoint:r,network:"solana"})})]}),n.tokenAccountOwner&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"Token account owner"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(oy,{walletAddress:n.tokenAccountOwner,rpcEndpoint:r,network:"solana"})})]}),n.from&&/*#__PURE__*/e(Kt,{children:[/*#__PURE__*/t(jh,{children:"From"}),/*#__PURE__*/t(qh,{children:/*#__PURE__*/t(oy,{walletAddress:n.from,rpcEndpoint:r,network:"solana"})})]})]}):null}let yg=/*#__PURE__*/Ka.div.withConfig({displayName:"InstructionsBox",componentId:"sc-5a140027-0"})(["display:flex;flex-direction:column;width:100%;overflow:hidden;&&{border:1px solid;border-color:var(--privy-color-foreground-4);border-radius:var(--privy-border-radius-md);}"]),gg=/*#__PURE__*/Ka.header.withConfig({displayName:"InstructionsBoxHeader",componentId:"sc-5a140027-1"})(["display:flex;justify-content:space-between;align-items:center;padding:12px;background-color:var(--privy-color-background-2);"]),fg=/*#__PURE__*/Ka.h4.withConfig({displayName:"HeaderTitle",componentId:"sc-5a140027-2"})(["font-size:14px;font-weight:500;line-height:19.6px;"]),wg=/*#__PURE__*/Ka.div.withConfig({displayName:"InstructionsBoxContent",componentId:"sc-5a140027-3"})(["padding:12px;"]),vg=/*#__PURE__*/Ka.div.withConfig({displayName:"NavigationButtonsConatiner",componentId:"sc-5a140027-4"})(["display:flex;gap:8px;align-items:center;"]);const Cg=({instructions:r,fees:a,onClose:i,receiptHeader:o,receiptDescription:s,transactionInfo:l,solPrice:c,rpcEndpoint:d,signOnly:h})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:i}),/*#__PURE__*/t(Qs,{style:{marginBottom:"16px"},children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Js,{color:"var(--privy-color-success-light)"}),/*#__PURE__*/t(ci,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-success)"})]})}),/*#__PURE__*/t(Ql,{title:o??`Transaction ${h?"signed":"complete"}!`,description:s??"You're all set."}),/*#__PURE__*/t(pg,{solPrice:c,instructions:r,fees:a,transactionInfo:l,rpcEndpoint:d}),/*#__PURE__*/t(Xs,{}),/*#__PURE__*/t(Eg,{loading:!1,onClick:i,children:"Close"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let Eg=/*#__PURE__*/Ka(st).withConfig({displayName:"SubmitButton",componentId:"sc-6f95cdcf-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);async function Tg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,publicClient:o,requesterAppId:s}){let l=await bg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,requesterAppId:s});return await o.sendRawTransaction({serializedTransaction:l})}async function bg({accessToken:e,entropyId:t,entropyIdVerifier:n,transactingWallet:r,walletProxy:a,transactionRequest:i,requesterAppId:o}){return(await a.rpc({entropyId:t,entropyIdVerifier:n,hdWalletIndex:r.walletIndex??0,chainType:"ethereum",accessToken:e,requesterAppId:o,request:{method:"eth_signTransaction",params:[i]}})).response.data}let Ag=({data:n})=>{let r=n=>"object"==typeof n&&null!==n?/*#__PURE__*/t(kg,{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 _g=/*#__PURE__*/Ka.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 kg=/*#__PURE__*/Ka.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 Ig=({data:e})=>/*#__PURE__*/t(_g,{children:/*#__PURE__*/t(Ag,{data:e})});let Ng=/*#__PURE__*/Ka.div.withConfig({displayName:"Container",componentId:"sc-b3a607dd-0"})(["display:flex;flex-direction:column;min-height:72px;"]);var xg=({onBack:n,details:r})=>/*#__PURE__*/e(Ng,{children:[/*#__PURE__*/t(ot,{backFn:n}),/*#__PURE__*/t(Ig,{data:r}),/*#__PURE__*/t(ct,{})]});let Sg=({gasUsed:e,effectiveGasPrice:t})=>{if(e&&t)try{return _a(e*t)}catch(e){return}};const Rg=({txn:r,receipt:a,transactionInfo:i,onClose:o,tokenPrice:s,tokenSymbol:l,receiptHeader:c,receiptDescription:d})=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:o}),/*#__PURE__*/t(Zl,{title:c??"Transaction complete!",description:d??"You're all set."}),/*#__PURE__*/t(ly,{tokenPrice:s,from:a.from,to:a.to,gas:Sg(a),txn:r,transactionInfo:i,tokenSymbol:l}),/*#__PURE__*/t(Xs,{}),/*#__PURE__*/t(Og,{loading:!1,onClick:o,children:"All Done"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let Og=/*#__PURE__*/Ka(st).withConfig({displayName:"SubmitButton",componentId:"sc-f857236b-0"})(["&&{margin-top:24px;}transition:color 350ms ease,background-color 350ms ease;"]);const Wg=[{constant:!1,inputs:[{name:"_salt",type:"bytes32"},{name:"_initializer",type:"bytes"}],name:"deployAccount",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Mg=[{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"}]}],Pg=[{constant:!1,inputs:[{name:"spender",type:"address"},{name:"value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Lg=[{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"}],Dg=[{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"}],Ug=[{constant:!1,inputs:[{name:"_operator",type:"address"},{name:"_approved",type:"bool"}],name:"setApprovalForAll",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],Fg=[{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"}],Bg=[{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"}],zg=[{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"}],Hg=(e,t)=>{let n=Vg(Pg,e);if(n)return{action:"approve",functionName:"approve",isErc20Ish:!0,isNFTIsh:!1,spender:n.args[0],amount:n.args[1]};let r=Vg(Uu,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=Vg(Wg,e);if(a&&"string"==typeof a.args[1]){let e=$g(a.args[1]);if(e&&e[4].encodedInitData)return Hg(e[4].encodedInitData,t)}let i=Vg(Ug,e);if(i)return{action:"approve",functionName:"setApprovalForAll",isNFTIsh:!0,isErc20Ish:!1,operator:i.args[0],approved:i.args[1]};let o=Vg(Fg,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=Vg(Dg,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=Vg(zg,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=Vg(Bg,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=Vg(Lg,e);return d?{action:"mint",functionName:d.functionName,isNFTIsh:!0,isErc20Ish:!1,args:d.args}:{action:"transaction",isErc20Ish:!1,isNFTIsh:!1}};let Vg=(e,t)=>{try{let n=Pa({abi:e,data:t});return{functionName:n.functionName,args:n.args||[]}}catch(e){return null}},$g=e=>{try{if("string"==typeof e)return La(Mg,`0x${e.slice(10)}`)}catch(e){return null}};const jg=(e,t,n)=>{let[r,a]=s(null),{getAccessToken:i}=hr(),{walletProxy:l}=x();return o((()=>{r&&a(null),(async()=>{if(!await i()||!l||!t)return null;let r=[],a=!0,o=await hy(e,n,t.address).catch((t=>(t.details.includes("insufficient funds")?a=!1:r.push(t),e)));return{tx:o,totalGasEstimate:o.gas,hasFunds:a,errors:r}})().then(a)}),[e]),r};let Gg=new ca(new da("There was an issue preparing your transaction",zi.E32603_DEFAULT_INTERNAL_ERROR.eipCode)),qg=(e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0;const Kg=/*#__PURE__*/Ka.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 Yg=e=>{if(!Aa(e))return e;try{return Ua(e)}catch{return e}},Zg=e=>JSON.stringify(e,null,2),Jg=r=>{let{types:a,primaryType:i,...o}=r.typedData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(Ig,{data:o}),/*#__PURE__*/t(mh,{text:Zg(r.typedData),itemName:"full payload to clipboard"})," "]})};let Qg=/*#__PURE__*/Ka.div.withConfig({displayName:"InputHelp",componentId:"sc-84af275e-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)")),Xg=/*#__PURE__*/Ka.span.withConfig({displayName:"ContentWithIcon",componentId:"sc-84af275e-1"})(["display:flex;align-items:center;gap:8px;"]),ef=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-84af275e-2"})(["display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:82px;"]),tf=/*#__PURE__*/Ka.div.withConfig({displayName:"Grow",componentId:"sc-84af275e-3"})(["flex-grow:1;"]);let nf=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-a512957a-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:27px;margin-right:27px;gap:24px;"]);const rf=/*#__PURE__*/h(((r,a)=>{let[i,o]=s(""),[l,c]=s(""),[d,h]=s(!1),{authenticated:u,user:p}=hr(),{initUpdateEmail:m}=x(),{navigate:y,setModalData:g,currentScreen:f}=lr(),{enabled:w,token:v}=it(),C=dr(),E=pn(i)&&(C.disablePlusEmails&&i.includes("+")?(l||c("Please enter a valid email address without a '+'."),!1):(l&&c(""),!0)),T=d||!E,b=()=>{!w||v||u?(async e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");h(!0);try{await m(p.email.address,i,e),y(cr.AWAITING_PASSWORDLESS_CODE)}catch(e){g({errorModalData:{error:e,previousScreen:f||cr.LANDING}})}h(!1)})(v):(g({captchaModalData:{callback:e=>{if(!p?.email)throw Error("User is required to have an email address to update it.");return m(p.email.address,i,e)},userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:cr.ERROR_SCREEN}}),y(cr.CAPTCHA_SCREEN))};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/e(af,{children:[l&&/*#__PURE__*/t(Zt,{style:{marginTop:"0.25rem",textAlign:"left"},children:l}),/*#__PURE__*/e(of,{$error:!!l,children:[/*#__PURE__*/t(ii,{}),/*#__PURE__*/t("input",{ref:a,id:"email-input",type:"email",placeholder:"your@email.com",onChange:e=>o(e.target.value),onKeyUp:e=>{"Enter"===e.key&&b()},value:i,autoComplete:"email"}),r.stacked?null:/*#__PURE__*/t(mn,{isSubmitting:d,onClick:b,disabled:T,children:"Submit"})]})]}),r.stacked?/*#__PURE__*/t(st,{loadingText:null,loading:d,disabled:T,onClick:b,children:"Submit"}):null]})}));let af=yn,of=bn;const sf=({style:e,...n})=>/*#__PURE__*/t("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"38px",width:"38px",...e},...n,children:/*#__PURE__*/t("path",{d:"M20 13.6V20M20 26.4H20.016M36 20C36 28.8365 28.8366 36 20 36C11.1635 36 4.00001 28.8365 4.00001 20C4.00001 11.1634 11.1635 3.99999 20 3.99999C28.8366 3.99999 36 11.1634 36 20Z",stroke:"currentColor",strokeWidth:"3.2",strokeLinecap:"round",strokeLinejoin:"round"})});let lf=/*#__PURE__*/Ka.div.withConfig({displayName:"ConnectContainer",componentId:"sc-fc448c87-0"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;width:100%;padding-top:8px;padding-bottom:32px;"]),cf=/*#__PURE__*/Ka.div.withConfig({displayName:"IconContainer",componentId:"sc-fc448c87-1"})(["display:flex;align-items:center;justify-content:center;height:72px;aspect-ratio:1;color:var(--privy-color-error);background-color:var(--privy-color-error-light);border-radius:50%;"]),df=/*#__PURE__*/Ka.div.withConfig({displayName:"GappedContainer",componentId:"sc-fc448c87-2"})(["display:flex;flex-direction:column;gap:8px;"]);const hf=/*#__PURE__*/Za([":root{--privy-border-radius-sm:6px;--privy-border-radius-md:12px;--privy-border-radius-mdlg:16px;--privy-border-radius-lg:24px;--privy-border-radius-full:9999px;--privy-color-background:",";--privy-color-background-2:",";--privy-color-background-3:",";--privy-color-foreground:",";--privy-color-foreground-2:",";--privy-color-foreground-3:",";--privy-color-foreground-4:",";--privy-color-foreground-accent:",";--privy-color-accent:",";--privy-color-accent-light:",";--privy-color-accent-lightest:",";--privy-color-accent-dark:",";--privy-color-accent-darkest:",";--privy-color-success:",";--privy-color-success-dark:",";--privy-color-success-light:",";--privy-color-error:",";--privy-color-error-light:",";--privy-color-warn:",";--privy-color-warn-light:",";--privy-height-modal-full:620px;--privy-height-modal-compact:480px;};"],(e=>e.theme.background),(e=>e.theme.background2),(e=>e.theme.background3),(e=>e.theme.foreground),(e=>e.theme.foreground2),(e=>e.theme.foreground3),(e=>e.theme.foreground4),(e=>e.theme.foregroundAccent),(e=>e.theme.accent),(e=>e.theme.accentLight),(e=>e.theme.accentLightest),(e=>e.theme.accentDark),(e=>e.theme.accentDarkest),(e=>e.theme.success),(e=>e.theme.successDark),(e=>e.theme.successLight),(e=>e.theme.error),(e=>e.theme.errorLight),(e=>e.theme.warn),(e=>e.theme.warnLight)),uf=/*#__PURE__*/Ka.div.withConfig({displayName:"StylesWrapper",componentId:"sc-bc1e45b4-0"})([""," color:var(--privy-color-foreground-2);h3{font-size:16px;line-height:24px;font-weight:500;color:var(--privy-color-foreground-2);}h4{font-size:14px;line-height:20px;font-weight:500;color:var(--privy-color-foreground);}p{font-size:13px;line-height:20px;color:var(--privy-color-foreground-2);}button:focus,input:focus,optgroup:focus,select:focus,textarea:focus{outline:none;border-color:var(--privy-color-accent-light);box-shadow:0 0 0 1px var(--privy-color-accent-light);}.mobile-only{@media (min-width:441px){display:none;}}@keyframes fadein{0%{opacity:0;}100%{opacity:1;}}"],"\n *,\n ::before,\n ::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n }\n\n line-height: 1.15;\n -webkit-text-size-adjust: 100%;\n -moz-tab-size: 4;\n tab-size: 4;\n font-feature-settings: normal;\n\n margin: 0;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n display: inline;\n }\n\n a {\n color: inherit;\n text-decoration: inherit;\n }\n\n b,\n strong {\n font-weight: bolder;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n font-family: inherit;\n font-size: 100%;\n font-weight: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n }\n\n button,\n select {\n text-transform: none;\n }\n\n button,\n [type='button'],\n [type='reset'],\n [type='submit'] {\n -webkit-appearance: button;\n background-color: transparent;\n background-image: none;\n }\n\n ::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n :-moz-focusring {\n outline: 1px dotted ButtonText;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n legend {\n padding: 0;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [type='search'] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n }\n\n summary {\n display: list-item;\n }\n\n blockquote,\n dl,\n dd,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n hr,\n figure,\n p,\n pre {\n margin: 0;\n }\n\n fieldset {\n margin: 0;\n padding: 0;\n }\n\n legend {\n padding: 0;\n }\n\n ol,\n ul,\n menu {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n textarea {\n resize: vertical;\n }\n\n input::placeholder,\n textarea::placeholder {\n opacity: 1;\n color: #9ca3af;\n }\n\n button,\n [role='button'] {\n cursor: pointer;\n }\n\n :disabled {\n cursor: default;\n }\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n }\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n [hidden] {\n display: none;\n }\n"),pf=({children:n,open:r,onClick:i,...o})=>/*#__PURE__*/t(Gi,{show:r,as:a.Fragment,children:/*#__PURE__*/e(qi,{onClose:i,...o,as:yf,children:[/*#__PURE__*/t(Ki,{as:a.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/t(mf,{id:"privy-dialog-backdrop","aria-hidden":"true"})}),/*#__PURE__*/t(gf,{children:/*#__PURE__*/t(Ki,{as:a.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/t(Yi,{as:ff,children:n})})})]})});let mf=/*#__PURE__*/Ka.div.withConfig({displayName:"Backdrop",componentId:"sc-3cfde0b5-0"})(["position:fixed;inset:0;transition:backdrop-filter 100ms ease;backdrop-filter:blur(3px);-webkit-backdrop-filter:blur(3px);&.entering,&.leaving{backdrop-filter:unset;-webkit-backdrop-filter:unset;}"]),yf=/*#__PURE__*/Ka.div.withConfig({displayName:"DialogWrapper",componentId:"sc-3cfde0b5-1"})(["position:relative;z-index:999999;"]),gf=/*#__PURE__*/Ka.div.withConfig({displayName:"DialogContainer",componentId:"sc-3cfde0b5-2"})(["position:fixed;inset:0;display:flex;align-items:center;justify-content:center;width:100vw;min-height:100vh;"]);const ff=/*#__PURE__*/Ka.div.withConfig({displayName:"Panel",componentId:"sc-3cfde0b5-3"})(["padding:0;background:transparent;border:none;width:100%;pointer-events:auto;outline:none;display:block;@media (max-width:440px){opacity:1;transform:translate3d(0,0,0);transition:transform 200ms ease-in;position:fixed;bottom:0;&.entering,&.leaving{opacity:0;transform:translate3d(0,100%,0);transition:transform 150ms ease-in 0ms,opacity 0ms ease 150ms;}}@media (min-width:441px){opacity:1;transition:opacity 100ms ease-in;&.entering,&.leaving{opacity:0;transition-delay:5ms;}margin:auto;width:360px;box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]),wf=/*#__PURE__*/Ka.div.withConfig({displayName:"CenterItem",componentId:"sc-3cfde0b5-4"})(["display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;"]);let vf={[cr.LANDING]:()=>{let{app:e}=lr();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/t(em,{connectOnly:!1}):/*#__PURE__*/t(Kp,{connectOnly:!1})},[cr.CONNECT_OR_CREATE]:()=>{let{app:e}=lr();return e.loginMethodsAndOrder&&e.loginMethodsAndOrder.primary.length>0?/*#__PURE__*/t(em,{connectOnly:!0}):/*#__PURE__*/t(Kp,{connectOnly:!0})},[cr.AWAITING_PASSWORDLESS_CODE]:()=>{let{app:r,navigate:a,lastScreen:i,navigateBack:l,setModalData:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),{closePrivyModal:h,resendEmailCode:u,resendSmsCode:p,getAuthMeta:m,loginWithCode:g,updateWallets:f,createAnalyticsEvent:w}=x(),{authenticated:v,logout:C,user:E}=hr(),[T,b]=s(tc),[_,k]=s(!1),[I,R]=s(null),[O,W]=s(null),[M,P]=s(0);d.current=()=>null;let L=m()?.email?0:1,D=ur-500;o((()=>{if(M){let e=setTimeout((()=>{P(M-1)}),1e3);return()=>clearTimeout(e)}}),[M]),o((()=>{if(v&&_&&E){if(r?.legal.requireUsersAcceptTerms&&!E.hasAcceptedTerms){let e=setTimeout((()=>{a(cr.AFFIRMATIVE_CONSENT_SCREEN)}),D);return()=>clearTimeout(e)}if(ht(E,r.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),w({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AwaitingPasswordlessCodeScreen"}}),C()},callAuthOnSuccessOnClose:!0}}),a(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),D);return()=>clearTimeout(e)}{f();let e=setTimeout((()=>h({shouldCallAuthOnSuccess:!0,isSuccess:!0})),ur);return()=>clearTimeout(e)}}}),[v,_,E]),o((()=>{if(I&&0===O){let e=setTimeout((()=>{b(tc),R(null);let e=document.querySelector("input[name=code-0]");e?.focus()}),1400);return()=>clearTimeout(e)}}),[I]);let U=e=>{e.preventDefault();let t=e.currentTarget.value.replace(" ","");if(""===t)return;if(isNaN(Number(t)))return R("Code should be numeric"),void W(1);R(null),W(null);let n=Number(e.currentTarget.name?.charAt(5)),r=[...t||[""]].slice(0,6-n),o=[...T.slice(0,n),...r,...T.slice(n+r.length)];b(o);let s=Math.min(Math.max(n+r.length,0),5);if(!isNaN(Number(e.currentTarget.value))){let e=document.querySelector(`input[name=code-${s}]`);e?.focus()}if(o.every((e=>e&&!isNaN(+e)))){let e=document.querySelector(`input[name=code-${s}]`);e?.blur(),g(o.join("")).then((()=>k(!0))).catch((e=>{if(e instanceof N&&e.privyErrorCode===A.INVALID_CREDENTIALS)R("Invalid or expired verification code");else if(e instanceof N&&e.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE)R(e.message);else{if(e instanceof N&&e.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),void a(cr.USER_LIMIT_REACHED_SCREEN);if(e instanceof N&&e.privyErrorCode===A.USER_DOES_NOT_EXIST)return void a(cr.ACCOUNT_NOT_FOUND_SCREEN);if(e instanceof N&&e.privyErrorCode===A.LINKED_TO_ANOTHER_USER)return c({errorModalData:{error:e,previousScreen:i??cr.AWAITING_PASSWORDLESS_CODE}}),void a(cr.ERROR_SCREEN,!1);if(e instanceof N&&e.privyErrorCode===A.DISALLOWED_PLUS_EMAIL)return c({inlineError:{error:e}}),void a(cr.CONNECT_OR_CREATE,!1);if(e instanceof N&&e.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return c({accountTransfer:{nonce:e.data?.data?.nonce,account:0===L?m()?.email:m()?.phoneNumber,displayName:e.data?.data?.account?.displayName,linkMethod:0===L?"email":"sms",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void a(cr.LINK_CONFLICT_SCREEN);R("Issue verifying code")}W(0)}))}},F=0==L?/*#__PURE__*/t(ii,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"}):
12
+ /*#__PURE__*/t(oi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),B=/*#__PURE__*/e("p",0==L?{children:["Please check ",/*#__PURE__*/t(pc,{children:m()?.email})," for an email from privy.io and enter your code below."]}:{children:["Please check ",/*#__PURE__*/t(pc,{children:m()?.phoneNumber})," for a message from ",r?.name||"Privy"," and enter your code below."]});/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:()=>l()},"header"),/*#__PURE__*/e(sc,{children:[/*#__PURE__*/t(Ql,{title:"Enter confirmation code",description:B,icon:F}),/*#__PURE__*/e(ut,{children:[/*#__PURE__*/e(lc,{children:[/*#__PURE__*/t(cc,{$fail:!!I,$success:_,children:/*#__PURE__*/t("span",{children:I||(_?"Success!":"")})}),/*#__PURE__*/t("div",{children:T.map(((e,n)=>/*#__PURE__*/t("input",{name:`code-${n}`,type:"text",value:T[n],onChange:U,onKeyUp:e=>{"Backspace"===e.key&&(e=>{if(1===O&&(R(null),W(null)),b([...T.slice(0,e),"",...T.slice(e+1)]),e>0){let t=document.querySelector(`input[name=code-${e-1}]`);t?.focus()}})(n)},inputMode:"numeric",autoFocus:0===n,pattern:"[0-9]",className:`${_?"success":""} ${I?"fail":""}`,autoComplete:y?"one-time-code":"off"},n)))})]}),/*#__PURE__*/e(dc,{children:[/*#__PURE__*/e("span",{children:["Didn't get ",0==L?"an email":"a message","?"]}),M?/*#__PURE__*/e(uc,{children:[/*#__PURE__*/t(ai,{color:"var(--privy-color-foreground)",strokeWidth:1.33,height:"12px",width:"12px"}),/*#__PURE__*/t("span",{children:"Code sent"})]}):/*#__PURE__*/t(hc,{children:/*#__PURE__*/t("button",{onClick:async()=>{P(30),0==L?await u():await p()},children:"Resend code"})})]})]})]}),/*#__PURE__*/t(ct,{})]})},[cr.AWAITING_CONNECTION]:_n,[cr.AWAITING_CONNECT_ONLY_CONNECTION]:()=>{let r,{navigateBack:a,navigate:i,lastScreen:l,currentScreen:c,data:d,setModalData:h}=lr(),{walletConnectionStatus:u,closePrivyModal:p}=x(),[m,g]=s(void 0),[f,w]=s(0),v=ft(u?.connector?.walletClientType||"unknown"),C="connected"===u?.status,E="switching_to_supported_chain"===u?.status;o((()=>{if(C){let e;if(d?.externalConnectWallet?.onCompleteNavigateTo){let t=d.externalConnectWallet.onCompleteNavigateTo,n=u.connectedWallet?.address;e=setTimeout((()=>{d.funding&&h({...d,funding:{...d.funding,connectedWalletAddress:n}}),i(t({walletChainType:u.connector?.chainType}))}),ur)}else e=setTimeout(p,ur);return()=>clearTimeout(e)}}),[C]);o((()=>{u?.connectError&&(e=>{g(bt(e))})(u?.connectError)}),[u]);let T=u?.connector?.connectorType||"injected",b=u?.connector?.walletClientType||"unknown",A=v?.metadata?.shortName||v?.name||u?.connector?.walletBranding.name||"Browser Extension",_=v?.image_url?.md||u?.connector?.walletBranding.icon||(e=>/*#__PURE__*/t(Xe,{...e})),k="Browser Extension"===A?A.toLowerCase():A;r=C?`Successfully connected with ${k}`:m?m.message:E?"Switching networks":`Waiting for ${k}`;let I="Don’t see your wallet? Check your other browser windows.";return C?I="You’re good to go!":f>=2&&m?I="Unable to connect wallet":m?I=m.detail:E?I="Switch your wallet to the requested network.":"metamask"===b&&y?I="Click to continue to open and connect MetaMask.":"metamask"===b?I="For the best experience, connect only one wallet at a time.":"wallet_connect_v2"===T?I="Open your mobile wallet app to continue":"coinbase_wallet"===T&&(I="Open the Coinbase app on your phone to continue."),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{backFn:c===l?void 0:a}),/*#__PURE__*/e(Sc,{children:[/*#__PURE__*/t(Tt,{walletLogo:_,success:C,fail:!!m}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:r}),/*#__PURE__*/t("p",{children:I})]}),m==na.ERROR_USER_EXISTS?/*#__PURE__*/t(st,{onClick:a,children:"Use a different wallet"}):!C&&m?.retryable&&f<2?/*#__PURE__*/t(st,{onClick:()=>{w(f+1),g(void 0),u?.connectRetry()},disabled:!C&&(!m?.retryable||f>=2),children:"Retry"}):!C&&m&&f>=2?/*#__PURE__*/t(st,{onClick:a,children:"Use a different wallet"}):null]}),/*#__PURE__*/t(yt,{})]})},[cr.AWAITING_FARCASTER_CONNECTION]:()=>{let{authenticated:r,logout:a,ready:i,user:c}=hr(),{lastScreen:d,navigate:h,navigateBack:u,setModalData:p,app:m}=lr(),{getAuthFlow:g,loginWithFarcaster:w,closePrivyModal:v,createAnalyticsEvent:C}=x(),[E,T]=s(void 0),[b,_]=s(!1),[k,I]=s(!1),N=l([]),R=g(),O=R?.meta.connectUri;return o((()=>{let e=Date.now(),t=setInterval((async()=>{let n=await R.pollForReady.execute(),r=Date.now()-e;if(n){clearInterval(t),_(!0);try{await w(),I(!0)}catch(e){let t={retryable:!1,message:"Authentication failed"};if(e?.privyErrorCode===A.ALLOWLIST_REJECTED)return void h(cr.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),void h(cr.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===A.USER_DOES_NOT_EXIST)return void h(cr.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===A.LINKED_TO_ANOTHER_USER)t.detail=e.message??"This account has already been linked to another user.";else{if(e?.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return p({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:"farcaster",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,farcasterEmbeddedAddress:e.data?.data?.otherUser?.farcasterEmbeddedAddress}}),void h(cr.LINK_CONFLICT_SCREEN);e?.privyErrorCode===A.INVALID_CREDENTIALS?(t.retryable=!0,t.detail="Something went wrong. Try again."):e?.privyErrorCode===A.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again.")}T(t)}}else r>12e4&&(clearInterval(t),T({retryable:!0,message:"Authentication failed",detail:"The request timed out. Try again."}))}),2e3);return()=>{clearInterval(t),N.current.forEach((e=>clearTimeout(e)))}}),[]),o((()=>{if(i&&r&&k&&c){if(m?.legal.requireUsersAcceptTerms&&!c.hasAcceptedTerms){let e=setTimeout((()=>{h(cr.AFFIRMATIVE_CONSENT_SCREEN)}),ur);return()=>clearTimeout(e)}k&&(ht(c,m.embeddedWallets)?N.current.push(setTimeout((()=>{p({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),C({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"FarcasterConnectStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),ur)):N.current.push(setTimeout((()=>v({shouldCallAuthOnSuccess:!0,isSuccess:!0})),ur)))}}),[k,i,r,c]),/*#__PURE__*/e(n,y||b?{children:[/*#__PURE__*/t(ot,{backFn:d?u:void 0,onClose:v},"header"),/*#__PURE__*/t(_t,{}),
13
+ /*#__PURE__*/t(n,f?{children:/*#__PURE__*/e(Eh,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:k,fail:!!E}),/*#__PURE__*/t(wh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t(Nl,{children:E?E.message:"Sign in with Farcaster"}),/*#__PURE__*/t(xl,{children:E?E.detail:"To sign in with Farcaster, please open the Warpcast app."})]}),O&&/*#__PURE__*/t(st,{onClick:e=>{e.preventDefault(),window.location.href=O},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(Ch,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:k,fail:!!E}),/*#__PURE__*/t(wh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t(Nl,{children:E?E.message:"Signing in with Farcaster"}),/*#__PURE__*/t(xl,{children:E?E.detail:"This should only take a moment"}),/*#__PURE__*/t(Ft,{children:O&&y&&/*#__PURE__*/t(gh,{text:"Take me to Warpcast",url:O,color:vh})})]})]})}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{backFn:d?u:void 0,onClose:v},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Ch,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Nl,{children:"Sign in with Farcaster"}),/*#__PURE__*/t(xl,{children:"Scan with your phone's camera to continue."}),/*#__PURE__*/t(Bt,{children:O?/*#__PURE__*/t(zt,{url:O,size:275,squareLogoElement:wh}):/*#__PURE__*/t(Ht,{})}),/*#__PURE__*/e(Ft,{children:[/*#__PURE__*/t(xl,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),O&&/*#__PURE__*/t(mh,{text:O,itemName:"link",color:vh})]})]})}),/*#__PURE__*/t(yt,{})]})},[cr.AWAITING_FARCASTER_SIGNER]:()=>{let{lastScreen:r,navigateBack:a,data:i,app:c}=lr(),{requestFarcasterSignerStatus:d,closePrivyModal:h}=x(),[u,p]=s(void 0),[m,g]=s(!1),[w,v]=s(!1),C=l([]),E=i?.farcasterSigner;o((()=>{let e=Date.now(),t=setInterval((async()=>{if(!E?.public_key)return clearInterval(t),void p({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===E.status&&(clearInterval(t),g(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),ur)));let n=await d(E?.public_key),r=Date.now()-e;"approved"===n.status?(clearInterval(t),g(!1),v(!0),C.current.push(setTimeout((()=>h({shouldCallAuthOnSuccess:!1,isSuccess:!0})),ur))):r>3e5?(clearInterval(t),p({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===n.status&&(clearInterval(t),p({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),C.current.forEach((e=>clearTimeout(e)))}}),[]);let T="pending_approval"===E?.status?E.signer_approval_url:void 0;/*#__PURE__*/return e(n,y||m?{children:[/*#__PURE__*/t(ot,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(_t,{}),
14
+ /*#__PURE__*/t(n,f?{children:/*#__PURE__*/e(Ah,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:w,fail:!!u}),/*#__PURE__*/t(wh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t(Nl,{children:u?u.message:"Add a signer to Farcaster"}),/*#__PURE__*/t(xl,{children:u?u.detail:"This will allow "+c.name+" to add casts, likes, follows, and more on your behalf."})]}),T&&/*#__PURE__*/t(st,{onClick:e=>{e.preventDefault(),window.location.href=T},children:"Open Warpcast app"})]})}:{children:/*#__PURE__*/e(bh,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:w,fail:!!u}),/*#__PURE__*/t(wh,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t(Nl,{children:u?u.message:"Requesting signer from Farcaster"}),/*#__PURE__*/t(xl,{children:u?u.detail:"This should only take a moment"}),/*#__PURE__*/t(Ft,{children:T&&y&&/*#__PURE__*/t(gh,{text:"Take me to Warpcast",url:T,color:Th})})]})]})}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{backFn:r?a:void 0,onClose:h},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(bh,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Nl,{children:"Add a signer to Farcaster"}),/*#__PURE__*/e(xl,{children:["This will allow ",c.name," to add casts, likes, follows, and more on your behalf."]}),/*#__PURE__*/t(Bt,{children:"pending_approval"===E?.status?/*#__PURE__*/t(zt,{url:E.signer_approval_url,size:275,squareLogoElement:wh}):/*#__PURE__*/t(Ht,{})}),/*#__PURE__*/e(Ft,{children:[/*#__PURE__*/t(xl,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===E?.status&&/*#__PURE__*/t(mh,{text:E.signer_approval_url,itemName:"link",color:Th})]})]})}),/*#__PURE__*/t(yt,{})]})},[cr.SELECT_PASSKEY_SIGNUP_OR_LOGIN]:()=>{let{enabled:r,token:a}=it(),{lastScreen:i,currentScreen:o,navigateBack:s,navigate:l,setModalData:c}=lr(),{initSignupWithPasskey:d,initLoginWithPasskey:h}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:i&&o!==i?s:void 0}),/*#__PURE__*/t(Il,{children:/*#__PURE__*/e(wy,{children:[/*#__PURE__*/t(iu,{}),/*#__PURE__*/t(ou,{})]})}),/*#__PURE__*/t(Nl,{children:"Log in or create a new account?"}),/*#__PURE__*/t(xl,{children:"Create a new account with a passkey or use a passkey to log in to an existing account."}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(st,{onClick:async()=>{r&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!0},captchaModalData:{callback:e=>d({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:cr.ERROR_SCREEN}}),l(cr.CAPTCHA_SCREEN)):(await d({withPrivyUi:!0}),c({passkeyAuthModalData:{passkeySignupFlow:!0}}),l(cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE))},children:"Create new account"}),/*#__PURE__*/t(Hl,{onClick:async()=>{r&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>h({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE,onErrorNavigateTo:cr.ERROR_SCREEN}}),l(cr.CAPTCHA_SCREEN)):(await h({withPrivyUi:!0}),c({passkeyAuthModalData:{passkeySignupFlow:!1}}),l(cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE))},children:"Log in with a passkey"})]}),/*#__PURE__*/t(ct,{})]})},[cr.AWAITING_PASSKEY_SYSTEM_DIALOGUE]:()=>{let{app:r,lastScreen:a,currentScreen:i,navigateBack:c,data:d,setModalData:h,navigate:u}=lr(),{loginWithPasskey:p,signupWithPasskey:m,closePrivyModal:y,createAnalyticsEvent:g}=x(),{user:f,logout:w}=hr(),{passkeySignupFlow:v}=d?.passkeyAuthModalData??{},C=ur-500,[E,T]=s("loading"),[b,_]=s(null),k=l([]),I=e=>{k.current=[e,...k.current]};o((()=>()=>{k.current.forEach((e=>clearTimeout(e))),k.current=[]}),[]);let N=async()=>{T("loading");try{v?await m():await p(),T("success")}catch(e){_(e),T("error")}};return o((()=>{if("success"===E&&f){if(r?.legal.requireUsersAcceptTerms&&!f.hasAcceptedTerms)return void I(setTimeout((()=>{u(cr.AFFIRMATIVE_CONSENT_SCREEN)}),C));if(!ht(f,r?.embeddedWallets))return void I(setTimeout((()=>{y({shouldCallAuthOnSuccess:!0,isSuccess:!0})}),ur));I(setTimeout((()=>{h({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),g({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"PasskeyStatusScreen"}}),w()},callAuthOnSuccessOnClose:!0}}),u(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),C))}}),[f,E]),o((()=>{N()}),[]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{backFn:a&&i!==a?c:void 0}),/*#__PURE__*/e(vy,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:"success"===E,fail:"error"===E}),/*#__PURE__*/t(ou,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:(()=>{switch(E){case"loading":return"Waiting for passkey";case"success":return"Success";case"error":return"Something went wrong"}})()}),/*#__PURE__*/t("p",{style:{whiteSpace:"pre-wrap"},children:(()=>{switch(E){case"loading":return v?"Please follow prompts to register your passkey.":"Please follow prompts to verify your passkey.\nYou will have to sign up with another method first to register a passkey for your account.";case"success":return"You've successfully logged in with your passkey.";case"error":if(b instanceof M){if(b.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE)return"Cannot link more passkeys to account.";if(b.privyErrorCode===A.PASSKEY_NOT_ALLOWED)return"Passkey request timed out or rejected by user.\nYou will have to sign up with another method first to register a passkey for your account."}return"An unknown error occurred.\nYou will have to sign up with another method first to register a passkey for your account."}})()})]}),(()=>{switch(E){case"loading":case"success":/*#__PURE__*/return t(st,{onClick:()=>{},disabled:!0,children:"Continue"});case"error":/*#__PURE__*/return t(st,{onClick:N,disabled:!1,children:"Retry"})}})()]}),/*#__PURE__*/t(yt,{})]})},[cr.WALLET_INTERSTITIAL_SCREEN]:()=>{let{ready:r}=hr(),{data:a}=lr(),[i,o]=s(!1);if(!a?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:l,connectOnly:c,chainType:d}=a.installWalletModalData,h=l.getMobileRedirect({useUniversalLink:!i,isSolana:"solana"===d,connectOnly:c}),u=l.name.replace(/ wallet/gi,""),p={title:`Redirecting to ${u} Mobile Wallet`,description:`We'll take you to the ${u} Mobile Wallet app to continue your login experience.`,footnote:""};return r&&(p.description=`For the best experience, we'll automatically log you into the ${u} Mobile Wallet in-app browser.`,p.footnote="You can always return here to login via other methods."),i&&(p.title="Still here?",p.description=`You may need to install the ${l.name} mobile app.`,p.footnote=`Once you're done, you can connect with ${l.name} wallet to complete the login.`),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Jl,{title:p.title,description:p.description}),/*#__PURE__*/e(hn,{children:[/*#__PURE__*/t(An,{href:h,onClick:()=>setTimeout((()=>o(!0)),1e3),loading:r&&!h,children:i?"Go to App Store":"Continue"}),p.footnote?/*#__PURE__*/t("p",{children:p.footnote}):null]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.LOGIN_FAILED_SCREEN]:()=>{let{closePrivyModal:r}=x(),{navigate:a}=lr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(rm,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),/*#__PURE__*/t(Jl,{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(hn,{children:[/*#__PURE__*/t(st,{onClick:()=>a(cr.LANDING),children:"Try again"}),/*#__PURE__*/t(dt,{onClick:()=>r(),children:"Cancel"})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.AWAITING_OAUTH_SCREEN]:()=>{let{authenticated:r,logout:a,ready:i,user:l}=hr(),{app:c,setModalData:d,navigate:h,resetNavigation:u}=lr(),{getAuthMeta:p,initLoginWithOAuth:m,loginWithOAuth:y,updateWallets:g,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v}=x(),[C,E]=s(!1),[T,b]=s(void 0),_=p()?.provider||"google",{name:k,component:I}=Go(_);o((()=>{y(_).then((()=>{E(!0),f(!0)})).catch((e=>{if(f(!1),e?.privyErrorCode===A.ALLOWLIST_REJECTED)return b(void 0),u(),void h(cr.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),b(void 0),u(),void h(cr.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===A.USER_DOES_NOT_EXIST)return b(void 0),u(),void h(cr.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return b(void 0),u(),d({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:p()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void h(cr.LINK_CONFLICT_SCREEN);let{retryable:t,detail:n}=function(e,t){let n={detail:"",retryable:!1},r=Mo(t);if(e?.privyErrorCode===A.LINKED_TO_ANOTHER_USER&&(n.detail="This account has already been linked to another user."),e?.privyErrorCode===A.INVALID_CREDENTIALS&&(n.retryable=!0,n.detail="Something went wrong. Try again."),e.privyErrorCode===A.OAUTH_USER_DENIED&&(n.detail=`Retry and check ${r} to finish connecting your account.`,n.retryable=!0),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&(n.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===A.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=Go(t).name;n.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===A.OAUTH_ACCOUNT_SUSPENDED){let e=Go(t).name;n.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE&&(n.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===A.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(n.detail="Something went wrong. Please try again."),n}(e,_);b({retryable:t,detail:n,message:"Authentication failed"})})).finally((()=>{Ko()}))}),[k,_]),o((()=>{if(i&&r&&C&&l){if(c?.legal.requireUsersAcceptTerms&&!l.hasAcceptedTerms){let e=setTimeout((()=>{h(cr.AFFIRMATIVE_CONSENT_SCREEN)}),ur);return()=>clearTimeout(e)}if(ht(l,c.embeddedWallets)){let e=setTimeout((()=>{d({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:_,screen:"OAuthStatusScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),ur);return()=>clearTimeout(e)}{let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),ur);return g(),()=>clearTimeout(e)}}}),[i,r,C,l]);let N=C?`Successfully connected with ${k}`:T?T.message:`Verifying connection to ${k}`,R="";return R=C?"You’re good to go!":T?T.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(fy,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:C,fail:!!T}),/*#__PURE__*/t(I,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:N}),/*#__PURE__*/t("p",{children:R})]}),T&&T?.retryable?/*#__PURE__*/t(un,{onClick:()=>{Ko(),m(_),b(void 0)},disabled:!C&&!T?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(yt,{})]})},[cr.CROSS_APP_AUTH_SCREEN]:()=>{let r=dr(),{data:a,navigate:l,setModalData:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),{crossAppAuthFlow:h,updateWallets:u,closePrivyModal:p,createAnalyticsEvent:m}=x(),{logout:y}=At(),[g,f]=s({}),w=a?.crossAppAuth,v={id:w.appId,name:w.name,logoUrl:w.logoUrl},C=new T(`There was an issue connecting your ${v.name} account. Please try again.`),E=new Ge((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 T?f({error:e}):(e instanceof N&&w.popup&&w.popup.close(),f({error:C}))}else f({error:C})})),b=()=>{g.data&&(u(),w.onSuccess(g.data),p({shouldCallAuthOnSuccess:!0,isSuccess:!0})),w.onError(g.error??new T("User canceled flow")),p({shouldCallAuthOnSuccess:!1,isSuccess:!1})};d.current=b,o((()=>{v.id.length&&E.execute(v.id)}),[v.id]),o((()=>{if(!g.data)return;let e=g.data;if(r.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{l(cr.AFFIRMATIVE_CONSENT_SCREEN)}),ur);return()=>clearTimeout(e)}if(ht(e,r.embeddedWallets)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),m({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${v.id}`,screen:"CrossAppAuthScreen"}}),y()},callAuthOnSuccessOnClose:!0}}),l(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),ur);return()=>clearTimeout(e)}let t=setTimeout(b,ur);return()=>clearTimeout(t)}),[g.data]);let{title:A,subtitle:_}=i((()=>g.data?{title:`Successfully connected with ${v.name}`,subtitle:"You're good to go!"}:g.error?{title:"Authentication failed",subtitle:g.error.message}:{title:`Connecting to ${v.name}`,subtitle:`Please check the pop-up from ${v.name} to continue`}),[g,v.name]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:b}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(Oc,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:!!g.data,fail:!!g.error}),/*#__PURE__*/t(Rc,{name:v.name,logoUrl:v.logoUrl})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:A}),/*#__PURE__*/t("p",{children:_})]})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(yt,{})]})},[cr.ALLOWLIST_REJECTION_SCREEN]:()=>{let{navigate:r,app:a}=lr(),i=a?.allowlistConfig.errorTitle||"You don't have access to this app",o=a?.allowlistConfig.errorDetail||"Have you been invited?",s=a?.allowlistConfig.errorCtaText||"Try another account";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/e(Kl,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(ul,{}),/*#__PURE__*/t(ql,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})]})}),/*#__PURE__*/e(Yl,{children:[/*#__PURE__*/t("string"==typeof i?"h3":n,{children:i}),/*#__PURE__*/t("string"==typeof o?"p":n,{children:o})]}),a?.allowlistConfig.errorCtaLink?
15
+ /*#__PURE__*/t(st,{as:"a",href:a.allowlistConfig.errorCtaLink,children:s}):/*#__PURE__*/t(st,{onClick:()=>{r(cr.LANDING)},children:s})]})]})},[cr.ACCOUNT_NOT_FOUND_SCREEN]:()=>{let{navigate:r,app:a,setModalData:i,data:o}=lr(),{getAuthMeta:s,client:l}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/e(dl,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(Js,{color:"var(--privy-color-warn-light)"}),/*#__PURE__*/t(Ja,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-warn)"})]})}),/*#__PURE__*/e(hl,{children:[/*#__PURE__*/t("h3",{children:"Account not found"}),/*#__PURE__*/e("p",{children:["Please try logging in again or go to ",a.name," to create an account."]})]}),/*#__PURE__*/t(Xs,{}),/*#__PURE__*/t(st,{onClick:()=>{let e=s();i({...o,login:{...o?.login,...e?.disableSignup?{disableSignup:!0}:{}}}),l?.authFlow&&(l.authFlow=void 0),r(cr.LANDING)},children:"Try logging in again"})]})]})},[cr.USER_LIMIT_REACHED_SCREEN]:()=>{let{navigate:r}=lr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/e(lf,{children:[/*#__PURE__*/t(cf,{children:/*#__PURE__*/t(sf,{})}),/*#__PURE__*/e(df,{children:[/*#__PURE__*/t("h3",{children:"Unable to sign in"}),/*#__PURE__*/t("p",{children:"This application has reached its user limit and cannot sign in new users."})]}),/*#__PURE__*/t(st,{onClick:()=>{r(cr.LANDING)},children:"Go back"})]}),/*#__PURE__*/t(ct,{})]})},[cr.INSTALL_WALLET_SCREEN]:()=>{let{navigateBack:r,data:a}=lr();if(!a?.installWalletModalData)throw Error("Wallet data is missing");let{walletConfig:i}=a.installWalletModalData;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:r},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(vp,{...i}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/e(yt,{children:[/*#__PURE__*/t("span",{children:"Still not sure? "}),/*#__PURE__*/t("a",{target:"_blank",href:"https://solana.com/docs/intro/wallets",children:"Learn more"})]})]})},[cr.LINK_EMAIL_SCREEN]:()=>{let{app:r}=lr();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Ql,{title:"Connect your email",description:`Add your email to your ${r?.name} account`,icon:/*#__PURE__*/t(ii,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(hn,{children:/*#__PURE__*/t(kp,{stacked:!0})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.LINK_PHONE_SCREEN]:()=>{let{app:r,currentScreen:a,data:i,navigate:o,setModalData:s}=lr(),{initLoginWithSms:l}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Ql,{title:"Connect your phone",description:`Add your number to your ${r?.name} account`,icon:/*#__PURE__*/t(oi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),/*#__PURE__*/t(hn,{children:/*#__PURE__*/t(Dp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await l({phoneNumber:e,withPrivyUi:!0}),o(cr.AWAITING_PASSWORDLESS_CODE)}catch(e){s({errorModalData:{error:e,previousScreen:i?.errorModalData?.previousScreen||a||cr.LINK_PHONE_SCREEN}}),o(cr.ERROR_SCREEN)}},hideRecent:!0})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.LINK_WALLET_SCREEN]:()=>{let{app:r,data:a}=lr(),i=a?.externalConnectWallet?.suggestedAddress,o=i?/*#__PURE__*/e("span",{children:["Link the wallet with address ",/*#__PURE__*/t(lt,{showCopyIcon:!1,address:i})," ",r?.name?`to ${r.name}.`:"."]}):`Link a wallet to your ${r?.name} account`,{connectors:s}=x(),l=xc({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(ot,{},"header"),l.length>0&&/*#__PURE__*/t(Jl,{title:"Link your wallet",description:o}),/*#__PURE__*/t(tl,{children:/*#__PURE__*/t(Nc,{wallets:l})}),/*#__PURE__*/t(ct,{})]})},[cr.LINK_PASSKEY_SCREEN]:()=>{let{user:r,unlinkPasskey:a}=hr(),{linkWithPasskey:i,closePrivyModal:l}=x(),c=r?.linkedAccounts.filter((e=>"passkey"===e.type)),[d,h]=s(!1),[u,p]=s(""),[m,y]=s(!1),[g,f]=s(!1);o((()=>{0===c.length&&f(!1)}),[c.length]);let w=async e=>(h(!0),await a(e).then((()=>y(!0))).catch((e=>{e instanceof M&&e.privyErrorCode===A.MISSING_MFA_CREDENTIALS?p("Cannot unlink a passkey enrolled in MFA"):p("Unknown error occurred.")})).finally((()=>{h(!1)})));/*#__PURE__*/return e(n,m?{children:[/*#__PURE__*/t(ot,{onClose:()=>l()},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(ci,{})}),/*#__PURE__*/t(mu,{style:{marginBottom:"1.5rem"},children:"Passkeys updated"}),/*#__PURE__*/t(yu,{children:" "}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:()=>l(),children:"Done"})}),/*#__PURE__*/t(yt,{})]}:g?{children:[/*#__PURE__*/t(ot,{backFn:()=>f(!1),onClose:()=>l()},"header"),/*#__PURE__*/t(su,{passkeys:c,expanded:g,onUnlink:w,onExpand:()=>f(!0)}),/*#__PURE__*/t(yt,{})]}:{children:[/*#__PURE__*/t(ot,{onClose:()=>l()},"header"),/*#__PURE__*/t(Il,{children:/*#__PURE__*/e(cu,{children:[/*#__PURE__*/t(iu,{}),/*#__PURE__*/t(ou,{})]})}),/*#__PURE__*/t(mu,{children:"Secure your account with a passkey"}),/*#__PURE__*/t(gu,{}),0===c.length?/*#__PURE__*/t(lu,{}):/*#__PURE__*/t(su,{passkeys:c,expanded:g,onUnlink:w,onExpand:()=>f(!0)}),/*#__PURE__*/e(Ml,{style:{marginTop:"12px"},children:[u&&/*#__PURE__*/t(du,{$fail:!0,children:u}),/*#__PURE__*/t(st,{onClick:()=>{h(!0),i().then((()=>y(!0))).catch((e=>{if(e instanceof M){if(e.privyErrorCode===A.CANNOT_LINK_MORE_OF_TYPE)return void p("Cannot link more passkeys to account.");if(e.privyErrorCode===A.PASSKEY_NOT_ALLOWED)return void p("Passkey request timed out or rejected by user.")}p("Unknown error occurred.")})).finally((()=>{h(!1)}))},loading:d,children:"Add new passkey"})]}),/*#__PURE__*/t(yt,{})]})},[cr.UPDATE_EMAIL_SCREEN]:()=>/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Ql,{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(ii,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(hn,{children:/*#__PURE__*/t(rf,{stacked:!0})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}),[cr.UPDATE_PHONE_SCREEN]:()=>{let{currentScreen:r,data:a,navigate:i,setModalData:o}=lr(),{user:s}=hr(),{initUpdatePhone:l}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(Ql,{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(oi,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),/*#__PURE__*/t(hn,{children:/*#__PURE__*/t(Dp,{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(cr.AWAITING_PASSWORDLESS_CODE)}catch(e){o({errorModalData:{error:e,previousScreen:a?.errorModalData?.previousScreen||r||cr.LINK_PHONE_SCREEN}}),i(cr.ERROR_SCREEN)}},hideRecent:!0})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.CONNECT_ONLY_LANDING_SCREEN]:()=>{let{app:r,data:a}=lr(),i=dr(),o=a?.externalConnectWallet?.suggestedAddress,s=o?/*#__PURE__*/e("span",{children:["Connect the wallet with address ",/*#__PURE__*/t(lt,{showCopyIcon:!1,address:o})," ",r?.name?`to ${r.name}.`:"."]}):`Connect a wallet to your ${r?.name} account`,{connectors:l}=x(),c=xc({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(ot,{},"header"),c.length>0&&/*#__PURE__*/t(Zl,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(nl,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(Nc,{wallets:c})}),r&&/*#__PURE__*/t(Et,{app:r,alwaysShowImplicitConsent:!0}),/*#__PURE__*/t(ct,{})]})},[cr.CONNECT_ONLY_AUTHENTICATED_SCREEN]:()=>{let{app:r,data:a}=lr(),i=dr(),o=a?.externalConnectWallet?.suggestedAddress,s=o?`Connect the wallet with address ${Ct(o)} ${r?.name?`to ${r.name}.`:"."}`:`Connect a wallet to ${r?.name}`,{connectors:l}=x(),c=xc({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(ot,{},"header"),c.length>0&&/*#__PURE__*/t(Jl,{title:"Connect your wallet",description:s}),/*#__PURE__*/t(nl,{$colorScheme:i.appearance.palette.colorScheme,children:/*#__PURE__*/t(Nc,{wallets:c})}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN]:()=>{let{app:r,setModalData:a,navigate:i,data:l,onUserCloseViaDialogOrKeybindRef:c}=lr(),[d,h]=s(""),{embeddedWallets:u}=dr(),{authenticated:p,user:m,getAccessToken:y}=hr(),{closePrivyModal:g,walletProxy:f,refreshSessionAndUser:w,recoverPrimaryWallet:v}=x(),{onSuccess:C,onFailure:E,callAuthOnSuccessOnClose:b}=l.createWallet,A=!0===r?.embeddedWallets.requireUserOwnedRecoveryOnCreate,{createWallet:_}=cd(),[k,I]=s(null),N=new Ge((async()=>{let e=await y();if(m&&e&&f)try{let t=wr(m);if(t&&"privy"===t.recoveryMethod)await v();else if(t){let{entropyId:n,entropyIdVerifier:r}=jn(t);try{if(!await f.connect({accessToken:e,entropyId:n,entropyIdVerifier:r}))throw new T("Primary wallet not connected.")}catch(e){return I(t),void i(cr.EMBEDDED_WALLET_CREATED_SCREEN)}}let n=Wt(m,r.embeddedWallets.ethereum.createOnLogin),a=Mt(m,r.embeddedWallets.solana.createOnLogin);if(n&&a){let t=await _({user:m});if(await f.createSolana({accessToken:e,ethereumAddress:t?.address}),!t)return;return I(t),void i(cr.EMBEDDED_WALLET_CREATED_SCREEN)}if(a){await f.createSolana({accessToken:e,ethereumAddress:yr(m)?.address});let t=await w();return I(gr(t)),void i(cr.EMBEDDED_WALLET_CREATED_SCREEN)}if(n){let e=await _({user:m});if(!e)return;I(e),i(cr.EMBEDDED_WALLET_CREATED_SCREEN)}}catch(e){h(e.message)}}));return o((()=>p&&m?A?(a({...l,recoverySelection:{...l?.recoverySelection,isInAccountCreateFlow:!0}}),i(Jc({walletAction:"create",showAutomaticRecovery:!1,availableRecoveryMethods:u.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:!1,isResettingPassword:!1}))):void N.execute():(i(cr.LANDING),void E(Error("User must be authenticated before creating a Privy wallet")))),[A,p]),c.current=()=>null,d?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{closeable:!1}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Something went wrong",description:d})]}),/*#__PURE__*/t(st,{onClick:()=>{k?(C(k),g({shouldCallAuthOnSuccess:b})):(E(new R("User wallet creation failed")),g({shouldCallAuthOnSuccess:!1}))},children:"Close"}),/*#__PURE__*/t(dd,{})]}):/*#__PURE__*/t(Lc,{})},[cr.EMBEDDED_WALLET_CREATED_SCREEN]:()=>{let{user:r}=hr(),{closePrivyModal:a,isNewUserThisSession:i,updateWallets:s}=x(),{app:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),{onSuccess:h,onFailure:u,callAuthOnSuccessOnClose:p}=c.createWallet,m=()=>{let e=yr(r)??gr(r);e?(s(),h(e)):u(Error("Failed to create wallet")),a({shouldCallAuthOnSuccess:p})};return o((()=>{let e=setTimeout(m,pr);return()=>clearTimeout(e)}),[]),d.current=m,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:m}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(si,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:i?"Welcome"+(l?.name?` to ${l?.name}`:""):"All set!",description:i?"You’ve successfully created an account.":"Your account is secured."})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_CONNECTING_SCREEN]:()=>{let{authenticated:r,user:a,getAccessToken:l}=hr(),{closePrivyModal:c,createAnalyticsEvent:d,walletProxy:h}=x(),{navigate:u,data:p,setModalData:m,onUserCloseViaDialogOrKeybindRef:y}=lr(),g=i((()=>Date.now()),[]),[f,w]=s(!1),{onCompleteNavigateTo:v,onFailure:C,shouldForceMFA:E,entropyId:T,entropyIdVerifier:b}=p?.connectWallet,A=e=>{f||(w(!0),C("string"==typeof e?Error(e):e))};o((()=>{let e,t=mr(a,T);return r&&t?h?((async()=>{let n=await l();if(!n)return A("User must be authenticated and have a Privy wallet before it can be connected");try{await h.connect({accessToken:n,entropyId:T,entropyIdVerifier:b}),E&&await h.verifyMfa({accessToken:n});let t=(Date.now()-g)/1e3;v===cr.EMBEDDED_WALLET_KEY_EXPORT_SCREEN&&t<1?e=setTimeout((()=>{u(v,!1)}),1e3*(1-t)):u(v,!1)}catch(e){if($c(e)&&"privy"===t.recoveryMethod){let e=await l();if(!e)return A("User must be authenticated and have a Privy wallet before it can be recovered");try{d({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:t.address}});let n=await(h?.recover({accessToken:e,entropyId:T,entropyIdVerifier:b}));n?.entropyId||A(Error("Unable to recover wallet")),v?u(v):c({shouldCallAuthOnSuccess:!1}),d({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}}),u(v)}catch(e){A("An error has occurred, please try again.")}}else $c(e)&&"privy"!==t.recoveryMethod?(m({...p,recoverWallet:{entropyId:T,entropyIdVerifier:b,onCompleteNavigateTo:v,onFailure:C},recoveryOAuthStatus:{provider:t.recoveryMethod,action:"recover",isInAccountCreateFlow:!1}}),u(Qc(t.recoveryMethod))):A(e)}})(),()=>clearTimeout(e)):void 0:A("User must be authenticated and have a Privy wallet before it can be connected")}),[r,a,h]);let _=()=>{A("User exited before wallet could be connected"),c({shouldCallAuthOnSuccess:!1})};return y.current=_,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:_}),f?/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),/*#__PURE__*/t(st,{onClick:()=>c({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):/*#__PURE__*/t(Lc,{}),/*#__PURE__*/t(td,{})]})},[cr.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN]:()=>{let[r,a]=s(!0),{authenticated:i,getAccessToken:l,user:c}=hr(),{walletProxy:d,closePrivyModal:h,createAnalyticsEvent:u}=x(),{navigate:p,data:m,onUserCloseViaDialogOrKeybindRef:y}=lr(),[g,f]=s(void 0),[w,v]=s(""),[C,E]=s(!1),{entropyId:T,entropyIdVerifier:b,onCompleteNavigateTo:A,onSuccess:_,onFailure:k}=m.recoverWallet,I=(e="User exited before their wallet could be recovered")=>{h({shouldCallAuthOnSuccess:!1}),k("string"==typeof e?new R(e):e)};y.current=I,o((()=>{if(!i)return I("User must be authenticated and have a Privy wallet before it can be recovered")}),[i]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:I}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(Ey,{children:[/*#__PURE__*/e(Cy,{children:[/*#__PURE__*/t(oo,{height:48,width:48,stroke:"var(--privy-color-accent)"}),/*#__PURE__*/t("h3",{style:{color:"var(--privy-color-foreground)"},children:"Enter your password"}),/*#__PURE__*/t("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(wd,{children:[/*#__PURE__*/t(gd,{type:r?"password":"text",onChange:e=>(e=>{e&&f(e)})(e.target.value),disabled:C,style:{paddingRight:"2.3rem"}}),/*#__PURE__*/t(bd,{style:{right:"0.75rem"},children:r?/*#__PURE__*/t(_d,{onClick:()=>a(!1)}):/*#__PURE__*/t(kd,{onClick:()=>a(!0)})})]}),!!w&&/*#__PURE__*/t(Ty,{children:w})]}),/*#__PURE__*/e("div",{children:[/*#__PURE__*/e(vn,{children:[/*#__PURE__*/t("h4",{children:"Why is this necessary?"}),/*#__PURE__*/t("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),/*#__PURE__*/t(by,{loading:C||!d,disabled:!g,onClick:async()=>{E(!0);let e=await l(),t=mr(c,T);if(!e||!t||null===g)return I("User must be authenticated and have a Privy wallet before it can be recovered");try{u({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t.address}}),await(d?.recover({accessToken:e,entropyId:T,entropyIdVerifier:b,recoveryPassword:g})),v(""),A?p(A):h({shouldCallAuthOnSuccess:!1}),_?.(t),u({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t.address}})}catch(e){!function(e){return Vc(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)}(e)?v("An error has occurred, please try again."):v("Invalid recovery password, please try again.")}finally{E(!1)}},warn:!1,hideAnimations:!T&&C,children:"Recover your account"})]})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN]:()=>{let[r,a]=s(!1),{navigate:i,lastScreen:o,navigateBack:l,setModalData:c,data:d,onUserCloseViaDialogOrKeybindRef:h}=lr(),{user:u}=hr(),{embeddedWallets:p}=dr(),{closePrivyModal:m}=x(),y=wr(u),g=null===y,{isInAccountCreateFlow:f,isResettingPassword:w}=d.recoverySelection,v=y&&"privy"!==y.recoveryMethod,C=v?/*#__PURE__*/e("span",{children:["Your account is currently secured using"," ",/*#__PURE__*/t("strong",{children:Sy[y?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function E(e){c({recoveryOAuthStatus:{provider:e,action:g?"create-wallet":"set-recovery",isInAccountCreateFlow:f}}),i(cr.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN)}function T(){d?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),m({shouldCallAuthOnSuccess:d?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return h.current=T,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:T,backFn:r?()=>a(!1):o?l:void 0,infoFn:o||r?void 0:()=>a(!0)},"header"),r?/*#__PURE__*/t(Ry,{onClose:()=>a(!1)}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(Ql,{title:v?"Update backup method":"Secure your account",icon:/*#__PURE__*/t(yo,{width:48}),description:C}),/*#__PURE__*/t(ky,{children:p.userOwnedRecoveryOptions.filter((e=>!["icloud","google-drive"].includes(y?.recoveryMethod||"")||e!==y?.recoveryMethod)).sort().map((n=>{switch(n){case"google-drive":/*#__PURE__*/return e(il,{onClick:()=>E("google-drive"),children:[/*#__PURE__*/t(xy,{children:/*#__PURE__*/t(_y,{style:{width:18}})}),"Back up to Google Drive"]},n);case"icloud":/*#__PURE__*/return e(il,{onClick:()=>E("icloud"),children:[/*#__PURE__*/t(xy,{children:/*#__PURE__*/t(Ay,{style:{width:24}})}),"Back up to Apple iCloud"]},n);case"user-passcode":/*#__PURE__*/return e(il,{onClick:()=>{i(Zc({isCreatingWallet:g,skipSplashScreen:!0}))},children:[/*#__PURE__*/t(xy,{children:/*#__PURE__*/t(go,{style:{width:18}})}),w?"Reset your":"Set a"," password"]},n);default:return null}}))})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN]:()=>{let{user:r,getAccessToken:a}=hr(),{walletProxy:i,refreshSessionAndUser:o,closePrivyModal:l}=x(),c=lr(),{entropyId:d,entropyIdVerifier:h}=c.data?.recoverWallet,[u,p]=s(!1),[m,y]=s(null),[g,f]=s(null);function w(){if(!u){if(g)return c.data?.setWalletPassword?.onFailure(g),void l();if(!m)return c.data?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),void l()}}c.onUserCloseViaDialogOrKeybindRef.current=w;let v=!(!u&&!m);/*#__PURE__*/return e(n,g?{children:[/*#__PURE__*/t(ot,{onClose:w},"header"),/*#__PURE__*/t(Oy,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:/*#__PURE__*/t(Qa,{height:38,width:38,stroke:"var(--privy-color-error)"})}),/*#__PURE__*/t(St,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),/*#__PURE__*/t(Xs,{style:{minHeight:"2rem"}}),/*#__PURE__*/t(Jt,{onClick:()=>f(null),children:"Try again"}),/*#__PURE__*/t(ct,{})]}:{children:[/*#__PURE__*/t(ot,{onClose:w},"header"),/*#__PURE__*/t(yo,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),/*#__PURE__*/t(St,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),/*#__PURE__*/t(Rt,{style:{marginTop:"1rem"},children:"When you log into a new device, you’ll only need to authenticate to access your account. Never get logged out if you forget your password."}),/*#__PURE__*/t(Xs,{style:{minHeight:"2rem"}}),/*#__PURE__*/t(Jt,{loading:u,disabled:v,onClick:()=>async function(){p(!0);try{let e=await a(),t=mr(r,d);if(!e||!i||!t)return;if(!(await i.setRecovery({accessToken:e,entropyId:d,entropyIdVerifier:h,existingRecoveryMethod:t.recoveryMethod,recoveryMethod:"privy"})).entropyId)throw Error("Unable to set recovery on wallet");let n=await o();if(!n)throw Error("Unable to set recovery on wallet");let s=mr(n,t.address);if(!s)throw Error("Unabled to set recovery on wallet");y(!!n),setTimeout((()=>{c.data?.setWalletPassword?.onSuccess(s),l()}),ur)}catch(e){f(e)}finally{p(!1)}}(),children:m?"Success":"Confirm"}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN]:()=>{let{logout:r}=hr(),{navigate:a,setModalData:i,data:l}=lr(),{recoveryOAuthFlow:d,closePrivyModal:h,createAnalyticsEvent:u}=x(),[p,m]=s(!1),{provider:y,action:g,isInAccountCreateFlow:f}=l?.recoveryOAuthStatus,[w,v]=s(void 0),[C,E]=s("create-wallet"===g);if("user-passcode"===y)throw Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let T=Ny[y].name,b=Ny[y].component,A=l?.recoverWallet?.onCompleteNavigateTo,_=new Ge((async(e="create-wallet")=>(E(!0),new Promise(((t,n)=>{setTimeout((async()=>{try{let n=window.open();await d(y,e,n),m(!0),t()}catch(t){v({message:`${"recover"===e?"Recovery":"Back up"} with ${T} unsuccessful`,detail:"recover"===g?`Please verify that you are selecting the ${T} account associated with your backup.`:"",retryable:!0}),n()}}),0)})))));o((()=>{"recover"!==g&&_.execute(f?"create-wallet":"set-recovery")}),[]),o((()=>{if(!p)return;let e=setTimeout((()=>{f?(i({createWallet:{onSuccess:()=>{},onFailure:e=>{u({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"RecoveryOAuthScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),a(cr.EMBEDDED_WALLET_CREATED_SCREEN)):h({shouldCallAuthOnSuccess:!1})}),ur);return()=>clearTimeout(e)}),[p]);let k=c((async()=>{await _.execute("recover"),A?a(A):m(!0)}),[]),I="google-drive"===y?"Google Drive":"Apple iCloud",N=p&&`Successfully ${"recover"===g?"recovered":"backed up"} with ${I}.`||w&&w.message||`${"recover"===g?"Recovering":"Backing up"} with ${I}...`,S=w?w.detail:"";/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{}),C?/*#__PURE__*/t(n,{children:/*#__PURE__*/e(ky,{children:[/*#__PURE__*/t(Ql,{title:N,icon:/*#__PURE__*/t(b,{style:{width:"38px",height:"38px"}}),description:S}),w&&w?.retryable?/*#__PURE__*/t(st,{onClick:()=>{Ko(),v(void 0),"create-wallet"===g?_.execute("create-wallet"):k()},disabled:!p&&!w?.retryable,children:"Try again"}):null]})}):/*#__PURE__*/e(ky,{children:[/*#__PURE__*/t(Ql,{title:"Confirm it's really you",icon:/*#__PURE__*/t(b,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${I} where your account is backed up.`}),/*#__PURE__*/e(st,{onClick:k,children:["Confirm with ",I]})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_KEY_EXPORT_SCREEN]:()=>{let[r,a]=s(null),{authenticated:i,user:l,getAccessToken:c}=hr(),{closePrivyModal:d,createAnalyticsEvent:h,clientAnalyticsId:u}=x(),p=dr(),{data:m,onUserCloseViaDialogOrKeybindRef:y}=lr(),{onFailure:g,onSuccess:f,origin:w,appId:v,appClientId:C,walletToExport:E,primaryWallet:T}=m.keyExport,b=e=>{d({shouldCallAuthOnSuccess:!1}),g("string"==typeof e?Error(e):e)},A=()=>{d({shouldCallAuthOnSuccess:!1}),f(),h({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:E.address}})};return o((()=>{if(!i||!E)return b("User must be authenticated before exporting their wallet");c().then(a,b)}),[i,l]),y.current=A,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:A}),/*#__PURE__*/e(od,{children:[/*#__PURE__*/t(St,{children:"Transfer wallet"}),/*#__PURE__*/e(Rt,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",/*#__PURE__*/t("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),/*#__PURE__*/t(nd,{theme:p.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),/*#__PURE__*/t(Nt,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:E.address,showIcon:!0}),/*#__PURE__*/t("div",{style:{width:"100%"},children:r&&/*#__PURE__*/t(id,{origin:w,appId:v,appClientId:C,accessToken:r,clientAnalyticsId:u,walletToExport:E,primaryWallet:T,dimensions:{height:"44px"}})})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN]:()=>{let{authenticated:r}=hr(),{initializeWalletProxy:a,closePrivyModal:i}=x(),{navigate:l,data:c,onUserCloseViaDialogOrKeybindRef:d}=lr(),[h,u]=s(!0),[p,m]=s(""),[y,g]=s(),[f,w]=s(null),[v,C]=s(!1),E=null!==f;o((()=>{r||l(cr.LANDING)}),[r]),o((()=>{a(fr).then((e=>{u(!1),e||(m("An error has occurred, please try again."),g(new ca(new da(p,zi.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:T,data:b,confirmAndSign:A,onSuccess:_,onFailure:k,uiOptions:I}=c.signMessage,N={title:I?.title||"Sign message",description:I?.description||"Signing this message will not cost you any fees.",buttonText:I?.buttonText||"Sign and continue"},S=e=>{e?_(e):k(y||new ca(new da("The user rejected the request.",zi.E4001_USER_REJECTED_REQUEST.eipCode))),i({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{w(null),m(""),g(void 0)}),200)};return d.current=()=>{S(f)},/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:()=>S(f)}),/*#__PURE__*/t(_t,{}),I?.iconUrl&&"string"==typeof I.iconUrl?/*#__PURE__*/t(ef,{children:/*#__PURE__*/t(Kg,{size:"sm",src:I.iconUrl,alt:"app image"})}):null,/*#__PURE__*/t(St,{children:N.title}),/*#__PURE__*/t(Rt,{children:N.description}),"personal_sign"===T&&/*#__PURE__*/t(_g,{children:Yg(b)}),"eth_signTypedData_v4"===T&&/*#__PURE__*/t(Jg,{typedData:b}),"solana_signMessage"===T&&/*#__PURE__*/t(_g,{children:b}),/*#__PURE__*/t(tf,{}),/*#__PURE__*/t(Qg,{$fail:!0,children:p}),/*#__PURE__*/t(Jt,{disabled:v||E||h,loading:v,onClick:async()=>{C(!0),m("");try{let e=await A();w(e),C(!1),setTimeout((()=>{S(e)}),ur)}catch(e){console.error(e),m("An error has occurred, please try again."),g(new ca(new da(p,zi.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),C(!1)}},children:v?"Signing...":E?/*#__PURE__*/e(Xg,{children:[/*#__PURE__*/t(ph,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",/*#__PURE__*/t("span",{children:"Success"})]}):N.buttonText}),I?.isCancellable&&/*#__PURE__*/t(mn,{style:{marginTop:"1rem"},onClick:()=>S(null),isSubmitting:!1,children:"Not now"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN]:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=lr(),{rpcConfig:l,chains:c,closePrivyModal:d,walletProxy:h,client:u,showFiatPrices:p}=x(),{getAccessToken:m,user:y}=hr(),g=dr(),[f,w]=s(0),v=(e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(e),[C,E]=s(qg(e,f)),[T,b]=s(null),[A,_]=s(),[k,I]=s(!1),[N,S]=s(null),[R,O]=s(null),[W,M]=s(null),[P,L]=s(void 0),[D,U]=s(void 0),[F,B]=s(!1),[z,H]=s(!1),[V,$]=s([]),[j,G]=s([]),[q,K]=s(!1),[Y,Z]=s(void 0);if(!C||!e?.sendTransaction||!e?.sendTransaction.transactingWallet)/*#__PURE__*/return t(ch,{error:Error("Invalid transaction request"),onClick:()=>{e?.sendTransaction?.onFailure(Gg),d({shouldCallAuthOnSuccess:!1})}});let{entropyId:J,entropyIdVerifier:Q,transactingWallet:X}=e.sendTransaction,ee=i((()=>c.find((e=>Number(e.id)===Number(C.chainId)))),[C.chainId]),te=ee?.nativeCurrency.symbol??"ETH",ne=i((()=>Hg(C.data,!!g.embeddedWallets.extendedCalldataDecoding)),[C.data]),{action:re,isErc20Ish:ae,isNFTIsh:ie}=ne,{toAddress:oe,tokenAddress:se}=i((()=>({toAddress:ne.isErc20Ish?ne.transferTo:C.to??void 0,tokenAddress:ne.isErc20Ish?C.to:void 0})),[ne]);o((()=>{C.to&&ee&&ae&&ln({address:C.to,chain:ee,rpcConfig:g.rpcConfig,privyAppId:g.id}).then(b).catch(console.error)}),[C.to,ee]);let{tokenPrice:le,isTokenPriceLoading:ce}=Oh(C.chainId),{balance:de}=dn({rpcConfig:g.rpcConfig,appId:g.id,address:X.address,chain:ee}),he=i((()=>Ha(Number(C.chainId),c,l,{appId:g.id})),[C.chainId,l]),ue=jg(C,X,he);o((()=>{E(qg(e,f))}),[f]),o((()=>{e.sendTransaction?.getIsSponsored?e.sendTransaction.getIsSponsored().then(_).catch(console.error):_(!1)}),[e.sendTransaction.getIsSponsored]);let pe=()=>{if(!k)return N?e?.sendTransaction?.onSuccess({hash:N}):W||ue?.errors[0]?e?.sendTransaction?.onFailure(W??ue?.errors[0]??Gg):e?.sendTransaction?.onFailure(new ca(new da("The user rejected the request",zi.E4001_USER_REJECTED_REQUEST.eipCode))),d({shouldCallAuthOnSuccess:!1})};n.current=pe;let me=!!(e.funding&&e.funding.supportedOptions.length>0),ye=Yt(BigInt(ue?.totalGasEstimate??0n),te),ge=p&&le?tn(BigInt(ue?.totalGasEstimate??0n),le):void 0,fe=Yt(de??0n,te,void 0,!0),we=p&&le?tn(de??0n,le):void 0,ve=e.sendTransaction?.uiOptions?.transactionInfo?.title;ve||(ve="approve"===re?ae?"Confirm address":"Confirm action":`Approve ${re}`);let Ce=e.sendTransaction?.uiOptions?.description||(ae&&"approve"===re?`${g.name} would like your permission for ${Ct(ne.spender)} to spend tokens on your behalf.`:`${g.name} wants your permission to approve the following transaction.`),Ee=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),be=Te&&me,Ae=be?"Add funds":e.sendTransaction?.uiOptions?.buttonText||(f<v?"Continue":"Approve");if(o((()=>{let e=(e,t,n)=>{if(t.isErc20Ish&&t.amount&&n)Z(nn({amount:t.amount,decimals:n.decimals})),$([{value:Y,symbol:n?.symbol}]);else if(e.value){let t=BigInt(e.value),n=le&&tn(t,le);$(p&&n?[{value:n}]:[{value:Tn(t),symbol:te}])}else $(p?[{value:"$0"}]:[{value:"0",symbol:te}])},t=ue?.tx??C;g.embeddedWallets.transactionScanning.enabled&&t?(K(!0),(async e=>{if(u)return await u.scanTransaction({metadata:{domain:g.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})})(t).then((e=>{if(!e)throw Error("Transaction scan failed");if("Success"===e.validation.status&&("Benign"===e.validation.result_type?U("safe"):"Warning"===e.validation.result_type?U("warn"):"Malicious"===e.validation.result_type&&(U("error"),H(!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}:{iconUrl:t.asset.logo_url,value:t.in[0].value,symbol:t.asset.symbol,usdValue:t.in[0].usd_price},n.push(e)}else if(t.out[0]?.value){let e;e="ERC721"===t.asset.type||"approve_for_all"===t.out[0].value?{nftName:t.asset.name}:{iconUrl:t.asset.logo_url,value:t.out[0].value,symbol:t.asset.symbol,usdValue:t.out[0].usd_price},r.push(e)}for(let e of t)for(let t of Object.keys(e.spenders)){let n;n="ERC721"===e.asset.type||"approve_for_all"===e.spenders[t]?.value?{nftName:e.asset.name}:{iconUrl:e.asset.logo_url,value:e.spenders[t]?.value,symbol:e.asset.symbol,usdValue:e.spenders[t]?.usd_price},r.push(n)}return{assetsIn:n,assetsOut:r}}(e.simulation.assets_diffs,e.simulation.exposures);if(0===n.length&&0===t.length)throw Error("No tokens found");$(n),G(t)}K(!1)})).catch((()=>{K(!1),e(t,ne,T)}))):e(t,ne,T)}),[C,ue?.tx,ne,T]),R/*#__PURE__*/)return t(Rg,{txn:ue?.tx??C,onClose:pe,receipt:R,transactionInfo:e.sendTransaction?.uiOptions.transactionInfo,tokenPrice:le,tokenSymbol:te,receiptHeader:e.sendTransaction?.uiOptions.successHeader,receiptDescription:e.sendTransaction?.uiOptions.successDescription});if(W)/*#__PURE__*/return t(Qy,{transactionError:W,transactionHash:N??void 0,network:"ethereum",chainId:ue?.tx.chainId??C.chainId,onClose:pe,onRetry:({resetNonce:e})=>{M(null);let t={...ue?.tx??C};e&&(t.nonce=void 0),E(t)}});let _e=0!==v&&"number"==typeof f&&0!==f?()=>{w(f-1)}:void 0;return F&&P?/*#__PURE__*/t(xg,{details:P,onBack:()=>B(!1)}):/*#__PURE__*/t(Gy,{transactionIndex:f,onBack:_e,maxIndex:v,disabled:Te&&!me||z,isSubmitting:k,submitError:W,isPreparing:!ue,isTokenPriceLoading:ce,isTokenContractInfoLoading:!ie&&!T,prepareError:ue?.errors[0],symbol:T?.symbol,chain:ee,img:Ee,title:ve,subtitle:Ce,txValue:C.value,fee:ge??ye,isSponsored:A,from:X?.address??"",to:oe,tokenAddress:se??void 0,network:g.chains.find((e=>e.id===C.chainId))?.name??"",transactionDetails:{...ne,formattedAmount:Y},cta:Ae,missingFunds:Te,action:re,balance:we??fe,onClose:pe,onClick:be?async()=>{if(!X)return;if(!me)throw Error("Funding wallet is not enabled");let t=cr.FUNDING_METHOD_SELECTION_SCREEN;r({...e,funding:{...e.funding,methodScreen:t,chainType:"ethereum",amount:Da(BigInt(ue?.tx.value??0)+BigInt(ue?.totalGasEstimate?.toString()??0)),chain:ee}}),a(t)}:async()=>{if(f<v)w(f+1);else{I(!0);try{let t=await m();if(k||!t||!X||!h||!y)return;let n=e?.sendTransaction?.onConfirm?await e.sendTransaction.onConfirm():await Tg({accessToken:t,transactingWallet:X,entropyId:J,entropyIdVerifier:Q,walletProxy:h,transactionRequest:ue?.tx??C,publicClient:he,requesterAppId:e.sendTransaction?.requesterAppId});if(S(n),e.sendTransaction?.signOnly)return await new Promise((e=>setTimeout(e,ur))),e?.sendTransaction?.onSuccess({hash:n}),d({shouldCallAuthOnSuccess:!1});let r=await he.waitForTransactionReceipt({hash:n});if("reverted"===r.status)throw Error("Transaction failed");O(r)}catch(e){console.warn({transaction:ue?.tx??C,error:e}),M(e)}finally{I(!1)}}},validation:D,hasScanDetails:!!P,setIsScanDetailsOpen:B,preventMaliciousTransaction:z,setPreventMaliciousTransaction:H,tokensSent:V,tokensReceived:j,isScanning:q,isCancellable:e.sendTransaction?.uiOptions?.isCancellable??!1})},[cr.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN]:()=>{let{data:e,onUserCloseViaDialogOrKeybindRef:n,setModalData:r,navigate:a}=lr(),{client:l,closePrivyModal:c,walletProxy:d,showFiatPrices:h}=x(),u=dr(),{user:p,getAccessToken:m}=hr(),[y,g]=s(e?.sendSolanaTransaction?.transactionRequest),[f,w]=s(),[v,C]=s(),[E,T]=s(0),[b,A]=s({value:0n,isLoading:!1}),[_,k]=s(!1),[I,N]=s(),[S,R]=s(),O=e?.sendSolanaTransaction?.connection,W=e?.sendSolanaTransaction?.transactingWallet,M=e?.sendSolanaTransaction?.signOnly??!1,P=f?.instructions.length??1,L=W?.imported?Lr(p):wr(p),D=Er(O?.rpcEndpoint||""),{solPrice:U,isSolPriceLoading:F}=Rh({enabled:h}),B=i((()=>{let e,t;if(!f)return;let n=f.spender;0===E&&W?.address===n&&(e=Ph(f.fee));let r=Ph(b.value,3,!0),a=f.instructions[E];if(!a)return{fee:e,spender:n,balance:r};if("unknown"===a.type)return{fee:e,spender:n,program:a.program,balance:r};if("ata-creation"===a.type)return{fee:e,spender:n,balance:r,tokenAccountOwner:a.owner,tokenAccount:a.ata,tokenAddress:a.mint};let i=a.fromAccount,o="sol-transfer"===a.type?a.toAccount:a.toAccount||a.toAta,s="spl-transfer"===a.type?a.token.address:void 0;return null!=e&&"SOL"===a.token.symbol&&(t=Ph(a.value+f.fee)),{fee:e,spender:n,from:i,to:o,tokenAddress:s,amount:`${Ra(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}}),[f,E,W?.address,b]),z=i((()=>{let e,t;if(!f||!h||!U||F)return;function n(...e){return Lh(e.reduce(((e,t)=>e+t),0n),U??0)}0===E&&W?.address===f.spender&&(e=n(f.fee));let r=n(b.value),a=f.instructions[E];return a&&"unknown"!==a.type&&"ata-creation"!==a.type?(null!=e&&"SOL"===a.token.symbol&&(t=n(a.value,f.fee)),{fee:e,amount:"SOL"===a.token.symbol?n(a.value):`${Ra(a.value,a.token.decimals)} ${a.token.symbol}`.trim(),total:t,balance:r}):{fee:e,balance:r}}),[f,h,U,F,W?.address,E,b]),H=i((()=>{if(M||!f||b.isLoading||E>0)return!1;let e=f.instructions[E];if(!e)return!1;let t=0n;return W?.address===f.spender&&(t+=f.fee),"value"in e&&W?.address===e.fromAccount&&"SOL"===e.token.symbol&&(t+=e.value),b.value<t}),[f,b,E,M]);if(o((()=>{!async function(){if(y&&O&&l)try{C(void 0);let e=await Bh({tx:y,connection:O,client:l});w(e),T(0)}catch(e){console.error("Failed to prepare transaction",e),C(e)}}()}),[y,O,l]),o((()=>{(async function(){if(!W||!O)return;A({value:b.value,isLoading:!0});let e=new Bi({name:"mainnet-beta",rpcUrl:O.rpcEndpoint});A({value:await e.getBalance(W.address).catch((()=>0n))??0n,isLoading:!1})})().catch(console.error)}),[f,O]),!(y&&e?.sendSolanaTransaction&&W&&O)){let n=Error("Invalid transaction request");/*#__PURE__*/return t(ch,{error:n,onClick:()=>{e?.sendSolanaTransaction?.onFailure(n),c({shouldCallAuthOnSuccess:!1})}})}let V=()=>{if(!_)return I?e?.sendSolanaTransaction?.onSuccess(I):(e?.sendSolanaTransaction?.onFailure(S??v??Error("User exited the modal before submitting the transaction")),T(0)),c({shouldCallAuthOnSuccess:!1})};n.current=V;let $=e.sendSolanaTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?/*#__PURE__*/t("img",{src:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:e.sendSolanaTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,j=!!(e.funding&&e.funding.supportedOptions.length>0),G=H&&j;return I?/*#__PURE__*/t(Cg,{instructions:f?.instructions.reduce(((e,t)=>("ata-creation"===t.type&&e.push({tokenAccountOwner:t.owner,tokenAccount:t.ata}),"spl-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount||t.toAta,amount:t.value,token:t.token}),"sol-transfer"===t.type&&e.push({from:t.fromAccount,to:t.toAccount,amount:t.value,token:t.token}),e)),[])??[],fees:0===E?I.fees:0n,onClose:V,transactionInfo:e.sendSolanaTransaction?.uiOptions.transactionInfo,solPrice:U,receiptHeader:e.sendSolanaTransaction?.uiOptions.successHeader,receiptDescription:e.sendSolanaTransaction?.uiOptions.successDescription,rpcEndpoint:O.rpcEndpoint,signOnly:M}):S?/*#__PURE__*/t(Qy,{transactionError:S,connection:O,onClose:V,network:"solana",onRetry:async()=>{R(void 0);let{blockhash:e}=await O.getLatestBlockhash();Uh(y)?y.message.recentBlockhash=e:y.recentBlockhash=e,g(y)}}):/*#__PURE__*/t(qy,{img:$,title:e.sendSolanaTransaction?.uiOptions?.transactionInfo?.title||"Confirm transaction",subtitle:e.sendSolanaTransaction?.uiOptions?.description||`${u.name} wants your permission to approve the following transaction.`,cta:G?"Add funds":e.sendSolanaTransaction?.uiOptions?.buttonText||"Approve",transactionIndex:E,maxIndex:P-1,network:"mainnet-beta"==D?"Solana":D,blockExplorerUrl:"https://explorer.solana.com",total:h?z?.total:B?.total,amount:h?z?.amount:B?.amount,fee:h?z?.fee:B?.fee,balance:h?z?.balance:B?.balance,from:B?.from,to:B?.to,tokenAccount:B?.tokenAccount,tokenAccountOwner:B?.tokenAccountOwner,tokenAddress:B?.tokenAddress,transactingWalletAddress:W.address,programAddress:B?.program,disabled:H&&!j,isSubmitting:_,isPreparing:!f||b.isLoading,isTokenPriceLoading:h&&F,isMissingFunds:H,submitError:S??void 0,parseError:v,onClick:G?async()=>{if(!W)return;if(!j)throw Error("Funding wallet is not enabled");let t=cr.FUNDING_METHOD_SELECTION_SCREEN;r({...e,funding:{...e.funding,methodScreen:t}}),a(t)}:async()=>{if(E<(f?.instructions.length??1)-1)T(E+1);else try{k(!0);let t=await m();if(_||!t||!W||!d||!p||!L)return;let{rootWallet:n}=Dr(p,W.address);if(!n)throw Error("No root wallet for transacting wallet found");let{entropyId:r,entropyIdVerifier:a}=jn(n);if(M)await Wy({tx:y,accessToken:t,walletProxy:d,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:W.address,transactingWalletIndex:W.walletIndex??0}),N(Fh("",y,null));else{let{signature:n,receipt:i}=await My({tx:y,accessToken:t,connection:O,walletProxy:d,entropyId:r,entropyIdVerifier:a,transactingWalletAddress:W.address,transactingWalletIndex:W.walletIndex??0,transactionOptions:e.sendSolanaTransaction?.transactionOptions});N(Fh(n,y,i))}}catch(e){console.warn({transaction:y,error:e}),R(e)}finally{k(!1)}},onClose:V,onBack:E>0&&P>1?()=>T(E-1):void 0})},[cr.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN]:()=>{let{app:r,data:a}=lr(),{closePrivyModal:i}=x(),[l,c]=s(!1),[d,h]=s(),{address:u,onDelegate:p,onSuccess:m,onError:y}=a.delegatedActions.consent,g=async()=>{l?m():y(d??new T("User declined delegating actions.")),i({shouldCallAuthOnSuccess:!1})};return o((()=>{if(!l&&!d)return;let e=setTimeout(g,pr);return()=>clearTimeout(e)}),[l,d]),/*#__PURE__*/e(n,l||d?{children:[/*#__PURE__*/t(ot,{onClose:g}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(ut,{children:[d?/*#__PURE__*/t(ei,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(ci,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(It,{height:20}),/*#__PURE__*/t(Ql,{title:d?"Something went wrong":"Success!",description:d?"Please try again.":`You’ve successfully granted delegated action permissions to ${r.name}.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}:{children:[/*#__PURE__*/t(ot,{closeable:!0,onClose:g}),/*#__PURE__*/t(di,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(Nl,{style:{marginTop:24,color:"var(--privy-color-foreground)"},children:"Enable offline access"}),/*#__PURE__*/e(xl,{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:u,title:"Wallet",isLoading:!1}),/*#__PURE__*/e(Wc,{style:{marginTop:24},children:[/*#__PURE__*/t(dt,{onClick:g,children:"Not now"}),/*#__PURE__*/t(st,{onClick:async()=>{try{await p(),c(!0)}catch(e){h(e)}},children:"Accept"})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_DELEGATED_ACTIONS_REVOKE_SCREEN]:()=>{let{app:r,data:a}=lr(),{closePrivyModal:i}=x(),[l,c]=s(!1),[d,h]=s(),{onRevoke:u,onSuccess:p,onError:m}=a.delegatedActions.revoke,y=async()=>{l?p():m(d??new T("User declined revoking access to their delegated wallet.")),i({shouldCallAuthOnSuccess:!1})};return o((()=>{if(!l&&!d)return;let e=setTimeout(y,pr);return()=>clearTimeout(e)}),[l,d]),/*#__PURE__*/e(n,l||d?{children:[/*#__PURE__*/t(ot,{onClose:y}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(ut,{children:[d?/*#__PURE__*/t(ei,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(ci,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(It,{height:20}),/*#__PURE__*/t(Ql,{title:d?"Something went wrong":"Success!",description:d?"Please try again.":"You've successfully revoked permissions."})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}:{children:[/*#__PURE__*/t(ot,{closeable:!0,onClose:y}),/*#__PURE__*/t(hi,{width:56,height:56,style:{margin:"auto"}}),/*#__PURE__*/t(Nl,{style:{marginTop:24},children:"Revoke offline access to wallet"}),/*#__PURE__*/e(xl,{children:["By confirming, ",r.name," will no longer be able to use this wallet on your behalf when you are not online."]}),/*#__PURE__*/e(Pc,{style:{marginTop:24},children:[/*#__PURE__*/t(dt,{onClick:y,children:"Deny"}),/*#__PURE__*/t(st,{onClick:async()=>{try{await u(),c(!0)}catch(e){h(e)}},children:"Confirm"})]}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_METHOD_SELECTION_SCREEN]:()=>{let{wallets:r}=Tr(),{wallets:a}=oa(),{navigate:s,data:l,setModalData:c}=lr(),{client:d}=x(),h=dr(),u=l?.funding,p=Yu(np),m=Yu(rp),y="solana"===u.chainType,g=y?void 0:u,f=i((()=>((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&&Ii(Number(n.chain.id),d),u=!!l||d&&Ni(Number(n.chain.id),d),p=[];for(let o of(n.preferredCardProvider&&n.supportedOptions.sort((e=>e.provider===n.preferredCardProvider?-1:1)),n.supportedOptions))"card"===o.method&&"coinbase"===o.provider&&u&&p.push((()=>Xu(t,n,r,a,i,"buy"))),"card"===o.method&&"moonpay"===o.provider&&h&&d&&p.push((()=>ep(t,n,e,d,r,a,i,"credit_debit_card")));for(let e of n.supportedOptions)"exchange"===e.method&&"coinbase"===e.provider&&u&&(o=()=>Xu(t,n,r,a,i,"buy"));for(let e of i?.funding?.supportedOptions??[])"wallets"===e.method&&(s=()=>a(cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN));return{onFundWithCard:p,onFundWithExchange:o,onFundWithWallet:s}})(h,d,u,c,s,l)),[h,d,u,l,c,s]);o((()=>{if(u?.defaultFundingMethod&&u.usingDefaultFundingMethod)switch(c({funding:{...u,usingDefaultFundingMethod:!1}}),u?.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":s(cr.FUNDING_MANUAL_TRANSFER_SCREEN)}}),[]),o((()=>{g?.erc20Address&&!g.erc20ContractInfo&&ln({address:g.erc20Address,chain:g.chain,rpcConfig:h.rpcConfig,privyAppId:h.id}).then((e=>{c({...l,funding:{...g,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}})})).catch(console.error)}),[g?.erc20Address,g?.chain]);let w=y?a.find((({address:e})=>e===u.address)):r.find((({address:e})=>C(e)===C(u.address))),v=ft(w?.walletClientType||"unknown"),E=v?.name||"wallet",T=w&&"privy"!==w.walletClientType?E:h.name,b=!(!g?.erc20Address||g?.erc20ContractInfo);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/e("h3",{children:["Add funds to your"," ",T?.toLowerCase().endsWith("wallet")?T:T+" wallet"]}),/*#__PURE__*/e(bu,{children:[u.errorMessage&&/*#__PURE__*/t(Vu,{theme:h.appearance.palette.colorScheme,children:u.errorMessage}),f.onFundWithCard?.[0]&&/*#__PURE__*/e(il,{disabled:b,onClick:f.onFundWithCard[0],children:[/*#__PURE__*/t(Au,{children:/*#__PURE__*/t(Qi,{style:{width:24}})}),"Pay with card",p?/*#__PURE__*/t(qu,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):m?/*#__PURE__*/t(Ku,{style:{marginLeft:"auto",maxWidth:"100%",width:"auto",height:"0.875rem"}}):null]}),f.onFundWithExchange&&/*#__PURE__*/e(il,{disabled:b,onClick:f.onFundWithExchange,children:[/*#__PURE__*/t(Au,{children:/*#__PURE__*/t(Ji,{style:{width:24}})}),"Transfer from an exchange"]}),f.onFundWithWallet&&/*#__PURE__*/e(il,{disabled:b,onClick:f.onFundWithWallet,children:[/*#__PURE__*/t(Au,{children:/*#__PURE__*/t(cn,{style:{width:24}})}),"Transfer from wallet"]}),/*#__PURE__*/e(il,{disabled:b,onClick:()=>s(cr.FUNDING_MANUAL_TRANSFER_SCREEN),children:[/*#__PURE__*/t(Au,{children:/*#__PURE__*/t(Xi,{style:{width:24}})}),"Receive funds"]}),u?.showAlternateFundingMethod&&f.onFundWithCard?.[1]&&/*#__PURE__*/t(ju,{theme:h.appearance.palette.colorScheme,children:/*#__PURE__*/e(Ru,{children:["Having trouble or facing location restrictions?"," ",/*#__PURE__*/t(Ou,{onClick:f.onFundWithCard[1],children:"Try a different provider."})]})})]}),/*#__PURE__*/t(ct,{})]})},[cr.MOONPAY_STATUS_SCREEN]:()=>{let{app:r,data:a,setModalData:i,navigateBack:o}=lr(),{closePrivyModal:s}=x(),{externalTransactionId:l}=a?.moonpayStatus,c=la(l||null,r.fundingMethodConfig.moonpay.useSandbox??!1);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{title:"Fund account",backFn:()=>{let e={...a?.funding,showAlternateFundingMethod:!0};e.usingDefaultFundingMethod&&(e.usingDefaultFundingMethod=!1),i({funding:e}),o()}}),/*#__PURE__*/t(sp,{status:c,onClickCta:s}),/*#__PURE__*/t(ct,{})]})},[cr.COINBASE_ONRAMP_STATUS_SCREEN]:()=>{let{data:r,setModalData:a,navigate:i,navigateBack:c}=lr(),{closePrivyModal:d,createAnalyticsEvent:h,client:u}=x(),[p,m]=s("pending-in-flow"),y=l(0),g={...r?.funding,showAlternateFundingMethod:!0};g.usingDefaultFundingMethod&&(g.usingDefaultFundingMethod=!1);let{partnerUserId:f,popup:w}=r?.coinbaseOnrampStatus??{};return o((()=>{if("pending-in-flow"===p||"pending-after-flow"===p){let e=setInterval((async()=>{if(f)try{let{status:e}=await u.getCoinbaseOnRampStatus({partnerUserId:f});if("success"===e)return void m("success");if("failure"===e)throw Error("There was an error completing Coinbase Onramp flow.");if(y.current>=3)return a({funding:g}),void i(cr.FUNDING_METHOD_SELECTION_SCREEN);w?.closed&&(y.current=y.current+1,m("pending-after-flow"))}catch(e){console.error(e),m("error"),h({eventName:ia,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),a({funding:{...g,errorMessage:"Something went wrong adding funds. Please try again or use another method."}}),i(cr.FUNDING_METHOD_SELECTION_SCREEN)}}),1500);return()=>clearInterval(e)}}),[f,w,p]),/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{title:"Fund account",backFn:()=>{a({funding:g}),c()}},"header"),/*#__PURE__*/t(Fu,{status:p,onClickCta:d}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:()=>{let r,{connectors:a}=x(),{app:i,setModalData:l,data:c,navigate:d}=lr(),{wallets:h}=Tr(),{wallets:u}=oa(),[p,m]=s("default"),y="solana"===c?.funding?.chainType,g=!!c?.funding?.crossChainBridgingEnabled;r="ethereum"===c?.funding?.chainType?c.funding.erc20Address&&!c.funding.isUSDC?"ethereum-only":g&&!c.funding.chain.testnet?"ethereum-and-solana":"ethereum-only":g?"ethereum-and-solana":"solana-only";let f=h.filter((e=>"privy"!==e.walletClientType)),w=f.map((e=>e.walletClientType)),v=u.filter((e=>"privy"!==e.walletClientType)),C=v.map((e=>e.walletClientType)),E=[],T={...c.funding};T.usingDefaultFundingMethod&&(T.usingDefaultFundingMethod=!1);let b=({address:e,walletChainType:t})=>{l({...c,funding:{...T,connectedWalletAddress:e,onContinueWithExternalWallet:()=>d(_({destChainType:y?"solana":"ethereum",sourceChainType:t}))}}),d(cr.FUNDING_EDIT_AMOUNT_SCREEN)};"solana-only"!==r&&E.push(...f.map(((e,n)=>/*#__PURE__*/t(up,{onClick:()=>b({address:e.address,walletChainType:"ethereum"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),"ethereum-only"!==r&&E.push(...v.map(((e,n)=>/*#__PURE__*/t(up,{onClick:()=>b({address:e.address,walletChainType:"solana"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},n)))),E.push(...xc({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 A=/*#__PURE__*/t(hp,{text:"More wallets",onClick:()=>m("overflow")}),_=({sourceChainType:e,destChainType:t})=>"ethereum"===e&&"solana"===t?cr.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN:"ethereum"===e&&"ethereum"===t?cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN:"solana"===e&&"ethereum"===t?cr.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN:cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN;return o((()=>{l({...c,externalConnectWallet:{onCompleteNavigateTo:({walletChainType:e})=>(l({...c,funding:{...T,onContinueWithExternalWallet:()=>{d(_({destChainType:y?"solana":"ethereum",sourceChainType:e??"ethereum"}))}}}),cr.FUNDING_EDIT_AMOUNT_SCREEN)}})}),[]),/*#__PURE__*/e(n,"overflow"===p?{children:[/*#__PURE__*/t(ot,{backFn:()=>m("default")},"header"),/*#__PURE__*/e(tl,{children:[/*#__PURE__*/t(Rt,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),E]}),/*#__PURE__*/t(ct,{})]}:{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(Ql,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),/*#__PURE__*/e(tl,{children:[E.length>4?E.slice(0,3):E,E.length>4&&A]}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_EDIT_AMOUNT_SCREEN]:()=>{let{data:r,setModalData:a}=lr(),i=r?.funding,o="solana"===i.chainType,s=l(null),{tokenPrice:c}=Oh(o?"solana":i.chain.id),d=o?void 0:i,h=!(!d?.erc20Address||d?.erc20ContractInfo),u=o?"SOL":i.erc20Address?i.erc20ContractInfo?.symbol:i.chain.nativeCurrency.symbol||"ETH",p=parseFloat(i.amount),m=!isNaN(p)&&p>0,y=c?en(i.amount,c):void 0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(St,{children:"Confirm or edit amount"}),/*#__PURE__*/e(sn,{style:{marginTop:"32px"},children:[/*#__PURE__*/t(_u,{children:h?/*#__PURE__*/t(kh,{size:"50px"}):/*#__PURE__*/e(n,{children:[/*#__PURE__*/e(ku,{onClick:()=>s.current?.focus(),children:[/*#__PURE__*/t(Nu,{ref:s,value:i.amount,onChange:e=>{let t=e.target.value;/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1&&a({...r,funding:{...i,amount:t}})}}),/*#__PURE__*/t(xu,{children:u})]}),!d?.erc20Address&&/*#__PURE__*/t(Su,{children:y&&m?`${y} USD`:""})]})}),/*#__PURE__*/t(Jt,{style:{marginTop:"1rem"},disabled:!m,onClick:i.onContinueWithExternalWallet,children:"Continue"})]}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:l}=x(),{navigate:c,setModalData:d,app:h,data:u}=lr(),{wallets:p}=Tr(),[m,y]=s(!1),[g,f]=s(0n),[w,v]=s(!1),[C,E]=s(null),[b,_]=s(null),[k,I]=s([]),[N,S]=s(0),[R,O]=s(!1),[W,M]=s(!1),[P,L]=s(!1),[D,U]=s(!1),[F,B]=s(),[z,H]=s();if(!u?.funding||"ethereum"!==u.funding.chainType)throw Error("Invalid funding data");let{erc20ContractInfo:V,chain:$,connectedWalletAddress:j}=u.funding,G=u.funding.address,q=u.funding.erc20Address,[K,Y]=s(u.funding.amount);o((()=>{q&&!V&&E(Error("Unable to fetch token details"))}),[]);let Z=!!q&&!!V,J=Z?BigInt(parseFloat(K)*10**V.decimals):Oa(K),Q=j?p.find((({address:e})=>e===j)):p[0],X=ft(Q?.walletClientType||"unknown"),ee=X?.name||"wallet",[te,ne]=s(null);o((()=>{(async()=>{if(!Q)return;let e=await Q.getEthereumProvider();ne(Na({account:Q.address,transport:xa(e)}).extend(Sa))})().catch(console.error)}),[Q]);let[re,ae]=s(0n);o((()=>{ka({chain:$,transport:Ia(Va($,r,a))}).getBalance({address:G}).then(ae).catch(console.error)}),[]);let[ie,oe]=s(0n);o((()=>{Z&&Xt({chain:$,address:G,appId:a,rpcConfig:r,erc20Address:q}).then((e=>oe(e.balance))).catch(console.error)}),[]);let{tokenPrice:se}=Oh($.id),[le,ce]=s({to:G,chain:$,value:J,data:void 0});o((()=>{(async()=>{let e,t;if(!te||!Q||R||P)return;O(!0);let n=ka({chain:le.chain,transport:Ia(Va(le.chain,r,a))});if(Z&&!le.data)return await n.simulateContract({address:q,chain:le.chain,abi:Uu,functionName:"transfer",args:[G,J],account:Q.address}).catch((e=>{console.warn("Simulated token transfer failed with error, fetching bridge options.",e)}))?(O(!1),void ce({to:q,chain:le.chain,data:Wa({abi:Uu,functionName:"transfer",args:[G,J]}),value:"0x0"})):(O(!1),void v(!0));try{e=await n.prepareTransactionRequest({account:Q.address,to:le.to,chain:le.chain,data:le.data,value:BigInt(le.value??0)})}catch(e){if(console.error(e),k.length>1)_(e.shortMessage??"Something went wrong");else if(W&&0===k.length)return void E(new T(`Wallet ${Ct(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))}if(!e)return O(!1),void v(!0);O(!1),L(!0),y(!0),f(e.gas);try{await te.switchChain({id:le.chain.id})}catch(e){await te.addChain({chain:le.chain}),await te.switchChain({id:le.chain.id})}try{t=await te.sendTransaction(e)}catch(e){if(console.error(e),"TransactionExecutionError"===e.name)if(k.length<1){let t=e.shortMessage;(e.shortMessage.includes("rejected the request")||e.details.includes("rejected the request"))&&(t="User rejected the request."),E(new T(t,void 0,A.TRANSACTION_FAILURE))}else _(e.shortMessage??"Something went wrong")}if(t)return await te.waitForTransactionReceipt({hash:t}),L(!1),W?(B(t),void H("pending")):(U(!0),void l({eventName:ia,payload:{provider:"external",status:"success",txHash:t,address:Q.address,chainId:le.chain.id,chainType:"ethereum",value:le.value?Ra(BigInt(le.value),V?.decimals??18):void 0,token:V?.symbol??q??"ETH",destinationAddress:G,destinationChainId:$.id,destinationChainType:"ethereum",destinationValue:J?Ra(J,V?.decimals??18):void 0,destinationToken:V?.symbol??q??$.nativeCurrency.name}}));L(!1)})().catch(console.error)}),[te,le]),o((()=>{(async()=>{if(!w||!te||!Q)return;let e=vr(h.chains).filter((e=>e.id!==$.id&&!!e.testnet==!!$.testnet));Z&&e.unshift($);let t=await $h({chains:e,address:Q.address,appId:a,rpcConfig:r}),n=Z?t.filter((e=>e.balance>0n)):t.filter((e=>e.balance>J));if(n.length<1)return void E(new T(`Wallet ${Ct(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({quote:await ih({isTestnet:!!$.testnet,input:nh({amount:J.toString(),user:Q.address,recipient:G,destinationChainId:$.id,destinationCurrency:q,originChainId:e.chain.id})}),...e}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void E(new T(`Wallet ${Ct(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));let o=i.map((e=>({bridgeTx:oh(e.quote),balance:e.balance,chain:e.chain}))).filter((e=>!!e.bridgeTx));if(o.length>1)return void I(o);let s=o[0];s?(M(!0),ce({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):E(new T(`Wallet ${Ct(Q.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))})().catch(console.error)}),[w]),sh({transactionHash:F,wallet:Q,isTestnet:!!$.testnet,bridgingStatus:z,setBridgingStatus:H,onSuccess({transactionHash:e,wallet:t}){M(!1),U(!0),l({eventName:ia,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:le.chain.id,chainType:"ethereum",value:le.value?Ra(BigInt(le.value),V?.decimals??18):void 0,token:V?.symbol??q??"ETH",destinationAddress:G,destinationChainId:$.id,destinationChainType:"ethereum",destinationValue:J?Ra(J,V?.decimals??18):void 0,destinationToken:V?.symbol??q??$.nativeCurrency.name}})},onFailure({error:e}){M(!1),E(e)}}),o((()=>{if(!C)return;let e={error:C,previousScreen:cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN};d({funding:u?.funding,sendTransaction:u?.sendTransaction,errorModalData:e}),c(cr.ERROR_SCREEN,!1)}),[C]);let de=!Z&&se?en(K??"0",se):void 0,he=Z?g:rn([g,J]),ue=he&&se?tn(he,se):void 0,pe=he?Yt(he,"ETH"):void 0,me=g&&se?tn(g,se):void 0,ye=g?Yt(g,"ETH"):void 0;if(o((()=>{if(!D)return;let e=setTimeout(i,_r);return()=>clearTimeout(e)}),[D]),D/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success!",description:`You’ve successfully added ${K} ${Z?V.symbol:$.nativeCurrency.symbol} to your ${h.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let ge=Z?`${nn({amount:ie,decimals:V.decimals})} ${V.symbol}`:Yt(re,$.nativeCurrency.symbol,3,!0),fe=k[N];return k.length>1&&fe?/*#__PURE__*/t(Wu,{displayName:ee,configuredFundingChain:$,formattedBalance:ge,fundingAmount:K,fundingCurrency:Z?V.symbol:$.nativeCurrency.symbol,fundingAmountInUsd:de,options:k,selectedOption:fe,isPreparing:R,isSubmitting:P,addressToFund:G,fundingWalletAddress:Q?.address||"",errorMessage:b,onSubmit:()=>{u.funding?.amount!==K?async function(){if(Q&&fe)try{let e=await ih({isTestnet:!!$.testnet,input:nh({amount:J.toString(),user:Q.address,recipient:G,destinationChainId:$.id,destinationCurrency:q,originChainId:fe.chain.id})}),t=oh(e);if(!t)throw Error("Invalid transaction request");M(!0),ce({data:t.data,to:t.to,value:t.value,chain:fe.chain})}catch(e){console.error(e),E(new T("Unable to fetch quotes for bridging",e,A.INSUFFICIENT_BALANCE))}}().catch(console.error):ce({to:fe.bridgeTx.to,data:fe.bridgeTx.data,value:fe.bridgeTx.value,chain:fe.chain})},onSelect:e=>{e!==N&&(_(null),S(e))},onAmountChange:Y}):m&&g&&Q&&u?.funding?/*#__PURE__*/t(Mu,{wallet:Q,displayName:ee,addressToFund:G,isBridging:W,isErc20Flow:Z,totalPriceInUsd:ue,totalPriceInNativeCurrency:pe,gasPriceInUsd:me,gasPriceInNativeCurrency:ye,chainId:$.id,chainName:$.name}):
16
+ /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(kh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_SOLANA_WALLET_SCREEN]:()=>{let{closePrivyModal:r,createAnalyticsEvent:a}=x(),{navigate:i,setModalData:c,app:d,data:h}=lr(),{wallets:u}=oa(),p=ra(),[m,y]=s(0n),[g,f]=s(null),[w,v]=s(!1),[C,E]=s(!1),b=l(!1);if(!h?.funding||"solana"!==h.funding.chainType)throw Error("Invalid funding data");let{address:_,amount:k,cluster:I,connectedWalletAddress:N}=h.funding,S=kr(I),{tokenPrice:R}=Oh("solana"),{fundingAmountInBaseUnit:O,totalPriceInUsd:W,totalPriceInNativeCurrency:M,feePriceInNativeCurrency:P,feePriceInUsd:L}=Dh({amount:k,fee:m,tokenPrice:R}),D=N?u.find((({address:e})=>e===N)):u[0],U=ft(D?.walletClientType||"unknown"),F=U?.name||"wallet";return o((()=>{(async()=>{if("solana"===D?.type&&D.sendTransaction&&!w&&!b.current){b.current=!0;try{let e=p(aa);if(!e)throw new T("Unable to load solana plugin");let{connection:t,transaction:n}=await e.createTransferTransaction({from:D.address,to:_,amount:O,cluster:I}),r=await n.getEstimatedFee(t);null!=r&&y(BigInt(r)),v(!0);let i=await t.simulateTransaction(n);if(i.value.err)return i.value.logs?.find((e=>/insufficient (lamports|funds)/gi.test(e)))?void f(new T(`Wallet ${Ct(D.address,void 0,void 0,"solana")} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",i.value.err),void f(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE)));let o=await D.sendTransaction(n,t);a({eventName:ia,payload:{provider:"external",status:"success",txHash:o,rpcEndpoint:S,address:D.address,value:Ra(O,9),chainType:"solana",clusterName:I.name,token:"SOL",destinationAddress:_,destinationValue:Ra(O,9),destinationChainType:"solana",destinationClusterName:I.name,destinationToken:"SOL"}}),v(!1),E(!0)}catch(e){if(console.error(e),v(!1),/user rejected the request/gi.test(e.message||""))return void f(new T("Transaction was rejected by the user",void 0,A.TRANSACTION_FAILURE));f(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE))}}})().catch(console.error).finally((()=>b.current=!1))}),[]),o((()=>{if(!g)return;let e={error:g,previousScreen:cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),i(cr.ERROR_SCREEN,!1)}),[g]),o((()=>{if(!C)return;let e=setTimeout(r,_r);return()=>clearTimeout(e)}),[C]),C?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success!",description:`You’ve successfully added ${k} SOL to your ${d.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}):D&&w?/*#__PURE__*/t(Mu,{wallet:D,displayName:F,addressToFund:_,isBridging:!1,isErc20Flow:!1,totalPriceInUsd:W,totalPriceInNativeCurrency:M,gasPriceInUsd:L,gasPriceInNativeCurrency:P,chainId:"solana",chainName:I.name}):
17
+ /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(kh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_AWAITING_EVM_TO_SOL_BRIDGING_SCREEN]:()=>{let{rpcConfig:r,appId:a,closePrivyModal:i,createAnalyticsEvent:l}=x(),{navigate:c,setModalData:d,app:h,data:u}=lr(),{wallets:p}=Tr(),m=ra(),[y,g]=s(null),[f,w]=s(null),[v,C]=s([]),[E,b]=s(0),[_,k]=s(!1),[I,N]=s(!1),[S,R]=s(!1),[O,W]=s(!1),[M,P]=s(),[L,D]=s();if(!u?.funding||"solana"!==u.funding.chainType)throw Error("Invalid funding data");let{address:U,cluster:F,connectedWalletAddress:B}=u.funding,[z,H]=s(u.funding.amount),V=B?p.find((({address:e})=>e===B)):p[0],$=ft(V?.walletClientType||"unknown"),j=$?.name||"wallet",[G,q]=s(null);o((()=>{(async()=>{if(!V)return;let e=await V.getEthereumProvider();q(Na({account:V.address,transport:xa(e)}).extend(Sa))})().catch(console.error)}),[V]);let[K,Y]=s(0n),Z=Ph(K);o((()=>{let e=m(aa);e?e.getBalance({address:U,cluster:F}).then((e=>Y(BigInt(e)))):console.warn("Unable to load solana plugin, skipping balance")}),[]);let[J,Q]=s(),{tokenPrice:X}=Oh("solana"),{fundingAmountInBaseUnit:ee,fundingAmountInUsd:te}=Dh({amount:z,fee:0n,tokenPrice:X});if(o((()=>{(async()=>{if(!G||!V)return;let e=["testnet","devnet"].includes(F.name);e&&console.warn("Solana testnets are not supported for bridging");let t=vr(h.chains).filter((({testnet:t})=>!!t===e)),n=(await $h({chains:t,address:V.address,appId:a,rpcConfig:r})).filter((e=>e.balance>0n));if(n.length<1)return void g(new T(`Wallet ${Ct(V.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));n.sort(((e,t)=>Number(t.balance-e.balance)));let i=(await Promise.allSettled(n.map((async e=>({...e,quote:await ih({isTestnet:!1,input:nh({amount:ee.toString(),user:V.address,recipient:U,destinationChainId:br,destinationCurrency:Ar,originChainId:e.chain.id})})}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(i.length<1)return void g(new T(`Unable to fetch quotes for bridging. Wallet ${Ct(V.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));let o=i.map((({quote:e,balance:t,chain:n})=>({bridgeTx:oh(e),balance:t,chain:n}))).filter((({bridgeTx:e})=>!!e));if(o.length>1)return void C(o);let s=o.at(0);s?(N(!0),Q({data:s.bridgeTx.data,to:s.bridgeTx.to,value:s.bridgeTx.value,chain:s.chain})):g(new T(`Unable to select bridge option from quotes. Wallet ${Ct(V.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))})().catch(console.error)}),[G]),o((()=>{(async()=>{let e,t;if(!G||!V||_||S||!J)return;k(!0);let n=ka({chain:J.chain,transport:Ia(Va(J.chain,r,a))});try{e=await n.prepareTransactionRequest({account:V.address,to:J.to,chain:J.chain,data:J.data,value:BigInt(J.value??0)})}catch(e){console.error(e),v.length>1&&w(e.shortMessage??"Something went wrong")}if(e){k(!1),R(!0);try{await G.switchChain({id:J.chain.id})}catch(e){await G.addChain({chain:J.chain}),await G.switchChain({id:J.chain.id})}try{t=await G.sendTransaction(e)}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(v.length<1?g(new T(e.shortMessage,void 0,A.TRANSACTION_FAILURE)):w(e.shortMessage??"Something went wrong"))}if(t)return await G.waitForTransactionReceipt({hash:t}),I?(D("pending"),void P(t)):(R(!1),W(!0),void l({eventName:ia,payload:{provider:"external",status:"success",txHash:t,address:V.address,chainId:J.chain.id,chainType:"ethereum",value:J.value?Ra(BigInt(J.value),18):void 0,token:"ETH",destination:U,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ra(ee,9),destinationToken:"SOL"}}));R(!1)}else k(!1)})().catch(console.error)}),[G,J]),sh({transactionHash:M,wallet:V,isTestnet:!1,bridgingStatus:L,setBridgingStatus:D,onSuccess({transactionHash:e,wallet:t}){N(!1),W(!0),l({eventName:ia,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainId:J?.chain.id,chainType:"ethereum",value:J?.value?Ra(BigInt(J.value),18):void 0,token:"ETH",destination:U,destinationClusterName:"mainnet-beta",destinationChainType:"solana",destinationValue:Ra(ee,9),destinationToken:"SOL"}})},onFailure({error:e}){N(!1),g(e)}}),o((()=>{if(!y)return;let e={error:y,previousScreen:cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN};d({funding:u?.funding,sendTransaction:u?.sendTransaction,errorModalData:e}),c(cr.ERROR_SCREEN,!1)}),[y]),o((()=>{if(!O)return;let e=setTimeout(i,_r);return()=>clearTimeout(e)}),[O]),O/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success!",description:`You’ve successfully added ${z} SOL to your ${h.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]});let ne=v[E];return v.length>1&&ne?/*#__PURE__*/t(Wu,{displayName:j,configuredFundingChain:F,formattedBalance:Z,fundingAmount:z,fundingCurrency:"SOL",fundingAmountInUsd:te,options:v,selectedOption:ne,isPreparing:_,isSubmitting:S,addressToFund:U,fundingWalletAddress:V?.address||"",errorMessage:f,onSubmit:()=>{u.funding?.amount!==z?async function(){if(V&&ne)try{let e=await ih({isTestnet:!1,input:nh({amount:ee.toString(),user:V.address,recipient:U,destinationChainId:br,destinationCurrency:Ar,originChainId:ne.chain.id})}),t=oh(e);if(!t)throw Error("Invalid transaction request");N(!0),Q({data:t.data,to:t.to,value:t.value,chain:ne.chain})}catch(e){console.error(e),g(new T("Unable to fetch quotes for bridging",e,A.INSUFFICIENT_BALANCE))}}().catch(console.error):Q({to:ne.bridgeTx.to,data:ne.bridgeTx.data,value:ne.bridgeTx.value,chain:ne.chain})},onSelect:e=>{e!==E&&(w(null),b(e))},onAmountChange:H}):S&&V?/*#__PURE__*/t(Mu,{wallet:V,displayName:j,addressToFund:U,isBridging:I,isErc20Flow:!1,chainId:"solana",chainName:F.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
18
+ /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(kh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_AWAITING_SOL_TO_EVM_BRIDGING_SCREEN]:function(){let{closePrivyModal:r,createAnalyticsEvent:a}=x(),{navigate:i,setModalData:c,app:d,data:h}=lr(),{wallets:u}=oa(),p=l(!1),m=ra(),[y,g]=s(!1),[f,w]=s(!1),[v,C]=s(null),[E,b]=s(),[_,k]=s();if(!h?.funding||"ethereum"!==h.funding.chainType)throw Error("Invalid funding data");let{amount:I,connectedWalletAddress:N,chain:S,cluster:R,isUSDC:O}=h.funding,W=h.funding.address,M=h.funding.erc20Address,P=h.funding.isUSDC?"USDC":S.nativeCurrency.symbol,L=R??{name:"mainnet-beta"},D=N?u.find((({address:e})=>e===N)):u[0],U=ft(D?.walletClientType||"unknown"),F=U?.name||"wallet";return o((()=>{(async function(){if(!D||!S||p.current)return;let e=m(aa);if(!e)return void C(new T("Unable to solana plugin"));p.current=!0,S?.testnet&&console.warn("Solana testnets are not supported for bridging");let t=O?1e6*parseFloat(I):Oa(I),n=await ih({isTestnet:!!S.testnet,input:nh({amount:t.toString(),user:D.address,recipient:W,destinationChainId:S.id,originChainId:br,originCurrency:O?Ir:Ar,destinationCurrency:O?M:void 0})}).catch(console.error);if(!n)return void C(new T(`Unable to fetch quotes for bridging. Wallet ${an(D.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE));let r=await e.createBridgeTransactionFromRelayQuote({quote:n,from:D.address,cluster:L});if(r)try{g(!0);let{connection:e,transaction:t}=r,a=await e.simulateTransaction(t);if(a.value.err)return a.value.logs?.find((e=>/insufficient (lamports|funds)/gi.test(e)))?void C(new T(`Wallet ${an(D?.address)} does not have enough funds. ${n.details.currencyIn.amountFormatted} ${P} are needed to complete the transaction.`,void 0,A.INSUFFICIENT_BALANCE)):(console.error("Transaction failed:",a.value.err),void C(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE)));let i=await D.sendTransaction(t,e),o=await e.confirmTransaction(i);if(o.value.err)return console.error("Transaction failed:",o.value.err),void C(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE));b(i),k("pending")}catch(e){if(console.error(e),/user rejected the request/gi.test(e.message||""))return void C(new T("Transaction was rejected by the user",void 0,A.TRANSACTION_FAILURE));C(new T("Something went wrong",void 0,A.TRANSACTION_FAILURE))}else C(new T(`Unable to select bridge option from quotes. Wallet ${an(D.address)} does not have enough funds.`,void 0,A.INSUFFICIENT_BALANCE))})().catch(console.error)}),[]),sh({transactionHash:E,wallet:D,isTestnet:!1,bridgingStatus:_,setBridgingStatus:k,onSuccess({transactionHash:e,wallet:t}){g(!1),w(!0),a({eventName:ia,payload:{provider:"external",status:"success",txHash:e,address:t.address,chainType:"solana",clusterName:L.name,token:"SOL",destinationAddress:W,destinationChainId:S.id,destinationChainType:"ethereum",destinationValue:I,destinationToken:O?"USDC":"ETH"}})},onFailure({error:e}){g(!1),C(e)}}),o((()=>{if(!f)return;let e=setTimeout(r,_r);return()=>clearTimeout(e)}),[f]),o((()=>{if(!v)return;let e={error:v,previousScreen:cr.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),i(cr.ERROR_SCREEN,!1)}),[v]),f?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/t(ci,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),/*#__PURE__*/t(Ql,{title:"Success!",description:`You’ve successfully added ${I} ${P} to your ${d.name} wallet. It may take a minute before the funds are available to use.`})]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]}):y&&D?/*#__PURE__*/t(Mu,{wallet:D,displayName:F,addressToFund:W,isBridging:y,isErc20Flow:!1,chainId:S.id,chainName:S.name,totalPriceInUsd:void 0,totalPriceInNativeCurrency:void 0,gasPriceInUsd:void 0,gasPriceInNativeCurrency:void 0}):
19
+ /*#__PURE__*/e(n,{children:[/*#__PURE__*/t(_h,{}),/*#__PURE__*/t(kh,{}),/*#__PURE__*/t("div",{style:{marginTop:"1rem"}}),/*#__PURE__*/t(ct,{})]})},[cr.FUNDING_MANUAL_TRANSFER_SCREEN]:()=>{let{wallets:r}=Tr(),{wallets:a}=oa(),{data:l,setModalData:c,navigate:d,lastScreen:h}=lr(),{rpcConfig:u,appId:p,createAnalyticsEvent:m,closePrivyModal:y}=x(),g=dr(),[f,w]=s(void 0),[v,C]=s(!1),E=ra(),T=l?.funding,{reloadBalance:b}=dn({rpcConfig:u,appId:p,address:"ethereum"===T.chainType?T.address:void 0,chain:"ethereum"===T.chainType?T.chain:void 0}),A="solana"===T.chainType,_=A?"SOL":T.erc20Address?T.erc20ContractInfo?.symbol:T.chain.nativeCurrency.symbol,k=A?a.find((({address:e})=>e===T.address)):r.find((({address:e})=>Ct(e)===Ct(T.address)));if(!T)return c({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:h||cr.FUNDING_METHOD_SELECTION_SCREEN},funding:l?.funding,sendTransaction:l?.sendTransaction}),d(cr.ERROR_SCREEN),/*#__PURE__*/t(n,{});o((()=>{let e=A?async function(){if("solana"!==T.chainType)return;let e=E(aa);e?e.getBalance({address:T.address,cluster:T.cluster}).then((e=>{let t=BigInt(e);f&&t>f&&(C(!0),m({eventName:ia,payload:{provider:"manual",status:"success",chainType:"solana",address:k?.address,value:Ra(t-f,9),token:"SOL"}})),w(t)})):console.warn("Unable to load solana plugin, skipping balance")}:async function(){"ethereum"===T.chainType&&(async()=>{if(!T.erc20Address)return await b()??BigInt(0);{let{balance:e}=await Xt({chain:T.chain,address:T.address,erc20Address:T.erc20Address,rpcConfig:u,appId:p});return e}})().then((e=>{f&&e>f&&(C(!0),m({eventName:ia,payload:{provider:"manual",status:"success",chainType:"ethereum",address:k?.address,chainId:T.chain.id,value:Ra(e-f,T.erc20ContractInfo?.decimals??18),token:T.erc20ContractInfo?.symbol??T.erc20Address??"ETH"}})),w(e)})).catch((()=>w(void 0)))},t=setInterval(e,2e3);return e(),()=>clearInterval(t)}),[f]);let I=i((()=>void 0!==f&&f>=parseFloat(T.amount)),[f,T.amount]),N=i((()=>null==f?"":T.isUSDC?xi({amount:f,decimals:6}):A?Ph(f,3,!0,!0):null!=T.erc20ContractInfo?.decimals?xi({amount:f,decimals:T.erc20ContractInfo.decimals}):Si({wei:f})),[f,A,T]),S="ethereum"===T.chainType?T.chain.name:ip[T.cluster.name],R=i((()=>""===T.uiConfig?.receiveFundsTitle?null:/*#__PURE__*/t(St,{children:T.uiConfig?.receiveFundsTitle??`Receive ${T.amount} ${_??""}`.trim()})),[T.uiConfig?.receiveFundsTitle,T.amount,_]),O=i((()=>""===T.uiConfig?.receiveFundsSubtitle?null:/*#__PURE__*/t(Rt,{children:T.uiConfig?.receiveFundsSubtitle??`Scan this code or copy your wallet address to receive funds on ${S}.`})),[T.uiConfig?.receiveFundsSubtitle,S]);/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(_h,{}),R,O,/*#__PURE__*/e(sn,{style:{gap:"1rem",margin:R||O?"1rem 0":"0"},children:[/*#__PURE__*/t(zt,{url:`${T.chainType}:${T.address}`,size:200,squareLogoElement:ap}),/*#__PURE__*/e(ju,{theme:g.appearance.palette.colorScheme,children:["Make sure to send funds on ",S,"."]}),/*#__PURE__*/t(Nt,{title:"Your wallet",errMsg:void 0,showIcon:!0,isLoading:!T||void 0===f,isPulsing:!I,balance:`${N} ${_}`,address:T.address,statusColor:I?"green":"gray"}),v&&/*#__PURE__*/t(st,{onClick:()=>y({shouldCallAuthOnSuccess:!1,isSuccess:!0}),children:"Continue"})]}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN]:()=>{let{closePrivyModal:r}=x(),{data:a,setModalData:i,navigate:o,onUserCloseViaDialogOrKeybindRef:s}=lr(),{onSuccess:l,onFailure:c}=a.setWalletPassword,d=()=>{c(new R("Exited before password was added to wallet")),r({shouldCallAuthOnSuccess:!1})};return s.current=d,/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:d}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(xt,{children:[/*#__PURE__*/e(Lt,{children:[/*#__PURE__*/t(Ti,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),/*#__PURE__*/t(Dt,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:/*#__PURE__*/t(bi,{width:"12px",height:"12px",fill:"white"})})]}),/*#__PURE__*/e(Ql,{title:"Secure Your Account",children:["Please set a password to secure your account.",/*#__PURE__*/t("p",{children:"Losing access to this password and this device will make your account inaccessible."})]})]}),/*#__PURE__*/t(st,{onClick:()=>{i({createWallet:{onFailure:c,onSuccess:l,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),o(cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN)},children:"Add password"}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN]:()=>{let[e,n]=s(null),[r,a]=s(!1),[i,l]=s(null),[c,d]=s(""),{authenticated:h,getAccessToken:u,user:p}=hr(),{walletProxy:m,refreshSessionAndUser:y,closePrivyModal:g,createAnalyticsEvent:f}=x(),{app:w,navigate:v,data:C,onUserCloseViaDialogOrKeybindRef:E}=lr(),{onSuccess:T,onFailure:b}=C.createWallet,A=wr(p),_="user-passcode"===e?.recoveryMethod,k="user-passcode"===A?.recoveryMethod;o((()=>{h||(v(cr.LANDING),b(new O("User must be authenticated before setting a password on a Privy wallet")))}),[h]);let I=()=>i?(b(i),void g({shouldCallAuthOnSuccess:!1})):_?(T(e),void g({shouldCallAuthOnSuccess:!1})):(b(new R("Exited before password was added to wallet")),void g({shouldCallAuthOnSuccess:!1}));E.current=I;/*#__PURE__*/return t(eh,{appName:w?.name||"privy",config:{initiatedBy:"user",onCancel:I},error:i?"An error has occurred, please try again.":void 0,buttonLoading:r,buttonHideAnimations:!1,password:c,isResettingPassword:k,onPasswordGenerate:()=>d($d()),onPasswordChange:d,onSubmit:async()=>{_?(T(e),g({shouldCallAuthOnSuccess:!1})):(a(!0),l(null),await(async()=>{let e=await u();if(e&&A?.address&&c&&m)try{f({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k}});let{entropyId:t,entropyIdVerifier:r}=jn(A);if(!(await m.setRecovery({accessToken:e,entropyId:t,entropyIdVerifier:r,recoveryPassword:c,recoveryMethod:"user-passcode"})).entropyId)return l(new R("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k,reason:"error setting password"}});let a=await y(),i=wr(a);if(!i)return l(new R("Error setting password on privy wallet")),void f({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k,reason:"wallet disconnected"}});n(i),f({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:A.address,existingRecoveryMethod:A.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:k}})}catch(e){console.warn(e),l(e instanceof Error?e:Error("Error setting password on privy wallet")),f({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:A.address,reason:e}})}})(),a(!1))},onClose:I})},[cr.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN]:()=>{let{app:e,navigate:n,data:r,onUserCloseViaDialogOrKeybindRef:a}=lr(),[i,l]=s(""),[c,d]=s(!1),[h,u]=s(),[p,m]=s(null),{authenticated:y,user:g}=hr(),{closePrivyModal:f,isNewUserThisSession:w,initializeWalletProxy:v}=x(),{onSuccess:C,onFailure:E,callAuthOnSuccessOnClose:T}=r.createWallet,{createWallet:b}=cd(),[A,_]=s(null),k=new Ge((async()=>{try{let e=await b({recoveryPassword:h,user:g});if(!e)return;_(e),w?n(cr.EMBEDDED_WALLET_CREATED_SCREEN):(C(e),f({shouldCallAuthOnSuccess:T}))}catch(e){l(e.message)}}));o((()=>{p||v(3e4).then((e=>m(e)))}),[p]),o((()=>{if(!y||!g)return n(cr.LANDING),void E(Error("User must be authenticated before creating a Privy wallet"))}),[y]),a.current=()=>null;/*#__PURE__*/return t(eh,{config:{initiatedBy:"automatic"},appName:e?.name||"privy",loading:!p,buttonLoading:c,buttonHideAnimations:!A&&c,isResettingPassword:!1,error:i,password:h||"",onClose:()=>{A&&"user-passcode"!==A?.recoveryMethod?(E(new R("User created a wallet but failed to set a password for it")),f({shouldCallAuthOnSuccess:!1})):A?(C(A),f({shouldCallAuthOnSuccess:T})):(E(new R("User wallet creation failed")),f({shouldCallAuthOnSuccess:!1}))},onPasswordChange:u,onPasswordGenerate:()=>u($d()),onSubmit:async()=>(d(!0),k.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>d(!1))))})},[cr.MFA_ENROLLMENT_FLOW_SCREEN]:()=>{let{user:r,enrollInMfa:a}=hr(),[i,l]=s(null),{unenrollWithSms:c,unenrollWithTotp:d,unenrollWithPasskey:h}=im(),{app:u,ready:p,data:m,onUserCloseViaDialogOrKeybindRef:y}=lr(),{closePrivyModal:g}=x(),{promptMfa:f}=am(),{initEnrollmentWithTotp:w}=im(),[v,C]=s(!1),[E,T]=s(null),[b,A]=s(null),_=()=>{g({shouldCallAuthOnSuccess:!0}),a(!1),setTimeout((()=>{l(null),T(null)}),500)},{initEnrollmentWithPasskey:k,submitEnrollmentWithPasskey:I}=im(),[N,S]=s(!1),[R,O]=s(null);y.current=_;let W=r?.mfaMethods.includes("sms"),M=!!r?.phone,P=r?.mfaMethods.includes("totp"),L=r?.mfaMethods.includes("passkey"),D=W||P||L,U=r?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function F(){l(null),T(null)}if(o((()=>{D&&C(!0)}),[D]),!p||!r||!u/*#__PURE__*/)return e(n,{children:[/*#__PURE__*/t(ot,{onClose:_},"header"),/*#__PURE__*/t(Il,{children:/*#__PURE__*/t(om,{})}),/*#__PURE__*/t(Sl,{children:/*#__PURE__*/t(Ht,{})}),/*#__PURE__*/t(yt,{})]});if("sms"===i)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ja,{})}),/*#__PURE__*/t(Nl,{children:"Remove SMS verification?"}),/*#__PURE__*/e(xl,{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(Ml,{children:/*#__PURE__*/t(st,{warn:!0,onClick:async function(){l(null);try{await c()}catch(e){l(null)}},children:"Remove SMS for MFA"})}),/*#__PURE__*/t(yt,{})]});if("totp"===i)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ja,{})}),/*#__PURE__*/t(Nl,{children:"Remove Authenticator App verification?"}),/*#__PURE__*/e(xl,{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(Ml,{children:/*#__PURE__*/t(st,{warn:!0,onClick:async function(){l(null);try{await d()}catch(e){l(null)}},children:"Remove Authenticator App for MFA"})}),/*#__PURE__*/t(yt,{})]});if("passkey"===i){let r=m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa??!0;/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:F,onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(Ja,{})}),/*#__PURE__*/t(Nl,{children:"Are you sure you want to remove this passkey?"}),/*#__PURE__*/t(xl,{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(Ml,{children:/*#__PURE__*/t(st,{warn:!0,onClick:async function(){l(null);try{await h({removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){l(null)}},children:"Yes, remove"})}),/*#__PURE__*/t(yt,{})]})}if(0===m.mfaEnrollmentFlow.mfaMethods.length&&!D)/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(Nl,{children:"Add more security"}),/*#__PURE__*/e(xl,{children:[u?.name," does not have any verification methods enabled."]}),/*#__PURE__*/t(Ml,{children:/*#__PURE__*/t(st,{onClick:_,children:"Close"})}),/*#__PURE__*/t(yt,{})]});let B=!D&&!v;return B?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{onClose:_},"header"),/*#__PURE__*/t(Vl,{style:{marginBottom:"1.5rem"},children:/*#__PURE__*/t(oo,{})}),/*#__PURE__*/t(Nl,{children:"Transaction Protection"}),/*#__PURE__*/t(xl,{children:"Set up transaction protection to add an extra layer of security to your account"}),/*#__PURE__*/e(Rl,{children:[/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(io,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),/*#__PURE__*/e(Wl,{children:[/*#__PURE__*/t(Ol,{children:/*#__PURE__*/t(so,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),/*#__PURE__*/e(Ml,{children:[/*#__PURE__*/t(st,{onClick:()=>C(!0),children:"Continue"}),/*#__PURE__*/t(dt,{onClick:_,children:"Not now"})]}),/*#__PURE__*/t(yt,{})]}):"sms"===E?/*#__PURE__*/t(Im,{appName:u?.name||"Privy",onComplete:_,onReset:F,onClose:_}):"totp"===E&&b?/*#__PURE__*/t(xm,{onComplete:_,onClose:_,onReset:F,totpInfo:{...b,appName:u?.name||"Privy"}}):"passkey"===E?/*#__PURE__*/t(dm,{appName:u?.name||"Privy",onComplete:_,onReset:F,onClose:_}):/*#__PURE__*/t(lm,{showIntro:B,userMfaMethods:r.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:M,onBackToIntro:function(){C(!1)},handleSelectMethod:async function(e){return await f().catch(O),"totp"===e?(T(e),A(null),void w().then((e=>{A(e)})).catch((()=>{A(null),F()}))):"passkey"===e&&1===U.length?await async function(){S(!0);try{await k(),await I({credentialIds:U},{removeForLogin:m?.mfaEnrollmentFlow?.shouldUnlinkOnUnenrollMfa})}catch(e){O(e)}finally{S(!1)}}():void T(e)},isTotpLoading:"totp"===E&&!b,isPasskeyLoading:N,error:R,onClose:_,setRemovingMfaMethod:async e=>{await f().catch(O),l(e)}})},[cr.CAPTCHA_SCREEN]:()=>{let{lastScreen:r,currentScreen:a,data:i,navigateBack:c,navigate:d,setModalData:h}=lr(),{status:u,token:p,waitForResult:m,reset:y,execute:g}=it(),f=l([]),w=e=>{f.current=[e,...f.current]},[v,C]=s(!0);o((()=>(w(setTimeout(C,1e3,!1)),()=>{f.current.forEach((e=>clearTimeout(e))),f.current=[]})),[]);let[E,T]=s(""),[b,A]=s("Checking that you are a human..."),[_,k]=s(/*#__PURE__*/t(st,{onClick:()=>{},disabled:!0,children:"Continue"})),[I,N]=s(!1),[x,S]=s(3),R=i?.captchaModalData,O=async e=>{try{await(R?.callback(e)),R?.onSuccessNavigateTo&&d(R?.onSuccessNavigateTo,!1)}catch(e){if(e instanceof qe)return;h({errorModalData:{error:e,previousScreen:r||cr.LANDING}}),d(R?.onErrorNavigateTo||cr.ERROR_SCREEN,!1)}};o((()=>{"success"===u?w(setTimeout((async()=>{let e=await m();!e||R?.userIntentRequired||O(e)}),1e3)):"ready"===u&&w(setTimeout((()=>{"ready"===u&&g()}),500))}),[u]),o((()=>{if(!v)switch(u){case"success":T("Success!"),A("CAPTCHA passed successfully."),k(/*#__PURE__*/t(st,{onClick:()=>{N(!0),O(p)},disabled:!R?.userIntentRequired,loading:I,children:R?.userIntentRequired?"Continue":"Continuing..."}));break;case"loading":T(""),A("Checking that you are a human..."),k(/*#__PURE__*/t(st,{onClick:()=>{},disabled:!0,children:"Continue"}));break;case"error":T("Something went wrong"),x<=0?(A("If you use an adblocker or VPN, try disabling and re-attempting."),k(null)):(A("You did not pass CAPTCHA. Please try again."),k(/*#__PURE__*/t(st,{onClick:W,children:"Retry"})))}}),[u,v,I]);let W=async()=>{if(x<=0)return;S((e=>e-1)),y(),g();let e=await m();!e||R?.userIntentRequired||O(e)};/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{backFn:r&&a!==r?c:void 0}),/*#__PURE__*/e(gc,{children:["success"===u?/*#__PURE__*/t(si,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}):"error"===u?/*#__PURE__*/t(li,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}):/*#__PURE__*/t(mc,{}),/*#__PURE__*/e(mt,{children:[E?/*#__PURE__*/t("h3",{children:E}):null,/*#__PURE__*/t("p",{children:b})]}),_]}),/*#__PURE__*/t(yt,{})]})},[cr.ERROR_SCREEN]:()=>{let{navigate:e,navigateBack:n,data:r,lastScreen:a,currentScreen:i}=lr(),o=r?.errorModalData?.previousScreen||(a===i?void 0:a);/*#__PURE__*/return t(ch,{error:r?.errorModalData?.error||Error(),backFn:()=>o?e(o,!1):n(),onClick:()=>e(o||cr.LANDING,!1)})},[cr.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE]:()=>{let{closePrivyModal:r}=x();/*#__PURE__*/return e(n,{children:[/*#__PURE__*/t(ot,{},"header"),/*#__PURE__*/t(pp,{children:/*#__PURE__*/t(ni,{style:{width:32,height:32}})}),/*#__PURE__*/t(Jl,{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(hn,{children:/*#__PURE__*/t(st,{onClick:()=>r(),children:"Close"})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(ct,{})]})},[cr.AFFIRMATIVE_CONSENT_SCREEN]:()=>{let{user:e,logout:n}=hr(),{app:r,onUserCloseViaDialogOrKeybindRef:a,setModalData:i,navigate:o}=lr(),{acceptTerms:s,closePrivyModal:l,createAnalyticsEvent:c}=x(),d=e=>{e?.preventDefault(),l({shouldCallAuthOnSuccess:!1}),n()};a.current=d;/*#__PURE__*/return t(jl,{termsAndConditionsUrl:r?.legal.termsAndConditionsUrl,privacyPolicyUrl:r?.legal.privacyPolicyUrl,onAccept:async t=>{t.preventDefault(),await s(),e&&ht(e,r.embeddedWallets)?(i({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),c({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AffirmativeConsentScreen"}}),n()},callAuthOnSuccessOnClose:!0}}),o(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)):l()},onDecline:d})},[cr.TELEGRAM_AUTH_SCREEN]:()=>{let{authenticated:r,logout:a,ready:i,user:l}=hr(),{app:c,setModalData:d,navigate:h,resetNavigation:u,data:p}=lr(),{initLoginWithTelegram:m,loginWithTelegram:y,updateWallets:g,setReadyToTrue:f,closePrivyModal:w,createAnalyticsEvent:v,getAuthMeta:C}=x(),[E,T]=s(!1),[b,_]=s(void 0),k=it();async function I(){try{let e=await async function(){let e;if(!r){if(k.enabled&&"error"===k.status)throw new qe(k.error,null,A.CAPTCHA_FAILURE);return k.enabled&&"success"!==k.status&&(k.execute(),e=await k.waitForResult()),e}}();await y({captchaToken:e}),T(!0),f(!0)}catch(e){if(e?.privyErrorCode===A.ALLOWLIST_REJECTED)return _(void 0),u(),void h(cr.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===A.USER_LIMIT_REACHED)return console.error(new S(e).toString()),_(void 0),u(),void h(cr.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===A.USER_DOES_NOT_EXIST)return _(void 0),u(),void h(cr.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===A.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return _(void 0),u(),d({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,telegramAuthResult:C()?.telegramAuthResult,telegramWebAppData:C()?.telegramWebAppData,displayName:e.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void h(cr.LINK_CONFLICT_SCREEN);let{retryable:t,detail:n}=Xo(e);_({retryable:t,detail:n,message:"Authentication failed"})}}o((()=>{I()}),[]),o((()=>{if(!(i&&r&&E&&l))return;if(c?.legal.requireUsersAcceptTerms&&!l.hasAcceptedTerms){let e=setTimeout((()=>{h(cr.AFFIRMATIVE_CONSENT_SCREEN)}),ur);return()=>clearTimeout(e)}if(ht(l,c.embeddedWallets)){let e=setTimeout((()=>{d({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),v({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:"telegram",screen:"TelegramAuthScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),h(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),ur);return()=>clearTimeout(e)}g();let e=setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),ur);return()=>clearTimeout(e)}),[i,r,E,l]);let N=E?"Successfully connected with Telegram":b?b.message:"Verifying connection to Telegram",R="";return R=E?"You’re good to go!":b?b.detail:"Just a few moments more",/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/e(nf,{children:[/*#__PURE__*/t(Qs,{children:/*#__PURE__*/e("div",{children:[/*#__PURE__*/t(pt,{success:E,fail:!!b}),/*#__PURE__*/t($p,{style:{width:"38px",height:"38px"}})]})}),/*#__PURE__*/e(mt,{children:[/*#__PURE__*/t("h3",{children:N}),/*#__PURE__*/t("p",{children:R})]}),b&&b?.retryable?/*#__PURE__*/t(un,{onClick:async()=>{try{_(void 0),p?.telegramAuthModalData?.seamlessAuth||await m(void 0,p?.login?.disableSignup),await I()}catch(e){let{retryable:t,detail:n}=Xo(e);_({retryable:t,detail:n,message:"Authentication failed"})}},disabled:!E&&!b?.retryable,children:"Retry"}):null]}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(yt,{})]})},[cr.LINK_CONFLICT_SCREEN]:()=>{let{initiateAccountTransfer:e,closePrivyModal:n}=x(),{data:r,navigate:a,lastScreen:i,setModalData:o}=lr(),[l,c]=s(void 0),[d,h]=s(!1),[u,p]=s(!1),m=async()=>{try{if(!r?.accountTransfer?.nonce||!r?.accountTransfer?.account)throw Error("missing account transfer inputs");p(!0),await e({nonce:r?.accountTransfer?.nonce,account:r?.accountTransfer?.account,accountType:r?.accountTransfer?.linkMethod,externalWalletMetadata:r?.accountTransfer?.externalWalletMetadata,telegramWebAppData:r?.accountTransfer?.telegramWebAppData,telegramAuthResult:r?.accountTransfer?.telegramAuthResult,farcasterEmbeddedAddress:r?.accountTransfer?.farcasterEmbeddedAddress,oAuthUserInfo:r?.accountTransfer?.oAuthUserInfo}),h(!0),p(!1),setTimeout(n,1e3)}catch(e){o({errorModalData:{error:e,previousScreen:i||cr.LINK_CONFLICT_SCREEN}}),a(cr.ERROR_SCREEN,!0)}};return l?/*#__PURE__*/t(Al,{address:l,onClose:n,onRetry:()=>c(void 0),onTransfer:m,isTransferring:u,transferSuccess:d}):/*#__PURE__*/t(_l,{onClose:n,onInfo:()=>c(r?.accountTransfer?.embeddedWalletAddress),onContinue:()=>c(r?.accountTransfer?.embeddedWalletAddress),onTransfer:m,isTransferring:u,transferSuccess:d,data:r})}},Cf=[cr.LANDING,cr.AWAITING_CONNECTION],Ef=({isMfaVerifying:r,onMfaVerificationComplete:a})=>{let{ready:i,isModalOpen:s}=hr(),{headless:l}=dr(),{ready:c,currentScreen:d}=lr(),{status:h,execute:u,reset:p,enabled:m}=it(),y=s&&d&&Cf.includes(d)&&!l&&"ready"===h;return o((()=>{y&&u()}),[y]),o((()=>{!s&&m&&p()}),[s,m]),i&&c||d===cr.AWAITING_OAUTH_SCREEN||d===cr.CROSS_APP_AUTH_SCREEN||d===cr.TELEGRAM_AUTH_SCREEN?!d&&r?/*#__PURE__*/t(yy,{open:r,onClose:a}):d?/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(sl,{$if:!!r,children:/*#__PURE__*/t(vf[d],{})}),/*#__PURE__*/t(sl,{$if:!r,children:/*#__PURE__*/t(yy,{open:r,onClose:a})})]}):null:/*#__PURE__*/e(n,{children:[/*#__PURE__*/t(ot,{}),/*#__PURE__*/t(_t,{}),/*#__PURE__*/t(wf,{children:/*#__PURE__*/t(Ht,{})}),/*#__PURE__*/t(kt,{}),/*#__PURE__*/t(yt,{})]})},Tf=({isMfaVerifying:e,onMfaVerificationComplete:n})=>{let r=l(null);/*#__PURE__*/return t(_f,{style:{height:kn(r)},id:"privy-modal-content",children:/*#__PURE__*/t("div",{ref:r,children:/*#__PURE__*/t(Ef,{isMfaVerifying:e,onMfaVerificationComplete:n})})})};const bf=({open:e})=>{let{app:n}=lr(),{gracefulClosePrivyModal:r}=(()=>{let{closePrivyModal:e}=x(),{onUserCloseViaDialogOrKeybindRef:t}=lr();return{gracefulClosePrivyModal:c((()=>{if(!t?.current)return e({shouldCallAuthOnSuccess:!1});t.current()}),[e])}})(),[a,i]=s(!1);Zs({onMfaRequired:()=>{n?.mfa.noPromptOnMfaRequired||i(!0)}});let o=e||a;return n.render.standalone?/*#__PURE__*/t(uf,{children:/*#__PURE__*/t(Af,{id:"privy-modal-content",children:/*#__PURE__*/t(Ef,{isMfaVerifying:a,onMfaVerificationComplete:()=>i(!1)})})}):/*#__PURE__*/t(pf,{open:o,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>r(),children:/*#__PURE__*/t(uf,{children:/*#__PURE__*/t(Tf,{isMfaVerifying:a,onMfaVerificationComplete:()=>i(!1)})})})};let Af=/*#__PURE__*/Ka.div.withConfig({displayName:"ContentWrapper",componentId:"sc-ca7fbebb-0"})(["display:flex;flex-direction:column;text-align:center;font-size:14px;line-height:20px;width:100%;background:var(--privy-color-background);padding:0 16px;"]),_f=/*#__PURE__*/Ka(Af).withConfig({displayName:"BaseModal",componentId:"sc-ca7fbebb-1"})(["transition:height 150ms ease-out;overflow-x:hidden;overflow-y:auto;scrollbar-width:none;max-height:calc(100svh - 32px);border-radius:var(--privy-border-radius-lg) var(--privy-border-radius-lg) 0 0;box-shadow:0px 0px 36px rgba(55,65,81,0.15);@media (min-width:441px){box-shadow:0px 8px 36px rgba(55,65,81,0.15);border-radius:var(--privy-border-radius-lg);}"]);function kf(e){let n=l(null),r=l();return o((()=>{r.current?.remove(),r.current=function({botUsername:e,scriptHost:t}){let n=document.createElement("script"),{origin:r}=new URL(t);return n.async=!0,n.src=`${r}/js/telegram-login.js`,n.setAttribute("data-telegram-login",e),n.setAttribute("data-request-access","write"),n.setAttribute("data-lang","en"),n}(e),n.current?.after(r.current)}),[e]),/*#__PURE__*/t("div",{ref:n,hidden:!0})}async function If(e,t,n,r,a,i=!1){let o=i,s=async s=>{if(o&&t&&t.length>0){s===(i?0:1)?a("configureMfa","onMfaRequired",{mfaMethods:t}):r.current?.reject(new Hc("missing_or_invalid_mfa","MFA verification failed, retry."));let o=await new Promise(((e,t)=>{n.current={resolve:e,reject:t},setTimeout((()=>{let e=new Hc("mfa_timeout","Timed out waiting for MFA code");r.current?.reject(e),t(e)}),3e5)}));return await e(o)}return await e()},l=null;for(let e=0;e<4;e++)try{l=await s(e),r.current?.resolve(void 0);break}catch(e){if("missing_or_invalid_mfa"!==e.type)throw r.current?.resolve(void 0),e;o=!0}if(null===l){let e=new Hc("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw r.current?.reject(e),e}return l}var Nf;let xf=(Nf=0,()=>"id-"+Nf++);function Sf(e){return void 0!==e.error}let Rf=new class{enqueue(e,t){this.callbacks[e]=t}dequeue(e,t){let n=this.callbacks[t];if(!n)throw Error(`cannot dequeue ${e} event: no event found for id ${t}`);switch(delete this.callbacks[t],e){case"privy:iframe:ready":case"privy:wallets:create":case"privy:wallets:add":case"privy:wallets:import":case"privy:wallets:set-recovery":case"privy:wallets:connect":case"privy:wallets:recover":case"privy:wallets:rpc":case"privy:wallet:create":case"privy:mfa:verify":case"privy:mfa:init-enrollment":case"privy:mfa:submit-enrollment":case"privy:mfa:unenroll":case"privy:mfa:clear":case"privy:auth:unlink-passkey":case"privy:farcaster:init-signer":case"privy:farcaster:sign":case"privy:solana-wallet:create":case"privy:delegated-actions:consent":return n;default:throw Error(`invalid wallet event type ${e}`)}}constructor(){this.callbacks={}}},Of=new Map,Wf=(e,t)=>"bigint"==typeof t?t.toString():t;function Mf(e,t,n,r){let a=n.contentWindow;if(!a)throw Error("iframe not initialized");let i=((e,t)=>`${e}${JSON.stringify(t,Wf)}`)(e,t);if("privy:wallet:create"===e){let e=Of.get(i);if(e)return e}let o=new Promise(((n,i)=>{let o=xf();Rf.enqueue(o,{resolve:n,reject:i}),a.postMessage({id:o,event:e,data:t},r)})).finally((()=>{Of.delete(i)}));return Of.set(i,o),o}function Pf(e){let n=l(null),r=l(e.mfaMethods),a=ha(),[i,c]=s(!1);return o((()=>{r.current=e.mfaMethods}),[e.mfaMethods]),o((()=>{if(!i)return;let t=n.current;if(!t)return;function o(t){var n;t&&t.origin===e.origin&&"string"==typeof(n=t.data).event&&/^privy:.+/.test(n.event)&&function(e){switch(e.event){case"privy:iframe:ready":let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data);case"privy:wallets:create":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:add":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:set-recovery":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:connect":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:recover":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:rpc":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallet:create":let n=Rf.dequeue(e.event,e.id);return Sf(e)?n.reject(new Hc(e.error.type,e.error.message)):n.resolve(e.data);case"privy:wallets:import":let r=Rf.dequeue(e.event,e.id);return Sf(e)?r.reject(new Hc(e.error.type,e.error.message)):r.resolve(e.data);case"privy:mfa:verify":let a=Rf.dequeue(e.event,e.id);return Sf(e)?a.reject(new Hc(e.error.type,e.error.message)):a.resolve(e.data);case"privy:mfa:init-enrollment":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:submit-enrollment":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:unenroll":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:clear":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:auth:unlink-passkey":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:solana-wallet:create":let i=Rf.dequeue(e.event,e.id);return Sf(e)?i.reject(new Hc(e.error.type,e.error.message)):i.resolve(e.data);case"privy:farcaster:init-signer":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:farcaster:sign":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:delegated-actions:consent":{let t=Rf.dequeue(e.event,e.id);return Sf(e)?t.reject(new Hc(e.error.type,e.error.message)):t.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}(t.data)}let s={createWallet:n=>If((r=>Mf("privy:wallets:create",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),addWallet:n=>If((r=>Mf("privy:wallets:add",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),setRecovery:n=>If((r=>Mf("privy:wallets:set-recovery",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),connect:n=>If((r=>Mf("privy:wallets:connect",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),recover:n=>If((r=>Mf("privy:wallets:recover",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a,!n.recoveryAccessToken&&!n.recoveryPassword&&!n.recoverySecretOverride),rpc:n=>If((r=>Mf("privy:wallets:rpc",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),create:n=>Mf("privy:wallet:create",n,t,e.origin),importWallet:n=>Mf("privy:wallets:import",n,t,e.origin),createSolana:n=>If((r=>Mf("privy:solana-wallet:create",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),createDelegatedAction:n=>Mf("privy:delegated-actions:consent",n,t,e.origin),verifyMfa:n=>If((r=>Mf("privy:mfa:verify",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a,!0),initEnrollMfa:n=>If((r=>Mf("privy:mfa:init-enrollment",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),submitEnrollMfa:n=>If((r=>Mf("privy:mfa:submit-enrollment",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),unenrollMfa:n=>If((r=>Mf("privy:mfa:unenroll",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),clearMfa:n=>Mf("privy:mfa:clear",n,t,e.origin),unlinkPasskeyAccount:n=>If((r=>Mf("privy:auth:unlink-passkey",{...n,...r},t,e.origin)),r.current,e.mfaPromise,e.mfaSubmitPromise,a),initFarcasterSigner:n=>Mf("privy:farcaster:init-signer",n,t,e.origin),signFarcasterMessage:n=>Mf("privy:farcaster:sign",n,t,e.origin)};window.addEventListener("message",o);let l=new AbortController;return In((()=>Mf("privy:iframe:ready",{},t,e.origin)),{abortSignal:l.signal}).then((()=>e.onLoad(s)),((...t)=>{console.warn("Privy iframe failed to load: ",...t),e.onLoadFailed()})),()=>{window.removeEventListener("message",o),l.abort()}}),[i]),
20
+ /*#__PURE__*/t("iframe",{ref:n,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>c(!0),src:Ot(e.origin,`/apps/${e.appId}/embedded-wallets`,{caid:e.clientAnalyticsId,client_id:e.appClientId})})}const Lf=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.delegated));class Df{async handleSignMessage(e){if(!e.params||"string"!=typeof e.params.message)throw Error("Message must be provided as a string for Solana signMessage RPC");return await dw({message:e.params.message,options:{address:this.address,uiOptions:{}}})}async request(e){if(console.debug("EmbeddedSolanaProvider.request() called with args",e),!await rw())throw Error("User must be authenticated to use embedded Solana wallet");if(!await cw())throw new T("Unable to connect to Solana embedded wallet");if("signMessage"===e.method)return await this.handleSignMessage(e);throw Error("Embedded Solana provider does not yet support this RPC method.")}constructor(e,t){this.walletProxy=e,this.address=t}}const Uf=()=>{let e=dr();o((()=>{(async e=>{let t=new URL("v3/wallets","https://explorer-api.walletconnect.com");t.searchParams.append("projectId",e);let n=await fetch(t);return n.ok?Object.values((await n.json()).listings).sort((({slug:e},{slug:t})=>"rainbow"===e&&"metamask"===t?1:"metamask"===e||"rainbow"===e?-1:1)):(console.debug(`Failed to fetch WalletConnect listings: ${await n.text().catch((()=>"No response."))}`),[])})(e.walletConnectCloudProjectId).then((e=>Nn({listings:e}))).catch(console.error)}),[e.walletConnectCloudProjectId])},Ff="popup-privy-oauth",Bf="PRIVY_OAUTH_USE_BROADCAST_CHANNEL";class zf{async authenticate(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(K,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw b(e)}}async link(){if(!this.api)throw new T("Auth flow has no API instance");try{return await this.api.post(Y,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw b(e)}}constructor({authorizationCode:e,stateCode:t,codeVerifier:n,provider:r}){this.meta={authorizationCode:e,stateCode:t,codeVerifier:n,provider:r}}}async function Hf({api:e,requesterAppId:t,providerAppId:n}){let r=(await e.get(`/api/v1/apps/${t}/cross-app/connections`)).connections.find((e=>e.provider_app_id===n));if(!r)throw new T("Invalid connected app");return{name:r.provider_app_name,logoUrl:r.provider_app_icon_url||void 0,apiUrl:r.provider_app_custom_api_url,readOnly:r.read_only}}const Vf=async({user:e,address:t,client:n,request:r,requesterAppId:a,reconnect:i})=>{n.createAnalyticsEvent({eventName:"cross_app_request_started",payload:{address:t,method:r.method}});let o=e?.linkedAccounts.find((e=>"cross_app"===e.type&&(e.embeddedWallets.some((e=>e.address===t))||e.smartWallets.some((e=>e.address===t)))));if(!e||!o)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Cannot request a signature with this wallet address",address:t}}),new T("Cannot request a signature with this wallet address");let s=n.getProviderAccessToken(o.providerApp.id),l=await Hf({api:n.api,requesterAppId:a,providerAppId:o.providerApp.id});if(!s){if(l.readOnly)throw console.error("cannot transact against a read-only provider app"),new T("Cannot transact against a read-only provider app");await i({appId:o.providerApp.id,action:"link"})&&(s=n.getProviderAccessToken(o.providerApp.id))}if(!s)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Transactions require a valid token",address:t}}),new T("Transactions require a valid token");let c=Zu();if(!c)throw n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Missing token",address:t}}),new T("Failed to initialize signature request");let d=new URL(`${l.apiUrl}/oauth/transact`);return d.searchParams.set("token",s||""),d.searchParams.set("request",$f(r)),c.location=d.href,new Promise(((e,a)=>{let i=setTimeout((()=>{d(),a(new T("Request timeout")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Request timeout",address:t}})}),12e4),s=setInterval((()=>{c.closed&&(d(),a(new T("User rejected request")),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"User rejected request",address:t}}))}),300),l=i=>{i.data&&("set"===i.data.token?.action&&void 0!==i.data.token?.value?n.storeProviderAccessToken(o.providerApp.id,i.data.token.value):"clear"===i.data.token?.action&&n.storeProviderAccessToken(o.providerApp.id,null),"PRIVY_CROSS_APP_ACTION_RESPONSE"===i.data.type&&i.data.result&&(d(),e(i.data.result),n.createAnalyticsEvent({eventName:"cross_app_request_success",payload:{address:t,method:r.method}})),"PRIVY_CROSS_APP_ACTION_ERROR"===i.data.type&&i.data.error&&(d(),a(i.data.error),n.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:i.data.error,address:t}})))};window.addEventListener("message",l);let d=()=>{c.close(),clearInterval(s),clearTimeout(i),window.removeEventListener("message",l)}}))};let $f=e=>JSON.stringify({content:{request:{request:jf(e,_a)}},timestamp:Date.now(),callbackUrl:window.origin});const jf=(e,t)=>"bigint"==typeof e?t(e):Array.isArray(e)?e.map((e=>jf(e,t))):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,jf(n,t)]))):e,Gf=e=>!!e.fundingConfig&&ua(e.fundingConfig.options).length>=1;async function qf({url:e,popup:t,provider:n}){return t.location=e,new Promise(((e,n)=>{function r(){t?.close(),window.removeEventListener("message",a)}function a(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(e(t.data),r()),"https://cdn.apple-cloudkit.com"===t.origin&&t.data.ckSession&&(e({type:"PRIVY_OAUTH_RESPONSE",ckWebAuthToken:t.data.ckSession}),r()),"PRIVY_OAUTH_ERROR"===t.data.type&&(n(t.data.error),r()))}window.addEventListener("message",a)}))}let Kf,Yf,Zf,Jf,Qf,Xf,ew,tw;function nw(){return Kf?Kf.getCustomerAccessToken():Promise.resolve(Zr.get(Kn)||null)}async function rw(){return Kf?Kf.getAccessToken():Promise.resolve(Zr.get(Yn)||Zr.get(Kn)||null)}const aw=(e,t)=>Yf(e,t),iw=(e,t)=>Zf(e,t),ow=(e,t)=>Jf(e,t),sw=(e,t)=>Qf(e,t),lw=()=>Xf(),cw=()=>ew(),dw=({message:e,options:t})=>tw({message:e,options:t}),hw=({config:e,...n})=>{var r;if("undefined"!=typeof window&&0>["localhost","127.0.0.1"].indexOf(window.location.hostname)&&"https:"!==window.location.protocol)throw new T("Embedded wallet is only available over HTTPS");if("string"!=typeof(r=n.appId)||25!==r.length)throw new T("Cannot initialize the Privy provider with an invalid Privy app ID");Kf||(Kf=new qs({appId:n.appId,appClientId:n.clientId,apiUrl:n.apiUrl}));let a=Object.assign({},e);/*#__PURE__*/
21
+ return t(Ur,{client:Kf,clientConfig:a,children:/*#__PURE__*/t(pa,{children:/*#__PURE__*/t(uw,{...n,client:Kf})})})};let uw=n=>{let a=n.client,d=ra();Uf();let[h,u]=s(!1),[p,m]=s(!1),[y,g]=s(!1),[f,w]=s(null),[k,I]=s([]),[N,x]=s([]),[S,R]=s([]),[O,W]=s(!1),[U,F]=s(null),[B,z]=s(!1),[H,V]=s({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:P}),[$,j]=s({status:"initial"}),[G,q]=s({status:"initial"}),[K,Y]=s({status:"initial"}),[J,Q]=s({status:"initial"}),[X,ee]=s({status:"initial"}),[te,ne]=s({status:"initial"}),[re,ae]=s(null),ie=dr(),oe=Fr(),[se,le]=s(!0),[ce,de]=s({}),[he,ue]=s(null),[pe,me]=s(null),[ye,ge]=s(!1),[fe,we]=s(!1),[ve,Ce]=s(ie.customAuth?.enabled?{status:"initial"}:{status:"not-enabled"}),Ee=l(null),Te=l(null),be=l(ma),[Ae,_e]=s(!1);a.onStoreCustomerAccessToken=e=>{e&&ya(be,"accessToken","onAccessTokenGranted",{accessToken:e})},a.onDeleteCustomerAccessToken=()=>{w(null),g(!1),ya(be,"accessToken","onAccessTokenRemoved")};let ke=l(null),Ie=l(null),Ne=l(!1),xe=({showWalletUIs:e})=>Ne.current?Ne.current:void 0!==e?!e:!ie.embeddedWallets.showWalletUIs,Se=e=>{F(e),setTimeout((()=>{u(!0)}),15)},Re=e=>{("off"!==ie.embeddedWallets.ethereum.createOnLogin||"off"!==ie.embeddedWallets.solana.createOnLogin)&&le(!0),Se(e)};o((()=>{let e=[...Br(f),Lr(f)].filter((e=>!!e));re&&R(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 T("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:()=>{throw new T("Cannot unlink an embedded Solana wallet")},getProvider:async()=>new Df(re,e.address),async signMessage(t){let n=await rw();if(!n||!re)throw new T("Must have valid access token and Privy wallet to send transaction",A.MUST_BE_AUTHENTICATED);let r=e.imported?Lr(f):wr(f);if(!r)throw new T("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=jn(r);if(!await lt.recoverPrimaryWallet().catch((()=>!1)))throw new T("Wallet couldn't be connected",A.UNKNOWN_CONNECT_WALLET_ERROR);if(!f)throw new T("Attempting to sign a transaction with no user initialized");let{response:o}=await re.rpc({accessToken:n,entropyId:a,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:e.walletIndex??0,request:{method:"signMessage",params:{message:Buffer.from(t).toString("base64")}}});return Buffer.from(o.data.signature,"base64")},async sendTransaction(e,t,n){let{signature:r}=await Qe({transaction:e,connection:t,transactionOptions:n,wallet:this,signOnly:!1});return r},async signTransaction(t){let n=await rw();if(!n||!re)throw new T("Must have valid access token and Privy wallet to send transaction",A.MUST_BE_AUTHENTICATED);if(!await lt.recoverPrimaryWallet().catch((()=>!1)))throw new T("Wallet couldn't be connected",A.UNKNOWN_CONNECT_WALLET_ERROR);let r=e.imported?e:wr(f);if(!r)throw new T("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=jn(r);return await Wy({tx:t,accessToken:n,walletProxy:re,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0}),t},async signAllTransactions(t){let n=await rw();if(!n||!re)throw new T("Must have valid access token and Privy wallet to send transaction",A.MUST_BE_AUTHENTICATED);if(!await lt.recoverPrimaryWallet().catch((()=>!1)))throw new T("Wallet couldn't be connected",A.UNKNOWN_CONNECT_WALLET_ERROR);let r=e.imported?e:wr(f);if(!r)throw new T("Attempting to sign a transaction without a root wallet");let{entropyId:a,entropyIdVerifier:i}=jn(r);for(let r of t)await Wy({tx:r,accessToken:n,walletProxy:re,entropyId:a,entropyIdVerifier:i,transactingWalletAddress:e.address,transactingWalletIndex:e.walletIndex??0});return t},loginOrLink:async()=>{throw new T("Cannot login or link with an embedded Solana wallet")},disconnect:()=>{},isConnected:async()=>!0}))))}),[re,f]),o((()=>{if(!f)return void a.connectors?.removeEmbeddedWalletConnectors();let e=yr(f),t=zr(f),r=Hr(f);e&&t.length||a.connectors?.removeEmbeddedWalletConnectors(),r||a.connectors?.removeImportedWalletConnector(),a.connectors?re?(e&&a.connectors.addEmbeddedWalletConnectors({walletProxy:re,rootWallet:e,embeddedWallets:t,defaultChain:ie.defaultChain,appId:n.appId}),r&&a.connectors.addImportedWalletConnector(re,r.address,ie.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")}),[re,f]),o((()=>{re&&pe?.(re)}),[re]);let Oe=l();o((()=>{(async()=>{if(!ie.customAuth?.enabled)return void Ce({status:"not-enabled"});le(!0);let{getCustomAccessToken:e,isLoading:t}=ie.customAuth;if(p&&!t&&"loading"!==ve.status){Ce({status:"loading"});try{let t=await e();if(t===Oe.current)return void Ce({status:"done"});if(!t&&y)return Oe.current=t,await st.logout(),Ce({status:"done"}),void ya(be,"customAuth","onUnauthenticated");if(!t)return Oe.current=t,void Ce({status:"done"});a.startAuthFlow(new bo(t));let{user:n,isNewUser:r}=await a.authenticate();if(!n)return await st.logout(),Ce({status:"error",error:new T("Failed to sync with custom auth provider")}),void ya(be,"customAuth","onUnauthenticated");void 0!==r&&ya(be,"login","onComplete",{user:n,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),Oe.current=t,ya(be,"customAuth","onAuthenticated",{user:n}),Ce({status:"done"}),w(n||null),W(r||!1),g(!0),we(!0)}catch(e){if(console.warn(e),await st.logout(),ya(be,"customAuth","onUnauthenticated"),"User already exists with provided custom JWT account."===e.message)return void Ce({status:"initial"});ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),Ce({status:"error",error:e})}}})()}),["initial"===ve.status,ie.customAuth?.enabled,ie.customAuth?.getCustomAccessToken,ie.customAuth?.isLoading,p,y]),o((()=>{fe&&re&&f&&(async()=>{let e=Wt(f,ie.embeddedWallets.ethereum.createOnLogin),t=Mt(f,ie.embeddedWallets.solana.createOnLogin),n=await rw();if(n){if(e&&t){let e=await $e(f,fr);return await re.createSolana({accessToken:n,ethereumAddress:e?.address}),void we(!1)}if(t)return await re.createSolana({accessToken:n,ethereumAddress:yr(f)?.address}),await lt.refreshSessionAndUser(),void we(!1);if(e)return await $e(f,fr),void we(!1)}})().catch(console.error)}),[fe&&re&&f]),o((()=>{if(ie.externalWallets.solana.connectors)return ie.externalWallets.solana.connectors.onMount(),()=>ie.externalWallets.solana.connectors?.onUnmount()}),[ie.externalWallets.solana.connectors]),o((()=>{!p&&oe&&async function(){let e,t=We(),n=Me(),i=r();a.initializeConnectorManager({walletConnectCloudProjectId:ie.walletConnectCloudProjectId,rpcConfig:ie.rpcConfig,chains:ie.chains,defaultChain:ie.defaultChain,store:i,walletList:ie.appearance.walletList,shouldEnforceDefaultChainOnConnect:ie.shouldEnforceDefaultChainOnConnect,externalWalletConfig:ie.externalWallets,appName:ie.name??"Privy",walletChainType:ie.appearance.walletChainType}),a.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=a.connectors.walletConnectors.length,n=a.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);n===t?_e(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:n,expected:t}),_e(!0)}),1500)})),a.connectors?.initialize().then((()=>{Fe()}));let o=await a.getAuthenticatedUser(),s=!!o;ie.legal.requireUsersAcceptTerms&&o&&!o.hasAcceptedTerms?(await a.logout(),lt.setReadyToTrue(!0),ya(be,"logout","onSuccess")):(ie.customAuth?.enabled||(g(!!o),o&&ya(be,"login","onComplete",{user:o,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),w(o)),t?Ie.current=s?"link":"login":n&&!s?(Ie.current="login",de({telegramAuthModalData:{seamlessAuth:!0}}),Re(cr.TELEGRAM_AUTH_SCREEN)):lt.setReadyToTrue(!!o))}()}),[a,he,p,oe]),o((()=>{if(p){if(!f||!f.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType)))return void ge(!0);ge([...k,...S].some((e=>"privy"===e.walletClientType)))}}),[p,f,k,S]),o((()=>{a.connectors?.setWalletList(ie.appearance.walletList)}),[ie.appearance.walletList.join()]);let We=()=>{let e=qo();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(Ff).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(a.startAuthFlow(new Wo(e)),Re(cr.AWAITING_OAUTH_SCREEN),!0))},Me=()=>{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())}())?(ts(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=es(e.replace("#tgWebAppData=","")),{user:n,auth_date:r,hash:a}=t;return n&&r&&a?t:void 0}())?(ts(),{flowType:"web-app",authData:e}):void 0}();if(!e||!ie.loginMethods.telegram||!ie.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new Qo;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},Pe=async(e,t,n,r)=>{if("solana_adapter"!==e)Le(await(a.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,n,r);else{let e=a.connectors?.findSolanaWalletConnector(t);if(!e)return;Le(e,t,n,r)}};async function Le(e,t,n,r){if(!e)return V({status:"disconnected",connectedWallet:null,connectError:new _("Unable to connect to wallet."),connector:null,connectRetry:P}),r?.(null,n);V({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:P}),e instanceof nt&&t&&await e.resetConnection(t),V({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Le(e,t,n,r)});try{let t=await e.connect({showPrompt:!0});if((!t||rt(t))&&ie.shouldEnforceDefaultChainOnConnect&&!ie.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){V((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:P})));try{await(t?.switchChain(ie.defaultChain.id)),t&&(t.chainId=Wn(Ze(ie.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${ie.defaultChain.id}`)}}return V((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:P}))),t&&ya(be,"connectWallet","onSuccess",{wallet:t}),r?.(t,n)}catch(e){return e instanceof M?(console.warn(e.cause?e.cause:e.message),ya(be,"connectWallet","onError",e.privyErrorCode||A.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),ya(be,"connectWallet","onError",A.UNKNOWN_CONNECT_WALLET_ERROR)),V((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),r?.(null,n)}}let De=async(e,t,n)=>{if(null===e||!rt(e))return;let r=new at(e,a,t,n);a.startAuthFlow(r)},Ue=async(e,t,n)=>{if(null===e||!va(e))return;let r=new xn(e,a,t,n);a.startAuthFlow(r)},Fe=()=>{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=xs({connectorType:t,walletClientType:n});if(!i||!i.isInstalled)return Re(cr.LOGIN_FAILED_SCREEN);if(!a.connectors)throw new T("Connector not initialized");Se(r?cr.AWAITING_CONNECT_ONLY_CONNECTION:cr.AWAITING_CONNECTION);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),Pe(t,n,void 0,r?void 0:"solana_adapter"===t?Ue:De)};o((()=>{p&&y&&null===f&&a.getAuthenticatedUser().then(w)}),[p,y,f,a]);let Be=e=>{if(!y)throw ya(be,"linkAccount","onError",A.MUST_BE_AUTHENTICATED,{linkMethod:e}),new T("User must be authenticated before linking an account.")},ze=e=>{if(!y||!f)return!1;if("privy"===e.walletClientType)return!0;for(let t of f.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},He=async e=>{let t;if(!a.connectors)throw new T("Connector not initialized");t="ethereum"===e.type?a.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:a.connectors.findSolanaWalletConnector(e.walletClientType)||null,V((n=>({...n,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:P}))),ie.captchaEnabled&&!y?(de({captchaModalData:{callback:t=>rt(e)?De(e,t):Ue(e,t),userIntentRequired:!1,onSuccessNavigateTo:cr.AWAITING_CONNECTION,onErrorNavigateTo:cr.ERROR_SCREEN}}),Re(cr.CAPTCHA_SCREEN)):(rt(e)?await De(e):await Ue(e),Re(cr.AWAITING_CONNECTION))},Ve=()=>{I((e=>{let t=a.connectors?.wallets.filter(rt).map((e=>({...e,linked:ze(e),loginOrLink:async()=>{if(!await e.isConnected())throw new T("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot link or login with embedded wallet");He(e)},fund:async t=>{await lt.fundWallet(e.address,t)},unlink:async()=>{if(!y)throw new T("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot unlink an embedded wallet");w(await a.unlinkEthereumWallet(e.address))}})))||[];return Mn(e,t)?e:t})),x((e=>{let t=(a.connectors?.wallets??[]).filter(va).map((e=>({...e,linked:ze(e),loginOrLink:async()=>{if(!await e.isConnected())throw new T("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot link or login with embedded wallet");He(e)},fund:async()=>{throw new T("'fund' is deprecated for Solana wallets - use 'fundWallet' instead")},unlink:async()=>{if(!y)throw new T("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new T("Cannot unlink an embedded wallet");w(await a.unlinkSolanaWallet(e.address))}})));return Mn(e,t)?e:t}))};o((()=>{Ve()}),[f?.linkedAccounts,y,p]),o((()=>{if(p){if(!a.connectors)throw new T("Connector not initialized");Ve(),a.connectors.on("walletsUpdated",Ve)}}),[p]),o((()=>{[...ie.loginMethodsAndOrder?.primary??[],...ie.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>a.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!a]);let $e=async(e,t,n)=>{let r=yr(e),a=gr(e);if(n&&"walletIndex"in n&&"number"==typeof n.walletIndex)return Ge(e,t,n.walletIndex,r,a);let i=n&&"createAdditional"in n&&n.createAdditional;if(r&&!i)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");let[o,s]=await Promise.all([lt.initializeWalletProxy(t),rw()]);if(!o&&ie.customAuth?.enabled)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!o||!s||ie.embeddedWallets?.requireUserOwnedRecoveryOnCreate)return je();if(!r)return a&&await lt.recoverPrimaryWallet(),await o.create({accessToken:s,solanaAddress:a?.address}),Ke(0,"ethereum");{let t=(Vr(e)?.walletIndex??0)+1,{entropyId:n,entropyIdVerifier:r}=jn(wr(e));return await lt.recoverPrimaryWallet(),await o.addWallet({accessToken:s,entropyId:n,entropyIdVerifier:r,chainType:"ethereum",hdWalletIndex:t}),Ke(t,"ethereum")}},je=async()=>new Promise(((e,t)=>{le(!0),de({createWallet:{onSuccess:t=>{ya(be,"createWallet","onSuccess",{wallet:t}),e(t)},onFailure:e=>{ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),t(e)},callAuthOnSuccessOnClose:!1}}),Se(cr.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)})),Ge=async(e,t,n,r,a)=>{if(n<0)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${n}) is invalid.`);let[i,o]=await Promise.all([lt.initializeWalletProxy(t),rw()]);if(!i&&ie.customAuth?.enabled)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");if(!i||!o||ie.embeddedWallets?.requireUserOwnedRecoveryOnCreate){if(0==n)return je();throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Create wallet UI can only be displayed when walletIndex is 0.")}if(0==n){if(r)return r;await i.create({accessToken:o,solanaAddress:a?.address})}else{if(!r)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error("A user must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let t=zr(e).find((e=>e.walletIndex===n));if(t)return t;let{entropyId:a,entropyIdVerifier:s}=jn(wr(e));await lt.recoverPrimaryWallet(),await i.addWallet({accessToken:o,entropyId:a,entropyIdVerifier:s,chainType:"ethereum",hdWalletIndex:n})}return Ke(n,"ethereum")},qe=async({user:e,wp:t,accessToken:n,walletIndex:r,ethereumWallet:a})=>{let i=Br(e).find((e=>e.walletIndex===r));if(i)return i;if(0===r)a&&await lt.recoverPrimaryWallet(),await t.createSolana({accessToken:n,ethereumAddress:a?.address});else{let a=wr(e);if(!a)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error("User must have a wallet at HD index 0 before creating a wallet at greater HD indices.");let{entropyId:i,entropyIdVerifier:o}=jn(a);await lt.recoverPrimaryWallet(),await t.addWallet({accessToken:n,entropyId:i,entropyIdVerifier:o,chainType:"solana",hdWalletIndex:r})}return Ke(r,"solana")},Ke=async(e,t)=>{let n=await lt.refreshSessionAndUser(),r=("ethereum"===t?zr(n):Br(n)).find((t=>t.walletIndex===e));if(!r)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");return ya(be,"createWallet","onSuccess",{wallet:r}),r},Ye=({transaction:e,uiOptions:t,fundWalletConfig:r,address:a,signOnly:i})=>new Promise((async(o,s)=>{let{requesterAppId:l}=t||{},c=i?"signTransaction":"sendTransaction";if(!y||!f)return ya(be,c,"onError",A.MUST_BE_AUTHENTICATED),void s(Error("User must be authenticated before signing with a Privy wallet"));let d=a??yr(f)?.address;if(!d)throw new T("User must have an embedded wallet to send a transaction.");let{signingWallet:h,rootWallet:u}=$r(f,d);if(!u||!h)return ya(be,c,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have a Privy wallet before signing"));le(!0);let p=ct.wallets.find((e=>"privy"===e.walletClientType&&C(e.address)===C(h.address))),m=await(p?.getEthereumProvider());if(!p||!m)throw new T(`Cannot sendTransaction before embedded wallet ${h.address} is connected`);let g=e.chainId?Number(e.chainId):Ca(p.chainId);(e=>{if(!ie.chains.map((e=>e.id)).includes(e))throw new _(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,A.UNSUPPORTED_CHAIN_ID)})(g);let w={...e,from:e.from??h.address,chainId:g},v=await rw();if(!v||!re)return ya(be,c,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void s(Error("Must have valid access token and Privy wallet to send transaction"));let E=Ha(w.chainId,ie.chains,ie.rpcConfig,{appId:n.appId});if(xe({showWalletUIs:t?.showWalletUIs}))(async()=>{try{if(!await lt.recoverPrimaryWallet())return ya(be,c,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),void s(Error("Unable to connect to wallet"));let e=await hy(w,E,w.from),{entropyId:t,entropyIdVerifier:n}=jn(u),r=i?await bg({accessToken:v,entropyId:t,entropyIdVerifier:n,transactingWallet:h,walletProxy:re,transactionRequest:w,requesterAppId:l}):await Tg({accessToken:v,entropyId:t,entropyIdVerifier:n,transactingWallet:h,walletProxy:re,transactionRequest:e,publicClient:E,requesterAppId:l});i?ya(be,"signTransaction","onSuccess",{signature:r}):ya(be,"sendTransaction","onSuccess",{hash:r}),o({hash:r})}catch(e){ya(be,c,"onError",A.TRANSACTION_FAILURE),s(e)}})();else{let{entropyId:e,entropyIdVerifier:n}=jn(u),a={entropyId:e,entropyIdVerifier:n,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN,onFailure:e=>{ya(be,c,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),s(e)}},d=Gf(ie)?fa({address:h.address,appConfig:ie,fundWalletConfig:r,methodScreen:cr.FUNDING_METHOD_SELECTION_SCREEN,chainIdOverride:w.chainId,comingFromSendTransactionScreen:!0}):void 0;de({connectWallet:a,sendTransaction:{transactionRequest:w,transactingWallet:h,entropyId:e,entropyIdVerifier:n,signOnly:i,onConfirm:i?async()=>await bg({accessToken:v,entropyId:e,entropyIdVerifier:n,transactingWallet:h,walletProxy:re,transactionRequest:w,requesterAppId:l}):void 0,onSuccess:e=>{i?ya(be,"signTransaction","onSuccess",{signature:e.hash}):ya(be,"sendTransaction","onSuccess",{hash:e.hash}),o(e)},onFailure:e=>{ya(be,c,"onError",A.TRANSACTION_FAILURE),s(e)},uiOptions:t||{},fundWalletConfig:r,requesterAppId:l},funding:d}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),Qe=({transaction:e,connection:t,transactionOptions:n,fundWalletConfig:r,uiOptions:a,wallet:i,signOnly:o})=>new Promise((async(s,l)=>{let{requesterAppId:c}=a||{},d=o?"signSolanaTransaction":"sendSolanaTransaction";if(!y||!f)return ya(be,d,"onError",A.MUST_BE_AUTHENTICATED),void l(new T("User must be authenticated before signing with a Privy wallet",A.MUST_BE_AUTHENTICATED));let h=i?f.linkedAccounts.find((e=>"wallet"===e.type&&e.address===i.address)):gr(f);if(!h)return ya(be,d,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void l(new T("Must have a Privy wallet before signing",A.EMBEDDED_WALLET_NOT_FOUND));le(!0);let{rootWallet:u}=Dr(f,h.address);if(!await lt.recoverPrimaryWallet().catch((()=>!1))||!u)throw ya(be,d,"onError",A.EMBEDDED_WALLET_NOT_FOUND),new T(`Cannot sendSolanaTransaction before embedded wallet ${h.address} is connected`,A.EMBEDDED_WALLET_NOT_FOUND);if(xe({showWalletUIs:a?.showWalletUIs}))(async()=>{let r=await rw();if(!r||!re)return ya(be,d,"onError",A.EMBEDDED_WALLET_NOT_FOUND),void l(new T("Must have valid access token and Privy wallet to send transaction",A.EMBEDDED_WALLET_NOT_FOUND));try{let i;if(!await lt.recoverPrimaryWallet())return ya(be,d,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),void l(new T("Unable to connect to wallet",A.UNKNOWN_CONNECT_WALLET_ERROR));if(xe({showWalletUIs:a?.showWalletUIs})&&!o)try{if(!await async function(e,t){let{value:n}=await t.simulateTransaction(e);if("BlockhashNotFound"===n.err)throw Error("Simulation failed: Blockhash not found");return null==n.err&&n.logs?.every((e=>!/insufficient funds/gi.test(e)))}(e,t))return ya(be,d,"onError",A.INSUFFICIENT_BALANCE),void l(new T("Solana wallet has insufficient funds for this transaction.",A.INSUFFICIENT_BALANCE))}catch(e){return console.error(e),ya(be,d,"onError",A.TRANSACTION_FAILURE),void l(new T(e instanceof Error?e.message:"Transaction failed.",A.TRANSACTION_FAILURE))}let{entropyId:c,entropyIdVerifier:u}=Kr(f);if(o)await Wy({accessToken:r,tx:e,walletProxy:re,entropyId:c,entropyIdVerifier:u,transactingWalletAddress:h.address,transactingWalletIndex:h.walletIndex??0}),i=Fh("",e,null),ya(be,"signSolanaTransaction","onSuccess",{signedTransaction:e});else{let{signature:a,receipt:o}=await My({accessToken:r,tx:e,connection:t,walletProxy:re,transactionOptions:n,entropyId:c,entropyIdVerifier:u,transactingWalletAddress:h.address,transactingWalletIndex:h.walletIndex??0});i=Fh(a,e,o),ya(be,"sendSolanaTransaction","onSuccess",{response:i})}s(i)}catch(e){ya(be,d,"onError",A.TRANSACTION_FAILURE),l(e)}})();else{let{entropyId:i,entropyIdVerifier:p}=jn(u),m={entropyId:i,entropyIdVerifier:p,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN,onFailure:e=>{ya(be,d,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),l(e)}},y=Gf(ie)?ga({address:h.address,appConfig:ie,methodScreen:cr.FUNDING_METHOD_SELECTION_SCREEN,fundWalletConfig:r,comingFromSendTransactionScreen:!0}):void 0;de({connectWallet:m,sendSolanaTransaction:{transactionRequest:e,connection:t,transactionOptions:n,transactingWallet:h,onSuccess:e=>{o?ya(be,"signSolanaTransaction","onSuccess",{signedTransaction:e.signedTransaction}):ya(be,"sendSolanaTransaction","onSuccess",{response:e}),s(e)},onFailure:e=>{ya(be,d,"onError",A.TRANSACTION_FAILURE),l(e)},uiOptions:a||{},requesterAppId:c,signOnly:o},funding:y}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}}));function Xe(){return new Promise((async(e,t)=>{let n=await rw();if(!n||!re)throw Error("Must have valid access token to enroll in MFA");try{await re.verifyMfa({accessToken:n}),e()}catch(e){t(e)}}))}let et=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],tt=e=>{let t=f?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:n,loginMethod:r}=Ep(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw ya(be,"linkAccount","onError",A.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:r}),new T(`User already has an account of type ${n} linked.`)};async function it({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){F(null);let n=t?"setWalletPassword":"setWalletRecovery";if(!y||!f)throw ya(be,n,"onError",A.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let r=wr(f);if(!r||!re)throw ya(be,n,"onError",A.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");try{await Xe()}catch(e){throw ya(be,n,"onError",A.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,i)=>{le(!0);let o={onSuccess:e=>{ya(be,n,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{ya(be,n,"onError",A.USER_EXITED_SET_PASSWORD_FLOW),i(e)},callAuthOnSuccessOnClose:!1},s="user-passcode"===r.recoveryMethod,l=Jc({walletAction:"update",availableRecoveryMethods:ie.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:s,showAutomaticRecovery:e}),{entropyId:c,entropyIdVerifier:d}=jn(r);de({setWalletPassword:o,recoverWallet:{entropyId:c,entropyIdVerifier:d,onFailure:i},createWallet:o,connectWallet:{onCompleteNavigateTo:l,shouldForceMFA:!1,entropyId:c,entropyIdVerifier:d,onFailure:e=>{ya(be,n,"onError",A.UNKNOWN_CONNECT_WALLET_ERROR),i(e)}},recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:s}}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}))}async function ot({appId:e,action:t}){let n=await rw();if("link"===t&&!n)throw ya(be,"linkAccount","onError",A.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new T("User must be authenticated before linking an account.");if("login"===t&&n)throw ya(be,"login","onError",A.UNKNOWN_AUTH_ERROR),new T("Attempted to log in, but user is already logged in. Use a `link` helper instead.");ke.current=`privy:${e}`,Ie.current=t;let r=Zu();return a.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,i)=>{let{name:o,logoUrl:s}=await Hf({api:a.api,providerAppId:e,requesterAppId:ie.id});de({crossAppAuth:{appId:e,name:o,logoUrl:s,action:t,popup:r,onSuccess:n,onError:i}}),Re(cr.CROSS_APP_AUTH_SCREEN)}))}let st={ready:p,authenticated:y,user:f,walletConnectors:a.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),de({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,suggestedAddress:e?.suggestedAddress,walletChainType:e?.walletChainType}}),Se(y?cr.CONNECT_ONLY_AUTHENTICATED_SCREEN:cr.CONNECT_ONLY_LANDING_SCREEN)},linkWallet:e=>{e&&"target"in e&&e&&(e=void 0),Be("siwe"),ke.current="siwe",Ie.current="link",de({...ce,externalConnectWallet:{...ce.externalConnectWallet,suggestedAddress:e?.suggestedAddress,walletList:e?.walletList,walletChainType:e?.walletChainType}}),Se(cr.LINK_WALLET_SCREEN)},startCrossAppAuthFlow:ot,linkEmail:()=>{Be("email"),tt("email"),ke.current="email",Ie.current="link",Se(cr.LINK_EMAIL_SCREEN)},linkPhone:()=>{Be("sms"),tt("phone"),ke.current="sms",Ie.current="link",Se(cr.LINK_PHONE_SCREEN)},linkGoogle:async()=>{Be("google"),tt("google_oauth"),Ie.current="link",await lt.initLoginWithOAuth("google")},linkTwitter:async()=>{Be("twitter"),tt("twitter_oauth"),Ie.current="link",await lt.initLoginWithOAuth("twitter")},linkDiscord:async()=>{Be("discord"),tt("discord_oauth"),Ie.current="link",await lt.initLoginWithOAuth("discord")},linkGithub:async()=>{Be("github"),tt("github_oauth"),Ie.current="link",await lt.initLoginWithOAuth("github")},linkSpotify:async()=>{Be("spotify"),tt("spotify_oauth"),Ie.current="link",await lt.initLoginWithOAuth("spotify")},linkInstagram:async()=>{Be("instagram"),tt("instagram_oauth"),Ie.current="link",await lt.initLoginWithOAuth("instagram")},linkTiktok:async()=>{Be("tiktok"),tt("tiktok_oauth"),Ie.current="link",await lt.initLoginWithOAuth("tiktok")},linkLinkedIn:async()=>{Be("linkedin"),tt("linkedin_oauth"),Ie.current="link",await lt.initLoginWithOAuth("linkedin")},linkApple:async()=>{Be("apple"),tt("apple_oauth"),Ie.current="link",await lt.initLoginWithOAuth("apple")},linkPasskey:async()=>{Be("passkey"),tt("passkey"),await lt.initLinkWithPasskey(),Se(cr.LINK_PASSKEY_SCREEN)},linkTelegram:async e=>{if(Be("telegram"),tt("telegram"),Ie.current="link",ke.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new Qo;a.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=es(e.launchParams.initDataRaw),de({telegramAuthModalData:{seamlessAuth:!0}}),Re(cr.TELEGRAM_AUTH_SCREEN)}else ya(be,"linkAccount","onError",A.INVALID_DATA,{linkMethod:"telegram"});else await lt.initLoginWithTelegram();Se(cr.TELEGRAM_AUTH_SCREEN)},linkFarcaster:async()=>{Be("farcaster"),tt("farcaster"),await lt.initLoginWithFarcaster(),Ie.current="link",ke.current="farcaster",Se(cr.AWAITING_FARCASTER_CONNECTION)},updateEmail:()=>{if(Be("email"),!f?.email)throw new T("User does not have an email linked to their account.");Ie.current="update",ke.current="email",Se(cr.UPDATE_EMAIL_SCREEN)},updatePhone:()=>{if(Be("sms"),!f?.phone)throw new T("User does not have a phone number linked to their account.");Ie.current="update",ke.current="sms",Se(cr.UPDATE_PHONE_SCREEN)},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(!p){let e=await new Promise((e=>{ue((t=>e.bind(t)))}));if(ue(null),e)return void console.warn(t)}!f||f.isGuest?(Ie.current="login",de({login:e}),Re(cr.LANDING)):console.warn(t)},connectOrCreateWallet:async()=>{p||(await new Promise((e=>{ue((()=>e))})),ue(null)),y?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(Ie.current="login",Re(cr.CONNECT_OR_CREATE))},logout:async()=>{if(Ie.current=null,ke.current=null,f&&a.clearProviderAcccessTokens(f),F(null),await a.logout(),f&&re)try{await re.clearMfa({userId:f.id})}catch(e){}w(null),g(!1),ya(be,"logout","onSuccess"),u(!1),Zr.del(sr),Zr.del(Dn(ie.id))},getAccessToken:c((()=>a.getCustomerAccessToken()),[a]),unlinkWallet:async e=>{let t;return w(t=e.startsWith("0x")?await a.unlinkEthereumWallet(e):await a.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await a.unlinkEmail(e);return w(t),t},unlinkPhone:async e=>{let t=await a.unlinkPhone(e);return w(t),t},unlinkGoogle:async e=>{let t=await a.unlinkOAuth("google",e);return w(t),t},unlinkTwitter:async e=>{let t=await a.unlinkOAuth("twitter",e);return w(t),t},unlinkDiscord:async e=>{let t=await a.unlinkOAuth("discord",e);return w(t),t},unlinkGithub:async e=>{let t=await a.unlinkOAuth("github",e);return w(t),t},unlinkSpotify:async e=>{let t=await a.unlinkOAuth("spotify",e);return w(t),t},unlinkInstagram:async e=>{let t=await a.unlinkOAuth("instagram",e);return w(t),t},unlinkTiktok:async e=>{let t=await a.unlinkOAuth("tiktok",e);return w(t),t},unlinkLinkedIn:async e=>{let t=await a.unlinkOAuth("linkedin",e);return w(t),t},unlinkApple:async e=>{let t=await a.unlinkOAuth("apple",e);return w(t),t},unlinkFarcaster:async e=>{let t=await a.unlinkFarcaster(e);return w(t),t},unlinkTelegram:async e=>{let t=await a.unlinkTelegram(e);return w(t),t},unlinkPasskey:async e=>{let t=await rw();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!re)throw Error("Wallet proxy not initialized.");let n=ie.passkeys.shouldUnenrollMfaOnUnlink;await re.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:n});let r=await a.getAuthenticatedUser();return w(r),r},unlinkCrossAppAccount:async({subject:e})=>{let t=f?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new T("Invalid subject");a.storeProviderAccessToken(t.id,null);let n=await a.unlinkOAuth(`privy:${t.id}`,e);return w(n),n},createWallet:async e=>{e&&"target"in e&&e&&(e=void 0);let t=await lt.refreshSessionAndUser();if(!t)throw ya(be,"createWallet","onError",A.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return $e(t,15e3,e)},setWalletRecovery:async e=>it({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>it({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{},o=e.message;if(!y||!f)return ya(be,"signMessage","onError",A.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let s=t?.address??yr(f)?.address;if(!s)throw new T("User must have an embedded wallet to sign a message.");let{signingWallet:l,rootWallet:c}=$r(f,s);if(!l||!c)return ya(be,"signMessage","onError",A.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));if("string"!=typeof o||o.length<1)return ya(be,"signMessage","onError",A.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));le(!0);let d=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let e=await rw();if(!re||!e||!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:l.address,requesterAppId:i}});let{entropyId:t,entropyIdVerifier:n}=jn(c),{response:r}=await re.rpc({accessToken:e,entropyId:t,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:l.walletIndex??0,requesterAppId:i,request:{method:"personal_sign",params:[o,l.address]}}),s=r.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:l.address,requesterAppId:i}}),s};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await d();ya(be,"signMessage","onSuccess",{signature:e}),n({signature:e})}catch(e){ya(be,"signMessage","onError",A.UNABLE_TO_SIGN),r(e??new ca("Unable to sign message"))}else{let e={method:"personal_sign",data:o,confirmAndSign:d,onSuccess:e=>{ya(be,"signMessage","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{ya(be,"signMessage","onError",A.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},{entropyId:a,entropyIdVerifier:i}=jn(c);de({signMessage:e,connectWallet:{entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{ya(be,"signMessage","onError",A.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),signTypedData:(e,t)=>new Promise((async(n,r)=>{let{requesterAppId:i}=t?.uiOptions||{};if(!y||!f)return ya(be,"signTypedData","onError",A.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let o=t?.address??yr(f)?.address;if(!o)throw new T("User must have an embedded wallet to sign a message.");let{signingWallet:s,rootWallet:l}=$r(f,o);if(!l||!s)return ya(be,"signTypedData","onError",A.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));le(!0);let c=Je(e),d=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let e=await rw();if(!re||!e||!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:s.address,requesterAppId:i}});let{entropyId:t,entropyIdVerifier:n}=jn(l),{response:r}=await re.rpc({accessToken:e,entropyId:t,entropyIdVerifier:n,chainType:"ethereum",hdWalletIndex:s.walletIndex??0,requesterAppId:i,request:{method:"eth_signTypedData_v4",params:[s.address,c]}}),o=r.data;return a.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:s.address,requesterAppId:i}}),o};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await d();ya(be,"signTypedData","onSuccess",{signature:e}),n({signature:e})}catch(e){ya(be,"signTypedData","onError",A.UNABLE_TO_SIGN),r(e??new ca("Unable to sign message"))}else{let e={method:"eth_signTypedData_v4",data:c,confirmAndSign:d,onSuccess:e=>{ya(be,"signTypedData","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{ya(be,"signTypedData","onError",A.UNABLE_TO_SIGN),r(e)},uiOptions:t?.uiOptions||{}},{entropyId:a,entropyIdVerifier:i}=jn(l);de({signMessage:e,connectWallet:{entropyId:a,entropyIdVerifier:i,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{ya(be,"signMessage","onError",A.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),sendTransaction:async(e,t)=>await Ye({transaction:e,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await Ye({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),exportWallet:e=>new Promise((async(t,r)=>{if(!y||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));e&&"target"in e&&e&&(e=void 0);let i=e?.address??yr(f)?.address;if(!i)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(!E(i))return void r(Error("Must provide a valid Ethereum address."));let{signingWallet:o,rootWallet:s}=$r(f,i);if(!o||!s)return void r(Error("Must have a Privy wallet before exporting"));le(!0);let{entropyId:l,entropyIdVerifier:c}=jn(s),d={entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:cr.EMBEDDED_WALLET_KEY_EXPORT_SCREEN,onFailure:r,shouldForceMFA:!0};de(ce),await rw()&&re?re?(de({keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:o,primaryWallet:s,onSuccess:t,onFailure:r},connectWallet:d}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)):r(Error("Must have a Privy wallet before exporting")):r(Error("Must have valid access token to enroll in MFA"))})),promptMfa:Xe,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 T("Invalid MFA code");Ee.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{Te.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new T("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));Ee.current?.resolve({mfaMethod:e,mfaCode:r,relyingParty:window.origin}),await new Promise(((e,t)=>{Te.current={resolve:e,reject:t}}));break;default:throw Ee.current?.reject(new T("Unsupported MFA method")),new T(`Unsupported MFA method: ${e}`)}},cancel(){Ee.current?.reject(new T("MFA canceled"))},async initEnrollmentWithSms(e){let t=await rw();if(!t||!re)throw Error("Must have valid access token to enroll in MFA");await re.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,n)=>{if(!e)return lt.closePrivyModal(),void t();ie.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."),de({mfaEnrollmentFlow:{mfaMethods:ie.mfa.methods,shouldUnlinkOnUnenrollMfa:ie.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:n}}),Se(cr.MFA_ENROLLMENT_FLOW_SCREEN)})),async initEnrollmentWithTotp(){let e=await rw();if(!e||!re)throw Error("Must have valid access token to enroll in MFA");let t=await re.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await rw();if(!t||!re)throw Error("Must have valid access token to enroll in MFA");await re.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),w(await a.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await rw();if(!t||!re)throw Error("Must have valid access token to enroll in MFA");await re.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),w(await a.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let n=await rw();if(!n||!re)throw Error("Must have valid access token to enroll in MFA");await re.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:e,removeForLogin:t.removeForLogin}),w(await a.getAuthenticatedUser())},async unenroll(e,t={}){let n=await rw();if(!n||!re)throw Error("Must have valid access token to remove MFA");"passkey"===e?await re.submitEnrollMfa({method:"passkey",accessToken:n,credentialIds:[],removeForLogin:t.removeForLogin}):await re.unenrollMfa({method:e,accessToken:n}),w(await a.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await rw(),t=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!re||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");let n=await re.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===n.status&&w(await a.getAuthenticatedUser()||f||null),de({farcasterSigner:n}),Se(cr.AWAITING_FARCASTER_SIGNER)},getFarcasterSignerPublicKey:async()=>{let e,t=await rw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!re||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=f.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await rw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!re||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!f.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let r=await import("@simplewebauthn/browser"),a=await re.signFarcasterMessage({address:n.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:r.bufferToBase64URLString(e)},fid:BigInt(f.farcaster.fid),relyingParty:window.origin});return new Uint8Array(r.base64URLStringToBuffer(a.signature))},createGuestAccount:async()=>{if(f&&!f.isGuest)throw Error("User cannot already be authenticated to create a guest account");return f?.isGuest?f:lt.loginWithGuestAccountFlow()},signMessageWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Vf({user:f,client:a,address:t,requesterAppId:ie.id,request:{method:r?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:n},reconnect:ot})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:n}){let r=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),i=Je(e);return Vf({user:f,client:a,address:t,requesterAppId:ie.id,request:{method:r?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,i],chainId:n},reconnect:ot})},sendTransactionWithCrossAppWallet(e,{address:t}){let n=f?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Vf({user:f,client:a,address:t,requesterAppId:ie.id,request:{method:n?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:ot})},isModalOpen:h,mfaMethods:ie.mfa.methods};Yf=st.signMessage,Zf=st.signTypedData,Qf=async(e,t)=>await Ye({transaction:e,...t,signOnly:!1}),Jf=async(e,t)=>({signature:(await Ye({transaction:e,...t,signOnly:!0})).hash});let lt={setAuthenticated:g,setUser:w,isNewUserThisSession:O,pendingTransaction:null,walletConnectionStatus:H,connectors:a.connectors?.walletConnectors??[],solanaWallets:N,rpcConfig:ie.rpcConfig,chains:ie.chains,appId:n.appId,showFiatPrices:"native-token"!==ie.embeddedWallets.priceDisplay.primary,clientAnalyticsId:a.clientAnalyticsId,customAuthStatus:ve,hideWalletUIs:Ne,isHeadlessSigning:c(xe,[ie.embeddedWallets.showWalletUIs]),emailOtpState:G,setEmailOtpState:q,smsOtpState:K,setSmsOtpState:Y,oAuthState:X,setOAuthState:ee,telegramAuthState:te,setTelegramAuthState:ne,siweState:J,setSiweState:Q,isHeadlessOAuthLoading:B,nativeTokenSymbolForChainId:e=>ie.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(re)return re;let t=new Promise((e=>{me((()=>t=>e(t)))})),n=new Promise((t=>setTimeout((()=>t(null)),e))),r=await Promise.race([t,n]);return me(null),r},getAuthFlow:()=>a.authFlow,getAuthMeta:()=>a.authFlow?.meta,client:a,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=p&&y&&f;r&&ke.current&&(t=et(f)),"login"===Ie.current?e.shouldCallAuthOnSuccess&&r&&ke.current?ya(be,"login","onComplete",{user:f,isNewUser:O,wasAlreadyAuthenticated:!1,loginMethod:ke.current,loginAccount:t??null}):ya(be,"login","onError",A.USER_EXITED_AUTH_FLOW):"link"===Ie.current&&t?e.isSuccess&&r&&ke.current?ya(be,"linkAccount","onSuccess",{user:f,linkMethod:ke.current,linkedAccount:t}):ke.current&&ya(be,"linkAccount","onError",A.USER_EXITED_LINK_FLOW,{linkMethod:ke.current}):"update"===Ie.current&&t&&(e.isSuccess&&r&&ke.current?ya(be,"update","onSuccess",{user:f,updateMethod:ke.current,updatedAccount:t}):ke.current&&ya(be,"update","onError",A.USER_EXITED_UPDATE_FLOW,{linkMethod:ke.current}));let i=U&&Lu.includes(U),o=U===cr.ERROR_SCREEN&&ce.errorModalData&&Lu.includes(ce.errorModalData.previousScreen);if((i||o)&&ce.funding){let e,t=Du[U]??null;if("solana"===ce.funding.chainType){let n=d(aa);if(n)try{e=BigInt(await n.getBalance({address:ce.funding.address,cluster:ce.funding.cluster}))}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");ya(be,"fundSolanaWallet","onUserExited",{address:ce.funding.address,cluster:ce.funding.cluster,fundingMethod:t,balance:e})}else{let r=Ha(ce.funding.chain.id,ie.chains,ie.rpcConfig,{appId:n.appId});try{e=await r.getBalance({address:ce.funding.address})}catch{console.error("Unable to pull wallet balance")}ya(be,"fundWallet","onUserExited",{address:ce.funding.address,chain:ce.funding.chain,fundingMethod:t,balance:e})}}de({...ce,externalConnectWallet:{suggestedAddress:void 0}}),Ie.current=null,ke.current=null,W(!1),u(!1),setTimeout((()=>{a.authFlow=void 0}),200)},solanaSignMessage:({message:e,options:t})=>new Promise((async(n,r)=>{if(!y||!f)return ya(be,"signSolanaMessage","onError",A.MUST_BE_AUTHENTICATED),void r(Error("User must be authenticated before signing with a Privy wallet"));let i=t?.address??gr(f)?.address;if(!i)throw new T("User must have an embedded wallet to sign a message.");let{signingWallet:o,rootWallet:s}=Dr(f,i);if(!o||!s)return ya(be,"signSolanaMessage","onError",A.EMBEDDED_WALLET_NOT_FOUND),void r(Error("Must have a Privy wallet before signing"));if("string"!=typeof e||e.length<1)return ya(be,"signMessage","onError",A.INVALID_MESSAGE),void r(Error("Message must be a non-empty string"));le(!0);let l=async()=>{if(!y)throw Error("User must be authenticated before signing with a Privy wallet");let t=await a.getAccessToken();if(!t)throw Error("User must be authenticated to use their embedded wallet.");let n=lt.walletProxy??await lt.initializeWalletProxy(15e3);if(!n)throw Error("Failed to initialize embedded wallet proxy.");if(!await lt.recoverPrimaryWallet())throw Error("Unable to connect to wallet");if(!s)throw Error("No root wallet for signing wallet found");let{entropyId:r,entropyIdVerifier:i}=Kr(f),{response:l}=await n.rpc({accessToken:t,entropyId:r,entropyIdVerifier:i,chainType:"solana",hdWalletIndex:o.walletIndex??0,request:{method:"signMessage",params:{message:e}}});return l.data.signature};if(xe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await l();ya(be,"signSolanaMessage","onSuccess",{signature:new Uint8Array(Buffer.from(e,"base64"))}),n({signature:e})}catch(e){r(e)}else{let a={method:"solana_signMessage",data:e,confirmAndSign:l,onSuccess:e=>{ya(be,"signSolanaMessage","onSuccess",{signature:new Uint8Array(Buffer.from(e,"base64"))}),n({signature:e})},onFailure:e=>{r(e)},uiOptions:t?.uiOptions},{entropyId:i,entropyIdVerifier:o}=jn(s);de({signMessage:a,connectWallet:{entropyId:i,entropyIdVerifier:o,onCompleteNavigateTo:cr.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN,onFailure:e=>{ya(be,"signSolanaMessage","onError",A.UNKNOWN_CONNECT_WALLET_ERROR),r(e)}}}),Re(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)}})),signSolanaTransaction:async({transaction:e,connection:t,uiOptions:n,transactionOptions:r,address:a})=>{let i=a?S.find((e=>e.address===a)):S.slice().sort(((e,t)=>(e.walletIndex??0)-(t.walletIndex??0)))[0];if(!i)throw ya(be,"signSolanaTransaction","onError",A.EMBEDDED_WALLET_NOT_FOUND),new T("Embedded wallet not found",A.EMBEDDED_WALLET_NOT_FOUND);let{signedTransaction:o}=await Qe({transaction:e,connection:t,transactionOptions:r,uiOptions:n,wallet:i,signOnly:!0});return o},sendSolanaTransaction:async({transaction:e,connection:t,uiOptions:n,transactionOptions:r,fundWalletConfig:a,address:i})=>{let o=i?S.find((e=>e.address===i)):S.slice().sort(((e,t)=>(e.walletIndex??0)-(t.walletIndex??0)))[0];if(!o)throw ya(be,"sendSolanaTransaction","onError",A.EMBEDDED_WALLET_NOT_FOUND),new T("Embedded wallet not found",A.EMBEDDED_WALLET_NOT_FOUND);return await Qe({transaction:e,connection:t,transactionOptions:r,uiOptions:n,fundWalletConfig:a,wallet:o,signOnly:!1})},openPrivyModal:Se,connectWallet:Le,initLoginWithWallet:async(e,t,n)=>{rt(e)?(ke.current="siwe",De(e,t,n)):(ke.current="siws",Ue(e,t,n))},loginWithWallet:async()=>{let e,t,n;if(!p)throw new L;if(a.authFlow instanceof at?e="siwe":a.authFlow instanceof xn&&(e="siws"),!e)throw new T("Must initialize SIWE/SIWS flow first.");if(null!==await a.getAccessToken())try{({user:t}=await a.link()),ke.current=e}catch(t){throw ya(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:n}=await a.authenticate()),ke.current=e}catch(e){throw ya(be,"login","onError",e.privyErrorCode||A.GENERIC_CONNECT_WALLET_ERROR),e}w(t||f||null),W(n||!1),g(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:n})=>new Promise((async(r,a)=>{let i=await rw();if(!y||!f||!i)throw new T("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new T("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=lt.walletProxy??await lt.initializeWalletProxy(15e3);if(!o)throw new T("Wallet proxy not initialized.");if((({address:e,chainType:t,user:n})=>!!Lf(n).find((n=>n.address===e&&n.chainType===t)))({address:e,chainType:t,user:f}))return r();let s=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new T("Address to delegate is not associated with current user.");return{address:n.address,chainType:n.chainType,walletIndex:n.walletIndex??0}})({address:e,user:f}),l=(({address:e,user:t})=>{let n=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!n)throw new T("Address to delegate is not associated with current user.");let r=n.imported?n:wr(t);if(!r)throw new T("Unable to determine root address for delegated address.");return{address:r.address,chainType:r.chainType,imported:r.imported}})({address:e,user:f}),c=async()=>{await o.createDelegatedAction({accessToken:i,rootWallet:l,delegatedWallets:[s]}),await lt.refreshSessionAndUser()};if(await lt.recoverPrimaryWallet(),n)de({delegatedActions:{consent:{address:e,onDelegate:c,onSuccess:async()=>{r()},onError:async e=>{a(e)}}}}),Se(cr.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN);else try{await c(),r()}catch(e){a(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,n)=>{if(!y||!f)throw new T("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");if(0===Lf(f).length)throw new T("User has no delegated wallets to revoke.");let r=async()=>{await a.revokeDelegatedWallet(),await lt.refreshSessionAndUser()};if(e)de({delegatedActions:{revoke:{onRevoke:r,onSuccess:async()=>{t()},onError:async e=>{n(e)}}}}),Se(cr.EMBEDDED_WALLET_DELEGATED_ACTIONS_REVOKE_SCREEN);else try{await r(),t()}catch(e){n(e)}})),initLoginWithFarcaster:async(e,t)=>{let n=new Io(e,t);a.startAuthFlow(n);try{ke.current="farcaster",await n.initializeFarcasterConnect()}catch(e){throw"login"===Ie.current?ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&ya(be,"linkAccount","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!p)throw new L;if(!(a.authFlow instanceof Io))throw new T("Must initialize Farcaster flow first.");if(null!==await a.getAccessToken())try{({user:e}=await a.link()),ke.current="farcaster"}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await a.authenticate()),ke.current="farcaster"}catch(e){throw ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}w(e||null),W(t||!1),g(!0)},async loginWithGuestAccountFlow(){let e=new xo(this.appId);a.startAuthFlow(e);try{Ie.current="login",ke.current="guest";let{user:e,isNewUser:t}=await a.authenticate();if(t=t||!1,!e)throw new T("Unable to authenticate guest account");let n=await rw(),r=await lt.initializeWalletProxy(fr);if(n&&r)try{let t=Wt(e,ie.embeddedWallets.ethereum.createOnLogin),a=Mt(e,ie.embeddedWallets.solana.createOnLogin);if(t&&a){let t=await $e(e,fr);await r.createSolana({accessToken:n,ethereumAddress:t?.address}),e=await lt.refreshSessionAndUser()}else a?(await r.createSolana({accessToken:n,ethereumAddress:yr(e)?.address}),e=await lt.refreshSessionAndUser()):t?(await $e(e,fr),e=await lt.refreshSessionAndUser()):w(e)}catch(t){w(e),console.warn("Unable to create embedded wallet for guest account")}return W(t),g(!0),ya(be,"login","onComplete",{user:e,isNewUser:t,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),e}catch(e){throw ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}},async crossAppAuthFlow({appId:e,popup:t,action:n}){let r=`privy:${e}`;ke.current=r;let{url:i,stateCode:o,codeVerifier:s}=await async function({api:e,appId:t}){let n=So(),r=Ro(),a=await Oo(n);try{let{url:i}=await e.post(Z,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:a,state_code:r});return{url:i,stateCode:r,codeVerifier:n}}catch(e){throw b(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 T("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 T("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 T("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 T(t.data.error)),i()),t.data.type===Bf&&((r=new BroadcastChannel(Ff)).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 T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED);let h=await async function({appId:e,stateCode:t,codeVerifier:n,authorizationCode:r,action:a,client:i}){if(!r||!t)throw new T("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===r)throw new T("User denied confirmation during cross-app auth flow");try{let o=new zf({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=b(e);if(t.privyErrorCode)throw new T(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 T("Invalid code during cross-app auth flow.",void 0,A.OAUTH_USER_DENIED);throw new T("Invalid code during cross-app auth flow.",void 0,A.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:s,stateCode:c,authorizationCode:d,action:n,client:a});h&&a.storeProviderAccessToken(e,h);let u=await lt.refreshSessionAndUser();if(!u)throw new T("Unable to update user");return a.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),u}catch(e){throw a.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:r}}),e}},async initLoginWithOAuth(e,t,n){if(ke.current=e,!Yr())return void Re(cr.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE);if("google"===e&&vc(window.navigator.userAgent))return void Re(cr.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE);"twitter"===e&&window.opener&&window.opener.postMessage({type:Bf},"*"),Zr.del(Fn),Zr.del(Bn);let r=new Wo({provider:e,disableSignup:!!n,withPrivyUi:!0});t&&r.addCaptchaToken(t),a.startAuthFlow(r);let i=await a.authFlow.getAuthorizationUrl();i&&i.url&&("twitter"===e&&v&&(i.url=i.url.replace("x.com","twitter.com")),window.location.assign(i.url))},async initLoginWithTelegram(e,t){if(!p)throw new L;ke.current="telegram";let n=new Qo(e,t);a.startAuthFlow(n),ne({status:"loading"}),n.meta.telegramWebAppData=void 0,n.meta.telegramAuthResult=await new Promise(((e,t)=>ie.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:ie.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(n=>n?e(n):t(new T("Telegram auth failed or was canceled by the client")))):t(new T("Telegram was not initialized")):t(new T("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,n;if(!(a.authFlow instanceof Qo))throw new T("Must initialize Telegram flow before calling loginWithTelegram");a.authFlow.meta.captchaToken||=e?.captchaToken;let r=await rw(),i=e?.intent||Ie.current;if("login"===i)try{let e=await a.authenticate();t=e.user,n=e.isNewUser,ke.current="telegram"}catch(e){throw ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}else{if("link"!==i)throw new T("Unknown auth intent");try{t=(await a.link()).user,ke.current="telegram"}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}w(t),W(n||!1),g(!0),ne({status:"done"});let o=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:n||!1,wasAlreadyAuthenticated:!!r,loginAccount:o}},async recoveryOAuthFlow(e,t,n){let r,i;function o(t){if(!t)throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:"Unable to open recovery OAuth popup",provider:e}}),new T("Recovery OAuth failed")}switch(e){case"google-drive":{let t,s,{url:l,codeVerifier:c,stateCode:d}=await Xc({api:Kf.api,provider:e});o(l);try{let r=await qf({url:l,popup:n,provider:e});if(t=r.stateCode,s=r.authorizationCode,t!==d)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:d??"",returnedStateCode:t??""}}),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED)}catch(t){throw a.createAnalyticsEvent({eventName:"recovery_oauth_error",payload:{error:t.toString(),provider:e}}),new T("Recovery OAuth failed")}[r,i]=await Promise.all([rw(),ed({api:Kf.api,provider:e,codeVerifier:c,stateCode:t,authorizationCode:s})]);break}case"icloud":{let{url:t}=await Xc({api:Kf.api,provider:e});o(t);let{ckWebAuthToken:a}=await qf({url:t,popup:n,provider:e});i=a,r=await rw()}}if(!re)throw new T("Cannot connect to wallet proxy");if(!r)throw new T("Unable to authorize user");switch(t){case"recover":{let t=ce.recoverWallet?.entropyId,n=ce.recoverWallet?.entropyIdVerifier;if(!t||!n)throw new T("Recovery OAuth failed");a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:t,recoveryMethod:e}}),await re.recover({accessToken:r,entropyId:t,entropyIdVerifier:n,recoveryAccessToken:i}),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:t,recoveryMethod:e}});break}case"create-wallet":{a.createAnalyticsEvent({eventName:"embedded_wallet_creation_started"}),await re.create({accessToken:r,recoveryAccessToken:i,recoveryMethod:e});let t=yr(await lt.refreshSessionAndUser());if(!t)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to create wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_creation_completed",payload:{walletAddress:t.address}}),ya(be,"createWallet","onSuccess",{wallet:t});break}case"set-recovery":{let t=wr(f);if(!t)throw ya(be,"setWalletRecovery","onError",A.EMBEDDED_WALLET_NOT_FOUND),Error("Embedded wallet not found");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}});let{entropyId:n,entropyIdVerifier:o}=jn(t);await re.setRecovery({accessToken:r,entropyId:n,entropyIdVerifier:o,recoveryMethod:e,recoveryAccessToken:i});let s=wr(await lt.refreshSessionAndUser());if(!s)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to set recovery on wallet");a.createAnalyticsEvent({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:t.address,existingRecoveryMethod:t.recoveryMethod,targetRecoveryMethod:e}}),ya(be,"setWalletRecovery","onSuccess",{method:e,wallet:s});break}default:throw new T("Unsupported recovery action")}},async loginWithOAuth(e){let t,n,r;if(!(a.authFlow instanceof Wo))throw new T("Must initialize OAuth flow before calling loginWithOAuth");let i=Zr.get(zn),o=a.authFlow.meta.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:i??"",returnedStateCode:o??""}}),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{let n=await a.link();t=n.user,r=n.oAuthTokens,ke.current=e}catch(t){throw ya(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let i=await a.authenticate();t=i.user,n=i.isNewUser,r=i.oAuthTokens,ke.current=e}catch(t){throw"login"===Ie.current?ya(be,"login","onError",t.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&ya(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return w(t),W(n||!1),g(!0),r&&t&&ya(be,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),r},passkeyAuthState:$,setPasskeyAuthState:j,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let n=new Yo({captchaToken:e,setPasskeyAuthState:j});a.startAuthFlow(n),Ie.current="login";try{ke.current="passkey",j({status:"generating-challenge"}),await n.initRegisterFlow(t),j({status:"awaiting-passkey"})}catch(e){throw j({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!p)throw new L;if(!(a.authFlow instanceof Yo))throw new T("Must initialize Passkey flow first.");if("passkey"!==ke.current){let e=new T("Must init login with Passkey flow first.");throw j({status:"error",error:e}),e}let n=await rw();try{ke.current="passkey",j({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await a.authenticate())}catch(e){throw j({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}w(e),W(t||!1),g(!0),j({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 Yo({captchaToken:e,setPasskeyAuthState:j});a.startAuthFlow(n),Ie.current="login";try{ke.current="passkey",j({status:"generating-challenge"}),await n.initAuthenticationFlow(t),j({status:"awaiting-passkey"})}catch(e){throw j({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,n;if(!p)throw new L;if(!(a.authFlow instanceof Yo))throw new T("Must initialize Passkey flow first.");if(e?.credentialIds&&(a.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==ke.current){let e=new T("Must init login with Passkey flow first.");throw j({status:"error",error:e}),e}let r=await rw();try{ke.current="passkey",j({status:"awaiting-passkey"}),({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw j({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}w(t),W(n||!1),g(!0),j({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 Yo({captchaToken:e});a.startAuthFlow(t),Ie.current="link",ke.current="passkey",j({status:"generating-challenge"});try{await t.initLinkFlow(),j({status:"awaiting-passkey"})}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),j({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!p)throw new L;if(!(a.authFlow instanceof Yo))throw new T("Must initialize Passkey flow first.");if("passkey"!==ke.current)throw new T("Must init login with Passkey flow first.");try{ke.current="passkey",({user:e}=await a.link())}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return w(e||f||null),j({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,n){if(!Yr())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&&vc(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 Wo({provider:e,withPrivyUi:!1,disableSignup:n??!1});t&&r.addCaptchaToken(t),ee({status:"loading"});let i=await a.startAuthFlow(r).getAuthorizationUrl();i?.url&&window.location.assign(i.url)},async loginWithHeadlessOAuth(e){let t,n,r;z(!0),ee({status:"loading"}),a.startAuthFlow(new Wo(e));let i=Zr.get(zn),o=e.stateCode;if(i!==o)throw a.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:i??"",returnedStateCode:o??""}}),z(!1),new T("Unexpected auth flow. This may be a phishing attempt.",void 0,A.OAUTH_UNEXPECTED);if(null!==await a.getAccessToken())try{({user:t,oAuthTokens:r}=await a.link()),ke.current=e.provider;let n=et(t);t&&n&&ya(be,"linkAccount","onSuccess",{user:t,linkMethod:ke.current,linkedAccount:n})}catch(t){throw z(!1),ya(be,"linkAccount","onError",t.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:n,oAuthTokens:r}=await a.authenticate()),ke.current=e.provider;let i=et(t);t&&i&&void 0!==n&&ya(be,"login","onComplete",{user:t,isNewUser:n,wasAlreadyAuthenticated:!1,loginMethod:ke.current,loginAccount:i})}catch(e){throw z(!1),ee({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}return w(t),W(n||!1),g(!0),z(!1),ee({status:"done"}),r&&t&&ya(be,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:r,user:t}),t??void 0},initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{let i=new _o({email:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ke.current="email",q({status:"sending-code"}),await i.sendCodeEmail({withPrivyUi:r}),q({status:"awaiting-code-input"})}catch(e){throw q({status:"error",error:e}),"login"===Ie.current?ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async(e,t,n)=>{let r=new ko(e,t,n);a.startAuthFlow(r);try{await r.sendCodeEmail({withPrivyUi:!0})}catch(e){ya(be,"update","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:ke.current})}},initUpdatePhone:async(e,t,n)=>{let r=new Jo(e,t,n);a.startAuthFlow(r);try{await r.sendSmsCode({withPrivyUi:!0})}catch(e){ya(be,"update","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:ke.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:n,withPrivyUi:r})=>{Y({status:"sending-code"});let i=new Zo({phoneNumber:e,captchaToken:t,disableSignup:n});a.startAuthFlow(i);try{ke.current="sms",await i.sendSmsCode({withPrivyUi:r}),Y({status:"awaiting-code-input"})}catch(e){throw Y({status:"error",error:e}),"login"===Ie.current?ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR):"link"===Ie.current&&ya(be,"linkAccount","onError",e.privyErrorCode||A.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 _o?q(e):a.authFlow instanceof Zo&&Y(e)}if(r({status:"submitting-code"}),!p){let e=new L;throw r({status:"error",error:e}),e}if(a.authFlow instanceof _o)a.authFlow.meta.emailCode=e.trim();else{if(!(a.authFlow instanceof Zo)){let e=new T("Must initialize a passwordless code flow first");throw r({status:"error",error:e}),e}a.authFlow.meta.smsCode=e.trim()}let i=await rw();if("link"===Ie.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:ke.current}),e}else if("update"===Ie.current)try{({user:t}=await a.link())}catch(e){throw r({status:"error",error:e}),ya(be,"update","onError",e.privyErrorCode||A.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:ke.current}),e}else try{({user:t,isNewUser:n}=await a.authenticate())}catch(e){throw r({status:"error",error:e}),ya(be,"login","onError",e.privyErrorCode||A.UNKNOWN_AUTH_ERROR),e}let o=t||f;w(o||null),W(n||!1),g(!0),r({status:"done"});let s=null;return a.authFlow instanceof _o?s=o?.linkedAccounts.find((({type:e})=>"email"===e))||null:a.authFlow instanceof Zo&&(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})=>{Ie.current="link",ke.current="siwe",Q({status:"generating-message"});let r=await a.generateSiweNonce({address:e,captchaToken:n});return Q({status:"awaiting-signature"}),Sn({address:e,chainId:t.replace("eip155:",""),nonce:r})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let n=await a.generateSiweNonce({address:e});return Sn({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}),w((r=await lt.refreshSessionAndUser()??r)||f||null)},linkWithSiwe:async({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i})=>{let o;Be("siwe");let s=null;try{Q({status:"submitting-signature"}),o=await a.linkWithSiwe({message:e,signature:t,chainId:n,walletClientType:r,connectorType:i}),o=await lt.refreshSessionAndUser()??o,Q({status:"done"}),(s=et(o)||null)&&ya(be,"linkAccount","onSuccess",{user:o,linkMethod:"siwe",linkedAccount:s})}catch(e){throw ya(be,"linkAccount","onError",e.privyErrorCode||A.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),Ie.current=null,ke.current=null,Q({status:"error",error:e}),e}let l=o||f;return w(l||null),Ie.current=null,ke.current=null,{user:l,linkedAccount:s}},refreshSessionAndUser:async()=>{let e=await a.getAuthenticatedUser();return g(!!e),w(e),e},walletProxy:re,createAnalyticsEvent:({eventName:e,payload:t,timestamp:n})=>a.createAnalyticsEvent({eventName:e,payload:t,timestamp:n}),acceptTerms:async()=>{let e=await a.acceptTerms();return w(e),e},getUsdTokenPrice:e=>a.getUsdTokenPrice(e),getUsdPriceForSol:()=>a.getUsdPriceForSol(),getSplTokenMetadata:e=>a.getSplTokenMetadata(e),recoverPrimaryWallet:async e=>new Promise((async(t,n)=>{let r=wr(e?.user??f)||Hr(e?.user??f)||Lr(e?.user??f);r||t(!0);let i=await rw();if(!i||!re||!r)return void n(Error("Must have valid access token and Privy wallet to recover wallet"));le(!0);let{entropyId:o,entropyIdVerifier:s}=jn(r);try{await re.connect({accessToken:i,entropyId:o,entropyIdVerifier:s}),t(!0)}catch(e){$c(e)&&"privy"===r.recoveryMethod?(a.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:r.address}}),(await re.recover({entropyId:o,entropyIdVerifier:s,accessToken:i})).entropyId||n(Error("Unable to recover wallet")),a.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:r.address}}),t(!0)):$c(e)&&"privy"!==r.recoveryMethod?(de({recoverWallet:{entropyId:o,entropyIdVerifier:s,onFailure:n,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:r.recoveryMethod,action:"recover"}}),Se(Qc(r.recoveryMethod))):n(e)}})),embeddedSolanaWallets:S,createEmbeddedSolanaWallet:async e=>{e&&"target"in e&&(e=void 0);let t=await lt.refreshSessionAndUser();if(!t)throw ya(be,"createWallet","onError",A.MUST_BE_AUTHENTICATED),Error("User must be authenticated before creating a Privy wallet");return(async(e,t,n)=>{let r=yr(e),a=gr(e),i=n&&"createAdditional"in n&&n.createAdditional,o=n&&"walletIndex"in n?n.walletIndex:void 0,s=(qr(e)?.walletIndex??-1)+1;if(a&&!i&&"number"!=typeof o)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_ALREADY_EXISTS),Error("User already has an embedded wallet.");if("number"==typeof o&&o<0)throw ya(be,"createWallet","onError",A.EMBEDDED_WALLET_CREATE_ERROR),Error(`A negative walletIndex (${o}) is invalid.`);let[l,c]=await Promise.all([lt.initializeWalletProxy(t),rw()]);if(!l||!c)throw ya(be,"createWallet","onError",A.UNKNOWN_EMBEDDED_WALLET_ERROR),Error("Failed to connect to wallet proxy");return await qe({user:e,wp:l,accessToken:c,walletIndex:o??s,ethereumWallet:r})})(t,15e3,e)},exportSolanaWallet:e=>new Promise((async(t,r)=>{if(!y||!f)return void r(Error("User must be authenticated before exporting their Privy wallet"));let i=e?.address??gr(f)?.address;if(!i)return void r(Error("User does not have an HD Solana wallet."));let{signingWallet:o,rootWallet:s}=Dr(f,i);if(!o||!s)return void r(Error("Must have a Privy wallet before exporting"));if(le(!0),!await rw()||!re)return void r(Error("Must have valid access token to enroll in MFA"));if(!re)return void r(Error("Must have a Privy wallet before exporting"));let{entropyId:l,entropyIdVerifier:c}=jn(s);de({connectWallet:{entropyId:l,entropyIdVerifier:c,onCompleteNavigateTo:cr.EMBEDDED_WALLET_KEY_EXPORT_SCREEN,onFailure:r,shouldForceMFA:!0},keyExport:{appId:n.appId,appClientId:n.clientId,origin:a.apiUrl,walletToExport:o,primaryWallet:s,onSuccess:t,onFailure:r}}),Se(cr.EMBEDDED_WALLET_CONNECTING_SCREEN)})),setReadyToTrue:e=>{m(!0),he?.(e)},updateWallets:()=>Ve(),fundWallet:async(e,t)=>{let n=cr.FUNDING_METHOD_SELECTION_SCREEN;de({funding:fa({address:e,appConfig:ie,fundWalletConfig:t,methodScreen:n})}),Se(n)},openModal:Se,requestFarcasterSignerStatus:async e=>{let t=await rw(),n=f?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!re||!n)throw Error("Must have an embedded wallet to use Farcaster signers");if(!f?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let r=await a.requestFarcasterSignerStatus(e);return"approved"===r.status&&w(await a.getAuthenticatedUser()||f||null),r},connectCoinbaseSmartWallet:async()=>{ie.externalWallets.coinbaseWallet.connectionOptions="smartWalletOnly";let e=a.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||a.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Le(e);await Pe("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 w(c),c}};Xf=lt.recoverPrimaryWallet,ew=lt.recoverPrimaryWallet,tw=lt.solanaSignMessage;let ct=i((()=>({wallets:k,ready:ye&&Ae})),[k,ye,Ae]),dt=a.authFlow instanceof Qo,ht=!ie.headless&&ie.captchaEnabled&&!y&&(p||dt);/*#__PURE__*/return t(Wr.Provider,{value:st,children:/*#__PURE__*/t(wa.Provider,{value:be,children:/*#__PURE__*/t(jr.Provider,{value:ct,children:/*#__PURE__*/t(Rn,{...ie,children:/*#__PURE__*/e(D.Provider,{value:lt,children:[/*#__PURE__*/t(On,{children:/*#__PURE__*/e(Gr,{data:ce,setModalData:de,setInitialScreen:F,initialScreen:U,authenticated:y,open:h,children:[n.children,ht&&/*#__PURE__*/t(Ys,{delayedExecution:!1}),/*#__PURE__*/t(hf,{theme:{...ie.appearance.palette||{}}}),!ie.render.standalone&&/*#__PURE__*/t(bf,{open:h})]})}),se&&oe?/*#__PURE__*/t(Pf,{appId:n.appId,appClientId:n.clientId,clientAnalyticsId:a.clientAnalyticsId,origin:a.apiUrl,mfaMethods:f?.mfaMethods,mfaPromise:Ee,mfaSubmitPromise:Te,onLoad:ae,onLoadFailed:()=>null}):null,ie.loginConfig.telegramAuthConfiguration&&
22
+ /*#__PURE__*/t(sl,{$if:!0,children:/*#__PURE__*/t(kf,{scriptHost:n.apiUrl||ir,botUsername:ie.loginConfig.telegramAuthConfiguration.botName})})]})})})})})};const pw=()=>{let{getAccessToken:e,user:t}=hr(),{refreshSessionAndUser:n,initializeWalletProxy:r}=x(),a=ha();return{importWallet:c((({privateKey:i})=>Co({getAccessToken:e,user:t,initializeWalletProxy:r,refreshSessionAndUser:n,emitPrivyEvent:a},{privateKey:i,chainType:"ethereum"})),[t,e,n,r,a])}},mw=()=>{let{importWallet:e}=pw();return{...u(Wr),importWallet:e}},yw=e=>{ta("login",e);let t=it(),n=Fr(),{ready:r,user:a}=hr(),{initLoginWithHeadlessOAuth:i,loginWithHeadlessOAuth:s,oAuthState:l,setOAuthState:d,isHeadlessOAuthLoading:h}=x(),u=c((async e=>{try{if(t.enabled&&"success"!==t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);return await i(e.provider,t.token,e.disableSignup)}catch(e){throw d({status:"error",error:e}),e}}),[i,t]),p=c((async()=>{let e=qo();try{if(a)return console.warn("Cannot login with OAuth when already logged in"),a;if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");if(e.popupFlow)return}catch(e){throw d({status:"error",error:e}),e}try{return await s(e)}catch(e){throw d({status:"error",error:e}),e}finally{Ko()}}),[s]);return o((()=>{let e=qo();r&&n&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&p().catch((()=>{}))}),[r,n]),{initOAuth:u,loading:h,state:l}},gw=e=>{let t=it(),{emailOtpState:n,setEmailOtpState:r,initLoginWithEmail:a,loginWithCode:i}=x();return{sendCode:c((async({email:n,disableSignup:i})=>{try{let e;if(!n)throw Error("Email required to send OTP code");if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({email:n,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[a]),loginWithCode:c((async({code:n})=>{try{if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);let{user:r,isNewUser:a,wasAlreadyAuthenticated:o,linkedAccount:s}=await i(n);e?.onComplete?.({user:r,isNewUser:a,wasAlreadyAuthenticated:o,loginMethod:"email",loginAccount:s})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[i,t.status]),state:n}},fw=e=>{let t=it(),{initSignupWithPasskey:n,signupWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:i}=x();return{signupWithPasskey:c((async()=>{try{let a;if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),a=await t.waitForResult()),await n({captchaToken:a,withPrivyUi:!1});let{user:i,isNewUser:o,wasAlreadyAuthenticated:s,loginAccount:l}=await r();e?.onComplete?.({user:i,isNewUser:o,wasAlreadyAuthenticated:s,loginMethod:"passkey",loginAccount:l})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||A.UNKNOWN_AUTH_ERROR),t}}),[r,t.status]),state:a}},ww=e=>{let t=it(),{initLoginWithPasskey:n,loginWithPasskey:r,passkeyAuthState:a,setPasskeyAuthState:i}=x();return{loginWithPasskey:c((async a=>{try{let i;if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);t.enabled&&"success"!==t.status&&(t.execute(),i=await t.waitForResult()),await n({captchaToken:i,withPrivyUi:!1});let{user:o,isNewUser:s,wasAlreadyAuthenticated:l,loginAccount:c}=await r(a);e?.onComplete?.({user:o,isNewUser:s,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(a){throw i({status:"error",error:a}),e?.onError?.(a.privyErrorCode||A.UNKNOWN_AUTH_ERROR),a}}),[r,t.status]),state:a}},vw=e=>{let{initLinkWithPasskey:t,linkWithPasskey:n,passkeyAuthState:r,setPasskeyAuthState:a}=x();return{linkWithPasskey:c((async()=>{try{await t();let r=await n();if(!r)throw Error("Error, user not found");let a=r.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:r,linkMethod:"passkey",linkedAccount:a})}catch(t){throw a({status:"error",error:t}),e?.onError?.(t.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[n]),state:r}},Cw=e=>{let t=it(),{smsOtpState:n,setSmsOtpState:r,initLoginWithSms:a,loginWithCode:i}=x();return{sendCode:c((async({phoneNumber:n,disableSignup:i})=>{try{let e;if(!n)throw Error("SMS required to send OTP code");if(t.enabled&&"error"===t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);return t.enabled&&"success"!==t.status&&(t.execute(),e=await t.waitForResult()),await a({phoneNumber:n,captchaToken:e,disableSignup:i,withPrivyUi:!1})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[a]),loginWithCode:c((async({code:n})=>{try{if(t.enabled&&"success"!==t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);let{user:r,isNewUser:a,wasAlreadyAuthenticated:o,linkedAccount:s}=await i(n);e?.onComplete?.({user:r,isNewUser:a,wasAlreadyAuthenticated:o,loginMethod:"sms",loginAccount:s})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR),n}}),[i,t.status]),state:n}},Ew=e=>{let t=it(),{siweState:n,setSiweState:r,linkWithSiwe:a,generateSiweMessage:i}=x();return{generateSiweMessage:c((async({address:t,chainId:n})=>{try{if(!t||!n)throw Error("wallet address and chainId required to generate nonce");return await i({address:t,chainId:n}).then((e=>e))}catch(t){throw r({status:"error",error:t}),e?.onError?.(t.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[i]),linkWithSiwe:c((async({signature:n,message:i,chainId:o,walletClientType:s,connectorType:l})=>{try{if(t.enabled&&"success"!==t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);let{user:r,linkedAccount:c}=await a({message:i,signature:n,chainId:o,walletClientType:s,connectorType:l});c&&e?.onSuccess?.({user:r,linkMethod:"siwe",linkedAccount:c})}catch(n){throw r({status:"error",error:n}),e?.onError?.(n.privyErrorCode||A.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),n}}),[a,t.status]),state:n}};function Tw(){let{signTransaction:e}=u(Wr);return{signTransaction:e}}function bw(e){let{linkEmail:t,linkPhone:n,linkWallet:r,linkGoogle:a,linkApple:i,linkTwitter:o,linkDiscord:s,linkGithub:l,linkLinkedIn:c,linkTiktok:d,linkSpotify:h,linkInstagram:p,linkTelegram:m,linkFarcaster:y}=u(Wr);return ta("linkAccount",e),{linkEmail:t,linkPhone:n,linkWallet:r,linkGoogle:a,linkApple:i,linkTwitter:o,linkDiscord:s,linkGithub:l,linkLinkedIn:c,linkTiktok:d,linkSpotify:h,linkInstagram:p,linkFarcaster:y,linkTelegram:m}}function Aw(e){let{updateEmail:t,updatePhone:n}=u(Wr);return ta("update",e),{updateEmail:t,updatePhone:n}}function _w(e){let{createWallet:t}=u(Wr);return ta("createWallet",e),{createWallet:t}}const kw=()=>{let{connectCoinbaseSmartWallet:e}=x();return{connectCoinbaseSmartWallet:e}},Iw=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:n,signTypedDataWithCrossAppWallet:r,sendTransactionWithCrossAppWallet:a}=hr();return{loginWithCrossAppAccount:({appId:t})=>e({appId:t,action:"login"}),linkCrossAppAccount:({appId:t})=>e({appId:t,action:"link"}),unlinkCrossAppAccount:t,signMessage:n,signTypedData:r,sendTransaction:a}};function Nw(e){let{sendTransaction:t}=u(Wr);return ta("sendTransaction",e),{sendTransaction:t}}function xw(e){let{setWalletPassword:t}=u(Wr);return ta("setWalletPassword",e),{setWalletPassword:t}}function Sw(){let{createGuestAccount:e}=u(Wr);return{createGuestAccount:e}}function Rw(e){let{setWalletRecovery:t}=u(Wr);return ta("setWalletRecovery",e),{setWalletRecovery:t}}function Ow(e){let{signMessage:t}=u(Wr);return ta("signMessage",e),{signMessage:t}}const Ww=()=>{let{ready:e,wallets:t}=Tr(),{user:n}=hr(),{rpcConfig:r,chains:a,appId:i}=x();return{signAuthorization:c((async(o,s)=>{if(!n)throw Error("User must be authenticated before signing with a Privy wallet");if(!e)throw Error("Wallets are not ready");let l=s?.address??yr(n)?.address??Fa,c=t.find((e=>Ba(e.address)===Ba(l)));if(!c)throw Error("Signing wallet not found.");let d=o.chainId??Number(c.chainId.split(":")[1]),h=a.find((e=>e.id===d));if(!h)throw Error("Error, chain not configured in PrivyProvider config");let u=Na({account:l,chain:h,transport:Ia(Va(h,r,i))}).extend(Eo()),p=await u.prepareAuthorization({...o,sponsor:o.sponsor||void 0}),m=await c.getEthereumProvider(),y=await m.request({method:"secp256k1_sign",params:[To(p)]});return{...p,...za(y)}}),[e,t,n,a])}};function Mw(e){let{signTypedData:t}=u(Wr);return ta("signTypedData",e),{signTypedData:t}}const Pw=()=>{let{isModalOpen:e}=u(Wr);return{isOpen:e}};function Lw(e){let{getAccessToken:t}=u(Wr);return ta("accessToken",e),{getAccessToken:t}}function Dw(e){let{authenticated:t,user:n}=hr(),{initLoginWithOAuth:r}=x(),a=ha();return ta("oAuthAuthorization",e),{reauthorize:e=>Uw(t,n,r,a,e.provider)}}let Uw=async(e,t,n,r,a)=>{if(!e)throw r("linkAccount","onError",A.MUST_BE_AUTHENTICATED,{linkMethod:a}),new T("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(a))))throw new T(`OAuth account of type ${a} not linked to the account.`);await n(a)};const Fw=e=>{let{customAuthStatus:t}=x();return ta("customAuth",e),{status:t}};function Bw(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:n}=hr();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:n}}const zw=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=x();return{delegateWallet:async({address:e,chainType:n})=>await t({address:e,chainType:n,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},Hw=()=>{let{setUser:e,client:t}=u(D),{user:n}=u(Wr);return{user:n,refreshUser:c((async()=>{let n=await(t?.updateUserAndIdToken());return e(n??null),n}),[t,e])}},Vw=e=>{let t=it(),{initLoginWithTelegram:n,loginWithTelegram:r,telegramAuthState:a,setTelegramAuthState:i}=x();return{login:c((async a=>{try{if(t.enabled&&"success"!==t.status)throw new qe(t.error,null,A.CAPTCHA_FAILURE);await n(t.token,a?.disableSignup);let{user:i,isNewUser:o,loginAccount:s,wasAlreadyAuthenticated:l}=await r({intent:"login"});e?.onComplete?.({user:i,isNewUser:o,wasAlreadyAuthenticated:l,loginMethod:"telegram",loginAccount:s})}catch(a){throw i({status:"error",error:a}),e?.onError?.(a.privyErrorCode||A.UNKNOWN_AUTH_ERROR),a}}),[n,r,t]),state:a}},$w=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=x();return{delegateWallet:async({address:e,chainType:n})=>await t({address:e,chainType:n,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}};export{Ys as Captcha,Os as ConnectorManager,Ke as EthereumWalletConnector,bf as LoginModal,qs as PrivyClient,hw as PrivyProvider,qn as VERSION,qc as errorIndicatesMaxMfaRetries,jc as errorIndicatesMfaTimeout,Gc as errorIndicatesMfaVerificationFailed,nw as getAccessToken,kw as useConnectCoinbaseSmartWallet,_w as useCreateWallet,Iw as useCrossAppAccounts,Fw as useCustomAuth,zw as useDelegatedActions,Bw as useFarcasterSigner,Sw as useGuestAccounts,$w as useHeadlessDelegatedActions,Bs as useIdentityToken,pw as useImportWallet,bw as useLinkAccount,vw as useLinkWithPasskey,Ew as useLinkWithSiwe,gw as useLoginWithEmail,yw as useLoginWithOAuth,ww as useLoginWithPasskey,Cw as useLoginWithSms,Vw as useLoginWithTelegram,At as useLogout,am as useMfa,im as useMfaEnrollment,Pw as useModalStatus,Dw as useOAuthTokens,mw as usePrivy,Zs as useRegisterMfaListener,Nw as useSendTransaction,xw as useSetWalletPassword,Rw as useSetWalletRecovery,Ww as useSignAuthorization,Ow as useSignMessage,Tw as useSignTransaction,Mw as useSignTypedData,fw as useSignupWithPasskey,oa as useSolanaWallets,Lw as useToken,Aw as useUpdateAccount,Hw as useUser,Tr as useWallets};