import{H as f,Lh as v,M as b,P as p,T as d,Ua as O,aa as a,n as h,rc as w,s as u,sa as S,ta as n,ua as g,x as o}from"./chunk-GM43ZGTR.js";import{i as c}from"./chunk-SLIYHYWC.js";var E=(()=>{let i=class i{peertubeRouter=a(v);el=a(g);percentLimit=n(70);onItself=n(!1,{transform:w});dataObservable=n(void 0);nearOfBottom=S();decimalLimit=0;lastCurrentBottom=-1;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,I=u(r,"scroll").pipe(p(!0),d(200,void 0,t),h(()=>this.getScrollInfo()),f((e,s)=>e.current===s.current),b());this.scrollDownSub=I.pipe(o(({current:e})=>this.isScrollingDown(e)),o(({current:e,maximumScroll:s})=>e/s>this.decimalLimit)).subscribe(()=>{this.nearOfBottom.emit()});let m=this.dataObservable();m&&m.pipe(o(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){let r=this.lastCurrentBottom<t;return this.lastCurrentBottom=t,r}};c(i,"\u0275fac",function(r){return new(r||i)}),c(i,"\u0275dir",O({type:i,selectors:[["","myInfiniteScroller",""]],inputs:{percentLimit:[1,"percentLimit"],onItself:[1,"onItself"],dataObservable:[1,"dataObservable"]},outputs:{nearOfBottom:"nearOfBottom"}}));let l=i;return l})();export{E as a};
/**i18n:aa38438cfc6bb6877c9985433629bf5f310ba8cfd6183982ad2c0c8f601d3935*/
//# sourceMappingURL=chunk-NQRZPYWN.js.map
