import{G as a}from"./chunk-I5MYHHJE.js";import{Z as r,ba as o}from"./chunk-CKLXM6EG.js";var l=class t{constructor(e){this.router=e;this.loadUserFromStorage()}user=null;redirectUrl=null;loadUserFromStorage(){let e=localStorage.getItem("currentUser");e&&(this.user=JSON.parse(e))}setUser(e){this.user=e,localStorage.setItem("currentUser",JSON.stringify(e)),localStorage.setItem("token",e.token),this.redirectUrl?(this.router.navigateByUrl(this.redirectUrl),this.redirectUrl=null):this.router.navigate(["/"])}isLoggedIn(){let e=localStorage.getItem("token");return!!this.getToken()}isPermissionsExist(){let e=localStorage.getItem("encrypted");return console.log(!!e,"!!encrypted"),!!e}getCurrentUser(){return this.user??{roles:[]}}getToken(){return localStorage.getItem("token")}clearUser(){this.user=null,localStorage.removeItem("currentUser"),localStorage.removeItem("token"),localStorage.removeItem("full_name"),localStorage.removeItem("employee_id"),localStorage.removeItem("warehouse_id"),localStorage.removeItem("role"),localStorage.removeItem("token"),this.router.navigate(["/auth/login"])}static \u0275fac=function(i){return new(i||t)(o(a))};static \u0275prov=r({token:t,factory:t.\u0275fac,providedIn:"root"})};export{l as a};
