import{a as f,b}from"./chunk-FLPECHOR.js";import{a as u,b as R}from"./chunk-KFE3NGXT.js";import{c as S,d as x}from"./chunk-V36WA7UR.js";import{Kb as m,Lb as v}from"./chunk-2GUKPKKM.js";import{a as n,b as A}from"./chunk-3AUKOF45.js";import{Sd as g,g as d,ha as o,na as I,oa as U,ta as p,x as a,ya as l}from"./chunk-XJKQ67XR.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};
