UNPKG

ranui

Version:

A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.

96 lines (95 loc) 2.65 kB
import { m as i, t as l } from "./mermaid-parser.core-uIDZYuBu.js"; import { n } from "./chunk-Y2CYZVJY-0JxdZxki.js"; import { m as o } from "./src-DtRLxcYO.js"; import "./chunk-WYO6CB5R-DDHkKowO.js"; import "./chunk-VAUOI2AC-izt0o4id.js"; import { n as p, r as u, t as a } from "./chunk-MOJQB5TN-BC46HDyu.js"; import { t as f } from "./chunk-JWPE2WC7-CGEmUMMZ.js"; var c = i().RailroadAbnf.parser.LangiumParser, m = /* @__PURE__ */ n((e) => { const r = e.alternatives.map(d); return r.length === 1 ? r[0] : { type: "choice", alternatives: r }; }, "transformAlternation"), d = /* @__PURE__ */ n((e) => { const r = e.elements.map(g); return r.length === 1 ? r[0] : { type: "sequence", elements: r }; }, "transformConcatenation"), v = /* @__PURE__ */ n((e) => { if (e.includes("*")) { const [t, s] = e.split("*"); return { min: t ? parseInt(t, 10) : 0, max: s ? parseInt(s, 10) : 1 / 0 }; } const r = parseInt(e, 10); return { min: r, max: r }; }, "parseRepeat"), g = /* @__PURE__ */ n((e) => { const r = b(e.primary); if (!e.repeat) return r; const { min: t, max: s } = v(e.repeat); return t === 0 && s === 1 ? { type: "optional", element: r } : { type: "repetition", element: r, min: t, max: s }; }, "transformElement"), b = /* @__PURE__ */ n((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 m(e.element); case "AbnfOptionalGroup": return { type: "optional", element: m(e.element) }; default: throw new Error(`Unsupported ABNF primary node: ${e.$type}`); } }, "transformPrimary"), y = /* @__PURE__ */ n((e) => ({ name: e.name, definition: m(e.definition) }), "transformRule"), A = /* @__PURE__ */ n((e) => { f(e, a), e.title && a.setTitle(e.title), e.rules.map((r) => a.addRule(y(r))); }, "populateDb"), w = { parser: { parse: /* @__PURE__ */ n((e) => { a.clear(), o.debug("[ABNF Parser] Starting Langium parse"); const r = c.parse(e); if (r.lexerErrors.length > 0 || r.parserErrors.length > 0) throw new l(r); const t = r.value; o.debug("[ABNF Parser] Parsed rules:", t.rules.length), A(t), o.debug("[ABNF Parser] Parse complete"); }, "parse"), parser: { yy: a } }, db: a, renderer: u, styles: p }; export { w as diagram };