"use strict";(self.webpackChunkpowerwiki=self.webpackChunkpowerwiki||[]).push([[3729],{13729(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),p=t(78731),o=(0,p.WG)().RailroadEbnf.parser.LangiumParser,l=(0,i.K)(e=>{const r=e.alternatives.map(m);return 1===r.length?r[0]:{type:"choice",alternatives:r}},"transformChoice"),m=(0,i.K)(e=>{const r=e.elements.map(f);return 1===r.length?r[0]:{type:"sequence",elements:r}},"transformSequence"),u=(0,i.K)(e=>{switch(e.$type){case"EbnfTerminal":return{type:"terminal",value:e.value};case"EbnfNonTerminal":return{type:"nonterminal",name:e.name};case"EbnfSpecial":return{type:"special",text:e.text};case"EbnfGroup":return l(e.element);case"EbnfOptional":return{type:"optional",element:l(e.element)};case"EbnfRepetition":return{type:"repetition",element:l(e.element),min:0,max:1/0};default:throw new Error(`Unsupported EBNF primary node: ${e.$type}`)}},"transformPrimary"),c=(0,i.K)((e,r)=>{switch(r.$type){case"EbnfOptionalPostfix":return{type:"optional",element:e};case"EbnfZeroOrMorePostfix":return{type:"repetition",element:e,min:0,max:1/0};case"EbnfOneOrMorePostfix":return{type:"repetition",element:e,min:1,max:1/0};case"EbnfExceptionPostfix":return{type:"sequence",elements:[e,{type:"terminal",value:"-"},u(r.except)]};default:throw new Error(`Unsupported EBNF postfix node: ${r.$type}`)}},"transformPostfix"),f=(0,i.K)(e=>e.postfixes.reduce((e,r)=>c(e,r),u(e.base)),"transformTerm"),d=(0,i.K)(e=>({name:e.name,definition:l(e.definition)}),"transformRule"),b=(0,i.K)(e=>{(0,a.S)(e,n.db),e.title&&n.db.setTitle(e.title),e.rules.map(e=>n.db.addRule(d(e)))},"populateDb"),y={parser:{parse:(0,i.K)(e=>{n.db.clear(),s.R.debug("[EBNF Parser] Starting Langium parse");const r=o.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new p.zg(r);const t=r.value;s.R.debug("[EBNF Parser] Parsed rules:",t.rules.length),b(t),s.R.debug("[EBNF Parser] Parse complete")},"parse"),parser:{yy:n.db}},db:n.db,renderer:n.U,styles:n.$}}}]);