import{j as e}from"./vendor-mui-69397583.js";import{r as u}from"./vendor-react-ece1c85f.js";import{F as j,a as f}from"./FormContainer-91c2b0e4.js";import{I as g,B as F,T as v}from"./index-c62ac197.js";import{A as y}from"./Alert-7dfbd254.js";import{A as b}from"./ActionLink-33e476e1.js";import{u as w}from"./useTimeOutMessage-e4eaa9f2.js";import{c as S,a as N,F as P,b as E,d as I}from"./index.esm-70ab539c.js";import"./vendor-redux-a1f00e6b.js";import"./vendor-pdf-b2a5d8b1.js";import"./vendor-devex-33a39e11.js";import"./vendor-i18n-2fcb1983.js";import"./vendor-msal-9caa1ed1.js";import"./vendor-charts-eccea5d1.js";const k=S().shape({email:N().matches(/^[^\s@]+@[^\s@]+\.[a-zA-Z]{2,}$/,"Invalid email").required("Please enter your email")}),A=l=>{const{disableSubmit:m=!1,className:c,signInUrl:d="/sign-in"}=l,[o,p]=u.useState(!1),[t,h]=w(),x=async(a,s)=>{var i,n;s(!0);try{(await v(a.email)).success&&(s(!1),p(!0))}catch(r){h(((n=(i=r==null?void 0:r.response)==null?void 0:i.data)==null?void 0:n.message)||r.toString()),s(!1)}};return e.jsxs("div",{className:c,children:[e.jsx("div",{className:"mb-6",children:o?e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"mb-1",children:"Check your email"}),e.jsx("p",{children:"We have sent a password recovery instruction to your email"})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"mb-1",children:"Forgot Password"}),e.jsx("p",{children:"Please enter your email address to receive a verification code"})]})}),t&&e.jsx(y,{showIcon:!0,className:"mb-4",type:"danger",children:t}),e.jsx(P,{initialValues:{email:""},validationSchema:k,onSubmit:(a,{setSubmitting:s})=>{m?s(!1):x(a,s)},children:({touched:a,errors:s,isSubmitting:i})=>e.jsx(E,{children:e.jsxs(j,{children:[e.jsx("div",{className:o?"hidden":"",children:e.jsx(f,{invalid:s.email&&a.email,errorMessage:s.email,children:e.jsx(I,{type:"email",autoComplete:"off",name:"email",placeholder:"Email",component:g})})}),e.jsx(F,{block:!0,loading:i,variant:"solid",type:"submit",children:o?"Resend Email":"Send Email"}),e.jsxs("div",{className:"mt-4 text-center",children:[e.jsx("span",{children:"Back to "}),e.jsx(b,{to:d,children:"Sign in"})]})]})})})]})},M=()=>e.jsx(A,{disableSubmit:!1}),G=M;export{G as default};
