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

// ../node_modules/highlight.js/lib/languages/javascript.js
var P = D((K, p) => {
  var O = "[A-Za-z$_][0-9A-Za-z$_]*", C = [
    "as",
    // for exports
    "in",
    "of",
    "if",
    "for",
    "while",
    "finally",
    "var",
    "new",
    "function",
    "do",
    "return",
    "void",
    "else",
    "break",
    "catch",
    "instanceof",
    "with",
    "throw",
    "case",
    "default",
    "try",
    "switch",
    "continue",
    "typeof",
    "delete",
    "let",
    "yield",
    "const",
    "class",
    // JS handles these with a special rule
    // "get",
    // "set",
    "debugger",
    "async",
    "await",
    "static",
    "import",
    "from",
    "export",
    "extends"
  ], v = [
    "true",
    "false",
    "null",
    "undefined",
    "NaN",
    "Infinity"
  ], w = [
    "Intl",
    "DataView",
    "Number",
    "Math",
    "Date",
    "String",
    "RegExp",
    "Object",
    "Function",
    "Boolean",
    "Error",
    "Symbol",
    "Set",
    "Map",
    "WeakSet",
    "WeakMap",
    "Proxy",
    "Reflect",
    "JSON",
    "Promise",
    "Float64Array",
    "Int16Array",
    "Int32Array",
    "Int8Array",
    "Uint16Array",
    "Uint32Array",
    "Float32Array",
    "Array",
    "Uint8Array",
    "Uint8ClampedArray",
    "ArrayBuffer",
    "BigInt64Array",
    "BigUint64Array",
    "BigInt"
  ], L = [
    "EvalError",
    "InternalError",
    "RangeError",
    "ReferenceError",
    "SyntaxError",
    "TypeError",
    "URIError"
  ], x = [
    "setInterval",
    "setTimeout",
    "clearInterval",
    "clearTimeout",
    "require",
    "exports",
    "eval",
    "isFinite",
    "isNaN",
    "parseFloat",
    "parseInt",
    "decodeURI",
    "decodeURIComponent",
    "encodeURI",
    "encodeURIComponent",
    "escape",
    "unescape"
  ], B = [
    "arguments",
    "this",
    "super",
    "console",
    "window",
    "document",
    "localStorage",
    "module",
    "global"
    // Node.js
  ], U = [].concat(
    x,
    B,
    w,
    L
  );
  function $(e) {
    return e ? typeof e == "string" ? e : e.source : null;
  }
  r($, "source");
  function m(e) {
    return u("(?=", e, ")");
  }
  r(m, "lookahead");
  function u(...e) {
    return e.map((n) => $(n)).join("");
  }
  r(u, "concat");
  function k(e) {
    let _ = /* @__PURE__ */ r((a, { after: g }) => {
      let E = "</" + a[0].slice(1);
      return a.input.indexOf(E, g) !== -1;
    }, "hasClosingTag"), n = O, T = {
      begin: "<>",
      end: "</>"
    }, s = {
      begin: /<[A-Za-z0-9\\._:-]+/,
      end: /\/[A-Za-z0-9\\._:-]+>|\/>/,
      /**
       * @param {RegExpMatchArray} match
       * @param {CallbackResponse} response
       */
      isTrulyOpeningTag: /* @__PURE__ */ r((a, g) => {
        let E = a[0].length + a.index, d = a.input[E];
        if (d === "<") {
          g.ignoreMatch();
          return;
        }
        d === ">" && (_(a, { after: E }) || g.ignoreMatch());
      }, "isTrulyOpeningTag")
    }, t = {
      $pattern: O,
      keyword: C,
      literal: v,
      built_in: U
    }, N = "[0-9](_?[0-9])*", c = `\\.(${N})`, S = "0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*", A = {
      className: "number",
      variants: [
        // DecimalLiteral
        { begin: `(\\b(${S})((${c})|\\.)?|(${c}))[eE][+-]?(${N})\\b` },
        { begin: `\\b(${S})\\b((${c})\\b|\\.)?|(${c})\\b` },
        // DecimalBigIntegerLiteral
        { begin: "\\b(0|[1-9](_?[0-9])*)n\\b" },
        // NonDecimalIntegerLiteral
        { begin: "\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b" },
        { begin: "\\b0[bB][0-1](_?[0-1])*n?\\b" },
        { begin: "\\b0[oO][0-7](_?[0-7])*n?\\b" },
        // LegacyOctalIntegerLiteral (does not include underscore separators)
        // https://tc39.es/ecma262/#sec-additional-syntax-numeric-literals
        { begin: "\\b0[0-7]+n?\\b" }
      ],
      relevance: 0
    }, i = {
      className: "subst",
      begin: "\\$\\{",
      end: "\\}",
      keywords: t,
      contains: []
      // defined later
    }, f = {
      begin: "html`",
      end: "",
      starts: {
        end: "`",
        returnEnd: !1,
        contains: [
          e.BACKSLASH_ESCAPE,
          i
        ],
        subLanguage: "xml"
      }
    }, R = {
      begin: "css`",
      end: "",
      starts: {
        end: "`",
        returnEnd: !1,
        contains: [
          e.BACKSLASH_ESCAPE,
          i
        ],
        subLanguage: "css"
      }
    }, I = {
      className: "string",
      begin: "`",
      end: "`",
      contains: [
        e.BACKSLASH_ESCAPE,
        i
      ]
    }, b = {
      className: "comment",
      variants: [
        e.COMMENT(
          /\/\*\*(?!\/)/,
          "\\*/",
          {
            relevance: 0,
            contains: [
              {
                className: "doctag",
                begin: "@[A-Za-z]+",
                contains: [
                  {
                    className: "type",
                    begin: "\\{",
                    end: "\\}",
                    relevance: 0
                  },
                  {
                    className: "variable",
                    begin: n + "(?=\\s*(-)|$)",
                    endsParent: !0,
                    relevance: 0
                  },
                  // eat spaces (not newlines) so we can find
                  // types or variables
                  {
                    begin: /(?=[^\n])\s/,
                    relevance: 0
                  }
                ]
              }
            ]
          }
        ),
        e.C_BLOCK_COMMENT_MODE,
        e.C_LINE_COMMENT_MODE
      ]
    }, y = [
      e.APOS_STRING_MODE,
      e.QUOTE_STRING_MODE,
      f,
      R,
      I,
      A,
      e.REGEXP_MODE
    ];
    i.contains = y.concat({
      // we need to pair up {} inside our subst to prevent
      // it from ending too early by matching another }
      begin: /\{/,
      end: /\}/,
      keywords: t,
      contains: [
        "self"
      ].concat(y)
    });
    let M = [].concat(b, i.contains), l = M.concat([
      // eat recursive parens in sub expressions
      {
        begin: /\(/,
        end: /\)/,
        keywords: t,
        contains: ["self"].concat(M)
      }
    ]), o = {
      className: "params",
      begin: /\(/,
      end: /\)/,
      excludeBegin: !0,
      excludeEnd: !0,
      keywords: t,
      contains: l
    };
    return {
      name: "Javascript",
      aliases: ["js", "jsx", "mjs", "cjs"],
      keywords: t,
      // this will be extended by TypeScript
      exports: { PARAMS_CONTAINS: l },
      illegal: /#(?![$_A-z])/,
      contains: [
        e.SHEBANG({
          label: "shebang",
          binary: "node",
          relevance: 5
        }),
        {
          label: "use_strict",
          className: "meta",
          relevance: 10,
          begin: /^\s*['"]use (strict|asm)['"]/
        },
        e.APOS_STRING_MODE,
        e.QUOTE_STRING_MODE,
        f,
        R,
        I,
        b,
        A,
        {
          // object attr container
          begin: u(
            /[{,\n]\s*/,
            // we need to look ahead to make sure that we actually have an
            // attribute coming up so we don't steal a comma from a potential
            // "value" container
            //
            // NOTE: this might not work how you think.  We don't actually always
            // enter this mode and stay.  Instead it might merely match `,
            // <comments up next>` and then immediately end after the , because it
            // fails to find any actual attrs. But this still does the job because
            // it prevents the value contain rule from grabbing this instead and
            // prevening this rule from firing when we actually DO have keys.
            m(u(
              // we also need to allow for multiple possible comments inbetween
              // the first key:value pairing
              /(((\/\/.*$)|(\/\*(\*[^/]|[^*])*\*\/))\s*)*/,
              n + "\\s*:"
            ))
          ),
          relevance: 0,
          contains: [
            {
              className: "attr",
              begin: n + m("\\s*:"),
              relevance: 0
            }
          ]
        },
        {
          // "value" container
          begin: "(" + e.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*",
          keywords: "return throw case",
          contains: [
            b,
            e.REGEXP_MODE,
            {
              className: "function",
              // we have to count the parens to make sure we actually have the
              // correct bounding ( ) before the =>.  There could be any number of
              // sub-expressions inside also surrounded by parens.
              begin: "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + e.UNDERSCORE_IDENT_RE + ")\\s*=>",
              returnBegin: !0,
              end: "\\s*=>",
              contains: [
                {
                  className: "params",
                  variants: [
                    {
                      begin: e.UNDERSCORE_IDENT_RE,
                      relevance: 0
                    },
                    {
                      className: null,
                      begin: /\(\s*\)/,
                      skip: !0
                    },
                    {
                      begin: /\(/,
                      end: /\)/,
                      excludeBegin: !0,
                      excludeEnd: !0,
                      keywords: t,
                      contains: l
                    }
                  ]
                }
              ]
            },
            {
              // could be a comma delimited list of params to a function call
              begin: /,/,
              relevance: 0
            },
            {
              className: "",
              begin: /\s/,
              end: /\s*/,
              skip: !0
            },
            {
              // JSX
              variants: [
                { begin: T.begin, end: T.end },
                {
                  begin: s.begin,
                  // we carefully check the opening tag to see if it truly
                  // is a tag and not a false positive
                  "on:begin": s.isTrulyOpeningTag,
                  end: s.end
                }
              ],
              subLanguage: "xml",
              contains: [
                {
                  begin: s.begin,
                  end: s.end,
                  skip: !0,
                  contains: ["self"]
                }
              ]
            }
          ],
          relevance: 0
        },
        {
          className: "function",
          beginKeywords: "function",
          end: /[{;]/,
          excludeEnd: !0,
          keywords: t,
          contains: [
            "self",
            e.inherit(e.TITLE_MODE, { begin: n }),
            o
          ],
          illegal: /%/
        },
        {
          // prevent this from getting swallowed up by function
          // since they appear "function like"
          beginKeywords: "while if switch catch for"
        },
        {
          className: "function",
          // we have to count the parens to make sure we actually have the correct
          // bounding ( ).  There could be any number of sub-expressions inside
          // also surrounded by parens.
          begin: e.UNDERSCORE_IDENT_RE + "\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
          // end parens
          returnBegin: !0,
          contains: [
            o,
            e.inherit(e.TITLE_MODE, { begin: n })
          ]
        },
        // hack: prevents detection of keywords in some circumstances
        // .keyword()
        // $keyword = x
        {
          variants: [
            { begin: "\\." + n },
            { begin: "\\$" + n }
          ],
          relevance: 0
        },
        {
          // ES6 class
          className: "class",
          beginKeywords: "class",
          end: /[{;=]/,
          excludeEnd: !0,
          illegal: /[:"[\]]/,
          contains: [
            { beginKeywords: "extends" },
            e.UNDERSCORE_TITLE_MODE
          ]
        },
        {
          begin: /\b(?=constructor)/,
          end: /[{;]/,
          excludeEnd: !0,
          contains: [
            e.inherit(e.TITLE_MODE, { begin: n }),
            "self",
            o
          ]
        },
        {
          begin: "(get|set)\\s+(?=" + n + "\\()",
          end: /\{/,
          keywords: "get set",
          contains: [
            e.inherit(e.TITLE_MODE, { begin: n }),
            { begin: /\(\)/ },
            // eat to avoid empty params
            o
          ]
        },
        {
          begin: /\$[(.]/
          // relevance booster for a pattern common to JS libs: `$(something)` and `$.something`
        }
      ]
    };
  }
  r(k, "javascript");
  p.exports = k;
});

export {
  P as a
};
