import{a,b as p,c as u}from"./chunk-WBKED7LK.js";import"./chunk-AQ7QNAOH.js";import{a as l}from"./chunk-CDENLQJG.js";import{b as m}from"./chunk-GCLFR7RJ.js";import{b as s}from"./chunk-GBAVNUHL.js";import"./chunk-BPMBFFCK.js";import"./chunk-OMKCQORZ.js";import"./chunk-NPTHKJ2T.js";import"./chunk-PNOROMQC.js";import"./chunk-YLPW272G.js";import"./chunk-EE6VSO4L.js";import"./chunk-KIKOYZ3Y.js";import"./chunk-AYJOBZGG.js";import"./chunk-72QLSRFG.js";import"./chunk-RZZP2ERR.js";import"./chunk-SR3GFKQL.js";import"./chunk-6FD75OKF.js";import"./chunk-QY6Y4V6I.js";import"./chunk-O4AR42YJ.js";import"./chunk-F4FWBINX.js";import"./chunk-2LQZINQI.js";import{b as i}from"./chunk-BG5BKATX.js";import{a as n}from"./chunk-YUSHYV7C.js";import"./chunk-3ZIVKGVJ.js";import"./chunk-OOJM4CTU.js";var d=s().Railroad.parser.LangiumParser,t=n(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 r=e.elements.map(t);return r.length===1?r[0]:{type:"sequence",elements:r}}case"RailroadChoiceExpr":{let r=e.alternatives.map(t);return r.length===1?r[0]:{type:"choice",alternatives:r}}case"RailroadOptionalExpr":return{type:"optional",element:t(e.element)};case"RailroadOneOrMoreExpr":return{type:"repetition",element:t(e.element),min:1,max:1/0};case"RailroadZeroOrMoreExpr":return{type:"repetition",element:t(e.element),min:0,max:1/0};default:throw new Error(`Unsupported railroad expression: ${e.$type}`)}},"transformExpression"),c=n(e=>({name:e.name,definition:t(e.definition)}),"transformRule"),f=n(e=>{l(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(c(r)))},"populateDb"),g={parse:n(e=>{a.clear(),i.debug("[Railroad Parser] Starting Langium parse");let r=d.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new m(r);let o=r.value;i.debug("[Railroad Parser] Parsed rules:",o.rules.length),f(o),i.debug("[Railroad Parser] Parse complete")},"parse"),parser:{yy:a}},y={parser:g,db:a,renderer:u,styles:p},w=y;export{w as default,y as diagram};
