/**
* TableOfContents — slide-in drawer for epub.js navigation tree.
*/
import type { KeyboardEvent } from "react";
import { useTranslation } from "react-i18n-lite";
import { PanelCloseButton } from "./PanelCloseButton";
export interface EpubTocItem {
label: string;
href: string;
subitems?: EpubTocItem[];
}
interface TableOfContentsProps {
items: EpubTocItem[];
isOpen: boolean;
onClose: () => void;
onNavigate: (href: string) => void;
}
function TocEntry({
item,
depth,
onNavigate,
}: {
item: EpubTocItem;
depth: number;
onNavigate: (href: string) => void;
}) {
return (
<>
{item.subitems?.map((sub) => (