/**
 * /scratch/<path...> — in-browser viewer for files under <dataDir>/scratch/.
 *
 * Why this page exists: the raw `/api/scratch/<path>` route returns the
 * file with its proper MIME, which works for images / pdf but is poor UX
 * for markdown — browsers either show raw text or trigger a download
 * (depending on the browser's text/markdown handling).
 *
 * This wrapper renders .md through MarkdownContent (same renderer as
 * chat), and falls back to a plain <pre> for other text formats. It also
 * exposes a one-click download link for any file type.
 */

import ScratchViewer from '@/components/ScratchViewer';

export default async function ScratchPage({
  params,
}: {
  params: Promise<{ path: string[] }>;
}) {
  const { path } = await params;
  const joined = (path || []).map(encodeURIComponent).join('/');
  return <ScratchViewer path={joined} />;
}
