import { IconFeatherFilled, IconDiamondFilled, IconCompassFilled, IconFlameFilled, IconMeteorFilled } from '@tabler/icons-react'

export const PRESETS = [
  { id: 'glyph', name: 'Glyph', desc: '5x5', tag: 'very easy', speedrunSecs: 45, icon: IconFeatherFilled },
  { id: 'rune', name: 'Rune', desc: '5x5', tag: 'easy', speedrunSecs: 60, icon: IconDiamondFilled },
  { id: 'scroll', name: 'Scroll', desc: '9x9', tag: 'medium', speedrunSecs: 300, icon: IconCompassFilled },
  { id: 'codex', name: 'Codex', desc: '15x15', tag: 'hard', speedrunSecs: 1200, icon: IconFlameFilled },
  { id: 'grimoire', name: 'Grimoire', desc: '21x21', tag: 'expert', speedrunSecs: 2700, icon: IconMeteorFilled },
] as const

export const SPEEDRUN_LIMITS: Record<string, number> = Object.fromEntries(
  PRESETS.map(p => [p.id, p.speedrunSecs])
)

export function formatSpeedrunTime(secs: number): string {
  if (secs < 60) return `${secs}s`
  return `${Math.floor(secs / 60)} min`
}

export function speedrunDescription(): string {
  return 'Countdown timer, no hints, no pausing. Beat the clock or lose. Time limits: ' +
    PRESETS.map(p => `${p.name} ${formatSpeedrunTime(p.speedrunSecs)}`).join(', ') + '.'
}
