import { createDefaultCoreModule as e, createDefaultSharedCoreModule as t } from "../../../../../langium/lib/default-module.js";
import { inject as n } from "../../../../../langium/lib/dependency-injection.js";
import { EmptyFileSystem as r } from "../../../../../langium/lib/workspace/file-system-provider.js";
import { AbstractMermaidTokenBuilder as i, AbstractMermaidValueConverter as a, MermaidGeneratedSharedModule as o, TreemapGrammarGeneratedModule as s, __name as c } from "./chunk-K5T4RW27.js";
//#region ../../node_modules/@mermaid-js/parser/dist/chunks/mermaid-parser.core/chunk-LIHQZDEY.mjs
var l = class extends i {
	static {
		c(this, "TreemapTokenBuilder");
	}
	constructor() {
		super(["treemap"]);
	}
}, u = /classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/, d = class extends a {
	static {
		c(this, "TreemapValueConverter");
	}
	runCustomConverter(e, t, n) {
		if (e.name === "NUMBER2") return parseFloat(t.replace(/,/g, ""));
		if (e.name === "SEPARATOR" || e.name === "STRING2") return t.substring(1, t.length - 1);
		if (e.name === "INDENTATION") return t.length;
		if (e.name === "ClassDef") {
			if (typeof t != "string") return t;
			let e = u.exec(t);
			if (e) return {
				$type: "ClassDefStatement",
				className: e[1],
				styleText: e[2] || void 0
			};
		}
	}
};
function f(e) {
	let t = e.validation.TreemapValidator, n = e.validation.ValidationRegistry;
	if (n) {
		let e = { Treemap: t.checkSingleRoot.bind(t) };
		n.register(e, t);
	}
}
c(f, "registerValidationChecks");
var p = class {
	static {
		c(this, "TreemapValidator");
	}
	checkSingleRoot(e, t) {
		let n;
		for (let r of e.TreemapRows) r.item && (n === void 0 && r.indent === void 0 ? n = 0 : (r.indent === void 0 || n !== void 0 && n >= parseInt(r.indent, 10)) && t("error", "Multiple root nodes are not allowed in a treemap.", {
			node: r,
			property: "item"
		}));
	}
}, m = {
	parser: {
		TokenBuilder: /* @__PURE__ */ c(() => new l(), "TokenBuilder"),
		ValueConverter: /* @__PURE__ */ c(() => new d(), "ValueConverter")
	},
	validation: { TreemapValidator: /* @__PURE__ */ c(() => new p(), "TreemapValidator") }
};
function h(i = r) {
	let a = n(t(i), o), c = n(e({ shared: a }), s, m);
	return a.ServiceRegistry.register(c), f(c), {
		shared: a,
		Treemap: c
	};
}
c(h, "createTreemapServices");
//#endregion
export { m as TreemapModule, h as createTreemapServices };
