import { Component, HostListener } from '@angular/core';
import { Router } from '@angular/router';


@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css'],
    standalone: false
})
export class AppComponent {
  title = 'dns-ui';
  constructor(private router: Router) {
    //console.log('Available Routes:', this.router.config);
  }

  // @HostListener('window:beforeunload', ['$event'])
  // onBeforeUnload(event: Event) {
  //   //localStorage.clear(); // Clear session storage
  //   //this.navigateToSessionTimeOut()
    
  // }
  @HostListener('window:beforeunload', ['$event'])
  onBeforeUnload(event: Event) {
    //localStorage.clear(); // Clear session storage
    //this.navigateToSessionTimeOut()    
  }

  private isTabClosing = false;
  @HostListener('window:visibilitychange')
  onVisibilityChange() {
    // if (document.visibilityState === 'hidden') {
    //   this.isTabClosing = true;
    //    localStorage.clear();
    //    sessionStorage.clear();
    // }
  }

  navigateToSessionTimeOut(){
    this.router.navigateByUrl("/session-timeout");
  }
}
