function wordRegexp(e) {
  return /* @__PURE__ */ RegExp("^((" + e.join(")|(") + "))\\b");
}
var wordOperators = wordRegexp([
  "and",
  "or",
  "not",
  "is"
]), commonKeywords = /* @__PURE__ */ "as.assert.break.class.continue.def.del.elif.else.except.finally.for.from.global.if.import.lambda.pass.raise.return.try.while.with.yield.in.False.True".split("."), commonBuiltins = /* @__PURE__ */ "abs.all.any.bin.bool.bytearray.callable.chr.classmethod.compile.complex.delattr.dict.dir.divmod.enumerate.eval.filter.float.format.frozenset.getattr.globals.hasattr.hash.help.hex.id.input.int.isinstance.issubclass.iter.len.list.locals.map.max.memoryview.min.next.object.oct.open.ord.pow.property.range.repr.reversed.round.set.setattr.slice.sorted.staticmethod.str.sum.super.tuple.type.vars.zip.__import__.NotImplemented.Ellipsis.__debug__".split(".");
function top(e) {
  return e.scopes[e.scopes.length - 1];
}
function mkPython(a) {
  for (var o = "error", s = a.delimiters || a.singleDelimiters || /^[\(\)\[\]\{\}@,:`=;\.\\]/, c = [
    a.singleOperators,
    a.doubleOperators,
    a.doubleDelimiters,
    a.tripleDelimiters,
    a.operators || /^([-+*/%\/&|^]=?|[<>=]+|\/\/=?|\*\*=?|!=|[~!@]|\.\.\.)/
  ], l = 0; l < c.length; l++) c[l] || c.splice(l--, 1);
  var u = a.hangingIndent, d = commonKeywords, f = commonBuiltins;
  a.extra_keywords != null && (d = d.concat(a.extra_keywords)), a.extra_builtins != null && (f = f.concat(a.extra_builtins));
  var p = !(a.version && Number(a.version) < 3);
  if (p) {
    var m = a.identifiers || /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*/;
    d = d.concat([
      "nonlocal",
      "None",
      "aiter",
      "anext",
      "async",
      "await",
      "breakpoint",
      "match",
      "case"
    ]), f = f.concat([
      "ascii",
      "bytes",
      "exec",
      "print"
    ]);
    var h = RegExp(`^(([rbuf]|(br)|(rb)|(fr)|(rf))?('{3}|"{3}|['"]))`, "i");
  } else {
    var m = a.identifiers || /^[_A-Za-z][_A-Za-z0-9]*/;
    d = d.concat(["exec", "print"]), f = f.concat([
      "apply",
      "basestring",
      "buffer",
      "cmp",
      "coerce",
      "execfile",
      "file",
      "intern",
      "long",
      "raw_input",
      "reduce",
      "reload",
      "unichr",
      "unicode",
      "xrange",
      "None"
    ]);
    var h = RegExp(`^(([rubf]|(ur)|(br))?('{3}|"{3}|['"]))`, "i");
  }
  var g = wordRegexp(d), _ = wordRegexp(f);
  function v(e, t) {
    var n = e.sol() && t.lastToken != "\\";
    if (n && (t.indent = e.indentation()), n && top(t).type == "py") {
      var r = top(t).offset;
      if (e.eatSpace()) {
        var a2 = e.indentation();
        return a2 > r ? S(e, t) : a2 < r && w(e, t) && e.peek() != "#" && (t.errorToken = true), null;
      } else {
        var s2 = y(e, t);
        return r > 0 && w(e, t) && (s2 += " " + o), s2;
      }
    }
    return y(e, t);
  }
  function y(e, n, r) {
    if (e.eatSpace()) return null;
    if (!r && e.match(/^#.*/)) return "comment";
    if (e.match(/^[0-9\.]/, false)) {
      var i = false;
      if (e.match(/^[\d_]*\.\d+(e[\+\-]?\d+)?/i) && (i = true), e.match(/^[\d_]+\.\d*/) && (i = true), e.match(/^\.\d+/) && (i = true), i) return e.eat(/J/i), "number";
      var a2 = false;
      if (e.match(/^0x[0-9a-f_]+/i) && (a2 = true), e.match(/^0b[01_]+/i) && (a2 = true), e.match(/^0o[0-7_]+/i) && (a2 = true), e.match(/^[1-9][\d_]*(e[\+\-]?[\d_]+)?/) && (e.eat(/J/i), a2 = true), e.match(/^0(?![\dx])/i) && (a2 = true), a2) return e.eat(/L/i), "number";
    }
    if (e.match(h)) return e.current().toLowerCase().indexOf("f") === -1 ? (n.tokenize = x(e.current(), n.tokenize), n.tokenize(e, n)) : (n.tokenize = b(e.current(), n.tokenize), n.tokenize(e, n));
    for (var l2 = 0; l2 < c.length; l2++) if (e.match(c[l2])) return "operator";
    return e.match(s) ? "punctuation" : n.lastToken == "." && e.match(m) ? "property" : e.match(g) || e.match(wordOperators) ? "keyword" : e.match(_) ? "builtin" : e.match(/^(self|cls)\b/) ? "self" : e.match(m) ? n.lastToken == "def" || n.lastToken == "class" ? "def" : "variable" : (e.next(), r ? null : o);
  }
  function b(e, t) {
    for (; "rubf".indexOf(e.charAt(0).toLowerCase()) >= 0; ) e = e.substr(1);
    var n = e.length == 1, r = "string";
    function i(e2) {
      return function(t2, n2) {
        var r2 = y(t2, n2, true);
        return r2 == "punctuation" && (t2.current() == "{" ? n2.tokenize = i(e2 + 1) : t2.current() == "}" && (e2 > 1 ? n2.tokenize = i(e2 - 1) : n2.tokenize = s2)), r2;
      };
    }
    function s2(s3, c2) {
      for (; !s3.eol(); ) if (s3.eatWhile(/[^'"\{\}\\]/), s3.eat("\\")) {
        if (s3.next(), n && s3.eol()) return r;
      } else if (s3.match(e)) return c2.tokenize = t, r;
      else if (s3.match("{{")) return r;
      else if (s3.match("{", false)) return c2.tokenize = i(0), s3.current() ? r : c2.tokenize(s3, c2);
      else if (s3.match("}}")) return r;
      else if (s3.match("}")) return o;
      else s3.eat(/['"]/);
      if (n) {
        if (a.singleLineStringErrors) return o;
        c2.tokenize = t;
      }
      return r;
    }
    return s2.isString = true, s2;
  }
  function x(e, t) {
    for (; "rubf".indexOf(e.charAt(0).toLowerCase()) >= 0; ) e = e.substr(1);
    var n = e.length == 1, r = "string";
    function i(i2, s2) {
      for (; !i2.eol(); ) if (i2.eatWhile(/[^'"\\]/), i2.eat("\\")) {
        if (i2.next(), n && i2.eol()) return r;
      } else if (i2.match(e)) return s2.tokenize = t, r;
      else i2.eat(/['"]/);
      if (n) {
        if (a.singleLineStringErrors) return o;
        s2.tokenize = t;
      }
      return r;
    }
    return i.isString = true, i;
  }
  function S(e, t) {
    for (; top(t).type != "py"; ) t.scopes.pop();
    t.scopes.push({
      offset: top(t).offset + e.indentUnit,
      type: "py",
      align: null
    });
  }
  function C(e, t, n) {
    var r = e.match(/^[\s\[\{\(]*(?:#|$)/, false) ? null : e.column() + 1;
    t.scopes.push({
      offset: t.indent + (u || e.indentUnit),
      type: n,
      align: r
    });
  }
  function w(e, t) {
    for (var n = e.indentation(); t.scopes.length > 1 && top(t).offset > n; ) {
      if (top(t).type != "py") return true;
      t.scopes.pop();
    }
    return top(t).offset != n;
  }
  function T(e, t) {
    e.sol() && (t.beginningOfLine = true, t.dedent = false);
    var n = t.tokenize(e, t), r = e.current();
    if (t.beginningOfLine && r == "@") return e.match(m, false) ? "meta" : p ? "operator" : o;
    if (/\S/.test(r) && (t.beginningOfLine = false), (n == "variable" || n == "builtin") && t.lastToken == "meta" && (n = "meta"), (r == "pass" || r == "return") && (t.dedent = true), r == "lambda" && (t.lambda = true), r == ":" && !t.lambda && top(t).type == "py" && e.match(/^\s*(?:#|$)/, false) && S(e, t), r.length == 1 && !/string|comment/.test(n)) {
      var a2 = "[({".indexOf(r);
      if (a2 != -1 && C(e, t, "])}".slice(a2, a2 + 1)), a2 = "])}".indexOf(r), a2 != -1) if (top(t).type == r) t.indent = t.scopes.pop().offset - (u || e.indentUnit);
      else return o;
    }
    return t.dedent && e.eol() && top(t).type == "py" && t.scopes.length > 1 && t.scopes.pop(), n;
  }
  return {
    name: "python",
    startState: function() {
      return {
        tokenize: v,
        scopes: [{
          offset: 0,
          type: "py",
          align: null
        }],
        indent: 0,
        lastToken: null,
        lambda: false,
        dedent: 0
      };
    },
    token: function(e, t) {
      var n = t.errorToken;
      n && (t.errorToken = false);
      var r = T(e, t);
      return r && r != "comment" && (t.lastToken = r == "keyword" || r == "punctuation" ? e.current() : r), r == "punctuation" && (r = null), e.eol() && t.lambda && (t.lambda = false), n ? o : r;
    },
    indent: function(e, t, n) {
      if (e.tokenize != v) return e.tokenize.isString ? null : 0;
      var r = top(e), a2 = r.type == t.charAt(0) || r.type == "py" && !e.dedent && /^(else:|elif |except |finally:)/.test(t);
      return r.align == null ? r.offset - (a2 ? u || n.unit : 0) : r.align - (a2 ? 1 : 0);
    },
    languageData: {
      autocomplete: commonKeywords.concat(commonBuiltins).concat(["exec", "print"]),
      indentOnInput: /^\s*([\}\]\)]|else:|elif |except |finally:)$/,
      commentTokens: { line: "#" },
      closeBrackets: { brackets: [
        "(",
        "[",
        "{",
        "'",
        '"',
        "'''",
        '"""'
      ] }
    }
  };
}
var words = function(e) {
  return e.split(" ");
};
mkPython({});
const cython = mkPython({ extra_keywords: words("by cdef cimport cpdef ctypedef enum except extern gil include nogil property public readonly struct union DEF IF ELIF ELSE") });
export {
  mkPython as n,
  cython as t
};
