import{o as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{T as r,Vt as i,c as a,d as o,h as s,j as c,rt as l}from"./useActiveWallet-CEs8euQ3.js";import{k as u}from"./context-Cdw68BC2.js";import{R as d}from"./index-CKYEOQWW.js";import{a as f,g as p,l as m,o as h}from"./index-CnFVexq_.js";import"./toViemAccount-BywVRwQG.js";import{o as g}from"./get-entropy-details-for-user-Bq7nAeEf.js";import{t as _}from"./modal-context-DHfp-mFQ.js";import{r as v,u as y}from"./ModalHeader-BS54PZSj.js";import{n as b}from"./ScreenHeader-CHmc4-Lu.js";import{t as x}from"./FundWalletMethodHeader-Doi39iuD.js";import{t as S}from"./Subtitle-CV-2yKE4.js";import{t as C}from"./Chip-D2-wZOHJ.js";import{c as w}from"./styles-C_oGPfcb.js";import{t as T}from"./InjectedWalletIcon-DLcYOGDj.js";import{t as E}from"./WalletOverflowButton-BtWfFdyX.js";var D=n(),O=e(t(),1),k=e(c(),1),A=({provider:e,displayName:t,logo:n,connectOnly:r,connector:o})=>{let s,{navigate:c,setModalData:u}=_(),{connectWallet:f,walletConnectionStatus:g}=i(),v=a(),[y,b]=(0,O.useState)(!1),x=o.connectorType===`wallet_connect_v2`?e:o.walletClientType,[S,C]=(0,O.useState)(!1);(0,O.useEffect)((()=>{S&&(g?.status===`connected`||g?.connectError)&&(c(r?`ConnectOnlyStatusScreen`:`ConnectionStatusScreen`),C(!1))}),[S,g]);let w=h(e),E=window.matchMedia(`(display-mode: standalone)`).matches,A=p({connectorType:o.connectorType,walletClientType:x});s=A&&A.chainTypes.includes(o.chainType)?()=>{A.isInstalled||o.chainType===`solana`&&`isInstalled`in o&&o.isInstalled?(f(o,x),c(r?`ConnectOnlyStatusScreen`:`ConnectionStatusScreen`)):m({isMobile:k.isMobile,walletConfig:A})?(u((t=>({...t,externalConnectWallet:{...t?.externalConnectWallet,preSelectedWalletId:e,walletChainType:o.chainType===`solana`?`solana-only`:`ethereum-only`}}))),c(r?`ConnectOnlyLandingScreen`:`AuthenticateWithWalletScreen`)):k.isMobile?(u({installWalletModalData:{walletConfig:A,chainType:o.chainType,connectOnly:r}}),c(`WalletInterstitialScreen`)):(u({installWalletModalData:{walletConfig:A,chainType:o.chainType,connectOnly:r}}),c(`InstallWalletScreen`))}:o.connectorType!==`coinbase_wallet`||o.coinbaseWalletConfig.preference?.options!==`eoaOnly`||!k.isMobile||E||l()?()=>{if(!d(window.navigator.userAgent)||event?.isTrusted){if(o.walletClientType===`mobile_wallet_adapter`)return f(o,x),void C(!0);f(o,x),r?o.connectorType===`wallet_connect_v2`?(u((e=>({...e,externalConnectWallet:{...e?.externalConnectWallet,preSelectedWalletId:`wallet_connect_qr`}}))),c(`ConnectOnlyLandingScreen`)):c(`ConnectOnlyStatusScreen`):c(`ConnectionStatusScreen`)}}:()=>{window.location.href=`https://go.cb-w.com/dapp?cb_url=${encodeURI(window.location.href)}`};let P=t||w?.metadata?.shortName||w?.name||o.walletClientType;return(0,D.jsxs)(j,{onClick:()=>{y||(b(!0),setTimeout((()=>b(!1)),2e3),s())},disabled:y,children:[(0,D.jsx)(T,{icon:n||w?.image_url?.md,name:P}),(0,D.jsx)(`span`,{children:P}),(0,D.jsxs)(N,{id:`chip-container`,children:[v?.walletClientType===x&&v?.chainType===o.chainType?(0,D.jsx)(M,{color:`gray`,children:`Recent`}):(0,D.jsx)(`span`,{id:`connect-text`,children:`Connect`}),o.chainType===`solana`&&(0,D.jsx)(M,{color:`gray`,children:`Solana`})]})]})},j=r(o)`
  /* Wallet name text color */
  > span {
    color: var(--privy-color-foreground);
  }

  /* Show "Connect" on hover */
  > #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;
    }
  }
`,M=r(C)`
  margin-left: auto;
`,N=r.div`
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
`,P=[`coinbase_wallet`,`base_account`],F=[`metamask`,`okx_wallet`,`rainbow`,`uniswap`,`bybit_wallet`,`ronin_wallet`,`haha_wallet`,`uniswap_extension`,`zerion`,`rabby_wallet`,`cryptocom`,`binance`,`kraken_wallet`,`robinhood_wallet`],I=[`safe`],L=[`phantom`,`backpack`,`solflare`,`jupiter`,`universal_profile`],R={component:()=>{let e,{connectors:t}=i(),{setModalData:n,data:r,navigate:a}=_(),o=u(),{wallets:c}=g(),l=t.filter(f).flatMap((e=>e.wallets)),[d,p]=(0,O.useState)(`default`),m=r?.funding?.chainType===`solana`,h=!!r?.funding?.crossChainBridgingEnabled;e=r?.funding?.chainType===`ethereum`?r.funding.erc20Address&&!r.funding.isUSDC?`ethereum-only`:h&&!r.funding.chain.testnet?`ethereum-and-solana`:`ethereum-only`:h&&!r.funding?.isUSDC?`ethereum-and-solana`:`solana-only`;let C=c.filter((e=>e.walletClientType!==`privy`)),w=C.map((e=>e.walletClientType)),T=l.filter((e=>e.walletClientType!==`privy`)),k=T.map((e=>e.walletClientType)),j=[],M={...r.funding};M.usingDefaultFundingMethod&&=!1;let N=({wallet:e,walletChainType:t})=>{n({...r,funding:{...M,connectedWallet:e,onContinueWithExternalWallet:()=>a(B({destChainType:m?`solana`:`ethereum`,sourceChainType:t}))},solanaFundingData:r?.solanaFundingData?{...r.solanaFundingData,sourceWalletData:{address:e.address,walletClientType:e.walletClientType}}:void 0}),a(`FundingAmountEditScreen`)};e!==`solana-only`&&j.push(...C.map(((e,t)=>(0,D.jsx)(z,{onClick:()=>N({wallet:e,walletChainType:`ethereum`}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},t)))),e!==`ethereum-only`&&j.push(...T.map(((e,t)=>(0,D.jsx)(z,{onClick:()=>N({wallet:e,walletChainType:`solana`}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},t)))),j.push(...(({walletList:e,walletChainType:t,connectors:n,connectOnly:r,ignore:i,walletConnectEnabled:a,forceWallet:o})=>{let s=[],c=[],l=[],u=n.filter((e=>t===`ethereum-only`?e.chainType===`ethereum`:t!==`solana-only`||e.chainType===`solana`)),d=u.find((e=>e.connectorType===`wallet_connect_v2`));for(let[n,f]of(o?[o.wallet]:e).entries()){if(f===`detected_ethereum_wallets`)for(let[e,t]of u.filter((({chainType:e,connectorType:t,walletClientType:n})=>e!==`solana`&&(n===`uniswap_wallet_extension`||n===`uniswap_extension`?!i.includes(`uniswap`):n===`crypto.com_wallet_extension`||n===`crypto.com_onchain`?!i.includes(`cryptocom`):t===`injected`&&!i.includes(n)))).entries()){let{walletClientType:i,walletBranding:a,chainType:o}=t;(i===`unknown`?c:s).push((0,D.jsx)(A,{connectOnly:r,provider:i,logo:a.icon,displayName:a.name,connector:t},`${n}-${f}-${i}-${o}-${e}`))}if(f===`detected_solana_wallets`)for(let[e,a]of u.filter((({chainType:e,walletClientType:n})=>{if(e===`solana`)return t!==`ethereum-only`&&!i.includes(n)})).entries()){let{walletClientType:t,walletBranding:i,chainType:o}=a;(t===`unknown`?c:s).push((0,D.jsx)(A,{connectOnly:r,provider:t,logo:i.icon,displayName:i.name,connector:a},`${n}-${f}-${t}-${o}-${e}`))}if(L.includes(f)){let e=u.find((e=>e.connectorType===`injected`&&e.walletClientType===f||e.connectorType===f));if(e&&s.push((0,D.jsx)(A,{connectOnly:r,provider:f,connector:e},`${n}-${f}`)),t===`solana-only`||t===`ethereum-and-solana`){let e=u.find((({chainType:e,walletClientType:t})=>e===`solana`&&t===f));e&&s.push((0,D.jsx)(A,{connectOnly:r,provider:f,connector:e},`${f}-solana`))}}else if(F.includes(f)){let e=u.find((e=>f===`uniswap`?e.walletClientType===`uniswap_wallet_extension`||e.walletClientType===`uniswap_extension`:f===`cryptocom`?e.walletClientType===`crypto.com_wallet_extension`||e.walletClientType===`crypto.com_onchain`:e.connectorType===`injected`&&e.walletClientType===f));if(a&&!e&&(e=d),e&&s.push((0,D.jsx)(A,{connectOnly:r,provider:f,connector:e,logo:e.connectorType===`injected`?e.walletBranding.icon:void 0,displayName:e.connectorType===`injected`?e.walletBranding.name:void 0},`${n}-${f}`)),t===`solana-only`||t===`ethereum-and-solana`){let e=u.find((({chainType:e,walletClientType:t})=>e===`solana`&&t===f));e&&s.push((0,D.jsx)(A,{connectOnly:r,provider:f,connector:e},`${f}-solana`))}}else if(P.includes(f)){let e=u.find((({connectorType:e})=>e===f));e&&s.push((0,D.jsx)(A,{connectOnly:r,provider:f,connector:e,displayName:e.walletClientType===`coinbase_wallet`?`Coinbase`:`Base`,logo:e.walletClientType===`coinbase_wallet`?`data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==`:`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAALZJREFUaEPtmjEOhDAMBNc/O14GvOzys3CAKK6eAlmaVGl2Zc+kTOU685vkc9/bnD2prZK5/TZY24z9P+g4F5hNh7/GdoG37WlAA5CATwgCxHENYISwQAMQII5rACOEBRqAAHFcAxghLNAABIjjGsAIYYEGIEAc1wBGCAs0AAHiuAYwQligAQgQxzWAEcICDUCAOK4BjBAWaAACxHENYISwQAMQII6fBjr+VHkW3+u+tfyxMpJaDgYzYxb/ALZVAAAAAElFTkSuQmCC`},`${n}-${f}`))}else if(I.includes(f))d&&l.push((0,D.jsx)(A,{connectOnly:r,provider:f,connector:d},`${n}-${f}`));else if(f===`wallet_connect`)d&&l.push((0,D.jsx)(A,{connectOnly:r,provider:f,connector:d,logo:d.walletBranding.icon,displayName:`WalletConnect`},`${n}-${f}`));else if(f===o?.wallet){let t=o.chainType===`ethereum`&&e.includes(`detected_ethereum_wallets`),i=o.chainType===`solana`&&e.includes(`detected_solana_wallets`);if(t||i){let e=u.find((({walletClientType:e})=>e===f));e&&s.push((0,D.jsx)(A,{connectOnly:r,provider:f,displayName:e.walletBranding?.name,logo:e.walletBranding?.icon,connector:e},`${n}-${f}`))}}}return[...c,...s,...l]})({walletList:o.appearance.walletList.filter((e=>!C.some((t=>t.walletClientType===e))&&!T.some((t=>t.walletClientType===e)))),walletChainType:e,connectors:t,connectOnly:!0,ignore:[...o.appearance.walletList,...w,...k],walletConnectEnabled:o.externalWallets.walletConnect.enabled}));let R=(0,D.jsx)(E,{text:`More wallets`,onClick:()=>p(`overflow`)}),B=({sourceChainType:e,destChainType:t})=>e===`ethereum`&&t===`solana`?`AwaitingEvmToSolBridgingScreen`:e===`ethereum`&&t===`ethereum`?`AwaitingExternalEthereumTransferScreen`:e===`solana`&&t===`ethereum`?`AwaitingSolToEvmBridgingScreen`:M.externalSolanaFundingScreen;return(0,O.useEffect)((()=>{n({...r,externalConnectWallet:{onCompleteNavigateTo:({address:e,walletClientType:t,walletChainType:i})=>{let o=i??`ethereum`,s=o===`ethereum`?C.find((n=>n.address===e&&n.walletClientType===t)):T.find((n=>n.address===e&&n.walletClientType===t));return n({...r,funding:{...M,connectedWallet:s,onContinueWithExternalWallet:()=>{a(B({destChainType:m?`solana`:`ethereum`,sourceChainType:o}))}},solanaFundingData:r?.solanaFundingData?{...r.solanaFundingData,sourceWalletData:{address:e||``,walletClientType:t||``}}:void 0}),`FundingAmountEditScreen`}}})}),[]),(0,D.jsxs)(D.Fragment,d===`overflow`?{children:[(0,D.jsx)(v,{backFn:()=>p(`default`)},`header`),(0,D.jsxs)(s,{children:[(0,D.jsx)(S,{style:{color:`var(--privy-color-foreground-3)`,textAlign:`left`},children:`More wallets`}),j]}),(0,D.jsx)(y,{})]}:{children:[(0,D.jsx)(x,{}),(0,D.jsx)(b,{title:`Transfer from wallet`,description:`Connect a wallet to deposit funds or send funds manually to your wallet address.`}),(0,D.jsxs)(s,{children:[j.length>4?j.slice(0,3):j,j.length>4&&R]}),(0,D.jsx)(y,{})]})}},z=({onClick:e,icon:t,name:n,chainType:r})=>(0,D.jsxs)(o,{onClick:e,children:[(0,D.jsx)(w,{style:{width:20},children:(0,D.jsx)(T,{icon:t,name:n})}),n,(0,D.jsx)(C,{color:`gray`,style:{marginLeft:`auto`},children:`Connected`}),r===`solana`&&(0,D.jsx)(C,{color:`gray`,children:`Solana`})]});export{R as TransferFromWalletScreen,R as default};