import{A as e}from"./p-2f569553.js";import{g as t,s as a,r as n}from"./p-5d409601.js";const r={AUTH_USER_LOCALSTORAGE:"CurrentUser",userManagement:{defaultAdminUserName:"admin"},localization:{defaultLocalizationSourceName:"Test"},authorization:{encrptedAuthTokenName:"enc_auth_token"}};class s{static getInstance(){return s.instance||(s.instance=new s),s.instance}async getToken(){let e=await t(r.AUTH_USER_LOCALSTORAGE);return e&&e.JWToken&&new Date(e.ExpiresOn).getTime()>(new Date).getTime()?e.JWToken:null}async getAuthUser(){let e=await t(r.AUTH_USER_LOCALSTORAGE);return e&&e.JWToken&&new Date(e.ExpiresOn).getTime()>(new Date).getTime()?e:null}getAuthUserSync(){let e=JSON.parse(localStorage.getItem(r.AUTH_USER_LOCALSTORAGE));return e&&e.JWToken&&new Date(e.ExpiresOn).getTime()>(new Date).getTime()?e:null}getTokenSync(){let e=JSON.parse(localStorage.getItem(r.AUTH_USER_LOCALSTORAGE));return e&&e.JWToken&&new Date(e.ExpiresOn).getTime()>(new Date).getTime()?e.JWToken:null}isAuthenticated(){try{if(this.getTokenSync())return!0}catch(e){return!1}}async getTokenExpiry(){let e=await t(r.AUTH_USER_LOCALSTORAGE);if(!e)return 0;let a=0;return e.ExpiresOn&&(a=new Date(e.ExpiresOn).getTime()-(new Date).getTime()),Math.max(0,a)}async saveAuthUser(t){e.state.authUser=Object.assign({},t),e.state.isAuthenticated=!0,await a(r.AUTH_USER_LOCALSTORAGE,t)}async removeAuthUser(){e.state.authUser=null,e.state.isAuthenticated=!1,await n(r.AUTH_USER_LOCALSTORAGE)}}export{r as A,s as T}