import{c as C}from"./chunk-CFFHWVA5.js";import{C as d,T as l,V as m,Y as f,aa as h,ea as p,k as s,ka as g,m as u,w as r}from"./chunk-UNHECMG2.js";var o="default",F=(()=>{class n{constructor(){this.action$=new s,this.loadingCounts$=d(this.action$.pipe(f((t,{action:e,context:i})=>{switch(e){case"increment":return t[i]=(t[i]||0)+1,t;case"decrement":return t[i]=Math.max(0,(t[i]||0)-1),t;default:return t}},{}),h({})),{connector:()=>new u(1)}),this.loading$=this.loading(),this.loadingCountsSub=this.loadingCounts$.connect()}ngOnDestroy(){this.loadingCountsSub.unsubscribe()}loading(t=o){return this.loadingCounts$.pipe(r(e=>e[t]),r(y),l())}load(t,e=o){let i=typeof e=="string"?e:e.context||o,b=typeof e=="object"&&e.stopOnFirstValue||!1,a=this.decrementLoadingCount(i),c=!0;function $(){c&&(a(),c=!1)}return t.pipe(C(this.incrementLoadingCount(i)),b?p($):m(a))}incrementLoadingCount(t){return()=>this.action$.next({action:"increment",context:t})}decrementLoadingCount(t){return()=>this.action$.next({action:"decrement",context:t})}static{this.\u0275fac=function(e){return new(e||n)}}static{this.\u0275prov=g({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();function y(n){return(n||0)!==0}export{F as a};
