import{a as h,b as l}from"./chunk-2AVGQ2MQ.js";var d=class{constructor(t,e,r,a,o,c,u){this.datePipe=t,this.toastr=e,this.cdr=r,this.router=a,this.sharedService=o,this.TranslateService=c,this.dataManagementService=u,this.list=[],this.sortedList=[],this.sortDirection=!1,this.searchUser="",this.filteredList=[],this.noUsersFound=!1,this.showNavigation=!1,this.next="",this.previous="",this.last="",this.first="",this.currentpageCount=0,this.totalpageCount=0,this.sortColumn="userName",this.selectedRadio="",this.parseResponse=s=>i=>{this.list=i.body.data,this.list=i.body.data.map(n=>l(h({},n),{userNameEncoded:btoa(n.userName)})),this.filteredList=[...this.list],this.sortTable(this.sortColumn),i.body.metadata?(this.showNavigation=!0,this.next=i.body.metadata.links?.next,this.previous=i.body.metadata.links?.previous,this.last=i.body.metadata.links?.last,this.first=i.body.metadata.links?.first,this.currentpageCount=i.body.metadata.pageNumber,this.totalpageCount=Math.ceil(i.body.metadata.totalCount/i.body.metadata.recordsPerPage)):this.showNavigation=!1,s?s():this.cdr.detectChanges()},this.parseError=s=>{switch(s.status){case 400:console.error("Bad Request: ",s.message);break;case 401:console.error("Unauthorized: ",s.message),this.toastr.error(this.TranslateService.instant("Token expired, navigating to logout page."),this.TranslateService.instant("Error")),setTimeout(()=>{this.router.navigate(["/logout"])},3e3);break;case 403:console.error("Forbidden: ",s.message);break;case 404:console.error("Not Found: ",s.message);break;case 447:this.toastr.info(this.TranslateService.instant("Changes were not saved.  The User is under Legal hold. Please contact your Administrator."),this.TranslateService.instant("Info"));break;case 500:console.error("Internal Server Error: ",s.message);break;case 503:console.error("Internal Server Error: ",s.message);break;default:console.error("Unknown Error: ",s.message);break}}}getFormattedDate(t){return this.datePipe.transform(t,"dd-MMM-yyyy HH:mm:ss")||""}sendMeTo(t,e){e!=""&&this.sharedService.setData("currentPolicyName",e),this.router.navigate([t])}getAll(t,e){return this.sortedList=[],this.sortDirection=!1,this.dataManagementService.getAll(t).subscribe(this.parseResponse(e),this.parseError)}getAll_Navigate(t,e){this.sortedList=[],this.sortDirection=!1,this.dataManagementService.getAll_Navigate(t,e).subscribe(this.parseResponse(),this.parseError)}sortTable(t){this.sortColumn===t?this.sortDirection=!this.sortDirection:(this.sortColumn=t,this.sortDirection=!0),this.applySorting()}applySorting(){this.sortedList=this.filteredList.sort((t,e)=>{let r=t[this.sortColumn]||"",a=e[this.sortColumn]||"";typeof r=="string"&&(r=r.toLowerCase()),typeof a=="string"&&(a=a.toLowerCase());let o=0;return r>a?o=1:r<a&&(o=-1),this.sortDirection?o:-o})}getCaretClass(t){return this.sortColumn===t?this.sortDirection?"fa fa-caret-up":"fa fa-caret-down":""}trackByUser(t,e){return e.userName}filterUsers(){this.searchUser=this.searchUser.trim();let t=this.searchUser.toLowerCase();this.filteredList=this.list.filter(e=>e.userName?.toLowerCase().includes(t)||e.displayName?.toLowerCase().includes(t)||e.emailId?.toLowerCase().includes(t)),this.noUsersFound=this.filteredList.length===0,this.applySorting()}};export{d as a};
