(window.webpackJsonp=window.webpackJsonp||[]).push([[46],{381:function(e,t,s){"use strict";s.r(t);var o={name:"CustomerLogin",components:{Captcha:function(){return s.e(24).then(s.bind(null,380))},MessageBox:function(){return s.e(119).then(s.bind(null,358))},ForgotPassword:function(){return s.e(105).then(s.bind(null,445))},ButtonToggle:function(){return s.e(23).then(s.bind(null,392))}},props:{referer:{type:String,default:""},easyPay:{type:Object,default:null}},data:function(){return{username:"",password:"",verifying:!1,invalidCaptcha:!1,showPassword:!1,errorMessage:"",showForgotPassword:!1,signInFailReason:""}},computed:{logoUrl:function(){return this.$root.isMangoWeb||"images/mango_web_logo.png"!==this.$root.settings.logoUrl?this.$root.router.getUrl(this.$root.settings.logoUrl):this.$root.router.getUrl("images/mango_pay_logo.png")},useCaptcha:function(){return this.$root.settings.allowCaptcha},badLogin:function(){return this.password.length<3||this.username.length<3}},mounted:function(){this.$root.settings.isDemo&&(this.password=this.username="arsguest"),null!==this.$root.helper.getCookie("mw-keepsignedin")&&"0"===this.$root.helper.getCookie("mw-keepsignedin")&&this.loginCheck()},methods:{goToActivation:function(){this.$emit("showActivation")},loginWithCaptcha:function(){var e=this;if(!this.badLogin){if(this.signInFailReason="",!this.useCaptcha)return this.loginCheck();if(""!==this.$refs.signInCaptcha.text){this.verifying=!0,this.$emit("verifying",!0);var t=setInterval((function(){e.$refs.signInCaptcha.checking||(clearInterval(t),e.$refs.signInCaptcha.isValid?e.loginCheck():(e.verifying=!1,e.$emit("verifying",!1),e.invalidCaptcha=!0))}),1e3)}else this.invalidCaptcha=!0}},loginCheck:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.verifying=!0,this.$emit("verifying",!0),this.$root.api.put("authenticate",{username:t||this.username,password:s||this.password}).then((function(t){var s=t.code,o=t.data;0===s?(e.$root.$emit("generic-sign-in"),e.login(o)):-902===s?e.errorMessage=e.lang.errorMessage902:(e.verifying=!1,e.$emit("verifying",!1),e.signInFailReason=o)}))},login:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.$root.$emit("sign-in");var s=function(){if(e.$root.isMangoWeb)if(null!==e.easyPay)e.$root.router.go("QuickPay",{existingInvoiceInformation:e.easyPay});else{e.$root.topMenu.getExpiringCreditCards(!0);var o=t&&t.referer?e.$root.router.getPageName(t.referer):e.referer?e.referer:null;null===o&&(o=e.$root.helper.getLandingPage()),t&&t.referer||e.referer||"Dashboard"!==o&&!e.$root.settings.defaultToDashboard?e.$root.router.go(o):e.$root.settings.dashboardAccount||e.$root.settings.dashboardBilling||e.$root.settings.dashboardDelivery||e.$root.settings.dashboardFavorites?e.$root.router.go("Dashboard",{showQuickLink:!0}):e.$root.router.go("MyDeliveries")}else e.$root.router.go("Payments");e.$root.$off("deliveryStopsLoaded",s)};this.$root.$on("deliveryStopsLoaded",s),this.$root.loadIntitialData()},keepSignedInChanged:function(e){this.$root.helper.setCookie("mw-keepsignedin",e)},errorMessageClick:function(){location.reload(!0)},guestView:function(){this.$root.router.go("Orders",{guest:!0})}}},n=s(0),a=Object(n.a)(o,(function(){var e=this,t=e._self._c;return t("div",{attrs:{id:"mw-customer-login"}},[t("div",{directives:[{name:"show",rawName:"v-show",value:!e.verifying,expression:"!verifying"}],staticClass:"mw-cl-form"},[t("div",{staticClass:"mw-cl-logo"},[t("img",{attrs:{src:e.logoUrl}})]),e._v(" "),t("h5",[e._v(e._s(e.lang.welcomeBack))]),e._v(" "),t("div",{staticClass:"mw-customer-username"},[t("label",[e._v(e._s(e.lang.username))]),e._v(" "),t("input",{directives:[{name:"model",rawName:"v-model",value:e.username,expression:"username"}],ref:"username",staticClass:"form-control mw-customer-login-input",attrs:{type:"text",placeholder:e.lang.enterUsername},domProps:{value:e.username},on:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.loginWithCaptcha.apply(null,arguments)},input:function(t){t.target.composing||(e.username=t.target.value)}}}),e._v(" "),t("label",[e._v(e._s(e.lang.password))])]),e._v(" "),t("div",{staticClass:"mw-customer-login-password"},["checkbox"==(e.showPassword?"text":"password")?t("input",{directives:[{name:"model",rawName:"v-model",value:e.password,expression:"password"}],staticClass:"form-control mw-customer-login-input",attrs:{placeholder:e.lang.enterPassword,type:"checkbox"},domProps:{checked:Array.isArray(e.password)?e._i(e.password,null)>-1:e.password},on:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.loginWithCaptcha.apply(null,arguments)},change:function(t){var s=e.password,o=t.target,n=!!o.checked;if(Array.isArray(s)){var a=e._i(s,null);o.checked?a<0&&(e.password=s.concat([null])):a>-1&&(e.password=s.slice(0,a).concat(s.slice(a+1)))}else e.password=n}}}):"radio"==(e.showPassword?"text":"password")?t("input",{directives:[{name:"model",rawName:"v-model",value:e.password,expression:"password"}],staticClass:"form-control mw-customer-login-input",attrs:{placeholder:e.lang.enterPassword,type:"radio"},domProps:{checked:e._q(e.password,null)},on:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.loginWithCaptcha.apply(null,arguments)},change:function(t){e.password=null}}}):t("input",{directives:[{name:"model",rawName:"v-model",value:e.password,expression:"password"}],staticClass:"form-control mw-customer-login-input",attrs:{placeholder:e.lang.enterPassword,type:e.showPassword?"text":"password"},domProps:{value:e.password},on:{keyup:function(t){return!t.type.indexOf("key")&&e._k(t.keyCode,"enter",13,t.key,"Enter")?null:e.loginWithCaptcha.apply(null,arguments)},input:function(t){t.target.composing||(e.password=t.target.value)}}}),e._v(" "),t("span",{staticClass:"mw-clickable input-group-text",attrs:{title:e.showPassword?e.lang.hidePassword:e.lang.showPassword},on:{click:function(t){e.showPassword=!e.showPassword}}},[t("i",{class:["fas",e.showPassword?"fa-eye":"fa-eye-slash"]})])]),e._v(" "),t("div",{staticClass:"mw-customer-keep-signed-in"},[t("label",{staticClass:"mw-customer-button-toggle-label"},[e._v(e._s(e.lang.keepMeSignedIn))]),e._v(" "),t("button-toggle",{staticClass:"mw-customer-button-toggle",attrs:{buttons:[e.lang.yesButton,e.lang.noButton],default:null===e.$root.helper.getCookie("mw-keepsignedin")?1:parseInt(e.$root.helper.getCookie("mw-keepsignedin"))},on:{click:e.keepSignedInChanged}})],1),e._v(" "),e.useCaptcha?t("div",{staticClass:"mw-customer-login-captcha-section"},[t("label",[e._v(e._s(e.lang.captcha))]),e._v(" "),t("captcha",{ref:"signInCaptcha",staticClass:"mw-customer-login-captcha",attrs:{name:"signIn"},on:{editingCaptcha:function(t){e.invalidCaptcha=!1},keyup_enter:e.loginWithCaptcha}})],1):e._e(),e._v(" "),e.invalidCaptcha?t("label",{staticClass:"mw-cl-error"},[e._v(e._s(e.lang.invalidCaptcha))]):e._e(),e._v(" "),e.signInFailReason.length>0?t("label",{staticClass:"mw-cl-error"},[e._v(e._s(e.signInFailReason))]):e._e(),e._v(" "),t("div",{staticClass:"mw-customer-login-footer"},[t("div",{staticClass:"mw-customer-login-forgot-password"},[t("button",{staticClass:"btn btn-link",on:{click:function(t){e.showForgotPassword=!0}}},[e._v(e._s(e.lang.forgotYourUsernamePassword))])]),e._v(" "),t("div",{staticClass:"mw-customer-login-sign-in"},[t("button",{staticClass:"mw-cl-sign-in btn btn-lg",attrs:{disabled:e.badLogin,type:"button"},on:{click:e.loginWithCaptcha}},[e._v(e._s(e.lang.signIn))])])])]),e._v(" "),t("div",{directives:[{name:"show",rawName:"v-show",value:e.verifying,expression:"verifying"}],staticClass:"mw-loading"},[t("label",[e._v(e._s(e.lang.verifyingIdentity))]),e._v(" "),e._m(0)]),e._v(" "),e.errorMessage?t("message-box",{attrs:{text:e.errorMessage,"first-button":"OK",image:"error"},on:{click:e.errorMessageClick}}):e._e(),e._v(" "),e.showForgotPassword?t("forgot-password",{on:{showActivation:e.goToActivation,close:function(t){e.showForgotPassword=!1}}}):e._e()],1)}),[function(){var e=this._self._c;return e("div",{staticClass:"progress"},[e("div",{staticClass:"progress-bar",attrs:{role:"progressbar"}})])}],!1,null,null,null);t.default=a.exports}}]);