1import{r as T,j as U}from"./vendor-ui-hao9kjdD.js";import{b8 as H,P as B,r as K,I as Q,bJ as X,bt as S,dP as O,bK as Y,h as m,bv as $}from"./vendor-privy-BgdVndUX.js";import{a as z}from"./shouldProceedtoEmbeddedWalletCreationFlow-Cv_C9s3_-DbolsZpT.js";import{n as G}from"./ScreenLayout-DF3DCKOK-DkUASfh6.js";import{c as Z}from"./telegram-B-JqnkqZ-DDuFqTXP.js";import"./ModalHeader-rCMpqA2a-w_7zhD6f.js";import"./Screen-CV2tt2Ap-D3pZ-yda.js";import"./index-Dq_xe9dz-CndYRAYm.js";const ee=({success:r,errorMessage:t,onRetry:d})=>{let n=r?"Successfully connected with Telegram":t?t.message:"Verifying connection to Telegram";return U.jsx(G,{title:n,subtitle:r?"You're good to go!":t?t.detail:"Just a few moments more",icon:Z,iconVariant:"loading",iconLoadingStatus:{success:r,fail:!!t},secondaryCta:t!=null&&t.retryable&&d?{label:"Retry",onClick:d}:void 0,watermark:!0})},ce={component:()=>{let{authenticated:r,logout:t,ready:d,user:n}=H(),{setModalData:b,navigate:c,resetNavigation:g,data:u}=B(),f=K(),{initLoginWithTelegram:k,loginWithTelegram:I,updateWallets:F,setReadyToTrue:P,closePrivyModal:j,createAnalyticsEvent:J,getAuthMeta:E}=Q(),[v,V]=T.useState(!1),[A,o]=T.useState(void 0),i=X();async function R(){var s,a,l,h,p,C,w,_,W,L,M,D,N,x;try{let e=await async function(){let y;if(!r){if(i.enabled&&i.status==="error")throw new Y(i.error,null,m.CAPTCHA_FAILURE);return i.enabled&&i.status!=="success"&&(i.execute(),y=await i.waitForResult()),y}}();await I({captchaToken:e}),V(!0),P(!0)}catch(e){if((e==null?void 0:e.privyErrorCode)===m.ALLOWLIST_REJECTED)return o(void 0),g(),void c("AllowlistRejectionScreen");if((e==null?void 0:e.privyErrorCode)===m.USER_LIMIT_REACHED)return console.error(new $(e).toString()),o(void 0),g(),void c("UserLimitReachedScreen");if((e==null?void 0:e.privyErrorCode)===m.USER_DOES_NOT_EXIST)return o(void 0),g(),void c("AccountNotFoundScreen");if((e==null?void 0:e.privyErrorCode)===m.ACCOUNT_TRANSFER_REQUIRED&&((a=(s=e.data)==null?void 0:s.data)!=null&&a.nonce))return o(void 0),g(),b({accountTransfer:{nonce:(h=(l=e.data)==null?void 0:l.data)==null?void 0:h.nonce,account:(C=(p=e.data)==null?void 0:p.data)==null?void 0:C.subject,telegramAuthResult:(w=E())==null?void 0:w.telegramAuthResult,telegramWebAppData:(_=E())==null?void 0:_.telegramWebAppData,displayName:(M=(L=(W=e.data)==null?void 0:W.data)==null?void 0:L.account)==null?void 0:M.displayName,linkMethod:"telegram",embeddedWalletAddress:(x=(N=(D=e.data)==null?void 0:D.data)==null?void 0:N.otherUser)==null?void 0:x.embeddedWalletAddress}}),void c("LinkConflictScreen");let{retryable:y,detail:q}=O(e);o({retryable:y,detail:q,message:"Authentication failed"})}}return T.useEffect(()=>{R()},[]),T.useEffect(()=>{if(!(d&&r&&v&&n))return;if(f!=null&&f.legal.requireUsersAcceptTerms&&!n.hasAcceptedTerms){let a=setTimeout(()=>{c("AffirmativeConsentScreen")},S);return()=>clearTimeout(a)}if(z(n,f.embeddedWallets)){let a=setTimeout(()=>{b({createWallet:{onSuccess:()=>{},onFailure:l=>{console.error(l),J({eventName:"embedded_wallet_creation_failure_logout",payload:{error:l,provider:"telegram",screen:"TelegramAuthScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),c("EmbeddedWalletOnAccountCreateScreen")},S);return()=>clearTimeout(a)}F();let s=setTimeout(()=>j({shouldCallAuthOnSuccess:!0,isSuccess:!0}),S);return()=>clearTimeout(s)},[d,r,v,n]),U.jsx(ee,{success:v,errorMessage:A,onRetry:A!=null&&A.retryable?async()=>{var s,a;try{o(void 0),(s=u==null?void 0:u.telegramAuthModalData)!=null&&s.seamlessAuth||await k(void 0,(a=u==null?void 0:u.login)==null?void 0:a.disableSignup),await R()}catch(l){let{retryable:h,detail:p}=O(l);o({retryable:h,detail:p,message:"Authentication failed"})}}:void 0})},isCaptchaRequired:!0,isShownBeforeReady:!0};export{ce as TelegramAuthScreen,ee as TelegramAuthScreenView,ce 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.