import{Fc as v,H as u,M as f,Na as S,P as d,T as b,aa as g,n as m,s as h,ua as p,wc as O,x as n,xc as o}from"./chunk-4SQIIPGX.js";import{i as c}from"./chunk-PVXKA76F.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=h(r,"scroll").pipe(d(!0),b(200,void 0,t),m(()=>this.getScrollInfo()),u((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 a=this.dataObservable();a&&a.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}};c(i,"\u0275fac",function(r){return new(r||i)}),c(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:c36872b108225e22fdb1f8f6f623d1b8958602fe2a49f49507ac6a06e578d8cc*/
//# sourceMappingURL=chunk-ZDGEXYWW.js.map
