import { AdminApiClient } from './admin/AdminApiClient';
import { AnalyticsApiClient } from './analytics/AnalyticsApiClient';
import { AuthApiClient } from './auth/AuthApiClient';
import { DashboardApiClient } from './dashboard/DashboardApiClient';
import { DriversApiClient } from './drivers/DriversApiClient';
import { LeaguesApiClient } from './leagues/LeaguesApiClient';
import { MediaApiClient } from './media/MediaApiClient';
import { PaymentsApiClient } from './payments/PaymentsApiClient';
import { PenaltiesApiClient } from './penalties/PenaltiesApiClient';
import { PolicyApiClient } from './policy/PolicyApiClient';
import { ProtestsApiClient } from './protests/ProtestsApiClient';
import { RacesApiClient } from './races/RacesApiClient';
import { SponsorsApiClient } from './sponsors/SponsorsApiClient';
import { TeamsApiClient } from './teams/TeamsApiClient';
import { WalletsApiClient } from './wallets/WalletsApiClient';
import { ErrorReporter } from '../interfaces/ErrorReporter';
import { Logger } from '../interfaces/Logger';

import { ConsoleLogger } from '../infrastructure/logging/ConsoleLogger';

export class ApiClient {
  public readonly admin: AdminApiClient;
  public readonly analytics: AnalyticsApiClient;
  public readonly auth: AuthApiClient;
  public readonly dashboard: DashboardApiClient;
  public readonly drivers: DriversApiClient;
  public readonly leagues: LeaguesApiClient;
  public readonly media: MediaApiClient;
  public readonly payments: PaymentsApiClient;
  public readonly penalties: PenaltiesApiClient;
  public readonly policy: PolicyApiClient;
  public readonly protests: ProtestsApiClient;
  public readonly races: RacesApiClient;
  public readonly sponsors: SponsorsApiClient;
  public readonly teams: TeamsApiClient;
  public readonly wallets: WalletsApiClient;

  constructor(baseUrl: string) {
    // Default implementations for logger and error reporter if needed
    const logger: Logger = new ConsoleLogger();
    const errorReporter: ErrorReporter = { report: (error) => console.error(error) };

    this.admin = new AdminApiClient(baseUrl, errorReporter, logger);
    this.analytics = new AnalyticsApiClient(baseUrl, errorReporter, logger);
    this.auth = new AuthApiClient(baseUrl, errorReporter, logger);
    this.dashboard = new DashboardApiClient(baseUrl, errorReporter, logger);
    this.drivers = new DriversApiClient(baseUrl, errorReporter, logger);
    this.leagues = new LeaguesApiClient(baseUrl, errorReporter, logger);
    this.media = new MediaApiClient(baseUrl, errorReporter, logger);
    this.payments = new PaymentsApiClient(baseUrl, errorReporter, logger);
    this.penalties = new PenaltiesApiClient(baseUrl, errorReporter, logger);
    this.policy = new PolicyApiClient(baseUrl, errorReporter, logger);
    this.protests = new ProtestsApiClient(baseUrl, errorReporter, logger);
    this.races = new RacesApiClient(baseUrl, errorReporter, logger);
    this.sponsors = new SponsorsApiClient(baseUrl, errorReporter, logger);
    this.teams = new TeamsApiClient(baseUrl, errorReporter, logger);
    this.wallets = new WalletsApiClient(baseUrl, errorReporter, logger);
  }
}

// Export a default instance if needed, but apiClient.ts seems to handle it
export const api = new ApiClient(process.env.NEXT_PUBLIC_API_URL || '');
