import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,t as n,wt as r}from"./mui-B6lh3XSP.js";import{d as i,l as a,t as o}from"./IconButton-BEBOUWhl.js";import{t as s}from"./TextField-DOdnjCrL.js";import{t as c}from"./Typography-DfQXhGTT.js";import{Mt as l,en as u,f as d,mt as f,w as p,yt as m}from"./index-KVuxnkWj.js";import{t as h}from"./LoginLayout-D-6rL4KT.js";import{t as g}from"./BackIcon-BjuxlqVJ.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=m(),[r]=i(),b=r.get(`passwordReset`),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(``),[T,E]=(0,_.useState)(!1),D=f(async e=>{e.preventDefault(),b?await p(`/api/password/update`,{method:`POST`,body:new URLSearchParams(`token=${encodeURIComponent(b)}&password=${encodeURIComponent(C)}`)}):await p(`/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)(c,{className:e.title,color:`primary`,children:n(`loginReset`)})]}),b?(0,v.jsx)(s,{required:!0,label:n(`userPassword`),name:`password`,value:C,type:`password`,autoComplete:`current-password`,onChange:e=>w(e.target.value)}):(0,v.jsx)(s,{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:d,message:n(b?`loginUpdateSuccess`:`loginResetSuccess`)})]})};export{b as default};