{"version":3,"sources":["login.js"],"names":["signin","signout","header","renderUserStatus","desktopBtnLogin","helpers","trimTrailingSlash","pathname","saveReturnUrl","sessionStorage","RETURN_PATH_KEY","window","href","removeSavedUrl","hydrateReturnUrl","savedReturnUrl","getItem","origin","searchParams","URLSearchParams","location","search","logoutConfirmed","get","loginCancelled","redirectUrl","URL","includes","toString","_window$Oidc","Oidc","UserManager","oidc_config","login","authority","client_id","redirect_uri","oidcInstance","store","localStorage","response_type","post_logout_redirect_uri","scope","userStore","WebStorageStateStore","automaticSilentRenew","silent_redirect_uri","url","currentUrl","await","signinRedirectCallback","catch","clearStaleState","async","signinRedirect","extraQueryParams","lng","lang","getUser","signinSilent","Promise","resolve","then","signoutRedirect","document","querySelector","loggedIn","classList","add","remove","mobileBtnLogin","addEventListener","mobileBtnLogout","events","addUserSignedOut","error","desktopBtnLogout","removeUser","user","expired"],"mappings":"AAAA,CAAA,iBACC,IAgFMA,EAEJC,EAiBIC,EAEAC,EAWAC,EAAAA,EAhHAC,EAAU,CACdC,kBADc,SAAAC,GAEf,OAAAA,EAAOA,SAAA,GAAP,EAAOA,EAAyBA,MAAA,EAAA,CAAkB,CAA3C,EAAAA,CAFQ,EAIdC,cAJc,WAKfC,eAAAA,QAAAC,EAAAC,OAAwCA,SAAAC,IAAxCH,CALe,EAOdI,eAPc,WAQfJ,eAAAA,WAAAC,CAAAD,CARe,EAUdK,iBAVc,WAWf,IAAMC,EAAiBN,eAAeO,QAAQN,CAAvBD,GAA2CE,OAAOM,OACnEC,EAAe,IAAIC,gBAAgBR,OAAOS,SAASC,MAApC,EAEfC,EAA+C,SAA7BJ,EAAaK,IAAI,MAAjBL,EAClBM,EAA+C,kBAA9BN,EAAaK,IAAI,OAAjBL,EAIvB,GAFAb,EAAAA,eAAAA,EAEAU,EAAIA,SAAA,QAAJ,IAAIO,GAAsCA,GAIxC,OAHMG,EAAc,IAAIC,IAAIf,OAAOM,MAAf,GACRV,SAAWQ,EAAeY,SAAS,KAAxBZ,E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AAA,EAANuD,QAAMvD,IAaV2E,EAAKC,QAVC5E,EAAiB,CAAA,CAAjBA,EAORA,KAAAA,EAAOA,CAAAA,CAAP,EA9EDE,EAAAS,iBAAA,CATD,CA3DD,EAAA","file":"login.min.js","sourcesContent":["(async function () {\n\tconst helpers = {\n\t trimTrailingSlash(pathname) {\n\t\treturn pathname.endsWith('/') ? pathname.slice(0, -1) : pathname;\n\t },\n\t saveReturnUrl() {\n\t\tsessionStorage.setItem(RETURN_PATH_KEY, window.location.href);\n\t },\n\t removeSavedUrl() {\n\t\tsessionStorage.removeItem(RETURN_PATH_KEY);\n\t },\n\t hydrateReturnUrl() {\n\t\tconst savedReturnUrl = sessionStorage.getItem(RETURN_PATH_KEY) || window.origin;\n\t\tconst searchParams = new URLSearchParams(window.location.search);\n \n\t\tconst logoutConfirmed = searchParams.get('done') === 'true';\n\t\tconst loginCancelled = searchParams.get('error') === 'access_denied';\n \n\t\thelpers.removeSavedUrl();\n \n\t\tif (savedReturnUrl.includes('/ecare') && (logoutConfirmed || loginCancelled)) {\n\t\t const redirectUrl = new URL(window.origin);\n\t\t redirectUrl.pathname = savedReturnUrl.includes('/ar') ? '/ar' : '';\n \n\t\t return (window.location = redirectUrl.toString());\n\t\t}\n \n\t\twindow.location = savedReturnUrl;\n\t },\n\t};\n \n\tconst RETURN_PATH_KEY = 'corpp:return-path';\n \n\tconst { UserManager, WebStorageStateStore } = window.Oidc;\n\tconst { oidc_config } = window.login;\n \n\tconst oidcInstance = new UserManager({\n\t authority: oidc_config.authority,\n\t client_id: oidc_config.client_id,\n\t redirect_uri: oidc_config.redirect_uri,\n\t response_type: 'code',\n\t scope: 'openid CHANNEL_WEB',\n\t userStore: new WebStorageStateStore({ store: window.localStorage }),\n\t post_logout_redirect_uri: oidc_config.post_logout_redirect_uri,\n\t automaticSilentRenew: true,\n\t silent_redirect_uri: oidc_config.silent_redirect_uri,\n\t loadUserInfo: false,\n\t staleStateAge: 3600,\n\t stopCheckSessionOnError: false,\n\t // accessTokenExpiringNotificationTime: 1790, // fast silent refresh\n\t});\n \n\t// #######################\n\t// ### handle auth endings\n\t// #######################\n \n\tconst url = new URL(window.location.href);\n\tconst currentUrl = helpers.trimTrailingSlash(`${url.origin}${url.pathname}`);\n \n\tif (currentUrl === oidc_config.silent_redirect_uri) {\n\t await oidcInstance.signinSilentCallback();\n\t return;\n\t}\n \n\tif (currentUrl === oidc_config.redirect_uri) {\n\t await oidcInstance.signinRedirectCallback().catch(() => {});\n\t helpers.hydrateReturnUrl();\n\t return;\n\t}\n \n\tif (currentUrl === oidc_config.post_logout_redirect_uri) {\n\t helpers.hydrateReturnUrl();\n\t return;\n\t}\n \n\t// #######################\n\t// ### setup DOM listeners\n\t// #######################\n \n\toidcInstance.clearStaleState();\n \n\tconst signin = async () => {\n\t helpers.saveReturnUrl();\n\t await oidcInstance.signinRedirect({ extraQueryParams: { lng: oidc_config.lang } });\n\t};\n \n\tconst signout = async () => {\n\t helpers.saveReturnUrl();\n\t await oidcInstance\n\t\t.getUser()\n\t\t.then(user => {\n\t\t return user.expired ? oidcInstance.signinSilent() : Promise.resolve();\n\t\t})\n\t\t.then(() => oidcInstance.signoutRedirect({ extraQueryParams: { lng: oidc_config.lang } }))\n\t\t.catch(() => {\n\t\t renderUserStatus(false);\n\t\t helpers.removeSavedUrl();\n\t\t});\n\t};\n \n\tconst header = document.querySelector('header#main-header');\n \n\tconst renderUserStatus = loggedIn => {\n\t if (loggedIn) {\n\t\treturn header.classList.add('logged');\n\t }\n \n\t header.classList.remove('logged');\n\t};\n \n\tconst mobileBtnLogin = header.querySelector('button#login-mobile');\n\tconst mobileBtnLogout = header.querySelector('button#logout-mobile');\n \n\tconst desktopBtnLogin = header.querySelector('button#login-desktop');\n\tconst desktopBtnLogout = header.querySelector('button#logout-desktop');\n \n\tmobileBtnLogin.addEventListener('click', () => signin());\n\tmobileBtnLogout.addEventListener('click', () => signout());\n \n\tdesktopBtnLogin.addEventListener('click', () => signin());\n\tdesktopBtnLogout.addEventListener('click', () => signout());\n \n\toidcInstance.events.addUserSignedOut(async () => {\n\t oidcInstance\n\t\t.signinSilent()\n\t\t.then(() => renderUserStatus(true))\n\t\t.catch(async error => {\n\t\t if (error && error.error === 'login_required') {\n\t\t\tawait oidcInstance.removeUser();\n\t\t\treturn renderUserStatus(false);\n\t\t }\n\t\t});\n\t});\n \n\toidcInstance\n\t .signinSilent()\n\t .then(() => renderUserStatus(true))\n\t .catch(error => {\n\t\tif (error && error.error === 'login_required') {\n\t\t return renderUserStatus(false);\n\t\t}\n\t });\n \n\tconst user = await oidcInstance.getUser();\n \n\tif (!user) {\n\t return renderUserStatus(false);\n\t}\n \n\tif (user.expired) {\n\t return renderUserStatus(false);\n\t}\n \n\trenderUserStatus(true);\n })();"]}