import { commonjsGlobal as p } from "../../_virtual/_commonjsHelpers.mjs";
import { h } from "./node_modules/hastscript/index.mjs";
import { p as y } from "../parse-entities/index.mjs";
import { p as v } from "./node_modules/prismjs/components/prism-core.mjs";
import { m as w } from "./lang/markup.mjs";
import { c as m } from "./lang/css.mjs";
import { c as b } from "./lang/clike.mjs";
import { j as k } from "./lang/javascript.mjs";
var a = typeof globalThis == "object" ? globalThis : typeof self == "object" ? self : typeof window == "object" ? window : typeof p == "object" ? p : {}, j = U();
a.Prism = {
  manual: !0,
  disableWorkerMessageHandler: !0
};
var E = h, x = y, u = v, P = w, T = m, _ = b, A = k;
j();
var c = {}.hasOwnProperty;
function d() {
}
d.prototype = u;
var n = new d(), K = n;
n.highlight = N;
n.register = f;
n.alias = L;
n.registered = O;
n.listLanguages = C;
f(P);
f(T);
f(_);
f(A);
n.util.encode = M;
n.Token.stringify = G;
function f(r) {
  if (typeof r != "function" || !r.displayName)
    throw new Error("Expected `function` for `grammar`, got `" + r + "`");
  n.languages[r.displayName] === void 0 && r(n);
}
function L(r, t) {
  var e = n.languages, i = r, s, o, g, l;
  t && (i = {}, i[r] = t);
  for (s in i)
    for (o = i[s], o = typeof o == "string" ? [o] : o, g = o.length, l = -1; ++l < g; )
      e[o[l]] = e[s];
}
function N(r, t) {
  var e = u.highlight, i;
  if (typeof r != "string")
    throw new Error("Expected `string` for `value`, got `" + r + "`");
  if (n.util.type(t) === "Object")
    i = t, t = null;
  else {
    if (typeof t != "string")
      throw new Error("Expected `string` for `name`, got `" + t + "`");
    if (c.call(n.languages, t))
      i = n.languages[t];
    else
      throw new Error("Unknown language: `" + t + "` is not registered");
  }
  return e.call(this, r, i, t);
}
function O(r) {
  if (typeof r != "string")
    throw new Error("Expected `string` for `language`, got `" + r + "`");
  return c.call(n.languages, r);
}
function C() {
  var r = n.languages, t = [], e;
  for (e in r)
    c.call(r, e) && typeof r[e] == "object" && t.push(e);
  return t;
}
function G(r, t, e) {
  var i;
  return typeof r == "string" ? {
    type: "text",
    value: r
  } : n.util.type(r) === "Array" ? H(r, t) : (i = {
    type: r.type,
    content: n.Token.stringify(r.content, t, e),
    tag: "span",
    classes: ["token", r.type],
    attributes: {},
    language: t,
    parent: e
  }, r.alias && (i.classes = i.classes.concat(r.alias)), n.hooks.run("wrap", i), E(i.tag + "." + i.classes.join("."), R(i.attributes), i.content));
}
function H(r, t) {
  for (var e = [], i = r.length, s = -1, o; ++s < i; )
    o = r[s], o !== "" && o !== null && o !== void 0 && e.push(o);
  for (s = -1, i = e.length; ++s < i; )
    o = e[s], e[s] = n.Token.stringify(o, t, e);
  return e;
}
function M(r) {
  return r;
}
function R(r) {
  var t;
  for (t in r)
    r[t] = x(r[t]);
  return r;
}
function U() {
  var r = "Prism" in a, t = r ? a.Prism : void 0;
  return e;
  function e() {
    r ? a.Prism = t : delete a.Prism, r = void 0, t = void 0;
  }
}
export {
  K as c
};
