var _a;
import { GitGraphModule, createGitGraphServices } from "./dist-chunks-mermaid-parser.core-chunk-S6J4BHB3.js";
import { InfoModule, createInfoServices } from "./dist-chunks-mermaid-parser.core-chunk-LBM3YZW2.js";
import { PacketModule, createPacketServices } from "./dist-chunks-mermaid-parser.core-chunk-76Q3JFCE.js";
import { PieModule, createPieServices } from "./dist-chunks-mermaid-parser.core-chunk-T53DSG4Q.js";
import { ArchitectureModule, createArchitectureServices } from "./dist-chunks-mermaid-parser.core-chunk-O7ZBX7Z2.js";
import { RadarModule, createRadarServices } from "./dist-chunks-mermaid-parser.core-chunk-LHMN2FUI.js";
import { TreemapModule, createTreemapServices } from "./dist-chunks-mermaid-parser.core-chunk-FWNWRKHM.js";
import { __name } from "./dist-chunks-mermaid-parser.core-chunk-FPAJGGOC.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-FPAJGGOC.js";
var parsers = {};
var initializers = {
  info: /* @__PURE__ */ __name(async () => {
    const { createInfoServices: createInfoServices2 } = await import("./dist-chunks-mermaid-parser.core-info-NVLQJR56.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-BFZMPI3H.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-7BOR55EZ.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-U656AL7Q.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-F6HP7TQM.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-NHE76QYJ.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-KMMF4GRG.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
