/**
 * Lightweight syntax highlighter using PrismLight with only the languages
 * this app needs, instead of the full Prism build that ships all 300 grammars.
 *
 * Usage:
 *   import { SyntaxHighlighter } from "@/lib/syntax-highlighter"
 *
 * Saves ~850 KB of client JS by not shipping unused language grammars.
 */
import SyntaxHighlighter from "react-syntax-highlighter/dist/esm/prism-light"
import python from "react-syntax-highlighter/dist/esm/languages/prism/python"
import javascript from "react-syntax-highlighter/dist/esm/languages/prism/javascript"
import typescript from "react-syntax-highlighter/dist/esm/languages/prism/typescript"
import java from "react-syntax-highlighter/dist/esm/languages/prism/java"
import json from "react-syntax-highlighter/dist/esm/languages/prism/json"
import css from "react-syntax-highlighter/dist/esm/languages/prism/css"
import markup from "react-syntax-highlighter/dist/esm/languages/prism/markup"
import bash from "react-syntax-highlighter/dist/esm/languages/prism/bash"
import jsx from "react-syntax-highlighter/dist/esm/languages/prism/jsx"
import tsx from "react-syntax-highlighter/dist/esm/languages/prism/tsx"

SyntaxHighlighter.registerLanguage("python", python)
SyntaxHighlighter.registerLanguage("javascript", javascript)
SyntaxHighlighter.registerLanguage("typescript", typescript)
SyntaxHighlighter.registerLanguage("java", java)
SyntaxHighlighter.registerLanguage("json", json)
SyntaxHighlighter.registerLanguage("css", css)
SyntaxHighlighter.registerLanguage("html", markup)
SyntaxHighlighter.registerLanguage("markup", markup)
SyntaxHighlighter.registerLanguage("bash", bash)
SyntaxHighlighter.registerLanguage("jsx", jsx)
SyntaxHighlighter.registerLanguage("tsx", tsx)
const mockPlaintext = (prism: any) => {
  prism.languages.plaintext = {}
  prism.languages.text = {}
}
mockPlaintext.displayName = "plaintext"
mockPlaintext.aliases = ["text"]

SyntaxHighlighter.registerLanguage("plaintext", mockPlaintext as any)
SyntaxHighlighter.registerLanguage("text", mockPlaintext as any)

export { SyntaxHighlighter }
