1import{dW as M,dl as D,dm as N,dn as x,d6 as m,dF as I,dS as f,d8 as E,eP as v,dG as O,dr as d,e3 as U}from"./index-D2C6Ukks.js";import{a as j}from"./shouldProceedtoEmbeddedWalletCreationFlow-BTsQS1ZO-BnmW677v.js";import{n as k}from"./ScreenLayout-BgwOsyLd-DB-Rk5qO.js";import{c as F}from"./telegram-B-JqnkqZ-DljqensN.js";import"./ModalHeader-D7u2VQIH-vf4SbDPg.js";import"./Screen-yabWN6I5-sGNebaAa.js";import"./index-Dq_xe9dz-ZtCqX3yt.js";const $=({success:r,errorMessage:a,onRetry:c})=>{let i=r?"Successfully connected with Telegram":a?a.message:"Verifying connection to Telegram";return E.jsx(k,{title:i,subtitle:r?"You're good to go!":a?a.detail:"Just a few moments more",icon:F,iconVariant:"loading",iconLoadingStatus:{success:r,fail:!!a},secondaryCta:a?.retryable&&c?{label:"Retry",onClick:c}:void 0,watermark:!0})},Q={component:()=>{let{authenticated:r,logout:a,ready:c,user:i}=M(),{setModalData:A,navigate:l,resetNavigation:u,data:p}=D(),y=N(),{initLoginWithTelegram:R,loginWithTelegram:b,updateWallets:C,setReadyToTrue:w,closePrivyModal:_,createAnalyticsEvent:W,getAuthMeta:S}=x(),[g,L]=m.useState(!1),[h,o]=m.useState(void 0),s=I();async function T(){try{let e=await(async function(){let t;if(!r){if(s.enabled&&s.status==="error")throw new O(s.error,null,d.CAPTCHA_FAILURE);return s.enabled&&s.status!=="success"&&(s.execute(),t=await s.waitForResult()),t}})();await b({captchaToken:e}),L(!0),w(!0)}catch(e){if(e?.privyErrorCode===d.ALLOWLIST_REJECTED)return o(void 0),u(),void l("AllowlistRejectionScreen");if(e?.privyErrorCode===d.USER_LIMIT_REACHED)return console.error(new U(e).toString()),o(void 0),u(),void l("UserLimitReachedScreen");if(e?.privyErrorCode===d.USER_DOES_NOT_EXIST)return o(void 0),u(),void l("AccountNotFoundScreen");if(e?.privyErrorCode===d.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return o(void 0),u(),A({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,telegramAuthResult:S()?.telegramAuthResult,telegramWebAppData:S()?.telegramWebAppData,displayName:e.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void l("LinkConflictScreen");let{retryable:t,detail:n}=v(e);o({retryable:t,detail:n,message:"Authentication failed"})}}return m.useEffect((()=>{T()}),[]),m.useEffect((()=>{if(!(c&&r&&g&&i))return;if(y?.legal.requireUsersAcceptTerms&&!i.hasAcceptedTerms){let t=setTimeout((()=>{l("AffirmativeConsentScreen")}),f);return()=>clearTimeout(t)}if(j(i,y.embeddedWallets)){let t=setTimeout((()=>{A({createWallet:{onSuccess:()=>{},onFailure:n=>{console.error(n),W({eventName:"embedded_wallet_creation_failure_logout",payload:{error:n,provider:"telegram",screen:"TelegramAuthScreen"}}),a()},callAuthOnSuccessOnClose:!0}}),l("EmbeddedWalletOnAccountCreateScreen")}),f);return()=>clearTimeout(t)}C();let e=setTimeout((()=>_({shouldCallAuthOnSuccess:!0,isSuccess:!0})),f);return()=>clearTimeout(e)}),[c,r,g,i]),E.jsx($,{success:g,errorMessage:h,onRetry:h?.retryable?async()=>{try{o(void 0),p?.telegramAuthModalData?.seamlessAuth||await R(void 0,p?.login?.disableSignup),await T()}catch(e){let{retryable:t,detail:n}=v(e);o({retryable:t,detail:n,message:"Authentication failed"})}}:void 0})},isCaptchaRequired:!0,isShownBeforeReady:!0};export{Q as TelegramAuthScreen,$ as TelegramAuthScreenView,Q 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.