import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{t}from"./chunk-X3CZISLH-DX9Il8sT.js";import"./chunk-WYO6CB5R-BrkmBSXu.js";import"./chunk-VAUOI2AC-BWKY1JwH.js";import{n,r,t as i}from"./chunk-MOJQB5TN-DJqvBbWO.js";import{t as a}from"./chunk-JWPE2WC7-DVXcaiue.js";import{n as o}from"./chunk-5TONJI2A-DOX2waSJ.js";import{t as s}from"./mermaid-parser.core-h2Myc9xB.js";var c=o().Railroad.parser.LangiumParser,l=e(e=>{switch(e.$type){case`RailroadTerminalExpr`:return{type:`terminal`,value:e.value};case`RailroadNonTerminalExpr`:return{type:`nonterminal`,name:e.name};case`RailroadSpecialExpr`:return{type:`special`,text:e.text};case`RailroadSequenceExpr`:{let t=e.elements.map(l);return t.length===1?t[0]:{type:`sequence`,elements:t}}case`RailroadChoiceExpr`:{let t=e.alternatives.map(l);return t.length===1?t[0]:{type:`choice`,alternatives:t}}case`RailroadOptionalExpr`:return{type:`optional`,element:l(e.element)};case`RailroadOneOrMoreExpr`:return{type:`repetition`,element:l(e.element),min:1,max:1/0};case`RailroadZeroOrMoreExpr`:return{type:`repetition`,element:l(e.element),min:0,max:1/0};default:throw Error(`Unsupported railroad expression: ${e.$type}`)}},`transformExpression`),u=e(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),d=e(e=>{a(e,i),e.title&&i.setTitle(e.title),e.rules.map(e=>i.addRule(u(e)))},`populateDb`),f={parser:{parse:e(e=>{i.clear(),t.debug(`[Railroad Parser] Starting Langium parse`);let n=c.parse(e);if(n.lexerErrors.length>0||n.parserErrors.length>0)throw new s(n);let r=n.value;t.debug(`[Railroad Parser] Parsed rules:`,r.rules.length),d(r),t.debug(`[Railroad Parser] Parse complete`)},`parse`),parser:{yy:i}},db:i,renderer:r,styles:n};export{f as diagram};