import { _, ak as xt, aj as kt, a5 as vt, a6 as bt, a8 as wt, a7 as St, g as lt, ap as Et, a9 as Q, bk as Lt, aq as Mt, ag as At } from "./index-CMZig9xg.js";
import { h as Tt } from "./ordinal-DfAQgscy-BEJTu10r.js";
function Dt(t) {
  for (var n = t.length / 6 | 0, r = new Array(n), a = 0; a < n; ) r[a] = "#" + t.slice(a * 6, ++a * 6);
  return r;
}
const Pt = Dt("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");
function ct(t, n) {
  let r;
  if (n === void 0)
    for (const a of t)
      a != null && (r < a || r === void 0 && a >= a) && (r = a);
  else {
    let a = -1;
    for (let c of t)
      (c = n(c, ++a, t)) != null && (r < c || r === void 0 && c >= c) && (r = c);
  }
  return r;
}
function dt(t, n) {
  let r;
  if (n === void 0)
    for (const a of t)
      a != null && (r > a || r === void 0 && a >= a) && (r = a);
  else {
    let a = -1;
    for (let c of t)
      (c = n(c, ++a, t)) != null && (r > c || r === void 0 && c >= c) && (r = c);
  }
  return r;
}
function tt(t, n) {
  let r = 0;
  if (n === void 0)
    for (let a of t)
      (a = +a) && (r += a);
  else {
    let a = -1;
    for (let c of t)
      (c = +n(c, ++a, t)) && (r += c);
  }
  return r;
}
function Ct(t) {
  return t.target.depth;
}
function Nt(t) {
  return t.depth;
}
function Ot(t, n) {
  return n - 1 - t.height;
}
function _t(t, n) {
  return t.sourceLinks.length ? t.depth : n - 1;
}
function It(t) {
  return t.targetLinks.length ? t.depth : t.sourceLinks.length ? dt(t.sourceLinks, Ct) - 1 : 0;
}
function R(t) {
  return function() {
    return t;
  };
}
function ut(t, n) {
  return X(t.source, n.source) || t.index - n.index;
}
function ht(t, n) {
  return X(t.target, n.target) || t.index - n.index;
}
function X(t, n) {
  return t.y0 - n.y0;
}
function et(t) {
  return t.value;
}
function jt(t) {
  return t.index;
}
function $t(t) {
  return t.nodes;
}
function zt(t) {
  return t.links;
}
function ft(t, n) {
  const r = t.get(n);
  if (!r) throw new Error("missing: " + n);
  return r;
}
function yt({ nodes: t }) {
  for (const n of t) {
    let r = n.y0, a = r;
    for (const c of n.sourceLinks)
      c.y0 = r + c.width / 2, r += c.width;
    for (const c of n.targetLinks)
      c.y1 = a + c.width / 2, a += c.width;
  }
}
function Ft() {
  let t = 0, n = 0, r = 1, a = 1, c = 24, k = 8, d, m = jt, i = _t, o, f, p = $t, y = zt, w = 6;
  function v() {
    const e = { nodes: p.apply(null, arguments), links: y.apply(null, arguments) };
    return P(e), A(e), T(e), O(e), C(e), yt(e), e;
  }
  v.update = function(e) {
    return yt(e), e;
  }, v.nodeId = function(e) {
    return arguments.length ? (m = typeof e == "function" ? e : R(e), v) : m;
  }, v.nodeAlign = function(e) {
    return arguments.length ? (i = typeof e == "function" ? e : R(e), v) : i;
  }, v.nodeSort = function(e) {
    return arguments.length ? (o = e, v) : o;
  }, v.nodeWidth = function(e) {
    return arguments.length ? (c = +e, v) : c;
  }, v.nodePadding = function(e) {
    return arguments.length ? (k = d = +e, v) : k;
  }, v.nodes = function(e) {
    return arguments.length ? (p = typeof e == "function" ? e : R(e), v) : p;
  }, v.links = function(e) {
    return arguments.length ? (y = typeof e == "function" ? e : R(e), v) : y;
  }, v.linkSort = function(e) {
    return arguments.length ? (f = e, v) : f;
  }, v.size = function(e) {
    return arguments.length ? (t = n = 0, r = +e[0], a = +e[1], v) : [r - t, a - n];
  }, v.extent = function(e) {
    return arguments.length ? (t = +e[0][0], r = +e[1][0], n = +e[0][1], a = +e[1][1], v) : [[t, n], [r, a]];
  }, v.iterations = function(e) {
    return arguments.length ? (w = +e, v) : w;
  };
  function P({ nodes: e, links: h }) {
    for (const [u, s] of e.entries())
      s.index = u, s.sourceLinks = [], s.targetLinks = [];
    const l = new Map(e.map((u, s) => [m(u, s, e), u]));
    for (const [u, s] of h.entries()) {
      s.index = u;
      let { source: x, target: b } = s;
      typeof x != "object" && (x = s.source = ft(l, x)), typeof b != "object" && (b = s.target = ft(l, b)), x.sourceLinks.push(s), b.targetLinks.push(s);
    }
    if (f != null)
      for (const { sourceLinks: u, targetLinks: s } of e)
        u.sort(f), s.sort(f);
  }
  function A({ nodes: e }) {
    for (const h of e)
      h.value = h.fixedValue === void 0 ? Math.max(tt(h.sourceLinks, et), tt(h.targetLinks, et)) : h.fixedValue;
  }
  function T({ nodes: e }) {
    const h = e.length;
    let l = new Set(e), u = /* @__PURE__ */ new Set(), s = 0;
    for (; l.size; ) {
      for (const x of l) {
        x.depth = s;
        for (const { target: b } of x.sourceLinks)
          u.add(b);
      }
      if (++s > h) throw new Error("circular link");
      l = u, u = /* @__PURE__ */ new Set();
    }
  }
  function O({ nodes: e }) {
    const h = e.length;
    let l = new Set(e), u = /* @__PURE__ */ new Set(), s = 0;
    for (; l.size; ) {
      for (const x of l) {
        x.height = s;
        for (const { source: b } of x.targetLinks)
          u.add(b);
      }
      if (++s > h) throw new Error("circular link");
      l = u, u = /* @__PURE__ */ new Set();
    }
  }
  function D({ nodes: e }) {
    const h = ct(e, (s) => s.depth) + 1, l = (r - t - c) / (h - 1), u = new Array(h);
    for (const s of e) {
      const x = Math.max(0, Math.min(h - 1, Math.floor(i.call(null, s, h))));
      s.layer = x, s.x0 = t + x * l, s.x1 = s.x0 + c, u[x] ? u[x].push(s) : u[x] = [s];
    }
    if (o) for (const s of u)
      s.sort(o);
    return u;
  }
  function S(e) {
    const h = dt(e, (l) => (a - n - (l.length - 1) * d) / tt(l, et));
    for (const l of e) {
      let u = n;
      for (const s of l) {
        s.y0 = u, s.y1 = u + s.value * h, u = s.y1 + d;
        for (const x of s.sourceLinks)
          x.width = x.value * h;
      }
      u = (a - u + d) / (l.length + 1);
      for (let s = 0; s < l.length; ++s) {
        const x = l[s];
        x.y0 += u * (s + 1), x.y1 += u * (s + 1);
      }
      j(l);
    }
  }
  function C(e) {
    const h = D(e);
    d = Math.min(k, (a - n) / (ct(h, (l) => l.length) - 1)), S(h);
    for (let l = 0; l < w; ++l) {
      const u = Math.pow(0.99, l), s = Math.max(1 - u, (l + 1) / w);
      N(h, u, s), I(h, u, s);
    }
  }
  function I(e, h, l) {
    for (let u = 1, s = e.length; u < s; ++u) {
      const x = e[u];
      for (const b of x) {
        let V = 0, $ = 0;
        for (const { source: q, value: J } of b.targetLinks) {
          let Y = J * (b.layer - q.layer);
          V += M(q, b) * Y, $ += Y;
        }
        if (!($ > 0)) continue;
        let W = (V / $ - b.y0) * h;
        b.y0 += W, b.y1 += W, E(b);
      }
      o === void 0 && x.sort(X), g(x, l);
    }
  }
  function N(e, h, l) {
    for (let u = e.length, s = u - 2; s >= 0; --s) {
      const x = e[s];
      for (const b of x) {
        let V = 0, $ = 0;
        for (const { target: q, value: J } of b.sourceLinks) {
          let Y = J * (q.layer - b.layer);
          V += U(b, q) * Y, $ += Y;
        }
        if (!($ > 0)) continue;
        let W = (V / $ - b.y0) * h;
        b.y0 += W, b.y1 += W, E(b);
      }
      o === void 0 && x.sort(X), g(x, l);
    }
  }
  function g(e, h) {
    const l = e.length >> 1, u = e[l];
    G(e, u.y0 - d, l - 1, h), L(e, u.y1 + d, l + 1, h), G(e, a, e.length - 1, h), L(e, n, 0, h);
  }
  function L(e, h, l, u) {
    for (; l < e.length; ++l) {
      const s = e[l], x = (h - s.y0) * u;
      x > 1e-6 && (s.y0 += x, s.y1 += x), h = s.y1 + d;
    }
  }
  function G(e, h, l, u) {
    for (; l >= 0; --l) {
      const s = e[l], x = (s.y1 - h) * u;
      x > 1e-6 && (s.y0 -= x, s.y1 -= x), h = s.y0 - d;
    }
  }
  function E({ sourceLinks: e, targetLinks: h }) {
    if (f === void 0) {
      for (const { source: { sourceLinks: l } } of h)
        l.sort(ht);
      for (const { target: { targetLinks: l } } of e)
        l.sort(ut);
    }
  }
  function j(e) {
    if (f === void 0)
      for (const { sourceLinks: h, targetLinks: l } of e)
        h.sort(ht), l.sort(ut);
  }
  function M(e, h) {
    let l = e.y0 - (e.sourceLinks.length - 1) * d / 2;
    for (const { target: u, width: s } of e.sourceLinks) {
      if (u === h) break;
      l += s + d;
    }
    for (const { source: u, width: s } of h.targetLinks) {
      if (u === e) break;
      l -= s;
    }
    return l;
  }
  function U(e, h) {
    let l = h.y0 - (h.targetLinks.length - 1) * d / 2;
    for (const { source: u, width: s } of h.targetLinks) {
      if (u === e) break;
      l += s + d;
    }
    for (const { target: u, width: s } of e.sourceLinks) {
      if (u === h) break;
      l -= s;
    }
    return l;
  }
  return v;
}
var rt = Math.PI, st = 2 * rt, z = 1e-6, Gt = st - z;
function ot() {
  this._x0 = this._y0 = // start of current subpath
  this._x1 = this._y1 = null, this._ = "";
}
function mt() {
  return new ot();
}
ot.prototype = mt.prototype = {
  constructor: ot,
  moveTo: function(t, n) {
    this._ += "M" + (this._x0 = this._x1 = +t) + "," + (this._y0 = this._y1 = +n);
  },
  closePath: function() {
    this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z");
  },
  lineTo: function(t, n) {
    this._ += "L" + (this._x1 = +t) + "," + (this._y1 = +n);
  },
  quadraticCurveTo: function(t, n, r, a) {
    this._ += "Q" + +t + "," + +n + "," + (this._x1 = +r) + "," + (this._y1 = +a);
  },
  bezierCurveTo: function(t, n, r, a, c, k) {
    this._ += "C" + +t + "," + +n + "," + +r + "," + +a + "," + (this._x1 = +c) + "," + (this._y1 = +k);
  },
  arcTo: function(t, n, r, a, c) {
    t = +t, n = +n, r = +r, a = +a, c = +c;
    var k = this._x1, d = this._y1, m = r - t, i = a - n, o = k - t, f = d - n, p = o * o + f * f;
    if (c < 0) throw new Error("negative radius: " + c);
    if (this._x1 === null)
      this._ += "M" + (this._x1 = t) + "," + (this._y1 = n);
    else if (p > z) if (!(Math.abs(f * m - i * o) > z) || !c)
      this._ += "L" + (this._x1 = t) + "," + (this._y1 = n);
    else {
      var y = r - k, w = a - d, v = m * m + i * i, P = y * y + w * w, A = Math.sqrt(v), T = Math.sqrt(p), O = c * Math.tan((rt - Math.acos((v + p - P) / (2 * A * T))) / 2), D = O / T, S = O / A;
      Math.abs(D - 1) > z && (this._ += "L" + (t + D * o) + "," + (n + D * f)), this._ += "A" + c + "," + c + ",0,0," + +(f * y > o * w) + "," + (this._x1 = t + S * m) + "," + (this._y1 = n + S * i);
    }
  },
  arc: function(t, n, r, a, c, k) {
    t = +t, n = +n, r = +r, k = !!k;
    var d = r * Math.cos(a), m = r * Math.sin(a), i = t + d, o = n + m, f = 1 ^ k, p = k ? a - c : c - a;
    if (r < 0) throw new Error("negative radius: " + r);
    this._x1 === null ? this._ += "M" + i + "," + o : (Math.abs(this._x1 - i) > z || Math.abs(this._y1 - o) > z) && (this._ += "L" + i + "," + o), r && (p < 0 && (p = p % st + st), p > Gt ? this._ += "A" + r + "," + r + ",0,1," + f + "," + (t - d) + "," + (n - m) + "A" + r + "," + r + ",0,1," + f + "," + (this._x1 = i) + "," + (this._y1 = o) : p > z && (this._ += "A" + r + "," + r + ",0," + +(p >= rt) + "," + f + "," + (this._x1 = t + r * Math.cos(c)) + "," + (this._y1 = n + r * Math.sin(c))));
  },
  rect: function(t, n, r, a) {
    this._ += "M" + (this._x0 = this._x1 = +t) + "," + (this._y0 = this._y1 = +n) + "h" + +r + "v" + +a + "h" + -r + "Z";
  },
  toString: function() {
    return this._;
  }
};
function gt(t) {
  return function() {
    return t;
  };
}
function Ut(t) {
  return t[0];
}
function Vt(t) {
  return t[1];
}
var Wt = Array.prototype.slice;
function qt(t) {
  return t.source;
}
function Yt(t) {
  return t.target;
}
function Qt(t) {
  var n = qt, r = Yt, a = Ut, c = Vt, k = null;
  function d() {
    var m, i = Wt.call(arguments), o = n.apply(this, i), f = r.apply(this, i);
    if (k || (k = m = mt()), t(k, +a.apply(this, (i[0] = o, i)), +c.apply(this, i), +a.apply(this, (i[0] = f, i)), +c.apply(this, i)), m) return k = null, m + "" || null;
  }
  return d.source = function(m) {
    return arguments.length ? (n = m, d) : n;
  }, d.target = function(m) {
    return arguments.length ? (r = m, d) : r;
  }, d.x = function(m) {
    return arguments.length ? (a = typeof m == "function" ? m : gt(+m), d) : a;
  }, d.y = function(m) {
    return arguments.length ? (c = typeof m == "function" ? m : gt(+m), d) : c;
  }, d.context = function(m) {
    return arguments.length ? (k = m ?? null, d) : k;
  }, d;
}
function Rt(t, n, r, a, c) {
  t.moveTo(n, r), t.bezierCurveTo(n = (n + a) / 2, r, n, c, a, c);
}
function Xt() {
  return Qt(Rt);
}
function Kt(t) {
  return [t.source.x1, t.y0];
}
function Zt(t) {
  return [t.target.x0, t.y1];
}
function Bt() {
  return Xt().source(Kt).target(Zt);
}
var at = function() {
  var t = /* @__PURE__ */ _(function(m, i, o, f) {
    for (o = o || {}, f = m.length; f--; o[m[f]] = i) ;
    return o;
  }, "o"), n = [1, 9], r = [1, 10], a = [1, 5, 10, 12], c = {
    trace: /* @__PURE__ */ _(function() {
    }, "trace"),
    yy: {},
    symbols_: { error: 2, start: 3, SANKEY: 4, NEWLINE: 5, csv: 6, opt_eof: 7, record: 8, csv_tail: 9, EOF: 10, "field[source]": 11, COMMA: 12, "field[target]": 13, "field[value]": 14, field: 15, escaped: 16, non_escaped: 17, DQUOTE: 18, ESCAPED_TEXT: 19, NON_ESCAPED_TEXT: 20, $accept: 0, $end: 1 },
    terminals_: { 2: "error", 4: "SANKEY", 5: "NEWLINE", 10: "EOF", 11: "field[source]", 12: "COMMA", 13: "field[target]", 14: "field[value]", 18: "DQUOTE", 19: "ESCAPED_TEXT", 20: "NON_ESCAPED_TEXT" },
    productions_: [0, [3, 4], [6, 2], [9, 2], [9, 0], [7, 1], [7, 0], [8, 5], [15, 1], [15, 1], [16, 3], [17, 1]],
    performAction: /* @__PURE__ */ _(function(m, i, o, f, p, y, w) {
      var v = y.length - 1;
      switch (p) {
        case 7:
          const P = f.findOrCreateNode(y[v - 4].trim().replaceAll('""', '"')), A = f.findOrCreateNode(y[v - 2].trim().replaceAll('""', '"')), T = parseFloat(y[v].trim());
          f.addLink(P, A, T);
          break;
        case 8:
        case 9:
        case 11:
          this.$ = y[v];
          break;
        case 10:
          this.$ = y[v - 1];
          break;
      }
    }, "anonymous"),
    table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, { 5: [1, 3] }, { 6: 4, 8: 5, 15: 6, 16: 7, 17: 8, 18: n, 20: r }, { 1: [2, 6], 7: 11, 10: [1, 12] }, t(r, [2, 4], { 9: 13, 5: [1, 14] }), { 12: [1, 15] }, t(a, [2, 8]), t(a, [2, 9]), { 19: [1, 16] }, t(a, [2, 11]), { 1: [2, 1] }, { 1: [2, 5] }, t(r, [2, 2]), { 6: 17, 8: 5, 15: 6, 16: 7, 17: 8, 18: n, 20: r }, { 15: 18, 16: 7, 17: 8, 18: n, 20: r }, { 18: [1, 19] }, t(r, [2, 3]), { 12: [1, 20] }, t(a, [2, 10]), { 15: 21, 16: 7, 17: 8, 18: n, 20: r }, t([1, 5, 10], [2, 7])],
    defaultActions: { 11: [2, 1], 12: [2, 5] },
    parseError: /* @__PURE__ */ _(function(m, i) {
      if (i.recoverable)
        this.trace(m);
      else {
        var o = new Error(m);
        throw o.hash = i, o;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ _(function(m) {
      var i = this, o = [0], f = [], p = [null], y = [], w = this.table, v = "", P = 0, A = 0, T = 2, O = 1, D = y.slice.call(arguments, 1), S = Object.create(this.lexer), C = { yy: {} };
      for (var I in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, I) && (C.yy[I] = this.yy[I]);
      S.setInput(m, C.yy), C.yy.lexer = S, C.yy.parser = this, typeof S.yylloc > "u" && (S.yylloc = {});
      var N = S.yylloc;
      y.push(N);
      var g = S.options && S.options.ranges;
      typeof C.yy.parseError == "function" ? this.parseError = C.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function L(b) {
        o.length = o.length - 2 * b, p.length = p.length - b, y.length = y.length - b;
      }
      _(L, "popStack");
      function G() {
        var b;
        return b = f.pop() || S.lex() || O, typeof b != "number" && (b instanceof Array && (f = b, b = f.pop()), b = i.symbols_[b] || b), b;
      }
      _(G, "lex");
      for (var E, j, M, U, e = {}, h, l, u, s; ; ) {
        if (j = o[o.length - 1], this.defaultActions[j] ? M = this.defaultActions[j] : ((E === null || typeof E > "u") && (E = G()), M = w[j] && w[j][E]), typeof M > "u" || !M.length || !M[0]) {
          var x = "";
          s = [];
          for (h in w[j])
            this.terminals_[h] && h > T && s.push("'" + this.terminals_[h] + "'");
          S.showPosition ? x = "Parse error on line " + (P + 1) + `:
` + S.showPosition() + `
Expecting ` + s.join(", ") + ", got '" + (this.terminals_[E] || E) + "'" : x = "Parse error on line " + (P + 1) + ": Unexpected " + (E == O ? "end of input" : "'" + (this.terminals_[E] || E) + "'"), this.parseError(x, {
            text: S.match,
            token: this.terminals_[E] || E,
            line: S.yylineno,
            loc: N,
            expected: s
          });
        }
        if (M[0] instanceof Array && M.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + j + ", token: " + E);
        switch (M[0]) {
          case 1:
            o.push(E), p.push(S.yytext), y.push(S.yylloc), o.push(M[1]), E = null, A = S.yyleng, v = S.yytext, P = S.yylineno, N = S.yylloc;
            break;
          case 2:
            if (l = this.productions_[M[1]][1], e.$ = p[p.length - l], e._$ = {
              first_line: y[y.length - (l || 1)].first_line,
              last_line: y[y.length - 1].last_line,
              first_column: y[y.length - (l || 1)].first_column,
              last_column: y[y.length - 1].last_column
            }, g && (e._$.range = [
              y[y.length - (l || 1)].range[0],
              y[y.length - 1].range[1]
            ]), U = this.performAction.apply(e, [
              v,
              A,
              P,
              C.yy,
              M[1],
              p,
              y
            ].concat(D)), typeof U < "u")
              return U;
            l && (o = o.slice(0, -1 * l * 2), p = p.slice(0, -1 * l), y = y.slice(0, -1 * l)), o.push(this.productions_[M[1]][0]), p.push(e.$), y.push(e._$), u = w[o[o.length - 2]][o[o.length - 1]], o.push(u);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, k = /* @__PURE__ */ function() {
    var m = {
      EOF: 1,
      parseError: /* @__PURE__ */ _(function(i, o) {
        if (this.yy.parser)
          this.yy.parser.parseError(i, o);
        else
          throw new Error(i);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ _(function(i, o) {
        return this.yy = o || this.yy || {}, this._input = i, 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__ */ _(function() {
        var i = this._input[0];
        this.yytext += i, this.yyleng++, this.offset++, this.match += i, this.matched += i;
        var o = i.match(/(?:\r\n?|\n).*/g);
        return o ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), i;
      }, "input"),
      // unshifts one char (or a string) into the input
      unput: /* @__PURE__ */ _(function(i) {
        var o = i.length, f = i.split(/(?:\r\n?|\n)/g);
        this._input = i + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - o), this.offset -= o;
        var p = 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), f.length - 1 && (this.yylineno -= f.length - 1);
        var y = 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: f ? (f.length === p.length ? this.yylloc.first_column : 0) + p[p.length - f.length].length - f[0].length : this.yylloc.first_column - o
        }, this.options.ranges && (this.yylloc.range = [y[0], y[0] + this.yyleng - o]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      // When called from action, caches matched text and appends it on next action
      more: /* @__PURE__ */ _(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__ */ _(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__ */ _(function(i) {
        this.unput(this.match.slice(i));
      }, "less"),
      // displays already matched input, i.e. for error messages
      pastInput: /* @__PURE__ */ _(function() {
        var i = this.matched.substr(0, this.matched.length - this.match.length);
        return (i.length > 20 ? "..." : "") + i.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      // displays upcoming input, i.e. for error messages
      upcomingInput: /* @__PURE__ */ _(function() {
        var i = this.match;
        return i.length < 20 && (i += this._input.substr(0, 20 - i.length)), (i.substr(0, 20) + (i.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      // displays the character position where the lexing error occurred, i.e. for error messages
      showPosition: /* @__PURE__ */ _(function() {
        var i = this.pastInput(), o = new Array(i.length + 1).join("-");
        return i + this.upcomingInput() + `
` + o + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ _(function(i, o) {
        var f, p, y;
        if (this.options.backtrack_lexer && (y = {
          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 && (y.yylloc.range = this.yylloc.range.slice(0))), p = i[0].match(/(?:\r\n?|\n).*/g), p && (this.yylineno += p.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: p ? p[p.length - 1].length - p[p.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + i[0].length
        }, this.yytext += i[0], this.match += i[0], this.matches = i, 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(i[0].length), this.matched += i[0], f = this.performAction.call(this, this.yy, this, o, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), f)
          return f;
        if (this._backtrack) {
          for (var w in y)
            this[w] = y[w];
          return !1;
        }
        return !1;
      }, "test_match"),
      // return next match in input
      next: /* @__PURE__ */ _(function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var i, o, f, p;
        this._more || (this.yytext = "", this.match = "");
        for (var y = this._currentRules(), w = 0; w < y.length; w++)
          if (f = this._input.match(this.rules[y[w]]), f && (!o || f[0].length > o[0].length)) {
            if (o = f, p = w, this.options.backtrack_lexer) {
              if (i = this.test_match(f, y[w]), i !== !1)
                return i;
              if (this._backtrack) {
                o = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return o ? (i = this.test_match(o, y[p]), i !== !1 ? i : !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__ */ _(function() {
        var i = this.next();
        return i || this.lex();
      }, "lex"),
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: /* @__PURE__ */ _(function(i) {
        this.conditionStack.push(i);
      }, "begin"),
      // pop the previously active lexer condition state off the condition stack
      popState: /* @__PURE__ */ _(function() {
        var i = this.conditionStack.length - 1;
        return i > 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__ */ _(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__ */ _(function(i) {
        return i = this.conditionStack.length - 1 - Math.abs(i || 0), i >= 0 ? this.conditionStack[i] : "INITIAL";
      }, "topState"),
      // alias for begin(condition)
      pushState: /* @__PURE__ */ _(function(i) {
        this.begin(i);
      }, "pushState"),
      // return the number of states currently on the stack
      stateStackSize: /* @__PURE__ */ _(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ _(function(i, o, f, p) {
        switch (f) {
          case 0:
            return this.pushState("csv"), 4;
          case 1:
            return 10;
          case 2:
            return 5;
          case 3:
            return 12;
          case 4:
            return this.pushState("escaped_text"), 18;
          case 5:
            return 20;
          case 6:
            return this.popState("escaped_text"), 18;
          case 7:
            return 19;
        }
      }, "anonymous"),
      rules: [/^(?:sankey-beta\b)/i, /^(?:$)/i, /^(?:((\u000D\u000A)|(\u000A)))/i, /^(?:(\u002C))/i, /^(?:(\u0022))/i, /^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i, /^(?:(\u0022)(?!(\u0022)))/i, /^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],
      conditions: { csv: { rules: [1, 2, 3, 4, 5, 6, 7], inclusive: !1 }, escaped_text: { rules: [6, 7], inclusive: !1 }, INITIAL: { rules: [0, 1, 2, 3, 4, 5, 6, 7], inclusive: !0 } }
    };
    return m;
  }();
  c.lexer = k;
  function d() {
    this.yy = {};
  }
  return _(d, "Parser"), d.prototype = c, c.Parser = d, new d();
}();
at.parser = at;
var K = at, B = [], H = [], Z = /* @__PURE__ */ new Map(), Ht = /* @__PURE__ */ _(() => {
  B = [], H = [], Z = /* @__PURE__ */ new Map(), Mt();
}, "clear"), nt, Jt = (nt = class {
  constructor(t, n, r = 0) {
    this.source = t, this.target = n, this.value = r;
  }
}, _(nt, "SankeyLink"), nt), te = /* @__PURE__ */ _((t, n, r) => {
  B.push(new Jt(t, n, r));
}, "addLink"), it, ee = (it = class {
  constructor(t) {
    this.ID = t;
  }
}, _(it, "SankeyNode"), it), ne = /* @__PURE__ */ _((t) => {
  t = At.sanitizeText(t, lt());
  let n = Z.get(t);
  return n === void 0 && (n = new ee(t), Z.set(t, n), H.push(n)), n;
}, "findOrCreateNode"), ie = /* @__PURE__ */ _(() => H, "getNodes"), re = /* @__PURE__ */ _(() => B, "getLinks"), se = /* @__PURE__ */ _(() => ({
  nodes: H.map((t) => ({ id: t.ID })),
  links: B.map((t) => ({
    source: t.source.ID,
    target: t.target.ID,
    value: t.value
  }))
}), "getGraph"), oe = {
  nodesMap: Z,
  getConfig: /* @__PURE__ */ _(() => lt().sankey, "getConfig"),
  getNodes: ie,
  getLinks: re,
  getGraph: se,
  addLink: te,
  findOrCreateNode: ne,
  getAccTitle: St,
  setAccTitle: wt,
  getAccDescription: bt,
  setAccDescription: vt,
  getDiagramTitle: kt,
  setDiagramTitle: xt,
  clear: Ht
}, F, pt = (F = class {
  static next(t) {
    return new F(t + ++F.count);
  }
  constructor(t) {
    this.id = t, this.href = `#${t}`;
  }
  toString() {
    return "url(" + this.href + ")";
  }
}, _(F, "Uid"), F.count = 0, F), ae = {
  left: Nt,
  right: Ot,
  center: It,
  justify: _t
}, le = /* @__PURE__ */ _(function(t, n, r, a) {
  const { securityLevel: c, sankey: k } = lt(), d = Et.sankey;
  let m;
  c === "sandbox" && (m = Q("#i" + n));
  const i = c === "sandbox" ? Q(m.nodes()[0].contentDocument.body) : Q("body"), o = c === "sandbox" ? i.select(`[id="${n}"]`) : Q(`[id="${n}"]`), f = (k == null ? void 0 : k.width) ?? d.width, p = (k == null ? void 0 : k.height) ?? d.width, y = (k == null ? void 0 : k.useMaxWidth) ?? d.useMaxWidth, w = (k == null ? void 0 : k.nodeAlignment) ?? d.nodeAlignment, v = (k == null ? void 0 : k.prefix) ?? d.prefix, P = (k == null ? void 0 : k.suffix) ?? d.suffix, A = (k == null ? void 0 : k.showValues) ?? d.showValues, T = a.db.getGraph(), O = ae[w];
  Ft().nodeId((g) => g.id).nodeWidth(10).nodePadding(10 + (A ? 15 : 0)).nodeAlign(O).extent([
    [0, 0],
    [f, p]
  ])(T);
  const D = Tt(Pt);
  o.append("g").attr("class", "nodes").selectAll(".node").data(T.nodes).join("g").attr("class", "node").attr("id", (g) => (g.uid = pt.next("node-")).id).attr("transform", function(g) {
    return "translate(" + g.x0 + "," + g.y0 + ")";
  }).attr("x", (g) => g.x0).attr("y", (g) => g.y0).append("rect").attr("height", (g) => g.y1 - g.y0).attr("width", (g) => g.x1 - g.x0).attr("fill", (g) => D(g.id));
  const S = /* @__PURE__ */ _(({ id: g, value: L }) => A ? `${g}
${v}${Math.round(L * 100) / 100}${P}` : g, "getText");
  o.append("g").attr("class", "node-labels").attr("font-family", "sans-serif").attr("font-size", 14).selectAll("text").data(T.nodes).join("text").attr("x", (g) => g.x0 < f / 2 ? g.x1 + 6 : g.x0 - 6).attr("y", (g) => (g.y1 + g.y0) / 2).attr("dy", `${A ? "0" : "0.35"}em`).attr("text-anchor", (g) => g.x0 < f / 2 ? "start" : "end").text(S);
  const C = o.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(T.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply"), I = (k == null ? void 0 : k.linkColor) ?? "gradient";
  if (I === "gradient") {
    const g = C.append("linearGradient").attr("id", (L) => (L.uid = pt.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (L) => L.source.x1).attr("x2", (L) => L.target.x0);
    g.append("stop").attr("offset", "0%").attr("stop-color", (L) => D(L.source.id)), g.append("stop").attr("offset", "100%").attr("stop-color", (L) => D(L.target.id));
  }
  let N;
  switch (I) {
    case "gradient":
      N = /* @__PURE__ */ _((g) => g.uid, "coloring");
      break;
    case "source":
      N = /* @__PURE__ */ _((g) => D(g.source.id), "coloring");
      break;
    case "target":
      N = /* @__PURE__ */ _((g) => D(g.target.id), "coloring");
      break;
    default:
      N = I;
  }
  C.append("path").attr("d", Bt()).attr("stroke", N).attr("stroke-width", (g) => Math.max(1, g.width)), Lt(void 0, o, 0, y);
}, "draw"), ce = {
  draw: le
}, ue = /* @__PURE__ */ _((t) => t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, `
`).trim(), "prepareTextForParsing"), he = K.parse.bind(K);
K.parse = (t) => he(ue(t));
var ge = {
  parser: K,
  db: oe,
  renderer: ce
};
export {
  ge as diagram
};
