import { Provider } from '@nestjs/common';

// Import core interfaces
import type { ILeagueMembershipRepository } from '@core/racing/domain/repositories/ILeagueMembershipRepository';
import type { IProtestRepository } from '@core/racing/domain/repositories/IProtestRepository';
import type { IRaceRepository } from '@core/racing/domain/repositories/IRaceRepository';
import type { Logger } from '@core/shared/application/Logger';

// Import concrete in-memory implementations
import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';

// Import use cases
import { ReviewProtestUseCase } from '@core/racing/application/use-cases/ReviewProtestUseCase';

// Import presenters
import { ReviewProtestPresenter } from './presenters/ReviewProtestPresenter';

// Define injection tokens
export const PROTEST_REPOSITORY_TOKEN = 'IProtestRepository';
export const RACE_REPOSITORY_TOKEN = 'IRaceRepository';
export const LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN = 'ILeagueMembershipRepository';
export const LOGGER_TOKEN = 'Logger';
export const REVIEW_PROTEST_PRESENTER_TOKEN = 'ReviewProtestPresenter';

export const ProtestsProviders: Provider[] = [
  {
    provide: LOGGER_TOKEN,
    useClass: ConsoleLogger,
  },
  {
    provide: REVIEW_PROTEST_PRESENTER_TOKEN,
    useClass: ReviewProtestPresenter,
  },
  // Use cases
  {
    provide: ReviewProtestUseCase,
    useFactory: (
      protestRepo: IProtestRepository,
      raceRepo: IRaceRepository,
      leagueMembershipRepo: ILeagueMembershipRepository,
      logger: Logger,
      output: ReviewProtestPresenter,
    ) => new ReviewProtestUseCase(protestRepo, raceRepo, leagueMembershipRepo, logger, output),
    inject: [
      PROTEST_REPOSITORY_TOKEN,
      RACE_REPOSITORY_TOKEN,
      LEAGUE_MEMBERSHIP_REPOSITORY_TOKEN,
      LOGGER_TOKEN,
      REVIEW_PROTEST_PRESENTER_TOKEN,
    ],
  },
];