import{r as e,h as s,F as o,H as r}from"./p-d55626d1.js";import{c as t}from"./p-2fd22ed9.js";import"./p-0bc4f624.js";import"./p-9bfc48ee.js";import{r as a}from"./p-097729d8.js";import{s as m}from"./p-62c3d279.js";import{r as i,p as c}from"./p-c7f96882.js";const n=class{constructor(s){e(this,s),this.resetEmailFormId="resetEmail",this.resetPasswordFormId="resetPassword",this.resetRequested=!1,this.resetWithToken=!1,this.resetCompleted=!1,this.token=null}async formEventHandler({detail:e}){return e.formId==this.resetEmailFormId?this.requestReset(e):e.formId==this.resetPasswordFormId?this.resetPassword(e):void 0}async componentDidRender(){const e=new URLSearchParams(location.search).get("reset");e&&(this.token=e,this.resetWithToken=!0)}async requestReset(e){const s={};Object.keys(e).map((o=>{e[o].key&&(s[e[o].key]=e[o].value)})),(await t.client.mutate({mutation:m(i),variables:s})).data.userRequestPasswordReset&&(this.resetRequested=!0)}async resetPassword(e){const s={};Object.keys(e).map((o=>{e[o].key&&(s[e[o].key]=e[o].value)})),(await t.client.mutate({mutation:m(c),variables:{token:this.token,resetInput:s}})).data.userResetPassword&&(this.resetCompleted=!0,a.router.push("/login"))}render(){return s(r,null,s("corejam-box",{p:8,max:"md",mx:"auto",px:4,lgPx:0,flex:!0,justify:"between",mb:24},s("corejam-box",{w:"5",mx:"auto"},s(o,null,0==this.resetWithToken?0==this.resetRequested?s(o,null,s("corejam-box",{bWidthBottom:1,bColor:"gray-400",mb:8,mt:12},s("corejam-type",{as:"h3",size:"xl"},"Reset Password")),s("corejam-form-container",{name:this.resetEmailFormId},s("corejam-form-input",{name:"email",type:"text",formId:this.resetEmailFormId,label:"Your Email",placeholder:"Your email"}),s("corejam-base-link",{href:"#"},s("corejam-form-submit",{formId:this.resetEmailFormId},s("corejam-type",{size:"sm",weight:"bold",transform:"uppercase",decoration:"underline"},"Reset"))))):s("corejam-modal",{message:"Please check your mail",type:"success"}):0==this.resetCompleted?s(o,null,s("corejam-box",{bWidthBottom:1,bColor:"gray-400",mb:8,mt:12},s("corejam-type",{as:"h3",size:"xl"},"Update Password")),s("corejam-form-container",{name:this.resetPasswordFormId},s("corejam-box",{flex:!0,mb:8},s("corejam-form-input",{name:"password",type:"password",formId:this.resetPasswordFormId,label:"Password",placeholder:"Password"})),s("corejam-box",{flex:!0,mb:8},s("corejam-form-input",{name:"passwordConfirm",type:"password",formId:this.resetPasswordFormId,label:"Confirm Password",placeholder:"Confirm Password"})),s("corejam-base-link",{href:"#"},s("corejam-form-submit",{formId:this.resetPasswordFormId},s("corejam-type",{size:"sm",weight:"bold",transform:"uppercase",decoration:"underline"},"Reset"))))):s("corejam-type",null,"Please check your mail")))))}};export{n as auth_reset}