UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

148 lines (137 loc) • 23.9 kB
import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import{MagnifyingGlassIcon as l}from"@heroicons/react/24/outline";import{useVirtualizer as i}from"@tanstack/react-virtual";import{useMemo as a,useState as o,useCallback as r,useRef as c,useEffect as s}from"react";import{isMobile as d}from"react-device-detect";import{styled as h}from"styled-components";import{a as m,T as u}from"./ModalHeader-D8-mhjp4.mjs";import{C as p}from"./CopyableText-BCytXyJL.mjs";import{L as g}from"./Link-DJ5gq9Di.mjs";import{Q as w}from"./QrCode-C1tgJtOy.mjs";import{E as f}from"./EmailInputForm-Dgoii4vf.mjs";import{u as y,q as v}from"./context-WTldtXS8.mjs";import{u as b}from"./useI18n-BuIe8nUA.mjs";import{M as C,q as x,d as _,e as L,K as W,V as k,w as T,S as z}from"./useActiveWallet-3RHPIBxJ.mjs";import{u as S,P as A,b as E}from"./internal-context-Z-fyxadS.mjs";import{W as j}from"./WalletCards-DH1rqayz.mjs";import{W as K,h as B}from"./use-export-wallet-CV4p7L0b.mjs";import{S as q}from"./Screen-Bp-TN9gb.mjs";const O={phantom:{mobile:{native:"phantom://",universal:"https://phantom.app/ul/"}},solflare:{mobile:{native:void 0,universal:"https://solflare.com/ul/v1/"}},metamask:{image_url:{sm:C,md:C}}};class I{static normalize(e){return e.replace(/[-_]wallet$/,"").replace(/[-_]extension$/,"").toLowerCase()}isEth(e){return e.chains.some((e=>e.includes("eip155:")))}isSol(e){return e.chains.some((e=>e.includes("solana:")))}inAllowList(e,n){if(!this.normalizedAllowList||0===this.normalizedAllowList.length||"listing"===n&&this.includeWalletConnect)return!0;let t=I.normalize(e);return this.normalizedAllowList.some((e=>t===I.normalize(e)))}inDenyList(e,n){return"listing"===n&&"rabby"===e||"agw"===I.normalize(e)}chainMatches(e){return"ethereum-only"===this.chainFilter?"ethereum"===e:"solana-only"!==this.chainFilter||"solana"===e}getAllowListKey(e,n,t,l){let i=I.normalize(e);for(let e of this.normalizedAllowList||[])if(i===I.normalize(e))return e;if("connector"===n){if(("injected"===t||"solana_adapter"===t)&&"ethereum"===l&&this.detectedEth)return"detected_ethereum_wallets";if(("injected"===t||"solana_adapter"===t)&&"solana"===l&&this.detectedSol)return"detected_solana_wallets"}if("listing"===n&&this.includeWalletConnect)return"wallet_connect"}connectorOk(e){return!!("null"!==e.connectorType&&"walletconnect_solana"!==e.walletBranding.id&&this.chainMatches(e.chainType)&&(this.inAllowList(e.walletClientType,"connector")||("injected"===e.connectorType||"solana_adapter"===e.connectorType)&&("ethereum"===e.chainType&&this.detectedEth||"solana"===e.chainType&&this.detectedSol)))}listingOk(e){if(e.slug.includes("coinbase"))return!1;if("ethereum-only"===this.chainFilter){if(!this.isEth(e))return!1}else if("solana-only"===this.chainFilter&&!this.isSol(e))return!1;return!(!this.inAllowList(e.slug,"listing")||this.inDenyList(e.slug,"listing"))}getWallets(e,n){let t=new Map,l=e=>{let n=t.get(e.id);if(n){n.chainType!==e.chainType&&(n.chainType="multi");let t=new Set(n.chains);e.chains.forEach((e=>t.add(e))),n.chains=Array.from(t),!n.icon&&e.icon&&(n.icon=e.icon),!n.url&&e.url&&(n.url=e.url),!n.listing&&e.listing&&(n.listing=e.listing),!n.allowListKey&&e.allowListKey&&(n.allowListKey=e.allowListKey)}else t.set(e.id,e)};e.filter((e=>this.connectorOk(e))).forEach((e=>{let n=I.normalize(e.walletClientType);l({id:n,label:e.walletBranding?.name??n,source:"connector",connector:e,chainType:e.chainType,icon:e.walletBranding?.icon,url:void 0,chains:["ethereum"===e.chainType?"eip155":"solana"],allowListKey:this.getAllowListKey(e.walletClientType,"connector",e.connectorType,e.chainType)})}));let i=e.find((e=>"wallet_connect_v2"===e.connectorType)),a=e.find((e=>"walletconnect_solana"===e.walletBranding.id));n.filter((e=>this.listingOk(e))).forEach((n=>{let t=[...n.chains].filter((e=>e.includes("eip155:")||e.includes("solana:")));if(e.some((e=>I.normalize(e.walletClientType)===I.normalize(n.slug)&&"ethereum"===e.chainType&&"null"!==e.connectorType))||i||n.mobile.native||n.mobile.universal||x[n.slug]?.chainTypes.includes("ethereum")||(t=t.filter((e=>!e.includes("eip155:")))),e.some((e=>I.normalize(e.walletClientType)===I.normalize(n.slug)&&"solana"===e.chainType&&"null"!==e.connectorType))||a||n.mobile.native||n.mobile.universal||x[n.slug]?.chainTypes.includes("solana")||(t=t.filter((e=>!e.includes("solana:")))),!t.length)return;let o=I.normalize(n.slug),r=O[n.slug],c=r?.image_url?.sm||n.image_url?.sm;t.some((e=>e.includes("eip155:")))&&l({id:o,label:n.name||o,source:"listing",listing:n,chainType:"ethereum",icon:c,url:n.homepage,chains:t,allowListKey:this.getAllowListKey(n.slug,"listing")}),t.some((e=>e.includes("solana:")))&&l({id:o,label:n.name||o,source:"listing",listing:n,chainType:"solana",icon:c,url:n.homepage,chains:t,allowListKey:this.getAllowListKey(n.slug,"listing")})})),this.includeWalletConnectQr&&i&&l({id:"wallet_connect_qr",label:"WalletConnect",source:"connector",connector:i,chainType:"ethereum",icon:K,url:void 0,chains:["eip155"],allowListKey:"wallet_connect_qr"}),this.includeWalletConnectQrSolana&&a&&l({id:"wallet_connect_qr_solana",label:"WalletConnect",source:"connector",connector:a,chainType:"solana",icon:K,url:void 0,chains:["solana"],allowListKey:"wallet_connect_qr_solana"});let o=Array.from(t.values());o.forEach((e=>{let n=O[e.listing?.slug||e.id];n?.image_url?.sm&&(e.icon=n.image_url.sm)}));let r=new Map;return this.normalizedAllowList?.forEach(((e,n)=>{r.set(I.normalize(e),n)})),{wallets:o.slice().sort(((e,n)=>{if(e.allowListKey&&n.allowListKey){let t=this.normalizedAllowList?.findIndex((n=>I.normalize(n)===I.normalize(e.allowListKey)))??-1,l=this.normalizedAllowList?.findIndex((e=>I.normalize(e)===I.normalize(n.allowListKey)))??-1;if(t!==l&&t>=0&&l>=0)return t-l}if(e.allowListKey&&!n.allowListKey)return-1;if(!e.allowListKey&&n.allowListKey)return 1;let t=I.normalize(e.id),l=I.normalize(n.id);"binance-defi"===t?t="binance":"universalprofiles"===t?t="universal_profile":"cryptocom-defi"===t?t="cryptocom":"bitkeep"===t&&(t="bitget_wallet"),"binance-defi"===l?l="binance":"universalprofiles"===l?l="universal_profile":"cryptocom-defi"===l?l="cryptocom":"bitkeep"===l&&(l="bitget_wallet");let i=r.has(t),a=r.has(l);return i&&a?r.get(t)-r.get(l):i?-1:a?1:"connector"===e.source&&"listing"===n.source?-1:"listing"===e.source&&"connector"===n.source?1:e.label.toLowerCase().localeCompare(n.label.toLowerCase())})),walletCount:o.length}}constructor(e,n){this.chainFilter=e,n&&n.length>0&&(this.normalizedAllowList=n.map(String),this.normalizedAllowList.includes("binance")&&this.normalizedAllowList.push("binance-defi-wallet"),this.normalizedAllowList.includes("bitget_wallet")&&this.normalizedAllowList.push("bitkeep")),this.detectedEth=this.normalizedAllowList?.includes("detected_ethereum_wallets")??!1,this.detectedSol=this.normalizedAllowList?.includes("detected_solana_wallets")??!1,this.includeWalletConnect=this.normalizedAllowList?.includes("wallet_connect")??!1,this.includeWalletConnectQr=this.normalizedAllowList?.includes("wallet_connect_qr")??!1,this.includeWalletConnectQrSolana=this.normalizedAllowList?.includes("wallet_connect_qr_solana")??!1}}var N=t=>/*#__PURE__*/e("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...t,children:[/*#__PURE__*/n("path",{d:"m0 0h32v32h-32z",fill:"#5469d4"}),/*#__PURE__*/n("path",{d:"m15.997 5.333-.143.486v14.106l.143.143 6.548-3.87z",fill:"#c2ccf4"}),/*#__PURE__*/n("path",{d:"m15.996 5.333-6.548 10.865 6.548 3.87z",fill:"#fff"}),/*#__PURE__*/n("path",{d:"m15.997 21.306-.08.098v5.025l.08.236 6.552-9.227z",fill:"#c2ccf4"}),/*#__PURE__*/n("path",{d:"m15.996 26.665v-5.36l-6.548-3.867z",fill:"#fff"}),/*#__PURE__*/n("path",{d:"m15.995 20.07 6.548-3.87-6.548-2.976v6.847z",fill:"#8698e8"}),/*#__PURE__*/n("path",{d:"m9.448 16.2 6.548 3.87v-6.846z",fill:"#c2ccf4"})]}),U=t=>/*#__PURE__*/e("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...t,children:[/*#__PURE__*/e("linearGradient",{id:"a",gradientUnits:"userSpaceOnUse",x1:"7.233",x2:"24.766",y1:"24.766",y2:"7.234",children:[/*#__PURE__*/n("stop",{offset:"0",stopColor:"#9945ff"}),/*#__PURE__*/n("stop",{offset:".2",stopColor:"#7962e7"}),/*#__PURE__*/n("stop",{offset:"1",stopColor:"#00d18c"})]}),/*#__PURE__*/n("path",{d:"m0 0h32v32h-32z",fill:"#10111a"}),/*#__PURE__*/n("path",{clipRule:"evenodd",d:"m9.873 20.41a.645.645 0 0 1 .476-.21l14.662.012a.323.323 0 0 1 .238.54l-3.123 3.438a.643.643 0 0 1 -.475.21l-14.662-.012a.323.323 0 0 1 -.238-.54zm15.376-2.862a.322.322 0 0 1 -.238.54l-14.662.012a.642.642 0 0 1 -.476-.21l-3.122-3.44a.323.323 0 0 1 .238-.54l14.662-.012a.644.644 0 0 1 .475.21zm-15.376-9.738a.644.644 0 0 1 .476-.21l14.662.012a.322.322 0 0 1 .238.54l-3.123 3.438a.643.643 0 0 1 -.475.21l-14.662-.012a.323.323 0 0 1 -.238-.54z",fill:"url(#a)",fillRule:"evenodd"})]});const $=h.div` display: flex; justify-content: space-between; align-items: center; `,F=h.button` padding: 0.25rem; height: 30px; width: 30px; display: flex; align-items: center; justify-content: center; border-radius: var(--privy-border-radius-full); background: var(--privy-color-background-2); `,D=h.div` position: relative; display: inline-flex; align-items: center; &::after { content: ' '; border-radius: var(--privy-border-radius-full); height: 6px; width: 6px; background-color: var(--privy-color-icon-success); position: absolute; right: -3px; top: -3px; } `,M=h.img` width: 32px; height: 32px; border-radius: 0.25rem; object-fit: contain; `,P=h.span` display: flex; gap: 0.25rem; align-items: center; padding: 0.25rem 0.5rem; font-size: 0.75rem; font-weight: 500; line-height: 1.125rem; /* 150% */ border-radius: var(--privy-border-radius-sm); background-color: var(--privy-color-background-2); svg { width: 100%; max-width: 1rem; max-height: 1rem; stroke-width: 2; } `,Q=h.div` display: flex; flex-direction: column; gap: 0.5rem; max-height: 24rem; overflow-y: scroll; &::-webkit-scrollbar { display: none; } scrollbar-gutter: stable both-edges; scrollbar-width: none; -ms-overflow-style: none; ${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} background-repeat: no-repeat; background-size: 100% 32px, 100% 16px; background-attachment: local, scroll; `;function R({enabled:e=!0,walletList:n,walletChainType:t}){let l=y(),{connectors:i}=S(),{listings:r,loading:c}=_(e),s=t??l.appearance.walletChainType,d=n??l.appearance?.walletList,h=a((()=>new I(s,d)),[s,d]),{wallets:m,walletCount:u}=a((()=>h.getWallets(i,r)),[h,i,r]),[p,g]=o(""),w=a((()=>p?m.filter((e=>e.label.toLowerCase().includes(p.toLowerCase()))):m),[p,m]),[f,v]=o();return{selected:f,setSelected:v,search:p,setSearch:g,loadingListings:c,wallets:w,walletCount:u}}let H=e=>!e||"string"!=typeof e&&(e instanceof T||e instanceof z);const V=({index:l,style:i,data:a,recent:o})=>{let r=a.wallets[l],{walletChainType:c,handleWalletClick:s}=a,{t:d}=b(),h={...i,boxSizing:"border-box"};return r?/*#__PURE__*/e(X,{style:h,onClick:()=>s(r),children:[r.icon&&(r.connector&&!H(r.connector)?/*#__PURE__*/n(D,{children:"string"==typeof r.icon?/*#__PURE__*/n(M,{src:r.icon}):/*#__PURE__*/n(r.icon,{style:{width:"32px",height:"32px"}})}):"string"==typeof r.icon?/*#__PURE__*/n(M,{src:r.icon}):/*#__PURE__*/n(r.icon,{style:{width:"32px",height:"32px"}})),/*#__PURE__*/n(ne,{children:r.label}),o?/*#__PURE__*/e(t,{children:[/*#__PURE__*/n(P,{children:d("connectWallet.lastUsed")}),/*#__PURE__*/n(Z,{children:/*#__PURE__*/e(t,{children:["ethereum-only"===c&&/*#__PURE__*/n(N,{}),"solana-only"===c&&/*#__PURE__*/n(U,{})]})})]}):/*#__PURE__*/n(Z,{children:!("ethereum-only"===c||"solana-only"===c)&&/*#__PURE__*/e(t,{children:[r.chains?.some((e=>e.startsWith("eip155")))&&/*#__PURE__*/n(N,{}),r.chains?.some((e=>e.startsWith("solana")))&&/*#__PURE__*/n(U,{})]})})]}):null};var Y=({className:h,customDescription:p,connectOnly:C,preSelectedWalletId:_,hideHeader:K,...$})=>{let F=y(),{t:D}=b(),{connectors:P}=S(),Q=$.walletChainType||F.appearance.walletChainType,Y=$.walletList||F.appearance?.walletList,{onBack:ie,onClose:ae,app:oe}=$,{selected:re,setSelected:ce,qrUrl:se,setQrUrl:de,connecting:he,uiState:me,errorCode:ue,wallets:pe,walletCount:ge,handleConnect:we,handleBack:fe,showSearchBar:ye,isInitialConnectView:ve,title:be,search:Ce,setSearch:xe}=function({onConnect:e,onBack:n,onClose:t,onConnectError:l,walletList:i,walletChainType:c,app:s}){let h=y(),{connectors:m}=S(),{t:u}=b(),{wallets:p,walletCount:g,search:w,setSearch:f,selected:C,setSelected:x}=R({enabled:L(i??[]),walletList:i,walletChainType:c}),[_,k]=o(),[T,z]=o(),[E,j]=o(),[K,B]=o(),q=!C&&!E&&!K,O=q&&(g>6||w.length>0),I=m.find((e=>"wallet_connect_v2"===e.connectorType)),N=r((async(n,t)=>{if(n){if(K?.connector===n&&"loading"===_)return void console.log("Already connecting to this wallet, skipping duplicate attempt");if(k("loading"),"string"==typeof n)return B({connector:n,name:t?.name??"Wallet",icon:t?.icon,id:t?.id,url:t?.url}),void window.open(n,"_blank");B({connector:n,name:t?.name??n.walletBranding.name??"Wallet",icon:t?.icon??n.walletBranding.icon,id:t?.id,url:t?.url});try{let t=await n.connect({showPrompt:!0});if(!t)return k("error"),z(void 0),void l?.(new A("Unable to connect wallet"));k("success"),z(void 0),W({address:t.address,client:t.walletClientType,appId:h.id}),setTimeout((()=>{e({connector:n,wallet:t})}),v)}catch(n){if(console.error("ERROR: ",{e:n}),n?.message?.includes("already pending for origin")||n?.message?.includes("wallet_requestPermissions"))return void console.log("Connection request already pending, maintaining loading state");k("error"),z(n?.privyErrorCode),l?.(n instanceof Error?n:new A(n?.message||"Unable to connect wallet"))}}}),[h.id,e,K,_]),U=r((()=>E?(k(void 0),z(void 0),B(void 0),void j(void 0)):K?(k(void 0),z(void 0),void B(void 0)):C?(k(void 0),z(void 0),B(void 0),void x(void 0)):"error"===_||"loading"===_?(k(void 0),z(void 0),void B(void 0)):void n?.()),[E,K,C,_,n]),$=a((()=>K?.connector===I&&E&&d&&K?.name?u("connectWallet.goToWallet",{walletName:K.name}):K?.connector===I&&E&&K?.name?u("connectWallet.scanToConnect",{walletName:K.name}):E&&K?.name?u(d?"connectWallet.goToWallet":"connectWallet.scanToConnect",{walletName:K.name}):"string"==typeof K?.connector?u("connectWallet.openOrInstall",{walletName:K.name}):C&&!K?u("connectWallet.selectNetwork"):K?null:u("connectWallet.selectYourWallet")),[K,E,C,I,u]);return{selected:C,setSelected:x,qrUrl:E,setQrUrl:j,connecting:K,uiState:_,errorCode:T,search:w,setSearch:f,wallets:p,walletCount:g,wc:I,isInitialConnectView:q,showSearchBar:O,title:$,handleConnect:N,handleBack:U,onClose:t,onConnect:e,app:s}}({...$,walletList:Y,walletChainType:Q}),_e=P.find((e=>"wallet_connect_v2"===e.connectorType)),Le=P.find((e=>"walletconnect_solana"===e.walletBranding.id)),We=c(null),ke=i({count:pe.length,getScrollElement:()=>We.current,estimateSize:()=>56,overscan:6,gap:5}),Te=r((async e=>{let n="solana-only"!==Q&&e.chains?.some((e=>e.startsWith("eip155"))),t="ethereum-only"!==Q&&e.chains?.some((e=>e.startsWith("solana"))),l=()=>{let n=e.id;return x[n]||x[`${n}_wallet`]},i=n=>{let t=I.normalize(e.id);return P.find((e=>I.normalize(e.walletClientType)===t&&e.chainType===n&&!("ethereum"===e.chainType&&e instanceof T||"solana"===e.chainType&&e instanceof z)))},a=async()=>{if(!_e||!e.listing)return!1;let n=O[e.listing.slug]?{...e.listing,...O[e.listing.slug]}:e.listing;return _e.setWalletEntry(n,de),await _e.resetConnection(e.id),await we(_e,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0},o=async()=>!!Le&&!!e.listing&&(await Le.disconnect(),Le.wallet.setWalletEntry(e.listing,de),await new Promise((e=>setTimeout(e,100))),await we(Le,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0),r=async n=>{let t=(e=>{let n=l();if(n)return n.getMobileRedirect({isSolana:e,connectOnly:!!C,useUniversalLink:!1})})(n);return!!t&&(await we(t,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0)};if(n&&t)ce(e);else{if(n&&!t){let n=i("ethereum");if(n&&!H(n))return void await we(n,{name:e.label,icon:e.icon,id:e.id,url:e.url});if(d&&l()){if(await r(!1)||await a())return}else if(await a()||await r(!1))return}if(t&&!n){let n=i("solana");if(n&&!H(n))return void await we(n,{name:e.label,icon:e.icon,id:e.id,url:e.url});if(d){if(await r(!0)||await o())return}else if(await o()||await r(!0))return}if(!H(e.connector)){if(_e&&"wallet_connect_v2"===e.connector?.connectorType)if(await _e.resetConnection(e.id),"wallet_connect_qr"!==e.id&&e.listing){let n=O[e.listing.slug]?{...e.listing,...O[e.listing.slug]}:e.listing;_e.setWalletEntry(n,de)}else _e.setWalletEntry({id:"wallet_connect_qr",name:"WalletConnect",rdns:"",slug:"wallet-connect",homepage:"",chains:["eip155"],mobile:{native:"",universal:void 0}},de);return Le&&"walletconnect_solana"===e.connector?.walletBranding.id&&(await Le.disconnect(),"wallet_connect_qr_solana"!==e.id&&e.listing?Le.wallet.setWalletEntry(e.listing,de):Le.wallet.setWalletEntry({id:"wallet_connect_solana_qr",name:"WalletConnect",rdns:"",slug:"wallet-connect-solana",homepage:"",chains:["solana"],mobile:{native:"",universal:void 0}},de),await new Promise((e=>setTimeout(e,100)))),void await we(e.connector,{name:e.label,icon:e.icon,id:e.id,url:e.url})}e.url&&await we(e.url,{name:e.label,icon:e.icon,id:e.id,url:e.url})}}),[_e,Le,we,ce,de,Q,C,P]);return s((()=>{if(!_)return;let e=pe.find((({id:e})=>e===_));e&&Te(e).catch(console.error)}),[_]),/*#__PURE__*/e(q,{className:h,children:[/*#__PURE__*/n(q.Header,{icon:K&&ve?void 0:he&&!se||se&&d&&he?.icon?he.icon:he?void 0:j,iconVariant:he&&!se||se&&d?"loading":void 0,iconLoadingStatus:he&&!se||se&&d?{success:"success"===me,fail:"error"===me}:void 0,title:K&&ve?void 0:he&&!se?D("connectWallet.waitingForWallet",{walletName:he.name}):se&&d?D("connectWallet.waitingForWallet",{walletName:he?.name??"connection"}):be,subtitle:K&&ve?void 0:he&&!se&&"string"==typeof he.connector?D("connectWallet.installAndConnect",{walletName:he.name}):he&&!se&&"string"!=typeof he.connector?"error"===me?ue===E.NO_SOLANA_ACCOUNTS?`The connected wallet has no Solana accounts. Please add a Solana account in ${he.name} and try again.`:D("connectWallet.tryConnectingAgain"):D("connectionStatus.connectOneWallet"):ve?p??(oe?D("connectWallet.connectToAccount",{appName:oe.name}):null):null,showBack:!!ie||!ve,showClose:!0,onBack:ie||fe,onClose:ae}),/*#__PURE__*/e(q.Body,{ref:We,$colorScheme:F.appearance.palette.colorScheme,style:{marginBottom:se?"0.5rem":void 0},children:[ye&&/*#__PURE__*/n(G,{children:/*#__PURE__*/e(f,{style:{background:"transparent"},children:[/*#__PURE__*/n(k,{children:/*#__PURE__*/n(l,{})}),/*#__PURE__*/n("input",{className:"login-method-button",type:"text",placeholder:D("connectWallet.searchPlaceholder",{count:String(ge)}),onChange:e=>xe(e.target.value),value:Ce})]})}),se&&d&&"loading"===me&&/*#__PURE__*/e("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem"},children:[/*#__PURE__*/n(m,{variant:"primary",onClick:()=>window.open(se.universal??se.native,"_blank"),style:{width:"100%"},children:D("connectWallet.openInApp")}),/*#__PURE__*/n(te,{value:se.universal??se.native,iconOnly:!0,children:"Copy link"})]}),se&&!d&&"loading"===me&&/*#__PURE__*/n("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem"},children:/*#__PURE__*/n(te,{value:se.universal??se.native,iconOnly:!0,children:D("connectWallet.copyLink")})}),se&&!d&&/*#__PURE__*/n(w,{size:280,url:se.universal??se.native,squareLogoElement:he?.icon?"string"==typeof he.icon?e=>/*#__PURE__*/n("svg",{...e,children:/*#__PURE__*/n("image",{href:he.icon,height:e.height,width:e.width})}):he.icon:B}),se&&!d&&he?.url&&("binance"===he.id||"binanceus"===he.id||"binance-defi"===he.id)&&/*#__PURE__*/e(le,{children:[/*#__PURE__*/e("span",{children:["Don't have ",he.name,"? "]}),/*#__PURE__*/n(g,{href:he.url,target:"_blank",size:"sm",children:"Download here"})]}),/*#__PURE__*/e(J,{children:[he&&!se&&"string"==typeof he.connector&&/*#__PURE__*/e(X,{onClick:()=>window.open(he.connector,"_blank"),children:[he.icon&&("string"==typeof he.icon?/*#__PURE__*/n(M,{src:he.icon}):/*#__PURE__*/n(he.icon,{})),/*#__PURE__*/n(ne,{children:he.name})]}),re?.chains.some((e=>e.startsWith("eip155")))&&!he&&/*#__PURE__*/e(X,{onClick:()=>Te({...re,chains:re.chains.filter((e=>e.startsWith("eip155")))}),children:[re.icon&&("string"==typeof re.icon?/*#__PURE__*/n(M,{src:re.icon}):/*#__PURE__*/n(re.icon,{})),/*#__PURE__*/n(ne,{children:re.label}),/*#__PURE__*/n(Z,{children:/*#__PURE__*/n(N,{})})]}),re?.chains.some((e=>e.startsWith("solana")))&&!he&&/*#__PURE__*/e(X,{onClick:()=>Te({...re,chains:re.chains.filter((e=>e.startsWith("solana")))}),children:[re.icon&&("string"==typeof re.icon?/*#__PURE__*/n(M,{src:re.icon}):/*#__PURE__*/n(re.icon,{})),/*#__PURE__*/n(ne,{children:re.label}),/*#__PURE__*/n(Z,{children:/*#__PURE__*/n(U,{})})]}),ve&&/*#__PURE__*/e(t,{children:[!(ge>0)&&/*#__PURE__*/n(ee,{children:D("connectWallet.noWalletsFound")}),ge>0&&!se&&/*#__PURE__*/n("div",{style:{maxHeight:56*Math.min(pe.length,5)+5,width:"100%"},children:/*#__PURE__*/n("div",{style:{height:`${ke.getTotalSize()}px`,width:"100%",position:"relative"},children:ke.getVirtualItems().map((e=>/*#__PURE__*/n(V,{index:e.index,style:{position:"absolute",top:0,left:0,height:`${e.size}px`,transform:`translateY(${e.start}px)`},data:{wallets:pe,walletChainType:Q,handleWalletClick:Te}},e.key)))})})]})]})]}),/*#__PURE__*/e(q.Footer,{children:[he&&!se&&"string"!=typeof he.connector&&"error"===me&&/*#__PURE__*/n(q.Actions,{children:/*#__PURE__*/n(m,{style:{width:"100%",alignItems:"center"},variant:"error",onClick:()=>we(he.connector,{name:he.name,icon:he.icon,id:he.id,url:he.url}),children:D("connectWallet.retry")})}),!!(oe&&oe.legal.privacyPolicyUrl&&oe.legal.termsAndConditionsUrl)&&/*#__PURE__*/n(u,{app:oe,alwaysShowImplicitConsent:!0}),/*#__PURE__*/n(q.Watermark,{})]})]})};let G=h.div` position: sticky; // Offset by negative margin to account for focus outline margin-top: -3px; padding-top: 3px; top: -3px; z-index: 1; background: var(--privy-color-background); padding-bottom: calc(var(--screen-space) / 2); `,J=h.div` display: flex; flex-direction: column; gap: ${5}px; `,X=h.button` && { gap: 0.5rem; align-items: center; display: flex; position: relative; text-align: left; font-weight: 500; transition: background 200ms ease-in; width: calc(100% - 4px); border-radius: var(--privy-border-radius-md); padding: 0.75em; border: 1px solid var(--privy-color-foreground-4); justify-content: space-between; } &:hover { background: var(--privy-color-background-2); } `,Z=h.span` display: flex; align-items: center; justify-content: end; position: relative; & > svg { border-radius: var(--privy-border-radius-full); stroke-width: 2.5; width: 100%; max-height: 1rem; max-width: 1rem; flex-shrink: 0; } & > svg:not(:last-child) { border-radius: var(--privy-border-radius-full); margin-right: -0.375rem; } `,ee=h.div` height: 60px; display: flex; align-items: center; justify-content: center; text-align: center; `,ne=h.span` text-overflow: ellipsis; white-space: nowrap; color: var(--privy-color-foreground); font-weight: 400; flex: 1; `,te=h(p)` && { margin: 0.5rem auto 0 auto; } `,le=h.div` text-align: center; margin-top: 1rem; font-size: 0.875rem; font-weight: 400; color: var(--privy-color-foreground-3); `;export{P as C,$ as H,Q as S,M as W,F as a,I as b,V as c,Y as i,R as u};