import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import * as pdfjs from "pdfjs-dist";
// Vite resolves `?url` to a bundled asset URL the browser can fetch.
import pdfWorkerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url";

import { App } from "./App";

// PDF.js needs a worker URL before any PDF is parsed. Set it once at app
// bootstrap so both the source-layer ingest (extract.ts) and the viewer
// adapter (PdfSpikeViewer) can open documents.
pdfjs.GlobalWorkerOptions.workerSrc = pdfWorkerUrl;

const container = document.getElementById("root");
if (!container) throw new Error("#root not found");

createRoot(container).render(
  <StrictMode>
    <App />
  </StrictMode>,
);
