import { a7 as ui, a8 as gi, ap as Xt, ao as xi, a9 as di, aa as pi, _ as a, l as Ft, aU as fi, ab as mi, av as yi, aB as Ct, ae as bi, aD as Vt, aE as Ai, ba as Si, bb as wi, bc as Bt } from "./index-Bh-wTBlD.js";
import { t as Ci } from "./init-DjUOC4st-C8Nwz6AJ.js";
import { h as ki } from "./ordinal-DfAQgscy-BEJTu10r.js";
import { f as Ot } from "./linear-h6L3lVRp-DOzK9CUG.js";
function _i(t, i, e) {
  t = +t, i = +i, e = (h = arguments.length) < 2 ? (i = t, t = 0, 1) : h < 3 ? 1 : +e;
  for (var s = -1, h = Math.max(0, Math.ceil((i - t) / e)) | 0, g = new Array(h); ++s < h; )
    g[s] = t + s * e;
  return g;
}
function yt() {
  var t = ki().unknown(void 0), i = t.domain, e = t.range, s = 0, h = 1, g, u, p = !1, k = 0, D = 0, L = 0.5;
  delete t.unknown;
  function w() {
    var f = i().length, v = h < s, R = v ? h : s, P = v ? s : h;
    g = (P - R) / Math.max(1, f - k + D * 2), p && (g = Math.floor(g)), R += (P - R - g * (f - k)) * L, u = g * (1 - k), p && (R = Math.round(R), u = Math.round(u));
    var E = _i(f).map(function(d) {
      return R + g * d;
    });
    return e(v ? E.reverse() : E);
  }
  return t.domain = function(f) {
    return arguments.length ? (i(f), w()) : i();
  }, t.range = function(f) {
    return arguments.length ? ([s, h] = f, s = +s, h = +h, w()) : [s, h];
  }, t.rangeRound = function(f) {
    return [s, h] = f, s = +s, h = +h, p = !0, w();
  }, t.bandwidth = function() {
    return u;
  }, t.step = function() {
    return g;
  }, t.round = function(f) {
    return arguments.length ? (p = !!f, w()) : p;
  }, t.padding = function(f) {
    return arguments.length ? (k = Math.min(1, D = +f), w()) : k;
  }, t.paddingInner = function(f) {
    return arguments.length ? (k = Math.min(1, f), w()) : k;
  }, t.paddingOuter = function(f) {
    return arguments.length ? (D = +f, w()) : D;
  }, t.align = function(f) {
    return arguments.length ? (L = Math.max(0, Math.min(1, f)), w()) : L;
  }, t.copy = function() {
    return yt(i(), [s, h]).round(p).paddingInner(k).paddingOuter(D).align(L);
  }, Ci.apply(w(), arguments);
}
var bt = function() {
  var t = /* @__PURE__ */ a(function(B, o, l, c) {
    for (l = l || {}, c = B.length; c--; l[B[c]] = o) ;
    return l;
  }, "o"), i = [1, 10, 12, 14, 16, 18, 19, 21, 23], e = [2, 6], s = [1, 3], h = [1, 5], g = [1, 6], u = [1, 7], p = [1, 5, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], k = [1, 25], D = [1, 26], L = [1, 28], w = [1, 29], f = [1, 30], v = [1, 31], R = [1, 32], P = [1, 33], E = [1, 34], d = [1, 35], _ = [1, 36], r = [1, 37], W = [1, 43], X = [1, 42], F = [1, 47], V = [1, 50], S = [1, 10, 12, 14, 16, 18, 19, 21, 23, 34, 35, 36], H = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36], m = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 27, 28, 34, 35, 36, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], A = [1, 64], M = {
    trace: /* @__PURE__ */ a(function() {
    }, "trace"),
    yy: {},
    symbols_: { error: 2, start: 3, eol: 4, XYCHART: 5, chartConfig: 6, document: 7, CHART_ORIENTATION: 8, statement: 9, title: 10, text: 11, X_AXIS: 12, parseXAxis: 13, Y_AXIS: 14, parseYAxis: 15, LINE: 16, plotData: 17, BAR: 18, acc_title: 19, acc_title_value: 20, acc_descr: 21, acc_descr_value: 22, acc_descr_multiline_value: 23, SQUARE_BRACES_START: 24, commaSeparatedNumbers: 25, SQUARE_BRACES_END: 26, NUMBER_WITH_DECIMAL: 27, COMMA: 28, xAxisData: 29, bandData: 30, ARROW_DELIMITER: 31, commaSeparatedTexts: 32, yAxisData: 33, NEWLINE: 34, SEMI: 35, EOF: 36, alphaNum: 37, STR: 38, MD_STR: 39, alphaNumToken: 40, AMP: 41, NUM: 42, ALPHA: 43, PLUS: 44, EQUALS: 45, MULT: 46, DOT: 47, BRKT: 48, MINUS: 49, UNDERSCORE: 50, $accept: 0, $end: 1 },
    terminals_: { 2: "error", 5: "XYCHART", 8: "CHART_ORIENTATION", 10: "title", 12: "X_AXIS", 14: "Y_AXIS", 16: "LINE", 18: "BAR", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "SQUARE_BRACES_START", 26: "SQUARE_BRACES_END", 27: "NUMBER_WITH_DECIMAL", 28: "COMMA", 31: "ARROW_DELIMITER", 34: "NEWLINE", 35: "SEMI", 36: "EOF", 38: "STR", 39: "MD_STR", 41: "AMP", 42: "NUM", 43: "ALPHA", 44: "PLUS", 45: "EQUALS", 46: "MULT", 47: "DOT", 48: "BRKT", 49: "MINUS", 50: "UNDERSCORE" },
    productions_: [0, [3, 2], [3, 3], [3, 2], [3, 1], [6, 1], [7, 0], [7, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 3], [9, 2], [9, 3], [9, 2], [9, 2], [9, 1], [17, 3], [25, 3], [25, 1], [13, 1], [13, 2], [13, 1], [29, 1], [29, 3], [30, 3], [32, 3], [32, 1], [15, 1], [15, 2], [15, 1], [33, 3], [4, 1], [4, 1], [4, 1], [11, 1], [11, 1], [11, 1], [37, 1], [37, 2], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1], [40, 1]],
    performAction: /* @__PURE__ */ a(function(B, o, l, c, y, n, I) {
      var x = n.length - 1;
      switch (y) {
        case 5:
          c.setOrientation(n[x]);
          break;
        case 9:
          c.setDiagramTitle(n[x].text.trim());
          break;
        case 12:
          c.setLineData({ text: "", type: "text" }, n[x]);
          break;
        case 13:
          c.setLineData(n[x - 1], n[x]);
          break;
        case 14:
          c.setBarData({ text: "", type: "text" }, n[x]);
          break;
        case 15:
          c.setBarData(n[x - 1], n[x]);
          break;
        case 16:
          this.$ = n[x].trim(), c.setAccTitle(this.$);
          break;
        case 17:
        case 18:
          this.$ = n[x].trim(), c.setAccDescription(this.$);
          break;
        case 19:
          this.$ = n[x - 1];
          break;
        case 20:
          this.$ = [Number(n[x - 2]), ...n[x]];
          break;
        case 21:
          this.$ = [Number(n[x])];
          break;
        case 22:
          c.setXAxisTitle(n[x]);
          break;
        case 23:
          c.setXAxisTitle(n[x - 1]);
          break;
        case 24:
          c.setXAxisTitle({ type: "text", text: "" });
          break;
        case 25:
          c.setXAxisBand(n[x]);
          break;
        case 26:
          c.setXAxisRangeData(Number(n[x - 2]), Number(n[x]));
          break;
        case 27:
          this.$ = n[x - 1];
          break;
        case 28:
          this.$ = [n[x - 2], ...n[x]];
          break;
        case 29:
          this.$ = [n[x]];
          break;
        case 30:
          c.setYAxisTitle(n[x]);
          break;
        case 31:
          c.setYAxisTitle(n[x - 1]);
          break;
        case 32:
          c.setYAxisTitle({ type: "text", text: "" });
          break;
        case 33:
          c.setYAxisRangeData(Number(n[x - 2]), Number(n[x]));
          break;
        case 37:
          this.$ = { text: n[x], type: "text" };
          break;
        case 38:
          this.$ = { text: n[x], type: "text" };
          break;
        case 39:
          this.$ = { text: n[x], type: "markdown" };
          break;
        case 40:
          this.$ = n[x];
          break;
        case 41:
          this.$ = n[x - 1] + "" + n[x];
          break;
      }
    }, "anonymous"),
    table: [t(i, e, { 3: 1, 4: 2, 7: 4, 5: s, 34: h, 35: g, 36: u }), { 1: [3] }, t(i, e, { 4: 2, 7: 4, 3: 8, 5: s, 34: h, 35: g, 36: u }), t(i, e, { 4: 2, 7: 4, 6: 9, 3: 10, 5: s, 8: [1, 11], 34: h, 35: g, 36: u }), { 1: [2, 4], 9: 12, 10: [1, 13], 12: [1, 14], 14: [1, 15], 16: [1, 16], 18: [1, 17], 19: [1, 18], 21: [1, 19], 23: [1, 20] }, t(p, [2, 34]), t(p, [2, 35]), t(p, [2, 36]), { 1: [2, 1] }, t(i, e, { 4: 2, 7: 4, 3: 21, 5: s, 34: h, 35: g, 36: u }), { 1: [2, 3] }, t(p, [2, 5]), t(i, [2, 7], { 4: 22, 34: h, 35: g, 36: u }), { 11: 23, 37: 24, 38: k, 39: D, 40: 27, 41: L, 42: w, 43: f, 44: v, 45: R, 46: P, 47: E, 48: d, 49: _, 50: r }, { 11: 39, 13: 38, 24: W, 27: X, 29: 40, 30: 41, 37: 24, 38: k, 39: D, 40: 27, 41: L, 42: w, 43: f, 44: v, 45: R, 46: P, 47: E, 48: d, 49: _, 50: r }, { 11: 45, 15: 44, 27: F, 33: 46, 37: 24, 38: k, 39: D, 40: 27, 41: L, 42: w, 43: f, 44: v, 45: R, 46: P, 47: E, 48: d, 49: _, 50: r }, { 11: 49, 17: 48, 24: V, 37: 24, 38: k, 39: D, 40: 27, 41: L, 42: w, 43: f, 44: v, 45: R, 46: P, 47: E, 48: d, 49: _, 50: r }, { 11: 52, 17: 51, 24: V, 37: 24, 38: k, 39: D, 40: 27, 41: L, 42: w, 43: f, 44: v, 45: R, 46: P, 47: E, 48: d, 49: _, 50: r }, { 20: [1, 53] }, { 22: [1, 54] }, t(S, [2, 18]), { 1: [2, 2] }, t(S, [2, 8]), t(S, [2, 9]), t(H, [2, 37], { 40: 55, 41: L, 42: w, 43: f, 44: v, 45: R, 46: P, 47: E, 48: d, 49: _, 50: r }), t(H, [2, 38]), t(H, [2, 39]), t(m, [2, 40]), t(m, [2, 42]), t(m, [2, 43]), t(m, [2, 44]), t(m, [2, 45]), t(m, [2, 46]), t(m, [2, 47]), t(m, [2, 48]), t(m, [2, 49]), t(m, [2, 50]), t(m, [2, 51]), t(S, [2, 10]), t(S, [2, 22], { 30: 41, 29: 56, 24: W, 27: X }), t(S, [2, 24]), t(S, [2, 25]), { 31: [1, 57] }, { 11: 59, 32: 58, 37: 24, 38: k, 39: D, 40: 27, 41: L, 42: w, 43: f, 44: v, 45: R, 46: P, 47: E, 48: d, 49: _, 50: r }, t(S, [2, 11]), t(S, [2, 30], { 33: 60, 27: F }), t(S, [2, 32]), { 31: [1, 61] }, t(S, [2, 12]), { 17: 62, 24: V }, { 25: 63, 27: A }, t(S, [2, 14]), { 17: 65, 24: V }, t(S, [2, 16]), t(S, [2, 17]), t(m, [2, 41]), t(S, [2, 23]), { 27: [1, 66] }, { 26: [1, 67] }, { 26: [2, 29], 28: [1, 68] }, t(S, [2, 31]), { 27: [1, 69] }, t(S, [2, 13]), { 26: [1, 70] }, { 26: [2, 21], 28: [1, 71] }, t(S, [2, 15]), t(S, [2, 26]), t(S, [2, 27]), { 11: 59, 32: 72, 37: 24, 38: k, 39: D, 40: 27, 41: L, 42: w, 43: f, 44: v, 45: R, 46: P, 47: E, 48: d, 49: _, 50: r }, t(S, [2, 33]), t(S, [2, 19]), { 25: 73, 27: A }, { 26: [2, 28] }, { 26: [2, 20] }],
    defaultActions: { 8: [2, 1], 10: [2, 3], 21: [2, 2], 72: [2, 28], 73: [2, 20] },
    parseError: /* @__PURE__ */ a(function(B, o) {
      if (o.recoverable)
        this.trace(B);
      else {
        var l = new Error(B);
        throw l.hash = o, l;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ a(function(B) {
      var o = this, l = [0], c = [], y = [null], n = [], I = this.table, x = "", q = 0, Et = 0, hi = 2, It = 1, ri = n.slice.call(arguments, 1), T = Object.create(this.lexer), U = { yy: {} };
      for (var at in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, at) && (U.yy[at] = this.yy[at]);
      T.setInput(B, U.yy), U.yy.lexer = T, U.yy.parser = this, typeof T.yylloc > "u" && (T.yylloc = {});
      var nt = T.yylloc;
      n.push(nt);
      var li = T.options && T.options.ranges;
      typeof U.yy.parseError == "function" ? this.parseError = U.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function ci(O) {
        l.length = l.length - 2 * O, y.length = y.length - O, n.length = n.length - O;
      }
      a(ci, "popStack");
      function $t() {
        var O;
        return O = c.pop() || T.lex() || It, typeof O != "number" && (O instanceof Array && (c = O, O = c.pop()), O = o.symbols_[O] || O), O;
      }
      a($t, "lex");
      for (var $, j, z, ot, Q = {}, tt, Y, Mt, it; ; ) {
        if (j = l[l.length - 1], this.defaultActions[j] ? z = this.defaultActions[j] : (($ === null || typeof $ > "u") && ($ = $t()), z = I[j] && I[j][$]), typeof z > "u" || !z.length || !z[0]) {
          var ht = "";
          it = [];
          for (tt in I[j])
            this.terminals_[tt] && tt > hi && it.push("'" + this.terminals_[tt] + "'");
          T.showPosition ? ht = "Parse error on line " + (q + 1) + `:
` + T.showPosition() + `
Expecting ` + it.join(", ") + ", got '" + (this.terminals_[$] || $) + "'" : ht = "Parse error on line " + (q + 1) + ": Unexpected " + ($ == It ? "end of input" : "'" + (this.terminals_[$] || $) + "'"), this.parseError(ht, {
            text: T.match,
            token: this.terminals_[$] || $,
            line: T.yylineno,
            loc: nt,
            expected: it
          });
        }
        if (z[0] instanceof Array && z.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + j + ", token: " + $);
        switch (z[0]) {
          case 1:
            l.push($), y.push(T.yytext), n.push(T.yylloc), l.push(z[1]), $ = null, Et = T.yyleng, x = T.yytext, q = T.yylineno, nt = T.yylloc;
            break;
          case 2:
            if (Y = this.productions_[z[1]][1], Q.$ = y[y.length - Y], Q._$ = {
              first_line: n[n.length - (Y || 1)].first_line,
              last_line: n[n.length - 1].last_line,
              first_column: n[n.length - (Y || 1)].first_column,
              last_column: n[n.length - 1].last_column
            }, li && (Q._$.range = [
              n[n.length - (Y || 1)].range[0],
              n[n.length - 1].range[1]
            ]), ot = this.performAction.apply(Q, [
              x,
              Et,
              q,
              U.yy,
              z[1],
              y,
              n
            ].concat(ri)), typeof ot < "u")
              return ot;
            Y && (l = l.slice(0, -1 * Y * 2), y = y.slice(0, -1 * Y), n = n.slice(0, -1 * Y)), l.push(this.productions_[z[1]][0]), y.push(Q.$), n.push(Q._$), Mt = I[l[l.length - 2]][l[l.length - 1]], l.push(Mt);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, C = /* @__PURE__ */ function() {
    var B = {
      EOF: 1,
      parseError: /* @__PURE__ */ a(function(o, l) {
        if (this.yy.parser)
          this.yy.parser.parseError(o, l);
        else
          throw new Error(o);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ a(function(o, l) {
        return this.yy = l || this.yy || {}, this._input = o, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
          first_line: 1,
          first_column: 0,
          last_line: 1,
          last_column: 0
        }, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
      }, "setInput"),
      // consumes and returns one char from the input
      input: /* @__PURE__ */ a(function() {
        var o = this._input[0];
        this.yytext += o, this.yyleng++, this.offset++, this.match += o, this.matched += o;
        var l = o.match(/(?:\r\n?|\n).*/g);
        return l ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), o;
      }, "input"),
      // unshifts one char (or a string) into the input
      unput: /* @__PURE__ */ a(function(o) {
        var l = o.length, c = o.split(/(?:\r\n?|\n)/g);
        this._input = o + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - l), this.offset -= l;
        var y = this.match.split(/(?:\r\n?|\n)/g);
        this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), c.length - 1 && (this.yylineno -= c.length - 1);
        var n = this.yylloc.range;
        return this.yylloc = {
          first_line: this.yylloc.first_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.first_column,
          last_column: c ? (c.length === y.length ? this.yylloc.first_column : 0) + y[y.length - c.length].length - c[0].length : this.yylloc.first_column - l
        }, this.options.ranges && (this.yylloc.range = [n[0], n[0] + this.yyleng - l]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      // When called from action, caches matched text and appends it on next action
      more: /* @__PURE__ */ a(function() {
        return this._more = !0, this;
      }, "more"),
      // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
      reject: /* @__PURE__ */ a(function() {
        if (this.options.backtrack_lexer)
          this._backtrack = !0;
        else
          return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
` + this.showPosition(), {
            text: "",
            token: null,
            line: this.yylineno
          });
        return this;
      }, "reject"),
      // retain first n characters of the match
      less: /* @__PURE__ */ a(function(o) {
        this.unput(this.match.slice(o));
      }, "less"),
      // displays already matched input, i.e. for error messages
      pastInput: /* @__PURE__ */ a(function() {
        var o = this.matched.substr(0, this.matched.length - this.match.length);
        return (o.length > 20 ? "..." : "") + o.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      // displays upcoming input, i.e. for error messages
      upcomingInput: /* @__PURE__ */ a(function() {
        var o = this.match;
        return o.length < 20 && (o += this._input.substr(0, 20 - o.length)), (o.substr(0, 20) + (o.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      // displays the character position where the lexing error occurred, i.e. for error messages
      showPosition: /* @__PURE__ */ a(function() {
        var o = this.pastInput(), l = new Array(o.length + 1).join("-");
        return o + this.upcomingInput() + `
` + l + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ a(function(o, l) {
        var c, y, n;
        if (this.options.backtrack_lexer && (n = {
          yylineno: this.yylineno,
          yylloc: {
            first_line: this.yylloc.first_line,
            last_line: this.last_line,
            first_column: this.yylloc.first_column,
            last_column: this.yylloc.last_column
          },
          yytext: this.yytext,
          match: this.match,
          matches: this.matches,
          matched: this.matched,
          yyleng: this.yyleng,
          offset: this.offset,
          _more: this._more,
          _input: this._input,
          yy: this.yy,
          conditionStack: this.conditionStack.slice(0),
          done: this.done
        }, this.options.ranges && (n.yylloc.range = this.yylloc.range.slice(0))), y = o[0].match(/(?:\r\n?|\n).*/g), y && (this.yylineno += y.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: y ? y[y.length - 1].length - y[y.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + o[0].length
        }, this.yytext += o[0], this.match += o[0], this.matches = o, this.yyleng = this.yytext.length, this.options.ranges && (this.yylloc.range = [this.offset, this.offset += this.yyleng]), this._more = !1, this._backtrack = !1, this._input = this._input.slice(o[0].length), this.matched += o[0], c = this.performAction.call(this, this.yy, this, l, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), c)
          return c;
        if (this._backtrack) {
          for (var I in n)
            this[I] = n[I];
          return !1;
        }
        return !1;
      }, "test_match"),
      // return next match in input
      next: /* @__PURE__ */ a(function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var o, l, c, y;
        this._more || (this.yytext = "", this.match = "");
        for (var n = this._currentRules(), I = 0; I < n.length; I++)
          if (c = this._input.match(this.rules[n[I]]), c && (!l || c[0].length > l[0].length)) {
            if (l = c, y = I, this.options.backtrack_lexer) {
              if (o = this.test_match(c, n[I]), o !== !1)
                return o;
              if (this._backtrack) {
                l = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return l ? (o = this.test_match(l, n[y]), o !== !1 ? o : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      }, "next"),
      // return next match that has a token
      lex: /* @__PURE__ */ a(function() {
        var o = this.next();
        return o || this.lex();
      }, "lex"),
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: /* @__PURE__ */ a(function(o) {
        this.conditionStack.push(o);
      }, "begin"),
      // pop the previously active lexer condition state off the condition stack
      popState: /* @__PURE__ */ a(function() {
        var o = this.conditionStack.length - 1;
        return o > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      }, "popState"),
      // produce the lexer rule set which is active for the currently active lexer condition state
      _currentRules: /* @__PURE__ */ a(function() {
        return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
      }, "_currentRules"),
      // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
      topState: /* @__PURE__ */ a(function(o) {
        return o = this.conditionStack.length - 1 - Math.abs(o || 0), o >= 0 ? this.conditionStack[o] : "INITIAL";
      }, "topState"),
      // alias for begin(condition)
      pushState: /* @__PURE__ */ a(function(o) {
        this.begin(o);
      }, "pushState"),
      // return the number of states currently on the stack
      stateStackSize: /* @__PURE__ */ a(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ a(function(o, l, c, y) {
        switch (c) {
          case 0:
            break;
          case 1:
            break;
          case 2:
            return this.popState(), 34;
          case 3:
            return this.popState(), 34;
          case 4:
            return 34;
          case 5:
            break;
          case 6:
            return 10;
          case 7:
            return this.pushState("acc_title"), 19;
          case 8:
            return this.popState(), "acc_title_value";
          case 9:
            return this.pushState("acc_descr"), 21;
          case 10:
            return this.popState(), "acc_descr_value";
          case 11:
            this.pushState("acc_descr_multiline");
            break;
          case 12:
            this.popState();
            break;
          case 13:
            return "acc_descr_multiline_value";
          case 14:
            return 5;
          case 15:
            return 5;
          case 16:
            return 8;
          case 17:
            return this.pushState("axis_data"), "X_AXIS";
          case 18:
            return this.pushState("axis_data"), "Y_AXIS";
          case 19:
            return this.pushState("axis_band_data"), 24;
          case 20:
            return 31;
          case 21:
            return this.pushState("data"), 16;
          case 22:
            return this.pushState("data"), 18;
          case 23:
            return this.pushState("data_inner"), 24;
          case 24:
            return 27;
          case 25:
            return this.popState(), 26;
          case 26:
            this.popState();
            break;
          case 27:
            this.pushState("string");
            break;
          case 28:
            this.popState();
            break;
          case 29:
            return "STR";
          case 30:
            return 24;
          case 31:
            return 26;
          case 32:
            return 43;
          case 33:
            return "COLON";
          case 34:
            return 44;
          case 35:
            return 28;
          case 36:
            return 45;
          case 37:
            return 46;
          case 38:
            return 48;
          case 39:
            return 50;
          case 40:
            return 47;
          case 41:
            return 41;
          case 42:
            return 49;
          case 43:
            return 42;
          case 44:
            break;
          case 45:
            return 35;
          case 46:
            return 36;
        }
      }, "anonymous"),
      rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:(\r?\n))/i, /^(?:(\r?\n))/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:\})/i, /^(?:[^\}]*)/i, /^(?:xychart-beta\b)/i, /^(?:xychart\b)/i, /^(?:(?:vertical|horizontal))/i, /^(?:x-axis\b)/i, /^(?:y-axis\b)/i, /^(?:\[)/i, /^(?:-->)/i, /^(?:line\b)/i, /^(?:bar\b)/i, /^(?:\[)/i, /^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i, /^(?:\])/i, /^(?:(?:`\)                                    \{ this\.pushState\(md_string\); \}\n<md_string>\(\?:\(\?!`"\)\.\)\+                  \{ return MD_STR; \}\n<md_string>\(\?:`))/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s+)/i, /^(?:;)/i, /^(?:$)/i],
      conditions: { data_inner: { rules: [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: !0 }, data: { rules: [0, 1, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 23, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: !0 }, axis_band_data: { rules: [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: !0 }, axis_data: { rules: [0, 1, 2, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: !0 }, acc_descr_multiline: { rules: [12, 13], inclusive: !1 }, acc_descr: { rules: [10], inclusive: !1 }, acc_title: { rules: [8], inclusive: !1 }, title: { rules: [], inclusive: !1 }, md_string: { rules: [], inclusive: !1 }, string: { rules: [28, 29], inclusive: !1 }, INITIAL: { rules: [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: !0 } }
    };
    return B;
  }();
  M.lexer = C;
  function N() {
    this.yy = {};
  }
  return a(N, "Parser"), N.prototype = M, M.Parser = N, new N();
}();
bt.parser = bt;
var Ti = bt;
function At(t) {
  return t.type === "bar";
}
a(At, "isBarPlot");
function kt(t) {
  return t.type === "band";
}
a(kt, "isBandAxisData");
function G(t) {
  return t.type === "linear";
}
a(G, "isLinearAxisData");
var rt, Yt = (rt = class {
  constructor(t) {
    this.parentGroup = t;
  }
  getMaxDimension(t, i) {
    if (!this.parentGroup)
      return {
        width: t.reduce((h, g) => Math.max(g.length, h), 0) * i,
        height: i
      };
    const e = {
      width: 0,
      height: 0
    }, s = this.parentGroup.append("g").attr("visibility", "hidden").attr("font-size", i);
    for (const h of t) {
      const g = wi(s, 1, h), u = g ? g.width : h.length * i, p = g ? g.height : i;
      e.width = Math.max(e.width, u), e.height = Math.max(e.height, p);
    }
    return s.remove(), e;
  }
}, a(rt, "TextDimensionCalculatorWithFont"), rt), Wt = 0.7, zt = 0.2, lt, Nt = (lt = class {
  constructor(t, i, e, s) {
    this.axisConfig = t, this.title = i, this.textDimensionCalculator = e, this.axisThemeConfig = s, this.boundingRect = { x: 0, y: 0, width: 0, height: 0 }, this.axisPosition = "left", this.showTitle = !1, this.showLabel = !1, this.showTick = !1, this.showAxisLine = !1, this.outerPadding = 0, this.titleTextHeight = 0, this.labelTextHeight = 0, this.range = [0, 10], this.boundingRect = { x: 0, y: 0, width: 0, height: 0 }, this.axisPosition = "left";
  }
  setRange(t) {
    this.range = t, this.axisPosition === "left" || this.axisPosition === "right" ? this.boundingRect.height = t[1] - t[0] : this.boundingRect.width = t[1] - t[0], this.recalculateScale();
  }
  getRange() {
    return [this.range[0] + this.outerPadding, this.range[1] - this.outerPadding];
  }
  setAxisPosition(t) {
    this.axisPosition = t, this.setRange(this.range);
  }
  getTickDistance() {
    const t = this.getRange();
    return Math.abs(t[0] - t[1]) / this.getTickValues().length;
  }
  getAxisOuterPadding() {
    return this.outerPadding;
  }
  getLabelDimension() {
    return this.textDimensionCalculator.getMaxDimension(
      this.getTickValues().map((t) => t.toString()),
      this.axisConfig.labelFontSize
    );
  }
  recalculateOuterPaddingToDrawBar() {
    Wt * this.getTickDistance() > this.outerPadding * 2 && (this.outerPadding = Math.floor(Wt * this.getTickDistance() / 2)), this.recalculateScale();
  }
  calculateSpaceIfDrawnHorizontally(t) {
    let i = t.height;
    if (this.axisConfig.showAxisLine && i > this.axisConfig.axisLineWidth && (i -= this.axisConfig.axisLineWidth, this.showAxisLine = !0), this.axisConfig.showLabel) {
      const e = this.getLabelDimension(), s = zt * t.width;
      this.outerPadding = Math.min(e.width / 2, s);
      const h = e.height + this.axisConfig.labelPadding * 2;
      this.labelTextHeight = e.height, h <= i && (i -= h, this.showLabel = !0);
    }
    if (this.axisConfig.showTick && i >= this.axisConfig.tickLength && (this.showTick = !0, i -= this.axisConfig.tickLength), this.axisConfig.showTitle && this.title) {
      const e = this.textDimensionCalculator.getMaxDimension(
        [this.title],
        this.axisConfig.titleFontSize
      ), s = e.height + this.axisConfig.titlePadding * 2;
      this.titleTextHeight = e.height, s <= i && (i -= s, this.showTitle = !0);
    }
    this.boundingRect.width = t.width, this.boundingRect.height = t.height - i;
  }
  calculateSpaceIfDrawnVertical(t) {
    let i = t.width;
    if (this.axisConfig.showAxisLine && i > this.axisConfig.axisLineWidth && (i -= this.axisConfig.axisLineWidth, this.showAxisLine = !0), this.axisConfig.showLabel) {
      const e = this.getLabelDimension(), s = zt * t.height;
      this.outerPadding = Math.min(e.height / 2, s);
      const h = e.width + this.axisConfig.labelPadding * 2;
      h <= i && (i -= h, this.showLabel = !0);
    }
    if (this.axisConfig.showTick && i >= this.axisConfig.tickLength && (this.showTick = !0, i -= this.axisConfig.tickLength), this.axisConfig.showTitle && this.title) {
      const e = this.textDimensionCalculator.getMaxDimension(
        [this.title],
        this.axisConfig.titleFontSize
      ), s = e.height + this.axisConfig.titlePadding * 2;
      this.titleTextHeight = e.height, s <= i && (i -= s, this.showTitle = !0);
    }
    this.boundingRect.width = t.width - i, this.boundingRect.height = t.height;
  }
  calculateSpace(t) {
    return this.axisPosition === "left" || this.axisPosition === "right" ? this.calculateSpaceIfDrawnVertical(t) : this.calculateSpaceIfDrawnHorizontally(t), this.recalculateScale(), {
      width: this.boundingRect.width,
      height: this.boundingRect.height
    };
  }
  setBoundingBoxXY(t) {
    this.boundingRect.x = t.x, this.boundingRect.y = t.y;
  }
  getDrawableElementsForLeftAxis() {
    const t = [];
    if (this.showAxisLine) {
      const i = this.boundingRect.x + this.boundingRect.width - this.axisConfig.axisLineWidth / 2;
      t.push({
        type: "path",
        groupTexts: ["left-axis", "axisl-line"],
        data: [
          {
            path: `M ${i},${this.boundingRect.y} L ${i},${this.boundingRect.y + this.boundingRect.height} `,
            strokeFill: this.axisThemeConfig.axisLineColor,
            strokeWidth: this.axisConfig.axisLineWidth
          }
        ]
      });
    }
    if (this.showLabel && t.push({
      type: "text",
      groupTexts: ["left-axis", "label"],
      data: this.getTickValues().map((i) => ({
        text: i.toString(),
        x: this.boundingRect.x + this.boundingRect.width - (this.showLabel ? this.axisConfig.labelPadding : 0) - (this.showTick ? this.axisConfig.tickLength : 0) - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0),
        y: this.getScaleValue(i),
        fill: this.axisThemeConfig.labelColor,
        fontSize: this.axisConfig.labelFontSize,
        rotation: 0,
        verticalPos: "middle",
        horizontalPos: "right"
      }))
    }), this.showTick) {
      const i = this.boundingRect.x + this.boundingRect.width - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0);
      t.push({
        type: "path",
        groupTexts: ["left-axis", "ticks"],
        data: this.getTickValues().map((e) => ({
          path: `M ${i},${this.getScaleValue(e)} L ${i - this.axisConfig.tickLength},${this.getScaleValue(e)}`,
          strokeFill: this.axisThemeConfig.tickColor,
          strokeWidth: this.axisConfig.tickWidth
        }))
      });
    }
    return this.showTitle && t.push({
      type: "text",
      groupTexts: ["left-axis", "title"],
      data: [
        {
          text: this.title,
          x: this.boundingRect.x + this.axisConfig.titlePadding,
          y: this.boundingRect.y + this.boundingRect.height / 2,
          fill: this.axisThemeConfig.titleColor,
          fontSize: this.axisConfig.titleFontSize,
          rotation: 270,
          verticalPos: "top",
          horizontalPos: "center"
        }
      ]
    }), t;
  }
  getDrawableElementsForBottomAxis() {
    const t = [];
    if (this.showAxisLine) {
      const i = this.boundingRect.y + this.axisConfig.axisLineWidth / 2;
      t.push({
        type: "path",
        groupTexts: ["bottom-axis", "axis-line"],
        data: [
          {
            path: `M ${this.boundingRect.x},${i} L ${this.boundingRect.x + this.boundingRect.width},${i}`,
            strokeFill: this.axisThemeConfig.axisLineColor,
            strokeWidth: this.axisConfig.axisLineWidth
          }
        ]
      });
    }
    if (this.showLabel && t.push({
      type: "text",
      groupTexts: ["bottom-axis", "label"],
      data: this.getTickValues().map((i) => ({
        text: i.toString(),
        x: this.getScaleValue(i),
        y: this.boundingRect.y + this.axisConfig.labelPadding + (this.showTick ? this.axisConfig.tickLength : 0) + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0),
        fill: this.axisThemeConfig.labelColor,
        fontSize: this.axisConfig.labelFontSize,
        rotation: 0,
        verticalPos: "top",
        horizontalPos: "center"
      }))
    }), this.showTick) {
      const i = this.boundingRect.y + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0);
      t.push({
        type: "path",
        groupTexts: ["bottom-axis", "ticks"],
        data: this.getTickValues().map((e) => ({
          path: `M ${this.getScaleValue(e)},${i} L ${this.getScaleValue(e)},${i + this.axisConfig.tickLength}`,
          strokeFill: this.axisThemeConfig.tickColor,
          strokeWidth: this.axisConfig.tickWidth
        }))
      });
    }
    return this.showTitle && t.push({
      type: "text",
      groupTexts: ["bottom-axis", "title"],
      data: [
        {
          text: this.title,
          x: this.range[0] + (this.range[1] - this.range[0]) / 2,
          y: this.boundingRect.y + this.boundingRect.height - this.axisConfig.titlePadding - this.titleTextHeight,
          fill: this.axisThemeConfig.titleColor,
          fontSize: this.axisConfig.titleFontSize,
          rotation: 0,
          verticalPos: "top",
          horizontalPos: "center"
        }
      ]
    }), t;
  }
  getDrawableElementsForTopAxis() {
    const t = [];
    if (this.showAxisLine) {
      const i = this.boundingRect.y + this.boundingRect.height - this.axisConfig.axisLineWidth / 2;
      t.push({
        type: "path",
        groupTexts: ["top-axis", "axis-line"],
        data: [
          {
            path: `M ${this.boundingRect.x},${i} L ${this.boundingRect.x + this.boundingRect.width},${i}`,
            strokeFill: this.axisThemeConfig.axisLineColor,
            strokeWidth: this.axisConfig.axisLineWidth
          }
        ]
      });
    }
    if (this.showLabel && t.push({
      type: "text",
      groupTexts: ["top-axis", "label"],
      data: this.getTickValues().map((i) => ({
        text: i.toString(),
        x: this.getScaleValue(i),
        y: this.boundingRect.y + (this.showTitle ? this.titleTextHeight + this.axisConfig.titlePadding * 2 : 0) + this.axisConfig.labelPadding,
        fill: this.axisThemeConfig.labelColor,
        fontSize: this.axisConfig.labelFontSize,
        rotation: 0,
        verticalPos: "top",
        horizontalPos: "center"
      }))
    }), this.showTick) {
      const i = this.boundingRect.y;
      t.push({
        type: "path",
        groupTexts: ["top-axis", "ticks"],
        data: this.getTickValues().map((e) => ({
          path: `M ${this.getScaleValue(e)},${i + this.boundingRect.height - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)} L ${this.getScaleValue(e)},${i + this.boundingRect.height - this.axisConfig.tickLength - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)}`,
          strokeFill: this.axisThemeConfig.tickColor,
          strokeWidth: this.axisConfig.tickWidth
        }))
      });
    }
    return this.showTitle && t.push({
      type: "text",
      groupTexts: ["top-axis", "title"],
      data: [
        {
          text: this.title,
          x: this.boundingRect.x + this.boundingRect.width / 2,
          y: this.boundingRect.y + this.axisConfig.titlePadding,
          fill: this.axisThemeConfig.titleColor,
          fontSize: this.axisConfig.titleFontSize,
          rotation: 0,
          verticalPos: "top",
          horizontalPos: "center"
        }
      ]
    }), t;
  }
  getDrawableElements() {
    if (this.axisPosition === "left")
      return this.getDrawableElementsForLeftAxis();
    if (this.axisPosition === "right")
      throw Error("Drawing of right axis is not implemented");
    return this.axisPosition === "bottom" ? this.getDrawableElementsForBottomAxis() : this.axisPosition === "top" ? this.getDrawableElementsForTopAxis() : [];
  }
}, a(lt, "BaseAxis"), lt), ct, Ri = (ct = class extends Nt {
  constructor(t, i, e, s, h) {
    super(t, s, h, i), this.categories = e, this.scale = yt().domain(this.categories).range(this.getRange());
  }
  setRange(t) {
    super.setRange(t);
  }
  recalculateScale() {
    this.scale = yt().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(0.5), Ft.trace("BandAxis axis final categories, range: ", this.categories, this.getRange());
  }
  getTickValues() {
    return this.categories;
  }
  getScaleValue(t) {
    return this.scale(t) ?? this.getRange()[0];
  }
}, a(ct, "BandAxis"), ct), ut, Di = (ut = class extends Nt {
  constructor(t, i, e, s, h) {
    super(t, s, h, i), this.domain = e, this.scale = Ot().domain(this.domain).range(this.getRange());
  }
  getTickValues() {
    return this.scale.ticks();
  }
  recalculateScale() {
    const t = [...this.domain];
    this.axisPosition === "left" && t.reverse(), this.scale = Ot().domain(t).range(this.getRange());
  }
  getScaleValue(t) {
    return this.scale(t);
  }
}, a(ut, "LinearAxis"), ut);
function St(t, i, e, s) {
  const h = new Yt(s);
  return kt(t) ? new Ri(
    i,
    e,
    t.categories,
    t.title,
    h
  ) : new Di(
    i,
    e,
    [t.min, t.max],
    t.title,
    h
  );
}
a(St, "getAxis");
var gt, Li = (gt = class {
  constructor(t, i, e, s) {
    this.textDimensionCalculator = t, this.chartConfig = i, this.chartData = e, this.chartThemeConfig = s, this.boundingRect = {
      x: 0,
      y: 0,
      width: 0,
      height: 0
    }, this.showChartTitle = !1;
  }
  setBoundingBoxXY(t) {
    this.boundingRect.x = t.x, this.boundingRect.y = t.y;
  }
  calculateSpace(t) {
    const i = this.textDimensionCalculator.getMaxDimension(
      [this.chartData.title],
      this.chartConfig.titleFontSize
    ), e = Math.max(i.width, t.width), s = i.height + 2 * this.chartConfig.titlePadding;
    return i.width <= e && i.height <= s && this.chartConfig.showTitle && this.chartData.title && (this.boundingRect.width = e, this.boundingRect.height = s, this.showChartTitle = !0), {
      width: this.boundingRect.width,
      height: this.boundingRect.height
    };
  }
  getDrawableElements() {
    const t = [];
    return this.showChartTitle && t.push({
      groupTexts: ["chart-title"],
      type: "text",
      data: [
        {
          fontSize: this.chartConfig.titleFontSize,
          text: this.chartData.title,
          verticalPos: "middle",
          horizontalPos: "center",
          x: this.boundingRect.x + this.boundingRect.width / 2,
          y: this.boundingRect.y + this.boundingRect.height / 2,
          fill: this.chartThemeConfig.titleColor,
          rotation: 0
        }
      ]
    }), t;
  }
}, a(gt, "ChartTitle"), gt);
function Ht(t, i, e, s) {
  const h = new Yt(s);
  return new Li(h, t, i, e);
}
a(Ht, "getChartTitleComponent");
var xt, Pi = (xt = class {
  constructor(t, i, e, s, h) {
    this.plotData = t, this.xAxis = i, this.yAxis = e, this.orientation = s, this.plotIndex = h;
  }
  getDrawableElement() {
    const t = this.plotData.data.map((e) => [
      this.xAxis.getScaleValue(e[0]),
      this.yAxis.getScaleValue(e[1])
    ]);
    let i;
    return this.orientation === "horizontal" ? i = Bt().y((e) => e[0]).x((e) => e[1])(t) : i = Bt().x((e) => e[0]).y((e) => e[1])(t), i ? [
      {
        groupTexts: ["plot", `line-plot-${this.plotIndex}`],
        type: "path",
        data: [
          {
            path: i,
            strokeFill: this.plotData.strokeFill,
            strokeWidth: this.plotData.strokeWidth
          }
        ]
      }
    ] : [];
  }
}, a(xt, "LinePlot"), xt), dt, vi = (dt = class {
  constructor(t, i, e, s, h, g) {
    this.barData = t, this.boundingRect = i, this.xAxis = e, this.yAxis = s, this.orientation = h, this.plotIndex = g;
  }
  getDrawableElement() {
    const t = this.barData.data.map((s) => [
      this.xAxis.getScaleValue(s[0]),
      this.yAxis.getScaleValue(s[1])
    ]), i = Math.min(this.xAxis.getAxisOuterPadding() * 2, this.xAxis.getTickDistance()) * (1 - 0.05), e = i / 2;
    return this.orientation === "horizontal" ? [
      {
        groupTexts: ["plot", `bar-plot-${this.plotIndex}`],
        type: "rect",
        data: t.map((s) => ({
          x: this.boundingRect.x,
          y: s[0] - e,
          height: i,
          width: s[1] - this.boundingRect.x,
          fill: this.barData.fill,
          strokeWidth: 0,
          strokeFill: this.barData.fill
        }))
      }
    ] : [
      {
        groupTexts: ["plot", `bar-plot-${this.plotIndex}`],
        type: "rect",
        data: t.map((s) => ({
          x: s[0] - e,
          y: s[1],
          width: i,
          height: this.boundingRect.y + this.boundingRect.height - s[1],
          fill: this.barData.fill,
          strokeWidth: 0,
          strokeFill: this.barData.fill
        }))
      }
    ];
  }
}, a(dt, "BarPlot"), dt), pt, Ei = (pt = class {
  constructor(t, i, e) {
    this.chartConfig = t, this.chartData = i, this.chartThemeConfig = e, this.boundingRect = {
      x: 0,
      y: 0,
      width: 0,
      height: 0
    };
  }
  setAxes(t, i) {
    this.xAxis = t, this.yAxis = i;
  }
  setBoundingBoxXY(t) {
    this.boundingRect.x = t.x, this.boundingRect.y = t.y;
  }
  calculateSpace(t) {
    return this.boundingRect.width = t.width, this.boundingRect.height = t.height, {
      width: this.boundingRect.width,
      height: this.boundingRect.height
    };
  }
  getDrawableElements() {
    if (!(this.xAxis && this.yAxis))
      throw Error("Axes must be passed to render Plots");
    const t = [];
    for (const [i, e] of this.chartData.plots.entries())
      switch (e.type) {
        case "line":
          {
            const s = new Pi(
              e,
              this.xAxis,
              this.yAxis,
              this.chartConfig.chartOrientation,
              i
            );
            t.push(...s.getDrawableElement());
          }
          break;
        case "bar":
          {
            const s = new vi(
              e,
              this.boundingRect,
              this.xAxis,
              this.yAxis,
              this.chartConfig.chartOrientation,
              i
            );
            t.push(...s.getDrawableElement());
          }
          break;
      }
    return t;
  }
}, a(pt, "BasePlot"), pt);
function Ut(t, i, e) {
  return new Ei(t, i, e);
}
a(Ut, "getPlotComponent");
var ft, Ii = (ft = class {
  constructor(t, i, e, s) {
    this.chartConfig = t, this.chartData = i, this.componentStore = {
      title: Ht(t, i, e, s),
      plot: Ut(t, i, e),
      xAxis: St(
        i.xAxis,
        t.xAxis,
        {
          titleColor: e.xAxisTitleColor,
          labelColor: e.xAxisLabelColor,
          tickColor: e.xAxisTickColor,
          axisLineColor: e.xAxisLineColor
        },
        s
      ),
      yAxis: St(
        i.yAxis,
        t.yAxis,
        {
          titleColor: e.yAxisTitleColor,
          labelColor: e.yAxisLabelColor,
          tickColor: e.yAxisTickColor,
          axisLineColor: e.yAxisLineColor
        },
        s
      )
    };
  }
  calculateVerticalSpace() {
    let t = this.chartConfig.width, i = this.chartConfig.height, e = 0, s = 0, h = Math.floor(t * this.chartConfig.plotReservedSpacePercent / 100), g = Math.floor(
      i * this.chartConfig.plotReservedSpacePercent / 100
    ), u = this.componentStore.plot.calculateSpace({
      width: h,
      height: g
    });
    t -= u.width, i -= u.height, u = this.componentStore.title.calculateSpace({
      width: this.chartConfig.width,
      height: i
    }), s = u.height, i -= u.height, this.componentStore.xAxis.setAxisPosition("bottom"), u = this.componentStore.xAxis.calculateSpace({
      width: t,
      height: i
    }), i -= u.height, this.componentStore.yAxis.setAxisPosition("left"), u = this.componentStore.yAxis.calculateSpace({
      width: t,
      height: i
    }), e = u.width, t -= u.width, t > 0 && (h += t, t = 0), i > 0 && (g += i, i = 0), this.componentStore.plot.calculateSpace({
      width: h,
      height: g
    }), this.componentStore.plot.setBoundingBoxXY({ x: e, y: s }), this.componentStore.xAxis.setRange([e, e + h]), this.componentStore.xAxis.setBoundingBoxXY({ x: e, y: s + g }), this.componentStore.yAxis.setRange([s, s + g]), this.componentStore.yAxis.setBoundingBoxXY({ x: 0, y: s }), this.chartData.plots.some((p) => At(p)) && this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
  }
  calculateHorizontalSpace() {
    let t = this.chartConfig.width, i = this.chartConfig.height, e = 0, s = 0, h = 0, g = Math.floor(t * this.chartConfig.plotReservedSpacePercent / 100), u = Math.floor(
      i * this.chartConfig.plotReservedSpacePercent / 100
    ), p = this.componentStore.plot.calculateSpace({
      width: g,
      height: u
    });
    t -= p.width, i -= p.height, p = this.componentStore.title.calculateSpace({
      width: this.chartConfig.width,
      height: i
    }), e = p.height, i -= p.height, this.componentStore.xAxis.setAxisPosition("left"), p = this.componentStore.xAxis.calculateSpace({
      width: t,
      height: i
    }), t -= p.width, s = p.width, this.componentStore.yAxis.setAxisPosition("top"), p = this.componentStore.yAxis.calculateSpace({
      width: t,
      height: i
    }), i -= p.height, h = e + p.height, t > 0 && (g += t, t = 0), i > 0 && (u += i, i = 0), this.componentStore.plot.calculateSpace({
      width: g,
      height: u
    }), this.componentStore.plot.setBoundingBoxXY({ x: s, y: h }), this.componentStore.yAxis.setRange([s, s + g]), this.componentStore.yAxis.setBoundingBoxXY({ x: s, y: e }), this.componentStore.xAxis.setRange([h, h + u]), this.componentStore.xAxis.setBoundingBoxXY({ x: 0, y: h }), this.chartData.plots.some((k) => At(k)) && this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
  }
  calculateSpace() {
    this.chartConfig.chartOrientation === "horizontal" ? this.calculateHorizontalSpace() : this.calculateVerticalSpace();
  }
  getDrawableElement() {
    this.calculateSpace();
    const t = [];
    this.componentStore.plot.setAxes(this.componentStore.xAxis, this.componentStore.yAxis);
    for (const i of Object.values(this.componentStore))
      t.push(...i.getDrawableElements());
    return t;
  }
}, a(ft, "Orchestrator"), ft), mt, $i = (mt = class {
  static build(t, i, e, s) {
    return new Ii(t, i, e, s).getDrawableElement();
  }
}, a(mt, "XYChartBuilder"), mt), K = 0, jt, Z = Rt(), J = Tt(), b = Dt(), wt = J.plotColorPalette.split(",").map((t) => t.trim()), et = !1, _t = !1;
function Tt() {
  const t = Si(), i = Ct();
  return Vt(t.xyChart, i.themeVariables.xyChart);
}
a(Tt, "getChartDefaultThemeConfig");
function Rt() {
  const t = Ct();
  return Vt(
    Ai.xyChart,
    t.xyChart
  );
}
a(Rt, "getChartDefaultConfig");
function Dt() {
  return {
    yAxis: {
      type: "linear",
      title: "",
      min: 1 / 0,
      max: -1 / 0
    },
    xAxis: {
      type: "band",
      title: "",
      categories: []
    },
    title: "",
    plots: []
  };
}
a(Dt, "getChartDefaultData");
function st(t) {
  const i = Ct();
  return bi(t.trim(), i);
}
a(st, "textSanitizer");
function Qt(t) {
  jt = t;
}
a(Qt, "setTmpSVGG");
function Gt(t) {
  t === "horizontal" ? Z.chartOrientation = "horizontal" : Z.chartOrientation = "vertical";
}
a(Gt, "setOrientation");
function Kt(t) {
  b.xAxis.title = st(t.text);
}
a(Kt, "setXAxisTitle");
function Lt(t, i) {
  b.xAxis = { type: "linear", title: b.xAxis.title, min: t, max: i }, et = !0;
}
a(Lt, "setXAxisRangeData");
function Zt(t) {
  b.xAxis = {
    type: "band",
    title: b.xAxis.title,
    categories: t.map((i) => st(i.text))
  }, et = !0;
}
a(Zt, "setXAxisBand");
function Jt(t) {
  b.yAxis.title = st(t.text);
}
a(Jt, "setYAxisTitle");
function qt(t, i) {
  b.yAxis = { type: "linear", title: b.yAxis.title, min: t, max: i }, _t = !0;
}
a(qt, "setYAxisRangeData");
function ti(t) {
  const i = Math.min(...t), e = Math.max(...t), s = G(b.yAxis) ? b.yAxis.min : 1 / 0, h = G(b.yAxis) ? b.yAxis.max : -1 / 0;
  b.yAxis = {
    type: "linear",
    title: b.yAxis.title,
    min: Math.min(s, i),
    max: Math.max(h, e)
  };
}
a(ti, "setYAxisRangeFromPlotData");
function Pt(t) {
  let i = [];
  if (t.length === 0)
    return i;
  if (!et) {
    const e = G(b.xAxis) ? b.xAxis.min : 1 / 0, s = G(b.xAxis) ? b.xAxis.max : -1 / 0;
    Lt(Math.min(e, 1), Math.max(s, t.length));
  }
  if (_t || ti(t), kt(b.xAxis) && (i = b.xAxis.categories.map((e, s) => [e, t[s]])), G(b.xAxis)) {
    const e = b.xAxis.min, s = b.xAxis.max, h = (s - e) / (t.length - 1), g = [];
    for (let u = e; u <= s; u += h)
      g.push(`${u}`);
    i = g.map((u, p) => [u, t[p]]);
  }
  return i;
}
a(Pt, "transformDataWithoutCategory");
function vt(t) {
  return wt[t === 0 ? 0 : t % wt.length];
}
a(vt, "getPlotColorFromPalette");
function ii(t, i) {
  const e = Pt(i);
  b.plots.push({
    type: "line",
    strokeFill: vt(K),
    strokeWidth: 2,
    data: e
  }), K++;
}
a(ii, "setLineData");
function ei(t, i) {
  const e = Pt(i);
  b.plots.push({
    type: "bar",
    fill: vt(K),
    data: e
  }), K++;
}
a(ei, "setBarData");
function si() {
  if (b.plots.length === 0)
    throw Error("No Plot to render, please provide a plot with some data");
  return b.title = Xt(), $i.build(Z, b, J, jt);
}
a(si, "getDrawableElem");
function ai() {
  return J;
}
a(ai, "getChartThemeConfig");
function ni() {
  return Z;
}
a(ni, "getChartConfig");
function oi() {
  return b;
}
a(oi, "getXYChartData");
var Mi = /* @__PURE__ */ a(function() {
  yi(), K = 0, Z = Rt(), b = Dt(), J = Tt(), wt = J.plotColorPalette.split(",").map((t) => t.trim()), et = !1, _t = !1;
}, "clear"), Bi = {
  getDrawableElem: si,
  clear: Mi,
  setAccTitle: pi,
  getAccTitle: di,
  setDiagramTitle: xi,
  getDiagramTitle: Xt,
  getAccDescription: gi,
  setAccDescription: ui,
  setOrientation: Gt,
  setXAxisTitle: Kt,
  setXAxisRangeData: Lt,
  setXAxisBand: Zt,
  setYAxisTitle: Jt,
  setYAxisRangeData: qt,
  setLineData: ii,
  setBarData: ei,
  setTmpSVGG: Qt,
  getChartThemeConfig: ai,
  getChartConfig: ni,
  getXYChartData: oi
}, Oi = /* @__PURE__ */ a((t, i, e, s) => {
  const h = s.db, g = h.getChartThemeConfig(), u = h.getChartConfig(), p = h.getXYChartData().plots[0].data.map((d) => d[1]);
  function k(d) {
    return d === "top" ? "text-before-edge" : "middle";
  }
  a(k, "getDominantBaseLine");
  function D(d) {
    return d === "left" ? "start" : d === "right" ? "end" : "middle";
  }
  a(D, "getTextAnchor");
  function L(d) {
    return `translate(${d.x}, ${d.y}) rotate(${d.rotation || 0})`;
  }
  a(L, "getTextTransformation"), Ft.debug(`Rendering xychart chart
` + t);
  const w = fi(i), f = w.append("g").attr("class", "main"), v = f.append("rect").attr("width", u.width).attr("height", u.height).attr("class", "background");
  mi(w, u.height, u.width, !0), w.attr("viewBox", `0 0 ${u.width} ${u.height}`), v.attr("fill", g.backgroundColor), h.setTmpSVGG(w.append("g").attr("class", "mermaid-tmp-group"));
  const R = h.getDrawableElem(), P = {};
  function E(d) {
    let _ = f, r = "";
    for (const [W] of d.entries()) {
      let X = f;
      W > 0 && P[r] && (X = P[r]), r += d[W], _ = P[r], _ || (_ = P[r] = X.append("g").attr("class", d[W]));
    }
    return _;
  }
  a(E, "getGroup");
  for (const d of R) {
    if (d.data.length === 0)
      continue;
    const _ = E(d.groupTexts);
    switch (d.type) {
      case "rect":
        if (_.selectAll("rect").data(d.data).enter().append("rect").attr("x", (r) => r.x).attr("y", (r) => r.y).attr("width", (r) => r.width).attr("height", (r) => r.height).attr("fill", (r) => r.fill).attr("stroke", (r) => r.strokeFill).attr("stroke-width", (r) => r.strokeWidth), u.showDataLabel) {
          const r = u.showDataLabelOutsideBar;
          if (u.chartOrientation === "horizontal") {
            let W = function(A, M) {
              const { data: C, label: N } = A;
              return M * N.length * X <= C.width - F;
            };
            a(W, "fitsHorizontally");
            const X = 0.7, F = 10, V = d.data.map((A, M) => ({ data: A, label: p[M].toString() })).filter((A) => A.data.width > 0 && A.data.height > 0), S = V.map((A) => {
              const { data: M } = A;
              let C = M.height * 0.7;
              for (; !W(A, C) && C > 0; )
                C -= 1;
              return C;
            }), H = Math.floor(Math.min(...S)), m = /* @__PURE__ */ a((A) => r ? A.data.x + A.data.width + F : A.data.x + A.data.width - F, "determineLabelXPosition");
            _.selectAll("text").data(V).enter().append("text").attr("x", m).attr("y", (A) => A.data.y + A.data.height / 2).attr("text-anchor", r ? "start" : "end").attr("dominant-baseline", "middle").attr("fill", g.dataLabelColor).attr("font-size", `${H}px`).text((A) => A.label);
          } else {
            let W = function(m, A, M) {
              const { data: C, label: N } = m, B = A * N.length * 0.7, o = C.x + C.width / 2, l = o - B / 2, c = o + B / 2, y = l >= C.x && c <= C.x + C.width, n = C.y + M + A <= C.y + C.height;
              return y && n;
            };
            a(W, "fitsInBar");
            const X = 10, F = d.data.map((m, A) => ({ data: m, label: p[A].toString() })).filter((m) => m.data.width > 0 && m.data.height > 0), V = F.map((m) => {
              const { data: A, label: M } = m;
              let C = A.width / (M.length * 0.7);
              for (; !W(m, C, X) && C > 0; )
                C -= 1;
              return C;
            }), S = Math.floor(Math.min(...V)), H = /* @__PURE__ */ a((m) => r ? m.data.y - X : m.data.y + X, "determineLabelYPosition");
            _.selectAll("text").data(F).enter().append("text").attr("x", (m) => m.data.x + m.data.width / 2).attr("y", H).attr("text-anchor", "middle").attr("dominant-baseline", r ? "auto" : "hanging").attr("fill", g.dataLabelColor).attr("font-size", `${S}px`).text((m) => m.label);
          }
        }
        break;
      case "text":
        _.selectAll("text").data(d.data).enter().append("text").attr("x", 0).attr("y", 0).attr("fill", (r) => r.fill).attr("font-size", (r) => r.fontSize).attr("dominant-baseline", (r) => k(r.verticalPos)).attr("text-anchor", (r) => D(r.horizontalPos)).attr("transform", (r) => L(r)).text((r) => r.text);
        break;
      case "path":
        _.selectAll("path").data(d.data).enter().append("path").attr("d", (r) => r.path).attr("fill", (r) => r.fill ? r.fill : "none").attr("stroke", (r) => r.strokeFill).attr("stroke-width", (r) => r.strokeWidth);
        break;
    }
  }
}, "draw"), Wi = {
  draw: Oi
}, Yi = {
  parser: Ti,
  db: Bi,
  renderer: Wi
};
export {
  Yi as diagram
};
