Something went wrong. Try again.
Original-language reader for Kant, Aristotle & more: select any passage to gloss, translate, or hear it read aloud, with exact citations.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536import { pageNumberOf } from "@/lib/model/locus"import type { FacsimileConfig } from "@/lib/schemas/model"
/** * Facsimile asset resolution (§4). The catalog stores **relative** keys; the * delivery base is a runtime env (`VITE_FACSIMILE_BASE`) so one catalog serves * both dev (the `public/facsimile/` copy) and prod (the R2 public base). */
export type ImagesConfig = Extract<FacsimileConfig, { kind: "images" }>export type PdfConfig = Extract<FacsimileConfig, { kind: "pdf" }>
export function facsimileBase(): string { const base = import.meta.env.VITE_FACSIMILE_BASE ?? "/facsimile/" return base.endsWith("/") ? base : `${base}/`}
/** Husserl: the page image for an anchor, or null if that page isn't mapped. */export function imageUrlFor(config: ImagesConfig, anchorId: string | null): string | null { if (!anchorId) return null const key = config.pages[anchorId] return key ? facsimileBase() + key : null}
/** Heidegger: the source PDF URL (rendered client-side via pdf.js). */export function pdfUrlFor(config: PdfConfig): string { return facsimileBase() + config.pdfKey}
/** Heidegger: 1-based PDF page for an anchor (print page + delta), or null. */export function pdfPageFor(config: PdfConfig, anchorId: string | null): number | null { if (!anchorId) return null const n = pageNumberOf(anchorId) return n === null ? null : n + config.pageDelta}