1import{o as B,k as Y,x as ee,u as se,r as a,j as e,g as y,y as k,L as M,B as F,U as ae,s as m}from"./index-DgcHkVT2.js";import{L as I}from"./label-ClDlVZWr.js";import{P as U}from"./PasswordInput-CUZJgRKm.js";import{C as q}from"./circle-check-DZUNTTwU.js";import{S as re}from"./shield-check-Bl7315L2.js";import"./eye-off-B7TZutt9.js";import"./eye-CUe0PK13.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const $=B("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const te=B("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),oe=r=>[{label:"MÃnimo 8 caracteres",ok:r.length>=8},{label:"Letra maiúscula",ok:/[A-Z]/.test(r)},{label:"Letra minúscula",ok:/[a-z]/.test(r)},{label:"Número",ok:/\d/.test(r)},{label:"Caractere especial (!@#$...)",ok:/[^A-Za-z0-9]/.test(r)}],xe=()=>{const r=Y(),[C]=ee(),{isRecovery:V,clearRecovery:K,user:d}=se(),u=C.get("token")||"",Z=window.location.hash.includes("type=recovery"),c=V||Z||C.get("mode")==="recovery",[g,S]=a.useState(""),[P,_]=a.useState(""),[i,D]=a.useState(""),[T,H]=a.useState(""),[j,w]=a.useState(!1),[W,x]=a.useState(!0),[E,N]=a.useState(""),[L,o]=a.useState(""),[G,J]=a.useState(!1),[h,R]=a.useState(!1),[z,A]=a.useState(!1),f=a.useMemo(()=>oe(i),[i]),b=f.every(s=>s.ok),p=f.filter(s=>s.ok).length;a.useEffect(()=>{if(c){x(!1),d!=null&&d.email&&S(d.email);return}if(!u){r("/");return}const t=setTimeout(async()=>{x(!0),N("");try{const{data:n,error:l}=await m.functions.invoke("validate-setup-token",{body:{token:u}});if(l||!(n!=null&&n.valid)){N((n==null?void 0:n.error)||"Token inválido. Por favor, entre em contato com o suporte."),x(!1);return}S(n.email),_(n.name||"")}catch{N("Erro ao validar token. Tente novamente.")}finally{x(!1)}},500);return()=>clearTimeout(t)},[u,r,c,d]);const O=async s=>{if(s.preventDefault(),o(""),!b){o("Sua senha não atende todos os requisitos");return}if(i!==T){o("As senhas não coincidem");return}w(!0);try{if(c){const{error:v}=await m.auth.updateUser({password:i});if(v){v.message.toLowerCase().includes("weak")||v.message.toLowerCase().includes("fraca")?o("Essa senha é muito comum e pode ser facilmente adivinhada. Por favor, escolha uma senha diferente e mais criativa."):o(v.message);return}K(),r("/");return}const{data:t,error:n}=await m.functions.invoke("validate-setup-token",{body:{token:u,action:"consume"}});if(n||!(t!=null&&t.valid)){o((t==null?void 0:t.error)||"Token expirado ou inválido. Tente novamente."),w(!1);return}const{error:l}=await m.auth.signUp({email:g,password:i,options:{emailRedirectTo:window.location.origin,data:P?{full_name:P}:void 0}});if(l){if(l.message.includes("already registered")){r(`/entrar?email=${encodeURIComponent(g)}`);return}else l.message.toLowerCase().includes("weak")||l.message.toLowerCase().includes("fraca")?o("Essa senha é muito comum e pode ser facilmente adivinhada. Por favor, escolha uma senha diferente e mais criativa."):o(l.message);return}const{error:X}=await m.auth.signInWithPassword({email:g,password:i});if(X){o("Conta criada, mas houve um erro ao entrar. Tente fazer login.");return}J(!0),r("/meus-produtos",{replace:!0})}catch{o("Erro ao criar conta. Tente novamente.")}finally{w(!1)}},Q=p<=2?"bg-destructive":p<=3?"bg-yellow-500":p<=4?"bg-blue-500":"bg-green-500";return W?e.jsxs("div",{className:"min-h-screen dotted-bg flex flex-col",children:[e.jsx("header",{className:"border-b border-white/10 py-4 px-4",children:e.jsx("div",{className:"container mx-auto",children:e.jsx(y,{to:"/",children:e.jsx(k,{size:"sm",showText:!0})})})}),e.jsx("main",{className:"flex-1 flex items-center justify-center",children:e.jsx(M,{className:"h-8 w-8 animate-spin text-primary"})})]}):E&&!G?e.jsxs("div",{className:"min-h-screen dotted-bg flex flex-col",children:[e.jsx("header",{className:"border-b border-white/10 py-4 px-4",children:e.jsx("div",{className:"container mx-auto",children:e.jsx(y,{to:"/",children:e.jsx(k,{size:"sm",showText:!0})})})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-5 text-center",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-destructive/10 border border-destructive/30 p-4",children:[e.jsx(te,{className:"h-6 w-6 text-destructive flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-bold text-destructive",children:"Link inválido"}),e.jsx("p",{className:"text-xs text-destructive/70",children:E})]})]}),e.jsx(F,{variant:"outline",className:"w-full",onClick:()=>r("/"),children:"Voltar ao inÃcio"})]})})]}):e.jsxs("div",{className:"min-h-screen dotted-bg flex flex-col",children:[e.jsx("header",{className:"border-b border-white/10 py-4 px-4",children:e.jsx("div",{className:"container mx-auto",children:e.jsx(y,{to:"/",children:e.jsx(k,{size:"sm",showText:!0})})})}),e.jsx("main",{className:"flex-1 flex items-center justify-center px-4 py-10",children:e.jsxs("div",{className:"w-full max-w-sm space-y-5",children:[!c&&e.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-green-500/10 border border-green-500/30 p-4",children:[e.jsx(q,{className:"h-6 w-6 text-green-500 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-green-400",children:"Pagamento confirmado!"}),e.jsx("p",{className:"text-xs text-green-400/70",children:"Crie uma senha para acessar seu produto."})]})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-primary/20",children:e.jsx($,{className:"h-7 w-7 text-primary"})})}),e.jsx("h1",{className:"text-2xl font-black text-foreground mb-1",children:c?"Redefinir Senha":"Defina sua Senha"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:c?"Digite sua nova senha abaixo":"Defina uma senha para acessar seu conteúdo"})]}),e.jsxs("form",{onSubmit:O,className:"rounded-2xl bg-white/5 border border-white/10 p-6 space-y-4",children:[L&&e.jsx("div",{className:"rounded-lg bg-destructive/10 border border-destructive/30 p-3 text-sm text-destructive",children:L}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"password",children:"Senha"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(U,{id:"password",placeholder:"Crie uma senha forte",value:i,onChange:s=>D(s.target.value),onFocus:()=>A(!0),onBlur:()=>A(!1),show:h,onToggleShow:()=>R(!h),required:!0})})]}),i.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex gap-1",children:f.map((s,t)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-colors ${t<p?Q:"bg-white/10"}`},t))}),z&&e.jsx("div",{className:"grid grid-cols-1 gap-1.5",children:f.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[s.ok?e.jsx(q,{className:"h-3.5 w-3.5 text-green-500 flex-shrink-0"}
11):e.jsx(ae,{className:"h-3.5 w-3.5 text-muted-foreground/40 flex-shrink-0"}),e.jsx("span",{className:`text-xs transition-colors ${s.ok?"text-green-400":"text-muted-foreground/60"}`,children:s.label})]},s.label))}),z&&b&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-400",children:[e.jsx(re,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-medium",children:"Senha forte!"})]})]}),e.jsxs("div",{children:[e.jsx(I,{htmlFor:"confirmPassword",children:"Confirmar senha"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(U,{id:"confirmPassword",placeholder:"Repita a senha",value:T,onChange:s=>H(s.target.value),show:h,onToggleShow:()=>R(!h),required:!0})})]}),e.jsxs(F,{type:"submit",className:"w-full",disabled:j||!b,children:[j?e.jsx(M,{className:"h-4 w-4 animate-spin"}):e.jsx($,{className:"h-4 w-4"}),j?"Criando conta...":"Confirmar Senha"]})]})]})})]})};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.