import {$,o as oe}from'./chunk-maPEFEVk.js';import {B,Q}from'./chunk-C6WdsICs.js';import {J,a6 as pi,a5 as fh,cI as p,j8 as da,c as tS,ev as ne,cN as g,bP as he,ay as df,ah as ot,j9 as Se,aa as ye,ew as Ie,ad as ce}from'./main-WUGO6e7n.js';var L,y=J(()=>{pi();fh();p();da();tS();B();ne();$();L=(()=>{class r extends g{constructor(e,t,i){super(),this.roleService=e,this.userService=t,this.applicationService=i,this.grantAccessSelectionSelectionSource=new he,this.grantAccessSelectionSelection=this.grantAccessSelectionSelectionSource.asObservable();}select(e){this.roleService.getAllRoleSummaries().pipe(df(t=>(e.allRoles=t||[],this.applicationService.getAllSummaries())),df(t=>(e.allApplications=t,this.userService.getUsersList())),ot(t=>e.showReadOnlyUsers??!0?t:t.filter(i=>i.userTypeValue!==Se.ReadOnly)),ot(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)(ye(Q),ye(Ie),ye(oe))};}static{this.\u0275prov=ce({token:r,factory:r.\u0275fac,providedIn:"root"});}}return r})();});export{L,y};