// Session types enum
export enum SessionType {
  FireRange = 0,
  Challenge = 1,
  Protect = 2,
  DeEscalation = 3,
  Terrorism = 4,
  FireExtinction = 5,
  Recovering = 6,
  LongRange = 7,
}

export const SESSION_TYPE_LABELS: Record<number, string> = {
  [SessionType.FireRange]: 'Stand de Tir',
  [SessionType.Challenge]: 'Challenge',
  [SessionType.Protect]: 'Protection',
  [SessionType.DeEscalation]: 'Désescalade',
  [SessionType.Terrorism]: 'Terrorisme',
  [SessionType.FireExtinction]: 'Incendie',
  [SessionType.Recovering]: 'Récupération',
  [SessionType.LongRange]: 'Tir Longue Distance',
};

export const SESSION_TYPE_COLORS: Record<number, string> = {
  [SessionType.FireRange]: '#4a90d9',
  [SessionType.Challenge]: '#9b59b6',
  [SessionType.Protect]: '#27ae60',
  [SessionType.DeEscalation]: '#f39c12',
  [SessionType.Terrorism]: '#e74c3c',
  [SessionType.FireExtinction]: '#e67e22',
  [SessionType.Recovering]: '#1abc9c',
  [SessionType.LongRange]: '#2980b9',
};

// React event types
export enum ReactEventType {
  EnemyHit = 0,
  CivilianHit = 1,
  PoliceHit = 2,
  ObjectHit = 3,
  PaperTargetHit = 4,
  TargetHit = 5,
  DeadBodyHit = 6,
}

export const REACT_EVENT_TYPE_LABELS: Record<number, string> = {
  [ReactEventType.EnemyHit]: 'Ennemi',
  [ReactEventType.CivilianHit]: 'Civil',
  [ReactEventType.PoliceHit]: 'Police',
  [ReactEventType.ObjectHit]: 'Objet',
  [ReactEventType.PaperTargetHit]: 'Cible Papier',
  [ReactEventType.TargetHit]: 'Cible',
  [ReactEventType.DeadBodyHit]: 'Corps',
};

// User roles
export enum UserRole {
  Police = 0,
  Enemy = 1,
  Civil = 2,
  IA = 3,
}

export const USER_ROLE_LABELS: Record<number, string> = {
  [UserRole.Police]: 'Police',
  [UserRole.Enemy]: 'Ennemi',
  [UserRole.Civil]: 'Civil',
  [UserRole.IA]: 'IA',
};

// User status
export enum UserStatus {
  Alive = 0,
  LightlyInjured = 1,
  SeriouslyInjured = 2,
  Dead = 3,
}

export const USER_STATUS_LABELS: Record<number, string> = {
  [UserStatus.Alive]: 'Vivant',
  [UserStatus.LightlyInjured]: 'Blessé léger',
  [UserStatus.SeriouslyInjured]: 'Blessé grave',
  [UserStatus.Dead]: 'Mort',
};

export const USER_STATUS_COLORS: Record<number, string> = {
  [UserStatus.Alive]: '#27ae60',
  [UserStatus.LightlyInjured]: '#f39c12',
  [UserStatus.SeriouslyInjured]: '#e67e22',
  [UserStatus.Dead]: '#e74c3c',
};

// Data interfaces matching API responses
export interface Session {
  id: number;
  sessionTypeAsInt: number;
  sessionName: string;
  sessionDateAsString: string;
  mapName: string;
  scenarioName: string;
  success: boolean;
  timeToFinish: number;
  score: number;
  nbEnemyHit: number;
  nbCivilsHit: number;
  damageTaken: number;
  replayFileName: string;
}

export interface User {
  id: number;
  username: string;
  firstName: string;
  lastName: string;
  leftHanded: boolean;
  maleGender: boolean;
  charSkinAssetName: string;
  weaponAssetName: string;
  lastConnection: string;
  avgPrecision: number;
  avgReaction: number;
  avgFault: number;
  avgRapidity: number;
  size: number;
}

export interface Participation {
  userId: number;
  sessionId: number;
  score: number;
  firePrecision: number;
  reactionTime: number;
  nbEnemyHit: number;
  nbCivilsHit: number;
  damageTaken: number;
  endStatus: number;
  avatar: string;
  weapon: string;
  roleId: number;
  resultsAsString: string;
}

export interface DebriefRow {
  userId: number;
  sessionId: number;
  nbFiredShotsByUser: number;
  nbMissedShotsByUser: number;
  nbEnemyHitsByUser: number;
  nbCivilHitsByUser: number;
  nbPoliceHitsByUser: number;
  nbObjectHitsByUser: number;
  nbDeadBodyHitsByUser: number;
  nbReceivedHitsFromEnemyIA: number;
  nbReceivedHitsFromEnemyUser: number;
  nbReceivedHitsFromPoliceUser: number;
  totalEnemyKilled: number;
  totalCivilKilled: number;
  totalPoliceKilled: number;
  averagePrecision: number;
  averageReactionTime: number;
}

export interface SessionDebriefRow {
  sessionId: number;
  sessionTypeId: number;
  sessionType: string;
  sessionName: string;
  sessionDate: string;
  mapName: string;
  scenarioName: string;
  sessionSuccessful: number;
  sessionDuration: number;
  shooterId: number;
  shooterName: string;
  shooterRoleId: number;
  shooterRole: string;
  shotIndex: number;
  reactId: number;
  reactModeId: number;
  reactMode: string;
  reactTypeId: number;
  reactType: string;
  targetUserId: number;
  targetUserName: string;
  targetRoleId: number;
  targetRole: string;
  targetName: string;
  targetBoneName: string;
  targetKilled: number;
  hitLocationX: number;
  hitLocationY: number;
  hitLocationTag: string;
  hitPrecision: number;
  hitTargetDistance: number;
  reactionTime: number;
  timeStamp: number;
  nbHit: number;
  nbKilled: number;
}

export interface UserGlobalStats {
  totals: DebriefRow;
  nbSessions: number;
  totalDuration: number;
  firstSession: string;
  lastSession: string;
  sessionDebriefRows: SessionDebriefRow[];
}

export interface ObjectiveResults {
  civilian?: { score: number; maxScore: number; success: boolean };
  time?: { score: number; maxScore: number; success: boolean };
  enemy?: { score: number; maxScore: number; success: boolean };
  health?: { score: number; maxScore: number; success: boolean };
  precision?: { score: number; maxScore: number; success: boolean };
  reactTime?: { score: number; maxScore: number; success: boolean };
  ammoLimit?: { score: number; maxScore: number; success: boolean };
  target?: { score: number; maxScore: number; success: boolean };
  overall?: { score: number; maxScore: number; success: boolean };
}

// API response wrapper
export interface ApiResponse<T> {
  status: boolean;
  message: string;
  [key: string]: T | boolean | string;
}
