import{a,h as l}from"./chunk-HQJI5M5I.js";import{a as e}from"./chunk-PTMJTNEU.js";import{$ as h,G as d,X as r,Yd as g,ea as o,q as u}from"./chunk-PCDQIHDN.js";var R=(()=>{let i=class i{constructor(){this.http=o(l),this.translationService=o(g)}set language(t){localStorage.setItem(i.DEFAULT_LOCALE_STORAGE_KEY,t),this.translationService.setLocale({language:t})}get language(){return localStorage.getItem(i.DEFAULT_LOCALE_STORAGE_KEY)??"en"}getCurrentAccountData(){return this.http.get(`${e.endpoints.api}/account/current`).pipe(d(1),r(t=>this.currentUser=t))}updateCurrentAccountUser(t){let n=new a().set("content-type","application/json");return this.http.post(`${e.endpoints.api}/account/current`,t,{headers:n}).pipe(r(()=>this.language=t.language))}getUsers(){return this.http.get(`${e.endpoints.api}/account/list`)}getTenantUsers(t){return this.http.get(`${e.endpoints.api}/account/list`)}getUser(t){return this.http.get(`${e.endpoints.api}/account/${t}`)}createUser(t){let n=new a().set("content-type","application/json");return this.http.post(`${e.endpoints.api}/account`,t,{headers:n})}validateUserUpdate(t){return this.http.put(`${e.endpoints.api}/account/${t.id}/validate`,t)}updateUser(t){let n=new a().set("content-type","application/json");return this.http.put(`${e.endpoints.api}/account/${t.id}`,t,{headers:n})}deleteUser(t){return this.http.delete(`${e.endpoints.api}/account/${t}`)}getTenants(t=!0){return this.http.get(`${e.endpoints.api}/tenant`).pipe(u(n=>{let c=n.findIndex(s=>s.id===-1);return c>=0&&(n[c].name=this.translationService.translate("Unassigned")),t?n:n.filter(s=>s.id!==-1)}))}getTenant(t,n=!0){return this.http.get(`${e.endpoints.api}/tenant/${t}`)}createTenant(t){let n=new a().set("content-type","application/json");return this.http.post(`${e.endpoints.api}/tenant`,t,{headers:n})}updateTenant(t){let n=new a().set("content-type","application/json");return this.http.put(`${e.endpoints.api}/tenant/${t.id}`,t,{headers:n})}deleteTenant(t){return this.http.delete(`${e.endpoints.api}/tenant/${t}`)}getRole(t){return this.http.get(`${e.endpoints.api}/account/role/${t}`)}getDefaultRole(){return this.http.get(`${e.endpoints.api}/account/role/default`)}getUserRoles(){return this.http.get(`${e.endpoints.api}/account/userroles`)}getRoles(){return this.http.get(`${e.endpoints.api}/account/role`)}createRole(t){let n=new a().set("content-type","application/json");return this.http.post(`${e.endpoints.api}/account/role`,t,{headers:n})}validateRoleUpdate(t){return this.http.put(`${e.endpoints.api}/account/role/${t.id}/validate`,t)}updateRole(t){let n=new a().set("content-type","application/json");return this.http.put(`${e.endpoints.api}/account/role/${t.id}`,t,{headers:n})}deleteRole(t){return this.http.delete(`${e.endpoints.api}/account/role/${t}`)}};i.DEFAULT_LOCALE_STORAGE_KEY="defaultLocale",i.\u0275fac=function(n){return new(n||i)},i.\u0275prov=h({token:i,factory:i.\u0275fac});let p=i;return p})();export{R as a};
