drizzle-cube
Version:
Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.
1,529 lines (1,527 loc) • 681 kB
JavaScript
import { jsxs as E, jsx as d, Fragment as be } from "react/jsx-runtime";
import W, { Component as Av, useRef as ne, useState as X, useLayoutEffect as a0, useEffect as ie, forwardRef as an, useMemo as Ne, useImperativeHandle as i0, useCallback as re, memo as ve, useContext as sn, createContext as s0 } from "react";
import { useCubeQuery as Tv, useDebounce as kv, useFilterValues as Rv } from "./hooks.js";
import { F as on, I as Ie, d as Mv, a as qv, b as Dv, c as Iv, e as Ov, f as Pv, g as Lv, h as Fv, i as $v, j as Vv, k as zv, l as Bv, m as Hv, n as jv, o as Gv, p as o0, q as Kr, r as Uv, s as Wv, t as Xe, u as Cu, v as dr, w as Bt, x as Pt, y as je, z as Yr, A as Kv, B as fr, C as bc, D as vc, E as Yv, G as l0, H as Lt, J as Au, K as Qv, L as Ft, M as Xv, N as c0, O as Zv, P as Jv, Q as Tu, R as xc, S as ku, T as ex } from "./chunks/icons-CEfXECaS.js";
import { u as pt } from "./chunks/providers-DwDirAYo.js";
import { i as vt, b as Ru, d as tx, e as Mu, t as rx, g as nx, h as ax, j as Er, l as ix, k as sx, m as u0, C as qu, n as Du, q as d0, o as wc, p as Iu, r as Pn, s as f0, u as ox, v as lx, w as cx, D as h0, T as ux, a as dx, R as fx, S as hx, P as mx, A as px, L as gx, B as yx } from "./chunks/charts-MTxju0dv.js";
import { c as rk, F as nk, z as ak, y as ik, x as sk, E as ok } from "./chunks/charts-MTxju0dv.js";
import { WidthProvider as bx, Responsive as vx } from "react-grid-layout";
import { createPortal as xx } from "react-dom";
class wx extends Av {
constructor(t) {
super(t), this.state = {
hasError: !1,
error: null,
errorInfo: null
};
}
static getDerivedStateFromError(t) {
return {
hasError: !0,
error: t,
errorInfo: null
};
}
componentDidCatch(t, r) {
this.setState({
error: t,
errorInfo: r.componentStack || null
}), console.error("Chart Error Boundary caught a rendering error:", t, r);
}
handleReset = () => {
this.setState({
hasError: !1,
error: null,
errorInfo: null
});
};
render() {
return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ E("div", { className: "flex flex-col items-center justify-center w-full h-full p-6 text-center border-2 border-dashed border-red-300 rounded-lg bg-red-50", children: [
/* @__PURE__ */ d("div", { className: "h-12 w-12 text-red-500 mb-4", children: "⚠️" }),
/* @__PURE__ */ d("h3", { className: "text-lg font-semibold text-red-600 mb-2", children: this.props.portletTitle ? `Rendering Error in ${this.props.portletTitle}` : "Chart Rendering Error" }),
/* @__PURE__ */ d("p", { className: "text-sm text-gray-600 mb-4 max-w-md", children: "There was an error rendering this chart component. This is different from query errors. The error details are shown below." }),
/* @__PURE__ */ d("div", { className: "w-full max-w-2xl mb-4", children: /* @__PURE__ */ E("div", { className: "bg-gray-100 rounded-lg p-3 text-left", children: [
/* @__PURE__ */ E("div", { className: "text-xs font-mono text-red-600 mb-2", children: [
/* @__PURE__ */ d("strong", { children: "Error:" }),
" ",
this.state.error?.message
] }),
this.state.error?.name && /* @__PURE__ */ E("div", { className: "text-xs font-mono text-gray-600 mb-2", children: [
/* @__PURE__ */ d("strong", { children: "Type:" }),
" ",
this.state.error.name
] }),
this.props.portletConfig && /* @__PURE__ */ E("details", { className: "text-xs font-mono text-gray-600 mb-2", children: [
/* @__PURE__ */ d("summary", { className: "cursor-pointer", children: "Portlet Configuration" }),
/* @__PURE__ */ d("pre", { className: "mt-2 whitespace-pre-wrap bg-blue-50 p-2 rounded-sm overflow-auto max-h-32", children: JSON.stringify(this.props.portletConfig, null, 2) })
] }),
this.props.cubeQuery && /* @__PURE__ */ E("details", { className: "text-xs font-mono text-gray-600 mb-2", children: [
/* @__PURE__ */ d("summary", { className: "cursor-pointer", children: "Cube Query" }),
/* @__PURE__ */ d("pre", { className: "mt-2 whitespace-pre-wrap bg-green-50 p-2 rounded-sm overflow-auto max-h-32", children: typeof this.props.cubeQuery == "string" ? JSON.stringify(JSON.parse(this.props.cubeQuery), null, 2) : JSON.stringify(this.props.cubeQuery, null, 2) })
] }),
this.state.errorInfo && /* @__PURE__ */ E("details", { className: "text-xs font-mono text-gray-600", children: [
/* @__PURE__ */ d("summary", { className: "cursor-pointer", children: "Component Stack" }),
/* @__PURE__ */ d("pre", { className: "mt-2 whitespace-pre-wrap", children: this.state.errorInfo })
] })
] }) }),
/* @__PURE__ */ E(
"button",
{
onClick: this.handleReset,
className: "px-3 py-1 bg-blue-500 text-white rounded-sm text-sm hover:bg-blue-600",
children: [
/* @__PURE__ */ d(on, { style: { width: "16px", height: "16px", display: "inline", marginRight: "4px" } }),
"Try Again"
]
}
)
] }) : this.props.children;
}
}
const _x = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Mv, className: e }),
description: "Compare values across categories",
useCase: "Best for comparing discrete categories, showing rankings, or displaying changes over time",
dropZones: [
{
key: "xAxis",
label: "X-Axis (Categories)",
description: "Dimensions and time dimensions for grouping",
mandatory: !1,
acceptTypes: ["dimension", "timeDimension"],
emptyText: "Drop dimensions & time dimensions here"
},
{
key: "yAxis",
label: "Y-Axis (Values)",
description: "Measures for bar heights",
mandatory: !0,
acceptTypes: ["measure"],
emptyText: "Drop measures here"
},
{
key: "series",
label: "Series (Split into Multiple Series)",
description: "Dimensions to create separate data series",
mandatory: !1,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions here to split data into series"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "stacked", "hideHeader"],
displayOptionsConfig: [
{
key: "target",
label: "Target Values",
type: "string",
placeholder: "e.g., 100 or 50,75 for spread",
description: "Single value or comma-separated values to spread across X-axis"
}
]
}, Nx = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: qv, className: e }),
description: "Show trends and changes over time",
useCase: "Best for continuous data, trends, time series, and showing relationships between multiple series",
dropZones: [
{
key: "xAxis",
label: "X-Axis (Time/Categories)",
description: "Time dimensions or dimensions for X-axis",
mandatory: !0,
acceptTypes: ["dimension", "timeDimension"],
emptyText: "Drop time dimensions or dimensions here"
},
{
key: "yAxis",
label: "Y-Axis (Values)",
description: "Measures for line values",
mandatory: !0,
acceptTypes: ["measure"],
emptyText: "Drop measures here"
},
{
key: "series",
label: "Series (Multiple Lines)",
description: "Dimensions to create separate lines",
mandatory: !1,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions here for multiple lines"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "target",
label: "Target Values",
type: "string",
placeholder: "e.g., 100 or 50,75 for spread",
description: "Single value or comma-separated values to spread across X-axis"
}
]
}, Sx = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Dv, className: e }),
description: "Emphasize magnitude of change over time",
useCase: "Best for showing cumulative totals, volume changes, or stacked comparisons over time",
dropZones: [
{
key: "xAxis",
label: "X-Axis (Time/Categories)",
description: "Time dimensions or dimensions for X-axis",
mandatory: !0,
acceptTypes: ["dimension", "timeDimension"],
emptyText: "Drop time dimensions or dimensions here"
},
{
key: "yAxis",
label: "Y-Axis (Values)",
description: "Measures for area values",
mandatory: !0,
acceptTypes: ["measure"],
emptyText: "Drop measures here"
},
{
key: "series",
label: "Series (Stack Areas)",
description: "Dimensions to create stacked areas",
mandatory: !1,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions here for stacked areas"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "stacked", "hideHeader"],
displayOptionsConfig: [
{
key: "target",
label: "Target Values",
type: "string",
placeholder: "e.g., 100 or 50,75 for spread",
description: "Single value or comma-separated values to spread across X-axis"
}
]
}, Ex = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Iv, className: e }),
description: "Show proportions of a whole",
useCase: "Best for showing percentage distribution or composition of a total (limit to 5-7 slices)",
dropZones: [
{
key: "xAxis",
label: "Categories",
description: "Dimension for pie slices",
mandatory: !0,
maxItems: 1,
acceptTypes: ["dimension"],
emptyText: "Drop a dimension for categories"
},
{
key: "yAxis",
label: "Values",
description: "Measure for slice sizes",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for values"
}
],
displayOptions: ["showLegend", "showTooltip", "hideHeader"]
}, Cx = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Ov, className: e }),
description: "Reveal correlations between variables",
useCase: "Best for identifying patterns, correlations, outliers, and relationships between two measures",
dropZones: [
{
key: "xAxis",
label: "X-Axis",
description: "Measure or dimension for X position",
mandatory: !0,
maxItems: 1,
acceptTypes: ["dimension", "timeDimension", "measure"],
emptyText: "Drop a field for X-axis"
},
{
key: "yAxis",
label: "Y-Axis",
description: "Measure for Y position",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for Y-axis"
},
{
key: "series",
label: "Series (Color Groups)",
description: "Dimension to color points by category",
mandatory: !1,
maxItems: 1,
acceptTypes: ["dimension"],
emptyText: "Drop a dimension to color points"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"]
}, Ax = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Pv, className: e }),
description: "Compare three dimensions of data",
useCase: "Best for showing relationships between three variables (X, Y, and size), market analysis",
dropZones: [
{
key: "xAxis",
label: "X-Axis",
description: "Horizontal axis position",
mandatory: !0,
maxItems: 1,
acceptTypes: ["dimension", "timeDimension", "measure"],
emptyText: "Drop a field for X-axis position"
},
{
key: "yAxis",
label: "Y-Axis",
description: "Vertical axis position",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for Y-axis position"
},
{
key: "sizeField",
label: "Bubble Radius",
description: "Size of bubbles based on this measure",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for bubble size"
},
{
key: "series",
label: "Bubble Labels",
description: "Field to use for bubble labels and identification",
mandatory: !0,
maxItems: 1,
acceptTypes: ["dimension"],
emptyText: "Drop a dimension for bubble labels"
},
{
key: "colorField",
label: "Bubble Colour",
description: "Color bubbles by this field (optional)",
mandatory: !1,
maxItems: 1,
acceptTypes: ["dimension", "measure"],
emptyText: "Drop a field for bubble color (optional)"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "minBubbleSize", "maxBubbleSize", "bubbleOpacity", "hideHeader"]
}, Tx = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Lv, className: e }),
description: "Compare multiple metrics across categories",
useCase: "Best for multivariate comparisons, performance metrics, strengths/weaknesses analysis",
dropZones: [
{
key: "xAxis",
label: "Axes (Categories)",
description: "Dimensions for radar axes",
mandatory: !0,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions for radar axes"
},
{
key: "yAxis",
label: "Values",
description: "Measures for radar values",
mandatory: !0,
acceptTypes: ["measure"],
emptyText: "Drop measures for values"
},
{
key: "series",
label: "Series (Multiple Shapes)",
description: "Dimensions to create multiple radar shapes",
mandatory: !1,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions for multiple shapes"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"]
}, kx = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Fv, className: e }),
description: "Circular progress and KPI visualization",
useCase: "Best for showing progress toward goals, KPIs, or comparing percentages in a compact form",
dropZones: [
{
key: "xAxis",
label: "Categories",
description: "Dimensions for radial segments",
mandatory: !0,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions for categories"
},
{
key: "yAxis",
label: "Values",
description: "Measures for radial bar lengths",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for values"
}
],
displayOptions: ["showLegend", "showTooltip", "hideHeader"]
}, Rx = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: $v, className: e }),
description: "Visualize hierarchical data with nested rectangles",
useCase: "Best for showing part-to-whole relationships in hierarchical data, disk usage, budget allocation",
dropZones: [
{
key: "xAxis",
label: "Categories",
description: "Dimensions for treemap rectangles",
mandatory: !0,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions for categories"
},
{
key: "yAxis",
label: "Size",
description: "Measure for rectangle sizes",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for size"
},
{
key: "series",
label: "Color Groups",
description: "Dimension to color rectangles by category",
mandatory: !1,
maxItems: 1,
acceptTypes: ["dimension"],
emptyText: "Drop a dimension for color grouping"
}
],
displayOptions: ["showLegend", "showTooltip", "hideHeader"]
}, Mx = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Vv, className: e }),
description: "Display detailed tabular data",
useCase: "Best for precise values, detailed analysis, sortable/filterable data exploration",
dropZones: [
{
key: "xAxis",
label: "Columns",
description: "All fields to display as columns",
mandatory: !1,
acceptTypes: ["dimension", "timeDimension", "measure"],
emptyText: "Drop fields to display as columns (or leave empty for all)"
}
],
displayOptions: ["hideHeader"]
}, qx = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: zv, className: e }),
description: "GitHub-style activity grid showing temporal patterns",
useCase: "Best for visualizing activity patterns over time, contribution calendars, and temporal heatmaps",
dropZones: [
{
key: "dateField",
label: "Time Dimension",
description: "Time field that determines grid structure (granularity affects layout)",
mandatory: !0,
maxItems: 1,
acceptTypes: ["timeDimension"],
emptyText: "Drop a time dimension (granularity affects grid structure)"
},
{
key: "valueField",
label: "Activity Measure",
description: "Measure used for activity intensity (color coding)",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for activity intensity"
}
],
displayOptions: ["showLabels", "showTooltip", "colorIntensity", "hideHeader"],
validate: (e) => {
const { dateField: t, valueField: r } = e;
return !t || Array.isArray(t) && t.length === 0 ? {
isValid: !1,
message: "Time dimension is required for activity grid"
} : !r || Array.isArray(r) && r.length === 0 ? {
isValid: !1,
message: "Activity measure is required for intensity mapping"
} : { isValid: !0 };
}
}, Dx = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Bv, className: e }),
description: "Display key performance indicators as large numbers",
useCase: "Perfect for showing important metrics like revenue, user count, or other key business metrics in a prominent, easy-to-read format",
dropZones: [
{
key: "yAxis",
label: "Value",
description: "Measure to display as KPI number",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure here"
}
],
displayOptionsConfig: [
{
key: "target",
label: "Target Value",
type: "string",
placeholder: "e.g., 100",
description: "Target value to compare against (first value used if multiple provided)"
},
{
key: "prefix",
label: "Prefix",
type: "string",
placeholder: "e.g., $, €, #",
description: "Text to display before the number"
},
{
key: "suffix",
label: "Suffix",
type: "string",
placeholder: "e.g., %, units, items",
description: "Text to display after the number"
},
{
key: "decimals",
label: "Decimal Places",
type: "number",
defaultValue: 0,
min: 0,
max: 10,
step: 1,
description: "Number of decimal places to display"
},
{
key: "valueColorIndex",
label: "Value Color",
type: "paletteColor",
defaultValue: 0,
description: "Color from the dashboard palette for the KPI value text"
}
],
displayOptions: ["hideHeader"]
}, Ix = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Hv, className: e }),
description: "Display change between latest and previous values with trend indicators",
useCase: "Perfect for showing performance changes over time, such as revenue growth, user acquisition changes, or other metrics where the trend and delta are more important than the absolute value",
dropZones: [
{
key: "yAxis",
label: "Value",
description: "Measure to track changes for",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure here"
},
{
key: "xAxis",
label: "Dimension (optional)",
description: "Dimension for ordering data (typically time)",
mandatory: !1,
maxItems: 1,
acceptTypes: ["dimension", "timeDimension"],
emptyText: "Drop a dimension for ordering"
}
],
displayOptionsConfig: [
{
key: "prefix",
label: "Prefix",
type: "string",
placeholder: "e.g., $, €, #",
description: "Text to display before the number"
},
{
key: "suffix",
label: "Suffix",
type: "string",
placeholder: "e.g., %, units, items",
description: "Text to display after the number"
},
{
key: "decimals",
label: "Decimal Places",
type: "number",
defaultValue: 1,
min: 0,
max: 10,
step: 1,
description: "Number of decimal places to display"
},
{
key: "positiveColorIndex",
label: "Positive Change Color",
type: "paletteColor",
defaultValue: 2,
// Typically green in most palettes
description: "Color for positive changes (increases)"
},
{
key: "negativeColorIndex",
label: "Negative Change Color",
type: "paletteColor",
defaultValue: 3,
// Typically red in most palettes
description: "Color for negative changes (decreases)"
},
{
key: "showHistogram",
label: "Show Variance Histogram",
type: "boolean",
defaultValue: !0,
description: "Display historical variance chart below the delta"
}
],
displayOptions: ["hideHeader"],
validate: (e) => !e.yAxis || Array.isArray(e.yAxis) && e.yAxis.length === 0 ? {
isValid: !1,
message: "A measure is required for KPI Delta charts"
} : { isValid: !0 }
}, Ox = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: jv, className: e }),
description: "Display key performance indicators as customizable text",
useCase: "Perfect for showing metrics with custom formatting, combining multiple values, or displaying contextual KPI information using templates",
dropZones: [
{
key: "yAxis",
label: "Value",
description: "Measure to display in the KPI text template",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure here"
}
],
displayOptionsConfig: [
{
key: "template",
label: "Text Template",
type: "string",
placeholder: "e.g., Total Revenue: ${value}",
description: "Template for displaying the text. Use ${value} to insert the measure value."
},
{
key: "decimals",
label: "Decimal Places",
type: "number",
defaultValue: 0,
min: 0,
max: 10,
step: 1,
description: "Number of decimal places to display for numeric values"
},
{
key: "valueColorIndex",
label: "Value Color",
type: "paletteColor",
defaultValue: 0,
description: "Color from the dashboard palette for the KPI value text"
}
],
displayOptions: ["hideHeader"]
}, Px = {
icon: ({ className: e }) => /* @__PURE__ */ d(Ie, { icon: Gv, className: e }),
description: "Display custom markdown content with formatting",
useCase: "Perfect for adding documentation, notes, instructions, or formatted text to dashboards",
skipQuery: !0,
// This chart doesn't require a valid query
dropZones: [],
// No drop zones needed for markdown content
displayOptionsConfig: [
{
key: "content",
label: "Markdown Content",
type: "string",
placeholder: `# Welcome
Add your **markdown** content here:
- Lists with bullets
- [Links](https://example.com)
- *Italic* and **bold** text`,
description: "Enter markdown text. Supports headers (#), bold (**text**), italic (*text*), links ([text](url)), and lists (- item)."
},
{
key: "accentColorIndex",
label: "Accent Color",
type: "paletteColor",
defaultValue: 0,
description: "Color from the dashboard palette for headers, bullets, and links"
},
{
key: "fontSize",
label: "Font Size",
type: "select",
defaultValue: "medium",
options: [
{ value: "small", label: "Small" },
{ value: "medium", label: "Medium" },
{ value: "large", label: "Large" }
],
description: "Overall text size for the markdown content"
},
{
key: "alignment",
label: "Text Alignment",
type: "select",
defaultValue: "left",
options: [
{ value: "left", label: "Left" },
{ value: "center", label: "Center" },
{ value: "right", label: "Right" }
],
description: "Horizontal alignment of the markdown content"
}
],
displayOptions: ["hideHeader"]
}, hr = {
bar: _x,
line: Nx,
area: Sx,
pie: Ex,
scatter: Cx,
bubble: Ax,
radar: Tx,
radialBar: kx,
treemap: Rx,
table: Mx,
activityGrid: qx,
kpiNumber: Dx,
kpiDelta: Ix,
kpiText: Ox,
markdown: Px
}, Lx = {
dropZones: [
{
key: "xAxis",
label: "X-Axis (Categories)",
description: "Dimensions and time dimensions for grouping",
mandatory: !1,
acceptTypes: ["dimension", "timeDimension"],
emptyText: "Drop dimensions & time dimensions here"
},
{
key: "yAxis",
label: "Y-Axis (Values)",
description: "Measures for values or dimensions for series",
mandatory: !1,
acceptTypes: ["measure", "dimension"],
emptyText: "Drop measures or dimensions here"
},
{
key: "series",
label: "Series (Split into Multiple Series)",
description: "Dimensions to create separate data series",
mandatory: !1,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions here to split data into series"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip"]
};
function Fc(e, t) {
return t[e] || Lx;
}
function Ou(e, t) {
let r, n;
if (t === void 0)
for (const a of e)
a != null && (r === void 0 ? a >= a && (r = n = a) : (r > a && (r = a), n < a && (n = a)));
else {
let a = -1;
for (let i of e)
(i = t(i, ++a, e)) != null && (r === void 0 ? i >= i && (r = n = i) : (r > i && (r = i), n < i && (n = i)));
}
return [r, n];
}
function _c(e, t) {
let r;
if (t === void 0)
for (const n of e)
n != null && (r < n || r === void 0 && n >= n) && (r = n);
else {
let n = -1;
for (let a of e)
(a = t(a, ++n, e)) != null && (r < a || r === void 0 && a >= a) && (r = a);
}
return r;
}
function Pu(e, t) {
let r;
if (t === void 0)
for (const n of e)
n != null && (r > n || r === void 0 && n >= n) && (r = n);
else {
let n = -1;
for (let a of e)
(a = t(a, ++n, e)) != null && (r > a || r === void 0 && a >= a) && (r = a);
}
return r;
}
function Fx(e) {
return e;
}
var Ln = 1, Fn = 2, Nc = 3, sr = 4, Lu = 1e-6;
function $x(e) {
return "translate(" + e + ",0)";
}
function Vx(e) {
return "translate(0," + e + ")";
}
function zx(e) {
return (t) => +e(t);
}
function Bx(e, t) {
return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (r) => +e(r) + t;
}
function Hx() {
return !this.__axis;
}
function m0(e, t) {
var r = [], n = null, a = null, i = 6, s = 6, o = 3, c = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, u = e === Ln || e === sr ? -1 : 1, l = e === sr || e === Fn ? "x" : "y", f = e === Ln || e === Nc ? $x : Vx;
function h(m) {
var g = n ?? (t.ticks ? t.ticks.apply(t, r) : t.domain()), v = a ?? (t.tickFormat ? t.tickFormat.apply(t, r) : Fx), p = Math.max(i, 0) + o, y = t.range(), w = +y[0] + c, S = +y[y.length - 1] + c, _ = (t.bandwidth ? Bx : zx)(t.copy(), c), A = m.selection ? m.selection() : m, b = A.selectAll(".domain").data([null]), N = A.selectAll(".tick").data(g, t).order(), q = N.exit(), T = N.enter().append("g").attr("class", "tick"), M = N.select("line"), C = N.select("text");
b = b.merge(b.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), N = N.merge(T), M = M.merge(T.append("line").attr("stroke", "currentColor").attr(l + "2", u * i)), C = C.merge(T.append("text").attr("fill", "currentColor").attr(l, u * p).attr("dy", e === Ln ? "0em" : e === Nc ? "0.71em" : "0.32em")), m !== A && (b = b.transition(m), N = N.transition(m), M = M.transition(m), C = C.transition(m), q = q.transition(m).attr("opacity", Lu).attr("transform", function(L) {
return isFinite(L = _(L)) ? f(L + c) : this.getAttribute("transform");
}), T.attr("opacity", Lu).attr("transform", function(L) {
var k = this.parentNode.__axis;
return f((k && isFinite(k = k(L)) ? k : _(L)) + c);
})), q.remove(), b.attr("d", e === sr || e === Fn ? s ? "M" + u * s + "," + w + "H" + c + "V" + S + "H" + u * s : "M" + c + "," + w + "V" + S : s ? "M" + w + "," + u * s + "V" + c + "H" + S + "V" + u * s : "M" + w + "," + c + "H" + S), N.attr("opacity", 1).attr("transform", function(L) {
return f(_(L) + c);
}), M.attr(l + "2", u * i), C.attr(l, u * p).text(v), A.filter(Hx).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === Fn ? "start" : e === sr ? "end" : "middle"), A.each(function() {
this.__axis = _;
});
}
return h.scale = function(m) {
return arguments.length ? (t = m, h) : t;
}, h.ticks = function() {
return r = Array.from(arguments), h;
}, h.tickArguments = function(m) {
return arguments.length ? (r = m == null ? [] : Array.from(m), h) : r.slice();
}, h.tickValues = function(m) {
return arguments.length ? (n = m == null ? null : Array.from(m), h) : n && n.slice();
}, h.tickFormat = function(m) {
return arguments.length ? (a = m, h) : a;
}, h.tickSize = function(m) {
return arguments.length ? (i = s = +m, h) : i;
}, h.tickSizeInner = function(m) {
return arguments.length ? (i = +m, h) : i;
}, h.tickSizeOuter = function(m) {
return arguments.length ? (s = +m, h) : s;
}, h.tickPadding = function(m) {
return arguments.length ? (o = +m, h) : o;
}, h.offset = function(m) {
return arguments.length ? (c = +m, h) : c;
}, h;
}
function Fu(e) {
return m0(Nc, e);
}
function $u(e) {
return m0(sr, e);
}
var jx = { value: () => {
} };
function ln() {
for (var e = 0, t = arguments.length, r = {}, n; e < t; ++e) {
if (!(n = arguments[e] + "") || n in r || /[\s.]/.test(n)) throw new Error("illegal type: " + n);
r[n] = [];
}
return new zr(r);
}
function zr(e) {
this._ = e;
}
function Gx(e, t) {
return e.trim().split(/^|\s+/).map(function(r) {
var n = "", a = r.indexOf(".");
if (a >= 0 && (n = r.slice(a + 1), r = r.slice(0, a)), r && !t.hasOwnProperty(r)) throw new Error("unknown type: " + r);
return { type: r, name: n };
});
}
zr.prototype = ln.prototype = {
constructor: zr,
on: function(e, t) {
var r = this._, n = Gx(e + "", r), a, i = -1, s = n.length;
if (arguments.length < 2) {
for (; ++i < s; ) if ((a = (e = n[i]).type) && (a = Ux(r[a], e.name))) return a;
return;
}
if (t != null && typeof t != "function") throw new Error("invalid callback: " + t);
for (; ++i < s; )
if (a = (e = n[i]).type) r[a] = Vu(r[a], e.name, t);
else if (t == null) for (a in r) r[a] = Vu(r[a], e.name, null);
return this;
},
copy: function() {
var e = {}, t = this._;
for (var r in t) e[r] = t[r].slice();
return new zr(e);
},
call: function(e, t) {
if ((a = arguments.length - 2) > 0) for (var r = new Array(a), n = 0, a, i; n < a; ++n) r[n] = arguments[n + 2];
if (!this._.hasOwnProperty(e)) throw new Error("unknown type: " + e);
for (i = this._[e], n = 0, a = i.length; n < a; ++n) i[n].value.apply(t, r);
},
apply: function(e, t, r) {
if (!this._.hasOwnProperty(e)) throw new Error("unknown type: " + e);
for (var n = this._[e], a = 0, i = n.length; a < i; ++a) n[a].value.apply(t, r);
}
};
function Ux(e, t) {
for (var r = 0, n = e.length, a; r < n; ++r)
if ((a = e[r]).name === t)
return a.value;
}
function Vu(e, t, r) {
for (var n = 0, a = e.length; n < a; ++n)
if (e[n].name === t) {
e[n] = jx, e = e.slice(0, n).concat(e.slice(n + 1));
break;
}
return r != null && e.push({ name: t, value: r }), e;
}
var Sc = "http://www.w3.org/1999/xhtml";
const zu = {
svg: "http://www.w3.org/2000/svg",
xhtml: Sc,
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
};
function cn(e) {
var t = e += "", r = t.indexOf(":");
return r >= 0 && (t = e.slice(0, r)) !== "xmlns" && (e = e.slice(r + 1)), zu.hasOwnProperty(t) ? { space: zu[t], local: e } : e;
}
function Wx(e) {
return function() {
var t = this.ownerDocument, r = this.namespaceURI;
return r === Sc && t.documentElement.namespaceURI === Sc ? t.createElement(e) : t.createElementNS(r, e);
};
}
function Kx(e) {
return function() {
return this.ownerDocument.createElementNS(e.space, e.local);
};
}
function p0(e) {
var t = cn(e);
return (t.local ? Kx : Wx)(t);
}
function Yx() {
}
function $c(e) {
return e == null ? Yx : function() {
return this.querySelector(e);
};
}
function Qx(e) {
typeof e != "function" && (e = $c(e));
for (var t = this._groups, r = t.length, n = new Array(r), a = 0; a < r; ++a)
for (var i = t[a], s = i.length, o = n[a] = new Array(s), c, u, l = 0; l < s; ++l)
(c = i[l]) && (u = e.call(c, c.__data__, l, i)) && ("__data__" in c && (u.__data__ = c.__data__), o[l] = u);
return new Le(n, this._parents);
}
function Xx(e) {
return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function Zx() {
return [];
}
function g0(e) {
return e == null ? Zx : function() {
return this.querySelectorAll(e);
};
}
function Jx(e) {
return function() {
return Xx(e.apply(this, arguments));
};
}
function ew(e) {
typeof e == "function" ? e = Jx(e) : e = g0(e);
for (var t = this._groups, r = t.length, n = [], a = [], i = 0; i < r; ++i)
for (var s = t[i], o = s.length, c, u = 0; u < o; ++u)
(c = s[u]) && (n.push(e.call(c, c.__data__, u, s)), a.push(c));
return new Le(n, a);
}
function y0(e) {
return function() {
return this.matches(e);
};
}
function b0(e) {
return function(t) {
return t.matches(e);
};
}
var tw = Array.prototype.find;
function rw(e) {
return function() {
return tw.call(this.children, e);
};
}
function nw() {
return this.firstElementChild;
}
function aw(e) {
return this.select(e == null ? nw : rw(typeof e == "function" ? e : b0(e)));
}
var iw = Array.prototype.filter;
function sw() {
return Array.from(this.children);
}
function ow(e) {
return function() {
return iw.call(this.children, e);
};
}
function lw(e) {
return this.selectAll(e == null ? sw : ow(typeof e == "function" ? e : b0(e)));
}
function cw(e) {
typeof e != "function" && (e = y0(e));
for (var t = this._groups, r = t.length, n = new Array(r), a = 0; a < r; ++a)
for (var i = t[a], s = i.length, o = n[a] = [], c, u = 0; u < s; ++u)
(c = i[u]) && e.call(c, c.__data__, u, i) && o.push(c);
return new Le(n, this._parents);
}
function v0(e) {
return new Array(e.length);
}
function uw() {
return new Le(this._enter || this._groups.map(v0), this._parents);
}
function Qr(e, t) {
this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
Qr.prototype = {
constructor: Qr,
appendChild: function(e) {
return this._parent.insertBefore(e, this._next);
},
insertBefore: function(e, t) {
return this._parent.insertBefore(e, t);
},
querySelector: function(e) {
return this._parent.querySelector(e);
},
querySelectorAll: function(e) {
return this._parent.querySelectorAll(e);
}
};
function dw(e) {
return function() {
return e;
};
}
function fw(e, t, r, n, a, i) {
for (var s = 0, o, c = t.length, u = i.length; s < u; ++s)
(o = t[s]) ? (o.__data__ = i[s], n[s] = o) : r[s] = new Qr(e, i[s]);
for (; s < c; ++s)
(o = t[s]) && (a[s] = o);
}
function hw(e, t, r, n, a, i, s) {
var o, c, u = /* @__PURE__ */ new Map(), l = t.length, f = i.length, h = new Array(l), m;
for (o = 0; o < l; ++o)
(c = t[o]) && (h[o] = m = s.call(c, c.__data__, o, t) + "", u.has(m) ? a[o] = c : u.set(m, c));
for (o = 0; o < f; ++o)
m = s.call(e, i[o], o, i) + "", (c = u.get(m)) ? (n[o] = c, c.__data__ = i[o], u.delete(m)) : r[o] = new Qr(e, i[o]);
for (o = 0; o < l; ++o)
(c = t[o]) && u.get(h[o]) === c && (a[o] = c);
}
function mw(e) {
return e.__data__;
}
function pw(e, t) {
if (!arguments.length) return Array.from(this, mw);
var r = t ? hw : fw, n = this._parents, a = this._groups;
typeof e != "function" && (e = dw(e));
for (var i = a.length, s = new Array(i), o = new Array(i), c = new Array(i), u = 0; u < i; ++u) {
var l = n[u], f = a[u], h = f.length, m = gw(e.call(l, l && l.__data__, u, n)), g = m.length, v = o[u] = new Array(g), p = s[u] = new Array(g), y = c[u] = new Array(h);
r(l, f, v, p, y, m, t);
for (var w = 0, S = 0, _, A; w < g; ++w)
if (_ = v[w]) {
for (w >= S && (S = w + 1); !(A = p[S]) && ++S < g; ) ;
_._next = A || null;
}
}
return s = new Le(s, n), s._enter = o, s._exit = c, s;
}
function gw(e) {
return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function yw() {
return new Le(this._exit || this._groups.map(v0), this._parents);
}
function bw(e, t, r) {
var n = this.enter(), a = this, i = this.exit();
return typeof e == "function" ? (n = e(n), n && (n = n.selection())) : n = n.append(e + ""), t != null && (a = t(a), a && (a = a.selection())), r == null ? i.remove() : r(i), n && a ? n.merge(a).order() : a;
}
function vw(e) {
for (var t = e.selection ? e.selection() : e, r = this._groups, n = t._groups, a = r.length, i = n.length, s = Math.min(a, i), o = new Array(a), c = 0; c < s; ++c)
for (var u = r[c], l = n[c], f = u.length, h = o[c] = new Array(f), m, g = 0; g < f; ++g)
(m = u[g] || l[g]) && (h[g] = m);
for (; c < a; ++c)
o[c] = r[c];
return new Le(o, this._parents);
}
function xw() {
for (var e = this._groups, t = -1, r = e.length; ++t < r; )
for (var n = e[t], a = n.length - 1, i = n[a], s; --a >= 0; )
(s = n[a]) && (i && s.compareDocumentPosition(i) ^ 4 && i.parentNode.insertBefore(s, i), i = s);
return this;
}
function ww(e) {
e || (e = _w);
function t(f, h) {
return f && h ? e(f.__data__, h.__data__) : !f - !h;
}
for (var r = this._groups, n = r.length, a = new Array(n), i = 0; i < n; ++i) {
for (var s = r[i], o = s.length, c = a[i] = new Array(o), u, l = 0; l < o; ++l)
(u = s[l]) && (c[l] = u);
c.sort(t);
}
return new Le(a, this._parents).order();
}
function _w(e, t) {
return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Nw() {
var e = arguments[0];
return arguments[0] = this, e.apply(null, arguments), this;
}
function Sw() {
return Array.from(this);
}
function Ew() {
for (var e = this._groups, t = 0, r = e.length; t < r; ++t)
for (var n = e[t], a = 0, i = n.length; a < i; ++a) {
var s = n[a];
if (s) return s;
}
return null;
}
function Cw() {
let e = 0;
for (const t of this) ++e;
return e;
}
function Aw() {
return !this.node();
}
function Tw(e) {
for (var t = this._groups, r = 0, n = t.length; r < n; ++r)
for (var a = t[r], i = 0, s = a.length, o; i < s; ++i)
(o = a[i]) && e.call(o, o.__data__, i, a);
return this;
}
function kw(e) {
return function() {
this.removeAttribute(e);
};
}
function Rw(e) {
return function() {
this.removeAttributeNS(e.space, e.local);
};
}
function Mw(e, t) {
return function() {
this.setAttribute(e, t);
};
}
function qw(e, t) {
return function() {
this.setAttributeNS(e.space, e.local, t);
};
}
function Dw(e, t) {
return function() {
var r = t.apply(this, arguments);
r == null ? this.removeAttribute(e) : this.setAttribute(e, r);
};
}
function Iw(e, t) {
return function() {
var r = t.apply(this, arguments);
r == null ? this.removeAttributeNS(e.space, e.local) : this.setAttributeNS(e.space, e.local, r);
};
}
function Ow(e, t) {
var r = cn(e);
if (arguments.length < 2) {
var n = this.node();
return r.local ? n.getAttributeNS(r.space, r.local) : n.getAttribute(r);
}
return this.each((t == null ? r.local ? Rw : kw : typeof t == "function" ? r.local ? Iw : Dw : r.local ? qw : Mw)(r, t));
}
function x0(e) {
return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function Pw(e) {
return function() {
this.style.removeProperty(e);
};
}
function Lw(e, t, r) {
return function() {
this.style.setProperty(e, t, r);
};
}
function Fw(e, t, r) {
return function() {
var n = t.apply(this, arguments);
n == null ? this.style.removeProperty(e) : this.style.setProperty(e, n, r);
};
}
function $w(e, t, r) {
return arguments.length > 1 ? this.each((t == null ? Pw : typeof t == "function" ? Fw : Lw)(e, t, r ?? "")) : Ht(this.node(), e);
}
function Ht(e, t) {
return e.style.getPropertyValue(t) || x0(e).getComputedStyle(e, null).getPropertyValue(t);
}
function Vw(e) {
return function() {
delete this[e];
};
}
function zw(e, t) {
return function() {
this[e] = t;
};
}
function Bw(e, t) {
return function() {
var r = t.apply(this, arguments);
r == null ? delete this[e] : this[e] = r;
};
}
function Hw(e, t) {
return arguments.length > 1 ? this.each((t == null ? Vw : typeof t == "function" ? Bw : zw)(e, t)) : this.node()[e];
}
function w0(e) {
return e.trim().split(/^|\s+/);
}
function Vc(e) {
return e.classList || new _0(e);
}
function _0(e) {
this._node = e, this._names = w0(e.getAttribute("class") || "");
}
_0.prototype = {
add: function(e) {
var t = this._names.indexOf(e);
t < 0 && (this._names.push(e), this._node.setAttribute("class", this._names.join(" ")));
},
remove: function(e) {
var t = this._names.indexOf(e);
t >= 0 && (this._names.splice(t, 1), this._node.setAttribute("class", this._names.join(" ")));
},
contains: function(e) {
return this._names.indexOf(e) >= 0;
}
};
function N0(e, t) {
for (var r = Vc(e), n = -1, a = t.length; ++n < a; ) r.add(t[n]);
}
function S0(e, t) {
for (var r = Vc(e), n = -1, a = t.length; ++n < a; ) r.remove(t[n]);
}
function jw(e) {
return function() {
N0(this, e);
};
}
function Gw(e) {
return function() {
S0(this, e);
};
}
function Uw(e, t) {
return function() {
(t.apply(this, arguments) ? N0 : S0)(this, e);
};
}
function Ww(e, t) {
var r = w0(e + "");
if (arguments.length < 2) {
for (var n = Vc(this.node()), a = -1, i = r.length; ++a < i; ) if (!n.contains(r[a])) return !1;
return !0;
}
return this.each((typeof t == "function" ? Uw : t ? jw : Gw)(r, t));
}
function Kw() {
this.textContent = "";
}
function Yw(e) {
return function() {
this.textContent = e;
};
}
function Qw(e) {
return function() {
var t = e.apply(this, arguments);
this.textContent = t ?? "";
};
}
function Xw(e) {
return arguments.length ? this.each(e == null ? Kw : (typeof e == "function" ? Qw : Yw)(e)) : this.node().textContent;
}
function Zw() {
this.innerHTML = "";
}
function Jw(e) {
return function() {
this.innerHTML = e;
};
}
function e1(e) {
return function() {
var t = e.apply(this, arguments);
this.innerHTML = t ?? "";
};
}
function t1(e) {
return arguments.length ? this.each(e == null ? Zw : (typeof e == "function" ? e1 : Jw)(e)) : this.node().innerHTML;
}
function r1() {
this.nextSibling && this.parentNode.appendChild(this);
}
function n1() {
return this.each(r1);
}
function a1() {
this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function i1() {
return this.each(a1);
}
function s1(e) {
var t = typeof e == "function" ? e : p0(e);
return this.select(function() {
return this.appendChild(t.apply(this, arguments));
});
}
function o1() {
return null;
}
function l1(e, t) {
var r = typeof e == "function" ? e : p0(e), n = t == null ? o1 : typeof t == "function" ? t : $c(t);
return this.select(function() {
return this.insertBefore(r.apply(this, arguments), n.apply(this, arguments) || null);
});
}
function c1() {
var e = this.parentNode;
e && e.removeChild(this);
}
function u1() {
return this.each(c1);
}
function d1() {
var e = this.cloneNode(!1), t = this.parentNode;
return t ? t.insertBefore(e, this.nextSibling) : e;
}
function f1() {
var e = this.cloneNode(!0), t = this.parentNode;
return t ? t.insertBefore(e, this.nextSibling) : e;
}
function h1(e) {
return this.select(e ? f1 : d1);
}
function m1(e) {
return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function p1(e) {
return function(t) {
e.call(this, t, this.__data__);
};
}
function g1(e) {
return e.trim().split(/^|\s+/).map(function(t) {
var r = "", n = t.indexOf(".");
return n >= 0 && (r = t.slice(n + 1), t = t.slice(0, n)), { type: t, name: r };
});
}
function y1(e) {
return function() {
var t = this.__on;
if (t) {
for (var r = 0, n = -1, a = t.length, i; r < a; ++r)
i = t[r], (!e.type || i.type === e.type) && i.name === e.name ? this.removeEventListener(i.type, i.listener, i.options) : t[++n] = i;
++n ? t.length = n : delete this.__on;
}
};
}
function b1(e, t, r) {
return function() {
var n = this.__on, a, i = p1(t);
if (n) {
for (var s = 0, o = n.length; s < o; ++s)
if ((a = n[s]).type === e.type && a.name === e.name) {
this.removeEventListener(a.type, a.listener, a.options), this.addEventListener(a.type, a.listener = i, a.options = r), a.value = t;
return;
}
}
this.addEventListener(e.type, i, r), a = { type: e.type, name: e.name, value: t, listener: i, options: r }, n ? n.push(a) : this.__on = [a];
};
}
function v1(e, t, r) {
var n = g1(e + ""), a, i = n.length, s;
if (arguments.length < 2) {
var o = this.node().__on;
if (o) {
for (var c = 0, u = o.length, l; c < u; ++c)
for (a = 0, l = o[c]; a < i; ++a)
if ((s = n[a]).type === l.type && s.name === l.name)
return l.value;
}
return;
}
for (o = t ? b1 : y1, a = 0; a < i; ++a) this.each(o(n[a], t, r));
return this;
}
function E0(e, t, r) {
var n = x0(e), a = n.CustomEvent;
typeof a == "function" ? a = new a(t, r) : (a = n.document.createEvent("Event"), r ? (a.initEvent(t, r.bubbles, r.cancelable), a.detail = r.detail) : a.initEvent(t, !1, !1)), e.dispatchEvent(a);
}
function x1(e, t) {
return function() {
return E0(this, e, t);
};
}
function w1(e, t) {
return function() {
return E0(this, e, t.apply(this, arguments));
};
}
function _1(e, t) {
return this.each((typeof t == "function" ? w1 : x1)(e, t));
}
function* N1() {
for (var e = this._groups, t = 0, r = e.length; t < r; ++t)
for (var n = e[t], a = 0, i = n.length, s; a < i; ++a)
(s = n[a]) && (yield s);
}
var C0 = [null];
function Le(e, t) {
this._groups = e, this._parents = t;
}
function vr() {
return new Le([[document.documentElement]], C0);
}
function S1() {
return this;
}
Le.prototype = vr.prototype = {
constructor: Le,
select: Qx,
selectAll: ew,
selectChild: aw,
selectChildren: lw,
filter: cw,
data: pw,
enter: uw,
exit: yw,
join: bw,
merge: vw,
selection: S1,
order: xw,
sort: ww,
call: Nw,
nodes: Sw,
node: Ew,
size: Cw,
empty: Aw,
each: Tw,
attr: Ow,
style: $w,
property: Hw,
classed: Ww,
text: Xw,
html: t1,
raise: n1,
lower: i1,
append: s1,
insert: l1,
remove: u1,
clone: h1,
datum: m1,
on: v1,
dispatch: _1,
[Symbol.iterator]: N1
};
function we(e) {
return typeof e == "string" ? new Le([[document.querySelector(e)]], [document.documentElement]) : new Le([[e]], C0);
}
function E1(e) {
let t;
for (; t = e.sourceEvent; ) e = t;
return e;
}
function He(e, t) {
if (e = E1(e), t === void 0 && (t = e.currentTarget), t) {
var r = t.ownerSVGElement || t;
if (r.createSVGPoint) {
var n = r.createSVGPoint();
return n.x = e.clientX, n.y = e.clientY, n = n.matrixTransform(t.getScreenCTM().inverse()), [n.x, n.y];
}
if (t.getBoundingClientRect) {
var a = t.getBoundingClientRect();
return [e.clientX - a.left - t.clientLeft, e.clientY - a.top - t.clientTop];
}
}
return [e.pageX, e.pageY];
}
const C1 = { passive: !1 }, mr = { capture: !0, passive: !1 };
function $n(e) {
e.stopImmediatePropagation();
}
function $t(e) {
e.preventDefault(), e.stopImmediatePropagation();
}
function A0(e) {
var t = e.document.documentElement, r = we(e).on("dragstart.drag", $t, mr);
"onselectstart" in t ? r.on("selectstart.drag", $t, mr) : (t.__noselect = t.style.MozUserSelect, t.style.MozUserSelect = "none");
}
function T0(e, t) {
var r = e.document.documentElement, n = we(e).on("dragstart.drag", null);
t && (n.on("click.drag", $t, mr), setTimeout(function() {
n.on("click.drag", null);
}, 0)), "onselectstart" in r ? n.on("selectstart.drag", null) : (r.style.MozUserSelect = r.__noselect, delete r.__noselect);
}
const Cr = (e) => () => e;
function Ec(e, {
sourceEvent: t,
subject: r,
target: n,
identifier: a,
active: i,
x: s,
y: o,
dx: c,
dy: u,
dispatch: l
}) {
Object.defineProperties(this, {
type: { value: e, enumerable: !0, configurable: !0 },
sourceEvent: { value: t, enumerable: !0, configurable: !0 },
subject: { value: r, enumerable: !0, configurable: !0 },
target: { value: n, enumerable: !0, configurable: !0 },
identifier: { value: a, enumerable: !0, configurable: !0 },
active: { value: i, enumerable: !0, configurable: !0 },
x: { value: s, enumerable: !0, configurable: !0 },
y: { value: o, enumerable: !0, configurable: !0 },
dx: { value: c, enumerable: !0, configurable: !0 },
dy: { value: u, enumerable: !0, configurable: !0 },
_: { value: l }
});
}
Ec.prototype.on = function() {
var e = this._.on.apply(this._, arguments);
return e === this._ ? this : e;
};
function A1(e