import{I as b,O as d,R as p,Ua as w,V as S,ba as c,n as h,pc as u,sa as g,sg as D,t as f,ta as r,tg as v,ua as O,y as s}from"./chunk-3MFSOWAK.js";import{i as a}from"./chunk-ASXIZBWV.js";var k=(()=>{let i=class i{peertubeRouter=c(v);el=c(O);percentLimit=r(70);onItself=r(!1,{transform:u});dataObservable=r(void 0);setAngularState=r(void 0,{transform:u});parentDisabled=r(!1);nearOfBottom=g();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},n=this.onItself()?this.container:window,I=f(n,"scroll").pipe(p(!0),S(200,void 0,t),h(()=>this.getScrollInfo()),b((e,l)=>e.current===l.current),d());this.scrollDownSub=I.pipe(s(({current:e})=>this.isScrollingDown(e)),s(({current:e,maximumScroll:l})=>e/l>this.decimalLimit)).subscribe(()=>{this.setAngularState()&&!this.parentDisabled()&&this.setScrollRouteParams(),this.nearOfBottom.emit()});let m=this.dataObservable();m&&m.pipe(s(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 n=this.lastCurrentBottom<t;return this.lastCurrentBottom=t,n}setScrollRouteParams(){this.peertubeRouter.addRouteSetting(D.REUSE_COMPONENT)}};a(i,"\u0275fac",function(n){return new(n||i)}),a(i,"\u0275dir",w({type:i,selectors:[["","myInfiniteScroller",""]],inputs:{percentLimit:[1,"percentLimit"],onItself:[1,"onItself"],dataObservable:[1,"dataObservable"],setAngularState:[1,"setAngularState"],parentDisabled:[1,"parentDisabled"]},outputs:{nearOfBottom:"nearOfBottom"}}));let o=i;return o})();export{k as a};
/**i18n:a80de7963c3a1ee38e5afb7317b8dafa5dd6a0c8b3d465be96b90b317d6167e1*/
//# sourceMappingURL=chunk-2EXI5TT3.js.map
