!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={4341:(e,t,r)=>{r.d(t,{CLEAR_SESSION_STATE:()=>a,LOGOUT_USER:()=>n,RECEIVE_USER_INFO:()=>s,SESSION_STATE_STATUS_UNCHANGED:()=>u,SET_LOGGED_USER:()=>o,UPDATE_SESSION_STATE_STATUS:()=>i,UPDATE_USER_INFO:()=>l});r(8779),r(4656),r(4054),r(6793),r(9893);const o="SET_LOGGED_USER",n="LOGOUT_USER",s="RECEIVE_USER_INFO",a="CLEAR_SESSION_STATE",i="UPDATE_SESSION_STATE_STATUS",u="unchanged",l="UPDATE_USER_INFO"},9893:(e,t,r)=>{r.d(t,{clearAuthInfo:()=>c,getIdToken:()=>S,getOAuth2ClientId:()=>p,getOAuth2IDPBaseUrl:()=>E});var o=r(6793);r(8362),r(2691);const n=require("browser-tabs-lock");var s=r.n(n);const a=require("js-cookie");var i=r.n(a);r(6530),r(3856),r(4341);require("crypto-js/sha256"),require("crypto-js/enc-base64url"),require("crypto-js/enc-hex"),"undefined"!=typeof window&&(window.crypto||window.msCrypto);new(s());const u="authInfo",l="idToken",d=()=>{try{let e=(0,o.getFromLocalStorage)(u,!1);return e?JSON.parse(e):null}catch(e){return null}},c=()=>{"undefined"!=typeof window&&((0,o.removeFromLocalStorage)(u),i().remove(l))},S=()=>{if("undefined"!=typeof window){const e=d();return e?e.idToken:null}return null},p=()=>"undefined"!=typeof window?window.OAUTH2_CLIENT_ID:null,E=()=>"undefined"!=typeof window?window.IDP_BASE_URL:null},4054:(e,t,r)=>{r(3838),r(2691),r(6530),r(271),r(4656),r(6793),r(4341),r(9893);const o=e=>t=>({type:e,payload:t});o("RESET_LOADING"),o("START_LOADING"),o("STOP_LOADING")},6793:(e,t,r)=>{r.d(t,{getFromLocalStorage:()=>o,removeFromLocalStorage:()=>n});r(8362),r(6530);const o=(e,t)=>{if("undefined"!=typeof window){let r=window.localStorage.getItem(e);return t&&(console.log(`getFromLocalStorage removing key ${e}`),n(e)),r}return null},n=e=>{"undefined"!=typeof window&&window.localStorage.removeItem(e)}},8779:e=>{e.exports=require("@babel/runtime/helpers/defineProperty")},3838:e=>{e.exports=require("@babel/runtime/helpers/objectWithoutProperties")},4656:e=>{e.exports=require("i18n-react/dist/i18n-react")},3856:e=>{e.exports=require("idtoken-verifier")},8362:e=>{e.exports=require("moment-timezone")},2691:e=>{e.exports=require("superagent/lib/client")},271:e=>{e.exports=require("sweetalert2")},6530:e=>{e.exports=require("urijs")}},t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o](s,s.exports,r),s.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var o={};return(()=>{r.r(o),r.d(o,{loggedUserReducer:()=>c});var e=r(8779),t=r.n(e),n=r(4341),s=r(3856),a=r.n(s),i=r(9893);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function l(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?u(Object(o),!0).forEach((function(r){t()(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):u(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}const d={isLoggedUser:!1,member:null,sessionState:null,backUrl:null,sessionStateStatus:n.SESSION_STATE_STATUS_UNCHANGED},c=(e=d,t)=>{const{type:r,payload:o}=t;let s=(0,i.getOAuth2IDPBaseUrl)(),u=(0,i.getOAuth2ClientId)();switch(r){case n.SET_LOGGED_USER:{let{sessionState:r}=t.payload;return l(l({},e),{},{isLoggedUser:!0,sessionState:r,backUrl:null,sessionStateStatus:n.SESSION_STATE_STATUS_UNCHANGED})}case n.UPDATE_SESSION_STATE_STATUS:{let{sessionStateStatus:r}=t.payload;return l(l({},e),{},{sessionStateStatus:r})}case n.CLEAR_SESSION_STATE:return(0,i.clearAuthInfo)(),l(l({},e),{},{isLoggedUser:!1,sessionState:null,backUrl:null});case n.LOGOUT_USER:return(0,i.clearAuthInfo)(),l(l({},d),{},{backUrl:o.backUrl});case n.RECEIVE_USER_INFO:{let{response:r}=t.payload;if(""!==s&&""!==u){let e=new(a())({issuer:s,audience:u}).decode((0,i.getIdToken)()),t=e.payload.groups||[],o=e.payload.address||{};t=t.map((e=>({id:e.id,title:e.name,description:e.name,code:e.slug,created:e.created_at,last_edited:e.updated_at}))),r=l(l({},r),{},{groups:[...r.groups,...t],address:o})}return l(l({},e),{},{member:r})}case n.UPDATE_USER_INFO:{let r=t.payload;return l(l({},e),{},{member:r})}default:return e}}})(),o})()));
//# sourceMappingURL=reducers.js.map