import{Ag as v,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,t as f,ta as r,ua as O,y as s,zg as D}from"./chunk-XD25PYOU.js";import{i as a}from"./chunk-FPVLB6PA.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:fc817608a00477e18624cf8be5badc6c9afae12f0946c7c1548c95cf79bd0e7b*/
//# sourceMappingURL=chunk-THURTBNN.js.map
