import { ComparisonRepository } from '../repositories/comparison.repository';

export class ComparisonService {
  constructor(private readonly repository: ComparisonRepository) {}

  getItems(): string[] {
    return this.repository.getAll();
  }

  addItem(productId: string): boolean {
    if (this.repository.count() >= 6) return false;
    
    this.repository.add(productId);
    return true;
  }

  removeItem(productId: string): void {
    this.repository.remove(productId);
  }

  clearItems(): void {
    this.repository.clear();
  }

  isInComparison(productId: string): boolean {
    return this.repository.has(productId);
  }

  canAddMore(): boolean {
    return this.repository.count() < 6;
  }
}
