import { createHighlighter } from "shiki";
let highlighter = null;
const SUPPORTED_LANGUAGES = [
  "typescript",
  "javascript",
  "tsx",
  "jsx",
  "json",
  "bash",
  "shell",
  "sql",
  "css",
  "html",
  "markdown",
  "yaml",
  "gherkin"
];
async function getShikiHighlighter() {
  if (!highlighter) {
    highlighter = await createHighlighter({
      themes: ["github-dark", "github-light"],
      langs: SUPPORTED_LANGUAGES
    });
  }
  return highlighter;
}
async function highlightCode(code, lang, theme = "github-dark") {
  const hl = await getShikiHighlighter();
  const normalizedLang = normalizeLanguage(lang);
  return hl.codeToHtml(code, {
    lang: normalizedLang,
    theme
  });
}
function normalizeLanguage(lang) {
  const langMap = {
    ts: "typescript",
    js: "javascript",
    sh: "bash",
    yml: "yaml",
    md: "markdown"
  };
  const normalized = lang.toLowerCase();
  return langMap[normalized] || normalized;
}
export {
  getShikiHighlighter,
  highlightCode
};
