1import{j as e}from"./vendor-query-skQMsM6X.js";import{r as a,u as Q,b as Y,a as Z,L as w}from"./vendor-react-DyYvSSk1.js";import{u as z,a as ee,i as te,s as ae,H as oe,P as se,w as y,b as q}from"./index-BGwtrXIa.js";import{A as re,a as ne,b as ie,G as le,c as ce,d as B,e as V,f as me}from"./AuthShell-CpnIM4wQ.js";import{a5 as ue,n as de,E as pe,a as xe,A as fe}from"./vendor-ui-CCmu0bzQ.js";import{T as he}from"./TurnstileWidget-BWLtC2Bx.js";import{i as ge,s as ve}from"./validation-Ckkm_oms.js";import{t as je}from"./errorTranslations-lTGRyFpS.js";import{u as be}from"./useRateLimit-D-J1eJct.js";import{L as we}from"./LaunchPromoBanner-nZsibx3i.js";import"./vendor-supabase-BfoV2C50.js";function ye(){const{isAuthenticated:n}=z();return a.useEffect(()=>{},[n]),null}function Ee({email:n,onClose:s}){return e.jsx("div",{className:"landing-mono min-h-screen flex items-center justify-center bg-background px-4",children:e.jsxs("div",{className:"max-w-md w-full glass-card rounded-2xl p-8 relative animate-scale-in",children:[e.jsx("button",{onClick:s,className:"absolute top-4 right-4 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Fechar",children:e.jsx(ue,{size:20})}),e.jsxs("div",{className:"text-center space-y-6",children:[e.jsx("div",{className:"w-16 h-16 bg-primary/20 rounded-full flex items-center justify-center mx-auto",children:e.jsx(de,{size:32,className:"text-primary"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Verifique seu email"}),e.jsx("p",{className:"text-muted-foreground",children:"Enviamos um link de confirmação para:"}),e.jsx("p",{className:"font-medium text-primary",children:n})]}),e.jsxs("div",{className:"space-y-4 text-sm text-muted-foreground",children:[e.jsx("p",{children:"Clique no link enviado para ativar sua conta e fazer login."}),e.jsx("p",{children:"Não recebeu o email? Verifique sua caixa de spam ou entre em contato conosco."})]}),e.jsx("button",{onClick:s,className:"w-full btn-premium py-3 px-4 rounded-lg",children:"Entendi"})]})]})})}function qe(){const{login:n,user:s,isAuthenticated:E}=z(),{data:D}=ee(),O=te(D),m=Q(),N=Y(),[S]=Z(),[i,p]=a.useState(""),[x,F]=a.useState(""),[u,$]=a.useState(!1),[A,k]=a.useState(!0),[f,h]=a.useState(!1),[R,d]=a.useState(null),[G,L]=a.useState(!1),[g,v]=a.useState(null),[T,j]=a.useState(null),[P,U]=a.useState(!1),[C,b]=a.useState(!0),[H,W]=a.useState(!1),{checkRateLimit:J,remainingTime:K}=be({maxAttempts:5,windowMs:6e4}),c=a.useMemo(()=>{var r;const t=(r=N.state)==null?void 0:r.from,o=t?`${t.pathname}${t.search}${t.hash}`:void 0;return ae(S.get("redirect")||o,"/editor")},[N.state,S]);a.useEffect(()=>{if(!C)return;const t=setTimeout(()=>W(!0),3e3);return()=>clearTimeout(t)},[C]),a.useEffect(()=>{const t=localStorage.getItem("rr.lastEmail");if(t)try{const o=JSON.parse(t);o.expires&&o.expires>Date.now()?(p(o.email),k(!0)):localStorage.removeItem("rr.lastEmail")}catch{p(t)}},[]),a.useEffect(()=>{s&&!s.email_confirmed_at&&L(!0)},[s]),a.useEffect(()=>{(async()=>{if(!(!E||!s))try{const{data:o}=await q.from("profiles").select("profile_completed").eq("id",s.id).maybeSingle();o!=null&&o.profile_completed?m(c,{replace:!0}):m(y("/complete-profile",c),{replace:!0})}catch(o){console.error("Error checking profile:",o),m(y("/complete-profile",c),{replace:!0})}})()},[E,s,m,c]),a.useEffect(()=>{const t=new URLSearchParams(window.location.search),o=t.get("error"),r=t.get("message");if(o&&r){let l=r;switch(o){case"oauth_error":l="Erro no login com Google. Por favor, tente novamente.";break;case"exchange_error":l="Erro ao processar autenticação. Por favor, tente novamente.";break;case"auth_failed":l="Falha na autenticação. Por favor, tente novamente.";break}d(l),window.history.replaceState({},document.title,window.location.pathname)}},[]);const I=a.useMemo(()=>i?ge(i)?null:"Por favor, insira um email válido":null,[i]),_=!!(f||I||!i||!x||!g&&!P&&!H);async function X(t){if(t.preventDefault(),!_){if(!J()){d(`Muitas tentativas. Aguarde ${K()} segundos.`);return}d(null),j(null),h(!0);try{const o=g?{token:g}:{skipVerification:!0}
1,{data:r,error:l}=await q.functions.invoke("verify-turnstile",{body:o});if(l||!(r!=null&&r.success)){j("Sua rede pode estar bloqueando a verificação de segurança. Tente novamente em alguns segundos â o login continuará funcionando."),v(null),h(!1);return}const M=ve(i);await n(M,x),A?localStorage.setItem("rr.lastEmail",JSON.stringify({email:M,expires:Date.now()+30*24*60*60*1e3})):localStorage.removeItem("rr.lastEmail")}catch(o){const{title:r}=je(o,"Não foi possÃvel entrar. Verifique as credenciais.");d(r)}finally{h(!1)}}}return G&&(s!=null&&s.email)?e.jsx(Ee,{email:s.email,onClose:()=>L(!1)}):e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx("title",{children:"Login | RadReport - Laudos Radiológicos com IA"}),e.jsx("meta",{name:"description",content:"Acesse sua conta RadReport e continue criando laudos com o Tomo, ditado natural e Corretor IA."}),e.jsx("link",{rel:"canonical",href:"https://radreport.com.br/login"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"}),e.jsx("meta",{property:"og:title",content:"Login | RadReport"}),e.jsx("meta",{property:"og:description",content:"Acesse sua conta e crie laudos com o Tomo â copiloto de IA para radiologia."}),e.jsx("meta",{property:"og:url",content:"https://radreport.com.br/login"}),e.jsx("meta",{property:"og:image",content:"https://radreport.com.br/icon-512.png"}),e.jsx("meta",{property:"og:locale",content:"pt_BR"}),e.jsx("meta",{property:"og:site_name",content:"RadReport"}),e.jsx("meta",{property:"og:type",content:"website"})]}),e.jsxs(re,{eyebrow:"Vol. 01 · Acesso",headline:["O laudo é seu.","A velocidade,","nossa."],asideLabel:"Plataforma",asideText:`Tomo â copiloto de IA no editor, ditado natural em português clÃnico, ${se.templates_count}+ templates, frases modelo, tabelas RADS e calculadoras. LGPD e IA não-custodial.`,children:[e.jsx(ne,{line1:"Bem-vindo",line2:"de volta."}),e.jsx(ie,{active:"login"}),O&&e.jsx("div",{className:"mt-6",children:e.jsx(we,{variant:"compact"})}),e.jsx("div",{className:"mt-6",children:e.jsx(le,{variant:"mono"})}),e.jsx(ce,{label:"ou com email"}),e.jsxs("form",{onSubmit:X,className:"space-y-5",children:[e.jsx(B,{id:"login-email",label:"Email",error:I,children:e.jsx("input",{id:"login-email",type:"email",autoComplete:"email",value:i,onChange:t=>p(t.target.value),className:V,placeholder:"[email protected]",required:!0})}),e.jsx(B,{id:"login-password",label:"Senha",action:e.jsx(w,{to:"/forgot-password",className:"font-mono-label text-[10px] uppercase tracking-[0.2em] text-[color:var(--mono-text-dim)] transition-colors hover:text-[color:var(--mono-text)]",children:"Esqueci"}),children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"login-password",type:u?"text":"password",autoComplete:"current-password",value:x,onChange:t=>F(t.target.value),className:`${V} pr-12`,placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",required:!0}),e.jsx("button",{type:"button",onClick:()=>$(!u),"aria-label":u?"Ocultar senha":"Mostrar senha",className:"absolute right-2 top-1/2 flex h-11 w-11 -translate-y-1/2 items-center justify-center text-[color:var(--mono-text-dim)] transition-colors hover:text-[color:var(--mono-text)]",children:u?e.jsx(pe,{className:"h-4 w-4"}):e.jsx(xe,{className:"h-4 w-4"})})]})}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm text-[color:var(--mono-text-muted)]",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:t=>k(t.target.checked),className:"h-4 w-4 rounded-sm border-[color:var(--mono-hairline-strong)] accent-[color:var(--mono-text)]"}),"Lembrar-me neste dispositivo"]}),e.jsx(he,{onSuccess:t=>{v(t),b(!1)},onError:j,onExpire:()=>v(null),onUnavailable:()=>{U(!0),b(!1)},onLoading:b}),T&&e.jsx("p",{className:"text-xs text-destructive",children:T}),P&&e.jsxs("p",{className:"text-xs text-[color:var(--mono-text-dim)]",children:["Em uma rede restrita?"," ",e.jsx(w,{to:"/status",className:"underline underline-offset-2 hover:text-[color:var(--mono-text)]",children:"Diagnóstico de rede"})]}),R&&e.jsx("div",{className:"border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:R}),e.jsxs("button",{type:"submit",disabled:_,className:me,children:[f?"Entrando...":"Entrar",!f&&e.jsx(fe,{size:16})]})]}),e.jsxs("p",{className:"mt-6 text-center text-sm text-[color:var(--mono-text-muted)]",children:["Ainda não tem conta?"," ",e.jsx(w,{to:y("/signup",c),className:"font-medium text-[color:var(--mono-text)] underline underline-offset-4 hover:opacity-70",children:"Criar conta"})]}),e.jsx(ye,{})]})]})}export{qe 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.