1import{dC as K,d7 as X,d8 as z,d9 as Z,db as h,d6 as g,dd as i,dL as ee,eo as j,dy as f,ep as te,d$ as y}from"./index-CIQz0BjK.js";import{i as re,B as oe,C as ae,o as ne,h as ie,s as se,d as de,n as ce,l as le,e as ue,r as me}from"./twitch-5IOe4sIQ-D6UUDMaT.js";import{F as pe}from"./GlobeAltIcon-Xnb6T0qu.js";import{a as he}from"./shouldProceedtoEmbeddedWalletCreationFlow-dAaEJGU0-BZFld6si.js";import{n as ye}from"./ScreenLayout-BHPjJ5Cm-BwJYu7CA.js";import{e as Ee}from"./capitalizeFirstLetter-DmLYqXsO-tV1Idewc.js";import"./ModalHeader-Cmkl2H_I-CsUXfRyF.js";import"./Screen-BtitJMEE-zUn-R8d-.js";import"./index-Dq_xe9dz-BJ7onZ8w.js";const fe=({style:e})=>g.jsx(pe,{style:{color:"var(--privy-color-error)",...e}});let F={google:{name:"Google",component:me},discord:{name:"Discord",component:ue},github:{name:"Github",component:le},linkedin:{name:"LinkedIn",component:ce},twitter:{name:"Twitter",component:de},spotify:{name:"Spotify",component:se},instagram:{name:"Instagram",component:ie},tiktok:{name:"Tiktok",component:ne},line:{name:"LINE",component:ae},twitch:{name:"Twitch",component:oe},apple:{name:"Apple",component:re}},ve=({iconUrl:e,...o})=>y.createElement("svg",{width:"33",height:"32",viewBox:"0 0 33 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},y.createElement("foreignObject",{x:"2",y:"2",width:"29",height:"28"},y.createElement("img",{src:e,width:"29",height:"28",style:{display:"block",objectFit:"contain",borderRadius:"4px"},alt:"Provider icon"})));const v=(e,o)=>{if(e in F)return F[e];if(te(e)&&o){let a=o.find(t=>t.provider===e);if(a)return{name:a.provider_display_name,component:t=>y.createElement(ve,{...t,iconUrl:a.provider_icon_url})}}return{name:"Unknown",component:fe}};function ge(e,o,a){let t={detail:"",retryable:!1},s=Ee(o);if((e==null?void 0:e.privyErrorCode)===i.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),(e==null?void 0:e.privyErrorCode)===i.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e.privyErrorCode===i.OAUTH_USER_DENIED&&(t.detail=`Retry and check ${s} to finish connecting your account.`,t.retryable=!0),(e==null?void 0:e.privyErrorCode)===i.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),(e==null?void 0:e.privyErrorCode)===i.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let n=v(o,a).name;t.detail=`Request limit reached for ${n}. Please wait a moment and try again.`}if((e==null?void 0:e.privyErrorCode)===i.OAUTH_ACCOUNT_SUSPENDED){let n=v(o,a).name;t.detail=`Your ${n} account is suspended. Please try another login method.`}return(e==null?void 0:e.privyErrorCode)===i.CANNOT_LINK_MORE_OF_TYPE&&(t.detail="You cannot authorize more than one account for this user."),(e==null?void 0:e.privyErrorCode)===i.OAUTH_UNEXPECTED&&o.startsWith("privy:")&&(t.detail="Something went wrong. Please try again."),t}const Se=({providerName:e,ProviderLogo:o,success:a,errorMessage:t,onRetry:s})=>{let n=a?`Successfully connected with ${e}`:t?t.message:`Verifying connection to ${e}`;return g.jsx(ye,{title:n,subtitle:a?"You're good to go!":t?t.detail:"Just a few moments more",icon:o,iconVariant:"loading",iconLoadingStatus:{success:a,fail:!!t},secondaryCta:t!=null&&t.retryable&&s?{label:"Retry",onClick:s}:void 0,watermark:!0})},Ue={component:()=>{var _;let{authenticated:e,logout:o,ready:a,user:t}=K(),{setModalData:s,navigate:n,resetNavigation:u}=X(),d=z(),{getAuthMeta:S,initLoginWithOAuth:Y,loginWithOAuth:H,updateWallets:V,setReadyToTrue:T,closePrivyModal:q,createAnalyticsEvent:B}=Z(),[E,Q]=h.useState(!1),[m,c]=h.useState(void 0),l=((_=S())==null?void 0:_.provider)||"google",{name:A,component:G}=v(l,d.customOAuthProviders);return h.useEffect(()=>{H(l).then(()=>{Q(!0),T(!0)}).catch(r=>{var O,C,w,R,N,b,U,I,L,k,P,D,$,x,M,W;if(T(!1),(r==null?void 0:r.privyErrorCode)===i.ALLOWLIST_REJECTED)return c(void 0),u(),void n("AllowlistRejectionScreen");if((r==null?void 0:r.privyErrorCode)===i.USER_LIMIT_REACHED)return console.error(new ee(r).toString()),c(void 0),u(),void n("UserLimitReachedScreen");if((r==null?void 0:r.privyErrorCode)===i.USER_DOES_NOT_EXIST)return c(void 0),u(),void n("AccountNotFoundScreen");if((r==null?void 0:r.privyErrorCode)===i.ACCOUNT_TRANSFER_REQUIRED&&((C=(O=r.data)==null?void 0:O.data)!=null&&C.nonce))return c(void 0),u(),s({accountTransfer:{nonce:(R=(w=r.data)==null?void 0:w.data)==null?void 0:R.nonce,account:(b=(N=r.data)==null?void 0:N.data)==null?void 0:b.subject,displayName:(L=(I=(U=r.data)==null?void 0:U.data)==null?void 0:I.account)==null?void 0:L.displayName,linkMethod:(k=S())==null?void 0:k.provider,embeddedWalletAddress:($=(D=(P=r.data)==null?void 0:P.data)==null?void 0:D.otherUser)==null?void 0:$.embeddedWalletAddress,oAuthUserInfo:(W=(M=(x=r.data)==null?void 0:x.data)==null?void 0:M.otherUser)==null?void 0:W.oAuthUserInfo}}),void n("LinkConflictScreen");let{retryable:p,detail:J}=ge(r,l,d.customOAuthProviders);c({retryable:p,detail:J,message:"Authentication failed"})}).finally(()=>{j()})},[A,l]),h.useEffect(()=>
1{if(a&&e&&E&&t){if(d!=null&&d.legal.requireUsersAcceptTerms&&!t.hasAcceptedTerms){let r=setTimeout(()=>{n("AffirmativeConsentScreen")},f);return()=>clearTimeout(r)}if(he(t,d.embeddedWallets)){let r=setTimeout(()=>{s({createWallet:{onSuccess:()=>{},onFailure:p=>{console.error(p),B({eventName:"embedded_wallet_creation_failure_logout",payload:{error:p,provider:l,screen:"OAuthStatusScreen"}}),o()},callAuthOnSuccessOnClose:!0}}),n("EmbeddedWalletOnAccountCreateScreen")},f);return()=>clearTimeout(r)}{let r=setTimeout(()=>q({shouldCallAuthOnSuccess:!0,isSuccess:!0}),f);return V(),()=>clearTimeout(r)}}},[a,e,E,t]),g.jsx(Se,{providerName:A,ProviderLogo:G,success:E,errorMessage:m,onRetry:m!=null&&m.retryable?()=>{j(),Y(l),c(void 0)}:void 0})},isShownBeforeReady:!0};export{Ue as OAuthStatusScreen,Se as OAuthStatusScreenView,Ue as default};
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.