'use strict';

var chunkS6J4BHB3 = require('./chunks/mermaid-parser.core/chunk-S6J4BHB3.js');
var chunkLBM3YZW2 = require('./chunks/mermaid-parser.core/chunk-LBM3YZW2.js');
var chunk76Q3JFCE = require('./chunks/mermaid-parser.core/chunk-76Q3JFCE.js');
var chunkT53DSG4Q = require('./chunks/mermaid-parser.core/chunk-T53DSG4Q.js');
var chunkO7ZBX7Z2 = require('./chunks/mermaid-parser.core/chunk-O7ZBX7Z2.js');
var chunkLHMN2FUI = require('./chunks/mermaid-parser.core/chunk-LHMN2FUI.js');
var chunkFWNWRKHM = require('./chunks/mermaid-parser.core/chunk-FWNWRKHM.js');
var chunkFPAJGGOC = require('./chunks/mermaid-parser.core/chunk-FPAJGGOC.js');

// src/parse.ts
var parsers = {};
var initializers = {
  info: /* @__PURE__ */ chunkFPAJGGOC.__name(async () => {
    const { createInfoServices: createInfoServices2 } = await Promise.resolve().then(function () { return require('./chunks/mermaid-parser.core/info-NVLQJR56.js'); });
    const parser = createInfoServices2().Info.parser.LangiumParser;
    parsers.info = parser;
  }, "info"),
  packet: /* @__PURE__ */ chunkFPAJGGOC.__name(async () => {
    const { createPacketServices: createPacketServices2 } = await Promise.resolve().then(function () { return require('./chunks/mermaid-parser.core/packet-BFZMPI3H.js'); });
    const parser = createPacketServices2().Packet.parser.LangiumParser;
    parsers.packet = parser;
  }, "packet"),
  pie: /* @__PURE__ */ chunkFPAJGGOC.__name(async () => {
    const { createPieServices: createPieServices2 } = await Promise.resolve().then(function () { return require('./chunks/mermaid-parser.core/pie-7BOR55EZ.js'); });
    const parser = createPieServices2().Pie.parser.LangiumParser;
    parsers.pie = parser;
  }, "pie"),
  architecture: /* @__PURE__ */ chunkFPAJGGOC.__name(async () => {
    const { createArchitectureServices: createArchitectureServices2 } = await Promise.resolve().then(function () { return require('./chunks/mermaid-parser.core/architecture-U656AL7Q.js'); });
    const parser = createArchitectureServices2().Architecture.parser.LangiumParser;
    parsers.architecture = parser;
  }, "architecture"),
  gitGraph: /* @__PURE__ */ chunkFPAJGGOC.__name(async () => {
    const { createGitGraphServices: createGitGraphServices2 } = await Promise.resolve().then(function () { return require('./chunks/mermaid-parser.core/gitGraph-F6HP7TQM.js'); });
    const parser = createGitGraphServices2().GitGraph.parser.LangiumParser;
    parsers.gitGraph = parser;
  }, "gitGraph"),
  radar: /* @__PURE__ */ chunkFPAJGGOC.__name(async () => {
    const { createRadarServices: createRadarServices2 } = await Promise.resolve().then(function () { return require('./chunks/mermaid-parser.core/radar-NHE76QYJ.js'); });
    const parser = createRadarServices2().Radar.parser.LangiumParser;
    parsers.radar = parser;
  }, "radar"),
  treemap: /* @__PURE__ */ chunkFPAJGGOC.__name(async () => {
    const { createTreemapServices: createTreemapServices2 } = await Promise.resolve().then(function () { return require('./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;
}
chunkFPAJGGOC.__name(parse, "parse");
var MermaidParseError = 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;
  }
  static {
    chunkFPAJGGOC.__name(this, "MermaidParseError");
  }
};

exports.GitGraphModule = chunkS6J4BHB3.GitGraphModule;
exports.createGitGraphServices = chunkS6J4BHB3.createGitGraphServices;
exports.InfoModule = chunkLBM3YZW2.InfoModule;
exports.createInfoServices = chunkLBM3YZW2.createInfoServices;
exports.PacketModule = chunk76Q3JFCE.PacketModule;
exports.createPacketServices = chunk76Q3JFCE.createPacketServices;
exports.PieModule = chunkT53DSG4Q.PieModule;
exports.createPieServices = chunkT53DSG4Q.createPieServices;
exports.ArchitectureModule = chunkO7ZBX7Z2.ArchitectureModule;
exports.createArchitectureServices = chunkO7ZBX7Z2.createArchitectureServices;
exports.RadarModule = chunkLHMN2FUI.RadarModule;
exports.createRadarServices = chunkLHMN2FUI.createRadarServices;
exports.TreemapModule = chunkFWNWRKHM.TreemapModule;
exports.createTreemapServices = chunkFWNWRKHM.createTreemapServices;
exports.AbstractMermaidTokenBuilder = chunkFPAJGGOC.AbstractMermaidTokenBuilder;
exports.AbstractMermaidValueConverter = chunkFPAJGGOC.AbstractMermaidValueConverter;
exports.Architecture = chunkFPAJGGOC.Architecture;
exports.ArchitectureGeneratedModule = chunkFPAJGGOC.ArchitectureGeneratedModule;
exports.Branch = chunkFPAJGGOC.Branch;
exports.Commit = chunkFPAJGGOC.Commit;
exports.CommonValueConverter = chunkFPAJGGOC.CommonValueConverter;
exports.GitGraph = chunkFPAJGGOC.GitGraph;
exports.GitGraphGeneratedModule = chunkFPAJGGOC.GitGraphGeneratedModule;
exports.Info = chunkFPAJGGOC.Info;
exports.InfoGeneratedModule = chunkFPAJGGOC.InfoGeneratedModule;
exports.Merge = chunkFPAJGGOC.Merge;
exports.MermaidGeneratedSharedModule = chunkFPAJGGOC.MermaidGeneratedSharedModule;
exports.Packet = chunkFPAJGGOC.Packet;
exports.PacketBlock = chunkFPAJGGOC.PacketBlock;
exports.PacketGeneratedModule = chunkFPAJGGOC.PacketGeneratedModule;
exports.Pie = chunkFPAJGGOC.Pie;
exports.PieGeneratedModule = chunkFPAJGGOC.PieGeneratedModule;
exports.PieSection = chunkFPAJGGOC.PieSection;
exports.Radar = chunkFPAJGGOC.Radar;
exports.RadarGeneratedModule = chunkFPAJGGOC.RadarGeneratedModule;
exports.Statement = chunkFPAJGGOC.Statement;
exports.Treemap = chunkFPAJGGOC.Treemap;
exports.TreemapGeneratedModule = chunkFPAJGGOC.TreemapGeneratedModule;
exports.isArchitecture = chunkFPAJGGOC.isArchitecture;
exports.isBranch = chunkFPAJGGOC.isBranch;
exports.isCommit = chunkFPAJGGOC.isCommit;
exports.isGitGraph = chunkFPAJGGOC.isGitGraph;
exports.isInfo = chunkFPAJGGOC.isInfo;
exports.isMerge = chunkFPAJGGOC.isMerge;
exports.isPacket = chunkFPAJGGOC.isPacket;
exports.isPacketBlock = chunkFPAJGGOC.isPacketBlock;
exports.isPie = chunkFPAJGGOC.isPie;
exports.isPieSection = chunkFPAJGGOC.isPieSection;
exports.isTreemap = chunkFPAJGGOC.isTreemap;
exports.MermaidParseError = MermaidParseError;
exports.parse = parse;
