import { defaultLexerErrorProvider as e } from "../../../chevrotain/lib/src/scan/lexer_errors_public.js";
import { Lexer as t } from "../../../chevrotain/lib/src/scan/lexer_public.js";
import "../../../chevrotain/lib/src/api.js";
//#region ../../node_modules/langium/lib/parser/lexer.js
var n = class {
	buildUnexpectedCharactersMessage(t, n, r, i, a) {
		return e.buildUnexpectedCharactersMessage(t, n, r, i, a);
	}
	buildUnableToPopLexerModeMessage(t) {
		return e.buildUnableToPopLexerModeMessage(t);
	}
}, r = { mode: "full" }, i = class {
	constructor(e) {
		this.errorMessageProvider = e.parser.LexerErrorMessageProvider, this.tokenBuilder = e.parser.TokenBuilder;
		let n = this.tokenBuilder.buildTokens(e.Grammar, { caseInsensitive: e.LanguageMetaData.caseInsensitive });
		this.tokenTypes = this.toTokenTypeDictionary(n), this.chevrotainLexer = new t(s(n) ? Object.values(n) : n, {
			positionTracking: "full",
			skipValidations: e.LanguageMetaData.mode === "production",
			errorMessageProvider: this.errorMessageProvider
		});
	}
	get definition() {
		return this.tokenTypes;
	}
	tokenize(e, t = r) {
		let n = this.chevrotainLexer.tokenize(e);
		return {
			tokens: n.tokens,
			errors: n.errors,
			hidden: n.groups.hidden ?? [],
			report: this.tokenBuilder.flushLexingReport?.(e)
		};
	}
	toTokenTypeDictionary(e) {
		if (s(e)) return e;
		let t = o(e) ? Object.values(e.modes).flat() : e, n = {};
		return t.forEach((e) => n[e.name] = e), n;
	}
};
function a(e) {
	return Array.isArray(e) && (e.length === 0 || "name" in e[0]);
}
function o(e) {
	return e && "modes" in e && "defaultMode" in e;
}
function s(e) {
	return !a(e) && !o(e);
}
//#endregion
export { i as DefaultLexer, n as DefaultLexerErrorMessageProvider };
