// The single home for per-verse tools: original words, cross-references, // commentary, and people & places, plus bookmark / copy. import { useEffect, useState } from 'react'; import Sheet from './Sheet.jsx'; import { CommentaryTab, PeoplePlacesTab } from '../StudyPanel.jsx'; import { BookmarkIcon, CopyIcon } from '../../utils/bibleUtils.jsx'; import { formatCrossRef, speakOriginalWord } from '../../utils/wordStudy.js'; import { READER_TRANSLATIONS, fetchChapter } from '../../utils/bibleText.js'; import { diffVerses, differenceLabel } from '../../utils/textDiff.js'; import { DiffText } from './DiffText.jsx'; const TABS = [['commentary', 'Commentary'], ['compare', 'Compare'], ['original', 'Original'], ['refs', 'Cross-refs'], ['people', 'People & places']]; function OriginalTab({ words }) { if (!words) return

No original-language data for this verse.

; return (
{words.map((w, i) => { const isHebrew = w.s?.startsWith('H'); const canSpeak = isHebrew || w.s?.startsWith('G'); return (
{w.o}
{w.t}
{w.g}
{w.p &&
{w.p}
} {w.s &&
{w.s}
} {canSpeak && ( )}
); })}
); } function RefsTab({ refs, loading, onJump }) { if (loading && !refs) return

Loading…

; if (!refs?.length) return

No cross-references for this verse.

; return (
{refs.slice(0, 20).map((ref, i) => ( ))}
); } // This verse in every translation, one under the other. Each Bible loads the chapter it is in // (BSB and NET come from the free source; the rest through the server) and shows this verse. function CompareTab({ book, chapter, verse, current }) { const [rows, setRows] = useState({}); // id -> { text } | { error } | undefined while loading useEffect(() => { const controller = new AbortController(); setRows({}); READER_TRANSLATIONS.forEach((t) => { fetchChapter(t.id, book, chapter, { signal: controller.signal }) .then(({ verses }) => { const text = verses.find((v) => v.number === verse)?.text; setRows((r) => ({ ...r, [t.id]: text ? { text } : { error: 'No verse here in this translation.' } })); }) .catch((err) => { if (!controller.signal.aborted) setRows((r) => ({ ...r, [t.id]: { error: err.message || 'Unavailable.' } })); }); }); return () => controller.abort(); }, [book, chapter, verse]); const mine = rows[current]?.text; return (
{READER_TRANSLATIONS.map((t) => { const row = rows[t.id]; // How this wording differs from the Bible being read, word by word const d = row?.text && mine && t.id !== current ? diffVerses(mine, row.text) : null; return (

{t.id}{t.id === current ? ' · reading' : ''} {d && {differenceLabel(d.similarity)}}

{!row ?

Loading…

: row.error ?

{row.error}

:

}
); })}

{mine ? <>Marked words aren’t in the {current} wording. : null} Copyright notices for each translation appear at the foot of the chapter when you read it.

); } export default function VerseSheet({ verse, book, bookName, chapter, translation, words, crossRefs, crossRefsLoading, onLoadCrossRefs, bookmarkColor, onToggleBookmark, onCycleColor, onJump, onClose, }) { const [tab, setTab] = useState('commentary'); const [copied, setCopied] = useState(false); useEffect(() => { if (verse && tab === 'refs') onLoadCrossRefs(); }, [verse?.number, tab]); // eslint-disable-line react-hooks/exhaustive-deps useEffect(() => { setCopied(false); }, [verse?.number]); if (!verse) return null; const copy = () => { navigator.clipboard?.writeText(`${bookName} ${chapter}:${verse.number} ${translation} — ${verse.text}`); setCopied(true); window.setTimeout(() => setCopied(false), 1500); }; const actionBtn = 'rounded-lg p-1.5 hover:bg-black/5'; return ( {bookmarkColor && ( )} )} >
{TABS.map(([id, label]) => ( ))}
{tab === 'commentary' && } {tab === 'compare' && } {tab === 'original' && } {tab === 'refs' && } {tab === 'people' && }
); }