import{a as f,b}from"./chunk-TFPQAHWC.js";import{a as u,b as R}from"./chunk-HYRET37P.js";import{c as S,d as x}from"./chunk-K36RKQI4.js";import{Gb as m,Hb as v}from"./chunk-XBRJZCAD.js";import{a as n,b as A}from"./chunk-TS62PHQY.js";import{Gd as g,g as d,ha as o,ma as I,na as U,sa as p,x as a,xa as l}from"./chunk-JSJB5BKT.js";import{e as h}from"./chunk-SZAW6ZBW.js";var L,y=h(()=>{I();U();A();v();g();b();x();R();L=(()=>{class r extends n{constructor(e,t,i){super(),this.roleService=e,this.userService=t,this.applicationService=i,this.grantAccessSelectionSelectionSource=new d,this.grantAccessSelectionSelection=this.grantAccessSelectionSelectionSource.asObservable()}select(e){this.roleService.getAllRoleSummaries().pipe(o(t=>(e.allRoles=t||[],this.applicationService.getAllSummaries())),o(t=>(e.allApplications=t,this.userService.getUsersList())),a(t=>e.showReadOnlyUsers??!0?t:t.filter(i=>i.userTypeValue!==m.ReadOnly)),a(t=>e.excludedUserIds&&e.excludedUserIds.length>0?t.filter(i=>!e.excludedUserIds.find(c=>c===i.id)):t)).subscribe(t=>{e.allUsers=t||[],e.permission&&(e.allSelected=e.permission.allowedUsersAndRoles),e.allSelected&&(e.users=this.getSelectedUserIds(e),e.roles=this.getSelectedRoleIds(e),e.applications=this.getSelectedApplicationIds(e)),this.grantAccessSelectionSelectionSource.next(e)})}consolidate(e){let t=e.roles.map(s=>s.id),i=e.users.map(s=>s.id),c=e.applications.map(s=>s.id);return i.concat(t).concat(c)}getSelectedUserIds(e){return e.allUsers.filter(i=>e.allSelected.indexOf(i.id)>-1).map(i=>i.id)}getSelectedRoleIds(e){return e.allRoles.filter(i=>e.allSelected.indexOf(i.id)>-1).map(i=>i.id)}getSelectedApplicationIds(e){return e.allApplications.filter(i=>e.allSelected.indexOf(i.id)>-1).map(i=>i.id)}static{this.\u0275fac=function(t){return new(t||r)(l(f),l(S),l(u))}}static{this.\u0275prov=p({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})()});export{L as a,y as b};
