import{r as i,h as n}from"./p-03169580.js";import{l as o}from"./p-c5cf028c.js";import{s as l}from"./p-511f6a28.js";import"./p-4cb16df5.js";import"./p-7cbdb4ea.js";import"./p-59c95c5f.js";const a="fireenjin-mx-page-login app-header ion-button.menu-button{display:none !important}";let t=class{constructor(n){i(this,n);this.isAwaitingEmail=false;this.isUsingEmailLink=false}onChange(i){var n,o,l,a;if(((n=i===null||i===void 0?void 0:i.target)===null||n===void 0?void 0:n.name)==="email"&&((o=i===null||i===void 0?void 0:i.target)===null||o===void 0?void 0:o.value)){this.email=i.target.value}else if(((l=i===null||i===void 0?void 0:i.target)===null||l===void 0?void 0:l.name)==="password"&&((a=i===null||i===void 0?void 0:i.target)===null||a===void 0?void 0:a.value)){this.password=i.target.value}}async presentLoading(){const i=await o.create({cssClass:"my-custom-class",message:"Please wait...",duration:2e3});await i.present();const{role:n,data:l}=await i.onDidDismiss();console.log("Loading dismissed!",n,l)}async login(i){var n,o;this.error=null;this.presentLoading();let a;try{a=i==="email"?this.isUsingEmailLink?await this.auth.withEmailLink(this.email,{url:l.config.url,dynamicLinkDomain:l.config.dynamicLinkDomain,iOS:{bundleId:"net.madnessenjin.mx"},android:{packageName:"net.madnessenjin.mx",installApp:false,minimumVersion:"12"},handleCodeInApp:true}):await this.auth.withEmail(this.email,this.password):await this.auth.withSocial(i);if(((n=a===null||a===void 0?void 0:a.user)===null||n===void 0?void 0:n.uid)||((o=a===null||a===void 0?void 0:a.data)===null||o===void 0?void 0:o.user)){const i=document.querySelector("ion-router");i.push("dashboard")}if(i==="email"&&this.isUsingEmailLink){this.isAwaitingEmail=true}}catch(i){this.error=i.message}}async sendPasswordReset(){var i;if(!((i=this.email)===null||i===void 0?void 0:i.length)){alert("Please enter a valid email address.");return}try{this.presentLoading();await this.auth.sendPasswordReset(this.email);this.isAwaitingEmail=true}catch(i){this.error=i.message}}render(){return[n("ion-content",{class:"ion-padding"},n("img",{alt:"fireenjin.mx Icon",src:"./assets/icon/icon.png",height:"250",width:"250",style:{margin:"0 auto",display:"block"}}),this.error&&n("ion-label",{style:{display:"block",maxWidth:"500px",margin:"15px auto 0 auto"},color:"danger"},n("ion-icon",{name:"information-circle"})," ",this.error),this.isAwaitingEmail?n("ion-grid",{style:{maxWidth:"500px",margin:"0 auto"}},n("ion-row",null,n("ion-col",{class:"ion-padding"},n("ion-icon",{style:{display:"block",width:"100px",height:"100px",color:"var(--ion-color-medium-tint)",margin:"15px auto"},name:"mail"}),n("ion-label",null,"We sent an email to ",this.email," with instructions. Please check your inbox and spam folders."))),n("ion-row",null,n("ion-col",null,n("ion-button",{fill:"outline",expand:"block",onClick:()=>this.isAwaitingEmail=false},n("ion-icon",{slot:"start",name:"arrow-back"}),n("ion-label",null,"Go Back"))),n("ion-col",null))):n("ion-grid",{style:{maxWidth:"500px",margin:"0 auto"}},n("ion-row",null,n("ion-col",null,n("fireenjin-input",{name:"email",type:"email",label:"Email Address",labelPosition:"stacked",placeholder:"j.doe@madnesslabs.net",value:this.email,required:true}),!this.isUsingEmailLink&&n("fireenjin-input",{name:"password",type:"password",labelPosition:"stacked",label:"Password",required:true}))),n("ion-row",null,n("ion-col",null,n("ion-button",{fill:"outline",expand:"block",onClick:()=>this.isUsingEmailLink=!this.isUsingEmailLink},n("ion-icon",{slot:"start",name:!this.isUsingEmailLink?"mail":"lock-closed"}),n("ion-label",null,this.isUsingEmailLink?"Sign-in with Password":"Sign-in With Email Link"))),n("ion-col",null,n("ion-button",{color:"warning",expand:"block",onClick:()=>this.login("email")},n("ion-label",null,"Sign-in"),n("ion-icon",{slot:"end",name:"log-in"})))),!this.isUsingEmailLink&&n("ion-row",null,n("ion-col",null,n("ion-button",{fill:"clear",color:"medium",expand:"block",onClick:()=>this.sendPasswordReset()},"Forgot my Password"))))),n("app-footer",null)]}};t.style=a;export{t as fireenjin_mx_page_login};
//# sourceMappingURL=p-889e8c44.entry.js.map