import {
  a as c,
  c as S
} from "./chunk-IO47FP3U.js";

// ../node_modules/refractor/lang/jsx.js
var h = S((v, d) => {
  d.exports = p;
  p.displayName = "jsx";
  p.aliases = [];
  function p(j) {
    (function(a) {
      var i = a.util.clone(a.languages.javascript), x = /(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source, y = /(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source, l = /(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;
      function u(e, t) {
        return e = e.replace(/<S>/g, function() {
          return x;
        }).replace(/<BRACES>/g, function() {
          return y;
        }).replace(/<SPREAD>/g, function() {
          return l;
        }), RegExp(e, t);
      }
      c(u, "re"), l = u(l).source, a.languages.jsx = a.languages.extend("markup", i), a.languages.jsx.tag.pattern = u(
        /<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source
      ), a.languages.jsx.tag.inside.tag.pattern = /^<\/?[^\s>\/]*/, a.languages.jsx.tag.inside["attr-value"].pattern = /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/, a.languages.jsx.tag.inside.tag.inside["class-name"] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/, a.languages.jsx.tag.inside.comment = i.comment, a.languages.insertBefore(
        "inside",
        "attr-name",
        {
          spread: {
            pattern: u(/<SPREAD>/.source),
            inside: a.languages.jsx
          }
        },
        a.languages.jsx.tag
      ), a.languages.insertBefore(
        "inside",
        "special-attr",
        {
          script: {
            // Allow for two levels of nesting
            pattern: u(/=<BRACES>/.source),
            alias: "language-javascript",
            inside: {
              "script-punctuation": {
                pattern: /^=(?=\{)/,
                alias: "punctuation"
              },
              rest: a.languages.jsx
            }
          }
        },
        a.languages.jsx.tag
      );
      var g = /* @__PURE__ */ c(function(e) {
        return e ? typeof e == "string" ? e : typeof e.content == "string" ? e.content : e.content.map(g).join("") : "";
      }, "stringifyToken"), f = /* @__PURE__ */ c(function(e) {
        for (var t = [], s = 0; s < e.length; s++) {
          var n = e[s], o = !1;
          if (typeof n != "string" && (n.type === "tag" && n.content[0] && n.content[0].type === "tag" ? n.content[0].content[0].content === "</" ? t.length > 0 && t[t.length - 1].tagName === g(n.content[0].content[1]) && t.pop() : n.content[n.content.length - 1].content === "/>" || t.push({
            tagName: g(n.content[0].content[1]),
            openedBraces: 0
          }) : t.length > 0 && n.type === "punctuation" && n.content === "{" ? t[t.length - 1].openedBraces++ : t.length > 0 && t[t.length - 1].openedBraces > 0 && n.type === "punctuation" && n.content === "}" ? t[t.length - 1].openedBraces-- : o = !0), (o || typeof n == "string") && t.length > 0 && t[t.length - 1].openedBraces === 0) {
            var r = g(n);
            s < e.length - 1 && (typeof e[s + 1] == "string" || e[s + 1].type === "plain-text") && (r += g(e[s + 1]), e.splice(s + 1, 1)), s > 0 && (typeof e[s - 1] == "string" || e[s - 1].type === "plain-text") && (r = g(e[s - 1]) + r, e.splice(s - 1, 1), s--), e[s] = new a.Token(
              "plain-text",
              r,
              null,
              r
            );
          }
          n.content && typeof n.content != "string" && f(n.content);
        }
      }, "walkTokens");
      a.hooks.add("after-tokenize", function(e) {
        e.language !== "jsx" && e.language !== "tsx" || f(e.tokens);
      });
    })(j);
  }
  c(p, "jsx");
});

export {
  h as a
};
