1import{B as e,P as t,t as n}from"./jsx-runtime-CG8VHYdG.js";import{n as r}from"./dist-Dfvr-iq_.js";import{f as i,h as a,i as o,n as s,o as c,p as l,r as u}from"./auth-CqbdQDn7.js";import{n as d}from"./AuthProvider-CzwHH36T.js";import{t as f}from"./button-CF3160Yq.js";import{n as p,r as m,t as h}from"./tabs-CrBi7Pp6.js";import{t as g}from"./buildFlags-DHFILslG.js";import{t as _}from"./input-D8zlO1Ru.js";import{t as v}from"./label-Cv4yFMSa.js";var y=e(t(),1),b=n(),x=()=>(0,b.jsxs)(`svg`,{viewBox:`0 0 18 18`,className:`h-4 w-4`,"aria-hidden":`true`,children:[(0,b.jsx)(`path`,{fill:`#4285F4`,d:`M17.64 9.2c0-.64-.06-1.25-.16-1.84H9v3.48h4.84a4.14 4.14 0 0 1-1.8 2.72v2.26h2.92c1.71-1.57 2.68-3.88 2.68-6.62z`}),(0,b.jsx)(`path`,{fill:`#34A853`,d:`M9 18c2.43 0 4.47-.8 5.96-2.18l-2.92-2.26c-.8.54-1.84.86-3.04.86-2.34 0-4.32-1.58-5.03-3.7H.96v2.33A9 9 0 0 0 9 18z`}),(0,b.jsx)(`path`,{fill:`#FBBC05`,d:`M3.97 10.72a5.4 5.4 0 0 1 0-3.44V4.95H.96a9 9 0 0 0 0 8.1l3.01-2.33z`}),(0,b.jsx)(`path`,{fill:`#EA4335`,d:`M9 3.58c1.32 0 2.5.45 3.44 1.35l2.58-2.58A9 9 0 0 0 .96 4.95l3.01 2.33C4.68 5.16 6.66 3.58 9 3.58z`})]});function S(e){let t=e;switch(t?.name){case`UsernameExistsException`:return`An account with this email already exists. Try logging in.`;case`InvalidPasswordException`:return`Password must be at least 8 characters with upper, lower, and number.`;case`InvalidParameterException`:return`Please check the information you entered.`;case`NotAuthorizedException`:return`Incorrect email or password.`;case`UserNotFoundException`:return`No account found with this email.`;case`CodeMismatchException`:return`That verification code is incorrect.`;case`ExpiredCodeException`:return`That code has expired. Request a new one.`;case`LimitExceededException`:return`Too many attempts. Please wait a bit and try again.`;default:return t?.message||`Something went wrong. Please try again.`}}var C={login:{title:`Welcome back`,description:`Log in to your TCP3 account.`},signup:{title:`Create your account`,description:`Sign up with your email and a password.`},confirm:{title:`Verify your email`,description:`Enter the 6-digit code we emailed you.`},forgot:{title:`Reset your password`,description:`We'll email you a verification code.`},reset:{title:`Choose a new password`,description:`Enter the code and your new password.`}};function w({onAuthenticated:e,returnTo:t,showHeading:n=!1}){let{refreshUser:w}=d(),[T,E]=(0,y.useState)(`login`),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(``),[N,P]=(0,y.useState)(``),[F,I]=(0,y.useState)(``),L=async()=>{O(!0);try{await l(k.trim(),j),await w(),r.success(`Logged in.`),await e()}catch(e){e.name===`UserNotConfirmedException`?(r.info(`Please verify your email first.`),E(`confirm`)):r.error(S(e))}finally{O(!1)}},R=async()=>{O(!0);try{await a(k.trim(),j),r.success(`Account created. Check your email for a code.`),E(`confirm`)}catch(e){r.error(S(e))}finally{O(!1)}},z=async()=>{O(!0);try{await o(k.trim(),N.trim()),r.success(`Email verified. You can log in now.`),P(``),E(`login`)}catch(e){r.error(S(e))}finally{O(!1)}},B=async()=>{try{await i(k.trim()),r.success(`A new code is on its way.`)}catch(e){r.error(S(e))}},V=async()=>{O(!0);try{await c(k.trim()),r.success(`Check your email for a reset code.`),E(`reset`)}catch(e){r.error(S(e))}finally{O(!1)}},H=async()=>{O(!0);try{await u(k.trim(),N.trim(),F),r.success(`Password reset. You can log in now.`),P(``),I(``),E(`login`)}catch(e){r.error(S(e))}finally{O(!1)}},U=e=>{if(e.preventDefault(),!D){if(T===`login`)return L();if(T===`signup`)return g.signup?R():void 0;if(T===`confirm`)return z();if(T===`forgot`)return V();if(T===`reset`)return H()}},{title:W,description:G}=C[T];return(0,b.jsxs)(`div`,{className:`space-y-4`,children:[n&&(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsx)(`h2`,{className:`text-lg font-semibold`,children:W}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:G})]}),g.signup&&(T===`login`||T===`signup`)&&(0,b.jsx)(h,{value:T,onValueChange:e=>E(e),children:(0,b.jsxs)(p,{className:`grid w-full grid-cols-2`,children:[(0,b.jsx)(m,{value:`login`,children:`Log in`}),(0,b.jsx)(m,{value:`signup`,children:`Sign up`})]})}),(0,b.jsxs)(`form`,{onSubmit:U,className:`space-y-4`,children:[T!==`reset`&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(v,{htmlFor:`auth-email`,children:`Email`}),(0,b.jsx)(_,{id:`auth-email`,type:`email`,autoComplete:`email`,required:!0,value:k,onChange:e=>A(e.target.value),disabled:T===`confirm`})]}),(T===`login`||T===`signup`)&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(v,{htmlFor:`auth-password`,children:`Password`}),(0,b.jsx)(_,{id:`auth-password`,type:`password`,autoComplete:T===`login`?`current-password`:`new-password`,required:!0,minLength:8,value:j,onChange:e=>M(e.target.value)})]}),(T===`confirm`||T===`reset`)&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(v,{htmlFor:`auth-code`,children:`Verification code`}),(0,b.jsx)(_,{id:`auth-code`,inputMode:`numeric`,autoComplete:`one-time-code`,required:!0,value:N,onChange:e=>P(e.target.value)})]}),T===`reset`&&(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(v,{htmlFor:`auth-new-password`,children:`New password`}),(0,b.jsx)(_,{id:`auth-new-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:F,onChange:e=>I(e.target.value)})]}),(0,b.jsxs)(f,{type:`submit`,className:`w-full`,disabled:D,children:[T===`login`&&`Log in`,T===`signup`&&`Sign up`,T===`confirm`&&`Verify email`,T===`forgot`&&`Send reset code`,T===`reset`&&`Reset password`]})]}),g.googleAuth&&(T===`login`||T===`signup`)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,b.jsx)(`span`,{className:`w-full border-t`})}),(0,b.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,b.jsx)(`span`,{className:`bg-background px-2 text-muted-foreground`,children:`or`})})]}),(0,b.jsxs)(f,{type:`button`,variant:`outline`,className:`w-full`,disabled:D,onClick:()=>s(`Google`,{returnTo:t}),children:[(0,b.jsx)(x,{}),`Continue with Google`]})]}),(0,b.jsxs)(`div`,{className:`text-center text-sm text-muted-foreground`,children:[T===`login`&&(0,b.jsx)(`button`,{type:`button`,className:`underline hover:text-foreground`,onClick:()=>E(`forgot`),children:`Forgot your password?`}),T===`confirm`&&(0,b.jsx)(`button`,{type:`button`,className:`underline hover:text-foreground`,onClick:B,children:`Resend code`}),(T===`forgot`||T===`reset`)&&(0,b.jsx)(`button`,{type:`button`,className:`underline hover:text-foreground`,onClick:()=>E(`login`),children:`Back to log in`})]})]})}export{w as t};
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.