import{r as i,j as e}from"./vendor-react-wBh_31cN.js";import{G as l,r as d,ar as j,as as v}from"./index-BKr2rJhV.js";import{j as g,u as b}from"./vendor-redux-CJZrIb6x.js";import{u as N,F as w}from"./index.esm-CAGtek53.js";import{o as S}from"./yup-XkUC3UEH.js";import{I as y}from"./input-H6_qmzms.js";import{L as C}from"./label-Dnebucx5.js";import{C as P,a as $,b as k,c as E}from"./card-DISTA6Ay.js";import{u as F}from"./useQueryParam-CfnQDC5y.js";import{H}from"./Hero-ILcN0sPk.js";import"./vendor-router-D1GqFWiT.js";import"./vendor-utils-OeoE2qq_.js";import"./vendor-icons-BUUmD6ht.js";import"./vendor-radix-BRyWS4bQ.js";import"./vendor-grid-CeFlDWv4.js";import"./theme-colors-BFneJNsI.js";const L=j().shape({email:v().email().required().label("Email")}),W=()=>{const o=g(),x=b(r=>r.loading.effects.auth.recoverPassword),[u]=F("email"),s=N({shouldUnregister:!1,resolver:S(L),defaultValues:{email:u}}),[m,p]=i.useState(!1),[n,h]=i.useState(""),[a,c]=i.useState(),f=i.useCallback(async({email:r})=>{c(null);const t=await o.auth.recoverPassword({data:r});t!=null&&t.error?c(t):(h(r),p(!0))},[o.auth]);return e.jsxs("div",{className:"flex flex-col items-center mt-[50px]",children:[e.jsx(H,{}),e.jsx("span",{className:"mb-[60px] mt-[15px] text-lg text-quartz-primary",children:"Hopsworks"}),(a==null?void 0:a.error)&&e.jsx("div",{className:"w-[466px] mb-5 rounded-md border border-destructive bg-destructive/10 p-3 text-sm text-destructive",children:(a==null?void 0:a.message)||"Incorrect email"}),e.jsxs(P,{className:"w-[466px]",children:[e.jsx($,{children:e.jsx(k,{children:"Reset password"})}),e.jsxs(E,{children:[m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Done"}),e.jsxs("div",{className:"flex items-center mt-2 gap-1",children:[e.jsx("span",{className:"text-xs",children:"An email has been sent to"}),e.jsx("span",{className:"text-xs text-quartz-primary font-medium",children:n})]})]}),e.jsx("div",{className:"flex justify-end mt-5",children:e.jsx(l,{variant:"secondary",onClick:()=>{window.location.href=`${d.auth.login}?email="${n}"`},children:"Login"})})]}),!m&&e.jsx(w,{...s,children:e.jsxs("form",{className:"flex flex-col",onSubmit:s.handleSubmit(f),children:[e.jsxs("div",{className:"w-full",children:[e.jsx(C,{className:"mb-1.5",children:"Email Address"}),e.jsx(y,{placeholder:"email",...s.register("email"),"aria-invalid":!!s.formState.errors.email}),s.formState.errors.email&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:s.formState.errors.email.message})]}),e.jsxs("div",{className:"flex justify-end mt-5 gap-5",children:[e.jsx(l,{variant:"secondary",type:"button",onClick:()=>{window.location.href=`${d.auth.login}?email="${s.getValues("email")}"`},children:"Login"}),e.jsx(l,{loading:x,type:"submit",children:"Send reset link"})]})]})})]})]})]})};export{W as default,L as schema};
