@privy-io/react-auth
Version:
React client for the Privy Auth API
148 lines (137 loc) • 25 kB
JavaScript
"use strict";var e=require("react/jsx-runtime"),n=require("@heroicons/react/24/outline"),t=require("@tanstack/react-virtual"),l=require("react"),i=require("react-device-detect"),a=require("styled-components"),o=require("./ModalHeader-BCPQgekO.js"),r=require("./CopyableText-DbFeIZI0.js"),s=require("./Link-BdtTp2J4.js"),c=require("./QrCode-CE12LRBB.js"),d=require("./EmailInputForm-Y-nHsEtF.js"),u=require("./context-D-ZJYjUg.js"),h=require("./useI18n-DFGBJl_S.js"),p=require("./useActiveWallet-Cn6zOXx5.js"),m=require("./internal-context-BJv4f_bO.js"),g=require("./WalletCards-BfpeHH5n.js"),w=require("./use-export-wallet-B5ujV5Nk.js"),y=require("./Screen-BfKedqka.js");const f={phantom:{mobile:{native:"phantom://",universal:"https://phantom.app/ul/"}},solflare:{mobile:{native:void 0,universal:"https://solflare.com/ul/v1/"}},metamask:{image_url:{sm:p.Metamask,md:p.Metamask}}};class v{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=v.normalize(e);return this.normalizedAllowList.some((e=>t===v.normalize(e)))}inDenyList(e,n){return"listing"===n&&"rabby"===e||"agw"===v.normalize(e)}chainMatches(e){return"ethereum-only"===this.chainFilter?"ethereum"===e:"solana-only"!==this.chainFilter||"solana"===e}getAllowListKey(e,n,t,l){let i=v.normalize(e);for(let e of this.normalizedAllowList||[])if(i===v.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=v.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=>v.normalize(e.walletClientType)===v.normalize(n.slug)&&"ethereum"===e.chainType&&"null"!==e.connectorType))||i||n.mobile.native||n.mobile.universal||p.mobileWalletsConfig[n.slug]?.chainTypes.includes("ethereum")||(t=t.filter((e=>!e.includes("eip155:")))),e.some((e=>v.normalize(e.walletClientType)===v.normalize(n.slug)&&"solana"===e.chainType&&"null"!==e.connectorType))||a||n.mobile.native||n.mobile.universal||p.mobileWalletsConfig[n.slug]?.chainTypes.includes("solana")||(t=t.filter((e=>!e.includes("solana:")))),!t.length)return;let o=v.normalize(n.slug),r=f[n.slug],s=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:s,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:s,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:w.WALLET_CONNECT_LOGO_DATA_URI,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:w.WALLET_CONNECT_LOGO_DATA_URI,url:void 0,chains:["solana"],allowListKey:"wallet_connect_qr_solana"});let o=Array.from(t.values());o.forEach((e=>{let n=f[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(v.normalize(e),n)})),{wallets:o.slice().sort(((e,n)=>{if(e.allowListKey&&n.allowListKey){let t=this.normalizedAllowList?.findIndex((n=>v.normalize(n)===v.normalize(e.allowListKey)))??-1,l=this.normalizedAllowList?.findIndex((e=>v.normalize(e)===v.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=v.normalize(e.id),l=v.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 x=n=>/*#__PURE__*/e.jsxs("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...n,children:[/*#__PURE__*/e.jsx("path",{d:"m0 0h32v32h-32z",fill:"#5469d4"}),/*#__PURE__*/e.jsx("path",{d:"m15.997 5.333-.143.486v14.106l.143.143 6.548-3.87z",fill:"#c2ccf4"}),/*#__PURE__*/e.jsx("path",{d:"m15.996 5.333-6.548 10.865 6.548 3.87z",fill:"#fff"}),/*#__PURE__*/e.jsx("path",{d:"m15.997 21.306-.08.098v5.025l.08.236 6.552-9.227z",fill:"#c2ccf4"}),/*#__PURE__*/e.jsx("path",{d:"m15.996 26.665v-5.36l-6.548-3.867z",fill:"#fff"}),/*#__PURE__*/e.jsx("path",{d:"m15.995 20.07 6.548-3.87-6.548-2.976v6.847z",fill:"#8698e8"}),/*#__PURE__*/e.jsx("path",{d:"m9.448 16.2 6.548 3.87v-6.846z",fill:"#c2ccf4"})]}),b=n=>/*#__PURE__*/e.jsxs("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...n,children:[/*#__PURE__*/e.jsxs("linearGradient",{id:"a",gradientUnits:"userSpaceOnUse",x1:"7.233",x2:"24.766",y1:"24.766",y2:"7.234",children:[/*#__PURE__*/e.jsx("stop",{offset:"0",stopColor:"#9945ff"}),/*#__PURE__*/e.jsx("stop",{offset:".2",stopColor:"#7962e7"}),/*#__PURE__*/e.jsx("stop",{offset:"1",stopColor:"#00d18c"})]}),/*#__PURE__*/e.jsx("path",{d:"m0 0h32v32h-32z",fill:"#10111a"}),/*#__PURE__*/e.jsx("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 C=a.styled.div`
display: flex;
justify-content: space-between;
align-items: center;
`,j=a.styled.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);
`,_=a.styled.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;
}
`,W=a.styled.img`
width: 32px;
height: 32px;
border-radius: 0.25rem;
object-fit: contain;
`,L=a.styled.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;
}
`,T=a.styled.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 k({enabled:e=!0,walletList:n,walletChainType:t}){let i=u.useAppConfig(),{connectors:a}=m.usePrivyInternal(),{listings:o,loading:r}=p.useExternalWalletListings(e),s=t??i.appearance.walletChainType,c=n??i.appearance?.walletList,d=l.useMemo((()=>new v(s,c)),[s,c]),{wallets:h,walletCount:g}=l.useMemo((()=>d.getWallets(a,o)),[d,a,o]),[w,y]=l.useState(""),f=l.useMemo((()=>w?h.filter((e=>e.label.toLowerCase().includes(w.toLowerCase()))):h),[w,h]),[x,b]=l.useState();return{selected:x,setSelected:b,search:w,setSearch:y,loadingListings:r,wallets:f,walletCount:g}}let S=e=>!e||"string"!=typeof e&&(e instanceof p.EthereumNullConnector||e instanceof p.SolanaNullConnector);const z=({index:n,style:t,data:l,recent:i})=>{let a=l.wallets[n],{walletChainType:o,handleWalletClick:r}=l,{t:s}=h.useI18n(),c={...t,boxSizing:"border-box"};return a?/*#__PURE__*/e.jsxs(q,{style:c,onClick:()=>r(a),children:[a.icon&&(a.connector&&!S(a.connector)?/*#__PURE__*/e.jsx(_,{children:"string"==typeof a.icon?/*#__PURE__*/e.jsx(W,{src:a.icon}):/*#__PURE__*/e.jsx(a.icon,{style:{width:"32px",height:"32px"}})}):"string"==typeof a.icon?/*#__PURE__*/e.jsx(W,{src:a.icon}):/*#__PURE__*/e.jsx(a.icon,{style:{width:"32px",height:"32px"}})),/*#__PURE__*/e.jsx(N,{children:a.label}),i?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(L,{children:s("connectWallet.lastUsed")}),/*#__PURE__*/e.jsx(M,{children:/*#__PURE__*/e.jsxs(e.Fragment,{children:["ethereum-only"===o&&/*#__PURE__*/e.jsx(x,{}),"solana-only"===o&&/*#__PURE__*/e.jsx(b,{})]})})]}):/*#__PURE__*/e.jsx(M,{children:!("ethereum-only"===o||"solana-only"===o)&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[a.chains?.some((e=>e.startsWith("eip155")))&&/*#__PURE__*/e.jsx(x,{}),a.chains?.some((e=>e.startsWith("solana")))&&/*#__PURE__*/e.jsx(b,{})]})})]}):null};let A=a.styled.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);
`,E=a.styled.div`
display: flex;
flex-direction: column;
gap: ${5}px;
`,q=a.styled.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);
}
`,M=a.styled.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;
}
`,I=a.styled.div`
height: 60px;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
`,N=a.styled.span`
text-overflow: ellipsis;
white-space: nowrap;
color: var(--privy-color-foreground);
font-weight: 400;
flex: 1;
`,B=a.styled(r.CopyableText)`
&& {
margin: 0.5rem auto 0 auto;
}
`,O=a.styled.div`
text-align: center;
margin-top: 1rem;
font-size: 0.875rem;
font-weight: 400;
color: var(--privy-color-foreground-3);
`;exports.Chip=L,exports.CloseButton=j,exports.Header=C,exports.ScrollContainer=T,exports.WalletFilterer=v,exports.WalletIcon=W,exports.WalletRow=z,exports.i=({className:a,customDescription:r,connectOnly:C,preSelectedWalletId:j,hideHeader:_,...L})=>{let T=u.useAppConfig(),{t:K}=h.useI18n(),{connectors:F}=m.usePrivyInternal(),U=L.walletChainType||T.appearance.walletChainType,P=L.walletList||T.appearance?.walletList,{onBack:R,onClose:D,app:$}=L,{selected:Q,setSelected:H,qrUrl:V,setQrUrl:G,connecting:Y,uiState:J,errorCode:X,wallets:Z,walletCount:ee,handleConnect:ne,handleBack:te,showSearchBar:le,isInitialConnectView:ie,title:ae,search:oe,setSearch:re}=function({onConnect:e,onBack:n,onClose:t,onConnectError:a,walletList:o,walletChainType:r,app:s}){let c=u.useAppConfig(),{connectors:d}=m.usePrivyInternal(),{t:g}=h.useI18n(),{wallets:w,walletCount:y,search:f,setSearch:v,selected:x,setSelected:b}=k({enabled:p.shouldFetchWcRegistryListings(o??[]),walletList:o,walletChainType:r}),[C,j]=l.useState(),[_,W]=l.useState(),[L,T]=l.useState(),[S,z]=l.useState(),A=!x&&!L&&!S,E=A&&(y>6||f.length>0),q=d.find((e=>"wallet_connect_v2"===e.connectorType)),M=l.useCallback((async(n,t)=>{if(n){if(S?.connector===n&&"loading"===C)return void console.log("Already connecting to this wallet, skipping duplicate attempt");if(j("loading"),"string"==typeof n)return z({connector:n,name:t?.name??"Wallet",icon:t?.icon,id:t?.id,url:t?.url}),void window.open(n,"_blank");z({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 j("error"),W(void 0),void a?.(new m.PrivyConnectorError("Unable to connect wallet"));j("success"),W(void 0),p.setActiveWallet({address:t.address,client:t.walletClientType,appId:c.id}),setTimeout((()=>{e({connector:n,wallet:t})}),u.DEFAULT_SUCCESS_SCREEN_DURATION_MS)}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");j("error"),W(n?.privyErrorCode),a?.(n instanceof Error?n:new m.PrivyConnectorError(n?.message||"Unable to connect wallet"))}}}),[c.id,e,S,C]),I=l.useCallback((()=>L?(j(void 0),W(void 0),z(void 0),void T(void 0)):S?(j(void 0),W(void 0),void z(void 0)):x?(j(void 0),W(void 0),z(void 0),void b(void 0)):"error"===C||"loading"===C?(j(void 0),W(void 0),void z(void 0)):void n?.()),[L,S,x,C,n]),N=l.useMemo((()=>S?.connector===q&&L&&i.isMobile&&S?.name?g("connectWallet.goToWallet",{walletName:S.name}):S?.connector===q&&L&&S?.name?g("connectWallet.scanToConnect",{walletName:S.name}):L&&S?.name?i.isMobile?g("connectWallet.goToWallet",{walletName:S.name}):g("connectWallet.scanToConnect",{walletName:S.name}):"string"==typeof S?.connector?g("connectWallet.openOrInstall",{walletName:S.name}):x&&!S?g("connectWallet.selectNetwork"):S?null:g("connectWallet.selectYourWallet")),[S,L,x,q,g]);return{selected:x,setSelected:b,qrUrl:L,setQrUrl:T,connecting:S,uiState:C,errorCode:_,search:f,setSearch:v,wallets:w,walletCount:y,wc:q,isInitialConnectView:A,showSearchBar:E,title:N,handleConnect:M,handleBack:I,onClose:t,onConnect:e,app:s}}({...L,walletList:P,walletChainType:U}),se=F.find((e=>"wallet_connect_v2"===e.connectorType)),ce=F.find((e=>"walletconnect_solana"===e.walletBranding.id)),de=l.useRef(null),ue=t.useVirtualizer({count:Z.length,getScrollElement:()=>de.current,estimateSize:()=>56,overscan:6,gap:5}),he=l.useCallback((async e=>{let n="solana-only"!==U&&e.chains?.some((e=>e.startsWith("eip155"))),t="ethereum-only"!==U&&e.chains?.some((e=>e.startsWith("solana"))),l=()=>{let n=e.id;return p.mobileWalletsConfig[n]||p.mobileWalletsConfig[`${n}_wallet`]},a=n=>{let t=v.normalize(e.id);return F.find((e=>v.normalize(e.walletClientType)===t&&e.chainType===n&&!("ethereum"===e.chainType&&e instanceof p.EthereumNullConnector||"solana"===e.chainType&&e instanceof p.SolanaNullConnector)))},o=async()=>{if(!se||!e.listing)return!1;let n=f[e.listing.slug]?{...e.listing,...f[e.listing.slug]}:e.listing;return se.setWalletEntry(n,G),await se.resetConnection(e.id),await ne(se,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0},r=async()=>!!ce&&!!e.listing&&(await ce.disconnect(),ce.wallet.setWalletEntry(e.listing,G),await new Promise((e=>setTimeout(e,100))),await ne(ce,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0),s=async n=>{let t=(e=>{let n=l();if(n)return n.getMobileRedirect({isSolana:e,connectOnly:!!C,useUniversalLink:!1})})(n);return!!t&&(await ne(t,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0)};if(n&&t)H(e);else{if(n&&!t){let n=a("ethereum");if(n&&!S(n))return void await ne(n,{name:e.label,icon:e.icon,id:e.id,url:e.url});if(i.isMobile&&l()){if(await s(!1)||await o())return}else if(await o()||await s(!1))return}if(t&&!n){let n=a("solana");if(n&&!S(n))return void await ne(n,{name:e.label,icon:e.icon,id:e.id,url:e.url});if(i.isMobile){if(await s(!0)||await r())return}else if(await r()||await s(!0))return}if(!S(e.connector)){if(se&&"wallet_connect_v2"===e.connector?.connectorType)if(await se.resetConnection(e.id),"wallet_connect_qr"!==e.id&&e.listing){let n=f[e.listing.slug]?{...e.listing,...f[e.listing.slug]}:e.listing;se.setWalletEntry(n,G)}else se.setWalletEntry({id:"wallet_connect_qr",name:"WalletConnect",rdns:"",slug:"wallet-connect",homepage:"",chains:["eip155"],mobile:{native:"",universal:void 0}},G);return ce&&"walletconnect_solana"===e.connector?.walletBranding.id&&(await ce.disconnect(),"wallet_connect_qr_solana"!==e.id&&e.listing?ce.wallet.setWalletEntry(e.listing,G):ce.wallet.setWalletEntry({id:"wallet_connect_solana_qr",name:"WalletConnect",rdns:"",slug:"wallet-connect-solana",homepage:"",chains:["solana"],mobile:{native:"",universal:void 0}},G),await new Promise((e=>setTimeout(e,100)))),void await ne(e.connector,{name:e.label,icon:e.icon,id:e.id,url:e.url})}e.url&&await ne(e.url,{name:e.label,icon:e.icon,id:e.id,url:e.url})}}),[se,ce,ne,H,G,U,C,F]);return l.useEffect((()=>{if(!j)return;let e=Z.find((({id:e})=>e===j));e&&he(e).catch(console.error)}),[j]),/*#__PURE__*/e.jsxs(y.Screen,{className:a,children:[/*#__PURE__*/e.jsx(y.Screen.Header,{icon:_&&ie?void 0:Y&&!V||V&&i.isMobile&&Y?.icon?Y.icon:Y?void 0:g.WalletCards,iconVariant:Y&&!V||V&&i.isMobile?"loading":void 0,iconLoadingStatus:Y&&!V||V&&i.isMobile?{success:"success"===J,fail:"error"===J}:void 0,title:_&&ie?void 0:Y&&!V?K("connectWallet.waitingForWallet",{walletName:Y.name}):V&&i.isMobile?K("connectWallet.waitingForWallet",{walletName:Y?.name??"connection"}):ae,subtitle:_&&ie?void 0:Y&&!V&&"string"==typeof Y.connector?K("connectWallet.installAndConnect",{walletName:Y.name}):Y&&!V&&"string"!=typeof Y.connector?"error"===J?X===m.PrivyErrorCode.NO_SOLANA_ACCOUNTS?`The connected wallet has no Solana accounts. Please add a Solana account in ${Y.name} and try again.`:K("connectWallet.tryConnectingAgain"):K("connectionStatus.connectOneWallet"):ie?r??($?K("connectWallet.connectToAccount",{appName:$.name}):null):null,showBack:!!R||!ie,showClose:!0,onBack:R||te,onClose:D}),/*#__PURE__*/e.jsxs(y.Screen.Body,{ref:de,$colorScheme:T.appearance.palette.colorScheme,style:{marginBottom:V?"0.5rem":void 0},children:[le&&/*#__PURE__*/e.jsx(A,{children:/*#__PURE__*/e.jsxs(d.EmailUpdateForm,{style:{background:"transparent"},children:[/*#__PURE__*/e.jsx(p.LoginMethodIconWrapper,{children:/*#__PURE__*/e.jsx(n.MagnifyingGlassIcon,{})}),/*#__PURE__*/e.jsx("input",{className:"login-method-button",type:"text",placeholder:K("connectWallet.searchPlaceholder",{count:String(ee)}),onChange:e=>re(e.target.value),value:oe})]})}),V&&i.isMobile&&"loading"===J&&/*#__PURE__*/e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem"},children:[/*#__PURE__*/e.jsx(o.Button,{variant:"primary",onClick:()=>window.open(V.universal??V.native,"_blank"),style:{width:"100%"},children:K("connectWallet.openInApp")}),/*#__PURE__*/e.jsx(B,{value:V.universal??V.native,iconOnly:!0,children:"Copy link"})]}),V&&!i.isMobile&&"loading"===J&&/*#__PURE__*/e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem"},children:/*#__PURE__*/e.jsx(B,{value:V.universal??V.native,iconOnly:!0,children:K("connectWallet.copyLink")})}),V&&!i.isMobile&&/*#__PURE__*/e.jsx(c.QrCode,{size:280,url:V.universal??V.native,squareLogoElement:Y?.icon?"string"==typeof Y.icon?n=>/*#__PURE__*/e.jsx("svg",{...n,children:/*#__PURE__*/e.jsx("image",{href:Y.icon,height:n.height,width:n.width})}):Y.icon:w.WalletConnect}),V&&!i.isMobile&&Y?.url&&("binance"===Y.id||"binanceus"===Y.id||"binance-defi"===Y.id)&&/*#__PURE__*/e.jsxs(O,{children:[/*#__PURE__*/e.jsxs("span",{children:["Don't have ",Y.name,"? "]}),/*#__PURE__*/e.jsx(s.Link,{href:Y.url,target:"_blank",size:"sm",children:"Download here"})]}),/*#__PURE__*/e.jsxs(E,{children:[Y&&!V&&"string"==typeof Y.connector&&/*#__PURE__*/e.jsxs(q,{onClick:()=>window.open(Y.connector,"_blank"),children:[Y.icon&&("string"==typeof Y.icon?/*#__PURE__*/e.jsx(W,{src:Y.icon}):/*#__PURE__*/e.jsx(Y.icon,{})),/*#__PURE__*/e.jsx(N,{children:Y.name})]}),Q?.chains.some((e=>e.startsWith("eip155")))&&!Y&&/*#__PURE__*/e.jsxs(q,{onClick:()=>he({...Q,chains:Q.chains.filter((e=>e.startsWith("eip155")))}),children:[Q.icon&&("string"==typeof Q.icon?/*#__PURE__*/e.jsx(W,{src:Q.icon}):/*#__PURE__*/e.jsx(Q.icon,{})),/*#__PURE__*/e.jsx(N,{children:Q.label}),/*#__PURE__*/e.jsx(M,{children:/*#__PURE__*/e.jsx(x,{})})]}),Q?.chains.some((e=>e.startsWith("solana")))&&!Y&&/*#__PURE__*/e.jsxs(q,{onClick:()=>he({...Q,chains:Q.chains.filter((e=>e.startsWith("solana")))}),children:[Q.icon&&("string"==typeof Q.icon?/*#__PURE__*/e.jsx(W,{src:Q.icon}):/*#__PURE__*/e.jsx(Q.icon,{})),/*#__PURE__*/e.jsx(N,{children:Q.label}),/*#__PURE__*/e.jsx(M,{children:/*#__PURE__*/e.jsx(b,{})})]}),ie&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[!(ee>0)&&/*#__PURE__*/e.jsx(I,{children:K("connectWallet.noWalletsFound")}),ee>0&&!V&&/*#__PURE__*/e.jsx("div",{style:{maxHeight:56*Math.min(Z.length,5)+5,width:"100%"},children:/*#__PURE__*/e.jsx("div",{style:{height:`${ue.getTotalSize()}px`,width:"100%",position:"relative"},children:ue.getVirtualItems().map((n=>/*#__PURE__*/e.jsx(z,{index:n.index,style:{position:"absolute",top:0,left:0,height:`${n.size}px`,transform:`translateY(${n.start}px)`},data:{wallets:Z,walletChainType:U,handleWalletClick:he}},n.key)))})})]})]})]}),/*#__PURE__*/e.jsxs(y.Screen.Footer,{children:[Y&&!V&&"string"!=typeof Y.connector&&"error"===J&&/*#__PURE__*/e.jsx(y.Screen.Actions,{children:/*#__PURE__*/e.jsx(o.Button,{style:{width:"100%",alignItems:"center"},variant:"error",onClick:()=>ne(Y.connector,{name:Y.name,icon:Y.icon,id:Y.id,url:Y.url}),children:K("connectWallet.retry")})}),!!($&&$.legal.privacyPolicyUrl&&$.legal.termsAndConditionsUrl)&&/*#__PURE__*/e.jsx(o.TermsAndConditions,{app:$,alwaysShowImplicitConsent:!0}),/*#__PURE__*/e.jsx(y.Screen.Watermark,{})]})]})},exports.useWalletsListController=k;