@svgrid/grid-wc 2.0.1 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,576 @@
1
+ import { A as e, B as t, C as n, D as r, F as i, G as a, I as o, K as s, L as c, N as l, O as u, P as d, Q as f, T as p, V as m, X as h, Y as g, _ as ee, a as te, d as _, et as v, f as y, g as b, h as x, j as S, n as ne, nt as C, o as w, q as T, rt as E, s as D, tt as re, u as O, v as k, x as A } from "./client-DOa609yZ.js";
2
+ import { t as ie } from "./SvGridChart-EY7OOxv6.js";
3
+ //#region ../../node_modules/.pnpm/svelte@5.55.9/node_modules/svelte/src/transition/index.js
4
+ function j(e) {
5
+ let t = e - 1;
6
+ return t * t * t + 1;
7
+ }
8
+ function M(e) {
9
+ let t = typeof e == "string" && e.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);
10
+ return t ? [parseFloat(t[1]), t[2] || "px"] : [e, "px"];
11
+ }
12
+ function N(e, { delay: t = 0, duration: n = 400, easing: r = j, x: i = 0, y: a = 0, opacity: o = 0 } = {}) {
13
+ let s = getComputedStyle(e), c = +s.opacity, l = s.transform === "none" ? "" : s.transform, u = c * (1 - o), [d, f] = M(i), [p, m] = M(a);
14
+ return {
15
+ delay: t,
16
+ duration: n,
17
+ easing: r,
18
+ css: (e, t) => `
19
+ transform: ${l} translate(${(1 - e) * d}${f}, ${(1 - e) * p}${m});
20
+ opacity: ${c - u * t}`
21
+ };
22
+ }
23
+ //#endregion
24
+ //#region ../../node_modules/.pnpm/svelte@5.55.9/node_modules/svelte/src/easing/index.js
25
+ function P(e) {
26
+ let t = e - 1;
27
+ return t * t * t + 1;
28
+ }
29
+ //#endregion
30
+ //#region ../grid/dist/chart-export.js
31
+ function F(e) {
32
+ return e instanceof SVGSVGElement ? e : e.querySelector("svg.sv-grid-chart-svg") ?? e.querySelector("svg");
33
+ }
34
+ function I(e, t, n) {
35
+ return getComputedStyle(e).getPropertyValue(t).trim() || n;
36
+ }
37
+ function L(e, t = {}) {
38
+ let n = F(e);
39
+ if (!n) throw Error("chartToSvgString: no <svg> found");
40
+ let r = I(n, "--sg-fg", "#0f172a"), i = I(n, "--sg-muted", "#64748b"), a = I(n, "--sg-border", "#e2e8f0"), o = t.background ?? I(n, "--sg-bg", "#ffffff"), s = n.viewBox.baseVal, c = s && s.width ? s.width : n.clientWidth || 520, l = s && s.height ? s.height : n.clientHeight || 300, u = n.cloneNode(!0);
41
+ u.setAttribute("width", String(c)), u.setAttribute("height", String(l)), u.setAttribute("xmlns", "http://www.w3.org/2000/svg");
42
+ let d = [
43
+ "fill",
44
+ "fill-opacity",
45
+ "stroke",
46
+ "stroke-width",
47
+ "stroke-opacity",
48
+ "stroke-dasharray",
49
+ "stroke-linecap",
50
+ "stroke-linejoin",
51
+ "opacity",
52
+ "font-size",
53
+ "font-family",
54
+ "font-weight",
55
+ "text-anchor"
56
+ ], f = n.querySelectorAll("*"), p = u.querySelectorAll("*");
57
+ for (let e = 0; e < f.length; e += 1) {
58
+ let t = p[e];
59
+ if (!t || !t.style) continue;
60
+ let n = getComputedStyle(f[e]);
61
+ for (let e of d) {
62
+ let r = n.getPropertyValue(e);
63
+ r && r !== "normal" && t.style.setProperty(e, r);
64
+ }
65
+ }
66
+ u.querySelectorAll(".sv-grid-chart-hit").forEach((e) => e.remove());
67
+ let m = document.createElementNS("http://www.w3.org/2000/svg", "style");
68
+ m.textContent = `
69
+ .sv-grid-chart-axis { fill: ${i}; font-size: 10px; font-family: sans-serif; }
70
+ .sv-grid-chart-gridline { stroke: ${a}; stroke-width: 1; opacity: 0.6; }
71
+ .sv-grid-chart-gridline.is-zero { stroke: ${i}; opacity: 0.9; }
72
+ .sv-grid-chart-datalabel { fill: ${r}; font-size: 9.5px; font-weight: 600; font-family: sans-serif; }
73
+ .sv-grid-chart-datalabel.on-bar { fill: #fff; }
74
+ .sv-grid-chart-donut-total { fill: ${r}; font-size: 16px; font-weight: 800; font-family: sans-serif; }
75
+ .sv-grid-chart-donut-label { fill: ${i}; font-size: 10px; font-family: sans-serif; }
76
+ `, u.insertBefore(m, u.firstChild);
77
+ let h = document.createElementNS("http://www.w3.org/2000/svg", "rect");
78
+ return h.setAttribute("x", "0"), h.setAttribute("y", "0"), h.setAttribute("width", String(c)), h.setAttribute("height", String(l)), h.setAttribute("fill", o), u.insertBefore(h, m.nextSibling), new XMLSerializer().serializeToString(u);
79
+ }
80
+ function R(e, t) {
81
+ let n = document.createElement("a");
82
+ n.href = e, n.download = t, document.body.appendChild(n), n.click(), n.remove();
83
+ }
84
+ function ae(e, t = "chart.svg", n = {}) {
85
+ let r = L(e, n), i = URL.createObjectURL(new Blob([r], { type: "image/svg+xml" }));
86
+ R(i, t), setTimeout(() => URL.revokeObjectURL(i), 1e3);
87
+ }
88
+ function oe(e, t = {}) {
89
+ let n = L(e, t), r = t.scale ?? 2, i = F(e), a = i.viewBox.baseVal, o = (a && a.width ? a.width : i.clientWidth || 520) * r, s = (a && a.height ? a.height : i.clientHeight || 300) * r;
90
+ return new Promise((e, t) => {
91
+ let r = URL.createObjectURL(new Blob([n], { type: "image/svg+xml" })), i = new Image();
92
+ i.onload = () => {
93
+ let n = document.createElement("canvas");
94
+ n.width = Math.round(o), n.height = Math.round(s);
95
+ let a = n.getContext("2d");
96
+ if (!a) {
97
+ URL.revokeObjectURL(r), t(/* @__PURE__ */ Error("canvas 2d context unavailable"));
98
+ return;
99
+ }
100
+ a.drawImage(i, 0, 0, n.width, n.height), URL.revokeObjectURL(r), n.toBlob((n) => n ? e(n) : t(/* @__PURE__ */ Error("toBlob failed")), "image/png");
101
+ }, i.onerror = () => {
102
+ URL.revokeObjectURL(r), t(/* @__PURE__ */ Error("failed to rasterize chart SVG"));
103
+ }, i.src = r;
104
+ });
105
+ }
106
+ async function se(e, t = "chart.png", n = {}) {
107
+ let r = await oe(e, n), i = URL.createObjectURL(r);
108
+ R(i, t), setTimeout(() => URL.revokeObjectURL(i), 1e3);
109
+ }
110
+ var z = (e) => {
111
+ let t = e == null ? "" : String(e);
112
+ return /[",\n]/.test(t) ? `"${t.replace(/"/g, "\"\"")}"` : t;
113
+ };
114
+ function B(e) {
115
+ let t = e.categories ?? [], n = e.series ?? [];
116
+ return !t.length || !n.length ? "" : [["Category", ...n.map((e) => e.label)].map(z).join(","), ...t.map((e, t) => [e, ...n.map((e) => e.values[t] ?? "")].map(z).join(","))].join("\n");
117
+ }
118
+ function ce(e, t = "chart.csv") {
119
+ let n = B(e);
120
+ if (!n) return !1;
121
+ let r = URL.createObjectURL(new Blob([n], { type: "text/csv;charset=utf-8" }));
122
+ return R(r, t), setTimeout(() => URL.revokeObjectURL(r), 1e3), !0;
123
+ }
124
+ //#endregion
125
+ //#region ../grid/dist/SvGridChartPanel.svelte
126
+ var le = e("<div role=\"separator\" aria-label=\"Resize chart panel\"></div>"), ue = e("<button type=\"button\" class=\"sv-grid-chart-btn\">Clear filter</button>"), de = S("<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><polyline points=\"20 6 9 17 4 12\"></polyline></svg>"), fe = S("<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"></path><polyline points=\"7 10 12 15 17 10\"></polyline><line x1=\"12\" y1=\"15\" x2=\"12\" y2=\"3\"></line></svg>"), pe = e("<div class=\"sv-grid-chart-export-menu\" role=\"menu\"><button type=\"button\" role=\"menuitem\">PNG image</button> <button type=\"button\" role=\"menuitem\">SVG vector</button> <button type=\"button\" role=\"menuitem\">CSV data</button> <button type=\"button\" role=\"menuitem\">Copy to clipboard</button></div>"), me = e("<button type=\"button\" aria-label=\"Chart with AI\" title=\"Chart with AI\"><svg width=\"13\" height=\"13\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M12 2l1.9 4.6L18.5 8.5 13.9 10.4 12 15l-1.9-4.6L5.5 8.5l4.6-1.9L12 2zm6 11l1 2.4 2.4 1-2.4 1L18 21l-1-2.6-2.4-1 2.4-1L18 13zM6 14l.8 2 2 .8-2 .8L6 20l-.8-2.4-2-.8 2-.8L6 14z\"></path></svg> AI</button>"), he = e("<button type=\"button\" class=\"sv-grid-chart-icon-btn\" aria-label=\"Add chart\" title=\"Add chart\"><svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"></line><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"></line></svg></button>"), ge = S("<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M8 3v3a2 2 0 0 1-2 2H3\"></path><path d=\"M21 8h-3a2 2 0 0 1-2-2V3\"></path><path d=\"M3 16h3a2 2 0 0 1 2 2v3\"></path><path d=\"M16 21v-3a2 2 0 0 1 2-2h3\"></path></svg>"), _e = S("<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M8 3H5a2 2 0 0 0-2 2v3\"></path><path d=\"M21 8V5a2 2 0 0 0-2-2h-3\"></path><path d=\"M3 16v3a2 2 0 0 0 2 2h3\"></path><path d=\"M16 21h3a2 2 0 0 0 2-2v-3\"></path></svg>"), ve = e("<button type=\"button\" class=\"sv-grid-chart-icon-btn\"><!></button> <button type=\"button\" class=\"sv-grid-chart-icon-btn\" aria-label=\"Dock chart\" title=\"Dock\"><svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\"></rect><line x1=\"15\" y1=\"3\" x2=\"15\" y2=\"21\"></line></svg></button>", 1), ye = e("<button type=\"button\" class=\"sv-grid-chart-icon-btn\" aria-label=\"Pop out chart\" title=\"Pop out\"><svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M15 3h6v6\"></path><path d=\"M10 14 21 3\"></path><path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"></path></svg></button>"), be = e("<div><button type=\"button\" class=\"sv-grid-chart-tab-label\" role=\"tab\"> </button> <button type=\"button\" class=\"sv-grid-chart-tab-x\" title=\"Remove\">&times;</button></div>"), xe = e("<div class=\"sv-grid-chart-tabs\" role=\"tablist\" aria-label=\"Charts\"></div>"), Se = e("<p class=\"sv-grid-chart-ai-msg is-error\"> </p>"), Ce = e("<p class=\"sv-grid-chart-ai-msg\"> </p>"), we = e("<div class=\"sv-grid-chart-ai\"><form class=\"sv-grid-chart-ai-row\"><input class=\"sv-grid-chart-ai-input\" type=\"text\" placeholder=\"Describe a chart, e.g. revenue by region stacked by product\"/> <button type=\"submit\" class=\"sv-grid-chart-btn\"> </button></form> <!></div>"), Te = e("<option> </option>"), Ee = e("<option> </option>"), De = e("<option> </option>"), Oe = e("<label class=\"sv-grid-chart-ctl\"><span class=\"sv-grid-chart-ctl-lbl\">Split by</span> <select><option>(none)</option><!></select></label>"), ke = e("<option> </option>"), Ae = e("<option> </option>"), je = e("<option> </option>"), Me = e("<label class=\"sv-grid-chart-toggle\"><input type=\"checkbox\"/> Stacked</label>"), Ne = e("<label class=\"sv-grid-chart-toggle\" title=\"Logarithmic value axis - flattens wide-range data\"><input type=\"checkbox\"/> Log scale</label>"), Pe = e("<label class=\"sv-grid-chart-toggle\" title=\"Space points by actual date - real time ticks and proportional gaps\"><input type=\"checkbox\"/> Date axis</label>"), Fe = e("<label class=\"sv-grid-chart-ctl\"><span class=\"sv-grid-chart-ctl-lbl\">Type</span> <select></select></label> <label class=\"sv-grid-chart-ctl\"><span class=\"sv-grid-chart-ctl-lbl\">Group by</span> <select></select></label> <!> <label class=\"sv-grid-chart-ctl\"><span class=\"sv-grid-chart-ctl-lbl\">Value</span> <select></select></label> <label class=\"sv-grid-chart-ctl\"><span class=\"sv-grid-chart-ctl-lbl\">Aggregate</span> <select></select></label> <label class=\"sv-grid-chart-ctl\"><span class=\"sv-grid-chart-ctl-lbl\">Format</span> <select></select></label> <!> <label class=\"sv-grid-chart-toggle\"><input type=\"checkbox\"/> Labels</label> <!> <!>", 1), Ie = e("<p class=\"sv-grid-chart-empty\"><!></p>"), Le = e("<div class=\"sv-grid-chart-float-resizer\" role=\"separator\" aria-label=\"Resize chart window\"></div>"), Re = e("<section aria-label=\"Chart\"><!> <header class=\"sv-grid-chart-panel-head\"><div><svg class=\"sv-grid-chart-title-icon\" width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><line x1=\"12\" y1=\"20\" x2=\"12\" y2=\"10\"></line><line x1=\"18\" y1=\"20\" x2=\"18\" y2=\"4\"></line><line x1=\"6\" y1=\"20\" x2=\"6\" y2=\"16\"></line></svg> <span class=\"sv-grid-chart-title\">Chart</span> <div class=\"sv-grid-chart-actions\"><!> <div class=\"sv-grid-chart-export\"><button type=\"button\" class=\"sv-grid-chart-icon-btn\" aria-label=\"Export chart\" title=\"Export\"><!></button> <!></div> <!> <!> <!> <button type=\"button\" class=\"sv-grid-chart-close\" aria-label=\"Close chart\">&times;</button></div></div> <!> <!> <div class=\"sv-grid-chart-controls\"><!></div></header> <div class=\"sv-grid-chart-panel-body\"><!></div> <!></section>");
127
+ function V(e, d) {
128
+ re(d, !0);
129
+ let S = ne(d, "ctrl", 7), j = f(() => S().chartingConfig), M = f(() => S().chartCfg), F = f(() => S().chartIsCustom), I = f(() => c(j)?.position ?? "bottom"), L = f(() => c(j)?.crossFilter !== !1), R = f(() => S().chartSpec), z = f(() => S().chartableColumns), B = f(() => S().chartSize ?? (c(I) === "right" ? c(j)?.width ?? 340 : c(j)?.height ?? 260)), V = f(() => S().chartFloating), H = f(() => S().chartMaximized), U = f(() => S().chartFloatRect), ze = h(null);
130
+ function Be() {
131
+ let e = c(ze)?.offsetParent;
132
+ return {
133
+ w: e?.clientWidth ?? 800,
134
+ h: e?.clientHeight ?? 520
135
+ };
136
+ }
137
+ function Ve() {
138
+ if (!S().chartFloatRect) {
139
+ let { w: e, h: t } = Be(), n = Math.min(600, Math.max(360, e - 80)), r = Math.min(430, Math.max(260, t - 90));
140
+ S().chartFloatRect = {
141
+ x: Math.round((e - n) / 2),
142
+ y: Math.round((t - r) / 2),
143
+ w: n,
144
+ h: r
145
+ };
146
+ }
147
+ S().chartFloating = !0;
148
+ }
149
+ function He() {
150
+ S().chartFloating = !1, S().chartMaximized = !1;
151
+ }
152
+ let Ue = () => S().chartMaximized = !S().chartMaximized;
153
+ function We(e) {
154
+ if (!c(V) || c(H) || e.target?.closest("button")) return;
155
+ let t = S().chartFloatRect;
156
+ if (!t) return;
157
+ e.preventDefault();
158
+ let n = e.clientX, r = e.clientY, { w: i, h: a } = Be(), o = (e) => {
159
+ let o = Math.max(0, Math.min(i - t.w, t.x + e.clientX - n)), s = Math.max(0, Math.min(a - t.h, t.y + e.clientY - r));
160
+ S().chartFloatRect = {
161
+ x: o,
162
+ y: s,
163
+ w: t.w,
164
+ h: t.h
165
+ };
166
+ }, s = () => {
167
+ window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s);
168
+ };
169
+ window.addEventListener("pointermove", o), window.addEventListener("pointerup", s);
170
+ }
171
+ function Ge(e) {
172
+ let t = S().chartFloatRect;
173
+ if (!t) return;
174
+ e.preventDefault(), e.stopPropagation();
175
+ let n = e.clientX, r = e.clientY;
176
+ e.target.setPointerCapture?.(e.pointerId);
177
+ let i = (e) => {
178
+ S().chartFloatRect = {
179
+ x: t.x,
180
+ y: t.y,
181
+ w: Math.max(300, t.w + e.clientX - n),
182
+ h: Math.max(220, t.h + e.clientY - r)
183
+ };
184
+ }, a = () => {
185
+ window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", a);
186
+ };
187
+ window.addEventListener("pointermove", i), window.addEventListener("pointerup", a);
188
+ }
189
+ let Ke = f(() => c(V) ? c(H) ? "left:12px; top:12px; right:12px; bottom:12px; width:auto; height:auto;" : c(U) ? `left:${c(U).x}px; top:${c(U).y}px; width:${c(U).w}px; height:${c(U).h}px;` : "" : c(I) === "right" ? `width:${c(B)}px` : `height:${c(B)}px`), qe = h(0), Je = h(0), Ye = f(() => c(R) ? c(R).type === "pie" ? c(R).categories.length : c(R).series.length : 0), Xe = f(() => (c(Ye) > 1 ? 36 : 0) + (c(M)?.export === !0 ? 30 : 0)), Ze = f(() => c(qe) > 24 ? c(qe) - 8 : void 0), Qe = f(() => c(Je) > 24 ? Math.max(120, c(Je) - 8 - c(Xe)) : void 0), $e = [
190
+ {
191
+ value: "bar",
192
+ label: "Bar"
193
+ },
194
+ {
195
+ value: "line",
196
+ label: "Line"
197
+ },
198
+ {
199
+ value: "area",
200
+ label: "Area"
201
+ },
202
+ {
203
+ value: "pie",
204
+ label: "Pie"
205
+ }
206
+ ], et = [
207
+ {
208
+ value: "sum",
209
+ label: "Sum"
210
+ },
211
+ {
212
+ value: "avg",
213
+ label: "Average"
214
+ },
215
+ {
216
+ value: "count",
217
+ label: "Count"
218
+ }
219
+ ], tt = [
220
+ {
221
+ value: "number",
222
+ label: "Number"
223
+ },
224
+ {
225
+ value: "currency",
226
+ label: "Currency"
227
+ },
228
+ {
229
+ value: "percent",
230
+ label: "Percent"
231
+ }
232
+ ];
233
+ function nt(e) {
234
+ c(L) && e.category != null && S().applyChartCrossFilter(String(e.category));
235
+ }
236
+ let rt = h(null), W = h(!1), it = h(!1), at = () => c(rt)?.querySelector("svg") ?? null, ot = f(() => !!(c(R) && c(R).categories?.length && c(R).series?.length));
237
+ function st() {
238
+ let e = at();
239
+ e && se(e, "chart.png"), g(W, !1);
240
+ }
241
+ function ct() {
242
+ let e = at();
243
+ e && ae(e, "chart.svg"), g(W, !1);
244
+ }
245
+ function lt() {
246
+ c(R) && ce(c(R), "chart.csv"), g(W, !1);
247
+ }
248
+ async function ut() {
249
+ let e = at();
250
+ if (g(W, !1), !(!e || typeof ClipboardItem > "u" || !navigator.clipboard?.write)) try {
251
+ let t = await oe(e);
252
+ await navigator.clipboard.write([new ClipboardItem({ "image/png": t })]), g(it, !0), setTimeout(() => g(it, !1), 1400);
253
+ } catch {}
254
+ }
255
+ m(() => {
256
+ if (!c(W)) return;
257
+ let e = (e) => {
258
+ e.target?.closest(".sv-grid-chart-export") || g(W, !1);
259
+ };
260
+ return window.addEventListener("pointerdown", e), () => window.removeEventListener("pointerdown", e);
261
+ });
262
+ let dt = f(() => !!S().chartAiHandler), G = h(!1), K = h(""), q = h(!1), J = h(""), Y = h("");
263
+ async function ft() {
264
+ let e = S().chartAiHandler, t = c(K).trim();
265
+ if (!(!e || !t || c(q))) {
266
+ g(q, !0), g(J, ""), g(Y, "");
267
+ try {
268
+ let n = await e(t);
269
+ n ? (S().applyChartConfig(n), g(Y, typeof n.rationale == "string" ? n.rationale : "", !0)) : g(J, "Couldn't build a chart from that request.");
270
+ } catch (e) {
271
+ g(J, e instanceof Error ? e.message : "Something went wrong.", !0);
272
+ } finally {
273
+ g(q, !1);
274
+ }
275
+ }
276
+ }
277
+ let pt = h(!1);
278
+ function mt(e) {
279
+ e.preventDefault(), g(pt, !0);
280
+ let t = c(I) === "right" ? e.clientX : e.clientY, n = c(B);
281
+ e.target.setPointerCapture?.(e.pointerId);
282
+ let r = (e) => {
283
+ let r = c(I) === "right" ? t - e.clientX : t - e.clientY;
284
+ S().chartSize = Math.max(160, Math.min(720, n + r));
285
+ }, i = () => {
286
+ g(pt, !1), window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", i);
287
+ };
288
+ window.addEventListener("pointermove", r), window.addEventListener("pointerup", i);
289
+ }
290
+ var X = Re();
291
+ let ht;
292
+ var gt = a(X), _t = (e) => {
293
+ var n = le();
294
+ let r;
295
+ t(() => {
296
+ r = k(n, 1, "sv-grid-chart-resizer", null, r, { "is-dragging": c(pt) }), _(n, "aria-orientation", c(I) === "right" ? "vertical" : "horizontal");
297
+ }), i("pointerdown", n, mt), u(e, n);
298
+ };
299
+ p(gt, (e) => {
300
+ c(V) || e(_t);
301
+ });
302
+ var vt = T(gt, 2), Z = a(vt);
303
+ let yt;
304
+ var bt = T(a(Z), 4), xt = a(bt), St = (e) => {
305
+ var t = ue();
306
+ i("click", t, () => S().clearChartCrossFilter()), u(e, t);
307
+ };
308
+ p(xt, (e) => {
309
+ c(L) && !c(F) && e(St);
310
+ });
311
+ var Ct = T(xt, 2), Q = a(Ct), wt = a(Q), Tt = (e) => {
312
+ u(e, de());
313
+ }, Et = (e) => {
314
+ u(e, fe());
315
+ };
316
+ p(wt, (e) => {
317
+ c(it) ? e(Tt) : e(Et, -1);
318
+ }), E(Q);
319
+ var Dt = T(Q, 2), Ot = (e) => {
320
+ var n = pe(), r = a(n), o = T(r, 2), s = T(o, 2), l = T(s, 2);
321
+ E(n), t(() => s.disabled = !c(ot)), i("click", r, st), i("click", o, ct), i("click", s, lt), i("click", l, ut), u(e, n);
322
+ };
323
+ p(Dt, (e) => {
324
+ c(W) && e(Ot);
325
+ }), E(Ct);
326
+ var kt = T(Ct, 2), At = (e) => {
327
+ var n = me();
328
+ let r;
329
+ t(() => {
330
+ r = k(n, 1, "sv-grid-chart-btn sv-grid-chart-ai-btn", null, r, { "is-active": c(G) }), _(n, "aria-expanded", c(G));
331
+ }), i("click", n, () => g(G, !c(G))), u(e, n);
332
+ };
333
+ p(kt, (e) => {
334
+ c(dt) && !c(F) && e(At);
335
+ });
336
+ var jt = T(kt, 2), Mt = (e) => {
337
+ var t = he();
338
+ i("click", t, () => S().addChart()), u(e, t);
339
+ };
340
+ p(jt, (e) => {
341
+ c(F) || e(Mt);
342
+ });
343
+ var Nt = T(jt, 2), Pt = (e) => {
344
+ var n = ve(), r = s(n), o = a(r), l = (e) => {
345
+ u(e, ge());
346
+ }, d = (e) => {
347
+ u(e, _e());
348
+ };
349
+ p(o, (e) => {
350
+ c(H) ? e(l) : e(d, -1);
351
+ }), E(r);
352
+ var f = T(r, 2);
353
+ t(() => {
354
+ _(r, "aria-label", c(H) ? "Restore" : "Maximize"), _(r, "title", c(H) ? "Restore" : "Maximize");
355
+ }), i("click", r, Ue), i("click", f, He), u(e, n);
356
+ }, Ft = (e) => {
357
+ var t = ye();
358
+ i("click", t, Ve), u(e, t);
359
+ };
360
+ p(Nt, (e) => {
361
+ c(V) ? e(Pt) : e(Ft, -1);
362
+ });
363
+ var It = T(Nt, 2);
364
+ E(bt), E(Z);
365
+ var Lt = T(Z, 2), Rt = (e) => {
366
+ var o = xe();
367
+ n(o, 23, () => S().charts, (e) => e.id, (e, n, o) => {
368
+ var s = be();
369
+ let l;
370
+ var d = a(s), f = a(d, !0);
371
+ E(d);
372
+ var p = T(d, 2);
373
+ E(s), t(() => {
374
+ l = k(s, 1, "sv-grid-chart-tab", null, l, { "is-active": c(o) === S().activeChartIndex }), _(d, "aria-selected", c(o) === S().activeChartIndex), r(f, c(n).title), _(p, "aria-label", `Remove ${c(n).title}`);
375
+ }), i("click", d, () => S().activeChartIndex = c(o)), i("click", p, () => S().removeChart(c(o))), u(e, s);
376
+ }), E(o), u(e, o);
377
+ };
378
+ p(Lt, (e) => {
379
+ !c(F) && S().charts.length > 1 && e(Rt);
380
+ });
381
+ var zt = T(Lt, 2), Bt = (e) => {
382
+ var n = we(), i = a(n), s = a(i);
383
+ O(s);
384
+ var l = T(s, 2), d = a(l, !0);
385
+ E(l), E(i);
386
+ var f = T(i, 2), m = (e) => {
387
+ var n = Se(), i = a(n, !0);
388
+ E(n), t(() => r(i, c(J))), u(e, n);
389
+ }, h = (e) => {
390
+ var n = Ce(), i = a(n, !0);
391
+ E(n), t(() => r(i, c(Y))), u(e, n);
392
+ };
393
+ p(f, (e) => {
394
+ c(J) ? e(m) : c(Y) && e(h, 1);
395
+ }), E(n), t((e) => {
396
+ s.disabled = c(q), l.disabled = e, r(d, c(q) ? "Thinking..." : "Chart it");
397
+ }, [() => c(q) || !c(K).trim()]), o("submit", i, (e) => {
398
+ e.preventDefault(), ft();
399
+ }), D(s, () => c(K), (e) => g(K, e)), u(e, n);
400
+ };
401
+ p(zt, (e) => {
402
+ c(dt) && c(G) && !c(F) && e(Bt);
403
+ });
404
+ var Vt = T(zt, 2), Ht = a(Vt), Ut = (e) => {
405
+ var o = Fe(), l = s(o), d = T(a(l), 2);
406
+ n(d, 21, () => $e, (e) => e.value, (e, n) => {
407
+ var i = Te(), o = a(i, !0);
408
+ E(i);
409
+ var s = {};
410
+ t(() => {
411
+ r(o, c(n).label), s !== (s = c(n).value) && (i.value = (i.__value = c(n).value) ?? "");
412
+ }), u(e, i);
413
+ }), E(d);
414
+ var f;
415
+ x(d), E(l);
416
+ var m = T(l, 2), h = T(a(m), 2);
417
+ n(h, 21, () => c(z).dims, (e) => e.id, (e, n) => {
418
+ var i = Ee(), o = a(i, !0);
419
+ E(i);
420
+ var s = {};
421
+ t(() => {
422
+ r(o, c(n).label), s !== (s = c(n).id) && (i.value = (i.__value = c(n).id) ?? "");
423
+ }), u(e, i);
424
+ }), E(h);
425
+ var g;
426
+ x(h), E(m);
427
+ var ee = T(m, 2), te = (e) => {
428
+ var o = Oe(), s = T(a(o), 2), l = a(s);
429
+ l.value = l.__value = "", n(T(l), 17, () => c(z).dims, (e) => e.id, (e, n) => {
430
+ var i = De(), o = a(i, !0);
431
+ E(i);
432
+ var s = {};
433
+ t(() => {
434
+ r(o, c(n).label), s !== (s = c(n).id) && (i.value = (i.__value = c(n).id) ?? "");
435
+ }), u(e, i);
436
+ }), E(s);
437
+ var d;
438
+ x(s), E(o), t(() => {
439
+ d !== (d = S().chartSeriesId ?? "") && (s.value = (s.__value = S().chartSeriesId ?? "") ?? "", b(s, S().chartSeriesId ?? ""));
440
+ }), i("change", s, (e) => S().chartSeriesId = e.currentTarget.value || null), u(e, o);
441
+ };
442
+ p(ee, (e) => {
443
+ c(z).dims.length > 1 && e(te);
444
+ });
445
+ var _ = T(ee, 2), v = T(a(_), 2);
446
+ n(v, 21, () => c(z).measures, (e) => e.id, (e, n) => {
447
+ var i = ke(), o = a(i, !0);
448
+ E(i);
449
+ var s = {};
450
+ t(() => {
451
+ r(o, c(n).label), s !== (s = c(n).id) && (i.value = (i.__value = c(n).id) ?? "");
452
+ }), u(e, i);
453
+ }), E(v);
454
+ var ne;
455
+ x(v), E(_);
456
+ var w = T(_, 2), D = T(a(w), 2);
457
+ n(D, 21, () => et, (e) => e.value, (e, n) => {
458
+ var i = Ae(), o = a(i, !0);
459
+ E(i);
460
+ var s = {};
461
+ t(() => {
462
+ r(o, c(n).label), s !== (s = c(n).value) && (i.value = (i.__value = c(n).value) ?? "");
463
+ }), u(e, i);
464
+ }), E(D);
465
+ var re;
466
+ x(D), E(w);
467
+ var k = T(w, 2), A = T(a(k), 2);
468
+ n(A, 21, () => tt, (e) => e.value, (e, n) => {
469
+ var i = je(), o = a(i, !0);
470
+ E(i);
471
+ var s = {};
472
+ t(() => {
473
+ r(o, c(n).label), s !== (s = c(n).value) && (i.value = (i.__value = c(n).value) ?? "");
474
+ }), u(e, i);
475
+ }), E(A);
476
+ var ie;
477
+ x(A), E(k);
478
+ var j = T(k, 2), M = (e) => {
479
+ var n = Me(), r = a(n);
480
+ O(r), C(), E(n), t(() => y(r, S().chartStacked)), i("change", r, (e) => S().chartStacked = e.currentTarget.checked), u(e, n);
481
+ };
482
+ p(j, (e) => {
483
+ S().chartType !== "pie" && e(M);
484
+ });
485
+ var N = T(j, 2), P = a(N);
486
+ O(P), C(), E(N);
487
+ var F = T(N, 2), I = (e) => {
488
+ var n = Ne(), r = a(n);
489
+ O(r), C(), E(n), t(() => y(r, S().chartLogScale)), i("change", r, (e) => S().chartLogScale = e.currentTarget.checked), u(e, n);
490
+ };
491
+ p(F, (e) => {
492
+ S().chartType !== "pie" && e(I);
493
+ });
494
+ var L = T(F, 2), R = (e) => {
495
+ var n = Pe(), r = a(n);
496
+ O(r), C(), E(n), t(() => y(r, S().chartTimeAxis)), i("change", r, (e) => S().chartTimeAxis = e.currentTarget.checked), u(e, n);
497
+ };
498
+ p(L, (e) => {
499
+ S().chartDimensionIsDate && S().chartType !== "pie" && e(R);
500
+ }), t(() => {
501
+ f !== (f = S().chartType) && (d.value = (d.__value = S().chartType) ?? "", b(d, S().chartType)), g !== (g = S().chartDimensionId ?? "") && (h.value = (h.__value = S().chartDimensionId ?? "") ?? "", b(h, S().chartDimensionId ?? "")), ne !== (ne = S().chartMeasureId ?? "") && (v.value = (v.__value = S().chartMeasureId ?? "") ?? "", b(v, S().chartMeasureId ?? "")), re !== (re = S().chartReduce) && (D.value = (D.__value = S().chartReduce) ?? "", b(D, S().chartReduce)), ie !== (ie = S().chartValueFormat) && (A.value = (A.__value = S().chartValueFormat) ?? "", b(A, S().chartValueFormat)), y(P, S().chartDataLabels);
502
+ }), i("change", d, (e) => S().chartType = e.currentTarget.value), i("change", h, (e) => S().chartDimensionId = e.currentTarget.value || null), i("change", v, (e) => S().chartMeasureId = e.currentTarget.value || null), i("change", D, (e) => S().chartReduce = e.currentTarget.value), i("change", A, (e) => S().chartValueFormat = e.currentTarget.value), i("change", P, (e) => S().chartDataLabels = e.currentTarget.checked), u(e, o);
503
+ };
504
+ p(Ht, (e) => {
505
+ c(F) || e(Ut);
506
+ }), E(Vt), E(vt);
507
+ var $ = T(vt, 2), Wt = a($), Gt = (e) => {
508
+ {
509
+ let t = f(() => c(M)?.zoom === !0), n = f(() => c(M)?.brush === !0), r = f(() => c(M)?.export === !0 ? !0 : void 0);
510
+ ie(e, {
511
+ get spec() {
512
+ return c(R);
513
+ },
514
+ get width() {
515
+ return c(Ze);
516
+ },
517
+ get height() {
518
+ return c(Qe);
519
+ },
520
+ onSelect: nt,
521
+ interactive: !0,
522
+ legend: !0,
523
+ get dataLabels() {
524
+ return S().chartDataLabels;
525
+ },
526
+ get zoomable() {
527
+ return c(t);
528
+ },
529
+ get brush() {
530
+ return c(n);
531
+ },
532
+ get toolbar() {
533
+ return c(r);
534
+ }
535
+ });
536
+ }
537
+ }, Kt = (e) => {
538
+ var t = Ie(), n = a(t), r = (e) => {
539
+ u(e, l("Charting needs at least one text column (to group by) and one numeric column (to measure)."));
540
+ }, i = (e) => {
541
+ u(e, l("No data to chart."));
542
+ };
543
+ p(n, (e) => {
544
+ !c(z).dims.length || !c(z).measures.length ? e(r) : e(i, -1);
545
+ }), E(t), u(e, t);
546
+ };
547
+ p(Wt, (e) => {
548
+ c(R) && (c(R).series.length || c(F)) ? e(Gt) : e(Kt, -1);
549
+ }), E($), te($, (e) => g(rt, e), () => c(rt));
550
+ var qt = T($, 2), Jt = (e) => {
551
+ var t = Le();
552
+ i("pointerdown", t, Ge), u(e, t);
553
+ };
554
+ p(qt, (e) => {
555
+ c(V) && !c(H) && e(Jt);
556
+ }), E(X), te(X, (e) => g(ze, e), () => c(ze)), t(() => {
557
+ ht = k(X, 1, "sv-grid-chart-panel", null, ht, {
558
+ "is-right": c(I) === "right" && !c(V),
559
+ "is-bottom": c(I) === "bottom" && !c(V),
560
+ "is-floating": c(V),
561
+ "is-maximized": c(V) && c(H)
562
+ }), ee(X, c(Ke)), yt = k(Z, 1, "sv-grid-chart-drawer-title", null, yt, { "is-drag-handle": c(V) && !c(H) }), _(Q, "aria-expanded", c(W));
563
+ }), i("pointerdown", Z, We), i("click", Q, () => g(W, !c(W))), i("click", It, () => S().chartPanelOpen = !1), w($, "clientWidth", (e) => g(qe, e)), w($, "clientHeight", (e) => g(Je, e)), A(3, X, () => N, () => ({
564
+ x: !c(V) && c(I) === "right" ? c(B) : 0,
565
+ y: !c(V) && c(I) === "bottom" ? c(B) : 0,
566
+ duration: 180,
567
+ easing: P
568
+ })), u(e, X), v();
569
+ }
570
+ d([
571
+ "pointerdown",
572
+ "click",
573
+ "change"
574
+ ]);
575
+ //#endregion
576
+ export { V as default };
@@ -0,0 +1,50 @@
1
+ import { A as e, G as t, L as n, O as r, Q as i, T as a, X as o, Y as s, et as c, o as l, rt as u, tt as d } from "./client-DOa609yZ.js";
2
+ import { a as f } from "./chart-CSZhFIR9.js";
3
+ import { t as p } from "./SvGridChart-EY7OOxv6.js";
4
+ //#region ../grid/dist/SvGridChartView.svelte
5
+ var m = e("<div class=\"sv-grid-chart-view svelte-9enbu0\"><!></div>");
6
+ function h(e, h) {
7
+ d(h, !0);
8
+ let g = o(0), _ = o(0), v = i(() => {
9
+ let e = f(h.data ?? [], {
10
+ type: h.chart.type ?? "bar",
11
+ category: h.chart.category,
12
+ value: h.chart.value,
13
+ series: h.chart.series,
14
+ reduce: h.chart.reduce,
15
+ stacked: h.chart.stacked,
16
+ stacked100: h.chart.stacked100,
17
+ sort: h.chart.sort,
18
+ topN: h.chart.topN,
19
+ palette: h.chart.palette
20
+ });
21
+ return h.chart.valueFormat && (e.valueFormat = h.chart.valueFormat), e;
22
+ });
23
+ var y = m(), b = t(y), x = (e) => {
24
+ {
25
+ let t = i(() => h.chart.legend ?? !0), r = i(() => h.chart.dataLabels ?? !1);
26
+ p(e, {
27
+ get spec() {
28
+ return n(v);
29
+ },
30
+ get width() {
31
+ return n(g);
32
+ },
33
+ get height() {
34
+ return n(_);
35
+ },
36
+ get legend() {
37
+ return n(t);
38
+ },
39
+ get dataLabels() {
40
+ return n(r);
41
+ }
42
+ });
43
+ }
44
+ };
45
+ a(b, (e) => {
46
+ n(g) > 0 && n(_) > 0 && e(x);
47
+ }), u(y), l(y, "clientWidth", (e) => s(g, e)), l(y, "clientHeight", (e) => s(_, e)), r(e, y), c();
48
+ }
49
+ //#endregion
50
+ export { h as default };