import{n as e}from"./chunk-5TONJI2A.CElyBWeO.js";import{n as t}from"./chunk-Y2CYZVJY.DsF7k-Jl.js";import{t as n}from"./src.DMVfaFne.js";import"./chunk-I66GZJ75.DE9AwV3O.js";import"./chunk-3NCLNEKW.ceKyfhHo.js";import{n as r,r as i,t as a}from"./chunk-6Q2QTUOP.BnFhCSJK.js";import{t as o}from"./chunk-JWPE2WC7.A3RzWITa.js";import{t as s}from"./mermaid-parser.core.CG5TU4Z9.js";var c=e().Railroad.parser.LangiumParser,l=t(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=t(e=>({name:e.name,definition:l(e.definition)}),`transformRule`),d=t(e=>{o(e,a),e.title&&a.setTitle(e.title),e.rules.map(e=>a.addRule(u(e)))},`populateDb`),f={parser:{parse:t(e=>{a.clear(),n.debug(`[Railroad Parser] Starting Langium parse`);let t=c.parse(e);if(t.lexerErrors.length>0||t.parserErrors.length>0)throw new s(t);let r=t.value;n.debug(`[Railroad Parser] Parsed rules:`,r.rules.length),d(r),n.debug(`[Railroad Parser] Parse complete`)},`parse`),parser:{yy:a}},db:a,renderer:i,styles:r};export{f as diagram};