"use strict";(self.webpackChunkpowerwiki=self.webpackChunkpowerwiki||[]).push([[2449],{92449(e,r,t){t.d(r,{diagram:()=>y});var n=t(67977),a=t(77454),s=(t(22422),t(32178),t(31293)),i=t(86827),l=t(78731),p=(0,l.sB)().RailroadAbnf.parser.LangiumParser,o=(0,i.K)(e=>{const r=e.alternatives.map(m);return 1===r.length?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),m=(0,i.K)(e=>{const r=e.elements.map(c);return 1===r.length?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),u=(0,i.K)(e=>{if(e.includes("*")){const[r,t]=e.split("*");return{min:r?parseInt(r,10):0,max:t?parseInt(t,10):1/0}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),c=(0,i.K)(e=>{const r=d(e.primary);if(!e.repeat)return r;const{min:t,max:n}=u(e.repeat);return 0===t&&1===n?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:n}},"transformElement"),d=(0,i.K)(e=>{switch(e.$type){case"AbnfStringLiteral":case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return o(e.element);case"AbnfOptionalGroup":return{type:"optional",element:o(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),b=(0,i.K)(e=>({name:e.name,definition:o(e.definition)}),"transformRule"),f=(0,i.K)(e=>{(0,a.S)(e,n.db),e.title&&n.db.setTitle(e.title),e.rules.map(e=>n.db.addRule(b(e)))},"populateDb"),y={parser:{parse:(0,i.K)(e=>{n.db.clear(),s.R.debug("[ABNF Parser] Starting Langium parse");const r=p.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new l.zg(r);const t=r.value;s.R.debug("[ABNF Parser] Parsed rules:",t.rules.length),f(t),s.R.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:n.db}},db:n.db,renderer:n.U,styles:n.$}}}]);