import { useState, useEffect } from 'react'; import { createTheme, CssBaseline, ThemeProvider, Typography, Button, Box, CircularProgress, Select, MenuItem, FormControl, InputLabel, FormControlLabel, Checkbox, Alert } from '@mui/material'; import { MultiplicationTable } from './components/MultiplicationTable'; import { getNextPrime, getPreviousPrime, getInitialPrimeForViewport, PRIMES } from './utils/primeUtils'; const theme = createTheme({ palette: { mode: 'light', primary: { main: '#1976d2', }, }, }); function App() { const [currentPrime, setCurrentPrime] = useState(() => getInitialPrimeForViewport()); const [isComputing, setIsComputing] = useState(true); const [showColorBar, setShowColorBar] = useState(false); const [isMobile, setIsMobile] = useState(false); // Detect mobile device useEffect(() => { const checkMobile = () => { const isMobileDevice = window.innerWidth < 768; // Standard tablet/mobile breakpoint setIsMobile(isMobileDevice); }; checkMobile(); window.addEventListener('resize', checkMobile); return () => window.removeEventListener('resize', checkMobile); }, []); const handleNextPrime = () => { setCurrentPrime(prev => getNextPrime(prev)); }; const handlePreviousPrime = () => { setCurrentPrime(prev => getPreviousPrime(prev)); }; return ( {/* Sidebar with controls */} Finite Field Multiplication Table Prime: {currentPrime} {isComputing && } Multiplication table modulo {currentPrime} Showing ({currentPrime - 1} × {currentPrime - 1}) grid Select Prime Each cell (i, j) shows the value of (i × j) mod {currentPrime} {isMobile ? ( This visualization is best viewed on a desktop. ) : ( setShowColorBar(e.target.checked)} /> } label="Show Color Bar" /> )} {/* Main content area */} ); } export default App;