import { useState } from 'react'; import { useApp } from '../context/AppContext.js'; import { buildPronunciationGuide } from '../utils/bibleUtils.jsx'; import { speakOriginalWord } from '../utils/wordStudy.js'; export default function PronunciationPage() { const { project, setCurrentPage } = useApp(); const [search, setSearch] = useState(''); const [copied, setCopied] = useState(false); const chapters = Array.isArray(project?.chapters) ? project.chapters : []; // Collect all words with chapter/chunk context, deduplicated by Strong's number const seen = new Set(); const entries = []; chapters.forEach((ch) => { ch.chunks.forEach((chunk) => { (chunk.greekWords ?? []).forEach((word) => { if (!word.lexeme && !word.transliteration) return; const key = word.strongNumber || `${word.lexeme}__${word.transliteration}`; if (seen.has(key)) return; seen.add(key); entries.push({ word, chapterRef: `${ch.book} ${ch.chapter}` }); }); }); }); const q = search.trim().toLowerCase(); const filtered = q ? entries.filter(({ word }) => (word.englishGloss ?? '').toLowerCase().includes(q) || (word.shortDefinition ?? '').toLowerCase().includes(q) || (word.lexeme ?? '').toLowerCase().includes(q) || (word.transliteration ?? '').toLowerCase().includes(q) || (word.strongNumber ?? '').toLowerCase().includes(q), ) : entries; const greek = filtered.filter(({ word }) => !word.strongNumber?.startsWith('H')); const hebrew = filtered.filter(({ word }) => word.strongNumber?.startsWith('H')); const copyAll = () => { const guide = buildPronunciationGuide(project); navigator.clipboard.writeText(guide).then(() => { setCopied(true); setTimeout(() => setCopied(false), 2000); }); }; return (
{/* Page header */}

Pronunciation Guide

{project?.title && (

{project.title}

)}

{entries.length} unique word{entries.length !== 1 ? 's' : ''} across all chapters

{/* Search */}
setSearch(e.target.value)} className="w-full rounded-2xl border border-slate-300 bg-white px-4 py-3 text-sm text-slate-900 shadow-sm placeholder:text-slate-400 focus:border-sky-500 focus:outline-none focus:ring-2 focus:ring-sky-200" />
{entries.length === 0 ? (

🔤

No words yet

Add Greek or Hebrew words in the Word Studies panel on the Study page.

) : filtered.length === 0 ? (

No words match "{search}"

) : (
{greek.length > 0 && } {hebrew.length > 0 && }
)}
); } function WordGroup({ title, color, words, onSpeak }) { const accent = { sky: { badge: 'bg-sky-100 text-sky-700 border-sky-200', speak: 'bg-sky-100 text-sky-700 hover:bg-sky-200', heading: 'text-sky-800 border-sky-200 bg-sky-50' }, emerald: { badge: 'bg-emerald-100 text-emerald-700 border-emerald-200', speak: 'bg-emerald-100 text-emerald-700 hover:bg-emerald-200', heading: 'text-emerald-800 border-emerald-200 bg-emerald-50' }, }[color]; return (

{title} · {words.length} word{words.length !== 1 ? 's' : ''}

{words.map(({ word, chapterRef }) => ( ))}
); } function WordCard({ word, chapterRef, accent, onSpeak }) { return (
{/* Top row: lexeme + speak */}
{word.lexeme && (

{word.lexeme}

)} {word.transliteration && (

{word.transliteration}

)}
{word.lexeme && ( )} {word.strongNumber && ( {word.strongNumber} )}
{/* Gloss + definition */}
{word.englishGloss && (

{word.englishGloss}

)} {word.shortDefinition && word.shortDefinition !== word.englishGloss && (

{word.shortDefinition}

)}
{/* Footer: part of speech + source passage */}
{word.partOfSpeech && ( {word.partOfSpeech} )} {chapterRef}
); }