import{a,b as m,c as d}from"./chunk-UITSOMYB.mjs";import{a as s}from"./chunk-JQRUD6KW.mjs";import{b as p}from"./chunk-DMV4VAQV.mjs";import"./chunk-HNC4WDU7.mjs";import"./chunk-SATU7PGQ.mjs";import"./chunk-224SPVON.mjs";import{b as n}from"./chunk-EQFTRU2I.mjs";import"./chunk-E5QJAATJ.mjs";import"./chunk-66DQ2XMT.mjs";import"./chunk-D6VWDJW2.mjs";import"./chunk-BI6VK774.mjs";import"./chunk-XNMVGMAZ.mjs";import"./chunk-4RFN2BYJ.mjs";import"./chunk-FWYVLQTC.mjs";import"./chunk-RRFMTAIC.mjs";import"./chunk-TZUXEDM2.mjs";import"./chunk-OIYT25JQ.mjs";import"./chunk-NV3KIAZN.mjs";import"./chunk-L5GCOVLC.mjs";import"./chunk-Y3FQM624.mjs";import"./chunk-KEUXMURM.mjs";import{b as t}from"./chunk-LIEV3EAG.mjs";import{a as o}from"./chunk-AQ6EADP3.mjs";var u=n().Railroad.parser.LangiumParser,i=o(r=>{switch(r.$type){case"RailroadTerminalExpr":return{type:"terminal",value:r.value};case"RailroadNonTerminalExpr":return{type:"nonterminal",name:r.name};case"RailroadSpecialExpr":return{type:"special",text:r.text};case"RailroadSequenceExpr":{let e=r.elements.map(i);return e.length===1?e[0]:{type:"sequence",elements:e}}case"RailroadChoiceExpr":{let e=r.alternatives.map(i);return e.length===1?e[0]:{type:"choice",alternatives:e}}case"RailroadOptionalExpr":return{type:"optional",element:i(r.element)};case"RailroadOneOrMoreExpr":return{type:"repetition",element:i(r.element),min:1,max:1/0};case"RailroadZeroOrMoreExpr":return{type:"repetition",element:i(r.element),min:0,max:1/0};default:throw new Error(`Unsupported railroad expression: ${r.$type}`)}},"transformExpression"),c=o(r=>({name:r.name,definition:i(r.definition)}),"transformRule"),y=o(r=>{s(r,a),r.title&&a.setTitle(r.title),r.rules.map(e=>a.addRule(c(e)))},"populateDb"),R={parse:o(r=>{a.clear(),t.debug("[Railroad Parser] Starting Langium parse");let e=u.parse(r);if(e.lexerErrors.length>0||e.parserErrors.length>0)throw new p(e);let l=e.value;t.debug("[Railroad Parser] Parsed rules:",l.rules.length),y(l),t.debug("[Railroad Parser] Parse complete")},"parse"),parser:{yy:a}};var E={parser:R,db:a,renderer:d,styles:m},b=E;export{b as default,E as diagram};
