import { Component, signal, inject } from '@angular/core';
import { RouterOutlet, Router, NavigationEnd } from '@angular/router';
import {provideIcons} from "@ng-icons/core";
import { filter } from 'rxjs/operators';
import {cssMenu} from "@ng-icons/css.gg";
import { OpenPanelService } from '@core/services/openpanel.service';

@Component({
  selector: 'app-root',
  imports: [RouterOutlet],
  templateUrl: './app.html',
  styleUrl: './app.scss',
  viewProviders: [provideIcons({cssMenu})]
})
export class App {
  protected readonly title = signal('hurler-webdesign-saas');
  private readonly router = inject(Router);
  private readonly opService = inject(OpenPanelService);

  constructor() {
    // Optional: Manuelles Tracking von Seitenaufrufen, falls nicht automatisch in OpenPanelService konfiguriert
    this.router.events.pipe(
      filter(event => event instanceof NavigationEnd)
    ).subscribe((event) => {
      this.opService.trackScreenView((event as NavigationEnd).urlAfterRedirects);
    });
  }
}
