import{o as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{L as r,Vt as i,j as a}from"./useActiveWallet-CEs8euQ3.js";import{b as o}from"./context-Cdw68BC2.js";import"./index-CKYEOQWW.js";import{o as s}from"./index-CnFVexq_.js";import{r as c}from"./toViemAccount-BywVRwQG.js";import{t as l}from"./modal-context-DHfp-mFQ.js";import{t as u}from"./ScreenLayout-Dy-3vlz4.js";import{getErrorDetails as d}from"./ConnectionStatusScreen-Dp3G8z7P.js";var f=n(),p=e(t(),1),m=e(a(),1),h=({walletLogo:e,success:t,errorMessage:n,title:i,subtitle:a,onRetry:o,onUseDifferentWallet:s,onBack:c,numRetries:l,maxRetries:d})=>(0,f.jsx)(u,{title:i,subtitle:a,icon:e,iconVariant:`loading`,iconLoadingStatus:{success:t,fail:!!n},primaryCta:n===r.ERROR_USER_EXISTS?{label:`Use a different wallet`,onClick:s}:!t&&n?.retryable&&l<d?{label:`Retry`,onClick:o,disabled:!n?.retryable||l>=d}:!t&&n&&l>=d?{label:`Use a different wallet`,onClick:s}:void 0,onBack:c,watermark:!0}),g={component:()=>{let e,{navigateBack:t,navigate:n,lastScreen:r,currentScreen:a,data:u,setModalData:g}=l(),{walletConnectionStatus:_,closePrivyModal:v}=i(),[y,b]=(0,p.useState)(void 0),[x,S]=(0,p.useState)(0),C=s(_?.connector?.walletClientType||`unknown`),w=_?.status===`connected`,T=_?.status===`switching_to_supported_chain`;(0,p.useEffect)((()=>{if(w){let e;if(u?.externalConnectWallet?.onCompleteNavigateTo){let t=u.externalConnectWallet.onCompleteNavigateTo,r=_.connectedWallet?.address;e=setTimeout((()=>{if(u.funding&&_.connector){let e=_.connector.wallets.find((e=>e.address===r));g({...u,funding:{...u.funding,connectedWallet:e}})}n(t({address:r,walletClientType:_.connector?.walletClientType,walletChainType:_.connector?.chainType}))}),o)}else e=setTimeout(v,o);return()=>clearTimeout(e)}}),[w]),(0,p.useEffect)((()=>{var e;_?.connectError&&(e=_?.connectError,b(d(e)))}),[_]);let E=_?.connector?.connectorType||`injected`,D=_?.connector?.walletClientType||`unknown`,O=C?.metadata?.shortName||C?.name||_?.connector?.walletBranding.name||`Browser Extension`,k=C?.image_url?.md||_?.connector?.walletBranding.icon||(e=>(0,f.jsx)(c,{...e})),A=O===`Browser Extension`?O.toLowerCase():O;e=w?`Successfully connected with ${A}`:y?y.message:T?`Switching networks`:`Waiting for ${A}`;let j=`Don’t see your wallet? Check your other browser windows.`;return w?j=`You’re good to go!`:x>=2&&y?j=`Unable to connect wallet`:y?j=y.detail:T?j=`Switch your wallet to the requested network.`:D===`metamask`&&m.isMobile?j=`Click to continue to open and connect MetaMask.`:D===`metamask`?j=`For the best experience, connect only one wallet at a time.`:E===`wallet_connect_v2`?j=`Open your mobile wallet app to continue`:E===`coinbase_wallet`&&(j=`Confirm in the Coinbase app/popup to continue.`),(0,f.jsx)(h,{walletName:O,walletLogo:k,success:w,errorMessage:y,title:e,subtitle:j,onRetry:()=>{S(x+1),b(void 0),_?.connectRetry()},onUseDifferentWallet:t,onBack:a===r?void 0:t,numRetries:x,maxRetries:2})}};export{g as ConnectOnlyStatusScreen,g as default,h as ConnectOnlyStatusScreenView};