const CLASS_COLORS = [
  '#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF',
  '#800000', '#008000', '#000080', '#808000', '#800080', '#008080',
]

export const FALLBACK_CLASS_NAMES = [
  'Car', 'Person', 'Truck', 'Bicycle', 'Motorcycle', 'Bus',
  'Animal', 'Tree', 'Building', 'Sign', 'Boat', 'Plane',
]

export function getClassColor(classNum: number): string {
  const base = classNum % 20
  return CLASS_COLORS[base % CLASS_COLORS.length]
}

export function getPhotoModeSuffix(classNum: number): string {
  const mode = Math.floor(classNum / 20)
  return mode === 1 ? ' (winter)' : mode === 2 ? ' (night)' : ''
}

export function getClassNameFallback(classNum: number): string {
  const base = classNum % 20
  return FALLBACK_CLASS_NAMES[base % FALLBACK_CLASS_NAMES.length] ?? `#${classNum}`
}

export function hexToRgba(hex: string, alpha: number): string {
  const h = hex.replace('#', '')
  const r = parseInt(h.slice(0, 2), 16)
  const g = parseInt(h.slice(2, 4), 16)
  const b = parseInt(h.slice(4, 6), 16)
  return `rgba(${r},${g},${b},${alpha})`
}
