import{s as m}from"./chunk-VA2ZAQUO.js";import{I as o,Y as r,ea as n,f as s,ja as c}from"./chunk-F5OOQG77.js";var f=(()=>{class i{constructor(t){this.router=t,this.timeoutDuration=10*60*1e3,this.activityEvents=["mousemove","keydown","click","touchstart"],this.onDestroy$=new s,this.isActive=!1}initialize(t){t&&(this.timeoutDuration=t),this.start()}start(){this.isActive||(this.isActive=!0,this.resetTimeout(),this.registerActivityEvents())}stop(){this.isActive&&(this.isActive=!1,clearTimeout(this.timeoutTimer),this.removeActivityEvents())}setTimeoutDuration(t){this.timeoutDuration=t,this.isActive&&this.resetTimeout()}resetTimeout(){this.isActive&&(clearTimeout(this.timeoutTimer),this.timeoutTimer=setTimeout(()=>this.handleTimeout(),this.timeoutDuration))}registerActivityEvents(){let t=new s;this.activityEvents.forEach(e=>window.addEventListener(e,()=>t.next())),t.pipe(o(500),r(this.onDestroy$)).subscribe(()=>this.resetTimeout())}removeActivityEvents(){this.activityEvents.forEach(t=>window.removeEventListener(t,()=>{}))}handleTimeout(){this.router.navigate(["/logout"])}ngOnDestroy(){clearTimeout(this.timeoutTimer),this.onDestroy$.next(),this.onDestroy$.complete(),this.removeActivityEvents()}static{this.\u0275fac=function(e){return new(e||i)(c(m))}}static{this.\u0275prov=n({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();export{f as a};
