import{r,u as h,cT as f,a as e,j as s,B as b,cU as y,F as w,c as N}from"./index-0d8158eb.js";import{u as x,M as S}from"./index.esm-07f1e6d3.js";import{S as u,L as v}from"./login-layout-d129ef85.js";import{C}from"./index-aba65090.js";import{S as E}from"./index-845e4de2.js";import"./index-9af9f9f3.js";const L=({toResetPassword:a})=>{const[t,l]=r.useState(!1),{register:n,handleSubmit:i,reset:c}=x(),m=h(),o=f();return e("form",{onSubmit:i(d=>{o.mutate(d,{onSuccess:()=>{m("/a/orders")},onError:()=>{l(!0),c()}})}),children:s("div",{className:"flex flex-col items-center",children:[e("span",{className:"inter-2xlarge-semibold text-grey-90 mt-4",children:"Welcome back!"}),e("span",{className:"inter-base-regular text-grey-50 mt-2",children:"It's great to see you 👋🏼"}),e("span",{className:"inter-base-regular text-grey-50 mb-xlarge",children:"Log in to your account below"}),e(u,{placeholder:"Email...",...n("email",{required:!0}),autoComplete:"email"}),e(u,{placeholder:"Password...",type:"password",...n("password",{required:!0}),autoComplete:"current-password"}),t&&e("span",{className:"inter-small-regular mt-2 w-full text-rose-50",children:"These credentials do not match our records"}),e(b,{className:"rounded-rounded inter-base-regular mt-4 w-[320px]",variant:"primary",size:"large",type:"submit",loading:o.isLoading,children:"Continue"}),e("span",{className:"inter-small-regular text-grey-50 mt-8 cursor-pointer",onClick:a,children:"Reset password"})]})})},k=/^\S+@\S+$/i,I=({goBack:a})=>{const[t,l]=r.useState(!1),[n,i]=r.useState(!1),[c,m]=r.useState(!1),{register:o,handleSubmit:p}=x(),d=y();return e("form",{onSubmit:p(g=>{if(!k.test(g.email)){i(!0);return}i(!1),l(!1),d.mutate({email:g.email},{onSuccess:()=>{m(!0)},onError:()=>{l(!0)}})}),children:s("div",{className:"flex flex-col items-center",children:[e("span",{className:"inter-2xlarge-semibold mt-base text-grey-90",children:"Reset your password"}),s("span",{className:"inter-base-regular text-grey-50 mt-xsmall text-center",children:["Enter your email address below, and we'll send you",e("br",{}),"instructions on how to reset your password."]}),c?s("div",{className:"text-violet-60 rounded-rounded bg-violet-10 p-base gap-x-small mt-large flex",children:[e("div",{children:e(C,{size:20})}),s("div",{className:"gap-y-2xsmall flex flex-col",children:[e("span",{className:"inter-small-semibold",children:"Succesfully sent you an email"}),e("span",{className:"inter-small-regular",children:"We've sent you an email which you can use to reset your password. Check your spam folder if you haven't received it after a few minutes."})]})]}):s(w,{children:[e(u,{placeholder:"lebron@james.com...",...o("email",{required:!0}),className:"mt-xlarge mb-0"}),t&&e("div",{className:"mt-xsmall w-[318px]",children:e("span",{className:"inter-small-regular text-left text-rose-50",children:"We can't find a user with that email address"})}),n&&e("div",{className:"mt-xsmall w-[318px]",children:e("span",{className:"inter-small-regular text-left text-rose-50",children:"Not a valid email address"})}),e("button",{className:"text-grey-0 rounded-rounded inter-base-regular mt-4 h-[48px] w-[320px] border bg-violet-50 py-3 px-4",type:"submit",children:"Send reset instructions"})]}),e("span",{className:"inter-small-regular text-grey-50 mt-8 cursor-pointer",onClick:a,children:"Go back to sign in"})]})})},F=()=>{const[a,t]=r.useState(!1);return s(v,{children:[e(E,{title:"Login"}),e("div",{className:"flex h-full w-full items-center justify-center",children:e("div",{className:N("bg-grey-0 rounded-rounded flex min-h-[600px] w-[640px] justify-center transition-['min-height'] duration-300",{"min-h-[480px]":a}),children:s("div",{className:"flex w-full flex-col items-center px-[120px] pt-12",children:[e(S,{}),a?e(I,{goBack:()=>t(!1)}):e(L,{toResetPassword:()=>t(!0)})]})})})]})};export{F as default};
