import{Da as a,H as h,Ma as O,N as f,Q as b,U as p,da as d,dc as c,m as u,og as I,pg as v,s as m,sa as S,ua as g,x as n}from"./chunk-X3RCWQ3R.js";import{i as t}from"./chunk-SR6RTMQI.js";var x=(()=>{let s=class s{constructor(e,i){t(this,"peertubeRouter");t(this,"el");t(this,"percentLimit",70);t(this,"onItself",!1);t(this,"dataObservable");t(this,"setAngularState");t(this,"parentDisabled",!1);t(this,"nearOfBottom",new S);t(this,"decimalLimit",0);t(this,"lastCurrentBottom",-1);t(this,"scrollDownSub");t(this,"container");t(this,"checkScroll",!1);this.peertubeRouter=e,this.el=i,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 e={leading:!0,trailing:!0},i=this.onItself?this.container:window,w=m(i,"scroll").pipe(b(!0),p(200,void 0,e),u(()=>this.getScrollInfo()),h((r,l)=>r.current===l.current),f());this.scrollDownSub=w.pipe(n(({current:r})=>this.isScrollingDown(r)),n(({current:r,maximumScroll:l})=>r/l>this.decimalLimit)).subscribe(()=>{this.setAngularState&&!this.parentDisabled&&this.setScrollRouteParams(),this.nearOfBottom.emit()}),this.dataObservable&&this.dataObservable.pipe(n(r=>r.length!==0)).subscribe(()=>this.checkScroll=!0)}getScrollInfo(){return{current:this.container.scrollTop,maximumScroll:this.getMaximumScroll()}}getMaximumScroll(){let e=this.onItself?this.container.clientHeight:window.innerHeight;return this.container.scrollHeight-e}hasScroll(){return this.getMaximumScroll()>0}isScrollingDown(e){let i=this.lastCurrentBottom<e;return this.lastCurrentBottom=e,i}setScrollRouteParams(){this.peertubeRouter.addRouteSetting(I.REUSE_COMPONENT)}};t(s,"\u0275fac",function(i){return new(i||s)(a(v),a(g))}),t(s,"\u0275dir",d({type:s,selectors:[["","myInfiniteScroller",""]],inputs:{percentLimit:"percentLimit",onItself:[2,"onItself","onItself",c],dataObservable:"dataObservable",setAngularState:[2,"setAngularState","setAngularState",c],parentDisabled:"parentDisabled"},outputs:{nearOfBottom:"nearOfBottom"},standalone:!0,features:[O]}));let o=s;return o})();export{x as a};
/**i18n:3d16453f213eb5db982e7e7dd90631843ac5d3f860726a614777c3e9e3f9b57e*/
//# sourceMappingURL=chunk-VD3IIXV7.js.map
