discord-user-card
Version:
Display Discord users' profile cards just like in Discord.
1,449 lines • 2.49 MB
JavaScript
var al = Object.defineProperty;
var il = (t, e, s) => e in t ? al(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
var B = (t, e, s) => il(t, typeof e != "symbol" ? e + "" : e, s);
import { discrimToAvatar as cl, imageToUrl as we, mapDiscordImageHash as je, ColorUtils as lt, getColorFromImage as _l, PresenceUpdateStatus as dt, formatTimestamp as vt, orderBadges as dl, badgeToUrl as ll, ActivityType as Ne, userIdToTimestamp as gl, defaultUserCardProperties as Qr } from "@discord-user-card/core";
import { ActivityType as nS, DiscordUserCardBadges as oS, DiscordUserCardBotBadges as rS, PresenceUpdateStatus as aS, defaultUserCardProperties as iS, flagsToBadges as cS } from "@discord-user-card/core";
function ml(t) {
return Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(" ");
}
function pl(t) {
return Object.entries(t).filter(([, e]) => e !== void 0).map(([e, s]) => `${e}: ${s};`).join(" ");
}
function D(t, e) {
const s = t.getAttribute("class") || "", n = ml(e);
s !== n && t.setAttribute("class", n);
}
function ke(t, e) {
const s = t.getAttribute("style") || "", n = pl(e);
s !== n && t.setAttribute("style", n);
}
function O(t, e) {
for (const s of Array.from(t.attributes))
e.includes(s.name) || t.removeAttribute(s.name);
}
function v(t, e) {
!t || !e || t.contains(e) || t.appendChild(e);
}
function z(t, e) {
!t || !e || t.contains(e) && t.removeChild(e);
}
async function Be(t, e) {
for (const s of Object.values(t))
s && "render" in s && await s.render(e);
}
function Ge(t, e) {
for (const s of Object.values(t))
s && "renderSkeleton" in s && s.renderSkeleton(e);
}
function xe(t) {
if (t)
for (const e of Object.values(t))
e && "destroy" in e && e.destroy();
}
function X_(t) {
return t.avatar ? gt(t.avatar) ? t.avatar : we({
image: je(t.avatar),
scope: "avatars",
relatedId: t.id,
animation: document.hasFocus() && !window.matchMedia("(prefers-reduced-motion: reduce)").matches
}) : cl(t.id, t.discriminator);
}
function Xr(t) {
if (t.banner)
return gt(t.banner) ? t.banner : we({
image: je(t.banner),
scope: "banners",
relatedId: t.id,
animation: document.hasFocus() && !window.matchMedia("(prefers-reduced-motion: reduce)").matches
});
}
async function ul(t) {
if (!t.bannerColor)
return hl(t);
const [e, s, n] = lt.intToRgb(t.bannerColor);
return `rgb(${e}, ${s}, ${n})`;
}
async function hl(t) {
const [e] = await _l(X_(t));
return `rgb(${e[0]}, ${e[1]}, ${e[2]})`;
}
function El(t) {
const { status: e } = t;
return e === dt.Online ? { status: e, color: "#23a55a" } : e === dt.Idle ? { status: e, color: "#f0b232" } : e === dt.DoNotDisturb ? { status: e, color: "#f23f43" } : { status: dt.Offline, color: "#80848e" };
}
function fl(t) {
const e = je(t.avatarDecoration);
if (e)
return we({
image: e,
scope: "avatar-decoration-presets",
relatedId: t.id,
animation: document.hasFocus() && !window.matchMedia("(prefers-reduced-motion: reduce)").matches
});
}
function gt(t) {
try {
return new URL(t), !0;
} catch {
return !1;
}
}
const ze = "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==", ot = (t, e = 0, s = 1) => Lr(Pr(e, t), s), Mr = (t) => {
t._clipped = !1, t._unclipped = t.slice(0);
for (let e = 0; e <= 3; e++)
e < 3 ? ((t[e] < 0 || t[e] > 255) && (t._clipped = !0), t[e] = ot(t[e], 0, 255)) : e === 3 && (t[e] = ot(t[e], 0, 1));
return t;
}, Z_ = {};
for (let t of [
"Boolean",
"Number",
"String",
"Function",
"Array",
"Date",
"RegExp",
"Undefined",
"Null"
])
Z_[`[object ${t}]`] = t.toLowerCase();
function ie(t) {
return Z_[Object.prototype.toString.call(t)] || "object";
}
const ce = (t, e = null) => t.length >= 3 ? Array.prototype.slice.call(t) : ie(t[0]) == "object" && e ? e.split("").filter((s) => t[0][s] !== void 0).map((s) => t[0][s]) : t[0], Ot = (t) => {
if (t.length < 2) return null;
const e = t.length - 1;
return ie(t[e]) == "string" ? t[e].toLowerCase() : null;
}, { PI: It, min: Lr, max: Pr } = Math, Ve = It * 2, Lt = It / 3, bl = It / 180, Sl = 180 / It, oe = {
format: {},
autodetect: []
};
class j {
constructor(...e) {
const s = this;
if (ie(e[0]) === "object" && e[0].constructor && e[0].constructor === this.constructor)
return e[0];
let n = Ot(e), o = !1;
if (!n) {
o = !0, oe.sorted || (oe.autodetect = oe.autodetect.sort((r, a) => a.p - r.p), oe.sorted = !0);
for (let r of oe.autodetect)
if (n = r.test(...e), n) break;
}
if (oe.format[n]) {
const r = oe.format[n].apply(
null,
o ? e : e.slice(0, -1)
);
s._rgb = Mr(r);
} else
throw new Error("unknown format: " + e);
s._rgb.length === 3 && s._rgb.push(1);
}
toString() {
return ie(this.hex) == "function" ? this.hex() : `[${this._rgb.join(",")}]`;
}
}
const yl = "2.6.0", X = (...t) => new X.Color(...t);
X.Color = j;
X.version = yl;
const vl = (...t) => {
t = ce(t, "cmyk");
const [e, s, n, o] = t, r = t.length > 4 ? t[4] : 1;
return o === 1 ? [0, 0, 0, r] : [
e >= 1 ? 0 : 255 * (1 - e) * (1 - o),
// r
s >= 1 ? 0 : 255 * (1 - s) * (1 - o),
// g
n >= 1 ? 0 : 255 * (1 - n) * (1 - o),
// b
r
];
}, { max: Zr } = Math, Tl = (...t) => {
let [e, s, n] = ce(t, "rgb");
e = e / 255, s = s / 255, n = n / 255;
const o = 1 - Zr(e, Zr(s, n)), r = o < 1 ? 1 / (1 - o) : 0, a = (1 - e - o) * r, i = (1 - s - o) * r, c = (1 - n - o) * r;
return [a, i, c, o];
};
j.prototype.cmyk = function() {
return Tl(this._rgb);
};
X.cmyk = (...t) => new j(...t, "cmyk");
oe.format.cmyk = vl;
oe.autodetect.push({
p: 2,
test: (...t) => {
if (t = ce(t, "cmyk"), ie(t) === "array" && t.length === 4)
return "cmyk";
}
});
const Pt = (t) => Math.round(t * 100) / 100, Cl = (...t) => {
const e = ce(t, "hsla");
let s = Ot(t) || "lsa";
return e[0] = Pt(e[0] || 0), e[1] = Pt(e[1] * 100) + "%", e[2] = Pt(e[2] * 100) + "%", s === "hsla" || e.length > 3 && e[3] < 1 ? (e[3] = e.length > 3 ? e[3] : 1, s = "hsla") : e.length = 3, `${s}(${e.join(",")})`;
}, J_ = (...t) => {
t = ce(t, "rgba");
let [e, s, n] = t;
e /= 255, s /= 255, n /= 255;
const o = Lr(e, s, n), r = Pr(e, s, n), a = (r + o) / 2;
let i, c;
return r === o ? (i = 0, c = Number.NaN) : i = a < 0.5 ? (r - o) / (r + o) : (r - o) / (2 - r - o), e == r ? c = (s - n) / (r - o) : s == r ? c = 2 + (n - e) / (r - o) : n == r && (c = 4 + (e - s) / (r - o)), c *= 60, c < 0 && (c += 360), t.length > 3 && t[3] !== void 0 ? [c, i, a, t[3]] : [c, i, a];
}, { round: Ft } = Math, wl = (...t) => {
const e = ce(t, "rgba");
let s = Ot(t) || "rgb";
return s.substr(0, 3) == "hsl" ? Cl(J_(e), s) : (e[0] = Ft(e[0]), e[1] = Ft(e[1]), e[2] = Ft(e[2]), (s === "rgba" || e.length > 3 && e[3] < 1) && (e[3] = e.length > 3 ? e[3] : 1, s = "rgba"), `${s}(${e.slice(0, s === "rgb" ? 3 : 4).join(",")})`);
}, { round: jt } = Math, Ar = (...t) => {
t = ce(t, "hsl");
const [e, s, n] = t;
let o, r, a;
if (s === 0)
o = r = a = n * 255;
else {
const i = [0, 0, 0], c = [0, 0, 0], _ = n < 0.5 ? n * (1 + s) : n + s - n * s, d = 2 * n - _, l = e / 360;
i[0] = l + 1 / 3, i[1] = l, i[2] = l - 1 / 3;
for (let g = 0; g < 3; g++)
i[g] < 0 && (i[g] += 1), i[g] > 1 && (i[g] -= 1), 6 * i[g] < 1 ? c[g] = d + (_ - d) * 6 * i[g] : 2 * i[g] < 1 ? c[g] = _ : 3 * i[g] < 2 ? c[g] = d + (_ - d) * (2 / 3 - i[g]) * 6 : c[g] = d;
[o, r, a] = [jt(c[0] * 255), jt(c[1] * 255), jt(c[2] * 255)];
}
return t.length > 3 ? [o, r, a, t[3]] : [o, r, a, 1];
}, ed = /^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/, td = /^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/, sd = /^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/, nd = /^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/, od = /^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/, rd = /^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/, { round: Jr } = Math, Fr = (t) => {
t = t.toLowerCase().trim();
let e;
if (oe.format.named)
try {
return oe.format.named(t);
} catch {
}
if (e = t.match(ed)) {
const s = e.slice(1, 4);
for (let n = 0; n < 3; n++)
s[n] = +s[n];
return s[3] = 1, s;
}
if (e = t.match(td)) {
const s = e.slice(1, 5);
for (let n = 0; n < 4; n++)
s[n] = +s[n];
return s;
}
if (e = t.match(sd)) {
const s = e.slice(1, 4);
for (let n = 0; n < 3; n++)
s[n] = Jr(s[n] * 2.55);
return s[3] = 1, s;
}
if (e = t.match(nd)) {
const s = e.slice(1, 5);
for (let n = 0; n < 3; n++)
s[n] = Jr(s[n] * 2.55);
return s[3] = +s[3], s;
}
if (e = t.match(od)) {
const s = e.slice(1, 4);
s[1] *= 0.01, s[2] *= 0.01;
const n = Ar(s);
return n[3] = 1, n;
}
if (e = t.match(rd)) {
const s = e.slice(1, 4);
s[1] *= 0.01, s[2] *= 0.01;
const n = Ar(s);
return n[3] = +e[4], n;
}
};
Fr.test = (t) => ed.test(t) || td.test(t) || sd.test(t) || nd.test(t) || od.test(t) || rd.test(t);
j.prototype.css = function(t) {
return wl(this._rgb, t);
};
X.css = (...t) => new j(...t, "css");
oe.format.css = Fr;
oe.autodetect.push({
p: 5,
test: (t, ...e) => {
if (!e.length && ie(t) === "string" && Fr.test(t))
return "css";
}
});
oe.format.gl = (...t) => {
const e = ce(t, "rgba");
return e[0] *= 255, e[1] *= 255, e[2] *= 255, e;
};
X.gl = (...t) => new j(...t, "gl");
j.prototype.gl = function() {
const t = this._rgb;
return [t[0] / 255, t[1] / 255, t[2] / 255, t[3]];
};
const { floor: Rl } = Math, Dl = (...t) => {
t = ce(t, "hcg");
let [e, s, n] = t, o, r, a;
n = n * 255;
const i = s * 255;
if (s === 0)
o = r = a = n;
else {
e === 360 && (e = 0), e > 360 && (e -= 360), e < 0 && (e += 360), e /= 60;
const c = Rl(e), _ = e - c, d = n * (1 - s), l = d + i * (1 - _), g = d + i * _, m = d + i;
switch (c) {
case 0:
[o, r, a] = [m, g, d];
break;
case 1:
[o, r, a] = [l, m, d];
break;
case 2:
[o, r, a] = [d, m, g];
break;
case 3:
[o, r, a] = [d, l, m];
break;
case 4:
[o, r, a] = [g, d, m];
break;
case 5:
[o, r, a] = [m, d, l];
break;
}
}
return [o, r, a, t.length > 3 ? t[3] : 1];
}, Nl = (...t) => {
const [e, s, n] = ce(t, "rgb"), o = Lr(e, s, n), r = Pr(e, s, n), a = r - o, i = a * 100 / 255, c = o / (255 - a) * 100;
let _;
return a === 0 ? _ = Number.NaN : (e === r && (_ = (s - n) / a), s === r && (_ = 2 + (n - e) / a), n === r && (_ = 4 + (e - s) / a), _ *= 60, _ < 0 && (_ += 360)), [_, i, c];
};
j.prototype.hcg = function() {
return Nl(this._rgb);
};
X.hcg = (...t) => new j(...t, "hcg");
oe.format.hcg = Dl;
oe.autodetect.push({
p: 1,
test: (...t) => {
if (t = ce(t, "hcg"), ie(t) === "array" && t.length === 3)
return "hcg";
}
});
const Ol = /^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/, Il = /^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/, ad = (t) => {
if (t.match(Ol)) {
(t.length === 4 || t.length === 7) && (t = t.substr(1)), t.length === 3 && (t = t.split(""), t = t[0] + t[0] + t[1] + t[1] + t[2] + t[2]);
const e = parseInt(t, 16), s = e >> 16, n = e >> 8 & 255, o = e & 255;
return [s, n, o, 1];
}
if (t.match(Il)) {
(t.length === 5 || t.length === 9) && (t = t.substr(1)), t.length === 4 && (t = t.split(""), t = t[0] + t[0] + t[1] + t[1] + t[2] + t[2] + t[3] + t[3]);
const e = parseInt(t, 16), s = e >> 24 & 255, n = e >> 16 & 255, o = e >> 8 & 255, r = Math.round((e & 255) / 255 * 100) / 100;
return [s, n, o, r];
}
throw new Error(`unknown hex color: ${t}`);
}, { round: ft } = Math, id = (...t) => {
let [e, s, n, o] = ce(t, "rgba"), r = Ot(t) || "auto";
o === void 0 && (o = 1), r === "auto" && (r = o < 1 ? "rgba" : "rgb"), e = ft(e), s = ft(s), n = ft(n);
let i = "000000" + (e << 16 | s << 8 | n).toString(16);
i = i.substr(i.length - 6);
let c = "0" + ft(o * 255).toString(16);
switch (c = c.substr(c.length - 2), r.toLowerCase()) {
case "rgba":
return `#${i}${c}`;
case "argb":
return `#${c}${i}`;
default:
return `#${i}`;
}
};
j.prototype.hex = function(t) {
return id(this._rgb, t);
};
X.hex = (...t) => new j(...t, "hex");
oe.format.hex = ad;
oe.autodetect.push({
p: 4,
test: (t, ...e) => {
if (!e.length && ie(t) === "string" && [3, 4, 5, 6, 7, 8, 9].indexOf(t.length) >= 0)
return "hex";
}
});
const { cos: tt } = Math, Al = (...t) => {
t = ce(t, "hsi");
let [e, s, n] = t, o, r, a;
return isNaN(e) && (e = 0), isNaN(s) && (s = 0), e > 360 && (e -= 360), e < 0 && (e += 360), e /= 360, e < 1 / 3 ? (a = (1 - s) / 3, o = (1 + s * tt(Ve * e) / tt(Lt - Ve * e)) / 3, r = 1 - (a + o)) : e < 2 / 3 ? (e -= 1 / 3, o = (1 - s) / 3, r = (1 + s * tt(Ve * e) / tt(Lt - Ve * e)) / 3, a = 1 - (o + r)) : (e -= 2 / 3, r = (1 - s) / 3, a = (1 + s * tt(Ve * e) / tt(Lt - Ve * e)) / 3, o = 1 - (r + a)), o = ot(n * o * 3), r = ot(n * r * 3), a = ot(n * a * 3), [o * 255, r * 255, a * 255, t.length > 3 ? t[3] : 1];
}, { min: kl, sqrt: xl, acos: Ml } = Math, Ll = (...t) => {
let [e, s, n] = ce(t, "rgb");
e /= 255, s /= 255, n /= 255;
let o;
const r = kl(e, s, n), a = (e + s + n) / 3, i = a > 0 ? 1 - r / a : 0;
return i === 0 ? o = NaN : (o = (e - s + (e - n)) / 2, o /= xl((e - s) * (e - s) + (e - n) * (s - n)), o = Ml(o), n > s && (o = Ve - o), o /= Ve), [o * 360, i, a];
};
j.prototype.hsi = function() {
return Ll(this._rgb);
};
X.hsi = (...t) => new j(...t, "hsi");
oe.format.hsi = Al;
oe.autodetect.push({
p: 2,
test: (...t) => {
if (t = ce(t, "hsi"), ie(t) === "array" && t.length === 3)
return "hsi";
}
});
j.prototype.hsl = function() {
return J_(this._rgb);
};
X.hsl = (...t) => new j(...t, "hsl");
oe.format.hsl = Ar;
oe.autodetect.push({
p: 2,
test: (...t) => {
if (t = ce(t, "hsl"), ie(t) === "array" && t.length === 3)
return "hsl";
}
});
const { floor: Pl } = Math, Fl = (...t) => {
t = ce(t, "hsv");
let [e, s, n] = t, o, r, a;
if (n *= 255, s === 0)
o = r = a = n;
else {
e === 360 && (e = 0), e > 360 && (e -= 360), e < 0 && (e += 360), e /= 60;
const i = Pl(e), c = e - i, _ = n * (1 - s), d = n * (1 - s * c), l = n * (1 - s * (1 - c));
switch (i) {
case 0:
[o, r, a] = [n, l, _];
break;
case 1:
[o, r, a] = [d, n, _];
break;
case 2:
[o, r, a] = [_, n, l];
break;
case 3:
[o, r, a] = [_, d, n];
break;
case 4:
[o, r, a] = [l, _, n];
break;
case 5:
[o, r, a] = [n, _, d];
break;
}
}
return [o, r, a, t.length > 3 ? t[3] : 1];
}, { min: jl, max: Ul } = Math, Bl = (...t) => {
t = ce(t, "rgb");
let [e, s, n] = t;
const o = jl(e, s, n), r = Ul(e, s, n), a = r - o;
let i, c, _;
return _ = r / 255, r === 0 ? (i = Number.NaN, c = 0) : (c = a / r, e === r && (i = (s - n) / a), s === r && (i = 2 + (n - e) / a), n === r && (i = 4 + (e - s) / a), i *= 60, i < 0 && (i += 360)), [i, c, _];
};
j.prototype.hsv = function() {
return Bl(this._rgb);
};
X.hsv = (...t) => new j(...t, "hsv");
oe.format.hsv = Fl;
oe.autodetect.push({
p: 2,
test: (...t) => {
if (t = ce(t, "hsv"), ie(t) === "array" && t.length === 3)
return "hsv";
}
});
const Le = {
// Corresponds roughly to RGB brighter/darker
Kn: 18,
// D65 standard referent
Xn: 0.95047,
Yn: 1,
Zn: 1.08883,
t0: 0.137931034,
// 4 / 29
t1: 0.206896552,
// 6 / 29
t2: 0.12841855,
// 3 * t1 * t1
t3: 8856452e-9
// t1 * t1 * t1
}, { pow: Gl } = Math, cd = (...t) => {
t = ce(t, "lab");
const [e, s, n] = t;
let o, r, a, i, c, _;
return r = (e + 16) / 116, o = isNaN(s) ? r : r + s / 500, a = isNaN(n) ? r : r - n / 200, r = Le.Yn * Bt(r), o = Le.Xn * Bt(o), a = Le.Zn * Bt(a), i = Ut(3.2404542 * o - 1.5371385 * r - 0.4985314 * a), c = Ut(-0.969266 * o + 1.8760108 * r + 0.041556 * a), _ = Ut(0.0556434 * o - 0.2040259 * r + 1.0572252 * a), [i, c, _, t.length > 3 ? t[3] : 1];
}, Ut = (t) => 255 * (t <= 304e-5 ? 12.92 * t : 1.055 * Gl(t, 1 / 2.4) - 0.055), Bt = (t) => t > Le.t1 ? t * t * t : Le.t2 * (t - Le.t0), { pow: _d } = Math, dd = (...t) => {
const [e, s, n] = ce(t, "rgb"), [o, r, a] = Yl(e, s, n), i = 116 * r - 16;
return [i < 0 ? 0 : i, 500 * (o - r), 200 * (r - a)];
}, Gt = (t) => (t /= 255) <= 0.04045 ? t / 12.92 : _d((t + 0.055) / 1.055, 2.4), Yt = (t) => t > Le.t3 ? _d(t, 1 / 3) : t / Le.t2 + Le.t0, Yl = (t, e, s) => {
t = Gt(t), e = Gt(e), s = Gt(s);
const n = Yt(
(0.4124564 * t + 0.3575761 * e + 0.1804375 * s) / Le.Xn
), o = Yt(
(0.2126729 * t + 0.7151522 * e + 0.072175 * s) / Le.Yn
), r = Yt(
(0.0193339 * t + 0.119192 * e + 0.9503041 * s) / Le.Zn
);
return [n, o, r];
};
j.prototype.lab = function() {
return dd(this._rgb);
};
X.lab = (...t) => new j(...t, "lab");
oe.format.lab = cd;
oe.autodetect.push({
p: 2,
test: (...t) => {
if (t = ce(t, "lab"), ie(t) === "array" && t.length === 3)
return "lab";
}
});
const { sin: ql, cos: Hl } = Math, ld = (...t) => {
let [e, s, n] = ce(t, "lch");
return isNaN(n) && (n = 0), n = n * bl, [e, Hl(n) * s, ql(n) * s];
}, gd = (...t) => {
t = ce(t, "lch");
const [e, s, n] = t, [o, r, a] = ld(e, s, n), [i, c, _] = cd(o, r, a);
return [i, c, _, t.length > 3 ? t[3] : 1];
}, zl = (...t) => {
const e = ce(t, "hcl").reverse();
return gd(...e);
}, { sqrt: Vl, atan2: Wl, round: $l } = Math, md = (...t) => {
const [e, s, n] = ce(t, "lab"), o = Vl(s * s + n * n);
let r = (Wl(n, s) * Sl + 360) % 360;
return $l(o * 1e4) === 0 && (r = Number.NaN), [e, o, r];
}, pd = (...t) => {
const [e, s, n] = ce(t, "rgb"), [o, r, a] = dd(e, s, n);
return md(o, r, a);
};
j.prototype.lch = function() {
return pd(this._rgb);
};
j.prototype.hcl = function() {
return pd(this._rgb).reverse();
};
X.lch = (...t) => new j(...t, "lch");
X.hcl = (...t) => new j(...t, "hcl");
oe.format.lch = gd;
oe.format.hcl = zl;
["lch", "hcl"].forEach(
(t) => oe.autodetect.push({
p: 2,
test: (...e) => {
if (e = ce(e, t), ie(e) === "array" && e.length === 3)
return t;
}
})
);
const at = {
aliceblue: "#f0f8ff",
antiquewhite: "#faebd7",
aqua: "#00ffff",
aquamarine: "#7fffd4",
azure: "#f0ffff",
beige: "#f5f5dc",
bisque: "#ffe4c4",
black: "#000000",
blanchedalmond: "#ffebcd",
blue: "#0000ff",
blueviolet: "#8a2be2",
brown: "#a52a2a",
burlywood: "#deb887",
cadetblue: "#5f9ea0",
chartreuse: "#7fff00",
chocolate: "#d2691e",
coral: "#ff7f50",
cornflowerblue: "#6495ed",
cornsilk: "#fff8dc",
crimson: "#dc143c",
cyan: "#00ffff",
darkblue: "#00008b",
darkcyan: "#008b8b",
darkgoldenrod: "#b8860b",
darkgray: "#a9a9a9",
darkgreen: "#006400",
darkgrey: "#a9a9a9",
darkkhaki: "#bdb76b",
darkmagenta: "#8b008b",
darkolivegreen: "#556b2f",
darkorange: "#ff8c00",
darkorchid: "#9932cc",
darkred: "#8b0000",
darksalmon: "#e9967a",
darkseagreen: "#8fbc8f",
darkslateblue: "#483d8b",
darkslategray: "#2f4f4f",
darkslategrey: "#2f4f4f",
darkturquoise: "#00ced1",
darkviolet: "#9400d3",
deeppink: "#ff1493",
deepskyblue: "#00bfff",
dimgray: "#696969",
dimgrey: "#696969",
dodgerblue: "#1e90ff",
firebrick: "#b22222",
floralwhite: "#fffaf0",
forestgreen: "#228b22",
fuchsia: "#ff00ff",
gainsboro: "#dcdcdc",
ghostwhite: "#f8f8ff",
gold: "#ffd700",
goldenrod: "#daa520",
gray: "#808080",
green: "#008000",
greenyellow: "#adff2f",
grey: "#808080",
honeydew: "#f0fff0",
hotpink: "#ff69b4",
indianred: "#cd5c5c",
indigo: "#4b0082",
ivory: "#fffff0",
khaki: "#f0e68c",
laserlemon: "#ffff54",
lavender: "#e6e6fa",
lavenderblush: "#fff0f5",
lawngreen: "#7cfc00",
lemonchiffon: "#fffacd",
lightblue: "#add8e6",
lightcoral: "#f08080",
lightcyan: "#e0ffff",
lightgoldenrod: "#fafad2",
lightgoldenrodyellow: "#fafad2",
lightgray: "#d3d3d3",
lightgreen: "#90ee90",
lightgrey: "#d3d3d3",
lightpink: "#ffb6c1",
lightsalmon: "#ffa07a",
lightseagreen: "#20b2aa",
lightskyblue: "#87cefa",
lightslategray: "#778899",
lightslategrey: "#778899",
lightsteelblue: "#b0c4de",
lightyellow: "#ffffe0",
lime: "#00ff00",
limegreen: "#32cd32",
linen: "#faf0e6",
magenta: "#ff00ff",
maroon: "#800000",
maroon2: "#7f0000",
maroon3: "#b03060",
mediumaquamarine: "#66cdaa",
mediumblue: "#0000cd",
mediumorchid: "#ba55d3",
mediumpurple: "#9370db",
mediumseagreen: "#3cb371",
mediumslateblue: "#7b68ee",
mediumspringgreen: "#00fa9a",
mediumturquoise: "#48d1cc",
mediumvioletred: "#c71585",
midnightblue: "#191970",
mintcream: "#f5fffa",
mistyrose: "#ffe4e1",
moccasin: "#ffe4b5",
navajowhite: "#ffdead",
navy: "#000080",
oldlace: "#fdf5e6",
olive: "#808000",
olivedrab: "#6b8e23",
orange: "#ffa500",
orangered: "#ff4500",
orchid: "#da70d6",
palegoldenrod: "#eee8aa",
palegreen: "#98fb98",
paleturquoise: "#afeeee",
palevioletred: "#db7093",
papayawhip: "#ffefd5",
peachpuff: "#ffdab9",
peru: "#cd853f",
pink: "#ffc0cb",
plum: "#dda0dd",
powderblue: "#b0e0e6",
purple: "#800080",
purple2: "#7f007f",
purple3: "#a020f0",
rebeccapurple: "#663399",
red: "#ff0000",
rosybrown: "#bc8f8f",
royalblue: "#4169e1",
saddlebrown: "#8b4513",
salmon: "#fa8072",
sandybrown: "#f4a460",
seagreen: "#2e8b57",
seashell: "#fff5ee",
sienna: "#a0522d",
silver: "#c0c0c0",
skyblue: "#87ceeb",
slateblue: "#6a5acd",
slategray: "#708090",
slategrey: "#708090",
snow: "#fffafa",
springgreen: "#00ff7f",
steelblue: "#4682b4",
tan: "#d2b48c",
teal: "#008080",
thistle: "#d8bfd8",
tomato: "#ff6347",
turquoise: "#40e0d0",
violet: "#ee82ee",
wheat: "#f5deb3",
white: "#ffffff",
whitesmoke: "#f5f5f5",
yellow: "#ffff00",
yellowgreen: "#9acd32"
};
j.prototype.name = function() {
const t = id(this._rgb, "rgb");
for (let e of Object.keys(at))
if (at[e] === t) return e.toLowerCase();
return t;
};
oe.format.named = (t) => {
if (t = t.toLowerCase(), at[t]) return ad(at[t]);
throw new Error("unknown color name: " + t);
};
oe.autodetect.push({
p: 5,
test: (t, ...e) => {
if (!e.length && ie(t) === "string" && at[t.toLowerCase()])
return "named";
}
});
const Kl = (t) => {
if (ie(t) == "number" && t >= 0 && t <= 16777215) {
const e = t >> 16, s = t >> 8 & 255, n = t & 255;
return [e, s, n, 1];
}
throw new Error("unknown num color: " + t);
}, Ql = (...t) => {
const [e, s, n] = ce(t, "rgb");
return (e << 16) + (s << 8) + n;
};
j.prototype.num = function() {
return Ql(this._rgb);
};
X.num = (...t) => new j(...t, "num");
oe.format.num = Kl;
oe.autodetect.push({
p: 5,
test: (...t) => {
if (t.length === 1 && ie(t[0]) === "number" && t[0] >= 0 && t[0] <= 16777215)
return "num";
}
});
const { round: ud } = Math;
j.prototype.rgb = function(t = !0) {
return t === !1 ? this._rgb.slice(0, 3) : this._rgb.slice(0, 3).map(ud);
};
j.prototype.rgba = function(t = !0) {
return this._rgb.slice(0, 4).map((e, s) => s < 3 ? t === !1 ? e : ud(e) : e);
};
X.rgb = (...t) => new j(...t, "rgb");
oe.format.rgb = (...t) => {
const e = ce(t, "rgba");
return e[3] === void 0 && (e[3] = 1), e;
};
oe.autodetect.push({
p: 3,
test: (...t) => {
if (t = ce(t, "rgba"), ie(t) === "array" && (t.length === 3 || t.length === 4 && ie(t[3]) == "number" && t[3] >= 0 && t[3] <= 1))
return "rgb";
}
});
const { log: bt } = Math, hd = (t) => {
const e = t / 100;
let s, n, o;
return e < 66 ? (s = 255, n = e < 6 ? 0 : -155.25485562709179 - 0.44596950469579133 * (n = e - 2) + 104.49216199393888 * bt(n), o = e < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (o = e - 10) + 115.67994401066147 * bt(o)) : (s = 351.97690566805693 + 0.114206453784165 * (s = e - 55) - 40.25366309332127 * bt(s), n = 325.4494125711974 + 0.07943456536662342 * (n = e - 50) - 28.0852963507957 * bt(n), o = 255), [s, n, o, 1];
}, { round: Xl } = Math, Zl = (...t) => {
const e = ce(t, "rgb"), s = e[0], n = e[2];
let o = 1e3, r = 4e4;
const a = 0.4;
let i;
for (; r - o > a; ) {
i = (r + o) * 0.5;
const c = hd(i);
c[2] / c[0] >= n / s ? r = i : o = i;
}
return Xl(i);
};
j.prototype.temp = j.prototype.kelvin = j.prototype.temperature = function() {
return Zl(this._rgb);
};
X.temp = X.kelvin = X.temperature = (...t) => new j(...t, "temp");
oe.format.temp = oe.format.kelvin = oe.format.temperature = hd;
const { pow: Tt, sign: Jl } = Math, Ed = (...t) => {
t = ce(t, "lab");
const [e, s, n] = t, o = Tt(e + 0.3963377774 * s + 0.2158037573 * n, 3), r = Tt(e - 0.1055613458 * s - 0.0638541728 * n, 3), a = Tt(e - 0.0894841775 * s - 1.291485548 * n, 3);
return [
255 * qt(4.0767416621 * o - 3.3077115913 * r + 0.2309699292 * a),
255 * qt(-1.2684380046 * o + 2.6097574011 * r - 0.3413193965 * a),
255 * qt(-0.0041960863 * o - 0.7034186147 * r + 1.707614701 * a),
t.length > 3 ? t[3] : 1
];
};
function qt(t) {
const e = Math.abs(t);
return e > 31308e-7 ? (Jl(t) || 1) * (1.055 * Tt(e, 1 / 2.4) - 0.055) : t * 12.92;
}
const { cbrt: Ht, pow: eg, sign: tg } = Math, fd = (...t) => {
const [e, s, n] = ce(t, "rgb"), [o, r, a] = [
zt(e / 255),
zt(s / 255),
zt(n / 255)
], i = Ht(0.4122214708 * o + 0.5363325363 * r + 0.0514459929 * a), c = Ht(0.2119034982 * o + 0.6806995451 * r + 0.1073969566 * a), _ = Ht(0.0883024619 * o + 0.2817188376 * r + 0.6299787005 * a);
return [
0.2104542553 * i + 0.793617785 * c - 0.0040720468 * _,
1.9779984951 * i - 2.428592205 * c + 0.4505937099 * _,
0.0259040371 * i + 0.7827717662 * c - 0.808675766 * _
];
};
function zt(t) {
const e = Math.abs(t);
return e < 0.04045 ? t / 12.92 : (tg(t) || 1) * eg((e + 0.055) / 1.055, 2.4);
}
j.prototype.oklab = function() {
return fd(this._rgb);
};
X.oklab = (...t) => new j(...t, "oklab");
oe.format.oklab = Ed;
oe.autodetect.push({
p: 3,
test: (...t) => {
if (t = ce(t, "oklab"), ie(t) === "array" && t.length === 3)
return "oklab";
}
});
const sg = (...t) => {
t = ce(t, "lch");
const [e, s, n] = t, [o, r, a] = ld(e, s, n), [i, c, _] = Ed(o, r, a);
return [i, c, _, t.length > 3 ? t[3] : 1];
}, ng = (...t) => {
const [e, s, n] = ce(t, "rgb"), [o, r, a] = fd(e, s, n);
return md(o, r, a);
};
j.prototype.oklch = function() {
return ng(this._rgb);
};
X.oklch = (...t) => new j(...t, "oklch");
oe.format.oklch = sg;
oe.autodetect.push({
p: 3,
test: (...t) => {
if (t = ce(t, "oklch"), ie(t) === "array" && t.length === 3)
return "oklch";
}
});
j.prototype.alpha = function(t, e = !1) {
return t !== void 0 && ie(t) === "number" ? e ? (this._rgb[3] = t, this) : new j([this._rgb[0], this._rgb[1], this._rgb[2], t], "rgb") : this._rgb[3];
};
j.prototype.clipped = function() {
return this._rgb._clipped || !1;
};
j.prototype.darken = function(t = 1) {
const e = this, s = e.lab();
return s[0] -= Le.Kn * t, new j(s, "lab").alpha(e.alpha(), !0);
};
j.prototype.brighten = function(t = 1) {
return this.darken(-t);
};
j.prototype.darker = j.prototype.darken;
j.prototype.brighter = j.prototype.brighten;
j.prototype.get = function(t) {
const [e, s] = t.split("."), n = this[e]();
if (s) {
const o = e.indexOf(s) - (e.substr(0, 2) === "ok" ? 2 : 0);
if (o > -1) return n[o];
throw new Error(`unknown channel ${s} in mode ${e}`);
} else
return n;
};
const { pow: og } = Math, rg = 1e-7, ag = 20;
j.prototype.luminance = function(t, e = "rgb") {
if (t !== void 0 && ie(t) === "number") {
if (t === 0)
return new j([0, 0, 0, this._rgb[3]], "rgb");
if (t === 1)
return new j([255, 255, 255, this._rgb[3]], "rgb");
let s = this.luminance(), n = ag;
const o = (a, i) => {
const c = a.interpolate(i, 0.5, e), _ = c.luminance();
return Math.abs(t - _) < rg || !n-- ? c : _ > t ? o(a, c) : o(c, i);
}, r = (s > t ? o(new j([0, 0, 0]), this) : o(this, new j([255, 255, 255]))).rgb();
return new j([...r, this._rgb[3]]);
}
return ig(...this._rgb.slice(0, 3));
};
const ig = (t, e, s) => (t = Vt(t), e = Vt(e), s = Vt(s), 0.2126 * t + 0.7152 * e + 0.0722 * s), Vt = (t) => (t /= 255, t <= 0.03928 ? t / 12.92 : og((t + 0.055) / 1.055, 2.4)), Ie = {}, mt = (t, e, s = 0.5, ...n) => {
let o = n[0] || "lrgb";
if (!Ie[o] && !n.length && (o = Object.keys(Ie)[0]), !Ie[o])
throw new Error(`interpolation mode ${o} is not defined`);
return ie(t) !== "object" && (t = new j(t)), ie(e) !== "object" && (e = new j(e)), Ie[o](t, e, s).alpha(
t.alpha() + s * (e.alpha() - t.alpha())
);
};
j.prototype.mix = j.prototype.interpolate = function(t, e = 0.5, ...s) {
return mt(this, t, e, ...s);
};
j.prototype.premultiply = function(t = !1) {
const e = this._rgb, s = e[3];
return t ? (this._rgb = [e[0] * s, e[1] * s, e[2] * s, s], this) : new j([e[0] * s, e[1] * s, e[2] * s, s], "rgb");
};
j.prototype.saturate = function(t = 1) {
const e = this, s = e.lch();
return s[1] += Le.Kn * t, s[1] < 0 && (s[1] = 0), new j(s, "lch").alpha(e.alpha(), !0);
};
j.prototype.desaturate = function(t = 1) {
return this.saturate(-t);
};
j.prototype.set = function(t, e, s = !1) {
const [n, o] = t.split("."), r = this[n]();
if (o) {
const a = n.indexOf(o) - (n.substr(0, 2) === "ok" ? 2 : 0);
if (a > -1) {
if (ie(e) == "string")
switch (e.charAt(0)) {
case "+":
r[a] += +e;
break;
case "-":
r[a] += +e;
break;
case "*":
r[a] *= +e.substr(1);
break;
case "/":
r[a] /= +e.substr(1);
break;
default:
r[a] = +e;
}
else if (ie(e) === "number")
r[a] = e;
else
throw new Error("unsupported value for Color.set");
const i = new j(r, n);
return s ? (this._rgb = i._rgb, this) : i;
}
throw new Error(`unknown channel ${o} in mode ${n}`);
} else
return r;
};
j.prototype.tint = function(t = 0.5, ...e) {
return mt(this, "white", t, ...e);
};
j.prototype.shade = function(t = 0.5, ...e) {
return mt(this, "black", t, ...e);
};
const cg = (t, e, s) => {
const n = t._rgb, o = e._rgb;
return new j(
n[0] + s * (o[0] - n[0]),
n[1] + s * (o[1] - n[1]),
n[2] + s * (o[2] - n[2]),
"rgb"
);
};
Ie.rgb = cg;
const { sqrt: Wt, pow: st } = Math, _g = (t, e, s) => {
const [n, o, r] = t._rgb, [a, i, c] = e._rgb;
return new j(
Wt(st(n, 2) * (1 - s) + st(a, 2) * s),
Wt(st(o, 2) * (1 - s) + st(i, 2) * s),
Wt(st(r, 2) * (1 - s) + st(c, 2) * s),
"rgb"
);
};
Ie.lrgb = _g;
const dg = (t, e, s) => {
const n = t.lab(), o = e.lab();
return new j(
n[0] + s * (o[0] - n[0]),
n[1] + s * (o[1] - n[1]),
n[2] + s * (o[2] - n[2]),
"lab"
);
};
Ie.lab = dg;
const _t = (t, e, s, n) => {
let o, r;
n === "hsl" ? (o = t.hsl(), r = e.hsl()) : n === "hsv" ? (o = t.hsv(), r = e.hsv()) : n === "hcg" ? (o = t.hcg(), r = e.hcg()) : n === "hsi" ? (o = t.hsi(), r = e.hsi()) : n === "lch" || n === "hcl" ? (n = "hcl", o = t.hcl(), r = e.hcl()) : n === "oklch" && (o = t.oklch().reverse(), r = e.oklch().reverse());
let a, i, c, _, d, l;
(n.substr(0, 1) === "h" || n === "oklch") && ([a, c, d] = o, [i, _, l] = r);
let g, m, h, S;
return !isNaN(a) && !isNaN(i) ? (i > a && i - a > 180 ? S = i - (a + 360) : i < a && a - i > 180 ? S = i + 360 - a : S = i - a, m = a + s * S) : isNaN(a) ? isNaN(i) ? m = Number.NaN : (m = i, (d == 1 || d == 0) && n != "hsv" && (g = _)) : (m = a, (l == 1 || l == 0) && n != "hsv" && (g = c)), g === void 0 && (g = c + s * (_ - c)), h = d + s * (l - d), n === "oklch" ? new j([h, g, m], n) : new j([m, g, h], n);
}, bd = (t, e, s) => _t(t, e, s, "lch");
Ie.lch = bd;
Ie.hcl = bd;
const lg = (t, e, s) => {
const n = t.num(), o = e.num();
return new j(n + s * (o - n), "num");
};
Ie.num = lg;
const gg = (t, e, s) => _t(t, e, s, "hcg");
Ie.hcg = gg;
const mg = (t, e, s) => _t(t, e, s, "hsi");
Ie.hsi = mg;
const pg = (t, e, s) => _t(t, e, s, "hsl");
Ie.hsl = pg;
const ug = (t, e, s) => _t(t, e, s, "hsv");
Ie.hsv = ug;
const hg = (t, e, s) => {
const n = t.oklab(), o = e.oklab();
return new j(
n[0] + s * (o[0] - n[0]),
n[1] + s * (o[1] - n[1]),
n[2] + s * (o[2] - n[2]),
"oklab"
);
};
Ie.oklab = hg;
const Eg = (t, e, s) => _t(t, e, s, "oklch");
Ie.oklch = Eg;
const { pow: $t, sqrt: Kt, PI: Qt, cos: ea, sin: ta, atan2: fg } = Math, bg = (t, e = "lrgb", s = null) => {
const n = t.length;
s || (s = Array.from(new Array(n)).map(() => 1));
const o = n / s.reduce(function(l, g) {
return l + g;
});
if (s.forEach((l, g) => {
s[g] *= o;
}), t = t.map((l) => new j(l)), e === "lrgb")
return Sg(t, s);
const r = t.shift(), a = r.get(e), i = [];
let c = 0, _ = 0;
for (let l = 0; l < a.length; l++)
if (a[l] = (a[l] || 0) * s[0], i.push(isNaN(a[l]) ? 0 : s[0]), e.charAt(l) === "h" && !isNaN(a[l])) {
const g = a[l] / 180 * Qt;
c += ea(g) * s[0], _ += ta(g) * s[0];
}
let d = r.alpha() * s[0];
t.forEach((l, g) => {
const m = l.get(e);
d += l.alpha() * s[g + 1];
for (let h = 0; h < a.length; h++)
if (!isNaN(m[h]))
if (i[h] += s[g + 1], e.charAt(h) === "h") {
const S = m[h] / 180 * Qt;
c += ea(S) * s[g + 1], _ += ta(S) * s[g + 1];
} else
a[h] += m[h] * s[g + 1];
});
for (let l = 0; l < a.length; l++)
if (e.charAt(l) === "h") {
let g = fg(_ / i[l], c / i[l]) / Qt * 180;
for (; g < 0; ) g += 360;
for (; g >= 360; ) g -= 360;
a[l] = g;
} else
a[l] = a[l] / i[l];
return d /= n, new j(a, e).alpha(d > 0.99999 ? 1 : d, !0);
}, Sg = (t, e) => {
const s = t.length, n = [0, 0, 0, 0];
for (let o = 0; o < t.length; o++) {
const r = t[o], a = e[o] / s, i = r._rgb;
n[0] += $t(i[0], 2) * a, n[1] += $t(i[1], 2) * a, n[2] += $t(i[2], 2) * a, n[3] += i[3] * a;
}
return n[0] = Kt(n[0]), n[1] = Kt(n[1]), n[2] = Kt(n[2]), n[3] > 0.9999999 && (n[3] = 1), new j(Mr(n));
}, { pow: yg } = Math;
function wt(t) {
let e = "rgb", s = X("#ccc"), n = 0, o = [0, 1], r = [], a = [0, 0], i = !1, c = [], _ = !1, d = 0, l = 1, g = !1, m = {}, h = !0, S = 1;
const b = function(T) {
if (T = T || ["#fff", "#000"], T && ie(T) === "string" && X.brewer && X.brewer[T.toLowerCase()] && (T = X.brewer[T.toLowerCase()]), ie(T) === "array") {
T.length === 1 && (T = [T[0], T[0]]), T = T.slice(0);
for (let w = 0; w < T.length; w++)
T[w] = X(T[w]);
r.length = 0;
for (let w = 0; w < T.length; w++)
r.push(w / (T.length - 1));
}
return P(), c = T;
}, y = function(T) {
if (i != null) {
const w = i.length - 1;
let M = 0;
for (; M < w && T >= i[M]; )
M++;
return M - 1;
}
return 0;
};
let N = (T) => T, k = (T) => T;
const x = function(T, w) {
let M, U;
if (w == null && (w = !1), isNaN(T) || T === null)
return s;
w ? U = T : i && i.length > 2 ? U = y(T) / (i.length - 2) : l !== d ? U = (T - d) / (l - d) : U = 1, U = k(U), w || (U = N(U)), S !== 1 && (U = yg(U, S)), U = a[0] + U * (1 - a[0] - a[1]), U = ot(U, 0, 1);
const L = Math.floor(U * 1e4);
if (h && m[L])
M = m[L];
else {
if (ie(c) === "array")
for (let W = 0; W < r.length; W++) {
const Z = r[W];
if (U <= Z) {
M = c[W];
break;
}
if (U >= Z && W === r.length - 1) {
M = c[W];
break;
}
if (U > Z && U < r[W + 1]) {
U = (U - Z) / (r[W + 1] - Z), M = X.interpolate(
c[W],
c[W + 1],
U,
e
);
break;
}
}
else ie(c) === "function" && (M = c(U));
h && (m[L] = M);
}
return M;
};
var P = () => m = {};
b(t);
const R = function(T) {
const w = X(x(T));
return _ && w[_] ? w[_]() : w;
};
return R.classes = function(T) {
if (T != null) {
if (ie(T) === "array")
i = T, o = [T[0], T[T.length - 1]];
else {
const w = X.analyze(o);
T === 0 ? i = [w.min, w.max] : i = X.limits(w, "e", T);
}
return R;
}
return i;
}, R.domain = function(T) {
if (!arguments.length)
return o;
d = T[0], l = T[T.length - 1], r = [];
const w = c.length;
if (T.length === w && d !== l)
for (let M of Array.from(T))
r.push((M - d) / (l - d));
else {
for (let M = 0; M < w; M++)
r.push(M / (w - 1));
if (T.length > 2) {
const M = T.map((L, W) => W / (T.length - 1)), U = T.map((L) => (L - d) / (l - d));
U.every((L, W) => M[W] === L) || (k = (L) => {
if (L <= 0 || L >= 1) return L;
let W = 0;
for (; L >= U[W + 1]; ) W++;
const Z = (L - U[W]) / (U[W + 1] - U[W]);
return M[W] + Z * (M[W + 1] - M[W]);
});
}
}
return o = [d, l], R;
}, R.mode = function(T) {
return arguments.length ? (e = T, P(), R) : e;
}, R.range = function(T, w) {
return b(T), R;
}, R.out = function(T) {
return _ = T, R;
}, R.spread = function(T) {
return arguments.length ? (n = T, R) : n;
}, R.correctLightness = function(T) {
return T == null && (T = !0), g = T, P(), g ? N = function(w) {
const M = x(0, !0).lab()[0], U = x(1, !0).lab()[0], L = M > U;
let W = x(w, !0).lab()[0];
const Z = M + (U - M) * w;
let de = W - Z, te = 0, me = 1, I = 20;
for (; Math.abs(de) > 0.01 && I-- > 0; )
(function() {
return L && (de *= -1), de < 0 ? (te = w, w += (me - w) * 0.5) : (me = w, w += (te - w) * 0.5), W = x(w, !0).lab()[0], de = W - Z;
})();
return w;
} : N = (w) => w, R;
}, R.padding = function(T) {
return T != null ? (ie(T) === "number" && (T = [T, T]), a = T, R) : a;
}, R.colors = function(T, w) {
arguments.length < 2 && (w = "hex");
let M = [];
if (arguments.length === 0)
M = c.slice(0);
else if (T === 1)
M = [R(0.5)];
else if (T > 1) {
const U = o[0], L = o[1] - U;
M = vg(0, T).map(
(W) => R(U + W / (T - 1) * L)
);
} else {
t = [];
let U = [];
if (i && i.length > 2)
for (let L = 1, W = i.length, Z = 1 <= W; Z ? L < W : L > W; Z ? L++ : L--)
U.push((i[L - 1] + i[L]) * 0.5);
else
U = o;
M = U.map((L) => R(L));
}
return X[w] && (M = M.map((U) => U[w]())), M;
}, R.cache = function(T) {
return T != null ? (h = T, R) : h;
}, R.gamma = function(T) {
return T != null ? (S = T, R) : S;
}, R.nodata = function(T) {
return T != null ? (s = X(T), R) : s;
}, R;
}
function vg(t, e, s) {
let n = [], o = t < e, r = e;
for (let a = t; o ? a < r : a > r; o ? a++ : a--)
n.push(a);
return n;
}
const Tg = function(t) {
let e = [1, 1];
for (let s = 1; s < t; s++) {
let n = [1];
for (let o = 1; o <= e.length; o++)
n[o] = (e[o] || 0) + e[o - 1];
e = n;
}
return e;
}, Cg = function(t) {
let e, s, n, o;
if (t = t.map((r) => new j(r)), t.length === 2)
[s, n] = t.map((r) => r.lab()), e = function(r) {
const a = [0, 1, 2].map((i) => s[i] + r * (n[i] - s[i]));
return new j(a, "lab");
};
else if (t.length === 3)
[s, n, o] = t.map((r) => r.lab()), e = function(r) {
const a = [0, 1, 2].map(
(i) => (1 - r) * (1 - r) * s[i] + 2 * (1 - r) * r * n[i] + r * r * o[i]
);
return new j(a, "lab");
};
else if (t.length === 4) {
let r;
[s, n, o, r] = t.map((a) => a.lab()), e = function(a) {
const i = [0, 1, 2].map(
(c) => (1 - a) * (1 - a) * (1 - a) * s[c] + 3 * (1 - a) * (1 - a) * a * n[c] + 3 * (1 - a) * a * a * o[c] + a * a * a * r[c]
);
return new j(i, "lab");
};
} else if (t.length >= 5) {
let r, a, i;
r = t.map((c) => c.lab()), i = t.length - 1, a = Tg(i), e = function(c) {
const _ = 1 - c, d = [0, 1, 2].map(
(l) => r.reduce(
(g, m, h) => g + a[h] * _ ** (i - h) * c ** h * m[l],
0
)
);
return new j(d, "lab");
};
} else
throw new RangeError("No point in running bezier with only one color.");
return e;
}, wg = (t) => {
const e = Cg(t);
return e.scale = () => wt(e), e;
}, Ue = (t, e, s) => {
if (!Ue[s])
throw new Error("unknown blend mode " + s);
return Ue[s](t, e);
}, Qe = (t) => (e, s) => {
const n = X(s).rgb(), o = X(e).rgb();
return X.rgb(t(n, o));
}, Xe = (t) => (e, s) => {
const n = [];
return n[0] = t(e[0], s[0]), n[1] = t(e[1], s[1]), n[2] = t(e[2], s[2]), n;
}, Rg = (t) => t, Dg = (t, e) => t * e / 255, Ng = (t, e) => t > e ? e : t, Og = (t, e) => t > e ? t : e, Ig = (t, e) => 255 * (1 - (1 - t / 255) * (1 - e / 255)), Ag = (t, e) => e < 128 ? 2 * t * e / 255 : 255 * (1 - 2 * (1 - t / 255) * (1 - e / 255)), kg = (t, e) => 255 * (1 - (1 - e / 255) / (t / 255)), xg = (t, e) => t === 255 ? 255 : (t = 255 * (e / 255) / (1 - t / 255), t > 255 ? 255 : t);
Ue.normal = Qe(Xe(Rg));
Ue.multiply = Qe(Xe(Dg));
Ue.screen = Qe(Xe(Ig));
Ue.overlay = Qe(Xe(Ag));
Ue.darken = Qe(Xe(Ng));
Ue.lighten = Qe(Xe(Og));
Ue.dodge = Qe(Xe(xg));
Ue.burn = Qe(Xe(kg));
const { pow: Mg, sin: Lg, cos: Pg } = Math;
function Fg(t = 300, e = -1.5, s = 1, n = 1, o = [0, 1]) {
let r = 0, a;
ie(o) === "array" ? a = o[1] - o[0] : (a = 0, o = [o, o]);
const i = function(c) {
const _ = Ve * ((t + 120) / 360 + e * c), d = Mg(o[0] + a * c, n), g = (r !== 0 ? s[0] + c * r : s) * d * (1 - d) / 2, m = Pg(_), h = Lg(_), S = d + g * (-0.14861 * m + 1.78277 * h), b = d + g * (-0.29227 * m - 0.90649 * h), y = d + g * (1.97294 * m);
return X(Mr([S * 255, b * 255, y * 255, 1]));
};
return i.start = function(c) {
return c == null ? t : (t = c, i);
}, i.rotations = function(c) {
return c == null ? e : (e = c, i);
}, i.gamma = function(c) {
return c == null ? n : (n = c, i);
}, i.hue = function(c) {
return c == null ? s : (s = c, ie(s) === "array" ? (r = s[1] - s[0], r === 0 && (s = s[1])) : r = 0, i);
}, i.lightness = function(c) {
return c == null ? o : (ie(c) === "array" ? (o = c, a = c[1] - c[0]) : (o = [c, c], a = 0), i);
}, i.scale = () => X.scale(i), i.hue(s), i;
}
const jg = "0123456789abcdef", { floor: Ug, random: Bg } = Math, Gg = () => {
let t = "#";
for (let e = 0; e < 6; e++)
t += jg.charAt(Ug(Bg() * 16));
return new j(t, "hex");
}, { log: sa, pow: Yg, floor: qg, abs: Hg } = Math;
function Sd(t, e = null) {
const s = {
min: Number.MAX_VALUE,
max: Number.MAX_VALUE * -1,
sum: 0,
values: [],
count: 0
};
return ie(t) === "object" && (t = Object.values(t)), t.forEach((n) => {
e && ie(n) === "object" && (n = n[e]), n != null && !isNaN(n) && (s.values.push(n), s.sum += n, n < s.min && (s.min = n), n > s.max && (s.max = n), s.count += 1);
}), s.domain = [s.min, s.max], s.limits = (n, o) => yd(s, n, o), s;
}
function yd(t, e = "equal", s = 7) {
ie(t) == "array" && (t = Sd(t));
const { min: n, max: o } = t, r = t.values.sort((i, c) => i - c);
if (s === 1)
return [n, o];
const a = [];
if (e.substr(0, 1) === "c" && (a.push(n), a.push(o)), e.substr(0, 1) === "e") {
a.push(n);
for (let i = 1; i < s; i++)
a.push(n + i / s * (o - n));
a.push(o);
} else if (e.substr(0, 1) === "l") {
if (n <= 0)
throw new Error(
"Logarithmic scales are only possible for values > 0"
);
const i = Math.LOG10E * sa(n), c = Math.LOG10E * sa(o);
a.push(n);
for (let _ = 1; _ < s; _++)
a.push(Yg(10, i + _ / s * (c - i)));
a.push(o);
} else if (e.substr(0, 1) === "q") {
a.push(n);
for (let i = 1; i < s; i++) {
const c = (r.length - 1) * i / s, _ = qg(c);
if (_ === c)
a.push(r[_]);
else {
const d = c - _;
a.push(r[_] * (1 - d) + r[_ + 1] * d);
}
}
a.push(o);
} else if (e.substr(0, 1) === "k") {
let i;
const c = r.length, _ = new Array(c), d = new Array(s);
let l = !0, g = 0, m = null;
m = [], m.push(n);
for (let b = 1; b < s; b++)
m.push(n + b / s * (o - n));
for (m.push(o); l; ) {
for (let y = 0; y < s; y++)
d[y] = 0;
for (let y = 0; y < c; y++) {
const N = r[y];
let k = Number.MAX_VALUE, x;
for (let P = 0; P < s; P++) {
const R = Hg(m[P] - N);
R < k && (k = R, x = P), d[x]++, _[y] = x;
}
}
const b = new Array(s);
for (let y = 0; y < s; y++)
b[y] = null;
for (let y = 0; y < c; y++)
i = _[y], b[i] === null ? b[i] = r[y] : b[i] += r[y];
for (let y = 0; y < s; y++)
b[y] *= 1 / d[y];
l = !1;
for (let y = 0; y < s; y++)
if (b[y] !== m[y]) {
l = !0;
break;
}
m = b, g++, g > 200 && (l = !1);
}
const h = {};
for (let b = 0; b < s; b++)
h[b] = [];
for (let b = 0; b < c; b++)
i = _[b], h[i].push(r[b]);
let S = [];
for (let b = 0; b < s; b++)
S.push(h[b][0]), S.push(h[b][h[b].length - 1]);
S = S.sort((b, y) => b - y), a.push(S[0]);
for (let b = 1; b < S.length; b += 2) {
const y = S[b];
!isNaN(y) && a.indexOf(y) === -1 && a.push(y);
}
}
return a;
}
const zg = (t, e) => {
t = new j(t), e = new j(e);
const s = t.luminance(), n = e.luminance();
return s > n ? (s + 0.05) / (n + 0.05) : (n + 0.05) / (s + 0.05);
}, { sqrt: He, pow: Ce, min: Vg, max: Wg, atan2: na, abs: oa, cos: St, sin: ra, exp: $g, PI: aa } = Math;
function Kg(t, e, s = 1, n = 1, o = 1) {
var r = function(Ee) {
return 360 * Ee / (2 * aa);
}, a = function(Ee) {
return 2 * aa * Ee / 360;
};
t = new j(t), e = new j(e);
const [i, c, _] = Array.from(t.lab()), [d, l, g] = Array.from(e.lab()), m = (i + d) / 2, h = He(Ce(c, 2) + Ce(_, 2)), S = He(Ce(l, 2) + Ce(g, 2)), b = (h + S) / 2, y = 0.5 * (1 - He(Ce(b, 7) / (Ce(b, 7) + Ce(25, 7)))), N = c * (1 + y), k = l * (1 + y), x = He(Ce(N, 2) + Ce(_, 2)), P = He(Ce(k, 2) + Ce(g, 2)), R = (x + P) / 2, T = r(na(_, N)), w = r(na(g, k)), M = T >= 0 ? T : T + 360, U = w >= 0 ? w : w + 360, L = oa(M - U) > 180 ? (M + U + 360) / 2 : (M + U) / 2, W = 1 - 0.17 * St(a(L - 30)) + 0.24 * St(a(2 * L)) + 0.32 * St(a(3 * L + 6)) - 0.2 * St(a(4 * L - 63));
let Z = U - M;
Z = oa(Z) <= 180 ? Z : U <= M ? Z + 360 : Z - 360, Z = 2 * He(x * P) * ra(a(Z) / 2);
const de = d - i, te = P - x, me = 1 + 0.015 * Ce(m - 50, 2) / He(20 + Ce(m - 50, 2)), I = 1 + 0.045 * R, Y = 1 + 0.015 * R * W, Q = 30 * $g(-Ce((L - 275) / 25, 2)), _e = -(2 * He(Ce(R, 7) / (Ce(R, 7) + Ce(25, 7)))) * ra(2 * a(Q)), fe = He(
Ce(de / (s * me), 2) + Ce(te / (n * I), 2) + Ce(Z / (o * Y), 2) + _e * (te / (n * I)) * (Z / (o * Y))
);
return Wg(0, Vg(100, fe));
}
function Qg(t, e, s = "lab") {
t = new j(t), e = new j(e);
const n = t.get(s), o = e.get(s);
let r = 0;
for (let a in n) {
const i = (n[a] || 0) - (o[a] || 0);
r += i * i;
}
return Math.sqrt(r);
}
const Xg = (...t) => {
try {
return new j(...t), !0;
} catch {
return !1;
}
}, Zg = {
cool() {
return wt([X.hsl(180, 1, 0.9), X.hsl(250, 0.7, 0.4)]);
},
hot() {
return wt(["#000", "#f00", "#ff0", "#fff"]).mode(
"rgb"
);
}
}, Ct = {
// sequential
OrRd: ["#fff7ec", "#fee8c8", "#fdd49e", "#fdbb84", "#fc8d59", "#ef6548", "#d7301f", "#b30000", "#7f0000"],
PuBu: ["#fff7fb", "#ece7f2", "#d0d1e6", "#a6bddb", "#74a9cf", "#3690c0", "#0570b0", "#045a8d", "#023858"],
BuPu: ["#f7fcfd", "#e0ecf4", "#bfd3e6", "#9ebcda", "#8c96c6", "#8c6bb1", "#88419d", "#810f7c", "#4d004b"],
Oranges: ["#fff5eb", "#fee6ce", "#fdd0a2", "#fdae6b", "#fd8d3c", "#f16913", "#d94801", "#a63603", "#7f2704"],
BuGn: ["#f7fcfd", "#e5f5f9", "#ccece6", "#99d8c9", "#66c2a4", "#41ae76", "#238b45", "#006d2c", "#00441b"],
YlOrBr: ["#ffffe5", "#fff7bc", "#fee391", "#fec44f", "#fe9929", "#ec7014", "#cc4c02", "#993404", "#662506"],
YlGn: ["#ffffe5", "#f7fcb9", "#d9f0a3", "#addd8e", "#78c679", "#41ab5d", "#238443", "#006837", "#004529"],
Reds: ["#fff5f0", "#fee0d2", "#fcbba1", "#fc9272", "#fb6a4a", "#ef3b2c", "#cb181d", "#a50f15", "#67000d"],
RdPu: ["#fff7f3", "#fde0dd", "#fcc5c0", "#fa9fb5", "#f768a1", "#dd3497", "#ae017e", "#7a0177", "#49006a"],
Greens: ["#f7fcf5", "#e5f5e0", "#c7e9c0", "#a1d99b", "#74c476", "#41ab5d", "#238b45", "#006d2c", "#00441b"],
YlGnBu: ["#ffffd9", "#edf8b1", "#c7e9b4", "#7fcdbb", "#41b6c4", "#1d91c0", "#225ea8", "#253494", "#081d58"],
Purples: ["#fcfbfd", "#efedf5", "#dadaeb", "#bcbddc", "#9e9ac8", "#807dba", "#6a51a3", "#54278f", "#3f007d"],
GnBu: ["#f7fcf0", "#e0f3db", "#ccebc5", "#a8ddb5", "#7bccc4", "#4eb3d3", "#2b8cbe", "#0868ac", "#084081"],
Greys: ["#ffffff", "#f0f0f0", "#d9d9d9", "#bdbdbd", "#969696", "#737373", "#525252", "#252525", "#000000"],
YlOrRd: ["#ffffcc", "#ffeda0", "#fed976", "#feb24c", "#fd8d3c", "#fc4e2a", "#e31a1c", "#bd0026", "#800026"],
PuRd: ["#f7f4f9", "#e7e1ef", "#d4b9da", "#c994c7", "#df65b0", "#e7298a", "#ce1256", "#980043", "#67001f"],
Blues: ["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"],
PuBuGn: ["#fff7fb", "#ece2f0", "#d0d1e6", "#a6bddb", "#67a9cf", "#3690c0", "#02818a", "#016c59", "#014636"],
Viridis: ["#440154", "#482777", "#3f4a8a", "#31678e", "#26838f", "#1f9d8a", "#6cce5a", "#b6de2b", "#fee825"],
// diverging
Spectral: ["#9e0142", "#d5