import { Eye, Image as ImageIcon, Leaf, Moon, Package, Pill, Sun } from 'lucide-react'
import { useEffect, useState } from 'react'
import About from './pages/About'
import Caption from './pages/Caption'
import FoodLabel from './pages/FoodLabel'
import Home from './pages/Home'
import Plant from './pages/Plant'
import Prescription from './pages/Prescription'
// Hash routes, so a page can be linked and survives a reload (no router needed).
const ROUTES = {
'#/caption': 'caption',
'#/prescription': 'prescription',
'#/product-label': 'label',
'#/plant': 'plant',
'#/about': 'about',
}
const pageFromHash = () => ROUTES[window.location.hash] ?? 'home'
const TOOLS = [
{ page: 'caption', href: '#/caption', label: 'Caption a photo', short: 'Caption', icon: ImageIcon },
{ page: 'prescription', href: '#/prescription', label: 'Read a prescription', short: 'Prescription', icon: Pill },
{ page: 'label', href: '#/product-label', label: 'Check a food label', short: 'Food label', icon: Package },
{ page: 'plant', href: '#/plant', label: 'Identify a plant', short: 'Plant', icon: Leaf },
]
function useTheme() {
const [theme, setTheme] = useState(() => (document.documentElement.dataset.theme === 'dark' ? 'dark' : 'light'))
useEffect(() => {
if (theme === 'dark') document.documentElement.dataset.theme = 'dark'
else delete document.documentElement.dataset.theme
try {
localStorage.setItem('theme', theme)
} catch {
// storage blocked: the choice lasts for this visit only
}
}, [theme])
return [theme, () => setTheme((t) => (t === 'dark' ? 'light' : 'dark'))]
}
function Header({ page, theme, onToggleTheme }) {
return (