import * as React from 'react'; import { useState, useEffect, useRef } from 'react'; import { Stats, Theme, TyperPunkGame } from '../types'; import { useTheme } from '../contexts/ThemeContext'; import { EndScreen } from './EndScreen'; interface Props { game: TyperPunkGame | null; text: string; input: string; stats: Stats; attribution?: string; onInput: (input: string, accuracy: number, mistakes: number) => void; onFinish: ( finalStats: Stats, wpmHistory: Array<{ time: number; wpm: number; raw: number; isError: boolean }>, finalUserInput: string, charTimings: Array<{ time: number; isCorrect: boolean; char: string; index: number }>, keypressHistory: Array<{ time: number; index: number; isCorrect: boolean }> ) => void; onReset: () => void; onMainMenu: () => void; } // Error boundary for TypingGame class TypingGameErrorBoundary extends React.Component<{ children: React.ReactNode }, { error: Error | null }> { constructor(props: { children: React.ReactNode }) { super(props); this.state = { error: null }; } static getDerivedStateFromError(error: Error) { return { error }; } componentDidCatch(error: Error, errorInfo: any) { console.error('TypingGame error boundary caught:', error, errorInfo); } render() { if (this.state.error) { return