1import{eR as v,d8 as i,eS as z,ei as Xe,ej as qe,ek as Pe,eJ as Ye,er as Ve,eQ as R,eF as Je,eT as Ke,eU as Te,eV as ze,eO as _e,eW as G,d9 as y,eP as Ge,eX as Ze,en as k,eY as He,eZ as Qe,e_ as Re,e$ as et,ck as tt,c1 as nt,ee as at}from"./index-I4Bd4QeM.js";import{n as ve}from"./Link-DTncR-24-Ch_ZKyPh.js";import{t as Ae}from"./useI18n-C0rfdPEH-C659f15P.js";import{a as ot}from"./shouldProceedtoEmbeddedWalletCreationFlow-DDzHjOUJ-BAxfBWiJ.js";import{n as it}from"./ScreenLayout-DTsWfKKs-rOYZW3HB.js";import"./ModalFooter-DKyozrEX-BzUQ78VB.js";import"./Screen-DMmH56yL-DVjkRCtI.js";import"./index-CWARkn2w-DrMeyL5V.js";const ke=o=>{var E;let c=(E=localStorage.getItem("-walletlink:https://www.walletlink.org:Addresses"))==null?void 0:E.split(" ").filter((l=>tt(l,{strict:!0}))).map((l=>nt(l)));return!!(c!=null&&c.length)&&!!(o!=null&&o.linkedAccounts.filter((l=>l.type=="wallet"&&c.includes(l.address))).length)};let lt=new Set(["phantom"]);const Z=o=>o&<.has(o.toLowerCase())?"transaction":"offchain-message",rt=o=>(o==null?void 0:o.privyErrorCode)===k.LINKED_TO_ANOTHER_USER?v.ERROR_USER_EXISTS:o instanceof He&&!o.details.default?o.details:o instanceof Qe?v.ERROR_TIMED_OUT:(o==null?void 0:o.privyErrorCode)===k.CANNOT_LINK_MORE_OF_TYPE?v.ERROR_USER_LIMIT_REACHED:v.ERROR_WALLET_CONNECTION,ct=({walletLogo:o,title:c,subtitle:E,signSuccess:l,errorMessage:s,connectSuccess:S,separateConnectAndSign:A,signing:N,walletConnectRedirectUri:$,walletConnectFallbackUniversalUri:u,hasTabbedAway:D,showCoinbaseWalletResetCta:j,numRetries:q,onBack:T,onSign:n,onRetry:_,onCoinbaseReset:W,onDifferentWallet:m})=>{let{t:e}=Ae(),P=j?{label:"Use a different wallet",onClick:W,disabled:l}:s===v.ERROR_USER_EXISTS&&T?{label:"Use a different wallet",onClick:m}:S&&!l&&A?{label:N?"Signing":"Sign with your wallet",onClick:n,disabled:N}:!l&&(s!=null&&s.retryable)&&q<2?{label:"Retry",onClick:_,disabled:!1}:l||s?void 0:{label:e("connectionStatus.connecting"),onClick:()=>{},disabled:!0};return y.jsx(it,{title:c,subtitle:E,icon:o,iconVariant:"loading",iconLoadingStatus:{success:l,fail:!!s},primaryCta:P,onBack:T,watermark:!0,children:!S&&$&&!D&&y.jsxs(st,{children:[e("connectionStatus.stillHere")," ",y.jsx(ve,{href:$,target:"_blank",variant:"underlined",size:"sm",children:e("connectionStatus.tryConnectingAgain")}),u&&y.jsxs(y.Fragment,{children:[" ",e("connectionStatus.or")," ",y.jsx(ve,{href:u,target:"_blank",variant:"underlined",size:"sm",children:e("connectionStatus.useDifferentLink")})]})]})})},ht={component:()=>{var ie,le,re,ce,se,de,ue,ge,Se,pe,fe,we,me,he,ye;let o,[c,E]=i.useState(!1),[l,s]=i.useState(!1),[S,A]=i.useState(void 0),{authenticated:N,logout:$}=z(),{navigate:u,navigateBack:D,lastScreen:j,currentScreen:q,setModalData:T,data:n}=Xe(),_=qe(),{t:W}=Ae(),{getAuthFlow:m,walletConnectionStatus:e,closePrivyModal:P,initLoginWithWallet:H,loginWithWallet:We,updateWallets:Le,createAnalyticsEvent:Ie}=Pe(),{walletConnectors:Y}=z(),[F,Oe]=i.useState(0),{user:d}=z(),[Ue]=i.useState((d==null?void 0:d.linkedAccounts.length)||0),[Q,Me]=i.useState(""),[xe,Ne]=i.useState(""),[$e,ee]=i.useState(!1),{hasTabbedAway:De}
1=(function(){let[t,a]=i.useState(!1),r=i.useCallback((()=>{document.hidden&&a(!0)}),[]);return i.useEffect((()=>(document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r))),[r]),{hasTabbedAway:t,reset:()=>a(!1)}})(),{enabled:je,token:te}=Ye(),f=Ve(((ie=e==null?void 0:e.connector)==null?void 0:ie.walletClientType)||"unknown"),L=R.isMobile&&((le=e==null?void 0:e.connector)==null?void 0:le.connectorType)==="wallet_connect_v2"||R.isMobile&&((re=e==null?void 0:e.connector)==null?void 0:re.connectorType)==="coinbase_wallet"||R.isMobile&&((ce=e==null?void 0:e.connector)==null?void 0:ce.connectorType)==="base_account"||R.isMobile&&((se=e==null?void 0:e.connector)==null?void 0:se.connectorType)==="injected"&&((de=e==null?void 0:e.connector)==null?void 0:de.walletClientType)==="phantom"||R.isMobile&&((ue=e==null?void 0:e.connector)==null?void 0:ue.connectorType)==="solana_adapter"&&e.connector.walletClientType==="mobile_wallet_adapter",w=(e==null?void 0:e.status)==="connected",ne=(e==null?void 0:e.status)==="switching_to_supported_chain";i.useEffect((()=>{var r,p,I,O,U,M;let t=m(),a=t instanceof Re||t instanceof Te?t:void 0;w&&((r=e.connector)==null?void 0:r.chainType)==="solana"&&Je(Ke)&&((p=n==null?void 0:n.login)==null?void 0:p.isSigningInWithLedgerSolana)===void 0?u("ConnectLedgerScreen",!1):(w&&!a&&(!je||te||N?H(e.connectedWallet,te,(I=n==null?void 0:n.login)==null?void 0:I.disableSignup,(O=n==null?void 0:n.login)!=null&&O.isSigningInWithLedgerSolana?Z((U=e.connector)==null?void 0:U.walletClientType):"plain").then((()=>{ee(!0)})):(T({captchaModalData:{callback:C=>{var h,b,x;return H(e.connectedWallet,C,(h=n==null?void 0:n.login)==null?void 0:h.disableSignup,(b=n==null?void 0:n.login)!=null&&b.isSigningInWithLedgerSolana?Z((x=e.connector)==null?void 0:x.walletClientType):"plain").then((()=>{ee(!0)}))},userIntentRequired:!1,onSuccessNavigateTo:"ConnectionStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),u("CaptchaScreen",!1))),a instanceof Te&&((M=n==null?void 0:n.login)!=null&&M.isSigningInWithLedgerSolana)&&(a.messageType=Z(a.meta.walletClientType)),a&&L&&w&&!a.preparedMessage?a.buildMessage():a&&!L&&w&&(l||(async()=>{var C,h;s(!0),A(void 0);try{((C=e==null?void 0:e.connector)==null?void 0:C.connectorType)==="wallet_connect_v2"&&((h=e==null?void 0:e.connector)==null?void 0:h.walletClientType)==="metamask"&&await ze(2500),await V()}catch(b){console.warn("Auto-prompted signature failed",b)}finally{s(!1)}})()))}),[F,w,$e]),i.useEffect((()=>{if(d&&c){let t=_e-500;if(_!=null&&_.legal.requireUsersAcceptTerms&&!d.hasAcceptedTerms){let r=setTimeout((()=>{u("AffirmativeConsentScreen")}),t);return()=>clearTimeout(r)}if(ot(d,_.embeddedWallets)){let r=setTimeout((()=>{T({createWallet:{onSuccess:()=>{},onFailure:p=>{console.error(p),Ie({eventName:"embedded_wallet_creation_failure_logout",payload:{error:p,screen:"ConnectionStatusScreen"}}),$()},callAuthOnSuccessOnClose:!0}}),u("EmbeddedWalletOnAccountCreateScreen")}),t);return()=>clearTimeout(r)}Le();let a=setTimeout((()=>P({shouldCallAuthOnSuccess:!0,isSuccess:!0})),_e);return()=>clearTimeout(a)}}),[d,c]);let ae=t=>{var a,r,p,I,O,U,M,C,h,b,x,Ce,be,Ee;if((t==null?void 0:t.privyErrorCode)!==k.ALLOWLIST_REJECTED){if((t==null?void 0:t.privyErrorCode)===k.USER_LIMIT_REACHED)return console.error(new et(t).toString()),void u("UserLimitReachedScreen");if((t==null?void 0:t.privyErrorCode)!==k.USER_DOES_NOT_EXIST)return(t==null?void 0:t.privyErrorCode)===k.ACCOUNT_TRANSFER_REQUIRED&&((r=(a=t.data)==null?void 0:a.data)!=null&&r.nonce)?(T({accountTransfer:{nonce:(I=(p=t.data)==null?void 0:p.data)==null?void 0:I.nonce,account:(O=m())==null?void 0:O.meta.address,displayName:(C=(M=(U=t.data)==null?void 0:U.data)==null?void 0:M.account)==null?void 0:C.displayName,externalWalletMetadata:{walletClientType:(h=m())==null?void 0:h.meta.walletClientType,chainId:(b=m())==null?void 0:b.meta.chainId,connectorType:(x=m())==null?void 0:x.meta.connectorType},linkMethod:m()instanceof Re?"siwe":"siws",embeddedWalletAddress:(Ee=(be=(Ce=t.data)==null?void 0:Ce.data)==null?void 0:be.otherUser)==null?void 0:Ee.embeddedWalletAddress}}),void u("LinkConflictScreen")):void A(rt(t));u("AccountNotFoundScreen")}
1else u("AllowlistRejectionScreen")};async function V(){try{await We(),E(!0)}catch(t){ae(t)}finally{s(!1)}}i.useEffect((()=>{e!=null&&e.connectError&&ae(e==null?void 0:e.connectError)}),[e]),((t,a)=>{let r=i.useRef((()=>{}));i.useEffect((()=>{r.current=t})),i.useEffect((()=>{if(a!==null){let p=setInterval((()=>r.current()),a||0);return()=>clearInterval(p)}}),[a])})((()=>{let t=B==="wallet_connect_v2"&&(e==null?void 0:e.connector)instanceof G?e.connector.redirectUri:void 0;t&&Me(t);let a=B==="wallet_connect_v2"&&(e==null?void 0:e.connector)instanceof G?e.connector.fallbackUniversalRedirectUri:void 0;a&&Ne(a)}),(e==null?void 0:e.connector)instanceof G&&!Q?500:null);let B=((ge=e==null?void 0:e.connector)==null?void 0:ge.connectorType)||"injected",J=((Se=e==null?void 0:e.connector)==null?void 0:Se.walletClientType)||"unknown",K=((pe=f==null?void 0:f.metadata)==null?void 0:pe.shortName)||(f==null?void 0:f.name)||((fe=e==null?void 0:e.connector)==null?void 0:fe.walletBranding.name)||"Browser Extension",Fe=((we=f==null?void 0:f.image_url)==null?void 0:we.md)||((me=e==null?void 0:e.connector)==null?void 0:me.walletBranding.icon)||(t=>y.jsx(Ge,{...t})),oe=K==="Browser Extension"?K.toLowerCase():K;o=c?W("connectionStatus.successfullyConnected",{walletName:oe}):S?W("connectionStatus.errorTitle",{errorMessage:S.message}):ne?"Switching networks":w?l&&L?"Signing":"Sign to verify":`Waiting for ${oe}`;let g=W("connectionStatus.checkOtherWindows");c?g=Ue===((d==null?void 0:d.linkedAccounts.length)||0)?"Wallet was already linked.":"You're good to go!":F>=2&&S?g="Unable to connect wallet":S?g=S.detail:ne?g="Switch your wallet to the requested network.":w&&L?g="Sign the message in your wallet to verify it belongs to you.":J==="metamask"&&R.isMobile?g="Click continue to open and connect MetaMask.":J==="metamask"?g="For the best experience, connect only one wallet at a time.":B==="wallet_connect"?g="Open your mobile wallet app to continue":B==="coinbase_wallet"?Ze()||(g=ke(d)?"Continue with the Coinbase app. Not the right wallet? Reset your connection below.":"Confirm in the Coinbase app/popup to continue."):(he=n==null?void 0:n.login)!=null&&he.isSigningInWithLedgerSolana&&(g="Ledger requires a transaction to verify your identity. You'll sign a transaction that performs no onchain action.");let X=(ye=Y==null?void 0:Y.walletConnectors)==null?void 0:ye.find((t=>t.walletClientType==="coinbase_wallet")),Be=J==="coinbase_wallet"&&(ke(d)||S===v.ERROR_USER_EXISTS);return y.jsx(ct,{walletLogo:Fe,title:o,subtitle:g,signSuccess:c,errorMessage:S,connectSuccess:w,separateConnectAndSign:L,signing:l,walletConnectRedirectUri:Q,walletConnectFallbackUniversalUri:xe,hasTabbedAway:De,showCoinbaseWalletResetCta:Be,numRetries:F,onBack:j&&q!==j?D:void 0,onSign:()=>{s(!0),V()},onRetry:()=>{Oe(F+1),A(void 0),w?(s(!0),V()):e==null||e.connectRetry()},onCoinbaseReset:()=>{X&&(X==null||X.disconnect())},onDifferentWallet:D})}};let st=at.p` 2 text-align: center; 3 color: var(--privy-color-foreground-2); 4 font-size: 14px; 5 line-height: 22px; 6 margin: 16px 0; 7`;export{ht as ConnectionStatusScreen,ct as ConnectionStatusView,ht as default,rt as getErrorDetails};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.