import type { BibleBook, Testament, BibleSection } from '$lib/types/bible'; import { bibleBooks } from '$lib/types/bible'; // Book number (1-66) to book ID mapping derived from bibleBooks order property export const bookNumberToId: Record = bibleBooks.reduce((acc, book) => { acc[book.order] = book.id; return acc; }, {} as Record); // Book ID to book number mapping (reverse lookup) export const bookIdToNumber: Record = bibleBooks.reduce((acc, book) => { acc[book.id] = book.order; return acc; }, {} as Record); export function getBookById(id: string): BibleBook | undefined { return bibleBooks.find((book) => book.id === id); } export function getBookByNumber(number: number): BibleBook | undefined { return bibleBooks.find((book) => book.order === number); } export function getBooksByTestament(testament: Testament): BibleBook[] { return bibleBooks.filter((book) => book.testament === testament); } export function getBooksBySection(section: BibleSection): BibleBook[] { return bibleBooks.filter((book) => book.section === section); } export function isAdjacent(bookId1: string, bookId2: string): boolean { const book1 = getBookById(bookId1); const book2 = getBookById(bookId2); if (!book1 || !book2) return false; return Math.abs(book1.order - book2.order) === 1; } export { bibleBooks };