import{a,b as u,c as f}from"./chunk-WBKED7LK.js";import"./chunk-AQ7QNAOH.js";import{a as m}from"./chunk-CDENLQJG.js";import{b as p}from"./chunk-GCLFR7RJ.js";import"./chunk-GBAVNUHL.js";import"./chunk-BPMBFFCK.js";import{b as l}from"./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 s}from"./chunk-BG5BKATX.js";import{a as t}from"./chunk-YUSHYV7C.js";import"./chunk-3ZIVKGVJ.js";import"./chunk-OOJM4CTU.js";var v=l().RailroadAbnf.parser.LangiumParser,i=t(e=>{let r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=t(e=>{let r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=t(e=>{if(e.includes("*")){let[n,o]=e.split("*"),c=n?parseInt(n,10):0,d=o?parseInt(o,10):1/0;return{min:c,max:d}}let r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=t(e=>{let r=A(e.primary);if(!e.repeat)return r;let{min:n,max:o}=b(e.repeat);return n===0&&o===1?{type:"optional",element:r}:{type:"repetition",element:r,min:n,max:o}},"transformElement"),A=t(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=t(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=t(e=>{m(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:t(e=>{a.clear(),s.debug("[ABNF Parser] Starting Langium parse");let r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new p(r);let n=r.value;s.debug("[ABNF Parser] Parsed rules:",n.rules.length),h(n),s.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},I={parser:R,db:a,renderer:f,styles:u};export{I as diagram};
