import{Dc as O,Ec as o,I as u,Mc as v,N as f,Pa as S,Q as d,U as b,ba as g,o as m,t as h,ua as p,y as n}from"./chunk-RKSLYOIW.js";import{i as c}from"./chunk-QQ7SJNXU.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:5a85df092a135682c90bae008e37ec28160e04e5f445e29af2927333ba91ffa1*/
//# sourceMappingURL=chunk-SW3KSKPN.js.map
