import { G as gi, K as xi, i as Ft, f as di, W as pi, U as fi, p as n, g as Xt, a0 as mi, A as yi, H as bi, o as Ct, s as Nt, F as Ai, ah as wi, c as Ci, ai as Si, aj as Bt } from "./index-CNUFa5l3.js";
import { q as zt } from "./linear-1MXhYum8-DQFsmHI2.js";
import { s as ki } from "./ordinal-D9ksOc8y-CrGveXkB.js";
import { e as _i } from "./init-8lPFe2y8-B2MlpiqM.js";
function Ti(e, t, i) {
  e = +e, t = +t, i = (a = arguments.length) < 2 ? (t = e, e = 0, 1) : a < 3 ? 1 : +i;
  for (var s = -1, a = Math.max(0, Math.ceil((t - e) / i)) | 0, l = Array(a); ++s < a; ) l[s] = e + s * i;
  return l;
}
function mt() {
  var e = ki().unknown(void 0), t = e.domain, i = e.range, s = 0, a = 1, l, c, p = !1, d = 0, R = 0, v = 0.5;
  delete e.unknown;
  function S() {
    var m = t().length, M = a < s, P = M ? a : s, E = M ? s : a;
    l = (E - P) / Math.max(1, m - d + R * 2), p && (l = Math.floor(l)), P += (E - P - l * (m - d)) * v, c = l * (1 - d), p && (P = Math.round(P), c = Math.round(c));
    var I = Ti(m).map(function(f) {
      return P + l * f;
    });
    return i(M ? I.reverse() : I);
  }
  return e.domain = function(m) {
    return arguments.length ? (t(m), S()) : t();
  }, e.range = function(m) {
    return arguments.length ? ([s, a] = m, s = +s, a = +a, S()) : [s, a];
  }, e.rangeRound = function(m) {
    return [s, a] = m, s = +s, a = +a, p = !0, S();
  }, e.bandwidth = function() {
    return c;
  }, e.step = function() {
    return l;
  }, e.round = function(m) {
    return arguments.length ? (p = !!m, S()) : p;
  }, e.padding = function(m) {
    return arguments.length ? (d = Math.min(1, R = +m), S()) : d;
  }, e.paddingInner = function(m) {
    return arguments.length ? (d = Math.min(1, m), S()) : d;
  }, e.paddingOuter = function(m) {
    return arguments.length ? (R = +m, S()) : R;
  }, e.align = function(m) {
    return arguments.length ? (v = Math.max(0, Math.min(1, m)), S()) : v;
  }, e.copy = function() {
    return mt(t(), [s, a]).round(p).paddingInner(d).paddingOuter(R).align(v);
  }, _i.apply(S(), arguments);
}
var yt = function() {
  var e = /* @__PURE__ */ n(function(h, y, g, u) {
    for (g || (g = {}), u = h.length; u--; g[h[u]] = y) ;
    return g;
  }, "o"), t = [
    1,
    10,
    12,
    14,
    16,
    18,
    19,
    21,
    23
  ], i = [2, 6], s = [1, 3], a = [1, 5], l = [1, 6], c = [1, 7], p = [
    1,
    5,
    10,
    12,
    14,
    16,
    18,
    19,
    21,
    23,
    34,
    35,
    36
  ], d = [1, 25], R = [1, 26], v = [1, 28], S = [1, 29], m = [1, 30], M = [1, 31], P = [1, 32], E = [1, 33], I = [1, 34], f = [1, 35], D = [1, 36], r = [1, 37], z = [1, 43], F = [1, 42], H = [1, 47], X = [1, 50], A = [
    1,
    10,
    12,
    14,
    16,
    18,
    19,
    21,
    23,
    34,
    35,
    36
  ], k = [
    1,
    10,
    12,
    14,
    16,
    18,
    19,
    21,
    23,
    24,
    26,
    27,
    28,
    34,
    35,
    36
  ], T = [
    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
  ], w = [1, 64], _ = {
    trace: /* @__PURE__ */ n(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__ */ n(function(h, y, g, u, C, o, at) {
      var x = o.length - 1;
      switch (C) {
        case 5:
          u.setOrientation(o[x]);
          break;
        case 9:
          u.setDiagramTitle(o[x].text.trim());
          break;
        case 12:
          u.setLineData({
            text: "",
            type: "text"
          }, o[x]);
          break;
        case 13:
          u.setLineData(o[x - 1], o[x]);
          break;
        case 14:
          u.setBarData({
            text: "",
            type: "text"
          }, o[x]);
          break;
        case 15:
          u.setBarData(o[x - 1], o[x]);
          break;
        case 16:
          this.$ = o[x].trim(), u.setAccTitle(this.$);
          break;
        case 17:
        case 18:
          this.$ = o[x].trim(), u.setAccDescription(this.$);
          break;
        case 19:
          this.$ = o[x - 1];
          break;
        case 20:
          this.$ = [Number(o[x - 2]), ...o[x]];
          break;
        case 21:
          this.$ = [Number(o[x])];
          break;
        case 22:
          u.setXAxisTitle(o[x]);
          break;
        case 23:
          u.setXAxisTitle(o[x - 1]);
          break;
        case 24:
          u.setXAxisTitle({
            type: "text",
            text: ""
          });
          break;
        case 25:
          u.setXAxisBand(o[x]);
          break;
        case 26:
          u.setXAxisRangeData(Number(o[x - 2]), Number(o[x]));
          break;
        case 27:
          this.$ = o[x - 1];
          break;
        case 28:
          this.$ = [o[x - 2], ...o[x]];
          break;
        case 29:
          this.$ = [o[x]];
          break;
        case 30:
          u.setYAxisTitle(o[x]);
          break;
        case 31:
          u.setYAxisTitle(o[x - 1]);
          break;
        case 32:
          u.setYAxisTitle({
            type: "text",
            text: ""
          });
          break;
        case 33:
          u.setYAxisRangeData(Number(o[x - 2]), Number(o[x]));
          break;
        case 37:
          this.$ = {
            text: o[x],
            type: "text"
          };
          break;
        case 38:
          this.$ = {
            text: o[x],
            type: "text"
          };
          break;
        case 39:
          this.$ = {
            text: o[x],
            type: "markdown"
          };
          break;
        case 40:
          this.$ = o[x];
          break;
        case 41:
          this.$ = o[x - 1] + "" + o[x];
          break;
      }
    }, "anonymous"),
    table: [
      e(t, i, {
        3: 1,
        4: 2,
        7: 4,
        5: s,
        34: a,
        35: l,
        36: c
      }),
      { 1: [3] },
      e(t, i, {
        4: 2,
        7: 4,
        3: 8,
        5: s,
        34: a,
        35: l,
        36: c
      }),
      e(t, i, {
        4: 2,
        7: 4,
        6: 9,
        3: 10,
        5: s,
        8: [1, 11],
        34: a,
        35: l,
        36: c
      }),
      {
        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]
      },
      e(p, [2, 34]),
      e(p, [2, 35]),
      e(p, [2, 36]),
      { 1: [2, 1] },
      e(t, i, {
        4: 2,
        7: 4,
        3: 21,
        5: s,
        34: a,
        35: l,
        36: c
      }),
      { 1: [2, 3] },
      e(p, [2, 5]),
      e(t, [2, 7], {
        4: 22,
        34: a,
        35: l,
        36: c
      }),
      {
        11: 23,
        37: 24,
        38: d,
        39: R,
        40: 27,
        41: v,
        42: S,
        43: m,
        44: M,
        45: P,
        46: E,
        47: I,
        48: f,
        49: D,
        50: r
      },
      {
        11: 39,
        13: 38,
        24: z,
        27: F,
        29: 40,
        30: 41,
        37: 24,
        38: d,
        39: R,
        40: 27,
        41: v,
        42: S,
        43: m,
        44: M,
        45: P,
        46: E,
        47: I,
        48: f,
        49: D,
        50: r
      },
      {
        11: 45,
        15: 44,
        27: H,
        33: 46,
        37: 24,
        38: d,
        39: R,
        40: 27,
        41: v,
        42: S,
        43: m,
        44: M,
        45: P,
        46: E,
        47: I,
        48: f,
        49: D,
        50: r
      },
      {
        11: 49,
        17: 48,
        24: X,
        37: 24,
        38: d,
        39: R,
        40: 27,
        41: v,
        42: S,
        43: m,
        44: M,
        45: P,
        46: E,
        47: I,
        48: f,
        49: D,
        50: r
      },
      {
        11: 52,
        17: 51,
        24: X,
        37: 24,
        38: d,
        39: R,
        40: 27,
        41: v,
        42: S,
        43: m,
        44: M,
        45: P,
        46: E,
        47: I,
        48: f,
        49: D,
        50: r
      },
      { 20: [1, 53] },
      { 22: [1, 54] },
      e(A, [2, 18]),
      { 1: [2, 2] },
      e(A, [2, 8]),
      e(A, [2, 9]),
      e(k, [2, 37], {
        40: 55,
        41: v,
        42: S,
        43: m,
        44: M,
        45: P,
        46: E,
        47: I,
        48: f,
        49: D,
        50: r
      }),
      e(k, [2, 38]),
      e(k, [2, 39]),
      e(T, [2, 40]),
      e(T, [2, 42]),
      e(T, [2, 43]),
      e(T, [2, 44]),
      e(T, [2, 45]),
      e(T, [2, 46]),
      e(T, [2, 47]),
      e(T, [2, 48]),
      e(T, [2, 49]),
      e(T, [2, 50]),
      e(T, [2, 51]),
      e(A, [2, 10]),
      e(A, [2, 22], {
        30: 41,
        29: 56,
        24: z,
        27: F
      }),
      e(A, [2, 24]),
      e(A, [2, 25]),
      { 31: [1, 57] },
      {
        11: 59,
        32: 58,
        37: 24,
        38: d,
        39: R,
        40: 27,
        41: v,
        42: S,
        43: m,
        44: M,
        45: P,
        46: E,
        47: I,
        48: f,
        49: D,
        50: r
      },
      e(A, [2, 11]),
      e(A, [2, 30], {
        33: 60,
        27: H
      }),
      e(A, [2, 32]),
      { 31: [1, 61] },
      e(A, [2, 12]),
      {
        17: 62,
        24: X
      },
      {
        25: 63,
        27: w
      },
      e(A, [2, 14]),
      {
        17: 65,
        24: X
      },
      e(A, [2, 16]),
      e(A, [2, 17]),
      e(T, [2, 41]),
      e(A, [2, 23]),
      { 27: [1, 66] },
      { 26: [1, 67] },
      {
        26: [2, 29],
        28: [1, 68]
      },
      e(A, [2, 31]),
      { 27: [1, 69] },
      e(A, [2, 13]),
      { 26: [1, 70] },
      {
        26: [2, 21],
        28: [1, 71]
      },
      e(A, [2, 15]),
      e(A, [2, 26]),
      e(A, [2, 27]),
      {
        11: 59,
        32: 72,
        37: 24,
        38: d,
        39: R,
        40: 27,
        41: v,
        42: S,
        43: m,
        44: M,
        45: P,
        46: E,
        47: I,
        48: f,
        49: D,
        50: r
      },
      e(A, [2, 33]),
      e(A, [2, 19]),
      {
        25: 73,
        27: w
      },
      { 26: [2, 28] },
      { 26: [2, 20] }
    ],
    defaultActions: {
      8: [2, 1],
      10: [2, 3],
      21: [2, 2],
      72: [2, 28],
      73: [2, 20]
    },
    parseError: /* @__PURE__ */ n(function(h, y) {
      if (y.recoverable) this.trace(h);
      else {
        var g = Error(h);
        throw g.hash = y, g;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ n(function(h) {
      var y = this, g = [0], u = [], C = [null], o = [], at = this.table, x = "", rt = 0, vt = 0, oi = 0, ri = 2, Et = 1, li = o.slice.call(arguments, 1), L = Object.create(this.lexer), V = { yy: {} };
      for (var xt in this.yy) Object.prototype.hasOwnProperty.call(this.yy, xt) && (V.yy[xt] = this.yy[xt]);
      L.setInput(h, V.yy), V.yy.lexer = L, V.yy.parser = this, L.yylloc === void 0 && (L.yylloc = {});
      var dt = L.yylloc;
      o.push(dt);
      var ci = L.options && L.options.ranges;
      typeof V.yy.parseError == "function" ? this.parseError = V.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function ui(W) {
        g.length -= 2 * W, C.length -= W, o.length -= W;
      }
      n(ui, "popStack");
      function Mt() {
        var W = u.pop() || L.lex() || Et;
        return typeof W != "number" && (W instanceof Array && (u = W, W = u.pop()), W = y.symbols_[W] || W), W;
      }
      n(Mt, "lex");
      for (var B, pt, Y, O, ft, U = {}, lt, N, It, ct; ; ) {
        if (Y = g[g.length - 1], this.defaultActions[Y] ? O = this.defaultActions[Y] : (B ?? (B = Mt()), O = at[Y] && at[Y][B]), O === void 0 || !O.length || !O[0]) {
          var $t = "";
          for (lt in ct = [], at[Y]) this.terminals_[lt] && lt > ri && ct.push("'" + this.terminals_[lt] + "'");
          $t = L.showPosition ? "Parse error on line " + (rt + 1) + `:
` + L.showPosition() + `
Expecting ` + ct.join(", ") + ", got '" + (this.terminals_[B] || B) + "'" : "Parse error on line " + (rt + 1) + ": Unexpected " + (B == Et ? "end of input" : "'" + (this.terminals_[B] || B) + "'"), this.parseError($t, {
            text: L.match,
            token: this.terminals_[B] || B,
            line: L.yylineno,
            loc: dt,
            expected: ct
          });
        }
        if (O[0] instanceof Array && O.length > 1) throw Error("Parse Error: multiple actions possible at state: " + Y + ", token: " + B);
        switch (O[0]) {
          case 1:
            g.push(B), C.push(L.yytext), o.push(L.yylloc), g.push(O[1]), B = null, pt ? (B = pt, pt = null) : (vt = L.yyleng, x = L.yytext, rt = L.yylineno, dt = L.yylloc, oi > 0);
            break;
          case 2:
            if (N = this.productions_[O[1]][1], U.$ = C[C.length - N], U._$ = {
              first_line: o[o.length - (N || 1)].first_line,
              last_line: o[o.length - 1].last_line,
              first_column: o[o.length - (N || 1)].first_column,
              last_column: o[o.length - 1].last_column
            }, ci && (U._$.range = [o[o.length - (N || 1)].range[0], o[o.length - 1].range[1]]), ft = this.performAction.apply(U, [
              x,
              vt,
              rt,
              V.yy,
              O[1],
              C,
              o
            ].concat(li)), ft !== void 0) return ft;
            N && (g = g.slice(0, -1 * N * 2), C = C.slice(0, -1 * N), o = o.slice(0, -1 * N)), g.push(this.productions_[O[1]][0]), C.push(U.$), o.push(U._$), It = at[g[g.length - 2]][g[g.length - 1]], g.push(It);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  };
  _.lexer = /* @__PURE__ */ function() {
    return {
      EOF: 1,
      parseError: /* @__PURE__ */ n(function(h, y) {
        if (this.yy.parser) this.yy.parser.parseError(h, y);
        else throw Error(h);
      }, "parseError"),
      setInput: /* @__PURE__ */ n(function(h, y) {
        return this.yy = y || this.yy || {}, this._input = h, 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"),
      input: /* @__PURE__ */ n(function() {
        var h = this._input[0];
        return this.yytext += h, this.yyleng++, this.offset++, this.match += h, this.matched += h, h.match(/(?:\r\n?|\n).*/g) ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), h;
      }, "input"),
      unput: /* @__PURE__ */ n(function(h) {
        var y = h.length, g = h.split(/(?:\r\n?|\n)/g);
        this._input = h + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - y), this.offset -= y;
        var u = 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), g.length - 1 && (this.yylineno -= g.length - 1);
        var C = 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: g ? (g.length === u.length ? this.yylloc.first_column : 0) + u[u.length - g.length].length - g[0].length : this.yylloc.first_column - y
        }, this.options.ranges && (this.yylloc.range = [C[0], C[0] + this.yyleng - y]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      more: /* @__PURE__ */ n(function() {
        return this._more = !0, this;
      }, "more"),
      reject: /* @__PURE__ */ n(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"),
      less: /* @__PURE__ */ n(function(h) {
        this.unput(this.match.slice(h));
      }, "less"),
      pastInput: /* @__PURE__ */ n(function() {
        var h = this.matched.substr(0, this.matched.length - this.match.length);
        return (h.length > 20 ? "..." : "") + h.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      upcomingInput: /* @__PURE__ */ n(function() {
        var h = this.match;
        return h.length < 20 && (h += this._input.substr(0, 20 - h.length)), (h.substr(0, 20) + (h.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      showPosition: /* @__PURE__ */ n(function() {
        var h = this.pastInput(), y = Array(h.length + 1).join("-");
        return h + this.upcomingInput() + `
` + y + "^";
      }, "showPosition"),
      test_match: /* @__PURE__ */ n(function(h, y) {
        var g, u, C;
        if (this.options.backtrack_lexer && (C = {
          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 && (C.yylloc.range = this.yylloc.range.slice(0))), u = h[0].match(/(?:\r\n?|\n).*/g), u && (this.yylineno += u.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: u ? u[u.length - 1].length - u[u.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + h[0].length
        }, this.yytext += h[0], this.match += h[0], this.matches = h, 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(h[0].length), this.matched += h[0], g = this.performAction.call(this, this.yy, this, y, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), g) return g;
        if (this._backtrack) {
          for (var o in C) this[o] = C[o];
          return !1;
        }
        return !1;
      }, "test_match"),
      next: /* @__PURE__ */ n(function() {
        if (this.done) return this.EOF;
        this._input || (this.done = !0);
        var h, y, g, u;
        this._more || (this.yytext = "", this.match = "");
        for (var C = this._currentRules(), o = 0; o < C.length; o++) if (g = this._input.match(this.rules[C[o]]), g && (!y || g[0].length > y[0].length)) {
          if (y = g, u = o, this.options.backtrack_lexer) {
            if (h = this.test_match(g, C[o]), h !== !1) return h;
            if (this._backtrack) {
              y = !1;
              continue;
            } else return !1;
          } else if (!this.options.flex) break;
        }
        return y ? (h = this.test_match(y, C[u]), h === !1 ? !1 : h) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      }, "next"),
      lex: /* @__PURE__ */ n(function() {
        return this.next() || this.lex();
      }, "lex"),
      begin: /* @__PURE__ */ n(function(h) {
        this.conditionStack.push(h);
      }, "begin"),
      popState: /* @__PURE__ */ n(function() {
        return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      }, "popState"),
      _currentRules: /* @__PURE__ */ n(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"),
      topState: /* @__PURE__ */ n(function(h) {
        return h = this.conditionStack.length - 1 - Math.abs(h || 0), h >= 0 ? this.conditionStack[h] : "INITIAL";
      }, "topState"),
      pushState: /* @__PURE__ */ n(function(h) {
        this.begin(h);
      }, "pushState"),
      stateStackSize: /* @__PURE__ */ n(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ n(function(h, y, g, u) {
        switch (g) {
          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
        }
      }
    };
  }();
  function $() {
    this.yy = {};
  }
  return n($, "Parser"), $.prototype = _, _.Parser = $, new $();
}();
yt.parser = yt;
var Ri = yt;
function bt(e) {
  return e.type === "bar";
}
n(bt, "isBarPlot");
function St(e) {
  return e.type === "band";
}
n(St, "isBandAxisData");
function G(e) {
  return e.type === "linear";
}
n(G, "isLinearAxisData");
var j, Vt = (j = class {
  constructor(t) {
    this.parentGroup = t;
  }
  getMaxDimension(t, i) {
    if (!this.parentGroup) return {
      width: t.reduce((l, c) => Math.max(c.length, l), 0) * i,
      height: i
    };
    let s = {
      width: 0,
      height: 0
    }, a = this.parentGroup.append("g").attr("visibility", "hidden").attr("font-size", i);
    for (let l of t) {
      let c = Si(a, 1, l), p = c ? c.width : l.length * i, d = c ? c.height : i;
      s.width = Math.max(s.width, p), s.height = Math.max(s.height, d);
    }
    return a.remove(), s;
  }
}, n(j, "TextDimensionCalculatorWithFont"), j), Ot = 0.7, Wt = 0.2, Q, Yt = (Q = class {
  constructor(t, i, s, a) {
    this.axisConfig = t, this.title = i, this.textDimensionCalculator = s, this.axisThemeConfig = a, 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() {
    let 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() {
    Ot * this.getTickDistance() > this.outerPadding * 2 && (this.outerPadding = Math.floor(Ot * 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) {
      let s = this.getLabelDimension(), a = Wt * t.width;
      this.outerPadding = Math.min(s.width / 2, a);
      let l = s.height + this.axisConfig.labelPadding * 2;
      this.labelTextHeight = s.height, l <= i && (i -= l, this.showLabel = !0);
    }
    if (this.axisConfig.showTick && i >= this.axisConfig.tickLength && (this.showTick = !0, i -= this.axisConfig.tickLength), this.axisConfig.showTitle && this.title) {
      let s = this.textDimensionCalculator.getMaxDimension([this.title], this.axisConfig.titleFontSize), a = s.height + this.axisConfig.titlePadding * 2;
      this.titleTextHeight = s.height, a <= i && (i -= a, 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) {
      let s = this.getLabelDimension(), a = Wt * t.height;
      this.outerPadding = Math.min(s.height / 2, a);
      let l = s.width + this.axisConfig.labelPadding * 2;
      l <= i && (i -= l, this.showLabel = !0);
    }
    if (this.axisConfig.showTick && i >= this.axisConfig.tickLength && (this.showTick = !0, i -= this.axisConfig.tickLength), this.axisConfig.showTitle && this.title) {
      let s = this.textDimensionCalculator.getMaxDimension([this.title], this.axisConfig.titleFontSize), a = s.height + this.axisConfig.titlePadding * 2;
      this.titleTextHeight = s.height, a <= i && (i -= a, 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() {
    let t = [];
    if (this.showAxisLine) {
      let 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) {
      let 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((s) => ({
          path: `M ${i},${this.getScaleValue(s)} L ${i - this.axisConfig.tickLength},${this.getScaleValue(s)}`,
          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() {
    let t = [];
    if (this.showAxisLine) {
      let 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) {
      let i = this.boundingRect.y + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0);
      t.push({
        type: "path",
        groupTexts: ["bottom-axis", "ticks"],
        data: this.getTickValues().map((s) => ({
          path: `M ${this.getScaleValue(s)},${i} L ${this.getScaleValue(s)},${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() {
    let t = [];
    if (this.showAxisLine) {
      let 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) {
      let i = this.boundingRect.y;
      t.push({
        type: "path",
        groupTexts: ["top-axis", "ticks"],
        data: this.getTickValues().map((s) => ({
          path: `M ${this.getScaleValue(s)},${i + this.boundingRect.height - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)} L ${this.getScaleValue(s)},${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() : [];
  }
}, n(Q, "BaseAxis"), Q), K, Di = (K = class extends Yt {
  constructor(t, i, s, a, l) {
    super(t, a, l, i), this.categories = s, this.scale = mt().domain(this.categories).range(this.getRange());
  }
  setRange(t) {
    super.setRange(t);
  }
  recalculateScale() {
    this.scale = mt().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(0.5), Xt.trace("BandAxis axis final categories, range: ", this.categories, this.getRange());
  }
  getTickValues() {
    return this.categories;
  }
  getScaleValue(t) {
    return this.scale(t) ?? this.getRange()[0];
  }
}, n(K, "BandAxis"), K), q, Li = (q = class extends Yt {
  constructor(t, i, s, a, l) {
    super(t, a, l, i), this.domain = s, this.scale = zt().domain(this.domain).range(this.getRange());
  }
  getTickValues() {
    return this.scale.ticks();
  }
  recalculateScale() {
    let t = [...this.domain];
    this.axisPosition === "left" && t.reverse(), this.scale = zt().domain(t).range(this.getRange());
  }
  getScaleValue(t) {
    return this.scale(t);
  }
}, n(q, "LinearAxis"), q);
function At(e, t, i, s) {
  let a = new Vt(s);
  return St(e) ? new Di(t, i, e.categories, e.title, a) : new Li(t, i, [e.min, e.max], e.title, a);
}
n(At, "getAxis");
var J, Pi = (J = class {
  constructor(t, i, s, a) {
    this.textDimensionCalculator = t, this.chartConfig = i, this.chartData = s, this.chartThemeConfig = a, 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) {
    let i = this.textDimensionCalculator.getMaxDimension([this.chartData.title], this.chartConfig.titleFontSize), s = Math.max(i.width, t.width), a = i.height + 2 * this.chartConfig.titlePadding;
    return i.width <= s && i.height <= a && this.chartConfig.showTitle && this.chartData.title && (this.boundingRect.width = s, this.boundingRect.height = a, this.showChartTitle = !0), {
      width: this.boundingRect.width,
      height: this.boundingRect.height
    };
  }
  getDrawableElements() {
    let 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;
  }
}, n(J, "ChartTitle"), J);
function Ht(e, t, i, s) {
  return new Pi(new Vt(s), e, t, i);
}
n(Ht, "getChartTitleComponent");
var Z, vi = (Z = class {
  constructor(t, i, s, a, l) {
    this.plotData = t, this.xAxis = i, this.yAxis = s, this.orientation = a, this.plotIndex = l;
  }
  getDrawableElement() {
    let t = this.plotData.data.map((s) => [this.xAxis.getScaleValue(s[0]), this.yAxis.getScaleValue(s[1])]), i;
    return i = this.orientation === "horizontal" ? Bt().y((s) => s[0]).x((s) => s[1])(t) : Bt().x((s) => s[0]).y((s) => s[1])(t), i ? [{
      groupTexts: ["plot", `line-plot-${this.plotIndex}`],
      type: "path",
      data: [{
        path: i,
        strokeFill: this.plotData.strokeFill,
        strokeWidth: this.plotData.strokeWidth
      }]
    }] : [];
  }
}, n(Z, "LinePlot"), Z), tt, Ei = (tt = class {
  constructor(t, i, s, a, l, c) {
    this.barData = t, this.boundingRect = i, this.xAxis = s, this.yAxis = a, this.orientation = l, this.plotIndex = c;
  }
  getDrawableElement() {
    let t = this.barData.data.map((a) => [this.xAxis.getScaleValue(a[0]), this.yAxis.getScaleValue(a[1])]), i = Math.min(this.xAxis.getAxisOuterPadding() * 2, this.xAxis.getTickDistance()) * 0.95, s = i / 2;
    return this.orientation === "horizontal" ? [{
      groupTexts: ["plot", `bar-plot-${this.plotIndex}`],
      type: "rect",
      data: t.map((a) => ({
        x: this.boundingRect.x,
        y: a[0] - s,
        height: i,
        width: a[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((a) => ({
        x: a[0] - s,
        y: a[1],
        width: i,
        height: this.boundingRect.y + this.boundingRect.height - a[1],
        fill: this.barData.fill,
        strokeWidth: 0,
        strokeFill: this.barData.fill
      }))
    }];
  }
}, n(tt, "BarPlot"), tt), it, Mi = (it = class {
  constructor(t, i, s) {
    this.chartConfig = t, this.chartData = i, this.chartThemeConfig = s, 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");
    let t = [];
    for (let [i, s] of this.chartData.plots.entries()) switch (s.type) {
      case "line":
        {
          let a = new vi(s, this.xAxis, this.yAxis, this.chartConfig.chartOrientation, i);
          t.push(...a.getDrawableElement());
        }
        break;
      case "bar":
        {
          let a = new Ei(s, this.boundingRect, this.xAxis, this.yAxis, this.chartConfig.chartOrientation, i);
          t.push(...a.getDrawableElement());
        }
        break;
    }
    return t;
  }
}, n(it, "BasePlot"), it);
function Ut(e, t, i) {
  return new Mi(e, t, i);
}
n(Ut, "getPlotComponent");
var et, Ii = (et = class {
  constructor(t, i, s, a) {
    this.chartConfig = t, this.chartData = i, this.componentStore = {
      title: Ht(t, i, s, a),
      plot: Ut(t, i, s),
      xAxis: At(i.xAxis, t.xAxis, {
        titleColor: s.xAxisTitleColor,
        labelColor: s.xAxisLabelColor,
        tickColor: s.xAxisTickColor,
        axisLineColor: s.xAxisLineColor
      }, a),
      yAxis: At(i.yAxis, t.yAxis, {
        titleColor: s.yAxisTitleColor,
        labelColor: s.yAxisLabelColor,
        tickColor: s.yAxisTickColor,
        axisLineColor: s.yAxisLineColor
      }, a)
    };
  }
  calculateVerticalSpace() {
    let t = this.chartConfig.width, i = this.chartConfig.height, s = 0, a = 0, l = Math.floor(t * this.chartConfig.plotReservedSpacePercent / 100), c = Math.floor(i * this.chartConfig.plotReservedSpacePercent / 100), p = this.componentStore.plot.calculateSpace({
      width: l,
      height: c
    });
    t -= p.width, i -= p.height, p = this.componentStore.title.calculateSpace({
      width: this.chartConfig.width,
      height: i
    }), a = p.height, i -= p.height, this.componentStore.xAxis.setAxisPosition("bottom"), p = this.componentStore.xAxis.calculateSpace({
      width: t,
      height: i
    }), i -= p.height, this.componentStore.yAxis.setAxisPosition("left"), p = this.componentStore.yAxis.calculateSpace({
      width: t,
      height: i
    }), s = p.width, t -= p.width, t > 0 && (l += t, t = 0), i > 0 && (c += i, i = 0), this.componentStore.plot.calculateSpace({
      width: l,
      height: c
    }), this.componentStore.plot.setBoundingBoxXY({
      x: s,
      y: a
    }), this.componentStore.xAxis.setRange([s, s + l]), this.componentStore.xAxis.setBoundingBoxXY({
      x: s,
      y: a + c
    }), this.componentStore.yAxis.setRange([a, a + c]), this.componentStore.yAxis.setBoundingBoxXY({
      x: 0,
      y: a
    }), this.chartData.plots.some((d) => bt(d)) && this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
  }
  calculateHorizontalSpace() {
    let t = this.chartConfig.width, i = this.chartConfig.height, s = 0, a = 0, l = 0, c = Math.floor(t * this.chartConfig.plotReservedSpacePercent / 100), p = Math.floor(i * this.chartConfig.plotReservedSpacePercent / 100), d = this.componentStore.plot.calculateSpace({
      width: c,
      height: p
    });
    t -= d.width, i -= d.height, d = this.componentStore.title.calculateSpace({
      width: this.chartConfig.width,
      height: i
    }), s = d.height, i -= d.height, this.componentStore.xAxis.setAxisPosition("left"), d = this.componentStore.xAxis.calculateSpace({
      width: t,
      height: i
    }), t -= d.width, a = d.width, this.componentStore.yAxis.setAxisPosition("top"), d = this.componentStore.yAxis.calculateSpace({
      width: t,
      height: i
    }), i -= d.height, l = s + d.height, t > 0 && (c += t, t = 0), i > 0 && (p += i, i = 0), this.componentStore.plot.calculateSpace({
      width: c,
      height: p
    }), this.componentStore.plot.setBoundingBoxXY({
      x: a,
      y: l
    }), this.componentStore.yAxis.setRange([a, a + c]), this.componentStore.yAxis.setBoundingBoxXY({
      x: a,
      y: s
    }), this.componentStore.xAxis.setRange([l, l + p]), this.componentStore.xAxis.setBoundingBoxXY({
      x: 0,
      y: l
    }), this.chartData.plots.some((R) => bt(R)) && this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
  }
  calculateSpace() {
    this.chartConfig.chartOrientation === "horizontal" ? this.calculateHorizontalSpace() : this.calculateVerticalSpace();
  }
  getDrawableElement() {
    this.calculateSpace();
    let t = [];
    this.componentStore.plot.setAxes(this.componentStore.xAxis, this.componentStore.yAxis);
    for (let i of Object.values(this.componentStore)) t.push(...i.getDrawableElements());
    return t;
  }
}, n(et, "Orchestrator"), et), st, $i = (st = class {
  static build(t, i, s, a) {
    return new Ii(t, i, s, a).getDrawableElement();
  }
}, n(st, "XYChartBuilder"), st), nt = 0, Gt, ht = Tt(), ot = _t(), b = Rt(), wt = ot.plotColorPalette.split(",").map((e) => e.trim()), ut = !1, kt = !1;
function _t() {
  let e = wi(), t = Ct();
  return Nt(e.xyChart, t.themeVariables.xyChart);
}
n(_t, "getChartDefaultThemeConfig");
function Tt() {
  let e = Ct();
  return Nt(Ai.xyChart, e.xyChart);
}
n(Tt, "getChartDefaultConfig");
function Rt() {
  return {
    yAxis: {
      type: "linear",
      title: "",
      min: 1 / 0,
      max: -1 / 0
    },
    xAxis: {
      type: "band",
      title: "",
      categories: []
    },
    title: "",
    plots: []
  };
}
n(Rt, "getChartDefaultData");
function gt(e) {
  let t = Ct();
  return Ci(e.trim(), t);
}
n(gt, "textSanitizer");
function jt(e) {
  Gt = e;
}
n(jt, "setTmpSVGG");
function Qt(e) {
  e === "horizontal" ? ht.chartOrientation = "horizontal" : ht.chartOrientation = "vertical";
}
n(Qt, "setOrientation");
function Kt(e) {
  b.xAxis.title = gt(e.text);
}
n(Kt, "setXAxisTitle");
function Dt(e, t) {
  b.xAxis = {
    type: "linear",
    title: b.xAxis.title,
    min: e,
    max: t
  }, ut = !0;
}
n(Dt, "setXAxisRangeData");
function qt(e) {
  b.xAxis = {
    type: "band",
    title: b.xAxis.title,
    categories: e.map((t) => gt(t.text))
  }, ut = !0;
}
n(qt, "setXAxisBand");
function Jt(e) {
  b.yAxis.title = gt(e.text);
}
n(Jt, "setYAxisTitle");
function Zt(e, t) {
  b.yAxis = {
    type: "linear",
    title: b.yAxis.title,
    min: e,
    max: t
  }, kt = !0;
}
n(Zt, "setYAxisRangeData");
function ti(e) {
  let t = Math.min(...e), i = Math.max(...e), s = G(b.yAxis) ? b.yAxis.min : 1 / 0, a = G(b.yAxis) ? b.yAxis.max : -1 / 0;
  b.yAxis = {
    type: "linear",
    title: b.yAxis.title,
    min: Math.min(s, t),
    max: Math.max(a, i)
  };
}
n(ti, "setYAxisRangeFromPlotData");
function Lt(e) {
  let t = [];
  if (e.length === 0) return t;
  if (!ut) {
    let i = G(b.xAxis) ? b.xAxis.min : 1 / 0, s = G(b.xAxis) ? b.xAxis.max : -1 / 0;
    Dt(Math.min(i, 1), Math.max(s, e.length));
  }
  if (kt || ti(e), St(b.xAxis) && (t = b.xAxis.categories.map((i, s) => [i, e[s]])), G(b.xAxis)) {
    let i = b.xAxis.min, s = b.xAxis.max, a = (s - i) / (e.length - 1), l = [];
    for (let c = i; c <= s; c += a) l.push(`${c}`);
    t = l.map((c, p) => [c, e[p]]);
  }
  return t;
}
n(Lt, "transformDataWithoutCategory");
function Pt(e) {
  return wt[e === 0 ? 0 : e % wt.length];
}
n(Pt, "getPlotColorFromPalette");
function ii(e, t) {
  let i = Lt(t);
  b.plots.push({
    type: "line",
    strokeFill: Pt(nt),
    strokeWidth: 2,
    data: i
  }), nt++;
}
n(ii, "setLineData");
function ei(e, t) {
  let i = Lt(t);
  b.plots.push({
    type: "bar",
    fill: Pt(nt),
    data: i
  }), nt++;
}
n(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 = Ft(), $i.build(ht, b, ot, Gt);
}
n(si, "getDrawableElem");
function ai() {
  return ot;
}
n(ai, "getChartThemeConfig");
function ni() {
  return ht;
}
n(ni, "getChartConfig");
function hi() {
  return b;
}
n(hi, "getXYChartData");
var Fi = {
  parser: Ri,
  db: {
    getDrawableElem: si,
    clear: /* @__PURE__ */ n(function() {
      bi(), nt = 0, ht = Tt(), b = Rt(), ot = _t(), wt = ot.plotColorPalette.split(",").map((e) => e.trim()), ut = !1, kt = !1;
    }, "clear"),
    setAccTitle: fi,
    getAccTitle: pi,
    setDiagramTitle: di,
    getDiagramTitle: Ft,
    getAccDescription: xi,
    setAccDescription: gi,
    setOrientation: Qt,
    setXAxisTitle: Kt,
    setXAxisRangeData: Dt,
    setXAxisBand: qt,
    setYAxisTitle: Jt,
    setYAxisRangeData: Zt,
    setLineData: ii,
    setBarData: ei,
    setTmpSVGG: jt,
    getChartThemeConfig: ai,
    getChartConfig: ni,
    getXYChartData: hi
  },
  renderer: { draw: /* @__PURE__ */ n((e, t, i, s) => {
    let a = s.db, l = a.getChartThemeConfig(), c = a.getChartConfig(), p = a.getXYChartData().plots[0].data.map((f) => f[1]);
    function d(f) {
      return f === "top" ? "text-before-edge" : "middle";
    }
    n(d, "getDominantBaseLine");
    function R(f) {
      return f === "left" ? "start" : f === "right" ? "end" : "middle";
    }
    n(R, "getTextAnchor");
    function v(f) {
      return `translate(${f.x}, ${f.y}) rotate(${f.rotation || 0})`;
    }
    n(v, "getTextTransformation"), Xt.debug(`Rendering xychart chart
` + e);
    let S = mi(t), m = S.append("g").attr("class", "main"), M = m.append("rect").attr("width", c.width).attr("height", c.height).attr("class", "background");
    yi(S, c.height, c.width, !0), S.attr("viewBox", `0 0 ${c.width} ${c.height}`), M.attr("fill", l.backgroundColor), a.setTmpSVGG(S.append("g").attr("class", "mermaid-tmp-group"));
    let P = a.getDrawableElem(), E = {};
    function I(f) {
      let D = m, r = "";
      for (let [z] of f.entries()) {
        let F = m;
        z > 0 && E[r] && (F = E[r]), r += f[z], D = E[r], D || (D = E[r] = F.append("g").attr("class", f[z]));
      }
      return D;
    }
    n(I, "getGroup");
    for (let f of P) {
      if (f.data.length === 0) continue;
      let D = I(f.groupTexts);
      switch (f.type) {
        case "rect":
          if (D.selectAll("rect").data(f.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), c.showDataLabel) {
            let r = c.showDataLabelOutsideBar;
            if (c.chartOrientation === "horizontal") {
              let z = function(w, _) {
                let { data: $, label: h } = w;
                return _ * h.length * F <= $.width - H;
              };
              n(z, "fitsHorizontally");
              let F = 0.7, H = 10, X = f.data.map((w, _) => ({
                data: w,
                label: p[_].toString()
              })).filter((w) => w.data.width > 0 && w.data.height > 0), A = X.map((w) => {
                let { data: _ } = w, $ = _.height * 0.7;
                for (; !z(w, $) && $ > 0; ) --$;
                return $;
              }), k = Math.floor(Math.min(...A)), T = /* @__PURE__ */ n((w) => r ? w.data.x + w.data.width + 10 : w.data.x + w.data.width - 10, "determineLabelXPosition");
              D.selectAll("text").data(X).enter().append("text").attr("x", T).attr("y", (w) => w.data.y + w.data.height / 2).attr("text-anchor", r ? "start" : "end").attr("dominant-baseline", "middle").attr("fill", l.dataLabelColor).attr("font-size", `${k}px`).text((w) => w.label);
            } else {
              let z = function(k, T, w) {
                let { data: _, label: $ } = k, h = T * $.length * 0.7, y = _.x + _.width / 2, g = y - h / 2, u = y + h / 2, C = g >= _.x && u <= _.x + _.width, o = _.y + w + T <= _.y + _.height;
                return C && o;
              };
              n(z, "fitsInBar");
              let F = f.data.map((k, T) => ({
                data: k,
                label: p[T].toString()
              })).filter((k) => k.data.width > 0 && k.data.height > 0), H = F.map((k) => {
                let { data: T, label: w } = k, _ = T.width / (w.length * 0.7);
                for (; !z(k, _, 10) && _ > 0; ) --_;
                return _;
              }), X = Math.floor(Math.min(...H)), A = /* @__PURE__ */ n((k) => r ? k.data.y - 10 : k.data.y + 10, "determineLabelYPosition");
              D.selectAll("text").data(F).enter().append("text").attr("x", (k) => k.data.x + k.data.width / 2).attr("y", A).attr("text-anchor", "middle").attr("dominant-baseline", r ? "auto" : "hanging").attr("fill", l.dataLabelColor).attr("font-size", `${X}px`).text((k) => k.label);
            }
          }
          break;
        case "text":
          D.selectAll("text").data(f.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) => d(r.verticalPos)).attr("text-anchor", (r) => R(r.horizontalPos)).attr("transform", (r) => v(r)).text((r) => r.text);
          break;
        case "path":
          D.selectAll("path").data(f.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") }
};
export {
  Fi as diagram
};
