export interface LeagueData {
  id: string;
  name: string;
  description: string | null;
  visibility: 'public' | 'private';
  ownerId: string;
  status: 'active' | 'pending' | 'archived';
  createdAt: Date;
  updatedAt: Date;
  
  // Structure
  maxDrivers: number | null;
  approvalRequired: boolean;
  lateJoinAllowed: boolean;
  
  // Schedule
  raceFrequency: string | null;
  raceDay: string | null;
  raceTime: string | null;
  tracks: string[] | null;
  
  // Scoring
  scoringSystem: any | null;
  bonusPointsEnabled: boolean;
  penaltiesEnabled: boolean;
  
  // Stewarding
  protestsEnabled: boolean;
  appealsEnabled: boolean;
  stewardTeam: string[] | null;
  
  // Tags
  gameType: string | null;
  skillLevel: string | null;
  category: string | null;
  tags: string[] | null;
}

export interface LeagueStats {
  leagueId: string;
  memberCount: number;
  raceCount: number;
  sponsorCount: number;
  prizePool: number;
  rating: number;
  reviewCount: number;
}

export interface LeagueFinancials {
  leagueId: string;
  walletBalance: number;
  totalRevenue: number;
  totalFees: number;
  pendingPayouts: number;
  netBalance: number;
}

export interface LeagueStewardingMetrics {
  leagueId: string;
  averageResolutionTime: number;
  averageProtestResolutionTime: number;
  averagePenaltyAppealSuccessRate: number;
  averageProtestSuccessRate: number;
  averageStewardingActionSuccessRate: number;
}

export interface LeaguePerformanceMetrics {
  leagueId: string;
  averageLapTime: number;
  averageFieldSize: number;
  averageIncidentCount: number;
  averagePenaltyCount: number;
  averageProtestCount: number;
  averageStewardingActionCount: number;
}

export interface LeagueRatingMetrics {
  leagueId: string;
  overallRating: number;
  ratingTrend: number;
  rankTrend: number;
  pointsTrend: number;
  winRateTrend: number;
  podiumRateTrend: number;
  dnfRateTrend: number;
}

export interface LeagueTrendMetrics {
  leagueId: string;
  incidentRateTrend: number;
  penaltyRateTrend: number;
  protestRateTrend: number;
  stewardingActionRateTrend: number;
  stewardingTimeTrend: number;
  protestResolutionTimeTrend: number;
}

export interface LeagueSuccessRateMetrics {
  leagueId: string;
  penaltyAppealSuccessRate: number;
  protestSuccessRate: number;
  stewardingActionSuccessRate: number;
  stewardingActionAppealSuccessRate: number;
  stewardingActionPenaltySuccessRate: number;
  stewardingActionProtestSuccessRate: number;
}

export interface LeagueResolutionTimeMetrics {
  leagueId: string;
  averageStewardingTime: number;
  averageProtestResolutionTime: number;
  averageStewardingActionAppealPenaltyProtestResolutionTime: number;
}

export interface LeagueComplexSuccessRateMetrics {
  leagueId: string;
  stewardingActionAppealPenaltyProtestSuccessRate: number;
  stewardingActionAppealProtestSuccessRate: number;
  stewardingActionPenaltyProtestSuccessRate: number;
  stewardingActionAppealPenaltyProtestSuccessRate2: number;
}

export interface LeagueComplexResolutionTimeMetrics {
  leagueId: string;
  stewardingActionAppealPenaltyProtestResolutionTime: number;
  stewardingActionAppealProtestResolutionTime: number;
  stewardingActionPenaltyProtestResolutionTime: number;
  stewardingActionAppealPenaltyProtestResolutionTime2: number;
}

export interface LeagueRepository {
  create(league: LeagueData): Promise<LeagueData>;
  findById(id: string): Promise<LeagueData | null>;
  findByName(name: string): Promise<LeagueData | null>;
  findByOwner(ownerId: string): Promise<LeagueData[]>;
  search(query: string): Promise<LeagueData[]>;
  update(id: string, updates: Partial<LeagueData>): Promise<LeagueData>;
  delete(id: string): Promise<void>;
  
  getStats(leagueId: string): Promise<LeagueStats>;
  updateStats(leagueId: string, stats: LeagueStats): Promise<LeagueStats>;
  
  getFinancials(leagueId: string): Promise<LeagueFinancials>;
  updateFinancials(leagueId: string, financials: LeagueFinancials): Promise<LeagueFinancials>;
  
  getStewardingMetrics(leagueId: string): Promise<LeagueStewardingMetrics>;
  updateStewardingMetrics(leagueId: string, metrics: LeagueStewardingMetrics): Promise<LeagueStewardingMetrics>;
  
  getPerformanceMetrics(leagueId: string): Promise<LeaguePerformanceMetrics>;
  updatePerformanceMetrics(leagueId: string, metrics: LeaguePerformanceMetrics): Promise<LeaguePerformanceMetrics>;
  
  getRatingMetrics(leagueId: string): Promise<LeagueRatingMetrics>;
  updateRatingMetrics(leagueId: string, metrics: LeagueRatingMetrics): Promise<LeagueRatingMetrics>;
  
  getTrendMetrics(leagueId: string): Promise<LeagueTrendMetrics>;
  updateTrendMetrics(leagueId: string, metrics: LeagueTrendMetrics): Promise<LeagueTrendMetrics>;
  
  getSuccessRateMetrics(leagueId: string): Promise<LeagueSuccessRateMetrics>;
  updateSuccessRateMetrics(leagueId: string, metrics: LeagueSuccessRateMetrics): Promise<LeagueSuccessRateMetrics>;
  
  getResolutionTimeMetrics(leagueId: string): Promise<LeagueResolutionTimeMetrics>;
  updateResolutionTimeMetrics(leagueId: string, metrics: LeagueResolutionTimeMetrics): Promise<LeagueResolutionTimeMetrics>;
  
  getComplexSuccessRateMetrics(leagueId: string): Promise<LeagueComplexSuccessRateMetrics>;
  updateComplexSuccessRateMetrics(leagueId: string, metrics: LeagueComplexSuccessRateMetrics): Promise<LeagueComplexSuccessRateMetrics>;
  
  getComplexResolutionTimeMetrics(leagueId: string): Promise<LeagueComplexResolutionTimeMetrics>;
  updateComplexResolutionTimeMetrics(leagueId: string, metrics: LeagueComplexResolutionTimeMetrics): Promise<LeagueComplexResolutionTimeMetrics>;
}
