import{e as v,f as V}from"./chunk-KOYZ2E2W.js";import{Aj as f,Bj as y,s as d,t as z}from"./chunk-EAIMSMGJ.js";import{g as m,h as j}from"./chunk-AIHAZUSZ.js";import{b as S,c as w}from"./chunk-IOINCEV4.js";import{Gd as M,ka as c,na as I,sa as l,x as t,xa as n}from"./chunk-JSJB5BKT.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};
