@object-ui/plugin-report 17.3.0 → 17.5.0

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.
package/dist/index.js CHANGED
@@ -1,56 +1,56 @@
1
- import { ComponentRegistry as e, buildDatasetDrillFilter as t, buildDatasetFieldHelpers as n, formatDimensionValue as r, formatMeasure as i, mergeFilters as a, pivotBucketId as o, pivotCellKey as s } from "@object-ui/core";
2
- import * as c from "react";
3
- import l from "react";
4
- import { isSpecReport as u, specReportToPresentation as d } from "@object-ui/types";
5
- import { SchemaRenderer as f, SchemaRendererContext as p } from "@object-ui/react";
6
- import { Badge as m, Button as h, Card as g, CardContent as _, CardDescription as v, CardHeader as y, CardTitle as b, Skeleton as x } from "@object-ui/components";
7
- import { jsx as S, jsxs as C } from "react/jsx-runtime";
8
- import { AlertTriangle as w, Download as T, Loader2 as E, Printer as D, RefreshCw as O, Table2 as k } from "lucide-react";
9
- import { getCellRenderer as A, resolveCellRendererType as j } from "@object-ui/fields";
10
- import { useSafeFieldLabel as M, useSafeTranslate as ee } from "@object-ui/i18n";
1
+ import { ComponentRegistry as e, buildDatasetDrillFilter as t, buildDatasetFieldHelpers as n, formatDimensionValue as r, formatMeasure as i, mergeFilters as a, pivotBucketId as o, pivotCellKey as s, pivotDimensionValue as c, relabelDimensions as l } from "@object-ui/core";
2
+ import * as u from "react";
3
+ import d from "react";
4
+ import { isSpecReport as f, specReportToPresentation as p } from "@object-ui/types";
5
+ import { SchemaRenderer as m, SchemaRendererContext as h, toRenderableSchema as g, useDatasetDimensionLabels as _ } from "@object-ui/react";
6
+ import { Badge as v, Button as y, Card as b, CardContent as x, CardDescription as S, CardHeader as C, CardTitle as w, Skeleton as T } from "@object-ui/components";
7
+ import { jsx as E, jsxs as D } from "react/jsx-runtime";
8
+ import { AlertTriangle as O, Download as k, Loader2 as A, Printer as j, RefreshCw as M, Table2 as N } from "lucide-react";
9
+ import { getCellRenderer as ee, resolveCellRendererType as P } from "@object-ui/fields";
10
+ import { useDisplayLocale as F, useSafeFieldLabel as I, useSafeTranslate as L } from "@object-ui/i18n";
11
11
  //#region src/LegacyReportRenderer.tsx
12
- var N = ({ schema: t }) => {
12
+ var R = ({ schema: t }) => {
13
13
  let { title: n, description: r, data: i, columns: a } = t;
14
14
  t.chart?.type;
15
15
  let o = !!t.chart;
16
- return /* @__PURE__ */ C(g, {
16
+ return /* @__PURE__ */ D(b, {
17
17
  className: `h-full flex flex-col ${t.className || ""}`,
18
- children: [/* @__PURE__ */ C(y, { children: [n && /* @__PURE__ */ S(b, { children: n }), r && /* @__PURE__ */ S(v, { children: r })] }), /* @__PURE__ */ C(_, {
18
+ children: [/* @__PURE__ */ D(C, { children: [n && /* @__PURE__ */ E(w, { children: n }), r && /* @__PURE__ */ E(S, { children: r })] }), /* @__PURE__ */ D(x, {
19
19
  className: "flex-1 overflow-auto space-y-4",
20
20
  children: [o && (() => {
21
21
  let n = t.chart?.type, r = n ? e.get(n) : null;
22
- return r ||= e.get("chart"), r ? /* @__PURE__ */ S("div", {
22
+ return r ||= e.get("chart"), r ? /* @__PURE__ */ E("div", {
23
23
  className: "min-h-[300px] border rounded-lg p-4 bg-background/50",
24
- children: /* @__PURE__ */ S(r, { schema: {
24
+ children: /* @__PURE__ */ E(r, { schema: {
25
25
  ...t.chart,
26
26
  data: t.chart.data || i
27
27
  } })
28
- }) : /* @__PURE__ */ C("div", {
28
+ }) : /* @__PURE__ */ D("div", {
29
29
  className: "min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center",
30
30
  children: ["Unknown component type: ", n || "chart"]
31
31
  });
32
- })(), i && i.length > 0 && /* @__PURE__ */ S("div", {
32
+ })(), i && i.length > 0 && /* @__PURE__ */ E("div", {
33
33
  className: "border rounded-lg",
34
34
  children: (() => {
35
35
  let t = e.get("grid") || e.get("table");
36
- return t ? /* @__PURE__ */ S(t, { schema: {
36
+ return t ? /* @__PURE__ */ E(t, { schema: {
37
37
  type: "grid",
38
38
  rowData: i,
39
39
  columnDefs: a,
40
40
  domLayout: "autoHeight"
41
- } }) : /* @__PURE__ */ S("div", {
41
+ } }) : /* @__PURE__ */ E("div", {
42
42
  className: "overflow-x-auto",
43
- children: /* @__PURE__ */ C("table", {
43
+ children: /* @__PURE__ */ D("table", {
44
44
  className: "w-full text-sm text-left",
45
- children: [/* @__PURE__ */ S("thead", {
45
+ children: [/* @__PURE__ */ E("thead", {
46
46
  className: "text-xs uppercase bg-muted",
47
- children: /* @__PURE__ */ S("tr", { children: a?.map((e) => /* @__PURE__ */ S("th", {
47
+ children: /* @__PURE__ */ E("tr", { children: a?.map((e) => /* @__PURE__ */ E("th", {
48
48
  className: "px-6 py-3",
49
49
  children: e.headerName || e.label || e.field
50
50
  }, e.field)) })
51
- }), /* @__PURE__ */ S("tbody", { children: i.map((e, t) => /* @__PURE__ */ S("tr", {
51
+ }), /* @__PURE__ */ E("tbody", { children: i.map((e, t) => /* @__PURE__ */ E("tr", {
52
52
  className: "bg-background border-b",
53
- children: a?.map((t) => /* @__PURE__ */ S("td", {
53
+ children: a?.map((t) => /* @__PURE__ */ E("td", {
54
54
  className: "px-6 py-4",
55
55
  children: e[t.field]
56
56
  }, t.field))
@@ -64,29 +64,29 @@ var N = ({ schema: t }) => {
64
64
  };
65
65
  //#endregion
66
66
  //#region src/ReportExportEngine.ts
67
- function P(e, t, n) {
67
+ function te(e, t, n) {
68
68
  let r = e.fields || [], i = r.map((e) => e.label || e.name), a = t.map((e) => r.map((t) => {
69
69
  let n = e[t.name];
70
- return n = B(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
70
+ return n = ie(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
71
71
  }));
72
- H([...n?.includeHeaders === !1 ? [] : [i.join(",")], ...a.map((e) => e.join(","))].join("\n"), n?.filename || `${e.title || "report"}.csv`, "text/csv");
72
+ U([...n?.includeHeaders === !1 ? [] : [i.join(",")], ...a.map((e) => e.join(","))].join("\n"), n?.filename || `${e.title || "report"}.csv`, "text/csv");
73
73
  }
74
- function te(e, t, n) {
74
+ function ne(e, t, n) {
75
75
  let r = {
76
76
  title: e.title,
77
77
  description: e.description,
78
78
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
79
79
  data: t
80
80
  };
81
- H(JSON.stringify(r, null, 2), n?.filename || `${e.title || "report"}.json`, "application/json");
81
+ U(JSON.stringify(r, null, 2), n?.filename || `${e.title || "report"}.json`, "application/json");
82
82
  }
83
- function F(e, t, n) {
84
- let r = e.fields || [], i = V(n?.orientation), a = ne(n?.pageSize);
85
- H(`<!DOCTYPE html>
83
+ function z(e, t, n) {
84
+ let r = e.fields || [], i = oe(n?.orientation), a = ae(n?.pageSize);
85
+ U(`<!DOCTYPE html>
86
86
  <html>
87
87
  <head>
88
88
  <meta charset="utf-8">
89
- <title>${z(e.title || "Report")}</title>
89
+ <title>${H(e.title || "Report")}</title>
90
90
  <style>
91
91
  @page { size: ${a} ${i}; margin: 20mm; }
92
92
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
@@ -100,20 +100,20 @@ function F(e, t, n) {
100
100
  </style>
101
101
  </head>
102
102
  <body>
103
- <h1>${z(e.title || "Report")}</h1>
104
- ${e.description ? `<p class="description">${z(e.description)}</p>` : ""}
103
+ <h1>${H(e.title || "Report")}</h1>
104
+ ${e.description ? `<p class="description">${H(e.description)}</p>` : ""}
105
105
  <p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
106
106
  <table>
107
- <thead><tr>${r.map((e) => `<th>${z(e.label || e.name)}</th>`).join("")}</tr></thead>
108
- <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${z(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
107
+ <thead><tr>${r.map((e) => `<th>${H(e.label || e.name)}</th>`).join("")}</tr></thead>
108
+ <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${H(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
109
109
  </table>
110
110
  </body>
111
111
  </html>`, n?.filename || `${e.title || "report"}.html`, "text/html");
112
112
  }
113
- function I(e, t, n) {
114
- let r = e.fields || [], i = V(n?.orientation), a = ne(n?.pageSize), o = window.open("", "_blank");
113
+ function re(e, t, n) {
114
+ let r = e.fields || [], i = oe(n?.orientation), a = ae(n?.pageSize), o = window.open("", "_blank");
115
115
  if (!o) {
116
- F(e, t, {
116
+ z(e, t, {
117
117
  ...n,
118
118
  format: "html",
119
119
  filename: n?.filename?.replace(/\.pdf$/, ".html") || `${e.title || "report"}.html`
@@ -124,7 +124,7 @@ function I(e, t, n) {
124
124
  <html>
125
125
  <head>
126
126
  <meta charset="utf-8">
127
- <title>${z(e.title || "Report")}</title>
127
+ <title>${H(e.title || "Report")}</title>
128
128
  <style>
129
129
  @page { size: ${a} ${i}; margin: 20mm; }
130
130
  @media print { .no-print { display: none; } }
@@ -139,56 +139,56 @@ function I(e, t, n) {
139
139
  </style>
140
140
  </head>
141
141
  <body>
142
- <h1>${z(e.title || "Report")}</h1>
143
- ${e.description ? `<p class="description">${z(e.description)}</p>` : ""}
142
+ <h1>${H(e.title || "Report")}</h1>
143
+ ${e.description ? `<p class="description">${H(e.description)}</p>` : ""}
144
144
  <p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
145
145
  <table>
146
- <thead><tr>${r.map((e) => `<th>${z(e.label || e.name)}</th>`).join("")}</tr></thead>
147
- <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${z(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
146
+ <thead><tr>${r.map((e) => `<th>${H(e.label || e.name)}</th>`).join("")}</tr></thead>
147
+ <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${H(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
148
148
  </table>
149
149
  </body>
150
150
  </html>`), o.document.close(), o.onload = () => {
151
151
  o.print();
152
152
  };
153
153
  }
154
- function L(e, t, n) {
154
+ function B(e, t, n) {
155
155
  let r = e.fields || [], i = r.map((e) => e.label || e.name), a = t.map((e) => r.map((t) => {
156
156
  let n = e[t.name];
157
- return n = B(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n") || n.includes(" ")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
157
+ return n = ie(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n") || n.includes(" ")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
158
158
  }));
159
- H("" + [...n?.includeHeaders === !1 ? [] : [i.join(" ")], ...a.map((e) => e.join(" "))].join("\n"), n?.filename || `${e.title || "report"}.tsv`, "text/tab-separated-values");
159
+ U("" + [...n?.includeHeaders === !1 ? [] : [i.join(" ")], ...a.map((e) => e.join(" "))].join("\n"), n?.filename || `${e.title || "report"}.tsv`, "text/tab-separated-values");
160
160
  }
161
- function R(e, t, n, r) {
161
+ function V(e, t, n, r) {
162
162
  switch (e) {
163
163
  case "csv":
164
- P(t, n, r);
164
+ te(t, n, r);
165
165
  break;
166
166
  case "json":
167
- te(t, n, r);
167
+ ne(t, n, r);
168
168
  break;
169
169
  case "html":
170
- F(t, n, r);
170
+ z(t, n, r);
171
171
  break;
172
172
  case "pdf":
173
- I(t, n, r);
173
+ re(t, n, r);
174
174
  break;
175
175
  case "excel":
176
- L(t, n, r);
176
+ B(t, n, r);
177
177
  break;
178
178
  default: console.warn(`Unsupported export format: ${e}`);
179
179
  }
180
180
  }
181
- function z(e) {
181
+ function H(e) {
182
182
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
183
183
  }
184
- function B(e) {
184
+ function ie(e) {
185
185
  if (typeof e == "string" && e.length > 0) {
186
186
  let t = e.charAt(0);
187
187
  if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `\t${e}`;
188
188
  }
189
189
  return e;
190
190
  }
191
- function ne(e) {
191
+ function ae(e) {
192
192
  return [
193
193
  "A4",
194
194
  "A3",
@@ -196,19 +196,19 @@ function ne(e) {
196
196
  "Legal"
197
197
  ].includes(e || "") ? e : "A4";
198
198
  }
199
- function V(e) {
199
+ function oe(e) {
200
200
  return e === "landscape" ? "landscape" : "portrait";
201
201
  }
202
- function H(e, t, n) {
202
+ function U(e, t, n) {
203
203
  let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
204
204
  a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
205
205
  }
206
206
  //#endregion
207
207
  //#region src/formatValue.ts
208
- function U(e, t) {
208
+ function W(e, t) {
209
209
  if (e == null || e === "") return "";
210
210
  let n = t?.type, r = t?.format;
211
- if (n === "date" || r === "date" || re(e)) return ie(e);
211
+ if (n === "date" || r === "date" || se(e)) return ce(e);
212
212
  if (n === "number" || typeof e == "number") {
213
213
  let t = typeof e == "number" ? e : Number(e);
214
214
  return isNaN(t) ? String(e) : r === "currency" || r === "currency_cny" ? `¥${t.toLocaleString("en-US", {
@@ -224,10 +224,10 @@ function U(e, t) {
224
224
  }
225
225
  return String(e);
226
226
  }
227
- function re(e) {
227
+ function se(e) {
228
228
  return typeof e == "string" && /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e);
229
229
  }
230
- function ie(e) {
230
+ function ce(e) {
231
231
  try {
232
232
  let t = new Date(e);
233
233
  return isNaN(t.getTime()) ? String(e) : `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}-${String(t.getDate()).padStart(2, "0")}`;
@@ -237,7 +237,7 @@ function ie(e) {
237
237
  }
238
238
  //#endregion
239
239
  //#region src/ReportViewer.tsx
240
- function ae(e, t) {
240
+ function le(e, t) {
241
241
  if (!t || t.length === 0 || !e || e.length === 0) return null;
242
242
  let n = t[0], r = n.field, i = /* @__PURE__ */ new Map();
243
243
  for (let t of e) {
@@ -253,7 +253,7 @@ function ae(e, t) {
253
253
  let o = n.sort === "desc" ? -1 : 1;
254
254
  return a.sort((e, t) => e.key.localeCompare(t.key) * o), a;
255
255
  }
256
- function oe(e, t, n) {
256
+ function ue(e, t, n) {
257
257
  if (!e) return 0;
258
258
  let r = e.map((e) => Number(e[t]) || 0);
259
259
  switch (n) {
@@ -266,18 +266,18 @@ function oe(e, t, n) {
266
266
  default: return "";
267
267
  }
268
268
  }
269
- var W = ({ schema: e, onRefresh: t }) => {
270
- let { report: n, data: r, showToolbar: i = !0, allowExport: a = !0, allowPrint: o = !0, loading: s = !1 } = e, c = (e) => {
269
+ var G = ({ schema: e, onRefresh: t }) => {
270
+ let { report: n, data: r, showToolbar: i = !0, allowExport: a = !0, allowPrint: o = !0, loading: s = !1 } = e, c = L(), l = (e) => {
271
271
  if (!n) {
272
272
  console.warn("ReportViewer: Cannot export, no report defined");
273
273
  return;
274
274
  }
275
- R(e, n, r || [], n.exportConfigs?.[e]);
276
- }, u = () => {
275
+ V(e, n, r || [], n.exportConfigs?.[e]);
276
+ }, u = c("common.printDialogHint", "Opens your browser’s print dialog (not a PDF export)"), f = () => {
277
277
  window.print();
278
- }, d = () => {
278
+ }, p = () => {
279
279
  t?.();
280
- }, p = (e, t) => oe(r, e, t), w = (e, t) => {
280
+ }, h = (e, t) => ue(r, e, t), _ = (e, t) => {
281
281
  let r = n?.conditionalFormatting;
282
282
  if (!(!r || !Array.isArray(r))) for (let n of r) {
283
283
  if (n.field !== e) continue;
@@ -302,16 +302,16 @@ var W = ({ schema: e, onRefresh: t }) => {
302
302
  return n.backgroundColor && (e.backgroundColor = n.backgroundColor), n.textColor && (e.color = n.textColor), e;
303
303
  }
304
304
  }
305
- }, E = (e, t) => {
305
+ }, O = (e, t) => {
306
306
  if (e == null || e === "") return "";
307
307
  if (t.renderAs === "badge" && (!t.type || t.type === "string" || t.type === "text")) {
308
308
  let n = t.colorMap?.[String(e)] || "";
309
- return /* @__PURE__ */ S(m, {
309
+ return /* @__PURE__ */ E(v, {
310
310
  className: n,
311
311
  children: String(e)
312
312
  });
313
313
  }
314
- if (t.aggregation) return U(e, t);
314
+ if (t.aggregation) return W(e, t);
315
315
  if (t.type) {
316
316
  let n = { ...t };
317
317
  t.colorMap && !n.options && (n.options = Object.entries(t.colorMap).map(([e, t]) => ({
@@ -319,129 +319,132 @@ var W = ({ schema: e, onRefresh: t }) => {
319
319
  label: e,
320
320
  color: t
321
321
  })));
322
- let r = A(j(n));
323
- return /* @__PURE__ */ S(r, {
322
+ let r = ee(P(n));
323
+ return /* @__PURE__ */ E(r, {
324
324
  value: e,
325
325
  field: n
326
326
  });
327
327
  }
328
- return U(e, t);
328
+ return W(e, t);
329
329
  };
330
- return n ? /* @__PURE__ */ C("div", {
330
+ return n ? /* @__PURE__ */ D("div", {
331
331
  className: "space-y-4",
332
- children: [i && /* @__PURE__ */ C("div", {
332
+ children: [i && /* @__PURE__ */ D("div", {
333
333
  className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border",
334
- children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("h2", {
334
+ children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("h2", {
335
335
  className: "text-lg font-semibold",
336
336
  children: n.title
337
- }), n.description && /* @__PURE__ */ S("p", {
337
+ }), n.description && /* @__PURE__ */ E("p", {
338
338
  className: "text-sm text-muted-foreground",
339
339
  children: n.description
340
- })] }), /* @__PURE__ */ C("div", {
340
+ })] }), /* @__PURE__ */ D("div", {
341
341
  className: "flex items-center gap-2",
342
+ "data-print-hide": !0,
342
343
  children: [
343
- n.refreshInterval && /* @__PURE__ */ C(h, {
344
+ n.refreshInterval && /* @__PURE__ */ D(y, {
344
345
  variant: "outline",
345
346
  size: "sm",
346
- onClick: d,
347
- children: [/* @__PURE__ */ S(O, { className: "h-4 w-4 mr-2" }), "Refresh"]
347
+ onClick: p,
348
+ children: [/* @__PURE__ */ E(M, { className: "h-4 w-4 mr-2" }), "Refresh"]
348
349
  }),
349
- o && /* @__PURE__ */ C(h, {
350
+ o && /* @__PURE__ */ D(y, {
350
351
  variant: "outline",
351
352
  size: "sm",
352
- onClick: u,
353
- children: [/* @__PURE__ */ S(D, { className: "h-4 w-4 mr-2" }), "Print"]
353
+ onClick: f,
354
+ "aria-label": `Print: ${u}`,
355
+ title: u,
356
+ children: [/* @__PURE__ */ E(j, { className: "h-4 w-4 mr-2" }), "Print"]
354
357
  }),
355
- a && n.showExportButtons && /* @__PURE__ */ C("div", {
358
+ a && n.showExportButtons && /* @__PURE__ */ D("div", {
356
359
  className: "flex items-center gap-1",
357
360
  children: [
358
- /* @__PURE__ */ C(h, {
361
+ /* @__PURE__ */ D(y, {
359
362
  variant: "outline",
360
363
  size: "sm",
361
- onClick: () => c("pdf"),
362
- children: [/* @__PURE__ */ S(T, { className: "h-4 w-4 mr-2" }), "PDF"]
364
+ onClick: () => l("pdf"),
365
+ children: [/* @__PURE__ */ E(k, { className: "h-4 w-4 mr-2" }), "PDF"]
363
366
  }),
364
- /* @__PURE__ */ C(h, {
367
+ /* @__PURE__ */ D(y, {
365
368
  variant: "outline",
366
369
  size: "sm",
367
- onClick: () => c("excel"),
368
- children: [/* @__PURE__ */ S(T, { className: "h-4 w-4 mr-2" }), "Excel"]
370
+ onClick: () => l("excel"),
371
+ children: [/* @__PURE__ */ E(k, { className: "h-4 w-4 mr-2" }), "Excel"]
369
372
  }),
370
- /* @__PURE__ */ C(h, {
373
+ /* @__PURE__ */ D(y, {
371
374
  variant: "outline",
372
375
  size: "sm",
373
- onClick: () => c("csv"),
374
- children: [/* @__PURE__ */ S(T, { className: "h-4 w-4 mr-2" }), "CSV"]
376
+ onClick: () => l("csv"),
377
+ children: [/* @__PURE__ */ E(k, { className: "h-4 w-4 mr-2" }), "CSV"]
375
378
  })
376
379
  ]
377
380
  })
378
381
  ]
379
382
  })]
380
- }), /* @__PURE__ */ C(g, { children: [/* @__PURE__ */ C(y, { children: [!i && n.title && /* @__PURE__ */ S(b, { children: n.title }), !i && n.description && /* @__PURE__ */ S(v, { children: n.description })] }), /* @__PURE__ */ C(_, {
383
+ }), /* @__PURE__ */ D(b, { children: [/* @__PURE__ */ D(C, { children: [!i && n.title && /* @__PURE__ */ E(w, { children: n.title }), !i && n.description && /* @__PURE__ */ E(S, { children: n.description })] }), /* @__PURE__ */ D(x, {
381
384
  className: "space-y-6",
382
385
  children: [
383
- s && /* @__PURE__ */ C("div", {
386
+ s && /* @__PURE__ */ D("div", {
384
387
  className: "space-y-6",
385
- children: [/* @__PURE__ */ S("div", {
388
+ children: [/* @__PURE__ */ E("div", {
386
389
  className: "grid grid-cols-1 md:grid-cols-3 gap-4",
387
390
  children: [
388
391
  1,
389
392
  2,
390
393
  3
391
- ].map((e) => /* @__PURE__ */ S(g, { children: /* @__PURE__ */ C(_, {
394
+ ].map((e) => /* @__PURE__ */ E(b, { children: /* @__PURE__ */ D(x, {
392
395
  className: "p-4 space-y-2",
393
- children: [/* @__PURE__ */ S(x, { className: "h-4 w-20" }), /* @__PURE__ */ S(x, { className: "h-8 w-28" })]
396
+ children: [/* @__PURE__ */ E(T, { className: "h-4 w-20" }), /* @__PURE__ */ E(T, { className: "h-8 w-28" })]
394
397
  }) }, e))
395
- }), /* @__PURE__ */ C("div", {
398
+ }), /* @__PURE__ */ D("div", {
396
399
  className: "space-y-2",
397
- children: [/* @__PURE__ */ S(x, { className: "h-10 w-full" }), [
400
+ children: [/* @__PURE__ */ E(T, { className: "h-10 w-full" }), [
398
401
  1,
399
402
  2,
400
403
  3,
401
404
  4,
402
405
  5
403
- ].map((e) => /* @__PURE__ */ S(x, { className: "h-8 w-full" }, e))]
406
+ ].map((e) => /* @__PURE__ */ E(T, { className: "h-8 w-full" }, e))]
404
407
  })]
405
408
  }),
406
- !s && n.sections?.map((e, t) => e.visible === !1 ? null : /* @__PURE__ */ C("div", {
409
+ !s && n.sections?.map((e, t) => e.visible === !1 ? null : /* @__PURE__ */ D("div", {
407
410
  className: "space-y-2",
408
411
  children: [
409
- e.title && e.type !== "header" && /* @__PURE__ */ S("h3", {
412
+ e.title && e.type !== "header" && /* @__PURE__ */ E("h3", {
410
413
  className: "text-lg font-semibold border-b pb-2",
411
414
  children: e.title
412
415
  }),
413
- e.type === "header" && e.title && /* @__PURE__ */ S("div", {
416
+ e.type === "header" && e.title && /* @__PURE__ */ E("div", {
414
417
  className: "text-2xl font-bold py-4",
415
418
  children: e.title
416
419
  }),
417
- e.type === "summary" && /* @__PURE__ */ S("div", {
420
+ e.type === "summary" && /* @__PURE__ */ E("div", {
418
421
  className: "grid grid-cols-1 md:grid-cols-3 gap-4",
419
- children: n.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */ S(g, { children: /* @__PURE__ */ C(_, {
422
+ children: n.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */ E(b, { children: /* @__PURE__ */ D(x, {
420
423
  className: "p-4",
421
- children: [/* @__PURE__ */ S("div", {
424
+ children: [/* @__PURE__ */ E("div", {
422
425
  className: "text-sm text-muted-foreground",
423
426
  children: e.label || e.name
424
- }), /* @__PURE__ */ S("div", {
427
+ }), /* @__PURE__ */ E("div", {
425
428
  className: "text-2xl font-bold",
426
- children: U(p(e.name, e.aggregation), e)
429
+ children: W(h(e.name, e.aggregation), e)
427
430
  })]
428
431
  }) }, t))
429
432
  }),
430
- e.type === "table" && /* @__PURE__ */ S("div", {
433
+ e.type === "table" && /* @__PURE__ */ E("div", {
431
434
  className: "border rounded-lg overflow-x-auto",
432
- children: /* @__PURE__ */ C("table", {
435
+ children: /* @__PURE__ */ D("table", {
433
436
  className: "w-full text-sm min-w-[600px]",
434
- children: [/* @__PURE__ */ S("thead", {
437
+ children: [/* @__PURE__ */ E("thead", {
435
438
  className: "bg-muted",
436
- children: /* @__PURE__ */ S("tr", { children: e.columns?.map((e, t) => /* @__PURE__ */ S("th", {
439
+ children: /* @__PURE__ */ E("tr", { children: e.columns?.map((e, t) => /* @__PURE__ */ E("th", {
437
440
  className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
438
441
  children: e.label || e.name
439
442
  }, t)) })
440
- }), /* @__PURE__ */ S("tbody", { children: (() => {
441
- let t = ae(r || [], n.groupBy || []);
442
- return t ? t.map((t) => /* @__PURE__ */ C(l.Fragment, { children: [/* @__PURE__ */ S("tr", {
443
+ }), /* @__PURE__ */ E("tbody", { children: (() => {
444
+ let t = le(r || [], n.groupBy || []);
445
+ return t ? t.map((t) => /* @__PURE__ */ D(d.Fragment, { children: [/* @__PURE__ */ E("tr", {
443
446
  className: "bg-muted/60",
444
- children: /* @__PURE__ */ C("td", {
447
+ children: /* @__PURE__ */ D("td", {
445
448
  colSpan: e.columns?.length || 1,
446
449
  className: "px-4 py-2 font-semibold text-sm",
447
450
  children: [
@@ -451,73 +454,73 @@ var W = ({ schema: e, onRefresh: t }) => {
451
454
  ")"
452
455
  ]
453
456
  })
454
- }), t.rows.map((t, n) => /* @__PURE__ */ S("tr", {
457
+ }), t.rows.map((t, n) => /* @__PURE__ */ E("tr", {
455
458
  className: "border-t hover:bg-muted/50 even:bg-muted/20",
456
- children: e.columns?.map((e, n) => /* @__PURE__ */ S("td", {
459
+ children: e.columns?.map((e, n) => /* @__PURE__ */ E("td", {
457
460
  className: `px-4 py-2 ${e.type === "number" ? "text-right tabular-nums" : ""}`,
458
- style: w(e.name, t[e.name]),
459
- children: E(t[e.name], e)
461
+ style: _(e.name, t[e.name]),
462
+ children: O(t[e.name], e)
460
463
  }, n))
461
- }, n))] }, t.key)) : r?.map((t, n) => /* @__PURE__ */ S("tr", {
464
+ }, n))] }, t.key)) : r?.map((t, n) => /* @__PURE__ */ E("tr", {
462
465
  className: "border-t hover:bg-muted/50 even:bg-muted/20",
463
- children: e.columns?.map((e, n) => /* @__PURE__ */ S("td", {
466
+ children: e.columns?.map((e, n) => /* @__PURE__ */ E("td", {
464
467
  className: `px-4 py-2 ${e.type === "number" ? "text-right tabular-nums" : ""}`,
465
- style: w(e.name, t[e.name]),
466
- children: E(t[e.name], e)
468
+ style: _(e.name, t[e.name]),
469
+ children: O(t[e.name], e)
467
470
  }, n))
468
471
  }, n));
469
472
  })() })]
470
473
  })
471
474
  }),
472
- e.type === "text" && e.text && /* @__PURE__ */ S("div", {
475
+ e.type === "text" && e.text && /* @__PURE__ */ E("div", {
473
476
  className: "prose max-w-none",
474
- children: /* @__PURE__ */ S("p", { children: e.text })
477
+ children: /* @__PURE__ */ E("p", { children: e.text })
475
478
  }),
476
- e.type === "page-break" && /* @__PURE__ */ S("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
477
- e.content && /* @__PURE__ */ S(f, { schema: e.content })
479
+ e.type === "page-break" && /* @__PURE__ */ E("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
480
+ Array.isArray(e.content) ? e.content.map((e, t) => /* @__PURE__ */ E(m, { schema: g(e) }, t)) : e.content && /* @__PURE__ */ E(m, { schema: g(e.content) })
478
481
  ]
479
482
  }, t)),
480
- !n.sections && r && r.length > 0 && /* @__PURE__ */ S("div", {
483
+ !n.sections && r && r.length > 0 && /* @__PURE__ */ E("div", {
481
484
  className: "border rounded-lg overflow-x-auto",
482
- children: /* @__PURE__ */ C("table", {
485
+ children: /* @__PURE__ */ D("table", {
483
486
  className: "w-full text-sm min-w-[600px]",
484
- children: [/* @__PURE__ */ S("thead", {
487
+ children: [/* @__PURE__ */ E("thead", {
485
488
  className: "bg-muted",
486
- children: /* @__PURE__ */ S("tr", { children: n.fields?.map((e, t) => /* @__PURE__ */ S("th", {
489
+ children: /* @__PURE__ */ E("tr", { children: n.fields?.map((e, t) => /* @__PURE__ */ E("th", {
487
490
  className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
488
491
  children: e.label || e.name
489
492
  }, t)) })
490
- }), /* @__PURE__ */ S("tbody", { children: r.map((e, t) => /* @__PURE__ */ S("tr", {
493
+ }), /* @__PURE__ */ E("tbody", { children: r.map((e, t) => /* @__PURE__ */ E("tr", {
491
494
  className: "border-t hover:bg-muted/50 even:bg-muted/20",
492
- children: n.fields?.map((t, n) => /* @__PURE__ */ S("td", {
495
+ children: n.fields?.map((t, n) => /* @__PURE__ */ E("td", {
493
496
  className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
494
- style: w(t.name, e[t.name]),
495
- children: E(e[t.name], t)
497
+ style: _(t.name, e[t.name]),
498
+ children: O(e[t.name], t)
496
499
  }, n))
497
500
  }, t)) })]
498
501
  })
499
502
  })
500
503
  ]
501
504
  })] })]
502
- }) : /* @__PURE__ */ S(g, { children: /* @__PURE__ */ S(_, {
505
+ }) : /* @__PURE__ */ E(b, { children: /* @__PURE__ */ E(x, {
503
506
  className: "p-8 text-center text-muted-foreground",
504
507
  children: "No report to display"
505
508
  }) });
506
509
  };
507
510
  //#endregion
508
511
  //#region src/DatasetReportRenderer.tsx
509
- function G(e) {
512
+ function K(e) {
510
513
  if (!e || typeof e != "object") return !1;
511
514
  let t = e;
512
515
  return typeof t.dataset == "string" && t.dataset.length > 0 || t.type === "joined" && Array.isArray(t.blocks) && t.blocks.some((e) => typeof e?.dataset == "string");
513
516
  }
514
- function K(e, t) {
517
+ function de(e, t) {
515
518
  return e ? typeof e == "string" ? e : typeof e == "object" && typeof e.default == "string" ? e.default : t : t;
516
519
  }
517
520
  function q(e) {
518
521
  return Array.isArray(e) ? e.filter((e) => typeof e == "string" && !!e) : [];
519
522
  }
520
- function J(e) {
523
+ function fe(e) {
521
524
  if (!Array.isArray(e)) return;
522
525
  let t = {};
523
526
  for (let n of e) {
@@ -526,21 +529,21 @@ function J(e) {
526
529
  }
527
530
  return Object.keys(t).length > 0 ? t : void 0;
528
531
  }
529
- function se(e, t, n) {
532
+ function pe(e, t, n) {
530
533
  if (!e) return;
531
534
  let r = /* @__PURE__ */ new Set([...t, ...n]), i = {};
532
535
  for (let [t, n] of Object.entries(e)) r.has(t) && (i[t] = n);
533
536
  return Object.keys(i).length > 0 ? i : void 0;
534
537
  }
535
- function Y(e, t, n, r, i, a, o) {
536
- let [s, l] = c.useState({
538
+ function J(e, t, n, r, i, a, o) {
539
+ let [s, c] = u.useState({
537
540
  status: "idle",
538
541
  rows: []
539
- }), u = se(o, t, n), d = JSON.stringify(r ?? null), f = JSON.stringify(a ?? null), p = JSON.stringify(u ?? null), m = `${e}|${t.join(",")}|${n.join(",")}|${d}|${f}|${p}`;
540
- return c.useEffect(() => {
542
+ }), l = pe(o, t, n), d = JSON.stringify(r ?? null), f = JSON.stringify(a ?? null), p = JSON.stringify(l ?? null), m = `${e}|${t.join(",")}|${n.join(",")}|${d}|${f}|${p}`;
543
+ return u.useEffect(() => {
541
544
  let o = i;
542
545
  if (!o || typeof o.queryDataset != "function") {
543
- l({
546
+ c({
544
547
  status: "error",
545
548
  rows: [],
546
549
  error: "This data source does not support dataset queries."
@@ -548,14 +551,14 @@ function Y(e, t, n, r, i, a, o) {
548
551
  return;
549
552
  }
550
553
  if (!e || n.length === 0) {
551
- l({
554
+ c({
552
555
  status: "idle",
553
556
  rows: []
554
557
  });
555
558
  return;
556
559
  }
557
560
  let s = !1;
558
- return l({
561
+ return c({
559
562
  status: "loading",
560
563
  rows: []
561
564
  }), o.queryDataset(e, {
@@ -563,9 +566,9 @@ function Y(e, t, n, r, i, a, o) {
563
566
  measures: n,
564
567
  ...r && Object.keys(r).length > 0 ? { runtimeFilter: r } : {},
565
568
  ...a ? { totals: { groupings: a } } : {},
566
- ...u ? { order: u } : {}
569
+ ...l ? { order: l } : {}
567
570
  }).then((e) => {
568
- s || l({
571
+ s || c({
569
572
  status: "ok",
570
573
  rows: Array.isArray(e?.rows) ? e.rows : [],
571
574
  fields: Array.isArray(e?.fields) ? e.fields : [],
@@ -576,7 +579,7 @@ function Y(e, t, n, r, i, a, o) {
576
579
  totals: Array.isArray(e?.totals) ? e.totals : void 0
577
580
  });
578
581
  }).catch((e) => {
579
- s || l({
582
+ s || c({
580
583
  status: "error",
581
584
  rows: [],
582
585
  error: String(e?.message ?? e)
@@ -586,8 +589,8 @@ function Y(e, t, n, r, i, a, o) {
586
589
  };
587
590
  }, [m]), s;
588
591
  }
589
- function X({ dataset: e }) {
590
- return /* @__PURE__ */ C("div", {
592
+ function me({ dataset: e }) {
593
+ return /* @__PURE__ */ D("div", {
591
594
  className: "flex items-center justify-center rounded-md border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
592
595
  children: [
593
596
  "This report binds the “",
@@ -596,81 +599,81 @@ function X({ dataset: e }) {
596
599
  ]
597
600
  });
598
601
  }
599
- function Z({ status: e, error: t }) {
600
- return e === "error" ? /* @__PURE__ */ C("div", {
602
+ function Y({ status: e, error: t }) {
603
+ return e === "error" ? /* @__PURE__ */ D("div", {
601
604
  role: "alert",
602
605
  className: "flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",
603
- children: [/* @__PURE__ */ S(w, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ S("span", {
606
+ children: [/* @__PURE__ */ E(O, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ E("span", {
604
607
  className: "break-words",
605
608
  children: t
606
609
  })]
607
- }) : /* @__PURE__ */ C("div", {
610
+ }) : /* @__PURE__ */ D("div", {
608
611
  className: "flex items-center gap-2 p-4 text-xs text-muted-foreground",
609
- children: [/* @__PURE__ */ S(E, { className: "h-4 w-4 animate-spin" }), " Running report…"]
612
+ children: [/* @__PURE__ */ E(A, { className: "h-4 w-4 animate-spin" }), " Running report…"]
610
613
  });
611
614
  }
612
- function ce() {
613
- return /* @__PURE__ */ C("div", {
615
+ function he() {
616
+ return /* @__PURE__ */ D("div", {
614
617
  className: "flex flex-col items-center justify-center gap-2 rounded-md border border-dashed bg-muted/20 p-6 text-xs text-muted-foreground",
615
- children: [/* @__PURE__ */ S(k, { className: "h-6 w-6" }), " The dataset returned no rows for this report’s scope."]
618
+ children: [/* @__PURE__ */ E(N, { className: "h-6 w-6" }), " The dataset returned no rows for this report’s scope."]
616
619
  });
617
620
  }
618
- var le = "cursor-pointer hover:bg-accent/40";
619
- function ue({ dataset: e, rows: a, values: o, runtimeFilter: s, dataSource: c, onDrill: l, order: u, withTotals: d }) {
620
- let f = Y(e, a, o, s, c, d && a.length > 0 ? [[]] : void 0, u), { fieldLabel: p } = M(), m = ee();
621
- if (o.length === 0) return /* @__PURE__ */ S(X, { dataset: e });
622
- if (f.status === "loading" || f.status === "idle") return /* @__PURE__ */ S(Z, { status: f.status });
623
- if (f.status === "error") return /* @__PURE__ */ S(Z, {
621
+ var ge = "cursor-pointer hover:bg-accent/40";
622
+ function _e({ dataset: e, rows: a, values: o, runtimeFilter: s, dataSource: c, onDrill: u, order: d, withTotals: f }) {
623
+ let p = J(e, a, o, s, c, f && a.length > 0 ? [[]] : void 0, d), { fieldLabel: m } = I(), h = L(), g = F(), v = _(p.object, p.dimensionFields, a);
624
+ if (o.length === 0) return /* @__PURE__ */ E(me, { dataset: e });
625
+ if (p.status === "loading" || p.status === "idle") return /* @__PURE__ */ E(Y, { status: p.status });
626
+ if (p.status === "error") return /* @__PURE__ */ E(Y, {
624
627
  status: "error",
625
- error: f.error
628
+ error: p.error
626
629
  });
627
- if (f.rows.length === 0) return /* @__PURE__ */ S(ce, {});
628
- let h = !!l && a.length > 0, g = f.dimensionFields ? a.filter((e) => e in f.dimensionFields) : [], _ = (n, r) => {
630
+ if (p.rows.length === 0) return /* @__PURE__ */ E(he, {});
631
+ let y = !!u && a.length > 0, b = p.dimensionFields ? a.filter((e) => e in p.dimensionFields) : [], x = (n, r) => {
629
632
  let i = {};
630
633
  for (let e of a) i[e] = n[e];
631
- let o = f.drillRanges?.[r], c = !!o && Object.keys(o).length > 0, u = f.object && (g.length > 0 || c) ? t(f.drillRawRows?.[r], g, f.dimensionFields ?? {}, s, o) : void 0;
632
- l({
634
+ let o = p.drillRanges?.[r], c = !!o && Object.keys(o).length > 0, l = p.object && (b.length > 0 || c) ? t(p.drillRawRows?.[r], b, p.dimensionFields ?? {}, s, o) : void 0;
635
+ u({
633
636
  dataset: e,
634
637
  groupKey: i,
635
638
  runtimeFilter: s,
636
- object: f.object,
637
- objectFilter: u
639
+ object: p.object,
640
+ objectFilter: l
638
641
  });
639
- }, { measureField: v, headerLabel: y } = n(f.fields, f.object, p), b = [...a, ...o], x = d ? f.totals?.find((e) => Array.isArray(e.dimensions) && e.dimensions.length === 0)?.rows?.[0] : void 0, w = m("report.total", "Total");
640
- return /* @__PURE__ */ S("div", {
642
+ }, { measureField: S, headerLabel: C } = n(p.fields, p.object, m), w = [...a, ...o], T = l(p.rows, v), O = f ? p.totals?.find((e) => Array.isArray(e.dimensions) && e.dimensions.length === 0)?.rows?.[0] : void 0, k = h("report.total", "Total");
643
+ return /* @__PURE__ */ E("div", {
641
644
  className: "overflow-auto max-h-[70vh] rounded-md border",
642
- children: /* @__PURE__ */ C("table", {
645
+ children: /* @__PURE__ */ D("table", {
643
646
  className: "w-full text-xs",
644
- children: [/* @__PURE__ */ S("thead", {
647
+ children: [/* @__PURE__ */ E("thead", {
645
648
  className: "bg-muted/40",
646
- children: /* @__PURE__ */ S("tr", { children: b.map((e) => /* @__PURE__ */ S("th", {
649
+ children: /* @__PURE__ */ E("tr", { children: w.map((e) => /* @__PURE__ */ E("th", {
647
650
  className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
648
- children: y(e)
651
+ children: C(e)
649
652
  }, e)) })
650
- }), /* @__PURE__ */ C("tbody", { children: [f.rows.map((e, t) => /* @__PURE__ */ S("tr", {
651
- className: `border-t${h ? ` ${le}` : ""}`,
652
- "data-testid": h ? "dataset-drill-row" : void 0,
653
- onClick: h ? () => _(e, t) : void 0,
654
- children: b.map((t) => /* @__PURE__ */ S("td", {
653
+ }), /* @__PURE__ */ D("tbody", { children: [T.map((e, t) => /* @__PURE__ */ E("tr", {
654
+ className: `border-t${y ? ` ${ge}` : ""}`,
655
+ "data-testid": y ? "dataset-drill-row" : void 0,
656
+ onClick: y ? () => x(p.rows[t], t) : void 0,
657
+ children: w.map((t) => /* @__PURE__ */ E("td", {
655
658
  className: "px-2 py-1 tabular-nums whitespace-nowrap",
656
- children: o.includes(t) ? i(e[t], v(t)?.format, v(t)?.currency, v(t)?.percentScale) : r(e[t])
659
+ children: o.includes(t) ? i(e[t], S(t)?.format, S(t)?.currency, S(t)?.percentScale, g) : r(e[t], g)
657
660
  }, t))
658
- }, t)), x && /* @__PURE__ */ C("tr", {
661
+ }, t)), O && /* @__PURE__ */ D("tr", {
659
662
  className: "border-t bg-muted/30 font-medium",
660
663
  "data-testid": "dataset-report-total-row",
661
- children: [a.length > 0 && /* @__PURE__ */ S("td", {
664
+ children: [a.length > 0 && /* @__PURE__ */ E("td", {
662
665
  colSpan: a.length,
663
666
  className: "px-2 py-1 whitespace-nowrap",
664
- children: w
665
- }), o.map((e) => /* @__PURE__ */ S("td", {
667
+ children: k
668
+ }), o.map((e) => /* @__PURE__ */ E("td", {
666
669
  className: "px-2 py-1 tabular-nums whitespace-nowrap",
667
- children: i(x[e], v(e)?.format, v(e)?.currency, v(e)?.percentScale)
670
+ children: i(O[e], S(e)?.format, S(e)?.currency, S(e)?.percentScale, g)
668
671
  }, e))]
669
672
  })] })]
670
673
  })
671
674
  });
672
675
  }
673
- function de(e) {
676
+ function ve(e) {
674
677
  switch (e) {
675
678
  case "summary": return "summary";
676
679
  case "matrix": return "matrix";
@@ -678,7 +681,7 @@ function de(e) {
678
681
  default: return "tabular";
679
682
  }
680
683
  }
681
- function fe(e) {
684
+ function ye(e) {
682
685
  switch (e) {
683
686
  case "bar":
684
687
  case "column":
@@ -709,9 +712,9 @@ function fe(e) {
709
712
  };
710
713
  }
711
714
  }
712
- function pe(t) {
713
- let [, n] = c.useReducer((e) => e + 1, 0);
714
- return c.useEffect(() => {
715
+ function be(t) {
716
+ let [, n] = u.useReducer((e) => e + 1, 0);
717
+ return u.useEffect(() => {
715
718
  if (e.get(t)) return;
716
719
  let r = typeof e.subscribe == "function" ? e.subscribe(() => {
717
720
  e.get(t) && n();
@@ -719,53 +722,53 @@ function pe(t) {
719
722
  return i && typeof i.then == "function" && i.then(() => n()).catch(() => {}), r;
720
723
  }, [t]), e.get(t);
721
724
  }
722
- function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o }) {
723
- let s = typeof t.xAxis == "string" ? t.xAxis : "", c = typeof t.yAxis == "string" ? t.yAxis : "", l = fe(t.type), u = l.kind === "series" || l.kind === "single_value", d = Y(e, l.kind === "series" && s ? [s] : [], u && c ? [c] : [], r, a, void 0, o), f = pe("chart"), { fieldLabel: p } = M(), m = typeof t.title == "string" ? t.title : void 0;
724
- if (l.kind === "tabular") return null;
725
- if (l.kind === "unsupported") return /* @__PURE__ */ C("div", {
725
+ function xe({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o }) {
726
+ let s = typeof t.xAxis == "string" ? t.xAxis : "", c = typeof t.yAxis == "string" ? t.yAxis : "", d = ye(t.type), f = d.kind === "series" || d.kind === "single_value", p = J(e, d.kind === "series" && s ? [s] : [], f && c ? [c] : [], r, a, void 0, o), m = be("chart"), { fieldLabel: h } = I(), g = F(), v = u.useMemo(() => s ? [s] : [], [s]), y = _(p.object, p.dimensionFields, v), b = typeof t.title == "string" ? t.title : void 0;
727
+ if (d.kind === "tabular") return null;
728
+ if (d.kind === "unsupported") return /* @__PURE__ */ D("div", {
726
729
  className: "rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground",
727
730
  "data-testid": "dataset-report-chart-unsupported",
728
731
  children: [
729
732
  "Chart type “",
730
- l.type,
733
+ d.type,
731
734
  "” is not a spec chart type — the grouped table below carries this report’s numbers."
732
735
  ]
733
736
  });
734
- if (l.kind === "series" && !s || !c) return null;
735
- if (d.status === "loading" || d.status === "idle") return /* @__PURE__ */ C("div", {
737
+ if (d.kind === "series" && !s || !c) return null;
738
+ if (p.status === "loading" || p.status === "idle") return /* @__PURE__ */ D("div", {
736
739
  className: "flex items-center gap-2 p-4 text-xs text-muted-foreground",
737
- children: [/* @__PURE__ */ S(E, { className: "h-4 w-4 animate-spin" }), " Loading chart…"]
740
+ children: [/* @__PURE__ */ E(A, { className: "h-4 w-4 animate-spin" }), " Loading chart…"]
738
741
  });
739
- if (d.status === "error" || d.rows.length === 0) return null;
740
- if (l.kind === "single_value") {
741
- let { measureField: e, headerLabel: t } = n(d.fields, d.object, p), r = e(c);
742
- return /* @__PURE__ */ C("div", {
742
+ if (p.status === "error" || p.rows.length === 0) return null;
743
+ if (d.kind === "single_value") {
744
+ let { measureField: e, headerLabel: t } = n(p.fields, p.object, h), r = e(c);
745
+ return /* @__PURE__ */ D("div", {
743
746
  className: "rounded-md border bg-card p-3",
744
747
  "data-testid": "dataset-report-metric",
745
- children: [m ? /* @__PURE__ */ S("h3", {
748
+ children: [b ? /* @__PURE__ */ E("h3", {
746
749
  className: "mb-2 text-sm font-semibold",
747
- children: m
748
- }) : null, /* @__PURE__ */ C("div", {
750
+ children: b
751
+ }) : null, /* @__PURE__ */ D("div", {
749
752
  className: "flex flex-col gap-0.5 py-2",
750
- children: [/* @__PURE__ */ S("span", {
753
+ children: [/* @__PURE__ */ E("span", {
751
754
  className: "text-2xl font-semibold tabular-nums",
752
- children: i(d.rows[0]?.[c], r?.format, r?.currency, r?.percentScale)
753
- }), /* @__PURE__ */ S("span", {
755
+ children: i(p.rows[0]?.[c], r?.format, r?.currency, r?.percentScale, g)
756
+ }), /* @__PURE__ */ E("span", {
754
757
  className: "text-xs text-muted-foreground",
755
758
  children: t(c)
756
759
  })]
757
760
  })]
758
761
  });
759
762
  }
760
- return f ? /* @__PURE__ */ C("div", {
763
+ return m ? /* @__PURE__ */ D("div", {
761
764
  className: "rounded-md border bg-card p-3",
762
765
  "data-testid": "dataset-report-chart",
763
- children: [m ? /* @__PURE__ */ S("h3", {
766
+ children: [b ? /* @__PURE__ */ E("h3", {
764
767
  className: "mb-2 text-sm font-semibold",
765
- children: m
766
- }) : null, /* @__PURE__ */ S(f, { schema: {
767
- chartType: l.chartType,
768
- data: d.rows,
768
+ children: b
769
+ }) : null, /* @__PURE__ */ E(m, { schema: {
770
+ chartType: d.chartType,
771
+ data: l(p.rows, y),
769
772
  xAxisKey: s,
770
773
  series: [{ dataKey: c }],
771
774
  height: typeof t.height == "number" ? t.height : 280,
@@ -773,44 +776,46 @@ function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o })
773
776
  } })]
774
777
  }) : null;
775
778
  }
776
- function Q(e, t) {
777
- return o(e.map((e) => String(t[e] ?? "∅")));
779
+ function X(e, t) {
780
+ return o(e.map((e) => c(t[e])));
778
781
  }
779
- function he(e, t) {
780
- return e.map((e) => r(t[e])).join(" / ");
782
+ function Se(e, t, n) {
783
+ return e.map((e) => r(t[e], n)).join(" / ");
781
784
  }
782
- function ge({ dataset: e, rows: a, columnsAcross: o, values: l, runtimeFilter: u, dataSource: d, onDrill: f, order: p }) {
783
- let m = Y(e, [...a, ...o], l, u, d, [
785
+ function Z({ dataset: e, rows: a, columnsAcross: o, values: c, runtimeFilter: d, dataSource: f, onDrill: p, order: m }) {
786
+ let h = J(e, [...a, ...o], c, d, f, [
784
787
  a,
785
788
  o,
786
789
  []
787
- ], p), h = ee(), { fieldLabel: g } = M(), _ = c.useMemo(() => {
788
- if (m.status !== "ok") return null;
790
+ ], m), g = L(), { fieldLabel: v } = I(), y = F(), b = _(h.object, h.dimensionFields, [...a, ...o]), x = u.useMemo(() => {
791
+ if (h.status !== "ok") return null;
789
792
  let e = [], t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
790
- return m.rows.forEach((c, l) => {
791
- let u = Q(a, c), d = Q(o, c);
792
- if (!n.has(u)) {
793
- n.add(u);
794
- let t = {};
795
- for (let e of a) t[e] = c[e];
793
+ return l(h.rows, b).forEach((c, l) => {
794
+ let u = h.rows[l], d = X(a, c), f = X(o, c);
795
+ if (!n.has(d)) {
796
+ n.add(d);
797
+ let t = {}, r = {};
798
+ for (let e of a) t[e] = u[e], r[e] = c[e];
796
799
  e.push({
797
- id: u,
798
- label: he(a, c),
799
- key: t
800
+ id: d,
801
+ label: Se(a, c, y),
802
+ key: t,
803
+ display: r
800
804
  });
801
805
  }
802
- if (!r.has(d)) {
803
- r.add(d);
804
- let e = {};
805
- for (let t of o) e[t] = c[t];
806
+ if (!r.has(f)) {
807
+ r.add(f);
808
+ let e = {}, n = {};
809
+ for (let t of o) e[t] = u[t], n[t] = c[t];
806
810
  t.push({
807
- id: d,
808
- label: he(o, c),
809
- key: e
811
+ id: f,
812
+ label: Se(o, c, y),
813
+ key: e,
814
+ display: n
810
815
  });
811
816
  }
812
- i.set(s(u, d), {
813
- row: c,
817
+ i.set(s(d, f), {
818
+ row: u,
814
819
  index: l
815
820
  });
816
821
  }), {
@@ -819,108 +824,113 @@ function ge({ dataset: e, rows: a, columnsAcross: o, values: l, runtimeFilter: u
819
824
  cells: i
820
825
  };
821
826
  }, [
822
- m,
827
+ h,
823
828
  a,
824
- o
829
+ o,
830
+ b,
831
+ y
825
832
  ]);
826
- if (l.length === 0) return /* @__PURE__ */ S(X, { dataset: e });
827
- if (m.status === "loading" || m.status === "idle") return /* @__PURE__ */ S(Z, { status: m.status });
828
- if (m.status === "error") return /* @__PURE__ */ S(Z, {
833
+ if (c.length === 0) return /* @__PURE__ */ E(me, { dataset: e });
834
+ if (h.status === "loading" || h.status === "idle") return /* @__PURE__ */ E(Y, { status: h.status });
835
+ if (h.status === "error") return /* @__PURE__ */ E(Y, {
829
836
  status: "error",
830
- error: m.error
837
+ error: h.error
831
838
  });
832
- if (!_ || _.rowHeaders.length === 0) return /* @__PURE__ */ S(ce, {});
833
- let { measureField: v, headerLabel: y } = n(m.fields, m.object, g), b = h("report.total", "Total"), x = !!f, w = m.dimensionFields ? [...a, ...o].filter((e) => e in m.dimensionFields) : [], T = (n, r, i) => {
834
- let a = m.drillRanges?.[i], o = !!a && Object.keys(a).length > 0, s = m.object && (w.length > 0 || o) ? t(m.drillRawRows?.[i], w, m.dimensionFields ?? {}, u, a) : void 0;
835
- f({
839
+ if (!x || x.rowHeaders.length === 0) return /* @__PURE__ */ E(he, {});
840
+ let { measureField: S, headerLabel: C } = n(h.fields, h.object, v), w = g("report.total", "Total"), T = !!p, O = h.dimensionFields ? [...a, ...o].filter((e) => e in h.dimensionFields) : [], k = (n, r, i) => {
841
+ let a = h.drillRanges?.[i], o = !!a && Object.keys(a).length > 0, s = h.object && (O.length > 0 || o) ? t(h.drillRawRows?.[i], O, h.dimensionFields ?? {}, d, a) : void 0;
842
+ p({
836
843
  dataset: e,
837
844
  groupKey: {
838
845
  ...n,
839
846
  ...r
840
847
  },
841
- runtimeFilter: u,
842
- object: m.object,
848
+ runtimeFilter: d,
849
+ object: h.object,
843
850
  objectFilter: s
844
851
  });
845
- }, E = _.colHeaders.flatMap((e) => l.map((t) => ({
852
+ }, A = x.colHeaders.flatMap((e) => c.map((t) => ({
846
853
  col: e,
847
854
  measure: t,
848
- header: l.length === 1 ? e.label : `${e.label} · ${y(t)}`
849
- }))), D = (e) => m.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows, O = /* @__PURE__ */ new Map();
850
- for (let e of D(a) ?? []) O.set(Q(a, e), e);
851
- let k = /* @__PURE__ */ new Map();
852
- for (let e of D(o) ?? []) k.set(Q(o, e), e);
853
- let A = D([])?.[0], j = O.size > 0, N = k.size > 0;
854
- return /* @__PURE__ */ S("div", {
855
+ header: c.length === 1 ? e.label : `${e.label} · ${C(t)}`
856
+ }))), j = (e) => {
857
+ let t = h.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows;
858
+ return t && l(t, b);
859
+ }, M = /* @__PURE__ */ new Map();
860
+ for (let e of j(a) ?? []) M.set(X(a, e), e);
861
+ let N = /* @__PURE__ */ new Map();
862
+ for (let e of j(o) ?? []) N.set(X(o, e), e);
863
+ let ee = j([])?.[0], P = M.size > 0, R = N.size > 0;
864
+ return /* @__PURE__ */ E("div", {
855
865
  className: "overflow-auto max-h-[70vh] rounded-md border",
856
866
  "data-testid": "dataset-matrix",
857
- children: /* @__PURE__ */ C("table", {
867
+ children: /* @__PURE__ */ D("table", {
858
868
  className: "w-full text-xs",
859
- children: [/* @__PURE__ */ S("thead", {
869
+ children: [/* @__PURE__ */ E("thead", {
860
870
  className: "bg-muted/40",
861
- children: /* @__PURE__ */ C("tr", { children: [
862
- a.map((e) => /* @__PURE__ */ S("th", {
871
+ children: /* @__PURE__ */ D("tr", { children: [
872
+ a.map((e) => /* @__PURE__ */ E("th", {
863
873
  className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
864
- children: y(e)
874
+ children: C(e)
865
875
  }, e)),
866
- E.map((e) => /* @__PURE__ */ S("th", {
876
+ A.map((e) => /* @__PURE__ */ E("th", {
867
877
  className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
868
878
  children: e.header
869
879
  }, `${e.col.id}-${e.measure}`)),
870
- j && l.map((e) => /* @__PURE__ */ S("th", {
880
+ P && c.map((e) => /* @__PURE__ */ E("th", {
871
881
  className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
872
882
  "data-testid": "matrix-total-col-header",
873
- children: l.length === 1 ? b : `${b} · ${y(e)}`
883
+ children: c.length === 1 ? w : `${w} · ${C(e)}`
874
884
  }, `total-${e}`))
875
885
  ] })
876
- }), /* @__PURE__ */ C("tbody", { children: [_.rowHeaders.map((e) => /* @__PURE__ */ C("tr", {
886
+ }), /* @__PURE__ */ D("tbody", { children: [x.rowHeaders.map((e) => /* @__PURE__ */ D("tr", {
877
887
  className: "border-t",
878
888
  children: [
879
- a.map((t) => /* @__PURE__ */ S("td", {
889
+ a.map((t) => /* @__PURE__ */ E("td", {
880
890
  className: "px-2 py-1 whitespace-nowrap font-medium",
881
- children: r(e.key[t])
891
+ children: r(e.display[t], y)
882
892
  }, t)),
883
- E.map((t) => {
884
- let n = _.cells.get(s(e.id, t.col.id)), r = n?.row[t.measure], a = x && n != null;
885
- return /* @__PURE__ */ S("td", {
886
- className: `px-2 py-1 text-right tabular-nums whitespace-nowrap${a ? ` ${le}` : ""}`,
893
+ A.map((t) => {
894
+ let n = x.cells.get(s(e.id, t.col.id)), r = n?.row[t.measure], a = T && n != null;
895
+ return /* @__PURE__ */ E("td", {
896
+ className: `px-2 py-1 text-right tabular-nums whitespace-nowrap${a ? ` ${ge}` : ""}`,
887
897
  "data-testid": a ? "dataset-drill-cell" : void 0,
888
- onClick: a ? () => T(e.key, t.col.key, n.index) : void 0,
889
- children: i(r, v(t.measure)?.format, v(t.measure)?.currency, v(t.measure)?.percentScale)
898
+ onClick: a ? () => k(e.key, t.col.key, n.index) : void 0,
899
+ children: i(r, S(t.measure)?.format, S(t.measure)?.currency, S(t.measure)?.percentScale, y)
890
900
  }, `${t.col.id}-${t.measure}`);
891
901
  }),
892
- j && l.map((t) => /* @__PURE__ */ S("td", {
902
+ P && c.map((t) => /* @__PURE__ */ E("td", {
893
903
  className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
894
904
  "data-testid": "matrix-row-total",
895
- children: i(O.get(e.id)?.[t], v(t)?.format, v(t)?.currency, v(t)?.percentScale)
905
+ children: i(M.get(e.id)?.[t], S(t)?.format, S(t)?.currency, S(t)?.percentScale, y)
896
906
  }, `total-${t}`))
897
907
  ]
898
- }, e.id)), N && /* @__PURE__ */ C("tr", {
908
+ }, e.id)), R && /* @__PURE__ */ D("tr", {
899
909
  className: "border-t bg-muted/30 font-medium",
900
910
  "data-testid": "matrix-total-row",
901
911
  children: [
902
- a.length > 0 && /* @__PURE__ */ S("td", {
912
+ a.length > 0 && /* @__PURE__ */ E("td", {
903
913
  colSpan: a.length,
904
914
  className: "px-2 py-1 whitespace-nowrap",
905
- children: b
915
+ children: w
906
916
  }),
907
- E.map((e) => /* @__PURE__ */ S("td", {
917
+ A.map((e) => /* @__PURE__ */ E("td", {
908
918
  className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
909
- children: i(k.get(e.col.id)?.[e.measure], v(e.measure)?.format, v(e.measure)?.currency, v(e.measure)?.percentScale)
919
+ children: i(N.get(e.col.id)?.[e.measure], S(e.measure)?.format, S(e.measure)?.currency, S(e.measure)?.percentScale, y)
910
920
  }, `${e.col.id}-${e.measure}`)),
911
- j && l.map((e) => /* @__PURE__ */ S("td", {
921
+ P && c.map((e) => /* @__PURE__ */ E("td", {
912
922
  className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
913
923
  "data-testid": "matrix-grand-total",
914
- children: i(A?.[e], v(e)?.format, v(e)?.currency, v(e)?.percentScale)
924
+ children: i(ee?.[e], S(e)?.format, S(e)?.currency, S(e)?.percentScale, y)
915
925
  }, `grand-${e}`))
916
926
  ]
917
927
  })] })]
918
928
  })
919
929
  });
920
930
  }
921
- var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i }) => {
922
- let o = a(e.runtimeFilter ?? e.filter, n), s = e.drilldown === !1 ? void 0 : r, c = de(e.type);
923
- if (c === "joined" && Array.isArray(e.blocks)) return /* @__PURE__ */ S("div", {
931
+ var Ce = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i }) => {
932
+ let o = a(e.runtimeFilter ?? e.filter, n), s = e.drilldown === !1 ? void 0 : r, c = ve(e.type);
933
+ if (c === "joined" && Array.isArray(e.blocks)) return /* @__PURE__ */ E("div", {
924
934
  className: i,
925
935
  "data-testid": "dataset-joined-report",
926
936
  "data-report-name": e.name,
@@ -930,7 +940,7 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
930
940
  gap: 24
931
941
  },
932
942
  children: e.blocks.map((e, n) => {
933
- let r = a(o, e.runtimeFilter ?? e.filter), i = q(e.columns), c = J(e.order), l = de(e.type), u = l === "matrix" && i.length > 0 ? /* @__PURE__ */ S(ge, {
943
+ let r = a(o, e.runtimeFilter ?? e.filter), i = q(e.columns), c = fe(e.order), l = ve(e.type), u = l === "matrix" && i.length > 0 ? /* @__PURE__ */ E(Z, {
934
944
  dataset: String(e.dataset ?? ""),
935
945
  rows: q(e.rows),
936
946
  columnsAcross: i,
@@ -939,7 +949,7 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
939
949
  dataSource: t,
940
950
  onDrill: s,
941
951
  order: c
942
- }) : /* @__PURE__ */ S(ue, {
952
+ }) : /* @__PURE__ */ E(_e, {
943
953
  dataset: String(e.dataset ?? ""),
944
954
  rows: q(e.rows),
945
955
  values: q(e.values),
@@ -949,29 +959,29 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
949
959
  order: c,
950
960
  withTotals: l === "summary" || l === "matrix"
951
961
  });
952
- return /* @__PURE__ */ C("section", {
962
+ return /* @__PURE__ */ D("section", {
953
963
  "data-testid": "dataset-report-block",
954
964
  "data-block-id": e.name ?? `block-${n}`,
955
965
  className: "flex flex-col gap-2 rounded-lg border bg-card p-4",
956
- children: [/* @__PURE__ */ C("header", {
966
+ children: [/* @__PURE__ */ D("header", {
957
967
  className: "flex flex-col gap-0.5",
958
- children: [/* @__PURE__ */ S("h3", {
968
+ children: [/* @__PURE__ */ E("h3", {
959
969
  className: "text-sm font-semibold",
960
- children: K(e.label, e.name ?? `Block ${n + 1}`)
961
- }), e.description ? /* @__PURE__ */ S("p", {
970
+ children: de(e.label, e.name ?? `Block ${n + 1}`)
971
+ }), e.description ? /* @__PURE__ */ E("p", {
962
972
  className: "text-xs text-muted-foreground",
963
- children: K(e.description, "")
973
+ children: de(e.description, "")
964
974
  }) : null]
965
975
  }), u]
966
976
  }, e.name ?? `block-${n}`);
967
977
  })
968
978
  });
969
- let l = q(e.columns), u = J(e.order);
970
- if (c === "matrix" && l.length > 0) return /* @__PURE__ */ S("div", {
979
+ let l = q(e.columns), u = fe(e.order);
980
+ if (c === "matrix" && l.length > 0) return /* @__PURE__ */ E("div", {
971
981
  className: i,
972
982
  "data-testid": "dataset-report",
973
983
  "data-report-name": e.name,
974
- children: /* @__PURE__ */ S(ge, {
984
+ children: /* @__PURE__ */ E(Z, {
975
985
  dataset: String(e.dataset ?? ""),
976
986
  rows: q(e.rows),
977
987
  columnsAcross: l,
@@ -983,18 +993,18 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
983
993
  })
984
994
  });
985
995
  let d = e.chart && typeof e.chart == "object" && e.chart.type ? e.chart : null;
986
- return /* @__PURE__ */ C("div", {
996
+ return /* @__PURE__ */ D("div", {
987
997
  className: `${i ?? ""} flex flex-col gap-3`,
988
998
  "data-testid": "dataset-report",
989
999
  "data-report-name": e.name,
990
1000
  "data-report-presentation": c,
991
- children: [d ? /* @__PURE__ */ S(me, {
1001
+ children: [d ? /* @__PURE__ */ E(xe, {
992
1002
  dataset: String(e.dataset ?? ""),
993
1003
  chart: d,
994
1004
  runtimeFilter: o,
995
1005
  dataSource: t,
996
1006
  order: u
997
- }) : null, /* @__PURE__ */ S(ue, {
1007
+ }) : null, /* @__PURE__ */ E(_e, {
998
1008
  dataset: String(e.dataset ?? ""),
999
1009
  rows: q(e.rows),
1000
1010
  values: q(e.values),
@@ -1005,37 +1015,37 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
1005
1015
  withTotals: c === "summary" || c === "matrix"
1006
1016
  })]
1007
1017
  });
1008
- }, $ = (e) => {
1009
- let { dataSource: t, rows: n, runtimeFilter: r, onDrill: i, className: a } = e, o = c.useContext(p), s = t ?? o?.dataSource, l = e.schema;
1010
- if (l && typeof l == "object" && l.type === "spec-report" && l.report && typeof l.report == "object" && (l = l.report), G(l)) return /* @__PURE__ */ S(_e, {
1011
- report: l,
1018
+ }, Q = (e) => {
1019
+ let { dataSource: t, rows: n, runtimeFilter: r, onDrill: i, className: a } = e, o = u.useContext(h), s = t ?? o?.dataSource, c = e.schema;
1020
+ if (c && typeof c == "object" && c.type === "spec-report" && c.report && typeof c.report == "object" && (c = c.report), K(c)) return /* @__PURE__ */ E(Ce, {
1021
+ report: c,
1012
1022
  dataSource: s,
1013
1023
  runtimeFilter: r,
1014
1024
  onDrill: i,
1015
1025
  className: a
1016
1026
  });
1017
- if (u(l)) {
1027
+ if (f(c)) {
1018
1028
  let e = {
1019
1029
  type: "report-viewer",
1020
- report: d(l),
1030
+ report: p(c),
1021
1031
  data: n ?? [],
1022
1032
  showToolbar: !1
1023
1033
  };
1024
- return /* @__PURE__ */ S("div", {
1034
+ return /* @__PURE__ */ E("div", {
1025
1035
  className: a,
1026
1036
  "data-testid": "report-presentation-bridge",
1027
- children: /* @__PURE__ */ S(W, { schema: e })
1037
+ children: /* @__PURE__ */ E(G, { schema: e })
1028
1038
  });
1029
1039
  }
1030
- return /* @__PURE__ */ S(N, { schema: l });
1040
+ return /* @__PURE__ */ E(R, { schema: c });
1031
1041
  };
1032
1042
  //#endregion
1033
1043
  //#region src/LiveReportExporter.ts
1034
- async function ve(e, t) {
1044
+ async function $(e, t) {
1035
1045
  let { dataSource: n, resource: r, queryParams: i, format: a, exportConfig: o } = t, s = a || e.defaultExportFormat || "pdf";
1036
1046
  try {
1037
1047
  let t = (await n.find(r, i)).data || [];
1038
- return R(s, e, t, {
1048
+ return V(s, e, t, {
1039
1049
  format: s,
1040
1050
  ...e.exportConfigs?.[s],
1041
1051
  ...o
@@ -1053,17 +1063,17 @@ async function ve(e, t) {
1053
1063
  };
1054
1064
  }
1055
1065
  }
1056
- function ye(e, t, n = {}) {
1057
- let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(xe), s = o.map((e) => e.header), c = t.map((e, t) => o.map((n) => {
1066
+ function we(e, t, n = {}) {
1067
+ let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(Ee), s = o.map((e) => e.header), c = t.map((e, t) => o.map((n) => {
1058
1068
  if (n.formula) return n.formula.replace(/\{ROW\}/g, String(t + 2));
1059
1069
  let r = e[n.name];
1060
- return Se(r, n.numberFormat);
1070
+ return De(r, n.numberFormat);
1061
1071
  }));
1062
1072
  if (a && t.length > 0) {
1063
1073
  let n = o.map((n, r) => {
1064
1074
  let i = (e.fields || []).find((e) => e.name === n.name);
1065
1075
  if (i?.aggregation) {
1066
- let e = we(r), n = t.length + 1;
1076
+ let e = ke(r), n = t.length + 1;
1067
1077
  switch (i.aggregation) {
1068
1078
  case "sum": return `=SUM(${e}2:${e}${n})`;
1069
1079
  case "avg": return `=AVERAGE(${e}2:${e}${n})`;
@@ -1077,15 +1087,15 @@ function ye(e, t, n = {}) {
1077
1087
  });
1078
1088
  c.push(n);
1079
1089
  }
1080
- Ee("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
1090
+ je("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
1081
1091
  }
1082
- function be(e, t, n, r) {
1092
+ function Te(e, t, n, r) {
1083
1093
  return async () => {
1084
1094
  let i = e.schedule;
1085
1095
  if (!i?.enabled) return [];
1086
1096
  let a = i.formats || [e.defaultExportFormat || "pdf"], o = [];
1087
1097
  for (let r of a) {
1088
- let i = await ve(e, {
1098
+ let i = await $(e, {
1089
1099
  dataSource: t,
1090
1100
  resource: n,
1091
1101
  format: r
@@ -1095,16 +1105,16 @@ function be(e, t, n, r) {
1095
1105
  return r(e, i), o;
1096
1106
  };
1097
1107
  }
1098
- function xe(e) {
1108
+ function Ee(e) {
1099
1109
  return {
1100
1110
  name: e.name,
1101
1111
  header: e.label || e.name
1102
1112
  };
1103
1113
  }
1104
- function Se(e, t) {
1105
- return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US", Ce(t)) : Te(String(e));
1114
+ function De(e, t) {
1115
+ return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US", Oe(t)) : Ae(String(e));
1106
1116
  }
1107
- function Ce(e) {
1117
+ function Oe(e) {
1108
1118
  if (e.includes("%")) return {
1109
1119
  style: "percent",
1110
1120
  minimumFractionDigits: 0
@@ -1115,23 +1125,23 @@ function Ce(e) {
1115
1125
  maximumFractionDigits: Math.max(0, t - 1)
1116
1126
  };
1117
1127
  }
1118
- function we(e) {
1128
+ function ke(e) {
1119
1129
  let t = "", n = e;
1120
1130
  for (; n >= 0;) t = String.fromCharCode(n % 26 + 65) + t, n = Math.floor(n / 26) - 1;
1121
1131
  return t;
1122
1132
  }
1123
- function Te(e) {
1133
+ function Ae(e) {
1124
1134
  if (e.length > 0) {
1125
1135
  let t = e.charAt(0);
1126
1136
  if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `'${e}`;
1127
1137
  }
1128
1138
  return e;
1129
1139
  }
1130
- function Ee(e, t, n) {
1140
+ function je(e, t, n) {
1131
1141
  let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
1132
1142
  a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
1133
1143
  }
1134
- e.register("report", $, {
1144
+ e.register("report", Q, {
1135
1145
  namespace: "report",
1136
1146
  label: "Report",
1137
1147
  category: "Report",
@@ -1152,7 +1162,7 @@ e.register("report", $, {
1152
1162
  label: "Chart Configuration"
1153
1163
  }
1154
1164
  ]
1155
- }), e.register("spec-report", $, {
1165
+ }), e.register("spec-report", Q, {
1156
1166
  namespace: "report",
1157
1167
  label: "Spec Report",
1158
1168
  category: "Report",
@@ -1165,7 +1175,7 @@ e.register("report", $, {
1165
1175
  type: "string",
1166
1176
  label: "Report Type"
1167
1177
  }]
1168
- }), e.register("report-viewer", W, {
1178
+ }), e.register("report-viewer", G, {
1169
1179
  namespace: "report",
1170
1180
  label: "Report Viewer",
1171
1181
  category: "Report",
@@ -1180,4 +1190,4 @@ e.register("report", $, {
1180
1190
  }]
1181
1191
  });
1182
1192
  //#endregion
1183
- export { _e as DatasetReportRenderer, N as LegacyReportRenderer, $ as ReportRenderer, W as ReportViewer, be as createScheduleTrigger, P as exportAsCSV, L as exportAsExcel, F as exportAsHTML, te as exportAsJSON, I as exportAsPDF, ye as exportExcelWithFormulas, R as exportReport, ve as exportWithLiveData, U as formatValue, G as isDatasetReport, a as mergeFilters };
1193
+ export { Ce as DatasetReportRenderer, R as LegacyReportRenderer, Q as ReportRenderer, G as ReportViewer, Te as createScheduleTrigger, te as exportAsCSV, B as exportAsExcel, z as exportAsHTML, ne as exportAsJSON, re as exportAsPDF, we as exportExcelWithFormulas, V as exportReport, $ as exportWithLiveData, W as formatValue, K as isDatasetReport, a as mergeFilters };