import{a as F,d as u}from"./chunk-CFFHWVA5.js";import{a as G}from"./chunk-CQICYL3N.js";import{a as s}from"./chunk-C7V3KKPV.js";import{A as $,i as P}from"./chunk-2YE7XEKS.js";import{$d as o,P as V,Pd as R,Qd as U,Rd as h,Sd as j,Vd as a,Wd as x,Xd as m,Zd as A,_ as S,_d as l,aa as C,ba as n,ea as O,ee as I,fe as _,ie as v,k as T,ka as g,ne as d,pa as f,w as c}from"./chunk-UNHECMG2.js";function M(e){var r=Object.create(Object.getPrototypeOf(e));return Object.assign(r,e),r}function k(e,r,t){t===void 0&&(t=e.name);var i=M(e);return i.validate=r,i.decode=function(p){return r(p,_(i))},i.name=t,i}function y(e,r,t){return t===void 0&&(t="withFallback("+e.name+")"),k(e,function(i,p){return R(function(){return h(r)})(e.validate(i,p))},t)}var q=o({Key:a,Value:a}),D=o({Id:a,Settings:I(l(q))}),b=d.pipe(o({mail:y(m,!1),gui:y(m,!1),phoneMobile:y(m,!1)})),E=new j("NotificationTypesInactive",e=>Array.isArray(e)&&e.every(r=>typeof r=="string"),(e,r)=>typeof e=="string"?h(e.split(";").filter(Boolean)):U(e,r),e=>e.join(";")),z=(function(e){return e.Grid="grid",e.List="list",e})(z||{}),w=d.pipe(o({presenceControl:A({grid:null,list:null})})),Q=o({eventId:v(x),group:v(G.props.Key)}),N=d.pipe(I(l(Q))),Y=o({AccessInfo:o({Roles:l(a),Permissions:l(a)})});var L=(()=>{class e extends F{constructor(){let t=f(P),i=f($);super(t,i,D,"UserSettings")}getUserSettingsCst(t){return this.http.get(`${this.baseUrl}/Cst`,{params:t}).pipe(n(s(this.codec)))}updateUserSettingsCst(t){return this.http.patch(`${this.baseUrl}/Cst`,t)}getAccessInfo(){return this.http.get(`${this.baseUrl}/?expand=AccessInfo`).pipe(n(s(Y)),c(({AccessInfo:t})=>t))}static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275prov=g({token:e,factory:e.\u0275fac,providedIn:"root"})}}return e})();var Z=100,H="presenceControlViewMode",W="presenceControlGroupView",B="notification",J="notificationTypesInactive",Tt=(()=>{class e{constructor(){this.settingsRestService=f(L),this.refetch$=new T,this.settings$=this.refetch$.pipe(C(null),V(Z),n(()=>this.settingsRestService.getUserSettingsCst()),c(t=>t.Settings),S(1)),this.accessInfo$=this.settingsRestService.getAccessInfo().pipe(S(1))}refetch(){this.refetch$.next()}getSetting(t){return this.settings$.pipe(c(i=>i.find(p=>p.Key===t)?.Value??null))}saveSetting(t,i){return this.settingsRestService.updateUserSettingsCst(this.buildSettings(t,i)).pipe(O(()=>this.refetch$.next()))}getPresenceControlViewMode(){return this.getSetting(H).pipe(u('{"presenceControl":"grid"}'),n(s(w)),c(({presenceControl:t})=>t))}savePresenceControlViewMode(t){return this.saveSetting(H,w.encode({presenceControl:t}))}getPresenceControlGroupView(){return this.getSetting(W).pipe(u("[]"),n(s(N)))}savePresenceControlGroupView(t){return this.saveSetting(W,N.encode(t))}getNotificationChannels(){return this.getSetting(B).pipe(u("{}"),n(s(b)))}saveNotificationChannels(t){return this.saveSetting(B,b.encode(t))}getNotificationTypesInactive(){return this.getSetting(J).pipe(u(""),n(s(E)))}saveNotificationTypesInactive(t){return this.saveSetting(J,E.encode(t))}getRolesAndPermissions(){return this.accessInfo$.pipe(c(({Roles:t,Permissions:i})=>[...t,...i]),C(null))}buildSettings(t,i){return{Id:"Cst",Settings:[{Key:t,Value:i}]}}static{this.\u0275fac=function(i){return new(i||e)}}static{this.\u0275prov=g({token:e,factory:e.\u0275fac,providedIn:"root"})}}return e})();export{z as a,Tt as b};
