import{_ as v}from"./WebFormFields-tqR0CcGC.mjs";import{_ as V,C as n,b8 as l,o as u,c as d,d as m,w as p,a as o,n as g,t as w,i as c,L as k,M as f,a4 as y,k as h,u as F,b9 as q,ax as S,p as C,m as R}from"./entry.DqIAapZC.js";import{_ as T}from"./WebFormWrapper-CpR2L6LR.mjs";import{u as I}from"./useVueRecaptcha-BuitovM3.mjs";import{u as L}from"./useFormHasErrors-IQPuMYam.mjs";import"./vue-select-CmP0gxFo.mjs";const U={props:{},async setup(e){const{$gql:s}=F(),i=await s.query("getReCAPTCHAPublicKey");return{tenantRecaptchaPublicKey:i==null?void 0:i.data}},data(){return{mode:"login",siteUser:null,loginValues:{username:"",password:""},resetPasswordValues:{email:""},error:null,showErrors:!1,loginErrors:{},resetPasswordErrors:{},processing:!1,qualifyingMembership:!1,message:null,recaptcha:null}},computed:{returnedFromSSO(){var e,s;return(s=(e=n())==null?void 0:e.query)==null?void 0:s.siteUserToken},submitDisabled(){var e,s;return this.mode==="login"&&(!((e=this.loginValues)!=null&&e.username)||!((s=this.loginValues)!=null&&s.password))||this.mode==="reset-password"&&!this.resetPasswordValues.email},loginFieldInfo(){return[{columns:[{fields:{username:{type:"email_input",label:"Email",placeholder:"Enter Email",required:!0,disabled:this.processing,showErrors:this.showErrors,icon:!0},password:{type:"password",label:"Password",placeholder:"Enter Password",required:!0,disabled:this.processing,showErrors:this.showErrors,icon:!0}}}]}]},resetPasswordFieldInfo(){return[{columns:[{fields:{email:{type:"email_input",label:"Email",placeholder:"Enter Email",required:!0,disabled:this.processing,showErrors:this.showErrors,icon:!0}}}]}]}},async mounted(){var e,s,i;this.siteUser=l.getUserInfo(),l.isLoggedIn()&&(window.location=((e=n().query)==null?void 0:e.redirectTo)===""||((s=n().query)==null?void 0:s.redirectTo)===void 0?"/account":(i=n().query)==null?void 0:i.redirectTo),this.recaptcha=I(this.tenantRecaptchaPublicKey),this.$route.query.email&&(this.loginValues.username=this.$route.query.email),this.$route.query.mode==="resetPassword"&&this.setMode("reset-password")},methods:{register(){return l.getRegistrationLink()},setMode(e){this.mode=e,e==="reset-password"?this.resetPasswordValues.email=this.loginValues.username:e==="login"&&(this.loginValues.username=this.resetPasswordValues.email)},update(e,s,i){this.mode==="login"?(this.loginValues[e]=s,this.loginErrors[e]={errorObj:i}):(this.resetPasswordValues[e]=s,this.resetPasswordErrors[e]={errorObj:i})},submitForm(){this.showErrors=L(this.mode==="login"?this.loginErrors:this.resetPasswordErrors??{})>0},async handleSubmit(){try{this.error="",this.processing=!0;let e=null;if(this.mode==="login"){const s=await this.recaptcha("siteUserLogin");if(e=await l.login(this.loginValues.username,this.loginValues.password,s),e!=null&&e.error)throw new Error(e.message)}if(this.mode==="reset-password"){const s=await this.recaptcha("siteUserResetPassword");e=await l.requestPasswordReset(this.resetPasswordValues.email,n().path,s),this.message=`You will receive an email momentarily if the account exists. Check your spam folder if you don’t see the email. Contact customerservice@${this.$ss.general.rootDomain} for further assistance.`}this.processing=!1}catch(e){this.error=e,this.processing=!1}}}},M=e=>(C("data-v-be325d77"),e=e(),R(),e),x={key:0},B={key:1},D={class:"form-content"},N={key:0,class:"preface"},W={key:1,class:"preface"},A={class:"submit"},K={class:"links"},H=M(()=>o("div",{class:"consent"},[h(" By creating an account, you are agreeing to Endeavor Business Media's "),o("a",{href:"https://www.endeavorbusinessmedia.com/endeavor-terms",target:"_blank",rel:"noopener"},"Terms of Service"),h(" and "),o("a",{href:"https://www.endeavorbusinessmedia.com/privacy-policy",target:"_blank",rel:"noopener"},"Privacy Policy")],-1));function O(e,s,i,z,r,t){const _=v,b=q,P=T,E=S;return u(),d("div",{ref:"loginForm",class:"login-form",style:g({fontFamily:e.$ss.primaryFontFamily})},[m(E,null,{default:p(()=>[o("h2",{class:"title",style:g({fontFamily:e.$ss.primaryFontFamily,color:e.$ss.baseStyles.primaryColor})},[r.mode==="login"?(u(),d("span",x,"Login to "+w(e.$ss.general.siteName),1)):c("",!0),r.mode==="reset-password"?(u(),d("span",B,"Reset Password")):c("",!0)],4),o("div",D,[m(P,{error:r.error,processing:r.processing,padding:"0",message:r.message,"qualifying-membership":r.qualifyingMembership},{default:p(()=>[o("form",{class:"form",onSubmit:s[3]||(s[3]=k((...a)=>t.handleSubmit&&t.handleSubmit(...a),["prevent"]))},[r.mode==="login"&&e.$ss.memberships.siteLoginPageText?(u(),d("div",N,[o("p",null,w(e.$ss.memberships.siteLoginPageText),1)])):c("",!0),r.mode==="reset-password"?(u(),d("div",W," Please enter your email address below to reset your password. ")):c("",!0),m(_,{"field-info":r.mode==="login"?t.loginFieldInfo:t.resetPasswordFieldInfo,"field-values":r.mode==="login"?r.loginValues:r.resetPasswordValues,onUpdate:t.update},null,8,["field-info","field-values","onUpdate"]),o("div",A,[o("div",K,[f(o("a",{onClick:s[0]||(s[0]=a=>t.setMode("reset-password"))},"Reset Password",512),[[y,r.mode==="login"]]),f(o("a",{onClick:s[1]||(s[1]=a=>t.setMode("login"))},"Return to Login",512),[[y,r.mode==="reset-password"]]),h(" | "),o("a",{class:"register",onClick:s[2]||(s[2]=(...a)=>t.register&&t.register(...a))},"Join")]),m(b,{color:e.$ss.baseStyles.primaryColor,label:r.mode==="login"?"Login":"Reset",disabled:t.submitDisabled,type:"submit",onOnClick:t.submitForm},null,8,["color","label","disabled","onOnClick"])])],32),H]),_:1},8,["error","processing","message","qualifying-membership"])])]),_:1})],4)}const j=V(U,[["render",O],["__scopeId","data-v-be325d77"]]);export{j as default};