1import{i as e}from"./rolldown-runtime-BgaNhQyE.js";import{i as t,r as n}from"./framework-Tx0HeTaA.js";import{d as r,l as i,o as a,s as o}from"./schemas-CoA-Mxxa.js";import{t as s}from"./password-input-xqWxTG8U.js";import{t as c}from"./button-p0Sh-Dwp.js";import{t as l}from"./link-bFSG1oHF.js";import{t as u}from"./field-DUfSgfRt.js";import{t as d}from"./input-DnAOEtvG.js";import{t as f}from"./browser-DiaVwm2m.js";var p=r().trim().toLowerCase().pipe(a(`Informe um e-mail válido.`).max(254)),m=r().min(10,`A senha deve possuir pelo menos 10 caracteres.`).max(128);function h(e){return e.refine(e=>e.password===e.passwordConfirmation,{message:`As senhas não coincidem.`,path:[`passwordConfirmation`]})}var g=i({email:p,password:m});h(i({name:r().trim().min(1,`Informe seu nome.`).max(160),phone:r().trim().min(8,`Informe um telefone válido (com DDD).`).max(40),email:p,password:m,passwordConfirmation:m,legalAcceptance:o(`accepted`,{error:`Você precisa aceitar os Termos de Uso e a PolÃtica de Privacidade.`}),marketingConsent:o(`accepted`).optional()})),i({email:p}),h(i({password:m,passwordConfirmation:m}));var _=e(t(),1);function v(e){return e.nextLevel===`aal2`&&e.nextLevel!==e.currentLevel}var y=`https://internal.invalid`;function b(e,t=`/app`){if(!e)return t;let n;try{n=new URL(e,y)}catch{return t}return n.origin===y?`${n.pathname}${n.search}${n.hash}`:t}var x=n(),S={},C=[0,450,900];function w(e){if(!e||typeof e!=`object`)return``;let t=e;return typeof t.code==`string`?t.code:``}function T(e){if(!e||typeof e!=`object`)return!1;let t=e,n=typeof t.name==`string`?t.name:``,r=typeof t.status==`number`?t.status:0,i=typeof t.message==`string`?t.message.toLowerCase():``;return n===`AuthRetryableFetchError`||r===408||r===429||r===502||r===503||r===504||r===520||r===522||i.includes(`fetch failed`)||i.includes(`network`)||i.includes(`timeout`)}function E(e){let t=w(e);return t===`email_not_confirmed`?`Seu e-mail ainda não foi confirmado. Abra o e-mail de confirmação enviado pelo SharkHUB e tente novamente.`:t===`user_banned`?`Este acesso está temporariamente bloqueado. Entre em contato com o suporte.`:t===`over_request_rate_limit`||t===`over_email_send_rate_limit`?`Foram feitas muitas tentativas em pouco tempo. Aguarde alguns minutos e tente novamente.`:t===`invalid_credentials`?`E-mail ou senha incorretos. Confira os dados e tente novamente.`:`Não foi possÃvel concluir o acesso. Tente novamente.`}function D(e){return new Promise(t=>setTimeout(t,e))}function O({next:e}){let[t,n]=(0,_.useState)(S),[r,i]=(0,_.useState)(!1);async function a(t){if(t.preventDefault(),r)return;let a=t.currentTarget,o=new FormData(a),s=typeof o.get(`email`)==`string`?String(o.get(`email`)):``,c=g.safeParse({email:o.get(`email`),password:o.get(`password`)});if(!c.success){let e=c.error.flatten().fieldErrors;n({error:`Revise os campos informados.`,email:s,fieldErrors:{email:e.email?.[0],password:e.password?.[0]}});return}i(!0),n({email:c.data.email});let l=f();try{let t=!1;for(let e=0;e<C.length;e+=1){let r=C[e]??0;r>0&&await D(r);let{error:i}=await l.auth.signInWithPassword(c.data);if(!i){t=!0;break}if(T(i)){if(e<C.length-1)continue;n({error:`O acesso está instável neste momento. Aguarde alguns segundos e tente novamente.`,email:c.data.email});return}n({error:E(i),email:c.data.email});return}if(!t){n({error:`O acesso está instável neste momento. Aguarde alguns segundos e tente novamente.`,email:c.data.email});return}let{data:r,error:i}=await l.auth.mfa.getAuthenticatorAssuranceLevel();if(i){if(T(i)){n({error:`Sua sessão foi iniciada, mas a validação de segurança ficou indisponÃvel. Tente entrar novamente.`,email:c.data.email});return}n({error:`Não foi possÃvel validar a segurança da sessão. Tente novamente.`,email:c.data.email});return}let a=b(e,`/app`);if(r&&v(r)){window.location.assign(`/mfa/challenge?next=${encodeURIComponent(a)}`);return}window.location.assign(a)}catch(e){n({error:T(e)?`O acesso está instável neste momento. Aguarde alguns segundos e tente novamente.`:`Não foi possÃvel concluir o acesso. Tente novamente.`,email:c.data.email})}finally{i(!1)}}return(0,x.jsxs)(`form`,{onSubmit:a,className:`mt-8 space-y-5`,noValidate:!0,children:[(0,x.jsx)(`input`,{type:`hidden`,name:`next`,value:e}),(0,x.jsxs)(u.Root,{invalid:!!t.fieldErrors?.email,children:[(0,x.jsx)(u.Label,{children:`E-mail`}),(0,x.jsx)(d,{name:`email`,type:`email`,autoComplete:`email`,defaultValue:t.email,required:!0}),(0,x.jsx)(u.Error,{children:t.fieldErrors?.email})]}),(0,x.jsxs)(u.Root,{invalid:!!t.fieldErrors?.password,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,x.jsx)(u.Label,{children:`Senha`}),(0,x.jsx)(l,{href:`/forgot-password`,className:`text-xs font-semibold text-ocean-300 hover:underline`,children:`Esqueceu a senha?`})]}),(0,x.jsx)(s,{name:`password`,autoComplete:`current-password`,required:!0}),(0,x.jsx)(u.Error,{children:t.fieldErrors?.password})]}),t.error?(0,x.jsx)(`div`,{role:`alert`,className:`rounded-xl border border-danger-500/20 bg-danger-500/8 px-4 py-3 text-sm text-danger-200`,children:t.error}):null,(0,x.jsx)(c,{type:`submit`,className:`w-full`,loading:r,children:r?`Entrandoâ¦`:`Entrar c
1om segurança`}),(0,x.jsxs)(`p`,{className:`text-center text-sm text-ink-400`,children:[`Não tem uma conta?`,` `,(0,x.jsx)(l,{href:`/signup?next=${encodeURIComponent(e)}`,className:`font-semibold text-ocean-300 hover:underline`,children:`Criar conta`})]})]})}export{O as LoginForm};
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.