function signinCustomer(){console.log("Ids3 Host: "+ct.utls.url.identityHostUrl());mgr.signinRedirect().then(function(){console.log("signinRedirect then")}).catch(function(n){console.log(n)})}function signoutCustomer(){mgr.signoutRedirect().then(function(n){console.log("signoutRedirect then",n)}).catch(function(n){console.log(n)})}function endSigninMainWindow(){var t=window.location.hash,n=t.replace("#/id_token","#id_token");n=window.location.protocol+"//"+window.location.host+n;mgr.signinRedirectCallback({data:n}).then(function(n){postSigninRedirect(n)}).catch(function(n){console.log(n)})}function postSigninRedirect(n){if(console.log("postSigninRedirect",n),storeCustomer(n),n.profile.contactmarketid===undefined||n.profile.contactuserid===undefined)ct.customer.clientStore.setItem(ct.customer.storageKeys.CustomerFirstTimeUser,!0),window.location.replace("/login?type=firstTimeUser");else{ct.customer.clientStore.removeItem(ct.customer.storageKeys.CustomerFirstTimeUser);var t=ct.customer.clientStore.getItem(ct.customer.storageKeys.PostLoginRedirectUrl);ct.customer.clientStore.removeItem(ct.customer.storageKeys.PostLoginRedirectUrl);t===undefined||t===null?window.location.replace("/account/dashboard"):window.location.replace(decodeURIComponent(t))}}var settings={authority:ct.utls.url.identityHostUrl(),client_id:"ContactPortal",redirect_uri:window.location.protocol+"//"+window.location.host+"/login",silent_redirect_uri:window.location.protocol+"//"+window.location.host+"/login",post_logout_redirect_uri:window.location.protocol+"//"+window.location.host,response_type:"id_token token",scope:ct.utls.url.identityContactPortalScope(),monitorSession:!0,filterProtocolClaims:!0,loadUserInfo:!0,ui_locales:ct.utls.getMarketId()},mgr;Oidc.Log.logger=console;Oidc.Log.level=Oidc.Log.ERROR;mgr=new Oidc.UserManager(settings);mgr.events.addAccessTokenExpiring(function(){console.log("token expiring")});mgr.events.addAccessTokenExpired(function(){console.log("token expired");$(window).off("beforeunload");removeCustomerLocalStorage();signoutCustomer()});mgr.events.addSilentRenewError(function(n){console.log("silent renew error",n.message)});mgr.events.addUserLoaded(function(n){console.log("user loaded",n);mgr.getUser().then(function(){console.log("getUser loaded user after userLoaded event fired")})});mgr.events.addUserUnloaded(function(n){console.log("user unloaded"+n)});mgr.events.addUserSignedOut(function(n){console.log("user signed out"+n);signinCustomer()});window.location.href.indexOf("#")>=0&&window.location.href.indexOf("agentportal")<0&&endSigninMainWindow()