@object-ui/plugin-report 17.3.0 → 17.6.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, buildCategoryOrder as t, buildChartSeries as n, buildDatasetDrillFilter as r, buildDatasetFieldHelpers as i, buildOptionColorMap as a, chartConfigPresentation as o, deriveDimensionLabelMaps as s, dimensionOptionTranslator as c, formatDimensionValue as l, formatMeasure as u, localizeFieldOptions as d, mergeAuthoredSeries as f, mergeFilters as p, pivotBucketId as m, pivotCellKey as h, pivotDimensionValue as g, relabelDimensions as _ } from "@object-ui/core";
2
+ import * as v from "react";
3
+ import y from "react";
4
+ import { isSpecReport as b, specReportToPresentation as x } from "@object-ui/types";
5
+ import { SchemaRenderer as S, SchemaRendererContext as C, toRenderableSchema as w, useDatasetDimensionLabels as T, useDatasetDimensionMeta as E } from "@object-ui/react";
6
+ import { Badge as D, Button as O, Card as k, CardContent as A, CardDescription as j, CardHeader as M, CardTitle as N, Skeleton as P } from "@object-ui/components";
7
+ import { jsx as F, jsxs as I } from "react/jsx-runtime";
8
+ import { AlertTriangle as ee, Download as L, Loader2 as te, Printer as R, RefreshCw as ne, Table2 as re } from "lucide-react";
9
+ import { getCellRenderer as ie, resolveCellRendererType as ae } from "@object-ui/fields";
10
+ import { pickLocalized as oe, useDisplayLocale as z, useObjectTranslation as se, useSafeFieldLabel as B, useSafeTranslate as V } from "@object-ui/i18n";
11
11
  //#region src/LegacyReportRenderer.tsx
12
- var N = ({ schema: t }) => {
12
+ var H = ({ 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__ */ I(k, {
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__ */ I(M, { children: [n && /* @__PURE__ */ F(N, { children: n }), r && /* @__PURE__ */ F(j, { children: r })] }), /* @__PURE__ */ I(A, {
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__ */ F("div", {
23
23
  className: "min-h-[300px] border rounded-lg p-4 bg-background/50",
24
- children: /* @__PURE__ */ S(r, { schema: {
24
+ children: /* @__PURE__ */ F(r, { schema: {
25
25
  ...t.chart,
26
26
  data: t.chart.data || i
27
27
  } })
28
- }) : /* @__PURE__ */ C("div", {
28
+ }) : /* @__PURE__ */ I("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__ */ F("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__ */ F(t, { schema: {
37
37
  type: "grid",
38
38
  rowData: i,
39
39
  columnDefs: a,
40
40
  domLayout: "autoHeight"
41
- } }) : /* @__PURE__ */ S("div", {
41
+ } }) : /* @__PURE__ */ F("div", {
42
42
  className: "overflow-x-auto",
43
- children: /* @__PURE__ */ C("table", {
43
+ children: /* @__PURE__ */ I("table", {
44
44
  className: "w-full text-sm text-left",
45
- children: [/* @__PURE__ */ S("thead", {
45
+ children: [/* @__PURE__ */ F("thead", {
46
46
  className: "text-xs uppercase bg-muted",
47
- children: /* @__PURE__ */ S("tr", { children: a?.map((e) => /* @__PURE__ */ S("th", {
47
+ children: /* @__PURE__ */ F("tr", { children: a?.map((e) => /* @__PURE__ */ F("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__ */ F("tbody", { children: i.map((e, t) => /* @__PURE__ */ F("tr", {
52
52
  className: "bg-background border-b",
53
- children: a?.map((t) => /* @__PURE__ */ S("td", {
53
+ children: a?.map((t) => /* @__PURE__ */ F("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 ce(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 = fe(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
+ K([...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 le(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
+ K(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 U(e, t, n) {
84
+ let r = e.fields || [], i = me(n?.orientation), a = pe(n?.pageSize);
85
+ K(`<!DOCTYPE html>
86
86
  <html>
87
87
  <head>
88
88
  <meta charset="utf-8">
89
- <title>${z(e.title || "Report")}</title>
89
+ <title>${G(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>${G(e.title || "Report")}</h1>
104
+ ${e.description ? `<p class="description">${G(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>${G(e.label || e.name)}</th>`).join("")}</tr></thead>
108
+ <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${G(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 ue(e, t, n) {
114
+ let r = e.fields || [], i = me(n?.orientation), a = pe(n?.pageSize), o = window.open("", "_blank");
115
115
  if (!o) {
116
- F(e, t, {
116
+ U(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>${G(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>${G(e.title || "Report")}</h1>
143
+ ${e.description ? `<p class="description">${G(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>${G(e.label || e.name)}</th>`).join("")}</tr></thead>
147
+ <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${G(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 de(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 = fe(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
+ K("" + [...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 W(e, t, n, r) {
162
162
  switch (e) {
163
163
  case "csv":
164
- P(t, n, r);
164
+ ce(t, n, r);
165
165
  break;
166
166
  case "json":
167
- te(t, n, r);
167
+ le(t, n, r);
168
168
  break;
169
169
  case "html":
170
- F(t, n, r);
170
+ U(t, n, r);
171
171
  break;
172
172
  case "pdf":
173
- I(t, n, r);
173
+ ue(t, n, r);
174
174
  break;
175
175
  case "excel":
176
- L(t, n, r);
176
+ de(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 G(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 fe(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 pe(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 me(e) {
200
200
  return e === "landscape" ? "landscape" : "portrait";
201
201
  }
202
- function H(e, t, n) {
202
+ function K(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 q(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" || he(e)) return ge(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 he(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 ge(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 _e(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 ve(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 J = ({ schema: e, onRefresh: t }) => {
270
+ let { report: n, data: r, showToolbar: i = !0, allowExport: a = !0, allowPrint: o = !0, loading: s = !1 } = e, c = V(), 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
+ W(e, n, r || [], n.exportConfigs?.[e]);
276
+ }, u = c("common.printDialogHint", "Opens your browser’s print dialog (not a PDF export)"), d = () => {
277
277
  window.print();
278
- }, d = () => {
278
+ }, f = () => {
279
279
  t?.();
280
- }, p = (e, t) => oe(r, e, t), w = (e, t) => {
280
+ }, p = (e, t) => ve(r, e, t), m = (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
+ }, h = (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__ */ F(D, {
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 q(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 = ie(ae(n));
323
+ return /* @__PURE__ */ F(r, {
324
324
  value: e,
325
325
  field: n
326
326
  });
327
327
  }
328
- return U(e, t);
328
+ return q(e, t);
329
329
  };
330
- return n ? /* @__PURE__ */ C("div", {
330
+ return n ? /* @__PURE__ */ I("div", {
331
331
  className: "space-y-4",
332
- children: [i && /* @__PURE__ */ C("div", {
332
+ children: [i && /* @__PURE__ */ I("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__ */ I("div", { children: [/* @__PURE__ */ F("h2", {
335
335
  className: "text-lg font-semibold",
336
336
  children: n.title
337
- }), n.description && /* @__PURE__ */ S("p", {
337
+ }), n.description && /* @__PURE__ */ F("p", {
338
338
  className: "text-sm text-muted-foreground",
339
339
  children: n.description
340
- })] }), /* @__PURE__ */ C("div", {
340
+ })] }), /* @__PURE__ */ I("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__ */ I(O, {
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: f,
348
+ children: [/* @__PURE__ */ F(ne, { className: "h-4 w-4 mr-2" }), "Refresh"]
348
349
  }),
349
- o && /* @__PURE__ */ C(h, {
350
+ o && /* @__PURE__ */ I(O, {
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: d,
354
+ "aria-label": `Print: ${u}`,
355
+ title: u,
356
+ children: [/* @__PURE__ */ F(R, { className: "h-4 w-4 mr-2" }), "Print"]
354
357
  }),
355
- a && n.showExportButtons && /* @__PURE__ */ C("div", {
358
+ a && n.showExportButtons && /* @__PURE__ */ I("div", {
356
359
  className: "flex items-center gap-1",
357
360
  children: [
358
- /* @__PURE__ */ C(h, {
361
+ /* @__PURE__ */ I(O, {
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__ */ F(L, { className: "h-4 w-4 mr-2" }), "PDF"]
363
366
  }),
364
- /* @__PURE__ */ C(h, {
367
+ /* @__PURE__ */ I(O, {
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__ */ F(L, { className: "h-4 w-4 mr-2" }), "Excel"]
369
372
  }),
370
- /* @__PURE__ */ C(h, {
373
+ /* @__PURE__ */ I(O, {
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__ */ F(L, { 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__ */ I(k, { children: [/* @__PURE__ */ I(M, { children: [!i && n.title && /* @__PURE__ */ F(N, { children: n.title }), !i && n.description && /* @__PURE__ */ F(j, { children: n.description })] }), /* @__PURE__ */ I(A, {
381
384
  className: "space-y-6",
382
385
  children: [
383
- s && /* @__PURE__ */ C("div", {
386
+ s && /* @__PURE__ */ I("div", {
384
387
  className: "space-y-6",
385
- children: [/* @__PURE__ */ S("div", {
388
+ children: [/* @__PURE__ */ F("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__ */ F(k, { children: /* @__PURE__ */ I(A, {
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__ */ F(P, { className: "h-4 w-20" }), /* @__PURE__ */ F(P, { className: "h-8 w-28" })]
394
397
  }) }, e))
395
- }), /* @__PURE__ */ C("div", {
398
+ }), /* @__PURE__ */ I("div", {
396
399
  className: "space-y-2",
397
- children: [/* @__PURE__ */ S(x, { className: "h-10 w-full" }), [
400
+ children: [/* @__PURE__ */ F(P, { 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__ */ F(P, { 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__ */ I("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__ */ F("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__ */ F("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__ */ F("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__ */ F(k, { children: /* @__PURE__ */ I(A, {
420
423
  className: "p-4",
421
- children: [/* @__PURE__ */ S("div", {
424
+ children: [/* @__PURE__ */ F("div", {
422
425
  className: "text-sm text-muted-foreground",
423
426
  children: e.label || e.name
424
- }), /* @__PURE__ */ S("div", {
427
+ }), /* @__PURE__ */ F("div", {
425
428
  className: "text-2xl font-bold",
426
- children: U(p(e.name, e.aggregation), e)
429
+ children: q(p(e.name, e.aggregation), e)
427
430
  })]
428
431
  }) }, t))
429
432
  }),
430
- e.type === "table" && /* @__PURE__ */ S("div", {
433
+ e.type === "table" && /* @__PURE__ */ F("div", {
431
434
  className: "border rounded-lg overflow-x-auto",
432
- children: /* @__PURE__ */ C("table", {
435
+ children: /* @__PURE__ */ I("table", {
433
436
  className: "w-full text-sm min-w-[600px]",
434
- children: [/* @__PURE__ */ S("thead", {
437
+ children: [/* @__PURE__ */ F("thead", {
435
438
  className: "bg-muted",
436
- children: /* @__PURE__ */ S("tr", { children: e.columns?.map((e, t) => /* @__PURE__ */ S("th", {
439
+ children: /* @__PURE__ */ F("tr", { children: e.columns?.map((e, t) => /* @__PURE__ */ F("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__ */ F("tbody", { children: (() => {
444
+ let t = _e(r || [], n.groupBy || []);
445
+ return t ? t.map((t) => /* @__PURE__ */ I(y.Fragment, { children: [/* @__PURE__ */ F("tr", {
443
446
  className: "bg-muted/60",
444
- children: /* @__PURE__ */ C("td", {
447
+ children: /* @__PURE__ */ I("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,84 @@ 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__ */ F("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__ */ F("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: m(e.name, t[e.name]),
462
+ children: h(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__ */ F("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__ */ F("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: m(e.name, t[e.name]),
469
+ children: h(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__ */ F("div", {
473
476
  className: "prose max-w-none",
474
- children: /* @__PURE__ */ S("p", { children: e.text })
477
+ children: /* @__PURE__ */ F("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__ */ F("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__ */ F(S, { schema: w(e) }, t)) : e.content && /* @__PURE__ */ F(S, { schema: w(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__ */ F("div", {
481
484
  className: "border rounded-lg overflow-x-auto",
482
- children: /* @__PURE__ */ C("table", {
485
+ children: /* @__PURE__ */ I("table", {
483
486
  className: "w-full text-sm min-w-[600px]",
484
- children: [/* @__PURE__ */ S("thead", {
487
+ children: [/* @__PURE__ */ F("thead", {
485
488
  className: "bg-muted",
486
- children: /* @__PURE__ */ S("tr", { children: n.fields?.map((e, t) => /* @__PURE__ */ S("th", {
489
+ children: /* @__PURE__ */ F("tr", { children: n.fields?.map((e, t) => /* @__PURE__ */ F("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__ */ F("tbody", { children: r.map((e, t) => /* @__PURE__ */ F("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__ */ F("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: m(t.name, e[t.name]),
498
+ children: h(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__ */ F(k, { children: /* @__PURE__ */ F(A, {
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 ye(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
+ var be = /* @__PURE__ */ new Set(), xe = () => globalThis.process?.env?.NODE_ENV !== "production";
518
+ function Se(e, t) {
519
+ if (!xe()) return;
520
+ let n = e.filter;
521
+ if (n === void 0) return;
522
+ let r = `${t}:${n && typeof n == "object" ? Object.keys(n).sort().join(",") : String(n)}`;
523
+ be.has(r) || (be.add(r), console.warn(`[ObjectUI] ${t} carries \`filter\`, which is not an authorable key. Did you mean \`filter\` → \`runtimeFilter\`? NO filter was applied — it renders UNFILTERED, showing rows the report was scoped to exclude. \`ReportSchema\` (\`@objectstack/spec\`) is strict and rejects \`filter\`, so this document did not come through the validated path; the renderer no longer reads it either. Fix the producer: rename \`filter\` to \`runtimeFilter\`. (objectui#5137)`));
524
+ }
525
+ function Ce(e) {
526
+ return `Report \`${e.name ?? "(unnamed)"}\``;
527
+ }
528
+ function we(e, t) {
515
529
  return e ? typeof e == "string" ? e : typeof e == "object" && typeof e.default == "string" ? e.default : t : t;
516
530
  }
517
- function q(e) {
531
+ function Y(e) {
518
532
  return Array.isArray(e) ? e.filter((e) => typeof e == "string" && !!e) : [];
519
533
  }
520
- function J(e) {
534
+ function Te(e) {
521
535
  if (!Array.isArray(e)) return;
522
536
  let t = {};
523
537
  for (let n of e) {
@@ -526,21 +540,21 @@ function J(e) {
526
540
  }
527
541
  return Object.keys(t).length > 0 ? t : void 0;
528
542
  }
529
- function se(e, t, n) {
543
+ function Ee(e, t, n) {
530
544
  if (!e) return;
531
545
  let r = /* @__PURE__ */ new Set([...t, ...n]), i = {};
532
546
  for (let [t, n] of Object.entries(e)) r.has(t) && (i[t] = n);
533
547
  return Object.keys(i).length > 0 ? i : void 0;
534
548
  }
535
- function Y(e, t, n, r, i, a, o) {
536
- let [s, l] = c.useState({
549
+ function X(e, t, n, r, i, a, o) {
550
+ let [s, c] = v.useState({
537
551
  status: "idle",
538
552
  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(() => {
553
+ }), l = Ee(o, t, n), u = JSON.stringify(r ?? null), d = JSON.stringify(a ?? null), f = JSON.stringify(l ?? null), p = `${e}|${t.join(",")}|${n.join(",")}|${u}|${d}|${f}`;
554
+ return v.useEffect(() => {
541
555
  let o = i;
542
556
  if (!o || typeof o.queryDataset != "function") {
543
- l({
557
+ c({
544
558
  status: "error",
545
559
  rows: [],
546
560
  error: "This data source does not support dataset queries."
@@ -548,14 +562,14 @@ function Y(e, t, n, r, i, a, o) {
548
562
  return;
549
563
  }
550
564
  if (!e || n.length === 0) {
551
- l({
565
+ c({
552
566
  status: "idle",
553
567
  rows: []
554
568
  });
555
569
  return;
556
570
  }
557
571
  let s = !1;
558
- return l({
572
+ return c({
559
573
  status: "loading",
560
574
  rows: []
561
575
  }), o.queryDataset(e, {
@@ -563,9 +577,9 @@ function Y(e, t, n, r, i, a, o) {
563
577
  measures: n,
564
578
  ...r && Object.keys(r).length > 0 ? { runtimeFilter: r } : {},
565
579
  ...a ? { totals: { groupings: a } } : {},
566
- ...u ? { order: u } : {}
580
+ ...l ? { order: l } : {}
567
581
  }).then((e) => {
568
- s || l({
582
+ s || c({
569
583
  status: "ok",
570
584
  rows: Array.isArray(e?.rows) ? e.rows : [],
571
585
  fields: Array.isArray(e?.fields) ? e.fields : [],
@@ -576,7 +590,7 @@ function Y(e, t, n, r, i, a, o) {
576
590
  totals: Array.isArray(e?.totals) ? e.totals : void 0
577
591
  });
578
592
  }).catch((e) => {
579
- s || l({
593
+ s || c({
580
594
  status: "error",
581
595
  rows: [],
582
596
  error: String(e?.message ?? e)
@@ -584,10 +598,10 @@ function Y(e, t, n, r, i, a, o) {
584
598
  }), () => {
585
599
  s = !0;
586
600
  };
587
- }, [m]), s;
601
+ }, [p]), s;
588
602
  }
589
- function X({ dataset: e }) {
590
- return /* @__PURE__ */ C("div", {
603
+ function De({ dataset: e }) {
604
+ return /* @__PURE__ */ I("div", {
591
605
  className: "flex items-center justify-center rounded-md border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
592
606
  children: [
593
607
  "This report binds the “",
@@ -597,80 +611,80 @@ function X({ dataset: e }) {
597
611
  });
598
612
  }
599
613
  function Z({ status: e, error: t }) {
600
- return e === "error" ? /* @__PURE__ */ C("div", {
614
+ return e === "error" ? /* @__PURE__ */ I("div", {
601
615
  role: "alert",
602
616
  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", {
617
+ children: [/* @__PURE__ */ F(ee, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ F("span", {
604
618
  className: "break-words",
605
619
  children: t
606
620
  })]
607
- }) : /* @__PURE__ */ C("div", {
621
+ }) : /* @__PURE__ */ I("div", {
608
622
  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…"]
623
+ children: [/* @__PURE__ */ F(te, { className: "h-4 w-4 animate-spin" }), " Running report…"]
610
624
  });
611
625
  }
612
- function ce() {
613
- return /* @__PURE__ */ C("div", {
626
+ function Oe() {
627
+ return /* @__PURE__ */ I("div", {
614
628
  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."]
629
+ children: [/* @__PURE__ */ F(re, { className: "h-6 w-6" }), " The dataset returned no rows for this report’s scope."]
616
630
  });
617
631
  }
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, {
632
+ var ke = "cursor-pointer hover:bg-accent/40";
633
+ function Ae({ dataset: e, rows: t, values: n, runtimeFilter: a, dataSource: o, onDrill: s, order: c, withTotals: d }) {
634
+ let f = X(e, t, n, a, o, d && t.length > 0 ? [[]] : void 0, c), { fieldLabel: p } = B(), m = V(), h = z(), g = T(f.object, f.dimensionFields, t);
635
+ if (n.length === 0) return /* @__PURE__ */ F(De, { dataset: e });
636
+ if (f.status === "loading" || f.status === "idle") return /* @__PURE__ */ F(Z, { status: f.status });
637
+ if (f.status === "error") return /* @__PURE__ */ F(Z, {
624
638
  status: "error",
625
639
  error: f.error
626
640
  });
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) => {
629
- let i = {};
630
- 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({
641
+ if (f.rows.length === 0) return /* @__PURE__ */ F(Oe, {});
642
+ let v = !!s && t.length > 0, y = f.dimensionFields ? t.filter((e) => e in f.dimensionFields) : [], b = (n, i) => {
643
+ let o = {};
644
+ for (let e of t) o[e] = n[e];
645
+ let c = f.drillRanges?.[i], l = !!c && Object.keys(c).length > 0, u = f.object && (y.length > 0 || l) ? r(f.drillRawRows?.[i], y, f.dimensionFields ?? {}, a, c) : void 0;
646
+ s({
633
647
  dataset: e,
634
- groupKey: i,
635
- runtimeFilter: s,
648
+ groupKey: o,
649
+ runtimeFilter: a,
636
650
  object: f.object,
637
651
  objectFilter: u
638
652
  });
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", {
653
+ }, { measureField: x, headerLabel: S } = i(f.fields, f.object, p), C = [...t, ...n], w = _(f.rows, g), E = d ? f.totals?.find((e) => Array.isArray(e.dimensions) && e.dimensions.length === 0)?.rows?.[0] : void 0, D = m("report.total", "Total");
654
+ return /* @__PURE__ */ F("div", {
641
655
  className: "overflow-auto max-h-[70vh] rounded-md border",
642
- children: /* @__PURE__ */ C("table", {
656
+ children: /* @__PURE__ */ I("table", {
643
657
  className: "w-full text-xs",
644
- children: [/* @__PURE__ */ S("thead", {
658
+ children: [/* @__PURE__ */ F("thead", {
645
659
  className: "bg-muted/40",
646
- children: /* @__PURE__ */ S("tr", { children: b.map((e) => /* @__PURE__ */ S("th", {
660
+ children: /* @__PURE__ */ F("tr", { children: C.map((e) => /* @__PURE__ */ F("th", {
647
661
  className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
648
- children: y(e)
662
+ children: S(e)
649
663
  }, 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", {
664
+ }), /* @__PURE__ */ I("tbody", { children: [w.map((e, t) => /* @__PURE__ */ F("tr", {
665
+ className: `border-t${v ? ` ${ke}` : ""}`,
666
+ "data-testid": v ? "dataset-drill-row" : void 0,
667
+ onClick: v ? () => b(f.rows[t], t) : void 0,
668
+ children: C.map((t) => /* @__PURE__ */ F("td", {
655
669
  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])
670
+ children: n.includes(t) ? u(e[t], x(t)?.format, x(t)?.currency, x(t)?.percentScale, h) : l(e[t], h)
657
671
  }, t))
658
- }, t)), x && /* @__PURE__ */ C("tr", {
672
+ }, t)), E && /* @__PURE__ */ I("tr", {
659
673
  className: "border-t bg-muted/30 font-medium",
660
674
  "data-testid": "dataset-report-total-row",
661
- children: [a.length > 0 && /* @__PURE__ */ S("td", {
662
- colSpan: a.length,
675
+ children: [t.length > 0 && /* @__PURE__ */ F("td", {
676
+ colSpan: t.length,
663
677
  className: "px-2 py-1 whitespace-nowrap",
664
- children: w
665
- }), o.map((e) => /* @__PURE__ */ S("td", {
678
+ children: D
679
+ }), n.map((e) => /* @__PURE__ */ F("td", {
666
680
  className: "px-2 py-1 tabular-nums whitespace-nowrap",
667
- children: i(x[e], v(e)?.format, v(e)?.currency, v(e)?.percentScale)
681
+ children: u(E[e], x(e)?.format, x(e)?.currency, x(e)?.percentScale, h)
668
682
  }, e))]
669
683
  })] })]
670
684
  })
671
685
  });
672
686
  }
673
- function de(e) {
687
+ function je(e) {
674
688
  switch (e) {
675
689
  case "summary": return "summary";
676
690
  case "matrix": return "matrix";
@@ -678,7 +692,7 @@ function de(e) {
678
692
  default: return "tabular";
679
693
  }
680
694
  }
681
- function fe(e) {
695
+ function Me(e) {
682
696
  switch (e) {
683
697
  case "bar":
684
698
  case "column":
@@ -709,9 +723,9 @@ function fe(e) {
709
723
  };
710
724
  }
711
725
  }
712
- function pe(t) {
713
- let [, n] = c.useReducer((e) => e + 1, 0);
714
- return c.useEffect(() => {
726
+ function Ne(t) {
727
+ let [, n] = v.useReducer((e) => e + 1, 0);
728
+ return v.useEffect(() => {
715
729
  if (e.get(t)) return;
716
730
  let r = typeof e.subscribe == "function" ? e.subscribe(() => {
717
731
  e.get(t) && n();
@@ -719,208 +733,244 @@ function pe(t) {
719
733
  return i && typeof i.then == "function" && i.then(() => n()).catch(() => {}), r;
720
734
  }, [t]), e.get(t);
721
735
  }
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", {
736
+ function Pe(e, t, n) {
737
+ if (!(!Array.isArray(e) || !t)) for (let r of e) {
738
+ if (!r || typeof r != "object") continue;
739
+ let { name: e, label: i } = r;
740
+ if (e === t) return oe(i, n) || void 0;
741
+ }
742
+ }
743
+ function Fe({ dataset: e, chart: r, runtimeFilter: l, dataSource: p, order: m }) {
744
+ let h = typeof r.xAxis == "string" ? r.xAxis : "", g = typeof r.yAxis == "string" ? r.yAxis : "", y = Me(r.type), b = y.kind === "series" || y.kind === "single_value", x = X(e, y.kind === "series" && h ? [h] : [], b && g ? [g] : [], l, p, void 0, m), S = Ne("chart"), { fieldLabel: C, fieldOptionLabel: w } = B(), T = V(), D = z(), { language: O } = se(), k = v.useMemo(() => h ? [h] : [], [h]), A = E(x.object, x.dimensionFields, k), { categoryColors: j, dimensionLabels: M, categoryOrder: N } = v.useMemo(() => {
745
+ if (!A) return {
746
+ categoryColors: null,
747
+ dimensionLabels: null,
748
+ categoryOrder: null
749
+ };
750
+ let { metaByPath: e, relabel: n } = A, r = n[0]?.path, i = r ? e[r] : void 0, o = r ? d(i?.options, c(i, w)) : void 0;
751
+ return {
752
+ categoryColors: a(o),
753
+ dimensionLabels: s(e, n, w),
754
+ categoryOrder: t(o)
755
+ };
756
+ }, [A, w]), P = typeof r.title == "string" ? r.title : void 0;
757
+ if (y.kind === "tabular") return null;
758
+ if (y.kind === "unsupported") return /* @__PURE__ */ I("div", {
726
759
  className: "rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground",
727
760
  "data-testid": "dataset-report-chart-unsupported",
728
761
  children: [
729
762
  "Chart type “",
730
- l.type,
763
+ y.type,
731
764
  "” is not a spec chart type — the grouped table below carries this report’s numbers."
732
765
  ]
733
766
  });
734
- if (l.kind === "series" && !s || !c) return null;
735
- if (d.status === "loading" || d.status === "idle") return /* @__PURE__ */ C("div", {
767
+ if (y.kind === "series" && !h || !g) return null;
768
+ if (x.status === "loading" || x.status === "idle") return /* @__PURE__ */ I("div", {
736
769
  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…"]
770
+ children: [/* @__PURE__ */ F(te, { className: "h-4 w-4 animate-spin" }), " Loading chart…"]
738
771
  });
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", {
772
+ if (x.status === "error" || x.rows.length === 0) return null;
773
+ let { measureField: ee, headerLabel: L } = i(x.fields, x.object, C), R = Pe(r.series, g, O) ?? L(g);
774
+ if (y.kind === "single_value") {
775
+ let e = ee(g);
776
+ return /* @__PURE__ */ I("div", {
743
777
  className: "rounded-md border bg-card p-3",
744
778
  "data-testid": "dataset-report-metric",
745
- children: [m ? /* @__PURE__ */ S("h3", {
779
+ children: [P ? /* @__PURE__ */ F("h3", {
746
780
  className: "mb-2 text-sm font-semibold",
747
- children: m
748
- }) : null, /* @__PURE__ */ C("div", {
781
+ children: P
782
+ }) : null, /* @__PURE__ */ I("div", {
749
783
  className: "flex flex-col gap-0.5 py-2",
750
- children: [/* @__PURE__ */ S("span", {
784
+ children: [/* @__PURE__ */ F("span", {
751
785
  className: "text-2xl font-semibold tabular-nums",
752
- children: i(d.rows[0]?.[c], r?.format, r?.currency, r?.percentScale)
753
- }), /* @__PURE__ */ S("span", {
786
+ children: u(x.rows[0]?.[g], e?.format, e?.currency, e?.percentScale, D)
787
+ }), /* @__PURE__ */ F("span", {
754
788
  className: "text-xs text-muted-foreground",
755
- children: t(c)
789
+ children: R
756
790
  })]
757
791
  })]
758
792
  });
759
793
  }
760
- return f ? /* @__PURE__ */ C("div", {
794
+ if (!S) return null;
795
+ let { data: ne, xAxisKey: re, series: ie } = n(_(x.rows, M), [h], [g], x.fields, { nullCategoryLabel: T("chart.nullCategory", "(None)") }), ae = f(ie, r.series).map((e) => e.dataKey === g ? {
796
+ ...e,
797
+ label: R
798
+ } : e), { title: oe, ...H } = o(r, j);
799
+ return /* @__PURE__ */ I("div", {
761
800
  className: "rounded-md border bg-card p-3",
762
801
  "data-testid": "dataset-report-chart",
763
- children: [m ? /* @__PURE__ */ S("h3", {
802
+ children: [P ? /* @__PURE__ */ F("h3", {
764
803
  className: "mb-2 text-sm font-semibold",
765
- children: m
766
- }) : null, /* @__PURE__ */ S(f, { schema: {
767
- chartType: l.chartType,
768
- data: d.rows,
769
- xAxisKey: s,
770
- series: [{ dataKey: c }],
771
- height: typeof t.height == "number" ? t.height : 280,
772
- isAnimationActive: !1
804
+ children: P
805
+ }) : null, /* @__PURE__ */ F(S, { schema: {
806
+ chartType: y.chartType,
807
+ data: ne,
808
+ xAxisKey: re,
809
+ series: ae,
810
+ height: 280,
811
+ isAnimationActive: !1,
812
+ ...H,
813
+ ...N ? { categoryOrder: N } : {}
773
814
  } })]
774
- }) : null;
815
+ });
775
816
  }
776
817
  function Q(e, t) {
777
- return o(e.map((e) => String(t[e] ?? "∅")));
818
+ return m(e.map((e) => g(t[e])));
778
819
  }
779
- function he(e, t) {
780
- return e.map((e) => r(t[e])).join(" / ");
820
+ function Ie(e, t, n) {
821
+ return e.map((e) => l(t[e], n)).join(" / ");
781
822
  }
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, [
784
- a,
785
- o,
823
+ function Le({ dataset: e, rows: t, columnsAcross: n, values: a, runtimeFilter: o, dataSource: s, onDrill: c, order: d }) {
824
+ let f = X(e, [...t, ...n], a, o, s, [
825
+ t,
826
+ n,
786
827
  []
787
- ], p), h = ee(), { fieldLabel: g } = M(), _ = c.useMemo(() => {
788
- if (m.status !== "ok") return null;
789
- 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];
828
+ ], d), p = V(), { fieldLabel: m } = B(), g = z(), y = T(f.object, f.dimensionFields, [...t, ...n]), b = v.useMemo(() => {
829
+ if (f.status !== "ok") return null;
830
+ let e = [], r = [], i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
831
+ return _(f.rows, y).forEach((s, c) => {
832
+ let l = f.rows[c], u = Q(t, s), d = Q(n, s);
833
+ if (!i.has(u)) {
834
+ i.add(u);
835
+ let n = {}, r = {};
836
+ for (let e of t) n[e] = l[e], r[e] = s[e];
796
837
  e.push({
797
838
  id: u,
798
- label: he(a, c),
799
- key: t
839
+ label: Ie(t, s, g),
840
+ key: n,
841
+ display: r
800
842
  });
801
843
  }
802
- if (!r.has(d)) {
803
- r.add(d);
804
- let e = {};
805
- for (let t of o) e[t] = c[t];
806
- t.push({
844
+ if (!a.has(d)) {
845
+ a.add(d);
846
+ let e = {}, t = {};
847
+ for (let r of n) e[r] = l[r], t[r] = s[r];
848
+ r.push({
807
849
  id: d,
808
- label: he(o, c),
809
- key: e
850
+ label: Ie(n, s, g),
851
+ key: e,
852
+ display: t
810
853
  });
811
854
  }
812
- i.set(s(u, d), {
813
- row: c,
814
- index: l
855
+ o.set(h(u, d), {
856
+ row: l,
857
+ index: c
815
858
  });
816
859
  }), {
817
860
  rowHeaders: e,
818
- colHeaders: t,
819
- cells: i
861
+ colHeaders: r,
862
+ cells: o
820
863
  };
821
864
  }, [
822
- m,
823
- a,
824
- o
865
+ f,
866
+ t,
867
+ n,
868
+ y,
869
+ g
825
870
  ]);
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, {
871
+ if (a.length === 0) return /* @__PURE__ */ F(De, { dataset: e });
872
+ if (f.status === "loading" || f.status === "idle") return /* @__PURE__ */ F(Z, { status: f.status });
873
+ if (f.status === "error") return /* @__PURE__ */ F(Z, {
829
874
  status: "error",
830
- error: m.error
875
+ error: f.error
831
876
  });
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({
877
+ if (!b || b.rowHeaders.length === 0) return /* @__PURE__ */ F(Oe, {});
878
+ let { measureField: x, headerLabel: S } = i(f.fields, f.object, m), C = p("report.total", "Total"), w = !!c, E = f.dimensionFields ? [...t, ...n].filter((e) => e in f.dimensionFields) : [], D = (t, n, i) => {
879
+ let a = f.drillRanges?.[i], s = !!a && Object.keys(a).length > 0, l = f.object && (E.length > 0 || s) ? r(f.drillRawRows?.[i], E, f.dimensionFields ?? {}, o, a) : void 0;
880
+ c({
836
881
  dataset: e,
837
882
  groupKey: {
838
- ...n,
839
- ...r
883
+ ...t,
884
+ ...n
840
885
  },
841
- runtimeFilter: u,
842
- object: m.object,
843
- objectFilter: s
886
+ runtimeFilter: o,
887
+ object: f.object,
888
+ objectFilter: l
844
889
  });
845
- }, E = _.colHeaders.flatMap((e) => l.map((t) => ({
890
+ }, O = b.colHeaders.flatMap((e) => a.map((t) => ({
846
891
  col: e,
847
892
  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", {
893
+ header: a.length === 1 ? e.label : `${e.label} · ${S(t)}`
894
+ }))), k = (e) => {
895
+ let t = f.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows;
896
+ return t && _(t, y);
897
+ }, A = /* @__PURE__ */ new Map();
898
+ for (let e of k(t) ?? []) A.set(Q(t, e), e);
899
+ let j = /* @__PURE__ */ new Map();
900
+ for (let e of k(n) ?? []) j.set(Q(n, e), e);
901
+ let M = k([])?.[0], N = A.size > 0, P = j.size > 0;
902
+ return /* @__PURE__ */ F("div", {
855
903
  className: "overflow-auto max-h-[70vh] rounded-md border",
856
904
  "data-testid": "dataset-matrix",
857
- children: /* @__PURE__ */ C("table", {
905
+ children: /* @__PURE__ */ I("table", {
858
906
  className: "w-full text-xs",
859
- children: [/* @__PURE__ */ S("thead", {
907
+ children: [/* @__PURE__ */ F("thead", {
860
908
  className: "bg-muted/40",
861
- children: /* @__PURE__ */ C("tr", { children: [
862
- a.map((e) => /* @__PURE__ */ S("th", {
909
+ children: /* @__PURE__ */ I("tr", { children: [
910
+ t.map((e) => /* @__PURE__ */ F("th", {
863
911
  className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
864
- children: y(e)
912
+ children: S(e)
865
913
  }, e)),
866
- E.map((e) => /* @__PURE__ */ S("th", {
914
+ O.map((e) => /* @__PURE__ */ F("th", {
867
915
  className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
868
916
  children: e.header
869
917
  }, `${e.col.id}-${e.measure}`)),
870
- j && l.map((e) => /* @__PURE__ */ S("th", {
918
+ N && a.map((e) => /* @__PURE__ */ F("th", {
871
919
  className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
872
920
  "data-testid": "matrix-total-col-header",
873
- children: l.length === 1 ? b : `${b} · ${y(e)}`
921
+ children: a.length === 1 ? C : `${C} · ${S(e)}`
874
922
  }, `total-${e}`))
875
923
  ] })
876
- }), /* @__PURE__ */ C("tbody", { children: [_.rowHeaders.map((e) => /* @__PURE__ */ C("tr", {
924
+ }), /* @__PURE__ */ I("tbody", { children: [b.rowHeaders.map((e) => /* @__PURE__ */ I("tr", {
877
925
  className: "border-t",
878
926
  children: [
879
- a.map((t) => /* @__PURE__ */ S("td", {
927
+ t.map((t) => /* @__PURE__ */ F("td", {
880
928
  className: "px-2 py-1 whitespace-nowrap font-medium",
881
- children: r(e.key[t])
929
+ children: l(e.display[t], g)
882
930
  }, 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}` : ""}`,
887
- "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)
931
+ O.map((t) => {
932
+ let n = b.cells.get(h(e.id, t.col.id)), r = n?.row[t.measure], i = w && n != null;
933
+ return /* @__PURE__ */ F("td", {
934
+ className: `px-2 py-1 text-right tabular-nums whitespace-nowrap${i ? ` ${ke}` : ""}`,
935
+ "data-testid": i ? "dataset-drill-cell" : void 0,
936
+ onClick: i ? () => D(e.key, t.col.key, n.index) : void 0,
937
+ children: u(r, x(t.measure)?.format, x(t.measure)?.currency, x(t.measure)?.percentScale, g)
890
938
  }, `${t.col.id}-${t.measure}`);
891
939
  }),
892
- j && l.map((t) => /* @__PURE__ */ S("td", {
940
+ N && a.map((t) => /* @__PURE__ */ F("td", {
893
941
  className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
894
942
  "data-testid": "matrix-row-total",
895
- children: i(O.get(e.id)?.[t], v(t)?.format, v(t)?.currency, v(t)?.percentScale)
943
+ children: u(A.get(e.id)?.[t], x(t)?.format, x(t)?.currency, x(t)?.percentScale, g)
896
944
  }, `total-${t}`))
897
945
  ]
898
- }, e.id)), N && /* @__PURE__ */ C("tr", {
946
+ }, e.id)), P && /* @__PURE__ */ I("tr", {
899
947
  className: "border-t bg-muted/30 font-medium",
900
948
  "data-testid": "matrix-total-row",
901
949
  children: [
902
- a.length > 0 && /* @__PURE__ */ S("td", {
903
- colSpan: a.length,
950
+ t.length > 0 && /* @__PURE__ */ F("td", {
951
+ colSpan: t.length,
904
952
  className: "px-2 py-1 whitespace-nowrap",
905
- children: b
953
+ children: C
906
954
  }),
907
- E.map((e) => /* @__PURE__ */ S("td", {
955
+ O.map((e) => /* @__PURE__ */ F("td", {
908
956
  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)
957
+ children: u(j.get(e.col.id)?.[e.measure], x(e.measure)?.format, x(e.measure)?.currency, x(e.measure)?.percentScale, g)
910
958
  }, `${e.col.id}-${e.measure}`)),
911
- j && l.map((e) => /* @__PURE__ */ S("td", {
959
+ N && a.map((e) => /* @__PURE__ */ F("td", {
912
960
  className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
913
961
  "data-testid": "matrix-grand-total",
914
- children: i(A?.[e], v(e)?.format, v(e)?.currency, v(e)?.percentScale)
962
+ children: u(M?.[e], x(e)?.format, x(e)?.currency, x(e)?.percentScale, g)
915
963
  }, `grand-${e}`))
916
964
  ]
917
965
  })] })]
918
966
  })
919
967
  });
920
968
  }
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", {
969
+ var Re = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i }) => {
970
+ let a = Ce(e);
971
+ Se(e, a);
972
+ let o = p(e.runtimeFilter, n), s = e.drilldown === !1 ? void 0 : r, c = je(e.type);
973
+ if (c === "joined" && Array.isArray(e.blocks)) return /* @__PURE__ */ F("div", {
924
974
  className: i,
925
975
  "data-testid": "dataset-joined-report",
926
976
  "data-report-name": e.name,
@@ -930,52 +980,53 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
930
980
  gap: 24
931
981
  },
932
982
  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, {
983
+ Se(e, `${a} block \`${e.name ?? n}\``);
984
+ let r = p(o, e.runtimeFilter), i = Y(e.columns), c = Te(e.order), l = je(e.type), u = l === "matrix" && i.length > 0 ? /* @__PURE__ */ F(Le, {
934
985
  dataset: String(e.dataset ?? ""),
935
- rows: q(e.rows),
986
+ rows: Y(e.rows),
936
987
  columnsAcross: i,
937
- values: q(e.values),
988
+ values: Y(e.values),
938
989
  runtimeFilter: r,
939
990
  dataSource: t,
940
991
  onDrill: s,
941
992
  order: c
942
- }) : /* @__PURE__ */ S(ue, {
993
+ }) : /* @__PURE__ */ F(Ae, {
943
994
  dataset: String(e.dataset ?? ""),
944
- rows: q(e.rows),
945
- values: q(e.values),
995
+ rows: Y(e.rows),
996
+ values: Y(e.values),
946
997
  runtimeFilter: r,
947
998
  dataSource: t,
948
999
  onDrill: s,
949
1000
  order: c,
950
1001
  withTotals: l === "summary" || l === "matrix"
951
1002
  });
952
- return /* @__PURE__ */ C("section", {
1003
+ return /* @__PURE__ */ I("section", {
953
1004
  "data-testid": "dataset-report-block",
954
1005
  "data-block-id": e.name ?? `block-${n}`,
955
1006
  className: "flex flex-col gap-2 rounded-lg border bg-card p-4",
956
- children: [/* @__PURE__ */ C("header", {
1007
+ children: [/* @__PURE__ */ I("header", {
957
1008
  className: "flex flex-col gap-0.5",
958
- children: [/* @__PURE__ */ S("h3", {
1009
+ children: [/* @__PURE__ */ F("h3", {
959
1010
  className: "text-sm font-semibold",
960
- children: K(e.label, e.name ?? `Block ${n + 1}`)
961
- }), e.description ? /* @__PURE__ */ S("p", {
1011
+ children: we(e.label, e.name ?? `Block ${n + 1}`)
1012
+ }), e.description ? /* @__PURE__ */ F("p", {
962
1013
  className: "text-xs text-muted-foreground",
963
- children: K(e.description, "")
1014
+ children: we(e.description, "")
964
1015
  }) : null]
965
1016
  }), u]
966
1017
  }, e.name ?? `block-${n}`);
967
1018
  })
968
1019
  });
969
- let l = q(e.columns), u = J(e.order);
970
- if (c === "matrix" && l.length > 0) return /* @__PURE__ */ S("div", {
1020
+ let l = Y(e.columns), u = Te(e.order);
1021
+ if (c === "matrix" && l.length > 0) return /* @__PURE__ */ F("div", {
971
1022
  className: i,
972
1023
  "data-testid": "dataset-report",
973
1024
  "data-report-name": e.name,
974
- children: /* @__PURE__ */ S(ge, {
1025
+ children: /* @__PURE__ */ F(Le, {
975
1026
  dataset: String(e.dataset ?? ""),
976
- rows: q(e.rows),
1027
+ rows: Y(e.rows),
977
1028
  columnsAcross: l,
978
- values: q(e.values),
1029
+ values: Y(e.values),
979
1030
  runtimeFilter: o,
980
1031
  dataSource: t,
981
1032
  onDrill: s,
@@ -983,21 +1034,21 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
983
1034
  })
984
1035
  });
985
1036
  let d = e.chart && typeof e.chart == "object" && e.chart.type ? e.chart : null;
986
- return /* @__PURE__ */ C("div", {
1037
+ return /* @__PURE__ */ I("div", {
987
1038
  className: `${i ?? ""} flex flex-col gap-3`,
988
1039
  "data-testid": "dataset-report",
989
1040
  "data-report-name": e.name,
990
1041
  "data-report-presentation": c,
991
- children: [d ? /* @__PURE__ */ S(me, {
1042
+ children: [d ? /* @__PURE__ */ F(Fe, {
992
1043
  dataset: String(e.dataset ?? ""),
993
1044
  chart: d,
994
1045
  runtimeFilter: o,
995
1046
  dataSource: t,
996
1047
  order: u
997
- }) : null, /* @__PURE__ */ S(ue, {
1048
+ }) : null, /* @__PURE__ */ F(Ae, {
998
1049
  dataset: String(e.dataset ?? ""),
999
- rows: q(e.rows),
1000
- values: q(e.values),
1050
+ rows: Y(e.rows),
1051
+ values: Y(e.values),
1001
1052
  runtimeFilter: o,
1002
1053
  dataSource: t,
1003
1054
  onDrill: s,
@@ -1006,36 +1057,36 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
1006
1057
  })]
1007
1058
  });
1008
1059
  }, $ = (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,
1060
+ let { dataSource: t, rows: n, runtimeFilter: r, onDrill: i, className: a } = e, o = v.useContext(C), s = t ?? o?.dataSource, c = e.schema;
1061
+ if (c && typeof c == "object" && c.type === "spec-report" && c.report && typeof c.report == "object" && (c = c.report), ye(c)) return /* @__PURE__ */ F(Re, {
1062
+ report: c,
1012
1063
  dataSource: s,
1013
1064
  runtimeFilter: r,
1014
1065
  onDrill: i,
1015
1066
  className: a
1016
1067
  });
1017
- if (u(l)) {
1068
+ if (b(c)) {
1018
1069
  let e = {
1019
1070
  type: "report-viewer",
1020
- report: d(l),
1071
+ report: x(c),
1021
1072
  data: n ?? [],
1022
1073
  showToolbar: !1
1023
1074
  };
1024
- return /* @__PURE__ */ S("div", {
1075
+ return /* @__PURE__ */ F("div", {
1025
1076
  className: a,
1026
1077
  "data-testid": "report-presentation-bridge",
1027
- children: /* @__PURE__ */ S(W, { schema: e })
1078
+ children: /* @__PURE__ */ F(J, { schema: e })
1028
1079
  });
1029
1080
  }
1030
- return /* @__PURE__ */ S(N, { schema: l });
1081
+ return /* @__PURE__ */ F(H, { schema: c });
1031
1082
  };
1032
1083
  //#endregion
1033
1084
  //#region src/LiveReportExporter.ts
1034
- async function ve(e, t) {
1085
+ async function ze(e, t) {
1035
1086
  let { dataSource: n, resource: r, queryParams: i, format: a, exportConfig: o } = t, s = a || e.defaultExportFormat || "pdf";
1036
1087
  try {
1037
1088
  let t = (await n.find(r, i)).data || [];
1038
- return R(s, e, t, {
1089
+ return W(s, e, t, {
1039
1090
  format: s,
1040
1091
  ...e.exportConfigs?.[s],
1041
1092
  ...o
@@ -1053,17 +1104,17 @@ async function ve(e, t) {
1053
1104
  };
1054
1105
  }
1055
1106
  }
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) => {
1107
+ function Be(e, t, n = {}) {
1108
+ let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(He), s = o.map((e) => e.header), c = t.map((e, t) => o.map((n) => {
1058
1109
  if (n.formula) return n.formula.replace(/\{ROW\}/g, String(t + 2));
1059
1110
  let r = e[n.name];
1060
- return Se(r, n.numberFormat);
1111
+ return Ue(r, n.numberFormat);
1061
1112
  }));
1062
1113
  if (a && t.length > 0) {
1063
1114
  let n = o.map((n, r) => {
1064
1115
  let i = (e.fields || []).find((e) => e.name === n.name);
1065
1116
  if (i?.aggregation) {
1066
- let e = we(r), n = t.length + 1;
1117
+ let e = Ge(r), n = t.length + 1;
1067
1118
  switch (i.aggregation) {
1068
1119
  case "sum": return `=SUM(${e}2:${e}${n})`;
1069
1120
  case "avg": return `=AVERAGE(${e}2:${e}${n})`;
@@ -1077,15 +1128,15 @@ function ye(e, t, n = {}) {
1077
1128
  });
1078
1129
  c.push(n);
1079
1130
  }
1080
- Ee("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
1131
+ qe("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
1081
1132
  }
1082
- function be(e, t, n, r) {
1133
+ function Ve(e, t, n, r) {
1083
1134
  return async () => {
1084
1135
  let i = e.schedule;
1085
1136
  if (!i?.enabled) return [];
1086
1137
  let a = i.formats || [e.defaultExportFormat || "pdf"], o = [];
1087
1138
  for (let r of a) {
1088
- let i = await ve(e, {
1139
+ let i = await ze(e, {
1089
1140
  dataSource: t,
1090
1141
  resource: n,
1091
1142
  format: r
@@ -1095,16 +1146,16 @@ function be(e, t, n, r) {
1095
1146
  return r(e, i), o;
1096
1147
  };
1097
1148
  }
1098
- function xe(e) {
1149
+ function He(e) {
1099
1150
  return {
1100
1151
  name: e.name,
1101
1152
  header: e.label || e.name
1102
1153
  };
1103
1154
  }
1104
- function Se(e, t) {
1105
- return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US", Ce(t)) : Te(String(e));
1155
+ function Ue(e, t) {
1156
+ return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US", We(t)) : Ke(String(e));
1106
1157
  }
1107
- function Ce(e) {
1158
+ function We(e) {
1108
1159
  if (e.includes("%")) return {
1109
1160
  style: "percent",
1110
1161
  minimumFractionDigits: 0
@@ -1115,19 +1166,19 @@ function Ce(e) {
1115
1166
  maximumFractionDigits: Math.max(0, t - 1)
1116
1167
  };
1117
1168
  }
1118
- function we(e) {
1169
+ function Ge(e) {
1119
1170
  let t = "", n = e;
1120
1171
  for (; n >= 0;) t = String.fromCharCode(n % 26 + 65) + t, n = Math.floor(n / 26) - 1;
1121
1172
  return t;
1122
1173
  }
1123
- function Te(e) {
1174
+ function Ke(e) {
1124
1175
  if (e.length > 0) {
1125
1176
  let t = e.charAt(0);
1126
1177
  if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `'${e}`;
1127
1178
  }
1128
1179
  return e;
1129
1180
  }
1130
- function Ee(e, t, n) {
1181
+ function qe(e, t, n) {
1131
1182
  let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
1132
1183
  a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
1133
1184
  }
@@ -1165,7 +1216,7 @@ e.register("report", $, {
1165
1216
  type: "string",
1166
1217
  label: "Report Type"
1167
1218
  }]
1168
- }), e.register("report-viewer", W, {
1219
+ }), e.register("report-viewer", J, {
1169
1220
  namespace: "report",
1170
1221
  label: "Report Viewer",
1171
1222
  category: "Report",
@@ -1180,4 +1231,4 @@ e.register("report", $, {
1180
1231
  }]
1181
1232
  });
1182
1233
  //#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 };
1234
+ export { Re as DatasetReportRenderer, H as LegacyReportRenderer, $ as ReportRenderer, J as ReportViewer, Ve as createScheduleTrigger, ce as exportAsCSV, de as exportAsExcel, U as exportAsHTML, le as exportAsJSON, ue as exportAsPDF, Be as exportExcelWithFormulas, W as exportReport, ze as exportWithLiveData, q as formatValue, ye as isDatasetReport, p as mergeFilters };