!function WP$Authentication$LoginController$definition(){$$WP.Utilities.guaranteeExistence($$WP,"Authentication.Login.Controllers");var e=$$WP.Strings.getNamespace("authentication.login"),o=function LoginController(e,o){if($$WPUtil.IsNullOrEmpty(e)||(this._autoFocusInDataTile=e),$$WPUtil.IsNullOrEmpty(o)||(this._captchaRequired=o),this.proxify("_registerHandlers","_checkLogin","_cancelLogin","_storageAccessRequestFailed","_storageAccessRequestSucceeded","_launchLoginPopup","_adjustMainContentToFormFactor","_hideForm","_showLoginLaunchButton","_showNoCookiesError","_showForm","_isFormAllowed","_isHostedCrossDomain","_isLoginWidget","_shouldSetFocusOnLogin","_highlightLoginFields"),this._registerHandlers(),this._isFormAllowed()){var t,n=document.getElementById("loginForm");if(n&&(this._shouldSetFocusOnLogin()&&n.Login.focus(),$afe.select(".alert").hasClass("hidden")||setTimeout((function(){var e=$afe.select("#errorMessage");(e.safeAttr("role","alert"),WP.DOM.Browser.isSafari)&&(e.remove(),$afe.select("#loginErrorMessage").children().eq(0).safeAppend(e));WP.DOM.Browser.isIE&&$afe.select("#errorMessage").focus()}),500)),this._captchaRequired)t=$afe.select("#invisibleCaptchaContainer"),this.__captcha=new $$WP.Captcha(t),this.__captcha.Render();this._appendDeviceIdToHiddenForm(),this._appendPostLoginUrlToHiddenForm(),this._adjustMainContentToFormFactor(),this._isLoginWidget()&&this._isHostedCrossDomain()&&WP.DOM.Browser.isFirefox&&$$WPUtil.canWriteCookies()&&"1"!=getCookie("LoginWidget",!0)&&this._showLoginLaunchButton()}};o.prototype={_autoFocusInDataTile:!0,_captchaRequired:!1,$SubmitButton:null,$BackButton:null,__captcha:null,_registerHandlers:function(){var e=$afe.select("body");e.on("successfulStorageRequest",this._storageAccessRequestSucceeded),e.on("failedStorageRequest",this._storageAccessRequestFailed),e.on("showLoginLaunchButton",this._showLoginLaunchButton),e.on("showForm",this._showForm),this.$noCookiesButton=$afe.select("#noCookiesButton"),this.$noCookiesButton.click(this._launchLoginPopup),this.$SubmitButton=$afe.select("#submit"),this.$SubmitButton.click(this._checkLogin),this.$BackButton=$afe.select("#back"),this.$BackButton&&this.$BackButton.click(this._cancelLogin),this.$SubmitButton.safeAttr("disabled",!1),$afe.jq(window).on("resize",this._adjustMainContentToFormFactor)},_storageAccessRequestSucceeded:function(){WP.DOM.Browser.isSafari&&document.referrer!==window.location.href&&window.location.reload(!0)},_hideForm:function(){$afe.select("#sidebar").addClass("hidden"),$afe.select("#footer").addClass("hidden"),$afe.select(".login").remove(),$afe.select(".signup").addClass("hidden")},_showNoCookiesError:function(){this._hideForm(),$afe.select("#noCookiesError").show()},_showForm:function(){$afe.select("#sidebar").removeClass("hidden"),$afe.select("#footer").removeClass("hidden"),$afe.select(".login").removeClass("hidden"),$afe.select(".signup").removeClass("hidden"),$afe.select("#noCookies").hide()},_showLoginLaunchButton:function(){this._hideForm(),$afe.select("#noCookies").show()},_storageAccessRequestFailed:function(){"function"==typeof document.requestStorageAccess&&$afe.select("#noCookies").is(":hidden")&&$afe.select("#noCookiesButtonContainer").safePrepend(e.getString("CookieAccessRequestFailed")),this._showLoginLaunchButton()},_isFormAllowed:function(){if(self!==top){if(WP.DOM.Browser.isIE)return this._showLoginLaunchButton(),!1}else if(!$$WPUtil.canWriteCookies())return this._showNoCookiesError(),!1;return!0},_isHostedCrossDomain:function(){try{return window.top.location.hostname.toLowerCase()!==window.location.hostname.toLowerCase()}catch(e){return!0}},_isLoginWidget:function(){return-1!==document.location.pathname.toLowerCase().indexOf("authentication/login/loginwidget")},_shouldSetFocusOnLogin:function(){if(""!==loginForm.Login.value)return!1;if(""!==loginForm.Password.value)return!1;if(!0!==this._autoFocusInDataTile&&window.top!==window)return!1;if(0!==window.location.hash.length)return!1;if($afe.jq(window).width()>1300){if(window.location.search.includes("option=faq"))return!1;if(window.location.search.includes("option=hlthprivacy"))return!1;if(window.location.search.includes("option=termsandconditions"))return!1;if(window.location.search.includes("option=epiccopyright"))return!1}return!0},_launchLoginPopup:function(){var e=document.location.protocol+"//"+document.location.hostname+makeLink("Authentication/Login");openWindow(e,"_blank","width=800,height=600,resizable,status,scrollbars",!1)},_checkLogin:function(e){var o,t,n,i,s;if(this._clearErrorMessage(),(s=$afe.select("#loginForm")[0])&&(o=$afe.select("#Login")[0],t=$afe.select("#Password")[0],(n=o.value)&&(n=n.trim()),i=t.value,!this._highlightLoginFields(o,t,n,i,s)))return!1;if(null!=o&&turnOffHighlight(o),null!=t&&turnOffHighlight(t),e.preventDefault(),this._captchaRequired){this.__captcha.GetResponse(function(e){this._appendCaptchaToHiddenForm(e),this._submitLogin(n,i)}.bind(this))}else this._submitLogin(n,i);return!0},_highlightLoginFields:function(o,t,n,i,s){return""==n&&""==i?(null!=o&&turnOnHighlight(o),null!=t&&turnOnHighlight(t),this._addErrorMessage(e.getString("NoUsernameOrPasswordError")),s.Login.focus(),!1):""==n?(null!=o&&turnOnHighlight(o),null!=t&&turnOffHighlight(t),this._addErrorMessage(e.getString("NoUsernameError")),s.Login.focus(),!1):""!=i||(null!=t&&turnOnHighlight(t),null!=o&&turnOffHighlight(o),this._addErrorMessage(e.getString("NoPasswordError")),s.Password.focus(),!1)},_submitLogin:function(e,o){var t={Type:"StandardLogin",Credentials:{Username:WP.Utils.b64EncodeUnicode(e),Password:WP.Utils.b64EncodeUnicode(o)}};loginJSON=JSON.stringify(t),this._appendElementToLoginSubmission("LoginInfo",loginJSON),$loginForm=$afe.select("#actualLogin"),$loginForm.submit(),disableButtonAndShowSpinner(this.$SubmitButton)},_appendCaptchaToHiddenForm:function(e){"hCaptcha"===this.__captcha.CaptchaType?this._appendElementToLoginSubmission("h-captcha-response",e):this._appendElementToLoginSubmission("g-recaptcha-response",e)},_appendDeviceIdToHiddenForm:function(){try{var e=localStorage.getItem(getDeviceIdKey());this._appendElementToLoginSubmission("DeviceId",e)}catch(e){this._showLoginLaunchButton()}},_appendPostLoginUrlToHiddenForm:function(){var e=$$WPUtil.queryString("postLoginUrl");this._appendElementToLoginSubmission("postLoginUrl",e)},_appendElementToLoginSubmission:function(e,o){var t=document.createElement("input"),n=$afe.jq(t);n.safeAttr("type","hidden"),n.safeAttr("name",e),n.safeAttr("value",o),$afe.select("#actualLogin").safeAppend(t)},_cancelLogin:function(e){return e.preventDefault(),$$WP.Utilities.TryRedirect(makeLink("Authentication/Reauthenticate/Cancel")),!0},_clearErrorMessage:function(){$afe.select("#loginErrorMessage .alert.card").addClass("hidden")},_addErrorMessage:function(e){var o=$afe.select("#loginErrorMessage .alert.card"),t=$afe.select("#errorMessage");(t.text(e),o.removeClass("hidden"),o.removeAttr("role"),o.safeAttr("role","alert"),WP.DOM.Browser.isSafari)&&(t.remove(),$afe.select("#loginErrorMessage").children().eq(0).safeAppend(t))},_adjustMainContentToFormFactor:function(){var e=$afe.select(".mainLoginContent.beforeLoginFields"),o=$afe.select(".mainLoginContent.afterLoginFields");$$WP.Utilities.UI.IsMediumSmallScreen()?this._copyMainContent(e,o):this._copyMainContent(o,e)},_copyMainContent:function(e,o){if(e&&o){var t=e.children(".mainLoginContentBody"),n=o.children(".mainLoginContentBody");t&&t.length>0&&n&&n.length<1&&o.safeAppend(t[0])}}},$$WP.Authentication.Login.Controllers.LoginController=o,o.extend($$WP.Controllers.Controller,"WP$Authentication$Login$Controllers$LoginController")}();