import{a,b as m,c as p}from"./chunk-WBKED7LK.js";import"./chunk-AQ7QNAOH.js";import{a as s}from"./chunk-CDENLQJG.js";import{b as l}from"./chunk-GCLFR7RJ.js";import"./chunk-GBAVNUHL.js";import"./chunk-BPMBFFCK.js";import"./chunk-OMKCQORZ.js";import{b as i}from"./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 n}from"./chunk-BG5BKATX.js";import{a as t}from"./chunk-YUSHYV7C.js";import"./chunk-3ZIVKGVJ.js";import"./chunk-OOJM4CTU.js";var f=i().RailroadPeg.parser.LangiumParser,c=t(e=>{let r=e.alternatives.map(d);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformOrderedChoice"),d=t(e=>{let r=e.elements.map(P);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformSequence"),P=t(e=>{let r=g(e.suffix);return e.operator?{type:"special",text:e.operator==="&"?`&${u(r)}`:`!${u(r)}`}:r},"transformPrefix"),u=t(e=>{switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}},"nodeToLabel"),g=t(e=>{let r=v(e.primary);if(!e.operator)return r;switch(e.operator){case"?":return{type:"optional",element:r};case"*":return{type:"repetition",element:r,min:0,max:1/0};case"+":return{type:"repetition",element:r,min:1,max:1/0};default:throw new Error(`Unsupported PEG suffix operator: ${e.operator}`)}},"transformSuffix"),v=t(e=>{switch(e.$type){case"PegLiteral":return{type:"terminal",value:e.value};case"PegIdentifier":return{type:"nonterminal",name:e.name};case"PegGroup":return c(e.element);case"PegAny":return{type:"special",text:e.dot};default:throw new Error(`Unsupported PEG primary node: ${e.$type}`)}},"transformPrimary"),y=t(e=>({name:e.name,definition:c(e.definition)}),"transformRule"),h=t(e=>{s(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(y(r)))},"populateDb"),b={parse:t(e=>{a.clear(),n.debug("[PEG Parser] Starting Langium parse");let r=f.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new l(r);let o=r.value;n.debug("[PEG Parser] Parsed rules:",o.rules.length),h(o),n.debug("[PEG Parser] Parse complete")},"parse"),parser:{yy:a}},R={parser:b,db:a,renderer:p,styles:m};export{R as diagram};
