var ERRORCLASS = "error";
function wordRegexp(r) {
  return RegExp("^((" + r.join(")|(") + "))\\b", "i");
}
var singleOperators = /* @__PURE__ */ RegExp("^[\\+\\-\\*/%&\\\\|\\^~<>!]"), singleDelimiters = /* @__PURE__ */ RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]"), doubleOperators = /* @__PURE__ */ RegExp("^((==)|(<>)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))"), doubleDelimiters = /* @__PURE__ */ RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"), tripleDelimiters = /* @__PURE__ */ RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))"), identifiers = /* @__PURE__ */ RegExp("^[_A-Za-z][_A-Za-z0-9]*"), openingKeywords = [
  "class",
  "module",
  "sub",
  "enum",
  "select",
  "while",
  "if",
  "function",
  "get",
  "set",
  "property",
  "try",
  "structure",
  "synclock",
  "using",
  "with"
], middleKeywords = [
  "else",
  "elseif",
  "case",
  "catch",
  "finally"
], endKeywords = ["next", "loop"], operatorKeywords = [
  "and",
  "andalso",
  "or",
  "orelse",
  "xor",
  "in",
  "not",
  "is",
  "isnot",
  "like"
], wordOperators = wordRegexp(operatorKeywords), commonKeywords = /* @__PURE__ */ "#const.#else.#elseif.#end.#if.#region.addhandler.addressof.alias.as.byref.byval.cbool.cbyte.cchar.cdate.cdbl.cdec.cint.clng.cobj.compare.const.continue.csbyte.cshort.csng.cstr.cuint.culng.cushort.declare.default.delegate.dim.directcast.each.erase.error.event.exit.explicit.false.for.friend.gettype.goto.handles.implements.imports.infer.inherits.interface.isfalse.istrue.lib.me.mod.mustinherit.mustoverride.my.mybase.myclass.namespace.narrowing.new.nothing.notinheritable.notoverridable.of.off.on.operator.option.optional.out.overloads.overridable.overrides.paramarray.partial.private.protected.public.raiseevent.readonly.redim.removehandler.resume.return.shadows.shared.static.step.stop.strict.then.throw.to.true.trycast.typeof.until.until.when.widening.withevents.writeonly".split("."), commontypes = /* @__PURE__ */ "object.boolean.char.string.byte.sbyte.short.ushort.int16.uint16.integer.uinteger.int32.uint32.long.ulong.int64.uint64.decimal.single.double.float.date.datetime.intptr.uintptr".split("."), keywords = wordRegexp(commonKeywords), types = wordRegexp(commontypes), stringPrefixes = '"', opening = wordRegexp(openingKeywords), middle = wordRegexp(middleKeywords), closing = wordRegexp(endKeywords), doubleClosing = wordRegexp(["end"]), doOpening = wordRegexp(["do"]), indentInfo = null;
function indent(r, S) {
  S.currentIndent++;
}
function dedent(r, S) {
  S.currentIndent--;
}
function tokenBase(S, D) {
  if (S.eatSpace()) return null;
  if (S.peek() === "'") return S.skipToEnd(), "comment";
  if (S.match(/^((&H)|(&O))?[0-9\.a-f]/i, false)) {
    var O = false;
    if ((S.match(/^\d*\.\d+F?/i) || S.match(/^\d+\.\d*F?/) || S.match(/^\.\d+F?/)) && (O = true), O) return S.eat(/J/i), "number";
    var k = false;
    if (S.match(/^&H[0-9a-f]+/i) || S.match(/^&O[0-7]+/i) ? k = true : S.match(/^[1-9]\d*F?/) ? (S.eat(/J/i), k = true) : S.match(/^0(?![\dx])/i) && (k = true), k) return S.eat(/L/i), "number";
  }
  return S.match(stringPrefixes) ? (D.tokenize = tokenStringFactory(S.current()), D.tokenize(S, D)) : S.match(tripleDelimiters) || S.match(doubleDelimiters) ? null : S.match(doubleOperators) || S.match(singleOperators) || S.match(wordOperators) ? "operator" : S.match(singleDelimiters) ? null : S.match(doOpening) ? (indent(S, D), D.doInCurrentLine = true, "keyword") : S.match(opening) ? (D.doInCurrentLine ? D.doInCurrentLine = false : indent(S, D), "keyword") : S.match(middle) ? "keyword" : S.match(doubleClosing) ? (dedent(S, D), dedent(S, D), "keyword") : S.match(closing) ? (dedent(S, D), "keyword") : S.match(types) || S.match(keywords) ? "keyword" : S.match(identifiers) ? "variable" : (S.next(), ERRORCLASS);
}
function tokenStringFactory(r) {
  var S = r.length == 1, C = "string";
  return function(w, T) {
    for (; !w.eol(); ) {
      if (w.eatWhile(/[^'"]/), w.match(r)) return T.tokenize = tokenBase, C;
      w.eat(/['"]/);
    }
    return S && (T.tokenize = tokenBase), C;
  };
}
function tokenLexer(S, C) {
  var w = C.tokenize(S, C), T = S.current();
  if (T === ".") return w = C.tokenize(S, C), w === "variable" ? "variable" : ERRORCLASS;
  var E = "[({".indexOf(T);
  return E !== -1 && indent(S, C), indentInfo === "dedent" && dedent(S, C) || (E = "])}".indexOf(T), E !== -1 && dedent(S, C)) ? ERRORCLASS : w;
}
const vb = {
  name: "vb",
  startState: function() {
    return {
      tokenize: tokenBase,
      lastToken: null,
      currentIndent: 0,
      nextLineIndent: 0,
      doInCurrentLine: false
    };
  },
  token: function(r, S) {
    r.sol() && (S.currentIndent += S.nextLineIndent, S.nextLineIndent = 0, S.doInCurrentLine = 0);
    var C = tokenLexer(r, S);
    return S.lastToken = {
      style: C,
      content: r.current()
    }, C;
  },
  indent: function(r, S, C) {
    var w = S.replace(/^\s+|\s+$/g, "");
    return w.match(closing) || w.match(doubleClosing) || w.match(middle) ? C.unit * (r.currentIndent - 1) : r.currentIndent < 0 ? 0 : r.currentIndent * C.unit;
  },
  languageData: {
    closeBrackets: { brackets: [
      "(",
      "[",
      "{",
      '"'
    ] },
    commentTokens: { line: "'" },
    autocomplete: openingKeywords.concat(middleKeywords).concat(endKeywords).concat(operatorKeywords).concat(commonKeywords).concat(commontypes)
  }
};
export {
  vb as t
};
