import{i as e}from"./chunk-aKtaBQYM.js";import{Ft as t,t as n,vt as r}from"./mui-BgU4WrXF.js";import{d as i,l as a,t as o}from"./IconButton-oialqkv3.js";import{t as s}from"./Typography-7EcQ2i3p.js";import{t as c}from"./TextField-DctlzLY-.js";import{Et as l,Ut as u,ct as d,f,pt as p,w as m}from"./index-bel1r0Sr.js";import{t as h}from"./LoginLayout-DF1i1Q4g.js";import{t as g}from"./BackIcon-CSBDQ_HZ.js";var _=e(t(),1),v=r(),y=n()(e=>({container:{display:`flex`,flexDirection:`column`,gap:e.spacing(2)},header:{display:`flex`,alignItems:`center`},title:{fontSize:e.spacing(3),fontWeight:500,marginLeft:e.spacing(1),textTransform:`uppercase`}})),b=()=>{let{classes:e}=y(),t=a(),n=p(),[r]=i(),b=r.get(`passwordReset`),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(``),[T,E]=(0,_.useState)(!1),D=d(async e=>{e.preventDefault(),b?await m(`/api/password/update`,{method:`POST`,body:new URLSearchParams(`token=${encodeURIComponent(b)}&password=${encodeURIComponent(C)}`)}):await m(`/api/password/reset`,{method:`POST`,body:new URLSearchParams(`email=${encodeURIComponent(x)}`)}),E(!0)});return(0,v.jsxs)(h,{children:[(0,v.jsxs)(`div`,{className:e.container,children:[(0,v.jsxs)(`div`,{className:e.header,children:[(0,v.jsx)(o,{color:`primary`,onClick:()=>t(`/login`),children:(0,v.jsx)(g,{})}),(0,v.jsx)(s,{className:e.title,color:`primary`,children:n(`loginReset`)})]}),b?(0,v.jsx)(c,{required:!0,label:n(`userPassword`),name:`password`,value:C,type:`password`,autoComplete:`current-password`,onChange:e=>w(e.target.value)}):(0,v.jsx)(c,{required:!0,type:`email`,label:n(`userEmail`),name:`email`,value:x,autoComplete:`email`,onChange:e=>S(e.target.value)}),(0,v.jsx)(u,{variant:`contained`,color:`secondary`,type:`submit`,onClick:D,disabled:!/(.+)@(.+)\.(.{2,})/.test(x)&&!C,fullWidth:!0,children:n(`loginReset`)})]}),(0,v.jsx)(l,{open:T,onClose:()=>t(`/login`),autoHideDuration:f,message:n(b?`loginUpdateSuccess`:`loginResetSuccess`)})]})};export{b as default};