import{Fc as v,H as h,M as f,Ma as S,P as b,T as d,aa as g,n as m,ra as p,s as u,x as n,xc as O,yc as o}from"./chunk-THW6YIIG.js";import{i as a}from"./chunk-PTJGHD3V.js";var M=(()=>{let i=class i{el=g(p);percentLimit=o(70);onItself=o(!1,{transform:v});dataObservable=o(void 0);nearOfBottom=O();decimalLimit=0;lastCurrentBottom;scrollDownSub;container;checkScroll=!1;constructor(){this.decimalLimit=this.percentLimit()/100}ngAfterViewChecked(){this.checkScroll&&(this.checkScroll=!1,setTimeout(()=>{this.hasScroll()===!1&&this.nearOfBottom.emit()}))}ngOnInit(){this.initialize()}ngOnDestroy(){this.scrollDownSub&&this.scrollDownSub.unsubscribe()}initialize(){this.container=this.onItself()?this.el.nativeElement:document.documentElement;let t={leading:!0,trailing:!0},r=this.onItself()?this.container:window,w=u(r,"scroll").pipe(b(!0),d(200,void 0,t),m(()=>this.getScrollInfo()),h((e,l)=>e.current===l.current),f());this.scrollDownSub=w.pipe(n(({current:e})=>this.isScrollingDown(e)),n(({current:e,maximumScroll:l})=>e/l>this.decimalLimit)).subscribe(()=>{this.nearOfBottom.emit()});let c=this.dataObservable();c&&c.pipe(n(e=>e.length!==0)).subscribe(()=>this.checkScroll=!0)}getScrollInfo(){return{current:this.container.scrollTop,maximumScroll:this.getMaximumScroll()}}getMaximumScroll(){let t=this.onItself()?this.container.clientHeight:window.innerHeight;return this.container.scrollHeight-t}hasScroll(){return this.getMaximumScroll()>0}isScrollingDown(t){if(this.lastCurrentBottom===void 0)return this.lastCurrentBottom=t,!1;let r=this.lastCurrentBottom<t;return this.lastCurrentBottom=t,r}};a(i,"\u0275fac",function(r){return new(r||i)}),a(i,"\u0275dir",S({type:i,selectors:[["","myInfiniteScroller",""]],inputs:{percentLimit:[1,"percentLimit"],onItself:[1,"onItself"],dataObservable:[1,"dataObservable"]},outputs:{nearOfBottom:"nearOfBottom"}}));let s=i;return s})();export{M as a};
/**i18n:90f1dd82a779b57eddc91ef20913c88eecaa9632bba8ac04ad50f47ae2b82df7*/
//# sourceMappingURL=chunk-WO7G3OWE.js.map
