/**
 * Analytics metrics view model
 * Represents metrics data for analytics
 *
 * Note: No matching generated DTO available yet
 */
export class AnalyticsMetricsViewModel {
  pageViews: number;
  uniqueVisitors: number;
  averageSessionDuration: number;
  bounceRate: number;

  constructor(data: { pageViews: number; uniqueVisitors: number; averageSessionDuration: number; bounceRate: number }) {
    this.pageViews = data.pageViews;
    this.uniqueVisitors = data.uniqueVisitors;
    this.averageSessionDuration = data.averageSessionDuration;
    this.bounceRate = data.bounceRate;
  }

  /** UI-specific: Formatted page views */
  get formattedPageViews(): string {
    return this.pageViews.toLocaleString();
  }

  /** UI-specific: Formatted unique visitors */
  get formattedUniqueVisitors(): string {
    return this.uniqueVisitors.toLocaleString();
  }

  /** UI-specific: Formatted session duration */
  get formattedSessionDuration(): string {
    const minutes = Math.floor(this.averageSessionDuration / 60);
    const seconds = Math.floor(this.averageSessionDuration % 60);
    return `${minutes}:${seconds.toString().padStart(2, '0')}`;
  }

  /** UI-specific: Formatted bounce rate */
  get formattedBounceRate(): string {
    return `${this.bounceRate.toFixed(1)}%`;
  }
}