import { isCrossReference as e, isRuleCall as t } from "../languages/generated/ast.js";
import { getCrossReferenceTerminal as n, getRuleType as r } from "../utils/grammar-utils.js";
//#region ../../node_modules/langium/lib/parser/value-converter.js
var i = class {
	convert(r, i) {
		let a = i.grammarSource;
		if (e(a) && (a = n(a)), t(a)) {
			let e = a.rule.ref;
			if (!e) throw Error("This cst node was not parsed by a rule.");
			return this.runConverter(e, r, i);
		}
		return r;
	}
	runConverter(e, t, n) {
		switch (e.name.toUpperCase()) {
			case "INT": return a.convertInt(t);
			case "STRING": return a.convertString(t);
			case "ID": return a.convertID(t);
		}
		switch (r(e)?.toLowerCase()) {
			case "number": return a.convertNumber(t);
			case "boolean": return a.convertBoolean(t);
			case "bigint": return a.convertBigint(t);
			case "date": return a.convertDate(t);
			default: return t;
		}
	}
}, a;
(function(e) {
	function t(e) {
		let t = "";
		for (let r = 1; r < e.length - 1; r++) {
			let i = e.charAt(r);
			if (i === "\\") {
				let i = e.charAt(++r);
				t += n(i);
			} else t += i;
		}
		return t;
	}
	e.convertString = t;
	function n(e) {
		switch (e) {
			case "b": return "\b";
			case "f": return "\f";
			case "n": return "\n";
			case "r": return "\r";
			case "t": return "	";
			case "v": return "\v";
			case "0": return "\0";
			default: return e;
		}
	}
	function r(e) {
		return e.charAt(0) === "^" ? e.substring(1) : e;
	}
	e.convertID = r;
	function i(e) {
		return parseInt(e);
	}
	e.convertInt = i;
	function a(e) {
		return BigInt(e);
	}
	e.convertBigint = a;
	function o(e) {
		return new Date(e);
	}
	e.convertDate = o;
	function s(e) {
		return Number(e);
	}
	e.convertNumber = s;
	function c(e) {
		return e.toLowerCase() === "true";
	}
	e.convertBoolean = c;
})(a ||= {});
//#endregion
export { i as DefaultValueConverter };
