1import{a2 as T,bb as W,r as c,j as e,aq as z,I as C,c as M,ag as F,ac as R,aD as H,R as J,u as x}from"./index-8frt79CZ.js";import{L as S}from"./label-ChkK1Wlu.js";import{u as Q}from"./useAuth-JUM9ozwg.js";import{u as U}from"./ClienteApp-CA5yBqIY.js";import{M as X}from"./mail-ClJJoPzx.js";import"./middleware-CyxBdRGG.js";import"./react-Dcugf22v.js";import"./house-BMMa0CWt.js";import"./wallet-BYfveuuF.js";import"./shopping-bag-CPh0HoBK.js";import"./tag-CRY3vH7U.js";import"./user-CP6hPVQh.js";import"./skeleton-4RnhQIr6.js";function Y(n){const t=n.replace(/\D/g,"").slice(0,11);return t.length<=2?t.length?`(${t}`:"":t.length<=7?`(${t.slice(0,2)}) ${t.slice(2)}`:t.length<=11?`(${t.slice(0,2)}) ${t.slice(2,7)}-${t.slice(7)}`:`(${t.slice(0,2)}) ${t.slice(2,7)}-${t.slice(7,11)}`}function k(n){return`+55${n.replace(/\D/g,"")}`}function Z({length:n=6,onComplete:t,isLoading:f=!1}){const[m,h]=c.useState(Array(n).fill("")),u=c.useRef([]);function N(s,i){var d;const a=i.replace(/\D/g,"").slice(-1),l=[...m];l[s]=a,h(l),a&&s<n-1&&((d=u.current[s+1])==null||d.focus());const o=l.join("");o.length===n&&!l.includes("")&&t(o)}function p(s,i){var a;if(i.key==="Backspace"){const l=[...m];l[s]?(l[s]="",h(l)):s>0&&((a=u.current[s-1])==null||a.focus())}}function g(s){var o;s.preventDefault();const i=s.clipboardData.getData("text").replace(/\D/g,"").slice(0,n);if(!i)return;const a=Array(n).fill("");i.split("").forEach((d,y)=>{a[y]=d}),h(a);const l=Math.min(i.length-1,n-1);(o=u.current[l])==null||o.focus(),i.length===n&&t(i)}return e.jsx("div",{className:"flex gap-2 justify-center",onPaste:g,children:m.map((s,i)=>e.jsx("input",{ref:a=>{u.current[i]=a},type:"text",inputMode:"numeric",maxLength:1,value:s,disabled:f,onChange:a=>N(i,a.target.value),onKeyDown:a=>p(i,a),className:"w-11 h-14 text-center text-xl font-bold border-2 border-gray-200 rounded-xl focus:border-primary focus:outline-none transition-colors disabled:opacity-50 bg-white"},i))})}function _(n){const[t,f]=c.useState(0);function m(){f(n)}return c.useEffect(()=>{if(t<=0)return;const h=setInterval(()=>f(u=>u-1),1e3);return()=>clearInterval(h)},[t]),{remaining:t,start:m}}function xe(){const n=T(),[t]=W(),f=t.get("redirect")??"/cliente",{signInWithOtp:m,verifyOtp:h,signInWithPassword:u}=Q(),{setIsGuest:N}=U(),[p,g]=c.useState("phone"),[s,i]=c.useState(""),[a,l]=c.useState(!1),[o,d]=c.useState(!1),[y,D]=c.useState(!1),{remaining:v,start:L}=_(60),[b,A]=c.useState(""),[w,V]=c.useState(""),[E,K]=c.useState(!1),[P,$]=c.useState(!1);async function I(){if(s.replace(/\D/g,"").length<10){x.error("Informe um número de telefone válido");return}d(!0);const{error:j}=await m(k(s));if(d(!1),j){x.error(j.message??"Erro ao enviar código");return}l(!0),L(),x.success("Código enviado por SMS!")}async function q(r){D(!0);const{error:j}=await h(k(s),r);if(D(!1),j){x.error("Código inválido ou expirado");return}n(f,{replace:!0})}async function B(){if(v>0)return;d(!0);const{error:r}=await m(k(s));if(d(!1),r){x.error(r.message);return}L(),x.success("Novo código enviado!")}async function O(){if(!b||!w){x.error("Preencha e-mail e senha");return}$(!0);const{error:r}=await u(b,w);if($(!1),r){x.error("E-mail ou senha incorretos");return}n(f,{replace:!0})}function G(){N(!0),n("/cliente")}return e.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-safe pt-6 pb-2",children:a&&p==="phone"?e.jsxs("button",{onClick:()=>l(!1),className:"flex items-center gap-1 text-gray-600",children:[e.jsx(z,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:"Voltar"})]}):e.jsx("div",{className:"h-6"})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center px-6 py-8",children:[e.jsxs("div",{className:"mb-8 text-center",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-primary text-white text-2xl font-bold shadow-lg mb-3",children:"M"}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:a?"Confirmar código":"Entrar na ComprouTai"}),e.jsx("p",{className:"text-gray-500 text-sm mt-1",children:a?`Enviamos um SMS para ${s}`:p==="phone"?"Acesse com seu número de celular":"Acesse com e-mail e senha"})]}),p==="phone"&&!a&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(S,{className:"text-sm font-medium text-gray-700 mb-1 block",children:"Celular"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500 text-sm select-none",children:"+55"}),e.jsx(C,{type:"tel",placeholder:"(11) 99999-9999",value:s,onChange:r=>i(Y(r.target.value)),className:"pl-12 h-12 text-base",onKeyDown:r=>r.key==="Enter"&&I()})]})]}),e.jsx(M,{onClick:I,disabled:o,className:"w-full h-12 text-base font-semibold",children:o?"Enviando...":"Continuar"}),e.jsx("button",{onClick:()=>g("email"),className:"w-full text-center text-sm text-primary underline underline-offset-2",children:"Entrar c
1om e-mail e senha"})]}),p==="phone"&&a&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Z,{onComplete:q,isLoading:y}),y&&e.jsx("p",{className:"text-center text-sm text-gray-500",children:"Verificando..."}),e.jsx("div",{className:"text-center",children:v>0?e.jsxs("p",{className:"text-sm text-gray-500",children:["Reenviar em"," ",e.jsxs("span",{className:"font-semibold text-gray-700",children:[v,"s"]})]}):e.jsxs("button",{onClick:B,disabled:o,className:"text-sm text-primary flex items-center gap-1 mx-auto",children:[e.jsx(F,{className:"w-4 h-4"}),o?"Enviando...":"Reenviar código"]})})]}),p==="email"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(S,{className:"text-sm font-medium text-gray-700 mb-1 block",children:"E-mail"}),e.jsxs("div",{className:"relative",children:[e.jsx(X,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx(C,{type:"email",placeholder:"[email protected]",value:b,onChange:r=>A(r.target.value),className:"pl-9 h-12 text-base"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-1",children:[e.jsx(S,{className:"text-sm font-medium text-gray-700",children:"Senha"}),e.jsx(R,{to:"/cliente/esqueci-senha",className:"text-xs text-primary underline",children:"Esqueci minha senha"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(C,{type:E?"text":"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:w,onChange:r=>V(r.target.value),className:"pr-10 h-12 text-base",onKeyDown:r=>r.key==="Enter"&&O()}),e.jsx("button",{type:"button",onClick:()=>K(!E),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400",children:E?e.jsx(H,{className:"w-4 h-4"}):e.jsx(J,{className:"w-4 h-4"})})]})]}),e.jsx(M,{onClick:O,disabled:P,className:"w-full h-12 text-base font-semibold",children:P?"Entrando...":"Entrar"}),e.jsx("button",{onClick:()=>g("phone"),className:"w-full text-center text-sm text-primary underline underline-offset-2",children:"Entrar com número de celular"})]})]}),e.jsxs("div",{className:"px-6 pb-safe pb-8 space-y-3",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Não tem conta? "}),e.jsx(R,{to:"/cliente/cadastro",className:"text-sm font-semibold text-primary",children:"Cadastrar"})]}),e.jsx("button",{onClick:G,className:"w-full text-center text-sm text-gray-400 underline underline-offset-2",children:"Entrar como visitante"})]})]})}export{xe 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.