ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
975 lines (969 loc) • 33.7 kB
JavaScript
import { n as d } from "./chunk-Y2CYZVJY-0JxdZxki.js";
import { p as G } from "./src-DtRLxcYO.js";
import { H as mt, J as kt, K as _t, U as xt, a as vt, d as bt, s as wt, v as St, w as Lt, x as tt, y as Et } from "./chunk-WYO6CB5R-DDHkKowO.js";
import { t as At } from "./ordinal-BMN81JG2.js";
function Tt(t) {
for (var i = t.length / 6 | 0, s = new Array(i), c = 0; c < i; ) s[c] = "#" + t.slice(c * 6, ++c * 6);
return s;
}
var Mt = Tt("4e79a7f28e2ce1575976b7b259a14fedc949af7aa1ff9da79c755fbab0ab");
function at(t, i) {
let s;
if (i === void 0)
for (const c of t) c != null && (s < c || s === void 0 && c >= c) && (s = c);
else {
let c = -1;
for (let u of t) (u = i(u, ++c, t)) != null && (s < u || s === void 0 && u >= u) && (s = u);
}
return s;
}
function dt(t, i) {
let s;
if (i === void 0)
for (const c of t) c != null && (s > c || s === void 0 && c >= c) && (s = c);
else {
let c = -1;
for (let u of t) (u = i(u, ++c, t)) != null && (s > u || s === void 0 && u >= u) && (s = u);
}
return s;
}
function Z(t, i) {
let s = 0;
if (i === void 0)
for (let c of t) (c = +c) && (s += c);
else {
let c = -1;
for (let u of t) (u = +i(u, ++c, t)) && (s += u);
}
return s;
}
function Nt(t) {
return t.target.depth;
}
function Ct(t) {
return t.depth;
}
function Pt(t, i) {
return i - 1 - t.height;
}
function gt(t, i) {
return t.sourceLinks.length ? t.depth : i - 1;
}
function It(t) {
return t.targetLinks.length ? t.depth : t.sourceLinks.length ? dt(t.sourceLinks, Nt) - 1 : 0;
}
function H(t) {
return function() {
return t;
};
}
function lt(t, i) {
return q(t.source, i.source) || t.index - i.index;
}
function ct(t, i) {
return q(t.target, i.target) || t.index - i.index;
}
function q(t, i) {
return t.y0 - i.y0;
}
function J(t) {
return t.value;
}
function Ot(t) {
return t.index;
}
function $t(t) {
return t.nodes;
}
function Dt(t) {
return t.links;
}
function ut(t, i) {
const s = t.get(i);
if (!s) throw new Error("missing: " + i);
return s;
}
function ht({ nodes: t }) {
for (const i of t) {
let s = i.y0, c = s;
for (const u of i.sourceLinks)
u.y0 = s + u.width / 2, s += u.width;
for (const u of i.targetLinks)
u.y1 = c + u.width / 2, c += u.width;
}
}
function zt() {
let t = 0, i = 0, s = 1, c = 1, u = 24, m = 8, r, l = Ot, y = gt, h, p, x = $t, k = Dt, L = 6;
function _() {
const e = {
nodes: x.apply(null, arguments),
links: k.apply(null, arguments)
};
return A(e), E(e), M(e), $(e), v(e), ht(e), e;
}
_.update = function(e) {
return ht(e), e;
}, _.nodeId = function(e) {
return arguments.length ? (l = typeof e == "function" ? e : H(e), _) : l;
}, _.nodeAlign = function(e) {
return arguments.length ? (y = typeof e == "function" ? e : H(e), _) : y;
}, _.nodeSort = function(e) {
return arguments.length ? (h = e, _) : h;
}, _.nodeWidth = function(e) {
return arguments.length ? (u = +e, _) : u;
}, _.nodePadding = function(e) {
return arguments.length ? (m = r = +e, _) : m;
}, _.nodes = function(e) {
return arguments.length ? (x = typeof e == "function" ? e : H(e), _) : x;
}, _.links = function(e) {
return arguments.length ? (k = typeof e == "function" ? e : H(e), _) : k;
}, _.linkSort = function(e) {
return arguments.length ? (p = e, _) : p;
}, _.size = function(e) {
return arguments.length ? (t = i = 0, s = +e[0], c = +e[1], _) : [s - t, c - i];
}, _.extent = function(e) {
return arguments.length ? (t = +e[0][0], s = +e[1][0], i = +e[0][1], c = +e[1][1], _) : [[t, i], [s, c]];
}, _.iterations = function(e) {
return arguments.length ? (L = +e, _) : L;
};
function A({ nodes: e, links: f }) {
for (const [o, a] of e.entries())
a.index = o, a.sourceLinks = [], a.targetLinks = [];
const n = new Map(e.map((o, a) => [l(o, a, e), o]));
for (const [o, a] of f.entries()) {
a.index = o;
let { source: g, target: b } = a;
typeof g != "object" && (g = a.source = ut(n, g)), typeof b != "object" && (b = a.target = ut(n, b)), g.sourceLinks.push(a), b.targetLinks.push(a);
}
if (p != null) for (const { sourceLinks: o, targetLinks: a } of e)
o.sort(p), a.sort(p);
}
function E({ nodes: e }) {
for (const f of e) f.value = f.fixedValue === void 0 ? Math.max(Z(f.sourceLinks, J), Z(f.targetLinks, J)) : f.fixedValue;
}
function M({ nodes: e }) {
const f = e.length;
let n = new Set(e), o = /* @__PURE__ */ new Set(), a = 0;
for (; n.size; ) {
for (const g of n) {
g.depth = a;
for (const { target: b } of g.sourceLinks) o.add(b);
}
if (++a > f) throw new Error("circular link");
n = o, o = /* @__PURE__ */ new Set();
}
}
function $({ nodes: e }) {
const f = e.length;
let n = new Set(e), o = /* @__PURE__ */ new Set(), a = 0;
for (; n.size; ) {
for (const g of n) {
g.height = a;
for (const { source: b } of g.targetLinks) o.add(b);
}
if (++a > f) throw new Error("circular link");
n = o, o = /* @__PURE__ */ new Set();
}
}
function N({ nodes: e }) {
const f = at(e, (a) => a.depth) + 1, n = (s - t - u) / (f - 1), o = new Array(f);
for (const a of e) {
const g = Math.max(0, Math.min(f - 1, Math.floor(y.call(null, a, f))));
a.layer = g, a.x0 = t + g * n, a.x1 = a.x0 + u, o[g] ? o[g].push(a) : o[g] = [a];
}
if (h) for (const a of o) a.sort(h);
return o;
}
function D(e) {
const f = dt(e, (n) => (c - i - (n.length - 1) * r) / Z(n, J));
for (const n of e) {
let o = i;
for (const a of n) {
a.y0 = o, a.y1 = o + a.value * f, o = a.y1 + r;
for (const g of a.sourceLinks) g.width = g.value * f;
}
o = (c - o + r) / (n.length + 1);
for (let a = 0; a < n.length; ++a) {
const g = n[a];
g.y0 += o * (a + 1), g.y1 += o * (a + 1);
}
w(n);
}
}
function v(e) {
const f = N(e);
r = Math.min(m, (c - i) / (at(f, (n) => n.length) - 1)), D(f);
for (let n = 0; n < L; ++n) {
const o = Math.pow(0.99, n), a = Math.max(1 - o, (n + 1) / L);
B(f, o, a), C(f, o, a);
}
}
function C(e, f, n) {
for (let o = 1, a = e.length; o < a; ++o) {
const g = e[o];
for (const b of g) {
let I = 0, S = 0;
for (const { source: U, value: W } of b.targetLinks) {
let ot = W * (b.layer - U.layer);
I += O(U, b) * ot, S += ot;
}
if (!(S > 0)) continue;
let V = (I / S - b.y0) * f;
b.y0 += V, b.y1 += V, j(b);
}
h === void 0 && g.sort(q), z(g, n);
}
}
function B(e, f, n) {
for (let o = e.length - 2; o >= 0; --o) {
const a = e[o];
for (const g of a) {
let b = 0, I = 0;
for (const { target: V, value: U } of g.sourceLinks) {
let W = U * (V.layer - g.layer);
b += T(g, V) * W, I += W;
}
if (!(I > 0)) continue;
let S = (b / I - g.y0) * f;
g.y0 += S, g.y1 += S, j(g);
}
h === void 0 && a.sort(q), z(a, n);
}
}
function z(e, f) {
const n = e.length >> 1, o = e[n];
R(e, o.y0 - r, n - 1, f), P(e, o.y1 + r, n + 1, f), R(e, c, e.length - 1, f), P(e, i, 0, f);
}
function P(e, f, n, o) {
for (; n < e.length; ++n) {
const a = e[n], g = (f - a.y0) * o;
g > 1e-6 && (a.y0 += g, a.y1 += g), f = a.y1 + r;
}
}
function R(e, f, n, o) {
for (; n >= 0; --n) {
const a = e[n], g = (a.y1 - f) * o;
g > 1e-6 && (a.y0 -= g, a.y1 -= g), f = a.y0 - r;
}
}
function j({ sourceLinks: e, targetLinks: f }) {
if (p === void 0) {
for (const { source: { sourceLinks: n } } of f) n.sort(ct);
for (const { target: { targetLinks: n } } of e) n.sort(lt);
}
}
function w(e) {
if (p === void 0) for (const { sourceLinks: f, targetLinks: n } of e)
f.sort(ct), n.sort(lt);
}
function O(e, f) {
let n = e.y0 - (e.sourceLinks.length - 1) * r / 2;
for (const { target: o, width: a } of e.sourceLinks) {
if (o === f) break;
n += a + r;
}
for (const { source: o, width: a } of f.targetLinks) {
if (o === e) break;
n -= a;
}
return n;
}
function T(e, f) {
let n = f.y0 - (f.targetLinks.length - 1) * r / 2;
for (const { source: o, width: a } of f.targetLinks) {
if (o === e) break;
n += a + r;
}
for (const { target: o, width: a } of e.sourceLinks) {
if (o === f) break;
n -= a;
}
return n;
}
return _;
}
var et = Math.PI, nt = 2 * et, F = 1e-6, jt = nt - F;
function it() {
this._x0 = this._y0 = this._x1 = this._y1 = null, this._ = "";
}
function pt() {
return new it();
}
it.prototype = pt.prototype = {
constructor: it,
moveTo: function(t, i) {
this._ += "M" + (this._x0 = this._x1 = +t) + "," + (this._y0 = this._y1 = +i);
},
closePath: function() {
this._x1 !== null && (this._x1 = this._x0, this._y1 = this._y0, this._ += "Z");
},
lineTo: function(t, i) {
this._ += "L" + (this._x1 = +t) + "," + (this._y1 = +i);
},
quadraticCurveTo: function(t, i, s, c) {
this._ += "Q" + +t + "," + +i + "," + (this._x1 = +s) + "," + (this._y1 = +c);
},
bezierCurveTo: function(t, i, s, c, u, m) {
this._ += "C" + +t + "," + +i + "," + +s + "," + +c + "," + (this._x1 = +u) + "," + (this._y1 = +m);
},
arcTo: function(t, i, s, c, u) {
t = +t, i = +i, s = +s, c = +c, u = +u;
var m = this._x1, r = this._y1, l = s - t, y = c - i, h = m - t, p = r - i, x = h * h + p * p;
if (u < 0) throw new Error("negative radius: " + u);
if (this._x1 === null) this._ += "M" + (this._x1 = t) + "," + (this._y1 = i);
else if (x > F) if (!(Math.abs(p * l - y * h) > F) || !u) this._ += "L" + (this._x1 = t) + "," + (this._y1 = i);
else {
var k = s - m, L = c - r, _ = l * l + y * y, A = k * k + L * L, E = Math.sqrt(_), M = Math.sqrt(x), $ = u * Math.tan((et - Math.acos((_ + x - A) / (2 * E * M))) / 2), N = $ / M, D = $ / E;
Math.abs(N - 1) > F && (this._ += "L" + (t + N * h) + "," + (i + N * p)), this._ += "A" + u + "," + u + ",0,0," + +(p * k > h * L) + "," + (this._x1 = t + D * l) + "," + (this._y1 = i + D * y);
}
},
arc: function(t, i, s, c, u, m) {
t = +t, i = +i, s = +s, m = !!m;
var r = s * Math.cos(c), l = s * Math.sin(c), y = t + r, h = i + l, p = 1 ^ m, x = m ? c - u : u - c;
if (s < 0) throw new Error("negative radius: " + s);
this._x1 === null ? this._ += "M" + y + "," + h : (Math.abs(this._x1 - y) > F || Math.abs(this._y1 - h) > F) && (this._ += "L" + y + "," + h), s && (x < 0 && (x = x % nt + nt), x > jt ? this._ += "A" + s + "," + s + ",0,1," + p + "," + (t - r) + "," + (i - l) + "A" + s + "," + s + ",0,1," + p + "," + (this._x1 = y) + "," + (this._y1 = h) : x > F && (this._ += "A" + s + "," + s + ",0," + +(x >= et) + "," + p + "," + (this._x1 = t + s * Math.cos(u)) + "," + (this._y1 = i + s * Math.sin(u))));
},
rect: function(t, i, s, c) {
this._ += "M" + (this._x0 = this._x1 = +t) + "," + (this._y0 = this._y1 = +i) + "h" + +s + "v" + +c + "h" + -s + "Z";
},
toString: function() {
return this._;
}
};
function ft(t) {
return function() {
return t;
};
}
function Bt(t) {
return t[0];
}
function Ft(t) {
return t[1];
}
var Rt = Array.prototype.slice;
function Vt(t) {
return t.source;
}
function Ut(t) {
return t.target;
}
function Wt(t) {
var i = Vt, s = Ut, c = Bt, u = Ft, m = null;
function r() {
var l, y = Rt.call(arguments), h = i.apply(this, y), p = s.apply(this, y);
if (m || (m = l = pt()), t(m, +c.apply(this, (y[0] = h, y)), +u.apply(this, y), +c.apply(this, (y[0] = p, y)), +u.apply(this, y)), l) return m = null, l + "" || null;
}
return r.source = function(l) {
return arguments.length ? (i = l, r) : i;
}, r.target = function(l) {
return arguments.length ? (s = l, r) : s;
}, r.x = function(l) {
return arguments.length ? (c = typeof l == "function" ? l : ft(+l), r) : c;
}, r.y = function(l) {
return arguments.length ? (u = typeof l == "function" ? l : ft(+l), r) : u;
}, r.context = function(l) {
return arguments.length ? (m = l ?? null, r) : m;
}, r;
}
function Gt(t, i, s, c, u) {
t.moveTo(i, s), t.bezierCurveTo(i = (i + c) / 2, s, i, u, c, u);
}
function Ht() {
return Wt(Gt);
}
function Yt(t) {
return [t.source.x1, t.y0];
}
function Xt(t) {
return [t.target.x0, t.y1];
}
function qt() {
return Ht().source(Yt).target(Xt);
}
var rt = (function() {
var t = /* @__PURE__ */ d(function(r, l, y, h) {
for (y = y || {}, h = r.length; h--; y[r[h]] = l) ;
return y;
}, "o"), i = [1, 9], s = [1, 10], c = [
1,
5,
10,
12
], u = {
trace: /* @__PURE__ */ d(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__ */ d(function(l, y, h, p, x, k, L) {
var _ = k.length - 1;
switch (x) {
case 7:
const A = p.findOrCreateNode(k[_ - 4].trim().replaceAll('""', '"')), E = p.findOrCreateNode(k[_ - 2].trim().replaceAll('""', '"')), M = parseFloat(k[_].trim());
p.addLink(A, E, M);
break;
case 8:
case 9:
case 11:
this.$ = k[_];
break;
case 10:
this.$ = k[_ - 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: i,
20: s
},
{
1: [2, 6],
7: 11,
10: [1, 12]
},
t(s, [2, 4], {
9: 13,
5: [1, 14]
}),
{ 12: [1, 15] },
t(c, [2, 8]),
t(c, [2, 9]),
{ 19: [1, 16] },
t(c, [2, 11]),
{ 1: [2, 1] },
{ 1: [2, 5] },
t(s, [2, 2]),
{
6: 17,
8: 5,
15: 6,
16: 7,
17: 8,
18: i,
20: s
},
{
15: 18,
16: 7,
17: 8,
18: i,
20: s
},
{ 18: [1, 19] },
t(s, [2, 3]),
{ 12: [1, 20] },
t(c, [2, 10]),
{
15: 21,
16: 7,
17: 8,
18: i,
20: s
},
t([
1,
5,
10
], [2, 7])
],
defaultActions: {
11: [2, 1],
12: [2, 5]
},
parseError: /* @__PURE__ */ d(function(l, y) {
if (y.recoverable) this.trace(l);
else {
var h = new Error(l);
throw h.hash = y, h;
}
}, "parseError"),
parse: /* @__PURE__ */ d(function(l) {
var y = this, h = [0], p = [], x = [null], k = [], L = this.table, _ = "", A = 0, E = 0, M = 0, $ = 2, N = 1, D = k.slice.call(arguments, 1), v = Object.create(this.lexer), C = { yy: {} };
for (var B in this.yy) Object.prototype.hasOwnProperty.call(this.yy, B) && (C.yy[B] = this.yy[B]);
v.setInput(l, C.yy), C.yy.lexer = v, C.yy.parser = this, typeof v.yylloc > "u" && (v.yylloc = {});
var z = v.yylloc;
k.push(z);
var P = v.options && v.options.ranges;
typeof C.yy.parseError == "function" ? this.parseError = C.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
function R(S) {
h.length = h.length - 2 * S, x.length = x.length - S, k.length = k.length - S;
}
d(R, "popStack");
function j() {
var S = p.pop() || v.lex() || N;
return typeof S != "number" && (S instanceof Array && (p = S, S = p.pop()), S = y.symbols_[S] || S), S;
}
d(j, "lex");
for (var w, O, T, e, f, n = {}, o, a, g, b; ; ) {
if (T = h[h.length - 1], this.defaultActions[T] ? e = this.defaultActions[T] : ((w === null || typeof w > "u") && (w = j()), e = L[T] && L[T][w]), typeof e > "u" || !e.length || !e[0]) {
var I = "";
b = [];
for (o in L[T]) this.terminals_[o] && o > $ && b.push("'" + this.terminals_[o] + "'");
v.showPosition ? I = "Parse error on line " + (A + 1) + `:
` + v.showPosition() + `
Expecting ` + b.join(", ") + ", got '" + (this.terminals_[w] || w) + "'" : I = "Parse error on line " + (A + 1) + ": Unexpected " + (w == N ? "end of input" : "'" + (this.terminals_[w] || w) + "'"), this.parseError(I, {
text: v.match,
token: this.terminals_[w] || w,
line: v.yylineno,
loc: z,
expected: b
});
}
if (e[0] instanceof Array && e.length > 1) throw new Error("Parse Error: multiple actions possible at state: " + T + ", token: " + w);
switch (e[0]) {
case 1:
h.push(w), x.push(v.yytext), k.push(v.yylloc), h.push(e[1]), w = null, O ? (w = O, O = null) : (E = v.yyleng, _ = v.yytext, A = v.yylineno, z = v.yylloc, M > 0 && M--);
break;
case 2:
if (a = this.productions_[e[1]][1], n.$ = x[x.length - a], n._$ = {
first_line: k[k.length - (a || 1)].first_line,
last_line: k[k.length - 1].last_line,
first_column: k[k.length - (a || 1)].first_column,
last_column: k[k.length - 1].last_column
}, P && (n._$.range = [k[k.length - (a || 1)].range[0], k[k.length - 1].range[1]]), f = this.performAction.apply(n, [
_,
E,
A,
C.yy,
e[1],
x,
k
].concat(D)), typeof f < "u") return f;
a && (h = h.slice(0, -1 * a * 2), x = x.slice(0, -1 * a), k = k.slice(0, -1 * a)), h.push(this.productions_[e[1]][0]), x.push(n.$), k.push(n._$), g = L[h[h.length - 2]][h[h.length - 1]], h.push(g);
break;
case 3:
return !0;
}
}
return !0;
}, "parse")
};
u.lexer = /* @__PURE__ */ (function() {
return {
EOF: 1,
parseError: /* @__PURE__ */ d(function(l, y) {
if (this.yy.parser) this.yy.parser.parseError(l, y);
else throw new Error(l);
}, "parseError"),
setInput: /* @__PURE__ */ d(function(r, l) {
return this.yy = l || this.yy || {}, this._input = r, 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__ */ d(function() {
var r = this._input[0];
return this.yytext += r, this.yyleng++, this.offset++, this.match += r, this.matched += r, r.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), r;
}, "input"),
unput: /* @__PURE__ */ d(function(r) {
var l = r.length, y = r.split(/(?:\r\n?|\n)/g);
this._input = r + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - l), this.offset -= l;
var h = 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), y.length - 1 && (this.yylineno -= y.length - 1);
var p = 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: y ? (y.length === h.length ? this.yylloc.first_column : 0) + h[h.length - y.length].length - y[0].length : this.yylloc.first_column - l
}, this.options.ranges && (this.yylloc.range = [p[0], p[0] + this.yyleng - l]), this.yyleng = this.yytext.length, this;
}, "unput"),
more: /* @__PURE__ */ d(function() {
return this._more = !0, this;
}, "more"),
reject: /* @__PURE__ */ d(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__ */ d(function(r) {
this.unput(this.match.slice(r));
}, "less"),
pastInput: /* @__PURE__ */ d(function() {
var r = this.matched.substr(0, this.matched.length - this.match.length);
return (r.length > 20 ? "..." : "") + r.substr(-20).replace(/\n/g, "");
}, "pastInput"),
upcomingInput: /* @__PURE__ */ d(function() {
var r = this.match;
return r.length < 20 && (r += this._input.substr(0, 20 - r.length)), (r.substr(0, 20) + (r.length > 20 ? "..." : "")).replace(/\n/g, "");
}, "upcomingInput"),
showPosition: /* @__PURE__ */ d(function() {
var r = this.pastInput(), l = new Array(r.length + 1).join("-");
return r + this.upcomingInput() + `
` + l + "^";
}, "showPosition"),
test_match: /* @__PURE__ */ d(function(r, l) {
var y, h, p;
if (this.options.backtrack_lexer && (p = {
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 && (p.yylloc.range = this.yylloc.range.slice(0))), h = r[0].match(/(?:\r\n?|\n).*/g), h && (this.yylineno += h.length), this.yylloc = {
first_line: this.yylloc.last_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.last_column,
last_column: h ? h[h.length - 1].length - h[h.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + r[0].length
}, this.yytext += r[0], this.match += r[0], this.matches = r, 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(r[0].length), this.matched += r[0], y = this.performAction.call(this, this.yy, this, l, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), y) return y;
if (this._backtrack) {
for (var x in p) this[x] = p[x];
return !1;
}
return !1;
}, "test_match"),
next: /* @__PURE__ */ d(function() {
if (this.done) return this.EOF;
this._input || (this.done = !0);
var r, l, y, h;
this._more || (this.yytext = "", this.match = "");
for (var p = this._currentRules(), x = 0; x < p.length; x++)
if (y = this._input.match(this.rules[p[x]]), y && (!l || y[0].length > l[0].length)) {
if (l = y, h = x, this.options.backtrack_lexer) {
if (r = this.test_match(y, p[x]), r !== !1) return r;
if (this._backtrack) {
l = !1;
continue;
} else return !1;
} else if (!this.options.flex) break;
}
return l ? (r = this.test_match(l, p[h]), r !== !1 ? r : !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"),
lex: /* @__PURE__ */ d(function() {
var l = this.next();
return l || this.lex();
}, "lex"),
begin: /* @__PURE__ */ d(function(l) {
this.conditionStack.push(l);
}, "begin"),
popState: /* @__PURE__ */ d(function() {
return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
}, "popState"),
_currentRules: /* @__PURE__ */ d(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__ */ d(function(l) {
return l = this.conditionStack.length - 1 - Math.abs(l || 0), l >= 0 ? this.conditionStack[l] : "INITIAL";
}, "topState"),
pushState: /* @__PURE__ */ d(function(l) {
this.begin(l);
}, "pushState"),
stateStackSize: /* @__PURE__ */ d(function() {
return this.conditionStack.length;
}, "stateStackSize"),
options: { "case-insensitive": !0 },
performAction: /* @__PURE__ */ d(function(l, y, h, p) {
switch (h) {
case 0:
return this.pushState("csv"), 4;
case 1:
return this.pushState("csv"), 4;
case 2:
return 10;
case 3:
return 5;
case 4:
return 12;
case 5:
return this.pushState("escaped_text"), 18;
case 6:
return 20;
case 7:
return this.popState("escaped_text"), 18;
case 8:
return 19;
}
}, "anonymous"),
rules: [
/^(?:sankey-beta\b)/i,
/^(?:sankey\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: [
2,
3,
4,
5,
6,
7,
8
],
inclusive: !1
},
escaped_text: {
rules: [7, 8],
inclusive: !1
},
INITIAL: {
rules: [
0,
1,
2,
3,
4,
5,
6,
7,
8
],
inclusive: !0
}
}
};
})();
function m() {
this.yy = {};
}
return d(m, "Parser"), m.prototype = u, u.Parser = m, new m();
})();
rt.parser = rt;
var K = rt, Q = [], Y = [], X = /* @__PURE__ */ new Map(), Kt = /* @__PURE__ */ d(() => {
Q = [], Y = [], X = /* @__PURE__ */ new Map(), vt();
}, "clear"), Qt = class {
constructor(t, i, s = 0) {
this.source = t, this.target = i, this.value = s;
}
static {
d(this, "SankeyLink");
}
}, Zt = /* @__PURE__ */ d((t, i, s) => {
Q.push(new Qt(t, i, s));
}, "addLink"), Jt = class {
constructor(t) {
this.ID = t;
}
static {
d(this, "SankeyNode");
}
}, te = {
nodesMap: X,
getConfig: /* @__PURE__ */ d(() => tt().sankey, "getConfig"),
getNodes: /* @__PURE__ */ d(() => Y, "getNodes"),
getLinks: /* @__PURE__ */ d(() => Q, "getLinks"),
getGraph: /* @__PURE__ */ d(() => ({
nodes: Y.map((t) => ({ id: t.ID })),
links: Q.map((t) => ({
source: t.source.ID,
target: t.target.ID,
value: t.value
}))
}), "getGraph"),
addLink: Zt,
findOrCreateNode: /* @__PURE__ */ d((t) => {
t = wt.sanitizeText(t, tt());
let i = X.get(t);
return i === void 0 && (i = new Jt(t), X.set(t, i), Y.push(i)), i;
}, "findOrCreateNode"),
getAccTitle: Et,
setAccTitle: xt,
getAccDescription: St,
setAccDescription: mt,
getDiagramTitle: Lt,
setDiagramTitle: _t,
clear: Kt
}, yt = class st {
static {
d(this, "Uid");
}
static {
this.count = 0;
}
static next(i) {
return new st(i + ++st.count);
}
constructor(i) {
this.id = i, this.href = `#${i}`;
}
toString() {
return "url(" + this.href + ")";
}
}, ee = {
left: Ct,
right: Pt,
center: It,
justify: gt
}, ne = /* @__PURE__ */ d((t) => {
let i = 0, s = 0;
for (const c of t) {
const u = c.value ?? 0;
u > i && (i = u, s = c.layer ?? 0);
}
return s;
}, "findCentralNodeLayer"), ie = { draw: /* @__PURE__ */ d(function(t, i, s, c) {
const { securityLevel: u, sankey: m } = tt(), r = bt.sankey;
let l;
u === "sandbox" && (l = G("#i" + i));
const y = u === "sandbox" ? G(l.nodes()[0].contentDocument.body) : G("body"), h = u === "sandbox" ? y.select(`[id="${i}"]`) : G(`[id="${i}"]`), p = m?.width ?? r.width, x = m?.height ?? r.width, k = m?.useMaxWidth ?? r.useMaxWidth, L = m?.nodeAlignment ?? r.nodeAlignment, _ = m?.prefix ?? r.prefix, A = m?.suffix ?? r.suffix, E = m?.showValues ?? r.showValues, M = m?.nodeWidth ?? r.nodeWidth ?? 10, $ = m?.nodePadding ?? r.nodePadding ?? 12, N = m?.labelStyle ?? r.labelStyle ?? "legacy", D = m?.nodeColors ?? {}, v = c.db.getGraph(), C = ee[L];
zt().nodeId((n) => n.id).nodeWidth(M).nodePadding($ + (E ? 15 : 0)).nodeAlign(C).extent([[0, 0], [p, x]])(v);
const B = ne(v.nodes), z = At(Mt), P = /* @__PURE__ */ d((n) => D[n] ?? z(n), "getNodeColor");
h.append("g").attr("class", "nodes").selectAll(".node").data(v.nodes).join("g").attr("class", "node").attr("id", (n) => (n.uid = yt.next("node-")).id).attr("transform", function(n) {
return "translate(" + n.x0 + "," + n.y0 + ")";
}).attr("x", (n) => n.x0).attr("y", (n) => n.y0).append("rect").attr("height", (n) => n.y1 - n.y0).attr("width", (n) => n.x1 - n.x0).attr("fill", (n) => P(n.id));
const R = /* @__PURE__ */ d(({ id: n, value: o }) => E ? `${n}
${_}${Math.round(o * 100) / 100}${A}` : n, "getText"), j = /* @__PURE__ */ d((n) => N === "outlined" ? (n.layer ?? 0) < B ? {
x: n.x0 - 6,
anchor: "end"
} : {
x: n.x1 + 6,
anchor: "start"
} : n.x0 < p / 2 ? {
x: n.x1 + 6,
anchor: "start"
} : {
x: n.x0 - 6,
anchor: "end"
}, "getLabelPosition"), w = h.append("g").attr("class", "node-labels").attr("font-size", 14), O = /* @__PURE__ */ d((n) => w.selectAll(n ? `.${n}` : "text").data(v.nodes).join("text").attr("class", n ?? null).attr("x", (o) => j(o).x).attr("y", (o) => (o.y1 + o.y0) / 2).attr("dy", `${E ? "0" : "0.35"}em`).attr("text-anchor", (o) => j(o).anchor).text(R), "appendLabel");
N === "outlined" ? (O("sankey-label-bg"), O("sankey-label-fg")) : O();
const T = h.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(v.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply"), e = m?.linkColor ?? "gradient";
if (e === "gradient") {
const n = T.append("linearGradient").attr("id", (o) => (o.uid = yt.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (o) => o.source.x1).attr("x2", (o) => o.target.x0);
n.append("stop").attr("offset", "0%").attr("stop-color", (o) => P(o.source.id)), n.append("stop").attr("offset", "100%").attr("stop-color", (o) => P(o.target.id));
}
let f;
switch (e) {
case "gradient":
f = /* @__PURE__ */ d((n) => n.uid, "coloring");
break;
case "source":
f = /* @__PURE__ */ d((n) => P(n.source.id), "coloring");
break;
case "target":
f = /* @__PURE__ */ d((n) => P(n.target.id), "coloring");
break;
default:
f = e;
}
T.append("path").attr("d", qt()).attr("stroke", f).attr("stroke-width", (n) => Math.max(1, n.width)), kt(void 0, h, 0, k);
}, "draw") }, re = /* @__PURE__ */ d((t) => t.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, `
`).trim(), "prepareTextForParsing"), se = /* @__PURE__ */ d((t) => `.label {
font-family: ${t.fontFamily};
}
.node-labels {
font-family: ${t.fontFamily};
}
/* Outlined label style - background stroke for better readability */
.sankey-label-bg {
stroke: ${t.mainBkg || t.background || "#fff"};
stroke-width: 4px;
stroke-linejoin: round;
paint-order: stroke;
}
/* Foreground label text */
.sankey-label-fg {
fill: ${t.textColor};
}
/* Node styling */
.node rect {
shape-rendering: crispEdges;
}
/* Link styling */
.link {
fill: none;
stroke-opacity: 0.5;
mix-blend-mode: multiply;
}
`, "getStyles"), oe = K.parse.bind(K);
K.parse = (t) => oe(re(t));
var he = {
styles: se,
parser: K,
db: te,
renderer: ie
};
export {
he as diagram
};