var _a;
import { GitGraphModule, createGitGraphServices } from "./dist-chunks-mermaid-parser.core-chunk-BN7GFLIU.js";
import { InfoModule, createInfoServices } from "./dist-chunks-mermaid-parser.core-chunk-T44TD3VJ.js";
import { PacketModule, createPacketServices } from "./dist-chunks-mermaid-parser.core-chunk-KMC2YHZD.js";
import { PieModule, createPieServices } from "./dist-chunks-mermaid-parser.core-chunk-WFWHJNB7.js";
import { ArchitectureModule, createArchitectureServices } from "./dist-chunks-mermaid-parser.core-chunk-JEIROHC2.js";
import { RadarModule, createRadarServices } from "./dist-chunks-mermaid-parser.core-chunk-WFRQ32O7.js";
import { TreemapModule, createTreemapServices } from "./dist-chunks-mermaid-parser.core-chunk-XRWGC2XP.js";
import { __name } from "./dist-chunks-mermaid-parser.core-chunk-4KMFLZZN.js";
import { AbstractMermaidTokenBuilder, AbstractMermaidValueConverter, Architecture, ArchitectureGeneratedModule, Branch, Commit, CommonValueConverter, GitGraph, GitGraphGeneratedModule, Info, InfoGeneratedModule, Merge, MermaidGeneratedSharedModule, Packet, PacketBlock, PacketGeneratedModule, Pie, PieGeneratedModule, PieSection, Radar, RadarGeneratedModule, Statement, Treemap, TreemapGeneratedModule, isArchitecture, isBranch, isCommit, isGitGraph, isInfo, isMerge, isPacket, isPacketBlock, isPie, isPieSection, isTreemap } from "./dist-chunks-mermaid-parser.core-chunk-4KMFLZZN.js";
var parsers = {};
var initializers = {
  info: /* @__PURE__ */ __name(async () => {
    const { createInfoServices: createInfoServices2 } = await import("./dist-chunks-mermaid-parser.core-info-63CPKGFF.js");
    const parser = createInfoServices2().Info.parser.LangiumParser;
    parsers.info = parser;
  }, "info"),
  packet: /* @__PURE__ */ __name(async () => {
    const { createPacketServices: createPacketServices2 } = await import("./dist-chunks-mermaid-parser.core-packet-HUATNLJX.js");
    const parser = createPacketServices2().Packet.parser.LangiumParser;
    parsers.packet = parser;
  }, "packet"),
  pie: /* @__PURE__ */ __name(async () => {
    const { createPieServices: createPieServices2 } = await import("./dist-chunks-mermaid-parser.core-pie-WTHONI2E.js");
    const parser = createPieServices2().Pie.parser.LangiumParser;
    parsers.pie = parser;
  }, "pie"),
  architecture: /* @__PURE__ */ __name(async () => {
    const { createArchitectureServices: createArchitectureServices2 } = await import("./dist-chunks-mermaid-parser.core-architecture-O4VJ6CD3.js");
    const parser = createArchitectureServices2().Architecture.parser.LangiumParser;
    parsers.architecture = parser;
  }, "architecture"),
  gitGraph: /* @__PURE__ */ __name(async () => {
    const { createGitGraphServices: createGitGraphServices2 } = await import("./dist-chunks-mermaid-parser.core-gitGraph-ZV4HHKMB.js");
    const parser = createGitGraphServices2().GitGraph.parser.LangiumParser;
    parsers.gitGraph = parser;
  }, "gitGraph"),
  radar: /* @__PURE__ */ __name(async () => {
    const { createRadarServices: createRadarServices2 } = await import("./dist-chunks-mermaid-parser.core-radar-NJJJXTRR.js");
    const parser = createRadarServices2().Radar.parser.LangiumParser;
    parsers.radar = parser;
  }, "radar"),
  treemap: /* @__PURE__ */ __name(async () => {
    const { createTreemapServices: createTreemapServices2 } = await import("./dist-chunks-mermaid-parser.core-treemap-75Q7IDZK.js");
    const parser = createTreemapServices2().Treemap.parser.LangiumParser;
    parsers.treemap = parser;
  }, "treemap")
};
async function parse(diagramType, text) {
  const initializer = initializers[diagramType];
  if (!initializer) {
    throw new Error(`Unknown diagram type: ${diagramType}`);
  }
  if (!parsers[diagramType]) {
    await initializer();
  }
  const parser = parsers[diagramType];
  const result = parser.parse(text);
  if (result.lexerErrors.length > 0 || result.parserErrors.length > 0) {
    throw new MermaidParseError(result);
  }
  return result.value;
}
__name(parse, "parse");
var MermaidParseError = (_a = class extends Error {
  constructor(result) {
    const lexerErrors = result.lexerErrors.map((err) => err.message).join("\n");
    const parserErrors = result.parserErrors.map((err) => err.message).join("\n");
    super(`Parsing failed: ${lexerErrors} ${parserErrors}`);
    this.result = result;
  }
}, __name(_a, "MermaidParseError"), _a);
export {
  AbstractMermaidTokenBuilder,
  AbstractMermaidValueConverter,
  Architecture,
  ArchitectureGeneratedModule,
  ArchitectureModule,
  Branch,
  Commit,
  CommonValueConverter,
  GitGraph,
  GitGraphGeneratedModule,
  GitGraphModule,
  Info,
  InfoGeneratedModule,
  InfoModule,
  Merge,
  MermaidGeneratedSharedModule,
  MermaidParseError,
  Packet,
  PacketBlock,
  PacketGeneratedModule,
  PacketModule,
  Pie,
  PieGeneratedModule,
  PieModule,
  PieSection,
  Radar,
  RadarGeneratedModule,
  RadarModule,
  Statement,
  Treemap,
  TreemapGeneratedModule,
  TreemapModule,
  createArchitectureServices,
  createGitGraphServices,
  createInfoServices,
  createPacketServices,
  createPieServices,
  createRadarServices,
  createTreemapServices,
  isArchitecture,
  isBranch,
  isCommit,
  isGitGraph,
  isInfo,
  isMerge,
  isPacket,
  isPacketBlock,
  isPie,
  isPieSection,
  isTreemap,
  parse
};
//# sourceMappingURL=dist-mermaid-parser.core.js.map
