import { AbstractMermaidTokenBuilder, AbstractMermaidValueConverter, Architecture, ArchitectureGrammarGeneratedModule, Branch, Commit, CommonValueConverter, GitGraph, GitGraphGrammarGeneratedModule, Info, InfoGrammarGeneratedModule, Merge, MermaidGeneratedSharedModule, Packet, PacketBlock, PacketGrammarGeneratedModule, Pie, PieGrammarGeneratedModule, PieSection, Radar, RadarGrammarGeneratedModule, Statement, Treemap, TreemapGrammarGeneratedModule, __name, isArchitecture, isBranch, isCommit, isGitGraph, isInfo, isMerge, isPacket, isPacketBlock, isPie, isPieSection, isTreemap } from "./chunks/mermaid-parser.core/chunk-TCCFYFTB.js";
import { ArchitectureModule, createArchitectureServices } from "./chunks/mermaid-parser.core/chunk-UMXZTB3W.js";
import { GitGraphModule, createGitGraphServices } from "./chunks/mermaid-parser.core/chunk-4F5CHEZ2.js";
import { InfoModule, createInfoServices } from "./chunks/mermaid-parser.core/chunk-FRFDVMJY.js";
import { PacketModule, createPacketServices } from "./chunks/mermaid-parser.core/chunk-SJTYNZTY.js";
import { PieModule, createPieServices } from "./chunks/mermaid-parser.core/chunk-PL6DKKU2.js";
import { RadarModule, createRadarServices } from "./chunks/mermaid-parser.core/chunk-TQ3KTPDO.js";
import { TreemapModule, createTreemapServices } from "./chunks/mermaid-parser.core/chunk-B2363JML.js";
var parsers = {}, initializers = {
	info: /* @__PURE__ */ __name(async () => {
		let { createInfoServices: S } = await import("./chunks/mermaid-parser.core/info-VBDWY6EO.js");
		parsers.info = S().Info.parser.LangiumParser;
	}, "info"),
	packet: /* @__PURE__ */ __name(async () => {
		let { createPacketServices: S } = await import("./chunks/mermaid-parser.core/packet-DYOGHKS2.js");
		parsers.packet = S().Packet.parser.LangiumParser;
	}, "packet"),
	pie: /* @__PURE__ */ __name(async () => {
		let { createPieServices: S } = await import("./chunks/mermaid-parser.core/pie-VRWISCQL.js");
		parsers.pie = S().Pie.parser.LangiumParser;
	}, "pie"),
	architecture: /* @__PURE__ */ __name(async () => {
		let { createArchitectureServices: S } = await import("./chunks/mermaid-parser.core/architecture-7HQA4BMR.js");
		parsers.architecture = S().Architecture.parser.LangiumParser;
	}, "architecture"),
	gitGraph: /* @__PURE__ */ __name(async () => {
		let { createGitGraphServices: S } = await import("./chunks/mermaid-parser.core/gitGraph-G5XIXVHT.js");
		parsers.gitGraph = S().GitGraph.parser.LangiumParser;
	}, "gitGraph"),
	radar: /* @__PURE__ */ __name(async () => {
		let { createRadarServices: S } = await import("./chunks/mermaid-parser.core/radar-ZZBFDIW7.js");
		parsers.radar = S().Radar.parser.LangiumParser;
	}, "radar"),
	treemap: /* @__PURE__ */ __name(async () => {
		let { createTreemapServices: S } = await import("./chunks/mermaid-parser.core/treemap-GDKQZRPO.js");
		parsers.treemap = S().Treemap.parser.LangiumParser;
	}, "treemap")
};
async function parse(S, Z) {
	let Q = initializers[S];
	if (!Q) throw Error(`Unknown diagram type: ${S}`);
	parsers[S] || await Q();
	let $ = parsers[S].parse(Z);
	if ($.lexerErrors.length > 0 || $.parserErrors.length > 0) throw new MermaidParseError($);
	return $.value;
}
__name(parse, "parse");
var MermaidParseError = class extends Error {
	constructor(S) {
		let Z = S.lexerErrors.map((S) => S.message).join("\n"), Q = S.parserErrors.map((S) => S.message).join("\n");
		super(`Parsing failed: ${Z} ${Q}`), this.result = S;
	}
	static #e = __name(this, "MermaidParseError");
};
export { parse };
