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