import { inject, ref } from "vue";
import { prismjsHighlightCode } from "./prismjs.mjs";
import { shikiHighlightCode } from "./shiki.mjs";
import { createSymbol } from "../../utils/symbol.mjs";
const HighlighterKey = createSymbol("highlighter");
function createHighlighter(options) {
  return ref({
    highlight: async (code, language) => {
      var _a;
      const type = (_a = options == null ? void 0 : options.type) != null ? _a : "shiki";
      if (language === "text") {
        return code;
      } else if (type === "shiki" && (options == null ? void 0 : options.shiki)) {
        return await shikiHighlightCode(options.shiki, code, language);
      } else if (type === "prismjs" && (options == null ? void 0 : options.prismjs)) {
        return await prismjsHighlightCode(options.prismjs, code, language);
      } else {
        return code;
      }
    }
  });
}
function useHighlighter() {
  const highlighter = inject(HighlighterKey);
  if (!highlighter)
    throw new Error("[VenoUi] Could not find highlighter instance");
  return highlighter;
}
export {
  HighlighterKey,
  createHighlighter,
  useHighlighter
};
//# sourceMappingURL=index.mjs.map
