import {
  RadarModule,
  createRadarServices
} from "./chunks/mermaid-parser.esm/chunk-5JK2ZFQI.mjs";
import {
  RailroadModule,
  createRailroadServices
} from "./chunks/mermaid-parser.esm/chunk-K6MUF66K.mjs";
import {
  RailroadEbnfModule,
  createRailroadEbnfServices
} from "./chunks/mermaid-parser.esm/chunk-XRWCGVEZ.mjs";
import {
  RailroadAbnfModule,
  createRailroadAbnfServices
} from "./chunks/mermaid-parser.esm/chunk-7Z5WYCAB.mjs";
import {
  RailroadPegModule,
  createRailroadPegServices
} from "./chunks/mermaid-parser.esm/chunk-6FZVZRWD.mjs";
import {
  TreemapModule,
  createTreemapServices
} from "./chunks/mermaid-parser.esm/chunk-33V2TFPT.mjs";
import {
  WardleyModule,
  createWardleyServices
} from "./chunks/mermaid-parser.esm/chunk-Y6E45FVX.mjs";
import {
  CynefinModule,
  createCynefinServices
} from "./chunks/mermaid-parser.esm/chunk-2T73OB2K.mjs";
import {
  GitGraphModule,
  createGitGraphServices
} from "./chunks/mermaid-parser.esm/chunk-RZAHRGXK.mjs";
import {
  InfoModule,
  createInfoServices
} from "./chunks/mermaid-parser.esm/chunk-IYI6ETTS.mjs";
import {
  PacketModule,
  createPacketServices
} from "./chunks/mermaid-parser.esm/chunk-4W2XWMKJ.mjs";
import {
  PieModule,
  createPieServices
} from "./chunks/mermaid-parser.esm/chunk-27K6WKKE.mjs";
import {
  TreeViewModule,
  createTreeViewServices
} from "./chunks/mermaid-parser.esm/chunk-5XZ4DK4T.mjs";
import {
  ArchitectureModule,
  createArchitectureServices
} from "./chunks/mermaid-parser.esm/chunk-O467AACY.mjs";
import {
  EventModelingModule,
  createEventModelingServices
} from "./chunks/mermaid-parser.esm/chunk-HTDLG6IT.mjs";
import {
  AbnfAlternation,
  AbnfConcatenation,
  AbnfElement,
  AbnfGroup,
  AbnfNumVal,
  AbnfOptionalGroup,
  AbnfPrimary,
  AbnfRule,
  AbnfRuleName,
  AbnfStringLiteral,
  AbstractMermaidTokenBuilder,
  AbstractMermaidValueConverter,
  Architecture,
  ArchitectureGrammarGeneratedModule,
  Branch,
  Commit,
  CommonTokenBuilder,
  CommonValueConverter,
  Cynefin,
  CynefinGrammarGeneratedModule,
  DomainBlock,
  DomainItem,
  EbnfChoice,
  EbnfExceptionPostfix,
  EbnfGroup,
  EbnfNonTerminal,
  EbnfOneOrMorePostfix,
  EbnfOptional,
  EbnfOptionalPostfix,
  EbnfPostfix,
  EbnfPrimary,
  EbnfRepetition,
  EbnfRule,
  EbnfSequence,
  EbnfSpecial,
  EbnfTerm,
  EbnfTerminal,
  EbnfZeroOrMorePostfix,
  EmDataEntity,
  EmFrame,
  EventModel,
  EventModelingGeneratedModule,
  GitGraph,
  GitGraphGrammarGeneratedModule,
  Info,
  InfoGrammarGeneratedModule,
  Merge,
  MermaidGeneratedSharedModule,
  Packet,
  PacketBlock,
  PacketGrammarGeneratedModule,
  PegAny,
  PegGroup,
  PegIdentifier,
  PegLiteral,
  PegOrderedChoice,
  PegPrefix,
  PegPrimary,
  PegRule,
  PegSequence,
  PegSuffix,
  Pie,
  PieGrammarGeneratedModule,
  PieSection,
  Radar,
  RadarGrammarGeneratedModule,
  Railroad,
  RailroadAbnf,
  RailroadAbnfGrammarGeneratedModule,
  RailroadChoiceExpr,
  RailroadEbnf,
  RailroadEbnfGrammarGeneratedModule,
  RailroadExpression,
  RailroadGrammarGeneratedModule,
  RailroadNonTerminalExpr,
  RailroadOneOrMoreExpr,
  RailroadOptionalExpr,
  RailroadPeg,
  RailroadPegGrammarGeneratedModule,
  RailroadRule,
  RailroadSequenceExpr,
  RailroadSpecialExpr,
  RailroadTerminalExpr,
  RailroadZeroOrMoreExpr,
  Statement,
  Transition,
  TreeNode,
  TreeView,
  TreeViewGrammarGeneratedModule,
  Treemap,
  TreemapGrammarGeneratedModule,
  Wardley,
  WardleyGrammarGeneratedModule,
  __name,
  isArchitecture,
  isBranch,
  isCommit,
  isCynefin,
  isDomainBlock,
  isDomainItem,
  isEmModelEntityType,
  isEmResetFrame,
  isGitGraph,
  isInfo,
  isMerge,
  isPacket,
  isPacketBlock,
  isPie,
  isPieSection,
  isRailroad,
  isRailroadAbnf,
  isRailroadEbnf,
  isRailroadPeg,
  isTransition,
  isTreemap,
  isWardley
} from "./chunks/mermaid-parser.esm/chunk-36B4POZ4.mjs";

// src/parse.ts
var parsers = {};
var initializers = {
  info: /* @__PURE__ */ __name(async () => {
    const { createInfoServices: createInfoServices2 } = await import("./chunks/mermaid-parser.esm/info-QFOQQBRF.mjs");
    const parser = createInfoServices2().Info.parser.LangiumParser;
    parsers.info = parser;
  }, "info"),
  packet: /* @__PURE__ */ __name(async () => {
    const { createPacketServices: createPacketServices2 } = await import("./chunks/mermaid-parser.esm/packet-FGNDS4OH.mjs");
    const parser = createPacketServices2().Packet.parser.LangiumParser;
    parsers.packet = parser;
  }, "packet"),
  pie: /* @__PURE__ */ __name(async () => {
    const { createPieServices: createPieServices2 } = await import("./chunks/mermaid-parser.esm/pie-YUPJXSLS.mjs");
    const parser = createPieServices2().Pie.parser.LangiumParser;
    parsers.pie = parser;
  }, "pie"),
  treeView: /* @__PURE__ */ __name(async () => {
    const { createTreeViewServices: createTreeViewServices2 } = await import("./chunks/mermaid-parser.esm/treeView-543TCLMP.mjs");
    const parser = createTreeViewServices2().TreeView.parser.LangiumParser;
    parsers.treeView = parser;
  }, "treeView"),
  architecture: /* @__PURE__ */ __name(async () => {
    const { createArchitectureServices: createArchitectureServices2 } = await import("./chunks/mermaid-parser.esm/architecture-LXSXJMMV.mjs");
    const parser = createArchitectureServices2().Architecture.parser.LangiumParser;
    parsers.architecture = parser;
  }, "architecture"),
  gitGraph: /* @__PURE__ */ __name(async () => {
    const { createGitGraphServices: createGitGraphServices2 } = await import("./chunks/mermaid-parser.esm/gitGraph-RPOXWWS7.mjs");
    const parser = createGitGraphServices2().GitGraph.parser.LangiumParser;
    parsers.gitGraph = parser;
  }, "gitGraph"),
  eventmodeling: /* @__PURE__ */ __name(async () => {
    const { createEventModelingServices: createEventModelingServices2 } = await import("./chunks/mermaid-parser.esm/eventmodeling-3TKZ67CO.mjs");
    const parser = createEventModelingServices2().EventModel.parser.LangiumParser;
    parsers.eventmodeling = parser;
  }, "eventmodeling"),
  radar: /* @__PURE__ */ __name(async () => {
    const { createRadarServices: createRadarServices2 } = await import("./chunks/mermaid-parser.esm/radar-XPXPHQQ7.mjs");
    const parser = createRadarServices2().Radar.parser.LangiumParser;
    parsers.radar = parser;
  }, "radar"),
  railroad: /* @__PURE__ */ __name(async () => {
    const { createRailroadServices: createRailroadServices2 } = await import("./chunks/mermaid-parser.esm/railroad-VTOPCF2A.mjs");
    const parser = createRailroadServices2().Railroad.parser.LangiumParser;
    parsers.railroad = parser;
  }, "railroad"),
  railroadEbnf: /* @__PURE__ */ __name(async () => {
    const { createRailroadEbnfServices: createRailroadEbnfServices2 } = await import("./chunks/mermaid-parser.esm/railroad-ebnf-OYQ5POVO.mjs");
    const parser = createRailroadEbnfServices2().RailroadEbnf.parser.LangiumParser;
    parsers.railroadEbnf = parser;
  }, "railroadEbnf"),
  railroadAbnf: /* @__PURE__ */ __name(async () => {
    const { createRailroadAbnfServices: createRailroadAbnfServices2 } = await import("./chunks/mermaid-parser.esm/railroad-abnf-WGHC63JR.mjs");
    const parser = createRailroadAbnfServices2().RailroadAbnf.parser.LangiumParser;
    parsers.railroadAbnf = parser;
  }, "railroadAbnf"),
  railroadPeg: /* @__PURE__ */ __name(async () => {
    const { createRailroadPegServices: createRailroadPegServices2 } = await import("./chunks/mermaid-parser.esm/railroad-peg-X6X7SCMX.mjs");
    const parser = createRailroadPegServices2().RailroadPeg.parser.LangiumParser;
    parsers.railroadPeg = parser;
  }, "railroadPeg"),
  treemap: /* @__PURE__ */ __name(async () => {
    const { createTreemapServices: createTreemapServices2 } = await import("./chunks/mermaid-parser.esm/treemap-YQVZMLZN.mjs");
    const parser = createTreemapServices2().Treemap.parser.LangiumParser;
    parsers.treemap = parser;
  }, "treemap"),
  wardley: /* @__PURE__ */ __name(async () => {
    const { createWardleyServices: createWardleyServices2 } = await import("./chunks/mermaid-parser.esm/wardley-MTJJCXAO.mjs");
    const parser = createWardleyServices2().Wardley.parser.LangiumParser;
    parsers.wardley = parser;
  }, "wardley"),
  cynefin: /* @__PURE__ */ __name(async () => {
    const { createCynefinServices: createCynefinServices2 } = await import("./chunks/mermaid-parser.esm/cynefin-XZUCOWIB.mjs");
    const parser = createCynefinServices2().Cynefin.parser.LangiumParser;
    parsers.cynefin = parser;
  }, "cynefin")
};
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 = class extends Error {
  constructor(result) {
    const lexerErrors = result.lexerErrors.map((err) => {
      const line = err.line !== void 0 && !isNaN(err.line) ? err.line : "?";
      const column = err.column !== void 0 && !isNaN(err.column) ? err.column : "?";
      return `Lexer error on line ${line}, column ${column}: ${err.message}`;
    }).join("\n");
    const parserErrors = result.parserErrors.map((err) => {
      const line = err.token.startLine !== void 0 && !isNaN(err.token.startLine) ? err.token.startLine : "?";
      const column = err.token.startColumn !== void 0 && !isNaN(err.token.startColumn) ? err.token.startColumn : "?";
      return `Parse error on line ${line}, column ${column}: ${err.message}`;
    }).join("\n");
    super(`Parsing failed: ${lexerErrors} ${parserErrors}`);
    this.result = result;
  }
  static {
    __name(this, "MermaidParseError");
  }
};
export {
  AbnfAlternation,
  AbnfConcatenation,
  AbnfElement,
  AbnfGroup,
  AbnfNumVal,
  AbnfOptionalGroup,
  AbnfPrimary,
  AbnfRule,
  AbnfRuleName,
  AbnfStringLiteral,
  AbstractMermaidTokenBuilder,
  AbstractMermaidValueConverter,
  Architecture,
  ArchitectureGrammarGeneratedModule as ArchitectureGeneratedModule,
  ArchitectureModule,
  Branch,
  Commit,
  CommonTokenBuilder,
  CommonValueConverter,
  Cynefin,
  CynefinGrammarGeneratedModule as CynefinGeneratedModule,
  CynefinModule,
  DomainBlock,
  DomainItem,
  EbnfChoice,
  EbnfExceptionPostfix,
  EbnfGroup,
  EbnfNonTerminal,
  EbnfOneOrMorePostfix,
  EbnfOptional,
  EbnfOptionalPostfix,
  EbnfPostfix,
  EbnfPrimary,
  EbnfRepetition,
  EbnfRule,
  EbnfSequence,
  EbnfSpecial,
  EbnfTerm,
  EbnfTerminal,
  EbnfZeroOrMorePostfix,
  EmDataEntity,
  EmFrame,
  EventModel,
  EventModelingGeneratedModule,
  EventModelingModule,
  GitGraph,
  GitGraphGrammarGeneratedModule as GitGraphGeneratedModule,
  GitGraphModule,
  Info,
  InfoGrammarGeneratedModule as InfoGeneratedModule,
  InfoModule,
  Merge,
  MermaidGeneratedSharedModule,
  MermaidParseError,
  Packet,
  PacketBlock,
  PacketGrammarGeneratedModule as PacketGeneratedModule,
  PacketModule,
  PegAny,
  PegGroup,
  PegIdentifier,
  PegLiteral,
  PegOrderedChoice,
  PegPrefix,
  PegPrimary,
  PegRule,
  PegSequence,
  PegSuffix,
  Pie,
  PieGrammarGeneratedModule as PieGeneratedModule,
  PieModule,
  PieSection,
  Radar,
  RadarGrammarGeneratedModule as RadarGeneratedModule,
  RadarModule,
  Railroad,
  RailroadAbnf,
  RailroadAbnfGrammarGeneratedModule as RailroadAbnfGeneratedModule,
  RailroadAbnfModule,
  RailroadChoiceExpr,
  RailroadEbnf,
  RailroadEbnfGrammarGeneratedModule as RailroadEbnfGeneratedModule,
  RailroadEbnfModule,
  RailroadExpression,
  RailroadGrammarGeneratedModule as RailroadGeneratedModule,
  RailroadModule,
  RailroadNonTerminalExpr,
  RailroadOneOrMoreExpr,
  RailroadOptionalExpr,
  RailroadPeg,
  RailroadPegGrammarGeneratedModule as RailroadPegGeneratedModule,
  RailroadPegModule,
  RailroadRule,
  RailroadSequenceExpr,
  RailroadSpecialExpr,
  RailroadTerminalExpr,
  RailroadZeroOrMoreExpr,
  Statement,
  Transition,
  TreeNode,
  TreeView,
  TreeViewGrammarGeneratedModule as TreeViewGeneratedModule,
  TreeViewModule,
  Treemap,
  TreemapGrammarGeneratedModule as TreemapGeneratedModule,
  TreemapModule,
  Wardley,
  WardleyGrammarGeneratedModule as WardleyGeneratedModule,
  WardleyModule,
  createArchitectureServices,
  createCynefinServices,
  createEventModelingServices,
  createGitGraphServices,
  createInfoServices,
  createPacketServices,
  createPieServices,
  createRadarServices,
  createRailroadAbnfServices,
  createRailroadEbnfServices,
  createRailroadPegServices,
  createRailroadServices,
  createTreeViewServices,
  createTreemapServices,
  createWardleyServices,
  isArchitecture,
  isBranch,
  isCommit,
  isCynefin,
  isDomainBlock,
  isDomainItem,
  isEmModelEntityType,
  isEmResetFrame,
  isGitGraph,
  isInfo,
  isMerge,
  isPacket,
  isPacketBlock,
  isPie,
  isPieSection,
  isRailroad,
  isRailroadAbnf,
  isRailroadEbnf,
  isRailroadPeg,
  isTransition,
  isTreemap,
  isWardley,
  parse
};
