import{e as v,f as V}from"./chunk-EKRRPOZR.js";import{Wj as f,Xj as y,a as d,b as z}from"./chunk-2GUKPKKM.js";import{g as m,h as j}from"./chunk-CUIDVWNH.js";import{b as S,c as w}from"./chunk-IBUDDWQO.js";import{Sd as M,ka as c,oa as I,ta as l,x as t,ya as n}from"./chunk-XJKQ67XR.js";import{a,b as p,e as h}from"./chunk-SZAW6ZBW.js";var u,A=h(()=>{u=class{constructor(o){this.subscriptionCount=0,this.subscriberCount=0,this.subscribers=[],this.subscriptions=[],o&&(this.id=o.id,this.name=o.name,this.subscribers=o.subscribers||[],this.subscriptions=o.subscriptions||[],this.subscriberCount=this.subscribers.length,this.subscriptionCount=this.subscriptions.length)}}});var O,x=h(()=>{z();I();A();M();w();j();V();y();O=(()=>{class r extends d{constructor(s,e,i,b){super(s,e),this.subscriberFactoryService=i,this.assetServices=b}get(s){return this.assetServices.GetSubscriberGroup(s).pipe(c(e=>this.handleGetApiResult(e)),t(e=>this.returnWhenSuccessful(e,()=>this.normalizeSubscribersInGroup(e.data))))}getAll(){return this.assetServices.GetAllSubscriberGroups().pipe(c(s=>this.handleGetApiResult(s)),t(s=>this.returnWhenSuccessful(s,()=>this.normalizeSubscribersInGroups(s.data))))}getAllAsViewModel(){return this.getAll().pipe(t(s=>s?this.toViewModels(this.normalizeSubscribersInGroups(s)):null))}save(s){let e=this.toSaveModel(s);return this.assetServices.SaveSubscriberGroup(e).pipe(c(i=>this.handleSaveApiResult(i)),t(i=>this.returnWhenSuccessful(i,()=>i.data)))}delete(s){return this.assetServices.DeleteSubscriberGroup(s).pipe(c(e=>this.handleDeleteApiResult(e)),t(e=>this.isSuccessful(e)))}normalizeSubscribersInGroup(s){return p(a({},s),{subscribers:this.subscriberFactoryService.toSubscribers(s.subscribers)})}normalizeSubscribersInGroups(s){return(s||[]).map(e=>this.normalizeSubscribersInGroup(e))}toViewModel(s){return new u(s)}toViewModels(s){return(s||[]).map(e=>this.toViewModel(e))}toSaveModel(s){let e=(i,b,G)=>G.indexOf(i)===b;return p(a({},s),{subscribers:[],subscriptions:[],subscriberIds:s.subscriberIds.filter(e).filter(i=>!!i)})}static{this.\u0275fac=function(e){return new(e||r)(n(S),n(m),n(v),n(f))}}static{this.\u0275prov=l({token:r,factory:r.\u0275fac,providedIn:"root"})}}return r})()});export{O as a,x as b};
