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

// ../node_modules/highlight.js/lib/languages/r.js
var u = l((_, c) => {
  function m(e) {
    return e ? typeof e == "string" ? e : e.source : null;
  }
  a(m, "source");
  function g(e) {
    return r("(?=", e, ")");
  }
  a(g, "lookahead");
  function r(...e) {
    return e.map((t) => m(t)).join("");
  }
  a(r, "concat");
  function b(e) {
    let s = /(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/, t = /[a-zA-Z][a-zA-Z_0-9]*/;
    return {
      name: "R",
      // only in Haskell, not R
      illegal: /->/,
      keywords: {
        $pattern: s,
        keyword: "function if in break next repeat else for while",
        literal: "NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",
        built_in: (
          // Builtin constants
          "LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"
        )
      },
      compilerExtensions: [
        // allow beforeMatch to act as a "qualifier" for the match
        // the full match begin must be [beforeMatch][begin]
        (n, d) => {
          if (!n.beforeMatch) return;
          if (n.starts) throw new Error("beforeMatch cannot be used with starts");
          let i = Object.assign({}, n);
          Object.keys(n).forEach((o) => {
            delete n[o];
          }), n.begin = r(i.beforeMatch, g(i.begin)), n.starts = {
            relevance: 0,
            contains: [
              Object.assign(i, { endsParent: !0 })
            ]
          }, n.relevance = 0, delete i.beforeMatch;
        }
      ],
      contains: [
        // Roxygen comments
        e.COMMENT(
          /#'/,
          /$/,
          {
            contains: [
              {
                // Handle `@examples` separately to cause all subsequent code
                // until the next `@`-tag on its own line to be kept as-is,
                // preventing highlighting. This code is example R code, so nested
                // doctags shouldn’t be treated as such. See
                // `test/markup/r/roxygen.txt` for an example.
                className: "doctag",
                begin: "@examples",
                starts: {
                  contains: [
                    { begin: /\n/ },
                    {
                      begin: /#'\s*(?=@[a-zA-Z]+)/,
                      endsParent: !0
                    },
                    {
                      begin: /#'/,
                      end: /$/,
                      excludeBegin: !0
                    }
                  ]
                }
              },
              {
                // Handle `@param` to highlight the parameter name following
                // after.
                className: "doctag",
                begin: "@param",
                end: /$/,
                contains: [
                  {
                    className: "variable",
                    variants: [
                      { begin: s },
                      { begin: /`(?:\\.|[^`\\])+`/ }
                    ],
                    endsParent: !0
                  }
                ]
              },
              {
                className: "doctag",
                begin: /@[a-zA-Z]+/
              },
              {
                className: "meta-keyword",
                begin: /\\[a-zA-Z]+/
              }
            ]
          }
        ),
        e.HASH_COMMENT_MODE,
        {
          className: "string",
          contains: [e.BACKSLASH_ESCAPE],
          variants: [
            e.END_SAME_AS_BEGIN({ begin: /[rR]"(-*)\(/, end: /\)(-*)"/ }),
            e.END_SAME_AS_BEGIN({ begin: /[rR]"(-*)\{/, end: /\}(-*)"/ }),
            e.END_SAME_AS_BEGIN({ begin: /[rR]"(-*)\[/, end: /\](-*)"/ }),
            e.END_SAME_AS_BEGIN({ begin: /[rR]'(-*)\(/, end: /\)(-*)'/ }),
            e.END_SAME_AS_BEGIN({ begin: /[rR]'(-*)\{/, end: /\}(-*)'/ }),
            e.END_SAME_AS_BEGIN({ begin: /[rR]'(-*)\[/, end: /\](-*)'/ }),
            { begin: '"', end: '"', relevance: 0 },
            { begin: "'", end: "'", relevance: 0 }
          ]
        },
        {
          className: "number",
          relevance: 0,
          beforeMatch: /([^a-zA-Z0-9._])/,
          // not part of an identifier
          variants: [
            // TODO: replace with negative look-behind when available
            // { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/ },
            // { begin: /(?<![a-zA-Z0-9._])0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/ },
            // { begin: /(?<![a-zA-Z0-9._])(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/ }
            {
              // Special case: only hexadecimal binary powers can contain fractions.
              match: /0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/
            },
            {
              match: /0[xX][0-9a-fA-F]+([pP][+-]?\d+)?[Li]?/
            },
            {
              match: /(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?[Li]?/
            }
          ]
        },
        {
          // infix operator
          begin: "%",
          end: "%"
        },
        // relevance boost for assignment
        {
          begin: r(t, "\\s+<-\\s+")
        },
        {
          // escaped identifier
          begin: "`",
          end: "`",
          contains: [
            { begin: /\\./ }
          ]
        }
      ]
    };
  }
  a(b, "r");
  c.exports = b;
});

export {
  u as a
};
